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

int n;
string s;
long long ans=0;
bool rc[8001];
bool gc[8001];
bool bc[8001];
vector<int> rr,gg,bb;
int rcnt=0, gcnt=0, bcnt=0;

void solve(int x){
	int i=0,j=0;
	int gtmp=gcnt, btmp=bcnt, rtmp=rcnt;
	if(s[x-1]=='R'){
		while(gg[i]<x and i<(int)gg.size()-1){	
				i++;
				gtmp--;
			}
		while(bb[j]<x and j<(int)bb.size()-1){
			j++;
			btmp--;
		}
		while(i<(int)gg.size()-1 and j<(int)bb.size()-1){
			if(gg[i]<bb[j]){
				if(bc[2*gg[i]-x]){
					ans+=btmp-1;
				}else{
					ans+=btmp;
				}
				gtmp--;
				i++;
			}else{
				if(gc[2*bb[j]-x]){
					ans+=gtmp-1;
				}else{
					ans+=gtmp;
				}
				btmp--;
				j++;
			}
		}
		
	}else if(s[x-1]=='G'){
		while(rr[i]<x and i<(int)rr.size()-1){
				i++;
				rtmp--;
			}
		while(bb[j]<x and j<(int)bb.size()-1){
			j++;
			btmp--;
		}
		while(i<(int)rr.size()-1 and j<(int)bb.size()-1){
			if(rr[i]<bb[j]){
				if(bc[2*rr[i]-x]){
					ans+=btmp-1;
				}else{
					ans+=btmp;
				}
				rtmp--;
				i++;
			}else{
				if(rc[2*bb[j]-x]){
					ans+=rtmp-1;
				}else{
					ans+=rtmp;
				}
				btmp--;
				j++;
			}
		}
		
	}else if(s[x-1]=='B'){
		while(gg[i]<x and i<(int)gg.size()-1){
				i++;
				gtmp--;
			}
		while(rr[j]<x and j<(int)rr.size()-1){
			j++;
			rtmp--;
		}
		while(i<(int)gg.size()-1 and j<(int)rr.size()-1){
			if(gg[i]<rr[j]){
				if(rc[2*gg[i]-x]){
					ans+=rtmp-1;
				}else{
					ans+=rtmp;
				}
				gtmp--;
				i++;
			}else{
				if(gc[2*rr[j]-x]){
					ans+=gtmp-1;
				}else{
					ans+=gtmp;
				}
				rtmp--;
				j++;
			}
		}
		
	}
}

int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	cin>>n>>s;
	for(int i=1; i<=n;i++){
		rc[i]=false;
		gc[i]=false;
		bc[i]=false;
		if(s[i-1]=='R'){
			rr.push_back(i);
			rc[i]=true;
			rcnt++;
		}else if(s[i-1]=='G'){
			gg.push_back(i);
			gc[i]=true;
			gcnt++;
		}if(s[i-1]=='B'){
			bb.push_back(i);
			bc[i]=true;
			bcnt++;
		}
	}
	gg.push_back(5000);
	bb.push_back(5000);
	rr.push_back(5000);
	for(int i=1; i<=n-2;i++){
		solve(i);
	}
	
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3704
n = int(input())
used = set()
bot = [int(input()) for i in range(n)]
bot.insert(0,0)
here = 1
used.add(1)
cnt = 0
while True:
    if here == 2:
        print(cnt)
        exit()
    elif bot[here] not in used:
        used.add(bot[here])
        here = bot[here]
        cnt += 1
    else:
        print(-1)
        exit()

Measured memory_bytes: 55896
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define FORD(i, a, b) for (ll i = a ; i > b ; i--)
#define hahashad ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
typedef long long ll;
#define VL vector<ll> 
#define what(A) cout<<#A<<" is "<<A<<endl;
int main()
{
    ll n;
    cin>>n;
    map<ll, ll> m;
    FOR(i,1,n+1)
    {
        m[i]=0;
    }
	FOR(i,1,101)
    {
        FOR(j,1,101)
        {
            FOR(k,1,101)
            {
                ll a=pow(k,2)+pow(j,2)+pow(i,2)+(k*i)+(j*i)+(j*k);
                m[a]++;
            }
        }
    }
    FOR(i,1,n+1)
        cout<<m[i]<<endl;
    
}

Measured memory_bytes: 6060
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
const int inf = 1001001001;


int n, m, q;
int A[11]{};
int a[50], b[50], c[50], d[50];
int ans = 0;

void dfs(int x) {
  if(x == n){
    int sum = 0;
    for(int i = 0; i <q; i++){
      if(A[b[i]] - A[a[i]] == c[i]) sum += d[i];
    }
    ans = max(ans,sum);
    return;
  }

  for(int i = min(A[x],m); i <= m; i++){
    A[x+1] = i;
    dfs(x+1);
  }
}



int main(){
  cin >> n >> m >> q;
  rep(i,q) cin >> a[i] >> b[i] >> c[i] >> d[i];
  A[0] = 1;
  dfs(0);
  cout << ans << endl;
  return 0;
}


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

using namespace std;

using ll = long long;
const int inf = (int)1e9;
ll s;
int x_1 = inf, x_2 = 1, y_1, y_2;

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

    cin >> s;
    y_2 = (int)( (s + x_1 - 1) / x_1);

    y_1 = (int)(1LL * x_1 * y_2 - s);

    cout << 0 << ' ' << 0 << ' ' << x_1 << ' ' << y_1 << ' ' << x_2 << ' ' << y_2 << '\n';

    return 0;
}


Measured memory_bytes: 256
#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)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;


ll dp[5050][2];
int main(){
    int n;
    cin>>n;
    ll r[n],a[n],w[n],t[n];
    rep(i,n)cin>>r[i]>>a[i]>>w[i]>>t[i];
    vector<int> ord(n);
    iota(ord.begin(),ord.end(),0);
    sort(ord.begin(),ord.end(),[&](int x,int y){
        return r[x]+t[x]<r[y]+t[y];
    });
    rep(j,5050)rep(k,2)dp[j][k]=-longinf;
    dp[0][0]=0;
    for(auto i : ord){
        rep(j,r[i]+t[i]){
            if(j-r[i]>=0)dp[j][1]=max(dp[j][1],dp[j-r[i]][0]+a[i]);
        }
        rep(j,r[i]+t[i]){
            if(j-r[i]>=0)dp[j][1]=max(dp[j][1],dp[j-r[i]][1]+w[i]);
        }
        rep(j,5050){
            dp[j][0]=max(dp[j][0],dp[j][1]);
            dp[j][1]=-longinf;
        }
    }
    ll ans = 0;
    rep(j,5050)ans = max(ans,dp[j][0]);
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3308
import itertools
n=int(input())
cnt=0
for j in range(1, len(str(n))+1):
  lst=(list(itertools.product([3, 5, 7], repeat=j)))
  for i in range(len(lst)):
    temp=int("".join(map(str, lst[i])))
    if "3" in str(temp) and "5" in str(temp) and "7" in str(temp) and temp<=n:
      cnt+=1
print(cnt)

Measured memory_bytes: 12220
#include<bits/stdc++.h>
using namespace std;
int a[100000];
int main()
{
    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;
    for(int i=1;i<=ty-sy;i++)
    {
        cout<<"U";
    }
    for(int i=1;i<=tx-sx;i++)
    {
        cout<<"R";
    }
    for(int i=1;i<=ty-sy;i++)
    {
        cout<<"D";
    }
    for(int i=1;i<=tx-sx;i++)
    {
        cout<<"L";
    }
    cout<<"L";
    for(int i=0;i<=ty-sy;i++)
    {
        cout<<"U";
    }
    cout<<"R";
    for(int i=1;i<=tx-sx;i++)
    {
        cout<<"R";
    }
    cout<<"D";
    cout<<"R";
    for(int i=0;i<=ty-sy;i++)
    {
        cout<<"D";
    }
    cout<<"L";
    for(int i=1;i<=tx-sx;i++)
    {
        cout<<"L";
    }
    cout<<"U"<<endl;
    return 0;
}


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

#define int         long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
using namespace std;

void solve(){
   int a[5],b,c=0,d,e=1,k=0,n,i;
   cin>>n;
   vector < int > v(n),gdl(n+1,0),gdr(n+1,0);
   rep(i,0,n) cin>>v[i];
   rep(i,0,n)
    {
        gdl[i+1]=__gcd(gdl[i],v[i]);
    }
    for(i=n-1;i>=0;i--)
    {
        gdr[i]=__gcd(gdr[i+1],v[i]);
    }
    e=0;
    rep(i,0,n)
    {
        b=gdl[i];
        c=gdr[i+1];
        k=__gcd(b,c);
        if(e<k) e=k;
    }

cout<<e;
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    // cin>>t;
    while(t--){
        solve();
    }
    return 0;
}


Measured memory_bytes: 2560
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <bitset>
#include <iostream>
#include <deque>
#include <functional>
#include <iterator>
#include <limits>
#include <map>
#include <numeric>
#include <string>
#include <vector>
#include <vector>

using namespace std;

#define int long long

#define ALL(v) begin(v), end(v)
#define RALL(v) rbegin(v), rend(v)

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)

#define debug(x) cerr << #x << ": " << x << endl;

const int MOD = 1e9 + 7;

signed main(void)
{
  int n;
  int a;
  int b;
  cin >> n >> a >> b;

  cout << min(n * a, b) << endl;
  
}


Measured memory_bytes: 256
//B
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <string>
#include <vector>
#include <map>
#include <list>
#include <set>
#include <stack>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <cassert>
using namespace std;
#define LL long long
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483648
#define INT_MAX 2147483647
#define LL_MIN -9223372036854775808
#define LL_MAX 9223372036854775807
#define segment_size 65536
#define ROOP() while (true)

int main(){
    string S;
    cin >> S;
    if(S[0] != 'A'){
        cout << "WA" << endl;
        return 0;
    }

    bool already = false;
    for(int i=2; i<S.size()-1; i++){
        if(S[i] == 'C'){
            if(already){
                cout << "WA" << endl;
                return 0;
            }
            already = true;
        }
    }
    if(already == false){
        cout << "WA" << endl;
        return 0;
    }

    int c = 0;
    string s = "abcdefghijklmnopqrstuvwxyz";
    for(int i=0; i<S.size(); i++){
        for(int j=0; j<s.size(); j++){
            if(S[i] == s[j]){
                c++;
                break;
            }
        }
    }

    if(c+2 != S.size()){
        cout << "WA" << endl;
        return 0;
    }

    cout << "AC" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <utility>
#include <iostream>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <vector>
#include <algorithm>

using namespace std;

int main(int argc, char const *argv[]) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  std::cin >> n;
  std::vector<int> v;
  int a;

  for (size_t i = 0; i < n; i++) {
    std::cin >> a;
    v.push_back(a);
  }

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

  int max = v.back();


  int dist = 2147483647;

  int sec;
  for (size_t i = 0; i < n; i++) {
    if(abs(v[i]-max/2)<=dist && v[i]!=max){
      dist = abs(v[i]-max/2);
      sec = v[i];
    }
  }

  std::cout << max << " " << sec << '\n';

  return 0;
}


Measured memory_bytes: 892
<?php
//error_reporting(0);
$N = trim(fgets(STDIN));
//list($A,$B) = explode(" ",trim(fgets(STDIN)));
//$a = explode(" ",trim(fgets(STDIN)));
//$b = explode(" ",trim(fgets(STDIN)));

$a = array(111,222,333,444,555,666,777,888,999);
foreach($a as $v) {
  if ($N<=$v) {
    printf("%d\n",$v);
    exit;
  }
}


Measured memory_bytes: 3700
#include<stdio.h>

int main(void){
  int N;
  scanf("%d",&N);
  
  int a=0,w=0,t=0,r=0;
  char s[5];
  for(int i=0;i<N;i++){
    scanf("%s",s);
    if(s[0]=='A'){
      a++;
    }
    if(s[0]=='W'){
      w++;
    }
    if(s[0]=='T'){
      t++;
    }
    if(s[0]=='R'){
      r++;
    }
  }
  printf("AC x %d\n",a);
  printf("WA x %d\n",w);
  printf("TLE x %d\n",t);
  printf("RE x %d\n",r);
 return 0;
}

Measured memory_bytes: 1736
/**
 *   author: malviyanshiv
 *   created: 10 August 2019  17:37:15
**/

#include <bits/stdc++.h>

using namespace std;

#define REP(i, a, b) for(int i = a; i < b; i++)
#define RREP(i, a, b) for(int i = a-1; i >= b; i--)
#define FORE(a) for(auto ele : a )
#define ALL(a) begin(a), end(a)
#define RPB(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))

#define PB push_back
#define MP make_pair
#define MOD 1000000007
#define INF 0x7fffffff
#define LINF 2000000000000000007
#define F first
#define S second
#define TC int t; cin >> t; while(t--)
#define SET(a,b) memset(a,b,sizeof(a))

#define TRACE

#ifdef TRACE
#define trace1(x)                cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;

#else

#define trace1(x)
#define trace2(x, y)
#define trace3(x, y, z)
#define trace4(a, b, c, d)
#define trace5(a, b, c, d, e)
#define trace6(a, b, c, d, e, f)

#endif

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


void optimizeIO(){
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
}

int main(){
    optimizeIO();

    int n;
    cin >> n;
    string s;
    map<string, int> mp;
    REP(i, 0, n){
        cin >> s;
        sort(s.begin(), s.end());
        mp[s]++;
    }
    ll res = 0;
    for(auto ech : mp){
        ll tp = ech.S;
        res += (tp*(tp-1))/2;
    }

    cout << res << endl;
    
    return 0;
}

Measured memory_bytes: 11264
n,m=map(int,input().split())
#二次元リストに電灯と接続スイッチを入力
data = [] 
for i in range (m) :
  a=list(map(int,input().split()))
  a=a[1:]
  data.append(a)
#modはP系統を全部入力したリスト、要素数ｍ
mod = list(map(int,input().split()))
#ここからビット全探索開始
ans=0
for i in range (2**n):
  checker=0 #点灯する電球の数
  switch=[]#このパターンでONのスイッチ
  for j in range (n):
    if (i>>j)&1:
      switch.append(j+1)
  for x in range(m) :#各電球に対してチェック
    cnt=0 #オンになってる接続スイッチ数
    for k in switch:#switch内全要素探索
      if data[x].count(k)!=0:
        cnt+=1
    if cnt%2==mod[x]:
      checker+=1
  if checker == m:
    ans+=1
    
print(ans)

Measured memory_bytes: 3064
N,X,D=map(int,input().split())
from collections import defaultdict as d
r=N*(X!=0)+1
if D:
 f,c,r=d(int),d(int),0
 for x,y,z in sorted(((N-k)*k*j+~-k*k//2+k*X//D,j,k*X%D)for k in range(N+1) for j in[0,1]):
  r+=(x-f[z]+1)*(c[z]<2)*y
  f[z]=x if(c[z]+y<1)else f[z]
  c[z]-=2*y-1
print(r)

Measured memory_bytes: 128344
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
a = LIST()

a.sort(reverse=True)
ans = 0
for i in range(N):
	if i%2 == 0:
		ans += a[i]
	else:
		ans -= a[i]

print(ans)

Measured memory_bytes: 5144
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<map>
#include<utility>
#include<functional>
#include<stack>
#include<queue>
#include<cmath>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef std::pair<int, int> int_pair;
using namespace std;
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }


int main() {

	int a = 0, b = 0,k = 0,Min = 0;
	vector<int> cds;
	cin >> a >> b >> k;

	Min = min(a, b);

	for (int i = 1; i <= Min; i++) {
	
		if (a % i == 0 && b % i == 0) {
	
			cds.push_back(i);
		}
	}

	sort(cds.begin(), cds.end(),greater<int>());

	cout << cds[k - 1] << endl;

}


Measured memory_bytes: 256
package main

import (
	f "fmt"
)

func sum(x int) int {
	if x == 0 {
		return 0
	}
	return sum(x/10) + x%10
}

func main() {

	var x, a, b int
	f.Scan(&x, &a, &b)

	res := 0

	for i := 1; i <= x; i++ {
		ans := sum(i)
		if a <= ans && ans <= b {
			res += i
		}
	}

	f.Println(res)

}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define Ans(f, y, n) if(f) cout << y << endl; else cout << n << endl;
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) cout << #v << "=" << endl; REP(i, v.size()){ cout << v[i] << ","; } cout << endl;
#define mdebug(m) cout << #m << "=" << endl; REP(i, m.size()){ REP(j, m[i].size()){ cout << m[i][j] << ","; } cout << endl;}
#define pb push_back
#define int long long
#define INF 1000000000000000000

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;
using pairs = vector<Pii>;

template<typename T> void readv(vector<T> &a){ REP(i, a.size()) cin >> a[i]; }
void readv_m1(vector<int> &a){ REP(i, a.size()){cin >> a[i]; a[i]--;} }

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

int mod = 1000000007;
//int mod = 998244353;
#define Add(x, y) x = (x + (y)) % mod
#define Mult(x, y) x = (x * (y)) % mod
#define AddMult(x, y, z) x = (x + (y) * (z)) % mod



signed main(){

    int N; cin >> N;
    vec A(N); readv(A);
    int ans = 1, m = 1;
    REP(i, N){
        ans *= 3;
        if(A[i] % 2 == 0) m *= 2;
    }
    cout << ans - m << endl;

    return 0;
}


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

typedef unsigned long long ll;

int main()
{
    ll N;
    cin >> N;
    ll t = N - 1;
    if (N == 2)
    {
        cout << 1 << endl;
    }
    else if (N == 1)
    {
        cout << 0 << endl;
    }
    else
    {
        cout << (t) * (t + 1) / 2 << endl;
    }
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
#include<set>
#include<vector>
#include<sstream>
#include<queue>
#include <iomanip>
#include <fstream>
#include<unordered_set>
#include<stack>
#include <map>
#include<unordered_map>
#include<time.h>
#include <chrono>
constexpr auto INF = 9223372036854775807;
typedef long long int ll;
typedef unsigned long long int ull;
typedef unsigned long int ul;
#define f(i,a,b) for(ll i=(ll)a;i<(ll)b;i+=1)
#define rf(i,a,b) for(ll i=(ll)a;i>=(ll)b;i-=1)
#define endl '\n'
#define N 1000000007 // prime modulo value 
#define all(x) x.begin(),x.end()
using namespace std;
#define MAX 1000001 
#define M 998244353
ll inverse(ll n)
{
	ll modu = M;
	ll m = modu;
	ll a = 0, b = 1;
	if (modu == 1)
		return 0;
	while (n > 1)
	{
		ll quo = n / modu;
		ll temp = modu;
		modu = n % modu, n = temp;
		temp = a; 
		a = b - (quo * a);
		b = temp;
	}
	if (b < 0)
		b += m;
	return b;
}
int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	ll n;
	cin >> n;
	unordered_map<string, ll> mp;
	set<string> st;
	ll maxi = 0;
	f(i, 0, n)
	{
		string s;
		cin >> s;
		st.insert(s);
		if (mp.find(s) == mp.end())
		{
			mp[s] = 1;
			if (mp[s] > maxi)
				maxi = mp[s];
		}
		else
		{
			mp[s] += 1;
			if (mp[s] > maxi)
				maxi = mp[s];
		}
	}
	for (auto i = st.begin(); i != st.end(); i++)
	{
		if (mp[*i] == maxi)
			cout << *i << endl;
	}
	return 0;
}


Measured memory_bytes: 32072
//qiita.com/wakimiko/items/69b86627bea0e8fe29d5
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

#define MAX_V 1000
#define INF 100000000

struct edge {
    int from; //出発点
    int to;   //到達点
    int cost; //移動コスト
};

int main()
{
    int V; //頂点の数
    int side; //辺の数
    int S; //始点
    int G; //終点
    int d[MAX_V]; //始点からそこまで行くのにかかるコスト
    vector<edge> edges; //移動の情報を保存する

    cin >> V;
    cin >> side;
    cin >> S;

    fill(d, d+V, INF); //すべての頂点をINFにする
    d[S] = 0; //始点を0にする

    for (int i = 0; i < side; i++) {
        struct edge add;
        cin >> add.from;
        cin >> add.to;
        cin >> add.cost;
        edges.push_back(add);
    }

    bool negative_cycle=0;

    for (int i = 0; i < V; i++) {
        for (int j = 0; j < (int)edges.size(); j++) {

            struct edge e = edges[j];

            if ((d[e.to] > d[e.from] + e.cost)&&(d[e.from]<INF)) {  //移動した後のコストが小さいと、頂点のコストを更新
                d[e.to] = d[e.from] + e.cost;
                if (i == V-1) {         //頂点の数と同じ回数ループすると、負の閉路があるのでループをぬける
                    negative_cycle=1;
                    break;
                } 
            }
        }
    }

    if(negative_cycle==0){
        for(int i=0; i<V; i++){
            if(d[i]<INF){
                cout << d[i] << endl;
            }else{
                cout << "INF" << endl;
            }
        }
    }else{
        cout << "NEGATIVE CYCLE" << endl;
    }
    return 0;
}



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

typedef long long ll;
typedef vector<long long> vecll;
typedef vector<string> vecstr;

#define rep0(i, n) for(ll i=0; i<(ll)(n); i++)
#define rep1(i, n) for(ll i=1; i<=(ll)(n); i++)
#define rep(i, a, b) for(ll i=(ll)a; i<=(ll)(b); i++)
#define rep0r(i, n) for(ll i=(ll)(n)-1; i>=0; i--)
#define rep1r(i, n) for(ll i=(ll)(n); i>0; i--)
#define repr(i, a, b) for(ll i=(ll)b; i>=(ll)(a); i--)
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) a * b / __gcd(a, b)
#define len(x) x.size()
#define Sort(x) sort(x.begin(), x.end())
#define rSort(x) sort(x.begin(), x.end(), greater<ll>())

const ll mod_const = 1000000007;

ll modpow(ll a, ll n, ll m) {
    ll result = 1;
    while(n > 0) {
        if(n&1) {
            result = result * a % m;
        }

    a = a * a % m;
    n >>= 1;
    }

    return result;
}

ll modinv(ll a, ll n) {
    if(a <= 1) {
        return 1;
    } else {
        return  n - modinv(n%a, n) * (n/a) % n;
    }
}

ll comb(ll n, ll r, ll m = mod_const) {
    vecll fac = {1, 1};
    vecll inv ={1, 1};
    vecll facinv = {1 , 1};

    rep(i, 2, n) {
        fac.push_back(fac[i-1] * i % m);
        inv.push_back(modinv(i, m));
        facinv.push_back(facinv[i-1] * inv[i] % m);
    }

    if (n<r || n<0 || r<0) {
        return 0;
    } else {
        return fac[n] * (facinv[r] * facinv[n-r] % m) % m;
    }
}
void solve() {
    ll k, a, b;
    cin >> k >> a >> b;

    ll p;
    bool flag = false;
    rep1(i, 1000) {
        p = k * i;

        if(a<=p && p<=b) {
            flag = true;
        }
    }

    if(flag) {
        cout << "OK" << endl;
    } else {
        cout << "NG" << endl;
    }

}

signed main() {
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    solve();
    return 0;
}

Measured memory_bytes: 3656
while True:
    a,calc,b= input().split()
    a=int(a)
    b=int(b)
    if calc=='?':
        break
    elif calc=='+':
        print(a+b)
    elif calc=='-':
        print(a-b)
    elif calc=='*':
        print(a*b)
    elif calc=='/':
        print((int)(a/b))


Measured memory_bytes: 5596
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(ll i = n;i >= 0;--i)
#define FOR(i,m,n) for(ll i = m, i##_len=(n);i <i##_len; ++i)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
const int INF = 1e9;
const ll LLINF = 1e16;
 
ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}


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

    if(n == 1 && m == 1){
        cout << 1 << endl;
    }
    else if(n == 1){
        cout << m - 2 << endl;
    }
    else if( m== 1){
        cout << n - 2 << endl;
    }
    else{
        cout << max(0ll,n*m - (2 * n + (m - 2) * 2)) << endl;
    }


    return 0;
}

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

#define N 500000
void marge(int *,int ,int ,int );
void margeSort(int *,int ,int );

int left,right,mid,cnt=0;

int main()
{
  int n,x,S[N];

  scanf("%d",&n);
  for(x=0;x<n;x++)
    {
      scanf("%d",&S[x]);
    }
  margeSort(S,0,n);

  for(x=0;x<n;x++)
    {
      if(x>0)printf(" ");
      printf("%d",S[x]);
    }
  printf("\n%d\n",cnt);
  return 0;
}



void marge(int S[],int left,int mid,int right)
{
  int i,j,k,n1,n2;
  int L[N/2+2],R[N/2+2];
  
  n1=mid-left;
  n2=right-mid;

  //L[0...n1],R[0...n2]を作成
  for(i=0;i<n1;i++)
    {
      L[i]=S[left+i];
    }
  for(i=0;i<n2;i++)
    {
      R[i]=S[mid+i];
    }
  L[n1]=1000000001;
  R[n2]=1000000001;
  i=0;
  j=0;

  for(k=left;k<right;k++)
    {
      cnt++;
      if(L[i]<=R[j])
	{
	  S[k]=L[i];
	  i=i+1;
	}
      
      else
	{
	  S[k]=R[j];
	  j=j+1;
	}
	    
    }
}

void margeSort(int S[],int left,int right)
{
  int mid;
  if(left+1<right)
    {
      mid=(left+right)/2;
      margeSort(S,left,mid);
      margeSort(S,mid,right);
      marge(S,left,mid,right);
    }
}



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

ll N;

vector<vector<ll>> dp1(2003, vector<ll>(2003, INF));
vector<vector<ll>> dp2(2003, vector<ll>(2003, INF));
vector<ll> A(2003,0);

//1ならX

ll F(ll next,ll aite,ll ikou){
    if(next==1){
        if(dp1[aite][ikou]!=INF)return dp1[aite][ikou];
        if(ikou==N)return dp1[aite][ikou]=llabs(A[aite]-A[N]);
        return dp1[aite][ikou]=max(F(1,aite,ikou+1),F(2,ikou,ikou+1));
    }
    else if(next==2){
        if(dp2[aite][ikou]!=INF)return dp2[aite][ikou];
        if(ikou==N)return dp2[aite][ikou]=llabs(A[aite]-A[N]);
        return dp2[aite][ikou]=min(F(2,aite,ikou+1),F(1,ikou,ikou+1));
    }
}


int main(){
    cin >> N;
    ll Z;
    cin >> Z;
    ll W;
    cin >> W;
    A[0]=W;
    for(ll i=0;i<N;i++)cin>>A[i+1];

    print(F(1,0,1))

    return 0;
}


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

using namespace std;

#define sim template <class c
#define ris return *this
#define dor > debug &operator<<
#define eni(x)                                                                        \
	sim > typename enable_if<sizeof dud<c>(0) x 1, debug &>::type operator<<(c i) \
	{
sim > struct rge
{
	c b, e;
};
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c *x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug
{
#ifdef LOCAL
	~debug()
	{
		cerr << endl;
	}
	eni(!=) cerr << boolalpha << i;
	ris;
} eni(==) ris << range(begin(i), end(i));
}
sim, class b dor(pair<b, c> d)
{
	ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d)
{
	*this << "[";
	for (auto it = d.b; it != d.e; ++it)
		*this << ", " + 2 * (it == d.b) << *it;
	ris << "]";
}
#else
	sim dor(const c &)
	{
		ris;
	}
#endif
}
;
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

#define forn(i, n) for (ll i = 0; i < int(n); i++)
#define rfor(n, i) for (ll i = (n - 1); i >= 0; --i)
#define all(V) V.begin(), V.end()
#define rall(V) V.rbegin(), V.rend()
#define len(V) (int)V.size()
#define ll long long
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define endl '\n'
#define M_PI 3.14159265358979323846
#define EPS 1e-7

int cnt = 0;


void solve()
{
	int n, m; cin >> n >> m;
	vector<string> a(n);
	forn(i, n) 
	{
		cin >> a[i];
		cout << a[i] << endl << a[i] << endl;
	}
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	solve();
}


Measured memory_bytes: 3696
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<stack>
#include<climits>
#include<cstring>
#include<queue>
#include<map>
#include<functional>
using namespace std;

typedef unsigned long long ull;

int main(){
    int N;
    cin >> N;
    ull A, B;
    cin >> A >> B;
    vector<ull> Xs(N);
    for (int i=0;i<N;i++){
        cin >> Xs[i];
    }

    ull S = 0;
    for (int i=1;i<N;i++){
        S += min((Xs[i] - Xs[i-1])*A, B);
    }
    cout << S << endl;
    return 0;
}

Measured memory_bytes: 1024
N = int(input())
A = list(map(int, input().split()))

import collections

c = collections.Counter(A)

sum_all = sum([v * max(v - 1, 0) // 2 for k, v in c.items()])

ans = []
for a in A:
  b = c[a]
  ans_a = sum_all - (b * max(b - 1, 0) // 2) + (max(b - 1, 0) * max(b - 2, 0) // 2)
  ans.append(ans_a)
print(*ans, sep='\n')




Measured memory_bytes: 30620
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = (int)(n); i >= 0; i--)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

ll N, T, W, H, M, C, V;

const int MAX = 510000;
const int MOD = 1e9;

const double PI=3.14159265358979323846;

/*
long long fac[MAX], finv[MAX], inv[MAX];

vector<double> cx, cy, c;
 ll MM = 1e12;

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

std::vector<int> Eratosthenes(int n ){
    std::vector<bool> is_prime( n + 1 );
    for( int i = 0; i <= n; i++ ) is_prime[ i ] = true;
    std::vector<int> P;
    for( int i = 2; i <= n; i++ ){
        if( is_prime[ i ] ){
            for( int j = 2 * i; j <= n; j += i ){
                is_prime[ j ] = false;
            }
            P.emplace_back( i );
        }
    }
    return P;
}*/

int length(vector<int> v, int u, int HW){
    if(v.size() == 0) return HW;
    if(v[0] > u) return v[0];
    if(v[v.size() - 1] < u) return HW - v[v.size()- 1] -1;
    else{
        int i = lower_bound(ALL(v), u)- v.begin();
        return v[i] - v[i-1] -1;
    }
}

int main(){
    cin >> H >> W;
    vector<vector<int>> row(H);
    vector<vector<int>> col(W);
    vector<vector<int>> ok(H, vector<int> (W, 0));
    string str;
    REP(i, H){
        cin >> str;
        REP(j,W){
            if(str[j] == '#') { ok[i][j] = 1; row[i].push_back(j); col[j].push_back(i);}
        }
    }
    int ans = 0;

    REP(i, H){
        REP(j,W){
            if(ok[i][j]) continue;
            int cnd = length(row[i], j, W) + length(col[j], i, H);
            ans = max(ans, cnd-1);
            }
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 50048
#include <stdio.h>

void printArray(int var[], int num) {
  int i;
  for (i = 0; i < num; i++) {
      if (i > 0) printf(" ");
      printf("%d", var[i]);
  }
  printf("\n");
}

int selectionSort(int var[], int num) {
  int i, j, iMin, tmp;
  int counter = 0;
  for (i = 0; i < num; i++) {
    iMin = i;

    for (j = i; j < num; j++) {
      if (var[j] < var[iMin]) {
        iMin = j;
      }
    }
    if (iMin != i) counter++;
    tmp = var[i];
    var[i] = var[iMin];
    var[iMin] = tmp;
  }
  return counter;
}

int main(void) {
  int i, num, counter;
  scanf("%d", &num);
  int var[num];
  for (i = 0; i < num; i++) scanf("%d", &var[i]);

  counter = selectionSort(var, num);
  printArray(var, num);
  printf("%d\n", counter);


  return 0;
}


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

using namespace std;

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

#define each(i,a) for (auto&& i : a)
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
#define pb push_back
#define all(a) (a).begin(),(a).end()
#define chmin(x,v) x = min(x, v)
#define chmax(x,v) x = max(x, v)

const ll linf = 1e18;
const double eps = 1e-12;
const double pi = acos(-1);

template<typename T>
istream& operator>>(istream& is, vector<T>& vec) {
    each(x,vec) is >> x;
    return is;
}
template<typename T>
ostream& operator<<(ostream& os, const vector<T>& vec) {
    rep(i,vec.size()) {
        if (i) os << " ";
        os << vec[i];
    }
    return os;
}
template<typename T>
ostream& operator<<(ostream& os, const vector< vector<T> >& vec) {
    rep(i,vec.size()) {
        if (i) os << endl;
        os << vec[i];
    }
    return os;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll h;
    const ll w = 5;
    while (cin >> h, h) {
        vector<vector<ll>> m(h, vector<ll>(w)); cin >> m;
        reverse(all(m));
        ll ans = 0;
        function<ll(ll,ll,ll,ll)> chain = [&](ll x, ll y, ll k, ll cnt) {
            if (k < 0 || x >= w || m[y][x] != k) return cnt;
            ll c = chain(x+1, y, k, cnt+1);
            if (c >= 3) {
                ans += m[y][x];
                m[y][x] = -1;
            }
            return c;
        };
        auto fall = [&]() {
            rep(y, h-1) rep(x, w) {
                if (m[y][x] < 0) {
                    m[y][x] = m[y+1][x];
                    m[y+1][x] = -1;
                }
            }
        };
        while (true) {
            bool is_updated = false;
            rep(y, h) rep(x, w) {
                if (chain(x, y, m[y][x], 0) >= 3) {
                    is_updated = true;
                }
            }
            if (!is_updated) break;
            rep(i, h) fall();
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 3172
#include <cstdio>
#include <algorithm>
using namespace std;
#define INF (1<<27)
int cost[100][100];
int main() {
	int n,m,s,g1,g2;
	while(scanf("%d %d",&n,&m),n) {
		scanf("%d %d %d",&s,&g1,&g2);s--;g1--;g2--;
		for(int i=0;i<n;i++)
			for(int j=0;j<n;j++)
				cost[i][j]=cost[j][i]=(i==j)?0:INF;
		for(int i=0;i<m;i++) {
			int a,b,c;
			scanf("%d %d %d",&a,&b,&c);
			cost[a-1][b-1]=c;
		}
		for(int k=0;k<n;k++)
			for(int i=0;i<n;i++)
				for(int j=0;j<n;j++)
					cost[i][j]=min(cost[i][j],cost[i][k]+cost[k][j]);
		int ans=1<<30;
		for(int k=0;k<n;k++)
			ans=min(ans,cost[s][k]+cost[k][g1]+cost[k][g2]);
		printf("%d\n",ans);
	}
}

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

public class Main {

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

      int n = Integer.parseInt(br.readLine());
      String[] line;
      MyList list = new MyList();

      for(int i=0; i<n; i++) {
        line = br.readLine().split(" ");
        switch( line[0] ) {
          case "insert" :
            list.insertFirst( Integer.parseInt(line[1]) );
            break;
          case "deleteFirst" :
            list.deleteFirst();
            break;
          case "deleteLast" :
            list.deleteLast();
            break;
            case "delete" :
              list.delete( Integer.parseInt(line[1]) );
              break;
          default :
            System.out.println("n:" + i + " is failed.");
        }
      }

      System.out.println ( list.getAllElements() );
    }
  }
}

class Node {
  Node next,prev;
  int key;

  public Node(int key) {
    this.key = key;
  }
}

class MyList {
  Node nil;
  Node current;
  int size;

  public MyList() {
    nil = new Node(0);
    nil.next = nil.prev = nil;
    size = 0;
  }

  public String getAllElements() {
    StringBuilder buf = new StringBuilder(size*2);

    if(size > 0){
      current = nil.next;
      for(int i=0; i<size; i++){
        buf.append(current.key).append(" ");
        current = current.next;
      }
    }
    buf.setLength(buf.length()-1);

    return buf.toString();
  }
  public void insertFirst(int x) {
    if(size == 0) {
      current = new Node(x);
      nil.next = current;
      nil.prev = current;
      current.prev = nil;
      current.next = nil;
      size++;
    }
    else {
      Node add = new Node(x);
      
      current.prev.next = add;
      add.prev = current.prev;

      add.next = current;
      current.prev = add;

      current = add;
      size++;
    }
  }
  public void deleteFirst() {
    nil.next = current.next;
    current.next.prev = current.prev;

    current = current.next;
    size--;
  }
  public void deleteLast() {
    current = nil.prev;

    nil.prev = current.prev;
    current.prev.next = current.next;

    current = nil.next;
    size--;
  }
  public void delete(int x) {
    Node target = findFirst(x);

    if(target == nil) current = current.next;
    else {
      current.prev.next = target.next;
      current.next.prev = target.prev;
      current = nil.next;
      size--;
    }
  }
  private Node findFirst(int x) {
    while(current != nil) {
      if(current.key == x) break;
      current = current.next;
    }

    return current;
  }
}


Measured memory_bytes: 190020
/*																													   
 Templatka c++ Kacper Fis																							   																											   //
*/																													  
																								   
#include <bits/stdc++.h>																							   
																													   
using namespace std; 																								   
		
const double eps = 1e-9;																							   
const int INF = 1000000001;																						   
const float PI = 3.14;																								   
typedef long long LL;																								   
																													   
typedef vector<int> vi;																								   
typedef list<int> li;																								   
typedef queue<int> qi; 																								   
typedef pair<int,int> ii; 																							   
typedef map<string,int> msi; //np msi['nazwa'] = 'liczba'															   
typedef vector<ii> vii; //vector par<int>, do tworzenia tablicy dla grafów wagowych #dijkstra #Bellman_Ford			   
typedef priority_queue< ii, vector<ii>, greater<ii> > pq; //kolejka priorytetowa vectorów par(top()=min) #dijkstra	   
																													   																				   
vector<ii>::iterator iter;																							   
																													   																				   
#define print_list(x) for(it = (x).begin(); it != (x).end(); it++) {cout << *it << " ";}							   
#define print_vector(x) for(it2 = (x).begin(); it2 != (x).end(); it2++) {cout << *it2 << " ";}						   
#define search_list(x) for(it = (x).begin(); it != (x).end(); it++)													   
#define search_vector(x) for(it2 = (x).begin(); it2 != (x).end(); it2++);											   
#define pb(x) push_back(x) 																							   
#define pf(x) push_front(x)																							   
#define mp(x, y) make_pair(x, y)                                                                                       
///////////////////////////////////////////////GLOBAL DEFINITIONS////////////////////////////////////////////////////////


///////////////////////////////////////////////////FUNCTIONS/////////////////////////////////////////////////////////////


/////////////////////////////////////////////////////MAIN////////////////////////////////////////////////////////////////
int main()																					 
{ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);                  												       
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	
	int r;
	cin >> r;
	cout << 2 * M_PI * r << endl;
	
	
	
	
	
	

	
	return 0;
 }


Measured memory_bytes: 3792
<?php

(new Main)->excute();

class Main
{
    public function excute()
    {
        while (true) {
            fscanf(STDIN, '%d %d', $height, $width);
            if ($height == 0 && $width == 0) { break; }
            
            $chessBoard = (new ChessBoard($height, $width, '#', '.'))->make();
            Self::draw($chessBoard);
        }
    }
    
    public static function draw($object)
    {
        echo $object, PHP_EOL;
    }
}


class ChessBoard
{
    private $height;
    private $width;
    private $char1;
    private $char2;
    
    
    public function __construct($height, $width, $char1, $char2)
    {
        $this->height = $height;
        $this->width  = $width;
        $this->char1  = $char1;
        $this->char2  = $char2;
    }
    
    public function make()
    {
        $chessBoard = [];
        for ($i = 0; $i < $this->height; $i++) {
            if ($i % 2 == 0) {
                $chessBoard[] = $this->makeLine($this->char1, $this->char2);
            } else {
                $chessBoard[] = $this->makeLine($this->char2, $this->char1);
            }
        }
        
        return implode(PHP_EOL, $chessBoard).PHP_EOL;
    }
    
    private function makeLine($firstChar, $secondChar)
    {
        $line = '';
        for ($i = 0; $i < $this->width; $i++) {
            if ($i % 2 == 0) {
                $line .= $firstChar;
            } else {
                $line .= $secondChar;
            }
        }
        
        return $line;
    }
}

Measured memory_bytes: 15464
// #include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <tuple>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repd(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
#define repdm(i, a, b) for (ll i = (ll)(a); i > (ll)(b); i--)
const ll INF = 1LL << 60;

int main()
{

  ll N, A, B, C, D, E;
  cin >> N >> A >> B >> C >> D >> E;

  ll M = min({A, B, C, D, E});

  cout << ((N + (M - 1)) / M) + 4 << endl;
}

Measured memory_bytes: 256
n = int(input())
col = [0] * 9
a = list(map(int, input().split()))
mi = 0
for i in a:
    if i < 400:
        col[0] += 1
    elif i < 800:
        col[1] += 1
    elif i < 1200:
        col[2] += 1
    elif i < 1600:
        col[3] += 1
    elif i < 2000:
        col[4] += 1
    elif i < 2400:
        col[5] += 1
    elif i < 2800:
        col[6] += 1
    elif i < 3200:
        col[7] += 1
    else:
        col[8] += 1
for h in col[:-1]:
    mi += 1 if h else 0
print(max(mi, 1), mi + col[-1])

Measured memory_bytes: 3064
import fractions
n = int(input())
a = list(map(int,input().split()))
a.sort()
if n==1:
    print(*a)
else:
    s = a[0]
    for i in range(1,n):
        s = s * a[i] / fractions.gcd(s, a[i])
    ans = 0
    for i in a:
        ans += s/i
    print(s/ans)

Measured memory_bytes: 5048
#include<iostream>
#include<cstdio>
using namespace std;
#define MAX 100000

int parent(int i) { return i / 2; }
int left(int i) { return 2 * i; }
int right(int i) { return 2 * i + 1; }

int main() {
	int H, i, A[MAX + 1];

	scanf("%d", &H);
	for (i = 1; i <= H; i++) {
		scanf("%d", &A[i]);
	}

	for (i = 1; i <= H; i++) {
		printf("node %d: ", i);
		printf("key = %d, ", A[i]);
		if (parent(i) >= 1) {
			printf("parent key = %d, ", A[parent(i)]);
		}
		if (left(i) <= H) {
			printf("left key = %d, ", A[left(i)]);
		}
		if (right(i) <= H) {
			printf("right key = %d, ", A[right(i)]);
		}
		printf("\n");

	}

	return 0;
}


Measured memory_bytes: 3176
#include<bits/stdc++.h>
using namespace std;
#define vi vector<int>
#define sl set<ll>
#define vs vector<string>
#define vl vector<ll>
#define vi vector<int>
#define vpl vector<pair<ll,ll>>
#define pb push_back
#define PI 3.14159265358979323846
#define ll long long
#define ld long double
#define endl "\n"
#define rep(i,a,b) for (ll i = (a); i < (b); i++)
#define repp(i,a,b) for (ll i = (a); i >= (b); i--)
#define rop(i,a,b)  for(ll i=(a); i>(b); i--)
#define min3(a, b, c) min(c, min(a, b))
#define min4(a, b, c, d) min(d, min(c, min(a, b)))
#define tt long long t; cin>>t; while(t--)
#define IOS ios::sync_with_stdio(0);cin.tie(0);
const int maxn=1e5+100;


int main()
{
char x;
  ll ans=0;
  while(cin>>x)
  { ans+=x-'0';
    if(ans%9==0) ans=0;
  }
  if(ans%9) cout<<"No"<<endl;
  else cout<<"Yes"<<endl;
}

Measured memory_bytes: 3596
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
using namespace std;
#define debug(x) std::cerr << #x << " = " << (x) << std::endl
typedef long long LL;
const int MAXN = 2e5+17;
char mp[100][100];
int main(int argc ,char const *argv[])
{
    #ifdef noob
    freopen("Input.txt","r",stdin);freopen("Output.txt","w",stdout);
    #endif  
    int n,m;
    cin>>n>>m;
    int dap = 0;
    int k1 = ceil(1.0*n/50),k2;
    if(n>1) m-=1;
    k2 = k2=ceil(1.0*m/50);
    if(m>0) n--;
    k1 = ceil(1.0*n/50);
    while(k1--) 
    {
        n-=50;
        for (int i = 0; i < 100; ++i)
        {
            for (int j = 0; j < 3; ++j)
            {
                int tj= j+dap*3;
                if(((tj-1)%3==0)&&i&1) mp[i][tj]='.';
                else mp[i][tj]='#';
            }
        }
        if(n<0)
        {
            int tms = -1*n;
            for (int i = 0; i < 100; ++i)
            {
                for (int j = 0; j < 3; ++j)
                {
                    int tj=j+dap*3;
                    if(mp[i][tj]=='.'&&tms>0) 
                    {
                        mp[i][tj] = '#'; 
                        tms--;
                    }
                }
            }
            dap++;
            break;
        }
        dap++;
    }
    while(k2--) 
    {
        m-=50;
        for (int i = 0; i < 100; ++i)
        {
            for (int j = 0; j < 3; ++j)
            {
                int tj= j+dap*3;
                if(((tj-1)%3==0)&&i&1) mp[i][tj]='#';
                else mp[i][tj]='.';
            }
        }
        if(m<0)
        {
            int tms = -1*m;
            for (int i = 0; i < 100; ++i)
            {
                for (int j = 0; j < 3; ++j)
                {
                    int tj=j+dap*3;
                    if(mp[i][tj]=='#'&&tms>0) 
                    {
                        mp[i][tj] = '.'; 
                        tms--;
                    }
                }
            }
            dap++;
            break;
        }
        dap++;
    }
    cout<<100<<" "<<dap*3<<endl;
    for (int i = 0; i < 100; ++i)
        cout<<mp[i]<<endl;
    return 0;   
}

Measured memory_bytes: 256
#include <cstdio>

int A, B;

int main() {
	scanf("%d%d", &A, &B);
	if (A <= 0 && B >= 0) puts("Zero");
	else if (A > 0 || (B - A) & 1) puts("Positive");
	else puts("Negative");
	return 0;
}

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    int* a;
    a = new int[3 * N];
    priority_queue<int, vector<int>, greater<int> > leftque;
    priority_queue<int> rightque;
    long long *leftsum, *rightsum, ans = -1e18;
    leftsum = new long long[3 * N];
    rightsum = new long long[3 * N];
    for (int i = 0; i < 3 * N; ++i) {
        cin >> a[i];
        if (i < N) {
            leftque.push(a[i]);
            leftsum[N - 1] += a[i];
        } else if (i >= 2 * N) {
            rightque.push(a[i]);
            rightsum[2 * N] += a[i];
        }
    }
    for (int i = N; i <= 2 * N; ++i) {
        leftque.push(a[i]);
        int res = leftque.top();
        leftque.pop();
        leftsum[i] = leftsum[i - 1] - res + a[i];
    }
    for (int i = 2 * N - 1; i >= N - 1; --i) {
        rightque.push(a[i]);
        int res = rightque.top();
        rightque.pop();
        rightsum[i] = rightsum[i + 1] - res + a[i];
    }
    for (int i = N - 1; i < 2 * N; ++i) {
        ans = max(ans, leftsum[i] - rightsum[i + 1]);
    }
    cout << ans << endl;
    delete[] a;
    delete[] leftsum;
    delete[] rightsum;

    return 0;
}

Measured memory_bytes: 5240