akhauriyash/Code-Regression huggingface dataset:
D = [[-1, 0], [1, 0], [0, -1], [0, 1]]

def puyo_rensa(old, cnt)
  check = 14.times.map{ [false] * 8 }
  res = 0
  (1..12).each do |i|
    (1..6).each do |j|
      unless check[i][j] || old[i][j] == 'O' || old[i][j] == '.'
        puyo_connector(i, j, old){ |arr|
          if arr.size >= 4
            arr.each do |s, t|
              D.each do |x, y|
                p, q = s + x, t + y
                check[p][q] = true if old[p][q] == 'O'
              end
              check[s][t] = true
            end
            res = 1
          end
        }
      end
    end
  end
 #check.each{ |c| c.each{ |d| print d ? 1 : 0}; puts}
 #puts
  fld = puyo_eraser(old, check)
  if res == 1 then puyo_rensa(fld, cnt + 1)
  else cnt
  end
end

def puyo_connector(i, j, fld)
  check = 14.times.map{ [false] * 8 }
  arr = [[i, j]]
  ret = [[i, j]]
  check[i][j] = true
  until arr.empty?
    i, j = arr.shift
    D.each do |x, y|
      p, q = i + x,  j + y
      if !check[p][q] && fld[i][j] == fld[p][q]
        check[p][q] = true
        arr << [p, q]
        ret << [p, q]
      end
    end
  end
  yield(ret)
end

def puyo_eraser(fld, check)
  fld = fld.transpose
  nfld = 8.times.map{ [] }
  8.times do |i|
    13.downto(0) do |j|
      unless check.transpose[i][j]
        nfld[i] << fld[i][j]
      end
    end
    (14 - nfld[i].size).times{ nfld[i] << '.' }
    nfld[i].reverse!
  end
  nfld.transpose
end

gets.to_i.times do
  fld = 14.times.map{ ['.'] * 8 }
  12.times do |i|
    gets.chomp.split('').each_with_index do |c, j|
      fld[i+1][j+1] = c
    end
  end
  p puyo_rensa(fld, 0)
end

Measured memory_bytes: 10524
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
#include <map>
#include <unordered_map>
#include <chrono>
#include <numeric>
using namespace std;
using ll = long long;
const ll INF = (ll)1e18+1;
const ll DIV = 1000000007;
//#define TEST
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
#ifdef TEST
    chrono::system_clock::time_point start, end;
    start = chrono::system_clock::now();
#endif
    long H_1, M_1, H_2, M_2, K;
    cin >> H_1 >> M_1 >> H_2 >> M_2 >> K;
    //if(M_2 < M_1) M_2+=60, H_2--;
    //ll minute = (H_2 - H_1) * 60 + (M_2 - M_1);
    //cerr << minute << endl;
    //cout << K * ((minute-1) / K) << endl;
    if(M_2 < K) M_2+=60,H_2--;
    M_2-=K;
    ll minute = (H_2 - H_1) * 60 + (M_2 - M_1);
    cout << minute << endl;
#ifdef TEST
    end = chrono::system_clock::now();
    cerr << static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count() / 1000.0) << "[ms]" << endl;
#endif
    return 0;
}

Measured memory_bytes: 3652
#include<stdio.h>
int main()
    {
    int A1,A2,A3;
    scanf("%d %d %d",&A1,&A2,&A3);
    int sum=A1+A2+A3;
    if (sum>=22)
    printf("bust");
    else
    printf("win");
    return 0;
    }


Measured memory_bytes: 128
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define N  50
#define Si 50
#define INF 100000

char str[N][Si+1];
int num[N][26];
int common[26];

int min(int x, int y){
	if(x < y) return x;
	else return y;
}

int main(void){
	int n, i, j, p;
	int ret=0;

	memset(num, 0, N*26*sizeof(int));
	for(i=0; i<26; i++) common[i] = INF;
	scanf("%d", &n);
	for(i=0; i<n; i++){
		scanf("%s", &str[i][0]);
	}
	
	for(i=0; i<n; i++){
		p=0;
		while(str[i][p] != '\0'){
			num[i][str[i][p] - 'a']++;
			p++;
		}
		
	}
	for(i=0; i<n; i++){
		for(j=0; j<26; j++){
			common[j] = min(common[j], num[i][j]);
		}
	}
	for(i=0; i<26; i++){
		for(j=0; j<common[i]; j++)
			printf("%c", 'a'+i);
	}
	printf("\n");

	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <iomanip>
#include <bitset>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>

using namespace std;

int main() {
  int n, k;
  cin >> n >> k; k--;
  string a;
  cin >> a;
  a[k] = tolower(a[k]);
  cout << a << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
   int w, sum, i = 1, last_mon;
   scanf("%d", &w);
   while ( i ) {
      sum = 0;
      if ( w < 10 ) { sum += 1150; w = 0; }
      else { sum += 1150; w -= 10; }
      if ( w < 10 ) { sum += w * 125; w = 0; }
      else { sum += 125 * 10; w -= 10; }
      if ( w < 10 ) { sum += w * 140; w = 0; }
      else { sum += 140 * 10; w -= 10; }
      if ( w > 0 ) sum += w * 160;
      printf("%d\n", 4280 - sum);
      scanf("%d", &w);
      i = w + 1;
   }
   return 0;
}

Measured memory_bytes: 1796
def get_primes(n):
  if n<=1:
    return []
  prime=[2]
  limit=int(n**0.5)
  p=[i+1 for i in range(2,n,2)]
  while limit>p[0]:
    prime.append(p[0])
    p=[j for j in p if j%p[0]!=0]
  return prime+p

N = int(input())

ans = []
primes = get_primes(55555)
for i in range(3, 55555 + 1, 2):
  if i in primes and i%5 == 1:
    ans.append(i)
  if len(ans) == N:
    break
print(*ans)

Measured memory_bytes: 10468
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	for(int i=0; i<n; i++){
		int x,y,b,p;
		int ans_a,ans_b;
		cin>>x>>y>>b>>p;
		int k=(max(b,5)*x + max(p,2)*y);
		k=(k*10-k*2)/10;
		cout<<min( (x*b+y*p) , k)<<endl;
	}
}


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

const int N = 1000;
vector< vector<int> > G(N);
int d[N],f[N],visited[N];
int timer = 1;

void dfs(int s){
  d[s] = timer++;
  visited[s] = 1;
  for(int i = 0; i < G[s].size(); i++){
    int v = G[s][i];
    if(!visited[v]) dfs(v);
  }
  f[s] = timer++;
}

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

  int n; cin >> n;
  for(int i = 0; i < n; i++){
    int u,k; cin >> u >> k;
    for(int j = 0; j < k; j++){
      int v; cin >> v;
      G[u].push_back(v);
    }
  }

  for(int i = 1; i <= n; i++){
    if(!visited[i]) dfs(i);
  }
  for(int i = 1; i <= n; i++){
    cout << i << " " << d[i] << " " << f[i] << endl;
  }

  return 0;
}



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

using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;
#define DEBUG freopen("in.txt", "r", stdin);

struct fastio {
    fastio() {
        ios::sync_with_stdio(false);
        cout << setprecision(10) << fixed;
        cin.tie(0);
    }
};

fastio _fast_io;

ll a, b, x;
int main() {
    cin >> a >> b >> x;
    ll ans = b / x;
    if (a > 0)
        ans -= (a - 1) / x;
    else
        ++ans;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3688
n = gets.chomp.to_i
ans = 0
k = 1
a = Array.new(n).map{Array.new(2)}
for i in 0..n-1
  a[i][0],a[i][1] = gets.split.map(&:to_i)
end

for i in 1..n-1
  for j in 0..i-1
    d = (a[i][0]-a[j][0])**2+(a[i][1]-a[j][1])**2
    ans += Math.sqrt(d)
  end
end

puts ans*2/n


Measured memory_bytes: 1788
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    long H = sc.nextLong();
    long answer =0;
    long enmcnt =1;
    while(H!=1){
      answer = answer + enmcnt;
      H=H/2;
      enmcnt=enmcnt*2;
      //System.out.println(answer);
    }
    answer = answer + enmcnt;
    System.out.println(answer);
    
    
    
  }
  

  
}

Measured memory_bytes: 23124
import sys
sys.setrecursionlimit(10**7)
import math
mod = 10**9 + 7
def I(): return int(input())
def II(): return map(int, input().split())
def L(): return list(map(int, input().split()))
def TWO(M):
  L=[0]*M
  R=[0]*M
  for i in range(M):
    L[i],R[i] = II()
  return L, R

N,A,B = map(int, input().split())
if A*N <=B:
  print(A*N)
else:
  print(B)

Measured memory_bytes: 38384
package main

import "fmt"

func main() {
	// Code for A - AtCoDeer and Paint Cans
	var a, b, c int
	fmt.Scanf("%d %d %d", &a, &b, &c)

	if a == b && b == c {
		fmt.Println("1")
	} else if a != b && b != c && c != a {
		fmt.Println("3")
	} else {
		fmt.Println("2")
	}
}


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

#define all(x) begin(x), end(x)

using i64 = int_fast64_t;
using u64 = uint_fast64_t;
using f64 = double;
using p64 = pair<i64, i64>;

constexpr i64 INF = INT_FAST64_MAX / 2;

template<typename T>
struct binary_indexed_tree {
    vector<T> t_;
    i64 n_;

    binary_indexed_tree(size_t n): t_(n + 1), n_(n + 1) {}

    void add(i64 i, T x) {
        for (; i <= n_; i += i & -i) t_[i] += x;
    }

    T sum(i64 i) {
        T res = 0;
        for (; i > 0; i -= i & -i) res += t_[i];
        return res;
    }
};

struct query { i64 idx, l, r; };

void solve() {
    i64 n, q;
    cin >> n >> q;
    vector<i64> c(n);
    for (auto& e : c) cin >> e;
    vector<query> qs(q);
    for (i64 i = 0; i < q; i++) {
        auto& [ idx, l, r ] = qs[i];
        idx = i;
        cin >> l >> r;
    }
    sort(all(qs), [](const query &x, const query &y) { return x.r < y.r; });

    vector<i64> right(n), ans(q);
    binary_indexed_tree<i64> cnt(n);
    i64 i = 0;
    for (auto& [ idx, l, r ] : qs) {
        for (; i < r; i++) {
            if (right[c[i]]) cnt.add(right[c[i]], -1);
            right[c[i]] = i + 1;
            cnt.add(right[c[i]], 1);
        }
        ans[idx] = cnt.sum(r) - cnt.sum(l - 1);
    }
    for (auto& e : ans) cout << e << "\n";
    cout << endl;
}

int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
}


Measured memory_bytes: 31084
#include <iostream>
#include <vector>
#include <string>
using namespace std;
const char* solve() {
    int H, W;
    cin >> H >> W;
    vector<string> s(H);
    for (auto& i : s) cin >> i;
    int dh[] = {1, -1, 0, 0}, dw[] = {0, 0, 1, -1};
    for (int h = 0; h < H; h++) {
        for (int w = 0; w < W; w++) {
            if (s[h][w] == '.') continue;
            int cnt = 0;
            for (int i = 0; i < 4; i++) {
                int nh = h + dh[i], nw = w + dw[i];
                if (nh < 0 || nh >= H || nw < 0 || nw >= W) continue;
                if (s[nh][nw] == '#') cnt++;
            }
            if (cnt == 0) return "No";
        }
    }
    return "Yes";
}
int main() {
    cout << solve() << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--) // [a, b)
#define reprev(i,n) reprrev(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
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; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
    詰まった時に、別の分野の問題として考え直す（これdpでは？、グラフとしてみればいいのでは？）
    多くの問題はパターンマッチだが、パターンに落とし込むまでが難しく、そのための訓練としてわからない問題をあれこれ色々な角度から考察してみるのではないか
    cin.tie(0);
    ios::sync_with_stdio(false);<- これら、printfとかと併用しない方が良さそう

*/

const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n==0) return 1;
    ll res=modpow(x, n/2);

    if(n%2==0) return res*res%mod;
    else return res*res%mod*x%mod;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };

/* <--------------------------------------------> */

int n;
vector<ll> memo(1<<20, 0);
vector<bool> flg(1<<20, false);
vector<vector<ll>> a(20, vector<ll>(20, 0));

ll f(int S){
    if(flg[S]) return memo[S];
    flg[S]=true;
    ll tmp=0;
    rep(i, n) repr(j, i+1, n) if(S&1<<i && S&1<<j) tmp+=a[i][j];
    for(int T=S; T>0; T=(T-1)&S) chmax(tmp, f(T)+f(S^T));
    return memo[S]=tmp;
}

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

    cin >> n;
    rep(i, n) rep(j, n) cin >> a[i][j];

    cout << f((1<<n)-1) << endl;

    return 0;
}


Measured memory_bytes: 8576
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
#define sz(i) (int)(i.size())
#define F first
#define S second
#define L long double
#define P pair<int, int>
const int inf = 0x3f3f3f3f3f3f3f3LL;
const int mod = (int)1e9 + 7;
using namespace std;
#if LOCAL
#include "../../tr.h"
#else
#define tr(...)
#define endl '\n'
#endif
template<class T> void smin(T& a, T val) {if (a > val) a = val;}template<class T> void smax(T& a, T val) {if (a < val) a = val;}
const int N = 5*(int)1e5 + 10;

int n, a, b;

int power(int a, int b, int m = mod){a %= m; if(b < 0)b += m-1; int r = 1; while(b){if(b&1)r=(r*a)%m; a = (a*a)%m; b>>=1;}return r;}

long long C(int n, int r) {
    if(r > n - r) r = n - r; // because C(n, r) == C(n, n - r)
    long long ans = 1;
    int i;

    for(i = 1; i <= r; i++) {
        ans *= n - r + i;
        ans %= mod;
        ans *= power(i, -1);
        ans %= mod;
    }

    return ans;
}

int32_t main(){_
   
   cin>>n>>a>>b;

   int total = power(2, n) - 1;
   total += mod;
   total %= mod;


   total -= C(n, a);   
   total += mod;
   total %= mod;
   total -= C(n, b);   
   total += mod;
   total %= mod;

   cout<<total;   

   return 0;
}

Measured memory_bytes: 256
s = str(input())
mx = 0
for i in range(len(s)):
    for j in range(i+1,len(s)+1):
        cnt = j-i
        p = 0
        for k in list(s[i:j]):
            if k in ["A","C","G","T"]:
                p += 1
        if p == cnt:
            if p > mx:
                mx = p
print(mx)


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

using ll = long long;

int main()
{
  ll N, T;
  std::cin >> N >> T;

  std::vector<ll> va(N);
  for (ll i = 0; i < N; i++) {
    std::cin >> va[i];
  }

  // 自分より後ろのデータの最大値を求めておく
  std::vector<std::pair<ll, ll> > vmax(N);
  vmax[N-1] = std::make_pair(va[N-1], N-1);
  for (ll i = N-1; i >= 0; i--) {
    vmax[i] = std::max(vmax[i+1], std::make_pair(va[i], i));
  }

  // 自分と, 自分より後ろのデータの最大値との幅で, 最大値を求めておく
  ll max_range = 0LL;
  for (ll i = 0; i < N; i++) {
    max_range = std::max(max_range, vmax[i].first - va[i]);
  }

  // 自分と, 自分より後ろのデータの最大値との幅が, 幅の最大値であれば神の手を入れる
  // Ai は相異なるという制約があるので, カウントだけしていけば良さそう
  ll cnt = 0LL;
  for (ll i = 0; i < N; i++) {
    if (max_range == vmax[i].first - va[i]) {
      cnt++;
    }
  }

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


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using i64 = long long;

int main() {
    constexpr i64 mod = 1000000007;
    int n;
    std::string s;
    std::cin >> n >> s;
    std::map<char, int> cnt;
    for (auto c : s) cnt[c]++;
    i64 ret = 1;
    for (auto &el : cnt) ret = ret * (el.second + 1) % mod;
    std::cout << ret - 1 << std::endl;

    return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }    //最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }     //最小公倍数
using Graph = vector<vector<ll>>;
ll inf=300000000000000000;
const double PI = 3.14159265358979323846;
int main(){
  char c;
  cin >> c;
  if((c-'a')<26&&(c-'a')>=0){
    cout << 'a' << endl;
  }
  else cout << 'A' << endl;
}


Measured memory_bytes: 3620
#include <vector>
#include <iostream>

int main()
{
    static const int MAX = 100001;
    std::vector<long long> fact(MAX), fact_inv(MAX), inv(MAX);
    constexpr long long mod = 1000000007;
    auto factinit = [&fact, &fact_inv, &inv](long long mod)
    {
        fact[0] = fact[1] = 1;
        fact_inv[0] = fact_inv[1] = 1;
        inv[0] = inv[1] = 1;
        for (int i = 2; i < MAX; ++i)
        {
            fact[i] = fact[i - 1] * i % mod;
            inv[i] = mod - inv[mod % i] * (mod / i) % mod;
            fact_inv[i] = fact_inv[i - 1] * inv[i] % mod;
        }
    };

    int n, m;
    std::cin >> n >> m;
    if (n + 1 != m && n != m + 1 && n != m)
    {
        std::cout << 0 << std::endl;
        return 0;
    }
    factinit(mod);

    long long ans = fact[n] * fact[m];
    if (n == m) ans *= 2;
    ans = (ans + mod) % mod;
    std::cout << ans << std::endl;
    return 0;
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ui unsigned int
#define ull unsigned long long
#define db long double
#define pii pair<int,int>
#define pli pair<ll,int>
#define X first
#define Y second
#define mp make_pair
#define pb push_back
#define vi vector<int>
#define vii vector<vi>
#define lb lower_bound
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define per(i,b,a) for(int i=(b);i>=(a);--i)
#define rep0(i,a,b) for(int i=(a);i<(b);++i)
#define fore(i,a) for(int i=0;i<a.size();++i)
#define gc() getchar()
#define ls x<<1,l,m
#define rs x<<1|1,m+1,r
inline ll rd()
{
	ll x=0,w=1;char c=gc();while(!isdigit(c)&&c!='-')c=gc();
	if(c=='-')c=gc(),w=-1;while(isdigit(c))x=x*10+c-48,c=gc();return x*w;
}
const int a[11]={0,1,2,4,7,12,20,29,38,52,73};
int n,p[11];ll m,e[11][11];
int main()
{
	n=rd();m=0;
	rep(i,2,n)
	{
		rep(j,1,i-1)e[i][j]=e[j][i]=(m+1)*a[j];
		if(i==n)break;
		m=0;rep(j,1,i)p[j]=j;
		do
		{
			ll s=0;rep(j,1,i-1)s+=e[p[j]][p[j+1]];m=max(m,s);
		}while(next_permutation(p+1,p+i+1));
	}
	rep(i,1,n)
	{
		rep(j,1,n)printf("%lld ",e[i][j]);
		puts("");
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <cmath>
#include <climits>
#include <cstdio>
#include <iomanip>
#include <utility>

using namespace std;
typedef long long int ll;

#define SP(x) setprecision((int)x)
#define ALL(v) v.begin(),v.end()

int main(int argc, char const *argv[])
{
    ll a, b;
    cin >> a >> b;
    ll ans = 0;
    for (ll i = 1; i <= a; i++)
    {
        if (i == a)
        {
            if(i <= b)
                ans++;
        }
        else
            ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <map>
#include <math.h>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <set>
#include <queue>
#include <sstream>
#include <stack>
#include <deque>
#include <memory.h>
#include <cassert>
#include <ctime>
#include <climits>
#include <list>
#include <time.h>
#include <unordered_map>
#include <bitset>
#include <exception>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned long long ull;
#define pb push_back
#define mp make_pair
#define INPUT "/Users/bekhzodsoliev/Desktop/C++/cp/cp/file.in"
#define OUTPUT "/Users/bekhzodsoliev/Desktop/C++/cp/cp/file.out"
#define lc v << 1
#define rc (v << 1) + 1
#define inf 1e+9
#define linf ll(1e+18)
#define dinf 1e+14

typedef long long ll;
#define pb push_back
#define mp make_pair

void solve()
{
    for(int i = 0; i < 3; i++)
    {
        string s;
        cin >> s;
        cout << s[i];
    }
}

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0); cout.tie(0);
    //freopen(INPUT, "r", stdin);freopen(OUTPUT, "w", stdout);
    int t = 1;
    //cin >> t;
    
    while(t--)
    {
        solve();
    }
    
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
//debug
#define vecprint(v) rep(i,v.size())cout << v[i] << " ";cout << endl;
#define setprint(s) for(auto i=s.begin();i!=s.end();i++)cout << *i << " ";cout << endl;
#define mappairprint(s) for(auto i=s.begin();i!=s.end();i++)cout << i->first << " " << i->second << endl;cout << endl;
//reader
#define r1(a) cin>>(a)
#define r2(a,b) cin>>(a)>>(b)
#define r3(a,b,c) cin>>(a)>>(b)>>(c)
//writer
#define w1(a) cout<<(a)<<" "
#define w2(a,b) cout<<(a)<<" "<<(b)<<" "
#define w3(a,b,c) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "
#define wl1(a) cout<<(a)<<endl
#define wl2(a,b) cout<<(a)<<" "<<(b)<<endl
#define wl3(a,b,c) cout<<(a)<<" "<<(b)<<" "<<(c)<<endl
//variable definition
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
//roop
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep1(i,n) for (int i = 1; i <= (n); ++i)
#define all(c) c.begin(),c.end()
//term
#define elif else if
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
using namespace std;
using ll = long long;
//const
constexpr double PI = 3.141592653589793238462643383279;
vector<int> dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};


int main() {
  //input
  int l,r,d;
  cin >> l >> r;
  cin >> d;
  
  string s;
  cin >> s;

  //process
  int ret = 0;
  rep(i,101) {
    int t = d * i;
    if(t >= l && t <= r) ret++;
  }
  
  //output
  cout << ret << endl;
}

Measured memory_bytes: 3624
#include <stdio.h>

int main (void)
{
  int P, Q, R;
  scanf("%d %d %d", &P, &Q, &R);

  int min = 9999;
  for (int i = 0; i < 1; i++){
  if (P+Q < min) min = P+Q;
  if (Q+R < min) min = Q+R;
  if (R+P < min) min = R+P;
}

  printf("%d\n",min);
  return 0;
}

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

using namespace std;

int main()
{
  int N, A, B;
  cin >> N >> A >> B;
  if ((B - A) % 2 == 0)
    cout << "Alice" << endl;
  else
    cout << "Borys" << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
#define int long long
using namespace std;
typedef pair<int,int>P;
#define fi first
#define se second

priority_queue<P> q,v;
priority_queue<P,vector<P>,greater<P> > q2;

signed main(){
  int sum=0,PPP=0;
  int n,k;
  cin>>n>>k;
  int t[n],d[n];
  r(i,n)cin>>t[i]>>d[i];
  r(i,n){
    q.push(P(d[i],t[i]));
  }
  map<int,int>st;
  r(i,n){
    P p=q.top();q.pop();
    if(st[p.se]||PPP==k)v.push(p);
    else{
      q2.push(p);
      st[p.se]++;
      sum+=p.fi;
      PPP++;
    }
  }
  int x=n-v.size();
  int ans= sum+x*x;
  while(!v.empty()){
    P p=v.top();v.pop();
    if((int)q2.size()==k){
      P a=q2.top();q2.pop();
      st[a.se]--;
      if(st[a.se]==0)x--;
      sum-=a.fi;
    }
    int A=p.fi;
    int B=p.se;
    sum+=A;
    st[B]++;
    if(st[B]==1)x++;
    q2.push(p);
    ans=max(ans,sum+x*x);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 11248
#include<bits/stdc++.h>
using namespace std;
//<<setprecision(30)
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for (ll i = 1; i <= (ll)(n); i++)
#define INF 1000000000000
#define MOD 1000000007
using ll = long long;
using Graph = vector<vector<int>>;

int main(){
  int N,M; cin>>N>>M;
  vector<ll> A(N),B(N),C(M),D(M);
  rep(i,N)cin>>A.at(i)>>B.at(i);
  rep(i,M)cin>>C.at(i)>>D.at(i);
  rep(i,N){
    ll res = INF;
    int num = 0;
    rep(j,M){
      if(res>abs(A.at(i)-C.at(j))+abs(B.at(i)-D.at(j)))num=j;
      res = min(abs(A.at(i)-C.at(j))+abs(B.at(i)-D.at(j)),res);
      
    }
    cout<<num+1<<endl;
  }
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(int argc, char *argv[])
{
	int N;
	string S;

	cin >> N >> S;

	if (N % 2 == 1) {
		cout << "No" << endl;
		return 0;
	}

	for (int i = 0; i < N / 2; i++) {
		if (S[i] != S[i + N / 2]) {
			cout << "No" << endl;
			return 0;
		}
	}

	cout << "Yes" << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int INF = 1e9;
int MOD = 1e9+7;
main(){
    int edge[200][200];
    int N,M,R;
    cin >> N >> M >> R;
    vector<int> r(R);
    fill(edge[0],edge[200],INF);
    for(int i = 0;i < N;i++)edge[i][i] = 0;
    for(int i = 0;i < R;i++)cin >> r[i];
    for(int i = 0;i < M;i++){
        int a,b,c;
        cin >> a >> b >> c;
        a--;b--;
        edge[a][b] = edge[b][a] = c;
    }
    for(int i = 0;i < N;i++)for(int j = 0;j < N;j++)for(int k = 0;k < N;k++){
        edge[j][k] = min(edge[j][k],edge[j][i] + edge[i][k]);
    }
    sort(r.begin(),r.end());
    int mini = INF;
    do{
        int sum = 0;
        for(int i = 1;i < R;i++){
            sum += edge[r[i]-1][r[i-1]-1];
        }
        mini = min(mini,sum);
    }while(next_permutation(r.begin(),r.end()));
    cout << mini << endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <string>

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;

using namespace std;


int inputValue(){
    int a;
    cin >> a;
    return a;
};

void inputArray(int * p, int a){
    rep(i, a){
        cin >> p[i];
    }
};

void inputVector(vector<int> * p, int a){
    rep(i, a){
        int input;
        cin >> input;
        p -> push_back(input);
    }
}

template <typename T>
void output(T a, int precision) {
    if(precision > 0){
        cout << setprecision(precision)  << a << "\n";
    }
    else{
        cout << a << "\n";
    }
}

void dfs(ll i,ll n,int* num){
	if(i>n){
		return;
	}

	string temp=to_string(i);
	int num_3=0,num_5=0,num_7=0;
	rep(l0,temp.size()){
		if(temp[l0]=='3'){
			num_3++;
		}
		if(temp[l0]=='5'){
			num_5++;
		}
		if(temp[l0]=='7'){
			num_7++;
		}
	}
	if(num_3>0 & num_5>0 & num_7>0){
		*num=*num+1;
	}

	dfs(i*10+3,n,num);
	dfs(i*10+5,n,num);
	dfs(i*10+7,n,num);
}

int main() {
	ll n;
	cin >> n;
	int number=0;
	dfs(0,n,&number);
	cout << number << endl;
}


Measured memory_bytes: 256
<?php

fscanf(STDIN, "%d %d", $n, $k);
$V = array_map('intval', explode(' ', trim(fgets(STDIN))));

$max = 0;

for ($l = 0; $l <= $k; ++$l) {
    for ($r = 0; $r <= $k - $l; ++$r) {
        if ($r + $l > $n) break;

        $s = [];
        $sum = 0;
        for ($i = 0; $i < $l; ++$i) {
            $sum += $V[$i];
            $s[] = $V[$i];
        }
        for ($i = 0; $i < $r; ++$i) {
            $sum += $V[$n - 1 - $i];
            $s[] = $V[$n - 1 - $i];
        }

        $d = $k - $r - $l;
        sort($s);

        /* echo "l: $l, r: $r, sum: $sum, d: $d"; */

        for ($i = 0; $i < $d; ++$i) {
            if ($i >= count($s)) break;
            if ($s[$i] > 0) break;

            $sum -= $s[$i];
        }

        $max = max($max, $sum);
        /* echo ", after sum: $sum", PHP_EOL; */
    }
}
echo $max;


Measured memory_bytes: 4604
import java.util.Scanner;
import java.util.Collections;
import java.util.Arrays;
import java.util.Set;
import java.util.HashSet;
import java.util.ArrayList;

public class Main {
    static final Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
		int N=sc.nextInt();
		String S=sc.next();
		ArrayList<String> list1 = new ArrayList<String>();
		ArrayList<String> list2 = new ArrayList<String>();
		int ans = 0;

		for(int i=1;i<N;i++){
			list1 = new ArrayList<String>();
			list2 = new ArrayList<String>();
			String str1 = S.substring(0, i);
			String str2 = S.substring(i, N);

			for(int i2 = 0;i2<str1.length();i2++){
				list1.add(CS(str1.charAt(i2)));
				
			}
			for(int i2 = 0;i2<str2.length();i2++){
				list2.add(CS(str2.charAt(i2)));
			}

			int cnt = 0;

			HashSet<String> set = new HashSet<String>(list1);
			list1 = new ArrayList<String>(set);
			set = new HashSet<String>(list2);
			list2 = new ArrayList<String>(set);
			for(String str: list1){
				if(list2.contains(str)) cnt++;
			}
			ans = Math.max(ans, cnt);
			
		}

		System.out.println(ans);
			
		
    }

    static void sort(int[] a, int b) {//arrays.sort 0で降順, それ以外で昇順
        if (b == 0) {
            Arrays.sort(a);
            int t = 0;
            int c = a.length - 1;
            for (int i = c; i >= c / 2 + 1; i--) {

                t = a[i];
                a[i] = a[c - i];
                a[c - i] = t;
            }
        } else {
            Arrays.sort(a);
        }
    }

    static int SI(String a) {
        return Integer.parseInt(a);
    }

    static char SC(String a) {
        return a.charAt(0);
    }

    static double SD(String a) {
        return new Double(a).doubleValue();
    }

    static String CS(char a) {
        return String.valueOf(a);
    }

    static int DI(double a) {
        return new Double(a).intValue();
    }

    static String DS(double a) {
        return Double.toString(a);
    }

    static int LI(long a) {
        return new Long(a).intValue();
    }

    static char LC(long a) {
        return Long.toString(a).charAt(0);
    }

    static double LD(long a) {
        return new Long(a).doubleValue();
    }

    static long IL(int a) {
        return new Integer(a).longValue();
    }

    static double ID(int a) {
        return new Integer(a).doubleValue();
    }

    static char IC(int a) {
        return Integer.toString(a).charAt(0);
    }

    static String IS(int a) {
        return Integer.toString(a);
    }

}


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

int main() {
   int N;
   ll M;  cin >> N >> M;
   vector<pair<ll, ll>> v(N);
   
   for(int i = 0; i < N; i++) cin >> v[i].first >> v[i].second;

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

   ll res = 0;
   ll ans = 0;
   for(int i = 0; i < N && M > 0; i++) {
       ans += v[i].first * min(M, v[i].second);
       M -= min(M, v[i].second);
   }

   cout << ans;

    return 0;

}

Measured memory_bytes: 1792
A, B = map(int,input().split())
mod = 10**9+7
def factorical(n):
  ret = 1
  for i in range(1,n+1):
    ret *= i
    ret %= mod
  return ret%mod

a = factorical(A)
b = factorical(B)
if(abs(A-B) >= 2):
  print(0)
elif(A == B):
  print(a*b*2%mod)
else:
  print(a*b%mod)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
signed main(){
  int A,B; cin>>A>>B;
  cout<<(A+B)%24<<endl;
  }


Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var n, m int
	fmt.Scanf("%d %d", &n, &m)
	isAC := make([]bool, n+1)
	counter := make(map[string]int)
	wa := make([]int, n+1)
	var p int
	var s string
	for i := 0; i < m; i++ {
		fmt.Scanf("%d %s", &p, &s)
		if isAC[p] {
			continue
		}
		if s == "WA" {
			wa[p]++
		} else if s == "AC" {
			counter["WA"] += wa[p]
			counter["AC"]++
			isAC[p] = true
		}
	}
	fmt.Printf("%d %d", counter["AC"], counter["WA"])
}


Measured memory_bytes: 7612
void solve();

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

//////////////////////////////////////////////////
//////////////////////////////////////////////////
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <functional>
#include <limits.h>
#include <complex>
#include <assert.h>
#include <set>
using namespace std;
typedef pair<int, int> pii;
typedef long double ld;
typedef long long ll;
typedef complex<ld> Point;
vector<int> vcount;

void solve() {
	string S;
	cin >> S;
	vcount.resize(26,0);
	for (int i = 0; i < 4; i++) {
		vcount[S[i] - 'A']++;
	}
	bool flag = false;
	for (int i = 0; i < 26; i++) {
		if (vcount[i] != 0 && vcount[i] != 2) {
			flag = true;
			break;
		}
	}
	if (flag)cout << "No" << endl;
	else cout << "Yes" << endl;
	return;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstdlib>

using namespace std;

int main(){
  int n,m;
  cin >> n >> m;
  string a[n];
  string b[m];
  for(int i = 0; i< n; i++){
    string tempa;
    cin >> tempa;
    a[i] = tempa;
  }
  for(int i = 0; i< m; i++){
    string tempb;
    cin >> tempb;
    b[i] = tempb;
  }

  bool result = false;

  //以下全探索
  for(int upleft = 0; upleft<=n-m; upleft++){
    for(int upright = 0; upright <= n-m; upright++){
      bool check = true;
      for(int k = 0; k<m; k++){
        for(int s = 0; s<m; s++){
          if(a[upleft+k][upright+s] != b[k][s]){
            check = false;
            break;
          }
        }
      }
      if(check){
        result = true;
        break;
      }
    }
  }

  if(result){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}


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

#define MAX_N 200010
#define INF 1e14
typedef long long ll;

#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)

struct BIT{
  ll bit[MAX_N+1];

  void init(){
    memset(bit,0,sizeof(bit));
  }

  ll sum(int i){
    ll s=0;
    while(i>0){
      s+=bit[i];
      i-=i&-i;
    }
    return s;
  }

  void add(int i,ll v){
    while(i<=MAX_N){
      bit[i]+=v;
      i+=i&-i;
    }
  }
};

struct RangeSumQuery{
  //int size;
  BIT bit0, bit1;

  RangeSumQuery(){}

  void init() {
    //size = size_;
    bit0.init();
    bit1.init();
  }

  //[from, to)
  ll sum(int from, int to) {
    return (bit0.sum(to)+bit1.sum(to)*to) - (bit0.sum(from)+bit1.sum(from)*from);
  }

  //[from, to)
  void add(int from, int to, ll value) {
    bit0.add(to, to * value);
    bit0.add(from, - from * value);
    bit1.add(from, value);
    bit1.add(to, -value);
  }
};

ll N, Q;
vector<ll> A[26];
ll B[MAX_N];
char str[MAX_N];
RangeSumQuery bit;

int main() {
    scanf("%s", str);
    N = strlen(str);
    rep(i,26) A[i].clear();

    rep(i, N) A[str[i]-'a'].push_back(i);
    ll odd = 0;
    rep(i,26) if((int)A[i].size() % 2 == 1) odd++;
    if(odd >= 2) {
      printf("-1\n");
      return 0;
    }
    rep(i,26) {
      int n=(int)A[i].size();
      rep(j,(n+1)/2) B[A[i][j]] = A[i][n - j - 1];
    }
    ll res = 0;
    bit.init();
    rep(i,N)bit.add(i+1,i+2,i);
    ll n = N;
    rep(i, N) {
      if(bit.sum(i+1,i+2) == 0) {
        ll j = B[i] + 1;
        res += n - bit.sum(j,j+1) - 1;
        if(i + 1 != j) {
          bit.add(1,j,-1);
          bit.add(j,N+1,-2);
        }
        else {
          bit.add(j,N+1,-1);
        }
        bit.add(i+1,i+2,INF);
        bit.add(j,j+1,INF);
        n -= 2;
      }
    }
    printf("%lld\n", res);

  return 0;
}


Measured memory_bytes: 6772
N,A,B,C,D= list(map(int,input().split()))
def nibun(func ,min_ ,max_ ):
    left = min_
    right= max_
    while not(left==right):
        mid = (left+right) //2
        tmp = func(mid)
        if tmp:
            right = mid
        else:
            left = mid+1
    return left

X = abs(A-B)
def calc(n):
    m = N-n-1
    min_val = -D*n +C*m
    max_val = -C*n +D*m
    return min_val , max_val

def check(n):
    return calc(n)[0] <=X


n= (nibun(check,0,N))
print("YES" if calc(n)[0]<=abs(A-B) and calc(n)[1]>=abs(A-B)else "NO")

Measured memory_bytes: 3064
#include <stdio.h>
#define N 100
#define INFTY 1<<21

int M[N][N],n;

void calc(){
  int i,v,x,y;
  int d[N],col[N];

  for(i=0; i<n; i++){
    d[i] = INFTY;
    col[i] = 0;
  }
  d[0] = 0;
  col[0] = 1;

  while(1){
    v = INFTY;
    x = -1;

    for(i=0; i<n; i++){
      if(v > d[i] && col[i] != 2){
        v = d[i];
        x = i;
      }
    }
    if(x == -1) break;
    col[x] = 2;
    for(y=0; y<n; y++){
      if(col[y] != 2 && M[x][y] != INFTY){
        if(d[y] > d[x] + M[x][y]){
          d[y] = d[x] + M[x][y];
          col[y] = 1;
        }
      }
    }
  }

  for(i=0; i<n; i++){
    printf("%d",i);
    printf(" %d\n",d[i] == INFTY ? -1 :d[i]);
  }

}

int main(){
  int i,j;
  scanf("%d",&n);
  for(i=0; i<n; i++){
    for(j=0; j<n; j++){
      M[i][j] = INFTY;
    }
  }

  int k,c,x,y;
  for(i=0; i<n; i++){
    scanf("%d%d",&x,&k);
    for(j=0; j<k; j++){
      scanf("%d%d",&y,&c);
      M[x][y] = c;
    }
  }

  calc();

  return 0;
}



Measured memory_bytes: 2112
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
template<class T>void chmax(T &a,T b){if(a<b)a=b;}
template<class T>void chmin(T &a,T b){if(a>b)a=b;}
constexpr ll INF=1000000000000000000;
int n,a,b,p[5010],q[5010];
ll dp[5010][10010];
int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    cin>>n>>a>>b;
    rep(i,n){
        cin>>p[i];
        q[p[i]-1]=i+1;
    }
    rep(i,n+1)rep(j,2*n+2)dp[i][j]=INF;
    dp[0][1]=0;
    rep(i,n){
        ll cur=INF;
        for(int j=1;j<=2*n+1;j++){
            if(j%2==1){
                chmin(cur,dp[i][j]);
                chmin(cur,dp[i][j-1]);
            }
            if(j>q[i]*2)chmin(dp[i+1][j],cur+a);
            if(j<q[i]*2)chmin(dp[i+1][j],cur+b);
            if(j==q[i]*2)chmin(dp[i+1][j],cur);
        }
    }
    ll ans=INF;
    rep(j,2*n+2)chmin(ans,dp[n][j]);
    cout<<ans<<endl;
    return 0;
}


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

#define fir first
#define sec second
using namespace std;
typedef long long LL;
typedef unsigned long long u64;

template <typename T> inline bool cmin(T & a, const T & b) { return a > b ? a = b, 1 : 0;}
template <typename T> inline bool cmax(T & a, const T & b) { return a < b ? a = b, 1 : 0;}
int inp() {
	int x = 0, f = 1;char ch;
	for(ch = getchar(); !isdigit(ch); ch = getchar())
		if(ch == '-') f = -1;
	for(; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
	return x * f;
}

int n, m, K;
int main() {
	int i;
	cin >> n >> m >> K;
	for(i = 0; i <= n; i++) {
		double y = K - i * m;
		y /= (n - 2 * i);
		if(y == int(y) && int(y) <= m && int(y) >= 0) {
			return puts("Yes"), 0;
		} 
	}
	puts("No");	
	return 0;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define ff              first
#define ss              second
#define pb              push_back
#define int             long long
#define mp              make_pair
#define pr              pair<long long,long long>
#define vr              vector<long long>
#define mod1            1000000007
#define mod2            998244353
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define ll              long long
#define ld	            long double
#define w(x)            int x; cin>>x; while(x--)

int32_t sum_of_digit(int n)  
{  
    if (n == 0)  
    return 0;  
    return (n % 10 + sum_of_digit(n / 10));  
}  



int32_t main()
{ 
    int n;
    cin>>n;
    
    int r=n%1000;
    int q=n/1000;
    int ans=0;
    if(r==0)
    ans=0;
    else
    {
        ans=(q+1)*1000-n;
    }
    
    cout<<ans<<"\n";
    
	return 0;
	}

Measured memory_bytes: 3628
// practice with kaiboy
import java.io.*;
import java.util.*;

public class Main extends PrintWriter {
	Main() { super(System.out, true); }
	Scanner sc = new Scanner(System.in);
	public static void main(String[] $) {
		Main o = new Main(); o.main(); o.flush();
	}

	void main() {
		int n = sc.nextInt();
		long c = sc.nextLong();
		long[] xx = new long[n + 2];
		int[] vv = new int[n + 2];
		long[] pp = new long[n + 2];
		long[] qq = new long[n + 2];
		for (int i = 1; i <= n; i++) {
			xx[i] = sc.nextLong();
			pp[i] = qq[i] = vv[i] = sc.nextInt();
		}
		for (int i = 1; i <= n; i++)
			pp[i] += pp[i - 1];
		for (int i = n; i >= 1; i--)
			qq[i] += qq[i + 1];
		long ans = 0, z = 0;
		for (int i = 1; i <= n; i++) {	// p p q
			long p2 = pp[i] - xx[i] * 2;
			long q = qq[i] - (c - xx[i]);
			ans = Math.max(ans, z + q);
			z = Math.max(z, p2);
		}
		z = 0;
		for (int i = n; i >= 1; i--) {	// q q p
			long p = pp[i] - xx[i];
			long q2 = qq[i] - (c - xx[i]) * 2;
			ans = Math.max(ans, z + p);
			z = Math.max(z, q2);
		}
		println(ans);
	}
}


Measured memory_bytes: 63020
x, y, z, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

ab = []
for i in range(x):
  for j in range(y):
    ab.append(a[i] + b[j])
ab = sorted(ab, reverse=True)

abc = []
for i in range(min(k, len(ab))):
  for j in range(z):
    abc.append(ab[i] + c[j])
abc = sorted(abc, reverse=True)

for i in range(k):
  print(abc[i])


Measured memory_bytes: 148864
#include<stdio.h>
#include<string.h>
long long gcd(long long a, long long b){
    return b==0 ? a : gcd(b,a%b);
}
int main()
{
    long long a,b,c;

    scanf("%lld %lld",&a,&b);
    c=gcd(a,b);
    printf("%lld",(a*b)/c);
    return 0;
}


Measured memory_bytes: 128
#include<cstdio>
#include <iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<queue>
#include<vector>
#include<functional>
#include<cmath>
#include<map>
#include<stack>
#include<cstdlib>
#include<list>
#include<set>
#include<numeric>

#define MOD 1000000007

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

int anna[5010], bluno[5010];

int main()
{
	queue<int> q;
	int A, B;  cin >> A >> B;
	for (int i = 0; i < A; i++) {
		cin >> anna[i];
	}

	for (int i = 0; i < B; i++)
		cin >> bluno[i];

	int ans = 0;
	int cur = 0;
	int sum = 0;
	for (int i = 0; i < B-ans; i++) {
		cur = i;
		for (int j = 0; j < A; j++) {
			if (bluno[cur] == anna[j]) {
				sum++;
				cur++;
			}
		}
		ans = max(ans, sum);
		sum = 0;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3128
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int r = sc.nextInt();
		sc.close();

		System.out.println(r + Math.max(10 - n, 0) * 100);
	}
}


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

int main(){
    int n;
    cin >> n;
    vector<int> v(n);
    for(int i = 0; i < n; i++){
        cin >> v.at(i);
    }
    int sum = 0;
    for(int i = 0; i < n; i++){
        for(int j = i+1; j < n; j++){
            sum += v.at(i) * v.at(j);
        }
    }
    cout << sum << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define LL long long
#define FASTER ios_base::sync_with_stdio(false); cin.tie(0);
using namespace std;

int main()
{
    FASTER;

    map <int, int> mp, mpp;
    map <int, int> :: iterator it;
    int N, M, u, v;
    cin >> N >> M;
    for(int i = 0; i < M; i++){
        cin >> u >> v;
        if(u == 1) mp[v]++;
        if(v == N) mpp[u]++;
    }
    bool ok = false;
    for(it = mp.begin(); it != mp.end(); it++){
        if(mpp[it->first]){
            ok = true;
            break;
        }
    }
    if(ok) cout << "POSSIBLE" << "\n";
    else cout << "IMPOSSIBLE" << "\n";
    return 0;
}


Measured memory_bytes: 14336
n = int(input())
#n, k = map(int,input().split())

plst = [int(i) for i in input().split()]
lst = [0] * 8
kami = 0
for i in plst:
    l = i // 400
    if l >= 8:
        kami += 1
    else:
        lst[l] = 1
s = sum(lst)
print(max(s, 1), s + kami)

Measured memory_bytes: 3060
#include<iostream>
#include<vector>

using namespace std;
using ll = long long int;

int main(void) {
    int n, m, q;
    cin >> n >> m >> q;
    vector<int> a(q), b(q), c(q), d(q);
    for (int i = 0; i < q; i++) {
        cin >> a[i] >> b[i] >> c[i] >> d[i];
    }
    int mx = 0, score;
    vector<int> s(n, 1);
    do {
        score = 0;
        //for (int i = 0; i < n; i++) cout << s[i];
        //cout << " ";
        for (int i = 0; i < q; i++) {
            if (s[b[i] - 1] - s[a[i] - 1] == c[i]) score += d[i];
        }
        //cout << score << endl;
        mx = max(mx, score);
        s[n - 1]++;
        if (m != 1) {
            for (int i = 0; i < n; i++) {
                if (s[n - 1 - i] > m) {
                        s[n - 2 - i]++;
                    for (int j = 0; j <= i; j++) {
                        s[n - 1 - i + j] = s[n - 2 - i];
                    }
                }
            }
        }
    } while (s[0] != m);
    cout << mx << endl;
}

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

int p[100010];

int main () {

int n;
cin >> n;
for (int i = 1; i <= n; i ++) {
	cin >> p[i];
}
int br = 0;
for (int i = 1; i <= n; i ++) {
	if (p[i]==i) {swap(p[i],p[i+1]); br++;}
}
cout << br;
 

return 0;
}


Measured memory_bytes: 640
#include<cstdio>
#include<algorithm>
using namespace std;
int a[110];
int main()
{
	int n;
	scanf("%d", &n);
	int cnt = 0;
	for (int i = 0; i < n; i++)
	{
		scanf("%d", &a[i]);
		if (i)
		{
			if (a[i] == a[i - 1])
			{
				cnt++;
				a[i] = 0;
			}
		}
	}
	printf("%d", cnt);
}

Measured memory_bytes: 128
#include<algorithm>
#include<iostream>
#include<string.h>
#include<stdio.h>
#include<string>
#include<math.h>
#include<vector>
#include<queue>
#include<set>
#include<map>
using namespace std;
int main()
{
int a,b,c,d;
cin>>a>>b>>c>>d;
cout<<(min(a,b)+min(c,d));
return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define int long long
#define all(a) a.begin(), a.end()
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e15;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m;
    cin >> n;
    map<int, int> mp;
    rep(i, 0, n){
        int d;
        cin >> d;
        mp[d]++;
    }
    bool f = true;
    cin >> m;
    rep(i, 0, m){
        int t;
        cin >> t;
        if(mp[t] == 0) f = false;
        mp[t]--;
    }
    if(f) cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 12800
#include <stdio.h>
#include <math.h>
#include <time.h>
#include<stdlib.h>
#include<string.h>

int main(void) {
	long long int s, c, ans = 0;

	scanf("%lld %lld", &s, &c);

	c /= 2;

	if (s < c) {
		ans += s;
		c -= s;
		ans += c / 2;
	}
	else {
		ans += c;
	}

	printf("%lld", ans);
}

Measured memory_bytes: 1724
#include <bits/stdc++.h>
#include <fstream>
#define inputtxt() std::ifstream in("input.txt"); std::cin.rdbuf(in.rdbuf())
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define foreach(e, v) for (auto e : v)
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
#define collect(arr, size) rep(i,size) cin >> arr[i];

int main(){
    int n,k; vector<int>score((int)'z',0); string hands;
    cin >> n >> k;
    cin >> score['r'] >> score['s'] >> score['p'];
    cin >> hands;
    
    char win['z'], lose['z'];
     win['r']='p';  win['s']='r';  win['p']='s';
    lose['p']='r'; lose['r']='s'; lose['s']='p';
    
    auto is_within = [&](int a){return 0 <= a && a < n;};
    vector<char> myhands(n);
    int highest = 0;
    rep(i,n){
        if(is_within(i-k)){
            if(myhands[i-k]==win[hands[i]]){
                if(is_within(i+k)){
                    myhands[i] = lose[hands[i+k]];
                }else{
                    myhands[i] = '-';
                }
                continue;
            }
        }
        myhands[i] = win[hands[i]];
        highest += score[myhands[i]];
    }
    cout << highest << endl;
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
using P = pair<ll, ll>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep1(i, n) for(ll i=1;i<=(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define INF 1000000000

void solve_keyence2020() {
	ll n;
	ll ans = 0;
	cin >> n;

	vector<P> x(n);
	vector<P> d(n);

	rep(i, n) {
		cin >> x[i].first >> x[i].second;
		d[i].first = x[i].first + x[i].second;
		d[i].second = x[i].first - x[i].second;
	}

	sort(ALL(x));
	sort(ALL(d));

	ans = 1;
	ll upper = d[0].first;
	rep2(i, 1, n) {
		if (upper <= d[i].second) {
			ans++;
			upper = d[i].first;
		}
	}

	cout << ans << "\n";
}

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

	solve_keyence2020();

	return 0;
}


Measured memory_bytes: 3328
#include <iostream>
#include <cstdio>

const int N = 9;

int main(void) {
  int n = 0;

  while (scanf("%d", &n) != EOF) {
    int count = 0;
    
    for (int i = 0; i <= N; i++) {
      for (int j = 0; j <= N; j++) {
	for (int k = 0; k <= N; k++) {
	  for (int l = 0; l <= N; l++) {
	    if ((i + j + k + l) == n) {
	      count++;
	    }
	  }
	}
      }
    }

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

Measured memory_bytes: 1208