akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
using namespace std;
typedef long long int ll;
typedef long double ld;

#define MOD 998244353

int main(){
    ll n,t,a,ans=0,z=10000000;
    cin >> n >> t >> a;
    a*=1000;
    t*=1000;
    for (ll i=1;i<=n;i++){
        ll h,f;
        cin >> h;
        f=t-(h*6);
        if (f>a && f-a<z){
            ans=i;
            z=f-a;
        }
        if (f<=a){
            if (a-f<z){
                ans=i;
                z=a-f;
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
using namespace std;

int sum(int a) {
	return (a > 0) ? (sum(a / 10) + a % 10) : 0;
}

int main() {
	int n;
	scanf("%d", &n);
	int best = sum(1) + sum(n - 1);
	for (int a = 2; a < n; ++a) {
		int b = n - a;
		best = min(best, sum(a) + sum(b));
	}
	printf("%d\n", best);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <iomanip>
#include <cmath>
#include <map>
using namespace std;
using ll = long long;
constexpr ll MOD = 998244353;

ll mod_pow(ll x, ll e) {
  ll ret = 1;
  while(e) {
    if(e&1) ret = ret * x % MOD;
    x = x * x % MOD;
    e >>= 1;
  }
  return ret;
}

int main() {
  ll n; cin >> n;
  vector<ll> a(n+1);
  vector<ll> cnt(n+1);
  for(int i = 0; i < n; ++i) {
    cin >> a[i];
    ++cnt[a[i]];
  }
  if(cnt[0] != 1 || a[0] != 0) {
    cout << 0 << endl;
    return 0;
  }
  ll ans = 1;
  for(int i = 1; i < n; ++i) {
    if(cnt[i+1] > 0 && cnt[i] == 0) {
      cout << 0 << endl;
      return 0;
    }
    ans = ans * mod_pow(cnt[i], cnt[i+1]) % MOD;
  }
  cout << ans;
  return 0;
}


Measured memory_bytes: 1792
#include "bits/stdc++.h"

using namespace std;

#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl

typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define rep1(i,n) for(ll i=1;i<=(ll)(n);i++)
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define rrep1(i,n) for(ll i=(ll)(n);i>0;i--)
#define REP(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
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 (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = 1e18;
const ll MOD = 1000000007;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { 1,0, -1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
#define mp make_pair



int main () {
  int n;
  cin >> n;
  if (n < 1200) {
    cout << "ABC" << endl;
  }
  else if (n < 2800) {
    cout << "ARC" << endl;
  }
  else {
    cout << "AGC" << endl;
  }
}


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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

typedef bitset<300>bs;

const int mod=1000000007;
inline void add(int &a,int b){
    a+=b;
    if(a>=mod)a-=mod;
}
int mpow(int n,int m){
    int ret=1;
    while(m){
        if(m&1)ret=ret*n%mod;
        n=n*n%mod;
        m>>=1;
    }
    return ret;
}

int dp[333][333];

int po[333];
signed main(){
    po[0]=1;
    for(int i=1;i<333;i++)po[i]=po[i-1]*2%mod;
    int N;
    cin>>N;
    vector<bs>C(N);
    rep(i,N){
        rep(j,N){
            int c;cin>>c;C[i][j]=c;
        }
    }

    int r=0;
    rep(j,N){
        int k=-1;
        for(int i=r;i<N;i++)if(C[i][j]){
            k=i;
            break;
        }
        if(k==-1)continue;
        if(k!=r)swap(C[r],C[k]);
        for(int i=k+1;i<N;i++)if(C[i][j])C[i]^=C[r];
        r++;
    }



    int ans=0;
    for(int k=r;k<=N;k++){
        memset(dp,0,sizeof(dp));
        dp[0][0]=1;
        for(int i=0;i<N;i++){
            for(int j=0;j<=k;j++){
                add(dp[i+1][j],dp[i][j]*po[j]%mod);
                if(j+1<=k)add(dp[i+1][j+1],dp[i][j]*(po[k]-po[j]+mod)%mod);
            }
        }

        int tmp=1;
        for(int i=0;i<k-r;i++)tmp=tmp*(po[N-r-i]-1)%mod;
        for(int i=0;i<k-r;i++)tmp=tmp*mpow(po[k-r-i]-1,mod-2)%mod;
        tmp=tmp*dp[N][k]%mod;
        tmp=tmp*mpow(po[N-k],N)%mod;
        ans=(ans+tmp)%mod;
    }
    cout<<ans<<endl;
    return 0;
}


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

int main()
{
  int n;
  string s;
  cin >> n >> s;
  ll rnum = 0;
  ll gnum = 0;
  ll bnum = 0;
  for (int i = 0; i < n; i++) {
    if (s[i] == 'R') rnum++;
    else if (s[i] == 'G') gnum++;
    else if (s[i] == 'B') bnum++;
  }
  ll ans = rnum * gnum * bnum;
  for (int i = 0; i < n - 1; i++) {
    for (int j = i + 1; 2 * j - i < n; j++) {
      if (s[i] == s[j]) continue;
      if (s[i] == s[2 * j - i]) continue;
      if (s[j] == s[2 * j - i]) continue;
      ans--;
    }
  }
  cout << ans << endl;

  return 0;
}


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

int read()
{
	int x=0,w=1;
	char ch=getchar();
	while(ch<'0'||ch>'9')
	{
	   if(ch=='-')  w=-1;
	   ch=getchar();
	}
	while(ch>='0'&&ch<='9')
	{
	   x=x*10+ch-'0';
	   ch=getchar();
	}
	return x*w;
}

int main()
{
	int m,n,k,l;
	bool flag=false;
	k=read();
	n=read();
	m=read();
	for(int i=n;i<=m;i++)
	{
		if(i%k==0)
		{
			flag=true;
			break;
		}
	}
	if(!flag)	printf("NG\n");
	else printf("OK\n");
	return 0;	
} 

Measured memory_bytes: 3568
#include <iostream>

using namespace std;

int main(){
   int n;
   cin >> n;
   bool ans = false;

   int a;
   for(int i=0;i<n;i++){
      cin >> a;
      if(a%2!=0){
         ans = true;
      }
   }

   cout << (ans ? "first" : "second") << endl;
}

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

/**
 * 何回2で割れるか求めます
 * @param a 求めたい数
 * @return 割れる回数
 */
int divide2(int a) {
	int ans = 0;
	while ((a & 1) == 0) { // 偶数なら
		a >>= 1; // 2で割る
		ans ++;
	}
	return ans;
}
int main() {
	int N, a;
	cin >> N;
	int ans = 0;
	for (int i = 0;i < N;i ++) {
		cin >> a;
		ans += divide2(a);
	}
	cout << ans;
	return 0;
}
/*
31536000のコメント解説欄
ここテンプレで用意してるから、A問題とかだとこの先空欄の危険あり

まず、1個を除いて常に3倍する方が操作回数は増える
ということは、各aに対し2^x×奇数とすると、x回だけ操作を行える
後はこれの総和でおｋ
*/

Measured memory_bytes: 256
using System;
using System.Linq;

namespace moff4 {
    class MainClass {
        //const int max = 1000000000;
        public static void Main(string[] args) {


            var str1 = System.Console.ReadLine();
            var str2 = System.Console.ReadLine();

            var n = int.Parse(str1);
            var aList = str2.Split(' ').Select(x => int.Parse(x)).ToList();;

            Console.WriteLine(aList.Max() - aList.Min());
        }
    }
}



Measured memory_bytes: 11348
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
#include <iomanip>
#include <climits>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
//typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define revrep(i, n) for(ll i = (n)-1; i >= 0; i--)
#define pb push_back
#define f first
#define s second
#define chmin(x, y) x = min(x, y);
#define chmax(x, y) x = max(x, y);

//const ll INFL = LLONG_MAX;//10^18 = 2^60
const ll INFL = 1LL<<60;
//const int INF = INT_MAX;
const ll INF = 1 << 30;//10^9
ll MOD = 1000000007;
//ll MOD = 998244353;

vector<ll> dy = {0, 1, 0, -1, 1, 1, -1, -1, 0};
vector<ll> dx = {1, 0, -1, 0, 1, -1, 1, -1, 0};

void pres(double A, ll x = 10){cout << fixed << setprecision(x) << A << endl;}
void BinarySay(ll x, ll y = 60){rep(i, y) cout << (x>>(y-1-i) & 1); cout << endl;}
ll cnt_bit(ll x){return __builtin_popcountll(x);}

ll pow_long(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2) res *= x;
    x *= x; k /= 2;
  }
  return res;
}

ll pow_mod(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2){
      res *= x; res %= MOD;
    }
    x *= x; x %= MOD;
    k /= 2;
  }
  return res;
}

ll inverse(ll x){return pow_mod(x, MOD - 2);};

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

ll lcm(ll x, ll y){
  ll res = x / gcd(x, y);
  res *= y;
  return res;
};

//コンビネーション
const int MAXcomb = 200010;
ll fac[MAXcomb], finv[MAXcomb], inv[MAXcomb];
//facはn!,finvは1/n!
//invは逆元
void COMinit(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < MAXcomb; i++){
        fac[i] = fac[i-1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
        finv[i] = finv[i-1] * inv[i] % MOD;
    }
}
ll comb(int n, int k){
    if(n < k) return 0;
    if(n < 0 || k < 0) return 0;
    return fac[n] * finv[k] % MOD * finv[n-k] % MOD;
}

const int MAXkai = 200010;
ll kai_memo[MAXkai];
ll kai(ll N){
  if(kai_memo[N] != 0) return kai_memo[N];
  if(N <= 1) return 1;
  return kai_memo[N] = N * kai(N-1) % MOD;
}


void solve(){
  ll N;
  cin >> N;
  vector<pair<ll, ll>> seg;
  rep(i, N){
    ll X, L;
    cin >> X >> L;
    seg.pb({X+L, X-L});
  }
  sort(seg.begin(), seg.end());
  ll now = -INFL;
  ll ans = 0;
  rep(i, N){
    if(now <= seg[i].s){
      ans++;
      now = seg[i].f;
    }
  }
  cout << ans << endl;
}


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


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

#define ll long long
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
// pll pp; -> (pp.first,pp.second)
// vector<vl> pp(n,vl(2)); sort(pp.begin(),pp.end(),[](vl a,vl b){return a[0]<b[0];});

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define RREP(i,n) for(ll (i)=(n)-1;(i)>=0;(i)--)
#define FOR(i,a,b) for(ll (i)=(a);(i)<(b);(i)++)
#define FORR(i,a,b) for(ll (i)=(b)-1;(i)>=(a);(i)--)
#define DEBUG(x) cout << #x << ": " << x << endl
#define CHMAX(a,b) a=max((a),(b))
#define CHMIN(a,b) a=min((a),(b))
/*}}}*/
int main() {
  ll m,k;
  cin >> m >> k;
  ll t = 1;
  REP(i,m) t *= 2;
  if(t<=k){
    cout << -1 << endl;
    return 0;
  }
  if(m==1){
    if(k==0){
      cout << 0 << " ";
      cout << 0 << " ";
      cout << 1 << " ";
      cout << 1;
      cout << endl;
      return 0;
    }else if(k==1){
      cout << -1 << endl;
      return 0;
    }
  }
  REP(i,t){
    if(i!=k) cout << i << " ";
  }
  cout << k << " ";
  RREP(i,t){
    if(i!=k) cout << i << " ";
  }
  cout << k;
  return 0;
}


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

int main() {

    int a,b,c,d;

    cin >> a >> b >> c >> d;

    string ans = "Balanced";

    if(a+b < c+d){
        ans = "Right";
    }
    else if(a+b > c+d){
        ans = "Left";
    }

    cout << ans << endl;

    return 0;
}

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

void solve(long long N, std::vector<long long> L)
{
    sort(L.begin(), L.end());
    long long cnt = 0LL;

    for (size_t i = 0; i < N; i++)
    {
        for (size_t j = i + 1; j < N; j++)
        {
            long long r = N;
            long long l = j;
            while (r > l + 1)
            {
                long long c = (r + l) / 2LL;
                (L[i] + L[j] <= L[c] ? r : l) = c;
            };
            cnt += l - j;
        }
    }

    cout << cnt << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main()
{
    long long N;
    scanf("%lld", &N);
    std::vector<long long> L(N);
    for (int i = 0; i < N; i++)
    {
        scanf("%lld", &L[i]);
    }
    solve(N, std::move(L));
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
	int x[10000];
	int i;
	for(;;){
		scanf("%d",&x[i]);
		if(x[i] == 0) break;
		i++;
	}
	for(i=0;i<10000;i++){
		if(x[i]==0) break;
		printf("Case %d: %d\n",i+1,x[i]);
	}
	return 0;
}


Measured memory_bytes: 2032
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);
#define FO cout.tie(NULL);
#define FI cin.tie(NULL);
using namespace std;
int main()
{
    FAST
    FO
    FI
    string s;
    cin>>s;
    int q;
    cin>>q;
    int rev=0;
    string start="", end="";
    while(q--)
    {
        int t;
        cin>>t;
        if(t==1)
        {
            if(rev==0) rev=1;
            else rev=0;
        }
        else
        {
            int f;
            char c;
            cin>>f>>c;
            if(f==1)
            {
                if(rev)
                {
                    end+=c;
                }
                else
                {
                    start=c+start;
                }
            }
            else
            {
                if(rev)
                {
                    start=c+start;
                }
                else
                {
                    end+=c;
                }
            }
        }
    }
    if(rev)
    {
        for(int i=end.length()-1; i>=0; i--)
        {
            cout<<end[i];
        }
        for(int i=s.length()-1; i>=0; i--)
        {
            cout<<s[i];
        }
        for(int i=start.length()-1; i>=0; i--)
        {
            cout<<start[i];
        }
        cout<<"\n";
        return 0;
    }
    cout<<start<<s<<end<<"\n";
    return 0;
}


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

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

  if(a==b && b==c){cout<<1<<endl;}  
  else if((a==b && b!=c) || (b==c && a!=b) || (a==c && b!=c)){cout<<2<<endl;}
  else{cout<<3<<endl;}
 }

Measured memory_bytes: 256
#include<stdio.h>
int main()
{

int W,H,x,y,r;
scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
if(x>0&&y>0&&r>0)
{
    if((x+r)<=W&&y<H)
    {
        printf("Yes\n");
    }
    else{
        printf("No\n");
    }
}
    else{
        printf("No\n");
    }
    return 0;

}



Measured memory_bytes: 2128
moves = [
    {'F': lambda i, j, x: (i, min(n, j + x)), 'B': lambda i, j, x: (i, max(1, j - x))},
    {'F': lambda i, j, x: (min(m, i + x), j), 'B': lambda i, j, x: (max(1, i - x), j)},
    {'F': lambda i, j, x: (i, max(1, j - x)), 'B': lambda i, j, x: (i, min(n, j + x))},
    {'F': lambda i, j, x: (max(1, i - x), j), 'B': lambda i, j, x: (min(m, i + x), j)}]
turns = {'R': lambda i: (i + 1) % 4, 'L': lambda i: (i - 1) % 4}

while True:
    m, n = map(int, input().split())
    if not m:
        break
    i, j = 1, 1
    cci = 0
    while True:
        cmd = input()
        ch = cmd[0]
        if ch in 'FB':
            i, j = moves[cci][ch](i, j, int(cmd.split()[1]))
        elif ch in 'RL':
            cci = turns[ch](cci)
        else:
            print(i, j)
            break

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

int main(){
    int n, m;
    cin >> n >> m;
    int x[m];
    rep(i, m){
        cin >> x[i];
    }

    if(n>=m){
        cout << 0 << endl;
        return 0;
    }

    sort(x, x+m);
    int d = x[m-1] - x[0];

    if(n==1){
        cout << d << endl;
    }else{
        int dx[m-1];
        rep(i, m-1){
            dx[i] = x[i+1] - x[i];
        }
        sort(dx, dx+m-1);
        
        rep(i, n-1){
            d -= dx[m-2-i];
        }
        cout << d << endl;

    }

    return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include<math.h>
int main(void){
    double x1, y1, x2, y2;
   
    scanf("%lf %lf %lf %lf\n", &x1, &y1, &x2, &y2);
    
    printf("%.8f\n", sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)));
    
    return 0;    
}



Measured memory_bytes: 2104
import static java.lang.System.out;
import java.util.Scanner;
import java.util.Arrays;

public class Main{
   static Scanner sc = new Scanner(System.in);
   public static void main(String[] args){
      char[] s = sc.next().toCharArray();
      char[] t = sc.next().toCharArray();
      boolean flag = false;
      int tlength = t.length-1;
      Arrays.sort(s);
      Arrays.sort(t);

      int loop = Math.min(s.length,t.length);
      for(int i=0;i<loop;i++){
         if(s[i] == t[tlength]){
            tlength--;
            if(s.length < t.length && i == loop-1){
               flag = true;
               break;
            }
            continue;
         }else if(s[i] > t[tlength]){
            break;
         }else{
            flag = true;
            break;
         }
         
      }

      /**
       * パターン
       * 数値以下 break
       * 数値以上 break
       * 同じ     continue
       * 
       */
      String result = flag ? "Yes":"No"; 
      System.out.println(result);
   }
}


Measured memory_bytes: 23764
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  int n;
  cin >> n;
  vector<string> in(n);
  bool can = false;
  for (int i = 0; i < n; i++) {
    cin >> in[i];
    for (int j = 0; j < n; j++) {
      can |= in[i][j] == '#';
    }
  }
  if (!can) {
    cout << -1 << endl;
    return 0;
  }
  vector<int> col(n);
  int cnt = 0;
  for (int j = 0; j < n; j++) {
    int white = 0;
    for (int i = 0; i < n; i++) {
      if (in[i][j] == '#') col[j] = 1;
      else white++;
    }
    cnt += white > 0;
  }
  int ans = 1 << 30;
  for (int i = 0; i < n; i++) {
    int white = 0;
    for (int j = 0; j < n; j++) {
      white += in[i][j] == '.';
    }
    ans = min(ans, white + 1 - col[i]);
  }
  cout << ans + cnt << endl;
  return 0;	
}

Measured memory_bytes: 512
#include <stdio.h>

int A[50];
int n;

int solve(int i, int m)
{
	if (m == 0) return 1;
	if (i >= n) return 0;
	return solve(i + 1, m) || solve(i + 1, m - A[i]);
}

int main()
{
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
	{
		scanf("%d", &A[i]);
	}

	int q, M;
	scanf("%d", &q);
	for (int i = 0; i < q; i++)
	{
		scanf("%d", &M);
		if (solve(0, M))printf("yes\n");
		else printf("no\n");
	}

	return 0;
}


Measured memory_bytes: 2676
#include <bits/stdc++.h>
#define ll long long
#define MAX ((int)1e8 + 7)
using namespace std;

int main()
{
 ll k;
 cin>>k;
 string str="ACL";
 for(int i=0; i<k; i++){
    cout<<str;
 }

 return 0;
}


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

int main() {
  int N; cin >> N;
  int K; cin >> K;
  
  int cnt = 0;
  for(int i = 0; i < N; ++i){
    int h; cin >> h;
    if(h >= K) cnt++;
  }
  
  cout << cnt << endl;
}

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

const int mod = 1e9+7;
int dp[100010][2];

int main() {
  string s; cin >> s;
  int n = s.size();
  dp[0][0] = 1;
  for(int i = 0; i < n; i++) {
    // a + b == 0
    if(s[i] == '0') {
      dp[i+1][0] = dp[i][0];
      dp[i+1][1] = dp[i][1];
    } else {
      dp[i+1][1] = (dp[i][0] + dp[i][1]) % mod;
    }

    // a + b == 1
    if(s[i] == '0') {
      (dp[i+1][1] += (dp[i][1] * 2) % mod) %= mod;
    } else {
      (dp[i+1][0] += (dp[i][0] * 2) % mod) %= mod;
      (dp[i+1][1] += (dp[i][1] * 2) % mod) %= mod;
    }
  }
  int ans = (dp[n][0] + dp[n][1]) % mod;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1280
N,Q=map(int,input().split())
S=input()

AC=[0]*N
cnt=0
for i in range(1,N):
    if S[i-1]=="A" and S[i]=="C":
        cnt+=1
    AC[i]=cnt
        
for _ in range(Q):
    l,r=map(int,input().split())
    l-=1
    r-=1
    print(AC[r]-AC[l])

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

int main(){
  char s[5];
  scanf("%s", s);
  sort(s, s+4);
  printf((s[0]==s[1] && s[1]!=s[2] && s[2]==s[3]) ? "Yes\n": "No\n");
  return  0;
}

Measured memory_bytes: 256
#include<cstdlib>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<queue>
#include<set>
using namespace std;
const int MAXN = (int) 1500 + 10;
const int INF = (int) 0x3f3f3f3f;
typedef long long LL;

int m,n;
int h[MAXN],w[MAXN];
int cnt[1500000 + 10];

void work(){
    while(scanf("%d%d",&n,&m)&&n&&m){
        for(int i=1;i<=n;i++) scanf("%d",&h[i]);
        for(int i=1;i<=m;i++) scanf("%d",&w[i]);
        for(int i=2;i<=n;i++) h[i]+=h[i-1];
        for(int i=2;i<=m;i++) w[i]+=w[i-1];
        for(int i=1;i<=1500000;i++) cnt[i]=0;
        for(int i=0;i<n;i++){
            for(int j=i+1;j<=n;j++){
                cnt[h[j]-h[i]]++;
            }
        }
        LL ans=0;
        for(int i=0;i<m;i++){
            for(int j=i+1;j<=m;j++) ans+=cnt[w[j]-w[i]];
        }
        printf("%lld\n",ans);
    }
}

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













Measured memory_bytes: 8488
#include<cstdio>
#include<cstring>
using namespace std;

int main()
{
	int N,L,i,j,a[202],sum=0,temp,x,y=0,z=0,cha;
	scanf("%d%d",&N,&L);
	for(i=1;i<=N;++i)
	{a[i]=L+i-1;sum+=a[i];}
	for(i=1;i<=N;++i)
	{y=0;temp=0;temp-=a[i];
		for(j=1;j<=N;j++)
		{temp+=a[j];}
		cha=sum-temp;
		if(cha==0)
		{printf("%d",temp);return 0;}
		if(cha<0)
		{y=1;cha=0-cha;}
		if(i==1)
		{x=cha;}
		if(x>cha)
		{x=cha;
			if(y==1)
			{z=1;}
			else
			{z=0;}
		}
	}
	if(z==1)
	{x=0-x;}
	printf("%d",sum-x);
	return 0;
}

Measured memory_bytes: 128
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0092
"""
import sys


def find_square0(data):
    max_size = 0
    dp = [] # dp??¨???2?¬??????????
    # '.'????????????1??????'*'????????????0????????????
    for row in data:
        temp = []
        for c in row:
            if c == '.':
                temp.append(1)
            else:
                temp.append(0)
        dp.append(temp)

    # ????±?????????????????????????????????£????????????????????£?????¢????¢??????§??????????????§????????????
    for y in range(1, len(dp)):
        for x in range(1, len(dp[0])):
            if dp[y][x] == 1:
                dp[y][x] = min(dp[y-1][x-1], dp[y-1][x], dp[y][x-1]) + 1
                if dp[y][x] > max_size:
                    max_size = dp[y][x]
    return max_size


def find_square2(data):
    max_size = 0
    dp = [[0]*len(data[0]) for _ in range(len(data))] # dp??¨???2?¬???????????????¨??????0??§?????????
    # '.'????????????1???
    for y, row in enumerate(data):
        for x, c in enumerate(row):
            if c == '.':
                dp[y][x] = 1

    # (?????¨???(curr_row)??¨???????????????(prev_row)????????¢????????????????????§?????????????????????)
    prev_row = dp[0]
    for curr_row in dp[1:]:
        for x, t in enumerate(curr_row[1:], start=1):
            if t == 1:
                curr_row[x] = min(prev_row[x-1], prev_row[x], curr_row[x-1]) + 1
                if curr_row[x] > max_size:
                    max_size = curr_row[x]
        prev_row = curr_row
    return max_size


def find_square3(data):
    from array import array
    max_size = 0
    dp = [array('I', [0]*len(data[0])) for _ in range(len(data))]  # ????¬?????????????array??????????????§?¢????
    # '.'????????????1???
    for y, row in enumerate(data):
        for x, c in enumerate(row):
            if c == '.':
                dp[y][x] = 1

    prev_row = dp[0]
    for curr_row in dp[1:]:
        for x, t in enumerate(curr_row[1:], start=1):
            if t == 1:
                curr_row[x] = min(prev_row[x-1], prev_row[x], curr_row[x-1]) + 1
                if curr_row[x] > max_size:
                    max_size = curr_row[x]
        prev_row = curr_row
    return max_size


def find_square4(data):
    # 4.91[s]
    max_size = 0
    dp = [0 for _ in range(1024*1024)]
    # '.'????????????1???
    for y, row in enumerate(data):
        for x, c in enumerate(row):
            if c == '.':
                dp[y*1024+x] = 1

    # ????±?????????????????????????????????£????????????????????£?????¢????¢??????§??????????????§????????????
    for y in range(1, len(data)):
        for x in range(1, len(data)):
            if dp[y*1024+x] == 1:
                dp[y*1024+x] = min(dp[(y-1)*1024+x-1], dp[(y-1)*1024+x], dp[y*1024+x-1]) + 1
                if dp[y*1024+x] > max_size:
                    max_size = dp[y*1024+x]
    return max_size



def main(args):
    while True:
        n = int(input())
        if n == 0:
            break
        data = [input() for _ in range(n)]
        result = find_square0(data)
        print(result)


if __name__ == '__main__':
    main(sys.argv[1:])

Measured memory_bytes: 35048
import operator
import numpy as np
n = int(input())
xy = np.array([list(map(int, input().split())) for _ in range(n)])

sa1 = np.argsort(xy[:,0])
sa2 = np.argsort(xy[:,1])

s1 = xy[sa1,0]
s2 = xy[sa2,1]
c1 = s1[1:] - s1[:-1]
c2 = s2[1:] - s2[:-1]

c = [(c, (sa1[i], sa1[i+1])) for i, c in enumerate(c1)] + [(c, (sa2[i], sa2[i+1])) for i, c in enumerate(c2)]
c = sorted(c, key=operator.itemgetter(0))

total_cost = 0
sg = {}
for cost, verts in c:
    vf1 = sg.get(verts[0])
    vf2 = sg.get(verts[1])
    if vf1 and vf2:
        if vf1 is vf2: continue
        if len(vf1) < len(vf2): vf1, vf2 = vf2, vf1
        total_cost += cost
        vf1.update(vf2)
        for v in vf2: sg[v] = vf1
    else:
        total_cost += cost
        if vf1:
            vf1.add(verts[1])
            sg[verts[1]] = vf1
        elif vf2:
            vf2.add(verts[0])
            sg[verts[0]] = vf2
        else:
            sg[verts[0]] = sg[verts[1]] = set(verts)
print(total_cost)

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

int main(){
    long N;
    long number[100003] = {};
    long maxnumber = 0;
    long tempa;

    cin >> N;
    for(long i=0;i<N;i++){
        cin >> tempa;
        number[tempa]++;
        if(tempa!=0){
            number[tempa-1]++;
        }
        if(tempa!=100000){
            number[tempa+1]++;
        }
    }

    for(long i=0;i<=100000;i++){
        maxnumber = max(maxnumber,number[i]);
    }

    cout << maxnumber << endl;

    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define cyes cout<<"YES"<<endl
#define cno cout<<"NO"<<endl
#define sp <<" "<<
#define cst(x) cout<<fixed<<setprecision(x)
#define pi 3.14159265359
#define mod 1000000007
struct edge {
    int to; 
    int id;
    edge(int t, int w) : to(t),id(w) {}
};
using namespace std;
using ll = long long;
using ld = long double;
using Graph = vector<vector<edge>>;
using que_a = priority_queue<int, vector<int>, greater<int> >;
using que_d = priority_queue<int>;
using pint = pair<int,int>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main(){

    string s; cin >> s;
    rep(i,s.size()){
        if(s.at(i) == 'P') cout << 'P';
        if(s.at(i) == 'D') cout << 'D';
        if(s.at(i) == '?') cout << 'D';
    }
    cout << endl;
    return 0;
}

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

int main(){
	string s;
	cin>>s;
	if(s[0]=='S'){
		if(s[1]=='U') cout<<7;
		else cout<<1;
	}
	else if(s[0]=='M') cout<<6;
	else if(s[0]=='T'){
		if(s[1]=='U') cout<<5;
		else cout<<3;
	}
	else if(s[0]=='W') cout<<4;
	else if(s[0]=='F') cout<<2;
}

Measured memory_bytes: 3520
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <cmath>
#include <algorithm>
#include <random>
#include <chrono>
#include <iomanip>
#include <numeric>
#define lint unsigned long long int
#define FOR(x, to) for(int x=0; x<(int)(to); x++)
#define DUMP(ar) for(auto itd=begin(ar); itd != end(ar); itd++) cout << "["s << itd - begin(ar) << "]:"s << *itd << endl
#define DUMPL(ar) for(auto itd=begin(ar); itd != end(ar); itd++) { cout << *itd; if(end(ar)-itd > 1) cout << ' '; } cout << endl
#define COUT(x) cout << (x) << endl
#define VCIN(ar) for(auto &vcin: (ar)) cin >> vcin
#define ALL(ar) ar.begin(), ar.end()
#define LOOPD(i) cout << "ループ["s << i << "]回目---------------"s << endl
using namespace std;
// lint:64ビット 10^19
using P = pair<lint, string>;

struct item{
    int w;
    int v;
};

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

    int n, w;
    cin >> n >> w;
    vector<item> items(n);
    for(auto &i : items){
        cin >> i.w >> i.v;
    }

    vector<P> values_able(1'000*100+1, make_pair(numeric_limits<lint>::max(), string(n, '0')));
    for(int i=0; i<n; i++){
        if((lint)items[i].w < values_able[items[i].v].first){
            values_able[items[i].v].first = items[i].w;
            values_able[items[i].v].second = string(n, '0');
            values_able[items[i].v].second.at(i) = '1';
        }
    }

    for(int i=0; i<(int)values_able.size(); i++){
        lint mmin = values_able[i].first;
        int from = -1;
        for(int j=0; j<n; j++){
            if(items[j].v > i) continue;
            if(values_able[i-items[j].v].second.at(j) == '1') continue;
            if(values_able[i-items[j].v].first == numeric_limits<lint>::max()) continue;
            lint tmp_w = values_able[i-items[j].v].first + items[j].w;
            if(tmp_w <= (lint)w && tmp_w < mmin){
                mmin = tmp_w;
                from = j;
            }
        }

        if(from == -1) continue;
        values_able[i].first = mmin;
        values_able[i].second = values_able[i-items[from].v].second;
        values_able[i].second.at(from) = '1';
    }

    for(int i=values_able.size()-1; i>=0; i--){
        if(values_able[i].first == numeric_limits<lint>::max()) continue;
        COUT(i);
        break;
    }

    return 0;
}

Measured memory_bytes: 15872
#!/usr/bin/python
import sys
if sys.version_info[0]>=3: raw_input=input

def M(l,r):
	if l+1>=r: return 0
	if l+2==r:
		if A[l]<=A[l+1]: return 0
		A[l],A[l+1]=A[l+1],A[l]
		return 1
	m = (l+r)//2
	i=l
	j=m
	k=l
	cl=M(l,m)
	cr=M(m,r)
	c=0
	while i<m and j<r:
		if A[i]<=A[j]:
			W[k]=A[i]
			k+=1
			i+=1
		else:
			W[k]=A[j]
			k+=1
			j+=1
			c+=m-i
	while i<m:
		W[k]=A[i]
		k+=1
		i+=1
	while j<r:
		W[k]=A[j]
		k+=1
		j+=1
	for i in range(l,r): A[i]=W[i]
	return cl+cr+c

raw_input()
A=list(map(int,raw_input().split()))
W=[0]*len(A)
print(M(0,len(A)))

Measured memory_bytes: 21712
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <queue>
#include <sstream>
#include <stack>
#include <time.h>
#include <vector>
#include <complex>
#include <map>
#include <set>
#include <iomanip>
#include <math.h>
#include <stdlib.h>
using namespace std;
int main(){
  int a,b,ans=0;
  cin>>a>>b;
  ans+=a-1;
  if (b >= a) ans++;
  cout<<ans;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define rep(i,a,n) for(ll i=a;i<n;i++)
#define ALL(s) s.begin(),s.end()
#define P pair<ll,ll>
#define vl vector<ll>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vvl vector<vector<ll>>
#define print(n) cout<<n<<endl
const int M=100010;
const int inf=1000000007;
const long long INF=1000000000000000007;
using ll=long long;
int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};


int main(){
	int n,k;
	ll ans=0;
	P p[M];
	cin>>n>>k;
	rep(i,0,n)cin>>p[i].second>>p[i].first;
	sort(p,p+n,greater<>());
	ll sum=0,cnt=0;
	stack<ll> v;
	P num;
	bool f[M]={};
	rep(i,0,k){
		sum+=p[i].first;
		if(!f[p[i].second]){
			cnt++;
			f[p[i].second]=true;
		}else v.push(p[i].first);
	}
	ans=sum+cnt*cnt;
	rep(i,k,n){
		if(v.empty())break;
		sum+=p[i].first;
		sum-=v.top();
		v.pop();
		if(!f[p[i].second]){
			cnt++;
			f[p[i].second]=true;
		}else v.push(p[i].first);
		ans=max(ans,sum+cnt*cnt);
	}
	print(ans);
}

Measured memory_bytes: 2432
#include<stdio.h>
#include<stdlib.h>
#include<math.h>

typedef long long int int64;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))

void run(void){
  int a,b,c,x,y;
  scanf("%d%d%d%d%d",&a,&b,&c,&x,&y);
  int ans=0;
  if(a+b>=2*c){
    while(x>0 && y>0){
      ans+=2*c;
      x--;
      y--;
    }
  }
  if(a>=2*c){
    ans+=2*c*x;
    y=MAX(y-x,0);
    x=0;
  }
  if(b>=2*c){
    ans+=2*c*y;
    x=MAX(x-y,0);
    y=0;
  }
  ans+=a*x+b*y;
  printf("%d\n",ans);
  return;
}

int main(void){
  run();
  return 0;
}


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

string itos(int n){
	stringstream ss; ss<<n;
	return ss.str();
}
/*
int f(string n){
	for(int i = 0 ; i < n.size()-1 ; i++){
		string t = n;
		t.replace(i,2,itos(n[i]+n[i+1]-2*'0'));
		if(!f(t)) return true;
	}
	return false;
}*/
int sup(string n){
	int ans = 0;
	while(n.size() != 1){
		n.replace(0,2,itos(n[0]+n[1]-2*'0'));
		ans++;
	}
	return ans;
}
int main(){
	int t; cin >> t;
	string s;
	while(cin >> s){
		cout << (sup(s)%2 ? "Fabre" : "Audrey") << " wins." << endl;
	}
}

Measured memory_bytes: 0
using System;
    class Program
    {
        static void Main()
        {
            string[] input = Console.ReadLine().Split();
            int[] inputarray = new int[5];
            for (int i = 0; i <= 4; i++)
            {
                inputarray[i] = int.Parse(input[i]);
            }
            Array.Sort<int>(inputarray);
            Array.Reverse(inputarray);
            for (int i = 0; i < 4; i++)
            {
                Console.Write(inputarray[i] + " ");
            }
            Console.WriteLine(inputarray[4]);
            Console.ReadLine();
        }
    }

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


int main() {
int N,count;
cin >>N;
vector<int> vec(N);
count=1;

rep(i,N){
cin>>vec[i];
}
sort(vec.begin(),vec.end());
rep(i,N-1){
  if(vec[i] != vec[i+1]){
  count++;
  
  }
  else{
    continue;
  }

}
cout<<count <<endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner reader = new Scanner(System.in);
		int N = reader.nextInt();
		for(int i = 0; i < N; i++){
			long a = reader.nextInt();
			long b = reader.nextInt();
			long c = reader.nextInt();
			if((c*c)==(a*a)+(b*b)){
				System.out.println("YES");
			} else if((b*b)==(a*a)+(c*c)) {
				System.out.println("YES");
			}else if((a*a)==(b*b)+(c*c)){
				System.out.println("YES");
			} else {System.out.println("NO");}
		}
	}
}

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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define a first
#define b second
#define sz size()
#define pb(x) push_back(x) 
#define bg begin()
#define ed end()
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define mp(x,y) make_pair(x,y)
const ll MOD=1000000007;

ll maxx(ll x,ll y,ll z){
	return max(max(x,y),z);
}
ll minn(ll x,ll y,ll z){
	return min(min(x,y),z);
}
ll gcd(ll x,ll y){
	if(x%y==0) return y;
    else return gcd(y,x%y);
}
ll lcm(ll x,ll y){
	return x*(y/gcd(x,y));
}
ll myceil(ll x,ll y){//yがいくつ集まったらx以上になるか
	if(x<=y) return 1;
	else if(x%y==0) return x/y;
	else return x/y+1;
}

//a,b x
int main(){
	ll N; cin>>N;
	vector<ll> t(N);
	ll sum=0;
	rep(i,N){
		cin>>t[i];
		sum+=t[i];
	}
	ll M; cin>>M;
	vector<ll> p(M);
	vector<ll> x(M);
	rep(i,M) cin>>p[i]>>x[i];
	rep(i,M){
		cout<<sum-t[p[i]-1]+x[i]<<endl;
	}
}

Measured memory_bytes: 256
while 1 do
h,w=gets.split(" ");
h=h.to_i;
w=w.to_i;

if h==0 && w==0 then
        break
end

(1..w).each{|i|
        print "#"
}
print "\n"

(2..h-1).each{|i|
        print "#"
        (2..w-1).each{|j|
                print "."
        }
        print "#\n"
}
(1..w).each{|i|
        print "#"
}
print "\n";
print "\n";
end

Measured memory_bytes: 8728
n,k=map(int,input().split())
a=list(map(lambda x:int(x)-1,input().split()))
lst=[0]
now=0
memo=0
town=[0]*n
town[0]=1
b=0
for i in range(k):
	now=a[now]
	if town[now]==1:
		memo=now
		b=1
		break
	lst.append(now)
	town[now]=1
if b==1:
	i=lst.index(memo)
	l=len(lst)
	if memo!=0:
		lst=lst[i:]
		l-=len(lst)
		print(lst[(k-l)%len(lst)]+1)
	else:
		print(lst[k%l]+1)
else:
	print(now+1)

Measured memory_bytes: 32276
#include<stdio.h>
#include<string.h>
 
#define M 1000003
#define L 14
 
char H[M][L];
 
int getChar(char ch) {
    if (ch == 'A') {
        return 1;
    }
    else if (ch == 'C') {
        return 2;
    }
    else if (ch == 'G') {
        return 3;
    }
    else if (ch == 'T') {
        return 4;
    }
    return 0;
}
 
long long getKey(char str[]) {
    long long sum = 0, p = 1, i;
    for (i = 0; i < strlen(str); i++) {
        sum += p * (getChar(str[i]));
        p *= 5;
    }
    return sum;
}
 
int hash1(int key) {
    return key % M;
}
 
int hash2(int key) {
    return 1 + key % (M - 1);
}
 
int getHashValue(char str[], int i) {
    return (hash1(getKey(str)) + i * hash2(getKey(str))) % M;
}
 
int find(char str[]) {
    int hashval, i = 0;
 
    while (1) {
        hashval = getHashValue(str, i);
        if (!strcmp(H[hashval], str)) return 1;
        if (!strcmp(H[hashval], "\0")) return 0;
        i++;
    }
}
 
void insert(char str[]) {
    int hashval, i = 0;
 
    while (1) {
        hashval = getHashValue(str, i);
        if (!strcmp(H[hashval], "\0")) {
            strcpy(H[hashval], str);
            break;
        }
        i++;
    }
}
 
int main() {
    int i, n;
    char str[L], com[9];
 
    for (i = 0; i < M; i++) {
        H[i][0] = '\0';
    }
 
    scanf("%d", &n);
 
    for (i = 0; i < n; i++) {
        scanf("%s %s", com, str);
 
        if (com[0] == 'i') {
            insert(str);
        } else {
            if (find(str)) {
                printf("yes\n");
            } else {
                printf("no\n");
            }
        }
    }
 
    return 0;
}

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

#define debug(x) cout <<"DEBUG"<<" "<< #x << ":" << x << '\n'

// n回繰り返し
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順
#define rep1(i,n) for(int i = 1; i <= ((int)(n)); i++) // 1-indexed昇順
#define rrep(i,n) for(int i = ((int)(n)-1); i >= 0; i--)  // 0-indexed降順
#define rrep1(i,n) for(int i = ((int)(n)); i >= 1; i--)   // 1-indexed降順
#define all(x) (x).begin(),(x).end()

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii;  // 2次元配列
typedef vector<ll> vll;
typedef vector<double> vd;
typedef pair<int, int> PII;

template<typename T>
using vec = vector<T>;
template<class T>
using maxheap = std::priority_queue<T>;
template<class T>
using minheap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

template<class T,class U> inline bool chmax(T &a, const U &b){if(a<b){a=b;return 1;}return 0;}
template<class T,class U> inline bool chmin(T &a, const U &b){if(a>b){a=b;return 1;}return 0;}

const ld Pi = std::acos(-1.0L);
const ll infll = (1LL<<62)-1;
const int inf = (1<<30)-1;
const int mod = 1000000007;
// const int mod = 998244353;


/*FUNCs=================================================*/
int num_753;
vi cond = {3,5,7};
int recursive(ll n, ll P) {
    ll ret;
    rep(i,3) {
        ret = cond[i];
        ret += P*10;
        if(ret <= n) {
            bool ok = [&]() {
                bool ok3 = 0, ok5 = 0, ok7 = 0;
                string s = to_string(ret);
                for(auto ch : s) {
                    if(ch == '3') ok3 = 1;
                    if(ch == '5') ok5 = 1;
                    if(ch == '7') ok7 = 1;
                }
                return ok3&ok5&ok7;
            }();
            if(ok) ++num_753;
            recursive(n, ret);
        }
    }
    return 0;
}

/*MAIN==================================================*/
signed main(){
    int _StartTime_ = clock();
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化
    // cout << fixed << setprecision(15);

    ll n; cin >> n;
    ignore = recursive(n, 0);
//    for(auto d : num_753) debug(d);

    cout << num_753 << '\n';

    // printf("ExecutionTime: %d /ms\n",1000*(int)((clock()-_StartTime_)/CLOCKS_PER_SEC));
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N;
    string Str;
    cin >> N >> Str;
    int countW=0,countB=0;
    int White[N+2]={0};
    int Black[N+2]={0};
    for(int i=1; i<=N; i++){
        if(Str.at(i-1)=='#'){
            countB++;
        }
        Black[i]=countB;
        if(Str.at(N-i)=='.'){
            countW++;
        }
        White[N-i+1]=countW;
    }
    int answer=N;
    for(int i=0; i<N+1; i++){
        if(answer>(Black[i]+White[i+1])){
            answer=Black[i]+White[i+1];
        }
    }
    cout << answer;
    return 0;
}

//00110111000100101010111001

Measured memory_bytes: 2180
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<stdint.h>
#include<malloc.h>
#include<x86intrin.h>

int my_gets(char *buf,int nBuf,FILE *fp){
    int ch;

    while(--nBuf >0){
        ch=getc(fp);
        if(ch==EOF || ch=='\n')
            break;
        *(buf++)=(char)ch;
    }
    *(buf)='\0';

    return nBuf;
}

int InputIntAry(int *a,int nBuf,int N,int K){
    int ret=0;
    int64_t tmp;
    char *buf,*ptr;

    buf=(char*)malloc(nBuf*sizeof(char));
    my_gets(buf,nBuf,stdin);

    ptr=strtok(buf," ");
    while(ptr!=NULL && N-->0){
        tmp=atoll(ptr);
        if(tmp < K){    //Kより大きなカードは必要に決まっているし, 他のカードの判定に関係しない
            a[ret++] = (int)tmp;
            //printf("%d\n",a[ret-1]);
        }
        ptr=strtok(NULL," ");
    }
    free(buf);

    return ret;
}

#define MIN(a,b)  ( ((a)<(b))?(a):(b) )

int CmpCh(const void *a, const void *b){        //a-bを返す(qsortなら昇順)
    return *((char*)a)- *((char*)b);
}

int main(){
    int N,cnt=0;
    char buf[200]={};

    scanf("%d%*c",&N);
    my_gets(buf,sizeof(buf)/sizeof(char),stdin);
    for(int i=0;i<N;i++){
        if(buf[i]=='R')
            cnt++;
        else if(buf[i]=='B')
            cnt--;
    }
    if(cnt>0)
        puts("Yes");
    else
    {
        puts("No");
    }
    
    return 0;
}

Measured memory_bytes: 128
package main

import "fmt"

func main() {
	// 0:A, 1:G, 2:C, 3:T
	var dp [101][4][4][4]int
	var n int

	fmt.Scan(&n)

	dp[0][3][3][3] = 1
	mod := 1000000007

	for len := 0; len < n; len++ {
		for c1 := 0; c1 < 4; c1++ {
			for c2 := 0; c2 < 4; c2++ {
				for c3 := 0; c3 < 4; c3++ {
					if dp[len][c1][c2][c3] == 0 {
						continue
					}

					for a := 0; a < 4; a++ {
						if a == 2 && c1 == 1 && c2 == 0 {
							continue
						}
						if a == 2 && c1 == 0 && c2 == 1 {
							continue
						}
						if a == 1 && c1 == 2 && c2 == 0 {
							continue
						}
						if a == 2 && c1 == 1 && c3 == 0 {
							continue
						}
						if a == 2 && c2 == 1 && c3 == 0 {
							continue
						}

						dp[len+1][a][c1][c2] += dp[len][c1][c2][c3]
						dp[len+1][a][c1][c2] %= mod
					}
				}
			}
		}
	}

	var ans int
	for c1 := 0; c1 < 4; c1++ {
		for c2 := 0; c2 < 4; c2++ {
			for c3 := 0; c3 < 4; c3++ {
				ans += dp[n][c1][c2][c3]
				ans %= mod
			}
		}
	}

	fmt.Print(ans)

}


Measured memory_bytes: 640
def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7 #出力の制限
N = 10**4
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )


N,K = map(int,input().split())
for i in range(1,1+K):
    ans = cmb(1+N-K,i,mod)
    ans *= cmb(K-1,K-i,mod)
    print(ans%mod)


Measured memory_bytes: 74672
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <inttypes.h>
#include <string.h>
#include <math.h>

int main (void)
{
    intmax_t K, X;
    intmax_t ans = 0;

    scanf("%jd%jd", &K, &X);

    for (intmax_t i = X - (K - 1); i < X + K; i++) {
        printf("%jd ", i);
    }
    puts("");

    return 0;
}


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


int main(){
	char s[101]={};
	char t[101]={};
	cin>>s>>t;
	int a=strlen(s);
	int b=strlen(t);
	for(int i=0; i<b; i++){
		cout<<t[i];
	}
	for(int i=0; i<a; i++){
		cout<<s[i];
	}
	cout<<endl;
}

Measured memory_bytes: 3628
#include<cstdio>
#include<cmath>
#include<climits>
#include<algorithm>
#include<sstream>
#include<iostream>
#include<string>
#include<queue>
#include<stack>
#include<set>
#include<list>
#include<map>
#include<vector>

using namespace std;


#define rep(i,n) for(int i=0; i<n; i++)
#define rept(i,a,b) for(int i=a; i<b; i++)
#define ll long long
#define MOD 1000000007
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

#define IMIN INT_MIN;
#define IMAX INT_MAX;


int main(){
	int N, M;
	cin >> N >> M;
	ll a[M];
	vector<ll> dp(N+10, 0);
	vector<bool> ok(N+10, true);
	rep(i, M) {
		cin >> a[i];
		ok[a[i]] = false;
	}
	dp[0] = 1;
	rept(i, 1, N+5) {
		if (ok[i]) {
			if (ok[i-1]) {
				dp[i] += dp[i-1];
				dp[i] %= MOD;
			}
			if (i > 1) {
				if (ok[i-2]) {
					dp[i] += dp[i-2];
					dp[i] %= MOD;
				}
			}
		}
	}
	cout << dp[N] << endl;


	return 0;
}



Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=1LL<<61;

int main() {
  ll n;
  cin >> n;
  vec a(n);
  ll x=0;
  for(ll i=0;i<n;i++) {
    cin >> a[i];
    if(i>1) x^=a[i];
  }
  ll s=a[0]+a[1];
  ll d=(s-x)/2;
  if(s-x<0||(s-x)%2||d&x||d>a[0]) {
    cout << -1 << endl;
    return 0;
  }
  ll ans=d;
  for(ll i=(1LL<<61);i;i>>=1) {
    if(!(i&x)) continue;
    if(ans+i<=a[0]) ans+=i;
  }
  if(ans) cout << a[0]-ans << endl;
  else cout << -1 << endl;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int main() {
  long long x;
  cin >> x;
  if(x>=400 && x<=599)
    cout << 8;
  else if(x<=799)
    cout << 7;
  else if(x<=999)
    cout << 6;
  else if(x<=1199)
    cout << 5;
  else if(x<=1399)
    cout << 4;
  else if(x<=1599)
    cout << 3;
  else if(x<=1799)
    cout << 2;
  else if(x<=1999)
    cout << 1;
  return 0;
}

Measured memory_bytes: 3588
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <map>
#include <set>

using namespace std;

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

int main() {
	int n;
	cin >> n;
	vector<long long> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}

	int temp = a[0];

	for (int i = 1; i < n ; i++) {
		temp = gcd(a[i], temp);
	}

	cout << temp << endl;
	return 0;
}

Measured memory_bytes: 1024