akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define inf INT_MAX
#define INF LLONG_MAX
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
#define IN(a,n) rep(i,n){ cin>>a[i]; }
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
#define vi vector<int>



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

  int n,m;
  cin>>n>>m;
  vector<P> v;
  rep(i,m){
    int a,b;
    cin>>a>>b;
    v.PB(P(b,a));
  }

  sort(all(v));
  int ans=0,t=0;
  rep(i,m){
    if(t>v[i].S) continue;
    t=v[i].F;
    ans++;
  }

  cout<<ans<<endl;

}

Measured memory_bytes: 2420
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.BufferedReader;

public class Main{
    public static void main(String[] args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        int a = Integer.parseInt(br.readLine());

        long result = fact(a);

        System.out.println(result);
    }

    private static long fact(int x){
        if(x == 1) return 1;
        else return x * fact(x-1);
    }
}

Measured memory_bytes: 24088
#include<stdio.h>

#define N 100


int main(void){

	int n,v,j;	
	int A[N];

	scanf("%d",&n);	

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

		scanf("%d",&A[i]);

		}

		for(int i=0;i<n-1;i++){

				printf("%d ",A[i]);
				
		
		}
	
		printf("%d\n",A[n-1]);
	for(int i=1;i<n;i++){

		v=A[i];
		j=i-1;

		while(j>=0 && A[j] > v){

			A[j+1] = A[j];
		
			j--;

			A[j+1] = v;
		}

		for(int i=0;i<n-1;i++){

			printf("%d ",A[i]);
			
		
		}
	
	printf("%d\n",A[n-1]);

	

	
	}		


	return 0;
}


Measured memory_bytes: 2684
#ABC057_C
N = int(input())
divisor_bigger_length = []
for i in range(1,int(N**0.5)+1):
    if N % i ==0:
        divisor_bigger_length.append(max( len(str(i)), len(str(N//i)) ))
#print(divisor_bigger_length)
print(min(divisor_bigger_length))

Measured memory_bytes: 2940
import numpy as np

N,M = map(int,input().split())
A = np.array([list(input()) for i in range(N)])
B = np.array([list(input()) for i in range(M)])
f = False

for i in range(N-M+1):
  for j in range(N-M+1):
    if (A[i:i+M,j:j+M]==B).all():
      f = True

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


Measured memory_bytes: 12416
package main

import (
	"fmt"
)

func main() {
	var a, b int
	fmt.Scan(&a, &b)

	if (a+b)%2 == 0 {
		fmt.Println((a + b) / 2)
	} else {
		fmt.Println((a+b)/2 + 1)
	}
}


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

const int MAX_V=4040;
struct edge {int to,cost;};
vector<vector<edge>> G(MAX_V);
vector<tuple<int,int,int> > E;
int N,M;

int par[MAX_V]; //　親
int rnk[MAX_V]; // rank, 木の深さ

// V要素で初期化
void init(){
  for(int i=0;i<MAX_V;i++){
    par[i]=i;
    rnk[i]=0;
  }
}

// 木の根を求める
int find(int x){
  if (par[x] == x){
    return x;
  }else{
    return par[x] = find(par[x]);
  }
}

// ｘとｙの属する集合を併合
void unite(int x, int y){
  x = find(x);
  y = find(y);
  if (x == y) return;

  if (rnk[x] < rnk[y]){
    par[x] = y;
  }else{
    par[y] = x;
    if (rnk[x] == rnk[y]) rnk[x]++;
  }
}

// ｘとｙが同じ集合に属するかどうか
bool same(int x, int y){
  return find(x) == find(y);
}

int maxE[4040][4040];

int main(){
  cin>>N>>M;
  rep(i,M){
    int a,b,c; cin>>a>>b>>c; a--,b--;
    E.push_back(make_tuple(c,a,b));
  }
  sort(E.begin(),E.end());
  init();
  ll sum=0;
  rep(i,M){
    tuple<int,int,int> t=E[i];
    int c=get<0>(t),a=get<1>(t),b=get<2>(t);
    if(!same(a,b)){
      unite(a,b);
      G[a].push_back({b,c});
      G[b].push_back({a,c});
      sum+=c;
    }
  }
  rep(s,N){
    queue<tuple<int,int,int> > que;
    que.push(make_tuple(s,-1,0));
    while(que.size()){
      tuple<int,int,int> t=que.front(); que.pop();
      int v=get<0>(t), p=get<1>(t), ma=get<2>(t);
      for(auto e:G[v]) if(e.to!=p){
        if(e.cost>ma) ma=e.cost;
        maxE[s][e.to]=ma;
        que.push(make_tuple(e.to,v,ma));
      }
    }
  }
  int Q; cin>>Q;
  rep(i,Q){
    int s,t; cin>>s>>t; s--,t--;
    cout<<sum-maxE[s][t]<<endl;
  }
  return 0;
}


Measured memory_bytes: 70636
// C
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

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

#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif


//#include <bits/stdc++.h>
#define rep(i, z, n) for(int i = z; i < n; i++)
#define repB(i, z, n) for(int i = n - 1; i >= z; i--)
#define all(v) v.begin(), v.end()
typedef long long ll;
#define PI 3.14159265358979
//const int64_t INF = 1LL << 60;
//const int INF = 1 << 29;
//const int64_t MOD = 1000000007;
//const int64_t INF = 998244353;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;
//#define P pair<int, int>
typedef pair<int, int> P;
using namespace std;

vector<pair<int64_t, int64_t>> prime_factorize(int64_t n) {
    vector<pair<int64_t, int64_t>> res;
    for (int64_t p = 2; p * p <= n; p++) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0){
            num++;
            n /= p;
        }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}
 
int main(){
    int64_t N;
    cin >> N;
    vector<pair<int64_t, int64_t>> p = prime_factorize(N);
    
    int64_t count = 0;
    rep(i, 0, p.size()){
        int64_t X = p.at(i).first;
        int64_t Y = p.at(i).second;
        int n = 0;
        while(((n + 2) * (n + 1)) / 2 <= Y){
            n++;
        }
        //cout << X << " " << Y << " " << n << endl;
        count += n;
    }
    cout << count << endl;
}


Measured memory_bytes: 3628
#include <iostream>

#define NMAX (2*100000)

int main() {
    int N, Q;
    std::string S;
    
    std::cin >> N >> Q;
    std::cin >> S;
    
    using P = std::pair<char, char>;
    P temp, td[NMAX];
    
    for (int i=0; i<Q; ++i) {
        std::cin >> temp.first >> temp.second;
        td[i] = temp;
    }
    
    int lcur = 0;
    int rcur = N-1;
    for (int i=Q-1; i>=0; --i) {
        //std::cout << td[i].first << " " << td[i].second << std::endl;
        
        if (S[lcur]==td[i].first && td[i].second=='L') {
            lcur++;
        } else if (S[lcur-1]==td[i].first && td[i].second=='R' && lcur!=0) {
            lcur--;
        } 
        
        if (S[rcur]==td[i].first && td[i].second=='R') {
            rcur--;
        } else if (S[rcur+1]==td[i].first && td[i].second=='L' && rcur!=N) {
            rcur++;
        }
        
        //std::cout << lcur << " " << rcur << std::endl;
    }
    int ans = N;
    if (lcur >= 0) ans -= lcur;
    if (rcur <= N-1) ans -= ((N-1) - rcur);
    std::cout << ans << std::endl;
}

Measured memory_bytes: 900
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const ll mod = 1e9+7;

int main(){
    int n,k;
    cin >> n >> k;
    vector<int> h(n);
    int ans = mod;
    for(int i = 0; i < n; i++) cin >> h[i];
    sort(h.begin(),h.end());    
    for(int i = 0; i < n-k+1; i++){
        int can = h[i+k-1]-h[i];
        if(ans > can) ans = can;
    }
    cout << ans << endl;
    return 0;
}


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

int main()
{
//#ifndef ONLINE_JUDGE
//    freopen("input.txt","r",stdin);
//#endif
    int n;
    cin>>n;
    n--;
    vector<int>arr(n);
    for(int i = 0 ;i<n;i++)
        cin>>arr[i];
    ll ans =  0;
    ans+=arr[0];
    for(int i = 0;i<n-1;i++)
        ans+=min(arr[i],arr[i+1]);
    ans+=arr[n-1];
    cout<<ans<<endl;
    return 0;
}

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

#define for0(i, n) for (ll i = 0; i < (ll)(n); ++i) // 0 based indexing
#define for1(i, n) for (ll i = 1; i <= (ll)(n); ++i) // 1 based indexing
#define forc(i, l, r) for (ll i = (ll)(l); i <= (ll)(r); ++i) // closed interver from l to r r inclusive
#define forr0(i, n) for (ll i = (ll)(n) - 1; i >= 0; --i) // reverse 0 based.
#define forr1(i, n) for (ll i = (ll)(n); i >= 1; --i) // reverse 1 based

#define ff first
#define ss second
#define pb push_back

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
  string s,t;
  cin >> s >> t;
  ll ans =0;
  for0(i,3){ if(s[i] == t[i] ) ans++; }
  cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 256
def makelist(n, m):
    return [[0 for _ in range(m)] for _ in range(n)]


N = int(input())
A = [0]*N
for i in range(N):
    A[i] = int(input())


A.sort()

dp1 = [0]*N
dp2 = [0]*N

ans = 0
if N % 2 == 0:
    for i in range(N//2):
        ind = i * 2 + 1
        dp1[ind] = A[i]
            
    for i in range(N//2, N):
        ind = (i - N//2) * 2
        dp1[ind] = A[i]
        
    for i in range(N-1):
        ans += abs(dp1[i] - dp1[i+1])
else:
    # miniを多く
    dp1[0] = A[N//2-1]
    dp1[-1] = A[N//2]
    for i in range(N//2-1):
        ind = (i+1) * 2
        dp1[ind] = A[i]
    for i in range(N//2 + 1, N):
        ind = (i - (N//2+1)) * 2 + 1
        dp1[ind] = A[i]

    for i in range(N-1):
        ans += abs(dp1[i] - dp1[i+1])


    # maxを多く
    dp2[0] = A[N//2]
    dp2[-1] = A[N//2+1]
    for i in range(N//2):
        ind = i * 2 + 1
        dp2[ind] = A[i]
    for i in range(N//2 + 2, N):
        ind = (i - (N//2+1)) * 2
        dp2[ind] = A[i]

    cnt = 0
    for i in range(N-1):
        cnt += abs(dp2[i] - dp2[i+1])
    ans = max(ans, cnt)
        
print(ans)



Measured memory_bytes: 49496
#include <iostream>
#include <queue>
#include <string>
#include <algorithm>
using namespace std;

int main(int argc, char** argv) {
	
	int n, q, t;
	int total_time = 0;
	string name;
	queue<pair<string, int> > Q;
	
	cin >> n >> q;
	
	for (int i = 0; i < n; i++) {
		cin >> name >> t;
		Q.push(make_pair(name, t));
	}
	
	while (!Q.empty()) {
		pair<string, int> item = Q.front();
		total_time += min(item.second, q);
		item.second -= min(item.second, q);
		if (item.second == 0) {
			cout << item.first << " " << total_time << endl; 
		} else {
			Q.push(item);
		}
		Q.pop();
	}
	
	return 0;
}


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

using namespace std;
using namespace __gnu_pbds;

const int maxn = 2e5 + 7;
const int mod = 998244353;

int n;
struct node
{
	int id,l,r;
}a[maxn];
bool operator<(node a,node b)
{
	return a.l<b.l;
}
stack<node>s;
long long dp[maxn];

int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d%d",&a[i].l,&a[i].r);
	for(int i=1;i<=n;i++)
	{
		a[i].r+=a[i].l;
	}
	sort(a+1,a+1+n);
	for(int i=1;i<=n;i++)
		a[i].id=i;

	a[n+1].id = n+1;
	a[n+1].l = a[n+1].r = 2e9+7;
	s.push(a[n+1]);
	dp[n+1]=1;
	
	for(int i=n;i>=1;i--)
	{
		while(!s.empty() && a[i].r > s.top().l)
			s.pop();
		dp[i]=(dp[i+1]+dp[s.top().id])%mod;
		s.push(a[i]);
	}
	printf("%lld\n",dp[1]);
	return 0;
}




Measured memory_bytes: 5376
#include <bits/stdc++.h>
using namespace std;
 
int main(){
	ios_base::sync_with_stdio(false);
	cout.tie(NULL);
	cin.tie(NULL);
	long long n,m,k;
	cin >> n >> m >> k;
	vector<long long> v1;
	for(long long i = 0 ; i < n ; i += 1){
		long long a;
		cin >> a;
		if(i == 0){
			v1 = {a};
			continue;
		}
		v1.push_back(v1.back()+a);
	}
	long long ans = upper_bound(v1.begin(),v1.end(),k)-v1.begin() , sum = 0;
	for(long long i = 0 ; i < m ; i += 1){
		long long a;
		cin >> a;
		sum += a;
		if(sum > k){
			break;
		}
		ans = max(ans,i+1+(upper_bound(v1.begin(),v1.end(),k-sum)-v1.begin()));
	}
	cout << ans << endl;
}

Measured memory_bytes: 5324
#include <string>
#include <cctype>
#include<iostream>
#include<map>
#include<sstream>
using namespace std;
istream* input;
int no_of_errors;
enum Token_value {
  END,NUMBER,PLUS='+',MINUS='-',MUL='*',DIV='/',
  PRINT=';',ASSIGN='=',LP='(',RP=')'
};
Token_value curr_tok = PRINT;
int number_value;
string string_value;
Token_value get_token()
{
  char ch;
  do {
    if(!input->get(ch)) return curr_tok = END;
  } while (ch!='\n' && isspace(ch));
 
  switch (ch) {
  case ';':
  case '\n':
    return curr_tok=PRINT;
  case '*':
  case '/':
  case '+':
  case '-':
  case '(':
  case ')':
  case '=':
return curr_tok=Token_value(ch);
  case '0': case '1': case '2': case '3': case '4':
case '5': case '6': case '7': case '8': case '9':
    input->putback(ch);
    *input >> number_value;
    return curr_tok=NUMBER;
  }
}
int expr(bool);
int prim(bool get)
{
  if (get) get_token();
  switch (curr_tok) {
  case NUMBER:
    { int v = number_value;
      get_token();
      return v;
    }
  case MINUS:
    return -prim(true);
  case LP:
    { int e = expr(true);
      get_token();
      return e;
    }
  }
}
int term(bool get)
{
  int left = prim(get);
  for (;;)
    switch (curr_tok) {
    case MUL:
      left *= prim(true);
      break;
    case DIV:
      if (int d = prim(true)) {
left /= d;
break;
      }
    default:
      return left;
    }
}
int expr(bool get)
{
  int left = term(get);
  for (;;)
    switch (curr_tok) {
    case PLUS:
      left += term(true);
      break;
    case MINUS:
      left -= term(true);
      break;
    default:
      return left;
    }
}
int main()
{
  int n;
  input = &cin;
  cin>>n;
  while(n--){
    while (*input) {
      get_token();
      if (curr_tok == END) break;
      if (curr_tok == PRINT) continue;
      cout << expr(false) << '\n';
    }
  }
  return no_of_errors;
} 

Measured memory_bytes: 0
#include<stdio.h>
#define min(a,b) (a>b?b:a)
#define max(a,b) (a<b?b:a)
int main(){
  int N,a,b;
  scanf("%d%d%d",&N,&a,&b);
  printf("%d %d\n",min(a,b),max(0,a+b-N));
}

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

using namespace std;

namespace {

    typedef double real;
    typedef long long ll;

    template<class T> ostream& operator<<(ostream& os, const vector<T>& vs) {
        if (vs.empty()) return os << "[]";
        auto i = vs.begin();
        os << "[" << *i;
        for (++i; i != vs.end(); ++i) os << " " << *i;
        return os << "]";
    }
    template<class T> istream& operator>>(istream& is, vector<T>& vs) {
        for (auto it = vs.begin(); it != vs.end(); it++) is >> *it;
        return is;
    }

    const real EPS = 1e-5;
    bool EQ(real a, real b) { return abs(a - b) < EPS; }
    struct Matrix : public vector< vector<real> > {
        int H, W;
        Matrix(int H, int W) : H(H), W(W) {
            clear(); resize(H, vector<real>(W, 0));
        }
    };
    void eliminate(Matrix& M) {
        // ????????????±???\???
        int H = M.H, W = M.W;
        for (int i = 0; i < H; i++) {
            int p = i;
            for (int j = i; j < H; j++) {
                if (M[j][i] > M[p][i]) {
                    p = j;
                }
            }
            if (EQ(M[p][i], 0)) continue;
            swap(M[i], M[p]);
            real x = M[i][i];
            for (int j = i; j < W; j++) M[i][j] /= x;
            for (int k = i + 1; k < H; k++) {
                real y = M[k][i];
                for (int l = i; l < W; l++) {
                    M[k][l] -= y * M[i][l];
                }
            }
        }
        // ????¢??????????£?????\
        for (int i = H - 1; i >= 0; i--) {
            for (int j = i - 1; j >= 0; j--) {
                real x = M[j][i];
                for (int k = i; k < W; k++) {
                    M[j][k] -= x * M[i][k];
                }
            }
        }
    }

    int D;
    vector<real> V;
    bool input() {
        cin >> D;
        if (D == 0) return false;
        V.resize(D + 3);
        cin >> V;
        return true;
    }

    void solve() {
        for (int d = 0; d < D + 3; d++) {
            // assume f(d) is the outliner;
            Matrix M(D + 2, D + 2);
            for (int i = 0, p = 0; i < D + 3; i++) {
                if (i == d) continue;
                for (int j = 0; j < D + 1; j++) {
                    M[p][j] = pow(i, j);
                }
                M[p][D + 1] = V[i];
                p++;
            }
            eliminate(M);
            if (EQ(M[D + 1][D + 1], 0)) {
                cout << d << endl;
                return;
            }
        }
        assert(false);
    }
}

int main() {
    while (input()) solve();
    return 0;
}

Measured memory_bytes: 3388
from math import factorial

def comb(n, k):
    return factorial(n)//factorial(k)//factorial(n-k)

inp = input().split()

N = int(inp[0])
K = int(inp[1])

for i in range(1, K+1):
    if(i > N-K+1):
        print(0)
    else:
        print("%d"%(comb(N-K+1, i)*comb(K-1, i-1)%1000000007))


Measured memory_bytes: 69976
/* Author : Prasuk Jain */
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define int              long long int
#define ull              unsigned long long
#define ld               long double
#define fo(i, n)         for(int i=0; i<n; i++)
#define Fo(i, a, b)      for(int i=a; i<b; i++)
#define rfo(i, n)        for(int i=n-1; i>=0; i--)
#define Rfo(i, a, b)     for(int i=b-1; i>=a; i--)
#define tr(it, v)        for(auto it=v.begin(); it!=v.end(); it++)
#define F                first
#define S                second
#define vi               vector<int>
#define vvi              vector<vector<int>>
#define pii              pair<int, int>
#define pqb              priority_queue<int>
#define pqs              priority_queue<int, vi, greater<int>>
#define mii              map<int, int>
#define uset             unordered_set<int>
#define umap             unordered_map<int, int>
#define mp               make_pair
#define pb(x)            push_back(x)
#define hcf(x, y)        __gcd(x, y)
#define lcm(x, y)        boost::math::lcm(x,y)
#define setpre(x, y)     fixed << setprecision(y) << x
#define setbits(x)       __builtin_popcountll(x)
#define zerolead(x)      __builtin_clzll(x)
#define zerotrail(x)     __builtin_ctzll(x)
#define all(x)           x.begin(), x.end()
#define sortall(x)       sort(all(x))
#define PI               3.1415926535897932384626
const int mod = 1e9+7;
const int inf = 1e18;
int mpow(int base, int exp);
bool isprime(int num);
void prifact(int num);

//*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!//

void coderprasukj(){ 
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}

int32_t main() {
    coderprasukj();
    double a, b, h, m, x, ans;
    cin >> a >> b >> h >> m;
    x = abs(30*h + m/2 - 6*m);
    x = x*PI/180;
    ans = sqrt((a*a) + (b*b) - (2*a*b*cos(x)));
    cout << setpre(ans, 9) << "\n";
    return 0;
}

//*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!//

int mpow(int base, int exp) {
    base %= mod;
    int result = 1;
    while (exp > 0) {
        if (exp & 1) result = ((int)result * base) % mod;
        base = ((int)base * base) % mod;
        exp >>= 1;
    }
  return result;
}

bool isprime(int num) {
    if(num <= 1) return false;
    for(int i=2; i*i <= num; i++)
        if(num%i == 0) return false;
    return true;
}

void prifact(int num){
    for(int i=2; i<=num; i++)
    if(num%i == 0){
        int cnt = 0;
        while(num%i == 0)
        cnt++ , num /= i;
        cout << i << "^" << cnt << " ";
    }
    if(num > 1)
    cout << num << "^" << "1" << " ";
}




Measured memory_bytes: 4188
#include<iostream>
#include<cassert>
#include<stdexcept>
#include<utility>
#include<functional>
#include<numeric>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<array>
#include<stack>
#include<queue>
#include<deque>
#include<vector>
#include<complex>
#include<set>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include<string>
#include<bitset>
#include<bits/stdc++.h>

namespace ProconLib{
    using Hash=__int128;
    template<typename Container>
    class RollingHash{
        int N;
        const static Hash MOD=Hash(1e18l)+9;
        const static Hash A=Hash(1e12l)+39;
        std::vector<Hash> powA;
        std::vector<Hash> h;
        public:
        RollingHash(Container c):N(c.size()),h(N+1,0),powA(N+1){
            int id=0;
            for(auto e:c){
                h[id+1]=((h[id]*A+e)%MOD);
                id++;
            }
            powA[0]=1;
            for(int i=0;i+1<=N;i++) powA[i+1]=(powA[i]*A)%MOD;
        }
        Hash get(int l,int r){
            return (h[r]+(MOD-(h[l]*powA[r-l])%MOD))%MOD;
        }
        Hash getA(){return A;}
        Hash getMOD(){return MOD;}
    };
};

//not verified

using namespace std;
using namespace ProconLib;
using ll=long long;

const int SIZE=1e6+3;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin>>s;

    string t;
    cin>>t;
    swap(s,t);
    string tc;
    for(int i=0;i<SIZE;i++){
        tc+=t[i%t.size()];
    }
    RollingHash<string> rhs(s);
    RollingHash<string> rht(tc);

    vector<int> p(t.size());
    for(int i=0;i<t.size();i++){
        if(rhs.get(0,s.size())==rht.get(i,i+s.size())){
            p[i]=(i+s.size())%t.size();
        }
        else{
            p[i]=-1;
        }
    }
    vector<vector<int>> g(t.size());
    for(int i=0;i<g.size();i++){
        if(p[i]!=-1){
            g[p[i]].push_back(i);
        }
    }
    vector<int> dp(t.size());
    queue<int> qs;
    for(int i=0;i<g.size();i++) if(p[i]==-1) qs.push(i);
    int cnt=0;
    while(!qs.empty()){
        auto tmp=qs.front(); qs.pop();
        cnt++;
        for(auto to:g[tmp]){
            qs.push(to);
            dp[to]=dp[tmp]+1;
        }
    }
    if(cnt==t.size()){
        cout<<*max_element(dp.begin(),dp.end())<<endl;
    }
    else{
        cout<<-1<<endl;
    }


    return 0;
}
  



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

int main() {
    string N; cin >> N;
    int K; cin >> K;
    int L = N.size();
    vector<vector<int>> dp0(L, vector<int>(K+1)), dp1(L, vector<int>(K+1));
    dp0[0][0] = 1;
    dp0[0][1] = (int)(N[0]-'0')-1;
    dp1[0][1] = 1;
    for (int i = 1; i < L; i++) {
        int tmp = (int)(N[i]-'0');
        for (int j = 0; j <= K; j++) {
            if (tmp != 0) {
                if (j) dp1[i][j] = dp1[i-1][j-1];
            }
            else {
                dp1[i][j] = dp1[i-1][j];
            }

            dp0[i][j] = dp0[i-1][j];
            if (tmp) {
                dp0[i][j] += dp1[i-1][j];
            }
            if (j) {
                dp0[i][j] += dp0[i-1][j-1]*9;
                if (tmp) {
                    dp0[i][j] += dp1[i-1][j-1]*(tmp-1);
                }
            }
        }
    }
    cout << dp0[L-1][K] + dp1[L-1][K] << endl;
}


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

namespace ABC144D
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] abx = Console.ReadLine().Split(' ');
            int a = int.Parse(abx[0]);
            int b = int.Parse(abx[1]);
            int x = int.Parse(abx[2]);
            int v = a * a * b;
            double ans = 0;
            if (v / 2 < x)
            {
                double h = (((double)v - x) * 2) / (a * a);
                double tan = Math.Atan(h / a);
                ans = tan * 180 / Math.PI;
                //Console.WriteLine(h);
            }
            else
            {
                double h = ((double)x * 2) / (a * b);
                double tan = Math.Atan(h / b);
                ans = 90 - tan * 180 / Math.PI;
            }
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 27716
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define MAX(a,b) a=a>b?a:b
#define MIN(a,b) a=a>b?a:b
#define REP(i,x,n) for(int i=x;i<n;i++)
#define REPR(i,x,n) for(int i=n-1;i>=x;i--)
#define F first
#define S second
using namespace std;
typedef long long ll;
const ll MOD =1e9 + 7;



int main(){
	int n,x,y;
    string s;
    cin>>s;
    
        if(s=="SUN")
            cout<<7;
            if(s=="SAT")
            cout<<1;
           if(s== "FRI")
            cout<<2;
          
            if(s=="THU")
            cout<<3;
            ;
            if(s== "WED")
            cout<<4;
            ;
            if(s== "TUE")
            cout<<5;
            ;
            if(s== "MON")
            cout<<6;
            ;
            
    
    
    cout<<endl;
	
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define MAX ((int)(1e7))
#define pi (2*acos(0))
#define mp make_pair
#define M ((int)(1e9 + 7))
#define xx first
#define yy second
#define NN ((int)(5e5+2))
#define N ((int)(4e2 + 2))
#define pq priority_queue
///#define Q queue
#define eps 0
#define log 20
#define pb push_back
#define MOD 998244353


using namespace std;
using namespace __gnu_pbds;

typedef long long int ll;
typedef unsigned long long int lu;

typedef tree < int ,  null_type ,  less < int > ,  rb_tree_tag ,  tree_order_statistics_node_update > o_set;

int main()
{
    int t;
    scanf("%d",&t);
    while(t--){
        ll a, b, c, d;
        scanf("%lld %lld %lld %lld",&a,&b,&c,&d);
        if(a<b || d<b) printf("No\n");
        else{
            if(c+1>=b){
                printf("Yes\n");
            }
            else{
                ll s = a - b*(a/b);
                ll l = c+1-s, r = b-1-s, x = d%b;
                if(x>0) x = __gcd(x,b);
                if(l<=0 || (x>0 && ((l/x)*x==l || ((1 + l/x)*x<=r && (1 + l/x)*x>=l)))) printf("No\n");
                else printf("Yes\n");
            }
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using P = pair<int, int>;
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};


int main(){
    int x, a, b;
    cin >> x >> a >> b;
    string ans = "safe";
    if (a>=b) ans = "delicious";
    else if (b-a>=x+1) ans = "dangerous";
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3628
#include<iostream>
#define MAX_N 100001
using namespace std;

int a_seq[MAX_N];
bool is_checked[MAX_N];

int main() {
    int N, a;
    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> a;
        a_seq[i] = --a;
    }
    int now_button = 0, ans = 0;
    while (true) {
        if (is_checked[now_button]) {
            cout << -1 << endl;
            return 0;
        }
        if (now_button == 1) {
            cout << ans << endl;
            return 0;
        }
        is_checked[now_button] = true;
        ans++;
        now_button = a_seq[now_button];
    }
    return 0;
}

Measured memory_bytes: 768
from sys import stdin
input = stdin.readline


class Bit:
    def __init__(self, n):
        self.size = n
        self.tree = [0] * (n + 1)

    def sum(self, i):
        s = 0
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s

    def add(self, i, x):
        while i <= self.size:
            self.tree[i] += x
            i += i & -i


N, Q = map(int, input().split())
c = list(map(int, input().split()))

lr = []
for i in range(Q):
    l, r = map(int, input().split())
    lr.append([l, r, i])

lr.sort(key=lambda x: x[1])
# print("lr", lr)
rightest = [-1] * (N + 1)
current_q = 0
bit = Bit(N)
ans = [0] * Q

for i in range(N):
    if rightest[c[i]] != -1:
        bit.add(rightest[c[i]] + 1, -1)
    rightest[c[i]] = i
    bit.add(i + 1, 1)
    # print(bit.tree)

    while current_q < Q and lr[current_q][1] == i + 1:
        ans[lr[current_q][2]] = bit.sum(lr[current_q][1]) - bit.sum(lr[current_q][0] - 1)
        current_q += 1

for i in range(Q):
    print(ans[i])


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

#define pb push_back
#define mp make_pair
#define F first
#define S second
#define FOR(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define SORT(c) sort((c).begin(),(c).end())

typedef long long ll;
const ll inf = 2e9+7;
const int MAX_N = 5e5+5;
int dx[] = {-1,0,1,0},dy[] = {0,1,0,-1};
vector<ll> prime;

ll inv[MAX_N],fac[MAX_N];

template <class T = int> T in(){T x;cin >> x;return (x);}
inline ll GCD(ll a,ll b){ll c;while(b!=0){c=a%b;a=b;b=c;}return a;}
inline ll LCM(ll a,ll b){return a*b/GCD(a,b);}
inline ll POW(ll a,ll b){ll c=1;while(b>0){if(b&1){c=a*c%inf;}a=a*a%inf;b>>=1;}return c;}
inline void _nCr(){fac[0]=1;for(int i=1;i<MAX_N;i++){fac[i]=fac[i-1]*i%inf;}for(int i=0;i<MAX_N;i++){inv[i]=POW(fac[i],inf-2);}}
inline ll nCr(ll n,ll r){return (fac[n]*inv[r]%inf)*inv[n-r]%inf;}
inline void PRI(ll n){bool a[n+1];for(int i=0;i<n+1;i++){a[i]=1;}for(int i=2;i<n+1;i++){if(a[i]){prime.pb(i);ll b=i;while(b<=n){a[b]=0;b+=i;}}}}

class UnionFind {
private:
	int par[MAX_N];
	int rank[MAX_N];
public:
	void init(int n);
	int find(int x);
	void unite(int x,int y);
	bool same(int x,int y);
};

void UnionFind::init(int n) {
	for (int i = 0;i < n;i++) {
		par[i] = i;
		rank[i] = 0;
	}
}

int UnionFind::find(int x) {
	if (par[x] == x) return x;
	else return par[x] = find(par[x]);
}

void UnionFind::unite(int x,int y) {
	x = find(x);
	y = find(y);
	if (rank[x] < rank[y]) par[x] = y;
	else {
		par[y] = x;
		if (rank[x] == rank[y]) rank[x]++;
	}
}

bool UnionFind::same(int x,int y) {
	x = find(x);
	y = find(y);
	return x == y;
}

int main() {
	int a = in(), b = in(),k = in();
	int cnt = 0;
	vector<int> div;
	FOR(i,1,101) {
		if (a%i==0 && b%i==0) {
			cnt++;
			div.pb(i);
		}
	}
	cout << div[div.size()-k] << endl;
}

Measured memory_bytes: 256
import java.util.*;

class Main {
    final private static long mod = 998244353;
    public static void main(String[] args) {
        //final int MOD = 998244353;
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        int D[] = new int[N];
        for (int i=0; i<N; i++)
            D[i] = Integer.parseInt(sc.next());
        sc.close();

        long C[] = new long[Arrays.stream(D).max().getAsInt() + 1];
        for (int i : D) {
            C[i]++;
        }

        if (D[0] != 0 || C[0] != 1) {
            System.out.println("0");
            return;
        }

        long ans = 1;
        for (int i=0; i<C.length-1; i++) {
            ans *= modPow(C[i], C[i+1]);
            ans %= mod;
        }

        System.out.println(ans);
    }

    private static long modPow(long x, long y) {
        long z = 1;
        while (y>0) {
            if (y%2==0) {
                x = (x * x) % mod;
                y /= 2;
            } else {
                z = (z * x) % mod;
                y--;
            }
        }
        return z;
    }
}

Measured memory_bytes: 49000
#include <iostream>
#include <math.h>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <iomanip>
using namespace std;



int main() {
	int N;
	
	cin >> N;
	vector<int> X(N);
	int sum = 0;
	for (int i = 0; i < N; i++){
		cin >> X[i];
		sum += X[i];
	}
	
	int P, P1,ans = 0, ans1 = 0;
	if(sum % N == 0){
		P = sum / N;
		for(int i = 0; i < N; i++){
			ans = ans + (X[i] - P) * (X[i] - P);
		}
	}
	else{
		P = sum / N;
		P1 = P + 1;
		for(int i = 0; i < N; i++){
			ans = ans + (X[i] - P) * (X[i] - P);
			ans1 = ans1 + (X[i] - P1) * (X[i] - P1);
		}
		if(ans1 < ans){
			ans = ans1;
		}
	}

	cout << ans;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<int64_t,int64_t> pll;
typedef vector<int64_t> vl;
int dx[]={1,-1,0,0,1,-1,1,-1};
int dy[]={0,0,1,-1,1,-1,-1,1};
const long double PI = acos(-1);
#define INF (2147483647)
#define mod (1000000007)
#define limit (7368791)
#define rep(i,a,b) for (int64_t i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
#define sz(s) (s).size()
#define ALL(a) begin(a),end(a)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

ll n,m,l=1,a[100010],i;
ll r(){ll x;cin>>x;return x;}
ll gcd(ll a,ll b){
    if(!b)return a;
    return gcd(b,a%b);
}
ll f(){
    REP(i,n){
        l=l/gcd(a[i],l)*a[i];
        if(l>m)return 0;
    }
    REP(i,n)if(!(l/a[i]%2))return 0;
    return m/l+1>>1;
}
void solve() 
{
    cin>>n>>m;
    REP(i,n)a[i]=r()/2;
    cout<<f()<<endl;
}
int main()
{
    cin.tie(0);
	ios::sync_with_stdio(false);
    solve();
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <vector>
#include <string>
#define SIS std::ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);

using namespace std;
typedef long long ll;
#define PAI 3.14159265358979323846
const int MAX = 0x7ffffff;
int t;

int main()
{
	SIS;
	double r;
	cin >> r;
	printf("%.20f\n", 2 * PAI * r); 
}

Measured memory_bytes: 3760
import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    // 整数の入力
	int a = Integer.parseInt(sc.next());
    int b = Integer.parseInt(sc.next());
    int unuse = 1;
    int count = 0;
    
    while(unuse < b){
      unuse--;
      unuse += a;
      count++;
    }
    
    System.out.println(count);
    
  }
}

Measured memory_bytes: 23252
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;

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

const ll INF=1e18;

int main(){
    ll n;
    cin >> n;
    map<ll,ll> m;
    vector<ll> a(n);
    rep(i,n){
       cin >> a[i];
       a[i]--;
    }
    ll pos=0;
    ll cnt=0;
    while(!m.count(pos)){
        m[pos]++;
        pos=a[pos];
        cnt++;
        if(pos==1){
            cout << cnt << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
} 


Measured memory_bytes: 10204
n = int(input())
a = [0] + list(map(int, input().split()))

for i in range(n, 0, -1):
  a[i] = sum(a[i::i]) % 2

print(sum(a))

for j in range(1, n+1):
  if a[j] == 1:
    print(j)

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

int main()
{
	int n;
	cin>>n;
	int c=n%10;
	if(c==3)
	cout<<"bon";
	else if(c==0 || c==1 ||c==6 || c==8)
	cout<<"pon";
	else
	cout<<"hon";

 return 0;
}


Measured memory_bytes: 3612
/*

宣告——
汝身听吾号令，托付吾之命运于汝之剑，
应圣杯之召，若汝遵从此意志此理，回应吧。
在此起誓，吾愿成就世间一切之善行，吾愿诛尽世间一切之恶行。
汝为身缠三大言灵之七天，从抑止之轮显现吧，天秤之守护者！

*/
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cassert>
#include<bitset>
using namespace std;
inline int read(){
	int re=0,flag=1;char ch=getchar();
	while(!isdigit(ch)){
		if(ch=='-') flag=-1;
		ch=getchar();
	}
	while(isdigit(ch)) re=(re<<1)+(re<<3)+ch-'0',ch=getchar();
	return re*flag;
}
int n;bitset<4000010>b;
int main(){
	n=read();b[0]=1;int i,sum=0,a;for(i=1;i<=n;i++) a=read(),b|=b<<a,sum+=a;
	for(i=(sum+1)/2;;i++) if(b[i]){cout<<i;return 0;}
}
/*

20
100 200 300 400 500 600 1000 1 1 1 1 1 1
123
132
1
3

2
3
7657


*/

Measured memory_bytes: 1664
import itertools
N = int(input())
X = int(((8 * N + 1)**0.5 - 1) // 2)
if N != X * (X + 1) // 2:
    print('No')
    exit()
index = 0
ans = [[X] for _ in range(X + 2)]
for i, j in itertools.combinations(range(1, X + 2), 2):
    index += 1
    ans[i] += [index]
    ans[j] += [index]
print('Yes')
print(X + 1)
[print(*_) for _ in ans[1:]]


Measured memory_bytes: 9544
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i ,n) for(int i = 0 ; i < (n) ; i ++ )
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
using ll = long long;
using vll=vector<ll>;
using P = pair<int, int>;
const int inf=1e9+7;
const ll INF=1e18;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }
int main() {
 int n;
  cin>>n;
  rep(i,11){
   if(n<=i*100+i*10+i){
     if(n> (i-1)*100+(i-1)*10+i-1) cout<<i*100+i*10+i<<endl;
   }
  }
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#define min(p,q)((p)<(q)?(p):(q))

long v[60],w[60],c[60],u[60],dp[2600];
int main(){
	long n,m;
	scanf("%ld%ld",&n,&m);
	for(int i=0;i<n;i++)scanf("%ld%ld%ld",v+i,w+i,c+i);
	//効率降順
	for(int i=n-1;i>=0;i--)for(int j=0;j<i;j++){
		if(v[j]*w[j+1]<v[j+1]*w[j]){
			long t;
			t=v[j];v[j]=v[j+1];v[j+1]=t;
			t=w[j];w[j]=w[j+1];w[j+1]=t;
			t=c[j];c[j]=c[j+1];c[j+1]=t;
		}
	}
	long ans=0;
	for(int i=0;i<n;i++){
		u[i]=min(c[i],m/w[i]);
		ans+=v[i]*u[i];
		m-=w[i]*u[i];
	}
	long back=min(2500,ans);
	for(int i=n-1;back>0;){
		if(u[i]){
			back-=v[i];
			ans-=v[i];
			m+=w[i];
			u[i]--;
		}else i--;
	}
	for(int i=1;i<2600;i++)dp[i]=1e10;
	for(int i=0;i<n;i++){
		c[i]=min(c[i]-u[i],2600);
		for(int k=1;c[i];k*=2){
			c[i]-=k=min(k,c[i]);
			long vv=v[i]*k,ww=w[i]*k;
			for(int j=2550-vv;j>=0;j--)dp[j+vv]=min(dp[j+vv],dp[j]+ww);
		}
	}
	for(int i=2550;i>=0;i--)if(dp[i]<=m){
		printf("%ld\n",ans+i);
		return 0;
	}
}


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

#define for_(i,a,b) for(int i=(a);i<(b);++i)
template< typename T > void minUpdate(T& a, T b) { a = min(a, b); }

int violate[10][6] = {
	{-1},
	{2,3,6,8,9,-1},
	{3,6,9,-1},
	{-1},
	{2,3,6,8,9,-1},
	{-1},
	{-1},
	{2,3,6,8,9,-1},
	{3,6,9,-1},
	{-1},	
};

int dp[2][2][10][10];

bool check(int L, int R) {
	for (int j=0; violate[R][j] != -1; ++j) if (violate[R][j] == L) return false;
	return true;
}

int main() {
	string S;
	
	while (cin >> S, S != "#") {
		int m = S.size();
		/*
		for_(b,0,2) for_(L,0,10) for_(R,0,10) dp[0][b][L][R] = 1L << 30;
		dp[0][0][0][S[0] - '0'] = 0;
		dp[0][1][S[0] - '0'][0] = 0;
		
		for_(i,1,m) {
			int nLR = S[i] - '0';
			for_(b,0,2) for_(L,0,10) for_(R,0,10) dp[1][b][L][R] = 1L << 30;
			for_(b,0,2) for_(L,0,10) for_(R,0,10) {
				if (dp[0][b][L][R] == 1L << 30) continue;
				if (check(nLR, R)) minUpdate(dp[1][1][nLR][R], dp[0][b][L][R] + (b ? 1 : 0));
				if (check(L, nLR)) minUpdate(dp[1][0][R][nLR], dp[0][b][L][R] + (b ? 0 : 1));
			}
			swap(dp[0], dp[1]);
		}
		
		int ans = 1L << 30;
		for_(b,0,2) for_(L,0,10) for_(R,0,10) minUpdate(ans, dp[0][b][L][R]);
		cout << ans << endl;
		*/
		int L[2] = {0, 0}, R[2] = {0, 0}, cnt[2] = {0, 0};
		bool flag[2] = {false, true};
		
		for_(i,0,m) {
			for_(b,0,2) {
				int r = (flag[b] ? S[i] - '0' : R[b]), l = (flag[b] ? L[b] : S[i] - '0');
				bool inv = false;
				for (int j=0; violate[r][j] != -1; ++j) inv |= (violate[r][j] == l);
				
				if (inv) {
					if (flag[b]) L[b] = r;
					else R[b] = l;
					++cnt[b];
				} else {
					R[b] = r;
					L[b] = l;
					flag[b] = !flag[b];
				}
			}
		}
		cout << min(cnt[0], cnt[1]) << endl;
	}
}

Measured memory_bytes: 3268
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <complex>

using namespace std;

complex<double> p[3];
complex<double> c[3];

void in(int a, int b, int cc){
	c[0] = p[a];
	c[1] = p[b];
	c[2] = p[cc];
}

void orig(){
	c[1] -= c[0];
	c[2] -= c[0];
	c[0] -= c[0];
}

void revb(){
	if(c[1].real() <= 0.0){
		c[1] = complex<double>(-c[1].real(), c[1].imag());
		c[2] = complex<double>(-c[2].real(), c[2].imag());
	}
}

void lotate(){
	double si = sin(arg(c[1]));
	double co = cos(arg(c[1]));
	c[1] = complex<double>(co*c[1].real()+si*c[1].imag(), -si*c[1].real()+co*c[1].imag());
	c[2] = complex<double>(co*c[2].real()+si*c[2].imag(), -si*c[2].real()+co*c[2].imag());
}

void revc(){
	if(c[2].imag() <= 0.0){
		c[1] = complex<double>(c[1].real(), -c[1].imag());
		c[2] = complex<double>(c[2].real(), -c[2].imag());
	}
}

complex<double> midv(complex<double> c1, complex<double> c2){
	return (abs(c2)/(abs(c1)+abs(c2)))*c1 + (abs(c1)/(abs(c1)+abs(c2)))*c2;
}

double bin(){
	complex<double> aw = midv(c[1],c[2]);
	complex<double> bw = midv(-c[1],c[2]-c[1]);


	double ma = min(aw.imag(),bw.imag());
	double mi = 0.0;

	for(int i=0;i<120;i++){
		double mid = (ma+mi)/2.0;

		double len = mid*2.0 + abs(mid/tan(arg(aw))) + abs(mid/tan(arg(bw)));
		//cout<<ma<<" "<<mi<<" "<<len<<" "<<abs(c[1])<<endl;

		if(len >= abs(c[1])){
			ma = mid;
		} else {
			mi = mid;
		}
	}

	return ma;
}

double calc(int a, int b, int cc){
	in(a,b,cc);
	orig();
	revb();
	lotate();
	revc();
	return bin();
}

int main(){
	for(int i=0;i<3;i++){
		double x,y; cin>>x>>y;
		p[i] = complex<double>(x,y);
	}

	double ans = 0.0;
	ans = max(ans, calc(0,1,2));
	ans = max(ans, calc(1,2,0));
	ans = max(ans, calc(2,0,1));

	printf("%.13f\n",ans);

	return 0;

}

Measured memory_bytes: 768
import java.util.*;

public class Main{
	public static void main(String arg[]){
			Scanner sc = new Scanner(System.in);
			int H = sc.nextInt();
			int n = sc.nextInt();
			int c=1;
			while(true){
				H = H-n;
				if(H <= 0)
					break;	
				c++;
			}
			System.out.println(c);
	}
}

Measured memory_bytes: 23252
#include<bits/stdc++.h>
using namespace std;
int main()
{

    int a,b,c,d,x,y;
    cin>>a>>b>>c>>d;

      if(a%d==0)
      {
          
          x=a/d;
          
          
      }
      else
      {
          
          x=(a/d)+1;
          
          
      }
    
    if(c%b==0)
    {
        
        y=c/b;
        
        
    }
    else
    {
        
        y=(c/b)+1;
        
        
    }
    
    if(x>=y)
    {
        
        
        cout<<"Yes"<<"\n";
        
    }
    else
    {
        
        
        cout<<"No"<<"\n";
        
        
    }
    
    
    
}



Measured memory_bytes: 3604
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<set>
#include<queue>
#include<map>
//#include<bits/stdc++.h>
#define int long long
#define for0(i, n) for(int i = 0; i < (n); i++)
#define for1(i, n) for(int i = 1; i <= (n);i++)
#define mp make_pair
#define all(x) x.begin(),x.end()
#define puts(x) cout << x << "\n"
#define endwith return
constexpr int mod = 1000000007;
using namespace std;
int input() { int t; cin >> t; return t; }
string m[1234567];
int h, w, k, x, y, xg, yg;
set<pair<int, int>>s1;
map<pair<int, int>, int>m2;
priority_queue<pair<int, pair<int, int>>, vector<pair<int, pair<int, int>>>, greater<pair<int, pair<int, int>>>> pq;
signed main() {
	cin >> h >> w >> k;
	cin >> x >> y >> xg >> yg; x--; y--; xg--; yg--;
	for0(i, h)for0(j, w)m2[mp(i, j)] = mod;
	for0(i, h)cin >> m[i];
	pq.push(mp(0, mp(x, y)));
	while (pq.size()) {
		pair<int, pair<int, int>>p1 = pq.top(); pq.pop();
		if (p1.second == mp(xg, yg)) {
			puts(p1.first); return 0;
		}
		if (s1.find(p1.second) != s1.end())continue;
		s1.insert(p1.second);
		int c = p1.first, x1 = p1.second.first, y1 = p1.second.second;
		m2[p1.second] = c;
		for1(i, k) {
			if (x1 - i < 0)break;
			if (m[x1 - i][y1] == '@')break;
			if (m2[mp(x1 - i, y1)] < c + 1)break;
			pq.push(mp(c + 1, mp(x1 - i, y1)));
			m2[mp(x1 - i, y1)] = c + 1;
		}
		for1(i, k) {
			if (x1 + i >= h)break;
			if (m[x1 + i][y1] == '@')break;
			if (m2[mp(x1 + i, y1)] < c + 1)break;
			pq.push(mp(c + 1, mp(x1 + i, y1)));
			m2[mp(x1 + i, y1)] = c + 1;
		}
		for1(i, k) {
			if (y1 - i < 0)break;
			if (m[x1][y1 - i] == '@')break;
			if (m2[mp(x1, y1 - i)] < c + 1)break;
			pq.push(mp(c + 1, mp(x1, y1 - i)));
			m2[mp(x1, y1 - i)] = c + 1;
		}
		for1(i, k) {
			if (y1 + i >= w)break;
			if (m[x1][y1 + i] == '@')break;
			if (m2[mp(x1, y1 + i)] < c + 1)break;
			pq.push(mp(c + 1, mp(x1, y1 + i)));
			m2[mp(x1, y1 + i)] = c + 1;
		}
	}
	puts(-1);
}

Measured memory_bytes: 142708
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>

#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define repi(i,a,b) for(int i = (a); i < (b); i++)

using namespace std;

typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;

const int INF=1<<29;
const double EPS=1e-9;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};
int n;//計算する行列の数
const int MAX_N =110;
int dp[MAX_N][MAX_N];//dp[i][j]:=Ai...Ajの計算に必要な最小のコスト
pii A[MAX_N];//行列firstを行secondを列とする。
void init(){
	for(int i =0; i < n;i++){
		for(int j = 0;j < n;j++){
			dp[i][j]=INF;
		}
	}
	for(int i =0;i < n;i++){
		dp[i][i]=0;
	}
}

int solve(){
	for(int k =1;k <n;k++){
		for(int i =0;i <n-k;i++){
			for(int j =i;j <i+k;j++){
				int sz =A[i].first*A[j].second*A[i+k].second;
				dp[i][i+k]=
				min(dp[i][i+k],dp[i][j]+dp[j+1][i+k]+sz);
			}
		}
	}
	return dp[0][n-1];
}

int main(){
	cin>>n;
	init();
	for(int i =0;i < n;i++){
		cin>>A[i].first>>A[i].second;
	}
	cout <<solve()<<endl;
	return 0;
}

Measured memory_bytes: 1208
while n = gets.to_i
  break if n == 0
  table = {}
  time = []
  n.times do
    sh, sm, ss, th, tm, ts = gets.split(/\s|:/).map(&:to_i)
    p = sh * 3600 + sm * 60 + ss
    q = th * 3600 + tm * 60 + ts
    table[p] ||= 0 ; table[p] += 1
    table[q] ||= 0 ; table[q] -= 1
    time << p; time << q
  end
  time = time.uniq.sort
  (1...time.size).each{ |i| table[time[i]] += table[time[i-1]] }
  p table.values.max
end

Measured memory_bytes: 13288
package main

import (
	"fmt"
	"strconv"
)

func main() {

	var S string
	fmt.Scanf("%s", &S)

	var flagYYMM, flagMMYY int
	var S1, S2 int
	S1, _ = strconv.Atoi(S[0:2])
	S2, _ = strconv.Atoi(S[2:4])
	if 0 < S2 && S2 < 13 {
		flagYYMM = 1
	}
	if 0 < S1 && S1 < 13 {
		flagMMYY = 1
	}

	if flagYYMM == 1 && flagMMYY == 1 {
		fmt.Println("AMBIGUOUS")
	} else if flagYYMM == 1 {
		fmt.Println("YYMM")
	} else if flagMMYY == 1 {
		fmt.Println("MMYY")
	} else {
		fmt.Println("NA")
	}
}


Measured memory_bytes: 1836