akhauriyash/Code-Regression huggingface dataset:
n,w=map(int,input().split())
a=[list(map(int,input().split())) for _ in range(n)]
dp=[[0 for _ in range(w+1)] for _ in range(n+1)]
for i in range(n):
    for j in range(w+1):
        weight,value=a[i]
        dp[i+1][j]=max(dp[i][j],dp[i+1][j])
        if j+weight<=w:
            dp[i+1][j+weight]=max(dp[i][j+weight],dp[i][j]+value)
print(dp[-1][-1])

Measured memory_bytes: 218132
#include<iostream>
#include<cstdio>
#include<iomanip>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<numeric>
#include<limits>
#include<bitset>
#include<functional>
#include<type_traits>
#include<queue>
#include<stack>
#include<array>
#include<random>
#include<utility>
#include<cstdlib>
#include<ctime>

#define ld  long double
#define ll  long long int
#define ull unsigned long long int
#define pb  push_back
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLr(obj) (obj).rbegin(), (obj).rend()
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,s,n) for(int i=s;i<n;i++)

const int    INF = 1e11;
const double EPS = 1e-11;

//切り上げ整数除算
int divRoundUp(const int& a, const int& b) { return (a + b - 1) / b; }
//四捨五入
int roundOff(const double& a) { return (int)(a + 0.5); }
// r の(誤差付きの)符号に従って, -1, 0, 1 を返す.
int sgn(const ld& r) { return (r > EPS) - (r < -EPS); }
// a, b の(誤差付きの)大小比較の結果に従って, -1, 0, 1 を返す.
int sgn(const ld& a, const ld& b) { return sgn(a - b); }

using namespace std;

inline void Main() {
	ull r, d, x; cin >> r >> d >> x;
	REP(i, 10) {
		x = r * x - d;
		cout << x << "\n";
	}
}

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

	Main();

	return 0;
}

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

int main() {
  int N;
  cin >> N;
  int n0, n4;
  n0 = 0;
  n4 = 0;
  for (int i = 0; i < N; i++) {
    int a;
    cin >> a;
    if (a % 2 == 1) n0++;
    else if (a % 4 == 0) n4++;
  }
  
  if (n0 + n4 == N) {
    if (n0 <= n4 + 1) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
  else {
    if (n0 <= n4) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        int h = Integer.parseInt(sc.next());
        int w = Integer.parseInt(sc.next());
        char[][] a = new char[h][w];
        for (int i = 0; i < h; i++) {
            a[i] = sc.next().toCharArray();
        }
        sc.close();

        // 主処理
        List<char[]> list = new ArrayList<>();
        for (int i = 0; i < h; i++) {
            if (new String(a[i]).replace(".", "").length() != 0) {
                list.add(a[i]);
            }
        }

        List<Integer> deleteIndexList = new ArrayList<>();
        for (int i = 0; i < w; i++) {
            boolean isDelete = true;
            for (int j = 0; j < list.size(); j++) {
                if (list.get(j)[i] == '#') {
                    isDelete = false;
                    break;
                }
            }
            if (isDelete) {
                deleteIndexList.add(i);
            }
        }

        String result = "";
        if (deleteIndexList.size() < w) {
            for (int i = 0; i < list.size(); i++) {
                String line = "";
                for (int j = 0; j < w; j++) {
                    if (!deleteIndexList.contains(j)) {
                        line += list.get(i)[j];
                    }
                }
                result += line + "\n";
            }

        } else {
            result = "\n";
        }

        // 出力
        System.out.print(result);
    }
}


Measured memory_bytes: 31060
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
using namespace std;

int main(){
  vector<vector<int>> c(3, vector<int>(3));
  for (int i=0; i<3; i++) 
    for (int j=0; j<3; j++) 
      cin >> c[i][j];

  vector<int> a(3);
  vector<int> b(3);
    

  int amax = min(min(c[0][0], c[0][1]), c[0][2]);
  int bmax = min(min(c[0][0], c[1][0]), c[2][0]);

  for (int i=amax; i>=0; i--) {
    for(int j=bmax; j>=0; j--) {
      if (i+j != c[0][0]) continue;
      // abの確定
      a[0] = i;
      for(int k=0; k<3; k++) b[k] = c[0][k] - a[0];
      b[0] = j;
      for(int k=0; k<3; k++) a[k] = c[k][0] - b[0];

      // check

      bool check = true;
      for (int k=0; k<3 && check; k++) {
        for (int l=0; l<3 && check; l++) {
          if (c[k][l] != a[k]+b[l]) {
            check = false;
            break;
          }
          if (k==2 && l==2 && c[k][l] == a[k] + b[l]) {
            cout << "Yes" << endl;
            return 0;
          }
        }
      }
    }
  }
  cout << "No" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(long long i=0; i<n; i++)
#define Rep(i,n) for(long long i=1; i<n; i++)
#define ll long long
#include <math.h>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <queue>
#include <set>
#include <vector>


using namespace std;
#define PI acos(-1)
using P =pair<int,int>;

ll f(ll x,ll c,ll d){
    ll res =x;
    res -=x/c;
    res -=x/d;
    res+= x/lcm(c,d);
    return res;
}

int main(){
  ll x;
  cin>>x;
  Rep(i,10000){
      for(ll j=-10000;j<10000;j++){
               if(pow(i,5)-pow(j,5)==x){
                   cout<<i<<" "<<j<<endl;
                   return 0;
               }
      }
     
      
  }
}


Measured memory_bytes: 4168
#include <iostream>
#include <cstdio>
#include <queue>
#include <vector>
#include <stack>
#include <string>
#include <tuple>
#include <random>
#include <map>
#include <set>
#include <complex>
#include <algorithm>
#include <cassert>
#include <iterator>
#include <numeric>
#include <cmath>
#include <stdio.h>
#include <functional>

//#include<bits/stdc++.h>
#define vll vector<ll>
#define vi vector<int>
#define vpll vector<pair<ll,ll>>
#define pii pair<int,int>
#define REP(i,a) for(int (i)=0; (i)<(a); (i)++)
#define RREP(i,a) for(int (i)=a-1; (i)>=(0); (i)--)
#define REP2(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
#define m0(x) memset(x,0,sizeof(x))
typedef long long ll;
using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); 
    int N,M;
    cin >> N >> M;
    cout << N*(N-1)/2 + M*(M-1)/2;




    return 0;
}

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

const int INF = 2e9;

int main(){
    int r,g,b,n;
    cin >> r >> g >> b >> n;
    int x,y,z;
    int ans = 0;
    x = n/r + 1;
    y = n/g + 1;
    rep(i,x){
        rep(j,y){
            int res = n - i * r - j * g;
            if(res >= 0 && res % b == 0) ans++; 
        }
    }
    cout << ans << endl;
}

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

int main()
{
  string str, func;
  int n;
  cin >> str >> n;

  for(int i=0;i<n;i++)
    {
      cin >> func;
      
      if(func=="print")
	{
	  int a, b;
	  cin >> a >> b;
	  cout << str.substr(a, b-a+1) << endl;
	}
      if(func=="replace")
	{
	  int a, b;
	  string p;
	  cin >> a >> b >> p;
	  str = str.replace(a, b-a+1, p);
	}
      if(func=="reverse")
	{
	  int a, b;
	  string p, q;
	  cin >> a >> b;
	  p = str.substr(a, b-a+1);
	  q = p.at(p.size()-1);
	  for(int i=1;i <= p.size()-1;i++)
	    q += p.at(p.size()-1-i);
	  str = str.replace(a, b-a+1, q);
	}
    }
}

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

int main(){
  int n, a, b;
  cin >> n >> a >> b;
  int total = 0;
  for(int i = a; i <= n; i++){
    int sum = 0, temp = i;
    while(temp > 0){
      sum += temp % 10;
      temp /= 10;
    }
    if(sum >= a && sum <= b){
      total += i;
    }
  }
  cout << total << endl;
  return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
int main() {
    int n,m;cin>>n>>m;
    vector<int> g[n];
    for (int i=0;i<m;i++) {
        int a,b;cin>>a>>b;a--,b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    queue<int> q;
    q.push(0);
    int vis[n]{1};
    int ans[n];
    while (q.size()) {
        int v=q.front();q.pop();
        for (int u:g[v])
            if (!vis[u]) {
                ans[u]=v+1;
                vis[u]=1;
                q.push(u);
            }
    }
    cout<<"Yes"<<endl;
    for (int i=1;i<n;i++)
        cout<<ans[i]<<endl;
    return 0;
}

Measured memory_bytes: 10744
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

void solve() {
  string s;
  cin >> s;
  int l;
  rep(i,s.size()) {
    if (s[i] == 'A') {
      l = i;
      break;
    }
  }
  int r;
  for (int i = s.size()-1; i >= 0; i--) {
    if (s[i] == 'Z') {
      r = i;
      break;
    }
  }
  cout << r - l + 1 << endl;
}

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

Measured memory_bytes: 3744
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define int long long
#define x first
#define y second
#define pb push_back
#define inf 10000000000000000
#define N 1000000007
#define speed ios_base::sync_with_stdio(0);cin.tie(0);
using namespace std;
template<class L,class R> ostream& operator<<(ostream& cout,pair<L, R> P)
{return cout<<'('<<P.x<<','<< P.y<<')';}
template<class T> ostream& operator<<(ostream& cout,vector<T> V)
{cout<<"[ ";for(auto v:V)cout<<v<<' ';return cout<<']';}

//edge cases when n=1 , m=1. wrong variable in loop. if<->while
signed main()
{
	speed
	//global var
	int n,x,y;
	cin>>n>>x>>y;
	--x;--y;
	vector<int> ans(n,0);

	for(int i=0;i<n;++i)
	{
		for(int j=i;j<n;++j)
		{
			int d1=j-i;
			int d2=abs(x-i)+abs(y-j)+1;
			ans[min(d1,d2)]++;
		}
	}
	for(int i=1;i<n;++i)
	{
		cout<<ans[i]<<"\n";
	}
}

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

int main(){
    int k, s, i, j, c = 0;
    cin >> k >> s;
    for(i=0; i<=k; i++){
        for(j=0; j<=k; j++){
            if(s-i-j >=0 && s-i-j <= k){
                c++;
            }
        }
    }
    cout << c;
    return 0;
}

Measured memory_bytes: 256
/*Function Template*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pint;
const int MAX = 510000;
const int MOD = 1000000007;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define Rep(i, n) for(ll i = 1; i < (n); i++)
#define ALL(a)  (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll fac[MAX], finv[MAX], inv[MAX];


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;
}
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }

}
ll Len(ll n) {
  ll s=0;
  while(n!=0) s++, n/=10;
  return s;
}


ll Sint(ll n) {
  ll m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(ll i=s-1;i>=0;i--) m+=n/((ll)pow(10,i))-(n/((ll)pow(10,i+1)))*10;
  return m;
}


ll Svec(vector<ll> v){
  ll n=0;
  for(ll i=0;i<v.size();i++) n+=v[i];
  return n;
}


ll GCD(ll a,ll b) {
  return b ? GCD(b,a%b) : a;
}


ll LCM(ll a,ll b){
  return a/GCD(a,b)*b;
}


ll Factorial(ll n){
  ll m=1;
  while(n>=1) m*=n,n--;
  return m;
}

void runlength(string s,vector<pair<char,ll>> &p){
  ll x=1;
  if(s.size()==1){
    p.push_back(pair<char,ll>(s[0],1));
  }
  for(ll i=0;i<s.size()-1;i++){
    if(s[i]==s[i+1]){
      x++;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[i],x));
      }
    }else{
      p.push_back(pair<char,ll>(s[i],x));
      x=1;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[s.size()-1],x));
      }
    }
  }
}




ll COM(ll n,ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

const int MAX_N=100010;
vector<bool> sieve_of_eratosthenes(){
  vector<bool> isPrime(MAX_N+1,true);
  for(int i=2;i<=MAX_N;i++){
    if(isPrime[i]){
      for(int j=2*i;j<=MAX_N;j+=i){
        isPrime[j]=false;
      }
    }
  }
  return isPrime;
}

vector<pint> prime_factorize(ll n){
  vector<pint> ans;
  for(ll p=2;p<=sqrt(n);p++){
    if(n%p!=0) continue;
    ll cnt=0;
    while(n%p==0){
      n/=p;
      cnt++;
    }
    ans.push_back(make_pair(p,cnt));
  }
  if(n!=1) ans.push_back(make_pair(n,1));
  return ans;
}

/*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/
int main() {
  IOS;
  ll a,b,c,k,ans=0;
  cin>>a>>b>>c>>k;
  if(k%2==0){
    ans=a-b;
    if(abs(ans)>1e18){
      cout<<"Unfair"<<endl;
    }else{
      cout<<ans<<endl;
    }
  }else{
    ans=b-a;
    if(abs(ans)>1e18){
      cout<<"Unfair"<<endl;
    }else{
      cout<<ans<<endl;
    }
  }
}

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

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    long long n, d;
    cin >> n >> d;
    int ans = 0;
    for (int i = 0; i < n; i++) {
        long long x, y;
        cin >> x >> y;
        if (x * x + y * y <= d * d) ans++;
    }
    cout << ans << '\n';
}

Measured memory_bytes: 3640
takaMonHP, takaMonAP, aokiMonHP, aokiMonAP = map(int, input().split())

while True:
    aokiMonHP = aokiMonHP - takaMonAP
    if aokiMonHP <= 0:
        print("Yes")
        break
    takaMonHP = takaMonHP - aokiMonAP
    if takaMonHP <= 0:
        print("No")
        break


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

int main() {
  int n;
  cin >> n;
  vector<int> l(n);
  for (int i = 0; i < n; i++) cin >> l[i];
  sort(l.begin(), l.end());

  long long ans = 0;
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      int x = lower_bound(l.begin(), l.end(), l[i] + l[j]) - l.begin();
      ans += x - j - 1;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3620
#include<stdio.h>
int main(){
    int a,b;
    scanf("%d %d",&a,&b);
    while(1){
        if(a>b){
            int t=b;
            b=a;
            a=t;
        }
        b=b%a;
        if(b==0) break;
    }
    printf("%d\n",a);
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<math.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

int main() {
	int a, b;
	cin >> a >> b;
	if (a > b) {
		cout << a - 1 << endl;
	}
	else {
		cout << a << endl;
	}
	return 0;
}


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

int main(){
  int n;
  cin >> n;
  int l[n],r[n];
  rep(i,n) cin >> l[i] >> r[i];
  
  int num=0;
  rep(i,n) num += r[i]-l[i]+1;
  
  cout << num << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(i,a,n) for(int i=a;i<n;i++)
#define ps(x) cout<<x<<" "
#define pn(x) cout<<x<<"\n"
#define sz(a) int((a).size())
#define pb push_back
typedef vector< int > vi;
typedef pair< int,int > pairs;

int main()
{
    int a,b,c,k;
    cin>>a>>b>>c>>k;
    ll sum=0;
    sum=sum+ min(a,k)*1; k=k-min(a,k); if(k<=0){pn(sum);return 0;}
    sum=sum+ min(b,k)*0; k=k-min(b,k); if(k<=0){pn(sum);return 0;}
    sum=sum+ min(c,k)*(-1);k=k-min(c,k); if(k<=0){pn(sum);return 0;}
    

}

Measured memory_bytes: 3636
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <functional>

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) 42
#endif

#define rep_(i, a_, b_, a, b, ...) for (int i = (a), i##_len = (b); i < i##_len; ++i)
#define rep(i, ...) rep_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define reprev_(i, a_, b_, a, b, ...) for (int i = (b-1), i##_min = (a); i >= i##_min; --i)
#define reprev(i, ...) reprev_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define all(x) (x).begin(), (x).end()
template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
// template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> P;
typedef long double ld;

int main (void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, k; cin >> n >> k;
    vector<bool> s(n);
    rep (i, k) {
        int d; cin >> d;
        rep (j, d) {
            int a; cin >> a; a--;
            s[a] = true;
        }
    }
    int ans = 0; rep (i, n) if (s[i] == false) ans++;
    cout << ans << "\n";
    return 0;
}

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

#define REPZ(i, z, n) for (decltype(n) i = (z); i <= (n); i++)
#define REP(i, n) for (decltype(n) i = 0; i <= (n); i++)
#define ALL(v) v.begin(), v.end()
#define SIZE(v) ((ll)(v).size())
#define MAX(v) (*max_element(ALL(v)))
#define MIN(v) (*min_element(ALL(v)))
#define INF 1000000000000  // 1E+12

// 略
#define PB push_back
#define F first
#define S second
#define MP make_pair
#define READ cin >>
#define PRINT cout <<
#define PYES cout << "Yes" << endl;
#define POK cout << "OK" << endl;
#define PNO cout << "No" << endl;
#define PNG cout << "NG" << endl;

using namespace std;

// デバッグ用
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}

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

#ifdef _DEBUG
#define debug(...) debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

// typedef
typedef long long ll;
typedef unsigned long long ul;
typedef long double ld;
typedef pair<ll, ll> pl;

// const
// 円周率
const ld pi = acos(-1);
// mod用
// 1E+9 +7
const ll mod = (int)1e+9 + 7;
// 1s間で可能なループ回数2E+8回
// int        最大値2147483647         〜2E+9
// long long  最大値9223372036854775807〜9E+18
// 総和accumulate
// 単純リストvector<type> push_back
// 連想配列map<key,value> insert,
// 集合set<type>
// pair キーとバリューを格納 firstとsecondでアクセス
// 小数点指定 cout << fixed << setprecision(15) << endl;
// to_string<->stoi
// stoll(longlong)
// stod(double)
// deep copy v1->v2 copy(v1.begin(), v1.end(), back_inserter(v2) );
// 大文字65-90(-32)
// 小文字97-122(+32)
//  priority_queue<pair<ll, ll>, vector<pair<ll, ll>>, greater<pair<ll, ll>>>
//  ba;
bool check(int bits, int p, vector<int> connect) {
  int sum = 0;
  for (int i : connect) {
    sum += (bool)(bits & (1 << i));
    // debug(i,bits,sum,p);
  }
  return (sum % 2 == p);
}
int main() {
  // faster
  // C言語流の入出力は使用できない
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  int n, m;
  cin >> n >> m;
  vector<vector<int>> connect(m, vector<int>(0));
  vector<int> p(m);
  rep(i, m) {
    int k;
    cin >> k;
    rep(j, k) {
      int temp;
      cin >> temp;
      temp--;
      connect[i].push_back(temp);
    }
  }
  rep(i, m) cin >> p[i];
  // rep(i,m) debug(p[i]);
  int res = 0;
  // int light;
  // cin >> light;
  // cout << check(3, p[light], connect[light]) << endl;
  for (int bits = 0; bits < (1 << n); bits++) {
    bool flag = true;
    rep(light, m) { flag &= check(bits, p[light], connect[light]); }
    res += flag;
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 256
n, k = map(int, input().split())
a = list(map(int, input().split()))
bitcount = []
k += 1
m = k
f = [sum(a)]
while(m > 0 or max(a) > 0):
    odd = sum(list(map(lambda x: x%2, a)))
    bitcount.append(odd)
    a = list(map(lambda x: x//2, a))
    m = m//2
for keta in range(len(bitcount)):
    if k & (2 ** keta) != 0:
        ans = 0
        for i in range(keta):
            ans += max(bitcount[i], n - bitcount[i]) * 2 ** i
        for i in range(keta + 1, len(bitcount)):
            if k & (2 ** i) == 0:
                ans += bitcount[i] * 2 ** i
            else:
                ans += (n - bitcount[i]) * 2 ** i
        ans += bitcount[keta] * 2 ** keta
        f.append(ans)
print(max(f))


Measured memory_bytes: 14620
import re
S = input()
flag = False
res = re.match(r'.*keyence$',S)
if res :
  flag = True
res = re.match(r'^k.*eyence$',S)
if res :
  flag = True
res = re.match(r'^ke.*yence$',S)
if res :
  flag = True
res = re.match(r'^key.*ence$',S)
if res :
  flag = True
res = re.match(r'^keye.*nce$',S)
if res :
  flag = True
res = re.match(r'^keyen.*ce$',S)
if res :
  flag = True
res = re.match(r'^keyenc.*e$',S)
if res :
  flag = True
res = re.match(r'^keyence.*',S)
if res :
  flag = True
if flag :
  print('YES')
else :
  print('NO')

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

void solve(int n){
    int ans=0;
    for(int i=1;i<n;i++){
        int sum = 0;
        for(int j=i;j<n;j++){
            sum += j;
            if(sum==n && j-i+1>=2 ){
                ans++;
                break;
            }
            if(sum>n){
                break;
            }
        }
    }
    cout << ans << endl;
}

int main(){
    int n;
    while(cin>>n){
        if(n==0) break;
        solve(n);
    }
}

Measured memory_bytes: 1160
require 'set'

class Hash
  def push(key, value)
    self[key] = [] if self[key] == nil
    self[key].push(value)
  end
end

class Array
  def lower_bound(value)
    left = -1;
    right = self.length;
    while left + 1 < right
      mid = left + (right - left) / 2;
      if self[mid] >= value
        right = mid
      else
        left = mid
      end
    end
    right
  end

  def unique
    res = [self.first]
    each_cons(2) do |a, b|
      if a != b
        res.push(b)
      end
    end
    res
  end
end

def get_ints
  gets.split.map(&:to_i)
end

def get_ints_minus_one
  get_ints.map { |x| x - 1 }
end

def get_int
  gets.chomp.to_i
end

N = get_int
A = get_ints

X = Array.new(N, 0)

sum = 0
N.times do |i|
  sum ^= A[i]
end

N.times do |i|
  X[i] = sum ^ A[i]
end

puts X.join(' ')



Measured memory_bytes: 37048
parseInt(x::SubString{String}) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
	n = parseInt.(split(readline()))
	x = Array{Int}(2, n[1])
	for i in 1:n[1]
		x[:,i] = readline() |> split |> x -> parseMap(x)
	end
	maxa = maximum(x[1,:])
	useb = Int[]
	for i in 1:n[1]
		if x[2,i] > maxa
			push!(useb, x[2,i])
		end
	end
	useb = sort(useb, rev=true)
	hp = n[2]
	count = 0
	for i in 1:length(useb)
		if hp > 0
			hp -= useb[i]
			count += 1
		end
	end
	if hp > 0
		if hp%maxa == 0
			count += div(hp, maxa)
		else
			count += div(hp, maxa)+1
		end
	end
	print(count)
end

main()

Measured memory_bytes: 160128
N = int(input())
xys = []
for i in range(N):
  x, y = map(int, input().split())
  xys.append((x, y))
Isx = sorted(range(N), key=lambda i: (xys[i][0], xys[i][1]))
Isy = sorted(range(N), key=lambda i: (xys[i][1], xys[i][0]))
#print(Isx)
#print(Isy)
M = set()
for i in range(1, N):
  p, q = Isx[i-1], Isx[i]
  a, b = xys[p]
  c, d = xys[q]
  cost = min(abs(a-c), abs(b-d))
  M.add((cost, p, q))
for i in range(1, N):
  p, q = Isy[i-1], Isy[i]
  a, b = xys[p]
  c, d = xys[q]
  cost = min(abs(a-c), abs(b-d))
  M.add((cost, p, q))
#print(M)
S = list(M)
S.sort(reverse=True)
#print(S)
r = 0
UF = list(range(N))
def par(m):
  if UF[m] == m:
    return m
  ret = par(UF[m])
  UF[m] = ret
  return ret
while S:
  cost, p, q = S.pop()
  i = par(p)
  j = par(q)
  if i != j:
    r += cost
    UF[i] = j
  #print(UF)
print(r)


Measured memory_bytes: 63400
#include<stdio.h>
#include<stdlib.h>
int main(){
    char s[100];
    int x[100],i=0;
    while(scanf("%s",s)!=EOF){
        if(s[0]=='+'){
            x[i-2]=x[i-2]+x[i-1];
            i--;
        }
        else if(s[0]=='-'){
            x[i-2]=x[i-2]-x[i-1];
            i--;
        }
        else if(s[0]=='*'){
            x[i-2]=x[i-2]*x[i-1];
            i--;
        }
        else{
        x[i]=atoi(s);
        i++;
        }
    }
    printf("%d\n",x[i-1]);
  return 0;
}


Measured memory_bytes: 2760
#include <stdio.h>

using namespace std;

int main(){
	int n;
	scanf("%d",&n);
	int A[n];

	for(int i = 0; i < n; i++) scanf("%d",&A[i]);

	for(int i = n-1; i > 0; i--) printf("%d ",A[i]);
	printf("%d\n",A[0]);
}


Measured memory_bytes: 2724
package main

import "fmt"

func main() {
	var n, k int
	fmt.Scan(&n, &k)

	r := 0.0
	for i := 1; i <= n; i++ {
		p := 1.0 / float64(n)
		for j := i; j < k; j *= 2 {
			p /= 2.0
		}
		r += p
	}
	fmt.Println(r)
}


Measured memory_bytes: 512
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
int size;
int k;
int hieght[100005];
long long int dp[100005];

long long int calc(int i)
{
	if(dp[i]!=-1)
		return dp[i];
	if(i==0)
		return 0;
	if(i==1)
	{
		dp[1] = (long long int)fabs(hieght[0]-hieght[1]);
		return dp[i];
	}
	dp[i] = 1e9 + 7;
	long long int substitute = i-k;
	if(substitute<0)
		substitute = 0;
	for(long long int j=substitute;j<i;j++)
	{
		if(j>=0)
			dp[i] = (long long int) fmin((calc(j) + (long long int)fabs(hieght[i]-hieght[j])),dp[i]);
	}
//	printf("i is %d dp[i] is %lld\n",i,dp[i]);
	return dp[i];
}

int main() 
{
	scanf("%d%d",&size,&k);
	for(int i=0;i<100005;i++)
	{
		dp[i] = -1;
	}
	for(int i=0;i<size;i++)
	{
		scanf("%d",&hieght[i]);
	}
	long long int ans = calc(size-1);
	printf("%lld\n",ans);
	return 0;
}



Measured memory_bytes: 4480
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <map>

using namespace std;

typedef long long ll;


class TaskD
{
public:
	ll A, B, N;

	ll calc(ll x, ll a, ll b)
	{
		return ((a*x)/b) - (a * (x/b));
	}

	void process()
	{
		cin >>  A >> B >> N;
		if(B>N)
			cout << calc(N, A, B) << "\n";
		else
			cout << calc(B-1, A, B) << "\n";
	}
};


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

	TaskD solver;
	solver.process();

	return 0;
}



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

int main()
{
  int n, k; cin >> n >> k;
  vector<long long int> h(n);
  for(int i = 0; i < n; ++i) cin >> h[i];
  
  if(k >= n) cout << 0;
  else
  {
    sort(h.begin(), h.end());
    int rem = n - k;
    cout << accumulate(h.begin(), h.begin()+rem, 0LL);
  }
  return 0;
}


Measured memory_bytes: 4844
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << endl
#define COUTF(x) cout << setprecision(15) << (x) << endl
#define ENDL cout << endl
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define REVERSE(x) reverse(ALL(x))
#ifdef _DEBUG
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
#else
#define debug(x)
#endif
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
constexpr int INF = 0x3f3f3f3f;
constexpr ll INFL = 0x3f3f3f3f3f3f3f3f;
constexpr double PI = 3.141592653589793238462643383279;

signed main() {
  ll N, K;
  cin >> N >> K;
  ll R, S, P;
  cin >> R >> S >> P;

  char T[N];
  ll ans = 0;
  rep(i, N) {
    debug(i);
    char t;
    cin >> t;
    debug(t);
    T[i] = t;
    debug(i - K);
    debug(T[i - K]);

    if (0 <= i - K && t == T[i - K]) {
      debug("same");
      T[i] = 'A';
      continue;
    }

    switch (t) {
      case 'r':
        ans += P;
        break;
      case 's':
        ans += R;
        break;
      case 'p':
        ans += S;
        break;
    }

    debug(ans);
  }
  COUT(ans);
  return 0;
}

Measured memory_bytes: 384
using System;

namespace ABC069
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            char[] cs = s.ToCharArray();
            int len = cs.Length;
            Console.WriteLine("{0}{1}{2}",cs[0],len-2,cs[len-1]);
        }
    }
}


Measured memory_bytes: 13140
from math import ceil,floor
ansc,ansf = 0,0
n = int(input())
a = list(map(int,input().split()))
 
gp = sum(a)/len(a)
c = ceil(gp)
f = floor(gp)

for i in a:
  ansc += (i-c)**2
  ansf += (i-f)**2
  
print(min(ansc,ansf))

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		int[] town = new int[N+1];
		int[] hero = new int[N];
		int diff =0;
		for(int i =0;i<N+1;i++) {
			town[i] = scan.nextInt();
		}

		long count = 0;
		for(int i =0;i<N;i++) {
			hero[i] = scan.nextInt();
			if (town[i]<hero[i]) {
				count += town[i];
				hero[i] -= town[i];
				town[i] = 0;

				if(town[i+1]<hero[i]) {
					count += town[i+1];
					hero[i] -= town[i+1];
					town[i+1] = 0;
				} else {
					count += hero[i];
					town[i+1] -= hero[i];
					hero[i]=0;
				}
			} else {
				count += hero[i];
				town[i] -= hero[i];
				hero[i]=0;
			}
		}
		System.out.println(count);
		scan.close();
	}

}



Measured memory_bytes: 65044
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>

using namespace std;




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

	long long n, k, i, j, x, ct, ans;
	cin >> n >> k;
	vector<long long> a(n + 1), last(n + 1, -1);
	for (i = 1; i <= n; i++) cin >> a[i];
	x = 1;
	last[1] = 0;

	for (i = 1; i <= k; i++) {
		x = a[x];
		if (last[x] == -1) {
			last[x] = i;
			if (i == k) ans = x;
		}
		else {
			ct = i - last[x];
			k -= i;
			k %= ct;
			for (i = 0; i < k; i++) x = a[x];
			ans = x;
			break;
		}
	}

	cout << ans << "\n";


	return 0;
}


Measured memory_bytes: 6052
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <string>
#include <iomanip>

#define ll long long

using namespace std;

const ll mod = 1e9+7;

int main()
{
    int N;

    cin >> N;

    vector <ll int> A(N+3), B(N+3, 0);

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


    ll ans = 0;



    for(int i = N - 2; i > 0; i--) {
       B[i] = (B[i] + B[i+1])%mod;;
    }

    for(int i = 1; i < N; i++) {
        ans = (ans + (B[i]*A[i-1]) % mod)%mod;
    }

    cout << ans;


    return 0;
}

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

using namespace std;
using ll = long long;
using ld = long double;

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

#define READ(x) (cin >> (x))
#define WRITE_N(x) (cout << (x) << endl)
#define WRITE(x) (cout << (x))
#define WRITE_YESNO(x) (WRITE_N((x) ? "Yes" : "No"))

#define PRECISE_COUT std::cout << std::setprecision(15) << std::fixed

bool xor_logic(bool x, bool y) { return (x && y) || (!x && !y); }

using coord = pair<ll, ll>;

template <typename T1, typename T2>
bool pair_second_lt(const pair<T1, T2> &p1, const pair<T1, T2> &p2) {
  return p1.second > p2.second;
}

ll solve(vector<ll> &h, vector<ll> &w) {
  set<coord> c;
  unordered_map<ll, ll> h_map, w_map;
  for (size_t i = 0; i < h.size(); i++) {
    c.emplace(coord{h[i], w[i]});

    h_map[h[i]]++;
    w_map[w[i]]++;
  }

  unordered_set<ll> h_max_keys, w_max_keys;
  ll h_max = 0, w_max = 0;
  for (auto &&p : h_map) {
    if (p.second > h_max) {
      h_max = p.second;
      h_max_keys = {p.first};
    } else if (p.second == h_max) {
      h_max_keys.emplace(p.first);
    }
  }
  for (auto &&p : w_map) {
    if (p.second > w_max) {
      w_max = p.second;
      w_max_keys = {p.first};
    } else if (p.second == w_max) {
      w_max_keys.emplace(p.first);
    }
  }

  bool is_all_coord_has_target = true;
  for (auto &&h_k : h_max_keys) {
    for (auto &&w_k : w_max_keys) {
      if (c.count(coord{h_k, w_k}) == 0) {
        is_all_coord_has_target = false;
        break;
      }
    }
  }

  return h_max + w_max - (is_all_coord_has_target ? 1 : 0);
}

int main() {
  // get values from input
  cin.tie(0);
  ios::sync_with_stdio(false);

  ll H, W, M;
  cin >> H >> W >> M;

  std::vector<ll> h(M, 0), w(M, 0);
  for (size_t i = 0; i < M; i++) {
    cin >> h[i] >> w[i];
  }

  // main procedure
  ll ans = solve(h, w);

  // output
  cout << ans << endl;

  return 0;
}

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

int main(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  int x=max(a,c);
  int y=min(b,d);
  //cout<<x<<" "<<y<<endl;
  int ans=y-x;
  if(ans<0)ans=0;
  cout<<ans<<endl;


  return 0;
}


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

int main() {
	int n;
	cin >> n;
	vector<P> ab(n);
	rep(i, n) {
		int a, b;
		cin >> a >> b;
		ab[i] = make_pair(b, a);
	}
	sort(ab.begin(), ab.end());

	int time = 0;
	rep(i, n) {
		time += ab[i].second;
		if (time > ab[i].first) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &vec){ os << "["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const deque<T> &vec){ os << "deq["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa){ os << "(" << pa.first << "," << pa.second << ")"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const unordered_map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename T> void ndarray(vector<T> &vec, int len) { vec.resize(len); }
template<typename T, typename... Args> void ndarray(vector<T> &vec, int len, Args... args) { vec.resize(len); for (auto &v : vec) ndarray(v, args...); }
template<typename T> bool mmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool mmin(T &m, const T q) { if (m > q) {m = q; return true;} else return false; }
template<typename T1, typename T2> pair<T1, T2> operator+(const pair<T1, T2> &l, const pair<T1, T2> &r) { return make_pair(l.first + r.first, l.second + r.second); }
template<typename T1, typename T2> pair<T1, T2> operator-(const pair<T1, T2> &l, const pair<T1, T2> &r) { return make_pair(l.first - r.first, l.second - r.second); }
#define dbg(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ") " << __FILE__ << endl;

 
int main(){
  string s;
  int n;
  int ans=0;
  cin>>n>>s;
  for(int i=0;i<n-2;i++){
    if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C'){
      ans++;
    }
  }
  cout<<ans;
}


Measured memory_bytes: 256
def foo
  i = gets.to_i
  i.times do
    left = []
    right = []
    list = gets.split.map(&:to_i)
    list.each do |j|
      if left.empty? || j > left.last
        left << j
      elsif right.empty? || j > right.last
        right << j
      end
    end

    res = list.length == (right.length + left.length) ? 'YES' : 'NO'
    puts res
  end
end

foo

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

using namespace std;

vector<int> v;
long long ar[200010];

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

    int n, a;
    cin >> n;
    long long sum = 0, ans = 1e15;

    for(int i = 0; i < n; i++) {
        cin >> a;
        ar[i] = a + ar[i - 1];
        sum += a;
    }


    for(int i = 0; i < n - 1; i++) {
        ans = min(ans, abs(1ll * (sum - 2 * ar[i])));
    }

    cout << ans;

	return 0;
}


Measured memory_bytes: 1792
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include <math.h>
#include <limits.h>

int n,m,r,ans=1e9,tmp,count;
int d[10],a[20000],b[20000],c[20000],cost[300][300];
bool visited[10];

int dfs(int a,int b){
    visited[b]=true;
    count++;
    tmp+=cost[d[a]][d[b]];
    if (count>=r-1){
        if(tmp<ans){
            ans=tmp;
        }
    } else {
        for (int i=0; i<r; i++){
            if (visited[i]==false){
                dfs(b,i);
                visited[i]=false;
            }
        }
    }
    count--;
    tmp-=cost[d[a]][d[b]];
    return 0 ;
}

int main(void){
    scanf("%d%d%d",&n,&m,&r);
    for (int i=0; i<r; i++){
        scanf("%d",&d[i]);
        d[i]--;
    }
    for (int i=0; i<=n; i++){
        for (int j=0; j<=n; j++){
            cost[i][j]=1e9;
        }
    }
    for (int i=0; i<m; i++){
        scanf("%d%d%d",&a[i],&b[i],&c[i]);
        cost[a[i]-1][b[i]-1]=c[i];
        cost[b[i]-1][a[i]-1]=c[i];
    }
    for (int k=0; k<=n; k++){
        for (int i=0; i<=n; i++){
            for (int j=0; j<=n; j++){
                if (cost[i][j]>cost[i][k]+cost[k][j]){
                    cost[i][j]=cost[i][k]+cost[k][j];
                }
            }
        }
    }
    for (int i=0; i<r; i++){
        for (int j=0; j<r; j++){
            if (i!=j){
                visited[i]=true;
                dfs(i,j);
                visited[j]=false;
                visited[i]=false;
            }
        }
    }
    printf("%d\n",ans);
	return 0 ;
}

Measured memory_bytes: 640
#include <algorithm>
#include <cmath>
#include <iostream>
#include <vector>
#include <map>

const std::string judge[4] = {"AC", "WA", "TLE", "RE"};

int main() {
  uint32_t N = 0;
  std::cin >> N;
  std::map<std::string, uint32_t> result;
  for (size_t i = 0; i < N; i++)
  {
    std::string str;
    std::cin >> str;
    result[str]++;
  }
  
  for (auto &&r : judge)
  {
    std::cout << r << " x " << result[r] << std::endl;
  }
  return 0;
}

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

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

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

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

#define FF first
#define SS second

#define DUMP(x) cout<<#x<<":"<<(x)<<endl
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class T>
istream& operator>>(istream& is, vector<T>& xs){
  for(auto& x: xs)
	is >> x;
  return is;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
ostream& operator<<(ostream& os, const vector<T>& xs){
  for(unsigned int i=0;i<xs.size();++i)
	os << (i?" ":"") << xs[i];
  return os;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;
const LL INIT = 999999999999998ll + 2;
const LL INF = 1e18;

struct Edge{
  int to;
  LL cost;

  Edge(int t, LL c = 0): to(t), cost(c)
  {}
  bool operator>(const Edge& rhs) const{
	return cost > rhs.cost;
  }
  bool operator<(const Edge& rhs) const{
	return cost < rhs.cost;
  }

};
using Graph = vector<vector<Edge>>;

void add_edge(Graph& graph, int u, int v, LL cost = 0){
  graph[u].push_back(Edge(v,cost));
  graph[v].push_back(Edge(u,cost));
}
void Dijkstra(const Graph& G, vector<LL>& d, int s){
  using Type = pair<LL,int>;
  priority_queue<Type, vector<Type>, greater<Type> > pq;
  fill(d.begin(), d.end(), INF);
  d[s] = 0;
  pq.push(MP(0,s));

  while(!pq.empty()){
	Type pii = pq.top();
	pq.pop();
	int v = pii.second;
	if(d[v] < pii.first) continue;
	for(const auto& e: G[v]){
	  if(d[e.to] > d[v] + e.cost){
		d[e.to] = d[v] + e.cost;
		pq.push(MP(d[e.to], e.to));
	  }
	}
  }
}


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

  int N, M, S, T;
  cin >> N >> M >> S >> T;
  --S;
  --T;

  Graph GY(N), GS(N);
  REP(i,M){
	LL u, v, s, t;
	cin >> u >> v >> s >> t;
	--u;
	--v;
	add_edge(GY, u, v, s);
	add_edge(GS, u, v, t);
  }

  VL cy(N), cs(N);
  Dijkstra(GY, cy, S);
  Dijkstra(GS, cs, T);

  VL cost(N);
  REP(i,N) cost[i] = cy[i] + cs[i];
  for(int i=N-2;i>=0;--i) mini(cost[i], cost[i+1]);

  for(auto& x: cost) cout << INIT - x << endl;

  return 0;
}


Measured memory_bytes: 20912
#include <bits/stdc++.h>
using namespace std;
const int mod =1e9+7;

int main() {
	// your code goes here
	
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int n,i,j,k;
	cin>>n;
	double p;
	vector<double>dp(n+1);
	dp[0]=1;
	for(i=0;i<n;i++)
	{
	    cin>>p;
	    
	    for(j=i+1;j>=0;j--)
	    {
	        dp[j]= (p==0?0:(dp[j-1]*p)) + dp[j]*(1-p);
	    }
	    
	}
	p=0;
	for(i=0;i<=n;i++)
	{
	    if(i>(n-i))
	    p+=dp[i];
	}
	cout<<setprecision(100)<<p;
	
	
	return 0;
}


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

int main(){
    int n,l;
    cin >> n >> l;
    vector<int> s(n);
    int sum = 0;
    int s_min = 200;
    rep(i,n){
        s[i] = l + i;
        sum += s[i];
    }
  	int ans = 10000;
  	rep(i,n){
      	int t = sum - s[i];
      	if(abs(t-sum) < abs(ans-sum)) ans = t;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
/* 
*/
// #pragma GCC optimize("Ofast")
// #pragma GCC target("avx,avx2,fma")
#include <iostream>
#include <iomanip>
#include <sstream>
#include <fstream>
#include <string>
#include <cstring>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <stack>
#include <deque>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <utility>
#include <bitset>
 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
 
#define LSOne(S) (S & (-S))
#define EPS 1e-9
 
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pd;
typedef tree<pi, null_type, less<pi>, rb_tree_tag, tree_order_statistics_node_update> ordered_multiset;

int main()
{
    std::ios::sync_with_stdio(false);
    cin.tie(0); // BEFORE SUBMIT DON'T FORGET TO UNCOMMENT THIS
    int n, limit;
    cin >> n >> limit;
    vector<int> w(n+5), val(n+5);
    int sumV = 0;
    for(int i = 0; i < n; ++i)
    {
        cin >> w[i] >> val[i];
        sumV += val[i];
    }

    vector<ll> dp(sumV+1, 1e15);
    dp[0] = 0;
    for(int i = 0; i < n; ++i)
    {
        for(int j = sumV; j >= 0; --j)
        {
            dp[j] = min(dp[j], dp[max(0, j-val[i])] + w[i]);
        }
    }
    
    for(int i = sumV; i >= 0; --i)
    {
        if(dp[i] <= limit)
        {
            cout << i << "\n";
            break;
        }
    }
    return 0; 
}


Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<math.h>
#define cinf(n,x) for(int i=0;i<(n);i++) cin >> x[i];
typedef long long int ll;
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
using namespace std;

int main(){
	double x1,y1,x2,y2,xp,yp,disx,disy,ansx,ansy;
	int q;
	bool X_FLG =false , Y_FLG =false;
	cin >>x1>>y1>>x2>>y2; cin >>q;
	if(y1==y2){
		X_FLG=true;
	}
	else if(x1==x2){
		Y_FLG=true;
	}
	else{
		disy=(y2-y1);
		disx=(x2-x1);
	}
	for(int i=0;i<q;i++){
		cin >>xp>>yp;
		if(X_FLG){
			printf("%.10lf %.10lf\n",xp,y1);
		}
		else if(Y_FLG){
			printf("%.10lf %.10lf\n",x1,yp);
		}
		else{
			ansx= (disx*disx*xp+disx*disy*yp+disy*disy*x2-disx*disy*y2)/(disy*disy+disx*disx);
			ansy=disy*(ansx-x2)/disx+y2;
			printf("%.10lf %.10lf\n",ansx,ansy );
		}
	}
}


Measured memory_bytes: 3264
/**
*    created: 16.05.2020 08:02:14
**/

#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
const int inf =1000000000;

int main() {
    string c1, c2;
    cin >> c1 >> c2;
    reverse(c1.begin(), c1.end());
    if(c1==c2) cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  int64_t n;
  cin >> n;
  vector<int64_t> vec(n),ans(100000);
  rep(i,n){
    cin >> vec.at(i);
  }
  int64_t answer=0;
  for(int64_t x: vec){
    if(x>100000){
      answer++;
      continue;
    }
    ans.at(x-1)++;
  }
  rep(i,100000){
    if(ans.at(i)>=i+1){
      answer+=ans.at(i)-i-1;
    }else{
      answer+=ans.at(i);
    }
  }
  cout << answer;
}
   

Measured memory_bytes: 1792
#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[i];
        sum += a[i];
    }

    int ave_1, ave_2;
    ave_1 = sum / N;
    ave_2 = sum / N + 1;
    
    int ans_1 = 0;
    int ans_2 = 0;

    for (int i = 0; i < N; i++){
        ans_1 += (a[i] - ave_1) * (a[i] - ave_1);
        ans_2 += (a[i] - ave_2) * (a[i] - ave_2);
    }

    cout << min(ans_1, ans_2) << endl;
}

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

int a,b;

int main() {
	scanf("%d%d",&a,&b);
	printf("%d\n",(a+b-3)/(a-1));
	return 0;
}

/*
高桥君的家里只有一个电源插头的插口。因此，高桥君考虑使用几个A个口的电源插口，将未使用的插口扩展到B口以上。
使用1个A个口的电源插口和1个未使用的插口，可以再增加A个口。最少需要几个电源开关?
*/

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

using namespace std;
struct aaa{aaa(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(20);};}aaa;

typedef long long int64;


int main() {
    int64 a,b,k;
    cin >> a >> b >> k;
    cout << max(0LL, a - k) << " ";
    cout << max(0LL, b - max(0LL, k-a)) << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>

using namespace std;
int main()
{
	int n, i, max, min;
	cin>>n;
	int ar[n];

   for(i = 0; i < n; i++)
   {
   	cin>>ar[i];
   }
   sort(ar, ar+n);
  
   max = ar[n-1];
   min = ar[0];
   cout<<(max-min)<<endl;
}

Measured memory_bytes: 256