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

string remv(const string &S) {
    string res = "";
    for(auto &c : S) {
        if(res.empty()) res += c;
        else if(res.back() == '(' and c == ')') res.pop_back();
        else res += c;
    }
    return res;
}

int main() {
    int N; cin >> N;
    using Bracket = tuple<string, int, int>;
    vector<Bracket> L, R;
    for(int i = 0; i < N; ++i) {
        string S; cin >> S;
        S = remv(S);
        int l = count(S.begin(), S.end(), '(');
        int r = count(S.begin(), S.end(), ')');
        if(l >= r) L.emplace_back(S, l, r);
        else R.emplace_back(S, l, r);
    }
    sort(L.begin(), L.end(), [](const Bracket &A, const Bracket &B){
        return get<2>(A) < get<2>(B);
    });
    sort(R.begin(), R.end(), [](const Bracket &A, const Bracket &B){
        return get<1>(A) > get<1>(B);
    });
    string ans = "";
    for(auto &[s, l, r] : L) ans += s;
    for(auto &[s, l, r] : R) ans += s;
    cout << (remv(ans).empty() ? "Yes" : "No") << '\n';
    return 0;
}


Measured memory_bytes: 45236
n,d=map(int,input().split())
arr=[list(map(int,input().split())) for _ in range(n)]
ans=0
for i in range(0,n-1):
  for j in range(i+1,n):
    tmp=0
    for k in range(d):
      tmp+=(arr[j][k]-arr[i][k])**2
    tmp=tmp**0.5
    if tmp==int(tmp):
      ans+=1
print(ans)

Measured memory_bytes: 3064
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <numeric>
#include <iterator>
#include <fstream>
#include <math.h>

#include <random>
#include <vector>
#include <string>
#include <stack>
#include <set>
#include <map>
#include <deque>
#include <queue>
#include <list>
#include <bitset>
#include <unordered_set>
#include <unordered_map>

#include <random>
#include <ctime>

#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

using namespace std;

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

#define FOR(i, from, to) for (int i = from; i < to; i++)
#define ROF(i, from, to) for (int i = from; i > to; i--)

const long double PI = 3.141592653589793238463;
const int INF = 0x3f3f3f3f;
const int INFS = 1000000000;
const ll M = 1000000007;
const ll LLINF = 1000000000000000000;
const double EPS = 1e-8;

#define int long long

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);

    int n, a;
    cin >> n >> a;
    vector<int> x(n);
    FOR(i, 0, n)
        cin >> x[i];
    vector<vector<int> > dp(n + 1, vector<int>(2501, 0)), pr(n, vector<int>(2501, 0));
    dp[0][0] = 1;
    pr[0][0] = 1;
    FOR(i, 0, n) {
        FOR(j, 1, n + 1) {
            FOR(s, 0, 2501) {
                if (pr[j - 1][s] > 0 && s + x[i] <= 2500) {
                    dp[j][s + x[i]] += pr[j - 1][s];
                }
            }
        }
        pr = dp;
    }
    int ans = 0;
    FOR(i, 1, n + 1) {
        if (i * a <= 2500) {
            ans += dp[i][i * a];
        }
    }
    cout << ans << "\n";

    return 0;
}


Measured memory_bytes: 6048
while true
  h,w = gets.split.map{ |e| e.to_i}
  break if (h == 0 && w == 0)
  h.times { |i|
    if (i == 0 || i == h-1)
      puts "#"*w
    else
      puts "#" + "."*(w-2) + "#"
    end
  }
  puts ""
end

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

int n, c = 1, a[100005];
int main()
{
	int i, t = 0;
	cin >> n;
	for (i = 0; i < n; i++) {
		scanf("%d", &a[i]);
	}
	for (i = 1; i < n; i++) {
		if (t == 0) {
			if (a[i - 1] < a[i]) t = 1;
			else if (a[i - 1] > a[i]) t = 2;
		} else if (t == 1) {
			if (a[i - 1] > a[i]) c++, t = 0;
		} else {
			if (a[i - 1] < a[i]) c++, t = 0;
		}
	}
    cout << c << endl;
    return 0;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vel;
typedef vector<int> vei;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> ve_vel;
typedef vector<vector<int>> ve_vei;
typedef vector<vector<char>> ve_vec;
typedef vector<vector<bool>> ve_veb;
typedef vector<vector<string>> ve_ves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pub push_back
#define pob pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
//#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
const int64 INF = 1LL << 58;
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; }

int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const int MAX = 410;
using pint = pair<int,int>;

int H, W;
ves field;

ll numb = 0, numw = 0;
bool seen[MAX][MAX];
void dfs(int x, int y) {
    seen[x][y] = true;
    if (field[x][y] == '#') numb++;
    else numw++;
    
    for (int dir = 0; dir < 4; ++dir) {
        int nx = x + dx[dir];
        int ny = y + dy[dir];
        if (nx < 0 || nx >= H || ny < 0 || ny >= W) continue;
        if (field[x][y] == field[nx][ny]) continue;
        if (seen[nx][ny]) continue;
        dfs(nx, ny);
    }
}

int main() {
    cin >> H >> W;
    field.resize(H);
    rep(i,H) cin >> field[i];
    
    ll res = 0;
    rep(x,H) rep(y,W) {
        if (field[x][y] == '.') continue;
        if (seen[x][y]) continue;
        numb = numw = 0;
        dfs(x, y);
        res += numb * numw;
    }
    cout << res << endl;
}

Measured memory_bytes: 18176
import queue

H, W = map(int, input().split())
S= [input() for i in range(H)]

def bfs():
    start=[0,0]
    goal=[W-1,H-1]
    distance=[[-1]*H for j in range(W)]
    li_x=[1,-1,0,0]
    li_y=[0,0,1,-1]
    q = queue.Queue()
    q.put(start)
    distance[start[0]][start[1]]=1

    while not q.empty():
        hoge=q.get()
        x=hoge[0]
        y=hoge[1]
        dis=distance[x][y]

        for i in range(4):
            x1=x+li_x[i]
            y1=y+li_y[i]
            if (0 <=x1 < W and 0 <= y1 < H):
                if distance[x1][y1] == -1:
                    if S[y1][x1]=='.':
                        q.put([x1,y1])
                        distance[x1][y1]=dis+1
    m=''
    for i in range(H):
        m+=S[i]
    
    if distance[W-1][H-1]==-1:
        ans=-1 
    else:
        ans=m.count('.')-distance[W-1][H-1]
    return ans

ans=bfs()
print(ans)


Measured memory_bytes: 3952
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())




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

	int cnt[26];
	rep(i, 26)cnt[i]=INF;
	int n;
	cin>>n;
	rep(i,n){
		string s;
		cin>>s;
		rep(j, 26)cnt[j] = min<int>(cnt[j],
			count(all(s),'a'+j));
	}
	rep(i, 26)cout << string(cnt[i],'a'+i);
	cout<<endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    char S[100000],T[100001],ch;
    int i,len,c;
    scanf("%s%s",&S,&T);
    len=strlen(S);
    c=1;
    for(i=0;i<len;i++){
        if(S[i]!=T[i]){
           c=0;
           printf("No\n");
           return 0;
        }
    }
    if(c==1)
       printf("Yes\n");
    return 0;
}


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

using namespace std;

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

  int n, m, x, y;
  cin >> n >> m >> x >> y;
  vector<int> X(n), Y(m);
  for (auto &xx: X) cin >> xx;
  for (auto &yy: Y) cin >> yy;

  sort(X.begin(), X.end());
  sort(Y.begin(), Y.end());

  string res = "No War";
  if (x >= y || X[n-1] >= Y[0] || X[n-1] >= y || Y[0] <= x) res = "War";
  cout << res << endl;

  return 0;
}



Measured memory_bytes: 256
n,m=map(int, input().split()) 

tmp1 = 0
tmp2 = 0

if n != 0:
    tmp1 = n * (n - 1) / 2

if m != 0:
    tmp2 = m * (m - 1) / 2

r = int(tmp1 + tmp2)
print(r)

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

int h, w, k;
int c[8][8];
bool choose[16];

int numChc(int step) {
    if (step == h + w) {
        int cnt = 0;
        for (int i = 0; i < h; ++i) {
            for (int j = 0; j < w; ++j) {
                if (c[i][j] && choose[i] && choose[h + j]) {
                    ++cnt;
                }
            }
        }
        return cnt == k? 1 : 0;
    }
    choose[step] = false;
    int n1 = numChc(step + 1);
    choose[step] = true;
    int n2 = numChc(step + 1);
    return n1 + n2;
}

void solve()
{
    cin >> h >> w >> k;
    for (int i = 0; i < h; ++i) {
        string s;
        cin >> s;
        for (int j = 0; j < w; ++j) {
            c[i][j] = (s[j] == '#'? 1 : 0);
        }
    }
    cout << numChc(0) << endl;
}

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

    /* int T; */
    /* cin >> T; */
    /* for (int t = 0; t < T; ++t) { */
        solve();
    /* } */
    return 0;
}


Measured memory_bytes: 3652
import java.util.Comparator;
import java.util.List;
import java.util.Optional;
import java.util.PriorityQueue;
import java.util.Scanner;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

public class Main {
    public static void main(final String[] args) {
        final Scanner scanner = new Scanner(System.in);
        final int n = scanner.nextInt();
        final List<Long> list = IntStream.range(0, 3 * n)
                .mapToObj(i -> scanner.nextLong())
                .collect(Collectors.toList());

        final long[] sumOfFormer = new long[n + 1];
        sumOfFormer[0] = list.stream().limit(n).mapToLong(Long::longValue).sum();
        final PriorityQueue<Long> formerQueue = new PriorityQueue<>();
        for (int i = 0; i < n; i++) {
            formerQueue.add(list.get(i));
        }
        for (int i = n, j = 1; i < 2 * n; i++, j++) {
            final long minOfQueue = Optional.ofNullable(formerQueue.poll()).orElseThrow(RuntimeException::new);
            final long tmp = list.get(i);
            if (tmp > minOfQueue) {
                formerQueue.add(tmp);
                sumOfFormer[j] = sumOfFormer[j - 1] + tmp - minOfQueue;
            } else {
                formerQueue.add(minOfQueue);
                sumOfFormer[j] = sumOfFormer[j - 1];
            }
        }

        final long[] sumOfLatter = new long[n + 1];
        sumOfLatter[n] = list.stream().skip(2 * n).mapToLong(Long::longValue).sum();
        final PriorityQueue<Long> latterQueue = new PriorityQueue<>(Comparator.reverseOrder());
        for (int i = 0; i < n; i++) {
            latterQueue.add(list.get(i + 2 * n));
        }
        for (int i = 2 * n - 1, j = n - 1; i >= n; i--, j--) {
            final long maxOfQueue = Optional.ofNullable(latterQueue.poll()).orElseThrow(RuntimeException::new);
            final long tmp = list.get(i);
            if (tmp < maxOfQueue) {
                latterQueue.add(tmp);
                sumOfLatter[j] = sumOfLatter[j + 1] + tmp - maxOfQueue;
            } else {
                latterQueue.add(maxOfQueue);
                sumOfLatter[j] = sumOfLatter[j + 1];
            }
        }

        long max = Long.MIN_VALUE;
        for (int i = 0; i < n + 1; i++) {
            max = Math.max(max, sumOfFormer[i] - sumOfLatter[i]);
        }

        System.out.println(max);
    }
}


Measured memory_bytes: 110448
n, q = map(int,list(input().split()))
l = []
d = {}
t = 0
for _ in range(n):
    name, time = list(input().split())
    l.append(name)
    d[name] = int(time)
index = 0
while d:
    if d[l[0]] > q:
        d[l[0]] -= q
        t += q
        l.append(l.pop(0))
    else:
        t += d[l[0]]
        print(str(l[0]) + ' ' + str(t))
        del d[l[0]]
        del l[0]
        n -= 1
    
        
        
        



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

#define M 1046527
#define NIL (-1)
#define L 14

char H[M][L];

int getChar(char);
long long getKey(char*);
int h1(int);
int h2(int);
int find(char*);
int insert(char*);

int main(){
    int i,n,h;
    char str[L],com[9];

    for(i=0;i<M;i++){
        H[i][0]='\0';
    }

    scanf("%d",&n);

    for(i=0;i<n;i++){
        scanf("%s %s",com,str);

        if(com[0]=='i') insert(str);
        else{
            if(find(str)) printf("yes\n");
            else printf("no\n");
        }
    }

    return 0;
}

int getChar(char ch){
    if(ch=='A') return 1;
    else if(ch=='C') return 2;
    else if(ch=='G') return 3;
    else if(ch=='T') return 4;
    else return 0;
}

long long getKey(char *str){
    long long sum=0,p=1,i;

    for(i=0;i<strlen(str);i++){
        sum+=p*(getChar(str[i]));
        p*=5;
    }

    return sum;
}

int h1(int key){
    return key%M;
}

int h2(int key){
    return 1+(key%(M-1));
}

int find(char *str){
    long long key,i,h;

    key=getKey(str);

    for(i=0;;i++){
        h=(h1(key)+i*h2(key))%M;
        if(strcmp(H[h],str)==0) return 1;
        else if(strlen(H[h])==0) return 0;
    }

    return 0;
}

int insert(char *str){
    long long key,i,h;

    key=getKey(str);

    for(i=0;;i++){
        h=(h1(key)+i*h2(key))%M;
        if(strcmp(H[h],str)==0) return 1;
        else if(strlen(H[h])==0){
            strcpy(H[h],str);
            return 0;
        }
    }

    return 0;
}


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

int main(){
  vector<int> v(5);
  for(int i=0;i<5;i++){
    cin >> v.at(i);
  }
  int k;
  cin >> k;
  for(int i=0;i<5;i++){
    for(int j=0;j<i;j++){
      if(v.at(i)-v.at(j)>k){
        cout << ":(" << endl;
        return 0;
      }
    }
  }
  cout << "Yay!" << endl;
  return 0;
}


Measured memory_bytes: 256
#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 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 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

const double PI=acos(-1);
const double EPS=1e-9; //うまくいかなかったらゆるめる

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) {
    int n;
    cin >> n;
    int c[10][10] = {};
    loop(i,1,n+1){
        int a = i;
        while(a > 9)a /= 10;
        int b = i%10;
        c[a][b]++;
    }
    int ans = 0;
    rep(i,10)rep(j,10)ans += c[i][j]*c[j][i];
    cout << ans << endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std ;
typedef long long lld;
const int N=1e5+5, M = 1e5, OO = 0x3f3f3f3f;
lld mem[101][N];
int n , k;
pair<int , int > t[N];
lld knapsack(int i = n-1, int rem = k)
{
    if(rem < 0)
        return -OO;
    if(i < 0 )
        return 0;
    lld &ret = mem[i][rem];
    if (ret != -1)
        return ret;
    ret = max(knapsack(i - 1, rem), knapsack(i - 1, rem - t[i].first) + t[i].second);
    return	ret;
}
main()
{
    scanf("%d %d", &n, &k);
    memset(mem, -1, sizeof mem);
    for(int i = 0 ; i < n ; ++i)
        scanf("%d %d", &t[i].first, &t[i].second);
    sort(t , t + n);
    cout<<knapsack();

}


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

using namespace std;

const int MX_SZ = 1e+5 + 42;

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

    vector<int> nums;
    int cnt = 0;
    char prv = '7';
    for (auto c : s) {
        if (prv != '7' and prv != c) {
            nums.push_back(cnt);
            cnt = 1;
        } else {
            ++cnt;
        }
        prv = c;
    }
    nums.push_back(cnt);

    if (nums.size() <= 2) {
        cout << *max_element(nums.begin(), nums.end()) << endl;
        return 0;
    }

    vector<int> pref(MX_SZ, 0);
    for (int i = 1; i <= nums.size(); ++i) {
        pref[i] = nums[i - 1];
        if (i != 1) {
            pref[i] += pref[i - 1];
        }
    }
    int suf = 0;
    int answer = MX_SZ;
    vector<int> d;
    for (int i = nums.size() - 1; i >= 0; --i) {
        d.push_back(max(suf, pref[i]));
        suf += nums[i];
    }
    sort(d.begin(), d.end());
    cout << d[1] << endl;
}


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

int main(void){

    long long A, B;

    char op[2];

    scanf("%lld%s%lld", &A, op, &B);

    if(op[0] == '+'){
        printf("%lld\n", A + B);
    }else{
        printf("%lld\n", A - B);
    }

    return 0;
}

Measured memory_bytes: 1700
#include <iostream>

using namespace std;

int main()
{
    int h, w;

    while (cin >> h >> w) {
        if (h == 0 && w == 0) {
            break;
        }
        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {
                if ((i + j) % 2 == 0) {
                    cout << "#";
                } else {
                    cout << ".";
                }
            }
            cout << endl;
        }
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 3096
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; i++ )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
int dx[4]={1,0,-1,0} , dy[4]={0,1,0,-1} ;

typedef vector<vector<int>> graph;
struct LowLink{
    graph v;
    vector<int> art,low,ord;
    vector <pint> bridge;

    LowLink(int n):v(n),ord(n,-1),low(n){};

    void addedge(int x,int y){
        v[x].push_back(y);
        v[y].push_back(x);
    }
    
    void dfs(int& count,int from,int x){
        ord[x]=count++;
        low[x]=ord[x];
        bool isart=false;
        int cnt=0;
        for(auto to:v[x]){
            if(to==from)continue;
            if(ord[to]==-1){
                cnt++;
                dfs(count,x,to);
                if(ord[x]<low[to])bridge.push_back({min(x,to),max(to,x)});
                if(from!=-1&&ord[x]<=low[to])isart=true;
                low[x]=min(low[x],low[to]);
            }
            else low[x]=min(low[x],ord[to]);
        }
        if(from==-1&&cnt>1)isart=true;
        if(isart)art.push_back(x);
    }
    void dfs(){
        int count=0;
        dfs(count,-1,0);
    }
};


int main(){
    int n,m;
    cin>>n>>m;
    LowLink ll(n);
    rep(i,m){
        int x,y;
        cin>>x>>y;
        ll.addedge(x,y);
    }
    ll.dfs();
    sort(ll.art.begin(),ll.art.end());
    for(auto x:ll.art)cout<<x<<endl;
   return 0;
}


Measured memory_bytes: 4644
package main

import "fmt"

func main() {
	var s string
	fmt.Scan(&s)

	ans := 0
	cnt := 0
	for _, c := range s {
		if c == 'A' || c == 'C' || c == 'G' || c == 'T' {
			cnt++
		} else {
			cnt = 0
		}
		if cnt > ans {
			ans = cnt
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 512
package main

import (
	"fmt"
	"os"
	"strconv"
	"bufio"
	"strings"
)

// define
var (
	sc = bufio.NewScanner(os.Stdin)
)

func scanIntLine(len int) []int{
	arr := make([]int, len)
	for i:=0; i<len; i++{
		sc.Scan()
		tmp, err := strconv.Atoi(sc.Text())
		if err == nil{
			arr[i] = tmp
		}
	}
	return arr
}

func scanStringLine(len int) []string{
	arr := make([]string, len)
	for i:=0; i<len; i++{
		sc.Scan()
		arr[i] = sc.Text()
	}
	return arr
}

func scanIntSplit(len int) []int{
	arr := make([]int, len)
	sc.Scan()
	for i, v := range strings.Split(sc.Text(), " "){
		tmp, err := strconv.Atoi(v)
		if err == nil{
			arr[i] = tmp
		}
	}
	return arr
}

func main(){
	arr := scanIntLine(4)
	A, B, C, X := arr[0], arr[1], arr[2], arr[3]
	ans := 0
	for a:=0; a<=A; a++{
		if X < 500*a {
			break
		}
		for b:=0; b<=B; b++{
			if X < 100*b {
				break
			}
			for c:=0; c<=C; c++{
				if X == 500*a+100*b+50*c {
					ans++
				} else if X < 500*a+100*b+50*c{
					break
				}
			}
		}
	}
	fmt.Println(ans)
}

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

using namespace std;

int main() {
  int N, M, l, r, tmpl, tmpr;
  cin >> N >> M;
  vector<int> L(M), R(M);
  cin >> l >> r;
  for (int i = 1; i < M; ++i) {
    cin >> tmpl >> tmpr;
    l = max(l, tmpl);
    r = min(r, tmpr);
  }
  cout << max(r - l + 1, 0) << endl;
  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s,s1="";
    int a;
    cin>>s;
    vector<int>v;
    for(int i=0; i<s.size(); i++)
    {
        s1+=s[i];
        s1+=s[i+1];
        s1+=s[i+2];
        stringstream ss(s1);
        ss>>a;
        v.push_back(abs(753-a));
        s1="";
    }
    sort(v.begin(),v.end());
    cout<<v[0]<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int main(){
	string a,b;
	cin >> a >> b;
	if(a=="H"){
		if(b=="H"){
			cout << "H" << endl;
		}else if(b=="D"){
			cout << "D" << endl;
		}
	}else{
		if(b=="H"){
			cout << "D" << endl;
		}else if(b=="D"){
			cout << "H" << endl;
		}
	}
	return 0;
}

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

class Main{
    public static void main(String args[])throws IOException{
      try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))){
        String[] input = br.readLine().split(" ");

        int num = Integer.parseInt(input[0]);
        int total = Integer.parseInt(input[1]);

        if(num * 500 >= total){
          System.out.println("Yes");
        }else{
          System.out.println("No"); 
        }
      }
    }
}

Measured memory_bytes: 22612
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,m;
    cin>>n>>m;
    int ans=1;
    if(m%n==0){
        cout<<m/n<<endl;
        return 0;
    }
    for(int i=m/n;i>1;i--){
        if(m%i==0){
            ans=i;
            break;
        }
    }
    cout<<ans<<endl;
    return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
const int N = 100010;
typedef long long int64;
 
map<int64 , int> val;
int n , size[N] , fa[N];
 
int64 d[N];
typedef pair<int64 , int> pii;
priority_queue<pii> leaf;
#define mp make_pair 
 
int main() {
    cin >> n;
    for(int i = 1 ; i <= n ; ++i) {
        cin >> d[i];
        size[i] = 1;
        val[d[i]] = i; 
    }
    for(int i = 1 ; i <= n ; ++i) leaf.push(mp(d[i] , i));
	
	int64 root = 0;
    while(leaf.size()) {
        int x = leaf.top().second;
        leaf.pop();
 
		val.erase(d[x]);
        if(val.count(d[x] - n + size[x]*2))
            fa[x] = val[d[x] - n + size[x]*2];
        else break;
        
        size[fa[x]] += size[x];
        root += size[x];
    }
 
    for(int i = 1 , cnt = 0; i <= n ; ++i) {
    	if(fa[i] == 0 && (++cnt > 1 || d[i] != root))  {cout << -1 << endl; return 0;}
	}
    for(int i = 1 ; i <= n ; ++i)
        if(fa[i]) cout << i << ' ' << fa[i] << endl;
	
    return 0;
}

Measured memory_bytes: 10868
#include<bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_upd>
//order_of_key (k) : Number of items strictly smaller than k .
//find_by_order(k) : K-th element in a set (counting from zero).
*/
using namespace std;

#define LL long long
#define LD long double
#define PB push_back
#define MP make_pair
#define all(x) x.begin(), x.end()

const LL MOD = 998244353 ;
const LD EPS = 0.0000001 ;

LL pows(LL a, LL b)
{
	if (b == 0) return 1LL;
	LL temp = pows(a, b / 2);
	temp = (temp * temp) % MOD;
	if (b % 2) temp = (temp * a) % MOD;
	return temp;
}

const int N = 200000 + 500;

vector<int> graph[N];
int pa[N][20];
int depth[N];

void dfs(int node, int par)
{
	pa[node][0] = par;
	depth[node] = depth[par] + 1;
	for (int i = 1; i < 20; i++) pa[node][i] = pa[pa[node][i - 1]][i - 1];

	for (auto it : graph[node]){
		if (it == par) continue;
		dfs(it, node);
	}
}

int xthParent(int node, int x)
{	
	if (x == 0) return node;
	for (int i = 19; i >= 0; i--){
		if (x & (1 << i)) node = pa[node][i];
	}
	return node;
}

void solve()
{

}

int main(void)
{
	LL x, y, a, b, c; cin >> x >> y >> a >> b >> c;
	vector<LL> red(a), green(b), col(c);
	for (int i = 0; i < a; i++) {
		cin >> red[i];
	}
	for (int i = 0; i < b; i++){
		cin >> green[i];
	}
	for (int i = 0; i < c; i++){
		cin >> col[i];
	}

	sort(red.begin(), red.end());
	reverse(red.begin(), red.end());

	sort(green.begin(), green.end());
	reverse(green.begin(), green.end());

	sort(col.begin(), col.end());
	reverse(col.begin(), col.end());


	priority_queue<LL, vector<LL>, greater<LL> > all;

	LL ans = 0;

	for (int i = 0; i < min(x, a); i++){
		ans += red[i];
		all.push(red[i]);
	}

	for (int i = 0; i < min(y, b); i++){
		ans += green[i];
		all.push(green[i]);
	}

	for (int i = 0; i < c; i++){
		if (col[i] <= all.top()){
			break;
		}
		ans += col[i] - all.top();
		all.pop();
		all.push(col[i]);
	}
	cout << ans << endl;
	return 0;
}




Measured memory_bytes: 9588
import java.util.Scanner;

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

    for (int i = 0;; i++) {
      x = sc.next();
      if (x.equals("0")) break;
      ans = 0;
      for (int j = 0; j < x.length(); j++) {// ans 算出
        c = x.charAt(j);
        ans += c - '0';
      }
      System.out.printf("%d\n", ans);
    }

    sc.close();
  }
}



Measured memory_bytes: 26652
#include <bits/stdc++.h>
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
Apparently, the tree supports the same operations as the set 
(at least I haven't any problems with them before), but also there are two new features — 
find_by_order() — The first returns an iterator to the k-th largest element (counting from zero)
order_of_key() — the number of items in a set that are strictly smaller than our item. 
https://codeforces.com/blog/entry/11080
using namespace __gnu_pbds; */
using namespace std;
#define test() int t;cin>>t;for(int test=1;test<=t;test++)
#define int long long
#define MOD 1000000007
#define pb push_back 
#define ins insert
#define fast(); ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ld long double
#define endl '\n'
int m(int a) {
    return ((a%MOD)+MOD)%MOD;
}
int p(int a, int b) {
    int res = 1;
    while(b > 0){
        if(b&1) res = m(m(res)*m(a));
        a = m(m(a)*m(a));
        b >>= 1;
    }
    return res;
}
// vector<int> fac; //precompute fac array
// fac.resize(n+1);
// fac[0] = 1; 
// for (int i=1; i<=n; i++)   fac[i] = m(m(fac[i-1])*m(i));
// int modInverse(int n){ 
// return p(n, MOD-2); 
// }  
// int nCrModPFermat(int n, int r){   
//     if(r == 0)  return 1; 
//     return m(m(m(fac[n])*m(modInverse(fac[r])))*m(modInverse(fac[n-r]))); 
// } 
signed main(){
    fast();
    int ans;
    for(int i=1, j; i<=5; i++){
        cin >> j;
        if(j == 0){
            ans = i;
        }
    }
    cout << ans << endl;
    cerr << "\nTime elapsed : " << 1000 * clock() / CLOCKS_PER_SEC << " ms\n";
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
#define int long long
int dp[100005][105];

int solve(int r,int i,int wt[],int val[],int n)
{
	if(r<=0)
		return 0;
	if(i==n)
		return INT_MAX;
	if(dp[r][i]!=-1)
		return dp[r][i];

	return dp[r][i]=min(solve(r,i+1,wt,val,n),wt[i]+solve(r-val[i],i+1,wt,val,n));
}
int32_t main()
{

	 int n,w;
	 cin>>n>>w;
	 int wt[n+1];
	 int val[n+1];
	 int V=0;
	 for(int i=0;i<n;i++)
	 {
	 	cin>>wt[i];
	 	cin>>val[i];
	 	V+=val[i];
	 }
	 memset(dp,-1,sizeof(dp));
	for(int i=V;i>=0;i--)
	{
		if(solve(i,0,wt,val,n)<=w)
		{
		  cout<<i<<endl;
		  break;
		}

	}

}


Measured memory_bytes: 82304
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb = new StringBuilder(br.readLine());
		int n = Integer.parseInt(br.readLine());
		StringBuilder temp;
		for (int i = 0; i < n; i++) {
			String[ ] splitCommand = br.readLine().split(" ");
			int a = Integer.parseInt(splitCommand[1]);
			int b = Integer.parseInt(splitCommand[2]);
			if (splitCommand[0].startsWith("p")) {
				// ????????????print a b????????´???
				System.out.println(sb.substring(a, b + 1));
			} else if (splitCommand[0].startsWith("rev")) {
				// ????????????reverse a b????????´???
				temp = new StringBuilder(sb.substring(a, b + 1));
				temp.reverse();
				sb.replace(a, b + 1, new String(temp));
			} else {
				// ????????????replace a b p????????´???
				String p = splitCommand[3];
				sb.replace(a, b + 1, p);
			}
		}
	}
}

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

int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  for(int i=0; i<N; i++){
    cin >> a.at(i);
  }
  sort(a.begin(), a.end());
  reverse(a.begin(), a.end());
  
  int Alice=0,Bob=0;
  for(int i=0; i<N; i++){
    if(i%2==0){
      Alice+=a.at(i);
    }
    else{
      Bob+=a.at(i);
    }
  }
  cout << Alice-Bob <<endl;
}


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

int ds(int p){
  int ret = 0;
  for(int i = (int)log10(p); i >= 0; i--){
    ret += (p / pow(10, i));
    p -= (int)(p / pow(10, i)) * pow(10, i);
  }
  return ret;
}

int main() {
    int n = 0;
    int ans = INT_MAX, tmp = 0;
    cin >> n;
    for(int i = 1; i <= n/2; i++){
        tmp = ds(i) +  ds(n - i);
        if(ans > tmp)ans = tmp;
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	int n,k,f,x,y,t,t1,t2;
	cin>>n;
	int a,b;
	a=b=0;
	f=1;
	t1=0;
	while(n--)
	{
		cin>>t2>>x>>y;
		t=t2-t1;
		k=abs(x-a)+abs(y-b);
		if(k<=t)
		{
			a=x;
			b=y;
		}
		else
		{
			f=0;
		}
		if(t%2!=k%2)
		{
			f=0;
		}
		t1=t2;
	}
	if(f)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
return 0;
}

Measured memory_bytes: 256
N, M, C = map(int, input().split())

B = list(map(int, input().split()))

A = []
for _ in range(N):
    temp = list(map(int, input().split()))
    A.append(temp)

cnt = 0
for a_list in A:
    sum = 0
    for a, b in zip(a_list, B):
        sum += a*b
    if sum + C > 0:
        cnt += 1

print(cnt)

Measured memory_bytes: 3064
n,m,x,y = map(int,input().split())
xl = list(map(int,input().split()))
yl = list(map(int,input().split()))
xl.append(x)
yl.append(y)
xl.sort()
yl.sort()

if xl[-1] < yl[0]:
    print('No War')
else:
    print('War')

Measured memory_bytes: 9112
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

use std::cmp::min;

fn main() {
    let n = read::<usize>();
    let k = read::<usize>();

    let s = read::<String>().chars().collect::<Vec<char>>();
    let mut ans = 0;

    for i in 1..s.len() {
        if s[i] == s[i-1] {
            ans+=1;
        }       
    }

    println!("{}", min(ans + k*2, n-1))
}

Measured memory_bytes: 4352
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<string>
using namespace std;


int n,m,q;
int x[10];
int y[10];
int a[100],b[100],c[100],d[100];
int next_permutation(void);
int checkq(void);

int main(void){
        int i,j;

        scanf("%d%d%d", &n,&m,&q);

        for(i=0;i<q;i++){
                scanf("%d%d%d%d", &a[i],&b[i],&c[i],&d[i]);
        }
        for(i=0;i<q;i++){
                a[i]--;
                b[i]--;
        }
        for(i=0;i<n;i++){
                x[i] = 1;
        }
       
        int M = checkq();

  // printf("%d\n",checkq());
        while(x[0]!=m || x[n-1]!=m){
                next_permutation();
                for(i=0;i<n;i++){
                        y[i]=x[i];
                }
                if(checkq() >= M){
                        M = checkq();
                }
        }

        printf("%d\n",M);

        return 0;

}

int next_permutation(void){
        int i,j;
        for(i=n-1;i>=0;i--){
                if(x[i]<m){
                        x[i]++;
                        for(j=i;j<n;j++){
                                x[j] = x[i];
                        }
                        return 0;
                }
        }
}

int checkq(void){
        int i,j;
        int score = 0;
        for(i=0;i<q;i++){
                if(y[b[i]] - y[a[i]] == c[i]){
                        score = score + d[i];
                }
        }
        return score;
}


Measured memory_bytes: 3708
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

typedef long long ll;

#define rep(i, a, n) for (ll i = a; i < (ll)n; ++i)
#define repd(i, n) for (ll i = (n)-1; i >= 0; --i)
#define INF 10e12
#define MOD 1000000000 + 7
#define MAX 51000
#define all(x) (x).begin(), (x).end()
#define MX(x) *max_element(all(x))
#define MN(x) *min_element(all(x))

using namespace std;

int main(void)
{
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    int n, l;
    cin >> n >> l;
    int all = (l + n - 1 + l) * (double)n / 2;
    if (l <= 0)
    {
        if (l + n - 1 >= 0)
        {
            cout << all << endl;
            return 0;
        }
        else
        {
            cout << all - (l + n - 1) << endl;
            return 0;
        }
    }
    cout << all - l << endl;
}

Measured memory_bytes: 3640
N = int(input()); MOD = pow(10,9)+7
A = list(map(int,input().split()))
S = sum(A)**2%MOD
nijo = 0
for x in A:
  nijo = (nijo + x**2)%MOD
ans = (S-nijo)*pow(2,MOD-2,MOD)%MOD
print(ans%MOD)

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

int main(){
  string S = "Sunny",C = "Cloudy",R = "Rainy",X;
  cin >> X;
  
  if(X == S)
    cout << C << '\n';
  else if(X == C)
    cout << R << '\n';
  else if(X == R)
    cout << S << '\n';
  return 0;
}
  


Measured memory_bytes: 256
import java.util.Scanner;


public class Main {
	
	static Scanner sc = new Scanner(System.in);
	static int n, m, i=0;
	static int a[] = new int[3];

	public static void main(String[] args) {
		
		while(read())
		{
			solve();
		}
	}
	
	static boolean read(){
		if(!sc.hasNext()) return false;
		if(n == m) n = sc.nextInt();
		
		a[i] = sc.nextInt();
		i++;
		
		return true;
	}
	
	static void solve(){
		if(i != 3) return;
		
		System.out.println((a[0] * a[0] == a[1] * a[1] + a[2] * a[2] ||
		   a[1] * a[1] == a[0] * a[0] + a[2] * a[2] ||
		   a[2] * a[2] == a[0] * a[0] + a[1] * a[1])
		   ?"YES":"NO");
		i=0;
	}

}

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

#define M 1000000
#define NIL -1
#define L 14

char H[M][L];

int getChar(char ch) {
  if ( ch == 'A' ) return 1;
  else if ( ch == 'C' ) return 2;
  else if ( ch == 'G' ) return 3;
  else if ( ch == 'T' ) return 4;
  else return 0;
}

long long getKey(char str[]) {
  long long sum = 0, p = 1, i;
  for (i = 0; i < strlen(str); i++ ) {
    sum += p*(getChar(str[i]));
    p *= 5;
  }
  return sum;
}

int h1(int key){ return key % M; }
int h2(int key){ return (key % (M - 1))+1; }

int find(char str[]) {
  

  long long i, h;
  
  long long key = getKey(str);
  
  for (i = 0; ; i++ ) {
    h = (h1(key) + h2(key)* i ) % M;

    if ( strcmp(str,H[h]) == 0 ) return 1;
    else if ( strlen(H[h]) == 0 ) return 0;

  }
  
  return 0;
}

int insert(char str[]) {
  
  long long i, h;
  long long key = getKey(str);

  for (i = 0; ; i++) {
    h = (h1(key) + h2(key)* i ) % M;

    if ( strcmp(H[h],str) == 0 ) return 1;
    else if ( strlen(H[h]) == 0 ) {
      strcpy(H[h], str);
      return 0;
    }

  }
  
  return 0;
}

int main() {
  int i, n, h;
  char str[L], com[9];
  for (i = 0; i < M; i++ ) H[i][0] = '\0';
  scanf("%d", &n);
  for (i = 0; i<n; i++) {
    scanf("%s %s", com, str); 
    if ( com[0] == 'i' ) {
      insert(str);
    } else {
      if ( find(str) ) {
	printf("yes\n");
      } else {
	printf("no\n");
      }
    }
  }
  return 0;
}



Measured memory_bytes: 15404
#include<iostream>
#include<math.h>
#include<vector>
#include<array>
#include<algorithm>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<set>
#include<cstdio>
#include<cstring>
#include<string>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const ll INF=1e18;

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

    ll X, Y, Z;
    cin >> X >> Y >> Z;

    cout << Z << " " << X << " " << Y << '\n';

    return 0;
}

Measured memory_bytes: 256
n = int(input())
l1 = []
l2 = []
for i in range(n):
    a, b = map(int, input().split())
    l1.append(a)
    l2.append(b)
l1.sort()
l2.sort()
if n % 2:
    t0 = l1[n // 2]
    t1 = l2[n // 2]
    print(t1 - t0 + 1)
else:
    x1 = l1[n // 2]
    x0 = l1[(n - 1) // 2]
    y1 = l2[n // 2]
    y0 = l2[(n - 1) // 2]
    if x0 > x1: x0, x1 = x1, x0
    if y0 > y1: y0, y1 = y1, y0
    print(y1 - x1 + 1 + y0 - x0)
    # tmp1 = l[(n - 1) // 2]
    # tmp2 = l[n // 2]
    # print(tmp2[1] - tmp2[0] + 1 + tmp1[1] - tmp1[0])

Measured memory_bytes: 98952
#include <stdio.h>

int main(int argc, char const *argv[]) {

  int A, B, K;
  scanf("%d %d %d", &A, &B, &K);

  if (A < B) {
    int C = B;
    B = A;
    A = C;
  }

  int c = 0;
  int i;
  for (i = A; i >= 0; i--) {
    if ((A % i == 0) && (B % i == 0)) {
      c += 1;
      //printf("公約数は%d\n", i);
      if (c == K) {
        break;
      }
    }
  }

  printf("%d\n", i);

  return 0;

}


Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
using namespace std;

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

using LL = long long;
using PII = pair<int, int>;
using VI = vector<int>;

const int dx[4] = {0, 0, -1, 1};
const int dy[4] = {1, -1, 0, 0};
int n, m;
char s[2000][2000];
int b[2000][2000];
vector<int> q;

int bfs(char r) {
    memset(b, -1, sizeof(b));
    q.clear();
    REP(i, n) REP(j, m) if (s[i][j] == r) {
        q.push_back(i * m + j);
        b[i][j] = 0;
    }
    int ans = 0;
    for (int i = 0; i < q.size(); i++) {
        int x = q[i] / m;
        int y = q[i] % m;
        REP(k, 4) {
            int tx = x + dx[k];
            int ty = y + dy[k];
            if (tx < 0 || tx >= n || ty < 0 || ty >= m || b[tx][ty] != -1)
                continue;
            q.push_back(tx * m + ty);
            ans = b[tx][ty] = b[x][y] + 1;
        }
    }
    return ans;
}

int main() {
    scanf("%d%d", &n, &m);
    REP(i, n) scanf("%s", s[i]);
    cout << bfs('#') << endl;
    return 0;
}

Measured memory_bytes: 25196
#include<stdio.h>
int main(void)
{
    int n,x[100000],y[100000],t[100000],i,sum=0;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d %d %d",&t[i],&x[i],&y[i]);
        sum++;
        if((t[i]-x[i]-y[i])<0) sum--;
        else if((t[i]-x[i]-y[i])%2) sum--;
        }
    if(sum==n) printf("Yes");
    else printf("No");
    return 0;
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define loop(i, r, n) for (int i = (r); i <= (n); i++)

using ll = long long;
using namespace std;

const ll MOD = 1000000007;

int main(){
    int n; cin >> n;
    vector<vector<int>> a(n,vector<int>(n)); rep(i,n) rep(j,n) cin >> a[i][j];
    vector<ll> ans(1<<n,0); ans[0] = 1;
    rep(i,(1<<n)-1){
        int num = __builtin_popcount(i);
        rep(j,n) if(!(i & 1<<j) && a[num][j]) ans[i^(1<<j)] += ans[i], ans[i^(1<<j)] %= MOD;
    }
    cout << ans[(1<<n)-1] << endl;
}

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

using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define MIN(a,b) ((a)>(b)? (b): (a))
#define MAX(a,b) ((a)<(b)? (b): (a))

const long long INF = 1LL << 60;
typedef unsigned long long ll;
const long long MOD = 1000000000 + 7;

int main(){
    int x,a,b;
    cin >> x >> a >> b;
    if(a >= b){
        cout << "delicious" << endl;
        return 0;
    }
    if(b-a>x) cout << "dangerous" << endl;
    else cout << "safe" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define ull unsigned long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int dy[] = {0, 0, 1, -1, 0};
int dx[] = {1, -1, 0, 0, 0};

int gcm(int a, int b)
{
    if (b == 0)
        return a;
    gcm(b, a % b);
}

int main()
{
    int n;
    double s = 0;
    cin >> n;
    REP(i, n)
    {
        double x;
        string u;
        cin >> x >> u;
        if (u.find("BTC") != -1)
            s += 380000.0 * x;
        else
            s += x;
    }
    cout << s << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int v2(int x){
    if(x==0) return 0;
    return x/2+v2(x/2);
}
bool div2(int n,int k){
    if(n==0 && k==0) return false;
    return (v2(n)-v2(k)-v2(n-k))>0;
}
int main(){
    int n;
    cin >> n;
    string a;
    cin >> a;
    int dig[n];
    for(int i=0;i<n;i++){
        if(a[i]=='1'){
            dig[i] = 1;
        }
        else if(a[i]=='2'){
            dig[i] = 2;
        }
        else{
            dig[i] = 3;
        }
    }
    int mod2 = 0;
    for(int i=0;i<n;i++){
        if(!div2(n-1,i)){
            mod2+=dig[i];
            mod2%=2;
        }
    }
    if(mod2%2){
        cout << 1 << endl;
        return 0;
    }
    //differentiate between 0 and 2??
    int dig2[n-1];
    bool zero = false;
    for(int i=0;i<n-1;i++){
        dig2[i] = abs(dig[i]-dig[i+1]);
        if(dig2[i]%2) zero = true;
    }
    int mod4 = 0;
    for(int i=0;i<n-1;i++){
        if(!div2(n-2,i)){
            mod4+=dig2[i];
            mod4%=4;
        }
    }
    if(mod4%4==2 && !zero){
        cout << 2 << endl;
    }
    else{
        cout << 0 << endl;
    }

    return 0;

}



Measured memory_bytes: 11724
def run():
  N = int(input())
  abc_li = [[int(i) for i in input().split()] for n in range(N)]
  dp = [[0]*3 for n in range(N)]
  dp[0] = abc_li[0]
  for n in range(1, N):
    for next_abc in range(3):
      for pre_abc in range(3):
        if pre_abc == next_abc: continue
        dp[n][next_abc] = max(dp[n][next_abc], dp[n-1][pre_abc]+abc_li[n][next_abc])
  print(max(dp[N-1]))
  
if __name__ == '__main__':
  run()

Measured memory_bytes: 44072
fn main() {
    let n: i32 = read();
    let list: Vec<i32> = read_vec();
    let max = list.iter().max().unwrap();
    let mut r = 0;
    let max2 = max / 2;
    
    for &x in &list {
        if (r - max2).abs() > (x - max2).abs() {
            r = x;
        }
    }
    
    println!("{} {}", max, r);
    
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}

Measured memory_bytes: 4352
import java.util.*;

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

        long a = sc.nextLong();
        long b = sc.nextLong();
        long c = sc.nextLong();
 
        if(4*a*b<(c-a-b)*(c-a-b) && c-a-b>0){
            System.out.println("Yes");
        }
        else{
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 22608
#include <iostream>
#include <utility>
#include <tuple>
#include <string>
#include <cstdint>
#include <vector>
#include <array>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <cassert>
using namespace std;
using i64 = int64_t;
int main() {
    int n;
    vector<int> a;
    cin >> n;
    a.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    reverse(begin(a), end(a));
    vector<int> lis;
    for (int i = 0; i < n; ++i) {
        auto it = lower_bound(begin(lis), end(lis), a[i] + 1);
        if (it == end(lis)) {
            lis.push_back(a[i]);
        } else {
            *it = a[i];
        }
    }
    cout << lis.size() << endl;
    return 0;
}

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

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)

int main()
{
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  while (1)
  {
    c -= b;
    if (c <= 0)
    {
      cout << "Yes" << endl;
      break;
    }
    a -= d;
    if (a <= 0)
    {
      cout << "No" << endl;
      break;
    }
  }
  return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <cmath>
using namespace std;
 
int main()
{
	string a,b;
	int x;
	int zh(string s);
	
	cin>>a>>b;   //1 21
	
	x=zh(a+b);
	
	if(int(sqrt(x))==sqrt(x))
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
	
	return 0;
}
 
int zh(string s)    //"121"
{
	int tmp=0;
	
	for(int i=0;i<s.size();i++)
		tmp=tmp*10+(s[i]-'0');
	
	return tmp;
}

Measured memory_bytes: 256