akhauriyash/Code-Regression huggingface dataset:
N = gets.to_i
A = gets.split.map(&:to_i)

counter = Hash.new(0)

A.each do |a|
  counter[a] += 1
  counter[a] = 1 if counter[a] == 3
end

c = counter.count { |k, v| v == 2 }

if c % 2 == 0
  puts A.uniq.size
else
  puts A.uniq.size - 1
end


Measured memory_bytes: 24452
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<string>
#include<queue>
#include<utility>
#include<cmath>
#include<sstream>
#include<istream>
#include<numeric>

using namespace std;


int main()
{
  int N, M;

  cin >> N >> M;

  vector<int> A(N);

  int sum = 0;

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

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

  if(A[N-M] >= sum*(1.0/(4.0*(double)M))){
    cout << "Yes" << endl;
  }
  else  cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 256
use std::io;

fn get_line() -> String {
    let mut input = String::new();
    io::stdin().read_line(&mut input).unwrap();
    input
}

fn main() {
    let hoge = get_line();
    let ab: Vec<u8> = hoge.trim().split(" ").map(|x| x.parse().unwrap()).collect();
    let (a, b) = (ab[0], ab[1]);
    if ((a + b) % 3 == 0 || a % 3 == 0 || b % 3 == 0) {
        println!("Possible");
    } else {
        println!("Impossible");
    }
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define All(x) (x).begin(),(x).end()
using namespace std;
using ll = long long;

int main(){
    int N,K;cin>>N>>K;
    vector<ll> x(N);
    REP(i,N) cin>>x[i];
    ll ans=1e18;
    K--;
    REP(i,N-K){
        if(x[i]<0&&x[i+K]>0){
            ans=min(ans,x[i+K]-x[i]+min(-x[i],x[i+K]));
        }
        else if(x[i+K]>0) ans=min(ans,x[i+K]);
        else ans=min(ans,-x[i]);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 1024
from itertools import combinations
N = int(input())
if N == 1:
    print(0)
    exit(0)
def get_sieve_of_eratosthenes(n):
    import math
    if not isinstance(n, int):
        raise TypeError('n is int type.')
    if n < 2:
        raise ValueError('n is more than 2')
    prime = []
    limit = math.sqrt(n)
    data = [i + 1 for i in range(1, n)]
    while True:
        p = data[0]
        if limit <= p:
            return prime + data
        prime.append(p)
        data = [e for e in data if e % p != 0]
    return prime
prime = get_sieve_of_eratosthenes(N)
n = len(prime)
ans = 0
divNum = [0] + [ N//i for i in range(1,N+1) ]
for p in prime:
    ip = p * p
    while ip <= N:
        divNum[p] += divNum[ip]
        ip *= p

for i in range(n):
    if 74 <= divNum[prime[i]]:
        ans += 1
    for j in range(n):
        if i != j and 4 <= divNum[prime[i]] and 14 <= divNum[prime[j]]:
            ans += 1
        if i != j and 2 <= divNum[prime[i]] and 24 <= divNum[prime[j]]:
            ans += 1
        for k in range(j+1,n):
            if i != j and i != k:
                if 2 <= divNum[prime[i]] and 4 <= divNum[prime[j]] and 4 <= divNum[prime[k]]:
                    ans += 1
            
print(ans)


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

#define eps 1e-5

int solve(int N,int K){
  if (N==0) return 1;
  int m = 1 + floor(log(N+eps) / log(K));
  return m;
}

int main() {
    int n,k; cin>>n>>k;
    cout << solve(n,k) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#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 show(x) {for(auto i: x){cout << i << " ";} cout<<endl;}
#define showm(m) {for(auto i: m){cout << m.x << " ";} cout<<endl;}
typedef long long ll;
typedef pair<int, int> P;
ll gcd(int x, int y){ return y?gcd(y, x%y):x;}
ll lcm(ll x, ll y){ return (x*y)/gcd(x,y);}


const int COL_MAX = 1010;
int choko[10][COL_MAX] = {0};

int main()
{
    int h, w, k;
    cin >> h >> w >> k;
 
    rep(i, h){
        string s;
        cin >> s;
        rep(j, w){
            choko[i][j] = s[j] - '0';
        }
    }

    int ans_min = MOD;
    rep(i, 1<<(h-1)){
        vector<int> divide;
        int ans = 0;
        divide.push_back(0);
        rep(i2, h-1){
            if ((i>>i2)&1==1){
                //h=10:0010010011 => (0,)1,2,5,8(,10)
                divide.push_back(i2+1);
                ans++;
            }
        }
        divide.push_back(h);
        //show(divide);
        //cout << i << ":";
        vector<int> sum_len(h);
        rep(j, w){
            vector<int> sum_sum_len(h+1, 0);
            vector<int> oneline_sum(h+1, 0);
            rep(i2, h){
                sum_len[i2] += choko[i2][j];
            }
            rep(i2, h){
                sum_sum_len[i2+1] = sum_sum_len[i2] + sum_len[i2];
                oneline_sum[i2+1] = oneline_sum[i2] + choko[i2][j];
            }
            int max_sum = 0;
            int oneline_block_sum = 0;
            rep(div, divide.size()-1){
                int block_sum = sum_sum_len[divide[div+1]] - sum_sum_len[divide[div]]; 
                int oneline_block = oneline_sum[divide[div+1]] - oneline_sum[divide[div]];
                max_sum = max(max_sum, block_sum);
                oneline_block_sum = max(oneline_block_sum, oneline_block);              
            }
            //cout << i << ":" << j << ":"<< max_sum << endl;  

            if (oneline_block_sum > k) {
                ans = MOD;
                break;
            }
            if (max_sum > k){
                //reset
                rep(i2, h){
                    sum_len[i2] = choko[i2][j];
                }
                ans++;
            }
        }
        ans_min = min(ans_min, ans);
    }
    cout << ans_min << endl;
}



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

int main(){
  int n;
  cin >> n;
  vector<long long int> l(n+1);
  l.at(0)=2;
  l.at(1)=1;
  for(int i=2;i<n+1;i++){
    l.at(i)=l.at(i-1)+l.at(i-2);
  }
  cout << l.at(n) << endl;
}


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

char map[255][255];

int dire4[][2] = {
    {1, 0}, {-1, 1}, {0, 1}, {1, 1}, 
    {-1, -1}, {0, -1}, {1, -1}, {-1, 0}
};

int main(){
    int n;
    while(1){
        cin >> n;
        if(n == 0) break;

        for(int y = 0;y < n;y++) {
            for(int x = 0;x < n;x++) {
                cin >> map[y][x];
            }
        }

        int ans = 0;
        for(int y = 0;y < n;y++) {
            for(int x = 0;x < n;x++) {
                for(int z = 0;z < 8;z++) {
                    int dx = dire4[z][0], dy = dire4[z][1];
                    int cx = x, cy = y;
                    int c = 0;
                    for(;map[cy][cx] == '1' && 0 <= cx && cx < n && 0 <= cy && cy < n;) {
                        cx += dx;
                        cy += dy;
                        c++;
                    }
                    ans = max(ans, c);
                }
            }
        }
        cout << ans << endl;

    }
}

Measured memory_bytes: 1224
#include <iostream>
#include <algorithm>
#include <fstream>
#include <cstdio>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <set>
#include <map>
#include <stdlib.h>
#include <string.h>


#define show(x) cerr << "# " << #x << " = " << (x) << endl

#define FOR(i, a, b) for(__typeof(a) i = a; i != b; i++)
#define FR(i, a) FOR(i, 0, a)
#define FOREACH(i, t) FOR(i, t.begin(), t.end())
#define ALL(x) (x).begin(), (x).end()
#define SZ(a) int(a.size())
#define PB push_back
#define MP make_pair
#define F first
#define S second


#define _USE_MATH_DEFINES
using namespace std;

inline bool ascending(int i, int j) { return (i < j); }
inline bool descending(int i, int j) { return (i > j); }

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

const int MN = 200000 + 1;


ll solve(string s){

	ll res = 0;
	if (SZ(s) == 0)
		return 0 ;
	ll num = 0;
	for (int i = 0; i < SZ(s)-1; ++i)
	{
		num = num*10 + s[i] - '0';
		res += (num) * (1 << (SZ(s) - i - 2));
		res +=solve( s.substr(i+1));
	}
	num = num *10 + s[SZ(s)-1] - '0';
	res += num;
	//show(s);
	//show(res);
	return res;
}

int main(){
	string s;
	cin >> s;
	cout << solve(s) << endl;
	return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n, m;
	cin >> n >> m;
	priority_queue<int> pq;
	for (int i = 0; i < n; i++) {
		int x;
		cin >> x;
		pq.push(x);
	}
	while (m--) {
		int x = pq.top();
		pq.pop();
		pq.push(x / 2);
	}
	long long sum = 0;
	while (!pq.empty()) {
		sum += pq.top();
		pq.pop();
	}
	cout << sum;
	return 0;
}

Measured memory_bytes: 892
#include<stdio.h>

double calc(int a, char op[2], int b){
	if (op[0] == '+')
		return a + b;
	else if (op[0] == '-')
		return a - b;
	else if (op[0] == '*')
		return a*b;
	else if (op[0] == '/')
		return a / b;
	else
		return 0.0;
}

int main(void){
	int a[1000], b[1000];
	char op[1000][2];

	int i=0;
	while (1){
		scanf("%d %s %d", &a[i], op[i], &b[i]);
		if (op[i][0] == '?')
			break;

		i++;
	}
	int n = i;
	for (i = 0; i < n; i++){
		printf("%.0f\n", calc(a[i], &op[i][0], b[i]));
	}


	return 0;
}


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

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

  a=n%10;
  n/=10;
  b=n%10;
  n/=10;
  c=n%10;
  n/=10;

  if((a==b && b==c)||(b==c && c==n)) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;  
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S; cin >> S;
    int L = INF, R = 0;
    rep(i, S.length()) {
        if (S[i] == 'A') L = min(L, i);
        if (S[i] == 'Z') R = max(R, i);
    }
    cout << R - L + 1 << endl;

    return 0;
}


Measured memory_bytes: 720
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
const int maxn = 100010;
int n, x[maxn], nxt[maxn][18], q, l;
int main()
{
    scanf("%d", &n);
    for(int i = 1; i <= n; i++) scanf("%d", &x[i]);
    scanf("%d", &l);
    for(int i = 1; i <= n; i++)
        nxt[i][0] = upper_bound(x + 1, x + 1 + n, x[i] + l) - x - 1;
    for(int i = 1; i <= 17; i++)
        for(int j = 1; j <= n; j++)
            nxt[j][i] = nxt[nxt[j][i - 1]][i - 1];
    scanf("%d", &q);
    while(q--) {
        int a, b, ans = 0;
        scanf("%d %d", &a, &b);
        if(a > b) swap(a, b);
        if(a == b) {
            puts("0");
            continue;
        }
        for(int i = 17; i >= 0; i--)
            if(nxt[a][i] < b) {
                a = nxt[a][i];
                ans += (1 << i);
            }
        printf("%d\n", ans + 1);
    }
    return 0;
}

Measured memory_bytes: 8192
#include <iostream>
using namespace std;
 
int main() {
    int N;
    unsigned int A[200],count=0;
  	bool is_even = true;
  	cin >> N;
  	for(int i = 0;i<N;i++){
    	cin >> A[i];
      	if(A[i]%2==1) is_even=false;
    }
  	while(is_even){
      	count++;
  		for(int i = 0;i<N;i++){
    		A[i]=A[i]/2;
          	if(A[i]%2==1) is_even=false;
    	}
    }
  	cout << count << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <vector>
#include <queue>
#include <string>
#include <limits>
#include <algorithm>
#include <map>
#include <sstream>
#include <unordered_map>

using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
static ull tenq = 1000000000;
static ull mod = tenq + 7;

using namespace std;

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

  ll numB = 0;
  ll res = 0;
//  cout << s << endl;
  for (auto i = 0; i < s.size(); i++) {
//    cout << i << " " << numB << endl;
    if (s[i] == 'B') numB++;
    else {
      res += numB;
    }
  }

  cout << res << endl;

  return 0;
}


Measured memory_bytes: 1336
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define pb push_back

ll euclidean_gcd(ll a, ll b) {
  if(a < b) return euclidean_gcd(b, a);
  ll r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

int main(){
    ll n,x;
    cin >> n >> x;
    vector<ll> xx;
    ll now;
    xx.pb(x);
    for(ll i=0;i<n;i++){
        ll s;
        cin >> s;
        xx.pb(s);
    }
    sort(xx.begin(),xx.end());
    ll y[n];
    for(int i=0;i<n;i++){
        y[i]=xx[i+1]-xx[i];
    }
    now=y[0];

    for(ll i=1;i<n;i++){
        now=euclidean_gcd(now,y[i]);
    }
    cout << now << endl;
    return 0;
}

Measured memory_bytes: 1908
import math
n = int(input())

start = (0,0)
end = (100,0)

def koch(n,p1,p2):
    if n == 0:
        return

    s = ( (p1[0]*2 + p2[0])/3, (p1[1] *2 + p2[1])/3 )
    t = ( (p1[0] + p2[0]*2)/3, (p1[1] + p2[1] *2)/3 )

    ux = (t[0] - s[0])/2 - (t[1] - s[1])*math.sqrt(3)/2 + s[0]
    uy = (t[0] - s[0])*math.sqrt(3)/2 + (t[1] - s[1])/2 + s[1]
    u = (ux, uy)
    koch(n-1,p1, s)
    ppp(s)
    koch(n-1, s, u)
    ppp(u)
    koch(n-1, u, t)
    ppp(t)
    koch(n-1, t,p2)

def ppp(t):
    print("{:.08f} {:.08f}".format(t[0],t[1]))

ppp(start)
koch(n,start,end)
ppp(end)



Measured memory_bytes: 5748
using System;

class A{
    static int top;
    static int[] s = new int[300];
    public static void Main() {
        string[] Stack = Console.ReadLine().Split(' ');
        foreach(string d in Stack) {
            int i;
            if (Int32.TryParse(d,out i)) {
                Push(i);
            } else {
                int a = Pop();
                int b = Pop();
                switch (d) {
                    case "+": {                            
                        Push(a+b);
                        break;
                    }
                    case "-": {
                        Push(b-a);
                        break;
                    }
                    case "*": {
                        Push(a*b);
                        break;
                    }
                    default: {
                        Console.Error.WriteLine("Can't Calcurate");
                        break;
                    }
                }
            }
        }
        Console.WriteLine(s[top]);
    }

    public static void Push(int x) {
        if (top > s.Length) {
            Console.Error.WriteLine("Stack OverFlow");
        }
        top++;
        s[top] = x;
    }

    public static int Pop() {
        if (top < 0) {
            Console.Error.WriteLine("Stack UnderFrow");
        }
        top--;
        return s[top + 1];
    }

}


Measured memory_bytes: 9244
#include <cmath>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <iomanip>
#include <map>
#include <stack>
#include <queue>
    
using namespace std;

typedef long long ll;

int main() {
    ll a,b,la,lb;
    cin>>a>>b;
    
    if(a%4==0) la=0;
    else if(a%4==1) la=a-1;
    else if(a%4==2) la=1;
    else la=a;
    if(b%4==0) lb=b;
    else if(b%4==1) lb=1;
    else if(b%4==2) lb=b+1;
    else lb=0;
    ll ans=la^lb;
    
    cout<<ans<<endl;
}

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

using namespace std;

using ll = long long;
using vi = vector<int>;
using pi = pair<int,int>;

int MOD = 1e9+7;

//ll po(ll b, ll p){ return !p?1:po(b*b%MOD,p/2)*(p&1?b:1)%MOD;}
// ll pomd(ll a, ll k, ll md) { ll p; if (k == 0){ return 1; } p = pomd(a, k / 2, md); p = p * p % md; if (k % 2){ p = p * a % md; } return p; }
// counting divsrs: vi arr(N); for(int i{1}; i<N; ++i) for(int j=i; j<N; j+=i) d[j]++;

#define mp make_pair
#define pb push_back
#define rsz resize
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)

void setIO(string name = ""){
    freopen((name+".in").c_str(), "r", stdin); 
    freopen((name+".out").c_str(), "w", stdout);
}	

int main(){
 	ios_base::sync_with_stdio(0); cin.tie(0); 
	// setIO();
	ll h,n; cin >> h >> n;
	vi arr(n);
	for(int i{}; i<n; i++) cin >> arr[i];
	sort(all(arr), greater<int>());
	for(int i{}; i<n; i++){
		h-=arr[i];
		if(h<=0){
			cout << "Yes" << "\n";
			return 0;
		}
	}

	if(h<=0){
		cout << "Yes" << "\n";
	}else{
		cout << "No" << "\n";	
	}



}





Measured memory_bytes: 3712
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<algorithm>
#include<queue>
#include<vector>
#define ll long long
#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b)
#define inf 0x3f3f3f3f
#define mod 1000000007
#define eps 1e-18
inline ll read()
{
    ll tmp=0; char c=getchar(),f=1;
    for(;c<'0'||'9'<c;c=getchar())if(c=='-')f=-1;
    for(;'0'<=c&&c<='9';c=getchar())tmp=(tmp<<3)+(tmp<<1)+c-'0';
    return tmp*f;
}
using namespace std;
char s[310];
int f[2][310][310];
int n,m;
int main()
{
	int i,j,k;
	scanf("%s",s); n=strlen(s); m=read();
	int ans=0;
	for(k=0;k<=m;k++){
		for(i=0;i<n;i++)
			f[k&1][i][i]=1,f[k&1][i+1][i]=0;
		for(i=1;i<n;i++)
			for(j=0;j+i<n;j++){
				int l=j,r=j+i;
				f[k&1][l][r]=max(f[k&1][l+1][r],f[k&1][l][r-1]);
				if(s[l]==s[r])f[k&1][l][r]=max(f[k&1][l][r],f[k&1][l+1][r-1]+2);
				else if(k>0)f[k&1][l][r]=max(f[k&1][l][r],f[(k&1)^1][l+1][r-1]+2);
			}
		
		ans=max(ans,f[k&1][0][n-1]);
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 896
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
// #pragma GCC optimize("unroll-loops")

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

using namespace std;
using namespace __gnu_pbds;

#define DEBUG
#ifdef DEBUG
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
	template <typename Arg1>
	void __f(const char* name, Arg1&& arg1)
	{
		cerr << name << " = " << arg1 << endl;
	}
	template <typename Arg1, typename... Args>
	void __f(const char* names, Arg1&& arg1, Args&&... args)
	{
		const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " = " << arg1 << " || ";
		__f(comma+1, args...);
	}
#else
#define debug(...)
#endif

template <class Ch, class Tr, class Container>
basic_ostream <Ch, Tr> & operator << (basic_ostream <Ch, Tr> & os, Container const& x) {
    os << "{ ";
    for(auto& y : x) os << y << " ; ";
    return os << "}";
}

template <class X, class Y>
ostream & operator << (ostream & os, pair <X, Y> const& p) {
	return os << "[ " << p.first << ", " << p.second << "]" ;
}

#define FAST_IO std::ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long int
#define pb push_back
#define mp make_pair
#define ld long double
#define sz(a) (ll)(a).size()
#define endl "\n"

// priority_queue<ll, vector<ll>, less<ll>>pq;     // Max Heap
// priority_queue<ll, vector<ll>, greater<ll>>pq;  // Min Heap

typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
//K-th smallest
//cout << k << "kth (1 based indexing) smallest: " << *A.find_by_order(k - 1) << endl;
//NO OF ELEMENTS < X
//cout << "No of elements less than " << X << " are " << A.order_of_key(X) << endl;

int main()
{
	FAST_IO;

    ll x, y;
    cin >> x >> y;
    ll w = y - 2 * x;
    if(w % 2 == 1)
    {
    	cout << "No" << endl;
    	return 0;
    }
    w /= 2;
    if(w >= 0 && w <= x) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

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

template <typename T, typename E>
struct SegmentTree {
	typedef function<T(T, T)> F;
	typedef function<T(T, E)> G;
	typedef function<E(E, E)> H;
	typedef function<E(E, int)> P;
	int n;
	F f;
	G g;
	H h;
	P p;
	T d1;
	E d0;
	vector<T> dat;
	vector<E> laz;
	SegmentTree(int n_, F f, G g, H h, T d1, E d0,
		vector<T> v = vector<T>(), P p = [](E a, int b) {return a; }) :
		f(f), g(g), h(h), d1(d1), d0(d0), p(p) {
		init(n_);
		if (n_ == (int)v.size()) build(n_, v);
	}
	void init(int n_) {
		n = 1;
		while (n < n_) n *= 2;
		dat.clear();
		dat.resize(2 * n - 1, d1);
		laz.clear();
		laz.resize(2 * n - 1, d0);
	}
	void build(int n_, vector<T> v) {
		for (int i = 0; i < n_; i++) dat[i + n - 1] = v[i];
		for (int i = n - 2; i >= 0; i--)
			dat[i] = f(dat[i * 2 + 1], dat[i * 2 + 2]);
	}
	inline void eval(int len, int k) {
		if (laz[k] == d0) return;
		if (k * 2 + 1 < n * 2 - 1) {
			laz[k * 2 + 1] = h(laz[k * 2 + 1], laz[k]);
			laz[k * 2 + 2] = h(laz[k * 2 + 2], laz[k]);
		}
		dat[k] = g(dat[k], p(laz[k], len));
		laz[k] = d0;
	}
	T update(int a, int b, E x, int k, int l, int r) {
		eval(r - l, k);
		if (r <= a || b <= l) return dat[k];
		if (a <= l && r <= b) {
			laz[k] = h(laz[k], x);
			return g(dat[k], p(laz[k], r - l));
		}
		return dat[k] = f(update(a, b, x, k * 2 + 1, l, (l + r) / 2),
			update(a, b, x, k * 2 + 2, (l + r) / 2, r));
	}
	T update(int a, int b, E x) {
		return update(a, b, x, 0, 0, n);
	}
	T query(int a, int b, int k, int l, int r) {
		eval(r - l, k);
		if (r <= a || b <= l) return d1;
		if (a <= l && r <= b) return dat[k];
		T vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
		T vr = query(a, b, k * 2 + 2, (l + r) / 2, r);
		return f(vl, vr);
	}
	T query(int a, int b) {
		return query(a, b, 0, 0, n);
	}
};

int main() {
	long long N, D, A, ANS = 0;
	vector<pair<long long, long long> > V;
	vector<long long> W;
	cin >> N >> D >> A;
	V.resize(N), W.resize(N);
	for (int i = 0; i < N; i++) cin >> V[i].first >> V[i].second, W[i] = V[i].first;
	sort(V.begin(), V.end()), sort(W.begin(), W.end());
	SegmentTree<long long, long long> Seg(N,
		plus<long long>(),
		plus<long long>(),
		plus<long long>(),
		0, 0, vector<long long>(N, 0),
		multiplies<long long>());
	for (int i = 0; i < N; i++) {
		long long X = Seg.query(i, i + 1), Y;
		if (X >= V[i].second) continue;
		Y = V[i].second - X;
		long COUNT = (Y + A - 1) / A;
		long long P = V[i].first + D + D;
		long long Q = upper_bound(W.begin(), W.end(), P) - W.begin();
		Seg.update(i, Q, COUNT * A);
		ANS += COUNT;
	}
	cout << ANS << endl;
}

Measured memory_bytes: 16256
#include<stdio.h>
#include<stdlib.h>
int cmp(const void *a, const void *b)
{
    return *(int*)b-*(int*)a;
}
int s[100005];
int main()
{
    unsigned long long int a=0;
    unsigned long long int b=0;
    int flaga=0;
    int flagb=0;
    int n;
    unsigned long long int ans;
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%d",&s[i]);
    }
    qsort(s,n,sizeof(int),cmp);
    for(int i=0;i<n;){
        if(s[i]==s[i+1] && flaga==0){
            a=s[i];
            i+=2;
            flaga=1;
        }
        else if(s[i]==s[i+1] && flagb==0){
            b=s[i];
            i+=2;
            flagb=1;
        }
        else{
            i++;
        }
    }
    ans=a*b;
    printf("%llu\n",ans);
}


Measured memory_bytes: 892
#include <bits/stdc++.h>
#define int long long
#define FOR(i,a,b) for (int i = a; i <= b; ++i)
#define ROF(i,a,b) for (int i = b; i >= a; --i)
using namespace std;

const int N = 5010, P = 1e9+7;

int n, p[N], f[N], siz[N], k;
int dp[N][N], poww[N], fact[N];
int ans, cnt;
vector<int> v;

int find(int x) { return f[x]==x?x:f[x]=find(f[x]); }
int ksm(int a, int x) {
	int ret = 1;
	for (; x; x >>= 1, a = (a*a)%P) if (x&1) (ret *= a) %= P;
	return ret;
}

signed main() {
	cin >> n;
	poww[0] = fact[0] = 1;
	FOR(i,1,n) {
		poww[i] = poww[i-1]*(n-1)%P;
		fact[i] = fact[i-1]*i%P;
	}
	FOR(i,1,n) f[i] = i;

	FOR(i,1,n) {
		cin >> p[i];
		if (p[i] != -1) f[find(p[i])] = find(i);
	}
	FOR(i,1,n) siz[find(i)]++;
	FOR(i,1,n) {
		if (p[i] == -1) {
			v.push_back(siz[find(i)]);
			siz[find(i)] = 0;
		}
	}
	FOR(i,1,n) if (f[i] == i && siz[i]) cnt++;
	k = v.size();
	ans = (poww[k]*(n-cnt))%P;
	dp[0][0] = 1;

	FOR(i,1,k) {
		FOR(j,0,k) {
			dp[i][j] = dp[i-1][j];
			if (j) (dp[i][j] += dp[i-1][j-1]*v[i-1]) %= P;
		}
	}
	FOR(i,2,k) (ans -= dp[k][i]*fact[i-1]%P*poww[k-i]%P) %= P;
	FOR(i,0,k-1) (ans -= (v[i]-1)*poww[k-1]%P) %= P;
	cout << (ans+P)%P << endl;
}


Measured memory_bytes: 199592
n = int(input())

a = list(range(1, 10))
z = list(range(1, 10))

az = []
az_r = []
az0 = []
az1 = []
for i in a:
    for j in z:
        az.append(i*10+j)
        az_r.append(i+j*10)
        az0.append(0)
        az1.append(0)

for i in range(1, n+1):
    if i < 10:
        j = i*10+i
    else:
        j = i
    str1 = str(j)
    str_index = int(str1[0])*10 + int(str1[-1])
    str_index_r = int(str1[0]) + int(str1[-1])*10
    if int(str1[-1]) != 0 and int(str1[0]) != 0:
        az0[az.index(str_index)] += 1
        az1[az.index(str_index_r)] += 1

ans = 0
for i in range(len(az0)):
    if az0[i] >0 and az1[i] >0:
        ans += az0[i]*az1[i]

print(ans)

Measured memory_bytes: 3064
#include <stdio.h>

int main(void) {

  int h,w;
  scanf("%d %d", &h, &w);
  int c[10][10];
  for (int i = 0; i < 10; i++) {
    for (int j = 0; j < 10; j++) {
      scanf("%d", &c[i][j]);
    }
  }
  int a[h][w];
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      scanf("%d", &a[i][j]);
    }
  }
  int flag;
  while (1) {
    flag = 0;
    for (int i = 0; i < 10; i++) {
      for (int j = 0; j < 10; j++) {
        for (int k = 0; k < 10; k++) {
          if (c[i][k]+c[k][j] < c[i][j]) {
            c[i][j] = c[i][k]+c[k][j];
            flag = 1;
          }
        }
      }
    }
    if (flag == 0) {
      break;
    }
  }
  long magic = 0;
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      if (a[i][j] != -1 && a[i][j] != 1) {
        magic += c[a[i][j]][1];
      }
    }
  }
  printf("%ld\n", magic);

  return 0;
}

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

const int maxn = 1e5 + 10;
int n, a[maxn], b[maxn], c[maxn], f[3][maxn];

int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) {
		scanf("%d %d %d", a + i, b + i, c + i);
		f[0][i] = max(f[1][i - 1], f[2][i - 1]) + a[i];
		f[1][i] = max(f[0][i - 1], f[2][i - 1]) + b[i];
		f[2][i] = max(f[0][i - 1], f[1][i - 1]) + c[i];
	}
	printf("%d", max(f[0][n], max(f[1][n], f[2][n])));
	return 0;
}

Measured memory_bytes: 2560
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>

using namespace std;
using ll = long long;

#define INF 1000000007
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((int)(x).size())
#define MSG(a) cout << #a << " " << a << endl;

int main()
{
    int n, k;
    cin >> n >> k;
    vector<int> h(n);
    int min_h = INF;
    for (int i = 0; i < n; i++) {
        cin >> h[i];
    }
    sort(ALL(h));
    for (int i = 0; i < n-k+1; i++) {
        min_h = min(min_h, h[i+k-1] - h[i]);
    }
    cout << min_h << endl;

    return 0;
}


Measured memory_bytes: 640
import java.util.*;

public class Main{
  public static void main(String[]args){
    Scanner sc = new Scanner(System.in);
    long N = sc.nextLong();
    long M = sc.nextLong();
    long n, m;
    if(N >= 2){
      n = N-2;
    }else{
      n = 1;
    }
    
    if(M >= 2){
      m = M-2;
    }else{
      m = 1;
    }
    
    long ans = 0;
    ans += n * m;
    
    System.out.println(ans);
  }
}

Measured memory_bytes: 21716
#include <cstdio>
#include <iostream>
#include <string>
using namespace std;
int main() {
    int n;
    int a = 0, b = 0;
    scanf("%d", &n);
    while(n--) {
        string t, h;
        cin >> t >> h;
        int vic = t.compare(h);
        if(vic > 0) a += 3;
        else if(vic < 0) b += 3;
        else {a++; b++;}
    }
    printf("%d %d\n", a, b);
}


Measured memory_bytes: 3332
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;
ll dp[2001];
int main() {
	ll s; cin >> s;
	dp[3] = 1;
	for (ll i = 4; i <= s; i++)
		dp[i] = (dp[i-1] + dp[i-3]) % MOD;
	cout << dp[s] << '\n';
	return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <string.h>
#include <stack>
#define Endl endl
#define mp make_pair
#define rep(N) for(int i=0;i<N;i++)
#define repj(N) for(int j=0;j<N;j++)
#define ll long long 
#define pii pair<int,int>
#define pll pair<ll,ll>
#define For(I,N) for(int I=0;I<N;I++)
#define cinone(N) int N;cin>>N;
#define scanfone(N) int N;cin>>N;
#define cinng(N,M) int N[M];for(int yiuytvnm=0;yiuytvnm<M;yiuytvnm++) cin>>N[yiuytvnm];
#define scanfng(N,M) int N[M];for(int qrwuoiq=0;qrwuoiq<M;qrwuoiq++) scanf("%d",&N[qrwuoiq]);
#define over(A) {cout<<A<<endl;exit(0);}
#define all(A) A.begin(),A.end()
#define ceil(a,b) ((a-1)/b+1)
typedef unsigned long long ull;
const int inf=1039074182;
const int mod=1e9+7;
using namespace std;
pii a[1005];
pii b[1005];
bool usex[1005];
bool usey[1005];
int n,m;

int main()
{
//	freopen("input.txt","r",stdin);
	cin>>n>>m;
	for(int i=0;i<n;i++)
	{
		scanf("%d",&a[i].first);
		a[i].second=i;
	}
	for(int j=0;j<m;j++)
	{
		scanf("%d",&b[j].first);
		b[j].second=j;
	}
	ll res=1;
	sort(a,a+n);
	sort(b,b+m);
	reverse(a,a+n);
	reverse(b,b+m);
//	for(int i=0;i<n;i++)
//	{
//		cout<<a[i].first<<'-'<<a[i].second<<' ';
//	}
//	cout<<endl;
//	for(int j=0;j<m;j++)
//	{
//		cout<<b[j].first<<'-'<<b[j].second<<' ';
//	}
//	cout<<endl;
	int i=0,j=0;
	int xk=0,yk=0;
	int xu=0,yu=0;
	int su=0;
	for(int k=n*m;k>=1;k--)
	{
		if(a[i].first==k && b[j].first==k)
		{
			usex[a[i].second]=true;
			usey[b[j].second]=true;
			xk++;
			yk++;
			i++;
			j++;
			su++;
		}
		else if(a[i].first==k)
		{
			res*=yk;
			res%=mod;
			usex[a[i].second]=true;
			xk++;
			i++;
			su++;
		}
		else if(b[j].first==k)
		{
			res*=xk;
			res%=mod;
			usey[b[j].second]=true;
			yk++;
			j++;
			su++;
		}
		else
		{
			res*=((((1LL*xk*yk)%mod-su))%mod+mod)%mod;
			su++;
			res%=mod;
		}
	}
	cout<<res<<endl;
//	int pre=n*m+1;
//	while(true)
//	{
//		if(max(a[i].first,b[j].first)!=pre-1) over(0);
//		pre--;
//		if(a[i].first==b[j].first)
//		{
//			if(a[i+1].first==a[i].first || b[j+1].first==b[j].first) over(0);
//			if(usex[a[i].second] || usey[b[j].second]) over(0);
//			usex[a[i].second]=true;
//			usey[b[j].second]=true;
//			xk++;
//			yk++;
//			i++;
//			j++;
//		}
//		else if(a[i].first>b[j].first)
//		{
//			if(a[i+1].first==a[i].first) over(0);
//			if(usex[a[i].second] || yk==0) over(0);
//			res*=yk;
//			res%=mod;
//			usex[a[i].second]=true;
//			xk++;
//			i++;
//		}
//		else if(a[i].first<b[j].first)
//		{
//			if(b[j+1].first==b[j].first) over(0);
//			if(usey[b[j].second] || xk==0) over(0);
//			res*=xk;
//			res%=mod;
//			usey[a[i].second]=true;
//			yk++;
//			j++;
//		}
//		if(i==n && j==m) break;
//	}
//	cout<<res<<endl;
	return 0;
}

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

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

  vector<int> data;

  for (int i = 0; i < k; i++)
  {
    int temp1;
    cin >> temp1;
    for (int j = 0; j < temp1; j++)
    {
      int temp2;
      cin >> temp2;
      data.push_back(temp2);
    }
  }

  sort(data.begin(), data.end());
  data.erase(unique(data.begin(), data.end()), data.end());

  int p = data.size();
  cout << n - p << endl;
}

Measured memory_bytes: 3708
import sys
input = sys.stdin.readline
n,k=map(int,input().split())
h=list(map(int,input().split()))
h.sort()
h.reverse()
if n <= k:
  print(0)
else:
  ans=0
  for i in range(k,n):
    ans+=h[i]
  print(ans)

Measured memory_bytes: 78796
#include <cstdio>
#include <map>
#include <vector>
#define pb push_back
#define fs first
#define sc second
#define mp make_pair
#define rep(i,j,k) for (i=j;i<=k;i++)
using namespace std;
const int N=1e5+5;
typedef pair<int,int> Pair;
Pair q[2*N];
int n,i,j,u,v,l,r,cnt,dgr,sz[N],fa[N];
map<Pair,int> g;
vector<int> E[N];
int find(int x) {return fa[x]==x?x:fa[x]=find(fa[x]);}
int main()
{
//	freopen("r&b.in","r",stdin);
//	freopen("r&b.out","w",stdout);
	scanf("%d",&n);
	rep(i,1,2*n-2)
	{
		scanf("%d%d",&u,&v);
		E[u].pb(v); E[v].pb(u);
		g[mp(u,v)]++; g[mp(v,u)]++; sz[u]++; sz[v]++;
		if (g[mp(u,v)]==2) q[++r]=mp(u,v);
	}
	rep(i,1,n) fa[i]=i;
	rep(l,1,r)
	{
		u=find(q[l].fs); v=find(q[l].sc);
		if (u==v) continue;
		cnt++;
		if (sz[u]<sz[v]) swap(u,v);
		fa[v]=u;
		rep(i,0,sz[v]-1)
		{
			j=find(E[v][i]);
			if (j==u) continue;
			E[u].pb(j);
			sz[u]++;
			g[mp(u,j)]++; g[mp(j,u)]++;
			
			dgr=g[mp(u,j)];
			if (dgr>2) {
				printf("NO\n");
				return 0;
			}
			else if (dgr==2) q[++r]=mp(u,j);
		}
	}
	if (cnt<n-1) printf("NO\n");
	else printf("YES\n");
	return 0;
}

Measured memory_bytes: 47488
#include <bits/stdc++.h> 
using namespace std;
#define rep(i, N) for(int i=0; i<N; i++)
typedef long long ll;
#define dump(x) cerr<<#x<<"="<<x<<endl
using P = pair<int, int>;

int main() {
    string s; cin >> s;
    string h = "hi";

    string ans = "";
    for(int i=0; i<(s.size())/2; i++){
        ans += h;
    }
    dump(ans);

    if(ans==s) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
//abc066_b.cpp
//Tue Oct 30 22:24:32 2018

#include <iostream>
#include <string>
#include <queue>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;

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

	int flag = 0;
	for (int i=s.size()-2;i>=2;i=i-2){
//		cout << s.substr(0,i/2) << " " << s.substr(i/2,i/2) << endl;
		if (s.substr(0,i/2) == s.substr(i/2,i/2)){
			flag = i;
			break;
		}
	}
	cout << flag << endl;
}

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

	#include <ext/pb_ds/assoc_container.hpp> // Common file
	#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
	using namespace __gnu_pbds;
	using namespace std;
	#define int long long
	//for set
	// typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;   
	// for multiset
	typedef tree<
	int,
	null_type,
	less<int>,
	rb_tree_tag,
	tree_order_statistics_node_update> ordered_set;

	#define ff first
	#define ss second
	#define endl "\n"
	#define all(x) (x).begin(), (x).end()
	#define sz(x) (int)(x.size())
	#define PI 3.1415926535897932384626433832795
	int MOD=1e9+7;
	int powmod(int a,int l, int md){int res=1;while(l){if(l&1)res=res*a%md;l/=2;a=a*a%md;}return res;}
	int binpow(int a,int l){int res=1;while(l){if(l&1)res=res*a;l/=2;a=a*a;}return res;}
	typedef long long ll; typedef vector<ll> vi; typedef pair<ll, ll> ii; typedef vector<ii> vii;
	#define pb push_back
	int __set(int b, int i) {return b|(1ll<<i);} //set ith bit
	int __unset(int b, int i) {return b&(~(1UL<<i));}
	int __check(int b, int i) {return b&(1ll<<i);} //returns 0 if ith bit is 0
	int mulmod(int a, int b, int md) {return ((a%md)*(b%md))%md;}
	int addmod(int a, int b, int md) {return (a+b)%md;}
	int submod(int a, int b, int md) {return (((a-b)%md)+md)%md;}
	int divmod(int a, int b, int md) {return mulmod(a, powmod(b, md-2, md), md);} //if md is prime;
	const ll inf = 0xFFFFFFFFFFFFFFFL; //very large number
	// priority_queue<int, vector<int>, greater<int> > pq; //for min priority_queue
	#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	clock_t time_p=clock();
	void time()
	{
	    time_p=clock()-time_p;
	    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
	}
	vector<vii> g(55);
	vi vis;
	int dp[(1<<20)];
	int vv;
	vii q(25);
	int dfs(int u, int node) {
		vis[u]=1;
		int ret=0;
		for(int i = 0; i < sz(g[u]); i++) {
			int v = g[u][i].ff;
			if(!vis[v]) {
				int tp = dfs(v,node);
				if(tp==1) {
					ret=1;
					vv |= (1ll<<(g[u][i].ss));
				}
			}
		}
		if(u==node) return 1;
		return ret;
	}
	signed main(void)
	{
		IOS;
		int n; cin>>n;
		for(int i = 0; i < n-1; i++) {
			int u,v; cin>>u>>v;
			g[u-1].pb({v-1,i});
			g[v-1].pb({u-1,i});
		}
		int m; cin>>m;
		for(int i = 0; i < m; i++) {
			int u,v; cin>>u>>v;
			vis.assign(n,0);
			vv=0;
			dfs(u-1,v-1);
			dp[(1ll<<i)]=vv;
		}
		for(int i = 2; i < (1ll<<m); i++) {
			if(__builtin_popcountll(i)>1) {
				int id=__builtin_ffsll(i);
				id--;
				int num=__unset(i,id);
				dp[i]=dp[num]|dp[(1ll<<id)];
			}
		}
		int ans=0;
		for(int i = 0; i < (1ll<<m); i++) {
			int mm = (__builtin_popcountll(i)%2==0?1:-1);
			ans += mm*(1ll<<(n-1-__builtin_popcountll(dp[i])));
		}
		cout<<ans<<endl;
		time();
		return 0;
	}

Measured memory_bytes: 8448
#include <iostream>
#include <string>
#include <cstring>

using namespace std;

void next(string &s) {
    for (int i = 0; i < s.size(); i++) {
        if (isalpha(s[i])) {
            s[i] = (s[i] + 1 - 'a') % 26 + 'a';
        }
    }
}

int main() {
    string s;
    while (getline(cin, s)) {
        while (true) {
            if (s.find("the") != string::npos) break;
            if (s.find("this") != string::npos) break;
            if (s.find("that") != string::npos) break;
            next(s);
        }
        cout << s << endl;
    }
    return 0;
}

Measured memory_bytes: 0
#include <algorithm>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <queue>
#include <stack>
#include <utility>
#include <vector>
using std::cin;
using std::cout;
using std::endl;

int main(void) {

    int d, g;
    int amount[11], bonus[11];
    int answer = 1100;
    cin >> d >> g;
    for (int i = 1; i <= d; i++) {
        cin >> amount[i] >> bonus[i];
    }

    //解き切らなくても大丈夫な時
    if (amount[d] * d * 100 >= g) {
        answer = g / (d * 100);
        if (g % (d * 100) != 0)
            answer++;
    }
    //だめな時
    for (int bit = 1; bit <= (1 << d) - 1; bit++) {
        // bitは解き切る問題の集合
        int score = 0;
        int count = 0;
        //解き切る問題を解き切る
        for (int i = 1; i <= d; i++) {
            int mask = 1 << (i - 1);
            if (bit & mask) {
                score += amount[i] * i * 100 + bonus[i];
                count += amount[i];
            }
        }
        if (score < g) {
            //解き切らない問題のうち最大スコアのものを見る
            int not_complete = 1 << d;
            for (int i = d; i > 0; i--) {
                not_complete = not_complete >> 1;
                if (not_complete & (~bit)) {
                    //見つかったら残りを埋めきれるか確認
                    if (score + (amount[i] - 1) * 100 * i >= g) {
                        //残りを埋めきれる
                        int needed_score = g - score;
                        count += needed_score / (i * 100);
                        if (needed_score % (i * 100) != 0)
                            count++;
                    } else {
                        //残りを埋めるのに失敗
                        count = 1100;
                    }
                    break;
                }
            }
        }

        //仕上げの比較
        if (answer > count) {
            answer = count;
        }
    }

    cout << answer << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <functional>
#include <cmath>
#include <string>
#include <vector>
#include <queue>

using namespace std;

int main() {
  int n;
  cin >> n;
  long long ans = 0;
  for(int i = 1; i <= n; ++i) {
    if (i%3 != 0 && i%5 != 0) ans += i;
  }
  cout << ans << endl;
  return 0;
}

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

def add(x):
    if x == 'r':
        return p
    elif x == 's':
        return r
    else:
        return s

nk =[0]*k
for i in range(n):
    key = i%k
    if nk[key]==0:
        nk[key] = [t[i]]
    else:
        nk[key].append(t[i])
ans = 0
for j in nk:
    if j ==0:
        continue
    ans += add(j[0])
    for k in range(1, len(j)):
        if j[k]== j[k-1]:
            j[k]='q'
        else:
            ans += add(j[k])
print(ans)

Measured memory_bytes: 17072
#include <stdio.h>

int main()
{

    int s;
    scanf("%d", &s);
    char a[200];
    scanf("%s", a);
    int i = 0;
    for (i = 0; a[i] != '\0'; i++)
    {
        
    }
    if(i>s){
        for (i = 0; i<s; i++)
        {
            printf("%c", a[i]);
        }
        printf("...");
    }else
        printf("%s", a);


    printf("\n");
}

Measured memory_bytes: 1736
#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<numeric>
#include<map>
#include<queue>
#include<deque>
#include<set>
#include<cstdio>
#include<cstring>
#include<string>
using namespace std;
typedef long long ll;

int main(){
    int N,K;cin>>N>>K;
    int x[60],y[60];
    pair<int,int> p[60];
    int a,b;
    for(int i=0;i<N;i++){
        cin>>a>>b;
        p[i]={a,b};
        x[i]=a; y[i]=b;
    }
    sort(x,x+N);sort(y,y+N);
    ll ans=9*pow(10,18);
    for(int i=0;i<N-1;i++){
        int x0=x[i];
        for(int j=i+1;j<N;j++){
            int x1=x[j];
            for(int k=0;k<N-1;k++){
                int y0=y[k];
                for(int l=k+1;l<N;l++){
                    int y1=y[l];
                    int count=0;
                    for(int m=0;m<N;m++){
                        int px=p[m].first,py=p[m].second;
                        if(x0<=px && px<=x1 && y0<=py && py<=y1)
                            count++;
                    }
                    if(count>=K){
                        ll S=(ll)(x1-x0)*(ll)(y1-y0);
                        ans=min(ans,S);
                    }
                }
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
typedef pair<ll,ll> P;
#define pb push_back
#define ft first
#define sd second
#define mp make_pair
#define fr(i,n) for(int i=0;i<(n);i++)
#define Fr(i,n) for(int i=0;i++<(n);)
#define ifr(i,n) for(int i=(n)-1;i>=0;i--)
#define iFr(i,n) for(int i=(n);i>0;i--)

int main(){
    ll n,k,ans=0;
    cin>>n>>k;
    deque<ll> v(n);
    fr(i,n) cin>>v[i];
    fr(i,min(k+1,n+1)){
        fr(j,i+1){
            ll kari=0;
            priority_queue<ll> pq;
            fr(l,j){
                kari+=v[l];
                if(v[l]<0) pq.push(-v[l]);
            }
            fr(l,i-j){
                kari+=v[n-1-l];
                if(v[n-1-l]<0) pq.push(-v[n-1-l]);
            }
            fr(l,k-i){
                if(pq.empty()) break;
                kari+=pq.top();pq.pop();
            }
            ans=max(ans,kari);
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>
  
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
  
using namespace std;
  
typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;
  
const int INF=1<<29;
const double EPS=1e-9;
  
const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};
 

int main() {
  int N, A, B;
  cin >> N >> A >> B;
  cout << min(N * A, B) << endl;
  return 0;
}

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

#define F                   first
#define S                   second
#define int                 long long int
#define pb                  push_back
#define mp                  make_pair
#define pii                 pair<int,int>
#define vi                  vector<int>
#define mii                 map<int,int>
#define pqb                 priority_queue<int>
#define pqs                 priority_queue<int,vi,greater<int> >
#define mod                 1000000007
#define endl                '\n'
#define rep(i,a,b)            for(int i=a;i<b;i++)
int rec( vector<vector<int>> &a, int n, int idx, int prev, vector<vector<int>>&dp) {
    if (idx == n) {
        return 0;
    }
    int ans = 0;
    if (dp[idx][prev] != -1) {
        return dp[idx][prev];
    }
    for (int i = 0; i < 3; i++) {
        if (prev != i) {

            ans = max(ans, rec(a, n, idx + 1, i, dp) + a[idx][i]);
        }
    }
    return dp[idx][prev] = ans;
}
void c_p_c()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}

int32_t main()
{
    c_p_c();
    int n;
    cin >> n;
    vector<vector<int>> a(n, vector<int>(4));
    for (int i = 0; i < n; i++) {
        int x, y, z;
        cin >> x >> y >> z;
        a[i][0] = x;
        a[i][1] = y;
        a[i][2] = z;
    }
    vector<vector<int>> dp(n + 1, vector<int>(4, -1));
    int ans = rec(a, n, 0, 3, dp);


    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 25024
#include <iostream>
#include <vector>
#include <algorithm> 

using namespace std;


int solution_DP_bottom_up(const vector<int>& s, int k)
{
	vector<int> DP(s.size(), numeric_limits<int>::max());
	DP[0] = 0;
	for (int i = 1; i < (int) s.size(); i++) {
		for (int j = 1; j <= k; j++) {
			if(i - j >= 0)
				DP[i] = min(DP[i], DP[i-j] + abs(s[i-j] - s[i]));
		}
	}
	return DP[s.size()-1];
}



int main()
{
	int N;
	int k;
	cin >> N >> k;
	vector<int> s(N);
	for(int i = 0; i < N; i++) {
		cin >> s[i];
	}
	cout << solution_DP_bottom_up(s, k) << endl;
}


Measured memory_bytes: 1024
#include <iostream> 
using namespace std;
 
int main(){
	string S;
	cin >> S;
	string ans = "CODEFESTIVAL2016";
	int process = 0;
	for(int i = 0; i < 16; i++){
		if(S[i] != ans[i]){
			process++;
		}
	}
	cout << process << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
using namespace std;

string S;
string ans;

int main() {
	cin >> S;
	for (int n = 0; n < S.size(); n++) {
		if (S[n] == '0')ans += string("0");
		else if (S[n] == '1')ans += string("1");
		else {
			if (ans.size() != 0)ans.erase(ans.begin() + ans.size() - 1);
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Text;

namespace AOJ
{
    class Program
    {
        static void Main(string[] args)
        {
            var result = Volume0.DigitNumber();
            System.Diagnostics.Trace.Write(result);
            Console.Write(result);
        }
    }

    public static class Volume0
    {
        public static string DigitNumber()
        {
            var result = new StringBuilder();
            var input = Console.ReadLine();
            while (!string.IsNullOrEmpty(input))
            {
                var inputs = input.Split(' ');
                result.AppendLine((int.Parse(inputs[0]) + int.Parse(inputs[1])).ToString().Length.ToString());
                input = Console.ReadLine();
            }
            return result.ToString();
        }
    }
}

Measured memory_bytes: 5632
from bisect import bisect_left 
#bisect_left(a,x):a[i]>=xとなるような最小のi.
#昇順ソートされたリストaに昇順を崩さずxを挿入できる位置s(0-index)を返す.
#a=[1,3,5,7,9,11,13,15,17,19]
#s = bisect_left(a,4)
#s=2
a,b,c,d,e,f=map(int,input().split())
wa=set()
a*=100
b*=100
for i in range((f+a-1)//a+1):
    for j in range((f+b-1)//b+1):
        if 1<=i*a+j*b<=f:
            wa.add(i*a+j*b)
su=set()
e=100*e/(100+e)
x=int(f*e//100)
for i in range((x+c-1)//c+1):
    for j in range((x+d-1)//d+1):
        if i*c+j*d<=x:
            su.add(i*c+j*d)
su=sorted(list(su))
# print(wa)
# print(su)
ans=0
x,y=0,0
e+=0.001
f+=0.001
for i in wa:
    # print(i,su[bisect_left(su,f-i)-1],su[bisect_left(su,e*i/(100-e))-1])
    p=min(bisect_left(su,f-i),bisect_left(su,e*i/(100-e)))
    if p>0:
        if ans<=su[p-1]/(i+su[p-1]):
            ans=su[p-1]/(i+su[p-1])
            x,y=i,su[p-1]
print(max(x+y,a),y)

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

int main()
{
    // 整数の入力
    string S;
    cin >> S;

    if (S.at(S.size() - 1) == 's')
    {
        cout << S + "es" << endl;
    }
    else
    {
        cout << S + "s" << endl;
    }
    return 0;
}

Measured memory_bytes: 3636