akhauriyash/Code-Regression huggingface dataset:
/**
 * Dont raise your voice, improve your argument.
 * --Desmond Tutu
 */

#include <bits/stdc++.h>
using namespace std;

#define DEBUG
#ifndef DEBUG
#define endl "\n"
#endif

const double PI=3.1415926535897932384626433;
typedef long long ll;
#define fori(n) for(ll i=0; i<(n); i++)

#define cins(s) string s; cin>>s;
#define cini(i) int i; cin>>i;
#define cinll(l) ll l; cin>>l;
#define cind(d) double d; cin>>d;
#define cinai(a, n) vi a(n); fori(n) { cin>>a[i]; }
#define cinall(a, n) vll a(n); fori(n) { cin>>a[i]; }
#define cinas(s, n) vs s(n); fori(n) { cin>>s[i]; }

typedef pair<int, int> pii;
typedef pair<double,double> pdd;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<string> vs;
typedef vector<ll> vll;

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

    vi ans(s.size()+1);

    int cnt=1;
    for(int i=0; i<s.size(); i++) {
        if(s[i]=='<') {
            ans[i+1]=cnt;
            cnt++;
        } else
            cnt=1;
    }

    cnt=1;
    for(int i=s.size()-1; i>=0; i--) {
        if(s[i]=='>') {
            ans[i]=max(cnt, ans[i]);
            cnt++;
        } else
            cnt=1;
    }

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

    cout<<a<<endl;
}


Measured memory_bytes: 2844
x1   = list(map(int, input().split()))
x2   = list(map(int, input().split()))
x3   = list(map(int, input().split()))
card = [x1, x2, x3]

numLen  = int(input())
numList = [int(input()) for _ in range(numLen)]
ans = "No"
for x in range(3):
    for y in range(3):
        for numList_i in range(numLen):
            if card[x][y] == numList[numList_i]:
                card[x][y] = "x"

for i in range(3):
    if card[i][0] == "x" and card[i][1] == "x" and card[i][2] == "x":
        ans = "Yes"
    if card[0][i] == "x" and card[1][i] == "x" and card[2][i] == "x":
        ans = "Yes"

if card[0][0] == "x" and card[1][1] == "x" and card[2][2] == "x":
    ans = "Yes"
if card[0][2] == "x" and card[1][1] == "x" and card[2][0] == "x":
    ans = "Yes"
print(ans)




Measured memory_bytes: 3064
#include <iostream>
using namespace std;
int main(){
    int n,k;
    cin>>n>>k;

    if(n%2==0&&k<=n/2){
        cout<<"YES";
    }else if(n%2==1 && k<=(n+1)/2){
        cout<<"YES";
    }else{
        cout<<"NO";
    }
}

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

int main() {
	int a, b;
	cin >> a >> b;
	if ((a + b) % 2 == 0) {
		cout << (a + b) / 2 << endl;
	}
	else {
		cout << (a + b) / 2 + 1 << endl;
	}
	return 0;
}

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

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

ll dp[101][100001];
int n,m;
int w[101];
int v[101];

ll solve(int x, int p){
    if (x == n) return 0;
    if (dp[x][p] != -1) return dp[x][p];
    if (p+w[x] > m) return dp[x][p] = solve(x+1,p);
    return dp[x][p] = max(v[x]+solve(x+1,p+w[x]),solve(x+1,p));
}

int main(int argc, char const *argv[]) {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n >> m;
    memset(&dp,-1,sizeof(dp));
    for (int i = 0; i < n; i++){
        cin >> w[i] >> v[i];
    }
    cout << solve(0,0) << endl;
    return 0;
}


Measured memory_bytes: 79232
(defvar A (read))
(defvar B (read))
(defvar x (ceiling (max (/ (* 100 A)  8)
                        (/ (* 100 B) 10)) ))

(if (and (< (*  8 x) (* 100 (1+ A)))
         (< (* 10 x) (* 100 (1+ B))) )
    (princ x) (princ -1))

Measured memory_bytes: 3304
//#pragma GCC optimize("03,unroll-loops")
//#pragma GCC target("avx,avx2,fma")

#include<bits/stdc++.h>
typedef long long ll;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ordered_set tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>
#define pb           push_back
#define ff           first
#define ss           second
#define gcd(a, b)    __gcd(a, b)
#define lcm(a, b)    ((a)*((b)/gcd(a,b)))
#define all(v)       v.begin(),v.end()
#define lllim        2147483648
#define Pi           2*acos(0.0)
#define sci(n)	     scanf("%d",&n)
#define scii(n,m)    scanf("%d%d",&n,&m)
#define scl(n)       scanf("%lld",&n)
#define scll(n,m)    scanf("%lld%lld",&n,&m)
#define pii          pair<int,int>
#define pll 	     pair<ll,ll>
#define mem(a,b)     memset(a, b, sizeof(a))
#define fill_(a,b)   fill(a,a+n,b);
#define MOD          1000000007
#define fast_cin     ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define filein       freopen("input.txt","r", stdin)
#define watch(x)     cerr << __LINE__ << ": " << #x << " = " << (x) << '\n'
#define case		 int t,cas=1;cin>>t;while(t--)
#define forn(i,a,n)  for(int i=a;a==0?i<n:i<=n;i++)



/*------------------------------Graph Moves----------------------------*/
//const int fx[]= {+1,-1,+0,+0};
//const int fy[]= {+0,+0,+1,-1};
//const int fx[]= {+0,+0,+1,-1,-1,+1,-1,+1};  // Kings Move
//const int fy[]= {-1,+1,+0,+0,+1,+1,-1,-1}; // Kings Move
//const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
//const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move
/*---------------------------------------------------------------------*/

using namespace std;
using namespace __gnu_pbds;

const int maxn=1e6+5;

bool vis[maxn];
vector<int>pr;

void si()
{
	for(int i=4;i<maxn;i+=2) vis[i]=1;
	
	for(int i=3;i*i<maxn;i+=2)
	{
		if(!vis[i])
		{
			for(int j=i*i;j<maxn;j+=2*i)
				vis[j]=1;
		}
	}
	
	pr.pb(2);
	
	for(int i=3;i<maxn;i+=2)
	{
		if(!vis[i])
			pr.pb(i);
		
	}
	
}


void solve()
{
	si();
	int n;
	cin>>n;
	int ara[n+2];
	
	map<int,int>mpc;
	int p=-1;
    forn(i,0,n)
    {
		cin>>ara[i];
		
		if(ara[i]==1)
		{
			p=1;
		}
		mpc[ara[i]]++;
	}
	
	if(p==1)
	{
		if(mpc[1]==1)
		{
			cout<<1<<endl;
			return;
		}
		else
		{
			cout<<0<<endl;
			return ;
		}
	}
	
	
	vector<int>v;
	map<int,int>mpr;
	forn(i,0,n)
	{
		if(mpc[ara[i]]==1)
		{
			v.pb(ara[i]);
		}
		else
		{
			mpr[ara[i]]=1;
		}
	}
	
	int cnt=0;
	if(v.size())
	{
		sort(all(v));
		//cnt++;
		
		//mpr[v[0]]=1;
		
		for(int i=0;i<(int)v.size();i++)
		{
			bool f=0;
			
			//cout<<v[i]<<" ff "<<endl;
			for(int j=2;j*j<=v[i];j++)
			{
				if(v[i]%j==0)
				{
					if(mpr[j]==1)
					{
						//cnt++;	
						f=1;
						break;
					}
					if(mpr[v[i]/j]==1)
					{
						f=1;
						break;
					}
				}
			}
			
			mpr[v[i]]=1;
			
			if(!f)
			{
				//cout<<v[i]<<" f "<<endl;
				cnt++;
			}
			
		}
	}
	
	
	cout<<cnt<<endl;
	
	
	

}


int main()
{
    fast_cin;
    //case
    {
        //cout<<""<<cas++<<""<<endl;
        solve();
    }

    return 0;
}


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

#define ms(a,x) memset(a,x,sizeof(a))
using namespace std;

typedef long long ll;
struct pp{
	int key;
	pp *l, *r, *p; 
};

pp *root , *NIL;
pp * find(pp *x,int k){
	while(x != NIL &&k != x->key){
		if(k < x->key)
			x = x->l;
		else 
			x = x->r;
	}
	return x;
}

void insert (int k){
	pp *y=NIL;
	pp *x=root;
	pp *z;
	z = (pp *)malloc(sizeof(pp));
	
	z->key=k;
	z->l=NIL;
	z->r=NIL;
	
	
	while(x!=NIL){
		y=x;
		if(z->key < x->key){
			x=x->l;
		}
		else {
			x=x->r;
		}
	}
	
	z->p=y;
	if(y==NIL){
		root = z;
	}else 
		if(z->key < y->key){
			y->l = z;
		}
		else {
			y->r = z;
		}
}

void in(pp *x){
	if(x == NIL) return ;
	in(x->l);
	printf(" %d",x->key);
	in(x->r);
}

void pr(pp *x){
	if(x == NIL) return ;
	printf(" %d",x->key);
	pr(x->l);
	pr(x->r);
}
int main(){
	int n,x;
	string com;
	cin >> n;
	for (int i = 0 ; i < n ; i ++){
		cin>>com;
		if(com[0] == 'f'){
			scanf("%d", &x);
			pp *t= find(root ,x );
			if(t != NIL)cout<<"yes\n";
			else printf("no\n");
		} 
		else if(com == "insert"){
			scanf("%d", &x);
			insert(x);
		}
		else if(com == "print"){
			in(root);
			cout<<endl;
			pr(root);
			cout<<endl;
		}
	}
	return 0;
}




Measured memory_bytes: 22052
/**
 * Author: Deb Natkh Maxim (debnatkh@gmail.com)
 * Date: 02.03.2019
 */

#include <bits/stdc++.h>
#define int long long
#define x first
#define y second
using namespace std;

const int MAXN = 1e5;
vector <int> arr;

unordered_set <int> graph[MAXN];
vector <int> path;

void findEulerPath(int v) {
    while (!graph[v].empty()) {
        int u = *graph[v].begin();
        graph[v].erase(u);
        graph[u].erase(v);
        findEulerPath(u);
    }
    path.push_back(v);
}



signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);

    int n, m;
    cin >> n >> m;
    vector <int> cnt(n, 0);
    for (int i = 0; i < m; i++) {
        int v, u;
        cin >> v >> u;
        graph[v - 1].insert(u - 1);
        graph[u - 1].insert(v - 1);
        cnt[v - 1]++;
        cnt[u - 1]++;
    }
    bool flag = true;
    for (int i = 0; i < n; i++) {
        flag &= (cnt[i] % 2 == 0);
    }
    if (!flag) {
        cout << "No\n";
        return 0;
    }
    if (*max_element(cnt.begin(), cnt.end()) >= 6) {
        cout << "Yes\n";
        return 0;
    }
    if (*max_element(cnt.begin(), cnt.end()) <= 2) {
        cout << "No\n";
        return 0;
    }
    if (count(cnt.begin(), cnt.end(), 4) >= 3) {
        cout << "Yes\n";
        return 0;
    }
    if (count(cnt.begin(), cnt.end(), 4) == 1) {
        cout << "No\n";
        return 0;
    }
    vector <int> fours;
    for (int i = 0; i < n; i++) if (cnt[i] == 4) fours.push_back(i);
    int A = fours[0], B = fours[1];
    findEulerPath(A);
    vector <int> posA, posB;
    reverse(path.begin(), path.end());
    for (int i = 0; i < m; i++) {
        if (path[i] == A) posA.push_back(i);
        if (path[i] == B) posB.push_back(i);
        // cout << ++path[i] << " ";
    }
    // cout << endl;
    int a1 = posA[0], a2 = posA[1];
    int b1 = posB[0], b2 = posB[1];
    A++; B++;
    // cout << A << " " << B << endl;
    // cout << a1 << " " << a2 << " " << b1 << " " << b2 << endl;
    if (b1 >= a2 || b2 <= a2) {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }

    return 0;
}

Measured memory_bytes: 23288
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

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

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

func main() {
	sc.Split(bufio.ScanWords)

	A, B, C, D := getInt(), getInt(), getInt(), getInt()

	ans := min(B, D) - max(A, C)
	if ans < 0 {
		ans = 0
	}
	out(ans)
}


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

int main() {
  string a,b,c;
  cin>>a>>b>>c;
  char A=a[0]-0x20;
  char B=b[0]-0x20;
  char C=c[0]-0x20;
  cout<<A<<B<<C<<endl;
}

Measured memory_bytes: 256
n, k = map(int, input().split())

# num[x]:kで割ってxあまる数が1以上N以下に何個あるか
num = [0 for _ in range(k)]
for i in range(1, n + 1):
    num[i % k] += 1

res = 0
for a in range(k):
    b = (k - a) % k
    c = (k - a) % k
    if (b + c) % k != 0:
        continue
    res += num[a] * num[b] * num[c]

print(res)


Measured memory_bytes: 4632
//#pragma GCC optimize(3)
#pragma comment(linker,"/stack:16777216")
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<list>
#include<stack>
#include<queue>
#include<deque>
#include<functional>
#include<utility>
#include<algorithm>
#include<sstream>
#include<cstring>
#include<cmath>
#include<cctype>
#include<exception>
#include<climits>
#include<cfloat>
#include<iomanip>
#include<bitset>
#include<streambuf>
#include<cstdlib>
#include<ctime>
//#include"functions.h"
//#include"highprecision.h"
#define pb push_back
#define pf push_front
#define ppb pop_back
#define mp make_pair
#define np next_permutation
#define fi first
#define sc second
#define vi vector<int>
#define vll vector<long long>
#define vvi vector<vector<int> >
#define vpi vector<pair<int,int> >
#define pii pair<int,int>
#define pll pair<long long,long long>
#define pff pair<float,float>
#define pdd pair<double,double>
#define psi pair<string,int>
#define pis pair<int,string>
#define ppi pair<pii,int>
#define pdi pair<pii,pii>
#define LN 84757
#define INF 1e9
#define LLINF 1e18
#define MAXINT 0x7fffffff
#define MAXLL 0x7fffffffffffffff
#define EPS 1e-5
#define DEPS 1e-9
#define LDEPS 1e-13
#define MOD 1000000007
#define E 2.7182818284
#define PI 3.1415926535
#define rep(a,b) for(int a=0;a<b;a++)
#define forn(a,n) for(int a=1;a<=n;a++)
#define forr(a,n) for(int a=n;a>=1;a--)
#define repn(a,n,p) for(int a=0;a<n;a+=p)
#define repr(a,n) for(int a=n-1;a>=0;a--)
#define foreach(a,b) for(__typeof(b.begin())a=b.begin();a!=b.end();a++)
#define fillemp(a) memset(a,0,sizeof(a))
#define fillinf(a) memset(a,0x3f,sizeof(a))
#define frestream freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define stdf(a,b) freopen(a,"r",stdin);freopen(b,"w",stdout);
#define inputf(a) freopen(a,"r",stdin);
#define outputf(a) freopen(a,"w",stdout);
#define sz(a) a.size()
#define all(a) a.begin(),a.end()
#define MOD 1000000007
typedef long long ll;
typedef long double ld;
using namespace std;

int main(){
	/*
	int n,m;
	cin>>n>>m;
	cout<<(n+m-1)/m;
	ll n,m,a=0;
	cin>>n>>m;
	rep(i,m){
		int x;
		cin>>x;
		a+=x;
	}
	//cout<<a<<endl;
	if(a>=n)cout<<"Yes";
	else cout<<"No";*/
	ll n,k;
	cin>>n>>k;
	k=min(n,k);
	vector<ll> v;
	rep(i,n){
		ll x;
		cin>>x;
		v.pb(x);
	}
	sort(all(v));
	ll p=n-k,a=0;
	rep(i,p){
		a+=v[i];
	}
	cout<<a;
	return 0;
}

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

long long GCD(long long a, long long b) 
{ 
    if(b==0) 
        return a; 
    return GCD(b, a%b);  
      
}

long long LCM(long long a, long long b)
{
    long long gcd=GCD(a,b);
     return (a*b)/gcd;
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    
    long long i, j, k, n, m, t, x=0, y, z, s=0, c=0, l;
    cin >> n;
    int a[n];
    for(i=0; i<n; i++)
    {
        cin >> a[i];
    }
    sort(a, a+n);
    for(i=n-1; i>=0; i--)
    {
        if(x%2==0)
            s+=a[i];
        else 
            s-=a[i];
        x++;
    }
    cout << s << endl;
}


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

int main(){
    string s,t;
    int count = 0;
    cin>>s>>t;
    int n=s.length();
    int m=t.length();
    int ans=1000000;
    for(int r=0;r<=n-m;r++){
        count = 0;
        for(int i=0;i<m;i++){
            if(s[i+r]!=t[i]){
                count++;
            }
        }
        ans=min(ans,count);
    }
    
    cout<<ans;
}


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

using namespace std;
#define inf 1000000000
#define unvisited -1
#define visited 1
#define eps 1e-9
#define mp make_pair
#define pb push_back
#define pi acos(-1.0)
#define uint64 unsigned long long
#define FastSlowInput ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define debug if(true)
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;

int main(){
	int n,i,j;
	int a,b,d;
	scanf("%d %d",&n,&d);
	int cnt=0;
	while(n--){
		scanf("%d %d",&a,&b);
		ll tot = (ll)a*(ll)a + (ll)b*(ll)b;
		ll comp = (ll)d*(ll)d;
		if(tot <= comp){cnt++;}
	}
	printf("%d\n",cnt);
	
	return 0;
};

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

const int maxn = 1e4, inf = 1e9;
int n, k, l, a[maxn + 3], b[maxn + 3];
char s[maxn + 3], t[maxn + 3];

int _abs(int x) {
	return x < 0 ? -x : x;
}

int solve(int p, int q) {
	int ret = 0;
	for (int i = 0; i + p <= k || i + q <= l; i++) {
		int x = i + p <= k ? a[i + p] : n;
		int y = i + q <= l ? b[i + q] : n;
		ret += _abs(x - y);
	}
	for (int i = 1; p - i >= 1 || q - i >= 1; i++) {
		int x = p - i >= 1 ? a[p - i] : 0;
		int y = q - i >= 1 ? b[q - i] : 0;
		ret += _abs(x - y);
	}
	return ret;
}

int main() {
	scanf("%d %s %s", &n, s + 1, t + 1);
	for (int i = 1; i < n; i++) {
		if (s[i] != s[i + 1]) {
			a[++k] = i;
		}
	}
	for (int i = 0; i < 3; i++) {
		a[++k] = 0, a[++k] = n;
	}
	for (int i = 1; i < n; i++) {
		if (t[i] != t[i + 1]) {
			b[++l] = i;
		}
	}
	for (int i = 0; i < 3; i++) {
		b[++l] = 0, b[++l] = n;
	}
	if (t[1] != s[1]) {
		b[++l] = 0;
	}
	sort(a + 1, a + k + 1);
	sort(b + 1, b + l + 1);
	int ans = inf;
	for (int i = 1; i <= k; i += 2) {
		ans = min(ans, solve(i, 1));
	}
	for (int i = 1; i <= l; i += 2) {
		ans = min(ans, solve(1, i));
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

#define XMAX 1000000000

int main(){
  int n, i, j, k, x, q;
  char buf[32];
  unsigned int *a;
  a = (unsigned int *)malloc(XMAX/8);
  for (i=0; i<XMAX/8/sizeof(int); i++)
    a[i] = 0;
  
  int count=0;
  unsigned int bit[32];
  unsigned int u = 1;
  for (i=0; i<32; i++) {
    bit[i] = u;
    u *= 2;
  }
  
  fgets(buf, 32, stdin);
  n = atoi(buf);
  for (i = 0; i < n; i++){
    fgets(buf, 32, stdin);
    q = atoi(buf);
    x = atoi(strchr(buf, ' '));
    
    if (q==0) {
      if ((a[x/32] & bit[x%32]) == 0) {
	a[x/32] |= bit[x%32];
	count++;
      }
      
      k = count;
      if (k==0) {
	putc_unlocked('0', stdout);
      } else {
	if (k<0) {
	  putc_unlocked('-', stdout);
	  k=-k;
	}
	for (j=1; j*10<=k; j*=10);
	for (;j>0; j/=10) {
	  putc_unlocked('0'+k/j, stdout);
	  k %= j;
	}
      }
      putc_unlocked('\n', stdout);
      
    } else if (q==1){
      if ((a[x/32] & bit[x%32]) == 0)
	putc_unlocked('0', stdout);
      else
	putc_unlocked('1', stdout);
      putc_unlocked('\n', stdout);
    } else { // q==2
      if (a[x/32] & bit[x%32]) {
	count--;
	a[x/32] &= ~bit[x%32];
      }

    }
  }
  return 0;
}



Measured memory_bytes: 123728
import java.util.Scanner;


public class Main 
{

	public static void main(String[] args) 
	{
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		
//		int A[]=new int[N];
//		int B[]=new int[N];
		
		
		int max_num=sc.nextInt();;
		int min_val=sc.nextInt();;
		
		int num=0;
		int val=0;
		for(int i=1;i<N;i++)
		{
			num=sc.nextInt();
			val=sc.nextInt();
			if(max_num<num)
			{
				max_num=num;
				min_val=val;
			}
		}
		System.out.println(max_num+min_val);
		sc.close();
		
	}

}


Measured memory_bytes: 63268
#include <algorithm>
#include <cstdlib>
#include <iostream>
#include <vector>
using namespace std;

class BIT {
private:
	int size;
	vector<long long> bit;
	int mod;

public:
	BIT(int n, int m):size(n), bit(n + 1, 0), mod(m) {}

	void add(int i, int x) {
		while(i <= size) {
			bit[i] += x;
			bit[i] %= mod;
			i += i & -i;
		}
	}

	long long sum(int i) const {
		long long s = 0;
		while(i > 0) {
			s += bit[i];
			i -= i & -i;
		}
		return s % mod;
	}
};

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

	for(int a, b, p; cin >> a >> b >> p && a;) {
		const int num = b - a + 2;

		vector<string> order;
		order.reserve(num);

		for(int i = a; i <= b; ++i) {
			order.emplace_back(to_string(i));
		}

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

		BIT bit(num, p);
		bit.add(1, 1);

		for(const auto &s : order) {
			const int index = stoi(s) - a + 2;
			const auto tmp = bit.sum(index - 1);
			bit.add(index, tmp);
		}

		cout << (bit.sum(num) - 1 + p) % p << endl;
	}

	return EXIT_SUCCESS;
}

Measured memory_bytes: 7444
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int main(void){
    long long a,b,k;
    cin>>a>>b>>k;
    for(long long i=a;i<=b;i++){
        if(i<a+k || b-k<i)cout<<i<<endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int a,b;
    cin >> a >> b;
    if(a>b)
    {
        cout << "a > b\n";
    }else if(a == b)
    cout << "a == b\n";
    else
    cout << "a < b\n";
    return 0;
}


Measured memory_bytes: 3024
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,cnt=0;
  cin >> n;
  int a[n];
  for(int i=0;i<n;i++)cin >> a[i];
  for(int i=0;i<n;i++){
    for(int j=i+1;j<n;j++){
      for(int k=j+1;k<n;k++){
        int t=max(a[i],max(a[j],a[k]));
        int w=a[i]+a[j]+a[k]-t;
        if(w>t && a[i]!=a[j] && a[j]!=a[k] && a[k]!=a[i])cnt++;
      }
    }
  }
  cout << cnt << endl;
}
  

Measured memory_bytes: 3636
N = int(input())
W = [input() for _ in range(N)]
if len(W) != len(set(W)):
    print("No")
    exit()

f = True
for i in range(len(W)-1):
    if W[i][-1] != W[i+1][0]:
        f = False

if not f:
    print("No")
else:
    print("Yes")

Measured memory_bytes: 62484
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(x),end(x)
#define show(obj) {for(auto x:obj)cout<<x<<' ';cout<<endl;}
#define line "----------"
typedef long long ll;
typedef pair<int,int> ip;
typedef pair<ll,ll> lp;
const int inf = 1001001000;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

int main(){
	string s,t; 
	cin>>s>>t;
	if(s == t.substr(0,s.size())){cout<<"Yes"<<endl;}
	else cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 3628
from collections import deque,defaultdict,Counter
from heapq import heapify,heappop,heappush,heappushpop
from copy import copy,deepcopy
from itertools import product,permutations,combinations,combinations_with_replacement
from bisect import bisect_left,bisect_right
from math import sqrt,gcd,ceil,floor,factorial
# from fractions import gcd
from functools import reduce
from pprint import pprint
from statistics import mean,median,mode
import sys
sys.setrecursionlimit(10 ** 6)

INF = float('inf')
mod = 10**9 + 7

def mycol(data,col):
    return [ row[col] for row in data ]

def mysort(data,col,reverse=False):
    data.sort(key=lambda x:x[col],reverse=revese)
    return data

def mymax(data):
    M = -1*float('inf')
    for i in range(len(data)):
        m = max(data[i])
        M = max(M,m)
    return M

def mymin(data):
    m = float('inf')
    for i in range(len(data)):
        M = min(data[i])
        m = min(m,M)
    return m

def mycount(ls,x):
    # lsはソート済みであること
    l = bisect_left(ls,x)
    r = bisect_right(ls,x)
    return (r-l)

def mydictvaluesort(dictionary):
    return sorted( dictionary.items(), key=lambda x:x[1] )

def mydictkeysort(dictionary):
    return sorted( dictionary.items(), key=lambda x:x[0] )

def myoutput(ls,space=True):
    if space:
        if len(ls)==0:
            print(' ')
        elif type(ls[0])==str:
            print(' '.join(ls))
        elif type(ls[0])==int:
            print(' '.join(map(str,ls)))
        else:
            print('Output Error')
    else:
        if len(ls)==0:
            print('')
        elif type(ls[0])==str:
            print(''.join(ls))
        elif type(ls[0])==int:
            print(''.join(map(str,ls)))
        else:
            print('Output Error')

def I():
    return int(input())

def MI():
    return map(int,input().split())

def RI():
    return list(map(int,input().split()))

def CI(n):
    return [ int(input()) for _ in range(n) ]

def LI(n):
    return [ list(map(int,input().split())) for _ in range(n) ]

def S():
    return input()

def MS():
    return input().split()

def RS():
    return list(input())

def CS(n):
    return [ input() for _ in range(n) ]

def LS(n):
    return [ list(input()) for _ in range(n) ]

# ddict = defaultdict(lambda: 0)
# ddict = defaultdict(lambda: 1)
# ddict = defaultdict(lambda: int())
# ddict = defaultdict(lambda: list())
# ddict = defaultdict(lambda: float())


x = I()
ans = 0

p = x//11
q = x%11

ans += p * 2
if q==0:
    ans += 0
elif q <= 6:
    ans += 1
else:
    ans += 2

print(ans)

Measured memory_bytes: 72736
import java.util.Scanner;

public class Main {

	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int n = Integer.parseInt(scan.nextLine());
		int[] arr = new int[n+1];
		int max = 100;
		int sum = 0;
		for(int i = 0 ; i<n ; i++){
			arr[i] = Integer.parseInt(scan.nextLine());
			if(arr[i]>max){
				max = arr[i];
			}
			sum += arr[i];
		}
		scan.close();
		System.out.println(sum - max/2);
	}
}

Measured memory_bytes: 23636
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>
#define ll long long
#define re register
using namespace std;
struct ios{
	template <typename ty> inline ios& operator >> (ty &x)
	{
		register int f=1;x=0;register char c=getchar();
		for(;c<'0'||c>'9';c=getchar()) if(c=='-') f=-1;
		for(;c>='0'&&c<='9';c=getchar()) x=(x<<1)+(x<<3)+(c^48);
		x*=f;return *this;
	}
	template <typename ty>  inline ios& operator << (ty x)
	{
		if(x<0) x=-x,putchar('-');
		if(x>9) *this << x/10;
		putchar(x%10+48);
		return *this;
	}
	inline ios& operator << (char c){putchar(c);return *this;}
}io;
ll n,a[1000],sum,k,fac[1000],tot,b[1000];
inline bool check(ll x)//以x为最大gcd 
{
	for(int i=1;i<=n;i++) b[i] = a[i]%x;//对于每个a[i]找到他的对于x的模数，
	sort(b+1,b+1+n);
	int cnt = 0;
	int l=1,r=n;
	while(l<r)
	{
		
//		int dis = x-b[r];
//		if(b[l] >= dis) cnt += dis,b[l] -= dis,b[r] += dis;
//		else 
//		{
//			cnt += b[l],b[r] += b[l],b[l] -= b[l];
//		}
//		while(b[r]==x) r--;
//		while(b[l]==0) l++;
		int tp = b[l]+b[r];
		if(tp < x)
		{
			cnt += b[l];
			b[r] += b[l];
			b[l] = 0;
			++l;
		}
		else
		{
			cnt += x-b[r];
			b[r] = x;
			--r;
			b[l] = tp - x;//br+bl == tp
			if(b[l]==0) ++l;
		}
	}
//	for(int i=1;i<=n;i++) if(b[i]%x!=0) return false;
	return (b[l]%x==0) && (cnt <= k);
}

int main()
{
	io >> n >> k;
	for(int i=1;i<=n;i++) io >> a[i],sum += a[i];
	ll ans = 1;
	for(ll i=1;i*i<=sum;i++)
	{
		if(sum%i==0) 
		{
//			fac[++tot] = i;
//			if(i!=sum/i) fac[++tot] = sum/i;
			if(check(i)) ans = max(ans,i);
			if(check(sum/i)) ans = max(ans,sum/i);
		}
	}
//	sort(fac+1,fac+1+tot);
//	for(int i=tot;i>=1;i--)
//	{
//		if(check(fac[i]))
//		{
//			io << fac[i];
//			return 0;
//		}
//	}
	io << ans;
	return 0;
}

Measured memory_bytes: 256
def check_right_triangle(side1, side2, side3):
	pow = 2
	if side1**pow == side2**pow + side3**pow:
		return True
	if side2**pow == side3**pow + side1**pow:
		return True
	if side3**pow == side1**pow + side2**pow:
		return True
	return False


def check():
	for i in range(int(raw_input())):
		sides = map(int, raw_input().split())
		if check_right_triangle(sides[0], sides[1], sides[2]):
			print "YES"
		else:
			print "NO"



if __name__ == "__main__":
	check()
	# print check_right_triangle(4, 3, 5)
	# print check_right_triangle(4, 3, 6)
	# print check_right_triangle(8, 8, 8)

Measured memory_bytes: 4236
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
using namespace std;

struct Data{
    int m;
    char io;
    string id;
};

void requireTime(map<string,int> &time, map<string, vector<pair<int, int>>> s){
    auto it = s.begin();
    vector<pair<int, int>> god = s["000"];
    it++;

    for(; it != s.end(); it++){
        rep(i,god.size()){
            vector<pair<int, int>> tmp = it->second;
            rep(j,tmp.size()){
                int left = max(god[i].first, tmp[j].first);
                int right = min(god[i].second, tmp[j].second);
                time[ it->first ] += max(0, right - left);
            }
        }
    }
}

int main(){
    int n;
    while(cin >> n,n){
        int maxi = 0;
        map<string,int> time;//id->?????????????????????
        map<string, vector<pair<int, int>>> seg; //id?????¨?????????
        rep(i,n){
            string id;
            int th,tm,m,d;
            char io,g;

            cin >> m >> g >> d >> th >> g >> tm >> io >> id;
            int time = m * 30 * 24 * 60 + d * 24 * 60 + th * 60 + tm;
            if(io == 'I'){
                seg[id].emplace_back(make_pair(time,-1));
            }else{
                seg[id].back().second = time;
            }
        }
        requireTime(time,seg);
        //show(maxi)
        for(auto it : time){
            maxi = max(maxi,it.second);
        }
        cout << maxi << endl;
    }
}

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

#define int long long
struct Fast {Fast(){cin.tie(0);ios::sync_with_stdio(0);}} fast;
using intpair = pair<int, int>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()

int H, W;

signed main(){
    int k;
    cin >> H >> W >> k;
    
    vector<string> field(H);
    rep(i,H) cin >> field[i];
    
    vector<vector<int>> ans(H, vector<int>(W));
    
    int person = 1;
    int not_found_line = 0;
    int last_found_line = 0;
    rep(y,H){
        int strawberries = count(ALL(field[y]), '#');
        if(strawberries == 0) continue;
        rep(x,W){
            ans[y][x] = person;
            if(field[y][x] == '#' && --strawberries > 0){
                person++;
            }
        }
        person++;
        for(int i = not_found_line; i < y; i++){
            ans[i] = ans[y];
        }
        not_found_line = y + 1;
        last_found_line = y;
    }
    
    for(int i = last_found_line + 1; i < H; i++){
        ans[i] = ans[last_found_line];
    }
    
    rep(i,H){
        rep(j,W) cout << (j ? " " : "") << ans[i][j];
        cout << endl;
    }
}

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

int main(){
  int a,ans;
  cin >> a;
  if(a<10){
    ans=a;
  }else if(a>=10 && a<100){
    ans=9;
  }else if(a>=100 && a<1000){
    ans=a-90;
  }else if(a>=1000 && a<10000){
    ans=909;
  }else if(a>=10000 && a<100000){
    ans=a-9090;
  }else{
    ans=90909;
  }
  cout << ans << endl;
}


Measured memory_bytes: 384
function Main(input){
  input = input.split(" ");
  
  var r = input[0];
  var g = input[1];
  var b = input[2];
  var rgb = parseInt(r + g + b);

  if(rgb%4 == 0){
    console.log("YES");
  }else{
    console.log("NO");
  }
}
 
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include <iostream>
#include <list>
#include <algorithm>
using namespace std;

typedef struct ct
{
    int c;
    int t;
}ct_type;
bool cmp(ct_type a, ct_type b)
{
    return a.c < b.c;
}
int main()
{
    int n, t;
    cin >> n >> t;
    ct_type road[n];
    int num = 0;
    for (int i = 0; i < n; i++)
    {
        int c,t2;
        cin >> c >> t2;
        if(t2 <= t)
        {
            road[num].c=c;
            road[num].t=t2;
            num++;
        }
    }
    if(num==0)
    {
        cout << "TLE" << endl;
        return 0;
    }
    sort(road, road+num, cmp);
    cout << road[0].c << endl;
    
    return 0;
}

Measured memory_bytes: 256
import sys
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


def main():
    A, B = map(int, readline().split())
    print((A+B)%24)


if __name__ == '__main__':
    main()

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

void fnInput(int& rnLowNum, int& rnHighNum)
{
  cin >> rnLowNum >> rnHighNum;
}

void fnDigitGet(int nNum, vector<int>& rvnDigit)
{
  for (int n = rvnDigit.size() - 1; n >= 0; n--)
  {
    rvnDigit[n] = nNum % 10;
    nNum /= 10;
  }
}

int fnPalindromeCnt(int nLowNum, int nHighNum)
{
  int nPlindromeCnt = 0;
  vector<int> vnDigit(5);

  for (int nNum = nLowNum; nNum <= nHighNum; nNum++)
  {
    fnDigitGet(nNum, vnDigit);

    vector<int> vnRevDigit(vnDigit);
    reverse(begin(vnRevDigit), end(vnRevDigit));

    if (vnDigit == vnRevDigit)  nPlindromeCnt++;
  }
  return nPlindromeCnt;
}

int main()
{
  int nLowNum, nHighNum, nMinSum, nMaxSum;
  fnInput(nLowNum, nHighNum);

  cout << fnPalindromeCnt(nLowNum, nHighNum) << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <string>
#include <cstring>
#include <sstream>
#include <cmath>
#include <functional>
#include <fstream>
#include <cstdlib>
typedef long long ll;
const int MOD = 1e9+7;


#define REP(i, N) for (int i = 0; i < (N); i++)
#define REPP(i, a, b) for (int i = (a); i < (b); i++)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define VSORT(c) sort((c).begin(),(c).end())
#define SZ(x) ((int)(x).size())
//vvintを作る　マクロで　 #define vvint(N,M) vector<vector<int>>

using namespace std;


int main(){
    
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,vtmp;
    cin >> N;
    vector<double> v;

    for(int i = 0; i < N;i++){
        cin >> vtmp;
        v.push_back(vtmp);
    }

    VSORT(v);
    reverse(ALL(v));
    
    for(int i = 0; i < N-1; i++){
        double avg = (v[v.size()-1]+v[v.size()-2])/2;
        v.erase(v.end()-1);
        v.erase(v.end()-1);
        v.push_back(avg);
    }


    cout << v[0] << endl;



    

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int64_t N,M,K;
  cin >> N >> M >> K;
  int a=0;int b=0;
  int64_t ans=0;
  std::vector<int64_t> A(N+1);
  std::vector<int64_t> B(M+1);
  A.at(0) = 0;
  B.at(0) = 0;
  for (int i = 1; i < N+1; ++i)
    {
      cin >> a;
      A.at(i) = a+A.at(i-1);
    }
  for (int i = 1; i < M+1; ++i)
    {
      cin >> b;
      B.at(i) = b+B.at(i-1);
    }

  for (int i = 0; i < N+1; ++i){
    int left = 0;
    int right = M;
    for (int x = 0; x < log2(200001)+10; ++x){ 
      int64_t mid = (left+right)/2;
      if(K-A.at(i)<B.at(mid)){
        right = mid ;  
      }else{
        left = mid ;
      }
    }

      if(A.at(i)+B.at(right)<=K){
        ans = max(ans,int64_t(i+right));
      }else if(A.at(i)+B.at(left)<=K){
        ans = max(ans,int64_t(i+left));
      }
  }
  cout << ans << endl;
}




Measured memory_bytes: 6360
// ABC 53 B

#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
using namespace std;

typedef long long ll;

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; }
const long long INF = 1LL<<60;

int main()
{
  string s;
  cin >> s;
  int idx1 = s.find('A');
  int idx2 = s.rfind('Z');

  cout << idx2 - idx1 + 1 << endl;

  return 0;
}


Measured memory_bytes: 640
N, K = gets.split.map(&:to_i)
a = Array.new(10**5 + 1, 0)
N.times do
  ai, bi = gets.split.map(&:to_i)
  a[ai] += bi
end
s = 0
ans = (1..(10**5+1)).find do |i|
  s += a[i]
  s >= K
end
p ans


Measured memory_bytes: 2556
import java.util.*;

public class Main{
  public static void main(String[]args){
    Scanner sc=new Scanner(System.in);
    int a=sc.nextInt();
    int b=sc.nextInt();
    int c=sc.nextInt();
    int ans=0;
    if(b/a>c){
      ans=c;
    }else{
      ans=b/a;
    }
    System.out.println(ans);
  }
}


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

ll cnt[100005];
const int mod=1e9+7;

int main(){
  int n;
  cin>>n;
  rep(i,n) {
    int a;
    cin>>a;
    cnt[a]++;
  }
  ll ans=1;
  if(n%2!=0){
    for(int i=0; i<=n-1; i+=2){
      if(i==0){
	if(cnt[i]!=1){
	cout<<0<<endl;
	return 0;
	}
	continue;
      }
      if(cnt[i]!=2){
	cout<<0<<endl;
	return 0;
      }
      ans=ans*2%mod;
    }
  }
  else{
    for(int i=1; i<=n-1; i+=2){
      if(cnt[i]!=2){
	cout<<0<<endl;
	return 0;
      }
      ans=ans*2%mod;
    }
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 1024
#include <algorithm>
#include <deque>
#include <iostream>
#include <map>
#include <set>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;

int main() {
  ll N;
  cin >> N;
  vector<vector<ll> > to(N), distance(N);
  ll u, v, w;
  for (int i = 0; i < N - 1; i++) {
    cin >> u >> v >> w;
    u--;
    v--;
    to[u].push_back(v);
    distance[u].push_back(w);
    to[v].push_back(u);
    distance[v].push_back(w);
  }
  vector<ll> ans(N, -1);
  ans[0] = 0;
  deque<ll> q;
  q.push_back(0);
  while (!q.empty()) {
    int v = q.front();
    q.pop_front();
    for (int i = 0; i < to[v].size(); i++) {
      int u = to[v][i];
      int w = distance[v][i];
      if (ans[u] != -1) continue;
      ans[u] = (ans[v] + w) % 2;
      q.push_back(u);
    }
  }
  for (auto a : ans) {
    cout << a << endl;
  }
  return 0;
}

Measured memory_bytes: 13184
#include <bits/stdc++.h>
#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define itrep(x) for(auto it=(x).begin();it!=(x).end();it++)
#define Sort(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define vi vector<int>
#define INF (int)1e9
#define INFL 1e18
#define MOD 1000000007
#define pb push_back
#define MP make_pair
#define PI 3.1415926535
typedef long long int ll;
typedef std::pair<int,int> P;
int D=1;
int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

using namespace std;
int n,m;
vector<vector<bool>> v(8,vector<bool>(8,false));

int dfs(int x,vector<bool> visited){
    bool all_visit=true; //全部訪問済みかどうか
    rep(i,0,n){
        if(!visited[i])all_visit=false;
    }
    if(all_visit)return 1;
    
    int ret=0; //答え
    
    rep(i,0,n){//全ての頂点を見る中で
        if(!v[x][i])continue; //そもそも辺が張られてなければ飛ばす
        if(visited[i])continue; //既に訪問済みなら飛ばす
        
        visited[i]=true; //訪問済みにする
        ret+=dfs(i,visited); //その辺を始点にして再帰
        visited[i]=false; //これをしないと、for文回す中で独立した施行にならない
    }
    
    return ret; //retを返すよお
}

int main(){
    cin>>n>>m;
    rep(i,0,m){ //グラフを隣接行列で構築する
        int x,y;
        cin>>x>>y;
        x--; y--;
        v[x][y]=true;
        v[y][x]=true;
    }
    
    vector<bool> visited(8,false); //訪問済みかどうかを格納する配列
    visited[0]=true;
    
    cout<<dfs(0,visited)<<endl;
    
    
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> arr;
typedef vector<arr> matrix;
typedef vector<ll> longarr;
typedef vector<longarr> longmat;
typedef map<int, arr> graph;
typedef vector<char> chararr;
typedef vector<chararr> charmat;
int mod=1000000007;
charmat grid(1000, chararr(1000, ' '));
longmat dp(1000, longarr(1000, 0));
int solve(int h, int w) {
    for(int i=0;i<h;++i){
        if (grid[i][0] != '#') dp[i][0]=1;
        else break;
    }
    for(int i=0;i<w;++i){
    if (grid[0][i] != '#') dp[0][i]=1;
    else break;
    }
	for (int i = 1; i < h; ++i) {
		for (int j = 1; j < w; ++j) {
			if (grid[i][j] != '#') dp[i][j] =( (dp[i][j]%mod) + (dp[i - 1][j]%mod) + (dp[i][j - 1]%mod) )%mod;
		}
	}
	return dp[h - 1][w - 1];

}
int main() {
// #ifndef ONLINE_JUDGE
// 	freopen("input.txt", "r", stdin);
// 	freopen("output.txt", "w", stdout);
// #endif
	int h, w;
	cin >> h >> w;
	for (int i = 0; i < h; ++i) {
		for (int j = 0; j < w; ++j) {
			cin >> grid[i][j];
		}
	}
	cout << solve(h, w);
}

Measured memory_bytes: 12468
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
using LL = long long;
const LL LINF = 1e18;
const double EPS = 1e-10;
using namespace std;
#define COUT(v) cout<<(v)<<endl
#define CIN(n)  int(n);cin >> (n)
#define LCIN(n) LL(n);cin >> (n)
#define SCIN(n) string(n);cin >> (n)
#define YES(n) cout<<((n)? "YES" : "NO")<<endl
#define Yes(n) cout<<((n)? "Yes" : "No")<<endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) <<endl

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)

#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(obj) (obj).begin(),(obj).end()

#define P pair<int,int>
#define I vector<int>
#define pb(v) push_back(v)
#define V vector
#define rt return
#define rmsame(a) sort(ALL(a)),a.erase(unique(ALL(a)), a.end())
#define ENDL cout<<endl
#define MAXE(a,b) a=max(a,b)
#define MINE(a,b) a=min(a,b)

typedef string::const_iterator State;
class PalseError {};
class Edge{
public:
    int from,to,value;
    Edge(LL a,LL b,LL c){
        from = a;
        to = b;
        value = c;
    }
    Edge(LL a,LL b){
        from = a;
        to = b;
    }
};

int main(){
    string str;cin >> str;
    for(int a = 0;a < str.size();a++){
        for(int b = a+1;b <= str.size();b++){
            string s = str;
            s.erase(s.begin()+a,s.begin()+b);
            if(s == "keyence"){
                COUT("YES");
                return 0;
            }
        }
    }
    YES(str == "keyence");
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		while(true) {
			int n = stdIn.nextInt();
			if(n == 0) {
				break;
			}
			int[][] data = new int[n+1][n+1];
			for(int i = 0; i < n; i++) {
				for(int j = 0; j < n; j++) {
					data[i][j] = stdIn.nextInt();
				}
			}
			for(int i = 0; i < n; i++) {
				int sum = 0;
				for(int j = 0; j < n; j++) {
					sum += data[i][j];
				}
				data[i][n] = sum;
			}
			for(int i = 0; i < n+1; i++) {
				int sum = 0;
				for(int j = 0; j < n; j++) {
					sum += data[j][i];
				}
				data[n][i] = sum;
			}
			
			for(int i = 0; i < n+1; i++) {
				for(int j = 0; j < n+1; j++) {
					System.out.printf("%5d",data[i][j]);
				}
				System.out.println();
			}
		}
	}	
}

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

char str[100050];
bool dp[100050];

int main() {
	int N;
	scanf("%d",&N);
	scanf("%s", str);
	int sl = N;
	int dx[] = {0, 1, 0, 1};
	int dy[] = {1, 1, 0, 0};
	int i=0;
	while(i<4){
		dp[0] = dx[i];
		dp[1] = dy[i];
		for (int j = 2; j < sl; j++) {
			if (str[j-1] == 'o') {
				if (dp[j-1] == 1) {
					dp[j] = dp[j-2];
				} else {
					dp[j] = 1 - dp[j-2];
				}
			} else {
				if (dp[j-1] == 1) {
					dp[j] = 1 - dp[j-2];
				} else {
					dp[j] = dp[j-2];
				}
			}
		}
		int lb = 0;
		if (dp[sl - 1] == 1) {
			if (str[sl-1] == 'o') {
				if (dp[sl - 2] == dp[0]) {
					lb++;
				}
			} else {
				if (dp[sl - 2] != dp[0]) {
					lb++;
				}
			}
		} else {
			if (str[sl - 1] == 'x') {
				if (dp[sl - 2] == dp[0]) {
					lb++;
				}
			} else {
				if (dp[sl - 2] != dp[0]) {
					lb++;
				}
			}
		}
		if (dp[0]==1){
			if(str[0]=='o'){
				if(dp[sl-1]==dp[1])lb++;
			} else {
				if(dp[sl-1]!=dp[1])lb++;
			}
		}else{
			if(str[0]=='x'){
				if(dp[sl-1]==dp[1])lb++;
			} else {
				if(dp[sl-1]!=dp[1])lb++;
			}
		}
		if (lb==2) {
			for (int j = 0; j < sl; j++) {
				if (dp[j] == 0) printf("W");
				else printf("S");
			}
			return 0;
		} else i++;
	}
	printf("-1");
}



Measured memory_bytes: 512
from operator import itemgetter
N, *A = map(int, open(0).read().split())
X = [(x-l, x+l) for x, l in zip(*[iter(A)]*2)]
X.sort(key=itemgetter(1))
ans = 0
R = -float('inf')
for l, r in X:
    if R <= l:
        ans += 1
        R = r
print(ans)


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

typedef pair<int, int> P;

int a[100000];
P card[100000];

int max(int a,int b){return a > b ? a : b;}

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

    for(int i = 0; i < n; i++) cin >> a[i];
    for(int i = 0; i < m; i++) {
        int c, b;
        cin >> c >> b;
        card[i] = P(b, c);
    }

    sort(a, a + n);
    sort(card, card + m);
    reverse(card, card + m);

    int t = 0;
    for(int i = 0; i < m; i++) {
        P p = card[i];
        int b = p.first;
        int c = p.second;
        for(int j = 0; j < c; j++) {
            a[t] = max(a[t], b);
            t++;

            if(t == n) break;
        }

        if (t == n) break;
    }

    long long s = 0;
    for(int i = 0; i < n; i++) s += a[i];
    cout << s;
    return 0;
}


Measured memory_bytes: 1408
#include <cstdio>
#include <algorithm>
using namespace std;
const int MAXN=1010000;
const int MOD=1e9+7;
long long n,a,b;
long long c[MAXN];
long long f[MAXN],s[MAXN];
int main()
{
	//freopen("test.in","r",stdin);
	//freopen("test.out","w",stdout);
	scanf("%lld%lld%lld",&n,&a,&b);
	if(a>b)swap(a,b);
	for(int i=1;i<=n;i++)
	{
		scanf("%lld",&c[i]);
		if(i>2&&c[i]-c[i-2]<a)
		{
			printf("0");
			return 0;
		}
	}	
	f[0]=s[0]=1;
	for(int i=1,l=0,r=0;i<=n;i++)
	{
		while(i>1&&c[i]-c[r+1]>=b)r++;
		if(l<=r)
		{	
			f[i]=s[r];
			if(l!=0)f[i]=(f[i]+MOD-s[l-1])%MOD;
		}
		s[i]=(s[i-1]+f[i])%MOD;
		if(i>1&&c[i]-c[i-1]<a)l=i-1;
	}
	long long ans=0;
	for(int i=n;i>=0;i--)
	{
		ans=(ans+f[i])%MOD;
		if(i<n&&a>c[i+1]-c[i])break;
	}
	printf("%lld",ans);
	return 0;
}


Measured memory_bytes: 9088
#include <iostream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <utility>
#include <map>
#include <list>
#include <climits>
#include <set>
#include <deque>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>

// #define cerr if(false)cerr
#define watch(x) cerr << "> " << #x << ": " << x << "\n";

using namespace std;

template <typename T>
std::ostream &operator <<(std::ostream &out, vector<T> &v) {
	for (typename vector<T>::size_type i = 0; i < v.size(); ++i)
		out << v[i] << " ";
	out << "\n";
    return out;
}
template <typename T, typename N>
std::ostream &operator <<(std::ostream &out, vector<pair<T, N> > &v) {
	for (size_t i = 0; i < v.size(); ++i)
		out << "(" << v[i].first << ", " << v[i].second << ") ";
	out << "\n";
    return out;
}
template <typename T>
std::ostream &operator <<(std::ostream &out, vector<vector<T> > &v) {
	for (size_t i = 0; i < v.size(); ++i) {
		for (size_t j = 0; j < v[i].size(); ++j) {
			out << v[i][j] << " ";
		}
		out << "\n";
	}
   	return out;
}

int main() {

	std::ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	int n;
	cin >> n;

	int k = 1;
	while (k * (k + 1) / 2 < n) {
		++k;
	}

	int total = k * (k + 1) / 2;
	vector<int> ans;
	while (k) {
		if (total - k != n) {
			cout << k << "\n";
		} 

		--k;
	}

	return 0;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
// */
using namespace std;
#define int long
signed main(){
  int a,b,k;
  cin>>a>>b>>k;
  for(int i=0;i<k;++i){
    if(i&1)a+=b/2,b/=2;
    else b+=a/2,a/=2;
  }
  cout<<a<<" "<<b;
}

Measured memory_bytes: 256
def get_input():
    while True:
        try:
            yield ''.join(input())
        except EOFError:
            break

N = list(get_input())
for l in range(len(N)):
    p = N[l].split()
    s = []
    for i in range(len(p)):
        if p[i] == "+":
            a = float(s.pop())
            b = float(s.pop())
            s.append(str(b+a))
        elif p[i] == "-":
            a = float(s.pop())
            b = float(s.pop())
            s.append(str(b-a))
        elif p[i] == "*":
            a = float(s.pop())
            b = float(s.pop())
            s.append(str(b*a))
        elif p[i] == "/":
            a = float(s.pop())
            b = float(s.pop())
            s.append(str(b/a))
        else:
            s.append(p[i])
    print(s[0])


Measured memory_bytes: 5584
# region header
import sys
import math
from bisect import bisect_left, bisect_right, insort_left, insort_right
from collections import defaultdict, deque, Counter
from copy import deepcopy
from fractions import gcd
from functools import lru_cache, reduce
from heapq import heappop, heappush
from itertools import accumulate, groupby, product, permutations, combinations, combinations_with_replacement
from math import ceil, floor, factorial, log, sqrt, sin, cos
from operator import itemgetter
sys.setrecursionlimit(10**7)
rs = lambda: sys.stdin.readline().rstrip()
ri = lambda: int(rs())
rf = lambda: float(rs())
rs_ = lambda: [_ for _ in rs().split()]
ri_ = lambda: [int(_) for _ in rs().split()]
rf_ = lambda: [float(_) for _ in rs().split()]
INF = float('inf')
MOD = 10 ** 9 + 7
PI = math.pi
# endregion
A, B = ri_()
print((A-1)*(B-1))

Measured memory_bytes: 63084