akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
#define fi first
#define se second
int h,w,dp[10][1001];
string s;
typedef pair<int,int> P;
vector<P> v[7];
int dist(P a,P b){
	return abs(a.fi-b.fi)+abs(a.se-b.se);
}
main(){
	while(cin>>w>>h,w){
		int ans=1e9,syu=0;
		r(i,7)v[i].clear();
		r(i,h){
			cin>>s;
			r(j,w){
			if(isdigit(s[j]))v[s[j]-'0'].push_back(P(i,j));
			if(s[j]=='S')v[0].push_back(P(i,j));
			if(s[j]=='G')v[6].push_back(P(i,j));
	  	}
		}
		r(o,5){
			int pp=1e9;
			r(i,10)r(j,1001)dp[i][j]=1e9;
			dp[0][0]=0;
			vector<P>px=v[1];
			r(i,4)v[i+1]=v[i+2];
			v[5]=px;
			r(i,4)r(j,v[i].size())r(k,v[i+1].size())
				dp[i+1][k]=min(dp[i+1][k],dp[i][j]+dist(v[i][j],v[i+1][k]));
			r(i,v[4].size())pp=min(pp,dp[4][i]+dist(v[6][0],v[4][i]));
			if(pp<ans){
				ans=pp;
				syu=o+1;
			}
		}
		if(ans==1e9)cout<<"NA"<<endl;
		else cout<<syu<<' '<<ans<<endl;
	}
}

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

// void debug(int ans,int k){
// 	cout<<ans<<" "<<k<<endl;
// }


int main(){
	int a,b,c,k;
	int ans=0;
	cin>>a>>b>>c>>k;

	if(a<k){
		k-=a;
		ans+=1*a;
	}
	else{
		ans=1*k;
		goto OUTPUT;
	}

	// debug(ans,k);

	if(b<k){
		k-=b;
	}
	else{
		goto OUTPUT;
	}

	// debug(ans,k);

	ans+=-1*k;

	// debug(ans,k);

	OUTPUT:
	cout<<ans<<endl;


	return 0;
}

Measured memory_bytes: 3576
import math
N, K = map(int, input().split())
A = list(map(int, input().split()))

a = math.ceil(A.index(1)/(K-1))
b = math.ceil((N-a*(K-1))/(K-1))
ans = min(a+b, math.ceil((N-1)/(K-1)))
print (ans)          

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

// @@ !! LIM(f:updMaxMin)
// --> f:updMaxMin
// ---- inserted function updMaxMin from util.cc
template<typename T>
bool updMax(T& tmax, const T& x) {
  if (x > tmax) { tmax = x; return true;  }
  else          {           return false; }
}
template<typename T>
bool updMin(T& tmin, const T& x) {
  if (x < tmin) { tmin = x; return true;  }
  else          {           return false; }
}
// ---- end updMaxMin
// @@ !! LIM  -- end mark --

int main(/* int argc, char *argv[] */) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  ll N, K; cin >> N >> K;
  vector H(N, 0LL);
  for (ll i = 0; i < N; i++) cin >> H[i];
  vector r(H);
  r.push_back(0);
  sort(r.begin(), r.end());
  auto last = unique(r.begin(), r.end());
  r.resize(last - r.begin());
  ll rsz = r.size();
  ll big = 1e15;
  vector cur(rsz, vector(K + 1, big));
  cur[0][0] = 0;
  for (ll i = 0; i < N; i++) {
    vector nxt(rsz, vector(K + 1, big));
    ll j0 = lower_bound(r.begin(), r.end(), H[i]) - r.begin();
    for (ll j = 0; j < rsz; j++) {
      for (ll k = 0; k <= K; k++) {
	ll w = max(H[i] - r[j], 0LL);
	updMin(nxt[j0][k], cur[j][k] + w);
	if (k + 1 <= K) updMin(nxt[j][k + 1], cur[j][k]);
      }
    }
    cur = move(nxt);
  }
  ll ans = big;
  for (ll j = 0; j < rsz; j++) {
    for (ll k = 0; k <= K; k++) updMin(ans, cur[j][k]);
  }
  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 4688
<?php
//error_reporting(0);
//$N = trim(fgets(STDIN));
list($A,$B,$C,$D) =  explode(" ",trim(fgets(STDIN)));
//$a =  explode(" ",trim(fgets(STDIN)));

//総数
$A-=1;
$diff = $B - $A;

$bcw   = intdiv_compat($B , $C);
$bdw   = intdiv_compat($B , $D);

$acw   = intdiv_compat($A , $C);
$adw   = intdiv_compat($A , $D);

$g = lcm($C,$D);
if ($g > 0) {
$gbw   = intdiv_compat($B , $g);
$gaw   = intdiv_compat($A , $g);
printf("%d\n",$diff - ($bcw-$acw) - ($bdw-$adw) + ($gbw-$gaw));
}
else {
printf("%d\n",$diff - ($bcw-$acw) - ($bdw-$adw));
}

//printf("%d %d %d %d %d %d %d\n",$diff,$bcw,$bdw,$acw,$adw,$gbw,$gaw);


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

function lcm($a,$b) {
  $l = gcd($a,$b);
  return $a / $l * $b;
}

        function intdiv_compat($dividend, $divisor)
        {
            $dividend = (int) $dividend;
            $divisor = (int) $divisor;
            if ($divisor === 0) {
                throw new DivisionByZeroError('Division by zero');
            }
            if ($divisor === -1 && $dividend === PHP_INT_MIN) {
                throw new ArithmeticError('Division of PHP_INT_MIN by -1 is not an integer');
            }
            $dividend = ($dividend - $dividend % $divisor);
            return ((int) ($dividend / $divisor));
        }


Measured memory_bytes: 4604
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define sz(x) ll(x.size())
using namespace std;

int main(){
  ll n,m,cnt=0,sum=0;
  cin>>n>>m;
  ll a[n];
  rep(i,n){
  	 cin>> a[i];
  	 sum+=a[i];
  }
  rep(i,n) if(4*m*a[i]>=sum) cnt++;
  if(cnt>=m) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

//#define LOCAL 0
//#ifdef LOCAL
//#define DEBUG(s) cout << (s) << endl
//#define dump(x)  cerr << #x << " = " << (x) << endl
//#define BR cout << endl;
//#else
//#define DEBUG(s) do{}while(0)
//#define dump(x) do{}while(0)
//#define BR
//#endif


//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30)
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007
//ここから編集する


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

    int N,A,B;
    cin >> N >> A >> B;
    if((A-B) % 2){
        cout << "Borys" << endl;
    }else{
        cout << "Alice" << endl;
    }


    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <set>
#include <queue>
#include <deque>
#include <map>
#include <stack>
#include <cmath>
using namespace std;

#define mod 1000000007
#define ten5 100005
#define ten52 200005
#define ten6 1000005
#define PI 3.1415926
#define pb(x) push_back(x)
#define all(x) x.begin(),x.end()
#define mkpr(x1,x2) make_pair(x1,x2)
typedef long long int ll;


//stack<char> stk;
//set<ll> sll;
//set<pair<ll,ll>> spll;
//map<string,ll> mp;
//map<pair<ll,ll>,ll>::iterator iter;
//map<ll,ll> mp;
//deque<ll> deq;
//vector<ll> vll;
ll num[ten5],pp[ten52],mm[ten52];
//priority_queue<ll> pq;          //decreasing

int main(void)
{
    //ll m,n,i,j,k=0,pre,money=1000;
    double m,n,i,j,k=0,pre=0;
    cin>>n>>m;
    for(i=0;i<n;i++)
    {
        cin>>j>>k;
        if(m*m>=(j*j+k*k)) pre++;
    }
    cout<<pre;

    return 0;
}





Measured memory_bytes: 3784
#include<stdio.h>
int main(void){
  int i,j,l,tmp,A=0,B=0;
  scanf("%d",&l);
  int card[l];
  for(i=0;i<l;i++){
    scanf("%d",&card[i]);
  }
  for(i=0;i<l;i++){
    for(j=i+1;j<l;j++){
      if(card[i]<card[j]){
        tmp=card[i];
        card[i]=card[j];
        card[j]=tmp;
      }
    }
  }
  for(i=0;i<l;i++){
    if(i%2==0){
      A+=card[i];
    }else{
      B+=card[i];
    }
  }
  printf("%d",A-B);
  return 0;
}
  
      


Measured memory_bytes: 128
package main

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

func main() {
	sc.Split(bufio.ScanWords)
	a := nextInts(3)
	sort.Sort(sort.IntSlice(a))
	puts(a[2]*10 + a[1] + a[0])
	wt.Flush()
}

var (
	sc  = bufio.NewScanner(os.Stdin)
	rdr = bufio.NewReaderSize(os.Stdin, 1000000)
	wt  = bufio.NewWriter(os.Stdout)
)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	i, _ := strconv.Atoi(next())
	return i
}

func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(next(), 64)
	return f
}

func nextInts(n int) []int {
	slice := make([]int, n)
	for i := 0; i < n; i++ {
		slice[i] = nextInt()
	}
	return slice
}

func nextFloat64s(n int) []float64 {
	slice := make([]float64, n)
	for i := 0; i < n; i++ {
		slice[i] = nextFloat64()
	}
	return slice
}

func nextMega() string {
	buf := make([]byte, 0, 1000000)
	for {
		l, p, _ := rdr.ReadLine()
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}

func putf(format string, a ...interface{}) {
	fmt.Fprintf(wt, format, a...)
}

func puts(a ...interface{}) {
	fmt.Fprintln(wt, a...)
}


Measured memory_bytes: 640
#include <stdio.h>
#define D_SIZE_BUFF 200000

int main()
{
    long N,K,Q;
    long sekikai_sya_num;
    long tokuten[D_SIZE_BUFF];  // seikai shita kazu

    scanf("%ld %ld %ld",&N,&K,&Q);

    // QUIZ start !!
    for(long i=0;i<Q;i++)
    {
        scanf("%ld",&sekikai_sya_num);
        tokuten[sekikai_sya_num-1]++;
    }

    // kekka happyo~
    for(long i=0;i<N;i++)
    {
        // zenbu de Qkai nanode, Q-tokuten ten genten suru
        // 0 ten ika ha make
        long kekka = K - (Q-tokuten[i]);
        if(kekka < 1) printf("No");
        else printf("Yes");

        if(i<N-1) printf("\n");
    }

    return 0;
}

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


void solve(long long A, long long B, long long M, std::vector<long long> a, std::vector<long long> b, std::vector<long long> x, std::vector<long long> y, std::vector<long long> c){
    long long ans = INT_MAX;
    for(int i=0;i<M;++i)
        ans = min(ans,a[x[i]-1]+b[y[i]-1]-c[i]);
    sort(a.begin(),a.end());
    sort(b.begin(),b.end());
    ans = min(ans,a[0]+b[0]);
    cout<<ans<<endl;
}

int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    long long M;
    scanf("%lld",&M);
    std::vector<long long> a(A);
    for(int i = 0 ; i < A ; i++){
        scanf("%lld",&a[i]);
    }
    std::vector<long long> b(B);
    for(int i = 0 ; i < B ; i++){
        scanf("%lld",&b[i]);
    }
    std::vector<long long> x(M);
    std::vector<long long> y(M);
    std::vector<long long> c(M);
    for(int i = 0 ; i < M ; i++){
        scanf("%lld",&x[i]);
        scanf("%lld",&y[i]);
        scanf("%lld",&c[i]);
    }
    solve(A, B, M, std::move(a), std::move(b), std::move(x), std::move(y), std::move(c));
    return 0;
}


Measured memory_bytes: 4224
/*
tarun360
IIT Indore
*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ll_s long
#define mod 1000000007
#define forn(i,start,lim) for(ll i=start;i<lim;i++)
#define forn_d(i,start,lim) for(ll i=start;i>=lim;i--)
#define forn_s(i,start,lim) for(ll_s i=start;i<lim;i++)
#define forn_d_s(i,start,lim) for(ll_s i=start;i>=lim;i--)
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define debug1(a) cout<<a<<endl
#define debug2(a,b) cout<<a<<" "<<b<<endl
#define debug3(a,b,c) cout<<a<<" "<<b<<" "<<c<<endl
#define debug4(a) cout<<"chu "<<a<<endl

ll w[105],v[105],dp[105][100005];

int main()
{
  ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
  ll n,W;
  cin>>n>>W;
  forn(i,1,n+1) cin>>w[i]>>v[i];
  forn(i,1,n+1){
    forn(j,1,W+1){
      if(j-w[i]<0) dp[i][j]=dp[i-1][j];
      else
        dp[i][j]=max(dp[i-1][j],dp[i-1][j-w[i]] + v[i]);
    }
  }
  cout<<dp[n][W]<<endl;
  return 0;
}


Measured memory_bytes: 79360
import numpy as np
import math as m

def main(**kwargs):
    res = -1
    now = 1263

    while now > 0:
        now -= 1
        
        if (int(now * 0.08) == a and int(now * 0.1) == b):
            res = now

    return res

if __name__ == "__main__":
    cin = np.array(input().split(" ")).astype("int")
    a, b, *_ = cin

    cout = main(a=a, b=b)
    print(cout)

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

using namespace std;
using ll = long long;

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

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define debug(x) cout << #x << ": " << x << endl;
#define popcnt __builtin_popcount


int main() {
    int n, m;
    cin >> n >> m;
    vector<int> a(n), b(n), c(m), d(m);
    for(int i = 0; i < n; i++)
    {
        cin >> a[i] >> b[i];
    }
    for(int i = 0; i < m; i++)
    {
        cin >> c[i] >> d[i];
    }
    
    for(int i = 0; i < n; i++)
    {
        int dis = (int)1e9, res=-1;
        pair<int, int> student;
        student.first = a[i], student.second = b[i];
        for(int j = 0; j < m; j++)
        {
            if(dis>abs(student.first-c[j])+abs(student.second-d[j])){
                dis = abs(student.first - c[j]) + abs(student.second - d[j]);
                res = j + 1;
            }
        }
        cout << res << endl;
    }
    


    return 0;
}

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

using namespace std;
#define MOD 1000000007
#define pi 3.1415926535897932384626433832795028841971693993751058209749445923078164062
#define ll long long
#define pb push_back
#define pf push_front
#define mp make_pair
#define mt make_tuple
#define ub upper_bound
#define lb lower_bound
#define popb pop_back()
#define popf pop_front()
#define ff first
#define ss second
#define vl vector<ll>
#define vi vector<int>
#define vs vector<string>
#define vll vector< pair<ll,ll> >
#define vii vector< pair<int,int> >
#define viii vector< tuple <int,int,int> >
#define vlll vector< tuple <ll,ll,ll> >
#define vvl vector<vector<ll>>
#define vv vector<vector<int>>
#define all(v) v.begin(),v.end()
#define sqrt sqrtl
#define cbrt cbrtl
#define pll pair<ll,ll>
#define pii pair<int,int>
#define mapcl map<char,ll>
#define mapci map<char,int>
#define mapll map<ll,ll>
#define mapii map<int,int>
#define seti set<int>
ifstream fin("input.txt");
ofstream fout("output.txt");
#define FOR(i, l, r) for (int i = int(l); i < int(r); ++i)
#define print(a)       for(auto x : a) cout << x << " "; cout << "\n"
#define print1(a)      for(auto x : a) cout << x.ff << " " << x.ss << "\n"
#define print2(a,x,y)  for(int i = x; i < y; i++) cout<< a[i]<< " "; cout << "\n"

ll fast_exp(ll base, ll exp) {ll res=1;while(exp>0) {if(exp%2==1) res=(res*base)%MOD;base=(base*base)%MOD;exp/=2;}return res%MOD;}
int gcd(int a,int b){while (a&&b)a>b?a%=b:b%=a;return a+b;}
int val(char c){if (c >= '0' && c <= '9')return (int)c - '0';else return (int)c - 'A' + 10;}
ll pows(int a , int b){ll res=1;for(int i=0; i<b; ++i){res*=a;}return res;}
ll logx(ll base, ll num){int cnt=0;while(num!=1){num/=base; ++cnt;}return cnt;}
ll divisibles(ll a, ll b, ll m){if(a%m==0)return (b/m)-(a/m)+1;else return (b/m)-(a/m);}// in [a,b]
string bitstring(int n, int size){string s;while(n){s+=(n%2)+'0';n/=2;}while(s.size()<size){s+='0';}reverse(all(s));return s;}
// dsu start

vi root(200001,0);
vi size(200001,1);
int find(int x){while(x!=root[x])x = root[x];return x;}
bool same(int a,int b){return find(a)==find(b);}
void unite(int a, int b){a = find(a);b = find(b);if(size[a]<size[b])swap(a,b);size[a] += size[b];root[b] = a;}

// dsu end
vi vis(200001,0);
vi adj[200001];

int main()
{	
    std::ios::sync_with_stdio(false);
    //string bitstring = std::bitset< 3 >( 7 ).to_string(); <bits> (num)
    //srand(time(0));
    //cin.tie(NULL);
    //cout.tie(NULL);
    int k,s;
    cin>>k>>s;
    int cnt = 0;
    for(int i=0 ;i<=k; ++i)
    	for(int j=0 ;j<=k; ++j)
    	{
    		if(s-(i+j)<=k && s-(i+j)>=0)
    		{
    			//cout<<i<<" "<<j<<" "<<(s-(i+j))<<"\n";
    			++cnt;
    		}
    	}

    cout<<cnt<<"\n";
    	
    		

 	  
}

Measured memory_bytes: 7424
N = int(input())

counter = [0] * (N + 1)

for i in range(2, N + 1):
    cur = i
    for j in range(2, i + 1):
        while cur % j == 0:
            counter[j] += 1
            cur //= j

def num(n):
    return len([m for m in range(2, N + 1) if counter[m] >= n - 1])

print(num(75) + num(25) * (num(3) - 1) + num(15) * (num(5) - 1) +
        num(5) * (num(5) - 1) * (num(3) - 2) // 2)

Measured memory_bytes: 3064
// Package main provides
//
// File:  c.go
// Author: ymiyamoto
//
// Created on Wed Jan  9 09:22:05 2019
//
package main

import (
	"fmt"
	"sort"
)

func main() {
	var N int
	fmt.Scan(&N)
	arr := make([]int, N)
	for i := 0; i < N; i++ {
		fmt.Scan(&arr[i])
	}
	sort.Ints(arr)

	a, b := 0, 0
	index := 0
	for i := len(arr) - 1; i >= 0; i-- {
		if i > 0 && arr[i] == arr[i-1] {
			a = arr[i]
			index = i - 2
			break
		}
	}

	for i := index; i >= 0; i-- {
		if i > 0 && arr[i] == arr[i-1] {
			b = arr[i]
			break
		}
	}

	fmt.Println(a * b)
}


Measured memory_bytes: 5504
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); i++)
int main(void)
{
    int n, m, sum;
    cin >> n >> m;
    vector<vector<int> > A(n, vector<int>(m));
    vector<int> b(m);
    rep(i, n)
    {
        rep(j, m)
        {
            cin >> A.at(i).at(j);
        }
    }
    rep(i, m)
    {
        cin >> b.at(i);
    }
    
    rep(i ,n)
    {
        sum = 0;
        rep(j, m)
        {
            sum += A.at(i).at(j) * b.at(j);
        }
        cout << sum << endl;
    }
}



Measured memory_bytes: 3200
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#define ll long long
using namespace std;
int read()
{
	char ch=getchar();int f=0,x=1;
	while(ch<'0'||ch>'9'){if(ch=='-') x=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){f=(f<<1)+(f<<3)+ch-'0';ch=getchar();}
	return f*x;
}
const int mod=1000000007;
ll c[2005][2005],n,k;
int main()
{
	n=read(),k=read();
	for(int i=0;i<=n;i++)
	{
		c[i][0]=1;
		for(int j=1;j<=i;j++)
		{
			c[i][j]=(c[i-1][j-1]+c[i-1][j])%mod;
		}
	}
	for(int i=1;i<=k;i++)
	{
		printf("%lld\n",1LL*c[n-k+1][i]*c[k-1][i-1]%mod);
	}
}


Measured memory_bytes: 30080
n=int(input())
s=[]
s.append(2)
s.append(1)
if n==1:
    print('1')
    exit()
else:
    for i in range(2,87):
        k = s[i-2]+s[i-1]
        s.append(k)
        if i==n:
            print(s[i])
            exit()


Measured memory_bytes: 9172
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <bitset>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <utility>
#include <set>
#include <map>
#include <tuple> 
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <list>
using namespace  std;
using ll = long long;
using P = pair<ll, ll>;
#define REP(i, n) for(long long (i)=0, i_bound = (long long)(n); (i)<i_bound; ++i)
#define FOR(i, a, b) for(long long (i)=(a); (i)<(b); ++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
const long long MOD = static_cast<long long>(1e9) + 7LL;
const long long INF = 1234567891234567890LL;

ll gcd(ll a, ll b) {
    if(b==0) return a;
    while(b){
        ll tmp = a;
        a = b;
        b = tmp%b;
    }
    return a;
}
int main(){
    cin.tie(0);
    cout.sync_with_stdio(false);
    ll N;
    cin >> N;
    vector<ll> A(N);
    REP(i, N) cin >> A[i];
    ll cd = A[0];
    ll cm = A[0];
    for(int i=0; i<N; i++){
        cd = gcd(cm, A[i]);
        cm = (cm/cd) * A[i];
    }
    cout << cm << endl;
    return 0;
}

Measured memory_bytes: 256
#include<ios>
int w[4444][4444],n,k,i,j,x,y,ans,now;char c;
#define g(u,v)w[u+k][v+k]-w[u][v+k]-w[u+k][v]+w[u][v]
main(){
	scanf("%d%d",&n,&k);
	for(i=0;i<n;i++){
		scanf("%d%d %c",&x,&y,&c);
		if(c=='B')x+=k;
		x%=2*k,y%=2*k;
		w[x+1+k][y+1+k]++;
	}
	for(i=1;i<=4*k;i++)for(j=1;j<=4*k;j++)w[i][j]+=w[i-1][j]+w[i][j-1]-w[i-1][j-1];
	for(i=0;i<k;i++)for(j=0;j<k;j++){
		now=g(i+k,j+2*k)+g(i+2*k,j+k)+g(i,j+k)+g(i+k,j);
		if(ans<now)ans=now;
		now=g(i+2*k,j+2*k)+g(i,j+2*k)+g(i+k,j+k)+g(i+2*k,j)+g(i,j);
		if(ans<now)ans=now;
	}
	printf("%d\n",ans);
}

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

using namespace std;

#define int long long

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    int n, k;
    cin >> n >> k;
    
    int x = n / k;
    int ans = x * x * x;
    
    if (k % 2 == 0) {
        if (n < k / 2) x = 0;
        else x = (n - k / 2) / k + 1;
        ans += x * x * x;
    }

    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define ll long long
#define pii pair<long long, long long>
using namespace std;

vector<pii> v;
ll a, b, h, suf[100008];
int n, ind, k, ans;

int main(){
    #ifdef DEBUG
       freopen("input.txt", "r", stdin);
    #endif // DEBUG
    cin >> n >> h;
    ans = 1e9 + 5;
    for(int i = 1; i <= n; ++i){
        cin >> a >> b;
        v.pb(mp(b, a));
    }

    sort(v.begin(), v.end());
    suf[(int)v.size()] = 0;
    suf[(int)v.size() - 1] = v[(int)v.size() - 1].X;
    for(int i = (int)v.size() - 2; i >= 0; --i){
        suf[i] = suf[i + 1] + v[i].X;
    }
    for(int i = (int)v.size() - 1; i >= 0; --i){
        if(suf[i] >= h){
            ans = min(ans, n - i);
        }
        ind = lower_bound(v.begin(), v.end(), mp(v[i].Y, 0ll)) - v.begin();
        if(suf[ind] >= h){
            ans = min(ans, n - ind);
            continue;
        }
        if((h - suf[ind]) % v[i].Y == 0){
            k = (h - suf[ind]) / v[i].Y;
        }
        else{
            k = (h - suf[ind]) / v[i].Y + 1;
        }
        ans = min(ans, n - ind + k);
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 2672
S = input()
N = len(S)
ans = [0] * N
i = 0
while i < N:
    if i == N-1:
        ans[N-1] += 1
        break
    count = 1
    while S[i + count] == S[i]:
        count += 1
        if count == N - i:
            break
    if S[i] == 'R':
        ans[i + count - 1] += (count + 1) // 2
        ans[i + count] += count // 2
    else:
        ans[i] += (count + 1) // 2
        ans[i - 1] += count // 2
    i += count
print(*ans)

Measured memory_bytes: 10672
#!/usr/bin/env python3
import sys


def solve(N: int, W: int, w: "List[int]", v: "List[int]"):
    INF = 10**10
    VMAX=10**3*N
    dp=[[INF for j in range(VMAX+1)] for i in range(N+1)]
    dp[0][0] = 0
    for i in range(1,N+1):
        for j in range(VMAX+1):
            if j-v[i-1] >=0:
                dp[i][j] = min(dp[i-1][j],dp[i-1][j-v[i-1]]+w[i-1])
            else:
                dp[i][j] = dp[i-1][j]

    for i in range(VMAX,-1,-1):
        if dp[-1][i] <= W:
            print(i)
            break
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    W = int(next(tokens))  # type: int
    w = [int()] * (N)  # type: "List[int]"
    v = [int()] * (N)  # type: "List[int]"
    for i in range(N):
        w[i] = int(next(tokens))
        v[i] = int(next(tokens))
    solve(N, W, w, v)

if __name__ == '__main__':
    main()


Measured memory_bytes: 171376
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
int INF = 1e9+7;
int mod = 1e9+7;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
signed main() {
    int N;
    cin >> N;
    vector<int>A(N);
    vector<int>B(N);
    vector<int>C(N);
    for(int i = 0; i < N; i++) cin >> A[i];
    for(int i = 0; i < N; i++) cin >> B[i];
    for(int i = 0; i < N; i++) cin >> C[i];
    sort(A.begin(),A.end());
    sort(C.begin(),C.end());
    int ans = 0;
    for(int i = 0; i < N; i++) {
        int cnt = 1;
        int it = lower_bound(A.begin(),A.end(),B[i])-A.begin();
        cnt*=it;
        it = C.end()-upper_bound(C.begin(),C.end(),B[i]);
        cnt*=it;
        ans+=cnt;
    }
    cout << ans << endl;
}


Measured memory_bytes: 5640
#include <iostream>
#include <utility>
#include <vector>
#include <list>
#include <unordered_set>
#include <set>
#include <unordered_map>
#include <map>
#include <stack>
#include <queue>
#include <cassert>
#include <cmath>
#include <algorithm>
#include <stdlib.h>
#include <stdio.h>
#include <fstream>
#include <tuple>

//....................................................................................................................//

using std::cin;
using std::cout;
using std::vector;
using std::list;
using std::unordered_set;
using std::set;
using std::map;
using std::unordered_map;
using std::multimap;
using std::unordered_multimap;
using std::pair;
using std::make_pair;
using std::min;
using std::max;
using std::swap;
using std::stack;
using std::deque;
using std::queue;
using std::ios_base;
using std::ifstream;
using std::ofstream;
using std::string;
using std::tuple;
using std::make_tuple;
using std::get;
using std::upper_bound;
using std::lower_bound;
using std::max_element;
using std::min_element;
using std::multiset;
using std::greater;
using std::priority_queue;
using std::less;

//....................................................................................................................//

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned long ul;

[[maybe_unused]] const string endl = "\n";
[[maybe_unused]] const string sep = " ";
[[maybe_unused]] const string yes = "YES\n";
[[maybe_unused]] const string no = "NO\n";
[[maybe_unused]] const string ng = "NG\n";
[[maybe_unused]] const string ok = "OK\n";
[[maybe_unused]] const double pi = acos(-1);
[[maybe_unused]] const ull modular = 998244353;

//....................................................................................................................//


int main() {
    cin.tie(nullptr);
    cout.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    cout.precision(10);
    string s;
    string t;
    cin >> s >> t;
    if (s.size() == t.size() - 1) {
        bool x = true;
        for (int i = 0; x && i < s.size(); ++i) {
            if (s[i] != t[i]) {
                x = false;
            }

        }
        if (x) {
            cout << "Yes";
        } else {
            cout << "No";
        }
    } else {
        cout << "No";
    }
}


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

int main(void)
{
  int i;
  int m, n;
  char say[10];
  char num[10];
  int mem[1002]; //alive:1
  int current, alive_num;

  while(1){
    scanf("%d %d", &m, &n);
    if(m==0 && n==0) break;

    for(i=1; i<=m; i++){
      mem[i]=1;
    }
    mem[m+1]=0;
    alive_num=m; current=1;
    for(i=1; i<=n; i++){
      scanf("%s", say);
      if(alive_num==1) continue;
      sprintf(num, "%d", i);
      if(i%15==0 && strcmp(say, "FizzBuzz")!=0
	 || i%5!=0 && i%3==0 && strcmp(say, "Fizz")!=0
	 || i%3!=0 && i%5==0 && strcmp(say, "Buzz")!=0
	 || i%3!=0 && i%5!=0 && strcmp(say, num)!=0){
	mem[current]=0;
	alive_num--;
      }
      while(mem[++current]==0){
	if(current>m) current=0;
      }
    }
    current=1;
    while(1){
      if(mem[current]==1){
	printf("%d", current);
	if(--alive_num==0) break;
	printf(" ");
      }
      current++;
    }
    printf("\n");
  }
}

Measured memory_bytes: 632
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<=int(b);++i)
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
int INF=numeric_limits<int>::max();
// for(int j=0;j<N;++j) {
int main(void) {
  int n,m;cin>>n>>m;
  ll need_time=0;
  int a;
  rep(i,1,m) {
    cin>>a;
    need_time+=a;
  }
  if(n-need_time>=0) {
    pr(n-need_time);
  } else {
    pr(-1);
  }
  return 0;
}


Measured memory_bytes: 3620
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#define rep(i, a, b) for(int i = a; i < (b); ++i)
using namespace std;
typedef long long ll;

vector<pair<int, int>> to[100010];
bool visited[100010];
ll dist[100010];
ll gcd(ll a, ll b)
{
   if (b == 0)
   {
       return a;
   }
    return gcd(b, a%b);
}
void dfs(int now, ll d) {
  visited[now] = true;
  dist[now] = d;
  for (auto p : to[now]) {
    if (visited[p.first]) continue;
    dfs(p.first, d + p.second);
  }
}

int main() {
    int l,r,d;
    string s;
    cin>>l>>r>>d;
    
    ll ans=0;
    for(int i = l; i<=r ;i++){
        if(i%d == 0) ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 5936
<?php
fscanf(STDIN, "%d", $N);
$A = array_map('intval', explode(' ', trim(fgets(STDIN))));
rsort($A);
$ans = array_sum(array_slice($A, 0, intdiv($N + 1, 2))) * 2;
$ans -= $A[0];
if ($N % 2 === 1) $ans -= $A[intdiv($N - 1, 2)];
printf("%d", $ans);


Measured memory_bytes: 38108
//Mahir Ratanpara (DA-IICT)
#include<bits/stdc++.h>
using namespace std;
#define Ff(i,a,n) for(i=a;i<n;i++)
#define Fr(i,a,n) for(i=a;i>n;i--)
#define ll long long
#define FAST ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
typedef pair<ll, ll>	pa;
typedef vector<ll>		vc;
typedef vector<pa>		vp;
typedef vector<vc>		vvc;
int mpow(int base, int exp); 
void ipgraph(ll n,ll m);
void dfs(int u, int par);
const int mod = 1000000007;
const int N = 3e5, M = N;
//=======================

vc g[N];

int main() {
    FAST;
    ll t, i, j, k, p, q, r, x, y, u, v, n, m;
    cin>>x;
	ll curr=100;
	ll years=0;
	while(curr<x)
	{
		curr+=curr*(1)/100;
		years++;
	}
	cout<<years;
    return 0;
}

int mpow(int base, int exp) {
  base %= mod;
  int result = 1;
  while (exp > 0) {
    if (exp & 1) result = ((ll)result * base) % mod;
    base = ((ll)base * base) % mod;
    exp >>= 1;
  }
  return result;
}

void ipgraph(ll n, ll m){
	int i, u, v;
	while(m--){
		cin>>u>>v;
		g[u-1].pb(v-1);
		g[v-1].pb(u-1);
	}
}

void dfs(int u, int par){
	for(int v:g[u]){
		if (v == par) continue;
		dfs(v, u);
	}
}

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

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

    int ans = 0;
    for (int i = 0; i < n; i++) {
        if (i == 0) {
            ans += B[0];
        }
        else if (i == n - 1) {
            ans += B[n - 2];
        }
        else {
            ans += min(B[i - 1], B[i]);
        }
    }

    cout << ans << endl;

    return 0;
}


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

int read() {
    int x = 0, f = 1;
    char c = getchar();
    while (c < '0' || c > '9') {
        if (c == '-') f = -1;
        c = getchar();
    }
    while (c >= '0' && c <= '9') {
        x = x * 10 + c - '0';
        c = getchar();
    }
    return x * f;
}

long long a[200005], b[200005];
long long c[200005];
int cnt;

int main() {
    int n = read();
    long long sum = 0, tmp = 0;
    int res = 0;
    for (int i = 1; i <= n; ++i) {
        a[i] = read();
        sum += a[i];
    }
    for (int i = 1; i <= n; ++i) {
        b[i] = read();
        sum -= b[i];
        if (b[i] > a[i]) {
            tmp += b[i] - a[i];
            res++;
        }
        else c[++cnt] = a[i] - b[i];
    }
    if (sum < 0) {
        puts("-1");
        return 0;
    }
    sort(c + 1, c + 1 + cnt);
    for (int i = cnt; i >= 1; --i) {
        if (tmp <= 0) break;
        res++;
        tmp -= c[i];
    }
    printf("%d\n", res);
    return 0;
}

Measured memory_bytes: 3456
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AOJ
{
	class Program
	{
		static void Main(string[] args)
		{
			var s = "";
			while((s=Console.ReadLine())!=null)
			{
				var e = s.Split(' ');
				var stack = new Stack<double>();
				for(int i=0;i<e.Length;i++)
				{
					if (e[i] == "+")
					{
						var t1 = stack.Pop();
						var t2 = stack.Pop();
						stack.Push(t2 + t1);
					}
					else if (e[i] == "-")
					{
						var t1 = stack.Pop();
						var t2 = stack.Pop();
						stack.Push(t2 - t1);
					}
					else if (e[i] == "/")
					{
						var t1 = stack.Pop();
						var t2 = stack.Pop();
						stack.Push(t2 / t1);
					}
					else if (e[i] == "*")
					{
						var t1 = stack.Pop();
						var t2 = stack.Pop();
						stack.Push(t2 * t1);
					}
					else
					{
						stack.Push(double.Parse(e[i]));
					}
				}
				Console.WriteLine(stack.Pop());
			}
		}
	}
}

Measured memory_bytes: 6052
import java.util.*;
import java.util.stream.IntStream;

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

        Map<Integer,Integer> map = new HashMap<>();
        IntStream intStream = IntStream.range(0, N).map(i ->{
            return sc.nextInt();
        });

        intStream.forEach(i -> {
                  Integer v = map.getOrDefault(i, 0);
                  map.put(i,v+1);
        });

        long result = map.entrySet().stream().filter(entry -> {
            if(1 == entry.getValue() % 2){
                return true;
            }else {return false;}
        }).count();

        System.out.print(result);
    }
}

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

int main() {
  int N;
  cin >> N;
  vector<int> C(N - 1), S(N - 1), F(N - 1);
  for (int i = 0; i < N - 1; i++) cin >> C.at(i) >> S.at(i) >> F.at(i);

  for (int i = 0; i < N; i++) {
    int time = 0;
    for (int j = i; j < N - 1; j++) {
      int tmp = S.at(j);
      while (tmp < time) tmp += F.at(j);
      time = max(time, tmp);
      time += C.at(j);
    }
    cout << time << "\n";
  }
}

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

using namespace std;

int main(){
    int n,x;
    int ans=0;
    cin>>n>>x;
    vector<int> hoge(n);
    for(int i=0;i<n;i++){
        cin>>hoge.at(i);
        x-=hoge.at(i);
        ans++;
    }
    
    sort(hoge.begin(),hoge.end());
    ans+=x/hoge.at(0);
    
    cout<<ans<<endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
    double a,b,c,d,e,f,x,y;
    while (scanf("%lf %lf %lf %lf %lf %lf",&a,&b,&c,&d,&e,&f) != EOF) {
     y=((c*d)-(a*f)) / ((b*d)-(a*e));
     x=(c-(b*y)) / a;
     
     printf("%.3f %.3f\n",x,y);

    }
    return 0;
}


Measured memory_bytes: 1928
#![allow(unused_imports, unused_macros, dead_code)]

macro_rules! min {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| min!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = min!($($ys),*);
        if $x < t { $x } else { t }
    }}
}
macro_rules! max {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| max!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = max!($($ys),*);
        if $x > t { $x } else { t }
    }}
}
macro_rules! ewriteln {
    ($($args:expr),*) => { let _ = writeln!(&mut std::io::stderr(), $($args),*); };
}
macro_rules! trace {
    ($x:expr) => { ewriteln!(">>> {} = {:?}", stringify!($x), $x) };
    ($($xs:expr),*) => { trace!(($($xs),*)) }
}
macro_rules! put {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        if let Some(x) = it.next() { print!("{}", x); }
        for x in it { print!(" {}", x); }
        println!("");
    }};
    ($x:expr) => { println!("{}", $x) };
    ($x:expr, $($xs:expr),*) => { print!("{} ", $x); put!($($xs),*) }
}

const M: i64 = 1_000_000_007;

fn main() {
    let mut sc = Scanner::new();
    let x: i64 = sc.cin();
    for a in 0..10000i64 {
        for b in -10000..10000i64 {
            if a.pow(5) - b.pow(5) == x {
                put!(a, b);
                return;
            }}}
}

use std::io::{self, Write};
use std::str::FromStr;
use std::collections::VecDeque;

struct Scanner { stdin: io::Stdin, buffer: VecDeque<String>, }
impl Scanner {
    fn new() -> Self { Scanner { stdin: io::stdin(), buffer: VecDeque::new() } }
    fn cin<T: FromStr>(&mut self) -> T {
        while self.buffer.len() == 0 {
            let mut line = String::new();
            let _ = self.stdin.read_line(&mut line);
            for w in line.split_whitespace() {
                self.buffer.push_back(String::from(w));
            }
        }
        self.buffer.pop_front().unwrap().parse::<T>().ok().unwrap()
    }
    fn chars(&mut self) -> Vec<char> { self.cin::<String>().chars().collect() }
    fn vec<T: FromStr>(&mut self, n: usize) -> Vec<T> { (0..n).map(|_| self.cin()).collect() }
}


Measured memory_bytes: 2136
require 'prime'

N = gets.to_i
factors = {}
for i in 2..N
    ifacts = i.prime_division
    ifacts.each do |fac|
        if !(factors.has_key?(fac.first))
            factors.store( fac.first, fac.last )
        else
            factors[fac.first] += fac.last
        end
    end
end

# p factors

cnt = 1
factors.each_value do |exp|
    cnt *= exp + 1
end
puts cnt % (10**9 + 7)

Measured memory_bytes: 2300
//
//  main.cpp
//  at
//
//  Created by 黄道煜 on 2018/8/18.
//  Copyright © 2018年 黄道煜. All rights reserved.
//

#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;

int n, m, k, ans[200005], t[200005];

struct A {int l, r, id;} a[200005], b[200005];

bool CMP (A x, A y) {return x.r<y.r;}

void add(int x, int y) {for(; x<=n; x+=(x&-x)) t[x]+=y;}
int sum(int x) {int y=0; for(; x; x-=(x&-x)) y+=t[x]; return y;}

int main()
{
    scanf("%d%d%d", &n, &m, &k);
    for(int i=1; i<=m; i++) scanf("%d%d", &a[i].l, &a[i].r);
    for(int i=1; i<=k; i++) scanf("%d%d", &b[i].l, &b[i].r), b[i].id=i;
    sort(a+1, a+m+1, CMP);
    sort(b+1, b+k+1, CMP);
    for(int i=1, j=1; i<=k; i++)
    {
        while(a[j].r<=b[i].r && j<=m)
        {
            add(a[j].l, 1);
            j++;
        }
        
        ans[b[i].id]=sum(b[i].r)-sum(b[i].l-1);
    }
    for(int i=1; i<=k; i++) printf("%d\n", ans[i]);
}


Measured memory_bytes: 6144
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <numeric>
#include <map>
#include <utility>
using namespace std;
#define ll long long
#define rep(i,l,r) for(ll i=(l);i<(r);i++)
string s,t;
int size,tsize;
int canrep(int start){
    rep(i,0,tsize){
        if(s[i+start]=='?'||s[i+start]==t[i]);
        else return 0;
    }
    return 1;
}
int main(void){
    cin>>s>>t;
    size=s.size();
    tsize=t.size();
    for(int i=size-tsize;i+1;i--){
        if(canrep(i)){
            s.replace(i,tsize,t);
            replace(s.begin(),s.end(),'?','a');
            cout<<s<<endl;
            return 0;
        }
    }
    cout<<"UNRESTORABLE"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define UM unordered_map
#define ALL(a) (a).begin(), (a).end()
typedef vector<ll> vi;
typedef vector<vector<ll>> vvi;
typedef pair<ll, ll> pii;
const ll INF = 1LL << 58;
const ll MOD = 1000000007;
struct Edge
{
    ll s, t, d;
};
typedef vector<vector<Edge>> Graph;
typedef vector<pii> vpii;
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;
}

signed main()
{
    int N, M, Q;
    cin >> N >> M >> Q;
    int A[510][510] = {0};
    int l, r;
    REP(i, M)
    {
        cin >> l >> r;
        A[l][r]++;
    }
    int tmp;
    REP(i, N + 1)
    {
        tmp = 0;
        REP(j, N + 1)
        {
            tmp += A[i][j];
            A[i][j] = tmp;
        }
    }

    vi ans;
    REP(i, Q)
    {
        cin >> l >> r;
        tmp = 0;
        FOR(j, l, r + 1)
        {
            tmp += A[j][r] - A[j][l - 1];
        }
        ans.push_back(tmp);
    }

    REP(i, Q)
    cout << ans[i] << endl;

    // system("pause");
}

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

int main()
{
	int h, w;

	while (true)
	{
		cin >> h >> w;
		if ((h == 0) && (w == 0))break;

		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				cout << (((i + j) % 2 == 0) ? "#" : ".");
			}
			cout << endl;
		}
		cout << endl;
	}

	return 0;
}


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

#define lint long long
#define P pair<int, int>
#define LLP pair<long long, long long>
#define REP(i, x, n) for(int i = (x), i##_len = (int)(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = (int)(n) ; i < i##_len ; ++i)
#define reps(i, n) for(int i = 1, i##_len = (int)(n) ; i <= i##_len ; ++i)
#define rrep(i, n) for(int i = (int)(n) - 1 ; i >= 0 ; --i)
#define rreps(i, n) for(int i = (int)(n) ; i > 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())

const int IINF = (1 << 30) - 1;
const long long LLINF = 1LL << 61;
const long long MOD = 1000000007LL;
const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};
const double EPS = 1e-8;

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

    int n;
    cin >> n;

    int ans = sqrt(n);
    ans *= ans;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#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, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

vll dx = {1, 0, -1, 0};
vll dy = {0, 1, 0, -1};

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

    string s;
    cin >> s;
    string p = "", q = "hi";
    REP(i, 5) {
        p += q;
        if (s == p) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

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

#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_CAT_I(x,y) x ## y
//#define CPP_STR(x) CPP_STR_I(x)
//#define CPP_STR_I(args...) #args
//#define ASSERT(expr...) assert((expr))

using i8 = int8_t;
using u8 = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
//using f80 = __float80;

constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
constexpr char EL[] = "\n";

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(),(x).end()
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))
#define UNIQUE(x) (x).erase(unique(all(x)), (x).end());
#define REPIT(x) for(auto it=(x).begin(), end=(x).end(); it!=end; ++it)
#define perm(c) sort(all(c)); for(bool c##p=1;c##p;c##p=next_permutation(all(c)))

template<typename T = i64>
T IN() { T x; cin >> x; return (x); }

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }
template<typename T, size_t N>
i64 SIZE(const T(&)[N]) { return static_cast<i64>(N); }

template<typename T, typename U, typename Comp = less<>>
bool chmax(T& xmax, const U& x, Comp comp = {}) {
	if (comp(xmax, x)) {
		xmax = x;
		return true;
	}
	return false;
}
template<typename T, typename U, typename Comp = less<>>
bool chmin(T& xmin, const U& x, Comp comp = {}) {
	if (comp(x, xmin)) {
		xmin = x;
		return true;
	}
	return false;
}

void print() {
  cout << EL;
}
template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
  cout << head;
  if (sizeof...(tail) != 0) cout << " ";
  print(forward<Tail>(tail)...);
}
template <class T>
void print(vector<T> &vec) {
  for (auto& a : vec) {
	cout << a;
	if (&a != &vec.back()) cout << " ";
  }
  cout << EL;
}
template <class T>
void print(vector<vector<T>> &df) {
  for (auto& vec : df) {
	print(vec);
  }
}

struct ProconInit {
	static constexpr int IOS_PREC = 15;
	static constexpr bool AUTOFLUSH = false;

	ProconInit() {
		cin.tie(nullptr);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(IOS_PREC);
		if (AUTOFLUSH)
			cout << unitbuf;
	}
} PROCON_INIT;
#pragma endregion

signed solve()
{
	i64 n;
	cin >> n;
	map<i64, i64> a;
	REP(i, n)
	{
		i64 v;
		cin >> v;
		a[v]++;
	}

	if (n % 2 == 0)
	{
		if (a.count(0) > 0)
		{
			print(0);
			return 0;
		}
	}
	else
	{
		if (a.count(0) == 0 || a[0] != 1)
		{
			print(0);
			return 0;
		}
	}

	i64 ans = 1;
	REPIT(a)
	{
		if ((*it).first == 0) continue;
		if ((*it).second != 2)
		{
			print(0);
			return 0;
		}
		ans *= 2;
		ans %= MOD;
	}

	print(ans);
	return 0;
}

#ifndef LOCALCODE
signed main()
{
	return solve();
}
#endif


Measured memory_bytes: 4224
#include <cstdio>
#include <algorithm>
using namespace std;
bool comp(const int& a, const int& b) {
    return a>b;
}
int n, m;
int p[1000];
int main() {
    while (scanf("%d%d",&n,&m)) {
        if (!n&&!m) break;
        for (int i=0; i<n; i++) {
            scanf("%d",&p[i]);
        }
        sort(p,p+n,comp);
        for (int i=m-1; i<n; i+=m) {
            p[i]=0;
        }
        int res=0;
        for (int i=0; i<n; i++) {
            res+=p[i];
        }
        printf("%d\n",res);
    }
}

Measured memory_bytes: 0
#include <iostream>

int main(){
  
 char b;
  
  std::cin >> b;
  
  if(b=='A') std::cout << 'T'<<std::endl;
  if(b=='T') std::cout << 'A'<<std::endl;
  if(b=='C') std::cout << 'G'<<std::endl;
  if(b=='G') std::cout << 'C'<<std::endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <ios>
#include <iomanip>
#include <stack>
#include <queue>
#include <algorithm>

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

using namespace std;

const int INF = 100000000;

int n,A,B,C;
vector<int> take;
int ans = INF;

void dfs(int a,int b,int c,int count,int mp){
  if (count == n) {
    if (a * b * c == 0) {
      return;
    }
    ans = min(ans,mp +  abs(a - A) + abs(b - B) + abs(c - C));
    return;
  }

  dfs(a,b,c,count + 1,mp);
  dfs(a + take[count],b,c,count + 1,a == 0 ? mp : mp +10);
  dfs(a,b + take[count],c,count + 1,b == 0 ? mp : mp +10);
  dfs(a,b,c + take[count],count + 1,c == 0 ? mp : mp +10);
}

int main(){
  cin >> n >> A >> B >> C;

  take = vector<int>(n);

  REP(i,n){
    int l;
    cin >> l;
    take[i] = l;
  }


  dfs(0,0,0,0,0);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 384