akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
ll n;
int main(){
    cin>>n;
    vector<int> v(n,0);
    rep(i,n) cin>>v[i];
    int ans=inf;
    rep(i,101){
        int now=0;
        rep(j,n){
            now+=(v[j]-i)*(v[j]-i);
        }
        if(ans>now) ans=now;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
void fizzbuzz(int);

int main(){
 
    int n;
    cin>>n;
    fizzbuzz(n);
    return 0;
}
void fizzbuzz(int n){
    unsigned long int sum =0;
    for(int i=1;i<=n;i++){
        if(i%3==0 || i%5 == 0)
        continue;
        else{
            sum += i;
        }
    }
    cout<<sum<<endl;
}//MinDistToFarthestNode

Measured memory_bytes: 3584
#include <bits/stdc++.h>
#define p pair<int, int>
using namespace std;

struct edge{
  int from, to, cost;
};

bool cmp(const edge &a, const edge &b){
  return a.cost < b.cost;
}

int par[200005];
int _rank[200005];
void init(int n){
  for(int i = 0; i < n; i++){
    par[i] = i;
    _rank[i] = 0;
  }
}

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

void unite(int x, int y){
  x = find(x); y = find(y);
  if(_rank[x] > _rank[y]) swap(x, y);
  par[y] = x;
  if(_rank[x] == _rank[y]) _rank[x]++;
}

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

int main(){
  vector<p> px, py;
  int n, x, y;
  cin >> n;
  for(int i = 0; i < n; i++){
    cin >> x >> y;
    px.push_back(p(x, i));
    py.push_back(p(y, i));
  }
  sort(px.begin(), px.end());
  sort(py.begin(), py.end());
  vector<edge> g;
  for(int i = 1; i < px.size(); i++){
    int dist = abs(px[i].first - px[i-1].first);
    g.push_back(edge{px[i-1].second, px[i].second, dist});
  }
  for(int i = 1; i < py.size(); i++){
    int dist = abs(py[i].first - py[i-1].first);
    g.push_back(edge{py[i-1].second, py[i].second, dist});
  }
  sort(g.begin(), g.end(), cmp);
  init(2 * n);
  int sum = 0;
  for(int i = 0; i < g.size(); i++){
    edge e = g[i];
    if(!same(e.from, e.to)){
      unite(e.from, e.to);
      sum += e.cost;
    }
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 7144
using System.Collections.Generic;
using System;


public class hello
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        var s1 = new List<int>();
        var s2 = new List<int>();
        string[] line = Console.ReadLine().Trim().Split(' ');
        for (int i = 0; i < n; i++) s1.Add(int.Parse(line[i]));
        s1.Sort();
        var s10 = s1[0];
        int s10end;
        if (s10 % 2 == 0) s10end = s10 / 2;
        else s10end = (s10 - 1) / 2;
        for (int i = 1; i <= s10end; i++)
            if (s10 % i == 0) s2.Add(i);
        s2.Add(s10);
        if (s1.Count == 2)
        {
            foreach (var x in s2)
                if (s1[1] % x == 0) Console.WriteLine(x);
        }
        else
            foreach (var x in s2)
                if (s1[1] % x == 0 && s1[2] % x == 0) Console.WriteLine(x);
    }
}

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

int main(){
  int N, A, B, R;
  cin >> N >> A >> B;
  R = N * A;
  
  if(R < B){
    cout << R << endl;
  }
  
  else if(R == B){
    cout << R << endl;
  }
  
  else if(R > B){
    cout << B << endl;
  }
}

Measured memory_bytes: 256
/**
 *	   author: nayakashutosh9 
**/
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define endl "\n"
#define mod 1000000007
#define inf 1e18
 
/*******************************************************************/
 


int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
 //    int t,tc=1;cin>>t;
	// cin.ignore();
	// while(t--){

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

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

#define rep(i,n) for(ll i=0;i<n;i++)
#define repm(i,m,n) for(ll i=m;i<n;i++)
#define max(a,b) (((a)>(b))?(a):(b))
#define min(a,b) (((a)<(b))?(a):(b))
#define YesNo(a) (a)?cout<<"Yes"<<endl:cout<<"No"<<endl
#define YESNO(a) (a)?cout<<"YES"<<endl:cout<<"NO"<<endl
#define INF (2e9)
#define PI (acos(-1))
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007

typedef long long ll;

int main(){
    int n; cin >> n;
    vector<int> L(n); rep(i,n) cin >> L[i];

    sort(all(L));

    int ans = 0;
    rep(i,n){
        repm(j,i+1,n){
            repm(k,j+1,n){
                if(L[i]+L[j] > L[k] && L[i] != L[j] && L[j] != L[k] && L[i] != L[k]) ans++;
            }
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define f first
#define s second
#define fore(i,a,b) for(int i = (a), ThxMK = (b); i < ThxMK; ++i)
#define pb push_back
#define all(s) begin(s), end(s)
#define _ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define sz(s) int(s.size())
#define ENDL '\n'
using namespace std;
typedef long double ld;
typedef long long lli;
typedef pair<lli,lli> ii;
typedef vector<int> vi;
typedef vector<lli> vl;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
#define deb(x) cout << #x": " << (x) << endl;

const int N = 1e4+5;
const lli INF = 1e18;
const lli MOD = 1e9+7;


vi primes(1,2);
vector<vector<ld>>nk;
void sieve(){
	vi m(N+1,0);
	for(int i = 4; i<N; i+=2)m[i]=1;
	for(int i = 3; i*i<=N; i+=2)if(!m[i])for(int j = i*i; j<N; j+=i)m[j]=1;
	for(int i = 3; i<N; i+=2)if(!m[i])primes.pb(i);
}

void pascal(){
	nk =vector<vector<ld>>(N,vector<ld>(N,0.0));
	fore(i,0,N)nk[i][0]=nk[i][i]=1.0;
	fore(i,1,N)fore(j,1,i)nk[i][j]=nk[i-1][j-1]+nk[i-1][j];
}

lli gcd(lli a, lli b){return (b?gcd(b,a%b):a);}

lli lcm(lli a, lli b){
	if(a<b)swap(a,b);
	lli c = gcd(a,b);
	a/=c;
	return a*b;
}

int popcount(lli x) { return __builtin_popcountll(x); }

lli poww(lli a, lli b){
	lli res =1;
	while(b){
		if(b&1) res = res * a;
		a = a*a;
		b/=2;
	}
	return res;
}

lli powm(lli a, lli b){
	lli res =1;
	while(b){
		if(b&1) res = (res * a)%MOD;
		a = (a*a)%MOD;
		b/=2;
	}
	return res;
}

bool isPrime(lli x){
	if(x==1)return 0;
	for(auto i:primes){
		if(i*i>x)return 1;
		if(x%i==0)return 0;
	}
	return 1;
}

lli SUM(lli a, lli b, lli mod=MOD){
	return (a+b+mod)%mod;
}
lli PROD(lli a, lli b, lli mod=MOD){
	a%=mod; b%=mod;
	return a*b % mod;
}
int dx[4]={-1,0,0,1}, dy[4]={0,1,-1,0};

// ---- コーディングはここから！ ('-')7

void solve(){
	int n; cin>>n;
	string s; cin>>s;
	vvl dp(n,vl(n,0)), sum(n,vl(n+1,0));
	dp[0][0]=1;
	fore(i,1,n+1)sum[0][i]=1;
	fore(i,1,n){
		if(s[i-1]=='>')fore(j,0,i+1)dp[i][j]=SUM(sum[i-1][n],-sum[i-1][j]), sum[i][j+1]=dp[i][j];
		else fore(j,0,i+1)dp[i][j]=sum[i-1][j], sum[i][j+1]=dp[i][j];
		fore(j,2,n+1)sum[i][j]=SUM(sum[i][j],sum[i][j-1]);
	}
	cout<<sum[n-1][n]<<ENDL;
}

int main(){_
	//int t; cin>>t; fore(tt,0,t)

	solve();
}


Measured memory_bytes: 144176
n = int(input())
ac = 0
wa = 0
tle = 0
re = 0

for i in range(n):
    mozi = input()
    #print(mozi)
    
    
    if mozi == "AC":
        ac = ac + 1
        
    elif mozi == "WA":
        wa = wa + 1
    
    elif mozi == "TLE":
        tle = tle + 1
        
    else:
        re = re + 1
        
print("AC x " , ac)
print("WA x " , wa)
print("TLE x " , tle)
print("RE x " ,re)

Measured memory_bytes: 9148
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int mae = scanner.nextInt();
        while (mae != -1) {
            int yon = 1;
            int kari = mae;
            long dasu = 0;
            int kake = 1;

            long keta = 1;
            while (kari > 0) {
                int amari = kari % 4;
                int shou = kari / 4;
                dasu += amari * keta;
                keta *= 10;
                kari = shou;
            }

            System.out.println(dasu);

            mae = scanner.nextInt();
        }
    }
}



Measured memory_bytes: 30684
#include <iostream>
#include <vector>
#include <algorithm>
typedef long long ll;
using namespace std;
const int maxN = 111;
ll cnt[maxN];
bool used[maxN];
vector <int> v;

ll calc(int l, int r) {
    for (int i = 1; i <= 100; i++) {
        cnt[i] = 0;
        used[i] = 0;
    }
    ll sum = 0;
    for (int i = l; i <= r; i++) {
        ll cur = 0;
        for (int j = 1; j < v[i]; j++) {
            cur += cnt[j];
        }
        cur++;
        cnt[v[i]] += cur;
        sum += cur;
        if (sum > 1e14) {
            return 1e14;
        }
    }
    return sum;
}
int main(void) {
    ll n;
    cin >> n;
    v.push_back(1);
    vector <int> r;
    for (int j = 2; j <= 100; j++) {
           r.push_back(j);
    }
    if (n != 1) {
        for (int j = 0; j <= r.size(); j++) {
            int i = r[j];
            v.push_back(i);
            ll mx = 0;
            int pp = 0;
            vector <int> v1 = v;
            for (int p = 0; p < v.size(); p++) {
                for (int j = (int)v.size() - 2; j >= p; j--) {
                    v[j + 1] = v[j];
                }
                v[p] = i;
                ll cur = calc(0, (int)v.size() - 1);
                if (cur <= n && cur > mx) {
                    mx = max(cur, mx);
                    pp = p;
                }
                v = v1;
            }
            for (int j = (int)v.size() - 2; j >= pp; j--) {
                v[j + 1] = v[j];
            }
            v[pp] = i;
            if (mx == 99) {
                int o = 0;
            }
            fflush(stderr);
            if (mx == n) {
                break;
            }
        }
    }
    if (calc(0, v.size() - 1) != n) {
        return -1;
    }
    cout << (int)v.size() + 100 << endl;
    for (int i = 1; i <= 100LL; i++) {
        cout << i << " ";
    }
    for (auto el : v) {
        cout << el << " ";
    }
    cout << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define chmin(x,y) x = min(x,y)
using namespace std;
typedef long long ll;
const int INF = 1001001001;

int main() {
    int s;
    cin >> s;
    map<int, int> mm;
    int prev = s;
    mm[s] = 1;
    for(ll i=2; i<=1000000; i++){
        int tmp;
        if(prev%2){
            tmp = prev*3 + 1;
        }else{
            tmp = prev/2;
        }

        if(mm[tmp] > 0){
            cout << i << endl;
            return 0;
        }

        mm[tmp]++;
        prev = tmp;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int M=1000007,A=998244353,B=100000007;
int k,n;
long long a[100005],s,p[65],i,j,ans;
int main()
{
	scanf("%d",&n);
	for(i=1;i<=n;i++)
	{
		scanf("%lld",&a[i]);
		s^=a[i];
	}
	for(i=1;i<=n;i++)
		for(j=60;j>=0;j--)
			if(((s>>j)&1)==0)
				if((a[i]>>j)&1)
					if(p[j]==0)
					{
						p[j]=a[i];
						break;
					}
					else
						a[i]^=p[j];
	for(i=60;i>=0;i--)
		if(((ans>>i)&1)^1)
			ans^=p[i];
	cout<<ans+(s^ans);
}

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

int main(){
  int n;
  cin >> n;
  string s1,s2;
  cin >> s1 >> s2;
  int dom[n];
  int cnt=0;
  for(int i=0;i<n;i++){
    if(i+1>=n){
      dom[cnt++] = 0;
      break;
    }
    if(s1[i] != s1[i+1]){
      dom[cnt++] = 0;
    }else{
      dom[cnt++] = 1;
      i++;
    }
  }
  long int ans=1;
  if(dom[0] ==0)
    ans *= 3;
  else
    ans *= 6;
  for(int i=1;i<cnt;i++){
    // cout << dom[i];
    if(dom[i]==0){
      if(dom[i-1] == 0)
        ans *= 2;
      else
        ans *= 1;
    }else{
      if(dom[i-1] == 0)
        ans *= 2;
      else
        ans *= 3;
    }
  }
  // cout << endl;
  cout << ans%1000000007 << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
using ll = long long;
using P = pair<int, int>;
#include<algorithm>
#include<math.h>
#include<map>

int main() {
	ll a, b, k,c(0);
	cin >> a >> b >> k;
	if (a > k) {
			a -= k;
			cout << a << ' ' << b;
			return 0;
	}
	else {
		k -= a;
		a = 0;
	}
	if (b > k) {
		b -= k;
		cout << a << ' ' << b;
	}
	else {
		cout << 0 << ' ' << 0;
	}
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pli = pair<ll, int>;
using pil = pair<int, ll>;
using uint = unsigned int;
template <typename T>
using Graph = vector<vector<T>>;
const int MOD = 1e9 + 7;
const ld PI = acosl(-1);

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

    int N;
    cin >> N;
    vector<int> va(N), vb(N);
    for (int i = 0; i < N; ++i)
        cin >> va[i] >> vb[i];
    sort(va.begin(), va.end());
    sort(vb.begin(), vb.end());

    ll ans = 0;
    if (N & 1) {
        int l = va[N >> 1], r = vb[N >> 1];
        ans = r - l + 1;
    } else {
        pii mi, ma;
        mi = {va[(N >> 1) - 1], vb[(N >> 1) - 1]};
        ma = {va[N >> 1], vb[N >> 1]};
        ans = mi.second - mi.first + ma.second - ma.first + 1;
    }

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


Measured memory_bytes: 4744
#include <bits/stdc++.h>
using namespace std;
signed main(){
  long long n,a[200000],b=0,c[200000];
  cin>>n;
  c[0]=0;
  a[0]=0;
  for(int i=1;i<=n;i++){
    cin>>a[i];
  }
  sort(a,a+n+1);
  for(int i=1;i<=n;i++){
    c[i]+=(a[i]+c[i-1]);
    if(a[i]<=c[i-1]*2)
      b++;
    else
      b=0;
  }
    
  cout<<b+1<<endl;
    
  return(0);
}


Measured memory_bytes: 2816
#include <bits/stdc++.h>
#define rep(i, n) for(long long int i = 0; i < n; i++)
#define _rep(i, m, n) for(long long int i = m; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
//const int N = 1000000;
const ll mod = 1000000007;
//using Graph = vector<vector<int>>;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int dh[8] = {0, 0, 1, 1, 1, -1, -1, -1};
const int dw[8] = {1, -1, 0, 1, -1, 0, 1, -1};
  
ll gcd(ll A, ll B){
    if(B == 0)return A;
    return gcd(B, A % B);
}
ll lcm(ll A, ll B){
    return A * (B / gcd(A, B));
}
using Edge = pair<int,int>;
using Graph = vector<vector<Edge>>;
Graph G;
  
/*------------------------------------------------------------------*/

int main(){
    ll n; cin >> n;
    ll ans = 1e15;
    for(ll i = 1; i * i <= n; i++){
        ll j = n / i;
        if(n % i == 0){
            ans = min(ans, i + j - 2);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
n, m = map(int, input().split())
arr = []
for i in range(m):
    a, b = map(int, input().split())
    arr.append((a,b))

one = set([b for a, b in arr if a == 1])
last = set([a for a, b in arr if b == n])
connect = one & last
if len(connect) >= 1:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Measured memory_bytes: 44292
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll a[100005];
int main()
{
    ll n;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        int c;
        cin>>c;
        a[c]=i;
    }
    set<ll> s;
    s.insert(a[n]);
    s.insert(a[n-1]);
    ll sum=(n-1)*(min(a[n],a[n-1])*(n+1-max(a[n],a[n-1])));
    //cout<<sum<<'\n';
    for(int i=n-2;i>=1;i--)
    {
        set<ll>::iterator it;
        it=s.lower_bound(a[i]);
        ll r,l,r1,l1;



        //
        if(it==s.begin())
        {l=0;
        l1=0;
        }
        else {

            it--;
            l=*it;
            if(it==s.begin())
                l1=0;
            else {
                    it--;
                    l1=*it;
            }
        }

        it=s.lower_bound(a[i]);
        if(it==s.end())
        {
            r=n+1;
            r1=n+1;
        }
        else{
            r=*it;
            it++;
            if(it==s.end())
            {
                r1=n+1;
            }
            else r1=*it;
        }
        //cout<<l1<<" "<<l<<" "<<a[i]<<" "<<r<<" "<<r1<<'\n';
        sum=sum+i*((r1-r)*(a[i]-l)+(l-l1)*(r-a[i]));
        s.insert(a[i]);
        //cout<<sum<<'\n';
    }
    cout<<sum<<'\n';


}


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

int main() {
  int n;
  std::cin >> n;
  int a, min = 0, max = 0;
  std::vector<bool> exist(8, false);
  for (int i = 0; i < n; ++i) {
    std::cin >> a;
    if (a >= 3200) {
      max++;
      continue;
    }
    if (!exist[a/400]) {
      min++;
      max++;
      exist[a/400] = true;
    }
  }
  if (min == 0 & max != 0)
    min = 1;
  std::cout << min << " " << max << std::endl;
}


Measured memory_bytes: 256
h,w=map(int,input().split())
s=[list(input()) for i in range(h)]
l=['#']*(w+2)

for i in range(h):
    s[i]=['#']+s[i]+['#']
s=[l]+s+[l]

for i in range(h+2):
    s[i]=''.join(s[i])
    
print(*s,sep='\n')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using std::cerr;using std::cin;using std::cout;using std::abs;using std::min;using std::max;using std::swap;using std::map;using std::unordered_map;using std::unordered_set;using std::bitset;using std::pair;using std::set;using std::string;using std::vector;using std::sort;using ll=long long;using uint=unsigned int;using pii=pair<int,int>;using pll=pair<ll,ll>;using ull = unsigned long long;using ld=long double;template<typename T>void _(const char*s,T h){cerr<<s<<" = "<<h<<"\n";}template<typename T,typename...Ts>void _(const char*s,T h,Ts...t){int b=0;while(((b+=*s=='(')-=*s==')')!=0||*s!=',')cerr<<*s++;cerr<<" = "<<h<<",";_(s+1,t...);}// break continue pop_back 998244353
#define int ll
#define pii pll
#define f first
#define s second
#define pb emplace_back
#define forn(i,n) for(int i=0;i<(n);++i)
#define sqr(x) ((x)*(x))
struct init{init(){cin.tie(0);std::iostream::sync_with_stdio(0);cout<<std::fixed<<std::setprecision(10);cerr<<std::fixed<<std::setprecision(5);}~init(){
#ifdef LOCAL
#define dbg(...) _(#__VA_ARGS__,__VA_ARGS__)
cerr<<"Time elapsed: "<<(double)clock()/CLOCKS_PER_SEC<<"s.\n";
#else
#define dbg(...) 
#endif
}}init;template<typename T,typename U>void upx(T&x,U y){if(x<y)x=y;}template<typename T,typename U>void upn(T&x,U y){if(x>y)x=y;}
const int N=2e5+2,M=1e9+7;

int32_t main(){

    int n;
    string s;
    cin>>n>>s;
    int ans=1,fac=1,bal=0;
    for(int i=1;i<=n;++i)(fac*=i)%=M;
    for(char c:s){
        if(c=='B'){
            if(bal&1){
                (ans*=bal)%=M;
                bal--;
            }else{
                bal++;
            }
        }else{
            if(bal&1){
                bal++;
            }else{
                (ans*=bal)%=M;
                bal--;
            }
        }
    }
    if(bal!=0)ans=0;
    cout<<(ans*fac)%M<<'\n';


    return 0;
}


Measured memory_bytes: 720
#include <bits/stdc++.h>
#define INF 1e9
using namespace std;

#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(a)  (a).begin(),(a).end()
#define endl "\n"

template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
typedef long long ll;


// Inputs
int D;
vector<int> c;
vector<vector<int>> s;

class Answer {
public:
    // 0~25の構造体
    vector<int> ans;
    explicit Answer() {
        ans.resize(D,0);
    }

    void print_ans() {
        for(const auto &it: ans) cout << it+1 << endl;
    }
};


// スコア計算を行う
ll calc(const Answer& ans) {
    // あるコンテストi-1が開催されていない日数
    vector<int> not_open_term(26,0);
    ll manzoku = 0;
    REP(day,D) {
        manzoku += s[day][ans.ans[day]];
        REP(typ,26) not_open_term[typ]++;
        REP(typ,26) if(typ != ans.ans[day])manzoku -= not_open_term[typ] * c[typ];
        not_open_term[ans.ans[day]] = 0;
        // For B その日終了時に満足度を出力する。
        cout << manzoku << endl;
    }
    return manzoku;
}


void read() {
    cin >> D;
    c.resize(26);
    REP(i,26) cin >> c[i];
    s.resize(D);
    REP(i,D) {
        s[i].resize(26);
        REP(j,26) cin >> s[i][j];
    }
}

// 下がりやすさを無視して一番点が高い物を選ぶ
Answer greedy1() {
    Answer answer = Answer();
    REP(day,D) {
        int mx = 0;
        REP(typ,26) if(chmax(mx,s[day][typ])) answer.ans[day] = typ;
    }
    return answer;
}

// 下がりやすさを考慮して一番高い物を選ぶ
Answer greedy2() {
    Answer answer = Answer();
    // あるコンテストi-1が開催されていない日数
    vector<int> not_open_term(26,0);

    REP(day,D) {
        // 期待値の最大値
        int mx = 0;
        REP(typ,26) {
            // そのコンテストを開催した際の満足度変動値を計算する。
            int manzoku = s[day][typ];
            REP(_typ,26) if(_typ != typ )manzoku-=(not_open_term[_typ] * c[_typ]);
            if(chmax(mx,manzoku)) answer.ans[day] = typ;
        }
        REP(i,26) not_open_term[i]++;
        // 開催するコンテストが決定されたらそれの日数を0にする。
        not_open_term[answer.ans[day]] = 0;
    }
    return answer;

}

void solveB() {
    read();
    Answer answer = Answer();
    REP(i,D) {
        cin >> answer.ans[i];
        answer.ans[i]--;
    }
    cerr << calc(answer) << endl;
}

void solve() {
    read();
    // auto ans = Answer();
    // ans.print_ans();
    auto ans = greedy2();
    ans.print_ans();
}

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

Measured memory_bytes: 3680
N, L = map(int, input().split())

taste = [L+i-1 for i in range(1,N+1)]
amount_taste = sum(taste)

if L < 0 and L+N-1 < 0:
    ans = amount_taste - max(taste)
elif L <= 0 and 0 <= L+N-1:
    ans = amount_taste
elif 0 < L and 0 < L+N-1:
    ans = amount_taste - min(taste)

print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define ios ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
using namespace std;
typedef long long int ll;
const ll mod=1e9+7;
ll qsm(ll a,ll b)
{
	ll s=1;
	while(b)
	{
		if(b&1)s=s*a%mod;
		a=a*a%mod;
		b>>=(ll)1;
	}
	return s;
}
int main()
{
	ios;
	ll n;
	cin>>n;
	if(n<=1){cout<<0<<'\n';return 0;}
	ll a=(((qsm(10,n)%mod-qsm(9,n)%mod+mod)%mod-qsm(9,n)+mod)%mod+qsm(8,n))%mod;
	cout<<a<<'\n';
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
    using namespace std;
     
    using ll = long long;
     
    #define INF (1LL << 31 - 1)
    #define MOD int(1e9+7)
    #define repi(i,j,n) for(int i = (j); i < (n); ++i)
    #define rep(i,n) repi(i,0,n)
    #define fi first
    #define se second
     
    inline void init() {
        cin.tie(0);
        ios::sync_with_stdio(false);
    }
     
    int a, b, c, d, e, f, ansx, ansy;
    bool water[3001], suger[3001];
     
    int main() {
        cin >> a >> b >> c >> d >> e >> f;
        a *= 100;
        b *= 100;
     
        water[0] = suger[0] = true;
     
        for (int i = 0; i <= f; ++i) {
            if (i >= a) water[i] = water[i] | water[i - a];
            if (i >= b) water[i] = water[i] | water[i - b];
            if (i >= c) suger[i] = suger[i] | suger[i - c];
            if (i >= d) suger[i] = suger[i] | suger[i - d];
        }
     
        ansx = a, ansy = 0;
     
        for (int x = 0; x <= f; x+=100) {
            if (water[x]) {
                for (int y = 0; y <= f - x; ++y) {
                    if (suger[y]) {
                        if (x * e < y * 100) break;
     
                        if ((x + y) * ansy < y * (ansx + ansy)) {
                            ansx = x;
                            ansy = y;
                        }
                    }
                }
            }
        }
     
        cout << ansx + ansy << " " << ansy << endl;
     
        return 0;
    }

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
#define LL long long
using namespace std;
const LL mod=1e9+7;
LL fac[100010],inv[100010];
void pre()
{
	fac[0]=fac[1]=inv[0]=inv[1]=1;
	for(LL i=2;i<=100005;i++) inv[i]=(mod-mod/i)*inv[mod%i]%mod;
	for(LL i=2;i<=100005;i++) inv[i]=inv[i-1]*inv[i]%mod,fac[i]=fac[i-1]*i%mod;
}
LL C(LL m,LL n) {return fac[m]*inv[m-n]%mod*inv[n]%mod;}
LL n,len,last[100010];
int main()
{
	pre();
	scanf("%lld",&n);n++;
	for(LL i=1;i<=n;i++)
	{
		LL c;scanf("%lld",&c);
		if(last[c]) len=i-last[c]+1;
		else last[c]=i;
	}
	for(LL i=1;i<=n;i++)
	{
		LL ans=C(n,i);
		if(n-len>=i-1) (ans-=C(n-len,i-1))%=mod;
		printf("%lld\n",(ans+mod)%mod);
	}
}

Measured memory_bytes: 3584
#include<set>
#include<queue>
#include<utility>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<numeric>
#include<functional>
#include<string>
#include<iostream>

using namespace std;
const int one = 1;
const int big = (one<<20);
typedef long long int llint;
bool solve(void){
	int d,n,m,h,ans=0,a,saki;
	vector<llint>tenpo;
	scanf("%d",&d);
	if(d==0){return false;}
	tenpo.push_back(0);
	tenpo.push_back(d);
	scanf("%d",&n);
	scanf("%d",&m);
	for(h=1;h<n;h++){
		scanf("%d",&a);
		tenpo.push_back(a);
	}
	sort(tenpo.begin(),tenpo.end());
	for(h=0;h<m;h++){
		scanf("%d",&saki);
		auto it=upper_bound(tenpo.begin(),tenpo.end(),saki);
		a=min(abs((*it)-saki),abs((*(it-1))-saki));
		ans+=a;
	}
	printf("%d\n",ans);
	return true;
}
int main(void){
	while(solve()){}
	return 0;
}

Measured memory_bytes: 3944
a = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(a[int(input())-1])

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

int main() {

	ll n; cin >> n;
	vector<ll> vx(n), vy(n), vh(n);
	ll hPositiveIndex;
	for (ll i = 0; i < n; i++) {
		cin >> vx[i] >> vy[i] >> vh[i];
		if (0 < vh[i]) hPositiveIndex = i;
	}
	const ll p = 100;
	ll resx = -1;
	ll resy = -1;
	ll resh = -1;
	for (ll x = 0; x <= p; x++) {
		for (ll y = 0; y <= p; y++) {			
			ll h = vh[hPositiveIndex] + abs(vx[hPositiveIndex] - x) + abs(vy[hPositiveIndex] - y);
			bool ok = true;
			for (ll i = 0; i < n; i++) {
				if (0 < vh[i] && vh[i] != h - abs(vx[i] - x) - abs(vy[i] - y)) ok = false;
				if (vh[i] == 0 && h > abs(vx[i] - x) + abs(vy[i] - y)) ok = false;
			}
			if (ok) {
				resx = x;
				resy = y;
				resh = h;
			}
		}
	}
	cout << resx << " " << resy << " " << resh << endl;
	return 0;
}

Measured memory_bytes: 3552
n, m, x = map(int, input().split())
c = []
a = []
for _ in range(n):
    tmp = list(map(int, input().split()))
    c.append(tmp[0])
    a.append(tmp[1:])

ans = float('inf')
for p in range(2 ** n):
    total = 0
    line = [0] * m
    for i in range(n):
        if (p >> i) & 1:
            for j in range(m):
                line[j] += a[i][j]
            total += c[i]
    if all((num >= x for num in line)):
        ans = min(ans, total)

print(ans if ans != float('inf') else -1)

Measured memory_bytes: 9232
fn main() {
    let (n, k, v) = read();
    let ans = solve(n, k, v);
    write(ans);
}
 
fn read() -> (u64, u64, Vec<u64>) {
    let mut l1 = String::new();
    std::io::stdin().read_line(&mut l1).ok();
    let mut iter = l1.trim().split_whitespace();
    let n = iter.next().unwrap().parse::<u64>().unwrap();
    let k = iter.next().unwrap().parse::<u64>().unwrap();

    let mut l1 = String::new();
    std::io::stdin().read_line(&mut l1).ok();
    let v: Vec<u64> = l1.trim()
        .split_whitespace()
        .map(|x| x.parse::<u64>().unwrap())
        .collect();
    
    (n, k, v)
}
 
fn write(ans: u64) {
    println!("{}", ans);
}
 
fn solve(n: u64, k: u64, mut v: Vec<u64>) -> u64 {
    if v.len() as u64 <= k {
        return 0;
    }

    v.sort();
    let s = &v[..v.len() - k as usize];
    s.iter().sum::<u64>()
}


Measured memory_bytes: 5788
import java.util.Arrays;

import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner sc = new Scanner(System.in);
        int N=sc.nextInt();
        int[] d=new int[N];
        int mid=0;
        int max=0;
        int min=100000;
        for(int i=0;i<N;i++){
            d[i]=sc.nextInt();
            mid+=d[i];
            if(d[i]>max){
                max=d[i];
            }
            if(d[i]<min){
                min=d[i];
            }
        }
        int[] e=d;
        Arrays.sort(e);

        mid=e[N/2-1];
        int count=0;










        System.out.println(e[N/2]-e[N/2-1]);






    }
}


Measured memory_bytes: 50396
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <functional>
#include <set>
#include <sstream>
#include <map>
 
using namespace std;
 
const double eps=1e-10;
 
int main()
{
	int m,d;

	int dd[13]={0,31,29,31,30,31,30,31,31,30,31,30,31};
	for(int i=1;i<=12;i++) dd[i]+=dd[i-1];

	string str[]={
		"Monday",
		"Tuesday",
		"Wednesday",
		"Thursday",
		"Friday",
		"Saturday",
		"Sunday"
	};

	while(cin>>m>>d,m){
		int day=(d+dd[m-1]+2)%7;
		cout<<str[day]<<endl;
	}

	return 0;
}

Measured memory_bytes: 1196
def main():
    from itertools import combinations

    INF = 1 << 30

    N, M, X = map(int, input().split())

    book = []
    for _ in range(N):
        c, *a = map(int, input().split())
        book.append((c, a))

    ans = INF
    for take in range(1, N + 1):
        for comb in combinations(book, r=take):
            cost = 0
            know = [0] * M
            for c, a in comb:
                cost += c
                for i, x in enumerate(a):
                    know[i] += x
            if all(x >= X for x in know) and ans > cost:
                ans = cost

    if ans == INF:
        print(-1)
    else:
        print(ans)


if __name__ == '__main__':
    main()

# import sys
# input = sys.stdin.readline
# 
# sys.setrecursionlimit(10 ** 7)
# 
# (int(x)-1 for x in input().split())
# rstrip()
#
# def binary_search(*, ok, ng, func):
#     while abs(ok - ng) > 1:
#         mid = (ok + ng) // 2
#         if func(mid):
#             ok = mid
#         else:
#             ng = mid
#     return ok


Measured memory_bytes: 68648
#include <bits/stdc++.h>
#define rep(i,n)    for(long long i = 0; i < (n) ; ++i)
#define orep(i,n)   for(long long i = 1; i <= (n); ++i)   // one rep
#define drep(i,n)   for(long long i = (n)-1; i >= 0; --i) // down rep
#define srep(i,s,t) for(long long i = (s); i < (t); ++i)  // set rep
#define rng(x)  (x).begin(),(x).end()

  // range
#define rrng(a) (a).rbegin(),(a).rend() // reverse range
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define ru(x,y) (((x)+(y)-1)/(y)) // round up
#define fi first
#define se second
#define eb emplace_back
#define fcout cout << fixed << setprecision(15)


using namespace std;
using ll  = long long;
using P   = pair<int,int>;
using vi  = vector<int>;
using vvi = vector<vi>;
using vp  = vector<P>;
using vl  = vector<ll>;

template<typename T> void Yes(T flag) {
  cout << (flag ? "Yes" : "No") << endl;
}

template<typename T> void pv(vector<T> vec) {
  cout << "[";
  for(auto& v : vec) { cout << v << ","; }
  cout << "]" << endl;
}

template<>
void pv(vector<P> vec) {
  cout << "[";
  for(auto& v : vec) {
    cout << "<" << v.fi << ","<< v.se << ">" << ",";
  }
  cout << "]" << endl;
}

template<typename T> void pv2(vector<vector<T>> vec) {
  for(auto& v : vec) pv(v);
}


// int n以下の素数リスト
struct PrimeTable {
  int n;
  vector<int> sieve, primes;
  PrimeTable(int n) : n(n), sieve(n+1) {
    sieve[0] = sieve[1] = -1;
    for(long long i = 2;i < n+1;++i) {
      if (sieve[i]) continue;
      primes.emplace_back(i);
      sieve[i] = i;
      // 一番小さい素因数のみ記録する
      for (long long j = i*i; j <= n; j += i) if (!sieve[j]) sieve[j] = i;
    }
  }
  bool isPrime(int m) { return sieve[m] == m; }
  vector<int> factorList(int x) {
    vector<int> res;
    if(x == 0) {
      res.emplace_back(0);
      return res;
    } else if(x == 1) {
      res.emplace_back(1);
      return res;
    }
    while (x != 1) {
      res.emplace_back(sieve[x]);
      x /= sieve[x];
    }
    return res;
  }
  vector<pair<int,int>> factorPair(int x) {
    vector<int> fl = factorList(x);
    vector<pair<int,int>> res(1, pair<int,int>(fl[0], 0));
    for (int p : fl) {
      if (res.back().first == p) res.back().second++;
      else res.emplace_back(p, 1);
    }
    return res;
  }
};

ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a; }

int main() {
  int n; cin >> n;
  vi a(n,0);
  int one=0;
  rep(i,n) {
    int b; cin >> b;
    if(b==1) one++;
    a.at(i) = b;
  }
  PrimeTable p = PrimeTable(1000005);

  vi s(1000005,0);
  bool flag = true;
  rep(i,n) {
    vector<int> pa = p.factorList(a.at(i));
    int x = pa.at(0);
    if(x==1) continue;
    if(!s.at(x)) s.at(x)++;
    else {
      flag = false;
      break;
    }
    rep(j,pa.size()) {
      if(x != pa.at(j)) {
        x = pa.at(j);
        if(!s.at(x)) s.at(x)++;
        else {
          flag = false;
          break;
        }
      }
    }
    if(!flag) break;
  }


  if(flag) {
    cout << "pairwise coprime" << endl;
    return 0;
  }

  int ans = a.at(0);
  orep(i,n-1) {
    ans = gcd(ans,a.at(i));
  }
  if(ans == 1) cout << "setwise coprime" << endl;
  else cout << "not coprime" << endl;


  return 0;
}


Measured memory_bytes: 15308
n=int(input())
a=list(map(int,input().split()))
a.sort()
A=(2**(n//2))%(10**9+7)
for i in range(n):
  if i%2==n%2 and i+1!=a[i] or i%2==(n+1)%2 and i!=a[i]:
    A=0
    break
print(A)

Measured memory_bytes: 13880
#include <iostream>
#include <vector>
#include <unordered_map>
#include <map>
#include <algorithm>
#include <set>
#include <unordered_set>
#include <deque>
#include <cmath>
#include <stack>
#include <queue>
#include <string>
#include <locale>
#include <iomanip>

#define nl '\n';

using namespace std;

int n, p, x;

int main(){

    cin >> n;

    vector<int> v1;
    vector<int> v2;

    for(int i = 0; i < n; i++){
        cin >> p;
        v1.push_back(p);
        v2.push_back(p);
    }

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

    for(int i = 0; i < v1.size(); i++){
        if(v1[i] != v2[i]){
            x++;
        } if(x > 2){
            cout << "NO";
            return 0;
        }
    }

    cout << "YES";



}

//g++ -std=c++14 comp.cpp -o b; ./b.exe
//g++ -std=c++14 comp.cpp && ./a.out

// char** arr = new char*[r];
// for(long long i = 0; i < r; i++) arr[i] = new char[c];

Measured memory_bytes: 256
#include <stdio.h>
#define NUM 1000001

typedef unsigned long long int ll;

int main(){
    int N=0;
    ll A[NUM];
    ll B[NUM];
    int i =0;
    ll sum =0;
    
    scanf("%d",&N);
    for(i=0;i <= N;i++){
        scanf("%llu",&A[i]);
    }
    for(i=0;i < N;i++)
    {
    	scanf("%llu",&B[i]);
    }
    
    for(i=0;i < N;i++)
    {
        if(A[i] <= B[i])
        {
        	sum+=A[i];
        	B[i]-=A[i];
        	if(A[i+1] <= B[i])
        	{
        		sum+=A[i+1];
        		A[i+1]=0;
        	}else{
        		sum+=B[i];
        		A[i+1]-=B[i];
        	}
        }else{
            sum+=B[i];
        }
    }
    
    printf("%llu",sum);
    return 0;
}

Measured memory_bytes: 6272
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
ll i, t, n, K;
double temp, a[200600];
int main()
{
    //I am Monim, a tiny creature of Allah
    cin >> n >> K;
    for(i=1;i<=n;i++)
    {
        cin >> a[i];
        if(i>K)
        {
            if(a[i-K]<a[i])
                cout << "Yes" <<endl;
            else
                cout << "No" <<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 5304
N = int(input())
W = list(map(int, input().split()))

diff = max(W)

for i in range(N):
    left = sum([W[j] for j in range(i)])
    right = sum([W[k] for k in range(i, N)])
    d = abs(left - right)
    if d < diff:
        diff = d

print(diff)


Measured memory_bytes: 3060
#include<iostream>
#include<iomanip>
//#include<cstdio>
#include<vector>
#include<map>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cassert>
using namespace std;
typedef long long ll;
int N;
int H[20];

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

	int ans = 0;
	int hmax = 0;
	for(int i=0; i<N; i++){
		if(hmax <= H[i]) ans++;
		hmax = max(hmax, H[i]);
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
 
int main() {
  long long  N ,K;

  cin >> N >> K;

  long long NmodK = N % K;

  if(NmodK > (abs(NmodK-K))){
    cout << (abs(NmodK-K)) << endl;
  }else{
    cout << NmodK << endl;
  }

  //while(1){
//
  //  tmp = N;
  //  N = abs(N-K);
  //  
  //  cout << "tmp:" << tmp;
  //  cout << " N:" << N;
  //  cout << " K:" << K;
  //  cout << endl;
//
  //  if(tmp < N){
  //    cout << tmp << endl;
  //    return 0;
  //  }
  //}  
}





Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

n=II()
s=SI()
p=s.count("1")
p0=p-1
p1=p+1
pw0=[]
pw1=[]
two0=two1=1
for _ in range(n):
    pw0.append(two0)
    pw1.append(two1)
    if p0>0:two0=two0*2%p0
    two1=two1*2%p1

t0=0
t1=0
for i,c in enumerate(s[::-1]):
    if c=="1":
        if p0>0:t0=(t0+pw0[i])%p0
        t1=(t1+pw1[i])%p1

def popcnt(x):
    return bin(x).count("1")

dp0=[-1]*n
def f0(x):
    if x==0:return 1
    if dp0[x]==-1:dp0[x]=f0(x%popcnt(x))+1
    return dp0[x]

ans=[]
for i,c in enumerate(s[::-1]):
    if p0==0 and c=="1":
        ans.append(0)
        continue
    if c=="1":
        cur=(t0-pw0[i])%p0
    else:
        cur=(t1+pw1[i])%p1
    ans.append(f0(cur))

for a in ans[::-1]:print(a)

Measured memory_bytes: 29680
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const long double PI = acos(-1);
#define chmin(i, j) i = min(i, j);
#define chmax(i, j) i = max(i, j);
#define rep(i, n) for(int i=0;i<n;i++)
ll MOD = 1000000007;
ll fact(ll m) {
  if(m == 0 || m == 1) return 1LL;
  else return (m * fact(m-1LL)) % MOD;
}
bool custom(pair<ll, ll> a, pair<ll, ll> b) {
  if(a.first == b.first) return (a.second > b.second);
  else return a.first < b.first;
}
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
int main() {
  ll n, K;
  cin >> n >> K;
  vector<vector<int>> g(n);
  vector<bool> seen(n);
  for(int i=0;i<n-1;i++) {
    int a, b;
    cin >> a >> b;
    a--;b--;
    g[a].emplace_back(b);
    g[b].emplace_back(a);
  }
  vector<ll> k1(K);
  vector<ll> k2(K);
  for(int i=0;i<K;i++) {
    if(i == 0) k1[i] = 1;
    else k1[i] = k1[i-1] * (K-i) % MOD;;
  }
  for(int i=0;i<K-1;i++) {
    if(i == 0) k2[i] = 1;
    else k2[i] = k2[i-1] * (K-i-1) % MOD;
  }
  queue<int> que;
  ll ans = K;
  bool yes = true;
  que.emplace(0);
  while(!que.empty()) {
    int node = que.front();que.pop();
    if(seen[node]) continue;
    seen[node] = true;
    ll deg = g[node].size();
    if(deg > K-1) {
      yes = false;
      break;
    }
    if(node == 0) ans = ans * k1[deg] % MOD;
    else {
      deg--;
      ans = ans * k2[deg] % MOD;
    }
    for(auto&el : g[node]) que.emplace(el);
  }
  if(yes) cout << ans << endl;
  else cout << 0 << endl;
}


Measured memory_bytes: 8056
#include <iostream>
#include <iterator>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <cstring>
#include <stack>
#include <vector>
#include <list>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <limits>
#include <utility>
#define EPS (1e-10)
#define REP(i,n) for(int i=0;i<n;i++)
#define equals(a,b) (fabs((a) - (b)) < EPS)
#define ll long long
using namespace std;

//typedef pair<int,int> P;
//const ll MOD = 1000000007;
//const ll INF = 100000000;

double R;

//stack<int> stack;
//queue<int> que;
//priority_queue<int> pque;
//set<int> s; set<int>::iterator ite;
//multiset<int> ms; multiset<int>::iterator ite;
//map<int, int> m; map<int, int>::iterator ite;
//multimap<int, int> mm; multimap<int, int>::iterator ite;

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

#define PI 3.14159265359
void solve() {
  printf("%lf\n", 2 * PI * R);
}

int main(int argc, char const *argv[]) {

  scanf("%lf", &R);

  solve();
  return 0;
}


Measured memory_bytes: 3828
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define rep(i,j,k) for(int i=j;i<k;i++)
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
int main(){
  int a;
  cin >> a;
  cout << (3* a * a) << endl;
	return 0;
}


Measured memory_bytes: 256
from collections import deque

class Graph:
    def __init__(self,size):
        self.graph = [ {
            'idx' : i,
            'to': [],
            'inputs' : 0,
        } for i in range(size) ]

    def add_node(self,start,end):
        self.graph[start]['to'].append(end)
        self.graph[end]['inputs'] += 1

    def topological_sort(self):
        inputs = [i['inputs'] for i in self.graph]
        no_inputs = deque([ i['idx'] for i in self.graph if i['inputs'] == 0])
        ans = []
        while no_inputs:
            vertex1 = no_inputs.popleft()
            ans.append(vertex1)
            for vertex2 in self.graph[vertex1]['to']:
                inputs[vertex2] -= 1
                if inputs[vertex2] == 0:
                    no_inputs.append(vertex2)
        return ans

def main():
    n,m = map(int, input().split())
    G = Graph(n)
    for _ in range(m):
        x,y = map(int, input().split())
        G.add_node(x-1,y-1)
    tp = G.topological_sort()
    dist = [0] * n
    for v in tp[::-1]:
        for t in G.graph[v]['to']:
            if dist[v] <= dist[t]:
                dist[v] = dist[t] + 1
    print(max(dist))

if __name__ == '__main__':
    main()

Measured memory_bytes: 97884
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define pll pair<ll,ll>
#define pint pll
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

ll r[200020];

int main(){
  int n;
  cin >> n;
  ll p;
  cin >> p;
  string s;
  cin >> s;
  if(p==2 || p==5){
    ll ans=0;
    rep(i,n){
      if((s[i]-'0')%p==0)ans+=i+1;
    }
    cout << ans << endl;
    return 0;
  }
  ll x=1;
  r[n]=0;
  for(int i=n-1;i>=0;i--){
    r[i]=(r[i+1]+((s[i]-'0')*x)%p)%p;
    x*=10;
    x%=p;
  }
  ll ans=0;
  ll cnt[p]={};
  cnt[0]++;
  for(int i=n-1;i>=0;i--){
    ans+=cnt[r[i]];
    cnt[r[i]]++;
  }
  cout << ans << endl;
return 0;}

Measured memory_bytes: 2180
#!/usr/bin/env python3

# from typing import Optional
# from typing import List
# from typing import Dict
# from typing import Tuple
# from typing import Sequence


def main():
    N = int(input())
    A = map(lambda x: int(x), input().split())

    currentMax = 0
    result = 0
    for item in A:
        if item > currentMax:
            currentMax = item
        else:
            result += currentMax - item

    print(result)


if __name__ == "__main__":
    main()


Measured memory_bytes: 25072
#include <bits/stdc++.h>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<string.h>
using namespace std;
#define pb push_back
#define all(v) v. begin(),v. end()
#define  rep(i,n,v) for(i=n;i<v;i++)
#define per(i,n,v) for(i=n;i>v;i--)
#define ff first 
#define ss second 
#define pp pair<ll,ll>
#define ll  long long
#define endl '\n'
void solve()
{
  ll n, a,m=0,b=1, c,k=0, i, j,l=1e9+7;
  string s, r, y;
  cin>>s;
  rep(i,0,s.length())
  {
    if(s[i]=='0') b=0;
     if(s[i]=='1') b=1;
      if(s[i]=='2') b=2;
       if(s[i]=='3') b=3;
        if(s[i]=='4') b=4;
         if(s[i]=='5') b=5;
          if(s[i]=='6') b=6;
           if(s[i]=='7') b=7;
            if(s[i]=='8') b=8;
             if(s[i]=='9') b=9;
    k+=b;
  }
  if(k%9==0) cout<<"Yes";
  else cout<<"No";
}
int main()
{
 ios_base::sync_with_stdio(false);
  cin. tie(0);cout. tie(0);
    ll t=1;
   //cin>>t;
    while(t--)
    {
      solve();
    }
    return 0;
}

Measured memory_bytes: 3764
import java.util.*;
import java.io.*;

class Main
{
	public static void main (String[] args) throws Exception
	{
		// your code goes here
		BufferedReader bu=new BufferedReader(new InputStreamReader(System.in));
		int n=Integer.parseInt(bu.readLine());
		int i,j,k;long sum=0;
		for(i=1;i<=n;i++)
		for(j=1;j<=n;j++)
		{
			int g=gcd(i,j);
			for(k=1;k<=n;k++)
			sum=sum+gcd(g,k);
		}
		System.out.print(sum);
	}
	
	static int gcd(int a,int b)
	{
		if(a<b) a=a^b^(b=a);
		while(b!=0)
		{
			int t=b;
			b=a%b;
			a=t;
		}
		return a;
	}
}

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

#define LL long long int
#define L long int
#define IM INT_MAX
#define Im INT_MIN
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define read  freopen("input.txt", "r", stdin)
#define write freopen("output.txt", "w", stdout)
#define pb(x) push_back(x)
#define all(v) sort(v.begin(),v.end())

int main(){

fast;

double n,x,t;

cin>>n>>x>>t;

LL ans=ceil(n/x);
ans*=t;

cout<<ans;

return 0;
}


Measured memory_bytes: 3824
#include<stdio.h>
 
int main(void)
{
  int a,b,c,d;
  scanf("%d %d %d %d",&a,&b,&c,&d);
  
  if(a>=d){
    printf("%d\n",d);
  }
  else if((a+b) >= d){
    printf("%d\n",a);
  }
  else{
    printf("%d\n",a-(d-(a+b)));
  }
  return 0;
}

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

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

using namespace std;

int main() {
  int h, w;
  std::cin >> h >> w;
  std::vector<string> a(h);
  rep(i, h) { std::cin >> a[i]; }

  std::vector<int> v1(h), v2(w);

  rep(i, h) {
    rep(j, w) {
      if (a[i][j] == '#') {
        v1[i] = 1;
        break;
      }
    }
  }

  rep(i, w) {
    rep(j, h) {
      if (a[j][i] == '#') {
        v2[i] = 1;
        break;
      }
    }
  }

  rep(i, h) {
    bool ok = false;
    rep(j, w) {
      if (v1[i] == 1 && v2[j] == 1) {
        std::cout << a[i][j];
        ok = true;
      }
    }
    if (ok) {
      std::cout << std::endl;
    }
  }

  return 0;
}


Measured memory_bytes: 3608
let readString() = stdin.ReadLine()
let readStringArray() = stdin.ReadLine().Split(' ');
let readInt() = readString() |> int
let readIntArray() = readStringArray() |> Array.map(fun x -> int x)
let char2String(value) = List.ofSeq value |> List.toArray |> System.String

let s = readString().ToCharArray() |> List.ofArray

let next c = if c = '0' then '1' else '0'

let rec solve str c = 
    match str with
    | h::t -> if h = c then (solve t (next c)) + 1  else solve t (next c)
    | _ -> 0

min (solve s '0') (solve s '1') 
|> printfn "%d"

Measured memory_bytes: 22364