akhauriyash/Code-Regression huggingface dataset:
package main

import (
	"bufio"
	"fmt"
	"io"
	"math"
	"os"
	"strconv"
	"strings"

)


func main() {
	solve(os.Stdin, os.Stdout)
}

type ReaderEx struct {
	baseScanner *bufio.Scanner
	words       []string
	nextWordIdx func() int
	initWordIdx func(int)
}

func NewScannerEx(stdin io.Reader) *ReaderEx {
	var this ReaderEx
	var idx int
	var wordsCnt int
	this.baseScanner = bufio.NewScanner(stdin)
	this.baseScanner.Buffer(make([]byte, 0), 1E+11)
	this.nextWordIdx = func() int {
		cur := idx
		idx = (idx + 1) % wordsCnt
		return cur
	}
	this.initWordIdx = func(wc int) {
		idx = 0
		wordsCnt = wc
	}
	return &this
}

func (me *ReaderEx) Scan(doSplit bool) (isScanned bool) {
	isScanned = me.baseScanner.Scan()
	if doSplit {
		me.words = strings.Fields(me.baseScanner.Text())
	} else {
		me.words = []string{me.baseScanner.Text()}
	}
	me.initWordIdx(len(me.words))
	return
}

func (me *ReaderEx) nextBytes() []byte {
	return []byte(me.words[me.nextWordIdx()])
}
func (me *ReaderEx) nextString() string {
	return me.words[me.nextWordIdx()]
}

type StringArray []string

func (me *ReaderEx) nextStringArray() StringArray {
	return me.words[me.nextWordIdx():]
}

func (me StringArray) toStrings() []string {
	return me
}

func (me StringArray) toInts() []int {
	strValues := me.toStrings()
	values := make([]int, len(strValues))
	for i, v := range strValues {
		n, err := strconv.Atoi(v)
		if err != nil {
			panic(err)
		}
		values[i] = n
	}
	return values
}
func (me *ReaderEx) nextInt() int {
	n, err := strconv.Atoi(me.words[me.nextWordIdx()])

	defer func() {
		if err != nil {
			panic(fmt.Sprintf("getInt(%d)", n))
		}
	}()
	return n
}

func pow(x, y, mod int) (ans int) {

	ans = 1
	for bit := 1 << uint(math.Floor(math.Log2(float64(y)))); ; bit >>= 1 {
		if y&bit != 0 {
			ans *= x
			if mod > 0 {
				ans %= mod
			}
		}
		if bit <= 1 {
			return
		}
		ans *= ans
		if mod > 0 {
			ans %= mod
		}
	}
}

type factType struct {
	prime int
	count int
}

func fact(n int) (facts []*factType) {

	for i := 2; i*i <= n; i++ {
		if n%i == 0 {
			fa := factType{prime: i}
			for n%fa.prime == 0 {
				n /= fa.prime
				fa.count++
			}
			facts = append(facts, &fa)
		}
	}
	if n > 1 {
		facts = append(facts, &factType{prime: n, count: 1})
	}
	return facts
}
func dec2bin(n int) (ret []bool) {
	for bit := 1 << uint(math.Floor(math.Log2(float64(n)))); ; bit >>= 1 {
		ret = append(ret, n&bit != 0)

		if bit <= 1 {
			return
		}
	}

}

func abs(v int) int {
	if v < 0 {
		v = -v
	}
	return v
}

func b2i(b bool) (i int) {
	if b {
		i = 1
	} else {
		i = 0
	}
	return
}

func solve(stdin io.Reader, stdout io.Writer) {

	r := NewScannerEx(stdin)
	r.Scan(true)
	a, b := r.nextInt(), r.nextInt()

	fmt.Fprintln(stdout, int(math.Ceil(float64(b-1)/float64(a-1))))
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define ll long long

const int N = 100010;

int n, a[N], b[N];

int main(){
	scanf("%d", &n);
	for (int i = 0; i < n; ++ i){
		scanf("%d%d", &a[i], &b[i]);
	}
	ll ans = 0;
	for (int i = n - 1; i >= 0; -- i){
		ll now = ans + a[i];
		ans += (b[i] - now % b[i]) % b[i];
		
	}
	return printf("%lld\n", ans), 0;
}

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

#define For(i, j, k) for(int i = j; i <= k; i++)
#define Forr(i, j, k) for(int i = j; i >= k; i--)
#define pb push_back

using namespace std;

const int N = 100010;

typedef long long LL;

LL sg(LL x){
	++x;
	return x & (-x);
}

struct Trie{
	
	int ch[N][2], node;
	
	void insert(char* S, int l){
		int o = 0;
		For(i, 1, l){
			int &c = ch[o][S[i] - '0'];
			if(!c) c = ++node;
			o = c;
		}
	}

	LL calc(int o, LL dep){
		if(!ch[o][0] && !ch[o][1]) return 0;
		LL ret = 0;
		For(i, 0, 1) 
			if(!ch[o][i]) ret ^= sg(dep - 1);
			else ret ^= calc(ch[o][i], dep - 1);
		return ret;
	}

}T;

int n;
LL L;
char S[N];

int main(){
	
	scanf("%d%lld", &n, &L);
	For(i, 1, n){
		scanf("%s", S + 1);
		int l = strlen(S + 1);
		T.insert(S, l);
	}

	puts(!T.calc(0, L) ? "Bob" : "Alice");

	return 0;
}

Measured memory_bytes: 5248
import java.util.*;
import java.lang.*;

import static java.lang.StrictMath.abs;

class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int l = sc.nextInt();
        int y = sc.nextInt();
        int z = sc.nextInt();
        int ans = 0;
        ans  = (l -z)/ (y+z);
        System.out.println(ans);
    }
}



Measured memory_bytes: 23764
#include<stdio.h>
int main(){
  int n,i;
  scanf("%d",&n);
  long long vote[n+1][2];
  for(i=0;i<n;i++)
    scanf("%lld%lld",&vote[i][0],&vote[i][1]);
  long long t=vote[0][0],a=vote[0][1];
  for(i=0;i<n;i++){
    if(t%vote[i][0]!=0){
      t=t/vote[i][0];
      t=vote[i][0]*(t+1);
    }
    if(a%vote[i][1]!=0){
      a=a/vote[i][1];
      a=vote[i][1]*(a+1);
    }
    if(t/vote[i][0]<a/vote[i][1])
      t+=vote[i][0]*(a/vote[i][1]-t/vote[i][0]);
    if(t/vote[i][0]>a/vote[i][1])
      a+=vote[i][1]*(t/vote[i][0]-a/vote[i][1]);
  }
  printf("%lld\n",t+a);
  return 0;
}

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

using namespace std;

int main()
{
    int N,L;
    cin >> N >> L;
    vector<string> S(N);

    for(int i=0; i<N; i++){
        cin >> S.at(i);
    }

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

    string ans;

    for(int i=0; i<N; i++){
        ans += S.at(i);
    }

    cout << ans << endl;
}

Measured memory_bytes: 3616
class Dice():
    
    def __init__(self, labels):
        self.__pip = labels
        
    def get_top(self):
        return self.__pip[0]
        
    def roll_e(self): # 03520
        self.__pip[0], self.__pip[3], self.__pip[5], self.__pip[2] = \
            self.__pip[3], self.__pip[5], self.__pip[2], self.__pip[0]
            
    def roll_n(self): # 01540
        self.__pip[0], self.__pip[1], self.__pip[5], self.__pip[4] = \
            self.__pip[1], self.__pip[5], self.__pip[4], self.__pip[0]
            
    def roll_s(self): # 04510
        self.__pip[0], self.__pip[4], self.__pip[5], self.__pip[1] = \
            self.__pip[4], self.__pip[5], self.__pip[1], self.__pip[0]
    
    def roll_w(self): # 02530
        self.__pip[0], self.__pip[2], self.__pip[5], self.__pip[3] = \
            self.__pip[2], self.__pip[5], self.__pip[3], self.__pip[0]
    
    def roll_dice(self, command):
        if command == 'E':
            self.roll_e()
        elif command == 'N':
            self.roll_n()
        elif command == 'S':
            self.roll_s()
        else:
            self.roll_w()


def main():
    dice = Dice(list(input().split()))
    commands = input()
    for i in commands:
        dice.roll_dice(i)
    print(dice.get_top())
    
    
if __name__ == "__main__":
    main()



Measured memory_bytes: 5572
#include <iostream>

using namespace std;

int main() {
	int M, D;
	cin >> M >> D;
	
	int cnt = 0;
	for(int im = 1; im <= M; ++im) {
		for(int id = 1; id <= D; ++id) {
			int d10 = id / 10;
			int d1  = id % 10;
			if(d1  < 2) { continue; }
			if(d10 < 2) { continue; }
			if(im == d10 * d1) { ++cnt; }
		}
	}
	cout << cnt << endl;
}


Measured memory_bytes: 256
<?php namespace Track;

function main($lines) {
  $sum = 0;
  $ans = [];
  foreach ($lines as $index=>$value) {
    if($value == "0"){
        break;
    }
    for($i=0; $i<strlen($value); $i++){
        $sum += $value[$i];
    }
    $ans[] = $sum;
    $sum = 0;
  }
  echo implode(PHP_EOL, $ans);
}

$array = array();
while (true) {
  $stdin = fgets(STDIN);
  if ($stdin == "") {
    break;
  }
  $array[] = rtrim($stdin);
}
main($array);
echo PHP_EOL;


Measured memory_bytes: 9352
function main(){
  var i = 0;
  while(true){
    var fieldInfo = input[i].split(' ');
    var width = fieldInfo[0] - 0;//toInt
    var height = fieldInfo[1] - 0;//toInt
 
    // 0 0が入力された
    if(!width && !height){
      break;
    }
 
    var start;
    var goal;
    var elem = [[],[],[],[],[]];
    for(var ei = 0;ei < 5; ei++){
      elem[ei].length = 0;
    }
     
    for(var y = 0; y < height; y++){
      i++;//1行進める
      for(var x = 0; x < width; x++){
        var c = input[i][x];
 
        switch(c){
        case 'S':
          start = pos(x, y);
          break;
        case 'G':
          goal = pos(x, y);
          break;
        case '.':
          break;
        default : // 入力値が正しいので、絶対に属性
          elem[c - 1][elem[c - 1].length] = pos(x, y);
          break;
        }
      }
    }
 
     
    var bestElement = -1;
    var distance = Infinity;
     
    // 属性ごとにループ
    for (var startElem = 0; startElem < 5; startElem++) {
      // DPの初期化 DP[属性][同じ属性内の連番]
      var dp = [[],[],[],[],[]];
      for(var h = 0; h < 5; h++){
        var hLength = elem[h].length;
        dp[h].length = hLength;
        for(var hidx = 0; hidx < hLength; hidx++){
          dp[h][hidx] = Infinity;
        }
      }
       
      // 最初に選んだパチモンから次に捕まえられる属性番号
      var first = (startElem + 1) % 5;
 
      var firstLength = elem[first].length;
      for (var j = 0; j < firstLength; j++) {
        // s→e1を計算
        dp[first][j] = dist(start, elem[first][j]);
      }
       
      // s->1->2->3->4->g
      // なので、ループは間の-> * 3分まわす
      for (var e = 0; e < 3; e++) {
        // ex->e(x+1)
        var now = (first + e) % 5;
        var next = (now + 1) % 5;
        var nowLength = elem[now].length;
        var nextLength = elem[next].length;
        for (var j = 0; j < nowLength; j++) {
          for (var k = 0; k < nextLength; k++) {
            dp[next][k] = min(
              dp[next][k],
              dp[now][j] + 
                  dist(elem[now][j], elem[next][k]));
          }
        }
      }
       
      var last = (first + 3) % 5;
      var lastLength = elem[last].length;
      for (var j = 0; j < lastLength; j++) {
        // e4->g
        var d = dp[last][j] + 
                    dist(elem[last][j], goal);
         
        if (d < distance) {
          distance = d;
          bestElement = startElem + 1;
        }
         
      }
       
    }
     
    if (distance == Infinity) {
      console.log("NA");
    } else {
      console.log(bestElement + " " + distance);
    }
 
    i++;
  }
   
 
}
 
function dist(from, to){
  return abs((from >> 11) - (to >> 11)) + abs((from & 2047) - (to & 2047));
}
 
function min(a1, a2){
  var t = (a1 - a2);
  return a2 + (t & (t >> 31));
}
 
function pos(a, b){
  // 2^10 = 1024なので、下位10ビットでy座標を、上位ビットでx座標を表す
  return (a << 11) + b;
}

function abs(a){
 var mask = a >> 31;
 return (a ^ mask) - mask;
}
 
var
input = '';
 
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function(chunk) {
  input += chunk;
});
process.stdin.on('end', function() {
  input = input.split('\n');
  main();
});

Measured memory_bytes: 63672
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;

int main()
{
    int X, A;
    cin >> X >> A;
    cout << (X < A ? 0 : 10) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
 
using namespace std;
 
int main(){
    int n, card[13*4]={0};
 
    cin >> n;
    for (int i = 0; i < n; i++) {
        char s;
        int r;
        cin >> s >> r;
        switch (s) {
            case 'S': card[13*0 + r-1] = 1; break;
            case 'H': card[13*1 + r-1] = 1; break;
            case 'C': card[13*2 + r-1] = 1; break;
            case 'D': card[13*3 + r-1] = 1; break;
        }
    }
 
    for (int i = 0; i < 13*4; i++)
        if (card[i] == 0) {
            if (i < 13*1)      cout << "S ";
            else if (i < 13*2) cout << "H ";
            else if (i < 13*3) cout << "C ";
            else               cout << "D ";
            cout << i%13+1 << endl;
        }
 
    return 0;
}


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll ;
#define fast ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
 const ll inf=1e9+7;
string a,b,c;

ll mod(ll a)
{
	if(a<inf)return a;
	else 
	return a%inf;
}
 void test_cases()
{

ll n;
cin>>n;
 vector<ll>cnt(n+1,0);
while(n>1)
{
	ll x=n;
for(ll i=2;i<=x;i++)
{
	while(x%i==0)
	{
		cnt[i]++;
		x=x/i;
	}
}
	n--;
}

ll ans=1;
for(auto x:cnt)
{	
 //cout<<x<<" ";
	ans*=(x+1);
	ans=mod(ans);
}
 
 cout<<ans;
 
}


int main()
{
    fast;
  ll t;
 // cin>>t;
 t=1;
  while(t--)
  test_cases();

  	
}

		
	
	
	
	


Measured memory_bytes: 3684
#include<bits/stdc++.h>
#include <array>
using namespace std;
using ULL = unsigned long long;
using UL = unsigned;
using LL = long long;
#define rep(i, n) for(UL i = 0; i < (n); i++)

struct Problem {

	void Solve() {
		UL N, H, W; cin >> N >> H >> W;
		UL ans = (N - H + 1) * (N - W + 1);
		cout << ans << endl;
	}

	Problem();
};
int main() {
	unique_ptr<Problem> p(new Problem());
	p->Solve();
	return 0;
}
Problem::Problem() {
	cout << fixed << setprecision(10);
}

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

int main(){
    //input
    int N,M;
    cin >> N >>M;
    int i,j;
    vector<pair<int,int> > start, goal;
    int a,b;
    for(i=0; i<M; i++){
        cin >> a  >> b;
        start.push_back(make_pair(a-1,i));
        goal.push_back(make_pair(b-1,i));
    }

    //calc
    sort(start.begin(),start.end());
    sort(goal.begin(),goal.end());
    bool usable[M];
    fill(usable,usable+M,1);
    int ans=0, j_sta=0;
    for(i=0; i<M; i++){
        if(usable[goal[i].second]){
            ans++;
            usable[goal[i].second]=0;
            for(j=j_sta; j<M; j++){
                if(start[j].first<goal[i].first){
                    usable[start[j].second]=0;
                }else{
                    break;
                }
            }
            j_sta=j;
        }
    }

    //answer
    cout << ans << endl;
    system("pause");
    return 0;
}

Measured memory_bytes: 2404
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;

constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr long double EPS = 1e-8;

long long int N, M, K, L, R, H, W;
//int N, M, K, L, R, H, W;

int gcd(int a, int b) {
	while (b) {
		a %= b;
		swap(a, b);
	}
	return a;
}

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

	cin >> N;
	for (int i = 1; i <= N; i++) {
		for (int j = 1; j <= N; j++) {
			for (int k = 1; k <= N; k++) {
				M += gcd(gcd(i, j), k);
			}
		}
	}
	cout << M << endl;
}


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

#define all(v)   v.begin(), v.end()
#define endl "\n";
#define pb push_back
#define F first
#define S second
#define JULEE_DO_THE_THING fast()
#define to_str to_string
#define isOdd(n)    (n&1)
#define LLMAX LLONG_MAX
#define LLMIN LLONG_MIN
#define IMIN INT_MIN
#define IMAX INT_MAX

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef double dd;
typedef string str;
typedef vector<int> vecint;
typedef vector<ll> vecll;
typedef pair<int, int> pii;


void fast(){
    cin.tie(0);
    cout.tie(0);
    cin.sync_with_stdio(0);
}

bool compare(int &a, int &b){
    return a>b;
}

ll numOfDigits(ll n){
    if(!n) return 1;
    return (ll)(log10(n))+1;
}

ull pow (ll a, ll b);




/*


*/

ll BN ();
map<int ,int > mp;
int main()
{
    JULEE_DO_THE_THING;
    //freopen("test cases\\.txt", "r", stdin) ;
    int n; cin>>n;
    int mx = 0;
    map<str, int>mp;
    for(int i=0; i<n; i++){
    	str s; cin>>s;
    	mp[s]++;
    	mx = max(mx, mp[s]);
    }
    auto beg = *mp.rbegin();
    for(auto &it: mp){
    	if(it.S==mx)cout<<it.F<<endl;
    }
    return 0;
}


ll BN (){
    ll low = 0;
    ll up = 0;
    ll ans = 0;
    while(low<=up){
        ll mid = ((low+ up)/2);
        if(mid) {
            ans = mid;
            low = mid+1;
        }else up = mid-1;
    }
    return ans;
}


ull pow (ll a, ll b){
    ull res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}


Measured memory_bytes: 23936
//include
//------------------------------------------
#include <bits/stdc++.h>
using namespace std;
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const long long INF = 1000000007;
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
// chmax chmin
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; }

char win(char c){
    if(c == 'p') return 's';
    else if(c == 's') return 'r';
    else return 'p';
}

int main(void){
    int N,K,R,S,P; cin >> N >> K >> R >> S >> P;
    string T; cin >> T;
    map<char,int> m;
    m['r'] = R; m['s'] = S; m['p'] = P;
    int ans = 0;
    string me = "";
    REP(i,N){
        if(i-K >= 0){
            if(T[i-K] == T[i]){
                set<char> s{'r','s','p'};
                s.erase(me[i-K]);
                if(i+K < N){
                    if(T[i]!=T[i+K]) s.erase(win(T[i+K]));
                }
                char c;
                if(s.find(win(T[i])) != s.end()) c = win(T[i]);
                else c = *s.begin();
                if(c == win(T[i])) ans += m[c];
                me += c;
            }
            else{
                ans += m[win(T[i])];
                me += win(T[i]);
            }
        }else{
            ans += m[win(T[i])];
            me += win(T[i]);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i,a,b) for(ll i=(a);i<(b);i++)
#define all(a)  (a).begin(),(a).end()
#define pb emplace_back
#define INF (1e9+1)
//#define INF (1LL<<59)

int main(){
    string s;
    cin>>s;
    pii ans = pii(-1,-1);
    rep(i,s.size()-1){
        if(s[i]==s[i+1])ans = pii(i+1,i+2);
    }
    rep(i,s.size()-2){
        if(s[i]==s[i+2])ans = pii(i+1,i+3);
    }
    
    cout<<ans.first<<" "<<ans.second<<endl;
}

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

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

Measured memory_bytes: 3096
#include <iostream>

using namespace std;

int main(){
  int A, B;
  cin >> A >> B;
  
  int open = A;
  int tap_number = 1;
  while(true){
    if(B == 1){
      tap_number = 0;
      break;
    }
    if(open >= B) break;
    open = open + A-1;
    tap_number++;
  }
  cout << tap_number;
}

Measured memory_bytes: 256
import sys
import copy
input=sys.stdin.readline

n=int(input())
l=[0]+list(map(int,input().split()))+[0]
#print(l)
dis=copy.deepcopy(l)
a=0
for i in range(1,n+2):
    a+=abs(l[i]-l[i-1])
#print(dis)
for i in range(1,n+1):
    print(a-abs(l[i]-l[i-1])-abs(dis[i+1]-l[i])+abs(l[i-1]-l[i+1]))

Measured memory_bytes: 14052
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int D = sc.nextInt();
		int A = sc.nextInt();
		int[][] X = new int[N][2];
		for(int i = 0; i < N; i++) {
			X[i][0] = sc.nextInt();
			X[i][1] = sc.nextInt();
		}
		Arrays.sort(X, (x, y) -> x[0] - y[0]);
		long ans = 0;
		long[] S = new long[N+1];
		int d = 1;
		for(int i = 0; i < N; i++) {
			long temp = X[i][0] + D * 2;
			while(d < N && X[d][0] <= temp)
				d++;
			long k = Math.max(0, (X[i][1] - S[i] + A - 1) / A);
			S[i+1] += S[i] + k * A;
			S[d] -= k * A;
			ans += k;
		}
		System.out.println(ans);
	}

}

Measured memory_bytes: 119088
import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.*;
import java.util.LinkedList;

public class Main {
	public class pair implements Comparable<pair> {
		int wt;
		int val;
		double rat;

		pair(int a, int v) {
			wt = a;
			val = v;
			rat = v / wt;
		}

		@Override
		public int compareTo(pair o) {
			// TODO Auto-generated method stub
			return (int) (this.rat - o.rat);
		}

	}

	public static void main(String[] args) throws IOException {
		Scanner scn = new Scanner(System.in);

		int n = scn.nextInt();

		long cap = scn.nextLong();
		long wt[] = new long[n];
		int val[] = new int[n];
		int sum = 0;
		for (int i = 0; i < n; i++) {
			long w = scn.nextLong();
			int v = scn.nextInt();
			wt[i] = w;
			val[i] = v;
			sum += v;
		}
		long dp[][] = new long[n + 1][sum + 1];
		for (long v[] : dp)
			Arrays.fill(v, Integer.MAX_VALUE / 2);
		for (int i = 0; i <= n; i++) {
			dp[i][0] = 0;
		}
		for (int i = 1; i <= n; i++) {
			for (int j = 0; j <= sum; j++) {
				dp[i][j] = dp[i - 1][j];
				if (j - val[i - 1] >= 0) {
					dp[i][j] = Math.min(dp[i][j], wt[i - 1] + dp[i - 1][j - val[i - 1]]);
				}
			}
		}
		long ans = 0;
		for (int i = 0; i <= sum; i++) {
			if ( dp[n][i] <= cap) {
				ans = i;
			}
		}

		System.out.println(ans);

	}

}

Measured memory_bytes: 127568
#include  <stdio.h>
#define rep(i,l,n) for(i=l;i<n;i++)

int main(void){
	int i,j;
	rep(i,1,10){
		rep(j,1,10){
			printf("%dx%d=%d\n",i,j,i*j);
		}
	}
	return 0;
}

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

int main() {
	// your code goes here
	int ch, ei, don;
	int n = 0;
	ch = 0;
	ei = 0;
	don = 0;
	
	while (true) {
		vector <int> l(3);
		cin >> l[0];
		cin >> l[1];
		cin >> l[2];
		std::sort(l.begin(), l.end());
		if (l[0] + l[1] > l[2] && l[1] + l[2] > l[0] && l[2] + l[0] > l[1]) {
			n++;
			if (l[2] * l[2] == l[0] * l[0] + l[1] * l[1]) {
				ch++;
			} else if (l[2] * l[2] > l[0] * l[0] + l[1] * l[1]) {
				don++;
			} else {
				ei++;
			}
		} else {
			break;
		}
	}
	cout << n << " " << ch << " " << ei << " " << don << endl;
	return 0;
}


Measured memory_bytes: 3148
#include <iostream>
#define rep(i,n) for (int i = 0; i < (n); ++i) 
using namespace std;

int n;
int A[50];

bool solve(int i, int m)
{
    if (m == 0) return true;
    if (i >= n) return false;
    return solve(i+1, m) || solve(i+1, m-A[i]);
}

int main()
{
    cin >> n;
    rep(i,n) cin >> A[i];

    int q, m;
    cin >> q;
    rep(i,q) {
        cin >> m;
        if (solve(0, m)) puts("yes");
        else puts("no");
    }
    
    return 0;
}


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

ll comb(int n, int r) {
    if (r == 0 || r == n) return 1;
    else if (r == 1) return n;
    return comb(n-1, r-1) + comb(n-1, r);
}

int main() {
    int n, p;
    cin >> n >> p;
    vector<int> a(n);
    rep(i,n) cin >> a.at(i);
    int sum = 0, odd = 0;
    rep(i,n) {
        sum += a.at(i);
        if (a.at(i) % 2 == 1) odd++;
    }
    int r = sum%2;

    ll ans = (ll) 1<<(n-odd);
    if (odd == 0) {
        if (p != r) ans = 0;
        cout << ans << endl;
        return 0;
    }

    if (p == r) {
        ll comb_odd = 0;
        for (int i = 0; i <= odd; i += 2) {
            comb_odd += comb(odd, i);
        }
        ans *= comb_odd;
    }
    else {
        ll comb_odd = 0;
        for (int i = 1; i <= odd; i += 2) {
            comb_odd += comb(odd, i);
        }
        ans *= comb_odd;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3588
n,*L = map(int,open(0).read().split())
from collections import Counter
L = Counter(L)
li = []
for k,v in L.items():
    li.append([k,v])
li.sort(reverse = True)
LL = []
for i in range(len(li)):
    if li[i][1] >= 2:
        LL.append(li[i])

if len(LL) == 0:
    print(0)
    exit()
if LL[0][1] >= 4:
    print(LL[0][0]**2)
elif len(LL) >=2:
    print(LL[0][0]*LL[1][0])
else:
    print(0)

Measured memory_bytes: 23260
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int R;
  cin >> R;
   if ( R < 1200 ) {
     cout << "ABC" << endl;
   }
     else if ( R < 2800 ) {
       cout << "ARC" << endl;
     }
      else {
        cout << "AGC" << endl;
      }
}

Measured memory_bytes: 256
N, W = map(int, input().split())
w = [0] * N
v = [0] * N
for i in range(N):
    w[i], v[i] = map(int, input().split())

INF = 10 ** 10
dp = [[INF] * (10**5+1) for i in range(N+1)]
dp[0][0] = 0

for i in range(N):
    for sum_v in range(10**5+1):
        if sum_v - v[i] >= 0:
            dp[i+1][sum_v] = min(dp[i+1][sum_v], dp[i][sum_v-v[i]] + w[i])
        dp[i+1][sum_v] = min(dp[i+1][sum_v], dp[i][sum_v])

res = 0
for sum_v in range(10**5+1):
    if dp[N][sum_v] <= W:
        res = sum_v

print(res)

Measured memory_bytes: 121324
M = "#."*151
ans = []
add = ans.append
for line in open(0).readlines():
    H, W = map(int, line.split())
    if not H:
        break
    for i in range(H):
        j = i%2
        add(M[j:W+j])
        add("\n")
    add("\n")
open(1, 'w').writelines(ans)


Measured memory_bytes: 5648
#include<stdio.h>
int main()
{
    long long int a, b, k;
    scanf("%lld %lld", &a, &b);

    k = (a+b)/2;

    if(abs(a-k) == abs(b-k))
    {
        printf("%lld", k);
    }

    else
    {
        printf("IMPOSSIBLE");
    }

    return 0;
}


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

#define ll long long
#define mod 1000000007
#define debug1(x) cerr<<#x<<" : "<<x<<"\n";
#define debug2(x,y) cerr<<#x<<" : "<<x<<"\t"<<#y<<" : "<<y<<"\n";
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);


int main() {
    IOS;
    string s,t;
    cin>>s>>t;
    ll ans=t.size();
    for(ll i=0;i<=s.size()-t.size();i++){
        ll diff=0;
        for(ll j=i;j<i+t.size();j++){
            if(s[j]!=t[j-i])diff++;
        }
        ans=min(ans,diff);

    }
    cout<<ans;
    return 0 ;
}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp setprecision
#define pb(x) push_back(x)
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
const ll MOD = 1e9+7;
const ll MOD2 = 998244353;
const int inf = INT_MAX;
const ll INF = LLONG_MAX;
const string alpha = "abcdefghijklmnopqrstuvwxyz";

int main(){
    int A, B;
    cin >> A >> B;
    cout << A+B/2 << endl;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main {
    static final String YES = "Yes";
    static final String NO = "No";

    public static void main(final String[] args) throws Exception {
        final Scanner sc = new Scanner(System.in);
        String S;
        S = sc.next();

        final Solver solver = new Solver();
        if (solver.solve(S)) {
            System.out.println(YES);
        }
        else {
            System.out.println(NO);
        }
    }
}

class Solver {
    public boolean solve(String S) {
        final int length = S.length();
        if (length % 2 == 0) {
            return false;
        }

        if (!isPalindrome(S)) {
            return false;
        }

        final String first = S.substring(0, length / 2);
        final String second = S.substring(length / 2 + 1, length);
        return isPalindrome(first) && isPalindrome(second);
    }

    private boolean isPalindrome(final String s) {
        final int length = s.length();

        final String first;
        final String second;
        if (length % 2 == 0) {
            first = s.substring(0, length / 2);
            second = s.substring(length / 2, length);
        }
        else {
            first = s.substring(0, length / 2);
            second = s.substring(length / 2 + 1, length);
        }

        for (int i = 0; i < length / 2; i++) {
            if (first.charAt(i) != second.charAt(length / 2 - i - 1)) {
                return false;
            }
        }
        return true;
    }
}



Measured memory_bytes: 23892
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <functional>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cctype>
#include <cstdio>
#define ll long long
#define INF 1000000000000000001
#define MOD 1000000007
using namespace std;



int main(){
    int N;
    cin >> N;
    ll A[100001];
    ll B[100000];
    for(int i=0; i<N+1; i++){
        cin >> A[i];
    }
    for(int i=0; i<N; i++){
        cin >> B[i];
    }
    
    ll ans=0;
    for(int i=0; i<N; i++){
        ans+=min(B[i],A[i]);
        B[i]-=min(A[i],B[i]);
        ans+=min(B[i],A[i+1]);
        A[i+1]-=min(A[i+1],B[i]);
    }
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
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; }
#define all(x) (x).begin(),(x).end()
#define pll pair<ll,ll>
#define rep(i,n) for(int i=0;i<n;i++) 
const ll INF = 1LL<<60;
const ll mod = (int)1e9 + 7;

int main() {
    //ll N; cin >> N;
    //ll N,M; cin >> N >> M;
    //string S; cin >> S;
    //ll H,W; cin >> H >> W;
    int N,x;
    cin >> N >> x;
    int a[N];
    rep(i,N) cin >> a[i];
    ll sum=0;
    rep(i,N){
        if(i==0 && a[0]>x){
            sum+=a[0]-x;
            a[0]=x;
        }
        else if(i!=0){
            if(a[i]+a[i-1]>x){
                sum+=a[i]+a[i-1]-x;
                a[i]=x-a[i-1];
            }
        }
    }
    cout << sum;
    


}

/*



 */



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

#define all(x) (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define ll long long
#define ld long double
#define pb push_back
#define MOD 1000000007
#define LLMN LONG_LONG_MIN
#define LLMX LONG_LONG_MAX
#define LDMX LDBL_MAX
#define LDMN LDBL_MIN
#define MAX 1000003
#define pll pair<ll, ll>
#define vl vector<ll>
#define vll vector< vector<ll> >

ll mulmod(ll, ll);
ll fastpower(ll, ll);
void getprime(vector<bool>&);
void getfact(vector<ll>&, vector<ll>&);
ll ncr(ll, ll, vector<ll>&, vector<ll>&);

void solve()
{
    ll n, m;
    cin>>n>>m;
    vector<ll>dist(n, LLMX);
    vll adj(n);
    for(ll i=0;i<m;i++)
    {
        ll a, b;
        cin>>a>>b;
        a--;b--;
        adj[a].push_back(b);
        adj[b].push_back(a);    
    }
    queue<ll>q;
    q.push(0);
    dist[0] = 0;
    while(!q.empty())
    {
        ll x = q.front();
        q.pop();
        for(auto j : adj[x])
        {
            if(dist[j] == LLMX)
            {
                dist[j] = (x + 1);
                q.push(j);
            }
        }
    }
    bool f = true;
    for(ll i=0;i<n;i++)
    {    if(dist[i] == LLMX)
        {
            f = false;
            break;
        }
    }
    if(f)
    {
        cout<<"Yes\n";
        for(ll i=1;i<n;i++)
            cout<<dist[i]<<"\n";
    }
    else
        No();
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ll t = 1;
    //cin>>t;
    while(t--)
    {
        solve();        
    }
    return 0;
}

ll mulmod(ll a, ll b)
{
    ll res = 0; 
    a = a % MOD;
    while(b > 0)
    {
        if (b % 2 == 1)
            res = (res + a) % MOD;
 
        a = (a * 2) % MOD; 
        b /= 2;
    } 
    return res % MOD; 
}

ll  fastpower(ll a, ll n)
{
    ll res = 1;
    while(n > 0)
    {
        if(n % 2 != 0)
        {
            res = (res * a) % MOD;
        }
        n /= 2;
        a = (a * a) % MOD;
    }
    return res;
}

void getprime(vector<bool>&prime)
{
    prime[0] = false;
    prime[1] = false;
    
    for(ll i = 2;i <= MAX; i++)
    {
        if(prime[i])
        {
            for(ll j = i*i; j <= MAX; j += i)
                prime[j] = false;
        }
    }
}

void getfact(vector<ll> &fact, vector<ll> &ifact)
{
    fact[0] = 1;
    ifact[0] = 1;
    
    for(ll i = 1; i <= MAX; i++)
    {
        fact[i] = (fact[i-1] * i)%MOD;
        ifact[i] = (ifact[i-1] * fastpower(i, MOD -2) )%MOD;
    }
}

ll ncr(ll n, ll r, vector<ll>&fact, vector<ll>&ifact)
{
    ll res;
    res = (((fact[n] * ifact[r]) % MOD) * ifact[n-r]) % MOD;
    return res;
}


Measured memory_bytes: 12968
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n,k) for(ll i=(n);i<(k);i++)
#define ALL(a)  (a).begin(),(a).end()
ll ans=0;
ll gcd(ll a,ll b){
    return b?gcd(b,a%b):a;
}
ll div(ll a){
     ll cnt=0;
     while(a%2==0){
          a/=2;
          cnt++;
     }
     return cnt;
}
void Main(){
    ll n;cin>>n;
    ll m;cin>>m;
    vector<ll> a(n),b(n);
    ll L=1;
    For(i,0,n) {
         cin>>a[i];
         a[i]/=2;
         L=(L*a[i]/gcd(L,a[i]));
     }
     b[0]=div(a[0]);
     For(i,1,n){
          b[i]=div(a[i]);
          if(b[i]!=b[i-1]){
               cout<<0<<endl;
               return;
          }
     }
     ans=(m/L+1)/2;
     cout<<ans<<endl;
}
int main(){
     Main();
     return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>

//static int primes[100000000+1];
static int primes[10001];

void init_primes()
{
    int i, j, k;
    //for(i = 0; i <= 100000000; i++) {
    for(i = 0; i <= 10000; i++) {
        primes[i] = 1;
    }
    primes[0] = 0;
    primes[1] = 0;
    //for(i = 2; i <= 10000; i++) {
    for(i = 2; i <= 100; i++) {
        if(primes[i] == 1) {
            //for(j = i*i; j <= 100000000; j += i) {
            for(j = i*i; j <= 10000; j += i) {
                primes[j] = 0;
            }
        }
    }
}

int is_prime(int num)
{
    int i;
    for(i = 2; i <= 10000 && i < num; i++) {
        if(primes[i] == 1 && num%i == 0) {
        //printf("%d : %d\n", num , i);
        //if(num%i == 0) {
            return 0;
        }
    }
    return 1;
}

int main()
{
    int n;
    int a;
    int i;
    int count;

    init_primes();
    scanf("%d", &n);
    count = 0;
    for(i = 0; i < n; i++) {
        scanf("%d", &a);
        //count += primes[a];
        count += is_prime(a);
    }
    printf("%d\n", count);
    return 0;
}


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

using namespace std;

int main()
{
	string s;
	cin >> s;
	vector<bool> dp(s.size()+1, false);
	dp[0] = true;
	for (int i = 0; i <= dp.size(); i++)
	{
		if (i+5 < dp.size() && s.substr(i, 5) == "dream") dp[i+5] = dp[i+5] || dp[i];
		if (i+5 < dp.size() && s.substr(i, 5) == "erase") dp[i+5] = dp[i+5] || dp[i];
		if (i+7 < dp.size() && s.substr(i, 7) == "dreamer") dp[i+7] = dp[i+7] || dp[i];
		if (i+6 < dp.size() && s.substr(i, 6) == "eraser") dp[i+6] = dp[i+6] || dp[i];
	}
	cout << (dp.back() ? "YES" : "NO") << endl;
	return 0;
}


Measured memory_bytes: 512
def main():
  N=int(input())
  A=list(map(int,input().split()))
  s=sum(A)
  Q=int(input())
  d=[0]*(10**5 +1)#各数字の個数
  for i in A:
    d[i]+=1

  for i in range(Q):
    B,C=map(int,input().split())
    s += (C-B)*d[B]
    print(s)
    d[C]+=d[B]
    d[B]=0

if __name__ == "__main__":
    main()

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

void show(int*A, int N);

int bubblesort(int* A, int N) {
	int flag = 1;
	int Count = 0;

	while (flag) {
		flag = 0;
		

		for (int i = N - 1; i > 0; --i) {
			if (A[i] < A[i - 1]) {
				int Case = A[i - 1];
				A[i - 1] = A[i];
				A[i] = Case;
				++Count;
				flag = 1;
			}
		}
	}


	return Count;
}

void show(int* A, int N) {
	for (int i = 0; i < N; ++i) {
		if (i > 0) { cout << ' '; }
		cout << A[i];
	}
	cout << endl;
}

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

	int* A = new int[N];
	for (int i = 0; i < N; ++i) {
		cin >> A[i];
	}
	int s = bubblesort(A, N);
	show(A, N);
	cout << s << endl;


	delete[] A;

}


Measured memory_bytes: 3112
#include<iostream>

using namespace std;

using ll =  long long;

constexpr int N_MAX = 1000;
constexpr int M_MAX = 1000;
constexpr ll MOD = 1000000007;

namespace stirling {
    int n, m; // ボールの個数，グループ数
    ll s[N_MAX+1][M_MAX+1];
    
    void init(int nn, int mm) {
        n = nn;
        m = mm;
        s[0][0] = 1;
        for(int j=1;j<=m;++j) s[0][j] = 0;
        for(int i=1;i<=n;++i) s[i][0] = 0;
        for(int i=1;i<=n;++i) {
            for(int j=1;j<=m;++j) {
                s[i][j] = (s[i-1][j-1] + (s[i-1][j]*j) % MOD) % MOD;
            }
        }
    }

    const ll get(int i, int j) {
        return s[i][j];
    }
}

namespace bell {
    int n, m; // ボールの個数，グループ数
    ll b[N_MAX+1][M_MAX+1];
    
    void init(int nn, int mm) {
        n = nn;
        m = mm;
        stirling::init(n, m);
        for(int i=0;i<=n;++i) {
            b[i][0] = stirling::get(i, 0);
            for(int j=1;j<=m;++j) {
                b[i][j] = (b[i][j-1] + stirling::get(i, j)) % MOD;
            }
        }
    }

    const ll get(int i, int j) {
        return b[i][j];
    }
}

int main() {
    int n, m;
    cin >> n >> m;
    stirling::init(n, m);
    cout << stirling::get(n, m) << endl;
}


Measured memory_bytes: 10916
judge :: Int -> String
judge x
    | (x `mod` 2 == 0) = "Even"
    | otherwise = "Odd"

main = do
    input <- words <$> getLine
    let a = read (head input) :: Int;
        b = read (last input) :: Int;
        c = a * b
        ans = judge c
    putStrLn ans

Measured memory_bytes: 508
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <utility>
#include <cstddef>

using usize = std::size_t;

long long input () {
	std::string s;
	std::cin >> s;
	if (s.find('.') == std::string::npos) {
		return std::stoll(s) * 1'000'000'000; //'
	} else {
		bool flag = false;
		int count = 9;
		std::string t = "";
		for (const char &c : s) {
			if (c == '.') flag = true;
			else {
				if (flag) count--;
				t += c;
			}
		}
		long long ten = 1LL;
		for (int i = 0; i < count; i++) ten *= 10LL;
		return stoll(t) * ten;
	}
}

int main() {
	usize n;
	std::cin >> n;
	std::map<std::pair<int, int>, int> map;
	for (usize i = 0; i < n; i++) {
		long long a = input();
		int two = 0, five = 0;
		while (not (a & 1)) { a >>= 1; two++; }
		while (a % 5 == 0) { a /= 5; five++; }
		map[std::make_pair(two, five)]++;
	}
	
	long long ans = 0;
	for (auto [p1, c1] : map) for (auto [p2, c2] : map) {
		if (p1.first + p2.first >= 18 and p1.second + p2.second >= 18) {
			if (p1 == p2) ans += (1LL * c1 * (c1 - 1) / 2LL);
			else if (p1 > p2) ans += (1LL * c1 * c2);
		}
	}
	
	std::cout << ans << '\n';
	
	return 0;
}

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

int col[8];

int main(void)
{
	int tmp = 0;
	int N, a;

	cin >> N;
	for (int i = 0; i < N; ++i) {
		cin >> a;
		if (3200 <= a) {
			++tmp;
			continue;
		}
		int ind = a / 400;
		++col[ind];
	}

	int min, max;
	int cnt = 0;

	for (int i = 0; i < 8; ++i) {
		if (col[i] > 0) ++cnt;
	}

	min = cnt;
	max = cnt + tmp;
	if (min == 0) min = 1;
	//if (max > 8) max = 8;
	
	cout << min << " " << max << endl;

	return 0;
}

Measured memory_bytes: 256
// pana1-4
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<ll, P>IP;
typedef vector<ll> V;
typedef vector<V> V2;
typedef vector<vector<P> > G;
void g_dir(G &graph, ll a, ll b, ll w = 1){graph[a].push_back(P(b, w));}
void g_undir(G &graph, ll a, ll b, ll w = 1){g_dir(graph, a, b, w);g_dir(graph, b, a, w);}
#define rep(i, n) for(ll (i) = 0; (i) < (n); (i)++)
#define rep1(i, n) for(ll (i) = 1; (i) <= (n); (i)++)
#define rrep(i, n) for(ll (i) = (n) - 1; (i) >= 0; (i)--)
#define rrep1(i, n) for(ll (i) = (n); (i) >= 1; (i)--)
template<class T> void chmax(T &a, const T &b){if(a < b){a = b;}}
template<class T> void chmin(T &a, const T &b){if(a > b){a = b;}}
const ll INF = 1145141919;
const ll MOD = 1000000007;
const ll NUM = 101010;

ll v[10];
void inc(ll pos){
    v[pos]++;
    if(pos == 0)return;
    ll flg = 0;
    for(ll i = 0; i < pos; i++){
        if(v[i] + 1 >= v[pos])return;
    }
    v[pos] = 0;
    inc(pos - 1);
}


int main(){

    ll N;
    cin >> N;
    for(;v[0] == 0;){
        rep(i, N)cout << (char)(v[i] + 'a');
        cout << endl;
        inc(N - 1);
    }

    return 0;
}

Measured memory_bytes: 1536
#include <iostream>
    #include <math.h>
    #include <vector>
    #include <string>
    #include <cstdlib>
    #include <cmath>
    #include <algorithm>
    using namespace std;

int main() {

    int a,b;cin>>a>>b;
    cout<<a*b -(a+b-1)<<endl;
    return 0;   

}

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

int n,m,q;
int sd[37][1001];
int bd[1001][1001];
bool state[1001][37];

int main(void){
	while(1){
		scanf("%d %d %d",&n,&m,&q);
		if(n+m+q==0)break;
		for(int i=1;i<=q;i++){
			string s;
			string b;
			cin >> s >> b;
			for(int j=0;j<n;j++){
				sd[j][i]=s[j]-'0';
			}
			for(int j=0;j<m;j++){
				bd[j][i]=b[j]-'0';
			}
		}
		memset(state,true,sizeof(state));
		for(int i=1;i<=q;i++){
			for(int j=0;j<n;j++){
				for(int k=0;k<m;k++){
					if(bd[k][i]!=bd[k][i-1] && sd[j][i]==0){
						state[k][j]=false;
					}
					if(bd[k][i]==bd[k][i-1] && sd[j][i]==1){
						state[k][j]=false;
					}
				}
			}
		}
		for(int j=0;j<m;j++){
			int res=-1;
			for(int k=0;k<n;k++){
				if(state[j][k]){
					if(res==-1){
						res=k;
					}else res=-2;
				}
			}
			if(res<=9)printf("%c",res>=0?'0'+res:'?');
			else printf("%c",res-10+'A');
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 5308
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=88,S=6400;
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define ROF(i,a,b) for(int i=(a);i>=(b);i--)
#define MEM(x,v) memset(x,v,sizeof(x))
template<typename T>
inline void read(T &x){
	x=0;
	char ch=getchar();bool f=false;
	while(ch<'0' || ch>'9') f|=ch=='-',ch=getchar();
	while(ch>='0' && ch<='9') x=x*10+ch-'0',ch=getchar();
	if(f) x=-x;
}
int n,m,a[maxn][maxn],b[maxn][maxn],ans=1e9;
bitset<maxn*maxn*4> dp[maxn][maxn];
int main(){
	read(n);read(m);
	FOR(i,1,n) FOR(j,1,m) read(a[i][j]);
	FOR(i,1,n) FOR(j,1,m) read(b[i][j]);
	FOR(i,1,n) FOR(j,1,m) if(a[i][j]<b[i][j]) swap(a[i][j],b[i][j]); 
	dp[1][1][S+(a[1][1]-b[1][1])]=dp[1][1][S+(b[1][1]-a[1][1])]=1;
	FOR(i,1,n) FOR(j,1,m){
		if(i==1 && j==1) continue;
		if(i!=1) dp[i][j]|=dp[i-1][j]<<(a[i][j]-b[i][j]),dp[i][j]|=dp[i-1][j]>>(a[i][j]-b[i][j]);
		if(j!=1) dp[i][j]|=dp[i][j-1]<<(a[i][j]-b[i][j]),dp[i][j]|=dp[i][j-1]>>(a[i][j]-b[i][j]);
	}
	FOR(i,0,2*S) if(dp[n][m][i]) ans=min(ans,abs(i-S));
	printf("%d\n",ans);
	return 0;
}

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

int arr[101][101];
int brr[101];

int main() {
	int a,b;
	cin>>a>>b;
	for(int i=0;i<a;i++) {
		for(int j=0;j<b;j++) {
			cin>>arr[i][j];
		}
	}
	for(int i=0;i<b;i++) {
		cin>>brr[i];
	}
	for(int i=0;i<a;i++) {
		int sum=0;
		for(int j=0;j<b;j++) {
			sum+=arr[i][j]*brr[j];
//			cout<<sum<<" ";
		}
		cout<<sum<<endl;
	}
}


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

#define rep(i,n) for (int i=0; i<(n); i++)
const int INF =1001001001;
const ll BIG = 1000000007;
const double PI = 3.141592653589793;

double rescale(double r){
    if(r<=90) return PI/2-2*PI*(r/360);
    else if(r>=270) return PI-(2*PI*(r/360)-1.5*PI);
    else return -1*PI*(r-90)/180;
}

int main(){
    int a, b;
    cin >> a >> b;
    int h, m;
    cin >> h >> m;
    double ra, rb;
    double xa,ya, xb,yb;
    ra = 30*(double)h + (double)m/2;
    rb = 6*(double)m;
    ra = rescale(ra);
    rb = rescale(rb);
    xa = a*cos(ra);
    ya = a*sin(ra);
    xb = b*cos(rb);
    yb = b*sin(rb);
    double d = sqrt(pow(xa-xb, 2)+pow(ya-yb, 2));
    cout << fixed << setprecision(19) << d << endl;
}

Measured memory_bytes: 4148
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
void countingOdd(vector <int> const& vect) {
	int count = 0;
	int result = 0;
	for (int i = 0; i < vect.size(); i++) {
		count++;
		if (count % 2 != 0 && vect[i] % 2 != 0) result++;
	}
	cout << result;
}
int main() {
	int numSquares; 
	cin >> numSquares;
	vector <int> squares(numSquares);
	for (int i = 0; i < numSquares; i++) {
		cin >> squares[i];
	}
	countingOdd(squares);
	return 0;
}

Measured memory_bytes: 3512
from sys import stdin

if __name__ == '__main__':
    S, T = stdin.readline().rstrip().split()
    A, B = [int(x) for x in stdin.readline().rstrip().split()]
    U = stdin.readline().rstrip()
    if U == S:
        print('{} {}'.format(A-1, B))
    else:
        print('{} {}'.format(A, B-1))

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

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

	ll a,b,n;
	cin>>a>>b>>n;
	ll val = min(n,b-1);
	val *= a;
	val /= b;
	cout<<val<<'\n';

	return 0;
}


Measured memory_bytes: 3652
//
//  main.cpp
//
//  Under GPLv3 license
//

// #pragma GCC diagnostic error "-std=c++14"
// #pragma GCC optimize("O3")
// #pragma comment(linker, "/STACK:1024000000,1024000000")

#include <string.h>
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
// #include <unordered_map>
// #include <unordered_set>
#include <utility>
#include <vector>

#define pb push_back
#define pf push_front
#define mp make_pair

using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;

const int INF = (1 << 30) - 1;
const LL LINF = (1LL << 61) - 1;
const double EPS = 1e-10;
const int N = 1e5 + 1000;
const int LEN = 50;

int T;
int n;
vector<double> p;
double dp[N];

void init() {
  p.clear();
  memset(dp, 0, sizeof dp);
}

int main() {
// ios::sync_with_stdio(false);
// cin.tie(0);
// freopen(".in", "r", stdin);
// freopen(".out", "w", stdout);

#ifndef ONLINE_JUDGE
  double __start_time = clock();
#endif

  // insert code heree

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

    double buff = 0.00;
    for (int i = 0; i < n; i++) {
      double x;
      scanf("%lf", &x);
      if (x == 1.00) {
        buff += 1.00;
      } else {
        if (buff > 0) p.pb(buff), buff = 0.00;
        p.pb(x);
      }
    }

    if (buff > 0) p.pb(buff);

    n = (int)p.size();

    dp[n] = 0;
    for (int i = n - 1; i >= 0; i--) {
      dp[i] = INF;
      buff = 0;

      for (int j = i + 1; j <= n && j - i <= LEN; j++) {
        if (p[j - 1] < 1.00)
          buff = (buff + 1.00) / p[j - 1];
        else
          buff += p[j - 1];
        dp[i] = min(dp[i], buff + dp[j] + 1);
      }
    }

    printf("%.8lf\n", dp[0] - 1.00);
  }

#ifndef ONLINE_JUDGE
  cout << "LOCAL RUNNING TIME = "
       << double(((double)clock() - __start_time) / (double)CLOCKS_PER_SEC)
       << " sec" << endl;
#endif

  return 0;
}

Measured memory_bytes: 2960