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

using namespace std;

typedef long long ll;

const ll MOD = 1000000007;

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int n, m; cin >> n >> m;
    // ball num, has red ball
    pair<int, bool> p[n];
    for(int i=0;i<n;i++){
        p[i] = make_pair(1, false);
    }
    p[0] = make_pair(1, true);
    for(int i=0;i<m;i++){
        int x, y; cin >> x >> y;
        x--; y--;
        if(p[x].second) p[y].second = true;
        p[x].first--;
        p[y].first++;
        if(p[x].first <= 0){
            p[x].second = false;
        }
    }
    int ans = 0;
    for(int i=0;i<n;i++){
        if(p[i].second){
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
n=int(input())
a=list(map(int, input().split()))
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a
def lcm(a,b):
    return a*b//gcd(a,b)
x=1
for t in a:
    x=lcm(x,t)
x-=1
ans=0
for t in a:
    ans+=x%t
print(ans)


Measured memory_bytes: 41308
#include<bits/stdc++.h>
using namespace std;
int main() {
	int a, b, c, flag = 0;
	cin >> a >> b >> c;
	for(int i = 1; i <= 100; i++) {
		if(a * i % b == c) {
			flag = 1;
		}
	}
	if(flag) {
		cout << "YES" << endl;
	} else {
		cout << "NO" << endl;
	}

	return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n+1];
        for (int i=0; i<n+1; i++) {
            a[i] = sc.nextInt();
        }
        long sum=0;
        for (int i=0; i<n; i++) {
            int b = sc.nextInt();
            if (a[i] > b ) {
                a[i]-=b;
                sum+=b;
            }
            else {
                int c=b-a[i];
                sum+=a[i];
                a[i]=0;
                if (a[i+1] > c ) {
                    a[i+1]-=c;
                    sum+=c;
                }
                else {
                    sum+=a[i+1];
                    a[i+1] = 0;
                }
            }
        }

        System.out.println(sum);
    }
}


Measured memory_bytes: 62592
/**
 *start coding only after you have clear idea. Otherwise you will waste time to change your code frequently and debug
 */

#include <bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    unsigned long long int s;
    cin>>s;
    unsigned long long int sum=0;
    for(unsigned long long int i=1;i<=s;i++)
    {
        if(i%3!=0&&i%5!=0){
            sum=sum+i;
        }
    }
    cout<<sum;

    return 0;
}


Measured memory_bytes: 3608
# -*- coding:utf-8 -*-

import math

N = int(input())

type_dict = {}
for _ in range(N):
    s = input()
    counts = (
        s.count('a'), s.count('b'), s.count('c'), s.count('d'),
        s.count('e'), s.count('f'), s.count('g'), s.count('h'),
        s.count('i'), s.count('j'), s.count('k'), s.count('l'),
        s.count('m'), s.count('n'), s.count('o'), s.count('p'),
        s.count('q'), s.count('r'), s.count('s'), s.count('t'),
        s.count('u'), s.count('v'), s.count('w'), s.count('x'),
        s.count('y'), s.count('z')
    )
    if counts in type_dict:
        type_dict[counts] = type_dict[counts] + 1
    else:
        type_dict[counts] = 1


def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


print(sum([combinations_count(x, 2) for x in type_dict.values() if x > 1]))


Measured memory_bytes: 35932
def main():
    n = int(input())
    s = [0 for i in range(n)]
    g = {}
    ans = 0
    for i in range(n):
        s[i] = input()
        if g.get(s[i]) == None:
            g[s[i]] = 1
            ans += 1

    print(ans)
    
main()

Measured memory_bytes: 133008
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
const int INF = (1<<30)-1;
const long long LINF = (1LL<<62)-1;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, c, k;
  cin >> n >> c >> k;
  vector<int> t(n);
  rep(i, n) cin >> t[i];
  sort(t.begin(), t.end());
  int ans = 0, i = 0, idx;
  while (i < n) {
    idx = i;
    i++;
    ans++;
    while (i < n && i-idx+1 <= c && t[i] <= t[idx]+k)
      i++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 640
#include<iostream>
#define MIN(a,b) (((a)<(b))?(a):(b))
typedef long long ll;
const ll MOD = 1000000007;
using namespace std;
long long Kurikaeshi(long long a, long long N, long long p){
  if( N == 0) return 1;
  long long rt;
  if(N % 2 == 0){
    rt = Kurikaeshi(a, N / 2, p);
    rt = rt * rt % p;
    return rt;
  }
  if(N % 2 == 1){
    rt = Kurikaeshi(a, N - 1, p);
    rt = a * rt % p;
    return rt;
  }
}
int main(){
  int n;ll k, TABLE[200011], TABLE1[200011], TABLE2[200011];
  cin >> n >> k;
  ll Cx = 1, Hx = 1, Cy = 1, Hy = 1;
  TABLE[0] = 1;
  TABLE1[0] = 1;
  TABLE1[n-1] = 1;
  TABLE2[0] = 1;
  TABLE2[n-1] = 1;
  for(int i = 1; i < n; i++){
    Cx *= (n - i + 1);
    Cy *= i;
    Cx = Cx % MOD;
    Cy = Cy % MOD;
    ll tmp = Cx;
    tmp *= Kurikaeshi(Cy,MOD-2,MOD);
    tmp = tmp % MOD;
    TABLE1[i] = tmp;
  }
  for(int i = n - 2; i > 0; i--){
    Hx *= (i+1);
    Hy *= ( n - i - 1);
    Hx = Hx % MOD;
    Hy = Hy % MOD;
    ll tmp = Hx;
    tmp *= Kurikaeshi(Hy,MOD-2,MOD);
    tmp = tmp % MOD;
    TABLE2[i] = tmp;
  }
  for(int i = 0; i < n; i++){
    TABLE[i] = (TABLE1[i]*TABLE2[i]) % MOD;
  }
  ll ans = 0;
  for(int i = 0; i < MIN(k+1,n); i++){
    ans += TABLE[i];
    ans = ans % MOD;
  }
  cout << ans << endl;
  for(int i = 0; i < MIN((k+1),(n)); i++){
    //cout << TABLE1[i] << "*" << TABLE2[i] << "->" << TABLE[i] << endl;
  }
  return 0;
}

Measured memory_bytes: 4992
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <array>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <functional>

using namespace std;
using lli = long long int;

int main() {
    double W, H, x, y;
    cin >> W >> H >> x >> y;

    double S = W * H / 2;
    int count = (x == W / 2 && y == H / 2) ? 1 : 0;
    cout << S << " " << count << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,a[101];
	int ans=0;
	cin>>n;
	for(int i=0;i<n-1;i++)
	{
		cin>>a[i];
	}
	for(int i=0;i<n-1;i++)
	{
		if(i==0)
		{
			ans+=a[i];
		}
		else
		{
			if(a[i]>=a[i-1])
			{
				ans+=a[i-1]; 
			}
			else
			{
				ans+=a[i];
			}
		}
	}
	ans+=a[n-2];
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
	double t,ans,max,min;
	int i;
	
	max=-1.0;
	min=-1.0;
	
	while((scanf("%lf",&t))!=EOF){
		if(t>max || max<0)max=t;
		if(t<min || min<0)min=t;
	}
	
	printf("%lf\n",max-min);
	
	return 0;
}

Measured memory_bytes: 648
#include <iostream>
using namespace std;
 
int main(){
        int x,y[25000],z,i;
        while(true){
                i=0;
        cin>>x;
        if(x==-1)break;
                else if(x==0)cout<<0;
        while(x!=0){
                z=x/4;
                y[i]=x%4;
                x=z;
                i++;
        }
                for(int j=i-1;j>=0;j--){
         cout<<y[j];
                }
                
                cout<<endl;
        }
        return 0;
}
 

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

int main(){
  //std::ifstream in("input.txt");
  //std::cin.rdbuf(in.rdbuf());
  
  int N;
  cin >> N;

  vector<int64_t> a(N);
  for(int i=0; i<N; i++){
    cin >> a.at(i);
  }

  vector<int64_t> s(N+1, 0);
  for(int i=0; i<N; i++){
    s.at(i+1) = s.at(i) + a.at(i);
  }

  // for(int i=0; i<N+1; i++){
  //   cout << s.at(i) << ' ';
  // }
  // cout << endl;

  map<int64_t, int64_t> counter;
  for(int i=0; i<N+1; i++){
    counter[s.at(i)] += 1;
  }

  int64_t total = 0;
  for(auto it: counter){
    total += it.second * (it.second - 1) / 2;
  }
  cout << total << endl;


  return 0;
}

Measured memory_bytes: 15872
/*
ID: Sho10
LANG: C++
*/
#include <bits/stdc++.h> //Andrei Alexandru a.k.a Sho10
#define ll long long int
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#define all(a) (a).begin(), (a).end()
#define sz size
#define f first
#define s second
#define pb push_back
#define er erase
#define in insert
#define mp make_pair
#define pi pair
#define rc(s) return cout<<s,0
#define endl '\n'
#define mod 1000000007
#define PI 3.14159265359
#define CODE_START  ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
ll n,m;
int32_t main(){
cin>>n>>m;
ll ans=0;
if(n>=m){
    ll val=n/m;
    n=n-val*m;
    ans=min(n,abs(m-n));
}else {
ans=min(n,abs(n-m));
}
cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n, m;
    cin >> n >> m;
    vector<int> a(n);
    int tot = 0;
    for (int & x : a) {
        cin >> x;
        tot += x;
    }
    int w = 0;
    for (int & x : a) {
        w += x * 4 * m >= tot;
    }
    cout << (w >= m ? "Yes\n" : "No\n");
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(ll i=0; i<(n); ++i)
#define rep1(i,n) for(ll i=1; i<=(n); ++i)
#define repi(i,a,b) for(ll i=a; i<=(b); ++i)
#define rrep(i,n) for(ll i=(n-1); i>=0; --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define pb push_back
#define mp make_pair
#define to_s to_string
#define sz(v) (int)v.size()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define print(x) cout<<(x)<<'\n'
#define debug(x) cout << #x << ": " << (x) << '\n'
using namespace std;
using ll = long long;
using Edge = pair<ll,ll>;
using Graph = vector<vector<Edge>>;
typedef pair<ll,ll> P;
struct aaa{aaa(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);};}aaaaaaa;
int MOD = 1e9 + 7;
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);}
ll devc(ll x, ll y){return 1 + (x-1)/y;}

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;
}


int main(){
    ll N,K; cin >> N >> K;
    vector<ll> A(N); rep(i,N) cin >> A[i];
    sort(ALL(A));
    
    ll ans = 0;
    COMinit();
    rep(i,N){
        // MAXに選ばれる回数
        ll MX = i;
        ll Cmx = COM(MX,K-1);

        // MINに選ばれる回数
        ll MN = N-i-1;
        ll Cmn = COM(MN,K-1);
    
        ans += (A[i]*(Cmx-Cmn))%MOD;
        ans %= MOD;
    }
    print(ans);
}

Measured memory_bytes: 13056
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#pragma GCC optimize("Ofast")
//*********************************************DO IT NOW****************************************************************
#include<bits/stdc++.h> 
#include<random>
#define int long long   
#define pp pair<int,int> 
#define ss second 
#define ff first 
#define pb push_back
#define mod 1000000007
#define pi 3.14159265359
#define mk(arr,n,type)  type *arr=new type[n];
#define sl s1.length();
#define yes cout<< "YES"<<endl
#define no  cout<< "NO"<<endl
#define all(v) (v).begin(),(v).end()
#define s(v)   sort(v,v+n)
#define  mt mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define read(a,n) for(int i=0;i<n;i++)cin>>a[i]
#define print(a,n) for(int i=0;i<n;i++)cout<<a[i]<<" "
#define for1(i,a,n)  for(int i=0;i<n;i++)
#define rep(i, c) for(int i = 0; i < (int)c; i++)
using namespace std;
//**********************************************DO IT NOW***************************************************************
void fastio()
{  
  #ifndef ONLINE_JUDGE
  freopen("INPUT.txt","r",stdin);
  freopen("OUTPUT.txt","w",stdout); 
  #endif
  ios_base :: sync_with_stdio(false); 
  cin.tie(NULL) ; 
  cout.tie(NULL);
}
int dp[101][1001],ans1=1e9,dp1[1000001];
int num[10];
int a[1000000];
signed main()
{   
    fastio();
    int t=1;
  // cin>>t;
    while(t--)
    {  
        double n,m;
        cin>>n>>m;
        double x=n/m;
        cout<<x;
    }
}
    
// 🍪 🍪 🍪


Measured memory_bytes: 3724
program Project1;

{$APPTYPE CONSOLE}

uses
  SysUtils;
var
  a,h,w,i,j,count,x,y,sw,m,n,b,c,soeji,sum,max,k,min:Integer;
  l:array of Integer;
  s,s123,s1,s2,s3:string;
  al:string = 'abcdefghijklmnopqrstuvwxyz';
  tf,tfl,tfr:Boolean;
begin
  try
    { TODO -oUser -cConsole メイン : ここにコードを記述してください }
    Readln(n);
    count:=0;
    max  :=0;
    min  :=100;


    if n<=111 then
      Writeln('111')
    else if n<=222 then
      Writeln('222')
    else if n<=333 then
      Writeln('333')
    else if n<=444 then
      Writeln('444')
    else if n<=555 then
      Writeln('555')
    else if n<=666 then
      Writeln('666')
    else if n<=777 then
      Writeln('777')
    else if n<=888 then
      Writeln('888')
    else
      Writeln('999');

    Readln;
  except
    on E: Exception do
      Writeln(E.ClassName, ': ', E.Message);
  end;
end.


Measured memory_bytes: 128
n = int(input())
a = list(map(int, input().split()))

if n%2 == 0:
    for i in range(n-1,-1,-2):
        print (a[i], end = ' ')
    for i in range(0, n, 2):
        print (a[i], end = ' ')
else:
    for i in range(n-1, -1, -2):
        print (a[i], end = ' ')
    for i in range(1, n, 2):
        print (a[i], end = ' ')
    


Measured memory_bytes: 26176
#include <numeric>
#include <bits/stdc++.h>
#include <utility>
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <math.h>
#include <string>
#define ll long long
#define ull unsigned long long
#define make(type,x) type x; cin>>x
#define make2(type,x,y) type x,y; cin>>x>>y
#define fr(x,y) for(long long x=0;x<y;x++)
#define makevec(x,y,n) vector <x> y(n); for(ll i=0;i<n;i++) cin>>y[i]
#define M (ll)1000000007
#define MM (ll) 1e8
#define INF (ll) 1e18

# define IOS ios_base::sync_with_stdio(false); cin.tie(NULL)

using namespace std;

template <typename T>
T modpow(T base, T exp, T modulus) {
  base %= modulus;
  T result = 1;
  while (exp > 0) {
    if (exp & 1) result = (result * base) % modulus;
    base = (base * base) % modulus;
    exp >>= 1;
  }
  return result;
}
bool sortbysec(const pair <ll,ll> &a,const pair <ll,ll> &b){
    return a.second<b.second;
}

struct cmp {
	bool operator() (const pair<int, int> &a, const pair<int, int> &b) const {
		int lena = a.second - a.first + 1;
		int lenb = b.second - b.first + 1;
		if (lena == lenb) return a.first < b.first;
		return lena > lenb;
	}
};


struct c_h {
    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        x ^= FIXED_RANDOM;
        return x ^ (x >> 16);
    }
};

ll calcpow(ll x, ll y)
{
    ll temp;
    if(y == 0)
        return 1;
    temp = calcpow(x, y / 2);
    if (y % 2 == 0)
        return temp * temp;
    else
    {
        if(y > 0)
            return x * temp * temp;
        else
            return (temp * temp) / x;
    }
}
ll gcd(ll a, ll b){
    if(b==0) return a;
    return gcd(b,a%b);

}
ll egcd(ll a, ll b, ll &x,ll &y){
    if(b==0){
        x=1;
        y=0;
        return a;
    }
    ll x1;
    ll y1;
    ll g=egcd(b,a%b,x1,y1);
    x=y1;
    y=x1-y1*(a/b);
    return g;
}


bool isprime(ll a){
bool flag=1;
for(ll i=2;i*i<=a;i++){
    if(a%i==0) {flag=0; break;}
}
return flag;
}

ll dx8[8]={1,0,-1,0,1,-1,1,-1};
ll dy8[8]={0,1,0,-1,1,-1,-1,1};
ll dx4[4]={0,0,1,-1};
ll dy4[4]={1,-1,0,0};



int main(){
    IOS;
    make(ll,n);
    makevec(ll,a,n);
    unordered_map <ll,ll> um;
    fr(i,n) um[a[i]]++;
    ll ans=0;
    for(auto x : um){
        ans+=(x.second*(x.second-1))/2;
    }
    fr(i,n){
        cout<<ans-um[a[i]]+1<<endl;
    }



    return 0;
}


Measured memory_bytes: 11804
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>//sort,reverse
#include<utility>//pair
#include<queue>//queue,priority_queue
#include<deque>//double_ended queue
#include<map>//map
using namespace std;
typedef long long LL; 
typedef pair<LL,LL> P;//Pでpair<-,->を表す。
const LL MAX=2000010;
const LL MOD=1000000007;
typedef map<LL,LL>::iterator Itr;

int main()
{ 
    string S;
    cin>>S;
    string s=S;
    for(int i=0;i<s.size();i++){
        if(S[i]=='?'){s[i]='D';}
    }
    /*LL ans=0;
    for(int i=0;i<s.size();i++){
        if(s[i]=='D'){ans++;}
        if(s[i]=='P'&&i!=s.size()-1){
            if(s[i+1]=='D'){ans++;}
        }
    }*/
    cout<<s<<endl;
    return 0;
}

Measured memory_bytes: 3836
def main():
    n = int(input())
    S = input()

    array = [0,S[1:].count('E')]
    ans = sum(array)

    for i in range(1,len(S)):
        if S[i-1]=='W':
            array[0]+=1
        if S[i]=='E':
            array[1]-=1
        ans = min(ans, sum(array))
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 44228
#include <bits/stdc++.h>
 
using namespace std;
 
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define priority_queue pq 
#define vso(x) sort( x.begin() , x.end() )
#define aso(x) sort( x , x + x.size() )
#define print(x) cout << x << endl 
#define no cout << "NO\n" 
#define yes cout << "YES\n"
typedef long long ll ; 
typedef long double ld ;
typedef pair<ll, ll> pairs ;

// B3

int a[100009] , b[100009] , c[100009] ;
int dp_a[100009] , dp_b[100009] , dp_c[100009] ;

int main()
{
    //freopen("problem_name.out", "w", stdout) ;
    //freopen("problem_name.in", "r", stdin) ;
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
 
    //int t ; cin >> t ; while(t--){}
    int n ; cin >> n ;
    for ( int i = 1 ; i <= n ; i++ )
    {
        cin >> a[i] >> b[i] >> c[i] ;
        dp_a[i+1] += a[i] + max( dp_b[i] , dp_c[i] ) ;
        dp_b[i+1] += b[i] + max( dp_c[i] , dp_a[i] ) ;
        dp_c[i+1] += c[i] + max( dp_a[i] , dp_b[i] ) ;
        //cout << dp_a[i+1] << " " << dp_b[i+1] << " " << dp_c[i+1] << "\n" ;
    }
    print( max( dp_a[n+1] , max( dp_b[n+1] , dp_c[n+1] ) ) ) ;
}

Measured memory_bytes: 2560
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int k = sc.nextInt();
    int x = sc.nextInt();

    if (k * 500 >= x) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
  }
}


Measured memory_bytes: 22100
#include<stdio.h>

#define UP 0
#define FRONT 1
#define RIGHT 2
#define LEFT 3
#define BACK 4
#define BOTTOM 5

typedef struct{
	int label[6];		// label, what do each tiles have.
	int direction[6];	// direction, what direction is dice. [0]-[5]:up, front, right, left, back, bottom.
}dice;

int DiceRoll(dice* p, char c);

int main(void){
	dice a;
	int i=0, j=0;		// loop index
	int q=0;			// input; question times
	int u_content=0;	// input; up content
	int f_content=0;	// input; front content
	int u_label=-1;		
	int f_label=-1;
	int off_label=-1;

	for(i=0;i<6;i++) a.direction[i]=i;	// dice direction setup

	scanf("%d %d %d %d %d %d", &a.label[0], &a.label[1],
		&a.label[2], &a.label[3], &a.label[4], &a.label[5]);	// dice label setup
	
	scanf("%d", &q);		// get question times
	
	for(i=0;i<q;i++){
		scanf("%d %d", &u_content, &f_content);
		for(j=0;j<6;j++){
			if(u_content == a.label[j]) u_label = j;
			if(f_content == a.label[j]) f_label = j;
		}
		// roll to same up tile
		off_label = a.direction[UP];
		do{
			DiceRoll(&a, 'E');
		}while(a.direction[UP] != off_label && a.direction[UP] != u_label);
		
		if(a.direction[UP] == off_label){
			while(a.direction[UP] != u_label) DiceRoll(&a, 'N');
		}

		while(a.direction[FRONT] != f_label) DiceRoll(&a, 'R');

		printf("%d\n", a.label[a.direction[RIGHT]]);
	}

	return 0;
}

int DiceRoll(dice* p, char c){
	int tmp = -1;
	
	switch(c){
	case 'E':
		tmp = p->direction[UP];
		p->direction[UP] = p->direction[LEFT];		// up <- left
		p->direction[LEFT] = p->direction[BOTTOM];	// left <- bottom
		p->direction[BOTTOM] = p->direction[RIGHT];	// bottom <- right
		p->direction[RIGHT] = tmp;					// right <- up
		break;
	case 'N':
		tmp = p->direction[UP];
		p->direction[UP] = p->direction[FRONT];		// up <- front
		p->direction[FRONT] = p->direction[BOTTOM];	// front <- bottom
		p->direction[BOTTOM] = p->direction[BACK];	// bottom <- back
		p->direction[BACK] = tmp;					// back <- up
		break;
	case 'S':
		tmp = p->direction[UP];
		p->direction[UP] = p->direction[BACK];		// up <- back
		p->direction[BACK] = p->direction[BOTTOM];	// back <- bottom
		p->direction[BOTTOM] = p->direction[FRONT];	// bottom <- front
		p->direction[FRONT] = tmp;					// front <- up
		break;
	case 'W':
		tmp = p->direction[UP];
		p->direction[UP] = p->direction[RIGHT];		// up <- right
		p->direction[RIGHT] = p->direction[BOTTOM];	// right <- bottom
		p->direction[BOTTOM] = p->direction[LEFT];	// bottom <- left
		p->direction[LEFT] = tmp;					// left <- up
		break;
	case 'R':
		tmp = p->direction[FRONT];
		p->direction[FRONT] = p->direction[LEFT];	// front <- left
		p->direction[LEFT] = p->direction[BACK];	// left <- back
		p->direction[BACK] = p->direction[RIGHT];	// back <- right
		p->direction[RIGHT] = tmp;					// right <- front
		break;
	case 'L':
		tmp = p->direction[FRONT];
		p->direction[FRONT] = p->direction[RIGHT];	// front <- right
		p->direction[RIGHT] = p->direction[BACK];	// right <- back
		p->direction[BACK] = p->direction[LEFT];	// back <- left
		p->direction[LEFT] = tmp;					// left <- front
		break;
	default:
		break;
	}
	return 0;
}

Measured memory_bytes: 596
#include<bits/stdc++.h>
#define rep(i,m,n) for(int i=m;i<n;i++)
#define repr(i,n,m) for(int i=n;i>=m ;i--)
#define mod 1000000007
#define float long double
#define pb push_back
#define mp make_pair
#define pp pop_back
#define print(v) for(int i=0;i<v.size();i++) cout<<v[i]<<" ";cout<<endl
using namespace std;
bool sortcol( const vector<int>& v1, 
               const vector<int>& v2 ) { 
 return v1[0] < v2[0]; 
} 
bool sortbysec(const pair<int,int> &a,
             const pair<int,int> &b)
{
   return (a.second < b.second);
}
bool sortinrev(const pair<int,int> &a,  
              const pair<int,int> &b)
{
      return (a.first > b.first);
}
int ispal(string s)
{
	int x=s.length();
	for(int i=0,j=x-1;i<x/2,j>=x-x/2;i++,j--)
		if(s[i]!=s[j])
			return 0;
	return 1;
}
void solve()
{
	string s;
	cin>>s;
	if(s[0]=='7'||s[1]=='7'||s[2]=='7')
		cout<<"Yes";
	else
		cout<<"No";
}	
signed main()
{
           	   // #ifndef ONLINE_JUDGE
               // freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
               // #endif 
  int t=1;
 //cin>>t;
  while(t--){
  solve();
  cout<<"\n";
}
  cerr<<"time taken : "<<(float)clock()/CLOCKS_PER_SEC<<" secs"<<endl;
 return 0;
}  


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

#define ll long long
#define sd(x) scanf("%d", &(x))
#define pii pair<int, int>
#define F first
#define S second
#define all(c) ((c).begin()), ((c).end())
#define sz(x) ((int)(x).size())
#define ld long double

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

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

#ifdef LOCAL
#define cerr cout
#else
#endif

#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

const int N = 18;
const int K = 55;

ll C[K][K];
ll sm[K];
ll masks[2][N];
int okay[K];
int x[K];

ll ans = 0;
int positions[N], cnt;

void go(int i, int sgn, ll possible){
	if(i == cnt){
		ans += sgn * sm[__builtin_popcountll(possible)];
		return;
	}
	go(i + 1, sgn, possible);
	go(i + 1, sgn * -1, possible & masks[0][positions[i]]);
	go(i + 1, sgn * -1, possible & masks[1][positions[i]]);
}

int main(){
	ll s = 0, t = (1LL << 50) - 1;
	int n = 50, k = 50; 
	sd(n); sd(k); 
	scanf("%lld %lld", &s, &t);
	for(int i = 0; i < n; i++){
		x[i] = (rand() * (ll) rand()) % (1LL << 50);
		cin >> x[i];
	}

	for(int i = 0; i < K; i++){
		C[i][0]= 1;
		for(int j = 1; j <= i; j++){
			C[i][j] = C[i - 1][j - 1] + C[i - 1][j];
			if(j <= k) sm[i] += C[i][j];
		}
	}
	
	fill(okay, okay + n, 1);
	for(int i = 0; i < N; i++){
		int u = s >> i & 1, v = t >> i & 1;
		if(u && !v){
			printf("0\n");
			return 0;
		}
		if(!u && !v){
			for(int j = 0; j < n; j++) if(x[j] >> i & 1) okay[j] = 0;
			continue;
		}
		if(u && v){
			for(int j = 0; j < n; j++) if(!(x[j] >> i & 1)) okay[j] = 0;
			continue;
		}
		positions[cnt++] = i;
	}
	ll possible = 0;
	for(int i = 0; i < n; i++) if(okay[i]){
		possible |= 1LL << i;
		for(int j = 0; j < N; j++) masks[x[i] >> j & 1][j] |= 1LL << i;

	}

	go(0, 1, possible);
	printf("%lld\n", ans);
}

Measured memory_bytes: 3812
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc=new Scanner(System.in);
		
		int x=sc.nextInt();		//高橋X円持ってる
		
		int a=x/500;
		int b=(x%500)/5;
		
		System.out.println(a*1000+b*5);
		sc.close();

	}

}


Measured memory_bytes: 23252
import sys
sys.setrecursionlimit(10**6)
n,m=map(int,input().split())
a=[ -int(i) for i in input().split()]

from heapq import * 
heapify(a)
for _ in range(m):
  c=heappop(a)
  c=-((-c)//2)
  heappush(a,c)
print(-sum(a))



Measured memory_bytes: 14224
import java.util.Scanner;

public class Main {

	public static final long CONST = 100000007L;

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		String strS = scan.next();
		String strT = scan.next();

		int count = 0;

		for (int i = 0; i < 3; i++) {
			if ((strS.substring(i, i+1)).equals(strT.substring(i, i+1))) {
				count++;
			}
		}
		System.out.println(count);
	}
}


Measured memory_bytes: 25300
main = do
    getLine
    ls <- map read . words <$> getLine
    print $ analyze ls
    
analyze :: [Int] -> Int
analyze ls = if remain /= 0 then (length ls) - remain else -1
             where remain = countscore ls 1

countscore :: [Int] -> Int -> Int
-- リスト→今のインデックス
countscore [] num = num - 1
countscore ls num
    | head ls == num                = countscore (tail ls) (num+1)
    | otherwise                     = countscore (tail ls) num

Measured memory_bytes: 68988
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<vector>
#include<string>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<sstream>
#include<bitset>
using namespace std;
#define pii pair<int,int>
#define pdd pair<double,double>
#define mp make_pair
#define pb push_back
#define ALL(x)	x.begin(),x.end()
#define fst first
#define sec second
#define PQ priority_queue
typedef long long ll;
const double eps = 1e-6;

const int inf=0x3f3f3f3f;
const ll mod=1e9+7;
const double pi=acos(-1.0);
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;} 

const int maxn = 1e5+5;
int fa[maxn];
struct Node{
  ll x, y, id;
}st[maxn];
 
struct Edge{
  ll cost, p1, p2;
}edge[maxn*2];
 
int cmp1(Node a,Node b){ 
	return a.x<b.x; 
}
int cmp2(Node a,Node b){ 
	return a.y<b.y; 
}
int cmp3(Edge a,Edge b){ 
	return a.cost<b.cost; 
}
 
int find(int u){
  	if(fa[u]==u) 
  		return fa[u];
  	return fa[u]=find(fa[u]);
}
 
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++) {
		scanf("%lld%lld", &st[i].x, &st[i].y); 
		st[i].id=i; 
		fa[i]=i;
	}
    sort(st+1,st+1+n,cmp1);
    int cnt=0;
    for(int i=2;i<=n;i++){
        edge[++cnt].p1=st[i-1].id;
        edge[cnt].p2=st[i].id;
        edge[cnt].cost=st[i].x-st[i-1].x;
    }
    sort(st+1,st+1+n,cmp2);
    for(int i=2;i<=n;i++){
        edge[++cnt].p1=st[i-1].id;
        edge[cnt].p2=st[i].id;
        edge[cnt].cost=st[i].y-st[i-1].y;
    }
    sort(edge+1,edge+1+cnt,cmp3);
    ll ans=0;int num=0;
    for(int i=1;i<=cnt;i++){
        int x=find(edge[i].p1);
        int y=find(edge[i].p2);
        if(x==y) 
			continue;
        else{
            fa[x]=y;
            num++;
            ans+=(edge[i].cost);
        }
        if(num==n-1) break;
    }
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 7680
#include<bits/stdc++.h>
using namespace std;
// #define int               long long 
#define pb                push_back
#define ppb               pop_back
#define pf                push_front
#define ppf               pop_front
#define all(x)            (x).begin(),(x).end()
#define uniq(v)           (v).erase(unique(all(v)),(v).end())
#define sz(x)             (int)((x).size())
#define fr                first
#define sc                second
#define pii               pair<int,int>
#define loop(i,a,b)        for(int i=a;i<b;i++)
#define mem1(a)           memset(a,-1,sizeof(a))
#define mem0(a)           memset(a,0,sizeof(a))
#define ppc               __builtin_popcount
#define ppcll             __builtin_popcountll
#define br                break
#define con               continue
#define ll				  long long int

template<typename T1,typename T2>istream& operator>>(istream& in,pair<T1,T2> &a){in>>a.fr>>a.sc;return in;}
template<typename T1,typename T2>ostream& operator<<(ostream& out,pair<T1,T2> a){out<<a.fr<<" "<<a.sc;return out;}
template<typename T,typename T1>T amax(T &a,T1 b){if(b>a)a=b;return a;}
template<typename T,typename T1>T amin(T &a,T1 b){if(b<a)a=b;return a;}
 
const long long INF=1e18;
const int32_t M=1e9+7;
const int32_t MM=998244353;

priority_queue<pii, vector<pii>, greater<pii> >q;

#include<bits/stdc++.h>
using namespace std;
signed main(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output1.txt","w",stdout);
	#endif
    ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
 
	
		int n;
		ll ans=0;
		cin>>n;
		int a[n+1];
		loop(i,0,n)cin>>a[i];
		int mx=0;
		for(int i=0;i<n;i++){
			if(a[i]<mx)
				ans+= mx-a[i];
			else mx=a[i];
		}
		cout<<ans<<endl;
	
 
}

Measured memory_bytes: 4384
S = input()

if 1 <= int(S[0:2]) <= 12 and 1 <= int(S[2:]) <= 12:
    print('AMBIGUOUS')
    exit()
if 1 <= int(S[0:2]) <= 12:
    print('MMYY')
    exit()
if 1 <= int(S[2:]) <= 12:
    print('YYMM')
    exit()
else:
    print('NA')

Measured memory_bytes: 3060
H, W = [int(i) for i in input().split()]
A = [[int(i) for i in input().split()] for j in range(H)]

ans = []
dx = -1
w = 0

for h in range(H):
    dx *= -1
    for j in range(W):
        if A[h][w] % 2 == 1:
            A[h][w] -= 1
            a = [h+1, w+1]
            if w + dx < 0 or w + dx >= W:
                if h + 1 == H:
                    break
                A[h+1][w] += 1
                a += [h+2, w+1]
            else:
                w += dx
                A[h][w] += 1
                a += [h+1, w+1]
            ans.append(a)
            
        elif 0 <= w + dx < W:
            w += dx
            
            
        

print(len(ans))
for a in ans:
    print(*a)


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

namespace ABC179D
{
    class Program
    {
        static long ans = 0;
        static long mod= 998244353;
        static void Main(string[] args)
        {
            string[] NK = Console.ReadLine().Split(' ');
            long N = long.Parse(NK[0]);
            int K = int.Parse(NK[1]);
            bool[] hantei = new bool[200001];
            long[] henka = new long[K * 2];
            for(int i = 0; i < K; i++)
            {
                string[] LR = Console.ReadLine().Split(' ');
                long L = long.Parse(LR[0]);
                long R = long.Parse(LR[1]);
                henka[i * 2] = L * -1;
                henka[i * 2 + 1] = R * -1;
                for(long j = L; j <= R; j++)
                {
                    hantei[j] = true;
                }
            }
            //Console.WriteLine(string.Join(" ", S));
            //Console.WriteLine(string.Join(" ", henka));
            long[] ans = new long[N];
            ans[0] = 1;
            //Console.WriteLine(string.Join(" ", ans));
            for (int i = 1; i < N; i++)
            {
                //Console.WriteLine(string.Join(" ", henka));
                if (i > 1)
                {
                    ans[i] = ans[i - 1];
                }
                for(int d = 0; d < K; d++)
                {
                    if (henka[d * 2]+1 >= 0)
                    {
                        ans[i] += ans[henka[d * 2]+1];
                        ans[i] %= mod;
                    }
                    if (henka[d * 2 + 1] >= 0)
                    {
                        ans[i] += mod-ans[henka[d * 2 + 1]];
                        ans[i] %= mod;
                    }
                    henka[d * 2] += 1;
                    henka[d * 2 + 1] += 1;
                }
            }
            //Console.WriteLine(string.Join(" ", ans));
            Console.WriteLine(ans[N-1]);
        }
    }
}


Measured memory_bytes: 29252
from heapq import heappush, heappop
from operator import itemgetter


def main(n, m, works):
    backward = sorted(works, key=itemgetter(0), reverse=True)
    q = []
    score = 0
    for i in range(1, m + 1):
        while backward and backward[-1][0] <= i:
            a, b = backward.pop()
            heappush(q, -b)
            # print(q)
        if q:
            b = -heappop(q)
            score += b

    return score


n, m = list(map(int, input().split()))
works = []
for _ in range(n):
    a, b = list(map(int, input().split()))
    works.append((a, b))

print(main(n, m, works))

Measured memory_bytes: 20500
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
#define endl '\n'
#define PI acos(-1)
typedef long long ll;
using namespace std;

int main()
{
    cin.tie(NULL); cout.tie(NULL); ios_base::sync_with_stdio(false);
#ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
#endif
    int n;
    ll ans = 0;
    cin >> n;
    for(int i = 1; i <= n; i++)
        if(i % 3 && i % 5)
            ans += i;
    cout << ans;
}

Measured memory_bytes: 3648
N = int(input())
h = list(map(int, input().split()))

count = 0
for i in range(N):
    while h[i] != 0:
        if 0 in h[i:]:
            end = h[i:].index(0) + i
        else:
            end = N
        value = min(h[i:end])
        count += value
        
        for l in range(i, end):
            h[l] -= value
                
print(count)

Measured memory_bytes: 3064
//rankなし、若干手抜きver
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
typedef long long ll;
typedef vector<vector<ll>> vvl;
typedef vector<ll> vl;
typedef vector<vector<char>> vvc;
typedef vector<char> vc;
typedef pair<ll,ll> pll;
typedef priority_queue<string> priquest;
typedef priority_queue<string,vector<string>,greater<string>> rpriquest;
ll max(ll x,ll y){
if(x>y)return x;
else return y;
}
ll min(ll x,ll y){
  return x+y-max(x,y);
}

const ll big=1000000007;
int exp(int x,int y){
    if(y==0)return 1;//0^0=1
    if(x==1||x==0)return x;
    if(y%2==1)return (exp(x,y-1)*x);
    int t=exp(x,y/2);
    return (t*t);
}
void chmin(ll a,ll b){
    if(a>b)a=b;
    return;
}

struct unionfind{
  vector<int> par;
  vector<int> size;
  void begin(int n){
    par.resize(n,-1);
    size.resize(n,1);
  }
  int find(int x){
    if(par[x]==-1)return x;
    return par[x]=find(par[x]);
  }
  void unite(int x,int y){
    x=find(x);y=find(y);
    if(x==y)return;
    par[x]=y;
    size[y]+=size[x];
  }
};



int main(){
  int n,m,k;scanf("%d %d %d",&n,&m,&k);
  unionfind uf;
  uf.begin(n);
  vector<int> cant(n);
  rep(i,m){
    int a,b;scanf("%d %d",&a,&b);a--;b--;
    uf.unite(a,b);
    cant[a]++;cant[b]++;
  }rep(i,k){
    int a,b;scanf("%d %d",&a,&b);a--;b--;
    if(uf.find(a)==uf.find(b)){cant[a]++;cant[b]++;}
  }
  rep(i,n){
    int x=uf.find(i);
    printf("%d%c",uf.size[x]-cant[i]-1,(n-i-1 ? ' ' : '\n'));
  }
}

Measured memory_bytes: 2304
// http://www.ipsj.or.jp/07editj/promenade/4501.pdf

#include<cmath>
#include<cstdio>
#include<vector>
#include<algorithm>

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

const double EPS=1e-8;

int n,px[100],py[100];

int calc_band(int x){
	vector<double> Y0,Y1;
	rep(i,n){
		int x1=px[i],x2=px[(i+1)%n];
		int y1=py[i],y2=py[(i+1)%n];
		if(x1>x2){
			swap(x1,x2);
			swap(y1,y2);
		}
		if(x1<=x && x+1<=x2){
			Y0.push_back((double)(y2-y1)/(x2-x1)*(x+0-x1)+y1);
			Y1.push_back((double)(y2-y1)/(x2-x1)*(x+1-x1)+y1);
		}
	}
	sort(Y0.begin(),Y0.end());
	sort(Y1.begin(),Y1.end());

	int res=0,pre=-2000;
	rep(i,Y0.size()/2){
		int t=floor(min(Y0[2*i+0],Y1[2*i+0])+EPS);
		int b=ceil (max(Y0[2*i+1],Y1[2*i+1])-EPS);
		res+=b-max(t,pre);
		pre=max(pre,b);
	}
	return res;
}

int main(){
	while(scanf("%d",&n),n){
		rep(i,n) scanf("%d%d",px+i,py+i);

		int ans=0;
		for(int x=-2000;x<2000;x++){
			ans+=calc_band(x);
		}
		printf("%d\n",ans);
	}

	return 0;
}

Measured memory_bytes: 1060
#include <stdio.h>

int main(void){
	int a, b, c, x = 0, y = 0;
	while (scanf("%d,%d,%d", &a, &b, &c) != EOF){
		if (a*a + b*b == c*c) x++;
		if (a == b) y++;
	}
	printf("%d\n%d\n", x, y);
	return 0;
}

Measured memory_bytes: 596
'use strict'
const lines = require('fs').readFileSync(0, 'utf8').split('\n')
const nmq = lines[0].split(' ')
const N = parseInt(nmq[0], 10)
const M = parseInt(nmq[1], 10)
const Q = parseInt(nmq[2], 10)
const dp = Array(N)
const inputs = Array(N)
for (let l=0;l < N;l++) {
  dp[l] = Array(N-l)
  inputs[l] = Array(N-l)
}
for (let i=1;i <= M;i++) {
  const LR = lines[i].split(' ')
  const L = parseInt(LR[0], 10)
  const R = parseInt(LR[1], 10)
  inputs[L-1][R-L] = inputs[L-1][R-L] ? inputs[L-1][R-L] + 1 : 1
}
function query(p, q) {
  return subquery(q, q) - subquery(p-1, q)
}
// Lがl以下,Rがr以下のcount
function subquery(l, r) {
  if (l < 0) return 0
  if (typeof dp[l][r-l] === 'number') return dp[l][r-l]
  for (let i=0;i<=l;i++) {
    let count = 0
    for (let j=0;j<=r-i;j++) {
      count += inputs[i][j] || 0
      dp[i][j] = count + (i > 0 ? dp[i-1][j+1] : 0)
    }
  }
  return dp[l][r-l]
}
for (let i=M+1;i <= M+Q;i++) {
  const pq = lines[i].split(' ')
  const p = parseInt(pq[0], 10)
  const q = parseInt(pq[1], 10)
  console.log(query(p-1, q-1))
}

Measured memory_bytes: 61736
ma = lambda :map(int,input().split())
lma = lambda :list(map(int,input().split()))
tma = lambda :tuple(map(int,input().split()))
ni = lambda:int(input())
yn = lambda fl:print("Yes") if fl else print("No")
import collections
import math
import itertools
import heapq as hq
n = ni()
L = lma()
cnt = 0
for i in range(n):
    for j in range(i+1,n):
        for k in  range(j+1,n):
            if L[i] ==L[j] or L[i] ==L[k] or L[j] ==L[k]:
                continue
            if L[i] +L[j]>L[k] and L[k] +L[j]>L[i] and L[i] +L[k]>L[j] :
                cnt+=1
print(cnt)


Measured memory_bytes: 9472
#include <limits.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <math.h>

#define P 1000000007

int comp(const void *a, const void *b){return *(int*)a-*(int*)b;}

int main(void){
	long n;
	scanf("%ld", &n);
	if(n&1!=0){
		puts("0");
	}else{
		n/=2;
		long ans=0;
		while(n>=5){
			n/=5;
			ans+=n;
		}
		printf("%ld\n", ans);
	}
}


Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
	public static void main(String[]args) {
		try(Scanner scan = new Scanner(System.in)){
			
			
			int N = scan.nextInt();
			
			if(N%10==3) {
				System.out.println("bon");
			}else if(N%10==0||N%10==1||N%10==6||N%10==8) {
				System.out.println("pon");
			}else {
				System.out.println("hon");
			}
			
			
			
			
		}
		
		
	}
		

}


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

int main(){
    int k; cin >> k;
    int a,b; cin >> a >> b;
    for(int i=0;i<10000;i++){
        if(a<=k*i && k*i<=b){
            cout << "OK" << endl;
            return 0;
        }
    }
    cout << "NG" << endl;
}

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

namespace abc107_a
{
    class Program
    {
        static void Main(string[] args)
        {

            string[] input = Console.ReadLine().Split(' ');
            int N = int.Parse(input[0]);
            int i = int.Parse(input[1]);


            Console.WriteLine(N-i+1);
            Console.ReadLine();
        }
    }
}


Measured memory_bytes: 27456
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define endl "\n"
#define pb push_back
#define f(i,n) for(i=0;i<n;i++)
#define F(i,a,b) for(i=a;a<=b;i++)
#define arr(a,n) for( i=0;i<n;i++)cin>>a[i];
#define fi first
#define se second
#define mp make_pair
#define mod 1000000007
#define YES cout<<"YES"<<endl;
#define Yes cout<<"Yes"<<endl;
#define NO cout<<"NO"<<endl;
#define No cout<<"No"<<endl;
#define yes cout<<"yes"<<endl;
#define no cout<<"no"<<endl;
#define vi vector<ll>
#define ed end()
#define bg begin()
#define sz size()
#define ln length()
#define s() sort(a,a+n);
#define sr() sort(a,a+n,greater<ll>());
#define v()  sort(v.begin(),v.end());
#define vr() sort(v.begin(),v.end(),greater<ll>());
#define mod 1000000007
#define fast() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);}
ll power(ll x,ll y,ll p){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
int main() {
    #ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
    #endif
        

fast();
//ll t;cin>>t;while(t--)
{
    ll h,w,k,c=0;
    cin>>h>>w>>k;
    char a[h][w];
    for(int i=0;i<h;i++)
    {
      for(int j=0;j<w;j++)
      {
        cin>>a[i][j];
      }
    }
    /*for(int i=0;i<h;i++)
    {
      for(int j=0;j<w;j++)
      {
        cerr<<a[i][j];
      }
      cerr<<endl;
    }*/
    for(int i=0;i<(1<<h);i++)
    {
      for(int j=0;j<(1<<w);j++)
      {
        ll temp=0;
        for(int p=0;p<h;p++)
        {
          for(int q=0;q<w;q++)
          {
            
            if((i&(1<<(p)))&&(j&(1<<(q)))&&(a[p][q]=='#'))
            {
              //cout<<"I = "<<i<<" J = "<<j<<" P = "<<p<<" Q = "<<q<<"   "<<(i&(1<<(p)))<<" "<<(j&(1<<(q)))<<endl;
              //cerr<<i<<" "<<j<<" "<<p<<" "<<q<<endl;
                temp++;
                //cerr<<temp<<" ";
            }
          }
         // cerr<<endl;

        }
       // cerr<<endl<<endl;
        if(temp==k)
        {
          //cerr<<i<<" "<<j<<endl;

             c++;
        }
      }
     // cout<<"hash bahar aaya"<<endl;
    }
    cout<<c<<endl;
}
return 0;
}

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

int main() {
    int n, m;
    cin >> n >> m;
    priority_queue<pair<int, int>> que;
    rep(i, n) {
        int a;
        cin >> a;
        que.push({a, 1});
    }
    rep(i, m) {
        int a, b;
        cin >> a >> b;
        que.push({b, a});
    }

    ll ans = 0;
    while (n > 0) {
        auto p = que.top();
        que.pop();

        rep(i, min(n, p.second)) {
            ans += p.first;
        }
        n -= p.second;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 5368
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int x = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();

		if(a >= b) {
			System.out.println("delicious");
		} else if(a+x >= b) {
			System.out.println("safe");
		} else {
			System.out.println("dangerous");
		}
	}
}

Measured memory_bytes: 35784
class UnionFind():
    n=1
    par=[0]
    rnk=[0]
    def __init__(self,size):
        self.n=size
        self.par=[i for i in range(self.n)]
        self.rnk=[0 for i in range(self.n)]
    def find(self,vertex1):
        if self.par[vertex1]==vertex1:
            return vertex1
        else:
            self.par[vertex1]=self.find(self.par[vertex1])
            return self.par[vertex1]
    def unite(self,vertex1,vertex2):
        vertex1=self.find(vertex1)
        vertex2=self.find(vertex2)
        if vertex1==vertex2:
            return
        if (self.rnk[vertex1]<self.rnk[vertex2]):
            self.par[vertex1]=vertex2
        else:
            self.par[vertex2]=vertex1
            if(self.rnk[vertex1]==self.rnk[vertex2]):
                self.rnk[vertex1]+=1
    def same(self,vetrex1,vertex2):
        return self.find(vetrex1)==self.find(vertex2)

N=int(input())
edge=[]
points=[]
for i in range(N):
    x,y=map(int,input().split())
    points.append((i,x,y))
points.sort(key=lambda x:x[1])
for i in range(N-1):
    i1,x1,y1=points[i]
    i2,x2,y2=points[i+1]
    wt=min(abs(x1-x2),abs(y1-y2))
    edge.append((wt,i1,i2))
points.sort(key=lambda x:x[2])
for i in range(N-1):
    i1,x1,y1=points[i]
    i2,x2,y2=points[i+1]
    wt=min(abs(x1-x2),abs(y1-y2))
    edge.append((wt,i1,i2))
edge.sort()
G=UnionFind(N)
ans=0
for e in edge:
    w,i,j=e
    if not(G.same(i,j)):
        G.unite(i,j)
        ans+=w
print(ans)

Measured memory_bytes: 126372
#include <iostream>
#include <cstdlib>
#include <functional>
#include <queue>
#include <stack>
#include <map>
#include <vector>
#include <string>

using namespace std;

int main()
{
    int a,b,c;
    string result = "NO";
    cin >> a >> b >> c;
    if(a == 5 && b == 7 && c == 5){
        result = "YES";
    }else if(a == 7 && b == 5 && c == 5){
        result = "YES";
    }else if(a == 5 && b == 5 && c == 7){
        result = "YES";
    }
    cout << result << endl;
    return 0;
}

Measured memory_bytes: 256
A, B, C = map(int, input().split(" "))

t = {}

t[A] = t.get(A, 0) + 1
t[B] = t.get(B, 0) + 1
t[C] = t.get(C, 0) + 1

flag = False
for k, v in t.items():
    if v == 2:
        flag = True 


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

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

int main(){
    int n;
    // int w[100];
    cin >> n;
    vector<int>w(n);
    int sum=0;
    for(int i=0;i<n;i++){
        cin >> w[i];
        sum += w[i];
    }
    int ans=1e9;
    int now=0;
    for(int i=0;i<n;i++){
        now += w[i];
        ans=min(ans,abs(sum-now-now));
        // if(abs(sum-2*now)<=ans){
        //     ans = abs(sum-2*now);
        // }
    }
    cout << ans;
    return 0;
}
//今回の学び 
// １．絶対値にする関数abc()は引数が１つのみ。
// 
// 
// 
// 
// 
//

Measured memory_bytes: 3604
xn=input()
x,n=xn.split()
if n=='0':
  print(int(x))
else:
  p=input()
  p={int(i) for i in p.split()}
  s={i for i in range(-150,150)}
  s_p=list(s-p)
  d=[abs(i-int(x)) for i in s_p]
  print(s_p[d.index(min(d))])

Measured memory_bytes: 9220
n, q = map(int, input().split())
s = input()
a = [0] * n
for i in range(1, n):
    if s[i] == "C" and s[i-1] == "A":
        a[i] = a[i-1] + 1
    else:
        a[i] = a[i-1]
for i in range(q):
    l, r = map(int, input().split())
    print(a[r-1] - a[l-1])


Measured memory_bytes: 6060
#include<stdio.h>

int main(void){
    
 int i,x,n;
 n=100;
 for(i=1;i<n;i++){
 scanf("%d", &x);
 while( x != 0) {
   printf("Case %d: %d\n",i++,x);
   scanf("%d", &x);
}
}

return 0;
   
}



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

int main() {
    int n;cin>>n;
    vector<int> p(n),q(n);
    for (int i=0;i<n;i++)
        cin>>p[i];
    for (int i=0;i<n;i++)
        cin>>q[i];
    vector<int> r;
    for (int i=1;i<=n;i++)
        r.push_back(i);
    int a,b,c=0;
    do {
        if (p==r)
            a=c;
        if (q==r)
            b=c;
        c++;
    } while (next_permutation(r.begin(),r.end()));
    cout<<abs(a-b)<<endl;
    return 0;
}

Measured memory_bytes: 384