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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int main(){
  int h,w;
  cin>>h>>w;
  vector<string> s(h);
  REP(i,h)cin>>s[i];
  const int INF = 252521;
  vector<vi> dp(h,vi(w,INF));
  dp[0][0] = 0;
  queue<pii> Q;
  Q.push(pii(0,0));
  int dx[] = {1,0,-1,0};
  int dy[] = {0,1,0,-1};
  while(Q.size()){
    pii P = Q.front(); Q.pop();
    int i = P.first; int j = P.second;
    REP(d,4){
      int ni = i + dx[d];
      int nj = j + dy[d];
      if(ni<0 || nj<0 || ni>=h || nj>=w)continue;
      if(s[ni][nj]=='#')continue;
      if(dp[ni][nj] <= dp[i][j]+1)continue;
      dp[ni][nj] = dp[i][j]+1;
      Q.push(pii(ni,nj));
    }
  }
  int a = dp[h-1][w-1];
  if(a == INF){
    puts("-1");return 0;
  }
  int ans = h*w - (a+1);
  REP(i,h)ans -= count(ALL(s[i]),'#');
  cout<<ans<<endl;
  return 0;
}


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

struct score {
    ll a;
    ll b;
    ll c;
    ll d;
};

ll dfs(ll depth, ll num, vector<ll>& A, ll N, ll M, const vector<score>& scores)
{
    A[depth] = num;

    if (depth == N) {
        ll ans = 0;
        for (auto&& s : scores) {
            if (A[s.b] - A[s.a] == s.c) {
                ans += s.d;
            }
        }
        return ans;
    }

    ll ans = 0;
    for (ll i = num; i <= M; i++) {
        ans = max(ans, dfs(depth + 1, i, A, N, M, scores));
    }
    return ans;
}

void solve(long long N, long long M, long long Q, std::vector<long long> a, std::vector<long long> b, std::vector<long long> c, std::vector<long long> d)
{
    vector<score> scores;
    for (ll i = 0; i < Q; i++) {
        scores.push_back({ a[i], b[i], c[i], d[i] });
    }

    vector<ll> A(N + 1);
    ll ans = dfs(1, 1, A, N, M, scores);

    cout << ans << endl;
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
// clang-format off
int main(){
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    long long Q;
    scanf("%lld",&Q);
    std::vector<long long> a(Q);
    std::vector<long long> b(Q);
    std::vector<long long> c(Q);
    std::vector<long long> d(Q);
    for(int i = 0 ; i < Q ; i++){
        scanf("%lld",&a[i]);
        scanf("%lld",&b[i]);
        scanf("%lld",&c[i]);
        scanf("%lld",&d[i]);
    }
    solve(N, M, Q, std::move(a), std::move(b), std::move(c), std::move(d));
    return 0;
}


Measured memory_bytes: 3672
#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define irep(i,a,b) for(ll i=ll(a);i>=ll(b);i--)
using ll = long long;
using namespace std;


int main(){
	ll n,m;
	cin>>n>>m;
    ll a[n];
    rep(i,0,n)cin>>a[i];
    ll ans=0;
    ll st[n+1];
    st[0]=0;
    rep(i,1,n+1){
        st[i]=st[i-1]+a[i-1];
        st[i]%=m;
    }
    ll k=0;
    vector <ll> b;
    sort(st,st+n+1);
    rep(i,0,n) {
        if(st[i]==st[i+1])k++;
        else {b.push_back(k+1);k=0;continue;}
    }
    b.push_back(k+1);
    rep(i,0,b.size())ans+=b[i]*(b[i]-1)/2;
    cout<<ans<<endl;
    //rep(i,0,n+1)cout<<st[i]<<" ";
}

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

int main() {
  int A, B, X;
  cin >> A >> B >> X;
  if (A <= X){
    if (A + B >= X){
      cout << "YES" << endl;
    }
    else {
      cout << "NO"  << endl;
    }
  }
  else {
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 256
x,y = gets.split.map(&:to_i)
z = 0
if x == 1
  z += 300000
elsif x == 2
  z += 200000
elsif x == 3
  z += 100000
end

if y == 1
  z += 300000
elsif y == 2
  z += 200000
elsif y == 3
  z += 100000
end

if x == 1 && y == 1
  z += 400000
end

puts z

Measured memory_bytes: 1788
N, X = map(int, input().split(" "))
size = [1]
full_pt = [1]
for i in range(1, N + 1):
    size.append(2 * size[-1] + 3)
    full_pt.append(2 * full_pt[-1] + 1)


def calc(L, X):
    # level Lバーガーを下からX個食べるときの食べるパティ数
    if X <= 0:
        return 0
    elif L == 0:
        return X

    if X <= size[L - 1] + 1:
        # pan + L-1まで
        return calc(L - 1, X - 1)
    elif X < 2 * size[L - 1] + 2:
        # pan + L-1 + patie + L-1の途中まで
        return full_pt[L - 1] + 1 + calc(L - 1, X - 2 - size[L - 1])
    else:
        return full_pt[L]

print(calc(N, X))

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

ans = 'APPROVED'
for i in range(N):
    a = A[i]
    if a % 2 == 1:
        continue
    
    if a % 6 != 0 and a % 10 != 0:
        ans = 'DENIED'

print(ans)
        

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

const int MOD=1000000007;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;

int main(){
	int n;cin>>n;n%=10;
	if(n==2||n==4||n==5||n==7||n==9)puts("hon");
	else if(n==3)puts("bon");
	else puts("pon");
}

Measured memory_bytes: 3624
import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string;

auto rdsp(){return readln.splitter;}
void pick(R,T)(ref R r,ref T t){t=r.front.to!T;r.popFront;}
void readV(T...)(ref T t){auto r=rdsp;foreach(ref v;t)pick(r,v);}
void readA(T)(size_t n,ref T[]t){t=new T[](n);auto r=rdsp;foreach(ref v;t)pick(r,v);}

void main()
{
  int n; readV(n);
  int[] a; readA(n, a);

  foreach (i; 0..n) a[i] -= i+1;
  a.sort();

  auto b = n%2 == 1 ? a[n/2] : (a[n/2-1]+a[n/2])/2;
  auto r = 0L;
  foreach (i; 0..n) r += (a[i]-b).abs;

  writeln(r);
}


Measured memory_bytes: 6140
#include<iostream>
#include<cstring>
#include<queue>
using namespace std;
const int maxn=100005;
long long MAX[maxn],MIN[maxn],a[3*maxn];
int n;
int main(){
    cin>>n;
    priority_queue<int,vector<int>,greater<int> > q;
    for(int i=0;i<3*n;i++){
        cin>>a[i];
    }
    for(int i=0;i<n;i++){
        q.push(a[i]);MAX[0]+=a[i];
    }
    for(int i=n;i<2*n;i++){
        q.push(a[i]);
        MAX[i-n+1]=MAX[i-n]-q.top()+a[i];
        q.pop();
    }
    priority_queue<int> p;
    for(int i=3*n-1;i>2*n-1;i--){
        p.push(a[i]);MIN[n]+=a[i];
    }
    for(int i=2*n-1;i>=n;i--){
        p.push(a[i]);
        MIN[i-n]=MIN[i-n+1]-p.top()+a[i];
        p.pop();
    }
    for(int i=2*n-1;i>=n;i--){
        MIN[i-n]=MIN[i-n]<MIN[i-n+1]?MIN[i-n]:MIN[i-n+1];
    }
    long long ans=-(long long)(1<<31)*(1<<31);
    for(int i=0;i<=n;i++){
        long long ans0=MAX[i]-MIN[i];
        if(ans0>ans)ans=ans0;
    }
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 5112
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,(n)-1,0)
#define all(v) v.begin(), v.end()
#define endk '\n'
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ll mod2 = 998244353;
const ld eps = 1e-10;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b){if(a>b) a=b;}
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b){if(a<b) a=b;}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, k; ll s; cin >> n >> k >> s;
  if(s == (ll)1e9) {
    rep(i, k) cout << s << ' ';
    rep(i, n-k) cout << s-1 << ' ';
    cout << endk;
  } else {
    rep(i, k) cout << s << ' ';
    rep(i, n-k) cout << s+1 << ' ';
    cout << endk;
  }
  return 0;
}


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

long long dp[3001][3001];
long long rec(int i,int j,vector<int> &a){
    if(i>j){
        dp[i][j]=0;
    }
    else if(i==j){
        dp[i][j]=a[i];
    }
    else if(j-i==1){
        dp[i][j]=max(a[i],a[j]);
    }
    if(dp[i][j]!=-1){
        return dp[i][j];
    }
    long long x=a[i]+min(rec(i+2,j,a),rec(i+1,j-1,a));
    long long y=a[j]+min(rec(i,j-2,a),rec(i+1,j-1,a));
    dp[i][j]=max(x,y);
    return dp[i][j];
}
int main() {
    //code
    int n;
        cin>>n;
        for(int i=0;i<3001;i++){
            for(int j=0;j<3001;j++){
                dp[i][j]=-1;
            }
        }
        vector<int> a(n);
  long long sum=0;
        for(int i=0;i<n;i++){
            cin>>a[i];
          sum+=(long long)a[i];
        }
        
        long long ans=rec(0,n-1,a);
  ans=(long long)(2*ans-(long long)sum);
        cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 70784
h,w,d = map(int, input().split())
a=[list(map(int,input().split())) for i in range(h)]

q=int(input())
lr=[list(map(int,input().split())) for i in range(q)]

from collections import defaultdict
zahyo = defaultdict(list)
for i in range(h):
    for j in range(w):
        zahyo[a[i][j]-1] = [i,j]

rui=[0]*(h*w + 10)
for i in range(d,h*w):
    last=zahyo[i-d]
    now = zahyo[i]

    dist = abs(last[0]-now[0]) + abs(last[1]-now[1])
    rui[i] = rui[i-d] + dist

for que in lr:
    l,r=que
    print(rui[r-1]-rui[l-1])

Measured memory_bytes: 87516
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String line = br.readLine();
        char[] alpha = line.toCharArray();
        int n = alpha.length - 2;
        int m = n / 2;
        boolean b = true;
        while(n != 0) {
            b = true;
            for(int i = 0; i < m; i++) {
                if(alpha[i] != alpha[m + i]) {
                    b = false;
                    break;
                }
            }
            if(b) {
                break;
            }
            n = n -2;
            m = n / 2;
        }
        System.out.println(n);
    }
}

Measured memory_bytes: 21204
#include<iostream>
#include<string>
#include<algorithm>	
#include<cmath>
#include <vector>
using namespace std;
int main() {
	long long n = 0; string s; cin >> s;
	if (s.size() % 2 == 0) {
		n = s.size() - 2;
	}
	else{
		n = s.size() - 1;
	}
	for (int h = n; h >= 0; h--) {
		int b = 0;
		for (int i = 0; i < h / 2; i++) {
			if (s[i] == s[h / 2 + i]) {
				b++;
			}
		}
		if (b == h / 2) {
			cout << h << endl;
			cin >> n; return 0;
		}
		h--;
	}
	cin >> n;
}


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

int main(){
  int N;
  cin>>N;
  int x[N+1]={},y[N+1]={},t[N+1]={};
  for(int i=1;i<=N;i++){
    cin>>t[i]>>x[i]>>y[i];
  }
  for(int i=1;i<=N;i++){
    int dist = abs(x[i]-x[i-1])+abs(y[i]-y[i-1]);
    int T = t[i]-t[i-1];
    if((T-dist)/2 < 0 ||(T-dist)%2 != 0){
      cout<<"No"<<endl;
      return 0;
    }
  }
  cout<<"Yes"<<endl;
  return 0;
}


Measured memory_bytes: 1408
#include<iostream>
using namespace std;
int main(void){
  
  int h, w;
  
  cin >> h >> w;
  
  string s[h];
  
  for(int i = 0; i < h; i++){
    cin >> s[i];
  }
  
  for(int i = 0; i < h; i++){
    for(int j = 0; j < w; j++){
      if(s[i][j] == '.'){
        char n = '0';
        for(int k = -1; k <= 1; k++){
          for(int l = -1; l <= 1; l++){
            if(i-k < 0 || i-k >= h ||
               j-l < 0 || j-l >= w){
              continue;
            }
            if(s[i - k][j - l] == '#'){
              ++n;
            }
          }
        }
        s[i][j] = n;
      }
    }
  }
  
  for(int i = 0; i < h; i++){
    cout << s[i] << endl;
  }
  
  return 0;
}


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

constexpr int MOD = 1000000007;
const int INF = 1 << 30;

int main() {
    int n;
    cin >> n;
    vec a(n);
    rep(i, n) cin >> a[i];
    int res = 0;
    rep(i, n) {
        if (i % 2 == 0 && a[i] % 2 == 1) res++;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <cassert>

#define REP(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define eb emplace_back

typedef long long ll;
using namespace std;
long long gcd(long long a, long long b) {
  return b != 0 ? gcd(b, a % b) : a;
}
long long lcm(long long a, long long b) {
  return a * b / gcd(a, b);
}
// a x + b y = gcd(a, b)
long long extgcd(long long a, long long b, long long &x, long long &y) {
  long long g = a; x = 1; y = 0;
  if (b != 0) g = extgcd(b, a % b, y, x), y -= (a / b) * x;
  return g;
}
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    // cout << fixed << setprecision(20);
    int t;cin >> t;
    REP(_,t){
        ll a,b,c,d;cin >> a >> b >> c >> d;
        if(b > a or b > d){
            cout << "No" << '\n';
        }else if(c >= b){
            cout << "Yes" << '\n';
        }else{
            ll g = gcd(b,d);
            if(c - b + 1 >= 0){
                cout << "Yes" << '\n';
            }
            else{
                ll D = (a % g) - (c - b + 1);
                ll M = D / g;
                if(a%g - M*g >= 0){
                    cout << "Yes" << '\n';
                }
                else{
                    cout << "No" << '\n';
                }
            }
        }
    }
    return 0;
}


Measured memory_bytes: 888
#include <iostream> 
#include <stdlib.h> 
#include <string.h> 
#include <string> 
#include <sstream>
#include <cstring> 
#include<cmath>
using namespace std;
int main() {
	int x;
	cin >> x;
	cout << x / 3;
	
	return 0;

}

Measured memory_bytes: 3632
#include <bits/stdc++.h> 
using namespace std;
using ll = long long;
template<typename T> using v2 = vector<vector<T>>;
template<typename T> inline v2<T> fill(int r, int c, const T& t){ return v2<T>(r, vector<T>(c, t)); }
#define F first
#define S second

void solve(){
    int k;
    cin >> k;

    int rem = 0;
    int digits = 0;
    vector<bool> seen(k, false);
    while(true){
        ++digits;
        rem = (10*rem + 7)%k;
        if(rem == 0){
            cout << digits << '\n';
            return;
        }
        else if(seen[rem]){
            cout << "-1\n";
            return;
        }
        seen[rem] = true;
    }
}

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

Measured memory_bytes: 3748
#include<cstdio>
#include<cstring>
#include<vector>
#include<algorithm>
#include<cctype>
#include<sstream>
#include<string>
#include<iostream>
using namespace std;
int main(){
    int n;
    scanf("%d",&n);
    while(n--){
        char str[100];scanf("%s",str);
        int b[32];
        for(int i=0;i<8;i++){
            int val=(isdigit(str[i])?str[i]-'0':str[i]-'a'+10);
            for(int j=3;j>=0;j--)
                b[i*4+j]=(val>>(3-j))&1;
        }
        if(b[0])printf("-");
        int ip=0;
        for(int i=1;i<25;i++){
            ip=(ip<<1)+b[i];
        }
        printf("%d.",ip);

        double fp=0.0,dec=1.0;
        int m=0;
        for(int i=25;i<32;i++){
            dec/=2.0;
            if(b[i]){
                m=i-25;
                fp+=dec;
            }
        }
        int d=1;
        for(int i=0;i<=m;i++){
            d*=10;
            printf("%d",(int)(fp*d)%10);
        }
        puts("");
    }
    return 0;
}

Measured memory_bytes: 1204
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,K,x,s;
  s=0;
  cin>>N>>K;
  for(int i=0;i<N;i++){
    cin>>x;
    if(K<x) s+=2*(x-K);
    else if(K<2*x) s+=2*(K-x);
    else s+=2*x;
  }
  cout<<s;
    
}

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

#define f first 
#define s second 
#define pb push_back               
#define mp make_pair 

using namespace std;                    

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;

const int N = (int)1e5 + 123, mod = (int)1e9 + 7, inf = (int)1e9, LOG = 60;


ll n, m, k;
ll x[N], ans[N], a[N];
                        
int dpl[N], upl[N][LOG];
int dpr[N], upr[N][LOG];

int main(){
	srand(time(0));
    scanf("%lld", &n);       
    for(int i = 1; i <= n; i++){
    	scanf("%lld", &x[i]);
    }
    scanf("%lld%lld", &m, &k);
    for(int i = 1; i <= m; i++){
    	scanf("%lld", &a[i]);
    }

    for(int i = 1; i <= n; i++)
    	dpl[i] = dpr[i] = i;

    for(int i = 1; i <= m; i++){
    	int p = a[i];  
    	swap(dpl[p], dpl[p + 1]);
    	swap(dpr[p], dpr[p - 1]);
    }
    
    for(int i = 1;i <= n; i++)
    	upl[dpl[i]][0] = i;
    for(int i = 1; i < LOG; i++)
    	for(int j = 1; j <= n; j++)
    		upl[j][i] = upl[ upl[j][i - 1] ][i - 1];
	
	for(int i = 1;i <= n; i++)
    	upr[dpr[i]][0] = i;
    for(int i = 1; i < LOG; i++)
    	for(int j = 1; j <= n; j++)
    		upr[j][i] = upr[ upr[j][i - 1] ][i - 1];

    for(int i = 1; i <= n; i++){
    	int l = i, r = i;

    	for(int j = 0; j < LOG; j++)
    		if((1ll<<j) & k)
    			l = upl[l][j], r = upr[r][j];

    	ans[l] += x[i];
    	ans[r + 1] -= x[i];
    }

	for(int i = 1; i <= n; i++)
		printf("%lld\n", (ans[i] += ans[i - 1]));

	return 0;
}

Measured memory_bytes: 51328
package main

import "fmt"

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func main() {
	var N int
	fmt.Scan(&N)
	x := make([]int, N)
	y := make([]int, N)
	h := make([]int, N)
	for i := 0; i < N; i++ {
		fmt.Scan(&x[i], &y[i], &h[i])
	}

	MAX := 100
	for py := 0; py <= MAX; py++ {
		for px := 0; px <= MAX; px++ {
			needH := -1
			for i := 0; i < N; i++ {
				if h[i] > 0 {
					tmp := h[i] + abs(py-y[i]) + abs(px-x[i])
					if needH == -1 {
						needH = tmp
					} else {
						if needH != tmp {
							needH = -2
							break
						}
					}
				}
			}
			if needH == -2 {
				continue
			}

			for i := 0; i < N; i++ {
				if h[i] == 0 {
					dist := abs(py-y[i]) + abs(px-x[i])
					if needH > dist {
						needH = -2
						break
					}
				}
			}
			if needH == -2 {
				continue
			}

			fmt.Printf("%d %d %d\n", px, py, needH)
			return
		}
	}
}


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

#define vec     vector<int>
#define vecll   vector<ll>
#define vec2    vector<vector<int>>
#define vec2ll  vector<vector<ll>>
#define vpair   vector<pair<int, int>>
#define vpairll vector<pair<ll, ll>>

#define rep(i,n)         for(ll i=(ll)0; i<(ll)n; i++)
#define REP(i,m,n)       for(ll i=(ll)m; i<(ll)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define mpair(v1, v2)    make_pair(v1, v2)
#define pb(var)          push_back(var)
#define prt(var)         cout << var << "\n"
#define scn(var)         cin >> var;
#define pYes()           prt("Yes")
#define pNo()            prt("No")
#define prtd(n, var)     cout << fixed << setprecision(n) << var << "\n"
#define prt2(v1, v2)     cout << v1 << " " << v2 << "\n"
#define prt3(v1, v2, v3) cout << v1 << " " << v2 << " " << v3 << "\n"
#define prtall(var)      rep(i,var.size()){cout << var[i] << " ";} cout << "\n"

//----------------------------------------------------------------
vec ans;
struct Edge{
  int to, id;
};
class Graphs{

public:
  vector<vector<Edge>> graph;
  vector<int> check; // For DFS
  vector<ll> dist;   // For BFS
  queue<int> q; // For BFS
  int cmax=0;

  Graphs(int n){
    graph.resize(n);
    init(n);
  }
  ~Graphs(){}

  void addedge(int u, int v, int id){
    u--; v--;
    graph[u].push_back((Edge{v, id}));
    graph[v].push_back((Edge{u, id}));
  }
/*
  void addedge_cin(int m){
    rep(i,m){
      int a, b;
      cin >> a >> b;
      addedge(a, b);
    }
  }
*/
  void init(int n){
    check.assign(n, false);
    dist.assign(n, -1);
  }

  void dfs(int v, int c){
    check[v] = true;
    int color = 1;

    for(auto next_v : graph[v]){
      if(check[next_v.to]) continue;
      if(color == c) color++;
      ans[next_v.id] = color; cmax=max(cmax, color); color++;
      dfs(next_v.to, ans[next_v.id]);
    }
  }
/*
  void bfs(int v){
    dist[v] = 0;
    q.push(v);

    while(!q.empty()){
      int cur_v = q.front();
      q.pop();

      for(int next_v : graph[cur_v]){
        if(dist[next_v] != -1){
          continue;
        }

        dist[next_v] = dist[cur_v] + 1;
        q.push(next_v);
      }
    }
  }
*/
};

int main(void) {
  int n;
  cin >> n;
  Graphs g(n);
  rep(i,n-1){
    int a, b;
    cin >> a >> b;
    g.addedge(a, b, i);
  }
  ans.resize(n-1);

  g.dfs(0, -1);


  prt(g.cmax);
  rep(i,n-1){
    prt(ans[i]);
  }

}


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

// int/long:		-2147483648 - 2147483648 (-2^31 <= int < 2^31)
// long/long long:	-9223372036854775808 - 9223372036854775807 (-2^63 <= long < 2^63)
#define	INF (1<<29)
//536870912

#define	MOD 1000000007

int	main() {
	int x;
	cin >>x;
	if (1200>x)
		cout <<"ABC" <<endl;
	else
		cout <<"ARC" <<endl;
	return 0;
}



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

reversals = 0
need_to_sort = True
while need_to_sort:
    need_to_sort = False
    for index in range(len(arr) -1, 0, -1):
        if arr[index] < arr[index-1]:
            arr[index], arr[index-1] = arr[index-1], arr[index]
            need_to_sort = True
            reversals += 1
print(" ".join(map(str, arr)), reversals, sep="\n")


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



int hassh[27];

int main() {

    ios::sync_with_stdio(0);
    cin.tie(0);
    string s;
    cin>>s;
    
    for(auto ss : s){
        hassh[ss-'A']++;
    }
    
    if(hassh[0]>0&&hassh[1]>0){
        cout<<"Yes";
    }
    else{
        cout<<"No";
    }
    
}

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

using namespace std;

using ll = long long;

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

    char x, y;
    cin >> x >> y;
    if (x < y) cout << "<\n";
    else if (x > y) cout << ">\n";
    else cout << "=\n";

    return 0;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
#define ROF(i,a,b) for(ll i=a;i>=b;i--)
#define per(i,a) ROF(i,a,0)
#define pb push_back
using namespace std;
using ll=long long;
using ld=long double;
using ch=char;
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vP;
typedef vector<ch> vc;
typedef vector<vc> vvc;
const ll MOD=1000000007;
const ll MOD2=998244353;
const ld PI=acos(-1);
const ll INF=1e18;
struct edge{ll to,cost;};
struct edge2{ll from,to,cost;};

template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll N,Q;
    cin >> N >> Q;
    string s;
    cin >> s;
    vl ans(N-1,0),acc(N,0);
    rep(i,N-1){
        if(s[i]=='A'&&s[i+1]=='C'){
            ans[i]++;
        }
        acc[i+1]=acc[i]+ans[i];
    }
    rep(i,Q){
        ll l,r;
        cin >> l >> r;
        l--;r--;
        //cout << l << endl;
        cout << acc[r]-acc[l] << "\n";
    }
  	rep(i,N){
      	//cout << i << " " << acc[i] << endl;
    }
}

Measured memory_bytes: 5052
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define ll int64_t
#define all(v) v.begin(), v.end()
#define bitrep(n) for(int bit=0;bit<(1<<n);bit++)

int main() {

int N; cin >> N ;

vector<int> a(N);
rep(i,N) cin >> a[i];

int count4=0,count2=0,count=0;

rep(i,N){
  if(a[i]%4==0) count4++;
  else if(a[i]%2==0) count2++;
  else count++;
}

if(count2==0){
  if(count4+1>=count) cout << "Yes" << endl;
  else cout << "No" << endl;
}

else{
  if(count4>=count) cout << "Yes" << endl;

  else cout << "No" << endl;
}


  return 0;
}

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

using namespace std;

int const MAX = 1299709;
int prime[MAX + 1] = {0}; //0::prime 1::NOTprime;

void hurui()
{
    prime[1] = 1;
    for (int i = 1; i * i <= MAX; i++)
    {
        for (int j = 2; j <= MAX / i; j++)
        {
            if (prime[i] == 0)
                prime[i * j] = 1;
        }
    }
}

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

    hurui();
    int n;
    //for(int i=1;i<=30;i++) cout << prime[i] << endl;
    while (cin >> n, n)
    {
        int res = 0;
        if (prime[n] == 0)
        {
            cout << res << endl;
        }
        else
        {
            int mae = n, ato = n + 1;
            while (prime[mae] == 1)
            {
                res++;
                mae--;
            }
            while (prime[ato] == 1)
            {
                res++;
                ato++;
            }
            cout << res + 1 << endl;
        }
    }
}


Measured memory_bytes: 8160
#pragma comment(linker, "/STACK:10240000")
#include <bits/stdc++.h>

using namespace std;

const int MAXN = 110;

int a[MAXN];

int main ()
{
    int n;
    scanf ("%d", &n);
    for (int i = 1; i <= n; i ++)
    {
        scanf ("%d", &a[i]);
    }
    int all = 1, ans = 1;
    for (int i = 1; i <= n; i ++)
    {
        if (a[i] % 2 == 0)
        {
            all *= 2;
        }
        ans *= 3;
    }
    ans -= all;
    printf ("%d\n", ans);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;
int main(){
  int N; cin >> N;

  ll ans = 0;
  for(int i = 0;i < N;i++){
    ll A; cin >> A;
    while(A % 2 == 0){
      A/=2;
      ans++;
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int i, n, num[101] = {0};
	int max = 0;
	
	while(scanf("%d", &n) != EOF){
		num[n]++;
	}
	
	for(i = 0; i < 101; i++){
		if(num[i] > max){
			max = num[i];
		}
	}
	
	for(i = 0; i < 101; i++){
		if(num[i] == max){
			printf("%d\n", i);
		}
	}
	return(0);
}

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

int main(){
    int N,M,mazai=0;
    int64_t ans=0;
    cin>>N>>M;
    vector<pair<int64_t,int64_t>>A(N);
    for(int i=0;i<N;i++){
        cin>>A.at(i).first>>A.at(i).second;
    }
    
    sort(A.begin(),A.end());

    for(int i=0;i<N;i++){
        if(A.at(i).second+mazai<M){
            mazai += A.at(i).second;
            ans += A.at(i).second*A.at(i).first;
        }else{
            ans += (M-mazai)*A.at(i).first;
            break;
        }
    }
    
    cout<<ans<<endl;
}


Measured memory_bytes: 1792
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
const long long  mod = 1e9+7;
map<long long ,long long>dp;
#define bug cout<<88888888<<endl;
#define debug(x) cout << #x" = " << x << endl;
long long dfs(long long x)
{
    if(dp[x]) return dp[x];
    else
		return dp[x] = ((dfs(x/2)+dfs((x-1)/2)+dfs((x-2)/2)) )%mod;
}
long long n;
int main()
{
    dp[0] = 1;dp[1] = 2;
    cin>>n;
    cout<<dfs(n);
    return 0;
}

Measured memory_bytes: 256
class UnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n)]
        self.rank = [0] * (n)

    # 検索
    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    # 併合
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
        else:
            self.par[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    # 同じ集合に属するか判定
    def same_check(self, x, y):
        return self.find(x) == self.find(y)

n, m = [int(_n) for _n in input().split()]
p = [int(_p)-1 for _p in input().split()]
x = []
y = []
for i in range(0,m):
    X,Y = [int(_n) for _n in input().split()]
    x.append(X-1)
    y.append(Y-1)

uf = UnionFind(n)

for i in range(0,m):
    uf.union(x[i],y[i])

ans = 0
for i in range(0,n):
    if uf.find(i) == uf.find(p[i]):
        ans += 1

print(ans)

Measured memory_bytes: 26012
#include <iostream>
#include <vector>
#include <map>
#include <string>

using namespace std;

string s,t;
int s_len,t_len;

bool check(int k){
    for(int j = 0; j < t_len; j++){
        if(s[j + k] != '?'){
            if(s[j+k] != t[j]){
//                cout << s[j+k] << t[j] << endl;
                return false;
            }
        }
    }
    return true;
}

int main(){
    string ans;
    cin >> s >> t;
    s_len = s.length();
    t_len = t.length();
    int diff = s_len - t_len;
//    cout << diff << endl;
    for(int i = 0; i <= diff; i++){
        bool flag = false;
        flag = check(i);
        if(flag){
//            cout << i << endl;
            string temp;
            temp = s;
            for(int j = 0; j < t_len; j++){
                temp[j + i] = t[j];
            }
            for(int k = 0; k < s_len; k++){
                if(temp[k] == '?') temp[k] = 'a';
            }
                ans = temp;
            }
//            cout << ans << endl;
    }
    if(ans == ""){
        cout << "UNRESTORABLE" << endl;
    }else{
        cout << ans << endl;
    }
}

Measured memory_bytes: 256
h,w = map(int, input().split())
a = [input() for _ in range(h)]

ans = [""] * (h+2)
ans[0] = "#" * (w+2)
ans[-1] = "#" * (w+2)
for i in range(h):
  ans[i+1] = "#" + a[i] + "#"
for v in ans: print(v)

Measured memory_bytes: 3060
from itertools import accumulate

n, k = map(int, input().split())
a = list(map(int, input().split()))
for _ in range(k):
   b = [0] * n
   for i in range(n):
      b[max(0, i-a[i])] += 1
      tmp = i + a[i] + 1
      if tmp < n:
         b[tmp] -= 1
   a = list(accumulate(b))
   if a == [n] * n:
      break

print(*a)


Measured memory_bytes: 204192
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>

#define REP(i,n) for(auto i=0;i<n;++i)
#define REPR(i,n) for(auto i=n;i>=0;--i)
#define REPI(itr,v) for(auto itr=v.begin();itr!=v.end();++itr)
#define REPIR(itr,v) for(auto itr=v.rbegin();itr!=v.rend();++itr)
#define FOR(i,a,b) for(auto i=a;i<b;++i)
#define SORT(v,n) sort(v, v+n)
#define SORTV(v) sort(v.begin(), v.end())
#define ALL(v) v.begin(),v.end()
#define llong long long
#define ll long long
#define INF 999999999
#define MOD 1000000007
#define pb push_back
#define pf push_front
#define MP make_pair
#define SV(n,v) {int tmp;for(int i=0;i<n;++i){scanf("%d",&tmp);v.push_back(tmp);}}

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

using namespace std;

typedef pair<int,int> pii;

int main(){

  llong n;
  cin >> n;

  llong dp[101][4][4][4] = {};
  //ACGT

  dp[0][3][3][3] = 1;

  REP(i,n){
    REP(j,4){
      REP(k,4){
        REP(l,4){
          if(j == 0 && k == 2 && l == 1) continue;

          REP(a,4){
            if(k == 0 && l == 2 && a == 1) continue;
            if(k == 0 && l == 1 && a == 2) continue;
            if(k == 2 && l == 0 && a == 1) continue;
            if(j == 0 && l == 2 && a == 1) continue;
            if(j == 0 && k == 2 && a == 1) continue;

            dp[i+1][k][l][a] += dp[i][j][k][l];
            dp[i+1][k][l][a] %= MOD;
          }
        }
      }
    }
  }

  llong ans = 0;
  REP(i,4){
    REP(j,4){
      REP(k,4){
        ans = (ans + dp[n][i][j][k]) % MOD;
      }
    }
  }
  cout << ans << endl;
  return 0;
}



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

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

int N;
int p[20];
int main() {

	cin >> N;
	rep(i, N)cin >> p[i];

	int ans = 0;
	rep(i,N-2)
	{
		if (p[i] < p[i + 1] && p[i + 1] < p[i + 2])ans++;
		if (p[i] > p[i + 1] && p[i + 1] > p[i + 2])ans++;
	}

	cout << ans << endl;
	
}

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  vector<int> v(5),d(5);
  ll pos = 0;
  for (ll i = 0; i < 5; ++i) {
    cin >> v[i];
    double a = v[i]/10.0;
    d[i] = 10*(ceil(a));
  }
  ll diff = d[0] - v[0];
  for (ll i = 1; i < 5; ++i) 
    if (d[i]-v[i] > diff) pos = i;
  
  ll ans = 0;
  for (ll i = 0; i < 5; ++i) {
    if (i == pos) ans += v[i];
    else ans += d[i];
  }
  cout << ans << endl;
  return 0;
}


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

namespace Practice
{
    class Program
    {
        private static int ReadAndParseInt()
        {
            return int.Parse(Console.ReadLine());
        }
        private static int[] ReadAndParseIntArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
        }
        private static long ReadAndParseLong()
        {
            return long.Parse(Console.ReadLine());
        }
        private static long[] ReadAndParseLongArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
        }
        static void Main(string[] args)
        {
            //SolveA(args);
            SolveB(args);
            //SolveC(args);
            //SolveD(args);


        }
        
        private static void SolveB(string[] args)
        {
            int n = ReadAndParseInt();
            int sum = 0;
            for(int i=0;i<n;++i)
            {
                int val = ReadAndParseInt();
                if( IsPrime(val))
                {
                    sum++;
                }
            }
            Console.WriteLine(sum);
        }
        private static bool IsPrime(int val)
        {
            if( val == 1) { return false; }
            if( val == 2) { return true; }
            if( val % 2 == 0) { return false; }

            double sqrt = Math.Sqrt(val);
            int max = (int)Math.Ceiling(sqrt);
            for(int i=3; i <=max;i+=2)
            {
                if( val % i == 0) { return false; }
            }
            return true;
        }
    }
}



Measured memory_bytes: 17900
#include<cstdio>
using namespace std;
int a[200005];
int main(){
	int n,k,i;
	scanf("%d%d",&n,&k);
	for(i=1;i<=n;i++){
		scanf("%d",&a[i]);
	}
	for(i=k+1;i<=n;i++){
		if(a[i]>a[i-k]){
			printf("Yes\n"); 
		}
		else{
			printf("No\n"); 
		}
	}
	return 0;
} 

Measured memory_bytes: 2428
def a_cookie_exchanges(A, B, C):
    if A == B == C:
        if A & 1 == 0:
            return -1  # 3数がすべて等しい偶数。無限回行える
        else:
            return 0  # 3数がすべて等しい奇数。1回も行えない
    # 操作は高々log_2(10^9)回なので、シミュレーションして構わない
    ans = 0
    while A & 1 == 0 and B & 1 == 0 and C & 1 == 0:
        A, B, C = (B + C) // 2, (C + A) // 2, (A + B) // 2
        ans += 1
    return ans 

A, B, C = [int(i) for i in input().split()]
print(a_cookie_exchanges(A, B, C))

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

using namespace std;

#define ll long long




void solve() {

	int n, k;
	cin >> n >> k;
	int cnt= 0;
	while(n--) {
		int x;
		cin >> x;
		if(x >= k) {
			cnt++;
		}
	}
	cout << cnt;


	




	
}

int main() {

	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	solve();

	return 0;
}

Measured memory_bytes: 3572
cs=('S','H','C','D')
n=int(input())
card=[[False for i in range(13)] for j in range(4)]
for i in range(n):
    s,num=input().split()
    if s=='S':
        card[0][int(num)-1]=True
    elif s=='H':
        card[1][int(num)-1]=True
    elif s=='C':
        card[2][int(num)-1]=True
    elif s=='D':
        card[3][int(num)-1]=True

for i in range(4):
    for j in range(13):
        if card[i][j]==False:
            print(*cs[i],j+1)


Measured memory_bytes: 5612
#include <iostream>
#include <cstdio>
#include <set>
#include <stdio.h>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
	int card[5]={0};
	while(scanf("%d,%d,%d,%d,%d",&card[0],&card[1],&card[2],&card[3],&card[4]) != EOF){
		set<int> poker;
		vector<int> p;
		for(int i=0;i<5;i++){
			poker.insert(card[i]);
			p.push_back(card[i]);
		}
		sort(p.begin(),p.end());
		int d=poker.size();
		switch(d){
		case 2:
			if(p[2]!=p[3] || p[1]!=p[2]) cout<<"full house"<<endl;
			else cout<<"four card"<<endl;
			break;
		case 3:
			if((p[0]==p[1] && p[1]==p[2])||(p[1]==p[2] && p[2]==p[3])||(p[2]==p[3] && p[3]==p[4])) cout<<"three card"<<endl;
			else cout<<"two pair"<<endl;
			break;
		case 4:
			cout<<"one pair"<<endl;
			break;
		case 5:
			if(p[1]==p[0]+1 && p[2]==p[1]+1 && p[3]==p[2]+1 && p[4]==p[3]+1) cout<<"straight"<<endl;
			else if(p[0]==1 && p[1]==10 && p[2]==11 && p[3]==12 && p[4]==13) cout<<"straight"<<endl;
			else cout<<"null"<<endl;
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 1224
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <algorithm>

using namespace std;
typedef long long ll;

int main()
{
	int K, X;
	scanf("%d %d", &K, &X);
	
	if(500 * K >= X){
		printf("Yes\n");
	}
	else{
		printf("No\n");
	}
	
	return 0;
}

Measured memory_bytes: 128
a=input().split()
N=int(a[0])
K=int(a[1])
zantei=0
P=list(map(float,input().split()))

P_ex=list(map(lambda x: (x+1)/2,P))


for i in range(0,K):
    
    zantei+=P_ex[i]
zanans=0
buffer=P_ex[0]
beforeans=zantei
for i in range(1,N-K+1):
    if(beforeans-buffer+P_ex[K+i-1]>zantei):
        zantei=beforeans+P_ex[K+i-1]-buffer
    beforeans+=(P_ex[K+i-1]-buffer)
    buffer=P_ex[i]

print(zantei)
    
    

Measured memory_bytes: 23840
#include "bits/stdc++.h"
#pragma GCC optimize "03"
using namespace std;

#define int long long int
#define pb push_back
#define pii pair<int,int>
#define fi first
#define se second
#define rep(i,a,b) for (int i = a; i < b; ++i)
#define dbg(x) { cerr<<"> "<<#x<<": "<<x<< endl; }
#define dbg2(x,y) { cerr<<"> "<<#x<<": "<<x<<" , "<<#y<<": "<<y<<endl; }
#define dbg3(x,y,z) { cerr<<"> "<<#x<<": "<<x<<" , "<<#y<<": "<<y<<" , "<<#z<<": "<<z<<endl; }
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#ifndef LOCAL
#define endl '\n'
#endif
const int inf = INT_MAX;
const double eps = 0.0000001;
const double PI = acos(-1.0);
const int MOD = 1e9+7;
const int N  = 105;

int w[N], v[N], dp[N][100005];

int solve (int i, int j) {
	if (j == 0) return 0;
	if (j < 0) return -inf;
	if (i == 0) return 0;
	if (dp[i][j]) return dp[i][j];
	dp[i][j] = max(v[i] + solve(i-1, j-w[i]), solve(i-1, j));
	return dp[i][j];
}

signed main(){
    #ifdef LOCAL
        freopen("input.txt", "r", stdin);
        //freopen("output.txt", "w", stdout);
    #endif  
    IOS;

    int n, k;
    cin >> n >> k;
    for (int i = 1; i <= n; i++)
    	cin >> w[i] >> v[i];
    for (int i = 1; i<= n; i++) {
    	for (int j = 1; j <= k; j++) {
    		if (j >= w[i]) dp[i][j] = max(v[i] + dp[i-1][j-w[i]], dp[i-1][j]);
	    	else dp[i][j] = dp[i-1][j];
    	}
    }
    cout << dp[n][k];
    return 0;
}

Measured memory_bytes: 79360
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define rrep(i,n) for(int i=1; i<=(int)(n); i++)
#define pb push_back
#define all(v) v.begin(),v.end()
#define fi first
#define se second
#define bigger (char)toupper
#define smaller (char)tolower
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<string> vs;
typedef vector<char> vc;
typedef long long ll;
typedef unsigned long long ull;

int main() {
    double pi=3.1415926525897932384626;
    int n;
    cin>>n;
    n*=2;
    cout<<fixed<<setprecision(10);
    cout<<n*pi<<endl;
}


Measured memory_bytes: 3784
import java.util.Scanner;

public class Main
{
	public static void main(String[] args)
	{
		double[] d = new double[50];

		Scanner scan = new Scanner(System.in);
		String str = scan.nextLine();

		String[] substr = str.split(" ", 0);

		String s0 = substr[0];
		String s1 = substr[1];

		str = scan.nextLine();
		substr = str.split(" ", 0);

		int n0 = Integer.parseInt(substr[0]);
		int n1 = Integer.parseInt(substr[1]);

		str = scan.nextLine();

		if (str.equals(s0)) {
			n0--;
		} else {
			n1--;
		}
		System.out.println(n0+" "+n1);
	}
}


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

using namespace std;
using ll = long long;
// #define int ll
using PII = pair<ll, ll>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()

template<typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }

template<typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type
fill_v(T &t, const V &v) { t=v; }
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t, const V &v ) { for(auto &e:t) fill_v(e,v); }

template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
    out<<'('<<a.first<<','<<a.second<<')'; return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
    out<<'['; for(T i: a) {out<<i<<',';} out<<']'; return out;
}

int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0}; // DRUL
const int INF = 1<<30;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;

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

    ll n;
    cin >> n;
    ll g = 0;
    vector<ll> a(n+1);
    REP(i, n+1) {
        cin >> a[n-i];
        g = __gcd(g, abs(a[n-i]));
    }

    auto test = [&](ll p) {
        if(a[0]%p) return false;
        vector<ll> sum(p);
        FOR(i, 1, n+1) {
            ll mo = (a[i] >= 0 ? a[i] : (a[i]+p)%p);
            (sum[i%(p-1)] += mo) %= p;
        }
        bool flag = true;
        REP(i, p) if(sum[i]!=0) flag = false;
        return flag;
    };

    vector<ll> ans;

    // P <= N
    vector<bool> prime(n+2, true);
    prime[0] = prime[1] = false;
    for (int i = 2; i <= n; i++) {
        if (prime[i]) {
            if(test(i)) ans.push_back(i);
            for (int j = 2 * i; j <= n; j += i) {
                prime[j] = false;
            }
        }
    }

    for(ll i=2; i*i<=g; ++i) {
        if(g%i==0) ans.push_back(i);
        while(g%i==0) g/=i;
    }
    if(g>1) ans.push_back(g);

    // // P > N
    // ll t = a[n];
    // vector<ll> div;
    // for(ll i=2; i*i<=t; ++i) {
    //     if(t%i==0) div.push_back(i);
    //     while(t%i==0) t/=i;
    // }
    // if(t>1) div.push_back(t);
    // for(auto i: div) {
    //     if(i <= n) continue;
    //     bool flag = true;
    //     REP(j, n+1) if(a[j]%i != 0) flag = false;
    //     if(flag) ans.push_back(i);
    // }

    for(auto i: ans) cout << i << endl;

    return 0;
}


Measured memory_bytes: 384
x, y = map(int, input().split())
if x == 2 or y == 2:
    print('No')
elif x == 4 or x == 6 or x == 9 or x == 11:
    if y == 4 or y == 6 or y == 9 or y == 11:
        print('Yes')
    else:
        print('No')
elif x == 1 or x == 3 or x == 5 or x == 7 or x == 8 or x == 10 or x == 12:
    if x == 1 or x == 3 or x == 5 or x == 7 or x == 8 or x == 10 or x == 12:
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define P pair<int,int>
#define PI 3.141592653589793
const int INF = 1001001001;

int main() {
	int a, b, m;
	cin >> a >> b >> m;
	vector<int> r(a), d(b);
	rep(i, a) cin >> r[i];
	rep(i, b) cin >> d[i];
	int ans = INF;
	rep(i, m) {
		int x, y, c;
		cin >> x >> y >> c;
		ans = min(ans, r[x-1] + d[y-1] - c);
	}
	sort(r.begin(), r.end());
	sort(d.begin(), d.end());
	ans = min(ans, r[0] + d[0]);
	cout << ans << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define task "MAXFRAME"

#define nguyen_dz the_best
#define ll long long
#define ld long double
#define pb push_back
#define endl "\n"
#define ff first
#define ss second
#define pll pair<ll,ll>
#define YES cout <<"YES"<<endl;
#define NO cout <<"NO"<<endl;
#define Yes cout <<"Yes"<<endl;
#define No cout<<"No" <<endl;


using namespace std;
const ll  maxn= 4e6+100;

ld x[maxn], r[maxn];
ld ans[maxn];
stack <pair<ld,ld>> st;
ld dosth (ld x, ld r )
{
    ld nw=r;
  while (!st.empty())
  {
      ld x1= st.top().ff;
      ld r1= st.top().ss;
      r=min(r,(x1-x)*(x1-x)*1.0/(4.0*r1));
      if (r>=r1) st.pop();
      else break;
  }

  st.push(make_pair(x,r));
  return r;
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    //freopen("test.txt","r",stdin);
    if (fopen(task".INP","r"))
    {
        freopen(task".INP", "r", stdin);
        freopen(task".OUT", "w", stdout);
    }
  string s;
   cin>>s ;
   for (int i=0;i<s.length();i++)
   {
       if (s[i]=='?') s[i]='D';
   }
   cout <<s<<endl;


}



Measured memory_bytes: 3752
# http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1127&lang=en

from math import sqrt
from heapq import heappush, heappop
from collections import defaultdict


class UnionFind(object):
    def __init__(self, n):
        self.n = n
        self.par = [-1] * n
    
    def find(self, x):
        if self.par[x] < 0:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        
        if x == y:
            return False
        else:
            if self.par[x] > self.par[y]:
                x, y = y, x
            self.par[x] += self.par[y]
            self.par[y] = x
            return True

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def size(self, x):
        return -self.par[self.find(x)]

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.par) if x < 0]

    def group_count(self):
        return len(self.roots())


while True:
    N = int(input())
    if N == 0:
        break

    X, Y, Z, R = [], [], [], []
    for _ in range(N):
        xi, yi, zi, ri = map(float, input().split())
        X.append(xi)
        Y.append(yi)
        Z.append(zi)
        R.append(ri)

    # グラフ構造を作成？
    # 短いやつをつなげていって，森じゃなくなったらOKかな？
    uf = UnionFind(N)
    cost = 0.0
    edges = []
    for i in range(N):
        for j in range(i + 1, N):
            dx = X[i] - X[j]
            dy = Y[i] - Y[j]
            dz = Z[i] - Z[j]
            dij = sqrt(dx * dx + dy * dy + dz * dz) - R[i] - R[j]
            heappush(edges, (dij, i, j))

    # Kruskal
    while len(edges) > 0:
        (w, u, v) = heappop(edges)
        if uf.unite(u, v):
            if w > 0:
                cost += w
    print("{:.3f}".format(cost))



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

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

	if (s == "Sunny") {
		cout << "Cloudy" << endl;
	}
	else if (s == "Cloudy") {
		cout << "Rainy" << endl;
	}
	else if (s == "Rainy") {
		cout << "Sunny" << endl;
	}

	return 0;
}

Measured memory_bytes: 256