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

int main(){
int R,C;
cin >> R >> C; 
const int r = R, c = C;

int arr[r+1][c+1]{0};
int csum = 0,rsum = 0;

for(int i = 0; i < r;i++){
  for(int j = 0; j < c;j++){
    cin >> arr[i][j];
    csum += arr[i][j];
  }
  // cout << "csum is " << csum << endl;

  arr[i][c] = csum;
  csum = 0;
}

for(int i= 0; i < c + 1;i++){
  for(int j = 0; j < r ;j++){
  rsum += arr[j][i];
  }
  // cout << "rsum is " << rsum << endl;
  arr[r][i] = rsum;
  rsum = 0;
}

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

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

  return 0;
}


Measured memory_bytes: 3084
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <functional>

#ifdef LOCAL
	#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
	#define eprintf(...) 42
#endif

#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define repp(i, m, n) for(ll i = m, i##_len = (n); i < i##_len; ++i)
#define reprev(i, n) for(ll i = (n-1LL); i >= 0; --i)
#define all(x) (x).begin(), (x).end()
template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> P;
typedef long double ld;

int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<int> a(n), b((n + 1) / 2);
	rep (i, n) cin >> a[i];
	rep (i, (n + 1) / 2) b[i] = a[2 * i];
	sort(all(a));
	rep (i, (n + 1) / 2) eprintf("%d ", a[2 * i]); eprintf("\n");
	rep (i, (n + 1) / 2) eprintf("%d ", b[i]); eprintf("\n");
	map<int, int> m;
	rep (i, (n + 1) / 2) {
		m[a[2 * i]]++;
		m[b[i]]--;
	}
	ll ans = 0;
	for (auto x : m) {
		if (x.second > 0) ans += x.second;
	}
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 5504
from collections import defaultdict, Counter


def main():
    s = input()
    # 奇数
    if s[0] == s[-1]:
        if len(s) % 2 == 1:
            print("Second")
        else:
            print("First")
    # 偶数
    else:
        if len(s) % 2 == 1:
            print("First")
        else:
            print("Second")


if __name__ == '__main__':
    main()


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

#define REP(i, x) REPI(i, 0, x)
#define REPI(i, a, b) for (int i = int(a); i < int(b); ++i)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
using namespace std;

ll f(ll a) {
  ll ans = 0;
  while (a > 0 && a % 2 == 0) {
    a /= 2;
    ++ans;
  }
  return ans;
}

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

  int N;
  cin >> N;
  ll a;
  ll ans = 0ll;
  REP(i, N) {
    cin >> a;
    if (a % 2 == 0) {
      ans += f(a);
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define sz(x) int(x.size())
using ll = long long;
using P = pair<int,int>;
const ll LLINF = numeric_limits<long long>::max();
const int mod = 1000000007;
const int INF = 1001001001;

int main()
{
    set<int> al;

    for(int i=-100;i<=110;i++){
        al.insert(i);
    }
    int X,N;
    cin >> X >> N;
    set<int> p;
    for(int i=0;i<N;i++){
        int a;
        cin >> a;
        p.insert(a);
    }

    set<int> sa;
    set_difference(al.begin(), al.end(),
                      p.begin(), p.end(),
                      inserter(sa, sa.end()));

    int d = INF;
    int ans=X;
    for(int i: sa){
    
        if(d > abs(i-X)){
            ans = i;
            d = abs(i-X); 
        } 

    }

    cout << ans;
    return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
#define rep_i(i, n) for (int i = 0; i < (n); ++i)
#define rep_ll(i, n) for (long long i = 0; i < (n); ++i)
#define r_rep_i(i, start, end) for (int i = (start); i < (end); ++i)
#define r_rep_ll(i, start, end) for (long long i = (start); i < (end); ++i)
#define debug_vi(v) copy((v).begin(), (v).end(), ostream_iterator<int>(cout, " "));
#define debug_vll(v) copy((v).begin(), (v).end(), ostream_iterator<long long>(cout, " "));
#define debug_vd(v) copy((v).begin(), (v).end(), ostream_iterator<double>(cout, " "));
#define sort_v(v) sort((v).begin(), (v).end()); //昇順
#define d_sort_vi(v) sort((v).begin(), (v).end(), greater<int>()); //降
#define d_sort_vd(v) sort((v).begin(), (v).end(), greater<double>()); //昇順
#define say(t) cout << (t) << endl;
#define sum_vi(v) accumulate((v).begin(), (v).end(), 0);
#define sum_vll(v)accumulate((v).begin(), (v).end(), 0LL);

int main(){
  int n;cin >> n;
  vector<int> A(n);
  rep_i(i, n){
    cin >> A[i];
  }
  int m;cin >> m;
  vector<int> B(m);
  rep_i(i, m){
    cin >> B[i];
  }
  vector<int> C;

  set_intersection(begin(A), end(A), begin(B), end(B), inserter(C, end(C)));
  rep_i(i, C.size()){
    say(C[i]);
  }
}


Measured memory_bytes: 4752
/**
 * 0576-Homework
 */
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;

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

        int day = Integer.parseInt(br.readLine());
        int lang = Integer.parseInt(br.readLine());
        int math = Integer.parseInt(br.readLine());
        int langAb = Integer.parseInt(br.readLine());
        int mathAb = Integer.parseInt(br.readLine());

        while(lang > 0 || math > 0){
            lang -= langAb;
            math -= mathAb;
            day--;
        }

        System.out.println(day);

    }

}

Measured memory_bytes: 24212
#include <iostream>
using namespace std;
long long f(long long a,long long x){
  if(a == -1)return 0;
  else return a/x +1;
}
int main(){
  long long count=0,a,b,x;
  cin >> a >> b >> x;
  count = f(b,x) - f(a-1,x);
  cout << count;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  cin >> n;
  vi h(n+1);
  rep(i,n) cin >> h[i+1];
  int cnt = 0;
  int ans = 0;
  rep(i,n){
    if(h[i] < h[i+1]) {
      ans = max(ans, cnt);
      cnt = 0;
    }
    else cnt ++;
  }
  ans = max(ans, cnt);
  cout << ans << endl;
}

Measured memory_bytes: 3700
#include <bits/stdc++.h>
//#include <atcoder/all>
#define ll long long int
#define MOD 1000000007
#define P pair<ll,ll>
#define INF 1000000000000000000

//using namespace atcoder;
using namespace std;

int main(void){
  ll a, b, c;
  cin >> a >> b >> c;
  
  if (a + b >= c)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
    

  return 0;
}


Measured memory_bytes: 3628
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <array>
#include <vector>
#include <functional>
using namespace std;

int main() {
	int N, M, i, j, ans = 0, ans2;
	cin >> N;
	vector<int> T(N);
	for (i = 0; i < N; i++) {
		cin >> T[i];
		ans += T[i];
	}
	ans2 = ans;
	cin >> M;
	vector<int> P(M), X(M);
	for (i = 0; i < M; i++)cin >> P[i] >> X[i];

	for (i = 0; i < M; i++) {
		ans = ans2;
		ans += (X[i] - T[P[i] - 1]);
		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n=scan.nextInt();
		int k=scan.nextInt();
		int sum=0;
		int[] a=new int[n];
		for(int i=0;i<n;i++)
		{
			a[i]=scan.nextInt();
		}
		Arrays.sort(a);
		for(int i=0;i<k;i++)
		{
			sum+=a[i];
		}
		System.out.println(sum);
	}

}


Measured memory_bytes: 30172
#include "bits/stdc++.h"
using namespace std; 

#define IOS {ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);}
#define ll long long 

ll powermod(ll x,ll ex,ll md){ll ans=1ll;while(ex>0){if(ex&1ll) ans=(ans*x)%md; ex>>=1ll;x=(x*x)%md;}return ans;}
inline ll gcd(ll a,ll b) {if(b==0)return a;a%=b;return gcd(b,a);}
inline ll max(ll a,ll b) {return((a>b)?a:b);}
inline ll min(ll a,ll b) {return((a>b)?b:a);}


int main(){
        IOS;
        ll n;
        cin>>n;
        cout<<(!n)<<"\n";
}


Measured memory_bytes: 3616
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int main() {

    int a, b, c;
    scanf("%d%d%d", &a, &b, &c);
    
    if(a==b){
        printf("%d",c);
    }else if(a==c){
        printf("%d",b);
    }else{
        printf("%d",a);
    }
    
    return 0;

}


Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <cmath>
#include <complex>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cassert>
#include <iomanip>
using namespace std;

#define Rep(b, e, i) for(int i = b; i <= e; i++)
#define Repr(e, b, i) for(int i = e; i >= b; i--)
#define rep(n, i) Rep(0, n-1, i)
#define repr(n, i) Repr(n-1, 0, i)
#define all(v) (v).begin(), (v).end()
#define pb(v) push_back(v)
#define uniq(v) (v).erase(unique(all(v)),(v).end())
#define bitcnt(x) __builtin_popcount(x)
#define fst first
#define snd second
#define Pqaz(T) priority_queue<T,vector<T>,greater<T>>
#define Pqza(T) priority_queue<T>
#define put(x) cout << x;
#define putsp(x) cout << x << ' ';
#define putbd cout << "---------------------------------------------" << endl;
#define putln(x) cout << x << endl;
#define debug(x) cerr << #x << "=" << x << endl;
#define ENJYU std::ios::sync_with_stdio(false);std::cin.tie(0);

typedef long long ll;
typedef pair<ll, ll> llP;
typedef pair<int, int> intP;
typedef complex<double> comp;
typedef vector <int> vec;
typedef vector <ll> vecll;
typedef vector <double> vecd;
typedef vector <vec> mat;
typedef vector <vecll> matll;
typedef vector <vecd> matd;

//vector の中身を出力
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

const int MAX = 200020;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const ll INFL = 1e18;
const int MOD = 1000000007;

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

//********************************template END****************************************//

void solve(void){
	string S;
	cin >> S;

	int cnt = 0, place = -1;
	rep(S.size(), i)
	{
		if (i >= 2 && i < S.size()-1)
		{
			if (S[i] == 'C')
			{
				cnt++;
				place = i;
			}
		}
	}
	//debug(cnt);
	//debug(place);
	if (S[0] != 'A' || cnt != 1)
	{
		cout << "WA" << endl;
		return;
	}

	rep(S.size(), i)
	{
		if (i == 0 || i == place)
		{
			continue;
		}
		if (isupper(S[i]))
		{
			cout << "WA" << endl;
			return;
		}
	}
	cout << "AC" << endl;
	return;
}

int main(void){
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return 0;
}


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

int main() {
    vector<vector<int>> C(3, vector<int>(3));
    rep(i, 3) {
        rep(j, 3) {
            cin >> C[i][j];
        }
    }

    bool flg = true;
    for (int x = 0; x <= 100; x++) {
        vector<int> A(3), B(3);
        A[0] = x;
        rep(i, 3) {
            B[i] = C[0][i] - x;
        }
        for (int i = 1; i < 3; i++) {
            A[i] = C[i][0] - B[0];
        }

        rep(i, 3) {
            rep(j ,3) {
                if (C[i][j] != A[i] + B[j]) {
                    flg = false;
                }
            }
        }

        if (!flg) break;
    }

    if (flg) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3556
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define INF 1000000000
#define MOD 1000000007

vector<vector<int>> dp;
string s, t;

void lcs(int i, int j){
    if(i==0 || j==0) return;
    if(s[i-1]==t[j-1]){
        lcs(i-1, j-1);
        cout << s[i-1];
    }else{
        if(dp[i-1][j]>=dp[i][j-1]) lcs(i-1, j);
        else lcs(i, j-1);
    }
    return;
}



int main(){
    cin >> s >> t;
    int S = s.size();
    int T = t.size();
    dp.resize(S+1);
    for(vector<int> &v:dp)
        v.resize(T+1);
    
    for(int i=0; i<S; i++){
        for(int j=0; j<T; j++){
            if(s[i]==t[j]) dp[i+1][j+1] = dp[i][j] + 1;
            else dp[i+1][j+1] = max(dp[i+1][j], dp[i][j+1]);
        }
    }

    string ans = "";
    lcs(S, T);
    cout << endl;
    return 0;
}


Measured memory_bytes: 35840
while line = gets
  q = line.chomp.to_f
  break if q == -1

  x = q / 2
  while true
    x = x - (x**3 - q) / (3 * x**2)
    break if (x**3 - q).abs < 0.00001 * q
  end

  puts sprintf('%0.6f', x)
end

Measured memory_bytes: 8700
Word=input()
Word_list=list(Word)
 
number=0
renzoku=0
Enter=0
 
for num in range(3):
  if Word_list[num]=="R":
    number=number+1
  if (number>renzoku):
      renzoku=number
  else:
    number=0

print(renzoku)

Measured memory_bytes: 8880
#include<iostream>
#include<bits/stdc++.h>
#include<string>
#include<time.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define fi first    
#define se second
#define mod 1000000int
void solve()
{
    ll n,a,b;
    cin>>n>>a>>b;
    if(a>b)
        swap(a,b);
    if((b-a)%2==0)
        cout<<(b-a)/2;
    else{
        ll t=min(b-1,n-a);
        if((b-a)==1)
            cout<<t;
        else
        {
            ll e=(b-a+1)/2+a-1;
            ll e2=(b-a)/2+1+n-b;
            cout<<min(e,e2);
        }
    }
}
int main(){ 
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    // #endif  
    clock_t tStart = clock();
    int t;
    // cin>>t;
    // while(t--)
       solve();
    // printf("\nTime taken: %.2fs\n", (double)(clock() - tStart)/CLOCKS_PER_SEC);
    return 0;
}      

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n)  for (int i = 0; i < (int) (n); i++)
#define REP1(i, n) for (int i = 1; i <= (int) (n); i++)
#define all(x)     (x).begin(), (x).end()
#define SZ(x)      ((int) (x).size())
using ll = long long;
const ll mod  = 1e9 + 7;
const int INF = 2e9;
using pint = pair <int, int>;

int main() {
  string s;
  cin >> s;
  int n    = s.length();
  bool ans = true;
  for (int i = 0; i < n; i += 2) {
	  if (s.substr(i, 2) != "hi") {
		  ans = false;
		}
	}
  if (ans) {
	  cout << "Yes" << endl;
	} else {
	  cout << "No" << endl;
	}
  return 0;
}


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

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

    vector<long long> H(n);

    for(long long i = 0;i < n;i++){
        cin >> H[i];
    }

    sort(H.rbegin(),H.rend());

    long long count = 0;
    for(long long i = 0;i < n;i++){
        if(k>0){
            H[i] = 0;
            k--;
        }
        while(H[i]>0){
            H[i]--;
            count++;
        }
    }
    cout << count << endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define INF 100000000.0
#define EPS 1e-10
#define MOD 1000000007
using namespace std;
typedef pair<double, int> P;

int n, m, p, a, b;
int t[8];
double dist[(1<<8)*30+30];
vector<P> e[(1<<8)*30+30];

void solve(){
	rep(i,n) cin >> t[i];
	rep(i,(1<<8)*30+30) dist[i] = INF;
	rep(i,(1<<8)*30+30) e[i].clear();
	rep(i,p){
		int x, y; double z;
		cin >> x >> y >> z;
		x--; y--;
		rep(j,(1<<n)){
			rep(k,n){
				if((j&(1<<k)) != 0) continue;
				e[j*30+x].push_back(P(z/t[k],(j+(1<<k))*30+y));
				e[j*30+y].push_back(P(z/t[k],(j+(1<<k))*30+x));
			}
		}
	}
	priority_queue<P,vector<P>, greater<P> > que;
	dist[a] = 0.0;
	que.push(P(0.0,a));
	while(true){
		if(que.size() == 0) break;
		P q = que.top();
		que.pop();
		if(q.first > dist[q.second]) continue;
		rep(i,e[q.second].size()){
			P x = e[q.second][i];
			if(dist[x.second] > q.first+x.first){
				dist[x.second] = q.first+x.first;
				que.push(P(dist[x.second],x.second));
			}
		}
	}
	double ans = INF;
	rep(i,(1<<n)) ans = min(ans,dist[i*30+b]);
	if(ans == INF) puts("Impossible");
	else printf("%.9f\n",ans);
}

int main(){
	while(cin >> n >> m >> p >> a >> b){
		if(n==0&&m==0&&p==0&&a==0&&b==0) break;
		a--; b--;
		solve();
	}
}

Measured memory_bytes: 24068
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
ll mod =1e9+7;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,a,b) for(int i=(a);i<(b);++i)

template<class T> T maxt(T x,T y) {if (x>y) return x;else return y;}
template<class T> T mint(T x,T y) {if (x>y) return y;else return x;}
//sort(v.begin(), v.end(), [](auto& x, auto& y){return x[1] < y[1];});


//小数出力
double print_double(double d){printf("%.6f", d);}

//約数列挙
vector<ll> divisor(ll n) {
  vector<ll> ret;
  for(ll i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}



// ll combination_mod(int n, int k) {
//   k = mint(k,n-k);
//   ll ans = 1;
//   if (n==0 || k ==0) return ans;
//   rep(i,k) {
//     ans = ans*(n-i)%mod;
//     ans = ans*modinv(i+1)%mod;
//   }
//   return ans;
// }

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

//ベルマンフォード法
vector<ll> bellman_ford (vector<edge> edges, int V, int E, int r, ll INF = 100000000000) {  
  vector<ll> cost_to(V,INF);
  cost_to[r] = 0;
  rep(i,V) {
    rep(j,E) {
      edge e = edges[j];
      if (cost_to[e.from]==INF) continue;
      if (cost_to[e.to] > cost_to[e.from] + e.cost) {
        cost_to[e.to] = cost_to[e.from] + e.cost;
        if (i==V-1) {
          printf("NEGATIVE CYCLE\n");
          return {};
        }
      }

    }
  }
  return cost_to;
}

// combination
const int MAX = 510000;
const int MOD = 1000000007;
 
long long fac[MAX], finv[MAX], inv[MAX];
 
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;
}


template<class T> inline void chmin(T& a, T b) {if (a > b) a = b;}
template<class T> inline void chmax(T& a, T b) {if (a < b) a = b;}


// 木上の探索
vector<int> cnt;
void dfs(const vector<vector<int>> &G, int v, int p) {
    for (auto nv : G[v]) {
        if (nv == p) continue; // nv が親 p だったらダメ
        dfs(G, nv, v);
    }

    // 帰りがけ時に、部分木サイズを求める
    cnt[v] = 1; // 自分自身
    for (auto c : G[v]) {
        if (c == p) continue;
        cnt[v] += cnt[c]; // 子のサイズを加える
    }
}

int main() {
  double r;
  cin >> r;
  double ans = 2*r*acos(0)*2;
  cout << ans << endl;
}


Measured memory_bytes: 3824
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
#include <algorithm>
#include <list>
#include <map>
#include <utility>
#include <set>
 
#define rep(i, n) for(int i = 0; i < n; i++)
#define lli long long int
 
using namespace std;
 
int main() {
  
  string s;
  string r;

  cin >> s;
  cin >> r;

  s = s + s;

  rep(i, s.size() / 2) {

    int j = 0;

    while (j < r.size() && s[i + j] == r[j]) {
      if (j == r.size() - 1) {
        cout << "Yes" << endl;
        return 0;
      }
      j ++;
    }
  }
  cout << "No" << endl;

  return 0;
}



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

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

  int ispoor = 0;
  if(a == b && !(b == c)) ispoor = 1;
  if(b == c && !(c == a)) ispoor = 1;
  if(c == a && !(a == b)) ispoor = 1;

  if(ispoor){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}


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

#define ll long long

int main() {
    std::ios::sync_with_stdio(false);
    using namespace std;
    int n;
    cin >> n;
    vector< vector<ll> > A(n);
    for(int i = 0; i < n; i++)
        A[i].resize(n - i);

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

    for(int i = 1; i < n; i++)
        for(int j = 0; j < n - i; j++) {
            ll left = A[0][j] - A[i - 1][j + 1],
               right = A[0][j + i] - A[i - 1][j];
            if(left > right)
                A[i][j] = left;
            else
                A[i][j] = right;
        }

    cout << A[n - 1][0] << "\n";

    return 0;
}


Measured memory_bytes: 35584
#include<iostream>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<vector>
#include<climits>
#define ll long long int
using namespace std;
string make_id(int p) {
  string s = "000000";
  string t=to_string(p);
  string r;
  for(auto i=t.begin(); i!=t.end(); i++)
    s.push_back((*i));
  return s.substr(s.size()-6, s.size());
}

int main(void) {
  int n, m;
  vector<pair<pair<int, int>, int>> v;
  cin>>n>>m;
  for(int i=0; i<m; i++) {
    int p, y;
    cin>>p>>y;
    v.push_back(make_pair(make_pair(p, y), i));
  }
  sort(v.begin(), v.end());
  int y_index=1;
  int p_index=v[0].first.first;
  vector<pair<int, string>> vv;
  for(int i=0; i<m; i++) {
    string s;
    if(p_index==v[i].first.first) {
      s=make_id(v[i].first.first);
      s+=make_id(y_index);
      vv.push_back(make_pair(v[i].second, s));
    } else {
      p_index=v[i].first.first;
      y_index=1;
      s=make_id(v[i].first.first);
      s+=make_id(y_index);
      vv.push_back(make_pair(v[i].second, s));
    }
    y_index++;
  }
  sort(vv.begin(), vv.end());
  for(auto i=vv.begin(); i!=vv.end(); i++) {
    cout<<(*i).second<<endl;
  }
  return 0;
}


Measured memory_bytes: 10480
n = int(input())
if n <= 111:
    print(111)
elif n <= 222:
    print(222)
elif n <= 333:
    print(333)
elif n <= 444:
    print(444)
elif n <= 555:
    print(555)
elif n <= 666:
    print(666)
elif n <= 777:
    print(777)
elif n <= 888:
    print(888)
else:
    print(999)


Measured memory_bytes: 2940
#include <stdio.h>

int main(){
    int N,ans=0;
    scanf("%d",&N);
    int B[N-1];
    for(int i=0;i<N-1;i++){
        scanf("%d",&B[i]);
    }
    if(N>2){
        for(int i=0;i<N-1;i++){
            if((B[i]>B[i+1])&&(i<N-2)){
                ans+=B[i+1];
            }
            if((B[i]<=B[i+1])&&(i<N-2)){
                ans+=B[i];
            }
        }
    }
    ans+=B[0];
    ans+=B[N-2];
    printf("%d",ans);
    return 0;
}

Measured memory_bytes: 128
import itertools
n,m,x = map(int,input().split())
ca = []
for i in range(n):
    cakari = list(map(int,input().split()))
    ca.append(cakari)
ans = 1000000000000
for i in range(2**n):
    i = format(i, 'b')
    izero = i.zfill(n)
    utd = [0 for i in range(m+1)]
    for j in range(n):
        if izero[j] == '1':
            for k in range(m+1):
                utd[k] += ca[j][k]
    judge = True
    for l in range(m):
        if utd[l+1] < x:
            judge = False
    if judge == True and ans > utd[0]:
        ans = utd[0]
    
if ans != 1000000000000:
    print(ans)
else:
    print('-1')


Measured memory_bytes: 9236
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
	int n, k, c;
	cin>>n>>k>>c;
	string s;
	cin>>s;
	int x[200020], y[200020];
	x[0]=0;
	int pr=-c-1;
	for(int i=0; i<n; i++){
		x[i+1]=x[i];
		if(s[i]=='o' && pr+c<i){
			pr=i;
			x[i+1]++;
		}
	}
	y[n]=0, pr=n+c+1;
	for(int i=n-1; i>=0; i--){
		y[i]=y[i+1];
		if(s[i]=='o' && i+c<pr){
			pr=i;
			y[i]++;
		}
	}
	for(int i=0; i<n; i++){
		if(s[i]=='x') continue;
		if(x[i]+y[i+1]<k){
			cout<<i+1<<endl;
		}
	}
	return 0;
}


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

int main() {

  int A ,B , S, T , sum ;
  cin >> A >> B ;
  sum = 0;

  for (int i = A; i < B+1; i++) {
    S = 0;
    T = i ;
    for(int j = 5 ; j > 0 ; j--){
      S += (T%10)*std::pow(10 , j-1) ;
      T /= 10 ;
    }

    if ( i == S )
     sum++ ;

  }

  cout << sum << endl;

}


Measured memory_bytes: 256
#include<stdio.h>
#include<bits/stdc++.h>
using namespace std;
#define mx 100010
#define inf -9187201950435737472
#define int long long

struct node{
	int t,nt,dis;
}e[400005];
int n,m;
int cnt=0,head[mx],d[mx];

void add(int x,int y,int w){
	e[++cnt].t=y;
	e[cnt].dis=w;
	e[cnt].nt=head[x];
	head[x]=cnt;
}

void bfs(int p){
	queue<int> q;
	q.push(p);
	d[p]=0;
	int now;
	while(!q.empty()){
		now=q.front();
		q.pop();
		for(int i=head[now];i;i=e[i].nt){
			int v=e[i].t;
//			cout<<d[v]<<' '<<inf<<endl; 
			if(d[v]==inf){
				q.push(v);
				d[v]=d[now]+e[i].dis;
			}else{
//				cout<<v<<' '<<d[v]<<' '<<now<<' '<<d[now]<<endl;
				if(d[v]!=d[now]+e[i].dis){
					printf("No\n");
					exit(0);
				}
			}
		}
	}
}

signed main(){
	scanf("%lld%lld",&n,&m);
	memset(d,128,sizeof(d));
	int l,r,D;
	for(int i=1;i<=m;i++){
		scanf("%lld%lld%lld",&l,&r,&D);
		add(l,r,D);
		add(r,l,-D);
	}
	for(int i=1;i<=n;i++){
		if(d[i]==inf) bfs(i);
		
	}
	printf("Yes\n");
}


Measured memory_bytes: 12032
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n)for(int i=0;i<(int)(n);i++)
#define PI 3.141592653589793
//vector < vector<int>>a(0, vector<int>(0));二次元配列宣言


int main()
{
	int n;
	cin >> n;
	int ans = n / 2;
	if (n % 2 == 1)
		ans++;
	cout << ans<<endl;

}

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

void solve(long long N, std::vector<long long> X)
{
    long long T = 0, P = 0; /* T: sum of Xs, P: optimal P */

    for (size_t i = 0; i < N; i++)
    {
        T += X[i];
    }
    P = T / N;

    long long S = 0; /* stamina */
    for (size_t i = 0; i < N; i++)
    {
        S += (X[i] - P) * (X[i] - P);
    }

    S = min(S, S + 2 * T - N * (2 * P - 1));
    S = min(S, S - 2 * T + N * (2 * P + 1));

    cout << S << endl;
}

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


Measured memory_bytes: 256
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <vector>
#include <iostream>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
typedef long long ll;

int n;
ll X;
ll xs[200000+10];
ll cs[200000+10];

inline ll calc(ll k, int x) {
  return (k+1)*(k+1)*x;
}

int main(void) {
  cin >> n >> X;
  REP(i, n) {
    cin >> xs[i];
    cs[i+1] = cs[i] + xs[i];
  }
  ll res = 7000000000000000000LL;
  for(int i = 1; i <= (n+1)/2; ++i) {
    ll cur = 5LL*cs[n] + X*i;
    bool over = false;
    for(int i2 = n-i*2; i2 >= 0; i2 -= i) {
      ll tmp = cur + 2*cs[i2];
      if(tmp < 0) {
        over = true;
        // cerr << "over!" << endl;
        break;
      }
      cur = tmp;
    }
    // cerr << ">> " << i << " " << cur << endl;
    if(!over) {
      res = min(res, cur);
    }
  }

  cout << res + (X*n) << endl;
  
  return 0;
}


Measured memory_bytes: 3328
def main():

    N, C = map(int, input().split())
    A = []
    for _ in range(N):
        x, v = map(int, input().split())
        A.append([x, v])

    clock = [0]
    clock_r = [0]
    v = 0
    for i in range(N):
        v += A[i][1]
        clock.append(v-A[i][0])
        clock_r.append(v-2*A[i][0])
    prefix_clock = [0]
    prefix_clock_r = [0]
    for i in range(1, N+1):
        prefix_clock.append(max(prefix_clock[-1], clock[i]))
        prefix_clock_r.append(max(prefix_clock_r[-1], clock_r[i]))

    cclock = [0]
    cclock_r = [0]
    v = 0
    for i in range(N):
        v += A[N-1-i][1]
        cclock.append(v-(C-A[N-1-i][0]))
        cclock_r.append(v-2*(C-A[N-1-i][0]))
    prefix_cclock = [0]
    prefix_cclock_r = [0]
    for i in range(1, N+1):
        prefix_cclock.append(max(prefix_cclock[-1], cclock[i]))
        prefix_cclock_r.append(max(prefix_cclock_r[-1], cclock_r[i]))

    # print(A, C)
    # print(prefix_clock)
    # print(prefix_cclock)

    max_v = float('-inf')
    for i in range(N+1):
        v1 = prefix_clock_r[i]
        v2 = prefix_cclock[N-i]
        max_v = max(max_v, v1+v2)
        v3 = prefix_clock[i]
        v4 = prefix_cclock_r[N-i]
        max_v = max(max_v, v3+v4)
    return max_v


if __name__ == '__main__':
    print(main())

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

//#include <ext/pb_ds/assoc_container.hpp> // Common file
//#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update

#define rep(i,n) for(i=1;i<=n;i++)
#define Rep(i,n) for(i=0;i<n;i++)
#define For(i,a,b) for(i=a;i<=b;i++)

#define pb(x) push_back(x)
#define sz(x) x.size()

#define mem(ara,val) memset(ara,val,sizeof(ara))
#define eps 1e-9

#define si(x) scanf("%d",&x)
#define sii(x,y) scanf("%d %d",&x,&y)
#define siii(x,y,z) scanf("%d %d %d",&x,&y,&z)
#define sl(x) scanf("%lld",&x)
#define sll(x,y) scanf("%lld %lld",&x,&y)
#define slll(x,y,z) scanf("%lld %lld %lld",&x,&y,&z)
#define ss(ch) scanf("%s",ch)
#define pi(x) printf("%d",x)
#define pii(x,y) printf("%d %d",x,y)
#define piii(x,y,z) printf("%d %d %d",x,y,z)
#define pl(x) printf("%lld",x)
#define pll(x,y) printf("%lld %lld",x,y)
#define plll(x,y,z) printf("%lld %lld %lld",x,y,z)
#define ps(ch) printf("%s",ch)
#define Afridi 0
#define NL printf("\n")
#define debug(x) printf("wow  %d !!\n",x)
#define Max 1000005
#define INF (LL)1e18
//#define mod 1000000007
#define un(x) x.erase(unique( x.begin() , x.end() ), x.end())

#define FI freopen("in.txt","r",stdin)

#define D(x) cout << #x << " = " << x << endl
#define DD(x,y) cout << #x << " = " << x << "   " << #y << " = " << y << endl

typedef long long LL;
typedef unsigned long long ULL;

using namespace std;

LL bigmod(LL b,LL p,LL m)
{
    if(p == 0)return 1;
    LL my = bigmod(b,p/2,m);
    my*=my;my%=m;
    if(p & 1)my*=b,my%=m;
    return my;
}
LL setb(LL n,LL pos){return n=n | (1 << pos);}
LL resb(LL n,LL pos){return n=n & ~(1 << pos);}
bool checkb(LL n,LL pos){return (bool)(n & (1 << pos));}

LL a,b,c,d,e,f;
vector <LL> v,s;
bool visit[3005];

void F(LL sum)
{
	if( sum > f ) return;
	if(sum)v.pb(sum);
	if( visit[sum] ) return;
	visit[sum] = 1;
	F(sum+a*100);
	F(sum+b*100);
}

void G(LL sum)
{
	if( sum > f ) return;
	s.pb(sum);
	if( visit[sum] ) return;
	visit[sum] = 1;
	G(sum+c);
	G(sum+d);
}

struct info
{
	LL x,y;
	info() {}
	info(LL xx,LL yy) { x = xx; y = yy; }
	bool operator < (const info &p) const
	{
		return x * p.y < y * p.x;
	}
};
vector <info> fuck;

int main()
{
	//FI;
	sll(a,b);
	sll(c,d);
	sll(e,f);
	F(0);
	sort(v.begin(),v.end());
	un(v);


	mem(visit,0);
	G(0);
	sort(s.begin(),s.end());
	un(s);


	for(int i = 0; i < sz(v); i++)
	{
		for(int j = 0; j < sz(s); j++)
		{
			LL w = v[i];
			LL sg = s[j];
			LL tot = w + sg;
			if( tot > f ) continue;
			if( info(e,100+e) < info(sg,sg+w) ) continue;
			fuck.pb( info(sg,sg+w) );
		}
	}
	sort( fuck.begin() , fuck.end() );
	printf("%lld %lld\n",fuck[ sz(fuck)-1 ].y,fuck[ sz(fuck)-1 ].x);
	return 0;
}


Measured memory_bytes: 640
let n = read_int ()

let rec read_ints accu = function
  | 0 -> List.rev accu
  | k -> read_ints ((Scanf.scanf " %d" (fun x -> x)) :: accu) (k-1)

let a = Array.of_list (read_ints [] (2*n-1))


let check x =
  let i = ref (n-1) and j = ref (n-1) in
  while !i > 0 && (a.(!i-1)>=x) != (a.(!i)>=x) do
    i := !i - 1
  done;
  while !j < 2*n-2 && (a.(!j+1)>=x) != (a.(!j)>=x) do
    j := !j + 1
  done;
  if n-1- !i < !j-n+1 then a.(!i)>=x else a.(!j)>=x

let rec bsearch l r = if r = l+1 then l else let m = (l+r)/2 in if check m then bsearch m r else bsearch l m

let () = print_int (bsearch 1 (2*n))

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

int n,l,r;
int a[400010],b[800010];

int main()
{int i,j,k,p;
 
 scanf("%d",&n);
 for(i=1;i<=n;i++) scanf("%d",&a[i]);
 l=400000;
 r=400000;
 b[l]=a[1];
 for(i=2;i<=n;i++)
 	if(i&1)
		b[--l]=a[i];
	else
		b[++r]=a[i];
 //cout<<l<<" "<<r<<endl;		
 if(n&1)
 {	for(i=l;i<=r;i++)
 	{	printf("%d",b[i]);
 		printf("%c",i!=r?' ':'\n');
 	}
 }
 else
 {	for(i=r;i>=l;i--)
 	{	printf("%d",b[i]);
 		printf("%c",i!=l?' ':'\n');
 	}
 }
 
 return 0;
}

Measured memory_bytes: 4992
from collections import deque

H, W = map(int, input().split())
Ch, Cw = map(int, input().split())
Dh, Dw = map(int, input().split())

l = [[1 if i=="#" else 0 for i in input()] for _ in range(H)]
q = deque([(0, (Ch-1, Cw-1))])
INF = 10**12
costs = [[INF]*W for _ in range(H)]
costs[Ch-1][Cw-1] = 0

while q:
    cost, pos = q.popleft()
    h, w = pos
    for dh in range(-2, 3):
        for dw in range(-2, 3):
            if dh==0 and dw==0:
                continue
            hh, ww = h+dh, w+dw
            if not (0<=hh<H and 0<=ww<W):
                continue
            if l[hh][ww]:
                continue
            
            if ((abs(dh)==1 and dw==0) or (dh==0 and abs(dw)==1)) and costs[hh][ww] > costs[h][w]:
                costs[hh][ww] = costs[h][w]
                q.appendleft((cost, (hh, ww)))
            elif costs[hh][ww] > costs[h][w]+1:
                costs[hh][ww] = costs[h][w]+1
                q.append((cost+1, (hh, ww)))

ans = costs[Dh-1][Dw-1]
print(ans if ans!=INF else -1)


Measured memory_bytes: 105276
/*      ...वहां तूफान भी हार जाते हैं जहां कश्तियां जिद पर होती हैं !...        */
#include <bits/stdc++.h>
using namespace std;

#define fast ios_base::sync_with_stdio(false);   cin.tie(NULL); cout.tie(NULL);
#define fl(i,a,n) for(int i=a; i<n; i++)
#define ll long long 
#define pb push_back
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define test()  int tt;  cin>>tt;  while(tt--)
#define nl  cout<<"\n"
#define dbg(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args)    {
    cout << *it << " = " << a << endl;
    err(++it, args...);
}
const int mod=1e9+7;

int main()  {
    fast;
    int n;  cin>>n;
    vector<double> dp(n+1,0);
    dp[0]=1;
    fl(i,0,n)   {
        double d;   cin>>d;
        for(int j=i+1;j>=0;j--)  {
            dp[j]=(j==0 ? 0 : dp[j-1]*d) + dp[j]*(1-d);
        }
    }
    double ans=0;
    fl(i,0,n+1)   {
        if(i>n-i)   ans+=dp[i];
    }
    printf("%.10lf",ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define int long long
using P = pair<int,int>;
signed main(){
    int n;cin >> n;
    int a[n+1];
    rep(i,n+1)cin >> a[i];
    int ret = 1;

    reverse(a,a+n+1);
    vector<int>  sum(n+2);
    rep(i,n){
        sum[i+1] = sum[i] + a[i];
    }
    reverse(sum.begin(),sum.end());
    int ok;
    vector<int> num;
    reverse(a,a+n+1);
    int ans = 0;
    
    rep(i,n+1){
        if(num.size())num.push_back(min(ok*2,sum[i]));
        else num.push_back(1);
        ok = num.back()-a[i];
        if(ok < 0){
            cout << -1 << endl;
            return 0;
        }
        ret *= 2;
        ans += num.back();
    }
    cout << ans << endl;
    


    return 0;
}

Measured memory_bytes: 5880
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author SimplyDivine
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastReader in = new FastReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, FastReader in, PrintWriter out) {
            char[] s = in.next().toCharArray();
            int n = s.length;
            for (int i = n - 1; i >= 0; i--) {
                if (go(s, 0, i)) {
                    out.println(i);
                    break;
                }
            }
        }

        private boolean go(char[] s, int st, int en) {
            if ((en - st) % 2 != 0) return false;
            int mid = (st + en) / 2;
            for (int i = 0; i < mid; i++) {
                if (s[i] != s[mid + i]) return false;
            }
            return true;
        }

    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader(InputStream i) {
            br = new BufferedReader(new
                    InputStreamReader(i));
        }

        public String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

    }
}



Measured memory_bytes: 22356
mod = 998244353
 
N = int(input())
D = list(map(int,input().split()))
 
C = [0]*N
 
for i in range(N):
    C[D[i]]+=1
 
if D[0]!=0:
    print(0)  
elif C[0]==1:
    counter=1
    ans = 1
    for i in range(1,N):
        if C[i]==0 and counter<N:
            ans = 0
            break
        elif C[i]==0:
            break
        else:
            ans *= pow(C[i-1] ,C[i], mod)
            ans %= mod
            counter += C[i]
    print(ans)
else:
    print(0)

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

int main() {
  int N;
  cin >> N;
  vector<int> a(N*3);
  for(int i=0;i<N*3;i++){
    cin >> a[i];
  }

sort(a.begin(),a.end());
reverse(a.begin(),a.end());
long sum =0;
for(int i=0;i<N;i++){
  sum += a[2*i+1];
}

cout << sum << endl;

}


Measured memory_bytes: 1408
#include <iostream>
#include <algorithm>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}
const ll INF = 1e15;
const ll MOD = 1000000007;
typedef pair<ll,ll> P;
const ll MAX = 21;
constexpr ll nx[8] = {1,0,-1,0,-1,-1,1,1};
constexpr ll ny[8] = {0,1,0,-1,-1,1,-1,1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    string s,t;
    cin >> n;
    cin >> s >> t;
    ll ans,index;
    bool flag;
    if (s[0] == t[0]){
        ans = 3;
        index = 1;
        flag = 1;
    }
    else{
        ans = 6;
        index = 2;
        flag = 0;
    }
    while(index < n){
        if (s[index] == t[index]){
            if (flag) (ans *= 2)%=MOD;
            index++;
            flag = 1;
        }
        else{
            if (flag) (ans *= 2)%=MOD;
            else (ans *= 3)%=MOD;
            index += 2;
            flag = 0;
        }
    }
    PRINT(ans);
}


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

int main() {
    string s;
    cin >> s;
    
    string t = s;
    reverse(t.begin(), t.end());
    int count = 0;
    rep(i,s.size()) {
     if(s.at(i) != t.at(i)) {
     count++;
     }
    }
    cout << count / 2;
    
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
  int a,b,c,x,y,z;
  scanf("%d%d%d",&a,&b,&c);
  x=a;
  y=b;
  z=c;
  
  a=y;
  b=x;
  
  x=a;
  y=b;
  
  a=z;
  c=x;
  
  printf("%d %d %d",a,b,c);
  return 0;
}


Measured memory_bytes: 1696
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var arr=input.trim().split("\n").map(Number);
while(true){
   var n=arr.shift();
   if(n==0)break;
   var stone=[];
   while(n--)stone.push(arr.shift());
   var ary=[];
   var flag=false;
   stone.forEach(function(v,i){
      flag=!flag;
      if(flag)ary.push(v);
      else {
         if(ary[ary.length-1]==v)ary.push(v);
         else{
            ary.push(v);
            i--;
            while(true){
               if(i<0 || ary[i]==v)break;
               else {
                  ary[i]=v;
                  i--;
               }
            }
         }
      }
   });
   var cnt=0;
   ary.forEach(function(v){
      if(v==0)cnt++;
   });
   console.log(cnt);
}

Measured memory_bytes: 21080
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef pair<ll,ll> l_l;
typedef pair<int,int> i_i;
const ll mod=1e9+7;
const int inf=1<<30;

ll per(int l,int r){
  ll ans=1;
  for(int i=l;i>l-r;i--){
    ans*=i;
    ans%=mod;
  }
  return ans;
}

ll ans=1;
int n,k;
vector<vector<int> > to;
void dfs(int v,int p=-1){
  int l=p==-1?k:k-2;
  int r=p==-1?to[v].size()+1:to[v].size()-1;
  ans*=per(l,r);
  ans%=mod;
  rep(i,to[v].size()){
    int nv=to[v][i];
    if(nv==p) continue;
    dfs(nv,v);
  }
}

int main(){
  cin >> n >> k;
  to.resize(n);
  rep(i,n-1){
    int a,b;
    cin >> a >> b;
    a--; b--;
    to[a].push_back(b);
    to[b].push_back(a);
  }
  dfs(0);
  cout << ans << endl;
}

Measured memory_bytes: 12416
# Aizu Problem ITP_1_7_B: How many ways?
#
import sys, math, os

# read input:
PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
    sys.stdin = open("sample-input.txt", "rt")


while True:
    n, x = [int(_) for _ in input().split()]
    if n == x == 0:
        break
    cnt = 0
    for a in range(1, x // 3):
        for b in range(a + 1, x // 2):
            c = x - a - b
            if b < c <= n:
                cnt += 1
    print(cnt)

Measured memory_bytes: 7756
s = int(input())

A = [0]*1000002

c4 = 0
c2 = 0
c1 = 0

m4 = 0
m2 = 0
m1 = 0

for i in range(1,1000002):
    if i == 1:
        A[i-1]=s
        #i += 1
    
    if A[i-1]%2==0:
        A[i] = A[i-1]/2
    else:
        A[i] = 3*A[i-1] + 1

for i in range(len(A)):
    if A[i] == 4:
        c4 += 1
        if c4 == 2:
           m4 = i
    elif A[i] == 2:
        c2 += 1
        if c2 == 2:
           m2 = i
    elif A[i] == 1:
        c1 += 1
        if c1 == 2:
           m1 = i

print(min(m1,m2,m4)+1)

Measured memory_bytes: 34548
#include<bits/stdc++.h>
using namespace std;
int main(){
  
  int n;
  cin >> n;
  
  vector<int64_t> cont(n);
  
  int64_t count = 0;
  bool jad = false;
  for(int i = 0 ; i < n ; i++){
    int a;
    cin >> a;
    if(a < 0){
      count++;
      count %= 2;
      a *= -1;
    }
    if(a == 0){
      jad = true;
    }
    cont.at(i) = a;
  }
  
  sort(cont.begin() , cont.end());
  
  int64_t ans = 0;
  for(int i = 0 ; i < n ; i++){
    ans += cont.at(i);
  }
  
  if(count % 2 == 0 || jad){
    cout << ans << endl;
  }
  else{
    cout << ans - 2*cont.at(0) << endl;
  }
}

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

int main() {
  string s;
  cin >> s;
  int a = 0, ans = 0;
  for(int i=0;i<s.size();i++){
    if(s[i] == 'R') a++;
    if (s[i] == 'S') a=0;
    if(ans < a) ans = a;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3624
import sys
from bisect import bisect_right

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60


def main():
    N, *A = map(int, read().split())

    A.reverse()

    dp = [A[0]]
    for a in A[1:]:
        if a >= dp[-1]:
            dp.append(a)
        else:
            dp[bisect_right(dp, a)] = a

    print(len(dp))
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 14092
N, K = map(int, input().split())
dice = list(map(int, input().split()))
ma = 0
kitai = [0]*N
for i in range(N):
    kitai[i] = (((dice[i]+1)*dice[i])/2)/dice[i]
for i in range(K):
    ma += kitai[i]
tmp = ma
for i in range(K,N):
    tmp = tmp - kitai[i-K] + kitai[i]
    ma = max(tmp,ma)
print(ma)

Measured memory_bytes: 25060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1e9 + 7;
const int maxn = 1e5 + 10;
ll A[maxn], inv[maxn];

int main() {
    int N;
    scanf("%d", &N);
    inv[1] = 1;
    for(int i = 2; i <= N; ++i) inv[i] = inv[mod % i] * (mod - mod / i) % mod;
    for(int i = 2; i <= N; ++i) inv[i] = (inv[i] + inv[i - 1]) % mod;
    ll ans = 0;
    for(int i = 1; i <= N; ++i) {
        scanf("%lld", A + i);
        ans = (ans + A[i] * (inv[i] + inv[N - i + 1] + mod - 1)) % mod;
    }
    for(int i = 1; i <= N; ++i) ans = ans * i % mod;
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std ;
typedef long long ll ;
const int maxn = 1e5 + 5 ;
int n , k ;
int main()
{
	scanf("%d%d" , &n , &k) ;
	int num = 0 ;
	while(n > 0)
	{
		n /= k ;
		num ++ ;
	}
	printf("%d\n" , num) ;
    return 0 ;
}

Measured memory_bytes: 256