akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
// type alias
typedef long long LL;
typedef pair<int,int> II;
typedef tuple<int,int,int> III;
typedef vector<int> VI;
typedef vector<string> VS;
typedef unordered_map<int,int> MAPII;
typedef unordered_set<int> SETI;
template<class T> using VV=vector<vector<T>>;
// minmax
template<class T> inline T SMIN(T& a, const T b) { return a=(a>b)?b:a; }
template<class T> inline T SMAX(T& a, const T b) { return a=(a<b)?b:a; }
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// collection
#define ALL(c) (c).begin(),(c).end()
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// stdout
#define println(args...) fprintf(stdout, ##args),putchar('\n');
// debug cerr
template<class Iter> void __kumaerrc(Iter begin, Iter end) { for(; begin!=end; ++begin) { cerr<<*begin<<','; } cerr<<endl; }
void __kumaerr(istream_iterator<string> it) { (void)it; cerr<<endl; }
template<typename T, typename... Args> void __kumaerr(istream_iterator<string> it, T a, Args... args) { cerr<<*it<<"="<<a<<", ",__kumaerr(++it, args...); }
template<typename S, typename T> std::ostream& operator<<(std::ostream& _os, const std::pair<S,T>& _p) { return _os<<"{"<<_p.first<<','<<_p.second<<"}"; }
#define __KUMATRACE__ true
#ifdef __KUMATRACE__
#define dump(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); __kumaerr(_it, args); }
#define dumpc(ar) { cerr<<#ar<<": "; FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }
#define dumpC(beg,end) { cerr<<"~"<<#end<<": "; __kumaerrc(beg,end); }
#else
#define dump(args...)
#define dumpc(ar)
#define dumpC(beg,end)
#endif

// $ cp-batch LuckyPIN | diff LuckyPIN.out -
// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG -fsanitize=address LuckyPIN.cpp && ./a.out

/*
 
 12/1/2019
 
 4:13-
 
 */

int N;
string S;

bool issubseq(string &S, string &SS) {
  int p=0;
  for(int i=0; i<S.size(); ++i) if(p<SS.size()&&S[i]==SS[p]) {
    ++p;
  }
  return p==SS.size();
}

void solve() {
  int res=0;
  REP(a,10)REP(b,10)REP(c,10) {
    string s; s.push_back('0'+a),s.push_back('0'+b),s.push_back('0'+c);
    if(issubseq(S,s)) ++res;
  }
  cout<<res<<endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout<<setprecision(12)<<fixed;
  
  cin>>N>>S;
  solve();
  
  return 0;
}


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

int main()
{
    int n, k; cin>>n>>k;
    vector<long> s(n+1), p(n+1);
    for(int i=0; i<n; ++i) {
        int a; cin>>a;
        p[i+1]=p[i]+(a>0)*a;
        s[i+1]=s[i]+a;
    }
    long res=0;
    for(int i=1; i+k-1<=n; ++i) {
        auto x=p[n]-(p[i+k-1]-p[i-1]);
        auto y=s[i+k-1]-s[i-1];
        if (y>0) x+=y;
        res=max(res, x);
    }
    cout<<res;
}


Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <utility>
#include <climits>
#include <iomanip>
using namespace std;
#define MAXSIZE 100005
#define MAXL 100
#define MOD_CONST 1000000007
typedef long long int lli;

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

    vector<lli> b(n - 1);
    for(lli ib = 0; ib < n - 1; ib++){
        cin >> b[ib];
    }

    lli ans = 0;
    for(lli ians = 0; ians < n; ians++){
        ans += (ians == 0) ? b[0]
                : (ians < n - 1) ? min(b[ians - 1], b[ians])
                : b[n - 2];
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 888
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <string>
#include <array>
#include <cmath>
#include <queue>
#include <stack>
using namespace std;
using ll = long long;

int main() {

	ll n;
	cin >> n;

	ll res = 72036854775807;
	for (ll i = 1; i <= 1000000; ++i) {
		if (n % i == 0)
		{
			ll j = n / i;
			if (i * j == n)
			{
				ll tmp = i + j;
				res = min(tmp, res);
			}
		}
	}

	cout << res - 2 << endl;

	return 0;
}

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

typedef long long ll;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); ++itr)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second

const ll mod=1e9+7;

int n,a,b,c,d;

ll C[1010][1010]={};
ll dp[1010][1010];
ll fact[1010];
ll fact_inv[1010];

ll mod_inv(ll x)
{
    ll pw[32];
    pw[0]=x;
    for(int i=1; i<32; ++i) pw[i]=(pw[i-1]*pw[i-1])%mod;

    ll ret=1;
    ll p=mod-2;
    rep(i,32) if(p>>i&1) (ret*=pw[i])%=mod;
    return ret;
}

void init()
{
    // combination
    rep(i,1001)
    {
        C[i][0]=C[i][i]=1;
        for(int j=1; j<i; ++j) C[i][j] = (C[i-1][j-1]+C[i-1][j])%mod;
    }

    // fact
    fact[0]=fact[1]=1;
    for(int i=2; i<1001; ++i) fact[i]=(fact[i-1]*i)%mod;

    rep(i,1001) fact_inv[i] = mod_inv(fact[i]);

    // initialize
    memset(dp,-1,sizeof(dp));
}

ll dfs(int rem, int group)
{
    if(group==b+1) return rem?0:1;
    if(dp[rem][group]>=0) return dp[rem][group];

    ll ret=0;

    // 0人
    (ret+=dfs(rem,group+1))%=mod;

    if(c*group <= rem)
    {
        int tr = rem;
        int i=0;
        ll comb=1;
        while(i<c)
        {
            (comb*=C[tr][group])%=mod;
            tr -= group;
            ++i;
        }

        while(i<=d)
        {
            if(tr<0) break;

            // printf(" i = %d\n", i);
            ll add = (dfs(rem-i*group, group+1)*comb)%mod;
            (add*=fact_inv[i])%=mod;

            (ret+=add)%=mod;

            (comb*=C[tr][group])%=mod;
            tr -= group;
            ++i;
        }
    }

    return dp[rem][group]=ret;
}

int main()
{
    cin >>n >>a >>b >>c >>d;
    init();
    cout << dfs(n,a) << endl;
    return 0;
}


Measured memory_bytes: 15232
#include<cstdio>
#include<cstdlib>
#include<cstring>

struct Node {
    int key;
    Node *next, *prev;
};

Node *nil;

Node* listSearch(int key) {
    Node *cur = nil->next;
    while(cur != nil && cur->key != key) {
        cur = cur->next;
    }
    return cur;
}

void init() {
    nil = (Node *)malloc(sizeof(Node));
    nil->next = nil;
    nil->prev = nil;
}

void printList() {
    Node *cur = nil->next;
    int isf = 0;
    while(1) {
        if(cur == nil) break;
        if(isf++ > 0) printf(" ");
        printf("%d", cur->key);
        cur = cur->next;
    }
    printf("\n");
}

void deleteNode(Node *t) {
    if(t == nil) return;
    t->prev->next = t->next;
    t->next->prev = t->prev;
    free(t);
}

void deleteFirst() {
    deleteNode(nil->next);
}

void deleteLast() {
    deleteNode(nil->prev);
}

void deleteKey(int key) {
    deleteNode(listSearch(key));
}

void insert(int key) {
    Node *x = (Node *)malloc(sizeof(Node));
    x->key = key;
    x->next = nil->next;
    nil->next->prev = x;
    nil->next = x;
    x->prev = nil;
}

int main() {
    int key, n, i;
    int size = 0;
    char com[20];
    int np = 0, nd = 0;
    scanf("%d", &n);
    init();
    for(int i = 0; i < n; i++) {
        scanf("%s%d", com, &key);
        if(com[0] == 'i') { insert(key); np++; size++; }
        else if(com[0] == 'd') {
            if(strlen(com) > 6) {
                if(com[6] == 'F') deleteFirst();
                else if(com[6] == 'L') deleteLast();
            } else {
                deleteKey(key); nd++;
            }
            size--;
        }
    }
    printList();
    return 0;
}


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

int main(){
  string T;
  string S;
  int cnt = 0;
  
  cin >> S;
  cin >> T;
  
  for(int i = 0 ; i < 3 ; i++){
  if(T[i] == S[i]){
    cnt++;
   }
  }

  cout << cnt << endl;
    
  return 0;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.util.Scanner;
 
public class Main {
 
    public static void main(String[] args) throws IOException {
        Scanner scanner = new Scanner(System.in);
        String[] tmp = scanner.nextLine().split(" ");
        scanner.close();
        Integer side1 = Integer.valueOf(tmp[0]);
        Integer side2 = Integer.valueOf(tmp[1]);
        Double angle1 = Math.toRadians(Double.valueOf(tmp[2]));
 
        Double s = (side1 * side2 * Math.sin(angle1)) / 2;
        Double l = (side1 + side2)
                + Math.sqrt((side1 * side1) + (side2 * side2)
                        - (2 * side1 * side2 * Math.cos(angle1)));
        Double h = side2 * Math.sin(angle1);
 
        System.out.println(s + "\n" + l + "\n" + h);
    }
 
}

Measured memory_bytes: 26264
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

int main() {
  int h, w;
  cin >> h >> w;
  vector<vector<char>> s(h, vector<char>(w));

  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      cin >> s[i][j];
    }
  }

  vector<bool> tate(h, false), yoko(w, false);
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      if (s[i][j] == '#') {
        tate[i] = true;
      }
    }
  }

  for (int j = 0; j < w; j++) {
    for (int i = 0; i < h; i++) {
      if (s[i][j] == '#') {
        yoko[j] = true;
      }
    }
  }

  for (int i = 0; i < h; i++) {
    if (!tate[i]) {
      continue;
    }
    for (int j = 0; j < w; j++) {
      if (yoko[j]) {
        cout << s[i][j];
      }
    }
    cout << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <list>
#include <utility>
#include <tuple>
#include <cstdio>
#include <set>
#include <queue>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <cmath>
#include <limits>
#include <iomanip>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
const long long INF = 1LL << 60;
typedef long long ll;
int main() {
    ll N,T;
    cin >> N >> T;
    vector<ll> t(N);
    for(int i=0;i<N;i++){
        cin >> t[i];
    }
    vector<ll> dp(N+1);
    dp[1]=T;
    for(int i=2;i<=N;i++){
        dp[i]=dp[i-1] + min(T,t[i-1]-t[i-2]);
    }
    cout << dp[N] << endl;
}

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


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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  ll t1, t2;
  ll a1, a2, b1, b2;
  cin >> t1 >> t2 >> a1 >> a2 >> b1 >> b2;
  if (a1 > b1) {
    swap(a1, b1);
    swap(a2, b2);
  }
  ll mindist = (b1 - a1) * t1;
  ll fix = mindist - (a2 - b2) * t2;
  if (fix > 0) {
    cout << 0 << endl;
    return 0;
  }
  if (fix == 0) {
    cout << "infinity" << endl;
    return 0;
  }
  ll k = (mindist) / (-fix);
  if (k * (-fix) == mindist) {
    cout << 2 * k << endl;
  } else {
    cout << (k * 2 + 1) << endl;
  }
  return 0;
}


Measured memory_bytes: 256
'use strict';
(function(stdin) { 
  var inputs = stdin.toString();
  var params = inputs.split('\n')[0].split(' ').map(Number);
  (function(a,b) {
    //????????????????????????
    console.log(a * b,(a + b) * 2);
  }(params[0],params[1]));
}(require('fs').readFileSync('/dev/stdin', 'utf8')));

Measured memory_bytes: 7376
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef pair<int,P> P1;
#define fi first
#define sc second
#define mp make_pair
#define pb push_back
#define INF 100000000
int a[(1<<18)],n,ans[(1<<18)];
bool used[(1<<18)],bad;
vector<int>G[(1<<18)],R[(1<<18)];
int rev[(1<<18)],in[(1<<18)];
void solve(int L,int R,vector<int>zan){
	if(L == R){
		ans[L] = zan[0];
		return;
	}
	vector<int>lb,ub;
	for(int i=L;i<R;i+=2){
		if(zan[i-L] > zan[i+1-L]) bad = 1;
		lb.push_back(zan[i-L]);
		ub.push_back(zan[i+1-L]);
	}
	solve(L,(L+R)/2,lb);
	solve((L+R)/2+1,R,ub);
}
int mn[(1<<18)],mx[(1<<18)];
vector<P>vec[(1<<18)];
vector<int>zan;
int main() {
	cin>>n;
	for(int i=0;i<(1<<n);i++){
		cin>>a[i];
		a[i]--;
		if(a[i] >= 0){
			used[a[i]] = 1;
		}
	}
	for(int i=0;i<(1<<n);i++) if(!used[i]) zan.pb(i);
	for(int i=0;i<(1<<n);i++){
		mn[i] = 0;
		mx[i] = INF;
		if(a[i] >= 0){
			mn[i] = mx[i] = a[i];
		}
	}
	for(int i=0;i<(1<<n);i++){
		for(int j=0;j<n;j++){
			if(((i>>j)&1)){
				mn[i] = max(mn[i],mn[i-(1<<j)]);
			}
		}
	}
	for(int i=(1<<n)-1;i>=0;i--){
		for(int j=0;j<n;j++){
			if(!((i>>j)&1)){
				mx[i] = min(mx[i],mx[i+(1<<j)]);
			}
		}
	}
	for(int i=0;i<(1<<n);i++){
		if(mn[i] > mx[i]){
			puts("NO"); return 0;
		}
		if(a[i] == -1) vec[mn[i]].pb(mp(mx[i],i));
	}

	for(int i=0;i<(1<<n);i++) sort(vec[i].begin(),vec[i].end());
	priority_queue<P,vector<P>,greater<P> >que;
	for(int i=0;i<(1<<n);i++){
		for(int j=0;j<vec[i].size();j++){
			que.push(vec[i][j]);
		}
		if(used[i]) continue;
		if(que.empty() || que.top().fi < i){
		    puts("NO"); return 0;
		}
		a[que.top().sc] = i; que.pop();
	}
	//for(int i=0;i<(1<<n);i++) cout<<a[i]<<endl;
	vector<int>zip;
	for(int i=0;i<(1<<n);i++) zip.push_back(a[i]);
	solve(0,(1<<n)-1,zip);
	if(bad) puts("NO");
	else{
		puts("YES");
		for(int i=0;i<(1<<n);i++) printf("%d ",ans[i]+1);
		puts("");
	}
}

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

int main() {
    
    int A, B;
    cin >> A >> B;
    
    vector<char> x(B+2,'#');
    for (int j = 0; j < B + 2; j++){
        cout << x.at(j);
    }
    cout << endl;
    
    for (int i = 0; i < A; i++){
    string y;
    cin >> y;
    cout << "#" + y + "#" << endl;
    }
    
    for (int j = 0; j < B + 2; j++){
        cout << x.at(j);
    }
    cout << endl;
}

Measured memory_bytes: 256
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

enum P = 10L^^9+7;

void main()
{
    auto nk = readln.split.to!(int[]);
    auto N = nk[0];
    long K = nk[1];
    auto AS = readln.split.to!(int[]);

    long[] xs, ys;
    xs.length = N;
    ys.length = N;
    foreach (i, a; AS) {
        long x, y;
        foreach (j, b; AS) {
            if (b > a && j < i) ++x;
            if (b > a) ++y;
        }
        xs[i] = x;
        ys[i] = y;
    }
    long r;
    auto k = (K * (K - 1) / 2) % P;
    foreach (i; 0..N) {
        r = (r + (K *xs[i]) % P + (k * ys[i]) % P) % P;
    }
    writeln(r);
}

Measured memory_bytes: 380
//============================================================================
// Name        : main.cpp
// Author      : nekoroko
// Version     : none
// Copyright   : Your copyright notice
// Description : AtCoder
//============================================================================
#include <iostream>
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<queue>
#include<stack>
#include<cmath>
#include<list>
#include<set>

using namespace std;

int main() {
	int N;
	scanf("%d", &N);
	vector<long long> A(N);
	vector<long long> rain(N);
	for(int i = 0; i < N; ++i){
		scanf("%ld", &A[i]);
	}

	long long rain1 = 0;
	for(int i = 0; i < N; ++i){
		if(i % 2 == 0)rain1 += A[i];
		else rain1 -= A[i];
	}
	rain[0] = rain1;

	for(int i = 1; i < N; ++i){
		rain[i] = 2 * (A[i - 1] - rain[i - 1] / 2);
	}

	for(int i = 0; i < N; ++i){
		printf("%ld ", rain[i]);
	}
	printf("\n");

	return 0;
}



Measured memory_bytes: 2816
n = int(input())

tree = {i: [] for i in range(n)}

for _ in range(n-1):
  t = input().split()
  u, v = int(t[0]), int(t[1])
  tree[u-1].append(v-1)
  tree[v-1].append(u-1)

a = 0
idx = 0
q = []
q.append(a)
v = [0 for _ in range(n)]
v[a] = 1

while (idx != len(q)):
    a = q[idx]
    idx += 1
    for b in tree[a]:
        if (v[b] == 0):
            q.append(b)
            v[b] = 1

s = a
idx = 0
q = []
q.append([a, 1])
v = [0 for _ in range(n)]
v[a] = 1

while (idx != len(q)):
    a = q[idx]
    idx += 1
    for b in tree[a[0]]:
        if (v[b] == 0):
            q.append([b, a[1] + 1])
            v[b] = 1

l = a[1]
if l%3 == 2:
    print("Second")
else:
    print("First")

Measured memory_bytes: 121056
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mk make_pair
#define pii pair<int,int>
#define fst first
#define scd second
using namespace std;

inline ll read() {
	ll f=1,x=0;
	
	char ch=getchar();
	while(!isdigit(ch)){
	   if(ch=='-')f=-1;
	   ch=getchar();
	}
	
	while(isdigit(ch)){
	   x=x*10+ch-'0';
	   ch=getchar();
	}
	
	return x*f;
}

const int MAXN=1e5+5;
int n,m,fa[MAXN];

struct EDGE {
	int u,v;
}e[MAXN];

ll ans[MAXN],sz[MAXN];

int get_fa(int x) {
	if(x==fa[x]) return x;
	return fa[x]=get_fa(fa[x]);
}

int main() {
    //freopen("","r",stdin);
    //freopen("","w",stdout);
	
	ios::sync_with_stdio(0);
	cin.tie(0);/*syn加速*/
	
	n=read();
	m=read();
	
	for(int i=1;i<=m;++i) {
		e[i].u=read(); 
		e[i].v=read();
	}
	
	for(int i=1;i<=n;++i) 
	   fa[i]=i,sz[i]=1;
	
	ans[m]=(ll)n*(n-1)/2;
	
	for(int i=m;i>=1;--i) {
		int u=get_fa(e[i].u),v=get_fa(e[i].v);
		if(u==v) 
		    ans[i-1]=ans[i];
		else {
			ans[i-1]=ans[i]-sz[v]*sz[u];
			sz[v]+=sz[u]; fa[u]=v;
		}
	}
	
	for(int i=1;i<=m;++i) 
	   cout<<ans[i]<<endl;
	return 0;
}






Measured memory_bytes: 4096
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> llP;

ll mod(ll a, ll b){
  ll ret=a%b;
  if(ret<0) ret+=b;
  return ret;
}

ll modpow(ll a,ll b,ll c){
  ll res=1;
  while(b>0){
    if(b&1) res=mod(res*a,c);
    a=mod(a*a,c);
    b>>=1;
  }
  return res;
}

int main() {
  ll MAX=1000000000000000000;
  int n;
  cin>>n;
  ll a[n];
  for(int i=0;i<n;i++){
    cin>>a[i];
    if(a[i]==0){
      cout<<0<<endl;
      return 0;
    }
  }
  ll ans=1;
  for(int i=0;i<n;i++){
    if(MAX/ans>=a[i]){
      ans*=a[i];
    }
    else {
      cout<<-1<<endl;
      return 0;
    }
    if(ans==0){
      cout<<ans<<endl;
      return 0;
    }
  }
  cout<<ans<<endl;
  return 0;
}


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

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

using namespace std;

bool fd[10][10000];

int h, w;

int search( int r )
{
	int res = 0;
	if(r >= h) {
		rep(x, w) {
			int t_sum = 0;
			rep(y, h) {
				if(!fd[y][x]) ++t_sum;
			}
			res += max(t_sum, h-t_sum);
		}
		return res;
	}
	rep(i, w) {
		fd[r][i] = !fd[r][i];
	}
	res = max(res, search(r + 1));
	rep(i, w) {
		fd[r][i] = !fd[r][i];
	}
	res = max(res, search(r + 1));
	return res;
}

int main( void )
{
	while(cin >> h >> w, h | w) {
		rep(y, h) rep(x, w) {
			cin >> fd[y][x];
		}
		cout << search(0) << endl;
	}
	return 0;
}

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

int main(){
  int N,A;
  cin >> N >> A;
  if (N <= A || N % 500 == 0|| N % 500 <= A)
  {
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
// clang-format off
#include <bits/stdc++.h>

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (size_t i = 0; i < size_t(n); i++)
#define forn1(i,n) for (size_t i = 1; i <= size_t(n); i++)
#define popcnt __builtin_popcount
#define ffs __builtin_ffs
#define ctz __builtin_ctz
#define clz __builtin_clz
#define all(a) (a).begin(), (a).end()
 
using namespace std;

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
using pil = pair<int,ll>;
using pll = pair<ll,ll>;
template <typename T> using vec = vector<T>;
using vi = vec<int>;
using vl = vec<ll>;
template <typename T> using que = queue<T>;
template <typename T> using deq = deque<T>;

template <typename T> T id(T b) {return b;};
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}
template <typename S, typename K> bool contains(S s, K k) { return s.find(k) != s.end(); }
void fastio() { ios_base::sync_with_stdio(false); cin.tie(nullptr); }
constexpr ll TEN(int n) { if (n == 0) return 1LL; else return 10LL*TEN(n-1); }
// clang-format on

int main() {
    fastio();

    int a, b, c;
    cin >> a >> b >> c;

    if (a + b + c >= 22)
        cout << "bust\n";
    else
        cout << "win\n";

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define For(i,m,n) for(int i=m;i<n;i++)
#define FOR(n) for(int i=0;i<n;i++)
#define ll long long
ll mob=1000000007;
using namespace std;
int main()
{ 
string s;
cin>>s;int flag =0;
int y=s.length();
int u=(y-1)/2;
int p=((y+3)/2)-1;
for(int i=0;i<u/2;i++)
{
    if(s[i]==s[u-1-i])
    {continue;
        
    }
    else
    {
        flag =1;
      
    }
}
for(int i=p;i<(y-p)/2;i++)
{
    if(s[i]==s[(y-p)-1-i])
    {continue;
        
    }
    else
    {
        flag =1;
        
    }
}
for(int i=0;i<y;i++)
{
    if(s[i]==s[y-1-i])
    {continue;
        
    }
    else
    {
        flag =1;
        
    }
}

if(flag==0)
{cout<<"Yes";}
else
cout<<"No";




return 0;
}


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

namespace AtCoder.Abc
{
    class A_170_FiveVariables
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            // 整数配列の入力
            var inputLongArray = Console.ReadLine().Split(' ').Select(j => long.Parse(j)).ToArray();
            int i;
            for (i = 0; i < inputLongArray.Length; i++)
            {
                if (inputLongArray[i] == 0)
                {
                    break;
                }
            }
            long result = i + 1;

            Console.WriteLine(result);

            Console.Out.Flush();
        }
    }
}


Measured memory_bytes: 27844
#include<stdio.h>
#include<string.h>
int main(){
    int c[8], i, j, k, l;
    for(i = 0;~scanf("%d" , &c[i++]);){
        if(i==8) {
            int m[8]={1,4,1,4,1,2,1,2},r[8]={9},w=1<<30;
            for(j = 0; j < 8; j++){
                l = m[0];
                memmove( m, m+1, 7*4);
                m[7] = l;
                for(k = l = 0; k<8; k++)
                    l += c[k] - m[k] <=0 ? 0:c[k] - m[k];
                if(w > l || (w == l && memcmp(m,r,32) < 0))
                    w = l, memcpy(r, m, 32);
            }
            for(j = 0; j < 8; j++)
                printf("%d%s", r[j], j==7 ? "\n":" ");
            i = 0;
        }
    }
    return 0;
}

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

#define pb push_back
#define ff first
#define ss second

using ll = long long;
using pii = pair<int, int>;

int main() {
    ios::sync_with_stdio(false);cin.tie(nullptr);
    int n; cin >> n;
    string s; cin >> s;
    int i = 0, ans = 0;
    while (i < n) {
    	char c = s[i];
    	++i;
    	++ans;
    	while (i < n && s[i] == c) ++i;
    }
    cout << ans << "\n";
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pp;
typedef pair<ll,ll> pll;
void read(int& x){ scanf("%d",&x); }
void read(ll& x){ scanf("%lld",&x); }
template<typename T,typename... Args>
void read(T& a,Args&... b){ read(a); read(b...); }
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define eb emplace_back
#define x first
#define y second

char s[100010];
int cnt[26];
ll mn[26]; int mnp[26];

int main()
{
	scanf("%s", s+1);
	for(int i=1; s[i]; ++i){
		++cnt[s[i]-'a'];
		if(i > 1){
			for(int j=0; j<26; ++j){
				ll cv = cnt[j]*2 - i;
				if(cv > mn[j]){
					printf("%d %d\n", mnp[j]+1, i);
					return 0;
				}
			}
			for(int j=0; j<26; ++j){
				ll cv = (cnt[j]-(s[i]-'a'==j))*2 - (i-1);
				if(mn[j] > cv){
					mn[j] = cv;
					mnp[j] = i-1;
				}
			}
		}
		
	}
	printf("-1 -1\n");
	return 0;
}


Measured memory_bytes: 384
/* Code by Saborit */
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("Ofast") 
#define MX 100005
#define INF (1<<30)
#define EPS 1e-9
#define MOD 1000000007
#define mid (x+xend)/2
#define izq nod*2
#define der nod*2+1
#define fr first
#define sc second
#define pb push_back
#define mp make_pair
#define all(X) (X).begin(), (X).end()
#define unique(X) (X).resize(unique(all(X)) - (X).begin())
#ifdef LOCAL
	#include "debug.h"
#endif
using namespace std;
using namespace __gnu_pbds;
typedef long long int64;
typedef unsigned long long unt64;

#define SQ(X) ((int64)(X)*(X))

struct pt{
	int x, y;
};

long double dist(pt a, pt b){
	return sqrt(SQ(a.x - b.x) + SQ(a.y - b.y));
}

int N, fact = 1;
pt A[MX];

int main(void){
    //~ freopen("a.in", "r", stdin);
    //~ freopen("a.out", "w", stdout);
    
    scanf("%d", &N);
    for(int i=1; i<=N; i++){
		scanf("%d%d", &A[i].x, &A[i].y);	
		fact *= i;
	}
	fact /= N;
	
	long double sum = 0;
	for(int i=1; i<=N; i++)
		for(int j=i+1; j<=N; j++)
			sum += dist(A[i], A[j]) * fact;
    
    fact *= N;
    
    printf("%.8LF\n", 2 * sum / fact);
    
   return 0;
}


Measured memory_bytes: 3856
import java.util.Scanner;
 
public class Main {
	public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);
      String S = sc.next();
      
      int a =S.charAt(2);
      int b =S.charAt(3);
      int c =S.charAt(4);
      int d =S.charAt(5);
      
      if(a==b && c==d){
	System.out.println("Yes");
      }
      else{
       System.out.println("No");
      }
    }
}

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

typedef long long ll;
typedef vector<ll> vint;
typedef vector< vector<ll> > vvint;

#define rep(i,n) for(ll i=0;i<n;i++)
#define repf(i,f,n) for(ll i=f;i<n;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define mp make_pair
#define mt make_tuple
#define ALL(obj) (obj).begin(), (obj).end()
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

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


int main() {
    cout<<fixed<<setprecision(10);

    ll n,d; cin>>n>>d;
    ll ans = 0;
    rep(i,n){
        ll x,y; cin>>x>>y;
        if(x*x + y*y <= d*d) ans++;
    }
    cout<<ans<<endl;

    return 0;

}

Measured memory_bytes: 3668
#include <bit>
#include <bitset>
#include <assert.h>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <stdlib.h>
#include <queue>
#include <stack>


typedef long double ld;
typedef long long ll;

using namespace std;

ll n;

int main() {
	cin >> n;
	n--;
	string ret;
	ll curp = 1;
	if (n == 0) {
		cout << "a" << endl;
		return 0;
	}
	while (n > 0) {
		int cur = (n / curp) % 26;
		ret += ((char)cur + (char)'a');
		//cerr << n << " " << ret << endl;
		n -= curp * (cur + 1);
		curp *= 26;
	}
	reverse(ret.begin(), ret.end());
	cout << ret << endl;
	return 0;
}


Measured memory_bytes: 3644
#include <algorithm>
#include <complex>
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
using namespace std;

int main()
{
    int K, S;
    cin >> K >> S;
    int ans = 0;
    for (int x = 0; x <= K; x++)
    for (int y = 0; y <= K; y++) {
        int z = S - x - y;
        if (z < 0) break;
        if (z > K) continue;
        ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FIN         ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ii          pair<int,int>
#define F           first
#define S           second
#define pb          push_back
#define all(x)      (x).begin(),(x).end()
#define rall(x)     (x).rbegin(),(x).rend()
#define fore(i,a,b) for(int i = a;i < b; i+= 1)
#define forr(i,a)   for(int i = a; i >= 0; i--)
#define fori(i,m)   for(auto i = m.begin(); i != m.end(); i++) 
#define w(t)        while(t--)
#define sz(s)       int(s.size())
#define cls(a,car)  memset(a,car,sizeof (a))
#define db(x)       cerr << #x << " is " << x << '\n'
#define FL          freopen("input.txt", "r", stdin),freopen("output.txt", "w", stdout);
#define EjecuteTime cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n"
#define angle(x)    double(x * acos(-1) / 180.0)
using namespace std;
typedef long long   ll;
typedef vector<int> vi;
typedef vector<ii>  vii;
const int N = 1 * 1e5 + 5;
const ll mod = 1e9 + 7;
const double E = 1e-9;
int dx[] = {1, 0}, dy[] = {0, 1};
//int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
//int dx[] = {2, 1, -1, -2, -2, -1, 1, 2}, dy[] = {1, 2, 2, 1, -1, -2, -2, -1};
//int dx[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy[] = {0 ,1, 1, 1, 0, -1, -1, -1};
// fflush(stdout)
// cout << flush
// a + b = a ^ b + 2 * (a & b)
ll sumMod(ll a, ll b){return a + b > mod ? a + b - mod : a + b;}
int H, W;
char v[1005][1005];
ll dp[1005][1005];
ll f(int i, int j){
    if(i == H - 1 && j == W - 1)
        return 1;
    ll &ans = dp[i][j];
    if(ans == -1){
        ans = 0;
        for(int k = 0; k < 2; k++){
            int x = i + dx[k];
            int y = j + dy[k];
            if(x >= 0 && x < H && y >= 0 && y < W && v[x][y] == '.')
                //ans = (ans % mod + f(x, y)% mod) % mod;
                ans = sumMod(ans, f(x, y));
        }
    }
    return ans;
}
int main(){
    //FL;
    FIN;
    cin >> H >> W;
    for(int i = 0; i < H; i++)
        for(int j = 0; j < W; j++)
            cin >> v[i][j];
    cls(dp, -1);
    cout << f(0, 0) << '\n';
    EjecuteTime;
    return 0;
}       

Measured memory_bytes: 12800
#include <bits/stdc++.h>
using namespace std;
int main(){
int W, H;
cin>>W>>H;

int x, y, r;
cin>>x>>y>>r;

if(x - r >= 0 && x + r <= W && y - r >= 0 && y + r <= H)
cout<<"Yes"<<endl;
else cout<<"No"<<endl;
return 0;
}


Measured memory_bytes: 3100
#include <stdio.h>

int main(){
  long ret = 0;
  long n;
  scanf("%ld",&n);
  long i;
  for(i=1; i <= n; i++){
    if(i % 3 != 0 && i % 5 != 0){
      ret+=i;
    }
  }
  printf("%ld",ret);
}


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

using namespace std;
typedef long long ll;

const ll MOD = 1000000007;
int N;
vector<ll> C;
int beforepos[200001];
ll dp[200001];

int main() {
	cin >> N;
	for (int i = 0; i < N; i++) {
		ll a;
		cin >> a;
		C.push_back(a);
	}
	C.erase(std::unique(C.begin(), C.end()), C.end());
	for (int i = 0; i <= 200000; i++)beforepos[i] = -1;
	N = C.size();
	dp[0] = 1, beforepos[C[0]] = 0;
	for (int i = 1; i < N; i++) {
		dp[i] = dp[i - 1];
		if (beforepos[C[i]] != -1) {
			dp[i] += dp[beforepos[C[i]]];
			dp[i] %= MOD;
		}
		beforepos[C[i]] = i;
	}
	cout << dp[N - 1] << endl;
	return 0;
}

Measured memory_bytes: 4336
#include <bits/stdc++.h>
using namespace std;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define Ans(f, y, n) if(f) cout << y << endl; else cout << n << endl;
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) cout << #v << "=" << endl; REP(i, v.size()){ cout << v[i] << ","; } cout << endl;
#define mdebug(m) cout << #m << "=" << endl; REP(i, m.size()){ REP(j, m[i].size()){ cout << m[i][j] << ","; } cout << endl;}
#define pb push_back
#define int long long
#define INF 1000000000000000000

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;
using pairs = vector<Pii>;

template<typename T> void readv(vector<T> &a){ REP(i, a.size()) cin >> a[i]; }
void readv_m1(vector<int> &a){ REP(i, a.size()){cin >> a[i]; a[i]--;} }

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

int mod = 1000000007;
//int mod = 998244353;
#define Add(x, y) x = (x + (y)) % mod
#define Mult(x, y) x = (x * (y)) % mod
#define AddMult(x, y, z) x = (x + (y) * (z)) % mod



signed main(){

    string s; cin >> s;
    int n = SZ(s);
    map<int, int> m;
    vec x(n + 1);
    int tmp = 0;
    x[0] = 0;
    m[0] = 0;
    int l = 1;
    REP(i, n){
        tmp ^= bit(s[i] - 'a');
        if(m.count(tmp) == 0) m[tmp] = l++;
        x[i + 1] = tmp;
    }
    vec dp(l, INF);
    dp[0] = 0;
    REP(i, n){
        int b = x[i + 1];
        //int mm = dp[m[b]];
        int mm = INF;
        REP(k, 26){
            if(m.count(b ^ bit(k)) > 0) Min(mm, dp[m[b ^ bit(k)]]);
        }
        if(mm < dp[m[b]]) dp[m[b]] = mm + 1;
        else if(i == n - 1) dp[m[b]]++;
    }
    cout << dp[m[x[n]]] << endl;

    return 0;
}


Measured memory_bytes: 16148
#include<iostream>
using namespace std;
  int main(){
    int a,b,c;
    cin>>a>>b>>c;
    if(a > b) swap(a,b);
    if(b > c) swap(b,c);
    if(a > b) swap(a,b);

    cout<<a<<" "<<b<<" "<<c<<endl;

    return 0;
}


Measured memory_bytes: 3080
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_set>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<complex>
#include<tuple>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<double,ll> pdl;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;

const ll MX=86400;
double lim;

vector<ll> A(MX+1);

const double EPS=1e-10;


bool can(double x){
    double L=lim;
    for(int i=0;i<MX;i++){
        L+=x-A[i];
        if(L<0){return false;}
        L=min(L,lim);
    }
    double k=L;
    for(int i=0;i<MX;i++){
        L+=x-A[i];
        if(L<0){return false;}
        L=min(L,lim);
    }
    if(k>L+EPS){return false;}
    return true;
}


int main(){
    ll n;
    while(cin>>n>>lim){
        if(n==0){break;}
        for(auto &I:A){I=0;}
        for(int i=0;i<n;i++){
            ll s,t,u;
            cin>>s>>t>>u;
            A[s]+=u;
            A[t]-=u;
        }
        for(int i=1;i<=MX;i++){A[i]+=A[i-1];}
        double l=0,r=1e10;
        for(int i=0;i<100;i++){
            double m=l+(r-l)/2;
            if(can(m)){r=m;}
            else{l=m;}
        }
        cout<<fixed<<setprecision(12)<<l<<endl;
    }
    
    return 0;
}



Measured memory_bytes: 3500
#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string>
#include <map>
#include <stack>
#include <queue>
#include <vector>
#define inf 0x3f3f3f3f
#define met(a,b) memset(a,b,sizeof a)
#define pb push_back
typedef long long ll;
using namespace std;
const int N = 5e2+10;
const int M = 24005;
const ll mod=1e9+7;
using namespace std;
char str[N];
int main(){
    scanf("%s",str);
    for(int i=0;i<strlen(str);i++){
        if(str[i]==',')str[i]=' ';
    }
    puts(str);
    return 0;
}


Measured memory_bytes: 256
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();
		sc.close();
		if(A + B < 10) {
			System.out.println(A + B);
		}else {
			System.out.println("error");
		}
	}
}

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

template <class T>bool chmax(T& a, T b){
    if (a < b){
        a = b; 
        return 1; 
    } 
    return 0; 
    }

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;cin>>n;
  vector<P> a(n);
  ll tot=0;
  rep(i,n){
    cin>>a[i].first;
    a[i].second=i;
  }
  sort(a.begin(),a.end(),greater<P>());
  vector<vector<ll>> dp(n+1,vector<ll>(n+1,0));
  rep(i,n){
      for(int j=0;i+j<n;j++){
         P fs=a[i+j];
        chmax(dp[i+1][j],dp[i][j]+fs.first*abs(fs.second-i));
        chmax(dp[i][j+1],dp[i][j]+fs.first*abs(n-1-j-fs.second));
      }
  }

  ll res=0;
  rep(i,n+1)chmax(res,dp[i][n-i]);
  cout<<res<<endl;
  return 0;
  }


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

namespace A_PoisonousCookies
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split(' ');
            int A = int.Parse(str[0]);
            int B = int.Parse(str[1]);
            int C = int.Parse(str[2]);

            int result = 0;

            if (A+B+2 > C)
            {
                result = B + C;
            }

            else
            {
                result = A + B + 1 + B;
            }

            Console.Write(result);
            
        }
    }
}

Measured memory_bytes: 11092
n = int(input())
w1 = list(map(int,input().split()))
w2 = list(map(int,input().split()))
v1 = [0,0,0]
for i in range(3):
    v1[i] = w2[i] - w1[i]
dp1 = [0] * (n+1)
for i in range(n):
    p = 0
    q = 0
    r = 0
    if i+1 - w1[0] >= 0:
        p = dp1[i+1 - w1[0]] + v1[0]
    if i+1 - w1[1] >= 0:
        q = dp1[i+1 - w1[1]] + v1[1]
    if i+1 - w1[2] >= 0:
        r = dp1[i+1 - w1[2]] + v1[2]
    dp1[i+1] = max(p,q,r,dp1[i])
m = dp1[-1] + n

v2 = [0,0,0]
for i in range(3):
    v2[i] = w1[i] - w2[i]
dp2 = [0] * (m+1)
for i in range(m):
    p = 0
    q = 0
    r = 0
    if i+1 - w2[0] >= 0:
        p = dp2[i+1 - w2[0]] + v2[0]
    if i+1 - w2[1] >= 0:
        q = dp2[i+1 - w2[1]] + v2[1]
    if i+1 - w2[2] >= 0:
        r = dp2[i+1 - w2[2]] + v2[2]
    dp2[i+1] = max(p,q,r,dp2[i])
print(m + dp2[-1])


Measured memory_bytes: 230424
#include<stdio.h>
#include<string.h>
int main(void)
{
	int w,l,d;
	int n;
	int i,j,temp;
	int p[11];
	char t[11][21],tempt[21];
	
	scanf("%d",&n);
	while(n!=0){
		for(i=0;i<n;i++){
			scanf("%s %d %d %d",t[i],&w,&l,&d);
			p[i]=w*3+d;
		}
		for(i=0;i<n-1;i++){
			for(j=n-1;j>i;j--){
				if(p[j-1]<p[j]){
					temp=p[j-1];
					p[j-1]=p[j];
					p[j]=temp;
					strcpy(tempt,t[j-1]);
					strcpy(t[j-1],t[j]);
					strcpy(t[j],tempt);
				}
			}
		}
		for(i=0;i<n;i++){
			printf("%s,%d\n",t[i],p[i]);
		}
		scanf("%d",&n);
		if(n!=0){
			printf("\n");
		}
	}
	return 0;
}

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

int main(){
  long long a,d,c;
  bool prime[1000005];
  for(int i=2;i<1000005;i++)prime[i]=true;
  
  for(int i=2;i<1000005;i++){
    for(int j=1;i*j<1000005;j++){
      if(i!=i*j&&i*j<1000005)prime[i*j]=false;
    }
  }
  
  while(1){
    cin>>a>>d>>c;
    if(a==0&&d==0&&c==0)break;
    int cnt=0;
    for(int i=0;;i++){
      //cout<<a+d*i<<endl;
      if(prime[a+d*i])cnt++;
      if(cnt==c){
	cout<<a+d*i<<endl;
	break;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 3952
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstdlib>
#include<cstring>

using namespace std;

long long n,m;

int main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	scanf("%lld",&n);
	m=n/11;
	if(m*11==n)printf("%lld\n",m*2);
	else {
		if(m*11<n){
			if(m*11+6>=n)printf("%lld\n",m*2+1);
			else printf("%lld\n",m*2+2);
		}
	}
	return 0;
}


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

typedef long long LL;
LL gcd(LL a,LL b){
	return (b==0) ? a : gcd(b,a%b);
}

int main(){
	LL n,x;
	cin>>n>>x;
	LL d=gcd(n,x);
	cout<<d*(n/d*3-3)<<endl;
	return 0;
}

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

int main(){
    int w,h;
    while(1){
      cin>>h>>w;
      if(w == 0 && h==0)
        break;
        int d = h*h + w*w;
        int H=150;
        int W=150;
        int D=150*150*2;
        for(int i=1; i<=150; i++){
          for(int j=i+1; j<=150; j++){
            int z = i*i+j*j;
            if(z>d){
              if(z<D){
                H = i;
                W = j;
                D = z;
              }
              break;
            }
          }
        }
        for(int i=h+1; i<150; i++){
          bool flg =false;

          for(int j= i+1; j<=150; j++){
            int x = i*i+j*j;

            if(x==d){
              H=i;
              W=j;
              D=x;
              flg= true;
            }
            if(x>=d)
              break;
          }
          if(flg)
            break;
        }
        cout<<H<<' '<<W<<endl;
    }
    return 0;
}



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

template<typename T>
T gcd(T a,T b){
    if(b==0)return a;
    return gcd(b,a%b);
}

template <typename T,typename E>
struct SegmentTree{
private:
    typedef std::function<T(T,T)> F;
    typedef std::function<T(T,E)> G;
    int n;
    std::vector<T> init;
    F f;//function for caliculate
    G g;//function for update
    std::vector<T> node;

public:
    explicit SegmentTree(
            int sz,
            F cal,
            G upd,
            std::vector<T> initv=std::vector<T>(1,0)
    ){
        n=1;
        init=initv;
        f=cal;
        g=upd;
        while(n<sz)n=n*2;
        node.resize(static_cast<unsigned int>(2 * n - 1), init[0]);
        for (int i = 0; i <sz ; ++i) node[i+n-1]=init[i+1];
        for (int i = n-2; i >= 0 ; --i) node[i]=f(node[2*i+1],node[2*i+2]);
    }

    void update(int x, E val){//x:0-indexed
        x+=n-1;
        node[x]=g(node[x],val);
        while(x>0){
            x=(x-1)/2;
            node[x]=f(node[2*x+1],node[2*x+2]);
        }
    }

    T query(int p,int q,int k=0,int l=0,int r=-1){//[p,q):0-indexed
        if(r<0)r=n;
        if(r<=p||l>=q)return init[0];//out of range
        if(p<=l&&r<=q)return node[k];

        return f(query(p,q,2*k+1,l,(l+r)/2),query(p,q,2*k+2,(l+r)/2,r));
    }
};

//using namespace std;
using ll = long long;
int main() {
    int n;
    std::cin>>n;
    std::vector<int> a(n+1,0);
    for(int i = 0;i < n;++i) {
        std::cin>>a[i+1];
    }
    SegmentTree<int,int> st(n,[](int a,int b){return gcd(a,b);},[](int a,int b){return b;},a);
    int ans=0;
    for(int i = 0;i < n;++i) {
        int l=st.query(0,i);
        int r=st.query(i+1,n);
        ans=std::max(ans,gcd(l,r));
    }
    std::cout<<ans<<std::endl;

    return 0;
}


Measured memory_bytes: 2432
import sys
from itertools import product
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n, A, B, C = map(int, input().split())
    goal = [A, B, C]
    L = list(int(input()) for _ in range(n))

    res = f_inf
    for pattern in product([0, 1, 2, 3], repeat=n):
        cnt = [0] * 3
        length = [0] * 3
        for idx, p in enumerate(pattern):
            if p != 0:
                length[p - 1] += L[idx]
                cnt[p - 1] += 1
        mp = 0
        for i in range(3):
            if cnt[i] == 0:
                break
            mp += abs(goal[i] - length[i]) + (cnt[i] - 1) * 10
        else:
            res = min(res, mp)
    print(res)


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 9152
mod = 1000000007
n,m = map(int, input().split(" "))
a = set([int(input()) for i in range(m)])
ans = [0]*(n+1)
ans[0] = 1
for j in range(1,n+1):
  if j in a:
    ans[j] = 0
  else:
    ans[j] = (ans[j-1] + ans[j-2])%mod
print(ans[-1])
      

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

int main() {
  int n,k,x,y;
  cin >> n >> k >> x >> y;
  if(n<=k){
    cout << n*x << endl;
  }else{
    cout << k*x+(n-k)*y << endl;
  }
}


Measured memory_bytes: 256
from sys import stdin
N = int(input())
nums = list(map(lambda x: int(x), stdin.readline().split(' ')))

count = 0
for i in range(N-1):
    for j in reversed(range(i,N-1)):
        if nums[j] > nums[j+1]:
            nums[j], nums[j+1] = nums[j+1], nums[j]
            count += 1

output = ""
for i in nums:
    output += str(i) + ' '
print(output[:-1])
print(count)


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

int N;
int A[2010];
bitset<4000010> dp, tmp;
vector<int> S;

int main() {
    scanf("%d", &N);

    for(int i = 0; i < N; i++) {
        scanf("%d", &A[i]);
    }

    dp[0] = 1;

    for(int i = 0; i < N; i++) {
        tmp = dp << A[i];
        dp |= tmp;
    }

    for(int i = 0; i < 4000010; i++) {
        if(dp[i]) S.push_back(i);
    }

    printf("%d", S[ (int)S.size() / 2 ]);
}


Measured memory_bytes: 12396
/**
 *    author:  Daredevil666
 *    institution: IIT Patna
**/
#define _USE_MATH_DEFINES
#include<bits/stdc++.h>
#define nl cout<<"\n";
#define ll unsigned long long int
#define IOS  ios::sync_with_stdio(false);cin.tie(0);
using namespace std;
const ll mod=1e18;
int main()
{
IOS
ll a;
string s;
cin>>a>>s;
ll b=0;
ll i=0;
for( i=0;s[i]!='.';i++)
{
    b=b*10+s[i]-'0';
}
ll n=s.length();
ll c=(s[n-2]-'0')*10+(s[n-1]-'0');
ll d=(a*(b*100+c))/100;
cout<<d;
return 0;
}


Measured memory_bytes: 3588
import java.util.Scanner;


public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int W = scanner.nextInt();
        int H = scanner.nextInt();
        int x = scanner.nextInt();
        int y = scanner.nextInt();
        int r = scanner.nextInt();
        if(x+r<=W&&x-r>=0&&y+r<=H&&y-r>=0&&x>=0&&y>=0){System.out.println("Yes");}
        else if(x+r>W){System.out.println("No");}
        else if(y+r>H){System.out.println("No");}
        else if(x+r<0){System.out.println("No");}
        else if(y<0){System.out.println("No");}
        else if(x<0){System.out.println("No");}
        }
    }

Measured memory_bytes: 26212
#include<iostream>
#include<iomanip>
#include<cstdlib>
#include<algorithm>
#include<vector>
#include<map>
#include<cmath>
#include<string>

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

using namespace std;

int main(){


 ll int N;
 cin >> N;
 vector<int> A;
 ll int x[N+1];
 ll int y[N+1];
  ll int waru=1;

 rep(i,N){
	 cin >> x[i] >> y[i];
	 A.push_back(i);
         waru = waru*i;
 }
   vector<double> len(waru+1);
 
  double ans=0;
  unsigned int counter =1;
 do{
	 for(unsigned int i =0;i<N-1;i++){
		len[counter] +=  hypot( x[A[i]]-x[A[i+1]],y[A[i]]-y[A[i+1]]);  //sqrt( (double)( (x[A[i]]-x[A[i+1]])*(x[A[i]]-x[A[i+1]])
				//+(y[A[i]]-y[A[i+1]])*(y[A[i]]-y[A[i+1]]) ) );
//	 cout << x[A[i]]-x[A[i+1]] <<" " << y[A[i]]-y[A[i+1]] << endl;

                      
		}
	 counter+=1;
 }while(next_permutation(A.begin(),A.end()));


rep(i,waru){
	ans += len[i];
}
  cout << fixed << setprecision(7) << ans/(double)(waru);





	return 0;

}



Measured memory_bytes: 512
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        // 標準入力からデータを読み込む準備
        Scanner sc = new Scanner(System.in);
        double r = sc.nextDouble();
        double pi = Math.PI;
        double area = pi * r * r;
        double length = 2 * r * pi;/* ここを変えて周囲の長さを求めよう */
        System.out.printf("%f %f", area, length);
        sc.close();
    }
}


Measured memory_bytes: 28048
import java.io.*;
public class Main {

	public static void main(String[] args) throws IOException{
		InputStreamReader is = new InputStreamReader(System.in);
		BufferedReader br = new BufferedReader(is);

		String str = br.readLine();
		long n = Long.parseLong(str);
		
		System.out.println(f(n));
	}
	static long f(long n){
		if(n < 2)
			return 1;
		return(n * f(n-1));
	}

}

Measured memory_bytes: 9192