akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <vector>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <ctime>
#include <map>
#include <set>
#include <queue>
using namespace std;
#define lowbit(x) (x&(-x))
#define max(x,y) (x>y?x:y)
#define min(x,y) (x<y?x:y)
#define MAX 100000000000000000
#define MOD 1000000007
#define pi acos(-1.0)
#define ei exp(1)
#define PI 3.141592653589793238462
#define INF 0x3f3f3f3f3f
#define mem(a) (memset(a,0,sizeof(a)))
typedef long long ll;
ll gcd(ll a,ll b){
    return b?gcd(b,a%b):a;
}
const int N=100005;
const int mod=1e9+7;

int main()
{
    std::ios::sync_with_stdio(false);
    int a,b,c;
    while(cin>>a>>b>>c){
        int d=max(max(a,b),c);
        cout<<a+b+c-d<<endl;
    }
    return 0;
}


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

bool tl(vector<ll>&v1,vector<ll>&v2)
{
    if(v1[1]!=v2[1])
    return v1[1] < v2[1];
    return v1[0] < v2[0];
}

int main() {
    ll n,w,i,j,g,v,sum=0;
    cin>>n>>w;
    vector<vector<ll>>ma(n,vector<ll>(2,0));
    for(i=0;i<n;i++)
    {
        cin>>g>>v;
        sum+=v;
        ma[i][0]=g;
        ma[i][1]=v;
    }
    vector<vector<ll>>dp(n+1,vector<ll>(sum+1,0));
    //sort(ma.begin(),ma.end(),tl);
    for(i=0;i<dp.size();i++)
    {
        for(j=0;j<dp[0].size();j++)
        {
        dp[i][j]=INT_MAX;
        }
    }
    for(i=0;i<=n;i++)
    {
        dp[i][0]=0;
    }
    //cout<<sum<<endl;
    for(i=1;i<dp.size();i++)
    {
        for(j=1;j<dp[0].size();j++)
        {
            if(ma[i-1][1] > j)
            {
                dp[i][j]=dp[i-1][j];
            }
            else
            {
                dp[i][j]=min(dp[i-1][j],dp[i-1][j-ma[i-1][1]]+ma[i-1][0]);
            }
            //cout<<dp[i][j]<<" ";
        }
    }
    ll res=0;
    for(i=1;i<dp[0].size();i++)
    {
        if(dp[n][i]<=w)
        res=max(res,i);
    }
    cout<<res<<endl;
	return 0;
}


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

int main(){
    int A, B;
    cin >> A >> B;
    int ans = 0;
    for(int i = A; i <= B; i++){
        string string_i = to_string(i), reverse_i = to_string(i);
        reverse(reverse_i.begin(), reverse_i.end());
        ans += (string_i == reverse_i);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#ifdef xay5421
#define D(...) fprintf(stderr,__VA_ARGS__)
#else
#define D(...) ((void)0)
#define NDEBUG
#endif
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define per(i,a,b) for(int i=(a);i>=(b);--i)
using namespace std;
typedef long long LL;
const int N=250005,K=6,P=1e9+9,X[K]={137,197,101,103,107,109};
int n,key[K],iX[K],k[N][K],b[N][K];
LL ans;
map<vector<int>,int>mp;
int fpow(int k1,int k2){
	int k3=1;
	for(;k2;k2>>=1,k1=1LL*k1*k1%P)if(k2&1)k3=1LL*k3*k1%P;
	return k3;
}
void pt(const vector<int>&a){
	for(auto x:a)D("%d ",x);
	D("\n");
}
char s[N];
int main(){
#ifdef xay5421
	freopen("a.in","r",stdin);
#endif
	rep(i,0,K-1)iX[i]=fpow(X[i],P-2);
	scanf("%d%s",&n,s+1);
	per(i,n,1){
		rep(j,0,K-1){
			switch(s[i]){
				case'<':
					key[j]=1LL*key[j]*iX[j]%P;
					break;
				case'>':
					key[j]=1LL*key[j]*X[j]%P;
					break;
				case'+':
					key[j]=(key[j]+1)%P;
					break;
				case'-':
					key[j]=(key[j]+P-1)%P;
					break;
			}
		}
	}
	rep(j,0,K-1)k[n+1][j]=1;
	per(i,n,1){
		rep(j,0,K-1){
			k[i][j]=k[i+1][j];
			b[i][j]=b[i+1][j];
			switch(s[i]){
				case'<':
					k[i][j]=1LL*k[i][j]*X[j]%P;
					break;
				case'>':
					k[i][j]=1LL*k[i][j]*iX[j]%P;
					break;
				case'+':
					b[i][j]=(b[i][j]+P-k[i][j])%P;
					break;
				case'-':
					b[i][j]=(b[i][j]+k[i][j])%P;
					break;
			}
		}
	}
	auto get0=[&](int i){
		return vector<int>(b[i],b[i]+K);
	};
	auto get=[&](int i){
		vector<int>res(K);
		rep(j,0,K-1)res[j]=(1LL*k[i][j]*key[j]+b[i][j])%P;
		return res;
	};
	mp[get0(n+1)]=1;
	per(i,n,1){
		auto now=get(i);
		//pt(now);
		if(mp.count(now)){
			D("ans[%d]=%d\n",i,mp[now]);
			ans+=mp[now];
		}
		++mp[get0(i)];
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 42940
from math import gcd

K = int(input())
total = 0
for a in range(1, K + 1):
    for b in range(a, K + 1):
        d1 = gcd(a, b)
        for c in range(b, K + 1):
            d2 = gcd(d1, c)
            if a == b == c:
                total += d2
            elif a == b < c or a < b == c:
                total += d2 * 3
            elif a < b < c:
                total += d2 * 6
            else:
                assert False
print(total)

Measured memory_bytes: 9160
#include <cstdio>
#include <vector>
#include <algorithm>
#include <functional>
#pragma warning(disable : 4996)
using namespace std;
int N, W, w[100009], v[100009], cnt; vector<pair<double, int> > d1, d2;
double solve(double x) {
	double ret = 0.0, sum1 = 0.0, sum2 = 0.0;
	for (int i = 0; i < d1.size() && d1[i].first > 0.0; i++) {
		if (sum1 + d1[i].second < W + x) {
			ret += d1[i].first * d1[i].second;
			sum1 += d1[i].second;
		}
		else {
			ret += d1[i].first * (W + x - sum1);
			break;
		}
	}
	for (int i = 0; i < d2.size(); i++) {
		if (sum2 + d2[i].second < x) {
			ret += d2[i].first * d2[i].second;
			sum2 += d2[i].second;
		}
		else {
			ret += d2[i].first * (x - sum2);
			break;
		}
	}
	return ret;
}
int main() {
	scanf("%d%d", &N, &W);
	double sum = 0.0, sum2 = 0.0;
	for (int i = 0; i < N; i++) {
		scanf("%d%d", &w[i], &v[i]);
		if (w[i] == 0) sum += max(v[i], 0);
		if (w[i] > 0) d1.push_back(make_pair(1.0 * v[i] / w[i], w[i]));
		if (w[i] < 0) d2.push_back(make_pair(-1.0 * v[i] / w[i], -w[i])), sum2 -= w[i];
	}
	sort(d1.begin(), d1.end(), greater<pair<double, int> >());
	sort(d2.begin(), d2.end(), greater<pair<double, int> >());
	double l = 0.0, r = sum2;
	for (int i = 0; i < 90; i++) {
		double m1 = (l * 2.0 + r) / 3.0;
		double m2 = (l + r * 2.0) / 3.0;
		if (solve(m1) < solve(m2)) l = m1;
		else r = m2;
	}
	printf("%.10lf\n", solve(l) + sum);
	return 0;
}

Measured memory_bytes: 2964
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <string>
#include <cmath>
#include <queue>
#include <tuple>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <random>
#include <set>
#include <stack>
//#include <bits/stdc++.h>
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i,i0,n) for(int (i)=(i0);(i)<(n);(i)++)
#define FORR(i,i0,n) for(int (i)=(n)-1; (i)>=(i0);(i)--)
#define SORT(x) sort(x.begin(),x.end())
#define SORTR(x) sort(x.begin(),x.end(),greater<int>())
#define rn return
#define F first
#define S second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#include <time.h>

using namespace std;
using ll = long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;







int main(){
    string s;
    getline(cin, s); 
    int n = s.size();
    
    int f = s[0] - '0';
    
    vector<int> prev(2019,0);
    vector<int> next(2019,0);
    
    prev[f] = 1;
    
    int sum = 0;
    for(int i = 1; i < n;i++){
        int c = s[i] - '0';
        next = vector<int> (2019,0);
        next[c] = 1;
        for(int j = 0; j< 2019; j++){
            
            
            int count = prev[j];
            
            if (j==0){
                sum += count;
            }
            
            int nt = (10*j+c)%2019;
            next[nt] += count;
        }
        prev = next;
    }
    // cout << n << endl;
    // cout << prev.size() << endl;
    sum += prev[0];
    cout << sum;

}









Measured memory_bytes: 3752
import heapq as hq

n,k=map(int,input().split())
A=[]
S0=[] #種類が増えない寿司
S1=[] #種類が増える寿司
for i in range(n):
    t,d=map(int,input().split())
    A.append([t,d])
A=list(reversed(sorted(A)))

now=0
for i in range(n):
    t=A[i][0]
    d=A[i][1]
    if now==t:
        S0.append(-d)
    else:
        S1.append(-d)
        now=t
hq.heapify(S0)
hq.heapify(S1)
C=[] #消し得る寿司のストック(S0から出したもの)

x=0 #おいしさの合計
y=0 #種類数
for i in range(k):
    if len(S0)==0:
        x+=-hq.heappop(S1)
        y+=1
        continue
    if len(S1)==0:
        s0=-hq.heappop(S0)
        x+=s0
        hq.heappush(C,s0)
        continue
    if S1[0]<=S0[0]:
        x+=-hq.heappop(S1)
        y+=1
    else:
        s0=-hq.heappop(S0)
        x+=s0
        hq.heappush(C,s0)
ans=x+y**2

for i in range(min(len(S1),len(C))):
    c=hq.heappop(C)
    s1=-hq.heappop(S1)
    x+=s1-c
    y+=1
    ans=max(x+y**2,ans)
print(ans)

Measured memory_bytes: 24432
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		sc.close();

		int count = 0;
		int ans = 0;
		for(int i = 0; i <= 7; i++) {
			int tmp = (int) Math.floor(Math.pow(2, i));
			if(tmp <= N) {
				continue;
			}else {
				ans = (int) Math.floor(Math.pow(2, i - 1));
				break;
			}
		}
		System.out.println(ans);
	}

}

Measured memory_bytes: 23252
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#define FOR(i,k,n) for((i)=(k);(i)<(n);(i)++)
#define REP(i,n) for (int i=0;i<(n);i++)
#define pb push_back
#define all(a) (a).begin(),(a).end()  //greater<int>()
#define ll long long
using namespace std;

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

	REP(i,101){
		ans = (i*b + c)/a;
		if(ans-int(ans)==0){
			cout<<"YES"<<endl;
			return 0;
		}
	}

	cout<<"NO"<<endl;
   	return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.math.BigInteger; 

public class Main {
  
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
	BigInteger a = sc.nextBigInteger();
    BigInteger b = sc.nextBigInteger();
    BigInteger x = sc.nextBigInteger();
    BigInteger c = a.divide(x).add(BigInteger.valueOf(1));
    BigInteger d = b.divide(x).add(BigInteger.valueOf(1));
    BigInteger sa = d.subtract(c);
    
    if(a.mod(x).intValue() != 0){
      System.out.println(sa);
    } else{
      System.out.println(sa.add(BigInteger.valueOf(1))); 
    }
  }
}

Measured memory_bytes: 22996
n,k=map(int,input().split())
r,s,p=map(int,input().split())
t=list(input())

# d={'r':0,'s':0,'p':0}
d={}
ans=0
c=0
for i in t:

    if c >= k:
        x =d[c-k]
        y = c+k
        if i =='r':
            if x == 'p':
                if  y < n and t[y] == 's':
                    d[c]='s'
                else:
                    d[c]='r'
            else:
                ans += p ; d[c]='p'
        elif i == 's': 
            if x == 'r':
               if y < n and t[y] == 'p' :
                    d[c]='p'
               else:
                    d[c]='s'
            else:
                ans += r;d[c]='r'
        elif i == 'p': 
            if x == 's':
               if  y < n and t[y] == 'r':
                    d[c]='r'
               else:
                    d[c]='p'
            else:
                ans += s;d[c]='s'

    else:
        if i =='r':
            ans += p ; d[c]='p'
        elif i == 's': 
            ans += r;d[c]='r'
        elif i == 'p': 
            ans += s;d[c]='s'

    c+=1


print(ans)

Measured memory_bytes: 56076
#include<stdio.h>
int m,n,i,j,a[91][91],max;
int func(int,int,int);
int main(void)
{
	while(1){
		scanf("%d %d",&m,&n);
		if(n==0&&m==0) break;
		for(i=0;i<n;i++){
			for(j=0;j<m;j++){
				scanf("%d",&a[i][j]);
			}
		}
		max=0;
		for(i=0;i<n;i++){
			for(j=0;j<m;j++){
				if(a[i][j]==1){
					func(i,j,0);
				}
			}
		}
		printf("%d\n",max);
	}
}
int func(int x,int y,int cnt){
	if(x+1<n&&a[x+1][y]==1){
		a[x+1][y]=0;func(x+1,y,cnt+1);
		a[x+1][y]=1;
	}
	if(y+1<m&&a[x][y+1]==1){
		a[x][y+1]=0;func(x,y+1,cnt+1);
		a[x][y+1]=1;
	}
	if(x-1>=0&&a[x-1][y]==1){
		a[x-1][y]=0;func(x-1,y,cnt+1);
		a[x-1][y]=1;
	}
	if(y-1>=0&&a[x][y-1]==1){
		a[x][y-1]=0;func(x,y-1,cnt+1);
		a[x][y-1]=1;
	}
	if(max<cnt) max=cnt;
}


Measured memory_bytes: 2696
import collections

N = int(input())
s = []
for i in range(N):
    s.append(input())

c = collections.Counter(s)

print(f"AC x {c['AC']}")
print(f"WA x {c['WA']}")
print(f"TLE x {c['TLE']}")
print(f"RE x {c['RE']}")

Measured memory_bytes: 16612
#include <string>
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <stdlib.h>
#include <algorithm>
#include <list>
#include <math.h>
#include<string.h>
#define reps(i,j,k) for(int i=(j);i<(k);i++)
#define rep(i,j) reps(i,0,j)

//	rep(i,10)cout << i << endl;
using namespace std;

int main(void){
	int n;
	cin >> n;
	cout << 180 * (n-2) << endl;
	return 0;
}

Measured memory_bytes: 256
N = int(input())
C = [input() for i in range(N)]


ACcnt = C.count("AC")
WAcnt = C.count("WA")
TLEcnt = C.count("TLE")
REcnt = C.count("RE")

print('AC x ' + str(ACcnt))
print('WA x ' + str(WAcnt))
print('TLE x ' + str(TLEcnt))
print('RE x ' + str(REcnt))

Measured memory_bytes: 16272
#include <stdio.h>

char chk(char *a){
  char b[]={'o','x'},c;
  int i,j;
  for(i=0;i<2;i++){
    c=b[i];
    if((a[0]==c && a[4]==c && a[8]==c) || (a[2]==c && a[4]==c && a[6]==c)) return c;
    for(j=0;j<3;j++) if((a[j]==c && a[j+3]==c && a[j+6]==c) || (a[j*3]==c && a[j*3+1]==c && a[j*3+2]==c)) return c;
  }
  return 'd';
}

int main(){
  char a[81];

  while(fgets(a,80,stdin)!=NULL){
    printf("%c\n",chk(a));
  }
  return 0;
}

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

using namespace std;

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

    if(s[s.size() - 1] == 's') {
        cout << (s.substr(0, s.size()) + "es") << endl;
    } else {
        cout << (s.substr(0, s.size()) + "s") << endl;
    }
    return 0;
}

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

long max(long xs[], int size) {
  long result = xs[0];
  for (int i = 1; i < size; i++) {
    if(result < xs[i])
      result = xs[i];
  }
  
  return result;
}

long min(long xs[], int size) {

  long result = xs[0];
  for (int i = 1; i < size; i++) {
    if(result > xs[i])
      result = xs[i];
  }
  
  return result;
}

long sum(long xs[], int size) {
  long result = 0;
  for (int i = 0; i < size; i++) {
      result += xs[i];
  }
  
  return result;
}

int main(int argc, char *argv[])
{
  int n;
  cin >> n;
  long xs[n];

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

  cout << min(xs,n) << " " << max(xs,n) << " " << sum(xs,n) << "\n";
  return 0;
}

Measured memory_bytes: 3112
import java.util.*;

public class Main {
	static final int INF = Integer.MAX_VALUE/2;
	static final int mod = (int)1e9+7;
	static int n, c[], cnt, ans[], score;
	static List<Integer>[] graph;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		graph = new ArrayList[n];
		for(int i=0;i<n;i++) graph[i] = new ArrayList<>();
		for(int i=0;i<n-1;i++) {
			int a = sc.nextInt()-1, b = sc.nextInt()-1;
			graph[a].add(b);
			graph[b].add(a);
		}
		c = new int[n];
		for(int i=0;i<n;i++)c[i] = sc.nextInt();
		sc.close();
		Arrays.sort(c);
		cnt = 0;
		ans = new int[n];
		dfs(0,-1);
		StringBuilder sb = new StringBuilder();
		for(int i=0;i<n;i++) {
			sb.append(ans[i] + " ");
		}
		score -= c[n-1];
		System.out.println(score);
		System.out.println(sb.toString());
	}
	
	static void dfs(int v, int p) {
		for(int to:graph[v]) {
			if(to==p)continue;
			dfs(to, v);
		}
		ans[v] = c[cnt++];
		score += ans[v];
	}	
}

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

#define debug(x) cerr << #x << ": " << x << endl
#define debugArray(x, n)                                                       \
    for(long long hoge = 0; (hoge) < (n); ++(hoge))                            \
    cerr << #x << "[" << hoge << "]: " << x[hoge] << endl
using namespace std;

using ll = long long;
using ull = unsigned long long;
const ll INF = LLONG_MAX / 2;
const ll MOD = 1e9 + 7;

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    int N, T;
    cin >> N >> T;
    ll A[N], B[N];
    for(int i = 0; i < N; i++) {
        cin >> A[i] >> B[i];
    }
    ll dp1[N + 1][T] = {}, dp2[N + 1][T] = {};
    for(int i = 0; i < N; i++) {
        for(int t = T - 1; t >= 0; t--) {
            dp1[i + 1][t] = dp1[i][t];
            if(t >= A[i])
                dp1[i + 1][t] = max(dp1[i + 1][t], dp1[i][t - A[i]] + B[i]);
        }
    }
    for(int i = N - 1; i >= 0; i--) {
        for(int t = T - 1; t >= 0; t--) {
            dp2[i][t] = dp2[i + 1][t];
            if(t >= A[i])
                dp2[i][t] = max(dp2[i][t], dp2[i + 1][t - A[i]] + B[i]);
        }
    }
    ll ans = 0;
    for(int i = 0; i < N; i++) {
        for(int t = 0; t < T; t++) {
            ans = max(ans, dp1[i][t] + dp2[i + 1][T - 1 - t] + B[i]);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 141056
N = int(input())

answer = {(i-1)*i//2:i for i in range(2,500)}

from itertools import combinations


if N not in answer:
  print('No')
  exit()

else:
  print('Yes')

  k = answer[N]
  S = [set() for _ in range(k)]
  for i, c in enumerate(combinations(S,2)):
    for s in c:
      s.add(i+1)

  print(len(S))
  for s in S:
    print(str(len(s)) + ' ' + ' '.join(map(str, list(s))))

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

// @@ !! LIM()

int main(int argc, char *argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  vector<ll> vec(8);
  ll free = 0;
  ll N; cin >> N;
  for (ll i = 0; i < N; i++) {
    ll a; cin >> a;
    if (a >= 3200) free++;
    else vec.at(a / 400) = 1;
  }
  ll cnt = 0;
  for (ll i = 0; i < 8; i++) { cnt += vec.at(i); }
  cout << max(cnt, 1LL) << " " << cnt + free << endl;

  return 0;
}



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

int main()
{   
    int A, B, C, D;
    cin >> A >> B >> C >> D;
    bool taka = false;
    while((A>0)&&(C>0)){
        C-=B;
        if(C<=0){taka = true; break;}
        A-=D;
        if(A<=0){break;}
    }
    if(taka){
        std::cout << "Yes" << std::endl;
    }else{
        std::cout << "No" << std::endl;
    }
    return 0;
}


Measured memory_bytes: 3624
//C.cpp
#include <iostream>
#include <string>
using namespace std;

bool graph[60][60] = {false};
bool vis[60] = {false};
int N,M;

void dfs(int i);

int main(){
  cin >> N >> M;
  int a[60],b[60];
  for(int i = 0; i < M; i++){
    cin >> a[i] >> b[i];
    graph[a[i]-1][b[i]-1] = graph[b[i]-1][a[i]-1] = true;
  }

  int cnt = 0;

  for(int i = 0; i < M; i++){
    graph[a[i]-1][b[i]-1] = graph[b[i]-1][a[i]-1] = false;
    for(int j = 0; j < N; j++) vis[j] = false;
    dfs(0);
    bool connected = true;
    for(int j = 0; j < N; j++){
      if(!vis[j]){
        connected = false;
        break;
      }
    }
    if(!connected) ++cnt;
    graph[a[i]-1][b[i]-1] = graph[b[i]-1][a[i]-1] = true;
  }

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

}

void dfs(int i){
  vis[i] = true;
  for(int j = 0; j < N; j++){
    if(graph[i][j]&&!vis[j]) dfs(j);
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fastIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define trace1(x)                cout<<#x<<": "<<x<<endl
#define trace2(x, y)             cout<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cout<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define debugVec(vec) cout<<(#vec)<<": "; for (auto& i: vec) cout<<i<<" "; cout<<endl
#define pb push_back
#define ff first
#define ss second
#define all(v) (v).begin(), (v).end()
#define mod (int)(1e9+7)
using namespace std;
#define trace(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args);cout << endl; }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << " ";
    err(++it, args...);
}
signed main(){
	fastIO

    int r;
    cin >> r;
    cout << 2*r*(3.14);


    return 0;

}


Measured memory_bytes: 3804
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#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 rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define rev(v) reverse(v.begin(), v.end())
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
//const int64 INF = 1LL << 58;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
#define OK { cout << "OK" << endl; return 0; }
#define NG { cout << "NG" << endl; return 0; }
#define sz(v) ((int)(v).size())
#define uniq(a) sort(all(a));(a).resize(unique(all(a)) - a.begin());
#define dab(v) for(auto i:v)cout<<i<<' '; cout << endl;
#define vin(v) for (ll i = 0; i < v.size(); ++i) cin >> v[i];
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 (a>b) { a=b; return 1; } return 0; }
template<class T>void out(T a){cout << a << endl;}
template<class T>void die(T a){cout << a << endl; exit(0);}
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};

#define SIZE 200005
#define MOD 1000000007
 
typedef pair <int,int> P;
 
ll inv[SIZE], fac[SIZE], finv[SIZE];
void make(){
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for(int i=2; i<SIZE; i++)
	{
		inv[i] = MOD - inv[MOD%i]*(MOD/i)%MOD;
		fac[i] = fac[i-1] * (ll) i % MOD;
		finv[i] = finv[i-1] * inv[i] % MOD;
	}
    return ;
}
ll comb(int a,int b){
	if(a < b) return 0;
	return fac[a] * (finv[b] * finv[a-b] % MOD) % MOD;
}

ll beki(int a, int n){
    if(n == 0) return 1;
    ll ans = beki(a, n / 2);
    ans = ans * ans;
    if(n % 2 == 1) ans = ans * a;
    return ans;
}


int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
    //cout << fixed << setprecision(15);
    
    int N,K;cin>>N>>K;
    vi cnt(N,0);
    vi d(N);
    rep(i,K) {
        cin>>d[i];
        rep(j,d[i]){
            int a;cin>>a;
            cnt[a-1]++;
        }
    }
    int ans = 0;
    rep(i,N){
        if(cnt[i] == 0) ans++;
    }
    out(ans);

}

Measured memory_bytes: 3680
#include<cstdio>
#include<utility>
#include<cstring>
#include<set>
using namespace std;
typedef long long LL;
typedef pair < int , int > pii;
typedef set < pair < int , int > > spii;
#define mp make_pair
#define fs first
#define sc second
spii stt;
int n,m;
int main(){
	scanf("%d%d",&n,&m);
	int xb,x2,a,b;
	for(xb=0;xb<m;xb++){
		scanf("%d%d",&a,&b);
		stt.insert(mp(a,b));
		stt.insert(mp(b,a));
	}
	for(x2=2;x2<n;x2++){
		if(stt.find(mp(1,x2))!=stt.end() && stt.find(mp(x2,n))!=stt.end()){
			printf("POSSIBLE\n");
			return 0;
		}
	}
	printf("IMPOSSIBLE\n");
	return 0;
}

Measured memory_bytes: 18944
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    int n;
    cin>>n;
    ll a[n];
    ll sum=0;
    unordered_map<ll, ll> mp;
    for(int i=0;i<n;i++){
        cin>>a[i];
        sum += a[i];
        mp[a[i]]++;
    }
    ll q,b,c;
    cin>>q;
    for(int i=0;i<q;i++){
        cin>>b>>c;
        if(mp[b]>0){
            sum += mp[b]*(c-b);
            mp[c]+=mp[b];
            mp[b]=0;
        }
        cout<<sum<<'\n';
    }
    // cout<<'\n';
}


Measured memory_bytes: 7844
import Control.Monad
import Control.Applicative

main = do
    w <- readLn
    n <- readLn
    q <- replicateM n $ words<$>translate<$>getLine
    mapM_ print $ solve [1..w] [(swap a b) | (x:y:_) <- q, let a = read x :: Int, let b = read y :: Int]

solve xs [] = xs
solve xs (f:fs) = solve (f xs) fs

swap i j xs = map f (zip [1..] xs)
    where f (idx, x) | idx == i = xs !! (j-1)
                     | idx == j = xs !! (i-1)
                     | otherwise = x

translate :: String -> String
translate [] = []
translate (x:xs)
    | x == ',' = ' ' : translate xs
    | otherwise = x : translate xs

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

int main(){
  double ans;
  cin >> ans;
  cout << ans*6.283185307179586232 << endl;
}


Measured memory_bytes: 3776
import sys
import numpy as np

def list_add(in1,in2):
    wrk = np.array(in1) + np.array(in2)
    return wrk.tolist()

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

book = []
for i in range(N):
    book.append(list(map(int,input().split())))


for i in range(M):
    und_sum = 0
    for j in range(N):
        und_sum += book[j][i+1]
    if und_sum < X:
        print(-1)
        sys.exit()

min_money = 1000000000000000000
for i in range(2**N):
    if i == 0:
        continue
    flag_ok = 1
    buy = []
    for j in range(N):
        if((i>>j)&1):
            buy.append(j)
    sum = []
    for k in range(len(buy)):
        if k == 0:
            sum = book[buy[k]]
        else:
            sum = list_add(sum,book[buy[k]])
    for k in range(M):
        if sum[k+1] < X:
            flag_ok = 0
            break
    if flag_ok == 1:
        if min_money > sum[0]:
            min_money = sum[0]
    flag_ok = 1

print(min_money)


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

int hantei(int data){
  int i = 3;
  if(data == 2){
    return 1;
  }
  if(data < 2 || data % 2 == 0){
    return 0;
  }
  while(i <= sqrt(data)){
      if(data % i == 0){
        return 0;
      }
      i = i + 2;
  }
return 1;
}

int main(void){
   int data;
   int num,i;
   int sum=0;
   while(1){
      scanf("%d",&num);
      if(num >= 1 && num <= 10000){
        break;
      }
   }

  for(i = 0 ; i < num ; i++){
     while(1){
     scanf("%d",&data);
     if(data >= 2 && data <= 100000000){
       break;
     }
     }
     sum += hantei(data);
  }
   printf("%d\n",sum);
   return 0;
}



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

int main() {
    int n;
    cin >> n;
    vector<int> L(n);
    for (int i = 0; i < n; ++i) {
        cin >> L[i];
    }
    sort(L.begin(), L.end());
    long long ans = 0;
    for (int i = n-1; i >= 2; --i) {
        for (int j = i-1; j >= 1; --j) {
            int l = -1, r = j;
            while (l+1 < r) {
                int m = (l+r)/2;
                if (L[i] < L[j]+L[m]) r = m;
                else l = m;
            }
            ans += j-r;
        }
    }
    cout << ans << endl;
    return 0;
}

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

#define ARRAY_INIT 0
#define DIV_INIT 0
#define LOOP_INIT 0
#define G_MAX 12

int main( void )
{
	unsigned long ulW_Dtc_cnt;
	int *aulW_Dtestcase;
	unsigned long ulW_Cloop_cnt;
	unsigned long ulW_Cloop_sub_cnt;
	unsigned long ulW_Csort_cnt = DIV_INIT;
	unsigned long ulW_Dm;//?????????????????????????????°
	unsigned long aulW_DG[ G_MAX ];//?????????????????????
	unsigned long ulW_Dv;
	signed long slW_Dk;

	scanf( "%d", &ulW_Dtc_cnt );
	aulW_Dtestcase = malloc ( sizeof( int ) * ulW_Dtc_cnt );
	for( ulW_Cloop_cnt = LOOP_INIT; ulW_Cloop_cnt < ulW_Dtc_cnt; ulW_Cloop_cnt++ ){
		scanf( "%d", &aulW_Dtestcase[ ulW_Cloop_cnt ] );
	}

	ulW_Dm = 1;
	aulW_DG[ 0 ] = 1;
	while( 3 * aulW_DG[ ulW_Dm - 1 ] + 1 < ulW_Dtc_cnt ){
		aulW_DG[ ulW_Dm ] = 3 * aulW_DG[ ulW_Dm - 1 ] + 1;
		ulW_Dm++;
	}

	for( ulW_Cloop_cnt = LOOP_INIT; ulW_Cloop_cnt < ulW_Dm / 2; ulW_Cloop_cnt++ ){
		ulW_Dv = aulW_DG[ ulW_Cloop_cnt ];
		aulW_DG[ ulW_Cloop_cnt ] = aulW_DG[ ulW_Dm - 1 - ulW_Cloop_cnt ];
		aulW_DG[ ulW_Dm - 1 - ulW_Cloop_cnt ] = ulW_Dv;
	}

	printf( "%d\n", ulW_Dm );
	for( ulW_Cloop_cnt = LOOP_INIT; ulW_Cloop_cnt < ulW_Dm; ulW_Cloop_cnt++ ){
		if( ulW_Cloop_cnt == ulW_Dm - 1 ){
			printf( "%d\n", aulW_DG[ ulW_Cloop_cnt ] );
		}
		else{
			printf( "%d ", aulW_DG[ ulW_Cloop_cnt ] );
		}
	}

	for( ulW_Cloop_cnt = LOOP_INIT; ulW_Cloop_cnt < ulW_Dm; ulW_Cloop_cnt++){
		for( ulW_Cloop_sub_cnt = aulW_DG[ ulW_Cloop_cnt ]; ulW_Cloop_sub_cnt < ulW_Dtc_cnt; ulW_Cloop_sub_cnt++ ){
			ulW_Dv = aulW_Dtestcase[ ulW_Cloop_sub_cnt ];
			slW_Dk = ulW_Cloop_sub_cnt - aulW_DG[ ulW_Cloop_cnt ];
			while( ( slW_Dk >= 0 ) && ( aulW_Dtestcase[ slW_Dk ] > ulW_Dv ) ){
				aulW_Dtestcase[ slW_Dk + aulW_DG[ ulW_Cloop_cnt ] ] = aulW_Dtestcase[ slW_Dk ];
				slW_Dk -= aulW_DG[ ulW_Cloop_cnt ];
				ulW_Csort_cnt++;
			}
			aulW_Dtestcase[ slW_Dk + aulW_DG[ ulW_Cloop_cnt ] ] = ulW_Dv;
		}
	}

	printf( "%d\n", ulW_Csort_cnt );
	for( ulW_Cloop_cnt = LOOP_INIT; ulW_Cloop_cnt < ulW_Dtc_cnt; ulW_Cloop_cnt++ ){
		printf( "%d\n", aulW_Dtestcase[ ulW_Cloop_cnt ] );
	}

	return 0;
}

Measured memory_bytes: 4508
#include <iostream>


using namespace std;

string bom[8];


void chain(int x, int y){
    int move_x[4]={0,0,1,-1};
    int move_y[4]={1,-1,0,0};
    bom[y][x]='0';
    for(int i=0; i<4; i++){
        int cx=x;
        int cy=y;
        for(int j=0; j<3; j++){
            cx+=move_x[i];
            cy+=move_y[i];
            if(cx<0||cy<0||cx>7||cy>7)break;
            if(bom[cy][cx]=='1')chain(cx, cy);
        }
    }
}


int main(void) {
    
    int n;
    cin>>n;
    for(int j=0; j<n; j++){
        for(int i=0; i<8; i++){
            cin>>bom[i];
        }
        int x, y;
        cin>>x>>y;
        x--;
        y--;
        chain(x, y);
        cout<<"Data "<<j+1<<":"<<endl;
        for(int i=0; i<8; i++){
            cout<<bom[i]<<endl;
        }
    }
    
    
    
    
    return 0;
}

Measured memory_bytes: 1216
// AOJ 2274: Sequence Configuration
// 2017.11.11 bal4u@uu

#include <stdio.h>
#include <stdlib.h>
#include <time.h>

int c[501][501];
int a[1002];

char buf[5000], *p;
int getint()
{
	int n = 0;
	while (*p >= '0') n = (n<<3) + (n<<1) + (*p++ & 0xf);
	return n;
}

int main()
{
	int n, n2, n3, n8, k, i, j, s;

	fgets(p=buf, 20, stdin), n = getint(), p++, k = getint();
	n2 = n >> 1, n8 = n >> 3, n3 = 3*n8;
	for (i = 0; i < k; i++) {
		fgets(p=buf, 5000, stdin);
		for (j = 0; j < n2; j++) c[i][j] = getint()-1, p++;
	}

	srand((unsigned)time(NULL));
again:
	for (i = 0; i < n; i++) a[i] = rand() & 1;
	for (i = 0; i < k; i++) {
		for (s = 0, j = 0; j < n2; j++) {
			s += a[c[i][j]];
			if (s > n3) break;
		}
		if (s <= n8 || s > n3) goto again; 
	}

	for (i = 0; i < n; i++) putchar(a[i] + '0');
	putchar('\n');
	return 0;
}

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

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

using namespace std;

typedef long long ll;

                //  0   1  2   3    4  5   6    7  8   9  10 11 12
ll  days[2][13] = {{0,31,28,31,30,31,30,31,31,30,31,30,31},
		           {0,31,29,31,30,31,30,31,31,30,31,30,31}};//leap year

ll Leap  = 31 + 29 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31 + 30 + 31;
ll nLeap = 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31 + 30 + 31;

bool isLeap(ll year) { return ((year%4LL) == 0LL && (year%100LL) != 0LL || ( year % 400LL ) == 0LL); }

void compute(vector<int> vec){
  if( vec.size() == 3 ) {
    ll y = vec[0], m = vec[1], d = vec[2];
    ll counter = 0;
    if( y == 2012 ) {
      assert( m == 12 );
      counter = d - 21;
      assert( counter >= 0 );
    } else {
      counter = d;
      REP(month,1,m) counter += days[isLeap(y)][month];

      REP(year,2013,y) {
        if( isLeap(year) ) counter += Leap;
        else               counter += nLeap;
      }
      counter += 10LL;
    }
    ll limit = 13LL * ( 20LL * 20LL * 18LL * 20LL );
    while( counter > limit ) counter -= limit;
    ll b,ka,t,w,ki,temp;
    b = ka = t = w = ki = 0;
    ki = counter % 20LL;
    temp = counter - ki;
    assert( temp % 20LL == 0 );
    int total_winaru = temp / 20LL;
    w = total_winaru % 18LL;
    temp -= w * 20LL;
    assert( temp % (18LL*20LL) == 0 );
    int total_toun = temp / ( 18LL * 20LL );
    t = total_toun % 20LL;
    temp -= t * 20LL * 18LL;
    assert( temp % ( 20LL * 18LL * 20LL ) == 0 );
    int total_katoun = temp / ( 20LL * 18LL * 20LL );
    ka = total_katoun % 20LL;
    temp -= ka * 20LL * 18LL * 20LL;
    assert( temp % ( 20LL * 18LL * 20LL * 20LL ) == 0);
    int total_bakutoun = temp / ( 20LL * 18LL * 20LL * 20LL );
    b = total_bakutoun;
    temp -= b * 20LL * 18LL * 20LL * 20LL;
    assert( temp == 0 );
    cout << b << "." << ka << "." << t << "." << w << "." << ki << endl;
  } else {
    ll counter = 0;
    counter += ll(vec[0]) * 20LL * 20LL * 18LL * 20LL;
    counter += ll(vec[1]) * 20LL * 18LL * 20LL;
    counter += ll(vec[2]) * 18LL * 20LL;
    counter += ll(vec[3]) * 20LL;
    counter += ll(vec[4]);
    ll Y = 2012, M = 12,O = 21LL+counter;

    while( !( 1LL <= O && O <= days[isLeap(Y)][M] ) ){
      O -= days[isLeap(Y)][M];
      ++M;
      if( M > 12LL ) { M = 1; ++Y; }
    }
    cout << Y << "." << M << "." << O << endl;
  }
}

int main(){
  string s;
  while( cin >> s, s[0] != '#' ){
    rep(i,s.size()) if( s[i] == '.' ) s[i] = ' ';
    stringstream ss;
    ss << s;
    vector<int> vec;
    int temp;
    while( !( ss >> temp ).fail() ) vec.push_back(temp);
    compute(vec);
  }
  return 0;
}

Measured memory_bytes: 1240
/*
 _     _                             
| |__ | |__   __ _  __ _ _   _  __ _ 
| '_ \| '_ \ / _` |/ _` | | | |/ _` |
| |_) | | | | (_| | (_| | |_| | (_| |
|_.__/|_| |_|\__,_|\__, |\__, |\__,_|
                   |___/ |___/       
*/
#include<bits/stdc++.h>

#define ll          long long
#define pb          push_back
#define ppb         pop_back
#define BigInt      __int128
#define endl        '\n'
#define mii         map<ll int,ll int>
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define sim         template < class c
#define ris         return * this
#define dor         > debug & operator <<
#define eni(x)      sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {

using namespace std;

sim > struct rge {c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug 
{
	~debug() 
	{ 
		cerr<<endl; 
	}
	eni(!=) cerr << boolalpha << i; ris; }
	eni(==) ris << range(begin(i), end(i)); }
	sim, class b dor(pair < b, c > d) 
	{
		ris << "(" << d.first << ", " << d.second << ")";
	}
	sim dor(rge<c> d) 
	{
	  	*this << "[";
	  	for (auto it = d.b; it != d.e; ++it)
	    	*this << ", " + 2 * (it == d.b) << *it;
	  	ris << "]";
	}
};
#define fuck(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

#define N  100005

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int TESTS=1;
	// cin>>TESTS;
	while(TESTS--)
	{
		ll int n;
		cin >> n;
		string s;
		cin >> s;
		ll int w = 0;
		ll int r = 0;
		for(auto it : s) 
		{
			if(it == 'R') r++;
			else w++;
		}
		ll int cnt = 0;
		for(ll int i = 0; i < r; i++)
		{
			if(s[i] == 'W') cnt++;
		}
		cout << cnt;
	}
	return 0;
}

Measured memory_bytes: 3728
import sys, math
lines = [s.rstrip("\n") for s in sys.stdin.readlines()]
x = int(lines.pop(0))

def iter_primes():
    _primes = []
    for n in range(2, 10 ** 6):
        is_prime = True
        upper_limit = math.floor(math.sqrt(n))
        for p in _primes:
            if n % p == 0:
                is_prime = False
                break
            if p >= upper_limit:
                break
        if is_prime:
            _primes.append(n)
            yield n

for n in iter_primes():
    if x <= n:
        print(n)
        break


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

int main(void){
  int n;
  int i,j,k;
  long long a,b,c;
  cin>>a>>b>>c;
  if(a+b>c){cout<<"No";return 0;}
  else{
  	if((a+b-c)*(a+b-c)>4*a*b)cout<<"Yes";
  	else cout<<"No";
  }
  return 0;
}

Measured memory_bytes: 256
N = int(input())
s = [list(sorted(input())) for i in range(N)]
s.sort()

ans = []
tmp = 1
for idx,val in enumerate(s):
        if idx == 0:
                continue
        if val == s[idx - 1]:
                tmp += 1
        else:
                ans.append(tmp)
                tmp = 1
else:
        ans.append(tmp)

res = 0
for i in ans:
        res += (i * (i - 1)) // 2
print(res)


Measured memory_bytes: 25312
import collections
n = input()
a = list(map(int, input().split()))
s = collections.Counter(a);
res = 0
for i in range(10 ** 5 + 1):
    b = 0
    if i in s:
        b += s[i]
    if i - 1 in s:
        b += s[i - 1]
    if i + 1 in s:
        b += s[i + 1]
    res = max(res, b)
print(res)


Measured memory_bytes: 15064
#include <iostream>

int main(){
   int A, B;
   std::cin >> A >> B;

   int ans = 0;
   if(A>B){ 
      ans += A;
      A--;
   }else{
      ans += B;
      B--;
   }
   if(A>B){ 
      ans += A;
      A--;
   }else{
      ans += B;
      B--;
   }
   std::cout << ans << std::endl;

   return 0;
}


Measured memory_bytes: 256
#include <vector>
#include <string>
#include <iostream>
#include <iomanip>
#include <queue>
#include <algorithm>
#include <functional>
#include <map>
#include <array>
#include <cmath>
#include <set>
#include <numeric>

using namespace std;

template <typename T>
using TABLE = vector<vector<T>>;

using LONG = long long;
using LVEC = vector<long long>;

#define FOR(i, s, e) for(i = s; i < e; ++i)
#define FOR_INV(i, s, e) for(i = e - 1; i >= s; --i)

long long PRIME = 1e9 + 7;
long long PRIME2 = 998244353;


using pos = std::pair<LONG, LONG>;

LONG i, j, k;

int main(){
    LONG N;
    cin >> N;

    LONG A;
    LONG prev_A = -1;
    LONG count = 0;

    FOR(i, 0, N){
        cin >> A;

        if(count == -1){
            continue;
        }

        if(A > prev_A + 1){
            count = -1;
        }
        else if(A == prev_A + 1){
            ++count;
        }
        else{
            count += A;
        }

        prev_A = A;
    }

    count = max<LONG>(count - 1, -1);
    cout << count;
}



Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<set>
#define lol(i,n) for(ll i=0;i<n;i++)
#define mod 1000000007
typedef long long ll;

using namespace std;
int NOEL(){
  cout<<"No"<<endl;
  return 0;
}
#define N 100010
class RAQxRSQ{
  private:
  ll dat[2*N],laz[2*N];
  ll eval(ll k){
    if(k<N){
      laz[k*2+1]+=laz[k];
      laz[k*2+2]+=laz[k];
    }
    dat[k]+=laz[k],laz[k]=0;
    return dat[k];
  }
  public:
  void init(){
    lol(i,2*N)dat[i]=0,laz[i]=0;
  }
  void add(ll l,ll r,ll x){
    l+=N,r+=N+1;
    for(ll a=l,b=r;a<b;a>>=1,b>>=1){
      if(a&1)laz[a++]+=x;
      if(b&1)laz[--b]+=x;
    }
    for(ll a=l,b=r;a+b;a>>=1,b>>=1){
      dat[a/2]=eval(a)+eval(a^1);
      dat[b/2]=eval(b)+eval(b^1);
    }
  }
  ll qry(ll l,ll r){
    l+=N,r+=N+1;
    for(ll d=20;~d;d--){
      eval(l>>d); eval(r>>d);
    }
    ll res=0;
    for(ll a=l,b=r;a<b;a>>=1,b>>=1){
      if(a&1)res+=eval(a++);
      if(b&1)res+=eval(--b);
    }
    return res;
  }
};RAQxRSQ seg;
ll n,b[N];
ll ten[N];
class setTentou{
  public:
  vector<ll> a;
  ll ten[N],m;
  void sub(bool flip){
    seg.init();
    for(int i=0;i<m;i++){
      ll sum=seg.qry(a[i],N-3);
      if(flip)ten[m-i-1]+=sum;
      else ten[i]+=sum;
      seg.add(a[i],a[i],1);
    }
  }
  void main(){
    m=a.size();
    lol(i,m)ten[i]=0;
    sub(0);
    lol(i,m)a[i]=N-5-a[i];
    lol(i,m/2)swap(a[i],a[m-i-1]);
    sub(1);
  }
  void push(ll x){
    a.push_back(x);
  }
};setTentou ST1,ST2;

ll d[N][3];
int main(){
    cin>>n;
    lol(j,3)lol(i,n)cin>>d[i][j];
    lol(i,n){
      if(d[i][1]%3!=2)return NOEL();
      if(d[i][0]<d[i][2]){
	if(d[i][0]!=d[i][1]-1)return NOEL();
	if(d[i][2]!=d[i][1]+1)return NOEL();
	b[i]=0;
      }
      if(d[i][0]>d[i][2]){
	if(d[i][2]!=d[i][1]-1)return NOEL();
	if(d[i][0]!=d[i][1]+1)return NOEL();
	b[i]=1;
      }
      ll val=d[i][1]/3;
      if(val%2!=i%2)return NOEL();
      if(i%2==0)ST1.push(val);
      if(i%2==1)ST2.push(val);
    }
    //cout<<"pass"<<endl;
    ST1.main(); ST2.main();
    lol(i,n){
      if(i%2==0)ten[i]=ST1.ten[i/2];
      if(i%2==1)ten[i]=ST2.ten[i/2];
    }
    int cnt[2]={0,0};
    ll sum[2]={0,0};
    lol(i,n){
      sum[i%2]+=ten[i];
      //cout<<oddf<<" "<<b[i]<<endl;
      bool need=(b[i]+ten[i])%2;
      //need=need xor 1;
      //if(i&1)cout<<"A";else cout<<"B";
      //cout<<need<<endl;
      
      if(need)cnt[i%2]++;
    }
    sum[0]/=2,sum[1]/=2;
    //cout<<cnt[0]<<" "<<cnt[1]<<" "<<sum[0]<<" "<<sum[1]<<endl;
    bool vl=(cnt[0]+sum[1])%2; if(vl)return NOEL();
    bool vr=(cnt[1]+sum[0])%2; if(vr)return NOEL();
    cout<<"Yes"<<endl;
    return 0;
}


Measured memory_bytes: 9844
from fractions import gcd
def lcm(a,b):
  return a*b//gcd(a,b)
n=int(input())
a=list(map(int,input().split()))
ans=0
mod=10**9+7
l=a[0]
for i in range(1,n):
  l=lcm(l,a[i])
l%=mod
for aa in a:
  #　mod(10**9+7)逆元
  ans+=l*pow(aa,mod-2,mod)%mod
  ans%=mod
print(ans)

Measured memory_bytes: 69080
from copy import deepcopy
from sys import exit,setrecursionlimit
import math
from collections import defaultdict,Counter,deque
from fractions import Fraction as frac
import bisect
import sys
import logging
import heapq
logging.basicConfig(level=logging.DEBUG)

input = sys.stdin.readline

setrecursionlimit(1000000)

MOD = 10**9+7

def main():
    N,K=[int(x) for x in input().split()]
    H=[int(x) for x in input().split()]

    ans=0
    for h in H:
        if h >= K: 
            ans+=1
    print(ans)

main()

Measured memory_bytes: 80876
import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    if (s.endsWith("s")) {
      s += "es";
    } else {
      s += "s";
    }
    System.out.println(s);
  }
}

Measured memory_bytes: 38528
import sys

input=sys.stdin.readline

N,M=map(int,input().split())
A=list(map(int,input().split()))
A.sort()

def condition(num):
    count=0
    s=N-1
    t=0
    while N-1>=t and s>=0:
        if num>A[s]+A[t]:
            t+=1
        else:
            count+=N-t
            s-=1
    return count>=M

subans=0
start=1
end=2*A[N-1]
while end-start>1:
    test=(end+start)//2
    if condition(test):
        start=test
    else:
        end=test
if condition(end):
    subans=end
else:
    subans=start

data=[0]*N
count=0
s=N-1
t=0
while N-1>=t and s>=0:
    if subans>A[s]+A[t]:
        t+=1
    else:
        count+=N-t
        data[s]=2*(N-t)
        s-=1

ans=sum(data[i]*A[i] for i in range(0,N))
if count>M:
    ans-=(count-M)*subans
print(ans)

Measured memory_bytes: 56356
N = int(input())
A = list(map(int, input().split()))
li = [0,0,0]
for nums in A:
  if nums%4==0:
    li[0] += 1
  elif nums%2==0:
    li[1] += 1
  else:
    li[2] += 1
if li[1]==0 and li[2]-li[0]>1:
  print('No')
elif li[1]!=0 and li[2]-li[0]>0:
  print('No')
else:
  print('Yes')

Measured memory_bytes: 14252
from sys import stdin
import itertools
def main():
    #入力
    readline=stdin.readline
    N=int(readline())
    MARCH=[0,0,0,0,0]
    M=0
    A=1
    R=2
    C=3
    H=4
    for _ in range(N):
        S=readline().strip()
        if S[0]=="M":
            MARCH[M]+=1
        elif S[0]=="A":
            MARCH[A]+=1
        elif S[0]=="R":
            MARCH[R]+=1
        elif S[0]=="C":
            MARCH[C]+=1
        elif S[0]=="H":
            MARCH[H]+=1

    seq=[M,A,R,C,H]
    coms=itertools.combinations(seq,3)
    res=0
    for li in coms:
        X=li[0]
        Y=li[1]
        Z=li[2]
        res+=MARCH[X]*MARCH[Y]*MARCH[Z]

    print(res)
    
if __name__=="__main__":
    main()

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
const int N=3e5+5;
const int M=1e5+5;
struct each{
	int l,r;
}a[N];
vector<int>d[M];
int n,m,b[M],ans[M];
bool com(each x,each y){
	return x.l<y.l;
}
void add(int x,int y){
	while(x<=m){
		b[x]+=y;
		x+=x&-x;
	}
}
int query(int x){
	int ans=0;
	while(x){
		ans+=b[x];
		x-=x&-x;
	}
	return ans;
}
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)
		scanf("%d%d",&a[i].l,&a[i].r);
	int top=1;
	sort(a+1,a+n+1,com);
	for(int i=1;i<=m;i++){
		while(top<=n&&a[top].l==i)
			add(i,1),add(a[top++].r+1,-1);
		for(int j=i;j<=m;j+=i)	d[j].push_back(i);

		int si=d[i].size();
		for(int j=0;j<si;j++){
			if(i+d[i][j]<=m)	ans[d[i][j]]+=query(i)-query(i+d[i][j]);
			ans[d[i][j]]+=query(i)-query(i-d[i][j]);
		}
	}
	for(int i=1;i<=m;i++)	printf("%d\n",ans[i]);
	return 0;
}


Measured memory_bytes: 14464
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
    int N;
    cin>>N;
    vector<tuple<string,int,int>> a;
    REP(i,N){
        string s;
        int p;
        cin>>s>>p;
        a.emplace_back(s,p*-1,i);
    }
    sort(a.begin(),a.end());
    REP(i,N)cout<<get<2>(a[i])+1<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main
{
	public static void main(String[] args)
	{
	   Scanner sc = new Scanner(System.in);
       int a = sc.nextInt(); 
       int r = a % 10;
       if(r == 2 || r == 4 || r == 5 || r == 7 || r == 9)
         System.out.println("hon");
       else if(r == 0 || r == 1 || r == 6 || r == 8)
         System.out.println("pon");
       else
         System.out.println("bon");
	}
}


Measured memory_bytes: 35700
#include <iostream>
#include <cstring>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
#include <map>
#include <cstdlib>
#include <sstream>
#include <bitset>
using namespace std;

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



int main()
{
    int ans=0;
    string s;
    cin >> s;
    if(s[0]=='R' && s[1]=='R' && s[2]=='R') cout << 3 << endl;
    else if(s[1]=='R' && (s[0]=='R' || s[2]=='R')) cout << 2 << endl;
    else if(s[0]=='R' || s[1]=='R' || s[2]=='R') cout << 1 << endl;
    else cout << 0 << endl;




    return 0;
}

Measured memory_bytes: 3616
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
long long w[1000], v[1000];
long long dp[100001][101];
int main() {
	int n,weight;
	cin >> n>>weight;
	for (int i = 1; i <= n; i++) {
		cin >> w[i] >> v[i];
	}
	for (int i = 1; i <= weight; i++) {
		for (int j = 1; j <= n; j++) {
			dp[i][j] = dp[i][j-1];
			if (w[j] <= i) {
				dp[i][j] = max(dp[i - w[j]][j - 1] + v[j],dp[i][j]);
			}
	//		cout << dp[i][j] << " ";
		}
	//	cout << endl;
	}
	cout << dp[weight][n] << endl;
	return 0;
}

Measured memory_bytes: 79104
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string o,e;
  cin>>o>>e;
  for(int i=0;i<e.size();i++){
    cout<<o.at(i)<<e.at(i);
  }
  if(o.size()==e.size()+1){
    cout<<o.at(o.size()-1)<<endl;
  }
}

Measured memory_bytes: 256
import sys

n=30
f=[1,1,2,4]
while len(f)<=n:
    f.append(f[-1]+f[-2]+f[-3])


while True:
    n=int(input())
    if n==0:
        sys.exit()

    day=f[n]

    if day%3650==0:
        print(int(day/3650))
    else:
        print(int(day/3650)+1)

Measured memory_bytes: 7544