akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = (8*1e18);
const double PI = acos(-1);

using namespace std;
struct INIT { INIT(){
  cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;

int N, A, B, C, D;
map<int, int> memo;

int dfs(int x){
  if(x == 0) return memo[x] = 0;
  if(x == 1) return memo[x] = D;
  if(memo.count(x)) return memo[x];

  int ret = INF;
  if(INF/D > x) ret = x*D;

  for(int y = -4; y <= 4; y++){
    int n = x+y;
    if(n%2 == 0 && abs(y) < 2) chmin(ret, dfs(n/2)+A+D*abs(y));
    if(n%3 == 0 && abs(y) < 3) chmin(ret, dfs(n/3)+B+D*abs(y));
    if(n%5 == 0 && abs(y) < 5) chmin(ret, dfs(n/5)+C+D*abs(y));
  }

  return memo[x] = ret;
}


signed main() {
  int T; 
  cin >> T;

  REP(i, T){
    cin >> N >> A >> B >> C >> D;
    memo.clear();
    cout << dfs(N) << "\n";
  }

  return 0;
}

Measured memory_bytes: 4360
package main

import (
	"fmt"
	"math"
)

func main() {
	var str1, str2 string
	fmt.Scanf("%s", &str1)
	fmt.Scanf("%s", &str2)
	ans := lcs(str1, str2)
	fmt.Println(ans)
}

func lcs(str1 string, str2 string) string {
	dp := createTable(len(str1), len(str2))
	for i := 1; i <= len(str1); i++ {
		for j := 1; j <= len(str2); j++ {
			if str1[i-1] == str2[j-1] {
				dp[i][j] = 1 + dp[i-1][j-1]
			} else {
				dp[i][j] = int(math.Max(float64(dp[i-1][j]), float64(dp[i][j-1])))
			}
		}
	}
	var ans []rune
	j := len(str2)
	for i := len(str1); i > 0 && j > 0; {
		if dp[i][j] == int(math.Max(float64(dp[i-1][j]), float64(dp[i][j-1]))) {
			if dp[i-1][j] >= dp[i][j-1] {
				i--
			} else {
				j--
			}
		} else if dp[i][j] == dp[i-1][j-1]+1 {
			ans = append(ans, rune(str1[i-1]))
			i--
			j--
		}
	}
	return reverse(string(ans))
}

func reverse(str string) string {
	if len(str) == 0 {
		return ""
	}
	reversed := make([]rune, len(str))
	for i := 0; i <= len(str)/2; i++ {
		reversed[i], reversed[len(str)-1-i] = rune(str[len(str)-i-1]), rune(str[i])
	}
	return string(reversed)
}

func createTable(n int, m int) [][]int {
	dp := make([][]int, n+1)
	for i := range dp {
		dp[i] = make([]int, m+1)
	}
	dp[0][0] = 0
	return dp
}


Measured memory_bytes: 77016
d=int(input())
c=list(map(int,input().split()))
s=[]
for _ in range(d):
    s_i=list(map(int,input().split()))
    s.append(s_i)

for i in range(d):

    s_max=max(s[i])
    index=s[i].index(s_max)

    print(index+1)

Measured memory_bytes: 9516
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  double x = N;
  if(N%2 == 0)
  	cout << 0.50000000000 << endl;
  else{
    double odd;
    odd = (x + 1.0)/(2.0*x);
    cout << odd << endl;
  }
}

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

using ll=long long;



void solve(){
    string s,c="CODEFESTIVAL2016";
    cin>>s;
    int cnt=0;
    for(int i=0; i<s.size(); i++){
        if(s[i]!=c[i])cnt++;
    }
    cout<<cnt<<endl;
}

signed main(){
    //while(1)
    solve();
}

Measured memory_bytes: 256
using System;

namespace ITP1
{
    class Program
    {
        static void Main(string[] args)
        {
            int n, x;
            while (true)
            {
                string[] input = Console.ReadLine().Split(' ');
                n = int.Parse(input[0]);
                x = int.Parse(input[1]);

                if (n == 0 & x == 0) break;
                int ways = 0;
                for (int i = n; i >= 3 ; i--)
                {
                    for (int k = i - 1; k >= 2; k--)
                    {

                        if (i + k + 1 <= x & i != k)
                        {
                            for (int p = k - 1; p >= 1; p--)
                            {
                                if (i + k + p == x & i != p & k != p)
                                {
                                    ways++;
                                }
                            }
                        }
                    }


                }
                Console.WriteLine(ways);
               
            }
        } 

    }
}

Measured memory_bytes: 9156
#include<bits/stdc++.h>
#define mp make_pair
#define f first
#define se second
#define pb push_back
#define ms memset
#define MOD 1000000007
#define sp fixed<<setprecision
#define sz sizeof
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
bool pr[1000007];
ll fpow(ll x,ll y){x=x%MOD;ll res=1;while(y){if(y&1)res=res*x;res%=MOD;y=y>>1;x=x*x;x%=MOD;}return res;}
ll inv(ll a,ll m=MOD){ll c=m;ll y=0,x=1;if(m==1)return 0;while(a>1){ll q=a/m;ll t=m;m=a%m,a=t;t=y;y=x-q*y;x=t;}if(x<0)x+=c;return x;}
int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	ll n,k;
	cin>>n>>k;
	ll a[n];
	for(int i=0;i<n;i++)
	cin>>a[i];
	sort(a,a+n);
	bool winning[k+1];
	memset(winning,0,sizeof(winning));
	//0 is loosing
	// 1 is winning
	for(int i=a[0];i<=k;i++)
	{
		bool temp=1;
		for(int j=0;j<n;j++)
		{
			if(a[j]>i)
			continue;
			else
			temp&=winning[i-a[j]];
		}
		winning[i]=!temp;
	}
	if(winning[k])
	cout<<"First";
	else
	cout<<"Second";

}


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

using namespace std;

typedef unsigned uint;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ldbl;
typedef pair<int, int> pii;
typedef pair<uint, uint> puu;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pull;
typedef pair<double, double> pdd;
typedef vector<int> vi;
typedef vector<uint> vu;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<pii> vpii;
typedef vector<puu> vpuu;
typedef vector<pll> vpll;
typedef vector<pull> vpull;
typedef vector<string> vstr;
typedef vector<double> vdbl;
typedef vector<ldbl> vldbl;
#define pb push_back
#define ppb pop_back
#define pfr push_front
#define ppfr pop_front
#define emp emplace
#define empb emplace_back
#define be begin
#define rbe rbegin
#define all(x) (x).be(), (x).end()
#define rall(x) (x).rbe(), (x).rend()
#define fir first
#define sec second
#define mkp make_pair
#define brif(cond) if (cond) break
#define ctif(cond) if (cond) continue
#define retif(cond) if (cond) return
void canhazfast() {ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);}
template<typename T> T gcd(T a, T b) {return b ? gcd(b, a%b) : a;}
template<typename T> T extgcd(T a, T b, T &x, T &y)
{
    T x0 = 1, y0 = 0, x1 = 0, y1 = 1;
    while (b) {
        T q = a/b; a %= b; swap(a, b);
        x0 -= q*x1; swap(x0, x1);
        y0 -= q*y1; swap(y0, y1);
    }
    x = x0; y = y0; return a;
}
int ctz(uint x) {return __builtin_ctz(x);}
int ctzll(ull x) {return __builtin_ctzll(x);}
int clz(uint x) {return __builtin_clz(x);}
int clzll(ull x) {return __builtin_clzll(x);}
int popcnt(uint x) {return __builtin_popcount(x);}
int popcntll(ull x) {return __builtin_popcountll(x);}
int bsr(uint x) {return 31^clz(x);}
int bsrll(ull x) {return 63^clzll(x);}

int dp[65536];

int main()
{
    canhazfast();

    int n;

    cin >> n;
    for (int x = 1; x <= 100; ++x) {
        for (int y = 1; y <= 100; ++y) {
            for (int z = 1; z <= 100; ++z) {
                int v = x*x+y*y+z*z+x*y+x*z+y*z;
                ++dp[v];
            }
        }
    }
    for (int i = 1; i <= n; ++i) cout << dp[i] << '\n';

    return 0;
}


Measured memory_bytes: 3772
#include <stdio.h>

const int DX[] = {-1, 0, 1, 0};
const int DY[] = {0, -1, 0, 1};

char map[16][16];

void blast(int y, int x)
{
    int i;

    if (map[y][x] != '1'){
        return;
    }

    map[y][x] = '0';
    for (i = 0; i < 4; ++i){
        blast(y + DY[i], x + DX[i]);
    }
}

int scan_map(void)
{
    int i;

    if (scanf("%s", map[1] + 1) == EOF){
        return (0);
    }

    for (i = 2; i <= 12; ++i){
        scanf("%s", map[i] + 1);
    }

    return (1);
}

void solve(void)
{
    int cnt;
    int i, j;

    cnt = 0;
    for (i = 1; i <= 12; ++i){
        for (j = 1; j <= 12; ++j){
            if (map[i][j] == '1'){
                ++cnt;
                blast(i, j);
            }
        }
    }

    printf("%d\n", cnt);
}

int main(void)
{
    while (scan_map() != 0){
        solve();
    }

    return (0);
}

Measured memory_bytes: 540
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define PI acos(-1)
#define pcnt __builtin_popcountll
#define rng(a) a.begin(), a.end()
#define sz(x) (int)(x).size()
#define v(T) vector<T>
#define vv(T) v(v(T))
#define fi first
#define se second

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;

template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) {if (a > b) { a = b; return true; } return false; }

ll INF = 1001001001;
ll LINF = 1001001001001001001ll;

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

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

    ll ans = (a + b * (n - 1) - (b + a * (n - 1)));
    cout<<max(ans + 1, 0ll)<<endl;
}

Measured memory_bytes: 256
/*

Author : @karngyan
Team : BlundersPride
Date : 02-03-2019
Time : 00:02:04

*/


#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
//typedef tree<int,null_type,less<int>,rb_tree_tag,
//tree_order_statistics_node_update> indexed_set;
using namespace std;

typedef long long ll;
typedef long double ld;
typedef std::vector<ll> vll;
typedef std::pair<ll,ll> pll;
typedef std::vector<vll> vvll;

#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define endl '\n'
#define pb push_back
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define rrep(i,a,b) for(ll i=a;i>b;--i)
#define max3( a, b, c ) max( a , max(b , c))
#define cres(c,n) (c).clear(),(c).resize(n)
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define ff first
#define ss second
#define mk make_pair

vll v;

signed main()
{
	fast;
////////////////////////////////////////////////////////////////////////////////////////////
	
	ll a, b, k;
	cin >> a >> b >> k;
	k--;

	for(ll i = 1 ; i<=100 ; ++i)
	{
		if((a%i == 0) and (b%i == 0))
			v.pb(i);
	}
	sort(rall(v));
	cout<<v[k]<<endl;








////////////////////////////////////////////////////////////////////////////////////////////
	
	return 0;
}



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

using namespace std;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int n, su, sv;
    cin >> n >> su >> sv;
    su--; sv--;
    vector<vector<int>> g(n);
    for (int i = 0; i < n-1; i++) {
        int u, v;
        cin >> u >> v;
        u--; v--;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    int fromU = -1;
    int fromV = -1;
    int ans = 0;
    vector<int> path;
    function<void(int, int)> dfs;
    dfs = [&] (int v, int p) {
        path.push_back(v);
        if (v == sv) {
            int sz = path.size();
            int j = (sz - 2) / 2;
            ans = (sz - 1) / 2;
            fromU = path[j];
            fromV = path[j+1];
            return;
        } else {
            for (int u: g[v]) {
                if (u != p) {
                    dfs(u, v);
                }
            }
        }
        path.pop_back();
    };
    dfs(su, -1);
    //cout << fromU << " " << fromV << " -> " << ans << endl;

    int mx = 0;
    vector<int> d(n, -1);
    d[fromU] = 0;
    vector<int> q = {fromU};
    for (int qi = 0; qi < q.size(); qi++) {
        int v = q[qi];
        for (int u: g[v]) {
            if (d[u] == -1 && u != fromV) {
                d[u] = d[v] + 1;
                mx = max(d[u], mx);
                q.push_back(u);
            }
        }
    }
    ans += mx;
    cout << ans << endl;
}




Measured memory_bytes: 11256
#include<bits/stdc++.h>
using namespace std;
int main(){
  char c;
  cin>>c;
  if(c=='A') cout<<"T"<<endl;
  if(c=='G') cout<<"C"<<endl;
  if(c=='C') cout<<"G"<<endl;
  if(c=='T') cout<<"A"<<endl;
}


Measured memory_bytes: 3564
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
  int N;
  cin >> N;
  
  vector <int> a(N), b(N), c(N);
  for (int i = 0; i < N; ++i) {
    cin >> a[i];
    cin >> b[i];
    cin >> c[i];
  }
  
  vector <vector <int> > dp(N, vector <int> (3));
  dp[0][0] = a[0];
  dp[0][1] = b[0];
  dp[0][2] = c[0];
  for (int i = 1; i < N; ++i) {
    dp[i][0] = max(dp[i - 1][1], dp[i - 1][2]) + a[i];
    dp[i][1] = max(dp[i - 1][0], dp[i - 1][2]) + b[i];
    dp[i][2] = max(dp[i - 1][0], dp[i - 1][1]) + c[i];
  }
  
  vector <int> cand = *dp.rbegin();
  sort(cand.begin(), cand.end());
  cout << *cand.rbegin() << endl;
  return 0;
}

Measured memory_bytes: 9480
import sys
input = sys.stdin.readline

k,q=map(int,input().split())
D=tuple(map(int,input().split()))

def sum_count(A):
    S=0
    C=0
    for a in A:
        if a==0:
            C+=1
        else:
            S+=a
    return S,C

for query in range(q):
    n,x,m=map(int,input().split())

    D2=[d%m for d in  D]
    S,D0=sum_count(D2)
    R=(n-1)//k
    ANS=R*(k-D0) - (R*S+x%m)//m 
    x2=(x+S*R)%m
    rest=n-R*k-1
    S2,DR0=sum_count(D2[:rest])
    ANSR=rest - DR0 - (x2+S2)//m

    print(ANS+ANSR)

Measured memory_bytes: 63580
#include  <bits/stdc++.h>
using namespace std;
using ll = long long;
const int maxn = 1e5 + 5;
int t[maxn << 2], a[maxn], n, pg[maxn], ng[maxn];
ll ans = 0;
void build(int u = 1, int b = 1, int e = 100000) {
	if(b == e) return void(t[u] = a[b]);
	int m = b + e >> 1;
	build(u << 1, b, m);
	build(u << 1 | 1, m + 1, e);
	t[u] = max(t[u << 1], t[u << 1 | 1]);
}
int query(int l, int r, int u = 1, int b = 1, int e = 100000) {
	if(b > r or e < l or l > r) return 0;
	if(l <= b and e <= r) return t[u];
	int m = b + e >> 1;
	return max(query(l, r, u << 1, b, m), query(l, r, u << 1 | 1, m + 1, e));
}
int main(int argc, char const *argv[])
{
	// freopen("in", "r", stdin);
	cin >> n;
	for(int i = 1; i <= n; i++) {
		cin >> a[i];
	}
	build();
	a[0] = a[n + 1] = maxn;
	vector<int> stk = {0};
	for(int i = 1; i <= n; i++) {
		while(a[stk.back()] < a[i]) stk.pop_back();
		pg[i] = stk.back(), stk.push_back(i);
	}
	stk = {n + 1};
	for(int i = n; i >= 1; i--) {
		while(a[stk.back()] < a[i]) stk.pop_back();
		ng[i] = stk.back(), stk.push_back(i);
	}
	pg[0] = 0, ng[n + 1] = n + 1;
	for(int i = 1; i <= n; i++) {
		int l = 0, r = 0;
		if(pg[i] > 0) {
			int lx = -1, lo = 1, hi = pg[i] - 1, mid;
			if(a[pg[i] - 1] > a[i]) lx = pg[i] - 1;
			else {
				while(lo <= hi) {
					mid = lo + hi >> 1;
					if(query(mid, pg[i] - 1) < a[i]) {
						lx = mid, hi = mid - 1;
					} else {
						lo = mid + 1;
					}
				}
				lx--;
			}
			l = pg[i] - lx;
		} else {
			l = 0;
		}
		if(ng[i] < n + 1) {
			int rx = -1, lo = ng[i] + 1, hi = n, mid;
			if(a[ng[i] + 1] > a[i]) rx = ng[i] + 1;
			else {
				while(lo <= hi) {
					mid = lo + hi >> 1;
					if(query(ng[i] + 1, mid) < a[i]) {
						rx = mid, lo = mid + 1;
					} else {
						hi = mid - 1;
					}
				}
				rx++;
			}
			r = rx - ng[i];
		} else {
			r = 0;
		}
		ll ls = ll(l) * ll(ng[i] - i);
		ll rs = ll(r) * ll(i - pg[i]);
		ans += (ls + rs) * a[i];
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 2940
package main

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


func main() {
	var n, m, c int
	fmt.Scan(&n, &m, &c)

	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	b := make([]int, m)
	for i := 0; i < m; i++ {
		sc.Scan()
		b[i], _ = strconv.Atoi(sc.Text())
	}

	ans := 0
	for i := 0; i < n; i++ {
		p := 0
		for j := 0; j < m; j++ {
			sc.Scan()
			a, _ := strconv.Atoi(sc.Text())
			p += a * b[j]
		}
		if p+c > 0 {
			ans++
		}
	}
	fmt.Println(ans)

}



Measured memory_bytes: 1844
#!/usr/bin/env python3
#ABC142 B

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n,k = LI()
h = LI()
ans = 0
for i in range(n):
    if h[i] >= k:
        ans += 1
print(ans)

Measured memory_bytes: 50048
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
  int M, N;
  cin >> N >> M;
  vector<pair<long long, long long>> d(N);
  for(int i=0; i<N; ++i) cin >> d[i].first >> d[i].second;
  sort(d.begin(), d.end());

  long long cost=0;
  int amount=0;
  for(auto drink:d)
  {
    if(drink.second <= M)
    {
      M -= drink.second;
      cost += drink.first*drink.second;
    }
    else
    {
      cost += drink.first*M;
      break;
    }
  }
  cout << cost << endl;
  return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include<algorithm>
using namespace std;
#define rep(i,n) for(int i =0;i < n;i++)
int main() {
    int n, m,l,r,le = 0,ri = 100001;
    cin >> n >> m;
    rep(i, m) {
        cin >> l >> r;le = max(le, l);ri = min(ri, r);
    }
    cout << max(ri - le + 1,0) << endl;
 }

Measured memory_bytes: 256
n, m = map(int, input().split())

a = []
for _ in range(n):
    a.append(input())

b = []
for _ in range(m):
    b.append(input())

for i in range(n - m + 1):
    for j in range(n - m + 1):
        flag = True
        for b_x in range(m):
            a_x = b_x + i
            for b_y in range(m):
                a_y = b_y + j
                if(a[a_x][a_y] != b[b_x][b_y]):
                    flag = False
        if flag == True :
            print('Yes')
            exit()
print('No')

# print(yesNo)
                

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // std::ifstream in("input.txt");
    // std::cin.rdbuf(in.rdbuf());
    string s;
    cin >> s;
    ll sl = len(s);
    map<ll, ll> m;
    rep(i, sl) m[s[i]]++;
    ll ans = sl * (sl - 1) / 2 + 1;
    for(auto x : m) {
        ans -= x.second * (x.second - 1) / 2;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 720
//#include "stdafx.h"
#include <bits/stdc++.h>
#define ll long long
#define vi vector<int>
#define e "\n"
#define MaRiaMa { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); }
#define fix(n) cout << fixed << setprecision(n);
using namespace std;
int main()
{
	MaRiaMa;
	int n;
	cin >> n;
	ll ru = (n * 800) - ((n / 15) * 200);
	cout << ru;
}

Measured memory_bytes: 3512
n = int(input())
a = list(map(int, input().split()))

s = [0]*(n+1)
for i in range(n):
    s[i+1] += a[i] + s[i]
#print(s)
ans = float("inf")
for i in range(1, n):
    x = s[i]
    y = s[n]-s[i]
    ans = min(ans, abs(x-y))
print(ans)

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

#define ff first
#define ss second
typedef long long ll;
typedef pair<ll, ll> pii;

const ll N = 200 * 1000 + 20;
pii x[N];
ll n, d, a;

int main() {
  	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  	cin >> n >> d >> a;
  	for (int i = 0; i < n; i++)
      	cin >> x[i].ff >> x[i].ss;
 	sort(x, x + n);
  	deque<pii> dq;
  	ll sum = 0, ans = 0;
  	for (int i = 0; i < n; i++) {
		while (dq.size() && dq.front().ff + 2 * d < x[i].ff) {
          	sum -= dq.front().ss * a;
          	dq.pop_front();
        }
      	x[i].ss -= sum;
      	if (x[i].ss > 0) {
      		ll y = (x[i].ss + a - 1) / a;
      		if (y) {
				ans += y;
              	dq.push_back({x[i].ff, y});
              	sum += y * a;
            }
        }
    }
  	return cout << ans << "\n", 0;
}


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

int main(){
    string s;
    cin >> s;
    for(int i=0;i<s.size()-1;i++){
        if(s.at(i)=='A'&&s.at(i+1)=='C'){
            puts("Yes");
            return 0;
        }
    }
    puts("No");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define IO(i, o) freopen(i, "r", stdin), freopen(o, "w", stdout)

using namespace std;
int D, N;

int main(void){
	//IO("test.in", "test.out");
	scanf("%d%d", &D, &N);
	if(D == 0 && N != 100) printf("%d\n", N);
	else if(D == 0 && N == 100) printf("101\n");
	else if(D == 1 && N < 100) printf("%d00\n", N);
	else if(D == 1 && N == 100) printf("10100\n");
	else if(D == 2 && N < 100) printf("%d0000\n", N);
	else printf("1010000\n");
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define N
#define CM cerr<<(&MOP1-&MOP2)/1024.0/1024.0<<endl
using namespace std;
template <class T> inline T Min(T x, T y){
    return x<y?x:y;
}
template <class T> inline T Max(T x, T y){
    return x>y?x:y;
}
bool MOP1;
int a,b,c;
bool MOP2;
int main(){
	scanf("%d%d%d",&a,&b,&c);
	printf("%d\n",Max(0,c-a+b));
	return 0;
}






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

counts = [0 for _ in range(maxA+1)]
for a in A:
  counts[a] += 1

integers = [1 for _ in range(maxA+1)]
integers[0] = 0
integers[1] = 0
max_count = 0
for i in range(maxA+1):
   if integers[i] >= 1:
    count = 0
    for j in range(i,maxA+1,i):
      count += counts[j]
      integers[j] = 0
    max_count = max(max_count,count)

if max_count == N:
  answer = 'not coprime'
elif max_count >= 2:
  answer = 'setwise coprime'
else:
  answer = 'pairwise coprime'

print(answer)

Measured memory_bytes: 126252
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  int n,a,b;
  cin>>n>>a>>b;
  int h[n];
  for(int i=0;i<n;i++) cin>>h[i];
  int l=0,r=11111111111;
  while(l+1<r){
    int m=(l+r)/2;
    int t[n];
    int x=m;
    for(int i=0;i<n;i++){
      t[i]=max(0LL,h[i]-b*m);
      x-=(t[i]+(a-b)-1)/(a-b);
    }
    if(x>=0) r=m;
    else l=m;
  }
  cout<<r<<endl;
  return 0;
}


Measured memory_bytes: 1792
<?php
    $input_line = trim(fgets(STDIN));
    
    $num = explode(" ",$input_line);
    
    $x = intval($num[0]);
    $y = intval($num[1]);
    $z = intval($num[2]);
    
    $count=0;
    for($i=$x;$i<=$y;$i++){
        if($z%$i==0){
            $count++;
        }
    }
    echo $count;
    echo "\n";
?>


Measured memory_bytes: 9216
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i];
#define ft first
#define sc second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define LB(a,x) lb(all(a),x)-a.begin()
#define UB(a,x) ub(all(a),x)-a.begin()
#define mod 1000000007
//#define mod 998244353
#define FS fixed<<setprecision(15)
using namespace std;
typedef long long ll;
const double pi=3.141592653589793;
template<class T> using V=vector<T>;
using Graph = vector<vector<int>>;
using P=pair<ll,ll>;
typedef unsigned long long ull;
typedef long double ldouble;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline void out(T a){ cout << a << '\n'; }
void YN(bool ok){if(ok) cout << "Yes" << endl; else cout << "No" << endl;}
//void YN(bool ok){if(ok) cout << "YES" << endl; else cout << "NO" << endl;}


const ll INF=1e18;
const int mx=200005;

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    ll n;
    cin>>n;
    V<ll> a(n);
    cinf(n,a);
    ll g=a[0];
    for(int i=1;i<n;i++) g=__gcd(g,a[i]);
    sort(all(a));
    bool ok=1;
    V<bool> p(1000001,1);
    V<ll> pp;
    ll ma=*max_element(all(a));
    V<ll> mp(1000001,0);
    rep(i,n) mp[a[i]]++;
    
    for(ll i=2;i<=1000000;i++){
        if(i>ma) break;
        if(p[i]){
            //if(!st.count(i))
            int cnt=0;
            if(mp[i]>0) cnt+=mp[i];
            for(ll j=2*i;j<=1000000;j+=i){
                if(j>ma) break;
                p[j]=0;
                if(mp[j]>0) cnt+=mp[j];
            }
            if(cnt>1) ok=0;
        }
    }
    /*ll ma=*max_element(all(a));
    for(ll cur:pp){
        if(cur>ma) break;
        ll cnt=0;
        rep(j,n){
            if(a[j]%cur==0) cnt++;
        }
        if(cnt>1) ok=0;
        
    }*/
    if(ok) out("pairwise coprime");
    else if(g==1) out("setwise coprime");
    else out("not coprime");
}
//ペナルティ出しても焦らない　ACできると信じろ！！！
//どうしてもわからないときはサンプルで実験　何か見えてくるかも
//頭で考えてダメなら紙におこせ！！
/*
V,P(大文字)使用不可
乗算などの際にオーバーフローに注意せよ！
(適切にmodをとれ　にぶたんで途中で切り上げろ)
制約をよく読め！
{
    ・全探索できるなら全探索しろ
    ・異常な制約ならそこに注目
}
stringの計算量(扱い)注意
コーナー注意！(特に数値が小さいものについては要検証)
N行出力のときは'¥n'
グリッド上では行先が範囲内におさまるかif文で確認(RE注意)
if文ではちゃんと比較演算子==を使え('='でもエラー出ない)
配列(vector)の大きさが0か1以上かで場合分けせよ(RE注意)
(vector<int> a(m)でm==0というものはできない)
modはなるべく最後に取れ！
doubleを扱うときには(abs)ではなく'fabs'!!!
*/

Measured memory_bytes: 18988
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, K;
    cin >> N >> K;
    int V[110];
    rep(i, N) cin >> V[i];
    int ans = 0;
    REP(L, 0, min(N, K)) {
        REP(R, 0, min(N, K) - L) {
            if (L + R > N) continue;
            //cout << L << " " << R << "->";
            vector<int> G;
            rep(i, L) G.push_back(V[i]);
            rep(i, R) G.push_back(V[N - i - 1]);
            sort(G.begin(), G.end());
            //rep(i, G.size()) cout << G[i] << " ";
            //cout << "->";
            int amari = K - R - L;
            int tmp = 0;
            rep(i, G.size()) {
                if (G[i] < 0 && amari) {
                    amari--;
                } else {
                    tmp += G[i];
                }
                //cout << tmp << " ";
            }
            //cout << tmp << endl;
            ans = max(tmp, ans);
        }
    }
    cout << ans << endl;

    return 0;
}


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

#define MODSIZE 1000000007

ll reppow(ll x,ll n){
  ll res = 1;
  while(n > 0){
    if(n & 1) res = (res*x) % MODSIZE;
    x = (x*x) % MODSIZE;
    n >>= 1;
  }

  return res;
}

ll mod(ll val,ll m){
  ll res = val % m;
  if(res < 0) res += m;

  return res;
}

int main(){
  ll n,a,b;
  ll Xa,Xb;
  ll Ya,Yb;
  ll Z;
  ll ans;

  scanf("%lld %lld %lld", &n, &a, &b);

  int i;

  Xa = 1; Xb = 1; Ya = 1; Yb = 1;
  for(i = 0;i < a;i++){
    Xa = (Xa*(n - i)) % MODSIZE;
    Ya = (Ya*(i + 1)) % MODSIZE;
  }

  for(i = 0;i < b;i++){
    Xb = (Xb*(n - i)) % MODSIZE;
    Yb = (Yb*(i + 1)) % MODSIZE;
  }

  Ya = (reppow(Ya,MODSIZE - 2));
  Yb = (reppow(Yb,MODSIZE - 2));

  Z = mod((reppow(2,n) - 1) % MODSIZE - Xa*Ya % MODSIZE,MODSIZE);
  ans = mod(Z - Xb*Yb % MODSIZE,MODSIZE);

  printf("%lld", ans);

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int maxn=1e6+5;
int main()
{
    int n;
    char s[105];
    scanf("%d",&n);
    scanf("%s",s);
    if(n%2==1)
    {
        printf("No");
        return 0;
    }
    else
    {
        for(int i=0; i<n/2; i++)
        {
            if(s[i]!=s[n/2+i])
            {
                printf("No");
                return 0;
            }
        }
        printf("Yes");
    }
    return 0;
}


Measured memory_bytes: 256
using System;
namespace t{
class submit{
public static void Main(string[] args){
string input=Console.ReadLine();
string[] input1=input.Split(char.Parse(" "));
int a=int.Parse(input1[0]);
int b=int.Parse(input1[1]);
if(a==b){
Console.WriteLine("a"+" == "+"b");
}
if(a<b){
Console.WriteLine("a"+" < "+"b");
}
if(a>b){
Console.WriteLine("a"+" > "+"b");
}
}
}
}


Measured memory_bytes: 15888
#include<cstdio>
#include<iostream>
#include<vector>
#include<queue>
#include<algorithm>
#include<string.h>

using namespace std;

int main(int argc, char* argv[]){
  int n;
  int k;
  scanf("%d%d",&n,&k);
  int temp;
  long long int ans=0;
  for(int b=1;b<=n;b++){
    int p=n/b;
    int r=n%b;
    ans+=p*max(0,b-k)+max(0,r-k+1);
    if(0%b>=k)ans-=1;
  }
  printf("%lld\n",ans);
  return 0;
}

Measured memory_bytes: 256
import           Control.Monad
import qualified Data.ByteString.Char8 as B
import           Data.Char
import qualified Data.Vector.Unboxed   as U

readIntN :: Int -> IO (U.Vector Int)
readIntN n = U.unfoldrN n (B.readInt . B.dropWhile isSpace) <$> B.getLine

main :: IO ()
main = do
  n <- readLn
  as <- readIntN n
  print $ solve as

solve :: U.Vector Int -> Int
solve = fst . U.foldl' f (0, 0)
 where
  f (acc, h) x
    | h <= x    = (acc, h `max` x)
    | otherwise = (acc + h - x, h)


Measured memory_bytes: 10212
#include <stdio.h>

int main(void){
   int num,b,i,s,e;
   scanf("%d%d",&num,&b);

   s=b-num+1; e=b+num-1;
   for(i=s;i<=e;i++)
      printf("%d ",i);

   printf("\n");
   return 0;
}

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

int main(){
  int n,k,x,l;
  cin >> n >>k;
  l = 0;
  
  for (int i = 0; i<n ;i++){
    cin >>x;
    if (k <= x){//k <= x
      l += (x - k) *2;
    }
    else if (k <= x*2 ){//k/2 <= x < k
      l += (k - x ) *2;
    }
    else{//0 <= x < k/2 
      l += x*2;
    }
  }
  
  cout << l <<endl;
      
  
}

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

ll gcd(int x,int y){
    int t;
    while(y != 0){
        t = x % y;
        x = y;
        y = t;
    }
    return x;
}

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

    sort(v.begin(),v.end());

    ll ans = v[1] - v[0];

    for(int i = 2; i <= n; ++i)
        ans = gcd(ans,v[i] - v[i-1]);

    cout << ans << endl;

}

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

int main() {
 int N;
  cin >> N;
  vector<int> kazu(N);
  for(int i = 0; i < N; i++){
    cin >> kazu.at(i);
  }
  bool district = true;
  sort(kazu.begin(), kazu.end());
  for(int i = 0; i < N-1; i++){
    if(kazu.at(i) == kazu.at(i+1)){
      cout << "NO" << endl;
      district = false;
      break;
      
    }
  }
 if(district) cout << "YES" << endl;
}


Measured memory_bytes: 1024
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
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

s = input()
s = s.replace("BC", ".")
cnt = 0
ans = 0
for x in s:
	if x == "B" or x =="C":
		cnt = 0
		continue
	if x == ".":
		ans += cnt
	if x == "A":
		cnt += 1
print(ans)


Measured memory_bytes: 5720
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Kein Yukiyoshi
 */

#include "bits/stdc++.h"
#define int long long
#define rep(i, n)           for (int i = 0; i < (int)(n); i++)
#define REP(i, a, b)        for (int i = (int)(a); i < (int)(b); i++)
#define FOR(i, a)           for (auto &i : a)
#define ALL(obj)            begin(obj), end(obj)
#define MAX(x)              *max_element(ALL(x))
#define MIN(x)              *min_element(ALL(x))
#define sum(x)              accumulate(ALL(x), 0LL)
#define LOWER_BOUND(A, key) distance(A.begin(), lower_bound(ALL(A), key))
#define UPPER_BOUND(A, key) distance(A.begin(), upper_bound(ALL(A), key))

using namespace std;
const int MOD    = (int)(1e9 + 7);
const int INF    = (int)(1e13 + 7);
const double EPS = 1e-14;
const double PI  = acos(-1);

int CEIL(int a, int b) { return (a >= 0 ? (a + (b - 1)) / b : (a - (b - 1)) / b); } //ceil() for int
int mod(int a, int b) { return a >= 0 ? a % b : a - (b * CEIL(a, b)); }             //always return positive num
int bpm(int a, int b) {                                                             //return x^y in order(log(y))
  int res = 1;
  for (a %= MOD; b; a = a * a % MOD, b >>= 1)
    if (b & 1) res = res * a % MOD;
  return res;
}

class DIntegerCards {
public:
  static void solve(istream &cin, ostream &cout) {
    int N, M;
    cin >> N >> M;
    vector<int> A(N);
    rep(i, N) cin >> A[i];
    vector<pair<int, int>> BC(M);
    rep(i, M) cin >> BC[i].second >> BC[i].first;
    sort(ALL(BC));
    sort(ALL(A));
    int now = 0;
    for (int i = M - 1; i >= 0; i--) {
      rep(j, BC[i].second) {
        if (BC[i].first < A[now]) break;
        A[now] = BC[i].first;
        now++;
      }
    }
    cout << sum(A) << endl;
  }
};


signed main() {
  cin.tie(0);
  cout.tie(0);
  ios_base::sync_with_stdio(false);
  cout<<fixed<<setprecision(15);
  DIntegerCards solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}


Measured memory_bytes: 2560
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<map>
using namespace std;
#define ll long long
int main(){
	string S;
	cin >> S;
	int i;
	for(i=0;i<S.size();i++){
		cout << 'x';
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <cstring>
#include <climits>


#define FOR(i, a, b) for(int i=int(a); i<int(b); i++)
#define FORC(cont, it) for(decltype((cont).begin()) it = (cont).begin(); it != (cont).end(); it++)
#define pb push_back

using namespace std;

typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;



int main(){

	ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n, k;
    cin >> n >> k;

    int h[n];

    FOR(i,0,n){
        cin >> h[i];
    }

    long long dp[n+5];

    dp[0] = 0;

    for(int i = 1; i <= k && i < n; i++){
        dp[i] = abs(h[i] - h[0]);
    }

    FOR(i,k+1,n){
        int min = INT_MAX;
        for(int j = 1; j <= k && j <= i ; j++){
            min = (dp[i-j] + abs(h[i] - h[i-j])) < min ? (dp[i-j] + abs(h[i] - h[i-j])): min;
        }
        dp[i] = min;
    }

    cout << dp[n-1] << endl;
	return 0;
}


Measured memory_bytes: 1408
def valid(x):
    even_mask = 85  # 01010101
    odd_mask = 170  # 10101010
    return (x & odd_mask) >> 1 & (x & even_mask) == 0 and (x & odd_mask) << 1 & (x & even_mask) == 0

def yoko(x):
    a, b, c = 0, 0, 0
    for bit in range(1<<(W-1)):
        if not valid(bit):
            continue
        if bit >> (W - x - 1) & 1:
            a += 1
        elif W - x - 2 >= 0 and bit >> (W - x - 2) & 1:
            c += 1
        else:
            b += 1
    return a, b, c

H, W, K = map(int, input().split())

dp = [[0] * W for _ in range(H+1)]
dp[0][0] = 1
BIG = 1000000007

for i in range(H):
    for j in range(W):
        a, b, c = yoko(j)
        if j - 1 >= 0:
            dp[i+1][j-1] += a * dp[i][j]
            dp[i+1][j-1] %= BIG
        dp[i+1][j] += b * dp[i][j]
        dp[i+1][j] %= BIG
        if j + 1 < W:
            dp[i+1][j+1] += c * dp[i][j]
            dp[i+1][j+1] %= BIG
print(dp[H][K-1])

Measured memory_bytes: 3064
N = int(input())
p = [0] * (N+1)


def is_prime(n):
    for i in range(2, n):
        if not n % i:
            return False
    return True


def n(m):
    return sum([True for i in p if i >= m])


l = [i for i in range(2, N+1) if is_prime(i)]
for i in range(2, N+1):
    for j in l:
        while not i % j:
            p[j] += 1
            i //= j

print(n(74) +
      (n(2)-1) * n(24) +
      (n(2)-2) * ((n(4)-1) * n(4))//2 +
      (n(4)-1) * n(14))

Measured memory_bytes: 3064
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations,permutations,accumulate # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
#import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#
# my_round_int = lambda x:np.round((x*2 + 1)//2)
# 四捨五入
import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
ya = [0] * 100001
for x in range(1,101):
    for y in range(1,101):
        for z in range(1,101):
            n = x**2 + y**2 + z**2 + x*y + y*z + z*x
            ya[n] += 1
n = I()
for i in range(1,n+1):
    print(ya[i])


Measured memory_bytes: 79680
x,y,a,b,c = map(int,input().split(" "))
ar = list(map(int,input().split(" ")))
br = list(map(int,input().split(" ")))
cr = list(map(int,input().split(" ")))
ar = sorted(ar,reverse=True)
br = sorted(br,reverse=True)
ar = ar[0:x]
br = br[0:y]
ar = ar + br + cr
ar = sorted(ar,reverse=True)
count = 0
for i in range(x+y):
    count += ar[i]
print(count)

Measured memory_bytes: 22720
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<ll,ll>;
const ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define pow(x,y) modpow(x,y)
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REPS(i,n) for(ll (i)=1;(i)<=(n);(i)++)
#define RREP(i,n) for(ll (i)=(n-1);(i)>=0;(i)--)
#define RREPS(i,n) for(ll (i)=(n);(i)>0;(i)--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());

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

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

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    ll N,M;
    cin >> N >> M;
    if(N%2 == 1){
        REPS(i,M){
            cout << i << " " << N-i << "\n";
        }
    }else if(N == 4){
        cout << 2 <<" "<< 3 << "\n";
    }else{
        ll fronto = 1,backo = N/2-1;
        ll fronte = N/2,backe = N-1;
        REPS(i,M){
            if(i%2==1){
                cout << fronte << " " << backe << "\n";
                fronte++;
                backe--;
            }else{
                cout << fronto << " " << backo << "\n";
                fronto++;
                backo--;
            }
        }
    }
}

Measured memory_bytes: 3644
import bisect
while True:
    d = int(input())
    if d==0: break
    n = int(input())
    m = int(input())

    shops = [0]*n
    for i in range(1,n):
        shops[i] = int(input())
    shops.sort()
    shops.append(d)
    d = 0
    for i in range(m):
        cus = int(input())
        req = bisect.bisect(shops,cus)
        d += min(abs(cus-shops[req-1]), abs(cus-shops[req]))

    print(d)

Measured memory_bytes: 11840
def insertionSort(arr, N, g):
    cnt = 0
    for i in range(g, N):
        tmp = arr[i]
        j = i - g
        while(j >= 0 and arr[j] > tmp):
            arr[j + g] = arr[j]
            j -= g
            cnt += 1
        arr[j + g] = tmp
    return cnt


def shellSort(arr, N):
    G = []
    h = 0
    m = 0
    while h <= N / 9:
        h = 3 * h + 1
        G.append(h)
        m += 1
    G = G[::-1]

    cnt = sum([insertionSort(arr, N, g) for g in G])
    return (cnt, G)


N = int(input())
arr = [int(input()) for i in range(N)]

(cnt, G) = shellSort(arr, N)
print(len(G), ' '.join(map(str, G)), cnt, '\n'.join(map(str, arr)), end='\n')



Measured memory_bytes: 125980
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define debug(x) cerr << #x << " = " << x << "\n"
#define debugv(x) rep(i, x.size()) cerr << x[i] << (i == x.size() - 1 ? "\n" : " ")
using namespace std;
#define int long long
typedef long long ll;
typedef pair<int, int> pii;
const int INF = ((1LL << 30) + (1LL << 29));
const int MOD = 1000000007;

//=============================
int N,M,X,Y;
vector<int> xv;
vector<int> yv;
//=============================
void input()
{
    cin>>N>>M>>X>>Y;
    xv.resize(N);
    yv.resize(M);
    rep(i,N){
        cin>>xv[i];
    }
    rep(i,M){
        cin>>yv[i];
    }
}

void solve()
{
    sort(xv.rbegin(),xv.rend());
    sort(yv.begin(), yv.end());
    int xmax = xv[0];
    int ymin = yv[0];

    bool ans = (xmax < ymin) && (xmax > X) && (ymin <= Y);


    cout<< (ans ? "No War" : "War") << endl;

}

//=============================
signed main()
{
    input();
    solve();
    return 0;
}

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

int main(){
	int N, K;
	cin >> N >> K;
	long points[N][2];
	for(int i = 0; i < N; i++){
		cin >> points[i][0] >> points[i][1];
	}
	long ans = 4000000000000000000; 
	for(int l = 0; l < N; l++){
		for(int r = 0; r < N; r++){
			for(int u = 0; u < N; u++){
				for(int d = 0; d < N; d++){
					if((points[r][0] - points[l][0]) * (points[u][1] - points[d][1]) < ans && points[l][0] < points[r][0] && points[u][1] > points[d][1]){
						int in_point = 0;
						for(int i = 0; i < N; i++){
							if(points[l][0] <= points[i][0] && points[i][0] <= points[r][0] && points[u][1] >= points[i][1] && points[i][1] >= points[d][1]){
								in_point++;
							}
						}
						if(in_point >= K){
							ans = min(ans, (points[r][0] - points[l][0]) * (points[u][1] - points[d][1]));
						}
					}
				}
			}
		}
	}
	cout << ans << endl;
}

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

int main(){
	int n, m, k;
	cin >> n >> m >> k;
	int c = (n+m-1)/(k-1);
	LL dp[c+1][m+1];
	for(int i = 0; i <= c; i++){
		for(int j = 0; j <= m; j++){
			dp[i][j] = 0;
		}
	}
	dp[0][0] = 1;
	for(int i = 1; i <= c; i++){
		for(int j = 0; j <= m; j++){
			for(int l = 0; l < k && j+l <= m; l++){
				dp[i][j+l] = (dp[i][j+l] + dp[i-1][j]) % MOD;
			}
		}
	}
	LL ans = 0;
	while(m > 0){
		int cc = (n+m-1)/(k-1);
		ans += dp[cc][m];
		ans %= MOD;
		m -= (k-1);
	}
	cout << ans << endl;
}


Measured memory_bytes: 62720
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <iostream>
#include <string>
#include <set>
#include <map>
#include <unordered_map>
#include <complex>
#include <iomanip>
#include <cmath>
#include <tuple>
using namespace std;

int main() {
    int a, b, k;
    cin >> a >> b >> k;

    int counter = 0;
    int i = 1;
    vector<int> vec(a);
    while (i <= min(a, b)) {
        if (a % i == 0 && b % i == 0) vec.push_back(i);
        i++;
    }

    int res = vec[vec.size() - k];
    cout << res << endl;
}


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

vector<int> p;

bool isPrime(const int n) {
    for(int i = 0; i < (int)p.size(); i++)
    {
        if(n%p[i]==0) return false;
    }
    return true;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,a,ans;
    cin >> n;
    vector<int> v(5,0);
    for(int i = 2; i <= n; i++)
    {
        if (isPrime(i)) {
            a = 0;
            for(int j = i; n / j > 0; j *= i)
            {
                a += n / j;
            }
            p.push_back(i);
            if (a >= 2) v[0]++;
            if (a >= 4) v[1]++;
            if (a >= 14) v[2]++;
            if (a >= 24) v[3]++;
            if (a >= 74) v[4]++;
        }
    }
    ans =   v[1] * (v[1] - 1) / 2 * (v[0] - 2)
          + v[2] * (v[1] - 1)
          + v[3] * (v[0] - 1)
          + v[4];
    cout << ans << endl;
    return 0;
}

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

int main(){
  int a,b;
  double s,c;
  cin >>a>>b;
  s = ((double)a+b)/2;
  c = s-(int)s;
  if(c>=0.5)cout<<(int)s+1<<endl;
  else cout <<(int)s<<endl;
}

Measured memory_bytes: 256
// 失敗するからこそ そこから立ち向かって行く強さがあってそんな強さが本当の強さだと私は思うから
// ぜったいあきらめない
#include<bits/stdc++.h>
using namespace std;

#if defined(DAIJOBU)
#include "/home/ichigo/debug.hpp"
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define deb(x...)
#endif
#define FIO {ios::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);}


int main(){
	FIO
	
	int n;
	cin >> n;
	vector<string> a(n), b(n);
	for(int i = 0; i < n; i++)cin >> a[i];
	b = a;
	for(int i = 0; i < n; i++){
		for(int j = 0; j < n - 1; j++){
			if(a[j][1] > a[j + 1][1])swap(a[j], a[j + 1]);
		}
	}
	for(int i = 0; i < n; i++){
		int min_ = i;
		for(int j = i; j < n; j++){
			if(b[j][1] < b[min_][1]){
				min_ = j;
			}
		}
		if(min_ != i)swap(b[i], b[min_]);
	}
	cout << a[0];
	for(int i = 1; i < n; i++)cout << ' ' << a[i];
	cout << '\n' << "Stable\n";
	cout << b[0];
	if(b == a){
		for(int i = 1; i < n; i++)cout << ' ' << b[i];
		cout << '\n' << "Stable\n";
	}
	else{
		for(int i = 1; i < n; i++)cout << ' ' << b[i];
		cout << '\n' << "Not stable\n";
	}
	return 0;
}



Measured memory_bytes: 3184
(defmacro collect-times (n &body expr)
  `(loop repeat ,n
         collect (progn ,@expr)))

(defun read-times (n)
  (collect-times n (read)))

(defparameter *inf* (expt 10 10))

(defun main (books m x)
  (labels ((f (lst skills &optional (cost 0))
             (cond ((null lst)
                    (if (every (lambda (skill) (>= skill x)) skills)
                        cost
                        *inf*))
                   (t
                    (min (f (cdr lst) skills cost)
                         (f (cdr lst)
                            (mapcar #'+ skills (cdar lst))
                            (+ cost (caar lst))))))))
    (f books (collect-times m 0))))

(let ((n (read))
      (m (read))
      (x (read)))
  (format t "~a~%"
          (let ((ans (main (collect-times n (read-times (1+ m)))
                           m
                           x)))
            (if (= ans *inf*)
                -1
                ans))))


Measured memory_bytes: 25584
# frozen_string_literal: true

class Dice
  def initialize(params)
    @v = Array.new(6)
    (0..5).each do |i|
      @v[i] = params[i]
    end
  end

  def slide(a, b, c, d)
    tmp = @v[a]
    @v[a] = @v[b]
    @v[b] = @v[c]
    @v[c] = @v[d]
    @v[d] = tmp
  end

  def rotate_atom(char)
    case char
    when 'N'
      slide(0, 1, 5, 4)
    when 'E'
      slide(0, 3, 5, 2)
    when 'W'
      slide(0, 2, 5, 3)
    when 'S'
      slide(0, 4, 5, 1)
    end
  end

  def rotate(string)
    string.chars.each do |c|
      rotate_atom(c)
    end
  end

  def top
    @v[0]
  end
end

g = readline.split(' ')
dir = readline.chomp!
d = Dice.new(g)
d.rotate(dir)
puts d.top



Measured memory_bytes: 6872