akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
#define FOR(i,a,b) for(int i=(a);i<(int)(b);i++)
#define rep(i,n) FOR(i,0,n)
#define SYAMU(a) memset(a,0,sizeof(a))
#define dbg(x) cout<<#x<<": "<<(x)<<"\n"

const ll MOD = 1e9 + 7;
const int M = 200009;
int h,w,a,b;
ll f[M];
ll inv[M];

void init() {
    SYAMU(f); SYAMU(inv);
}

// ari114
ll mod_pow(ll x, ll n) {
    ll res = 1;
    while(n > 0) {
        if(n & 1) res = res * x % MOD;
        x = x * x % MOD;
        n >>= 1;
    }
    return res;
}

ll nCk(ll n, ll k) {
    return f[n] * inv[k] % MOD * inv[n-k] % MOD;
}

int main() {
    while(cin>>h>>w>>a>>b) {
        init();
        f[0] = inv[0] = 1;
        for(int i=1; i<=h+w; i++) {
            f[i] = i * f[i-1] % MOD;
            inv[i] = mod_pow(f[i], MOD-2);
        }

        ll ans = 0;
        /*
        rep(i, h-a) {
            ans = (ans + nCk(b-1+i, i) * nCk(w-b-1 + h-1-i, w-b-1)) % MOD;
        }
        */

        rep(i,w-b) {
            int p = 1LL * nCk(a+i-1, i) * nCk(w-i+h-a-2, h-a-1) % MOD;
            ans = (ans + p) % MOD;
        }

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

    return 0;
}


Measured memory_bytes: 3328
#include<stdio.h>

int main() {
	int n;
	unsigned long long ans = 1, a[100000];
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%llu", &a[i]);
	}
	for (int i = 0; i < n; i++) {
		if (a[i] == 0) {
			printf("0");
			return 0;
		}
	}
	for (int i = 0; i < n; i++) {
		if (a[i] > 1000000000000000000ULL / ans) {
			printf("-1");
			return 0;
		}
		ans *= a[i];
	}
	printf("%llu", ans);

	return 0;
}

Measured memory_bytes: 2924
#include <stdio.h>
#include <string.h>

int main()
{
   int n;
   scanf("%d", &n);
   int ac = 0, wa = 0, tle = 0, re = 0;
   char str[10];

   for (int i = 0; i < n; i++)
   {
       scanf("%s", str);
       if (strcmp(str, "AC") == 0)
            ac++;
       else if (strcmp(str, "WA") == 0)
            wa++;
       else if (strcmp(str, "TLE") == 0)
            tle++;
       else re++;
   }

   printf("AC x %d\nWA x %d\nTLE x %d\nRE x %d", ac, wa, tle, re);
   return 0;
}


Measured memory_bytes: 1728
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
struct stu
{
int s;
int b[12];
int x;
int su;
}
a[12];
int main(int argc, char** argv) 
{   
    int n,m;
	while(cin>>n>>m)
	{ 
     for(int i=0;i<m;i++)
	 {
	 cin>>a[i].s;
	 for(int j=0;j<a[i].s;j++)
	 cin>>a[i].b[j];
	 }
	 for(int i=0;i<m;i++)
	 cin>>a[i].x;
	 int sum=0;
	 for(int i=0;i<(1<<n);i++)
	 {
	int sa=0;
	for(int j=0;j<m;j++)
	a[j].su=0;
	for(int j=0;j<n;j++)
	{
	if(i&(1<<j))
	{
	for(int k=0;k<m;k++)
	{
	for(int p=0;p<a[k].s;p++)
	if(a[k].b[p]==j+1)
	a[k].su++;
	}
	}
	}
	for(int j=0;j<m;j++)
	if(a[j].su%2==a[j].x)
	sa++;
	if(sa==m)
	sum++;
	 }
	 cout<<sum<<endl;
	 } 
	return 0;
}

Measured memory_bytes: 256
from collections import deque

def readinput():
    n = int(input())
    commands = []
    for i in range(n):
        command = input().split()
        commands.append(command)
    return n,commands

def main(n,commands):
    l = deque([])
    for i in range(n):
        command = commands[i]
        if (command[0]=='insert'):
            op = command[1]
            l.appendleft(op)
        elif(command[0]=='delete'):
            op = command[1]
            try:
                l.remove(op)
            except:
                pass
        elif(command[0]=='deleteFirst'):
            l.popleft()
        elif(command[0]=='deleteLast'):
            l.pop()
        else:
            pass
        #print(' '.join(l))

    return l
    
def main2():
    n = int(input())
    l = deque([])
    for i in range(n):
        command = input().split()
        if (command[0]=='insert'):
            op = command[1]
            l.appendleft(op)
        elif(command[0]=='delete'):
            op = command[1]
            try:
                l.remove(op)
            except:
                pass
        elif(command[0]=='deleteFirst'):
            l.popleft()
        elif(command[0]=='deleteLast'):
            l.pop()
        else:
            pass
        #print(' '.join(l))

    return l
if __name__=='__main__':
    #n, commands=readinput()
    #ans = main(n,commands)
    ans = main2()
    print(' '.join(ans))


Measured memory_bytes: 69752
#include <iostream>

using namespace std;

double outer_product (double* x, double* y, int i) {
  return (x[i] - x[(i+3)%4]) * (y[i] - y[(i+1)%4]) - (y[(i+3)%4] - y[i]) * (x[(i+1)%4] - x[i]);
}

int main () {
  double x[4], y[4];
  double z0;
  bool success;

  while (cin >> x[0]) {
    cin.ignore();
    cin >> y[0];
    for (int i = 1; i <= 3; i++) {
      cin.ignore();
      cin >> x[i];
      cin.ignore();
      cin >> y[i];
    }
    success = true;

    z0 = outer_product(x, y, 0);
    for (int i = 1; i < 4; i++) {
      if (outer_product(x, y, i) * z0 < 0) {
        success = false;
      }
    }

    if(success)
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
  }
}

Measured memory_bytes: 1216
solve :: Int -> Int
solve a
    | a == 1 = 1
    | 2 <= a && a < 4 = 2
    | 4 <= a && a < 8 = 4
    | 8 <= a && a < 16 = 8
    | 16 <= a && a < 32 = 16
    | 32 <= a && a < 64 = 32
    | otherwise = 64

main = getLine >>= (\x -> print $ solve (read x :: Int))

Measured memory_bytes: 508
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cmath>
#include<cstdio>
#include<tuple>
#include<bitset>

using namespace std;
//#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(x) x.begin(),x.end()
#define ll long long
const int inf=1000000007;
const int MOD=1000000007;
signed main(){
  string s;cin>>s;
  int w;cin>>w;
  string res;
  rep(i,(int)s.length()){
    if(i%w==0)res+=s[i];
  }
  cout<<res<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct Node{
    int key;
    Node *parent,*left,*right;
};

Node *root,*nil;


void insert(int k){
    Node *y = nil;
    Node *x = root;
    Node *z;//ポインタ変数を宣言しているだけで、変数に何も格納されていない
    z = new Node;
    z -> key = k;
    z -> left = z -> right = nil;
    while( x != nil){
        y = x;
        if(z -> key < x -> key){
            x = x -> left;
        }else{
            x = x -> right;
        }
    }
    z -> parent = y;
    if(y == nil){
        root = z;
    }else if(z -> key < y -> key){
        y -> left = z;
    }else{
        y -> right = z;
    }
}

void preorder(Node* n){
    if(n == nil) return;
    cout << " " << n -> key ;
    preorder(n -> left);
    preorder(n -> right);
}

void inorder(Node* n){
    if( n == nil ) return;
    inorder(n -> left);
    cout << " " << n -> key;
    inorder(n -> right);
}

void print(Node *root){
    inorder(root);
    cout << endl;
    preorder(root);
}
int main(){
    int n;
    cin >> n;
    for(int i=0;i<n;i++){
        string order;
        cin >> order;
        if(order == "insert"){
            int key;
            cin >> key;
            insert(key);
        }else{
            print(root);
            cout << endl;
        }
    }
}




Measured memory_bytes: 26596
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using pll=pair<ll,ll>;

const ll MOD=1000000007;

ll abs1(ll a){
  if(a>=0)return a;
  else return -a;
}

ll pow1(ll a,ll b,ll p=LLONG_MAX){
  ll ret=1;
  while(b!=0){
    if((b&1)==1){
      ret*=a;
    }
    a*=a;
    if(a>=p)a%=p;
    b=b>>1;
  }
  return ret;
}

int digit(ll a,ll b){
  int i=0;
  while(a!=0){
    a/=b;
    i++;
  }
  return i;
}

int ord(ll a,ll p){
  int i=0;
  while(a%p==0){
    a/=p;
    i++;
  }
  return i;
}

ll gcd1(ll a,ll b){
  if(a==0 && b==0)return 0;
  ll n;
  while(a%b!=0){
    n=a%b;
    a=b;
    b=n;
  }
  return b;
}

ll solveLinear(ll n,ll m,ll c){
  if(n==0 && m==0)return 0;
  ll a[100],b[100];
  a[0]=n;b[0]=m;
  int i=1;
  while(b[i-1]!=0){
    a[i]=b[i-1];
    b[i]=a[i-1]%b[i-1];
    i++;
  }
  n=i;
  if(c%a[n-1]!=0){
    return 0;
  }
  ll x=c/a[n-1],y=0;
  for(i=1;i<n;i++){
    ll cnt=x;
    x=y;
    y=cnt-(a[n-i-1]/b[n-i-1])*y;
  }
  return x;
}

ll modRev(ll a,ll p=MOD){
  a%=p;
  ll n=solveLinear(a,p,1);
  n%=p;
  if(n<0)return n+p;
  return n;
}

ll fact(ll n,ll p=MOD){
  if(n<0)return 0;
  int i;
  ll ret=1;
  for(i=0;i<n;i++){
    ret=ret*(i+1);
    if(ret>=p)ret%=p;
  }
  return ret;
}

ll perm(ll n,ll k,ll p=MOD){
  if(n<0 || k<0 || n<k)return 0;
  int i;
  ll ret=1;
  for(i=0;i<k;i++){
    ret=ret*(n-i);
    if(ret>=p)ret%=p;
  }
  return ret;
}

ll binom(ll n,ll k,ll p=MOD){
  if(n<0 || k<0 || n<k)return 0;
  int i;
  ll ret=1,fact=1;
  for(i=0;i<k;i++){
    ret=ret*(n-i);
    fact*=i+1;
    if(ret>=p)ret%=p;
    if(fact>=p)fact%=p;
  }
  return (ret*modRev(fact))%p;
}

int main(){
  int i,j,k;ll cnt=0;
  ll n,x;
  cin>>n>>x;
  ll ans=n,y=n-x;
  while(y!=0){
    if(x<y)swap(x,y);
    ans+=2*(x/y)*y;
    cnt=x%y;
    x=y;
    y=cnt;
  }
  cout<<ans-x<<endl;
}


Measured memory_bytes: 256
def s():
 for e in iter(input,'0 0'):
  w,h=map(int,e.split())
  M=[[[1,0]*2 for _ in[0]*h]for _ in[0]*w]
  for i in range(1,w):
   for j in range(1,h):
    a,b=M[i-1][j][:2]
    c,d=M[i][j-1][2:]
    M[i][j]=[d,a+b,b,c+d]
  print((sum(M[w-2][h-1][:2])+sum(M[w-1][h-2][2:]))%10**5)
s()


Measured memory_bytes: 7836
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::cmp;

fn main() {
    input!{
        a: u64,
        b: u64,
        x: u64,
    }
    let ans = b / x - a / x + if a % x == 0 { 1 } else { 0 };
    println!("{}", ans);
}


Measured memory_bytes: 4352
H,W = map(int,input().split())
field = []
ans = [[0] * W for i in range(H)]

for i in range(H):
    field.append(list(input()))

#8方向走査
#下、右、上、左、右下、右上、左下、左上
dy = [1, 0, -1, 0, 1, -1, 1, -1]
dx = [0, -1, 0, 1, -1, -1, 1, 1]


for y in range(H):
    for x in range(W):

        if field[y][x] == "#":
            ans[y][x] = "#"
            continue

        cnt = 0
        for k in range(8):
            ny = y + dy[k]
            nx = x + dx[k]

            if 0 <= ny and ny < H and 0 <= nx and nx < W:
                if field[ny][nx] == "#":
                    cnt += 1

        ans[y][x] = str(cnt)

for h in range(H):
    print("".join(ans[h]))
            

Measured memory_bytes: 3188
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;
 
static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const ll INF = 1023456789;
 
#define REP(i,n)	for(int i=0;i<n;++i)
#define REPR(i,n)	for(int i=n-1;i>=0;--i)
#define FOR(i,s,n)	for(int i=s;i<n;++i)
#define FORR(i,s,n)	for(int i=n-1;i>=s;--i)
#define ALL(c)		(c).begin(),(c).end()
#define CLEAR(v)	memset(v,0,sizeof(v))
#define MP(a,b)		make_pair((a),(b))
#define ABS(a)		((a)>0?(a):-(a))
#define F			first
#define S			second
 
int main(int argc, char **argv) {
	int p, q, r;
	cin >> p >> q >> r;
	cout << min(p + q, min(q + r, r + p)) << endl;
	return 0;
}
 

Measured memory_bytes: 256
# include <iostream>
# include <algorithm>
#include <array>
# include <cassert>
#include <cctype>
#include <climits>
#include <numeric>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <tuple>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <chrono>
# include <random>
# include <limits.h>
# include <unordered_map>
# include <unordered_set>
# include <deque>
# include <cstdio>
# include <cstring>
#include <stdio.h>
#include<time.h>
#include <stdlib.h>
#include <cstdint>
#include <cfenv>

//#include <bits/stdc++.h>
using namespace std;
using LL = int;
using ULL = unsigned long long;
long long MOD = 1000000000 + 7;
constexpr long long INF = numeric_limits<LL>::max();
const double PI = acos(-1);
#define fir first
#define sec second
#define thi third
#define debug(x) cerr<<#x<<": "<<x<<'\n'
typedef pair<LL, LL> Pll;
typedef pair<LL, pair<LL, LL>> Ppll;
typedef pair<LL, pair<LL, bitset<100001>>> Pbll;
typedef pair<LL, pair<LL, vector<LL>>> Pvll;
typedef pair<LL, LL> Vec2;
struct Tll { LL first, second, third; };
struct Fll { LL first, second, third, fourd; };
typedef pair<LL, Tll> Ptll;
#define rep(i,rept) for(LL i=0;i<rept;i++)
#define Mfor(i,mf) for(LL i=mf-1;i>=0;i--)
LL h, w, n, m, k, t, s, q, last, cnt, sum, ans, dp[10000], a[2000000], b[2000000];
string str, ss;
bool f[1100][1100];
char c;
int di[4][2] = { { 0,1 },{ 1,0 },{ 0,-1 },{ -1,0 } };
struct Edge { LL to, cost; };
vector<Edge>vec[200000];
list<LL>li[20000];
vector<LL>v;
map<string, vector<LL>>ma;
set<LL>st;
void YN(bool f) {
	if (f)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}
void yn(bool f) {
	if (f)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}
int main() {
	cin >> n;
	rep(i, n) {
		LL x;
		cin >> x;
		v.push_back(x);
	}
	cin >> m;
	rep(i, m) {
		LL x, y, z;
		cin >> x >> y >> z;
		rotate(v.begin()+x,v.begin()+y,v.begin()+z);
	}
	rep(i, n) {
		cout << v[i]<<" \n"[i==n-1];
	}
	
	return 0;
}


Measured memory_bytes: 8192
// see https://gist.github.com/LumaKernel/ff55d49ee1af69b7388f15b707e75c15
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <complex>
#include <random>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> VI;
typedef vector<P> VP;

#define omajinai ios::sync_with_stdio(false);cin.tie(0)

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

#define LFOR(i,a,b) for(ll i=(a);i<(b);++i)
#define RLFOR(i,b,a) for(ll i=(b)-1;i>=(a);--i)

#define ALL(a) (a).begin(),(a).end()
#define UNIQUE(a) (a).erase(unique((a).begin(),(a).end()),(a).end())
#define MP make_pair
#define PB push_back
#define EACH(i,c) REP(i,(int)(c).size())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

#define dump(x) cerr << "[L " << __LINE__ << "] " << #x << " = " << (x) << "\n";
#define dump2(x,y) cerr << "[L " << __LINE__ << "] " << #x << " = " << (x)\
			<< " , " << #y << " = " << (y) << "\n";

const int INF = 1e9;
const double EPS = 1e-10;

int n,m[3];
ll k;
string s;

int main() {
	cin >> s;

	int j = 0;
	REP(i,s.size()){
		if(s[i]=='B'){
			if(j)j--;
		}else{
			s[j++] = s[i];
		}
	}
	REP(i,j)cout << s[i];
	cout << endl;
}


Measured memory_bytes: 256
N, M = map(int, input().split())
S = []
for _ in range(M):
    s = [int(i) - 1 for i in input().split()]
    S.append(s[1:])
P = [int(i) for i in input().split()]


def check(bits, i):
    on = 0
    for x in S[i]:
        if (bits >> x) & 1:
            on += 1
    return on & 1 == P[i]


ans = 0
for bits in range(1 << N):
    flag = True
    for i in range(M):
        # 電球iが点灯するか
        # print(bits, i, check(bits, i))
        if not check(bits, i):
            flag = False
            break
    if flag:
        ans += 1
print(ans)


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

using namespace std;

int dp[3001][3001];

int main(void){
	string str1, str2;
	cin >> str1 >> str2;

	for(int i=1; i<=str1.length(); i++){
		for(int j=1; j<=str2.length(); j++){
			if(str1[i-1] == str2[j-1]){
				dp[i][j] = dp[i-1][j-1]+1;
			} else{
				dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
			}
		}
	}
	//cout << dp[str1.length()][str2.length()] << endl;

	string res = "";
	int i = (int)str1.size(), j = (int)str2.size();
	while(i > 0 && j > 0){
		if(dp[i][j] == dp[i-1][j]) {
			--i;
		}else if(dp[i][j] == dp[i][j-1]) {	// (i-1, j-1) -> (i, j) と更新されていた場合
			--j;
		}else {
			res = str1[i-1] + res; // このとき s[i-1] == t[j-1] なので、t[j-1] + res でも OK
			--i, --j;
		}
	}
	if(dp[str1.length()][str2.length()] == 0) res = "";
	cout << res << endl;
}

Measured memory_bytes: 35456
// B - Picture Frame
#include <bits/stdc++.h>
using namespace std;

int H, W;
string a[100];

int solve();


int main() {

  cin >> H >> W;
  for(int i =0; i< H; i++){
    cin >> a[i];
  }

  solve();

}

int solve(){
  for(int i = 0; i<W+2; i++){
    cout << '#';
  }
  cout <<endl;

  for(int i= 0; i<H; i++){
    cout << '#' + a[i] + '#' << endl;
  }

  for(int i = 0; i<W+2; i++){
    cout << '#';
  }
  cout <<endl;

  return 0;


}


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

const int INF = 1<<28;
const int MAXN = 16;
int N;
string S, T;
int start, goal;
int cost[MAXN][1<<MAXN];

struct State {
  int pos, bit, cost;
  bool operator < (const State &s) const {
    return cost > s.cost;
  }
};


int dijkstra() {
  priority_queue<State> que;
  fill(cost[0], cost[MAXN], INF);
  for(int i = 0; i < N; ++i) {
    que.push((State){i, start, 0});
    cost[i][start] = 0;
  }
  while(que.size()) {
    const State s = que.top();
    que.pop();
    if(cost[s.pos][s.bit] < s.cost) continue;
    if(s.bit == goal) return s.cost;
    for(int i = 0; i < N; ++i) {
      for(int j = 0; j < N; ++j) {
        if((s.bit&(1<<i)) ^ (s.bit&(1<<j))); else continue;
        State t = {j, s.bit^(1<<i)^(1<<j), s.cost+abs(i-s.pos)+abs(j-i)};
        if(cost[t.pos][t.bit] <= t.cost) continue;
        que.push(t);
        cost[t.pos][t.bit] = t.cost;
      }
    }
  }
  return INF;
}

int main() {
  while(cin >> N && N) {
    cin >> S >> T;
    start = goal = 0;
    for(int i = 0; i < N; ++i) {
      if(S[i] == 'W') start |= 1<<i;
      if(T[i] == 'W') goal  |= 1<<i;
    }
    cout << dijkstra() << endl;
  }
  return 0;
}

Measured memory_bytes: 27144
n = int(input())
s = list(str(input()))

for i in range(len(s)):
    tmp = ord(s[i]) + n
    if tmp > ord('Z'):
        tmp -= ord('Z') - ord('A') + 1
    s[i] = chr(tmp)

ans = ''
for i in range(len(s)):
    ans += s[i]

print(ans)

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

int main() {
    ll n;
    cin >> n;
    ll ans = 0;
    for (int i = 1; i <= n; ++i) {
        if (i % 3 != 0 && i % 5 != 0) ans += i;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3636
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <bitset>    // bitset
#include <deque>     // deque
#include <iomanip>   //setprecsion
#include <iostream>  // cout, endl, cin
#include <map>       // map
#include <queue>     // queue, priority_queue
#include <set>       // set
#include <stack>     // stack
#include <string>    // string, to_string, stoi
#include <tuple>     // tuple, make_tuple
#include <utility>   // pair, make_pair
#include <vector>    // vector

#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>  //sin, cos, tan

using namespace std;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rrep(i, n) for (ll i = (n - 1); i >= 0; --i)
#define blank(ans) cout << (ans) << " ";
#define mp(p, q) make_pair(p, q)
#define mt(p, q, r) make_tuple(p, q, r)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()

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

typedef vector<ll> vll;
typedef vector<ld> vd;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<str> vs;
typedef vector<vector<ll>> vvll;
typedef vector<vector<ld>> vvd;
typedef vector<vector<bool>> vvb;
typedef vector<vector<char>> vvc;
typedef vector<vector<str>> vvs;
typedef vector<pair<ll, ll>> vpll;
typedef vector<tuple<ll, ll, ll>> vtlll;

const ld PI = acos(-1.0);
const ll MAX = 9000000000000000000;
const ll MIN = -9000000000000000000;
const ld DMAX = 4500;
const ld DMIN = -4500;
const ll MOD = 1000000007;

template <typename T>
void fin(T a)
{
  cout << a << endl;
  exit(0);
}

void Main()
{
  ll n; cin >> n;
  vll a(n); rep(i, n) cin >> a[i]; 
  ll S = 0;
  rep(i, n) S += a[i];
  ll ans = 0;
  rep(i, n)
  {
    S -= a[i];
    ans += (a[i] % 1000000007) * (S % 1000000007);
    ans %= 1000000007;
  }
  fin(ans);
}

//前処理
int main()
{
  //ios::sync_with_stdio(false);
  //cin.tie(0);
  cout << fixed << setprecision(20); //高精度少数表示
  //cout << setfill('0') << internal << setw(4); 0埋め４桁
  Main();
  return 0;
}


Measured memory_bytes: 5192
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>

using namespace std;

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

	if ((N[0] == N[1] && N[1] == N[2])
		|| (N[1] == N[2] && N[2] == N[3]))
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}

	return 0;
}

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

int main() {
    int x1,x2,x3,x4,x5; cin >> x1 >> x2 >> x3 >> x4 >> x5;

    if(x1 == 0) cout << 1 << endl;

    if(x2 == 0) cout << 2 << endl;

    if(x3 == 0) cout << 3 << endl;

    if(x4 == 0) cout << 4 << endl;

    if(x5 == 0) cout << 5 << endl;



   return 0;
}

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

int main(){
	int m;
	cin >> m;
	for(int rep=0; rep<m; rep++){
		double ini;
		int year, kind;
		cin >> ini >> year >> kind;
		int ans = 0;
		for(int i=0; i<kind; i++){
			double amount = ini;
			int mode, minus, opt=0;
			double gain;
			cin >> mode >> gain >> minus;
			for(int j=0; j<year; j++){
				if(mode==0){
					opt += amount*gain;
					amount -= minus;
				}else{
					amount = floor(amount + amount*gain -minus);
				}
			}
			ans = max(ans, (int)amount+opt);
		}
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 3176
#define _GLIBCXX_DEBUG
#include<algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<iostream>
#include<vector>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<string>
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define rep2(i,s,n) for(int i=s;i< (int)n; i++)
#define ll long long 
#define all(v) v.begin(),v.end()
using namespace std;
int main(){
  ll n ,m ; cin >>n>>m;
  if(2*n>m){
    cout<<m/2<<endl;
    return 0;
  }
  ll l=m/4-n/2;
  ll a=max({min(n+l,(m-2*l)/2),min(n+l+1,(m-2*l-2)/2),min(n+l-1,(m-2*l+2)/2)});
  cout <<a<<endl;
}

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

// boost
#include <boost/multiprecision/cpp_int.hpp>
using boost::multiprecision::cpp_int;

using ll = long long;
using ld = long double;

using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;
using vld = vector<ld>;
using vvld = vector<vld>;

typedef pair<ll, ll> P;

#define bit(n) (1LL << (n))

//#define int long long

#define all(v) v.begin(), v.end()

#define rep(i, n) for (ll i = 0; i < n; i++)
#define REP(i, n) for (ll i = 1; i < n; i++)

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)

template <class T>
inline void chmax(T& a, T b) {
  a = std::max(a, b);
}
template <class T>
inline void chmin(T& a, T b) {
  a = std::min(a, b);
}

#define mod (ll)(1e9 + 7)
// #define mod (998244353ll)

const long long INF = 1LL << 60;

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

  ll w, h;
  cin >> w >> h;

  vll p(w);
  vll q(h);
  rep(i, w) cin >> p[i];
  rep(i, h) cin >> q[i];

  sort(all(p));
  sort(all(q));
  ll ans = 0;
  for (auto it : p) {
    ll v = lower_bound(all(q), it) - q.begin();
    ans += (h + 1 - v) * it;
  }

  for (auto it : q) {
    ll v = upper_bound(all(p), it) - p.begin();
    ans += (w + 1 - v) * it;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 4700
#include <iostream>
#include <stdio.h>
#include <vector> 
#include <math.h> 
using namespace std;

int main(void) {
    int N; cin >> N;
    int odd,even;
    even = N / 2;
    odd = N / 2;
    if (N % 2 == 1) odd++;
    cout << even * odd << endl;
}

Measured memory_bytes: 3580
#include<iostream>
#include<string>
#include<vector>
#include<stack>
#include<algorithm>

using namespace std;

int main() {
    stack<int> S1;
    stack<pair<int,int> > S2;
     char ch;
     int sum=0;
   
     for(int i=0;cin>>ch;i++){
         if(ch=='\\')
             S1.push(i);
         else if(ch=='/'&&S1.size()>0){
            int j=S1.top();
            S1.pop();
            sum+=i-j;
            int a=i-j;
            while(S2.size()>0&&S2.top().first>j){
                 a+=S2.top().second;
                 S2.pop();
               }
            S2.push(make_pair(j,a));
           }
     }
 
     vector<int> ans;
     int t=0;
    while(S2.size()>0){
         ans.push_back(S2.top().second);
         S2.pop(); 
      }
     reverse(ans.begin(), ans.end());
     cout<<sum<<endl;
     cout<<ans.size();
     for(int i=0; i<ans.size();i++){
         cout <<" ";
         t+=ans[i];
         cout<<ans[i];
       }
     cout<<endl;
    
     return 0;
    }



Measured memory_bytes: 3224
//#include<bits\stdc++.h>
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<cstring>
#include<string>
#include<ctime>
#include<cmath>
#include<cctype>
#include<cstdlib>
#include<queue>
#include<deque>
#include<stack>
#include<vector>
#include<algorithm>
#include<utility>
#include<bitset>
#include<set>
#include<map>
#define ll long long
#define db double
#define INF 10000000000000010ll
#define ldb long double
#define pb push_back
#define put_(x) printf("%d ",x);
#define get(x) x=read()
#define gt(x) scanf("%d",&x)
#define gi(x) scanf("%lf",&x)
#define put(x) printf("%d\n",x)
#define putl(x) printf("%lld\n",x)
#define gc(a) scanf("%s",a+1)
#define rep(p,n,i) for(RE int i=p;i<=n;++i)
#define go(x) for(int i=lin[x],tn=ver[i];i;tn=ver[i=nex[i]])
#define fep(n,p,i) for(RE int i=n;i>=p;--i)
#define vep(p,n,i) for(RE int i=p;i<n;++i)
#define pii pair<int,int>
#define mk make_pair
#define RE register
#define P 1000000007
#define gf(x) scanf("%lf",&x)
#define pf(x) ((x)*(x))
#define uint unsigned long long
#define ui unsigned
#define EPS 1e-8
#define sq sqrt
#define S second
#define F first
#define mod 998244353
using namespace std;
char buf[1<<15],*fs,*ft;
inline char getc()
{
    return (fs==ft&&(ft=(fs=buf)+fread(buf,1,1<<15,stdin),fs==ft))?0:*fs++;
}
inline int read()
{
    RE int x=0,f=1;RE char ch=getc();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getc();}
    while(ch>='0'&&ch<='9'){x=((ll)x*10+ch-'0')%mod;ch=getc();}
    return x*f;
}
const int MAXN=200010;
int n,len,m,k,ans;
int vis[20];
char a[10][10];
inline void dfs(int x)
{
	if(x==n+m+1)
	{
		int cnt=0;
		rep(1,n,i)
		{
			if(vis[i])continue;
			rep(1,m,j)
			{
				if(vis[j+n])continue;
				if(a[i][j]=='#')++cnt;
			}
		}
		if(cnt==k)++ans;
		return;
	}
	vis[x]=1;
	dfs(x+1);
	vis[x]=0;
	dfs(x+1);
}
int main()
{
	//freopen("1.in","r",stdin);
	gt(n);gt(m);gt(k);
	rep(1,n,i)scanf("%s",a[i]+1);
	dfs(1);put(ans);
	return 0;
}


Measured memory_bytes: 3816
#include <bits/stdc++.h>
    #define rep(i,n) for(int i = 0; i < (n); i++)
     
    using namespace std;  
   
    int main() {
     int a,b,c;
     cin >> a>>b>>c;
    
     if(a<b &&b<c)	cout << "Yes" << '\n';
     else cout << "No" << '\n';
     
     return 0;
    }


Measured memory_bytes: 3048
#include"iostream"
using namespace std;
int main()
{
long n;
long d;
  cin>>n>>d;
  long long x[n];
  long long  y[n];
  long long  cnt=0;
  for(int i=0;i<n;i++)
  {
    cin>>x[i]>>y[i];
    if((x[i]*x[i]+y[i]*y[i])<=d*d)
      cnt++;
    
  }
  cout<<cnt;
 
}

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

int main(){
    int a,b,c,d,e;
    int k;
    cin >> a >> b >> c >> d >> e;
    cin >> k;
    int sum = 0;
    
    sum = e - a;
    
    if(sum <= k)
        cout << "Yay!" << endl;
    else
        cout << ":(" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
  
  string a,b;
  char c;
  cin >> a;
  int s = a.size();
  int i = 0;
  while(i < s){
    c = a[i];
      if(c == '?'){
        b += "D";
      }else{
        b += c;
      }
    i++;
  }
  cout << b;
    return 0;
}

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

typedef long long ll;

int main(){
    int n;
    string s;
    cin >> n;
    cin >> s;
    ll a=0, b=0, c=0;
    long ans;
    for(int i = 0; i < n; ++i){
        if(s[i]=='G'){
            a++;
        }else if(s[i]=='R'){
            b++;
        }else{
            c++;
        }
    }
    ans = a*b*c;
    for(int i=0; i < n-1; i++){
        for(int j = i+1; j < n; j++){
            if(s[i]==s[j]){
                continue;
            }
            int k=2*j-i;
            if(k>=n || s[j]==s[k] || s[k]==s[i]){
                continue;
            }
            --ans;
        }
    }
    cout << ans << "\n";
    return 0;
}

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

int main(){
    int N=0,zen=0,zenzen=0,ima=0;
    int a=0,b=0;
    bool check=false;

    cin>>a>>b;

vector<string> draw(a);
    
    for(auto&x: draw){
        cin>>x;
    }



    for(int i=0;i<a;i++){
        for(int j=0;j<b;j++){
            if(draw[i][j]=='#'){ 
                check=false;
                if(i>0&&draw[i-1][j]=='#')check=true;
                if(j>0&&draw[i][j-1]=='#')check=true;
                if(j<b-1&&draw[i][j+1]=='#')check=true;
                if(i<a-1&&draw[i+1][j]=='#')check=true;
                
                if(!check){ 
                    cout<<"No"<<endl;
                    return 0;
                }
            }
        }
    }


    cout<<"Yes"<<endl;


}


Measured memory_bytes: 256
package main

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

func main() {
	var s string
	fmt.Scan(&s)
	n := len(s)
	m := make([]int, n)
	for i := 0; i < n-1; i++ {
		if s[i] == 'R' && s[i+1] == 'L' {
			//left side
			for j := i; j >= 0; j-- {
				if s[j] == 'L' {
					break
				} else if (j-i)%2 == 0 {
					m[i]++
				} else {
					m[i+1]++
				}
			}
			//right side
			for j := i + 1; j < n; j++ {
				if s[j] == 'R' {
					break
				} else if (j-i)%2 == 0 {
					m[i]++
				} else {
					m[i+1]++
				}
			}
		}
	}
	wr := bufio.NewWriter(os.Stdout)
	wr.WriteString(strconv.Itoa(m[0]))
	for i := 1; i < n; i++ {
		wr.WriteString(" " + strconv.Itoa(m[i]))
	}
	wr.WriteString("\n")
	wr.Flush()
}

Measured memory_bytes: 2432
for _ in[0]*int(input()):
 X,z=input(),[]
 for y in input():
  s=i=0
  for k in z:
   t=X.find(y,s)+1
   if t<1:break
   if t<k:z[i]=t
   s=k;i+=1
  else:
   t=X.find(y,s)+1
   if t:z+=[t]
 print(len(z))


Measured memory_bytes: 5616
N,M = map(int,input().split(' '))
A = list(map(int,input().split(' ')))
A.sort(reverse=True)
A.append(-1)


ans = 0
BC = [list(map(int,input().split(' '))) for i in [0]*M]
BC.sort(reverse=True, key= lambda x:x[1])
BC.append([0,-1])

i = 0
j = 0
k = N
while(True):
	if k <= 0:
		break
	a = A[i]
	b,c = BC[j]
	if a > c:
		k = k-1
		ans += A[i]
		i = i+1
	else:
		if b < k:
			ans += b*c
			k = k-b
			j = j+1
		else:
			ans += k*c
			break

print(ans)





Measured memory_bytes: 82132
#include<iostream>
using namespace std;
int main(){
int n,m;
scanf("%d %d",&n,&m);
char arr[n][n];
char arr1[m][m];
for(int i=0;i<n;i++)
scanf("%s",arr[i]);
for(int i=0;i<m;i++)
scanf("%s",arr1[i]);
for(int i=0;i<n ;i++){
	for(int j=0 ;j<n;j++){
		int cnt=0;
		for(int a=0;a<m ;a++){
			for(int b=0;b<m;b++){
				if(arr1[a][b]==arr[i+a][j+b])
				cnt++;
			}
		}
		if(cnt==(m*m)){
		return( cout<<"Yes" ,      0);
			
		}
		
	}
}
printf("No\n");
}

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

int main() {
  int a, b, c, x;
  cin >> a >> b >> c >> x;
  int p = 0;
  
  for (int i = 0; i < a + 1; i++) {
    for (int j = 0; j < b + 1; j++) {
      for (int k = 0; k < c + 1; k++) {
        if (500*i + 100*j + 50*k == x) p++;
      }
    }
  }
  
  cout << p << endl;
}

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

typedef unsigned long long ll;
const ll INF = 1010000000000000017LL;
const ll MOD = 1000000007LL;

#define REP(i, n) for(ll i = 0 ; i < n; i++)

//#define DEBUG(fmt, ...)
#define DEBUG(fmt, ...) fprintf(stderr, fmt "\n", ##__VA_ARGS__)

int main(){
    std::cout<<std::fixed<<std::setprecision(10);

    ll N, A, B;

    cin >> N >> A >> B;

    ll m = N / (A+B);
    ll ans = m * A;

    ll rem = m == 0 ? N : (N%(m*(A+B)));
    if( rem  >= A ){
        ans += A;
    }else{
        ans += rem;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
import sys
N = int(input())
H = list(map(int, input().split()))

tmp = H[0]
min = H[0]-1
for i in range(1, N):
    if tmp <= H[i]:
        tmp = H[i]
    elif tmp == H[i] + 1:
        if min < tmp:
            min = tmp - 1
            tmp = H[i]
        else:
            print("No")
            sys.exit()
    else:
        print("No")
        sys.exit()

print("Yes")



Measured memory_bytes: 14380
import java.io.File;
import java.io.IOException;
import java.util.*;
 
public class Main {
 
	public static void main(String[] args) throws IOException {
		//File file = new File("input.txt");
		//Scanner sc = new Scanner(file);
		
		Scanner sc = new Scanner(System.in);
		
		String s1 = sc.next();
		String r2 = new StringBuilder(sc.next()).reverse().toString();
		
		System.out.println(s1.equals(r2) ? "YES" : "NO");
	}
}

Measured memory_bytes: 21716
import Debug.Trace

solve :: [Int] -> Int -> Int
solve (h:t) x
    | x == 1 = h
    | h == 1 = solve t (x-1)
    | otherwise = h

main :: IO ()
main = do
    s <- map (\x -> read [x]) <$> getLine
    x <- read <$> getLine
    print (solve s x)



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

using namespace std;

#define int long long
#define all(v) (v).begin(), (v).end()
#define resz(v, ...) (v).clear(), (v).resize(__VA_ARGS__)
#define reps(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep(i, n) reps(i, 0, n)

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

using Pi = pair<int, int>;
using Tapris = tuple<int, int, int>;
using vint = vector<int>;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

int n, m;
double g[111][111];

double dp[111][111];

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(2);

  while(cin >> n >> m, n || m) {
    rep(i, n) rep(j, n) cin >> g[i][j];

    fill(dp[0], dp[111], 0.0);
    rep(i, n) dp[0][i] = 1.0;
    rep(i, m-1) {
      rep(j, n) {
	rep(k, n) {
	  chmax(dp[i+1][j], dp[i][k]*g[k][j]);
	}
      }
    }
    double ans = 0;
    rep(i, n) chmax(ans, dp[m-1][i]);
    cout << ans << endl;
  }

  return 0;
}



Measured memory_bytes: 3492
def resolve():
    n = int(input())
    p = list(map(int, input().split()))
    count = 0
    for i in range(n):
        if i+1 != p[i]:
            count += 1
    if count == 2 or count == 0:
        print("YES")
    else:
        print("NO")
resolve()

Measured memory_bytes: 38256
import math
N,D = map(int,input().split())
X = []
for _ in range(N):
  x = input().split()
  x = [int(y) for y in x]
  X.append(x)

c = 0
for i in range(N):
  for j in range(i+1,N):
    s = 0
    for k in range(D):
      s += (X[i][k] - X[j][k])**2
    for l in range(1,math.floor(math.sqrt(s))+1):
      if s == l*l:
        c +=1
print(c)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define P pair<int,int>
using namespace std;
typedef long long ll;
const int maxx=500010;
int in[maxx],clo[maxx];
vector<P> a[maxx];
void dfs(int x,int fa,int fclo){
    int cnt=0;
    for(auto t:a[x]){
        if(t.first==fa) continue;
        cnt++;
        if(cnt==fclo) cnt++;
        clo[t.second]=cnt;
        dfs(t.first,x,cnt);
    }
}
int main(){
    int n; cin>>n;
    for(int i=1;i<n;i++){
        int x,y; cin>>x>>y;
        a[x].push_back(P(y,i));
        a[y].push_back(P(x,i));
    }
    dfs(1,0,0);
    int ans=0;
    for(int i=1;i<n;i++) ans=max(ans,clo[i]);
    cout<<ans<<endl;
    for(int i=1;i<n;i++){
        cout<<clo[i]<<endl;
    }
}


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

int main() {
	int R, G, B;
	cin >> R >> G >> B;

	int K;
	cin >> K;

	int count = 0;
	while (1) {
		if ((B > G && G > R) || count > K) {
			break;
		}
		if (G <= R) {
			G *= 2;
			count++;
		} else if (B <= G || B <= R) {
			B *= 2;
			count++;
		}
	}

	if (count > K) {
		cout << "No" << endl;
	} else {
		cout << "Yes" << endl;
	}

	return 0;
}

Measured memory_bytes: 3632
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC080C
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            int[] F = new int[N + 1];
            int[,] P = new int[N + 1, 10 + 1];
            string[] vals;

            for(int i=1; i<=N; i++)
            {
                vals = Console.ReadLine().Split();
                for (int j = 0; j < 10; j++)
                {
                    F[i] <<= 1;
                    F[i] |= int.Parse(vals[j]);
                }
                
            }

            for(int i=1; i<=N; i++)
            {
                vals = Console.ReadLine().Split();
                for(int j=0; j<=10; j++)
                {
                    P[i, j] = int.Parse(vals[j]);
                }
            }

            long max = long.MinValue;
            long b;

            for(int jf = 1; jf<=1023; jf++)
            {
                b = 0;
                for(int i=1; i<=N; i++)
                {
                    int flag = jf & F[i];
                    int count = bitCount(flag);
                    b += P[i, count];
                }
                if (max < b)
                    max = b;
            }

            Console.WriteLine(max);

        }
        

        static int bitCount(int n)
        {
            int ret = 0;
            while(n > 0)
            {
                ret += n & 0x01;
                n >>= 1;
            }
            return ret;
        }
    }
}


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

int main() {
	long long n = 50, k, a[50];
	cin >> k;
	for (int i = 0; i < n; i++) {
		a[i] = n - 1 + k / n;
	}

	k %= n;
	for (int i = 0; i < k % n; i++) {
		a[i] += n - k + 1;
	}

	for (int i = k % n; i < n; i++) {
		a[i] -= k;
	}

	cout << n << endl;
	for (auto&& x : a)cout << x << ' ';
	cout << endl;

	return 0;
}

Measured memory_bytes: 256
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,sqrt,factorial,hypot,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from fractions import gcd
from random import randint
def ceil(a,b): return (a+b-1)//b
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    N=I()
    print(ceil(N,2))
if __name__ == '__main__':
    main()

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

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

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

    int a,b,c; cin >> a >> b >> c;

    if((b*10+c)%4 == 0) cout << "YES" << endl;
    else cout << "NO" << endl;

    return 0;

}

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

int main() {
  /*

　　　　　　　 　　　　　　　　　　　　.,Å､
　　　　　　　 　　　　　　　　　 .r-‐i'''''''''''i''''‐-､
　　　　　　　 　　　　　　　　 o|　ｏ!　.ｏ　 i ｏ　!o
　　　　　　　 　　　　　　　　.|＼__|｀‐´｀‐／|__/|
　　　　　　　　　　 　　　　　 |_, ─''''''''''''─ ,､ /
　　　　　　　　　　　 　 　　　,/ノ　　　　　 ヽ＼､_
　　　　　　　　　　　　　 <´ﾌ ● ､　▼ 　, ●.ヽ ｀ヽ
　　　　　,ｨ　　 　 　 　 　 Y,.-ﾆ=.｀Y´｀Y´　'ﾆ二ミ／ 　ｷﾝｸﾞｶﾜｳｿｯｽ
　　　　 /;ｌ　 ,.イ　 ,,. -''"´ﾚ'´　　　.ｌ 　ｌ　 　　　 ヽ!｀丶､
　 ヽ￣;;;;;;ｿ/;;;;l/!　　 ,.-'´.|　　　　　!_」　　　　　　 | ヽ､　`
　　 ｌ;;;;;;;;;;;;;;;;;;;;;;;ｌ　 '´　 　 |　　　　　　　　　　　　　ｌ 　　`
　 　 ｌ;;;;;;;;;;;;;;;;;;;;ｌ　　　　 　 |　　　　　　　　　　 　 　 ｌ
　 　 ヽ;;;;;;;;;;;;;;;;;ｌ 　 　 　 　 ｌ　　　　　　　　　　　　 　ｌ
　　 　 ヽﾍ;ｨ;Nﾍ!　　 　 　 　ｌ 　　　　　　　　　 　 　 　ｌ
　　　　 ヾ　　 　ゝ　　　　　　ｌ　　　　　　　　　　　　 　丶ニ─ -､
　　　　　 ヽ　　　 ヽ　　　　 　!.ｌ　　　　　　　 i 　 　 !　　　　ヽ 　 ヽ
　　　　　 　丶､.　 　｀ `ｰ─'"´!ヽ　 　ｌ. 　 　 |　　 /　　　　　　　　 ヽ
　　　　　　　　 ｀ｰ-､_　　　＿_,.ｨ ヽ　 .|　　　 | 　 /　　　　　　　　　　!
　　　　　　　　　　　　￣￣　　　ｌ.　ヽ_」　　　.L_./　　　　　　　　　　　|

*/
  const int mod=1000000007;
  int N;
  cin >> N;
  string s1,s2;
  cin >> s1 >> s2;
  long tot=0;
  if(s1[0]==s2[0]){
    tot+=3;
    s1[0]=',';
  }
  else tot+=6;
  for(int i=1;i<N;i++){
    if(s1[i]==s2[i]){
      s1[i]=',';
      if(s1[i-1]==',')tot=tot*2%mod;
    }
    else if(s1[i]!=s1[i-1]){
      if(s1[i-1]==',')tot=tot*2%mod;
      else tot=tot*3%mod;
    }
  }
  cout << tot;
}

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

#define rep(i, a, b) for (int i = a; i < (int)(b); i++)

using namespace std;

int main() {
  while (1) {
    int n, x;
    cin >> n >> x;
    if (n == 0 && x == 0)
      return 0;
    int ans = 0;
    rep(i, 1, n + 1) rep(j, i + 1, n + 1)
        rep(k, j + 1, n + 1) if (i + j + k == x) ans++;
    cout << ans << endl;
  }
}



Measured memory_bytes: 3092
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <stack>
#include <climits>
#include <map>
#include <set>

using namespace std;

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

const ll mod = 1000000007;
const int inf = 1e9;
const long long INF = 1LL << 60;

int dp[100010];

int main()
{
    int n;
    cin >> n;
    vector<int> a;
    vector<int> b;
    for(int i = 6; i < 100000; i *= 6){
        a.push_back(i);
    }
    for(int i = 9; i < 100000; i *= 9){
        b.push_back(i);
    }
    for(int i = 0; i < 100010; i++){
        dp[i] = i;
    }

    for(int i = 0; i < 100010; i++){
        for(int j = 0; j < a.size(); j++){
            if(i >= a[j]){
                dp[i] = min(dp[i],dp[i-a[j]] + 1);
            }else{
                dp[i+1] = dp[i] + 1;
            }
        }
        for(int j = 0; j < b.size(); j++){
            if(i >= b[j]){
                dp[i] = min(dp[i],dp[i-b[j]] + 1);
            }else{
                dp[i+1] = dp[i] + 1;
            }
        }
    }
    cout << dp[n];
}

Measured memory_bytes: 640
n, m = map(int, input().split())
left = 0
right = n
for i in range(m):
  l, r = map(int, input().split())
  if left < l:
    left = l
  if right > r:
    right = r
if right >= left:
  print(right - left + 1)
else:
  print(0)

Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#include<sstream>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-10;
const int inf=1e9;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
int main(){
	int q;
	cin>>q;
	while(q--){
		int n,N;
		cin>>n;
		N=n*2;
		string s;cin>>s;
		rep(i,s.size())s[i]=(s[i]=='Y'?1:0);
		string t=s.substr(N);
		s=s.substr(0,N);
		vvi dp(n+1,vi(2,inf));
		if(t[0])dp[0][1]=2;
		else if(s[0]){
			dp[0][1]=1;
			dp[0][0]=1;
		}else dp[0][0]=0;
		rep(i,n){
			int a,b;
			if(i!=n-1){
				a=s[i*2+2]||s[i*2+1];
				b=t[i*2+2]||t[i*2+1];
			}else{
				a=s[i*2+1];
				b=t[i*2+1];
			}
			if(dp[i][0]!=inf){
				if(b)dp[i+1][1]=min(dp[i+1][1],dp[i][0]+2);
				else if(a){
					dp[i+1][1]=min(dp[i+1][1],dp[i][0]+1);
					dp[i+1][0]=min(dp[i+1][0],dp[i][0]+1);
				}else dp[i+1][0]=min(dp[i+1][0],dp[i][0]);
			}
			if(dp[i][1]!=inf){
				if(a+b==2){
					dp[i+1][1]=min(dp[i+1][1],dp[i][1]+2);
					dp[i+1][0]=min(dp[i+1][0],dp[i][1]+2);
				}else if(a+b==0)dp[i+1][1]=min(dp[i+1][1],dp[i][1]);
				else if(a){
					dp[i+1][1]=min(dp[i+1][1],dp[i][1]+1);
					dp[i+1][0]=min(dp[i+1][0],dp[i][1]+1);
				}else if(b)dp[i+1][1]=min(dp[i+1][1],dp[i][1]+1);
			}
		}
		cout<<min(dp[n][0],dp[n][1]+1)+n<<endl;
	}
}

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

int main(){
  int n;
  string s;
  cin >> n >> s;
  int cnt=0;
  for(int i=0;i<n-2;i++){
    string tmp;
    tmp = s.substr(i,3);
    if(tmp == "ABC") cnt++;
  }
  cout << cnt << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    int res, temp;
    int a[5001], b[5001];
    int na, nb;
    int i, j, k;
    
    scanf("%d%d", &na, &nb);
    
    for (i = 0; i < na; i++){
        scanf("%d", &a[i]);
    }
    for (i = 0; i < nb; i++){
        scanf("%d", &b[i]);
    }
    
    res = 0;
    for (i = 0; i < nb; i++){
        k = i;
        temp = 0;
        for (j = 0; j < na; j++){
            if (a[j] == b[k]){
                k++;
                temp++;
                if (k == nb){
                    break;
                }
            }
        }
        res = temp > res ? temp : res;
    }
    
    printf("%d\n", res);
    
    return (0);
}

Measured memory_bytes: 0