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

int main() {
    string s;
    cin >> s;
    if(s.length() % 2 == 1)cout << "No";
    else{
        bool ans = true;
        for(int i = 0; i < s.length(); i++){
            if(i % 2 == 0){
                if(s.at(i) != 'h')ans = false;
            }else{
                if(s.at(i) != 'i')ans = false;
            }
        }
        cout << ((ans) ? "Yes" : "No");
    }    
}

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

long double r[4] ;
long double l[4] ;
long double u[4] ;
long double d[4] ;

long double f(long double t){

    long double maxx = max(max(r[1]+t, l[1]-t), max(u[1],d[1])) ;
    long double minx = min(min(r[0]+t, l[0]-t), min(u[0],d[0])) ;
    long double maxy = max(max(u[3]+t, d[3]-t), max(r[3],l[3])) ;
    long double miny = min(min(u[2]+t, d[2]-t), min(r[2],l[2])) ;
    return (maxx - minx) * (maxy - miny) ;

}

int main(){


    r[0] = 1e11 ;
    r[1] = -1e11 ;
    r[2] = 1e11 ;
    r[3] = -1e11 ;
    l[0] = 1e11 ;
    l[1] = -1e11 ;
    l[2] = 1e11 ;
    l[3] = -1e11 ;
    u[0] = 1e11 ;
    u[1] = -1e11 ;
    u[2] = 1e11 ;
    u[3] = -1e11 ;
    d[0] = 1e11 ;
    d[1] = -1e11 ;
    d[2] = 1e11 ;
    d[3] = -1e11 ;
    long double n ;
    cin >> n ;
    for(long double i = 0; i < n; i++){

        long double x, y ;
        char di ;
        cin >> x >> y >> di ;
        if(di == 'R'){
            r[0] = min(r[0], x) ;
            r[1] = max(r[1], x) ;
            r[2] = min(r[2], y) ;
            r[3] = max(r[3], y) ;
        }
        if(di == 'L'){
            l[0] = min(l[0], x) ;
            l[1] = max(l[1], x) ;
            l[2] = min(l[2], y) ;
            l[3] = max(l[3], y) ;
        }
        if(di == 'U'){
            u[0] = min(u[0], x) ;
            u[1] = max(u[1], x) ;
            u[2] = min(u[2], y) ;
            u[3] = max(u[3], y) ;
        }
        if(di == 'D'){
            d[0] = min(d[0], x) ;
            d[1] = max(d[1], x) ;
            d[2] = min(d[2], y) ;
            d[3] = max(d[3], y) ;
        }

    }

    long double yo = 0.000001 ;
    long double g = 1e10 ;
    long double p = 1e10 ;
    long double tmp = f(g) ;
    long double tmp2 = f(g+yo) ;
    while(p > yo){

        p/=2 ;
        if (tmp > tmp2)
            g+= p ;
        else
            g-= p ;
        tmp = f(g) ;
        tmp2 = f(g+yo) ;
    }
    cout << fixed << setprecision(10) << f(round(g*1000)/1000) << endl ;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 0x3f3f3f3f
#define rep(i, a, n) for (int i=(a); i<(n); i++)
#define per(i, a, n) for (int i=(a); i>(n); i--)
typedef long long ll;
const int maxn = 2e5+5;
const int mod = 1e9+7;
using namespace std;

ll a[maxn], b[maxn];

void solve() {
	ll n; cin >> n;
	rep(i,0,n) cin >> a[i] >> b[i];
	rep(i,0,n-2) {
		if (a[i] == b[i] && a[i+1] == b[i+1] && a[i+2] == b[i+2]) {
			cout << "Yes\n";
			return;
		} 
	}
	cout << "No\n";
}

int main(int argc, char * argv[]) 
{
	ios_base::sync_with_stdio(false); cin.tie(0);
#ifdef DEBUG
	freopen("C:/Users/Fish_Brother/Desktop/in", "r", stdin);
	//freopen("C:/Users/Fish_Brother/Desktop/out", "w", stdout);
#endif

	//int t; cin >> t; while(t--)
	solve();

    return 0;
}

Measured memory_bytes: 3652
x,y,z,k = map(int, input().split())
aa = sorted(map(int, input().split()))
bb = sorted(map(int, input().split()))
cc = sorted(map(int, input().split()))
# 上のsortedがないとTLEする。
# 

ab = sorted(a+b for a in aa for b in bb)[:-k-1:-1]
abc = sorted(s+c for s in ab[:k] for c in cc)[:-k-1:-1]
print(*abc, sep='\n')


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

bool is_good_set(int a, int b, int c) {
    auto is_same_card = [](int a, int b, int c) {
        return a == b and b == c;
    };
    auto is_sequence = [](int a, int b, int c) {
        return a + 1 == b and b + 1 == c;
    };
    return is_same_card(a, b, c) or is_sequence(a, b, c);
}

bool is_all_good_set(vector<int> &cc) {
    return is_good_set(cc[0], cc[1], cc[2])
        && is_good_set(cc[3], cc[4], cc[5])
        && is_good_set(cc[6], cc[7], cc[8]);
}

int win(vector<int> &cards) {
    sort(cards.begin(), cards.end());
    do {
        if (is_all_good_set(cards)) return 1;
    } while (next_permutation(cards.begin(), cards.end()));
    return 0;
}

int main() {
    int T; cin >> T;
    while (T--) {
        vector<int> cards(9);
        for (auto &card: cards) cin >> card;
        for (auto &card: cards) {
            string color; cin >> color;
            if (color == "G") card += 10;
            if (color == "B") card += 20;
        }
        cout << win(cards) << endl;
    }
    return 0;
}


Measured memory_bytes: 3028
#include <iostream>
int main() {
  int n, ans, p, pmax = 0;
  std::cin >> n;
  while(std::cin >> p) {
    ans += p;
    (p>pmax?pmax=p:pmax=pmax);
  }
  ans -= pmax / 2;
  std::cout << ans << "\n";
}
    

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define REP(i, a, b) for (int i = (a); i <= (b); ++i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FORD(i, a, b) for(int i = (a); i > (b); --i)
#define REPD(i, a, b) for(int i = (a); i >=(b); --i)
#define TR(it, a) for(__typeof(a.begin()) it = a.begin(); it != a.end(); ++it)
#define endl '\n'
#define mp make_pair
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define ins insert
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define unmap unordered_map
#define pq priority_queue
#define minEle min_element
#define maxEle max_element
#define lb lower_bound //first pos >= val
#define ub upper_bound // first pos > val
#define bp __builtin_popcount
#define debug(a) cout << a << endl
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair <ll, ll> pll;
typedef pair <int, int> pii;
typedef pair <pii, int> ppi;
typedef pair <int, pii> pip;
typedef pair <ll, ld> pld;
typedef pair <ll, pll> pllp;
typedef pair <pll, ll> ppll;
typedef vector <int> vi;
typedef vector <ll> vll;
typedef vector <pll> vpll;
typedef vector <pii> vpii;
typedef map <int, int> mii;
typedef map <ll, ll> mll;
typedef string BigNum;

const ll maxN = 1e18;
const ll minN = -1e18;
const ll MOD = 1e9 + 7;
const ll MOD1 = 998244353;
const int baseHash = 331;
const int bigNumLength = 5000;
const ld PI = acos(-1);

//Remember limit for IT, etc..., and +1 in limit of any array
const ll limit = 2e5 + 5;
const ll limit1 = 1e6 + 5;
const ll limit2 = 1e3 + 5;
//If TLE let's use int instead of ll because it's as slow as your WPM :)))

/*----IMPORTANT THINGS----*/
pii dir[] = {{0, 1}, {1, 0}, {0, -1}, {-1, 0}, {1, 1}, {1, -1}, {-1, 1}, {-1, -1}};
//right down left up rightdown leftdown rightup leftup
pii NON = {-1, -1};
/*------------------------*/

ll n, m;
ll w[limit], v[limit];
ll f[limit];

void solveProblem() {
    ll ans = 0;

    REP(i, 1, n) {
        REPD(j, m, w[i]) {
            f[j] = max(f[j], f[j - w[i]] + v[i]);
        }
    }

    cout << f[m] << endl;
}

void fastInput() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}

void readInput() {
    cin >> n >> m;
    REP(i, 1, n) cin >> w[i] >> v[i];
}

int main() {
    fastInput();
    readInput();
    solveProblem();
}



Measured memory_bytes: 4408
import math
def wow(s):
    return s+3*s*(s-1)+s*(s-1)*(s-2)


n,k=map(int,input().split())

s=n//k
if k%2!=0:
    if s==1:
        print(1)
    elif s==2:
        print(8)
    else:
        print(wow(s))
else:
    print(wow(s)+wow(((n-(k//2))//k)+1))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; ++i)
using ll = long long;
using namespace std;
const int INF = 1e9;

int main() {

    int N;
    cin >> N;
    vector<int> A(N * 2);
    rep(i, N * 2) cin >> A[i];

    sort(A.begin(), A.end());
    int ans = 0;
    rep(i, N)
        ans += A[i * 2];

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
h, w, a, b = map(int, input().split())

mod = 10**9 + 7
fac = [1, 1]
inv = [1, 1]
finv = [1, 1]
for i in range(2, h+w+5):
    fac.append(fac[i-1] * i % mod)
    inv.append(mod - inv[mod%i] * (mod//i) % mod)
    finv.append(finv[i-1] * inv[i] % mod)

def nck(n, k):
    if n < k:
        return 0
    if n < 0 or k < 0:
        return 0
    return fac[n] * (finv[k] * finv[n-k] % mod) % mod

ans = 0
for i in range(h-a):
    ans += nck(i+b-1, b-1) * nck(h-1-i + w-b-1, w-b-1) % mod
    ans %= mod

print(ans)

Measured memory_bytes: 27092
import itertools
from collections import deque,defaultdict,Counter
from itertools import accumulate
import bisect
from heapq import heappop,heappush
from fractions import gcd
from copy import deepcopy
import math
import queue
#import numpy as np
#import sympy as syp(素因数分解とか)
Mod = 1000000007
import sys

sys.setrecursionlimit(100000) 
  
def sieve_of_eratosthenes(n):
    if not isinstance(n,int):
        raise TypeError("n is not int")
    if n<2:
        raise ValueError("n is not effective")
    prime = [1]*(n+1)
    for i in range(2,int(math.sqrt(n))+1):
        if prime[i] == 1:
            for j in range(2*i,n+1):
                if j%i == 0:
                    prime[j] = 0
    res = []
    for i in range(2,n+1):
        if prime[i] == 1:
            res.append(i)
    return res

def factorial(i):
    if i == 1:
        return 1
    else:
        return i*factorial(i-1)
 
class UnionFind:
    def __init__(self,n):
        self.parent = [i for i in range(n+1)]
        self.rank = [0 for i in range(n+1)]
    
    def findroot(self,x):
        if x == self.parent[x]:
            return x
        else:
            y = self.parent[x]
            y = self.findroot(self.parent[x])
            return y
    
    def union(self,x,y):
        px = self.findroot(x)
        py = self.findroot(y)
        if px < py:
            self.parent[py] = px
        else:
            self.parent[px] = py
 
    def same_group_or_no(self,x,y):
        return self.findroot(x) == self.findroot(y)




def main(): #startline--------------------------------------------
    n,m = map(int,input().split())
    p = list(map(int,input().split()))
    xy = [list(map(int,input().split())) for i in range(m)]
    un = UnionFind(n)
    for i in range(m):
        un.union(xy[i][0]-1,xy[i][1]-1)
    ans = 0
    for i in range(n):
        if un.same_group_or_no(i,p[i]-1):
            ans += 1
    print(ans)
if __name__ == "__main__":
    main() #endline===============================================
    

Measured memory_bytes: 38112
import java.io.{BufferedOutputStream, BufferedReader, InputStreamReader, PrintWriter}

object Main {
  def main(args: Array[String]): Unit = {
    val in = new BufferedReader(new InputStreamReader(System.in))
    val out = new PrintWriter(new BufferedOutputStream(System.out))
    val Array(a, b, x) = in.readLine().split("\\s+").map(_.toLong)

    out.println(b / x - a / x + (
      if (a % x == 0) {
        1
      } else {
        0
      }
      ))

    out.flush()
  }
}


Measured memory_bytes: 27164
if __name__ == '__main__':
	n = int(input())
	suits = [ 'S' , 'H', 'C', 'D']
	num = list(range(1,14))
	
	all = []
	for i in suits:
		for k in num:
			all.append([i,str(k)])
	
	data = []
	for i in range(n):
		data.append(input().split())
	
	for i in all:
		if not i in data:
			print(i[0]+" "+i[1])


Measured memory_bytes: 5600
#include<stdio.h>
int main()
{
     int N,X[100],i,k=0,j=0,a,stamina,total_stamina=0;
     scanf("%d",&N);
     for(i=0;i<N;i++)
     {
     	scanf("%d",&X[i]);
     	k=k+X[i];
	 }
	 a=k/N;
	 float P,q;
	 P=k%N;
	 q=P/N;
	 if(q>0.5){
	 	j=a+1;
	 }
	 else 
	 {
	 	j=a;
	 }
	 for(i=0;i<N;i++)
	 {
	 	stamina=(X[i]-j)*(X[i]-j);
	 	total_stamina=total_stamina+stamina;
	 	
	 }
	 printf("%d\n",total_stamina);
	return 0;
}


Measured memory_bytes: 128
#define		_CRT_SECURE_NO_WARNINGS
#include <cstdio>

#define		NIL		(-1)

int main()
{
	int		m, f, r;

	for (;;)
	{
		scanf("%d %d %d", &m, &f, &r);

		if ((m == NIL) && (f == NIL) && (r == NIL))
		{
			break;
		}

		if ((m == NIL) || (f == NIL))
		{
			printf("F\n");
		}
		else
		{
			int sum = m + f;

			if (sum >= 80)
			{
				printf("A\n");
			}
			else if (sum >= 65)
			{
				printf("B\n");
			}
			else if (sum >= 50)
			{
				printf("C\n");
			}
			else if (sum >= 30)
			{
				if (r >= 50)
				{
					printf("C\n");
				}
				else
				{
					printf("D\n");
				}
			}
			else
			{
				printf("F\n");
			}
		}
	}

	return 0;
}

Measured memory_bytes: 2692
#include <bits/stdc++.h>
using namespace std;
using ll = long long ;
using P = pair<ll, ll>;
using Vec = vector<ll>;
using VecP = vector<P>;
#define FOR(i, m, n) for(ll (i) = (m); (i) < (n); ++(i))
#define FORN(i, m, n) for(ll (i) = (m); (i) <= (n); ++(i))
#define FORR(i, m, n) for(ll (i) = (m); (i) >= (n); --(i))
#define rep(i, n) FOR(i, 0, n)
#define repn(i, n) FORN(i, 1, n)
#define repr(i, n) FORR(i, n, 0)
#define repnr(i, n) FORR(i, n, 1)
#define co(n) cout << (n) << endl
#define cosp(n) cout << (n) << ' '
#define setp(n) cout << fixed << setprecision(n);
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define mp make_pair
#define fs first
#define sc second

const ll INF = 1e9+1;
const ll LINF = 1e18+1;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const double PI = acos(-1);
const double EPS = 1e-9;

int main(void){
	ll m1, d1, m2, d2;
	cin >> m1 >> d1 >> m2 >> d2;
	if(m1 == m2) co(0);
	else co(1);

	return 0;
}


Measured memory_bytes: 764
#include<iostream>


using namespace std;

int main(){
  int n;
  cin >> n;
  //int *a = (int*)malloc(sizeof(int)*n);
  int flug = 1;
  for(int i=0;i<n;i++){
    int a;
    cin >> a;
    int g = int(a%2==0);
    int san = int(a%3==0);
    int go = int(a%5==0);
    int sum = (san+go);
    //cout << a << endl;
    //cout << g << " " << go << " " << san << endl;
    if(g && sum==0){
      cout << "DENIED" << endl;
      return 0;
    }
  }
  cout << "APPROVED" << endl;
  return 0;
}


Measured memory_bytes: 256
N,M = map(int,input().split())
A = [input() for _ in range(N)]
B = [input() for _ in range(M)]

FLG = 0
for i in range(N-M+1):
    for j in range(N-M+1):
        cnt = 0
        for k in range(M):
            if B[k]==A[i+k][j:j+M]:
                cnt += 1
        if cnt==M: FLG = 1

if FLG: print("Yes")
else: print("No")

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    ll N, A;
    cin >> N >> A;
    if(N % 500 <= A) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <iomanip>
#include <map>
#include <stack>
using namespace std;

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	for (int i = 1; i < b; i++) {
		if (a * i % b == c) {
			cout << "YES" << endl;
			return 0;
		}
	}
	cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 3632
from sys import stdin
from itertools import accumulate
def main():
    #入力
    readline=stdin.readline
    n,m,q=map(int,readline().split())
    table=[[0]*n for _ in range(n)]
    for i in range(m):
        l,r=map(lambda x:int(x)-1,readline().split())
        table[l][r]+=1

    #累積和
    for i in range(n):
        table[i]=list(accumulate(table[i]))

    ans=[0]*q
    for i in range(q):
        l,r=map(lambda x:int(x)-1,readline().split())
        t=0
        for j in range(l,r+1):
            t+=table[j][r]
        ans[i]=t

    for i in range(q):
        print(ans[i])

if __name__=="__main__":
    main()

Measured memory_bytes: 56796
#include<stdio.h>
int main()
{
	int n,x,y,h,w,s,l;
	while(scanf("%d",&n),n)
	{
		s=0;
		while(n--)
		{
			scanf("%d%d%d%d",&x,&y,&h,&w);
			l=x+y+h;
			if(l<=60 && w<=2) s+=600;
			else if(l<=80 && w<=5) s+=800;
			else if(l<=100 && w<=10) s+=1000;
			else if(l<=120 && w<=15) s+=1200;
			else if(l<=140 && w<=20) s+=1400;
			else if(l<=160 && w<=25) s+=1600;
		}
		printf("%d\n",s);
	}
	return 0;
}

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

int n,m,num,total;

int main(){
	cin>>m>>n;
	for(int i = 1;i <= n;i++){
		cin>>num;
		total = total+num;
	}
	if(total >= m){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define maxn 500005
#define ll long long
#define endl '\n'
using namespace std;
int arr[maxn];
ll dp[maxn];
bool ans[maxn];
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n,d;
	cin >> n >> d;
	for(int i=1;i<=n;i++)
		cin >> arr[i];
	dp[n] = 1;
	for(int i=n-1;i>=1;i--) {
		if(dp[i+1] * 2 <= arr[i+1])	
			dp[i] = dp[i+1];
		else
			dp[i] = dp[i+1] + arr[i+1];
	}
	for(int i=1;i<=n;i++) {
		if((ll)d >= dp[i]) 
			ans[i] = true;
		d = min(d,abs(d - arr[i]));
	}
	int q;
	cin >> q;
	while(q--) {
		int idx;
		cin >> idx;
		cout << (ans[idx] ? "YES" : "NO") << endl;
	}
	return 0;
}


Measured memory_bytes: 8320
import sys
import heapq
o=lambda:map(int,raw_input().split())
n=int(raw_input())
e=[[] for _ in range(n+1)]
for _ in range(n-1):a,b=o();e[a]+=[(b,1)];e[b]+=[(a,1)]
k=int(raw_input())
for _ in range(k):v,p=o();e[v]+=[(0,p)];e[0]+=[(v,p)]
vis=[False]*(n+1)
cost=[10**9]*(n+1)
q=[(0,0)]
heapq.heapify(q)
while len(q):
    c,v=heapq.heappop(q)
    vis[v]=True
    cost[v]=c
    for (w,d) in e[v]:
        if not vis[w] and c+d<cost[w]:
            heapq.heappush(q,(c+d,w))
            cost[w]=c+d
for i in range(1,n+1):
    for w,d in e[i]:
        if w!=0 and abs(cost[i]-cost[w])!=1:print 'No';sys.exit()
print 'Yes'
for i in range(n):print cost[i+1]


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

using namespace std;

int main(int argc, char *argv[]) {
    int N;
    cin >> N;
    vector<int> arr(N);
    for (int i = 0; i < N; i++) cin >> arr[i];
    int ans = 0;
    for (int j = 0; j < N; j++) {
        if ((j + 1) % 2 == 1 && arr[j] % 2 == 1) ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3628
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<numeric>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;
typedef pair<ll, ll> mp;

/*
AC
上のbitから順に0,1を選択する．
O(log(K)*n)なので間に合う

7 127
10 5
7 4
11 4
9 8
3 6
6 2
8 9

3 67
10 5
7 4
11 4

*/

//累乗法
ll mod_pow(ll x,ll n,ll mod=1e18+7){
	ll res=1;
	while(n){
		if(n&1) (res*=x)%=mod;
		(x*=x)%=mod;
		n>>=1;
	}
	return res;
}

int main(void){
	ll n,k,a[100010],b[100010],cur=0,ans=0;
	cin>>n>>k;
	rep(i,n)cin>>a[i]>>b[i];
	rep(j,n)if((a[j]|k)==k)ans+=b[j];
	// cout<<bitset<8>(k)<<endl;
	irep(i,31){//最上位bitがどうなってるかの確認
		ll c=mod_pow(2,i),d=k/c;//d：最上位bit
		k-=c*d;
		if(d==1){
			//f：d=0にして，下の桁を全て1にした数
			ll f=cur+c-1,sum=0;
			rep(j,n)if((a[j]|f)==f)sum+=b[j];
			ans=max(ans,sum);
			// cout<<bitset<8>(f)<<endl;
		}
		cur+=c*d;
	}
	cout<<ans<<endl;
	return 0;
}

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

int main(){
  string str;
  cin >> str;
  int cnt = 0;
  for(int i=0; i<(str.length()/2); i++){
    if(str[i] != str[str.length()-1-i]) cnt++;
  }
  cout << cnt << endl;
  return 0;
}

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

int main(){
    double n,k,x,y;
    cin>>n>>k>>x>>y;
    cout<<fixed<<setprecision(12)<<n*k/2<<" ";
    if(2*x==n&&2*y==k)cout<<"1"<<endl;
    else cout<<"0"<<endl;
    return 0;
}

Measured memory_bytes: 3744
#include <bits/stdc++.h>
#define int LL
#define rep(i,a,b) for(int i=a;i<b;i++)
#define per(i,b,a) for(int i=b;i>=a;i--)
#define For(i,a,b) for(int i=a;i<=b;i++)
#define Forenska(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define sqr(x) ((x)*(x))
#define lowbit(x) ((x)&(-x))
#define GREATER(x) x,vector<x>,greater<x>
#define randIn(L,R) (((LL)rand()*rand())%(R-L)+L)
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pLL;
typedef vector<int> vec;
typedef vector<LL> vecL;
typedef vector<pii> vecP;
typedef vector<pLL> vecPL;
typedef vector<string> vecS;
typedef vector<vec> mat;
typedef complex<double> point;
const long double PI=3.14159265358979323846264338327950;
const LL INFLL=0x3f3f3f3f3f3f3f3f;
const int INF=0x3f3f3f3f;
const long double EPS=1e-10;
int read()
{
    int x=0;
    char ch=' ';
    bool flag=false;
    while(ch<'0' || ch>'9')
    {
        if(ch=='-')flag=true;
        ch=getchar();
    }
    while(ch>='0' && ch<='9')
    {
        x=(x<<3)+(x<<1)+ch-'0';
        ch=getchar();
    }
    return flag?-x:x;
}
int lcm(int a,int b)
{
	return a/__gcd(a,b)*b;
}
const int MAX_N=100005;
int n,A,B;
int h[MAX_N];
bool check(int k)
{
	int lazy=k*B;
	int res=0;
	rep(i,0,n)res+=ceil(1.0*(h[i]-lazy>0?h[i]-lazy:0)/(A-B));
	return res<=k;
}
signed main()
{
	cin>>n>>A>>B;
	rep(i,0,n)cin>>h[i];
	int lb=1,ub=INF;
	while(lb<ub)
	{
		int mid=(lb+ub)/2;
	//	cout<<mid<<endl;
		if(check(mid))ub=mid;
		else lb=mid+1;
	}
	cout<<lb<<endl;
	return 0;
}

Measured memory_bytes: 1024
from datetime import datetime
import random
starttime=datetime.now()
D=int(input())
c=list(map(int,input().split()))
s=[list(map(int,input().split())) for i in range(D)]
def evaluate(t):
    last=[[0 for j in range(26)] for i in range(D)]
    manzokudo=0
    res=[]
    for d in range(D):
        for i in range(26):
            if d!=0:
                last[d][i]=last[d-1][i]
        last[d][t[d]]=d+1
        manzokudo+=s[d][t[d]]
        for i in range(26):
            manzokudo-=c[i]*(d+1-last[d][i])
        res.append(manzokudo)
    return res
solution=[]
for i in range(D):
    j=0
    for k in range(26):
        if s[i][k]>s[i][j]:
            j=k
    solution.append(j)
nowmanzoku=evaluate(solution)
while((datetime.now()-starttime).total_seconds()<1.9):
    d=random.randrange(D)
    q=random.randrange(26)
    p=solution[d]
    
    solution[d]=q
    nextmanzoku=evaluate(solution)
    if nextmanzoku>nowmanzoku:
        nowmanzoku=nextmanzoku
    else:
        solution[d]=p
for i in solution:
    print(i+1)

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

using namespace std;

const int mod = 1e9 + 7;

void add(int&a,int b) {
	if ((a += b) >= mod) a -= mod;
}

int mul(int a,int b) {
	return 1ll * a * b % mod;
}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin >> n;
	int now = 0;
	int ans = 0;
	for (int i = 1;i <= n;i++) {
		int x;
		cin >> x;
		add(ans,mul(now,x));
		add(now,x);
	}
	cout << ans;
} 

Measured memory_bytes: 3648
#include <algorithm>
#include <iostream>
#include <numeric>
#include <vector>
using namespace std;

int main() {
	vector<int> a(4), b(4);
	for (int& i : a) cin >> i;
	for (int& i : b) cin >> i;
	cout << max(accumulate(a.begin(), a.end(), 0), accumulate(b.begin(), b.end(), 0)) << endl;
}


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

using ll = long long;
using P = pair<int, int>;
using edge = struct {int to; ll cost;};

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

const int di[] = {-1, 0, 1, 0, 1, 1, -1, -1};
const int dj[] = {0, -1, 0, 1, 1, -1, 1, -1};
const int INF = 1001001001;

const int mod = 1000000007;
struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    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;
  }
};
struct combination
{
  vector<mint> fact, ifact;
  combination(int n) : fact(n + 1), ifact(n + 1)
  {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i)
      fact[i] = fact[i - 1] * i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i)
      ifact[i - 1] = ifact[i] * i;
  }
  mint operator()(int n, int k)
  {
    if (k < 0 || k > n)
      return 0;
    return fact[n] * ifact[k] * ifact[n - k];
  }
};

//long long gcd(long long a, long long b);
//long long lcm(long long a, long long b);

void solve()
{
  int n;
  cin >> n;
  vector<ll> x(n);
  vector<ll> b(n);
  rep(i, n) {
    ll a;
    cin >> a;
    x[i] = a;
    b[i] = a;
  }
  sort(ALL(b));
  rep(i, n) {
    if(x[i] >= b[n/2]) cout << b[n/2-1] << "\n";
    else cout << b[n/2] << "\n";
  }
}

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

Measured memory_bytes: 5376
A = int(input())
B = int(input())
C = int(input())
X = int(input())

result = 0
for i in range(A+1):
    for j in range(B+1):
        for k in range(C+1):
            if 500*i + 100*j + 50*k == X:
                result += 1
print(result)

Measured memory_bytes: 3060
// MOHIT KUMAR
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pin;
typedef pair<ll, ll> pl;
typedef pair<ld, ld> pd;
void change(ll&a , ll b) {a = max(a, b);}
#define ff(i, a, b) for ( ll i=a; i<(b); i++)
#define ffd(i, a, b) for ( ll i=a; i<= b; i++)
#define fr(i, a, b) for ( ll i = (b)-1; i >= a; i--)
#define ffr(i, a, b) for ( ll i = b ; i >= a; i--)
#define vl vector < ll >
#define vp vector < pl >
#define endl "\n"
#define sz(x) (ll)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()

const ld pi = acos(-1) ;
const ll maxn = 105 ;
const int mod = 1e9 + 7 ;
const ll INF = 1e18 ;
const int MX = 2000000001 ; // check the limits, dummy

int main() {
  ios_base::sync_with_stdio(0) , cin.tie(0);
  ll t, q, n, a, b, c, d, k, l, m, r,  x = 0, y = 0, z = 0 , sum = 0, ans = 0, temp = 0, res = 0 ;
  string s ;
  cin >> n ;
  vl dp(n + 1, 0) ;
  dp[0] = 1 ;
  ffd(i, 3, n) {
    ffr(j, 0, i - 3) {
      dp[i] += dp[j] % mod ;
      dp[i] %= mod ;
    }
  }
  cout << dp[n] ;
}

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

int main() {
  int x, n;
  cin >> n >> x;
  int cnt = 1;
  int pos = 0;
  rep(i, n){ 
    int diff;
    cin >> diff;
    pos += diff;
    if(pos <= x) cnt++;
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 256
height,width = map(int,input().split())

if height%2==0:
  h1=height//2
  h2=height//2
else:
  h1 = height//2 +1
  h2 = height//2

if height==1 or width ==1:
  ans = 1
else:
  ans = (h1+h2)*(width//2) + h1*(width%2)
print(ans)

Measured memory_bytes: 3060
N = int(input())

def dfs(s): # 文字列 s で始まる七五三数の個数
  if int(s) > N: # Nを超えるまで実行
    return 0
  ret = 1 if all(s.count(c) > 0 for c in '753') else 0 # s 自体が七五三数なら +1
  for c in '753':
    ret += dfs(s + c) # 753の1文字を足して実行
  return ret # 753数がいくつあるかカウント

print(dfs('0')) # 本当は dfs('') と書きたいが 4 行目でのエラーを防ぐため仕方なく

Measured memory_bytes: 2940
# import copy

# N = list(map(int,input().split(' ')))
# X =[input() for i in range(N[0])] 

def p(X):
    print(X)

N = input()
S = [str(c) for c in N]

count = 0

if S.count('R') >= 1:
    if S[1] == 'S':
        if S.count('R') ==2:
            count = 1
        else:
            count = 1
    else:
        count = S.count('R')

print(count)

Measured memory_bytes: 9112
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
#define MP make_pair
#define INF (sizeof(int) == 4 ? 1e9:1e18)
#define EPS 0.0000000001
using namespace std;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
template<class T> void join(T a){int b=0;for(auto itr :a){if(b++!=0)cout << " "; cout << itr;} }
using ll  = long long;
using ld  = long double;
using pii = pair<int,int>;
using piii = pair<int,pii>;
int W,H;
int dx[]={0,0,1,-1}, dy[]={1,-1,0,0};
bool valid(int x,int y){return (0<=x&&x<W)&&(0<=y&&y<H);}
signed main(){
    int a,b;
    while(cin >> a >>b, a+b){
        vector<int>v;
        string s = to_string(a);
        v.push_back(a);
        rep(i,20){
            while(s.size()<b){
                s  = "0"+s;
            }
            string temp = s;
            sort(all(temp),greater<char>());
            int num = stoi(temp);
            sort(all(temp));
            int dif = stoi(temp);
            v.push_back(num - dif);
            s = to_string(num-dif);
            //cout << s << endl;
        }
        vector<pii>f;
        rep(i,v.size())rep(j,v.size()){
            if(i == j)continue;
            if(v[j] == v[i] && i > j){
                f.push_back(pii(i,j));
            }
        }
        sort(all(f));
    cout << f.front().second << " " << v[f.front().first] << " " << f.front().first-f.front().second<< endl;
    }
}




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

int main(){
  string s;
  int n;
  cin >> n >> s;
  int ans = 0;
  for(int i = 0; i < s.size()-2; i++){
    if(s[i] == 'A' && s[i+1] == 'B' && s[i+2] == 'C'){
      ans++;
    }
  }
  cout << ans << endl;
}

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


/// File input & output /////
#define fRead(x)        freopen("x.txt","r",stdin)
#define fWrite(x)       freopen ("x.txt","w",stdout)

#define mt              make_tuple
#define ld              long double
#define ll              long long
#define ull             unsigned long long
#define ff              first
#define ss              second
#define pb              push_back
#define INF             2e16
#define PI              acos(-1.0)
#define mp              make_pair
#define pii             pair<int,int>
#define pll             pair<LL,LL>


#define min3(a,b,c)     min(a,min(b,c))
#define max3(a,b,c)     max(a,max(b,c))
#define min4(a,b,c,d)   min(a,min(b,min(c,d)))
#define max4(a,b,c,d)   max(a,max(b,max(c,d)))
#define SQR(a)          ((a)*(a))
#define FOR(i,a,b)      for(int i=a;i<=b;i++)
#define ROF(i,a,b)      for(int i=a;i>=b;i--)
#define REP(i,b)        for(int i=0;i<b;i++)
#define MEM(a,x)        memset(a,x,sizeof(a))
#define ABS(x)          ((x)<0?-(x):(x))

#define SORT(v)         sort(v.begin(),v.end())
#define REV(v)          reverse(v.begin(),v.end())


#define FASTIO        ios_base::sync_with_stdio(0);cin.tie(nullptr);




///..................Sort by second element in a pair in decending order............. ///
bool SortbySecDesc(const pair<long long,long long > &a, const pair<long long,long long > &b)
{
    return a.second>b.second;
}

///.........................first element of pair in descending order..........................//////
bool sortinrev(const pair<int,int> &a,
               const pair<int,int> &b)
{
       return (a.first > b.first);
}



///.............................................................TEMPLATE................................................./////


//long long  Prime[3000000],nPrime;
//long long  mark[10000002];
//
//void seive(long long int n)
//{
//	long long int i,j,limit=sqrt(n*1.0)+2;
//	mark[1]=1;
//	for(i=4; i<=n ;i+=2)
//	mark[i]=1;
//	Prime[nPrime++]=2;
//	for(i=3; i<=n; i+=2)
//	{
//		if(!mark[i])
//		{
//			Prime[nPrime++]=i;
//			if(i<=limit)
//			{
//				for(j=i*i; j<=n ;j+=i*2)
//				{
//					mark[j]=1;
//				}
//			}
//		}
//	}
//}

int main()
{
    FASTIO;

    ll a ;

    cin >> a;

    cout << (a) + (a*a) + (a*a*a) << endl;






    return 0;
}


Measured memory_bytes: 3652
#include<stdio.h>

int main(){
    int N, M, T_ex=0, P[100], X[100], T[100], T_sum=0;
    scanf("%d", &N); 
    for(int i=0; i<N; i++){
        scanf("%d", &T[i]);
         T_sum = T[i] + T_sum;
    }
    scanf("%d", &M);
    for(int i=0; i<M; i++){
        scanf("%d%d", &P[i], &X[i]);  
        
    }
    
     for(int i=0; i<M; i++){
          T_ex = T_sum - T[P[i]-1] + X[i];
        printf("%d\n", T_ex);
        T_ex = 0;
     }
    return 0;
}


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

int main(){
	bool t = false;
	string s;
	cin >> s;
	
	for(int i=0; i<s.size(); i++){
	
		if (i % 2 == 1) {
			if(s.at(i) == 'L' || s.at(i) == 'U' || s.at(i) == 'D') {
				t = true;
				}
				else {
					t = false;
					break;
					}
		}else{
			if(s.at(i) == 'R' || s.at(i) == 'U' || s.at(i) == 'D') {
				t = true;
				}
				else {
					t = false;
					break;
					}
			}
			
		}
			
	if(t == true)	cout << "Yes" <<endl;
			else 	cout << "No" << endl;
			
				
	return 0;
	}
	

Measured memory_bytes: 256
N, M = map(int, input().split())
X = list(map(int, input().split()))
Y = list(map(int, input().split()))

MOD = 10 ** 9 + 7

tmpX = 0
for i in range(N):
    tmpX += (2 * (i + 1) - N - 1) * X[i] % MOD
    tmpX %= MOD

tmpY = 0
for i in range(M):
    tmpY += (2 * (i + 1) - M - 1) * Y[i] % MOD
    tmpY %= MOD

print (tmpX * tmpY % MOD)

Measured memory_bytes: 83044
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll h,w,i,j;
    cin>>h>>w;
    string s[h];
    for(i=0;i<h;i++)
    cin>>s[i];
    ll dp[h][w];
    memset(dp,0,sizeof(dp));
    dp[0][0]=1;
    for(i=0;i<h;i++)
    {
        for(j=0;j<w;j++)
        {
            if(i-1>=0 && s[i-1][j]=='.')
            {
                dp[i][j]+=dp[i-1][j];
                dp[i][j]%=1000000007;
            }
            if(j-1>=0 && s[i][j-1]=='.')
            {
                dp[i][j]+=dp[i][j-1];
                dp[i][j]%=1000000007;
            }
        }
    }
    cout<<dp[h-1][w-1]%1000000007<<endl;
    return 0;
}

Measured memory_bytes: 9088
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,x) for(int i=((int)(x)-1);i>=0;i--)
using namespace std;
using ll = long long;
using Int = long long;

const int MOD = 1000000007;
const ll INF = numeric_limits<ll>::max();
const int inf = 1e8;

//少数点表示
//cout <<std::fixed << std::setprecision(14)

int main(){
    cin.tie( 0 ); ios::sync_with_stdio( false );
    int r;
    cin >> r;
    cout << pow(r,2);


}

Measured memory_bytes: 256
def solve():
  ans = 0
  N = int(input())
  C = list(map(int, input().split()))
  C.sort()
  mod = 10**9+7
  for i in range(N):
    ans += C[i]*(N+1-i)
  ans = ans*pow(2,2*N-2,mod)%mod
  return ans
print(solve())

Measured memory_bytes: 31660
#include <stdio.h>

int nm=0;
void binarysearch(int *, int, int);

int main(){
  int snm, tnm, i;
  int S[100000], T[50000];
  
  scanf("%d", &snm);
  for(i=0; i<snm; i++){
    scanf("%d", &S[i]);
  }
  scanf("%d", &tnm);
  for(i=0; i<tnm; i++){
    scanf("%d", &T[i]);
  }
  
  for(i=0; i<tnm; i++){
  binarysearch(S, T[i], snm);
  }
  printf("%d\n", nm);
  
  return 0;
}
void binarysearch(int *S, int T, int snm){
  int left=0, right=snm, mid;
  while(left < right){
    mid = (left + right) / 2;
    if(S[mid] == T){
      nm++;
      break;
    }
    else if(T < S[mid]) right = mid;
    else left = mid + 1;
  }
}


Measured memory_bytes: 2352
#include<bits/stdc++.h>
using namespace std;
int main() {
    int n,w;
    cin>>n>>w;
    vector<vector<char> >board(n, vector<char>(w));
    for(int i = 0;i < n;i++){
       for(int j = 0;j < w;j++){
          cin>>board[i][j];
       }
    }
    vector<vector<char> > rows;
    for(const auto &row: board) {
       if(find(row.begin(),row.end(),'#' ) != row.end()) {
       	 rows.push_back(row);
       }
    }
    vector<int> colls;
    for(int col = 0;col < w;col++){
       bool shouldAdd = false;
       for(int i = 0,n = rows.size();i < n;i++) {
          if(rows[i][col] == '#') {
	    shouldAdd = true;
	    break;
	  }
       }
       if(shouldAdd) colls.push_back(col);
    }
    vector<string> ans;
    for(const auto &row: rows){
       string ansrow;
       for(const int &col: colls){
          ansrow.push_back(row[col]);
       }
       ans.push_back(ansrow);
    }
    for(const auto ansRow: ans) cout<<ansRow<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

#define N 100000
typedef struct {
  char mark;
  int num;
  int s;
}Card;

void quickSort(Card *A,int p,int r){
  int q;
  
  if(p<r){
    q = partition(A,p,r);
    quickSort(A,p,q-1);
    quickSort(A,q+1,r);
  }
}

int partition(Card *A,int p,int r){

  int i,j,x;
  Card temp;
  
  x=A[r].num;
  i=p-1;

  for(j=p; j<r; j++){
    if (A[j].num <= x){
    i=i+1;
    temp = A[i];
    A[i]=A[j];
    A[j]=temp;
    }
  }
  temp=A[i+1];
  A[i+1]=A[r];
  A[r]=temp;

  return i+1;
}

int main(){

  int i,j,n,p=0,r,flag=0;
  char c;
  Card A[N];

  scanf("%d%c",&n,&c);

  for(i=0; i<n; i++){
    scanf("%c%d%c",&A[i].mark,&A[i].num,&c);
    A[i].s=i;
  }

  r=n-1;
  
  quickSort(A,p,r);

  for(i=0;i<r-1;i++){
    if(A[i].num == A[i + 1].num && A[i].s > A[i + 1].s){
      printf("Not stable\n");
      flag = 1;
      break;
    }
  }

  if(flag==0) printf("Stable\n");

  
  for(i=0; i<n; i++){
    printf("%c %d\n",A[i].mark,A[i].num);
  }
  
  return 0;
}

Measured memory_bytes: 1780
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;
using namespace std;
int main()
{
  int A, B, C, X;
  cin >> A >> B >> C >> X;
  int count = 0;
  rep(i, A + 1)
  {
    rep(j, B + 1)
    {
      rep(k, C + 1)
      {
        if (500 * i + 100 * j + 50 * k == X)
        {
          count++;
        }
      }
    }
  }
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
using namespace std ;
inline double Abs( double A ) {
	return A > 0 ? A : -A ;
}
int main() {
	
	int N ;
	scanf( "%d" , &N ) ;
	double T , A , H ;
	scanf( "%lf%lf" , &T , &A ) ;
	int Ans ;
	double Abss = 100000000.000000 ;
	for(register int i = 0 ; ++i <= N ; ) {
		scanf( "%lf" , &H ) ;
		register double Cha = Abs( T - H * 0.006 - A ) ;
		if( Cha < Abss ) {
			Abss = Cha ;
			Ans = i ;
		}
	}
	return not printf( "%d\n" , Ans ) ;
	
}

Measured memory_bytes: 128
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc=new Scanner(System.in);
        String S=sc.next();
        int len=S.length();
        
        if(len%2==1){
            System.out.println("No");
            return;
        }
        
        for(int i=0;i<len;i++){
            if(i%2==0){
                if(S.charAt(i)=='h'){
                    
                }else{
                    System.out.println("No");
                    return;
                }
            }else{
                if(S.charAt(i)=='i'){
                    
                }else{
                    System.out.println("No");
                    return;
                }
            }
        }
        
        System.out.println("Yes");
    }
}


Measured memory_bytes: 23124
#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;

const int MAXR = 110000;

vector<bool> get_prime_numbers(int n){
    vector<bool> table(n+1, true);
    table[0] = false;
    table[1] = false;
    for (int i=0; i<=(int)sqrt(n); i++){
        if (table[i]){
            for (int j=2*i; j<=n; j+=i){
                table[j] = false;
            }
        }
    }
    return table;
}

int main() {
    vector<bool> table = get_prime_numbers(MAXR);
    vector<int> like2017(MAXR, 0);

    for(int i=3; i<MAXR; i+=2){
        if(table[i] && table[(i+1)/2]){
            like2017[i]++;
        }
    }
    FOR(i,1,MAXR){
        like2017[i] += like2017[i-1];
    }

    int Q; cin >> Q;

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

    return 0;
}

Measured memory_bytes: 3704
import java.util.Scanner;
 
public class Main {
 
	public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);

        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        
        String res = "No";

        if((a == b && a != c)||(b == c && b != a)||(c == a && c != b)){res = "Yes";}

        System.out.println(res);

        sc.close();
    }
}

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

using namespace std;

int X;
int A,B;

int main() {
  
cin>>X>>A>>B;

int M=X-A;

while(1){
  M-=B;
  if(M==0){
    cout<<0<<endl; return 0;
  }
  if(M<0){
    cout<<M+B<<endl; return 0;
  }
}


}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
	int n;
	int data[4][13]={0};
	int i,k;
	char mark;
	scanf("%d", &n);
	for(i=0; i<n; i++){
		scanf("%s %d", &mark, &k);
		if(mark=='S'){
			data[0][k-1]=1;
		}
		else if(mark=='H'){
			data[1][k-1]=1;
		}
		else if(mark=='C'){
			data[2][k-1]=1;
		}
		else{
			data[3][k-1]=1;
		}
	}
	for(i=0; i<4; i++){
		for(k=0; k<13; k++){
			if(data[i][k]==0){
				if(i==0){
					printf("S %d\n", k+1);
				}
				else if(i==1){
					printf("H %d\n", k+1);
				}
				else if(i==2){
					printf("C %d\n", k+1);
				}
				else{
					printf("D %d\n", k+1);
				}
			}
		}
	}
	return 0;
}

Measured memory_bytes: 596
N = int(input())
edge = [[] for _ in range(N)]
for _ in range(N-1):
    u,v,w = map(int, input().split())
    edge[u-1].append((v-1, w))
    edge[v-1].append((u-1, w))

dist = [-1] * N
dist[0] = 0
que = [0]
while que:
    u = que.pop()
    d = dist[u]

    for v,w in edge[u]:
        if dist[v] > 0:
            continue
        dist[v] = d + w
        que.append(v)

for d in dist:
    if d % 2 == 0:
        print(0)
    else:
        print(1)

Measured memory_bytes: 42800
#include <iostream>
#include <map>
#include <unordered_map>
#include <set>
#include <utility>
#include <stack>
#include <cstdio>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <queue>
#include <algorithm>
#include <iterator>
#include <sstream>
#define popcount(x) __builtin_popcount(x)
#define oddparity(x) __builtin_parity(x)
#define clz(x) __builtin_clz(x)
#define ctz(x) __builtin_ctz(x)
#define sf scanf
#define pf printf
#define ll long long int
using namespace std;

int i;
string a, b;

int main()
{
    cin >> a >> b;
    if (a.size() > b.size()) {
        pf("GREATER\n");
    }
    else if (a.size() < b.size()) {
        pf("LESS\n");
    }
    else {
        for (i = 0; i < a.size(); i++) {
            if (a[i] > b[i]) {
                pf("GREATER\n");
                return 0;
            }
            else if (a[i] < b[i]) {
                pf("LESS\n");
                return 0;
            }
        }
        pf("EQUAL\n");
    }
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;

public class AtCoderC
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());

        int max = 0;
        Dictionary<string, int> dic = new Dictionary<string, int>();
        for (int i = 0; i < n; i++)
        {
            string s = Console.ReadLine();
            if (dic.ContainsKey(s))
            {
                int current = dic[s];
                dic[s] = current + 1;
                if (max < current + 1)
                {
                    max = current + 1;
                }

            }
            else
            {
                if (max < 1)
                {
                    max = 1;
                }
                dic.Add(s, 1);
            }
        }

        List<string> answers = new List<string>();
        foreach (var item in dic)
        {
            if (item.Value == max)
            {
                answers.Add(item.Key);
            }
        }

        var array = answers.ToArray();
        Array.Sort(array, new StringComparator());

        foreach (var answer in array)
        {
            Console.WriteLine(answer);
        }
    }
}

// 文字列比較のComparator
class StringComparator : IComparer<string>
{
    int IComparer<string>.Compare(string a, string b)
    {
        for (int i = 0; i < Math.Min(a.Length, b.Length); i++)
        {
            if (a[i] < b[i])
            {
                return -1;
            }
            else if (a[i] > b[i])
            {
                return 1;
            }
        }
        if (a.Length < b.Length)
        {
            return -1;
        }
        else if (a.Length > b.Length)
        {
            return 1;
        }
        else
        {
            return 0;
        }
    }
}

Measured memory_bytes: 40284
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
#include <cctype>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_map>
#include <set>
#include <deque>
#include <map>
#include <bitset>
#include <functional>
#include <cmath>

#define INF 1000000000
using namespace std;

int main() {
    int n;
    cin >> n;
    map<int, int> m;
    vector<int> a(n);
    int flag[1000010] = {0};
    vector<int> ans;
    for(int i = 0; i < n; i++){
        cin >> a[i];
        m[a[i]]++;
    }

    sort(a.begin(), a.end());
    int sum = 0;
    for(int i = 0; i < n; i++){
        if(flag[a[i]] == 0 && m[a[i]] == 1) sum++;
        if(flag[a[i]] == 0){
            for(int j = 1; j*a[i] < 1000010; j++){
                flag[j*a[i]] = 1;
            }
        }
    }

    cout << sum << endl;
}


Measured memory_bytes: 17084
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<map>
#include<iomanip>
#include<math.h>
#define rip(i,n) for(int i=0;i<n;i++)
#define ll long long
#define lb long double
#define vec vector<int>
#define set setprecision
#define pi 3.141592653589793238
using namespace std;
int main() {
	lb a, b, c;
	cin >> a >> b >> c;
	c = (c / 180) * pi;
	cout <<fixed << set(10) <<
		a * b * sin(c) / 2 << endl;
	cout <<fixed << set(10) <<
		(a + b) + (sqrt(pow(a - (b * cos(c)), 2) + pow(b * sin(c), 2)))<< endl;
	cout <<fixed << set(10) <<
		b * sin(c) << endl;
}


Measured memory_bytes: 3524