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

#define ll long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define debug3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define debugB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

template<typename T>
void printA(vector<T> &printArray, char between = ' ') {
   int paSize = printArray.size();
   for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between;}
   if (between != '\n') {cerr << endl;}
}

// ------------------------------------------------------------------------------------------

int N;
vector<int> prime;
map<int, int> mp;

void create() {
   for (int i = 2; i <= 100; i++) {
      bool ok = true;
      for (int j = 2; j <= 100; j++) {
         if (i == j) continue;
         if (i % j == 0) ok = false;
      }
      if (ok) prime.push_back(i);
   }
}

void m(int z) {
   // for (int x : prime) {
   //    if (i % x == 0) mp[x] += i / x;
   // }
   for (int i = 2; i <= z; i++) {
      while (z % i == 0) {
         z /= i;
         mp[i]++;
      }
   }
}

int main() {
   create();

   cin >> N;

   for (int i = N; i >= 1; i--) {
      m(i);
   }

   ll ans = 1;
   ll MOD = 1e9 + 7;

   for (auto x : mp) {
      // debug2(x.first, x.second)
      ans = ((ans%MOD) * (x.second+1)%MOD) % MOD;
      // ans *= (x.second+1);
   }

   cout << ans << endl;

   return 0;
}

Measured memory_bytes: 256
#include <map>
#include <cmath>
#include <cstdio>
#include <vector>
#include <iomanip>
#include <iostream>
#include <algorithm>
#include <functional>
#pragma warning(disable : 4996)
using namespace std;
int N, A, B; long long v[55], dp[55][55];
int main() {
	cin >> N >> A >> B;
	for (int i = 0; i < N; i++) cin >> v[i];
	dp[0][0] = 1;
	for (int i = 1; i <= 50; i++) {
		for (int j = 0; j <= i; j++) {
			dp[i][j] = dp[i - 1][j];
			if (j) dp[i][j] += dp[i - 1][j - 1];
		}
	}
	sort(v, v + N, greater<long long>());
	long long sum = 0;
	for (int i = 0; i < A; i++) sum += v[i];
	long long ret = 0;
	for (int i = A; i <= B; i++) {
		long long s = 0;
		for (int j = 0; j < i; j++) s += v[j];
		if (s * A == sum * i) {
			int cr = 0, dr = 0;
			for (int j = 0; j < N; j++) {
				if (v[j] == v[i - 1]) {
					cr++;
					if (j < i) dr++;
				}
			}
			ret += dp[cr][dr];
		}
	}
	cout << fixed << setprecision(15) << 1.0 * sum / A << endl;
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 256
//  Created by conan1024hao in 2019.
//  Copyright © 2019 conan1024hao. All rights reserved.
//  専用ライブラリです、自由にコピーして構いません。
//  感谢看我的代码！Wechat:conan1024hao QQ:810396815
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define INF 10e16
#define MOD 1000000007
#define  mod 1000000007
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
//using Int=int_fast64_t;
typedef long long int ll;
typedef pair<ll,ll>Pll;
typedef pair<int,int>Pin;
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[8]={-1,0,1,0,1,1,-1,-1};
int dy[8]={0,-1,0,1,1,-1,1,-1};
char dir[4]={'u','l','d','r'};
ll cmp1(pair<ll,string>a,pair<ll,string> b){
        if(a.fi!=b.fi)
        return a.fi<b.fi;
        else
        return a.se<b.se;
}
//--------------------------------------------------------------------------


//---------------------------------------------------------------------------
int main(){//問題をちゃんと見ろ!!!!!!!!!!!!!!!!!      llか??????????        memset()!!!!!!!!!!!!       ペナを減らせ!!!!!!!!!!!!!
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------
    int n;cin>>n;
    int ans=0;
    int cc=0;
    for(int i=1;i<=n;i++){
        int cnt=0;
        int m=i;
        while(m%2==0){
            m/=2;
            cnt++;
        }
        if(cnt>=cc){
            cc=cnt;
            ans=i;
        }
    }
    cout<<ans;
    //-------------------------------
    return 0;
}
//---------------------------------------------------------------------------






Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

int main() {
    ll n, m, k;
    cin >> n >> m >> k;

    exrep(i, 0, n) {
        exrep(j, 0, m) {
            if(i*j + (n-i)*(m-j) == k) {
                out("Yes");
                re0;
            }
        }
    }

    out("No");
    re0;
}

Measured memory_bytes: 256
#include <iostream>

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

using namespace std;

int main(){
  int N;
  cin >> N;
  int A[N+1];
  rep(i, N)
    cin >> A[i];
  //入力終了

  //実装上つけた
  A[N] = A[N-1]+(A[N-1]-A[N-2]);

  int ans = 0;
  for(int i=0; i<N; i++){
    //cout << i+1 << "-" ;

    //同じならカウントしなくていい
    //(次に単調増加/減少するところまで飛ばす)
    if(A[i] == A[i+1])
      continue;

    //単調増加するとき
    else if(A[i] < A[i+1]){
      while(A[i]<A[i+1] || A[i]==A[i+1])
	i++;
      ans++;
    }

    //単調減少するとき
    else if(A[i] > A[i+1]){
      while(A[i]>A[i+1] || A[i]==A[i+1])
	i++;
      ans++;
    }
    
    //cout << i+1 <<endl;
  }

  //解答
  cout << ans << endl;
    
  return 0;
}


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


int main(){
  
 int a,no,b,temp=0;

   scanf("%d", &no);
   b=no;
   while(no>0)
   {
    a=no%10;
    no=no/10;
    temp=temp*10+a;
   }
   if(temp == b)
 {
  cout<<"Yes"<<endl;
  }
 else
  {
  	cout<<"No"<<endl;
}
   	
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
//clock_t start=clock();clock_t end=clock();cout<<(double)(end-start)/CLOCKS_PER_SEC<<endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef pair<pii,pii> P;
typedef tuple<ll,ll,ll> tl;
typedef pair<double,double> pdd;
typedef vector<vector<ll>> mat;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll mod5=1000000009;
ll inf=1LL<<62;
double pi=3.141592653589793238462643383279L;
double eps=1e-14;
#define rep(i,m,n) for(int i=m;i<n;i++)
#define rrep(i,n,m) for(ll i=n;i>=m;i--)
#define srep(itr,st) for(auto itr=st.begin();itr!=st.end();itr++)
#define mrep(itr,mp) for(auto& itr:mp)
#define Max(a,b) a=max(a,b)
#define Min(a,b) a=min(a,b)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
#define umh unordered_map<ll,ll,custom_hash>
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll lcm(ll a,ll b){
    ll c=gcd(a,b);
    return a*b/c;
}
ll Pow(ll n,ll k){
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}
ll beki(ll n,ll k,ll md){
  ll ret=1;
  ll now=n;
    now%=md;
  while(k>0){
    if(k%2==1){
      ret*=now;
      ret%=md;
    }
    now*=now;
    now%=md;
    k/=2;
  }
  return ret;
}
ll gyaku(ll n,ll md){
  return beki(n,md-2,md);
}
ll popcount(ll n){
    ll ret=0;
    ll u=n;
    while(u>0){
        ret+=u%2;
        u/=2;
        
    }
    return ret;
}

int main(){
    ios::sync_with_stdio(false);cin.tie(0);
    int a,b,c,d;cin>>a>>b>>c>>d;
    int s=(c+b-1)/b,t=(a+d-1)/d;
    if(s<=t)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


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

int main() {

  int N , x;
  cin >> N >> x;

  int ans=0;

  int y = x;

  vector<int> a(N);

  for(int i=0;i<N;i++){
    cin >> a[i];
  }

  sort(a.begin() , a.end());

  for(int i=0;i<N ; i++){

    if(x>=a[i]){
      x -= a[i];
      ans++;
    }

    else break;

  }

  if(ans==N){
    int all=0;
    for(int i=0 ; i<N ;i++){
      all += a[i];
    }

    if(all < y) ans--;
    else ;
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>

bool f(std::string w) {
    int x = w[0];
    for (int i = 1; i < w.size(); i++) {
        x ^= w[i];
    }
    return x == 0;
}

int main() {

    std::string w;
    std::cin >> w;

    if (f(w)) {
        std::cout << "Yes" << std::endl;
    } else {
        std::cout << "No" << std::endl;
    }

    return 0;
}


Measured memory_bytes: 256
from fractions import gcd
a, b, c, d = map(int, input().split())
ans = b-a+1
lcm_cd = (c*d)//gcd(c, d)

under_a = (a-1)//c + (a-1)//d - (a-1)//lcm_cd
under_b = b//c + b//d - b//lcm_cd
print(ans-(under_b-under_a))


Measured memory_bytes: 64108
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <set>
#include<cstring>
#define ll long long
#define MODD 1000000007
#define  pii  pair<int,int>
#include<stdio.h>
#include <bits/stdc++.h>
using namespace std;
struct node{
    string name;
    double a,b,c;
    double sum;
    double avg;
}city[10000];
double cmd(node a, node b){
    return a.sum>b.sum;
}
int main(){
	int n;cin >>n;
	if(n%2)cout<<"No"<<endl;
	else {
        char ar[10000];
        char br[10000];
        for(int i=0;i<n/2;i++)cin>>ar[i];
        for(int i=0;i<n/2;i++)cin >>br[i];
        if(strcmp(ar,br)==0)cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
	}
	return 0;
}




Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;
using vl = vector<ll>;
using Map = map<ll,ll>;
using T = tuple<ll,ll,ll>;
using vvl = vector<vector<ll>>;
#define all(v) v.begin(), v.end()
#define prt(v) cout<<(v)<<"\n";
#define fi(v) get<0>(v)
#define se(v) get<1>(v)
#define th(v) get<2>(v)
#define endl "\n"
template <typename T> bool chmax(T &a, const T &b){if (a<b){a=b;return 1;}return 0;}
template <typename T> bool chmin(T &a, const T &b){if (a>b){a=b;return 1;}return 0;}
const ll INF=1LL<<60;
const ll MOD=998244353;


signed main(void){
    cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    ll S;
    cin >> S;
    vector<ll> A(N+1,0);
    for(ll i=0;i<N;++i)cin>>A[i+1];
    //dp[i][j]はA[i]まで見たとき、和がjとなる集合の個数
    vector<vector<ll>> dp(3001, vector<ll>(3001, 0));
    dp[0][0]=1;
    //ひとつづつ解禁
    for(ll i=1;i<=N;++i){
        for(ll j=0;j<3001;++j)dp[i][j]=(dp[i-1][j]*2%MOD);
        for(ll j=0;j<=3000-A[i];++j){
            dp[i][j+A[i]]+=dp[i-1][j];
            dp[i][j+A[i]]%=MOD;
        }
    }
    prt(dp[N][S])

    
    return 0;
}


Measured memory_bytes: 73696
#include <iostream>
#include <string>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <iomanip>
#include <queue>


using namespace std;

int main() {
    int N, N1 = 0, N0 = 0;
    string S;

    cin >> S;

    N = S.size();

    for (int i = 0; i < N; i++) {
        if (S[i] == '0') {
            N0++;
        }
        else {
            N1++;
        }
    }

    cout << min(N0, N1) * 2;

    return 0;
}

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

int main() {
  int N;
  int K;
  cin >> N >> K;
  
  int a = 1;
  int b;
  for (int i = 0; i < N; i++) { 
    b = a * 2;
    if (b - a > K) {
      a += K;
    }
    else {
      a = b;
    }
  }
  
  cout << a << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mod 1000000007
#define mod998 998244353
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define mkp make_pair
typedef long long ll;
using namespace std;

int N, a, b, dis[200000];
vector<int>v[200000];
bool vis[200000];

void dfs(int x, bool f) {
	vis[x] = f;
	for (int i : v[x]) {
		if (vis[i] ^ f) {
			dis[i] = dis[x] + 1;
			dfs(i, f);
		}
	}
}


int main() {
	cin >> N;
	for (int i = 0; i < N - 1; ++i) {
		cin >> a >> b;
		--a; --b;
		v[a].push_back(b);
		v[b].push_back(a);
	}
	dfs(0, true);
	pair<int, int>mx;
	mx = mkp(-1, -1);
	for (int i = 0; i < N; ++i) {
		mx = max(mx, mkp(dis[i], i));
	}
	dis[mx.second] = 0;
	dfs(mx.second, false);
	mx = mkp(-1, -1);
	for (int i = 0; i < N; ++i) {
		mx = max(mx, mkp(dis[i], i));
	}
	if (mx.first % 3 == 1) {
		puts("Second");
	}
	else {
		puts("First");
	}
}

Measured memory_bytes: 21504
n, x = map(int, input().split())
L = [int(i) for i in input().split()]
count = 0
zahyou = [0]
for i in range(n):
    zahyou.append(int(zahyou[i])+L[i])
for i in range(len(zahyou)):
    if zahyou[i]<=x:
        count+=1
print(count)

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

  int a,b,c,d;

  scanf("%d %d", &a, &b);

  c = a / b;
  d = a % b;

  double e;

  e = 1.0 * a / b;

  printf("%d %d %.8lf\n", c, d, e);

  return 0;

}

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

signed main(){
    int n,m;
    cin >> n >> m;
    int a,b;
    int cnt[n - 1] = {};
    REP(i,m){
        cin >> a >> b;
        if(a > b){
            swap(a, b);
        }
        if(a == 1){
            cnt[b - 2]++;
        }else{
            cnt[a - 2]++;
            cnt[b - 2]++;
        }
    }
    REP(i,n - 1){
        if(cnt[i] % 2 != 0){
            cout << "NO" << endl;
            return 0;
        }    
    }
    cout << "YES" << endl;
}

Measured memory_bytes: 640
#include <iostream>
 using namespace std;
 
int main(void){
	int i,x;
	i = 1;
	while(1) {
 		cin >> x ;
		if ( x == 0 ) break;
		cout << "Case " << i << ": " << x << endl;
		i++;
	}
	return 0;
} 

Measured memory_bytes: 1160
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000
#define MOD 10000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

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

signed main(){
    ll A,B; cin >> A >> B;
    cout << (A * B) / gcd(A,B) << endl;
}

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



int main()
{
    int m,n;
    cin>>n>>m;
    int a[n+1];
    for(int i=0;i<=n;i++)
        a[i]=0;
    for(int i=0;i<m;i++)
    {
        int x,y;
        cin>>x>>y;
        a[x]++;
        a[y]++;
    }
    for(int i=1;i<=n;i++)
        cout<<a[i]<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

void print(const std::vector<int> &v) {
    std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
    std::cout << std::endl;
}

int main() {
    int A, B, C, D;
    cin >> A >> B >> C >> D;
    int train = min(A, B);
    int bus = min(C, D);
    cout << train + bus << endl;
    return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"strings"
)

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

	if k == 1 {
		fmt.Println(0)
		return
	}

	ans := int(1e18)
	for b := 0; b < (1 << uint(n-1)); b++ {
		bits := b | (1 << uint(n-1))
		c := strings.Count(fmt.Sprintf("%b", bits), "1")
		if c != k {
			continue
		}

		mx := a[0]
		sum := 0
		for i := 1; i < n; i++ {
			if bits&(1<<uint(n-i-1)) == 0 || mx < a[i] {
				mx = max(mx, a[i])
				continue
			}
			sum += mx - a[i] + 1
			mx++
		}
		ans = min(ans, sum)
	}

	fmt.Println(ans)
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}


Measured memory_bytes: 1024
#![allow(clippy::needless_range_loop)]
#![allow(unused_macros)]
#![allow(dead_code)]

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        #[allow(unused_mut)]
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };

    ($iter:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        s: chars,
    }
    let modded = s
        .iter()
        .rev()
        .map(|x| (*x as u8 - b'0') as usize)
        .scan((1, 0), |state, x| {
            let (exp_10, last) = *state;
            let res = (x * exp_10 + last) % 2019;
            *state = (exp_10 * 10 % 2019, res);
            Some(res)
        })
        .collect::<Vec<_>>();
    let mut cnt = vec![0isize; 2019];
    cnt[0] = 1;
    for modl in modded.iter() {
        cnt[*modl] += 1;
    }
    let ans: isize = cnt.iter().map(|x| x * (x - 1) / 2).sum();
    println!("{}", ans);
}


Measured memory_bytes: 4780
#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    def check(X,Y,r2,err=1e-6):
        for x,y in p:
            if (x-X)**2 + (y-Y)**2 > r2+err:
                return 0
        return 1

    n = I()
    p = LIR(n)
    ans = float("inf")
    for i in range(n):
        xi,yi = p[i]
        for j in range(i+1):
            xj,yj = p[j]
            X = (xi+xj) / 2
            Y = (yi+yj) / 2
            r2 = (xi-X)**2+(yi-Y)**2
            if ans > r2 and check(X,Y,r2):
                ans = r2
            x,y = xj-xi,yj-yi
            for k in range(j):
                xk,yk = p[k]
                a,b = xk-xi,yk-yi
                deno = 2*(a*y-b*x)
                if deno == 0:
                    continue
                X = (y*(a**2+b**2)-b*(x**2+y**2))/deno+xi
                Y = (a*(x**2+y**2)-x*(a**2+b**2))/deno+yi
                r2 = (xi-X)**2+(yi-Y)**2
                if ans > r2 and check(X,Y,r2):
                    ans = r2
    print(ans**0.5)
    return

#Solve
if __name__ == "__main__":
    solve()


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

typedef struct Point
{
  double x, y;
}P;

void koch(int, P, P);

int main()
{
  P a, b;
  int n;

  scanf("%d",&n);

  a.x = 0;
  a.y = 0;
  b.x = 100;
  b.y =0;

  printf("%.8f %.8f\n",a.x,a.y);
  koch(n,a,b);
  printf("%.8f %.8f\n",b.x,b.y);
  
  return 0;
}

void koch(int n, P a, P b)
{
  P s, t, u;
  double th;

  th = M_PI * 60.0 / 180.0;
  
  if(n == 0)return;

  s.x = (2.0 * a.x + 1.0 * b.x)/3.0;
  s.y = (2.0 * a.y + 1.0 * b.y)/3.0;
  t.x = (1.0 * a.x + 2.0 * b.x)/3.0;
  t.y = (1.0 * a.y + 2.0 * b.y)/3.0;
  u.x = (t.x - s.x) * cos(th) - (t.y - s.y) * sin(th) + s.x;
  u.y = (t.x - s.x) * sin(th) + (t.y - s.y) * cos(th) + s.y;

  koch(n-1, a, s);
  printf("%.8f %.8f\n",s.x,s.y);
  koch(n-1, s, u);
  printf("%.8f %.8f\n",u.x,u.y);
  koch(n-1, u, t);
  printf("%.8f %.8f\n",t.x,t.y);
  koch(n-1, t, b);
}



Measured memory_bytes: 2112
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String X = sc.next();
        String Y = sc.next();
        int x = X.codePointAt(0);
        int y = Y.codePointAt(0);
        if (x == y) {
            System.out.println("=");
        }
        if (x > y) {
            System.out.println(">");
        }
        if (x < y) {
            System.out.println("<");
        }
    }
}


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

using namespace std;

using i64 = long long;

const i64 MOD = 1e9 + 7;
const i64 INF = i64(1e18) + 7;

template <typename T>
bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

template <typename T>
bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}


signed main(){
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; ++i)
        cin >> a[i];
    auto comp = a;
    sort(comp.begin(), comp.end());
    comp.erase(unique(comp.begin(), comp.end()), comp.end());
    vector<int> bef_pos(comp.back(), -1);
    vector<int> bef_arr(n, -1);
    for(int i = 0; i < n; ++i){
        a[i] = distance(comp.begin(), lower_bound(comp.begin(), comp.end(), a[i]));
        bef_arr[i] = bef_pos[a[i]];
        bef_pos[a[i]] = i;
    }
    vector<int> dp(n, 0);
    dp[0] = 1;
    for(int i = 1; i < n; ++i){
        i64 cnt = (bef_arr[i] == -1 || bef_arr[i] == i - 1 ? 0 : dp[bef_arr[i]]);
        dp[i] = (dp[i - 1] + cnt) % MOD;
    }
    cout << dp.back() << endl;
}


Measured memory_bytes: 7172
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 1000000010
#define EPS 1e-9
#define fst first
#define scd second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  string s;
  cin>>s;
  if(s=="Sunny") cout<<"Cloudy"<<endl;
  if(s=="Cloudy") cout<<"Rainy"<<endl;
  if(s=="Rainy") cout<<"Sunny"<<endl;

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<map>
#include<algorithm>
int main()
{
	int N,M,i,r;
	while(scanf("%d%d",&N,&M),N)
	{
		std::pair<int,int>a[10000];
		for(r=i=0;i<N;++i)scanf("%d%d",&a[i].second,&a[i].first);
		std::sort(a,a+N);
		for(i=N-1;i>=0;--i)
			if(M>=a[i].second)M-=a[i].second;
			else r+=(a[i].second-M)*a[i].first,M=0;
		printf("%d\n",r);
	}
	return 0;
}

Measured memory_bytes: 840
#!/usr/bin/env python3
import sys
from collections import defaultdict
sys.setrecursionlimit(10**8)
INF = float("inf")

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


class Graph(object):
    def __init__(self, N):
        self.N = N
        self.E = defaultdict(list)

    def add_edge(self, src, dest, w=1):
        self.E[src].append((dest, w))


g = Graph(N)
for i in range(N-1):
    g.add_edge(A[i]-1, i+1)

for i in range(N):
    print(len(g.E[i]))


Measured memory_bytes: 74224
#include <cmath>
#include <iomanip>
#include <iostream>

using namespace std;

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

    double p_dice = 1.0 / double(n);
    double p_coin = 1.0 / 2.0;
    double probability = 0;
    for (int i = 1; i <= n; ++i) {
        double coin = 1;
        int t = i;
        while (t < k) {
            t *= 2;
            coin *= p_coin;
        }
        probability += p_dice * coin;
    }
    cout << setprecision(12) << probability << '\n';
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define reps(i,n) for(int i = 1; i <= n; i++)
#define rrep(i,n) for(int i = n-1; i >= 0; i--)
#define rreps(i,n) for(int i = n; i >= 1; i--)
#define mrep(i,from,n) for(int i = from; i < n; i++)
#define mreps(i,from,n) for(int i = from; i <= n; i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define ERASE(x,val) x.erase(remove(ALL(x), val), x.end())
typedef long long ll;
typedef pair<ll, ll> P;
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; }
ll mod = 1000000007;

vector<ll> n_tot, n_p;
ll rec(ll n,ll x)
{
	if(x==0)return 0;
	if(n==0 && x==1)return 1;
	else if(x <= 1+n_tot[n-1]) return rec(n-1,x-1);
	else if(x==2+n_tot[n-1]) return n_p[n-1]+1;
	else if(x < n_tot[n])return n_p[n-1]+1+rec(n-1,x-n_tot[n-1]-2);
	else return n_p[n];
}

void solve()
{
	int n; cin >> n;
	ll x; cin >> x;
	n_tot.resize(n+1);
	n_p.resize(n+1);
	rep(i, n+1)n_tot[i]=((4LL<<i)-3);
	rep(i, n+1)n_p[i]=((2LL<<i)-1);
	ll ans = rec(n,x);
	cout << ans << endl;
	return;	
}

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	solve();
	return 0;
}


Measured memory_bytes: 256
n = int(input())
dat_a = map(int, input().split())
dat_a = list(dat_a)

import collections
q = collections.deque([])
c = 1
q.append((dat_a[0]))
while True:
    if c == len(dat_a):
        break
    q.appendleft(dat_a[c])
    c += 1

    if c == len(dat_a):
        break
    q.append(dat_a[c])
    c += 1

res = list(q)

if n %2  == 1:
    res.reverse()
res = map(str, res)
print(" ".join(res))


Measured memory_bytes: 31520
def dfs(x, bit) :
  if x > N :
    return 0
  res = bit == 7
  res += dfs(10*x + 3, bit|1)
  res += dfs(10*x + 5, bit|2)
  res += dfs(10*x + 7, bit|4)
  return res

N = int(input())
print(dfs(0, 0))


Measured memory_bytes: 3060
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int ab = sc.nextInt();
    int bc = sc.nextInt();
    int ca = sc.nextInt();
    
    int area = (ab* bc) / 2;
    
    System.out.println(area);
  }
  
  
  
}


Measured memory_bytes: 23124
#include <stdio.h>
#include <string.h>

int main(void)
{
	int i, num,  p, s=0, h=0, c=0, d=0, sp[13], he[13], cl[13],da[13];
	char	pattern;

	memset(&sp, 0, sizeof(sp));
	memset(&he, 0, sizeof(he));
	memset(&cl, 0, sizeof(cl));
	memset(&da, 0, sizeof(da));	
	
	scanf("%d" , &num);
	
	for(i=0; i<num; i++){
		scanf("%s" , &pattern);
		scanf("%d" , &p);
		
		switch(pattern){
			case('S'):
				sp[p-1] = p;
				s++;
				break;
			case('H'):
				he[p-1] = p;
				h++;
				break;
			case('C'):
				cl[p-1] = p;
				c++;
				break;
			case('D'):
				da[p-1] = p;
				d++;
				break;
			default:
				break;				
		}
	}
	if(s != 13){
		for(i=0; i<13; i++){
			if(sp[i] == 0){
				printf( "S %d\r\n", i+1);
			}
		}
	}
	if(h != 13){
		for(i=0; i<13; i++){
			if(he[i] == 0){
				printf( "H %d\r\n",  i+1);
			}
		}
	}
	if(c != 13){
		for(i=0; i<13; i++){
			if(cl[i] == 0){
				printf( "C %d\r\n",  i+1);
			}
		}
	}			
	if(d != 13){
		for(i=0; i<13; i++){
			if(da[i] == 0){
				printf( "D %d\r\n",  i+1);
			}
		}
	}
	return 0;	 
}

Measured memory_bytes: 596
N, H, W = map(int, input().split())
A = []
B = []
for i in range(N):
    A_, B_ = map(int, input().split())
    A.append(A_)
    B.append(B_)

ans = 0
for i in range(N):
    if A[i] >= H and B[i] >= W:
        ans += 1

print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
const int maxn=110;
typedef long long ll;
//ll a[maxn];
ll w[maxn];
ll v[4][maxn];
ll sum[4][maxn];
int cmp(int x,int y)
{
	return x>y;
}
int main()
{
	int n,w;
	while(~scanf("%d%d",&n,&w))
	{
		int a[4]={1,1,1,1};
		ll temp=0;
		for(int i=1;i<=n;++i)
		{
			int x,y;
			scanf("%d%d",&x,&y);
			if(i == 1)
				temp = x;
			v[x-temp][a[x-temp]++]=y;
		}
		sort(v[0]+1,v[0]+a[0]+1,cmp);
		sort(v[1]+1,v[1]+a[1]+1,cmp);
		sort(v[2]+1,v[2]+a[2]+1,cmp);
		sort(v[3]+1,v[3]+a[3]+1,cmp);
		for(int i=0;i<4;++i)
		{
			for(int j=1;j<a[i];++j)
			{
				sum[i][j]=sum[i][j-1]+v[i][j];
			}
		}
		ll ans = 0;
		for(int i=0;i<a[0];++i)
		{
			for(int j=0;j<a[1];++j)
			{
				for(int k=0;k<a[2];++k)
				{
					for(int l=0;l<a[3];++l)
					{
						if(temp*i+(temp+1)*j+(temp+2)*k+(temp+3)*l<=w)
						{
							ans=max(ans,sum[0][i]+sum[1][j]+sum[2][k]+sum[3][l]);
						}
					}
				}
			}
		}
		printf("%lld\n",ans);
	}
}

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

using namespace std;

int main() {
	int N,x;
	cin >> N >> x;
	vector<int>a(N);
	int ans = 0;

	for (int i = 0; i < N; i++) {
		cin >> a[i];
	}

	sort(a.begin(), a.end());

	for (int i = 0; i < N; i++) {
		if (i == N - 1) {
			if (x == a[i]) {
				ans++;
			}
			break;
		}
		if (x >= a[i]) {
			x = x - a[i];
			ans++;
		}
	}

	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
    int N, M, X, Y, i, max_x, min_y, war = 0;
    cin >> N; // num of x
    cin >> M; // num of y
    cin >> X;
    cin >> Y;
    vector<int> x(N);
    vector<int> y(M);
    
    for (i=0; i<N; i++) cin >> x[i];
    for (i=0; i<M; i++) cin >> y[i];

    sort(x.begin(), x.end());
    sort(y.begin(), y.end());

    max_x = x[N-1];
    min_y = y[0];

    if (max_x >= min_y) war = 1;
    else{
        war = 1;
        for (i=max_x + 1; i<=min_y; i++){
            if (i > X && i<= Y) war = 0;
        }
    }

    // cout << max_x << ' ' << min_y << '\n';

    if (war) cout << "War\n";
    else cout << "No War\n";

}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define rep(i, n) for(int i=0;i<(n);i++)
#define REP(i, n) for(int i=1;i<=(n);i++)
#define all(V) V.begin(),V.end()
typedef long long lint;
typedef std::pair<lint, lint> P;
constexpr int INF = INT_MAX;
constexpr lint LINF = LLONG_MAX;
constexpr double eps = 1e-9;
template<class T>
class prique :public std::priority_queue<T, std::vector<T>, std::greater<T>> {};
template <class T, class U>
inline bool chmax(T& lhs, const U& rhs) {
	if (lhs < rhs) {
		lhs = rhs;
		return 1;
	}
	return 0;
}
template <class T, class U>
inline bool chmin(T& lhs, const U& rhs) {
	if (lhs > rhs) {
		lhs = rhs;
		return 1;
	}
	return 0;
}
inline lint gcd(lint a, lint b) {
	while (b) {
		lint c = a;
		a = b; b = c % b;
	}
	return a;
}
inline lint lcm(lint a, lint b) {
	return a / gcd(a, b) * b;
}
bool isprime(lint n) {
	if (n == 1)return false;
	for (int i = 2; i * i <= n; i++) {
		if (n % i == 0)return false;
	}
	return true;
}
lint mypow(lint a, lint b) {
	if (!b)return 1;
	if (b & 1)return mypow(a, b - 1) * a;
	lint memo = mypow(a, b >> 1);
	return memo * memo;
}
lint modpow(lint a, lint b, lint m) {
	if (!b)return 1;
	if (b & 1)return modpow(a, b - 1, m) * a % m;
	lint memo = modpow(a, b >> 1, m);
	return memo * memo % m;
}
void printArray(std::vector<int>& vec) {
	rep(i, vec.size() - 1)std::cout << vec[i] << " ";
	std::cout << vec.back() << std::endl;
}
template<typename T>
void printArray(T l, T r) {
	T rprev = r;
	rprev--;
	for (T i = l; i != rprev; i++) {
		std::cout << *i << " ";
	}
	std::cout << *rprev << std::endl;
}
std::string to_string(std::vector<int>& vec) {
	std::string res = "[";
	rep(i, vec.size() - 1)res += std::to_string(vec[i]) + ", ";
	res += std::to_string(vec.back()) + "]";
	return res;
}
signed main() {
	int k;
	std::cin >> k;
	lint ans = 0;
	REP(i, k) {
		REP(j, k) {
			REP(l, k)ans += gcd(gcd(i, j), l);
		}
	}
	std::cout << ans << std::endl;
	return 0;
}

Measured memory_bytes: 3632
a,b=map(int,input().split())
c = ["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"]
x = ""
for i in range(a):
    x = input().split()
    if x.count("snuke") == True:
        for j in range(b):
            if x[j] == "snuke":
                print(c[j] + str(i+1))

Measured memory_bytes: 9188
import math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10**7)
inf = 10 ** 20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def pf(s): return print(s, flush=True)

N, Q = LI()
S = input()
"""
ACのインデックスをすべて記録しておき、始点、終点で区切って出す
少ない方を取ったほうがいいかな
"""
ACs = []
for sidx in range(0, len(S)-1):
    if S[sidx] == 'A':
        if S[sidx+1] == 'C':
            ACs.append(sidx)

#  print(ACs)

LR = []
for i in range(Q):
    LR.append(LI())

#  N, Q = 10**5, 10**5
#  S = 'ACTCTTCGTG'*10**4
#  LR = []
#  for i in range(Q):
#      LR.append([3,9000])

#  for l, r in LR:
#      tmp = S[l-1:r]
#      print(tmp.count('AC'))

result = []
#  print(ACs)
for l, r in LR:
    start = bisect.bisect_left(ACs, l-1)
    end = bisect.bisect_left(ACs, r-1)
    #  print('s,e', start, end)
    print(end-start)


Measured memory_bytes: 26488
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr int MOD = 1e9 + 7;

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (auto& e : a) cin >> e;

  ll r = 1;
  map<int, int> m;
  m[0] = 3;
  for (auto e : a) {
    r *= m[e];
    r %= MOD;
    if (m[e] == 0) break;
    m[e]--;
    m[e + 1]++;
  }
  cout << r << endl;
}


Measured memory_bytes: 5376
// D - Match Matching

// DPによる解法

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// const int INF = 2147483647;
// const ll INF = 9223372036854775807;
// const ll MOD = 1e9 + 7;

string dp[10030]; // dp[i]: i本のマッチで作れる最大の数
int m[10] = {0, 2, 5, 5, 4, 5, 6, 3, 7, 6};

string max_v(string v1, string v2) {
	if (v1.size() > v2.size()) return v1;
	if (v1.size() < v2.size()) return v2;

	if (v1 > v2) return v1;
	else return v2;
}


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

	vector<int> A;

	for (int i=0; i<M; i++) {
		int a;
		cin >> a;
		A.push_back(a);
	}

	for (int i=1; i<=N; i++) {
		dp[i] = "#";
	}

	for (int i=0; i<=N; i++) {
		for (int a : A) {
			if (dp[i] == "#") continue;

			dp[i+m[a]] = max_v(dp[i+m[a]], dp[i] + (char)('0' + a));
		}
	}

	cout << dp[N] << endl;

	/*
	// **** debug ****
	for (int i=0; i<=N; i++) {
		cout << dp[i] << endl;
	}
	*/

	return 0;
}

Measured memory_bytes: 61584
#pragma GCC optimize("03")
#include <bits/stdc++.h>
#define ll long long 
#define fi first
#define se second 

using namespace std;

int n, m, k;
char c[15][1010];
int dp[15][1010];
int st[15];
int vf; 

int get(int x, int y, int xx, int yy) {
    return dp[xx][yy] - dp[xx][y - 1] - dp[x - 1][yy] + dp[x - 1][y - 1];
}

int check(int l, int r) {
    int mx = 0;
    for (int i = 1; i <= vf; i++) {
        mx = max(mx, get(st[i - 1] + 1, l, st[i], r));
    }

    // cerr << "que: " << l << ' ' << r << ' ' << mx << endl;
    return mx <= k;
}

int solve(int mask) {
    int rs = __builtin_popcount(mask);

    vf = 0;
    for (int bit = 0; bit < (n - 1); bit++)
        if ((1 << bit) & mask) {
            st[++vf] = bit + 1;        
        }
    st[++vf] = n;

    // cerr << "mask: ";
    // for (int i = 1; i <= vf; i++)
    //     cerr << st[i] << ' ';
    // cerr << endl;

    int mx = 0;
    int l = 1; 

    for (int i = 1; i <= m; i++) {
        if (check(i, i) == false) {
            // cerr << "wtf\n";
            return INT_MAX; 
        }

        if (check(l, i))
            continue; 

        l = i;
        rs++; 
    }

    return rs;
}

int main() {
    // ifstream cin("tst.in");
    // ofstream cout("tst.out");
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);

    cin >> n >> m >> k;
    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= m; j++)
            cin >> c[i][j];

    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= m; j++)
            dp[i][j] = dp[i - 1][j] + dp[i][j - 1] - dp[i - 1][j - 1] + (c[i][j] == '1');

    int ans = INT_MAX;
    for (int mask = 0; mask < (1 << (n - 1)); mask++)
        ans = min(ans, solve(mask));

    cout << ans;

    return 0;
}

Measured memory_bytes: 384
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            int[] Arr = cin.ReadIntArray(2);
            int H = Arr[0];
            int N = Arr[1];
            int[] skillArr = cin.ReadIntArray(N);
            if (H > skillArr.Sum())
            {
                Console.WriteLine("No");
            }
            else
            {
                Console.WriteLine("Yes");
            }
        }   





    }


    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
        public double[] ReadDoubleArray(long N) { var ret = new double[N]; for (long i = 0; i < N; ++i) ret[i] = ReadDouble; return ret; }
    }
}


Measured memory_bytes: 18912
import numpy as np
n,t = map(int, input().split())
item = [None]*n
ans = 0
dp = np.zeros(t, dtype=int)

for i in range(n):
    a,b = map(int, input().split())
    item[i]=[a,b]
item.sort(key=lambda x:x[0])

for i in range(n):
    a,b = item[i]
    ans = max(ans, dp.max()+b)
    dp[a:] = np.maximum(dp[a:], dp[:-a]+b)

print(ans)


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

int main(){

    int H,W;

    while(true){
        scanf("%d%d",&H,&W);
        if(H == 0 && W == 0){
            break;
        }
        for(int j=0;j<H;j++){
            for(int i = 0;i<W;i++){
                printf("#");
            }
            printf("\n");
        }
        printf("\n");
    }


    return 0;
}



Measured memory_bytes: 2560
#include <bits/stdc++.h> 
#include <cstring>
using namespace std;
//typedef
typedef long long ll;
typedef vector<int> vi;
typedef vector<string> vs;
//define
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)

int main(){
   int n;
   float a;
   cin >> n ;
    if(n%2 == 0){
        cout << 0.5 << endl;
    }else{
        a = (double)(n/2 + 1)/(double)n;
        cout << a << endl;
    }
 return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define LL long long
#define Max 100005
#define Mod 1e9+7
const LL mod=1e9+7;
const LL inf=0x3f3f3f3f;
using namespace std;
char a[Max];
int n,q;
int sum[Max];
int main()
{
    scanf("%d%d",&n,&q);
    scanf("%s",a);
    for(int i=1;i<n;i++){
        if(a[i-1]=='A' && a[i]=='C')
            sum[i]=sum[i-1]+1;
        else
            sum[i]=sum[i-1];
    }
   /* for(int i=0;i<n;i++)
        printf("%d",sum[i]);*/
    int l,r;
    while(q--){
        scanf("%d%d",&l,&r);
        printf("%d\n",sum[r-1]-sum[l-1]);
    }

    return 0;
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){return o<<"("<<p.fs<<","<<p.sc<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}

string s;
int A[500001],B[500001];
void kmp(string s,int* A){
	A[0]=-1;
	int j=-1;
	rep(i,s.size()){
		while(j>=0&&s[i]!=s[j]) j=A[j];
		j++;
		A[i+1]=j;
	}
}
int main(){
	string s;
	cin>>s;
	int N=s.size();
	vector<int> ds;
	rep1(i,N-1){
		if(N%i==0) ds.pb(i);
	}
	int T=-1;
	for(int d:ds){
		bool is=1;
		rep(i,N) if(s[i]!=s[i%d]) is=0;
		if(is){
			T=d;
			break;
		}
	}
	if(T==-1){
		cout<<1<<endl<<1<<endl;
	}else if(T==1){
		cout<<N<<endl<<1<<endl;
	}else{
		kmp(s,A);
		rep(i,N) A[i]=i+1-A[i+1];
		reverse(all(s));
		kmp(s,B);
		rep(i,N) B[i]=i+1-B[i+1];
		int cnt=0;
		rep1(i,N-1){
			if( (A[i-1]==i || i%A[i-1]>0) && (B[N-1-i]==N-i || (N-i)%B[N-1-i]>0) ) cnt++;
		}
		cout<<2<<endl<<cnt<<endl;
	}
}


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

def solve():
    S = input()
    y, m, d = list(map(int, S.split("/")))

    if y < 2019:
        print("Heisei")
    elif y==2019 and m <= 4:
        print("Heisei")
    else:
        print("TBD")

if __name__ == "__main__":
    solve()


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

int main(){
	int a,b,c;
	cin >> a >> b >> c;
	
	int inputs[] = {a,b,c};
	
	for(int i = 2; i > 0; i--) {
		for(int j = 0; j < i; j++){
			if(inputs[j] > inputs[j+1])swap(inputs[j],inputs[j+1]);
		}
	}
	
	cout << inputs[0] << " " << inputs[1] << " " << inputs[2] << endl;
	
	return 0;
}



Measured memory_bytes: 3092
#include<cstdio>
#include<iostream>
using namespace std;
int main()
{
	int n,m,k;
	scanf("%d%d%d",&n,&m,&k);
	if(k==0)
	{
		cout<<"Yes"<<endl;
		return 0;
	}
	for(int i=1;i<=n;i++)
	for(int j=1;j<=m;j++)
	{
		if(i*j+(n-i)*(m-j)==k)
		{
			cout<<"Yes"<<endl;
			return 0;
		}
	}
	cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int n,i,j,k,l,m,r[200005][3]={},w[500005][2],nw=1,c[200005][2],nc=1,ncc,a[2],f=0;
  scanf("%d",&n);
  scanf("%d",&m);
  for(i=0;i<m;i++){
    for(j=0;j<2;j++){
      scanf("%d",&a[j]);
      a[j]--;
    }
    for(j=0;j<2;j++){
      w[nw][0]=a[j^1];
      if(r[a[j]][0]==0){
        r[a[j]][0]=nw;
      }else{
        w[r[a[j]][1]][1]=nw;
      }
      r[a[j]][1]=nw;
      nw++;
    }
  }
  c[0][0]=0;
  r[0][2]=1;
  while(nc!=0){
    ncc=nc;
    nc=0;
    for(i=0;i<ncc;i++){
      k=c[i][f];
      for(j=r[k][0];j!=0;j=w[j][1]){
        l=w[j][0];
        if(r[l][2]==0){
          r[l][2]=k+1;
          c[nc][f^1]=l;
          nc++;
        }
      }
    }
    f^=1;
  }
  printf("Yes\n");
  for(i=1;i<n;i++){
    printf("%d\n",r[i][2]);
  }
  return(0);
}

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

int main() {
    int S;
    cin >> S;
    bool A=false,B=false;
    if(0<S/100 && S/100 < 13)A=true;
    if(0<S%100 && S%100 < 13)B=true;
    string O;
    if(A&&B){
        O="AMBIGUOUS";
    }else if(A && !B){
        O="MMYY";
    }else if(!A && B){
        O="YYMM";
    }else{
        O="NA";
    }
    cout << O << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 1e10;

signed main() {
    string S;
    cin >> S;
    int A = 0;
    int ret = 0;
    for(int i = S.size() - 1;i >= 0;i--) {
        if(S.at(i) == 'W') {
            ret += i - A;
            A++;
        }
    }
    cout << ret << endl;
}

Measured memory_bytes: 640