akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include <array>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); i++)
using ULL = unsigned long long;
using UL = unsigned;
using LL = long long;

struct Problem {
	UL N, L;
	pair<UL, UL> pd[100000];
	LL lans[100001], rans[100001];
	void Solve() {
		cin >> N >> L;
		rep(i, N) cin >> pd[i].first >> pd[i].second;
		sort(pd, pd + N);
		LL lp = 1, rp = L;
		lans[0] = 0; rans[N] = 0;
		for (UL i = 1; i <= N; i++) {
			UL ri = N - i;
			lans[i] = lans[i - 1];
			rans[ri] = rans[ri + 1];
			if (pd[i - 1].second == 0) {
				lans[i] += pd[i - 1].first - lp;
			}
			else {
				lans[i] -= pd[i - 1].first - lp;
			}
			if (pd[ri].second == 0) {
				rans[ri] -= rp - pd[ri].first;
			}
			else {
				rans[ri] += rp - pd[ri].first;
			}
			lp++; rp--;
		}
		LL ans = 0;
		rep(i, N + 1) {
			ans = max(ans, lans[i] + rans[i]);
		}
		cout << ans << endl;
	}

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



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

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

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

typedef long long ll;

int main(){
    int n;
    cin >> n;
    int a[n];
    for(int i = 0; i < n; i++)  cin >> a[i];
    vector<ll> dp(n, 1000);
    for(int i = 1; i < n; i++){
        dp[i] = dp[i-1];
        for(int j = 0; j < i; j++){
            dp[i] = max(dp[i], dp[j]/a[j]*a[i]+dp[j]%a[j]);
        }
    }
    cout << *max_element(dp.begin(), dp.end()) << endl;
    return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <limits>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <complex>

using namespace std;

//define
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define dump(x)  cerr << #x << " = " << (x) << endl;

#define INF (INT_MAX/3)
#define PI (2*acos(0.0))
#define EPS (1e-8)

typedef long long ll;
typedef unsigned long long ull;

int n, m;
bool adjMatrix[501][501];
int used[501];

void init(){
  for(int i = 0; i <= 500; i++){
    used[i] = 0;
    for(int j = 0; j <= 500; j++){
      adjMatrix[i][j] = false;
    }
  }
}

void solve(int id, int c){
  if(c > 2) return;
  used[id] = 1;
  for(int i = 1; i <= n; i++){
    if(adjMatrix[id][i]){
      solve(i, c + 1);
    }
  }
}

int main(){
  ios_base::sync_with_stdio(0);
  while(cin >> n >> m, n || m){
    init();
    for(int i = 0; i < m; i++){
      int a, b; cin >> a >> b;
      adjMatrix[a][b] = adjMatrix[b][a] = true;
    }
    solve(1, 0);
    int ans = 0;
    for(int i = 1; i <= n; i++) if(used[i] == 1) ans++;
    ans--;
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 1444
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        long x = in.nextLong();
        long y = in.nextLong();
        if (x % y == 0){
            System.out.println(-1);
            return;
        }
        System.out.println(x);
    }
}

Measured memory_bytes: 21844
H, W = map(int,input().split())
HW = [input() for _ in range(H)]

ans = "Yes"
for i in range(H-1):
  for j in range(W-1):
    if(HW[i][j] == '.'):
      continue
    if(HW[i-1][j] == '#' and i != 0):
      continue
    if(HW[i][j-1] == '#' and j != 0):
      continue
    if(HW[i+1][j] == '#' and j != H):
      continue
    if(HW[i][j+1] == '#' and j != W):
      continue
    ans = "No"
print(ans)

Measured memory_bytes: 3064
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

from fractions import gcd

n, m = map(int, readline().split())
a = list(map(int, readline().split()))
for i in range(n):
    a[i] //= 2
lcm_memo = 1
for i in range(n):
    lcm_memo *= a[i] // gcd(lcm_memo, a[i])
    if lcm_memo > m:
        print(0)
        exit()
for i in range(n):
    if (lcm_memo // a[i]) % 2 == 0:
        print(0)
        exit()
print(1 + (m - lcm_memo) // (lcm_memo * 2))


Measured memory_bytes: 14576
#include<iostream>
#include<cstdio>
#include<string>
#include <iostream>

using namespace std;

int main() {
  int n;
  cin >> n;
  int k=0;
  int N = n;
  for(int i=0;i<=9;i++){
    k = k + n%10;
    n=n/10;
  }
  int c = N%k;
  if(c==0)cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout<<endl;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll R,G,B,N;
    cin >> R >> G >> B >> N;
    ll ans = 0;
    rep(i,0,3001){
        rep(j,0,3001){
            ll v = N - i*R - j*G;
            if(v >= 0 && v % B == 0) ans++;
        }
    }
    print(ans);
    
}

Measured memory_bytes: 256
#coding:utf-8
#A,Bの上からi桁目のビットの組み合わせの数を求める
L = input()
lenL = len(L)
dp1 = [0] * lenL  #i桁目まででL未満になることが確定済みの組み合わせの数
dp2 = [0] * lenL  #i桁目まででA+BがLと一致している組み合わせの数、dp1[i+1]を求めるためにも利用
dp1[0] = 1 #0... となる数,最初の1桁目は(0,0)
dp2[0] = 2 #1... 

mod = 10**9 + 7
for i in range(1,len(L)):
    
    dp1[i] = (dp1[i] + 3 * dp1[i-1]) % mod  #L未満であることは確定しているので(0,0),(1,0),(0,1)の3通り
    if L[i] == '1':
        dp2[i] = (dp2[i] + 2 * dp2[i-1]) % mod  #A+BをLと一致させるために(1,0),(0,1)の2通りをとる
        dp1[i] = (dp1[i] + dp2[i-1]) % mod  #Lのi桁目が1で(0,0)を選択した場合これ以降の桁(この桁を含む)でどんな組み合わせを選んでもL以下になることが確定
    else:
        dp2[i] = (dp2[i] + dp2[i-1]) % mod  #A+BをLと一致させるために(0,0)の1通り

print((dp1[-1] + dp2[-1]) % mod)

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

typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()

int N, K;
int ret = 1e9;
int x[100010];

int main() {
	cin >> N >> K;
	rep(i, N) cin >> x[i];

	for (int i = 0; i <= N-K; ++i) {
		int l = x[i], r = x[i + K - 1];
		if (r <= 0) {
			ret = min(ret, abs(l));
		} else if (l >= 0) {
			ret = min(ret, r);
		} else {
			ret = min(ret, min(r+abs(l)*2, abs(l)+r*2));
		}
	}
	cout << ret << endl;

	return 0;
}

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

int main(){
  int N;
  cin >> N;
  vector<int> a(N);
  int sum=0;
  for(int i=0;i<N;i++){
    cin >> a.at(i);
    sum+=a.at(i);
  }
  double average=(double)sum/N;
  int ans;
  double diff=1e9;
  for(int i=0;i<N;i++){
    if(diff>abs(a.at(i)-average)){
      diff = abs(a.at(i)-average);
      ans=i;
    }
  }
  cout << ans << endl;
  return 0;
}


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

int main() {
    bool beautiful = true;
    string w;
    cin >> w;
    int find[80] = {0};
    for(int i = 0; i < w.size(); i++) {
        find[int(w[i]) - 'a'] += 1;
    }
    for(int i = 0; i < 80; i++) {
        if(find[i] % 2 == 1) {
            beautiful = false;
        }
    }
    if(beautiful) { 
        cout << "Yes" << endl; 
    } else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <string>
#include <vector>
#include <iostream>
using namespace std;
int main(){
	int n, m;
	scanf("%d %d",&n,&m);
	vector<string> v;
	string s;
	for (int i = 0; i < n; i++){
		cin >> s;
		bool b = true;
		for (int j = 0; j < m; j++){
			if (s[j] == '#'){
				b = false;
				break;
			}
		}
		if (!b){
			v.push_back(s);
		}
	}
	for (int i = 0; i < m; i++){
		bool b = true;
		for (int j = 0; j < v.size(); j++){
			if (v[j][i] == '#'){
				b = false;
				break;
			}
		}
		if (b){
			for (int j = 0; j < v.size(); j++){
				v[j].erase(v[j].begin() + i);
			}
			i--;
			m--;
		}
	}
	for (int i = 0; i < v.size(); i++){
		for (int j = 0; j < v[i].size(); j++){
			cout << v[i][j];
		}
		printf("\n");
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rep2(i,s,n) for (int i = s; i < n; ++i)
#define all(a) a.begin(),a.end()
#define tmax(a,b,c) max(a,max(b,c))
#define tmin(a,b,c) min(a,min(b,c))
#define pb push_back
using namespace std;
using ll = long long;
using P = pair<int,int>;
template<class T> inline bool chmin(T& a,T b) {if(a > b){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;}
const int inf = 1001001001;

const int mod = 1000000007;
struct mint {
  ll x;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  bool operator==(const int n) const { return this->x == n;}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  void operator++() {
      x += 1;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  void operator--() {
      x -= 1;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

int main() {
    string s;
    cin >> s;
    int n = s.size();
    reverse(all(s));
    vector<vector<mint>> dp(n,vector<mint>(13));
    if(s[0] != '?') dp[0][s[0]-'0'] = 1;
    else rep(i,10) dp[0][i] = 1;
    int now = 1;
    rep(i,n-1) {
        now = now*10%13;
        bool que = (s[i+1] == '?');
        int ne;
        if(!que) ne= s[i+1]-'0';
        rep(j,13) {
            if(dp[i][j] == 0) continue;
            if(que) {
                rep(k,10) {
                    int l = (j+(now*k%13))%13;
                    dp[i+1][l] += dp[i][j];
                }
            } else {
                int l = (j+(now*ne%13))%13;
                dp[i+1][l] += dp[i][j];
            }
        }
    }
    cout << dp[n-1][5].x << endl;
}

Measured memory_bytes: 13696
n = int(input())
nums = list(map(int, input().split()))

def insertion_sort(lis, num):
    print(' '.join(map(str, lis)))
    for i in range(1, num):
        v = lis[i]
        j = i - 1  # j は iの前の数
        while j >= 0 and lis[j] > v:  # jが0以上で配列のj番目の要素が現在の要素より大きい場合
            lis[j + 1] = lis[j]  # 配列j+1番目の要素に配列j番目の要素を格納
            # print(' '.join(lis))
            j -= 1  # jを-1
            lis[j + 1] = v  # 配列j+1番目の要素にvを格納
        print(' '.join(map(str, lis)))
    return lis

insertion_sort(nums, n)



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

int main(void){
  int n,k;
  cin >> n >> k;
  int ans = 1;
  for(int i = 1;i <= n;i++){
    if(ans <= k){
      ans *= 2;
    }
    else{
      ans += k;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int exit=0;
		while(exit==0){
			int n = sc.nextInt();
			int p = sc.nextInt();
			if(n==0 && p==0){
				exit=1;
			}
			if(exit==0){
				int[] man = new int[n];
				int flag=0;
				int i=0;
				int cup=p;
				
				while(flag==0){
					if(cup!=0){
						man[i]++;
						cup--;
					}else if(cup==0){
						cup = man[i];
						man[i] = 0;
					}
					if(man[i]==p){
						flag=1;
						System.out.println(i);
					}
					i++;
					if(i==n)i=0;
				}
				
			}
		}
	}
}

Measured memory_bytes: 20256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] A;
        A = new int[n];
        int count = 0;
        for(int i=0;i<n;++i){
            A[i] = sc.nextInt();
        }
        for(int i=0;i<n-1;++i){
            for(int j=0;j<n-1;++j){
                if(A[j] > A[j+1]){
                    int c;
                    c = A[j];
                    A[j] = A[j+1];
                    A[j+1] = c;
                    count++;
                }
            }
        }
        print(A, n);
        System.out.println(count);
    }

    public static void print(int A[], int n){
        for(int i=0;i<n;++i){
            System.out.print(A[i]);
            if(i<n-1){System.out.print(" ");}
        }
        System.out.println();
    }
}




Measured memory_bytes: 26356
N, K = map(int, input().split())
ABn = [tuple(map(int, input().split())) for i in range(N)]

ABn = sorted(ABn, key=lambda x: x[0])
crr = K
ans = 0
for i in range(N):
    crr -= ABn[i][1]
    if crr <= 0:
        ans = ABn[i][0]
        break

print(ans)

Measured memory_bytes: 18960
#include <iostream>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <numeric>
#include <queue>
#include <deque>
#include <cmath>
#include <iomanip>
#include <cstdio>
#include <limits>
#include <climits>

using namespace std;

int main(){
    int n, k; cin >> n >> k;
    vector<pair<long long, long long>> xys(n);
    for(int i=0; i<n; ++i){
        cin >> xys[i].first >>xys[i].second;
    }
    long long ans=numeric_limits<long long>::max();
    vector<int> index(4);
    for(index[0]=0; index[0]<n; ++index[0]){
        for(index[1]=0; index[1]<n; ++index[1]){
            for(index[2]=0; index[2]<n; ++index[2]){
                for(index[3]=0; index[3]<n; ++index[3]){
                    long long x1=xys[index[0]].first, x2=xys[index[0]].first;
                    long long y1=xys[index[0]].second, y2=xys[index[0]].second;
                    for(int i=1; i<4; ++i){
                        x1=min(x1, xys[index[i]].first);
                        x2=max(x2, xys[index[i]].first);
                        y1=min(y1, xys[index[i]].second);
                        y2=max(y2, xys[index[i]].second);
                    }
                    int cnt=0;
                    for(int ki=0; ki<n; ++ki){
                        long long x3=xys[ki].first, y3=xys[ki].second;
                        if(x1<=x3 && x3<=x2 && y1<=y3 && y3<=y2) ++cnt;
                    }
                    if(cnt==k) ans=min(ans, (x2-x1)*(y2-y1));
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;

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

    int ans=0;
    for(int i=a;i<=b;i++){
        string num = to_string(i);
        string rev = num;
        reverse(rev.begin(),rev.end());
        if(rev==num) ans++;
    }
    cout << ans << endl;
}

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

int main() {
  int N, K;
  cin >> N >> K;
  vector<ll> S(N + 1, 0);
  for (int i = 0; i < N; i++) {
    ll a;
    cin >> a;
    S[i+1] = S[i] + a;
  }
  
  vector<ll> A;
  for (int i = 0; i < N + 1; i++) {
    for (int j = i + 1; j < N + 1; j++) {
      A.push_back(S[j] - S[i]);
    }
  }
  
  ll ret = 0;
  for (int digit = 60; digit >= 0; digit--) {
    int cnt = 0;
    vector<ll> B;
    for (int i = 0; i < A.size(); i++) {
      if ((1LL << digit) & A[i]) {
        cnt++;
        B.push_back(A[i]);
      }
    }
    
    if (cnt >= K) {
      ret |= (1LL << digit);
      A = B;
    }
  }
  
  cout << ret << endl;
}

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

#define fs first
#define se second
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; ++i)

using pii = pair<int, int>;
using vi = vector<int>;
using lint = long long;

const int inf = 1001001001;
const lint linf = 1001001001001001001ll;
const int mod = 1e9 + 7;
const int dx[]{0, 1, 0, -1, -1, -1, 1, 1}, dy[]{1, 0, -1, 0, -1, 1, -1, 1};

template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; } return a > b; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; } return a < b; }
template<typename T> inline void print(const T &x, string s = "\n") { cout << x << s; }
template<typename T> inline void print(const vector<T> &v, string s = " ") 
{ rep(i, v.size()) cout << v[i] << (i + 1 == v.size() ? "\n" : s); }
inline bool inside(int y, int x, int H, int W) { return 0 <= y && y < H && 0 <= x && x < W; }
inline lint in() { lint x; std::cin>>x; return x; }

int main() {
	int a = in(), b = in(), c = in();
	if (a <= c && c <= b) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
}



Measured memory_bytes: 256
# 値を渡すと約数の個数が返される
# num >= 2 であることは保障されている
def make_divisor_num(num):
    d_list = [1]
    for i in range(2, num // 2 + 1):
        if num % i == 0:
            d_list.append(i)
    d_list.append(num)
    return len(d_list)


N = int(input())
if N < 105:
    print(0)
    exit()


counter = 0
for num in range(105, N+1, 2):
    if make_divisor_num(num) == 8:
        counter += 1

print(counter)


Measured memory_bytes: 3060
/*********************
*  Author: xuziyuan  * 
*********************/
 
#include <bits/stdc++.h>

#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define LL long long
#define pii pair <LL,LL>
#define fi first
#define se second
#define pb push_back
#define mpr make_pair
 
using namespace std;
 
const LL MOD=1e9+7;

LL n,m,x,y,cover[60],dp[1100000];
vector <pii> g[60];
vector <LL> pass;

bool dfs(LL pos,LL no,LL to)
{
	if(pos==to) return true;
	rep(i,g[pos].size())
	{
		if(g[pos][i].fi==no) continue;
		pass.pb(g[pos][i].se);
		if(dfs(g[pos][i].fi,pos,to)) return true;
		pass.pop_back();
	}
	return false;
}

int main()
{
	cin>>n;
	rep(i,n-1)
	{
		cin>>x>>y;
		g[x].pb(mpr(y,i));
		g[y].pb(mpr(x,i));
	}
	cin>>m;
	rep(i,m)
	{
		cin>>x>>y;
		dfs(x,0,y);
		rep(j,pass.size()) cover[pass[j]]|=(1<<i);
		pass.clear();
	}
	dp[0]=1;
	rep(i,n-1)
	{
		for(int j=(1<<m)-1;j>=0;j--)
		{
			if(dp[j]==0) continue;
			dp[j|cover[i]]+=dp[j];
		}
	}
	cout<<dp[(1<<m)-1]<<endl;
	return 0;
}

Measured memory_bytes: 8448
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define vll vector<ll>
#define pll pair<ll,ll>
#define forA(i,a,n,x) for(auto i=a;i<n;i+=x)
#define forD(i,a,n,x) for(auto i=n-1;i>=0;i-=x)
#define ranit(it,n) for(auto it:n)
#define testCases ll t;cin>>t;while(t--)
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define mod 1000000007

vll adj[100003]; ll n;
ll dp[100003][3];

ll solve(ll i , ll j)
{
	if(i==n)return 0;
	
	if(dp[i][j]!=-1)return dp[i][j];
	
	if(j==0) return dp[i][j] = adj[i][j]+ max(solve(i+1,1),solve(i+1,2));
	else if(j==1) return dp[i][j]= adj[i][j]+ max(solve(i+1,0),solve(i+1,2));
	else return dp[i][j]=adj[i][j]+ max(solve(i+1,1),solve(i+1,0));
}

int main()
{
	ios_base::sync_with_stdio(false);	cin.tie(NULL);	cout.tie(NULL);
	ll a,b,c; cin>>n;
	memset(dp,-1,sizeof(dp));
	forA(i,0,n,1){cin>>a>>b>>c; adj[i].pb(a); adj[i].pb(b) ; adj[i].pb(c); }
	ll ans=0;
	forA(i,0,3,1)ans=max(solve(0,i),ans);
	cout<<ans;
	return 0;
}

Measured memory_bytes: 17764
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
using namespace std;
typedef long long ll;
const int INF = 1<<30;
const int MOD = 1e9 + 7;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int L, a, b, c, d;
    cin >> L >> a >> b >> c >> d;
    int ans = L;
    while(a > 0 || b > 0)
    {
        a -= c;
        b -= d;
        ans--;
    }
    cout << ans << endl;
    return 0;
}




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

int main() {
  string b;
  cin>>b;
  if (b=="A") {
    cout<<"T"<<endl;
  }
  else if (b=="T") {
    cout<<"A"<<endl;
  }
  else if (b=="G") {
    cout<<"C"<<endl;
  }
  else {
    cout<<"G"<<endl;
  }
  
}


Measured memory_bytes: 256
// 以下のソースを勉強する.
// zscoder氏.
// https://atcoder.jp/contests/dp/submissions/3938480
#include <bits/stdc++.h>
using namespace std;

const int MOD = (1e9 + 7);
int add(int a, int b){
    a += b;
    while(a >= MOD) a -= MOD;
    return a;
}

int mult(int a, int b){
    return (a * 1LL * b) % MOD;
}

int dp[111111][2];
vector<int> adj[123456];

void dfs(int u, int p = -1){
    int prod  = 1;
    int prod2 = 1;
    for(int v : adj[u]){
        if(v == p) continue;
        dfs(v, u);
        prod  = mult(prod, add(dp[v][0], dp[v][1]));
        prod2 = mult(prod2, dp[v][0]);
    }
    dp[u][0] = prod;
    dp[u][1] = prod2;
}

int main(){
    
    // 1. 入力情報取得.
    int N;
    scanf("%d", &N);
    for(int i = 0; i < N - 1; i++){
        int u, v;
        scanf("%d %d", &u, &v);
        u--;
        v--;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
    
    // 2. dp更新.
    dfs(0);
    int ans = 0;
    ans = add(ans, dp[0][0]);
    ans = add(ans, dp[0][1]);
    
    // 3. 出力.
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 13952
n = int(input())
a = list(int(input()) for i in range(n))

a.sort()
count = 0

for i, j in enumerate(a):
    try:
        if j == a[i + 1]:
            a[i] = 0
            count += 1
        else:
            pass
    except IndexError:
        pass

print(n - count)


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


    using namespace std;

    int main()
    {
        // .25   .50    1    2
        double a,b,c,d;
        cin>>a>>b>>c>>d;
        double n;
        cin>>n;
        d/=6;
        c/=4;
        b/=2;
        long long yen=0;
        while(d<=a&&d<=b&&d<=c&&n>=2){
            long long k=n/2;
            long long h=ceil(d*6);
            yen+=(h*k);
            n-=(2*k);
        }
        while(c<=a&&c<=b&&n>=1){
            long long k=n;
            long long h=ceil(c*4);
            yen+=(h*k);
            n-=(1*k);
        }
        while(b<=a&&n>=.50){
            long long k=n/.50;
            long long h=ceil(b*2);
            yen+=(h*k);
            n-=(.50*k);
        }
        while(n>=.25){
            long long k=ceil(n/.25);
            yen+=(a*k);
            n-=(.25*k);
        }
        cout<<yen<<endl;
        return 0;
    }


Measured memory_bytes: 256
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

const int MOD = 1000000007, INF = 1111111111;
using namespace std;
using lint = long long;

template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (int i = 0; i < (int)vec.size(); i++) {
		os << vec[i] << (i + 1 == vec.size() ? "" : " ");
	}
	return os;
}

#ifdef _DEBUG
template <class Head>
void dump(const char* str, Head &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + 1, t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int N, M;
	cin >> N >> M;

	vector<pair<int, int>> job(N);
	for (int i = 0; i < N; i++) cin >> job[i].first >> job[i].second;
	sort(job.begin(), job.end());

	int cnt = 0;
	lint ans = 0;
	priority_queue<int> pq;
	for (int i = 1; i <= M; i++) {

		while (cnt < N && job[cnt].first <= i) {
			pq.emplace(job[cnt].second);
			cnt++;
		}

		if (!pq.empty()) {
			ans += pq.top();
			pq.pop();
		}

	}

	cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 1660
#include <stdio.h>

int main(void) {

  int n,k,d;
  scanf("%d %d", &n, &k);
  int number_list[10];
  for (int i = 0; i < 10; i++) {
    number_list[i] = 0;
  }
  for (int i = 0; i < k; i++) {
    scanf("%d", &d);
    number_list[d]++;
  }
  int smallest;
  for (int i = 0; i < 10; i++) {
    if (number_list[i] == 0) {
      smallest = i;
      break;
    }
  }
  int price = n;
  int digits = 0;
  while (price > 0) {
    price /= 10;
    digits++;
  }
  price = n;
  int pay[digits+1];
  pay[digits] = 0;
  for (int i = 0; i < digits; i++) {
    pay[i] = price%10;
    price /= 10;
  }
  for (int i = digits-1; i >= 0; i--) {
    if (number_list[pay[i]] == 1) {
      for (int j = 0; j < i; j++) {
        pay[j] = smallest;
      }
      while (number_list[pay[i]] == 1) {
        if (pay[i] == 9) {
          pay[i] = 0;
          pay[i+1]++;
        } else {
          pay[i]++;
        }
      }
      for (int j = i+1; j < digits; j++) {
        while (number_list[pay[j]] == 1) {
          if (pay[j] == 9) {
            pay[j] = 0;
            pay[j+1]++;
          } else {
            pay[j]++;
          }
        }
      }
      break;
    }
  }
  if (pay[digits] != 0) {
    while (number_list[pay[digits]] == 1) {
      pay[digits]++;
    }
  }

  int answer = 0;
  for (int i = digits; i >= 0; i--) {
    answer *= 10;
    answer += pay[i];
  }
  printf("%d\n", answer);

  return 0;
}

Measured memory_bytes: 128
using System;
using System.Linq;

namespace Volume0_0012
{
    class Program
    {
        static void Main(string[] args)
        {
            string input;
            while( ( input = Console.ReadLine() ) != null)
            {
                var nums = input.Split(' ').Select( s => Convert.ToSingle(s)).ToArray();
                Console.WriteLine
                (
                    new Triagle
                    (
                        new Vector2(nums[0], nums[1]),
                        new Vector2(nums[2], nums[3]),
                        new Vector2(nums[4], nums[5])
                    )
                    .HitTest(new Vector2(nums[6], nums[7])) ?
                        "YES" :
                        "NO"
                );
            }
        }
    }

    public class Triagle
    {
        public Vector2 Point1 { get; set; }
        public Vector2 Point2 { get; set; }
        public Vector2 Point3 { get; set; }

        public Triagle(Vector2 p1, Vector2 p2, Vector2 p3)
        {
            Point1 = p1;
            Point2 = p2;
            Point3 = p3;
        }

        public bool HitTest(Vector2 p)
        {
            Vector2 AB = Vector2.Sub(Point2, Point1);
            Vector2 BP = Vector2.Sub(p, Point2);

            Vector2 BC = Vector2.Sub(Point3, Point2);
            Vector2 CP = Vector2.Sub(p, Point3);

            Vector2 CA = Vector2.Sub(Point1, Point3);
            Vector2 AP = Vector2.Sub(p, Point1);

            float c1 = Vector2.Cross(AB, BP);
            float c2 = Vector2.Cross(BC, CP);
            float c3 = Vector2.Cross(CA, AP);

            return (c1 > 0 && c2 > 0 && c3 > 0) || (c1 < 0 && c2 < 0 && c3 < 0) ? true : false;
        }
    }


    public class Vector2
    {
        public float X { get; set; }
        public float Y { get; set; }

        public Vector2(float x, float y)
        {
            X = x;
            Y = y;
        }

        public static float Cross(Vector2 vec1, Vector2 vec2)
        {
            return vec1.X * vec2.Y - vec1.Y * vec2.X;
        }

        public static Vector2 Sub(Vector2 vec1, Vector2 vec2)
        {
            return new Vector2(vec1.X - vec2.X, vec1.Y - vec2.Y);
        }

    }

}

Measured memory_bytes: 9744
#include <bits/stdc++.h>
#define vsort(v) sort(v.begin(), v.end())
#define rvsort(v) sort(v.begin(), v.end(), greater<ll>())
#define prvsort(v) sort(v.begin(), v.end(), greater<pair<ll, ll>>())
#define ll long long
#define ld long double
#define fixset(val) fixed << setprecision(10) << val 
#define rep(i, s, g) for (ll i = (s); i < (g); i++)
#define mod 1000000007
#define vfind(v, target) find(v.begin(), v.end(), target)
#define notFound(v, target) (vfind(v, target) == v.end())

using namespace std;

int main()
{
  ll N, ans = 0; cin >> N;
  vector<ll> A(N);
  rep(i, 0, N) cin >> A[i];
  vsort(A);
  vector<bool> B(A[N - 1] + 1, true);
  rep(i, 0, N) {
  	if (B[A[i]]) {
    	for (ll j = A[i] * 2; j <= A[N - 1]; j += A[i]) {
        	B[j] = false;
        }
    }
    if (i < N - 1 && A[i] == A[i + 1]) B[A[i]] = false;
  }
  rep(i, 0, N) {
  	if (B[A[i]]) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 4836
sx, sy, tx, ty = map(int, input().split())
dx = tx-sx
dy = ty-sy
ans = 'U'*dy + 'R'*dx + 'D'*dy + 'L'*dx
ans += 'L' + 'U'*(dy+1) + 'R'*(dx+1) + 'D'
ans += 'R' + 'D'*(dy+1) + 'L'*(dx+1) + 'U'
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define int long long
constexpr long long INF = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



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

    int H,W;
    cin>>H>>W;
    string S[H];
    rep(i,H){
        cin>>S[i];
    }
    int ans[H][W]{};
    rep(i,H){
        int c=0;
        rep(j,W){
            if(S[i][j]=='.'){
                ans[i][j]+=c;
                c++;
            }else{
                c=0;
            }
        }
    }
    for(int i=H-1;i>=0;i--){
        int c=0;
        for(int j=W-1;j>=0;j--){
            if(S[i][j]=='.'){
                ans[i][j]+=c;
                c++;
            }else{
                c=0;
            }
        }
    }
    rep(i,W){
        int c=0;
        rep(j,H){
            if(S[j][i]=='.'){
                ans[j][i]+=c;
                c++;
            }else{
                c=0;
            }
        }
    }
    for(int i=W-1;i>=0;i--){
        int c=0;
        for(int j=H-1;j>=0;j--){
            if(S[j][i]=='.'){
                ans[j][i]+=c;
                c++;
            }else{
                c=0;
            }
        }
    }
    int sum=0;
    rep(i,H){
        rep(j,W){
            sum=max(sum,ans[i][j]);
        }
    }
    sum++;
    cout << sum << endl;



    



}


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

#define NREP() for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define ALL(x) (x).begin(), (x).end()
#define MSG(x) cout << x << endl;
#define IPT(t, x) t ipt; cin >> ipt; x.push_back(ipt);
#define YN(x) x ? cout << "YES" << endl : cout << "NO" << endl;
#define Yn(x) x ? cout << "Yes" << endl : cout << "No" << endl;
#define yn(x) x ? cout << "yes" << endl : cout << "no" << endl;

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;

const static ll MOD = 1e9 + 7;
ll n, cnt, ans, a, b, c, d, tmp, m, h, w, x, y, sum, k, q;
string s;

int main() {
    cin >> s;
    string t;
    cin >> t;

     ans = 0;
    REP(i, 3) {
        if (s.at(i) == t.at(i)) ans++;
    }

    MSG(ans)
}


Measured memory_bytes: 384
import java.util.*;

public class Main {
	static boolean[] vis;
	static SegTree seg;
	static int n, k;
	static int idx = 0;
	static int[] ans;
	static int[] p;
	static int[] q;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		n = sc.nextInt();
		k = sc.nextInt();
		p = new int[n];
		vis = new boolean[n];
		ans = new int[n];
		for (int i = 0; i < n; ++i) {
			p[i] = sc.nextInt() - 1;
		}
		q = new int[n];
		for (int i = 0; i < n; ++i) {
			q[p[i]] = i;
		}
		seg = new SegTree(n);
		for (int i = 0; i < n; ++i) {
			seg.val[i + seg.n - 1] = q[i];
		}
		for (int i = seg.n - 2; i >= 0; --i) {
			seg.val[i] = Math.min(seg.val[2 * i + 1], seg.val[2 * i + 2]);
		}
		for (int i = 0; i < n; ++i) {
			if (!vis[i]) {
				dfs(i);
			}
		}
		StringBuilder sb = new StringBuilder();
		int[] t = new int[n];
		for (int i = 0; i < n; ++i) {
			t[ans[i]] = i;
		}
		ans = Arrays.copyOf(t, t.length);
		for (int i : ans) {
			sb.append((i + 1) + "\n");
		}
		System.out.println(sb);
	}

	static void dfs(int i) {
		while (true) {
			int min = seg.query(0, p[i]);
			if (min < i + k) {
				dfs(min);
			} else
				break;
		}
		ans[idx++] = i;
		vis[i] = true;
		seg.setVal(p[i], Integer.MAX_VALUE / 10);
	}

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

	static class SegTree {
		int n = 1;
		int[] val;

		public SegTree(int n_) {
			while (n < n_) {
				n *= 2;
			}
			val = new int[2 * n - 1];
		}

		void setVal(int k, int v) {
			k += n - 1;
			val[k] = v;
			while (k > 0) {
				k = (k - 1) / 2;
				val[k] = Math.min(val[2 * k + 1], val[2 * k + 2]);
			}
		}

		int query(int a, int b) {
			return query(a, b, 0, n, 0);
		}

		int query(int a, int b, int l, int r, int k) {
			if (a <= l && r <= b) {
				return val[k];
			} else if (r <= a || b <= l) {
				return Integer.MAX_VALUE / 10;
			} else {
				int vl = query(a, b, l, (l + r) / 2, 2 * k + 1);
				int vr = query(a, b, (l + r) / 2, r, 2 * k + 2);
				return Math.min(vl, vr);
			}
		}
	}

}


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

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vector<vector<bool>>> vvvb;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<vpll> vvpll;
typedef vector<double> vd;
typedef vector<vd> vdd;

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)
#define RFOR(i,x,y) for(ll i=(ll)x; i>=(ll)y; --i)
#define RREP(i,x) RFOR(i, x, 0)
#define ALL(a) a.begin(), a.end()
#define pb push_back
#define debug_print(x...) cerr << "line " << __LINE__ << " : "; debug_print_in(x);

template <typename First>
void debug_print_in(First first){
  cerr << first << endl;
  return;
}

template <typename First, typename... Rest>
void debug_print_in(First first, Rest... rest){
  cerr << first << " ";
  debug_print_in(rest...);
  return;
}

void IN(void){
  return;
}

template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
  cin >> first;
  IN(rest...);
  return;
}

template <typename First>
void OUT(First first){
  cout << first << endl;
  return;
}

template <typename First, typename... Rest>
void OUT(First first, Rest... rest){
  cout << first << " ";
  OUT(rest...);
  return;
}

template<class t, class u> void chmax(t&a,u b){if(a<b)a=b;};
template<class t, class u> void chmin(t&a,u b){if(a>b)a=b;};
int popcount(int t){return __builtin_popcount(t);} //GCC
int popcount(ll t){return __builtin_popcountll(t);} //GCC

template <typename T>
void vec_print(vector<T> VEC){
  REP(i, VEC.size()){
    cerr << VEC[i] << " ";
  }
  cerr << endl;
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  REP(i,MAT.size()){
    REP(j,MAT[i].size()){
      cerr << MAT[i][j] << " ";
    }
    cerr << endl;
  }
};

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;
constexpr ll MOD = (ll)((1E+9)+7);

ll N, K, C;

vll search(string S){
  vb ans(N, false);
  ll pos = 0;
  ll k=0;
  while(S[pos]=='x') pos++;
  ans[pos] = true;
  k++;
  while(k<K){
    pos += C+1;
    while(S[pos]=='x') pos++;
    ans[pos] = true;
    k++;
  }

  vll tmp(K);
  ll l=0;
  REP(i,N){
    if(ans[i]){
      tmp[l] = i;
      l++;
    }
  }
  return tmp;
}

int main(){
  cin.tie(0); // cut the cin and cout (default, std::flush is performed after std::cin)
  ios::sync_with_stdio(false); // cut the iostream and stdio (DON'T endl; BUT "\n";)

  IN(N,K,C);
  string S;
  IN(S);

  vll ans1 = search(S);
  ll pos = N-1;
  while(S[pos]=='x') pos--;
  ll tail = K-1;

  vll ans;

  while(tail>=0){
    if(ans1[tail]==pos) ans.pb(pos);
    ans1[tail] = pos;
    pos-=C+1;
    while(S[pos]=='x') pos--;
    tail--;
  }
  sort(ALL(ans));

  REP(i,ans.size()){
    OUT(ans[i]+1);
  }


  return 0;
}

Measured memory_bytes: 5060
#include <bits/stdc++.h>
#define fst first
#define snd second
#define rep(n) for(lint I = 0; (I) < (lint)(n); ++(I))
#define repeat(i, n) for(lint i = 0; (i) < (lint)(n); ++(i))
#define repeat_to(i, n) for(lint i = 0; (i) <= (lint)(n); ++(i))
#define repeat_from(i, m, n) for(lint i = (m); (i) < (lint)(n); ++(i))
#define repeat_from_to(i, m, n) for(lint i = (m); (i) <= (lint)(n); ++(i))
#define repeat_reverse_from_to(i, m, n) for(lint i = (m); (i) >= (lint)(n); --(i))
#define el cout<<endl
#define dump(x) cout<<" "<<#x<<"="<<x
#define vdump(v) for(size_t I=0; I<v.size(); ++I){cout<<" "<<#v<<"["<<I<<"]="<<v[I];} cout<<endl
using namespace std;
using lint = long long;
using ld = long double;

/****************** グラフ ******************/
// 諸宣言
using Weight = lint;
using Flow = lint;
struct Edge {
    int src, dst;
    Weight weight;
    Flow cap;
    Edge() : src(0), dst(0), weight(0) {}
    Edge(int s, int d, Weight w) : src(s), dst(d), weight(w) {}
    Edge(int s, int d, Weight w, Flow c) : src(s), dst(d), weight(w), cap(c) {}
};
using Edges = vector<Edge>;
using Graph = vector<Edges>;
using Array = vector<Weight>;
using Matrix = vector<Array>;

void add_edge(Graph &g, int a, int b, Weight w = 1, Flow c = 1) {
    g[a].emplace_back(a, b, w, c);
    g[b].emplace_back(b, a, w, c);
}
void add_arc(Graph &g, int a, int b, Weight w = 1, Flow c = 1) {
    g[a].emplace_back(a, b, w, c);
}

// ワーシャルフロイド法 (O(V^3))
Matrix warshall_floyd(const Graph &g) {
    auto const INF = numeric_limits<Weight>::max() / 8;
    int n = g.size();
    Matrix d(n, Array(n, INF));
    repeat(i, n) d[i][i] = 0;
    repeat(i, n) for (auto &e : g[i]) d[e.src][e.dst] = min(d[e.src][e.dst], e.weight);
    repeat(k, n) repeat(i, n) repeat(j, n) {
        if (d[i][k] != INF && d[k][j] != INF) d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
    }
    return d;
}

int main(void) {
    int n, m, r;
    cin >> n >> m >> r;
    
    Graph g(n);
    vector<int> towns(r);
    repeat(i, r) {
        int t;
        cin >> t;
        towns[i] = t - 1;
    }
    
    repeat(i, m) {
        int a, b, c;
        cin >> a >> b >> c;
        --a, --b;
        add_edge(g, a, b, c);
    }
    
    int ans = numeric_limits<int>::max();
    Matrix res = warshall_floyd(g);
    vector<int> perm(r);
    repeat(i, r) perm[i] = i;
    
    do {
        int ans_tag = 0;
        repeat(i, r - 1) {
            int s = towns[perm[i]];
            int t = towns[perm[i + 1]];
            ans_tag += res[s][t];
        }
        ans = min(ans, ans_tag);
    } while (next_permutation(perm.begin(), perm.end()));
        
    cout << ans << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
int dig(int n) {
    int ans = 0;
    if(n == 0) return 1;
    while(n != 0) {
        n/=10;
        ans++;
    }
    return ans;
}
int pow10(int n) {
    static vector<int> ans(1,1);
    while(ans.size()-1 < n) {
        ans.push_back(ans.back()*10);
    }
    return ans[n];
}

int lowest_num(int n) {
    return n%10;
}
int highest_num(int n) {
    return n/pow10(dig(n)-1);
}

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

    int n;
    cin >> n;
    vector<vector<int>> s(10, vector<int>(10,0));
    for(int a = 1; a <= n; a++) {
        s[highest_num(a)][lowest_num(a)]++;
    }
    int ans = 0;
    for(int l = 1; l <= 9; l++) for(int h = 1; h <= 9; h++) {
        ans += s[l][h] * s[h][l];
    }
    cout << ans << endl;
}

Measured memory_bytes: 3600
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <cassert>
#include <exception>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<string,ll> P;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<P> vp;
#define rep(i,a,n) for(ll i = (a);i < (n);i++)
#define per(i,a,n) for(ll i = (a);i > (n);i--)
#define lep(i,a,n) for(ll i = (a);i <= (n);i++)
#define pel(i,a,n) for(ll i = (a);i >= (n);i--)
#define clr(a,b) memset((a),(b),sizeof(a))
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define sz size()
#define print(X) cout << (X) << endl
const ll INF = 1e+8+7;
ll n,m,l;
string s,t;
int d[100010],dp[500][500];

int main(){
  ll p;
  ll ans = 0;
  cin >> n >> m >> l >> p;
  lep(i,0,n){
    lep(j,0,m){
      lep(k,0,l){
        if(i * 500 + j * 100 + k * 50 == p)ans++;
      }
    }
  }
  print(ans);
  return 0;
}

Measured memory_bytes: 888
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
    int N;
    while(cin >> N){
        vector<int> A(1<<N);
        vector<vector<int>> maxA(1 << N, vector<int>(2, 0));
        for(auto& t : A) cin >> t;
        for(int i=1;i<(1<<N);i++){
            vector<int> idx;
            idx.push_back(i);
            for(int j=0;j<N;j++){
                if(i&(1<<j)){
                    for(int k=0;k<2;k++) idx.push_back(maxA[i^(1<<j)][k]);
                }
            }
            sort(idx.begin(), idx.end(), [&](int a, int b){return A[a] != A[b] ? A[a] > A[b] : a > b;});
            idx.erase(unique(idx.begin(), idx.end()), idx.end());
            for(int j=0;j<2;j++) maxA[i][j] = idx[j];
        }
        int res = 0;
        for(int i=1;i<(1<<N);i++){
            res = max(res, A[maxA[i][0]] + A[maxA[i][1]]);
            cout << res << endl;
        }
    }
}

Measured memory_bytes: 18432
S = list(input())
N = int(len(S))

def ch_kai(lst):
    new_lst = lst[::-1]
    if lst == new_lst:
        return True
    else:
        return False

if ch_kai(S) and ch_kai(S[0:int((N-1)/2)]):
    print("Yes")
else:
    print("No")


Measured memory_bytes: 2940
#include <ctype.h>
#include <float.h>
#include <inttypes.h>
#include <limits.h>
#include <signal.h>
#include <stdarg.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include <math.h>
#ifdef __cplusplus
#include <bits/stdc++.h>
#endif
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
//#pragma GCC optimize("unroll-loops")

//char rbuf[]; int rbufl;
//#define getchar() rbuf[rbufl++]
#define getchar getchar_unlocked
#define putchar putchar_unlocked
int32_t nextint(void){ char c=getchar(); while(c!='-'&&(c<'0'||'9'<c)) c=getchar(); bool s=false; if(c=='-'){s=true;c=getchar();} uint32_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getchar(); } return s?-x:x; }
int64_t nextlong(void){ char c=getchar(); while(c!='-'&&(c<'0'||'9'<c)) c=getchar(); int s=0; if(c=='-'){s=1;c=getchar();} uint64_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getchar(); } return s?-x:x; }
uint32_t nextstr(char *s){ char c=getchar(); while(c==' '||c=='\n') c=getchar(); uint32_t len=0; while(c!=' '&&c!='\n'){ *s++=c; len++; c=getchar(); } *s='\0'; return len; }
void printint(int32_t x){ if(x<0){x=-x; putchar('-');}else if(x==0){putchar('0');} int d=0; char s[10]; while(x){ s[d]='0'+x%10; x/=10; d++; } for (int i=d-1; i>=0; i--) putchar(s[i]); putchar('\n'); }
void rsorta_d32(void *base, const int count, const int size, const int index){
	typedef int32_t rsort_t;
	rsort_t (*a)[size] = (rsort_t(*)[size])base;
	rsort_t (*b)[size] = (rsort_t(*)[size])malloc(count*size*sizeof(rsort_t));
	int c[0x100];
	for(int k=0; k<4; k++){
		memset(c, 0, sizeof(c)); for(int i=0; i<count; i++){ c[(a[i][index]>>(k<<3))&0xFF]++; } for(int i=1; i<0x100; i++) c[i]+=c[i-1]; for(int i=count-1; i>=0; i--){ int to=--c[(a[i][index]>>(k<<3))&0xFF]; for(int j=0; j<size; j++){ b[to][j]=a[i][j]; } }{rsort_t(*t)[size]=a; a=b; b=t;}
	}
	free(b);
}

#define P 1000000007
int a[200000];
int main(void){
	int n=nextint();
	for(int i=0; i<n; i++){
		a[i]=nextint();
	}
	long sum=0, sum2=0;
	for(int i=0; i<n; i++){
		sum=sum+a[i];
		sum2=sum2+(long)a[i]*a[i]%P;
	}
	sum=sum%P;
	sum2=sum2%P;
	int ans = ((long)sum*sum%P+P-sum2)%P;
	ans=ans%2==0?ans/2:(ans+P)/2;
	printf("%d\n", ans);
}


Measured memory_bytes: 2384
#include<bits/stdc++.h>
using namespace std;
int a[100100],b[100100];
long long n,k;
int main(){
	scanf("%lld%lld",&n,&k);
	for(int i=0;i<n;++i)
		scanf("%d%d",&a[i],&b[i]);
	long long ans=0;
	for(long long i=1;i<=(1<<30);i<<=1)if(k&i){
		long long s=0;
		long long t=(k^i)|(i-1);
		for(int j=0;j<n;++j)
			if((a[j]&t)==a[j])s+=b[j];
		ans=max(ans,s);
	}
	long long s=0;
	for(int i=0;i<n;++i)
		if((a[i]&k)==a[i])s+=b[i];
	ans=max(ans,s);
	printf("%lld",ans);
}

Measured memory_bytes: 1024
t = int(input())
for _ in range(t):
    n,a,b,c,d = map(int,input().split())

    memo = {}
    def dfs(n):
        if n == 0:
            return 0
        if n == 1:
            return d
        if n in memo:
            return memo[n]
        res = min(
            d*n,
            d*((n+1)//2*2-n)+a+dfs((n+1)//2),
            d*(n-n//2*2)+a+dfs(n//2),
            d*((n+2)//3*3-n)+b+dfs((n+2)//3),
            d*(n-n//3*3)+b+dfs(n//3),
            d*((n+4)//5*5-n)+c+dfs((n+4)//5),
            d*(n-n//5*5)+c+dfs(n//5),
        )
        memo[n] = res
        return res

    print(dfs(n))


Measured memory_bytes: 80432
#include<bits/stdc++.h>
using namespace std;
int a[100005];
int main()
{
	int n,x;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>x;
		a[x]=i;
	}
	for(int i=1;i<=n;i++)
		cout<<a[i]<<" ";
	return 0;
}


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

ll n,a,num[70][3],ans;
const ll mod=1e9+7;

signed main(){
    cin>>n;
    rep(i,n){
        cin>>a;
        rep(j,61){
            ll x=(1ll<<j)%mod;
            (ans+=num[j][!((a>>j)&1)]*x)%=mod;
            num[j][((a>>j)&1)]++;
        }

    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
struct vec{
	vector<int> ve;
};

int main(){
	int n,m,k,a,l,count,num;
	bool flag;
	vector<vec> vv;
	vector<int> vl;
	vec v;
	while(1){
		cin >> n;
		if(n == 0)break;
			vv.clear();
			count = 0;
		for(int i = 0;i < n;i++){
			cin >> m;
			v.ve.clear();
			for(int j = 0;j < m;j++){
				cin >> a;
				v.ve.push_back(a);
			}
			if(m != 0)vv.push_back(v);
			else if(m == 0){
				v.ve.push_back(-1);
				vv.push_back(v);
			}
		}
		cin >> l;
		vl.clear();
		for(int i = 0;i < l;i++){
			cin >> a;
			vl.push_back(a);
		}
		for(int i = 0;i < vv.size();i++){
			for(int j = 0;j < vl.size();j++){
			flag = false;
				for(int k = 0;k < vv[i].ve.size();k++){
					if(vl[j] == vv[i].ve[k]){
						flag = true;
						break;
					}
				}
			if(flag == false)break;
			}
			if(flag == true){
				count++;
				num = i;
			}
		}
		if(count == 1)cout << num+1 <<endl;
		else cout << -1 <<endl;
	}
	return 0;
}

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

using namespace std;
typedef long long ll;
typedef unsigned long ul;
typedef pair<ul, ul> P;

const int INF = 1e9;
const int MOD =1e9+7;
const ll LINF = 1e18;

int main(){
    int N, D, counter = 0;
    int x[11][11];

    cin >> N >> D;

    rep(i,N){
        rep(j,D) cin >> x[i][j];
    }

    for(int i=0; i < N - 1; i++){
        for(int j=i+1; j < N; j++){
            double temp = 0;
            rep(k,D){
                double tmp = abs(x[i][k] - x[j][k]);
                temp += pow(tmp, 2);
            }
            double ans = sqrt((double)temp);
            ans = ans - (int)ans;
            if(ans == 0) counter++;
        }
    }
    cout << counter << endl;

} 

Measured memory_bytes: 256