akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

// Define
#define int64_t long long
#define uint64_t unsigned long long
using ll = int64_t;
using ul = uint64_t;
using ld = long double;
const ll MOD = 1e9 + 7;
const ll INF = LONG_MAX;
const ul MAX = ULONG_MAX;
#define endl '\n'
#define space ' '
#define elif else if
#define def inline auto
#define func inline constexpr ll
#define run __attribute__((constructor)) def _
#define all(v) begin(v), end(v)
#define min(...) min({__VA_ARGS__})
#define max(...) max({__VA_ARGS__})

// Debug
#define debug(x) cerr << #x << " = " << (x) << " (L:" << __LINE__ << ")" << '\n'

// Loop
#define inc(i, a, n) for (ll i = (a), _##i = (n); i <= _##i; ++i)
#define dec(i, a, n) for (ll i = (a), _##i = (n); i >= _##i; --i)
#define rep(i, n) inc(i, 0, n - 1)

// Stream
#define fout(n) cout << fixed << setprecision(n)
#define fasten cin.tie(0), ios::sync_with_stdio(0)

// Speed
run() { fasten, fout(10); }
#pragma GCC optimize("-O3")
#pragma GCC target("avx")

// Math
func gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
func lcm(ll a, ll b) { return a * b / gcd(a, b); }

def mod_pow(ll a, ll b) {
    if (b == 0) return 1LL;
    if (b & 1) return (a * mod_pow(a, b - 1)) % MOD;
    ll half = mod_pow(a, b / 2);
    return half * half % MOD;
}

def mod_comb(ll n, ll r) {
    r = min(r, n - r);
    ll sup = 1, sub = 1;
    rep(i, r) {
        sup *= n - i, sub *= i + 1;
        sup %= MOD, sub %= MOD;
    }
    return sup * mod_pow(sub, MOD - 2) % MOD;
}

signed main() {
    ll N, M, S = 2;
    double P;
    cin >> N >> M;
    P = sqrt(M);
    ll A[int(P) + 1];
    while (M != 1) {
        A[S] = 0;
        if (M % S == 0) {
            while (M % S == 0) {
                M /= S;
                A[S]++;
            }
        } else if (S > P) {
            A[S]++;
            S++;
            break;
        }
        S++;
    }
    ll ANS = 1;
    inc(i, 2, S - 1) if (A[i]) {
        ANS *= mod_comb(N + A[i] - 1, N - 1);
        ANS %= MOD;
    }
    cout << ANS << endl;
}

// for compilation: g++ -O3 -o _ _.cpp -std=c++17


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
template<class T> bool umin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool umax(T &a, T b) { return a < b ? (a = b, true) : false; }
#define ALL(x) (x).begin(), (x).end()
LL POW(LL a,LL p,LL M){ if(!p) return 1LL;LL T = POW(a,p/2,M);T = T*T%M; if(p&1) T=T*(a%M)%M; return T; }
LL SQRT(LL a) { LL b = (LL)sqrtl(((double)a)+0.5); while(b*b<a) ++b; while(b*b>a) --b; return (b*b==a)?b:-1; }
//endl
//<------------------------edits---------------------------------------------->
const LL MOD = 1e9+7;//998244353
// #define LOCAL LDD
// #define int LL

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.precision(10);cout << fixed;
#ifdef LOCAL
  freopen("input.txt", "rt", stdin);
#endif
  int x,y,z;cin >> x >> y >> z;
  swap(x,y);
  swap(x,z);
  cout << x << " " << y << " " << z << endl; 
  cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s\n";
  return 0;
}

Measured memory_bytes: 256
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<cstdlib>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<string>
#include<utility>
#include<vector>

using namespace std;

#define ll long long
#define pal pair<ll,ll>
#define pad pair<double,double>
#define PB push_back
#define MP make_pair
#define F first
#define S second

const ll MOD = 1e9+7;
const ll INF = 1e18;
const double EPS = 1e-8;

long long MODPOW(long long x, long long n) {
    long long ret = 1;
    while (n > 0) {
        if (n & 1) ret = ret * x % MOD;
        x = x * x % MOD;
        n >>= 1;
    }
    return ret;
}

template<typename T,typename U>
bool chmax(T& max, const U& x){
	if(max<x){
		max = x;
		return true;
	}
	return false;
}

template<typename T,typename U>
bool chmin(T& min, const U& x){
	if(min>x){
		min = x;
		return true;
	}
	return false;
}

ll mp[3001][3001];
ll dp[3001][3001][4];

int main(){
	ll r,c,k;
	cin >> r >> c >> k;
	fill(mp[0],mp[0]+(r+1)*(c+1),0);
	for(ll i=0;i<k;i++){
		ll a,b,c;
		cin >> a >> b >> c;
		mp[a][b]=c;
	}
	fill(dp[0][0],dp[0][0]+(r+1)*(c+1)*4,0);

	for(ll i=1;i<=r;i++){
		for(ll j=1;j<=c;j++){
			for(ll k=0;k<4;k++){
				chmax(dp[i][j][0], max(dp[i][j-1][0],dp[i-1][j][k]));
			}
			for(k=1;k<4;k++){
				dp[i][j][k]=dp[i][j-1][k];
			}
			if(mp[i][j]!=0){
				chmax(dp[i][j][3], dp[i][j][2]+mp[i][j]);
				chmax(dp[i][j][2], dp[i][j][1]+mp[i][j]);
				chmax(dp[i][j][1], dp[i][j][0]+mp[i][j]);
			}
		}
	}
	for(ll i=1;i<4;i++){
		chmax(dp[r][c][i],dp[r][c][i-1]);
	}
	cout << dp[r][c][3] << endl;
}

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

int main()
{
  int n, k;
  cin >> n >> k;
  
  vector<int> s(n, 1);
  
  int a, b;
  for (int i = 0; i < k; i++) {
    cin >> a;
    for (int j = 0; j < a; j++) {
      cin >> b;
      s[b-1] = 0;
      //cout << "b:" << b-1 << " s[b]:" << s[b-1] << endl;
    }
  }

  int sum = 0;
  for (int i = 0; i < n; i++) {
      //cout << "i:" << s.at(i) << endl; 
      sum += s.at(i);
  }
  cout << sum << endl;
}


Measured memory_bytes: 3632
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;

int main() {
    int a, b;
    string op;
    int res;
    while (true) {
        cin >> a >> op >> b;
        if (op == "+") {
            res = a + b;
        }
        if (op == "-") {
            res = a - b;
        }
        if (op == "*") {
            res = a * b;
        }
        if (op == "/") {
            res = a / b;
        }
        if (op == "?") {
            break;
        }
        cout << res <<endl;
    }
END:
    return 0;
}




Measured memory_bytes: 3164
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<n;i++)
#define why(n,x) int n;while(cin >>n,n!=x)
#define iFOR(i,x,n)for(int i=x;i<n;i++)

int dx[]={1,0,-1,0};
int dy[]={0,-1,0,1};
int dxx[]={1,1,0,-1,-1,-1,0,1};
int dyy[]={0,-1,-1,-1,0,1,1,1};
bool inside(int x,int y,int w,int h){
  return (x>=0 && y>=0 && x<w && y<h);}
typedef long long ll;
typedef pair<int,int> pii;


int main(){
  cin.tie(0), ios::sync_with_stdio(false);
  int n,a,b;
  cin >>n;
  if(n==1) cout <<"Hello World";
  else{
    cin >>a>>b;
    cout <<a+b;
  }
  cout <<endl;


  

  return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.awt.geom.*;

public class Main{
	
	private void doit(){
		Scanner sc = new Scanner(System.in);
		while(true){
			int n = sc.nextInt();
			int k = sc.nextInt();
			if((n|k) == 0)break;
			int [] data = new int[k];
			for(int i = 0; i < k; i++){
				data[i] = sc.nextInt();
			}
			Arrays.sort(data);
			ArrayList<Integer> notexist = new ArrayList<Integer>();
			notexist.add(0);
			int prev = data[0];
			for(int i = 1; i < k; i++){
				if(prev + 1 != data[i]){
					for(int j = prev + 1; j <= data[i] - 1; j++){
						notexist.add(j);
					}
				}
				prev = data[i];
			}
			notexist.add(data[k-1] + 1);
			if(data[0] == 0){
				if(notexist.size() == 2){
					System.out.println(notexist.get(1) - notexist.get(0));
					continue;
				}
				prev = 0;
				int max = 0;
				for(int i = 2; i < notexist.size(); i++){
					int value = notexist.get(i) - prev - 1;
					max = Math.max(max, value);
					prev = notexist.get(i-1);
				}
				System.out.println(max);
			}
			else{
				prev = 0;
				int max = 0;
				for(int i = 1; i < notexist.size(); i++){
					int value = notexist.get(i) - prev - 1;
					max = Math.max(max, value);
					prev = notexist.get(i);
				}
				System.out.println(max);
			}
		}
	}

	private void debug(Object... o) {
		System.out.println("debug = " + Arrays.deepToString(o));
	}

	public static void main(String[] args) {
		new Main().doit();
	}
}

Measured memory_bytes: 62788
N = int(input())

array = []
for _ in range(0, N):
    array.append(map(int, input().split(' ')))

for a, b, c in array:
    a = a ** 2
    b = b ** 2
    c = c ** 2
    if a + b == c or b + c == a or c + a == b:
        print('YES')
    else:
        print('NO')



Measured memory_bytes: 5976
#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=(n)-1; i>=0; i--)
#define FOR(i,a,b) for(int i=(a); i<(b); i++)
#define RFOR(i,a,b) for(int i=(b-1); i>=(a); i--)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define pb push_back
using ll = long long;
using D = double;
using LD = long double;
using P = pair<int, int>;
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; }

int main(){
    int m,n; cin >> n >> m;
    int tmp = 0;
    vector<int> a(n);
    rep(i,n) {
        cin >> a[i];
        tmp += a[i];
    }
    int can = 0;
    rep(i,n){
        if(a[i]*4*m - tmp >= 0) can++;
    }
    if(can >= m) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 256
import java.io.*;
import java.math.*;
import java.util.*;
public class Main {
	
	public static void main(String[] args) {  
		FastScanner I = new FastScanner(); //Input
		OutPut O = new OutPut(); //Output
		long H = I.nextLong();
		int N = I.nextInt();
		for (int i = 0; i < N; i++) {
			long cur = I.nextLong();
			H-=cur;
		}
		O.pln(H<=0?"Yes":"No");
	}
	public static long ceil(long num, long den) {long ans = num/den; if (num%den!=0) 
	ans++; return ans;}
	public static long GCD(long a, long b) {
		if (a==0||b==0) return Math.max(a,b);
		return GCD(Math.min(a, b),Math.max(a, b)%Math.min(a, b));
	}
	public static long FastExp(long base, long exp, long mod) {
		long ans=1;
		while (exp>0) {
			if (exp%2==1) ans*=base;
			exp/=2;
			base*=base;
			base%=mod;
			ans%=mod;
		}
		return ans;
	}
	public static long ModInv(long num,long mod) {return FastExp(num,mod-2,mod);}
	public static int pop(long x) { //Returns number of bits within a number
		int cnt = 0;
		while (x>0) {
			if (x%2==1) cnt++;
			x/=2;
		}
		return cnt;
	}
	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());}
		long nextLong() {return Long.parseLong(next());};
		double nextDouble() {return Double.parseDouble(next());}
	}
	static class OutPut{
		PrintWriter w = new PrintWriter(System.out);
		void pln(double x) {w.println(x);w.flush();}
		void pln(boolean x) {w.println(x);w.flush();}
		void pln(int x) {w.println(x);w.flush();}
		void pln(long x) {w.println(x);w.flush();}
		void pln(String x) {w.println(x);w.flush();}
		void pln(char x) {w.println(x);w.flush();}
		void pln(StringBuilder x) {w.println(x);w.flush();}
		void pln(BigInteger x) {w.println(x);w.flush();}
		void p(int x) {w.print(x);w.flush();}
		void p(long x) {w.print(x);w.flush();}
		void p(String x) {w.print(x);w.flush();}
		void p(char x) {w.print(x);w.flush();}
		void p(StringBuilder x) {w.print(x);w.flush();}
		void p(BigInteger x) {w.print(x);w.flush();}
		void p(double x) {w.print(x);w.flush();}
		void p(boolean x) {w.print(x);w.flush();}
	}
}

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

int main(){
    int a,b;
    char op;
    while(1){
        cin>>a>>op>>b;
        if(op=='+'){
            cout<<a+b<<endl;
        }else if(op=='-'){
            cout<<a-b<<endl;
        }else if(op=='*'){
            cout<<a*b<<endl;
        }else if(op=='/'){
            cout<<a/b<<endl;
        }else{
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 3088
import sys
a=[0]*2001
b=[0]*4001
n=1001
for i in range(n):
  for j in range(n):
    a[i+j]+=1
n=2001
for i in range(n):
  for j in range(n):
    b[i+j]+=a[i]*a[j]
for i in sys.stdin:
  print b[int(i)]

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

using namespace std;
typedef long long int ll;
typedef pair <ll,ll> P;
#define REP(i, n) for(ll i = 0LL; i < (ll)(n); i++)
#define REPR(i, n) for(ll i = n-1; i >= 0LL; i--)
#define FOR(i, n, m) for(ll i = n; i < (ll)(m); i++)
#define PRINT(x) cout << x << endl
#define ALL(v) v.begin(), v.end()
#define INF (ll)1e18
#define INFD 1e18
#define PI 3.14159265358979
#define MOD 1000000007
#define vl vector<ll>

vector<ll> dx = {-1, 1, 0, 0};
vector<ll> dy = {0, 0, 1, -1};

ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

int main()
{
	ll N;
	cin >> N;
	map<ll, ll> m;
	REP(i, N) {
		ll a;
		cin >> a;
		m[a]++;
	}
	for(P p : m) {
		if (p.second >= 3) {
			PRINT(0);
			return 0;
		}
		if (p.first == 12 && p.second >= 2) {
			PRINT(0);
			return 0;
		}
		if (p.first == 0 && p.second >= 1) {
			PRINT(0);
			return 0;
		}
	}
	vector<bool> v(48, false);
	v[0] = true;
	vector<ll> tmp;
	for(P p : m) {
		if (p.second == 2) {
			v[p.first] = true;
			v[24 - p.first] = true;
		}
		if (p.first == 12) v[12] = true;
		if (p.second == 1) tmp.push_back(p.first);
	}
	ll ans = 0;
	REP(i, pow(2, tmp.size())) {
		REP(j, tmp.size()) {
			if ((i >> j) & 1LL) {
				v[tmp[j]] = true;
			} else {
				v[24-tmp[j]] = true;
			}
		}
		REP(j, 24) v[j+24] = v[j];
		// REP(i, 24) cout << v[i] << " ";
		// cout << endl;
		ll mi = INF;
		REP(s, 24) {
			FOR(t, s+1, 48) {
				if (v[s] && v[t]){
					mi = min(mi, abs(s - t));
				}

			}
		}
		ans = max(mi, ans);
		REP(j, tmp.size()) {
			if ((i >> j) & 1LL) {
				v[tmp[j]] = false;
			} else {
				v[24-tmp[j]] = false;
			}
		}
	}
	PRINT(ans);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
#include <math.h>
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
#define INF 99999999999
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

using llong = long long;
using namespace std;

int main(){
    llong n,d[51],sum = 0;
    cin >> n;
    rep(i,n) cin >> d[i];
    rep(i,n)for(llong j=i+1;j<n;j++){
        sum += d[i]*d[j];
    }
    cout << sum << endl;
}

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

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

const ll mod = 1000000007;
const int mxN = 2005;
const int mxM = 200005;

ll dp[mxN*2][mxN*2], a[mxM], b[mxM];
ll fac[mxN*8], ifac[mxN*8], inv[mxN*8];

void pre(){
	fac[0] = ifac[0] = fac[1] = ifac[1] = inv[1] = 1;
	for(int n = 2; n < mxN*8; n++){
		fac[n] = n*fac[n - 1]%mod;
		inv[n] = (mod - mod/n)*inv[mod%n]%mod;
		ifac[n] = ifac[n - 1]*inv[n]%mod;
	}
}

inline ll ncr(int n, int r){
	if(r < 0 || r > n)return 0;
	return fac[n]*(ifac[r]*ifac[n - r]%mod)%mod;
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cout<<setprecision(32);

	pre();
	memset(dp, 0, sizeof(dp));
	int n;
	cin>>n;
	for(int i = 0; i < n; i++){
		cin>>a[i]>>b[i];
		dp[mxN - a[i]][mxN - b[i]]++;
	}
	for(int i = 0; i + 1 < (mxN<<1); i++){
		for(int j = 0; j + 1 < (mxN<<1); j++){
			if(i){
				dp[i][j] += dp[i - 1][j];
				if(dp[i][j] >= mod)dp[i][j] -= mod;
			}
			if(j){
				dp[i][j] += dp[i][j - 1];
				if(dp[i][j] >= mod)dp[i][j] -= mod;
			}
		}
	}
	ll ans = 0;
	for(int i = 0; i < n; i++){
		ans += dp[mxN + a[i]][mxN + b[i]];
		ans += mod - ncr(2*a[i] + 2*b[i], 2*b[i]);
	}
	ans %= mod;
	ans *= (mod + 1)/2;
	ans %= mod;
	cout<<ans<<endl;


	return 0;
}

Measured memory_bytes: 129408
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>
#include<complex>

using namespace std;

#define ll long long
#define ld long double
#define EPS 1e-9
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef pair<int,pii> pip;
typedef vector<pii> vp;
typedef vector<vi> vvi;

int gcd(int a, int b){if(b==0) return a;return gcd(b,a%b);}
int lcm(int a, int b){return a/gcd(a,b)*b;}


signed main(void) {
    string s;
    int n;
    cin >> n;
    cin >> s;
    if(n >= 3200)cout << s << endl;
    else cout << "red" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#include <fstream>
#include <chrono>
#include <random>
#include <bitset>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(x) ((int)(x).size())
#define pb push_back
using ll = long long;
using namespace std;
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; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}

int main(){
  int R, C, K; cin >> R >> C >> K;
  vector<vector<ll>> A(R, vector<ll>(C, 0));
  rep(k,K){
    int r, c; ll v;
    cin >> r >> c >> v;
    r--;c--;
    A[r][c]=v;
  }
  ll inf=1e17;
  vector<vector<vector<ll>>> dp(R+1, vector<vector<ll>>(C+1, vector<ll>(4, 0)));
  dp[0][0][0]=0;
  dp[0][0][1]=A[0][0];
  rep(r,R){
    rep(c,C){
      if(r==0&&c==0) continue;
      // tate
      if(A[r][c]!=0){
        if(r)rep(i,4) chmax(dp[r][c][0], dp[r-1][c][i]);
        if(r)rep(i,4) chmax(dp[r][c][1], dp[r-1][c][i]+A[r][c]);
      }
      else{
        if(r)rep(i,4) chmax(dp[r][c][i],dp[r-1][c][i]);
      }
      // yoko
      if(A[r][c]!=0){

        if(c)rep(i,3) chmax(dp[r][c][i+1], dp[r][c-1][i]+A[r][c]);
        if(c)rep(i,4) chmax(dp[r][c][i], dp[r][c-1][i]);
      }
      else{
         if(c) rep(i,4) chmax(dp[r][c][i], dp[r][c-1][i]);
      }
    }
  }


  ll ans = 0;
  rep(i,4){
    chmax(ans, dp[R-1][C-1][i]);
    chmax(ans,dp[R][C-1][i]);
    chmax(ans,dp[R-1][C][i]);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 706544
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
#define pb push_back
#define mpr make_pair
#define pii pair<int, int>
#define pll pair<ll, ll>
#define ll long long
#define ld long double
#define all(arr) arr.begin(), arr.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define fo(i, l, r) for (int i = l; i <= r; i++)
#define INF 1000000001
#define inf1 1000000000000000001
#define MOD 1000000007
#define pie 3.14159265358979323846264338327950L
#define N 100005
#define mid(l, r) l + (r - l) / 2
#define vec vector<int>
#define vecl vector<ll>
#define umap unordered_map<ll,ll>
#define yes cout << "YES" << endl;
#define no cout << "NO" << endl;
#define endl "\n"
using namespace std;

int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};  
int ddx[8]={1,1,0,-1,-1,-1,0,1},ddy[8]={0,1,1,1,0,-1,-1,-1};
ll gcd(ll a,ll b){ if(!a)return b;return gcd(b%a,a);}
ll lcm(ll a, ll b) { return (a*b)/ gcd(a,b);}






void test_case() {

    int n, k;
    cin>>n>>k;

    vec arr(n);
    rep(i,n) {
        cin>>arr[i];
    }

    sort(all(arr));

    vector<bool> dp(N+1);


    for(int i=0; i<=k; i++) {
        for(auto it : arr) {
            if( i >= it && dp[i-it] == false) {
                dp[i] = true;
            }
        }
    }

    

    if(dp[k]) {
        cout<<"First"<<endl;
        return;
    } else {
        cout<<"Second"<<endl;
    }











    





    






}


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

    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);


    int t = 1;
    //cin >> t;
    while(t--)
    {   
        test_case();
    }
}


Measured memory_bytes: 3664
X, Y, A, B, C = map(int, input().split())
P = sorted(list(map(int, input().split())), reverse = True)
Q = sorted(list(map(int, input().split())), reverse = True)
R = list(map(int, input().split()))

P = P[:X]
Q = Q[:Y]

D = P + Q + R
D = sorted(D, reverse = True)

print(sum(D[:(X + Y)]))

Measured memory_bytes: 23200
from collections import deque
n, m = map(int, input().split())
neighbor = [[] for _ in range(n)]

for i in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    neighbor[a].append(b)
    neighbor[b].append(a)

minv = [-1] * n
minv[0] = 0
length = [-1] * n
length[0] = 0


def bfs():
    global neighbor, length
    queue = deque([[0, 0]])
    while len(queue) > 0:
        v = queue.popleft()

        for nv in neighbor[v[0]]:
            if length[nv] == -1:
                length[nv] = v[1] + 1
                minv[nv] = v[0] + 1
                queue.append([nv, v[1] + 1])


bfs()

f = True
for i in minv:
    f &= i != -1

if not f:
    print("No")
else:
    print("Yes")
    for i in range(1, n):
        print(minv[i])


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

namespace AtTest.C_Challenge
{
    class ABC_086
    {
        static void Main(string[] args)
        {
            Method(args);
            Console.ReadLine();
        }

        static void Method(string[] args)
        {
            int n = ReadInt();
            var ts = new int[n];
            var xs = new int[n];
            var ys = new int[n];
            for(int i = 0; i < n; i++)
            {
                int[] input = ReadInts();
                ts[i] = input[0];
                xs[i] = input[1];
                ys[i] = input[2];
            }

            int time = 0;
            int nowX = 0;
            int nowY = 0;
            for(int i = 0; i < n; i++)
            {
                int span = ts[i] - time;
                int distance 
                    = Math.Abs(xs[i] - nowX) + Math.Abs(ys[i] - nowY);
                if (distance <= span && distance % 2 == span % 2)
                {
                    time = ts[i];
                    nowX = xs[i];
                    nowY = ys[i];
                    //Console.WriteLine("OK");
                    continue;
                }
                else
                {
                    Console.WriteLine("No");
                    return;
                }
            }
            Console.WriteLine("Yes");
        }

        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 17228
#include <cstdio>
#include <vector>
#include <algorithm>
#include <functional>
#include <map>
#include <set>
#include <string>
#include <iostream>
#include <cassert>
#include <cmath>
using namespace std;

int main() {
	int h, w;
	cin >> h >> w;
	vector<string> s;
	int H = 0;
	for (int i = 0; i < h; i ++) {
		string t;
		cin >> t;
		bool ng = true;
		for (int j = 0; j < (int) t.size(); j ++) {
			if (t[j] == '#') ng = false;
		}
		if (!ng) {
			s.push_back(t);
			H ++;
		}
	}
	vector<bool> ngs(w);
	for (int i = 0; i < w; i ++) {
		bool ng = true;
		for (int j = 0; j < H; j ++) {
			if (s[j][i] == '#') {
				ng = false;
			}
		}
		ngs[i] = ng;
	}
	for (int i = 0; i < H; i ++) {
		for (int j = 0; j < w; j ++) {
			if (!ngs[j]) {
				cout << s[i][j];
			}
		}
		cout << endl;
	}
        return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=(ll)998244353;
const ll INF=(ll)1e18+10;

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

ll powmod(ll a,ll b){
    ll tmp=1ll;
    for (int i = 0; i < b; ++i) {
        (tmp*=a)%=MOD;
    }
    return tmp;
}

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

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

    if(a[0]!=0||cnt[0]>1){
        cout<<0<<endl;
        return 0;
    }
    ll ans=1ll;

    for (int i = 1; i < N; ++i) {
        (ans*=powmod(cnt[i-1],cnt[i]))%=MOD;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, o, n) for (auto i = (o); (i) < (n); ++(i))
#define FOR1(i, n) FOR(i, 1, n+1)
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (auto i = (n)-1; (i) >= 0; --i)
#define REPI(itr, v) for (auto itr = v.begin(); itr != v.end(); ++itr)
#define REPIR(itr, v) for (auto itr = v.rbegin(); itr != v.rend(); ++itr)
#define fi first
#define se second
#define ll long long
#define int long long
#define V2(name, h, w) vector<vector<int> > name((h), vector<int>(w));

#define dl(line) cerr << "RUN: until " << (line) << "th line." << endl
#define dv(name, value) cerr << (name) << " is " << (value) << endl
#define da(v)  cerr << "["; REPI(itr, v){cerr << *itr << (itr != --v.end() ? ", " : "");} cerr << "]" << endl

const string YES = "Yes";
const string NO = "No";

void solve(long long N, long long M, std::vector<long long> A){
  sort(A.begin(), A.end());

  int sum = 0; 
  REP(i, N){sum += A.at(i);}

  bool flag = false;
  int cnt = 0;

  REPIR(itr, A) {
    if (*itr < ceil((double)sum / (4 * M))) break;
    ++cnt;
    if (cnt == M){
      flag = true;
      break;
    } 
  }

  cout << (flag ? YES : NO) << endl;
}

signed main(){
  long long N;
  scanf("%lld",&N);
  long long M;
  scanf("%lld",&M);
  std::vector<long long> A(N);
  for(int i = 0 ; i < N ; i++){
    scanf("%lld",&A[i]);
  }
  solve(N, M, std::move(A));
}


Measured memory_bytes: 256
Scanf.scanf "%s %s" (fun s t ->
    let n = String.length s in
    let cp = Array.make 26 '.' in
    let cq = Array.make 26 '.' in
    let rec loop i =
        if i = n then "Yes" else
            let p = s.[i] in
            let q = t.[i] in
            let pi = int_of_char p - 97 in
            let qi = int_of_char q - 97 in
            if (cp.(pi) = '.' || cp.(pi) = q) &&
               (cq.(qi) = '.' || cq.(qi) = p)  then (
                cp.(pi) <- q;
                cq.(qi) <- p;
                loop (i + 1)
            ) else "No"
    in
    print_endline @@ loop 0
)

Measured memory_bytes: 3200
import java.util.Scanner;

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

        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();

        if(a<b){
            if(b<=c){
                System.out.printf("%d %d %d\n",a,b,c);
            }else if(a>=c){
                System.out.printf("%d %d %d\n",c,a,b);
            }else if(a<c && c<b){
                System.out.printf("%d %d %d\n",a,c,b);
            }
        }else{
            if (a <=c) {
                System.out.printf("%d %d %d\n", b, a, c);
            } else if (b >=c) {
                System.out.printf("%d %d %d\n", c, b, a);
            }else if(b<c && c<a){
                System.out.printf("%d %d %d\n",b,c,a);
            }
        }
    }
}


Measured memory_bytes: 26332
#include<bits/stdc++.h>
using namespace std;
long long int n;
long long int a[200010];
long long int ans = 0;
bool cmp(long long int a,long long int b)
{
	return a>b; 
} 
int main()
{
	scanf("%lld",&n);
	long long int i;
	for(i=0;i<n;i++)
	{
		scanf("%lld",&a[i]);
	}
	sort(a,a+n,cmp);
	if(n>=2)
	{
		ans += a[0]; 
		for(i=2;i<n;i++)
		{
			ans += a[i/2];
		}
	}
	printf("%lld",ans);
}

Measured memory_bytes: 5328
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include <cmath>
#include <limits>
#include <utility>
#include <map>
#include <iomanip>
#include <queue>
#include <cctype>
#include <stack>


#define rep(i,p,q) for(ll i = p;i < q;++i)
#define ll long long

using namespace std;

const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

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

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll npk(ll n, ll k) {
	ll ret = 1;
	if (n < k || n < 0)return 0;
	rep(i, 0, k) {
		ret *= (n - i);
		ret %= MOD;
	}
	if (ret < 0) ret = 0;
	return ret;
}

//134 C
int main(void) {
	ll n;
	cin >> n;
	vector<pair<ll,ll>> a = vector<pair<ll,ll>>(n);
	rep(i, 0, n) {
		ll b;
		cin >> b;
		a[i] = make_pair(b, i);
	}
	sort(a.rbegin(), a.rend());
	vector<ll> ans = vector<ll>(n);
	rep(i, 0, n) {
		if (i == 0) ans[a[i].second] = a[i + 1].first;
		else {
			ans[a[i].second] = a[0].first;
		}
	}
	rep(i, 0, n) {
		cout << ans[i] << endl;
	}
}


Measured memory_bytes: 6272
from collections import defaultdict, deque
import sys
import heapq
import bisect
import itertools
import queue
import copy
import time
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7

def inp(): return int(sys.stdin.readline())

def inpl(): return list(map(int, sys.stdin.readline().split()))

def inpl_str(): return list(sys.stdin.readline().split())

n, m = inpl()
l = [1] * n
a = 0
q = 0
for i in range(m):
    p, s = inpl_str()
    p = int(p)
    if l[p-1] > 0:
        if  s == 'AC':
            q += l[p-1]-1
            l[p-1] = 0
            a+=1
        else:
            l[p-1]+=1
print(a, q)

Measured memory_bytes: 4840
import java.io.*;
import java.math.*;
import java.util.*;
public class Main { //Just use Brute Force
	public static void main(String[] args) { 
		Scanner input = new Scanner(System.in);
		int N = input.nextInt();
		int M = input.nextInt();
		int[][] query = new int[M][2];
		for (int i = 0; i < M; i++) {
			query[i][0] = input.nextInt();
			query[i][1] = input.nextInt();
		}
		int lo = 1;
		while (N>1) {
			lo*=10;
			N--;
		}
		int hi = lo*10;
		if (lo==1) lo--;
		int ans = Integer.MAX_VALUE;
		for (int curNum = lo; curNum < hi; curNum++) {
			boolean bad = false;
			String Num = Integer.toString(curNum);
			for (int i = 0; i < M; i++) {
				int index = query[i][0]-1;
				int digit = query[i][1];
				if (!Num.substring(index,index+1).equals(Integer.toString(digit))) {
					bad = true;
					break;
				}
			}
			if (!bad) {
				ans = curNum;
				break;
			}
		}
		if (ans==Integer.MAX_VALUE) System.out.println(-1);
		else System.out.println(ans);
	}
}

Measured memory_bytes: 22608
#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define INF 1e18

using namespace std;

int a[3];

int check(string s, int d){
  if (d == 3)
    return 1;

  if (s.size() == 0)
    return 0;

  if ((s[0] - '0') == a[d])
    return check(s.substr(1), d + 1);

  return check(s.substr(1), d);
}

int main(void){
  ll n;
  string s;
  cin >> n >> s;
  
  ll res = 0;
  for (int i = 0; i < 10; i++){
    for (int j = 0; j < 10; j++){
      for (int k = 0; k < 10; k++){
        a[0] = i;
        a[1] = j;
        a[2] = k;
        int id = 0;
        for (int l = 0; l < n; l++){
          if (s[l] - '0' == a[id]){
            id++;
          }
          if (id == 3)
            break;
        }
        if (id == 3)
          res++;
      }
    }
  }


  std::cout << res << std::endl;

  return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,s=0,t=0;
    double m;
    cin>>n>>m;
    int a[n];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        t+=a[i];
    }
    for(int i=0;i<n;i++)
    {
        if(a[i]>=t/(4*m))
            s++;
    }
    if(s>=m)
        cout<<"Yes";
    else
        cout<<"No";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(v) v.begin(), v.end()
#define INF 10000000000
#define MOD 1000000007
using namespace std;
int main() {
    int n;
    cin >> n;
    string a, b, c;
    cin >> a >> b >> c;
    string s;
    map<char, int> m;
    rep(i, n) {
        if(a[i] == b[i])
            s += a[i];
        else if(b[i] == c[i])
            s += b[i];
        else
            s += c[i];
    }
    int ans = 0;
    rep(i, n) {
        if(a[i] != s[i]) ans++;
        if(b[i] != s[i]) ans++;
        if(c[i] != s[i]) ans++;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main() {
	int a, b, c, cnt = 0;
	scanf("%d %d %d", &a, &b, &c);
	for (int i = a; i <= b; i++) {
		if (!(c%i)) cnt++;
	}
	printf("%d\n", cnt);

	return 0;
}


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

//+=と=+に注意
//バケツは{0}で初期化しないと不具合を生じる
const int INF = 1001000000;

int main(){
  long int n,k,res=0,sum=0;
  string s;
  cin >> s;
  for (int i= 0;i<s.size();i++){
    if(s[i]=='B')res++;
    if(s[i]=='W')sum+=res;
  }
  cout << sum << endl;
}


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

double a[10000];
int main() {
	int n; scanf("%d", &n);
	rep(i, n)scanf("%lf", &a[i]);
	sort(a, a + n);
	double Max = 0;
	for (int i = 1; i < n - 2; i++) {
		double d = a[i] - a[i - 1];
		Max = max(Max, (a[n - 1] + a[n - 2]) / d);
	}
	Max = max(Max, (a[n - 3] + a[n - 4]) / (a[n - 1] - a[n - 2]));
	printf("%.7lf\n", Max);
}

Measured memory_bytes: 3260
#include <stdio.h>
int main(void){
    int n,min,max,i,a[10000];
    long long sum=0;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&a[i]);
        sum+=a[i];
    }
    max=min=a[0];
    for(i=1;i<n;i++){
        if(a[i]>max)max=a[i];
        if(a[i]<min)min=a[i];
    }
printf("%d %d %lld\n",min,max,sum);
   return 0;
}



Measured memory_bytes: 2104
#include<bits/stdc++.h>
 
using namespace std;
 
#define LL long long int
#define FASTIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
const int oo = 1e9 + 5;
const LL ooll = (LL)1e18 + 5;
const int MOD = 1e9 + 7;
// const int MOD = 998244353;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define rand(l, r) uniform_int_distribution<int>(l, r)(rng)

clock_t start = clock();

const int N = 1e5 + 5;

int d[2][N];
void solve() {
    int n;
    cin >> n;
    for (int i=0;i<n;++i) cin >> d[0][i] >> d[1][i];
    for (int i=0;i+2<n;++i) {
        if (d[0][i] == d[1][i] && d[0][i+1] == d[1][i+1] && d[0][i+2] == d[1][i+2]) {
            cout << "Yes\n";
            return;
        }
    }
    cout << "No\n";
}

int main() {
    FASTIO;
    int T = 1;
    // cin >> T;
    while (T--) {
        solve();
    }
    return 0;
} 

Measured memory_bytes: 3660
#include <math.h>
#include <stdio.h>

int main() {
	int n, i, a, max;

	scanf("%d", &n);
	if (n == 1) {
		printf("1\n");
		return 0;
	}
	max = 0;
	for (i = 0; i < 10; i++)
		if (pow(2, i) <= n && max < i) {
			max = i;
			a = pow(2, max);
		}
	printf("%d\n", a);
	return 0;
}


Measured memory_bytes: 384
n = int(input())
m = []
ans = 0
for i in range(n):
    x,u = input().split()
    m.append([float(x),u])
for i in range(n):
    if m[i][1] == 'BTC':
        ans += m[i][0] * 380000.0
    else:
        ans += m[i][0]
print(ans)

Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;
ll ans[2005]={0};
int main(){
  ll x;
  cin>>x;
  ll ans=0;
  ans+=(x/500)*1000;
  x%=500;
  ans+=(x/5)*5;
  cout<<ans<<endl;
}


Measured memory_bytes: 256
import bisect
N,M,K = map(int,input().split())
A = [0]+list(map(int,input().split()))
K2 =K
count = 0
numa = 0
numb = 0
count2 = 0
for i in range(N+1):
    count += A[i]
    A[i] = count
#累積和
B = [0]+list(map(int,input().split()))
count = 0
for i in range(M+1):
    count += B[i]
    B[i] = count
#累積和

for i in range(N+1):#Aに対してBを探す
    K = K2
    if A[i] <= K:
        K -= A[i]
        if count2 < i + bisect.bisect_right(B, K):
            count2 = i + bisect.bisect_right(B, K)-1
    else:
        break
print(count2)

Measured memory_bytes: 45168
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, n) for(int i=0; i<int(n); i++)
#define RNG(i, f, t) for(int i=int(f); i<=int(t); i++)
bool RELAXED = false;
template<int,typename T> struct MINMAX{ T val; MINMAX(T val) : val(val) {} };
template<typename T> MINMAX<1,T> MAX(T val) { return MINMAX<1,T>(val); };
template<typename T> MINMAX<2,T> MIN(T val) { return MINMAX<2,T>(val); };
template<typename T, typename U> inline T& operator|=(T &lhs, MINMAX<1,U> rhs) { return lhs = (rhs.val > lhs ? (RELAXED=true,rhs.val) : (RELAXED=false,lhs)); }
template<typename T, typename U> inline T& operator|=(T &lhs, MINMAX<2,U> rhs) { return lhs = (rhs.val < lhs ? (RELAXED=true,rhs.val) : (RELAXED=false,lhs)); }
template<typename T> inline vector<T> readVector(int n) { vector<T> vec(n); FOR(i,n) cin>>vec[i]; return vec; }
template<typename T> void EXIT(T answer) { cout<<answer<<endl; exit(0); }
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pii> vpii;
typedef signed long long int ll;

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

    int n; cin>>n;
    vi a = readVector<int>(n);

    map<int, int> occ;
    for(auto x : a) {
        occ[x]++;
    }

    ll total=0;
    for(auto e : occ) {
        total += 1LL * e.second * (e.second-1) / 2;
    }

    FOR(k,n) {
        ll ans = total;
        ll es = occ[a[k]];
        ans -= es * (es-1) / 2;
        ans += (es-1) * (es-2) / 2;
        cout<<ans<<endl;
    }
}



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

typedef long long ll;
typedef pair<int, int> ii;

string s ,t;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  
  cin >> s >> t;
  cout << t + s << endl;
  
  return 0;
}


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

public class Main {

	public static void main(String[] args) throws NumberFormatException,
			IOException {
		BufferedReader reader = new BufferedReader(new InputStreamReader(
				System.in));
		StringBuilder builder = new StringBuilder();
		String line;

		while ((line = reader.readLine()) != null) {
			if (line.isEmpty())
				break;
			StringTokenizer tokenizer = new StringTokenizer(line);
			double[] x = new double[4];
			double[] y = new double[4];
			for (int i = 0; i < 4; i++) {
				x[i] = Double.parseDouble(tokenizer.nextToken());
				y[i] = Double.parseDouble(tokenizer.nextToken());
			}
			if (x[0] > x[3] || x[1] < x[2] || y[0] > y[3] || y[1] < y[2]) {
				System.out.println("NO");
			} else {
				System.out.println("YES");
			}
		}
	}
}

Measured memory_bytes: 16932
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,t=0,x=0,y=0,f=0;
    cin>>n;
    for(int i=0,tt,tx,ty;i<n;i++)
    {
        cin>>tt>>tx>>ty;
        if((abs(tx-x)+abs(ty-y))%2!=(tt-t)%2||abs(tx-x)+abs(ty-y)>(tt-t))
            f=1;
        t=tt,x=tx,y=ty;
    }
    if(!f)cout<<"Yes";
    else cout<<"No";
    return 0;
}


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

ll inf = 1e9;

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

  vector<ll>last(26, -1);
  vector<ll>vec(d);

  for(int i=0;i<d;i++){
    ll t = (-1)*inf;
    for(int j=0;j<26;j++){

        ll sat = s[i][j];

        for(int k=0;k<26;k++){
          if(k == j) continue;
          sat -= c[k]*(d+1 - (last[k]+1));
        }

        if(sat > t){
          t = sat;
          last[j] = i;
          vec[i] = j;
        }

    }
  }

  for(int i=0;i<d;i++) cout << vec[i]+1 << endl;
}


Measured memory_bytes: 3716
#include <bits/stdc++.h>
 
#define endl '\n'
#define fi first
#define se second
#define MOD(n,k) ( ( ((n) % (k)) + (k) ) % (k))
#define forn(i,n) for (int i = 0; i < (n); i++)
#define forr(i,a,b) for (int i = (a); i <= (b); i++)
#define all(v) v.begin(), v.end()
#define pb push_back
 
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<ii> vii;

const int MX = 3005, mod = 998244353;
int n, s, a[MX];
ll mem[MX][MX];

ll dp (int i, int j) {
	if (j < 0) return 0;
	if (j == 0) return n - i + 1;
	if (i == n) return 0;

	ll &res = mem[i][j];
	if (res != -1) return res;
	res = 0;

	if (j == s) res = (i + 1) * dp(i + 1, j - a[i]);
	else res = dp(i + 1, j - a[i]);
	res += dp(i + 1, j);

	res %= mod;
	return res;
}

int main () {
	ios_base::sync_with_stdio(0); cin.tie(0);
	
	cin >> n >> s;
	forn (i, n) cin >> a[i];

	memset(mem, -1, sizeof(mem));
	cout << dp(0, s) << endl;

	return 0;
}

Measured memory_bytes: 70912
#include <iostream>
#include <cstdio>
#include <cstdlib>

using namespace std;

struct Node {
    int id;
    Node *parent;
    int child_num;
    Node **childlen;
};

int n;
Node nodes[100000];

int main(void) {

    scanf("%d", &n);

    for (int i = 0, id, n2; i < n; ++i) {
        scanf("%d", &id);
        scanf("%d", &n2);
        nodes[id].id = id;
        nodes[id].child_num = n2;
        nodes[id].childlen = new Node*[n2];
        for (int j = 0, id2; j < n2; ++j) {
            scanf("%d", &id2);
            nodes[id].childlen[j] = &nodes[id2];
            nodes[id2].id = id2;
            nodes[id2].parent = &nodes[id];
        }
    }

    for (int i = 0; i < n; ++i) {

        int depth = -1;
        Node *node = &nodes[i];
        while (node) {
            node = node->parent;
            ++depth;
        }

        const char *type = "internal node";
        if (nodes[i].parent == NULL) {
            type = "root";
        }
        else if (nodes[i].child_num == 0) {
            type = "leaf";
        }

        printf("node %d: parent = %d, depth = %d, %s, [",
                nodes[i].id, (nodes[i].parent ? nodes[i].parent->id : -1),
                depth, type);
        for (int j = 0, f = 0; j < nodes[i].child_num; ++j) {
            if (f) {
                printf(", %d", nodes[i].childlen[j]->id);
            }
            else {
                f = 1;
                printf("%d", nodes[i].childlen[j]->id);
            }
        }
        printf("]\n");
    }

    for (int i = 0; i < n; ++i) {
        if (nodes[i].child_num) {
            delete[] nodes[i].childlen;
        }
    }

    return 0;
}

Measured memory_bytes: 8108
import collections
s = input()
_q = int(input())
q = collections.deque(s)

rev = False
for _ in range(_q):
    *query, = map(str, input().split())

    if query[0] == "1":
        rev = not rev
        continue

    f, c = query[1], query[2]

    if rev ^ (f == "1"):
        q.appendleft(c)
    else:
        q.append(c)

if rev:
    q.reverse()

print("".join(q))


Measured memory_bytes: 8692
#include <iostream>
using namespace std;
int main (void) {
    int a;
    int b;
    int c;
    int x;
    int ans = 0;

    cin >> a >> b >> c >> x;

    for (int i = 0; i <= a; i++) {
        for (int j = 0; j <= b; j++) {
            for (int k = 0; k <= c; k++) {
                if (500 * i + 100 * j + 50 * k == x) ans++;
            }
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bits/stdc++.h>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;

#define rep(X, Y) for (int(X) = 0; (X) < (Y); ++(X))
#define rrep(X, Y) for (int(X) = (Y)-1; (X) >= 0; --(X))
#define all(X) (X).begin(), (X).end()
#define pb push_back
#define mp make_pair
#define fi first
#define sc second
#define print(x) cout << x << endl

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

const long long MOD = 1000000007;

void solve(long long N, long long M, std::vector<long long> A,
           std::vector<long long> B) {
  sort(all(A));
  sort(all(B));

  ll ans = 1;
  for (ll x = N * M; x >= 1; x--) {
    if ((upper_bound(all(A), x) - lower_bound(all(A), x) > 1) ||
        (upper_bound(all(B), x) - lower_bound(all(B), x) > 1)) {
      ans = 0;
      break;
    }

    bool aExists = binary_search(all(A), x);
    bool bExists = binary_search(all(B), x);
    ll num = 1;
    if (aExists && !bExists) {
      num = B.end() - lower_bound(all(B), x);
    } else if (!aExists && bExists) {
      num = A.end() - lower_bound(all(A), x);
    } else if (!aExists && !bExists) {
      num = (B.end() - lower_bound(all(B), x)) *
                (A.end() - lower_bound(all(A), x)) -
            (N * M - x);
    }
    ans *= num;
    ans %= MOD;
  }
  print(ans);
}

int main() {
  long long N;
  scanf("%lld", &N);
  long long M;
  scanf("%lld", &M);
  std::vector<long long> A(N);
  for (int i = 0; i < N; i++) {
    scanf("%lld", &A[i]);
  }
  std::vector<long long> B(M);
  for (int i = 0; i < M; i++) {
    scanf("%lld", &B[i]);
  }
  solve(N, M, std::move(A), std::move(B));
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define MIN -1000000
using namespace std;
typedef long long ll;
typedef pair <int,int> pii;
typedef pair<ll,ll> pll;
const int MOD=1e9+7;
ll ans=0;
template <typename A,size_t N,typename T>
void Fill(A (&array)[N],const T &val)
{
  fill((T*)array,(T*)(array+N),val);
}


const int MAX_V=15;
int V=10;
int H,W;
int d[MAX_V][MAX_V];
void warshall_floyd()
{
  for(int k=0;k<V;k++)
    {
      for(int i=0;i<V;i++)
	{
	  for(int j=0;j<V;j++)
	    {
	      d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
	    }
	}
    }
}


int main(void)
{
  cin >> H >> W;
  for (int i = 0; i < 10; ++i)
    {
      for (int j = 0; j < 10; ++j)
	{
	  cin >> d[i][j];
	}
    }
  warshall_floyd();
  for (int i = 0; i < H; ++i)
    {
      for (int j = 0; j < W; ++j)
	{
	  int A;
	  cin >> A;
	  if(A!=-1)
	    {
	      ans+=d[A][1];
	    }
	}
    }
 cout << ans << endl;
}


Measured memory_bytes: 256