akhauriyash/Code-Regression huggingface dataset:
def gcd(a, b):
    a, b = max(a, b), min(a, b)
    if b == 0:
        return a
    return gcd(b, a % b)


def main():
    N, X = map(int, input().split())
    C = list(map(int, input().split()))
    C = [abs(x-X) for x in C]
    retval = C[0]
    for i in range(1, N):
        retval = gcd(retval, C[i])
    print(retval)


if __name__ == "__main__":
    main()


Measured memory_bytes: 63512
/*?????????(Average)*/
#include <stdio.h>
int main(){
  int A, B, C, D, E, average;
  scanf("%d %d %d %d %d", &A, &B, &C, &D, &E);
  if (A < 40) {
    A = 40;
  }
  if (B < 40) {
    B = 40;
  }
  if (C < 40) {
    C = 40;
  }
  if (D < 40) {
    D = 40;
  }
  if (E < 40) {
    E = 40;
  }
  average = (A + B + C + D + E) / 5;
  printf("%d\n", average);
  return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
#define MAX 1000000007
#define ll long long int
#define fo(i,a,n) for(int i=a;i<n;i++)
#define ull unsigned long long int
#define pb push_back
#define eb emplace_back
using namespace std;


int main(){

    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    // int t;
    // cin>>t;

    // while(t--){
    // }

    int x;
    cin>>x;
    if(x==0)
        cout<<1<<endl;
    else if(x==1)
        cout<<0<<endl;


    return 0;
}

Measured memory_bytes: 3688
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cwchar>
#include <cwctype>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <codecvt>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize("Ofast")
using namespace std;
typedef int64_t ll;
typedef long double ld;
const ll INF=(1LL<<60);
const ld pi=acosl((ld)1);
const ll mod = 1000000007;
const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};
const int ddx[8]={1,0,-1,-1,-1,0,1,1};
const int ddy[8]={1,1,1,0,-1,-1,-1,0};

#define endN "\n"

bool solve(){
  ll x,y;cin>>x>>y;
  ll ans=0;
  while(x<=y){
    x*=2;
    ans++;
  }
  cout<<ans<<endl;
  return false;
}

signed main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout<<fixed;
	cout<<setprecision(30);
  // ll Q;cin>>Q;
	// while(Q--)solve();
  solve();
}


Measured memory_bytes: 256
#include<iostream>
using namespace std ;
#define  ll long long int 
#define pb push_back 
#include<bits/stdc++.h>

int main()
{
    ll n ;
    cin >> n ;
vector<ll> arr;
for( ll i= 0 ; i < 2*n ;i++) {
    ll  k ;
    cin>> k ; 
    arr.pb(k );
}
sort(arr.begin() , arr.end()) ;
ll sum = 0;
for( ll i=0 ; i< n ;i++ )
{
    sum+= min(arr[2*i] , arr[2*i+1]) ;
    
}
cout <<sum ;
return  0 ;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	static Scanner scanner;
	public static void main(String[] args) {
	    scanner = new Scanner(System.in);

	    int N=gi();
	    String S=gs();
	    int K=gi();
	    char c=S.charAt(K-1);
	    StringBuilder sb=new StringBuilder();
	    for (int i=0; i<N;i++) {
	    	if (S.charAt(i)==c) {
	    		sb.append(c);
	    	} else {
	    		sb.append("*");
	    	}
	    }
	    System.out.println(sb.toString());
	}

	public static double f(double r, double n, double m, double i) {
		double a = 0;
		double b=0;
		if(0<i&&i<n) {
			a=Math.abs(r-((2*r/n)*i));
			a= Math.sqrt(Math.pow(r, 2) - Math.pow(a, 2));
		}
		if(0<i-m&&i-m<n) {
			b=Math.abs(r-(2*r*(i-m)/n));
			b=Math.sqrt(Math.pow(r, 2) - Math.pow(b, 2));
		}
		return 2* Math.max(a, b);
	}
	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}

	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

Measured memory_bytes: 35588
#include <bits/stdc++.h>
#include <string.h>
#define ll long long
using namespace std;
struct value
{
	ll x;
	ll y;
};
bool compare(value a, value b)
{
	//for descending order replace with a.roll >b.roll
	if (a.y < b.y)
		return 1;
	else
		return 0;
}
void pk()
{
	ll n;
	cin>>n;
	if(n%1000==0)
	   cout<<0;
	else
	cout<<(((n/1000)+1)*1000)-n;	
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
		pk();
	
	
}

Measured memory_bytes: 3644
import java.util.Scanner;
public class Main{
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int a=scan.nextInt();
		int b=scan.nextInt();
		if(a-b<=0) {
			System.out.println("0");
		}
		else {
			System.out.println(a-b);
		}
	}
}

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

int main() {
  string S;
  cin >> S;
  
  string ans = "Yes";
  
  for (int i = 0; i < S.size(); i++) {
    if (i % 2 == 0 && S.at(i) == 'L') {
      ans = "No";
      break;
    }
    if (i % 2 == 1 && S.at(i) == 'R') {
      ans = "No";
      break;
    }
  }
  
  cout << ans << endl;
  
}

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

using namespace std;
using ll =long long;
typedef pair<int,int> P;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
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; }
//Write From this Line

int main()
{
	int n;
	cin >> n;
	int ans = 1e9;
	for(int a = 1; a <= n-1; a++){
		int A = a;
		int B = n - a;
		int tmp = 0;
		while(A!=0){
			tmp += A % 10;
			A /= 10;
		}
		while(B!=0){
			tmp += B % 10;
			B /= 10;
		}
		chmin(ans,tmp);
	}
	cout << ans << endl;
}


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

class trans {
public:
    void operator ()(char &c)
    {
        if (isalpha(c)) c = toupper(c);
    }
};

int main()
{
    std::string s;
    getline(std::cin, s);
    std::for_each(s.begin(), s.end(), trans());
    std::cout << s << std::endl;
}

Measured memory_bytes: 1176
N = int(input())
ls = []
for i in range(N):
  s = input().split()
  ls.append(s)
X = input()
ans = 0
mode = 0
for i in range(N):
  if ls[i][0] == X:
    mode = 1
  else:
    if mode == 1:
      ans += int(ls[i][1])
print(ans)

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

  int main() {
    int t[4];
    for (int i = 0; i < 4; i++) cin >> t[i];
    int k;
    cin >> k;
    
    cout << t[2] * 60 + t[3] - t[0] * 60 - t[1] - k << endl;
  }

Measured memory_bytes: 3636
#include <stdio.h>

int main(void)
{
	int a,b;

	scanf("%d %d",&a,&b);

	if (a<b)
		printf("a < b\n");
	else if (a > b)
		printf("a > b\n");
	else
		printf("a == b\n");

	return 0;
}

Measured memory_bytes: 580
#include "bits/stdc++.h"
#define fi first
#define se second
#define all(x) x.begin(), x.end()
#define setp(x) setprecision(x)
#define nep(x) next_permutation(x);
using namespace std;
using ull = unsigned long long;
using ll = long long;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;

int main() {
    double W, H, x, y;
    cin >> W >> H >> x >> y;
    cout << W * H / 2 << endl;
    if(H / 2 == y and W / 2 == x) puts("1");
    else puts("0");
}


Measured memory_bytes: 256
/*************************************************************************
    > File Name: solve.cpp
    > Author: liupo
    > Mail: lanzongwei@gmail.com
    > Created Time: 2020-05-03 20:12:02
 ************************************************************************/

#define GOODOJ
#define SYNC 0

#ifdef GOODOJ
#include <bits/stdc++.h>
#include <ext/pb_ds/priority_queue.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>
#include <chrono>
#include <random>
using namespace __gnu_pbds;
using namespace __gnu_cxx;
#else
#include <iostream>
#include <cstdio>
#include <cmath>
#include <set>
#include <algorithm>
#include <cstring>
#include <string>
#include <map>
#include <deque>
#include <vector>
#include <limits>
#include <cassert>
#include <sstream>
#include <iterator>
#include <functional>
#endif
using namespace std;

#define endl '\n'
#define fep(i,b,e) for(int i=(b);i<(e);++i)
#define rep(i,x) for(int i=0;i<(x);++i)
#define rap(i,x) for(auto& i : (x))
#define seg(t) (t).begin(), (t).end()
#define ep emplace_back
#define mkp make_pair
#define mkt make_tuple
#define qxx(i,x) for(int i = head[x]; ~i; i = node[i].nex)
#define F first
#define S second
#define lowbit(x) ((-(x))&(x))
#define RE register
#define getchar() getchar_unlocked()
#ifdef DEBUG
void err(istream_iterator<string>){}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << ' ';
    err(++it, args...);
}
#define debug(args...) {string _s=#args;replace(seg(_s),',',' ');\
cerr<<"DEBUG:";istringstream it(_s);\
err(istream_iterator<string>(it), args);cerr<<endl;}
#else
#define debug(...)
#endif

template<typename T> inline bool cmax(T& a,const T& b) {return a<b?a=b,1:0;}
template<typename T> inline bool cmin(T& a,const T& b) {return a>b?a=b,1:0;}

#ifdef GOODOJ
mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count());
typedef __gnu_pbds::priority_queue<int> pq;
#endif
typedef std::string str;
typedef long long ll;
typedef double db;
typedef pair<int, int> pa;

const double P = acos(-1.0), eps = 1e-9;
struct point { db x ,y;};
inline int sign(db a) {return a < -eps ? -1 : a > eps;}
#define dot(p1,p2,p3) ((p2.x-p1.x)*(p3.x-p1.x)+(p2.y-p1.y)*(p3.y-p1.y))
#define cross(p1,p2,p3) ((p2.x-p1.x)*(p3.y-p1.y)-(p3.x-p1.x)*(p2.y-p1.y))
#define crossOp(p1,p2,p3) sign(cross(p1,p2,p3))

const int Ma = 1e6, inf = 0x3f3f3f3f, mod = 1e9 + 7;

int aim[Ma];
signed main() {
    #if SYNC==0
    ios::sync_with_stdio(false);
    cin.tie(0);
    #endif
	int n, m; cin >> n >> m;
	vector<int> h(n);
	rep (i, n) cin >> h[i];
	rep (i, m) {
		int u, v;
		cin >> u >> v; u--, v--;
		if (h[u] > h[v]) ++aim[u], aim[v] = -inf;
		else if (h[v] > h[u]) ++aim[v], aim[u] = -inf;
		else aim[u] = aim[v] = -inf;
	}
	int ans = 0;
	rep (i, n) if (aim[i] >= 0) ++ans;
	cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 4056
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LS()
    return l
sys.setrecursionlimit(1000000)
mod = 1000000007

#A
def A():
    n,k = LI()
    print(n-k+1)
    return

#B
def B():
    n = I()

    return

#C
def C():
    n = I()

    return

#D
def D():
    n = I()

    return

#E
def E():
    n = I()

    return

#F
def F():
    n = I()

    return

#G
def G():
    n = I()

    return

#H
def H():
    n = I()

    return

#I
def I_():
    n = I()

    return

#J
def J():
    n = I()

    return

#Solve
if __name__ == "__main__":
    A()


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

int main(void){
  string s, t, ss;
  cin >> s >> t;
  ss = s;
  for(int i=0;i<s.size();++i){
   if(ss==t){
     cout << "Yes\n";
     return 0;
   }
   ss = ss[ss.size()-1] + ss.substr(0, ss.size()-1);
  }
  cout << "No\n";
}

Measured memory_bytes: 256
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		Set<String> set = new HashSet<>();
		
		for (int i = 0; i < n; i++) {
			String s = sc.next();
			set.add(s);
		}
		
		if (set.size() == 3) {
			System.out.println("Three");
		} else {
			System.out.println("Four");
		}

		sc.close();

	}

}


Measured memory_bytes: 35668
#include <bits/stdc++.h>
#define ff first
#define ss second
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
int main() {
  int k, x;
  cin >> k >> x;
  for (int i = x - k + 1; i <= x + k - 1; i++) {
    cout << i << ' ';
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>

typedef long long ll;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define print(x) cout<<(x)<<endl
#define rep(i,n) for(int i = 0;i < ((int)(n));++i)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define SUM(vec) accumulate(all(vec),0LL)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define test(a) cout<<"line:"<<__LINE__<<"["<<(#a)<<": "<<(a)<<"]"<<endl

const int INF = 1e9+7;
const ll INFL = 9*1e18;

ll inline digit(ll num){int tmp = 0;while(num){tmp++;num/=10;}return tmp;}
template<typename T>inline T digitSum(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;} // 各桁の和
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);}
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;}
template<typename T>inline T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;}


bool isOk(ll key,ll value){
  return key < value;
}

int binary_search(vector<ll> a,ll key){
  ll ok = key;
  ll ng = 0;

  while(abs(ok - ng) > 1){
    ll mid = (ok + ng) / 2;
    if(isOk(key,a[mid]))ok = mid;
    else ng = mid;
  }
  return ok;
}

int main() {
  cin.tie(0); ios::sync_with_stdio(0);
  ll n,k;cin>>n>>k;
  vector<pair<int,int> > ab(n);rep(i,n)cin>>ab[i].fi>>ab[i].se;
  sort(all(ab));
  ll tmp = 0;
  rep(i,n){
    tmp += ab[i].se;
    
    if(tmp >= k){
      print(ab[i].fi);
      return 0;
    }
  }
  print(ab[ab.size()-1].fi);
  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#include<vector>
#include<string>
#include<stack>
#include<iostream>
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define vec(a) vector<int>a
using namespace std;
//fibonacci
int binet(int n)
{
	return (pow((1+sqrt(5)),n-1)-pow((1-sqrt(5)),n-1))/(pow(2,n-1)*sqrt(5));
}


int main()
{
#ifndef ONLINE_JUDGE
	freopen("output.txt", "w", stdout);
	freopen("input.txt", "r", stdin);
#endif
	fastio
	string str;
	cin>>str;
	if(str=="SUN")
		cout<<7<<"\n";
	if(str=="MON")
		cout<<6<<"\n";
	if(str=="TUE")
		cout<<5<<"\n";
	if(str=="WED")
		cout<<4<<"\n";
	if(str=="THU")
		cout<<3<<"\n";
	if(str=="FRI")
		cout<<2<<"\n";
	if(str=="SAT")
		cout<<1<<"\n";
	return 0;
}
	

Measured memory_bytes: 3584
#include<iostream>
#include <stdlib.h>
using namespace std;

int main(){
	int n;//&#131;}&#131;X&#130;&#204;&#144;&#148;
	int sa,ga,sb,gb,dista,distb,sum;//s(g)a:&#131;X&#131;^&#129;[&#131;g(&#131;S&#129;[&#131;&#139;)&#146;n&#147;_a s(g)b:&#131;X&#131;^&#129;[&#131;g(&#131;S&#129;[&#131;&#139;)&#146;n&#147;_b dista(b):a(b)&#138;&#212;&#130;&#204;&#139;&#151;&#151;贈 sum:dista + distb
	
	cin >> n >> sa >> ga >> sb >> gb;
	
	sa--; ga--; sb--; gb--;
	
	sum=n*2;
	
	for(int i=1;i<=n;i++){
		dista=abs((sa/i)-(ga/i))+abs((sa%i)-(ga%i));
		distb=abs((sb/i)-(gb/i))+abs((sb%i)-(gb%i));
		
		if(sum>dista+distb)sum=dista+distb;
	}
	
	cout<<sum<<endl;
	
	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define rep(i,b) FOR(i,0,b)
#define INF 1e9
#define dump(x) cerr<<#x<<"="<<x<<endl
#define all(a) (a).begin(),(a).end()
typedef pair<int,int> P;
template <class T> void chmin(T & a, T const & b) { if (b < a) a = b; }
template <class T> void chmax(T & a, T const & b) { if (b > a) a = b; }
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
using ll = long long;
const ll mod = LLONG_MAX;

int N;
string s;
map<string,int> mp;
int a[5];
int main(){
  cin>>N;
  rep(i,N){
    cin>>s;
    if(s[0]=='M'){
      a[0]++;
    }else if(s[0]=='A'){
      a[1]++;
    }else if(s[0]=='R'){
      a[2]++;
    }else if(s[0]=='C'){
      a[3]++;
    }else if(s[0]=='H'){
      a[4]++;
    }
  }

  ll ans=0;

  for(int k=0;k+1<5;k++){
  for(int i=k+1;i<5;i++){
    ll ret = 1;
    for(int j=0;j<5;j++){
      if(i==j || k==j)continue;
      ret*=a[j];
    }
    ans+=ret;
  }
  }
  cout<<ans<<endl;


}


Measured memory_bytes: 384
#include <stdio.h>
#include <string>
#include <iostream>
#include <iomanip>
#include <map>
#include <algorithm>
#include <vector>
#include <math.h>
using namespace std;

int main(void) {
	long long a,b,c;
	cin >> a >> b >> c;
	if((a%2*b%2*c%2)==0){
		cout << 0 << endl;
		return 0;
	}
	cout << min(a*b,min(b*c,c*a)) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <queue>
#include <deque>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <unordered_map>
#include <iomanip>
#include <sstream>
#include <numeric>
using namespace std;
#define ll long long int
#define ld long double
#define vi vector<ll>
#define vvi vector<vi>
#define vs vector<string>
#define pi pair<ll,ll>
#define pb push_back
#define pf push_front
#define eb emplace_back
#define mp make_pair
#define fs first
#define se second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
int main() {
    ll n,k;
    cin>>n;
    k = 2;
    vi v(n);
    for(ll i=0;i<n;i++){
        cin>>v[i];
    }
    vi a(n,1e9);
    a[0] = 0;

    for(ll i=0;i<n;i++){
        for(ll j=(i+1);j<=(i+k) && j<n;j++){
            a[j] = min(a[j],a[i]+abs(v[i]-v[j]));
        }
    }

    cout<<a[n-1]<<endl;

}




Measured memory_bytes: 1920
import java.util.*;

class Main {
  public static void main (String[] args) {
    Scanner sc = new Scanner(System.in);
    
    int n = sc.nextInt();
    int[] a = new int[n];
    long kabu = 0;
    long money = 1000;
   
    for (int i=0; i<n; i++) {
      a[i] = sc.nextInt();
    }
    
    for (int i=1; i<n; i++) {
      if(a[i]>a[i-1]) {
        kabu = money / a[i-1];
        money = money % a[i-1];
        money += kabu*a[i];
        kabu = 0;
      }
    }
    
    System.out.println(money);
  }
}

Measured memory_bytes: 35520
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int a = input.nextInt();
        int b = input.nextInt();
        int c = input.nextInt();
        int k = input.nextInt();
        int ans = 0;
        int count = 0;
        int tmp;
        tmp = Math.min(a,k);
        count += tmp * 1;
        ans += tmp * 1;
        k = Math.max(k-tmp,0);
        tmp = Math.min(b,k);
        count += tmp * 1;
        ans += tmp * 0;
        k = Math.max(k-tmp,0);
        tmp = Math.min(c,k);
        count += tmp * 1;
        ans -= tmp * 1;
        k = Math.max(k-tmp,0);
        System.out.println(ans);
    }
}

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

int main(){
  int N,M;
  cin >>N;
  vector<int> t(N);
  rep(i,N) cin >>t[i];
  cin >> M;
  rep(i,M){
    int p,x;
    cin >>p >>x;
    int sum = 0;
    rep(i,N){
      if(i==p-1) sum += x;
      else sum += t[i];
    }
    cout << sum << endl;
  }
  return 0;
}

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

typedef unsigned int uint;

template <class F, class T>
void convert(const F &f, T &t){
  stringstream ss;
  ss << f;
  ss >> t;
}

long int pow(long int n, int m){
  if(m<=0){
    return 1;
  }else{
    return n * pow(n,m-1);
  }
}

int main(){
  int N;
  cin >> N;
  int a[N];
  int n;
  for(int i=0; i<N; ++i){
    cin >> n;
    a[n-1] = i;
  }
  long int ans = 0;
  long int l = -1, r = N;
  set<int> befs;
  for(long int i=0; i<N; ++i){
    set<int>::iterator it = befs.insert(a[i]).first;
    ++it;
    if(it == befs.end()){
      r = N;
    }else{
      r = (*it);
    }
    --it;
    if(it == befs.begin()){
      l = -1;
    }else{
      --it;
      l = (*it);
    }
    ans += (i+1) * (r-a[i]) * (a[i]-l);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 10368
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <cctype>
#include <cstring>
#include <set>
#include <map>
#define rep(i, m, n) for (int i = m; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define ll long long
#define ull unsigned long long
#define push(a) push_back(a)
#define pop(a) pop_back(a)
#define debug(x) cout << #x << ": " << x << endl
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

ll a,b,c,d,e,f,g;

int main(){
    cin >> a >> b;
    cout<<b*2-a<<endl;
}

Measured memory_bytes: 256
# ABC106 D - AtCoder Express 2
n,m,q=map(int,input().split())
mat=[[0]*(n+1) for i in range(n+1)]
for i in range(m):
    l,r=map(int,input().split())
    mat[l][r]+=1

for i in range(n+1):
    for j in range(n+1):
        mat[i][j]+=mat[i-1][j]
for i in range(n+1):
    for j in range(n+1):
        mat[i][j]+=mat[i][j-1]

for i in range(q):
    l,r=map(int,input().split())
    ans=mat[r][r]+mat[l-1][l-1]-mat[l-1][r]-mat[r][l-1]
    print(ans)

Measured memory_bytes: 13532
def main():
    buf = input()
    S = buf
    first = int(S[0:2])
    second = int(S[2:4])
    if first == 0 and second == 0:
        print('NA')
        return
    elif 1 <= first and first <= 12:
        if 1 <= second and second <= 12:
            print('AMBIGUOUS')
            return
        else:
            print('MMYY')
            return
    elif 1 <= second and second <= 12:
        print('YYMM')
        return
    else:
        print('NA')
        return

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <iostream>

using namespace std;

bool isVisited[50][50] = { false };
int isLand[50][50] = { 0 };

void dfs(int x, int y, int w, int h)
{
  if (x < 0 || x >= w || y < 0 || y >= h) return;
  if (isVisited[x][y] == true) return;
  if (isLand[x][y] == 0) return;

  isVisited[x][y] = true;

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

  for (int i = 0; i < 8; i++) {
    dfs(x + dx[i], y + dy[i], w, h);
  }
}

int main()
{
  int w, h;
  while (1) {
    cin >> w >> h;
    if (w == 0 && h == 0) break;
    
    for (int i = 0; i < h; i++) {
      for (int j = 0; j < w; j++) {
        cin >> isLand[j][i];
        isVisited[j][i] = false;
      }
    }

    int count = 0;
    for (int i = 0; i < h; i++) {
      for (int j = 0; j < w; j++) {
        if (isVisited[j][i] == false && isLand[j][i] == 1) {
          dfs(j, i, w, h);
          count++;
        }
      }
    }
    cout << count << endl;
  }
}



Measured memory_bytes: 3416
# p (0..6).to_a.map{|j| [6 ** j, 9 ** j] }.flatten.uniq.sort
a = [1, 6, 9, 36, 81, 216, 729, 1296, 6561, 7776, 46656, 59049, 531441]

m, dp = gets.to_s.to_i, [0]
(1..m).each {|i|
  t = 987654321
  idx = (a.bsearch_index{|j| i < j } || 13 ) - 1 # p a.size => 13
  (a[0..idx]).map{|j| i - j }.each{|c| t = dp[c] if t > dp[c] }
  dp.push(t + 1)
}
puts dp[-1]

Measured memory_bytes: 2812
import java.util.*;


public class Main {
    public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int ans = 0;
		
		int[] xs = new int[5];
		for (int i = 0; i<5; i++) {
		    xs[i] = sc.nextInt();
		    if (xs[i] == 0) {
		    ans = i+1;
		    } 
		}
		
		System.out.println(ans);
    }
}

Measured memory_bytes: 35672
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
using namespace std;
 
typedef long long ll;
const int mod = 1e9 + 7;
 
ll H, N;
vector<ll> A, B;
vector<ll> dp;
 
int main() {
    cin >> H >> N;
    A.resize(N);
    B.resize(N);
 
    rep(i, N) cin >> A[i] >> B[i]; 
 
    dp.resize(1e8 + 2);
 
    for (ll i = 0; i <= 1e8 + 1; i++) {
        dp[i] = 1e9;
    }
 
    dp[0] = 0;

    for (int i = 0; i <= 1e4; i++) {
        // N 通りの遷移
        rep(j, N) {
            dp[i + A[j]] = min(dp[i] + B[j], dp[i + A[j]]);
        }
    }
 
    ll ans = 1e9;
    for (ll i = H; i <= 1e8 + 1; i++) {
        ans = min(ans, dp[i]);
        // printf("%d, %d\n", i, ans);
    }
 
    cout << ans << endl;
}

Measured memory_bytes: 781568
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s;
  cin >> s;
  int count;
  count = 0;
  for(int i=0; i<s.size() ;++i){
  if(s.at(i)=='1'){
  ++count;
  }
  }
  cout << count <<endl;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

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

#include <bits/stdc++.h>
using namespace std;

#define INF 1000000010

int main(){
  int n,m;
  cin>>n>>m;
  
  int C[m];
  rep(i,m) cin>>C[i];
  
  int T[n+1];
  rep(i,n+1) T[i]=INF;
  T[0]=0;
  
  rep(i,m){
    for(int j=C[i];j<=n;j++){
      T[j]=min(T[j],T[j-C[i]]+1);
    }
  }
  
  cout<<T[n]<<endl;
      
  return 0;
}


Measured memory_bytes: 3280
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ldb = long double;
using pa = pair < ll, ll >;
using vec = vector < ll >;
#define pb push_back
#define F  first
#define S  second
#define f(i,x,n) for(ll i=x;i<n;i++) 
#define all(c) c.begin(),c.end()
#define edl "\n"
#define str string
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL)
const int MOD = 1e9 + 7, N = 1e5 + 10;
const ll LINF = LLONG_MAX;
int main() {
    fast();

    str s;
    cin >> s;
    if(count(all(s),'9')!=0)
    {
        cout<<"Yes";
    }   
    else
        cout<<"No";

    cerr << "Time taken: " << int((clock() * 1000.) / CLOCKS_PER_SEC) << "ms\n";
    return 0;
}
 

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

using namespace std;

int main(){

	int n;

	while(cin>>n){

	while(n>=39){
		n=n-39;
	}

	if(n==0){
		n=39;
	}

	if(n<10){
		cout<<"3C0"<<n<<endl;
	}
	else{
		cout<<"3C"<<n<<endl;
	}


	}
}

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

int main() {
  string a,b;
  cin >> a >> b;
  string c = a + b;
  int n = stoi(c);
  string result = "No";
  for(int i = 1; i < 320; i++) {
    int temp = i * i;
    if(n == temp) {
      result = "Yes";
      break;
    }
  }
  cout << result << endl;
}

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

int main() {
  int N, K, x;
  int sum = 0;
  cin >> N ;
  cin >> K ;
  
  for(int i=0;i<N;i++){
  cin >> x;
    if(2*x > K){
    	sum+=(K-x)*2;
    }
    else{
    	sum += 2*x;
    }
  }
  cout << sum;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/stack:512000000")
#include<utility>
#include<iostream>
#include<fstream>
#include<vector>
#include<array>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<functional>
#include<random>
#include<climits>
#include<queue>
#include<stack>
#include<deque>
#include<bitset>
#include<map>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<cassert>
#include<ccomplex>

#ifdef ONLINE_JUDGE
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,tune=native")
#pragma GCC optimize("unroll-loops")
#endif

#define all(x) x.begin(), x.end()
#define mp make_pair
#define X first
#define Y second

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;
mt19937_64 gen(time(nullptr));

ll const mod = 1e9 + 7;

namespace {
	ll mul(ll a, ll b) {
		ll val = a * b - (ll)((ld)a * b / mod) * mod;
		if (val < 0) val += mod;
		if (val >= mod) val -= mod;
		return val;
	}

	ll poww(ll a, ll b) {
		ll val = 1;
		a %= mod;
		while (b > 0) {
			if (b % 2) val = mul(a, val);
			a = mul(a, a);
			b >>= 1;
		}
		return val % mod;
	}

	ll inv(ll a) {
		return poww(a, mod - 2);
	}
}

int const maxn = 3005;

ll dp[3005][3005];

ll fw[3005][3005];

void upd(ll kind, ll i, ll add) {
	for (++i; i < maxn; i += -i & i) {
		fw[kind][i] += add;
		if (fw[kind][i] > mod) fw[kind][i] -= mod;
	}
}

ll get(ll kind, ll i) {
	ll ret = 0;
	for (++i; i > 0; i -= -i & i) {
		ret += fw[kind][i];
		if (ret > mod) ret -= mod;
	}
	return ret;
}

ll get(ll kind, ll i, ll j) {
	ll ret = get(kind, j) - get(kind, i - 1);
	ret %= mod; if (ret < 0) ret += mod;
	return ret;
}


signed main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	ll n; cin >> n;
	string s; cin >> s;
	for (ll x = 1; x <= n; x++) {
		dp[0][x] = 1;
		upd(0, x, 1);
	}
	for (ll i = 0; i < n - 1; i++) {
		if (s[i] == '<') {
			for (ll x = 1; x <= n - i - 1; x++) {
				upd(i + 1, x, get(i, 1, x));
				/*for (ll j = 1; j <= x; j++) {
					(dp[i + 1][x] += dp[i][j]) %= mod;
				}*/
				// dp[i+1][x] += dp[i][1] + ... + dp[i][x]
			}
		} else {
			for (ll x = 1; x <= n - i - 1; x++) {
				upd(i + 1, x, get(i, x + 1, n - i));
				/*for (ll j = x + 1; j <= n - i; j++) {
					(dp[i + 1][x] += dp[i][j]) %= mod;
				}*/
				// dp[i+1][x] += dp[i][x + 1] + ... + dp[i][n - i]
			}
		}
	}

	//cout << dp[n - 1][1] << endl;
	cout << get(n - 1, 1, 1) << endl;

	return 0;
}

/*
5
2 6 15 5 10

4
2 6 15 5

*/

Measured memory_bytes: 71936
import numpy as np
N = int(input())
A = np.array(list(map(int, input().split())))
B = np.array(list(map(int, input().split())))
C = np.array(list(map(int, input().split())))

A.sort()
B.sort()
C.sort()

cnt_A = np.searchsorted(A,B)
cnt_C = N - np.searchsorted(C,B,side='right')
ans = (cnt_A*cnt_C).sum()

print(ans)


Measured memory_bytes: 24948
;; -*- coding: utf-8 -*-
(eval-when (:compile-toplevel :load-toplevel :execute)
  (defparameter OPT
    #+swank '(optimize (speed 3) (safety 2))
    #-swank '(optimize (speed 3) (safety 0) (debug 0)))
  #+swank (ql:quickload '(:cl-debug-print :fiveam))
  #-swank (set-dispatch-macro-character #\# #\> (lambda (s c p) (declare (ignore c p)) (read s nil (values) t))))
#+swank (cl-syntax:use-syntax cl-debug-print:debug-print-syntax)
#-swank (disable-debugger) ; for CS Academy

;; BEGIN_INSERTED_CONTENTS
(defmacro xor (form1 form2)
  (let ((f1 (gensym)) (f2 (gensym)))
    `(let ((,f1 ,form1)
           (,f2 ,form2))
       (if ,f1 (not ,f2) ,f2))))

(defmacro dbg (&rest forms)
  #+swank
  (if (= (length forms) 1)
      `(format *error-output* "~A => ~A~%" ',(car forms) ,(car forms))
      `(format *error-output* "~A => ~A~%" ',forms `(,,@forms)))
  #-swank (declare (ignore forms)))

(defmacro define-int-types (&rest bits)
  `(progn
     ,@(mapcar (lambda (b) `(deftype ,(intern (format nil "UINT~A" b)) () '(unsigned-byte ,b))) bits)
     ,@(mapcar (lambda (b) `(deftype ,(intern (format nil "INT~A" b)) () '(signed-byte ,b))) bits)))
(define-int-types 2 4 7 8 15 16 31 32 62 63 64)

(declaim (inline println))
(defun println (obj &optional (stream *standard-output*))
  (let ((*read-default-float-format* 'double-float))
    (prog1 (princ obj stream) (terpri stream))))

(defconstant +mod+ 1000000007)

;; Body

(defun main ()
  (let* ((s (read-line)))
    (write-line
     (if (xor (oddp (length s))
              (char= (aref s 0) (aref s (- (length s) 1))))
         "First"
         "Second"))))

#-swank (main)


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

using namespace std;

int main()
{
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
#endif // LOCAL
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int w, h;
    cin >> w >> h;
    int x, y;
    cin >> x >> y;
    double s = (long long)w * h;
    if (w == 2 * x && h == 2 * y) {
        cout << s / 2 << " " << 1;
    } else {
        cout << s / 2 << " " << 0;
    }
    return 0;
}


Measured memory_bytes: 256
s,t = input(), input()
ls,lt = len(s), len(t)
for i in range(ls-lt,-1,-1):
  for j,s_ in enumerate(s[i:i+lt]):
#    print(i,s_)
    if (s_ == '?') | (s_ == t[j]):
      pass
    else:
      break
  else:
    s = s[:i] + t + s[i+lt:]
    s = s.replace('?','a')
    print(s)
    break
else:
  print('UNRESTORABLE')

Measured memory_bytes: 3064
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)
	ar := make([]int, 100001)
	for i := 0; i < n; i++ {
		var v int
		fmt.Scan(&v)
		ar[v]++
		ar[v+1]++
		if v > 0 {
			ar[v-1]++
		}
	}
	max := 0
	for _, v := range ar {
		if max < v {
			max = v
		}
	}
	fmt.Println(max)
}


Measured memory_bytes: 7568
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define endl '\n'
int mod=1e9+7;

signed main(){
  int n,h,w;
  cin>>n>>h>>w;
  int ans=0;
  for(int i=0;i<n;i++){
    int a,b;
    cin>>a>>b;
    if(a>=h&&b>=w)ans++;
  }
  cout<<ans<<endl;
}


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

typedef long long ll;
typedef pair<int,int> pii;

long long MOD = 10000000000 + 7;
template <class T>
class SegTree {
  int n;
  vector<T> data;
  T def;
  function<T(T, T)> operation;
  function<T(T, T)> update;

  // 区間[a,b)の総和。ノードk=[l,r)に着目している。
  T _query(int a, int b, int k, int l, int r) {
    if (r <= a || b <= l) return def; // 交差しない
    if (a <= l && r <= b){
      return data[k]; // a,l,r,bの順で完全に含まれる
    } else {
      T c1 = _query(a, b, 2 * k + 1, l, (l + r) / 2); // 左の子
      T c2 = _query(a, b, 2 * k + 2, (l + r) / 2, r); // 右の子
      return operation(c1, c2);
    }
  }

  public:
  // _n:必要サイズ, _def:初期値かつ単位元, _operation:クエリ関数,
  // _update:更新関数
  SegTree(size_t _n, T _def, function<T(T, T)> _operation,
      function<T(T, T)> _update) : def(_def), operation(_operation), update(_update) {
        n = 1;
        while (n < _n) {
          n *= 2;
        }
        data = vector<T>(2 * n - 1, def);
  }
  // 場所i(0-indexed)の値をxで更新
  void change(int i, T x) {
    i += n - 1;
    data[i] = update(data[i], x);
    while (i > 0) {
      i = (i - 1) / 2;
      data[i] = operation(data[i * 2 + 1], data[i * 2 + 2]);
    }
  }
  // [a, b)の区間クエリを実行
  T query(int a, int b) {
    return _query(a, b, 0, 0, n);
  }
  // 添字でアクセス
  T operator[](int i) {
    return data[i + n - 1];
  }
};

int main(void) {
  int N, Q;
  cin >> N >> Q;
  // 要素数N・long long型・区間min・点更新
  SegTree<long long> st(N, (1LL << 31) - 1,
             [](long long a, long long b) { return min(a, b); },
             [](long long a, long long b) { return b; });
  while(Q--) {
    int c, x, y;
    cin >> c >> x >> y;
    if (c == 0) {
      // update(x, y)
      st.change(x, y);
    } else {
      // find(s, t)
      cout << st.query(x, y + 1) << endl;
    }
  }
 
  return 0;
}



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

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

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cout<<setprecision(32);

	int n;
	cin>>n;
	vector<int> x(n), y(n), h(n);
	for(int i = 0; i < n; i++){
		cin>>x[i]>>y[i]>>h[i];
	}
	for(int cx = 0; cx <= 100; cx++){
		for(int cy = 0; cy <= 100; cy++){
			set<int> st;
			int lim = 2e9;
			for(int i = 0; i < n; i++){
				if(h[i])st.insert(h[i] + abs(cx - x[i]) + abs(cy - y[i]));
				else lim = min(lim, abs(cx - x[i]) + abs(cy - y[i]));
			}
			if(st.empty()){
				cout<<cx<<" "<<cy<<" "<<lim<<endl;
				exit(0);
			}
			if(st.size() == 1 && (*st.begin()) <= lim){
				cout<<cx<<" "<<cy<<" "<<(*st.begin())<<endl;
				exit(0);
			}
		}
	}

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
main(){
int a,b,c,d;
scanf("%d%d%d",&a,&b,&c);
if( b<a ){
d=a;
a=b;
b=d;
}
if( c<b ){
d=b;
b=c;
c=d;
}
if( b<a ){
d=a;
a=b;
b=d;
}
printf("%d %d %d\n",a,b,c);
return 0;
}

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

int check(int a, int b, int c);

int main(){
	int N = 0;
	int A, B, C;
	int i, j, k;
	int work;
	cin >> N;
	for(i = 0; i < N; i++){
		cin >> A >> B >> C;

		if(check(A, B, C)){
				cout << "YES\n";				
		}
		
		else{
			cout << "NO\n";
		}
    }
    return 0;
}

int check(int a, int b, int c){
    if( (a * a + b * b) == c * c || (b * b + c * c) == a * a || (c * c + a * a) == b * b ){
        return 1;
    }
    
    else{
        return 0;
    }
	
}

Measured memory_bytes: 1120
#include<stdio.h>
#define _USE_<ATH_DEFINES
#include<math.h>
int main(void)
{
	double x,y,r;
	scanf("%lf",&r);
	x=r*r*M_PI;
	y=2*r*M_PI;
	printf("%lf %lf\n",x,y);
	return 0;
}

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

int prime[999985];
int main()
{
  fill_n(prime, 999985, 1);
  prime[1] = 0;
  for(int i = 2; i * i <= 999985; i++) {
    if(prime[i]) {
      for(int j = i + i; j <= 999985; j += i) {
        prime[j] = 0;
      }
    }
  }
  for(int i = 1; i <= 999985; i++) {
    prime[i] += prime[i - 1];
  }

  int n;
  while(scanf("%d", &n), n) {
    long long ret = 0LL;
    for(int i = 0; i < n; i++) {
      int p, m;
      scanf("%d %d", &p, &m);
      int low = max(1, p - m);
      int high = min(999984, p + m);
      ret += prime[high] - prime[low - 1] - 1;
    }
    printf("%d\n", ret);
  }
}

Measured memory_bytes: 5092
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<ll> vec;
typedef vector<vec> mat;
int main(){
    int n;
    cin>>n;
    ll ans=0;
    rep(i,n) if((i+1)%3&&(i+1)%5) ans+=i+1;
    cout<<ans;
}

Measured memory_bytes: 3620
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <sstream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <list>
#include <numeric>
#include <stack>
#include <iomanip>
#include <random>
#include <complex>
#include <functional>
#include <tuple>

using namespace std;

#define Rep(i,a,b) for(int i = a; i < b; ++i)
#define rep(i,b) Rep(i,0,b)
#define allof(a) (a).begin(), (a).end()

#define Yes(q) ((q) ? "Yes" : "No")
#define YES(q) ((q) ? "YES" : "NO")
#define Possible(q) ((q) ? "Possible" : "Impossible")
#define POSSIBLE(q) ((q) ? "POSSIBLE" : "IMPOSSIBLE")

using ll = long long;

using pint = std::pair<int, int>;
using pll = std::pair<ll, ll>;


constexpr int inf = 1e9 + 7;
constexpr ll infll = 1ll << 60ll;
constexpr ll mod = 1e9 + 7;
// 0~3までは右左下上 4~7までは斜め
constexpr int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
constexpr int dy[] = { 0, -1, 0, 1, 1, -1, -1, 1 };

namespace {
	template<typename T> void chmax(T& a, T b) { a = std::max(a, b); }
	template<typename T> void chmin(T& a, T b) { a = std::min(a, b); }
	template<typename T> void chadd(T& a, T b) { a = a + b; }

	void Cout(long long x, const char* end = "\n") { std::cout << x << end; }
	template <typename T> void Cout(const T& x, const char* end = "\n") { std::cout << x << end; }
	template <typename T> void Cout(const std::vector<T>& x, const char* sep = " ", const char* end = "\n") { for (std::size_t i = 0, sz = x.size(); i < sz; i++) { std::cout << x[i] << (i == sz - 1 ? end : sep); } }

	void CCout(long long x, const char* end = "\n") { std::cerr << x << end; }
	template <typename T> void CCout(const T& x, const char* end = "\n") { std::cerr << x << end; }
	template <typename T> void CCout(const std::vector<T>& x, const char* sep = " ", const char* end = "\n") { for (std::size_t i = 0, sz = x.size(); i < sz; i++) { std::cerr << x[i] << (i == sz - 1 ? end : sep); } }

	// 標準入出力
	struct inp {
		std::size_t sz;
		inp(std::size_t _sz = 1) : sz(_sz) {}
		template <typename T> operator T () const { T a; std::cin >> a; return a; }
		template <typename T> operator std::vector<T>() const { vector<T> a(sz); for (std::size_t i = 0; i < sz; i++) std::cin >> a[i]; return a; }
		template <typename T, typename U> operator std::pair<T, U>() const { T f; U s; std::cin >> f >> s; return std::pair<T, U>(f, s); }
	};

	inp inp1; // input one

	bool isSosuu(ll n) {
		if (n == 1) return true;
		for (ll i = 2; i * i <= n; ++i) {
			if (n % i == 0) return false;
		}
		return true;
	}
}

int main() {

	ll a, b;
	cin >> a >> b;

	// 公約数だす

	vector<ll> nums;

	if (a == 1 || b == 1) nums.emplace_back(1);
	else {
		for (ll i = 1; i * i <= a; ++i) {
			if (a % i == 0) {
				ll first = i;
				ll second = a / i;

				// これらがbの公約数か
				if (b % first == 0) nums.emplace_back(first);
				if (b % second == 0) nums.emplace_back(second);
			}
		}
	}

	// 素数だけを選ぶ
	int ans = 0;
	rep(i, nums.size()) {
		if (isSosuu(nums[i])) ++ans;
	}

	Cout(ans);

	return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
#define erep(i,n) for(int i = 0;i<=n;i++)
#define rep1(i,n) for(int i = 1;i<n;i++)
#define erep1(i,n) for(int i = 1;i<=n;i++)
typedef long long ll;
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstring vector<string>
#define vdouble vector<double>
#define vll vector<ll>:
#define vbool vector<bool>
#define INF 100000000000000009
#define MOD 1000000007;
#define int long long
using P = pair<int,int>;
signed main(){
  int n,k;
  cin >> n >> k;
  vint A(n);
  rep(i,n) cin >> A[i];
  vint FIRST(n);
  vint down(n);
  for(int i = 0;i < n;i++){
    for(int j = 0;j < n;j++){
      if(A[i] > A[j]){
        down[i]++;
        if(i < j) FIRST[i]++;
      }
    }
  }
  //rep(i,n) cout << FIRST[i] << " " << down[i] << endl;
  int num = k*(k-1)/2;
  //cout << num << endl;
  num %= MOD;
  int ans = 0;
  rep(i,n){
    ans += FIRST[i]*k;
    ans %= MOD;
    ans += down[i]*num;
    ans %= MOD;
  }
  cout << ans << endl;
}

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

using namespace std;

typedef long long ll;
typedef unsigned int ui;
typedef pair<int, int> pi;

#define fi first
#define se second

int read() {
  int res = 0, w = 1; char c = getchar();
  while (!isdigit(c) && c != '-') c = getchar();
  if (c == '-') c = getchar(), w = -1;
  while (isdigit(c)) res = (res << 1) + (res << 3) + c - '0', c = getchar();
  return res * w;
}

const int N = 2e5 + 10;

char s[N];
int p[N];

int main() {
#ifdef dream_maker
//  freopen("tst.in", "r", stdin);
#else
  //freopen(".in", "r", stdin);
  //freopen(".out", "w", stdout);
#endif
  scanf("%s", s + 1);
  int n = strlen(s + 1);
  int cnt = 0; ll ans = 0;
  for (int i = n; i >= 1; i--) {
    if (s[i] == 'B' && s[i + 1] == 'C') p[i] = p[i + 2] + 1;
    if (s[i] == 'A') {
      ans += p[i + 1];
      p[i] = p[i + 1];
    }
//    cout << i << " " << p[i] << endl;
  } 
  cout << ans << endl;
  return 0;
}


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

int main()
{
  int n;
  cin >> n;
  string s;
  int ac = 0;
  int wa = 0;
  int tle = 0;
  int re = 0;
  for(int i = 0; i< n;++i){
    cin >> s;
    if(s == "AC") ac++;
    else if(s == "WA") wa++;
    else if(s == "TLE") tle++;
    else if(s == "RE") re++;
  }
  cout << "AC x "<< ac << endl;
  cout << "WA x "<< wa << endl;
  cout << "TLE x "<< tle << endl;
  cout << "RE x "<< re << endl;
}


Measured memory_bytes: 3632
l,r = map(int,input().split())

s = l//2019
t = r//2019

l -= 2019*s
r -= 2019*t

if s != t:
    print(0)
    exit()

ans = 10**10
for i in range(l,r+1):
    for j in range(l,r+1):
        #print(i,j,i*j)
        #print((i*j)%2019)
        if i >= j:
            continue
        ans = min(ans, (i*j)%2019)

print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

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

        vector< vector<int> > x(n, vector<int>(d));
        for (int i = 0; i < n; ++i) {
                for (int j = 0; j < d; ++j) {
                        cin >> x[i][j];
                }
        }

        vector<double> l;
        for (int a = 0; a < n - 1; ++a) {
                for (int b = a + 1; b < n; ++b){
                        double r = 0;
                        for (int c = 0; c < d; ++c) {
                                int temp = x[a][c] - x[b][c];
                                r += temp * temp;
                        }
                        l.push_back(sqrt(r));
                }
        }

        int ans = 0;
        for (int i = 0; i < l.size(); ++i) {
                if (l[i] == floor(l[i])) {
                        ++ans;
                }
        }

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

Measured memory_bytes: 384
#include <iostream>
#include <math.h>
#include <algorithm>
#include <vector>
#include <numeric>
#include <string>
using namespace std;
const double PI = acos(-1.0);
const string alp = "abcdefghijklmnopqrstuvwxyz";
const string ALP = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const string HEX = "0123456789ABCDEF";
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

int main(void) {
    int n,m,o;
    cin >> n >> m;
    o=n*100+m*1800;
    double t = 0;
    for(int i=1;i<100;i++){
        t+=o*(i/pow(2,i));
    }
    cout << t*pow(2,m-1);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
    ll a,b,c,d; cin>>a>>b; c=min(a,b); d=max(a,b);
    ll l=__gcd(c,d);
    ll r=(a*b);
    cout<<r/l;
}


Measured memory_bytes: 3596
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	var top,middle,bottom []int

	sc.Split(bufio.ScanWords)

	N := nextInt()

	for i := 0; i < N; i++ {
		top = append(top, nextInt())
	}
	for i := 0; i < N; i++ {
		middle = append(middle, nextInt())
	}
	for i := 0; i < N; i++ {
		bottom = append(bottom, nextInt())
	}

	sort.Ints(top)
	sort.Ints(middle)
	sort.Ints(bottom)

	ans := 0
	for i:=0;i<N;i++{
		a := sort.Search(N, func(n int) bool {
			return top[n] >= middle[i]
		})
		c := sort.Search(N, func(n int) bool {
			return bottom[n] > middle[i]
		})
		ans += a*(N-c)
	}
	fmt.Println(ans)
}

Measured memory_bytes: 9748
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
using namespace std;
typedef long long ll;

int n;
string s;
string t;
int main(void){
  cin >> n >> s >> t;
  
  for(int i = 0; i < n; i++){
    //cout << s.substr(i) << " "  <<  t.substr(0,n-i) << endl;
    if(s.substr(i) == t.substr(0,n-i)){
      cout << n+i << endl;
      return 0;
    }
  }
  cout << 2*n << endl;
}


Measured memory_bytes: 256