akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<int> a(n), b(n);
  for (int i = 0; i < n; i++){
    cin >> a[i] >> b[i];
    a[i]--;
    b[i]--;
  }
  vector<int> L(100001, 0);
  for (int i = 0; i < n; i++){
    L[b[i]]++;
  }
  for (int i = 0; i < 100000; i++){
    L[i + 1] += L[i];
  }
  vector<int> R(100001, 0);
  for (int i = 0; i < n; i++){
    R[a[i]]++;
  }
  for (int i = 100000; i >= 1; i--){
    R[i - 1] += R[i];
  }
  int ans1 = 0;
  for (int i = 0; i < n; i++){
    ans1 = max(ans1, n - L[a[i]] - R[b[i]]);
  }
  vector<int> d(100001, 0);
  for (int i = 0; i < n; i++){
    d[a[i]]++;
    d[b[i]]--;
  }
  for (int i = 0; i < 100000; i++){
    d[i + 1] += d[i];
  }
  int ans2 = 0;
  for (int i = 0; i < 100000; i++){
    ans2 = max(ans2, d[i]);
  }
  cout << ans1 << ' ' << ans2 << endl;
}


Measured memory_bytes: 5468
#include <iostream>
#include <vector>
#include <cstdio>
#include <string>
#include <algorithm>
using namespace std;
const long long mod = 1e9+7;

int main() {
    int N,M;
    cin >> N >> M;
    
    //階段が正常 => true
    //壊れている => false
    vector<int> oks(N+1, true); //0段目からN段目まで == 長さN+1
    for (int i = 0; i < M; i++)
    {
        int a;
        cin >> a;
        oks[a] = false;
    }
    
    vector<long long int>dp(N+1); //0からN
    //最初にいる0段目に登る方法は1通り
    dp[0] = 1;
    //now := 今いる段数
    //next := 今いる段数+(1段 or 2段) (ただしNを超えるときはN)
    for (int now = 0; now < N; now++)
    {
        //Nを超えないなら以下は2回ループする
        //now+1 == 今いる段数から1段のぼったところをnextに
        ///now+2 == ...
        for (int next = now+1; next <= min(N,now+2); next++)
        {
            //登った段がtrueなら
            if (oks[next])
            {
                //今いる段数まで登る登り方の総数を次の段数の総数に足す
                dp[next] += dp[now];
                //オーバーフロー防止 先に割っても答えは変わらない
                dp[next] %= mod;
            }
        }
    }
    
    //N段目まで登る登り方の総数を出力
    cout << dp[N] << endl;
    return 0;
}


Measured memory_bytes: 1408
from sys import stdin
from collections import deque
def main():
    #入力
    readline=stdin.readline
    N=int(readline())
    g=[[] for _ in range(N)]
    for _ in range(N-1):
        u,v,w=map(int,readline().split())
        u-=1
        v-=1
        g[u].append((v,w))
        g[v].append((u,w))

    #0からの距離を幅優先探索
    d=[0]*N
    is_searched=[False]*N
    is_searched[0]=True
    que=deque([0])
    while len(que)>=1:
        now=que.popleft()
        for x in g[now]:
            if is_searched[x[0]]==False:
                is_searched[x[0]]=True
                d[x[0]]=d[now]+x[1]
                que.append(x[0])

    
    for x in d:
        if x%2==0:
            print(0)
        else:
            print(1)

if __name__=="__main__":
    main()

Measured memory_bytes: 43924
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using P = pair<ll, ll>;
using mat = vector<vector<ll>>;

inline void IOS() { ios::sync_with_stdio(false), cin.tie(0); }

template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
	fill((T *)array, (T *)(array + N), val);
}

const ll INF = 1e16;
const ll MOD = 1e9 + 7;
//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//ll pas[5001][5002];
ll w[114], v[114];
ll dp[102][114514];

signed main(){
	IOS();
	ll n, W;
	cin >> n >> W;
	for (int i = 1;i <= n;++i) {
		cin >> w[i] >> v[i];
	}
	Fill(dp, INF);
	dp[0][0] = 0;	
	for (int i = 1;i <= n;++i) {
		for(int j = 0;j < 114514;++j) {
			if(j >= v[i])dp[i][j] = min(dp[i - 1][j], dp[i - 1][j - v[i]] + w[i]);
			else dp[i][j] = dp[i - 1][j];
		}
	}
	ll ans = 0;
	for (int i = 0;i < 114514;++i) {
		if(dp[n][i] <= W) ans = i;
	}
	
	cout << ans << endl;
	
}

Measured memory_bytes: 91520
#include <stdio.h>

#define min(a, b) ((a) < (b) ? a : b)

int cnt[100000];
int cnt2[100001];

int main(void) {
	int i;
	int n, m;
	int ans;

	scanf("%d %d", &n, &m);
	for (i = 0; i < n; i++) {
		int x;
		scanf("%d", &x);
		cnt[x % m]++;
		cnt2[x]++;
	}

	ans = 0;
	for (i = 1; i <= 100000; i++) {
		const int me = i % m, oppo = (m - me) % m;
		if (oppo != me)
			if (cnt[me] > cnt[oppo]) {
				const int down = min(cnt2[i] / 2, (cnt[me] - cnt[oppo]) / 2);
				cnt[i % m] -= down * 2;
				ans += down;
			}
	}

	for (i = 0; i < m; i++) {
		if ((m - i) % m == i) {
			ans += cnt[i] / 2;
			cnt[i] %= 2;
		} else {
			const int common = min(cnt[i], cnt[m - i]);
			ans += common;
			cnt[i] -= common;
			cnt[m - i] -= common;
		}
	}

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

	return 0;
}


Measured memory_bytes: 896
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

N = int(input())
S = [''.join(sorted(input().rstrip())) for _ in range(N)]

from collections import Counter
counter = Counter(S)

answer = sum(x*(x-1)//2 for x in counter.values())
print(answer)

Measured memory_bytes: 19788
#-*- coding: utf-8
#  -*-
"""
oj dl https://atcoder.jp/contests/abc116/tasks/abc116_d -d test-d
oj test -d test-d -c "python abc116d.py"
oj test -d test-d -c "python abc116d.py" test-d/sample-3.in
"""
from collections import defaultdict
import sys
import math
from datetime import datetime

def sol(a, b):
    if a > b:
        return int(str(b) * a)
    else:
        return int(str(a) * b)

    #if a + b + c <= 21: return 'win'
    #else: return 'bust'



do_submit = True
#do_submit = False

def input_parse(input_str):
    lines = [x.strip() for x in input_str.split("\n") if x.strip()]
    parsed_lines = [list(map(str, line.split())) for line in lines]
    print(parsed_lines)
    n = int(parsed_lines[0][0])
    k = int(parsed_lines[0][1])
    S = parsed_lines[1][0]
    return n, k, S


if not do_submit:
    a, b, c = input_parse("""
    3 1
    ABC
    """)
    print(sol(a, b, c))

    a, b, c = input_parse("""
    4 3
    CABA
    """)
    print(sol(a, b, c))

else:
    a, b = list(map(int, input().split()))
    # S = input().split()
    # a = int(input())
    # b = int(input())
    # T = input()
    print(sol(a, b))
    # S = input().strip()
    # print(sol(S))



Measured memory_bytes: 3828
import java.io.*;
import java.util.Arrays;
class Main{
	public static void main(String[] args) throws IOException {
		int[] n = new int[5];
		String[] str = new String[5];
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		for(;;){
			str = in.readLine().split(" ");
			n[0] = Integer.parseInt(str[0]); 
			String op = str[1];
			n[2] = Integer.parseInt(str[2]);
			if("?".equals(op)) break;
			switch(str[1]){
				case "+": n[3]=n[0]+n[2]; break;
				case "-": n[3]=n[0]-n[2]; break;
				case "*": n[3]=n[0]*n[2]; break;
				case "/": n[3]=n[0]/n[2]; break;
			}
			System.out.println(n[3]);
		}
	}
}

Measured memory_bytes: 24324
import java.util.Scanner;

class UnionFind{
	int[] par;
	int[] rank;
	int[] diff_weight;
	int N;

	public UnionFind(int n){
		N = n;
		par = new int[N];
		rank = new int[N];
		diff_weight = new int[N];
		for(int i = 0; i < N; i++){
			par[i] = i;
			rank[i] = 0;
			diff_weight[i] = 0;
		}
	}

	public int find(int x){
		if(par[x] == x) return x;
		int r = find(par[x]);
		diff_weight[x] += diff_weight[par[x]];
		return par[x] = r;
	}

	public int weight(int x) {
		find(x);
		return diff_weight[x];
	}

	public Boolean same(int x, int y){
		return find(x) == find(y);
	}


	public void unite(int x, int y, int w){
		w += weight(x); w -= weight(y);
		x = find(x); y = find(y);
		if(x == y) return;
		if(rank[x] < rank[y]) {
			int tmp = x; x = y; y = tmp;
			w -= w;
		}
		par[y] = x;
		diff_weight[y] = w;
		return;
	}

	public int diff(int x, int y) {
		return weight(y) - weight(x);
	}

}
class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt(), M = sc.nextInt();
		UnionFind uf = new UnionFind(N);
		boolean isOk = true;
		for(int i = 0; i < M; i++) {
			int L = sc.nextInt(), R = sc.nextInt(), W = sc.nextInt();
			if(uf.same(L - 1, R - 1)) {
				int diff = uf.diff(L - 1, R - 1);
				if(diff != W) isOk = false;
			}else {
				uf.unite(L - 1, R - 1, W);
			}
		}
		System.out.println(isOk ? "Yes" : "No");
	}
}


Measured memory_bytes: 150548
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define mod 1000000007
unordered_map<ll,vector<ll>> adj;
vector<ll> vis(300005,0);
vector<ll> p(100005,0);
ll c[100005];
ll cnt;
void dfs(ll node)
{
  if(vis[node])
    return;
  vis[node]=1;
  cnt++;
  for(auto i:adj[node])
    {
      dfs(i);
    }
}
ll modexpo(ll x,ll n,ll M){
    if(n==0)return 1;
    else if(n%2 == 0)return modexpo((x*x)%M,n/2,M);
    else return(x*modexpo((x*x)%M,(n-1)/2,M))%M;
}

int main()
{
  ll n;
  cin>>n;
  ll i;
  vector<ll> points;
  vector<ll> points1;
  ll x,y;
  for(i=0;i<n;i++)
  {
    cin>>x>>y;
    points.pb(x+y);
    points1.pb(x-y);
  }
  sort(points.begin(),points.end());
  sort(points1.begin(),points1.end());
  ll ans=points.back()-points.front();
  ans=max(points1.back()-points1.front(),ans);
  cout<<ans;
}


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

ll N, A, B;
vector<ll> HP;

bool canAllBeat(ll count) {
    ll DIFF = A - B;
    ll attackA = 0; //B攻撃*n回で倒せない敵を、倒すのに必要なA攻撃数
    for (ll hp : HP) {
        hp -= B * count;
        if (hp <= 0) {
            break;
        }
        attackA += ceil((double)hp / (double)DIFF);
    }
    return attackA <= count;
}
ll binSearch(ll minCount, ll maxCount) {
    if (maxCount - minCount < 2) {
        return canAllBeat(minCount) ? minCount : maxCount;
    }
    int center = (maxCount + minCount) / 2;
    if (canAllBeat(center)) {
        return binSearch(minCount, center);
    } else {
        return binSearch(center, maxCount);
    }
}

int main() {
    cin >> N >> A >> B;
    rep(i, N) {
        ll h;
        cin >> h;
        HP.push_back(h);
    }
    sort(HP.begin(), HP.end(), greater<ll>());
    //二分探索用のRangeを適当に決める
    ll minCount = HP[0] / A;
    ll maxCount = HP[0] / B + 10;

    ll ans = binSearch(minCount, maxCount);
    cout << ans << endl;

    return 0;
}


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

int main()
{
  int a,b,c;
  cin>>a>>b;
  c=a*b;
  if(c%2==0)
  {
    cout<<"Even"<<endl;
  }
  else
  {
    cout<<"Odd"<<endl;
  }
  return 0;
}
  


Measured memory_bytes: 256
#include <iostream>

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

  if (b == c) {
    std::cout << a << std::endl;
  } else if (a == c) {
    std::cout << b << std::endl;
  } else {
    std::cout << c << std::endl;
  }

  return 0;
}


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

using namespace std;
using int64 = long long int;

int main()
{
    int n, q;
    string s;
    cin >> n >> s >> q;

    set<int> sets[26];
    for (size_t i = 0; i < s.length(); i++)
    {
        sets[s[i] - 'a'].insert(static_cast<int>(i));
    }

    for (int _ = 0; _ < q; _++)
    {
        int i;
        cin >> i;

        if (i == 1)
        {
            int l;
            string c;
            cin >> l >> c;
            l--;

            sets[s[l] - 'a'].erase(l);
            s[l] = c[0];
            sets[s[l] - 'a'].insert(l);
        }
        else
        {
            int l, r;
            cin >> l >> r;
            l--;

            int result = 0;
            for (int i = 0; i < 26; i++)
            {
                auto it = sets[i].lower_bound(l);
                if (it != sets[i].end() && *it < r)
                {
                    result++;
                }
            }

            cout << result << endl;
        }
    }
}

Measured memory_bytes: 24196
import sys
input = sys.stdin.readline
from collections import deque

nn = 200200
mod = 10**9+7

fa = [1] * (nn+1)
fainv = [1] * (nn+1)
inv = [1] * (nn+1)
for i in range(nn):
    fa[i+1] = fa[i] * (i+1) % mod
fainv[-1] = pow(fa[-1], mod-2, mod)
for i in range(nn)[::-1]:
    fainv[i] = fainv[i+1] * (i+1) % mod
for i in range(1, nn)[::-1]:
    inv[i] = fainv[i] * fa[i-1]

C = lambda a, b: fa[a] * fainv[b] % mod * fainv[a-b] % mod if 0 <= b <= a else 0

N = int(input())
X = [[] for i in range(N)]
for i in range(N-1):
    x, y = map(int, input().split())
    X[x-1].append(y-1)
    X[y-1].append(x-1)

P = [-1] * N
Q = deque([0])
R = []
while Q:
    i = deque.popleft(Q)
    R.append(i)
    for a in X[i]:
        if a != P[i]:
            P[a] = i
            X[a].remove(i)
            deque.append(Q, a)

BU = [1] * N
TD = [1] * N
SI = [1] * N
for i in R[::-1]:
    a = 1
    s = 1
    for j in X[i]:
        a = a * BU[j] % mod
        s += SI[j]
    SI[i] = s
    BU[i] = inv[s] * a % mod

for i in R:
    c = len(X[i])
    AL = [1] * (c + 1)
    AR = [1] * (c + 1)
    for j in range(c):
        AL[j+1] = AL[j] * BU[X[i][j]] % mod
    for j in range(c)[::-1]:
        AR[j] = AR[j+1] * BU[X[i][j]] % mod
    for j in range(c):
        TD[X[i][j]] = TD[i] * AL[j] % mod * AR[j+1] % mod * inv[N - SI[X[i][j]]] % mod

for i in range(N):
    print(BU[i] * fa[SI[i]] % mod * TD[i] % mod * fa[N - SI[i]] % mod * C(N-1, SI[i] - 1) % mod)

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

#define rep(i, x, n) for(int i=(x);i<(n);i++)
#define reps(i, x, n) for(int i=(x);i<=(n);i++)
#define lol long long
#define SUM(n) ((n)+1)*(n)/2 //1〜nまでの総和を求める式
#define mp make_pair
#define fi first
#define se second
#define pu push_back
#define SYOU(x) fixed<<setprecision(x+1) //小数点桁数を指定する
#define abs(x,y) max(x,y)-min(x,y)
#define all(v) v.begin(),v.end()
#define UPDigit(a,b) (a+b-1)/b //小数点切り上げ
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const int MOD=int(1e9)+7; 
using namespace std;
using pii = pair<int, int>;
typedef vector<int> vit;
//八方向を見るのに使うと便利(楽)
const int dy[] = {0, 1, 0, -1, -1, 1, 1, -1};
const int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};

//最大公約数
lol gcd(lol x, lol y){ return (y != 0 ? gcd(y, x % y) : x); }
//最小公倍数
lol lcm(lol x, lol y){ return ((x * y) / gcd(max(x, y), min(x, y))); }

signed main(void){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  int key[m + 5] = {}, a[m + 5];
  rep(i, 0, m){
    int b, c;
    cin >> a[i] >> b;
    rep(j, 0, b){
      cin >> c;
      key[i] |= (1 << c - 1);
    }
  }
  vector<lol> ans(90000, LINF);
  ans[0] = 0;
  lol memo = pow(2, n);
  rep(i, 0, memo){
    rep(j, 0, m){
      if(ans[i] != LINF){
	ans[(i | key[j])] = min(ans[(i | key[j])], ans[i] + a[j]);
      }
    }
  }
  if(ans[memo - 1] == LINF){
    cout << "-1\n";
  } else {
    cout << ans[memo - 1] << '\n';
  }
  return 0;
}


Measured memory_bytes: 4060
#include<iostream>

#define FOR(i,j,k) for(int i=j;i<k;i++)

using namespace std;

int main(void)
{
	int g[128][128]={0};
	int x=0,y=0;
	int w;
	while(cin>>w){
		g[x++][y]=w;
		char c=cin.get();
		if(c=='\n'){
			x=0;
			y++;
		}
	}
	int h=y;
	for(int y=1;y<h;y++){
		if(y<h/2+1){
			for(int x=0;x<y+1;x++){
				if(x==0) g[x][y]+=g[x][y-1];
				else g[x][y]+=max(g[x][y-1],g[x-1][y-1]);
			}
		}else{
			for(int x=0;x<h-y;x++){
				g[x][y]+=max(g[x][y-1],g[x+1][y-1]);
			}
		}
	}
	cout<<g[0][h-1]<<endl;
	return 0;
}

Measured memory_bytes: 1228
import sys

while True:
  a = sys.stdin.readline()
  if not a: break

  a = a.rstrip().split(" ")
  b = raw_input().rstrip().split(" ")

  hit=0
  for i in range(len(a)):
    if a[i] == b[i]:
      hit+=1
      a[i] = -1

  blow=0
  for e in b:
    if e in a:
      blow+=1

  print("{} {}").format(hit, blow)

Measured memory_bytes: 6404
def main():
    n = int(input())
    a = list(map(int, input().split()))
    
    def solve():
        if 0 in a:
            return 0
        ans = 1
        for aa in a:
            ans *= aa
            if ans >10**18:
                return -1
        return ans
    print(solve())
        
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 21720
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>

using namespace std;
using ll = long long;

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

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

	cout << 6 - A - B << endl;

}

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

int main(){
    ios::sync_with_stdio(false);    cin.tie(NULL);  cout.tie(NULL);
    int n, k;  cin >> n >> k;   vector<long long int> vec(n), dp(n, INF);
    for(int i=0;n>i;i++){
        cin >> vec[i];
    }
    dp[0]=0;
    for(int i=1;n>i;i++){
        for(int j=1;min(i, k)>=j;j++){
            dp[i]=min(dp[i], dp[i-j]+abs(vec[i]-vec[i-j]));
        }
    }
    cout << dp[n-1];
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define ll long long
// struct compare{
//     bool operator()(pair<pair<int,int>,ll> a,pair<pair<int,int>,ll> b)
//     {
//         int x = a.first.first+a.first.second;
//         int y = b.first.first+b.first.second;
//         return (x)>(y);
//     }
// };
struct S{
    int w,s,v;
    bool operator <(S const &b) const {
        return (w+s<b.w+b.s);
    }
 
};
int n;
int main() {
    // priority_queue<pair<pair<int,int>,ll>,vector<pair<pair<int,int>,ll>>,compare> pq;
    cin>>n;
    // for(int i=0;i<n;i++)
    // {
    //     int a,b;
    //     ll c;
    //     cin>>a>>b>>c;
    //     pq.push({{a,b},c});
    // }
    vector<S> boxes(n);
    int max_cap=20005;;
    for(int i=0;i<n;i++){
        cin>>boxes[i].w>>boxes[i].s>>boxes[i].v;
    }
    sort(boxes.begin(),boxes.end());
    vector<ll> dp(max_cap+1,0);
    // memset(dp,0,sizeof dp);
    for(auto box:boxes)
    {
        int w,s,val;
        w = box.w;
        s = box.s;
        val = box.v;
        for(int cap=min(s,max_cap-w);cap>=0;--cap)
        {
            dp[cap+w] = max(dp[cap+w],dp[cap]+val);
        }
        // pq.pop();
    }
    ll ans=0;
    for(int i=0;i<max_cap;i++)
    ans = max(ans,dp[i]);
    cout<<ans;
}

Measured memory_bytes: 3604
"""
N進数
下記を繰り返して構築
NからNで割ったあまりを引く
そっからNで割る
"""
N = int(input())
if N == 0:
    print(0)
    exit(0)
ans = ""
mod = -2 
while N!=0:
    d = N % abs(mod)
    ans = str(d) + ans
    N -= d
    N //= mod
    # print(N)
print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
using namespace std;
using ll = long long;



int main() {
	int d;
	cin >> d;
	if (d == 25) cout << "Christmas" << endl;
	else if (d == 24) cout << "Christmas Eve" << endl;
	else if (d == 23) cout << "Christmas Eve Eve" << endl;
	else if (d == 22) cout << "Christmas Eve Eve Eve" << endl;


	return 0;
}


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

set<ll> enumDivisor(ll N) {
    set<ll> res;
    for (ll i = 1; i * i <= N; i++) {
        if (N % i == 0) {
            res.insert({i, N / i});
        }
    }
    return res;
}

int main() {
    ll N, ans = 0;
    cin >> N;
    for (ll k : enumDivisor(N)) {
        if (k == 1) continue;
        ll n = N;
        while (n % k == 0) n /= k;
        if (n % k == 1) ans++;
    }
    cout << ans + enumDivisor(N-1).size() - 1 << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  long int N,S;
  S=0;
  cin >> N;
  for(int i=1 ; i<N+1 ; i++){
    if(i%3!=0&&i%5!=0){
      S=S+i;
    }
  }
  cout << S << endl;
}


Measured memory_bytes: 3608
#include<bits/stdc++.h>
#define LLI long long int
#define ULTRA 2134567890

using namespace std;

char s[200007]={};
int dp[200007][2]={};

int main()
{
    int i,j;

    scanf("%s",s);
    int len = strlen(s);
    if(len==1)
    {
        printf("1\n");
        return 0;
    }

    int cnt = 0;
    bool flag = 0;
    dp[0][0] = 1;
    dp[0][1] = 0;
    if(s[1]==s[0])
        dp[1][0] = 1;
    else
        dp[1][0] = 2;
    dp[1][1] = 1;
    dp[2][1] = 2;
    for( i=1; i<len; i++)
    {
        if(s[i]==s[i-1])
        {
            dp[i][0] = dp[i-1][1]+1;
        }
        else
        {
            dp[i][0] = max(dp[i-1][0],dp[i-1][1])+1;
        }

        if(i<=2)
            continue;
        if(s[i]==s[i-2] && s[i-1] == s[i-3])
        {
            dp[i][1] = dp[i-2][0]+1;
        }
        else
        {
            dp[i][1] = max(dp[i-2][0],dp[i-2][1])+1;
        }
    }

    // for( i=0; i<len; i++)
    // {
    //     printf("%d ",dp[i][0]);
    // }
    // printf("\n");
    // for( i=0; i<len; i++)
    // {
    //     printf("%d ",dp[i][1]);
    // }
    // printf("\n");

    printf("%d\n",max(dp[len-1][0],dp[len-1][1]));


    return 0;
}


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

struct Node{
  int key;
  struct Node *next;
  struct Node *prev;
};

struct Node *nil;

struct Node *listSearch(int key);
void init();
void printList();
void deleteFirst();
void deleteLast();
void deleteKey(int key);
void deleteNode(struct Node *t);
void insert(int key);


int main(){
  int key, n,i;
  int size = 0, np=0,nd = 0;
  char c[20];

  scanf("%d",&n);
  init();
  for(i= 0;i<n; i++){
    scanf("%s",c);
    if(c[0] == 'i'){
      scanf("%d", &key);
      insert(key);
      np++;
      size++;
    }
    else if(c[0] == 'd'){
      if(strlen(c) > 6){
      if(c[6] == 'L'){
	deleteLast();
      }
      else if(c[6] == 'F'){
	deleteFirst();
       }
      }
      else {
	scanf("%d",&key);
	deleteKey(key);
	nd++;
      }
      size--;
    }
  }
  printList();
  return 0;
}


struct Node* listSearch(int key){
  struct Node *c = nil->next;
  while(c != nil && c->key != key){
    c = c->next;
  }
  return c;
}

 
void init(){
  nil = (struct Node *)malloc(sizeof(struct Node));
  nil->next = nil;
  nil->prev = nil;
}

 

void printList(){
  struct Node *cur = nil->next;
  int i = 0;
  while(1){
    if(cur == nil){
      break;
    }
    if(i++ >0){
      printf(" ");
    }
    printf("%d",cur->key);
    cur = cur->next;
  }
  printf("\n");
}

void deleteFirst(){
  deleteNode(nil->next);
}

void deleteLast(){
  deleteNode(nil->prev);
}

void deleteKey(int key){
  deleteNode(listSearch(key));
}

void deleteNode(struct Node *t){
  if(t == nil)return;
  t->prev->next = t->next;
  t->next->prev = t->prev;
  free(t);
}

void insert(int key){
  struct Node *x = (struct Node *)malloc(sizeof(struct Node));
  x->key = key;
  x->next = nil->next;
  nil ->next->prev = x;
  nil->next = x;
  x->prev = nil;
}



Measured memory_bytes: 32960
import java.util.*;

class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] A = new int[N];
        for(int i = 0; i < N; i++){
            A[i] = sc.nextInt();
        }

       int[] ans = new int[N];
       for(int i = 0; i < N; i++){
           ans[A[i]-1] = i + 1;
       }

       for(int i = 0; i < N; i++){
           System.out.print(ans[i] + " ");
       }
    }
}

Measured memory_bytes: 63244
// HOPE IS A GOOD THING MAY BE THE BEST OF THINGS AND NO GOOD THINGS EVER DIES  <3 
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define pii pair <int, int>
#define pll pair <long long, long long >
#define PI 2 * acos(0.0)
#define testcase ll T; cin >> T; for (int tc = 1; tc <= T; tc++)
const long long M = 2e5 + 10, M2 = 1e6 + 10, oo = 1e9 + 7;
int ara[20][20], cst[20];
int main () {
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n, m, x;
    cin >> n >> m >> x;
    for (int i = 0; i < n; i++) {
        cin >> cst[i];
        for (int j = 0; j < m; j++) {
            cin >> ara[i][j];
        }
    }
    ll ans = oo;
    for (ll msk = 0; msk <= (1LL << n); msk++) {
        bool ok = true;
        ll val[20] = {0}, tmp = 0;
        for (int i = 0; i < n; i++) {
            if (msk & (1LL << i)) {
                for (int j = 0; j < m; j++) val[j] += ara[i][j];
                tmp += cst[i];
            }
        }
        for (int i = 0; i < m; i++) {
            if (val[i] < x) ok = false;
        }
        if (ok) ans = min(ans, tmp);
    }
    if (ans == oo) cout << -1 << endl;
    else cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

// increment
#define rep_n(_1, _2, _3, NAME, ...) NAME
#define rep_2(i, n) for (int(i) = 0; (i) < (int)(n); ++(i))
#define rep_3(i, initial, n) for (int(i) = (int)(initial); (i) < (int)(n); ++(i))
#define rep(...) rep_n(__VA_ARGS__, rep_3, rep_2, rep_1)(__VA_ARGS__)
// decrement
#define rep_r_n(_1, _2, _3, NAME, ...) NAME
#define rep_r_2(i, n) for (int(i) = (int)(n); (i) > 0; (i)--)
#define rep_r_3(i, initial, n) for (int(i) = (int)(initial); (i) > (int)(n); (i)--)
#define rep_r(...) rep_r_n(__VA_ARGS__, rep_r_3, rep_r_2)(__VA_ARGS__)
// define type definition
using namespace std;
typedef long long ll;
using mpint = boost::multiprecision::cpp_int; // 多倍長整数（任意精度）
typedef pair<int, int> P;

// define construct variable
const double EPS = numeric_limits<double>::epsilon();
// 10^9 + 7
const ll MOD = ll(1e9) + 7;
const ll INF = ll(1e10);
const string ALPHABET = "abcdefghijklmnopqrstuvwxyz";
const double PI = acos(-1);

// define methods
// 最大公約数
ll gcd(const ll a, const ll b) { return b ? gcd(b, a % b) : a; }
// 最小公倍数
ll lcm(const ll a, const ll b) { return a / gcd(a, b) * b; }
// char -> int
int ctoi(char c) { return (int)(c - '0'); }
// 素因数分解
vector< pair<ll, ll> > prime_factorize(ll n)
{
	vector< pair<ll, ll> > p;
	for (ll i = 2; i * i <= n; i++)
	{
		if ((n % i) != 0)
			continue;
		pair<ll, ll> a = make_pair(i, 0);
		while ((n % i) == 0)
		{
			n /= i;
			a.second += 1;
		}
		p.push_back(a);
	}

	if (n != 1)
		p.push_back(make_pair(n, 1));
	return p;
}
// 組み合わせの整合性を保つ（後ほど解析する）
ll modinv(ll a)
{
	ll b = MOD, u = 1, v = 0;
	while (b)
	{
		ll t = a / b;
		a -= t * b;
		swap(a, b);
		u -= t * v;
		swap(u, v);
	}
	u %= MOD;
	if (u < 0)
	{
		u += MOD;
	}
	return u;
}
// 順列
ll permutation(const ll n, const ll m)
{
	ll result = 1;
	for (ll i = n; i > n - m; i--)
	{
		result = (result * i) % MOD;
	}
	return result;
}

// 繰り返し n 乗法
ll repeat_square(const ll n, const ll x)
{
	if (x == 0)
		return 1;
	ll res = repeat_square(n, x / 2);
	res = res * res % MOD;
	if ((x % 2) == 1)
		res = res * n % MOD;
	return res;
}
// 組み合わせ nCm
ll combination(ll n, ll m)
{
	ll p = permutation(n, m);
	ll div = 1;
	for (ll i = 2; i <= m; i++)
	{
		div = (div * i) % MOD;
	}
	return (p * modinv(div)) % MOD;
}

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

	ll ans = ll(1e12);
	rep(a, 1, ll(sqrt(N))+1) {
		ll b = N / a;
		if (a * b != N) continue;
		if ((a-1+b-1) < ans) ans = a-1+b-1;
	}

	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
n,y = map(int,input().split())

for i in range(0,n+1):
  for j in range(0,n+1):
    k = int((y - 10000*i - 5000*j)/1000)
    if(k>=0 and i+j+k == n):
      print(i,j,k)
      exit()
print(-1,-1,-1)

Measured memory_bytes: 42716
#include<bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n ; i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define whole(f, x, ...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x) // decltypeで型取得、引数があればva_argsのところに入れる
using namespace std;
typedef long long ll; // long longをllでかけるようにした
const int INF = 1e9;

int main(void){
    int n; cin >> n;
    vector<int> num(n), inp(n);
    int end = n - 1, start = 0;
    REP(i, n) cin >> inp[i];
    REP(i, n){
        if(i % 2 == 0){
            num[start] = inp[n - 1 - i];
            start++;
        }
        else{
            num[end] = inp[n - 1 - i];
            end--;
        }
    }

    REP(i, n){
        if(i != 0) cout << " ";
        cout << num[i];
    }
    cout << endl;
}

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

int main() {
  int x, y;
  cin >> x >> y;
  set<int> a,b;
  
  if(x==2 && y==2)
    cout << "Yes" << endl;
  else {
    a.insert(1); a.insert(3); a.insert(5); a.insert(7); a.insert(8); a.insert(10); a.insert(12);
    b.insert(4); b.insert(6); b.insert(9); b.insert(11);
    if((a.count(x) && a.count(y)) || (b.count(x) && b.count(y)))
      cout << "Yes";
    else
      cout << "No";
    cout << endl;
  }
}

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

using namespace std;

int main() {

	string s,r,b,br;

	cin >> s;
	r = s;
	reverse(r.begin(), r.end());
	if (s != r) {
		cout << "No" << endl;
		return 0;
	}
	
	b = s.substr(0,(s.length()-1)/2);
	br = b;
	reverse(br.begin(), br.end());
	if (b != br) {
		cout << "No" << endl;
		return 0;

	}


	b = s.substr((s.length()+3)/2-1, s.length() - 1);
	br = b;
	reverse(br.begin(), br.end());
	if (b != br) {
		cout << "No" << endl;
		return 0;

	}

	cout << "Yes" << endl;

	return 0;
}

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

using namespace std;


int main() {
    int a, b, k;
    cin >> a >> b >> k;
    for(int i = 0; i < k; i++) {
        if(i % 2 == 0) {
            if(a % 2 != 0) {
                a--;
            }
            int h = a / 2;
            a = h;
            b += h;
        } else {
            if(b % 2 != 0) {
                b--; 
            }
            int h = b / 2;
            b = h;
            a += h;
        }
    }
    cout << a << " " << b << "\n";
    return 0;
}

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

int main() {
  int N;
  cin >> N;
  
  double ans = 1;
  for(int i = 1; i < 40; i++){
    for(int j = 2; j < 10; j++){
      if(N >= pow(i , j)) ans = max(ans, pow(i , j));
    }
  }

    cout << ans << endl;
}

Measured memory_bytes: 384
import java.util.*;
public class Main {
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		String s1 = sc.next();
		String s2 = sc.next();
		for(int i = 0;i < s1.length() - 1;i++) {
		System.out.print(s1.charAt(i));
		System.out.print(s2.charAt(i));
		}
		System.out.print(s1.charAt(s1.length() - 1));
		if(s1.length() == s2.length()) {
			System.out.print(s2.charAt(s2.length() - 1));
		}
	}
}


Measured memory_bytes: 23636
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;
// #pragma GCC optimize("O2")
typedef long long int ll;
typedef long double ld;
typedef map <ll,ll> mm;
typedef vector <ll> mv;
typedef pair <ll,ll> mp;
typedef set <ll> ms;
typedef multiset <ll> mms;
typedef queue <ll> mq;
typedef deque <ll> mdq;
typedef stack <ll> mst;
typedef priority_queue <ll> mpq;
typedef priority_queue <ll, vector<ll>, greater<ll> > mmh;
typedef complex<double> cd;
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
#define ordered_multiset tree<ll,null_type,less_equal<ll>,rb_tree_tag,tree_order_statistics_node_update>
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define flush cout.flush();
#define all(v) v.begin(),v.end()
#define ff first
#define ss second
#define pb(v) push_back(v)
#define lb(v) lower_bound(v)
#define ub(v) upper_bound(v)
#define cn continue
#define forl(i,n) for(ll i=0;i<n;i++)
#define forlr(i,n) for(ll i=n-1;i>=0;i--)
#define rev(s) reverse(s.begin(),s.end())
void swap(ll &a,ll &b) {
	ll tmp=a;
	a=b;
	b=tmp;
}
ll atoistring(string s) {
	stringstream lol(s);
	ll x;
	lol>>x;
	return x;
}
void pv(mv v) {
	forl(i,v.size()) cout<<v[i]<<" ";
	cout<<"\n";
}
void pa(ll *v,ll size) {
	forl(i,size) cout<<v[i]<<" ";
	cout<<"\n";
}
void removeDups(mv &v) {
	sort(all(v));
	mv::iterator it = unique(v.begin(), v.end());
	v.resize(distance(v.begin(), it));
}
// ll facs[], facsinv[];
// ll nck(ll N,ll K,ll mod) {
// 	if(N<K) return 0;
// 	return (((facs[N]*facsinv[N-K])%mod)*facsinv[K])%mod;
// }
inline ld kthRoot(ld n, ll k) {
	return pow(k, (1.0 / k) * (log(n) / log(k)));
}
ll power(ll x,ll y,ll p) {
	ll res=1;
	x=x%p;
	while(y>0) {
		if(y&1) res = (res*x)%p;
		y=y>>1;
		x=(x*x)%p;
	}
	return res;
}
void checkmod(ll &x,ll mod) {
	if(x>=mod) x%=mod;
}
ll ncr(ll n, ll r, ll mod) {
	ll ans = 1;
	forl(i,min(r,n - r)) {
		ans *= n - i;
		checkmod(ans,mod);
		ans *= power(i+1, mod - 2,mod);
		checkmod(ans,mod);
	}
	return ans;
}
ll sumofgp(ll a,ll n,ll m) {
	// n = number of terms - 1
	if(n < 0) return 0;
	if(n == 0) return 1;
	if(n==1) return (1+a)%m;
	ll ans;
	if(n%2) ans=(1+a)*sumofgp((a*a)%m,(n-1)/2,m);
    else ans=1+((a*(1+a))%m)*sumofgp((a*a)%m,n/2-1,m);
    return ans%m;
}
ll power_of_2_not_less(ll n) {
	if(!n) return 1;
	n--;
	n |= n>>1;
	n |= n>>2;
	n |= n>>4;
	n |= n>>8;
	n |= n>>16;
	n |= n>>32;
	n++;
	return n;
}
ll mod = 1e9 + 7;
// void checktime()
// {
// 	struct timespec ts;
// 	printf("Running Program\n");
// 	clock_gettime(CLOCK_MONOTONIC_RAW,&ts);
// 	long double st=ts.tv_nsec/(1e9)+ts.tv_sec;
// 	// Call Funcn Here
// 	clock_gettime(CLOCK_MONOTONIC_RAW,&ts);
// 	long double en=ts.tv_nsec/(1e9)+ts.tv_sec;
// 	printf("Program ended\nTime = %Lf\n",en-st);
// }

void thisIsMain() {
	ll a, b, c, k;
	cin>>a>>b>>c;
	cin>>k;
	ll ans = 0;
	while(b <= a) {
		ans ++ ;
		b *= 2;
	}
	while(c <= b) {
		ans ++ ;
		c *= 2;
	}
	if(ans <= k) cout<<"Yes\n"; else cout<<"No\n";
}

int main(void)
{
	fastio
	ll t = 1;
	// cin>>t;
	while(t--) thisIsMain();
	return 0;
}

Measured memory_bytes: 3652
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>

using namespace std;

int main(){
  int k;
  cin >> k;
  int count_o = 0;
  int count_e = 0;
  for(int i = 1;i <= k;i++){
    if(i%2 == 0){
      count_o++;
    }
    else{
      count_e++;
    }
  }
  cout << count_o*count_e << endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
  string s1, s2;
  cin >> s1 >> s2;

  bool can = true;
  if(s1.size()+1 == s2.size()){
    for(int i = 0; i < s1.size(); i++){
      if(s1[i] == s2[i]){
        continue;
      }
      can = false;
    }
  }
  else{
    can = false;
  }

  if(can) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}

Measured memory_bytes: 3624
n, m, k = map(int, input().split())
friends = [set() for _ in range(n+1)]
blocked = [set() for _ in range(n+1)]

for i in range(m):
    a,b = map(int, input().split())
    friends[a].add(b)
    friends[b].add(a)
for i in range(k):
    c,d = map(int, input().split())
    blocked[c].add(d)
    blocked[d].add(c)

checked = set()
ans = [0]*(n+1)
for i in range(1,n+1):
    if i in checked:
        continue
    stack = list(friends[i])
    chain = set()
    while stack:
        f = stack.pop()
        if f in checked:
            continue
        chain.add(f)
        checked.add(f)
        stack.extend(friends[f])
    cnt = len(chain) - 1
    for c in chain:
        ans[c] = cnt - len(chain & (friends[c] | blocked[c]))
    
print(*ans[1:])

Measured memory_bytes: 87816
import sys
from itertools import starmap
readline = sys.stdin.readline
EPS = 1e-9
class Segment(object):
    __slots__ = ('fi', 'se')
    def __init__(self, fi, se):
        self.fi = fi
        self.se = se
def cross(a, b):
    return a.real * b.imag - a.imag * b.real
def dot(a, b):
    return a.real * b.real + a.imag * b.imag
def norm(base):
    return abs(base) ** 2
def project(s, p2):
    base = s.fi - s.se
    r = dot(p2 - s.fi, base) / norm(base)
    return s.fi + base * r
def reflect(s, p):
    return p + (project(s, p) - p) * 2.0
def ccw(p1, p2, p3):
    a = p2 - p1
    b = p3 - p1
    if cross(a, b) > EPS: return 1
    if cross(a, b) < -EPS: return -1
    if dot(a, b) < -EPS: return 2
    if norm(a) < norm(b): return -2
    return 0
def intersect4(p1, p2, p3, p4):
    return (ccw(p1, p2, p3) * ccw(p1, p2, p4) <= 0 and
			ccw(p3, p4, p1) * ccw(p3, p4, p2) <= 0)
def intersect2(s1, s2):
    return intersect4(s1.fi, s1.se, s2.fi, s2.se)
def getDistance(a, b):  return abs(a - b)
def getDistanceLP(l, p):
    return abs(cross(l.se - l.fi, p - l.fi) / abs(l.se - l.fi))
def getDistanceSP(s, p):
    if dot(s.se - s.fi, p - s.fi) < 0.0: return abs(p - s.fi)
    if dot(s.fi - s.se, p - s.se) < 0.0: return abs(p - s.se)
    return getDistanceLP(s, p)
def getDistances(s1, s2):
    if intersect2(s1, s2): return 0.0
    return min(getDistanceSP(s1, s2.fi), getDistanceSP(s1, s2.se),
               getDistanceSP(s2, s1.fi), getDistanceSP(s2, s1.se))
n = int(readline())
for _ in [0] * n:
    li = tuple(map(int, readline().split()))
    p0, p1, p2, p3 = (x + y * 1j for x, y in zip(li[::2], li[1::2]))
    s1 = Segment(p0, p1)
    s2 = Segment(p2, p3)
    print("{0:.10f}".format(getDistances(s1, s2)))

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

int main() {
  int N; cin >> N;
  int N_tmp = N, f_N = 0; 
  while ( N_tmp != 0 ) { f_N += N_tmp % 10; N_tmp /= 10; }
  string result = "No";
  if ( N % f_N == 0 ) result = "Yes";
  cout << result;
  return 0;
}

Measured memory_bytes: 256
N, T = map(int, input().split())
ct = [list(map(int, input().split())) for _ in range(N)]

cost = []

for i in range(N):
    if ct[i][1] <= T:
        cost.append(ct[i][0])

if len(cost) == 0:
    print('TLE')
else:
    print(min(cost))

Measured memory_bytes: 3060
#include <cstdio>
#include <climits>
#include <cassert>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <list>
#include <set>
#include <bitset>
#include <iterator>
#define rep(i, n) for(long long i = 0; i < (long long)(n); i++)
using namespace std;
typedef long long int LL;
typedef unsigned long long int ULL;
using Data = pair<LL, vector<LL>>;

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];
    }
    sort(a.begin(), a.end(), greater<LL>());
    sort(b.begin(), b.end(), greater<LL>());
    sort(c.begin(), c.end(), greater<LL>());
    priority_queue<Data> que;
    set<Data> se;
    que.push(Data(a[0] + b[0] + c[0], vector<LL>({0, 0, 0})));
    rep(k, K) {
        auto cur = que.top();
        que.pop();
        cout << cur.first << endl;

        if (cur.second[0] + 1 < X) {
            LL sum = cur.first - a[cur.second[0]] + a[cur.second[0] + 1];
            auto num = cur.second;
            num[0]++;
            auto d = Data(sum, num);
            if (not se.count(d)) {
                se.insert(d);
                que.push(d);
            }
        }
        if (cur.second[1] + 1 < Y) {
            LL sum = cur.first - b[cur.second[1]] + b[cur.second[1] + 1];
            auto num = cur.second;
            num[1]++;
            auto d = Data(sum, num);
            if (not se.count(d)) {
                se.insert(d);
                que.push(d);
            }
        }
        if (cur.second[2] + 1 < Z) {
            LL sum = cur.first - c[cur.second[2]] + c[cur.second[2] + 1];
            auto num = cur.second;
            num[2]++;
            auto d = Data(sum, num);
            if (not se.count(d)) {
                se.insert(d);
                que.push(d);
            }
        }

    }
    return 0;
}


Measured memory_bytes: 1536
#include<iostream>
#include<vector>
#include <queue>

#define INF 1<<29

using namespace std;

struct Edge {
    int to;
    double cost;
};

struct P {
    int v;
    double cost;
    int tickets;

    bool operator<(const P& o) const {
        return cost > o.cost;
    }
};

int main() {
    while (true) {
        int n, m, rn, s, g;
        double cost[30][257], ticket[8];

        cin >> n >> m >> rn >> s >> g;
        if ((n | m | rn | s | g) == 0) {
            break;
        }
        s--;
        g--;
        for (int i = 0; i < n; ++i) {
            int t;
            cin >> t;
            ticket[i] = t;
        }

        vector<Edge> edges[30];

        for (int j = 0; j < rn; j++) {
            int x, y;
            double z;
            cin >> x >> y >> z;
            edges[x - 1].push_back((Edge) { y - 1, z } );
            edges[y - 1].push_back((Edge) { x - 1, z } );
        }
        double dp[31][1 << 9];
        for (int i = 0; i < m; ++i) {
            fill(dp[i], dp[i] + (1 << n), INF);
        }
        dp[s][(1 << n) - 1] = 0;

        priority_queue<P> que;
        que.push((P) { s, 0, (1 << n) - 1 });
        while (!que.empty()) {
            P p = que.top();
            que.pop();
            for (int ei = 0; ei < edges[p.v].size(); ei++) {
                Edge e = edges[p.v][ei];
                for (int i = 0; i < n; i++) {
                    if (((p.tickets >> i) & 1 ) == 0) {
                        continue;
                    }
                    int at = p.tickets - (1 << i);

                    if (dp[e.to][at] > dp[p.v][p.tickets] + e.cost / ticket[i]) {
                        dp[e.to][at] = dp[p.v][p.tickets] + e.cost / ticket[i];
                        que.push((P) { e.to, dp[e.to][at], at });
                    }
                }
            }
        }

        double res = INF;
        for (int i = 0; i < (1 << n) - 1; ++i) {
            res = min(res, dp[g][i]);
        }
        if (res == INF) {
            cout << "Impossible" << endl;
        } else {
            cout << res << endl;
        }
    }
}

Measured memory_bytes: 5496
object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val n = sc.nextInt
  val (h :: hh) = Seq.fill(n)(sc.nextInt).reverse

  val (max, _, _) = hh.foldLeft((0, 0, h)) {
    case ((max, count, before), h) =>
      if (h >= before) {
        if (count + 1 > max) {
          (count + 1, count + 1, h)
        } else {
          (max, count + 1, h)
        }
      } else {
        (max, 0, h)
      }
  }

  println(max)
}

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

int main() {
  int K; cin >> K;
  string S; cin >> S;
  if ((int)S.size() <= K) cout << S << endl;
  else {
    rep(i, K) cout << S[i];
    cout << "..." << endl;
  }
}

Measured memory_bytes: 3596
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <numeric>
#include <deque>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
	string shortStr;
	string longStr;
	cin >> longStr;
	cin >> shortStr;
	int shortNum, longNum;
	int ans = 1000000;
	int ansTmp = 0;
	shortNum = shortStr.size();
	longNum = longStr.size();
	rep(i, longNum - shortNum + 1) {
		ansTmp = 0;
		rep(j, shortNum) {
			if (shortStr[j] != longStr[i + j]) {
				ansTmp++;
			}
		}
		if (ansTmp < ans) {
			ans = ansTmp;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 3636
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<unordered_map>
#include<cmath>
using namespace std;
using Graph = vector<vector<int>>;
typedef unsigned long long ll;
ll mod = (10e+8)+ 7;

#define For(N,i) for(int i = 0; i < N; i++)
int main(){
	int N;
	cin>>N;
	vector<int>C(N+1);
	vector<int>Y(N);
	For(N+1,i){
		cin>>C[i];
	}
	For(N,i){
		cin>>Y[i];
	}
	ll ans = 0;
	for(int i = 0; i < N; i++){
		
		ans += min(C[i], Y[i]);
		//cout<<ans<<endl;
		int c = C[i];
		C[i] = max(0,C[i]-Y[i]);
		Y[i] = max(0,Y[i]-c);
		ans += min(C[i+1], Y[i]);
		C[i+1] = max(0,C[i+1]-Y[i]);
		
		//cout<<ans<<endl;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 1024
#include <stdio.h>

void merge_sort (int array[], int left, int right) {
  int i, j, k, mid;
  int work[100001];  // 作業用配列
  if (left < right) {
    mid = (left + right)/2; // 真ん中
    merge_sort(array, left, mid);  // 左を整列
    merge_sort(array, mid+1, right);  // 右を整列
    for (i = mid; i >= left; i--) { work[i] = array[i]; } // 左半分
    for (j = mid+1; j <= right; j++) {
      work[right-(j-(mid+1))] = array[j]; // 右半分を逆順
    }
    i = left; j = right;
    for (k = left; k <= right; k++) {
      if (work[i] < work[j]) { array[k] = work[i++]; }
      else                   { array[k] = work[j--]; }
    }
  }
}





int main(void){

    int n,k;
    scanf("%d %d",&n,&k);
    int a[1001]; 
    
    for(int i=1;i<=n;i++){
    scanf("%d",&a[i]);
    }
 
    merge_sort(a, 1, n);
 
    int ans=0;
    
    for(int i=1;i<=k;i++){
        ans+=a[i];
    }
 
 
 printf("%d",ans);
 return 0;
}

Measured memory_bytes: 1756
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define rep(i,n) for(int i=0;i<(int)n;i++)
const ll INF = (1LL<<60);
const int MOD = 1000000007;


int main(){
    int k; cin >> k;
    string s = "ACL";
    rep(i,k) cout << s;
    cout << endl;
}

Measured memory_bytes: 3544
import java.util.*;
import static java.lang.Math.*;
import java.math.BigInteger;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int n = sc.nextInt();
		String s = sc.next();
		
		// 計算
		long result = 0;
		int[][] dp = new int[n+1][n+1];
		for(int i = n - 1; i >= 0; i--){
		    for(int j = n - 1; j >= 0; j--){
		        if(s.charAt(i) == s.charAt(j)){
		            dp[i][j] = dp[i + 1][j + 1] + 1;
		            result = max(result, min(dp[i][j], abs(j - i)));
		        }
		    }
		}
		
		// 出力
		System.out.println(result);
		
	}
}


Measured memory_bytes: 169292
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <vector>
using namespace std;

#define debug(x) cout<<#x<<": "<<x<<endl
#define rep(i,a,b) for(int i=a;i<b;i++)
#define PB push_back
#define putn(x,n) cout<< fixed<< setprecision(n)<< x << endl;
typedef long long ll;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int k, t,tmp;
	int ans = 0;
	int turn;
	cin >> k >> t;
	vector<int> a(t);
	rep(i, 0, t){
		cin >> tmp;
		a[i] = tmp;
	}
	if (t == 1)cout << k -1 << endl;
	else{
		sort(a.begin(), a.end());
		reverse(a.begin(), a.end());
		rep(i, 0, t - 1){
			for (; a[i] > 0;){
				rep(j, i + 1, t){
					turn = j + 1;
					if (a[i] != a[j]){
						turn = j;
						break;
					}
				}
				if (i != turn - 1){
					rep(j, i, turn)a[j]--;
				}
				else{
					if (a[i + 1] == 0)break;
					a[i]--;
					if (a[i] != a[i + 1]){
						rep(j, 0, t-1){
							if (a[t - j -1]){
								a[t - j-1]--;
								break;
							}
						}
					}
				}
			}
		}
		rep(i, 0, t){
			ans += a[i];
		}
		//rep(i, 0, t)debug(a[i]);
		if(ans!=0)ans--;
		cout << ans << endl;
	}
	
	return 0;
}


Measured memory_bytes: 256
import Control.Monad
import Data.List

solve = foldl' f (0, 0)
  where
    f (n, c) [a, b] = if a < n then t n c else t b (1 + c)
    t x y = (,) x $! y

readN = map read . words <$> getLine

main = do
  [n, m] <- readN
  rs <- replicateM m readN
  print . snd . solve . sortOn last $ rs


Measured memory_bytes: 94588
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <utility>
using namespace std;
typedef pair<int,int> pii;
typedef long long ll;
#define mp make_pair
#define fst first
#define scn second
int main(){
	while(true){
		int n,m,s,g1,g2;	cin>>n>>m>>s>>g1>>g2;
		if(n==0)	break;
		s--;	g1--;	g2--;
		vector<vector<ll>> dist(n,vector<ll>(n,1e9));
		for(int i=0;i<n;i++)	dist[i][i]=0;
		for(int i=0;i<m;i++){
			int f,t,d;	cin>>f>>t>>d;
			f--;	t--;
			dist[f][t]=d;
		}
		for(int k=0;k<n;k++){
			for(int i=0;i<n;i++){
				for(int j=0;j<n;j++){
					dist[i][j]=min(dist[i][j],dist[i][k]+dist[k][j]);
				}
			}
		}
		ll ret=1e9;
		for(int i=0;i<n;i++){
			ret=min(ret,dist[s][i]+dist[i][g1]+dist[i][g2]);
		}
		cout<<ret<<endl;
	}
	return 0;
}

Measured memory_bytes: 3220
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define mk make_pair
#define fi first
#define se second
#define vll vector<ll>
#define pii pair<ll,ll>
#define vvll vector< vector<ll> >
#define pb push_back
#define inf 1e16
#define M 1000000007
#define all(v) (v).begin(),(v).end()
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
#define mx 1000010

int main(){
	IOS;
	ll k,x;cin>>k>>x;
	vll v;
	ll t=-1000000;
	rep(i,0,2000001){v.pb(t);t++;}
	vll ans;
	for(ll i=x-(k-1);i<=x;i++)ans.pb(i);
	for(ll i=x+1;i<=x+(k-1);i++)ans.pb(i);
	rep(i,0,ans.size())cout<<ans[i]<<" ";
	return 0;
}



Measured memory_bytes: 18664