akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

int main()
{
    int m1, d1, m2, d2;
    cin >> m1 >> d1 >> m2 >> d2;

    if (m1 != m2) {
        cout << 1 << endl;
    } else {
        cout << 0 << endl;
    }

    return 0;
}

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

int main()
{
    int T;
    cin>>T;
    for (int t=0; t<T; t++)
    {
        int N;
        cin>>N;
        vector<long long> A(N);
        for (long long &a: A)
            cin>>a;
        string S;
        cin>>S;

        vector<long long> T;
        int ans = 0;

        for (int i=0; i<N; i++)
            if (S[i]=='1')
            {
                T.clear();
                for (int j=i+1; j<N; j++)
                    if (S[j]=='0')
                        T.push_back(A[j]);
                T.push_back(A[i]);
                bool ok = true;
                int p = 0;
                for (int b=0; b<60; b++)
                {
                    int t=p;
                    while (t<(int)T.size()-1 && (T[t]>>b&1)==0)
                        t++;
                    if (t>=(int)T.size()-1)
                    {
                        if (T[T.size()-1]>>b&1)
                        {
                            ok = false;
                            break;
                        }
                    }
                    else
                    {
                        swap(T[p], T[t]);
                        for (int i=0; i<(int)T.size(); i++)
                            if (i!=p && (T[i]>>b&1)!=0)
                            {
                                T[i] ^= T[p];
                            }
                        p++;
                    }
                }
                if (!ok)
                {
                    ans = 1;
                    break;
                }
            }
        cout<<ans<<endl;
    }
}


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

int main(){
    int h=0,k=0;
    int ih,yh,ik,yk;
    int a,b,c,d;

    cin>>ih>>yh;
    cin>>ik>>yk;
    cin>>a>>b>>c>>d;

    h+=(ih*a + yh*b + (ih/10)*c + (yh/20)*d); 

    k+=(ik*a + yk*b + (ik/10)*c + (yk/20)*d);

    if(h>k) cout<<"hiroshi"<<endl;
    else if(h<k) cout<<"kenjiro"<<endl;
    else cout<<"even"<<endl;

    return 0;
}



Measured memory_bytes: 3080
#[allow(unused_macros)]
macro_rules ! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( stdin . lock ( ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! input_inner { ( $ next : expr ) => { } ; ( $ next : expr , ) => { } ; ( $ next : expr , mut $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let mut $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! read_value { ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) } ; ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) } ; }

fn main() {
    input! {
        n: u64
    }

    println!("{}", n*(n+1)/2);
}

Measured memory_bytes: 4476
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define all(x) (x).begin(), (x).end()
#define MOD 1000000007
int main() {
    ll a, b, k;
    cin >> a >> b >> k;
    if(a >= k) {
        cout << a - k << " " << b << endl;
    } else {
        k -= a;
        cout << 0 << " " << max(0LL, b - k) << endl;
    }
}


Measured memory_bytes: 256
import sys
import math
import collections
import itertools
import array
import inspect

# Set max recursion limit
sys.setrecursionlimit(1000000)


# Debug output
def chkprint(*args):
    names = {
        id(v): k
        for k, v in inspect.currentframe().f_back.f_locals.items()
    }
    print(', '.join(
        names.get(id(arg), '???') + ' = ' + repr(arg) for arg in args))


# Binary converter
def to_bin(x):
    return bin(x)[2:]


def li_input():
    return [int(_) for _ in sys.stdin.readline().split()]


def gcd(n, m):
    if n % m == 0:
        return m
    else:
        return gcd(m, n % m)


def gcd_list(L):
    v = L[0]

    for i in range(1, len(L)):
        v = gcd(v, L[i])

    return v


def lcm(n, m):
    return (n * m) // gcd(n, m)


def lcm_list(L):
    v = L[0]

    for i in range(1, len(L)):
        v = lcm(v, L[i])

    return v


# Width First Search (+ Distance)
def wfs_d(D, N, K):
    """
    D: 隣接行列(距離付き)
    N: ノード数
    K: 始点ノード
    """

    dfk = [-1] * (N + 1)
    dfk[K] = 0

    cps = [(K, 0)]
    r = [False] * (N + 1)
    r[K] = True
    while len(cps) != 0:
        n_cps = []
        for cp, cd in cps:
            for i, dfcp in enumerate(D[cp]):
                if dfcp != -1 and not r[i]:
                    dfk[i] = cd + dfcp
                    n_cps.append((i, cd + dfcp))
                    r[i] = True

        cps = n_cps[:]

    return dfk


# Depth First Search (+Distance)
def dfs_d(v, pre, dist):
    """
    v:  現在のノード
    pre: １つ前のノード
    dist: 現在の距離

    以下は別途用意する
    D: 隣接リスト(行列ではない)
    D_dfs_d: dfs_d関数で用いる，始点ノードから見た距離リスト
    """

    global D
    global D_dfs_d

    D_dfs_d[v] = dist

    for next_v, d in D[v]:
        if next_v != pre:
            dfs_d(next_v, v, dist + d)

    return


def sigma(N):
    ans = 0
    for i in range(1, N + 1):
        ans += i
    return ans


def comb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2, r + 1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p - 1, r, p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

def bisearch(L, target):
    low = 0
    high = len(L) - 1
    
    while low <= high:
        mid = (low + high) // 2
        guess = L[mid]
        if guess == target:
            return True
        elif guess < target:
            low = mid + 1
        elif guess > target:
            high = mid - 1
    if guess != target:
        return False

# --------------------------------------------

dp = None


def main():
    N = int(input())
    L = li_input()

    x = max(L)
    i = L.index(x)
    L_ = L[:i] + L[i+1:]

    if x < sum(L_):
        print("Yes")
    else:
        print("No")


main()


Measured memory_bytes: 4852
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC174C
{
    class Program
    {
        static void Main(string[] args)
        {
            long K = long.Parse(Console.ReadLine());
            long L = 0;
            if (K % 7 == 0)
            {
                L = 9 * K / 7;
            }
            else
            {
                L = 9 * K;
            }
            //Console.WriteLine(L);
            long amari = 1;
            if (L % 2 == 0)
            {
                Console.WriteLine(-1);
            }
            else if (L % 5 == 0)
            {
                Console.WriteLine(-1);
            }
            else
            {
                for(int i = 1; i <= L; i++)
                {
                    amari *= 10;
                    if (amari % L == 1)
                    {
                        Console.WriteLine(i);
                        break;
                    }
                    else
                    {
                        amari = amari % L;
                    }
                }
            }
        }
    }
}


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

using namespace std;

using ll = long long;
using vll = vector<ll>;
using vii = vector<int>;
using pii = pair<int, int>;
template <typename T = vii>
using vec = vector<T>;

const ll INF = 1e18, MOD = 1e9 + 7;

const int MAX = 1e6;

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

    int n;
    cin >> n;
    vec<pair<ll, ll> > v(n);
    for (auto &p : v) {
        cin >> p.second >> p.first;
        p.second *= -1;
    }
    sort(v.begin(), v.end());
    ll curr = 0;
    for (auto e : v) {
        curr -= e.second;
        if (curr > e.first) {
            cout << "No\n";
            return 0;
        }
    }
    cout << "Yes\n";
}

Measured memory_bytes: 3328
loop{
    a="#"
b="."
h,w=gets.split(" ").map(&:to_i)
break if h==0 and w==0
h.times{|i|
    w.times{|j|
        if (i+j)%2==0
            print("#{a}")
        else
            print("#{b}")
        end
    }
    puts""
}
puts""
}


Measured memory_bytes: 6880
#include <iostream>
#include<vector>
using namespace std;
int main() {
    
    string s,t;
    cin>>s>>t;

    int m=s.size();
    int n=t.size();
    
    vector<vector<int>> dp(m+1,vector<int>(n+1));

    for(int i=0;i<=m;i++)
    {
      for(int j=0;j<=n;j++)
      {
          if(i==0||j==0)
           dp[i][j]=0;
           else if(s[i-1]==t[j-1])
            dp[i][j]=1+dp[i-1][j-1];
           else 
            dp[i][j]=max(dp[i][j-1],dp[i-1][j]); 
      }
    }

    int index=dp[m][n];
    char ch[index+1];
     ch[index]='\0';

    int i=m,j=n;
    while(i>0&&j>0)
    {
        if(s[i-1]==t[j-1])
        {
            ch[index-1]=s[i-1];
            i--;j--;index--;
        }
        else if(dp[i-1][j]>dp[i][j-1])
         i--;
        else
         j--;
    }
    cout<<ch;
}


Measured memory_bytes: 35584
n = int(input())
 
l = [[-1]*n for _ in range(n)]
 
for i in range(n):
  a = int(input())
  for j in range(a):
    x, y = map(int, input().split())
    x = x-1
    l[i][x] = y

#print(l)
ans = 0
for i in range(2 ** n):
  #ans_ = 0
  flag = 0
  for j in range(n):
    if ((i >> j) & 1):
      #ans_ += 1
      for k in range(n):
        if l[j][k] == 1 and ((i >> k) & 1)==1:
          continue
        elif l[j][k] == 0 and ((i >> k) & 1)==0:
          continue
        elif l[j][k] == -1:
          continue
        else:
          #print(l[j][k], (i >> k))
          flag = 1
  if flag == 0:
    ans_ = 0
    for p in range(n):
      if ((i >> p) & 1):
        ans_ += 1
    ans = max(ans, ans_)
print(ans)

Measured memory_bytes: 44124
function main(arg) {    
 	arg = arg.trim().split('\n');
 	var n = Number(arg[0]),
  		cut = arg[1].split('');

  	console.log(cut.map(function(str) {
      var num = str.charCodeAt() + n;
      if (num > 90) {
        num -= 26;
      }
      return String.fromCharCode(num)
    }).join(''));
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7500
#ifdef MY_LOCAL
#define MY_NAMESPACE(ns) namespace ns {
#define MY_NAMESPACE_    }
#define MY_DEBUG(s)      s
#else
#define MY_NAMESPACE(ns) 
#define MY_NAMESPACE_    
#define MY_DEBUG(s)      
#endif

#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <string>
#include <tuple>
#include <unordered_map>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define EPS (1e-7)
#define IINF ((int)1e9)


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

	string s, t;
	cin >> s;
	cin >> t;
	int res = 0;
	for (int i = 0; i < s.length(); i++)
	{
		if (s[i] != t[i])
			res++;
	}
	cout << res << "\n";
	return 0;
}
MY_NAMESPACE_

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

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

    if (a == 'H')
    {
       cout << b << endl;
    }else
    {
        char a = (b == 'H')? 'D' : 'H';
        cout << a << endl; 
    }   
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int n , k;
    cin >> n >> k;
    if(n > k ){
        if ( k == 1){
            cout << "Bob" <<endl;
        }
        else {
            cout << "Alice" <<endl;
        }

    }
    else if (k > n ){
            if( n == 1){
                cout << "Alice"<< endl;
            }
            else{
                cout << "Bob"<<endl;
            }
    }
    else if (n == k){
        cout << "Draw" <<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define endl "\n"
using ll=long long;
using namespace std;
ll l[110000],r[110000],p[110000],q[110000],sum[110000];
main(){
  ll n;
  cin>>n;
  rep(i,0,n)cin>>l[i]>>r[i];
  rep(i,2,100001)p[i]=1;
  rep(i,2,100001){
    if(p[i]==1){
      for(ll j=i*2;j<=100001;j+=i)p[j]=0;
    }
  }
  rep(i,2,100001){
    if(p[i]&&p[(i+1)/2])q[i]=1;
    sum[i]+=sum[i-1]+q[i];
  }
  rep(i,0,n)cout<<sum[r[i]]-sum[l[i]-1]<<endl;
}

Measured memory_bytes: 4736
#include<bits/stdc++.h>
typedef long long ll;
#define sz(x) int(x.size())
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define MOD 1000000007

using namespace std;

int main() {
    int N; cin >> N;
    cout << (N+1)/2 << endl;
}

Measured memory_bytes: 256
import sys

n, *v = map(int, sys.stdin.read().split())

def main():
    v.sort(reverse=True)
    res = 0
    for i in range(n-1):
        res += v[i] / 2 ** (i + 1)
    res += v[-1] / 2 ** (n - 1)
    return res

if __name__ == '__main__':
    ans = main()
    print(ans)

Measured memory_bytes: 3060
#include <stdio.h>
#include <iostream>

using namespace std;

int main()
{
	char s;
	cin >> s;

	if (s == 'a' || s == 'i' || s == 'u' || s == 'e' || s == 'o')
		cout << "vowel" << endl;
	else
		cout << "consonant" << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
	int N,A,B;
	char m[100000];
	scanf("%d %d %d",&N,&A,&B);
	for(int i=0;i<=N;i++){
		scanf("%c",&m[i]);
	}
	for(int i=0;i<=N;i++){
		if(m[i]=='c'){
			printf("No\n");
			continue;
		}
		if(m[i]=='a'){
			if(A+B>0){
				printf("Yes\n");
				A--;
			}
			else printf("No\n");
		}
		else if(m[i]=='b'){
			if(A+B>0 && B>0){
				printf("Yes\n");
				B--;
			}
			else printf("No\n");
		}
	}
	return 0;
}


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

int main() {
 int N,i,p=0,w=0,y=0,g=0;
  cin >> N;
 
 
  for(i=0;i<N;i++){
    string s;
    cin >> s;
    if(s=="P"){
      p++;
    }else if(s=="W"){
      w++;
    }
    else if(s=="G"){
      g++;
    }
    else if(s=="Y"){
      y++;
    }
  }
  
  if(p && w && g && y){
    cout << "Four" << endl;
}else{
    cout << "Three" << endl;
  }
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstring>
#include <chrono>
#include <complex>
#define endl "\n"
#define int long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define mod 1000000007
#define inf 1000000000000000001;
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define f first
#define s second
#define pb push_back

using namespace std;
void dfs(vector<int>v[], int u, int vis[], int col)
{
vis[u] = col;

for (auto i : v[u])
{
if (!vis[i])
{
dfs(v, i, vis, col);
}
}
}
void lala()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
}
int powr(int x,int y,int z)
{
	int	ans=1;
	int square=x;
	if(y==0)
	    return 1;
	while(y!=0)
	{
	    if(y%2)
	        ans=ans*square;
	    square=(square*square)%z;
	    y=y/2;
	    if(ans>z)
	        ans=ans%z;
	}
	return ans;
}
int32_t main()
{
std::ios::sync_with_stdio(false);

#ifndef ONLINE_JUDGE
freopen("inputf.txt", "r", stdin);
freopen("outputf.txt", "w", stdout);
#endif
int n, m;
cin >> n >> m;
vector<int>v[n + 1];
for (int i = 0; i < m; i++)
{
int x, y;
cin >> x >> y;
v[x].pb(y); v[y].pb(x);
}


int vis[n + 1] = {};

int col = 1;
for (int i = 1; i <= n; i++)
{
if (!vis[i])
{
dfs(v, i, vis, col);
col++;
}
}

map<int, int>ma;

for (int i = 1; i <= n; i++)
ma[vis[i]]++;
int res = 0;
for (auto i : ma)
{
res = max(res, i.s);
}
cout << res << endl;
return 0;
}


Measured memory_bytes: 25432
import java.util.Scanner;

public class Main {
    public static void main(String [] args) {
        Scanner scanner = new Scanner(System.in);
        long n = scanner.nextLong();
        long k = scanner.nextLong();
        int len = 0;
        if (n == 0) {
            System.out.println(1);
            return;
        }
        while (n > 0) {
            ++len;
            n /= k;
        }
        System.out.println(len);
    }
}


Measured memory_bytes: 23764
#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 r,g,b;
  cin >> r >> g >> b;
  int ans = r*100+g*10+b;
  if (ans%4==0){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 256
def cost(p, q):
    if p * q >= 0:
        return max(abs(p), abs(q)) * 2
    else:
        return abs(p - q) * 2

n = int(input())
a = list(map(int, input().split()))
b = [0] + a + [0]
d = sum([abs(b[i + 1] - b[i]) for i in range(n + 1)])
for i in range(n):
    print(d - abs(b[i + 1] - b[i]) - abs(b[i + 2] - b[i + 1]) + abs(b[i + 2] - b[i]))


Measured memory_bytes: 14048
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main() {
    string S;
    cin >> S;
    
    int ansf=-1, anse=-1;
    for(int s=1; s<S.size(); s++) {
        if(S[s-1]==S[s]) {
            ansf=s;
            anse=s+1;
            break;
        } else {
            if(s+1<S.size()) {
                if(S[s-1]==S[s+1] || S[s]==S[s+1]) {
                    ansf=s;
                    anse=s+2;
                }
            }
        }
    }
    
    cout << ansf << " " << anse << endl;


    return 0;
    
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define int long long
int MOD;
int mod_pow(int x,int n,int mod){
  int res=1LL;
  while(n>0){
    if(n&1) (res*=x)%=mod;
    (x*=x)%=mod;
    n>>=1;
  }
  return res;
}
int mod_inverse(int x,int mod){
  return mod_pow(x,mod-2,mod);
}
int flag;
int expression(string s,int&p);
int term(string s,int&p);
int factor(string s,int&p);
int number(string s,int&p);
 
int expression(string s,int&p){
  int res=term(s,p);
  while(p<(int)s.size()){
    if(s[p]=='+'){
      p++;
      (res+=term(s,p))%=MOD;
      continue;
    }
    if(s[p]=='-'){
      p++;
      (res+=MOD-term(s,p))%=MOD;
      continue;
    }
    if(flag) return 0;
    break;
  }
  return res;
}
 
int term(string s,int&p){
  int res=factor(s,p);
  while(p<(int)s.size()){
    if(s[p]=='*'){
      p++;
      (res*=factor(s,p))%=MOD;
      continue;
    }
    if(s[p]=='/'){
      p++;
      int tmp=factor(s,p);
      if(tmp==0){
	flag=1;
	break;
      }
      (res*=mod_inverse(tmp,MOD))%=MOD;
      continue;
    }
    if(flag) return 0;
    break;
  }
  return res;
}
 
int factor(string s,int&p){
  int res;
  if(s[p]=='('){
    p++;
    res=expression(s,p);
    p++;
  }else{
    res=number(s,p);
  }
  return res;
}
 
int number(string s,int&p){
  int res=0;
  while(p<(int)s.size()&&isdigit(s[p]))
    res=res*10+s[p++]-'0';
  return res;
}
 
signed main(){
  string s;
  while(getline(cin,s),s[0]!='0'){
    int latte=s.find(':');
    string x=s.substr(0,latte);
    //cout<<latte<<": "<<x<<endl;
    MOD=stoll(x);
    s.erase(s.begin(),s.begin()+latte+1);
    string t;
    for(int i=0;i<(int)s.size();i++) if(s[i]!=' ') t+=s[i];
    int p=0;
    flag=0;
    int ans=expression(t,p);
    if(flag) cout<<"NG"<<endl;
    else cout<<t<<" = "<<ans<<" (mod "<<MOD<<")"<<endl;
  }
  return 0;
}

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

#define rep(i,n) for(int i=0;i<(n); ++i)
#define INF 100000 // 2^31-1
#define MAX_V 1000


using namespace std;

using ll =long long;
using P = pair<int,int>;


 
int ctoi(const 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;
  }
}

//5
int gcd(int a,int b){return b?gcd(b,a%b):a;}


int main() {

ios::sync_with_stdio(false);
cin.tie(0);
double a,b,h,m;
cin>>a>>b>>h>>m;

double pi=2.0 * asin(1.0);
double unit=pi/180.0;

double onemin_h=0.5;
double onemin_m=6;

double hh=0.5*m+30*h;
double mm=6.0*m;

double haba=max(hh,mm)-min(hh,mm);

double res=0;
res=a*a+b*b-2*a*b*cos(haba*unit);
res=sqrt(res);

cout << fixed << setprecision(13) <<res << endl;


}

//cout << fixed << setprecision(5) <<(n*2)*M_PI << endl;

Measured memory_bytes: 4244
#include <algorithm>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>
using namespace std;
#define ALL(x) (x).begin(), (x).end()
#define OUT(x) cout << (x) << endl
typedef long long ll;

const ll INF = 1e10;
const int MAX_V = 100010;

int main() {
    int N;
    ll W;
    cin >> N >> W;
    ll w[N], v[N];
    for (int i = 0; i < N; i++) {
        cin >> w[i] >> v[i];
    }
    ll dp[N + 1][MAX_V];
    for (int i = 0; i < N + 1; i++) {
        for (int j = 0; j < MAX_V; j++) {
            dp[i][j] = INF;
        }
    }
    dp[0][0] = 0;

    for (int i = 0; i < N; i++) {
        for (int j = 0; j < MAX_V; j++) {
            if (j - v[i] >= 0) {
                dp[i + 1][j] = min(dp[i + 1][j], dp[i][j - v[i]] + w[i]);
            }
            dp[i + 1][j] = min(dp[i + 1][j], dp[i][j]);
        }
    }
    ll ans = 0;
    for (int i = 0; i < MAX_V; i++) {
        if (dp[N][i] <= W) ans = i;
    }
    OUT(ans);
}


Measured memory_bytes: 79104
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>
#include <stdio.h>
#include <string.h>
using ll = long long;

//LLONG_MAX
#define int long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define LOWER_BOUND(v,a) (lower_bound((v).begin(), (v).end(), (a)))
#define UPPER_BOUND(v,a) (upper_bound((v).begin(), (v).end(), (a)))
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define CONTAINS_MAP(m, a) (m).find((a)) != m.end()

using namespace std;

int N;
char S[100010];

signed main()
{
	cin >> N;
	cin >> S;

	char prev = ' ';
	int ans = 0;
	for (int i = 0; i < N; i++)
	{
		if (S[i] != prev)
		{
			ans++;
			prev = S[i];
		}
	}
	cout << ans << endl;
}



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

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

    int temp = 1;

    for (int i = 0; i < N; i++)
    {
        temp = ((temp * 2 < temp + K) ? (temp * 2) : (temp + K));
    }
    cout << temp << endl;
}


Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::io::{Write, BufWriter};

// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!(
        a: usize,
        b: usize,
        c: usize,
    );
    let mut dp: Vec<i32> = Vec::new();
    dp.resize(b, 0);
    dp[0] = 1;
    for i in 1..100 {
        let mul = i * a % b;
        if dp[mul] == 1 {
            break;
        }
        dp[mul] = 1;
    }
    let mut update = true;
    while update {
        update = false;
        for i in 0..b {
            for j in 0..b {
                if dp[i] * dp[j] == 1 {
                    let t = (i + j) % b;
                    if dp[t] == 0 {
                        update = true;
                        dp[t] = 1;
                    }
                }
            }
        }
    }
    println!("{}", if dp[c] == 1 {"YES"} else {"NO"});
}

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

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

const int maxn = 1e5 + 10;
int dist[maxn]; 
int main(int argc, char const *argv[]) {
	int k; cin >> k; 
	deque<int> q;
	for(int i = 0; i <= k; i++) 
		dist[i] = 1e9; 

	dist[1] = 1;
	q.push_back(1);

	while(!q.empty()) {
		int u = q.front(); q.pop_front(); 
		if(u == 0) { cout << dist[0] << endl; return 0; }
		int v = (u + 1) % k;
		if(dist[v] > dist[u] + 1) {
			dist[v] = dist[u] + 1; 
			q.push_back(v); 
		}
		v = (u * 10) % k;
		if(dist[v] > dist[u]) {
			dist[v] = dist[u];
			q.push_front(v);
		}
	}
}

Measured memory_bytes: 896
n = int(input())
s = []
for i in range(n):
    s += [int(input())]
s = sorted(s)
a = sum(s)
if a % 10 != 0:
    print(a)
    exit()
else:
    for i in range(n):
        if s[i] % 10 != 0:
            a -= s[i]
            if a % 10 != 0:
                print(a)
                f = 0
                exit()
        else:
            f = 1
if f:
    print(0)

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


using ll = long long;
const ll INF = 1LL << 50;


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

  const int NMAX = 1000;
  const int MMAX = 2000;

  int a[MMAX], b[MMAX];
  ll c[MMAX];

  for (int i=0; i<M; ++i) {
    cin >> a[i] >> b[i] >> c[i];
    c[i] = -c[i];
  }

  ll dist[NMAX];

  for (int i=0; i<N; ++i) {
    dist[i] = INF;
  }

  dist[0] = 0;

  for (int loop=0; loop<N-1; ++loop) {
    for (int i=0; i<M; ++i) {
      if (dist[a[i]-1] == INF) continue;

      if (dist[b[i]-1] > dist[a[i]-1] + c[i]) {
        dist[b[i]-1] = dist[a[i]-1] + c[i];
      }
    }
  }

  bool negative[NMAX];

  for (int i=0; i<N; ++i) {
    negative[i] = false;
  }

  for (int loop=0; loop<N; ++loop) {
    for (int i=0; i<M; ++i) {
      if (dist[a[i]-1] == INF) continue;

      if (dist[b[i]-1] > dist[a[i]-1] + c[i]) {
        dist[b[i]-1] = dist[a[i]-1] + c[i];
        negative[b[i]-1] = true;
      }

      if (negative[a[i]-1]) {
        negative[b[i]-1] = true;
      }
    }
  }

  if (negative[N-1]) {
    cout << "inf" << endl;
  }
  else {
    cout << -dist[N-1] << endl;
  }
}


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

int main(){
	const int LEN = 393;
	int n; cin >> n;
	int s[n], l[n], p[n];
	rep(i, n) cin >> s[i] >> l[n] >> p[i];
	int m; cin >> m;

	int dp[n+1][LEN+1];
	memset(dp, 0, sizeof(dp));
	loop(i, 1, n+1)loop(j, 1, LEN+1){
		if(j - s[i-1] >= 0) dp[i][j] = max(dp[i-1][j], dp[i][j - s[i-1]] + p[i-1]);
		else dp[i][j] = dp[i-1][j];
	}

	vector<int> ans;
	rep(i, m){
		int w; cin >> w;
		if(!dp[n][w]){
			cout << -1 << endl;
			return 0;
		} else ans.push_back(dp[n][w]);
	}
	for(int a : ans) cout << a << endl;
	return 0;
}



Measured memory_bytes: 3656
//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>

using namespace std;


void solve() {
    int K, A, B; cin >> K >> A >> B;

    for (int i = A; i <= B; i++) {
        if (i % K == 0) {
            cout << "OK" << endl;
            return;
        }
    }

    cout << "NG" << endl;
}


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

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int MOD=1e9+7;
template <class Q>
void clearQueue(Q & q) {
    q = Q();
}
void solve(){
    int n,k;cin>>n>>k;
    map<int,bool>mp;
    for(int i=1;i<=k;i++){
        int x;
        cin>>x;
        mp[x]=true;
    }
    for(int i=n;;i++){
        string s=to_string(i);
        bool flag=true;
        for(int j=0;j<s.length();j++){
            if(mp[s[j]-'0']==true) {flag=false;break;}
        }
        if(flag) {cout<<i;break;}
    }
}
int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL); 
	int T=1;
	// cin>>T;
	while(T--){
		solve();
	}
	return 0;
}


Measured memory_bytes: 3728
#include<stdio.h>
int main(void){
    int cup[3]={1},tmp,i;
    char a,b;
    while(scanf(" %c, %c",&a,&b)!=EOF){
        tmp=cup[a-'A'];
        cup[a-'A']=cup[b-'A'];
        cup[b-'A']=tmp;
    }
    for(i=0;i<3;i++)if(cup[i]==1)printf("%c\n",i+'A');

    return 0;
}

Measured memory_bytes: 540
import numpy as np

N = int(input())
A = np.array(list(map(int, input().split()))) #現状
B = np.array(list(map(int, input().split()))) #要求値

AminusB = A-B

if np.all(AminusB >= 0):
    print(0)
elif np.sum(AminusB) < 0:
    print(-1)
else:
    AminusB = np.sort(AminusB)[::-1]
    count = len(AminusB[AminusB < 0])
    minus = AminusB[AminusB < 0].sum()
    
    for i in range(N):
        minus += AminusB[i]
        count += 1
        if minus >= 0:
            break

    print(count)

Measured memory_bytes: 23900
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
using Edge = pair<int, ll>;
using Graph = vector<vector<int>>;
using WeightedGraph = vector<vector<Edge>>;
const ll INF64 = 1LL << 60;
const int INF32 = 1 << 29;
const ll MOD = 1000000007;

const int CASES = 3;

void solve() {
    ll H, W; cin >> H >> W;
    if(H==1 || W==1){
        cout << 1 << endl;
        return ;
    }
    ll w1 = W/2;
    ll w2 = W/2;
    if(W%2!=0) w1 += 1;
    ll ans = (w1 + w2) * (H/2);
    if(H%2!=0) ans += w1;
    cout << ans << endl;
}

int main() {
#ifdef MYLOCAL
    vector<string> filenames {"input1.txt", "input2.txt", "input3.txt", "input4.txt", "input5.txt"};
    cout << "------------\n";
    for(int i = 0; i < CASES; ++i){
        ifstream in(filenames[i]);
        cin.rdbuf(in.rdbuf());
        solve();
        cout << "------------\n";
    }
#else

    solve();

#endif
    return 0;
}


Measured memory_bytes: 256
/*                        ______
 _______   /\     |``\   |        |  /
    |     /  \    |__/   |____    |/
    |    / _ _\   |  \   |        |\
    |   /      \  |   \  |______  |  \

            Dept. of CSE
        Comilla  University

*/
#include<bits/stdc++.h>
#define pi 2*acos(0.0)
#define ll long long
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define Node struct node
#define spc " "
#define  E  2.71828182845904523536
#define pb push_back
#define pp pop_back
#define valid(nx,ny) nx>=0 && nx<n && ny>=0 && ny<m
#define ee endl
#define pii pair<int,int>
#define infinity 10000000000000000
#define mod 1000000007
int fx[]={0,0,+1,-1};
int fy[]={+1,-1,0,0};

using namespace std;
///check n=1;
///check corner case;
const int maX=1e5+1;
vector<ll>Graph[maX],cost[maX];
ll visit[maX];
ll x[10];
ll y[10];
double dist(ll i, ll j)
{
    double dx=x[i]-x[j];
    double dy=y[i]-y[j];
    return pow(dx*dx+dy*dy,0.5);
}

int main()
{
    ll n,i,j=0,cc=0;
    cin>>n;
    for(i=1;i<=n;i++){
        ll x=log10(i)+1;
        if(x&1)cc++;
    }
    cout<<cc<<endl;
}


Measured memory_bytes: 5248
#include <bits/stdc++.h>
#define mp make_pair
#define PII pair <int, int>
#define x first
#define y second

using namespace std;

int n, m;
int a[20005],r[20005];
int rs1[20005], rs2[20005];

int main(){
	cin >> n;
	for (int i = 1; i <= n; i++)
		cin >> a[i], r[a[i]] = i;
	for (int i = 1; i <= n; i++)
	{
		rs1[i] = 40000 * i;
		rs2[i] = 40000 * (n - i)+r[i];
	}
	for (int i = 1; i <= n; i++)
		cout << rs1[i] << " ";
	cout << "\n";
	for (int i = 1; i <= n; i++)
		cout << rs2[i] << " ";
	return 0;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
#define FOR(i, n) for(ll i = 0; i < n; i++)
#define FORR(i, n) for(ll i = n; i >= 0; i--)
#define FORS(i, m, n) for(int i = m;i < n;i++)
#define ALL(v) accumulate(v.begin(),v.end(),0)
#define SORT(v) sort(v.begin(),v.end())
#define OUT(n) (cout << n << endl)
#define IN1(a) (cin >> a)
#define IN2(a,b) (cin >> a >> b)
#define IN3(a,b,c) (cin >> a >> b >> c)
#define IN4(a,b,c,d) (cin >> a >> b >> c >> d)
using namespace std;
typedef long long ll;

int main(){
  int a,b,c,ans;
  IN3(a,b,c);
  ans = c - (a - b);
  if (ans <= 0){
    OUT("0");
  }
  else
  {
    OUT(ans);
  }
  
}

Measured memory_bytes: 256
from collections import Counter
n = int(input())
list_S = []
ans = []
for _ in range(n):
    list_S.append(str(input()))

list_S = Counter(list_S)
list_S = list(list_S.items())
list_S.sort(key=lambda x:x[1], reverse=True)

for l in list_S:
    if list_S[0][1] == l[1]:
        ans.append(l[0])
ans.sort()
for s in ans:
    print(s)

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

using namespace std;
typedef long long ll;
//ループ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//コンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
#define D()
//定数
#define INF 1000000000000 //10^12
#define MOD 10000007 //10^9+7
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

int main(){
    int n;
    cin >> n;
    n %= 10;
    if(n==3) cout << "bon";
    else if(n==0 || n== 1 || n== 6 || n==8) cout << "pon";
    else cout << "hon";    
}

Measured memory_bytes: 3504
#include <iostream>
#include <cstdio>
#include <bitset>
#include <queue>
#include <stack>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <utility>
#include <string>
#include <algorithm>
#include <cmath>
#include <limits>

using namespace std;
using ll=long long;
using vint=vector<int>;
using pint=pair<int,int>;

const double EPS = 1e-9;
const int inf = numeric_limits<int>::max();

#define rep(i,n) for(int i=0;i<int(n);++i)
#define rrep(i,n) for(int i=int(n-1);i>=0;--i)
#define REP(i,a,b) for(int i=int(a);i<int(b);++i)
#define RREP(i,a,b) for(int i=int(b-1);i>=int(a);--i)
#define SHOW(a) cout << #a << " = " << a << endl
#define ARR(a,n) for(int i=0;i<int(n);++i) cout << #a << "[" << i << "]" << " = " << a[i] << endl

void solve(){
  char t;
  int cnt=0;
  rep(i,4){
    cin >> t;
    if(t == '+')
      cnt++;
  }
  cout << (cnt-2) * 2 << endl;
}

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

Measured memory_bytes: 256
//#pragma GCC optimize("Ofast,unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,tune=native")
#include<bits/stdc++.h>

using namespace std;

#define all(x) (x).begin(),(x).end()
#define I(x, a) for(auto x : (a))
#define ins insert
#define F(i, l, r) for(auto i = (l); i < (r); i++)
#define DF(i, l, r) for(auto i = (l); i >= (r); i--)
#define E(i, l, r) for(auto i = (l); i <= (r); i++)
#define pb push_back
#define X first
#define Y second
#define mp make_pair
#define ret return
#define brk break
#define cont continue
#define move fjgjgjgjghd

typedef long long ll;
typedef unsigned long long ull;
typedef double dbl;
typedef pair<int, int> pii;

const int N = (int)2e5 + 5;
const int BUF = (int)1e7;

int q[BUF];
int qh = 0, qt = 0;
int n;
int a[N], b[N];
bool eq[N];

inline int prv(int i){
    ret i ? i - 1 : (n - 1);
}

inline int nxt(int i){
    ret i + 1 == n ? 0 : (i + 1);
}

inline void push(int x){
    q[qt++] = x;
}

inline void upd(int i){
    int l = prv(i), r = nxt(i);
    int pl = prv(l), nr = nxt(r);
    if(b[l] > b[pl] + b[i] && !eq[l])
        q[qt++] = l;
    if(b[r] > b[nr] + b[i] && !eq[r])
        q[qt++] = r;
}

int main(){
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> n;
    F(i, 0, n)
        cin >> a[i];
    F(i, 0, n)
        cin >> b[i];
    F(i, 0, n){
        if(a[i] == b[i]){
            eq[i] = 1;
            cont;
        }
        if(a[i] > b[i]){
            cout << -1;
            ret 0;
        }
        if(b[i] > b[prv(i)] + b[nxt(i)])
            push(i);
    }
    ll ans = 0;
    while(qh < qt){
        int i = q[qh++];
        int sum = b[prv(i)] + b[nxt(i)];
        if(sum >= b[i])cont;
        if(a[i] >= sum){
            if(a[i]%sum == b[i]%sum){
                ans += (b[i] - a[i])/sum;
                b[i] = a[i];
                eq[i] = 1;
            }
            else{
                cout << -1;
                ret 0;
            }
            upd(i);
        }
        else{
            ans += b[i]/sum;
            b[i] %= sum;
            if(b[i] < a[i]){cout << -1; ret 0;}
            if(b[i] == a[i])eq[i] = 1;
            upd(i);
        }
    }
    F(i, 0, n)
        if(a[i] != b[i])
            ans = -1;
    cout << ans;
    return 0;
}


Measured memory_bytes: 6528
import sys

input = sys.stdin.readline


def main():
    s = input().rstrip()
    N = len(s)

    i_C = -1
    for i in range(N):
        if s[i] == "C":
            i_C = i
            break
    i_F = -1
    for i in reversed(range(N)):
        if s[i] == "F":
            i_F = i
            break

    if i_C == -1 or i_F == -1:
        ans = "No"
    elif i_C < i_F:
        ans = "Yes"
    else:
        ans = "No"
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	Scanner sc = new Scanner(System.in);
	int n, k, s, cnt, use_cnt;

	void run() {
		for (;;) {
			n = sc.nextInt(); // less than or equal n
			k = sc.nextInt(); // num of elements
			s = sc.nextInt(); // sum of integer
			if ((n | k | s) == 0) {
				break;
			}
			cnt = 0;
			dfs(0, 1, 0);
			System.out.println(cnt);
		}
	}

	void dfs(int use_cnt, int num, int sum) {
		if (num - 1 > n) {
			return;
		}
		if (use_cnt == k) {
			if (sum == s) {
				cnt++;
			}
			return;
		} else {
			dfs(use_cnt + 1, num + 1, sum + num); // use num
			dfs(use_cnt, num + 1, sum); // not use num
		}
	}

	public static void main(String[] args) {
		new Main().run();
	}

	void debug(Object... o) {
		System.out.println(Arrays.deepToString(o));
	}
}

Measured memory_bytes: 20384
#include <iostream>
#include <string>
#include <vector>
#include <bits/stdc++.h>
#define ll long long

using namespace std;

int gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }

int main(){
    int S, W; cin >> S >> W;
    if (W >= S)
    {
      cout << "unsafe" << endl;
    }
    else
    {
      cout << "safe" << endl;
    }
    return 0;
    
}

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

int main()
{
    int N, K;
    int R, S, P;
    string T;

    cin >> N >> K;
    cin >> R >> S >> P;
    cin >> T;

    int score = 0;
    string Tlog;

    for (int i = 0; i < K; i++)
    {
        if (T[i] == 's')
        {
            score += R;
            Tlog += "r";
        }
        else if (T[i] == 'p')
        {
            score += S;
            Tlog += "s";
        }
        else
        {
            score += P;
            Tlog += "p";
        }
    }

    for (int i = K; i < N; i++)
    {
        if (T[i] == 's' && Tlog[i - K] != 'r')
        {
            score += R;
            Tlog += "r";
        }
        else if (T[i] == 'p' && Tlog[i - K] != 's')
        {
            score += S;
            Tlog += "s";
        }
        else if (T[i] == 'r' && Tlog[i - K] != 'p')
        {
            score += P;
            Tlog += "p";
        }
        else if (T[i] == 's' && Tlog[i - K] == 'r')
        {
            Tlog += "a";
        }
        else if (T[i] == 'p' && Tlog[i - K] == 's')
        {
            Tlog += "a";
        }
        else if (T[i] == 'r' && Tlog[i - K] == 'p')
        {
            Tlog += "a";
        }
    }

    cout << score << endl;

    return 0;
}


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

int ketasum(int n){
  int sum = 0;
  while (n > 0){
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

int main(){
  int n;
  cin >> n;
  int fn = ketasum(n);
  bool res = false;
  if (n % fn == 0) res = true;
  if (res) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n; i >= 0; i--)
#define reprr(i, m, n) for (ll i = m; i < n; i++)
#define inf 2e9
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;


int main()
{
    ll n; cin >> n; string s; cin >> s;
    vvll rgb(2);
    ll cnt = 0;
    vector<bool> v(4000, false);

    rep (i, s.size()) {
        char c = s[i];
        if (c == 'R') {
            rgb[0].push_back(i);
        } else if (c == 'G') {
            rgb[1].push_back(i);
        } else {
            v[i] = true;
            cnt++;
        }
    }

    ll total = 0;

    for (auto r : rgb[0]) {
        for (auto g : rgb[1]) {
            total += cnt;
            ll top = max(r, g) + abs(r - g);
            if (top < s.size() && v[top]) total--;

            ll bottom = min(r, g) - abs(r - g);
            if (bottom >= 0 && v[bottom]) total--;

            ll middle = min(r, g) + abs(r - g) / 2;
            if (abs(r - g) % 2 == 0 && v[middle]) total--;
        }
    }

    cout << total << endl;
    return 0;
}

Measured memory_bytes: 3632
import java.util.*;

public class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        String S = sc.nextLine();
        int num = 0;
        for (int i = 0; i < S.length(); i++) {
            if (S.charAt(i) == '+') {
                num++;
            } else {
                num--;
            }
        }
        sc.close();
        System.out.println(num);
    }
}


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

using namespace std;

const int maxn = 5e5 + 7, mod = 1e9 + 7;

int f[maxn];

int pw(int a, int b)
{
    if (!b) return 1;
    int p = pw(a, b / 2);
    p = 1LL * p * p % mod;
    if (b & 1) return 1LL * p * a % mod;
    return p;
}

int main()
{
//    freopen("TEST.INP", "r", stdin);
    f[0] = 1;
    for (int i = 1; i < maxn; ++i) f[i] = 1LL * f[i - 1] * i % mod;
    int n, m;
    cin >> n >> m;
    int ans = pw(1LL * f[m] * pw(f[m - n], mod - 2) % mod, 2);
    int c = 1;
    for (int i = 1; i <= n; ++i)
    {
        c = 1LL * c * (n - i + 1) % mod;
        int pn = 1LL * c * pw(f[i], mod - 2) % mod;
        int x = 1LL * f[m] * pw(f[m - i], mod - 2) % mod;
        int y = pw(1LL * f[m - i] * pw(f[m - n], mod - 2) % mod, 2);
        int d = (1LL * pn * x % mod) * y % mod;
        if (i & 1) ans -= d;
        else ans += d;
        if (ans >= mod) ans -= mod;
        if (ans < 0) ans += mod;
    }

    cout << ans;
    return 0;
}


Measured memory_bytes: 5496
#include <bits/stdc++.h>
//#include<iostream>
//#include<vector>
//#include<map>
//#include<math.h>
//#include<algorithm>

#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rep2(i,a,n) for(int i = (int)(a); i <= (int)(n); i++)
#define rrep(i,n) for(int i = (int)(n-1); i > -1; i--)
#define rrep2(i,n,a) for(int i = (int)(n); i >= (int)(a); i--)

#define fi first
#define se second

using namespace std;

using ll = long long;
using v_int = vector<int>;
using v2_int = vector<v_int>;
using v_ll = vector<ll>;
using v2_ll = vector<v_ll>;
using v_string = vector<string>;
using v_bool = vector<bool>;
using v2_bool = vector<v_bool>;
using pii = pair<int, int>;
using mii = map<int, int>;

const double PI = 3.1415926535897932;
const int INF = (int)2e9;
const ll LINF = (ll)2e18;
const ll MOD = 1000000007;
const int dc[8] = {1, -1, 0,  0, 1, -1,  1, -1};
const int dr[8] = {0,  0, 1, -1, 1,  1, -1, -1};

template<typename T, typename U> inline
ostream& operator<<(ostream &o, pair<T,U> &p) {
    return o << "{" << p.first << "," << p.second << "}";
}
template<typename T> inline
istream& operator>>(istream &is, vector<T> &vec) {
    for(auto &v : vec) { is >> v; }
    return is;
}
template<typename T> inline
ostream& operator<<(ostream &os, vector<T> &vec) {
    for(auto &v : vec) { os << v << ",";}
    return os;
}
template<typename T> inline
ostream& operator<<(ostream &os, vector<vector<T> > &mat) {
    for(auto &row : mat) { os << row << endl; }
    return os;
}

template<typename T> inline
void chmin(T &a, T b) { a = min(a, b); }
template<typename T> inline
void chmax(T &a, T b) { a = max(a, b); }

int main(void)
{
    int a = 6;
    int x,y;
    cin >> x >> y;
    cout << a - x - y << endl;
} /*atcoder*/



Measured memory_bytes: 3612
#include <iostream>
#include <vector>
#include <utility>
#include <string>
using namespace std;

int deg_in[32];
int deg_out[32];
int edge[32][32];
bool visited[32];

int foo(int n) {
	if(visited[n])
		return 0;
	visited[n] = true;
	int res = 0;
	for(int i = 0; i < 32; i++) {
		if(i != n && edge[n][i])
			res += foo(i);
	}
	return res + 1;
}

int main() {
	int n;
	while(cin >> n, n) {
		for(int i = 0; i < 32; i++) {
			deg_in[i] = deg_out[i] = 0;
			visited[i] = true;
			for(int j = 0; j < 32; j++) {
				edge[i][j] = 0;
			}
		}

		for(int i = 0; i < n; i++) {
			string s;
			cin >> s;
			int a, b;
			a = s[0] - 'a';
			b = s[s.size()-1] - 'a';
			deg_out[a]++; deg_in[b]++;
			edge[a][b] = 1;
			visited[a] = visited[b] = false;
		}

		bool flg = true;
		for(int i = 0; i < 32; i++) {
			flg &= deg_in[i] == deg_out[i];
		}

		bool flg1 = true;
		for(int i = 0; i < 32; i++) {
			int res = foo(i);
			if(res) {
				flg &= !!res && flg1;
				flg1 = false;
			}
		}

		if(flg)
			cout << "OK" << endl;
		else
			cout << "NG" << endl;
	}
}

Measured memory_bytes: 1200