akhauriyash/Code-Regression huggingface dataset:
#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 ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
  string s; cin >> s;
  REP(i, s.size()) {
    if (s[i] == ',') s[i] = ' ';
  }
  cout << s << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)){
			while(sc.hasNext()) {
				String str = sc.nextLine();
				if(str.equals("END OF INPUT")) break;
				String []words = str.split(" ");
				for(int i=0; i<words.length; i++) {
					System.out.print(words[i].length());
				}
				System.out.println();
			}
		}
	}
}


Measured memory_bytes: 26244
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import java.util.HashSet;
import java.util.NoSuchElementException;

public class Main {

	final long MOD = (long) 1e9 + 7;

	void run() {
		FastScanner sc = new FastScanner();
		String[] day = new String[] { "SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT" };
		int[] a = new int[] { 7, 6, 5, 4, 3, 2, 1 };
		String S = sc.next();
		for (int i = 0; i < day.length; ++i) {
			if (S.equals(day[i])) {
				System.out.println(a[i]);
			}
		}
	}

	public static void main(String[] args) throws FileNotFoundException {
		new Main().run();
	}

	void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}
}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}

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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

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

#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

int H, W, N;
int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  cin >> H >> W >> N;
  VI xs(N);
  REP(i,N) cin >> xs[i];

  VVI ans(H, VI(W));
  int it = 0;
  REP(i,N){
	while(xs[i]--){
	  int x = it / H;
	  int y = it % H;
	  if(x % 2)
		y = H - 1 - y;
	  ans[y][x] = i+1;
	  ++it;
	}
  }
  
  REP(y,H){
	REP(x,W) cout << (x?" ":"") << ans[y][x];
	cout << endl;
  }

  return 0;
}


Measured memory_bytes: 384
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <cmath>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <complex>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <list>
#include <unordered_map>

using namespace std;

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

	vector<int> A((int)N);
	for (int i = 0; i < N; ++i) {
		cin >> A[i];
	}

	bool win = 1;
	for (int i = 0; i <= N; ++i)
	{
		if (A[i] % 2 == 1) break;
		if (i == N) win = 0;
	}

	if (win) cout << "first" << std::endl;
	else cout << "second" << std::endl;

	return 0;
}

Measured memory_bytes: 640
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
import time,random

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)


def main():
    n,k = LI()
    a = LI()
    c = collections.defaultdict(lambda: inf)
    c[(0,0)] = 0
    for t in a:
        nc = collections.defaultdict(lambda: inf)
        for ck,cv in c.items():
            k1,k2 = ck
            if k1 >= t:
                if nc[(t,k2)] > cv:
                    nc[(t,k2)] = cv
            else:
                if nc[(t,k2)] > cv + t-k1:
                    nc[(t,k2)] = cv + t-k1
            if k2 < k:
                if nc[(k1,k2+1)] > cv:
                    nc[(k1,k2+1)] = cv
        c = nc

    return min(c.values())


print(main())




Measured memory_bytes: 164060
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
  let stdin = stdin();
  let stdin = stdin.lock();
  let token: String = stdin
    .bytes()
    .map(|c| c.expect("failed to read char") as char)
    .skip_while(|c| c.is_whitespace())
    .take_while(|c| !c.is_whitespace())
    .collect();
  token.parse().ok().expect("failed to parse token")
}

use std::cmp::{max, min};

fn main() {
  let a = read::<i32>();
  let mut ans = 0;

  if a % 2 == 0 {
    ans = (a / 2).pow(2)
  } else {
    ans = ((a - 1) / 2) * ((a + 1) / 2)
  }

  println!("{}", ans);

}



Measured memory_bytes: 4352
#include "bits/stdc++.h"
using namespace std;
using ll     = long long;
using pii    = pair<int, int>;
using pll    = pair<ll, ll>;
using vi     = vector<int>;
using vl     = vector<ll>;
using vvi    = vector<vi>;
using vvl    = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}
template <class C>
void print(const C &c, std::ostream &os = std::cout) {
    std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, " "));
    os << std::endl;
}

int main() {
    int h, w, d;
    cin >> h >> w >> d;
    vector<pii> a(h * w);
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            int aa;
            cin >> aa;
            aa--;
            a[aa].first  = i;
            a[aa].second = j;
        }
    }
    int q;
    cin >> q;
    vi l(q), r(q);
    for (int i = 0; i < q; ++i) {
        cin >> l[i] >> r[i];
    }
    vi magic(h * w, 0);
    for (int i = 0; i < h * w; ++i) {
        if (i + d >= h * w)
            continue;
        magic[i + d] = magic[i] + abs(a[i + d].first - a[i].first) + abs(a[i + d].second - a[i].second);
    }
    for (int i = 0; i < q; ++i) {
        cout << magic[r[i] - 1] - magic[l[i] - 1] << "\n";
    }
    return 0;
}

Measured memory_bytes: 2944
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

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

Measured memory_bytes: 256
<?php

fscanf(STDIN, "%d", $n);

$array = explode(" ", trim(fgets(STDIN)));

$half = intdiv($n, 2);

for($i=$n-1;$i>$half;$i--){

    if($array[$i] == 1){
        $box[$i+1] = $i+1;
    }

}
for($i = $n; $i >0; $i--){
    $check = ($i+1)*2;
    $flag = 0;
    while($check <= $n){
        $flag = ($flag + (isset($box[$check])?1:0))%2;
        $check = $check + ($i+1);
    }
    if(($flag && $array[$i] == 0) || (!$flag && $array[$i] == 1)){
        $box[$i+1] = $i+1;
    }
}
if(isset($box)) {
    $m = count($box);
}else{
    $m = 0;
    $p = 1;
}
$num = $m % 2;
if($array[0] == 1){
    if($num == 0){
        $box[1] = 1;
        $m++;
    }
}elseif($num == 1){
    $box[1] = 1;
    $m++;
}

echo $m.PHP_EOL;
if($m != 0){
    asort($box);
    echo implode(" ", $box);
}



Measured memory_bytes: 25328
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld =long double;
const ld eps = 1e-9;

bool check(const vector<vector<pair<int, int>>>&humans, int x, int y) {
	for (int i = 0; i < 4; ++i) {
		auto it=find(humans[i].begin(),humans[i].end(),make_pair(x,y));
		if(it!=humans[i].end())return false;
	}
	return true;
}

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

struct aa {
	int now;
	int cost;
	bool flag;
};
bool operator<(const aa&l, const aa&r) {
	return l.cost>r.cost;
}

int main()
{
	while (true) {
		int N,M;cin>>N>>M;
		if(!N)break;
		vector<vector<pair<int,int>>>edges(N);
		for (int i = 0; i < M; ++i) {
			int a,b,c;cin>>a>>b>>c;
			a--;b--;
			edges[a].push_back(make_pair(b,c));
			edges[b].push_back(make_pair(a,c));
		}
		vector<vector<int>>plus_edges(N);
		for (int i = 0; i < N; ++i) {
			for (auto e1 : edges[i]) {
				for (auto e2 : edges[i]) {
					if(e1==e2)continue;
					else {
						plus_edges[e1.first].push_back(e2.first);
						plus_edges[e2.first].push_back(e1.first);
					}
				}
			}
		}
		priority_queue<aa>que;
		vector<vector<int>>memo(N,vector<int>(2,1e9));
		memo[0][0]=0;
		que.push(aa{ 0,0,0 });
		while (!que.empty()) {
			auto atop(que.top());
			que.pop();
			for (auto e : edges[atop.now]) {
				const int next=e.first;
				const int next_cost=atop.cost+e.second;

				if (memo[next][atop.flag] > next_cost) {
					memo[next][atop.flag]=next_cost;
					que.push(aa{ next,next_cost,atop.flag });
				}
			}
			if (atop.flag == false) {
				for (auto pe : plus_edges[atop.now]) {
					if (memo[pe][true] > atop.cost) {
						memo[pe][true]=atop.cost;
						que.push(aa{ pe,atop.cost,true });
					}
				}
			}
		}
		int ans=min(memo[N-1][0],memo[N-1][1]);
		cout<<ans<<endl;
	}
	return 0;
}


Measured memory_bytes: 3152
import sys
input = sys.stdin.readline
from operator import itemgetter
sys.setrecursionlimit(10000000)
INF = 10**30
from collections import defaultdict

def main():
    n = int(input().strip())
    d = defaultdict(int)
    for i in range(1, n+1):
        ds = str(i)
        d[(ds[0], ds[-1])] += 1
    ans = 0
    for i in range(1, 10):
        for j in range(1, 10):
            si = str(i)
            sj = str(j)
            ans += d[(si, sj)] * d[(sj, si)]
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 40428
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); ++i)
#define reps(i,f,n) for(int i=(f); i<=(n); ++i)
#define outl(x) cout<< (x) << '\n'
#define FAST() cin.tie(0), ios::sync_with_stdio(false)

int main()
{
    FAST();
    int a,b, r;
    cin >> a >> b;
    outl(__gcd(a,b));

}

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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

template<class T>
bool ChangeMax(T&a,const T&b){
  if(a >= b) return false;
  a = b;    return true;
}

template<class T>
bool ChangeMin(T&a,const T&b){
  if(a <= b) return false;
  a = b;    return true;  
}

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v)is >> e;
  return is;
}

template<long long mod>
class modint{
private:
  long long num;
  long long extgcd(long long a, long long b, long long&x, long long&y)const {
    long long d = a;
    if(b != 0){d = extgcd(b, a%b, y, x);  y -= (a/b) * x;}
    else{x = 1; y = 0;}
    return d;
  }
  long long modinverse()const{
    long long x, y;
    extgcd(num, mod, x, y);
    return (mod + x%mod)%mod;
  }
public:
  modint():num(0){}
  modint(const long long x):num((x < 0?(x+mod):x)%mod ){}
  friend modint operator+(const modint&a, const modint&b)
  {    return modint(a.num + b.num);  }
  friend modint operator-(const modint&a, const modint&b)
  {    return modint(a.num - b.num);  }
  friend modint operator*(const modint&a, const modint&b)
  {    return modint(a.num * b.num);  }
  friend modint operator/(const modint&a, const modint&b)
  {    return modint(a*b.modinverse());  }
  modint& operator+=(const modint&b)
  {    return (*this) = (*this) + b;  }
  modint& operator-=(const modint&b)
  {    return (*this) = (*this) - b;  }
  modint& operator*=(const modint&b)
  {    return (*this) = (*this) * b;  }
  modint& operator/=(const modint&b)
  {    return (*this) = (*this) / b;  }
  modint& operator++()
  {    (*this)+=1; return (*this);  }
  modint& operator--()
  {    (*this)-=1; return (*this);  }
  modint operator++(int){
    modint tmp(*this);
    ++(*this);
    return tmp;
  }
  modint operator--(int){
    modint tmp(*this);
    --(*this);
    return tmp;
  }    
  modint pow(unsigned long long i){
    if(i == 0) return 1;
    if(i & 1){
      return (*this) * (this->pow(i-1));
    }
    modint<mod>hpow = (this->pow(i>>1));
    return hpow * hpow;
  }
  friend ostream& operator<<(ostream&os, const modint&a){
    os << a.num;
    return os;
  }
  friend istream& operator>>(istream&is, modint&a){
    long long x; is >> x;
    a = x;
    return is;
  }
};
constexpr int mod = 1'000'000'007;
using mint = modint<mod>;

int main(){
  int n; cin >> n;
  vector<int> v(n); cin >> v;
  mint sum = 0;
  for(auto e:v)sum += e;
  mint ans = 0;
  for(int i = 0; i < n; ++i){
    ans += (sum-v[i]) * v[i];
  }
  cout << ans/2 << endl;
  return 0;
}


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

int main()
{

    deque<long long> D{1, 2, 3, 4, 5, 6, 7, 8, 9};

    int N;
    cin>>N;
    for (int i = 1; i < N; i++)
    {
        long long tmp = D.front();
        D.pop_front();
        if (tmp % 10 != 0)
        {
            D.push_back(10 * tmp + tmp % 10 - 1);
        }
        D.push_back(10 * tmp + tmp % 10);
        if (tmp % 10 != 9)
        {
            D.push_back(10 * tmp + tmp % 10 + 1);
        }
    }
    cout << D.front() << endl;
}

Measured memory_bytes: 5112
#include <bits/stdc++.h>
using namespace std;
int dp[4001][4001];
int main(){
	string a,b;
	while(true){
		cin>>a>>b;
		if(cin.eof())	return 0;
		memset(dp,0,sizeof(dp));
		int ans=0;
		for(int i=0;i<(int)a.size();i++){
			for(int j=0;j<(int)b.size();j++){
				if(a[i]==b[j]){
					if(i*j==0)	dp[i][j]=1;
					else 	dp[i][j]=dp[i-1][j-1]+1;
					ans=max(ans,dp[i][j]);
				}
			}
		}
		cout<<ans<<endl;
	}
	return 0;
}

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

using namespace std;
using ll = long long;
using v1 = vector<int>;
using v2 = vector<vector<int>>;
using v3 = vector<vector<char>>;

int main(){
	int n;
	cin >> n;
	v1 a(n+1);
	rep(i,n){
		cin >> a[i+1];
	}
	for(int i = 1; i<n+1; i++){
		int b = i*2;
		int c = i*2 +1;
		int p = i/2;
		cout << "node " << i << ": key = " << a[i] << ", ";
		if(p >0) cout <<"parent key = " << a[p] << ", ";
		if(b <=n) cout << "left key = " << a[b] << ", ";
		if(c<=n) cout << "right key = " << a[c] << ", ";
		cout <<endl;
	}
}



Measured memory_bytes: 3104
#include <iostream>
#include <stdio.h>
using namespace std;

int main()
{
	int car[10],order[100],i,j,k=0;
	
	for(i=0; i<10; i++){car[i]=0;}
	i=0;
	while((scanf("%d",&order[i]))!=EOF){i++;}
	for(j=0; j<i; j++){
		if(order[j]!=0){
			car[k]=order[j];
			k++;
		}else{
			k--;
			cout << car[k] << endl;
			car[k]=0;
		}
	}
}

Measured memory_bytes: 1208
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;
static const int MAX = 200000;

int main()
{
	string s0, s1, s2;
	cin >> s0 >> s1 >> s2;

	if (s0.back() == s1[0] && s1.back() == s2[0]) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}

    return 0;
}

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

int main() {
    long long int a[3];
    cin >> a[0] >> a[1] >> a[2];
    if(a[0]%2 == 0 || a[1]%2 == 0 || a[2]%2 == 0) {
        cout << 0 << '\n';
    } else {
        sort(a, a+3);
        cout << ((a[2] - a[2]/2)*a[1]*a[0] - (a[2]/2)*a[1]*a[0]) << '\n';
    }
    
    return 0;
}


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

int main() {
    string s;
    cin>>s;
    if(s=="Sunny"){
        cout<<"Cloudy"<<endl;
    }
    else if(s=="Cloudy"){
        cout<<"Rainy"<<endl;
    }
    else {
        cout<<"Sunny"<<endl;
    }
}

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

ans = 0
if A[0] > x:
    ans += A[0] - x
    A[0] = x

for i in range(1,N):
    if A[i] + A[i-1] > x:
        tmp = A[i] + A[i-1] - x
        ans += tmp
        A[i] -= tmp

print(ans)

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

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif

	int n, m, c, a;
	cin >> n >> m >> c;
	vector<int> b;
	for(int i = 0; i < m; i++) {
		cin >> a;
		b.push_back(a);
	}
	int cnt = 0;
	for(int i = 0; i < n; i++) {
		int sum = c;
		for(int i = 0; i < m; i++) {
			cin >> a;
			sum += b[i] * a;
		}
		if(sum > 0) cnt += 1;
	}
	cout << cnt;
	return 0;
}

Measured memory_bytes: 3640
#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 FORR(i, m, n) for (int i = m; i >= n; i--)
#define pb(a) push_back(a)
using namespace std;
typedef long long ll;

int main()
{
    int N, M;
    cin >> N >> M;
    vector<pair<ll, ll>> data(N);

    ll a, b;
    REP(i, N)
    {
        cin >> a >> b;
        data.at(i) = make_pair(a, b);
    }

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

    ll ans = 0;
    REP(i, N)
    {
        if (data.at(i).second < M)
        {
            ans += data.at(i).first * data.at(i).second;
            M -= data.at(i).second;
        }
        else
        {
            ans += M * data.at(i).first;
            break;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using ll = long long;
int main()
{
    int N, K, Q;
    std::cin >> N >> K >> Q;
    std::vector<ll> A(N);
    std::map<ll, std::vector<int>> mp;
    for (int i = 0; i < N; i++) { std::cin >> A[i], mp[A[i]].push_back(i); }
    auto B = A;
    std::sort(B.begin(), B.end());
    std::vector<bool> ok(N, true);
    ll ans = 1LL << 60;
    for (int i = 0; i < N; i++) {
        const ll L = (i == 0 ? -1 : B[i - 1]);
        for (const auto e : mp[L]) { ok[e] = false; }
        std::vector<ll> v;
        std::vector<ll> buf;
        buf.reserve(N);
        for (int pos = 0; pos < N; pos++) {
            if (ok[pos]) {
                buf.push_back(A[pos]);
            } else {
                if (buf.size() > K - 1) {
                    std::sort(buf.begin(), buf.end());
                    for (int i = 0; i < buf.size() - K + 1; i++) { v.push_back(buf[i]); }
                }
                buf.clear();
            }
        }
        if (buf.size() > K - 1) {
            std::sort(buf.begin(), buf.end());
            for (int i = 0; i < buf.size() - K + 1; i++) { v.push_back(buf[i]); }
        }
 
        if (v.size() < Q) { continue; }
        std::sort(v.begin(), v.end());
        ans = std::min(ans, v[Q - 1] - B[i]);
    }
    std::cout << ans << std::endl;
 
    return 0;
}

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

vector<vector<int>> p;

void warshall_floyd(int n, vector<vector<int>> &d) {
  for (int k = 0; k < n; k++){
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
      }
    }
  }
}

void dfs(vector<int> head,vector<int> rest){
  if(rest.size()==0) p.push_back(head);
  else{
    for (int i = 0; i < (int)rest.size(); i++)
    {
      vector<int> restx = rest;
      vector<int> headx = head;
      headx.push_back(rest[i]);
      restx.erase(restx.begin()+i);
      dfs(headx,restx);
    }
  }
}

int main(){
  int n,m,R;
  cin >> n >> m >> R;

  vector<int> r(R);
  for (int i = 0; i < R; i++){
    int ri;
    cin >> ri;
    r[i]=ri-1;
  }
  
  vector<vector<int>> d(n,vector<int>(n,1000000000));
  for (int i = 0; i < m; i++)
  {
    int a,b,c;
    cin >> a >> b >> c;
    d[a-1][b-1] = c;
    d[b-1][a-1] = c;
  }

  warshall_floyd(n,d);

  vector<int> head;
  dfs(head,r);

  int ans = 1000000000;
  for (int i = 0; i < (int)p.size(); i++)
  {
    int sum = 0;
    for (int j = 0; j < R-1; j++)
    {
      int from = p[i][j];
      int to = p[i][(j+1)];
      sum += d[from][to];
    }
    ans = min(ans,sum);
  }

  cout << ans << endl;
}

Measured memory_bytes: 3512
using System;
using System.Linq;
using System.Collections.Generic;

namespace B
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var d = Console.ReadLine().Split().Select(int.Parse).ToArray();

            var ans = 0L;

            for (int i = 0; i < n - 1; i++)
            {
                var count = 0L;
                for (int j = i + 1; j < n; j++)
                {
                    count +=d[i]*d[j];
                }
                ans += count;
            }
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 13268
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <limits>

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> PII;
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 EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18


int main() {

	string s; cin >> s;
	int l = s.size();
	
	LL ans = 0;
	//仕切り線の部分集合を全列挙
	for (int bit = 0; bit < (1 << l-1); ++bit) {

		LL num = s[0] - '0';
		
		for (int j = 0; j < l-1; j++) {
			//仕切りが立ってれば、そこで数字が切れるので精算
			if (bit&(1 << j)) {
				ans += num;
				num = 0;
			}

			//現在の値を加える
			//s[j+1]で仕切りの右隣の文字を取得
			num = num * 10 + s[j + 1] - '0';
		}

		//残ってるのを回収
		ans += num;
	}

	cout << ans << endl;


	return 0;
}

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





int main(){
   int h,w;
   cin>>h>>w;
   int m=0;
   char a[1010][1010];
   int b[1010][1010];
   rep(i,h){
      rep(j,w){
         cin>>a[i][j];
         b[i][j]=101010;
         if(a[i][j]=='#')b[i][j]=0;
      }
   }
   
   rep(j,w){
      int n=101010;
      rep(i,h){
         n++;
         if(a[i][j]=='#'){
            n=min(b[i][j],n);
         }
         b[i][j]=min(b[i][j],n);
         if(b[i][j]!=101010)a[i][j]='#';
      }
      n=101010;
      repr(i,h){
         n++;
         if(a[i][j]=='#'){
            n=min(b[i][j],n);
         }
         b[i][j]=min(b[i][j],n);
         if(b[i][j]!=101010)a[i][j]='#';
      }
   }

 

   rep(i,h){
      int n=101010;
      rep(j,w){
         n++;
         if(a[i][j]=='#'){
            n=min(b[i][j],n);
         }
         
         b[i][j]=min(b[i][j],n);
         if(b[i][j]!=101010)a[i][j]='#';
      }
      n=101010;
      repr(j,w){
         n++;
         if(a[i][j]=='#'){
            n=min(b[i][j],n);
         }
         b[i][j]=min(b[i][j],n);
         if(b[i][j]!=101010)a[i][j]='#';
      }
   }
  


   rep(j,w){
      int n=101010;
      rep(i,h){
         n++;
         if(a[i][j]=='#'){
            n=min(b[i][j],n);
         }
         b[i][j]=min(b[i][j],n);
         if(b[i][j]!=101010)a[i][j]='#';
      }
      n=101010;
      repr(i,h){
         n++;
         if(a[i][j]=='#'){
            
            n=min(b[i][j],n);
         }
         b[i][j]=min(b[i][j],n);
         if(b[i][j]!=101010)a[i][j]='#';
      }
   }
   m=0;
   rep(i,h)rep(j,w)m=max(m,b[i][j]);
   cout<<m<<endl;
}



Measured memory_bytes: 5248
from collections import defaultdict

n, x, y = map(int, input().split())

d = defaultdict(int)

for i in range(1, n):
    for j in range(i + 1, n + 1):
        a = j - i
        b = abs(x - i) + 1 + abs(y - j)
        d[min(a, b)] += 1

for i in range(1, n):
    print(d[i])

Measured memory_bytes: 3956
#include<bits/stdc++.h>
using namespace std;
int a[33]={0,1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
int main()
{
	int k;
	cin>>k;
	cout<<a[k];
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}
#ifdef __LOCAL
#define debug(x) cerr << __LINE__ << ": " << #x << " = " << x << endl
#define debugArray(x, n)                           \
  cerr << __LINE__ << ": " << #x << " = {";        \
  for (long long hoge = 0; (hoge) < (n); ++(hoge)) \
    cerr << ((hoge) ? "," : "") << x[hoge];        \
  cerr << "}" << endl
#else
#define debug(x) (void(0))
#define debugArray(x, n) (void(0))
#endif

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int A, B;
  cin >> A >> B;
  if (A < B) swap(A, B);
  cout << A + max(A - 1, B) << '\n';
  return 0;
}


Measured memory_bytes: 3652
#include<iostream>
using namespace std;
int main(){
	int n,a;
	cin>>n;
	a=n%10;
	if(a==2 || a==4 || a==5 || a==7 || a==9){
		cout<<"hon"<<endl;
	}else if(a==0 || a==1 || a==6 || a==8){
		cout<<"pon"<<endl;
	}else{
		cout<<"bon"<<endl;
	}
	return 0;
}

Measured memory_bytes: 3128
n = gets.to_i
h = [*0...26].zip([*'a'..'z']).to_h
r = ([*'0'..'9'] + [*'a'..'p']).zip([*0...26]).to_h
size = (n - 1).to_s(26).size

a = (n - 1).to_s(26).chars.map.with_index { |e, idx| idx == size - 1 ? r[e] : r[e] - 1 }
size = a.size

size.times do |i|
  if a[-1 - i] < 0 && i != size - 1
    a[-1 - i - 1] -= 1
    a[-1 - i] += 26
  end
end

puts a.map { |e| h[e] }.join

Measured memory_bytes: 14412
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,s,n) for(int i=(s); i<(n); i++)
#define all(v) v.begin(),v.end()
#define res(n) resize(n)
#define rev(v) reverse(v.begin(),v.end())
#define sor(v) sort(v.begin(),v.end())
#define outve(v) for(auto i : v) cout << i << " ";cout << endl
#define in(n,v) for(int i=0; i<(n); i++){cin >> v[i];}
#define out(n) cout << (n) << endl
#define fi first
#define se second
#define ve vector
#define pq priority_queue
using namespace std;
typedef long long ll;
typedef long double ld;
const ll mod = 1000000007;



int main()
{
    
    int K;
    cin >> K;
    
    ve<ll> A(K);
    in(K,A);
    rev(A);
    if(A[0] != 2) {out(-1);return 0;}
    ll minA = 2,maxA = 3;
    
    reps(i,1,K){
        //cout << A[i] << " " << minA << " " << maxA << endl;
        ll a = maxA/A[i],mm = maxA;
        if(a*A[i] >= minA && a*A[i] <= maxA) maxA = a*A[i]+A[i]-1;
        else {out(-1);return 0;}

        if(minA%A[i] == 0) continue;
        else{
            ll b = minA/A[i];
            if((b+1)*A[i] >= minA && (b+1)*A[i] <= mm) minA = (b+1)*A[i];
            else {out(-1);return 0;}
        }
        
        //cout << A[i] << " " << minA << " " << maxA << endl;
    }

    cout << minA << " " << maxA << endl;

  
    
    return 0;
}


Measured memory_bytes: 1152
// use std::ops::{Index, IndexMut};
// use std::cmp::{Ordering, min, max};
// use std::collections::{BinaryHeap, BTreeMap};
// use std::collections::btree_map::Entry::{Occupied, Vacant};
// use std::clone::Clone;

fn getline() -> String{
    let mut res = String::new();
    std::io::stdin().read_line(&mut res).ok();
    res
}

macro_rules! readl {
    ($t: ty) => {
        {
            let s = getline();
            s.trim().parse::<$t>().unwrap()
        }
    };
    ($( $t: ty),+ ) => {
        {
            let s = getline();
            let mut iter = s.trim().split(' ');
            ($(iter.next().unwrap().parse::<$t>().unwrap(),)*) 
        }
    };
}

macro_rules! readlvec {
    ($t: ty) => {
        {
            let s = getline();
            let iter = s.trim().split(' ');
            iter.map(|x| x.parse().unwrap()).collect::<Vec<$t>>()
        }
    }
}

macro_rules! mvec {
    ($v: expr, $s: expr) => {
        vec![$v; $s]
    };
    ($v: expr, $s: expr, $($t: expr),*) => {
        vec![mvec!($v, $($t),*); $s]
    };
}

macro_rules! debug {
    ($x: expr) => {
        println!("{}: {:?}", stringify!($x), $x)
    }
}

fn printiter<'a, T>(v: &'a T)
where
    &'a T: std::iter::IntoIterator, 
    <&'a T as std::iter::IntoIterator>::Item: std::fmt::Display {
    for (i,e) in v.into_iter().enumerate() {
        if i != 0 {
            print!(" ");
        }
        print!("{}", e);
    }
    println!("");
}

fn main() {
    let n = readl!(usize);
    let a = readlvec!(i64);
    let x = (n as i64)*(n as i64+1)/2;
    let sum: i64 = a.iter().sum();
    if sum%x != 0 {
        println!("NO");
    } else {
        let num = sum/x;
        // debug!(num);
        let mut ans = "YES";
        let ad = {
            let mut res = Vec::with_capacity(n);
            for i in 0..n-1 {
                res.push(a[i+1]-a[i]);
            }
            res.push(a[0]-a[n-1]);
            res = res.into_iter().map(|x| x-num).collect();
            res
        };
        // debug!(ad);
        for e in &ad {
            if !(*e <= 0 && *e%n as i64 == 0) {
                ans = "NO";
            }
        }
        println!("{}", ans);
    }
    
}



Measured memory_bytes: 8444
#include <bits/stdc++.h>
using namespace std;
#define dump(x) cout << (x) << endl
typedef long long ll;
typedef vector<int> V;

int main() {
  int a, b;
  cin >> a >> b;
  dump(a%2 && b%2 ? "Yes" : "No");
  return 0;
}


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

int main() {
    string o, e; cin >> o >> e;
    string ans("");
    for (int i = 0; i < (int)e.size(); i++) {
        ans.push_back(o[i]);
        ans.push_back(e[i]);
    }
    if (o.size() != e.size()) ans.push_back(o[o.size() - 1]);
    cout << ans << endl;
}


Measured memory_bytes: 256
n = int(input())
sp = {}
for i in range(n):
    s, p = input().split()
    if s in sp:
        sp[s].append([int(p), i+1])
    else:
        sp[s] = []
        sp[s].append([int(p), i+1])
        
for i in sp.keys():
    sp[i].sort(reverse=True)
sp = sorted(sp.items(), key=lambda x:x[0])

for i in sp:
    for j in i[1]:
        print(j[1])

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

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

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

typedef long long ll;
typedef pair<int,int> P;
int dx[] = {-1, 1, 0,  0};
int dy[] = { 0, 0, 1, -1};
 
int main(){
  int n;
  cin >> n;
  int a[n];
  for(int i=0; i<n; i++) cin >> a[i];
  sort(a, a+n);
  int ma = a[n-1];
  int ha = (ma/2) + (ma%2);
  int tmp = abs(ha -a[0]);
  int mia = a[0];
  for(int i=0; i<n-1; i++){
    if(tmp>abs(ha -a[i])){
      mia = a[i];
      tmp = abs(ha -a[i]);
    }
  }
  cout << ma << " " << mia << endl;
  return 0;
}


Measured memory_bytes: 640
#include "bits/stdc++.h"

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)

using namespace std;
const long long INF = 1LL << 61;
const int MOD = 2019;

int main() {
	int N; cin >> N;
	vector<int> A(N);
	rep(i, N)cin >> A[i];
	vector<long long> d(N, 0);
	rep(i, N) {
		if (i % 2 == 0)d[0] += A[i];
		else d[0] -= A[i];
	}
	//cout << d[0] << endl;
	rep(i, N - 1) {
		d[i + 1] = (long long)2 * A[i] - d[i];
	}
	rep(i, N)cout << d[i] << " ";
}

Measured memory_bytes: 2432
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
typedef complex<double> P;
const int MAX_N = 1000000001;

int eulers_phi(int N){
  int ret = N;
  for(int i = 2; i * i <= N; ++i){
    if(!(N % i)){
      ret -= ret / i;
      while(!(N % i)) N /= i;
    }
  }
  if(N > 1) ret -= ret / N;
  return ret;
}

int main() {
  int N; cin >>N;
  cout <<eulers_phi(N) <<endl;
  return 0;
}

Measured memory_bytes: 1164
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()


int main(){
    ll N, cntR, cntB, cntG, cnt;
    ll sum;
    cin >> N;
    string box;
    cin >> box;
    cntR = 0;
    cntB = 0;
    cntG = 0;
    cnt = 0;
    for(ll i = 0; i < N; i++){
        if(box.at(i) == 'R'){
            cntR++;
        }
        if(box.at(i) == 'G'){
            cntG++;
        }
        if(box.at(i) == 'B'){
            cntB++;
        }
    } 
    for(ll i = 0; i < N-2; i++){
        for(ll j = 1; i + 2*j < N; j++){
            if(box.at(i) != box.at(i + j) && box.at(i) != box.at(i + 2 * j) && box.at(i + 2*j) != box.at(i + j)){
                cnt++;
            }
        }

    } 

    sum = cntR * cntB * cntG - cnt;
    cout << sum << endl;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
#ifdef _WIN32
#include "debug.hpp"
#endif
using namespace std;

#define rep(i, N)  for(int i = 0; i < (N); i++)
#define reps(i, N) for(int i = 1; i <= (N); i++)
#define repr(i, N) for(int i = (N) - 1; i >= 0; i--)
#define pub push_back

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

typedef long long ll;
typedef pair<int, int> P;
const int INF = 100000000;
const ll LINF = 10000000000000000;
const int MOD = 1000000007;
const int dx[9] = { 0, 1,  0, -1, 1,  1, -1, -1, 0};
const int dy[9] = { 1, 0, -1,  0, 1, -1, -1,  1, 0};
//--------------------------------------//
int A, B;

void solve(){
	int ans = 0;
	for(int i = A; i <= B; i++){
		int a[5];
		int n = i;
		int c = 5;
		while(c--) a[c] = n % 10, n /= 10;
		if(a[0] == a[4] and a[1] == a[3])
			ans++;
	}
	cout << ans << endl;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> A >> B;
		solve();
	return 0;
}


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

int main(void)
{
    int A,B;
    scanf("%d %d", &A, &B);
    if(B % A == 0) {
        printf("%d\n", A + B);
    }
    else{
        printf("%d\n", B-A);
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define sf scanf
#define pf printf
#define pb push_back
#define llu unsigned long long
#define U unsigned int
#define SIZE 1000002
#define pie 3.14159265358979323
#define minuss 1e-6
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
int main()
{
    ll n;
    cin>>n;
    double s[n+5];
    double st[n+4];
    double sum=0;
    for(int i=0; i<n; i++)
    {
        cin>>s[i];
        sum=sum+(1/s[i]);
    }
    double tot=1/sum;
    printf("%0.14f\n",tot);

}


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

int main()
{
    int n;cin>>n;
    set<string>s;
    for(int i=0;i<n;i++)
    {
        string str;
        cin>>str;
        s.insert(str);
    }
    cout<<s.size()<<endl;
    return 0;
}

Measured memory_bytes: 19192
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <functional>
#include <numeric>
#include <set>
 
#define v_exists(elem, v) find(v.begin(),v.end(),elem)!=v.end()
#define s_exists(elem, s) s.find(elem)!=s.end()
 
using namespace std;
 
long gcd(long a, long b) {
    return b == 0 ? a : gcd(b, a % b);
}
 
long lcm( long m, long n ){
	if ( ( 0 == m ) || ( 0 == n ) )
		return 0;
 
	return ((m / gcd(m, n)) * n);
}
 
 
bool sp(pair<int,int> a, pair<int,int> b){
 
	if(a.first == b.first && a.second == b.second){
		return true;
	} else if (a.first == b.second && a.second == b.first) {
		return true;
	}
	return false;
 
}
 
int main(){
// N M
// x1 y1
// x2 y2
// :
// xM yM
 
	int N, M;
 
	scanf("%d %d",&N,&M);
 
	cout << N+M/2 << endl;
}

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

int main() {
  int N, K, X, Y;
  cin >> N >> K >> X >> Y;
  int sum = 0;
  if (N < K) {
    sum = N * X;
  }
  else {
    sum = K * X + (N-K) * Y;
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
def x(r, d, prev_x)
	r * prev_x - d
end

input = STDIN.gets
splited = input.split(" ")

r = splited[0].to_i
d = splited[1].to_i
x2000 = splited[2].to_i

prev = x2000
10.times do |cnt|
	prev = x(r, d, prev)
	puts prev
end

Measured memory_bytes: 1788
using System;

namespace Free_1
{
    class Program
    {
        static void Main(string[] args)
        {
            int x = int.Parse(Console.ReadLine());
            if (x == 0)
            {
                Console.WriteLine(1);
            }
            else
            {
                Console.WriteLine(0);
            }
        }
    }
}

Measured memory_bytes: 27516
N, M = map(int, input().split())
s = []
c = []
for _ in range(M):
    a, b = map(int, input().split())
    s.append(a)
    c.append(b)
N_list = [10,]*(N)

f = True
for i in range(M):
    if N_list[s[i]-1] == 10:
        N_list[s[i]-1] = c[i]
    if N_list[s[i]-1] != c[i]:
        f = False
        print('-1')
        break
if f:
    if N == 1:
        if N_list[0] == 10 or N_list[0] == 0:
            print(0)
        else:
            print(N_list[0])
    else:
        if N_list[0] == 10:
            N_list[0] = 1
        if N_list[0] == 0:
            print('-1')
        else:
            N_list = [N_list[i]%10 for i in range(N)]
            count = 0
            for i, n in enumerate(list(range(N))[::-1]):
                count += N_list[i] * 10**n
            print(count)	

Measured memory_bytes: 3188
import math
a, b, C = map(int, input().split())

sinC = math.sin(math.radians(C))
cosC = math.cos(math.radians(C))

S = (a*b*sinC)/2
L = a+b+(a**2 + b**2 - 2*a*b*cosC)**0.5
h = 2*S/a

print(S)
print(L)
print(h)


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

using namespace std;

using int64 = long long;

struct Edge {
  int from, to;
  int id;
  int reverse_id;
};

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

  int n, m;
  cin >> n >> m;

  vector<vector<Edge>> graph(n);
  vector<Edge> edges;
  vector<int> is_actives(2 * m);
  vector<int> out_degrees(n);
  for (int i = 0; i < m; i++) {
    int v1, v2;
    cin >> v1 >> v2;
    v1--; v2--;
    Edge e1({v1, v2, 2 * i, 2 * i + 1});
    Edge e2({v2, v1, 2 * i + 1, 2 * i});
    graph[v1].push_back(e1);
    graph[v2].push_back(e2);
    edges.push_back(e1);
    edges.push_back(e2);
    is_actives[2 * i] = true;
    out_degrees[v1]++;
  }

  if (m % 2 == 1) {
    cout << -1 << endl;
    return 0;
  }

  vector<int> visited(n, 0);
  vector<int> used_edges(n, -1);
  function<int(int, int, int)> dfs =
      function<int(int, int, int)>([&] (int s, int v, int parent) {
        visited[v] = 1;
        if (v != s && out_degrees[v] % 2 == 1) {
          return v;
        }

        for (const auto& edge : graph[v]) {
          // if (is_actives[edge.id]) {
            if (edge.to == parent) continue;
            if (visited[edge.to]) continue;
            used_edges[edge.to] = edge.id;
            int dfs_value = dfs(s, edge.to, v);
            if (dfs_value >= 0) return dfs_value;
          // }
        }

        return -1;
      });
  

  while (true) {
    bool is_finished = true;
    for (int i = 0; i < n; i++) {
      if (out_degrees[i] % 2 == 1) is_finished = false;
    }
    if (is_finished) break;

    for (int s = 0; s < n; s++) {
      if (out_degrees[s] % 2 == 1) {
        int t = dfs(s, s, -1);
        if (t < 0) continue;
        int cur = t;
        while (cur != s) {
          Edge used_edge = edges[used_edges[cur]];
          if (is_actives[used_edge.id]) {
            out_degrees[used_edge.from]--;
            out_degrees[used_edge.to]++;
          } else {
            out_degrees[used_edge.from]++;
            out_degrees[used_edge.to]--;
          }
          is_actives[used_edge.id] = !is_actives[used_edge.id];
          is_actives[used_edge.reverse_id] = !is_actives[used_edge.reverse_id];

          cur = used_edge.from;
        }
      }
    }

    for (int i = 0; i < n; i++) visited[i] = 0;
    for (int i = 0; i < n; i++) used_edges[i] = -1;
  }

  for (int i = 0; i < 2 * m; i++) {
    if (is_actives[i]) {
      cout << edges[i].from + 1 << " " << edges[i].to + 1 << endl;
    }
  }
}


Measured memory_bytes: 15596
s = list(input())
s = s[:-1]  # 一文字とる
while True:
    n = len(s)
    if n % 2 == 1:
        s = s[:-1]
        continue
    a = n //2
    if s[:a] == s[a:]:
        print(n)
        exit()
    else:
        s = s[:-1]

Measured memory_bytes: 3060
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <random>
#include <tuple>
#include <iomanip>
#include <cstring>

using namespace std;

typedef long long ll;
//typedef pair<int,int> Pint;
//typedef pair<ll, ll> P;
//typedef pair<ll, pair<ll, ll>> P;
//typedef tuple<int,int,int> T;
typedef vector<ll> vec;
typedef vector<vec> mat;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define revrep(i, n) for(ll i = (n-1); i >= 0; i--)
#define pb push_back
#define f first
#define s second
//const ll INFL = 1LL << 60;//10^18 = 2^60
const ll INFL = 1LL << 60;
const int INF = 1 << 30;//10^9
ll MOD = 1e9 + 7;
//ll MOD  = 998244353;
vector<ll> dy = {0, 0, 1, -1, 1, 1, -1, -1, 0};
vector<ll> dx = {1, -1, 0, 0, 1, -1, 1, -1, 0};

ll max(ll a, ll b){return (a > b) ? a : b;}
ll min(ll a, ll b){return (a < b) ? a : b;}
ll pow_long(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2) res *= x;
    x *= x;
    k /= 2;
  }
  return res;
}
ll pow_mod(ll x, ll k){
  x %= MOD; x += MOD; x %= MOD;
  ll res = 1;
  while(k > 0){
    if(k % 2){
      res *= x; res %= MOD;
    }
    x *= x; x %= MOD;
    k /= 2;
  }
  return res;
}
ll inverse(ll x){return pow_mod(x, MOD - 2);};

//最大公約数
ll gcd(ll a, ll b){
    if(b == 0) return a;
    return gcd(b, a % b);
}

//最小公倍数
ll lcm(ll x, ll y){return x / gcd(x, y) * y;};

//コンビネーション
const int MAXcomb = 200010;
ll fac[MAXcomb], finv[MAXcomb], inv[MAXcomb];
//facはn!,finvは1/n!
//invは逆元
void COMinit(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < MAXcomb; i++){
        fac[i] = fac[i-1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
        finv[i] = finv[i-1] * inv[i] % MOD;
    }
}
ll comb(int n, int k){
    if(n < k) return 0;
    if(n < 0 || k < 0) return 0;
    return fac[n] * finv[k] % MOD * finv[n-k] % MOD;
}

ll kai_mod(ll x){
  if(x == 1) return 1;
  return x * kai_mod(x-1) % MOD;
}


int main(void){
  int a;
  string S;
  cin >> a >> S;
  if(a >= 3200) cout << S << endl;
  else cout << "red" << endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

typedef long long ll;

ll pow(ll n, ll r) {
    if (!r) return 1;
    if (r % 2) return n * pow(n, r - 1);
    ll t = pow(n, r / 2);
    return t * t;
}

int main() {
    ios::sync_with_stdio(false);
    ll x;
    cin >> x;
    for (ll a = -200; a <= 200; ++a) for (ll b = -200; b <= 200; ++b) if (pow(a, 5) - pow(b, 5) == x) {
        cout << a << " " << b << endl;
        return 0;
    }
    return 0;
}


Measured memory_bytes: 3576
#include<bits/stdc++.h>
#define reg register
#define rep(i, a, b) for (reg int i = (a), i##end = (b); i <= i##end; ++i)
#define dep(i, a, b) for (reg int i = (a), i##end = (b); i >= i##end; --i)
using namespace std;
using ll = long long;

signed main() {
	ll d;
	cin>>d;
	cout << "Christmas";
	rep(i, 0, 24-d) {
		cout << " Eve";
	}
}

Measured memory_bytes: 256