akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 100005;
int n, k;
char str[N];
stack<int> q;

int main() {
    cin>>n>>k;
    scanf("%s", str);
    
    int flag = 0, cnt = 0, i = 0, ans = 0;
    for(;i<n;i++) {
        if(flag == 1) {
            if(str[i] == 'R') {
                cnt ++;
            }else {
                flag = -1;
                ans += (cnt - 1);
                cnt = 1;
                q.push(1);
            }
        }else if(flag == -1) {
            if(str[i] == 'L') {
                cnt ++;
            }else {
                flag = 1;
                ans += (cnt - 1);
                cnt = 1;
                q.push(-1);
            }
        }else {
            flag = (str[i] == 'R') ? 1 : -1;
            cnt = 1;
        }
    }
    ans += (cnt - 1);
    if(flag == 1)q.push(1);
    else q.push(-1);
    //cout<<ans<<q.size()<<endl;
    while(!q.empty() && k-- > 0) {
        if(q.size() == 2) {
            ans ++;
            break;
        }else if(q.size() == 1) {
            break;
        }else {
            flag = q.top();
            q.pop(); q.pop(); q.pop();
            q.push(flag);
            ans += 2;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
#define ll long long
#define ls id << 1
#define rs id << 1 | 1
#define mem(array, value, size, type) memset(array, value, ((size) + 5) * sizeof(type))
#define memarray(array, value) memset(array, value, sizeof(array))
#define fillarray(array, value, begin, end) fill((array) + (begin), (array) + (end) + 1, value)
#define fillvector(v, value) fill((v).begin(), (v).end(), value)
#define pb(x) push_back(x)
#define st(x) (1LL << (x))
#define pii pair<int, int>
#define mp(a, b) make_pair((a), (b))
#define Flush fflush(stdout)
#define vecfirst (*vec.begin())
#define veclast (*vec.rbegin())
#define vecall(v) (v).begin(), (v).end()
#define vecupsort(v) (sort((v).begin(), (v).end()))
#define vecdownsort(v, type) (sort(vecall(v), greater<type>()))
#define veccmpsort(v, cmp) (sort(vecall(v), cmp))
using namespace std;
const int N = 500050;
const int inf = 0x3f3f3f3f;
const ll llinf = 0x3f3f3f3f3f3f3f3f;
const int mod = 998244353;
const int MOD = 1e9 + 7;
const double PI = acos(-1.0);
clock_t TIME__START, TIME__END;
void program_end()
{
#ifdef ONLINE
    printf("\nTime used: %.6lf(s)\n", ((double)TIME__END - TIME__START) / 1000);
    system("pause");
#endif
}
int n;
ll p[N][2];

inline void solve()
{
    scanf("%d", &n);
    for (int i = 0; i < n; ++i)
        scanf("%lld%lld", &p[i][0], &p[i][1]);
    ll ans = 0;
    for (int s = 0; s < st(2); ++s)
    {
        ll mx = -llinf, mn = llinf;
        for (int i = 0; i < n; ++i)
        {
            ll res = 0;
            for (int j = 0; j < 2; ++j)
                res += (s & st(j)) ? p[i][j] : -p[i][j];
            mx = max(mx, res);
            mn = min(mn, res);
        }
        ans = max(ans, mx - mn);
    }
    cout << ans << '\n';
}

int main()
{
    TIME__START = clock();
    int Test = 1;
    // scanf("%d", &Test);
    while (Test--)
        solve();
    TIME__END = clock();
    program_end();
    return 0;
}

Measured memory_bytes: 6884
#include <bits/stdc++.h>
using namespace std;
long long hp[200005];
signed main(){
	long long n,k,ans=0;
  cin>>n>>k;
  for(int i=0;i<n;i++){
    cin>>hp[i];
  }
  sort(hp,hp+n);
  for(int i=min(n-1,n-1-k);i>=0;i--){
    ans+=hp[i];
  }
  cout<<ans<<endl;
  return(0);
  }
  

Measured memory_bytes: 1792
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce



sys.setrecursionlimit(2147483647)
INF = float('inf')
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007


n, m, r = LI()
graph = [[INF] * n for _ in range(n)]
L = LI()
for u, v, c in LIR(m):
    graph[u - 1][v - 1] = c
    graph[v - 1][u - 1] = c

for i in range(n):
    graph[i][i] = 0


for i in range(n):
    for j in range(n):
        for k in range(n):
            graph[j][k]=min(graph[j][i]+graph[i][k], graph[j][k])



ans = INF
for i in permutations(L):
    ret = 0
    for j in range(r - 1):
        ret += graph[i[j]-1][i[j+1]-1]
    ans = min(ans, ret)


print(ans)

Measured memory_bytes: 64092
#include<stdio.h>

int main(){
  int N, K, p[1000], sum=0, min=0, trans;
  scanf("%d%d", &N, &K);
  for(int i=0; i<N; i++){
      scanf("%d", &p[i]);
  }
  for(int i=0; i<N; i++){
      for(int j=0; j<N-1; j++){
          if(p[j]>p[j+1]){
              trans = p[j];
              p[j] = p[j+1];
              p[j+1] = trans;
          }
        } 
    }
    for(int i=0; i<K; i++){
        sum = sum + p[i];
    }
        printf("%d", sum);
        return 0;
}




Measured memory_bytes: 1732
// ?????????????????????????????????
#include <vector>
#include <cstdlib>
#include <cstring>
#include <iostream>

using namespace std;

#define MAX_V 200
#define INF (1<<20)

//to:?????????,cap:??????,rev:???(G[e.to][e.rev]??§??????????§????????????¢???????????§?????????)
// rev?????????NW
struct edge {
	int to,cap,rev;
};

vector<edge> G[MAX_V];
bool used[MAX_V];

//???????????????rev???,???????????§??§??????????????????????????????size??§??????????????????????????\?????????????????¨???????????????(i.e ???????????\)???????????????????????????????????§?????????
void add_edge(int from,int to,int cap) {
	G[from].push_back( (edge){ to,cap,(int)G[to].size() } );
	G[to].push_back( (edge){ from,0,(int)G[from].size()-1});
}

//s??????t????§???????????????????????????????????????§?????????????????????????????????0????????????
int dfs(int v,int t,int f) {
	if (v==t) return f;
	used[v] = true;
	for (int i=0; i<G[v].size(); i++) {
		edge &e = G[v][i]; // ???????????????????????£????????§??????
		if (!used[e.to] && e.cap>0) {
			int d = dfs(e.to,t,min(f,e.cap));
			if (d > 0) { // ??????????????????????????£?????´???
				e.cap -= d;
				G[e.to][e.rev].cap += d; // ??????????????????
				return d;
			}
		}
	}
	return 0;
}

//s??????t???????????§??????????????????
int max_flow(int s,int t) {
	int flow = 0;
	while(1){
		memset(used,0,sizeof(used)); // ????????????
		int f = dfs(s,t,INF); // ?§?????????????????????§??§???????????´???1???????????¢???
		if (f==0) return flow; // ????????\?????????????????´???????????§
		flow += f; // ??????????????§??????
	}
}

int main() {
	int n=4;
	// vector<vector<int> >  to = {
	// {1,3}, {2,3}, {3,4}, {4}
	// } ;
	// vector<vector<int> > cap = {
	// {10,2}, {6,6}, {3,8}, {5}
	// } ;
	int edge_num;
	cin>>n>>edge_num;

	for(int i=0;i<edge_num;i++){
		int from,to,cap;cin>>from>>to>>cap;
		add_edge(from,to,cap);
	}

	// for(int i=0;i<n;i++){
	// cout<<"----"<<i<<endl;
	// for(int j=0;j<G[i].size();j++){
	// cout<<G[i][j].to<<" "<<G[i][j].cap<<" "<<G[i][j].rev<<endl;
	// }
	// }
	cout << max_flow(0,n-1) << endl;
}

Measured memory_bytes: 3208
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include <functional>
#include<time.h>
#include <stack>
#include<iomanip>
using namespace std;
#define rep(i,a,n) for(ll i=(a);i<(n);i++)
#define ll long long
#define llint long long int
#define reverse(v)  reverse(v.begin(), v.end());
#define Yes(ans) if(ans)cout<<"Yes"<<endl; else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl; else cout<<"NO"<<endl;
#define hei(a) vector<a>
#define whei(a) vector<vector<a>>
#define UF  UnionFind 
#define Pint pair<int,int>
#define keta(a)  fixed << setprecision(a)
constexpr auto INF = 100000000000;
constexpr auto mod = 1000000007;
//辞書順はnext_permutation( begin( v ), end( v ) );やで！
struct edge { int to, cost; };
long long modpow(long long a, long long n, long long mod) {
	long long res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

// mod. m での a の逆元 a^{-1} を計算するよ！
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}


//aCbをmod.mで割った余りを求める
ll int c(ll int a, ll int b, ll int m) {
	ll int ans = 1;
	for (ll int i = 0; i < b; i++) {
		ans *= a - i;
		ans %= m;
	}
	for (ll int i = 1; i <= b; i++) {
		ans *= modinv(i, m);
		ans %= m;
	}
	return ans;
}

//sは初めの点、vは頂点size、dは最短距離を求める(初期化はINF),Gは有向グラフ
void dijkdtra(int s, int v, vector<int>& d, whei(edge)& G) {
	priority_queue<Pint, vector<Pint>, greater<Pint>> que;//firstが距離、secondが頂点
	d[s] = 0;//スタートの距離はもちろんzero
	que.push(Pint(0, s));
	while (!que.empty()) {
		Pint p = que.top();
		que.pop();
		int V = p.second;
		if (d[V] < p.first)continue;
		for (int i = 0; i < G[V].size(); i++) {
			edge e = G[V][i];
			if (d[e.to] > d[V] + e.cost) {
				d[e.to] = d[V] + e.cost;
				que.push(Pint(d[e.to], e.to));
			}
		}
	}
}

Pint f(int x) {
	int b = 0;
	int a = x % 10;
	while (x) {
		b = x;
		x /= 10;
	}
	return Pint(a, b);
}


int main() {
	int n;
	cin >> n;
	map<Pint, int> m;
	ll ans = 0;
	rep(i, 1, n + 1) {
		Pint p = f(i);
		m[p]++;
	}
	rep(i, 1, 10) {
		rep(j, 1, 10) {
			ans += m[Pint(i, j)] * m[Pint(j, i)];
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
C=[list(map(int,input().split())) for i in range(3)]
x1=C[0][1]-C[0][0];x2=C[0][2]-C[0][1];
y1=C[1][0]-C[0][0];y2=C[2][0]-C[1][0];
C2=[[C[0][0],C[0][0]+x1,C[0][0]+x1+x2],
    [C[0][0]+y1,C[0][0]+x1+y1,C[0][0]+x1+x2+y1],
    [C[0][0]+y1+y2,C[0][0]+x1+y1+y2,C[0][0]+x1+x2+y1+y2]]
print("Yes"if C==C2 else"No")

Measured memory_bytes: 3064
#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;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()

int func(int N)
{
        if (N < 10)
                return N;
        return func(N / 10) + N % 10;
}

int main()
{
        int N;
        cin >> N;
        vector<int> a(N);
        rep(i, N) cin >> a[i];
        sort(all(a));
        reverse(all(a));
        int ans = 0;
        rep(i, N)
        {
                ans += a[i] * (i & 1 ? -1 : 1);
        }
        cout << ans << endl;

        return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<functional>
#include<map>
#include<cstdlib>
#include<complex>
#include<numeric>

using namespace std;
using Int = long long;
Int INF = 1LL << 60;

int main() {

	Int a, b;
	cin >> a >> b;

	Int ans=b/2;
	if (a >= 13)ans = b;
	else if (a <= 5)ans = 0;

	cout << ans << endl;


}

Measured memory_bytes: 256
s=list(map(int,tuple(input())))
k=int(input())
i=0
if 1 in s:
  for i in range(len(s)):
    if s[i]!=1:
      break
  if i>=k:
      print(1)
  else:
      print(s[i])
else:
  print(s[0])

Measured memory_bytes: 9144
#include<iostream>

using namespace std;

long h[100100];
long dp[100100];

int main(void)
{
  long N;
  cin >> N;
  for(long i=0;i<N;i++)
  {
    cin >> h[i];
  }
  dp[0] = 0;
  dp[1] = abs(h[0] - h[1]);
  for(long i=2;i<N;i++)
  {
    dp[i] = min(dp[i-2] + abs(h[i-2]-h[i]),dp[i-1] + abs(h[i-1] - h[i]));
  }

  cout << dp[N-1] << endl;
  return 0;
}


Measured memory_bytes: 1792
#include <algorithm>
#include <iostream>
#include <queue>
#include <stack>
#include <unordered_set>
using namespace std;

typedef pair<int, int> Sushi;

int main() {
    int n, k;
    cin >> n >> k;
    priority_queue<Sushi> pque;
    for (int i = 0; i < n; i++) {
        int t, d;
        cin >> t >> d;
        pque.push(Sushi(d, t));
    }

    long d_sum = 0;
    unordered_set<int> st;
    stack<int> remove_next;
    for (int i = 0; i < k; i++) {
        Sushi top = pque.top(); pque.pop();
        d_sum += top.first;
        if (st.find(top.second) == st.end()) {
            st.insert(top.second);
        } else {
            remove_next.push(top.first);
        }
    }
    long types = st.size();
    long ans = d_sum + types * types;
    while (!remove_next.empty() && !pque.empty()) {
        int remove_top = remove_next.top();
        Sushi add_top = pque.top(); pque.pop();
        if (st.find(add_top.second) == st.end()) {
            types++;
            st.insert(add_top.second);
            d_sum -= remove_top - add_top.first;
            ans = max(ans, types * types + d_sum);
            remove_next.pop();
        }
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 4596
import java.util.*;
import java.awt.geom.*;
import static java.lang.Math.*;
public class Main {
	final Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		new Main().init();
	}
	void init(){
		new Q2001A();
	}
	
	class Q2001A{
		int N;
		Q2001A(){
			while(true){
				N=sc.nextInt();
				if(N==0)	break;
				solve();
			}
		}
		void solve(){
			Point2D[][] p=new Point2D[N+2][N+2];
			for(int x=1; x<=N; ++x)	p[x][0]=new Point2D.Double(sc.nextDouble(), 0.0);
			for(int x=1; x<=N; ++x)	p[x][N+1]=new Point2D.Double(sc.nextDouble(), 1.0);
			for(int y=1; y<=N; ++y)	p[0][y]=new Point2D.Double(0.0, sc.nextDouble());
			for(int y=1; y<=N; ++y)	p[N+1][y]=new Point2D.Double(1.0, sc.nextDouble());
			p[0][0] = new Point2D.Double(0, 0);
			p[N+1][0] = new Point2D.Double(1, 0);
			p[0][N+1] = new Point2D.Double(0, 1);
			p[N+1][N+1] = new Point2D.Double(1, 1);
			for(int x=1; x<=N; ++x){
				Line2D.Double col = new Line2D.Double(p[x][0], p[x][N+1]);
				for(int y=1; y<=N; ++y){
					Line2D.Double row = new Line2D.Double(p[0][y], p[N+1][y]);
					p[x][y] = intersectionPoint(row, col);
				}
			}
			
			double ans=0.0;
			for(int x=0; x<=N; ++x)for(int y=0; y<=N; ++y){
				Point2D v1 = diff(p[x+1][y], p[x][y]),
						v2 = diff(p[x][y+1], p[x][y]);
				double area = abs(cross(v1, v2) /2);
				Point2D v3 = diff(p[x][y+1], p[x+1][y+1]),
						v4 = diff(p[x+1][y], p[x+1][y+1]);
				area += abs(cross(v3, v4)/2);
				ans = max(ans, area);
			}
			
			System.out.printf("%.6f\n", ans);
			
		}
		Point2D intersectionPoint(Line2D l1,Line2D l2){
			return intersectionPoint(l1.getP1(), l1.getP2(), l2.getP1(), l2.getP2());
		}
		Point2D intersectionPoint(Point2D a1,Point2D a2,Point2D b1,Point2D b2){
			Point2D a=diff(a2,a1),
					b=diff(b2,b1);
			return sum(a1, mul(cross(b, diff(b1,a1))/cross(b,a), a));
		}
		Point2D diff(Point2D p1,Point2D p2){
			return new Point2D.Double(p1.getX()-p2.getX(), p1.getY()-p2.getY());
		}
		double cross(Point2D p1,Point2D p2){
			return p1.getX()*p2.getY() - p2.getX()*p1.getY();
		}
		Point2D mul(double n,Point2D p1){
			return new Point2D.Double(p1.getX()*n, p1.getY()*n);
		}
		Point2D sum(Point2D p1,Point2D p2){
			return new Point2D.Double(p1.getX()+p2.getX(), p1.getY()+p2.getY());
		}
	}

}

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

void printRect(int w, int h)
{
    while (h-- > 0)
    {
        for (int x = 0; x < w; x++)
        {
            cout << '#';
        }
        cout << endl;
    }
}

int main(void)
{
    while (1)
    {
        int h, w;
        cin >> h >> w;
        if (h == 0 && w == 0)
            break;
        printRect(w, h);
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 3092
N,M = map(int,input().split())

arr = []
town = [[0]*2 for i in range(M)] #所属県、順番
count = [0]*(N+1)
for i in range(M):
    p,y= map(int,input().split())
    arr.append([i,p,y])

arr.sort(key=lambda x:x[2])

for i in arr:
    temp = i[1]
    town[i[0]][0] = temp
    town[i[0]][1] = count[i[1]]+1
    count[i[1]] += 1

for i in town:
    print(str(i[0]).zfill(6)+str(i[1]).zfill(6))

Measured memory_bytes: 38444
typedef long long ll;
#include <bits/stdc++.h>
using namespace std;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int main() {
    ll n,a,b,c;
    ll l[1000];
    std::cin >> n>>a>>b>>c;
    for (int i = 0; i < n; i++) {
        std::cin >> l[i];
    }
    ll result = 10000000;
    for (int i = 0; i < (ll)pow(4,n); i++) {
        ll tmp_a = 0;
        ll tmp_b = 0;
        ll tmp_c = 0;
        ll mp = 0;
        ll tmp_i = i;
        
        string test = "";
        
        for (int j = 0; j < n; j++) {
            if(tmp_i % 4 == 1){
                test = test+ "a";
                tmp_a += l[j];
                mp += 10;
            }else if(tmp_i % 4 == 2){
                test = test+ "b";
                tmp_b += l[j];
                mp += 10;
            }else if(tmp_i % 4 == 3){
                test = test+ "c";
                tmp_c += l[j];
                mp += 10;
            }else{
                test = test+ "/";
            }
            tmp_i /= 4;
        }
        if(tmp_a * tmp_b * tmp_c == 0){
            continue;
        }
        mp -= 30;
        // std::cout << test << std::endl;
        mp += (ll)abs(a-tmp_a) + (ll)abs(b-tmp_b) + (ll)abs(c -tmp_c);
        result = min(result,mp);
    }
    std::cout << result << std::endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin>>n;
    vector<int> a(n);
    for(int i=0;i<n;i++)cin>>a.at(i);
    int dp[100100];
    memset(dp,0,sizeof(dp));
    for(int i=1;i<n;i++){
    if(i>1)dp[i]=min(dp[i-2]+abs(a.at(i)-a.at(i-2)),dp[i-1]+abs(a.at(i)-a.at(i-1)));
    else dp[i]=abs(a.at(i)-a.at(i-1));
            
    }
    cout<<dp[n-1]<<endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <tuple>
#include <numeric>
using namespace std; using ll = long long; using ld = long double;  using pll = pair<ll, ll>;
using vl = vector<ll>; using vll = vector<vl>; using vpll = vector<pll>;
using vs = vector<string>; using tll = tuple<ll, ll, ll>; using vtll = vector<tll>;
const ld PI = 3.1415926535897932;
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define co(i) cout << i << endl;
#define co2(i,j) cout << i << " " << j << endl;
#define co3(i) cout << i << " ";
#define po(i) cout << i.first << " " << i.second << endl;
void in() {}
void debug_out() { cerr << endl; }
template<typename Head, typename... Tail>
void debug_out(Head h, Tail... t) {
	cerr << " " << h;
	if (sizeof...(t) > 0) cerr << " :";
	debug_out(t...);
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> vec) {
	for (size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
	return os;
}
ll ctoi(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2;
	case '3': return 3; case '4': return 4; case '5': return 5;
	case '6': return 6; case '7': return 7; case '8': return 8;
	case '9': return 9;  default: return 0;
	}
}
bool pairCompare(const pll firstElof, pll secondElof)
{
	return firstElof.first > secondElof.first;
}
//**Snippetリスト**//
//rep, vin, all, iteLoop, bitSearch, bitList, nod//
//gcdlcm, isPrime, eratos, primeFactorize, Npow, combination, divisor, modinv, doubling, digitDP//
//dfs, bfs, dijkstra, WarshallFloyd, BellmanFord, UnionFind, Kruskal, RMQ, LCA//
ll i, j, k, l; ll N, M, K, H, W, L, X, Y, Z, R, Q;
ll MOD = 1000000007, INF = 1LL << 60, ans = 0, z = 0, o = 1;
vl flag, D; vpll path;
//***********//
int main() { 
	ll A, V;
	cin >> A >> V;
	ll B, W;
	cin >> B >> W;
	ll T;
	cin >> T;
	ll D = abs(A - B);
	if (V <= W) cout << "NO";
	else {
		if (D<=T*(V-W)) {
			cout << "YES";
		}
		else {
			cout << "NO";
		}
	}
}

Measured memory_bytes: 3640
/***** author : @C0d1ngPhenomena *****/

	#include <bits/stdc++.h>
	#include <cstdio>
	#include <cstring>
	#include <cmath>
	#include <cstring>
	#include <chrono>
	#include <complex>
	#define endl "\n"
	#define ll long long int
	#define vi vector<int>
	#define vll vector<ll>
	#define vvi vector < vi >
	#define pii pair<int,int>
	#define pll pair<long long, long long>
	#define mod 1000000007
	#define inf 1000000000000000001;
	#define all(c) c.begin(),c.end()
	#define mp(x,y) make_pair(x,y)
	#define mem(a,val) memset(a,val,sizeof(a))
	#define eb emplace_back
	#define pb push_back
	#define f first
	#define s second
	
	using namespace std;
	int main()
	{
		std::ios::sync_with_stdio(false);
		
		ll S, W;
		cin>>S>>W;
		(W>=S)?cout<<"unsafe":cout<<"safe";
		return 0;
	}


Measured memory_bytes: 3692
/*Points to be noted :
1)Don't be afraid to fail.
2)Never give up easily,keep trying.
3)Don't care about other ppl's progress.
4)Spend much time on each problem & keep trying. I WILL DO IT!💯*/

// Mere bas ka nahi hai
// still i'm trying
// apna time aayega
//
//        .--------------.  
//        | Try First One|
//        '--------------'
//                |     .--------------.
//                |     |              |
//                V     V              |
//              .--------------.       |
//              |      AC.     |<---.  |  
//              '--------------'    |  |
//              (True)|  |(False)   |  |
//           .--------'  |          |  |
//           |           V          |  |
//           |  .--------------.    |  |
//           |  |   Try Again  |----'  |
//           |  '--------------'       |
//           |                         |
//           |  .--------------.       |
//           '->| Try Next One |-------'
//              '--------------'                          		  
//


#include<bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
#define int long long int
#define ld long double
#define ull unsigned long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define r0 return 0;
#define tc int t;cin>>t;while(t--)
#define for0(i, n) for (int i = 0; i < n; i++)
#define for1(i, n) for (int i = 1; i <= n; i++)
#define loop(i,a,b) for (int i = a; i < b; i++)
#define vi vector<int>
#define vii vector<long long int>
#define SORT(v) sort(v.begin(),v.end());
#define PI 3.1415926535897932384626433832795
#define mod 1000000007
#define md 998244353
#define inf 1000000000000000 //1e15
#define gcd __gcd
#define lcm(a,b) ((a)*(b))/gcd(a,b)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define crap ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define endl "\n"
int min(int a,int b){
    return (a<b)?a:b;
}
int max(int a,int b){
    return (a>b)?a:b;
}
int fp(int a,int b){
    if(b==0) return 1;
    int x=fp(a,b/2);
    x=(x*x)%mod;
    if(b&1) x=(x*a)%mod;
    return x;
}
int factorial(int n)
{
    int fact=1;
    for(int i=2;i<=n;i++)
    fact=fact*i;
    
    return fact;
}
int ncr(int n,int r)
{
    return factorial(n)/(factorial(r)*factorial(n-r));
}
void c_p_c()
{
    crap;
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}
signed main()
{
    c_p_c();
    int n,k;
    cin>>n>>k;
    int sum=0;
    int a[n];
    for(int i=0;i<n;i++)
        cin>>a[i];
    sort(a,a+n);
    for(int i=0;i<k;i++)
        sum+=a[i];
    cout<<sum<<endl;
}

Measured memory_bytes: 3592
#include <stdio.h>

#define MAX (10000 + 5)
int p[MAX];
int rank[MAX];

void makeSet(int x) {
    p[x] = x;
    rank[x] = 0;
}

void link(int x, int y) {
    if(rank[x] > rank[y]) {
        p[y] = x;
    } else {
        p[x] = y;
        if(rank[x] == rank[y]) {  
            rank[y]++;
        }
    }
}

int findSet(int x) {
    if(x != p[x]) 
        p[x] = findSet(p[x]);
    return p[x];
}

void myUnion(int x, int y) {
    link( findSet(x), findSet(y) );
}
    
int isSameSet(int x, int y) {
    return findSet(x) == findSet(y);
}
    
int main(void) {
	int i,n,q;
	int com,x,y;
	scanf("%d %d\n", &n, &q);
	for(i=0;i<n;i++) makeSet(i);
	
	for(i=0;i<q;i++) {
		scanf("%d %d %d\n", &com, &x, &y);
		if(com == 0) {
			/* 結合 */
			myUnion(x, y);
		} else {
			printf("%d\n", isSameSet(x, y));
		}
	}
	
	return 0;
}

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

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

  string s;
  cin >> s;
  int size = s.size();
  string ans = "";
  for (int i = 0; i < size; i++)
  {
    ans.push_back('x');
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e16;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (ll)(n); i++)

int main() {
  ll n; cin >> n;
  cout << n/3 << endl;
}

Measured memory_bytes: 3616
#include <iostream>

int main(void)
{
    int a, b;
    std::string s;
    std::cin >> a >> b >> s;
    bool flag = true;
    for (int i = 0; i < int(s.size()); ++i)
    {
        if (i == a)
        {
            flag &= (s[i] == '-');
        }
        else
        {
            flag &= ('0' <= s[i]) && (s[i] <= '9');
        }
    }
    std::cout << (flag ? "Yes" : "No") << std::endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    string s;
    int l=0,ans=0;
    cin>>s;
    for(int i=0;i<s.size();i++){
        if(s[i]=='A' || s[i]=='C' || s[i]=='G' || s[i]=='T'){
            l++;
        }
        else{
            if(ans<l){
                ans=l;
            }
            l=0;
        }
    }
    if(ans<l){
                ans=l;
            }
    cout<<ans<<endl;
    return(0);
}

Measured memory_bytes: 3612
#include<stdio.h>

#define INF 10000
#define WHITE 1
#define BLACK 0
#define GRAY 2

int p[101];
int d[101];
int color[101];
int num[101][101];

void prim(int);


int main(){
  int n;
  int i,j;
  

  scanf("%d",&n);


  for(i=1;i<=n;i++){
    for(j=1;j<=n;j++){
      scanf("%d",&num[i][j]);
    }
  }

  prim(n);

  return 0;
}

void prim(int n){
  int i,j,u;
  int mincost;
  int sum=0;

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

  d[1]=0;

  while(1){
    mincost=INF;
    for(i=1;i<=n;i++){
      if(color[i]!=BLACK && d[i]<mincost){
	mincost=d[i];
	u=i;
      }
    }    
    if(mincost==INF) break;

    color[u]=BLACK;
      
    for(i=1;i<=n;i++){
      if(color[i]!=BLACK && num[u][i]!=-1){
	if(num[u][i]<d[i]){
	  d[i]=num[u][i];
	  p[i]=u;
	  color[i]=GRAY;
	}
      }
    }
  }


  for(i=1;i<=n;i++){
    if(p[i]!=-1) sum+=num[i][p[i]];
  }
  printf("%d\n",sum);
}

Measured memory_bytes: 640
import std.stdio, std.string, std.conv;
void main() {
	long n, m, l;
	"%d %d %d\n".readf(&n, &m, &l);
	long[][] a, b;
	foreach (_n; 0..n) a ~= readln.split.to!(long[]);
	foreach (_m; 0..m) b ~= readln.split.to!(long[]);
	foreach (_a; a) {
		long[] c = [];
		foreach (_l; 0..l) {
			long s = 0;
			foreach (_m; 0..m) {
				s += _a[_m] * b[_m][_l];
			}
			c ~= s;
		}
		c.to!(string[]).join(" ").writeln;
	}
}

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

const int M = 1000000007;
long long modinv(int a, int m) {
    int x = m, y = a, p = 1, q = 0, r = 0, s = 1;
    while (y != 0) {
        int u = x / y;
        int x0 = y; y = x - y * u; x = x0;
        int r0 = p - r * u, s0 = q - s * u;
        p = r; r = r0; q = s; s = s0;
    }
    return q < 0 ? q + m : q;
}

int main() {
    int n; cin >> n;
    int x[n]; for (int i = 0; i < n; i++) cin >> x[i];
    long long f = 1, A = 0, ans = 0;
    for (int i = 1; i < n; i++) f = f * i % M;
    for (int i = 1; i < n; i++) {
        A += f * modinv(i, M) % M;
        ans += A * (x[i] - x[i-1]) % M;
    }
    cout << ans % M << endl;
}


Measured memory_bytes: 640
#include <iostream>
#include <cstdlib>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
using namespace std;

int main(){
    int d, g;
    cin >> d >> g;
    int p[d+1];
    int all[d+1];
    for(int i = 1; i <= d; i++){
        int c;
        cin >> p[i] >> c;
        all[i] = p[i]*i*100+c;
    }

    int min_count = 10000;
    for(long long i = 0; i < 1<<d; i++){
        long long sum = 0;
        int count = 0;
        for(int j = 0; j < d; j++){
            if(1<<j & i){
                sum += all[j+1];
                count += p[j+1];
            }
        }

        if(sum < g){
            for(int j = d-1; j >= 0; j--){
                if(!((1<<j)&i)){
                    int b = (g-sum)/(100*(j+1))+((g-sum)%(100*(j+1))==0?0:1);
                    if(b < p[j+1]){
                        // cout << j << " " << g - sum << " " << (g - sum) / (100 * (j + 1)) << b << endl;
                        count += b;
                        sum += ((g-sum)/(100*(j+1))+((g-sum)%(100*(j+1))==0?0:1))*(100*(j+1));
                    }
                    break;
                }
            }
        }
        if(sum < g){
            continue;
        }
        min_count = min(count, min_count);
        // cout << bitset<8>(i) << " " << sum << " " << count << endl;
    }
    cout << min_count << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
	int n, x;
	cin >> n;
	int array[n];

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

	for(int j = n - 1; j >= 0; j--){
		cout << array[j];
		if(j != 0) cout << " ";
	}
	cout << endl;

	return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll gcdEx(ll a, ll b, ll *x, ll *y) {
    if (!a) {*x = 0; *y = 1; return b;}
    ll x1, y1, gcd = gcdEx(b % a, a, &x1, &y1); *x = y1 - (b / a) * x1; *y = x1; return gcd;
}
ll modI(ll b, ll m)      {ll x, y; gcdEx(b, m, &x, &y); return (x % m + m) % m;}
#define all(x) (x).begin(), (x).end()
#define make_unique(x) sort(all((x))); (x).resize(unique(all((x))) - (x).begin())

#define sum(a)     ( accumulate ((a).begin(), (a).end(), 0ll))
#define mine(a)    (*min_element((a).begin(), (a).end()))
#define maxe(a)    (*max_element((a).begin(), (a).end()))
#define mini(a)    ( min_element((a).begin(), (a).end()) - (a).begin())
#define maxi(a)    ( max_element((a).begin(), (a).end()) - (a).begin())
#define lowb(a, x) ( lower_bound((a).begin(), (a).end(), (x)) - (a).begin())
#define uppb(a, x) ( upper_bound((a).begin(), (a).end(), (x)) - (a).begin())
#define MOD                 1000000007
#define modA(a,b)           (((a%MOD)+(b%MOD))%MOD)
#define modS(a,b)           (((((a%MOD)-(b%MOD))%MOD)<0)?(ll)(MOD+((a%MOD)-(b%MOD))%MOD):(ll)(((a%MOD)-(b%MOD))%MOD))
#define modM(a,b)           (ll)((((ll)(a%MOD))*((ll)(b%MOD)))%MOD)
#define modD(a,b)           ((modI(b,MOD)*(a%MOD))%MOD)
ll modP(ll x, ll y)         {
    ll r = 1; x %= MOD; while (y > 0) {
        if (y & 1) {r = (r * x) % MOD;}
        y = y >> 1; x = (x * x) % MOD;
    } return r;
}
ll max(ll a, ll b) {return (a > b ? a : b);}
ll min(ll a, ll b) {return (a < b ? a : b);}
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 << '\n'; }
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...);
}
ll gcd( ll a, ll b )
{
    if (b == 0)
    {
        return a;
    }
    else
    {
        return gcd( b, (a % b) );
    }
}
ll lcm (ll a, ll b)
{
    ll ans = (a  / gcd(a, b)) * b;
    return ans;
}
void solve()
{
    ll ans = 0;
    ll n;
    cin >> n;
    ans = 1000 - (n % 1000);
    if (ans == 1000) ans = 0;
    cout << ans << "\n";
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int t ;
    t = 1;
//   cin >> t;
    while (t--)
        solve();
    return 0;
}





Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
// Prioridade
typedef long long   ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpi;
typedef vector<pll> vpll;
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define REP(i,a,b) for(int i = a; i < (int)(b); i++)
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3f
#define all(x) x.begin(),x.end()
#define MOD 1000000007
#define endl '\n'
#define mdc(a, b) (__gcd((a), (b)))
#define mmc(a, b) (((a)/__gcd(a, b)) * b)
#define W(x) cerr << "\033[31m"<<  #x << " = " << x << "\033[0m" << endl;
// fim da Prioridade

double dp[2][302][302];
	
int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL); 	
	int n;
	cin >> n;
	vi count(4,0);
	for (int i = 0; i < n; i++){
		int x; 
		cin >> x;
		count[x]++;
	}
	for(int three = 0; three <= count[3]; three++){
		for(int two = 0; two <= count[3] + count[2]; two++){
			for(int one = 0; one <= n; one++){
				if(three + two + one > n || three + two + one == 0) continue;
				
				double answer = n;
				
				if(three) answer += three * dp[(three + 1) & 1][two + 1][one];
			
				if(two)   answer += two   * dp[three & 1][two - 1][one + 1];
				
				if(one)   answer += one   * dp[three & 1][two][one - 1];
				
				answer /= (three + two + one)*1.0;
				dp[three & 1][two][one] = answer;
			}
		}
	}
	
	cout << setprecision(9) << fixed << dp[count[3] & 1][count[2]][count[1]] << endl;
	return 0;
}
 


Measured memory_bytes: 1664
n=int(input())
s=list(map(int,input().split()))

s.sort()
if len(set(s))==1:
  print(0)
else:
  minx=s[0]
  maxx=s[-1]
  c=10**9
  for p in range(minx,maxx):
    t=0
    for i in s:
      t=t+(i-p)*(i-p)
    if c>t:
      c=t

  print(c)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<n;i++)
template<class T> inline T gcd(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}else{return 0;}}

#define MOD 1000000007
typedef long long ll;

int main(){
  int n;
  cin >> n;
  vector<int> v;
  int s[1000],sum=0;
  FOR(i,n){
    cin >> s[i];
    sum+=s[i];
    if(s[i]%10!=0)v.push_back(s[i]);
  }

  sort(v.begin(),v.end());
  if(sum%10==0){
    if(v.size()==0){
      cout << 0 << endl;
    }else{
      cout << sum-v[0] << endl;
    }
  }else{
    cout << sum << endl;
  }
  

  
}

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

int main()
{
  string weather;
  cin >> weather;
  if (weather == "Sunny"){
    cout << "Cloudy" << endl;
  }
  if (weather == "Cloudy"){
    cout << "Rainy" << endl;
  }
  if (weather == "Rainy"){
    cout << "Sunny" << endl;
  }
}

Measured memory_bytes: 256
import collections
import sys
sys.setrecursionlimit(10**5)
N, M, K = map(int, input().split())
AB = [tuple(map(int, input().split())) for i in range(M)]

CD = [tuple(map(int, input().split())) for i in range(K)]


class unionFind:
    parent = []

    def __init__(self, N):
        self.parent = [i for i in range(N)]

    def root(self, x):
        if self.parent[x] == x:
            return(x)
        else:
            self.parent[x] = self.root(self.parent[x])
            return(self.parent[x])

    def same(self, x, y):
        x, y = x-1, y-1
        return(self.root(x) == self.root(y))

    def unite(self, x, y):
        x, y = x-1, y-1
        x = self.root(x)
        y = self.root(y)
        if x == y:
            return
        else:
            self.parent[x] = y
            return


# F = [set() for i in range(N)]
F = unionFind(N)
f = [set() for i in range(N)]
for a, b in AB:
    F.unite(a, b)
    a -= 1
    b -= 1
    f[a].add(b)
    f[b].add(a)

B = [set() for i in range(N)]
for c, d in CD:
    c -= 1
    d -= 1
    B[c].add(d)
    B[d].add(c)

ans = [0]*N
D = collections.defaultdict(set)
for i in range(N):
    D[F.root(i)].add(i)

# print(f)
for i in range(N):
    x = D[F.root(i)]
    ret = len(x)
    ret -= 1
    ret -= len(x & f[i])
    ret -= len(x & B[i])
    ans[i] = ret
print(*ans)


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

int mod = 1'000'000'007;
long modpow(long a, int p){
  if (p==0) return 1;
  if (p%2==0){
    int half = p/2;
    long halfpow = modpow(a,half);
    return halfpow * halfpow % mod;
  }else{
    return a * modpow(a,p-1) % mod;
  }
}

long calcC(int a, int b){
  if (b>a-b) return calcC(a,a-b);
  long Mul = 1;
  long Div = 1;
  for (int i = 0; i<b; i++){
    Mul *= (a-i);
    Div *= (i+1);
    Mul %= mod;
    Div %= mod;
  }
  return Mul * modpow(Div,mod-2) % mod;
}

int main(){
  int n,m;
  cin >> n >> m;
  long ans = 1;
  for (int i=2; i*i<=m; i++){
    if (m%i==0){
      int cnt = 0;
      while(m%i==0){
        m/=i;
        cnt++;
      }
      ans*=calcC(cnt+n-1,cnt);
      ans%=mod;
    }
  }
  if (m!=1){
    ans*=calcC(n,1);
    ans%=mod;
  }
  cout << ans << endl;
}



Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
      int k, s, ans = 0;
      cin >> k >> s;
      for (int i = 0; i <= k; i ++) {
            for (int j = 0; j <= k; j ++) {
                  if (i + j <= s && s - i - j <= k) ans ++;
            }
      }
      cout << ans << endl;
      return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define VS vector<string>
#define VB vector<bool>
#define VP vector<pair<ll,ll>>
#define VVL vector<vector<ll>>
#define VVP vector<vector<pair<ll,ll>>>
#define PL pair<ll,ll>
#define ALL(v) (v).begin(), (v).end()
ll d1[4] = {1, -1, 0, 0};
ll d2[4] = {0, 0, 1, -1};

int main(){
    ll a;
    string b;
    cin >> a >> b;
    ll lb = 100 * (b[0] - '0') + 10 * (b[2] - '0') + b[3] - '0';
    ll p = a * lb;
    ll ans = p / 100;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3632
#include<iostream>
using namespace std;
main()
{
  int a,b,c;
  cin>>a;
  cin>>b;
  if((a==1&&b==2)||(a==2&&b==1))
     cout<<'3';
   else if((a==1&&b==3)||(a==3&&b==1))
     cout<<'2';
   else 
     cout<<'1';
  }

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <map>
#include <stack>
#include <set>
using namespace std;
typedef long long LL;
typedef unsigned long long uLL;
#define ms(a, b) memset(a, b, sizeof(a))
#define pb push_back
#define mp make_pair
#define eps 0.0000000001
#define IOS ios::sync_with_stdio(0);cin.tie(0);
const LL INF = 0x3f3f3f3f3f3f3f3f;
const int inf = 0x3f3f3f3f;
const int mod = 1e9+7;
const int maxn = 200000+10;
vector <int> a[maxn];
int main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
//        freopen("output.txt", "w", stdout);
#endif
    IOS
    int n, m;
    cin >> n >> m;
    for(int i = 0;i<m;i++){
        int u, v;
        cin >> u >> v;
        a[u].pb(v);
    }
    for(int i = 0;i<a[1].size();i++){
        for(int j = 0;j<a[a[1][i]].size();j++){
            if(a[a[1][i]][j] == n){
                cout << "POSSIBLE" << endl;
                return 0;
            }
        }
    }
    cout << "IMPOSSIBLE" << endl;
    return 0;
}


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

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


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

int main() {
  int h, n;
  cin >> h >> n;
  int a[n], b[n];
  for (int i = 0; i < n; i++) cin >> a[i] >> b[i];

  int dp[h+1];
  dp[0] = 0;
  for (int i = 1; i <= h; i++) dp[i] = 100000000;

  for (int i = 0; i < n; i++) {
    for (int j = 0; j < h; j++) {
      int k = min(h, j + a[i]);
      dp[k] = min(dp[k], dp[j] + b[i]);
    }
  }
  
  cout << dp[h] << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <list>
#include <map>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
 
int main(void)
{
    int N, D;
    int X[10][10] = {0};

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

    int ans = 0;
    for (int j = 1; j < N; ++j)
    {
        for (int i = 0; i < j; ++i)
        {
            int len = 0;
            for (int d = 0; d < D; ++d)
            {
                len += (X[i][d] - X[j][d]) * (X[i][d] - X[j][d]);
            }

            if (sqrt(len) - int(sqrt(len)) == 0.0)
            {
                ++ans;
            }
        }
    }

    cout << ans;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> PP;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
//#define INF 810114514
#define PI 3.141592653589
#define setdouble setprecision
#define REP(i,n) for(ll i=0;i<(n);++i)
#define OREP(i,n) for(ll i=1;i<=(n);++i)
#define RREP(i,n) for(ll i=(n)-1;i>=0;--i)
#define GOODBYE do { cout << "0" << endl; return 0; } while (false)
#define MM <<" "<<
#define Endl endl
#define debug false
#define debug2 false


int main(void){
    
    ll N;
    string C;
    
    cin >> N >> C;
    ll r = 0;
    REP(i,N){
        if(C[i]=='R')r++;
    }
    ll num=0;
    REP(i,r){
        if(C[i]=='W')num++;
    }
    cout << num << endl;
    
    return 0;
}



Measured memory_bytes: 3752
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
using namespace std;
typedef long long lng;
#define FOR(i,a,b) for(int i=(a); i<=(b); ++i)
#define FORD(i,b,a) for(int i=(b); i>=(a); --i)
#define REP(i,n) FOR(i,0,n-1)
#define ALL(a) (a).begin(), (a).end()
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end()) //ATTENTION: <a> must be sorted in advance

lng power(lng b, lng n) {lng sol=1; while(n>0) {if(n&1) {sol=sol*b;} n>>=1; b*= b;} return sol;} //calculate b^n

const int MOD = 1000000007; //10^9+7


/*********** variables ************/
lng dp[8000];
/**********************************/

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int K, S;
    cin >> K >> S;
    REP(i, K+1) REP(j, K+1) {
        dp[i+j]++;
    }
    lng cnt = 0;
    REP(i, K+1) {
        int dd = S - i;
        if(dd>=0) cnt += dp[dd];
    }
    cout << cnt << endl;
}


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

const int N = 302;
int dst[N][N];
bool a[N][N];
int n;

int main(){
	ios_base::sync_with_stdio(0); cout.tie(0); cin.tie(0);
	
	cin>>n;
	long long ans = 0;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			cin>>dst[i][j];
		}
	}
	
	bool hano = false;
	for(int k=1;k<=n;k++){
		for(int i=1;i<=n;i++){
			if(i == k)continue;
			for(int j=1;j<=n;j++){
				if(j == k)continue;
				if(dst[i][k] + dst[k][j] < dst[i][j]){
					hano = true;
				}else{
					if( dst[i][k] + dst[k][j] == dst[i][j] ){
						a[i][j] = true;
					}
				}
			}
		}
	}
	/*
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			cout<<a[i][j]<<" ";
		}
		cout<<endl;
	}
	*/
	if(hano){
		cout<<-1;
	}else{
		for(int i=1;i<=n;i++){
			for(int j=i+1;j<=n;j++){
				if(!a[i][j]){
					ans += dst[i][j];
				}
			}
		}
		cout<<ans<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 768
/*
2020-04-25
atcoder ABC
C - Low Elements
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
const ll mod = 1000000007;

int main() {
    int N, ans = 0;
    cin >> N;
    int min_p = N;
    for (int i = 0; i < N; i++) {
        int p;
        cin >> p;
        min_p = min(min_p, p);
        if (min_p == p) {
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    
    string S;
    cin >> S;
    
    int ans = 0;
    
    for(int i = 0; i < S.size() - 1; i++){
        if(S.at(i) == S.at(i + 1))
            ans = 1;
    }
    
    if(ans == 1)
        cout << "Bad" << endl;
    else
        cout << "Good" << endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <cmath>
#include <string>
#include <string.h>
#include <cstdlib>
#include <iomanip>
#include <stdio.h>

using namespace std;

class Dice {
  private:
   int face[6];
 
  public:
    int getTop();
    int getFace(int);
    void setFace(int label,int value);
    void turnRight();
    void turnOver(char dir);
    void debugOut();
    bool compare0(Dice dice);
    bool compare1(Dice dice);
    bool compare(Dice dice);
};

int Dice::getTop(){
  return face[0];
}

int Dice::getFace(int i){
  return face[i];
}

void Dice::setFace(int label,int value){
  if(label>5) return;
  face[label] = value;
}

void Dice::turnRight(){
    int tmp = face[1];
    face[1] = face[3]; face[3] = face[4];
    face[4] = face[2]; face[2] = tmp; // face[1]
}

void Dice::turnOver(char c){
  int tmp;
  if(c=='N'){
    tmp = face[0];
    face[0] = face[1]; face[1] = face[5];
    face[5] = face[4]; face[4] = tmp; // face[0]
  }

  if(c=='S'){
    tmp = face[0]; 
    face[0] = face[4]; face[4] = face[5];
    face[5] = face[1]; face[1] = tmp; //face[0]
  }

  if(c=='E'){
    tmp = face[0]; 
    face[0] = face[3]; face[3] = face[5];
    face[5] = face[2]; face[2] = tmp; //face[4]
  }

  if(c=='W'){
    tmp = face[0]; 
    face[0] = face[2]; face[2] = face[5];
    face[5] = face[3]; face[3] = tmp; //face[4]
  }
}

void Dice::debugOut(){
    for(int i=0;i<6;i++)
      printf("%d,",face[i]);
    putchar('\n');
}

bool Dice::compare0(Dice dice){
  for(int e=0;e<3;e++){
    for(int n=0;n<3;n++){
      if(getFace(0)==dice.getFace(0)&&getFace(5)==dice.getFace(5)) {
        return true;
      }
      turnOver('N');
    }
    turnOver('E');
  }
  return false;
}

bool Dice::compare1(Dice dice){
  for(int i=0;i<3;i++){
    if(getFace(1)==dice.getFace(1)&&
       getFace(2)==dice.getFace(2)&&
       getFace(3)==dice.getFace(3)&&
       getFace(4)==dice.getFace(4))
      return true;

    turnRight();
  }
  return false;
}

bool Dice::compare(Dice dice){

  if(!compare0(dice)) {
    return false;
  }
  if(compare1(dice))
    return true;
  return false;
}

int main(){
  Dice dice[100];
  int n,l;

  scanf("%d\n",&n);

  for(int i=0;i<n;i++){
    for(int j=0;j<6;j++){
      scanf("%d ",&l);
      dice[i].setFace(j,l);
    }
  }
  for(int i=0;i<n;i++){
   for(int j=0;j<n;j++){
     if(i==j) continue;
     if(dice[i].compare(dice[j])) {
       //dice[i].debugOut();
       //dice[j].debugOut();
       puts("No");
       return 0;
     } 

  }
  }
  puts("Yes");
}


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

	
	int dn[33];
int main(){
	int n=0;
	dn[0]=1;
	for(int i=0;i<30;i++){
		for(int j=1;j<=3;j++){
		dn[i+j]+=dn[i];
		}
	}
	
	while(true){
	cin >> n;
	if(n==0)
		break;
	int l=dn[n]/(365*10);
	if(dn[n]%(365*10)!=0)
		l++;

	cout << l << endl;
	}
}

Measured memory_bytes: 1160