akhauriyash/Code-Regression huggingface dataset:
#include <atcoder/lazysegtree>
#include <atcoder/modint>
#include <cstdio>

using namespace std;
using namespace atcoder;
using mint = modint998244353;

struct S {
	mint a;
	int size;
};

struct F {
	mint a, b;
};

S op(S l, S r) { return S{l.a + r.a, l.size + r.size}; }

S e() { return S{0, 0}; }

S mapping(F l, S r) { return S{l.a * r.a + l.b * r.size, r.size}; }

F composition(F l, F r) { return F{r.a * l.a, r.b * l.a + l.b}; }	//l(r(x))

F id() { return F{1, 0}; }

int main() {
	int n, q;
	scanf("%d%d", &n, &q);
	
	vector<S> a(n);
	for (int i = 0; i < n; i++) {
		int x;
		scanf("%d", &x);
		a[i] = S{x, 1};
	}
	
	lazy_segtree<S, op, e, F, mapping, composition, id> seg(a);
	for (int i = 0; i < q; i++) {
		int t;
		scanf("%d", &t);
		
		if (t == 0) {
			int l, r, a, b;
			scanf("%d%d%d%d", &l, &r, &a, &b);
			seg.apply(l, r, F{a, b});
		}
		else {
			int l, r;
			scanf("%d%d", &l, &r);
			printf("%d\n", seg.prod(l, r).a.val());
		}
	}
	return 0;
}

Measured memory_bytes: 19396
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long int lli;

struct info{
    int h,a;
    double rate;
    info(int h, int a, double r):h(h), a(a), rate(r){}
};
bool comp(const info& a, const info& b){
    return a.rate > b.rate;
}

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

    lli h,a,d,s;
    cin >> h >> a >> d >> s;
    vector<info> e;
    lli sum = 0, damage = 0;
    for(int i=0; i<n; i++){
        int eh,ea,ed,es;
        cin >> eh >> ea >> ed >> es;
        ea -= d;
        if(ea <= 0) continue;
        if(es > s){
            damage += ea;
        }
        if(a-ed <= 0){
            h = 0;
            continue;
        }
        eh = (eh+(a-ed)-1)/(a-ed);
        e.push_back(info(eh, ea, (double)ea/eh));
        sum += ea;
    }
    if(h==0){
        cout << -1 << endl;
        return 0;
    }

    sort(e.begin(), e.end(), comp);
    for(int i=0; i<(int)e.size(); i++){
        int limit = (h-damage)/sum;
        if(e[i].h > limit){
            h=0;
            break;
        }
        damage += sum*(e[i].h-1);
        sum -= e[i].a;
        damage += sum;
    }
    if(h <= damage){
        cout << -1 << endl;
    }else{
        cout << damage << endl;
    }
    return 0;
}

Measured memory_bytes: 3860
#include <cstdio>
#include <climits>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <list>
#include <set>
#include <bitset>
#include <iterator>
#define rep(i, n) for(long long i = 0; i < (long long)(n); i++)
using namespace std;
typedef long long int LL;
typedef unsigned long long int ULL;
struct mise {
    LL a;
    LL b;
};
bool cmp(const mise &x, const mise &y) {
    return x.a < y.a;
}
int main() {
    LL n, m;
    cin >> n >> m;

    vector<mise> v;
    rep(i, n) {
        LL x, y;
        mise tmp;
        cin >> x >> y;
        tmp.a = x;
        tmp.b = y;
        v.push_back(tmp);
        //cout << tmp.a << " " << tmp.b << endl;

    }
    sort(v.begin(), v.end(), cmp); // [](const mise &x, const mise &y) {
                             //     return x.a < y.a;
                             //     });
    LL res = 0;
    rep(i, n) {
        mise tmp = v[i];
        LL a = tmp.a;
        LL b = tmp.b;

        if (m - b <= 0) {
            res += a * m;
            break;
        } else {
            m -= b;
            res += a * b;
        }

    }
    cout << res << endl;

    return 0;
}


Measured memory_bytes: 2420
import numpy as np
h, w = map(int, input().split())
field = [list(input()) for _ in range(h)]

#%%
np_field = np.array(field)
cols = np.logical_not(np.all(np_field=='.', axis=0))
rows = np.logical_not(np.all(np_field=='.', axis=1))

ans = np_field[np.ix_(rows, cols)]

for a in ans:
    print(''.join(map(str, a)))

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

int main()
{
    string s;
    cin >> s;

    if (s.substr(s.size()-1 ,1) == "s") {
        cout << s + "es" << endl;
    } else {
        cout << s + "s" << endl;
    }

}

Measured memory_bytes: 3596
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include<string.h>
#include <math.h>

	int main() {
		int n, d, ans = 0;
		long long b, c;
		scanf("%d %d", &n, &d);
		while (n--) {
			scanf("%lld %lld", &b, &c);
			double sum = sqrt(pow(b, 2) + pow(c, 2));
			if (sum <= d)ans++;
		}
		printf("%d", ans);
		return 0;
	}

Measured memory_bytes: 2124
#include "iostream"
using namespace std;

int main()
{
	int h, w, i = 0;
	while (cin >> h >> w&&(h!=0||w!=0))
	{
		i++;
		if (i >= 2)
		{
			cout << endl;
		}
		for (int a = 0; a < h; a++)
		{
			for (int b = 0; b < w; b++)
			{
				cout << "#";
			}
			cout << endl;
		}		
	}
	cout << endl;
}


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

#define ll long long

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
    string str;
    cin>>str;
    
    map<char,int> mp;
    
    for(int i=0;i<str.length();i++)
    {
        mp[str[i]]++;
    }
    
    if(mp.size() == 2)
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
}

Measured memory_bytes: 256
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) rep(_,v.size())cout<<" "<<v[_];cout<<endl;
#define show2d(v) rep(_,v.size()){rep(__,v[_].size())cout<<" "<<v[_][__];cout<<endl;}cout<<endl;
using namespace std;
//kaewasuretyuui
typedef long long ll;
//#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
// #define mt make_tuple
// typedef tuple<int,int,int> tp;
// typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={0,1,0,-1,1,1,-1,-1};
int dy[]={1,0,-1,0,1,-1,1,-1};//RDLU
int main(){
	int n;
	cin>>n;
	vvi in(n,vi(3));
	rep(i,n)rep(j,3)cin>>in[i][j];
	rep(i,101)rep(j,101){
		vi t;
		bool h=true;
		rep(k,n){
			int w=abs(i-in[k][0])+abs(j-in[k][1])+in[k][2];
			if(in[k][2])t.pb(w);
		}
		sort(all(t));
		if(t[0]!=t[t.size()-1])continue;
		rep(k,n)if(!in[k][2]){
			int w=abs(i-in[k][0])+abs(j-in[k][1])+in[k][2];
			if(w<t[0])h=false;
		}
		if(!h)continue;
		cout<<i<<" "<<j<<" "<<t[0]<<endl;
		
	}

}

/*
int n,m;
vvi nex[2],dp(2);
vi in;
void f(int a){
	int N=-1,t=m;
	while(t){
		vi dp(n,-1);
		int w=0;
		rep(i,n)if(dp[i]==-1){
			int l=i,r=i+1;
			while(r<n&&in[r]-in[r-1]<=t)r++;
			loop(j,l,r)dp[j]=r;
		}
		nex[a].pb(dp);
		t/=2;
		N++;
	}
	dp[a]=vi(1<<N,-1);
	dp[a][0]=0;
	rep(i,1<<N)if(dp[a][i]-n)rep(j,N)if((i&1<<j)==0)cmax(dp[a][i|1<<j],nex[a][j+1][dp[a][i]]);
}
int main(){
	cin>>n>>m;
	in=vi(n);
	rep(i,n)cin>>in[i];
	
	f(0);
	rep(i,n)in[i]*=-1;
	sort(all(in));
	f(1);
	
	rep(i,n){
		int l=n-nex[1][0][i]-1,r=nex[0][0][i];
		bool h=false;
		
	}
	
}
*/








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

using namespace std;

using ll = long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;

using _loop_int = int;
#define REP(i,n) for(_loop_int i=0; i<(_loop_int)(n); i++)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a); i<(_loop_int)(b); i++)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1; i>=(_loop_int)(a); i--)

#define CHMIN(a,b) (a)=min((a),(b))
#define CHMAX(a,b) (a)=max((a),(b))
#define ALL(v) (v).begin(),(v).end()

#define DEBUG(x) cerr<<#x<<": "<<(x)<<endl
#define DEBUG_VEC(v) cerr<<#v<<": ";REP(__i,(v).size())cerr<<((v)[__i])<<", ";cerr<<endl

const ll MOD = 1000000007ll;

int main(){
    int n,k;
    cin>>n>>k;
    cout<<(k==1 ? 0 : n-k)<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <vector>
#include <algorithm>
#include <limits.h>
#include <iostream>
#include <set>
#include <cmath>
#include <queue>
#include <cstring>
#include <string.h>
#include <stdio.h>
#include <iomanip>
#include <map>
#include <unordered_map>
const int N=1e5+1;
int f[N];

using namespace std;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
   int n; cin>>n; int W; cin>>W;
   int w[n]; int v[n];
   for(int i=0;i<n;i++) {cin>>w[i]>>v[i];}


   long long int f[n+1][W+1];
   for(int i=0;i<=n;i++)
   {
       for(int j=0;j<=W;j++)
       {
           f[i][j]=0;
       }
   }


   for(int i=0;i<=n;i++) f[i][0]=0;
   for(int i=0;i<=W;i++) f[0][i]=0;


   for(int i=1;i<=n;i++)
   {
       for(int j=0;j<=W;j++)
       {
           f[i][j]=f[i-1][j];
           if(j-w[i-1]>=0) {f[i][j]=max(f[i][j],f[i-1][j-w[i-1]]+v[i-1]);}
       }
   }

cout<<f[n][W]<<"\n";



    return 0;
}

Measured memory_bytes: 79232
# def base_10_to_n(X, n):
#     if (int(X/n)):
#         return base_10_to_n(int(X/n), n)+str(X%n)
#     return str(X%n)



# def main():

#     alp = 'abcdefghijklmnopqrstuvwxyz'
#     n = int(input())

#     s = base_10_to_n(n-1,26)
#     print(s)


# if __name__ == "__main__":
#     main()

alp = 'abcdefghijklmnopqrstuvwxyz'
n = int(input())
for i in range(10):
    ind1 = 26*(pow(26,i-1)-1)//25 + 1
    ind2 = 26*(pow(26,i)-1)//25 + 1
    if ind1 <= n < ind2:
        n_len = i

# print(n_len)

n = n
ans = ''
for i in range(20,1,-1):
    curr_a = n%26
    ind = curr_a -1
    if ind == -1: ind = 25
    ans += alp[ind]
    if n < 26:
        break
    n = n//26
    if ind == 25: 
        n=n-1
        if n <= 0:break

print(ans[::-1])

Measured memory_bytes: 62036
import sys
input = sys.stdin.readline
n, x = [int(x) for x in input().strip().split()]
burgers = [False] * (n + 1)
burgers[0] = 'p'
leng = [1] * (n + 1)
patties = [1] * (n + 1)
for i in range(1, n+1):
    leng[i] = 2 * leng[i-1] + 3
    patties[i] = 2 * patties[i-1] + 1
def burger(l, x):
    if l == 0:
        ret = 1
    elif x == 1:
        ret = 0
    elif x <= leng[l] // 2:
        ret = burger(l-1, x-1)
    elif x == leng[l] // 2 + 1:
        ret = burger(l-1, x-2) + 1
    elif x < leng[l] - 2:
        ret = burger(l-1, leng[l-1]) + 1 + burger(l-1, x-2-leng[l-1])
    else:
        ret = patties[l]
    return ret

print(burger(n, x))

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

int main(){
    int N;
    cin>>N;
    for(int i=0;i<=9;i++){
        if(100*i+10*i+i<=N && N<=100*(i+1)+10*(i+1)+(i+1)){
            cout<<100*(i+1)+10*(i+1)+(i+1)<<endl;
            break;
        }
    }
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
    char Ba,a,b;
    int i=1;
    Ba='A';
    while(scanf("%c,%c",&a,&b) != EOF)
    {
        if(Ba==a)Ba=b;
        else if(Ba==b)Ba=a;
        fflush(stdin);
    }
    printf("%c\n",Ba);
    return 0;
}

Measured memory_bytes: 1140
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
int grid[2000][2000];
int n, m, ans;
void dodiag1(int x, int y, int d)
{
//	if (x != 801 || y != 801 || d != 1) return;
	int x2 = x+d;
	int y2 = y+d;

	int a1 = x-d;
	int b1 = y+d;

	int a2 = a1+d;
	int b2 = b1+d;

	int i1 = x+d;
	int j1 = y-d;
	int i2 = i1+d;
	int j2 = j1+d;

//	printf("%lld %lld %lld %lld\n", x2, y2, a2, b2);
	int am = 0;
	int a = a1;
	int b = b1;
	while (a <= a2 && b <= b2)
	{
		am += grid[a][b];
		a++;
		b++;
	}
	a = i1;
	b = j1;
	while (a <= i2 && b <= j2)
	{
		am += grid[a][b];
		a++;
		b++;
	}
	while (x2 <= 800+n && y2 <= 800+m)
	{
		if (grid[x][y] && grid[x2][y2]) ans += am;
		am -= grid[a1++][b1++];
		am += grid[++a2][++b2];
		am -= grid[i1++][j1++];
		am += grid[++i2][++j2];
		x++;
		y++;
		x2++;
		y2++;
	}
}
void dodiag2(int x, int y, int d)
{
//	if (x != 801 || y != 801 || d != 1) return;
	int x2 = x+d;
	int y2 = y-d;

	int a1 = x+d;
	int b1 = y+d;

	int a2 = a1+d;
	int b2 = b1-d;

	int i1 = x-d;
	int j1 = y-d;
	int i2 = i1+d;
	int j2 = j1-d;

//	printf("%lld %lld %lld %lld\n", x2, y2, a2, b2);
	int am = 0;
	int a = a1;
	int b = b1;
	while (a < a2 && b > b2)
	{
		am += grid[a][b];
		a++;
		b--;
	}
	a = i1;
	b = j1;
	while (a < i2 && b > j2)
	{
		am += grid[a][b];
		a++;
		b--;
	}
	while (x2 <= 800+n && y2 >= 800)
	{
		am -= grid[a1++][b1--];
		am -= grid[i1++][j1--];
		if (grid[x][y] && grid[x2][y2]) 
		{
		//	if (am) printf("%lld %lld, %lld %lld\n", x, y, x2, y2);
			ans += am;
		}
		am += grid[a2++][b2--];
		am += grid[i2++][j2--];
		x++;
		y--;
		x2++;
		y2--;
	}
}
#undef int
int main()
{
	#define int ll
	scanf("%lld%lld", &n, &m);
	for (int i = 800+1; i <= 800+n; i++)
	{
		for (int j = 800+1; j <= 800+m; j++) 
		{
			char a;
			scanf(" %c", &a);
			if (a == '#') grid[i][j] = 1;
		}
	}
	for (int i = 800+1; i <= 800+n; i++) 
	{
		for (int d = 1; d <= max(n, m); d++) dodiag1(i, 801, d);
	}
	for (int i = 800+2; i <= 800+m; i++) 
	{
		for (int d = 1; d <= max(n, m); d++) dodiag1(801, i, d);
	}
	for (int i = 800+1; i <= 800+n; i++) 
	{
		for (int d = 1; d <= max(n, m); d++) dodiag2(i, 800+m, d);
	}
	for (int i = 800+1; i < 800+m; i++) 
	{
		for (int d = 1; d <= max(n, m); d++) dodiag2(801, i, d);
	}
	printf("%lld\n", ans);
}

Measured memory_bytes: 6400
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <complex>
#include <deque>
#include <valarray>
#include <unordered_map>
#include <unordered_set>
#include <array>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <chrono>
#include <random>
#include <numeric>
using namespace std;
using ll = long long;
using ld = long double;
using str = string;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vs> vvs;
typedef vector<vc> vvc;
typedef vector<vb> vvb;
using P = pair<ll,ll>;
#define REP(i, n) for (ll i = 0; i < (int)(n); i++)
#define RREP(i, n) for (ll i = (int)(n)-1; i > -1 ; i--)
#define IN(T, x) T x;cin >> x;
#define AIN(T, a, n) vector<T> a(n);REP(i, n){cin >> a[i];}
#define A2IN(T1, a, T2, b, n) vector<T1> a(n);vector<T2> b(n);REP(i, n){cin >> a[i] >> b[i];}
#define ALL(a) (a).begin(),(a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) SORT(a);reverse(ALL(a))
#define pb push_back
#define mp make_pair
#define PF first
#define PS second
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
template<typename A, size_t N, typename T>void Fill(A (&array)[N], const T &val){fill( (T*)array, (T*)(array+N), val );}
#define OUT(x) cout << x << endl;
#define OUTD(x) cout << fixed << x << endl;
#define BOUT(b) if(b){OUT("Yes");}else{OUT("No");}
const ll MOD = 1000000007;
const ll INF = 10e9;
#define PI 3.14159265369;
ll dx[4] = {1,-1,0,0};
ll dy[4] = {0,0,1,-1};
ll ddx[8] = {1,1,1,-1,-1,-1,0,0};
ll ddy[8] = {0,1,-1,0,1,-1,1,-1};

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  IN(ll,L);
  IN(ll,R);
  ll ans = INF;
  for(ll i = L; i < R; i++){
    if(L%2019 == i%2019 && i != L){
      break;
    }
    for(ll j = i+1; j <= R; j++){
      if((i+1)%2019 == j%2019 && i+1 != j){
        break;
      }
      ll num = (i%2019)*(j%2019)%2019;
      chmin(ans,num);
    }
  }
  OUT(ans);
}

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

using namespace std;

using ll = long long int;

#define REP(i, N) for (int i = 0; i < (N); ++i)
#define scanInt(x) int x; scanf("%d", &(x)); getchar();
#define scanLLInt(x) ll x; scanf("%lld", &(x)); getchar();
#define scanVecInt(A, N) vector<int> A(N); REP(i, N){scanf("%d", &(A[i])); getchar();}
#define scanVecLLInt(A, N) vector<ll> A(N); REP(i, N){scanf("%lld", &(A[i])); getchar();}

int main()
{
    scanInt(N);
    vector<vector<char>> board(N, vector<char>(N));
    REP(i, N){REP(j, N){scanf("%c", &(board[i][j]));} getchar();}
    // REP(i, N){
    //     REP(j, N){
    //         cout << board[i][j] << " ";
    //     }
    //     cout << endl;
    // }
    vector<char> flag(N, true);
    REP(i, N){
        REP(j, N){
            const char temp = board[i][j];
            REP(b, N){
                if (board[(j + b) % N][(i - b + N) % N] != temp) flag[b] = false;
            }
        }
    }
    int sum = 0;
    REP(b, N){
        if (flag[b]) ++sum;
    }
    cout << sum * N << endl;
}


Measured memory_bytes: 384
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <iomanip>
#include <array>
#include <numeric>
#include <regex>
#include <bitset>
#include <deque>

using namespace std;
typedef long long ll;
typedef pair<int, int> p_ii;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)

const int INF = 1e9;
const double PI = acos(-1.0);
const ll MOD = 1e9 + 7;


int main() {
	
	int h, w;
	cin >> h >> w;
	string str[26][26];
	rep(i, h)rep(j, w)cin >> str[i][j];

	rep(i, h)rep(j, w) {
		if (str[i][j] == "snuke") {
			cout << (char)(j + 'A') << i + 1 << endl;
			return 0;
		}
	}

	return 0;
}

Measured memory_bytes: 256
import math
n,k = map(int,input().split())
a_list = [i for i in map(int,input().split())]
cnt_list = [0 for i in range(40)]
maxi = 0
if k == 0:
    maxi = sum(a_list)
else:
    for i in a_list:
        b = bin(i)[2:]
        b = b[::-1]
        for index,j in enumerate(b):
            cnt_list[-(index+1)] += int(j)
    goukei = 0
    for i in range(40):
        if cnt_list[i] <= n/2 and (goukei + 2**(39-i)) <= k:
            goukei += 2**(39-i)
            maxi += (2**(39-i)) * (n - cnt_list[i])
        else:
            maxi += (2**(39-i)) * (cnt_list[i])

print(maxi)


Measured memory_bytes: 14620
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath> // sqrt
#define _GLIBCXX_DEBUG // check []
#define DIVISOR 1000000007

using namespace std;
typedef pair<int,int> pii;
typedef pair<int64_t, int64_t> pII;

template<typename T>
void cins(vector<T>& arr) { for(T& e: arr) cin >> e; }

#ifdef DEBUG
#define debug(fmt, ...) \
    printf("[debug: %s] " fmt, __func__, __VA_ARGS__)
#define ps(arr) \
    debug("size %ld: ", arr.size()); \
    for(auto e: arr) cout << e << " "; \
    cout << endl;
#else
#define debug(fmt, ...)
#define ps(arr)
#endif


#define NUM_MAX 3500
int main(void) {
    int64_t num;
    cin >> num;

    vector<int> ans(3);
    for(int64_t k1 = 1; k1 <= NUM_MAX; k1++) {
        for(int64_t k2 = 1; k2 <= NUM_MAX; k2++) {
            int64_t nume = (int64_t)num * k1 * k2;
            int64_t deno = 4*k1*k2 - num*k1 - num*k2;
            if(deno <= 0) continue;
            if(nume%deno) continue;
            int64_t k3 = nume/deno;
            ans[0] = k1; ans[1] = k2; ans[2] = k3;
            break;
        }
    }

    for(auto e: ans) cout << e << " ";
    cout << endl;
    return 0;
}

Measured memory_bytes: 3632
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <iostream>
#include <string>
using namespace std;

using ll=long long;

int main()
{
    
    ll N,A,B;
    cin>>N>>A>>B;
    ll C=A+B;
    ll res=N/C*A;
    ll Y=N%C;
    if(Y>A){
        res+=A;
    }else{
        res+=Y;
    }
    cout<<res<<endl;
   
    return 0;
}


Measured memory_bytes: 888
import sys
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))

h,n=MAP()
a=LIST()
b=sum(a)
if h<=b:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 53316
import java.util.Scanner;

//AtCoder Beginner Contest 126
//A	Changing a Character
public class Main {

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

		sc.close();

		String ans = "";
		for (int i = 0; i < N; i++) {
			if (i == K - 1) {
				ans = ans + String.valueOf((char)(S.charAt(i) + 32));
			} else {
				ans = ans + S.charAt(i);
			}

		}
		System.out.print(ans);
	}
}


Measured memory_bytes: 21844
#include <iostream>
#include <cmath>
#include <algorithm>
#include <map>
#include <string>
#include <vector>
#define FOR(i, a, b)  for(int i=a; i<b; ++i)
#define rFOR(i, a, b) for(int i=a-1; i>=b; --i)
#define REP(i, n) for(int i=0; i<n; ++i)
#define rREP(i, n) for(int i=n-1; i>=0; --i)
#define all(a)  a.begin(), a.end()
#define MAXNUM = 300000
using namespace std;



int main(){
  int a, b; cin >> a >> b;
  if(a<=8 && b<=8)  cout << "Yay!" << endl;
  else  cout << ":(" << endl;
  return 0;
}


Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rp(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define p_queue(v) priority_queue<v, vector<v>, greater<v> >
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

void solve(){
    int n,m;
    cin >> n >> m;
    vi p(n+1);
    vi gru(n+1,0);
    repi(i,1,n+1){
        cin >> p.at(i);
    }
    vector<vector<int>> gra(n+1,vi(0));
    rp(i,m){
        int x,y;
        cin >> x >> y;
        gra[x].pb(y);
        gra[y].pb(x);
    }
    int gnum=1;
    repi(i,1,n+1){
        if(gru[i]!=0) continue;
        gru[i]=gnum;
        queue<int> que;
        for(int nxt:gra[i]){
            if(gru[nxt]!=0) continue;
            gru[nxt]=gnum;
            que.push(nxt);
        }
        while(!que.empty()){
            int q=que.front(); que.pop();
            for(int nxt:gra[q]){
                if(gru[nxt]!=0) continue;
                gru[nxt]=gnum;
                que.push(nxt);
            }
        }
        gnum++;
    }
    vector<vi> scr(n+1,vi(0)),name(n+1,vi(0));
    int ans=0;
    repi(i,1,n+1){
        if(gru[i]==0){
            if(p[i]==i) ans++;
            continue;
        }
        scr[gru[i]].pb(p[i]);
        name[gru[i]].pb(i);
    }
    repi(i,1,n+1){
        for(auto num:scr[i]){
            int a=upper_bound(all(name[i]),num)-lower_bound(all(name[i]),num);
            if(a>0) ans++;
        }
    }
    print(ans);
    return;
}
int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    solve();
    return 0;
}

Measured memory_bytes: 15232
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<int>; using VVI = vector<VI>; using VVVI = vector<VVI>;
const int inf=1e9+7;
const ll INF=1LL<<61;
const ll mod=1e9+7;

int main(){
  int i,j;
  int n;
  cin>>n;
  int p[n],q[n];
  for(i=0;i<n;i++) cin>>p[i];
  for(i=0;i<n;i++) cin>>q[i];
  VI perm(n);
  for(i=0;i<n;i++) perm[i]=i+1;
  int cnt=0;
  int pp,qq;
  do{
      cnt++;
      int f=0,f2=0;
      for(i=0;i<n;i++){
          if(p[i]!=perm[i]) break;
          if(i==n-1) f=1;
      }
      if(f==1) pp=cnt;
      for(i=0;i<n;i++){
          if(q[i]!=perm[i]) break;
          if(i==n-1) f2=1;
      }
      if(f2==1) qq=cnt;
} while(next_permutation(perm.begin(),perm.end()));

  cout<<abs(pp-qq)<<endl;
  
  return 0;
}


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

#define fi first
#define se second
#define show(x) cerr << #x << "=" << "\n"
typedef long long ll;
typedef unsigned long long ull;

using namespace std;
const ll llinf = LLONG_MAX;
const ull ullinf = ULLONG_MAX;

string s;
ll k;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(10);
  cout << fixed;
#ifdef LOCAL_DEFINE
  FILE *stream1;
  //FILE *stream2;
  stream1 = freopen("in.txt", "r", stdin);
  //stream2 = freopen("out.txt", "w", stdout);
  if (stream1 == NULL) return 0;
  //if (stream2 == NULL) return 0;:w
#endif
  cin >> s >> k;
	k--;
	int one = -1;
	for (int i = 0; i < (int)s.size(); i++) {
	  if (s[i] == '1') one = i;
		else break;
	}
	if (k > one) {
	  cout << s[one + 1] << endl;
	} else {
	  cout << 1 << endl;
	}
#ifdef LOCAL_DEFINE
  cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << "s.\n";
  fclose(stream1);
  //fclose(stream2);
#endif
  return 0;
}


Measured memory_bytes: 256
use std::io::{self, BufRead};

fn gcd(x: usize, y: usize) -> usize {
  let (mut a, mut b) = if x < y {
    (y, x)
  } else {
    (x, y)
  };
  while b != 0 {
    let r = a % b;
    a = b;
    b = r;
  }
  a
}

fn lcm_by_gcd(x: usize, y: usize, g: usize) -> usize {
  x * y / g
}

fn main() {
  let stdin = io::stdin();
  let mut lines = stdin.lock().lines();
  let xs: Vec<usize> = lines.next().unwrap().unwrap().split(' ').map(|x| x.parse().unwrap()).collect();
  let g = gcd(xs[0], xs[1]);
  let l = lcm_by_gcd(xs[0], xs[1], g);
  println!("{}", l);
}

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

string FMT_F = "%.10f";

static File _f;
void file_io(string fn) { _f = File(fn, "r"); }
static string[] s_rd;
T _RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T _RD(T = long)(File f) { while(!s_rd.length) s_rd = f.readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T[] _RDA(T = long)(T fix = 0) { auto r = readln.chomp.split.to!(T[]); r[] += fix; return r; }
T[] _RDA(T = long)(File f, T fix = 0) { auto r = f.readln.chomp.split.to!(T[]); r[] += fix; return r; }
T RD(T = long)() { if (_f.isOpen) return _RD!T(_f); else return _RD!T; }
T[] RDA(T = long)(T fix = 0) { if (_f.isOpen)  return _RDA!T(_f, fix); else return _RDA!T(fix); }

size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

void chmin(T)(ref T x, T y) { x = min(x, y); } void chmax(T)(ref T x, T y) { x = max(x, y); }
bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
T lcm(T)(T x, T y) { return x * (y / gcd(x, y)); }

long mod = 10^^9 + 7;
//long mod = 998_244_353;
//long mod = 1_000_003;
void moda(T)(ref T x, T y) { x = (x + y) % mod; }
void mods(T)(ref T x, T y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(T)(ref T x, T y) { x = (x * y) % mod; }
void modpow(T)(ref T x, T y) { if (!y) { x = 1; return; } auto t = x; x.modpow(y>>1); x.modm(x); if (y&1) x.modm(t); }
void modd(T)(ref T x, T y) { x.modm(y.modpow(mod - 2)); }

void main()
{
	auto S = RD!string;

	writeln(S == "ABC" ? "ARC" : "ABC");
	stdout.flush;
	debug readln;
}

Measured memory_bytes: 2696
path = []
num = [0 for _ in range(4)]
for _ in range(3):
    a, b = map(int, input().split())
    num[a-1] += 1
    num[b-1] += 1
    path.append((a, b))

num_1_set = set()
for i in range(4):
    if num[i] == 1:
        num_1_set.add(i+1)

ans = 'NO'
for a, b in path:
    if a != b:
        if a not in num_1_set and b not in num_1_set:
            ans = 'YES'
            break
print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define pb push_back
#define ers erase
#define ins insert
#define F first
#define S second
#define debug(x)  cerr << #x << " = " << x << endl
#define kill(x) return cout << x, 0;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef string str;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vl;


const ld Pi = 3.14159265359;
const ll MOD = 1000 * 1000 * 1000 + 7;
const ll MAXN = 2e5 + 10;
const ll INF = 1e18;
ll n, a[MAXN], par[MAXN];
ll ans;
int main(){
	IOS;
	cin >> n;
	cin >> par[0];
	for (int i = 1; i < n; i++){
		cin >> a[i];
		par[i] = par[i - 1] + a[i];
 	}
	sort(par, par + n);
	ll last = 0;
	par[n] = INF;
	for (ll i = 1; i < n + 1; i++){
		if (par[i] != par[i - 1]){
			ans += (i - 1 - last)*(i - last) / 2;
			last = i;
		}
	}
	for (int i = 0; i < n; i++) ans += (par[i] == 0);
	cout << ans;
	
	
	return 0;
}






/*
     ,---,           ___                 ,--,
    '  .' \        ,--.'|_             ,--.'|                             ,--,
   /  ;    '.      |  | :,'            |  | :                           ,--.'|    ,---.        ,---,
  :  :       \     :  : ' :            :  : '                 .--.--.   |  |,    '   ,'\   ,-+-. /  |
  :  |   /\   \  .;__,'  /    ,--.--.  |  ' |     ,--.--.    /  /    '  `--'_   /   /   | ,--.'|'   |
  |  :  ' ;.   : |  |   |    /       \ '  | |    /       \  |  :  /`./  ,' ,'| .   ; ,. :|   |  ,"' |
  |  |  ;/  \   \:__,'| :   .--.  .-. ||  | :   .--.  .-. | |  :  ;_    '  | | '   | |: :|   | /  | |
  '  :  | \  \ ,'  '  : |__  \__\/: . .'  : |__  \__\/: . .  \  \    `. |  | : '   | .; :|   | |  | |
  |  |  '  '--'    |  | '.'| ," .--.; ||  | '.'| ," .--.; |   `----.   \'  : |_|   :    ||   | |  |/
  |  :  :          ;  :    ;/  /  ,.  |;  :    ;/  /  ,.  |  /  /`--'  /|  | '.'\   \  / |   | |--'
  |  | ,'          |  ,   /;  :   .'   \  ,   /;  :   .'   \'--'.     / ;  :    ;`----'  |   |/
  `--''             ---`-' |  ,     .-./---`-' |  ,     .-./  `--'---'  |  ,   /         '---'
                            `--`---'            `--`---'                 ---`-'
*/




Measured memory_bytes: 3328
from itertools import combinations
import numpy as np
n,d=map(int,input().split())
array=[]
x=[list(map(int,input().split())) for i in range(n)]
cnt=0
for y,z in combinations(x, 2):
  a=(sum(dif**2 for dif in np.array(y)-np.array(z))**0.5)
  if a.is_integer():
    cnt+=1
print(cnt)
    


Measured memory_bytes: 13016
#include <cassert>
#include <algorithm>
#include <cctype>
#include <complex>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <ctime>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <sstream>
#include <tuple>
#include <typeinfo>
#include <unordered_set>
#include <unordered_map>
#include <vector>
using namespace std;

#define REP2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define REPD(i, n) for(int i = (int)(n) - 1; i >= 0; i--)
#define REP(i, n) REP2(i, 0, n)
#define ALL(c) (c).begin(), (c).end()
#define PB(e) push_back(e)
#define FOREACH(i, c) for(auto i = (c).begin(); i != (c).end(); ++i)
#define MP(a, b) make_pair(a, b)
#define BIT(n, m) (((n) >> (m)) & 1)

typedef long long ll;

template <typename S, typename T> ostream &operator<<(ostream &out, const pair<S, T> &p) {
  out << "(" << p.first << ", " << p.second << ")";
  return out;
}

template <typename T> ostream &operator<<(ostream &out, const vector<T> &v) {
  out << "[";
  REP(i, v.size()){
    if (i > 0) out << ", ";
    out << v[i];
  }
  out << "]";
  return out;
}

typedef pair<int, int> PI;

int main(int argc, char *argv[]) {
  int N;
  cin >> N;
  vector<PI> ps;
  map<PI, ll> pair_count;

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

    ll number = 0;
    int rest = 9;
    bool period = false;
    REP(i, s.size()) {
      if (s[i] != '.') {
        number = number * 10 + s[i] - '0';
        if (period) {
          rest--;
        }
      } else {
        period = true;
      }
    }

    int div2 = rest;
    int div5 = rest;
    while (number % 2 == 0) {
      number /= 2;
      div2++;
    }
    while (number % 5 == 0) {
      number /= 5;
      div5++;
    }
    pair_count[PI(min(20, div2), min(20, div5))]++;
  }

  ll res = 0;
  map<PI, int> iterated;
  for (const auto &p: pair_count) {
    // cout << p << endl;
    if (p.first.first * 2 >= 18 && p.first.second * 2 >= 18) {
      res += p.second * (p.second - 1) / 2;
    }
    for (const auto &q: iterated) {
      if (p.first.first + q.first.first >= 18 && p.first.second + q.first.second >= 18) {
        res += p.second * q.second;
      }
    }
    iterated[p.first] = p.second;
  }
  cout << res << endl;
}


Measured memory_bytes: 3624
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int,int> P;

int main(){
  int n;
  cin >> n;
  bool ok = 0;
  if(n%10==9)ok=1;
  if(n/10==9)ok=1;
  if(ok)cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
n,k=map(int,input().split())
mod=10**9+7
n_max=4*(10**5+1)
F,FI=[0]*(n_max+1),[0]*(n_max+1)
F[0],FI[0]=1,1
for i in range(n_max):
  F[i+1]=(F[i]*(i+1))%mod
FI[n_max-1]=pow(F[n_max-1],mod-2,mod)
for i in reversed(range(n_max-1)):
  FI[i]=(FI[i+1]*(i+1))%mod
def comb(x,y):
  return (F[x]*FI[x-y]*FI[y])%mod

if k>=n-1:
  print(comb(2*n-1,n))
else:
  ans=1
  for i in range(k):
    ans=(ans+comb(n,i+1)*comb(n-1,i+1))%mod

  print(ans)

Measured memory_bytes: 34676
#include<iostream>
#include<cmath>
using namespace std;
int main() {
  long long D,N;
  cin >> D >> N;
  if(N < 100)  cout << pow(100,D) * N << endl;
  else{
  int ans = pow(100,D) * (N+1);
  cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 640
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd
from itertools import accumulate, permutations, combinations, product, groupby, combinations_with_replacement
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from heapq import heappush, heappop
from functools import reduce
from decimal import Decimal, ROUND_CEILING
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

R, C, K = MAP()

dp = [[0]*4 for _ in range(C+1)]
field = [[0]*(C+1)] + [[0]*(C+1) for _ in range(R)]

for _ in range(K):
    r, c, v = MAP()
    field[r][c] = v

for i in range(1, R+1):
    dp_next = [[0]*4 for _ in range(C+1)]
    for j in range(1, C+1):
        up_max = max(dp[j])
        p = field[i][j]
        dp_next[j][0] = max(up_max, dp[j-1][0])
        dp_next[j][1] = max(up_max+p, dp_next[j-1][1], dp_next[j-1][0]+p)
        dp_next[j][2] = max(dp_next[j-1][2], dp_next[j-1][1]+p)
        dp_next[j][3] = max(dp_next[j-1][3], dp_next[j-1][2]+p)
    dp = dp_next

print(max(dp[-1]))


Measured memory_bytes: 226876
N,K = map(int,input().split())
P = [int(i) for i in input().split()]

S = []

a = 0
for i in range(N):
  a += P[i]
  S.append(a)

B = []
for i in range(N-K+1):
  if i == 0:
    B.append(S[K-1])
  else:
    B.append(S[(K-1)+i]-S[-1+i])

print(max(B)/2 + K/2)

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

int main() {
	int h, w; cin >> h >> w;
	vector<int> a(26, 0);
	for (int i = 0; i < h * w; i++) {
		char c; cin >> c;
		a[c - 'a']++;
	}
	int cnt1, cnt2;
	cnt1 = cnt2 = 0;
	for (auto x : a) {
		if (x % 2) cnt1++;
		if (x % 4 == 2) cnt2++;
	}
	cout << ((cnt1 <= h*w%2 && cnt2 <= h/2*(w%2)+w/2*(h%2)) ? "Yes" : "No") << '\n';
	return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, n) for (int i = 1; i <= (int)(n); i++)
#define ll long long
int in() {int x; cin>>x; return x;}
ll lin() {ll x; cin>>x; return x;}
string sin() {string x;cin>>x;return x;}
using graph = vector<vector<int>>;
using graph2 = vector<vector<pair<int, int>>>;

bool ifprime(int x){
    if(x==1)return false;
    if(x==2)return true;
    if(x%2==0)return false;
    for(int i=2;i*i<=x;i++){if(x%i==0)return false;}
    return true;
}
ll mod(ll x, ll y){if(x>=0||x%y==0) return x%y;return y+x%y;} //mod including minus
ll dv0(ll x, ll y){if(x>=0||x%y==0)return x/y;return x/y-1;} //rnd down
ll dv1(ll x, ll y){if(x%y==0) return dv0(x,y);return dv0(x,y)+1;} //rnd up

//Start from Here
int main(){
    ll N=lin();
    ll sum=0;
    rep2(i, N){
        if(i%3!=0&&i%5!=0){
            sum+=i;
        }
    }
    cout<<sum<<endl;
}

Measured memory_bytes: 3628
N, Y = list(map(int, input().split()))

ans = 0
for y in range(N +1):
    for w in range(N +1):
        if y*10000+w*5000+(N-y-w)*1000 == Y and N-y-w >= 0:
            ans = str(y)+" "+str(w)+" "+str(N-y-w)

if ans == 0:
    print(-1, -1, -1)
else:
    print(ans)

Measured memory_bytes: 9076
#include<stdio.h>
#include<math.h>
int main(void){
double x1,x2,y1,y2,g;
scanf("%lf %lf %lf %lf",&x1,&y1,&x2,&y2);
g=(x2-x1)*(x2-x1)+(y2-y1)*(y2-y1);
printf("%lf\n",sqrt(g));
return 0;
}

Measured memory_bytes: 652
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e3;
const ll inf = (1ll << 33) - ll(2e9);
int n, a[maxn + 10], b[maxn + 10];;
ll x[maxn + 10], y[maxn + 10], d[maxn + 10];
ll bkx[maxn + 10], bky[maxn + 10];

void update(ll v, int *a) {
	a[1] = 1; v -= d[1];
	for (int i = 2; i <= 34; ++i)
		v += d[i];
	assert(v % 2 == 0);
	v /= 2;
	assert(v >= 0 && (v < (1ll << 33)));
	for (int i = 34; i >= 2; --i)
		if (d[i] <= v) {
			v -= d[i]; a[i] = 1;
		} else a[i] = -1;
}

void getans(int x, int y) {
	if (x == 1 && y == 1) printf("R");
	else if (x == 1 && y == -1) printf("U");
	else if (x == -1 && y == 1) printf("D");
	else printf("L");
}

int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; ++i) {
		int a, b;
		scanf("%d%d", &a, &b);
		bkx[i] = a; bky[i] = b;
		x[i] = a + b; y[i] = a - b;
	}
	for (int i = 1; i <= n; ++i)
		if ((x[i] + x[1]) % 2 || (y[i] + x[1]) % 2) {
			printf("-1"); return 0;
		}
	if (x[1] & 1) d[1] = inf;
	else d[1] = inf - 1;
	for (int i = 2; i <= 34; ++i) d[i] = 1ll << (i - 2);
	printf("%d\n", 34);
	for (int i = 1; i <= 34; ++i)
		printf("%lld ", d[i]);
	printf("\n");
	for (int i = 1; i <= n; ++i) {
		update(x[i], a);
		update(y[i], b);
		ll nowx = 0, nowy = 0;
		for (int j = 1; j <= 34; ++j) {
			getans(a[j], b[j]);
			if (a[j] == 1 && b[j] == 1) nowx += d[j];
			else if (a[j] == 1 && b[j] == -1) nowy += d[j];
			else if (a[j] == -1 && b[j] == 1) nowy -= d[j];
			else nowx -= d[j];
		}
		assert(nowx == bkx[i] && nowy == bky[i]);
		printf("\n");
	}
}


Measured memory_bytes: 384
N=input()
N=int(N)
L=[]

def diff(L):
    total=0
    for i in range(len(L)-1):
        total+=abs(L[i+1]-L[i])
    return total
for i in range(N):
    A=input()
    L.append(int(A))
L.sort()
if len(L)>3:
    length=len(L)
    SL=L[:int(length/2)]
    LL=L[int(length/2):]
    result=[]
    result.append(SL[-1])
    SL.pop(-1)
    last=LL[0]
    LL.pop(0)
    while True:
        try:
            result.append(LL[-1])
            LL.pop(-1)
            result.append(SL[0])
            SL.pop(0)
        except:
            break
    if abs(result[-1]-last)>=abs(result[0]-last): 
        result.append(last)
    else:
        result.insert(0,last)
    print(diff(result))
elif len(L)==3:
    all=[diff([L[0],L[1],L[2]]),diff([L[0],L[2],L[1]]),diff([L[1],L[0],L[2]]),diff([L[1],L[2],L[0]]),diff([L[2],L[0],L[1]]),diff([L[2],L[1],L[0]])]
    print(max(all))
elif len(L)==2:
    print(abs(L[0]-L[1]))



Measured memory_bytes: 9060
fun initList(lmChar : MutableList<MutableList<MutableList<MutableList<MutableList<Long>>>>>){
    val l3 = mutableListOf<MutableList<MutableList<MutableList<Long>>>>()
    for(b3 in 0..3) {
        val l2 = mutableListOf<MutableList<MutableList<Long>>>()
        for (b2 in 0..3) {
            val l1 = mutableListOf<MutableList<Long>>()
            for (b1 in 0..3) {
                val l0 = mutableListOf<Long>()
                for (b0 in 0..3) {
                    if(b0 + b1 + b2 + b3 == 0) l0.add(1L)
                    else l0.add(0L)
                }
                l1.add(l0)
            }
            l2.add(l1)
        }
        l3.add(l2)
    }
    lmChar.add(l3)
}

fun nextStep(lmChar : MutableList<MutableList<MutableList<MutableList<MutableList<Long>>>>>, i : Int){
    val l3 = mutableListOf<MutableList<MutableList<MutableList<Long>>>>()
    for(b3 in 0..3) {
        val l2 = mutableListOf<MutableList<MutableList<Long>>>()
        for (b2 in 0..3) {
            val l1 = mutableListOf<MutableList<Long>>()
            for (b1 in 0..3) {
                val l0 = mutableListOf<Long>()
                for (b0 in 0..3) {
                    val flag = calculator(listOf(b3, b2, b1, b0))
                    val value =
                        lmChar[i - 1][1][b3][b2][b1] + lmChar[i - 1][2][b3][b2][b1] + lmChar[i - 1][3][b3][b2][b1] + lmChar[i - 1][0][b3][b2][b1]
                    l0.add((value % 1000000007L) * flag)
                }
                l1.add(l0)
            }
            l2.add(l1)
        }
        l3.add(l2)
    }
    lmChar.add(l3)
}

fun calculator(l : List<Int>) : Long{
    if(l[0] == 1 && l[1] == 2 && l[2] == 3) return 0L
    if(l[0] == 2 && l[1] == 1 && l[2] == 3) return 0L
    if(l[0] == 1 && l[1] == 3 && l[2] == 2) return 0L
    if(l[1] == 1 && l[2] == 2 && l[3] == 3) return 0L
    if(l[1] == 2 && l[2] == 1 && l[3] == 3) return 0L
    if(l[1] == 1 && l[2] == 3 && l[3] == 2) return 0L
    if(l[0] == 1 && l[2] == 2 && l[3] == 3) return 0L
    if(l[0] == 1 && l[1] == 2 && l[3] == 3) return 0L
    return 1L
}

fun main(args: Array<String>){
    val n = readLine()!!.toInt()
    val lmChar = mutableListOf<MutableList<MutableList<MutableList<MutableList<Long>>>>>()
    initList(lmChar)
    for(i in 1..n) nextStep(lmChar, i)
    var retValue = 0L
    for(b3 in 0..3){
        for(b2 in 0..3){
            for(b1 in 0..3){
                for(b0 in 0..3){
                    retValue += lmChar[n][b3][b2][b1][b0]
                    retValue %= 1000000007L
                }
            }
        }
    }
    println(retValue)
}

Measured memory_bytes: 40888
#include<stdio.h>
#include<stdint.h>
#include<inttypes.h>
#define PROCESS_MAX 100001

typedef struct{
    char          name[11];
    uint_fast32_t time    ;
} s_process;

int main(void)
{
    uint_fast32_t n, q, head = 0, tail = 0, process_time = 0;
    s_process process[PROCESS_MAX];

    scanf("%"SCNu32" %"SCNu32, &n, &q);
    for(uint_fast32_t i=0; i<n; ++i){
        scanf("%s %"SCNu32, process[i].name, &process[i].time);
    }
    tail = n;

    while(head != tail){
        if(process[head].time > q){
            process_time       += q            ;
            process[head].time -= q            ;
            process[tail]       = process[head];
            head = (head+1) % PROCESS_MAX;
            tail = (tail+1) % PROCESS_MAX;
        }else{
            process_time += process[head].time;
            printf("%s %"PRIu32"\n", process[head].name, process_time);
            head = (head+1) % PROCESS_MAX;
        }
    }

    return 0;
}

Measured memory_bytes: 4028
#include <bits/stdc++.h>
using namespace std;
int main(){
	long long n,k;
	cin>>n>>k;
	long long res=0;
	for (int i=k;i<n+2;i++) res+=i*(n+1-i)+1;
	res%=1000000007;
	cout<<res<<endl;
	return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#include<cstdio>
#define el "\n"
#define sp " "
typedef long long ll;

ll knapSack(ll W, ll wt[], ll val[], ll n) 
{ 
   ll i, w; 
   ll K[n+1][W+1]; 
  
   // Build table K[][] in bottom up manner 
   for (i = 0; i <= n; i++) 
   { 
       for (w = 0; w <= W; w++) 
       { 
           if (i==0 || w==0) 
               K[i][w] = 0; 
           else if (wt[i-1] <= w) 
                 K[i][w] = max(val[i-1] + K[i-1][w-wt[i-1]],  K[i-1][w]); 
           else
                 K[i][w] = K[i-1][w]; 
       } 
   } 
  
   return K[n][W]; 
} 
int main() 
{ 
   
    ll n,W,i;
	cin>>n>>W; 
     ll val[n];
    ll wt[n];
    for(i=0;i<n;i++)
    cin>>wt[i]>>val[i];
    
    cout<<knapSack(W, wt, val, n); 
    return 0; 
} 

Measured memory_bytes: 79104
s=list(input())
n=len(s)
if s[0]=='0' or s[-1]=='1':
  print(-1)
else:
  s.pop()
  sr=s.copy()
  sr.reverse()
  if s!=sr:
    print(-1)
  else:
    ans=[]
    now=1
    cnt=1
    for x in s:
      if x=='1':
        ans.append([now,now+cnt])
        now+=cnt
        cnt=1
      else:
        ans.append([now,now+cnt])
        cnt+=1
    for x in ans:
      print(x[0],x[1])


Measured memory_bytes: 25636
def main():
    N, K = [int(n) for n in input().split()]
    S = list(input())
    
    num = K - 1
    char = S[num]
    if char == "A":
        S[num] = "a"
    elif char == "B":
        S[num] = "b"
    else:
        S[num] = "c"
    print("".join(S))
main()

Measured memory_bytes: 2940
import java.util.*;
public class Main
{
public static void main(String args[])
{
Scanner sc= new Scanner(System.in);
  int n=sc.nextInt();
  int k=sc.nextInt();
  int a[]=new int[n];
  for(int i=0;i<n;i++)
  a[i]=sc.nextInt();
  int dp[]=new int[n];
  dp[0]=0;
  dp[1]=Math.abs(a[1]-a[0]);
  for(int i=2;i<n;i++)
  {
    int min=Integer.MAX_VALUE;
    for(int j=1;j<=k && i-j>=0;j++)
    min=Math.min(Math.abs(a[i]-a[i-j])+dp[i-j],min);
  dp[i]=min;
  }
  System.out.println(dp[n-1]);
}
}

Measured memory_bytes: 52288
//input.c
#include <stdio.h>
#include<stdlib.h>


int main(void){
  
  int N;
  int K;

  scanf("%d %d",&N,&K);

 if( K <= ((N+1)/2) )
{
printf("YES");
}
else
{
printf("NO");
}
  
  return 0;
}

Measured memory_bytes: 128