akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        long d = sc.nextLong();
        long need = d * d;
        int ans = 0;
        for (int i = 0; i < n; i++) {
            long x = sc.nextLong();
            long y = sc.nextLong();
            if (x * x + y * y <= need) {
                ans++;
            }
        }

        System.out.println(ans);
    }
}

Measured memory_bytes: 59880
#include<bits/stdc++.h>
using namespace std;
vector<pair<int,bool>> g[101111];
bool vis[201111];
bool col[101111];
void dfs(int x)
{
    vis[x] = 1;
    for(int i=0;i<g[x].size();++i)
    {
        if(!vis[g[x][i].first])
        {
            col[g[x][i].first] = col[x] ^ g[x][i].second;
            dfs(g[x][i].first);
        }
    }
}
int main()
{
    int n;
    cin>>n;
    for(int i=1;i<n;++i)
    {
        int x,y,w;
        cin>>x>>y>>w;
        g[x].push_back({y,w%2});
        g[y].push_back({x,w%2});
    }
    dfs(1);
    for(int i=1;i<=n;++i)
    {
        cout<<col[i]<<endl;
    }
}

Measured memory_bytes: 8192
#include<cstdio>
#include<cstring>
#include<algorithm>
#define ll long long
using namespace std;
const int N=1000010,P=998244353;
inline int read(){
	int x=0,f=0,c=getchar();
	for(;c>'9'||c<'0';f=c=='-',c=getchar());
	for(;c>='0'&&c<='9';c=getchar())
	x=(x<<1)+(x<<3)+c-'0';return f?-x:x;
}
inline void write(ll x){
	if(x<0)putchar('-'),x=-x;
	if(x>9)write(x/10);
}
#include<bitset>
bitset<510>f[510];
int n,m,x[N],y[N],ans,del[N];
void bfs(int s,bitset<510>&f){
	f[s]=1;for(int i=m;i;i--){
		if(f[x[i]]&&f[y[i]]){del[s]=1;return;}
		if(f[x[i]])f[y[i]]=1;
		if(f[y[i]])f[x[i]]=1;
	}
}
int main(){
	//freopen("1.out","w",stdout);
	int i,j;
	n=read();m=read();
	for(i=1;i<=m;i++)x[i]=read(),y[i]=read();
	for(i=1;i<=n;i++)bfs(i,f[i]);
	for(i=1;i<=n;i++)
		for(j=i+1;j<=n;j++)
			if(!del[i]&&!del[j])ans+=(f[i]&f[j]).count()==0;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 8448
import sys

s = sys.stdin.readline().rstrip()

def main():
    if s[0] == 'A':
        if 'C' in s[2:-1]:
            cnt = 0
            for letter in s:
                if 65 <= ord(letter) <= 90:
                    cnt += 1
            if cnt == 2:
                return 'AC'
    return 'WA'

if __name__ == '__main__':
    ans = main()
    print(ans)

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

int main(){
	int N,K,i;
  double min = 100000000000000,result=0;
  scanf("%d %d",&N,&K);
  
  for(i=0;i<=N;i++){
  	result =  pow(2,(double)(N-i));
    result = result + i*K;
    if(result <min) min = result;
    result = 0;
  }
  printf("%.0f\n",min);
  return 0;

}

Measured memory_bytes: 512
#include<iostream>
using namespace std;
int main(){
    int H,W,i,j;
    while(true){
        cin>>H >>W;
        if(H==0&W==0){
            break;
        }
        for(i=0;i<H;i++){
            for(j=0;j<W;j++){
                cout<<"#";
            }
            cout<<endl;
        }
        cout<<endl;
    }
    return 0;
}


Measured memory_bytes: 3068
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <stdio.h>
using namespace std;

#define rep(i,n) for(ll i=0;i<(n);++i)
using ll = long long;
using pll = pair<ll, ll>;
constexpr ll INF = (1LL << 60);
constexpr ll MOD = (1e9 + 7);
//constexpr ll MOD = (998244353);

using vl = vector<ll>;
using vvl = vector<vector<ll>>;

//template<class T>vector<T> vec(size_t a) { return vector<T>(a); }

long long modinv(long long a, long long m) {
	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;
}

ll maxVec(vector<ll> &v) {
	ll ans = -INF;
	rep(i, v.size()) {
		ans = max(ans, v[i]);
	}
	return ans;
}


int main() {
	
	auto comp =  [](const pll a, const pll b) { return a.first > b.first; };
	priority_queue<pll, vector<pll>, decltype(comp)> que(comp);

	ll v, e, r,s,t,d;
	pll a;
	cin >> v >> e >> r;
	vector<vector<pll>> graph(v, vector<pll>(0));
	rep(i, e) {
		cin >> s >> t >> d;
		graph[s].push_back(pll{t,d});
	}
	que.push(pll{ 0, r });

	vl ans(v, INF);
	ans[r] = 0;

	while (!que.empty()) {
		ll c = que.top().first, p = que.top().second;
		que.pop();
		rep(i, graph[p].size()) {
			a = graph[p][i];
			if (ans[a.first] > a.second + c) {
				ans[a.first] = a.second + c;
				que.push(pll{ a.second + c,a.first });
			}
		}
	}
	rep(i, v) {
		if (ans[i] == INF) {
			cout << "INF" << endl;
		}
		else {
			cout << ans[i] << endl;
		}
	}
}


Measured memory_bytes: 19428
#include <bits/stdc++.h>
using namespace std;
const long long mod = pow(10, 9) + 7;
const long long INF = 1LL << 60;
template <class T> bool chmin(T& a, T b){if (a > b) {a = b; return true;} return false;}
template <class T> bool chmax(T& a, T b){if (a < b) {a = b; return true;} return false;}
int divCeil(int A, int B) {return (A + (B - 1)) / B;}
long long divCeil(long long A, int B) {return (A + (B - 1)) / B;}
long long divCeil(int A, long long B) {return (A + (B - 1)) / B;}
long long divCeil(long long A, long long B) {return (A + (B - 1)) / B;}

int main()
{
  int X, Y, Z, K;
  cin >> X >> Y >> Z >> K;
  vector<long long> A(X), B(Y), C(Z);
  for (int i = 0; i < X; i++) cin >> A.at(i);
  for (int i = 0; i < Y; i++) cin >> B.at(i);
  for (int i = 0; i < Z; i++) cin >> C.at(i);
  
  sort(A.begin(), A.end(), greater<long long>());
  sort(B.begin(), B.end(), greater<long long>());
  sort(C.begin(), C.end(), greater<long long>());
  
  vector<long long> ABC;
  for (int i = 0; i < X; i++)
  {
    for (int j = 0; j < Y; j++)
    {
      for (int k = 0; k < Z; k++)
      {
        if ((i + 1) * (j + 1) * (k + 1) > K) break;
        ABC.push_back(A.at(i) + B.at(j) + C.at(k));
      }
    }
  }
  
  sort(ABC.begin(), ABC.end(), greater<long long>());
  
  for (int i = 0; i < K; i++) cout << ABC.at(i) << endl;
}

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

#define ll long long
#define MAX 300005
#define pp pair<int,pair<int,int>>
#define pb push_back
#define mod 1000000007
using namespace std;

/*
 * author: Kruti_20
 */

ll power(ll x, ll y);

ll gcd(ll a, ll b);

ll dp[105][MAX];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n, k;
    cin >> n >> k;
    ll a[n + 1];
    for (int i = 1; i <= n; i++) cin >> a[i];
    for (int i = 0; i <= a[1]; i++) dp[1][i] = i + 1;
    for (int i = a[1] + 1; i <= k; i++) dp[1][i] = dp[1][a[1]];
    for (int i = 2; i <= n; i++) {
        for (int j = 0; j <= k; j++) {
            dp[i][j] = (dp[i][j] + dp[i - 1][j]) % mod;
            if (j > 0) dp[i][j] = (dp[i][j] + dp[i][j - 1]) % mod;
            if (j > a[i]) dp[i][j] = (dp[i][j] + mod - dp[i - 1][j - a[i] - 1]) % mod;
        }
    }
    cout << (dp[n][k] - dp[n][k-1] + mod) % mod << "\n";
    return 0;
}


ll power(ll x, ll y) {
    ll res = 1;
    x = x % mod;
    while (y > 0) {
        if (y & 1) res = (res * x) % mod;
        y = y >> 1;
        x = (x * x) % mod;
    }
    return res;
}

ll gcd(ll a, ll b) {
    if (b == 0) return a;
    return gcd(b, a % b);
}


Measured memory_bytes: 233728
//2724 東海林 匠美 問１
import java.util.Scanner;
public class Main{
    int high;
    int low;
    int sa;
    
    public void solve(){
		Scanner sc = new Scanner(System.in);
      for(int i=0; i<7; i++){
	  	high=sc.nextInt();
		low=sc.nextInt();
		sa=high-low;
		System.out.println(sa);
      }
    }
	    public static void main(String[] args){
        Main obj = new Main();
        obj.solve();
    }
}

Measured memory_bytes: 17172
#include<stdio.h>
#include<algorithm>
#include<string.h>
#include<string>
#include<math.h>
#include<stdlib.h>
#include<time.h>
#include<map>
#include<queue>
#include<set>
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)
using namespace std;
int n;
long long a[300000],ans;
int main(){
	scanf("%d",&n);
	fo(i,1,n) scanf("%lld",&a[i]);
	fo(i,2,n) a[i]+=a[i-1];
	ans=abs(a[1]-(a[n]-a[1]));
	fo(i,2,n-1){
		long long te=abs(a[i]-(a[n]-a[i]));
		if (te<ans) ans=te;
	}
	printf("%lld\n",ans);
	return 0;
}

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

using namespace std;

const int MAX = 3010 ;
long double dp[MAX][MAX] ;
int n ;
long double arr[MAX] ;

long double solve(int idx , int h)
{
    if(idx == n)
    {
        if(h >= (n+1)/2)
            return 1.00;
        else
            return 0.00 ;
    }
    long double &ret = dp[idx][h] ;
    if(fabs(ret+1) > 1e-9)
        return ret ;
    ret = arr[idx] * solve(idx+1 , h+1) ;
    ret += (1 - arr[idx]) * solve(idx+1 , h) ;
    return ret ;
}

int main()
{
    memset(dp , -1 , sizeof(dp));
    cin>>n ;
    for(int i = 0 ; i < n ; ++i)
        cin>>arr[i] ;
    return cout<<fixed<<setprecision(12)<<solve(0 , 0)<<"\n" , 0 ;
}


Measured memory_bytes: 142080
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  
  for (int i = 0; i < N; i++) {
    string S_i;
    cin >> S_i;
    
    if (S_i == "Y") {
      cout << "Four" << endl;
      break;
    }
    
    if (i == N-1) {
      cout << "Three" << endl;
    }
  }
  
}

Measured memory_bytes: 256
#include<stdio.h>
 
int main(void){
  int N;
  long p=1;
  scanf("%d",&N);
  for(int i=1;i<=N;i++){
    p *= i;
    p %=  1000000007;
  }
 
 
  printf("%ld\n",p);
  return 0;
}

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

#define each(i,a) for (auto&& i : a)
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
#define pb push_back
#define all(a) (a).begin(),(a).end()
#define chmin(x,v) x = min(x, v)
#define chmax(x,v) x = max(x, v)

const ll linf = 1e18;
const double eps = 1e-12;
const double pi = acos(-1);

template<typename T>
istream& operator>>(istream& is, vector<T>& vec) {
    each(x,vec) is >> x;
    return is;
}
template<typename T>
ostream& operator<<(ostream& os, const vector<T>& vec) {
    rep(i,vec.size()) {
        if (i) os << " ";
        os << vec[i];
    }
    return os;
}
template<typename T>
ostream& operator<<(ostream& os, const vector< vector<T> >& vec) {
    rep(i,vec.size()) {
        if (i) os << endl;
        os << vec[i];
    }
    return os;
}
class Parser {
    string s;
    ll pos;
    ll E() {
        ll res = T();
        while (!end() && (nchar() == '+' || nchar() == '-')) {
            if (nchar() == '+') {
                read_char('+');
                res += T();
            }
            else {
                read_char('-');
                res -= T();
            }
        }
        return res;
    }
    ll T() {
        ll res = number();
        while (!end() && (nchar() == '*' || nchar() == '/')) {
            if (nchar() == '*') {
                read_char('*');
                res *= number();
            }
            else {
                read_char('/');
                res /= number();
            }
        }
        return res;
    }
    ll number() {
        if (nchar() == '(') {
            read_char('(');
            ll res = E();
            read_char(')');
            return res;
        }
        else {
            string res = "";
            while (!end() && isdigit(nchar())) {
                res += nchar();
                ++pos;
            }
            return stoll(res);
        }
    }
    bool end() {
        return nchar() == '=';
    }
    char nchar() {
        assert(pos < s.size());
        return s[pos];
    }
    void read_char(char c) {
        assert(!end() && nchar() == c);
        ++pos;
    }
public:
    Parser(const string& s) : s(s), pos(0) {}
    ll parse() {
        pos = 0;
        return E();
    }
};
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll T; cin >> T;
    rep(t, T) {
        string s; cin >> s;
        cout << Parser(s).parse() << endl;
    }
}



Measured memory_bytes: 3140
#include <stdio.h>
#include <string.h>

void hshuffle(int *dst, int* src, int n, int c, int p)
{
  memcpy(dst + 1, src + 1, (n - c - p + 1) * sizeof(int));
  memcpy(dst + n - c - p + 2,  src + n - p + 2, (p - 1) * sizeof(int));
  memcpy(dst + n - c + 1, src + n - c - p + 2, c * sizeof(int));
}

int main()
{
  int h[2][51];
  int i, j;
  int n, r;
  int p, c;

  while (1) {
    for (i = 0; i < 51; i++) {
      h[0][i] = h[1][i] = i;
    }
    scanf("%d %d", &n, &r);
    if (n == 0 && r == 0) break;
    for (i = 0; i < r; i++) {
      scanf("%d %d", &p, &c);
      if (!(i % 2)) {
        hshuffle(h[1], h[0], n, c, p);
      } else {
        hshuffle(h[0], h[1], n, c, p);
      }
    }
    r % 2 ? printf("%d\n", h[1][n]) : printf("%d\n", h[0][n]);
  }

  return 0;
}
        
               
          



Measured memory_bytes: 1984
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define N 100010
char s[N];
int cur1, cur2, ans;
int main()
{
    scanf("%s", s + 1);
    int n = strlen(s + 1);
    if (s[1] == 'p')
        ans = -1;
    cur2 = 1;
    for (int i = 2; i <= n; i++) {
        if (s[i] == 'p') {
            if (cur1 < cur2) {
                cur1++;
            } else
                ans--, cur2++;
        } else {
            if (cur1 < cur2) {
                cur1++;
                ans++;
            } else
                cur2++;
        }
    }
    printf("%d\n", ans);
    //system("pause");
    return 0;
}

Measured memory_bytes: 384
#include<cstdio>
#include<string>
#include<cstring>

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

using namespace std;

string solve(const string &s){
	int n=s.length();
	static int dp[2001][2001],from[2001][2001];

	rep(i,n+1) dp[i][0]=dp[0][i]=0, from[i][0]=from[0][i]=-1;

	rep(i,n) rep(j,n-i) {
		if(s[i]==s[n-j-1]){
			dp[i+1][j+1]=dp[i][j]+1;
			from[i+1][j+1]=2;
		}
		else{
			if(dp[i][j+1]<dp[i+1][j]){
				dp[i+1][j+1]=dp[i+1][j];
				from[i+1][j+1]=1;
			}
			else{
				dp[i+1][j+1]=dp[i][j+1];
				from[i+1][j+1]=0;
			}
		}
	}

	int len=0,i_len[2];
	for(int i=1;i<n;i++){
		int tmp=2*dp[i][n-i];
		if(len<tmp){
			len=tmp;
			i_len[0]=i;
			i_len[1]=n-i;
		}

		tmp=2*dp[i][n-i-1]+1;
		if(len<tmp){
			len=tmp;
			i_len[0]=i;
			i_len[1]=n-i-1;
		}
	}

	int idx=dp[i_len[0]][i_len[1]];
	string ans(idx,'@');
	for(int i=i_len[0],j=i_len[1];~from[i][j];){
		switch(from[i][j]){
			case 0: i--; break;
			case 1: j--; break;
			case 2: i--; j--; idx--; ans[idx]=s[i]; break;
		}
	}
	if(len%2==1) ans+=s[i_len[0]];
	rep(i,len/2) ans+=ans[len/2-i-1];

	return ans;
}

int main(){
	for(char s[2001];~scanf("%s",s);) puts(solve(s).c_str());
	return 0;
}

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

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

	static final int A = 1000000, MD = 1000000007;
	int power(long a, int k) {
		long p = 1;
		while (k > 0) {
			if ((k & 1) == 1)
				p = p * a % MD;
			a = a * a % MD;
			k >>= 1;
		}
		return (int) p;
	}
	void main() {
		int n = sc.nextInt();
		int[] aa = new int[n];
		int[] kk = new int[A];
		for (int i = 0; i < n; i++) {
			int a = aa[i] = sc.nextInt();
			for (int p = 2; p <= a / p; p++)
				if (a % p == 0) {
					int k = 0;
					while (a % p == 0) {
						k++;
						a /= p;
					}
					kk[p] = Math.max(kk[p], k);
				}
			if (a > 1)
				kk[a] = Math.max(kk[a], 1);
		}
		long m = 1;
		for (int a = 2; a < A; a++)
			if (kk[a] > 0)
				m = m * power(a, kk[a]) % MD;
		long ans = 0;
		for (int i = 0; i < n; i++) {
			int a = aa[i];
			long b = m;
			for (int p = 2; p <= a / p; p++)
				if (a % p == 0) {
					int k = 0;
					while (a % p == 0) {
						k++;
						a /= p;
					}
					b = b * power(p, MD - 1 - k) % MD;
				}
			if (a > 1)
				b = b * power(a, MD - 1 - 1) % MD;
			ans = (ans + b) % MD;
		}
		println(ans);
	}
}


Measured memory_bytes: 52316
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>

using namespace std;
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
constexpr int MOD = 1000000007;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
constexpr int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
constexpr int dy[] = {0, -1, 0, 1, 1, -1, -1, 1};

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){os << "["; for (const auto &v : vec) {os << v << ","; } os << "]"; return os; }


void solve() {
    vector<ll> C(4);
    vector<pll> P(4);
    for (int i = 0; i < 4; ++i) {
        cin >> C[i];
        P[i] = {(1 << (3 - i)) * C[i], i};
    }
    sort(P.begin(), P.end());
    ll N;
    cin >> N;
    N *= 4;
    
    int now = 0;
    int i = P[now].second;
    ll sum = 0;
    while(N > 0) {
        sum += C[i] * (N / (1 << i));
        N %= (1 << i);
        i = P[++now].second;
    }
    cout << sum << endl;
    
}

int main() {
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
N = int(input())
A = list(map(int, input().split()))

count = 0
dict_height = {}

for i in range(N):
  target = i+1-A[i]
  if target in dict_height.keys():
    count += dict_height[target]
  height = i+1+A[i]
  if height in dict_height.keys():
    dict_height[height] += 1
  else:
    dict_height[height] = 1

print(count)

Measured memory_bytes: 40516
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int w = sc.nextInt();
		int h = sc.nextInt();
		int in = 0;
		int out = 0;
		int n = sc.nextInt();
		int count = 0;
		for (int i = 0; i < n; i++) {
		    int x = sc.nextInt();
		    if (x == 0) {
		        out++;
		    } else {
		        in++;
		    }
		    if (out < w - 1) {
		        if (in == out) {
		            count++;
		        }
		    } else if (out > w - 1 && out < w - 1 + h - 1) {
		        if (in + 2 == out) {
		            count++;
		        }
		    } else if (out > w - 1 + h - 1) {
		        if (in + 4 == out) {
		            count++;
		        }
		    }
		}
	    System.out.println(count);
	}
}



Measured memory_bytes: 26416
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(0);

  Int n,m;
  cin>>n>>m;
  vector<vector<Int> > G(n);
  for(Int i=0;i<m;i++){
    Int x,y;
    cin>>x>>y;
    x--;y--;
    G[x].emplace_back(y);
    //G[y].emplace_back(x);
  }
  Int s,t;
  cin>>s>>t;
  s--;t--;
  vector<vector<Int>> dp(3,vector<Int>(n,-1));
  using P = pair<Int, Int>;
  queue<P> que;
  dp[0][s]=0;
  que.emplace(0,s);
  while(!que.empty()){
    Int d,v;
    tie(d,v)=que.front();que.pop();
    Int nd=(d+1)%3;
    for(Int u:G[v]){
      if(~dp[nd][u]) continue;
      dp[nd][u]=dp[d][v]+1;
      que.emplace(nd,u);
    }
  }
  if(~dp[0][t]) dp[0][t]/=3;
  cout<<dp[0][t]<<endl;
  return 0;
}


Measured memory_bytes: 8832
#define rep(i, a, b) for(int i = a; i < (int)(b); i++)
#include <bits/stdc++.h>

typedef long long ll;
using namespace std;
template<class T> inline void chmax(T &a, const T &b) {if(a < b) a = b;}
template<class T> inline void chmin(T &a, const T &b) {if(a > b) a = b;}
const long long INF = 1LL<<60;
const long long MOD = (ll)1e9+7;
// const long long MOD = (ll)1e6+3;
const long long MAX = (ll)1e5+10;

// GCD, LCM
long long GCD (long long C, long long D) {
   while (1) {
      if (C == 0 || D == 0) break;
      if (D>C) D -= (D/C)*C;
      else C -= (C/D)*D;
   }
   return max(C,D);
}

long long LCM(long long C, long long D) {
   return C / GCD(C,D) * D;
}

int main(void) {
    ll N,M;
    cin>>N>>M;
    vector<ll> A(N);
    rep(i,0,N) cin>>A[i];
    sort(A.begin(),A.end());
    ll now = 1;
    rep(i,0,N) {
        now = LCM(now,(ll)(A[i]/2));
        if (now>M) {
            cout<<0<<endl;
            return 0;
        }
    }
    // cout<<now<<endl;

    rep(i,0,N) {
        if ((now*2/A[i])%2==0) {
            cout<<0<<endl;
            return 0;
        }
    }
    ll ans = M / now;
    ans = (ans+1)/2;
    cout<<ans<<endl;









   return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define DEBUG if(0)
#define lli long long int
#define ldouble long double
using namespace std;

lli h, w;

int main()
{
  while (scanf("%lld %lld", &h, &w) != EOF)
  {
    lli ans = ((w >> 1LL) + (w & 1LL)) * ((h >> 1LL) + (h & 1LL));
    ans += (w >> 1LL) * (h >> 1LL);
    if (h == 1 || w == 1)
      ans = 1;
    printf("%lld\n", ans);
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <set>
#include <vector>
#include <string>
#include <algorithm>
#include <iterator>
#include <map>
#include <utility>
#include <list>
#include <climits>
#include <bitset>
#include <numeric>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i, n) for(auto i = (n).begin(); i != (n).end(); i++)
#define in_arr(type, a, n) copy_n(istream_iterator<type>(cin), n, (a).begin());
#define ll long long int

int gcd(int a, int b){
    int c;
    while(b > 0){
        c = a % b;
        a = b;
        b = c;
    }
    return a;
}

int main(){
    int a, b, c;
    cin >> a >> b >> c;
    int d = gcd(a, b);
    if(d == 1){
        cout << "YES" << endl;
    }else if(a % b == 0 && c == 0){
        cout << "YES" << endl;
    }else if(c % d == 0){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
    return 0;
}


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

using namespace std;
typedef long long ll;

int main(){
    ll H,W;cin >> H >> W;
    ll ans=min(H,W);
    ll s1,s2,s3;
    if(H%3==0 || W%3==0){
        cout << 0 << endl;
        return 0;
    }

    for(int i=1;i<W;i++){
        s1=H/2*(W-i);
        s2=(H/2+H%2)*(W-i);
        s3=H*i;
        ans=min(ans,max(s1,max(s2,s3))-min(s1,min(s2,s3)));
    }
    for(int i=1;i<H;i++){
        s1=W/2*(H-i);
        s2=(W/2+W%2)*(H-i);
        s3=W*i;
        ans=min(ans,max(s1,max(s2,s3))-min(s1,min(s2,s3)));
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
using namespace std;
int main(void){
    double r;
    
    cin >> r;
    
    double a = r * r * 3.141592653589;
    
    double b = 2 * r * 3.141592653589;
    
    cout << setprecision(20) << a << " " << setprecision(20) << b << endl;
}
    


Measured memory_bytes: 3264
#include<bits/stdc++.h>
#include<map>
#define ll long long int
#define ld long double
#define pb push_back
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define mod 1000000007
#define MAX 200010
#define endl '\n'
#define mp make_pair
#define INF 10000000
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define ff first
#define ss second
#define ps(x,y) fixed<<setprecision(y)<<x
#define pii pair<long long int,long int>
#define mii map<long long int,long long int>
#define w(t) 	int t; cin>>t; while(t--)
#define coutyes cout<<"YES"
#define coutno cout<<"NO"

using namespace std;


int main() {
	ll a,b,c,k;
	cin>>a>>b>>c>>k;
	ll sum=0;
	if(k<=a)	cout<<k;
	else{
		k-=a;
		sum+=a;
		if(k<=b)	cout<<sum;
		else{
			k-=b;
			sum-=k;
			cout<<sum;
		}
	}
}
 

Measured memory_bytes: 3636
from collections import Counter, deque
from fractions import gcd
from functools import lru_cache
from functools import reduce
import functools
import heapq
import itertools
import math
import numpy as np
import sys

sys.setrecursionlimit(10000)
INF = float('inf')

N = int(input())
S = input()

ws = []
cnt = 0
for c in S:
    if c == 'W':
        cnt += 1
    ws.append(cnt)

es = []
cnt = 0
for c in reversed(S):
    if c == 'E':
        cnt += 1
    es.append(cnt)
es.reverse()

ans = min(es[0], ws[-1])
for i in range(1, N - 1):
    ans = min(ans, ws[i - 1] + es[i + 1])
print(ans)


Measured memory_bytes: 27996
use proconio::input;
use std::cmp::*;

fn main() {
    input! {
        n: usize,
        a: [i64;n]
    }

    let mut ai: Vec<(i64, i64)> = a.iter().enumerate().map(|(i, &a)| (a, i as i64)).collect();
    //    let mut ai: Vec<(i64, i64)> = a.iter().enumerate().map(|(i, &a)| (a, i as i64)).collect();
    ai.sort();
    ai.reverse();
    // 降順に並んだ。
    // println!("{:?}", ai);
    //for (a, i) in &ai {
    //    println!("{},{}", a, i);
    //}
    let minimum = 0;
    let mut dp = vec![vec![minimum; n + 1]; n + 1];
    dp[0][0] = 0;

    for (i, &(a, j)) in ai.iter().enumerate() {
        for l in 0..i + 1 {
            let r = i - l;
            dp[l + 1][r] = max(dp[l + 1][r], dp[l][r] + a * (j - (l as i64)));
            dp[l][r + 1] = max(dp[l][r + 1], dp[l][r] + a * ((n - 1 - r) as i64 - j));
        }
    }
    //let mut ans = 0;    for l in 0..n {        let r = n - l;        ans = max(dp[l][r], ans);}
    //println!("{}", ans);
    println!(
        "{}",
        dp.iter().map(|d| d.iter().max().unwrap()).max().unwrap()
    );
}


Measured memory_bytes: 33404
#include<bits/stdc++.h>
#define de(x) cout<<#x<<"="<<x<<endl;
#define dd(x) cout<<#x<<"="<<x<<" ";
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define repd(i,a,b) for(int i=a;i>=(b);--i)
#define repp(i,a,b,t) for(int i=a;i<(b);i+=t)
#define ll long long
#define mt(a,b) memset(a,b,sizeof(a))
#define fi first
#define se second
#define inf 0x3f3f3f3f
#define INF 0x3f3f3f3f3f3f3f3f
#define pii pair<int,int>
#define pdd pair<double,double>
#define pdi pair<double,int>
#define mp(u,v) make_pair(u,v)
#define sz(a) a.size()
#define ull unsigned long long
#define ll long long
#define pb push_back
#define PI acos(-1.0)
#define qc std::ios::sync_with_stdio(false)
#define db double
const int mod = 1e9+7;
const int maxn = 1e5+5;
const double eps = 1e-6;
using namespace std;
bool eq(const db &a, const db &b) { return fabs(a - b) < eps; }
bool ls(const db &a, const db &b) { return a + eps < b; }
bool le(const db &a, const db &b) { return eq(a, b) || ls(a, b); }
ll gcd(ll a,ll b) { return a==0?b:gcd(b%a,a); };
ll lcm(ll a,ll b) { return a/gcd(a,b)*b; }
ll kpow(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll read(){
    ll x=0,f=1;char ch=getchar();
    while (ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while (ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
int a[25][maxn];
int dp[25][maxn];
int main()
{
	int n;
	cin>>n;
	rep(i,1,3){
		rep(j,1,n+1){
			scanf("%d",&a[i][j]);
		}
	}
	rep(i,1,3){
		rep(j,1,n+1){
			dp[i][j]=max(dp[i-1][j],dp[i][j-1])+a[i][j];
		}
	}
	cout<<dp[2][n];
	return 0;
}







Measured memory_bytes: 4480
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REP2(i, a, b) for (int i = (a); i < (int)(b); i++)
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef long long ll;
#define ALL(V) V.begin(), V.end()
template<class T,class U>bool chmin(T&a,const U&b){if(a<=b)return false;a=b;return true;}
template<class T,class U>bool chmax(T&a,const U&b){if(a>=b)return false;a=b;return true;}


VI Main(int K, int X)
{
    int N = 2*K-1;
    VI ans(N, 0);
    REP(i, N) ans[i] = X-K+1 + i;
    return ans;

}

int main(void){
    int K, X;
    cin >> K >> X;
    VI out = Main(K, X);
    int N = out.size();
    REP(i, N) cout << out[i] << ' ';
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main () {
  int N;
  vector<vector<int>> data(3, vector<int> (3));
  for(int i = 0; i < 3; i++){
    for(int j = 0; j < 3; j++){
      cin >> data.at(i).at(j);
    }
  }
  cin >> N;
  int a;
  for(int k = 0; k < N; k++){
    cin >> a;
    for(int i = 0; i < 3; i++){
      for(int j = 0; j < 3; j++){
        if(data.at(i).at(j) == a)data.at(i).at(j) = 0;
      }
    }
  }
  int flag = 0, count = 0;;
  for(int i = 0; i < 3; i++){
    count = 0;
    for(int j = 0; j < 3; j++){
      if(data.at(i).at(j) == 0)count++;
    }
    if(count == 3){
      cout << "Yes" << endl;
      return 0;
    }
  }
  for(int i = 0; i < 3; i++){
    count = 0;
    for(int j = 0; j < 3; j++){
      if(data.at(j).at(i) == 0)count++;
    }
    if(count == 3){
      cout << "Yes" << endl;
      return 0;
    }
  }
  count = 0;
  for(int i = 0; i < 3; i++){
    if(data.at(i).at(i) == 0)count++;
  }
  if(count == 3){
    cout << "Yes" << endl;
    return 0;
  }
  if(data.at(0).at(2) == 0 && data.at(1).at(1) == 0 && data.at(2).at(0) == 0){
    cout << "Yes" << endl;
    return 0;
  }
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
int a,b;
char c;
while(1){
scanf("%d %c %d",&a,&c,&b);
if(c=='+'){printf("%d\n",a+b);}
else if(c=='-'){printf("%d\n",a-b);}
else if(c=='*'){printf("%d\n",a*b);}
else if(c=='/'){printf("%d\n",a/b);}else{break;}
}
return 0;
}

Measured memory_bytes: 600
import java.util.Arrays;
import java.util.HashMap;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		HashMap <String,Integer> hm = new HashMap<String,Integer>();
		
		int n = sc.nextInt();
		
		for(int i = 0; i < n ; i++) {
			char []c = sc.next().toCharArray();
			Arrays.sort(c);
			String s = String.valueOf(c);
			
			if(hm.containsKey(s)) {
				hm.put(s, hm.get(s)+1);
			}
			else {
				hm.put(s,1);
			}	
		}
		
		long ans = 0;
		for(int a : hm.values()) {
			 ans += (long) a * (a -1) /2;
		}
		System.out.println(ans);
		
			
		

	}

}


Measured memory_bytes: 54224
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<(n);++i)
#define rep2(i,a,b) for (ll i=(a);i<(b);++i)
#define debug(x) cout << #x << '=' << x << endl
#define all(v) (v).begin(),(v).end()
const ll MOD=1e9+7;
//const ll MOD=998244353;
const ll INF=1e9;
const ll IINF=1e18;
const double EPS=1e-8;
const double pi=acos(-1);

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b,c,N;
    while(cin >> a >> b >> c,a){
        cin >> N;
        vector<int> state(a+b+c,2);
        vector<vector<int>> check(N,vector<int>(4));
        rep(i,N){
            rep(j,3) cin >> check[i][j+1],--check[i][j+1];
            cin >> check[i][0];
        }
        sort(all(check)); reverse(all(check));
        rep(i,N){
            if (check[i][0]) rep(j,3) state[check[i][j+1]]=1;
            else {
                int cnt=0;
                rep(j,3) if (state[check[i][j+1]]==1) ++cnt;
                if (cnt!=2) continue;
                rep(j,3) if (state[check[i][j+1]]!=1) state[check[i][j+1]]=0;
            }
        }
        rep(i,a+b+c) cout << state[i] << endl;
    }
}


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

#define FOR(i, a, b) for(long long int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000 //2000000000
#define LLINF 1000000000000000000 //9000000000000000000
#define PI 3.14159265358979

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



int main(void) {

	int n, m, t;
	int count = 0;
	int a[101] = {};

	cin >> n >> m >> t;
	FOR(i, 1, n) {
		cin >> a[i];
	}
	count += a[1] - m;
	FOR(i, 2, n) {
		if (a[i] - a[i - 1] <= 2 * m) {

		}
		else {
			count += a[i] - a[i - 1] - 2 * m;
		}
	}
	if (a[n] + m <= t) {
		count += t - (a[n] + m);
	}
	cout << count << endl;
}


Measured memory_bytes: 3112
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

typedef pair<string, string> P;

struct Node{
  string obj_name, property;
  int indent;
  Node* pre;
  vector<Node*> next;
  Node():obj_name(""),property(""),indent(0),pre(NULL){}
};

vector<string> input(){
  vector<string> res;
  string s;
  while(getline(cin,s)) res.push_back(s);
  return res;
}

int indent(const string& s){
  int cnt = 0;
  for(int i = 0; i < (int)s.length(); i++)
    if(s[i] == ' ') cnt++;
    else break;
  return cnt;
}

string erase(const string& s, char c){
  string res = "";
  bool up = false;
  for(int i = 0; i < (int)s.length(); i++){
    if(s[i] != c || up){
      res += s[i];
      up = true;
    }
  }
  return res;
}

Node* top = new Node();

P divide(const string& s){
  int pos = 0;
  while(s[pos] != ':' && pos < (int)s.length()) pos++;
  return P(s.substr(0,pos), s.substr(pos+1));
}


string find(const string& q){
  Node* node = top;
  string now = q;
  if(q == ".") return "object";

  while(now != ""){
    now = now.substr(1);
    int pos = 0;
    while(now[pos] != '.' && pos < (int)now.size()) pos++;
    string pro = now.substr(0, pos);
    Node* next = NULL;
    
    for(int i = 0; i < (int)node->next.size(); i++){
      if(node->next[i]->obj_name == pro) next = node->next[i];
    }

    //  cout << "now " << node->obj_name << endl;
    
    if(next == NULL) return "no such property";
    node = next;
    now = now.substr(pos);
  }

  if(node->property != "") return "string \"" + node->property + "\"";
  return "object";
}

void solve(const vector<string>& v, const string& q){

  Node* now = top;
  bool refresh = false;

  for(int i = 0; i < (int)v.size(); i++){
    if(refresh){
      now->indent = indent(v[i]);
      refresh = false;
    }else{
      int idt = indent(v[i]);
      while(idt < now->indent) now = now->pre;
    }

    P p = divide(v[i]);

    p.first = erase(p.first, ' ');
  
    if(p.second == ""){
      //object
      Node* tmp = new Node();
      tmp->obj_name = p.first;
      tmp->pre = now;
      now->next.push_back(tmp);
      now = tmp;
      refresh = true;
    }else{
      p.second = p.second.substr(1);

      //cout << now->obj_name << " " << p.first << " " << p.second << endl;
      Node* tmp = new Node();
      tmp->obj_name = p.first;
      tmp->property = p.second;
      now->next.push_back(tmp);
    }
  }
  cout << find(q) << endl;
}

int main(){
  top->obj_name = "top";
  string q;
  getline(cin,q);
  vector<string> in = input();
  solve(in, q);
  
  return 0;
}

Measured memory_bytes: 1420
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();
	    
	    if(a==b){
	    	System.out.println("Draw");
	    }else if(a==1){	
	    	System.out.println("Alice");
	    }else if(b==1){	
	    	System.out.println("Bob");	
	    }else if(a>b){	
	    	System.out.println("Alice");	
	    }else{
	    	System.out.println("Bob");
	      }
	}
	}


Measured memory_bytes: 35588
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>

using namespace std;
using ll = long long;

void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
int gcd(int a, int b){ return (b == 0) ? a : gcd(b, a % b); }

#define Sq(x) (x)*(x)
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Search(rb, re, x) distance(rb, find(rb, re, x))
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Reverse(c) reverse(Range(c))
#define Unique(a) a.erase(unique(Range(a)), a.end())
#define Cusum(T, xs, sxs) vector<T> sxs(xs.size()+1); For(i, (int)xs.size()) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinss(T, n, m, xs) Vec2(T, n, m, xs); For(i, n) For(j, m) cin >> xs[i][j]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) { for(const auto &e : xs) cout << e << " "; cout << "\n"; }
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")
#define vc vector
#define Mini(a, x) a = min(a, x)
#define Maxi(a, x) a = max(a, x)

// constexpr int MOD = 1e9+7;

int main(void){
    Cin(string, s);
    Cin(int, w);
    for(int i = 0; i < (int)s.size(); i += w) cout << s[i];
    cout << endl;
}





Measured memory_bytes: 256
def main():
    fac = 2**11
    l_a=[]
    for i in range(-fac,fac+1):
        l_a.append(i**5)
    l_b = l_a
    ans = int(input())
    #print(l_a)
    A=0
    B=0
    for num_a, i in enumerate(l_a):
        for num_b, j in enumerate(l_b):
            if i - j == ans:
                A = num_a - fac
                B = num_b - fac
    print(A,B)
main()

Measured memory_bytes: 65800
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static string InputPattern = "InputX";

    static List<string> GetInputList()
    {
        var WillReturn = new List<string>();

        if (InputPattern == "Input1") {
            WillReturn.Add("3");
            WillReturn.Add("3 1 2");
            WillReturn.Add("2 5 4");
            WillReturn.Add("3 6");
            //14
        }
        else if (InputPattern == "Input2") {
            WillReturn.Add("4");
            WillReturn.Add("2 3 4 1");
            WillReturn.Add("13 5 8 24");
            WillReturn.Add("45 9 15");
            //74
        }
        else if (InputPattern == "Input3") {
            WillReturn.Add("2");
            WillReturn.Add("1 2");
            WillReturn.Add("50 50");
            WillReturn.Add("50");
            //150
        }
        else {
            string wkStr;
            while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
        }
        return WillReturn;
    }

    static void Main()
    {
        List<string> InputList = GetInputList();

        int[] AArr = InputList[1].Split(' ').Select(X => int.Parse(X)).ToArray();
        int[] BArr = InputList[2].Split(' ').Select(X => int.Parse(X)).ToArray();
        int[] CArr = InputList[3].Split(' ').Select(X => int.Parse(X)).ToArray();

        int Answer = 0;
        for (int I = 0; I <= AArr.GetUpperBound(0); I++) {
            int CurrEatInd = AArr[I] - 1;
            Answer += BArr[CurrEatInd];
            if (I > 0) {
                int PrevEatInd = AArr[I - 1] - 1;
                if (PrevEatInd + 1 == CurrEatInd) {
                    Answer += CArr[PrevEatInd];
                }
            }
        }
        Console.WriteLine(Answer);
    }
}


Measured memory_bytes: 13396
a,b,c=map(int,input().split())
b=list(map(int,input().split()))
i=c
total=0
total2=0
while True:
    i+=1
    if i in b:
        total+=1
    if i==a:
        break
i=c
while True:
    i-=1
    if i in b:
        total2+=1
    if i==0:
        break
print(min(total,total2))

Measured memory_bytes: 9192
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
const int INF = 1 << 28;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}

int main() {
    int n, k;
    cin >> n >> k;
    vi a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    vector<bool> dp(k + 1, false);
    for (int i = 0; i <= k; ++i) {
        for (int j = 0; j < n; ++j) {
            int k = i - a[j];
            if (k >= 0 && dp[k] == false) {
                dp[i] = true;
            }
        }
    }
    if (dp[k])
        cout << "First"
             << "\n";
    else
        cout << "Second"
             << "\n";
    return 0;
}

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

public class Main {

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

    private void solve() throws IOException {
        BufferedReader f = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(System.out);

        int n = Integer.parseInt(f.readLine());
        int[] cost = new int[n];
        StringTokenizer tokenizer = new StringTokenizer(f.readLine());
        for (int i = 0; i< n; i++) cost[i] = Integer.parseInt(tokenizer.nextToken());

        long[] boughtButNotSold = new long[n];
        long money = 1000;
        for (int i = 0; i < n; i++) {
            for (int j = i - 1; j >= 0; j--) {
                if (cost[j] <= cost[i]) {
                    money += boughtButNotSold[j] * cost[i];
                    boughtButNotSold[j] = 0;
                }
            }
            for (int j = i - 1; j >= 0; j--) {
                if (cost[j] > cost[i]) {
                    money += cost[j] * boughtButNotSold[j];
                    boughtButNotSold[j] = 0;
                }
            }

            boughtButNotSold[i] = money / cost[i];
            money %= cost[i];
            //System.out.println(money + " " + Arrays.toString(boughtButNotSold));
        }


        for (int i = 0; i < n; i++) {
            money += boughtButNotSold[i] * cost[i];
        }

        out.println(money);
        out.close();
    }
}

Measured memory_bytes: 32800
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <tuple>
#include <queue>
#include <set>
#include <math.h>
#include <array>
#include <list>
#include <set>
const int MOD=1000000007;
const int INF=1000000000;
using namespace std;
typedef long long ll;
typedef tuple<ll,int,int> tup;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vp;

int main(int argc,char const* argv[])
{
  int a,b,c;
  int num[3];
  cin >> a >> b >> c;
  num[0]=a,num[1]=b,num[2]=c;
  sort(num,num+3,greater<int>());
  cout << 10*num[0]+num[1]+num[2] << endl;
  return 0;
}


Measured memory_bytes: 256
a,b = map(int, input().split())
ans = abs(abs(a) - abs(b))
sign = inc = 0
if a*b < 0:
    sign = 1
if a-b < 0:
    inc = 1

if a==0 and b==0:
    print(0)
    exit()
elif a==0:
    if inc == 0:
        ans += 1
        print(ans)
        exit()
elif b==0:
    if inc == 0:
        ans += 1
        print(ans)
        exit()

if sign == 0 and inc == 0:
    ans += 2
elif sign == 0 and inc == 1:
    pass
else:
    ans += 1
print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<string>
#include<algorithm>
#include<cmath>
#include<numeric>

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() {
    ll H, W, N; cin >> H >> W >> N;
    vector<ll> a, b;
    map<pair<ll,ll> , ll> count;
    map<pair<ll,ll> , ll> mp[10];
    for (int i = 0; i < N; i++) {
        ll x, y;
        cin >> x >> y;
        count[make_pair(x,y)]++;
        for (int s = -1; s <= 1; s++) {
            for (int t = -1; t <= 1; t++) {
                if (x+s <= 0 || x+s > H || y+t <= 0 || y+t > W)
                    continue;
                a.push_back(x+s);
                b.push_back(y+t);
            }
        }
    }

    for (int i = 0; i < a.size(); i++) {
        ll X = a[i], Y = b[i], cnt = 0;
        if (X <= 1 || X >= H || Y <= 1 || Y >= W) continue;
        for (ll x = max((ll)1,X-1); x <= min(H,X+1); x++) {
            for (ll y = max((ll)1,Y-1); y <= min(W,Y+1); y++) {
                cnt += count[make_pair(x,y)];
            }
        }
        mp[cnt][make_pair(X,Y)]++;
    }
    ll zero = (H-2)*(W-2);
    for (int i = 1; i <= 9; i++) zero -= mp[i].size();
    cout << zero << endl;
    for (int i = 1; i <= 9; i++) {
        cout << mp[i].size() << endl;
    }


}


Measured memory_bytes: 227756
#include<iostream>
#include<string>
#include<vector>
#include<numeric>
#include<math.h>
#include<algorithm>
#include<iomanip>
#include<list>
using namespace std;

int main() {

	int N;
	cin >> N;

	vector<int> d(N, 0);
	for (int i = 0; i < d.size(); i++) {
		cin >> d[i];
	}

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

	int K = d[N / 2] - d[N / 2 - 1];

	cout << K << endl;

	return 0;
}



Measured memory_bytes: 640
import java.util.*;
import java.io.*;

class Main {

	void solve () {

		int a = in.nextInt();
		String s = in.next();
		
		out.println(a>=3200? s : "red");
		
	}

	public static PrintWriter out = new PrintWriter(System.out);
	public static Scanner in = new Scanner(System.in);
	public static void main(String[] args) {
		new Main().solve();
		out.flush();
	}

}

Measured memory_bytes: 21716
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp2
{
    using System;
    using System.Linq;

    using Match = System.Int32;

    class Program
    {
        static readonly long DIVIDE_BASE = 1000000007;
        static readonly int REMAINDER_BASE = 13;
        static void Main(string[] args)
        {
            // スペース区切りの整数の入力
            char[] inputs = Console.ReadLine().ToCharArray();
            int n = inputs.Count();
            // 剰余の結果がいくつになる可能性があるかを保存する
            long[] remainderPossibilities = new long[REMAINDER_BASE];
            remainderPossibilities[0] = 1;
            for (int i = 0; i < n; i++)
            {
                long[] newList = new long[REMAINDER_BASE];
                if (inputs[i] == '?')
                {
                    for(int j = 0; j < 10; j++)
                    {
                        long[] tmpList = getNewPossibilitiesByShift(remainderPossibilities, j);
                        newList = VectorSum(newList, tmpList);
                    }
                }
                else
                {
                    int digit = int.Parse(inputs[i].ToString());
                    newList = getNewPossibilitiesByShift(remainderPossibilities, digit);
                }
                remainderPossibilities = newList;
                // Console.WriteLine(string.Join(" ", remainderPossibilities));
            }
            Console.WriteLine(remainderPossibilities[5].ToString());
        }

        static long[] getNewPossibilitiesByShift(long[] oldList, int shiftValue)
        {
            long[] newList = new long[REMAINDER_BASE];
            for (int i = 0; i < REMAINDER_BASE; i++)
            {
                newList[Destination(i, shiftValue)] = (newList[Destination(i, shiftValue)] + oldList[i]) % DIVIDE_BASE;
            }
            return newList;
        }

        static int Destination(int tmp, int shift)
        {
            return (tmp * 10 + shift) % REMAINDER_BASE;
        }

        static long[] VectorSum(long[] vector1, long[] vector2)
        {
            long[] result = new long[REMAINDER_BASE];
            for (int i = 0; i < REMAINDER_BASE; i++)
            {
                result[i] = (vector1[i] + vector2[i]) % DIVIDE_BASE;
            }
            return result;
        }
    }
}


Measured memory_bytes: 15704