akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using static MyIO;


public class B
{
	public static void Main()
	{
		int N = GetInt();
		var D = new Dictionary<int, int>();
		for(int i = 0; i < N; i++)
		{
			int current = 0;
			int d = GetInt();
			D.TryGetValue(d, out current);
			D[d] = current + 1;
		}

		int M = GetInt();
		var T = new Dictionary<int, int>();
		for(int i = 0; i < M; i++)
		{
			int current = 0;
			int t = GetInt();
			T.TryGetValue(t, out current);
			T[t] = current + 1;
		}

		foreach(int t in T.Keys)
		{
			int numD = 0;
			D.TryGetValue(t, out numD);
			if(numD < T[t])
			{
				Console.WriteLine("NO");
				return;
			}
		}
		Console.WriteLine("YES");
	}
}


public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt(){ return int.Parse(getArg()); }
	public static long GetLong(){ return long.Parse(getArg()); }
	public static double GetDouble(){ return double.Parse(getArg()); }
	public static string GetString(){ return getArg(); }
}


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

int main() {
  int a;
  cin >>a;
  if (a==1||a==2||a==3||a==5||a==7||a==11||a==13||a==15||a==17||a==19||a==23||a==29||a==31){
    cout << "1";
    }
  if(a==4||a==6||a==9||a==10||a==14||a==21||a==22||a==25||a==26){
    cout << "2";
    }
  if(a==28||a==30){
    cout<<"4";
    }
  if (a==8||a==12||a==18||a==20||a==27){
    cout << "5";
    }
  if (a==16){
    cout << "14";
    }
  if (a==24){
    cout <<"15";
    }
  if (a==32){
    cout << "51";
    }
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<cstdlib>  
#include<cmath>   
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include<map>
#include<algorithm>
#include<functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<list>
#include<deque>
#include<climits>
#include<typeinfo>
#include<utility>
#define LEN 100005
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,n) for(ll i=0;i<n;i++)
#define For(i,m,n) for(int i=m;i<n;i++)
#define FOR(i,m,n) for(ll i=m;i<n;i++)
using namespace std;
using ll = long long;
double pi() { return 3.14; }
int sum(int a, int b) { return a + b; }
int mul(int a, int b) { return a * b; }
ll LGCD(ll x, ll y) { if (x % y == 0) return y;else return LGCD(y, x % y); }
ll LLCM(ll x, ll y) { return x * y / LGCD(x, y); }

int GCD(int x, int y) { if (x % y == 0) return y;else return GCD(y, x % y); }
int LCM(int x, int y) { return x * y / GCD(x, y); }
ll dpc[10000][10000];

//void nCr(ll n, ll r) {
//	ll ans = 1;
//	for (int i = n; i > n - r; --i) {
//		ans = ans * i;
//	}
//	for (int i = 1; i < r + 1; ++i) {
//		ans = ans / i;
//	}
//	printf("%d",ans);
//}

ll combination(ll n, ll r) {
	if (n == r) { return dpc[n][n] = 1; }
	else if (r == 0) { return dpc[n][0] = 1; }
	else if (r == 1) { return dpc[n][1] = n; }
	else if (dpc[n][r]) { return dpc[n][r]; }
	else { return dpc[n][r] = combination(n - 1, r - 1) + combination(n - 1, r); }
}

//cout << fixed << setprecision(10);







ll checkman(vector<int> s, int i) {
	
	int mozila = 1;
	int n = s.size();
	int tmp = 0;
	ll ans=0;
	for (int k = i;k <n;k++) {
		tmp = tmp + s[k];
		if (tmp % 2019 == 0)ans++;

		


		tmp = (tmp * 10) % 2019;

	}
	return ans;


}


int main() {
	ll x;
	cin >> x;
	ll i = 0;
	ll a = 100;
	while (1) {
		i++;
		a = a * 1.01;
		if (a >= x)break;

	}
	cout << i << endl;
	return 0;
}



Measured memory_bytes: 3636
N = int(input())
A_list = list(map(int, input().split()))
B_list = list(map(int, input().split()))

taos = 0
keep = 0

for i, (a, b) in enumerate(zip(A_list, B_list)):
  if a >= (b + keep) :
    taos += (b + keep)
    keep = 0
  else:
    taos += a
    if keep > a:
      keep = b
    else:
      keep = (b + keep) - a 
  #print(i, taos, keep)

if A_list[-1] >= keep:
  taos += keep
else:
  taos += A_list[-1]
print(taos)

Measured memory_bytes: 19244
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
#include<complex>
using namespace std;

long long int solve(long long int n){
	if(n==2){return 3;}
	else if(n==4||n==6||n==9||n==11){return 2;}
	else{return 1;}
}

int main() {
	long long int n=0,m,a,b,c,d,e;
	long double z,w;
	string str,str2,str3;
	char ch;
	long long int x[130]={};
	cout << fixed << setprecision(10);
	cin>>a>>b>>c;
	if(a<=c&&c<=b){cout<<"Yes";}
	else{cout<<"No";}






	cout<<endl;
} 


Measured memory_bytes: 256
# coding: utf-8
N, A, B = map(int, input().split())
# print("N:", N, "A:", A, "B:", B) 
if A == 0:
    print(0)
elif B == 0 or N <= A:
    print(N)
else:
    num = int(N / (A + B)) * A + min(A, N % (A + B))
    print(num)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define ff first
#define ss second
#define ll long long
#define ld long double
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define pii pair<int, int>
#define vi vector<int>
#define vl vector<ll>
#define vii vector<pii>
#define sws ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl '\n'
#define teto(a, b) ((a+b-1)/(b))
using namespace std;

const int MAX = 200000;
const int MOD = 1000000007;
const int INF = 1e8;
const ll LLINF = 0x3f3f3f3f3f3f3f3f;
const ld EPS = 1e-7;

// Extra
#define forn(i, n) for(int i = 0; i < (int)n; i++)
#define forne(i, a, b) for(int i = a; i <= b; i++)
#define all(x) x.begin(), x.end()
//

int main() {
    int a, b, c;
    cin >> a >> b >> c;

    cout << min(c, b/a) << endl;


    return 0;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG

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

//loops
#define REP(i,n) for(int i=0;i<(ll)(n);i++)
#define REPD(i,n) for(int i=(ll)(n)-1;i>=0;i--)
#define OneToN(i,n) for(int i=1;i<(ll)(n+1);i++)
#define ZeroToN(i,n) for(int i=0;i<(ll)(n+1);i++)
#define AToB(i,a,b) for(int i=a;i<(ll)(b+1);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--)

//bitsearch
#define BITSEARCH(bit, n) for (int bit = 0; bit < (1<<n); ++bit)
#define isOne(bit, i) bit & (1<<i)


//arrays
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define add push_back


#define remove_unique(v) v.erase(unique(ALL(v)), v.end())

//pair
#define fir first
#define sec second

//types
#define ll long long
#define vec vector
#define cord2d pair<int,int>
//UNCOMMENT WHEN NEEDED
//#define int ll

//input
template <class T> T get(){ T s; cin >> s; return(s);}
#define gi get<int>()
#define gs get<string>()

template <class T> vector<T> getv(int n) { vec<T> v(n); REP(i, n) cin >> v[i]; return v; }
#define gim(n) getv<int>(n)
#define gsm(n) getv<string>(n)

//output
void print(int a){ cout << a << endl; }
void print(long long a){ cout << a << endl; }
void print(string a){ cout << a << endl; }
void print(char a){ cout << a << endl; }
void print(double a){ cout << a << endl; }
void print(double a, int dig){ cout << std::setprecision(dig) << a << endl; }

template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

template <class T = int>
void print(vec<T> v){ cout << v << endl; }

template <class T = int>
void print2dVec(vec<vec<T>> v2d){for(vec<T> v: v2d) {print(v);}}

void YesNo1(bool i = true){ return print(i?"Yes":"No"); }
void YESNO2(bool i = true){ return print(i?"YES":"NO"); }

//debug output
#define var_name(var) #var
template <class T> void debug(T &var, int nest = 0, string before = "") { cout << string("          ", nest) << before; print(var); }

//name replacement
#define y0 y0__
#define y1 y1__
#define j0 j0__
#define j1 j1__

//bool lambdas
#define lamb(exp) [](auto i){return exp;}
#define isEven [](int i){return i % 2 == 0;}
#define isOdd [](int i){return i % 2 != 0;}

//constants
const ll INF = 1e18;
const int MOD = 10000007;

//maths
int factorial(int k){ int sum = 1; for (int i = 1; i <= k; ++i) { sum *= i; } return sum; }
int gcd(int a, int b) {
    if (b == 0)
        return a;
    return gcd(b, a % b);
}

////////////////////

void Main() {
    //code here
    int n = gi, k = gi;
    vec<int> nums = gim(n);
    vec<int> dp {0};
    AToB(i, 1, n-1) {
        int minV;
        OneToN(dif,min(i, k)) {
            if (dif == 1) minV = abs(nums[i]-nums[i-dif]) + dp[i-dif];
            minV = min(minV, abs(nums[i]-nums[i-dif]) + dp[i-dif]);
        }
        dp.add(minV);
    }
    print(dp[n-1]);
}

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    Main();
}


Measured memory_bytes: 1276
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>  

#pragma warning(disable:4996)  
#pragma comment(linker, "/STACK:336777216")  
using namespace std;

#define mp make_pair  
#define Fi first  
#define Se second  
#define pb(x) push_back(x)  
#define szz(x) ((int)(x).size())  
#define rep(i, n) for(int i=0;i<n;i++)  
#define all(x) (x).begin(), (x).end()  
#define ldb ldouble  

typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

int IT_MAX = 1 << 20;
const ll MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10;

int main() {
	int A, P;
	scanf("%d %d", &A, &P);
	return !printf("%d\n", (3 * A + P) / 2);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define FOR(i,a,b) for(int i=(a); i<=(b); i++)
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define chmin(a,b) if((a)>(b)) (a)=(b);
#define chmax(a,b) if((a)<(b)) (a)=(b);
#define vi vector<int>
#define pii pair<int,int>
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define pb push_back
#define pf push_front
int gcd(int a,int b){/*a>=0,b>=0,￢(a=b=0)*/
  while(min(a,b)>0){if(a<b)swap(a,b);a%=b;}return max(a,b);
}
int dx[]={1,0,-1,0,1,-1,-1,1};
int dy[]={0,1,0,-1,1,1,-1,-1};
const int MOD = 1e9+7;
const long long INF = 1e18+10;

/*--------------------------------------------------------------------*/

signed main(){	
	string s;
	cin>>s;
	int a=0,b=0,c=0;
	rep(i,s.size()){
		if(s[i]=='a')a++;
		else if(s[i]=='b')b++;
		else c++;
	}
	int n=s.size()%3;

	if(n==0){
		if(a==b&&b==c){
			cout<<"YES"<<endl;
		}else{
			cout<<"NO"<<endl;
		}
	}else{
		vi x={a,b,c};
		sort(all(x));
		if(x[0]+1==x[2]){
			cout<<"YES"<<endl;
		}else{
			cout<<"NO"<<endl;
		}
	}
	return 0;
}


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

int main(void)
{
    int n,a,b,c;
    int count = 0;
    cin >> n;
    vector<int>lengths(n);
    for(int i = 0; i < n; i++){
        cin >> lengths[i];
    }

    for(int i = 0; i < n; i++){
        a = lengths[i];
        for(int j = i + 1; j < n; j++){
                b = lengths[j];
            for(int k = j + 1; k < n; k++){
                c = lengths[k];
                if(a!=b){
                    if(b!=c){
                        if(c!=a){
                             if (a < (b+c) && b < (a + c) && c < (a + b)){
                            
                            count++;
                            }
                        }
                    }
                }    
            }
        }
    }
    cout << count << endl;
}


Measured memory_bytes: 3632
import sys
from pprint import pprint

N, M = map(int, sys.stdin.readline().strip().split())
A = list(map(int, sys.stdin.readline().strip().split()))

v_sum = sum(A)
ans = 0
for a_i in A:
    if a_i >= (v_sum / (4 * M)):
        ans += 1

print("Yes" if ans >= M else "No")

Measured memory_bytes: 3572
import java.util.*;

public class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int A[] = {sc.nextInt(),sc.nextInt(),sc.nextInt()};
		String moji = (sum(A) >= 22) ? "bust" : "win";
		System.out.println(moji);
	}

	public static int sum(int[] num){
		int sum = 0;
		for(int i = 0; i < num.length;i++){
			sum += num[i];
		}
		return sum;
	}
}


Measured memory_bytes: 23508
import math

def abc168_c():
    A, B, H, M = map(int, input().split())
    # 時針の位相
    h_angle = 30 * H + 0.5 * M
    # 分針の位相
    m_angle = 6 * M
    # x方向
    x_dist = A * math.cos(math.radians(h_angle)) - B * math.cos(math.radians(m_angle))
    # y方向
    y_dist = A * math.sin(math.radians(h_angle)) - B * math.sin(math.radians(m_angle))
    # 距離
    dist = math.sqrt(x_dist ** 2 + y_dist ** 2)
    print('{:.12f}'.format(dist))

abc168_c()

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

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

mod = 10**9 + 7

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

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

N = I()
A = III()
A.sort(reverse=True)
plus = 0
for a in A:
    if a>0:
        plus += 1
if plus==N:
    plus -= 1

ans = []
val = A[plus]

if plus:
    for i in range(1,plus)[::-1]:
        ans.append((val,A[i]))
        val -= A[i]
    ans.append((A[0],val))
    val = A[0]-val

for i in range(plus+1,N):
    ans.append((val,A[i]))
    val -= A[i]

print(val)
for a in ans:
    print(*a, sep=' ')

Measured memory_bytes: 62512
import bisect,copy,heapq,itertools,string
from collections import *
from math import *
import sys
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

n, p = MAP()
a = list(map(lambda x:int(x)%2, input().split()))
e = a.count(0) if 0 in a else 0
o = a.count(1) if 1 in a else 0

ans = 0
if(p == 0):
    for i in range(0,e+1):
        for j in range(0,o+1,2):
            comb_e = factorial(e)//factorial(i)//factorial(e-i)
            comb_o = factorial(o)//factorial(j)//factorial(o-j)
            ans += comb_e * comb_o
else:
    for i in range(0,e+1):
        for j in range(1,o+1,2):
            comb_e = factorial(e)//factorial(i)//factorial(e-i)
            comb_o = factorial(o)//factorial(j)//factorial(o-j)
            ans += comb_e * comb_o
print(ans)

Measured memory_bytes: 10112
#include <bits/stdc++.h>
using namespace std;
template<class T, class U> bool chmax(T& a, const U& b){ if(a < b){ a = b; return 1; } return 0; }

int query(int a, int b){
    cout << "? " << a + 1 << ' ' << b + 1 << endl;
    int ans;
    cin >> ans;
    return ans;
}
void answer(const vector<int>& a){
    cout << '!';
    for(int i : a) cout << ' ' << i + 1;
    cout << endl;
}
int main() {
    int n;
    cin >> n;
    int max = 0, idx;
    for(int i = 0; i < n; i++) if(chmax(max, query(0, i))) idx = i;
    vector<int> ans(n);
    for(int i = 0; i < n; i++) ans[query(idx, i)] = i;
    answer(ans);
}


Measured memory_bytes: 3668
#include<bits/stdc++.h>
#include <iomanip>
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;

using Edge = pair<int, int>;
using Graph = vector<vector<Edge>>;

int N;
Graph G;
vector<int> colors;

void dfs(int v, int cur = 0){
    colors[v] = cur;

    for(auto e : G[v]){
        
        if(colors[e.first] != -1) continue;
        
        if(e.second % 2 == 1){
            dfs(e.first, 1-cur);
        }else{
            dfs(e.first, cur);
        }
    }
    
}

int main(void){
    cin >> N;
    G.resize(N);
    
    for(int i = 1; i < N; i++){
        int u,v,w; cin >> u >> v >> w;
        u--;
        v--;
        G[u].push_back(Edge(v, w));
        G[v].push_back(Edge(u, w));
    }
    
    colors.assign(N, -1);
    
    dfs(0);
    
    for(auto cur : colors){
        cout << cur << "\n";
    }
    
}


Measured memory_bytes: 7424
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

#define mp make_pair
#define pb push_back
#define ll long long

#define maxN 55

int n, p, i, x;
ll ans;
bool any;

int main()
{
 //   freopen("test.in","r",stdin);

    cin >> n >> p; ans = 1LL << n - 1;
    for (i = 1; i <= n; i++) {
        cin >> x;
        if (x & 1) any = true;
    }

    if (any == false) {
        if (p == 0)
            cout << ans * 2;
        else
            cout << 0;

        return 0;
    }

    cout << ans;


    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define pb push_back
int dy[]={0, 0, 1, -1, 1, 1, -1, -1};
int dx[]={1, -1, 0, 0, 1, -1, -1, 1};

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define mp make_pair
#define fi first
#define sc second
ll n,a[100010];
int main(){
    cin >> n;
    REP(i,n)
        cin >> a[i];
    sort(a,a + n);
    int maxi = 0;

    int now = a[0];int i = 0,next;
    while(i < n){
        int j = i;
        while(j < n && now == a[j])j++;
        next = j;
        while(j < n && now + 3 > a[j])j++;
        //cout << i << " "<< j << endl;
        maxi = max(maxi,j - i);
        i = next + 0;now = a[next];
    }
    cout << maxi << endl;
    return 0;
}


Measured memory_bytes: 1024
X, Y, Z, K = map(int, input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
A.sort(reverse = True)
B.sort(reverse = True)
C.sort(reverse = True)
t =[]
for i in range(X):
    for j in range(Y):
        for k in range(Z):
            if (i+1)*(j+1)*(k) <= K:
                t.append(A[i]+B[j]+C[k])
            else:break
t.sort(reverse=True)
for i in range(K):
    print(t[i])

Measured memory_bytes: 60092
#include<iostream>
#include<math.h>
#include<algorithm>
#include<stdint.h>
#include<vector>
#include<deque>
#include<stack>
#include<string>
#include<cstring>
#include<time.h>
#include<iomanip>
#include<list>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<random>
#include<bitset>
#include <queue>
#include <map>


using namespace std;
using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using ldouble = long double;

#define repi(i,a,b) for(ll i = (a); i < (b); i++)
#define rep(i, n) for(ll i = 0; i < (n); ++i)


int ctoi(char c) {
	switch (c)
	{
	case '0': return 0;
	case '1': return 1;
	case '2': return 2;
	case '3': return 3;
	case '4': return 4;
	case '5': return 5;
	case '6': return 6;
	case '7': return 7;
	case '8': return 8;
	case '9': return 9;
	default: return -1;
	}
}
int main() {
    int k;
    cin >> k;
	vector<string> v;
	repi(i, 1, 10) v.push_back(to_string(i));
    for(int i = 0; i < v.size(); ++i) {
		string s = v[i];
        for (int a = -1; a <= 1; ++a) {
			int matubi = ctoi(s.back());
			if (matubi + a < 0 || matubi + a > 9) continue;
			v.push_back(s + to_string(matubi + a));
			if (v.size() >= k) goto END;
        }
    }
END:
	cout << v[k-1] << endl;
    return 0;
}



Measured memory_bytes: 5748
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
int acs(const void *a, const void *b) { 
  return *(int*)a - *(int*)b;
} /* 1,2,3,4.. */
int des(const void *a, const void *b) {
  return *(int*)b - *(int*)a;
} /* 8,7,6,5.. */
int cmp_char(const void *a, const void *b) { 
  return *(char*)a - *(char*)b;
} /* a,b,c,d.. */
int cmp_str(const void *a, const void *b) {
  return strcmp(*(const char **)a, *(const char **)b);
} /* aaa,aab.. */
#define min(a,b) (a < b ? a : b)
#define max(a,b) (a > b ? a : b)
#define rep(i, l, r) for (int i = l; i < r; i++)
#define MAX 100001
#define MOD 1000000007

typedef long long int lli;

int main(void) {
  int n;
  scanf("%d", &n);

  char s[11];
  long long int march[5] = {0};
  rep(i, 0, n) {
    scanf("%s", s);
    if (s[0] == 'M') march[0]++;
    if (s[0] == 'A') march[1]++;
    if (s[0] == 'R') march[2]++;
    if (s[0] == 'C') march[3]++;
    if (s[0] == 'H') march[4]++;
  }

  long long int ans = 0;
  rep(i, 0, 5) {
    rep(j ,i+1, 5) {
      rep(k, j+1, 5) {
        ans += march[i] * march[j] * march[k];
      }
    }
  }
  printf("%lld\n", ans);
  return 0;
}


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

					using namespace std;
					typedef long long ll;
					int a, b, c;
					int main()
					{
                      cin >> a >> b >> c;
                      if((a == b && b != c) || (a == c && b != c) || (b == c && a != c))
   						cout << "Yes";
                      else cout << "No";
					}

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

int main(){
    int n, k;
    cin >> n >> k;
    double a[10001];
    a[0] = 1;
    for(int i = 1; i <= 10000; i++){
        a[i] = a[i-1]*0.5;
    }
    double ans = 0;
    for(int i = 1; i <= min(k-1, n); i++){
        int score = i;
        int count = 0;
        while(score < k){
            count++;
            score *= 2;
        }
        ans += ((double)(1.0)/(double)(n))*a[count];
    }
    if(k <= n){
        ans += (double)(n-k+1)/(double)(n);
    }
    cout << setprecision(12) << ans << endl;
    return 0;
}

Measured memory_bytes: 384
#include<stdio.h>

int func(int,int,int,int,int);
int p,q,a,n;
int main(void){
  
  while(scanf("%d %d %d %d",&p,&q,&a,&n),p,q,a,n){
    printf("%d\n",func(n,1,1,0,1));
  }
  
  return 0;
}

int func(int turn,int last,int product,int c,int d){

  if(p*d==c*q)return 1;  

  if(!turn)return 0;
  
  int i,count=0;
  for(i=last;product*i<=a;i++){

    if(c/d+1/i<=p/q)
      count+=func(turn-1,i,product*i,i*c+d,i*d);

  }  
  return count;
}

Measured memory_bytes: 408
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define int long long
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr long long INFL = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



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

    int N;
    cin>>N;
    int A[N];
    rep(i,N) cin>>A[i];
    int bit[63]{};
    int ans=0;
    rep(i,N){
        int x=2;
        rep(j,63){
            if(A[i]%x!=0){
                bit[j]++;
                A[i]-=x/2;
                if(A[i]==0) break;
            }
            x*=2;
        }
    }
    int x=1;
    rep(i,63){
        int p=(bit[i]*(N-bit[i]))%MOD;
        p=(p*x)%MOD;
        ans=(ans+p)%MOD;
        x=(x*2)%MOD;
    }
    cout << ans << endl;



}


Measured memory_bytes: 2560
// Package main provides
//
// File:  a.go
// Author: ymiyamoto
//
// Created on Sun Dec  2 20:57:55 2018
//
package main

import "fmt"

var x int

func main() {
	fmt.Scan(&x)
	if x == 7 || x == 5 || x == 3 {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}


Measured memory_bytes: 512
# coding: UTF-8

def f(i,r1,r2):
  return sum(r1[0:i+1]) + sum(r2[i:])
  


def solve():
  N = int(input())
  A=[]
  R1=list(map(int,input().split(" ")))
  R2=list(map(int,input().split(" ")))
  ans = 0
  for i in range(N):
    cand=f(i,R1,R2)
    #print(cand)
    ans = max(ans,cand)
    


  return ans
 
if __name__ == '__main__':
  ans = solve()
  print(ans, flush=True)

Measured memory_bytes: 3064
S = input()

R = {'R', 'U', 'D'}
L = {'L', 'U', 'D'}


for i, s in enumerate(S):
    if i % 2 == 0:
        if s not in R:
            print('No')
            exit()
    else:
        if s not in L:
            print('No')
            exit()
print('Yes')


Measured memory_bytes: 38256
#include <iostream>
#include <string>

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

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

int main() {
    int A,B;
    cin >> A >> B; //自然数x
    if(A <= 5){
      cout << 0 << endl;
    }
    else if(13 <= A) {
      cout << B << endl;
    }
    else if(6 <= A < 13){
      cout << B / 2 << endl;
    }


}


Measured memory_bytes: 256
H,W=map(int,raw_input().split(' '))

m=['.']*((H+2)*(W+2))

for h in range(1,H+1):
    S=raw_input()
    i=0
    for w in range(1,W+1):
        m[h*(W+2)+w]=S[i]
        i+=1

r=[0]*(H*W)
i=0
for h in range(1,H+1):
    for w in range(1,W+1):
        p=h*(W+2)+w
        if m[p]=='#':
            r[i]='#'
        else:
            if m[p-(W+2)-1]=='#':
                r[i]+=1
            if m[p-(W+2)]=='#':
                r[i]+=1
            if m[p-(W+2)+1]=='#':
                r[i]+=1
            if m[p-1]=='#':
                r[i]+=1
            if m[p+1]=='#':
                r[i]+=1
            if m[p+(W+2)-1]=='#':
                r[i]+=1
            if m[p+(W+2)]=='#':
                r[i]+=1
            if m[p+(W+2)+1]=='#':
                r[i]+=1
        i+=1

r=map(str,r)
for h in range(H):
    print ''.join(r[h*W:h*W+W])

Measured memory_bytes: 2780
#include <iostream>

using namespace std;

int main(){
    int n;
    string w[110];
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> w[i];
    }
    bool ans = true;
    for(int i = 0; i < n-1; i++){
        if(w[i][w[i].length()-1] != w[i+1][0])
            ans = false;
    }
    for(int i = 0; i < n; i++){
        for(int j = 0; j < i; j++){
            if(w[i] == w[j]){
                ans = false;
            }
        }
    }
    if(ans){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 384
#include<iostream>

using namespace std;

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

    int ans[n];
    for(int i=0;i<n;i++)ans[i] = 0;
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            if(a[j]==i+1 || b[j]==i+1)ans[i]++;
        }
    }
    for(int i=0;i<n;i++)cout << ans[i] << endl;
}


Measured memory_bytes: 256
#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 n; cin >> n;
    if(n%2 != 0) cout << n/2+1 << endl;
    else cout << n/2 << endl;
}

Measured memory_bytes: 256
from collections import deque

H,W = map(int, input().split())

s_lst = [[i for i in input()]for j in range(H)]

dist = [[-1 for i in range(W)] for i in range(H)]
dist[0][0] = 1
d = deque()
d.append([0,0])

white_cnt = 0
for i in range(H):
    for j in range(W):
        if s_lst[i][j] == ".":
            white_cnt += 1

dy_dx = [[1,0],[0,1],[-1,0],[0,-1]]

while d:
    x,y = d.popleft()
    for dx, dy in dy_dx:
        nx = x + dx
        ny = y + dy

        if 0>nx or W<=nx or 0>ny or H<=ny:
            continue

        if dist[ny][nx] != -1 or s_lst[ny][nx] == "#":
            continue
        d.append([nx,ny])
        dist[ny][nx] = dist[y][x] +1

if dist[H-1][W-1] == -1:
    print(-1)
else:
    print(white_cnt-dist[H-1][W-1])

Measured memory_bytes: 74308
times = []
#for num in ins:
tmp = []
for _ in range(5):
    num = int(input())
    if num % 10 == 0:
        time = num
    else:
        time = num - num % 10 + 10
    times.append(time)
    tm = num % 10
    if tm >= 1:
        tmp.append(tm)
    #print(num)

if len(tmp) == 0:
    tmp = [0]

yobun = min(tmp)
if yobun == 0:
    yobun = 10

all_time = sum(times) - (10-yobun)
print(all_time)

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

int main(){
    int n, k;
    cin >> n >> k;
    int cnt[101] = {0};
    for(int i=0;i<k;++i){
        int d;
        cin >> d;
        for(int j=0;j<d;++j){
            int a;
            cin >> a;
            ++cnt[a];
        }
    }
    int ans = 0;
    for(int i=1;i<=n;++i) if(cnt[i] == 0) ++ans;
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 3644
#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)

int n, k;
int ary[100000];

int main() {
	while(1) {
		scanf(" %d %d", &n, &k);
		if(n == 0 && k == 0) break;
		memset(ary, 0, sizeof ary);
		rep(i,n) {
			static int t;
			scanf(" %d", &t);
			ary[i] = t;
		}

		int sum = 0;
		for(int i = 0; i < k; i++) sum += ary[i];

		int maxv = sum;
		for(int i = 1; i < n - k + 1; i++) {
			sum -= ary[i - 1];
			sum += ary[i + k - 1];
			maxv = max<int>(maxv, sum);
		}
		printf("%d\n", maxv);
	}
	return 0;
}

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

using namespace std;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define sz(x) ll(x.size())
typedef long long ll;
typedef pair<int, int> P;
//typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = 1001001001;
#define mins(x, y) x = min(x, y)
#define maxs(x, y) x = max(x, y)


int mod;

struct mint {
    ll x;

    mint(ll x = 0) : x(x % mod) {}

    mint &operator+=(const mint a) {
        (x += a.x) %= mod;
        return *this;
    }

    mint &operator-=(const mint a) {
        (x += mod - a.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;
    }
};

ll b, ten;

mint pow_(mint x, ll t) {
    if (t == 0) return 1;
    if (t % 2 == 1) {
        return pow_(x, t - 1) * x;
    } else {
        mint y = pow_(x, t / 2);
        return y * y;
    }
}

mint f(ll l) {
    if (l == 0) return 0;
    if (l % 2 == 1) {
        ll pl = l - 1;
        mint x = f(pl);
        return x * ten + 1;
    } else {
        ll pl = l / 2;
        mint x = f(pl);
        return x * pow_(ten, pl) + x;
    }
}

mint g(ll l) {
    if (l == 0) return 0;
    if (l % 2 == 1) {
        ll pl = l - 1;
        mint x = g(pl);
        return x * ten + mint(b) * pl;
    } else {
        ll pl = l / 2;
        mint x = g(pl);
        return x * pow_(ten, pl) + x + mint(b) * pl * f(pl);
    }
}


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

    ll last = a + b * (L - 1);

    mint ans = 0;
    ten = 10;

    for (int i = 1; i <= 18; i++, ten *= 10) {
        ll l = ten / 10, r = ten - 1;
        if (last < l) continue;
        if (a > r) continue;
        ll na = 0;
        ll nl = 0;

        {
            if (a >= l) na = a;
            else {
                na = ((l - a) + (b - 1)) / b * b + a;
                na = min(na, last);
            }
        }
        {
            ll nlast = 0;

            if (last <= r) nlast = last;
            else {
                nlast = (r - a) / b * b + a;
            }
            nl = (nlast - na) / b + 1;
        }

        ans *= pow_(ten, nl);
        ans += f(nl) * na;
        ans += g(nl);
    }

    cout << ans.x << endl;

}



Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        String[] lines = getStdin();
        
        String[] str1 = new String[lines.length];
        int ver;
        int par;

        for (int i = 0; i < lines.length; i++){
            String str = lines[i];
            str1 = str.split(" ");
            ver = Integer.parseInt(str1[0]);
            par = Integer.parseInt(str1[1]);
            
            

            for (int j = 0; j < ver; j++){
                for (int k = 0; k < par; k++){
                    if (k == 0 || k == par - 1 || j == 0 || j == ver - 1){
                        System.out.print("#");
                    } else {
                        System.out.print(".");
                    }
                }
                
                System.out.println();
            
                
            }
            if(ver == 0 && par == 0){
                break;
            }
            System.out.println();
            
        }
        
        
        
    }

  
  private static String[] getStdin() {
    Scanner scanner = new Scanner(System.in);
    ArrayList<String> lines = new ArrayList<>();
    while (scanner.hasNext()) {
      lines.add(scanner.nextLine());
    }
    return lines.toArray(new String[lines.size()]);
  }
  
}




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


int main()
{
	ll t, n, m, i, j, k, a, b, c;

	scanf("%lld %lld %lld", &a, &b, &c);

	if(a>b) swap(a, b);
	if(b>c) swap(b, c);
	if(a>b) swap(a, b);

	if(a+b==c) printf("Yes\n");
	else printf("No\n");




	return 0;
}

Measured memory_bytes: 3744
// C - Colorful Leaderboard
#include <bits/stdc++.h>
using namespace std;
#define rp(i,n) for(int i=0;i<(n);++i)

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

	map<int,int> C;//<rate,count>
	rp(i, N){
		int a; cin>>a;
		if(a<400) C[400]++;
		else if(a<800) C[800]++;
		else if(a<1200) C[1200]++;
		else if(a<1600) C[1600]++;
		else if(a<2000) C[2000]++;
		else if(a<2400) C[2400]++;
		else if(a<2800) C[2800]++;
		else if(a<3200) C[3200]++;
		else C[4801]++;
	}

	int maxR = C.rbegin()->first;
	int maxC = C[maxR];

	int n = C.size();
	if(maxR < 4801) printf("%d %d\n", n, n);
	else{
		if(n > 1) printf("%d %d\n", n-1, n-1+maxC);
		else printf("%d %d\n", 1, maxC);
	}
}

Measured memory_bytes: 256
a = input()
b = input()
c = input()
card = [a,b,c]
name = ["A","B","C"]
turns = {"a":0,"b":1,"c":2}

win = ""
turn = 0
while True:
    if len(card[turn]) == 0:
        win = name[turn]
        break
    else:
        top = card[turn][0]
        card[turn] = card[turn][1:]
        turn = turns[top]

print(win)

Measured memory_bytes: 3064
#import<bits/stdc++.h>
using namespace std;typedef long long l;string s;l r[10]={1,11,112,1124,11248,112496,1124992,11249984,112499968,1124999936};l a=0;main(){cin>>s;for(int i=0;i<s.size();++i)a+=(r[s.size()-i-1]<<i)*(s[i]-48);cout<<a<<endl;}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
const int maxn = 1e5;
const int inf = 1<< 30;
typedef long long LL;
int main(){
	char a;
	int ans = 0;
	for(int i = 0;i<4;i++){
		scanf("%c",&a);
		if(a == '+') ans++;
		else ans--;
	}
	cout << ans << endl;
	return 0;
}

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

int main(void){
    double n, m = 0, a = 0, s[1000];
    
    while(1){
        cin >> n;
        if(n == 0) break;
        for(int i = 0; i < n; i++){
            cin >> s[i];
            m += s[i];
        }
        m /= n;
        for(int i = 0; i < n; i++){
            a += (s[i] - m) * (s[i] - m);
        }
        a = sqrt(a / n);
        cout << fixed << setprecision(5) << a << endl;
        a = 0;
        m = 0;
    }
    return 0;
}


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

int dp[1001][1001];
pair<int,int> solve(vector<int> value , vector<int> weight,int W,int N){
	for(int i=0;i<1001;i++)for(int j=0;j<1001;j++)
		dp[i][j] = 0;

	for(int i=1 ; i <= N ; i++){
		for(int wei = 0 ; wei <= W ; wei++){
			if(wei < weight[i])dp[i][wei] = dp[i-1][wei];
			else dp[i][wei] = max(dp[i-1][wei] , dp[i-1][wei-weight[i]]+value[i]);
		}
	}
	int maxVal = dp[N][W];
	int minWei = find(dp[N],dp[N]+W+1,maxVal)-dp[N];
	return make_pair(maxVal,minWei);
}

int main(){
	int n,w,CaseNum=0;
	while(cin >> w && w){
		cout << "Case " << ++CaseNum << ":" << endl;
		cin >> n;
		vector<int> val(n+1),wei(n+1);
		for(int i=1;i<=n;i++)
			scanf("%d,%d\n",&val[i],&wei[i]);
		pair<int,int> ans = solve(val,wei,w,n);
		cout << ans.first << endl << ans.second << endl;
	}
}

Measured memory_bytes: 0
#!/usr/bin python3
# -*- coding: utf-8 -*-

n, a, b = map(int, input().split())
h = [int(input()) for _ in range(n)]

def check(k):
    ret = 0
    for hi in h:
        if hi - k * b> 0:
            ret += ((hi - k * b)+(a-b-1)) // (a-b)
    return k >= ret

ok = 10**9
ng = -1

while ok - ng >1:
    mid = (ok + ng)//2
    if check(mid):
        ok = mid
    else:
        ng = mid

print(ok)

Measured memory_bytes: 12964
use std::io;
use std::collections::HashMap;


/// https://beta.atcoder.jp/contests/arc066/tasks/arc066_a
fn main() {
    const MOD: usize = 1_000_000_007;
    let _ = read_one::<usize>();
    let an = read::<usize>();
    let mut hm = HashMap::new();
    let mut zero = 0;

    for a in an {
        *hm.entry(a).or_insert(0) += 1;
        if a == 0 { zero += 1; }
        if hm.get(&a).unwrap() > &2 {
            println!("0");
            return;
        }
    }

    if zero > 1 {
        println!("0");
        return;
    }

    let mut conb: usize = 1;
    for v in hm.values() {
        conb = conb * v;
        conb = conb % MOD;
    }
    println!("{}", conb);
}


#[allow(dead_code)]
fn read<T>() -> Vec<T>
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_one<T>() -> T
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}

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

int main()
{
    string s;
    cin >> s;
    int price = 700;
    for (int i = 0; i < s.size(); i++)
    {
        if (s[i] == 'o')
        {
            price += 100;
        }
    }

    cout << price << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>

int main() {
  std::string A, B;
  std::cin >> A >> B;

  int n = A.length();
  int m = B.length();
  if ( n > m ) std::cout << "GREATER" << std::endl;
  else if ( n < m ) std::cout << "LESS" << std::endl;
  else {
    bool flag = false;
    for (int i = 0; i < n; ++i) {
      if ( A[i] > B[i] ) {
        std::cout << "GREATER" << std::endl;
        flag = true;
        break;
      }
      else if ( A[i] < B[i] ) {
        std::cout << "LESS" << std::endl;
        flag = true;
        break;
      }
    }
    if ( !flag ) std::cout << "EQUAL" << std::endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;

int H, W, N;
int a[100010], b[100010];

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  cin >> H >> W >> N;
  for (int i = 0; i < N; i++) {
    cin >> a[i] >> b[i];
  }
  map<pii, int> mp;
  for (int i = 0; i < N; i++) {
    for (int dy = 0; dy < 3; dy++) {
      for  (int dx = 0; dx < 3; dx++) {
        int ny = a[i] + dy;
        int nx = b[i] + dx;
        if (ny >= 3 && ny <= H && nx >= 3 && nx <= W) {
          mp[pii(ny, nx)]++;
        }
      }
    }
  }
  vector<ll> ans(10);
  ans[0] = (ll)(H - 2) * (W - 2);
  for (auto p : mp) {
    ans[p.second]++;
    ans[0]--;
  }
  for (int i = 0; i < 10; i++) {
    cout << ans[i] << endl;
  }

  return 0;
}

Measured memory_bytes: 57344
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<map>
using namespace std;
#define ll long long
int main(){
    int n,a,b;
    cin >> n >> a >> b;
    int ansa,ansb;
    ansa=a;
    if(b<ansa)ansa=b;
    ansb = a+b-n;
    if(ansb<0)ansb=0;
    cout << ansa <<" " <<ansb;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <utility>
#include <climits>
#include <bitset>
#include <cmath>
#include <set>

#define MOD 1000000007

using namespace std;

typedef long long ll;

typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<vl> vvl;
typedef vector<vi> vvi;

typedef pair<ll, ll> pll;
typedef pair<int, int> pi;

typedef vector<pll> vpl;
typedef vector<pi> vpi;

typedef queue<ll> ql;
typedef queue<int> qi;

template <class T>
void printv(vector<T> vc) {
    for (auto e: vc) cout << e << " ";
    cout << endl;
}

template <class T>
void printvv(vector<T> vvc) { 
    for (auto vc: vvc) {
        for (auto e: vc) cout << e << " ";
        cout << endl;
    }
}

template <class T>
void printvp(vector<pair<T, T> > vp) {
    for (auto pT: vp) cout << pT.first << " " << pT.second << endl;
}

int main() {
    int n; cin >> n;
    set<int> p;
    for (int i = 0; i < n; ++i) {
        int e; cin >> e;
        if (p.find(e) == p.end()) p.insert(e);
        else                      p.erase(e);
    }
    cout << p.size() << endl;
    return 0;
}

Measured memory_bytes: 4992
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <functional>
#include <ctime>
#include <cmath>
#include <limits>
#include <numeric>
#include <type_traits>
using namespace std;
using ll = long long;

unsigned euclidean_gcd(unsigned a, unsigned b) {
    if (a < b) return euclidean_gcd(b, a);
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

class UnionFind {
public:
    vector <ll> par;
    vector <ll> siz;
    UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    ll root(ll x) {
        while (par[x] != x) {
            x = par[x] = par[par[x]];
        }
        return x;
    }
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) {
        return root(x) == root(y);
    }

    ll size(ll x) {
        return siz[root(x)];
    }
};

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}

int main() {
    int s, w;
    cin >> s >> w;
    if (s <= w)cout << "unsafe" << endl;
    else cout << "safe" << endl;
}

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

int main(){
  int count=0,A,B,judge,t,u,v,w,x,y,high,low;
  
  cin >> A >> B;
  
  for(int i=A;i<=B;i++){
    //以下で考える数字がiに与えられる。
    judge = 1;
    //桁数を出す
    int keta = 1,k=0;
    
    for(int j=1;j<=i;j*=10){
      k++;
      keta = j;
    } 
    v = i;
    //ここまででｎ桁の数のnがkに、１０^(n-1)がketaに入力される。
    
    //上の位と下の位が合致しているかどうかを調べる。
    t =k/2;
    u =k;
    
    for(int l=0;l<t;l++){
      //上のくらいの数を決めたあと上の位の数字を削る。
      high = v/keta;
      v -= high*keta;
      keta /=10;
      x = keta;
      w =v;
      u -=2;
      //下の位の数を決めた後下の数字を削る。
      for(int m=0;m<u;m++){
        y = w/x;
        w -= x*y;
        x /=10;
      }
      
      low = w;
      
      //次の試行にむけてｖとketaを調整
      v /=10;
      keta /=10;
      
      //ここまででHighとlowが求まる。
      
      if (low != high){
        judge *=0;
        break;
      }
    }
      if(judge == 1)
        count++;
  }
    cout << count <<endl;
}

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

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

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
bool judge(int a,int b,string s){
    for(int i = a-1;i<b-1;i++){
        if(s[i] == '#' && s[i+1] == '#'){
            return false;
        }
    }
    return true;
}
bool check(int a,int b,string s){
    for(int i = a-1;i<=b-1;i++){
        if(s[i-1] == '.' && s[i] == '.' && s[i+1] == '.'){
            return true;
        }
    }
    return false;
}
int main(){
    int n,a,b,c,d;
    cin >> n >> a >> b >> c >> d;
    string s;
    cin >> s;
    if(judge(a,c,s) && judge(b,d,s)){
        if(c<d || check(b,d,s)){
            cout << "Yes" << endl;
        }
        else{
            cout << "No" << endl;
        }
    }
    else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 900
/**
 * author: Behradm
 * Created: 2020.09.13 17:35:49
 * In The Name of God
**/
#include <bits/stdc++.h>

using namespace std;

int main() {   
  ios::sync_with_stdio(false);
  cin.tie(0);
  auto Dist = [&](pair<int, int> a, pair<int, int> b) {
    return abs(a.first - b.first) + abs(a.second - b.second);
  };
  int n;
  cin >> n;
  vector<pair<int, int>> a(n);
  vector<pair<int, pair<int, int>>> x(n);
  vector<pair<int, pair<int, int>>> y(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i].first >> a[i].second;
    x[i] = {a[i].first + a[i].second, a[i]};
    y[i] = {a[i].first - a[i].second, a[i]};
  }                

  sort(x.begin(), x.end());
  sort(y.begin(), y.end());
  int best = max(Dist(x[0].second, x[n - 1].second), Dist(y[0].second, y[n - 1].second));
  cout << best << '\n';
  return 0;
}


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

Measured memory_bytes: 256
while True:
    plen = input()
    if plen == 0:
        break
    cnum = input()
    width = input()
    space = "." * input()
    def formated_print(note):
        for i in xrange(plen):
            print space.join(note[j*plen+i].ljust(width, ".") for j in xrange(cnum))
        print "#"
    note = []
    line = raw_input()
    while line != "?":
        if len(note) >= plen * cnum:
            formated_print(note)
            note = []
        if len(line) > width:
            note.append(line[:width])
            line = line[width:]
        else:
            note.append(line)
            line = ""
        if line == "":
            line = raw_input()
    if note:
        while len(note) < plen * cnum:
            note.append("")
        formated_print(note)
    print "?"

Measured memory_bytes: 4252
#include <iostream>
#include <cstdio>
#include <algorithm>
#define ll long long
using namespace std;
int n;
int a[1000000];
int main (){

    scanf("%d", &n);
    for(int i = 1; i <= n; ++i) {
        scanf("%d", &a[i]);
    }
    sort(a+1, a+1+n);
    int fi = 0, se = 0;
    int cnt1 = 0, cnt2 = 0;
    for(int i = 1; i < n; ++i) {
        if(a[i] >= fi && a[i+1] == a[i])se = fi, fi = a[i] , ++i;
        //cout << fi << " " << se;
    }

    ll ans = (ll) fi * se;
    printf("%lld", ans);

}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<string,int>;
using T = tuple<string,int,int>;

int main(){
  int n; cin >> n;
  vector<P> p(n);
  for(int i = 0; i < n; i++){
    cin >> p[i].first >> p[i].second;
  }
  string x; cin >> x;
  int ans = 0;
  bool flg = false;
  for(int i = 0; i < n; i++){
    if(flg){
      ans += p[i].second;
    }
    if(p[i].first == x) flg = true;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256