akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <numeric>
#include <stdio.h>
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
using ll = long long;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
int Max(int(a), int(b), int(c)) {
	return max(max(a, b), c);
}
int Min(int(a), int(b), int(c)) {
	return min(min(a, b), c);
}





int main() {
 
	ll A,B,C, an=0;
	cin >> A>>B>>C ;
	
	if (C <=A+ B) {
		an = C + B;
	}
	else {
		an = A + B+B+1;
	}
	cout << an << endl;
}

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

#define fi first
#define se second
#define sz(a) (int)(a).size()
#define all(a) (a).begin(), (a).end()
#define reset(a, v) memset((a), v, sizeof(a))

using namespace std;

typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<ii> vii;

int main() {
	int a, b; scanf("%d %d", &a, &b);
	if (a >= b) {
		for (int i = 0; i < a; i++) printf("%d", b);
	}
	else {
		for (int i = 0; i < b; i++) printf("%d", a);
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <stack>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <sstream>
#include <functional>
#include <ctime>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> PII;
typedef vector<int> VI;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)
#define CLEAR(d) memset((d), 0, (sizeof((d))))
#define ALL(c) (c).begin(), (c).end()
#define ABS(x) ((x < 0) ? -(x) : (x))
#define SORT(x) sort((x).begin(), (x).end())
#define RSORT(x) sort((x).begin(), (x).end(), greater<int>() )
#define SIZE(a) ((int)((a).size()))
#define MOD 1000000007
#define EPS 1e-7
#define PI  3.14159265358979323846
#define INF 100000000
struct edge { int to; int cost; };
//===================================================

int main()
{
    int n, a[100000];
    cin >> n;
    REP(i, n) cin >> a[i];
    int sum = ABS(a[n-1]);
    int p = 0;
    REP(i, n) {
        sum += ABS(a[i] - p);
        p = a[i];
    }
    REP(i, n) {
        int p1, p2, p3;
        if (i == 0) p1 = 0;
        else p1 = a[i - 1];
        if (i == (n - 1)) p3 = 0;
        else p3 = a[i + 1];
        p2 = a[i];

        int t = sum;
        t -= ABS(p1 - p2);
        t -= ABS(p2 - p3);
        t += ABS(p1 - p3);
        cout << t << endl;
    }
    return 0;
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    string pred; cin >> pred;
    string actual; cin >> actual;

    int ans = 0;
    for (int i = 0; i < pred.size(); i++) {
        if (pred[i] == actual[i]) {
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
//============================================================================
// Name        : あｂｃ59ｃ.cpp
// Author      : 
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include<algorithm>
#include<iostream>
#include<vector>
#include<string>
#include<queue>
#include<stack>
#include<cmath>
#include<list>
#include<set>
#include<map>

using namespace std;

int main() {
	int N;
	cin >> N;
	vector<long long> A(N);
	vector<long long> B(N);
	long long count1 = 0;
	long long count2 = 0;

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

	if(A[0] <= 0){
		B[0] = 1;
		count1 = abs(A[0]) + 1;
	}
	else{
		B[0] = A[0];
	}
	for(int i = 1; i < N; ++i){
		B[i] = A[i] + B[i - 1];
		if(i % 2 == 1 && 0 <= B[i]){
			count1 += abs(B[i]) + 1;
			B[i] = -1;
		}
		else if(i % 2 == 0 && B[i] <= 0){
			count1 += abs(B[i]) + 1;
			B[i] = 1;
		}
	}

	if(0 <= A[0]){
		B[0] = -1;
		count2 = abs(A[0]) + 1;
	}
	else{
		B[0] = A[0];
	}
	for(int i = 1; i < N; ++i){
		B[i] = A[i] + B[i - 1];
		if(i % 2 == 0 && 0 <= B[i]){
			count2 += abs(B[i]) + 1;
			B[i] = -1;
		}
		else if(i % 2 == 1 && B[i] <= 0){
			count2 += abs(B[i]) + 1;
			B[i] = 1;
		}
	}

	cout << min(count1, count2) << endl;

	return 0;
}


Measured memory_bytes: 1792
import numpy as np
import sys

X, Y, Z, K = map(int, input().split())
a = np.array(list(map(int, sys.stdin.readline().split())), dtype='int64')
b = np.array(list(map(int, sys.stdin.readline().split())), dtype='int64')
c = np.array(list(map(int, sys.stdin.readline().split())), dtype='int64')

d = (a + b.reshape([len(b), 1])).flatten()
d.sort()
e = (d[-K:] + c.reshape([len(c), 1])).flatten()
e.sort()

for ec in e[-K:][::-1]:
    print(ec)

Measured memory_bytes: 67264
#include <iostream>
#include <string>
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <vector>
#include <stdlib.h>

using namespace std;

int main() {
    int n,x;
    cin >> n >> x;
    int m[n],sum = 0,min = x;
    int reminds;
    for(int i = 0; i < n; i++) {
        cin >> m[i];
        sum += m[i];
        if(min > m[i]) {
            min = m[i];
        }
    }
    reminds = x - sum;
    cout << n + reminds/min;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a) for(int i = 0; i < a; i++)
#define all(v) v.begin(), v.end()
#define dcout cout << fixed << setprecision(15)
#define arep(i, a) for(auto i : a)
#define F first
#define S second
#define VE vector<int>
#define pb(x) push_back(x)
#define MOD 1000000007
#define INF 10000000000
#define int long long
#define KETA(n) floor(log10(n) + 1)
using namespace std;
signed main() {
    string s, t;
    cin >> s >> t;
    reverse(all(s));
    if(s == t)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256
N = gets.chop.to_i
S = gets.chop.split('')

r_count = S.count('R')
g_count = S.count('G')
b_count = S.count('B')

ans = r_count * g_count * b_count

(0..N).each do |i|
  (0..N).each do |d|
    j = i + d
    k = j + d

    break if k >= N

    if S[i] != S[j] && S[j] != S[k] && S[i] != S[k]
      ans -= 1
    end
  end
end

puts ans

# count = S.count
# ans = 0

# (0..count-3).each do |i|
#   (i+1..count-2).each do |j|
#     next if S[i] == S[j]
#     (j+1..count-1).each do |k|
#       next if j - i == k - j
#       a = S[i]
#       b = S[j]
#       c = S[k]
#       if b != c && a != c
#         ans += 1
#       end
#     end
#   end
# end

# puts ans


Measured memory_bytes: 14548
#include<cstdio>
using namespace std;

int gcd(int a, int b) {
	return b ? gcd(b, a % b) : a;
}
int x;
int main() {
	scanf("%d", &x);
	printf("%lld", 1ll * x * 360 / gcd(x, 360) / x);
}

Measured memory_bytes: 1732
#include <cstdio>
#include <vector>
using namespace std;

inline bool valid(int x){
	return 0 <= x && x <= 20;
}

int main()
{
	int N;
	scanf("%d\n", &N);

	vector<int> a(N);
	for(int i = 0; i < N; i++)
		scanf("%d", &a[i]);
	int answer = a.back(); a.pop_back();

	vector<vector<long long> > dp(a.size(), vector<long long>(21, 0));

	dp[0][a[0]] = 1;

	
	//左からi番目の穴に+か-を入れてjにするパターンは
	//a[i] + これまで = j or これまで - a[i] = j となる時のどちらか
	//<=> これまで = j - a[i] or これまで = j + a[i]
	//よってこれまでのパターン == dp[i - 1][j - a[i]] + dp[i - 1][j + a[i]]
	

	for(int i = 1; i < dp.size(); i++){
		for(int j = 0; j < 21; j++){
			if(valid(j - a[i]))
				dp[i][j] += dp[i - 1][j - a[i]];
			if(valid(j + a[i]))
				dp[i][j] += dp[i - 1][j + a[i]];
		}
	}

	printf("%lld\n", dp[dp.size() - 1][answer]);
	return 0;
}

Measured memory_bytes: 1064
#include "bits/stdc++.h"

#define REP(i,num) for(int i=0;i<(num);++i)
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

vector<string> split_naive(const string &s, char delim) {
	vector<string> elems;
	string item;
	for(char ch:s){
		if(ch==delim){
			if(!item.empty()) elems.push_back(item);
			item.clear();
		}
		else{
			item += ch;
		}
	}
	if(!item.empty()) elems.push_back(item);
	return elems;
}

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

	string S;
	map<string,int> M;
	while(cin>>S){
		auto SS=split_naive(S,',');
		M[SS[1]]++;
	}
	out(M["A"]);
	out(M["B"]);
	out(M["AB"]);
	out(M["O"]);
	return 0;
}


Measured memory_bytes: 3072
def main():
    n = int(input())
    C = [1, ]
    c = 6
    while c < 100000:
        C.append(c)
        c *= 6
    c = 9
    while c < 100000:
        C.append(c)
        c *= 9
    INF = float('inf')
    dp = [INF] * (n + 1)
    dp[0] = 0
    for i in range(1, n + 1):
        C_filtered = [c for c in C if c <= i]
        dp[i] = min([dp[i - c] + 1 for c in C_filtered])
    print(dp[n])
if __name__ == '__main__':
    main()


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

int main() {
  int n;
  cin>>n;
  map<string,vector<int>> c_n;
  multimap<int,int,greater<int>> p_n;
  rep(i,n){
    string s;
    int p;
    cin>>s>>p;
    c_n[s].push_back(i+1);
    p_n.insert(make_pair(p,i+1));
  }
  for(auto x : c_n){
      for(auto z : p_n){
        for(auto y : x.second){
          if(y==z.second){
            cout<<y<<endl;
          }
        }
      }
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>

using namespace std;

using ull_t = unsigned long long;

int main()
{
    short H, W;
    cin >> H >> W;
    
    vector<vector<short>> A(H, vector<short>(W));
    for (int y = 0; y < H; ++y)
        for (int x = 0; x < W; ++x)
            cin >> A[y][x];

    vector<tuple<int, int, int, int>> X;
    auto move = [&](int x1, int y1, int x2, int y2)
    {
        if (A[y1][x1] % 2 != 0)
        {
            ++A[y2][x2];
            --A[y1][x1];
            X.push_back(make_tuple(y1 + 1, x1 + 1, y2 + 1, x2 + 1));
        }
    };
    
    for (int y = 0; y < H; ++y)
    {
        int x = (y % 2 == 0) ? 0 : W - 1;
        int d = (y % 2 == 0) ? 1 : -1;
        for (; (x + d) >= 0 and (x + d) < W; x += d)
            move(x, y, x + d, y);
        if (y + 1 < H)
            move(x, y, x, y + 1);
    }

    cout << X.size() << endl;
    for (const auto &x : X)
        cout << get<0>(x) << " " << get<1>(x) << " "
             << get<2>(x) << " " << get<3>(x) << endl;
}


Measured memory_bytes: 4720
<?php

fscanf(STDIN, "%s %s", $n, $x);

//パン配列を作成
$arraypan = array();
for($i = 0; $i<$n; $i++){
	fscanf(STDIN, "%s", $m);
	array_push($arraypan,$m);
}

//一番安いパン
$minPanMoney = min($arraypan);
//持ち金 - パン１種類ずつ合わせた合計
$extraMoney = $x - array_sum($arraypan);
//余りのお金 / 一番安いパン
$buyCanPan = intval($extraMoney/$minPanMoney);

//買えるパンの合計個数
echo $n + $buyCanPan."\n";

Measured memory_bytes: 4604
#include<cstdio>
#include<cctype>
#define reg register
inline int read(){
	reg int x=0,f=1;reg char ch=getchar();
	for(;!isdigit(ch);f=ch=='-'?-1:1,ch=getchar());
	for(;isdigit(ch);x=(x<<3)+(x<<1)+(ch^48),ch=getchar());
	return x*f;
}
#define min(a,b) (a<b?a:b)
#define loop(a) (a<1?(n+a):a)
typedef long long ll;
ll a[2005],f[2005][2005],ans=1ll<<55;
int main(){
	reg int n=read(),x=read();
	for(reg int i=1;i<=n;i++)a[i]=f[i][0]=read();
	for(reg int i=1;i<=n;i++)
		for(reg int j=1;j<n;j++)
			f[i][j]=min(a[loop((i-j))],f[i][j-1]);
	for(reg int i=0;i<n;i++){
		ll t=x*1ll*i;
		for(reg int j=1;j<=n;j++)t+=f[j][i];
		ans=min(ans,t);
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 31488
#include<stdio.h>
#include<string.h>
int main()
{
    char a[20], b[20], c[20];
    scanf("%s %s %s", &a, &b, &c);
    int al, bl;
    al = strlen(a)-1;
    bl = strlen(b)-1;
    if(a[al]==b[0] && b[bl]==c[0])
    printf("YES");
    else printf("NO");
}


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

map<int, ll> memo;

ll fib(ll n){
    if(memo[n] == 0) memo[n] = fib(n-1) + fib(n-2);
    return memo[n];
}

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

    int n;
    cin >> n;

    memo[1] = 1;
    memo[0] = 1;
    cout << fib(n) << endl;

    return 0;
}


Measured memory_bytes: 3160
#include <cstdio>
#include <cstring>

char pr[200000];
int cnt[200000];
int main(void) {
    memset(pr, 1, sizeof(pr));
    pr[0] = pr[1] = 0;
    for(int i=2; i<150000; i++)
        for(int j=2; i*j<150000; j++)
            pr[i*j] = 0;
    for(int i=1; i<150000; i++)
        cnt[i] = cnt[i-1] + (pr[i] && pr[(i+1)/2]);

    int q;
    scanf("%d",&q);
    for(int i=0; i<q; i++) {
        int l,r;
        scanf("%d%d",&l,&r);
        printf("%d\n", cnt[r] - cnt[l-1]);
    }
}

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

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; }

using ll = long long;
using lb = long double;
using P = pair<ll,ll>;
using graph = vector<vector<ll>>;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const ll INF = 1LL<<60;
const ll mod = 1000000007LL;

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

struct mint {
    long long x;
public:
    mint(long long x=0) : x((x%mod+mod)%mod) {}
    mint operator-() const { 
      return mint(-x);
    }
    mint& operator+=(const mint& a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint& a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const  mint& a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint& a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint& a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint& a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    bool operator <(const mint& r){return this->x<r.x;}
    void operator++() {
        x++;
    }
    void operator--() {
        x--;
        if(x<0) x += mod;
    }
    // for prime mod
    mint inv() const {
        return pow(mod-2);
    }
    mint& operator/=(const mint& a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint& a) const {
        mint res(*this);
        return res/=a;
    }

    friend ostream& operator<<(ostream& os, const mint& m){
        os << m.x;
        return os;
    }
};

int main() {
  ll N;
  cin>>N;
  vector<mint> v(N);
  rep(i,N) cin>>v[i].x;
  sort(v.begin(),v.end());
  mint ans;
  ans.x = 0;
  mint K = 2;
  K = K.pow(N-1);
  rep(i,N){
    ans += K*((mint)i+(mint)2)*v[N-1-i];
  }
  ans *= K;
  cout<<ans<<endl;
}

Measured memory_bytes: 4816
#include<cstdio>

int getNeed(long long len,long long k){
    if(len==0) return 0;
    long long l = 1, r = len;
    long long res = -1;
    while(l<=r){
        long long m = (l+r)/2;
        long long have = -1;
        if(m==1) have = k;
        else have = (m-1)*(k-1)+k;
        if(have>=len){
            res = m;
            r = m-1;
        }
        else l = m+1;
    }
    return res;
}

int main(){
    int n,k;
    scanf("%d%d",&n,&k);
    int p = -1;
    for(int i = 1; i <= n; i++){
        int u;
        scanf("%d",&u);
        if(u==1) p = i;
    }
    int start = p-k+1, end = p;
    if(start<1) start = 1;
    if(end>n) end = n;
    int ans = n;
    //printf("start = %d, end = %d\n",start,end);
    for(int i = start; i <= end; i++){
        int cur = 1;
        if(i>1) cur += getNeed(i,k);
        if(i+k-1<n) cur += getNeed(n-(i+k-1)+1,k);
        if(cur<ans) ans = cur;
    }
    printf("%d\n",ans);
    return 0;
}


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

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

    double m = (a + b) / 2.0;
    double m_ = (int)m + 0.5;
    if(m >= m_){
        cout << (int)m + 1 << endl;
    }else{
        cout << (int)m << endl;
    }

    return EXIT_SUCCESS;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define RI(X) scanf("%d", &(X))
#define RII(X, Y) scanf("%d%d", &(X), &(Y))
#define RIII(X, Y, Z) scanf("%d%d%d", &(X), &(Y), &(Z))
#define DRI(X) int (X); scanf("%d", &X)
#define DRII(X, Y) int X, Y; scanf("%d%d", &X, &Y)
#define DRIII(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)
#define RS(X) scanf("%s", (X))
#define CASET int ___T, case_n = 1; scanf("%d ", &___T); while (___T-- > 0)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define PII pair<int,int>
#define VI vector<int>
#define VPII vector<pair<int,int> >
#define PLL pair<long long,long long>
#define VPLL vector<pair<long long,long long> >
#define F first
#define S second
typedef long long LL;
using namespace std;
const int MOD = 1e9+7;
const int SIZE = 1e6+10;
char s[24]="FESTIVAL";
LL up[8],d[8];
void get(int id,LL v){
    if(!id){
        while(d[id]<v){
            printf("F");
            d[id]++;
        }
        return;
    }
    while(d[id]<v){
        if(d[id-1]<d[id]&&d[id-1]<up[id-1]){
            get(id-1,d[id]);
        }
        printf("%c",s[id]);
        d[id]+=d[id-1];
    }
}
int main(){
    up[0]=256;
    d[0]=1;
    REPP(i,1,8)up[i]=up[i-1]*256,d[i]=1;
    LL K;
    cin>>K;
    REP(i,7)printf("%c",s[i]);
    while(K){
        int me=K&255;
        REP(i,me)printf("L");
        K-=me;
        K/=256;
        if(K){
            get(6,d[6]*256);
        }
    }
    puts("");
    return 0;
}


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

int main() {
	int ansa=0,ansb=0,ans;
	string os,s;
	char m;
	cin >> os;
	m = '0';
	s = os;
	for (int i = 0; i < (int)s.size(); i++) {
		if (s[i] == m) {
			if (m == '0') {
				s[i] = '1';
			}
			else {
				s[i] = '0';
			}
			ansa++;
		}
		m = s[i];
		
	}
	m = '1';
	s = os;
	for (int i = 0; i <(int) s.size(); i++) {
		if (s[i] == m) {
			if (m == '0') {
				s[i] = '1';
			}
			else {
				s[i] = '0';
			}
			ansb++;
		}
		m = s[i];

	}
	if (ansa > ansb) {
		ans = ansb;
	}
	else {
		ans = ansa;
	}
	
	cout << ans<< endl;
}

Measured memory_bytes: 512
use std::cmp::*;
use std::collections::BTreeSet;
use std::io::*;
use std::str::FromStr;
//portable utility
#[allow(dead_code)]
fn switch<T>(flag: bool, true_value: T, false_value: T) -> T {
    if flag {
        true_value
    } else {
        false_value
    }
}
#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}
#[allow(dead_code)]
fn read_string() -> Vec<char> {
    read::<String>().chars().collect()
}
#[allow(dead_code)]
fn read_vector<T: FromStr>(number: usize) -> Vec<T> {
    (0..number).map(|_| read()).collect()
}
fn main() {
    let r: f32 = read();
    println!("{}", 2.0 * r * std::f32::consts::PI);
}


Measured memory_bytes: 2148
import itertools
N = int(input())
z = []
for i in range(N):
  x,y = map(int,input().split())
  z.append((x,y))
ALL = 1
for i in range(N):
  ALL *= (i+1)
base = [i for i in range(N)]
A = list(itertools.permutations(base,N))
SUM = 0

def distance(a,b):
  ax = a[0]; ay = a[1]
  bx = b[0]; by = b[1]
  dis = ((ax-bx)**2 + (ay-by)**2)**(0.5)
  return dis

for X in A:
  now = z[X[0]]
  for i in range(1,N):
    nxt = z[X[i]]
    dif = distance(now,nxt)
    #print(dif)
    SUM += dif
#print(SUM,ALL)
ans = SUM/ALL
print(ans)

Measured memory_bytes: 13792
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.0000001
using namespace std;

int main(){

	int H,N;
	scanf("%d %d",&H,&N);

	bool** check = new bool*[H];
	int** dp = new int*[H];

	for(int i = 0; i < H; i++){
		check[i] = new bool[4];
		dp[i] = new int[5];
		for(int k = 0; k < 4; k++){
			check[i][k] = true;
		}
		for(int k = 0; k < 5; k++){
			dp[i][k] = 0;
		}
	}

	int x,y;

	for(int i = 0; i < N; i++){
		scanf("%d %d",&x,&y);
		check[y][x] = false;
	}

	for(int i = 1; i <= H-1; i++){

		dp[i][0] = dp[i-1][0];
		if(check[i-1][0] == true && check[i-1][1] == true && check[i][0] == true && check[i][1] == true){
			dp[i][1] = dp[i-1][0]+1;
		}
		if(check[i-1][1] == true && check[i-1][2] == true && check[i][1] == true && check[i][2] == true){
			dp[i][2] = dp[i-1][0]+1;
		}
		if(check[i-1][2] == true && check[i-1][3] == true && check[i][2] == true && check[i][3] == true){
			dp[i][3] = dp[i-1][0]+1;
		}
		if(check[i-1][0] == true && check[i-1][1] == true && check[i-1][2] == true && check[i-1][3] == true &&
				check[i][0] == true && check[i][1] == true && check[i][2] == true && check[i][3] == true){
			dp[i][4] = dp[i-1][0]+2;
		}


		dp[i][0] = max(dp[i][0],dp[i-1][1]);
		if(check[i-1][2] == true && check[i-1][3] == true && check[i][2] == true && check[i][3] == true){
			dp[i][3] = max(dp[i][3],dp[i-1][1]+1);
		}


		dp[i][0] = max(dp[i][0],dp[i-1][2]);


		dp[i][0] = max(dp[i][0],dp[i-1][3]);
		if(check[i-1][0] == true && check[i-1][1] == true && check[i][0] == true && check[i][1] == true){
			dp[i][1] = max(dp[i][1],dp[i-1][3]+1);
		}


		dp[i][0] = max(dp[i][0],dp[i-1][4]);
	}

	int ans = 0;
	for(int i = 0; i < 5; i++)ans = max(ans,dp[H-1][i]);

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

	return 0;
}

Measured memory_bytes: 3992
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i <= (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(ll i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

ll n, m;
string s, t;

int main(){
	cin.tie(0); ios::sync_with_stdio(false);
	
	cin >> s >> t;
	cout << t << s << endl;
	return 0;
}

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

const int INF  = 1e9;
const long long INFLL = 1e18;
const int NMAX = 200005;
const int MMAX = 100005;
const int KMAX = 1005;
const int MOD  = 1e9 + 7;
using namespace std;

// comment to disable debug functions
#define DEBUG

// frequently used macros

#define FORi(N) for(ll i = 0; i < N; ++i)
#define FORj(N) for(ll j = 0; j < N; ++j)
#define FORk(N) for(ll k = 0; k < N; ++k)

#if __cplusplus >= 201103L
#define ALL(v) begin(v),end(v)
#define SORT(v) sort(begin(v), end(v))
#define FIND(v,x) find(begin(v), end(v), (x))
#else
#define ALL(v) (v).begin(),(v).end()
#define SORT(v) sort(v.begin(), v.end())
#define FIND(v,x) find(v.begin(), v.end(), (x))
#endif

#define fi first
#define se second

#define MEMNEXT(from, to) do{ memmove((to), (from), sizeof(from)); \
memset((from), 0, sizeof(from)); } while(0)
#ifdef DEBUG
#define DUMP(x) do{ std::cerr << (#x) << ": " << x << std::endl; }while(0)
#else
#define DUMP(x) do{}while(0)
#endif

// frequent used aliases
typedef long long ll;
typedef pair<int, int> p;
typedef pair<ll, int> lp;
typedef pair<ll, ll> llp;
typedef vector<int> vec;
typedef vector<ll> vecll;
typedef vector<vec> mat;
typedef vector<vecll> matll;

// frequently used constants
static const int di[] = {-1, 0, 1, -1, 1, -1, 0, 1};
static const int dj[] = {-1, -1, -1, 0, 0, 1, 1, 1};

// frequently used structs
struct edge{
  int to,cost;
};

// printf for debug
#ifndef DEBUG
void debug(const char* format, ...){}
#else
void debug(const char* format, ...){
  va_list arg;
  va_start(arg, format);
  vprintf(format, arg);
  va_end(arg);
}
#endif

// dump vector
#ifdef DEBUG
#define DUMPV(v, c) do{       \
  printf("%s: ", #v);         \
  for (int i = 0; i < (c); ++i) \
  {                           \
  cout << (v)[i] << " ";      \
  }                           \
  cout << endl;               \
} while(0)
#else
#define DUMPV(v,c)
#endif

// std::fill of multi dimensions
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
  std::fill( reinterpret_cast<T*>(array),
             reinterpret_cast<T*>(array+N),
             val );
}

// binary search
ll BSearch(ll ok, ll ng, bool (*f)(ll)){
  ll mid;
  while(abs(ok - ng) > 1LL) {
    mid =  (ok + ng) / 2LL;
    if(f(mid)) {
      debug("BSearch: f(%d) == true\n", mid);
      ok = mid;
    }
    else
    {
      debug("BSearch: f(%d) == false\n", mid);
      ng = mid;
    }
  }
  return ok;
}

ll NUM_TEST_CASE = 1;

ll N,M,K,A[NMAX],B,C,D,E;
int dp[NMAX] = {};

string S;
vec v;

ll ans = {};

void solve(){
  // main algorithm
  ll high = 0;
  FORi(N) {
    ans += max(high - A[i], 0LL);
    high = max(high, A[i]);
  }
}
void debug(){
  // output debug information

}
void answer(){
  // output answer
  cout << ans << endl;
}
void init(){
  // initialize for each test case
  // Fill(dp, -1);
}
int main(int argc, char const *argv[])
{
  // operate inputs

  // cin >> NUM_TEST_CASE;

  for (int test_case = 0; test_case < NUM_TEST_CASE; ++test_case)
  {
    init();

    cin >> N;
    FORi(N) cin >> A[i];
    solve();
    #ifdef DEBUG
    debug();
    #endif
    answer();
  }

  return 0;
}

Measured memory_bytes: 5180
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
const ll INF = 1e18;
#define print(x) cout << (x) << endl;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    cout << (n-1)*n/2 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <cstring>

using namespace std;

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

int main(){
    int t, n;
    int visit[200][200];
    while(cin >> t >> n, t){
        int x, y;
        memset(visit, -1, sizeof(visit));
        for(int i=0;i<n;i++){
            cin >> x >> y;
            visit[x+100][y+100] = 1;
        }
        cin >> x >> y;
        int res = 0;
        queue< pair<int, int> > qu; qu.push(make_pair(x+100,y+100));
        visit[x+100][y+100] = 0;
        while(!qu.empty()){
            pair<int,int> pr = qu.front(); qu.pop();
            int cx = pr.first, cy = pr.second;
            res++;
            if(visit[cx][cy] == t) continue;
            for(int i=0;i<6;i++){
                int nx = cx+dx[i], ny = cy+dy[i];
                if(visit[nx][ny]!=-1) continue;
                visit[nx][ny] = visit[cx][cy]+1;
                qu.push(make_pair(nx,ny));
            }
        }
        cout << res << endl;
    }
}



Measured memory_bytes: 3248
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <math.h>
#include <utility>
#include <tuple>
#include <map>
#include <stack>
#include <queue>
#include <ctype.h>
#include <iomanip>
#include <bitset>
#include <set>
#include <ios>
#include <cstdlib>
using namespace std;
using ll = long long;
int main() {
    int a; cin >> a;
    string s; cin >> s;
    if(a>=3200) cout << s << endl;
    else cout << "red" << endl;

    return 0;
}

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

#define int long long
#define fi first
#define se second
#define otp(n) cout << n;
#define ct(n) cout << n << endl;
#define cts(n) cout << n << " ";
#define cte cout << endl;
#define ctv(v) rep(i,(v).size()) ct(v[i])
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define repo(i,o,n) for(int i=o;i<n;i++)
#define repm(i,n) for(int i=n-1;i>=0;i--)
#define repv(i,v) for(int i=0;i<(v).size();i++)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end());
#define vdelete(v) (v).erase(unique(all(v)), (v).end());
#define pb(n) push_back(n);

int n,c[500],s[500],f[500],ans[500];

main() {
    cin >> n;
    rep(i,n-1) cin >> c[i] >> s[i] >> f[i];
    rep(i,n) {
        repo(j,i,n-1) {
            if (ans[i]<s[j]) ans[i] = s[j];
            else if (!(ans[i]%f[j]));
            else ans[i] = ans[i]+f[j]-(ans[i]%f[j]);
            ans[i] += c[j];
        }
    }
    rep(i,n) ct(ans[i])
}


Measured memory_bytes: 256
dp = [[0,1,0,0,1,0,0,1,0,0,1,0]]
K = int(input())
sum = 0
deg = 1
flag = False

def deg_runrun(sum,i,deg,K):
    if deg == 0:
        return
    if deg == 1:
        for j in range(i-1,i+2):
            sum += dp[deg][j]
            if sum == K: 
                print(j-1,end='')
                return

    for j in range(i-1,i+2):
        if sum + dp[deg][j] >= K:
            print(j-1,end='')
            deg_runrun(sum, j, deg-1, K)
            return
        sum += dp[deg][j]


while not flag:
    dp.append([0]*12)
    for i in range(1,11):
        dp[deg][i] = dp[deg -1][i-1]+dp[deg-1][i]+dp[deg -1][i+1] 
    for i in range(2,11):
        if sum + dp[deg][i] >= K:
            print(i-1,end='')
            deg_runrun(sum, i, deg-1, K)
            flag = True
            break
        sum += dp[deg][i]
    deg += 1

print('')


Measured memory_bytes: 3064
x,y,a,b,c = map(int,input().split())
p = list(map(int,input().split()))
q = list(map(int,input().split()))
r = list(map(int,input().split()))
p.sort(reverse = True)
q.sort(reverse = True)
a = p[:x] + q[:y] + r
a.sort(reverse = True)
print(sum(a[:(x+y)]))

Measured memory_bytes: 111852
n, k = map(int, input().split())
alist = list(map(int, input().split()))

visited = [-1] * n
order = []
idx = 0
num = 0
while True:
  if not visited[idx] == -1:
    break
  visited[idx] = num
  num += 1
  order.append(idx)
  idx = alist[idx]-1
if visited[idx] == 0:
  print(order[k%len(order)]+1)
else:
  kotei = order[:visited[idx]]
  kurikaesi = order[visited[idx]:]
  if k <= len(kotei):
    print(order[k]+1)
  else:
    k -= len(kotei)
    print(kurikaesi[k%len(kurikaesi)]+1)

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

long long divcnt(long long p,long long a){
    long long ret=0;
    while(p%a==0){
        p=p/a;
        ++ret;
    }
    return ret;
}

int main(){
    long long n,p;
    cin>>n>>p;
    long long a=min(p,(long long)1e6);
    long long cnt=0;
    long long ans=1;

    while (a>1) {
        if(p%a==0){
            if(divcnt(p,a)>=n){
                ans=a;
                break;
            }
        }
        --a;
    }
    if(n==1)ans=p;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
//  Author: Tanuj Johal
//  It's a show time, Enjoy your everyday.

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

using namespace std;
using namespace __gnu_pbds;

#define ll          long long
#define fio         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb          push_back
#define vi          vector<ll>
#define pp          push_pop
#define pll         pair<ll,ll>
#define in          insert
#define ini(a,n)    memset(a,n,sizeof(a))
#define ff          first
#define ss          second
#define inf         1e18
#define all(p)      p.begin(), p.end()
#define que_max     priority_queue <int>
#define que_min     priority_queue <int, vi, greater<int>>
#define print(a)    for(auto i:a){cout<<i<<" ";}
#define print1(a)   for(auto i:a){cout<<i.ff<<" "<<i.ss<<endl;}
#define run_time cout << "\nTIME = " << clock() - tt << endl; tt = clock();

typedef tree<pll, null_type, less<pll>, rb_tree_tag, tree_order_statistics_node_update> Set;
unordered_map<ll,set<ll>> g;
unordered_map<ll,ll> vis;
ll tt;
const ll mod = 1e9+7;

ll power(ll x,ll y,ll p){ll r=1;x=x%p;while(y>0){if(y&1)r=(r*x)%p;y=y>>1;x=(x*x)%p;}return r;}
const ll N = 2e5 + 10;
ll dx[4]={-1, +1, 0, 0};
ll dy[4]={0, 0, +1, -1};
bool imp = false;


void solve()
{

    ll n;
    double d;
    cin >> n >> d;
    ll ans = 0;

    for(ll i=0;i<n;i++)
    {
        ll a, b;
        cin >> a >> b;
        double x, kk;
        kk = ((double)a*a) + ((double )b*b);
        kk = (double )sqrt((double ) kk);
        if(kk <= d)
            ans ++;

    }

    cout << ans << endl;


}

int main()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
#endif
    fio
//    precompute();

    int t=1;
    if(imp) cin>>t;
    tt = clock();
    while(t--)
    {
        // cout<<"Case #"<<tc<<": ";
        g.clear();
        vis.clear();
        solve();
        // tc++;
    }
//    run_time;

}

Measured memory_bytes: 3868
#include<bits/stdc++.h>
#define pb push_back
using namespace std;
int main()
{
    int n,m,h[100005],i,a,b;
    cin>>n>>m;
    vector<int>g[100001];
    for(i=1; i<=n; i++)
    {
        cin>>h[i];
    }
    for(i=1; i<=m; i++)
    {
        cin>>a>>b;
        g[a].pb(b);
        g[b].pb(a);
    }
    int cnt,ans=0;
    for(i=1; i<=n; i++)
    {
        cnt=0;
        for(int j=0;j<g[i].size();j++)
        {
            int k=g[i][j];
            if(h[k]<h[i])
            {
                cnt++;
            }
        }
        if(cnt==g[i].size())
        {
            ans++;
        }
    }
    cout<<ans<<'\n';
    return 0;
}


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

#define mp       make_pair
#define mt	  make_tuple
#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

const int INF=1<<29;
const double EPS=1e-9;
const ll MOD = 1000000007;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};
struct union_find {
  std::vector<int> parent;
  int __size;
  union_find(int size_) : parent(size_, -1), __size(size_) {}
  void unite(int x, int y) {
    if ((x = find(x)) != (y = find(y))) {
      if (parent[y] < parent[x]) std::swap(x, y);
      parent[x] += parent[y];
      parent[y] = x;
      __size--;
    }
  }
  bool is_same(int x, int y) { return find(x) == find(y); }
  int find(int x) { return parent[x] < 0 ? x : parent[x] = find(parent[x]); }
  int size(int x) { return -parent[find(x)]; }
  int size() { return __size; }
};
const int MAX_N = 200010;
const int MAX_KL = 100000;

int N,K,L;
vector<int> result;
int main(){

  cin >> N >> K >> L;
  union_find ut1(N);
  union_find ut2(N);
  for (int i = 0; i < K; i++){
    int p,q;
    cin >> p >> q;
    p--,q--;
    //paths[p][q]++;
    //paths[q][p]++;
    ut1.unite(p, q);
  }

  for (int i = 0; i < L; i++){
    int r,s;
    cin >> r >> s;
    r--,s--;
    ut2.unite(r, s);
  }
  map<pii, int> cnt;
  for (int i = 0; i < N; i++){
    cnt[mp(ut1.find(i), ut2.find(i))]++;
  }
  result.resize(N);
  for (int i = 0; i < N; i++){
    result[i] = cnt[mp(ut1.find(i), ut2.find(i))];
  }
  for (int i = 0; i < N; i++){
    if (i != N - 1){
      cout << result[i] << " ";
    }else{
      cout << result[i] << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 14336
#include <cstdio>

const int maxn = 1e6 + 10;

int n, fnt, rar, q[maxn], ans, i, j;
char s[maxn], t[maxn];

int main() {
	scanf("%d%s%s", &n, s + 1, t + 1);
	j = 1;
	for (i = 1; i <= n; ++i) {
		if(s[i] != t[i]) {
			j = 0;
			break;
		}
	}
	if(j) {
		return !puts("0");
	}
	j = n + 1;
	for (i = n; i; --i) {
		if(!(j - 1 >= i && t[j - 1] == s[i])) {
			continue;
		}
		while(j - 1 >= i && t[j - 1] == s[i]) {
			--j;
		}
		while(fnt < rar && q[fnt] - rar + fnt >= j) {
			++fnt;
		}
		if(i < j) {
			q[rar++] = i;
			(rar - fnt > ans) && (ans = rar - fnt);
		}
	}
	return !printf("%d\n", j == 1 ? ans + 1 : -1);
}

Measured memory_bytes: 6016
#include<iostream>
#include<cstdio>
using namespace std;
int main(){
	int a,b,d,r;
	double f;
	cin>>a>>b;
	d=a/b;
	r=a%b;
	f=(double)a/(double)b;
	cout<<d<<" "<<r<<" ";
	printf("%.8lf\n", f);
	return 0;
}

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

int main(){

    int N;
    int l[2010];
    cin >> N;
    for(int i = 0; i < N; i++) cin >> l[i];

    sort(l, l + N);

    long ans = 0;

    for(int i = 0; i < N - 2; i++){
        for(int j = i + 1; j < N - 1; j++){
            int tmp = l[i] + l[j];
            for(int k = j + 1; k < N; k++){
                if (tmp > l[k]){
                    ans++;
                } else {
                    break;
                }
            }
        }
    }

    cout << ans << "\n";

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
int n, b[200000][2] = {0}, c[200000] = {0}, d[200000] = {0}, e[200000] = {0};
int t = 0;
int compare_int(const void *a, const void *b)
{
  return *(int*)a - *(int*)b;
}
int main(void){
  scanf("%d", &n);getchar();
  for(int i = 0;i < n; i++){
    scanf("%d %d", &b[i][1], &b[i][0]);getchar();
  }
  for(int i = 0; i < n; i++){
    c[i] = i;
  }
  qsort(b, n, sizeof(int) * 2, compare_int);
  
  for(int i = 0; i < n; i++){
    d[i] = b[c[i]][1];
    e[i] = b[c[i]][0];
  }
  for(int i = 0; i < n; i++){
    t += d[i];
    if(t > e[i]){
    	printf("No\n");
      return 0;
    }
  }
  printf("Yes\n");
  return 0;
}

Measured memory_bytes: 4092
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<functional>
#include<map>
#include<cstdlib>
#include<complex>
#include<numeric>
#include<set>
#include<deque>
#include<queue>

using namespace std;
using Int = long long;
Int INF = 1LL << 60;
const Int MOD = 1000000000 + 7;

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	Int n, k;
	cin >> n >> k;

	n = n % k;
	Int temp = -(n - k);

	cout << min(n,temp) << "\n";
}


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

using namespace std;

int main() {
  string S;
  int Q;
  cin >> S >> Q;
  deque<char> str;
  for (int i = 0; i < S.length(); i++) {
    str.push_back(S[i]);
  }
  bool rev = false;
  for (int q = 0; q < Q; q++) {
    int T;
    cin >> T;
    if (T == 1) {
      rev = !rev;
    } else {
      int f;
      char c;
      cin >> f >> c;
      f--;
      if (rev) f ^= 1;
      if (f) {
        str.push_back(c);
      } else {
        str.push_front(c);
      }
    }
  }
  if (rev) reverse(str.begin(), str.end());
  for (char c : str) {
    cout << c;
  }
  cout << endl;

  return 0;
}
/* vim:set fdm=marker: */


Measured memory_bytes: 896
#include <bits/stdc++.h>
#define GET_MACRO(_1,_2,_3,_4,_5,NAME,...) NAME
#define pr(...) GET_MACRO(__VA_ARGS__,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__)
#define pr1(a) (#a)<<"="<<(a)
#define pr2(a,b) pr1(a)<<", "<<pr1(b)
#define pr3(a,b,c) pr2(a,b)<<", "<<pr1(c)
#define pr4(a,b,c,d) pr3(a,b,c)<<", "<<pr1(d)
#define pr5(a,b,c,d,e) pr4(a,b,c,d)<<", "<<pr1(e)
#define int long long
#define double long double
using namespace std;
const int N = 100010;
const int INF = 1LL<<55;
const int mod = (1e9)+7;
const double EPS = 1e-8;
const double PI = 6.0 * asin(0.5);
typedef pair<int,int> P;
typedef long long ll;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
ostream& operator<<(ostream& o,P p){return o<<"("<<p.first<<","<<p.second<<")";}
istream& operator>>(istream& i,P &p){return i>>p.first>>p.second;}
ostream& operator<<(ostream& o,vector<auto> &a){int i=0;for(auto t:a)o<<(i++?" ":"")<<t;return o;}
istream& operator>>(istream& i,vector<auto> &a){for(auto &t:a)i>>t;return i;}
void prArr(auto a,string s=" "){int i=0;for(auto t:a)cout<<(i++?s:"")<<t;cout<<endl;}


signed main(){
  int n;
  cin>>n;
  vector<int> A(n);
  cin>>A;

  int mx = 0;
  for(int i=0;i<n;i++){
    int j = i;
    while(j < n && A[j] == 1) j++;
    Max(mx,j - i);
  }

  cout<<mx+1<<endl;

  
  return 0;
}



Measured memory_bytes: 3112
import java.util.Scanner

object Main {
  def main(args: Array[String]): Unit = {
    //nextLineとnextを同時に使ったら死ぬ
    val sc = new Scanner(System.in)
    val a, b, c, x, y = sc.nextInt()
    val max = math.max(x, y)

    var ans = Long.MaxValue
    for (i <- 0 to max * 2) {
      val aa = math.max(0, x - i)
      val bb = math.max(0, y - i)
      ans = math.min(ans, c * i * 2 + aa * a + bb * b)
    }

    println(ans)
  }

}


Measured memory_bytes: 27216
/*
 * src.cpp
 *
 *  Created on: 2016/07/27
 *      Author: joi
 */

#include <bits/stdc++.h>

using namespace std;

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

int main(){
	int x,y;
	do{
		cin>>x>>y;
		if (x || y){
			int ans=0;
			if (x<y) swap(x,y);
			while(y){
				x%=y;
				swap(x,y);
				ans++;
			}
			cout<<x<<" "<<ans<<endl;
		}
	}while (x || y);
	return 0;
}

Measured memory_bytes: 1160
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include<vector>
#include<iomanip>
#include<map>
#include <queue>
#include<cmath>
#include<cstdio>
#include<iomanip>


using namespace std;
using ll = long long int; 

int main(void){

    ll h, w;
    cin>>h>>w;
    ll sum = 0;

    if(h==1 || w==1){
        cout<<"1"<<endl;
        return 0;
    }

    for(ll i=0;i<h;i++){
        if(i%2==0) sum += (w/2)+w%2;
        else sum += w/2;
    }

    cout<<sum<<endl;
    return 0;

}

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

//记得修改scanf_s
int main()
{
	long int n,*a;
	scanf("%ld", &n);
	a = (long int *)malloc(n * sizeof(long int));
	for (int i = 0; i < n; i++)
		scanf("%ld", &a[i]);

	double sum = 0, sum1 = 0;
	for (int i = 0; i < n; i++)
		sum += a[i];

	long int min = fabs(2 * a[0] - sum);
	for (int i = 0; i < n - 1; i++)
	{
		sum1 += a[i];
		if (min > fabs(2 * sum1 - sum))
			min = fabs(2 * sum1 - sum);
	}
	printf("%ld\n", min);
	return 0;
}

Measured memory_bytes: 1664
#include <iostream>
#include <bitset>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
using namespace std;

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

int main()
{
    int N, M;
    cin >> N >> M;
    string A[N], B[M];
    REP(i, N)
    {
        cin >> A[i];
    }
    REP(i, M)
    {
        cin >> B[i];
    }
    bool exist = false;

    for(int i = 0; i < N; i++)
    {
        for(int j = 0; j < N; j++)
        {
            if (i+M-1 >= N or j+M-1 >= N) continue;
            
            bool match = true;
            for(int point_i = 0; point_i < M; point_i++)
            {
                for(int point_j = 0; point_j < M; point_j++)
                {
                    if (B[point_i][point_j] != A[i+point_i][j+point_j])
                    {
                        match = false;
                    }
                }
            }
            if(match) exist = true;
        }
    }
    
    if(exist)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#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 REPL(i,m,n) for(ll i=(ll)(m); i<(ll)(n); i++)
#define repl(i,n) REPL(i,0,n)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  vector<ll> A(N);
  rep(i, N) cin >> A[i];
  ll ans = longinf;
  ll tmp = 0;
  ll sum = accumulate(all(A), 0LL);
  rep(i, N-1) {
    tmp += A[i];
    ans = min(abs(sum-tmp-tmp), ans);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
unordered_set<int> s;
int main() {
int n; cin >> n;
for (int i = 0; i < n; i++) {
int a; cin >> a;
auto it = s.find(a);
if (it != s.end()) {
s.erase(a);
} else {
s.insert(a);
}
}
std::cout << s.size() << "\n";
}

Measured memory_bytes: 4388
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  map<string,int> a;
  int n = 0;
  for (int i; i<N; i++) {
    string S;
    cin >> S;
    if (i == 0) {
      a[S] = 1;
      n += 1;
    }
    else {
      if (a.count(S)) {
      }
      else {
        a[S] = 1;
        n += 1;
      }
    }
  }
  cout << n << endl;
}

Measured memory_bytes: 19220
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define REP(i,n) for(int i = 0; i <= n; i++)
#define FOR(i,j,n) for(int i = j; i < n; i++)
#define RFOR(i,j,n) for(int i = j-1; i >= n; i--)
#define PREC(n) fixed << setprecision(n)
#define print_array(v) REP(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define _LIBCPP_DEBUG 0
using namespace std;
int64_t MOD = 1000000007;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  if(n == 1) { cout << 1 << endl; return 0; }
  REP(i,n) {
    if(i*i > n) { cout << (i-1)*(i-1) << endl; return 0; }
  }
  return 0;
}
//templete by private_yusuke

Measured memory_bytes: 256