akhauriyash/Code-Regression huggingface dataset:
//
//  main.cpp
//  ABC158D
//
#include <iostream>
#include<string>
#include<algorithm> // reverse
using namespace std;
int main(int argc, const char * argv[]) {
    string S,TMP;
    string L;
    string R;
    cin>>S;
    int Q;
    cin >> Q;
    int T;
    int F;
    string C;
    int direction=0;
    int num=0;
    for (int i=0; i<Q; i++) {
        cin>>T;
        if (T==1) {
            direction++;
            direction=direction%2;
            num++;
            TMP=R;
            R=L;
            L=TMP;
        }
        if (T==2) {
            cin>>F;
            cin>>C;
            if (F==1) {
                L=L+C;
            }
            if(F==2){
                R=R+C;
            }
        }
    }
    reverse(L.begin(), L.end());
    if (num%2==1) {
        reverse(S.begin(), S.end());
    }
    cout<<L<<S<<R<<endl;
    return 0;
}


Measured memory_bytes: 1456
from collections import defaultdict,deque
import math
def gcd(a,b):
    return b if not a%b else gcd(b,a%b)
def lcm(a,b):
    return (a*b)//gcd(a,b)
def prepare(n, MOD):
    # 1! - n! の計算
    f = 1
    factorials = [1]  # 0!の分
    for m in range(1, n + 1):
        f *= m
        f %= MOD
        factorials.append(f)
    # n!^-1 の計算
    inv = pow(f, MOD - 2, MOD)
    # n!^-1 - 1!^-1 の計算
    invs = [1] * (n + 1)
    invs[n] = inv
    for m in range(n, 1, -1):
        inv *= m
        inv %= MOD
        invs[m - 1] = inv

    return factorials, invs
    #nCr = (factorials[n]%MOD * invs[r]%MOD * invs[n-r]%MOD)%MOD
def main():
    n,m,k=map(int, input().split())
    MOD = 10**9 + 7
    #k=2の場合nについて最大の差n-1は1通り、n-2は2通り・・・n-iはi通り(i<n)
    facs,invs = prepare(max(k,n*m),MOD)
    res = 0
    tmp = min(k,n)
    for i in range(1,n):
        res = res + ((n-i)*i*m*m)*(facs[n*m-2]%MOD * invs[k-2]%MOD * invs[n*m-2-(k-2)]%MOD)%MOD
        res%=MOD
    tmp = min(k,m)
    for i in range(1,m):
        res = res + ((m-i)*i*n*n)*(facs[n*m-2]%MOD * invs[k-2]%MOD * invs[n*m-2-(k-2)]%MOD)%MOD
        res%=MOD
    print(res)


if __name__ == '__main__':
    main()


Measured memory_bytes: 84964
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;


public class Program
{	
    public static void Main()
	{
	    int[] n = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
	    int N = n[0];
	    int H = n[1];
	    int W = n[2];
	    
	    int cnt = 0;
	    int A,B;
	    for(int i = 0 ; i < N ; i++)
	    {
	        n = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
	        A = n[0];
	        B = n[1];
	  
	        if(H <= A && W <= B)
	        {
	            cnt++;
	        }
	    }
	    
	    Console.WriteLine(cnt);
	}

}

Measured memory_bytes: 11220
#pragma region RegionDefs
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define reps(i,l,r) for(int i=(l),i##_len=(r);i<i##_len;++i)
#define all(x) begin(x),end(x)
using namespace std;
const int INF = 1e9;
template<class T=int> using V = vector<T>;
template<class T=int> using PQ = priority_queue<T>;
template<class T=int> using PQG = priority_queue<T, V<T>, greater<T>>;
typedef long long ll;
const ll MOD = 10e9+7LL;
void in() {}
template<class Head, class... Tail>
void in(Head&& head, Tail&&... tail)
{
    cin >> head;
    in(move(tail)...);
}
#define IN(...) ll __VA_ARGS__; in(__VA_ARGS__)
//時間が厳しいとき使う
#define INI(...) int __VA_ARGS__; in(__VA_ARGS__)
#define INS(T, ...) T __VA_ARGS__; in(__VA_ARGS__)
#define VIN(T, v, n) V<T> v(n); for(auto& _elem:v)cin>>_elem
template<class T>bool chmax(T &a, const T &b) {if (a<b) {a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b) {if (a>b) {a=b; return 1;} return 0;}
#define y0 y__0
#define y1 y__1
#define j0 j__0
#define j1 j__1
#define YN(e) cout << ((e) ? "YES" : "NO") << endl
#define yn(e) cout << ((e) ? "Yes" : "No") << endl
#pragma endregion RegionDefs

void solve()
{
    IN(n, m);
    VIN(ll, v, m);
    ll s = 0;
    rep(i, m)
    {
        s += v[i];
    }
    cout << max(n - s, -1LL) << endl;
}

int main()
{
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(numeric_limits<double>::max_digits10);

    solve();

    return 0;
}

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

int main() {
  string s,res;
  cin >> s;
  if(s[0] == s[1] && s[1] == s[2]) res = "Yes";
  else if(s[1] == s[2] && s[2] == s[3]) res = "Yes";
  else res = "No";
  cout << res;
}


Measured memory_bytes: 256
while True:
    n = int(input())
    if n == 0: break
    d = dict()
    order = []
    for _ in range(n):
        i, p, q = map(int, input().split())
        d[i] = d[i]+p*q if i in d else p*q
        if i not in order: order.append(i)
    b = True
    for o in order:
        if d[o] > 999999:
            print(o)
            b = False
    if b: print("NA")

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

int gcd(int a,int b){
    if(a%b==0){
        return b;
    }
    else{
        return gcd(b,a%b);
    }
}

int main(){
    long long int n,h=0,w=0;
    cin>>n;
    vector<long long int>a(200000);

    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    sort(a.begin(),a.end(),greater<>());
    for(int i=0;i<n-1;i++){
        if(h==0&&a[i]==a[i+1]){
            h=a[i];
            i++;
        }
        else if(a[i]==a[i+1]){
            w=a[i];
            break;
        }
    }
    cout<<h*w<<endl;
    return 0;
}

Measured memory_bytes: 1792
{-# LANGUAGE ScopedTypeVariables #-}

import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VUM
import Control.Monad
import Control.Monad.Primitive 

-- Union-Find
makeUF :: PrimMonad m => Int -> m ((VUM.MVector (PrimState m) Int), (VUM.MVector (PrimState m) Int))
makeUF n = do
    par <- VU.unsafeThaw $ VU.generate n id
    siz <- VUM.replicate n 1
    return (par, siz)

root :: PrimMonad m => Int -> VUM.MVector (PrimState m) Int -> m Int
root x par = do
    r <- VUM.read par x
    if x == r
        then return x
        else do
            newr <- root r par
            VUM.write par x newr
            return newr

same :: PrimMonad m => Int -> Int -> VUM.MVector (PrimState m) Int -> m Bool
same x y par = do
    rx <- root x par
    ry <- root y par
    return $ rx == ry

unite :: PrimMonad m => Int -> Int -> VUM.MVector (PrimState m) Int -> VUM.MVector (PrimState m) Int -> m ()
unite x y par siz = do
    x' <- root x par
    y' <- root y par
    sx <- VUM.read siz x'
    sy <- VUM.read siz y'
    unless (x' == y') $ 
        if sx < sy
            then do
                VUM.modify siz (+sx) y'
                VUM.write par x' y'
            else do
                VUM.modify siz (+sy) x'
                VUM.write par y' x'

size :: PrimMonad m => Int -> VUM.MVector (PrimState m) Int -> VUM.MVector (PrimState m) Int -> m Int
size x par siz = root x par >>= VUM.read siz
    
main = do
    [n,m,k] <- map read . words <$> getLine :: IO [Int]
    (par, siz) <- makeUF (n+1)
    (cnt :: VUM.IOVector Int) <- VUM.replicate (n+1) 0
    forM_ [1..m] $ \_ -> do
        [a,b] <- map read . words <$> getLine :: IO [Int]
        unite a b par siz
        VUM.modify cnt (+1) a
        VUM.modify cnt (+1) b
    forM_ [1..k] $ \_ -> do
        [c,d] <- map read . words <$> getLine :: IO [Int]
        branch <- same c d par
        when branch $ do
            VUM.modify cnt (+1) c
            VUM.modify cnt (+1) d
        
    forM_ [1..n] $ \i -> do
        s <- size i par siz
        c <- VUM.read cnt i
        putStr $ show (s - c - 1)
        putStr " "
    putStrLn ""

Measured memory_bytes: 4604
#include<bits/stdc++.h>
using namespace std;
long N,W,w[100],v[100],res;
map<long,long>dp;
int main(){
  cin>>N>>W;
  for(int i=0;i<N;i++)cin>>w[i]>>v[i];
  dp[0]=0;
  for(int i=0;i<N;i++){
    auto tmp=dp;
    for(auto p:tmp){
      auto x=p.first+w[i];
      auto y=p.second+v[i];
      if(x<=W)res=max(res,dp[x]=max(dp[x],y));
    }
  }
  cout<<res<<endl;
}


Measured memory_bytes: 640
#include<iostream>
#include<math.h>
#include<algorithm>
#include<stdlib.h>
#include<stack>
#include<set>
#include<string.h>
#include<map>
#include<vector>
#define pb push_back
#define eb emplace_back
#define ins insert 
#define mp make_pair
#define ll long long 
#define max3(a,b,c) max(c,max(a,b))
#define min3(a,b,c) min(c,min(a,b))
#define M 10000007
#define inf 1000000000000000000
#define MOD 1000000007
using namespace std;
void solve(){
	ll n,m;
	cin>>n>>m;
	char a[n][m];
	ll dp[n][m];
	for (int i = 0; i < n; ++i)
	{
		for (int j = 0; j< m; ++j)
		{
			cin>>a[i][j];
			if(a[i][j]=='#')
				dp[i][j]=-1;
			else
				dp[i][j]=0;
		}
	}
	dp[0][0]=0;
	for (int i = 1; i < m; ++i)
	{
		if(dp[0][i]!=-1)
			dp[0][i]=1;
		else{
			for (int j = i+1; j < m; ++j)
			{
				dp[0][j]=-1;
			}
			break;
		}
	}
	for (int i = 1; i < n; ++i)
	{
		if(dp[i][0]!=-1)
			dp[i][0]=1;
		else{
			for (int j = i+1; j < n; ++j)
			{
				dp[j][0]=-1;
			}
			break;
		}
	}
	for (int i = 1; i < n; ++i)
	{
		for (int j =1; j < m; ++j)
		{
			if(dp[i-1][j]!=-1 && dp[i][j]!=-1)
				dp[i][j]=dp[i-1][j]%MOD;
			if(dp[i][j-1]!=-1 && dp[i][j]!=-1)
				dp[i][j]=(dp[i][j]+dp[i][j-1]%MOD)%MOD;
		}
	}
	cout<<dp[n-1][m-1];
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll t=1;
    //cin>>t;
    while(t--){
        solve();
    }
    return 0 ;
}


Measured memory_bytes: 9088
#include <cmath>
#include <cstdio>

#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <numeric>
#include <string>
#include <array>

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

using namespace std;
typedef long long int ll;

int main() {
  ll n;
  cin >> n;
  string s;
  cin >> s;
  vector<string> v(n);
  rep(i, n) v.at(i) = s[i];

  vector<ll> vcnt(n, 0);

  for (int j = 1; j < n; ++j) if(v.at(j) == "E") ++vcnt.at(0);

  for (int k = 1; k < n; ++k) {
    vcnt.at(k) = vcnt.at(k-1);
    if(v.at(k-1) == "W") ++vcnt.at(k);
    if(v.at(k) == "E")--vcnt.at(k);
  }
  cout << *min_element(all(vcnt)) << endl;
  return 0;
}

Measured memory_bytes: 19332
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
#define pb push_back
#define sz(i) (int)(i.size())
#define F first
#define S second
#define L long double
#define P pair<int, int>
const int inf = 0x3f3f3f3f3f3f3f3LL;
const int mod = (int)1e9 + 7;
using namespace std;
#if LOCAL
#include "../../tr.h"
#else
#define tr(...)
#define endl '\n'
#endif
template<class T> void smin(T& a, T val) {if (a > val) a = val;}template<class T> void smax(T& a, T val) {if (a < val) a = val;}
const int N = 111;

int n, a[N];
int dp[N][5][5][5][5];

/*
A => 0
G => 1
C => 2
T => 3
*/

vector<vector<int> > store;
vector<int> v;
int solve(int idx, int P4, int P3, int P2, int P1){
   if(P3 == 0 and P2 == 2 and P1 == 1)
      return 0;
   if(P3 == 0 and P2 == 1 and P1 == 2)
      return 0;
   if(P3 == 1 and P2 == 0 and P1 == 2)
      return 0;
   if(P4 == 0 and P2 == 1 and P1 == 2)
      return 0;
   if(P4 == 0 and P3 == 1 and P1 == 2)
      return 0;

   if(idx >= n)
      return 1;

   int &ans = dp[idx][P4][P3][P2][P1];
   if(~ans)
      return ans;
   ans = 0;
   for (int i = 0; i < 4; ++i)
   {
      ans += solve(idx+1, P3, P2, P1, i);
      ans %= mod;
   }

   return ans;
}

int32_t main(){_

   cin>>n;
   memset(dp, -1, sizeof dp);
   cout<<solve(0LL, 4LL, 4LL, 4LL, 4LL);
   #warning make sure N size is correct!
   return 0;
}

Measured memory_bytes: 768
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const int MAX_N = 1010;
const int MAX_M = 2010;
const ll INF = 1e16;

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

    vector<ll> a(MAX_M), b(MAX_M), c(MAX_M);
    rep(i, m) {
        cin >> a[i] >> b[i] >> c[i];
        a[i]--;  b[i]--;
        c[i] *= -1;
    }

    vector<ll> dist(MAX_N);
    rep(i, n) {
        dist[i] = INF;
    }

    dist[0] = 0;
    rep(loop, n-1) {
        rep(i, m) {

            if(dist[a[i]] == INF) {
                continue;
            }

            if(dist[b[i]] > dist[a[i]] + c[i]) {
                dist[b[i]] = dist[a[i]] + c[i];
            }

        }
    }

    ll ans = dist[n-1];

    vector<bool> negative(MAX_N);

    rep(loop, n) {
        rep(i, m) {

            if(dist[a[i]] == INF) {
                continue;
            }

            if(dist[b[i]] > dist[a[i]] + c[i]) {
                dist[b[i]] = dist[a[i]] + c[i];
                negative[b[i]] = true;
            }

            if(negative[a[i]]) {
                negative[b[i]] = true;
            }

        }
    }

    if(negative[n-1]) {
        cout << "inf";
    }
    else {
        cout << -ans;
    }

    cout << endl;
    return 0;
}

Measured memory_bytes: 256
// https://atcoder.jp/contests/abc084/tasks/abc084_b

#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <tuple>
#include <vector>
using namespace std;

typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define INF (1e9)
#define MOD (1000000007)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOREACH(x, a) for (auto &(x) : (a))
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define LEN(x) (sizeof(x) / sizeof(*(x)))
ll gcd(long a, long b) { return b ? gcd(b, a % b) : a; }
ll lcm(long a, long b) { return a * b / gcd(a, b); }

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a, b;
    cin >> a >> b;
    string s;
    cin >> s;
    bool flag = true;
    if (s.size() > a + b + 1) {
        cout << "No\n";
        return 0;
    }
    for (int i = 0; i < a; i++) {
        if (s[i] < '0' || s[i] > '9') {
            flag = false;
        }
    }
    if (s[a] != '-') {
        flag = false;
    }
    for (int i = b + 1; i < a + b + 1; i++) {
        if (s[i] < '0' || s[i] > '9') {
            flag = false;
        }
    }
    if (flag) {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }

    return 0;
}

Measured memory_bytes: 384
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

  public static void main(String[] args) {
    FastScanner fs = new FastScanner();
    long[] arr = fs.readLongArray(3);
    long x = Math.abs(arr[0]);
    long k = arr[1];
    long d = arr[2];
    if (x > 0 && x / d >= k) {
      x -= k * d;
      System.out.println(x);
    }
    else {
      long y = x / d;
      x -= y * d;
      k -= y;
      if (k % 2 == 0) {
        System.out.println(Math.abs(x));
      }
      else {
        System.out.println(Math.min(Math.abs(x + d), Math.abs(x - d)));
      }
    }
  }

  static class FastScanner {

    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer st = new StringTokenizer("");

    String next() {
      while (!st.hasMoreTokens()) {
        try {
          st = new StringTokenizer(br.readLine());
        } catch (IOException e) {
          e.printStackTrace();
        }
      }
      return st.nextToken();
    }

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

    int[] readIntArray(int n) {
      int[] a = new int[n];
      for (int i = 0; i < n; i++) {
        a[i] = nextInt();
      }
      return a;
    }

    long[] readLongArray(int n) {
      long[] a = new long[n];
      for (int i = 0; i < n; i++) {
        a[i] = nextLong();
      }
      return a;
    }

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


Measured memory_bytes: 32724
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;

template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

int main() {
  ll A;
  cin >> A;
  char op;
  cin >> op;
  ll B;
  cin >> B;

  if (op == '+')
    cout << A + B << endl;
  else
    cout << A - B << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,l;
    cin>>n>>l;
    vector<string>v(n);
    for(int i=0;i<n;i++)
        cin>>v[i];
    sort(v.begin(),v.end());
    for(int i=0;i<n;i++)
        cout<<v[i];
    cout<<endl;
    return 0;
}


Measured memory_bytes: 256
/*************************************************************************
    > File Name: B.cpp
    > Author: HandsomeHow
    > Mail: handsomehowyxh@gmail.com 
    > Created Time: 2017/7/1 20:09:56
 ************************************************************************/
 
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define pb push_back
#define mp make_pair
#define cl(a) memset((a),0,sizeof(a))
#ifdef HandsomeHow
#define dbg(x) cerr << #x << " = " << x << endl
#else
#define dbg(x)
#endif
typedef long long ll;
typedef unsigned long long ull;
typedef pair <int, int> pii;
const int inf=0x3f3f3f3f;
const double eps=1e-8;
const int mod=1000000007;
const double pi=acos(-1.0);
inline void gn(long long&x){
    int sg=1;char c;while(((c=getchar())<'0'||c>'9')&&c!='-');c=='-'?(sg=-1,x=0):(x=c-'0');
    while((c=getchar())>='0'&&c<='9')x=x*10+c-'0';x*=sg;}
inline void gn(int&x){long long t;gn(t);x=t;}
inline void gn(unsigned long long&x){long long t;gn(t);x=t;}
ll gcd(ll a,ll b){return a? gcd(b%a,a):b;}
ll powmod(ll a,ll x,ll mod){ll t=1ll;while(x){if(x&1)t=t*a%mod;a=a*a%mod;x>>=1;}return t;}
// (づ°ω°)づe★------------------------------------------------
const int maxn = 1e5+555;
int v[maxn];
int vis[maxn];
void add(ll &a, ll b){
    a += b;
    a %= mod;
}
void sub(ll &a, ll b){
    a -= b;
    if(a < 0) a += mod;
    a %= mod;
}
ll pre[maxn];
ll C(int n, int m){
    if(n<m)return 0;
    ll ret = pre[n] * powmod(pre[n-m],mod-2,mod);
    ret %= mod;
    ret = (ret * powmod(pre[m],mod-2,mod));
    ret %= mod;
    return ret;
}
int main(){
#ifdef HandsomeHow
    freopen("data.in","r",stdin);
    //freopen("data.out","w",stdout);
#endif
    pre[0]=1;
    rep(i,1,100005)pre[i]=(pre[i-1]*i)%mod;
    int n;gn(n);
    ++n;
    rep(i,1,n){
        gn(v[i]);
        vis[v[i]]++;
    }
    int id;
    rep(i,1,n)if(vis[i]==2)id=i;
    vector<int>pos;
    rep(i,1,n)if(v[i]==id)pos.pb(i);
    int pr = pos[0] - 1;
    int nx = n - pos[1];
    int tot = pr + nx;
    rep(i,1,n){
        ll ans = C(n,i);
        sub(ans,C(tot,i-1));
        printf("%lld\n",ans);
    }
    return 0;
}

Measured memory_bytes: 2816
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
#include <math.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 10e+6
#define DEKA 1000000007

using namespace std;

int main(){
    int n,l;
    cin >> n >> l;
    int ans=n*l+n*(n-1)/2;
    int a=INF;
    int b=INF;
    for(int i=1;i<=n;i++){
        if(a>abs(l+i-1)){
            a=min(a,abs(l+i-1));
            b=l+i-1;
        }
    }
   
    cout << ans-b<< endl;
}



Measured memory_bytes: 256
//
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
//
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

// solution 
use std::cmp;
#[allow(unused_mut)]
#[allow(non_snake_case)]
fn main() {
    input! {
        s: chars,
    }
    let A = s[0].to_digit(10).unwrap() as i32;
    let B = s[1].to_digit(10).unwrap() as i32;
    let C = s[2].to_digit(10).unwrap() as i32;
    let D = s[3].to_digit(10).unwrap() as i32;

    for ind in 0..8 {
        let op1 = ((ind&1)<<1) as i32 - 1;
        let op2 = (((ind>>1)&1)<<1) as i32 - 1;
        let op3 = (((ind>>2)&1)<<1) as i32 - 1;
        if (A + op1*B + op2*C + op3*D) == 7 {
            let op = ["-", "+"];
            let op1s = op[((op1+1)>>1) as usize];
            let op2s = op[((op2+1)>>1) as usize];
            let op3s = op[((op3+1)>>1) as usize];
            println!("{}{}{}{}{}{}{}=7", A, op1s, B, op2s, C, op3s, D);
            return
        }
    }
}


Measured memory_bytes: 4352
#include <iostream>

using namespace std;

int As, Ae;
int Bs, Be;

int main()
{
	cin >> As >> Ae >> Bs >> Be;

	int result = 0;

	if (Ae >= Be && Bs >= As) {
		result = Be - Bs;
	}
	else if (Be >= Ae && As >= Bs)
	{
		result = Ae - As;
	}
	else if (Ae >= Bs && Be >= As) {
		result = Bs > As ? Ae - Bs : Be - As;
	}

	cout << result << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define rep(i, n) for(int i=0; i<n; i++)
#define REP(i, n) for(int i=0; i<=n; i++)
#define repr(i, n) for(int i=n; i>0; i--)
#define REPR(i, n) for(int i=n; i>=0; i--)
const ll INF = 1e18;
const int INT_INF = 1e9;
const ll MOD = 1e9+7;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;

int n;

int main() {
    cin >> n;
    cout << n*n*n << endl;
}


Measured memory_bytes: 256
from collections import deque

N = int(input())
A = [[a - 1 for a in map(int, input().split())] for _ in range(N)]
matchAvailablePlayers = deque(range(N))  # 対戦可能な状態にある選手リスト
daysPassedWhenPlayedMostRecentMatch = [0] * N
opponentCandidateIdx = [-1] * N  # i番目の選手が対戦待ちをしている相手の番号が[i]に入る

# 最終日から順に遡る
while matchAvailablePlayers:
    playerIdx = matchAvailablePlayers.popleft()
    matchesOrderForThisPlayer = A[playerIdx]  # 鏡像コピー！

    if not matchesOrderForThisPlayer:  # この選手はもう全ての相手と対戦した
        continue

    finalOpponentIdx = matchesOrderForThisPlayer.pop()  # 現時点で一番最後に対戦したい相手のindex

    if opponentCandidateIdx[finalOpponentIdx] == playerIdx:  # 対戦成立
        daysPassedWhenPlayedMostRecentMatch[playerIdx] = daysPassedWhenPlayedMostRecentMatch[finalOpponentIdx] = max(daysPassedWhenPlayedMostRecentMatch[playerIdx], daysPassedWhenPlayedMostRecentMatch[finalOpponentIdx]) + 1  # 互いの「試合に至った日」をどちらか遅い方に合わせその翌日に書き換える
        matchAvailablePlayers.append(playerIdx)  # 試合終了、対戦可能リストに加える
        matchAvailablePlayers.append(finalOpponentIdx)
    else:  # 対戦できない、このプレイヤーは対戦待ちをする
        opponentCandidateIdx[playerIdx] = finalOpponentIdx

if any(A):  # リストのリストなので、if A:だと空リストが中に存在しているだけでもTrueになってしまう
    print(-1)
else:
    print(max(daysPassedWhenPlayedMostRecentMatch))


Measured memory_bytes: 35848
#include<bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define dofloat cout<<fixed<<setprecision(8)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define bitcount __builtin_popcount
#define all(vec) vec.begin(),vec.end()
#define rall(vec) vec.rbegin(),vec.rend()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<long long> vl;
typedef pair<long long,long long> pll;
typedef vector<pair<long long,long long> > vll;
typedef vector<pair<int,int> > vii;
typedef vector<int> vi;
typedef pair<int,int> ii;
const long long MOD=1000000007;
const long long MAX=100005;
const long double PI=3.14159265359;
const long double G=9.807;
const long long INF=1e18;
const long double EPS=1e-6;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
bool isprime(ll a){
  if(a==2)return 1;
  if(!(a&1))return 0;
  for(ll i=3;i*i<=a;i+=2)
    if(a%i==0)return 0;
  return 1;
}
ll mpow(ll base,ll exponent,ll modulus){
  if(modulus==1)return 0;
  long long result = 1;
  base=base%modulus;
  while(exponent){
    if(exponent%2 == 1)
    result=(result*base)%modulus;
    exponent=exponent>>1;
    base=(base*base)%modulus;
  }
  return result;
}
ll minv(ll a,ll mod){
  ll _gcd=gcd(a,mod);
  assert(_gcd==1);
  return mpow(a,mod-2,mod);
}


/*
ll ncr(ll N,ll K){
  if(N<K)return 0;
  if(K==0)return 1;
  if(N==0)return 0;

  ll den=1;
  for(ll i=1;i<=K;i++)den*=i;
  ll num=1;
  while(K--){
    num*=N;
    if(num%den==0){
      num/=den;
      den=1;
    }
    N--;
  }

  return num;
}
*/

ll n,m;
vl g[51];
map<pair<ll,ll>,ll>M;
vector<pll>ee;
ll done[51][(1LL<<20)],dp[51][(1LL<<20)];
ll par[51],h[51];

ll solve(ll i,ll mask){
  if(i == n-1){
    if(mask == (1LL<<m)-1)return 1;
    return 0;
  }
  if(done[i][mask])return dp[i][mask];
  ll sub_mask = M[ee[i]];
  // cout<<i<<' '<<sub_mask<<'\n';
  ll ans = solve(i+1,mask|sub_mask)+solve(i+1,mask);
  done[i][mask] = 1;
  return dp[i][mask] = ans;
}

void dfs(ll u,ll p,ll ct){
  par[u] = p;
  h[u] = ct;
  for(auto v:g[u]){
    if(v!=p){
      dfs(v,u,ct+1);
    }
  }
}

ll lca(ll u,ll v){
  vl f(n+1);
  ll cur = u;
  while(cur){
    f[cur] = 1;
    cur = par[cur];
  }
  cur = v;
  while(cur and !f[cur]){
    cur = par[cur];
  }
  return cur;
}


int main(){FAST;
cin>>n;

for(ll i=1;i<=n-1;++i){
  ll u,v;cin>>u>>v;
  g[u].pb(v);
  g[v].pb(u);
  ee.pb({min(u,v),max(u,v)});
}

dfs(1,0,0);

cin>>m;

for(ll i=0;i<m;++i){
  ll u,v;cin>>u>>v;
  if(h[u]>h[v]){
    swap(u,v);
  }
  ll L = lca(u,v);
  // cout<<i<<' '<<L<<'\n';
  ll cur = v;
  while(cur!=L){
    M[{min(cur,par[cur]),max(cur,par[cur])}]|=(1LL<<i);
    cur = par[cur];
  }
  cur = u;
  while(cur!=L){
    M[{min(cur,par[cur]),max(cur,par[cur])}]|=(1LL<<i);
    cur = par[cur];
  }
}

cout<<solve(0,0);

return 0;
}

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

using namespace std;

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

int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int N, M, R;
int dp[201][201];
int r[8];
int main() {
    cin >> N >> M >> R;

    rep(i, R) cin >> r[i];
    rep(i, 201) rep(j, 201) dp[i][j] = 1e9;
    rep(i, 201) dp[i][i] = 0;
    rep(i, M) {
        int a, b, c;
        cin >> a >> b >> c;
        a--;
        b--;
        dp[a][b] = c;
        dp[b][a] = c;
    }
    rep(k, 201) rep(i, 201) rep(j, 201) dp[i][j] =
        min(dp[i][j], dp[i][k] + dp[k][j]);

    rep(i, R) r[i]--;
    sort(r, r + R);

    int ans = 1e9;
    do {
        int sum = 0;
        rep(i, R) if (i) sum += dp[r[i - 1]][r[i]];
        ans = min(ans, sum);
    } while (next_permutation(r, r + R));

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

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

int main(){
    int x;
    cin>>x;
    int total=0;
    int syo,amari;
        syo=x/500;
        amari=x%500;
        total+=syo*1000;
        syo=amari/5;
        amari%=5;
        total+=syo*5;
    cout<<total<<endl;
    return 0;
}

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

int main() {
  long long int a,b,c;
  cin >>a >> b >> c;
  
  if(b > c){
    cout << (a*c) /b << endl;
  }
  
  else{
    cout << (a*(b-1))/b << endl;
  }
  
}

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

using namespace std;
using ll=long long;
#define rep2(i, a, n) for (int i = (a); i < (a); ++i)
#define rep(i,n) for (int i = 0; i < (n); ++i)

int main(){
  cin.tie(nullptr);ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  int h,w,n;cin>>h>>w>>n;
  int a[n],hoge[h][w],cnt=0;
  rep(i,n)cin>>a[i];
  rep(i,h){
    rep(j,w){
      if(a[cnt]==0)++cnt;
      --a[cnt];

      //$B4q?t(B
      if(i%2==0){
        hoge[i][j]=cnt+1;
      //$B6v?t(B
      }else{
        hoge[i][w-j-1]=cnt+1;
      }
    }
  }
  rep(i,h){
    rep(j,w){
      j!=w-1?cout<<hoge[i][j]<<" ":cout<<hoge[i][j];
    }
    cout<<endl;
  }
}


Measured memory_bytes: 3672
using System;

namespace A
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] In = Console.ReadLine().Split(' ');
            int a = int.Parse(In[0]);
            int b = int.Parse(In[1]);
            if (a <= 5) Console.WriteLine(0);
            else if (6 <= a &&a <= 12) Console.WriteLine(b / 2);
            else if (13 <= a) Console.WriteLine(b);
        }
    }
}


Measured memory_bytes: 27208
from decimal import *
n=int(input())
log=[]
H=[]
for i in range(n):
    log.append(tuple(map(int,input().split())))
t,a=1,1
for x,y in log:
    nxt=max(t//x + (1 if t%x else 0),a//y + (1 if a%y else 0))
    t=x*nxt
    a=y*nxt
print(t+a)

Measured memory_bytes: 5076
#include<cstdio>
#include<cstring>
#include<algorithm>
char s[15];
int len;
int main(){
	scanf("%s",s+1); len=strlen(s+1);
	for(int i=1;i<len;i++)if(s[i]=='A'&&s[i+1]=='C') return printf("Yes\n"),0;
	printf("No\n");
	return 0;
}

Measured memory_bytes: 128
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main(){
    int n; cin>>n;
    if(n%2) cout<<2*n<<endl;
    else cout<<n<<endl;
}


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

#define REP(i,n) for (int i=0;i<(n);i++)
#define PII pair<int,int>
#define LL long long

int main(){
  LL n;
  LL A,B;
  LL *dist;

  LL tir=0;

  cin>>n>>A>>B;
  dist=new LL[n];
  REP(i,n){
    cin>>dist[i];
  }
  
  REP(i,n-1){
    int dx=dist[i+1]-dist[i];
    if(A*dx>B){
      tir+=B;
    }else{
      tir+=A*dx;
    }
  }
  

  cout<<tir;

  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
using ld = long double;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,a,n) for(ll i=a;i<(ll)(n);i++)
#define repr(i,a,n) for(ll i=n-1;(ll)a<=i;i--)
#define lb lower_bound
#define ub upper_bound
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
const ll mod = 1000000007;
const ll INF = 1000000099;
const ll LINF = (ll)(1e18 +99);
vector<ll> dx={-1,1,0,0},dy={0,0,-1,1};
template<typename T,typename U> void chmin(T& t, const U& u){if(t>u)t=u;}
template<typename T,typename U> void chmax(T& t, const U& u){if(t<u)t=u;}
template<typename T>T gcd(T a,T b){return b?gcd(b,a%b):a;}
template<typename T>T mpow(T a, T n) {
   T res = 1;
   for(;n;n>>=1) {
      if (n & 1) res = res * a;
      a = a * a;
   }
   return res;
}

//cin.tie(0);ios::sync_with_stdio(false);



signed main(){
   int n;cin>>n;
   if(n==3 || n==5 || n==7){
      cout<<"YES"<<endl;
   }  else{
      cout<<"NO"<<endl;
   }
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <climits>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <bitset>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
typedef long long ll;
typedef pair<int,int> pii;
const int INF = 1<<29;
const double PI = acos(-1);
const double EPS = 1e-8;

int c[50],h[50];

vector<pii> g[50];
vector<pii> rg[50];

vector<int> p[50];

struct P {
  int a, b;
  ll S;
  int dist;
  P(int a, int b, ll S, int d) : a(a),b(b),S(S),dist(d) {}
  bool operator<(const P &b) const {
    return dist > b.dist;
  }
};
int dist[51][51];

int main() {
  int n, m;
  while(cin >> n >> m, n||m) {
    REP(i,n-2) {
      cin >> c[i+1] >> h[i+1];
    }
    c[0] = 0, h[0] = 0;
    c[n-1] = 0, h[n-1] = 1000;
    REP(i,n) {
      g[i].clear();
      rg[i].clear();
    }
    REP(i,m) {
      int a, b, d;
      cin >> a >> b >> d;
      a--; b--;
      if (h[a]<=h[b]) g[a].push_back(pii(b,d));
      if (h[b]<=h[a]) rg[b].push_back(pii(a,d));
    }
    priority_queue<P> Q;
    Q.push(P(0,0,0,0));
    memset(dist,0x3F,sizeof(dist));
    dist[0][0] = 0;
    int ans = -1;
    while(!Q.empty()) {
      P p = Q.top(); Q.pop();
      if (dist[p.a][p.b] < p.dist) continue;

      if (p.a == n-1 && p.b == n-1) {
        ans = p.dist;
        break;
      }
      FOR(it, g[p.a]) {
        int cost = (p.S>>it->first&1) ? 0 : c[it->first];
        cost += p.dist + it->second;
        if (dist[it->first][p.b] > cost) {
          dist[it->first][p.b] = cost;
          Q.push(P(it->first, p.b, p.S|1LL<<it->first, cost));
        }
      }
      FOR(it, rg[p.b]) {
        int cost = (p.S>>it->first&1) ? 0 : c[it->first];
        cost += p.dist + it->second;
        if (dist[p.a][it->first] > cost) {
          dist[p.a][it->first] = cost;
          Q.push(P(p.a, it->first, p.S|1LL<<it->first, cost));
        }
      }
    }
    cout << ans << endl;
  }
}

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

int main() {
    string S;
    cin >> S;
    string out = "AC";
    if (S.at(0) != 'A')
        out = "WA";
 
    int cnt = 0;
    int length = S.size();
    for (int i = 1; i < length; i++) {
        if (isupper(S.at(i))) {
            if (i == 1 || i == length - 1 || S.at(i) != 'C')
                out = "WA";
            cnt++;
        }
    }
    if (cnt != 1)
        out = "WA";
    cout << out << endl;
 
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <utility>
#include <set>


using namespace std;
using ll = long long int;

#define rep(i, n) for(ll i = 0; i < (n); i++)
#define MOD 1000000007LL

template<class T, class U> void show_pair(pair<T, U> &p) {
  cout << '(' << p.first << "," << p.second << ")" << endl;
}

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

  ll sum = 0;
  for (ll i = 1; i <= N; i++) {
    ll c = N / i;    

    sum += i * c * (c + 1) / 2;
  }

  cout << sum << endl;

  return 0;
}


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

int H, W;

bool a[2001][2001];

int p[2001][2001];
int q[2001][2001];

// #..#..
// .....#
// ....#.
// #.#...

int main(){
    cin >> H >> W;
    for(int i = 0; i < H; ++i){
        string s;
        cin >> s;
        for(int j = 0; j < W; ++j){
            if(s[j] == '#') {
                a[i][j] = true;
            }else {
                a[i][j] = false;
            }
        }
    }

    for(int y = 0; y < H; ++y){
        int tmp = 0;
        int begin = 0;
        for(int x = 0; x < W; ++x){
            if(a[y][x]){
                for(int i = begin; i < x; ++i){
                    p[y][i] = tmp;
                }
                begin = x + 1;
                tmp = 0;
            }else {
                tmp++;
            }
        }
        for(int i = begin; i < W; ++i){
            p[y][i] = tmp;
        }
    }

    for(int x = 0; x < W; ++x){
        int tmp = 0;
        int begin = 0;
        for(int y = 0; y < H; ++y){
            if(a[y][x]){
                for(int i = begin; i < y; ++i){
                    q[i][x] = tmp;
                }
                begin = y + 1;
                tmp = 0;
            }else {
                tmp++;
            }
        }
        for(int i = begin; i < H; ++i){
            q[i][x] = tmp;
        }
    }

    // for(int y = 0; y < H; ++y){
    //     for(int x = 0; x < W; ++x){
    //         cout << a[y][x];
    //     }
    //     cout << endl;
    // }
    //     cout << endl;

    // for(int y = 0; y < H; ++y){
    //     for(int x = 0; x < W; ++x){
    //         cout << p[y][x];
    //     }
    //     cout << endl;
    // }
    //     cout << endl;


    // for(int y = 0; y < H; ++y){
    //     for(int x = 0; x < W; ++x){
    //         cout << q[y][x];
    //     }
    //     cout << endl;
    // }

    int max_light = 0;
    for(int y = 0; y < H; ++y){
        for(int x = 0; x < W; ++x){
            if(a[y][x]) continue;
            if(max_light < p[y][x] + q[y][x] - 1) {
                max_light = p[y][x] + q[y][x] - 1;
            }
        }
    }

    cout << max_light << endl;
}



Measured memory_bytes: 35456
#include <algorithm>
#include <stack>
#include <iostream>
#include <stdexcept>

struct symbol
{
  bool _is_str = true;
  int _n;
  std::string _str;

  symbol(const std::string& str) {
    try{
      _n = std::stoi(str);
      _is_str = false;
    } catch(const std::invalid_argument& e)
    {
      _str = str;
    } catch(const std::exception& e)
    {
      std::cout << "error" << std::endl;
    }
  }

  bool is_str() const{
    return _is_str;
  }
};

int eval(std::stack<symbol>& eq) {
  auto s = eq.top();
  eq.pop();

  if (s.is_str()){
    auto r = eval(eq);
    auto l = eval(eq);

    if (s._str == "+"){
      return l + r;
    } else if (s._str == "-"){
      return l - r;
    } else if (s._str == "*"){
      return l * r;
    } else{
      std::cout << "invalid operand" << std::endl;
      return 0;
    }
  }

  return s._n;
}

int main()
{
  std::stack<symbol> st;
  std::string temp;
  while(std::cin >> temp){
    st.push(symbol(temp));
  }

  int ret = eval(st);
  std::cout << ret << std::endl;
}

Measured memory_bytes: 3316
#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;

const int MAX = 5100000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


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



Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <sstream>
#include <queue> 
#include <list>
#include <stack>
#include <unordered_map>
#include <algorithm> 
#include <numeric>  
#include <functional>
#include <cassert>
#include <bitset>
#include <cctype>  
#include <iomanip> 
#include <limits>  
#include <regex>
// std::numeric_limits<int>::max(), min()
// std::setprecision(X)
// std::islower(), std::isupper(), std::tolower, std::toupper
// std::accumulate(m.begin(), m.end(), 0LL);
// std::sort(begin(),end()) // 0, 1, 2, 3 ,4 (default, less);
// std::priority_queue<int, vector<int>, less<int>> que; // 4, 3, 2, 1 (defualt, less) : 
// if ( std::regex_match(S, std::regex("(dream|dreamer|erase|eraser)*")) ) std::cout << "YES" << std::endl;

#define rep(i,n)  for(int i = 0; i < (int)(n);    i++)
#define sz(x)     ((int)(x).size())
#define all(x)    (x).begin(),(x).end()

using ll = long long;

ll gcd ( ll a, ll b ) { if ( b == 0 ) return a; else return gcd ( b, a%b ); }
ll lcm ( ll a, ll b ) { return a * b / gcd(a, b); }

int main (void) {
  std::cin.tie(0);  std::ios::sync_with_stdio(false);
  int K; std::cin >> K;

  std::vector<ll> t(201, 0);
  for(int a=1; a<=K; a++) for(int b=1; b<=K; b++) t[gcd(a,b)]++;

  ll ans = 0;
  for(int i=1; i<=200; i++) for(int c=1; c<=K; c++) {
    ans += gcd(i,c) * t[i];
  }

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



Measured memory_bytes: 3656
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int a=sc.nextInt();
		int b=sc.nextInt();
		int k=sc.nextInt();
		int count=0;
		int ans=0;
		int []div=new int[15];

		for(int i=1;i<=a;i++){
			if(a%i==0 && b%i==0 ){
				div[count]=i;
				count++;
			}
		}
		ans=div[count-k];


		System.out.println(ans);
		sc.close();
	}
}



Measured memory_bytes: 22868
a, b, k = map(int, input().split())

ans = []
s = set()

for i in range(k):
    if a+i <= b and a+i >= a:
        ans.append(a+i)
        s.add(a+i)
for i in reversed(range(k)):
    if b-i <= b and b-i >= a:
        if b-i not in s:
            ans.append(b - i)

for i in ans:
    print(i)

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

int a[100000],b[100000],c[100000];
int main() {
  int n;
  cin >> n;
  for(int i = 0; i < n; i++) cin >> a[i];
  for(int i = 0; i < n; i++) cin >> b[i];
  for(int i = 0; i < n; i++) cin >> c[i];
  sort(a, a+n);
  sort(c, c+n);
  long long ans = 0;
  for(int j = 0; j < n; j++){
    ans+=(c+n-upper_bound(c,c+n,b[j]))*(lower_bound(a,a+n,b[j])-a);
  }
  cout << ans << endl;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(a) (a).begin(),(a).end()
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
const int INF=1e9;
const int MOD=100000;
int main(){
      map<char,string> s;
      s[' '] = "101";
      s['\''] = "000000";
      s[','] = "000011";
      s['-'] = "10010001";
      s['.'] = "010001";
      s['?'] = "000001";
      s['A'] = "100101";
      s['B'] = "10011010";
      s['C'] = "0101";
      s['D'] = "0001";
      s['E'] = "110";
      s['F'] = "01001";
      s['G'] = "10011011";
      s['H'] = "010000";
      s['I'] = "0111";
      s['J'] = "10011000";
      s['K'] = "0110";
      s['L'] = "00100";
      s['M'] = "10011001";
      s['N'] = "10011110";
      s['O'] = "00101";
      s['P'] = "111";
      s['Q'] = "10011111";
      s['R'] = "1000";
      s['S'] = "00110";
      s['T'] = "00111";
      s['U'] = "10011100";
      s['V'] = "10011101";
      s['W'] = "000010";
      s['X'] = "10010010";
      s['Y'] = "10010011";
      s['Z'] = "10010000";
      map<string,char> t;
      t["00000"] = 'A';
      t["00001"] = 'B';
      t["00010"] = 'C';
      t["00011"] = 'D';
      t["00100"] = 'E';
      t["00101"] = 'F';
      t["00110"] = 'G';
      t["00111"] = 'H';
      t["01000"] = 'I';
      t["01001"] = 'J';
      t["01010"] = 'K';
      t["01011"] = 'L';
      t["01100"] = 'M';
      t["01101"] = 'N';
      t["01110"] = 'O';
      t["01111"] = 'P';
      t["10000"] = 'Q';
      t["10001"] = 'R';
      t["10010"] = 'S';
      t["10011"] = 'T';
      t["10100"] = 'U';
      t["10101"] = 'V';
      t["10110"] = 'W';
      t["10111"] = 'X';
      t["11000"] = 'Y';
      t["11001"] = 'Z';
      t["11010"] = ' ';
      t["11011"] = '.';
      t["11100"] = ',';
      t["11101"] = '-';
      t["11110"] = '\'';
      t["11111"] = '?';
      string in;
      while(getline(cin,in)){
            string in1="",ans="";
            REP(i,in.size()){
                  in1+=s[in[i]];
            }
            while(in1.size()%5!=0)in1+='0';
            REP(i,in1.size()/5){
                  in.assign(in1,i*5,5);
                  ans+=t[in];
            }
            cout<<ans<<endl;
      }
}

Measured memory_bytes: 1200
defmodule Main do
 def takoyaki(nums) do
   cooking_count = div(Enum.at(nums,0),Enum.at(nums,1))
   cooking_rem = rem(Enum.at(nums,0),Enum.at(nums,1))
   cond do
     cooking_rem > 0 -> (cooking_count + 1) * Enum.at(nums,2)
     true -> cooking_count * Enum.at(nums,2)
     end
 end
 
 def main do
    nums = IO.read(:line) |> String.trim() |> String.split(" ") |> Enum.map(&String.to_integer/1)
    IO.puts takoyaki(nums)
 end
end

Measured memory_bytes: 30680
class DisjointSet:
    def __init__(self, size):
        self.rank = [0 for i in range(size)]
        self.p = [0 for i in range(size)]
        for i in range(size):
            self.makeSet(i)
    
    def makeSet(self, x):
        self.p[x] = x
        self.rank[x] = 0

    def same(self, x, y):
        return self.findSet(x) == self.findSet(y)

    def unite(self, x, y):
        self.link(self.findSet(x), self.findSet(y))

    def link(self, x, y):
        if self.rank[x] > self.rank[y]:
            self.p[y] = x
        else:
            self.p[x] = y
            if self.rank[x] == self.rank[y]:
                self.rank[y] += 1
    
    def findSet(self, x):
        if x != self.p[x]:
            self.p[x] = self.findSet(self.p[x])
        return self.p[x]
        

from collections import defaultdict, Counter
count_friend = Counter()
# friends = defaultdict(list)
friends_cluster = Counter()
# blocks = defaultdict(set)
count_block = Counter()
N, M, K = map(int, input().split())
ds = DisjointSet(N+1)
# graph = [[] for i in range(N+1)]
for i in range(M):
    A, B = map(int, input().split())
    ds.unite(A, B)
    count_friend[A] += 1
    count_friend[B] += 1
for i in range(K):
    C, D = map(int, input().split())
    if ds.same(C, D):
        count_block[C] += 1
        count_block[D] += 1
c_ids = [ds.findSet(i) for i in range(N+1)]
for i in range(1, N+1):
    friends_cluster[c_ids[i]] += 1
ans = []
for i in range(1, N+1):
    c_id = c_ids[i]
    ans += [friends_cluster[c_id]-count_block[i]-count_friend[i]-1]
print(' '.join(list(map(str, ans))))
# print(ds.p)

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

int main(void){
    int a,n,x;
    char s[10];
    scanf("%s",s);
    n = atoi(s);
    for(int i = 0; i < strlen(s);++i){
        a = s[i] - '0';
        x += a;
    }
    if(n % x == 0){
        printf("Yes");
    }else{
        printf("No");
    }
    return 0;
}

Measured memory_bytes: 128