akhauriyash/Code-Regression huggingface dataset:
N = int(input())
if N == 0:
    print("0")
else:
    ans = []
    p = 1
    while 2**(p-1) <= abs(N):
        if N%(2**p) > 0:
            ans.append("1")
            N -= (-2)**(p-1)
        else:
            ans.append("0")
        p += 1

    print("".join(ans[::-1]))


Measured memory_bytes: 38384
#include<iostream>
#include<queue>

using namespace std;

int main(){

  int n;
  cin >> n;
  
  int data[n+1][n+1];
  
  for(int i = 0; i <= n; i++){
    for(int j = 0; j <= n; j++){
      data[i][j] = 0;
    }
  }
  
  int from, to, conesum;
  
  for(int i = 0; i < n; i++){
    cin >> from >> conesum;
    for(int j = 0; j < conesum; j++){
      cin >> to;
      data[from][to] = 1;
    }
  }
  //graph end  
  


  int sumpake;
  cin >> sumpake;
  
    queue<int> Q;

    int ttl, myposi, min, sumin, sumina, finish = 0;

    int come[n+1];

    for(int i = 0; i < sumpake; i++){
    for(int i = 0; i < n+1; i++) come[i] = 0;
      min = 0;
      cin >> from >> to >> ttl;
      myposi = from;
      come[myposi] = 1;
      for(int j = 0; j < ttl; j++){
	if(j != 0){
	  for(int l = 0; l < sumina; l++){
	    if(Q.front() == to){
	      min = j;
	      finish = 1;
	      break;
	    }
	    myposi = Q.front();
	    Q.pop();
	    if(come[myposi] == 0){
	      for(int k = 1; k <= n; k++){
		if(data[myposi][k] == 1) {
		  Q.push(k);
		  sumin++;
		}
	      }
	    }
	    come[myposi] = 1;
	  }
	  if(finish == 1) break;
	}else{
	  sumin = 0;
	  for(int k = 1; k <= n; k++){
	    if(data[myposi][k] == 1) {
	      Q.push(k);
	      sumin++;
	    }
	  }
	  
	}
	  sumina = sumin;
	  sumin = 0;
      }
      
      if(min == 0) cout << "NA";
      else cout << min+1;
      cout << endl;
      finish = 0;
      while(!Q.empty()) Q.pop();
    }

  return 0;
}

Measured memory_bytes: 0
n, m = input().split()
n, m = int(n), int(m)
C = [int(c) for c in input().split()]

# Coin Changing Problem
T = [0] + [float('inf')] * n

for c in C:
    for j in range(c, n+1):
        T[j] = min(T[j], T[j - c] + 1)

print(T[-1])

Measured memory_bytes: 7524
import java.util.Scanner;

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

        while(true){
            int h = sc.nextInt();
            int w = sc.nextInt();

            if(h == 0 && w == 0){
                break;
            }
            for(int i = 0; i < h; i++){
                for(int j = 0; j < w; j++){
                    if(i % 2 == 0){
                        if(j % 2 == 0){
                            System.out.print("#");
                        }else{
                            System.out.print(".");
                        }
                    }else{
                        if(j % 2 == 0){
                            System.out.print(".");
                        }else{
                            System.out.print("#");
                        }
                    }
                }
                System.out.println();
            }
            System.out.println();
        }
    }
}


Measured memory_bytes: 35512
#include<bits/stdc++.h>
using namespace std;
inline void rd(int &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(int x){
  char f[10];
  int m=0, s=0;
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
template<class S, class T> inline S chmin(S &a, T b){
  if(a>b){
    a=b;
  }
  return a;
}
int N;
int K;
int H[100000];
int main(){
  int i, res;
  rd(N);
  rd(K);
  {
    int Lj4PdHRW;
    for(Lj4PdHRW=0;Lj4PdHRW<N;Lj4PdHRW++){
      rd(H[Lj4PdHRW]);
    }
  }
  sort(H, H+N);
  res = 1073709056;
  for(i=K-1;i<N;i++){
    chmin(res, H[i] - H[i-K+1]);
  }
  wt_L(res);
  wt_L('\n');
  return 0;
}
// cLay varsion 20190715-1

// --- original code ---
// int N, K, H[1d5];
// {
//   int i, res;
// 
//   rd(N,K,H(N));
//   sort(H, H+N);
// 
//   res = int_inf;
//   rep(i,K-1,N) res <?= H[i] - H[i-K+1];
//   wt(res);
// }


Measured memory_bytes: 640
using System;
using System.Linq;
using System.ComponentModel;
using System.Collections.Generic;

namespace ConsoleApp1 {
    public class Class {
        static void Main(string[] args) {
            var K = long.Parse(Console.ReadLine());
            var m = 7 % K;
            var ans = 1;
            while (m != 0) {
                if (K % 2 == 0 || K % 5 == 0) {
                    ans = -1;
                    break;
                }
                m = (m * 10 + 7) % K;
                ans++;
            }
            Console.Write(ans);
        }
    }
}

Measured memory_bytes: 27520
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define Fast_IO ios::sync_with_stdio(false);
#define fir first
#define sec second
#define mod 998244353
#define ll long long
inline int read()
{
	char ch=getchar(); int nega=1; while(!isdigit(ch)) {if(ch=='-') nega=-1; ch=getchar();}
	int ans=0; while(isdigit(ch)) {ans=ans*10+ch-48;ch=getchar();}
	if(nega==-1) return -ans;
	return ans;
}
typedef pair<int,int> pii;
int add(int x,int y){return x+y>=mod?x+y-mod:x+y;}
int sub(int x,int y){return x-y<0?x-y+mod:x-y;}
int mul(int x,int y){return 1LL*x*y%mod;}

signed main()
{
#ifdef __LOCAL__
	freopen("in.txt","r",stdin);
#endif
	int n,m,ans=0;
	cin>>n>>m;
	while(n)
	{
		ans++;
		n/=m;
	}
	cout<<ans<<endl;
#ifdef __LOCAL__
	cout<<"Time Used : "<<clock()<<endl;
#endif
	return 0;
}



Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AtCode
{
    class Class1
    {
        static void Main(string[] args)
        {
            string A = Console.ReadLine();
            string B = Console.ReadLine();
            string C = Console.ReadLine();
            char Next = new char();
            char Winner = new char();
            Next = A[0];
            A = A.Remove(0, 1);

            for(int i = 0; i < 300; i++)
            {
                if(Next == 'a')
                {
                    if (A.Length == 0)
                    {
                        Winner = 'A';
                        break;
                    }
                    if (A.Length != 0)
                    {
                        Next = A[0];
                        A = A.Remove(0, 1);

                    }
                    

                }
                else if(Next == 'b')
                {
                    if (B.Length == 0)
                    {
                        Winner = 'B';
                        break;
                    }
                    if (B.Length != 0)
                    {
                        Next = B[0];
                        B = B.Remove(0, 1);

                    }
                }
                else if(Next == 'c')
                {
                    if (C.Length == 0)
                    {
                        Winner = 'C';
                        break;
                    }
                    if (C.Length != 0)
                    {
                        Next = C[0];
                        C = C.Remove(0, 1);

                    }
                }
            }
            Console.WriteLine(Winner);
        }

       
    }
    
}

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

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

  vector<vector<bool>> s(M, vector<bool>(N));
  rep(i, M) {
    int k;
    cin >> k;
    rep(j, k) {
      int a;
      cin >> a;
      s[i][a - 1] = true;
    }
  }

  vector<int> p(M);
  rep(i, M) cin >> p[i];

  auto f = [&](auto x) {
    bool res = true;
    rep(i, M) {
      int cnt = 0;
      rep(j, N) if (x & 1 << j && s[i][j]) cnt++;
      if (cnt % 2 != p[i])
        res = false;
    }
    return res;
  };

  int ans = 0;
  rep(i, 1 << N) if (f(i)) ans++;
  cout << ans << endl;
}

Measured memory_bytes: 256
s=input()
ans=[0,0,0]
for i in range(3):
  if s[i]=='a':
    ans[0]+=1
  elif s[i]=='b':
    ans[1]+=1
  else:
    ans[2]+=1
if ans[0]==1 and ans[1]==1 and ans[2]==1:
  print("Yes")
else:
  print("No")


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

int main()
{
    int A, B, C, X;
    int i, j, k;
    int count = 0;
    cin >> A >> B >> C >> X;
    if (X / 500 < A)
    {
        A = X / 500 + 1;
    }
    if (X / 100 < B)
    {
        B = X / 100 + 1;
    }
    if (X / 50 < C)
    {
        C = X / 50 + 1;
    }

    for (i = 0; i <= A; i++)
    {
        for (j = 0; j <= B; j++)
        {
            for (k = 0; k <= C; k++)
            {
                if (500 * i + 100 * j + 50 * k == X)
                {
                    count++;
                }
            }
        }
    }

    cout << count << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ALL(A) (A).begin(),(A).end()
#define ll long long
const ll mod = 1e9+7;
const ll INF = 2*1e18;
const int inf = 1e9+7;

int main(void){
	int N,D;
	cin >> N >> D;
	int x[N][D];
	for(int i=0;i<N;i++)for(int j=0;j<D;j++){
		cin >> x[i][j];
	}
	int ans = 0;
	for(int i=0;i<N;i++){
		for(int b=i+1;b<N;b++){
			int temp = 0;
			for(int c=0;c<D;c++){
				temp += (x[i][c]-x[b][c])*(x[i][c]-x[b][c]);
			}
			for(int i=1;i<=100000;i++){
				if(i*i==temp)ans++;
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
#include<set>
#include<iomanip>
#include<map>
#include<type_traits>
using namespace std;


typedef long long ll;
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)

const int mod = 1000000007;



int main(){
  int h, w;
  cin >> h >> w;
  vector<string> s(h);
  rep(i, h) cin >> s[i];

  vector<vector<int> > cnt(h, vector<int>(w, 0));

  rep(i, h){
    vector<bool> done(w, false);
    rep(j, w){
      int len = 1;
      if(done[j] == true) continue;
      if(s[i][j] == '#')  continue;

      while(len + j < w){
        if(s[i][j + len] == '#') break;
        len += 1;
      }
      
      rep(k, len){
        cnt[i][j + k] += len;
        done[j + k] = true;
      }
    }
  }

    rep(j, w){
    vector<bool> done(h, false);
      rep(i, h){
        int len = 1;
        if(done[i] == true) continue;
        if(s[i][j] == '#')  continue;

        while(len + i < h){
          if(s[i + len][j] == '#') break;
          len += 1;
        }
        
        rep(k, len){
          cnt[i + k][j] += len;
          done[i + k] = true;
        }
    }
  }

  int ans = 0;
  rep(i, h){
    rep(j, w){
      ans = max(ans, cnt[i][j] - 1);
    }
  }

  cout << ans << endl;

}

Measured memory_bytes: 20096
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<queue>
#include<bitset>
#include<complex>
#include<cmath>
using namespace std;
template<typename __T>
inline void read(__T &x)
{
    x=0;
    int f=1;char c=getchar();
    while(!isdigit(c)){if(c=='-')	f=-1;c=getchar();}
    while(isdigit(c))	{x=x*10+c-'0';c=getchar();}
    x*=f;
}
int n,a,b;
int s[300005];
int blo[300005];
int main()
{
	read(n);
	read(a);
	read(b);
	if(n==1)
	{
		if(a==1 && b==1)
			printf("1\n");
		else
			printf("-1\n");
		return 0;
	}
	if(a==1)
	{
		if(b==n)
			for(int i=n;i>=1;i--)
				printf("%d ",i);
		else
			printf("-1");
		printf("\n");
		return 0;
	}
	if(b==1)
	{
		if(a==n)
			for(int i=1;i<=n;i++)
				printf("%d ",i);
		else
			printf("-1");
		printf("\n");
		return 0;
	}
	if(a+b>n+1)
	{
		printf("-1\n");
		return 0;
	}
	if(a+b==n+1)
	{
		for(int i=n-a+1;i<=n;i++)
			printf("%d ",i);
		for(int i=n-a;i>=1;i--)
			printf("%d ",i);
		return 0;
	}
	if(1ll*a*b<n)
	{
		printf("-1\n");
		return 0;
	}
	int rem=n;
	for(int i=1;i<=b;i++)
	{
		blo[i]++;
		rem--;
	}
	for(int i=1;i<=b;i++)
	{
		if(rem==0)	break;
		while(blo[i]!=a && rem)
		{
			blo[i]++;
			rem--;
		}
	}
	rem=-1;
	for(int i=1;i<=b;i++)
	{
		for(int j=n-rem-blo[i];j<n-rem;j++)
			printf("%d ",j);
		rem+=blo[i];
	}
	printf("\n");
	return 0;
}

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



int main() {
  ll a, ans;
  double b;
  cin >> a >> b;
  int ib = b*100 + 0.5;
  ans = (a*ib)/100;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3752
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    int nn ;
    cin >> nn;
   string s;
   cin >> s;
   vector<int>vec;
   bool mrk = 0;
   for(int i=0; i<s.size(); i++)
   {
       if(s[i]=='W'){vec.push_back(i);mrk = 1;}
   }
   if(!mrk)cout << 0 << endl;
   else
   {
       int in= 0,cnt = 0;
       for(int j=s.size()-1; j>=0; j--)
       {
           if(s[j]=='R'){
            if(vec[in]<j)
            {
                cnt++;
                swap(s[vec[in++]],s[j]);
                if(in>=j)break;
                if(in>=s.size())break;
            }
            else
            {
                break;
            }
           }
       }
       cout << cnt <<  endl;
   }

}


Measured memory_bytes: 4436
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;

#define rep(i,n) for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define NP next_permutation
#define pb push_back
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef multiset<ll> S;
typedef priority_queue<ll> PQ;
typedef priority_queue<P,vector<P>,greater<P>> SPQ;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;

const ll inf=1001001001001001;
const int INF=1001001001;
const int mod=1000000007;

template<class T> bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T> void decimal(T a){cout<<fixed<<setprecision(a);}
template<class T> void out(T a){cout<<a<<endl;}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<endl;}
template<class T> void outvp(T v){rep(i,v.size())outp(v[i]);}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<endl;}
template<class T> void outvv(T v){rep(i,v.size()){rep(j,v[i].size()){if(j)cout<<' ';cout<<v[i][j];}cout<<endl;}}

void YesNo(bool a){if(a) out("Yes"); else out("No");}
void yesno(bool a){if(a) out("yes"); else out("no");}
void YESNO(bool a){if(a) out("YES"); else out("NO");}
ll GCD(ll a,ll b){if(b==0) return a; return GCD(b,a%b);}
ll LCM(ll a,ll b){return(a/GCD(a,b))*(b/GCD(a,b))*GCD(a,b);}
ll POW(ll a,ll b){ll c=1; while(b>0){if(b&1){c=a*c %mod;}a=a*a %mod;b>>=1;}return c;}
vi calc(ll x){vi res; while(x>0){res.eb(x%10);x/=10;}reverse(all(res)); return res;}

void solve() {
  int a,b,m;
  cin>>a>>b>>m;
  vi p(a),q(b),v;
  // vector<PP> data;
  rep(i,a) cin>>p[i];
  rep(i,b) cin>>q[i];
  rep(i,m){
    int x,y,c;
    cin>>x>>y>>c;
    // data[i]=make_tuple(x,y,c)
    v.eb(p[x-1]+q[y-1]-c);
  }
  sort(all(p));
  sort(all(q));
  v.eb(p[0]+q[0]);
  sort(all(v));
  out(v[0]);
}

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


Measured memory_bytes: 2936
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,b,a) for(int i=b;i>=a;i--)
#define fori(a) for(auto i : a )
#define all(a) begin(a), end(a)
#define set(a,b) memset(a,b,sizeof(a))
#define sz(a) a.size()
double pi=acos(-1);
#define ll long long
#define ull unsigned long long
#define pb push_back
#define PF push_front //deque
// #define mp make_pair
#define pq priority_queue
const ll mod=1000000007;
#define f first
#define s second
#define pii pair< ll, ll >
#define vi vector<int>
#define vpii vector<pii>
#define debug(v) for(auto i:v) cout<<i<<" ";
#define tc int t; cin >> t; while(t--)

using namespace boost::multiprecision;
using namespace std;
void optimizeIO(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}


const int N=1000005;
ll fact[N],invfact[N];
ll power(ll x,ll y){
  if(y<=0) return 1LL;
  ll z=power(x,y/2);
  if(y%2) return (((z*z)%mod)*x)%mod;
  return (z*z)%mod;
}

void pre(){
  fact[0]=invfact[0]=invfact[1]=fact[1]=1;
  rep(i,2,N) fact[i]=(i*fact[i-1])%mod;
  rep(i,2,N) invfact[i]=(invfact[i-1]*power(i,mod-2))%mod;
}
ll nCr(ll n,ll k){ return (((fact[n]*invfact[n-k])%mod)*invfact[k])%mod; }



const int N1=1e6+1;
vector<int> isprime(N1,1),prime;
void seive(){
  rep(i,2,sqrt(N1)+1){
      if(isprime[i]){
        for(int j=i*i;j<N1;j+=i) isprime[j]=0;
        prime.pb(i);
      }
  }
  rep(i,sqrt(N1)+1,N1) if(isprime[i]) prime.pb(i);
}



struct dsu {
    vector<int> par, rank;
    dsu(int n): par(n+1), rank(n+1) {
        for (int i = 0; i <= n; i++) {
            par[i] = i;
            rank[i]= 1;
        }
    }
    int root(int a) {
        if (a == par[a]) return a;
        return par[a] = root(par[a]);
    }
    void merge(int a, int b) {
        a = root(a);
        b = root(b);
        if (a == b) return;
        if (rank[a] > rank[b]) swap(a, b);
        par[b] = a;
    }
    set<int> parent(int n){
        set<int> s;
        for(int i=1;i<=n;i++){
            s.insert(root(i));
        }
        return s;
    }
};

void solve(){

  ll n,x,m;
  cin>>n>>x>>m;
  ll last=x;
  map<ll,ll> m1;
  vector<ll> v1;
  v1.push_back(last);
  m1[last]=0;
  int idx=-1,idx2=-1;
  rep(i,1,n){
    last=(last*last)%m;
    if(last==0) break;
    if(m1.find(last)!=m1.end()){
      idx=m1[last];
      idx2=i;
      break;
    }
    else{
      m1[last]=i;
      v1.push_back(last);
    }
  }
  ll ans=accumulate(v1.begin(),v1.end(),0LL);
  if(idx2!=-1 ){
    ll cycle_sum=accumulate(v1.begin()+idx,v1.end(),0LL);
    ll len=v1.size()-idx;
    ll l=n-idx2;
    ll num=l/len,num2=l%len;
    ans=ans+cycle_sum*num+accumulate(v1.begin()+idx,v1.begin()+idx+num2,0LL);
    cout<<ans<<endl;
  }
  else cout<<ans<<endl;
}

int main(){
    optimizeIO();
    int r=1;
    // pre();
    {solve();}
}


Measured memory_bytes: 10540
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep1(i,n) for(int i=1; i<=(n); ++i)
#define repi(i,a,b) for(int i=a; i<=(b); ++i)
#define rrep(i,n) for(int 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 pr(x) cout<<(x)<<'\n'
#define debug(x) cout << #x << ": " << (x) << '\n'
#define yes "Yes"
#define no "No"
using namespace std;
using ll = long long;
using Edge = pair<int,long long>;
using Graph = vector<vector<Edge>>;
typedef pair<int,int> 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);}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};


int main(){
    string S;
    cin >> S;
    string odd = "RUD", even = "LUD";
    int ct = 0;
    
    rep(i,sz(S)){
        if((i%2) && even.find(S[i]) != -1) ct++;
        if(!(i%2) && odd.find(S[i]) != -1) ct++;
    }
    if(ct==sz(S)) pr("Yes");
    else pr("No");
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void)
{
  int a;
  int b;
  int c;
  int d;
  cin>>a;
  cin>>b;
  cin>>c;
  cin>>d;
  int win=0;
  
  while(1){
    c-=b;
    
    if(c<=0){
      win=1;
      break;
    }
    else {
      a-=d;
      if(a<=0){
        win=0;
        break;
      }
    }
  }
  
  if(win){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
}

Measured memory_bytes: 3636
import java.util.Scanner;

public class Main {
    public static void main(String... args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();

        int d = a / b;
        int r = a % b;
        double f = (double)a / b;
        System.out.println(d + " " + r + " " + String.format("%.5f",f));
    }
}



Measured memory_bytes: 26488
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <string>
#include <vector>
#include <cstdlib>
#include <utility>
#include <map>

using namespace std;

int main(){
    string s;
    cin >> s;
    long long int k;
    cin >> k;
    
    char ans = '1';
    int count = 0;
    
    for(int i = 0; i < s.size(); i++){
        if(s[i] != '1'){
            ans = s[i];
            break;
        }else{
            count++;
        }
    }
    if(k <= count){
        cout << '1';
    }else{
        cout << ans;
    }
}

Measured memory_bytes: 256
import math
A,B,H,M = map(int,input().split())
omega_h = 360 / (12*60)
omega_m = 360 / 60

min_sum_h = (H*60 + M) * omega_h
min_sum_h = min_sum_h % 360
min_sum_m = M * omega_m

if min_sum_h - min_sum_m > 180:
    omega = 360 - (min_sum_h - min_sum_m)
else:
    omega = min_sum_h - min_sum_m

cos_omega = math.cos(math.radians(omega))
res = (A**2 + B**2 - 2*A*B*cos_omega)**0.5
print("{:.20f}".format(res))

Measured memory_bytes: 9520
#include<bits/stdc++.h> 
 using namespace std;
 int main(){
  int n,a,b;
  cin>>n;
  if(n==1)
  {
  	cout<<"Hello World";
  }
  else
  {
  	cin>>a>>b;
  	cout<<a+b;
  }
 return 0; 
  }

Measured memory_bytes: 256
count = 0
s = list(str(input()))

if s[0] == s[1]:
    if s[2] == s[3]:
        count = 1
elif s[0] == s[2]:
    if s[1] == s[3]:
        count = 1
elif s[0] == s[3]:
    if s[1] == s[2]:
        count = 1

if s[0] == s[1] == s[2] == s[3]:
    count = 0

if count == 1:
    print("Yes")
else:
    print("No")

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

int main() {
  int n;
  ll x;
  cin >> n >> x;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];
  ll ans = 0;
  rep(i, n-1){
    ll num1 = a[i];
    ll num2 = a[i + 1];
    if(num1 + num2 > x){
      ll gap = num1 + num2 - x;
      ans += gap;
      if(num2 - gap < 0) {
        num2 = 0;
        num1 -= gap - num2;
      }else {
        num2 -= gap;
      }
    }
    a[i] = num1;
    a[i + 1] = num2;
  }
  cout << ans << endl;
}

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

typedef long long ll;

int main()
{
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    
    int a[3];
    cin >> a[0] >> a[1] >> a[2];
    sort(a, a+3);
    if(a[0] == 5 && a[1] == 5 && a[2] == 7) cout << "YES\n";
    else cout << "NO\n"; 
    return 0;
}



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

using namespace std;

#define _for(i,j,N) for(int i = (j);i < (N);i++)
#define _rep(i,j,N) for(int i = (j);i <= (N);i++)
#define ALL(x) x.begin(),x.end()
#define pb push_back
#define LL long long
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

template<typename T>
ostream& operator<<(ostream& os,const vector<T>& v) {
    _for(i,0,(int)(v.size()-1)) os << v[i] << " ";
    os << v[v.size()-1];
    return os;
}

template<typename T>
ostream& operator<<(ostream& os,const set<T>& v){
    for(typename set<T>::iterator it = v.begin();it != v.end();it++)
    os << *it <<" ";
    return os;
}
const int maxn = 5005;
int N;
LL A[maxn];
vector<int> G[maxn];
LL res = 0;

struct Cmp{
    bool operator()(const int &a,const int &b)const{
        return A[a] > A[b];
    }
};

const LL INF = 1e16;
LL dp[maxn][maxn][2];
LL aux[maxn][2];
int child[maxn];

void dfs(int u,int p){
    for(int j : G[u]){
        if(j == p) continue;
        dfs(j,u);
    }
    if(A[u] > 0){
        dp[u][0][0] = A[u];
    }else dp[u][0][1] = A[u];

    _for(i,0,maxn) _for(j,0,2) aux[i][j] = INF;
    int sum = 1;
    child[u] = 1;

    for(int v: G[u]){
        if(v == p) continue;
        _for(i,0,sum){
            _for(j,0,child[v]){
                _for(k1,0,2) _for(k2,0,2){
                    //if(v == 5) cout <<"j:"<<j << "val:"<<dp[5][j][0] <<endl;
                    if(dp[v][j][k2] < 0 || (!k2 && dp[v][j][k2] < INF)){
                        chmin(aux[j+i+1][k1],dp[u][i][k1]);
                    }
                    chmin(aux[i+j][k1|k2],dp[u][i][k1] + dp[v][j][k2]);

                }
            }
        }
        child[u] += child[v];
        sum += child[v];

        _for(i,0,maxn) _for(j,0,2){
            dp[u][i][j] =aux[i][j];
            aux[i][j] = INF;
        }

    }
}

int main()
{
    cin >> N;
    _rep(i,1,N){
        cin >> A[i];
    }

    _for(i,0,N-1){
        int u,v;
        cin >> u >> v;
        G[u].push_back(v);
        G[v].push_back(u);
    }

    _for(i,0,maxn) _for(j,0,maxn) _for(k,0,2) dp[i][j][k] = INF;
    _for(i,0,maxn) _for(k,0,2) aux[i][k] = INF;

    dfs(1,-1);
    int ans = maxn;
    _for(i,0,maxn){
        if(dp[1][i][1] < 0) chmin(ans,i);
        //cout << dp[1][i][1] << endl;
    }
    _for(i,0,maxn){
        if(dp[1][i][0] < INF) chmin(ans,i);
        //cout << child[i] <<endl;
    }
    //cout << dp[4][2][1] << endl;

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 392576
#include<bits/stdc++.h> 
using namespace std; int main()
 { long long int a,b,c,d,i;
     string s,ss;
     cin>>s; cin>>a; 
    if(s[0]=='1'&&a==1) { cout<<s[0]<<endl;} 
    
   else
    {
    
    for(i=0;i<s.size();i++)
    {
       if(s[i]!='1')
          {break;}
    }
   if(i!=s.size())
    {
     if(a>i)cout<<s[i];
            else cout<<"1";
    }
    else
        cout<<"1"<<endl;
} }

Measured memory_bytes: 256
///******* In the name of Allah *******///

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

int main ()
{
    int c,m,n,i,j,k,l;
    char a[113],b[113];
    cin>>n;
    cin>>a>>b;
    for(i=0;i<n;i++)
    {
        cout<<a[i]<<b[i];
    }

    return 0;
}


Measured memory_bytes: 256
/*	ex3_2
	L40S38	*/
#include<stdio.h>
int main(void){
    int n, r;
    scanf("%d",&n);
    //nはいろはちゃんが数えようとしている数（本）
    r=n%10;//rはnの1の位の数
    if(r==3){
        printf("bon");
    }else if(r==0||r==1||r==6||r==8){
        printf("pon");
    }else{
        printf("hon");
    }
    return 0;
}

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


int main() {
  int H, W;
  cin >> H >> W;
  while (H != 0 || W != 0) {
    rep(i,H) {
      rep(j,W) {
        cout << '#';
      }
      cout << endl;
    }

    cout << endl;
    cin >> H >> W;
  }

  return 0;
}


Measured memory_bytes: 3116
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

pub fn read_n<T: FromStr>(n: usize) -> Vec<T> {
    read_n_logic::<T>(n, vec![])
}

pub fn read_n_logic<T: FromStr>(n: usize, mut a: Vec<T>) -> Vec<T> {
    match n {
        0 => a,
        _ => {
            a.push(read::<T>());
            read_n_logic(n - 1, a)
        }
    }
}

use std::cmp::{max, min};

const MOD: u64 = 1_000_000_007;

fn prime_factors(a: i64) -> Vec<i64> {
    let mut p: Vec<i64> = vec![];
    let mut num = a;
    let mut d = 2;

    while num > 1 && d <= (a as f64).sqrt() as i64 {
        match num % d {
            0 => {
                p.push(d);
                num = num / d;
            }
            _ => d += 1,
        }
    }

    if num > 1 {
        p.push(num);
    }
    p
}

fn powmod(base: u64, exp: u64, m: u64) -> u64 {
    let b: Vec<bool> = format!("{:b}", exp)
        .chars()
        .map(|x| x.to_digit(10).unwrap() != 0)
        .collect();
    let mut v = 1;
    for bi in b {
        v *= v;
        v %= m;
        if bi {
            v *= base;
            v %= m
        }
    }
    return v % m;
}

fn invmod(x: u64, m: u64) -> u64 {
    powmod(x, m - 2, m)
}

fn main() {
    let max_val = 1_000_000;
    let n: usize = read();
    let a: Vec<i64> = read_n(n);
    let mut primes = vec![0; max_val];

    let mut ans = 0;
    for i in 0..a.len() {
        let ai = a[i];
        let mut prev = 0;
        let mut cnt = 0;
        for i in prime_factors(ai) {
            if i == prev {
                cnt += 1;
            } else {
                primes[prev as usize] = max(primes[prev as usize], cnt);
                prev = i;
                cnt = 1;
            }
        }
        primes[prev as usize] = max(primes[prev as usize], cnt);
    }
    let mut val = 1;

    for i in 0..primes.len() {
        let pi = primes[i];
        if pi != 0 {
            val *= powmod(i as u64, pi, MOD as u64);
            val %= MOD;
        }
    }

    let mut ans = 0;

    for i in 0..a.len() {
        let ai = a[i];
        ans += val * (invmod(ai as u64, MOD as u64) % MOD as u64);
        ans %= MOD as u64;
    }

    println!("{}", ans);
}


Measured memory_bytes: 15100
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

template <typename T> using oset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define ull unsigned long long int
#define ll long long int
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define MOD (ull)(double)(1e9 + 7)
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vb vector<bool>
#define vd vector<double>
#define vll vector<ll>
#define vpii vector<pii>
#define vpll vector<pll>
#define vvi vector<vi>
#define vvll vector<vll>
#define vs vector<string>
#define pull pair<ull, ull>
#define F first
#define S second
#define m_p make_pair
#define debug(x) cout << #x << " " << x << endl
#define printArr(a, start, end)for(int i=start ; i<end ; ++i)cout << a[i] << " ";cout << '\n';
#define readArr(a, start, end)for(int i=start ; i<end ; ++i)cin >> a[i];
#define read2D(mat, n, m)for(int i=0 ; i<n ; ++i)for(int j=0 ; j<m ; ++j)cin >> mat[i][j];

const long double PI = 3.141592653589793238462643383279502884197169399;

// Find Set LSB = (x&(-x)), isPowerOfTwo = (x & (x-1))

void solve(){
	ll k;
	cin >> k;
	
	if(!(k%2) || !(k%5)){
		cout << "-1";
		return;
	}
	
	int x = log10(k);
	++x;
	
	ll s=0;
	for(int i=0 ; i<x ; ++i){
		s *= 10;
		s += 7;
	}
	
	if(s < k){
		s *= 10;
		s += 7;
		++x;
	}
	
	ll cnt=x;
	set<ll> st;
	while(1){
		if(st.find(s) != st.end()){
			cout << "-1";
			return;
		}
		st.insert(s);
		ll rem = s % k;
		if(!rem)break;
		rem *= 10;
		s = rem + 7;
		cnt++;
	}
	
	cout << cnt;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	cout << fixed << setprecision(10);
	
	int tt=1;
	//cin >> tt;
	
	while(tt--){
		solve();
	}
}


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

#ifdef _DEBUG
#define debug(x) cout<<#x<<": "<<x<<endl
#else
#define debug(x)
#endif

using namespace std;

#define UNDEF (-1)

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> digits(N, UNDEF);
    for (int i = 0; i < M; ++i) {
        int si, ci;
        cin >> si >> ci;
        --si;
        if (digits[si] == UNDEF) {
            digits[si] = ci;
        } else if (digits[si] != ci) {
            cout << -1 << endl;
            return 0;
        } else {}
    }
    bool lz = true;
    for (int i = 0; i < N; ++i) {
        if (digits[i] == UNDEF) {
            if (N > 1 && lz) {
                digits[i] = 1;
            } else {
                digits[i] = 0;
            }
        }
        lz = lz && (digits[i] == 0);
    }
    if (N > 1 && digits[0] == 0) {
        cout << -1 << endl;
    } else {
        for (int i = 0; i < N; ++i) {
            cout << digits[i];
        }
        cout << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
#include <map>
#include <unordered_map>
#include <chrono>
#include <numeric>
using namespace std;
using ll = long long;
const long long INF = (long long)1e18+1;
#define DIV 1000000007

template <typename T>
inline T gcd(T a, T b) {return b ? gcd(b, a%b) : a;}

ll ngcd(vector<ll> a){
    ll res;
    res = a[0];
    for(ll i = 1; i < a.size() && res != 1; i++) {
        res = gcd(a[i], res);
    }
    return res;
}
#define TEST
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
#ifdef TEST
    chrono::system_clock::time_point start, end;
    start = chrono::system_clock::now();
#endif
    long idx=0;
    long K;
    cin >> K;
    ll total = 0;
    for(size_t i=1;i<=K; i++)
    {
        for(size_t j=1;j<=K; j++)
        {
            for(size_t k=1;k<=K; k++)
            {
                vector<ll> num={(ll)i, (ll)j, (ll)k};
                total += ngcd(num);
            }
        }
    }
    cout << total << endl;
#ifdef TEST
    end = chrono::system_clock::now();
    cerr << static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count() / 1000.0) << "[ms]" << endl;
#endif
    return 0;
}

Measured memory_bytes: 3844
#include <iostream>
#include<algorithm>
#include<string>
#include <cmath>
using namespace std;
int main()
{
	int A, B, C,D,K,X;
	X = 0;
	cin >> A >> B >> C >> D;
	cout << max({ 0,-max({A,C}) + min({B,D}) });
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

const int kMaxN = 2002;

int a[kMaxN * 3];
int f[kMaxN * 3][kMaxN * 3], p[kMaxN][kMaxN];
int n, ans;

void T0(int i, int j, int g) {  // 用g组的卡替换i
  g *= 3;
  f[j][g] = max(f[j][g], f[i][j] + (a[i] == a[g + 1] && a[i] == a[g + 2]));
  f[j][g + 1] = max(f[j][g + 1], f[i][j] + (a[i] == a[g] && a[i] == a[g + 2]));
  f[j][g + 2] = max(f[j][g + 2], f[i][j] + (a[i] == a[g] && a[i] == a[g + 1]));
}

void T1(int i, int j, int g) {  // 用g组的牌替换j
  g *= 3;
  f[i][g] = max(f[i][g], f[i][j] + (a[j] == a[g + 1] && a[j] == a[g + 2]));
  f[i][g + 1] = max(f[i][g + 1], f[i][j] + (a[j] == a[g] && a[j] == a[g + 2]));
  f[i][g + 2] = max(f[i][g + 2], f[i][j] + (a[j] == a[g] && a[j] == a[g + 1]));
}

void T2(int i, int j, int g) {  // 用g组的牌替换i和j
  g *= 3;
  f[g][g + 1] = max(f[g][g + 1], f[i][j] + (a[i] == a[j] && a[i] == a[g + 2]));
  f[g][g + 2] = max(f[g][g + 2], f[i][j] + (a[i] == a[j] && a[i] == a[g + 1]));
  f[g + 1][g + 2] = max(f[g + 1][g + 2], f[i][j] + (a[i] == a[j] && a[i] == a[g]));
}

void P() {  // 预处理
  int m = 2;
  for (int i = 3; i < 3 * n; i += 3) {           // 枚举组
    if (a[i] == a[i + 1] && a[i] == a[i + 2]) {  // 有一组相同直接消除
      ans++;
    } else {
      a[++m] = a[i], a[++m] = a[i + 1], a[++m] = a[i + 2];
    }
  }
  a[++m] = a[3 * n];  // 最后一组
  n = m / 3;
  for (int i = n; i >= 1; i--) {  // 预处理每组之后每种数字第一次出现的组
    for (int j = 1; j <= n; j++) {
      p[i][j] = p[i + 1][j];
    }
    p[i][a[i * 3]] = p[i][a[i * 3 + 1]] = p[i][a[i * 3 + 2]] = i;
  }
}

int main() {
  cin >> n;
  for (int i = 1; i <= 3 * n; i++) {
    cin >> a[i];
  }
  P();
  for (int j = 1; j < 3 * n; j++) {
    for (int i = 1; i < j; i++) {
      int g = j / 3 + 1;
      T0(i, j, g);
      T1(i, j, g);
      T2(i, j, g);
      if (p[g + 1][a[i]]) {
        T0(i, j, p[g][a[i]]);
        T2(i, j, p[g][a[i]]);
      }
      if (p[g + 1][a[j]]) {
        T1(i, j, p[g][a[j]]);
        T2(i, j, p[g][a[j]]);
      }
    }
  }
  cout << ans + f[3 * n + 1][3 * n + 2];
  return 0;
}

Measured memory_bytes: 111604
#include <iostream>
#include <stdio.h>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <set>
#include <map>
#include <math.h>
#include <bitset>
#include <vector>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

typedef long long ll;

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

ll n, k;

ll d[100000], h[100000];

int main () 
{
	cin >> n >> k;

	for (int i = 0; i < n; i++)
		scanf ("%lld", &h[i]);

	d[1] = abs (h[0] - h[1]);

	for (int i = 2; i < n; i++)
	{
		d[i] = INF;
		for (int j = i - 1; j >= max (0LL, i - k); j--)
			d[i] = min (d[i], d[j] + abs (h[j] - h[i]));
	}

	cout << d[n-1];
}

Measured memory_bytes: 1792
def main():

    n, a, b = map(int, input().split())
    mod = pow(10, 9) + 7

    p1, p2 = 1, 1
    for i in range(n-a+1, n+1):
        p1 *= i
        p1 %= mod

    for j in range(n-b+1, n+1):
        p2 *= j
        p2 %= mod
    # print(p2)

    q1, q2 = 1, 1
    g1 = [1, 1]
    g2 = [1, 1]
    inv = [0, 1]
    for i in range(2, max(a, b)+1):
        g1.append((g1[-1] * i) % mod)
        inv.append( ( -inv[mod % i] * (mod//i)) % mod )
        g2.append((g2[-1] * inv[-1]) % mod)
    q1 = g2[a] % mod
    q2 = g2[b] % mod

    memo = dict()
    memo[0] = 1
    def powmod(n, mod):
        if n in memo: return memo[n]
        memo[n//2] = powmod(n//2, mod)
        if n % 2 == 0:
            memo[n] = pow(powmod(n//2, mod), 2) % mod
        else:
            memo[n] = 2 * pow(powmod(n//2, mod), 2) % mod
        return memo[n]

    v = powmod(n, mod)
    v1 = (p1 * q1) % mod
    v2 = (p2 * q2) % mod
    # print(v, v1, v2)

    return (v-v1-v2-1) % mod
if __name__ == '__main__':
    print(main())


Measured memory_bytes: 81136
// Algorithm: Brute-force

#include "cstdio"
using namespace std;

const int maxn=30+10;
int n,c,d[maxn][maxn],t[4][maxn],x,y,z,ans;

int main()
{
    ans=0x7fffffff;    // 先把答案记为一个极大值，出现更小的就更新
    scanf("%d%d",&n,&c);

    register int i,j,k,l;
    for(i=1;i<=c;i++)
    {
        // 输入D矩阵(i-j)为颜色i变为颜色j的代价为(i,j)
        for(j=1;j<=c;j++)
        {
            scanf("%d",&d[i][j]);
        }
    }

    for(i=1;i<=n;i++)
    {
        // 输入矩阵C
        for(j=1;j<=n;j++)
        {
            scanf("%d",&x);
            t[(i+j)%3][x]++;    // 计算横坐标加纵坐标mod3的数值,颜色为x的个数+1
        }
    }

    for(i=1;i<=c;i++)
    {
        // 枚举坐标余数为0的颜色，统一变成颜色i，其代价之和为x
        // 比如例1中，坐标为1行2列的余数为(1+2)%3=0，其值2，变成i=1则D_21=1
        // 坐标2列1行的余数为(2+1)%3=0，其值为3，变成i=1则有D_31=31
        // x = D_21 + D_31 = 2
        x=0;
        for(j=1;j<=c;j++)
        {
            x+=t[0][j]*d[j][i];
        }

        for(j=1;j<=c;j++)
        {    // 枚举余数为1的颜色，统一变成颜色j,其代价之和为y
            if(j==i)
            {
                continue;    // 不同余数的颜色不能相同
            }

            y=0;
            for(k=1;k<=c;k++)
            {
                y+=t[1][k]*d[k][j];
            }

            for(k=1;k<=c;k++)
            {
                // 枚举坐标余数为2的颜色，统一变成颜色k,其代价之和为z
                if(k==j || k==i)
                {
                    continue;    // 不同余数的颜色不能相同
                }

                z=0;
                for(l=1;l<=c;l++)
                {
                    z+=t[2][l]*d[l][k];
                }

                if(ans>x+y+z)
                {
                    // 如果当前转换的代价和比之前的最优答案更小，就更新代价和
                    ans=x+y+z;
                }
            }
        }
    }

    printf("%d",ans);
    return 0;
}

Measured memory_bytes: 1712
#include <cstdio>
#include<iostream>
#include<algorithm>
 
#define NMAX 100000
#define QMAX 50000p
using namespace std;
 
int main(void){
 
    int n,q;
    long long S[NMAX],T;
    int cnt=0;
	int min,max;
    cin>>n;
 
    for(int i=0;i<n;i++){
        cin>>S[i];
    }
 
    cin>>q;
 
    for(int i=0;i<q;i++){
        cin>>T;
		min=0,max=n-1;
		while(1){
			if(S[(max+min)/2]==T){
				cnt++;
				break;
			}
			else if(S[(max+min)/2]<T){
				if(min==(max+min)/2){
					if(min+1<n){
						if(S[min+1]==T) cnt++;
					}
					break;
				}
				else min=(max+min)/2;
			}
			else if(S[(max+min)/2]>T){
				if(max==(max+min)/2) break;
				else max=(max+min)/2;
			}
		}
    }
 
    cout<<cnt<<endl;
 
    return 0;
}

Measured memory_bytes: 1948
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define int long long
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    sort(s.begin(), s.end());
    if(s[0] == s[1] && s[1] != s[2] && s[2] == s[3]) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 764
#include<iostream>
#include<cmath>

using namespace std;

int main() {
	
	int a, b, c;
	
	while( cin >> a >> b >> c) {
		
		if( a == b && b == c && c == 0)
			break;
			
		double d[4] = {};
		
		d[0] = sqrt(a * a + b * b) / 2;
		d[1] = sqrt(a * a + c * c) / 2;
		d[2] = sqrt(b * b + c * c) / 2;
		
		d[4] = min(d[0], min(d[1], d[2]));
		
		int n;
		cin >> n;
		
		for(int i=0;i<n;i++) {
			
			int r;
			cin >> r;
			
			if(r > d[4])
				cout << "OK\n";
			
			else
				cout << "NA\n";
			
		}
		
		
	}
	
	return 0;
}



Measured memory_bytes: 2932
n,w=map(int,input().split())
d={}
p=0
for i in range(n):
    a,b=map(int,input().split())
    if a in d: d[a].append(b)
    else: d[a]=[b]
    p=max(p,a)

for i in range(4):
    if p-i in d:d[p-i].sort(reverse=True)
    else: d[p-i]=[0]

l={}
for i in d:
    t=0
    l[i]=[0]
    for j in d[i]:
        t+=j
        l[i].append(t)
ans=0
for ai,i in enumerate(l[p]):
    for bj,j in enumerate(l[p-1]):
        for ck,k in enumerate(l[p-2]):
            for em,m in enumerate(l[p-3]):
                x=ai*p+bj*(p-1)+ck*(p-2)+em*(p-3)
                if x<=w:
                    ans=max(ans,i+j+k+m)
print(ans)


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

const int INF = 1e9;
const int MOD = 1e9 + 7;

using namespace std;

typedef long long ll;

#define REP(i, n) for (int i = 0; i < int(n); i++)
#define REPD(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = a; i < int(b); i++)
#define FORD(i, a, b) for (int i = b - 1; i >= int(a); i--)
#define WRAP(y, x, h, w) (0 <= y && y < h && 0 <= x && x < w)

#define ALL(x) (x).begin(), (x).end()

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

ll powmod(ll n, ll x)
{
    vector<ll> vll(32);
    vll[0] = n;
    FOR(i, 1, 32)
    {
        vll[i] = (vll[i - 1] * vll[i - 1]) % MOD;
    }
    ll ret = 1;
    int cnt = 0;
    while (x > 0) {
        if (x & 1) {
            ret = (ret * vll[cnt]) % MOD;
        }
        x >>= 1;
        cnt++;
    }
    return ret;
}

long long fac[2000001];
struct Comb {
    Comb()
    {
        fac[0] = fac[1] = 1;
        for (int i = 2; i < 2000001; i++) {
            fac[i] = fac[i - 1] * i % MOD;
        }
    }

    long long COM(int n, int k)
    {
        if (n < k)
            return 0;
        if (n < 0 || k < 0)
            return 0;
        ll ret = fac[n];
        ret = (ret * powmod(fac[k], MOD - 2)) % MOD;
        ret = (ret * powmod(fac[n - k], MOD - 2)) % MOD;
        return ret;
    }

    ll PERM(int n, int k)
    {
        if (n < k)
            return 0;
        ll ret = fac[n];
        ret = (ret * powmod(fac[n - k], MOD - 2)) % MOD;
        return ret;
    }
};

int main()
{
    
    ll n, k;
    cin >> n >> k;
    ll ans = 0;
    Comb C;
    vector<ll> end(n+2,0);
    FOR(i,1,n+2){
        end[i]=end[i-1]+n-i+1+MOD;
        end[i]%=MOD;
    }
    for (ll i = k; i <= n + 1; i++) {
        ll first=i*(i-1)/2;
        first%=MOD;
        ans += end[i]-first+MOD+1;
        ans %= MOD;
    }
    cout << ans << endl;
}

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

int main() {
  int k;
  cin>>k;
  string s;
  cin>>s;
  if(s.size()<=k){
    cout<<s<<endl;
  }else{
    for(int i=0;i<k;i++){
      cout<<s[i];
    }
    cout<<"..."<<endl;
  }
  return 0;
}


Measured memory_bytes: 3628
#include <stdio.h>

int main(void) {
	int x[100];
	int y,i;
	scanf("%d",&y);
	for(i=0;i<y;i++){
		scanf("%d",&x[i]);
	}
	for(i=0;i<y;i++){
		if(i==y-1){
			printf("%d\n",x[y-i-1]);
			break;
		}
		printf("%d ",x[y-i-1]);
	}
	return 0;
}

Measured memory_bytes: 596
#include<stdio.h>
#define MOD 1000000007;
int N, i, j;
char S[100001], c;
long long int dp[100001][4];
int main(){
	c=getchar(); while(c!=10){S[N++]=c; c=getchar();}

	for(int i = N; i >= 0; --i){
		for(int j = 3; j >= 0; --j){
			if(i == N){
				dp[i][j] = (j == 3 ? 1 : 0);
			}else{
				dp[i][j] = dp[i+1][j] * (S[i] == '?' ? 3LL : 1LL);
				if(j < 3 && (S[i] == '?' || S[i] == j+'A')){
					dp[i][j] += dp[i+1][j+1];
				}
				dp[i][j] %= MOD;
			}
		}
	}
	printf("%lld\n", dp[0][0]);
}


Measured memory_bytes: 3328
#include<cstdio>
int main(){
    float a,b,c,d,e,f,x,y;
    while(scanf("%f %f %f %f %f %f", &a, &b, &c, &d, &e, &f)!=EOF){
        x=(c*e-f*b)/(a*e-d*b);
        y=(c*d-a*f)/(b*d-e*a);
        if(x==0)    x=0;
        if(y==0)    y=0;
        printf("%.3f %.3f\n",x, y);
    }
    return 0;
}
/*int main(){
	float a,b,c,d,e,f,x,y,i,n;
	//while(cin >> a >> b >> c >> d >> e >> f){
	while(scanf("%f %f %f %f %f %f", &a, &b, &c, &d, &e, &f)!=EOF){
		x=(c*e-b*f)/(a*e-b*d);
		y=(c*d-a*f)/(b*d-a*e);
		if(x==-0) x=0;
		if(y==-0) y=0;
		printf("%.3f %.3f\n",x ,y);
	}
	return 0;
}*/


Measured memory_bytes: 2684
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
using ll = long long;

int main(){
	ll n;
	cin >> n;
	vector<char> alpha(30);
	int i=0;
	for(char moji='a';moji<='z';moji++){
		alpha[i] = moji;
		i++;
	}
	string ans = "";
	while(n != 0){
		n--;
		ans += alpha[n%26];
		n /= 26;
	}
	reverse(ans.begin(),ans.end());
	cout << ans << endl;
}


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

int main() {
  int N;
  cin >> N;
  
  vector<int> t(N);
  
  for(int i = 0; i < N; i++){
    cin >> t.at(i);
  }
  cout << (*max_element(t.begin(), t.end())) - (*min_element(t.begin(), t.end())) << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include <string>
#include<bits/stdc++.h>
#define ll long long int
#define ld long double
#define pb push_back
#define mp make_pair
#define M 1000000007
#define all(v) v.begin(),v.end()
#define fr(a,b,c) for(ll i=a;i<=b;i+=c)
#define inarr(arr,n); for(ll i=0;i<n;i++) cin >> arr[i];
#define outarr(arr,n); for(ll i=0;i<n;i++) cout<<arr[i]<<" ";
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
int main() {
    ios;
	vector <ll> a;
    for(int i=1;i<=9;i++){
        a.pb(i);
    }
    ll p=0;
    while(a.size()<1e5+5){
        ll z=a[p];
        ll d=z%10;
        ll new1=z*10+d-1;
        ll new2=z*10+d;
        ll new3=z*10+d+1;
        if(d!=0){
        a.pb(new1);
        }
        a.pb(new2);
        if(d!=9){
        a.pb(new3);}
        p+=1;
    }
    sort(a.begin(),a.end());
   ll k;
   cin>>k;
   cout<<a[k-1]<<endl;
    return 0;
}

Measured memory_bytes: 4204
package main

import "fmt"

func main() {
	var q, h, s, d, n int
	fmt.Scan(&q, &h, &s, &d, &n)

	qq := q * 40
	hh := h * 20
	ss := s * 10
	dd := d * 5

	cost := 0
	if dd < qq && dd < hh && dd < ss {
		cost += d * (n / 2)
		if n%2 != 0 {
			if qq < hh && qq < ss {
				cost += q * 4
			} else if hh < qq && hh < ss {
				cost += h * 2
			} else {
				cost += s
			}
		}
	} else {
		if qq < hh && qq < ss {
			cost += q * 4 * n
		} else if hh < qq && hh < ss {
			cost += h * 2 * n
		} else {
			cost += s * n
		}
	}
	fmt.Println(cost)
}


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

 using namespace std;
 
 int main(){
     int n; //n個のボタン
     cin >> n;
     vector<int> bt;
     for(int i = 0;i < n;i++){
         int a; //ボタンの出力先
         cin >> a;
         a--;
         bt.push_back(a);
     }
     
     int now = 0; int c = 0; //ボタンを押した回数がcount nowが現在光っているボタンの位置(添え字)
     for(;;){
         //二番目のボタンの位置の時
         if(now == 1){
             cout << c << endl;
             break;
         }
         
         //カウント数がボタン数を超えたら-1　同じ値を繰り返し出しているため、now = 1に到達できないから
         if(c >= n){
             cout << -1 << endl;
             break;
         }
         c++;
         //光っているボタンの現在位置を更新する。
         now = bt[now];
     }
     
 }


Measured memory_bytes: 3904