akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); i++)
using namespace std;

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

	string s;
	cin >> s;
	reverse(s.begin(), s.end());

	bool ok = true;
	while (true) {
		if (s[0] == 'm') {
			string sub = s.substr(0, 5);
			if ("maerd" != sub) {
				ok = false;
				break ;
			} else
				s.erase(s.begin(), s.begin() + 5);
		} else if (s[0] == 'r') {
			string sub = s.substr(0, 7);
			if ("remaerd" != sub) {
				sub = s.substr(0, 6);
				if ("resare" != sub) {
					ok = false;
					break ;
				} else {
					s.erase(s.begin(), s.begin() + 6);
				}
			} else
				s.erase(s.begin(), s.begin() + 7);
		} else if (s[0] == 'e') {
			string sub = s.substr(0, 5);
			if ("esare" != sub) {
				ok = false;
				break ;
			} else
				s.erase(s.begin(), s.begin() + 5);
		} else {
			ok = false;
			break;
		}
		if (s.size() == 0)
			break ;
	}

	if (ok) cout << "YES" << '\n';
	else cout << "NO" << '\n';
    return 0;
}


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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
typedef long long ll;


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

    vector<int> table(1e7+1,0);
    FOR(x,1,100){
        FOR(y,1,100){
            FOR(z,1,100){
                int n = x*x + y*y + z*z + x*y + y*z + z*x;
                table[n]++;
            }
        }
    }

    FOR(i,1,N+1){
        cout << table[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 42328
#include <bits/stdc++.h>
#include <cstdlib>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main() {
    double r;
    double l;
    cin >> r;
    l = (2 * r) * M_PI;
    cout << l << endl;
    return 0;
}


Measured memory_bytes: 3784
using System;
class Program
{
    public static void Main()
    {
        string[] str = Console.ReadLine().Split(' ');
        int a, b, c;
        a = int.Parse(str[0]);
        b = int.Parse(str[1]);
        c = int.Parse(str[2]);
        bool f = (c >= a) && (c <= b);
        Console.WriteLine(f ? "Yes" : "No");
    }
}

Measured memory_bytes: 13140
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;

#define CIN_ONLY if(1)
struct cww{cww(){
    CIN_ONLY{
        ios::sync_with_stdio(false);cin.tie(0);
    }
}}star;
#define fin "\n"
#define FOR(i,bg,ed) for(int i=(bg);i<(ed);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
#define pb push_back
#define DEBUG if(0)
#define REC(ret, ...) std::function<ret (__VA_ARGS__)>
template <typename T>inline bool chmin(T &l,T r)
{bool a=l>r;if(a)l=r;return a;}
template <typename T>inline bool chmax(T &l,T r)
{bool a=l<r;if(a)l=r;return a;}
template <typename T>
istream& operator>>(istream &is,vector<T> &v){
    for(auto &it:v)is>>it;
    return is;
}

typedef vector<int> V;
typedef vector<V> VV;
typedef pair<int,int> P;
int main(){
    int N,M;
    cin>>N>>M;
    N++;
    VV g(N);
    
    REP(i,M){
        int a,b;
        cin>>a>>b;
        g[a].pb(b);
        g[b].pb(a);
    }
    vector<vector<P>> color(11,vector<P>(N,P(-1,0)));
    int Q;
    cin>>Q;
    REP(i,Q){
        int v,d,c;
        cin>>v>>d>>c;
        color[d][v]=P(i,c);
    }
    int dist=10;
    while(dist>0){
        FOR(i,1,N){
            for(auto &nxt:g[i]){

                chmax(color[dist-1][nxt],color[dist][i]);
            }
            chmax(color[dist-1][i],color[dist][i]);
            //cout<<"("<<color[dist][i].fi<<","<<color[dist][i].se<<") ";
        }//cout<<endl;
        dist--;
    }
    FOR(i,1,N){
        cout<<color[0][i].se<<fin;
    }
}



Measured memory_bytes: 15480
/*╔═══╗──╔╗╔╗───────────────────╔╗────────╔═══╦═══╗
  ║║─║╠╗╠╗╔╣╚═╦══╦═╗╔╦╗╔═╗╔══╦══╣╚═╦╦══╦══╣║─║║║─╚╝
  ║╔═╗║╚╝║╚╣║║║╚╝║║─╔╦╗║║║║╚╝║╚╝║╚╝║║║═╬══║╔═╗║╚╩═║
  ╚╝─╚╩══╩═╩╝╚╩══╩╝─╚╩╝╚╝╚╩══╩══╩══╩╩══╩══╩╝─╚╩═══╝*/

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

#define f(i,k,n) for(i=k;i<n;i++)
#define fd(i,k,n) for(i=k;i>n;i--)
#define pb push_back
#define mp make_pair
#define ll long long
#define ull unsigned long long
#define vi vector<int>
#define vll vector<ll>
#define vvi vector<vi>
#define vvll vector<vll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mii map<int,int>
#define mll map<ll,ll>
#define all(c) c.begin(),c.end()
#define sz(c) (int)c.size()
#define lb lower_bound
#define ub upper_bound
#define gi greater<int>
#define rev reverse
#define ff first
#define ss second
#define yes cout << "YES" << endl
#define no cout << "NO" << endl
#define imp cout << "IMPOSSIBLE" << endl;
#define nl cout << endl
#define hello cout << "hello" << endl;
#define sp(x) fixed << setprecision(x)
#define re return

void dbg_out(){cerr << endl;}
template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T) { cerr << ' ' << H; dbg_out(T...); }
#define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)

const double pi = 3.14159265359;
const ll mod = 1000000007;
const ll modc = 998244353;

ll inline power(ll a, ll b, ll p){
    a %= p;
    ll ans = 1;
    while(b>0){
        if(b & 1)
            ans = (ans*a)%p;
        a = (a*a)%p;
        b >>= 1;
    }
    return ans;
}

ll mod_inv(ll n, ll p){
    return power(n,p-2, p);
}

bool inline isPrime(ll n) {
    if (n <= 1)  return false;
    if (n <= 3)  return true;
    if (n%2 == 0 || n%3 == 0) return false;
    for (ll i=5; i*i<=n; i=i+6)
        if (n%i == 0 || n%(i+2) == 0)
           return false;
    return true;
}
template<typename... T>
void W(T&&... args)
{
	((cout << sp(9) <<  args << " "), ...);
	nl;
}
template<typename... T>
void R(T&&... args)
{
	((cin >> args), ...);
}
ll ston(string s) 
{
	ll a = 0;
	reverse(s.begin(),s.end());
	ll pow = 1;
	for(int i=0;i<s.size();i++)
	{
		a += pow*(s[i]-'0');
		pow*=10;
	}
	return a;
}
template <class T>
string to_binary(T n) 
{
	string binaryNum;
	int i = 0;
	while (n > 0) {
		binaryNum.pb((n % 2)+'0');
		n = n / 2;
		i++;
	}
	reverse(binaryNum.begin(),binaryNum.end());
	return binaryNum;
}
template<class T>
void wv(T &v)
{
	for(auto x : v)
		cout << x << " " ;
	nl;
}
template<class T>
void rv(T &v)
{
	for(int i=0;i<sz(v);i++)
		cin >> v[i];
}
void solve()
{
	int i,j;ll sum = 0,prod = 1;ll maxl = LONG_MIN,minl = LONG_MAX;int maxi = INT_MIN,mini = INT_MAX;
	char c;
	cin >> c;
	if(c >='A' && c<='Z')
		cout << 'A' << endl;
	else
		cout << 'a' << endl;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int t = 1;
	while(t--)
	{
		solve();
	}
}


Measured memory_bytes: 3648
y, k, d = map(int, input().split())
x = abs(y)
if k * d <= x:
    a = x - k * d
else:
    if x % d == 0:
        if (k - (x / d)) % 2 == 0:
            a = 0
        else:
            a = d
    else:
        b = x // d
        if (k - b) % 2 == 0:
            a = x - d * b
        else:
            a = -x + b * d + d
print(a)

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

int main()
{
  ll d, t, s;
  cin >> d >> t >> s;

  bool ans = false;
  if (s * t >= d)
  {
    ans = true;
  }
  cout << (ans ? "Yes" : "No") << endl;
  return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef pair<ii, int> iii;
typedef vector<iii> viii;


int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    vi P(n);
    for (int i = 0; i < n; ++i) {
        int aux;
        cin >> aux;
        P[aux-1] = i+1;
    }
    vi ans1(n), ans2(n);
    ans1[0] = P[0], ans2[0] = 1e9 - n;
    for (int i = 1; i < n; ++i) {
        int targ = 1e9 + P[i] - n;
        int l = ans1[i-1]+1 , r = ans2[i-1]-1;
        if (l+r < targ) {
            l = targ-r;
        } else if (l+r > targ) {
            r = targ-l;
        }
        ans1[i] = l, ans2[i] = r;
    }
    for (int i = 0; i < n; ++i) {
        if (i != 0) cout << " ";
        cout << ans1[i];
    }
    cout << "\n";
    for (int i = 0; i < n; ++i) {
        if (i != 0) cout << " ";
        cout << ans2[i];
    }
    cout << "\n";
    return 0;
}

Measured memory_bytes: 896
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
typedef long long ll;
typedef pair<int, int> P;
 
int main(){
  int n;
  string s, t;
  cin >> n >> s >> t;
  
  for(int i=0; i<n; i++){
    cout << s.at(i) << t.at(i);
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
s = input().split()
A=int(s[0])
B=int(s[1])

def factorization(n):
    p=[]
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
            p.append(i)

    if temp!=1:
        arr.append([temp, 1])
        p.append(temp)

    if arr==[]:
        arr.append([n, 1])
        p.append(n)

    return p
A_fact=[]
B_fact=[]
answer=[]
count=0

A_fact=factorization(A)
B_fact=factorization(B)

for p in A_fact:
    if p in B_fact:
            answer.append(p)
            count+=1
if A==1 and B==1:
    print(count)
else:
    print(count+1)


Measured memory_bytes: 3316
S = list(input())
#print(S)
#print(len(S))

a=int((len(S)-1)/2)

def is_kaibun(kaibun):
    for i in range(len(kaibun)//2):
        if kaibun[i] != kaibun[-i-1]:
            return False
    return True

if is_kaibun(S) and is_kaibun(S[:a]) and is_kaibun(S[a+1:]):
        print('Yes')

else:
    print('No')


Measured memory_bytes: 2940
while True:
    
    h,w = map(int,input().split())
    if h == 0 and w == 0:
        break
    else:
        for j in range(h):
            if j % 2 == 0:
                for i in range(w):
                    if i % 2 == 0:
                        print("#",end="")
                    else:
                        print(".",end="")
                print()
            else:
                for i in range(w):
                    if i % 2 == 1:
                        print("#",end="")
                    else:
                        print(".",end="")
                print()
        print()


Measured memory_bytes: 7000
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		String s = scanner.next();
		for(int i=0;i<s.length();i++){
			if(i % 2 == 0){
				System.out.print(s.charAt(i));
			}
		}
		System.out.println();
	}

}


Measured memory_bytes: 34380
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
using ll=long long;

int main(){
    int n,m,x,i,j,ans=0;
    cin>>n>>m>>x;
    vector<int> c(n);
    vector<vector<int>> a(n,vector<int>(m));
    for(i=0;i<n;i++){
        cin>>c[i];
        ans+=c[i];
        for(j=0;j<m;j++){
            cin>>a[i][j];
        }
    }
    int bit;
  ans++;
    int bk=ans;
    for(bit=0;bit<(1<<n);++bit){
        int flag=0;
        vector<int> test(m,x);
        int sum_c=0;
        for(i=0;i<n;i++){
            if(bit&(1<<i)){
                for(j=0;j<m;j++){
                    test[j]-=a[i][j];
                }
                sum_c+=c[i];
            }
        }
        for(i=0;i<m;i++){
            if(test[i]>0){
                flag=1;
            }
        }
        if(flag==0 && ans>sum_c) ans=sum_c;
    }
    if(ans==bk) ans=-1;
    cout<<ans;
    return 0;
}



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

int main()
{
    int n; cin >> n;
    int n1 = n, sum = 0;
    while(n1) {
        sum += n1%10;
        n1 /= 10;
    }
    cout << (n % sum == 0 ? "Yes":"No") << endl;
    return 0;
}


Measured memory_bytes: 3636
import bisect
import sys
import math
import itertools
sys.setrecursionlimit(10000)

INF = float('inf')

# input macro
def i():
    return int(raw_input())
def ii():
    return map(int,raw_input().split(" "))
def ilist():
    return map(int,list(raw_input()))
def s():
    return raw_input()
def ss():
    return raw_input().split(" ")
def slist():
    return list(raw_input())
#

def join(s):
    return ''.join(s)

#iterate macro
def piter(n,m):
    return itertools.permutations(n,m)
def citer(n,m):
    return itertools.combinations(n,m)

#modulo macro
def modc(a,b,m):
    c = 1
    for i in xrange(b):
        c = c * (a - i) % m
        c = c * modinv(i + 1,m) % m
    return c
 
def gcd(a, b):
    (x, lastx) = (0, 1)
    (y, lasty) = (1, 0)
    while b != 0:
        q = a // b
        (a, b) = (b, a % b)
        (x, lastx) = (lastx - q * x, x)
        (y, lasty) = (lasty - q * y, y)
    return (lastx, lasty, a)
 
def modinv(a, m):
    (inv, q, gcd_val) = gcd(a, m)
    return inv % m

#bisect macro
def index(a, x):
    #Locate the leftmost value exactly equal to x
    i = bisect_left(a, x)
    if i != len(a) and a[i] == x:
        return i
    return -1

#memoize macro
def memoize(f):
    cache = {}
    def helper(*args):
        if args not in cache:
            cache[(args)] = f(*args)
        return cache[args]
    return helper

@memoize
def nck(a,b,m):
    b = min([a-b,b])
    if (b>a or b<0 or a<0):
        return 0
    elif a == 0:
        return 1
    return (nck(a-1,b-1,m)+nck(a-1,b,m)) % m

nh=zip([1,0,-1,0],[0,1,0,-1])

###########

sl=ilist()
n=len(sl)
sm=0
for j in range(n+1):
    for k in range(j+1,n+1):
        p=int(join(map(str,sl[j:k])))
        if j==0 and k==n:
            sm+=p
        elif j!=0 and k==n:
            sm+=p*(2**(j-1))
        elif j==0 and k!=n:
            sm+=p*(2**(n-k-1))
        else:
            sm+=p*(2**(j+n-k-2))

print sm


Measured memory_bytes: 2824
#include <bits/stdc++.h>
using namespace std;
int u[128][14];
const char* d = "SHCD";
int main() {
    int n; cin >> n;
    for (int i = 0; i < n; i++) {
        char c; int d;
        cin >> c >> d;
        u[c][d] = true;
    }
    for (int i = 0; i < 4; i++) {
        for (int j = 1; j <= 13; j++) {
            if (!u[d[i]][j]) {
                cout << d[i] << " " << j << endl;
            }
        }
    }
}


Measured memory_bytes: 3052
#include <stdio.h>

int main(){
  int H,W,i,j;
  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++){
        printf("#");
      }
      printf("\n");
    }
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 572
#include <bits/stdc++.h>
#define rep(i,n) for(int64_t i=0;i < (int64_t)(n);i++)
#define invrep(i,n) for(int64_t i=n-1;i >= 0;i--)
#define _GLIBCXX_DEBUG
using namespace std;

int main(){
  int64_t n,m;
  cin >> n >> m;
  cout << (n*(n-1)+m*(m-1))/2 << endl;
}


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

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


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

int main(void){
  int A, B, C;
  cin >> A >> B >> C;
  
  int ansX = max(max(A, B), C);
  int Y = ansX + 1;
  
  if ((3 * ansX - A - B -C) % 2 == 0) {
    cout << (3 * ansX - A - B -C) / 2 << endl;
  }
  else {
    cout <<  (3*Y - A - B -C) / 2 << endl;
  }
  
  
}

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

int main() {
    int a,b,k;
    int c,d,ck,dk;
    cin>>a>>b>>k;

    for(int i=0;i<k;++i){
        ck =(a+1) / 2;
        c = a/2;
        a -= ck;
        b += c;
        ++i;
        if(i>=k)break;
        dk =(b+1) / 2;
        d = b/2;
        a += d;
        b -= dk;
    }

    cout<<a<<" "<<b<<endl;

}





Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;

int main(){
    string s;
    cin >> s;
    int n=s.length();
    int rcount=0, lcount=0;
    int rgather,lgather;
    int turn=0;
    int flag=0;
    int bucket[1000200];

    for(int i=0;i<n;i++){
        if(turn==0){
            if(s[i]=='R') {
                flag=0;
                rcount++;
                turn=1;
            }
            else if(flag==0){
                flag=1;
                rgather=i-1;
                lgather=i;
                bucket[rgather]+=rcount;
                rcount=0;
                bucket[lgather]+=(lcount+1);
                lcount=0;
                turn=0;
            }
            else{
                bucket[rgather]++;
                turn=1;
            }
            continue;
        }

        if(turn==1){
            if(s[i]=='R'){
                if(flag){
                    turn=0;
                    i--;
                    continue;
                }
                lcount++;
                turn=0;
            }
            else if(flag==0){
                flag=1;
                rgather=i-1;
                lgather=i;
                bucket[rgather]+=rcount;
                rcount=0;
                bucket[lgather]+=(lcount+1);
                lcount=0;
                turn=0;
            }
            else{
                bucket[lgather]++;
                turn=0;
            }
        }
    }

    for(int i=0;i<n;i++){
        printf("%d",bucket[i]);
        if(i==n-1)  printf("\n");
        else        printf(" ");
    }
    
    
    /* 
    printf("%d\n",s.length()); これでおっけ
    cout << s << endl;
    */
    return 0;
}

Measured memory_bytes: 2944
#include <stdio.h>
#include <string.h>

void readInt(int *x) {
	scanf("%d", x);
	return;
}
void readInts(int n, int arr[]) {
	int i;
	for (i=0;i<n;i++) {
		readInt(&arr[i]);
	}
}
void readChar(char *x) {
	scanf("%c", x);
	return;
}
void readChars(char x[]) {
	scanf("%s", x);
	return;
}
void printInts(int n, int *arr) {
	int i;
	for (i=0;i<n;i++) {
		printf("%d ", arr[i]);
	}
	printf("\n");
	return;
}

int main(int argc, char const *argv[])
{
	char s[256];
	char *p = s;
	readChars(s);
	while (*p++!='\0') {
		//printf("%c", *p);
		printf("x");
	}
	printf("\n");

	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b) - 1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)

#define PB push_back
#define INF INT_MAX/3
#define ALL(a) (a).begin(),(a).end()
#define CLR(a) memset(a,0,sizeof(a))

typedef long long int ll;

using namespace std;

int main(){
    while(true){
	ll n;
	ll m;
	cin >> n;
	if(n==0) break;
	m = 0;
	int x = 1;
	while(n>0){
	    int mo = n % 8;
	    if(mo >= 5){
		m += (2 + (n % 8) )*x ;
	    }else if(mo >= 4){
		m += (1 + (n % 8))*x ;
	    }else{
		m += (n % 8)*x ;
	    }
	    x *= 10;
	    n /= 8;
	}
	cout << m << endl;
    }
    return 0;
}

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

int main()
{
    int N, M;
    cin >> N >> M;
    vector<int> H(N);
    for(int i=0;i<N;i++){
        cin >> H[i];
    }
    int Ai, Bi;
    vector<bool> good(N, true);
    for(int i=0;i<M;i++){
        cin >> Ai >> Bi;
        Ai--; Bi--;
        if(H[Ai] >= H[Bi]) good[Bi] = false;
        if(H[Ai] <= H[Bi]) good[Ai] = false;
    }
    int res = 0;
    for(auto v : good){
        if(v) res++;
    }
    cout << res << endl;

    return 0;
}

Measured memory_bytes: 3732
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,k,i;
    cin>>a>>b>>k;
    for(i=min(a,b);i>=1;i--)
    {
        if(a%i==0&&b%i==0)
        {
            k--;
        }
        if(k==0)
        {
            cout<<i<<endl;
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 768
#include<cstdio>
#include<algorithm>

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

using namespace std;

const int M=1000000007;

int main(){
	int n,W; scanf("%d%d",&n,&W);
	int w[200];
	rep(i,n) scanf("%d",w+i);

	sort(w,w+n);

	int ans=0;
	int dp[10001]={1},p=n-1;
	rep(i,W+1){ // 総重量 i の解を調べる
		int rem=i; // 絶対に入れないといけない品物を入れたあと、残りの品物を入れるべき重量
		rep(j,n) if(W-i>=w[j]) rem-=w[j];
		if(rem<0) continue;

		while(p>=0 && W-i<w[p]){
			for(int j=W;j>=w[p];j--) dp[j]=(dp[j]+dp[j-w[p]])%M;
			p--;
		}
		ans=(ans+dp[rem])%M;
	}

	printf("%d\n",ans);

	return 0;
}

Measured memory_bytes: 0
import math
n,d = [int (i) for i in input().split()]
a=[]
for i in range(n):
  x,y = [float(i) for i in input().split()]
  a.append(math.sqrt(x**2+y**2))

count = 0
for i in a:
  if i <= d:
    count+=1
print(count)

Measured memory_bytes: 17080
#include<bits/stdc++.h>
#define ll long long 
#define OJ \
        freopen("input.txt","r",stdin); \
        freopen("output.txt","w",stdout);
using namespace std;
int mod=1000000007;
int main()
{
//OJ;
 
ll a,b,c,d;
cin>>a>>b>>c>>d;
vector<ll > v;
v.push_back(a*c);
v.push_back(a*d);
v.push_back(b*c);
v.push_back(b*d);
sort(v.begin(),v.end());
cout<<v[3];


 }
     


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

int main(void){
    ll a, b;
    cin >> a >> b;

    if(a > 8 || b > 8){
        cout << ":(" << endl;
    }else{
        cout << "Yay!"<< endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main()
{
	char l[100005];
	scanf("%s", l);
	long long int p = 1000000007;
	int n = strlen(l);
	int i;
	long long int pow2[100005], pow3[100005];
	pow2[0] = pow3[0] = 1;
	for (i = 1; i < 100005; i++)
	{
		pow2[i] = 2 * pow2[i - 1];
		pow2[i] %= p;
		pow3[i] = 3 * pow3[i - 1];
		pow3[i] %= p;
	}
	long long int ans = pow3[n];
	int count1 = 0;
	for (i = 0; i < n; i++)
	{
		if (l[i] == '1')
			count1++;
		else
		{
			ans -= pow2[count1] * pow3[n - i - 1] * 2;
			ans %= p;
			if (ans < 0)
				ans += p;
		}
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;


int main() { 
    int n;
    cin >> n;
    int x1 = 0, y1 = 0;
    int flag = 1;
    int t1 = 0;
    for (int i = 0; i < n; i++) {
        int t2, x2, y2;
        cin >> t2 >> x2 >> y2;
        int dist = abs(x2 - x1) + abs(y2 - y1);
        if (dist > (t2 - t1) || (t2 - t1 - dist) % 2 == 1) {
            flag = 0;
        }
        x1 = x2, y1 = y2;
        t1 = t2;
    }
    if (flag == 1)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}




Measured memory_bytes: 3580
#include<bits/stdc++.h>
#include<vector>
#include<cstring>
#include<iostream>
#include<cstdio>
#define ull unsigned long long
#define ll long long
const int maxn=100000;
using namespace std;
priority_queue<int,vector<int>,greater<int>>q;
struct A{
 int x,y;
bool  operator < (A qq)
  {
      return y>qq.y;
  }
}z[100003];
int main()
{
   int n,m;
   cin>>n>>m;
   for(int i=1;i<=n;i++)
   {
       int a;
       scanf("%d",&a);
       q.push(a);
   }
   for(int i=1;i<=m;i++)
   {
       int a,b;
       scanf("%d%d",&z[i].x,&z[i].y);
   }
   sort(z+1,z+1+m);
   for(int i=1;i<=m;i++)
     while(q.top()<z[i].y&&z[i].x)
   {
       z[i].x--;
       q.pop();
       q.push(z[i].y);
   }
   ll sum=0;
   while(!q.empty())
   {
       sum+=(ll)(q.top());
       q.pop();
   }
   cout<<sum<<endl;
}


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

int main(){
	string s;
	cin >> s;
	string x;
	int ans;
	int n = 3;
	while(n--){
		x += s[0];
	}
	if(x >= s){
		ans = 100*(x[0]-'0') + 10*(x[1]-'0') + 1*(x[2]-'0');
	}else{
		n=3;
		while(n--){
			x[n] = s[0]+'1'-'0';
		}
		ans = 100*(x[0]-'0') + 10*(x[1]-'0') + 1*(x[2]-'0');
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define de_x(x) cout<<"debug_val: "<<x<<endl;
#define de_ve(x) for(auto it: x) cout<<it<<" ";
#define rep(i,a,n) for (int i=a;i<n;i++)
#define _rep(i,a,n) for (int i=a;i<=n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
typedef long long ll;
typedef vector<int> VI;
typedef pair<int,int> PII;
typedef double db;
std::mt19937 mrand(random_device{}());
int rnd(int x) { return mrand() % x ; }
const ll mod=1000000007;
ll ksm(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
int _;
/***********************/
int a[105];
void run(){
}
int main(){
//	for(scanf("%d",&_); _;_--) run();	
	int n ,r,ans =mod;
    cin>> n ;
    _rep(i,1,n){
        cin>> a[i];
     } 
    sort(a+1,a+n+1);
    _rep(i,1,a[n]){
        int cur = 0;
        _rep(j,1,n){
            cur += ksm(a[j] - i,2);
        }
        ans = min(ans,cur);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES 1
#define _EXT_CODECVT_SPECIALIZATIONS_H 1
#define _EXT_ENC_FILEBUF_H 1
#include <bits/stdc++.h>
#include <bits/extc++.h>
using namespace std;
using namespace __gnu_pbds;
#define MOD 998244353ll
#define INF 1000000000000000000ll
#define EPS 1e-9

#define getchar_unlocked _getchar_nolock
#define putchar_unlocked _putchar_nolock

typedef long long         ll;
typedef long double       ld;
typedef pair <ll,ll>      pl;
typedef tuple <ll,ll,ll>  tl;

ll N, A[300005], S, X[300005], Y[300005], M;
std::priority_queue <ll> pq;

int main() {
    
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    cin >> N;
    for (ll i = 1; i <= 3*N; i++) cin >> A[i];
    
    S = 0;
    for (ll i = 1; i <= N; i++) {
    	S += A[i];
    	pq.push(-A[i]);
	}
	X[N] = S;
	for (ll i = N+1; i <= 2*N; i++) {
		S += A[i];
		pq.push(-A[i]);
		S += pq.top();
		pq.pop();
		X[i] = S;
	}
	
	while (!pq.empty()) pq.pop();
	
	S = 0;
	for (ll i = 3*N; i > 2*N; i--) {
		S += A[i];
		pq.push(A[i]);
	}
	Y[2*N+1] = S;
	for (ll i = 2*N; i > N; i--) {
		S += A[i];
		pq.push(A[i]);
		S -= pq.top();
		pq.pop();
		Y[i] = S;
	}
	
	M = -INF;
	for (ll i = N; i <= 2*N; i++) {
		M = max(M, X[i] - Y[i+1]);
	}
	
	cout << M;
    
    return 0;
}

Measured memory_bytes: 6900
#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;++i)
#include<string>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<int, int>P;
//max=({});
//条件式が真ならwhileの中身を回し続ける
//printf("%d\n", ans);


int g[15][15];
const int INF = 1001001001;
const int dx[4] = { -1,0,1,0 };
const int dy[4] = { 0,-1,0,1 };

//最大公約数
ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}

//素因数分解
vector<pair<ll, int>>factorize(ll n) {
	vector<pair<ll, int>>res;
	for (ll i = 2;i * i <= n;++i) {
		if (n % i)continue;
		res.emplace_back(i, 0);
		while (n % i == 0) {
			n /= i;
			res.back().second++;
		}
	}
	if (n != 1)res.emplace_back(n, 1);
	return res;
}

int dp[1010][1010];
int bingo[3][3];
bool flag[3][3];

int main() {
	int n, q;
	cin >> n >> q;
	string s;
	cin >> s;
	vector<int>l(q), r(q), AC(n);
	rep(i, q) {
		cin >> l[i] >> r[i];
	}
	for (int i = 0;i < n - 1;++i) {
		if (s[i] == 'A' && s[i + 1] == 'C')AC[i + 1]++;
		AC[i + 2] = AC[i + 1];
	}
	rep(i, q) {
		ll ans = AC[r[i] - 1] - AC[l[i] - 1];
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 2176
#include <cstdio>
#include <algorithm>
#include <vector>
#define file(x) freopen(#x".in", "r", stdin), freopen(#x".out", "w", stdout)

inline int read()
{
	int data = 0, w = 1; char ch = getchar();
	while (ch != '-' && (ch < '0' || ch > '9')) ch = getchar();
	if (ch == '-') w = -1, ch = getchar();
	while (ch >= '0' && ch <= '9') data = data * 10 + (ch ^ 48), ch = getchar();
	return data * w;
}

const int N(1e5 + 10), M(3e5 + 10);
struct node { int l, r; } q[M];
inline int Len(const node &a) { return a.r - a.l + 1; }
inline int operator < (const node &a, const node &b) { return Len(a) < Len(b); }
int n, m, c[N];
void Add(int x, int v) { for (; x <= n; x += x & -x) c[x] += v; }
int Sum(int x) { int s = 0; for (; x; x -= x & -x) s += c[x]; return s; }

int main()
{
	m = read(), n = read();
	for (int i = 1; i <= m; i++) q[i] = (node) {read(), read()};
	std::sort(q + 1, q + m + 1);
	for (int i = 1, j = 0, sum = 0; i <= n; i++, sum = 0)
	{
		while (j < m && Len(q[j + 1]) <= i)
			++j, Add(q[j].l, 1), Add(q[j].r + 1, -1);
		for (int k = i; k <= n; k += i) sum += Sum(k);
		printf("%d\n", sum + m - j);
	}
	return 0;
}


Measured memory_bytes: 3584
#include<iostream>
#include<vector>
#include<algorithm>
#include<time.h>
using namespace std;

//?????°

//???????????????
int H;
int point;
vector<int> block[5];

//?????¨??????
clock_t start,now;

int getNum(int col, int row) {
	if(row<block[col].size())
		return block[col][row];
	else
		return 1000*col+row;   //?¢?????????????????????§??????????????°???
}

void chain(int row) {
	bool canDelete; //?¶????????????????????????????

	//?¶???????(????????????????????¨??§????????????????????????)
	for (int range = 5; 2<range ; range--) {
		//?¶??????????
		for (int col = 0; col < 6 - range; col++) {
			canDelete=true;
			//??¨??¨??????????????????
			for (int i = col+1; i < col+range; i++) 
				//1?????§???????????¨????????°?¶??????????
				if(getNum(col,row)!=getNum(i,row)){
					canDelete=false;
					break;
			}
			//?¶????????????§????????°
			if (canDelete) {
				//??????????¨????????????????
				point+=getNum(col,row)*range;
				//??¨??¨?¶????
				for (int i = col; i < col + range; i++) {
					block[i].erase(block[i].begin()+row);
				}
				//???????????¢??°??????
				return;
			}
		}
	}


	//5????¶???????
	canDelete=true;
	for(int i=1;i<5;i++)
		if(getNum(0,row)!=getNum(i,row)){
			canDelete=false;
			break;
		}
	if (canDelete) {
		point+=block[0][row]*5;
		for (int i = 0; i < 5; i++)
			block[i].erase(block[i].begin()+row);
		return;
	}
	//4????¶???????
}

int main() {
	while (true) {
		//?????????
		point=0;
		for (int i = 0; i < 5; i++)
			while(block[i].size()>0)
				block[i].pop_back();
		//??\???
		cin>>H;
		if(H==0)break;
		for (int i = 0; i < H; i++) {
			int temp;//??????????????????????????°
			for (int j = 0; j < 5; j++) {
				cin>>temp;
				block[j].push_back(temp);
			}
		}
		//????????????0?????????????????????????????????
		for(int i=0;i<5;i++)reverse(block[i].begin(),block[i].end());


		//?????????????????????????????£????????????
		int tempPoint=point;
		while(true){
			for (int i = H; i >= 0; i--) {
				chain(i);

			}
			now=clock();

			if(tempPoint==point)break;
			else tempPoint=point;
		}
		cout<<point<<endl;
	}
	return 0;
}

Measured memory_bytes: 3132
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)
input = sys.stdin.readline
INF = 2**62-1


def read_int():
    return int(input())


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


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


def warshall_floyd(g, N):
    d = g
    for k in range(N):
        for i in range(N):
            for j in range(N):
                if d[i][j] > d[i][k] + d[k][j]:
                    d[i][j] = d[i][k] + d[k][j]

    return d


@mt
def slv(H, W, S):
    ans = 0
    g = [[INF] *(H*W) for _ in range(H*W)]
    def idx(i, j):
        return i*W + j
    for i in range(H):
        for j in range(W):
            if S[i][j] != '.':
                continue
            if i > 0 and S[i-1][j] == '.':
                g[idx(i, j)][idx(i-1, j)] = 1

            if i < H-1 and S[i+1][j] == '.':
                g[idx(i, j)][idx(i+1, j)] = 1

            if j > 0 and S[i][j-1] == '.':
                g[idx(i, j)][idx(i, j-1)] = 1

            if j < W-1 and S[i][j+1] == '.':
                g[idx(i, j)][idx(i, j+1)] = 1

    d = warshall_floyd(g, W*H)
    ans = 0
    for i, r in enumerate(d):
        for j, v in enumerate(r):
            if v != INF and i != j:
                ans = max(ans, v)
    return ans


def main():
    H, W = read_int_n()
    S = [read_str() for _ in range(H)]


    # H = 20
    # W = 20
    # S = ['.'*W]*H
    print(slv(H, W, S))

if __name__ == '__main__':
    main()


Measured memory_bytes: 63852
n, m = map(int, input().split())
P = [0]*n
AC = 0
WA = 0
for i in range(m):
    p, S = input().split()
    p = int(p)
    if S == "AC" and P[p-1] != -1:
        WA += P[p-1]
        AC += 1
        P[p-1] = -1
    elif S == "WA" and P[p-1] != -1:
        P[p-1] += 1
print(AC, WA)

Measured memory_bytes: 9524
import * as fs from "fs";

const split = (str: string): string[] =>
  str.split(" ").map((v: string) => v.trim());
const split_number = (str: string): number[] =>
  split(str).map((v: string) => +v);

export function main(input: string) {
  const lines = input.split("\n");
  const [n, r] = split_number(lines[0]);

  if (n >= 10) {
    return r;
  } else {
    return r + (100 * (10 - n));
  }
}

if (!process.env.LOCAL_DEBUG) {
  console.log(main(fs.readFileSync("/dev/stdin", "utf8")));
}


Measured memory_bytes: 11468
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<bitset>
#include<queue>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) FOR(i,0,n)
typedef long long ll;
int main(){
	int n;
	cin >> n;
	cout << n/3 << endl;
	return 0;
}


Measured memory_bytes: 764
#include <stdio.h>
#include <math.h>

int main(void) {
	int X,r=1,i,j;
	scanf("%d",&X);
	for(i = 1;i<X;i++) {
		for(j = 2;j<X;j++) {
			int p = (int)pow((double)i,(double)j);
			if(p > X) {
				continue;
			}else if(p>r){
				r = p;
			}
		}
	}

	printf("%d",r);
	return 0;

}


Measured memory_bytes: 384
#include <iostream>
#include <iomanip>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
#include <numeric>
#include <queue>
#include <sstream>
#include <bitset>
#include<stack>

using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;

template<typename T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }

template<typename T>
map<T, T> getPrimeFactor(T n) {
	map<T, T> res;
	for (T i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			res[i] ++;
			n /= i;
		}
	}
	if (n != 1) res[n] = 1;
	return res;
}

template<typename T>
bool IsPrimeNumber(T num)
{
	if (num <= 2) return true;
	else if (num % 2 == 0) return false;

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	return true;
}

long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

#define rep(i,s,e) for(ll i=s;i<e;i++)
#define repeq(i,s,e) for(ll i=s;i<=e;i++)


int main() {
	ll X,N;
	std::cin >> X >> N;
	vector<bool> t(105, true);
	ll p;
	rep(i, 0, N) {
		std::cin >> p;
		t[p] = false;
	}

	ll sub = 9999;
	ll ans;
	rep(i, 0, t.size()) {
		if (t[i] && abs(i - X)<sub) {
			sub = abs(i - X);
			ans = i;
		}
	}
	std::cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3628
import sys
import math
from collections import defaultdict

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N):
    read_all = [tuple(map(int, input().split())) for _ in range(N)]
    return map(list,zip(*read_all))

#################

from collections import Counter

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

N = I()
d = defaultdict(int)

for i in range(2,N+1):
    c = Counter(prime_factorize(i))
    for k in c.keys():
        d[k] += c[k]

n2 = 0
n4 = 0
n14 = 0
n24 = 0
n74 = 0
for k in d.keys():
    if d[k]>=74:
        n74 += 1
    if d[k]>=24:
        n24 += 1
    if d[k]>=14:
        n14 += 1
    if d[k]>=4:
        n4 += 1
    if d[k]>=2:
        n2 += 1

ans = 0
if n4>=2 and n2>=3:
    ans += n4*(n4-1)//2 * (n2-2)
if n14>=1 and n4>=2:
    ans += n14*(n4-1)
if n24>=1 and n2>=2:
    ans += n24*(n2-1)
ans += n74

print(ans)

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

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N, M;
    cin >> N >> M;
    vector<ll> nums(N);
    for (int i = 0; i < N; i++)
    {
        cin >> nums.at(i);
    }
    vector<ll> ruisekiMod(N + 1);
    map<ll, ll> ruisekiModCount;
    for(int i = 0; i < N; i++)
    {
        ruisekiMod.at(i + 1) = (ruisekiMod.at(i) + nums.at(i)) % M;
        ruisekiModCount[ruisekiMod.at(i + 1)]++;
    }
    ll answer = 0;
    for(int i = 0; i < N; i++)
    {
        ll currentMod = ruisekiMod.at(i);
        answer += ruisekiModCount[currentMod];
        ruisekiModCount[ruisekiMod.at(i + 1)]--;
    }
    cout << answer << endl;
    return 0;
}


Measured memory_bytes: 5760
import sys,math,copy,queue,itertools,bisect
LI = lambda : [int(x) for x in sys.stdin.readline().split()]
NI = lambda : int(sys.stdin.readline())

N = NI()
data = [[a,i] for i,a in enumerate(LI())]
data.sort(reverse=True)

dp = [[0 for _ in range(N+1)] for _ in range(N+1)]

for i in range(N):
    a, p = data[i]
    for j in range(i+1):
        dp[i+1][j+1] = max(dp[i+1][j+1],dp[i][j] + abs(N-1-j-p)*a)
        dp[i+1][j] = max(dp[i+1][j], dp[i][j] + abs(i-j-p)*a)
print(max(dp[-1]))


Measured memory_bytes: 104028
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define erep(i,a,b) for(int i=a;i<=(int)(b);++i)
#define per(i,a,b) for(int i=(a);i>(b);--i)
#define eper(i,a,b) for(int i=(a);i>=b;--i)
#define pb push_back
#define mp make_pair
#define INF (1<<30)-1
#define MOD 1000000007
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a, b)*b;}

int n, m;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
    cin >> n;
    map<string, int> card;
    rep(i, 0, n) {
      string s;
      cin >> s;
      card[s]++;
    }
    cin >> m;
    rep(i, 0, m) {
      string t;
      cin >> t;
      card[t]--;
    }
    int ans = 0;
    for (auto itr = card.begin(); itr != card.end(); ++itr) {
      ans = max(ans, itr->second);
    }
    cout << ans << endl;
    return 0;
}


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

int main(void)
{
    long long int a,b,c,d,i,j,k,n;
    string s;
    char C[5];

    cin >> a >> b >> c >> d;

    if(a+b>c+d) cout << "Left";
    if(a+b==c+d) cout << "Balanced";
    if(a+b<c+d) cout << "Right";

    return 0;
}


Measured memory_bytes: 256
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>
 
#define _USE_MATH_DEFINES
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;

const int INF=1<<29;
const int MOD=1000000007;
const double EPS=1e-9;

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


int main()
{
    int M = 100000;
    vb is_prime(M+1,true);
    is_prime[0] = is_prime[1] = false;
    
    for(int i = 2; i*i <= M; i++) {
        if(is_prime[i]) {
            for(int j = 2; j*i <= M; j++)
                is_prime[i*j] = false;
        }
    }

    vi accum(M+1);
    accum[0] = accum[1] = 0;
    for(int i = 1; i <= M; i++) {
        if(is_prime[i] && is_prime[(i+1)/2])
            accum[i] = accum[i-1] + 1;
        else
            accum[i] = accum[i-1];
    }


    int Q; cin >> Q;
    int l, r;
    rep(i,Q) {
        cin >> l >> r;
        cout << accum[r] - accum[l-1] << endl;
    }

    return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#define M 100000
using namespace std;
bool prime[M];
void primeInit()
{
	for (int i = 0; i < M; i++)
	{
		prime[i] = false;
	}
}
void p()
{
	prime[2] = true;
	for (int i = 3; i < M; i++)
	{
		bool flag = false;
		for (int j = 2; j * j <= i; j++)
		{
			if (i % j == 0)
			{
				flag = true;
				break;
			}
		}
		if (!flag)prime[i] = true;
	}
}
int main()
{
	int m, a, b;
	primeInit();
	p();
	while (cin >> m >> a >> b && m != 0 || a != 0 || b != 0)
	{
		double ma = 0;
		int mp = 0;
		int mq = 0;
		for (int p = 2; p <= m / 2; p++)
		{
			if (!prime[p])continue;
			for (int q = 2; q <= m / p; q++)
			{
				if (!prime[q])continue;
				if (1.0 * p * q > ma && 1.0 * p * q <= m && (1.0 * p / q) <= 1 && (1.0 * p / q) >= (a * 1.0 / b))
				{
					ma = p * q;
					mp = p;
					mq = q;
				}
			}
		}

		cout << mp << " " << mq << endl;
	}
	return 0;
}

Measured memory_bytes: 1256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<cstring>
using namespace std;

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

const int MAX = 2 * 123456 + 100;

bool prime[MAX];

int main()
{
    prime[0] = prime[1] = 1;
    rep(i,MAX)if(!prime[i])for(int j = i*2;j<MAX;j+= i)prime[j] = 1;

    int n;
    while(cin >> n && n)
    {
        int ans = 0;
        for(int i = n+1;i<=2*n; i++)if(!prime[i]) ans ++;
        cout << ans << endl;
    }

    return 0;
}

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

int f(int x){
  int res = 0;
  while(x > 0){
    res = x % 10;
    x /= 10;
  }
  return res;
}

int main(){
  int n;
  cin >> n;
  vector<vector<int> > mem(10, vector<int>(10));
  for(int i = 1; i <= n; ++i){
    ++mem[i % 10][f(i)];
  }
  ll ans = 0;
  for(int i = 1; i <= n; ++i){
    ans += mem[f(i)][i % 10];
  }

  cout << ans << endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long a,b;
	cin>>a>>b;
	if (a<=9 && b<=9 && a>=1 && b>=1)
	{
		cout<<a*b<<endl;
	}
	else
	{
		cout<<"-1"<<endl;
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#define vll vector<ll>
#define vvvl vector<vvl>
#define vvl vector<vector<ll>>
#define VV(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define VVV(a, b, c, d) vector<vvl>(a, vvl(b, vll (c, d)));
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
using namespace std;

int main(int argc, char const *argv[]) {
  string s;std::cin >> s;
  for(int i=0;i<s.size();i++) if(s[i]=='?') s[i] = 'D';
  std::cout << s << '\n';
  return 0;
}


Measured memory_bytes: 3376
#include <iostream>
#include <sstream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <cstring>
#include <bitset>
#include <functional>
#include <random>
#define REP(i,a,n) for(int i=a;i<=n;++i)
#define PER(i,a,n) for(int i=n;i>=a;--i)
#define hr putchar(10)
#define pb push_back
#define lc (o<<1)
#define rc (lc|1)
#define mid ((l+r)>>1)
#define ls lc,l,mid
#define rs rc,mid+1,r
#define x first
#define y second
#define io std::ios::sync_with_stdio(false)
#define endl '\n'
#define DB(a) ({REP(__i,1,n) cout<<a[__i]<<' ';hr;})
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int P = 1e9+7, INF = 0x3f3f3f3f;
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll qpow(ll a,ll n) {ll r=1%P;for (a%=P;n;a=a*a%P,n>>=1)if(n&1)r=r*a%P;return r;}
ll inv(ll x){return x<=1?1:inv(P%x)*(P-P/x)%P;}
inline int rd() {int x=0;char p=getchar();while(p<'0'||p>'9')p=getchar();while(p>='0'&&p<='9')x=x*10+p-'0',p=getchar();return x;}
//head



const int N = 1e6+50;
int n, m, a[N], b[N];

int main() {
	scanf("%d%d", &n, &m);
	vector<int> v[2];
	REP(i,1,m) { 
		int t;
		scanf("%d", &t);
		v[t&1].pb(t);
	}
	if (m==1) {
		if (n==1) return puts("1\n1\n1"),0;
		return printf("%d\n%d\n%d %d\n",n,2,1,n-1),0;
	}
	if (v[1].size()>2) return puts("Impossible"),0;
	if (v[1].size()==2) {
		a[1] = v[1][0], a[m] = v[1][1];
		if (a[1]>a[m]) swap(a[1],a[m]);
		b[1] = a[1]+1;
		REP(i,2,m-1) { 
			a[i] = v[0].back(), v[0].pop_back();
			b[i] = a[i];
		}
		b[m] = a[m]-1;
	}
	else if (v[1].size()==1) {
		a[1] = v[1][0], b[1] = a[1]+1;
		REP(i,2,m) {
			a[i] = v[0].back(), v[0].pop_back();
			b[i] = a[i];
		}
		b[m] = a[m]-1;
	}
	else {
		a[1] = v[0].back(), b[1] = a[1]+1;
		v[0].pop_back();
		REP(i,2,m) {
			a[i] = v[0].back(), v[0].pop_back();
			b[i] = a[i];
		}
		b[m] = a[m]-1;
	}
	REP(i,1,m) printf("%d ",a[i]);hr;
	if (!b[m]) --m;
	printf("%d\n",m);
	REP(i,1,m) printf("%d ",b[i]);hr;
}








Measured memory_bytes: 2304
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,a[2005];
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll z,w;cin>>n>>z>>w;
    for(ll i=1;i<=n;i++)cin>>a[i];
    if(n==1)return cout<<abs(a[1]-w) , 0;
    cout<<max(abs(a[n]-w),abs(a[n-1]-a[n]));
}



Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>

using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype
template <class T> int __builtin_popcount(T n) { return n ? 1 + __builtin_popcount(n & (n - 1)) : 0; }
#endif

#define foreach(it, c) for (__typeof__((c).begin()) it=(c).begin(); it != (c).end(); ++it)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define CLEAR(arr, val) memset(arr, val, sizeof(arr))

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

template <class T> void max_swap(T& a, const T& b) { a = max(a, b); }
template <class T> void min_swap(T& a, const T& b) { a = min(a, b); }

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

const double PI = acos(-1.0);
const int dx[] = { 0, 1, 0, -1 };
const int dy[] = { 1, 0, -1, 0 };



int n, m;
int dpru(int* c, int* v)
{
	int dp[333][333];
	CLEAR(dp, 0);
	for (int i = 0; i < n; ++i)
	{
		for (int j = 0; j <= m; ++j)
		{
			dp[i + 1][j] = dp[i][j];
			if (j >= c[i])
				max_swap(dp[i + 1][j], dp[i + 1][j - c[i]] + v[i]);
		}
	}
	return dp[n][m];
}
int main()
{
	while (~scanf("%d%d", &n, &m))
	{
		int c[333], v[3][333];
		rep (i, n)
		{
			getchar();
			while (getchar() != '\n')
				;
			int t;
			scanf("%d", &t);
			c[i] = t;
			rep (j, 3)
				scanf("%d", v[j] + i);
		}
		int res = 0;
		rep (i, 3)
			max_swap(res, dpru(c, v[i]));
		printf("%d\n", res);
	}
}

Measured memory_bytes: 1316