akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;






int ispalindrome(string s)
{
    int n=s.size();
    for(int i=0;i<n;i++)
    {
        if(s[i]!=s[n-i-1])
        return 0;
    }
    return 1;
}

bool test=0;
void solve()
{
 
    string s,s1,s2;
    cin>>s;
    int x,y,n;
    n=s.size();
    s1=s.substr(0,(n-1)/2);
    s2=s.substr((n+3)/2-1,n);
    // cout<<s1<<" "<<s2<<endl;
    if(ispalindrome(s) && ispalindrome(s1) && ispalindrome(s2))
    cout<<"Yes";
    else
    cout<<"No";
    
}



















int main() {
    int t=1;
	if(test)
	cin>>t;
	while(t--)
	{
	    solve();
	}
	return 0;
}

Measured memory_bytes: 256
import sys
import collections

ue = list(map(int, input().split()))
ma = list(map(int, input().split()))
sita = list(map(int, input().split()))

n = int(input())

bingo = []

for s in range(n):
  bing = int(input())
  a = 0
  for i, j, k in zip(ue, ma, sita):
    if a == 3:
      continue
    if i == bing:
      ue[a] = '〇'
    if j == bing:
      ma[a] = '〇'
    if k == bing:
      sita[a] = '〇'
    a += 1

for i, j, k in zip(ue, ma, sita):
  if i == '〇' and j == '〇' and k == '〇':
    print('Yes')
    sys.exit()

x = collections.Counter(ue)
y = collections.Counter(ma)
z = collections.Counter(sita)

if x['〇'] == 3:
  print('Yes')
  sys.exit()
elif y['〇'] == 3:
  print('Yes')
  sys.exit()
elif z['〇'] == 3:
  print('Yes')
  sys.exit()

if ue[0] == '〇' and ma[1] == '〇' and sita[2] == '〇':
  print('Yes')
  sys.exit()
elif ue[2] == '〇' and ma[1] == '〇' and sita[0] == '〇':
  print('Yes')
  sys.exit()
print('No')

Measured memory_bytes: 3316
from bisect import bisect
from math import factorial

N = int(input())
S = input()
mod = 998244353
    
R, G, B = [], [], []
for i, s in enumerate(S):
    if s == "R":
        R.append(i)
    elif s == "G":
        G.append(i)
    else:
        B.append(i)

a = [None] * N
b, c = a[:], a[:]
for i, *x in zip(range(N), R, G, B):
    a[i], b[i], c[i] = sorted(x)

ans = factorial(N) % mod
for i, b_ in enumerate(b):
    x = bisect(a, b_) - i
    y = i - bisect(c, b_) + 1
    ans = x * y * ans % mod
print(ans)

Measured memory_bytes: 18708
#include<iostream>
#include<stdlib.h>
#include<stack>
#include<string>
using namespace std;

int main()
{
	stack<int>st;
	string s;
	while(cin>>s){
	if(s[0]=='+')
	{
		int a=(int)st.top();
		st.pop();
		int b=(int)st.top();
		st.pop();
		st.push(a+b);
	}
	else if(s[0]=='-'){
	    int a=(int)st.top();
		st.pop();
		int b=(int)st.top();
		st.pop();
		st.push(b-a);
	}
	else if(s[0]=='*'){
		int a=(int)st.top();
		st.pop();
		int b=(int)st.top();
		st.pop();
		st.push(b*a);
	}
	else 
	{
		st.push(atoi(s.c_str()));
	}
	}
	cout<<st.top()<<endl;
	return 0;
}

Measured memory_bytes: 3188
operators = ['+', '-', '*']

stack = []
ope_input = input().split()

for ope in ope_input:
    if ope not in operators:
        stack.append(ope)
    else:
        b = stack.pop()
        a = stack.pop()
        stack.append(str(eval(a + ope + b)))

print(stack.pop())



Measured memory_bytes: 5568
#include <iostream>

using namespace std;

#define Nmax 999

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

    for(i=0;N>=10;i++){
        N = N % 10;
    }
    switch(N){
        case 2:
        case 4:
        case 5:
        case 7:
        case 9:
        
            cout<<"hon"<<endl;
            break;
        
        case 0:
        case 1:
        case 6:
        case 8:
            cout<<"pon"<<endl;
            break;

        default:
            cout<<"bon"<<endl;
            break;

    }

    return 0;
}

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

const int m=1000000007;
ll f[2005];

ll power (ll x, ll y){
    ll ans =1;
    while(y>0){
        if(y%2==1)
            ans = (ans * x) % m;
        y/=2;
        x=(x*x)%m;
    }
    return ans;
}


ll ncr(ll n , ll r){
    ll ans = f[n]*(power(f[r],m-2)%m);
    ans%=m;
    ans*=(power(f[n-r],m-2)%m);
    ans%=m;
    return ans;
}

void testcase(){

    f[0]=1;
    for(int i=1;i<2005;i++){
        f[i]=f[i-1]*i;
        f[i]%=m;
    }
    ll n;
    cin >> n;
    ll res=0;
    for(int i=0;i<=n/3-1;i++){
        res+=ncr(n-2*i-3,i);

        res%=m;
    }

    cout << res;
}


int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int q=1;
  //  cin >> q;
    while(q--){
    testcase();
    }
    return 0;
}



Measured memory_bytes: 3660
def bSort(A):
    flag = 1
    i = 0
    count = 0
    while flag:
        flag = 0
        for j in range(len(A)-1, i, -1):
            if A[j] < A[j-1]:
                tmp = A[j]
                A[j] = A[j-1]
                A[j-1] = tmp
                flag = 1
                count += 1
        i += 1
    return A, count

if __name__ == '__main__':
    length = input()
    data = [int(x) for x in input().split()]
    data_s, c = bSort(data)
    print (' '.join([str(x) for x in data_s]))
    print (c)


Measured memory_bytes: 5608
#include <stdio.h>
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>
#include <queue>
#include <list>
#include <stack>
#include <math.h>
#include <map>
#include <unordered_map>
#include <set>
using namespace std;

#define ll long long
#define ull unsigned long long

#define	max	1000000007

ll gcd(ll a, ll b) {
	if (a < b)
		swap(a, b);
	while (ll r = a % b)
		a = b, b = r;
	return b;
}

ll combi(ll n, ll k)
{
	if (k >= n || k <= 0)
		return 1;
	ll r = 1;
	for (ll i = 1; i <= k; i++, n--)
		r *= n, r /= i;
	return r;
}

class mod
{
public:
	ll val;

	mod(ll v)
	{
		val = v % max;
	}

	mod()
	{
		val = 0;
	}

	void operator -=(const mod &v)
	{
		val -= v.val;

		if (val < 0)
			val += max;
	}

	void operator +=(const mod &v)
	{
		if (val + v.val >= max)
			val -= max;
		val += v.val;
	}

	void operator +=(ll &v)
	{
		if (val + v >= max)
			val -= max;
		val += v;
	}

	void operator *=(const mod &v)
	{
		val *= v.val;
		val %= max;
	}

	void operator *=(ll &v)
	{
		val *= v;
		val %= max;
	}

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

	void operator /=(const mod &v)
	{
		val *= modinv(v.val);
		val %= max;
	}

	void operator /=(ll &v)
	{
		val *= modinv(v);
		val %= max;
	}
};

int main()
{
	int n, k;
	cin >> n >> k;
	vector<ll> h(n);
	for (int i = 0; i < n; i++)
		cin >> h[i];
	sort(h.begin(), h.end(), greater<ll>());
	ll r = 0;
	if (n > k)
		for (int i = k; i < n; i++)
			r += h[i];

	printf("%lld", r);

	return 0;
}


Measured memory_bytes: 2424
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#define _USE_MATH_DEFINES
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <numeric>
#include <cmath>
#include <limits>
#include <bitset> 
#include <iterator> 
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include<deque>
#include <regex>
#include <list> 
#define rep(i,n) for(ll i=0;i<(n); ++i)
#define per(i,n) for(ll i=n-1;i>=0; --i)
#define all(x) (x).begin(),(x).end()
#define _GLIBCXX_DEBUG
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
typedef long long ll;
const ll MOD = 1000000007;
ll getDigit(ll n) {
	ll cnt = 0;
	while (n != 0) {
		n /= 10;
		cnt++;
	}
	return cnt;
}
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
typedef pair<double, long long> pair_t;
bool comp(const pair_t& a, const pair_t& b) {
	if (a.first == b.first)return  a.second > b.second;
	else {
		return a.first > b.first;
	}
}

int main() {
	ll n, a, b;
	cin >> n >> a >> b;
	cout << a * (n / (a + b)) + min(n % (a + b), a) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n,t;
char c='0';
int main(){
	cin >> n;
	getchar();
	while(n--){
		char cl = getchar();
		if(c != cl){
			c = cl;
			t++;
		}
	}
	cout << t << endl;
	return 0;
}

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

int N,M;
pair<int,int> PD[10010];
int main()
{
    while(cin >>N >> M && N)
    {
	    int d,p;
	    for(int i = 0;i<N;i++)
	    {
		    cin >> d;
		    cin >> p;
		    PD[i] = make_pair(p,d);
	    }
	    sort(PD,PD+N);
        int S=0;
        for(int i=0;i<N;i++)
			S += PD[i].first*PD[i].second;
        for(int i=N-1;i>=0;i--)
        {
            if(M <=0)
                break;
            int guarded = min(M,PD[i].second);
            S-=PD[i].first*guarded;
            M-=guarded;
        }
	    cout << S << endl;
    }
	return 0;
}


Measured memory_bytes: 3164
def cin():  return list(map(int,input().split()))

N, M, Q = list(map(int,input().split()))
v = [[0 for _ in range(N)] for _ in range(N)]
p = [[0 for _ in range(2)] for _ in range(Q)]

for _ in range(M):
    a, b = cin()
    v[a - 1][b - 1] += 1;

for i in range(Q):
    a, b = cin()
    p[i][0] = a - 1;
    p[i][1] = b - 1;
    
def d2_add(a):
    w = len(a[0])
    h = len(a)
    da = [[0] * w for j in range(h)]
    da[0][0] = a[0][0]
    for i in range(1, w):
        da[0][i] = da[0][i - 1] + a[0][i]
    for i in range(1, h):
        cnt_w = 0
        for j in range(w):
            cnt_w += a[i][j]
            da[i][j] = da[i - 1][j] + cnt_w
    return da

def d2_calc(da, p, q, x, y):
    if p > x or q > y:  return 0
    if p == 0 and q == 0:  return da[x][y]
    if p == 0:  return da[x][y] - da[x][q - 1]
    if q == 0:  return da[x][y] - da[p - 1][y]
    return da[x][y] - da[p - 1][y] - da[x][q - 1] + da[p - 1][q - 1]

ret = d2_add(v)
for i in range(Q):
    ans = d2_calc(ret, p[i][0], p[i][0], p[i][1], p[i][1])
    print(ans)

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

using ll = int64_t;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
  for (auto val : array)
    std::cout << val << ", ";
  std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << std::setprecision(10);

  int n, k; std::cin >> n >> k;
  vi hs(n);
  rep(i, n) std::cin >> hs[i];
  sort(rng(hs));
  ll ans = 0;
  rep(i, n - k) {
    ans += hs[i];
  }
  std::cout << ans << "\n";
}


Measured memory_bytes: 1024
#include<iostream>
main(){int n,m,i,a,c[1000001];for(std::string s;std::cin>>n>>m>>s,n;printf("%d\n",a))for(a=0,i=m;--i;a+=c[i]>=n)c[i]=s.substr(i,3)=="IOI"?c[i+2]+1:0;}

Measured memory_bytes: 5828
#include <iostream>
#include <math.h>
#include <string>
#include <string.h> 
#include <stdio.h>
#include <cstdlib>
using namespace std;
#define MAX 200000
#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 FORR(i, m, n) for(int i = m;i >= n;i--)
#define IN(n) scanf("%d",&n,);
#define OUT(n) printf("%d",n);
#define IN2(n,k) scanf("%d%d",&n,&k);
#define OUT2(n,k) printf("%d%d",n,k);
#define IN3(n,k,s) scanf("%d%d%d",&n,&k,&s);
#define OUT3(n,k,s) printf("%d%d%d\n",n,k,s);

int main(){
    int n,a,b,j=0,k,sum=0;
    IN3(n,a,b);

    while(j<=n/10){
        k=j/1000+(j/100)%10+(j/10)%10+j%10;

        for(int i=0;i<10; i++){
            if((j*10+i)>n)break;
            else if(k+i>=a && k+i<=b){
                sum+=j*10+i;
            }
        }
        j++;
    }
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 256
a=input('').split()
a=list(map(int,a))

b=(a[0])
c=(a[1])
d=(a[2])
e=(a[3])

f=b*d
g=b*e
h=c*d
i=c*e

if f>g:
  if h>f:
    if i>h:
      print(i)
    else:
      print(h)
  else:
    if i>f:
      print(i)
    else:
      print(f)
else:
  if h>g:
    if i>h:
      print(i)
    else:
      print(h)
  else:
    if i>g:
      print(i)
    else:
      print(g)


Measured memory_bytes: 9160
N = int(input())
H = [int(x) for x in input().split()][::-1]
for i in range(1, N):
    d = H[i] - H[i - 1]
    if d >= 2:
        print("No")
        exit()
    elif d == 1:
        H[i] -= 1
print("Yes")

Measured memory_bytes: 14396
/// [Amberjack] CUT BEGIN
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;

typedef int _loop_int;
#define __GET_REP_MACRO(_1,_2,_3,NAME,...) NAME
#define __REP0(i,n) for(_loop_int i=0;i<(n);++i)
#define __REP1(i,a,b) for(_loop_int i=(a);i<(b);++i)
#define __REPR0(i,n) for(_loop_int i=(n)-1;i>=0;--i)
#define __REPR1(i,a,b) for(_loop_int i=(b)-1;i>=(a);--i)
#define REP(...) __GET_REP_MACRO(__VA_ARGS__,__REP1,__REP0)(__VA_ARGS__)
#define REPR(...) __GET_REP_MACRO(__VA_ARGS__,__REPR1,__REPR0)(__VA_ARGS__)

#ifdef BURI
#define __DEBUG0() "Hello"
#define __DEBUG1(x) #x"("<<(x)<<")"
#define __DEBUG2(x,...) #x"("<<(x)<<"), " __DEBUG1(__VA_ARGS__)
#define __DEBUG3(x,...) #x"("<<(x)<<"), " __DEBUG2(__VA_ARGS__)
#define __DEBUG4(x,...) #x"("<<(x)<<"), " __DEBUG3(__VA_ARGS__)
#define __DEBUG5(x,...) #x"("<<(x)<<"), " __DEBUG4(__VA_ARGS__)
#define __GET_DEBUG_MACRO(_1,_2,_3,_4,_5,NAME,...) NAME
#define __DEBUG(...) __GET_DEBUG_MACRO(__VA_ARGS__,__DEBUG5,__DEBUG4,__DEBUG3,__DEBUG2,__DEBUG1,__DEBUG0)(__VA_ARGS__)
#define DEBUG(...) cerr<<__DEBUG(__VA_ARGS__)<<endl
#else
#define DEBUG(...)
#endif

inline void getll(ll &x){
  int sgn=1;x=0;
  char c=getchar();
  while(c!='-'&&(c<'0'||c>'9'))c=getchar();
  if(c=='-') sgn=-1; else x=c-'0';
  c=getchar();
  while('0'<=c&&c<='9'){
    x*=10;
    x+=c-'0';
    c=getchar();
  }
  x*=sgn;
}
inline void read(ll &x){getll(x);}
inline void read(int &x){ll y;getll(y);x=y;}
inline void read(float &x){scanf("%f",&x);}
inline void read(double &x){scanf("%lf",&x);}
inline void read(long double &x){scanf("%Lf",&x);}
inline void read(char *s){scanf("%s",s);}
inline void read(string &s){int len=s.size();char *buf=(char*)malloc(len*sizeof(char));scanf("%s",buf);s=string(buf);free(buf);}
inline void read(char &c){char *buf=(char*)malloc(5*sizeof(char));scanf("%s",buf);c=buf[0];free(buf);}
inline void read(){}
template<typename S,typename ...T>
inline void read(S& first, T&... rest){
  read(first);
  read(rest...);
}
/// [/Amberjack] CUT END

int n,a,b;
char s[125252];
int main(){
  read(n,a,b,s);
  REP(i,n){
    if(s[i]=='a'){
      if(a+b>0){
        puts("Yes");
        --a;
      }else{
        puts("No");
      }
    }else if(s[i]=='b'){
      if(a+b>0 && b>0){
        puts("Yes");
        --b;
      }else{
        puts("No");
      }
    }else{
      puts("No");
    }
  }
  return 0;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001
#define mod 1000000007
#define pi 3.141592653589793

ll gcd(ll a,ll b){
    if(b>a) swap(a,b);
    ll r=a%b;
    while(r!=0){
        a=b;
        b=r;
        r=a%b;
    }
    return b;
}
int main (){
    int n,y;
    cin >> n >>y;
    for(int i=0;i<=n;i++){
        for(int j=n-i;j>=0;j--){
            int m=y-10000*i-5000*j;
            if(m>=0){
                int k=m/1000;
                if(i+j+k==n){
                    cout << i << " " << j << " " << k <<endl;
                    return 0;
                }
            }
            else continue;
        }
    }
    cout << -1 << " " << -1 << " " << -1 << endl;
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>

typedef long long ll;
typedef unsigned long long ull;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i = 0;i < ((int)(n));++i)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define test(a) cout<<"line:"<<__LINE__<<"["<<(#a)<<": "<<(a)<<"]"<<endl

const int INF = 1e9+7;
const ll INFL = 9*1e18;
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };

#define SUM(vec) accumulate(all(vec),0LL) // 配列の中身を全部足す
template<typename T>void print(T&& x){cout<<x<<endl;}// 改行付き出力
ll inline digit(ll num){int tmp = 0;while(num){tmp++;num/=10;}return tmp;} // 桁数
template<typename T>inline T digitSum(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;} // 各桁の和
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);} // 最大公約数
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;} // 最小公倍数
template<typename T>inline T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;} // 累乗
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
bool isPrime(ll n); // 素数か
vector<ll> primes(ll n); // 素因数分解
int ctoi(char c){return c - '0';}

const ll COM_MAX = (ll)(1e6+100); // combinationの最大値
vector<ll> fac(COM_MAX),finv(COM_MAX),inv(COM_MAX);
void comb_init(); // 初期化
ll comb(ll n,ll k); // nCk

void dfs(int n,int now,string s){
  if(n == now)cout<<s<<endl;
  else rep(i,3)dfs(n+1,now,s+(char)('a'+i));
}

// TODO: write
int main() { 
  int n,k,s;cin>>n>>k>>s;
  rep(i,k){
    cout<<s<<" \n"[i==n-1];
  }
  
  rep(i,n-k){
     
    if(s==1000000000)cout<<1<<" \n"[i==n-k-1];
    else cout<<1000000000<<" \n"[i==n-k-1];
    
  }

  return 0;
}




void comb_init(){
  fac[0]=fac[1]=1;
  finv[0]=finv[1]=1;
  inv[1]=1;
  for(int i=2;i<COM_MAX;++i){
    fac[i]=fac[i-1]*i%INF;
    inv[i]=INF-inv[INF%i]*(INF/i)%INF;
    finv[i]=finv[i-1]*inv[i]%INF;
  }
}

ll comb(ll n,ll k){
  if(n<k)return 0;
  if(n<0||k<0)return 0;
  return fac[n]*(finv[k]*finv[n-k]%INF)%INF;
}

bool isPrime(ll n) {
	for (int i = 2; n >= i * i; ++i) {
		if(!(n % i))return false;
	}
  return true;
}
vector<ll> primes(ll n){
  vector<ll> v;
  for (ll i = 2; i*i <= n; ++i) {
    while(n%i==0){
      n/=i;
      v.pb(i);
    }
  }
  if(n != 1)v.pb(n);
  return v;
}


/* 二分探索の時に使う
template<typename T>bool isOk(T key,T value){
  return key <= value;
}
template<typename T>T binary_search(vector<T> a,T key){
  T ok = a.size();
  T ng = -1;
  while(abs(ok - ng) > 1){
    T mid = (ok + ng) / 2;
    if(isOk(key,a[mid]))ok = mid;
    else ng = mid;
  }
  return ok;
}
*/

Measured memory_bytes: 24704
#include<iostream>
#define N 4280
using namespace std;

int main(){
	
	int w;
	while(cin>>w){
		int s=0;
		if(w!=-1){
		if(w<=10)
			s=1150;
		else if(w<=20)
			s=1150+(w-10)*125;
		else if(w<=30)
			s=1150+10*125+(w-20)*140;
		else if(w>30)
			s=1150+10*125+10*140+(w-30)*160;
			
		cout<<N-s<<endl;
	}
		else
			break;
	}
		
	
}

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

const int DEPTH = 17;
struct RAQ {
	int d[1 << DEPTH + 1];
	
	RAQ() {
		for (int i = 0; i < 1 << DEPTH + 1; i++) {
			d[i] = 0;
		}
	}
	
	void add(int l, int r, int x, int a = 0, int b = (1 << DEPTH), int id = 0) {
		if (a >= r || b <= l) return;
		if (l <= a && b <= r) {
			d[id] += x;
			return;
		}
		add(l, r, x, a, (a + b) / 2, id * 2 + 1);
		add(l, r, x, (a + b) / 2, b, id * 2 + 2);
	}
	
	int query(int pos) {
		pos += (1 << DEPTH) - 1;
		
		int ret = d[pos];
		while (pos > 0) {
			pos = (pos - 1) / 2;
			ret += d[pos];
		}
		return ret;
	}
};

RAQ raq;

int main() {
	int n, q;
	cin >> n >> q;
	
	for (int i = 0; i < q; i++) {
		int type;
		cin >> type;
		
		if (type == 0) {
			int s, t, x;
			cin >> s >> t >> x;
			raq.add(s, t + 1, x);
		}
		else {
			int pos;
			cin >> pos;
			cout << raq.query(pos) << endl;
		}
	}
	
	return 0;
}


Measured memory_bytes: 4144
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define pli pair<ll, int>
#define pil pair<int, ll>
#define pll pair<ll, ll>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define endl '\n'
const int inf = 1000000007;
const ll INF = 1e18;
int mod = 998244353;
// int mod = 1000000007;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
template<typename T, typename U> T pow_(T a, U b) { return b ? pow_(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
ll modpow(ll a, ll b, ll _mod) { return b ? modpow(a * a % _mod, b / 2, _mod) * (b % 2 ? a : 1) % _mod : 1; }
template<class T, class U> ostream& operator << (ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<class T> ostream& operator << (ostream& os, const vector<T>& vec) { rep(i, sz(vec)) { if (i) os << " "; os << vec[i]; } return os; }
template<typename T> inline istream& operator >> (istream& is, vector<T>& v) { rep(j, sz(v)) is >> v[j]; return is; }
template<class T, class T2> inline void add(T &a, T2 b) { a += b; if (a >= mod) a -= mod; }
template<class T> void operator += (vector<T>& v, vector<T> v2) { rep(i, sz(v2)) v.eb(v2[i]); }

void solve();

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cout << fixed << setprecision(11);
  int T;
  T = 1;
  while (T--) solve();
}

template<typename T>
map<T, int> prime_factorize(T n) {
  T tmp = n;
  map<T, int> mp;
  for (T i = 2; i * i <= n; ++i) {
    ll cnt = 0;
    while (tmp % i == 0) {
      tmp /= i;
      cnt++;
    }
    if (cnt) mp[i] = cnt;
  }
  if (tmp != 1) mp[tmp] = 1;
  return mp;
}

void solve() {
  ll n;
  cin >> n;
  auto mp = prime_factorize(n);

  int ans = 0;
  for (auto e : mp) {
    auto binary_search = [&](int ok, int ng) {
      auto check = [&](int x) {
        if (1LL * x * (x + 1) / 2 <= e.S) return 1;
        return 0;
      };
      int d = 1;
      while (abs(ng - ok) > d) {
        int mid = (ng + ok) / 2;
        (check(mid) ? ok : ng) = mid;
      }
      return ok;
    };
    ans += binary_search(0, 1e7);
  }
  cout << ans << endl;
}


Measured memory_bytes: 3652
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <utility>
#include <cstdlib>
#include <memory>
#include <queue>
#include <cassert>
#include <cmath>
#include <ctime>
#include <complex>
#include <bitset>
#include <fstream>
#include <unordered_map>
#include <unordered_set>
#include <numeric>

using namespace std;

#define ws ws_____________________
#define y1 y1_____________________
#define y0 y0_____________________
#define left left_________________
#define right right_______________
#define next next_________________
#define prev prev_________________
#define hash hash_________________

#define pb push_back
#define fst first
#define snd second
#define mp make_pair 
#define sz(C) ((int) (C).size())
#define forn(i, n) for (int i = 0; i < int(n); ++i)
#define ford(i, n) for (int i = int(n) - 1; i >= 0; --i)
#define all(C) begin(C), end(C)

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vii;
typedef long double ld;
typedef complex<double> cd;

#define FILE_NAME "a"

const int MOD = 1e9 + 7;

void add(int& x, int y) {
	((x += y) >= MOD) && (x -= MOD);
}

int mul(int x, int y) {
	return x * 1ll * y % MOD;
}

int n, m;

bool read() {
	if  (scanf("%d%d", &n, &m) < 2) {
		return 0;
	}
	return 1;
}

int fact(int n) {
	int res = 1;
	for (int i = 2; i <= n; ++i) {
		res = mul(res, i);
	}
	return res;
}

int solve() {
	if  (n < m) {
		swap(n, m);
	}
	if  (n == m) {
		return mul(fact(n), mul(fact(n), 2));
	}
	if  (n == m + 1) {
		return mul(fact(n), fact(m));
	}
	return 0;
}

int main() {
#ifdef LOCAL
	freopen(FILE_NAME ".in", "r", stdin);
	// freopen(FILE_NAME ".out", "w", stdout);
#endif

	while (read()) {
		cout << solve() << "\n";
	}

#ifdef LOCAL
	cerr.precision(5);
	cerr << "Time: " << fixed << (double) clock() / CLOCKS_PER_SEC << endl;
#endif
	return 0;
}


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

using namespace std;

int main() {
  int h1,m1,h2,m2,k;
  cin>>h1>>m1>>h2>>m2>>k;
  int a=60*h1+m1;
  int b=60*h2+m2;
  cout<<b-a-k<<endl;
  
}

Measured memory_bytes: 3624
#include "bits/stdc++.h"
#include "math.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vin;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define drep(i,a,b) for(ll i=(a);i>=(b);--i)
#define SIZE(a) int((a).size())
#define out(a) cout<<(a)<<endl;
const int INF=INT_MAX;
const int MAX = 510000;
const ll MOD = 1000000007;
ll roundd(ll x,ll n){
  if(x>n){return x%n;}
  else if(x<0){return x%n+n;}
  else return x;
}

int main(){
  ll n,m;cin>>n>>m;
  vp l(m);
  rep(i,0,m){
    cin>>l[i].second>>l[i].first;
  }
  sort(l.begin(),l.end());
  ll tmp=0,ans=0;
  rep(i,0,m){
    if(tmp<l[i].second){
      ans++;tmp=l[i].first-1;
    }
  }
  cout<<ans<<endl;
}



Measured memory_bytes: 4824
def resolve():
    import math as m
    a, b, C = [int(i) for i in input().split()]
    c = m.sqrt((a)**2 + (b)**2 - (2 * a * b) * m.cos(m.radians(C)))
    h = b * m.sin(m.radians(C))
    print(a * h / 2)
    print(a + b + c)
    print(h)


resolve()



Measured memory_bytes: 5720
#include<iostream>
#include<vector>
using namespace std;
int main() {
	int X, N,d=0,ans=1;
	cin >> N >> X;
	vector<int> L(N+1);
	for (int i = 0; i < N; i++) {
		cin >> L[i];
	}
	d = L[0];
	for (int i = 1; i < N+1&&d<=X; i++) {
		ans++;
		d += L[i];
		
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
x = list(map(int,input().split()))
x.sort()
a = x[2]-x[0]
b = x[2]-x[1]

if a%2 == 0 and b%2 == 0:print(a//2+b//2)
if a%2 == 0 and b%2 == 1:print(a//2+(b+1)//2+1)
if a%2 == 1 and b%2 == 0:print((a+1)//2+b//2+1)
if a%2 == 1 and b%2 == 1:print((a-1)//2+(b-1)//2+1)

Measured memory_bytes: 3064
import java.util.*
import kotlin.comparisons.compareBy

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    (1..n).map { Restaurant(index = it, city = sc.next(), score = sc.nextInt()) }
            .sortedWith(compareBy({ it.city }, { -it.score }))
            .forEach { println(it.index) }
}

data class Restaurant(val index: Int, val city: String, val score: Int)


Measured memory_bytes: 35996
import java.util.*;

public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int[] d = new int[n];
        for(int i = 0;i<n;i++){
            d[i] = Integer.parseInt(sc.next());
        }
        Arrays.sort(d);
        if(n == 2){
            System.out.println(d[1] - d[0]);
        }else{
            int a = d[d.length/2] - d[d.length/2 -1];
            if(d[d.length/2 -1] - d[d.length/2] == 0 && d[d.length/2-1] - d[d.length/2 -2] == 0){
                a -= 1;
            }
            if(a <= 0){
                System.out.println(0);
            }else{
                System.out.println(a);
            }
        }
    }
}

Measured memory_bytes: 48648
#include<bits/stdc++.h>
#define ll long long int
#define ld long double
#define inf LLONG_MAX>>2
#define MAX 1000000
#define mod 1000000007
#define pb push_back
#define f(i,a,n,x) for ((i)=(a);(i)<(n);(i)+=(x))
#define fd(i,a,n,x) for ((i)=(a);(i)>=(n);(i)-=(x))
#define fi first
#define se second
#define mk make_pair
#define pi pair
#define vt vector
#define ms multiset
using namespace std;
void read(vt<ll> &a,ll n){ll i,temp;f(i,0,n,1){cin>>temp;a.pb(temp);}}
ll fa[MAX];
ll power(ll p,ll q){
    ll res=1;
    p%=mod;
    while(q){
        if (q&1)
            res=(res*p)%mod;
        q>>=1;
        p=(p*p)%mod;
    }
    return res;
}
ll fact(ll n){
    if (n<=1)
        return fa[n]=1;
    if (fa[n])
        return fa[n];
    return fa[n]=(n*fact(n-1))%mod;
}
ll ncr(ll n,ll r){
    if (!r)
        return 1;
    return (((fact(n)*power(fact(n-r),mod-2))%mod)*power(fact(r),mod-2))%mod;
}
void solve(){
    ll n,d,i,x,y,ans=0;
    vt<pi<ll,ll>> v;
    cin>>n>>d;
    f(i,0,n,1){
        cin>>x>>y;
        v.pb(mk(x,y));
    }
    f(i,0,n,1)
        if (sqrt(v[i].fi*v[i].fi+v[i].se*v[i].se)<=d)
            ans++;
    cout<<ans<<endl;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll t=1;
    //cin>>t;
    while(t--)
        solve();
    return 0;
}

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

using namespace std;

int main()
{
	int a, b, c, d;
	scanf("%d %d %d %d", &a, &b, &c, &d);

	int mn = min(b, d);
	int mx = max(a, c);
	printf("%d\n", mn - mx >= 0 ? mn - mx : 0);

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <cmath>
typedef long long ll;
using namespace std;
#define INF 1<<30

int N,A,B,C;
vector<int> L;

int rec(int i, int a, int b, int c){
  if(i == N){
    if(!a || !b || !c) return INF;
    return abs(a-A) + abs(b-B) + abs(c-C) - 30;
  }

  int res = rec(i+1, a, b, c);
  res = min(res, rec(i+1, a+L[i], b, c)+10);
  res = min(res, rec(i+1, a, b+L[i], c)+10);
  res = min(res, rec(i+1, a, b, c+L[i])+10);

  return res;
  
}

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

  cout << rec(0, 0, 0, 0) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=100010;
int main()
{
    int x , y , z;
    while (~scanf("%d%d%d", &x,&y,&z)){
        printf("%d\n", (x-z)/(y+z));
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<algorithm>
#include<map>
#include<cstdlib>
#include<cmath>
#include<numeric>
#include<iomanip>
#include<functional>
#include<cstdlib>
#include<queue>
#include<deque>
const double PI = acos(-1);
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
using ll =long long;
const int mod = 1000000007;

//map<string>a
class mint {
	long long x;
public:
	mint(long long x = 0) : x((x% mod + mod) % mod) {}
	mint operator-() const {
		return mint(-x);
	}
	mint& operator+=(const mint & a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint & operator-=(const mint & a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint & operator*=(const  mint & a) {
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint & a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint & a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint & a) const {
		mint res(*this);
		return res *= a;
	}
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}
	// for prime mod
	mint inv() const {
		return pow(mod - 2);
	}
	mint& operator/=(const mint & a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint & a) const {
		mint res(*this);
		return res /= a;
	}

	friend ostream& operator<<(ostream & os, const mint & m) {
		os << m.x;
		return os;
	}
};
int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}
//組み合わせ
void recursive_comb(vector<int> indexes, int s, int rest, std::function<void(vector<int>)> f) {
	if (rest == 0) {
		f(indexes);
	}
	else {
		if (s < 0) return;
		recursive_comb(indexes, s - 1, rest, f);
		indexes[rest - 1] = s;
		recursive_comb(indexes, s - 1, rest - 1, f);
	}
}

// nCkの組み合わせに対して処理を実行する
void foreach_comb(int n, int k, std::function<void(vector<int>)> f) {
	vector<int>indexes(k);
	recursive_comb(indexes, n - 1, k, f);
}

ll gcd(ll a, ll b) {
	if (a % b == 0) {
		return b;
	}
	else {
		return gcd(b, a % b);
	}
}
ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
};
//fixed << setprecision(2)
int popcount(int x) {
	int ans=0;
	int tmp;
	while (x != 0) {
		tmp = x >> 2;
			tmp = tmp << 1;
			if (tmp == x) {
				ans++;
			}
			x >> 1;
	}
	return ans;

}
int main() {
	int k, x;
	cin >> k >> x;
	for (int i = x - k + 1; i <= x + k - 1; i++) {
		cout << i << " ";
	}
}
	


Measured memory_bytes: 3560
w1=int(input())
w2=int(input())
w3=int(input())
w4=int(input())
w5=int(input())
w6=int(input())
w7=int(input())
w8=int(input())
w9=int(input())
w10=int(input())

k1=int(input())
k2=int(input())
k3=int(input())
k4=int(input())
k5=int(input())
k6=int(input())
k7=int(input())
k8=int(input())
k9=int(input())
k10=int(input())

waseda=[w1,w2,w3,w4,w5,w6,w7,w8,w9,w10]
keio=[k1,k2,k3,k4,k5,k6,k7,k8,k9,k10]

waseda.sort()
keio.sort()

w=waseda[7]+waseda[8]+waseda[9]
k=keio[7]+keio[8]+keio[9]

print(w,k)






Measured memory_bytes: 5608
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<stdlib.h>
#include<cassert>
using namespace std;
const long long mod=1000000009;
const long long inf=mod*mod;
const long long d2=500000004;
const double EPS=1e-10;
const double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}

int main(){
	long long N,A,B;
	scanf("%lld%lld%lld",&N,&A,&B);
	if(A>B||(A!=B&&N==1)){
		printf("0\n");return 0;
	}
	printf("%lld\n",B*(N-2)-A*(N-2)+1);
}


Measured memory_bytes: 128
a, b, c = map(int, input().split())

if a == b:
    if a == c:
        print("No")
    else:
        print("Yes")
elif a == c:
    if a == b:
        print("No")
    else:
        print("Yes")
elif b == c:
    if a == b:
        print("No")
    else:
        print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <string>

#define rep(i, a, b) for ( int i = (a); i < (b); i++ )
#define per(i, a, b) for ( int i = (b)-1; i >= (a); i--)
#define pb push_back
#define mp make_pair
#define bg begin()
#define en end()
#define all(v) (v).begin(), (v).end()
#define sz(v) (int)(v).size()

using namespace std;

typedef long long ll;
typedef long double ld;

using P = pair<int, int>;

static const long long MOD = 1000000007;
static const long long LINF = (ll)(1e18+99);
static const int INF = 1e9+99;

int ans;

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

    if (a>b) {
        a -= v*t;
        b -= w*t;
        if (a<=b) puts("YES");
        else puts("NO");
    } else {
        a += v*t;
        b += w*t;
        if (a>=b) puts("YES");
        else puts("NO");
    }


    return 0;
}



Measured memory_bytes: 3652
#include<stdio.h>
#include<string.h>
int main(void)
{
    long int i,j,sum = 0,a,k;
    char s[11];
    scanf("%s",s);
    a = strlen(s);
    for(i = 0 ; i < (1 << (a - 1)) ; i++)
    {
        k = 1;
        sum += s[a - 1] - 48;
        for(j = 0 ; j <= a - 2 ; j++)
        {
            if((i >> j) & 1)
            {
                k *= 10;
            }
            else
            {
                k = 1;
            }
            sum += (s[a - 2 - j] - 48) * k;
        }
    }
    printf("%ld\n",sum);
    return 0;
}

Measured memory_bytes: 1704
n,m,k = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
a = [0]
b = [0]

for i in range(n):
    a.append(a[i] + A[i])
for i in range(m):
    b.append(b[i] + B[i])

ans = 0
j = m
for i in range(0, n+1):
    if a[i] > k:
        break
    while b[j] > k - a[i]:
        j -= 1
    ans = max(ans, i+j)

print(ans)

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

int main(){
    int N, M, X;
    std::cin >> N >> M >> X;
    std::vector< int > C(N);
    std::vector< std::vector< int > > A(N, std::vector< int >(M));
    
    for(int i=0; i<N; i++){
        std::cin >> C[i];
        for(int j=0; j<M; j++){
            std::cin >> A[i][j];
        }
    }
    
    int pat_max = 1;
    for(int i=0; i<N; i++){
        pat_max *= 2;
    }
    
    int min = 1e9;
    for(int pat=1; pat<pat_max; pat++){
        int pat_tmp = pat;
        std::vector< bool > tmp(N);
        for(int i=0; i<N; i++){
            tmp[i] = pat_tmp & 1;
            pat_tmp = pat_tmp >> 1;
        }
        int price = 0;
        std::vector< int > Xcur(M, 0);
        for(int i=0; i<N; i++){
            if(tmp[i]){
                for(int j=0; j<M;j++){
                    Xcur[j] += A[i][j];
                }
                price += C[i];
            }
        }
        bool ok = true;
        for(int i=0; i<M; i++){
            if(Xcur[i] < X){
                ok = false;
            }
        }
        if(ok){
            if(min > price){
                min = price;
            }
        }
    }
        
    
    if(min == 1e9){
        std::cout << -1 << std::endl;
    }else{
        std::cout << min << std::endl;
    }
    
    return 0;
}



Measured memory_bytes: 3608
N,K = map(int,input().split())
A = list(map(int,input().split()))

while True:
  if K == 0:
    break
  imosu = [0 for i in range(N+2)]
  for i in range(N):
    l = max(0,i-A[i])
    r = min(N-1,i+A[i])
    imosu[l] += 1
    imosu[r+1] -= 1
  A = [imosu[0]]
  for i in imosu[1:N]:
    A.append(A[-1]+i)
  K -= 1
  if min(A) == N:
    break
  
print(*A) 


Measured memory_bytes: 183604
#include<stdio.h>
int main(){
	int i,w,n,a,b;
	int c[31],tmp;
	scanf("%d %d",&w,&n);
	for(i=1;i<=w;i++){
		c[i]=i;
	}
	for(i=0;i<n;i++){
		scanf("%d,%d",&a,&b);
		tmp=c[a];
		c[a]=c[b];
		c[b]=tmp;
	}
	for(i=1;i<=w;i++){
		printf("%d\n",c[i]);
	}
	return 0;
}

Measured memory_bytes: 596
# https://atcoder.jp/contests/abc083/tasks/abc083_a

import itertools
import collections
import bisect
import sys
input = sys.stdin.readline

def main():
    A, B, C, D = map(int, input().split())
    if A + B == C + D:
        print("Balanced")
    else:
        print("Left" if A + B > C + D else "Right")


if __name__ == '__main__':
    main()


Measured memory_bytes: 3316
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <climits>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <cctype>
#include <complex>
#include <regex>

using namespace std;

constexpr int MOD = 1000000007;

int main() {

    int N;
    cin >> N;

    string S1, S2;
    cin >> S1 >> S2;

    long long ans = 1;
    long long index = 0;
    long long pre = -1;

    //縦
    if (S1[0] == S2[0]) ans *= 3, index = 1, pre = 0;

    //横
    if (S1[0] != S2[0]) ans *= 6, index = 2, pre = 1;

    while (true) {
        if (index >= N) break;
        if (S1[index] == S2[index]) {
            if (pre == 0) {
                ans *= 2;
                ans %= MOD;
                pre = 0;
                index++;
            } else if (pre == 1) {
                ans *= 1;
                ans %= MOD;
                pre = 0;
                index++;
            }
        } else {
            if (pre == 0) {
                ans *= 2;
                ans %= MOD;
                pre = 1;
                index += 2;
            } else if (pre == 1) {
                ans *= 3;
                ans %= MOD;
                pre = 1;
                index += 2;
            }
        }
    }

    cout << ans << endl;

    return 0;
}

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

using LL = long long;
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();i++)
#define RFOR(i,c) for(__typeof((c).rbegin())i=(c).rbegin();i!=(c).rend();i++)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
 
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
os<<"["; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"]"; return os;
}
template<class T> ostream& operator<<(ostream &os, const set<T> &t) {
os<<"{"; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"}"; return os;
}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}
// clang-format on

void solve(long long N, long long M, std::vector<long long> s, std::vector<long long> c) {
  // solver code

  // check valid

  vector<LL> D(N, -1);

  REP(i, M) {
    int keta = s[i] - 1;
    int num = c[i];

    // COUT(num);
    if (D[keta] == -1) {
      D[keta] = num;
    } else if (D[keta] != num) {
      cout << -1 << endl;
      return;
    }
  }

  if (N > 1 && D[0] == -1) {
    D[0] = 1;
  }
  int ans = 0;

  REP(i, N) {
    if (D[i] != -1) {
      ans += D[i] * pow(10, N - 1 - i);
    }
  }

  cout << ans << endl;
}

int main() {
  long long N;
  scanf("%lld", &N);
  long long M;
  scanf("%lld", &M);
  std::vector<long long> s(M);
  std::vector<long long> c(M);
  for (int i = 0; i < M; i++) {
    scanf("%lld", &s[i]);
    scanf("%lld", &c[i]);

    if (N != 1) {
      if (s[i] == 1 && c[i] == 0) {
        cout << -1 << endl;
        return 0;
      }
    }
  }
  solve(N, M, std::move(s), std::move(c));
  return 0;
}


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

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}

int main() {
	int n = ri();
	int m = ri();
	int l = ri();
	std::vector<std::pair<int, int> > hen[n];
	for (int i = 0; i < m; i++) {
		int a = ri() - 1, b = ri() - 1, c = ri();
		hen[a].push_back({b, c});
		hen[b].push_back({a, c});
	}
	int res[n][n];
	for (int i = 0; i < n; i++) {
		std::vector<std::pair<int, int> > dist(n, {1000000001, 0});
		dist[i] = {0, 0};
		using T = std::pair<std::pair<int, int> , int>;
		std::priority_queue<T, std::vector<T>, std::greater<T> > que;
		que.push({{0, 0}, i});
		while (que.size()) {
			auto cur = que.top();
			que.pop();
			if (cur.first != dist[cur.second]) continue;
			int i = cur.second;
			int cnt = cur.first.first;
			int left = l - cur.first.second;
			for (auto j : hen[i]) {
				if (j.second > l) continue;
				std::pair<int, int> new_cost;
				if (j.second > left) {
					new_cost = {cnt + 1, j.second};
				} else new_cost = {cnt, cur.first.second + j.second};
				if (new_cost < dist[j.first]) dist[j.first] = new_cost, que.push({new_cost, j.first});
			}
		}
		for (int j = 0; j < n; j++) res[i][j] = dist[j].first == 1000000001 ? -1 : dist[j].first;
	}
	int q = ri();
	for (int i = 0; i < q; i++) {
		int a = ri() - 1, b = ri() - 1;
		std::cout << res[a][b] << std::endl;
	}
	return 0;
}



Measured memory_bytes: 2612
#!/bin/sh
export LC_ALL=C
read n
read s
read t
if [ "$s" = "$t" ]
then
	echo $n
	exit
fi
for i in `seq $n`
do
	cnt=$((i - 1))
	if [ `echo $t | egrep -c "^${s:$cnt:$n}"` -eq 1 ]
	then
		ans="${s/${s:$cnt:$n}/}$t"
		break
	fi
done
if [ ! "${ans}" ]
then
	ans=$s$t
fi
echo ${#ans}


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

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

    int a[200010];

    int b[200010];
    for(int i = 0;i < n;i++){
        cin >> a[i];
        b[a[i]] = i;
    }

    int dp[200010];

    dp[1] = 1;

    for(int i = 2;i <= n;i++){
        if(b[i-1] < b[i]){
            dp[i] = dp[i-1]+1;
        }else{
            dp[i] = 1;
        }
    }

    int ans = INT_MAX;

    for(int i = 0;i < n;i++){
        ans = min(ans, n-dp[i+1]);
    }

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

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

p = [[0, 0] for i in range(n)]
for i in range(n):
  p[i] = list(map(int, input().split()))
  
p.sort()

cnt = 0
for i in range(n):
  cnt += p[i][1]
  if cnt >= k:
    print(p[i][0])
    break

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

using namespace std;
typedef long long int ll;

int main()
{
    int N;
    cin >> N;
    int AC = 0, WA = 0, TLE = 0, RE = 0;
    for(int i = 0; i < N;i++)
    {
        string S;
        cin >> S;
        if(S == "AC") AC++;
        if(S == "WA") WA++;
        if(S == "TLE") TLE++;
        if(S == "RE") RE++;
    }
    cout << "AC" << " x " << AC << endl;
    cout << "WA" << " x " << WA << endl;
    cout << "TLE"<< " x " << TLE << endl;
    cout << "RE" << " x " << RE << endl;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,a,n) for(ll i = a;i < n;i++)
#define rrep(i,a,n) for(ll i = n; i >= a;i--)
#define LINF 1e18
#define INF 1e9
using namespace std;

#define P pair<ll,ll>
#define fs first
#define sc second

int main(){
    string s,t;
    cin >> s >> t;

    rep(i,0,s.size()){
        if(s[i] != t[i]){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 3628
///Bismillahir Rahmanir Rahim
#include<bits/stdc++.h>

#define                           int                         long long
#define                           fi                          first
#define                           si                          second
#define                           mp                          make_pair
#define                           pb                          push_back
#define                           pi                          pair<int,int>
#define                           f(i,l,r)                    for(int i=l;i<=r;i++)
#define                           rf(i,r,l)                   for(int i=r;i>=l;i--)
#define                           done(i)                     cout<<"done = "<<i<<endl;
#define                           fast                        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);




using namespace std;

const int inf=1e18;
const int mod=998244353;
const int M=3123;
inline int bigmod(int B,int P){int R=1;while(P>0){if(P&1){R=(R*B)%mod;}P>>=1;B=(B*B)%mod;}return R;}

int n,s;
int a[M+3];
int d[M+3];
int dp[M+3][M+2];
inline void yo(int &x)
{
    if(x<0)x+=mod;
    x=x%mod;
}
int solve(int pos,int sum)
{
    if(sum<0)return 0;
    int &ret=dp[pos][sum];
    if(ret!=(-1))return ret;
    ret=0;
    if(sum==0)
    {
         ret=n-(pos-1)+1;
        return ret;
    }
    if(pos>n)
    {
        return ret;
    }
    ret=solve(pos+1,sum-a[pos]);yo(ret);
    ret=ret+solve(pos+1,sum);yo(ret);
    return ret;
}
 main()

{
    fast
    memset(dp,-1,sizeof dp);
    cin>>n>>s;
    f(i,1,n)cin>>a[i];
    int ses=0;
    for(int i=n;i>=1;i--)
    {
        d[i]=d[i+1]+solve(i+1,s-a[i]);
        ses=ses+d[i];
        yo(ses);
    }
    cout<<ses<<endl;
    return 0;

}













Measured memory_bytes: 76672