akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(int)(n); i++)

using namespace std;
typedef long long LL;
typedef pair<int,int> P;

int main(){
	int N, M;
	cin >> N >> M;
	cout << N*(N-1)/2+M*(M-1)/2 << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <cmath>
#include <map>
#include <numeric>
#include <iomanip>


int main(void) {
	double j = 0, b = 0;

	long long n;

	std::cin >> n;

	for (size_t i = 0; i < n; i++) {
		double x;
		std::string u;
		std::cin >> x >> u;
		if (u == "JPY") {
			j += x;
		}
		else {
			b += x;
		}
	}

	std::cout << j + b * (380000.0) << std::endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iomanip> 
using namespace std; 
#define rep(i,a,b)		for(long int i=a;i<=b;i++)
#define MOD 1e9+7

long long d,n;
int main() 
{ 
	ios::sync_with_stdio(false);
    cin.tie(NULL);  
   
    
    cin>>d>>n;
    if(n<100)
    	cout<<pow(100,d)*n;
    else
    	cout<<setprecision(20)<<pow(100,d)*n+pow(100,d);
}
	

Measured memory_bytes: 3840
import sys
sys.setrecursionlimit(10 ** 9)

x = int(input())

def Add(count, list, change, check):
    # 出力
    if count <= 0:
        print(''.join(map(str, list)))
        return

    # 桁数の増加
    if all(item == 9 for item in list):
        list = [0 for y in range(0, len(list) + 1)]
        list[0] = 1
        Add(count - 1, list, len(list) - 1, max(0, len(list) - 2))
        return

    # 加算できる桁に加算
    if list[change] <= list[check] and list[change] < 9:
        list[change] += 1
        Clean(list, change + 1)
        Add(count - 1, list, len(list) - 1, max(0, len(list) - 2))
        return

    # 一つ上の桁を確認
    else:
        Add(count, list, change - 1, max(0, change - 2))
        return

# changeより下の桁を最小にする
def Clean(list, change):
    if change >= len(list):
        return
    for x in range(change, len(list)):
        list[x] = max(0, list[max(0, x - 1)] - 1)


Add(x, [0], 0, 0)

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

using namespace std;

int main()
{
    long long a, b;
    cin >> a >> b;
    if(a * b <= 0) cout << "Zero" << '\n';
    else{
        if(a > 0) cout << "Positive" << '\n';
        else{
            cout << ((b-a+1) & 1 ? "Negative" : "Positive") << '\n';
        }
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <iomanip>
#include <ios>
using namespace std;
int main(void){
  long N;
  cin >> N;
  
  long a,b,f;
  long ans = 100;
  
  for(long i=1;i<100001;i++){
    if(N % i == 0){
      a = i;
      b = N / i;
      string A = to_string(a);
      string B = to_string(b);
      f = max(A.length(),B.length());
      
      if(ans > f)
        ans = f;
    }
  }
  
  cout << ans << endl;
  
  return 0;
}

      


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
typedef pair<ll,ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; } template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define M 1000000007
#define all(a) (a).begin(),(a).end()
#define rep(i,n) reps(i,0,n)
#define reps(i,m,n) for(int i=(m);i<(n);i++)
int main(){
  int n;cin>>n;
  int a=n/100;
  for(int i=a;i>=0;i--){
    if(i*5>=n-a*100){
      cout<<1;return 0;
    }
  }
  cout<<0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
import java.util.Collections;
import java.util.StringTokenizer;
 
public class Main {
	
	static int N = (int)1e9 + 7;
	static int dp[];
 
	public static void main(String[] args) {
		FastScanner sc=new FastScanner();

		int n = sc.nextInt();
		int a[] = sc.readArray(n);
		dp = new int[n+1];
		Arrays.fill(dp, N);
		dp[0] = 0;
		for(int i = 0 ; i < n ; ++i ) {
			for(int j : new int[]{i+1  , i+2}) {
				if(j < n) {
					dp[j] = Math.min(dp[j], dp[i] + Math.abs(a[j] - a[i]));
				}
			}
		}
		System.out.println(dp[n-1]);
		
	}
	
	public void sort(int[] a) {
		ArrayList<Integer> l=new ArrayList<>();
		for (int i:a) l.add(i);
		Collections.sort(l);
		for (int i=0; i<a.length; i++) a[i]=l.get(i);
	}
	
	static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		
		public String next() {
			while (!st.hasMoreElements())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}
		
		int nextInt() {
			return Integer.parseInt(next());
		}
		
		long nextLong() {
			return Long.parseLong(next());
		}
		
		int[] readArray(int n) {
			int[] a=new int[n];
			for (int i=0; i<n; i++) a[i]=nextInt();
			return a;
		}
	}
 
}


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

int main () {
  string S, t = "YAKI";
  cin >> S;

  bool ans = true;
  if (S.size() < 4) {
      ans = false;
    }
  else {
    for (int i = 0; i < 4; i++) {
      if (S.at(i) != t.at(i)) {
        ans = false;
      }
    }
  }
  if (ans) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
using namespace std;
char s[105];
int main()
{
    scanf("%s",s);
    int len=strlen(s);
    if(len!=6){printf("No\n");return 0;}
    if(s[2]==s[3]&&s[4]==s[5])
        printf("Yes\n");
    else printf("No\n");
    return 0;
}


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

int main() {
    int n;
    cin >> n;
    map<string, int> mp;
    rep(i,n){
        string s;
        cin >> s;
        mp[s]++;
    }
    cout << mp.size() << endl;
    return 0; 
}

Measured memory_bytes: 19204
// 2014/07/07 Tazoe

#include <iostream>
using namespace std;

int main()
{
	while(true){
		int n;
		cin >> n;

		if(n==0)
			break;

		int h[101];
		for(int i=0; i<n+1; i++){
			cin >> h[i];
		}

		for(int i=0; i<n+1; i++){
			int tmp[100];
			for(int j=0; j<i; j++){
				tmp[j] = h[j];
			}
			for(int j=i+1; j<n+1; j++){
				tmp[j-1] = h[j];
			}

			int d = tmp[1]-tmp[0];
			bool flg = true;
			for(int j=1; j<n-1; j++){
				if(tmp[j+1]-tmp[j]!=d){
					flg = false;
					break;
				}
			}

			if(flg){
				cout << h[i] << endl;
				break;
			}
		}
	}

	return 0;
}

Measured memory_bytes: 1160
#include <iostream>

using namespace std;

int main()
{
    int n, k;
    long long ans=1;
    cin>>n>>k;
    for (int i=0; i<n; i++)
    {
        if (i==0) ans*=k;
        else ans*=(k-1);
    }
    cout<<ans<<'\n';
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define INF 1000000001
//0=48,A=65,a=97

int main() {
    ll q,h,s,d,n;cin >> q >> h >> s >> d >> n;
    ll x=min(min(4*q,2*h),s);
    if(2*x<=d){
        cout << x*n << endl;
        return 0;
    }

    else{
        if(n%2==0){
            cout << n/2*d << endl;

        }
        else{
            cout << (n-1)/2*d+x << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 3592
#include <iostream>
#include <string>

using namespace std;

int main() {
    string s, t;    cin >> s >> t;
    int len = s.length();

    for (int i = len; i > 0; i--) {
        bool can = true;
        for (int j = i; j - i + 1 <= len; j++) {
            if (s[j%len] != t[j-i])
                can = false;
        }
        if (can) {
            cout << "Yes" << endl;
            return 0;
        }
    }

    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 760
import java.util.Scanner;
public class Main {

//最小公倍数lcm
static long lcm (long a, long b) {
	long temp;
	long c = a;
	c *= b;
	while((temp = a%b)!=0) {
		a = b;
		b = temp;
	}
	return (long)(c/b);
}
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		
		long a = stdIn.nextLong();
		long b = stdIn.nextLong();
		long c = stdIn.nextLong();
		long d = stdIn.nextLong();
		
		/*long cnt = 0;
		for(long i = a; i <= b; i++) {
			if(i%c!=0 && i%d != 0) {
				cnt++;
			}
		}
		System.out.println(cnt);
		
		*/
		
		long acnt = b/c; //cで割り切れる数
		long bcnt = b/d;
		long l = lcm(c,d);
		long abcnt = b/l;
		
		long atemp = (a-1)/c;
		long btemp = (a-1)/d;
		long abtemp = (a-1)/l;
		
		long atmp = acnt-atemp;
		long btmp = bcnt-btemp;
		long abtmp = abcnt - abtemp;
		
		long ans = (b-a+1)-(atmp+btmp-abtmp);
		System.out.println(ans);
	}

}


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

void solve(long long N, long long M, std::vector<long long> A)
{
    sort(begin(A), end(A));

    while (M > 0)
    {
        while (M > 0 && (A.size() == 1 || A.back() / A[A.size() - 2] >= 2))
        {
            A.back() /= 2;
            M--;
        }

        auto it = upper_bound(begin(A), end(A), A.back() / 2);
        it += max(distance(it, end(A)) - M, 0LL);
        if (it != end(A))
        {
            transform(it, end(A), it, [](int n) { return n / 2; });
            M -= distance(it, end(A));
            sort(begin(A), end(A));
        }
    }

    long long ans = accumulate(begin(A), end(A), 0LL);
    cout << ans << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main()
{
    long long N;
    scanf("%lld", &N);
    long long M;
    scanf("%lld", &M);
    std::vector<long long> A(N);
    for (int i = 0; i < N; i++)
    {
        scanf("%lld", &A[i]);
    }
    solve(N, M, std::move(A));
    return 0;
}


Measured memory_bytes: 1024
import sys

class Node():
    def __init__(self,key):
        self.key = key
        self.left = None
        self.right = None

def insert(t, z):
    y = None
    x = t
    while x is not None:
        y = x
        if z.key < x.key:
            x = x.left
        else:
            x = x.right

    if y is None:
        return z
    else:
        if z.key < y.key:
            y.left = z
        else:
            y.right = z
        return t

def in_order(t):
    s = ""
    l = []
    curr = t
    while True:
        while curr is not None:
            l.append(curr)
            curr = curr.left
        if curr is None and len(l) == 0:
            break
        else:
            curr = l.pop()
            s += " " + str(curr.key)
            curr = curr.right
    return s

def pre_order(t):
    s = ""
    l = []
    curr = t
    while True:
        while curr is not None:
            s += " " + str(curr.key)
            l.append(curr)
            curr = curr.left
        if curr is None and len(l) == 0:
            break
        else:
            curr = l.pop()
            curr = curr.right
    return s

t = None
n = sys.stdin.readline()
lines = sys.stdin.readlines()
for line in lines:
    com = line.split()
    if com[0] == "insert":
        t = insert(t, Node(int(com[1])))
    else:
        print(in_order(t))
        print(pre_order(t))

Measured memory_bytes: 152088
/*
 * main.c
 *
 *  Created on: 2020/03/28
 *      Author: family
 */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define MAX(a,b) (a > b ? a : b)
#define MIN(a,b) (a > b ? b : a)
typedef long long int ll;
typedef unsigned long long int ull;

int sort_inc(const void *a, const void *b) { return (*(int*)a - *(int*)b);}
int sort_dec(const void* a, const void* b) { return (*(int*)b - *(int*)a);}
int sort_dec_ll(const void *a, const void *b) {
    ll da = *(ll*)a, db = *(ll*)b;    int val = 0;
    if(da > db) { val = -1; }
    else if (da == db) { val = 0; }
    else { val = 1; }
    return val;
}
int sort_inc_ll(const void *a, const void *b) {
    ll da = *(ll*)a, db = *(ll*)b;    int val = 0;
    if(da > db) { val = 1; }
    else if (da == db) { val = 0; }
    else { val = -1; }
    return val;
}
int sort_dic(const void *a, const void *b) {
    char *pa = (char *)a;    char *pb = (char *)b;    int i = 0, val = 0, N = 10;
    for (i = 0; i < N; i++) {
    	char da = pa[i], db = pb[i];
    	if (da == db) continue;
  		if (da > db) val = 1; else val = -1;
        break;
    }
    return val;
}


int main()
{
	int A = 0, B = 0, C = 0, tmp = 0;
	scanf("%d %d %d", &A, &B, &C);
	tmp = A;
	A = B;
	B = tmp;
	tmp = A;
	A = C;
	C = tmp;
	printf("%d %d %d\n", A, B, C);
    return 0;
}


Measured memory_bytes: 128
n,k,*a=map(int,open(0).read().split())
a=[x-1 for x in a]
dist=[0]*n
cur=0
while True:
	nxt=a[cur]
	if k==0:
		print(cur+1)
		break
	if dist[nxt]:
		k=(k-dist[nxt])%(dist[cur]-dist[nxt]+1)+dist[nxt]
		k-=1
		dist=[0]*n
		cur=nxt
	else:
		k-=1
		dist[nxt]=dist[cur]+1
		cur=nxt

Measured memory_bytes: 113600
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/














int N, M, L, Q;
ll D[303][303];
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> N >> M >> L;
	rep(i, 0, N) rep(j, 0, N) {
		if (i != j) D[i][j] = infl;
		else D[i][j] = 0;
	}
	rep(i, 0, M) {
		int a, b, c; cin >> a >> b >> c;
		a--; b--;
		D[a][b] = D[b][a] = c;
	}
	rep(k, 0, N) rep(i, 0, N) rep(j, 0, N) chmin(D[i][j], D[i][k] + D[k][j]);

	rep(i, 0, N) rep(j, 0, N) {
		if (i != j) {
			if (D[i][j] <= L) D[i][j] = 1;
			else D[i][j] = infl;
		}
		else D[i][j] = 0;
	}
	rep(k, 0, N) rep(i, 0, N) rep(j, 0, N) chmin(D[i][j], D[i][k] + D[k][j]);

	cin >> Q;
	rep(q, 0, Q) {
		int s, t; cin >> s >> t; s--; t--;

		ll ans = D[s][t];
		if (ans == infl) ans = -1;
		else ans--;
		printf("%lld\n", ans);
	}
}







Measured memory_bytes: 1280
import sys
import math
from collections import defaultdict
from bisect import bisect_left, bisect_right

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def LI(): return list(map(int, input().split()))
def LIR(row,col):
    if row <= 0:
        return [[] for _ in range(col)]
    elif col == 1:
        return [I() for _ in range(row)]
    else:
        read_all = [LI() for _ in range(row)]
        return map(list, zip(*read_all))

#################

X = I()

num = X//500
print(num*1000 + ((X-num*500)//5) *5)

Measured memory_bytes: 38384
sx, sy, tx, ty = map(int, input().split())

dx = tx - sx
dy = ty - sy

def _dflip(c):
    return {
        'U': 'R',
        'R': 'U',
        'D': 'L',
        'L': 'D',
    }[c]

def dflip(s):
    return ''.join(map(_dflip, s))

def g(dx, dy):
    return 'R' * dx + 'U' * (dy+1) + 'L' * (dx+1) + 'D' * (dy+1) + 'R'

def f(dx, dy):
    if dx > 0 and dy > 0:
        return g(dx, dy) + dflip(g(dy, dx))
    if dy == 0:
        return 'R' * dx + 'U' + 'L' * dx + 'DD' + 'R' * (dx) + 'URUU' + 'L' * (dx+2) + 'DDR'
    if dx == 0:
        return dflip(f(dy, dx))

print(f(dx, dy))

Measured memory_bytes: 3064
#include<iostream>
#include <stdio.h>
#include <string.h>
#define MAXT 2 * 10 * 10 * 10 * 10 * 10

using namespace std;

char s[MAXT] = {0};

int main()
{
	cin >> s;
	int lenS = strlen(s);

	for (int i = 0; i < lenS; i++)
	{
		if ((s[i] == '?') && (i + 1) < lenS)
		{
			if (i == 0)
			{
				if (s[i+1] == 'D') s[i] = 'P';
				else if (s[i+1] == 'P') s[i] = 'D';
				else if (s[i+1] == '?') s[i] = 'P';
			}
			else
			{
				if ((s[i-1] == 'P') || (s[i-1] == '?')) s[i] = 'D';
				else if (s[i+1] == 'P') s[i] = 'D';
				else if (s[i+1] == '?') s[i] = 'P';
				else s[i] = 'D';
			}
		}
		else if ((s[i] == '?') && (i + 1) == lenS) s[i] = 'D'; 
	}
	cout << s << endl;
	
	return 0; 
}


Measured memory_bytes: 3824
#include <bits/stdc++.h>
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define all(x) x.begin(), x.end()

using namespace std;

typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
typedef long long ll;

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

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

void solve(){	
  int n,k;cin>>n>>k;
  int mat[k][n+1];
  memset(mat,0,sizeof mat);
  for(int i=0;i<k;i++){
    int amount; cin>>amount;
    for(int j=0;j<amount;j++){
      int person;cin>>person;
      mat[i][person] = 1;
    }
  }
  int ans = 0;
  for(int i=1;i<=n;i++){
    bool t = true;
    for(int j=0;j<k;j++){
      if(mat[j][i] == 1){
        t = false;
        break;
      }
    }
    if(t){
      ans++;
    }
  }
  cout<<ans<<endl;
}

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


Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using Map = map<ll,vl>;
using Tu = tuple<ll,ll,ll>;
using vvl = vector<vector<ll>>;
const ll INF=1LL<<60;
const ll MOD=1000000007;


int main(){
    ll X;
    cin >> X;
    ll Y;
    cin >> Y;
    ll Z;
    cin >> Z;
    ll K;
    cin >> K;
    vector<ll> A(X,0);
    vector<ll> B(Y,0);
    vector<ll> C(Z,0);
    for(ll i=0;i<X;i++){
        cin>>A[i]
    ;}
    for(ll i=0;i<Y;i++){
        cin>>B[i]
    ;}
    for(ll i=0;i<Z;i++){
        cin>>C[i]
    ;}
    vector<ll> AB(0);
    for(ll i=0;i<X;i++){
        for(ll j=0;j<Y;j++){
            AB.emplace_back(A[i]+B[j]);
        ;}
    ;}
    sort(AB.rbegin(), AB.rend());
    vector<ll> ans(0);
    ll o=min(X*Y,K);
    for(ll i=0;i<o;i++){
     for(ll j=0;j<Z;j++){
         ans.emplace_back(AB[i]+C[j]);
     ;}
    ;}
    sort(ans.rbegin(), ans.rend());
    for(ll i=0;i<K;i++){
        cout<<ans[i]<<endl;
    ;}

    return 0;
}


Measured memory_bytes: 43368
#define _CRT_SECURE_NO_WARNINGS
#define _SCL_SECURE_NO_WARNINGS
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>
#include <functional>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
#include <sstream>
#include <numeric>
#include <list>
#include <bitset>
#include <fstream>

using namespace std;
#define REP(i,a,n) for(int i = (a); i < (int)(n); ++i)
#define REM(i,a,n) for(int i = ((n) - 1); i >= (a); --i)
#define EPS 1e-11
#define INF 0x3FFFFFFF
#define INFLL 0x3FFFFFFF3FFFFFFF
#define INFD 1.0e+308
#define FLOAT setprecision(16)
const double PI = 3.1415926535897932;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<LL, LL> PP;

template <class T, class U>
istream& operator >> (istream& ist, pair<T, U>& right) { return ist >> right.first >> right.second; }
template <class T, class U>
ostream& operator<<(ostream& ost, pair<T, U>& right) { return ost << right.first << ' ' << right.second; }
template <class T, class TCompatible, size_t N>
void Fill(T(&dest)[N], const TCompatible& val) { fill(begin(dest), end(dest), val); }
template <class T, class TCompatible, size_t M, size_t N>
void Fill(T(&dest)[M][N], const TCompatible& val) { for (int i = 0; i < M; ++i) Fill(dest[i], val); }
//sum, 累積和
// 負のときの割り算に注意
#if 1
#include <array>
#include <random>
#include <unordered_set>
#include <unordered_map>
template<class T>
using PriorityQ = priority_queue<T, vector<T>, greater<T> >;	// コスト小を優先
#endif

#ifdef ONLY_MY_ENVIR
#include "IntMod.h"
#include "Union_Find.h"
#include "Graph.h"
#include "Suffix_Array.h"
#include "Matrix.h"
#endif

#ifdef __GNUC__
typedef __int128 LLL;
istream& operator >> (istream& ist, __int128& val) { LL tmp;  ist >> tmp; val = tmp; return ist; }
ostream& operator<< (ostream& ost, __int128 val) { LL tmp = val; ost << tmp; return ost; }
#endif

int H, W, h, w;
LL A[500][500];
bool solve() {
	if (h == 1 && w == 1) return false;
	LL sum = 0;

	LL plus = 999999999 / (h * w - 1);
	LL minus = (h * w - 1) * plus + 1;
	REP(i, 0, H) {
		REP(j, 0, W) {
			A[i][j] = (i % h == h - 1 && j % w == w - 1 ? -minus : plus);
			sum += A[i][j];
		}
	}
	return sum > 0;
}

int main() {
	cin >> H >> W >> h >> w;
	int ok = solve();
	cout << (ok ? "Yes" : "No") << endl;
	if (ok) {
		REP(i, 0, H) {
			REP(j, 0, W) {
				cout << A[i][j] << (j == W - 1 ? '\n' : ' ');
			}
		}
	}

	return 0;
}


Measured memory_bytes: 4864
import java.util.*;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long k = sc.nextInt();
        long[] a = new long[n];
        long[] sum = new long[n+1];
        Map<Integer, Integer> map = new HashMap<>();
        long res = 0;
        map.put(0, 1);
        for(int i=0; i<n; i++) {
            a[i] = (sc.nextLong() + k - 1) % k;
            sum[i+1] = (sum[i] + a[i]) % k;
            int key = (int) sum[i+1];
            if(i-k+1 >= 0) {
                int k2 = (int)sum[(int)(i-k+1)];
                map.put(k2, map.get(k2)-1);
            }
            int count = map.getOrDefault(key, 0);
            res += count;
            map.put(key, count+1);
        }
        System.out.println(res);

    }

}


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

const int LEN = 1e5 + 7;

char st[LEN];
int st1[LEN], st2[LEN], N;
// b = 2, d = 3, p = 4, q = 5
int main() {
	scanf("%s",st);
	N = strlen(st);
	for(int i = 0; i < N; ++i) {
		int x;
		switch(st[i]) {
			case 'b': x = 2; break;
			case 'd': x = 3; break;
			case 'p': x = 4; break;
			case 'q': x = 5; break;
		}
		st1[i + 1] = x;
		st2[N - i] = (x ^ 1);
	}
	for(int i = 1; i <= N; ++i) {
		if(st1[i] != st2[i]) {
			printf("No\n");
			return 0;
		}
	}
	printf("Yes\n");
	return 0;
}

Measured memory_bytes: 1152
#include <cstdio>
#include <cstdlib>
#include <queue>

using namespace std;

typedef pair<long,long> P;

long N,M,Q;
long c[100000],v[100000];
int d[100000];

vector<long> G[100000];

long dp[100000][10];
long col[100000];

void rec(long s,int n,long co);

int main(){
	scanf("%ld %ld",&N,&M);
	for(long i=0;i<M;i++){
	  	long a,b;
		scanf("%ld %ld",&a,&b);
		a--;
		b--;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	scanf("%ld",&Q);
	for(long i=0;i<Q;i++){
		scanf("%ld %d %ld",&v[i],&d[i],&c[i]);
		v[i]--;
	}
	for(long i=Q-1;i>=0;i--){
		rec(v[i],d[i],c[i]);
	}
	for(long i=0;i<N;i++){
		printf("%ld\n",col[i]);
	}


	return 0;
}

void rec(long s,int n,long co){
	if(n==0){
		if(col[s]==0) col[s] = co;
		return;
	}
	if(dp[s][n]!=0) return;
	dp[s][n] = 1;
	rec(s,n-1,co);
	for(int i=0;i<G[s].size();i++){
		rec(G[s][i],n-1,co);
	}

}


Measured memory_bytes: 17396
#include <bits/stdc++.h>
#define long long long int
using namespace std;

// @author: pashka

int main() {
    ios::sync_with_stdio(false);

    long n;
    cin >> n;
    if (n % 2 == 1) {
        cout << 0;
        return 0;
    }
    n /= 2;
    // n! = 5^k * x, k = ?
    // n! = 1 2 3 4 (5) 6 7 8 9 (10) 11 12 ...  (25)
    
    long x = 5;
    long res = 0;
    while (x <= n) {
        res += n / x;
        x *= 5;
    }
    cout << res;

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.List;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.Arrays;
import java.util.Collections;
import java.util.*;
class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int n = scan.nextInt();
    if (n<=1000) {
      System.out.println(1000-n);
    }
    else if (n<=2000) {
      System.out.println(2000-n);
    }
    else if (n<=3000) {
      System.out.println(3000-n);
    }
    else if(n<=4000){
      System.out.println(4000-n);
    }
    else if (n<=5000) {
      System.out.println(5000-n);
    }
    else if (n<=6000) {
      System.out.println(6000-n);
    }
    else if(n<=7000){
      System.out.println(7000-n);
    }
    else if (n<=8000) {
      System.out.println(8000-n);
    }
    else if (n<=9000) {
      System.out.println(9000-n);
    }
    else{
      System.out.println(10000-n);
    }
  }
}


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

int N;
const int MAX_N = 1.0e5 + 100;
map<int, int> mp;

int main() {
    cin >> N;
    for (int i = 0; i < N; i++) {
        int A_in;
        cin >> A_in;
        mp[A_in]++;
    }

    vector<int> stick;
    for (auto itr = mp.begin(); itr != mp.end(); itr++) {
        int key = itr->first;
        int val = itr->second;

        if (val >= 2) stick.push_back(key);
        if (val >= 4) stick.push_back(key);
    }

    sort(begin(stick), end(stick), greater<>());

    if (stick.size() <= 1) cout << 0 << endl;
    else cout << (ll)stick[0] * (ll)stick[1] << endl;


    return 0;
}


Measured memory_bytes: 4992
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
typedef unsigned int uint;
using namespace std;

int main(){
  int x,t;
  cin >> x >> t;
  cout << max(0,x-t) << endl;
  return 0;
}


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


void dfs(int now, int prev, int prev_sum, vector<int>& ans, vector<vector<int>>& adj){
  ans[now] = ans[now] + prev_sum;
  for(auto next: adj[now]){
    if(next != prev){
      dfs(next, now, ans[now], ans, adj);
    }
  }
}

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

  vector<vector<int>> adj(N);
  for(int i = 0; i < N - 1; i++){
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    adj[a].push_back(b);
    adj[b].push_back(a);
  }

  vector<int> ans(N);
  for(int q = 0; q < Q; q++){
    int p, x;
    cin >> p >> x;
    p--;
    ans[p] += x;
  }

  dfs(0, -1, 0, ans, adj);
  for(int i = 0; i < N; i++){
    if(i){
      cout << ' ';
    }
    cout << ans[i];
  }
  cout << endl;
}


Measured memory_bytes: 26624
#include <iostream>
#include <ios>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <utility>
#include <typeinfo>
#include <tuple>
using namespace std;

#define MOD 1000000007
#define INF 1e9+7
#define INF_LONG 1e18
#define rep(i, n) for(int i=0; i<n; ++i)
#define rep1(i, n) for(int i=1; i<=n; ++i)
#define rrep(i, m, n) for(int i=m; i<n; ++i)
#define countof(array) (sizeof(array) / sizeof(array[0]))
typedef long long ll;

#define MAX_N 200000
#define MAX_M 100000
#define MAX_V 100
#define MAX_E 100
#define MAX_Q 100000

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

int ddx[] = {-1, 0, 1, 0, -1, 1, -1, 1};
int ddy[] = {0, -1, 0, 1, 1, 1, -1, -1};

string as = {"ABCDEFGHIJKLMNOPQRSTUVWXYZ"};
string ab = {"abcdefghijklmnopqrstuvwxyz"};

ll gcd(ll x, ll y) {
  if(y==0) return x;
  else return gcd(y, x%y);
}

ll lcm(ll x, ll y) {
  return (x*y)/gcd(x, y);
}

void yes() {
  cout << "Yes" << endl;
}

void no() {
  cout << "No" << endl;
}

void print_array(int array[], int len) {

  for(int i=0; i<len; ++i) {
    cout << array[i] << endl;
  }

}

ll absolute(ll x) {
  return (x<0)? (-1)*x : x;
}

//g++ AtCoder.cpp -o AtCoder
//AtCoder

//--------------------------



int main() {

  int a, b;
  cin >> a >> b;

  if((a+b)%2!=0) cout << "IMPOSSIBLE" << endl;
  else cout << (a+b)/2 << endl;

  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <functional>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef pair<int,int> P;
typedef pair<P,int> PP;
int main(){
	while(true){
		int m,t,p,r;
		scanf("%d%d%d%d",&m,&t,&p,&r);
		if(m==0) break;
		int tim[50][10]={},wa[50][10]={};
		rep(i,50) rep(j,10) tim[i][j]=-1;
		rep(i,r){
			int mm,tt,pp,jj;
			scanf("%d%d%d%d",&mm,&tt,&pp,&jj);
			tt--,pp--;
			if(jj==0) tim[tt][pp]=mm+wa[tt][pp]*20;
			else wa[tt][pp]++;
		}
		int pen[50]={},acp[50]={};
		rep(i,t) rep(j,p){
			if(tim[i][j]==-1) continue;
			acp[i]++;
			pen[i]+=tim[i][j];
		}
		vector<PP> vc;
		rep(i,t) vc.push_back(PP(P(acp[i],-pen[i]),i+1));
		sort(vc.begin(),vc.end(),greater<PP>());
		rep(i,t){
			if(i==0){
				printf("%d",vc[i].second);
				continue;
			}
			if(vc[i].first==vc[i-1].first) printf("=%d",vc[i].second);
			else printf(",%d",vc[i].second);
//			cout << vc[i].second << " acp " << vc[i].first.first << " pen " << vc[i].first.second << endl;
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 1200
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<bitset>
#include<unordered_map>
#include<climits>
#include<fstream>
using namespace std;
///////////////////library zone!!!!!!!!!!!!!!!!!!!!!!!!!!!!
typedef long long ll;
typedef long double ld;
#define all(a) (a).begin(),(a).end()
#define EPS (1e-5)
const ll Mod = 1000000007;
const ll mod = 998244353;
struct H {
	ll x, y;
	bool operator<(const H &b) const {
		if (x != b.x) return x < b.x;
		return y < b.y;
	}
	bool operator>(const H &b) const {
		if (x != b.x) return x > b.x;
		return y > b.y;
	}
	bool operator==(const H &b) const { return x == b.x&&y == b.y; }
	bool operator!=(const H &b) const { return (*this) != b; }
};
struct P {
	ll pos, cost;
	bool operator<(const P &b) const { return cost < b.cost; }
	bool operator>(const P &b) const { return cost > b.cost; }
};
struct B {
	ll to, cost;
};
struct E {
ll from, to, cost;
bool operator<(const E &b) const { return cost < b.cost; }
bool operator>(const E &b) const { return cost > b.cost; }
};
template<typename T, typename U>
void chmin(T &a, U b) {
	if (a > b) a = b;
}
template<typename T, typename U>
void chmax(T &a, U b) {
	if (a < b) a = b;
}
template<typename T>
T max_0(T a) {
	if (a < 0) return 0;
	return a;
}
template<typename T>
T min_0(T a) {
	if (a > 0) return 0;
	return a;
}
ll read() {
	ll u;
	ll k = scanf("%lld", &u);
	return u;
}
ll gcd(ll i, ll j) {
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcd(j%i, i);
}
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % p;
		x = x * x % p;
		n >>= 1;
	}
	return res;
}//x^n%p
vector<string>split(string s, char c = ' ') {
	vector<string>vec;
	string h = "";
	for (int i = 0; i < s.size();) {
		int j = i;
		while (j < s.size() && s[j] != ' ') {
			h += s[j++];
		}
		if (h.size() > 0) vec.push_back(h);
		h = "";
		i = j + 1;
	}
	return vec;
}
template<typename T>
void print_vec(vector<T>a) {
	for (int i = 0; i < a.size(); i++) {
		cout << (i == 0 ? "" : " ") << a[i];
	}
	cout << endl;
}
const ll Inf = 3023372036854775807;
const int inf = 1500000000;
#define int long long
//----------------------------------------------------
int a, b, c;
signed main() {
	cin >> a >> b >> c;
	if (a == b && b == c) cout << "Yes\n";
	else cout << "No\n";
}

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

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; }

using ll = long long;

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

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

int main() {
  int N;
  cin>>N;
  vector<ll> S(N);
  vector<ll> v(N);
  for(int i = 0; i < N;i++)cin>>v[i];
  sort(v.begin(),v.end());
  for(int i = 0; i < N; i++){
    if(i==0)S[i]=v[i];
    else S[i]=S[i-1]+v[i];
  }
  int ans=1;
  for(int i = N-1;i>=1;i--){
    if(S[i]<=3*S[i-1]) ans++;
    else break;
  }
  cout<<ans<<endl;
}

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

int main() {
  int N;
  int M = 1;
  cin >> N;
  
  int count = 0;
  
  while(true){
    if( N >= M ){
      M *= 2;
    }
    else{
      break;
      }
  }
    cout << M / 2 << endl;
    }

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1e18

int main() {
    double A, B, H, M;
    cin >> A >> B >> H >> M;
    double t0, t1;
    t0 = M_PI * H / 6.0 + M_PI / 6 * M / 60;
    t1 = M_PI * M / 30.0;
    cout << setprecision(12) << hypot(A * cos(t0) - B * cos(t1), A * sin(t0) - B * sin(t1)) << endl;
    return 0;
}

Measured memory_bytes: 4100
#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 = n-1; i >= 0; i--)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
using P = pair<int,int>;
using VI = vector<int>;
using VVI = vector<vector<int>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VP = vector<P>;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

int main(){
    int n, m, q;
    cin >> n >> m >> q;
    VP train(m);
    rep(i,m){
        int L, R;
        cin >> L >> R;
        L--; R--;
        train[i].first = L;
        train[i].second = R;
    }
    sort(all(train));

    VVI town(n);
    rep(i,m){
        int L, R;
        L = train[i].first;
        R = train[i].second;
        town[L].push_back(R);
    }

    rep(i,q){
        int l, r;
        cin >> l >> r;
        l--; r--;
        int ans = 0;
        for(int t = l; t <= r; t++){
            auto itr = upper_bound(all(town[t]), r);
            if (itr == town[t].begin()) continue;
            ans += itr - town[t].begin();
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 5876
#include <iostream>
using namespace std; 
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define ll long long
int main(int argc, char** argv) {
	int n;
	cin>>n;
	ll sum=0;
	rep(i,1,n)
	{
		if(i%3!=0&&i%5!=0)
		{
			sum+=1ll*i;
		}
	}
	cout<<sum;
	return 0;
}

Measured memory_bytes: 3632
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    divisors.sort()
    return divisors
n=int(input())
x=make_divisors(n)
l=len(x)
ans=0
for i in range(l):
    k=n
    if x[i]==1:
        continue
    while k%x[i]==0:
        k//=x[i]
    if k%x[i]==1 or k-k%x[i]==1:
        #print(x[i])
        ans+=1
#print(ans)
y=make_divisors(n-1)
#print(y)
l2=len(y)
ans2=0
for i in range(l2):
    k=n
    if y[i]==1:
        continue
    while k%y[i]==0:
        k//=y[i]
    if k%y[i]==1 or k-k%y[i]==1:
        #print(y[i])
        ans2+=1
print(ans+ans2)




Measured memory_bytes: 3316
#include<stdio.h>

int main(void){
    
    int x[3000], y[3000], z;
    int i = 0;
    while(1){
        scanf("%d %d", &x[i], &y[i]);
        if(x[i] == 0 && y[i] == 0)  break;
        i++;
    }
    for(z = 0; z < i; z++){
        if(x[z] >= y[z])
            printf("%d %d\n", y[z], x[z]);
        else
            printf("%d %d\n", x[z], y[z]);
    }
    
    return 0;
}



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

int n, ans;

int main() {
  cin >> n;
  vector<int> a(n);
  rep (i, n) {
  cin >> a.at(i);
  }
  sort(a.rbegin(), a.rend());
  ans = 0;
  rep (i, n) {
    if (i % 2 == 0) {
      ans += a.at(i);
    }else{
      ans -= a.at(i);
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
const ll nmax = 1e9 + 7;
const ll MOD = 998244353;
const double PI = 2 * asin(1);

int main(){
  int K, X; cin >> K >> X;

  if (500 * K >= X) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
import sys
from sys import exit
from collections import deque
from bisect import bisect_left, bisect_right, insort_left, insort_right #func(リスト,値)
from heapq import heapify, heappop, heappush
from math import *

sys.setrecursionlimit(10**6)
INF = 10**20
eps = 1.0e-20
MOD = 10**9+7

def lcm(x,y):
    return x*y//gcd(x,y)
def mint():
    return map(int,input().split())
def lint():
    return list(map(int,input().split()))
def ilint():
    return int(input()), list(map(int,input().split()))
def judge(x, l=['Yes', 'No']):
    print(l[0] if x else l[1])
def lprint(l, sep='\n'):
    for x in l:
        print(x, end=sep)
def ston(c, c0='a'):
    return ord(c)-ord(c0)
def ntos(x, c0='a'):
    return chr(x+ord(c0))
class counter(dict):
    def __init__(self, *args):
        super().__init__(args)
    def add(self,x):
        self.setdefault(x,0)
        self[x] += 1

N = int(input())
L = [0]*26
for _ in range(N):
    S = input()
    L[ston(S[0],'A')] += 1
s = ['M','A','R','C','H']
ans = 0
for l in [[0,1,2],[0,1,3],[0,1,4],[0,2,3],[0,2,4],[0,3,4],[1,2,3],[1,2,4],[1,3,4],[2,3,4]]:
    x,y,z = map(lambda x:ston(s[x],'A'), l)
    ans += L[x]*L[y]*L[z]
print(ans)

Measured memory_bytes: 74828
import java.util.Scanner;
import java.util.TreeMap;

public class Main {

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

		int N = sc.nextInt();
		int M = sc.nextInt();
		long[] a = new long[N];
		long[] b = new long[N];

		TreeMap<Long, Long> tmap = new TreeMap<Long, Long>();
		for (int i = 0; i < N; i++) {
			a[i] = sc.nextLong();
			b[i] = sc.nextLong();

			if (tmap.containsKey(a[i])) {
				tmap.put(a[i], tmap.get(a[i]) + b[i]);
			} else {
				tmap.put(a[i], b[i]);
			}
		}

		long sum = 0;
		for (Long cost : tmap.keySet())
        {
			long num = Math.min(M, tmap.get(cost));
			sum += cost * num;
			M -= num;
        }

		System.out.println(sum);
	}

}

Measured memory_bytes: 98292
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	private static final int N = 2019;

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			char[] s = scanner.next().toCharArray();
			long answer = 0L;
			int[] remains = new int[N];
			Arrays.fill(remains, 0);
			int now = 0, power = 1;
			remains[now]++;
			for (int i = s.length - 1; i >= 0; i--) {
				now += (s[i] - '0') * power;
				now %= N;
				power = power * 10 % N;
				answer += remains[now];
				remains[now]++;
			}
			System.out.println(answer);
		}
	}
}


Measured memory_bytes: 40832
#include <iostream>
#include <vector>
#include <algorithm>
#include <ctype.h>
using namespace std;

//isupperは大文字の時に真。<ctype.h>を加える
int main(){
  string s;
  cin>>s;
  int count=0;
  int count2=0;
  if(s.at(0)=='A'){
    for(int i=2;i<s.size()-1;i++){
      if(s.at(i)=='C'){
        count++;
      }
    }
    if(count==1){
      for(int i=0;i<s.size();i++){
        if(isupper(s.at(i))){
          count2++;
        }
      }
    }
  }
  if(count2==2){
    cout<<"AC"<<endl;
  }
  else{
    cout<<"WA"<<endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
using Int = long long;

int main() {
    Int N, W;
    cin >> N >> W;
    vector<Int> w, v;
    Int vSum = 0;
    for (Int i = 0; i < N; i++) {
        Int x, y;
        cin >> x >> y;
        w.push_back(x);
        v.push_back(y);
        vSum += y;
    }
    Int INF = 2000000000LL;
    vector<vector<pair<Int, Int>>> f(N, vector<pair<Int, Int>>(vSum + 1));
    for (Int x = 0; x <= vSum; x++) {
        if (x > v[0]) {
            f[0][x] = make_pair(INF, 0);
        } else if (x> 0){
            f[0][x] = make_pair(w[0], v[0]);
        } else {
            f[0][x] = make_pair(0, 0);
        }
    }
    for (Int k = 1; k <= N - 1; k++) {
        for (Int x = 0; x <= vSum; x++) {
            if (x < v[k]) {
                auto a = f[k - 1][x];
                if (a.first < w[k]) {
                    f[k][x] = a;
                } else {
                    f[k][x] = make_pair(w[k], v[k]);
                }
            } else {
                auto a = f[k - 1][x - v[k]];
                auto b = f[k - 1][x];
                if (a.first + w[k] < b.first) {
                    f[k][x] = make_pair(a.first + w[k], a.second + v[k]);
                } else {
                    f[k][x] = b;
                }
            }
        }
    }
    for (Int x = vSum; x >= 0; x--) {
        auto a = f[N - 1][x];
        if (a.first <= W) {
            cout << a.second << endl;
            return 0;
        }
    }
    cout << 0 << endl;
}


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

int main(){
    int a,b;
    int A,B;
    int a_frac, b_frac;
    int xmin, xmax;
    cin >> a >> b;

    if (a%2 == 1) {
        A = a * 12.5 + 1;
        a_frac = 11;
    }
    else {
        A = a * 12.5;
        a_frac = 12;
    }
    b_frac = 9;

    B = b * 10;

    //cout << "A, B, = " << A << ", " << B << endl;

    xmin = max({A, B});
    xmax = min({A+a_frac, B+b_frac});

    if (xmin <= xmax){
        cout << xmin << endl;
    } else {
        cout << -1 << endl;
    }

    return 0;
}

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

using namespace std;

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

using pii = pair<int, int>;
int N, M;

// bool used[1010][202][202];
int t = 1;
int dps[202][202], dpl[202][202], dp[1010][202];
bool solve() {
    cin >> N >> M;
    // cerr << "case #" << t++ << endl;
    if (N == 0) return false;
    REP(i, N) REP(j, N) {
        if (i != j)
            dps[i][j] = dpl[i][j] = 1e9;
        else
            dps[i][j] = dpl[i][j] = 0;
    }

    REP(i, M) {
        int x, y, t;
        char c;
        cin >> x >> y >> t >> c;
        bool sea = (c == 'S');
        x--, y--;
        if (sea) {
            dps[x][y] = dps[y][x] = min(dps[x][y], t);
        } else {
            dpl[x][y] = dpl[y][x] = min(dpl[x][y], t);
        }
        // G[x].push_back({y, t, sea});
        // G[y].push_back({x, t, sea});
    }
    REP(k, N) REP(i, N) REP(j, N) {
        dps[i][j] = min(dps[i][j], dps[i][k] + dps[k][j]);
        dpl[i][j] = min(dpl[i][j], dpl[i][k] + dpl[k][j]);
    }

    int R;
    cin >> R;
    vector<int> v(R);
    REP(i, R + 1) REP(j, N + 1) dp[i][j] = 1e9;
    REP(i, R) {
        cin >> v[i];
        v[i]--;
    }
    dp[0][v[0]] = 0;

    REP(i, R - 1) {
        REP(j, N) {
            dp[i + 1][j] = min(dp[i + 1][j], dp[i][j] + dpl[v[i]][v[i + 1]]);
            REP(k, N) { dp[i + 1][k] = min(dp[i + 1][k], dp[i][j] + dpl[v[i]][j] + dps[j][k] + dpl[k][v[i + 1]]); }
        }
    }
    int ans = 1e9;
    REP(i, N) { ans = min(ans, dp[R - 1][i]); }
    cout << ans << endl;
    return true;
}

signed main() {
    while (solve())
        ;
}


Measured memory_bytes: 5312
#include <bits/stdc++.h>
using namespace std;
const unsigned int MOD = 1000000007;
#define ll long long
#define PI 3.1416
string day [] = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
vector <string> v;
void dfs (string str, string t = "", int cnt = 0) {
    if (cnt == 2) {
        v.push_back (t);
        return;
    } else {
        for (int i = 0; i <str.size (); i ++) {
            dfs (str, t + str [i], cnt + 1);
        }
    }
}
int main () {
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int a,b;
    while(cin>>a>>b){
        int rs=0;
        for(int i=0;i<2;i++){
            if(a>b){
                rs+=a;
                a--;
            }else{
                rs+=b;
                b--;
            }
        }
        cout<<rs<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
// -*- coding:utf-8-unix -*-

use proconio::input;
use std::cmp::max;

fn main() {
    input! {
        n: usize, m: usize, k: usize,
        mut a: [usize; n],
        mut b: [usize; m],
    }

    let mut total: usize = a.iter().sum();

    let mut ans = n;
    while total > k && !a.is_empty() {
        total -= a.pop().unwrap();
        ans -= 1;
    }

    let mut temp = ans;
    for i in 0..m {
        temp += 1;
        total += b[i];
        while total > k && !a.is_empty() {
            total -= a.pop().unwrap();
            temp -= 1;
        }

        if total <= k {
            ans = max(ans, temp);
        }
    }

    println!("{}", ans);
}


Measured memory_bytes: 9348
#include "bits/stdc++.h"
using namespace std;
#define fios ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
typedef long long ll;
#ifdef LOCAL
mt19937 rng(unsigned(70));
#else
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#endif
#define rand rng


int main() {
	// fios;
	
	int k, a, b;
	cin >> k >> a >> b;
	if(a % k == 0 || b % k == 0) {
		puts("OK");
	} else
	if(floor(b*1.0 / k) - floor(a*1.0 / k) >= 1) {
		puts("OK");
	} else {
		puts("NG");
	}
}

Measured memory_bytes: 3748
n = int(input())
p = [0]*(n+1)
for i in range(1,n+1): p[i-1],p[i] = map(int,input().split())
m = [[0]*(n+1) for _ in range(n+1)]
# 対象とする行列の数l
for l in range(2,n+1):
    # for i in range(n+1): print(m[i])    
    # print("/////////////////////////////////")
    # 対象とする行列の範囲i,j
    # iは1からn-(l-1)まで
    for i in range(1,n-l+2):
        j = i+l-1
        m[i][j] = float("inf")
        # (M_iM_i+1...M_k)(M_k+1...M_j)の乗算回数が最小となるkを探す
        for k in range(i,j):
            m[i][j] = min(m[i][j], m[i][k]+m[k+1][j]+p[i-1]*p[k]*p[j])
print(m[1][n])


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

void solve() {
	int a, b, c, d; cin >> a >> b >> c >> d;
	while (a > 0 && c > 0) {
		c -= b;
		if (c <= 0) {
			cout << "Yes\n";
			break;
		}
		a -= d;
		if (a <= 0) {
			cout << "No\n";
			break;
		}	
	}



	//cout << "Case #" << t + 1 << ": " << count << endl;
}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(nullptr);
	/*int t; cin >> t;
	for (int i = 0; i < t; i++) {
		solve(i);
	}*/

	solve();

    return 0;
}

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

int main(void){
  char x[1001];
  int sum, iretation;

  while(1){
    scanf("%s", x);
    iretation = strlen(x);
    if(x[0] == '0') break;
    else{
      sum = 0;
      for(int i=0; i<iretation; i++){
        sum += (int)(x[i]-'0');
      }
    }
    printf("%d\n", sum);
  }
  return 0;
}



Measured memory_bytes: 2144
#include <iostream>
#include <map>
#include <queue>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
using namespace std;
#pragma warning (disable: 4996)

int N; string S, T;

int main() {
	cin >> N >> S >> T;
	for (int i = 0; i < N; i++) cout << S[i] << T[i]; cout << endl;
	return 0;
}

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

int main(){

	long long a,b;
	cin >> a >> b;

	if(a == 1)
		a = INT_MAX;

	if(b == 1)
		b = INT_MAX;

	if(a > b)
		cout << "Alice\n";
	if(b > a)
		cout << "Bob\n";
	if(a == b)
		cout << "Draw\n";
}

Measured memory_bytes: 256