akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define debug(x) #x << "=" << (x)
 
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif
 
const int inf=1e9;
const int64_t inf64=1e18;
const double eps=1e-9;
 
template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
    	os << v << ",";
    }
    os << "]";
    return os;
}
 
using i64=int64_t;
 
struct edge{
    int from,to;
    i64 weight;
    edge(int from_,int to_,i64 weight_){
        from=from_;
        to=to_;
        weight=weight_;
    }
};
 
void solve(){
    int N,M;
    cin >> N >> M;
    vector<edge> edges;
    rep(i,0,M){
        int a,b;
        i64 c;
        cin >> a >> b >> c;
        --a;
        --b;
        edges.push_back(edge(a,b,-c));
    }
 
    vector<i64> dist(N,inf64);
    dist[0]=0;
    for(int i=0; i<N-1; ++i){
        for(edge& e:edges){
            int u=e.from,v=e.to;
            if(dist[u]!=inf64 and dist[v]>dist[u]+e.weight) dist[v]=dist[u]+e.weight;
        }
    }
 
    vector<bool> negative(N,false);
    for(int i=0; i<N; ++i){
        for(edge& e:edges){
            int u=e.from,v=e.to;
            if(dist[u]!=inf64 and dist[v]>dist[u]+e.weight){
                dist[v]=dist[u]+e.weight;
                negative[v]=true;
            }
            if(negative[u]) negative[v]=true;
        }
    }
    if(negative[N-1]) cout << "inf" << endl;
    else cout << -dist[N-1] << endl;
}
 
int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(10);
    solve();
    return 0;
}

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

using namespace std;
int kx[] = {1,1,1,0,-1,0};
int ky[] = {-1,0,1,1,0,-1};
int gx[] = {0,1,0,-1,-1,-1};
int gy[] = {-1,0,1,1,0,-1};
int w,h,ans=0;
int d[110][110];

void dfs(int a,int b){
	d[a][b] = 2;
	for(int i = 0;i < 6;i++){
		int na,nb;
		if(a % 2 == 0){
			na = a + gy[i];
			nb = b + gx[i];
		}else{
			na = a + ky[i];
			nb = b + kx[i];
		}
		if(na >= 0 && na <= h+1 && nb >= 0 && nb <= w+1){
			if(d[na][nb] == 1)ans++;
			if(d[na][nb] == 0)dfs(na,nb);
		}
	}
}



int main(){
	cin >> w >> h;
	for(int i = 1;i <= h;i++){
		for(int j = 1;j <= w;j++){
			cin >> d[i][j];
		}
	}
	dfs(0,0);
	cout << ans << endl;
	return 0;
}


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

int main() {
  int N,A,B,v1,v2;
  
  cin >> N >> A >> B;
  
  v1 = N*A;
  
  v2=min(v1,B);
  
  cout << v2 <<endl;
  
  


}


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

using namespace std;
typedef long long ll;
typedef pair<int, int> P;

int main() {
  int n;
  cin >> n;
  vector<ll> A(n + 1);
  A[0] = 0;
  for (int i = 1; i <= n; ++i) {
    int a;
    cin >> a;
    A[i] = A[i - 1] + a;
  }
  ll ans = 1e18;
  int l = 1, r = 3;
  for (int center = 2; center < n - 1; ++center) {
    ll d = 1e18;
    while (l < center) {
      ll diff = abs((A[center] - A[l]) - A[l]);
      if (d < diff) break;
      d = diff;
      l++;
    }
    l--;

    d = 1e18;
    while (r < n) {
      ll diff = abs((A[n] - A[r]) - (A[r] - A[center]));
      if (d < diff) break;
      d = diff;
      r++;
    }
    r--;
    ll one = A[l];
    ll two = A[center] - A[l];
    ll three = A[r] - A[center];
    ll four = A[n] - A[r];
    ll ma = max(max(one, two), max(three, four));
    ll mi = min(min(one, two), min(three, four));
    ans = min(ans, ma - mi);
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <string>
#include <utility>
#include <deque>
#define MAX_N 100000
#define INF 1000000000000
typedef long long ll;
using namespace std;

int main(){
  ll cost[100000];
  ll K,tv,nv;
  deque<ll> V;
  cin>>K;

  for(int i=0;i<K;i++){
    cost[i]=INF;
  }
  cost[1]=0;
  V.push_back(1);

  while(!V.empty()){
    tv =V.front() ;
    V.pop_front();
    nv=(tv+1)%K;
    if(cost[nv]>cost[tv]+1){
      cost[nv]=cost[tv]+1;
      V.push_back(nv);
    }
    nv=(tv*10)%K;
    if(cost[nv]>cost[tv]){
      cost[nv]=cost[tv];
      V.push_front(nv);
    }
  }
  cout<<cost[0]+1<<endl;
  return 0;
}


Measured memory_bytes: 1408
N, K, Q = map(int, input().split())
A = [int(input()) for i in range(Q)]
a = [0] * N
for i in range(Q):
    a[A[i]-1] += 1
for i in range(N):
    if K - ( Q - a[i] ) > 0:
        print('Yes')
    else:
        print('No')


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

int n, m;
vector<int> taro, hanako;
int st, sh;

void solve() {
  int d = st - sh;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      if (2 * (taro[i] - hanako[j]) != d) continue;
      cout << taro[i] << ' ' << hanako[j] << endl;
      return;
    }
  }
  cout << -1 << endl;
  return;
}

int main() {
  while (cin >> n >> m, n) {
    taro = vector<int>(n);
    for (int i = 0; i < n; ++i) cin >> taro[i];
    sort(begin(taro), end(taro));
    st = accumulate(begin(taro), end(taro), 0);

    hanako = vector<int>(m);
    for (int i = 0; i < m; ++i) cin >> hanako[i];
    sort(begin(hanako), end(hanako));
    sh = accumulate(begin(hanako), end(hanako), 0);

    solve();
  }
  return 0;
}



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

#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
typedef long long ll ;
typedef long double ld ;

const ll MOD = 998244353, INF = 2E18 + 5 ;
const double PI = 2 * acos(0.0) ;
const long double EPS = 1.0E-14 ;


int main()
{
    string s, t, ss ;
    cin >> s >> t ;
    ss = s ;
    ss += t[t.size() - 1] ;

    if (ss == t)    cout << "Yes\n" ;
    else    cout << "No\n" ;



    return 0 ;
}


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

int main() {
  int N;
  cin >> N;
  int f = 0;
  int f2 = 0;
  for (int i = 0; i < N; i++){
      int A;
      cin >> A;
      if (A % 2 == 1){
          break;
      }
      while (A % 2 != 1){
          A /= 2;
          f2++;
      }
      if (f != 0){
          if (f > f2){
              f = f2;
          }
      }
      else{
        f = f2;
      }
      f2 = 0;
  }
  cout << f << endl;
}  

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

int main(){
  int a1, a2, a3;
  cin >> a1 >> a2 >> a3;
  priority_queue<int>Q;
  Q.push(abs(a2-a1));
  Q.push(abs(a3-a2));
  Q.push(abs(a1-a3));
  int ret;
  Q.pop();
  ret += Q.top();
  Q.pop();
  ret += Q.top();
  cout << ret;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define int long long int
#define double long double
#define inf (int)(1e15)
#define all(x) (x).begin(), (x).end()
#define pair pair<int, int>
typedef vector<int> vi;   // Vector of long long
typedef vector<vi> vvi;   // Vector of vi
typedef vector<pair> vii; // Vector of pairs
typedef vector<vii> vvii; // Vector of Vector of pairs
typedef vector<bool> vb;  // Vector of bool
#define pq priority_queue // Max heap (To convert to min heap, use negative sign before every value)
#define ff first          // For pairs
#define ss second
const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, -1, 0, 1};
const int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1}, dy8[] = {1, -1, 1, 0, -1, 1, -0, -1};
#define testcases(t) \
    int(t);          \
    cin >> (t);      \
    while ((t)--)
int n, k, dist = inf;
vi a;
signed main()
{
    cin >> n >> k;
    a.resize(n + 1);
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
        if (a[i] == 0)
            k--;
    }
    for (int l = 0; l < (n - k + 1); l++)
    {
        int r = l + k - 1;
        dist = min(dist, min(abs(a[l]) + abs(a[l] - a[r]), abs(a[r]) + abs(a[l] - a[r])));
    }
    cout << dist << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#define INF 0x3f3f3f3f
#define MOD 1000000007
#define PI 4*atan(1.0)
typedef long long ll;
typedef long double ld;
using namespace std;
int dx[4]={0,0,-1,1};
int dy[4]={-1,1,0,0};
const int SIZE=200001+5000;
//int arr[SIZE]={};
//???????????§???????????¬
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(auto i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
typedef int Weight;
struct Edge {
  int src, dst;
  Weight weight;
  Edge(int src, int dst, Weight weight) :
    src(src), dst(dst), weight(weight) { }
};
bool operator < (const Edge &e, const Edge &f) {
  return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
    e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

typedef vector<Weight> Array;
typedef vector<Array> Matrix;
void shortestPath(const Graph &g, int s,
    vector<Weight> &dist, vector<int> &prev) {
  int n = g.size();
  dist.assign(n, INF); dist[s] = 0;
  prev.assign(n, -1);
  priority_queue<Edge> Q; // "e < f" <=> "e.weight > f.weight"
  for (Q.push(Edge(-2, s, 0)); !Q.empty(); ) {
    Edge e = Q.top(); Q.pop();
    if (prev[e.dst] != -1) continue;
    prev[e.dst] = e.src;
    FOR(f,g[e.dst]) {
      if (dist[f->dst] > e.weight+f->weight) {
        dist[f->dst] = e.weight+f->weight;
        Q.push(Edge(f->src, f->dst, e.weight+f->weight));
      }
    }
  }
}
vector<int> buildPath(const vector<int> &prev, int t) {
  vector<int> path;
  for (int u = t; u >= 0; u = prev[u])
    path.push_back(u);
  reverse(path.begin(), path.end());
  return path;
}
int main(){
	Graph G;
	int N;
	cin>>N;
	for(int i=0;i<N;i++){
		Edges E;
		G.push_back(E);
	}
	for(int i=0;i<N;i++){
		int u,k;
		cin>>u>>k;
		for(int j=0;j<k;j++){
			int v,c;
			cin>>v>>c;
			G[u].push_back(Edge(u,v,c));
		}
	}
	vector<Weight> dist;
	vector<int> prev;
	shortestPath(G,0,dist,prev);
	for(int i=0;i<N;i++){
		cout<<i<<" "<<dist[i]<<endl;
	}
	return 0;
}

Measured memory_bytes: 3096
#include <stdio.h>

int main(void)
{
	int a[100][100], b[100][100];
	unsigned long long int c[100][100];
	int n, m, l;
	int i, j, k;

	scanf("%d %d %d", &n, &m, &l);
	for(i = 0;i < n;i++)
		for(j = 0;j < m;j++)
			scanf("%d", &a[i][j]);
	for(i = 0;i < m;i++)
		for(j = 0;j < l;j++)
			scanf("%d", &b[i][j]);
	for(i = 0;i < n;i++)
	{
		for(j = 0;j < l;j++)
		{
			c[i][j] = 0;
			for(k = 0;k < m;k++)
				c[i][j] += a[i][k] * b[k][j];
		}
	}
	for(i = 0;i < n;i++)
	{
		for(j = 0;j < l;j++)
		{
			if(j < l - 1)
				printf("%lld ", c[i][j]);
			else
				printf("%lld\n", c[i][j]);
		}
	}

	return 0;
}

Measured memory_bytes: 756
import math
def resolve():
    n, d = list(map(int, input().split()))
    x = [list(map(int, input().split())) for _ in range(n)]
    ans = 0
    for i in range(n):
        for j in range(i+1, n):
            d = math.sqrt(sum([(y-z)**2 for y,z in zip(x[i],x[j])]))
            if d.is_integer():
                ans += 1
    print(ans)
resolve()

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

int dp[50][(1 << 17) + 5];

int main() {
	int n, X, Y, Z;
	cin >> n >> X >> Y >> Z;
  
	int b = (1 << Z - 1) | (1 << Y + Z - 1) | (1 << X + Y + Z - 1);
  
	dp[0][0] = 1;
  
	for(int i = 0; i < n; ++i) {
		for(int j = 1; j < 11; ++j) {
			for(int S = 0; S < 1 << 17; ++S) {
				int a = (S << j | 1 << j - 1) & ((1 << 17) - 1);
				if((a & b) != b) {
					dp[i + 1][a] = (dp[i + 1][a] + dp[i][S]) % 1000000007;
				}
			}
		}
	}
	int ans = 1;
	for(int i = 0; i < n; ++i) {
		ans = 1LL * ans * 10 % 1000000007;
	}
	for(int S = 0; S < 1 << 17; ++S) {
		ans = (ans - dp[n][S] + 1000000007) % 1000000007;
	}
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 22272
from functools import reduce
class comb_mod:
    mod = 1000000007
    MAX = 10 ** 5
    fac = [0 for i in range(MAX)]
    finv = [0 for i in range(MAX)]
    inv = [0 for i in range(MAX)]

    def __init__(self):
        self.fac[0], self.fac[1] = 1, 1
        self.finv[0], self.finv[1] = 1, 1
        self.inv[1] = 1
        for i in range(2, self.MAX):
            self.fac[i] = self.fac[i - 1] * i % self.mod
            self.inv[i] = self.mod - self.inv[self.mod % i] * (self.mod // i) % self.mod
            self.finv[i] = self.finv[i - 1] * self.inv[i] % self.mod
    def combination(self, n, r):
        if n < r:
            return 0
        if n < 0 or r < 0:
            return 0
        return self.fac[n] * (self.finv[r] * self.finv[n - r] % self.mod) % self.mod
    def combination_mul(self, N, R):
        return reduce(lambda x, y: x * self.combination(y[0], y[1]) % self.mod, zip(N, R), 1)

def main():
    C = comb_mod()
    n, k = list(map(int, input().split()))
    for i in range(1, k + 1):
        N = [k - 1, n - k + 1]
        R = [i - 1, i]
        print(C.combination_mul(N, R))


if __name__ == '__main__':
    main()


Measured memory_bytes: 17220
#include<map>
#include<bitset>
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<stack>
#define REP(i,x,y) for(ll i=x;i<=y;i++)
typedef long long ll;
using namespace std;
ll const MAX = 100005;

vector<ll> a;
vector<ll> b;
int main() {
	ll n,k;
	cin >> n >> k;
	a.push_back(0);
	b.push_back(0);
	REP(i, 1, n) {
		ll p;
		cin >> p;
		if (p < 0) {
			a.push_back(-p);
		}
		else {
			b.push_back(p);
		}
	}
	sort(a.begin(), a.end());
	ll al = a.size();
	ll bl = b.size();
	al--; bl--;
	
	ll ans = 10000000000000000;
	if (al >= k) {
		ans = min(a[k], ans);

	}
	if (bl >= k) {
		ans = min(b[k], ans);
	}
	REP(i, 0, k) {
		ll j = k - i;
		if (i <= al && j <= bl) {
			ans = min({ ans, 2 * a[i] + b[j], 2 * b[j] + a[i] });
		}

	}
	cout << ans << endl;
}


Measured memory_bytes: 1656
#include <iostream>
#include <stdio.h>

using namespace std;

int main(){
   int m, f, r;
   int x=0;
   
   while(true){
     cin >> m >> f >> r;
     
     x= m+f;
     
     if(m+f+r == -1*3){ break; }
     else if(m==-1 || f==-1){
         cout << "F";
     } else if(x>=80){
         cout << "A";
     } else if(x>=65){
         cout << "B";
     } else if(x>=50){
         cout << "C";
     } else if(x>=30){
         if(r>=50){ cout << "C"; }
         else{ cout << "D";}
     } else {
         cout << "F";
     }
     
     cout << endl;
   }
   
   return 0;
}


Measured memory_bytes: 3088
#include<bits/stdc++.h>
using namespace std;
 
int main(){
    int x,y,z,w;

    cin>>x>>y>>z>>w;
    for(int i=x;i<z;i++){
        cout<<'R';
    }
    for(int i=y;i<w;i++) cout<<'U';

    for(int i=x;i<z;i++){
        cout<<'L';
    }
    for(int i=y;i<=w;i++) cout<<'D';

    for(int i=x;i<=z;i++){
        cout<<'R';
    }
    for(int i=y;i<=w;i++) cout<<'U';
    cout<<'L';
    cout<<'U';
    for(int i=x;i<=z;i++){
        cout<<'L';
    }
    for(int i=y;i<=w;i++) cout<<'D';
    cout<<'R';



}

Measured memory_bytes: 256
// Sakhiya07 - Yagnik Sakhiya
 
#include <bits/stdc++.h>
using namespace std;
 
#define ll  long long int
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define bp __builtin_popcountll
#define MOD 1000000007
 
#define FAST ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);srand(time(NULL));
 
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
const int N = 1e5 + 5;
int main() 
{
    FAST;
    ll n;
    cin >> n;
    ll a[n],sum = 0;
    for(ll i=0;i<n;i++)   cin >> a[i],sum+=a[i];
    cout<<sum-n;
}    

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int M1;
	int D1;
	int M2;
	int D2;
	cin >> M1 >> D1;
	cin >> M2 >> D2;
	
	if(M1==M2 && D1+1==D2){
		cout << 0 << endl;
	} else if(M1!=M2){
		cout << 1 << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <math.h>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <unordered_map>
#include <bitset>
#include <array>

using namespace std;

typedef long long ll;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	ll a, b;
	cin >> a >> b;
	cout << a*b/__gcd(a, b) << '\n';
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int count = sc.nextInt();
		int[] values = new int[count];
		int[] costs = new int[count];
		for (int i = 0; i < count; i++) {
			values[i] = sc.nextInt();
		}
		for (int i = 0; i < count; i++) {
			costs[i] = sc.nextInt();
		}
		sc.close();
		int answer = 0;
		for (int i = 0; i < count; i++) {
			if (values[i] > costs[i]) {
				answer += values[i] - costs[i];
			}
		}
		System.out.println(answer);
	}
}

Measured memory_bytes: 21332
def main():
	S = list(str(input()))
	LenP = 3
	ans = 0
	for i in range(2**LenP):
		P = ["-"]*LenP
		for j in range(LenP):
			if i >> j & 1:
				P[j] = "+"
		Res = [None] * (len(S)+len(P))
		Res[1::2],Res[::2] = P,S
		ResEval = "".join(Res)
		if eval(ResEval) == 7:
			ans = ResEval+"=7"
			print(ans)
			break

if __name__ == '__main__':
	main()

Measured memory_bytes: 9004
#![allow(non_snake_case)]

use std::io::{stdin, Read};
use std::str::FromStr;
fn read_option<T: FromStr>() -> Option<T> {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok()
}
fn read<T: FromStr>() -> T {
    let opt = read_option();
    opt.expect("failed to parse token")
}

fn main() {
    let N: usize = read();
    let mut seq = 0;
    for _ in 0..N {
        let a: usize = read();
        let b: usize = read();
        if a == b {
            seq += 1;
        } else {
            seq = 0;
        }
        if seq == 3 {
            println!("Yes");
            return;
        }
    }
    println!("No");
}


Measured memory_bytes: 2168
#include <stdio.h>
#include <string.h>

int main() {
  int x, top = 0, stack[100];
  char s[100];

  while(scanf("%s", s) != EOF) {
    if(s[0] == '+') {
      stack[top-2] += stack[top-1];
      top--;
    } else if(s[0] == '-') {
      stack[top-2] -= stack[top-1];
      top--;
    } else if(s[0] == '*') {
      stack[top-2] *= stack[top-1];
      top--;
    } else {
      x = atoi(s);
      stack[top++] = x;
    }
  }
  printf("%d\n", stack[0]);
  return 0;
}



Measured memory_bytes: 1972
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
       Scanner sc = new Scanner(System.in);
 
		int n = Integer.parseInt(sc.next());
		String s = sc.next();
	int cnt = 1;
	
	if(n > 1){
    	for(int i=1; i<n; i++){
	        if(s.charAt(i) != s.charAt(i-1)){
	            cnt++;
	        }
	    }
	}
	
		System.out.println(cnt);
		sc.close();
    }
}

Measured memory_bytes: 24764
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#define _GLIBCXX_DEBUG
#define INF 100000010
 #define PI 3.14159265359

using namespace std;
const int64_t mod = 1000000007;
const int64_t tmpMod = 998244353;

int main() {
 
  //int64_t N;
  string N;
  cin>>N;
  if(N=="SSS")cout<<0<<endl;
  else if(N=="RSS")cout<<1<<endl;
    else if(N=="SRS")cout<<1<<endl;
    else if(N=="SSR")cout<<1<<endl;
    else if(N=="RSR")cout<<1<<endl;
    else if(N=="RRS")cout<<2<<endl;
    else if(N=="SRR")cout<<2<<endl;
    else if(N=="RRR")cout<<3<<endl;
  //vector<int64_t> A(N);
  //for(int i=0; i<N; i++){cin>>A[i];}
  //vector<vector<int> > A(N,vector<int>(M));
  //for(int i=0; i<N; i++){
  //   for(int j=0; j<M; j++){
  //       cin>>A[i][j];
  //   }
  // }
  //sort(A.begin(),A.end());
  //for (int i = 0; i < N; i++) { maximum = max(maximum , A[i]);}
  //for (int i = 0; i < N; i++) { minimum = min(minimum , A[i]);}
  
}

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

int main() {
	int n;
	cin >> n;
	long long v[100000];
	int ans = 0, s = 0;
	for (int i = 0;i < n;i++)cin >> v[i];
	sort(v, v + n);
	while (s < n) {
		int aa = v[s], p = 0;
		while (s < n&&aa == v[s]) {
			p++;
			s++;
		}
		ans += p % 2;
	}
	cout << ans << endl;
}

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

int main() {
	int h, w; cin >> h >> w;
	char a[105][105];
	char b[105][105];

	for (int y = 0; y < h; y++) {
		scanf("%s", a[y]);
	}

	for (int y = 0; y < h + 2; y++) {
		for (int x = 0; x < w + 2; x++) {
			b[y][x] = '#';
		}
	}

	for (int y = 0; y < h; y++) {
		for (int x = 0; x < w; x++) {
			b[y+1][x+1] = a[y][x];
		}
	}

	for (int y = 0; y < h+2; y++) {
		for (int x = 0; x < w+2; x++) {
			cout << b[y][x];
		}
		cout << endl;
	}

	return 0;
}

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

int main() {
  
  ll n;
  cin >> n;
  
  ll m = n;
  ll c = 0;

  while(1) {
    m -= 1; 
    m /= 26;
    c++; 
    if (m < 1)break;
  }
  
  ll a = 1;
  REP(i,c) {
    n -= a;
    a *= 26;
  }
  
  vector<char> s(c);
  REP(i,c) {
    s[c-i-1] =  'a' + n % 26;
    n /= 26;
  }
     
  REP(i,c) cout << s[i];

}


Measured memory_bytes: 3600
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double LD;
using namespace std;
const int INF = 2147483647;
const int INF2 = 0x3f3f3f3f;
const ll INF64 = 3e18;
const double INFD = 1e30;
const double EPS = 1e-10;
const double PI = acos(-1);
const int MOD = 1e9 + 7;
template <typename T>
inline T read() {
    T X = 0, w = 0;
    char ch = 0;
    while (!isdigit(ch)) {
        w |= ch == '-';
        ch = getchar();
    }
    while (isdigit(ch)) X = (X << 3) + (X << 1) + (ch ^ 48), ch = getchar();
    return w ? -X : X;
}
const int MAXN = 200005;
const int MAXV = 3;
int n, m, k;
int dr[4] = {1, 0, -1, 0};
int dc[4] = {0, 1, 0, -1};
int dr2[8] = {1, 1, 1, -1, -1, -1, 0, 0};
int dc2[8] = {1, 0, -1, 1, 0, -1, 1, -1};
int CASE = 1;

int main() {
#ifdef LOCALLL
    freopen("in", "r", stdin);
    freopen("out", "w", stdout);
#endif
    scanf("%d", &n);
    vector<pair<int, int>> edges;
    for (int i = 0; i < n - 1; i++) {
        int u = read<int>(), v = read<int>();
        edges.push_back({u, v});
    }
    ll ans = 0;
    for (int i = 1; i <= n; i++) {
        ans += (ll)i * (i + 1) / 2;
    }
    for (auto e : edges) {
        int u = e.first, v = e.second;
        if (u > v) swap(u, v);
        ans -= (ll)u * (n - v + 1);
    }
    printf("%lld", ans);
    return 0;
}


Measured memory_bytes: 5384
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)   for(signed i=0; i<n; i++)
#define yn(b)   cout << ((b)?"Yes":"No") << endl
#define YN(b)   cout << ((b)?"YES":"No") << endl
#define pr(r)   cout << r << endl
#define min(x,y)    (x<y)?x:y
#define ll  long long

int main(void){
    string s;
    cin >> s;
    int i;
    rep(i, s.length()){
        if(i%2==0){
            cout << s.at(i);
        }
    }
    cout << endl;
}

Measured memory_bytes: 512
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<functional>
#include<map>
#include<cstdlib>
#include<complex>
#include<numeric>
#include<set>
#include<deque>
#include<queue>

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

template<int Modulo = MOD> struct Mint {
	Int val;
	constexpr Mint(Int v = 0) noexcept : val(v% Modulo) {
		if (val < 0) v += Modulo;
	}
	constexpr int getmod() { return Modulo; }
	constexpr Mint operator - () const noexcept { return val ? Modulo - val : 0; }
	constexpr Mint operator + (const Mint& r) const noexcept { return Mint(*this) += r; }
	constexpr Mint operator - (const Mint& r) const noexcept { return Mint(*this) -= r; }
	constexpr Mint operator * (const Mint& r) const noexcept { return Mint(*this) *= r; }
	constexpr Mint operator / (const Mint& r) const noexcept { return Mint(*this) /= r; }
	constexpr Mint& operator += (const Mint& r) noexcept {
		val += r.val;
		if (val >= Modulo) val -= Modulo;
		return *this;
	}
	constexpr Mint& operator -= (const Mint& r) noexcept {
		val -= r.val;
		if (val < 0) val += Modulo;
		return *this;
	}
	constexpr Mint& operator *= (const Mint& r) noexcept {
		val = val * r.val % Modulo;
		return *this;
	}
	constexpr Mint& operator /= (const Mint& r) noexcept {
		Int a = r.val, b = Modulo, u = 1, v = 0;
		while (b) {
			Int t = a / b;
			a -= t * b; swap(a, b);
			u -= t * v; swap(u, v);
		}
		val = val * u % Modulo;
		if (val < 0) val += Modulo;
		return *this;
	}
	constexpr bool operator == (const Mint& r) const noexcept {
		return this->val == r.val;
	}
	constexpr bool operator != (const Mint& r) const noexcept {
		return this->val != r.val;
	}
	friend ostream& operator << (ostream& os, const Mint<Modulo>& x) noexcept {
		return os << x.val;
	}
	friend istream& operator >> (istream& is, Mint<Modulo>& x) noexcept {
		Int tmp; is >> tmp;
		x = Mint<Modulo>(tmp);
		return is;
	}
	friend constexpr Mint<Modulo> modpow(const Mint<Modulo>& a, Int n) noexcept {
		Mint res(1), tmp = a;
		while (n > 0) {
			if (n & 1) res *= tmp;
			tmp *= tmp;
			n >>= 1;
		}
		return res;
	}
};

using mint = Mint<>;

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	Int N;
	cin >> N;

	map<Int, Int> dist;
	Int D;
	for (Int i = 0; i < N; i++) {
		cin >> D;
		if (i == 0 && D != 0) {
			cout << 0 << "\n";
			return 0;
		}
		dist[D]++;
	}

	
	mint ans = 1;
	Int dis;
	Int dis_be;
	Int cnt;
	Int cnt_be;
	for (auto itr = dist.begin(); itr != dist.end(); itr++) {
		dis = itr->first;
		cnt = itr->second;
		if (dis == 0) {
			dis_be = 0;
			if (cnt != 1) {
				cout << 0 << "\n";
				return 0;
			}
			continue;
		}
		if (dis == 1) {
			dis_be = 1;
			cnt_be = itr->second;
			continue;
		}

		if (dis != dis_be + 1) {
			cout << 0 << "\n";
			return 0;
		}

		for (Int i = 0; i < cnt; i++) {
			ans *= cnt_be;
		}
		cnt_be = cnt;
		dis_be = dis;
	}


	cout << ans << "\n";
}


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

#define vvi             vector<vector<int>>
#define ld              long double
#define mod             1000000007
#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vpii            vector<pair<int,int>>
#define fr(i,a,b)       for(int i = a; i < b; i += 1)
#define all(x)          x.begin(),x.end()
#define sz(a)           (int)(a.size())
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define pw(b,p)         pow(b,p) + 0.1
#define input(a)        for(auto it = a.begin(); it != a.end(); it++) { int value; cin >> value; *it = value;}
//#define print(a)        for(auto it = a.begin() ; it != a.end() ; it++){ cout << *it << " " ;}cout << '\n';
#define SS                      stringstream
#define db(...)                 __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...);
}

const int dirx[4] = {0, 0, -1, 1};
const int diry[4] = {-1, 1, 0, 0};

// 0 -> l, 1 - > r, 2 -> u , 3 -> down
void FASTIO()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}

int power(int x, int y, int p) 
{ 
    int res = 1;      // Initialize result 
 
    x = x % p;  // Update x if it is more than or 
                // equal to p 
 
    while (y > 0) 
    { 
        // If y is odd, multiply x with result 
        if (y & 1) 
            res = (res*x) % p; 
 
        // y must be even now 
        y = y>>1; // y = y/2 
        x = (x*x) % p; 
    } 
    return res; 
} 
 
// Returns n^(-1) mod p 
int modInverse(int n, int p) 
{ 
    return power(n, p-2, p); 
} 

const int mxN = 1e6 + 10;
// int a[mxN];
// int t[mxN], y[mxN], z[mxN];
// int ans;
// int n, m;
// vi v;

void test_case()
{
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	cout << max({a*c, a*d, b*c, b*d}) << '\n';
}   


int32_t main()
{
    FASTIO();

    int t;
    t = 1;
    //cin >> t;

    for(int i = 1; i <= t; i++)
    {
        //cout << "Case #" << i << ": ";
        test_case();
    }
    return 0;
} 


Measured memory_bytes: 3652
void main() {
    double[] ab = readln.split.to!(double[]);
    ceil(ab.sum/ab.length).writeln;
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.container;
import std.typecons;
import std.ascii;
import std.uni;

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

#define int long long
using ll = long long;
using ld = long double;
using intpair = pair<int, int>;
const int MOD = 1e9 + 7;
inline int mod (ll a, int m = MOD) { return (a % m + m) % m; }
struct Fast {Fast(){cin.tie(0);ios::sync_with_stdio(0);}} fast;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define ceiv(a, b) ((ll)((a) + (b) - 1)/(ll)(b))


string convert_radix(ll n, int radix = 26){
    if(n <= 0) return "";
    string ret = "";
    do{
        int modulo = n % 26;
        int rest = n / 26;
        
        if(modulo == 0){
            modulo = 26;
            rest--;
        }
        
        ret.push_back('a' + modulo - 1);
        n = rest;
    }while(n > 26);
    
    ret.push_back('a' + n - 1);
    reverse(ALL(ret));
    return ret;
}

signed main(){
    ll n; cin >> n;
    string s = convert_radix(n);
    for(char c: s){
        if(c < 'a' || 'z' < c) continue;
        cout << c;
    }
    cout << endl;
}

Measured memory_bytes: 3640
n, a, b, c, d = map(int, input().split())
s = input()
for i in range(a, max(c, d)):
  if s[i-1: i+1] == "##":
    print("No")
    exit()

if c < d:
  print("Yes")
  exit()
for i in range(b-1, d):
  if s[i-1:i+2] == "...":
    print("Yes")
    exit()
print("No")


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

const int mod = 1000000007;

int main(){
    long long N,K;
    cin >> N >> K;
    
    long long A[2001];
    rep(i,N){
        cin >> A[i];
    }
    
    long long ans = 0;
    rep(i,N){
        long long cnt1 = 0;
        long long cnt2 = 0;
        rep(j,i){
            if(A[j] > A[i]) cnt1++;
        }
        rep(j,N){
            if(A[j] > A[i]) cnt2++;
        }
        ans+=cnt1*K+(cnt2%mod)*((K*(K-1)/2)%mod);
        ans%=mod;
        
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 256
import java.io.PrintWriter

val pw = PrintWriter(System.out)

fun main(args : Array<String>) {
    func()
    pw.flush()
}

fun func() {
    val (n, k) = listOfInt()
    println(if (n % k == 0) 0 else 1)
}

fun next() = readLine()!!
fun listOfString() = next().split(" ")
fun listOfInt()= listOfString().map { it.toInt() }

fun println(value : Any) {
    pw.println(value)
}

Measured memory_bytes: 37816
A, B, M = map(int, input().split())
As = list(map(int, input().split()))
Bs = list(map(int, input().split()))
min_p = min(As)+min(Bs)
for i in range(M):
  a, b, m = map(int, input().split())
  min_p = min(As[a-1]+Bs[b-1]-m,  min_p)
print(min_p)

Measured memory_bytes: 70892
#pragma GCC optimize("Ofast,fast-math,unroll-loops")
  
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
  
#define int ll
//#define double long double
#define endl '\n'
#define all(C) (C).begin(), (C).end()
#define rall(C) (C).rbegin(), (C).rend()
#define mp make_pair 
#define pb emplace_back
#define dbg(x) cerr << #x << " : " << x << endl
//#define PI 3.141592653589
  
using namespace std;
//using namespace __gnu_pbds;
         
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair <int, int>;
using pll = pair <ll, ll>;
using pld = pair <ld, ld>;
 
/*
const ll MAX_MEM = 5e8;
char MEM[MAX_MEM];
ll MEM_POS = 0;
void* operator new(size_t x)
{
    auto ret = MEM + MEM_POS;
    MEM_POS += x;
    assert(MEM_POS < MAX_MEM);
    return ret;
}
void operator delete(void*)
{}
 
*/
 
template <class T>
istream& operator>> (istream &in, vector <T> &a)
{
    for (auto &i : a)
        in >> i;
    return in;
}
         
template <class T> 
ostream& operator<< (ostream &out, vector <T> a)
{
    for (auto &i : a)
        out << i << ' ';
    return out;
}
         
template <class T, class U>
istream& operator>> (istream &in, pair <T, U> &p)
{
    in >> p.first >> p.second;
    return in;
}
         
template <class T, class U>
ostream& operator<< (ostream &out, pair <T, U> p)
{
    out << p.first << " " << p.second << " ";
    return out;
}
         
inline void Start()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    //freopen("circlecover.in", "r", stdin);
    //freopen("circlecover.out", "w", stdout);
}

signed main()
{
    Start();
    int n, l;
    cin >> n >> l;
    vector <int> a(n);
    cin >> a;
    int j = n - 1;
    vector <int> ans;
    int cur = 0;
    for (auto &i : a)
        cur += i;
    while (j > 0 && a[j] + a[j - 1] < l && cur >= l)
    {
        cur -= a[j];
        ans.pb(j);
        --j;
    }
    if (j == 0)
    {
        cout << "Possible\n";
        for (auto &i : ans)
            cout << i << endl;
        return 0;
    }
    if (a[j] + a[j - 1] < l)
    {
        cout << "Impossible";
        return 0;
    }
    for (int i = 0; i + 1 <= j; ++i)
    {
        if (cur >= l)
        {
            ans.pb(i + 1);
            cur -= a[i];
        }
        else
        {
            cout << "Impossible";
            return 0;
        }
    }
    cout << "Possible\n";
    for (auto &i : ans)
        cout << i << endl;
    return 0;
}



Measured memory_bytes: 2548
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int V, E; cin >> V >> E;
	vector<vector<int>>G(V, vector<int>(V, INF));
	rep(i, 0, E) {
		int s, t, d; cin >> s >> t >> d;
		G[s][t] = d;
	}
	vector<vector<int>>dp(1 << V, vector<int>(V, INF));
	dp[(1 << V) - 1][0] = 0;
	for(int bits=(1<<V)-1;bits>=0;bits--){
		rep(i, 0, V)rep(j, 0, V) {
			if (!(bits&(1 << j)))
				chmin(dp[bits][i], dp[bits ^ (1 << j)][j] + G[i][j]);
		}
	}
	cout << (dp[0][0] == INF ? -1 : dp[0][0] )<< endl;
	return 0;
}

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

using namespace std;

const long long maxi=1e16+951;

long long a[1000],b[1000];
long long ans;
int n;
int main()
{
    cin>>n;

    for (int i=1;i<=n;i++)
        cin>>a[i];

    sort(a+1,a+n+1);
    reverse(a+1,a+n+1);

   for (long long i=1;i<n;i++)
   {
       long long l=0;
       long long r=1e16+1000;

        sort(a+1,a+n+1);
        reverse(a+1,a+n+1);

        if (a[1]<=n*n) break;

        while(l<r-1)
        {
            long long tr=(l+r)/2;
            long long cel=tr/i;

            for (int j=1;j<=n;j++)
                b[j]=a[j];

            for (int j=1;j<=i;j++)
                b[j]-=cel*(n+1-i);

            b[i+1]+=tr;

            for(long long j=1;j<=tr-cel*i;j++)
            {
                sort(b+1,b+i+1);
                reverse(b+1,b+i+1);

                b[1]-=n;
                for (int k=2;k<=i;k++)
                    b[k]++;

            }

               sort(b+1,b+i+1);
               reverse(b+1,b+i+1);

            if (b[i+1]<=b[1]) l=tr; else r=tr;
        }
        ans+=l+1;

        long long cel=(l+1)/i;

            for (int j=1;j<=i;j++)
                a[j]-=cel*(n+1-i);

            for(long long j=1;j<=(l+1)-cel*i;j++)
            {
                sort(a+1,a+i+1);
                reverse(a+1,a+i+1);

                a[1]-=n;
                for (int k=2;k<=i;k++)
                    a[k]++;

            }

        for (int j=i+1;j<=n;j++)
            a[j]+=l+1;
   }



   sort(a+1,a+n+1);
   reverse(a+1,a+n+1);

   ans+=n*max(a[n]-(n-1),0ll);

   for (int i=1;i<=n;i++)
    a[i]-=max(a[n]-(n-1),0ll);

   while(a[1]>=n)
   {
       a[1]-=n;
       for(int i=2;i<=n;i++)
        a[i]++;

       sort(a+1,a+n+1);
       reverse(a+1,a+n+1);
       ans++;
   }
   cout<<ans;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 1000000007
#define rep(i, N) for(ll i = 0; i < N; i++)
#define rep2(i, j, k) for(ll i = j; i < k; i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define print(x) cout << x << "\n"
#define print2(x, y) cout << x << " " << y << "\n"
#define printv(vec) rep(lp, vec.size()) cout << vec[lp] << " "; print(""); 
#define ALL(v) v.begin(), v.end()
#define SUM(v) accumulate(ALL(v), 0)
#define MAX(v) *max_element(ALL(v))
#define MIN(v) *min_element(ALL(v))
#define SORT(v) sort(ALL(v))
#define REV(v) reverse(ALL(v))
typedef long long ll;
using namespace std;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vs = vector<string>;

const int mod = 1000000007;
class mint {
public:
    ll x;
    mint(ll x = 0) : x((x % mod + mod) % mod) {}
    mint operator-() const { 
      return mint(-x);
    }
    mint& operator+=(const mint& a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint& a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const  mint& a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint& a) const {
        mint res(*this);
        return res += a;
    }
    mint operator-(const mint& a) const {
        mint res(*this);
        return res -= a;
    }
    mint operator*(const mint& a) const {
        mint res(*this);
        return res *= a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }
    mint inv() const {
        return pow(mod - 2);
    }
    mint& operator/=(const mint& a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint& a) const {
        mint res(*this);
        return res /= a;
    }
    friend ostream& operator<<(ostream& os, const mint& m){
        os << m.x;
        return os;
    }
};

ll modpow(ll a, ll n){
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

void Main(){

	ll N;
	cin >> N;
	ll ans = 0;
	rep(i, N + 1) if(i % 3 && i % 5) ans += i;
	print(ans);
	
}

int main(){
	
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	Main();
	return 0;
	
}





Measured memory_bytes: 3548
import java.util.Scanner;

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

		int MAX = 100;

		for (int posY = 0; posY <= MAX; posY++) {
			for (int posX = 0; posX <= MAX; posX++) {

				int needH = -1;

				for (int i = 0; i < n; i++) {
					if(h[i] > 0) {
						int tmp = h[i] + Math.abs(x[i] - posX) + Math.abs(y[i] - posY);
						if(needH == -1) {
							needH = tmp;
						} else if(needH != tmp) {
							needH = -2;
							break;
						}
					}
				}
				if(needH == -2) continue;

				for (int i = 0; i < n; i++) {
					int dist = 0;
					if(h[i] == 0) {
						dist = Math.abs(x[i] - posX) + Math.abs(y[i] - posY);
						if(needH > dist) {
							needH = -2;
							break;
						}
					}
				}
				if(needH == -2) continue;

				System.out.println(posX + " " + posY + " " + needH);
				return;
			}
		}
	}
}

Measured memory_bytes: 22868
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;


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

	string s, t;
	cin >> s >> t;
	sort(s.begin(), s.end());
	sort(t.rbegin(), t.rend());

	if (s < t) cout << "Yes\n";
	else cout << "No\n";

	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<string>
using namespace std;
char a[200],b[200];
bool amp(char x,char y){
	if(x<y) return x>y;
}
int main(){
	int len1,len2,ans,dis;
	while(~scanf("%s%s",a+1,b+1)){
		dis=0;
		len1=strlen(a+1);
		len2=strlen(b+1);
		sort(a+1,a+len1+1);
		sort(b+1,b+len2+1,amp);
		for(int i=1;i<=min(len1,len2);i++){
			if(a[i]<b[i]){
				ans=1;
				break;
			}
			else if(a[i]>b[i]){
				ans=0;
				break;
			}
			else ans=-1;
			if(ans==-1&&i==min(len1,len2)&&len1<len2) dis=1;
		}
		if(ans==1||dis==1) printf("Yes\n");
		else printf("No\n");
	}
}

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

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

typedef long long LL;

vector<int> seg;
int N;

int kosu(int x){
  x+=N-1;
  int ans=seg[x];
  while(x>0){
    x=(x-1)/2;
    ans+=seg[x];
  }
  return ans;
}

void update(int a,int b, int k=0, int l=0, int r=-1){
  if(r<0) r=N;
  if(r<=a||b<=l) return;
  if(a<=l&&r<=b) {
    seg[k]++;
    return;
  }
  update(a,b,2*k+1,l,(l+r)/2);
  update(a,b,2*k+2,(l+r)/2,r);
  return;
}

struct t{
  int d;
  int num;
  bool operator<(const struct t &r) const{
    return d<r.d;
  }
};

int main(){
  int n,m;
  cin >> n >> m;
  vector<int> kl(n,0),kr(n,0);
  vector<struct t> k(n);
  for(int i=0;i<n;i++){
    cin >> kl[i] >> kr[i];
    k[i]={kr[i]-kl[i]+1,i};
  }
  sort(k.begin(),k.end());
  // for(int i=0;i<n;i++) cout << k[i].d << endl;
  N=1;
  while(N<m+1) N*=2;
  seg=vector<int>(2*N-1,0);
  int now=0;
  int ans=0;
  for(int i=1;i<=m;i++){
    for(;now<n&&i>k[now].d;now++){
      update(kl[k[now].num],kr[k[now].num]+1);
    }
    ans=n-now;
    for(int j=0;j<=m;j+=i){
      ans+=kosu(j);
    }
    // for(int j=0;j<=m;j++){
    //   cout << kosu(j) <<" ";
    // }
    // cout << endl;
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 6656
#include <iostream>
using namespace std;
int main()
{
	int N; cin >> N ;
	int a[201][3]; int ans[201]={0};
	int num[3][101]={0};
	for(int i=1;i<=N;i++)
	{
		cin >> a[i][0] >> a[i][1] >> a[i][2] ;
		for(int j=0;j<3;j++) num[j][a[i][j]]++;
	}
	for(int i=1;i<=N;i++)
	{
		for(int j=0;j<3;j++)
		if(num[j][a[i][j]]==1) ans[i]+=a[i][j];
	}
	for(int i=1;i<=N;i++)
	cout << ans[i] << '\n' ;
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
#define rep(i, k) for(int i = 0; i < k; i++)
using namespace std;
int main() {
    string s;
    cin >> s;
    int n = (int)s.size();
    if(n % 2 == 0) {
        rep(i, n / 2) {
            if(s[i * 2 + 1] == 'R') {
                cout << "No";
                return 0;
            }
        }
        rep(i, n / 2) {
            if(s[i * 2] == 'L') {
                cout << "No";
                return 0;
            }
        }
    } else {
        rep(i, n / 2) {
            if(s[i * 2 + 1] == 'R') {
                cout << "No";
                return 0;
            }
        }
        rep(i, n / 2 + 1) {
            if(s[i * 2] == 'L') {
                cout << "No";
                return 0;
            }
        }
    }

    cout << "Yes";
    return 0;
}

Measured memory_bytes: 256
n,a,b = gets.chomp.split(" ").map(&:to_i)
x_arr = gets.chomp.split(" ").map(&:to_i)

result = 0
x_arr.each_cons(2) do |x1, x2|
  tmp = (x2 - x1) * a
  if tmp > b
    result += b
  else
    result += tmp
  end
end

puts result

Measured memory_bytes: 21668
# 2019/04/07
# AtCoder Beginner Contest 106 - B

# Input
n = int(input())

# Calc
ans = 0
for i in range(1, n+1, 2):
    cnt = 0 
    for j in range(1, i+1, 1):
        if (i % j) == 0:
            cnt += 1
    if cnt == 8:
        ans += 1

# Output
print(ans)

Measured memory_bytes: 2940
#include <bits/stdc++.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstring>
#include <complex>
#include <chrono>
#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 f first
#define s second

using namespace std;
const int MX = 100010;			// maximum no. of nodes in graph
vector<bool> visited(MX+1,0);
int n;
vector< vector<int> > G(MX+1);		// adjacency list, (edge,cost) pair
vi indegree(MX+1);
vi dist(MX+1);


void dfs(int src)
{
  visited[src]=1;
  for(auto a:G[src])
  {
    if(!visited[a])
    {
      --indegree[a];
      dist[a]=max(dist[a],1+dist[src]);
    }
    if(indegree[a]==0)
      dfs(a);
  }
}
int main()
{
  int m;					// no. of edges

  cin>>n>>m;
  for(int i = 1 ; i <= m ; i++)
  {
    int u,v;
    cin>>u>>v;			// 1 based indexing of nodes

    G[u].eb(v);
    indegree[v]++;
  }

  for(int i=1;i<=n;i++) if(!visited[i] && indegree[i]==0) dfs(i);

  int mxd=0;
  mxd=*max_element(dist.begin()+1,dist.begin()+n+1);
  cout << mxd<<endl;
}


Measured memory_bytes: 11136