akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define ALL(v) v.begin(),v.end()
using ll = long long;
using pii = pair<int,int>;
using vi = vector<int>;
using vs = vector<string>;
using vb = vector<bool>;
using vll = vector<long long>;
using vpii = vector<pair<int,int>>;
using vivi = vector<vector<int>>;
using vbvb = vector<vector<bool>>;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
const int mod = 1000000007;
const int inf = 1001001001;



int main(void) {
  ll n,k;
  cin >> n >> k;
  ll p = n%k;
  ll q = (n/k+1)*k-n;
  cout << min(p,q) << endl;
}






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

typedef std::pair<int, int> ipair;
#define pb push_back
#define ff first
#define ss second
#define fr(i, j, k) for (int i = j; i < k; i++)
#define int long long
#define ld long double
#define cnt_ones(x) __builtin_popcount(x)
#define all(x) x.begin(), x.end()
#define mp make_pair
#define mod 1000000007

template<class T> ostream& operator <<(ostream &out,vector<T> &A){for(auto x:A) out<<x<<" ";return out;}
template <class T1,class T2>T1 powr(T1 a,T2 b){T1 res = 1;fr(i,1,b+1)res = res*a;return res;}
#define IOS  std::ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);


int32_t main(){
  int n;  cin>>n;
  vector<int> A(n); fr(i,0,n) cin>>A[i];
  vector<int> dp(n,INT_MAX);
  dp[0] = 0;
  dp[1] = abs(A[0]-A[1]);
  fr(i,2,n)
    dp[i] = min(dp[i-1]+abs(A[i]-A[i-1]),dp[i-2]+abs(A[i]-A[i-2]));
  cout<<dp[n-1]<<endl;
}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <cstring>
#include <math.h>
#include <bitset>
#include <time.h>
#include <set>
#include <algorithm>
#define MODD 1000000007
#define ll long long
using namespace std;
int N;

int A[111111];
int counts[111111];
ll Solve(int N) {
    for(int i=0;i<=(N-1)/2;i++)
        counts[i]=0;
    for(int i=1;i<=N;i++) {
        if ((N-1-A[i])%2!=0 && (N+A[i]-1)%2!=0)
            return 0;
        
        
        
        counts[(N-1-A[i])/2]++;
    }
    
    
    ll answer=1;
    for(int i=0;i<=(N-1)/2;i++) {
        int j=N-1-i;
        
        
        if (i!=j) {
            if (counts[i]>2)
                return 0;
            
            if (counts[i]==2) {
                answer = (answer*2)%MODD;
            }
            
        } else {
            if (counts[i]>1)
                return 0;
        }
    }
    
    return answer;
    
}

int main() {
    
    // x, N-1-x
    // |N-1-2x|=A
    // either N-1-2x=A or 2x+1-N=A
    // x=(N-1-A)/2 or x=(N+A-1)/2
    
    
    cin>>N;
    for(int i=1;i<=N;i++) {
        cin>>A[i];
        
        
        
        
    }
    
    
    cout << Solve(N) << endl;
}

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

using namespace std;

const int N = 100000 + 3;

typedef long long ll;

int main() {
  int n;
  cin >> n;
  
  double ans = 0.0;
  for(int i = 0; i < n; ++i) {
    double x;
    cin >> x;
    ans += 1.0 / x;
  }

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


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


using namespace std;

#define M 1000000007
#define pb push_back
#define f first
#define s second
#define rep(i, st, ed) for(ll i=st; i<ed; i++)
#define repn(i, st, ed) for(ll i=st; i<=ed; i++)
#define repb(i, ed, st) for(ll i=ed; i>=st; i--)
#define all(v) v.begin(),v.end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

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

const long double PI  =3.141592653589793238463;
const int N = 1e5 + 10;
const ll INF = 1LL << 60;

template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}



// Main Code


int main()
{
	ll n, k;
	cin>>n>>k;
	ll maxx = ((n-1)*(n-2)) / 2;
	if(k > maxx) cout<<-1<<endl;
	else
	{
		ll diff= maxx - k;
		cout<<n-1+diff<<endl;
		ll m = n-1+diff;
		ll curr = 1;
		ll br = curr + 1;
		while(m--)
		{
			cout<<curr<<" "<<br<<endl;
			br++;
			if(br > n)
			{
				curr++;
				br = curr + 1;
			}
		}
	}
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
const long double PI = acos(-1.0L);
const long long MOD = 1000000007LL;
// const long long MOD = 998244353LL;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
template<class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true;} return false; }
template<class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true;} return false; }
///////////////////////////////////////////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int N,K; cin >> N >> K;
    vector<ll> A(N);
    rep(i,N) cin >> A[i];

    vector<ll> B(N+1),C(N+1);
    rep(i,N) {
        B[i+1] = B[i] + A[i];
        C[i+1] = C[i] + max(0LL,A[i]); 
    }

    ll ans = 0;
    rep(i,N-K+1) {
        chmax(ans,C[i]-C[0]+max(0LL,B[i+K]-B[i])+C[N]-C[i+K]);
    }

    cout << ans << endl;
}

Measured memory_bytes: 2560
#include <iostream>
#include <vector>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
  int n;
  cin>>n;
  int d[]={2,3,5,7,11,13};
  vector<int> e(6,0);
  int cnt;
  int ans=0;
  REP(i,n){
    if((i+1)%2==0){
      continue;
    }
    int origin = i+1;
    REP(j,6){
      while(origin%d[j]==0){
        origin /= d[j];
        e[j]++;
      }
    }
    REP(j,6){
      cnt *= e[j]+1;
    }
    if(cnt==8){
      ans++;
    }
    REP(j,6){
      e[j]=0;
    }
    cnt=1;
  }
  
  cout<<ans<<endl;
  return 0;
}

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

using namespace std;


int main()
{

    int n, m;
    cin >> n >> m;

    vector<int> p(n + 1, 0);
    int ac = 0, wasum = 0;

    for (int i = 0; i < m; i++) {
        int index;
        string s;
        cin >> index >> s;
        if (p[index] >= 0) {
            if (s == "WA") {
                p[index]++;
            }
            else {
                wasum += p[index];
                p[index] = -1;
                ac++;
            }
        }

    }


    cout << ac << " " << wasum << endl;
}

Measured memory_bytes: 640
A,B,K = map(int,input().split())

if B-A+1 > 2*K:
    for x in range(0,K):
        print(A+x)
    for x in range(K-1,-1,-1):
        print(B-x)
else:
    for x in range(0,B-A+1):
        print(A+x)

Measured memory_bytes: 3060
#include <iostream>
#define INF (2<<29)
using namespace std;

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    for(;;){
        int a,n,s=0,max=0,min=INF;
        cin>>n;
        if(n==0) break;
        for(int i = 0; i < n; i++){
            cin>>a;
            s+=a;
            if(max<a) max=a;
            if(min>a) min=a;
        }
        cout<<(s-max-min)/(n-2)<<endl;
    }
    return 0;
}

Measured memory_bytes: 3116
#include <stdio.h>
#include <algorithm>
using namespace std;

const int N = 100+10;
const int K = 1e5+10;

int n,k;
int T[N];
bool DP[K]; // 1 - przegryw.  0 - wygryw.

int main(){
  scanf("%d%d",&n,&k);
  for(int i=1; i<=n; i++)scanf("%d",&T[i]);
  DP[0] = 1;
  for(int i=1; i<T[1]; i++)DP[i] = 1;
  for(int i=T[1]; i<=k; i++){
    bool res = 1;
    for(int j=1; j<=n && i-T[j]>=0; j++){
      if(DP[i-T[j]]==1)res = 0;
    }
    DP[i] = res;
  }

  if(DP[k] == 0)printf("First\n");
  else printf("Second\n");


  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner

object Main {
  def main(args: Array[String]): Unit = {
    val sc = new Scanner(System.in)
    val Array(n, k) = sc.nextLine.split(" ").map(_.toInt)
    println(sc.nextLine.split(" ").map(_.toInt).sorted.reverse.slice(0, k).sum)
  }
}


Measured memory_bytes: 27168
import java.io.*;
import java.util.*;
import java.math.BigInteger;
public class Main {

static long[] list=new long[87];

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

   String nyuA=sc.nextLine();
 //  String nyuB=sc.nextLine();
 
 //   String[] s=sc.nextLine().split(" ");
   //  String[] e=sc.nextLine().split(" ");

int N=Integer.parseInt(nyuA);

//int Y=Integer.parseInt(e[1]);
//int Z=Integer.parseInt(e[2]);



ryuka(N);
System.out.println(list[N]);


	}
static long ryuka(int a){
if(a==0){list[0]=2;return 2;}
if(a==1){list[1]=1;return 1;}

long A=list[a-1];
long B=list[a-2];
if(A==0)A=ryuka(a-1);
if(B==0)B=ryuka(a-2);
list[a]=A+B;
return A+B;
}

}



Measured memory_bytes: 21972
#include <vector>
#include <algorithm>
#include <string>
#include <iostream>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cassert>
#include <chrono>
#include <random>
#include <iomanip>
#include <ctime>
#include <chrono>
#include <cstdlib>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define pb push_back
#define sz(x) (int)(x).size()
#define rep(i, a, b) for (int i = a; i <= b; i++)
#define per(i, a, b) for (int i = a; i >= b; i--)
#define au(i, x) for (auto&i : x)
typedef long double ld;
typedef long long ll;
mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
int main() {
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int n, m;
	cin >> n >> m;
	vector<int>a(n);
	int s = 0;
	rep(i, 0, n - 1) {
		cin >> a[i];
		s += a[i];
	}
	sort(rall(a));
	int M = m;
	rep(i, 0, n - 1) {
		if (a[i] * 4 * M < s) break;
		m--;
	}
	if (m > 0) cout << "No";
	else cout << "Yes";
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int num = sc.nextInt();
		String str = "hon";
        num = num%10;
		
		if (num == 3){
			str = "bon";
		}
		else if (num == 0 || num == 1 || num == 6 || num == 8){
			str = "pon";
		}
		 System.out.printf(str);
    }
}

Measured memory_bytes: 35612
#include <stdio.h>
#include <cmath>
#include <bits/stdc++.h>



using namespace std;

typedef vector<int> VI;
typedef vector<string> VS;


//container util
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#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, i; cin >> N >> i;

	cout << N+1-i << endl;


	return 0;

}


Measured memory_bytes: 256
/*its_Rashid*/
//#include <bits/stdc++.h>
#include <iostream>
#include <cmath>
#include <iomanip>
#include <ctime>
#include <time.h>
#include <string>
#include <vector>
#include <random>
#include <array>
using namespace std;

typedef double du;
typedef string st;
typedef long long ll;
typedef long double ld;
typedef long long int lli;

#define vi vector <lli>
#define loop(num) for (lli i = 0 ; i < num ; i ++ )
#define loopcin(num , ar ) for (lli i = 0 ; i < num ; i ++ ) {cin >> ar [i] ;}
#define loopcout(num , ar) for (lli i = 0 ; i < num ; i ++ ) {cout << ar [i] << ' '; }

#define forr(num1 , num2) for (lli i = num1 ; i < num2 ; i ++ )
#define forrcin(num1 , num2 , ar ) for (lli i = num1 ; i < num2 ; i ++ ) {cin >> ar [i] ;}
#define forrcout(num1 , num2 , ar) for (lli i = num1 ; i < num2 ; i ++ ) {cout << ar [i] << ' '; }

#define D2forrcin(num1_1 , num1_2 , num2_1 , num2_2 , A ) for (lli i = num1_1 ; i < num1_2 ; i ++){ for (lli j = num2_1 ; j < num2_2 ; j++){cin >> A[i][j] ;}}
#define D2forrcout(num1_1 , num1_2 , num2_1 , num2_2 , A ) for (lli i = num1_1 ; i < num1_2 ; i ++){ for (lli j = num2_1 ; j < num2_2 ; j++){cout << A[i][j] << ' ' ;}cout << endl ;}

#define YES cout << "YES" << endl ;
#define Yes cout << "Yes" << endl ;
#define NO cout << "NO" << endl ;
#define No cout << "No" << endl ;

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

int main()
{
    fastio;

    lli age;
    cin >> age;
    switch (age)
    {
    case 1 :
        printf("Hello World");
        break;
    case 2 :
        lli num1, num2;
        cin >> num1 >> num2;
        cout << num1 + num2;
        break;
    }
        return 0;
}

/*___________________________________________________________________functions___________________________________________________________________________*/



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

bool f(int x){
int keta =0;
  while(x){
    keta ++;
    x/=10;
  }

  return keta%2 ==1;
}


int main(){
int n;
  cin >> n;
  int ans =0;
  for (int i=1; i<=n;i++){
    if(f(i)) ans++;
  }
  cout <<ans <<endl;
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <vector>
#include <cfloat>
#include <string>
#include <cmath>
#include <set>
#include <cstdlib>
#include <map>
#include <ctime>
#include <iomanip>
#include <functional>
#include <deque>
#include <iostream>
#include <cstring>
#include <queue>
#include <cstdio>
#include <stack>
#include <climits>
#include <sys/time.h>
#include <cctype>

using namespace std;

typedef long long ll;

#define MARU 0
#define KAKU 1

int check(char c) {
  if (c == '(' ||
      c == ')') {
    return MARU;
  }
  if (c == '[' ||
      c == ']' ) {
    return KAKU;
  }
  return -1;
}

int main() {
  string str;
  while(true) {
    getline(cin, str);
    if (str == ".") break;

    string tstr;
    for (int i = 0; i < str.size(); i++) {
      if (check(str[i]) != -1) {
	tstr += str[i];
      }
    }

    if (tstr.size() == 0) {
      std::cout << "yes" << std::endl;
      continue;
    }
    if (tstr[0] == ')' ||
	tstr[0] == ']') {
      std::cout << "no" << std::endl;
      continue;
    }

    // std::cout << tstr << std::endl;
    bool yes = true;
    stack <int> st;
    st.push(check(tstr[0]));
    for (int i = 1; i < tstr.size(); i++) {
      if (st.size()) {
	int val = st.top();
	if (tstr[i] == '(' ||
	    tstr[i] == '[') {
	  st.push(check(tstr[i]));
	}else {
	  if (val != check(tstr[i])) {
	    yes = false;
	    break;
	  }else {
	    st.pop();
	  }
	}
      }else {
	if (tstr[i] == ')' ||
	    tstr[i] == ']') {
	  yes = false;
	  break;
	}else {
	  st.push(check(tstr[i]));
	}
      }
    }

    if (yes && st.empty()) {
      std::cout << "yes" << std::endl;
    }else {
      std::cout << "no" << std::endl;
    }
  }
}

Measured memory_bytes: 1180
A, B, C, D = [int(x) for x in input()]

for op1 in ['+', '-']:
    for op2 in ['+', '-']:
        for op3 in ['+', '-']:
            formula = '{}{}{}{}{}{}{}'.format(A, op1, B, op2, C, op3, D)
            if eval(formula)==7:
                print('{}=7'.format(formula))
                exit(0)


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

int main()
{
	string s;
	cin>>s;
	ll int i;
	if ((s[2]==s[3])&&(s[4]==s[5]))
	cout<<"Yes"<<endl;
	else
	cout<<"No"<<endl;
}
	
 


Measured memory_bytes: 256
N=int(input())
A=list(map(int,input().split()))
A.sort()

while len(A)>1:
    A0=[A[0]]
    A=[i%A0[0] for i in A[1:] if i%A0[0]!=0]
    A=A0+A
    A.sort()

print(A[0])

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

int main() {
    int a, b;
    cin >> a >> b;
    if (a <= -500 || a >= 500) {
        return 0;
    }
    if (b <= -500 || b >= 500) {
        return 0;
    }
    if (a < b) {
        cout << "a < b" << endl;
    } else if (a > b) {
        cout << "a > b" << endl;
    } else if (a == b) {
        cout << "a == b" << endl;
    }
}

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

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

int main(void) {
  int i;
  std::string S;
  long Q;
  int T, F;
  int reversed = 0;
  std::string c;
  std::cin >> S;
  scanf("%ld", &Q);
  for(i = 0;i < Q;i++) {
    scanf("%d", &T);
    if(T == 1) {
      reversed = !reversed;
    } else {
      std::cin >> F >> c;
      if(F == 1) {
        if(reversed) S += c;
        else S.insert(0, c);
      } else {
        if(reversed) S.insert(0, c);
        else S += c;
      }
    }
  }
  if(reversed) {
    for(i = S.size() - 1;i >= 0;i--) {
      printf("%c", S[i]);
    }
    puts("");
  } else {
    puts(S.c_str());
  }
  fflush(stdout);
  return 0;
}


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

int main()
{
  char object;
  cin >> object;
  int flag_vowel = 0;
  switch (object)
  {
  case 'a':
    flag_vowel = 1;
  case 'i':
    flag_vowel = 1;
  case 'u':
    flag_vowel = 1;
  case 'e':
    flag_vowel = 1;
  case 'o':
    flag_vowel = 1;
  }
  if (flag_vowel == 1)
  {
    cout << "vowel" << endl;
  }
  else
  {
    cout << "consonant" << endl;
  }
}

Measured memory_bytes: 256
#!/usr/bin/python3
# -*- coding:utf-8 -*-

from queue import deque

def main():
  h, w = map(int, input().strip().split())
  c_h, c_w = map(int, input().strip().split())
  d_h, d_w = map(int, input().strip().split())
  maze = [list(input().strip()) for _ in range(h)]
  visited = [[0] * w for _ in range(h)]
  
  def bfs():
    dq = deque([(c_h-1, c_w-1, 0)])
    while dq:
      (ih, iw, cnt) = dq.pop()
      if visited[ih][iw]:
        continue
      visited[ih][iw] = 1
      
      if ih == d_h-1 and iw == d_w-1:
        return cnt
      
      for dh in range(-2, 3):
        for dw in range(-2, 3):
          if not (0 <= ih + dh < h and 0 <= iw + dw < w) \
             or visited[ih + dh][iw + dw] == 1 \
             or maze[ih + dh][iw + dw] == '#':
            continue
          if (dh, dw) in [(0, 1), (0, -1), (1, 0), (-1, 0)]:
            dq.append((ih + dh, iw + dw, cnt))
          else:
            dq.appendleft((ih + dh, iw + dw, cnt+1))
      
    return -1
  print(bfs())
  
if __name__=='__main__':
  main()



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

using namespace std;

long long lit025, lit05, lit1, lit2, N;

long long cal(long long N) {
    long long ans = min(N * 4 * lit025, min(N * 2 * lit05, min(N * lit1, lit2 * N / 2)));
    return ans;
}

long long get(int u) {
    if(u == 0) return 0;
    return min(4 * lit025, min(2 * lit05, lit1));
}

int main() {
    //freopen("a.txt", "r", stdin);
    cin >> lit025 >> lit05 >> lit1 >> lit2 >> N;
    cout << cal((N /2) * 2)  +  get(N % 2);
}

Measured memory_bytes: 256
//{
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<ll,ll> ii;
#define REP(i,n) for(ll i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define FILL(i,n) memset(i,n,sizeof i)
#define X first
#define Y second
#define SZ(_a) (int)_a.size()
#define ALL(_a) _a.begin(),_a.end()
#define pb push_back
#ifdef brian
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<" ,";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // brian
//}


const ll MAXn=1e5+5,MAXlg=__lg(MAXn)+2;
const ll MOD=1000000007;
const ll INF=ll(1e15);

int main()
{
    IOS();
    ll N;
    cin>>N;
    if(N&1)cout<<N*2<<endl;
    else cout<<N<<endl;
}


Measured memory_bytes: 256
def solve(s):
    sum1 = 0
    sum2 = 0
    length = 0
    for i in s.split():
        x = int(i)
        sum1 += x**2
        sum2 += x
        length += 1

    score = 10**8

    for y in range(100,-101, -1):
        tmp = sum1 - sum2*2*y + length*(y**2)
        score = min(tmp, score)

    return score

if __name__ == "__main__":
    n = int(input())
    s = input()
    print(solve(s))

Measured memory_bytes: 3064
k = gets.to_i

lunluns = *1..9

if k < 10 then
    puts lunluns[k - 1]
else
    x = 0
    for i in (1..k) do
        x = lunluns.shift
        lunluns.push(x * 10 + x % 10 - 1) if x % 10 != 0
        lunluns.push(x * 10 + x % 10)
        lunluns.push(x * 10 + x % 10 + 1) if x % 10 != 9
    end
    puts x
end


Measured memory_bytes: 3964
import java.io.*;

public class Main{

	/**
	 * @param args
	 * @throws IOException 
	 */
	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		 BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		 String input = in.readLine();
		 String numbers[] = input.split(" ");
		 int a = Integer.parseInt(numbers[0]);
		 int b = Integer.parseInt(numbers[1]);
		 if(a < b){
			 System.out.println("a < b");
		 }
		 else if(a > b){
			 System.out.println("a > b");
		 }
		 else{
			 System.out.println("a == b");
		 }


	}

}

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

string solve() {
    ll N;
    cin >> N;
    string S, T, ans;
    cin >> S >> T;
    for ( int i = 0; i < N; i++ ) {
        ans.push_back(S[i]);
        ans.push_back(T[i]);
    }

    return ans;
}

int main() {
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

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

long long get_each_digits_num(long long n)
{
  int sum = 0;
  while (n > 0)
  {
    sum += n % 10;
    
    n /= 10;
  }
  
  return sum;
}

int main()
{
  long long  N;
  cin >> N;
  
  long long sum_digits = get_each_digits_num(N);
  
  if (0 == N % sum_digits)
  {
    printf("Yes");
  }
  else
  {
    printf("No");
  }

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
const int INF=1e9;
const int MOD=1e9+7;
//const int MOD=998244353;
const long long LINF=1e18;
using namespace std;
#define int long long
//template
int yo[2005][2005],ta[2005][2005];
//main
signed main(){
  memset(yo,0,sizeof(yo));memset(ta,0,sizeof(ta));
  int H,W;cin>>H>>W;
  std::vector<string> s(H+1);
  s[H]=string(W+1,'#');
  for(int i=0;i<H;i++)cin>>s[i],s[i]+="#";
  for(int i=0;i<H;i++){
    int now=0;
    for(int j=0;j<W;j++){
      if(s[i][j]=='.')yo[i][j]=++now;
      else yo[i][j]=now=0;
    }
    for(int j=W-1;j>=0;j--)if(s[i][j]=='.')yo[i][j]=max(yo[i][j],yo[i][j+1]);
  }
  for(int j=0;j<W;j++){
    int now=0;
    for(int i=0;i<H;i++){
      if(s[i][j]=='.')ta[i][j]=++now;
      else ta[i][j]=now=0;
    }
    for(int i=H-1;i>=0;i--)if(s[i][j]=='.')ta[i][j]=max(ta[i][j],ta[i+1][j]);
  }
  int ans=0;
  for(int i=0;i<H;i++)for(int j=0;j<W;j++)ans=max(ans,ta[i][j]+yo[i][j]);
  cout<<ans-1<<endl;
}


Measured memory_bytes: 67200
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>

using namespace std;

typedef long long ll;

const int mod = 1000000007;

int main(int argc, char *argv[]) {
	int N, K;

	cin >> N >> K;

	vector<pair<int, int>> s;
	for (int i = 1; i * i <= N; i++) {
		s.push_back(make_pair(i, 0));
		s.push_back(make_pair(N / i, 0));
	}
	sort(s.begin(), s.end());
	s.erase(unique(s.begin(), s.end()), s.end());

	for (int i = 0; i < s.size() - 1; i++) {
		int l = N / s[i + 1].first;
		int r = N / s[i].first;
		s[i].second = r - l;
	}
	s.back().second = 1;
	int m = s.size();

	map<int, int> mp;
	for (int i = 0; i < m; i++) {
		mp[s[i].first] = i;
	}
	vector<vector<ll>> dp(K + 1, vector<ll>(m));
	dp[0][mp[N]] = 1;
	for (int i = 0; i < K; i++) {
		for (int j = m - 2; j >= 0; j--) {
			dp[i][j] += dp[i][j + 1] % mod;
			dp[i][j] %= mod;
		}
		for (int j = 0; j < m; j++) {
			int nj = mp[N / s[j].first];
			dp[i + 1][j] += dp[i][nj] * s[j].second % mod;
			dp[i + 1][j] %= mod;
		}
	}
	ll ans = 0;
	for (int j = 0; j < m; j++) {
		ans += dp[K][j] % mod;
		ans %= mod;
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 54264
N,M = map(int,input().split())
A = list(map(int,input().split()))
XY = [tuple(map(int,input().split())) for i in range(M)]

if M==N-1:
    print(0)
    exit()

class UnionFind:
    def __init__(self,N):
        self.parent = [i for i in range(N)]
        self._size = [1] * N
        self.count = 0
    def root(self,a):
        if self.parent[a] == a:
            return a
        else:
            self.parent[a] = self.root(self.parent[a])
            return self.parent[a]
    def is_same(self,a,b):
        return self.root(a) == self.root(b)
    def unite(self,a,b):
        ra = self.root(a)
        rb = self.root(b)
        if ra == rb: return
        if self._size[ra] < self._size[rb]: ra,rb = rb,ra
        self._size[ra] += self._size[rb]
        self.parent[rb] = ra
        self.count += 1
    def size(self,a):
        return self._size[self.root(a)]

uf = UnionFind(N)
for x,y in XY:
    if uf.is_same(x,y): continue
    uf.unite(x,y)
for i in range(N):
    uf.root(i)

from collections import defaultdict
dic = defaultdict(lambda: set())
for i in range(N):
    dic[uf.root(i)].add(i)

need = (len(dic)-1)*2
if need > N:
    print('Impossible')
    exit()

ans = used = 0
import heapq
hq = []
heapq.heapify(hq)
for r,vs in dic.items():
    mini = -1
    mina = 10**9+1
    for i in vs:
        if A[i] < mina:
            mina = A[i]
            mini = i
    ans += mina
    used += 1
    for i in vs:
        if i==mini: continue
        heapq.heappush(hq, A[i])

for _ in range(need - used):
    ans += heapq.heappop(hq)
print(ans)

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

int main()
{
	long long x;
	cin >> x;
	long long y;
	bool found = false;
	if(x <= 6){
		y = 1;
		found = true;
	}
	if(x <= 11 && !found){
		y = 2;
		found = true;
	}
	long long z = x / 11;
	long long mod = x % 11;
	if(mod == 0 && !found){
		y = 2 * z;
		found = true;
	}
	if(mod <= 6 && !found){
		y = 2 * z + 1;
		found = true;
	}
	if(!found){
		y = 2 * z + 2;
	}
	cout << y << endl;

	return 0;

}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
 
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3") 
#pragma GCC optimization ("unroll-loops")
 
// #include <ext/pb_ds/detail/standard_policies.hpp>
using namespace std;
using namespace __gnu_pbds;
// const ll RANDOM = chrono::high_resolution_clock::now().time_since_epoch().count();
// gp_hash_table<int, int> table;
 
#define ll  long long
#define vii vector< ll >
#define pb push_back
#define pii pair<ll,ll>
#define ppi pair<pii,ll>
#define all(x) x.begin(),x.end()
#define S second
#define F first
#define ins insert
#define ld long double
#define lp(l,r) for(i=l;i<=r;++i)
 
#define lpj(l,r) for(j=l;j<=r;++j)
#define lpr(l,r) for(i=r;i>=l;--i)
#define lprj(l,r) for(j=r;j>=l;--j)
 
#define swap(a,b){ auto _t=a;a=b,b=_t;}
#define flush() cout.flush()
#define popcount __builtin_popcount
#define die() return 0;
#define sz() size() 


 
 
#define TRACE
 
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
 
#define MD          1000000007
#define M 			100011
#define LN             14
#define fftmod      998244353
#define EPS         (double)1e-10
 
long long  md=MD;
ll inf=1e18;
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); 
 
 
inline ll exp(ll a,ll b){if(a==0&&b==0)return 1ll;if(a==0)return 0ll;ll r=1LL;while(b>0){if(b&1){r=(r%md)*(a%md);r=(r+md)%md;}b/=2;a=(a%md)*(a%md);a=(a+md)%md;}return (r+md)%md;}
ll gcd(ll a,ll b){if(b==0)return a;if(a==0)return b;return gcd(b,a%b);}
inline ll poww(ll a,ll b){ll r=1LL;while(b>0){if(b&1)r=r*a;b/=2;a=a*a;}return (ll)r;}
 
using cd=complex<double>;
const double PI=acos(-1);
 
inline ll rand(ll l,ll r){
    return l+rng()%(r-l+1);
 
}


int B[2*M];

ll get(ll x){
	ll r=0;
	for(;x>=1;x-=x&-x)r+=B[x];
		return r;
}
ll up(ll x,ll val){
	for(;x<2e5;x+=x&-x)B[x]+=val;
}



int main(){
 
     
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
 
 
   // ifstream fin("input.txt");ofstream fout("outut.txt");
    ll t,i,j,m,n,s,z,k,p;string s1,s2;ll q;ll x,y;
    cin>>n;
    vii v;
    lp(1,n)cin>>x,v.pb(x);
    map<ll,ll> h;
    for(auto x:v)h[x];
    k=1;
	for(auto x:h)h[x.F]=k++;
	for(i=0;i<v.sz();++i)v[i]=h[v[i]];
	ll ans=0;
	for(i=0;i<v.sz();++i){
		x=0,p=2e5;
		// trace(v[i]);
		if(get(v[i]-1)==0){
			++ans;
			up(v[i],1);continue;

		}
		for(;p>=1;p/=2){
			while(x+p<v[i]&&get(x+p)<get(v[i]-1))x+=p;
		}
		// trace(x)
		++x;
			up(x,-1);
			up(v[i],1);





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




}



Measured memory_bytes: 7668
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<list>
#include<set>
#include<string>
using namespace std;
int gcd(int a, int b) {
	int c = a % b;
	while (c != 0) {
		a = b;
		b = c;
		c = a % b;
	}
	return b;
}
struct UnionFind {
	vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

	UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
		for (int i = 0; i < N; i++) par[i] = i;
	}

	int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
		if (par[x] == x) return x;
		return par[x] = root(par[x]);
	}

	void unite(int x, int y) { // xとyの木を併合
		int rx = root(x); //xの根をrx
		int ry = root(y); //yの根をry
		if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
		par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
	}

	bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
		int rx = root(x);
		int ry = root(y);
		return rx == ry;
	}
};
typedef long long ll;

const ll M = 1000000007;

vector<ll> fac(300001); //n!(mod M)
vector<ll> ifac(300001); //k!^{M-2} (mod M)

ll mpow(ll x, ll n) {
	ll ans = 1;
	while (n != 0) {
		if (n & 1) ans = ans * x % M;
		x = x * x % M;
		n = n >> 1;
	}
	return ans;
}
ll comb(ll a, ll b) {
	if (a == 0 && b == 0)return 1;
	if (a < b || a < 0)return 0;
	ll tmp = ifac[a - b] * ifac[b] % M;
	return tmp * fac[a] % M;
}
int compare(string a, string b) {
	int i;
	for (i = 0; i < a[i] != '\0'; i++) {
		if (b[i] == '\0')
			return -1;
		else if (a[i] < b[i])
			return 1;
		else if (a[i] > b[i])
			return -1;
	}
	if (b[i] != '\0')
		return 1;
	else
		return 0;
}
int main() {
	int n, m, i, j, k[11], s[11][11], p[11], ans = 0,t,maxt=1,a[11],ct,flag,q;
	cin >> n >> m;
	for (i = 0; i < m; i++) {
		cin >> k[i];
		for (j = 0; j < k[i]; j++)
			cin >> s[i][j];
	}
	for (i = 0; i < m; i++)
		cin >> p[i];
	for (i = 0; i < n; i++)
		maxt *= 2;
	for (t = 0; t < maxt; t++) {
		ct = t;
		for (i = 0; i < n; i++) {
			a[i] = ct % 2;
			ct /= 2;
		}
		flag = 1;
		for (i = 0; i < m; i++) {
			q = 0;
			for (j = 0; j < k[i]; j++)
				if (a[s[i][j] - 1] == 1)
					q++;
			if (q % 2 != p[i]) {
				flag--;
				break;
			}
		}
		if (flag == 1)
			ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 4992
#define _GLIBCXX_DEBUG
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
using namespace std;
typedef long long ll;
#define ALL(v) (v).begin(), (v).end()
const int mod = 1e9+7;

ll gcd(ll c, ll d) {
		if (d == 0) return c;
		gcd(d, c%d);
}

ll lcm(ll c, ll d) {
		ll t = gcd(c, d);
		return c / t * d;
}

ll f(ll x, int c, int d) {
		ll t1 = x / c;
		ll t2 = x / d;
		ll t3 = x / lcm(c, d);
		return x - (t1 + t2 - t3);
}

int main() {
		ll A, B;
		int C, D;
		cin >> A >> B >> C >> D;

		ll ans = f(B, C, D) - f(A-1, C, D);
		cout << ans << endl;

		return 0;
}


Measured memory_bytes: 256
N = gets.to_i
XY = Array.new(N){[]}
N.times do |i|
  gets.to_i.times do
    x, y = gets.split.map(&:to_i)
    XY[i] << [x - 1, y == 1]
  end
end

ans = 0
[true, false].repeated_permutation(N) do |a|
  next if a.flat_map.with_index{|t, i| t ? XY[i] : []}.any?{|x, y| a[x] != y}
  ans = [ans, a.count(true)].max
end
puts ans

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

int main() {
        int N;
        string S;
        int e = 0;
        int ans = 300000;

        cin >> N;
        cin >> S;

        for (int i = 0; i < N; ++i) {
                if (S[i] == 'E') e++;
        }

        for (int i = 0; i < N; ++i) {
                if (S[i] == 'E') e--;
                ans = min(ans, e);
                if (S[i] == 'W') e++;
        }
        cout << ans << endl;
}

Measured memory_bytes: 900
n = int(input())
l = [int(input()) for _ in range(n)]

if l[0] == 2:
    print(1)
    exit()
else:
    x = l[0]-1
    z = 1
    for i in range(10**5):
        z += 1
        if l[x] == 2:
            break
        else:
            x = l[x]-1

if z == 100001:
    print('-1')
else:
    print(z)


Measured memory_bytes: 7084
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)

#define CHMAX(a,b) a=max((a),(b))

int n,m;
int dist[125252];
vector<pii> g[125252];
bool used[125252];

const int INF = 1145141919;

int main(){
  scanf("%d%d",&n,&m);
  REP(i,m){
    int a,b,c;
    scanf("%d%d%d",&a,&b,&c);
    --a;--b;
    g[a].push_back(pii(b,c));
  }
  // dijkstra in 0~n-2
  REP(i,n)dist[i] = INF;
  // pair<-dist,pos>
  priority_queue<pii> Q;
  Q.push(pii(-0,0));
  dist[0] = 0;

  int ans = -1;
  while(!Q.empty()){
    pii P = Q.top(); Q.pop();
    int d = -P.first;
    int pos = P.second;
    // ???????????¢
    if(used[pos])continue;
    used[pos] = true;
    // ????????¨??¢?´¢
    for(const pii& P:g[pos]){
      int to = P.first;
      int c = P.second;
      // ????????§???
      if(c<d)continue;
      if(to==n-1){
        // ??´??????
        CHMAX(ans,c);
      }else{
        // ????????´??°
        if(dist[to] <= c)continue;
        dist[to] = c;
        Q.push(pii(-c,to));
      }
    }
  }
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 10000
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
using namespace std;

int main(){
  int n, a, b, tmp, cnt1=0, cnt2=0, cnt3=0;
  vector<int> v;
  cin >> n >> a >> b;
  for(int i=0;i<n;i++){
    cin >> tmp;
    v.push_back(tmp);
  }
  sort(v.begin(), v.end());
  for(int i=0;i<n;i++){
    if(v[i]<=a)cnt1++;
    else if(v[i]<=b)cnt2++;
    else cnt3++;
  }
  int ans=min(cnt1,cnt2);
  ans=min(ans,cnt3);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define inf 0x3f3f3f3f
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef double dd;
const int N = 1e5+5;
const dd eps = 1e-8;
const int mod = 1e9+7;

int n,m;

int main(){
  ios::sync_with_stdio(false);
  // freopen("input.txt","r",stdin);
  cin>>n>>m;
  int a1 = (n*(n-1))/2;
  int a2 = (m*(m-1))/2;
  cout<<a1+a2<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repl(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define reprl(i, n) for(ll i = n; i >= 0; i--)
#define fori(i, m, n) for(int i = m; i < (int)n; i++)
#define forl(i, m, n) for(ll i = m; i < (ll)n; i++)
#define all(v) v.begin(), v.end()
ll gcd(ll a,ll b) {
  return b? gcd(b,a%b): a;  
}
ll lcm(ll a,ll b) {
  return a*b/gcd(a,b);
}
bool isLowerCase(char c){
  return (c>='a'&&c<='z');
}
const string btos(bool ans){
  return (ans?"Yes":"No");
}
int main() {
  int n,k;cin>>n>>k;
  int ans=1;
  rep(i,n){
    ans+=(ans>=k)?k:ans;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m;cin>>n>>m;
  int a[m],b[m];
  int s[n+1],f[n+1];
  vector<int>par[n+1];
  fill(s,s+n+1,0);fill(f,f+n+1,0);
  for(int i=0;i<m;i++){
    cin>>a[i]>>b[i];
    s[a[i]]++;
    f[b[i]]++;
    par[a[i]].push_back(b[i]);
  }
  vector<int>v;
  int ans=0;
  for(int i=1;i<=n;i++){
    if(f[i]>0){
      ans++;
      for(int j=0;j<v.size();j++){
        int num=v[j];
        for(int k=0;k<par[num].size();k++){
          f[par[num][k]]--;
        }
      }
      v={};
    }
    if(s[i]>0){
      v.push_back(i);
    }
  }
  cout<<ans<<endl;
}
    
  

Measured memory_bytes: 7680
N = int(input())
X = list(map(int, input().split()))

MAX = 10 ** 6 + 1
prime = [True] * MAX
counted = set()
for v in X:
    if v in counted:
        prime[v] = False
        continue
    for j in range(2 * v, MAX, v):
        prime[j] = False
    counted.add(v)

ans = 0
for v in X:
    ans += int(prime[v])
print(ans)


Measured memory_bytes: 132488
#include <bits/stdc++.h>
using namespace std;
#define SORT(a) sort((a).begin(), (a).end())
#define RSORT(a) reverse((a).begin(), (a).end())
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;
const long long INF = 1LL << 60;

int main() {
  int n, m;
  cin >> n >> m;
  vector<string> a(n);
  vector<string> b(m);
  rep(i, n) cin >> a[i];
  rep(i, m) cin >> b[i];
  bool ans = false;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
        if(i+m-1>=n || j+m-1>=n) continue;
        bool tf=true;
      for (int k = 0; k < m; k++) {
        for (int s = 0; s < m; s++) {
            if(a[i+k][j+s]!=b[k][s]) tf=false;
        }
      }
        if(tf) ans=true;
    }
  }
  if (ans)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}


Measured memory_bytes: 256
function main()
	lines=readlines()
	N,M=map(x->parse(Int,x),split(shift!(lines)))
	X=Array{Int}(0)
	Y=Array{Int}(0)
	Z=Array{Int}(0)
	for s=lines
		x,y,z=map(x->parse(Int,x),split(s))
		push!(X,x)
		push!(Y,y)
		push!(Z,z)
	end
	ans=0
	for i=0:7
		if i%2==1
			Z=-Z
		end
		if i%4==2
			Y=-Y
		end
		if i==4
			X=-X
		end
		now=X+Y+Z
		sort!(now)
		ret=0
		for j=1:M
			ret+=now[N-j+1]
		end
		ans=max(ans,ret)
	end
	println(ans)
end
main()


Measured memory_bytes: 117132
# include <bits/stdc++.h>
#define INF 1e9
using namespace std;

int main(){
  int N; cin >> N;
  int B[N];
  for(int i=0; i < N-1; i++){
    cin >> B[i];
  }

  int ans = 0;
  ans += B[0];
  for(int i=1; i < N-1; i++){
    ans += min(B[i], B[i-1]);
    // cout << ans << endl;
  }
  ans += B[N-2];

  cout << ans << endl;

}


Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;

public static class P
{
    public static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        long res = 0;
        for (int i = 1; i <= n; i++)
        {
            if (i % 3 != 0 && i % 5 != 0) res += i;
        }
        Console.WriteLine(res);
    }


    static long GCD(long a, long b)
    {
        while (true)
        {
            if (b == 0) return a;
            a %= b;
            if (a == 0) return b;
            b %= a;
        }
    }
}

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

using namespace std;

#define INF 100000000
#define YJ 1145141919
#define INF_INT_MAX 2147483647
#define INF_LL 9223372036854775
#define INF_LL_MAX 9223372036854775807
#define EPS 1e-10
#define MOD 1000000007
#define MOD9 998244353
#define Pi acos(-1)
#define LL long long
#define ULL unsigned long long
#define LD long double

#define int long long

using II = pair<int, int>;

int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }
int extgcd(int a, int b, int &x, int &y) { int g = a; x = 1; y = 0; if (b != 0) g = extgcd(b, a % b, y, x), y -= (a / b) * x; return g; }

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(a)  begin((a)), end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())

const int MAX_N = 200005;
int N;
int Q;
vector<int> edge[MAX_N];

int num[MAX_N];

void dfs(int pos = 0, int pre = -1)
{
  for(int next : edge[pos]) {
    if(next == pre) continue;
    num[next] += num[pos];
    dfs(next, pos);
  }
}

signed main()
{
  cin >> N >> Q;
  REP(n,N-1) {
    int a, b; cin >> a >> b; a--; b--;
    edge[a].push_back(b); edge[b].push_back(a);
  }

  REP(q,Q) {
    int p,x;
    cin >> p >> x;
    p--;
    num[p] += x;
  }

  dfs();

  REP(n,N) {
    cout << num[n];
    if(n < N-1) cout << " ";
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 24320
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef pair<ll,ll> P;
#define fi first
#define se second
set<string> c;
map<ll,ll> mp;
const ll mod=1000000007;
const ll mod2=998244353;
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
int n,q;
vector<vector<ll>> graph;
vector<ll> ques;
vector<ll> score;
void dfs(int bfo,int now,ll point){
    point+=ques.at(now);
    score.at(now)=point;
    for(int i=0;i<graph.at(now).size();i++){
       if(graph.at(now).at(i)==bfo)continue;
        dfs(now,graph.at(now).at(i),point);
    }
    return;
}
int main(){
cin>>n>>q;
graph.resize(n);
for(int i=0;i<n-1;i++){
    ll a,b;
    cin>>a>>b;
    a--;b--;
    graph.at(a).push_back(b);
    graph.at(b).push_back(a);
}
score.resize(n);
ques.resize(n);
for(int i=0;i<q;i++){
     ll c,d;
     cin>>c>>d;
     c--;
     ques.at(c)+=d;
}
dfs(0,0,0);
for(int i=0;i<n;i++){
    cout<<score.at(i)<<" ";
}
cout<<endl;
}


Measured memory_bytes: 32128
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;

int main() {
    ll N, K;
    cin >> N >> K;
    vector<ll> h(N);
    for (ll i = 0; i < N; i++) {
        cin >> h[i];
    }

    vector<ll> dp(N + K, LLONG_MAX);
    dp[0] = 0;
    for (ll i = 0; i < N - 1; i++) {
        for (ll j = 1; j <= K; j++) {
            dp[i + j] = min(dp[i + j], dp[i] + abs(h[i] - h[i + j]));
        }
    }

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

Measured memory_bytes: 1792
use std::cmp::*;
use std::io::*;

fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let n: usize = itr.next().unwrap().parse().unwrap();
    let mut m = n;
    let mut o = 0;
    let mut p = 0;
    while m > 9 {
        o += m % 10;
        m /= 10;
        p += 1;
    }

    println!("{}", max(m - 1 + p * 9, m + o));
}


Measured memory_bytes: 2144
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int W = sc.nextInt();
		int H = sc.nextInt();
		
		int x = sc.nextInt();
		int y = sc.nextInt();
		int r = sc.nextInt();
		
		if(r<=x&&r<=y&&r<=(Math.sqrt(x*x+y*y))&&x+r<=W&&y+r<=H&&(Math.sqrt(x*x+y*y)+r<=Math.sqrt(W*W+H*H)))
		{
			System.out.println("Yes");
		}
		else
		{
			System.out.println("No");
		}
	}
}



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

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int n; cin >> n;
	vector<long long> a(n + 1);
	vector<long long> pre(n + 1);
	vector<long long> suf(n + 1);
	vector<int> cut_pre(n + 1);
	vector<int> cut_suf(n + 1);
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
	}
	for (int i = 1; i <= n; i++) {
		pre[i] = pre[i - 1] + a[i];
		suf[i] = suf[i - 1] + a[n + 1 - i];
	}
	for (int j = 0, i = 1; i <= n; i++) {
		while (j < i && pre[j + 1] * 2 <= pre[i]) j++;
		cut_pre[i] = j;
	}
	for (int j = 0, i = 1; i <= n; i++) {
		while (j < i && suf[j + 1] * 2 <= suf[i]) j++;
		cut_suf[i] = j;
	}
	long long ans = 1LL<<60;
	for (int i = 2; i <= n - 2; i++) {
		for (int j = cut_pre[i]; j <= cut_pre[i] + 1 && j <= i - 1; j++) {
			for (int k = cut_suf[n - i]; k <= cut_suf[n - i] + 1 && k <= n - i - 1; k++) {
				long long b = pre[j], c = pre[i] - pre[j];
				long long d = suf[k], e = suf[n - i] - suf[k];
				long long maxv = max(max(c, b), max(e, d));
				long long minv = min(min(c, b), min(e, d));
				ans = min(ans, maxv - minv);
			}
		}
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;

int main()
{
    int n,a[1000],s1=0,s2=0,i;
    cin>>n;
    for(i=0; i<n; i++)
    {
        cin>>a[i];
    }
    sort(a,a+n);
    for(i=n-1; i>=0; i=i-2)
    {
        s1=s1+a[i];
    }
     for(i=n-2; i>=0; i=i-2)
    {
        s2=s2+a[i];
    }
    //cout<<s1<<' '<<s2<<endl;
    cout<<s1-s2<<endl;

    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.StringReader;
import java.util.StringTokenizer;

public class Main  implements Runnable {
    public static void main(String[] args) {
        new Thread(null, new Main(), "", 64 * 1024 * 1024).start();
    }
    public void run() {
    	FastScanner sc = new FastScanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		int n = Integer.parseInt(sc.next());
		//int b = Integer.parseInt(sc.next());

		int[] a = new int [n];
		for (int i = 0; i < n; i++) {
			a[i] = Integer.parseInt(sc.next());
		}
		

		int[] l = new int [n];
		int[] r = new int [n];
		l[0] = a[0];
		r[n-1] = a[n-1];
		for (int i = 1; i < n; i++) {
			l[i] = gcd(l[i-1], a[i]);
		}		
		for (int i = n-2; i >= 0; i--) {
			r[i] = gcd(r[i+1], a[i]);
		}
		int ans = Math.max(l[n-2], r[1]);
		for (int i = 1; i < n-1; i++) {
			ans = Math.max(ans, gcd(l[i-1], r[i+1]));
		}
		out.printf("%d\n", ans);
		out.println();
		out.flush();
	}
    int gcd(int m, int n) {
        if(m < n)
        {
        	return gcd(n, m);
        }
        if(n==0)
        {
        	return m;
        }
        return gcd(n, m % n);
    }
    
    static class FastScanner {
        private BufferedReader reader = null;
        private StringTokenizer tokenizer = null;
        public FastScanner(String in) {
        	StringReader sr = new StringReader(in);
            reader = new BufferedReader(new BufferedReader(sr));
            tokenizer = null;
        }
        public FastScanner(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
            tokenizer = null;
        }
        public String next() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }
        public String nextLine() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    return reader.readLine();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken("\n");
        }
    }
}

Measured memory_bytes: 42020
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main(){
 ll n,m,net=0;
 cin>>n>>m;
 ll a[n];
 for(ll i=0;i<n;i++){
  cin>>a[i];
  net+=a[i];
 }
 sort(a,a+n,greater<ll>());
 float th=(float)net/(4.0*(float)m);
 if(a[m-1]<th)
  cout<<"No";
 else
  cout<<"Yes";
}


Measured memory_bytes: 256
import bisect
n = int(input())
s = input()
r = []
g = []
b = []
for i in range(n):
	if s[i] == "R":
		r.append(i+1)
	elif s[i] == "G":
		g.append(i+1)
	else:
		b.append(i+1)
ans = 0
if len(r) == 0 or len(g) == 0 or len(b) == 0:
	print (0)
	exit()
for i in r:
	for j in g:
		ans += len(b)
		if i > j:
			k = j-abs(i-j)
			m = i+abs(i-j)
		else:
			k = j+abs(i-j)
			m = i-abs(i-j)
		if k <= b[-1] and k >= b[0]:
			x = bisect.bisect_left(b,k)
			if x >= 0 and x < len(b):
				if b[x] == k:
					ans -= 1
		if m <= b[-1] and m >= b[0]:
			x = bisect.bisect_left(b,m)
			if x >= 0 and x < len(b):
				if b[x] == m:
					ans -= 1
		l = (i+j)//2
		if abs(i-l) == abs(j-l):
			x = bisect.bisect_left(b,l)
			if x >= 0 and x < len(b):
				if b[x] == l:
					ans -= 1
print (ans)

Measured memory_bytes: 76592