akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#include <stdio.h>
#include <cassert>
using namespace std;
using namespace __gnu_pbds;
typedef long long lo;
typedef pair<lo,lo> ll;//pair
typedef vector<lo> vl;  //vector of long
typedef vector<ll > vll;   //vector of pair
typedef priority_queue<lo>p_q;
typedef vector< vl > vvl;  //vector of vectors
#define X first
#define Y second
#define mp(a,b) make_pair((a),(b))
#define REP(a,b) for(lo i=(a);i<(lo)b;i++)//no need to declare variable i
#define REPE(a,b,c,d) REP(a,b)for(lo j=(c);j<(lo)d;j++)//no need to declare vaiables i,j
#define REPV(a,b,c) for((a)=b;(a)<(c);(a)++)//a is the variable
#define IREP(a,b) for(lo i=(a);i>=(b);i--)
#define IREPV(a,b,c) for((a)=b;(a)>=(c);(a)--)
#define all(v) (v).begin(),(v).end()
#define TRV(a) for(auto it : a)
#define INF 100100
#define MOD 1000000007
#define CHECK_BIT(var,pos) ((var) & (1<<(pos)))
#define pb(a) push_back((a))
//order statistic tree
typedef
tree<
  lo,
    null_type,
  less_equal<lo>,
  rb_tree_tag,
  // This policy updates nodes' metadata for order statistics.
  tree_order_statistics_node_update>
ordered_set;

/*#define gc getchar_unlocked
#define pc putchar_unlocked
inline void sprlo( lo a){
    lo i=0;
    char S[20];
    if(a==0)pc('0');
    if(a<0){
        pc('-');
        a*=-1;
    }
    while(a>0){
        S[i++]=a%10+'0';
        a=a/10;
    }
    --i;
    while(i>=0)
    pc(S[i--]);
    pc(' ');
}
inline void lprlo( lo a){
    lo i=0;
    char S[20];
    if(a==0)pc('0');
    while(a>0){
        S[i++]=a%10+'0';
        a=a/10;
    }
    --i;
    while(i>=0)
    pc(S[i--]);
    pc('\n');
}
inline lo uscan(){
    lo n=0;
    char c=gc();
    while(c<'0'||c>'9')c=gc();
    while(c<='9'&&c>='0'){
	    n=n*10+c-'0';
	    c=gc();
	}
    return n;
}*/
template<typename T> ostream& operator<< ( ostream &o,vector<T> v ) {
    if ( v.size() >0 )o<<v[0];
    for ( unsigned   i=1; i<v.size(); i++ )o<<" "<<v[i];
    return o<<endl;
}
template<typename U,typename V> ostream& operator<< ( ostream &o,pair<U,V> p ) {
    return o<<"("<<p.first<<", "<<p.second<<") ";
}
template<typename T> istream& operator>> ( istream &in,vector<T> &v ) {
    for ( unsigned   i=0; i<v.size(); i++ )in>>v[i];
    return in;
}
template<typename T> istream& operator>> ( istream &in,pair <T,T> &p ) {
    in>>p.X;
    in>>p.Y;
    return in;
}
vl visited(INF,-1);
lo res=0;
lo num=0;
vl g[INF];
lo add=0;
void dfs(lo node){
    if(visited[node]!=-1)return;
    stack<lo>s;
    s.push(node);
    visited[node]=1;
    lo cnt=1;
    lo x=0;
    while(!s.empty()){
        node=s.top();
        s.pop();
        TRV(g[node]){
            if(visited[it]==-1){
                visited[it]=1;
                s.push(it);
                cnt++;
            }
        }
    }
    add+=(cnt*(cnt-1))/2;
    res=max(res,cnt);
}
int main(){
    lo q,h,s,d;
    cin>>q>>h>>s>>d;
    if(h>2*q)h=2*q;
    if(s>2*h)s=2*h;
    if(d>2*s)d=2*s;
    lo n;
    cin>>n;
    cout<<d*(n/2)+s*(n%2);
    return 0;
}


Measured memory_bytes: 3328
def warshall_floyd(d):
    #d[i][j]=i番目の頂点からj番目の頂点までの最短距離
    for k in range(n):
        for i in range(n):
            for j in range(n):
                d[i][j] = min(d[i][j],d[i][k] + d[k][j])
    return d
import copy

n,m=map(int,input().split())
way_list=[[100 for i in range(n)] for j in range(n)]
for i in range(n):
    way_list[i][i]=0
#自分から自分の値はもちろんゼロ
#way_list[i][j]頂点iからjまでの最短距離
lists=[]
for i in range(m):
    a,b=map(int,input().split())
    way_list[a-1][b-1]=1
    way_list[b-1][a-1]=1
    lists.append((a,b))
#最短距離が100以下であれば十分到達可能
#そうでないなら到達は不可能
answer=0
for i in range(m):
    sub=copy.deepcopy(way_list)
    x,y=lists[i][0],lists[i][1]
    sub[x-1][y-1]=100
    sub[y-1][x-1]=100
    #一度この頂点がないものとして計算してみる
    P=warshall_floyd(sub)
    
    flag=True
    for i in range(n):
        for j in range(n):
            if P[i][j]>=100:
                flag=False
                #到達不可能な点が出た時→絶対必要な点
    if not flag:
        answer+=1
print(answer)

Measured memory_bytes: 46828
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/







void _main() {
    int B;
    while (cin >> B) {
        if (B == 0) return;

        int ans1 = B, ans2 = 1;
        rep(n, 2, 101010) {
            ll sm = 1LL * n * (n + 1) / 2;
            if (B < sm) break;

            int d = B - sm;
            if (d % n == 0) {
                ans1 = d / n + 1;
                ans2 = n;
            }
        }

        printf("%d %d\n", ans1, ans2);
    }
}




Measured memory_bytes: 3168
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;cin>>s;
  int m=10000000;
  for(int i=0;i<s.size()-2;i++){
    int a=s[i]-'a'+49;
    int b=s[i+1]-'a'+49;
    int c=s[i+2]-'a'+49;
    int num=100*a+10*b+c;
    m=min(m,abs(753-num));
  }
  cout<<m<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <array>
#include <algorithm>
#include <iomanip>
#include <cmath>


using namespace std;
using ull = unsigned long long;

int main()
{
    double x1, y1, x2, y2;

    cin >> x1 >> y1 >> x2 >> y2;

    auto xdist = x1 - x2;
    auto ydist = y1 - y2;

    cout << setprecision(10) << sqrt(xdist * xdist + ydist * ydist) << endl;

    return 0;
}

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

ll nck(ll n, ll k) {
    ll r = 1;
    for (ll d = 1; d <= k; ++d) {
        r *= n--;
        r /= d;
    }
    return r;
}

bool check(string s,int n,int m){
    string t=s.substr(n-1,m);
    string u=s.substr(n-1,m);
    reverse(u.begin(),u.end());
    //cout<<t<<endl;
    //cout<<u<<endl;
    if(u==t) return true;
    else return false;
}

int main(){
    //A
    /*
    int N,M;cin>>N>>M;
    if(N<=1&&M<=1) cout<<0<<endl;
    else cout<<nck(N,2)+nck(M,2)<<endl;
    */
   //B
   /*
   string s;cin>>s;
   int N=s.size();
   //string p="akasaka";
   //cout<<p.substr(5,7)<<endl;
   if(check(s,1,N)&&check(s,1,(N-1)/2)&&check(s,(N+3)/2,N-(N+3)/2+1))
        cout<<"Yes"<<endl;
   else cout<<"No"<<endl;
   */
  //C
  double L;cin>>L; //doubleにしないといけないらしい
  cout<<fixed<<setprecision(10);
  cout<<pow(L/3,3)<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
// problem b
using namespace std;
int main()
{
	int a,b;cin>>a>>b;
	for(int i=0;i<=a;++i)
	{
		int j = a-i;
		if(2*i+4*j==b)
		{
			cout<<"Yes\n";
			return 0;
		}
	}
	cout<<"No\n";
}

Measured memory_bytes: 3612
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (int)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
using vc = vector<char>;
using vvc = vector<vc>;
ll dx[4]={0,1,0,-1};
ll dy[4]={1,0,-1,0};
int main(){
  ll n,m,R;
  cin>>n>>m>>R;
  vll r(R);
  rep(i,R){
    cin>>r[i];
  }
  vvll t(n,vll(n,INF));
  rep(i,m){
    ll a,b,c;
    cin>>a>>b>>c;
    a--;
    b--;
    t[a][b]=c;
    t[b][a]=c;
  }
  rep(i,n) t[i][i]=0;
  for(int k=0;k<n;k++){
    for(int i=0;i<n;i++){
      for(int j=0;j<n;j++){
        t[i][j]=min(t[i][j],t[i][k]+t[k][j]);
      }
    }
  }
  vll f(R);
  rep(i,R) f[i]=i;
  
  ll ans=INF;
  do{
    ll cu=0;
    for(int i=0;i<R-1;i++){
      cu+=t[r[f[i]]-1][r[f[i+1]]-1];
    }
    ans=min(ans,cu);
  }while(next_permutation(f.begin(), f.end()));
  COUT(ans);
}

Measured memory_bytes: 512
#include <iostream>

using namespace std;

int max(int n, int l[]){
	int ans = -1;
	for (int i=0; i<n; i++){
		if (l[i] > ans){
			ans = l[i];
		}
	}
	return ans;
}

int sum(int n, int l[]){
	int ans = 0;
	for (int i=0; i<n; i++){
		ans += l[i];
	}
	return ans;
}

bool enough(int p, int k, int n, int l[]){
	int tmp = 0;
	int cnt = 0;
	for (int i=0; i<n; i++){
		if (tmp+l[i] > p){
			cnt++;
			tmp = l[i];
		}
		else{
			tmp += l[i];
		}
	}
	return (cnt+1 <= k);
}

int main(){

	int n;
	int k;
	int tmp;
	cin >> n;
	cin >> k;

	int l[n];
	for (int i=0; i<n; i++){
		cin >> tmp;
		l[i] = tmp;
	}

	int left = max(n,l);
	int right = sum(n,l);

	while (left != right){
		tmp = int((left+right)/2);
		if (enough(tmp, k, n, l)){
			right = tmp;
		}
		else{
			left = tmp+1;
		}
	}

	cout << right << endl;



	return 0;
}


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

using ll = long long;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using 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 << "{";
  rep(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
  for (auto val : array)
    std::cout << val << ", ";
  std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << std::setprecision(10);

  int n; std::cin >> n;
  vector<ll> a(n); rep(i, n) std::cin >> a[i];
  rep(i, n-1) {
    if (a[i] < 0)
      a[i] *= -1, a[i+1] *= -1;
  }
  ll sum = 0;
  bool exists = false;
  rep(i, n) {
    if (a[i] < 0) {
      exists = true;
      a[i] *= -1;
      sum += a[i];
    } else 
      sum += a[i];
  }
  if (exists) {
    ll mi = *min_element(rng(a));
    sum -= mi * 2;
  }
  std::cout << sum << "\n";
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define f(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(ll i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define pc(x)  __builtin_popcount (x)
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define ld long double
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod 1000000007
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >
#define flush fflush(stdout) 
#define primeDEN 727999983
#define test ll t;cin >> t; while(t--)
#define nx_pe next_permutation(s.begin(),s.end())
#define cl cout<<"\n"

    
int main()
{
   std::ios::sync_with_stdio(false);
   string s,t;
   cin>>s>>t;
   ll n=s.size(),m=t.size();
   ll dp[n+1][m+1];
   memset(dp,0,sizeof dp);
   rep(i,n+1)
   {
       rep(j,m+1)
       {
           if(i==0||j==0)
           {
               dp[i][j]=0;
           }
           else if(s[i-1]==t[j-1])
           {
               dp[i][j]=1+dp[i-1][j-1];
           }
           else
           {
               dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
           }
       }
   }
   
   string ans="";
   ll i=n,j=m,id=dp[n][m];
   while(i>0&&j>0)
   {
       if(s[i-1]==t[j-1])
       {
           ans+=s[i-1];
           i--,j--,id--;
       }
       else if(dp[i-1][j]>dp[i][j-1])i--;
       else j--;
   }
   reverse(all(ans));
   cout<<ans;
   
}














Measured memory_bytes: 70656
//#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <complex>
#include <iomanip>
#include <queue>
//定数
#define MOD 1000000007
//マクロ
#define rep(i,n)    for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))

#define vsort(v) sort((v).begin(), (v).end());

typedef unsigned long long int ull;
typedef long long lint;

using namespace std;




int main(){
    int r, D, x;
    


    //入力
    cin >> r >> D >> x;

    rep(i,10) x = r*x-D, cout << x << endl;

    return 0;
}

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

int main(){
  int a, b, c, k;
  cin >> a >> b >> c >> k;
  int t = 0;
  while(a >= b){ 
    b *= 2;
    t++;
  }
  while(b >= c){ 
    c *= 2;
    t++;
  }
  if(t <= k) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

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

A = list(map(int,input().split()))

flag = "APPROVED"

for i in range(N):

    if A[i] % 2 == 0 and A[i] % 3 != 0 and A[i] % 5 != 0:
        flag = "DENIED"
        break

print (flag)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define oo 0x3f3f3f3f

ll dp[2002];

int main()
{
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    ll s,mod=1e9+7;
    cin>>s;
    dp[0]=1;

    for(int i=0; i<s; i++)
    for(int x=3; x+i<=s; x++)
    {
        dp[x+i]+=dp[i];
        dp[x+i]%=mod;
    }

    cout<<dp[s];
}


Measured memory_bytes: 3648
using System;

namespace arc062_b
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            int p = 0;
            for (int i = 0; i < s.Length; i++)
            {
                if (s[i] == 'p')
                {
                    p++;
                }
            }
            Console.WriteLine(s.Length / 2 - p);
        }
    }
}

Measured memory_bytes: 3032
def main():
    N = int(input())
   # N , M , A , B = list(map(int,input().split()))
    T,A = list(map(int,input().split()))
    H = list(map(int,input().split()))
    diff = []
    for i in H:
        diff.append(abs(A - (T - i*0.006)))
    print(diff.index(min(diff)) + 1)
    
if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
import functools
MOD = 10**9 + 7
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))

def list_lcm(l):
    return functools.reduce(lcm,l)

g = list_lcm(A)

B = [g //a for a in A]
print(sum(B) % MOD)



Measured memory_bytes: 263140
#include <iostream>
#include <vector>
#define INF 2e+18
#define int long long
using namespace std;

signed main(){
	int n,t,q,a[100000],d[100000],stop[100000];
	vector<int> vec;
	cin >> n >> t >> q;
	for(int i = 0;i < n;i++){
		cin >> a[i] >> d[i];
		if(d[i] == 2) d[i] = -1;
		stop[i] = INF;
	}
	for(int i = 0;i < n - 1;i++){
		if(d[i] != d[i + 1]) vec.push_back((a[i] + a[i + 1]) / 2);
	}
	int pos = vec.size() - 1;
	for(int i = n - 1;i >= 0;i--){
		if(d[i] == 1) continue;
		while(pos >= 0){
			if(vec[pos] < a[i]){
				stop[i] = a[i] - vec[pos];
				break;
			}
			pos--;
		}
	}
	pos = 0;
	for(int i = 0;i < n;i++){
		if(d[i] == -1) continue;
		while(pos < vec.size()){
			if(vec[pos] > a[i]){
				stop[i] = vec[pos] - a[i];
				break;
			}
			pos++;
		}
	}
	for(int i = 0;i < q;i++){
		int p;
		cin >> p; p--;
		cout << a[p] + min(t,stop[p]) * d[p] << endl;
	}
	return 0;
}

Measured memory_bytes: 5888
import std.stdio, std.conv, std.array, std.string;
import std.algorithm;
import std.container;
import std.range;
import core.stdc.stdlib;
import std.math;

void main() {
  auto S = readln.chomp;
  writeln(S == "Sunny" ? "Cloudy" : S == "Cloudy" ? "Rainy" : "Sunny");
}


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

#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define MOD 1000000007
#define cey ce("Yes")
#define cen ce("No")
#define ceY ce("YES")
#define ceN ce("NO")

int dp[1100][1100];
char field[1100][1100];
int main()
{
	int H, W;
	cin >> H >> W;
	fx(H) {
		string s;
		cin >> s;
		fy(W) {
			field[x + 1][y + 1] = s[y];
		}
	}
	dp[1][0] = 1;
	fx(H) {
		fy(W) {
			if (field[x + 1][y + 1] == '#') { continue; }
			dp[x + 1][y + 1] = dp[x][y + 1] + dp[x + 1][y];
			dp[x + 1][y + 1] %= MOD;
		}
	}
	ce(dp[H][W])

    return 0;
}



Measured memory_bytes: 5632
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cout << #x << ": " << x << endl
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define endl '\n'

int gcd(int a, int b){ return ((b == 0) ? a : gcd(b, a % b)); }

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	string s;
	cin >> s;
	int mn = 1e9;
	rep(i, s.size()){
		if(i + 2 >= s.size()) break;
		int num = (s[i] - '0') * 100 + (s[i + 1] - '0') * 10 + (s[i + 2] - '0');
		mn = min(mn, abs(753 - num));
	}
	cout << mn << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


Measured memory_bytes: 256
if __name__ == '__main__':
    NT = input().split()
    N = int(NT[0])
    # print(N)
    T = int(NT[1])
    # print(T)
    t = input().split()
    s = 0
    for k in range(N-1):
        tmp = int(t[k+1]) - int(t[k])
        if tmp > T:
            s += tmp-T
    print( int(t[N-1]) + T - s )

Measured memory_bytes: 20856
#include<iostream>
#include<cstdio>
using namespace std;
int main(){
  int n,m,a,b,c,d,COST[101][101],TIME[101][101];
  while(1){
    for(int i=0;i<101;i++){
      for(int j=0;j<101;j++){
	COST[i][j] = TIME[i][j] = 1000000;
      }
    }

    cin >> n >> m;
    if(n==0&&m==0)break;
    for(int i=0;i<n;i++){
      cin >> a >> b >> c >> d;
      COST[a][b] = COST[b][a] = c;
      TIME[a][b] = TIME[b][a] = d;
    }
    for(int i=1;i<=m;i++){
      for(int j=1;j<=m;j++){
	for(int k=1;k<=m;k++){
	  if(COST[j][k]>COST[j][i]+COST[i][k]){
	    COST[j][k]=COST[j][i]+COST[i][k];
	  }
	  if(TIME[j][k]>TIME[j][i]+TIME[i][k]){
	    TIME[j][k]=TIME[j][i]+TIME[i][k];
	  }
	}
      }
    }
    cin >> m;
    for(int i=0;i<m;i++){
      cin >> a >> b >> c;
      cout << (c==0?COST[a][b]:TIME[a][b]) << endl;
    }
  }
}
			    

Measured memory_bytes: 1236
#include <iostream>
using namespace std;
typedef long long ll;
ll dp[64][101], M=1e9+7;
ll f(int x, int y){
    if(y==0)return 1;
    if(dp[x][y]!=-1)return dp[x][y];
    int a=(x/16)%4, b=(x/4)%4, c=x%4;
    ll r=f(b*16+c*4, y-1);
    r += f(b*16+c*4+3, y-1);
    r%=M;
    if(b!=0||c!=1)r+=f(b*16+c*4+2, y-1);
    r%=M;
    if(!(b==0&&c==2)&&
       !(b==2&&c==0)&&
       !(a==0&&b==2)&&
       !(a==0&&c==2)
    ){
        r += f(b*16+c*4+1, y-1);
        r%=M;
    }
    return dp[x][y]=r;
}
int main() {
    int n;
    cin >> n;
    for(int i=0;i<64;i++){
        for(int j=0;j<101;j++){
            dp[i][j] = -1;
        }
    }
    cout << f(63, n) << endl;
	return 0;
}

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

vector<bool> primes;
const int MAXV = 1e5;

int main()
{
    int n, m;
    cin >> n >> m;
    vector<int> list(n);
    vector<bool> hlist(n, true);
    for (int i = 0; i < n; i++) {
        cin >> list[i];
    }

    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        if (list[a] <= list[b]) hlist[a] = false;
        if (list[b] <= list[a]) hlist[b] = false;
    }

    int ans = 0;
    for (int i = 0; i < n; i++) {
        if (hlist[i]) {
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3768
#include <algorithm>
#include <bitset>
//#include <boost/multiprecision/cpp_int.hpp>
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstring>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <sstream>
#include <stdio.h>
#include <string>
#include <tuple>
#include <vector>
// namespace mp = boost::multiprecision;
using namespace std;
using ull = unsigned long long;
using ld = long double;
// using ll = boost::multiprecision::cpp_int;
using ll = long long;
#define FOR(i, N) for(ll i = 0; i < N; ++i)

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
// using int = ll;
ll gcd(ll m, ll n) {
    if(n == 0)
        return abs(m);
    return (gcd(n, m % n));
}
void putYN(bool b) {
    if(b) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}
void swap(ll &a, ll &b) {
    ll tmp = a;
    a = b;
    b = tmp;
}
ll combi(ll n, ll k) {
    ll r = 1, rr = 1;
    for(ll i = 0; i < k; ++i) {
        r *= (n - i);
        rr *= (i + 1);
        // r %= 1000000007;
        // rr %= 1000000007;
    }
    r /= rr;
    // r %= 1000000007;
    return r;
}
int main() {
    string S,T;
    cin >> S >>T;
    ll num=0;
    if(S[0]==T[0])
      num++;
    if (S[1] == T[1])
      num++;
    if (S[2] == T[2])
      num++;
    cout<<num<<endl;
    return 0;
}


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

#define rep_(v, f, l) for (int v = (f); v < (l); ++v)
#define rep(v, n) rep_(v, 0, n)
#define lep(v, n) rep_(v, 1, n + 1)

using namespace std;

typedef long long int lint;

static inline int in(){ int x; scanf("%d", &x); return x; }
static inline lint inl(){ lint x; scanf("%lld", &x); return x; }

struct UF {
    vector<int> data;
    UF(int n) : data(n, -1) {}
    bool merge(int x, int y){
        x = root(x);
        y = root(y);
        if (x != y){
            if (data[y] < data[x]) swap(x, y);
            data[x] += data[y];
            data[y] = x;
        }
        return x != y;
    }
    bool isSame(int x, int y){
        return root(x) == root(y);
    }
    int root(int x){
        return data[x] < 0 ? x : data[x] = root(data[x]);
    }
    int size(int x){
        return -data[root(x)];
    }
};

int main()
{
    int w, h;
    while (w = in(), h = in()){
        UF uf(w * h);
        int sx, sy;
        sx = in() - 1;
        sy = in() - 1;
        int gx, gy;
        gx = in() - 1;
        gy = in() - 1;
        int n = in();
        int field[128][128] = {};
        rep(i, n){
            int c, d, x, y;
            c = in();
            d = in();
            x = in() - 1;
            y = in() - 1;
            rep(j, 4) rep(k, 2){
                if (!d) field[y + k][x + j] = c;
                else field[y + j][x + k] = c;
            }
        }
        rep(i, h){
            rep(j, w){
                if (i + 1 < h && field[i][j] == field[i + 1][j]){
                    uf.merge(i * w + j, i * w + j + w);
                }
                if (j + 1 < w && field[i][j] == field[i][j + 1]){
                    uf.merge(i * w + j, i * w + j + 1);
                }
            }
        }

        if (uf.isSame(sy * w + sx, gy * w + gx)){
            puts("OK");
        }
        else {
            puts("NG");
        }
    }
    return (0);
}

Measured memory_bytes: 1276
import java.util.*;

public class Main {
  private static final int INF = 1_000_000_000;
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int[][] S = new int[N][N];
    for (int i = 0; i < N; i++) {
      String s = sc.next();
      for (int j = 0; j < N; j++) {
        char c = s.charAt(j);
        if (c == '1') {
          S[i][j] = 1;
        } else if (i == j) {
          S[i][j] = 0;
        } else {
          S[i][j] = INF;
        }
      }
    }
    
    int[] v = new int[N];
    v[0] = 1;
    if (!dfs(S, v, 0)) {
      System.out.println(-1);
      return;
    }
    
    for (int k = 0; k < N; k++) {
      for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
          S[i][j] = Math.min(S[i][j], S[i][k]+S[k][j]);
        }
      }
    }
    int max = 0;
    for (int i = 0; i < N; i++) {
      for (int j = 0; j < N; j++) {
        if (S[i][j] != INF) {
          max = Math.max(max, S[i][j]);
        }
      }
    }
    System.out.println(max+1);
  }
  
  private static boolean dfs(int[][] S, int[] v, int n) {

    for (int i = 0; i < v.length; i++) {
      if (S[n][i] != 1) {
        continue;
      }
      if ((v[n] == 1 && v[i] == 1) || (v[n] == 2 && v[i] == 2)) {
        return false;
      }
      if (v[i] == 0) {
        v[i] = v[n] == 1 ? 2 : 1;
        if (!dfs(S, v, i)) {
          return false;
        }
      }
    }
    return true;
  }
}

Measured memory_bytes: 25552
#include<bits/stdc++.h>
using namespace std;
int n, m, k, x, ans, ansa, ansb, ja, jb;
long long a[200010], b[200010], bj[200010];
void dfs(int i, int j, int num){
//	printf("aa");
//	if(i > n || j > m) return;
//	if(bj[num][t]) return;
//	bj[num][t] = 1;
	if(num <= ans) return;
	if(a[i] + b[j] <= k){
		if(ans < i+j) ans = i+j;
		return;
	}
	dfs(i-1, j, num-1);
	dfs(i, j-1, num-1);	
}
int main(){
	scanf("%d%d%d", &n, &m, &k);
	for(int i = 1; i <= n; i++){
		scanf("%d", &a[i]);
		a[i] += a[i-1];
		if(a[i] <= k) ja = i;
	}//	printf("%d %d\n", ja, jb);
	for(int i = 1; i <= m; i++){
		scanf("%d", &b[i]);
		b[i] += b[i-1];
		if(b[i] <= k) jb = i;
	}
	for(int i = 0; i <= ja; i++){
		x = upper_bound(b+1, b+1+jb, k - a[i]) - b - 1;
		if(ans < x+i) ans = x+i;
	}
	printf("%d", ans);
	return 0;
} 

Measured memory_bytes: 6924
#include<stdio.h>
int main()
{
	int l,n,i,sum = 0, answer = 0,flag = 0;
	scanf("%d %d",&n,&l);
	int f[n];
	for(i=0;i<n;i++)
	{
		f[i] = l + i;
	}
	for(i=0;i<n;i++)
	{
		sum += f[i];
	}
	for(i=0;i<n;i++)
	{
		if(f[i] == 0)
			flag = 1;
	}
	if(flag == 1)
		answer = sum;
	else if(sum < 0)
		answer = sum - f[n-1];
	else
		answer = sum - f[0];

	printf("%d\n",answer);
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define ll long long int 
#define endl '\n'
#define INF 1000000000
#define MOD 1000000007
#define MAX 100000000 
#define mp make_pair
#define pb push_back
using namespace std;
map<int,int> m;
int gcd(int a,int b)
{
	if(b==0)
	return a;
	else
	return gcd(b,a%b);
}
bool primeFactors(int n)  
{  
    bool f=0;  
    while (n % 2 == 0)  
    {
    	if(f==0)
    	{
    		m[2]++;
    		f=1;
    	}
    	if(m[2]==2)
    	{
    		return 1;
    	}
        n = n/2;  
    }  
    
    for (int i = 3; i <= sqrt(n); i = i + 2)  
    {
    	f=0;
        while (n % i == 0)  
        {  
            if(f==0)
            {
            	m[i]++;
            	f=1;
            }
            if(m[i]==2)
            {
            	return 1;
            }
            n = n/i;  
        }  
    }  
    if (n > 2)  
    {
    	m[n]++;
    	if(m[n]==2)
    	return 1;
    } 
    return 0;
}
int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    int a,g;
    bool f=0,q=0;
    for(int i=0;i<n;i++)
    {
    	cin>>a;
    	if(i==0)
    	{
    		g=a;
    	}
    	else
    	{
    		g=gcd(g,a);
    	}
    	if(q==0)
    	{
    		f=primeFactors(a);
    		if(f==1)
    		{
    			q=1;
    		}
    	}
    }
    if(q==0)
    {
    	cout<<"pairwise coprime"<<endl;
    }
    else
    if(g==1)
    {
    	cout<<"setwise coprime"<<endl;
    }
    else
    cout<<"not coprime"<<endl;
}


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

int n;
set < ll > s;
vector < ll > v;

int main(){
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		ll tmp;
		scanf("%lld",&tmp);
		if(s.find(tmp)!=s.end()){
			s.erase(s.find(tmp));
			v.push_back(tmp);
		}
		else s.insert(tmp);
	}
	int l=v.size();
	if(l>=2){
		sort(v.begin(),v.end());
		printf("%lld\n",v[l-1]*v[l-2]);
	}
	else printf("0\n");
}

Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long n;
  cin >> n;
  long long cnt = 1LL;
  for(long long i = 1; i*i <= n; i++){
    if(n%i == 0) cnt = i;
  }
  cout << cnt + n/cnt - 2 << 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();
        long s = 0L;
        Map<Long, Integer> map = new HashMap<Long, Integer>();
        map.put(0L, 1);
        long ans = 0L;
        for (int i = 0; i < n; i++) {
            s += sc.nextLong();
            if(map.containsKey(s)) ans += map.get(s);
            if(!map.containsKey(s)) map.put(s, 1);
            else map.put(s, map.get(s) + 1);
        }
        System.out.println(ans);
        sc.close();

    }

}


Measured memory_bytes: 100772
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <cstring>

/* 
PascalCase  クラス名
camelCase   メソッド名，関数名，変数名
snake_case  ファイル名，名前空間，std のメソッド名，変数名，型名に準じる場合
SNAKE_CASE	マクロ名，static const 定数，列挙体
*/

#define REP(i, n) for (int i = 0; i < (n); i++)
#define FOR(i, init, n) for(int i = init; i < (n); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define Cout(obj) cout << obj << endl
#define Size(obj) (int)(obj).size()
#define fcout cout << fixed << setprecision(10)
#define fi first
#define se second

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

const int MOD = 1e9 + 7;
const int iINF = 1e9;
const long long int llINF = 1e18;
const double PI = acos(-1.0);

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

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

    return gcd(b, a % b);
}

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

    ll W, H, C;
    cin >> W >> H >> C;

    ll _gcd = gcd(H, W);

    Cout(W / _gcd * H / _gcd * C);

    return 0;
}


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

int main(){
	double n;
  	cin >> n;
  	double count;
  
  	for(int i=1;i<=n;i++){
    	if(i%2!=0){
          count++;
        }
    }
  	double temp = count/n;
  	cout << temp << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
    int number;
    cin >> number;
    if( number % 100 <= 12 && number % 100 != 0 ){//下二つがつき

      if( number/100 <=12 && number/100 != 0 ){//上もつき
        cout << "AMBIGUOUS" <<endl;
      }
      else if(number / 100 >12 || number / 100 == 0){//上が年
        cout << "YYMM" <<endl;
    }
    else{
      cout << "NA" << endl;
    }
  }
    else{//下が年

      if( number/100 <=12 && number != 0 ){
        cout << "MMYY" <<endl;
    }
    else{
      cout << "NA" << endl;
    }
  }
    return 0;
}


Measured memory_bytes: 256
import math

def prime_check(x): #x>=2
    if x==2:
        return True,2
    elif x%2==0:
        return False,2
    else:
        limit=int(math.sqrt(x))
        for factor in range(3,limit+1,2):
            if x%factor==0:
                return False,factor
        return True,x


def prime_factorization(x): #x>=2
    factor_list=[]
    factor_dictionary={}
    factor_set=set()
    judge,factor=prime_check(x)
    while True:
        factor_list.append(factor)
        if factor in factor_set:
            factor_dictionary[factor]+=1
        else:
            factor_dictionary[factor]=1
            factor_set.add(factor)

        if judge:
            return factor_list,factor_dictionary,factor_set
            break
        else:
            x//=factor
            judge,factor=prime_check(x)


N=int(input())
ans=0
for i in range(1,N+1,2):
    List,Dict,Set=prime_factorization(i)
    Total=1
    while Set:
        element=Set.pop()
        Total*=Dict[element]+1
    if Total==8:
        ans+=1

print(ans)




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

char s[11][1010];
int main() {
	int n,m,k;
	scanf("%d%d%d", &n,&m,&k);
	for(int i=0; i<n; i++) scanf("%s", s[i]);
	int ans=1e9;
	for(int x=0;x<(1<<(n-1));x++) {
		int res=__builtin_popcount(x);
		int cnt[11]={};
		for(int j=0; j<m; j++) {
			int g=0, me[11]={};
			for(int i=0; i<n; i++) {
				me[g]+=(s[i][j]-'0');
				if ( x&(1<<(i)) ) g++;
			}
			bool ok=true, cut=false;
			for(int i=0; i<=g; i++) {
				if ( me[i]>k ) {ok=false; break;}
				if ( cnt[i]+me[i]>k ) cut=true;
			}
			if (!ok) {
				res+=1000000;
				break;
			}
			if (cut) {
				res++;
				for(int i=0; i<=g; i++) cnt[i]=me[i];
			} else {
				for(int i=0; i<=g; i++) cnt[i]+=me[i];
			}
		}
		ans=min(ans, res);
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 256
MOD = 10**9+7

N,K = map(int,input().split())
A = list(map(int,input().split()))
A.sort()

ans = 0

numer = [0 for _ in range(N+1)]
numer[0] = 1
inv = [0 for _ in range(N+1)]
inv[0] = 1

for i in range(N):
    numer[i+1] = numer[i]*(i+1)%MOD

for i in range(N):
    inv[i+1] = inv[i]*pow(i+1,MOD-2,MOD)%MOD

for i in range(N-K+1):
    ans += (A[N-i-1]-A[i])*numer[N-i-1]*inv[K-1]*inv[N-i-1-K+1]%MOD

print(ans%MOD)


Measured memory_bytes: 64808
# coding: utf-8
# Your code here!

    
count = int(input())
math = list(map(int,input().split()))
lis = [0] * count

for i in range(count - 1):
    lis[math[i] - 1] += 1
    
for j in range(count):
    print(lis[j])
    

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

int main() {
  int N;
  cin >> N;
  int x = 0;

  for (int i = 0; i < N; i++){
    int l, r;
    cin >> l >> r;
    x += r-l+1;
   
  }
  
  cout << x << endl;
  
  }
  
      
    

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

int main() {
  int N;
  cin >> N; 
  if(N<1 || N>100){
    return 0;
  }
  map<string, vector<pii>> M;
  for(int i=0; i<N; ++i){
    string name;
    int point;
    cin >> name >> point;
    // cout << name << " " << point << endl;
    if(point<0 || point>100){
      return 0;
    }
    //cout << name << " " << M[name].size() << endl;
    // setの要素: (レストラン番号, 評価)
    M[name].push_back(make_pair(i+1, point));
  }
  //cout << "M.size() = " << M.size() << endl;
  for(auto P: M){ // P.first: 市名, P.second: set
    if(P.second.size()>1){
      sort(P.second.begin(), P.second.end(),
           [](const pii &x, const pii &y){return x.second > y.second;});
    } 
    for(auto p: P.second){
      //cout << typeid(p).name() << endl;
      //cout << p.first << " " << p.second << endl;
      cout << p.first << endl;
    }
    //cout << typeid(S).name() << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <numeric>
#include <cmath>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define FILL(a,x); REP(i,sizeof(a)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define FILL2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define Liny "Yes\n"
#define Linn "No\n"
#define LINY "YES\n"
#define LINN "NO\n"
#define PI 3.141592653589793

//cout << setfill('0') << right << setw(4) << 12; // "0012"
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
ll sum(ll a[],ll N){ return accumulate(a,a+N,0LL);}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a/gcd(a,b)*b;}

int main(){
  double a,b,c; cin>>a>>b>>c;
  c  = c*PI/180;
  double S = a*b*sin(c)/2;
  double L = a+b+ sqrt(a*a+b*b-2*a*b*cos(c) );
  double h = b*sin(c);
  printf("%.5f\n",S);
  printf("%.5f\n",L);
  printf("%.5f\n",h);
}


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;

#define F first
#define S second
#define PB push_back
#define MK make_pair
#define REP(i, a, b) for (int i=a; i < b; i++)


bool sort_by(pi c, pi d){
	return c.S > d.S;
}

int main() {
	int N, K;
	cin >> N >> K;
	map<int, int> m;
	int tmp;
	REP(i, 0, N){
		cin >> tmp;
		++m[tmp];
	}
	
	vector<pi> v;
	for(auto i:m){
		v.PB(make_pair(i.first, i.second));
	}
	sort(v.begin(), v.end(), sort_by);
	
	int total = 0, ans = 0;
	for(auto i:v){
		total += 1;
		if(total > K) ans+=i.second;
		//cout << i.first << " " << i.second<< endl;
	}
	cout << ans;

}


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

using namespace std;

#define ll long long
#define endl '\n'

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n, k, ans = 0;
    cin >> n >> k;
    while (n != 0) {
        ans++;
        n /= k;
    }
    cout << ans << endl;
    return 0;
}

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

int main(void) {
	int a, b, c, d, e, f;
	double x, y;
	while (scanf("%d%d%d%d%d%d", &a, &b, &c, &d, &e, &f) != EOF) {
		x = (double)(c*e - b*f) / (a*e - b*d);
		y = (double)(c*d - a*f) / (b*d - a*e);
		if (fabs(x) < 1e-3) x = 0;
		if (fabs(y) < 1e-3) y = 0;

		printf("%.3f %.3f\n", x, y);
	}
	return 0;
}

Measured memory_bytes: 636
import math
K = int(input())
ans = 0
for a in range(1, K+1):
  for b in range(1, a+1):
    for c in range(1, b+1):
      if a != b and b != c and c != a:
        ans += math.gcd(math.gcd(a,b),c) * 6
      elif a == b and b == c:
        ans += math.gcd(math.gcd(a,b),c)
      else:
        ans += math.gcd(math.gcd(a,b),c) * 3
print(ans)


Measured memory_bytes: 9180
import math

def gcd(a, b):
    while b != 0:
        a, b = b, a % b
    return a

def lcm(a, b):
    return a // gcd(a, b) * b

a, b, c, d = map(int, input().split())
ran = b - a + 1

def count(x):
    r = ran if a % x == 0 else ran - (x - a % x)
    return r // x if r % x == 0 else r // x + 1

count1 = count(c)
count2 = count(d)
e = lcm(c, d)
count3 = count(e)
print(ran - (count1 + count2 - count3))


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

#define rep(i, l, r) for (ll i = (l); i <= (r); i++)
#define irep(i, r, l) for (ll i = (r); i >= (l); i--)
#define vec(t) vector<t>

using namespace std;
using ll = long long;
using vecint = vec(int);
using vecll = vec(ll);

const ll MOD = 1e9+7;

ll const maxn = 2e5 + 1;
ll fac[maxn];
ll ifac[maxn];

ll gcd(ll x, ll y, ll &a, ll &b) {
    if (x==0) {
        a = 0;
        b = 1;
        return y;
    } else {

        ll r = gcd(y%x, x, a, b);
        // gcd = [y-y/x]*a + x*b
        //     = ya - (y/x)*x*a + x*b
        b = (b - (y/x)*a);
        swap(a,b);

        return r;
    }
}

ll inverse(ll x) {
    ll a, b;
    gcd(x, MOD, a, b);

    return (a+MOD) % MOD;
}

ll ways(int w, int h) {
    if (w<=0 || h<=0) return 1;
    ll p1 = fac[(w + h)]  * ifac[w];
    p1 %= MOD;
    p1 *= ifac[h];
    p1 %= MOD;
    return p1;
}

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

    fac[0] = 1;
    rep(i, 1, 2e5) {
        fac[i] = (fac[i-1] * i) % MOD;
        ifac[i] = inverse(fac[i]);
    }



    int H, W, A, B;
    cin >> H >> W >> A >> B;

    int h= H - A;
    ll tt = 0;
    rep(l, B+1, W) {
        ll www = ways(l-1, h-1) * ways(W-l, H-(h+1));
        tt = (tt + (www)%MOD ) % MOD;
    }

    cout << tt << endl;
}

Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF=1e18,MOD=1e9+7;
const int iINF=1e9;
bool judge_odd(char c){
    if(c=='R'||c=='U'||c=='D'){
        return true;
    }
    else return false;
}
bool judge_even(char c){
    if(c=='L'||c=='U'||c=='D'){
        return true;
    }
    else return false;
}
int main(){
    bool flag=true;
    string s;
    cin>>s;
    for(int i=0;i<s.size();i++){
        if(i%2==0){
            if(!judge_odd(s[i])){
                flag=false;
            }
        }
        else{
            if(!judge_even(s[i])){
                flag=false;
            }
        }
    }
    if(flag)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S; cin >> S;
  if(S[0]==S[1] && S[1]==S[2] && S[2]==S[3]) cout << "Yes" << endl;
  else if(S[0]==S[1] && S[1]==S[2]) cout << "Yes" << endl;
  else if(S[1]==S[2] && S[2]==S[3]) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

int main() {
  int X;
  int k=0, l=0, m=0;

  int a, b, c;

  cin>>X;


  while (X%2==0)
  {
    X/=2;
    k++;

    if (k>=3)
    {
      break;
    } 
  }

  while (X%3==0)
  {
    X/=3;
    l++;

    if (l>=2)
    {
      break;
    } 
  }

  while (X%5==0)
  {
    X/=5;
    m++;

    if (m>=1)
    {
      break;
    }
  }

  cout<<8/pow(2,k)*9/pow(3,l)*5/pow(5,m);
  
}


Measured memory_bytes: 4072
//in the name of god
#include <bits/stdc++.h>
using namespace std;
#define MAX_N (int)1e5+20
#define INF 1e9+20
#define pb push_back
#define F first
#define S second
typedef long long LL;
typedef pair<int,int> pii;
const int delta=(int)1e9+7;
string s,t,r; set<string>ans;
bool ac(){
	for(int i=0;i<s.size();++i){
		bool b=1;
		for(int j=0;j<t.size();++j){
			if(i+j>s.size() || (s[i+j]!='?' && s[i+j]!=t[j])){
				b=0;
				break;
			}
		}
		if(b){
			r="";
			for(int j=0;j<i;++j) r+=s[j];
			for(int j=i;j<i+t.size();++j) r+=t[j-i];
			for(int j=i+t.size();j<s.size();++j){
				if(s[j]=='?') r+='a';
				else r+=s[j];
			}
			ans.insert(r);
		}
		if(s[i]=='?') s[i]='a';
	}
	return ans.size()>0;
}
int main(){
	ios_base::sync_with_stdio(false); cin.tie(0);
	cin>>s>>t;
	if(ac()) cout<<*ans.begin();
	else cout<<"UNRESTORABLE";
	return cout<<endl,0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define SIZE 200005
#define INF 1000000005LL
#define MOD 1000000007

using namespace std;
typedef long long ll;
typedef pair <int,int> P;

int N;
ll a[SIZE],b[SIZE];
ll bt[30][SIZE];
ll t[30];
int ans[30];

/*
void f(){
	ll res=0;
	rep(i,0,N) rep(j,0,N) {
		res ^= (a[i]+b[j]);
	}
	cout << res << endl;
}
*/


int main()
{
	cin >> N;
	rep(i,0,N)cin >> a[i];
	rep(i,0,N)cin >> b[i];

	//下処理
	t[0] = 1;
	rep(i,1,30)t[i] = t[i-1]*2;
	rep(i,1,30){
		rep(j,0,N) bt[i][j] = b[j] % t[i];
		sort(bt[i],bt[i]+N);
	}

	rep(i,0,N){
		rep(k,1,30){
			ll at = a[i]%t[k];
			int c = lower_bound(bt[k],bt[k]+N,t[k-1]-at)-bt[k];
			int d = lower_bound(bt[k],bt[k]+N,2*t[k-1]-at)-bt[k];
			int e = lower_bound(bt[k],bt[k]+N,3*t[k-1]-at)-bt[k];
			int f = lower_bound(bt[k],bt[k]+N,4*t[k-1]-at)-bt[k];
			d -= c;
			f -= e;
			ans[k] += (d+f)%2;
			ans[k] %= 2;
		}
	}
	ll res = 0;
	rep(i,1,30){
		res += ans[i]*t[i-1];
	}
	cout << res << endl;
	//f();


	return 0;
}


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

      String s = sc.nextLine();

      if(s.equals("SUN")){
        System.out.println(7);
      }
      if(s.equals("MON")){
          System.out.println(6);
        }
        if(s.equals("TUE")){
          System.out.println(5);
        }
        if(s.equals("WED")){
          System.out.println(4);
        }
        if(s.equals("THU")){
          System.out.println(3);
        }
        if(s.equals("FRI")){
          System.out.println(2);
        }
        if(s.equals("SAT")){
          System.out.println(1);
        }




  }
}


Measured memory_bytes: 20820
#include <stdio.h>

int counter(int *data,int b,int e,int k){
    int i;
    int count=0;
     for (i=b;i<e;++i){
     if (data[i]==k) count++;
     //printf("%d %d\n",data[0],data[4]);
     }
    return (count);
}

int main(){

    int i,n=1000,q=1000,ans[1000],e,b,k;
    int data[1000];
   
    for(i=0;i<5;++i){
	    data[i]=i; 
	}     
  
    //ans=counter(data,1,2,5);
    
    //printf ("ans= %3d",ans);


    scanf("%d",&n);
     
    
    for(i=0;i<n;++i){
	    scanf("%d",&data[i]); 
	}
	
    scanf("%d",&q);	
    
    for(i=0;i<q;++i){
	    scanf("%d",&b); 
	    scanf("%d",&e);
	    scanf("%d",&k);
	    ans[i]=counter(data,b,e,k);
	    //printf("ans= %d",ans);
	}	

    for(i=0;i<q;++i){
	    printf("%d\n",ans[i]); 
	}
    
    return 0;
}


Measured memory_bytes: 2108
import java.util.*;
public class Main {
	public static void main(String args[]){
    	Scanner s = new Scanner(System.in);
    	int N = s.nextInt();
      	int W = s.nextInt();
      	int wt[] = new int[N];
      	int ct[] = new int[N];
      	for(int i=0;i<N;i++){
        	wt[i] = s.nextInt();
          	ct[i] = s.nextInt();
        }
      	int ans = ans(wt,ct,W,N);
      	System.out.println(ans);
    }
  	public static int ans(int[] wt, int[] ct, int W, int N){
      	if(N<=0)
          	return 0;
      	int sum_value = 0;
      	for(int i=0;i<N;i++)
        	sum_value+=ct[i];
      	
      	long dp[] = new long[sum_value+1];
     	Arrays.fill(dp,Integer.MAX_VALUE);
      	dp[0] = 0;
        for(int i=0;i<N;i++){
      		for(int v=sum_value;v>=ct[i];v--){
              	
            	dp[v] = Math.min(dp[v], dp[v-ct[i]]+wt[i]);
            }
        }
        int max = 0;
      	for(int i=1;i<=sum_value;i++){
        	if(dp[i]<=W){
            	max = Math.max(max, i);
            }
        }
      	return max;
    }
}

Measured memory_bytes: 22228