akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define ll long long int 
#define mod 1000000007
#define se second
#define fi first
#define endl "\n"
#define pi 3.1415926535897932384626433832795028841971
#define MAX 9223372036854775807
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
//	cout<<fixed<<setprecision(10);
	ll n,m;
	cin>>n>>m;
	if(m>=n)
	cout<<"unsafe";
	else 
	cout<<"safe";
	return 0;
}

Measured memory_bytes: 3672
#include <iostream>
using namespace std;
int main()
{
    int A, B;
    string S, T, U;
    cin >> S >> T>>A>>B;
    if (A>=1 && B>=1 && S.length()>=1 && T.length() >= 1 && A<=10 && B <= 10 && S.length()<=100 && T.length() <= 100){
        if (S != T){
            cin >> U;
            if (U == S)
                A -= 1;
            else if (U == T)
                B -= 1;
            cout << A << " " << B;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
	int n,mini;
	string str;
	cin >> n;
	vector<vector<int>> v(n, vector<int>(26, 0));
	for (int i = 0; i < n; i++) {
		cin >> str;
		for (auto c : str) {
			v[i][c - 'a']++;
		}
	}
	
	for (int i = 0; i < 26; i++) {
		mini = v[0][i];
		for (int j = 1; j < n; j++) {
			mini = min(mini, v[j][i]);
		}
		for (int k = 0; k < mini; k++) {
			cout << (char)(i + 'a');
		}
	}
	cout << endl;
}


Measured memory_bytes: 256
//i ll be the king
#include<bits/stdc++.h>
#define ll long long int
#define ld long double
#define sync ios_base::sync_with_stdio(false); cin.tie(NULL) 
#define input(arr,n) for(ll i1=0;i1<n;i1++ )cin>>arr[i1]
#define rep(n) for(ll i2=0;i2<n;i2++)
#define vmp(v,a,b) v.push_back(make_pair(a,b))
#define si(a) scanf("%lld",&a)
#define pi(a) printf("%lld",a)
#define aset(a,n,k) for(ll i3=0;i3<n;i3++)a[i3]=k; 	
#define mod 1000000007
#define mp(a,b) make_pair(a,b)
#define f first
#define s second 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<ll, null_type,greater_equal<ll>, rb_tree_tag,tree_order_statistics_node_update>//s.order_of_key(val) *s.find_by_orde(ind)
using namespace std;
int main()
{
	sync;
	string s;
	cin>>s;
	ll cnt=0;
	for(ll i=0;i<s.length();i++)
	if(s[i]=='o')
	cnt++;
	if(cnt+(15-s.length())>=8)
	cout<<"YES";
	else
	cout<<"NO";
}

Measured memory_bytes: 256
import itertools
n = int(input())
l = list(map(int, input().split()))
ans = 0
comb = itertools.combinations(l, 3)
for i in comb:
    if len(set(i)) == 3:
        if (i[0] + i[1]) > i[2] and (i[1] + i[2]) > i[0] and (i[2] + i[0]) > i[1]:
            ans += 1
print(ans)


Measured memory_bytes: 9036
package main

import (
	"fmt"
	"math"
)

func main() {
	var n int
	fmt.Scan(&n)
	x := make([]float64, n)
	y := make([]float64, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&x[i], &y[i])
	}

	ans := float64(0)
	for i := 0; i < n; i++ {
		sum := float64(0)
		for j := 0; j < n; j++ {
			if j == i {
				continue
			}
			sum += math.Sqrt(math.Pow(x[i]-x[j], 2) + math.Pow(y[i]-y[j], 2))
		}
		ans += sum / float64(n)
	}
	fmt.Println(ans)
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define srep(i,n,m) for(int i=n;i<m;i++)
#define elif else if
#define INF 1000000007
using namespace std;
int gcd(int a,int b){
    if(b==0) return a;
    return gcd(b,a%b);
}
int n,m,cnt=0,o,aa[220000],cntl=0,ab[220000];
pair<int,int> p[220000];
string s,ss[220000];
char c,cc[5000][5000]={};
queue<int> que;
signed main(){
    cin>>n>>m;
    srep(i,m,n+2){
        cnt+=(i*n)-(i*(i-1))+1;
        cnt%=INF;
    }
    cout<<cnt;
}

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

int main(){
    int N,M;
    cin >> N >> M;
    priority_queue<long long> q;
    for(int i =0; i < N; i++){
        int a;
        cin >> a;
        q.push(a);
    }
    for(int i =0; i < M; i++){
        int top = q.top();
        q.pop();
        q.push(top/2);
    }
    long long ans = 0;
    for(int i =0; i < N; i++){
        ans += q.top();
        q.pop();
    }
    cout << ans << endl;
}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;

 
int main() {

    string s;
    cin >> s;
    int n = s.size();
    if(s[n-1] == 's')   cout<<s<<"es"<<endl;
    else    cout<<s<<"s"<<endl;
    
 return 0;
}


Measured memory_bytes: 3616
#include<iostream>
#include<string>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cstring>
using namespace std;

int main(){
    int n;
    cin >> n;
    double a[101],b[101];
    for(int i=0;i<n;i++) cin >> a[i];
    for(int i=0;i<n;i++) cin >> b[i];
    double sum = 0;
    for(int i=0;i<n;i++){
        sum += abs(a[i]-b[i]);
    }
    printf("%.8f\n",sum);
    sum = 0;
    for(int i=0;i<n;i++){
        sum += pow(abs(a[i]-b[i]),2.0);
    }
    printf("%.8f\n",pow(sum,1/2.0));
    sum = 0;
    for(int i=0;i<n;i++){
        sum += pow(abs(a[i]-b[i]),3.0);
    }
    printf("%.8f\n",pow(sum,1/3.0));
    double maxx = -1;
    for(int i=0;i<n;i++){
        maxx = max(maxx,abs(a[i]-b[i]));
    }
    printf("%.8f\n",maxx);
}



Measured memory_bytes: 3408
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <map>
#include <time.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define pb push_back
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define dep(i, a, n) for(int i = (a); i >= (n); i--)
#define mod (ll)(1e9+7)
#define int ll

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

signed main() {
  int c[5] = {};
  rep(i, 0, 3) {
    int a, b;
    cin >> a >> b;
    c[a]++;
    c[b]++;
  }
  int ks = 0;
  rep(i, 1, 5) {
    if(c[i] == 1) ks++;
  }

  if(ks > 2) {
    cout << "NO" << endl;
  }else {
    cout << "YES" << endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h> 
using namespace std;
typedef long long ll;
template<typename T1,typename T2> bool chmin(T1 &a,T2 b){if(a<=b)return 0; a=b; return 1;}
template<typename T1,typename T2> bool chmax(T1 &a,T2 b){if(a>=b)return 0; a=b; return 1;}



signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);

    ll n;
    cin>>n;
    ll a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    map<ll,ll> mp;
    ll ans = 0;
    for(int i=0;i<n;i++){
        mp[i-a[i]]++;
    }
    for(int i=0;i<n;i++){
        mp[i-a[i]]--;
        if(mp.count(i+a[i]))ans+=mp[i+a[i]];
    }
    cout << ans << endl;
}

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

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef pair<LL, LL> PLL;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(),(c).end())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

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

  string S; cin >> S;
  int N = SZ(S);

  bool ok = true;
  for(int i=0;i<N;++i)
	switch(S[i]){
	case 'q':
	  ok &= S[N-1-i] == 'p';
	  break;
	case 'p':
	  ok &= S[N-1-i] == 'q';
	  break;
	case 'b':
	  ok &= S[N-1-i] == 'd';
	  break;
	case 'd':
	  ok &= S[N-1-i] == 'b';
	  break;
	}

  cout << (ok?"Yes":"No") << endl;

  return 0;
}


Measured memory_bytes: 512
#include <iostream>
using namespace std;
int main(){
	int N,count=0,ans=0;
	cin>>N;
	for(int i=1;i<=N;i++){
		for(int j=1;j<=i;j++){
			if(i%j==0){
				count++;
			}
		}
		if(i%2==1&&count==8){
			ans++;
		}
		count=0;
	}
	cout<<ans<<endl;
}


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

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<pdd> vdd;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mem(a,b) memset(a, b, sizeof(a) )
#define all(x) (x).begin(),(x).end()
#define INF 1000000000000
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD-2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}

int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

int main(){
    int n;cin>>n;
    vi d(n);
    map<int,int>c;
    rep(i,n){
        cin>>d[i];
        c[d[i]]++;
    }
    int m;cin>>m;
    vi t(m);
    map<int,int>s;
    rep(i,m){
        cin>>t[i];
        s[t[i]]++;
    }
    bool a=true;
    rep(i,m){
        if(c[t[i]]<s[t[i]])a=false;
    }
    if(a)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}

Measured memory_bytes: 20608
#include<bits/stdc++.h>
using namespace std;
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pl;

#define sl(x) scanf("%lld",&x)
#define pl(x) printf("%lld\n",x)
#define sz(x) ((int)x.size())
#define s(x) sort(x.begin(),x.end())
#define all(v) v.begin(),v.end()
#define rs(v) { s(v) ; r(v) ; }
#define r(v) {reverse(all(v));}
#define pb push_back
#define F first
#define S second
#define f(i,n) for(ll i=0;i<n;i++)
#define rep(i,a,b) for(int i=a;i<=b;i++)

const ll mod = 1000000007;
const ll inf = (ll)5e16;
const ld eps = 1e-12;
const ll N = 1000005;
const ll LOGN = 19;
const ld PI = 3.14159265358979323846;
ll mul(ll a, ll b, ll m = mod) { return (ll)(a * b) % m;}
ll add(ll a, ll b, ll m = mod) { a += b; if(a >= m) a -= m; if(a < 0) a += m; return a;}
ll power(ll a, ll b, ll m = mod) { if(b == 0) return 1; if(b == 1) return (a % m); ll x = power(a, b / 2, m); x = mul(x, x, m); if(b % 2) x = mul(x, a, m); return x;}
bool is(ll x)
{
    vector < ll > v;
    while(x)
    {
        v.pb(x % 10);
        x /= 10;
    }
    f(i, v.size() / 2)
    {
        if(v[i] != v[v.size() - 1 - i]) return false;
    }
    return true;
}

int main()
{
    ios_base::sync_with_stdio(0);
    ll n;
    cin >> n;
    if(is(n)) cout << "Yes\n";
    else cout << "No\n";
    return 0;
}


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

int main()
{
	int H, W;
	while(1){
		cin >> H >> W;
		if (H == 0 && W == 0)
			break;
		else {
			for (int i = 0; i < H; ++i) {
				for (int j = 0; j < W; ++j) {
					cout << '#';
				}
				cout << endl;
			}
		}
		cout << endl;
	}
    return 0;
}



Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9+7;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(obj) (obj).begin(), (obj).end()

int main(){
    ll A, B, ans = 0;
    cin >> A >> B;
    if(A % 2 == 0){
        switch((B - A) % 4){
            case 0:
                ans = B;
                break;
            case 1:
                ans = 1;
                break;
            case 2:
                ans = 1 ^ B;
                break;
            case 3:
                ans = 0;
                break;
        }
    }else{
        switch((B - A) % 4){
            case 0:
                ans = A;
                break;
            case 1:
                ans = A ^ B;
                break;
            case 2:
                ans = A ^ 1;
                break;
            case 3:
                ans = A ^ 1 ^ B;
                break;
        }
    }
    printf("%lld\n\r", ans);
}


Measured memory_bytes: 256
from collections import deque


def solve():
    h, w = map(int, input().split())
    a = [input() for _ in range(h)]

    q = deque()

    arrived = [[True] * (w + 2)] + \
              [[True] + [False] * w + [True] for _ in range(h)] + \
              [[True] * (w + 2)]

    for i in range(h):
        for j in range(w):
            if a[i][j] == "#":
                q.append((i+1, j+1))
                arrived[i+1][j+1] = True

    ans = 0
    while q:
        ans += 1
        pop_max = len(q)
        cnt = 0
        while cnt != pop_max:
            i, j = q.popleft()
            if not arrived[i-1][j]:
                arrived[i-1][j] = True
                q.append((i-1, j))

            if not arrived[i+1][j]:
                arrived[i+1][j] = True
                q.append((i+1, j))

            if not arrived[i][j-1]:
                arrived[i][j-1] = True
                q.append((i, j-1))

            if not arrived[i][j+1]:
                arrived[i][j+1] = True
                q.append((i, j+1))

            cnt += 1

    ans -= 1
    print(ans)


def main():
    solve()


if __name__ == "__main__":
    main()


Measured memory_bytes: 131412
import math

a, b, x = map(float, input().split())

h = x / a**2.0

if x <= a**2 * b / 2.0:
    theta = math.atan((a*b**2.0)/(2.0*x))
else:
    theta = math.atan(2.0*(b-h)/a)

print(math.degrees(theta))


Measured memory_bytes: 3060
#!/usr/bin/env python
# -*- coding: utf-8 -*-

def solve():
    n = int(input())
    s = input()
    el, wl = [0]*n, [0]*n
    ec, wc = 0, 0
    for i in range(n):
        if s[n - 1 - i] == 'E':
            ec += 1
        if s[i] == 'W':
            wc += 1
        el[n - 1 - i] = ec
        wl[i] = wc

    ans = n - 1
    for i in range(n):
        if i == 0:
            ans = min(ans, el[i + 1])
        elif i == n - 1:
            ans = min(ans, wl[i - 1])
        else:
            ans = min(ans, wl[i - 1] + el[i + 1])
    print(max(0, ans))

if __name__=="__main__":
    solve()


Measured memory_bytes: 46556
N = int(input())
A = list(map(int,input().split()))
res = 0
SUM = 0
right = 0
for left in range(N):
    while right < N and (SUM ^ A[right]) == (SUM + A[right]):
        SUM += A[right]
        right += 1
    res += right -left
    if left==right:
        right += 1
    else:
        SUM -= A[left]
print(res)

Measured memory_bytes: 77772
n, k = map(int, input().split())
A = list(map(lambda x: int(x) - 1, input().split()))
prev = 0
count = 0
used = {prev: count}
for _ in range(min(k, n)):
  prev = A[prev]
  count += 1
  if prev in used:
    for _ in range((k - used[prev]) % (count - used[prev])):
      prev = A[prev]
    break
  used[prev] = count
print(prev + 1)

Measured memory_bytes: 32232
// dfmt off
T lread(T=long)(){return readln.chomp.to!T;}T[] lreads(T=long)(long n){return iota(n).map!((_)=>lread!T).array;}
T[] aryread(T=long)(){return readln.split.to!(T[]);}void arywrite(T)(T a){a.map!text.join(' ').writeln;}
void scan(L...)(ref L A){auto l=readln.split;foreach(i,T;L){A[i]=l[i].to!T;}}alias sread=()=>readln.chomp();
void dprint(L...)(lazy L A){debug{auto l=new string[](L.length);static foreach(i,a;A)l[i]=a.text;arywrite(l);}}
static immutable MOD=10^^9+7;alias PQueue(T,alias l="b<a")=BinaryHeap!(Array!T,l);import std, core.bitop;
// dfmt on

void main()
{
    long N = lread();
    auto A = lreads(N);
    auto dp = new long[][](2, N + 1);
    dp[0][] = dp[1][] = long.min;
    dp[0][0] = 0;

    foreach (i; 0 .. N)
    {
        dprint(dp[0][i], dp[1][i]);
        if (dp[1][i] != long.min)
        {
            long a = A[i] + 1;
            long r = (a < 2) ? 0 : a % 2;
            dp[r][i + 1] = dp[r][i + 1].max(dp[1][i] + a / 2);
        }
        if (dp[1][i] != long.min)
        {
            long a = A[i];
            long r = (a < 2) ? 0 : a % 2;
            dp[r][i + 1] = dp[r][i + 1].max(dp[1][i] + a / 2);
        }
        if (dp[0][i] != long.min)
        {
            long a = A[i];
            long r = (a < 2) ? 0 : a % 2;
            dp[r][i + 1] = dp[r][i + 1].max(dp[0][i] + a / 2);
        }
    }
    writeln(max(dp[0][N], dp[1][N]));
}


Measured memory_bytes: 6936
import java.util.Scanner;


public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int H;
		int W;
		
		while (true) {
			H = sc.nextInt();
			W = sc.nextInt();
			
			//0 0?????????
			if (H ==0 && W ==0) {
				break;
			}
			
			//????????¢???????????????
			for (int i = 0; i < H; i++) {
				for (int j = 0; j < W; j++) {
					//??????????????????
					if(i==0 || i==H-1 || j==0 || j==W-1){
						System.out.print('#');
					}
					else {
						System.out.print('.');
					}
				}
				//?¬??????????????????????
				System.out.println();
			}
			//???????????????????????????
			System.out.println();
		}
	}
}

Measured memory_bytes: 26736
import sys
input = sys.stdin.readline
 
 
def main():
    n,a,b = [int(i) for i in input().strip().split()]
    if (b-a) % 2 == 0:
        print(abs(b - a) // 2)
    else:
        ans = min(a - 1, n - b) + 1 + (b - a - 1) // 2
        print(ans)
    return 
 
 
 
if __name__ == "__main__":
    main()

Measured memory_bytes: 61188
#include <iostream>
#include <string>
#include <algorithm>
#include <ctime>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cassert>
#include <bitset>
#include <list>
#include <cstdio>
#include <stdio.h>
#include <string.h>
#include <cmath>

typedef long long ll;

using namespace std;

ll gcd(ll a, ll b)
{
    if((a%b) == 0) return b;
    else return gcd(b, a%b);
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b;
    cin >> a >> b;
    if(a<10 && b<10) cout << a*b;
    else cout << -1;
}


Measured memory_bytes: 256
import math
    
K = int(input())

sum = 0
dict = {}
for a in range(K):
	for b in range(K):
		ab = math.gcd(a+1, b+1)
		if ab in dict:
			dict[ab] = dict[ab]+1 
		else:
			dict[ab] = 1
for c in range(K):
	for ab in dict:
		sum += math.gcd(ab, c+1)*dict[ab]
print(sum)
	

Measured memory_bytes: 9136
#include <bits/stdc++.h>
#include <cmath>
using namespace std;
typedef long long ll;

int main(){
    int n;
    ll hai[87];

    cin >> n;
    hai[0] = 2;
    hai[1] = 1;

    for(int i = 2; i<=n; i++){
        hai[i] = hai[i - 2] + hai[i - 1];
    }

    cout << hai[n] << endl;



}


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


int main() {
    int A, B;
    cin >> A >> B;
    xrep(i, 1, 10000) {
        if((int)(i*0.08)==A && (int)(i*0.1)==B) {
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;



    return 0;
}

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

int main()
{
    string s;
    cin >> s;
    int len = s.length();
    int ans = 700;
    for (int i=0; i<len; i++)
    {
        if (s[i] == 'o') ans += 100;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <numeric>
using namespace std;
#define ll long long
#define mod107 1000000007
#define rep(i, n) for (int i = 0; i < n; ++i)
using Graph = vector<vector<int>>;
#define grepq priority_queue<double, std::vector<double>, std::greater<double>>
#define all(v) v.begin(), v.end()
#define PI acos(-1)

const ll INF = 10010001010;
const int inf = 1000034000;
typedef vector<ll> vecl;
typedef vector<int> veci;
typedef tuple<string, int, int> TUP;

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

vector<pair<long long, long long>> prime_factorize(long long N)
{
    vector<pair<long long, long long>> res;
    for (long long a = 2; a * a <= N; ++a)
    {
        if (N % a != 0)
            continue;
        long long ex = 0; // 指数

        // 割れる限り割り続ける
        while (N % a == 0)
        {
            ++ex;
            N /= a;
        }

        // その結果を push
        res.push_back({a, ex});
    }

    // 最後に残った数について
    if (N != 1)
        res.push_back({N, 1});
    return res;
}

int main()
{
    int X;
    cin >> X;
    int K = 1;
    while(1){
        if(X*K %360== 0){
            break;
        }
        K++;
    }
    cout << K << endl;
}


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

using namespace std;

typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = (ll)1e9 + 7;

int main()
{
  vector<string> S(3);
  vector<int> N3(3);
  for (int i = 0; i < 3; ++i) {
    cin >> S[i];
    N3[i] = S[i].size();
  }
  vector<int> indices = { 0, 0, 0 };
  int turn = 0;
  while (true) {
    if (indices[turn] >= N3[turn]) { break; }
    char ch = S[turn][indices[turn]];
    ++indices[turn];
    if (ch == 'a') { turn = 0; }
    else if (ch == 'b') { turn = 1; }
    else if (ch == 'c') { turn = 2; }
  }
  vector<char> P = { 'A', 'B', 'C' };
  char ans = P[turn];
  printf("%c\n", ans);
  return 0;
}


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

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

    ll ans = 0;
    for (int i = 0; i < N; i++)
    {
        ll a;
        cin >> a;
        while (a % 2 == 0)
        {
            ans++;
            a /= 2;
        }
        
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>


int main(void){
	int n;
	int i;
	int a,b;
	int count = 1;

	scanf("%d",&n);
		a = n%10;
		n = n/10;

	for(i=1;i<4;i++){
		b = n%10;
		if (a == b){
			count++;
		}
		else if(count ==3){
			break;
		}

		else{
			count = 1;
		}
			a = b;
		n = n/10;

	}
	if(count >= 3){
//		printf("%d",count);
		printf("Yes\n");
	}
	else{
//		printf("%d",count);
		printf("No\n");
	}
	getchar();
	getchar();
	getchar();
	getchar();

	return(0);
}


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

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	string s; cin >> s;
	long long c = 0, ans = 0;
	for (int i = s.length() - 1; i >= 0; i--) {
		if (s[i] == 'B')
			ans += c;
		else
			c++;
	}
	cout << ans << '\n';
	return 0;
}

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

using namespace std;

void solve(long N, long M, vector<long> H, vector<long> A, vector<long> B) {
  vector<vector<long>> ith_road(N);

  rep(j, M) {
    ith_road[A[j] - 1].emplace_back(j);
    ith_road[B[j] - 1].emplace_back(j);
  }

  long ans = 0;
  rep(i, N) {
    vector<long>& roads = ith_road[i];
    if (!roads.size()) {
      ans++;
      continue;
    }
      
    const long hight = H[i];
    bool highest = true;
    rep(k, roads.size()) {
      const long j = roads[k];
      long neighbor;
      if (A[j] == i + 1)
	neighbor = B[j] - 1;
      else
	neighbor = A[j] - 1;
      if (H[neighbor] >= hight)
	highest = false;
    }
    if (highest)
      ans++;
  }
  cout << ans << endl;
}

int main(){
  // int 3E4  long 2E9  ll 9E18
  cin.tie(0);
  ios::sync_with_stdio(false);

  long N, M;
  cin >> N >> M;
  vector<long> H(N);
  for(int i = 0 ; i < N ; i++)
    cin >> H[i];

  vector<long> A(M);
  vector<long> B(M);
  for(int i = 0 ; i < M ; i++)
    cin >> A[i] >> B[i];

  solve(N, M, move(H), move(A), move(B));

  return 0;
}


Measured memory_bytes: 11336
N, K = map(int, input().split())
h = [int(input()) for i in range(N)]

h.sort()
min_diff = 10 ** 10
for i in range(N - K + 1):
    diff = h[i + K - 1] - h[i]
    if diff < min_diff:
        min_diff = diff
print(min_diff)

Measured memory_bytes: 7384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,a,b) for(ll i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()

int main(void){
    ll l;
    cin >> l;

    vector<pair<ll, ll>> path[60];
    ll current_num = 2;
    ll last_v = 1;
    ll path_num = 2;
    path[0].push_back(pair<ll, ll>(1,0));
    path[0].push_back(pair<ll, ll>(1,1));

    ll tmp = l;
    vector<ll> seq;
    seq.push_back(tmp);
    if(tmp % 2 == 1){
        tmp--;
        seq.push_back(tmp);
    }
    while(tmp != 2){
        tmp /= 2;
        seq.push_back(tmp);
        if(tmp % 2 == 1){
            tmp--;
            seq.push_back(tmp);
        }
    }

    rrep(x, seq.size()-2, 0){
        if(current_num == seq[x] / 2.0){
            current_num *= 2;
            rep(i, 0, 60){
                fore(a, path[i]){
                    a.second *= 2;
                }
            }
            path[last_v].push_back(pair<ll, ll>(last_v + 1,0));
            path[last_v].push_back(pair<ll, ll>(last_v + 1,1));
            last_v++;
            path_num += 2;
        }else{
            current_num++;
            path[0].push_back(pair<ll, ll>(last_v, current_num - 1));
            path_num++;
        }
    }

    cout << last_v + 1 << " " << path_num << endl;
    rep(i, 0, 60){
        fore(a, path[i]){
            cout << i + 1 << " " << a.first + 1 << " " << a.second << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <vector>

using namespace std;

int p[5010],c[5010];
bool flag[5010];

long long check_max0(vector<int> &c, int size, int len){
  long long ans = 0;
  for (int i=0; i<size; ++i){
    long long tmp = 0;
    for (int j=0; j<len; ++j){
      tmp += c[(i+j)%size];
      if (tmp > ans) ans = tmp;
    }
  }
  return ans;
}

long long check_max1(vector<int> &c, int size, int len){
  long long ans = c[0];
  for (int i=0; i<size; ++i){
    long long tmp = 0;
    for (int j=0; j<len; ++j){
      tmp += c[(i+j)%size];
      if (tmp > ans) ans = tmp;
    }
  }
  return ans;
}

int main(){
  int n, k;
  scanf("%d%d",&n,&k);
  for (int i=1;i<=n;++i)
    scanf("%d",&p[i]);
  for (int i=1;i<=n;++i)
    scanf("%d",&c[i]);
  for (int i=1;i<=n;++i)
    flag[i] = true;

  long long ans = c[1];

  for (int i=1; i<=n; ++i){
    if (flag[i]){
      vector<int> _c;
      int now = i;
      while( flag[now] ){
        _c.push_back( c[now] );
        flag[now] = false;
        now = p[now];
      }
      int len = _c.size();
      long long sum = 0;
      for (int _i=0; _i<len; ++_i)
        sum += _c[_i];

      if ( k>=len ){
        long long tmp_ans = sum * ( k / len ) + check_max0(_c, len, k%len);
        if (tmp_ans > ans ) ans = tmp_ans;
        
        tmp_ans = sum * ( k / len -1 ) + check_max1(_c, len, len);
        if (tmp_ans > ans ) ans = tmp_ans;
      }
      long long tmp_ans = check_max1(_c, len, min( len, k ));
      if (tmp_ans > ans ) ans = tmp_ans;
      //printf("a %d %d\n",i, tmp_ans);
    }
  }
  printf("%lld\n",ans);

}


Measured memory_bytes: 3324
#include <stdio.h>
int main(){
  int N,a,i,j,k,count=0;
  int A[100];
  int flag;
  
  scanf("%d",&N);
  for(i=0;i<N;i++){
    scanf("%d",&A[i]);
  }
  flag=1;
  while(flag){
    flag=0;
    for(j=N-1;j>=1;j--){
      if(A[j] < A[j-1]){
	a=A[j];
	A[j]=A[j-1];
	A[j-1]=a;
	flag=1;
      count++;
      }
    }
    }
  for(k=0;k<N;k++){
    printf("%d",A[k]);
    if(k<N-1)printf(" ");
  }
  printf("\n");
  printf("%d\n",count);
}



Measured memory_bytes: 2104
#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;i++)
using namespace std;
 
int main() {
    int n;
    while (scanf("%d", &n), n) {
        unordered_map<string, int>mp;
        string s; int Max = 0;
        int d = 0;
        for (int i = 1; i <= n; i++) {
            string c; cin >> c;
            mp[c]++;
            if (mp[c] > Max) { s = c; Max = mp[c]; }
            int sec = 0;
            for (auto&& p : mp) {
                if (p.first != s&&sec < p.second) sec = p.second;
            }
            if (sec + n - i < Max && !d)d = i;
        }
        if (!d)puts("TIE");
        else cout << s << ' ' << d << endl;
    }
}

Measured memory_bytes: 3204
#include<iostream>
using namespace std;
int n,b,f,r,v,i,j,k,room[4][3][10];
int main(void){
  cin>>n;
  for(i=0;i<n;i++){
    cin>>b>>f>>r>>v;
    room[b-1][f-1][r-1]+=v;
  }
  for(i=0;i<4;i++){
    for(j=0;j<3;j++){
      for(k=0;k<10;k++){
        cout<<" "<<room[i][j][k];
      }
      cout<<endl;
    }
    if(i!=3)cout<<"####################"<<endl;
  }
  return 0;
}



Measured memory_bytes: 3092
import java.util.*;
public class Main{

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int t=sc.nextInt();
		int a[]=new int[n];
		int d[]=new int[n];
		for(int i=0;i<n;i++){
			a[i]=sc.nextInt();
		}
		d[n-1]=a[n-1];
		for(int i=n-1;i>=1;i--){
			if(a[i-1]>d[i]){
				d[i-1]=a[i-1];
			}else{
				d[i-1]=d[i];
			}
		}
		
		int count=0;
		int max=0;
		for(int i=0;i<n;i++){
			int p=d[i]-a[i];
			max=Math.max(max, p);
			//System.out.println(p);
		}
		for(int i=0;i<n;i++){
			int p=d[i]-a[i];
			if(p==max){
				count++;
			}
		}
		
		
		//System.out.println(Arrays.toString(d));
		System.out.println(count);
	}

}

Measured memory_bytes: 51804
#include <cstdio>
#include<bits/stdc++.h> 
#define pb          push_back 
#define endl        "\n"
#define mostrar(x,y) cout<<x<<" "<<y<<endl;
#define f           first
#define s           second
using namespace std;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<pair<int,int>> vii;
typedef pair<pair<int,int>,int> iii;

set<string> mesesValidos;

bool isYYMM(string &cad){
    string b = cad.substr(2,2);
    if(mesesValidos.find(b)==mesesValidos.end()){
        return false;
    }
    else{
        return true;
    }
}
bool isMMYY(string &cad){
    string b = cad.substr(0,2);
    if(mesesValidos.find(b)==mesesValidos.end()){
        return false;
    }
    else{
        return true;
    }   
}

int main(){
    ofstream out("output.txt");

    string num;
    cin>>num;
    mesesValidos.insert("01");
    mesesValidos.insert("02");
    mesesValidos.insert("03");
    mesesValidos.insert("04");
    mesesValidos.insert("05");
    mesesValidos.insert("06");
    mesesValidos.insert("07");
    mesesValidos.insert("08");
    mesesValidos.insert("09");
    mesesValidos.insert("10");
    mesesValidos.insert("11");
    mesesValidos.insert("12");
    if(isYYMM(num)){
        if(isMMYY(num)){
            cout<<"AMBIGUOUS\n";
        }
        else{
            cout<<"YYMM\n";
        }
    }
    else if(isMMYY(num)){
        if(isYYMM(num)){
            cout<<"AMBIGUOUS\n";   
        }
        else{
            cout<<"MMYY\n";
        }
    }
    else{
        cout<<"NA\n";
    }



    return 0;
}


Measured memory_bytes: 256
<?php
fscanf(STDIN,"%d%d",$n,$m);
$re=array();
$re=array_fill(1,$n,0);
for($i=1;$i<=$m;$i++){
 $ab=explode(" ",trim(fgets(STDIN)));
 $re[$ab[0]]++;
 $re[$ab[1]]++;
}

foreach($re as $val){
  echo $val."\n";
}




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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define _GLIBCXX_DEBUG

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vd = vector<double>;
using vvi = vector<vi>;
using vvll = vector<vll>;
using vvd = vector<vd>;
using vvvi = vector<vvi>;
using vvvll = vector<vvll>;
using vvvd = vector<vvd>;

const double pi=acos(-1);
const ll MOD=1e9+7;

const int MAX = 510000;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

//使う前にCOMinit
//最大に注意！！！！！！！！！！！！！！！

int main() {
    ll n,k;
    cin>>n>>k;
    ll ans=0;
    ll low=0,high=0;
    for (int i=0;i<k;i++){
        low+=i;
        high+=n-i;
    }
    ans+=high-low+1;
    for (int i=k;i<n+1;i++){
        low+=i;
        high+=n-i;
        ans+=high-low+1;
        ans%=MOD;
    }
    cout<<ans<<endl;





    /*ll now=1;
    rep(i,100){
        now*=10;
        now%=MOD;
    }
    ll s=((n+(n+1))/2+now*100)%MOD;
    COMinit();
    ll m=0;
    for (int i=k-1;k<n+1;k++){
        m+=COM(n,i);
        m%=MOD;
    }
    cout<<(s*m)%MOD<<endl;*/



    return 0;
}

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

#define FOR(i, m, n) for(int i = m;i < n;i++)
#define ll long long
const ll mod = 1e9+7;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n;
	cin >> n;
	ll ans = 1;
	FOR(i, 1, n+1){
		ans *= i;
		ans %= mod;
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
<?php
$map[] = ints();
$map[] = ints();
$map[] = ints();
$n = int();
for($i = 0; $i < $n; $i++){
    $k = int();
    for($y = 0; $y < 3; $y++){
        for($x = 0; $x < 3; $x++){
            if($map[$y][$x] == $k){
                $map[$y][$x] = 0;
            }
        }
    }
}
$flag = false;
for($i = 0; $i < 3; $i++){
    $flag += ($map[$i][0]+$map[$i][1]+$map[$i][2]) == 0;
    $flag += ($map[0][$i]+$map[1][$i]+$map[2][$i]) == 0;
}
$flag += ($map[0][0] + $map[1][1] + $map[2][2] == 0); 
$flag += ($map[0][2] + $map[1][1] + $map[2][0] == 0); 
echo $flag ? "Yes" : "No";
function str(){
  return trim(fgets(STDIN));
}
function ints(){
  return array_map("intval", explode(" ", trim(fgets(STDIN))));
}
function int(){
  return intval(trim(fgets(STDIN)));
}
function chmax(&$a,$b){if($a<$b){$a=$b;return 1;}return 0;}
function chmin(&$a,$b){if($a>$b){$a=$b;return 1;}return 0;}

function o(...$val){
    if(count($val)==1)$val = array_shift($val);
    $trace = debug_backtrace();
    echo $trace[0]['line'].")";
    if(is_array($val)){
        if(count($val) == 0){
            echo "empty array";
        }elseif(!is_array(current($val))){
            echo "array: ";
            echo implode(" ", addIndex($val))."\n";
        }else{
            echo "array:array\n";
            if(isCleanArray($val)){
                foreach($val as $row)echo implode(" ", addIndex($row))."\n";
            }else{
                foreach($val as $i => $row)echo "[".$i."] ".implode(" ", addIndex($row))."\n";
            }
        }
    }else{
        echo $val."\n";
    }
}
function addIndex($val){
    if(!isCleanArray($val)){
        $val = array_map(function($k, $v){return $k.":".$v;}, array_keys($val), $val);
    }
    return $val;
}
function isCleanArray($array){
    $clean = true;
    $i = 0;
    foreach($array as $k => $v){
        if($k != $i++)$clean = false;
    }
    return $clean;
}
/**
 * 座圧対象の配列を渡すと以下の値を返す
 * ・圧縮された配列
 * ・復元用のMap
 * ・圧縮用のMap
 **/
function atsu($array){
    $a = array_flip($array);
    $fuku = array_flip($a);
    sort($fuku);
    $atsu = array_flip($fuku);
    foreach($array as $i => $val)$array[$i] = $atsu[$val];
    return [$array, $fuku, $atsu];
}
//配列の最大公約数
function gcdAll($array){
    $gcd = $array[0];
    for($i = 1; $i < count($array); $i++){
        $gcd = gcd($gcd, $array[$i]);
    }
    return $gcd;
}

//最大公約数
function gcd($m, $n){
    if(!$n)return $m;
    return gcd($n, $m % $n);
}

//配列の最小公倍数
function lcmAll($array){
    $lcm = $array[0];
    for($i = 1; $i < count($array); $i++){
        $lcm = lcm($lcm, $array[$i]);
    }
    return $lcm;
}

//最小公倍数
function lcm($a, $b) {
    return $a / gcd($a, $b) * $b;
}
//ビットカウント-1の数を数える
function popcount($x){
    $con = 0;
    while ($x) {
        $x &= $x-1;
        ++$con;
    }
    return $con;
}


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

int main(){
    int N;
    cin >> N;
    string s;
    cin >> s;
    int ret = 0;
    for(size_t i = 0; i < N; i++)
    {
        if (s[i] == 'R')
            ret++;
    }
    if(ret > N/2)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
h,w=map(int,input().split())
l=[[1 if i=='.' else 0 for i in input()] for _ in range(h)]
for i in range(w):
    if l[0][i]==0:
        for j in range(i+1,w):
            l[0][j]=0
        break
for i in range(h):
    if l[i][0]==0:
        for j in range(i+1,h):
            l[j][0]=0
        break
for i in range(1,h):
    for j in range(1,w):
        if l[i][j]!=0:
            l[i][j]=l[i-1][j]+l[i][j-1]
print(l[h-1][w-1]%(10**9+7))


Measured memory_bytes: 157264
/*

参考にした提出
https://agc023.contest.atcoder.jp/submissions/2435072

*/


#include<cstddef>
#include<cstdint>
#include<cstdio>

using uint64 = std::uint_fast64_t;

constexpr uint64 M = 1000000007;

template<std::size_t N>
struct Fact {
	uint64 val[N], v2[N];
	constexpr Fact() :val(), v2() {
		val[0] = 1;
		for (std::size_t i = 1; i < N; ++i) val[i] = val[i - 1] * i % M;
		for (std::size_t i = 1; i < N; ++i) v2[i] = val[i - 1] * val[i] % M;
		for (std::size_t i = 1; i < N; ++i) val[i] = val[i] * i % M;
	}
};

template<std::size_t N, uint64 F>
struct IFact {
	uint64 val[N];
	constexpr IFact() : val() {
		val[N - 1] = F;
		for (std::size_t i = N - 1; i; --i) val[i - 1] = val[i] * i % M;
	}
};

constexpr auto fact = Fact<1000000>();
constexpr auto ifact = IFact<1000000, 498215386>();

int main() {
	unsigned int n;
	uint64 ans;
	scanf("%u", &n);
	const std::size_t N = n;
	for (std::size_t i = (N + 1) >> 1; i < N - 1; ++i) {
		ans += fact.v2[i] * ifact.val[(i << 1) - N] % M;
	}
	ans %= M;
	long long unsigned int o = fact.val[N - 1] < ans ? fact.val[N - 1] + M - ans : fact.val[N - 1] - ans;
	printf("%llu\n", o);
	return 0;
}


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

#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define repp(i, n, m) for(int (i) = (n); (i) < (m); (i)++)
#define repn(i, n) for(int (i) = 1; (i) <= (n); (i)++)
#define repr(i, n) for(int (i) = (n-1); (i) >= 0; (i)--)
#define all(x) (x).begin(), (x).end()
#define lint long long
#define ulint unsigned long long
#define ldou long double
#define fi first
#define se second
#define setpre(x) std::cout << fixed << setprecision(x)
#define ii(x) int x; cin >> (x)
#define ii2(x, y) int x, y; cin >> (x) >> (y)
#define ii3(x, y, z) int x, y, z; cin >> (x) >> (y) >> (z)
#define out(x) cout << (x) << endl
#define outs(x) cout << (x) << " "
#define yn(x) cout << ((x)?("Yes"):("No")) << endl
#define YN(x) cout << ((x)?("YES"):("NO")) << endl
#define bit_c(x) __builtin_popcountll(x)

inline void logger(){ std::cout << " [LOGGER] " << endl; }
template<typename A, typename... B>
void logger(const A& a, const B&... b){
    cout << a << " , "; logger(b...);
}

typedef pair<lint, lint> P;
const lint MOD = 1000000007;
const lint MOD9 = 998244353;
const lint INF = MOD * MOD;
const int MAX = 2000005;

/* ...o(^-^)o... */

int main(){
    lint n; cin >> n; lint ans = 0;
    repn(k, n){
        lint l = n / k;
        ans += k*(l*(l+1)/2);
    }
    out(ans);
}

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

typedef long long int ll;
ll MOD = 1000000007;
ll INFL = 1ll << 60;
ll INF = 1 << 28;

// ====================================================================

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

  int a = 0, b = 0;
  for (int i = 0; i < s.size(); i++) {
    if (i % 2 == 0) {
      if (s[i] != '0')
        a++;
    } else {
      if (s[i] != '1')
        a++;
    }
  }

  for (int i = 0; i < s.size(); i++) {
    if (i % 2 == 0) {
      if (s[i] != '1')
        b++;
    } else {
      if (s[i] != '0')
        b++;
    }
  }

  cout << min(a, b) << endl;
}


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

int main() {
	int N;
	cin >> N;
	vector<int> Nums(1000001,0);
	for (int i = 0; i < N; i++) {
		int A;
		cin >> A;
		Nums[A]++;
	}
	int ans = 0;
	for (int i = 1; i <= 1000000; i++) {
		if (Nums[i] >= 1) {
			if (Nums[i]==1) ans++;
			int k = i * 2;
			while (k <= 1000000) {
				Nums[k] = 0;
				k += i;
			}
		}
	}
	cout << ans << endl;

}

Measured memory_bytes: 7216
def calc(n):
  dic={0:0,1:3,2:5,3:7}
  ret=0
  for j in range(9):
    ret+=dic[n%4]*(10**j)
    n-=n%4
    n//=4
    if n==0:
      return ret

def check(n):
  cnt=[0]*10
  for c in str(n):
    cnt[int(c)]+=1
  if cnt[0]==0 and cnt[3]>=1 and cnt[5]>=1 and cnt[7]>=1:
    return True
  else:
    return False

n=int(input())
arr=[]
for i in range(4**9):
  tmp=calc(i)
  if check(tmp)==True:
    arr.append(tmp)
arr=sorted(arr)
for i in range(len(arr)):
  if arr[i]>n:
    print(i)
    break
else:
  print(len(arr))

Measured memory_bytes: 44252
using System;

namespace CA { 
    class Program {
        static void Main(string[] args) {
			string[] str = Console.ReadLine().Split(' ');
			int a = int.Parse(str[0]), b = int.Parse(str[1]);
			Console.WriteLine("{0} {1} {2}", a / b, a % b, (decimal)a / b);
        }
    }
}

Measured memory_bytes: 9188
import java.io.*;
import java.math.*;
import java.util.*;

public class Main {
    private static boolean debug = false;
    private static boolean elapsed = false;

    private static PrintWriter _out = new PrintWriter(System.out);
    private static PrintWriter _err = new PrintWriter(System.err);

    private static final int INF = Integer.MAX_VALUE / 2;

    private void solve(Scanner sc) {
        int r = sc.nextInt();
        if (r < 1200) {
            _out.println("ABC");
        } else if (r < 2800) {
            _out.println("ARC");
        } else {
            _out.println("AGC");
        }
    }
    private static BigInteger C(long n, long r) {
        BigInteger res = BigInteger.ONE;
        for (long i = n; i > n - r; --i) {
            res = res.multiply(BigInteger.valueOf(i));
        }
        for (long i = r; i > 1; --i) {
            res = res.divide(BigInteger.valueOf(i));
        }
        return res;
    }
    private static BigInteger P(long n, long r) {
        BigInteger res = BigInteger.ONE;
        for (long i = n; i > n - r; --i) {
            res = res.multiply(BigInteger.valueOf(i));
        }
        return res;
    }
    /*
     * 10^10 > Integer.MAX_VALUE = 2147483647 > 10^9
     * 10^19 > Long.MAX_VALUE = 9223372036854775807L > 10^18
     */
    public static void main(String[] args) {
        long S = System.currentTimeMillis();

        Scanner sc = new Scanner(System.in);
        new Main().solve(sc);
        _out.flush();

        long G = System.currentTimeMillis();
        if (elapsed) {
            _err.println((G - S) + "ms");
        }
        _err.flush();
    }
}

Measured memory_bytes: 21844
#include <stdio.h>
int main(void){
	int N;
    scanf("%d", &N);
    if(N >= 82){
		printf("No");
	}else if(N <= 9){
    	printf("Yes");
    }else{
    	for(int i = 2; i <= 9; i++){
			int j = N % i, k = N / i;
            if(j == 0 && k <10){
            	printf("Yes");
            	break;
            }
            if(i == 9){
            	printf("No");
            }
            
		}
	}
    return 0;
}


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

ll i;
ll num;
double ans;
ll A,B,N;
ll jpy[1000];
float 	bit[1000];
float money;
string S,T;

int main()
{
	cin>>N;
	for(i=0;i<N;i++){
		cin>>money;
		cin>>S;
		if(S=="JPY") ans+=(money*1.0);
		else ans+=(money*380000.0);

	}
	printf("%lf",ans);
}


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

W, H, N = list(map(int, input().split()))
minX = 0
maxX = W
minY = 0
maxY = H

def calc():
    if maxX < minX or maxY < minY:
        return 0
    return (maxX - minX) * (maxY - minY)

for i in range(N):
    x, y, a = list(map(int, input().split()))
    if a is 1:
        if minX < x:
            minX = x
    elif a is 2:
        if maxX > x:
            maxX = x
    elif a is 3:
        if minY < y:
            minY = y
    elif a is 4:
        if maxY > y:
            maxY = y

print(calc())


Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int day = sc.nextInt();

		int before = sc.nextInt();

		int after = sc.nextInt();

		if((after - before) <= 0) {
			System.out.println("delicious");
		}else if((after - before) >= (day+1)){
			System.out.println("dangerous");
		}else{
			System.out.println("safe");
		}



	}

}


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

using namespace std;

typedef long long ll;

int main() {
  int r,D,x;
  cin>>r>>D>>x;
  for (int i = 0; i < 10; i++) {
    int res = r * x - D;
    cout<<res<<endl;
    x = res;
  }
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#define rep(i, start, end) for (int i = (int)start; i < (int)end; ++i)
#define rrep(i, start, end) for (int i = (int)start - 1; i >= end; --i)
#define iter(i, c) for (auto i = (c).begin(); i != (c).end(); ++i)
#define riter(i, c) for (auto i = (c).rbegin(); i != (c).rend(); ++i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
using namespace std;
using ll = long long;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N, M, V, P;
    cin >> N >> M >> V >> P;
    vector<ll> A(N);
    rep(i, 0, N) cin >> A[i];
    sort(all(A));
    reverse(all(A));
    int l = 1, r = N + 1;
    while (r - l > 1) {
        int mid = (l + r) / 2;
        if (mid <= P) {
            l = mid;
            continue;
        }
        if (A[mid - 1] + M < A[P - 1]) {
            r = mid;
            continue;
        }
        ll cnt = 0;
        rep(i, 0, N) {
            if (i < P - 1 || i >= mid - 1) {
                cnt += M;
            }
            else {
                cnt += max(A[mid - 1] + M - A[i], 0LL);
            }
        }
        if (cnt >= M * V) {
            l = mid;
        }
        else {
            r = mid;
        }
    }
    cout << l << endl;
    return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner

fun main(args:Array<String>){
    val scanner=Scanner(System.`in`)

    val a=scanner.nextInt()

    val b=a%4
    val c=a%7

    if (b==0) println("Yes")
    else if (c==0) println("Yes")
    else if (b==1) {
        if (a>=21) println("Yes")
        else println("No")
    }
    else if (b==2){
        if (a>=14) println("Yes")
        else println("No")
    }
    else{
        if (a>=7) println("Yes")
        else println("No")
    }
}

Measured memory_bytes: 31400