akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/pb_ds/tree_policy.hpp"
using namespace __gnu_pbds;
using namespace std;
#define mem(x,y) memset(x,y,sizeof(x))  
#define lli long long int
#define ll long long 
#define ld long double
#define pb push_back
#define mp make_pair
#define F first
#define S second 
#define LB lower_bound
#define UB upper_bound
#define BS binary_search
#define pii pair<lli,lli>
const long long int mod=1000000007;
//const long long int mod=998244353;
const long double PI=3.141592653589793;
const long long int inf=1e18;
const long long int inf2=LLONG_MAX;
#define setBitCount(x) __builtin_popcountll(x)
#define all(a) (a).begin(), (a).end()
#define all_r(a) (a).rbegin(), (a).rend()
#define endl "\n"
lli gcd(lli a,lli b)
{
    if(b==0)
    return a;
    else
    return gcd(b,a%b);
}
lli lcm(lli a,lli b)
{
    return ((a*b)/gcd(a,b));
}
// calculating (x^y)%p
lli power(lli x,lli y,lli p)
{
    lli res = 1;      
    x = x % p;  
    while (y > 0)
    {
        if (y & 1) //y is odd  
        res = (res*x) % p;
        y = y>>1; 
        x = ( (x%p)*(x%p) )% p;  
    }
    return res%p;
}
// calculating modular inverse using fermat little theorem
lli modInverse(lli n,lli p) 
{
    return power(n, p-2, p)%p;
}

// policy based data structures !!
#define ordered_set tree<lli, null_type,less<lli>, rb_tree_tag,tree_order_statistics_node_update>
// s.order_of_key (k) : Number of items strictly smaller than k
// *(s.find_by_order(k)) : K-th element in a set (counting from zero)

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

    //freopen("given.in","r",stdin);
    //freopen("given.out","w",stdout);
   
    
    lli n;
    cin>>n;

    lli a[n+5],b[n+5],c[n+5];
    for(lli i=1;i<=n;i++)
    {
        cin>>a[i]>>b[i]>>c[i];
    }

    lli dp[n+5][3];
    mem(dp,0);

    for(lli i=1;i<=n;i++)
    {
        dp[i][0]=max(dp[i-1][1],dp[i-1][2])+a[i];
        dp[i][1]=max(dp[i-1][0],dp[i-1][2])+b[i];
        dp[i][2]=max(dp[i-1][1],dp[i-1][0])+c[i];
    }

    lli ans=max(dp[n][0],max(dp[n][1],dp[n][2]));
    cout<<ans;
    
    return 0;
}

Measured memory_bytes: 4992
#include <stdio.h>
#include <math.h>
int main()
{
    int a;
    scanf("%d",&a);
    while(a>=1)
    {
        if(fmod(sqrt(a),1)==0)
        {
            printf("%d\n",a);
            break;
        }
        a--;
    }
    return 0;
}


Measured memory_bytes: 128
from collections import Counter
N = list(input())
M = [0]
S = 0
K = 1
ans = 0

for i in range(len(N)):
    S += int(N[-i-1])*K
    S %= 2019

    K *= 10
    K %= 2019
    M.append(S)

P = Counter(M)
for i in range(2020):ans+=P[i]*(P[i]-1)//2
print(ans)


Measured memory_bytes: 17852
#include<cstdio>
#include<algorithm>
using namespace std;
int n,k;
long long qzh1[100005],qzh2[100005],a[100005],cnt,ans=-200000000000000;
int main()
{
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;++i) {scanf("%lld",&a[i]);qzh1[i]=qzh1[i-1];qzh2[i]=qzh2[i-1];if(a[i]>0) qzh1[i]+=a[i];else qzh2[i]+=a[i];}
	for(int i=k;i<=n;++i) ans=max(ans,max(qzh1[n]-qzh1[i]+qzh1[i-k],qzh1[n]+qzh2[i]-qzh2[i-k]));
	printf("%lld\n",ans);
	return 0;
}

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

template<typename T,T MOD,T B>
struct RollingHash{
  vector<T> hash,p;
  RollingHash(){}
  RollingHash(const string &s){
    int n=s.size();
    hash.assign(n+1,0);
    p.assign(n+1,1);
    for(int i=0;i<n;i++){
      hash[i+1]=(hash[i]*B+s[i])%MOD;
      p[i+1]=p[i]*B%MOD;
    }
  }
  //S[l, r)
  T find(int l,int r){
    T res=hash[r]+MOD-hash[l]*p[r-l]%MOD;
    return res>=MOD?res-MOD:res;
  }
};
//END CUT HERE
//INSERT ABOVE HERE
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  int n;
  string s;
  cin>>n>>s;
  using ll = long long;
  const ll MOD = 1e9+9;
  const ll B = 1362341;
  using RH = RollingHash<ll, MOD, B>;
  RH R(s);

  int l=0,r=n/2+1;
  while(r-l>1){
    int mid=(r+l)/2;
    map<ll,int>M;
    for(int i=0;i<n-mid+1;i++){
      ll x=R.find(i,i+mid);
      if(M.count(x) && M[x]<i){
        l=mid;
        goto L;
      }
      if(!M.count(x)){
        M[x] = i+mid-1;
      }
    }
    r=mid;
    L:;
    //cout<<l<<' '<<r<<endl;
  }

  cout<<l<<endl;

  return 0;
}

Measured memory_bytes: 640
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

template <typename T>
void print(T x) {
    cout << x << "\n";
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REVFOR(i, m, n) for (int i = (n - 1); i >= (m); --i)
#define REP(i, n) FOR(i, 0, n)
#define REVREP(i, n) REVFOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

int main() {
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    string s; cin >> s;

    vector<string> p = {"dream", "dreamer", "erase", "eraser"};
    REP(i, p.size()) reverse(ALL(p[i]));

    reverse(ALL(s));

    int i = 0;
    while(i < s.size()) {
        int prev = i;
        REP(j, p.size()) {
            bool f = true;
            REP(k, p[j].size()) {
                f &= s[i + k] == p[j][k];
                if (!f) break;
            }

            if (f) {
                i += p[j].size();
                break;
            }
        }

        if (i == prev) {
            print("NO");
            return 0;
        }
    }

    print("YES");
}

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

	int a = scan.nextInt();
    int b = scan.nextInt();
    int c = scan.nextInt();
    
    int x = a-b;
    if(c<=x){
      System.out.println(0);
    }else{
      int y = Math.abs(c-x);
      System.out.println(y);
    }
    
    
    
  }
}



Measured memory_bytes: 20948
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scanf("%d", &n)

	rating := scanIntSlice(n)
	colors := map[int]struct{}{}
	experts := 0
	for _, r := range rating {
		if r >= 3200 {
			experts++
		} else {
			colors[r/400] = struct{}{}
		}
	}

	if len(colors) == 0 {
		fmt.Printf("%d %d", 1, experts)
	} else {
		fmt.Printf("%d %d", len(colors), len(colors)+experts)
	}

}

func scanIntSlice(size int) []int {
	input := []int{}
	for i := 0; i < size; i++ {
		var in int
		fmt.Scanf("%d", &in)
		input = append(input, in)
	}
	return input
}


Measured memory_bytes: 512
package main

import "fmt"

func main() {
    var A, B int
    fmt.Scan(&A, &B)

    for i := 0; i < B; i++ {
        var C int
        fmt.Scan(&C)
        A = A - C
    }

    if A <= 0 {
        fmt.Println("Yes")
    } else {
        fmt.Println("No")
    }

}


Measured memory_bytes: 6320
#include <iostream>
#define int long long
using namespace std;

int mod = 1000000007;
int h, w, a, b;
int fact[300000];

void init() {
	fact[0] = 1;
	for (int i = 1; i < 300000; i++) {
		fact[i] = (fact[i-1] * i) % mod;
	}
}

int power(int a, int n) {
	if (n == 0) return 1;
	if (n % 2 == 0) return power((a * a) % mod, n / 2) % mod;
	return (a * power(a, n - 1)) % mod;
}

int comb(int n, int k) {
	if (n < 0 || k < 0 || n < k) return 0;
	int ret = fact[n];
	ret *= power(fact[n - k], mod - 2);
	ret %= mod;
	ret *= power(fact[k], mod - 2);
	ret %= mod;
	return ret;
}

signed main() {
	int i;
	
	cin >> h >> w >> a >> b;
	init();
	
	int ans = 0;
	for (i = 0; i < h - a; i++) {
		int x = comb(b + i, i);
		int y = comb((h - 1 - i) + (w - b - 2), h - 1 - i);
		
		if (i == h - a - 1) {
			y = comb((h - 1 - i) + (w - b - 1), h - 1 - i);
		}
		
		ans += (x * y) % mod;
		ans %= mod;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 2560
#include <iostream>
#include <algorithm>
#include <queue>

using namespace std;

typedef long long ll;

int main() {
    int n, m; cin >> n >> m;
    priority_queue <int> box;
    int u;
    while(n--) {
        cin >> u;
        box.push(u);
    }
    
    while(m--) {
        box.push(box.top() >> 1);
        box.pop();
    }
    
    ll mx = 0;
    while(!box.empty()) {
        mx += box.top();
        box.pop();
    }
    
    cout << mx;
    
    return 0;
}

Measured memory_bytes: 892
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const double PI=acos(-1);
const int INF = numeric_limits<int>::max();

int main(){
    int N;
    cin >> N;
    ll ans = 1;
    for (int i = 0; i < N; i++) 
    {
        ll A;
        cin >> A;
        if (A == 0) 
            ans = 0;
        else if (ans <= (ll)1e18 / A && ans > 0) 
             ans *= A;
        else if (ans > 0)
            ans = -1;
    }
    cout << ans << endl;

    return 0;
}

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

int main() {
  int a, b;

  cin >> a >> b;

  int ave = (a + b) / 2;
  float ave2 = (a + b) / 2.0;

  ave2 -= ave;

  ave2 *= 10;

  if (ave2 > 4) cout << ave + 1 << endl;
  else cout << ave << endl;

  return (0);
}


Measured memory_bytes: 256
#include <iostream>
#define llint long long

using namespace std;

llint N, K;

int main(void)
{
	cin >> N >> K;
	
	if(K == 0){
		cout << N*N << endl;
		return 0;
	}
	
	llint ans = 0;
	for(int b = K+1; b <= N; b++){
		llint k = N/b;
		ans += k*(b-K);
		ans += max(0LL, N - (k*b+K)+1) ;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main()
{
	int n;
	cin >> n;
	vector<ll> freq(100001);
	int arr[n];
	ll sum = 0;
	for(int i=0;i<n;i++){
		cin >> arr[i];
		freq[arr[i]]++;
		sum += arr[i];
	}
	int q;
	cin >> q;
	while(q--){
		ll b,c;
		cin >> b >> c;
		sum = sum - freq[b] * b + freq[b] * c;
		freq[c] += freq[b];
		freq[b] = 0;
		cout << sum << "\n";
	}
}

Measured memory_bytes: 4260
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
					*/

#include <stdio.h>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <numeric>
#include <iostream>
#include <random>
#include <map>
#include <unordered_map>
#include <queue>

#pragma GCC optimize("Ofast")
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for(int i = 1; i < (n); ++i)
#define rep2(i, n) for(int i = 2; i < (n); ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define reprm(i, n) for(int i = n - 1; i >= 0; --i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printin(a) printf(a ? "possible\n" : "inposible\n")
#define printdb(a) printf("%.16f\n", a)//少数出力
#define prints(s) printf("%s\n", s.c_str())//string出力
#define all(x) (x).begin(), (x).end()
#define allsum(a, b, c) ((a + b) * c / 2)//等差数列の和、初項,末項,項数
#define pb push_back
#define priq priority_queue

using ll = long long;

const int INF = 1073741823;
const int MINF = -1073741823;
const ll LINF = ll(4661686018427387903);
const ll MOD = 1000000007;
const double PI = acos(-1);

using namespace std;

void scans(string & str) {
	char c;
	scanf("%c", &c);
	while (c != '\n' && c != -1) {
		str += c;
		scanf("%c", &c);
	}
}

/*-----------------------------------------ここからコード-----------------------------------------*/


int main() {

	string s;
	int w;
	scans(s);
	scanf("%d", &w);
	for (int i = 0; i < s.length(); i += w) {
		printf("%c", s[i]);
	}
	printf("\n");

 	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <algorithm>
#include <numeric>
#include <utility>
#include <random>
#include <chrono>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
//const int mod = 1e9+7;
const int N = 90;
ll stock[N], n;

inline void quickread() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
}
void show(vector<ll> & a) {
    for(auto i: a) cout << i << " ";
    cout << endl;
}
void solve() {
    vector<ll> prices;
    for(int i = 1; i <= n; i ++) {
        if(stock[i] != stock[i-1]) prices.push_back(stock[i]);
    }
    n = prices.size();
    //show(prices);
    vector<ll> sign(n, 0);
    for(int i = 0; i < n; i ++) {
        if((i == 0 || prices[i] < prices[i-1]) && i < n && prices[i] < prices[i+1]) sign[i] = 1;
        if((i == n-1 || prices[i] > prices[i+1]) && i > 0 && prices[i] > prices[i-1]) sign[i] = 2;
    }
    ll curr = 1000;
    ll num = 0;
    //show(sign);
    for(int i = 0; i < n; i ++) {
        if(sign[i] == 1) {
            num += curr / prices[i];
            curr %= prices[i];
        } else if(sign[i] == 2) {
            curr += num*prices[i];
            num = 0;
        }
    }
    cout << curr << endl;
}

int main() {
    quickread();
    cin >> n;
    for(int i = 1; i <= n; i ++) cin >> stock[i];
    solve();
    return 0;
}


Measured memory_bytes: 3660
#include<bits/stdc++.h>
using namespace std;
 
#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG false

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

int main() {
	
	int w, a, b;
	cin >> w >> a >> b;
	if(a > b) swap(a, b);
	
	cout << max(0, b-(a+w)) << endl;
	
	return 0;
}

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

using namespace std;

int main(){
    string str;
    cin >> str;
    const int n = str.length();
    vector<string> vs(n);
    for(int i=0;i<n;i++){
        vs[i] = str.substr(i,1);
    }

    int bit;
    for(int i=0;i<(1<<n);i++){
        int total = stoi(vs[0]);
        for(int j=0;j<n-1;j++){
            if((i>>j)%2){
                total += stoi(vs[j+1]);
            }else{
                total -= stoi(vs[j+1]);
            }
        }
        if(total == 7){
            bit = i;
            break;
        }
    }

    for(int j=0;j<n-1;j++){
        cout << vs[j];
        if((bit>>j)%2){
            cout << "+";
        }else{
            cout << "-";
        }
    }
    cout << vs[n-1] << "=7" << endl;
}

Measured memory_bytes: 256
/**
 * CODE
 * BY
 * VIKAS VERMA
 * 
 * $$Always Check for Constraints
*/
#include <bits/stdc++.h>
using namespace std;
#define fo(i, n) for (int i = 0; i < n; i++)
#define Fo(i, n) for (int i = 1; k <= n; i++)
#define f_range(l, r) for (int i = l; i < r; i++)
#define jaldi ios_base::sync_with_stdio(0), cin.tie(NULL), cout.tie(NULL);
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define PI 3.1415926535897932384626
#define endl "\n"
#define F first
#define S second
#define PB push_back
#define MP make_pair
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpii;
typedef vector<vi> vvi;
typedef long long ll;
//=======================
const int MOD = 1'000'000'007;
const int N = 2e6 + 13;
//=======================
vi g[N];
int a[N];
//=======================

void solve()
{
  string s;
  cin >> s;
  ll count = 0;
  for (int i = 0; i < s.length(); i++)
  {
    count += s[i] - '0';
  }
  if (count % 9 == 0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

int main()
{
  jaldi
      // #ifndef ONLINE_JUDGE
      //       freopen("input.txt", "r", stdin);
      //   freopen("output.txt", "w", stdout);
      // #endif
      int t = 1;

  // cin >> t;

  while (t--)
  {
    solve();
  }

  return 0;
}

Measured memory_bytes: 50588
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int K = sc.nextInt();


       int Ks[]=new int[32];
       Ks[0]=1;
       Ks[1]=1;
       Ks[2]=1;
       Ks[3]=2;
       Ks[4]=1;
       Ks[5]=2;
       Ks[6]=1;
       Ks[7]=5;
       Ks[8]=2;
       Ks[9]=2;
       Ks[10]=1;
       Ks[11]=5;
       Ks[12]=1;
       Ks[13]=2;
       Ks[14]=1;
       Ks[15]=14;
       Ks[16]=1;
       Ks[17]=5;
       Ks[18]=1;
       Ks[19]=5;
       Ks[20]=2;
       Ks[21]=2;
       Ks[22]=1;
       Ks[23]=15;
       Ks[24]=2;
       Ks[25]=2;
       Ks[26]=5;
       Ks[27]=4;
       Ks[28]=1;
       Ks[29]=4;
       Ks[30]=1;
       Ks[31]=51;


  System.out.println(Ks[K-1]);



    }
}


Measured memory_bytes: 23380
//============================================================================
// Name        : l
// Date        : Wed Feb 20 21:45:48 CST 2019
// Author      : landcold7
// Description : Actions speak louder more than words
//============================================================================
#include "bits/stdc++.h"
using namespace std;

#define pb push_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define mst(x, y) memset(x, y, sizeof(x))
#define pvar(x) cout << #x << ": "
#define fora(e, c) for (auto &e : c)
#define fori(i, a, b) for (int i = a; i < b; ++i)
#define ford(i, a, b) for (int i = a; i > b; --i)
#define output(v) cout << (v) << '\n'
#define prt(x, a, n) { cout << x[a]; if (a < n - 1) cout << " "; }
#define pvi(x, v) if(v) pvar(x); fora(a, x) cout << a << " "; cout << "\n"
#define par(x, s, n, v) if(v) pvar(x); fori(y, s, n) prt(x, y, n) cout << "\n"

#ifndef __has_trace
#define trace(...)
#endif
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef vector<pii> vpii;

const int maxn = 3007;
const ll inf = 1e18 + 7;

ll dp[maxn][maxn][2];
int aa[maxn];

ll rec(int l, int r, int who){
    if (dp[l][r][who] != -inf) {
        return dp[l][r][who];
    }

    if (l > r) {
        return 0;
    }

    if (who == 0){
        ll x = -inf;
        x = max(x, aa[l] + rec(l + 1, r, 1));
        x = max(x, aa[r] + rec(l, r - 1, 1));
        return dp[l][r][who] = x;
    } else{
        ll x = inf;
        x = min(x, -aa[l] + rec(l + 1, r, 0));
        x = min(x, -aa[r] + rec(l, r - 1, 0));
        return dp[l][r][who] = x;
    }
}

void solve() {
    int n; cin >> n;
    fori (i, 1, n + 1) {
        cin >> aa[i];
    }

    fori (i, 0, maxn) fori (j, 0, maxn) fori (k, 0, 2) {
        dp[i][j][k] = -inf;
    }

    output(rec(1, n, 0));
}

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



Measured memory_bytes: 141824
#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <set>
#include <utility>
#include <cstdlib>
#include <queue>
#include <iomanip>
#include <cstdio>

using namespace std;


int N;
int ans;
int a[100001];

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

    for(int i=1;i<=N;i++)
        if(a[i]==i)
        {
            swap(a[i+1],a[i]);
            ans++;
        }

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



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

int main(){
    long long N,K ;
    cin >> N>>K;

    vector<int> S(N) ;
    for (int i = 0; i < N+1; i++)
    {
        S[i] = i ;
     //   cout << i <<": " <<S[i]<<", " ;
    }
   // cout << endl ;
    long long ans = 0;
    long long ue = (N*(N+(long)1))/(long)2 ;
    // cout << ue ;
    // cin >> ans ;
    for (long long i = K; i <= N+1; i++)    {
     // cout << i <<endl ;
      //  int ge = accumulate(S.begin(),S.begin()+i,0);
      //  cout << *S.end()-(i-1)<<"~" << *S.end() <<endl;
      //  int jo = accumulate(S.end()-(i-1),S.end()+1,0);
      //  cout << i <<" J,G:"<<jo << " " <<ge << endl ;

      long long ge = ((i-1)*(i))/2 ;
      long long jo = ue- (N-i+1)*(N-i)/2;

      //long long jo = i*(2*N-i+1)/2 ;
    //   cout <<ue<<"-"<< (N-i+1)*(N-i)/2<<endl;
    //   cout << i <<" J,G:"<<jo << " " <<ge << endl ;
        ans += jo-ge+1 ;
    }

    ans = ans%1000000007 ;
    

    cout << ans <<endl;
    

    return 0 ;
}

Measured memory_bytes: 4060
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<utility>
#include<set>
#include<stack>
#include<list>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cstring>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<cmath>
#include<cctype>


#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define ren(i,a,b) for(int i=a;i>=b;i--)
#define ff first
#define ss second
#define pll pair<long long int,long long int>
#define pii pair<int,int>
#define vll vector<long long int>
#define vii vector<int>
#define gi(n) scanf("%d",&n)
#define gll(n) scanf("%lld",&n)
#define gstr(n) scanf("%s",n)
#define gl(n) cin >> n
#define oi(n) printf("%d",n)
#define oll(n) printf("%lld",n)
#define ostr(n) printf("%s",n)
#define ol(n) cout << n
#define os cout<<" "
#define on cout<<"\n"
#define o2(a,b) cout<<a<<" "<<b
#define all(n) n.begin(),n.end()
#define present(s,x) (s.find(x) != s.end())
#define cpresent(s,x) (find(all(s),x) != s.end())
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
using namespace std;

typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
typedef vector<vector<ll> > mat;

int main()
{ios_base::sync_with_stdio(false);
int n,m,k;
cin>>n>>m>>k;

rep(i,0,n)
{
	rep(j,0,m)
	{
		int cnt=i*(m-j)+j*(n-i);
		if(cnt==k)
		{
			ol("Yes");
			return 0;
		}
	}
}
ol("No");
return 0;
}



Measured memory_bytes: 256
globals().update({"s": input()}) or ((lambda it: set(it.takewhile(lambda _: len([globals().update({"s": s[:-len(w)]}) for w in ["dreamer", "eraser", "dream", "erase"] if s.endswith(w)]), it.repeat(0))))(__import__("itertools")) or True) and print(s and "NO" or "YES")

Measured memory_bytes: 3316
#include <iostream>
using namespace std;
unsigned long long n,q,h,s,d;
unsigned long long khuye[120000000];
int main()
{
    cin>>q>>h>>s>>d;
    cin>>n;
    h=min(h,2*q);
    s=min(s,2*h);
    d=min(d,s*2);
    cout<<n/2*d+n%2*s;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define rep(i, a, b) for (ll i = a; i < b; i++)
#define per(i, a, b) for (ll i = a; i > b; i--)
#define vi vector<int>
#define vii vector<vi>
#define vl vector<ll>
#define vll vector<vl>
#define pb push_back
#define pii pair<int, int>
#define pll pair<ll, ll>
#define ff first
#define ss second
#define a(v) (v.begin(), v.end())
#define intlimit 2e9 + 69
#define longlimit 8e18 + 69
#define MOD 1000000007
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) ((a) * (b) / gcd(a, b))
using namespace std;
vii v;
vi vis;
int coco = 0;
void dfs(int x){
    vis[x]++;
    coco++;
    for(int u:v[x]){
        if(!vis[u]){
            dfs(u);
        }
    }
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n, m;
    cin >> n >> m;
    v.resize(n + 1);
    rep(i, 0, m)
    {
        int n1, n2;
        cin >> n1 >> n2;
        v[n1].pb(n2);
        v[n2].pb(n1);
    }
    vis.resize(n + 1, 0);
    int maxi = 0;
    rep(i, 1, n + 1)
    {
        if (!vis[i])
        {
            coco = 0;
            dfs(i);
            maxi = max(maxi, coco);
        }
    }
    cout << maxi;
}


Measured memory_bytes: 21144
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>

 
using namespace std;
 
int gcd(int x,int y)
{
    while(x!=y)
    {
        if(x>y) x=x-y;
        else
            y=y-x;
    }
    return x;
}
int main()
{
    long long a,b,c,d;
    cin >> a >> b >> c >> d;
    long long lcm = (c*d)/gcd(c,d);
    long long s;
    long long t;
    long long n = 0;
    s = b - (b%c);
    t = (s-a) /c;
    if(s >= a)
        n += t +1;

    s = b - (b%d);
    t = (s-a) /d;
    if(s>=a)
        n += t+1;

    s = b - (b%lcm);
    t = (s-a) /lcm;
    if(s>=a)
        n -= t+1;

    cout << (b-a+1) - n << endl;
    return 0;
}

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

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define chmax(a,b) (a<b?(a=b,1):0)
#define chmin(a,b) (a>b?(a=b,1):0)
#define valid(y,x,h,w) (0<=y&&y<h&&0<=x&&x<w)
const int INF = 1<<29;
const double EPS = 1e-8;
const double PI = acos(-1);
typedef long long ll;
typedef pair<int,int> pii;

int main() {
  int a = 0;
  REP(i,10) {
    int x; cin >> x;
    a += x;
  }
  cout << a << endl;
}

Measured memory_bytes: 1160
/* Coached by Dukkha */
#include <stdio.h>

int count(int n) {
	return n == 0 ? 0 : count(n / 10) + 1;
}

int main() {
	int n, k, h, p3, p2, b, cnt;

	scanf("%d", &n);
	k = count(n);
	cnt = 0;
	p3 = 27, p2 = 8;
	for (h = 3; h < k; h++) {
		cnt += p3 - p2 * 3 + 3;
		p3 *= 3, p2 *= 2;
	}
	for (b = 0; b < p3; b++) {
		int a, k3, k5, k7, x;

		k3 = k5 = k7 = 0;
		x = 0;
		a = b;
		for (h = 0; h < k; h++) {
			int d = a % 3, d_;

			if (d == 0)
				k3++, d_ = 3;
			else if (d == 1)
				k5++, d_ = 5;
			else
				k7++, d_ = 7;
			x = x * 10 + d_;
			a /= 3;
		}
		if (k3 && k5 && k7 && x <= n)
			cnt++;
	}
	printf("%d\n", cnt);
	return 0;
}


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

int main() {
	
	int A, P;
	cin >>A >>P;
	
	int pieceOfApple, applePie;
	
	pieceOfApple= A*3+P;
	
	applePie= pieceOfApple/2;
	
	cout <<applePie;
	
}

Measured memory_bytes: 256
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();
		int c=scan.nextInt();

		if(a==5 && b==5 &&c==7) {
			System.out.println("YES");

		}else if(a==5 && b==7 && c==5) {
			System.out.println("YES");

		}else if(a==7 && b==5 && c==5) {
			System.out.println("YES");

		}else {
			System.out.println("NO");
		}

	}

}


Measured memory_bytes: 23380
//AUTHOR: *Akash Shrivastva*
//Birla Institute of Technology,Mesra,India
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define M 1000000007
#define mp make_pair
#define pb push_back
#define vll vector<ll>
#define pll vector< pair <ll,ll> >
#define F first
#define S second
#define PII pair <ll,ll>
ll a[200001],f[200001],n,k;
ll check(ll mid)
{
	ll i,c=0;
	for (i=0;i<n;i++)
	{
		if (a[i]*f[i]>mid)	c+=a[i]-mid/f[i];
	}
	if (c<=k)	return 1;
	else	return 0;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    cin>>n>>k;
    a[n];f[n];ll i;
    for (i=0;i<n;i++)	cin>>a[i];
    for (i=0;i<n;i++)	cin>>f[i];
    sort(a,a+n);
	sort(f,f+n);reverse(f,f+n);
    ll lb=0,up=pow(10,12),ans,mid,cnt;
	while (lb<=up)
	{
		mid=(lb+up)/2;
		if (check(mid))	ans=mid,up=mid-1;
		else	lb=mid+1;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 3328
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <array>
#include <vector>
#include <functional>
#include <unordered_map> 
#include <map> 
#include <numeric>
#include <limits>
#include <utility>
#include <queue>
#include <random>
#include <bitset>
#include <memory>
#include <complex>
using namespace std;
typedef long long LL;

int main() {
	int n;
	LL a=0,b=0;
	cin >>n;
	vector<int> v(n);
	for (int i = 0; i < n; i++) {
		cin >>v[i];
	}
	sort(v.begin(),v.end());

	for (int i = 0; i < n; i++) {
		if (i % 2 == 0) {
			a+=v[(n-1)-i];
		}
		else {
			b += v[(n - 1) - i];
		}
	}

	cout <<a-b<<endl;

    return 0;
}

Measured memory_bytes: 256
x = gets.to_i

def is_prime(n)
  return false if n < 2
  return true if n == 2

  return false if n % 2 == 0

  for i in 3..Math.sqrt(n)
    return false if n % i == 0
  end

  true
end

while !is_prime(x) do
  x += 1
end

puts x

Measured memory_bytes: 1788
#define REP(i, t, n)  for (int i = t; i < n; i++)
#define ALL(n)        (n).begin(),(n).end()
#include <limits.h>
#include <stdio.h>
#include <cmath>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <deque>
#include <functional>
#include <algorithm>
#include <cstring>
#include <unordered_map>
#include <numeric>

#define INF (1000000000)

using namespace std;

typedef bool               BOOL;
typedef short              WORD;
typedef unsigned short     U_WORD;
typedef long               DWORD;
typedef unsigned long      U_DWORD;
typedef long long          QWORD;
typedef unsigned long long U_QWORD;
vector<QWORD> vecCumSumW;
DWORD N;

void solve_main()
{
	DWORD inputTmp;
	QWORD qwAns = INF;
	cin >> N;

	cin >> inputTmp;
	vecCumSumW.push_back(inputTmp);

	REP(i, 1, N) {
		cin >> inputTmp;
		inputTmp += vecCumSumW[i - 1];
		vecCumSumW.push_back(inputTmp);
	}

	REP(i, 0, N) {
		QWORD qwTmpAns;
		qwTmpAns = vecCumSumW[N - 1] - (vecCumSumW[i] * 2);	
		qwAns = min(abs(qwTmpAns), qwAns);
	}

	cout << qwAns << endl;
}

int main()		
{
#ifdef FOR_IDE
	ifstream in("input.txt");
	cin.rdbuf(in.rdbuf());
#endif

	solve_main();
	return 0;
}


Measured memory_bytes: 256
/*
    Author - Param Kothari
    Ah shit, here we go again
*/

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

#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back
#define mk make_pair

typedef long long ll;
typedef long double ld;

void solve(){
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    for(int i = 0; i < n; i++)
        cin >> a[i];
    int res = 0;
    sort(a.begin(), a.end());
    for(int i = 0; i < k; i++)
        res += a[i];
    cout << res << "\n";
    return; 
}

int main(){
    IOS;
    int t = 1;
    // cin >> t;
    for(int i = 1; i <= t; i++){
        solve();
    }
    return 0;
}

Measured memory_bytes: 3620
#include "bits/stdc++.h"
// #include "boost/math/common_factor.hpp" // gcd, lcm
using namespace std;

// #define int long long

signed main(void) {
  int num; // num
  num = 0; // count, result
  // num = numeric_limits<int>::min(); // max
  // num = numeric_limits<int>::max(); // min
  int n;
  int a, b, c;
  // cin >> n;
  cin >> c >> a >> b;

  num = c * a / 2;
  cout << num << endl;
  return 0;
}


Measured memory_bytes: 256
"""
author : halo2halo
date : 31, Jan, 2020
"""

import sys

# import itertools
# import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

a, b = read().decode('utf8').split()

print('H' if a==b else 'D')


Measured memory_bytes: 2940
#include<iostream>
using namespace std;
typedef unsigned long long ll;

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

ll lcm(ll a, ll b)
{
  return a*b/gcd(a,b);
}

int main()
{
  ll A,B,C,D;cin>>A>>B>>C>>D;
  ll E=lcm(C,D);
  ll AC=(A-1)/C; ll AD = (A-1)/D; ll AE = (A-1)/E;
  ll BC=B/C; ll BD = B/D; ll BE=B/E;
  ll AS = AC+AD-AE; ll BS = BC+BD-BE;
  ll answer = B-(A-1)-(BS-AS);
  cout<<answer<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
using namespace std;

typedef long long ll;
const ll MOD = 998244353;

int n;
char buf[2000+10];
int trs[10000];
int crs[10000];
int tbs[10000];
int cbs[10000];

inline int calcMaxR(int turn) {
  return crs[turn+1];
}
inline int calcMaxB(int turn) {
  return cbs[turn+1];
}

ll memo[4010][4010];
ll solve(int pos, int r) {
  ll &res = memo[pos][r];
  if(res < 0) {
    if(pos == n*2) {
      res = 1;
    } else {
      res = 0;
      if(calcMaxR(pos) >= r+1) {
        res += solve(pos+1, r+1);
      }
      if(calcMaxB(pos) >= pos-r+1) {
        res = (res + solve(pos+1, r)) % MOD;
      }
    }
  }
  return res;
}

int main(void) {
  scanf("%s", buf);
  n = strlen(buf);
  REP(i, n) {
    if(buf[i] == '0') {
      trs[i] = 2;
    } else if(buf[i] == '1') {
      trs[i] = 1;
      tbs[i] = 1;
    } else if(buf[i] == '2') {
      tbs[i] = 2;
    } else {
      assert(false);
    }
  }
  REP(i, 2*n) {
    if(trs[i] > 1) {
      trs[i+1] += trs[i]-1;
      trs[i] = 1;
    }
    crs[i+1] = crs[i] + trs[i];
    if(tbs[i] > 1) {
      tbs[i+1] += tbs[i]-1;
      tbs[i] = 1;
    }
    cbs[i+1] = cbs[i] + tbs[i];
  }
  
  memset(memo, -1, sizeof memo);
  ll res = solve(0, 0);
  
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 126208
#include <cmath>
#include <cstdio>
#include <iostream>

using namespace std;

int main(){
    int a,b;
    scanf("%d %d",&a,&b);
    int temp = b;
    int ans = 0;
    while(temp){
        ans++;
        temp/=10;
    }
    for(int i=0; i<ans; i++){
        a*=10;
    }
    a+=b;
    int s = (int)sqrt(a*1.0);
    if(s*s==a){
        printf("Yes\n");
    }
    else{
        printf("No\n");
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int sum = 0;
        int a = n;

        while(a > 0){
            sum += a % 10;
            a = a / 10;
        }
        
        System.out.println(n % sum == 0 ? "Yes" : "No");
    }
}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
#define N 100005
using namespace std;


int main() {
  string s; cin >> s;
  int ans = 0;
  for(int i = 0; i < s.size(); i++) {
    if(s[i] == '+') ans++;
    else ans--;
  }
  cout <<ans;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int n;
    cin>>n;
    int a[n];
    for(int i = 0;i<n;i++)
    {
        cin>>a[i];
    }
    long long money = 1000;
    int j = 0;
    for(int i = 0;i<n-1;i++)
    {
        if(a[i+1]>a[i])
        {
            continue;
        }
        else
        {
            long long stocks = money/a[j];
            money = (money - (stocks*(a[j]))+(stocks*a[i]));
            j = i+1;
        }
    }
    if(j!=n-1)
    {
        long long stocks = money/a[j];
        money = (money - (stocks*(a[j])) +(stocks*a[n-1]));
    }
    cout<<money<<endl;
    return 0;
} 

Measured memory_bytes: 3596
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <climits>
#include <cmath>
#include <vector>
using namespace std;

int main(void){
    int N, X;
    cin >> N >> X;
    vector<int> x(N);
    for(int i=0; i<N; i++){
        int y;
        cin >> y;
        x[i] = abs(y - X);
    }
    
    int ans = x[0];
    for(int i=1; i<N; i++){
        ans = __gcd(ans, x[i]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
#include <stdio.h>

int main(){
	int a, b, c, d, e, f;
	scanf("%d\n", &a);
	scanf("%d\n", &b);
	scanf("%d\n", &c);
	scanf("%d\n", &d);
	scanf("%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;
	}
	f = (a + b + c + d + e) / 5;
	printf("%d\n", f);
	return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int INF=1001001001;
const long long mod=1e9+7;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
    int N,M; cin >> N >> M;
    
    vector <int> oks(N+1,true);
    rep(i,M){
        int a; cin >> a;
        oks[a]=false;
    }
    
    vector <int> dp(N+1);
    dp[0]=1;
    for (int now=0; now<N; now++){
        for (int next=now+1; next<=min(N,now+2); next++){
            if(oks[next]){
                dp[next]+=dp[now];
                dp[next]%=mod;
            }
        }
    }
    cout << dp[N] << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <algorithm>
#include <cmath>
#include <complex>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>
#include <functional>
#include <cstring>
#include <regex>
#include <random>
#include <cassert>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, s, n) for (int i = (s); i < (int)(n); i++)
#define revrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define revrepr(i, s, n) for (int i = (n) - 1; i >= s; i--)
#define debug(x) cerr << #x << ": " << x << "\n"

using ll = long long;
using P = pair<int, int>;

const long long MOD = 1e9+7;

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

template<class T>
istream& operator >>(istream &is, vector<T> &v) {
    for (int i = 0; i < (int)v.size(); i++) cin >> v.at(i);
    return is;
}

template<class T, class U>
ostream& operator <<(ostream &os, pair<T, U> p) {
    cout << '(' << p.first << ", " << p.second << ')';
    return os;
}

template<class T>
void print(const vector<T> &v, const string &delimiter) { rep(i, v.size()) cout << (0 < i ? delimiter : "") << v.at(i); cout << endl; }

template<class T>
void print(const vector<vector<T>> &vv, const string &delimiter) { for (const auto &v: vv) print(v, delimiter); }

int main() {
    ll n, a, b;
    cin >> n >> a >> b;
    ll l = n / (a + b);
    ll ans = l * a + min(a, n % (a + b));
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define FOR(n) for(int i=0;i<n;i++)
#define FORJ(n) for(int j=0;j<n;j++)
#define PRN(n) printf("%d\n",n)
#define PRF(n) printf("%lf\n",n)
#define PRL(n) printf("%lld\n",n)
#define PRS(s) printf("%s\n",s)
#define PRC(c) printf("%c",c)
#define mod 1000000007
typedef long long int ll;
int u(const void *a, const void *b){
    return *(ll*)a-*(ll*)b;
}
int d(const void *a, const void *b){
    return *(ll*)b-*(ll*)a;
}
int min(int a,int b){
  if(a>b)return b;
  return a;
}
int max(int a,int b){
  if(a>b)return a;
  return b;
}
ll gcd(ll a,ll b){
  if(!b)return a;
  return gcd(b,a%b);
}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
int kt(ll a){
  int sum=0;
  while(a){
    a/=10;
    sum++;
  }
  return sum;
}
int ks(ll a){
  int sum=0;
  while(a){
    sum+=a%10;
    a/=10;
  }
  return sum;
}
int main(void){
  int n;
  scanf("%d",&n);
  ll a,b;
  FOR(n){
    scanf("%lld",&a);
    if(i){
      b=gcd(max(a,b),min(a,b));
    }else{
      b=a;
    }
  }
  PRL(b);
  return 0;
}


Measured memory_bytes: 256
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <list>
#include <stack>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi   vector<int> 
#define   co(x)  cout << x  
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   all(a) (a.begin(),a.end())
#define   ff   first
#define   ss   second
#define   pii  pair<int,int> 
#define   lcm(a,b) (a*b)/__gcd(a,b) 
using namespace std;


int n=55555;
bool  p[55559];

void  seive(){
    p[0]=p[1]=true;
    for (int i=4;i<=n;i+=2) p[i]=true;
    for (int i=3;i*i <= n;i += 2){
        if (p[i] == false)
        for (int j=i*i;j<=n;j+= i*2)
                p[j] = true;
    }
}


inline void solve(){
    seive();
    int n,s=28; cin>>n; 
    for (int i=10;i<=55555 and n>0;i++){
        if (p[i] == false and i%5==3){
            cout << i << " ";
            n--;
        }
    }
    cout << endl;
}

signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}


Measured memory_bytes: 3564
#include <iostream>
#include <string>
using namespace std;
int main()
{
    string string1;
    string letter;
    int N;
    int i = 0;
    int count = 0;
    cin >> N;
    cin >> string1;
while (i < string1.length()){
    if ((string1[i] == 'A') && string1[i + 1] == 'B' && string1[i + 2] == 'C')
    {
        count++;
        i++;
    }
        i++;
}
cout << count;
}

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

int main(){
    int n;
    cin >> n;
    vector<int> v(n);
    for(int i=0; i<n; i++) cin >> v[i];

    int ans = 1e9;
    for(int i=0; i<n-1; i++){
        int a = 0;
        for(int k=0; k<=i; k++) a += v[k];
        int b = 0;
        for(int k=i+1; k<n; k++) b += v[k];
        ans = min(ans, abs(a - b));
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll MOD = 1000000007;
const ll INF = 10000000000000000;
vector<int> x4 = {0, 1, 0, -1}, x8 = {0, 1, 1, 1, 0, -1, -1, -1};
vector<int> y4 = {1, 0, -1, 0}, y8 = {1, 1, 0, -1, -1, -1, 0, 1};
template<class T> struct edge { int from, to; T cost;};
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;}
template<class T> inline T powerM(T a,T b){if (b==0) return 1;
T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }
template<class T> inline T power(T a,T b,T m){ if (b==0) return 1;
  T tmp = power(a,b/2,m); if (b%2==0) return tmp*tmp%m; else return tmp*tmp%m*a%m; }
template<class T> inline T gcd(T a, T b){if (b==0) return a; return gcd(b, a%b);}
template<class T> inline T lcm(T a, T b){return a / gcd(a,b) * b;}
// ax+by=gcd(a,b)を解く
template<class T> inline T extgcd(T a,T b,T &x,T &y){if (b==0){x=1; y=0; return a;} T d=extgcd(b,a%b,y,x); y -= a/b*x; return d;}


struct LazySegmentTree {
  int N;
  vector<ll> node,lazy;
  vector<bool> delay;
  LazySegmentTree(int n_){
    N = 1; while (N < n_) N *= 2;
    node.assign(2*N-1, 0); // 暫定的な合計値
    lazy.assign(2*N-1, 0); // 一様に加えるやつ
    delay.assign(2*N-1, false); // 遅延しているかどうか
  }

  // 遅延評価
  void eval(int k,int l,int r){
    if (!delay[k]) return;
    node[k] += lazy[k] * (r - l);
    if (r-l > 1){
      // 葉ノードでなければlazyを伝播する
      lazy[2*k+1] += lazy[k]; delay[2*k+1] = true;
      lazy[2*k+2] += lazy[k]; delay[2*k+2] = true;
    }
    lazy[k] = 0; delay[k] = false;
  }

  // [a,b) に各々 x を加える。見ているノード k が [l,r)
  void add(int a,int b,ll x,int k=0,int l=0,int r=-1){
    if (r == -1) r = N;
    eval(k,l,r);
    if (b <= l || r <= a) return;
    if (a <= l && r <= b){
      lazy[k] += x; delay[k] = true;
      eval(k,l,r);
      return;
    }
    add(a, b, x, 2*k+1, l, (l+r)/2);
    add(a, b, x, 2*k+2, (l+r)/2, r);
    node[k] = node[2*k+1] + node[2*k+2];
  }

  // [a,b) の合計値を返す。見ているノード k が [l,r)
  ll getsum(int a,int b,int k=0,int l=0,int r=-1){
    if (r == -1) r = N;
    eval(k,l,r);
    if (b <= l || r <= a) return 0;
    if (a <= l && r <= b) return node[k];
    ll vl = getsum(a, b, 2*k+1, l, (l+r)/2);
    ll vr = getsum(a, b, 2*k+2, (l+r)/2, r);
    return vl + vr;
  }
};

int main() {
  int N,Q; cin >>N >>Q;
  LazySegmentTree lst(N);
  rep(qq, Q){
    int query; cin >>query;
    int s,t; cin >>s >>t; s--;
    if (query == 0){
      ll x; cin >>x;
      lst.add(s,t,x);
    }else{
      cout <<lst.getsum(s,t) <<endl;
    }
  }
}



Measured memory_bytes: 7144
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define mp make_pair
#define PI pair<ll,ll>
#define poly vector<ll>
#define mem(a) memset((a),0,sizeof(a))
#define For(i,l,r) for(int i=(int)(l);i<=(int)(r);i++)
#define Rep(i,r,l) for(int i=(int)(r);i>=(int)(l);i--)
#define pb push_back
#define fi first
#define se second
#define SZ(x) ((int)(x.size()))
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline ll read(){
	ll x = 0; char ch = gc(); bool positive = 1;
	for (; !isdigit(ch); ch = gc())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = gc())	x = x * 10 + ch - '0';
	return positive ? x : -x;
}
inline void write(ll a){
    if(a<0){
    	a=-a; putchar('-');
	}
    if(a>=10)write(a/10);
    putchar('0'+a%10);
}
inline void writeln(ll a){write(a); puts("");}
inline void wri(ll a){write(a); putchar(' ');}
ll rnd(){
	ull ans=0;
	For(i,0,4)ans=ans<<15^rand();
	return ans%((ull)1<<63);
}
const int N=100005;
int n,a[N],b[N],p[N],q[N],e[N],to[N];
map<int,int> M;
void GG(){
	puts("No"); exit(0);
}
int main(){
	#ifdef Brollan
		freopen("1.in","r",stdin);
	#endif
	n=read();
	For(i,1,n)q[i]=a[i]=read();
	For(i,1,n)p[i]=b[i]=read();
	sort(q+1,q+n+1);
	sort(p+1,p+n+1);
	int f=0;
	Rep(i,n,1){
		if(q[i]>p[i])GG();
		if(i>1&&q[i]<=p[i-1])f=1;
		M[q[i]]=p[i];
	}
	if(f)puts("Yes");
	else{
		map<int,int> MM;
		For(i,1,n)MM[b[i]]=i;
		For(i,1,n)e[i]=MM[M[a[i]]];
		int cnt=1;
		for(int i=e[1];i!=1;i=e[i])cnt++;
		if(cnt==n)GG();
		puts("Yes");
	}
}


Measured memory_bytes: 14696
n = int(input())
A = [int(input()) for _ in range(n)]
A.sort()
if n%2==1:
    a = 2*sum(A[n-n//2:]) - sum(A[n-n//2-2:n-n//2]) - 2*sum(A[:n-n//2-2])
    b = -2*sum(A[:n//2]) + sum(A[n//2:n//2+2]) + 2*sum(A[n//2+2:])
    print(max(a,b))
else: print(-2*sum(A[:(n-2)//2])-A[(n-2)//2]+A[(n-2)//2+1]+2*sum(A[(n-2)//2+2:]))

Measured memory_bytes: 7488
#include <bits/stdc++.h>
#include <string>
#include <algorithm>
#include <string.h>
#include <ctype.h>
#include <math.h>
#include <float.h>
#include <iomanip>
#include <iostream>
using namespace std;
 
int main(){

    int A,B,ans=0;
    cin>>A>>B;

    for(int i=1;i<=3;i++){
        if(A==i)ans+=(4-i)*100000;
        if(B==i)ans+=(4-i)*100000;
    }

    if(A==1&&B==1)ans+=400000;
    
    cout <<ans<<endl;
    
    return 0;

}

Measured memory_bytes: 256
import std.stdio, std.string, std.conv, std.range;
import std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, std.random, core.bitop;

void main() {
    int a, b, c;
    scan(a, b, c);
    int k;
    scan(k);

    int cnt;
    while (a >= b) {
        b *= 2;
        cnt++;
    }
    while (b >= c) {
        c *= 2;
        cnt++;
    }
    yes(cnt <= k);
}

void scan(T...)(ref T args) {
    auto line = readln.split; // @suppress(dscanner.suspicious.unmodified)
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront;
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;
    foreach (arg; args)
        if (x > arg) {
            x = arg;
            isChanged = true;
        }
    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;
    foreach (arg; args)
        if (x < arg) {
            x = arg;
            isChanged = true;
        }
    return isChanged;
}

void yes(bool ok, string y = "Yes", string n = "No") {
    return writeln(ok ? y : n);
}


Measured memory_bytes: 2740