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

#define F               first
#define S               second
#define ull             unsigned long long
#define ll              long long
#define db              long double
#define ST              string
#define pb              push_back
#define mp              make_pair
#define el              "\n"
#define vll             vector <ll>
#define vi              vector <int>
#define pii             pair <int, int>
#define pll             pair <ll, ll>
#define vec(v)          vector <v>
#define all(v)          (v.begin(), v.end())
#define rall(v)         (v.rbegin(), v.rend())
#define is_sort(v)      is_sorted all(v)
#define max_of(v)       *max_element all(v)
#define min_of(v)       *min_element all(v)
#define itos(s)         to_string(s)
#define cntone(x)       __builtin_popcountll(x)
#define cntzro(x)       __builtin_clz(x)
#define clr(x,y)        memset(x, y, sizeof(x))
#define For(i, a, b)    for(int i=a; i<b; i++)
#define Forr(i, a, b)   for(int i=a; i>=b; i--)
const ll mod = 1e9 + 7;

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


    /***************-Code starts from here-***************/
    int n;
    cin >> n;
    int c = 0, flag = 0;
    for (int i = 1; i <= n; i++)
    {
        int x , y;
        cin >> x >> y;
        if (x == y)
        {
            c++;
            if (c == 3)
            {
                flag = 1;
                break;
            }
        }
        else
            c = 0;
    }
    if (flag)
        cout << "Yes";
    else
        cout << "No";
    return 0;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
#define pb(x) push_back(x)
#define mp(x, y) make_pair(x, y)
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repd(i, n) for (ll i = n-1; i >= 0; i--)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define repd2(i, s, n) for (ll i = n-1; i >= (s); i--)

bool binary_search(vector<int> A, int key) {
    int left = 0, right = A.size();
    int mid;
    while (left < right) {
        mid = (left + right) / 2;
        if (A[mid] == key) {
            return true;
        }
        else if (A[mid] > key) {
            right = mid;
        }
        else{
            left = mid + 1;
        }
    }
    return false;
}
int main() {
    int n, q, sum = 0;
    cin >> n;
    vector<int> S(n);
    rep(i, n) cin >> S[i];
    sort(all(S));

    cin >> q;
    rep(i, q) {
        int key;
        cin >> key;
        if (binary_search(S, key)) sum++;

    }
    cout << sum << endl;
    return 0;
}


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

int main()
{
	string str;
	string apple = "apple";
	string peach = "peach";

	getline(cin, str);

	for (int i = 0; i < str.size() - 4; i++)
	{
		if (str.substr(i, 5) == "apple")
		{
			for (int j = 0; j < 5; j++)
			{
				str[i + j] = peach[j];
			}
		}
		else if (str.substr(i, 5) == "peach")
		{
			for (int j = 0; j < 5; j++)
			{
				str[i + j] = apple[j];
			}
		}
	}

	cout << str << endl;

	return 0;
}

Measured memory_bytes: 1188
#include <bits/stdc++.h>
#include <string>
#include <cmath>

using namespace std;

int main()
{
    long N = 0;
    cin >> N;
    long A[N];
    long max = 0;
    long result = 0;

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

    max = A[0];

    for (int i = 1 ; i < N; i++) {
        if (max < A[i]) {
            max = A[i];
        } else {
            result += max - A[i];
        }
    }
    cout << result << endl;
}

Measured memory_bytes: 5188
function Main(input) {
    var S = input[0].split('');

    for(var i = 1; i < S.length + 1; i++) {
        if (i % 2 === 0) {
            if (S[i - 1] === 'R') {
                return console.log('No');
            }
        } else {
            if (S[i - 1] === 'L') {
                return console.log('No');
            }
        }
    }

    console.log('Yes');
}

Main(require("fs").readFileSync("/dev/stdin", "utf8").trim().split(/\n/));

Measured memory_bytes: 21064
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
#define rep(i,a,b) for (int i = a; i < b; i++)
#define repn(i,a,b) for (int i = a; i >=b ;i--)
#define MOD 1000000007


int main(){
ios::sync_with_stdio(0);
cin.tie(0);
    ll n,a,b,c;cin>>n>>a>>b>>c;
    vector<string> v;
    string s;
    rep(i,0,n){
        cin>>s;
        v.push_back(s);
    }
    //cout<<v[0];
    vector<char> ch;
    bool flag=1;
    rep(i,0,n){
        string x=v[i];
        if(x=="AB"){
            if(a>b){
                a--;b++;
                ch.push_back('B');
            }
            else if(a==1&&b==1&&c==0){
                if(v[i+1]=="BC"){
                    a--;b++;ch.push_back('B');
                }
                else {
                    a++;b--;ch.push_back('A');
                }
            }
            else {
                a++;b--;ch.push_back('A');
            }
            
        }
        else if(x=="BC"){
            if(b>c){
                b--;c++;ch.push_back('C');
            }
            else if(b==1&&c==1&&a==0){
                if(v[i+1]=="AB"){
                    c--;b++;ch.push_back('B');
                }
                else {
                    c++;b--;ch.push_back('C');
                }
            }
            else {
                b++;c--;ch.push_back('B');
            }
            
        }
        else if(x=="AC"){
            if(a>c){
                a--;c++;ch.push_back('C');
            }
            else if(a==1&&c==1&&b==0){
                if(v[i+1]=="BC"){
                    a--;c++;ch.push_back('C');
                }
                else {
                    a++;c--;ch.push_back('A');
                }
            }
            else {
                a++;c--;ch.push_back('A');
            }   
        } //cout<<a<<" "<<b<<" "<<c<<"\n";
        if(a<0||b<0||c<0){
            flag=0;
            break;
        }  
    }
    if(flag==0)cout<<"No";
    else{
         cout<<"Yes\n";
         for(auto x : ch)cout<<x<<"\n";
    }
 
return 0;
}

Measured memory_bytes: 7432
#include <iostream>
#include <stdio.h>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <limits.h>
#include <math.h>
#include <functional>
#include <bitset>
#include <iomanip>

#define repeat(i,n) for (long long i = 0; (i) < (n); ++ (i))
#define debug(x) cerr << #x << ": " << x << '\n'
#define debugArray(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i] << '\n'
#define debugArrayP(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i].first<< " " << x[i].second << '\n'

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef vector<int> vint;
typedef vector<ll> vll;
const ll INF = INT_MAX;
const ll MOD = 1e9+7;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;cin>>N;
  bool four=false;
  repeat(i,N){
    char S;
    cin>>S;
    four |= S=='Y';
  }
  cout << (four? "Four":"Three")<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <valarray>
#include <cstdio>
using namespace std;
typedef valarray<int>V;
int n,m,a,b,c,t,i;
V M(const V &x,const V &y){
	V z(n*n);
	int i=0,j;
	for(;i<n;i++)for(j=0;j<n;j++)z[i*n+j]=(x[slice(i*n,n,1)]*y[slice(j,n,n)]).sum()%m;
	return z;
}
V E(const V &x,const int n){
	if(n==1)return x;
	if(n&1)return M(E(x,n-1),x);
	V y=E(x,n>>1);
	return M(y,y);
}
V s,x;
void O(const V &r){
    for(i=0;i<n-1;i++)printf("%d ",(r[slice(i*n,n,1)]*s).sum()%m);
    printf("%d\n",(r[slice(i*n,n,1)]*s).sum()%m);
}
main(){
	int i;
	for(;scanf("%d%d%d%d%d%d",&n,&m,&a,&b,&c,&t),n;){
		s.resize(n);
		for(i=0;i<n;i++)scanf("%d",&s[i]);
		x.resize(0);
		x.resize(n*n);
		if(t){
			x[0]=b;
			x[1]=c;
			for(i=1;i<n-1;i++){
				x[i*n+i-1]=a;
				x[i*n+i]=b;
				x[i*n+i+1]=c;
			}
			x[i*n+i-1]=a;
			x[i*n+i]=b;
			O(E(x,t));
		}else{
			for(i=0;i<n;i++)x[i*n+i]=1;
			O(x);
		}
	}
}

Measured memory_bytes: 1084
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define UM unordered_map
#define ALL(a) (a).begin(), (a).end()
typedef vector<ll> vi;
typedef vector<vector<ll>> vvi;
typedef pair<ll, ll> pii;
const ll INF = 1LL << 58;
const ll MOD = 1000000007;
struct Edge
{
    ll s, t, d;
};
typedef vector<vector<Edge>> Graph;
typedef vector<pii> vpii;
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}

signed main()
{
    int N;
    int tmp;
    int m = INF;
    cin >> N;
    REP(i, 5)
    {
        cin >> tmp;
        chmin(m, tmp);
    }
    int ans;
    ans = N / m + 5;
    if (m >= N)
        ans = 5;
    if (N % m == 0)
        ans--;
    cout << ans << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int K,R,L;
double P,E,T;
double dfs(int d,double l,double r){
  double mid=(l+r)/2;
  if(!d)return (T-E<mid&&mid<T+E)?1:0;
  if(r<T-E||T+E<l)return 0;
  if(mid>=T)return (1.0-P)*dfs(d-1,l,mid)+P*dfs(d-1,mid,r);
  return (1.0-P)*dfs(d-1,mid,r)+P*dfs(d-1,l,mid);
}
main(){
  cin>>K>>L>>R>>P>>E>>T;
  printf("%.9f\n",dfs(K,L,R));
}

Measured memory_bytes: 3292
#include <bits/stdc++.h>
/*#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
*/#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")    
using namespace std;
/*namespace mp = boost::multiprecision;
using Bint = mp::cpp_int;
using Real = mp::number<mp::cpp_dec_float<1024>>;
*/#define lli long long int
#define uli unsigned long long int
#define INF 999999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define rrep(i,m,n) for(lli i=m-1;i>=n;i--)
#define pb(n) push_back(n)
#define UE(N) N.erase(unique(N.begin(),N.end()),N.end());
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(50) << S << endl
#define Vec(K,L,N,S) vector<L> K(N,S)
#define DV(K,L,N,M,S) vector<vector<L>> K(N,vector<L>(M,S))
#define TV(K,L,N,M,R,S) vector<vector<vector<L>>> K(N,vector<vector<L>>(M,vector<L>(R,S)))
#define pint pair<lli,lli>
#define paf(L,R) pair<L,R>
#define mod 998244353
#define MAX 10000000
#define ALL(a)  a.begin(),a.end()
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  lli D,E,H,W,M,K,L,R,N,num=0,sum=0,flag=0;string S,T;
  cin >> N;
  D=E=H=W=0;
  rep(i,0,N){
    cin >> S;
    if(S=="AC")D++;
    else if(S=="WA")E++;
    else if(S=="TLE")H++;
    else W++;
  }
  cout << "AC x " << D << endl;
  cout << "WA x " << E << endl;
  cout << "TLE x " << H << endl;
  cout << "RE x " << W << endl;
}

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

int main(){
  int n,k;
  cin >> n >> k;
  vector<int> l(n);
  for (int i = 0; i < n; i++) cin >> l[i];
  sort(l.begin(),l.end());
  reverse(l.begin(),l.end());

  int ans=0;
  for (int i = 0; i < k; i++) ans+=l[i];
  
  cout  << ans << endl;  
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void) {
    int n;
    int sum = 0;
    char str[1000];
    scanf("%d", &n);
    sprintf(str, "%d", n);
    for (int i = 0; str[i] != '\0'; i++) {
        sum += str[i] - 0x30;
    }
    if (!(n % sum)) {
        printf("Yes\n");
    } else {
        printf("No\n");
    }
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <set>
#include <deque>
#include <map>
#include <iomanip>
#include <queue>
#include <stack>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <utility>
using namespace std;
int ky[8] = {-1,1,-2,2,-2,2,-1,1}; 
int kx[8] = {-2,-2,-1,-1,1,1,2,2};
int dy[4] = {-1,0,1,0};
int dx[4] = {0,1,0,-1};
int ddy[8] = {-1,0,1,-1,1,-1,0,1};
int ddx[8] = {-1,-1,-1,0,0,1,1,1};
typedef long long ll;
#define pi pair
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define rep1(i,a,b) for(int i = a; i < b; i++)
#define rep2(i,a,b) for(int i = a; i <= b; i++) 
#define INF 999999999999
const double PI = acos(-1.0); 
ll n;
ll a;
ll x[100001];
ll b,c;
ll s;
ll q;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    cin >> n;
    rep1(i,0,n){
        cin >> a;
        x[a]++;
        s += a;
    }
   // cout << s << '\n';
    cin >> q;
    rep1(i,0,q){
        cin >> b >> c;
        x[c] += x[b];
        s += (c - b) * x[b];
        x[b] = 0;
        cout << s << '\n';
    }
	return 0;
}


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

int main() {
  int N;
  cin >> N;
  bool a = false;
  
  for (int i=0; i<N; i++){
    char S;
    cin >> S;
    if (S == 'Y'){
      a = true;
    }
  }
  
  if (a){
    cout << "Four" << endl;
  }else{
    cout << "Three" << endl;
  }
}

Measured memory_bytes: 256
n = input()
k = input()
for i in range(k):
	x, y = map(int, raw_input().split())
	if x <= (n + 1) / 2:
		x -= 1
	else:
		x = n - x
	if y <= (n + 1) / 2:
		y -= 1
	else:
		y = n - y
	if x <= y < n - x:
		print 1 + x % 3
	else:
		print 1 + y % 3

Measured memory_bytes: 4244
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N,i,j,k;
    string S;
    cin >> N >> S;
    set<int> m;
    vector<bool> p(1000,true);
    for(i = 0;i < N - 2;i++){
        if (p[S[i] - '0']){
            for (j = i + 1; j < N - 1; j++){
                if (p[(S[j] - '0') * 10 + (S[i] - '0')]){
                    for (k = j + 1; k < N; k++){
                        m.insert((S[i] - '0') * 100 + (S[j] - '0') * 10 + (S[k] - '0'));
                    }
                    p[(S[j] - '0') * 10 + (S[i] - '0')] = false;
                }
            }
            p[S[i] - '0'] = false;
        }
    }
    cout << m.size() << endl;
}

Measured memory_bytes: 3684
n , m =  [ int(v) for v in input().split() ]
connect_matrix = [ [0 for j in range(n)] for i in range(n)]
breaking_list = []
for i in range(m):
    a, b = [ int(v)-1 for v in input().split() ]
    connect_matrix[a][b] = 1
    connect_matrix[b][a] = 1
    breaking_list.append((a,b))




def connect_check(intuple):
    global connect_matrix,n
    p, q = intuple[0], intuple[1]

    connect_matrix2 = [ [connect_matrix[i][j] for j in range(n)] for i in range(n)]
    arriving_list =  [ set([i]) for i in range(n)]
    connect_matrix2[p][q] = 0
    connect_matrix2[q][p] = 0

    
    for k in range(6):
        new_connect_matrix2 = []
        for i in range(n):
            templist = [ j for j in range(n) if connect_matrix2[i][j] > 0 and j not in arriving_list[i]]

            newlist = [ connect_matrix2[i][j] for j in range(n) ]
            for j in templist:
                newlist = [ newlist[h] | connect_matrix2[j][h] for h in range(n) ]
                arriving_list[i].add(j)
            #print(newlist)
            new_connect_matrix2.append(newlist)
        connect_matrix2 = new_connect_matrix2


    
    if { i for i in range(n) } not in arriving_list:
        ret = 1
    else:
        ret = 0
    return ret

ans = 0
for i in breaking_list:
    ans += connect_check(i)

print(ans)

Measured memory_bytes: 54492
#!/usr/bin/env python3

import sys
input=sys.stdin.readline


LEN=2*10**5+10

moves=[0]*LEN
for i in range(1,LEN):
  tmp=i
  cnt=0
  while tmp!=0:
    popcount=0
    for j in range(20):
      if tmp&(1<<j):
        popcount+=1
    tmp%=popcount
    cnt+=1
  moves[i]=cnt

n=int(input())
x=input()
k=x.count('1')
if k==0:
    for i in range(n):
        print(1)
elif k==1:
    pos=x.index('1')
    for i in range(n):
        if i==pos:
            print(0)
        else:
            if pos==n-1:
                print(2)
            else:
                if i==n-1:
                    print(2)
                else:
                    print(1)
else:
    sum1=0
    sum2=0
    tmp1=1
    tmp2=1
    for i in range(n-1,-1,-1):
        if x[i]=='1':
            sum1+=tmp1
            sum1%=k+1
            sum2+=tmp2
            sum2%=k-1
        tmp1*=2
        tmp1%=k+1
        tmp2*=2
        tmp2%=k-1
    for i in range(n):
        if x[i]=='0':
            tmp=sum1+pow(2,n-i-1,k+1)
            tmp%=k+1
            print(moves[tmp]+1)
        else:
            tmp=sum2-pow(2,n-i-1,k-1)
            tmp%=k-1
            print(moves[tmp]+1)

Measured memory_bytes: 75556
N = int(input())
A = list(map(int, input().split()))
up_or_down = 0
ans = 1
for i in range(len(A) - 1):
    if up_or_down == 0:
        up_or_down = A[i+1] - A[i]
    else:
        if up_or_down > 0 and A[i+1] - A[i] < 0:
            ans += 1
            up_or_down = 0
        elif up_or_down < 0 and A[i+1] - A[i] > 0:
            ans += 1
            up_or_down = 0
print(ans)

Measured memory_bytes: 84932
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include<set>
#include<map>
using namespace std;


int main() {
    char s;
    cin >> s;
    if(s == 'T'){
        cout << 'A';
    } 
    else if(s == 'G'){
        cout << 'C';
    }
    else if(s == 'C'){
        cout << 'G';
    }
    else{
        cout << 'T';
    }
    cout << endl;
}


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

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

#define INF 999999999

int main(){
	int N, X;
	cin >> N >> X;

	int mini = INF;
	REP(i, N){
		int m;
		cin >> m;
		X -= m;
		mini = min(m, mini);
	}

	cout << N + ( X / mini ) << endl;
	return 0;
}


Measured memory_bytes: 256
import collections

N = int(input())
vote_list = [input() for i in range(N)]
vote_list.sort()

count = collections.Counter(vote_list)
max_count = count.most_common()[0][1]
ans = []

for alpha, beta in count.items():
    if beta == max_count:
        ans.append(alpha)
ans.sort()
print("\n".join(ans))

Measured memory_bytes: 45092
#include<cstdio>
#include<cstring>
const int maxn=10010,mod=998244353;
char a[maxn],b[maxn];
int len,n,m;
int iv[maxn],fc[maxn],ifc[maxn];
int f[maxn][maxn];
int ans;
int main() {
	scanf("%s%s",a+1,b+1),len=strlen(a+1);
	for(register int i=1;i<=len;++i) {
		if(a[i]=='1'&&b[i]=='1') ++n;
		else if(a[i]=='1') ++m;
	}
	iv[1]=1;
	for(register int i=2;i<=len;++i)iv[i]=1ll*iv[mod%i]*(mod-mod/i)%mod;
	fc[0]=ifc[0]=1;
	for(register int i=1;i<=len;++i)fc[i]=1ll*fc[i-1]*i%mod,ifc[i]=1ll*ifc[i-1]*iv[i]%mod;
	f[0][0]=1;
	for(register int i=1;i<=m;++i)f[0][i]=1ll*f[0][i-1]*i*i%mod;
	for(register int i=1;i<=n;++i)for(register int j=1;j<=m;++j)f[i][j]=(1ll*f[i-1][j]*i*j+1ll*f[i][j-1]*j*j)%mod;
	for(register int i=0;i<=n;++i)ans=(ans+1ll*f[i][m]*fc[n]%mod*ifc[i]%mod*fc[n+m]%mod*ifc[m+i])%mod;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 389632
#include <bits/stdc++.h>
using namespace std;
#define MAX 100
#define INFTY (1<<21)
#define WHITE 0
#define GRAY 1
#define BLACK 2
#define NIL -1

int n, M[MAX][MAX];

int prim() {
  int u, minv;
  int d[MAX], p[MAX], color[MAX];

  for (int i = 0; i < n; i++) {
    d[i] = INFTY;
    p[i] = -1;
    color[i] = WHITE;
  }

  d[0] = 0;

  while ( 1 ) {
    minv = INFTY;
    u = -1;
    for (int i =0; i<n; i++) {
      if (minv > d[i] && color[i] != BLACK) {
        u = i;
        minv = d[i];
      }
    }
    if ( u == -1) break;
    color[u] = BLACK;
    for (int v = 0; v < n; v++) {
      if ( color[v] != BLACK && M[u][v] != INFTY) {
        if (d[v] > M[u][v]) {
          d[v] = M[u][v];
          p[v] = u;
          color[v] = GRAY;
        }
      }
    }
  }
  int sum = 0;
  for (int i = 0; i < n; i++) {
    if (p[i] != -1) sum += M[i][p[i]];
  }

  return sum;
}

int main(){
  cin >> n;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      int e; cin >> e;
      M[i][j] = (e == -1) ? INFTY : e;
    }
  }
  cout << prim() << endl;
  return 0;
}



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

/* typedef */

typedef unsigned long long ull_t;

/* main */

int main(int argc, char **argv) {
  ull_t n, hn, count, x, cn;
  double hnf;

  for (;;) {
    scanf("%llu", &n);
    if (n == 0) break;

    hn = n / 2;

    count = hn;
    for (x = 1; x * x < hn; x++)
      count += (hn + x - 1) / x;

    cn = 0;
    while (cn * cn < hn) cn++;

    printf("%llu\n", 2 * (8 * count - 4 * cn * cn) + 8 * n);
  }

  return 0;
}

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

using namespace std;

vector<string> strc;
int itens = 1;
int main()
{
    int n;

    cin >> n;
    for (int i = 0; i < n; i++)
    {
        string s;
        cin >> s;
        strc.push_back(s);
    }

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

    for (int i = 1; i < n ; i++)
    {
        if (strc[i].compare(strc[i - 1]) != 0)
            itens++;
    }

    cout << itens << endl;
        
    return 0;
}

Measured memory_bytes: 11580
#include<iostream>
#include<cstdio>
#include<cstring>
#include<vector>
#include<algorithm>
#include<cmath>
using namespace std;
#define INF 0x3f3f3f3f
const int maxn=2e5+10;  //2e5
#define _rep(i,a,b) for(int i=(a);i<=(b);++i)
int n,m,T,cnt,ans;
long long f[50],sumex0[maxn];
struct Node
{
    int a,b;
}store[maxn],ex0[maxn];

bool cmp(Node i,Node j)
{
    return 1ll*j.a*(i.b+1)<1ll*i.a*(j.b+1);
}
bool cmp2(Node A,Node B)
{
    return A.b<B.b;
}
int main()
{
    #ifdef __LOCAL__
        freopen("1.in","r",stdin);
        freopen("1.out","w",stdout);
    #endif
    cin>>n>>T;
    _rep(i,1,n)
    {
        cin>>store[i].a>>store[i].b;
        if(store[i].a==0)
        {
            ++cnt;
            ex0[cnt].a=store[i].a;
            ex0[cnt].b=store[i].b;
        }
    }   
    sort(store+1,store+1+n,cmp);
    sort(ex0+1,ex0+1+cnt,cmp2);
    m=n-cnt;
    // _rep(i,1,n)
    //     cout<<i<<" "<<store[i].a<<" "<<store[i].b<<endl;
    // _rep(i,1,cnt)
    //     cout<<i<<" "<<ex0[i].a<<" "<<ex0[i].b<<endl;
    // memset(f,0x3f,sizeof(f));
    _rep(i,1,30)  f[i]=INF;
    f[0]=0;
    _rep(i,1,m)
        for(int j=30;j>0;j--)
            if(j<=i)
                f[j]=min(f[j],(f[j-1]+1)*(store[i].a+1)+store[i].b);
    _rep(i,1,cnt)
        sumex0[i]=sumex0[i-1]+ex0[i].b+1;
    _rep(i,0,30)
    {
        // cout<<i<<" "<<f[i]<<endl;
        if(f[i]>T) continue;
        int pos=upper_bound(sumex0+1,sumex0+cnt+1,T-f[i])-sumex0-1;        
        ans=max(ans,i+pos);
        // cout<<pos<<" "<<i+pos-1<<endl;
    }  
    cout<<ans<<endl;
    
    return 0;
}

Measured memory_bytes: 4992
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
         int n=sc.nextInt();
         int ts=0;
         int hs=0;
         for(int i=0;i<n;i++){
        	 String t = sc.next();
             String h = sc.next();
           if(t.compareTo(h)>0){
             ts=ts+3;
             }
            else if(h.compareTo(t)>0){
             hs=hs+3;
           }else{
             hs++;
             ts++;
           }
         }
            System.out.println(ts+" "+hs);
  } 
}


Measured memory_bytes: 29064
n=int(input())
p=tuple(map(int,input().split()))
q=tuple(map(int,input().split()))
from itertools import permutations
for i,x in enumerate(permutations([i+1 for i in range(n)],n)):
  if x==p:a=i
  if x==q:b=i
print(abs(a-b))

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

using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
//typedef pair<ll, ll> P;
typedef pair<double, double> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

double equal(double a, double b) {
    return fabs(a - b) < DBL_EPSILON;
}

std::istream &operator>>(std::istream &in, set<string> &o) {
    string a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
//const ll mod = 1e10;

typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;

int main() {
    ll n, h, w;
    cin >> n >> h >> w;

    if (n < h || n < w) {
        cout << 0 << endl;
        ret();
    }

    ll hori = n - w + 1;
    ll ver = n - h + 1;
    cout << hori * ver << endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        // カードの枚数を受け取る
        int numberOfCards = sc.nextInt();
        
        // 4行13列の二次元配列(初期値はfalse)
        boolean[][] cardExistence = new boolean[4][13];
        
        for (int i=0; i<numberOfCards; i++) {
            String kigou = sc.next();
            int cardNum = sc.nextInt();
            
            // S:0, H:1, C:2, D:3
            if (kigou.equals("S")) 
                cardExistence[0][cardNum - 1] = true;
            else if (kigou.equals("H"))
                cardExistence[1][cardNum - 1] = true;
            else if (kigou.equals("C"))
                cardExistence[2][cardNum - 1] = true;
            else if (kigou.equals("D"))
                cardExistence[3][cardNum - 1] = true;
        }
        
        // S:0, H:1, C:2, D:3
        String[] marks = {"S", "H", "C", "D"};
        
        // 中身がfalse（ないカード）の場合、出力
        for (int i=0; i<4; i++) {
            for (int j=0; j<13; j++) {
                if (cardExistence[i][j] == false)
                    // ないカードの記号と数字を出力
                    System.out.println(marks[i] + " " + (j + 1));
            }
        }
    }
}


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

int N, M, Q;
int sum;
vector<int> a, b, c, d;

void pei(vector<int> A){
  if(A.size() == N+1){
    int sum2 = 0;
    for(int i = 0; i < Q; i++){
      if(A[b[i]] - A[a[i]] == c[i]){
        sum2 += d[i];
      }
    }
    sum = max(sum, sum2);
    return;
  }
  A.push_back(A.back());
  while(A.back() <= M){
    pei(A);
    A.back()++;
  }
}

int main(){
  int i;
  cin >> N >> M >> Q;
  a = b = c = d = vector<int>(Q);
  for(i = 0; i < Q; i++){
    cin >> a[i] >> b[i] >> c[i] >> d[i];
  }
  pei(vector<int>(1,1));
  cout << sum << endl;
  return 0;
}


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

#define rp(i, k, n) for (int i = k; i < n; i++)
typedef long long ll;

ll mod = 1e9 + 7;
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; }
const ll inf = 1ll << 60;



int main() {
    int n;
    scanf("%d", &n);
    ll dam[n];
    rp(i, 0, n) scanf("%lld", &dam[i]);
    ll sum1 = 0ll;
    ll sum2 = 0ll;
    rp(i, 0, n) {
        sum1 += dam[i];
        if(i%2) {
            sum2 += dam[i];
        }
    }
    ll a[n];
    a[0] = (sum1 - sum2 * 2) / 2;
    printf("%lld ", a[0] * 2);
    rp(i, 1, n) {
        a[i] = dam[i-1] - a[i-1];
        printf("%lld ", a[i] * 2);
    }
    return 0;
}


Measured memory_bytes: 2816
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long int ll;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n, z, w;
    cin >> n >> z >> w;
    vector<int> v(n);
    rep(i, n)
    {
        cin >> v[i];
    }
    if (n >= 2)
    {
        cout << max(abs(v[n - 1] - w), abs(v[n - 1] - v[n - 2]));
    }
    else
    {
        cout << abs(v[0] - w) << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mk make_pair
#define fs first
#define sc second
using namespace std;
typedef long long ll;
typedef long double ld;
int a[100010], n;
int mem[100010][33];
int f(int x){
  for(int i=0; i<31; ++i){
    if((1<<i)>=x)
      return i;
  }
}
int dp(int x, int mx){
  if(x==n)
    return 0;
  if(mem[x][mx]!=-1)
    return mem[x][mx];
  int res=0;
  int tmp1=f(a[x]), tmp2;
  tmp2=(1<<tmp1);
  if(tmp2!=a[x]){
    if(mx>=tmp1){
      res=dp(x+1, tmp1-1);
    }
    else{
      res=dp(x+1, tmp1)+tmp1-mx;
    }
  }
  else{
    res=dp(x+1, tmp1)+max(0, tmp1-mx);
  }
  mem[x][mx]=res;
  return res;
}
int main(){
  while(cin>>n){
    memset(mem, -1, sizeof mem);
    for(int i=0; i<n; ++i){
      scanf("%d",&a[i]);
    }
    int ans=dp(0,0);
    printf("%d\n",ans);
  }
  return 0;
}


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

int main(void){
    int a[3][3],x[3],y[3];
    bool ok = true;
    for(int i = 0;i < 3;i++){
        for(int j = 0;j < 3;j++){
            cin >> a[i][j];
        }
    }
    x[0] = 0;
    for(int i = 0;i < 3;i++)y[i] = a[0][i] - x[0];
    for(int j = 0;j < 3;j++)x[j] = a[j][0] - y[0];
    for(int i = 0;i < 3;i++){
        for(int j = 0;j < 3;j++){
            if(x[i] + y[j] != a[i][j])ok = false;
        }
    }
    if(ok == true)cout << "Yes";
    else cout << "No";
}

Measured memory_bytes: 256
import java.util.*;
 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        int T = Integer.parseInt(sc.next());
        int[] c = new int[N];
        int[] t = new int[N];
        int min = 1001;
        for(int i=0; i<N; i++) {
            c[i] = Integer.parseInt(sc.next());
            t[i] = Integer.parseInt(sc.next());
            if(T < t[i]) continue;
            if(min > c[i]) min = c[i];
        }
        if(min == 1001) System.out.println("TLE");
        else System.out.println(min);
    }
    
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
int main() {
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int N,A,B;
    int sum,sum2=0;
    cin >> N >> A >> B;
    FOR(i,A,N+1){
        sum = i/10000 + (i/1000 - i/10000*10) + (i/100 - i/1000*10)+(i/10 - i/100*10) + (i - i/10*10);
        if(A <=sum && sum <=B)
            sum2+= i;
    }
    cout << sum2;
    return 0;
}

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

int main(){
	int p = 0;
  	int q = 0;
    int r = 0;
  	int res = 0;
  	cin >> p >> q >> r;
	res = p+q;
 	res = min(res, q+r);
  	res = min(res, r+p);
	cout << res << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using static System.Math;
using System.Text;
using System.Threading;
using System.Globalization;
using System.Runtime.CompilerServices;
using Library;

namespace Program
{
    public static class ABC150A
    {
        static public int numberOfRandomCases = 0;
        static public void MakeTestCase(List<string> _input, List<string> _output, ref Func<string[], bool> _outputChecker)
        {
        }
        static public void Solve()
        {
            var K = NN;
            var X = NN;
            if (500 * K >= X) Console.WriteLine("Yes");
            else Console.WriteLine("No");
        }
        static class Console_
        {
            static Queue<string> param = new Queue<string>();
            public static string NextString() { if (param.Count == 0) foreach (var item in Console.ReadLine().Split(' ')) param.Enqueue(item); return param.Dequeue(); }
        }
        class Printer : StreamWriter
        {
            public override IFormatProvider FormatProvider { get { return CultureInfo.InvariantCulture; } }
            public Printer(Stream stream) : base(stream, new UTF8Encoding(false, true)) { base.AutoFlush = false; }
            public Printer(Stream stream, Encoding encoding) : base(stream, encoding) { base.AutoFlush = false; }
        }
        static public void Main(string[] args) { if (args.Length == 0) { Console.SetOut(new Printer(Console.OpenStandardOutput())); } var t = new Thread(Solve, 134217728); t.Start(); t.Join(); Console.Out.Flush(); }
        static long NN => long.Parse(Console_.NextString());
        static double ND => double.Parse(Console_.NextString());
        static string NS => Console_.NextString();
        static long[] NNList(long N) => Repeat(0, N).Select(_ => NN).ToArray();
        static double[] NDList(long N) => Repeat(0, N).Select(_ => ND).ToArray();
        static string[] NSList(long N) => Repeat(0, N).Select(_ => NS).ToArray();
        static IEnumerable<T> OrderByRand<T>(this IEnumerable<T> x) => x.OrderBy(_ => xorshift);
        static long Count<T>(this IEnumerable<T> x, Func<T, bool> pred) => Enumerable.Count(x, pred);
        static IEnumerable<T> Repeat<T>(T v, long n) => Enumerable.Repeat<T>(v, (int)n);
        static IEnumerable<int> Range(long s, long c) => Enumerable.Range((int)s, (int)c);
        static uint xorshift { get { _xsi.MoveNext(); return _xsi.Current; } }
        static IEnumerator<uint> _xsi = _xsc();
        static IEnumerator<uint> _xsc() { uint x = 123456789, y = 362436069, z = 521288629, w = (uint)(DateTime.Now.Ticks & 0xffffffff); while (true) { var t = x ^ (x << 11); x = y; y = z; z = w; w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)); yield return w; } }
    }
}
namespace Library {
}


Measured memory_bytes: 12640
#include<bits/stdc++.h>
using namespace std;
#define pii pair<int,int>
const int maxn = 1e3 + 10;
map<pii,int> mp;
pii a[maxn];
int n;
int main() {
	scanf("%d",&n);
	for (int i = 1; i <= n; i++) {
		scanf("%d%d",&a[i].first,&a[i].second);
	}
	sort(a + 1,a + n + 1);
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j < i; j++) {
			mp[pii(a[i].first - a[j].first,a[i].second - a[j].second)]++;
		}
	}
	int mx = 0;
	for (auto it : mp) {
		mx = max(mx,it.second);
	}
	printf("%d\n",n - mx);
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
typedef long long ll;
typedef pair<int, int> P;

ll dp[100001][2] = {};

int main(){
    int n, i, j;
    string l;
    cin >> l;
    n = l.length();
    dp[i][0] = 1;
    for(i=0; i<n; i++){
        if(l[i] == '0'){
            dp[i+1][0] = dp[i][0];
            dp[i+1][1] = 3*dp[i][1]%MOD;
        }else{
            dp[i+1][0] = 2*dp[i][0]%MOD;
            dp[i+1][1] = (3*dp[i][1] + dp[i][0])%MOD;
        }
    }
    cout << (dp[n][0]+dp[n][1])%MOD << "\n";
    return 0;
}

Measured memory_bytes: 2048
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;

public class Main {

    int N,M,K;

    public void solve() {
        N = nextInt();
        M = nextInt();
        K = nextInt();

        for(int i = 0;i <= N;i++) {
            for(int j = 0;j <= M;j++) {
                int sum = N * M - (i * M + j * N) + i * j * 2;
                
                if (K == sum) {
                    out.println("Yes");
                    return;
                }
            }
        }
        out.println("No");
    }

    public static void main(String[] args) {
        out.flush();
        new Main().solve();
        out.close();
    }

    /* Input */
    private static final InputStream in = System.in;
    private static final PrintWriter out = new PrintWriter(System.out);
    private final byte[] buffer = new byte[2048];
    private int p = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (p < buflen)
            return true;
        p = 0;
        try {
            buflen = in.read(buffer);
        } catch (IOException e) {
            e.printStackTrace();
        }
        if (buflen <= 0)
            return false;
        return true;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrint(buffer[p])) {
            p++;
        }
        return hasNextByte();
    }

    private boolean isPrint(int ch) {
        if (ch >= '!' && ch <= '~')
            return true;
        return false;
    }

    private int nextByte() {
        if (!hasNextByte())
            return -1;
        return buffer[p++];
    }

    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = -1;
        while (isPrint((b = nextByte()))) {
            sb.appendCodePoint(b);
        }
        return sb.toString();
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}

Measured memory_bytes: 22996
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define Graph vector<vector<int>>
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1000000007;

int main(){
    int X, Y, Z, K;
    cin >> X >> Y >> Z >> K;
    vector<ll> A(X), B(Y), C(Z);
    rep(i, X) cin >> A[i];
    rep(i, Y) cin >> B[i];
    rep(i, Z) cin >> C[i];

    vector<ll> AB;
    rep(i, X){
        rep(j, Y){
            AB.push_back(A[i] + B[j]);
        }
    }

    sort(all(AB));
    reverse(all(AB));

    vector<ll> ABC;
    int W = AB.size();
    W = min(W, K);
    
    rep(i, W){
        rep(j, Z){
            ABC.push_back(AB[i] + C[j]);
        }
    }

    sort(all(ABC));
    reverse(all(ABC));

    rep(i, K){
        cout << ABC[i] << endl;
    }

}

Measured memory_bytes: 43240
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long int
#define MAX 1000000007
using namespace std;

int main(void){
  int a,b;
  cin >> a >> b;
  if(a > 2*b) cout << a-2*b << endl;
  else cout << 0 << endl;
  return 0;
}


Measured memory_bytes: 256
//----------BHAVIK DIWANI(PICT_COMP)---------------
#include<bits/stdc++.h>
#include<stdlib.h>
#include<stdio.h>
#define mod 1000000007
#define ll long long
#define int long long
#define ull unsigned long long
#define test ll t; cin>>t; while(t--)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define FOR(p,n) for(ll i=p;i<(ll)n;i++)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
ll gcd(ll a,ll b){ if(b==0) return a;    return gcd(b,a%b);}
ll lcm(ll a,ll b) { return (a/gcd(a,b)*b);}
ull power(ull a, ull b) {a %= mod;  ull res = 1;  while (b > 0) { if (b & 1) res = res * a % mod;  a = a * a % mod;  b >>= 1; }  return res%mod; }
ll modmul(ll x, ll y){return (x*y)%mod;}
ll modadd(ll x, ll y){return (x+y)%mod;}
ll modsub(ll x, ll y){return (x-y+mod)%mod;}
ll fact[1000007]={0};
void facto() {fact[0]=1;fact[1]=1;for(int i=2;i<100007;i++)fact[i]=(fact[i-1]*i)%mod;}
ll ncr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(power(fact[r],mod-2)))%mod; res=(res*(power(fact[n-r],mod-2)))%mod; return res;}
ll npr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(power(fact[n-r],mod-2)))%mod; return res;}
#define MAX 1000005
#define forci(p,q) for(int i=p;i<q;i++)
bool prime[MAX];
/*ull sieve()
{
	memset(prime,true,sizeof(prime));
	for(ull p=2;p*p<MAX;p++)
	{
		if(prime[p]==true){
			for(ull i=2*p;i<MAX;i+=p)
			{
				prime[i]=false;
			}
		}
	}
	prime[0]=0;
	prime[1]=0;
}*/
using namespace std;
signed main()
{
	fastio;
	double r;
	cin>>r;
	double circum=3.141592653*2*r;
	cout<<fixed<<setprecision(7)<<circum;
	
	
	
	
	
	
}












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

using namespace std;
typedef long long ll;
typedef long  double lb;
int mod=1e9+7;
const int N=1e5+5;
vector<int>p[N];
queue<int>q;
int vis[N];
int n,m;
int ans;
void bfs(int x)
{
    vis[x]=1; q.push(x);
    while(q.size()){
        int k=q.front();q.pop();
        for(auto v:p[k]){
            if(!vis[v]){
                vis[v]=1;
                q.push(v);
            }
        }
    }
}
int main()
{
    scanf("%d%d",&n,&m);
    for(int i=1;i<=m;i++){
        int x,y,z;
        scanf("%d%d%d",&x,&y,&z);
        p[x].emplace_back(y);
        p[y].emplace_back(x);
    }
    for(int i=1;i<=n;i++){
        if(!vis[i]){
            bfs(i);ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}


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

int main(void) {
  ll N, M, D;
  cin >> N >> M >> D;

  if(D == 0) {
    printf("%.15lf\n", (double) (M - 1) / N);
  } else {
    ll cnt = N * 2 - D * 2;
    printf("%.15lf\n", (double) cnt / (N * N) * (M - 1));
  }
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.run();
    }
    
    // 変数一覧
    int n;

    public void run() {
        // 入力情報取得
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        sc.close();

        // 解答処理
        solve();
    }
    
    private void solve() {
        long ans = 0;
        for (int i = 1; i <= n; i++) {
            if (i % 3 != 0 && i % 5 != 0) {
                ans += i;
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 35772
#include <iostream>

using namespace std;

int main() {

    int k;
    int a[5];

    cin >> a[0] >> a[1] >> a[2] >> a[3] >> a[4] >> k;

    for (int i = 0; i < 5; ++i) {
        for (int j = i; j < 5; ++j) {
//            cout << a[i] << " " << a[j] << " " << k << endl;
            if( abs(a[i] - a[j]) > k ) {
                cout << ":(" << endl;
                return 0;
            }
        }
    }
    cout << "Yay!" << endl;
    return 0;
}

Measured memory_bytes: 256
// Aizu Vol0 0058: Orthogonal
// 2017.7.30

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

char *gets(char *);

#define LLONG long long

#define MAX 500
char buf[MAX + 5], *p;

int GetInt(void)
{
	int minus = 0, len = 0, n = 0;

	while (isspace(*p)) p++;
	if (*p == '-') p++, minus = 1;
	while (isdigit(*p)) n = 10 * n + (*p++ - '0');
	if (*p == '.') p++;
	while (isdigit(*p)) n = 10 * n + (*p++ - '0'), len++;
#define MAGIC 5
	while (len < MAGIC) n = 10 * n, len++;
	if (minus) n = -n;
	//	printf("%10d\n", n);
	return n;
}

int main()
{
	int ax1, ay1, ax2, ay2;
	int bx1, by1, bx2, by2;

	while (gets(p = buf) != NULL) {
		ax1 = GetInt(), ay1 = GetInt();
		ax2 = GetInt(), ay2 = GetInt();
		bx1 = GetInt(), by1 = GetInt();
		bx2 = GetInt(), by2 = GetInt();

		if (ax1 == ax2 && ay1 == ay2) goto NO;
		if (bx1 == bx2 && by1 == by2) goto NO;

		if (ax1 == ax2) {
			if (by1 == by2) goto YES;
			goto NO;
		}

		if (bx1 == bx2) {
			if (ay1 == ay2) goto YES;
			goto NO;
		}

		if ((LLONG)(ay2 - ay1)*(LLONG)(by2 - by1) != -(LLONG)(ax2 - ax1)*(LLONG)(bx2 - bx1)) {
NO:			puts("NO");
		}
		else {
YES:		puts("YES");
		}
	}
	return 0;
}

Measured memory_bytes: 524
import sys
sys.setrecursionlimit(10**6)

n = int(input())
A = list(map(int, input().split()))
#n, m = map(int, input().split())
#s = input()
#s,t = input().split()
#a = [int(input()) for _ in range(n)]
#
#readline = sys.stdin.readline
#n,m = [int(i) for i in readline().split()]
#ab = [[int(i) for i in readline().split()] for _ in range(n)]

ID = [i for i in range(1,n+1)]

ans = 0

for i,a in zip(ID, A):
    if i%2 == 1 and a%2 == 1:
        ans += 1
        
print(ans)

Measured memory_bytes: 9176
#include <bits/stdc++.h>  // include all standard C++ libraries

using namespace std;

// Loops
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define _rrep(i,n) rrepi(i,n,0)
#define rrepi(i,a,b) for(int i=int(a)-1;i>=int(b);--i)

#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(xi, x) for (auto&& xi : x)
// Note: we can use rep(i,N) or rep(i,from,to)


// typedef
using ll = long long;
template <class T> using vec = vector<T>;
using vi   = vector<int>;
using vvi  = vector<vi>;
using vvvi = vector<vvi>;
using pii  = pair<int, int>;


// Constants

// Shorter repr for frequently used terms
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second


// Algorithms
#define all(x) (x).begin(), (x).end()
#define uniq(v) v.erase( unique(all(v)), v.end() )
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))

template<class T> pair<T, size_t> max(vector<T> &x){ auto it = max_element(all(x)); return mp(*it, it-x.begin()); }
template<class T> pair<T, size_t> min(vector<T> &x){ auto it = min_element(all(x)); return mp(*it, it-x.begin()); }

template<class T> inline bool chmax(T &maxval, const T &newval) { if (maxval<newval) { maxval=newval; return 1; } return 0; }
template<class T> inline bool chmin(T &minval, const T &newval) { if (minval>newval) { minval=newval; return 1; } return 0; }

// Utilities
// Grid world utilities
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
#define inside(H,W,y,x) 0<=(x) && (x)<(W) && 0<=(y) && (y)<(H)

inline int in() {int x; cin >> x; return x;} // read int from cin
inline  ll IN() {ll x; cin >> x; return x;}  // read ll from cin



// Debug
#ifdef LOCAL
  #include "dump.hpp"
  #define debug(x) cerr << #x << ": " << x << '\n'
#else
  #define dump(...)
  #define debug(x)
#endif

// Paste snippets here!!
ll f(ll x0, const vector<ll> &a){
  int n = a.size();
  ll x = x0;
  rep(i,n){
    x = 2*a[i] - x;
    if(x<0) return 1;
  }
  if(x==x0) return 0;
  if(x<x0) return 1;
  return -1;
}
// 

int main(){
  cin.tie(0); ios::sync_with_stdio(false);    // Magic for faster cin
  int n; cin >> n;
  vector<ll> a(n);
  rep(i,n) cin >> a[i];
  dump(a);

  ll x0 = 0;
  rep(i,n) x0 += a[i];
  rep(i,n) {
    if(i%2) x0 -= 2*a[i];
  }
  rep(i,n-1){
    cout << x0 << " ";
    x0 = 2*a[i] - x0;
  }
  cout << x0 << endl;
  return 0;
}


Measured memory_bytes: 2176
fn read_stdin() -> String {
    use std::io::Read;
    let mut input = String::new();
    std::io::stdin().read_to_string(&mut input).unwrap();
    input
}

fn scan<'a, I: Iterator<Item = &'a str>, T: std::str::FromStr>(tokens: &mut I) -> T {
    tokens.next().unwrap().parse().ok().unwrap()
}

fn main() {
    let input = read_stdin();
    let tokens = &mut input.split_whitespace();
    let n: usize = scan(tokens);
    let mut conditions: Vec<usize> = vec![10; n];
    let m: usize = scan(tokens);
    for _ in 0..m {
        let s: usize = scan(tokens);
        let s = s - 1;
        let c: usize = scan(tokens);
        if n > 1 && s == 0 && c == 0 {
            println!("-1");
            return;
        } else if conditions[s] == 10 {
            conditions[s] = c;
        } else if conditions[s] != c {
            println!("-1");
            return;
        }
    }
    for i in 0..n {
        if conditions[i] == 10 {
            if n > 1 && i == 0 {
                conditions[i] = 1;
            } else {
                conditions[i] = 0;
            }
        }
        print!("{}", conditions[i]);
    }
    println!("");
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define ri rd<int>
#define rep(i, a, b) for (int i = (a), _ = (b); i <= _; ++i)
#define per(i, a, b) for (int i = (a), _ = (b); i >= _; --i)
#define For(i, a, b) for (int i = (a), _ = (b); i < _; ++i)
typedef long long LL;
const int maxN = 10007;

template<class T> T rd() {
	bool f = 1; char c = getchar(); for (; !isdigit(c); c = getchar()) if (c == '-') f = 0;
	T x = 0; for (; isdigit(c); c = getchar()) x = x * 10 + c - '0'; return f ? x : -x;
}

int n;
int a[maxN], b[maxN];
LL A = 0, B = 0;

int main() {

	n = ri();
	rep (i, 1, n) a[i] = ri();
	rep (i, 1, n) b[i] = ri();
	rep (i, 1, n) {
		if (a[i] < b[i]) {
			int t = (b[i] - a[i] + 1) >> 1;
			a[i] += t << 1;
			A += t;
		}
		if (a[i] > b[i]) {
			int t = a[i] - b[i];
			B += t;
		}
	}
	puts(A >= B ? "Yes" : "No");

	return 0;
}


Measured memory_bytes: 384