akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define Z -1
using namespace std;
struct NO{int p,l,r;};
struct NO T[100000];
int D[100000]={Z};
int rec(int u,int p){
  D[u]=p;
  if(T[u].r!=Z)rec(T[u].r,p);
  if(T[u].l!=Z)rec(T[u].l,p+1);
}
int main(){
  int a,b,c,n,l,r,j,k,i;
  for(cin>>n,i=0;i<n;i++)T[i].p=T[i].l=T[i].r=Z;
  for(i=0;i<n;i++)for(cin>>a>>b,j=0;j<b;j++){
    cin>>c;
    if(!j)T[a].l=c;
    else T[l].r=c;
    l=c;
    T[l].p=a;
  }
  for(i=0;i<n;i++)if(T[i].p==Z)r=i;
  rec(r,0);
for(i=0;i<n;i++){
  printf("node %d: parent = %d, depth = %d, ",i,T[i].p,D[i]);
  if(T[i].p==Z)cout<<"root, [";
  else if(T[i].l==Z)cout<<"leaf, [";
  else cout<<"internal node, [";
  for(j=0,c=T[i].l;c!=Z;c=T[c].r){
    if(j++)cout<<", ";
    cout<<c;
  }
  cout<<"]"<<endl;
}
}

Measured memory_bytes: 7808
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <complex>
#include <valarray>
#include <fstream>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>

#define _overload(a, b, c, d, ...) d
#define _rep1(X, A, Y) for (int (X) = (A);(X) <= (Y);++(X))
#define _rep2(X, Y) for (int (X) = 0;(X) < (Y);++(X))
#define rep(...) _overload(__VA_ARGS__, _rep1, _rep2)(__VA_ARGS__)
#define rrep(X,Y) for (int (X) = Y-1;(X) >= 0;--(X))
#define all(X) (X).begin(),(X).end()
#define _size(X) (int)((X).size())
#define mod(n, m) (((n)%(m)+(m))%m)
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
const int INFINT = 1 << 30;                          // 1.07x10^ 9
const ll INFLL = 1LL << 60;                          // 1.15x10^18
const double EPS = 1e-10;
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

const int MAX_N = 100000, MAX_M = 100000;
int N, M;
vector<Pll> drink;

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

  cin >> N >> M;
  rep(i, N) {
   ll A, B;
   cin >> A >> B;
   drink.push_back(Pll(A, B));
  }


  sort(all(drink));
  
  ll ans = 0;
  rep(i, drink.size()) {
    if (drink[i].sc > M) {
      ans += drink[i].fi * M;
      M = 0;
    } else {
      ans += drink[i].fi * drink[i].sc;
      M -= drink[i].sc;
    }

    if (M == 0) {
      break;
    }
  }


  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 2420
import numpy as np
 
N,W = map(int,input().split())
w,v = [0]*N ,[0]*N
arr = [map(int,input().split()) for _ in range(N)]
dp = np.zeros(W+1,dtype= np.int64)
 
for w,v in arr:
    np.maximum(dp[:-w] + v, dp[w:], out = dp[w:])
print(dp[-1])

Measured memory_bytes: 14588
n = int(input())
T, a = map(int, input().split())
Hs = list(map(int, input().split()))

ans = 10**6
result = 0
for i in range(n):
    t = T- Hs[i]*0.006
    if abs(a - t) < ans:
        ans = abs(a-t)
        result = i

print(result+1)


Measured memory_bytes: 3060
#include<stdio.h>

int check(int *S, int *C, int n){
  int i, checker=0;
  for(i=0; i<n; i++){
    if(S[i] != C[i]){
      checker += 1;
    }
  }
  if(checker == 0){
    return 1;
  }else{
    return 0;
  }
}
void operationOfF(int *S, int n, int *cout){
  int i, j;
  while(1){
    int C[12] = {0};
    for(i=0; i<n; i++){
      for(j=0; j<n; j++){
        if(S[i] == S[j]){
          C[i] += 1;
        }
      }
    }
    if(check(S, C, n)){
      break;
    }
    for(i=0; i<n; i++){
      S[i] = C[i];
    }
    *cout += 1;
  }
}
int main(){
  int n, S[12], i, cout;
  while(scanf("%d", &n), n){
    for(i=0; i<n; i++){
      scanf("%d", &S[i]);
    }
    cout = 0;
    operationOfF(S, n, &cout);
    printf("%d\n", cout);
    for(i=0; i<n-1; i++){
      printf("%d ", S[i]);
    }
    printf("%d\n", S[n-1]);
  }
  return 0;
}

Measured memory_bytes: 600
def I(): return int(input())
def MI(): return map(int, input().split())
def LMI(): return list(map(int, input().split()))
MOD = 10 ** 9 + 7


S = input()
cnt1 = 0
cur = S[0]
for c in S:
    if cur != c:
        cnt1 += 1
        cur = c

cnt2 = 0
cur = S[-1]
for c in reversed(S):
    if cur != c:
        cnt2 += 1
        cur = c

print(min(cnt1, cnt2))


Measured memory_bytes: 39792
#include <iostream>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#define endl "\n"
using namespace std;

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

    int count = 0;

    while(n > 0)
    {
    	n = n / k;
    	count ++;
    }
    cout << count << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
 
using lint=long long;
using pint=pair<int,int>;
template<class T> using ordered_set=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

int main()
{
   int N,K; cin>>N>>K;
   vector<double> a(N);
   for(int i=0;i<N;i++){
      int p; cin>>p;
      a[i]=(double)(p+1)/2;
   }

   vector<double> sum(N+1);
   for(int i=0;i<N;i++) sum[i+1]=sum[i]+a[i];

   double ans=0;
   for(int i=0;i+K<=N;i++) ans=max(ans,sum[i+K]-sum[i]);
   cout<<fixed<<setprecision(10)<<ans<<endl;
   return 0;
}


Measured memory_bytes: 3328
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <string>
#include <cstdlib>

using namespace std;

typedef long long ll;
const int INF = 1e8;

int main() {
    string s;
    ll K;
    cin >> s >> K;

    for(int i = 0; i < s.size() - 1; i++) {
        ll diff = (int)('z' - s[i] + 1);
        if(s[i] == 'a') continue;
        if(K < diff) {
            continue;
        }
        K -= diff;
        s[i] = 'a';
    }

    int n = s.size();
    K %= 26;
    for(int i = 0; i < K; i++) {
        s[n-1]++;
        if(s[n-1] == (char)('z'+1)) {
            s[n-1] = 'a';
        }
    }

    cout << s << endl;
}

Measured memory_bytes: 512
(declaim (optimize (speed 3) (safety 0) (debug 0)))

(defun exist (c s)
  (find c s :test #'equal))

(defun xor (a b)
  (eq (null a) (null b)))

(let ((x (string (read))))
  (format t "~A~%"
          (if (and (xor (exist #\N x) (exist #\S x))
                   (xor (exist #\E x) (exist #\W x)))
            "Yes"
            "No")))

Measured memory_bytes: 10344
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define pi 3.1415926536
#define pb push_back
#define N 1000000007
#define M 998244353
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define nrep(i,a,b) for(int i=a;i>=b;i--)

int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    ll t,i,j,k,q,x,y,l,r,z,n,flag =0,ans;
//    cin>>t;
//    while(t--){
      cin>>n;
      x = n%10;
	  if(x == 3) cout<<"bon";
	  else if(x == 0 || x == 1 || x == 6 || x == 8 ) cout<<"pon";
	  else cout<<"hon";
//	}
}

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

int main() {
    using namespace std;
    unsigned long N, M;
    cin >> N >> M;
    for(unsigned long i{1}; i < 1UL << N; ++i, puts(""))for(unsigned long j{1}; j < 1UL << M; ++j)putchar(48 | (1 & __builtin_ffsl(i | j)));
    return 0;
}

Measured memory_bytes: 1280
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <cmath>   
#include<cctype>
#include<string>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include <deque>
#include <utility> 

#define rep(i,m,n) for(int i = m;i < n;++i)
using namespace std;
using ll = long long;
using R = double;
const ll inf = 1LL << 50;
const int MOD = 1e9 + 7;

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



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

	int ini;
	int ans;
	cin >> ini;
	ans = abs(X-ini);


	rep(i, 0, n-1) {
		int x;
		cin >> x;
		ans = gcd(ans, abs(X-x));
	}

	cout << ans << endl;

	return 0;

}

Measured memory_bytes: 256
/*
	AOJ_0220:Binary Digit A Doctor Loved
*/
#include	<iostream>
#include	<string>

using namespace std;

string convert_toDigit(double);

int main(void) {
	double input;

	while (1) {
		cin >> input;

		if (input < 0.0) { break; }
		cout << convert_toDigit(input) << endl;
	}
	return 0;
}

string convert_toDigit(double targetNum) {
	string ans;
	double progressNum = 128.0;

	while (progressNum > 0.03125) {

		if (targetNum >= progressNum) {
			ans += '1';
			targetNum -= progressNum;
		} else {
			ans += '0';
		}
		progressNum /= 2;
		if (progressNum == 0.5) { ans += '.'; }
	}
	if (targetNum == 0.0) { return ans; }
	else { return "NA"; }
}

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

int main() {
  int a, b;
  cin >> a;
  cin >> b;
  if (a % 2 == 1 && b % 2 ==1) {
    cout << "Odd" << endl;
  }
  else {
    cout << "Even" << endl;
  }
}

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

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> a(n, 0);
    pair<int, int> p = make_pair(0, 0);
    // vector<int> a_sort(n);

    for (int i=0; i<n; i++) {
        cin >> a[i];
        if (p.second <= a[i]) {
            if (p.first <= a[i]) {
                p.second = p.first;
                p.first = a[i];
            }
            else
                p.second = a[i];
        }
    }
    
    // sort(a_sort.begin(), a_sort.end(), greater<int>());

    for (int i=0; i<n; i++) {
        if (a[i] != p.first)
            cout << p.first << endl;
        else
            cout << p.second << endl;
    }
}


Measured memory_bytes: 2432
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i, c) for(long long i=0; i<(long long)c; i++)
const ll INF=1000000000000001;
int main() {
	int n,t;
	ll ans=0;
	cin >>n;
	vector<int>a(n+1);
	int xyz;
	xyz=floor(sqrt(n));
	for(int i=1;i<xyz;i++){
		for(int j=1;j<xyz;j++){
			for(int k=1;k<xyz;k++){
				t=(i+j+k)*(i+j+k)-i*j-i*k-j*k;
				if (t<=n) a[t]++;
				else break;
			}
		}
	}
	for(int i=1;i<=n;i++){
		cout<<a[i]<<endl;
	}
	return 0;
}


Measured memory_bytes: 3648
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <string>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define SZ(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
typedef long long ll;

#define NMAX 20000

int gcd_r1[NMAX*NMAX];
bool mp[NMAX];

int main(){
	int n;
	cin >> n;
	if (n == 3){
		cout << "2 5 63" << endl;
		return 0;
	}
	int x;
	for(x=3; x<=30000 && n>3; n-=2,x+=12){
		cout << x << " " << x+6 << " ";
	}
	for(x=2; n>2; n-=3, x+=6){
		cout << x << " " << x +2 << " " << x+4 << " ";
	}
	if(n==1){
		cout << x+4 << endl; 
	}
	else if(n==2){
		cout << x << " " << x+2 << endl;
	}
	else if(n==0){
		cout << endl;
	}
}



Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <numeric>
using namespace std;
using var = long long;
#define rep(i,n) for(var i=0, i##_len=(n); i<i##_len; ++i)
#define repin(a,n) vector<var> a(n);rep(i,n){cin>>a[i];}
#define in(a) var a;cin>>a;
#define out(a) cout<<a;

int main()
{
	in(a);
	in(b);

	if ((b - a) % 2 == 0) {
		if (a < b) {
			out(a + abs(b - a) / 2);
		}
		else {
			out(b + abs(b - a) / 2);
		}
	}
	else {
		out("IMPOSSIBLE");
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<n;i++)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define ALL(a) a.begin(),a.end()

struct coord{
    float x;
    float y;
};

float length(coord a,coord b){
    return sqrt(pow((a.x-b.x),2)+pow((a.y-b.y),2));
}

int fact(int a){
    int x = 1;
    FOR(i,1,a+1) x *= i;
    return x;
}

int main()
{
    cout << setprecision(10);
    int N;
    cin >> N;
    vector<coord> A(N);
    REP(i,N) cin >> A[i].x >> A[i].y;
    float sum = 0;
    REP(j,N-1){
        FOR(k,j+1,N){
            sum += length(A[j],A[k]);
        }
    }
    cout << sum*2/N << endl;
    return 0;
}

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

public class Hello{
    public static void Main(){
        // ???????????????????¨??????§
        // Let's ?????£??¬????????????
        var n = int.Parse(System.Console.ReadLine());
        
        // var line = line.Select(elem => int.Parse(elem)).ToList();
        
        
        for (var i = 0; i < n; i++) {
            var line = System.Console.ReadLine().Split(' ');
            var line2 = line.Select(elem => int.Parse(elem)).ToList();
            var a = line2[0];
            var b = line2[1];
            var c = line2[2];
            var a2 = Math.Pow(a,2) == Math.Pow(b,2) + Math.Pow(c,2);
            var b2 = Math.Pow(b,2) == Math.Pow(c,2) + Math.Pow(a,2);
            var c2 = Math.Pow(c,2) == Math.Pow(a,2) + Math.Pow(b,2);
            
            if (a2 || b2 || c2) {
                System.Console.WriteLine("YES");
            }
            else {
                System.Console.WriteLine("NO");
            }
        }
       
        
    }
}

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

typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pair<int, int> > vii;
#define rrep(i, m, n) for(int (i)=(m); (i)<(n);  (i)++)
#define erep(i, m, n) for(int (i)=(m); (i)<=(n); (i)++)
#define  rep(i, n)    for(int (i)=0; (i)<(n);  (i)++)
#define rrev(i, m, n) for(int (i)=(n)-1; (i)>=(m); (i)--)
#define erev(i, m, n) for(int (i)=(n); (i)>=(m); (i)--)
#define  rev(i, n)    for(int (i)=(n)-1; (i)>=0; (i)--)
#define vrep(i, c)    for(__typeof((c).begin())i=(c).begin(); i!=(c).end(); i++)
#define  ALL(v)       (v).begin(), (v).end()
#define mp            make_pair
#define pb            push_back
template<class T, class S> inline bool minup(T& m, S x){ return m>(T)x ? (m=(T)x, true) : false; }
template<class T, class S> inline bool maxup(T& m, S x){ return m<(T)x ? (m=(T)x, true) : false; }

const int    INF = 1000000000;
const ll     MOD = 1000000007LL;
const double EPS = 1E-12;

char expr[] = {'+', '-', '*'};
vi a(4);

string to(int i)
{
  ostringstream os;
  os << a[i];
  return os.str();
}

inline int ret(int t, int i, int j)
{
  return t == 0 ? i + j : t == 1 ? i - j : i * j;
}

string solve()
{
  int tmp;
  do{
    rep(t, 5) rep(i, 3) rep(j, 3) rep(k, 3){
      if(t == 0){ // ((a+b)+c)+d
        tmp = ret(k, ret(j, ret(i, a[0], a[1]), a[2]), a[3]);
        if(tmp == 10) return "(("+to(0)+expr[i]+to(1)+")"+expr[j]+to(2)+")"+expr[k]+to(3);
      }
      else if(t == 1){ // ((a+b)+(c+d))
        tmp = ret(j, ret(i, a[0], a[1]), ret(k, a[2], a[3]));
        if(tmp == 10) return "(("+to(0)+expr[i]+to(1)+")"+expr[j]+"("+to(2)+expr[k]+to(3)+"))";
      }
      else if(t == 2){ // (a+(b+c))+d
        tmp = ret(k, ret(i, a[0], ret(j, a[1], a[2])), a[3]);
        if(tmp == 10) return  "("+to(0)+expr[i]+"("+to(1)+expr[j]+to(2)+"))"+expr[k]+to(3);
      }
      else if(t == 3){ // a+(b+(c+d))
        tmp = ret(i, a[0], ret(j, a[1], ret(k, a[2], a[3])));
        if(tmp == 10) return to(0)+expr[i]+"("+to(1)+expr[j]+"("+to(2)+expr[k]+to(3)+"))";
      }
      else{ // a+((b+c)+d)
        tmp = ret(i, a[0], ret(k, ret(j, a[1], a[2]), a[3]));
        if(tmp == 10) return to(0)+expr[i]+"(("+to(1)+expr[j]+to(2)+")"+expr[k]+to(3)+")";
      }
    }
  }while(next_permutation(ALL(a)));

  return "0";
}

int main()
{
  while((cin >> a[0] >> a[1] >> a[2] >> a[3]) && a[0]){
    sort(ALL(a));
    cout << solve() << endl;
  }

  return 0;
}

Measured memory_bytes: 1252
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
//#include<bits/stdc++.h>
#define int long long
#define mod 1000000007
#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()
using namespace std;
int n;
vector<int>t[234567];
int color[234567];
void f(int p) {
	for (int a : t[p])if (color[a] == mod) {
		color[a] = (color[p] + 1) % 2;
		f(a);
	}
}
signed main() {
	cin >> n;
	for1(i, n)color[i] = mod;
	for1(i, n - 1) {
		int a, b; cin >> a >> b;
		t[a].push_back(b);
		t[b].push_back(a);
	}
	color[1] = 0;
	f(1);
	int cnt0 = 0, cnt1 = 0;
	for1(i, n)if (color[i] == 0)cnt0++; else cnt1++;
	if (cnt0 < cnt1) {
		swap(cnt0, cnt1);
		for1(i, n) {
			color[i]++;
			color[i] %= 2;
		}
	}//cnt0>=cnt1
	if (cnt1 >= (n + 1) / 3) {
		int p1 = 1, p2 = 2, p3 = 3;
		for1(i, n) {
			if (color[i] == 0) {
				if (p1 > n) {
					cout << p3; p3 += 3;
				}
				else {
					cout << p1; p1 += 3;
				}
			}
			else {
				if (p2 > n) {
					cout << p3; p3 += 3;
				}
				else {
					cout << p2; p2 += 3;
				}
			}
			cout << (i < n ? ' ' : '\n');
		}
	}
	else {
		int p = 1, p3 = 3;
		for1(i, n) {
			if (color[i] == 1) {
				cout << p3;
				p3 += 3;
			}
			else {
				cout << p++;
				if (p % 3 == 0 && p / 3 <= cnt1)p++;
			}
			cout << (i < n ? ' ' : '\n');
		}
	}
}

Measured memory_bytes: 17408
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
using namespace std;
typedef long long  ll;
#define rep(i,s,n)for(ll i=s;i<n;i++)
#define repe(i,s,n)for(ll i=s;i<=n;i++)

static const double PI = 3.14159265358979;
static const ll MOD = 1e9 + 7;
static const ll INF = (ll)1 << 62;

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

	if (!(a & 1) || !(b & 1) || !(c & 1)) {
		cout << 0 << endl;
		return 0;
	}
	else {
		cout << min(min(a*b, b*c), c*a) << endl;
		return 0;
	}

	return 0;
}

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

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repr(i, n) for(int i = (n-1); i >= 0; --i)

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

typedef long long ll;
typedef pair<int, int> P;

const int MAX = 200005;
const int INF = 1001001001;
const int MOD = 1000000007;

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

    vector<int> C(N);
    vector<vector<int>> A(N, vector<int>(M));
    rep(i, N) {
        cin >> C[i];
        rep(j, M) cin >> A[i][j];
    }

    auto f = [&](int x) {
        vector<int> v(M);
        rep(i, N) {
            if (x >> i & 1) {
                rep(j, M) {
                    v[j] += A[i][j];
                }
            }
        }

        bool res = true;
        rep(i, M) {
            res &= X <= v[i];
        }
        return res;
    };

    int ans = INF;
    rep(bit, 1 << N) {
        if (f(bit)) {
            int res = 0;
            rep(j, N) {
                if (bit >> j & 1) res += C[j];
            }
            chmin(ans, res);
        }
    }

    cout << (ans != INF ? ans : -1) << endl;
}

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

class Program{
    static int n;
    static int[] v;
    static int[] c;
    static void Main(){
        n = int.Parse(Console.ReadLine());
        v = Console.ReadLine().Split().Select(int.Parse).ToArray();
        c = Console.ReadLine().Split().Select(int.Parse).ToArray();
        int ans = 0;
        for (int i = 0;i < n;i++)
            ans += (v[i] > c[i]) ? v[i] - c[i] : 0;
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 13268
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  long long n, m, l, b[100][100], a[100][100], c[100][100] = {};
  cin >> n >> m >> l;
  for(int i = 0; i < n; i++){
    for(int j = 0; j < m; j++){
      cin >> a[i][j];
    }
  }
  for(int i = 0; i < m; i++){
    for(int j = 0; j < l; j++){
      cin >> b[i][j];
    }
  }
  for(int i = 0; i < n; i++){
    for(int j = 0; j < m; j++){
      for(int k = 0; k < l; k++){
        c[i][k] += a[i][j] * b[j][k];
      }
    }
  }
  for(int i = 0; i < n; i++){
    for(int j = 0; j < l; j++){
      cout << (j == 0 ? "": " ") << c[i][j];
    }
    cout << endl;
  }
}


Measured memory_bytes: 3336
// Created by ...
#include <bits/stdc++.h>

#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'

#define vll vector< ll >
#define M 100000
#define MD 1000000007
#define pb push_back
#define rep(i,a,b) for(ll i = a; i <= b; ++i)
#define fo(i,a,b) for(int i = a; i<= b; ++i)
#define pii pair<ll,ll> 
#define vec(a) vector<a >
#define all(a) a.begin(),a.end()
#define se second
#define fi first
#define inf 0xffffffff
#define inchar getchar_unlocked
#define outchar(x) putchar_unlocked(x)
#define int long long
#define endl '\n'
#define IOS ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

using namespace std;
using ll = long long;
ll md=MD;

ll exp(ll a,ll b){ll r=1ll;while(b>0){if(b&1){r=r*(a%md);r=(r+md)%md;}b>>=1;a=(a%md)*(a%md);a=(a+md)%md;}return (r+md)%md;}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll Min(ll a,ll b){if(a<b)return a; return b;}
ll Max(ll a,ll b){if(a>b)return a; return b;}

bool check(int x,int y,int d){
	long double dist=(long double)x*x+(long double)y*y;
	dist=sqrt(dist);
	if(dist<=d)return true;
	return false;
}
int32_t main() {
    IOS;

        ll n,d,x,y,ans=0;
        cin>>n>>d;
        rep(i,0,n-1){
        	cin>>x>>y;
        	if(check(x,y,d))++ans;
        }
        cout<<ans;


        cout<<'\n';
    return 0;
}

Measured memory_bytes: 3688
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i <(n) ; ++i)
using namespace std;
using ll = long long;
void self_max(int &a,int b){
  a = max(a,b);
}

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

  if(a >=6 && a<=12){
    b /=2;
  }else if(a < 6){
    b =0;
  }

  cout << b << endl;

  return 0;
}


Measured memory_bytes: 384
/*{{{*/
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#ifdef LOCAL
int c_ = 0;
#define cout (c_?cerr:cout)
#define debug(...) \
{if(!c_++)cerr<<"\033[96;1m"; \
__VA_ARGS__; \
if(!--c_)cerr<<"\033[0m";}
#else
#define debug(...) {}
#endif
#define st first
#define nd second
#define all(...) (__VA_ARGS__).begin(), (__VA_ARGS__).end()
using namespace std;
using ll = long long;
using ld = long double;
template < typename t > using V = vector< t >;
template< typename t > int size(const t& c) {return c.size();}
void print() {cout << '\n';}
template< typename t, typename... v >
void print(const t& a, const v&... b)
{cout << a << (sizeof...(b)?" ":""); print(b...);}
#define flag() __LINE__"| "__PRETTY_FUNCTION__
#define dump(...) debug(print(#__VA_ARGS__,'=',__VA_ARGS__))
/*}}}*/

constexpr int nax = 100;

int n, tab[nax];

int32_t main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    cin >> n;
    for (int i = 0; i < n; ++i)
        cin >> tab[i];

    int res = 0;
    bool fl = false;
    for (int i = 1; i < n; ++i)
    {
        if (tab[i] == tab[i - 1])
        {
            if (fl) fl = false, ++res;
            else fl = true;
        }
        else
        {
            if (fl) ++res, fl = false;
        }
    }
    if (fl) ++res, fl = false;
    print(res);
}

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

using Graph = vector<vector<int>>;

vector<bool> seen;
int dfs(const Graph &g, int v, int& count, int from, int& ans, vector<int>& low, vector<int>& pre) {
  seen[v] = true;
  pre[v] = count++;
  low[v] = pre[v];

  for (auto next_v: g[v]) {
    if (seen[next_v] == false) {
      low[v] = min(low[v], dfs(g, next_v, count, v, ans, low, pre));
      if (low[next_v] == pre[next_v]) {
        ans++;
      }
    } else {
      if (from == next_v) {
        continue;
      }
      low[v] = min(low[v], low[next_v]);
    }
  }

  return low[v];
}

int main(void) {
  int n, m;
  cin >> n >> m;

  Graph g(n);
  rep(i, m) {
    int a, b;
    cin >> a >> b;
    --a;
    --b;
    g[a].push_back(b);
    g[b].push_back(a);
  }

  vector<int> low(n, -1);
  vector<int> pre(n, -1);
  int count = 0;
  int ans = 0;
  seen.assign(n, false);
  dfs(g, 0, count, -1,  ans, low, pre);

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

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

using namespace std;

typedef long long ll;
typedef long double ld;

#define mp make_pair
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define all(v) v.begin(),v.end()

const int maxn = 1e5 + 100, maxlg = 62;
const ll inf = 2e18, mod = 1e9 + 7;

int n, m, f[maxn], perm[maxn], tmp[maxn];
ll k, x[maxn];

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

	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> x[i];
	for (int i = 0; i < n - 1; i++)
		f[i] = i, perm[i] = i;

	cin >> m >> k;
	for (int i = 0; i < m; i++)
	{
		int pos;
		cin >> pos;
		pos--;
		swap(f[pos], f[pos - 1]);
	}

	while (k)
	{
		if (k & 1)
			for (int i = 0; i < n - 1; i++)
				perm[i] = f[perm[i]];
		for (int i = 0; i < n - 1; i++)
			tmp[i] = f[f[i]];
		swap(tmp, f);
		k /= 2;
	}
	
	ll ans = x[0];
	for (int i = 0; i < n; i++)
	{
		cout << ans << ".0" << endl;
		ans += x[perm[i] + 1] - x[perm[i]];
	}
}



Measured memory_bytes: 3456
#include<stdio.h>

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

  for(int i=0;i<12;i++){
    for(int j=i+1;j<12;j++){
      if(e[i]>e[j]){
        int a=e[i];
        e[i]=e[j];
        e[j]=a;
      }
    }
  }

  if(e[0]==e[3] && e[4]==e[7] && e[8]==e[11]) printf("yes\n");
  else printf("no\n");
  return 0;
}



Measured memory_bytes: 2136
#include<stdio.h>
int main(void){
    int x,i;
    scanf("%d",&x);
    for(i=1;i<=x;i++){
        if(i%3==0){
            printf(" %d",i);
        }
        else if(i%10==3){
            printf(" %d",i);
        }
        else if(i%100/10==3){
            printf(" %d",i);
        }
        else if(i%1000/100==3){
            printf(" %d",i);
        }
        else if(i%10000/1000==3){
            printf(" %d",i);
        }
    }
    printf("\n");
    return 0;
}

Measured memory_bytes: 2740
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 10000000000000009
//#define INF 9223372036854775807
typedef long long ll;
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define ZREP(i,n) for(int i=1;i<(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define rollcall cout<<"I'm Sucu."<<endl;
#define YES(s) s?cout << "YES" << endl:cout << "NO" << endl
#define Yes(s) s?cout << "Yes" << endl:cout << "No" << endl
#define Taka(s) s?cout << "Takahashi" << endl:cout << "Aoki" << endl
#define out(s,t,u) s?cout << t << endl:cout << u << endl
#define int ll
#define Endl endl


signed main(){
    int N,x;
    int a[2040];
    int b[2040][2040];
    cin >> N >> x;
    REP(i,N){
        cin >> a[i];
    }
    REP(i,N){
        b[i][0]=a[i];
        ZREP(k,N){
            b[i][k]=min(b[i][(k+N-1)%N],a[(i-k+N)%N]);
        }
    }
    
    int Ans=INF,sum;
    REP(k,N){
        sum=0;
        REP(i,N){
            sum+=b[i][k];
        }
        Ans=min(Ans,k*x+sum);
    }
    
    
    cout << Ans << endl;
    return 0;
}   


Measured memory_bytes: 32384
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
using namespace std;
typedef long long ll;

string S;

int main(){
    cin>>S;

    int ans=0;
    int sum=0;
    rep(i,S.size()){
        if(S[i]=='A' || S[i]=='C' ||
           S[i]=='G' || S[i]=='T'){
               sum++;
        }else{
            ans=max(ans,sum);
            sum=0;
        }
    }
    ans=max(ans,sum);

    cout<<ans<<endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Text;
using System.Numerics;
using System.IO;

namespace SolutionCS
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split(' ');
            int A = int.Parse(s[0]);
            int B = int.Parse(s[1]);
            int C = int.Parse(s[2]);

            Console.WriteLine(Math.Min(C, B /A));
        }
    }
}


Measured memory_bytes: 11092
import java.util.Scanner;
import java.util.HashMap;
import java.util.HashSet;
import java.util.ArrayList;
import java.util.List;
import java.util.Collections;

public class Main {

  public static class Building {

    int[][] floorRooms;

    public Building() {
      this.floorRooms = new int[3][10];
      for (int i = 0; i < 3; i++) {
        for (int j = 0; j < 10; j++) {
          this.floorRooms[i][j] = 0;
        }
      }
    }

    public void update(int f, int r, int v) {
      this.floorRooms[f][r] += v;
    }

    public void display() {
      for (int i = 0; i < 3; i++) {
        for (int j = 0; j < 10; j++) {
          System.out.print(" " + this.floorRooms[i][j]);
        }
        System.out.println();
      }
    }

  }

  public static void main(String[] args) {
    Scanner s = new Scanner(System.in);
    int n = s.nextInt();
    Building[] buildings = {
      new Building(),
      new Building(),
      new Building(),
      new Building()
    };
    for (int i = 0; i < n; i++) {
      int b = s.nextInt() - 1;
      int f = s.nextInt() - 1;
      int r = s.nextInt() - 1;
      int v = s.nextInt();
      buildings[b].update(f, r, v);
    }
    s.close();
    for (int i = 0; i < 4; i++) {
      buildings[i].display();
      if (i != 3)
        System.out.println("####################");
    }
  }
}



Measured memory_bytes: 29444
M,N = map(int,input().split())
if N == 0:
  print(M)
  exit()

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

i = 0
while(1):
  if not (M - i) in p:
    print(M-i)
    break
  if not (M + i) in p:
    print(M+i)
    break
  i += 1

Measured memory_bytes: 9176
#include<stdio.h>
#include<string.h>
int main(){
	char in[1000];
	scanf("%s",in);
	int moji=strlen(in);
	char out[moji];
	int i;
	for(i=0;i<moji;i++){
		if(in[i]<='C'){
			out[i]=in[i]-'A'+'X';
		}
		else{
			out[i]=in[i]-'D'+'A';
		}
	}
	for(i=0;i<moji;i++){
		printf("%c",out[i]);
	}
	printf("\n");
	return 0;
}

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

int main(){

	int r, c;
	cin >> r >> c;
	int A[r + 1][c + 1];

	for(int i = 0; i < r + 1; i++){
		for(int j = 0; j < c + 1; j++){
			A[i][j] = 0;
		}
	}

	for(int i = 0; i < r; i++){
		for(int j = 0; j < c; j++){
			cin >> A[i][j];
		}
	}

	for(int i = 0; i < r; i++){
		for(int j = 0; j < c; j++){
			A[i][c] += A[i][j];
		}
	}

	for(int i = 0; i < c; i++){
		for(int j = 0; j < r; j++){
			A[r][i] += A[j][i];
		}
	}

	for(int i = 0; i < r; i++){
		A[r][c] += A[i][c];
	}

	for(int i = 0; i < r + 1; i++){
		for(int j = 0; j < c + 1; j++){
			if(j) cout << " ";
			cout << A[i][j];
		}
		cout << endl;
	}

	return 0;
}

Measured memory_bytes: 1200
#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--)

using namespace std;
using ll = long long;

vector<int> kmp(string s) {
  int n = s.size();
  vector<int> p(n + 1);
  p[0] = -1;
  int j = -1;
  for (int i = 0; i < n; i++) {
    while (j != -1 && s[i] != s[j]) j = p[j];
    p[i + 1] = ++j;
  }
  return p;
}

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  string s, t;
  cin >> s >> t;
  const int n = s.size();
  const int m = t.size();
  vector<bool> match(n);
  int u = 0;
  auto pre = kmp(t);
  rep(i, n + m) {
    while (u != -1 && t[u] != s[i % n]) u = pre[u];
    u++;
    if (u == m) {
      match[(i+1-m) % n] = true;
    }
  }
  vector<vector<int>> g(n);
  vector<int> deg(n);
  rep(i, n) {
    if (match[i]) {
      int j = (i + m) % n;
      g[i].push_back(j);
      deg[j]++;
    }
  }
  queue<int> q;
  rep(i, n) if (deg[i] == 0) q.push(i);
  vector<int> dp(n);
  int num = 0;
  while (!q.empty()) {
    num++;
    int u = q.front(); q.pop();
    for (int v : g[u]) {
      dp[v] = max(dp[v], dp[u] + 1);
      if (--deg[v] == 0) {
        q.push(v);
      }
    }
  }
  if (num != n) {
    cout << -1 << endl;
  } else {
    cout << *max_element(dp.begin(), dp.end()) << endl;
  }
}

Measured memory_bytes: 34588
#include <map>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <algorithm>
#include <queue>
#define REP(i,n) for(int i=0; i<(int)(n); i++)

#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)

inline int getInt(){ int s; scanf("%d", &s); return s; }

using namespace std;

int main(){
  while(true){
    int n = getInt();
    int m = getInt();

    if(n + m == 0) break;

    vector<map<int, int> > v(n);

    REP(i,n){
      const int k = getInt();
      REP(j,k){
        const int x = getInt();
        const int d = getInt();
        v[i][x] = d;
      }
    }

    vector<vector<map<int, int> > >
      dp(n, vector<map<int, int> >(m + 1));

    FOR(it, v[0]){
      dp[0][m][it->first] = 0;
    }

    if(m > 0){
      FOR(it, v[1]){
        dp[1][m - 1][it->first] = 0;
      }
    }

    REP(i, n - 1) REP(j, m + 1) FOR(it1, dp[i][j]){
      // printf("(%d, %d) %d => %d\n", it1->first, i, j, it1->second);

      FOR(it2, v[i + 1]){
        const int x1   = it1->first;
        const int x2   = it2->first;
        const int cost = (v[i][it1->first] + it2->second) * std::abs(x1 - x2);
        const int next = it1->second + cost;

        // printf(" (%d, %d) %d: %d\n", x2, i + 1, j, next);

        if(dp[i + 1][j].count(x2))
          dp[i + 1][j][x2] = min(dp[i + 1][j][x2], next);
        else
          dp[i + 1][j][x2] = next;
      }
      if(j != 0 && i != n - 2){
        FOR(it2, v[i + 2]){
          const int x1   = it1->first;
          const int x2   = it2->first;
          const int cost = (v[i][it1->first] + it2->second) * std::abs(x1 - x2);
          const int next = it1->second + cost;

          // printf(" (%d, %d) %d: %d\n", x2, i + 2, j - 1, next);

          if(dp[i + 2][j - 1].count(x2))
            dp[i + 2][j - 1][x2] = min(dp[i + 2][j - 1][x2], next);
          else
            dp[i + 2][j - 1][x2] = next;
        }
      }
    }

    int ans = INT_MAX;

    REP(j,m + 1)FOR(it,dp[n - 1][j]){
      ans = min(ans, it->second);
    }
    REP(j,m)FOR(it,dp[n - 2][j + 1]){
      ans = min(ans, it->second);
    }

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

Measured memory_bytes: 2688
//includes
#include<iostream>
#include<vector>
#include<set>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<string>
#include<stack>
#include<map>
#include<queue>
#include<iomanip>
#include<numeric>
#include<assert.h>
#include<cstring>
#include<unordered_map>
#include<bitset>

//macros and consts
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define all(a) (a).begin(),(a).end()
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define FORE(i,a) for(auto &i : a)
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define accm accumulate
#define Fi first
#define Se second
#define INF 1e9
#define mINF -1e9
#define endl "\n"
#define CONT continue
#define BRK break

//shorter types
using namespace std;
using ll = long long;
using vi = std::vector<int>;
using vc = std::vector<char>;
using vll = std::vector<long long>;
//here begins your code
int N;
vll a;
signed main(){
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  cin >> N;
  a.resize(3*N);
  REP(i,3*N){
    cin >> a[i];
  }


    vector<long long> S(N*2+1, 0);
    priority_queue<long long, vector<long long>, greater<long long> > que1;
    for (int i = 0; i < N; ++i) {
        S[i+1] = S[i] + a[i];
        que1.push(a[i]);
    }
    for (int i = N; i < N*2; ++i) {
        long long mi = que1.top();
        if (a[i] > mi) {
            S[i+1] = S[i] - mi + a[i];
            que1.pop();
            que1.push(a[i]);
        }
        else S[i+1] = S[i];
    }

  vector<ll> T(N * 2 + 1 ,0);
  priority_queue<ll> que2;
  for(int i = 0 ; i < N ; i++){
    T[i+1] = T[i] + a[N*3-1-i];
    que2.push(a[N*3-1-i]);
  }

    for (int i = N; i < N*2; ++i) {
        long long ma = que2.top();
        if (a[N*3-1 - i] < ma) {
            T[i+1] = T[i] - ma + a[N*3-1 - i];
            que2.pop();
            que2.push(a[N*3-1 - i]);
        }
        else T[i+1] = T[i];
    }



  ll ret = -(1LL<<60);
  for(int i = N ; i <= N * 2 ; i++){
    ret = max(ret,S[i] - T[N*3 - i]);
  }
  cout << ret << endl;
  
  return 0;
}



Measured memory_bytes: 8052
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int n,k,a[4002][4002],sum[4002][4002];
int f(int x,int y){return sum[x][y]+sum[x+k][y+k]-sum[x][y+k]-sum[x+k][y];}
int main()
{
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++) 
	{
		int x,y;
		char c;
		cin>>x>>y>>c;
		if(c=='W') y+=k;
		x%=(2*k);
		y%=(2*k);
		a[x][y]++;
	}
	for(int i=0;i<4*k;i++)
	    for(int j=0;j<4*k;j++) sum[i+1][j+1]=sum[i+1][j]+a[i%(2*k)][j%(2*k)];
    for(int i=0;i<4*k;i++)
  		for(int j=0;j<4*k;j++) sum[j+1][i+1]+=sum[j][i+1];
	int ans=0;
	for(int i=1;i<=2*k;i++)
	    for(int j=1;j<=2*k;j++)
	    {
	    	int num=f(i,j)+f(i+k,j+k);
	    	ans=max(num,ans);
		}
	printf("%d\n",ans);
	return 0;
}

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

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    
    int sum = a + b + c;
    int mx = max(a, max(b, c));
    if(3 * mx % 2 == sum % 2) cout << (3 * mx - sum) / 2 << endl;
    else cout << (3 * (mx + 1) - sum) / 2 << endl;
}


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

int main(){

  ll n;

  scanf("%lld", &n);

  ll ans;

  ans = n*(n - 1)/2;

  printf("%lld\n", ans);

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
    int a, b, c, tmp;

    scanf("%d %d %d", &a, &b, &c);
    if (a>b) tmp=a, a=b, b=tmp;
    if (b>c) {
        tmp=b, b=c, c=tmp;
        if (a>b) tmp=a, a=b, b=tmp;
    }
    printf("%d %d %d\n", a, b, c);
    return 0;
}



Measured memory_bytes: 2048
#include<iostream>
#include<string>
#include<vector>
#include<numeric>
#include<math.h>
#include<algorithm>
#include<iomanip>
#include<bitset>
using namespace std;

int main() {

	int A, i;
	cin >> A >> i;

	cout << A - i + 1 << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long int lint;

#define PI acos(-1)
#define INF64 1LL << 60
#define INF32 1 << 29
#define all(a) (a).begin(), (a).end()
#define INV ((long long int)1000000007)

using namespace std;

void execute()
{
	lint N;
	cin >> N;
	lint ans = N / 11;
	ans *= 2;
	ans += (0 < N % 11) ? 1 : 0;
	ans += (6 < N % 11) ? 1 : 0;
	cout << ans << endl;
	return;
}

int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	execute();

	int stop;
	cin >> stop;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int solve() {
	int N, M;
	cin >> N >> M;
	vector<int> divisor;
	for (int i = 1; i * i <= M; i++) {
		if (M % i != 0) continue;
		divisor.push_back(i);
		if (i * i != M) divisor.push_back(M / i);
	}
	sort(divisor.rbegin(), divisor.rend());
	for (int i : divisor) {
		if (M / i >= N) return i;
	}
	return 1;
}
int main() {
	cout << solve() << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stack>
#include <sstream>
#include <queue>

using namespace std;

#define MAX_N (1<<18)
#define li long int
// segtree struct
// 大体 http://arc080.contest.atcoder.jp/submissions/1530583 のパクリ

// to change データ数を2^nになるように水増しする関係で、datに絶対影響しない値(UNDEF)が必要
// 問題によってSEG_UNDEFの中身は書き換えなければならない
const li SEG_UNDEF = 1145141919;


struct segtree{
  li n;
  li dat[2*MAX_N-1]; // ここの型は場合によって変わるはず

  void init(li n_){
    n = 1;
    while(n < n_) n *= 2;
    for(li i = 0; i < 2*n-1; i++) dat[i] = SEG_UNDEF;
  }

  // k番目の値をaに書き換える(to change)
  void update(li k, li a){
    k += n-1;
    dat[k] = a;
    while(k > 0){
      k = (k-1)/2;
      dat[k] = min(dat[k*2+1], dat[k*2+2]);
    }
  }

  // [a:b)の区間におけるデータの呼び出し。
  // a < bじゃないとコアダンプする
  li query(li a, li b){
    return querybody(a,b,0,0,n);
  }
  
  li querybody(li a, li b, li k, li l, li r){
    if(r <= a || b <= l) return SEG_UNDEF;
    if(a <= l && r <= b) return dat[k];
    else{
      li vl = querybody(a,b,k*2+1,l,(l+r)/2);
      li vr = querybody(a,b,k*2+2,(l+r)/2,r);
      // change
      return min(vl, vr);
    }
  }

  void show(){
    cout<<n*2-1<<"datas"<<endl;
    for(li i=0;i<n*2-1;++i){
      cout<<i<<","<<dat[i]<<endl;
    }
  }
};

// variables

segtree sg;
li N;
vector<li> ids;


li dfs(li beg, li end){
  //cout << beg<<","<<end<<endl;
  li result = 0;
  li value = sg.query(beg,end+1);
  li id = ids[value-1];
  //  cout<<"min is "<<value<<" id is "<<id<<endl; //debug
  li l = id - beg + 1;
  li r = end - id + 1;
  result += value * l * r;
  if(id-1 >= beg) {result += dfs(beg, id-1);}
  if(id+1 <=end ){result += dfs(id+1,end);}
  return result;
}


int main(){
  cin >> N;
  ids.resize(N);
  sg.init(N);
  for(li i=0;i<N;++i){
    li k;
    cin >> k;
    sg.update(i,k);
    ids[k-1]=i;
  }
  //sg.show(); //debug
  cout<<dfs(0,N-1);
  return 0;
}

Measured memory_bytes: 109056
/* 
	Author: ankrypt
*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define MOD 1000000007
#define ll long long int
#define u64 unsigned long long int
#define ff first
#define ss second
#define all(x) x.begin(), x.end() 
#define ub upper_bound
#define lb lower_bound
#define MAX_INT 15
#define fi(a, b, c, d) for(int a = b; a < c; a += d)
#define fl(a, b, c, d) for(ll a = b; a < c; a += d)
#define fei(a, b, c, d) for(int a = b; a <= c; a += d)
#define fel(a, b, c, d) for(ll a = b; a <= c; a += d)
#define quit exit(0)
#define pi 3.141592653589793238

ll N, M, A, B, C;
ll arr[MAX_INT], arr1[MAX_INT], data[MAX_INT];
vector<ll> V;


int main() {
	scanf("%lld", &N);
	double ans = 2 * pi * N;
	printf("%0.12lf\n", ans);	
	return 0;
}
/*
	Powered by Buggy Plugin
*/




Measured memory_bytes: 3816
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <functional>
#include <string>
#include <algorithm>
#include <string>
#include <climits>
#include <utility>

#define REP(i, n) for (int (i) = 0; (i) < (int)(n); (i)++)
#define REG(i, a, b) for (int (i) = ((int)(a)); (i) < ((int)(b)); i++)
#define ALL(V) (V).begin(), (V).end()
#define PRINT(STR) cout << (STR) << endl
#define ROUNDED(N) fixed << setprecision(N)
#define SPACE " "

typedef long long ll;
using namespace std;

int nextInt() { int n; cin >> n; return n; }
double nextDouble() { double d; cin >> d; return d; }
string nextString() { string str; cin >> str; return str; }

int main() {
	cin.tie(0); //?????±?????????????????????
	ios::sync_with_stdio(false); //printf??¨??±??????????????????

	int h,w;
	while(cin>>h>>w,h){
		int max_w = sqrt(w*w + h*h);
		int ans = 10000000;
		int ans_h,ans_w;
		int def = h*h+w*w;
		for(int i = sqrt((w*w + h*h)/2);i<max_w+2;i++){
			for(int j = 1;j<i;j++){
				if((def<i*i+j*j||def==i*i+j*j&&j>h)&&ans>=i*i+j*j){
					ans = i*i+j*j;
					ans_h = j;
					ans_w = i;
				}
			}
		}
		cout << ans_h << " " << ans_w  << endl;
	}
	return 0;
}

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

int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    int n; cin >> n;
    int a[200020]; for(int i=0; i < n; ++i) cin >> a[i];

    // a[l] ^ ... ^ a[r] == a[l] + ... + a[r]
    // <=> no same bit in a[l] ~ a[r] is set twice 

    int l = 0, r = 0;
    long x = 0, ans = 0;
    while(true) {
        if(l == n) break;
        // move r
        while(r < n && (x & a[r]) == 0) x ^= a[r++];
        // update ans
        ans += r - l;

        if(l == r) ++r;
        
        x ^= a[l++];
    }

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

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

const int N = 1e5 + 5;

int32_t main()
{
	IOS;
	int x;
	cin >> x;
	int cur = 100;
	int ans = 0;
	while(cur < x)
	{
		cur += cur / 100;
		ans++;
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 3608
from math import ceil, floor
A, B = map(int, input().split())
A_min = ceil(A*(100/8))
A_max = floor((A+1)*(100/8)) if A%2!=1 else (A+1)*(100/8)-1
B_min = ceil(B*10)
B_max = floor(((B+1)*10))-1
if A_min>B_max or A_max<B_min:
  print(-1)
elif A_min>=B_min:
  print(A_min)
elif B_min>=A_min:
  print(B_min)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
int main(){
int N,M;
  cin>>N;
  cin>>M;
  int a[N];
  int sum=0;
  for(int i=0;i<N;i++){
  	cin>>a[i];
    sum+=a[i];
  }
  int count=0;
  for(int i=0;i<N;i++){
  	if(sum/(4.0*M)<=a[i]){
    count++;
    }
    
    }
    if(count>=M){
    cout<< "Yes" <<endl;
    }else{cout<< "No" <<endl;
  }
}
 

Measured memory_bytes: 256
s = input()
q = int(input())

sl = ['']*(q*2+2)
sl[q] = s
m = q-1
u = q+1
rev = False
for _ in range(q):
    query = input().split()

    if query[0] == '1' and not(rev):
        rev = True
    elif query[0] == '1' and rev:
        rev = False

    elif query[0] == '2' and query[1] == '1' and not(rev):
        sl[m] = query[2]
        m -= 1

    elif query[0] == '2' and query[1] == '1' and rev:
        sl[u] = query[2]
        u += 1

    elif query[0] == '2' and query[1] == '2' and not(rev):
        sl[u] = query[2]
        u += 1

    elif query[0] == '2' and query[1] == '2' and rev:
        sl[m] = query[2]
        m -= 1

if rev:
    sl[q] = s[::-1]
    sl.reverse()
    print(''.join(sl))
else:
    print(''.join(sl))


Measured memory_bytes: 7284
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using vll = vector<ll> ;
using vs = vector<string> ;
#define all(v) v.begin(),v.end()

int main(){
  string S;cin>>S;
  string T[4]{"maerd","remaerd","esare","resare"};
  reverse(all(S));
  int i=0;
  bool flag=true;
  //cout<<S<<endl;
  while(i<S.size()){
    int tmp = 4;    
    rep(j,4){
      bool tmp_flag=false;
      if(i+T[j].size()>S.size()) continue;
      else{
        string tmp_s = S.substr(i,T[j].size());
        //cout<<i<<" "<<T[j]<<" "<<tmp_s<<endl;
        if(tmp_s==T[j]) tmp_flag=true;
      }
      if(tmp_flag){
        i += T[j].size();
        tmp = j;
        break;
      }
    }
    if(tmp==4){
      flag=false;
      break;
    }
    //cout<<"i "<<i<<endl;
  }
  if(flag) cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
}

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

int main() {
  int N, M, a, b, sum = 0;
  cin >> N >> M;

  vector<int>road(2 * M);
  for(int i = 0; i < 2 * M; i++){
    cin >> road.at(i);
  }

  for(int k = 1; k < N + 1; k++){
    for(int i = 0; i < 2 * M; i++){
      if(k == road.at(i)){
        sum += 1;
      }
    }
    cout << sum << endl;
    sum = 0;
  }

}




Measured memory_bytes: 256
N = int(input())
H = list(map(lambda h: int(h), input().split(" ")))

maxH = []
for i in range(len(H)):
  if i == 0:
    maxH.append(H[i])
  else:
    maxH.append(max([H[i],maxH[i-1]]))

impossible = False
for i in range(len(H)):
  if maxH[i] - H[i] >= 2:
    impossible = True

print("No") if impossible else print("Yes")

Measured memory_bytes: 20680
#include<bits/stdc++.h>
using namespace std;
int h[11];
int main()
{
	int n;
	cin>>n;
	int a[n],cnt=0,cnt1=0;
	for(int i=0;i<n;i++)
	cin>>a[i];
	
	for(int i=0;i<n;i++)
	{
		if(a[i]%2==0)
		{
			cnt1++;
			if(a[i]%3==0 || a[i]%5==0)
			cnt++;
		}
		
	}
	if(cnt==cnt1)
	cout<<"APPROVED\n";
	else cout<<"DENIED\n";
}

Measured memory_bytes: 256