akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>
typedef long long ll;
const ll N = 210;
const ll INF = 1e15;
using namespace std;
ll d[N][N];
ll ret = INF,r[8],n,m,R;
bool used[N];

void dfs(ll dist,ll last,ll cnt){
  ll i,j,k;
  if(cnt==R){
    ret = min(dist,ret);
    return;
  }
  for(i=0;i<R;i++){
    if(!used[i]){
      used[i]=true;
      if(last==-1)dfs(dist,r[i],cnt+1);
      else dfs(dist+d[last][r[i]],r[i],cnt+1);
      used[i]=false;
    }
  }
  return;
}

int main(){
  ll i,j,k,a,b,c;
  cin >> n >> m >> R;
  for(i=0;i<N;i++){
    for(j=0;j<N;j++)d[i][j]=INF;
    d[i][i]=0LL;
  }
  for(i=0;i<R;i++){
    cin >> a;
    r[i]=a-1;
  }
  for(i=0;i<m;i++){
    cin >> a >> b >> c;
    d[a-1][b-1]=c;
    d[b-1][a-1]=c;
  }
  for(k=0;k<n;k++){
    for(i=0;i<n;i++){
      for(j=0;j<n;j++){
        if(d[i][k]!=INF && d[k][j]!=INF){
          d[i][j] = min(d[i][j],d[i][k]+d[k][j]);
        }
      }
    }
  }
  dfs(0,-1,0);
  cout << ret << endl;
  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, n) for(int i = 0; i < (n); i++)
#define MEM(a, x) memset(a, x, sizeof(a))
#define ALL(a) a.begin(), a.end()
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())
typedef long long ll;

int w, h, n;

int main(int argc, char const *argv[]) {
	ios_base::sync_with_stdio(false);
	cin >> w >> h >> n;
	int r = w, l = 0, t = h, b = 0;
	FOR(i, n) {
		int x, y, a;
		cin >> x >> y >> a;
		if (a == 1) l = max(l, x);
		else if (a == 2) r = min(r, x);
		else if (a == 3) b = max(b, y);
		else t = min(t, y);
	}
	if (r <= l || t <= b) cout << 0 << endl;
	else cout << (r-l)*(t-b) << endl;
	return 0;
}

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

using namespace std;

int main(){
	queue<double> step;
	string in;
	int n;
	while(cin >> n,n){
		int count = 0;
		for(int i=0;i<n;i++){
			double tmp;
			cin >> in;
			if(in == "lu" || in == "ru")	tmp = 1;
			else if(in == "ld" || in == "rd")	tmp = -1;
			step.push(tmp);
		}
		int sum = 2;
		int target = 4;
		while(!step.empty()){
			sum += step.front();
			step.pop();
			if(sum == target){
				count++;
				target = 6 - min(target,4);
			}
		}
		cout << count << endl;
	}
	return 0;
}

Measured memory_bytes: 3200
// R x + G y + B z = N

#include <iostream>

using namespace std;

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

  int R, G, B, N;
  cin >> R >> G >> B >> N;
  int ans = 0;
  for (int x = 0; x <= N; x++) {
    for (int y = 0; y <= N; y++) {
      int tmp = N - R * x - G * y;
      if (tmp >= 0 && tmp % B == 0)
        ++ans;
    }
  }
  cout << ans << endl;
  
  return 0;
}


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


int main(void) {

    const int N = 3;

    int data[N];
    for (int i = 0; i < N; i++) {
        std::cin >> data[i];
    }

    std::sort(data, data + N);

    for (int i=1;i<N;i++) {
        if (data[i-1] != data[i]) {
            if (i == 1) {
                std::cout << data[i-1] << std::endl;
            }
            else {
                std::cout << data[i] << std::endl;
            }
        }
    }

    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int A,B;
  cin >> A >> B;
  int C;
  int i;
  int t_th,th,hu,te,o;
  int count=0;
  C=B-A+1;
  for(i=0; i<C; i++){
    t_th=A/10000;
    th=(A%10000)/1000;
    hu=((A%10000)%1000)/100;
    te=(((A%10000)%1000)%100)/10;
    o=(((A%10000)%1000)%100)%10;
    if(t_th==o && th==te)
      count++;
    A+=1;
  }
  cout << count << endl;
}
    

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
int A, B, C, D;
  cin >> A >> B >> C >> D;
  
  if(min(B,D) - max(A,C) > 0) cout << min(B,D) - max(A,C) << endl;
  else cout << 0 << endl;
  
  return 0;
  
}

Measured memory_bytes: 256
import java.io.*
import java.util.*
import kotlin.math.*

fun main(){
	val f = BufferedReader(InputStreamReader(System.`in`))

	val n = f.readLine().toInt()
	val array = f.readLine().toCharArray()

	var totalr = 0
	for(k in 0 until n) if(array[k] == 'R') totalr++

	var rafter = totalr
	var wbefore = 0
	var min = n+5
	for(k in 0 until n+1){
		min = min(min,max(rafter,wbefore))
		if(k < n){
			if(array[k] == 'W') wbefore++
			else rafter--
		}
	}

	println(min)
}


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


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

using namespace std;

int main() {

  string str;
  char ch1 = '0', ch2 = '0';
  int ans1 = 0, ans2 = 0;
  cin >> str;
  for(int i = 0;i < str.size();i++){
    if(ch1 == '0'){
      ch1 = str[i];
    }else if(str[i] != ch1 && ch1 != '0'){
      ch2 = str[i];
    }
  }
  for(int i = 0;i < str.size();i++){
    if(ch1 == str[i]){
      ans1++;;
    }else if(ch2 == str[i]){
      ans2++;
    }
  }
  if(ans1 == ans2 && ans1 + ans2 == str.size()){
    cout << "Yes";
  }else{
    cout << "No";
  }
}


Measured memory_bytes: 256
#define  _CRT_SECURE_NO_WARNINGS
#pragma comment (linker, "/STACK:526000000")

#include "bits/stdc++.h"

using namespace std;
typedef string::const_iterator State;
#define eps 1e-11L
#define MAX_MOD 1000000007LL
#define GYAKU 500000004LL

#define MOD 998244353LL
#define seg_size 262144*2LL
#define pb push_back
#define mp make_pair
typedef long long ll;
#define REP(a,b) for(long long (a) = 0;(a) < (b);++(a))
#define ALL(x) (x).begin(),(x).end()

unsigned long xor128() {
	static unsigned long x = 123456789, y = 362436069, z = 521288629, w = time(NULL);
	unsigned long t = (x ^ (x << 11));
	x = y; y = z; z = w;
	return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}

void init() {
	iostream::sync_with_stdio(false);
	cout << fixed << setprecision(20);
}

#define int ll

void solve() {
	int n, k, t, u, v, l;
	cin >> n >> k >> t >> u >> v >> l;
	vector<int> inputs;
	REP(i, n) {
		int a;
		cin >> a;
		inputs.push_back(a);
	}
	inputs.push_back(0);
	inputs.push_back(l);
	sort(ALL(inputs));
	long double ans = 0;
	int stock = 0;
	long double now_time = 0;
	for (int i = 1; i < inputs.size();++i) {
		long double distance = inputs[i] - inputs[i - 1];
		while (distance > 0.00000000L + eps) {
			if (now_time > eps) {
				if (distance > now_time* (long double)v) {
					distance -= now_time * (long double)v;
					ans += now_time;
					now_time = 0;
					continue;
				}
				else {
					long double used = distance / (long double)v;
					now_time -= used;
					ans += used;
					break;
				}
			}
			else {
				if (stock > 0) {
					stock--;
					now_time = t;
					continue;
				}
				ans += distance / (long double)u;
				break;
			}
		}
		stock++;
		if (stock - 1 == k) {
			now_time = t;
			stock = min(stock, k);
		}
	}
	cout << ans << endl;
}

#undef int
int main() {
	init();
	solve();
}


Measured memory_bytes: 3312
#include <bits/stdc++.h>
#define ALL(obj) begin(obj), end(obj)
#define debug(x) cerr << #x << ": " << x << '\n'
using namespace std;
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}

using ll = long long;
using ull = unsigned long long;
const int INF = 1e9;
// const int MOD = 1e9 + 7;
int main() {
    string S;
    cin >> S;
    int N = S.size();
    string k = "keyence";
    int l = 0, r = 0;
    for (int i = 0; i < 7; i++) {
        if (S[i] == k[i]) {
            l++;
        } else {
            break;
        }
    }
    for (int i = 0; i < 7; i++) {
        if (S[N - 1 - i] == k[7 - 1 - i]) {
            r++;
        } else {
            break;
        }
    }
    if (l + r >= 7) {
        cout << "YES\n";
    } else {
        cout << "NO\n";
    }
}


Measured memory_bytes: 3588
# -*- coding: utf-8 -*-
n = int(input())
xy = [list(map(int, input().split())) for _ in range(n)]

if n==1:
    print(1)
    exit()

def cost(p,q):
    e = 0
    for i in range(n):
        for j in range(n):
            v = xy[i]
            u = xy[j]
            if p==u[0]-v[0] and q==u[1]-v[1]:
                e += 1
                break
    return n-e

d = {}
for i in range(n):
    for j in range(n):
        if i==j:
            continue
        v = xy[i]
        u = xy[j]
        p = v[0]-u[0]
        q = v[1]-u[1]
        if (p,q) not in d:
            d[(p,q,)] = 0
        d[(p,q)] += 1

c = 0
for k in d:
    if d[k]>c:
        c = d[k]
        p,q = k

print(cost(p,q))

Measured memory_bytes: 3444
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <stack> 
#include <map>
#include <queue>
#include <unordered_map>
#include <cassert>
#include <iomanip>
#include <cmath>
#include <cstring>
using namespace std;

#define pb 					push_back

template<typename T,typename S>
ostream& operator <<(ostream& os, pair<T, S> input) {
	os<<"("<<input.first<<", "<<input.second<<")";
	return os;
}

template<typename T>
ostream& operator <<(ostream& os, vector<T> input) {
	for(auto t: input)
		os << t <<" ";

	return os;
}

int main() {
    //ios_base::sync_with_stdio(false);
	//cin.tie(0);
	//cout.tie(0);
	int n;
	cin >> n;
	string s;
	cin >> s;

	for(char & c: s){
		int ic = c-'A';
		int nc = (ic + n)%26;
		c = 'A' + nc;

;	}
	cout << s<<"\n";


	return 0;
}



Measured memory_bytes: 256
import std.stdio, std.conv, std.string, std.array, std.range, std.algorithm, std.container;
import std.math, std.random, std.bigint, std.datetime, std.format;
void main(string[] args){ if(args.length > 1) if(args[1] == "-debug") DEBUG = 1; solve(); }
void log()(){ writeln(""); } void log(T, A ...)(T t, lazy A a){ if(DEBUG) write(t, " "), log(a); } bool DEBUG = 0; 
string read(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
// ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- //

void solve(){
	int n = read.to!int;
	
	real[] vs;
	foreach(i; 0 .. n) vs ~= read.to!real;
	
	vs.sort();
	
	real ans = vs[0];
	foreach(i; 1 .. n) ans = (ans + vs[i]) / 2.0;
	
	writefln("%10.10f", ans);
}


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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)
#define rrep(i, n) for(int i = ((int)n - 1); i >= 0; --i)

typedef long long ll;

const int Inf = 1e9;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> a(n);
    bool all = true;
    rep (i, n) {
        int a;
        cin >> a;
        if (a % 2) all = false;
    }
    if (all) cout << "second" << endl;
    else cout << "first" << endl;
    
    return 0;
}



Measured memory_bytes: 896
#include<iostream>
#include<math.h>
using namespace std;

int main(void){
    int x, y, xx, yy;
    cin >> x >> y;
    xx = abs(x);
    yy = abs(y);

    if(x==0 && y>0) cout << y-x << endl;
    else if(x==0 && y<0) cout << x-y+1 << endl;
    else if(x>0 && y==0) cout << x-y+1 << endl;
    else if(x<0 && y==0) cout << y-x << endl;
    else if(x>0 && y>0){
        if(x<y) cout << y-x << endl;
        else cout << x-y+2 << endl; 
    }
    else if(x<0 && y<0){
        if(x>y) cout << x-y+2 << endl;
        else cout << y-x << endl;
    }
    else{
        cout << abs(xx-yy)+1 << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int64_t i=0; i<(int64_t)(n); i++)
#define all(v) v.begin(), v.end()
//c
int main(){

    int n, k;cin >> n >> k;
    vector<vector<int>> a(51, vector<int>(n));
    rep(i, n) cin >> a[0][i];

    rep(i, k){

        vector<int> memo(n+1);

        rep(j, n){
            int min, max;
            min=j-a[i][j];
            max=j+1+a[i][j];
            if(min<0) min=0;
            if(max>n) max=n;
            memo[min]++;
            memo[max]--;
        }

        int cnt=0;

        rep(j, n){
            cnt+=memo[j];
            a[i+1][j]=cnt;
        }

        bool fin=true;

        rep(j, n){
            if(a[i][j]!=a[i+1][j]) fin=false;
        }

        if(fin){
            k=i+1;
            break;
        }

    }

    rep(j, n-1){
        cout << a[k][j] << " ";
    }
    cout << a[k][n-1] << endl;

    return 0;

}

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

#define Fast ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)
#define FO freopen("in.txt", "r", stdin)
#define FC freopen("out.txt", "w", stdout)
#define aise cout<<"aise"<<endl
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define mp make_pair
#define ll long long
#define all(x) x.begin(), x.end()
#define mset(v, a) memset(v, a, sizeof(v))
#define pll pair< ll, ll >
#define pdd pair< double, double >
#define ff first
#define ss second
#define pi acos(-1.0)
#define mxN 2010
#define inf 1e14
#define MOD 1000000007

int main()
{

    string s,t;
    vector<string> v;
    cin >> s >> t;
    ll n = s.size(), m = t.size();
    for(ll i = n-1; i >=0; i--)
    {

        ll sz=0, k = i;
        for(ll j = m-1; j>=0; j--)
        {

            if(k < 0) break;
            if(s[k]=='?' || s[k]==t[j]) sz++;
            k--;
        }
        if(sz==m)
        {

            string ss=s;
            ll kk = i;
            for(ll j = m-1; j >=0; j--, kk--)
            {

                ss[kk] = t[j];
            }
            //cout << ss << " CH\n";
            for(ll j = 0; j < ss.size(); j++)
                if(ss[j]=='?') ss[j]='a';
            v.pb(ss);
        }
    }
    sort(all(v));
    if(v.size()==0) cout << "UNRESTORABLE";
    else cout << v[0];
}


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

int main()
{
    int N;
    cin >> N;
    int P[N],Q[N];
    for(int i = 0; i < N; i++)
    {
        cin >> P[i];
    }

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

    vector<int> PQ(N);
    for(int i = 0; i < N; i++)
    {
        PQ[i] = i+1;
    }

    int a = 0;
    int b = 0;
    
    int count = 0;

    do
    {
        count++;
        int pCount = 0;
        int qCount = 0;
        for(int i = 0; i < N; i++)
        {
            if(PQ[i] == P[i])pCount++;
            if(PQ[i] == Q[i])qCount++;
            if(pCount == N) a = count;
            if(qCount == N) b = count;
        }
        
    } while (next_permutation(PQ.begin(),PQ.end()));
    
    cout << abs(a - b) << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
ll ans = 0;
const ll mo = 998244353;
bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}
template< typename T >
struct BinaryIndexedTree {
  vector< T > data;

  BinaryIndexedTree(int sz) {
    data.assign(++sz, 0);
  }

  T sum(int k) {
    T ret = 0;
    for(++k; k > 0; k -= k & -k) ret += data[k];
    return (ret);
  }

  void add(int k, T x) {
    for(++k; k < data.size(); k += k & -k) data[k] += x;
  }
};
ll mypow(ll a,ll b){
    ll res=1;
    a%=mo;
    while(b){
        if(b&1)
            res=res*a%mo;
        a=a*a%mo;
        b>>=1;
    }
    return res;
}
int main()
{
ll n ;
cin >> n ;
ll res[n][4]={};
pair<ll,ll> p[n];
rep(i,n){
  cin >> p[i].first >> p[i].second;
}
sort(p,p+n, compare_by_b);
rep(i,n){
  p[i].second=i;
}

sort(p,p+n);
BinaryIndexedTree< int > bitlow(n);
BinaryIndexedTree< int > bithigh(n);
rep(i,n){
  res[i][0]=bitlow.sum(p[i].second);
  res[i][1]=i-res[i][0];
  bitlow.add(p[i].second,1);
  res[n-i-1][2]=bithigh.sum(p[n-i-1].second);
  res[n-i-1][3]=i-res[n-i-1][2];
  bithigh.add(p[n-i-1].second,1);
}
ll kai[n+2]={};
kai[0]=0;
kai[1]=2;
rep(i,n){
  kai[i+2]=kai[i+1]*2;
  kai[i+2]%=mo;
}
rep(i,n+1){
  kai[i+1]--;
}
ll temp;
rep(i,n){
  ans+=kai[res[i][0]]*kai[res[i][3]];ans%=mo;
  ans+=kai[res[i][1]]*kai[res[i][2]];ans%=mo;
  temp=kai[res[i][0]]*kai[res[i][1]];temp%=mo;temp*=kai[res[i][2]];ans+=temp;ans%=mo;
  temp=kai[res[i][1]]*kai[res[i][2]];temp%=mo;temp*=kai[res[i][3]];ans+=temp;ans%=mo;
  temp=kai[res[i][2]]*kai[res[i][3]];temp%=mo;temp*=kai[res[i][0]];ans+=temp;ans%=mo;
  temp=kai[res[i][3]]*kai[res[i][0]];temp%=mo;temp*=kai[res[i][1]];ans+=temp;ans%=mo;
  temp=kai[res[i][0]]*kai[res[i][1]];temp%=mo;temp*=kai[res[i][2]];temp%=mo;temp*=kai[res[i][3]];ans+=temp;ans%=mo;
}
ans+=mypow(2,n-1)*n;
ans%=mo;
cout << ans << endl;
return 0;
}


Measured memory_bytes: 12800
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        String str = sc.next();
        String S[] = str.split("");
        if(S[2].equals(S[3])&&S[4].equals(S[5]))
        {
            System.out.println("Yes");
        }
        else
        {
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 21716
N, K = map(int, input().split())

cnt = 0
cnt2 = 0
for k in range(1, N + 1):
    if k % K == 0:
        cnt += 1
    elif K % 2 == 0 and k % K == K // 2:
        cnt2 += 1

print(cnt ** 3 + cnt2 ** 3)


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

int main() {
  int N,count=0;
  string S;
  cin >> N >> S;
  for(int i=0;i<N-2;i++){
    if(S.substr(i,3) == "ABC"){
      count++;
    }
  }
  cout << count << endl;
}

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

using namespace std;

#define run_forrest_run ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define watch(x) cout << (#x) << " is " << (x) << endl
#define pb push_back
#define mp make_pair
#define ll long long
#define ull unsigned long long
#define vi vector <int>
#define pii pair <int, int>
#define sz(a) (int)a.size()
#define F first
#define S second
#define si set <int>
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
int gcd(int a,int b){if(b==0)return a;else return gcd(b,a%b);}
int lcm(int a,int b){return abs(a*b)/gcd(a,b);} 

const int inf = 1e9;	
const int mod = inf + 7;

const int N = 1e5+500;
vector <int> g[N];
vector <bool> visited(N);
vector <int> color(N);	

int main()
{                   
	run_forrest_run;
	string s;
	cin >> s;
	for (int i = 0; i < sz(s)-1; i++)
	{
		if (s[i]==s[i+1])
		{
			cout << "Bad";
			return 0;
		}
	}
	cout << "Good";

	return 0;
}

Measured memory_bytes: 3072
#include<bits/stdc++.h>
using namespace std;
#define res register int
#define ll long long
//#define cccgift
//#define getchar()(p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)
//char buf[1<<21],*p1=buf,*p2=buf;
template<typename T>
inline void read(T &x)
{
    static char ch;bool f=1;
    for(x=0,ch=getchar();!isdigit(ch);ch=getchar()) if(ch=='-') f=0;
    for(;isdigit(ch);x=(x<<1)+(x<<3)+(ch^48),ch=getchar());x=f?x:-x;
}
template<typename T>
void print(T x)
{
    if (x<0) x=-x,putchar('-');
    if (x>9) print(x/10);
    putchar(x%10+48);
}
template<typename T>
inline void print(T x,char ap) {print(x);if (ap) putchar(ap);}
template<typename T>
inline void chkmax(T &x,const T &y) {x=x<y?y:x;}
template<typename T>
inline void chkmin(T &x,const T &y) {x=x<y?x:y;}
struct node{
	int x,y;
	bool operator <(const node &b)const {return x<b.x||(x==b.x&&y<b.y);}
} a[3001];
int n,m,f[3001],maxx;
int main()
{
	ios::sync_with_stdio(false);
	cin>>n>>m,--m;
	for(res i=1;i<=n;++i) cin>>a[i].x>>a[i].y;
	sort(a+1,a+1+n);
	memset(f,0xf3,sizeof(f)),f[0]=0;
	for(res i=1;i<=n;++i) {
		for(res j=0;j<=m;++j) chkmax(maxx,f[j]+a[i].y);
		for(res j=m;j>=a[i].x;--j) chkmax(f[j],f[j-a[i].x]+a[i].y);
	}
	print(maxx,'\n');
	cout<<flush;
	return 0;
}
/* stuff you should look for
    * int overflow, array bounds
    * special cases (n=1?), set tle
    * do something instead of nothing and stay organized
*/ 

Measured memory_bytes: 256
import math

a, b, x = map(int, input().split())

y = x/(a**2)
if y == b/2:
    c = math.sqrt(a**2+b**2)
    print(math.degrees(math.asin(a/c)))
elif y > b/2:
    c = math.sqrt(a**2+4*(b-x/a**2)**2)
    print(90 - math.degrees(math.asin(a/c)))
else:
    c = math.sqrt(b**2+(2*x/(a*b))**2)
    print(90 - math.degrees(math.acos(b/c)))

Measured memory_bytes: 38256
/*input
4 6
1 2 100
3 1 100
2 4 100
4 3 100
1 4 100
3 2 100
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}

//}}}
const int maxn=15;
const int INF=0x3f3f3f3f;

int es[1<<maxn];
int adj[maxn][maxn];
int dp[maxn][1<<maxn];
int main(){
	IOS;
	int n,m;
	cin>>n>>m;
	ll tt=0;
	REP(i,m){
		int u,v,d;
		cin>>u>>v>>d;
		u--;v--;
		adj[u][v]=adj[v][u]=d;
		tt+=d;
	}
	for(int i=1;i<(1<<n);i++){
		int kk=i&-i;

		int tmp=0;
		while(kk%2==0){
			kk/=2;
			tmp++;
		}
		// if(tmp>=n) exit(0);
		int meow=i^(1<<tmp);
		es[i]=es[i^(1<<tmp)];
		for(int j=tmp+1;j<n;j++) if(i&(1<<j)){
			es[i]+=adj[tmp][j];
		}
	}
	REP(i,n) REP(j,1<<n) dp[i][j]=-INF;
	REP(mask,1<<n) for(int i=0;i<n;i++) if(mask&(1<<i)){
		if(i==0) dp[i][mask]=es[mask];
		else{
			int pre=mask^(1<<i);
			for(int sub=pre;sub>0;sub=(sub-1)&pre){
				REP(j,n) if(sub&(1<<j)){
					if(adj[j][i]) dp[i][mask]=max(dp[i][mask],dp[j][sub]+es[sub^mask]+adj[j][i]);
				}
			}
		}
	}
	cout<<tt-dp[n-1][(1<<n)-1]<<'\n';
	return 0;
}


Measured memory_bytes: 2304
# 分析ミス
N = int(input())

RED = []
BLUE = []

for i in range(N):
  a, b = map(int,input().split())
  RED.append((a,b))

for i in range(N):
  c, d = map(int,input().split())
  BLUE.append((c,d))

RED.sort(key=lambda x: -x[0]) #x座標が大きい順
BLUE.sort(key=lambda x: x[1]) #y標が小さい順

# print(RED, BLUE)
SELECTED_RED = set()
SELECTED_BLUE = set()

for i in range(N):
  for j in range(N):
    if i in SELECTED_RED or j in SELECTED_BLUE:
       continue
    
    a, b = RED[i]
    c, d = BLUE[j]
    if a < c and b < d:
      # d以下の最大のy座標はbである
      SELECTED_RED.add(i)
      SELECTED_BLUE.add(j)

print(len(SELECTED_RED))

Measured memory_bytes: 3064
n,m,k = map(int, input().split())
n_ = n*m
mod = 10**9+7
fun = [1]*(n_+1)
for i in range(1,n_+1):
    fun[i] = fun[i-1]*i%mod
rev = [1]*(n_+1)
rev[n_] = pow(fun[n_],mod-2,mod)
for i in range(n_-1,0,-1):
    rev[i] = rev[i+1]*(i+1)%mod

def nCr(n,r):
    if r > n:
        return 0
    return fun[n]*rev[r]%mod*rev[n-r]%mod
  
x = sum(i*(n-i) for i in range(n))%mod
y = sum(i*(m-i) for i in range(m))%mod
ans = (x*m**2 + y*n**2)%mod*nCr(n*m-2,k-2)%mod
print(ans)

Measured memory_bytes: 18804
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007 

ll a[200010];
map <ll,ll>b;
int main() {
	ll n;
	cin>>n;
	for(ll i=1;i<=n;i++){
		cin>>a[i];
	}
	for(ll i=1;i<=n;i++){
		a[i]=a[i]+a[i-1];
	}
	for(ll i=0;i<=n;i++){
		b[a[i]]++;
	}
	ll ans=0;
	for(auto itr=b.begin();itr!=b.end();itr++){
		ll now=itr->second;
		ans+=now*(now-1)/2;
	}
	cout <<ans;
	// your code goes here
	return 0;
}

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

using namespace std;
using ll = long long;
const ll mod = 1000000007;


const vector<vector<int>> dir4 = {{0, 1}, {1, 0}, {-1, 0}, {0, -1}};
const vector<vector<int>> dir9 = {{0, 1}, {1, 0}, {-1, 0}, {0, -1}, {1, 1}, {-1, 1}, {1, -1}, {-1, -1}, {0, 0}};


int main()
{
    int h, w, n;
    cin >> h >> w >> n;
    set<pair<int,int>> st;

    for(int i = 0; i < n; i++){
        pair<int,int> a;
        cin >> a.first >> a.second;
        st.insert(a);
    }

    map<pair<int,int>, int> Map;
    
    for(auto i : st){
        for(auto d : dir9){
            Map[{i.first + d[0], i.second + d[1]}]++;
        }
    }

    ll ans[10] = {0};
    ll cnt = 0;
    for(auto i : Map){
        if(i.first.first <= 1 || i.first.first >= h || i.first.second <= 1 || i.first.second >= w)continue; 
        ans[i.second]++;
        cnt++;
    }
    ans[0] = (ll)(h - 2) * (ll)(w - 2) - cnt;
    for(auto i : ans)cout << i << endl;
}

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

int main() {
  vector<int> v(3); rep(i,3) cin >> v[i];
  int ans = 0;
  int diff1,diff2,diff3;
  diff1 = abs(v[0] - v[1]);
  diff2 = abs(v[1] - v[2]);
  diff3 = abs(v[2] - v[0]);
  ans = diff1 + diff2 + diff3 - max({diff1, diff2, diff3});
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
	string x,y;
	cin>>x>>y;
	if(x[0]==y[2]&&x[1]==y[1]&&x[2]==y[0])
	{
		cout<<"YES";
	}
	else
	{
		cout<<"NO";
	}


	return 0;
}

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

int main()
{
    int n;
    vector<int> vec;
    cin >> n;
    
    int t;
    for(int i = 0; i < n; i++)
    {
        cin >> t;
        vec.push_back(t);
    }

    int cnt = 0;
    int sub = 0;
    for(int i = 0; i < n; ++i)
    {
        ++cnt;
        int num = vec.at(sub);
        if(num == 2)
        {
            break;
        }
        sub = num - 1;
        if(i == n - 1)
        {
            cnt = -1;
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 892
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <queue>
#include <vector>
#include <map>
#include <set>
#define MAXN 
#define P 998244353
#define G 3
#define INF 0x3f3f3f3f
#define rint register int
#define LL long long
#define LD long double
#define fuck printf("FUCK!!\n");
using namespace std;

int a, b, c;
int main()
{
    scanf("%d%d%d", &a, &b, &c);
    if(a==b && b==c) printf("Yes\n");
    else printf("No\n");
    return 0;
}

Measured memory_bytes: 128
/*
 * 2681.cc: Parentheses
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 100;

/* typedef */

typedef pair<int,int> pii;
typedef vector<pii> vpii;

/* global variables */

vpii asc, dsc, pl;

/* subroutines */

bool cmp0(const pii &a, const pii &b) {
  return a.first > b.first || (a.first == b.first && a.second > b.second);
}

bool cmp1(const pii &a, const pii &b) {
  return a.first < b.first || (a.first == b.first && a.second > b.second);
}

/* main */

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

  int sumh = 0;
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    int sn = s.size();
    int minh = 0, h = 0;
    for (int j = 0; j < sn; j++) {
      h += (s[j] == '(') ? 1 : -1;
      if (minh > h) minh = h;
    }
    //printf("%d: %d, %d\n", i, minh, h);

    if (h > 0) asc.push_back(pii(minh, h));
    else if (h < 0) dsc.push_back(pii(minh - h, h));
    else pl.push_back(pii(minh, h));
    sumh += h;
  }
  if (sumh != 0) {
    puts("No");
    return 0;
  }

  sort(asc.begin(), asc.end(), cmp0);
  sort(dsc.begin(), dsc.end(), cmp1);

  bool ok = true;
  int cur = 0;
  for (int i = 0; ok && i < asc.size(); i++) {
    ok = (cur + asc[i].first >= 0);
    cur += asc[i].second;
  }
  for (int i = 0; ok && i < pl.size(); i++) {
    ok = (cur + pl[i].first >= 0);
  }
  for (int i = 0; ok && i < dsc.size(); i++) {
    cur += dsc[i].second;
    ok = (cur + dsc[i].first >= 0);
  }

  cout << (ok ? "Yes" : "No") << endl;

  return 0;
}

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

int main(){
  int n;
  cin >> n;
  int w[n+1];
  int sum = 0;
  for ( int i = 0 ; i < n ; i++){
    cin >> w[i];
    sum += w[i];
  }

  int acc = 0;
  for ( int i = 0; i < n; i++){
    acc += w[i];
    if ( acc > sum/2 ){
      if ( acc - sum/2 < sum/2 - (acc - w[i]) ){
        cout << abs(sum - 2 * acc) << endl;
      } else {
        cout << abs( sum - 2 * (acc - w[i])) << endl;
      }
      break;
    }
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
#define all(x) (x).begin(), (x).end()
#define endl '\n'
#define fsp(x) cout << fixed << setprecision(x)
const ll inf = LLONG_MAX;
const long double pi = M_PI;
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

ll pty(ll lev) {
  if (lev == 0) return 1;
  return pty(lev - 1) * 2 + 1;
}

ll ply(ll lev) {
  if (lev == 0) return 1;
  return ply(lev - 1) * 2 + 3;
}

ll solve(ll n, ll x) {
  ll m = ply(n);
  if (x <= 1) return 0;
  if (x < m / 2) return solve(n - 1, x - 1);
  if (x == m / 2) return pty(n - 1);
  if (x == m / 2 + 1) return pty(n - 1) + 1;
  if (x < m - 1) return pty(n - 1) + 1 + solve(n - 1, x - m / 2 - 1);
  if (x >= m - 1) return pty(n - 1) * 2 + 1;
}

int main() {
  ll n, x;
  cin >> n >> x;
  cout << solve(n, x) << endl;
}

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

int main(void)
{
  int w, h, x, y, r;
  bool flg = true;
  cin >> w >> h >> x >> y >> r;

  // ???????????§??????
  if (y - r < 0 || y + r > h || x - r < 0 || x + r > w) flg = false;

  // ??????
  cout << (flg ? "Yes" : "No") << endl;
}

Measured memory_bytes: 1160
n = int(input())
ll = []
for i in range(n):
  *l, = input().split()
  l.append(i+1)
  ll.append(l)
ll.sort(reverse=True, key = lambda x:int(x[1]))
ll.sort(key=lambda x:x[0])
for i in range(n):
  print(ll[i][2])

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define ft first
#define sc second
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) {if(a<b) a=b;}
#define chmin(a, b) {if(a>b) a=b;}
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
static const ll INF=1e18;
static const ll MAX=1e5+7;
static const ll MOD=1e9+7;
ll max(ll a, ll b) {return a>b?a:b;}
ll min(ll a, ll b) {return a<b?a:b;}




int main(void) {
  ll a, b, t;
  cin >> a >> b >> t;
  pt(t/a*b);
  
  
  
}






Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <vector>
#define REP(i, n) for (int i = 0; (i) < (int)(n); ++ (i))
#define REP3(i, m, n) for (int i = (m); (i) < (int)(n); ++ (i))
#define REP_R(i, n) for (int i = (int)(n) - 1; (i) >= 0; -- (i))
#define REP3R(i, m, n) for (int i = (int)(n) - 1; (i) >= (int)(m); -- (i))
#define ALL(x) ::std::begin(x), ::std::end(x)
using namespace std;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;

constexpr int64_t MOD = 1000000007;

int64_t solve(int64_t S) {
    vector<ll> a(max((int64_t)6, S + 1));
    a[3] = 1;
    a[4] = 1;
    a[5] = 1;
    if (S <= 5) return a[S];
    REP3(i, 6, S + 1) {
        a[i] = 1;
        REP3(j, 3, i - 3 + 1) {
            a[i] = (a[i] + a[i - j]) % MOD;
        }
    }
    return a[S];
}

// generated by online-judge-template-generator v4.6.0 (https://github.com/kmyk/online-judge-template-generator)
int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    constexpr char endl = '\n';
    int64_t S;
    cin >> S;
    auto ans = solve(S);
    cout << ans << endl;
    return 0;
}


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

int gcd(int x, int y){
  if ( x < y) swap(x, y);
  if ( y == 0) return x;
  if ( x == 0) return y;

  return gcd(x%y, y);
}

int main(){
  int n;
  cin >> n;
  int a[n];
  for ( int i = 0; i < n; i++){ cin >> a[i]; }

  int l[n+1], r[n+1], maxv = 0;
  l[0] = 0, r[n] = 0;
  for ( int i = 0; i < n; i++){
    l[i + 1] = gcd(l[i], a[i]);
  }

  for ( int i = n - 1; i >= 0; i--){
    r[i] = gcd(r[i + 1], a[i]);
  }

  for ( int i = 0; i < n; i++){
    maxv = max(maxv, gcd(l[i], r[i+1]));
  }
  cout << maxv << endl;

  return 0;
}

Measured memory_bytes: 1408
//I Guds namespace
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

typedef long long ll;

const int MAXN = 2 * 100 * 1000 + 13;

int BIT[MAXN], n;

ll preS[MAXN], a, ans, k;

vector<ll> v;

ll bitC(int x)
{
	ll ret = 0;
	for(;x > 0;x -= x & (-x))
		ret += BIT[x];
	return ret;
}

void bitUpd(int x)
{
	for(;x < MAXN;x += x & (-x))
		BIT[x]++;
	return;
}

int main()
{
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> n >> k >> a; a -= k;
	if((preS[0] = a) > -1)
		ans++;
	v.push_back(preS[0]);
	for(int i = 1;i < n;i++)
	{
	cin >> a; a -= k;
		if((preS[i] = preS[i - 1] + a) > -1)
			ans++;
		v.push_back(preS[i]);
	}
	sort(v.begin(), v.end());
	v.resize(unique(v.begin(), v.end()) - v.begin());
	for(int i = 0;i < n;i++)
		preS[i] = upper_bound(v.begin(), v.end(), preS[i]) - v.begin();
	for(int i = 0;i < n;i++)
	{
		ans += bitC(preS[i]);
		bitUpd(preS[i]);
	}
	cout << ans << endl;
	return 0;
}


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



int main()
{
	int N,res;
	cin >> N;
	res = N;
	if ((N - 1) % 10 == 0){
		res = N + 8;
	}
	if ((N + 1) % 10 == 0){
		res = N - 8;
	}
	if ((N / 10 - 1) % 10 == 0){
		res = res + 80;
	}
	if ((N / 10 + 1) % 10 == 0){
		res = res - 80;
	}
	if ((N / 100 - 1) % 10 == 0){
		res = res + 800;
	}
	if ((N / 100 + 1) % 10 == 0){
		res = res - 800;
	}
	cout << res << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using pii=pair<int,int>;
using ll=long long;

#define fi first
#define se second
#define pb push_back
#define rep(i,n) for(int i=0; i<(int)(n); i++)

#define MOD 1000000007

vector<vector<ll>> dp0,dp1;

int main() {
	string K;
	int D;
	cin >> K >> D;
	int len = K.length();
	dp0 = vector<vector<ll>>(len, vector<ll>(D));
	dp1 = vector<vector<ll>>(len, vector<ll>(D));
	int c1 = K[0]-'0';
	rep(j, len) rep(i,D) {
		dp0[j][i%D] = 0;
		dp1[j][i%D] = 0;
	}
	rep(i,c1) dp0[0][i%D] += 1;
	dp1[0][c1%D] += 1;
	for(int i=0; i<len; i++) {
		if(i == 0) continue;
		int c = K[i] - '0';
		rep(j,10) {
			rep(s,D) {
				dp0[i][(s+j)%D] += dp0[i-1][s];
				dp0[i][(s+j)%D] %= MOD;
			}
		}
		rep(j,c) {
			rep(s,D) {
				dp0[i][(s+j)%D] += dp1[i-1][s];
				dp0[i][(s+j)%D] %= MOD;
			}
		}
		rep(s,D) {
			dp1[i][(s+c)%D] += dp1[i-1][s];
			dp1[i][(s+c)%D] %= MOD;
		}
	}
	/*rep(i,len) {
		rep(j,D) cout << setw(3) << dp0[i][j];
		cout << endl;
	}
	rep(i,len) {
		rep(j,D) cout << setw(3) << dp1[i][j];
		cout << endl;
	}*/
	ll ans = 0;
	ans = (ans + dp0[len-1][0]) % MOD;
	ans = (ans + dp1[len-1][0]) % MOD;
	ans--;
	if(ans < 0) ans += MOD;
	cout << ans << endl;


  return 0;
}


Measured memory_bytes: 18176
from operator import itemgetter
N,Q = map(int, input().split())
C = [int(c) for c in input().split()]
L = [[int(l) for l in input().split()] for _ in range(Q)]

for i in range(Q):
    L[i].append(i)
M = pow(2, len(bin(N))-2)
BIT = [0]*(M+1)
L.sort(key=itemgetter(1))
memo = [0]*(N+1)

ans = [0]*Q
i = 1
j = 0
while i <= N:
    c = C[i-1]
    idx = i
    if i <= L[j][1]:
        if memo[c] > 0:
            k = memo[c]
            while k <= M:
                BIT[k] -= 1
                k += k&(-k)
        memo[c] = i
        while idx <= M:
            BIT[idx] += 1
            idx += idx&(-idx)
    if i == L[j][1]:
        cnt = 0
        n = L[j][1]
        while n > 0:
            cnt += BIT[n]
            n -= n&(-n)
        n = L[j][0]-1
        while n > 0:
            cnt -= BIT[n]
            n -= n&(-n)
        ans[L[j][2]] = cnt
        j += 1
        if j == Q:
            break
        elif L[j][1] == i:
            i -= 1
    i += 1

for a in ans:
    print(a)

Measured memory_bytes: 226364
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define SZ(x) ((int)x.size())
#define L(i,u) for (register int i=head[u]; i; i=nxt[i])
#define rep(i,a,b) for (register int i=(a); i<=(b); i++)
#define per(i,a,b) for (register int i=(a); i>=(b); i--)
using namespace std;
typedef long long ll;
typedef unsigned int ui;
typedef pair<int,int> Pii;
typedef vector<int> Vi;
template<class T> inline void read(T &x){
	x=0; char c=getchar(); int f=1;
	while (!isdigit(c)) {if (c=='-') f=-1; c=getchar();}
	while (isdigit(c)) {x=x*10+c-'0'; c=getchar();} x*=f;
}
template<class T> inline void umin(T &x, T y){x=x<y?x:y;}
template<class T> inline void umax(T &x, T y){x=x>y?x:y;}
inline ui R() {
	static ui seed=416;
	return seed^=seed>>5,seed^=seed<<17,seed^=seed>>13;
}
const int N = 1<<18|3,mo=998244353,inv2=(mo+1)/2;
int n,a[N],all,g[N],f[N];
int power(int a, int n){
	int res=1;
	while(n){
		if(n&1)res=1LL*res*a%mo;a=1LL*a*a%mo;n>>=1;
	}
	return res;
}
inline void fwt(int *a, int n){
	for(int j=2;j<=n;j<<=1)
		for(int k=0;k<n;k+=j)rep(i,0,(j>>1)-1){
			int x=a[k+i],y=a[k+i+(j>>1)];
			a[k+i]=x+y<mo?x+y:x+y-mo;a[k+i+(j>>1)]=x-y>=0?x-y:x-y+mo;
		}
}
int main() {
	read(n);all=(1<<n)-1;
	int tot=0;rep(i,0,all)read(a[i]),tot=(tot+a[i])%mo;
	tot=power(tot,mo-2);rep(i,0,all)a[i]=1LL*a[i]*tot%mo;
	fwt(a,1<<n);rep(i,0,all)g[i]=power(1-a[i]+mo,mo-2);
//	rep(i,0,all)printf("%d:%d %d\n",i,a[i],g[i]);
	tot=0;rep(i,0,all)tot=(tot+g[i])%mo;
	fwt(g,1<<n);rep(i,0,all)f[i]=1LL*(tot-g[i]+mo)*inv2%mo;
	rep(i,0,all)f[i]=2LL*f[i]%mo,printf("%d\n",(f[i]+mo)%mo);
	return 0;
}


Measured memory_bytes: 5888
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <sys/time.h>

using namespace std;

void solve(int x, int y) {
    vector<int> gr1 = {1, 3, 5, 7, 8, 10, 12};
    vector<int> gr2 = {4, 6, 9, 11};
    vector<int> gr3 = {2,};
    bool x_is_gr1 = find(gr1.begin(), gr1.end(), x) != gr1.end();
    bool x_is_gr2 = find(gr2.begin(), gr2.end(), x) != gr2.end();
    if (x_is_gr1) {
        if (find(gr1.begin(), gr1.end(), y) != gr1.end()) {
            std::cout << "Yes" << std::endl;
        } else{
            std::cout << "No" << std::endl;
        }
    } else if(x_is_gr2) {
        if (find(gr2.begin(), gr2.end(), y) != gr2.end()) {
            std::cout << "Yes" << std::endl;
        } else {
            std::cout << "No" << std::endl;
        }
    } else {
        if (y == 2) {
            std::cout << "Yes" << std::endl;
        } else {
            std::cout << "No" << std::endl;
        }
    }
}

int main() {
    struct timeval start,end;
    long long span;
    int x, y;

    gettimeofday(&start,NULL);

    std::cin >> x >> y;
    solve(x, y);

    gettimeofday(&end,NULL);
    span = (end.tv_sec -start.tv_sec)*1000000LL + (end.tv_usec - start.tv_usec);
    std::cerr << "--Total Time: " << span/1000 << "ms" << endl;
    return 0;
}


Measured memory_bytes: 256
from math import factorial

mod = 10**9+7
n, k = map(int, input().split())

def combination(n,k):
  if n < k:
    return 0
  if k == 0 or k == n:
    return 1
  if k == 1:
    return n
  return factorial(n)//factorial(k)//factorial(n-k)

for i in range(1, k + 1):
  print(combination(n-k+1,i)*combination(k-1,i-1)%mod)


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

int main() {
  int N;
  cin >> N;
  long A[N][N], B[N][N], ans = 0;
  for (int i=0; i<N; i++)
    for (int j=0; j<N; j++) {
      cin >> A[i][j];
      B[i][j] = A[i][j];
    }
  for (int k=0; k<N; k++)
    for (int i=0; i<N; i++)
      for (int j=0; j<N; j++)
        B[i][j] = min(B[i][j], B[i][k] + B[k][j]);
  for (int i=0; i<N; i++) {
    for (int j=0; j<N; j++) {
      if (A[i][j] > B[i][j]) {
        cout << -1 << endl;
        return 0;
      }
      if (i == j)
        continue;
      bool need = true;
      for (int k=0; k<N; k++) {
        if (k == i || k == j)
          continue;
        if (A[i][j] == A[i][k]+A[k][j])
          need = false;
      }
      if (need)
        ans += A[i][j];
    }
  }
  cout << ans/2 << endl;
  return 0;
}

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

int field[101][101];
int dx[] = { 0,1,0,-1};
int dy[] = { 1,0,-1,0};
int w,h;
int xs=1,ys=2,xg,yg;
int num;

int dfs(int x, int y){

  int judge = 0,nx,ny;
  
  if(x == xg && y == yg){
    return 1;
  }

  for(int i = 0;i < 4;i++){
    nx = x + dx[i];
    ny = y + dy[i];
    if(nx <= w && ny <= h && 0 < nx && 0 < ny && field[ny][nx] == num && field[ny][nx] != -1){
      field[ny][nx] = -1;
      judge += dfs(nx,ny);
    }
  }  
  
  return judge;

}
int main(){

  int n;
  int c,d,x,y;
  int j_max,k_max;
  
  while(cin >> w >> h, w | h){
    for(int i = 0;i < 101;i++){
      for(int j = 0;j < 101;j++){
	field[i][j] = 0;
      }
    }
    cin >> xs >> ys;
    cin >> xg >> yg;
    cin >> n;
    for(int i = 0;i < n;i++){
      cin >> c >> d >> x >> y;
      if(d == 0){
	j_max = 2;
	k_max = 4;
      }else{
	j_max = 4;
	k_max = 2;
      }
      for(int j = y;j < y+j_max;j++){
	for(int k = x;k < x+k_max;k++){
	  field[j][k] = c;
	}
      }
    }
    num = field[ys][xs];
    
    if(dfs( xs, ys)){
      cout << "OK" << endl;
    }else{
      cout << "NG" << endl;
    }
  }
}
    

Measured memory_bytes: 1208
#include <bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
#define ll long long
#define ull unsigned long long
#define FI(i,a,n) for(int i=a; i<=n; i++)
#define RFI(i,n,a) for(int i=n; i>=a; i--)
#define FLL(i,a,n) for(ll i=a; i<=n; i++)
#define RFLL(i,n,a) for(ll i=n; i>=a; i--)
#define vi vector<int>
#define vll vector<ll>
#define all(v) v.begin(),v.end()
#define pll pair<ll,ll>
#define pi pair<int, int>
#define GCD(a,b) __gcd(a,b)
#define MP make_pair
#define PB push_back
#define PF push_front
#define LB lower_bound
#define UB upper_bound
#define debug(x) cout << x << endl
#define MOD 1000000007
#define INF LLONG_MAX
#define PI 3.14159265359
using namespace std;


int main()
{
  fastio
  int t;
  /* cin >> t; */ 
  /* while(t--) */
  /* { */

  /* } */
  int n, m, x;
  cin >> n >> m;
  while(m--)
  {
    cin >> x;
    n -= x;
  }
  if(n<0) cout << -1;
  else cout << n;



  return 0;
}




Measured memory_bytes: 3644
using System;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
      
            for(int A = 1; A < 10; A++)
            
            for (int B = 1; B < 10; B++)
           
            Console.WriteLine(A+"x"+B +"="+A*B);
            Console.ReadKey();

        }
    }
}

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

typedef long long int lli;
#define int lli
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<lli> vli;
typedef vector<pii> vii;

const int MOD	= 1e9 + 7;
const double PI = acos(-1.0);

#define fastio			ios_base::sync_with_stdio(false);cin.tie(0)
#define sz(a) int((a).size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define all(c) (c).begin(),(c).end()
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define endl "\n"
#define error_old(x) cerr << #x << " = " << (x) << endl
#define errorp(p) cerr << #p << " = " << (p.first) << ", " << (p.second) << endl
#ifdef DEBUG
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {it++;}
template<typename T, typename... Args> void err(istream_iterator<string> it, T a, Args... args) { cerr << *it << " = " << a << endl; err(++it, args...); }
#else
#define error(args...)
#endif
template<typename T> T gcd(T a, T b){return(b?__gcd(a,b):a);}
template <typename T> T lcm(T a, T b){return (a*b)/gcd(a,b); }

const int nax = 3005;
int dp[nax][nax][2];
int val[nax];

int rec(int i, int j, int who){
    if(dp[i][j][who] != -1){
        return dp[i][j][who];
    }
    if(i > j){
        return 0;
    }

    if(who){
        dp[i][j][who] = min(rec(i + 1, j, 1 - who) - val[i], rec(i, j - 1, 1 - who) - val[j]);
    }else{
        dp[i][j][who] = max(rec(i + 1, j, 1 - who) + val[i], rec(i, j - 1, 1 - who) + val[j]);
    }

    return dp[i][j][who];
}

void solve(){
    // dp[i][j][who] : substring [i, j] and it is turn of who;
    int n;
    cin >> n;
    rep(i, n){
        cin >> val[i];
    }
    rep(i, n){
        rep(j, n){
            rep(who, 2){
                dp[i][j][who] = -1;
            }
        }
    }

    cout << rec(0, n - 1, 0) <<  endl;
}

signed main(){
    #ifdef DEBUG
		freopen("test", "r", stdin);
	#endif
    fastio;
    
    solve();

    return 0;
}


Measured memory_bytes: 141312
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) {
        FastScanner fs=new FastScanner();
        double D=fs.nextInt();
        double T=fs.nextInt();
        double   S=fs.nextInt();
        double t=D/S;
        boolean ans= t<=T;
        if(ans){
            System.out.println("Yes");
        }
        else{
            System.out.println("No");
        }
    }
    static class FastScanner {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st=new StringTokenizer("");
        String next() {
            while (!st.hasMoreTokens())
                try {
                    st=new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }
        int[] readArray(int n) {
            int[] a=new int[n];
            for (int i=0; i<n; i++) a[i]=nextInt();
            return a;
        }
        long nextLong() {
            return Long.parseLong(next());
        }
    }
}


Measured memory_bytes: 32624
import java.util.Scanner;

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

        for(int i=0;i<3;i++){
            if(c[i] == '7'){
                System.out.print("Yes");
                System.out.flush();
                return;
            }
        }
        System.out.print("No");
        System.out.flush();
    }
}

Measured memory_bytes: 27012
#include <stdio.h>

int main(void) {
	int N,A[100000],dp[100000]={};
	scanf("%d",&N);
	for(int i=0; i<N; i++) scanf("%d",&A[i]);
	dp[0] = 0;
	for(int i=0; i<N; i++){
		dp[i+1] = A[i] - dp[i];
	}
	dp[0] = dp[N]/2;
	for(int i=0; i<N; i++){
		dp[i+1] = A[i] - dp[i];
		printf("%d ",dp[i]*2);
	}
	return 0;
}


Measured memory_bytes: 2048