akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

const int MAX = 510000;
const int MOD = 1000000007;

ll ans = 0;
ll n, m , q;
vector<ll> a , b , c , d;

void dfs(vector<ll> A){
  // cout<<A.size()<<endl;
  if(A.size() == n + 1){
    ll tmp = 0;
    rep(i,q){
      if(A[b[i]] - A[a[i]] == c[i]) tmp += d[i];
    }
    ans = max(ans , tmp);
    return ;
  }

  A.pb(A.back());
  while(A.back() <= m){
    dfs(A);
    A.back()++;
  }

}

int main(){
  cin >> n >> m >> q;
  a = b = c = d = vector<ll>(q);
  rep(i,q){
    cin >> a[i] >> b[i] >> c[i] >> d[i];
  }

  vector<ll> A(1,1);
  dfs(A);
  cout << ans <<endl;
}


Measured memory_bytes: 3604
using System;

class AOJ{
  static void Main(string[] args)
  {
    int[] stack = new int[101];
    int i = 0;
    string s;

    while ((s = Console.ReadLine()) != null){

      int n = int.Parse(s);

      if (n == 0){
        i--;
        Console.WriteLine(stack[i]);
      }

      else{
        stack[i] = n;
        i++;
      }
    }
  }
}

Measured memory_bytes: 9052
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  
  int min_count = 100;
  int count = 0;
  for (int i=0; i<N; i++) {
    int A;
    cin >> A;
    
    count = 0;
    while (A%2 == 0) {
      A = A/2;
      count++;
    }
    
    if (count < min_count) {
      min_count = count;
    }
    if (min_count==0)
      break;
  }
  cout << min_count << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.Set;
import java.util.TreeSet;
class Main {
	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)){
			int n = sc.nextInt();
			Set<Integer> a = new TreeSet<>();
			for(int i = 0; i < n; i++) {
				a.add(sc.nextInt());
			}
			int m = sc.nextInt();
			Set<Integer> b = new TreeSet<>();
			for(int i = 0; i < m; i++) {
				b.add(sc.nextInt());
			}

			a.removeIf((num) -> b.contains(num));
			a.forEach(num -> System.out.println(num));
		}
	}
}


Measured memory_bytes: 192268
#include <bits/stdc++.h>
using namespace std;
const int N=1e5+5;
typedef long long ll;
ll n,c,x[N],w[N],val[N],rval[N],shun[N],ni[N];
int main()
{
    cin>>n>>c;
    for(int i=1;i<=n;i++)
    {
        cin>>x[i]>>w[i];
        val[i]=val[i-1]+w[i];
        shun[i]=max(shun[i-1],val[i]-x[i]);
    }
    for(int i=n;i>=1;i--)
    {
        rval[i]=rval[i+1]+w[i];
        ni[i]=max(ni[i+1],rval[i]-c+x[i]);
    }
    ll A=0;
    for(int i=n;i>=1;i--)
    {
        A=max(A,rval[i]-2*(c-x[i])+shun[i-1]);
        A=max(A,ni[i]);
    }
    for(int i=1;i<=n;i++)
    {
        A=max(A,val[i]-2*x[i]+ni[i+1]);
        A=max(A,shun[i]);
    }
    cout<<A;
    return 0;
}


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

/*
var n = int.Parse(Console.ReadLine());
var s = Console.ReadLine().Split(' ');
var a = new int[100];
for (int i = 0; i < 100; i++) {
    a[i] = int.Parse(s[i]);
}
*/

namespace Test
{
    class MainClass
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine();
            var t = Console.ReadLine();
            bool ans = false;
            for (int i = 0; i < s.Length; i++)
            {
                var cycleT = new char[s.Length];
                for (int j = 0; j < s.Length; j++)
                {
                    cycleT[j] = t[(i + j) % s.Length];
                }
                var cycleTs = new String(cycleT);
                if (s.Equals(cycleTs))
                {
                    ans = true;
                }
            }
            if (ans) {
                Console.WriteLine("Yes");
            }
            else {
                Console.WriteLine("No");
            }

        }
    }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
#include <cstring>
#include <limits>
using namespace std;
#define ll long long int
#define lli long long int
#define fw(i, s, e) for (ll i = s; i < e; ++i)
#define fe(i, s, e) for (ll i = s; i <= e; ++i)
#define fb(i, e, s) for (ll i = e; i >= s; --i)
#define L(T)  \
    ll T;     \
    cin >> T; \
    while (T--)
#define FASTIO                   \
    ios::sync_with_stdio(false); \
    cin.tie(nullptr);            \
    cout.tie(nullptr);
#define mem(a, i) memset(a, i, sizeof(a))
#define ld long double
#define endl "\n"
#define in(P) \
    ll P;     \
    cin >> P;
int main()
{
    FASTIO
    // L(T)
    {
        in(n);
        in(k);
        ll a[n + 90];
        fw(i, 0, n)
        {
            cin >> a[i];
        }
        sort(a, a + n);
        ll s = 0;
        fw(i, 0, k)
        {
            s += a[i];
        }
        cout<<s<<endl;
    }
    return 0;
}

Measured memory_bytes: 3656
MODULE judgePrimeMod
!入力値が素数か否かを判定するためのモジュール．
      implicit none
      integer,parameter,private :: p = 16
      
      contains
      function isPrime( x ) result( TorF )
        implicit none
        integer(p),intent(in) :: x
        logical :: TorF
        integer(p) :: i
        
        if( x==2 )then
          TorF = .true.
          return
        end if
        
        if( x<2 .or. mod(x,2)==0 )then
          TorF = .false.
          return
        end if
        
        i = 3
        do while( i<=ceiling( sqrt(real(x)) ) )
          
          if( mod(x,i)==0 )then
            TorF = .false.
            return
          end if
          
          i = i + 2
        end do
        
        TorF = .true.
      end function
      END MODULE judgePrimeMod
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

      PROGRAM Repsept
      use judgePrimeMod
      IMPLICIT NONE
      INTEGER,PARAMETER :: p = 16
      integer(p) :: k,i,seven=0,ten
      
      
      read*,k
      if( mod(k,2)==0 .or.mod(k,5)==0 )then
        print'(a)','-1'
        stop
      end if
      
      i = 0
      ten = 1
      do while( .true. )
        seven = seven + 7*ten
        seven = mod(seven,k)
        
        if( mod(seven,k)==0 )then
          exit
        else
          i = i+1
          ten = mod(ten*10,k)
        end if
      end do
      
      print*,i+1
      
      
      
      stop
      !debugg
      
      
      
      END PROGRAM

Measured memory_bytes: 2844
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
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; }
const long long INF = 1LL << 60;
 
typedef pair<ll,ll> pairs;
vector<pairs> p;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
#define MAX_N 1000100
bool x[MAX_N];
ll num[MAX_N];
ll fibl[MAX_N]={0};
 
ll fib(ll a){
    if (fibl[a]!=0)return fibl[a];
    if (a==0){
        return 0;
    }else if (a==1){
        return 1;
    }
    return fibl[a]=fib(a-1)+fib(a-2);
}
 
ll eratosthenes(ll n) {
    int p = 0;
    for (ll i=0; i<=n; ++i) x[i] = true;
    x[0] = x[1] = false;
    for(int i=2; i<=n; ++i) {
        if(x[i]) {
            p++;
            for(int j=2*i; j<=n; j+=i) x[j] = false;
        }
        
        num[i] = p;
    }
    return p;
}
 
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}
 
ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

int main(){
    ll a,b;
    cin>>a>>b;
    
    if (a==1)a+=13;
    if (b==1)b+=13;
    
    if (a > b)cout << "Alice" << endl;
    else if (b > a)cout << "Bob" << endl;
    else cout << "Draw" << endl;
    
    return 0;
}




Measured memory_bytes: 256
n=int(input())
shogen=[[]for _ in range(n)]
for i in range(n):
    a=int(input())
    for j in range(a):
        x,y=map(int,input().split())
        shogen[i].append((x,y))

ans = 0
def dfs(i,tf):
    global ans
    if i == n:
        ok = True
        for j,a in enumerate(tf):
            if a == True:
                for x,y in shogen[j]:
                    if tf[x-1] == y:
                        pass
                    else:
                        ok = False
        if ok==True:
            ans = max(ans,tf.count(1))
        return
    else:
        dfs(i+1,tf+[True])
        dfs(i+1,tf+[False])

dfs(0,[])
print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define pi 3.1415926536
#define pb push_back
#define N 998244353
#define M 1000003
#define INF 1e9
int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int n,q,i,j,t,k,l,r;
   	cin>>n;
   	int a[n+5],dp[n+5]={0};
   	for(i=0;i<n;i++) cin>>a[i];
   	dp[0] = 0;
   	dp[1] = abs(a[1]-a[0]);
   	for(i=2;i<n;i++){
   	 dp[i] = min(dp[i-2] + abs(a[i-2]-a[i]), dp[i-1] + abs(a[i-1]-a[i]));	
	}
	cout<<dp[n-1];
 }

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

long long n;
vector<long long> h, ans;

long long solve();

int main() {
  cin >> n;
  h.resize(n);
  for(int i = 0; i < n; ++i) cin >> h[i];
  cout << solve() << endl;
  return 0;
}
long long solve() {
  long long nans = 0;
  ans.assign(n, 0);
  for(int i = 1; i < n; ++i) {
    if(h[i] <= h[i - 1]) ans[i] = ans[i - 1] + 1;
    nans = max(nans, ans[i]);
  }
  return nans;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<long long> vll;
typedef vector<pair<int,int> > vpi;
typedef vector<pair<long long, long long> > vpl;
typedef pair<int,int> pii;
typedef pair<long long, long long> pll;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,n) for(int i=1;i<=(int)(n);i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define ROT(a) a.begin(),a.begin()+1,a.end()
#define RROT(a) a.begin(),a.end()-1,a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
#define sz(a) a.size()
const ll MOD = 1e9+7;
const int MAX = 10000000;
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
//cout << 'H' << endl;
/*--------------------------------------------*/

int main(){
    //cout << fixed << setprecision(10)
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll N;
    cin >> N;

    map<string,ll> mp;

    rep(i,N){
        string s;
        cin >> s;

        mp[s]++;
    }

    ll ans = 0;

    for(auto i: mp){
        chmax(ans,i.second);
    }

    for(auto i:mp){
        if(i.second == ans){
            cout << i.first << endl; 
        }
    }
}

Measured memory_bytes: 23808
const input = require('fs').readFileSync('/dev/stdin', 'utf8').split(/\n/);
let str = input[0].split('');
let time = Number(input[1]);

for (let i=2; i<time+2; i++) {
    let order = input[i].split(' ');
    let a = Number(order[1]);
    let b = Number(order[2]);
    if (order[0] === 'replace') {
      let word = order[3].split('');
      str.splice(a, b+1-a, ...word);
    }
    if (order[0] === 'reverse') {
        word = str.slice(a, b+1);
        word.reverse();
        str.splice(a, b+1-a, ...word)
    }
    if (order[0] === 'print') {
        word = str.slice(a, b+1);
        console.log(word.join(''));
    }

}


Measured memory_bytes: 17768
#D
n = int(input())

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr
def suretu(n):
    a = []
    i = 1
    while True:
        n  = n - i
        if n >= 0:
            a.append(i)
            i += 1
        else:
            break
    return a
f = factorization(n)
flg = True
#print(f)
cnt = 0
if f == [[1,1]]:
    print(0)
else:
    for i in range(len(f)):
        cnt += len(suretu(f[i][1]))
    print(cnt)

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

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<bool> vb;

template <typename T, typename U> std::istream&operator>>(std::istream&i, pair<T,U>&p) {i >> p.x >> p.y; return i;}
template<typename T>std::istream&operator>>(std::istream&i,vector<T>&t) {for(auto&v:t){i>>v;}return i;}
template <typename T, typename U> std::ostream&operator<<(std::ostream&o, const pair<T,U>&p) {o << p.x << ' ' << p.y; return o;}
template<typename T>std::ostream&operator<<(std::ostream&o,const vector<T>&t) {if(t.empty())o<<'\n';for(size_t i=0;i<t.size();++i){o<<t[i]<<" \n"[i == t.size()-1];}return o;}

#define deb(x) cout << '>' << #x << ':' << x << endl;
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define END '\n'
#define inf 9e18
#define ff first
#define ss second
#define pb push_back

void solve(){
    int a, b;
    cin >> a >> b;
    cout << (a + b) % 24;
}
int main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    int t = 1;
    // cin >> t;
    while(t--){
        solve();
    }
    return 0;
}

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

#define EPS (1e-7)
#define INF (1<<25)
#define PI (acos(-1))
#define MOD 1000000007

#define FOR(i,a,n) for(int i=(a), i##_len=(n); i<i##_len; ++i)
#define REP(i,n) FOR(i,0,n)

#define whole(f,x,...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)

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 (b<a) { a=b; return 1; } return 0; }
#define abs(x) (x>0?(x):(-(x)))

using ll = long long;

ll fac(int n) {
  ll res = 1;
  for (ll i = 1; i <= n; ++i) {
    res = (res*i)% MOD;
  }
  return res;
}


int main() {
  int n,m; cin >> n >> m;
  ll ans = 0;
  if (abs(n-m) <= 1) {
    ans = fac(n);
    ans = ans*fac(m)%MOD;
  }
  if (n==m) ans = ans*2%MOD;
  cout << ans << endl;
  return 0;
}


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

typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define index(xs, x) (int)(lower_bound(all(xs), x) - xs.begin())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
int modpow(int x, int k, int MOD) {
  int a = 1;
  while (k > 0) {
    if (k & 1) a = (1LL*a*x) % MOD;
    x = (1LL*x*x) % MOD;
    k >>= 1;
  }
  return a;
}

int N, MOD;
int nCr[3001][3001];
int fact[3001];
int dp[3001][3001];
inline int mul(int x, int y) { return (1LL*x*y)%MOD; }
inline void add(int &x, int v) { x += v; if (x >= MOD) x -= MOD; }

signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> N >> MOD;

  nCr[0][0] = 1;
  for (int i=1; i<=3000; i++) {
    nCr[i][0] = 1;
    for (int j=1; j<=3000; j++) nCr[i][j] = (nCr[i-1][j-1]+nCr[i-1][j])%MOD;
  }
  fact[0] = 1;
  for (int i=1; i<=3000; i++) fact[i] = (1LL*i*fact[i-1])%MOD;

  dp[0][0] = 1;
  rep(i, 3000) {
    rep(y, i+1) {
      add(dp[i+1][y+1], dp[i][y]);
      add(dp[i+1][y], mul(y+1, dp[i][y]));
    }
  }

  int sum = 0;
  for (int S=0; S<=N; S++) {
    int base = modpow(2, N-S, MOD);
    int s = 0;
    int w = 1; // base^num
    rep(num, S+1) {
      add(s, mul(dp[S][num], w));
      w = mul(w, base);
    }
    s = mul(s, modpow(2, modpow(2, N-S, MOD-1), MOD));
    s = mul(s, nCr[N][S]);
    if (S%2) s = (MOD-s)%MOD;
    sum = (sum+s)%MOD;
  }
  cout << sum << "\n";
  return 0;
}


Measured memory_bytes: 69376
#include <stdio.h>
void insertionsort(int numbers[],int size);
void swap(int *p_from,int *p_to);
int A[100];
int main(){
  int N,i,j;
  scanf("%d",&N);
  for(i=0;i<N;i++){
    scanf(" %d",&A[i]);
  }
  for(i=0;i<N-1;i++){
    printf("%d ",A[i]);
  }
  printf("%d\n",A[N-1]);
  insertionsort(A,N);
  return 0;
}
void insertionsort(int A[],int size){
  int i,j,k;
  for(i=1;i<size;i++){
    j=i;
    while((j>0)&&(A[j-1]>A[j])){
      swap(&A[j-1],&A[j]);
      j--;
    }
    for(k=0;k<size-1;k++){
      printf("%d ",A[k]);
    }
    printf("%d\n",A[size-1]);
  }
}
void swap(int *p_from,int *p_to){
  int t;
  t=*p_from;
  *p_from=*p_to;
  *p_to=t;
}

Measured memory_bytes: 2716
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (int i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define pb push_back
using ll = long long;
using vin=vector<int>;
using vll=vector<ll>;
using vst=vector<string>;
using P = pair<int, int>;
const int inf=1e9+7;
const ll INF=1e18;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };


int main(){cout<<fixed<<setprecision(10);
		   int a,b,c,d;
           cin>>a>>b>>c>>d;
           if(a*b>c*d)cout<<a*b<<endl;
           else cout<<c*d<<endl;
}

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

typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;

#define mp make_pair
#define pb push_back
#define pf push_front
#define ss second
#define ff first
#define sz(x) (int)x.size()
#define newl "\n"
#define mem(x, val) memset(x, val, sizeof(x))
#define fastio                        \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL)
#define all(v) (v).begin(), (v).end()

const ld pi = 3.14159265359;
ll INF = 1e18 + 10;
ll MOD = 998244353;
ll mod = 1e9 + 7;

inline ll add(ll a, ll b, ll m)
{
    if ((a + b) >= m)
        return (a + b) % m;
    return a + b;
}

inline ll mul(ll a, ll b, ll m)
{
    if ((a * b) < m)
        return a * b;
    return (a * b) % m;
}

ll power(ll x, ll y, ll m)
{
    ll res = 1;
    x = x % m;
    if (x == 0)
        return 0;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % m;
        y = y >> 1;
        x = (x * x) % m;
    }
    return res;
}

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

void solve()
{
    ll x;
    cin >> x;
    if (x == 1)
    {
        cout << "1 0";
        return;
    }
    if (x == 2)
    {
        cout << "1 1";
        return;
    }
    for (ll i = 2; i < 4000; i++)
    {
        ll z = x;
        ll count = 0;
        while (z % i == 0)
        {
            z /= i;
            count++;
        }
        if (z == 1)
        {
            if (count==5)
            {
                cout << i << " 0";
                return;
            }
        }
    }
    for (ll i = 1; i < 4000; i++)
    {
        ll val = i * i * i * i * i;
        ll cal = abs(val - x);
        for (ll j = 2; j < 4000; j++)
        {
            ll count = 0;
            ll z;
            z = cal;
            while (z % j == 0)
            {
                z = z / j;
                count++;
            }
            if (z == 1)
            {
                if (count==5)
                {
                  	ll v=(val - x);
                    if (v<0)
                    {
                        cout << i << " " << -j;
                        return;
                    }
                    cout << i << " " << j;
                    return;
                }
            }
        }
    }
}

int main()
{
    fastio;
    int t;
    t = 1;
    //cin >> t;
    //int test=t;
    while (t-- > 0)
    {
        //cout<<"Case #"<<(test-t)<<": ";
        solve();
        //cout<<newl;
    }

    return 0;
}

Measured memory_bytes: 3652
if __name__ == "__main__":
    a = input()
    a = int(a)
    # not(0and9)
    not_0and9 = 8**a
    # not0
    not_0 = 9**a
    # not9
    not_9 = 9**a
    # not
    not_n = not_0 + not_9 - not_0and9
    n = 10**a - not_n
    print(n%(10**9+7))

Measured memory_bytes: 12184
#include <bits/stdc++.h>
#define rep(i, a, b) for (long long i = (a); i < (b); i++)
#define rep2(r, aa, bb) for (long long r = (aa)-1; r >= (bb); r--)

using namespace std;


int main()
{
    long long x, h;
    cin >> x >> h;
    if(x*500>=h){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}


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

int main() {
  int n, k;
  scanf("%d %d", &n, &k);
  vector<int> h(n);
  for (int i = 0; i < n; i++)
    scanf("%d", &h[i]);

  long long s = 0;
  sort(h.begin(), h.end());
  for (int i = 0; i < n - k; i++)
    s += h[i];
  printf("%lld\n", s);

  return 0;
}

Measured memory_bytes: 1024
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long int ll;
typedef vector< int > vi;
typedef pair< int, int > ii;
typedef vector< ii > vii;
typedef vector< ll > vll;
// #define DEBUG_MODE
#ifdef DEBUG_MODE
	#define debug(...) fprintf(stderr, __VA_ARGS__)
#else
	#define debug(...)
#endif

int n, m, k;
char s[100010];
char z[100010];
int a[100010];

int main () { 
#ifdef DEBUG_MODE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	scanf("%d%d", &n, &k);
	scanf("%s", s);

	m = 0;
	z[m] = '1';
	a[m] = 0;
	for (int i = 0; i < n; i++) {
		if (s[i] != z[m]) { m++; z[m] = s[i]; a[m] = 1; }
		else a[m]++;
	}
	if (z[m] != '1') { m++; z[m] = '1'; a[m] = 0; }
	m++;

	// for (int i = 0; i < m; i++) printf("%d ", a[i]);
	// printf("\n");
	// printf("%s\n", z);

	for (int i = 1; i < m; i++) a[i] += a[i - 1];
	k = 2 * k + 1;
	int ans = 0;
	if (k >= m) ans = a[m - 1];
	else {
		for (int i = k - 1; i < m; i++) if (z[i] == '1') {
			int tmp = a[i];
			if (i - k >= 0) tmp -= a[i - k];
			ans = max(ans, tmp);
		}
	}
	printf("%d\n", ans);
}

Measured memory_bytes: 768
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <list>

using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(d) string(1,d)
#define print(x) cout<<#x<<" = "<<x<<endl;

#define MOD 1000000007

int main() {
  ll n,d;
  cin>>n>>d;
  if(d==1){
    cout << n*(n-1)/2 << endl;
    return 0;
  }
  ll a = n-(d-1);
  ll b = a-2;
  cout << a*(a-1)/2+b+d-1 << endl;
  return 0;
}

Measured memory_bytes: 1156
#include<stdio.h>

int main(void){
    int num[3];
    int i,j;
    int buffer = 0;

    for(i = 0; i < 3; i++){scanf("%d", &num[i]);}
    for(i = 0; i < 2; i++){
        for(j = i+1; j< 3; j++){
            if(num[i] > num[j]){
                buffer = num[i];
                num[i] = num[j];
                num[j] = buffer;
            }
        }
    }
    for(i = 0 ; i < 3; i++){
        printf("%d", num[i]);
        if(i < 2){
        printf(" ");        
        }
    }
    printf("\n");

    return 0;
}



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

int main() {
  string S, T;
  cin >> S >> T;
  int ans = 1001;
  rep(i, S.size() - T.size() + 1) {
    int cnt = 0;
    rep(j, T.size()) {
      if (S.at(i + j) != T.at(j)) cnt++;
    }
    ans = min(ans, cnt);
  }
  cout << ans << endl;
}


Measured memory_bytes: 3624
import sys
n=int(input())
data=list(map(int,input().split()))
num=1
if any(i==0 for i in data):
    print(0)
    sys.exit()
else:
    for i in data:
        num*=i
        if 10**18<num:
            print(-1)
            sys.exit()
print(num)

Measured memory_bytes: 21644
#pragma gcc optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;

int a[4] = {300000, 200000, 100000, 0};

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int x, y, ans = 0;
    cin >> x >> y;
    --x, --y;
    if (x > 3) x = 3;
    if (y > 3) y = 3;
    ans += a[x] + a[y];
    if (!x && !y) ans += 400000;
    cout << ans << '\n';
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <math.h>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <climits>
#include <bitset>
#include <list>
#include <map>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

int main(){
    ll q, h, s, d, n;
    cin >> q >> h >> s >> d >> n;
    ll h_min, s_min, d_min;
    h_min=min(h, 2*q);
    s_min=min({s, 2*h_min, 4*q});
    d_min=min(d, 2*s_min);
    ll ans=n*s_min;
    if(2*s_min>d_min) ans-=(2*s_min-d_min)*(n/2);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main(){
	int n,count=0;
	bool ch;
	string name,a;
	cin>>n;
	cin>>name;
	for(int i=0;i<n;i++){
		cin>>a;
		ch=false;
		for(int lon=1;lon<a.size();lon++){
			for(int first=0;first+(name.size()-1)*lon<a.size();first++){
				bool t=true;
				for(int j=0;j<name.size();j++){
					if(a[first+(lon*j)]!=name[j])
						t=false;
				}
				if(t==true)
					ch=true;
			}
		}
		if(ch==true)
			count++;
	}
	cout<<count<<endl;
	return 0;
}

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

int main(){
 int d[6],tmp;
 char s; 

 for(int i=0;i<6;i++){
  cin >> d[i] ;
 }
 
 while(cin >> s){
  if(s=='E'){
   tmp=d[0];
   d[0]=d[3];
   d[3]=d[5];
   d[5]=d[2];
   d[2]=tmp;
  }
  if(s=='N'){
   tmp=d[0];
   d[0]=d[1];
   d[1]=d[5];
   d[5]=d[4];
   d[4]=tmp;
  }
  if(s=='S'){
   tmp=d[0];
   d[0]=d[4];
   d[4]=d[5];
   d[5]=d[1];
   d[1]=tmp;
  }
  if(s=='W'){
   tmp=d[0];
   d[0]=d[2];
   d[2]=d[5];
   d[5]=d[3];
   d[3]=tmp;
  }
 }
 
 cout << d[0] << endl ;

 return 0;
}

 

Measured memory_bytes: 3084
#include<stdio.h>
void main(){
int H,W;//たてH、よこW//
	while(1){
		scanf("%d %d",&H,&W);
		if(W==0||H==0)break;
	for(int i=1;i<=H;i++){
for(int j=1;j<=W;j++){
printf("#");
}printf("\n");
		
}printf("\n");}
}


Measured memory_bytes: 2048
#include <iostream>
#include <iomanip>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
#include <numeric>
#include <queue>
#include <sstream>
#include <bitset>
#include<stack>

using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;

template<typename T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }

template<typename T>
map<T, T> getPrimeFactor(T n) {
	map<T, T> res;
	for (T i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			res[i] ++;
			n /= i;
		}
	}
	if (n != 1) res[n] = 1;
	return res;
}

template<typename T>
bool IsPrimeNumber(T num)
{
	if (num <= 2) return true;
	else if (num % 2 == 0) return false;

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	return true;
}

long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}


#define in(x) cin >> x
#define out(x) cout << x
#define outn(x) cout << x << '\n'
#define outs(x) cout << x << ' '
#define rep(i,s,e) for(ll i=s;i<e;i++)
#define repeq(i,s,e) for(ll i=s;i<=e;i++)


int main() {
	ll n, m,ans=1;
	const ll mod = 1e9 + 7;
	std::cin >> n >> m;
	if (abs(n - m) > 1) {
		std::cout << 0 << endl;
		return 0;
	}

	repeq(i, 1, n) {
		ans = (ans*i)%mod;
	}
	repeq(i, 1, m) {
		ans = (ans*i)%mod;
	}

	if (n == m) {
		ans = (ans*2)%mod;
	}
	std::cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    char S[10];
    scanf("%s",S);

    if(S[0]==S[1]){
        if(S[2]==S[3]){
            if(S[0] != S[2]){
                printf("Yes");
            }else{
                printf("No");
        }}else{
            printf("No");
    }}else if(S[0]==S[2]){
        if(S[1]==S[3]){
            if(S[0]!=S[1]){
                printf("Yes");
            }else{
                printf("No");
        }}else{
            printf("No");
    }}else if(S[0]==S[3]){
        if(S[1]==S[2]){
            if(S[0]!=S[1]){
                printf("Yes");
            }else{
                printf("No");
        }}else{
            printf("No");
    }}else{
        printf("No");
    }
}

Measured memory_bytes: 128
#include<iostream>
#include<cctype>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<cctype>
#include<cstring>
#include<utility>
#include<cmath>
#include <string>
using namespace std;


int main() {
    string c1, c2;
    cin >> c1 >> c2;

    if (c1[0] == c2[2] && c1[1] == c2[1] & c1[2] == c2[0])cout << "YES" << endl;
    else cout << "NO" << endl;

    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast,inline,unroll-loops,fast-math")
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <climits>
#define N 18
using namespace std;

int a[N];

long long DP(int l, int r, int x, int y)
{
    int i;
    long long o;

    if(l + 1 == r)
        return (long long)a[l] * x + (long long)a[r] * y;

    for(i = l + 1, o = LLONG_MAX; i < r; i ++)
        o = min(o, DP(l, i, x, x + y) + DP(i, r, x + y, y) - (long long)a[i] * (x + y));

    return o;
}

int main(void)
{
    int n;
    int i;

    cin >> n;
    for(i = 0; i < n; i ++)
        cin >> a[i];
    cout << DP(0, n - 1, 1, 1) << endl;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

#define MAX 100
#define INF 100000000

int main() {
  int n, m, i, j, k, l, M[MAX][MAX], r[MAX], c[MAX], p[MAX];

  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    scanf("%d%d", &r[i], &c[i]);
  }

  p[0] = r[0];
  for (i = 1; i <=  n; i++) {
    p[i] = c[i - 1];
  }
  for (i = 0; i <= n; i++) {
    M[i][i] = 0;
  }
  for (i = 2; i <= n; i++) {
    for (j = 1; j <= n - i + 1; j++) {
      k = i + j - 1;
      M[j][k] = INF;
      for (l = j; l <= k - 1; l++) {
	m = M[j][l] + M[l + 1][k] + p[j - 1] * p[l] * p[k];
	if (m < M[j][k]) {
	  M[j][k] = m;
	}
      }
    }
  }

  printf("%d\n", M[1][n]);
  
  return 0;
}



Measured memory_bytes: 2104
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define SORT(x) sort((x).begin(),(x).end())
int main()
{
	int n,m,ans=0;
	vector<int> v1,v2;
	cin >> n >> m; 
	for(int i=0;i<n;i++)
	{
		int k;
		cin >> k;
		v1.pb(k);
	}
	for(int i=0;i<m;i++)
	{
		int k;
		cin >> k;
		v2.pb(k);
	}
	for(int i=0;i<v2.size();i++)
	{
		int s=i,t=0;
		while(s<v2.size()&&t<v1.size())
		{
			if(v2[s]==v1[t])
			{
				s++;
				ans=max(ans,s-i);
			}
			t++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1288
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<(n);i++)
#define MOD 1000000007
#define all(n) (n).begin(),(n).end()
typedef long long ll;
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}else{return 0;}}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}else{return 0;}}
template <class T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <class T> inline T LCM(T a,T b){return a*b/GCD(a,b);}

int main(){
	int n;
	cin >> n;
	double v[100];
	FOR(i,n){
		cin >> v[i];
	}
	sort(v,v+n);
	double x=v[0];
	for(int i=1;i<n;i++){
		x=(x+v[i])/2;
	}
	cout << fixed  << setprecision(10);
	cout << x << endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <map>
#include <set>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <stack>
#include <queue>
#include <utility>
#define rep(i,l,n) for(int i=l;i<n;i++)
#define rer(i,l,n) for(int i=l;i<=n;i++)
#define rrep(i,n,l) for(int i=n-1;i>=l;i--)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define pb(a) push_back(a);
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef vector<int> vi;
typedef vector<lint> vli;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

int d[10010][1261];
//int e[10010][1261];

int main(){
	int N,M,r;
	while(1){
		cin>>N>>M;
		if(N+M==0) break;
		cin>>r;
		memset(d,0,sizeof(d));
		//memset(e,0,sizeof(e));
		int t,n,m,s;
		rep(i,0,r){
			cin>>t>>n>>m>>s;
			if(s==1){
				d[m][t]++;
			}else{
				d[m][t]--;
			}
		}
		rep(j,1,M+1){
			rep(i,541,1261){
				d[j][i]+=d[j][i-1];
			}
		}
		rep(j,1,M+1){
			rep(i,540,1261){
				if(i==540){
					if(d[j][i]>0) d[j][i]=1;
					else d[j][i]=0;
				}else{
					if(d[j][i]>0) d[j][i]=d[j][i-1]+1;
					else d[j][i]=d[j][i-1];
				}
				//if(j==1 && 777<=i && i<=900) cout<<j<<" "<<i<<" "<<e[j][i]<<endl;
			}
			//cout<<endl;
		}
		int q;
		cin>>q;
		int ts,te,mm;
		rep(i,0,q){
			cin>>ts>>te>>mm;
			o(d[mm][te-1]-d[mm][ts-1]);
		}
	}
}

Measured memory_bytes: 50476
#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;

int main() {
    string s;
    int k;
    cin >> s >> k;
    int n = s.size();

    set<string> st;

    rep(i, n) {
        for(int j = 1; j <= k; j++) {
            if(i+j-1 < n) {
                string t = s.substr(i, j);
                st.insert(t);
            }
        }
    }

    auto pos = st.begin();
    rep(i, k-1) {
        pos++;
    }

    cout << *pos << endl;
    return 0;
}

/* setの要素を全て出力したい場合は以下のように書く 

    for(auto pos = st.begin(); pos != st.end(); pos++) {
        cout << *pos << "\n";
    }
    
*/


Measured memory_bytes: 1664
import java.util.Scanner;
import java.util.stream.Stream;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String line = sc.nextLine();
    //Split by '' and Convert String Array to Int Array
    int[] TARGET_NUMBERS = Stream.of(line.split(" ")).mapToInt(Integer::parseInt).toArray();
    int total = 0;

    line = sc.nextLine();
    //Split by '' and Convert String Array to Int Array
    int[] inputArray = Stream.of(line.split(" ")).mapToInt(Integer::parseInt).toArray();
    int numberOfTimes = inputArray[0];

    int max = 0;

    for (int i = 0; i< TARGET_NUMBERS.length;i++){
      max = Math.max(max, TARGET_NUMBERS[i]);
    }

    int power = max;
    for (int i = 0; i< numberOfTimes;i++){
      power = power*2;
    }

    total = TARGET_NUMBERS[0] + TARGET_NUMBERS[1] + TARGET_NUMBERS[2] + power - max;

    System.out.print(total);

  }
}

Measured memory_bytes: 27860
#include <iostream>
#include <iomanip>
#include <fstream>
#include <string>
#include <array>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <queue>
#include <bitset>
#include <tuple>
#include <cmath>
#include <complex>
#include <algorithm>
#include <utility>
#include <regex>
#include <cstdint>
#include <numeric>
#include <functional>
#include <cassert>

using namespace std;
using ll = int64_t;
using ull = uint64_t;

constexpr ll INF = 1'000'000'000'000'000'000;
namespace utils{
    template<class T, class Compare> using p_queue = priority_queue<T, vector<T>, Compare>;
    template<class T> using min_queue = p_queue<T, greater<T>>;
    template<class T> using max_queue = p_queue<T, less<T>>;

    template<class T> bool min_update(T& X, const T& A){ if(X > A) {X = A; return true;} return false; }
    template<class T> bool max_update(T& X, const T& A){ if(X < A) {X = A; return true;} return false; }
    using V_Set = unordered_set<int>;
    using E_Set = unordered_map<int, V_Set>;

    ll operator"" _64(unsigned long long x){ return ll(x); }

    ull operator"" _64u(unsigned long long x){ return ull(x); }

#define ALL(x) begin(x), end(x)
#define rALL(x) rbegin(x), rend(x)
}
using namespace utils;


void sub_main(istream &is) {
    ll N, D;
    is >> N >> D;
    if(!is) return;
    map<int, int> dd;
    for (int i = 1; i*i < 100000; ++i) {
        dd[i*i] = 1;
    } // end i
    vector<vector<int>> X;
    for (int i = 0; i < N; ++i) {
        X.emplace_back(D);
        for (int j = 0; j < D; ++j) {
            is >> X[i][j];
        } // end j
    } // end i
    ll count = 0;
    for (int i = 0; i < N; ++i) {
        for (int j = i + 1; j < N; ++j) {
            ll d2 = 0;
            for (int k = 0; k < D; ++k) {
                ll t = X[i][k] - X[j][k];
                d2 += t*t;
            } // end k
            count += dd.count(d2);
        } // end j
    } // end i

    cout << count << endl;
}

int main(int argc, char *argv[]) {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << setprecision(16) << scientific;
#ifdef DEBUG
    string test_cases = "test_B.txt";
    cerr << "DEBUG MODE" <<  endl;
    cerr << test_cases << " -->" << endl;
    auto fs = fstream(test_cases, fstream::in);
    int lp = 0;
    while(fs) {
        lp++;
        cout << lp <<  "#------\n";
        sub_main(fs);
    }
    cout << "------#" << endl;
    if(lp <= 1) sub_main(cin);
#else
    sub_main(cin);
#endif
    return 0;
}


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

int main(void){
    int N;  cin>>N;
    int s[N];  for(int i=0; i<N; i++) cin>>s[i];
    sort(s, s+N);

    int sum = 0;
    for(int i=0; i<N; i++) sum += s[i];

    if(sum%10==0){
        for(int i=0; i<N; i++){
            if(s[i]%10){
                sum -= s[i];
                break;
            }
        }
    }

    if(sum%10==0) sum = 0;

    cout << sum << endl;

    return 0;
}


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

using namespace std;

#define rep(i,m,n) for(int (i)=(int)(m);i<(int)(n);i++)
#define rep2(i,m,n) for(int (i)=(int)(n)-1;i>=(int)(m);i--)
#define REP(i,n) rep(i,0,n)
#define REP2(i,n) rep2(i,0,n)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define ll long long
#define ull unsigned long long
#define all(hoge) (hoge).begin(),(hoge).end()
#define en '\n'
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
typedef pair<ll, ll> P;
constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;
constexpr long long MOD = (ll) 1e9 + 7;
typedef vector<ll> Array;
typedef vector<Array> Matrix;


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;
}

struct Edge {
	ll to, cap, rev;
	Edge(ll _to, ll _cap, ll _rev) {
	to = _to; cap = _cap; rev = _rev;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

void add_edge(Graph& G, ll from, ll to, ll cap, bool revFlag, ll revCap) {
	G[from].push_back(Edge(to, cap, (ll)G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}


void solve(){
    ll n;
    cin>>n;
    ll ans=0;
    REP(i,n){
        ll t=i+1;
        if(t%3==0||t%5==0) continue;
        ans+=t;
    }
    cout<<ans<<en;
}

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

    solve();
    //ll t;cin>>t;REP(i,t) solve();

    return 0;
}


Measured memory_bytes: 3652
#include <stdio.h>
int main(void)
{
	int i,j,k,n,x,count;
	while(1){
		scanf("%d %d",&n,&x);
		if(n==0 && x==0) break;
		count=0;
		for(i=1;i<n-1;i++){
			for(j=i+1;j<n;j++){
				for(k=j+1;k<=n;k++){
					if(i+j+k==x)
						count++;
				}
			}
		}
		printf("%d\n",count);
	}
	return 0;
}

Measured memory_bytes: 600
// https://atcoder.jp/contests/dp/tasks/dp_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 (1e9 + 7)
#define LINF (1e18)
#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()
// int gcd(long a, long b) { return b ? gcd(b, a % b) : a; }
// int lcm(long a, long b) { return a * b / gcd(a, b); }

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, k;
    cin >> n >> k;
    vector<int> h(n + k, INF);
    REP(i, n) cin >> h[i];
    // 入力値の足場の高さHの差分の合計を最小化する
    vector<int> dp(n + k, INF);
    dp[0] = 0;
    // 配るDP
    // for (int i = 0; i < n; i++) {
    //     for (int j = 1; j <= k; j++) {
    //         dp[i + j] = min(dp[i + j], dp[i] + abs(h[i + j] - h[i]));
    //     }
    // }

    // 貰うDP
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= k && i - j >= 0; j++) {
            dp[i] = min(dp[i], dp[i - j] + abs(h[i - j] - h[i]));
        }
    }
    cout << dp[n - 1] << endl;

    return 0;
}

Measured memory_bytes: 1024
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DPL_1_D
// Pattern - Combinatorial - Longest Increasing Subsequence
// status: [solve][review]

#define SUBMIT

#include <iostream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;
using ui64 = unsigned long long;
using i64 = long long;

const int MAX_N = 100000;
int a[MAX_N];
int L[MAX_N + 1];
int length;
int n;

int compute_lis() {
    L[0] = a[0];
    length = 1;

    for (int i = 1; i < n; ++i) {
        if (L[length - 1] < a[i]) {
            L[length] = a[i];
            length++;
        } else {
            *lower_bound(L, L + length, a[i]) = a[i];
        }
    }

    return length;
}

int main() {
#ifdef SUBMIT
    auto& stream = cin;
#else
    string program_input_str = R"(5
5
1
3
2
4
)";
    stringstream stream(program_input_str);
#endif
    stream >> n;
    for (int i = 0; i < n; ++i) {
        stream >> a[i];
    }

    cout << compute_lis() << endl;
    return 0;
}



Measured memory_bytes: 3820
#C - Traveling Salesman around Lake WA(ヒント)
K,N = map(int,input().split())
A = list(map(int, input().split()))

A[N+1:] = [A[0] + K]#Aを二回繰り返して円を表現

distance_list = []
for i in range(N):
    distance = abs(A[i] - A[i+1])
    distance_list.append(distance)
distance_list.remove(max(distance_list))
print(sum(distance_list))

Measured memory_bytes: 93956
class UnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n+1)]
        self.rank = [0] * (n+1)

    # 検索
    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    # 併合
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
        else:
            self.par[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    # 同じ集合に属するか判定
    def same_check(self, x, y):
        return self.find(x) == self.find(y)

N, M = [int(x) for x in input().split()]

uf = UnionFind(N)
p = [int(x) for x in input().split()]
for m in range(M):
    x, y = [int(x) for x in input().split()]
    uf.union(x, y)

res = 0
for i in range(N):
    if uf.same_check(i+1, p[i]):
        res += 1
print(res)

Measured memory_bytes: 18608
import java .util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner (System.in);

		int inputN = sc.nextInt();

		if(inputN >= 30) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}

}


Measured memory_bytes: 35628
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=100003,INF=1<<30;

vector<int> dx={-1,0,-1,0},dy={-1,-1,0,0},tox={0,1,0,1},toy={0,0,1,1};

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N;cin>>N;
    vector<pair<int,int>> S(N);
    vector<int> T(N);
    map<pair<int,int>,int> MA;
    
    for(int i=0;i<N;i++){
        cin>>S[i].first>>S[i].second>>T[i];
        MA[{S[i].first,S[i].second}]=T[i];
    }
    
    int ans=0;
    
    for(int i=0;i<N;i++){
        for(int from=0;from<4;from++){
            int sum=0;
            for(int to=0;to<4;to++){
                sum+=MA[{S[i].first+dx[from]+tox[to],S[i].second+dy[from]+toy[to]}];
            }
            ans=max(ans,sum);
        }
    }
    
    cout<<ans<<" / 1"<<endl;
}




Measured memory_bytes: 60356
// https://atcoder.jp/contests/dp/tasks/dp_a
// https://qiita.com/drken/items/dc53c683d6de8aeacf5a

#include <stdio.h>
#include <cmath>
#include <algorithm>
#define _USE_MATH_DEFINES

#define N_MAX (100000)
#define K_MAX (100)

using namespace std;


int main(){
    int N_input;
    int K_input;
    int h[N_MAX+10];
    long long int cost[N_MAX+10];

    scanf("%d %d", &N_input, &K_input);

    for(auto i=1; i<=N_input; i++){
        scanf("%d", &h[i]);
    }

    for(auto i=2; i<=N_MAX; i++){
        cost[i] = 1LL << 60;
        
        for(auto j=max(1,i-K_input); j<=i-1; j++){
            cost[i] = min(cost[i], cost[j] + abs(h[j] - h[i]));
        }
    }

    printf("%lld", cost[N_input]);
    
}

Measured memory_bytes: 1280
#include <iostream>
#include <algorithm>
#include <tuple>
#include <vector>
#include <string>
#include <queue>
#include <cmath>
#include <iomanip>

using namespace std;

int main()
{
    long long a, v, b, w, t;
    cin >> a >> v >> b >> w >> t;
    if (v - w <= 0){
        cout << "NO" << endl;
    }
    else if( abs(b - a) <= t * (v-w))
    {
        cout << "YES" << endl;        
    }else{
        cout << "NO" << endl;
    }
 
    return 0;
}


Measured memory_bytes: 3620