akhauriyash/Code-Regression huggingface dataset:
#include <math.h>
#include <time.h>
#include <ctype.h>
#include <stdio.h>
#include <assert.h>
#include <stdlib.h>
#include <string.h>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
#include<iomanip>

#define mod 998244353
#define ll long long int
#define pb(x) push_back(x)
#define MP(x,y) make_pair(x,y)

using namespace std;

ll power(ll a, ll b, ll m)
{
	if (b == 0)
		return(1);
	ll sol = power(a, b / 2, m);
	sol = (sol * sol) % m;
	if (b % 2 == 1)
		sol = (sol * a) % m;
	return(sol);
}
ll gcd(ll a, ll b)
{
	if (b == 0)
		return a;
	else
	{
		return gcd(b, a % b);
	}
}
int h[100005];
void solve()
{
	int n;
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> h[i];
	bool flag = true;
	for (int i = n-2; i >=0; i--)
	{
		if (h[i]>h[i+1])
			h[i]--;
	}
	for (int i = 0; i < n-1; i++)
	{
		if (h[i + 1] < h[i])
		{
			flag = false;
		}
	}
	if (flag)
		cout << "Yes";
	else
		cout << "No";
}
int main()
{
	int t = 1;
	//cin >> t;
	while (t--)
		solve();
	return 0;
}

Measured memory_bytes: 640
a, b, c = map(int, input().split())
count = 0
# 全てを奇数or偶数(マイナー)に揃える
if a % 2 == 0 and b % 2 == 0 and c % 2 == 1:
    a += 1
    b += 1
    count += 1
elif a % 2 == 0 and b % 2 == 1 and c % 2 == 0:
    a += 1
    c += 1
    count += 1
elif a % 2 == 0 and b % 2 == 1 and c % 2 == 1:
    b += 1
    c += 1
    count += 1
elif a % 2 == 1 and b % 2 == 0 and c % 2 == 0:
    b += 1
    c += 1
    count += 1
elif a % 2 == 1 and b % 2 == 0 and c % 2 == 1:
    a += 1
    c += 1
    count += 1
elif a % 2 == 1 and b % 2 == 1 and c % 2 == 0:
    a += 1
    b += 1
    count += 1

# ソートして同じになるまでカウント
data_list = [a, b, c]
data_list.sort()
while data_list[0] != data_list[2]:
    data_list[0] += 2
    count += 1
while data_list[1] != data_list[2]:
    data_list[1] += 2
    count += 1
print(count)


Measured memory_bytes: 3064
import heapq
import math
n,m=list(map(int,input().split()))
a=list(map(lambda x:-1*int(x),input().split()))

heapq.heapify(a)
for _ in range(m):
    tmp=heapq.heappop(a)
    cal=math.ceil(tmp/2)
    heapq.heappush(a,cal)
    
print(sum(a)*-1)

Measured memory_bytes: 14532
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
const ll mod = 1e9+7;

int main() {
	ll n;
	cin>>n;
	cout<<(n^1);
	return 0;
}

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

int main(){
    int n, cnt2 = 0, cnt4 = 0; cin >> n;
    for(int i=0;i<n;i++){
        int a; cin >> a;
        if(a%4==0) cnt4++;
        else if(a%2==0) cnt2++;
    }

    int odd = n - cnt2 - cnt4;
    if(n/2 <= cnt4 || odd <= cnt4 || cnt2 == n) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
using namespace std;


void solve(){
  string s; cin >> s;
  sort(s.begin(), s.end());
  if(s == "abc") cout << "Yes\n";
  else cout << "No\n";
  return;
}

int main(){
  solve();
  return 0;
}


Measured memory_bytes: 256
n = int(input())
h = list(map(int, input().split()))
dp = [1001001001001001001] * n
dp[0] = 0
for i in range(n - 1):
    dp[i+1] = min(dp[i+1], dp[i] + abs(h[i+1] - h[i]))
    if i < n - 2:
        dp[i+2] = min(dp[i+2], dp[i] + abs(h[i+2] - h[i]))
print(dp[n-1])

Measured memory_bytes: 20452
import java.util.*;

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

    long a = sc.nextLong();
    long b = sc.nextLong();
    long c = sc.nextLong();
    long k = sc.nextLong();
    sc.close();

    long sum = 0;

    if (a <= k) {
      sum += a * 1;
      k -= a;
    } else {
      System.out.println(k);
      return;
    }
    if (k <= 0) {
      System.out.println(sum);
      return;
    }

    if (b <= k) {
      sum += b * 0;
      k -= b;
    } else {
      System.out.println(sum);
      return;
    }
    if (k <= 0) {
      System.out.println(sum);
      return;
    }

    if (c <= k) {
      sum += c * -1;
      k -= c;
    } else {
      sum += k * -1;
    }
    System.out.println(sum);
  }
}

Measured memory_bytes: 35796
#include<iostream>
using namespace std;
int main(){
	char a,b;
	cin >> a >> b;
	if(a == 'H' && b == 'H') cout << 'H' << endl;
	else if(a == 'H' && b == 'D') cout << 'D' << endl;
	else if(a == 'D' && b == 'H') cout << 'D' << endl;
	else cout << 'H' << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
  vector<int> high(10);
  for(int i=0; i<10; i++) cin >>high[i];
  sort(high.begin(),high.end());
  for(int i=9; i>=7; i--) cout <<high[i]<<endl;
  return 0;
}

Measured memory_bytes: 1212
#include <iostream>
#include <vector>
#include <map>
#include <utility>
#include <algorithm>

#define Fi first
#define Se second
using namespace std;


int tree[100005];
int p[100005];
int p_[100005];

int root(int a);
bool same(int a, int b);
void link(int a, int b);

int main()
{
    int ans = 0;
    int n, m;
    int x, y;

    cin >> n >> m;
    for ( int i = 1; i <= n; i++) {
        cin >> p[i];
        p_[p[i]] = i;
        tree[i] = i;
    }
    for ( int i = 1; i <= m; i++) {
        cin >> x >> y;
        link(p_[p[x]],p_[p[y]]);
    }


    for ( int i = 1; i <= n; i++) {
        if ( same(p_[i], i) ) {
            ans++;
        }
    }


    cout << ans << endl;

    return 0;
}

int root(int a)
{
    if ( tree[a] == a ) {
        return a;
    }
    return tree[a] = root(tree[a]);
}

bool same(int a, int b)
{
    return root(a) == root(b);
}

void link(int a, int b)
{
    tree[root(a)] = root(b);

    return;
}


Measured memory_bytes: 1408
# -*- coding: utf-8 -*-

import fractions

import sys
import math
import sys

input = sys.stdin.readline

n, m = map(int, input().split())
s = list(input())
t = list(input())

##最小公倍数を求める
f = fractions.gcd(n, m)
f = n * m // f

nn = f//n
mm = f//m

##最小公倍数を求める
ff = fractions.gcd(nn, mm)
ff = nn * mm // ff
#print(nn,mm)
#print(f,ff)
for i in range(f//ff):
 #   print(i*mm,i*nn,s[i*mm],t[i*nn])
    if s[i*mm] != t[i*nn]:
        print(-1)
        quit()

print(f)


Measured memory_bytes: 6492
#ifdef __GNUC__
#pragma GCC diagnostic ignored "-Wunused-result"
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#endif

#include <algorithm>
#include <cmath>
#include <cstring>
#include <iostream>
#include <sstream>
#include <numeric>
#include <map>
#include <set>
#include <queue>
#include <vector>

using namespace std;

typedef long long LL;
typedef long double LD;
typedef pair<LL, LL> II;
typedef pair<LL, II> III;
typedef priority_queue<III, vector<III>, greater<>> Queue;
static const LL INF = 1LL << 60;



struct UnionFind {
	std::vector<int> _parent;
	std::vector<int> _size;
	UnionFind(int size) : _parent(size, -1), _size(size, 1) { }
	void unite(int a, int b) {
		int ra = root(a), rb = root(b); if (ra == rb) { return; }
		if (_size[ra] >= _size[rb]) { _parent[rb] = ra, _size[ra] += _size[rb]; } else { _parent[ra] = rb, _size[rb] += _size[ra]; }
	}
	int root(int a) {
		int p = _parent[a];
		if (p < 0) { return a; }
		while (_parent[p] >= 0) { p = _parent[p]; }
		return _parent[a] = p;
	}
	int size(int a) { return _size[root(a)]; }
};

void solve(long long N, long long M, std::vector<long long> &A, std::vector<long long> &B) {
	UnionFind uf(N);
	for (LL i = 0; i < M; ++i) {
		uf.unite(A[i], B[i]);
	}
	LL ans = 0;
	for (LL i = 1; i < N; ++i) {
		if (uf.root(i - 1) != uf.root(i)) {
			++ans;
			uf.unite(i - 1, i);
		}
	}
	cout << ans << endl;
}

int main() {
    long long N;
	std::cin >> N;
	long long M;
	std::cin >> M;
	std::vector<long long> A(M);
	std::vector<long long> B(M);
	for (int i = 0; i < M; i++) {
		std::cin >> A[i]; A[i]--;
		std::cin >> B[i]; B[i]--;
	}
	solve(N, M, A, B);
	return 0;
}


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

int n,m;
string s;

int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)
	{
		cin>>s;
		cout<<s<<endl<<s<<endl;
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll int
int main()
{
    ll n,m,len,i,j,x;

    string s,t;
    cin>>s>>t;
    ll len1=s.size();
    ll  len2=t.size();
    ll c=0,mx=-1;
    for(i=0;i<=len1-len2;i++)
    {
        c=0;
        for(j=0;j<len2;j++)
        {
            if(s[i+j]==t[j])c++;
        }
        mx=max(mx,c);
    }
    cout<<len2-mx;


}


Measured memory_bytes: 3628
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import numpy


def main():
  r, c = map(int, input().split())
  g = numpy.array([[1 if v == '.' else 0 for v in input().strip()] for _ in range(r)])
  g = numpy.array([g, g])

  for x in range(1, c):
    g[0, :, x] += g[0, :, x] * g[0, :, x - 1]

  for x in range(c - 2, -1, -1):
    g[0, :, x] = (g[0, :, x] != 0) * numpy.maximum(g[0, :, x], g[0, :, x + 1])

  for y in range(1, r):
    g[1, y] += g[1, y] * g[1, y - 1]

  for y in range(r - 2, -1, -1):
    g[1, y] = (g[1, y] != 0) * numpy.maximum(g[1, y], g[1, y + 1])

  g = g[0] + g[1]

  print(numpy.max(g) - 1)


if __name__ == '__main__':
  main()



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

int main () {
  int N, K;
  cin >> N >> K;
  int l[60];
  int sum = 0;
  for (int i=0;i<N;++i) {
    cin >> l[i];
  }
  sort(l, l + N, greater<>());
  for (int i=0;i<K;++i) {
    sum += l[i];
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  for(int i = 1;  i <= n; ++i){
    int cnt = 0;
    int N = i;
    for(int x = 1; x * x<= n; ++x){
      for(int y = 1; y * y <= n; ++y){
        for(int z = 1; z * z <= n; ++z){
          int cal =  x * x + y * y + z * z + x * y + y * z + z * x;
          if( cal < N)
           	continue;
          if(cal == N)
            ++cnt;
        	break;
        }
      }
    }
    cout << cnt << '\n';
  }
}

Measured memory_bytes: 3556
m = int(1e9+7)
s = list(input())

dp = [[0 for _ in range(13)] for _ in range(2)]
dp[0][0] = 1
r = 1
ans = 0
for i in range(len(s)):
    for j in range(13):
        dp[(i + 1) % 2][j] = 0
    c = s[len(s) - 1 - i]
    if c == '?':
        for j in range(13):
            for k in range(10):
                dp[(i + 1) % 2][(k * r + j) % 13] += dp[i % 2][j]
    else:
        for j in range(13):
            dp[(i + 1) % 2][(int(c) * r + j) % 13] += dp[i % 2][j]
    for j in range(13):
        dp[(i + 1) % 2][j] %= m
    ans = dp[(i + 1) % 2][5]
    r *= 10
    r %= 13
print(ans)

Measured memory_bytes: 49904
n = int(input())
d,x = map(int,input().split())

a = [int(input()) for i in range(n)]
    
num = x

for i in range(n):
  j=0
  while j*a[i] + 1 <= d:
    num +=1
    j += 1
    
    
    
print(num)

Measured memory_bytes: 3060
#include <iostream>
using namespace std;
int main(void){
    double v;
    double t; //球が割れるのに必要な最低速度になるのは落下し始めてから何秒後か
    double y; //t秒後に物体が落下した距離
    int N; //球が割れる建物の階の最小値

    while(cin >> v){
        t = v / 9.8;
        y = 4.9 * t * t;
        N = (y + 5) / 5; 

        cout << N + 1 << endl;
    }
}


Measured memory_bytes: 3136
function Main(input){
  input = input.trim().split(' ').map(x=>parseFloat(x));
  var a = input[0];
  var b = input[1];
  var h = input[2];
  var m = input[3];
  var angle = ((h+m/60.0)/12.0 - m/60.0)*2.0*Math.PI;
  var cos = Math.cos(angle);
  var ans = Math.sqrt(a**2.0 + b**2.0 - 2.0*a*b*cos);
  console.log(ans);
}
  


Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

int main(){
    cin.tie(0);
   	ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> H(n);
    for(int i=0; i<n; i++){
        cin >> H[i];
    }
    int cnt=0;
    for(int i=1; i<n; i++){
        if(H[i]-H[i-1]<=-2 || cnt==2) {cout << "No" << endl; return 0;}
        else if(H[i]-H[i-1]==-1){cnt++;} 
        else if(H[i]-H[i-1]>0){cnt= 0;}
        else continue;
    }
    if(cnt==2) {cout << "No" << endl; return 0;}
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<utility>
#include <functional>
#include <set>
#include <map>
#include <queue>
#include <cmath>
#include <stack>

using namespace std;

int main() {
	long long int a, b, n;
	cin >> a >> b >> n;
	long long int so;
	if (b > n) so = n;
	else so = b - 1;
	cout << (so * a) / b;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(unique(all(x)), x.end());
typedef long long ll;
typedef complex<double> Complex;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for (int i = 0; i < sz(v); i++) {
        os << v[i];
        if (i < sz(v) - 1) os << " ";
    }
    return os;
}
int main() {
    ll a, b, c, k;
    cin >> a >> b >> c >> k;
    ll ans = 0;
    ans += min(a, k);
    k -= min(a, k);
    k -= min(b, k);
    ans -= min(c, k);
    cout << ans << endl;
}

Measured memory_bytes: 3636
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <vector>
using namespace std;
const int Maxn = 200010;
int n, m;
int maxx[Maxn<<2], la[Maxn<<2];
vector <int> vec[Maxn];
int _max(int x, int y) { return x > y ? x : y; }
void build_tree(int now, int L, int R) {
	if(L < R){
		int mid = L+R>>1, lc = now<<1, rc = now<<1|1;
		build_tree(lc, L, mid);
		build_tree(rc, mid+1, R);
		maxx[now] = maxx[lc];
	} else maxx[now] = -L;
}
void push_down(int now) {
	if(la[now] != 0){
		int lc = now<<1, rc = now<<1|1;
		maxx[lc] += la[now]; maxx[rc] += la[now];
		la[lc] += la[now]; la[rc] += la[now];
		la[now] = 0;
	}
}
void chg(int now, int L, int R, int l, int r) {
	if(L == l && R == r){
		maxx[now]++; la[now]++;
		return;
	}
	push_down(now);
	int mid = L+R>>1, lc = now<<1, rc = now<<1|1;
	if(r <= mid) chg(lc, L, mid, l, r);
	else if(l > mid) chg(rc, mid+1, R, l, r);
	else chg(lc, L, mid, l, mid), chg(rc, mid+1, R, mid+1, r);
	maxx[now] = _max(maxx[lc], maxx[rc]);
}
int qry(int now, int L, int R, int r) {
	if(R == r) return maxx[now];
	int mid = L+R>>1, lc = now<<1, rc = now<<1|1;
	if(r <= mid) return qry(lc, L, mid, r);
	else return _max(maxx[lc], qry(rc, mid+1, R, r));
}
int main() {
	int i, j, k;
	scanf("%d%d", &n, &m);
	for(i = 1; i <= n; i++){
		int x, y;
		scanf("%d%d", &x, &y);
		vec[y].push_back(x);
	}
	build_tree(1, 0, m);
	int ans = n-m;
	for(i = m+1; i >= 1; i--){
		for(j = 0; j < vec[i].size(); j++){
			int x = vec[i][j];
			chg(1, 0, m, x, i-1);
		}
		int res = qry(1, 0, m, i-1);
		ans = _max(ans, res-(m-i+1));
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 14080
import java.util.Arrays;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {

	public static void main(String[] args) {
		//		new Main().solveA();
		//		new Main().solveB();
		new Main().solveC();
		// new Main().solveD();
	}

	private void solveA() {
		Scanner scanner = null;
		int numA = 0;
		int numB = 0;

		try {
			scanner = new Scanner(System.in);
			numA = scanner.nextInt();
			numB = scanner.nextInt();

			System.out.println(Math.max(numA + numB, Math.max(numA - numB, numA * numB)));

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private void solveB() {
		Scanner scanner = null;
		int numN = 0;
		String numS = "";

		try {
			scanner = new Scanner(System.in);
			numN = scanner.nextInt();
			numS = scanner.next();
			String numWk = "";
			int res = 0;
			numWk = numS;
			for (int i = numN - 1; i >= 0; i--) {
				char[] val1 = numWk.substring(0, i).toCharArray();
				char[] val2 = numWk.substring(i, numN).toCharArray();

				Set<Character> wkSet1 = new HashSet<Character>();
				for (int j = 0; j < val1.length; j++) {
					wkSet1.add(val1[j]);
				}

				Set<Character> wkSet2 = new HashSet<Character>();
				for (int j = 0; j < val2.length; j++) {
					wkSet2.add(val2[j]);
				}

				Set<Character> chkSet = null;
				Set<Character> resSet = null;
				if (wkSet1.size() > wkSet2.size()) {
					chkSet = wkSet1;
					resSet = wkSet2;
				} else {
					chkSet = wkSet2;
					resSet = wkSet1;
				}

				int cnt = 0;
				for (Character character : chkSet) {
					if (resSet.contains(character)) {
						cnt++;
					}
				}

				res = Math.max(res, cnt);
			}

			System.out.println(res);

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private void solveC() {
		Scanner scanner = null;
		int numN = 0;
		char[] numS;

		try {
			scanner = new Scanner(System.in);
			numN = scanner.nextInt();
			numS = scanner.next().toCharArray();

			int[] eArray = new int[numS.length];
			int[] wArray = new int[numS.length];
			int[] resArray = new int[numS.length];

			wArray[numN - 1] = 0;
			if ('E' == numS[numN - 1]) {
				wArray[numN - 2] = 1;
			} else {
				wArray[numN - 2] = 0;
			}
			for (int i = numN - 3; i >= 0; i--) {
				if ('E' == numS[i + 1]) {
					wArray[i] = wArray[i + 1] + 1;
				} else {
					wArray[i] = wArray[i + 1];
				}
			}
			eArray[0] = 0;
			if ('W' == numS[0]) {
				eArray[1] = 1;
			} else {
				eArray[1] = 0;
			}
			for (int i = 0; i < numN; i++) {
				if (i >= 2 && 'W' == numS[i - 1]) {
					eArray[i] = eArray[i - 1] + 1;
				} else if (i >= 2) {
					eArray[i] = eArray[i - 1];
				}
				resArray[i] = eArray[i] + wArray[i];
			}
			Arrays.sort(resArray);
			System.out.println(resArray[0]);

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private void solveD() {
		Scanner scanner = null;
		int numN = 0;
		int numK = 0;
		int numS = 0;

		try {
			scanner = new Scanner(System.in);
			numN = scanner.nextInt();

			System.out.println("");

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}
}

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

typedef long long ll;
const ll INF = 1e9, MOD = 1e9 + 7;
const double EPS = 1e-9, PI = 3.141592653589793;
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define REPR(i,a,b) for(ll i=b;i>=a;i--)
#define repr(i,n) REPR(i,0,n)
#define All(v) (v).begin(), (v).end()
#define Pb push_back

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

    string s;
    cin >> s;
    if(s[6]=='5' || s[6]=='6'||s[6]=='7'||s[6]=='8'||s[6]=='9'||s[5]=='1'){
        cout << "TBD" << "\n";
    }else{
        cout << "Heisei" << "\n";
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(void){
    int a,b,c,d,e;
    int i,j,sum;
    cin >> a >> b >> c >> d >> e;
    if(a < 0){
        i = c * (0 - a);
        j = e * (b - 0);
        sum = i + d + j;
        cout << sum << endl;
    }
    else{
        i = e * (b - a);
        sum = i;
        cout << sum << endl;
    }
}


Measured memory_bytes: 3080
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;

#define ll long long
const long long llINF = 1LL << 60;
const int iINF = 0x20000000;
template<class T> inline bool chmin(T& a, T b) { if (b < a) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

void execute();
int main() 
{
    cin.tie(nullptr);
    ios::sync_with_stdio(false);// cin と scanfの併用禁止
    cout << fixed << setprecision(15);
    execute();
    return 0;
}


void execute()
{
    int X, Y;
    cin >> X >> Y;

    for(int i = 0; i <= X; i++){
        if(Y ==  2 * i + (4 * (X-i))){
            cout << "Yes" << endl;
            return;
        }

    }
    cout << "No" << endl;
}


Measured memory_bytes: 3664
require "matrix"
#  m*nの行列
m,n=gets.chomp.split(" ").map(&:to_i);
$mat=Array.new(m)
for i in 0..m-1 do
 $mat[i]=gets.chomp.split(" ").map(&:to_i)
end
$vec=Array.new(n)
for i in 0..n-1 do
 $vec[i]=gets.to_i
end
for i in 0..m-1 do
 sum=0
 for j in 0..n-1 do
 sum=sum+$mat[i][j]*$vec[j]
 end
 print("#{sum}\n")
end


Measured memory_bytes: 7368
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <numeric>
#include <complex>
#include <iomanip>
#include <cassert>
#include <random>


int main() {
    int p, q, r; std::cin >> p >> q >> r;
    std::cout << std::min({ p + q, q + r,r + p }) << std::endl;
    return 0;
}


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

#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, m, n) for(int i = (m); i < (int)(n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define INF 2000000000

#ifdef LOCAL
  #define eprintf(...) fprintf(stdout, __VA_ARGS__)
#else
  #define eprintf(...) 0
#endif

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef unsigned int uint;

int main() {
  int n, m;
  cin >> n >> m;
  vector<pair<int, int>> students(n);
  vector<pair<int, int>> checks(m);
  vector<pair<int, LL>> nears(n, pair<int, LL>(-1, INF));
  REP(i, n) {
    cin >> students[i].first >> students[i].second;
  }
  
  int c, d;
  REP(ck, m) {
    cin >> c >> d;
    REP(st, n) {
      LL dis = abs(c - students[st].first) + abs(d - students[st].second);
      if(nears[st].second > dis) {
        nears[st].first = ck+1;
        nears[st].second = dis;
      }
    }
  }
  for(auto p: nears) {
    cout << p.first << endl;
  }


  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fo(x, n) for(int i = x; i <= n; i++)
#define all(x) x.begin(), x.end()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector <int> vi;
const int MOD = 1e9 + 7;
void solve(){
    double n, k;
    cin >> n >> k;
    double win = 0;
    for(int i = 1; i <= min(n, k - 1); i++){
        int x = i, deg = 0;
        while(x < k){
            x *= 2;
            deg++;
        }
        win += 1 / pow(2, deg);
    }
    win += max(n - n, n - k + 1);
    win = win / n;
    cout << fixed << setprecision(20) << win;
}

int main(){
    ios::sync_with_stdio(false); cin.tie(0);
	int T = 1;
    //cin >> T;
    fo(1, T){
        solve();
    }
}




Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++)cin>>a[i];
    sort(a,a+n,greater<int>());
    int suma=0;
    int sumb=0;
    for(int i=0;i<n;i++)
    {
        if((i%2)==0)suma+=a[i];
    else sumb+=a[i];
    }
    cout<<suma-sumb<<'\n';
    return 0;
}

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

int main()
{
  int A, B, K;
  cin >> A >> B >> K;
  vector <int> vec(A * B);
  int number = 0;
  
  if (A < B)
  {
    for (int i = A; i > 0; i--)
    {
      if ((A % i == 0) && (B % i == 0))
      {
        vec.at(number) = i;
        number++;
      }
    }
  }
  
  else
  {
    for (int i = B; i > 0; i--)
    {
      if ((A % i == 0) && (B % i == 0))
      {
        vec.at(number) = i;
        number++;
      }
    }
  }
  
  cout << vec.at(K -= 1) << endl;
}

Measured memory_bytes: 256
from itertools import product

n, m, x = map(int, input().split())
books = [list(map(int, input().split())) for _ in range(n)]

minimum_cost = float('inf')

buy_selections = product([1, 0], repeat=n)
for selection in buy_selections:
    bought_books = [books[i] for i in range(n) if selection[i]]
    
    total_each = [0] * (m+1)
    for book in bought_books:
        for i in range(m+1):
            total_each[i] += book[i]
    
    if any([total < x for total in total_each[1:]]):
        continue
    if total_each[0] < minimum_cost:
        minimum_cost = total_each[0]

if minimum_cost == float('inf'):
    print('-1')
else:
    print(minimum_cost)

Measured memory_bytes: 68744
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <list>
#include <numeric>
#include <tuple>
#include <cstdio>

using namespace std;
typedef long long ll;

#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define repp(i,a,b) for(ll i=(a);i<=(b);++i)
#define vec vector
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl;
ll a, b, c;

int main() {
   cin >> a >> b >> c;
   // a+b, c枚しか食べられない
   // b + c枚しか食べられない
   if (a+b<c) {
      cout << b+min(a+b, c)+1 << endl;
   } else {
      cout << b+min(a+b, c) << endl;
   }
}


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

#define REP(i, s, n) for (int i = s; i < n; ++i)
#define rep(i, n) REP(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG false

int main()
{
    long long int a,b,x;
    cin>>a>>b>>x;
    long long int ans=b/x-a/x;
    if(a%x==0) ans++;
    cout<<ans<<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);
        while (true) {
            int H = sc.nextInt();
            int W = sc.nextInt();
            if (H == 0 && W == 0) {
                break;
            } else {
                for (int i = 0; i < H; i++) {
                    for (int j = 0; j < W; j++) {
                        if ((i + j) % 2 == 0) {
                            System.out.printf("#");
                        } else {
                            System.out.printf(".");
                        }
                    }
                    System.out.printf("\n");
                }
                System.out.printf("\n");
            }
        }
    }
}


Measured memory_bytes: 65328
#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define int long long
#define vec(a,n) vector<int> (a)((n));
#define Vec(a,n) vector<string> (a)((n));
#define twovec(a,n,m) vector<vector<int>> a(n,vector<int>(m,0));
#define Twovec(a,n,m) vector<vector<double>> a(n,vector<double>(m,0));
#define P pair<int,int>
#define All(a) (a).begin(),(a).end()
#define Sort(a) sort(All(a));
#define Reverse(a) reverse(All(a));
#define PQ(n) priority_queue<P,vector<P>,greater<P>> (n)
#define pq(n) priority_queue<int> (n)
#define print(a) cout << (a) << endl
#define printD(a) cout << setprecision(15) << (a) << endl;
using namespace std;
int max_int = 1000000007;
void Debug(auto a);
int nibul(auto a,auto b);
int nibuu(auto a,auto b);
void input(vector<int>& a,int n);

int n;

signed main(){
    cin >> n;
    vec(a,n);
    input(a,n);
    int ans=0;
    int cnt=1;
    REP(i,n){
        if(a[i] == cnt){
            cnt++;
        }
        else{
            ans++;
        }
    }
    (ans == n)? print(-1) : print(ans);
    //print(ans);

    return 0;
}

void Debug(auto a){
    cout << "{ ";
    for(auto b: a){
        cout << b << " ";
    }
    cout << "}" << endl;
}
int nibul(auto a,auto b){
    int x = lower_bound(All(a),b) - a.begin();
    //key以上の初めてのitr
    return x;
}
int nibuu(auto a,auto b){
    int x = upper_bound(All(a),b) - a.begin();
    //key以下の最後のitr
    return x-1;
}

void input(vector<int>& a,int n){
    REP(i,n){
        cin >> a[i];
    }
}


Measured memory_bytes: 1792
#include <iostream>
#include<string>
using namespace std;
int main(){
    string S;
    
    int N,K;
    cin>>N>>K;
    cin>>S;
    K=K-1;
    
        
    
        if(S[K]=='A'){
            S[K]='a';
        }
        else if(S[K]=='B'){
            S[K]='b';
            
        }
        else if(S[K]=='C'){
            S[K]='c';
        }
    
    cout<<S<<endl;
}


Measured memory_bytes: 256
#ifdef LOCAL
#include <cstdio>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cstring>
#else
#include <bits/stdc++.h>
#endif
using namespace std ;

typedef long long ll ;
#define rep(i , n ) for ( int i =0; i < n ; i++)
#define _sort(arg) sort(begin(arg), end(arg))
#define MOD 1000000007
#define pb push_back
#define DEBUG(x) cout << #x << ": " << x << endl;

/*
__attribute__((constructor))
void initial()
{
	cin.tie(NULL);
	ios::sync_with_stdio(false);
}
*/

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

	int A, B, C;
	
	cin >> A >> B >> C;
	int i = A;
	for (; i <= B*A; i=i+A)
	{
		if (i % B == C)
		{
			break;
		}
	}
	if (i > B * A)
	{
		cout << "NO" << endl;
	}
	else
	{
		cout << "YES" << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define maxc 100010
#define mod 1000000007
int main()
{
    int n;
    cin>>n;
    if(n==1)
        cout<<"Hello World"<<endl;
    else{
        int a,b;
        cin>>a>>b;
        cout<<a+b<<endl;
    }
    return 0;
}


Measured memory_bytes: 384
#include <iostream> // cout, endl, cin
#include <cmath> //sqrt pow
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
 
#define rep(i,n) for(int i = 0; i < n; i++)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define mod 1000000007
using ll = long long;
using namespace std;
int main(){
  int n;
  cin >> n;
  int ans = 0;
  int mx = 0;
  rep(i, n){
    int p;
    cin >> p;
    ans += p;
    mx = max(mx, p);
  }
  ans -= mx / 2;
  cout << ans << endl;
}

Measured memory_bytes: 256
package main

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

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string   { sc.Scan(); return sc.Text() }
func scanRunes() []rune    { return []rune(scanString()) }
func scanInt() int         { a, _ := strconv.Atoi(scanString()); return a }
func scanInt64() int64     { a, _ := strconv.ParseInt(scanString(), 10, 64); return a }
func scanFloat64() float64 { a, _ := strconv.ParseFloat(scanString(), 64); return a }

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = scanInt()
	}
	return res
}

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

//•*¨*•.¸¸♪main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)
func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	n := scanInt()
	cnt := make([]int, n+1)
	for i := 1; i < n+1; i++ {
		for j := 1; i*j <= n; j++ {
			cnt[i*j]++
		}
	}

	ans := 0
	for i := 0; i < n+1; i++ {
		ans += cnt[i] * i
	}
	fmt.Fprintln(wr, ans)
}


Measured memory_bytes: 82500
#include<stdio.h>

int main(){

int fib[50];
int i, x;

fib[0] = fib[1] = 1;

for(i = 2; i < 50; i++){
  fib[i] = fib[i-1] + fib[i-2];
}

scanf("%d", &x);
printf("%d\n", fib[x]);

return 0;
}

Measured memory_bytes: 1852
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please


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


	int N;
	cin >> N;

	map<int, int> MAP;
	rep1(j, N) {
		int kari = j;
		for (int i = 2; i <= j; i++) {
			while (kari % i == 0) {
				MAP[i]++;
				kari /= i;
			}
		}
	}

	int kosuu = MAP.size();
	vector<int> V;
	for (auto itr : MAP) V.pb(itr.second);

	int kotae = 0;
	rep(i, kosuu) {
		if (V[i] >= 74) kotae++;
	}
	rep(i, kosuu * kosuu) {
		int kari1 = i / kosuu;
		int kari2 = i % kosuu;
		if (kari1 != kari2) {
			if (V[kari1] >= 2 && V[kari2] >= 24) kotae++;
		}
	}
	rep(i, kosuu * kosuu) {
		int kari1 = i / kosuu;
		int kari2 = i % kosuu;
		if (kari1 != kari2) {
			if (V[kari1] >= 4 && V[kari2] >= 14) kotae++;
		}
	}
	rep(i, kosuu * kosuu * kosuu) {
		int temp = i;
		int kari1 = temp % kosuu;
		temp /= kosuu;
		int kari2 = temp % kosuu;
		int kari3 = temp / kosuu;
		if (kari1 != kari2 && kari2 != kari3 && kari1 != kari3 && kari2 < kari3) {
			if (V[kari1] >= 2 && V[kari2] >= 4 && V[kari3] >= 4) kotae++;
		}
	}
	co(kotae);

	Would you please 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);
        int a = Integer.parseInt(sc.next());
        int p = Integer.parseInt(sc.next());

        int result = (a * 3 + p) / 2;

        System.out.println(result);
    }
}

Measured memory_bytes: 21844
#include<iostream>
#include<algorithm>

using namespace std;

static const int N = 100;

int main() {
  int n, p[N + 1], m[N + 1][N + 1];

  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> p[i - 1] >> p[i];
  }

  for (int i = 1; i <= n; i++) {
    m[i][i] = 0;
  }

  for (int l = 2; l <= n; l++) {
    for (int i = 1; i <= n - l + 1; i++) {
      int j = i + l - 1;
      m[i][j] = (1 << 21);
      for(int k = i; k <= j - 1; k++) {
        m[i][j] = min(m[i][j], m[i][k] + m[k + 1][j] + p[i - 1] * p[k] * p[j]);
      }
    }
  }

  cout << m[1][n] << endl;

  return 0;
}


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

int main(){
  //使用する変数の初期化
  int n, a, c;
  //数値が何個あるか変数nに代入
  cin >> n;
  //動的配列初期化
  vector<int> v;
  //変数nの数値分ループ
  for(int i = 0; i < n; i++){
    //2で割った回数のカウンタ初期化
    c = 0;
    //2で割る数値を変数aに代入
    cin >> a;
    //2で割り切れる間ループ
    while(a % 2 == 0){
      //2で割った回数+1
      c++;
      //変数aの数値を最新化
      a = a / 2;
    }
    //動的配列の最後尾に変数aを2で割り切れた回数を追加
    v.push_back(c);
  }
  //動的配列の中身を小さい順に並び変える
  sort(v.begin(), v.end());
  //動的配列の先頭を出力
  cout << v[0];
}

Measured memory_bytes: 3600
#include <stdio.h>

int main()
{
  int a,b,i,n;
  while(scanf("%d %d %d",&a,&b,&n)!=EOF){
    int s=0;
    a%=b;
    for (i=0;i<n;i++){
      s+=a*10/b;
      a=a*10%b;
    }
    printf("%d\n",s);
  }

  return 0;
}

Measured memory_bytes: 596
import sys, os, math, bisect, itertools, collections, heapq, queue, copy, array

# from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
# from decimal import Decimal
# from collections import defaultdict, deque

sys.setrecursionlimit(10000000)

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)

MOD = 10 ** 9 + 7
INF = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = ii()
    print(1 if N == 0 else 0)



if __name__ == '__main__':
    main()


Measured memory_bytes: 9828
#include <bits/stdc++.h>
using namespace std;
#define maxn 200050
char input[maxn];
int nxt[maxn][26],dp[maxn];
int main(){
	scanf("%s",input+1);
	int n=strlen(input+1);
	for(int i=0;i<26;++i)
		nxt[n][i]=n+1;
	for(int i=n-1;i>=0;i--){
		for(int j=0;j<26;++j){
			nxt[i][j]=nxt[i+1][j];
		}
		nxt[i][input[i+1]-'a']=i+1;
	}
	for(int i=n;i>=0;i--){
		dp[i]=1e9;
		for(int j=0;j<26;++j)
			dp[i]=min(dp[i],dp[nxt[i][j]]+1);
	}
	int index=0;
	while(index!=n+1){
		for(int j=0;j<26;++j){
			if(dp[index]==dp[nxt[index][j]]+1){
				index=nxt[index][j];
				printf("%c",'a'+j);
				break;
			}
		}
	}
	return 0;
}


Measured memory_bytes: 21632
#include<stdio.h>
int main()
{
  int a=0;
  char s[3];

  scanf("%s", s);

    if(s[0]=='1'){
      a++;
    }
    if(s[1]=='1'){
      a++;
    }
    if(s[2]=='1'){
      a++;
    }
  
  printf("%d", a);
  return 0;
}


Measured memory_bytes: 128
#include <cstdio>

using namespace std;

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

const int N_MAX = 50;

int N, M;
char A[N_MAX][N_MAX + 1];
char B[N_MAX][N_MAX + 1];

void solve() {
  bool found = false;
  REP(a, N - M + 1) REP(b, N - M + 1) {
    bool ok = true;
    REP(i, M) REP(j, M) {
      if (A[a + i][b + j] != B[i][j]) {
        ok = false;
        break;
      }
    }
    if (ok) {
      found = true;
      break;
    }
  }
  puts(found ? "Yes" : "No");
}

void input() {
  scanf("%d%d", &N, &M);
  REP(i, N) scanf("%s", A[i]);
  REP(i, M) scanf("%s", B[i]);
}

int main() {
  input();
  solve();
  return 0;
}


Measured memory_bytes: 128
A, B, C, D = gets.split.map(&:to_i)
MOD = 998244353
result = 1
dp = Array.new(C+1){ Array.new(D+1) }
dp[A][B] = 1

(A+1).upto(C) do |a|
  dp[a][B] = (dp[a-1][B] * B ) % MOD
end

(B+1).upto(D) do |b|
  dp[A][b] = dp[A][b-1] * A
  (A+1).upto(C) do |a|
    dp[a][b] = (dp[a-1][b] * b + dp[a][b-1] * a - ((a-1)*(b-1)*dp[a-1][b-1])) % MOD
  end
end


puts dp[C][D]

Measured memory_bytes: 105060
#include<stdio.h>
#include<iostream>
#include<vector>
#include<math.h>
#include<queue>
#include<map>
#include<algorithm>
#include<string.h>
#include<functional>
#include<limits.h>
#include<stdlib.h>
#include<cmath>
#include<cstring>
#include<set>
#include<climits>
using namespace std;

#define intmax INT_MAX
#define lmax LONG_MAX
#define uintmax UINT_MAX
#define ulmax ULONG_MAX
#define llmax LLONG_MAX
#define ll long long
#define rep(i,a,N) for((i)=(a);(i)<(N);(i)++)
#define rrp(i,N,a) for((i)=(N)-1;(i)>=(a);(i)--)
#define llfor ll i,j
#define sc(a) cin>>a
#define pr(a) cout<<a<<endl
#define pY puts("YES")
#define pN puts("NO")
#define py puts("Yes")
#define pn puts("No")
#define pnn printf("\n")
#define sort(a) sort(a.begin(),a.end())
#define push(a,b) (a).push_back(b)
#define llvec vector<vector<ll>>
#define charvec vector<vector<char>>
#define size(a,b) (a,vector<ll>(b))
#define llpvec vector<pair<ll,ll>>
/*繰り上げ除算*/ll inc(ll x,ll y){ll ans=x/y;if(x%y!=0)ans++;return ans;}
/*最大公約数*/ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
/*最小公倍数*/ll lcm(ll x,ll y){return x/gcd(x,y)*y;}
/*n乗*/ll llpow(ll x,ll n){ll i,ans=1;rep(i,0,n)ans*=x;return ans;}
/*階乗*/ll fact(ll x){ll i,ans=1;rep(i,0,x)ans*=(x-i);return ans;}
/*nCr*/ll ncr(ll n,ll r){return fact(n)/fact(r)/fact(n-r);}
/*nPr*/ll npr(ll n,ll r){return fact(n)/fact(n-r);}
/*primejudge*/bool prime(ll a){if(a<=1)return false;ll i;for(i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}
llfor;///////////////////////////////////////////////////////////
int main(){
 ll h,n;
 sc(h);sc(n);
 llpvec pair(n);
 ll a,b,dp[30000];//[i番目の魔法までを使って][減る体力]=消耗する魔力の最小

 rep(j,0,30000){dp[j]=llpow(10,8)+10;}
 rep(i,0,n){
  sc(a);sc(b);pair[i]={b,a};
  dp[a]=b;
 } 
  
 ll cnt=0;  
 ll ans=inc(h,pair[0].second)*pair[0].first;
 dp[0]=0;
 rep(i,0,h){
  rep(j,0,n){
   dp[i+pair[j].second]=min(dp[i]+pair[j].first,dp[i+pair[j].second]);

  }
 }
 rep(i,h,30000)ans=min(ans,dp[i]);
 pr(ans); 
  
return 0;}

Measured memory_bytes: 3844
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<ll,ll> ii;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define RST(i,n) memset(i,n,sizeof i)
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(),a.end()
#define X first
#define Y second
#define mkp make_pair
#define pb push_back
#define eb emplace_back
#define pob pop_back
#ifdef cold66
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<" ,";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // cold66
//}
template<class T> inline bool chkmax(T &a, const T &b) { return b > a ? a = b, true : false; }
template<class T> inline bool chkmin(T &a, const T &b) { return b < a ? a = b, true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;

const ll MAXn=1e5+5,MAXlg=__lg(MAXn)+2;
const ll MOD=1000000007;
const ll INF=0x3f3f3f3f;

int main(){
  IOS();
  int a,b;
  cin>>a>>b;
  int tmp = a*b;
  if( tmp&1 ) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
#define int long long
int mod=1e9+7;

signed main()
{

    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n,m;
    cin>>n>>m;
    vector<vector<int>> dp(n,vector<int> (m,0));
    char a[n][m];

    for (int i=0;i<n;++i)
        for (int j=0;j<m;++j)
            cin>>a[i][j];

    if (a[0][0]=='#')
        return 0;
    else
        dp[0][0]=1;

    for (int i=1;i<n;++i)
    {
        if (a[i][0]!='#')
            dp[i][0]=dp[i-1][0];
        else
            break;
    }

    for (int j=1;j<m;++j)
    {
        if (a[0][j]!='#')
            dp[0][j]=dp[0][j-1];
        else
            break;
    }


    for (int i=1;i<n;++i)
    {
        for (int j=1;j<m;++j)
        {
            if (a[i][j]=='.')
            {
                dp[i][j]=0;
                if (a[i-1][j]=='.' && dp[i-1][j]!=-1)
                    dp[i][j]+=dp[i-1][j];
                if (a[i][j-1]=='.' && dp[i][j-1]!=-1)
                    dp[i][j]+=dp[i][j-1];
                dp[i][j]=dp[i][j]%mod;
            }
            else
                dp[i][j]=-1;
        }
    }

    cout<<dp[n-1][m-1]<<endl;
}


Measured memory_bytes: 12108
#include <cstdio>           // printf(), scanf()
#include <cmath>            // fabs(), sqrt()
#include <vector>
#include <utility>          // pair
#include <algorithm>        // sort(), inplace_merge()

using namespace std;
typedef pair<double, double> P; // first ??? x ??§?¨????second ??? y ??§?¨?

static const int MAX_N = 100000;
static const int INF = 1000000000;

P A[MAX_N];
int N;

bool
cmp_func(P a, P b)
{
	return a.second < b.second;
}

double
closest_pair(P* a, int n)
{
	double t;

	if (n <= 1)
		return INF;

	int m = n / 2;
	double x = a[m].first;
	double d = closest_pair(a, m); // (1)
	t = closest_pair(a + m, n - m);
	if (t < d)
		d = t;

	inplace_merge(a, a + m, a + n, cmp_func); // ??????????????????????????????????????????
	// ??????????????§ a ??? y ??§?¨??????????????????£?????????

	//x (2')
	vector<P> b; // ??´??????????????¢ d ????????????????????\????????????
	for (int i = 0; i < n; ++i)
	{
		if (fabs(a[i].first - x) >= d)
			continue;

		// b ?????\??£?????????????????????????°??????????y ??§?¨?????????? d ??\?????????????????§????????????
		for (unsigned int j = 0; j < b.size(); ++j)
		{
			double dx = a[i].first - b[b.size() - j - 1].first;
			double dy = a[i].second - b[b.size() - j - 1].second;
			if (dy >= d)
				break;

			t = sqrt(dx * dx + dy * dy);
			if (t < d)
				d = t;
		}

		b.push_back(a[i]);
	}

	return d;
}

int
main(int argc, char** argv)
{
	scanf("%d", &N);
	for (int i = 0; i < N; ++i)
		scanf("%lf %lf", &A[i].first, &A[i].second);

	sort(A, A + N);
	printf("%.10f\n", closest_pair(A, N));
	return 0;
}

Measured memory_bytes: 7356
#include <stdio.h>
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>

using ll = long long int;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

int main(void){
	int n,l,r,ans=0;
	std::string s;
	std::cin >> n;
	std::cin >> s;
	l = 0; r = n-1;
	while(l<r){
		if(s[l]=='R'){
			++l;
		}else if(s[r]=='W'){
			--r;
		}else{
			std::swap(s[l],s[r]);
			++l; --r;
			++ans;
		}
	}
	std::cout << ans << std::endl;
	return 0;
}


Measured memory_bytes: 3752
#include<bits/stdc++.h>
using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int INF = 1061109567;
const ll LINF = 4557430888798830399ll;

/* --- */

ll a[300005];

void TestCase() {
    int n;
    scanf("%d", &n);
    for(int i = 1; i <= n; ++i) {
        scanf("%lld", &a[i]);
        a[i] -= i;
    }
    sort(a + 1, a + 1 + n);
    ll mid = a[(n + 1) / 2];
    ll sum = 0;
    for(int i = 1; i <= n; ++i) {
        sum += abs(mid - a[i]);
    }
    printf("%lld\n", sum);
}

int main() {
#ifdef KisekiPurin
    freopen("KisekiPurin.in", "r", stdin);
    //freopen("KisekiPurin.out", "w", stdout);
#endif // KisekiPurin
    //InitCase();
    int t = 1;
    //scanf("%d", &t);
    for(int i = 1; i <= t; ++i) {
        //printf("Case #%d: ", i);
        TestCase();
    }
    return 0;
}


Measured memory_bytes: 1792
N, M = map(int, input().split())
# [[展望台の高さ, 道の数, 自分より高い展望台がない],[], ...] を
# ループの中で更新してくこととする
info_list = list()
for h in map(int, input().split()):
    info_list.append([h, 0, True])

for i in range(M):
    ai, bi = map(int, input().split())
    # 道の数更新
    info_list[ai - 1][1] += 1
    info_list[bi - 1][1] += 1
    # 高い展望台あるかどうか更新
    # print(info_list[ai - 1][0])
    # print(info_list[bi - 1][0])
    if info_list[ai - 1][0] < info_list[bi - 1][0]:
        # print("a")
        info_list[ai - 1][2] = False
    elif info_list[ai - 1][0] > info_list[bi - 1][0]:
        # print("b")
        info_list[bi - 1][2] = False
    else:
        # print("a=b")
        # 問題分より同じ高さの場合はどちらも良い展望台はではない解釈した
        info_list[ai - 1][2] = False
        info_list[bi - 1][2] = False
    # print(info_list)


result = len([i for i in info_list if i[2]])
print(result)



Measured memory_bytes: 99160