akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef vector<vector<int>> v2int;
typedef vector<ll> vll;
typedef vector<vector<ll>> v2ll;
typedef list<int> liint;
typedef pair<int, int> pint;
const int INF = int(2e9);
const ll LINF = ll(2e9) * ll(2e9);
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b) { a > b ? : a = b; }
template<class T, class C> void chmin(T& a, C b) { a < b ? : a = b; }

ll f(int W, int src, int dst) {
    int X = 1;
    rep(i, W - 1) X *= 2;
    ll ret = 0;
    rep(x, X) {
        bool is_cond = true;
        REP(i, 1, W - 1) {
            if (((x >> i) & 0x01) == 1 && ((x >> (i - 1)) & 0x01) == 1) {
                is_cond = false;
                break;
            }
        }
        if (is_cond == false) continue;
        if (src > dst) {
            int mask = (1 << (dst - 1));
            if ((x & mask) != 0) ret++;
        }
        if (src < dst) {
            int mask = (1 << (src - 1));
            if ((x & mask) != 0) ret++;
        }
        if (src == dst) {
            int mask1 = (1 << (src - 2));
            int mask2 = (1 << (src - 1));
            if ((x & mask1) == 0 && (x & mask2) == 0) ret++;
        }
    }
    return ret;
}

int main() {
    int H, W, K;
    cin >> H >> W >> K;
    v2ll dp(H + 1, vll(W + 1, 0));
    dp[0][1] = 1;
    ll p = 1000000007;
    REP(i, 1, H + 1) {
        REP(j, 1, W + 1) {
            dp[i][j] += dp[i - 1][j] * f(W, j, j);
            dp[i][j] %= p;
            if (j - 1 > 0) {
                dp[i][j] += dp[i - 1][j - 1] * f(W, j - 1, j);
                dp[i][j] %= p;
            }
            if (j + 1 <= W) {
                dp[i][j] += dp[i - 1][j + 1] * f(W, j + 1, j);
                dp[i][j] %= p;
            }
        }
    }
    cout << dp[H][K] << endl;
    return 0;
}

Measured memory_bytes: 256
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE OverloadedStrings #-}

import qualified Data.ByteString.Char8 as B

main :: IO ()
main = do
    s <- map B.head . B.group . B.sort <$> B.getLine
    putStrLn $ diff s ['a'..'z']
    where
        diff [] [] = "None"
        diff (_:_) [] = "None"
        diff [] (y:_) = [y]
        diff (x:xs) (y:ys)
            | x /= y = [y]
            | otherwise = diff xs ys


Measured memory_bytes: 764
#include <iostream>

using namespace std;

int main() {
  int n, k;
  cin >> n >> k;
  int ans = 0;
  int h;
  for (int i = 0; i < n; i++) {
    cin >> h;
    if (h >= k) ++ans;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional>
using namespace std;
#define int long long
#define double long double
#define FAST ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define mod 1000000007
using namespace __gnu_pbds;
typedef tree<int, null_type, less_equal<int>, rb_tree_tag,tree_order_statistics_node_update> new_data_set;
bool isprime(int n)
	{
    	if(n==1) return true;
    	for(int i = 2;i*i<=n;i++){
    		if(n%i==0) return false;
		}
		return true;
	}
int lcm(int a,int b){
	return (a*b)/__gcd(a,b);
}
int gcd(int a, int b) 
{ 
    if (b == 0) 
        return a; 
    return gcd(b, a % b);  
      
} 
unsigned int factorial(unsigned int n) 
{ 
    if (n == 0) 
    return 1; 
    return n * factorial(n - 1); 
} 
const int inf=1e17+7;
//const int N=2e5+5;
bool visited[100005] = {false};
vector<int> graph[100005];
string tranform(string s){
	for(int i=0;i<s.length();i++) {  
    if(s[i]>=65 && s[i]<=92){
		s[i]=s[i]+32;
    }
}
return s;
}
signed main(){
	FAST
	int n,w,sum=0,ans=0;
	cin>>n>>w;
	int a[n],b[n];
	for(int i=0;i<n;i++){
		cin>>a[i];
		cin>>b[i];
		sum+=b[i];
	}
	//cout<<sum<<endl;
	int dp[n+1][sum+1];
	for(int i=0;i<=n;i++){
		for(int j=0;j<=sum;j++){
			dp[i][j]=-1;
		}
	}
	dp[0][0]=0;
	for(int i=1;i<=n;i++){
		for(int j=0;j<=sum;j++){
			if(j<b[i-1]){
				dp[i][j]=dp[i-1][j];
				if(dp[i][j]!=-1){
					ans=max(ans,j);
				}
			}
			else{
				if(dp[i-1][j-b[i-1]]!=-1 && dp[i-1][j-b[i-1]]+a[i-1]<=w){
					dp[i][j]=dp[i-1][j-b[i-1]]+a[i-1];
					if(dp[i-1][j]!=-1){
						dp[i][j]=min(dp[i-1][j-b[i-1]]+a[i-1],dp[i-1][j]);
					}
					ans=max(ans,j);
				}
				else{
					dp[i][j]=dp[i-1][j];
				}
			}
			//cout<<dp[i][j]<<"   ";
		}
		//cout<<endl;
	}
	//cout<<endl;
	cout<<ans;
}

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

main() {
    string A,S,B; cin >> A >> S >> B;
    cout << "A" << S[0] << "C" << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<deque>
#define maxn 100010
using namespace std;
int read()
{
    int x=0,f=1;
    char ch=getchar();
    while(ch-'0'<0||ch-'0'>9){if(ch=='-') f=-1;ch=getchar();}
    while(ch-'0'>=0&&ch-'0'<=9){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
int n,tmp;
int a[maxn];
int state()
{
    int sum1=0,sum0=0;
    for(int i=1;i<=n;i++)
    {
        if(a[i]&1)  sum1++;
        else        sum0++;
    }
    if(sum0&1&&sum1)  return 1;
    if(!(sum0&1)&&sum1>=2)  return 2;
    return 3;
}
int gcd(int x,int y)
{
    if(!y)  return x;
    return gcd(y,x%y);
}
int main()
{
    n=read();
    for(int i=1;i<=n;i++)  a[i]=read();
    if(n==1)
    {
        if(a[1]==1)  puts("Second");
        else         puts("First");
        return 0;
    }
    while(state()==3)
    {
        int pos;
        for(int i=1;i<=n;i++)
        {
            if(a[i]&1)
            {
                pos=i;
                break;
            }
        }
        if(a[pos]==1)
        {
            for(int i=1;i<=n;i++)
            {
                tmp^=((a[i]-1)&1);
            }
            if(tmp&1)  puts("First");
            else       puts("Second");
            return 0;
        }
        a[pos]--;
        int g=0;
        for(int i=1;i<=n;i++)  g=gcd(g,a[i]);
        for(int i=1;i<=n;i++)  a[i]/=g;
        tmp^=1;
    }
    if((state()==1)^tmp) puts("First");
    else            puts("Second");
    return 0;
}

Measured memory_bytes: 640
#include <iostream>

using namespace std;

int main() {
    unsigned int x,y,z;
    cin >> x >> y >> z;
    unsigned int num = x / (y+z);
    unsigned int haji = x % (z+y);
    if(haji >= z) {
        cout << num << endl;
    }
    else {
        cout << num - 1 << endl;
    }
    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);

		final String a = "CF";

		boolean flag = false;
		int count = 0;
		String s = sc.next();

		for(int i = 0; i < s.length(); i++){
			if(a.charAt(count) == s.charAt(i)){
				if(++count == 2){
					flag = true;
					break;
				}
			}
		}

		if(flag){
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}
	}
}


Measured memory_bytes: 9680
#include<iostream>
#include<string>
#include<vector>
#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;
int main(){
    int h,w;
    cin >> h >> w;
    vector<string> s(h);
    rep(i,h)cin >> s[i];
    int d[5] = {0,1,0,-1,0};
    rep(i,h)rep(j,w)if(s[i][j] == '#'){
        bool c = false;
        rep(k,4){
            if(i + d[k] >= 0 && i + d[k] < h && j + d[k+1] >= 0 && j + d[k+1] < w){
                if(s[i+d[k]][j+d[k+1]] == '#') c = true;
            }
        }
        if(c == false){
            //cout << i << " " << j << endl;
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}


Measured memory_bytes: 256
///Bismillahir Rahmanir Rahim
#include "bits/stdc++.h"

#define                           ll                          long long
#define                           int                         ll
#define                           fi                          first
#define                           si                          second
#define                           mp                          make_pair
#define                           pb                          push_back
#define                           pi                          pair<ll,ll>
#define                           clr(x)                      memset(x,0,sizeof(x));
#define                           f(i,l,r)                    for(int i=l;i<=r;i++)
#define                           rf(i,r,l)                   for(int i=r;i>=l;i--)
#define                           done(i)                     cout<<"done = "<<i<<endl;
#define                           show(x,y)                   cout<<x<<" : ";for(auto z:y)cout<<z<<" ";cout<<endl;
#define                           fast                        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

using namespace std;

const ll inf=1e18;
const int mod=1e9+7;
const int M=10005;
int d[M],c[M],vis[M];
queue<int>q;
vector<int>adj[M];
int ses[M];
 main()

{
    fast
    int n;
    cin>>n;
    f(i,1,n-1)
    {
        int u,v;
        cin>>u>>v;
        d[u]++;
        d[v]++;
        adj[u].pb(v);
        adj[v].pb(u);
    }
    f(i,1,n)
    {
        if(d[i]==1)q.push(i),vis[i]=1;
    }
    f(i,1,n)cin>>c[i];
    sort(c+1,c+n+1);
    int cur=1,sum=0;
    while(!q.empty())
    {
        int u=q.front();
        ses[u]=c[cur];cur++;
        sum+=ses[u];
        q.pop();
        for(auto v:adj[u])
        {
             if(vis[v]==0)
             {
                 d[v]--;
                 if(d[v]==1)
                 {
                     q.push(v);
                     vis[v]=1;
                 }
             }
        }
    }
    sum-=c[n];
    cout<<sum<<endl;
    f(i,1,n)
    {
        cout<<ses[i]<<" ";
    }
    cout<<endl;
    return 0;

}





































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

#define rep(i, n) REP(i, 0, n)
#define repr(i, n) for (int i = (n); i >= 0; i--)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;

int main()
{
    char c;
    cin >> c;
    OP(char(c + 1));
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define LONGLONGMAX 9223372036854775807
#define LONGLONGMIN -9223372036854775807
#define INTMAX 32767
#define INTMIN -32767
#define ROUNDUP(divisor,dividend) (divisor + (dividend - 1)) / dividend
int a,b,c;
int main(){
  cin >> a >> b >> c;
  cout << (a==b && b==c ? "Yes":"No") << endl;
}


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

int main(){
    string s;
    cin >> s;
    int cnt = 0, cnts = 0, num = 0;
    for(int i=0; i<s.size()-1; i++){
        if(s[i] == 'A' || s[i] == 'C' || s[i] == 'G' || s[i] == 'T'){
            if(s[i+1] == 'A' || s[i+1] == 'C' || s[i+1] == 'G' || s[i+1] == 'T'){
                cnts++;
            }
        }else{ 
            cnt++;
            num = max(num, cnts);
            cnts = 0;
        }
    }
    cnts = max(num, cnts);
    if(cnt+1 == s.size()){
        if(s[0] == 'A' || s[0] == 'C' || s[0] == 'G' || s[0] == 'T'){
            cout << 1 << endl;
        }else cout << 0 <<endl;
    }else if(cnts == 0) cout << 1 << endl;
    else cout << cnts+1 << endl;
    //else cout << num+1 << endl; 

}

Measured memory_bytes: 256
t = set([])
a = map(int, raw_input().split())
n = a[0]
for i in xrange(n):
    t.add(a[2*i+1]*60+a[2*i+2])
b = map(int, raw_input().split())
n = b[0]
for i in xrange(n):
    t.add(b[2*i+1]*60+b[2*i+2])
tl = []
tl = list(t)
tl.sort()
print " ".join(":".join([str(time/60),str(time%60).zfill(2)]) for time in tl)

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

int main()
{
	vector<int> a(5);
	int sum = 0, min = 9, min_i = 0;
	for (int i = 0; i < 5; i++)
	{
		cin >> a[i];
		if (min > a[i] % 10 && a[i] % 10 != 0)
		{
			min = a[i] % 10;
			min_i = i;
		}
	}
	for (int i = 0; i < 5; i++)
	{
		if (min_i == i)
			continue;
		if (a[i] % 10 != 0) a[i] = a[i] + 10 - a[i] % 10;
		sum += a[i];
	}
	sum += a[min_i];
	cout << sum << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <climits>
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define srep(i, begin, end) for (__typeof(end) i = begin; i != end; i++)
#define si(x) int x = scanInt();
#define sll(x) LL x = scanLong();
#define sci(x) int x; scanf("%d", &x);
#define scll(x) LL x; scanf("%lld", &x);
#define pi(x) printf("%d ", x)
#define pll(x) printf("%lld ", x)
#define nl printf("\n")
#define clr(a) memset(a, 0, sizeof(a))
#define PB push_back
#define MP make_pair
using namespace std;
typedef unsigned int UI; // 32 bit integer
typedef long int LI; // 32 bit integer
typedef unsigned long int ULI; // 32 bit unsigned integer
typedef long long int LL; // 64 bit integer
typedef unsigned long long int  ULL; // 64 bit unsigned integer
typedef long double LD;
typedef vector<int> VI;
typedef vector<LL> VLL;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
const LL MOD = 1e9+7;

/* Fast I/O */
inline int scanInt() {
	int n = 0;
	char ch = getchar();
	int sign = 1;
	while(ch < '0' || ch > '9') {
		if(ch == '-')	sign = -1;
		ch = getchar();
	}
	while(ch >= '0' && ch <= '9') {
		n = (n<<1)+(n<<3)+(int)(ch-'0');
		ch = getchar();
	}
	return n*sign;
}

inline LL scanLong() {
	LL n = 0;
	char ch = getchar();
	LL sign = 1;
	while(ch < '0' || ch > '9') {
		if(ch == '-')	sign = -1;
		ch = getchar();
	}
	while(ch >= '0' && ch <= '9') {
		n = (n<<1)+(n<<3)+(LL)(ch-'0');
		ch = getchar();
	}
	return n*sign;
}

int main() {
	sll(n); sll(a); sll(b); sll(c);
	LL l[n], minCost = LONG_MAX;
	rep(i, 0, n)	l[i] = scanLong();
	rep(i, 0, (LL)pow(4ll, n)) {
		LL tmp = i;
		LL sa = 0, sb = 0, sc = 0;
		LL ca = 0, cb = 0, cc = 0;
		rep(j, 0, n) {
			if(tmp%4 == 0)		sa += l[j], ca++;
			else if(tmp%4 == 1)	sb += l[j], cb++;
			else if(tmp%4 == 2)	sc += l[j], cc++;
			tmp /= 4;
		}
		if(ca > 0 && cb > 0 && cc > 0) {
			LL cost = abs(sa-a) + abs(sb-b) + abs(sc-c) + 10 * (ca + cb + cc - 3);
			minCost = min(minCost, cost);
		}
	}
	pll(minCost); nl;
}


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

const ll maxn = 2e5 + 10;
const ll N = 1e5 + 1;

ll a[maxn], par[maxn], fen[maxn];
ll n;

ll get(ll x){
	ll ret = 0;
	for (x += N; x; x -= x & -x)
		ret += fen[x];
	return ret;
}

void add(ll x, ll val){
	for (x += N; x < maxn; x += x & -x)
		fen[x] += val;
}

ll check(ll x){
	for (ll i = 1; i <= n; i++)
		par[i] = (a[i] < x ? 1 : -1);
	for (ll i = 1; i <= n; i++)
		par[i] += par[i - 1];

	add(par[0], +1);
	ll ret = 0;
	for (ll i = 1; i <= n; i++) {
		ret += get(par[i] - 1);
		add(par[i], +1);
	}
	for (ll i = 0; i <= n; i++)
		add(par[i], -1);
	return ret;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin >> n;
	for (ll i = 1; i <= n; i++)
		cin >> a[i];
	ll tot = n * (n + 1) / 2;
	ll lo = 1, hi = 1000 * 1000 * 1000 + 1;
	while (hi - lo > 1){
		ll mid = (lo + hi) / 2;
		if (check(mid) > tot / 2)
			hi = mid;
		else
			lo = mid;
	}
	cout << lo << endl;
}


Measured memory_bytes: 4096
N,K=gets.split.map(&:to_i)
if ((N-1)*(N-2))/2<K
    puts -1
    exit
end
puts N-1+((N-1)*(N-2))/2 - K
(N-1).times do |i|
    puts [1,i+2].join(" ")
end
cnt = ((N-1)*(N-2))/2 - K
exit if cnt == 0
(2..N).to_a.combination(2) do |a,b|
    cnt -= 1
    puts [a,b].join(" ")
    exit if cnt == 0
end


Measured memory_bytes: 1916
#include<iostream>
#include<string>
using namespace std;
int main() {
  string s;
  cin >> s;
  bool f = true;
  int i;
  for(i=0;i<s.size()/2;i++) {
    if(s[i] != s[i+s.size()/2+1])f = false;
    if(s[i] != s[s.size()-i-1])f = false;
  }
  if(f)cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (int i=(int)from; i<(int)to; i++)
#define all(vec) vec.begin(), vec.end()
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

vector<ll> fac;
void c_fac(int x=pow(10,6)+10) { fac.resize(x,true); rep(i,x) fac[i] = i ? (fac[i-1]*i)%MOD : 1; }
ll inv(ll a, ll m=MOD) { ll b = m, x = 1, y = 0; while (b!=0) { int d = a/b; a -= b*d; swap(a,b); x -= y*d; swap(x,y); } return (x+m)%m; }
ll nck(ll n, ll k) { return fac[n]*inv(fac[k]*fac[n-k]%MOD)%MOD; }
ll gcd(ll a, ll b) { if (a<b) swap(a,b); return b==0 ? a : gcd(b, a%b); }
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }


int main() {
  ll N; cin >> N;
  ll a[N]; rep(i,N) cin >> a[i];
  ll dp[2][N][N]; rep(i,2) rep(j,N) fill_n(dp[i][j],N,0);
  rep(i,N) { dp[0][i][i] = a[i]; dp[1][i][i] = -1*a[i]; }
  repr(i,1,N) rep(j,N-i) {
    dp[0][j][j+i] = max(a[j+i]+dp[1][j][j+(i-1)], a[j]+dp[1][j+1][j+i]);
    dp[1][j][j+i] = min(-1*a[j+i]+dp[0][j][j+(i-1)], -1*a[j]+dp[0][j+1][j+i]);
  }

  // rep(i,N) debug(dp[0][i],dp[0][i]+N);
  ll result = dp[0][0][N-1];
  cout << result << endl;
  return 0;
}

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


int main(){
    int n;
    cin>>n;
    
    int a[10000];
    for(int i=0;i<n;i++) cin>>a[i];
    
    int mn = a[0],ma = a[0];
    long long sum = 0;
    for(int i=0;i<n;i++){
        mn = min(mn,a[i]);
        ma = max(ma,a[i]);
        sum += a[i];
    }

    cout<<mn<<" "<<ma<<" "<<sum<<endl;
    
  return 0;
}



Measured memory_bytes: 3132
n = int(input())
a = [list(map(int, input().split())) for _ in range(2)]

ans = 0
for i in range(n):
    s0 = sum(a[0][:i+1])
    s1 = sum(a[1][i:])
    ans = max(ans, s0+s1)
    
print(ans)

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

using namespace std;

int main(){
    size_t N;
    cin >> N;
    
    size_t sum = 0;
    for(size_t i = 0; i < N ; ++i)
    {
        size_t n;
        cin >> n;
        while(n % 2 == 0){ n = n / 2; ++sum;}
    }

    cout << sum;
}

Measured memory_bytes: 256
#include<cstdio>
#include <iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<queue>
#include<vector>
#include<functional>
#include<cmath>
#include<map>
#include<stack>
#include<cstdlib>
#include<list>
#include<set>
#include<numeric>

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

int main()
{
	string O, E;
	cin >> O >> E;

	for (int i = 1,j=0,k=0; i <= O.size() + E.size(); i++) {
		if (i % 2 == 0)
			cout << E[j++];
		else
			cout << O[k++];
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
import static java.util.Arrays.*;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {

	static void tr(Object... os) {
		System.err.println(deepToString(os));
	}

	void solve() {
		int n = sc.nextInt();
		if (n == 0) return;

		int ans = 0;
		for (;n-->0;) {
			int len = sc.nextInt() + sc.nextInt()+ sc.nextInt();
			int w = sc.nextInt();
			int fee = 0;
			if (len <= 60 && w <= 2) fee = 600;
			else if (len <= 80 && w <= 5) fee = 800;
			else if (len <= 100 && w <= 10) fee = 1000;
			else if (len <= 120 && w <= 15) fee = 1200;
			else if (len <= 140 && w <= 20) fee = 1400;
			else if (len <= 160 && w <= 25) fee = 1600;
			ans += fee;
		}
		out.println(ans);
	}

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

	MyScanner sc = null;
	PrintWriter out = null;
	public void run() throws Exception {
		sc = new MyScanner(System.in);
		out = new PrintWriter(System.out);
		for (;sc.hasNext();) {
			solve();
			out.flush();
		}
		out.close();
	}

	class MyScanner {
		String line;
		BufferedReader reader;
		StringTokenizer tokenizer;

		public MyScanner(InputStream stream) {
			reader = new BufferedReader(new InputStreamReader(stream));
			tokenizer = null;
		}
		public void eat() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					line = reader.readLine();
					if (line == null) {
						tokenizer = null;
						return;
					}
					tokenizer = new StringTokenizer(line);
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
		}
		public String next() {
			eat();
			return tokenizer.nextToken();
		}
		public String nextLine() {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		public boolean hasNext() {
			eat();
			return (tokenizer != null && tokenizer.hasMoreElements());
		}
		public int nextInt() {
			return Integer.parseInt(next());
		}
		public long nextLong() {
			return Long.parseLong(next());
		}
		public double nextDouble() {
			return Double.parseDouble(next());
		}
		public int[] nextIntArray(int n) {
			int[] a = new int[n];
			for (int i = 0; i < n; i++) a[i] = nextInt();
			return a;
		}
	}
}

Measured memory_bytes: 24764
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
	static List<int []> dx;
	static List<Integer>t;
	static int n,m,q;
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		n = Integer.parseInt(sc.next());
		m = Integer.parseInt(sc.next());
		q = Integer.parseInt(sc.next());
		
		dx = new ArrayList <int []>();
		t = new ArrayList<Integer>();
		dfs(0,1);
		
		int []a = new int [q];
		int []b = new int [q];
		int []c = new int [q];
		int []d = new int [q];
		
		for(int i = 0 ; i < q ;i++) {
			a[i] = Integer.parseInt(sc.next())-1;
			b[i] = Integer.parseInt(sc.next())-1;
			c[i] = Integer.parseInt(sc.next());
			d[i] = Integer.parseInt(sc.next());
		}
		int ans = -1;
		
		for(int []x : dx) {
			int temp = 0;
			for(int i = 0 ; i < q ;i++) {
				if(x[b[i]] - x[a[i]] == c[i]) {
					temp += d[i];
				}
			}
			ans = Math.max(temp, ans);
		}
		
		System.out.println(ans);
		
	}
	
	static void dfs(int id, int now) {
		
		if(id == n) {
			int []px = new int [t.size()];
			for(int i = 0 ; i < t.size() ;i++) {
				px[i] = t.get(i);
			}
			dx.add(px);
			return;
		}
		
		for(int i = now ; i <= m ;i++) {
			t.add(i);
			dfs(id+1,i);
			t.remove(id);
		}
	}
}


Measured memory_bytes: 45132
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	int a[n+1]={},b;
	for(int i=0;i<n-1;i++){
		cin>>b;
		++a[b-1];
	}
	for(int i=0;i<n;i++){
		cout<<a[i]<<endl;
	}
	
}

Measured memory_bytes: 4376
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 2e5 + 5;
typedef long long ll;
template <typename T> void read(T &x) {
	x = 0; int f = 1;
	char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
	for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
	x *= f;
}
bool check(ll x, ll y, ll s) {
	if (x < 0) x = -x;
	if (y < 0) y = -y;
	return x + y <= s;
}
ll x[MAXN], y[MAXN];
int main() {
	int n; read(n);
	int cnt[2] = {0, 0};
	for (int i = 1; i <= n; i++) {
		read(x[i]), read(y[i]);
		cnt[(x[i] + y[i]) % 2 == 0]++;
	}
	if (cnt[0] != 0 && cnt[1] != 0) {
		puts("-1");
		return 0;
	}
	vector <ll> ans, sum;
	ans.push_back(1);
	if (cnt[1]) ans.push_back(1);
	for (int i = 2; i <= 38; i++)
		ans.push_back(1ll << (i - 1));
	sum.push_back(0);
	for (unsigned i = 1; i < ans.size(); i++)
		sum.push_back(sum.back() + ans[i - 1]);
	cout << ans.size() << endl;
	for (auto x : ans)
		printf("%lld ", x);
	printf("\n");
	for (int i = 1; i <= n; i++) {
		string res; res.resize(ans.size());
		ll nowx = x[i], nowy = y[i];
		for (int j = ans.size() - 1; j >= 0; j--) {
			if (check(nowx + ans[j], nowy, sum[j])) {
				res[j] = 'L';
				nowx += ans[j];
			} else if (check(nowx - ans[j], nowy, sum[j])) {
				res[j] = 'R';
				nowx -= ans[j];
			} else if (check(nowx, nowy + ans[j], sum[j])) {
				res[j] = 'D';
				nowy += ans[j];
			} else if (check(nowx, nowy - ans[j], sum[j])) {
				res[j] = 'U';
				nowy -= ans[j];
			}
		}
		cout << res << endl;
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
class Main{
public static void main(String[] args){
int[] m=new int[10];
Scanner sc=new Scanner(System.in);
for(int i=0;i<m.length;i++){
m[i]=sc.nextInt();
}
Arrays.sort(m);
for(int i=1;i<=3;i++){
System.out.println(m[10-i]);
}
}
}

Measured memory_bytes: 12000
x,y,a,b,c = list(map(int, input().split()))
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))

p.sort()
q.sort()
p0 = p[-x:]
q0 = q[-y:]

all1 = p0 + q0 + r
all1.sort()

print(sum(all1[-(x+y):]))

Measured memory_bytes: 23328
#include<iostream>
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<string>
#include<cstring>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<bitset>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define mod 1000000007LL
#define eps 0.0001

#define rep(i, n) for(i = 0;i < n;++i)
#define rep1(i, n) for(i = 1;i < n;++i)
#define pri(x) cout << (x) << "\n"
#define pri2(x, y) cout << (x) << " " << (y) << "\n"
#define pri3(x, y, z) cout << (x) << " " << (y) << " " << (z) << "\n"


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    // ---------------------
    // コーディング開始
    // ---------------------

    string k;
    cin >> k;

    int i;
    rep(i,k.size()){
        if(k[i]=='A') {
            int j;
            for (j =k.size();j>=0;j--){
                if(k[j]=='Z') {
                    pri(j-i+1);
                    return 0;
                }
            }
        }
    }
    return 0;

}



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

#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define watch(x) cout << (#x) << " is " << (x) << endl
#define f(t) for(ll i =0;i<t;i++)
#define bs(a,x) binary_search(a.begin(),a.end(),x)
#define ll long long int
#define ul unsigned long int
#define ld long double
#define umpi unordered_map<int,int> 
#define umpl unordered_map<ll,ll> 
#define vi vector<int>
#define vl vector<ll>
#define fill(a,p) memset(a,p,sizeof(a))
#define pb push_back
#define mod 1000000007
#define N 200005
#define all(a) a.begin(),a.end()
#define point pair<ll,ll>
#define endl "\n"

const int inf = 1000000007;
const ll linf = 1ll * inf * inf;
const ll MAXIMUM =2005;

inline ll mul(ll a, ll b){ return (a * 1ll * b) % mod; }
inline ll sub(ll a, ll b){ ll c = a - b; if(c < 0) c += mod; return c; }
inline ll add(ll a, ll b){ ll c = a + b; if(c >= mod) c -= mod; return c; }
inline ll max(ll a, ll b){return a>b?a:b;}
inline ll minim(ll a, ll b){return a<b?a:b;}

struct hash_pair { 
    template <class T1, class T2> 
    size_t operator()(const pair<T1, T2>& p) const
    { 
        auto hash1 = hash<T1>{}(p.first); 
        auto hash2 = hash<T2>{}(p.second); 
        return hash1 ^ hash2; 
    } 
};

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

ll modInverse(ll n,ll p) 
{ 
    return power(n, p-2, p); 
} 


ll lcm(ll a,ll b){
  return (a*b)/__gcd(a,b);
}

bool comp(const point &p1,const point &p2){
	if(p1.first!=p2.first)return p1.first<p2.first;
	else return p1.second<p2.second;
}

int main()
{
	fio;
	ll n,w;cin>>n>>w;
	vl wei(n),value(n);
	f(n){
		cin>>wei[i]>>value[i];
	}
	ll v=0;
	v=accumulate(all(value),v);
	vl dp(v+1,inf);
	dp[0]=0;
	for(ll i=0;i<n;i++){
		for(ll j=v-value[i];j>=0;j--){
			dp[j+value[i]]=min(dp[j+value[i]],dp[j]+wei[i]);
		}
	}
	ll ans=0;
	for(ll i=0;i<=v;i++){
		if(dp[i]<=w){
			ans=max(ans,i);
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 1024
T = int(input())
for t in range(T):
    N, A, B, C, D = map(int, input().split())
    memo = {}
    def dist(n):
        if n == 0:
            return 0
        if n == 1:
            return D
        if n in memo:
            return memo[n]
        
        ret = min(
            D * n,
            D * abs(n - n//5*5) + C + dist(n//5),
            D * abs(n - (n+4)//5*5) + C + dist((n+4)//5),
            D * abs(n - n//3*3) + B + dist(n//3),
            D * abs(n - (n+2)//3*3) + B + dist((n+2)//3),
            D * abs(n - n//2*2) + A + dist(n//2),
            D * abs(n - (n+1)//2*2) + A + dist((n+1)//2)
        )

        memo[n] = ret
        return ret
    print(dist(N))


Measured memory_bytes: 10756
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
vector<vector<int> > dp(500, vector<int>(500, INF));
vector<pii> drug(50);
vector<int> cost(50);
int n, ma, mb;
/* function */
void initDPTable() {dp[0][0] = 0;}
void calcDPTable() {
    for (int i = 0; i < n; i++) {
        for (int j = 400; j >= 0; j--) {
            for (int k = 400; k >= 0; k--) {
                int nj = j + drug[i].first;
                int nk = k + drug[i].second;
                dp[nj][nk] = min(dp[nj][nk], dp[j][k] + cost[i]);
            }
        }
    }
}
void calcAns() {
    int ans = INF;
    for (int j = 1; j <= 400; j++) {
        for (int k = 1; k <= 400; k++) {
            if (ma * k == mb * j) {
                ans = min(ans, dp[j][k]);
            }
        }
    }
    if (ans == INF) cout << -1 << '\n';
    else cout << ans << '\n';
}
/* main */
int main() {
    cin >> n >> ma >> mb;
    int a, b, c;
    for (int i = 0; i < n; i++) {
        scanf("%d %d %d", &a, &b, &c);
        drug[i] = pii(a, b);
        cost[i] = c;
    }
    initDPTable();
    calcDPTable();
    calcAns();
}

Measured memory_bytes: 1280
# -*- coding: utf-8 -*-

def readInts():
  return [int(s) for s in input().split(" ")]

def sortKey(n):
  if n % 10 == 0:
    return 10
  else:
    return n % 10

def ceil10(n):
  if n % 10 > 0:
    return n + (10 - n % 10)
  else:
    return n

def main():
  A = readInts()[0]
  B = readInts()[0]
  C = readInts()[0]
  D = readInts()[0]
  E = readInts()[0]

  orders = sorted([A, B, C, D, E], key=sortKey)
  s = orders[0] + sum(map(ceil10, orders[1:]))
  print(s)

if __name__ == "__main__":
  main()


Measured memory_bytes: 3064
/* In the name of Allah */
#include<bits/stdc++.h>
using namespace std;

int main(){
int n, m;
cin >> n ;
int z = n % 10;
if(z == 2 || z == 4 ||z == 5 ||z == 7 ||z == 9)	{
	cout << "hon";
}else if(z == 0 ||z == 1 ||z == 6 ||z == 8 ){
	cout << "pon";
}else{
	cout << "bon";
}
	
	return 0;
}

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

int main() {
  int N, K, x;
  cin >> N >> K;
  
  int sum = 0;
  for(int i=0; i<N; i++){
    cin >> x;
    sum += 2 * min(x, K-x);
  }
  cout << sum;
}


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

int main(){
    long N, M;
    long step;
    cin >> N;
    long step_min = N;
    for(long i=1; i<=sqrt(N); i++){
        if(N%i == 0){
            M = N/i;
            step = abs(i+M)-2;
            if(step_min > step) step_min = step;
            //cout << i << step_min << endl;
        }
    }
    printf("%.0ld\n", step_min);
    return 0;
}

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


int main(int argc, char **argv)
{
	int k, a, b; cin >> k >> a >> b;
	
	if(a + (k - a % k) % k <= b)
		cout << "OK\n";
	else
		cout << "NG\n";
	
	return 0;
}

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

int main() {
  int p = 0, w = 0, g = 0, y = 0;
  int n;
  cin >> n;
  char h;
  for (int i = 0; i < n; i++) {
    cin >> h;
    if (h == 'P') p = 1;
    if (h == 'W') w = 1;
    if (h == 'G') g = 1;
    if (h == 'Y') y = 1;
  }

  if (p + w + g + y == 3)
    cout << "Three" << endl;
  else
    cout << "Four" << endl;
}


Measured memory_bytes: 256
# 入力
X = int(input())
A = int(input())
B = int(input())

# A円のケーキを1個買う
balance = X - A

# 残金で買えるケーキBの数を求める
quantity = balance // B

# Bのケーキを変えるだけ買う
balance -= B * quantity

# 残金を出力する
print(balance)

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

int main(){
  int n;
  cin >> n;
  long long ans = 0;

  for(int i=1;i<=n;i++){
    if(i%3!=0&&i%5!=0)ans += i;
  }
  
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3636
#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<functional>
using namespace std;


vector<int> book[10];
vector<int> sell[10];
int dp[11][2001];
int main(void){
	int n,k,res=0;
	memset(dp,0,sizeof(dp));
	scanf("%d%d",&n,&k);
	for(int i=0;i<n;i++){
		int a,b;
		scanf("%d%d",&a,&b);
		book[b-1].push_back(a);
	}
	for(int i=0;i<10;i++)sort(book[i].begin(),book[i].end(), greater<int>() );
	for(int i=0;i<10;i++){
		sell[i].push_back(0);
		if(book[i].size()>0)sell[i].push_back(book[i][0]);
		for(int j=1;j<book[i].size();j++){
			book[i][j]+=book[i][j-1];
			sell[i].push_back(book[i][j]+j*(j+1));
		}
	}
	
	for(int i=0;i<10;i++){
		for(int j=0;j<sell[i].size();j++){
			for(int l=0;l<=k;l++){
				if(l>=j){
					dp[i+1][l]=max(max(dp[i+1][l],dp[i][l]),dp[i][l-j]+sell[i][j]);
				}else dp[i+1][l]=max(dp[i+1][l],dp[i][l]);
			}
		}
	}
	cout << dp[10][k] << endl;
    return 0;
}

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

typedef long long ll;
typedef pair<int,int> PII;
#define CINSPEED ios::sync_with_stdio(false),std::cin.tie(0),std::cout.tie(0)
#define fi first
#define se second
#define pb push_back

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


const int N = 10010,M = 1000010;
int h,n;
int dp[N],a[N],b[N];
void solved()
{
    cin >> h >> n;
    
    for(int i = 0;i < n;i++)cin >> a[i] >> b[i];
    memset(dp,0x3f,sizeof dp);
    
    dp[0] = 0;
    for(int i = 0;i < n;i++)
    {
        for(int j = 0;j < h;j++)    
        {
            int target = j + a[i];
            target = target >= h ? h : target;
            dp[target] = min(dp[target],dp[j] + b[i]);
        }
    }
    cout << dp[h];
}

int main()
{
    CINSPEED;
    solved();
#ifdef LOCAL
    system("pause");
#endif
    return 0;
}


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

int main(){
    int T[5];
    int T_round[5];
    int delay=0;
    int all_time=0;
    for(int i=0;i<5;i++){
        cin>>T[i];
        if(T[i]%10!=0){
            T_round[i]=T[i]+10-T[i]%10;
            if(delay<10-T[i]%10){
                delay=10-T[i]%10;
            }
        }else{
            T_round[i]=T[i];
        }
        all_time+=T_round[i];
    }
    all_time-=delay;
    cout<<all_time<<endl;
}

Measured memory_bytes: 256
n = int(input())
table = []

for i in range(1,n+1):
    if i % 3 == 0:
        table.append(i)
    else:
        tmp = i
        while tmp != 0:
            if tmp % 10 == 3:
                table.append(i)
                break
            else:
                tmp //= 10

print(' ', end="")
print(' '.join(map(str, table)))



Measured memory_bytes: 6104
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define pi M_PI
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

bool check(string s){
    if (s == "ABC") return 1;
    string s_next;
    VI exist(3);
    REP(i,s.length()){
        if (s.substr(i,3) == "ABC"){
            s_next += 'X';
            i += 2;
        }else{
            s_next += s[i];
            exist[s[i]-'A'] = 1;
        }
    }
    if (s_next.size() == s.size()) return 0;
    bool f = 0;
    REP(k,3){
        if (exist[k] == 1) continue;
        string t = s_next;
        REP(i,t.length()) if (t[i] == 'X') t[i] = 'A' + k;
        f |= check(t);
    }
    return f;
}

int main() {
    string s;
    cin >> s;
    cout << (check(s) ? "Yes" : "No") << endl;
    return 0;
}

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

using namespace std;

typedef long long int llint;

int N;
string str;

void solve() {
  int open = 0, close = 0;

  for (int i = 0; i < N; ++i) {
    if (str[i] == '(') {
      close++;
    } else {
      if (close == 0) {
        open++;
      } else {
        close--;
      }
    }
  }

  for (int i = 0; i < open; ++i) {
    cout << '(';
  }
  cout << str;
  for (int i = 0; i < close; ++i) {
    cout << ')';
  }
  cout << endl;
}

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

  cin >> N;
  cin >> str;
  solve();

  return 0;
}

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

int main () {
  int N, L;
  cin >> N >> L;
  vector <string> words(N);
  for (int i = 0; i < N; i++) cin >> words.at(i);
  sort (words.begin(),words.end());
  for (int i = 0; i < N-1; i++) cout << words.at(i);
  cout << words.at(N-1) << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<math.h>
using namespace std;

int main() {
	char S[20];
	string T;
	string p;
	string Q;
	double m;
	int a = 0;
	int A = 0;
	int b = 0;
	int B = 0;
	int c = 0;
	int C = 0;
	int q, w, z;
	int n = 0;
	int x = 0;
	int y = 0;
	int ans = 0;
	cin >> a >> b >> A >> B;
	cout <<(a - A) * (b - B);

}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
typedef long long ll;
using namespace std;

ll mod=998244353, dp[310][45010], ep[310][45010];
int a[310];

int main() {
	int N;
	cin >> N;
	int sum=0;
	ll ans=1;
	for(int i=0; i<N; ++i){
		cin >> a[i];
		sum += a[i];
		(ans *= 3) %= mod;
	}
	dp[0][0]=ep[0][0]=3;
	for(int i=1; i*2<=sum; ++i) dp[0][i]=ep[0][i]=0;
	for(int i=0; i<N; ++i){
		for(int j=0; j*2<=sum; ++j){
			dp[i+1][j]=dp[i][j];
			ep[i+1][j]=ep[i][j];
			if(j>=a[i]){
				(dp[i+1][j] += (dp[i][j-a[i]]*2)%mod) %= mod;
				(ep[i+1][j] += ep[i][j-a[i]]) %= mod;
			}
		}
	}
	for(int i=0; i*2<=sum; ++i){
		(ans += mod-dp[N][i]) %= mod;
	}
	if(sum%2==0){
		(ans += ep[N][sum/2]) %= mod;
	}
	cout << ans << endl;
	return 0;
}

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

left = 1
right = N
# 1-indexed
# [left, right]

for _ in range(M):
    L, R = map(int, input().split())
    if L > left:
        left = L
    if R < right:
        right = R
    if right - left + 1 <= 0:
        break
print(max(0, right - left + 1))


Measured memory_bytes: 43608
while True:
    n,k=map(int,input().split())
    if n==0 and k==0:
        break
    else:
        a=[]
        s=0
        t=[]
        u=0
        for i in range(n):
            a.append(int(input()))
        for j in range(k):
            s+=a[j]
        t.append(s)
        for l in range(k,n):
            s=t[u]-a[l-k]+a[l]
            t.append(s)
            u+=1
        print(max(t))


Measured memory_bytes: 11520
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;

    for(int i=1;i<=9;i++)
    {
        if(n%i==0){
        int x=n/i;
        if(x<=9)
        {
            cout<<"Yes"<<endl;
            return 0;
        }
        }
    }
    cout<<"No"<<endl;
}


Measured memory_bytes: 3596
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
 
using namespace std;
 
int main(){
    string S;
    cin >> S;
    int count = 0;
    vector<int> res(1);
    for(int i = 0;i < S.size();i++){
        if(S.at(i) == 'A'||S.at(i) == 'T'||S.at(i) == 'G'||S.at(i) == 'C'){
            res.at(count)++;
        }else{
            res.push_back(0);
            count++;
        }
        
    }
    sort(res.rbegin(),res.rend());
    cout <<res.at(0)<<endl;
}

Measured memory_bytes: 256
#define DEB
#include<bits/stdc++.h>
#define REP(i,m) for(int i=0;i<(m);++i)
#define REPN(i,m,in) for(int i=(in);i<(m);++i)
#define ALL(t) (t).begin(),(t).end()
#define CLR(a) memset((a),0,sizeof(a))
#define pb push_back
#define mp make_pair
#define fr first
#define sc second

using namespace std;


#ifdef DEB
#define dump(x)  cerr << #x << " = " << (x) << endl
#define prl cerr<<"called:"<< __LINE__<<endl
template<class T> void debug(T a,T b){ for(;a!=b;++a) cerr<<*a<<' ';cerr<<endl;}
#else
#define dump(x) ;
#define prl ;
template<class T> void debug(T a,T b){ ;}
#endif

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

typedef long long int lint;
typedef pair<int,int> pi;

namespace std{
  template<class S,class T>
  ostream &operator <<(ostream& out,const pair<S,T>& a){
    out<<'('<<a.fr<<','<<a.sc<<')';
    return out;
  }
}

//const int INF=5e8;
int n;
int ar[105];

int cnt[105];
vector<int> vs[105];
pi es[105];

void fail(){
  puts("Impossible");
  exit(0);
}

int main(){
  cin>>n;
  REP(i,n){
    cin>>ar[i];
    ++cnt[ar[i]];
    vs[ar[i]].pb(i);
  }
  int mx=0;
  REP(i,n) if(cnt[i]>0) mx=i;

  int m=0;
  if(mx&1){
    int mn=(mx+1)/2;
    for(int i=mn;i<=mx;++i) if(cnt[i]<2) fail();
    if(cnt[mn]>2) fail();
    REP(i,mn) if(cnt[i]) fail();

    for(int i=mn;i<mx;++i){
      es[m++]=mp(vs[i][0],vs[i+1][0]);
      es[m++]=mp(vs[i][1],vs[i+1][1]);
    }
    es[m++]=mp(vs[mn][0],vs[mn][1]);
    for(int i=mn+1;i<=mx;++i){
      for(int j=2;j<vs[i].size();++j){
        es[m++]=mp(vs[i][j],vs[i-1][0]);
      }
    }
  }else{
    int mn=mx/2;
    for(int i=mn+1;i<=mx;++i) if(cnt[i]<2) fail();
    if(cnt[mn]!=1) fail();
    REP(i,mn) if(cnt[i]) fail();

    for(int i=mn+1;i<mx;++i){
      es[m++]=mp(vs[i][0],vs[i+1][0]);
      es[m++]=mp(vs[i][1],vs[i+1][1]);
    }
    es[m++]=mp(vs[mn][0],vs[mn+1][0]);
    es[m++]=mp(vs[mn][0],vs[mn+1][1]);
    for(int i=mn+1;i<=mx;++i){
      for(int j=2;j<vs[i].size();++j){
        es[m++]=mp(vs[i][j],vs[i-1][0]);
      }
    }
  }
  puts("Possible");
  return 0;
}




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

main()
{
	int n;
	cin>>n;
	
	vector<int> a(n),h(n);
	vector<ll> tree(n+1);
	
	for(int i=0;i<n;i++)
	cin>>h[i];
	
	for(int i=0;i<n;i++)
	cin>>a[i];
	
	for(int i=0;i<n;i++)
	{
		int index=h[i]-1;
		
		ll tmp=tree[index];
		
		while(index>0)
		{
			tmp=max(tree[index],tmp);
			index-=index&(-index);
		}
		
		index=h[i];
		
		while(index<=n)
		{
			tree[index]=max(tree[index],tmp+a[i]);
			index+=index&(-index);
		}
	}
	
	ll ans=0;
	
	int index=n;
		
	while(index>0)
	{
		ans=max(tree[index],ans);
		index-=index&(-index);
	}
	
	cout<<ans;
}

Measured memory_bytes: 3328
#include<cstdio>
int n, a[100005];
long long ok(long long x){
    for(int i = 1; i <= n; ++i) x = x - x % a[i];
    return x;
}
int main(){
    scanf("%d", &n);
    for(int i = 1; i <= n; ++i) scanf("%d", &a[i]);
    long long l = 0, r = 1e18;
    while(l <= r){
        long long mid = (l + r) / 2;
        if(ok(mid) >= 2) r = mid - 1;
        else l = mid + 1;
    }
    long long down = l;
    l = 0, r = 1e18;
    while(l <= r){
        long long mid = (l + r) / 2;
        if(ok(mid) <= 2) l = mid + 1;
        else r = mid - 1;
    }
    long long up = r;
    if(up < down) puts("-1");
    else printf("%lld %lld\n", down, up);
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
using namespace std;

int main() {
	int N;
	cin >> N;
	vector<int> ABC(3);
	for (int& i : ABC) cin >> i;
	vector<string> s(N);
	for (string& i : s) cin >> i;
	bool a = true;
	string b;
	for (vector<string>::iterator i = s.begin(); i != s.end(); i++) {
		if (!ABC[i->front() - 'A']) {
			if (!ABC[i->back() - 'A']) {
				a = false;
				break;
			}
			ABC[i->front() - 'A']++;
			ABC[i->back() - 'A']--;
			b += i->front();
		}
		else if (!ABC[i->back() - 'A']) {
			ABC[i->front() - 'A']--;
			ABC[i->back() - 'A']++;
			b += i->back();
		}
		else {
			if (i == s.end() - 1) {
				ABC[i->front() - 'A']++;
				ABC[i->back() - 'A']--;
				b += i->front();
			}
			else {
				if (i->front() == (i + 1)->front() || i->front() == (i + 1)->back()) {
					ABC[i->front() - 'A']++;
					ABC[i->back() - 'A']--;
					b += i->front();
				}
				else {
					ABC[i->front() - 'A']--;
					ABC[i->back() - 'A']++;
					b += i->back();
				}
			}
		}
	}
	if (a) {
		cout << "Yes" << endl;
		for (char& i : b) cout << i << endl;
	}
	else cout << "No";
}

Measured memory_bytes: 6664
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
int main()
{
    int N, T;
    cin >> N >> T;
    
    vector<P> AB(N);
    vector<vector<int>> dp(N + 1, vector<int>(6010, -1));

    rep(i, N) {
        cin >> AB[i].first >> AB[i].second; 
    }
    sort(all(AB));

    dp[0][0] = 0;
    rep(i, N) {
        rep(j, T + 1) {
            if (dp[i][j] >= 0) {
                chmax(dp[i + 1][j], dp[i][j]);
                if (j < T) {
                    chmax(dp[i + 1][j + AB[i].first], dp[i][j] + AB[i].second);
                }
            }
        }
    }

    int res = 0;
    rep(i, N + 1) {
        rep(j, 6010) {
            chmax(res, dp[i][j]);
        }
    }
    cout << res << endl;
    return 0;
}

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

const int maxN = 505, mod = 1e9 + 7;

int n, X;
int cnt[maxN + 1], f[maxN + 1][maxN + 1];
int fac[maxN + 1], inv[maxN + 1];

inline void update(int &x, int y) { x = x + y >= mod ? x + y - mod : x + y; }

inline int mpow(int a, int x)
{
	int ans = 1;
	while(x)
	{
		if(x & 1) ans = 1ll * ans * a % mod;
		a = 1ll * a * a % mod;
		x >>= 1;
	}
	return ans;
}

int main()
{
	scanf("%d %d", &n, &X);
	X ++;
	for(int i = 1; i <= n; i++)
	{
		int x;
		scanf("%d", &x);
		cnt[x] ++;
	}

	fac[0] = 1;
	for(int i = 1; i <= X; i++) fac[i] = 1ll * fac[i - 1] * i % mod;
	inv[X] = mpow(fac[X], mod - 2);
	for(int i = X - 1; i >= 0; i--) inv[i] = 1ll * inv[i + 1] * (i + 1) % mod;

	f[0][0] = mod - 1;
	for(int l = X; l >= 1; l--)
	{
		for(int c = X / l; c >= 0; c--)
			for(int s = 0; s <= X; s++)
			{
				if(!f[c][s]) continue;
				for(int i = 1; s + i * l <= X; i++)
					if(i & 1) update(f[c + i][s + i * l], mod - 1ll * f[c][s] * inv[i] % mod);
					else update(f[c + i][s + i * l], 1ll * f[c][s] * inv[i] % mod);
			}
		for(int i = 1; i <= cnt[l]; i++)
			for(int c = 0; c <= X / l; c++)
				for(int s = 0; s <= X; s++)
					f[c][s] = 1ll * f[c][s] * (s - c * l) % mod;
	}

	int ans = 0;
	for(int c = 1; c <= X; c++) update(ans, 1ll * f[c][X] * fac[c] % mod);

	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  char c;
  while (cin >> c) {
    cout << (c == ',' ? ' ' : c);
  }
}


Measured memory_bytes: 256