akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<vector>

#define IOS ios::sync_with_stdio(false),cin.tie(0)
#define REP(i,n) for(int i = 0;i < n;i++)
#define FOR(i,a,b) for(int i = a;i < b;i++)

using namespace std;
typedef unsigned long long ull;

int main() {
	IOS;
	int n, m;
	cin >> n >> m;
	vector<string> a(n);
	vector<string> b(m);
	ull B1 = 1145141, B2 = 1145143; //行方向と列方向の基数
	REP(i, n)cin >> a[i];
	REP(i, m)cin >> b[i];

	ull hb = 0;
	REP(i, m) { //bのハッシュを計算
		ull tmpb = 0;
		REP(j, m) {
			tmpb = tmpb * B1 + b[i][j];
		}
		hb = hb * B2 + tmpb;
	}

	int s = n - m + 1; //aの調べる回数
	ull t1 = 1, t2 = 1;
	REP(i, m)t1 *= B1;  //B1,B2のm乗を用意
	REP(i, m)t2 *= B2;
	vector<vector<ull>> tmp(n, vector<ull>(s, 0));
	vector<vector<ull>> ha(s, vector<ull>(s, 0));

	REP(i, n) {  //行方向のハッシュを計算
		REP(j, m)tmp[i][0] = tmp[i][0] * B1 + a[i][j];
		FOR(j, 1, s) tmp[i][j] = tmp[i][j - 1] * B1 - t1 * a[i][j - 1] + a[i][m + j - 1];
	}

	REP(j, s) {  //列方向のハッシュを計算
		REP(i, m)ha[0][j] = ha[0][j] * B2 + tmp[i][j];
		FOR(i, 1, s)ha[i][j] = ha[i - 1][j] * B2 - t2 * tmp[i - 1][j] + tmp[m + i - 1][j];
	}

	bool ans = false;
	REP(i, s) { //ハッシュが一致するか？
		REP(j, s)if (ha[i][j] == hb)ans = true;
	}

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



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(v) v.begin(), v.end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define Rep(n) for (ll _ = 0; _ < (ll)(n); _++)

template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
ll min(int a,ll b){return min((ll)a,b);} ll min(ll a,int b){return min(a,(ll)b);}

#define PRINT_VECTOR_MAX 100
template <class S> void print(vector<S> &v){for(ll i=0; i<(ll)min(v.size(),PRINT_VECTOR_MAX); i++){cerr << v[i] << ' ';}cerr << endl;}
template <class S> void print(vector<vector<S>> &v) {for (ll i = 0; i < (ll)min(v.size(),PRINT_VECTOR_MAX); i++) {for (ll j = 0; j < (ll)min(v[i].size(),PRINT_VECTOR_MAX); j++) {cerr << v[i][j] << ' ';}cerr << endl;}}

void Main();
int main(){
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(20);
	Main();
	return 0;
}

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

  // for prime mod
  mint inv() const { return pow(mod - 2); }
  mint& operator/=(const mint a) { return *this *= a.inv(); }
  mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }

void Main(){
	int n; cin >> n;
	priority_queue<int> pp, pm, mp, mm;
	Rep(n){
		int x,y; cin >> x >> y;
		pp.push(x+y);
		pm.push(x-y);
		mp.push(-x+y);
		mm.push(-x-y);
	}
	cout << max(pp.top() + mm.top(), pm.top() + mp.top()) << endl;
}	

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

const int MOD = 1000000007;

//long long
using ll = long long;

//出力系
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
 
// begin() end()
#define all(x) (x).begin(),(x).end()

//for
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

//最大公約数 
unsigned gcd(unsigned a, unsigned b) {
  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

// 最小公倍数
unsigned lcm(unsigned a, unsigned b){
    return a / gcd(a, b) * b; 
}

int main(){
    int N;
    cin >> N;
    int sum = 0;
    int pos;
    REP(i, N) {
        sum += i + 1;
        if(sum >= N) {
            pos = i + 1;
            break;
        }
    }

    int x = sum - N;
    REP(i, pos){
        if(x != i + 1) cout << i + 1 << endl;
    }
}



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

using namespace std;
typedef long long ll;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vd = vector<double>;
using vvd = vector<vd>;

#define out(a) cout << a << endl
#define out1(a) cout << a
#define in(a) cin >> a
#define in2(a, b) cin >> a >> b
#define in3(a, b, c) cin >> a >> b >> c
#define rep(i, N) for (ll i = 0; i < (ll)N; i++)
#define rep1(i, N) for (ll i = 1; i <= (ll)N; i++)
#define repi(i, j, N) for (ll j = (ll)i + 1; j < (ll)N; j++)
#define all(v) v.begin(), v.end()

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

constexpr int inf = 1e9;
constexpr ll linf = 1e18;
constexpr ll mod = 1e9 + 7;

void solve();

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

void solve()
{
    int a, b;
    in2(a, b);
    if ((a / 10 || b / 10) != 0)
    {
        out("-1");
    }
    else
    {
        out(a * b);
    }
}

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

using namespace std;

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


int main(){

    int A,B,C,X,Y;
    cin>>A>>B>>C>>X>>Y;
    ll sum=0;
    int price_d;
    if(X>=Y){
            price_d=min((A+B),2*C);
            sum+=price_d*Y;
            sum+=(X-Y)*min(A,2*C);

    }else{
        price_d=min((A+B),2*C);
            sum+=price_d*X;
            sum+=(Y-X)*min(B,2*C);

    }
    cout<<sum<<endl;
}

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

using ll=long long;
#define int ll

#define FOR(i,a,b) for(int i=int(a);i<int(b);i++)
#define REP(i,b) FOR(i,0,b)
#define MP make_pair
#define PB push_back
#define ALL(x) x.begin(),x.end()
#define REACH cerr<<"reached line "<<__LINE__<<endl
#define DMP(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define ZERO(x) memset(x,0,sizeof(x))

using pi=pair<int,int>;
using vi=vector<int>;
using ld=long double;

template<class T,class U>
ostream& operator<<(ostream& os,const pair<T,U>& p){
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}

template<class T>
ostream& operator <<(ostream& os,const vector<T>& v){
	os<<"[";
	REP(i,(int)v.size()){
		if(i)os<<",";
		os<<v[i];
	}
	os<<"]";
	return os;
}

int read(){
	int i;
	scanf("%lld",&i);
	return i;
}

void printSpace(){
	printf(" ");
}

void printEoln(){
	printf("\n");
}

void print(int x,int suc=1){
	printf("%lld",x);
	if(suc==1)
		printEoln();
	if(suc==2)
		printSpace();
}

string readString(){
	static char buf[3341919];
	scanf("%s",buf);
	return string(buf);
}

char* readCharArray(){
	static char buf[3341919];
	static int bufUsed=0;
	char* ret=buf+bufUsed;
	scanf("%s",ret);
	bufUsed+=strlen(ret)+1;
	return ret;
}

template<class T,class U>
void chmax(T& a,U b){
	if(a<b)
		a=b;
}

template<class T,class U>
void chmin(T& a,U b){
	if(a>b)
		a=b;
}

template<class T>
T Sq(const T& t){
	return t*t;
}

const int inf=LLONG_MAX/3;

const int Nmax=1145;
const int Vmax=5140;
vi ch[Nmax];
int x[Nmax];
bool dp[Vmax];
void Muri(){
	cout<<"IMPOSSIBLE"<<endl;
	exit(0);
}
pi dfs(int v){
	vector<pi> ws;
	for(auto c:ch[v])
		ws.PB(dfs(c));
	
	int sum=0;
	for(auto w:ws)
		sum+=w.first+w.second;
	
	memset(dp,0,sizeof(dp));
	dp[0]=1;
	int base=0;
	for(auto w:ws){
		int a=w.first,b=w.second;
		base+=min(a,b);
		a=max(a,b)-min(a,b);
		for(int i=Vmax-1;i>=a;i--)if(dp[i-a])
			dp[i]=1;
	}
	int ad=-1;
	REP(i,x[v]-base+1)if(dp[i])
		ad=x[v]-base-i;
	if(ad==-1)
		Muri();
	return pi(sum+ad-x[v],x[v]);
}

signed main(){
	int n=read();
	FOR(i,1,n){
		int p=read()-1;
		ch[p].PB(i);
	}
	REP(i,n)x[i]=read();
	dfs(0);
	cout<<"POSSIBLE"<<endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
long long n,m,x,y,mem[100001],ans;
vector <int> a[100001];
long long dp(int i){
    if(mem[i]) return mem[i];
    for(int k=0;k<a[i].size();k++){
        mem[i]=max(mem[i],1+dp(a[i][k]));
    }
    return mem[i];
}
int main(){
    cin>>n>>m;
    for(int i=0;i<m;i++){
        cin>>x>>y;
        a[x].push_back(y);
    }
    for(int i=1;i<=n;i++)
    ans=max(ans,dp(i));
    cout<<ans;
}


Measured memory_bytes: 8576
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) Rep(i, 0, n)
#define all(a) (a).begin(), (a).end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;

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

    int n, m;
    cin >> n >> m;
    int e[10][10] = {};
    rep(i, m)
    {
        int a, b;
        cin >> a >> b;
        a--, b--;
        e[a][b] = e[b][a] = 1;
    }
    vector<int> perm(n);
    rep(i, n) perm[i] = i;
    int ans = 0;
    do
    {
        if (perm[0] != 0)
            break;
        bool f = true;
        rep(i, n - 1) if (!e[perm[i]][perm[i + 1]]) f = false;
        if (f)
            ans++;
    } while (next_permutation(all(perm)));
    cout << ans << endl;
}

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

using namespace std;

#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl

typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.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 (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = 1e18;
const ll MOD = 1000000007;
//const ll MOD = 998244353;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p;
int dx[4] = { 1,0, -1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
//#define mp make_pair


int main() {
  ll n, W;
  cin >> n >> W;
  vl w(n), v(n);
  rep (i, n) {
    cin >> w[i] >> v[i];
  }
  vector<pll> hani(1, pll(0, 0));
  map<ll, ll> w2v;
  w2v[0] = 0;
  set<ll> st;
  rep (i, n) {
    st.erase(all(st));
    rrep (j, hani.size()) {
      ll mi = hani[j].first, ma = hani[j].second;
      //DEBUG(mi); DEBUG(ma);
      for (ll k = ma; k >= mi; k--) {
        if (k + w[i] > W) continue;
        if (st.count(k + w[i])) continue;
        st.insert(k + w[i]);
        w2v[k + w[i]] = max(w2v[k + w[i]], w2v[k] + v[i]);
      }
    }
    ll mi = hani.back().first, ma = hani.back().second;
    hani.push_back(pll(mi + w[0], ma + w[0] + 3));
  }
  ll ans = 0;
  for (auto itr = w2v.begin(); itr != w2v.end(); itr++) {
    ans = max(ans, itr->second);
  }
  cout << ans << endl;
}


Measured memory_bytes: 1792
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <bitset>

using namespace std;
typedef long long ll;

int main() {
    std::ios::sync_with_stdio(0); cin.tie(0);
    ll n, m, c;
    ll a,b;
    ll count=0;
    ll ans=0;
    cin >> n >> m ;
    int array [m][n];
    int bb[m];
    vector <pair<ll, ll> > pairs(n);
for(ll i=0;i<n;i++){
cin >> a >> b;
pairs[i] = make_pair(a,b);
}
sort(pairs.begin(), pairs.end());

    for(ll i=0;i<n;i++){
        if(pairs[i].second+count >= m){
            ans = ans+(m-count)*pairs[i].first;
            break;
        }else{
            count = count + pairs[i].second;
            ans = ans+pairs[i].first*pairs[i].second;
        }
    }


    // for(int i=0;i<A;i++){
    //     double z;
    //     string p;
    //     cin >> z;
    //     cin >> p;
    //     if(p=="BTC") {
    //         b += z*380000;
    //     }else if(p=="JPY"){
    //         b += z;
    //     }
    // }
    cout << ans << endl;
}

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

using namespace std;

int main()
{
    ios_base::sync_with_stdio(0);
    int n, m;
    cin >> n >> m;
    vector< vector<int> > a(m);
    for (int i = 0; i < m; ++i)
    {
        int k;
        cin >> k;
        for (int j = 0; j < k; ++j)
        {
            int x;
            cin >> x;
            --x;
            a[i].push_back(x);
        }
    }
    vector<int> p(m);
    for (int i = 0; i < m; ++i)
        cin >> p[i];
    int odp = 0;
    for (int mask = 0; mask < (1 << n); ++mask)
    {
        int ok = true;
        for (int i = 0; i < m; ++i)
        {
            int on = 0;
            for (int j = 0; j < a[i].size(); ++j)
                if ((mask & (1 << a[i][j])) > 0)
                    ++on;
            if (on % 2 != p[i])
                ok = false;
        }
        if (ok)
            ++odp;
    }
    cout << odp;
    return 0;
}


Measured memory_bytes: 256
a,b=map(int,input().split())
if b!=0:
  B=list(map(int,input().split()))
  A=B.copy()
  for i in range(b):
    A[i]= abs(A[i]-a)
  A.sort()
  for i in range(A[-1]+2):
    if A.count(i)==1:
      if i!=0:
        if a-i in B:
          result=a+i
          break
        else:
          result=a-i
          break
    elif A.count(i)==0:
      result=a-i
      break
else:
  result=a
print(result)

Measured memory_bytes: 9220
#include<bits/stdc++.h>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define case int t; cin>>t; while(t--)
using namespace std;
#define mod 1000000007
int r,c;
#define inf INT_MAX;
int dp[1001][1001];
int count(string *s,int rr,int cc){
    if(rr>=r || cc>=c){
        return 0;
    }
    if(rr==r-1 && cc==c-1){
        return 1;
    }
     if( dp[rr][cc]!= INT_MAX ) {
         return dp[rr][cc];
     }
    if(s[rr][cc]=='#'){
        return 0;
    }
    dp[rr][cc]=(count(s,rr,cc+1)+count(s,rr+1,cc))%mod;
    return dp[rr][cc];

   
}
int main()
{
    loop(i,0,1001){
        loop(j,0,1001)
        dp[i][j]=inf;
    }
    
    cin>>r>>c;
    string s[r];
    loop(i,0,r){
        cin>>s[i];
    }
    cout<<count(s,0,0)<<endl;


return 0;
}

Measured memory_bytes: 5376
#include<string.h>
#include<stdio.h>
const int N=100;
char a[N];

int main()
{
      while(gets(a))
      {
            int n=strlen(a);


  printf("%c",a[0]);
  printf("%d",n-2);
  printf("%c\n",a[n-1]);

      }

}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using db = double;
using pll = pair < ll, ll >;
 
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template < typename Arg1 >
void __f(const char* name, Arg1&& arg1) {
    cerr << name << " : " << arg1 << std :: endl;
}
template < typename Arg1, typename... Args >
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " : " << arg1 << " | ";
    __f(comma + 1, args...);
}
#else
#define trace(...)
#endif
 
#define pb push_back
#define mp make_pair
#define fastIo() ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0)
 
const int MOD = 1e9 + 7, INF = INT_MAX, N = 1e6 + 10;

ll cnt[N];

bool valid(ll a1) {
	if(cnt[a1] > 1) return false;

	for(ll i = 2; i*i <= a1; i++) {
		// trace(i, a1);
		if((a1%i == 0) && (cnt[a1/i] || cnt[i])) return false;
	}
	return true;
}

int main(){ 
	ll n; cin >> n;
	set<string>st;
	for(int i = 0; i < n; i++) {
		string a; cin >> a;
		st.insert(a);
	}
	cout << st.size();
}


Measured memory_bytes: 19192
get_number(Number) :-
    get_string(String),
    number_string(Number, String).

get_number(A, B) :-
    get_number(A),
    get_number(B).

get_number(A, B, C) :-
    get_number(A, B),
    get_number(C).

get_string(String) :-
    current_input(Input),
    read_string(Input, ' \n', '', _, String).

get_chars(Xs) :-
    get_string(S),
    string_chars(S, Xs).

/* memo
    code(int)
    string_code(1, S, C), (C: code)
    char_code(X, Y) (X: char, Y: code)
    string_chars(S, S2) (S: string, S2: [char])
    to_lower(C, C2) (C: char? C2: code?)
    sub_string

    f(0, [], []).
    f(Z, [X|Xs], [Y|Ys]) :- X = Y, f(Z1, Xs, Ys), Z is Z1 + 1.
    f(Z, [_|Xs], [_|Ys]) :- f(Z, Xs, Ys).

    match: =, \=

    numeric: <,=<, >, >= (eval)
    lexicographically: @<. @=<, @>, @>=
    value?: =:=, =\= (eval)
    identical: ==, \==
*/

main :-
    get_string(S),
    get_string(T),
    S = T -> writeln("H") ; writeln("D").


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

#define MAX 100000
int y[MAX],x[MAX],t[MAX];

int main(){
	int n;	cin>>n;
	for(int i=0;i<n;i++) cin>>t[i]>>x[i]>>y[i];

	int nowY=0, nowX=0;
	int now=0;

	string ans="Yes";
	for(int i=0;i<n;i++){
		int d= abs(nowX-x[i]) + abs(nowY-y[i]);
		int time = t[i]-now; 
		if(time>=d && (time-d)%2==0) continue;
		else{
			ans="No";
			break;
		}
	}

	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 1408
using System.Text;
using System.Collections.Generic;
using System;

public class P
{
    public int e { get; set; }
    public int t { get; set; }
}

public class Hello
{
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var n = int.Parse(line[0]);
        var m = int.Parse(line[1]);
        var a = new List<P>[n];
        for (int i = 0; i < n; i++) a[i] = new List<P>();
        while (true)
        {
            line = Console.ReadLine().Trim().Split(' ');
            var s = int.Parse(line[0]) - 1;
            var t = int.Parse(line[1]) - 1;
            var e = int.Parse(line[2]);
            if (s == -1 && t == -1 && e == 0) break;
            a[s].Add(new P { t = t, e = e });
        }
        var L = int.Parse(Console.ReadLine().Trim());
        var sb = new StringBuilder();
        for (int i = 0; i < L; i++)
        {
            var sL = new long[n];
            line = Console.ReadLine().Trim().Split(' ');
            var b = Array.ConvertAll(line, int.Parse);
            printAns(a, b, n, m ,sb);
        }
        Console.Write(sb);
    }
    static void printAns(List<P >[] a , int[] b, int n, int m, StringBuilder sb)
    {
        var ans = new long[n];
        for (int i = 0; i < n; i++)
        {
            var w = 0L;
            foreach (var x in a[i])
                w += x.e * b[x.t];
            ans[i] = w;
        }
        sb.Append(string.Join(" ", ans) + "\n");
    }
}


Measured memory_bytes: 58032
# from math import factorial,sqrt
# from itertools import permutations as permus
# from fractions import gcd
# from collections import deque,Counter
# from decimal import Decimal, getcontext
# # getcontext().prec = 1000
# # eps = Decimal(10) ** (-100)

# import numpy as np
# import scipy as scp

# 入力の受け取り
n = int(input())
# 列ベクトルとかの受け取り
dic = {}
for i in range(1,n+1):
    dic[i] = list(input().split())
    dic[i][1] = int(dic[i][1])

# print(dic)
ans = sorted(dic.items(),key=lambda x:(x[1][0],-x[1][1]))
# print(ans)

for i in range(len(ans)):
    print(ans[i][0])
# print("{:.10f}".format(ans))
# print(*ans)   # unpackして出力。間にスペースが入る
# for row in board:
#     print(*row,sep="")    #unpackして間にスペース入れずに出力する



Measured memory_bytes: 3060
lines = $stdin.read
array = lines.split("\n")

S = array[0].to_s

len = S.length
while len != 0
  len -= 1
  #printf S[0...len]

  if len % 2 == 0
    first  = S[0..len/2-1]
    second = S[len/2..len-1]
    #printf "[ #{first} ]"
    #printf "[ #{second} ]"
    #printf "\n"

    if first == second
      puts len
      exit
    end
  else
    #printf "\n"
    next
  end
end

puts S.length


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

int main(){
    int n, w;
    cin >> n >> w;
    vector<ll> dp(w+1, 0);
    // dp[i] = max value of items whose weight eqauls i
    for(int i = 0; i < n; i++){
        int wt, v;
        cin >> wt >> v;
        for(int j = w; j >= wt; j--){
            dp[j] = max(dp[j], dp[j-wt] + (ll)v);
        }
    }
    ll mx = 0;
    for(int i = 0; i <= w; i++) mx = max(mx, dp[i]);
    cout << mx << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
#include <string.h>

#define ll long long
#define ull unsigned long long

using namespace std;

int main() {
	string key;
	cin >> key;

	if (key == "a"){printf("b\n");}
	if (key == "b"){printf("c\n");}
	if (key == "c"){printf("d\n");}
	if (key == "d"){printf("e\n");}
	if (key == "e"){printf("f\n");}
	if (key == "f"){printf("g\n");}
	if (key == "g"){printf("h\n");}
	if (key == "h"){printf("i\n");}
	if (key == "i"){printf("j\n");}
	if (key == "j"){printf("k\n");}
	if (key == "k"){printf("l\n");}
	if (key == "l"){printf("m\n");}
	if (key == "m"){printf("n\n");}
	if (key == "n"){printf("o\n");}
	if (key == "o"){printf("p\n");}
	if (key == "p"){printf("q\n");}
	if (key == "q"){printf("r\n");}
	if (key == "r"){printf("s\n");}
	if (key == "s"){printf("t\n");}
	if (key == "t"){printf("u\n");}
	if (key == "u"){printf("v\n");}
	if (key == "v"){printf("w\n");}
	if (key == "w"){printf("x\n");}
	if (key == "x"){printf("y\n");}
	if (key == "y"){printf("z\n");}

	return 0;
}


Measured memory_bytes: 256
import numpy as np
import math
import scipy as sp
import queue
import collections

MOD = 10 ** 9 + 7
INF = 10 ** 9

def main(kwargs):
    s = kwargs["s"]
    t = kwargs["t"]

    if s == t[:-1]:
        res = 'Yes'
    else:
        res = 'No'

    return res

if __name__ == "__main__":
    kwargs = {}

    cin = input().split()
    kwargs["s"] = cin[0]

    cin = input().split()
    kwargs["t"] = cin[0]

    cout = main(kwargs)
    print(cout)

Measured memory_bytes: 30940
# 2019-11-18 00:38:19(JST)
import sys
# import collections
# import math
# from string import ascii_lowercase, ascii_uppercase, digits
# from bisect import bisect_left as bi_l, bisect_right as bi_r
# import itertools
# from functools import reduce
# import operator as op
# import re
# import heapq
# import array
# from scipy.misc import comb # (default: exact=False)
# import numpy as np 


def main():
    n, *b = [int(x) for x in sys.stdin.read().split()]
    a = [None for _ in range(n)]
    a[0], a[n-1] = b[0], b[n-2]
    for i in range(1, n-1):
        a[i] = min(b[i-1], b[i])

    ans = sum(a)
    print(ans)

if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int x = in.nextInt();
            int y = in.nextInt();
            if (x % y == 0) {
                out.println(-1);
            } else {
                out.println(x);
            }
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



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

int main(){
  int n;
  cin >> n;
  vector<int> data(n);
  for(int i = 0; i < n; i++){
    cin >> data.at(i);
  }
  sort(data.begin(), data.end());
  reverse(data.begin(), data.end());
  int other_side = 0;
  int long_side = 0;
  for(int i = 0; i < n; i++){
    if(i == 0){
      long_side = data.at(i);
      continue;
    }
    other_side += data.at(i);
  }
  if(long_side < other_side){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
a, b, c, d = map(int, input().split())

max_attack = 0
if(-(-a//d) > -(-c//b)):
    max_attack = int(-(-c//b))
else:
    max_attack = int(-(-a//d))

for cnt in range(0, max_attack):
    c = c - b
    if c <= 0:
        print('Yes')
        break
    a = a - d
    if a <= 0:
        print('No')

Measured memory_bytes: 9196
function main(input) {
  const inputs = input.trim().split('\n')
  const K = Number(inputs[0])
  const [A, B] = inputs[1].split(' ').map(Number)

  for(let i = A; i <= B; i++) {
    if (i % K === 0) {
      console.log('OK')
      return
    }
  }
  console.log('NG')
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'))


Measured memory_bytes: 29552
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define INF 1000000000
#define mod 1000000007
using ll=long long;
const ll LINF=1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
// ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
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(b<a){a=b;return true;}return false;}

int b[4001][4001],w[4001][4001];
int sb[4002][4002],sw[4002][4002];

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    
    int n,k;cin>>n>>k;
    
    rep(i,4*k)rep(j,4*k)b[i][j]=0,w[i][j]=0;

    int wall=0;
    rep(i,n){
        int x,y;char c;cin>>x>>y>>c;
        x%=(2*k);y%=(2*k);
        if(c=='B'){
            b[x][y]++;
            b[x+2*k][y]++;
            b[x][y+2*k]++;
            b[x+2*k][y+2*k]++;
        }
        else{
            wall++;
            w[x][y]++;
            w[x+2*k][y]++;
            w[x][y+2*k]++;
            w[x+2*k][y+2*k]++;
        }
    }
    
    rep(i,4*k+1)rep(j,4*k+1)sb[i][j]=0,sw[i][j]=0;
    rep(i,4*k){
        rep(j,4*k){
            sb[i+1][j+1]=sb[i][j+1]+sb[i+1][j]-sb[i][j]+b[i][j];
            sw[i+1][j+1]=sw[i][j+1]+sw[i+1][j]-sw[i][j]+w[i][j];
        }
    }


    int ans=0;
    rep(i,2*k+1){
        rep(j,2*k+1){
            int bcnt=sb[i+k][j+k]-sb[i][j+k]-sb[i+k][j]+sb[i][j]
                +sb[i+2*k][j+2*k]-sb[i+2*k][j+k]-sb[i+k][j+2*k]+sb[i+k][j+k];
            int wcnt=wall-(sw[i+k][j+k]-sw[i][j+k]-sw[i+k][j]+sw[i][j]
                +sw[i+2*k][j+2*k]-sw[i+2*k][j+k]-sw[i+k][j+2*k]+sw[i+k][j+k]);
            chmax(ans,bcnt+wcnt);
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 250496
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
#define N 200005
int A[N], n;
int main()
{
	scanf("%d", &n);
	int s = 0;
	for (int i = 1; i <= n; i++)
		scanf("%d", &A[i]), s ^= A[i];
	for (int i = 1; i <= n; i++)
		printf("%d%c", s ^ A[i], i == n ? 10 : 32);
}

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

using namespace std;

#define REP(i, n) for (int i=0; i<(n); ++i)
#define RREP(i, n) for (int i=(int)(n)-1; i>=0; --i)
#define FOR(i, a, n) for (int i=(a); i<(n); ++i)
#define RFOR(i, a, n) for (int i=(int)(n)-1; i>=(a); --i)

#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

#define DUMP(x) cerr<<#x<<" = "<<(x)<<endl
#define DEBUG(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<<endl;

template<class T>
ostream &operator<<(ostream &os, const vector <T> &v) {
    os << "[";
    REP(i, SZ(v)) {
        if (i) os << ", ";
        os << v[i];
    }
    return os << "]";
}

template<class T, class U>
ostream &operator<<(ostream &os, const pair <T, U> &p) {
    return os << "(" << p.first << " " << p.second << ")";
}

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 (b < a) {
        a = b;
        return true;
    }
    return false;
}

using ll = long long;
using ull = unsigned long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vi>;
using vvll = vector<vll>;

const ll MOD = 1e9 + 7;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;
const ld eps = 1e-9;

template<typename T>
struct edge {
    int src, to;
    T cost;
};

template<typename T>
using Graph = vector<vector<edge<T>>>;


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    // ifstream in("in.txt");
    // cin.rdbuf(in.rdbuf());

    int n, m; cin >> n >> m;
    vvi g(n);
    REP(i, m) {
        int u, v; cin >> u >> v; --u, --v;
        g[u].push_back(v);
        g[v].push_back(u);
    }

    vi par(n, -1);
    queue<int> que;
    que.push(0);
    vi used(n);
    used[0] = 1;

    while (!que.empty()) {
        int v = que.front(); que.pop();
        for (int u : g[v]) {
            if (used[u]) continue;
            used[u] = 1;
            par[u] = v;
            que.push(u);
        }
    }

    cout << "Yes" << endl;
    FOR(i, 1, n) {
        cout << par[i] + 1 << endl;
    }

    return 0;
}


Measured memory_bytes: 10648
import java.util.Scanner;

public class Main {

	public static void main(String[] args) { 
		Scanner scanner = new Scanner(System.in);
		
		int a = 0;
		int b = 0;
		
		a = scanner.nextInt();
		b = scanner.nextInt();
		
		int max = a+b;
		
		int sub = a-b;
		int mul = a*b;
		
		if (sub>max) {
			max = sub;
		}
		
		if (mul>max) {
			max = mul;
		}
		
		System.out.println(max);
		
		
		scanner.close();
	}

}


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

template<class T> inline void chmin(T& a, T b) {if (a > b) a = b;}
template<class T> inline void chmax(T& a, T b) {if (a < b) a = b;}


ll const mod = 1e9+7;
// べき乗
int64_t modpow(int64_t x, int64_t n) {
    x = x%mod;
    if(n==0) return 1;  //再帰の終了条件

    else if(n%2==1) {
        return (x*modpow(x, n-1))%mod;  //nが奇数ならnを1ずらす
    }
    else return modpow((x*x)%mod, n/2)%mod;  //nが偶数ならnが半分になる
}

//逆元　a/b の modをとるとき -> a*modinv(b)%mod
long long modinv(long long a, long long m = 1e9+7) {
  long long b = m, u = 1, v = 0;
  while (b) {
    long long t = a / b;
    a -= t * b; swap(a, b);
    u -= t * v; swap(u, v);
  }
  u %= m; 
  if (u < 0) u += m;
  return u;
}

int main() {
  ll Q=0;
  string S;
  cin >> S;
  int N=S.size();
  for (auto i:S) if(i=='?') Q++;
  vector<ll> a(N+1,0),b(N+1,0),c(N+1,0);
  rep2(i,1,N+1) {
    auto t = S[i-1];
    a[i] += a[i-1];
    b[i] += b[i-1];
    c[i] += c[i-1];
    if (t=='A') a[i]+=modpow(3,Q);
    else if (t=='B') b[i] += a[i-1];
    else if (t=='C') c[i] += b[i-1];
    else {
      a[i]+=modpow(3,Q-1);
      b[i] += a[i-1]*modinv(3)%mod;
      c[i] += b[i-1]*modinv(3)%mod;
    }
    a[i]%=mod;
    b[i]%=mod;
    c[i]%=mod;
    // printf("%lld %lld %lld\n",a[i],b[i],c[i]);
  }
  cout << c[N] << endl;
}

Measured memory_bytes: 2816
#include "bits/stdc++.h"
using namespace std;
int main() {
	string S, T;
	cin >> S >> T;
	int A, B;
	cin >> A >> B;
	string U;
	cin >> U;
	if (U == S) A--;
	else B--;
	cout << A << ' ' << B << endl;
}

Measured memory_bytes: 256
module Main where

import           Control.Monad
import           Data.List
import           Data.Ord
import           Data.List.Split
import           Data.Array.IO
import qualified Data.Vector.Unboxed as V

main :: IO ()
main = do
  [n, k] <- map read . words <$> getLine :: IO [Int]
  s <- getLine :: IO String
  let sums = (V.fromList . scanl (+) 0 . count . group) s
  print . V.maximum $ f sums k
  where
    count cs =
      let xs = if (head . head) cs == '0' then []:cs    else cs
          ys = if (even . length) xs then xs ++ [] else xs
      in  map length ys
    f sums k =
      let ls = V.length sums
          a  = 2 * k + 1
      in  V.fromList [(sums V.! min (i + a) (ls - 1)) - (sums V.! i) | i <- [0,2..(ls - 1)]]


Measured memory_bytes: 13180
/*
 * written by Yaqi Zhang
 * University of Wisconsin-Madison
 * 2020
 */

#include<algorithm>
#include<cstring>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stdio.h>
#include<vector>

#define INF 0x3f3f3f3f

using namespace std;


int main(int argc, char *argv[])
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    // LCS: longest common subsequence
    // DP[i, j] is the LCS of s[i:] and t[j:]
    // DP[ns, nt] = 0
    string s, t;
    cin >> s >> t;
    int ns = s.length(), nt = t.length();
    vector<vector<int>> dp(ns + 1, vector<int>(nt + 1, 0));
    for(int i = ns - 1; i >= 0; --i) {
        for(int j = nt - 1; j >= 0; --j) {
            if(s[i] == t[j]) {
                dp[i][j] = 1 + dp[i + 1][j + 1];
            } else {
                dp[i][j] = max(dp[i + 1][j], dp[i][j + 1]);
            }
        }
    }
    int i = 0, j = 0;
    string ans;
    while(dp[i][j] != 0) {
        if(s[i] == t[j]) {
            ans += s[i];
            ++i;
            ++j;
        } else {
            if(dp[i + 1][j] > dp[i][j + 1]) ++i;
            else ++j;
        }
    }
    cout << ans << endl;
    return 0;

}



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

#define fi first
#define se second

typedef pair<int ,int> pii;
typedef pair<int ,pii> pipii;

int N,M,Q;
int dp[100010][20] = {0};
pipii que[100010];
int ans[100010] = {0};
vector<int> V[100010];

void drow(int v,int d,int c)
{
    if(dp[v][d] != 0)return;
    dp[v][d] = 1;
    if(ans[v] == 0)ans[v] = c;
    if(d == 1)return;
    for(int i = 0; i < V[v].size(); i++)
    {
        drow(V[v][i],d - 1,c);
    }
    return;
}

int main()
{
    scanf("%d%d",&N,&M);
    for(int i = 0; i < M; i++)
    {
        int a,b;
        scanf("%d%d",&a,&b);
        V[a].push_back(b);
        V[b].push_back(a);
    }
    scanf("%d",&Q);
    for(int i = 0; i < Q; i++)
    {
        scanf("%d%d%d",&que[Q - i - 1].fi ,&que[Q - i - 1].se.fi ,&que[Q - i - 1].se.se);
    }
    for(int i = 0; i < Q; i++)
    {
        int v,d,c;
        v = que[i].fi;d = que[i].se.fi;c = que[i].se.se;
        drow(v,d + 1,c);
    }
    for(int i = 1; i < N + 1; i++)printf("%d\n",ans[i]);
    return 0;
}


Measured memory_bytes: 15864
(let ((s (read-line))
      (a 0)
      (b 0))
  (loop :for c :across s
        :if (char= c #\A)
        :do (incf a)
        :else 
        :do (incf b))
  (if (/= 0 (* a b))
      (format t "Yes~%")
      (format t "No~%")))



Measured memory_bytes: 23832
#include<cstring>
#include<iostream>
#include<cctype>
#include<cstdio>
#include<algorithm>
#include<queue>
#include<cmath>
#define writ(x,c) write(x),putchar(c);
typedef long long ll;
using namespace std;
inline int read()
{
    char c;int x=0;bool f=0;
    for(;!isdigit(c);c=getchar()) if(c=='-') f=1;
    for(;isdigit(c);c=getchar()) x=(x<<1)+(x<<3)+(c^48);
    return (f ? -x : x);
}
template <class _T>
void write(_T x)
{
	if(x<0) putchar('-'),x=-x;
    if(x>9) write(x/10);
    putchar(x%10+'0');
}
int n,ans;double t,a,q=10000000.0;
//T*×0.006
int main()
{
	n=read();scanf("%lf%lf",&t,&a);
	for(int i=1;i<=n;i++)
	{
		double s;
		scanf("%lf",&s);
		double tmp=t-s*0.006;
		if(abs(a-tmp)<q)
		{
			q=abs(a-tmp);
			ans=i;
		}
	}
	cout<<ans;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**6)
n = int(input())
adj = [[] for _ in range(n)]
for _ in range(n-1):
	x, y = map(int, input().split())
	adj[x-1].append(y-1)
	adj[y-1].append(x-1)

visited = [False for _ in range(n)]
def dfs(x):
	global visited
	nim = 0
	for v in adj[x]:
		if visited[v] == False:
			visited[v] = True
			nim ^= dfs(v)+1
	return nim

visited[0] = True
if dfs(0) == 0:
	print("Bob")
else:
	print("Alice")

Measured memory_bytes: 110316
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define MOD 1000000007
#define N 200005
ll fact[N], inv[N], finv[N];
void make()
{
	fact[0] = 1;
	fact[1] = 1;
	inv[1] = 1;
	finv[1] = finv[0] = 1;
	for(int i = 2; i < N; ++i)
	{
		fact[i] = fact[i - 1] * i % MOD;
		inv[i] = MOD - (MOD / i) * inv[MOD % i] % MOD;
		finv[i] = finv[i -1] * inv[i] % MOD;
	}
}

ll C(int a, int b)
{
	if(a < b || b < 0) return 0;
	return fact[a] * (finv[b] * finv[a - b] % MOD) % MOD;
}

ll exp(ll a, ll b)
{
	ll res = 1;
	while(b)
	{
		if(b & 1)
			res = res * a % MOD;
		b >>= 1;
		a = a * a % MOD;
	}
	return res;
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	make();
	ll n, a, b, c;
	cin >> n >> a >> b >> c;

	ll ans = 0, pa = a * inv[a + b] % MOD, pb = b * inv[a + b] % MOD;
	ll powa[N], powb[N];
	powa[0] = 1, powb[0] = 1;

	for(int i = 1;i < N; ++i)
	{
		powa[i] = powa[i - 1] * pa % MOD;
		powb[i] = powb[i - 1] * pb % MOD; 
	}

	for (int i = 0; i < n; ++i)
	{
		ans = (ans + C(n + i - 1, i) * (i + n) % MOD * ((powa[i] * powb[n] % MOD + powb[i] * powa[n] % MOD))%MOD) % MOD;
	}
	ans = ans * inv[100 -c] % MOD *100 % MOD;
	cout << ans; 
	return 0;
}

Measured memory_bytes: 8064
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)








int main() {
    ll x, y, z, k;
    cin >> x >> y >> z >> k;
    vector<ll> a(x), b(y), c(z);
    REP(i, x) cin >> a[i];
    REP(i, y) cin >> b[i];
    REP(i, z) cin >> c[i];
    
    vector<ll> v;
    REP(i, x){
        REP(j, y){
            v.push_back(a[i] + b[j]);
        }
    }
    sort(v.begin(), v.end());
    
    ll ok = 0, ng = INF;
    while(ng - ok > 1){
        ll ce = (ok + ng) / 2;
        ll sum = 0;
        REP(i, z){
            ll itr = lower_bound(v.begin(), v.end(), ce - c[i]) - v.begin();
            sum += v.size() - itr;
        }
        if(sum >= k){
            ok = ce;
        }
        else{
            ng = ce;
        }
    }
    
    vector<ll> res;
    REP(i, z){
        ll itr = lower_bound(v.begin(), v.end(), ok - c[i]) - v.begin();
        for(ll j = itr; j < v.size(); j++){
            res.push_back(v[j] + c[i]);
        }
    }
    
    sort(res.begin(), res.end(), greater<ll>());
    REP(i, k){
        cout << res[i] << endl;
    }
}

Measured memory_bytes: 141408
#input of int(split by space)
def get_i()
  return gets.chomp.split(" ").map(&:to_i)
end
#input of float(split by space)
def get_f()
  return gets.chomp.split(" ").map(&:to_f)
end
#input of string(split by space)
def get()
  return gets.chomp.split(" ")
end
#input of string(split per one character)
def get_nsp()
  return gets.chomp.split("")
end
#yes or no decision
def yn_judge(bool,y="Yes",n="No")
  return bool ? y : n 
end
#create of array
def array(size1,init=nil,size2=-1)
  if size2==-1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

def max(a,b)
    return a>b ? a : b
end

def min(a,b)
    return a>b ? b : a
end

INF=Float::INFINITY

a,b,c=get_i
if a+b==c or b+c==a or c+a==b
    puts "Yes"
else
    puts "No"
end

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

typedef long long ll;
typedef pair<int, int> P;
const int mod = 1e9 + 7;

ll N;
vector<ll> v;

struct Sieve {
   int n;
   vector<int> f, primes;
   Sieve(int n = 1): n(n), f(n + 1) {
      f[0] = f[1] = -1;
      for (ll i = 2; i <= n; i++) {
         if (f[i]) continue;
         primes.push_back(i);
         f[i] = i;
         for (ll j = i * i; j <= n; j += i) {
            if (!f[j]) f[j] = i;
         }
      }
   }

   bool isPrime(int x) { return f[x] == x; }

   vector<int> factorList(int x) {
      vector<int> res;
      while (x != 1) {
         res.push_back(f[x]);
         x /= f[x];
      }
      return res;
   }

   vector<P> factor(int x) {
      vector<int> fl = factorList(x);
      if (fl.size() == 0) return {};

      vector<P> res(1, P(fl[0], 0));
      for (int p : fl) {
         if (res.back().first == p) {
            res.back().second++;
         } else {
            res.emplace_back(p, 1);
         }
      }

      return res;
   }
};

struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

int main() {
   Sieve sieve(1e6);

   cin >> N;
   vector<int> a(N);
   rep(i, N) cin >> a[i];

   map<int, int> mp;
   rep(i, N) {
      auto f = sieve.factor(a[i]);
      for (auto p : f) {
         mp[p.first] = max(mp[p.first], p.second);
      }
   }

   mint lcm = 1;
   for (auto p : mp) {
      rep(i, p.second) {
         lcm *= p.first;
      }
   }
   mint ans;
   rep(i, N) {
      mint b = lcm / a[i];
      ans += b;
   }
   cout << ans.x << endl;
}

Measured memory_bytes: 4984
#include<bits/stdc++.h>
using namespace std;
struct flow
{
	static const int N=200005,INF=1e9;
	int n,s,t;
	struct edge
	{
		int v,w,f,c,nxt;
	}e[N];
	int head[N],cur[N],cnt;
	void addedge(int u,int v,int w,int f,int c)
	{
		cnt++;
		e[cnt].v=v,e[cnt].w=w,e[cnt].f=f,e[cnt].c=c;
		e[cnt].nxt=head[u];
		head[u]=cnt;
	}
	void add(int u,int v,int w,int c=0)
	{
		addedge(u,v,w,w,c);
		addedge(v,u,w,0,-c);
	}
	int dep[N],q[N];
	int bfs()
	{
		for(int i=1;i<=n;i++)
			dep[i]=-1,cur[i]=head[i];
		dep[s]=0;
		int l=0,r=1;
		q[0]=s;
		while(l<r)
		{
			int u=q[l++];
			for(int i=head[u];i;i=e[i].nxt)
			{
				if(dep[e[i].v]==-1&&e[i].f>0)
				{
					dep[e[i].v]=dep[u]+1;
					q[r++]=e[i].v;
				}
			}
		}
		return dep[t]!=-1;
	}
	int dfs(int u,int lim)
	{
		if(u==t||lim==0)
			return lim;
		int flow=0,f;
		for(int i=cur[u];i;i=e[i].nxt)
		{
			cur[u]=i;
			if(dep[e[i].v]==dep[u]+1&&(f=dfs(e[i].v,min(lim,e[i].f))))
			{
				flow+=f;
				lim-=f;
				e[i].f-=f;
				e[(i-1^1)+1].f+=f;
				if(!lim)
					break;
			}
		}
		return flow;
	}
	int max_flow()
	{
		int mf=0;
		while(bfs())
			mf+=dfs(s,INF);
		return mf;
	}
	int h[N],dis[N],pre[N],pu[N];
	priority_queue<pair<int,int>,vector<pair<int,int>>,greater<pair<int,int>>>pq;
	int min_cost(int f)
	{
		int res=0;
		for(int i=1;i<=cnt;i+=2)
			e[i].f=e[i].w;
		for(int i=2;i<=cnt;i+=2)
			e[i].f=0;
		while(f>0)
		{
			for(int i=1;i<=n;i++)
				dis[i]=INF;
			dis[s]=0;
			pq.emplace(0,s);
			while(!pq.empty())
			{
				auto p=pq.top();
				pq.pop();
				int u=p.second;
				if(dis[u]<p.first)
					continue;
				for(int i=head[u];i;i=e[i].nxt)
				{
					int v=e[i].v,c=e[i].c,f=e[i].f;
					if(f>0&&dis[v]>dis[u]+c+h[u]-h[v])
					{
						dis[v]=dis[u]+c+h[u]-h[v];
						pre[v]=i,pu[v]=u;
						pq.emplace(dis[v],v);
					}
				}
			}
			if(dis[t]==INF)
				return -1;
			for(int i=1;i<=n;i++)
				h[i]+=dis[i];
			int d=f;
			for(int u=t;u!=s;u=pu[u])
				d=min(d,e[pre[u]].f);
			f-=d;
			res+=d*h[t];
			for(int u=t;u!=s;u=pu[u])
			{
				e[pre[u]].f-=d;
				e[(pre[u]-1^1)+1].f+=d;
			}
		}
		return res;
	}
}g;
const int N=55;
int n,m,k,c,dp[N][N];
char a[N][N];
void sol(int x,int y)
{
	g.add(g.s,c,1,0);
	for(int i=0;i<=n;i++)
		for(int j=0;j<=m;j++)
			dp[i][j]=-1;
	dp[x][y]=0;
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		{
			if(a[i][j]=='#')
				continue;
			if(dp[i-1][j]!=-1)
				dp[i][j]=max(dp[i][j],dp[i-1][j]+1);
			if(dp[i][j-1]!=-1)
				dp[i][j]=max(dp[i][j],dp[i][j-1]+1);
			if(dp[i][j]!=-1)
				g.add(c,k+(i-1)*m+j,1,-dp[i][j]);
		}
	}	
}
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)
	{
		scanf("%s",a[i]+1);
		for(int j=1;j<=m;j++)
			if(a[i][j]=='o')
				k++;
	}
	g.n=k+n*m+2,g.s=k+n*m+1,g.t=k+n*m+2;
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		{
			g.add(k+(i-1)*m+j,g.t,1,0);
			if(a[i][j]=='o')
			{
				c++;
				sol(i,j);
			}
		}
	}
	printf("%d\n",-g.min_cost(k));
	return 0;
}

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



int main(){
    int x,y,i;
    cin>>x>>y;
    if((y-2*x)>=0 && (y-2*x)%2 == 0 && y<=4*x){
        cout<<"Yes";
    }
    else{
        cout<<"No";
    }
}


Measured memory_bytes: 3676
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T &a, T b) {if (a < b) {a = b;return 1;}return 0;}
template<class T> inline bool chmin(T &a, T b) {if (a > b) {a = b;return 1;}return 0;}

int main() {
  int n,d;
  cin >> n >> d;
  int cnt = 0;
  rep(i,n) {
    int x,y;
    cin >> x >> y;
    double total = pow(pow(x,2) + pow(y,2),0.5);
    if (total <= d) cnt++;
  }
  cout << cnt << endl;
}


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

#define full (m == 100 || e == 100 || j == 100)
#define avg(n) (m + e + j >= n)
#define me80 (m >= 80 || e >= 80)

int main() {
	int n, m, e, j;
	while (1) {
		cin >> n; if (n == 0)break;
		for (int i = 0; i < n; i++) {
			cin >> m >> e >> j;
			if (full || m + e >= 180 || avg(240)) cout << "A" << endl;
			else if (avg(210) || (avg(150) && me80)) cout << "B" << endl;
			else cout << "C" << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 3096