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

#define int long long
#define fast_io(); ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define loop(i,a,b) for(int i=a;i<b;i++)
#define all(x) x.begin(),x.end()
#define us unordered_set
#define um unordered_map
#define ms multiset
#define mm multimap
#define pb push_back
#define pf push_front
#define ins insert
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define _max max_element
#define _min min_element
#define tc(T) int T; cin>>T; while(T--)
#define q(q) int q; cin>>q; while(q--)
#define pi 3.1415926535897932384626433832
const int pinf=((int)2e18);
const int ninf=((int)-2e18);
const int mod=1000000007;

using namespace std;

int power(int x,int n,int M)
{
    if(n==0)
        return 1;
    else if(n%2 == 0)
        return power((x*x)%M,n/2,M);
    else
        return (x*power((x*x)%M,(n-1)/2,M))%M;
}

bool vowel(char c)
{
    return(c=='a' or c=='e' or c=='i' or c=='o' or c=='u' or c=='A' or c=='E' or c=='I' or c=='U' or c=='O');
}

int32_t main()
{
    fast_io();

    //FILE *fptr1=freopen("in.txt","r",stdin);
    //FILE *fptr2=freopen("out.txt","w",stdout);


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

    vector<int> a(n);

    loop(i,0,n) cin>>a[i];


    loop(i,k,n)
    {
        if(a[i]>a[i-k]) cout<< "Yes\n";
        else cout<< "No\n";
    }



    return 0;
}


Measured memory_bytes: 4780
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
bool bo[100];
#define ll long long
ll dp[1001][1001];
ll f(ll n,ll r)
{
	if(r==1) return n;
	if(n==r) return 1;
	if(dp[n][r]!=-1)
	{
		return dp[n][r];
	}
	dp[n][r]=f(n-1,r)+f(n-1,r-1);
	return dp[n][r];
}


ll ff(ll n)
{
	if(n==0) return 1;
	if(n==1) return 1;
	return n*ff(n-1);
}

int main()
{
	for(int i=0;i<1001;i++)
	{
		for(int j=0;j<1001;j++)
		{
			dp[i][j]=-1;
		}
	}
	
	ll n,r;
	cin>>n>>r;
	if(r==1 && n==1)
	{
		cout<<"0"<<endl;
		return 0;
	}
	else if(r==1)
	{
		cout<<0<<endl;
		return 0;
	}
	
		ll res;
        res = r * (ll) pow (r-1 , n-1);
        cout << res << "\n" ;
	
}


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

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

  switch(D)
  {
    case 22:
      cout << "Christmas Eve Eve Eve" << endl;
      break;
    case 23:
      cout << "Christmas Eve Eve" << endl;
      break;
    case 24:
      cout << "Christmas Eve" << endl;
      break;
    case 25:
      cout << "Christmas" << endl;
      break;
    default:
      ;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a) for(int i=0; i<(int)(a); i++)
typedef long long ll;
template<typename T>
struct edge {
  int src, to;
  T cost;
  edge(int to, T cost) : src(-1), to(to), cost(cost) {}
  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}
  edge &operator=(const int &x) {
    to = x;
    return *this;
  }
  operator int() const { return to; }
};
template<typename T>
using Edges = vector<edge<T>>;
template<typename T>
using WeightedGraph = vector<Edges<T>>;
using UnWeightedGraph = vector<vector<int>>;
template<typename T>
using Matrix = vector<vector<T>>;

/////////////////////////////////////////////////////////////////////
const ll inf = 1LL<<60;

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

  ll d = 1;
  for (ll i=1; i<=n; i++) {
    d = i;
    ll s = i*(i+1)/2;
    if (s >= n) break;
  }

  for (ll i=d; i>=1; i--) {
    ll t = min(n, i);
    cout << t << endl;
    n -= t;
    if (n <= 0) break;
  }

  return 0;
}


Measured memory_bytes: 3560
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define EPS (1e-7)
#define INF (1e9)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
const double PI = acos(-1);
const ll MOD = 1000000007;
// const ll MOD = 998244353;
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;
}
///////////////////////////////////////////////////////////////
 
int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int N; cin >> N;

    cout << N/3 << endl;
}

Measured memory_bytes: 256
n = int(input())
num = list(map(int, input().split()))
cnt = [1]*n
flug = 1
for i in range(n):
  if num[i] == flug:
      cnt[i] = 0
      flug += 1
if sum(cnt) == n:
  print(-1)
else:
  print(sum(cnt))
  
  


Measured memory_bytes: 24744
//***___********* ___*****___****___***___*********//
/*  |   \  |   | |   |   |   \  |     |     |   |  **
/*  |   |  |   | |___|   |   _  |__   |___  |___|  **
/*  |   |  |   | |   \   |  | | |         | |   |  **
/*  |___/  |___| |    \  |__| | |___  ____| |   |  **
//*************************************************/
#include<bits/stdc++.h>
#define ff double
#define endl "\n"
#define M 1000000007
#define forever while(1)
#define ll long long
#define pb push_back
#define vi vector<long long>
#define mii map<int,int>
#define pii pair<int,int>
#define set_zero(arr) memset(arr,0,sizeof(arr))
#define test ll t;cin>>t;while(t--)
#include <ext/pb_ds/tree_policy.hpp>
#define REP(i,n) for(int i=0;i<(n);i++)
#include <ext/pb_ds/assoc_container.hpp>
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
#define buffer cin.ignore(numeric_limits<streamsize>::max(),'\n');
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
using namespace std;
using namespace __gnu_pbds;

int read()
{
	char ch=getchar();int f=0;
	while(ch<'0'||ch>'9') ch=getchar();
	while(ch>='0'&&ch<='9') {f=f*10+(ch^48);ch=getchar();}
	return f;
}
bool comp(string a,string b){return a<b;}

int main()
{
    int n,m;
    cin>>n>>m;
    if(n==m)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    



return 0;
}




Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));
//priority_queue<int,vector<int>, greater<int> > q2;



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

	int N;
	cin >> N;
	cout << N * 32 << endl;
	return 0;
}




Measured memory_bytes: 3164
// #include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define repr(i,n) for (int i = n; i > 0; --i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

const int MAX = 100;
const int INF = (1<<12);

int main() {
  int n;
  int a, b;
  a = b = 0;
  cin >> n;
  vector<int> A(n);

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

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

  n--;
  while (1)
  {
    a += A[n];
    n--;
    if(n < 0) break;
    b += A[n];
    n--;
    if(n < 0) break;
  }
  cout << a - b << endl;
  return 0;
}

Measured memory_bytes: 256
def inpl(): return [int(i) for i in input().split()]
N = int(input())
A, B = [], []
for _ in range(N):
    a, b = inpl()
    A.append(a)
    B.append(b)
C = [B[i] for i in range(N) if A[i] > B[i]]
if not C:
    c = sum(A)
else:
    c = min(C)
print(sum(A)-c)

Measured memory_bytes: 4852
/*#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,a,b;
	cin>>n>>a>>b;
	cout<<min(n*a,b);
}*/
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,d,ans=0;
	cin>>n>>d;
	double f[105][105];
	for(int i=1;i<=n;i++)
	for(int j=1;j<=d;j++)
	cin>>f[i][j];
	for(int i=1;i<=n;i++)
	for(int j=i+1;j<=n;j++)
	{
		double dis=0;
		for(int k=1;k<=d;k++)
		dis+=(f[i][k]-f[j][k])*(f[i][k]-f[j][k]);
		dis=sqrt(dis);
		if(dis==ceil(dis)) ans++;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;

int n, m;
char flag[1024][1024];
char emblem[2][3];

bool check(int i, int j)
{
	if (i < 0 || i + 1 >= m) return (false);
	if (j < 0 || j + 1 >= n) return (false);
	return (strncmp(flag[i] + j, emblem[0], 2) == 0 && strncmp(flag[i + 1] + j, emblem[1], 2) == 0);
}

int main()
{
	scanf("%d %d", &m, &n);
	
	for (int i = 0; i < m; i++){
		scanf("%s", flag[i]);
	}
	
	scanf("%s", emblem[0]); scanf("%s", emblem[1]);
	
	int ans = 0;
	for (int i = 0; i <= m - 2; i++){
		for (int j = 0; j <= n - 2; j++){
			if (check(i, j)){
				ans++;
			}
		}
	}
	
	int base = ans;
	char rot[] = "JOI";
	for (int i = 0; i < m; i++){
		for (int j = 0; j < n; j++){
			char bef = flag[i][j];
			int ct = 0;
			
			if (check(i - 1, j)) ct++;
			if (check(i - 1, j - 1)) ct++;
			if (check(i, j - 1)) ct++;
			if (check(i, j)) ct++;
			
			for (int k = 0; k < 3; k++){
				int tmp = base - ct;
				flag[i][j] = rot[k];
				
				if (check(i - 1, j)) tmp++;
				if (check(i - 1, j - 1)) tmp++;
				if (check(i, j - 1)) tmp++;
				if (check(i, j)) tmp++;
				
				flag[i][j] = bef;
				ans = max(ans, tmp);
			}
		}
	}
	
	printf("%d\n", ans);
}

Measured memory_bytes: 2056
import sys

ns = lambda: sys.stdin.readline().rstrip()
ni = lambda: int(ns())
nm = lambda: map(int, sys.stdin.readline().split())
nms = lambda: map(str, sys.stdin.readline().split())
nl = lambda: list(nm())

n, k = nm()
h = nl()
h.insert(0, h[0])
INF = 10 ** 9
dp = [INF for _ in range(n + 1)]
dp[1] = 0

for i in range(2, n + 1):
    x = max(i - k, 1)
    dp[i] = min([d + abs(h[i] - hd) for d, hd in zip(dp[x:i], h[x:i])])
print(dp[-1])


Measured memory_bytes: 14012
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <iomanip>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<long double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

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

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }
#define INF 1LL<<60

int main() {
    int N, M;
    cin >> N >> M;
    vector< vector<int> > dist(N, vector<int>(N, 1e9));
    REP(i, M) {
        int s, t, d;
        cin >> s >> t >> d;
        dist[s][t] = d;
    }
    // cerr << "debug : " << (1<<0) << " " << (1<<1) << endl;
    int ans = 1e9;

    REP(s, N) {
        vector< vector<int> > dp((1<<N), vector<int>(N, 1e9));
        // REP(i, N)
        //     dp[0][i] = 0;
        dp[0][s] = 0;

        for(int bit = 0; bit < (1<<N); ++bit) {
            for(int v = 0; v < N; ++v)
                for(int u = 0; u < N; ++u)
                    if( (u != v) && (bit & (1<<v)) ) {
                        dp[bit][v] = min(dp[bit][v], dp[bit&~(1<<v)][u] + dist[u][v]);
                    }
        }
        ans = min(ans, dp[(1<<N)-1][s]);
    }

    if(ans == 1e9)
        ans = -1;
    
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 6236
#include <bits/stdc++.h>
using namespace std;
int a[101];

int main(){
  int n,m,T;
  cin>>n>>m>>T;
  
  for(int i=0;i<n;i++)cin>>a[i];
  a[n]=T+m;
  int ans=a[0]-m;
  for(int i=0;i<n;i++)ans+=max(0,a[i+1]-a[i]-2*m);
  cout<<ans<<endl;
  
  return 0;
}

Measured memory_bytes: 3108
import scala.io.{StdIn => in}
import scala.collection.{mutable => mu}

object Main extends App {
  val n = in.readInt
  val a = in.readLine.split(" ").map(_.toInt)

  val c = a.zipWithIndex.map { elm =>
    val (a, i) = elm
    a - (i+1) 
   }.sorted
  val b = c(n/2)

  val ans = a./:(0L, 1L){  (elm, ai) =>
    val (acc, idx) = elm
    (acc + (ai - (b + idx)).abs, idx + 1L)
  }._1

  println(ans)
}

Measured memory_bytes: 85420
#include <bits/stdc++.h>
#define MOD 1e9 + 7
#define PI 3.141592653589793238
#define pb push_back
#define ALL(V) (V).begin(), (V).end()
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long long int lint;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<int> VI;
typedef pair<ll, ll> P;
ll gcd(ll a, ll b) { return (a % b == 0 ? b : gcd(b, a % b)); }
ll lcm(ll a, ll b) { return a * b / gcd(a, b); }
ll char_to_ll(char c) { return (int)(c - '0'); }
ll string_to_ll(string s) { return char_to_ll(atoi(s.c_str())); }
bool is_prime(ll x){ if(x <= 1) return false; for(ll i = 2; sqrt(i) <= x; i++) if(x % i == 0) return false; return true; }


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

    cout << b << a << endl;
    
  

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
 
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    String t = sc.next();
    int a = sc.nextInt();
    int b = sc.nextInt();
    String u = sc.next();
    if (u.equals(s)) {
      a--;
    } else if (u.equals(t)) {
      b--;
    }
    System.out.println(a + " " + b);
  }
}

Measured memory_bytes: 22868
n,w=gets.split.map(&:to_i)
items=n.times.map{gets.split.map(&:to_i)}.sort_by(&:first)
dp=Hash.new(0)
dp[0]=0
items.each{|iw,iv|
  update=[]
  dp.each{|k,v|
    next if iw+k>w
    update << [iw+k,iv+v] if dp[iw+k]<iv+v
  }
  update.each{|k,v|dp[k]=v}
}
puts dp.values.max

Measured memory_bytes: 20532
package main

import (
	"bufio"
	"fmt"
	"math/rand"
	"os"
	"strconv"
	"strings"
	"time"
)

func last(d, i int, r [365]int) int {
	for j := d; j > 0; j-- {
		if r[j-1] == i {
			return j
		}
	}
	return 0
}

func increaseSatisfaction(held int, scoreList [26]int) int {
	return scoreList[held]
}

func decreaseSatisfaction(d int, s [365][26]int, c [26]int, r [365]int) int {
	// 1~d
	score := 0
	for t := 0; t < 26; t++ {
		score += c[t] * (d - last(d, t, r))
	}
	return -score
}

func shuffle(data [365]int) [365]int {
	n := 365
	r_new := data
	for i := n - 1; i >= 0; i-- {
		j := rand.Intn(i + 1)
		r_new[i], r_new[j] = r_new[j], r_new[i]
	}
	return r_new
}

func main() {
	rand.Seed(time.Now().UTC().UnixNano())

	numDay := 365
	lastHeldDays := [365]int{}
	score := 0
	c := [26]int{}
	s := [365][26]int{}
	r := [365]int{}

	for i := range r {
		r[i] = rand.Intn(26) + 1
	}

	r_new := [365]int{}

	r_new = shuffle(r)

	for i := 0; i < numDay; i++ {
		lastHeldDays[i] = 0
	}

	sc := bufio.NewScanner(os.Stdin)

	// Scan D
	if !sc.Scan() {
		panic("wrong input for D")
	}

	// Scan C
	cStr := ""
	if sc.Scan() {
		cStr = sc.Text()
		cArray := strings.Split(cStr, " ")
		for i, cE := range cArray {
			c[i], _ = strconv.Atoi(cE)
		}
	}

	// Scan S
	sStr := ""
	for i := 0; i < numDay; i++ {
		if sc.Scan() {
			sStr = sc.Text()
			sArray := strings.Split(sStr, " ")
			for j, sE := range sArray {
				s[i][j], _ = strconv.Atoi(sE)
			}
		}
	}

	// Search Best
	testCount := 1000
	currentScore := -100000000
	for count := 0; count < testCount; count++ {
		score = 0
		for d := 1; d <= numDay; d++ {
			score += increaseSatisfaction(r_new[d-1]-1, s[d-1])
			score += decreaseSatisfaction(d, s, c, r_new)
		}
		if currentScore < score {
			r = r_new
			currentScore = score
			// fmt.Printf("score updated %d\n", currentScore)
		}
		r_new = shuffle(r)
	}

	for i := 0; i < 365; i++ {
		fmt.Println(r_new[i])
	}

}


Measured memory_bytes: 2308
import sys
def fastio():
    from io import StringIO
    from atexit import register
    global input
    sys.stdin = StringIO(sys.stdin.read())
    input = lambda : sys.stdin.readline().rstrip('\r\n')
    sys.stdout = StringIO()
    register(lambda : sys.__stdout__.write(sys.stdout.getvalue()))
fastio()

INF = 10**20
MOD = 10**9 + 7
I = lambda:list(map(int,input().split()))
# from math import gcd
from math import ceil
from collections import defaultdict as dd, Counter
from bisect import bisect_left as bl, bisect_right as br

s = input()
t = input()

ans = 'NO'
if s == t[::-1]:
    ans = 'YES'
print(ans)

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

#define INF 0x3f3f3f3f
#define eps 1e-6

typedef long long LL;
const double pi = acos(-1.0);
const long long mod = 1e9;
using namespace std;

stack<int> s1;
stack<pair<int,int> > s2;
vector<int> ans;


int main()
{
    //ios_base::sync_with_stdio(false); cin.tie(0);
    //freopen("int.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    string s;
    cin >> s;
    int sum = 0;
    int len = s.size();
    for(int i = 0;i < len;i++)
    {
        if(s[i] == '\\')
            s1.push(i);
        else if(s[i] == '/' && s1.size() > 0)
        {
            int j = s1.top();s1.pop();
            sum += i - j;
            int a = i - j;
            while(s2.size() > 0 && s2.top().first > j)
            {
                a += s2.top().second;
                s2.pop();
            }
            s2.push(make_pair(j,a));
        }
    }
    while(s2.size() > 0)
    {
        ans.push_back(s2.top().second);
        s2.pop();
    }
    reverse(ans.begin(),ans.end());
    cout << sum << endl;
    cout << ans.size();
    for(int i = 0;i < ans.size();i++)
        cout << ' ' << ans[i];
    cout << endl;
    return 0;
}



Measured memory_bytes: 3240
#include <bits/stdc++.h>
using namespace std;
 
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &vec){ os << "["; for (auto v : vec) os << v << ", "; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const deque<T> &vec){ os << "deq["; for (auto v : vec) os << v << ", "; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const set<T> &vec){ os << "{"; for (auto v : vec) os << v << ", "; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_set<T> &vec){ os << "{"; for (auto v : vec) os << v << ", "; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ", "; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ", "; os << "}"; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa){ os << "(" << pa.first << ", " << pa.second << ")"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << ": " << v.second << ", "; os << "}"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const unordered_map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << ": " << v.second << ", "; os << "}"; return os; }
template<typename T> void ndarray(vector<T> &vec, int len) { vec.resize(len); }
template<typename T, typename... Args> void ndarray(vector<T> &vec, int len, Args... args) { vec.resize(len); for (auto &v : vec) ndarray(v, args...); }
template<typename T> bool chmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool chmin(T &m, const T q) { if (q < m) {m = q; return true;} else return false; }
template<typename T1, typename T2> pair<T1, T2> operator+(const pair<T1, T2> &l, const pair<T1, T2> &r) { return make_pair(l.first + r.first, l.second + r.second); }
template<typename T1, typename T2> pair<T1, T2> operator-(const pair<T1, T2> &l, const pair<T1, T2> &r) { return make_pair(l.first - r.first, l.second - r.second); }
#define f first
#define s second
 
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    long long op, a, b;
    cin >> op >> a >> b;
    long long ans = op + 1;
    long long c = 0;
    if(b > 2) {
        c = (((op - (a - 1)) / 2) - 1) * (b - a);
        c += b;
        if((op - (a - 1)) % 2 == 1)
            c++;
    }
    cout << max(ans, c);
}

Measured memory_bytes: 3584
#include <bits/stdc++.h> 
using namespace std;
 
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
 
//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef long long LL;
typedef pair<long, long> PLL;
 
//container util
//------------------------------------------
#define PB emplace_back
#define MP make_pair 
#define SZ(a) int((a).size())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
#define ALL(a)  (a).begin(),(a).end()
//constant
//--------------------------------------------
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

const LL MOD=1e9+7;



int main(){
    int A,B;
    cin>>A>>B;
    if(A>=13)cout<<B<<endl;
    else if(A>=6)cout<<B/2<<endl;
    else cout<<0<<endl;
    return 0;
}


Measured memory_bytes: 256
import sys
#input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

N, M = map(int, input().split())
G = [[] for _ in range(N)]
H = [0]*N
for _ in range(M):
    x, y = map(int, input().split())
    G[x-1].append(y-1)
    H[y-1]+=1

def topological_sort(G, H):
    res = []
    st0 = set()
    for v, n in enumerate(H):
        if n == 0:
            st0.add(v)
    while st0:
        v = st0.pop()
        res.append(v)
        for nv in G[v]:
            H[nv]-=1
            if H[nv] == 0:
                st0.add(nv)
    return res
i_to_v = topological_sort(G, H)
v_to_i = [0]*N
for i in range(N):
    v_to_i[i_to_v[i]] = i
dp = [0]*N
for i in range(N-1):
    for nv in G[i_to_v[i]]:
        dp[v_to_i[nv]] = max(dp[i]+1, dp[v_to_i[nv]])
print(max(dp))






Measured memory_bytes: 27604
#include<bits/stdc++.h>
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define ri(x) scanf("%d",&(x))
#define ri2(x,y) scanf("%d %d",&(x),&(y))
#define ri3(x,y,z) scanf("%d %d %d",&(x),&(y),&(z))
#define rll(x) scanf("%lld",&(x))
#define rll2(x,y) scanf("%lld %lld",&(x),&(y))
#define rll3(x,y,z) scanf("%lld %lld %lld",&(x),&(y),&(z))
#define gc(x) ((x) = getchar())
using namespace::std;

const long double PI = acos(-1);
const long long MOD = 1000000000 +7;

typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<ll,pll> tll;
typedef pair<int,int> ii;
typedef pair<int,ii> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<ll> vll;
typedef vector<pll> vpll;
typedef vector<tll> vtll;
typedef vector<string> vs;
typedef set<int> si;
typedef set<ii> sii;
typedef set<iii> siii;

ll gcd(ll a, ll b){ return b==0?a:gcd(b,a%b);}

ll add(ll a, ll b, ll m = MOD){
	if(a >= m) a %= m;
	if(b >= m) b %= m;
	if(a < 0) a += m;
	if(b < 0) b += m;
	ll res = a+b;
	if(res >= m or res <= -m) res %= m;
	if(res < 0) res += m;
	return res;
}

ll mul(ll a, ll b, ll m = MOD){
	if(a >= m) a %= m;
	if(b >= m) b %= m;
	if(a < 0) a += m;
	if(b < 0) b += m;
	ll res = a*b;
	if(res >= m or res <= -m) res %= m;
	if(res < 0) res += m;
	return res;
}

ll pow_mod(ll a, ll b, ll m = MOD){
	ll res = 1LL;
	a = a%m;
	while(b){
		if(b&1) res = mul(res,a,m);
		b >>= 1;
		a = mul(a,a,m);
	}
	return res;
}

ll fastexp(ll a, ll b){
	ll res = 1LL;
	while(b){
		if(b&1) res = res*a;
		b >>= 1;
		a *= a;
	}
	return res;
}

int gcdExtendido(int a, int b, int *x, int *y){
	if(a == 0){
		*x = 0;
		*y = 1;
		return b;
	}
	int x1, y1;
	int gcd = gcdExtendido(b%a,a,&x1,&y1);
	
	*x = y1-(b/a)*x1;
	*y = x1;
	return gcd;
}

int modInverso(int a, int m){
	int x, y;
	int g = gcdExtendido(a,m,&x,&y);
	if(g!=1) return -1;
	else return (x%m + m)%m;
}

/****************************************
*************P*L*A*N*T*I*L*L*A************
*****************************************/

const int N = 100000+5;

int n;
int L[N];
int R[N];
set<ii> l;
set<ii> r;

ll solve(){
	ll ans = 0LL;
	int position = 0;
	for(int i=1; i<=n; i++){
		int cur;
		if(i&1){ // Go right
			cur = (*l.rbegin()).second;
			if(L[cur] < position) break; // Can't go right, stop
			ans += L[cur] - position;
			position = L[cur];
		}
		else{ // Go left
			cur = (*r.begin()).second;
			if(position < R[cur]) break; // Can't go left, stop
			ans += position - R[cur];
			position = R[cur];
		}
		l.erase(mp(L[cur],cur));
		r.erase(mp(R[cur],cur));
	}
	ans += abs(position);
	return ans;
}

int main(){
	ri(n);
	for(int i=0; i<n; i++){
		ri2(L[i],R[i]);
		l.emplace(mp(L[i],i));
		r.emplace(mp(R[i],i));
	}
	ll ans = solve();
	l.clear(); r.clear();
	for(int i=0; i<n; i++){
		L[i] = -L[i];
		R[i] = -R[i];
		if(L[i] > R[i]) swap(L[i],R[i]);
		l.emplace(mp(L[i],i));
		r.emplace(mp(R[i],i));
	}
	ans = max(ans,solve());
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 10368
/*
      author  : nishi5451
      created : 15.08.2020 12:04:08
*/

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


int main(){
    int n,x;
    cin >> n >> x;
    int ans = 0;
    for(int i=x-n+1; i<=x+n-1; i++){
        cout << i << endl;
    }

    return 0;
}

Measured memory_bytes: 3604
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstring>
//#include <unordered_set>
#include <set>
 
using namespace std;
char field[1001][1001];
bool used[1001][1001];
 
int main(){
  int H,W;
  while(cin>>H>>W&&(H|W)){
    for(int i=0;i<H;i++)
      for(int j=0;j<W;j++)
    cin>>field[i][j];
    vector<string> vs;
    for(int dy=-1;dy<=1;dy++){
      for(int dx=-1;dx<=1;dx++){
    if(dy==0&&dx==0)continue;
    memset(used,0,sizeof(used));
    for(int i=0;i<H;i++){
      for(int j=0;j<W;j++){
        if(!(i==0||j==0||i==H-1||j==W-1))continue;
        int cx=j;
        int cy=i;
        string s;
        if(used[cy][cx])continue;
        while(1){
          used[cy][cx]=true;
          s+=field[cy][cx];
          cy+=dy;cx+=dx;
          cy=(cy+H)%H;
          cx=(cx+W)%W;
          if(used[cy][cx])break;
        }
        vs.push_back(s);
        //cout<<s<<endl;
      }
    }
      }
    }
    //unordered_set<string> us;
    set<string> us;
    string cand;
    for(int i=0;i<(int)vs.size();i++){
      for(int j=0;j<(int)vs[i].size();j++){
    for(int k=1;k<=(int)vs[i].size();k++){
      string s;
      for(int l=0;l<k;l++){
        s+=vs[i][(j+l)%vs[i].size()];
      }
      if(us.count(s)==1){
        if(cand==""||cand.size()<s.size())
          cand=s;
        else if(cand.size()==s.size()&&cand>s)
          cand=s;
      }
      else if(us.count(s)==0)
        us.insert(s);
    }
      }
    }
    if(cand.size()>1)cout<<cand<<endl;
    else cout<<0<<endl;
  }
 
  return 0;
}

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

int main(){
  int a, b, c;
  int ans = 0;
  cin >> a >> b >> c;
  for(int i = a;i <= b; i++){
    if(c%i==0) ans++;
  }
  cout << ans << endl;
}





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

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vint;
typedef vector<double> vd;
typedef vector<ll> vll;
typedef vector<string> vstr;
typedef vector<vector<int>> vvint;
typedef vector<pair<int, int>> vpii;
typedef vector<pair<ll, ll>> vpll;
typedef priority_queue<int, vector<int>, greater<int>> spqint; //小さい順に取り出し
typedef priority_queue<ll, vector<ll>, greater<ll>> spqll;     //小さい順に取り出し
typedef priority_queue<int, vector<int>, less<int>> bpqint;    //大きい順に取り出し
typedef priority_queue<ll, vector<ll>, less<ll>> bpqll;        //大きい順に取り出し

#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define FOR(i, a, b) for (ll i = (ll)a; i < (ll)b; i++)
#define IREP(i, v) for (auto i = (v).begin(); i != (v).end(); i++)
#define FI first
#define SE second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define PF push_front
#define TS to_string
#define BS binary_search
#define LB lower_bound
#define UB upper_bound
#define NP next_permutation
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) (ll) x.size()
#define SP(x) setprecision((ll)x)


int INF = 1e9;
int NIL = -1;
ll MOD = 1000000007;
ll LINF = 1e18;
double EPS = 1e-9;
double PI = M_PI;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; } //最大公約数
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }     //最小公倍数

void yes(){ cout << "Yes" << endl;}
void no(){ cout << "No" << endl;}
//-----------------------------------------
vector<long long> factor_array(long long n){
    vector<long long> res ;
    for(long long i=1;i*i<=n;i++){
        if(n%i==0){
            res.push_back(i) ;
            if(i*i!=n){
                res.push_back(n/i) ;
            }
        }
    }
    sort(res.begin(),res.end()) ;
    res.pop_back() ;
    return res ;
}

//-----------------------------------------
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::chrono::system_clock::time_point start,end;
    start = std::chrono::system_clock::now();

    int n ;
    cin >> n ;
    vll a(n) ;
    REP(i,n){
        cin >> a[i] ;
    }
    sort(ALL(a)) ;
    int ans = 0 ;
    vll cnt(1000000+1,0) ;
    REP(i,n){
        cnt[a[i]]++ ;
    }
    REP(i,n){
        bool f = true; 
        vll b ;
        b = factor_array(a[i]) ;
        if(cnt[a[i]]>=2){
            f = false ;
        }
        REP(j,SZ(b)){
            if(BS(ALL(a),b[j])){
                f = false ;
            }
        }
        if(f){
            ans++ ;
        }
    }

    cout << ans <<endl;



    end = std::chrono::system_clock::now();
    auto elapsed = std::chrono::duration_cast< std::chrono::milliseconds >(end - start).count();
    //std::cout << elapsed <<"ms"<< std::endl;

    

    return 0;
}



Measured memory_bytes: 12700
# coding: utf-8
import sys
import numpy as np

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

# neg, zero, posに分けて、二分探索
N, K = lr()
A = np.array(lr()); A.sort()
neg = A[A<0]
zero = A[A==0]
pos = A[A>0]

def check(x):
    '''x以下の積がK個以上あるならTrueを返す'''
    cnt = 0  # 最後に２でわる
    if x >= 0:
        cnt += len(zero) * N
    cnt += (np.searchsorted(A, x//pos, side='right')).sum()
    cnt += (N - np.searchsorted(A, (-x-1)//(-neg), side='right')).sum()
    cnt -= np.count_nonzero(A*A <= x)
    assert cnt % 2 == 0
    return (cnt//2) >= K

ok = 10**20; ng = -10**20
while abs(ng-ok) > 1:
    mid = (ok+ng) // 2
    if check(mid):
        ok = mid
    else:
        ng = mid

print(ok)
# 30

Measured memory_bytes: 34340
// https://atcoder.jp/contests/practice2/tasks/practice2_d

#include <atcoder/all>

#include "algorithm"
#include "bitset"
#include "cmath"
#include "functional"
#include "iomanip"
#include "iostream"
#include "map"
#include "numeric"
#include "queue"
#include "set"
#include "string"
#include "vector"
#define rep(i, to) for (ll i = 0; i < (to); ++i)
#define rep1(i, to) for (ll i = 1; i <= (to); ++i)
#define repf(i, from, to) for (ll i = from; i < (to); ++i)
#define repr(i, from) for (ll i = from - 1; i >= 0; --i)
#define all(vec) vec.begin(), vec.end()
#define unless(cond) if (!(cond))
#define fi first
#define se second
using namespace std;
using namespace atcoder;
using ll = long long;
using ld = long double;
template <typename T>
using V = vector<T>;
using VL = V<ll>;
template <typename T>
using VV = V<V<T>>;
using VVL = VV<ll>;
template <typename T>
using VVV = VV<V<T>>;
template <typename T, typename U>
using P = pair<T, U>;
using PL = P<ll, ll>;
using VPL = V<PL>;
template <typename T>
using asc_pq = priority_queue<T, V<T>, greater<T>>;

template <typename T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

template <typename T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

template <typename T>
inline ll len(V<T> arr) {
  return arr.size();
}

struct exit_exception : public std::exception {
  const char* what() const throw() { return "Exited"; }
};

template <typename T>
void drop(T res) {
  cout << res << endl;
  throw exit_exception();
}

const ll INF = 1e18;

void solve();

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

  try {
    solve();
  } catch (exit_exception& e) {
  }

  return 0;
}
#endif

void solve() {
  ll H, W;
  cin >> H >> W;

  V<string> mat(H);
  rep(i, H) cin >> mat[i];

  mf_graph<ll> g(H * W + 2);

  ll S = H * W;
  ll T = H * W + 1;

  // S -> even, odd -> T
  rep(h, H) rep(w, W) {
    unless(mat[h][w] == '.') continue;

    ll u = W * h + w;

    if ((h + w) % 2 == 0) {
      g.add_edge(S, u, 1);
    } else {
      g.add_edge(u, T, 1);
    }
  }

  // even -> odd
  rep(h, H) rep(w, W) {
    unless(mat[h][w] == '.') continue;
    unless((h + w) % 2 == 0) continue;

    ll e = W * h + w;

    int dx[] = {0, 1, 0, -1};
    int dy[] = {1, 0, -1, 0};

    rep(i, 4) {
      int nh = h + dy[i];
      int nw = w + dx[i];

      unless(0 <= nh && nh < H && 0 <= nw && nw < W) continue;
      unless(mat[nh][nw] == '.') continue;

      ll o = W * nh + nw;
      g.add_edge(e, o, 1);
    }
  }

  cout << g.flow(S, T) << "\n";

  auto edges = g.edges();

  for (auto e : edges) {
    if (e.from == S || e.to == T || e.flow == 0) continue;
    ll eh = e.from / W;
    ll ew = e.from % W;
    ll oh = e.to / W;
    ll ow = e.to % W;

    if (eh + 1 == oh) {
      mat[eh][ew] = 'v';
      mat[oh][ow] = '^';
    } else if (oh + 1 == eh) {
      mat[oh][ow] = 'v';
      mat[eh][ew] = '^';
    } else if (ew + 1 == ow) {
      mat[eh][ew] = '>';
      mat[oh][ow] = '<';
    } else if (ow + 1 == ew) {
      mat[oh][ow] = '>';
      mat[eh][ew] = '<';
    }
  }

  rep(h, H) cout << mat[h] << "\n";
}


Measured memory_bytes: 6380
#include <bits/stdc++.h>
using namespace std;
int main(void){
    long long a[100010],m=1e9+7,sum=0,c=0,n;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
        if(a[i]<0) c++;
        m=min(m,abs(a[i]));
        sum+=abs(a[i]);
    }
    if(c%2==0) cout<<sum;
    else cout<<sum-2*m;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define mod 1000000007
using namespace std;
#define f(i, n) for(int i = 0; i < n; ++i)
#define pb push_back
typedef long long int ll;


void input(){
   int n; cin >> n;
   map<string, int> m;
   f(i, n){
        string s;
        cin >>s;
        sort(s.begin(), s.end());
        ++m[s];
   }
   ll ans = 0;
   for(auto &it : m){
   ll x = it.second;
      ans += (ll)((x * (x - 1)) / 2);
   }
   cout << ans << endl;
}
int main()
{
 input();
 return 0;
}


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

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

int n;
int a[100000];

int main() {
	int i;
	
	cin >> n;
	for (i = 0; i < n; i++) cin >> a[i];
	
	int g = a[0];
	for (i = 1; i < n; i++) g = gcd(g, a[i]);
	cout << g << endl;
	return 0;
}

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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define ALPHABET    (26)
#define INF         INT_MAX
#define MOD         (1000000007LL)
#define EPS         (1e-10)
#define EQ(a, b)    (abs((a)-(b)) < EPS)

using LL  = long long;

int di[] = {0, -1, 0, 1};
int dj[] = {1, 0, -1, 0};
// }}}

int main() {
    std::ios::sync_with_stdio(false);
    int n, k;cin >> n >> k;
    map<int, int> m;
    priority_queue<int> pq;
    for(int i=0;i<n;i++){
        int a;cin >> a;
        m[a]--;
    }
    for(auto kv : m){
        pq.push(kv.second);
    }
    int ans = 0;
    while(pq.size() > k){
        ans -= pq.top();
        pq.pop();
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 10744
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 2e6+7;
const ll mod = 1e9 + 9;
#define afdafafafdafaf y1;
int ar[maxn], n, m;
int ans[maxn];
int f[maxn];

char ch[maxn];
int ins = 0;
int main()
{
    scanf("%d", &n);
    scanf("%s", ch+1);
    ch[0] = '_';
    for(int i=1;i<=n;i++){
        if(ch[i] != ch[i-1])ins++;
    }
    printf("%d\n", ins);
    return 0;
}


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

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

	int N;
	cin >> N;
	if (N == 0) {
		cout << 2;
		return 0;
	}
	if (N == 1) {
		cout << 1;
		return 0;
	}
	long s = 2, t = 1, u = 0;
	for (int i = 0; i < N-1; i++) {
		u = t;
		t = s + t;
		s = u;
	}
	cout << t;
}

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

using namespace std;

int main()
{

    int n,i,c=0,f=0;
    cin>>n;
    int a[101],b[101];

    for(i=0;i<n;i++)
    {
        cin>>a[i]>>b[i];}

        for(i=0;i<n;i++)
        {
            if(a[i]==b[i])
            c++;
        else
            c=0;
        if(c==3)
        {
            cout<<"Yes\n";
           f=1;break; //return 0;

        }

        }







if(!f)
    cout<<"No\n";
    return 0;
}


Measured memory_bytes: 3620
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
#include <cmath>
#include <array>
#include <climits>

const int MAXN = 200001;

long long int solve(long long int N, long long int K)
{
    if (N % K == 0) return 0;
    else
    {
        long long int ans = N % K;
        return (long long int)std::min(K-ans, ans);
    }

}

int main()
{
    long long int N, K;
    std::cin >> N >> K;
    long long int ans = solve(N, K);

    std::cout << ans << std::endl;
    return 0;
}

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

int main(){

    int n;
    int ans=2147483647;
    cin>>n;
    vector<int> w(n);
    for(int i=0;i<n;i++){
        cin>>w[i];
    }
    for(int i=0;i<n;i++){
        int s1=0,s2=0;
        for(int j=0;j<n;j++){
            if(j<=i) s1+=w[j];
            s2+=w[j];
        }
        s2-=s1;
        ans=min(ans,abs(s2-s1));
    }
    cout<<ans<<endl;




}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <vector>
#include <algorithm>
#include <map>

int main(){
  
  int N;
  scanf("%d", &N);
  std::vector<int > L(N);
  for(int i=0; i<N; i++){
    scanf("%d", &L[i]);
  }
  std::sort(L.begin(), L.end());

  int ans = 0;
  for (int i=0; i<N-1; i++){
    for (int j=i+1; j<N; j++){
      auto itr = std::lower_bound(L.begin(), L.end(),L[i]+L[j]);
      int index = itr - L.begin();
      ans += std::max(index-1-j,0);
    }
  }
  std::cout << ans << std::endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define LL long long
#define vi vector<int>
#define srt(a) sort(a.begin(), a.end());
#define se second
#define fi first
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)

bool comp(pair<LL,LL> i1, pair<LL,LL> i2) 
{ 
    if(i1.fi*i2.se > i2.fi*i1.se) 
        return true;
    if(i1.fi*i2.se > i2.fi*i1.se && i1.fi > i2.fi)  
      return true;

    return false;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cout.precision(10);
    cout << fixed;
    LL h,n; cin>>h>>n;
    vector <pair<LL,LL> > a(n);
    forn(i,n) cin>>a[i].fi>>a[i].se;
    vector <LL> dp(h+1,1e18);
    dp[h] = 0;
    for(LL i = h; i>=0 ;i--){
      for(auto j:a){
        dp[max(0LL,i-j.fi)] = min(dp[max(0LL,i-j.fi)], dp[i] + j.se);
      }
//      for(auto j:dp) cout<<j<<" ";
  //    cout<<endl;
    }
    cout<<dp[0]<<endl;
    return 0;
}



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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}

ll nextLong() { ll x; scanf("%lld", &x); return x;}

int main2() {
  int L = nextLong();
  int R = nextLong();
  int d = nextLong();

  int ans = 0;
  for (int i = L; i <= R; i++) {
    if (i % d == 0) ans++;
  }
  cout << ans << endl;
  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}

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

long long repeat(int n,long long sum){
  if(n<0){
	return 1;
  }
  if(n>=2){
	sum=repeat(n-2,sum);
	sum=repeat(n-1,sum);
  }
  if(n==1){
	sum+=2;
  }
  if(n==0){
	sum++;
  }
  return sum;
}

int main(){
  int max=1000000007;
  int H,W,K;
  cin >> H >> W >> K;
  vector<vector<long long> >A(H+1,vector<long long>(W,0));
  A[0][0]=1;
  
  if(W==1){
	cout << 1 << endl;
	return 0;
  }
  for(int i=1;i<H+1;i++){
	A[i][0]=A[i-1][0]*repeat(W-2,0)+A[i-1][1]*repeat(W-3,0);
	A[i][0]=A[i][0]%max;
	for(int j=1;j<W-1;j++){
	  A[i][j]=A[i-1][j]*repeat(W-j-2,0)*repeat(j-1,0)
		+A[i-1][j-1]*repeat(W-j-2,0)*repeat(j-2,0)
		+A[i-1][j+1]*repeat(W-j-3,0)*repeat(j-1,0);
	  A[i][j]=A[i][j]%max;
	}
	A[i][W-1]=A[i-1][W-1]*repeat(W-2,0)+A[i-1][W-2]*repeat(W-3,0);	
	A[i][W-1]=A[i][W-1]%max;
  }

  cout << A[H][K-1] << endl;

  return 0;
}


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

/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y) {
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}
int main() {
	int n;
	cin >> n;
	int s[1010] = {0};
	vector<int> k;
	for (int i = 0; i < n; i++) {
		int a;
		cin >> a;
		s[a]++;
		k.push_back(a);
	}
	int ruiseki[1010] = { 0 };
	for (int i = 1; i < 1010;i++) {
		ruiseki[i] = ruiseki[i - 1] + s[i];
	}

	long long int sum = 0;
	sort(k.begin(), k.end());
	for (int i = 0; i < n-1; i++) {
		for (int j = i + 1; j < n; j++) {
			int a = k[j] - k[i];
			int b = k[j] + k[i];
			if (a + 1 > k[i]) {
				if (b-1 <= 1000) {
					sum = sum + ruiseki[b - 1] - ruiseki[a];
				}
				else {
					sum = sum + ruiseki[1000] - ruiseki[a];
				}
				sum = sum - 1;
			}
			else {
				if (b - 1 <= 1000) {
					sum = sum + ruiseki[b - 1] - ruiseki[a];
				}
				else {
					sum = sum + ruiseki[1000] - ruiseki[a];
				}
				sum = sum - 2;
			}
		}
	}
		cout << sum/3;
}

Measured memory_bytes: 256
import numpy as np

N, M, C = map(int, input().split())
B = np.array([int(i) for i in input().split()])
cnt = 0
for i in range(N):
    A = np.array([int(i) for i in input().split()])
    if np.dot(A, B) + C > 0:
        cnt += 1
print(cnt)

Measured memory_bytes: 12440
package main

import (
	"fmt"
	"math"
)

func main() {
	var n int
	fmt.Scan(&n)
	arr := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&arr[i])
	}
	mn := math.MaxInt32
	for i := 0; i < n - 1; i++ {
		sum1, sum2 := 0, 0
		for j := 0; j < n; j++ {
			if i < j {
				sum1 += arr[j]
			} else {
				sum2 += arr[j]
			}
		}
		if abs(sum1 - sum2) < mn {
			mn = abs(sum1 - sum2)
		}
	}
	fmt.Println(mn)
}

func abs(x int) int {
	return int(math.Abs(float64(x)))
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <sstream>
using namespace std;

#define REP(i,a,n) for(i=a; i<n; i++)
#define rep(i,n) REP(i,0,n)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define foreach(it,x) for(typeof(x.begin()) it=x.begin(); it!=x.end(); it++)

map<string,char> btos;

void init(){
    btos["101"] = ' ';
    btos["000000"] = '\'';
    btos["000011"] = ',';
    btos["10010001"] = '-';
    btos["010001"] = '.';
    btos["000001"] = '?';
    btos["100101"] = 'A';
    btos["10011010"] = 'B';
    btos["0101"] = 'C';
    btos["0001"] = 'D';
    btos["110"] = 'E';
    btos["01001"] = 'F';
    btos["10011011"] = 'G';
    btos["010000"] = 'H';
    btos["0111"] = 'I';
    btos["10011000"] = 'J';
    btos["0110"] = 'K';
    btos["00100"] = 'L';
    btos["10011001"] = 'M';
    btos["10011110"] = 'N';
    btos["00101"] = 'O';
    btos["111"] = 'P';
    btos["10011111"] = 'Q';
    btos["1000"] = 'R';
    btos["00110"] = 'S';
    btos["00111"] = 'T';
    btos["10011100"] = 'U';
    btos["10011101"] = 'V';
    btos["000010"] = 'W';
    btos["10010010"] = 'X';
    btos["10010011"] = 'Y';
    btos["10010000"] = 'Z';
}

string ctob(char c){
    int n = ('A'<=c && c<='Z' ? c - 'A' : c==' ' ? 26 : c=='.' ? 27 : c==',' ? 28 :
             c=='-' ? 29 : c=='\'' ? 30 : 31);
    string res = "00000";
    int i = 0;
    //printf("c=%c, n=%d\n",c,n);
    while( n > 0 ){
        res[i++] = n % 2 + '0';
        n /= 2;
    }
    reverse(all(res));
    return res;
}

int main(){
    int i,j;
    string in;

    init();

    while( getline(cin,in) ){
        string bin,res;

        rep(i,in.size()){
            bin += ctob(in[i]);
        }

        int base = 0;
        for(i=0; i+base<bin.length()+1; ){
            string tmp = bin.substr(base, i);
            if( btos.count(tmp) ){
                res += btos[tmp];
                base += tmp.length();
                i = 1;
            }
            else{
                i++;
            }
            //printf("base=%d, i=%d, tmp=%s\n",base,i,tmp.c_str());
        }

        cout << res << endl;
    }

    return 0;
}

Measured memory_bytes: 0
#template
def inputlist(): return [int(j) for j in input().split()]
from collections import Counter
#template
#issueから始める
N = int(input())
L = inputlist()
L.sort()
ans = 0
from bisect import bisect_left
for i in range(N-2):
    for j in range(i+1,N-1):
        lia = L[j+1:]
        indexa = bisect_left(lia,L[i]+L[j])
        ans += indexa
print(ans)

Measured memory_bytes: 57608
#include <bits/stdc++.h>
using namespace std;
void dfs(int node,int parent,vector<int>ar[],int depth[],bool visited[]){
	visited[node]=true;
	if(ar[node].empty()){
		depth[node]=0;
		return;
	}
	if(depth[node])
		return;
	int m=0;
	for(int child:ar[node]){
		if(child==parent)
			continue;
		dfs(child,node,ar,depth,visited);
		m=max(m,depth[child]+1);
	}
	depth[node]=m;
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0),cout.tie(0);
	int n,m;
	cin>>n>>m;
	vector<int> ar[n+1];
	while(m--){
		int a,b;
		cin>>a>>b;
		ar[a].push_back(b);
	}
	int depth[n+1];
	bool visited[n+1];
	for(int i=0;i<=n;i++){
		depth[i]=0;
		visited[i]=false;
	}
	for(int i=1;i<=n;i++){
		if(!visited[i])
			dfs(i,-1,ar,depth,visited);
	}
	int ans=0;
	for(int i=0;i<=n;i++)
		ans=max(ans,depth[i]);
	cout<<ans<<"\n";
}

Measured memory_bytes: 10368