akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;

namespace easy_Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] ABC = Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
            int maxNum = ABC.Max();
            int maxIndex = Array.IndexOf(ABC,maxNum);
            ABC[maxIndex] = 0;
            int middleNum = ABC.Max();
            int middleIndex = Array.IndexOf(ABC,middleNum);
            ABC[middleIndex] = 0;
            int minNum = ABC.Max();
            Console.WriteLine(maxNum*10+middleNum+minNum);

        }   
            // float[] ABN = Array.ConvertAll(Console.ReadLine().Split(),float.Parse);
            // long[] NK = Array.ConvertAll(Console.ReadLine().Split(),long.Parse);
            // long N = NK[0];
            // long K = NK[1];
            // long K = long.Parse(Console.ReadLine());
            // int[] abc = Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
            // string S = Console.ReadLine();
            // int x = int.Parse(Console.ReadLine());
            // int b = int.Parse(Console.ReadLine());
            // int N = int.Parse(Console.ReadLine());
            // float N = float.Parse(Console.ReadLine());
            // string c = Console.ReadLine();
            // string B = Console.ReadLine();
            // string[] s = Console.ReadLine().Split();
            // var s = (new string[] { Console.ReadLine(), Console.ReadLine(), Console.ReadLine() }).Select(float.Parse);
            // float[] a = Array.ConvertAll(Console.ReadLine().Split(),float.Parse);
            // var X = Console.ReadLine();
            // int[,] abcd = new int[NMQ[2],4];
            // int[] A = new int[NMQ[0]];
            // int[] A_num = new int[NMQ[0]];
            // long[] s=Array.ConvertAll(Console.ReadLine().Split(),long.Parse);
            // var hs=new Dictionary<long,long>();
            // for(int i=0;i<s[0];i++){
            //     long[] q=Array.ConvertAll(Console.ReadLine().Split(),long.Parse);
            //     if(hs.ContainsKey(q[0])){hs[q[0]]+=q[1];}
            //     else{hs.Add(q[0],q[1]);}
            // }
        
        // //最小公倍数
        // static long Lcm(long a, long b)
        // {
        //     return a/Gcd(a,b)*b;
        // }

        // //最大公約数
        // static long Gcd(long m, long n)
        // {
        //     if(n==0)return m;
        //     return Gcd(n,m%n);
        // }
    }
}


Measured memory_bytes: 13152
def tax(p, x):
	return p * (100 + x) // 100

while True:
	x, y, s = map(int, input().split())
	if (x, y, s) == (0, 0, 0):
		break
	r = 0
	for i in range(1, s):
		for j in range(1, s):
			t = tax(i, x) + tax(j, x)
			if t > s:
				break
			if (t) == s:
				r = max((tax(i, y) + tax(j, y)), r)
	print(r)

Measured memory_bytes: 7728
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll, ll> P;
using VP = vector<P>;
using VVP = vector<VP>;
using VI = vector<ll>;
using VVI = vector<VI>;
using VVVI = vector<VVI>;
const int inf = 1e9 + 7;
const ll INF = 1LL << 61;
const ll mod = 1e9 + 7;

template <class T> inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

template <class T> inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int i, j;
    int n, k;
    cin >> n >> k;
    ll a[n];
    for (i = 0; i < n; i++) cin >> a[i];
    sort(a, a + n);
    ll ans = 0;
    for (i = 0; i < k; i++) ans += a[i];
    cout << ans << endl;
}

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

int main()
{
	int n; cin>>n;
	vector<int> stone(n),m(n);
	for(int i=0;i<n;i++) cin>>stone[i];
	m[0]=0; m[1]=abs(stone[0]-stone[1]);
	for(int i=2;i<n;i++)
	{
		m[i]=min(abs(stone[i]-stone[i-2])+m[i-2],abs(stone[i]-stone[i-1])+m[i-1]);
	}
	cout<<m[n-1]<<"\n";
	return 0;
 } 

Measured memory_bytes: 1024
import bisect

n=int(input())
a=sorted(list(map(int,input().split())))
b=sorted(list(map(int,input().split())))
c=sorted(list(map(int,input().split())))

ans=0
for i in b:
    x=bisect.bisect_left(a,i)
    y=n-bisect.bisect_right(c,i)
    ans+=x*y

print(ans)

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

const int N = 3e5 + 55;

int a[N] , dp[N] , t[4*N];


void upd(int pos , int x , int u = 1,  int ul = 1 , int ur = (int)3e5) {
	if(ul == ur) {
		t[u] = x;
		return;
	}

	int um = ul+ur>> 1;
	if(pos <= um) {
		upd(pos , x , u<<1 , ul , um);
	}
	else {
		upd(pos , x , u<<1|1 , um+1 , ur);
	}
	t[u] = max(t[u<<1] , t[u<<1|1]);
}

int get(int l , int r , int u = 1, int ul = 1 , int ur = (int)3e5) {
	if(l <= ul && ur <= r) {
		return t[u];
	}
	if(r < ul || ur < l) {
		return 0;
	}
	
	int um = ul+ur>> 1;
	return max(get(l , r , u<<1 , ul , um) , get(l , r , u<<1|1 , um+1 , ur));
}
int main() {
	int n , k;
	cin >> n >> k;
	for(int i = 1; i <= n; i ++) {
		cin >> a[i];
	}
	for(int i = 1; i <= n; i ++) {
		int l = max(0 , a[i]-k);
		int r = min((int)3e5 , a[i]+k);
		dp[i] = get(l , r) + 1;
		upd(a[i] , dp[i]);
	}
	cout << t[1];
}

Measured memory_bytes: 10080
n=int(input())
b_start=0
a_last=0
both=0
ans=0
for i in range(n):
    s=input()
    ans+=s.count("AB")
    if s[0]=="B":
        if s[len(s)-1]=="A":
            both+=1
        else:
            b_start+=1
    elif s[len(s)-1]=="A":
        a_last+=1
diff=abs(b_start-a_last)
# print(a_last, b_start, both, ans, diff)
if both>=1:
    ans+=both-1
    if a_last>=1:
        ans+=1
        a_last-=1
    if b_start>=1:
        ans+=1
        b_start-=1
ans+=min(a_last,b_start)
print(ans)


Measured memory_bytes: 3064
#include<iostream>
using namespace std;
int main(){
    long N,M;
    cin >> N >> M;
    if(N==1 && M==1) cout << 1 << endl;
    else if(N==1) cout << M-2 << endl;
    else if(M==1) cout << N-2 << endl;
    else cout <<  (N-2)*(M-2) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>
#include <iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> P;
const ll MOD=998244353;
const ll MAX_N=500010;
const ll INF=999999999999;
ll dp[3010][3010];

int main(){
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    dp[a][b]=1;
    for(int x=a+1;x<=c;x++){
        dp[x][b]=dp[x-1][b]*b;
        dp[x][b]%=MOD;
    }
    for(int y=b+1;y<=d;y++){
        dp[a][y]=dp[a][y-1]*a;
        dp[a][y]%=MOD;
    }
    for(int x=a+1;x<=c;x++){
        for(int y=b+1;y<=d;y++){
            dp[x][y]=dp[x-1][y]*y;
            dp[x][y]%=MOD;
            dp[x][y]+=dp[x][y-1]*x;
            dp[x][y]%=MOD;
            dp[x][y]-=dp[x-1][y-1]*(x-1)*(y-1);
            dp[x][y]%=MOD;
        }
    }
    cout<<(dp[c][d]+MOD)%MOD<<endl;
}


Measured memory_bytes: 73916
#include <bits/stdc++.h>
using namespace std;
#define int long long
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define OUTOFRANGE(y,x,h,w) ((y)<0||(x)<0||(y)>=(h)||(x)>=(w))
#define dump(...)
#define pb push_back
const signed INF_=1001001001; const long long INF=1001001001001001001LL;
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v))os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a,const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a,const U &b){return a>b?a=b,1:0;}
template<class T> using heap=priority_queue<T,vector<T>,greater<T>>;
struct before_main_function {
    before_main_function() {
        cin.tie(0); ios::sync_with_stdio(false);
        cout << setprecision(15) << fixed;
        #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

signed main() {
    int N, M;
    cin >> N >> M;
    vi A(N);
    cin >> A;
    vi S(N);
    S[0] = A[0];
    REP(i, N - 1) S[i + 1] += S[i] + A[i + 1];

    vi T(N);
    REP(i, N) T[i] = S[i] % M;

    map<int, int> cnt;
    cnt[0] = 1;
    int ans = 0;
    REP(i, N) {
        ans += cnt[T[i]];
        cnt[T[i]]++;
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 6528
/*https://atcoder.jp/contests/dp/tasks/dp_h*/
#include <iostream>
#include <vector>
using namespace std;
int main(){
	int H, W;
	cin >> H >> W;
	vector<vector<int>> a(H, vector<int>(W, 0));
	for (int i = 0; i < H; i++){
		for (int j = 0; j < W; j++){
			char c;
			cin >> c;
			if (c == '#') a[i][j] = 1;
		}
	}
	vector<vector<long long>>dp(H, vector<long long>(W , 0));
	dp[0][0] = 1;
	int mod = 1e9 + 7;
	for (int i = 0; i < H; i++){
		for (int j = 0; j < W; j++){
			if (a[i][j] == 1) continue;
			if (i != 0){
				dp[i][j] = ((dp[i][j] % mod) + (dp[i - 1][j] % mod)) % mod;
			}
			if (j != 0){
				dp[i][j] = ((dp[i][j] % mod) + (dp[i][j - 1] % mod)) % mod;
			}
		}
	}
	cout << dp[H - 1][W - 1];
}

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

using namespace std;

#define int long long
#define MOD 1000000007

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()

#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
template <typename T>
void print(T x)
{
    std::cout << x << '\n';
}

//typedef long long ll;
#define TENNINE 1000000005
#define TENFIVE 100005
//#define int long long

int N,M;
vector<int>A,B,C;

signed main()
{
    cin>>N>>M;
    A.resize(N);
    B.resize(M);
    C.resize(M);

    map<int,int,greater<int>> index;

    rep(i,N){
        cin>>A[i];
    }
    rep(i,M){
        cin>>B[i]>>C[i];
        index[C[i]]+=B[i];
    }

    sort(all(A));
    int j=0;
    int sum = 0;


    for(auto x:index){
       rep(i,x.second){
            if(A[j]<x.first){
                A[j] = x.first;
            }
            else{
                //int sum=0;

                for(auto temp:A){
                    sum+=temp;
                }
                cout << sum <<endl;
                return 0; 
            }
            j++;

        }

    }
        



for(auto temp:A){
                    sum+=temp;
                }
                cout << sum <<endl;
                return 0; 
}


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

int main() {
	string S; cin >> S;
	vector<long long>Bigger(S.size() + 1, 0), Less(S.size() + 1, 0);
	for (long long i = 0; i < S.size(); i++) {
		if (S.at(i) == '<') {
			Less.at(i + 1) = Less.at(i) + 1;
		}
	}
	for (long long i = S.size() - 1; i >= 0; i--) {
		if (S.at(i) == '>') {
			Bigger.at(i) = Bigger.at(i + 1) + 1;
		}
	}
	long long ans = 0;
	for (long long i = 0; i <= S.size(); i++) {
		ans += max(Less.at(i), Bigger.at(i));
	}
	cout << ans << endl;
}

Measured memory_bytes: 11668
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()
def rand_N(ran1, ran2):
    return random.randint(ran1, ran2)
def rand_List(ran1, ran2, rantime):
    return [random.randint(ran1, ran2) for i in range(rantime)]
def rand_ints_nodup(ran1, ran2, rantime):
  ns = []
  while len(ns) < rantime:
    n = random.randint(ran1, ran2)
    if not n in ns:
      ns.append(n)
  return sorted(ns)

def rand_query(ran1, ran2, rantime):
  r_query = []
  while len(r_query) < rantime:
    n_q = rand_ints_nodup(ran1, ran2, 2)
    if not n_q in r_query:
      r_query.append(n_q)
  return sorted(r_query)

from collections import defaultdict, deque, Counter
from sys import exit
from decimal import *
import heapq
import math
from fractions import gcd
import random
import string
import copy
from itertools import combinations, permutations, product
from operator import mul
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7


#############
# Main Code #
#############

N = getN()
A = getList()

abs_max = A[0]
max_index = 0
ans = []
for i in range(1, N):
    opt = abs(A[i])
    if opt >= abs_max:
        abs_max = opt
        max_index = i

for i in range(N):
    if i != max_index:
        A[i] += A[max_index]
        ans.append([max_index + 1, i + 1])

if A[max_index] >= 0:
    for i in range(1, N):
        A[i] += A[i - 1]
        ans.append([i, i + 1])
else:
    for i in range(N - 1, 0, -1):
        A[i - 1] += A[i]
        ans.append([i + 1, i])

print(len(ans))
for i in ans:
    print(*i)

Measured memory_bytes: 83592
#include <stdio.h>

char str[101];

int getitv(char c){
    int r=0;
    int i,j;
    for(i=0,j=0;str[i]!='\0';i++,j++){
        if(str[i]==c){
            if(j>r)
                r=j;
            j=-1;
        }
    }
    if(j>r)
        return j;
    else
        return r;
}

main(){
    scanf("%s",&str);
    char i;
    int r=1000;

    for(i='a';i<='z';i++){
        if(getitv(i)<r)
            r=getitv(i);
    }
    printf("%d\n",r);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define debug(x) cerr << #x << " " << x << '\n'
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
const int INF = 0x3f3f3f3f, N = 2e5 + 5;
const ll LINF = 1e18 + 5;
constexpr int dir[4][2] = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}};
int h, w;
char s[30][30];
bool vis[30][30];
int calcu(int a, int b, int c, int d)
{
	queue <tuple<int, int, int>> q;
	q.push(make_tuple(a, b, 0));
	memset(vis, 0, sizeof(vis));
	vis[a][b] = 1;
	while(sz(q))
	{
		int x, y, step;
		tie(x, y, step) = q.front(); q.pop();
		if(x==c and y==d) return step;
		for(int i=0; i<4; i++)
		{
			int tx = x + dir[i][0], ty = y + dir[i][1];
			if(tx<=0||ty<=0||tx>h||ty>w) continue;
			if(vis[tx][ty]||s[tx][ty]=='#') continue;
			q.push(make_tuple(tx, ty, step+1));
			vis[tx][ty] = 1;
		}
	}
	return -1;
}
int main()
{
 	ios::sync_with_stdio(false);
 	cin.tie(0);
	cin >> h >> w;
	for(int i=1; i<=h; i++) cin >> (s[i]+1);
	int ans = 0;
	for(int i=1; i<=h; i++)
	{
		for(int j=1; j<=w; j++)
		{
			if(s[i][j]=='#') continue;
			for(int k=1; k<=h; k++)
			{
				for(int l=1; l<=w; l++)
				{
					if(s[k][l]=='#') continue;
					ans = max(ans, calcu(i, j, k, l));
				}
			}
		}
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
#include<iterator>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> IP;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)

vector<string>num753(int N) {
	//桁数Nの753数を列挙
	vector<string>ans;
	if (N == 1) {
		ans = { "7","5","3" };
	}
	else {
		vector<string>TMP;
		TMP = num753(N - 1);
		string tmp;
		rep(i, TMP.size()) {
			tmp = TMP[i];
			tmp.push_back('7');
			ans.push_back(tmp);
			tmp = TMP[i];
			tmp.push_back('5');
			ans.push_back(tmp);
			tmp = TMP[i];
			tmp.push_back('3');
			ans.push_back(tmp);
		}
	}
	return ans;
}

vector<string>new753(vector<string>V) {
	vector<string>ans;
	int c3 = 0, c5 = 0, c7 = 0;
	rep(i, V.size()) {
		rep(j, V[i].size()) {
			if (V[i][j] == '3')c3++;
			if (V[i][j] == '5')c5++;
			if (V[i][j] == '7')c7++;
		}
		if (c3 == 0 || c5 == 0 || c7 == 0) {

		}
		else {
			ans.push_back(V[i]);
		}
		c3 = 0;
		c5 = 0;
		c7 = 0;
	}
	return ans;
}

int main() {
	int A;
	cin >> A;
	string S = to_string(A);
	int N = S.size();
	if (N < 3) {
		cout << 0 << endl;
		return 0;
	}
	int cnt = 0;
	vector<string>V;
	for (int i = 3; i <= N; i++) {
		vector<string>TMP = new753(num753(i));
		rep(j, TMP.size()) {
			V.push_back(TMP[j]);
		}
	}
	rep(i, V.size()) {
		if (stoi(V[i]) <= A) {
			cnt++;
		}
	}
	cout << cnt << endl;
}

Measured memory_bytes: 3196
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for (int64_t i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
#define pb push_back
vector<int>G[100010];
vector<int>dp(100010,0);
int r(){int x;cin>>x;return x;}
int dfs(int v){
    int &count=dp[v];
    if(count)return count;
    for(auto it:G[v])count=max(count,dfs(it)+1);
    return count;
}
void solve() 
{
    int n,m,ans=0;cin>>n>>m;
    REP(i,m)G[r()-1].pb(r()-1);
    REP(i,n)ans=max(ans,dfs(i));
    cout<<ans<<endl;
}
int main()
{
    cin.tie(0);
	ios::sync_with_stdio(false);
    solve();
    return 0;
}


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

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

const int INT_INF = 2147483646;
const ll LL_INF = 9223372036854775807;

bool SecondCompare(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second<b.second;
}
 
bool SecondCompareDes(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second>b.second;
}

ll minll(ll a, ll b){
    if(a >= b)  return b;
    else    return a;
}

ll maxll(ll a, ll b){
    if(a >= b)  return a;
    else    return b;
}

ll n,l;
ll arr[1000],arr2[1000];

int main(){
    cin >> n >> l;
    ll mem;
    ll mem_min = LL_INF;
    for(int i = 0; i < n; i++){
        arr[i] = l + i;
        if(mem_min > abs(arr[i])){
            mem_min = abs(arr[i]);
            mem = i;
        }
    }

    sort(arr2,arr2+n);
    ll ans = 0;
    for(int i = 0; i < n; i++){
        ans += arr[i];
    }
    ans -= arr[mem];

    cout << ans << endl;
}

Measured memory_bytes: 256
// B - Guidebook
#include <bits/stdc++.h>
using namespace std;
using tpl = tuple<string,int,int>;
#define tget(t,n) get<(n)>((t))

int cp(tpl &a, tpl &b){
	return tget(a,0)!=tget(b,0)?
		tget(a,0)<tget(b,0): tget(a,1)>tget(b,1);
}

int main(){
	int n; cin>>n;
	vector<tpl> sp;
	for(int i=0; i<n; ++i){
		string s; int p; cin>>s>>p;
		sp.push_back(make_tuple(s, p, i+1));
	}
	sort(sp.begin(), sp.end(), cp);
	for(auto e:sp) cout<< tget(e,2) <<endl;
}

Measured memory_bytes: 256
@d = gets.to_i
@c = gets.split.map &:to_i
@s = @d.times.map { gets.split.map &:to_i }

def score(schedule, range = 0...@d, last = [0] * 26)
  sat = 0
  range.each do |day|
    type = schedule[day]
    sat += @s[day][type]
    day += 1
    last[type] = day
    sat -= 26.times.sum { |i, day_last| @c[i] * (day - last[i]) }
  end
  sat
end

# greedy part

schedule = [0] * @d
last = [0] * 26
score = nil
@d.times do |day|
  s_max, i_max = -10000000, 0
  26.times do |i|
    schedule[day] = i
    s = score(schedule, day..day, last.dup)
    s_max, i_max = s, i if s > s_max
  end
  schedule[day] = i_max
  score = s_max
  last[i_max] = day + 1
end

# annealing part
t0 = 2000.0
t1 = 600.0
t = t0
tl = 5
100.times do
  day = rand @day
  type = rand 26
  prev = schedule[day]
  schedule[day] = type
  s = score(schedule)
  if s >= score or rand < Math.exp((score - s) / t)
    score = s
  else
    schedule[day] = prev
  end
  t = (t0 ** (1 - t)) * (t1 ** t)
end

schedule.each do |type|
  p type + 1
end


Measured memory_bytes: 15148
from itertools import product


def main():
    N, M = map(int, input().split())
    conn = [
        list(map(int, input().split()[1:]))
        for _ in range(M)
    ]
    conds = list(map(int, input().split()))

    ans = 0
    for state in product(("ON", "OFF"), repeat=N):
        if all(
            len([s for s in switches if state[s - 1] == "ON"]) % 2 == p
            for switches, p in zip(conn, conds)
        ):
            ans += 1
            
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
#include<cstdio>
#include<numeric>
#include<algorithm>

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

using namespace std;

typedef long long ll;

const int V_MAX=109;
const int E_MAX=1000;

template<class T>
struct graph{
	int n,m,head[V_MAX],next[2*E_MAX],to[2*E_MAX];
	T capa[2*E_MAX],flow[2*E_MAX];

	void init(int N){
		n=N;
		m=0;
		rep(u,n) head[u]=-1;
	}

	void add_directed_edge(int u,int v,T ca){
		next[m]=head[u]; head[u]=m; to[m]=v; capa[m]=ca; flow[m]=0; m++;
		next[m]=head[v]; head[v]=m; to[m]=u; capa[m]= 0; flow[m]=0; m++;
	}

	void add_undirected_edge(int u,int v,T ca){
		next[m]=head[u]; head[u]=m; to[m]=v; capa[m]=ca; flow[m]=0; m++;
		next[m]=head[v]; head[v]=m; to[m]=u; capa[m]=ca; flow[m]=0; m++;
	}
};

const ll INF=1LL<<61;

int layer[V_MAX],now[V_MAX];

template<class T>
bool make_layer(const graph<T> &G,int s,int t){
	int n=G.n;
	rep(u,n) layer[u]=(u==s?0:-1);

	int head=0,tail=0;
	static int Q[V_MAX]; Q[tail++]=s;
	while(head<tail && layer[t]==-1){
		int u=Q[head++];

		for(int e=G.head[u];e!=-1;e=G.next[e]){
			int v=G.to[e];
			T capa=G.capa[e],flow=G.flow[e];

			if(capa-flow>0 && layer[v]==-1){
				layer[v]=layer[u]+1;
				Q[tail++]=v;
			}
		}
	}

	return layer[t]!=-1;
}

template<class T>
T augment(graph<T> &G,int u,int t,T water){
	if(u==t) return water;

	for(int &e=now[u];e!=-1;e=G.next[e]){
		int v=G.to[e];
		T capa=G.capa[e],flow=G.flow[e];

		if(capa-flow>0 && layer[v]>layer[u]){
			T w=augment(G,v,t,min(water,capa-flow));
			if(w>0){
				G.flow[ e ]+=w;
				G.flow[e^1]-=w;
				return w;
			}
		}
	}
	return 0;
}

template<class T>
T Dinic(graph<T> &G,int s,int t){
	int n=G.n;
	T ans=0;
	while(make_layer(G,s,t)){
		rep(u,n) now[u]=G.head[u];
		for(T water=1;water>0;ans+=water) water=augment(G,s,t,INF);
	}
	return ans;
}

int main(){
	int n;
	for(ll W;scanf("%d%lld",&n,&W),n;){
		bool aki[100][7]={};
		ll need[100];
		rep(i,n){
			int m; scanf("%lld%d",need+i,&m);
			rep(j,m){
				char s[16]; scanf("%s",s);
				if(s[0]=='S' && s[1]=='u') aki[i][0]=true;
				if(s[0]=='M')              aki[i][1]=true;
				if(s[0]=='T' && s[1]=='u') aki[i][2]=true;
				if(s[0]=='W')              aki[i][3]=true;
				if(s[0]=='T' && s[1]=='h') aki[i][4]=true;
				if(s[0]=='F')              aki[i][5]=true;
				if(s[0]=='S' && s[1]=='a') aki[i][6]=true;
			}
		}

		int s=n+7,t=s+1;
		graph<ll> G;
		G.init(n+9);
		// source -> left nodes
		rep(u,7) G.add_directed_edge(s,u,W);
		// right nodes -> sink
		rep(i,n){
			int v=7+i;
			G.add_directed_edge(v,t,need[i]);
		}
		// left nodes -> right nodes
		rep(i,n) rep(j,7) if(aki[i][j]) {
			int u=j,v=7+i;
			G.add_directed_edge(u,v,W);
		}

		puts(Dinic(G,s,t)==accumulate(need,need+n,0LL)?"Yes":"No");
	}

	return 0;
}

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

#define REP(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define eb emplace_back

using ll = int64_t;

using namespace std;

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s,t;cin >> s >> t;
    int64_t ans = 0;
    REP(i,s.size()) ans += (s[i] != t[i]);
    cout << ans << '\n';
}



Measured memory_bytes: 3792
use std::io::stdin;
use std::iter::repeat;

fn read_ints() -> Vec<i32> {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace().map(|token| token.parse().unwrap()).collect()
}

fn main () {
    let params = read_ints();
    let d: i32 = *params.get(0).unwrap();
    let g: i32 = *params.get(1).unwrap();

    let problem_params: Vec<_> = (0..d).map(|_d| {
        let vec = read_ints();
        (*vec.get(0).unwrap(), *vec.get(1).unwrap())
    }).collect();

    let answer = (0..(1 as i32).rotate_left(d as u32))
        .map(|complete_bits| {
            let is_complete = |_d: &i32| {
                complete_bits.rotate_right(*_d as u32) & 1 == 1
            };
            let complete_params: Vec<_> = (0..d)
                .filter(&is_complete)
                .map(|_d| {
                    let (count, bonus) = *problem_params.get(_d as usize).unwrap();
                    (_d + 1, count, bonus)
                }).collect();
            let complete_scores = complete_params.iter().map(|&(difficulty, count, bonus)| {
                difficulty * count * 100 + bonus
            }).fold(0, |x, y| x + y);
            let complete_counts = complete_params.iter().map(|&(difficulty, count, bonus)| {
                count
            }).fold(0, |x, y| x + y);

            if complete_scores >= g {
                Some(complete_counts)
            } else {
                let incomplete_params: Vec<_> = (0..d)
                    .filter(|x| !&is_complete(x))
                    .map(|_d| {
                        let &(count, bonus) = problem_params.get(_d as usize).unwrap();
                        ((_d + 1) * 100, count)
                    }).collect();
                let mut incomplete_problems: Vec<_> = incomplete_params.into_iter().flat_map(|(score, count)| repeat(score).take(count as usize)).collect();
                incomplete_problems.sort_by_key(|&x| -x);

                let mut scores_to_goal = g - complete_scores;
                let mut incomplete_counts = 0;
                for score in incomplete_problems.into_iter() {
                    if scores_to_goal > 0 {
                        scores_to_goal -= score;
                        incomplete_counts += 1;
                    }
                }
                if scores_to_goal <= 0 {
                    Some(incomplete_counts + complete_counts)
                } else {
                    None
                }
            }
        })
        .flat_map(|res| res.into_iter())
        .min_by_key(|&x| x).unwrap();

    println!("{}", answer)
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
//#include<ext/pb_ds/assoc_container.hpp>
//#include<ext/pb_ds/tree_policy.hpp>
//
//    #pragma GCC optimize("unroll-loops")
//    #pragma GCC optimize("Ofast")
//    #pragma GCC optimize("-O3")
//    #pragma GCC optimize("no-stack-protector")
//    #pragma GCC optimize("fast-math")

#define fi first
#define f first
#define se second
#define s second
#define vi_a vector<int>a;
#define p_b push_back
////////////////////////////////???????????????CHECK THIS OUT???????????????//////////////////////////////
#define ll long long
////////////////////////////////???????????????CHECK THIS OUT???????????????//////////////////////////////
#define ld long double
#define pll pair<ll,ll>
#define pii pair<int,int>
#define m_p make_pair
#define fast_io cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);
#define all(x) x.begin(),x.end()
#define getfiles    ifstream cin("input.txt");ofstream cout("output.txt");
#define pw(x) (1ll << x)
#define sz(x) (ll)x.size()
#define endl "\n"
#define rall(x) x.rbegin(),x.rend()
#define len(a) (ll)a.size()
#define rep(x,l,r) for(ll x=l;x<r;x++)
//#define for(int i=0;i<n;i++) for(ll i=0;i<n;i++)
using namespace std;
//using namespace __gnu_pbds;
ld eps = (ld)1 / 1e6;
ll inf = 1e18, mod2 = 998244353, mod1 = 1e9 + 7;
ll sqr(ll a) { return a * a; }
ll qb(ll a) { return a * a * a; }
ll gcd(ll a, ll b) { return !a ? b : gcd(b % a, a); }
ll binpow(ll a, ll b, ll mod) { return b ? (b % 2 ? (a * (sqr(binpow(a, b / 2, mod)) % mod)) % mod : sqr(binpow(a, b / 2, mod)) % mod) : 1; }
ll binmult(ll a, ll b, ll mod) { return b ? (b % 2 ? (2 * binmult(a, b / 2, mod) + a) % mod : (2 * binmult(a, b / 2, mod)) % mod) : 0; }
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//const ll to[5]={0,4,6,7,9};
//const ll N=2*1e5+1;
const ll R=1e4;
//const ll to[7]={1,2,3,1,3,2,1};
const ll tx[4]={0,0,-1,1};
const ll ty[4]={-1,1,0,0};
const char rev_to[4]={'E','W','N','S'};
const ll N=2*1e5+4;
ll a[N];
vector<ll> g[N];
ll ans[N];
void dfs(ll v,ll p,vector<ll> &c){
    ll pos=lower_bound(all(c),a[v])-c.begin();
    ll prev=c[pos];
        c[pos]=a[v];
    ans[v]=lower_bound(all(c),inf)-c.begin()-1;
    for(auto z : g[v]){
        if(z==p) continue;
        dfs(z,v,c);
    }
    c[pos]=prev;
}
signed main(){
    fast_io;
    ll n;
    cin>>n;
    for(ll i=0;i<n;i++)cin>>a[i];
    ll v,u;
    for(ll i=1;i<n;i++){
        cin>>v>>u;--v;--u;
        g[v].p_b(u);
        g[u].p_b(v);
    }
    vector<ll> lol(N+2,inf);
        lol[0]=-inf;
    dfs(0,0,lol);
    for(ll i=0;i<n;i++){
        cout<<ans[i]<<endl;
    }
    return 0;
}
/*

    если WA , то чекер говно, поэтому почекай l8 строчку

*/


Measured memory_bytes: 33296
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <cstring>
#define MAXV 100500
#define F(a,b) for(int a = 0; a < b; ++ a)
#define FF(a,b) for(int a = 1; a <= b; ++ a)
#define INF 1LL << 60
typedef long long ll;
using namespace std;

int main(){
	int N, W;
	scanf("%d%d", &N, &W);
	vector<ll> v(N), w(N);
	F(i,N){
		scanf("%lld%lld", &v[i], &w[i]);
	}
	ll dp[N + 3][MAXV];
	F(i,N+1){
		F(j,MAXV){
			dp[i][j] = INF;
		}
	}
	dp[0][0] = 0;
	F(i,N){
		F(j,MAXV){
			if(j - w[i] >= 0){
				dp[i + 1][j] = min(dp[i][j], dp[i][j - w[i]] + v[i]);
			}else{
				dp[i + 1][j] = dp[i][j];
			}
		}
	}
	ll res = 0;
	F(i,MAXV){
		if(dp[N][i] <= W){
			res = max(res, (ll)i);
		}
	}
	printf("%lld\n", res);
	return 0;
}


Measured memory_bytes: 80896
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>

#define repd(i,a,b) for (int i=(a);i<(b);++i)
#define rep(i,n) repd(i,0,n)
#define reprd(i,a,b) for (int i=(a);i>=(b);--i)
#define repr(i,n) reprd(i,n,0)
typedef long long ll;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

using namespace std;

const ll BIG = 1000000007LL;

int inputValue(){
    int a;
    cin >> a;
    return a;
};

template<typename T>
void inputArray(T* p, int a){
    rep(i, a){
        cin >> p[i];
    }
};

template<typename T>
void inputVector(vector<T> * p, int a){
    rep(i, a){
        T input;
        cin >> input;
        p -> push_back(input);
    }
}

template <typename T>
void output(T a, int precision = 0) {
    if(precision > 0){
        cout << setprecision(precision)  << a << "\n";
    }
    else{
        cout << a << "\n";
    }
}

const int Max = 110000;
int N, K, R, S, P;
string T;
bool win[Max];

int main(int argc, const char * argv[]) {
    cin >> N >> K >> R >> S >> P >> T;

    int ans = 0;
    rep(i, N) {
        int score = 0;
        switch (T[i]) {
            case 'r':
                score = P;
            break;
            case 's':
                score = R;
            break;
            case 'p':
                score = S;
            break;
        }
        win[i] = true;

        if (i >= K) {
            // K個前が違う手のときは気にしなくて良い
            if (T[i-K] == T[i]) {
                if (win[i-K]) {
                    // 前回勝った
                    win[i] = false;
                }
            }
        }

        if (!win[i]) score = 0;
        // printf("%d: %d\n", i, score);
        ans += score;
    }

    output(ans);

    return 0;
}

Measured memory_bytes: 512
#include <stdio.h>
#include <limits.h>

int main(void) {
	unsigned long long int x = 0;
	unsigned long long int total = 100;
	int i;

	scanf("%lld", &x);

	for(i=1; ; i++) {
		total = total + total * 0.01;
		//printf("%lld\n", total);
		if(total>=x) {
			printf("%d", i);
			break;
		}
	}

	return 0;
}

Measured memory_bytes: 1728
#include <stdio.h>
#include <string.h>
#include <math.h>

using namespace std;


int main(void){
	int i, j, inp;
	bool flag[300001];

	for(i = 0;i <= 300000;i++){
		flag[i] = false;
		if(i % 7 == 1 || i % 7 == 6) flag[i] = true;
	}
	flag[1] = false;

	for(i = 2;i <= 300000;i++){
		if(i % 7 == 1 || i % 7 == 6){
			for(j = 6;j <= sqrt((double)i);j++){
				if((j % 7 == 1 || j % 7 == 6) && i % j == 0){
					flag[i] = false;
					break;
				}
			}
		}
	}

	scanf("%d",&inp);
	while(inp != 1){
		printf("%d:",inp);
		for(i = 6;i <= inp;i++)
			if(flag[i] && inp % i == 0) printf(" %d",i);
		printf("\n");
		scanf("%d",&inp);
	}
	return 0;
}

Measured memory_bytes: 1320
#include <iostream>
using namespace std;
int N,K,Q;
int A[100000];
int S[100000];
int main() {
    cin >> N >> K >> Q;
    for (int i=0; i<N; i++) S[i] = K;
    for (int i=0; i<Q; i++) {
        scanf("%d", &A[i]);
    }

    for (int i=0; i<N; i++) S[i] -= Q;
    for (int i=0; i<Q; i++) S[A[i]-1]++;

    for (int i=0; i<N; i++) {
        if (S[i] > 0) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    }
    return 0;
}


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

#define fi first
#define se second
#define FOR(a, b, c) for(int a = b; a <= c; ++a)
#define int long long

int n, m, d;

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    cin >> n >> m >> d;
    int tim = ((d == 0.00) ? 1 : 2);
    cout << fixed << setprecision(10) << 1.00 * tim * (m - 1) * (n - d) / (1.00 * n * n);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define fr(i,a,b) for (ll i = (a), _b = (b); i <= _b; i++)
#define frr(i,a,b) for (ll i = (a), _b = (b); i >= _b; i--)
#define sz(x) ((long long)x.size())
#define rep(i,n) for (ll i = 0, _n = (n); i < _n; i++)
#define repr(i,n) for (ll i = (n) - 1; i >= 0; i--)
#define debug(x) cout<<#x<<": "<<x<<endl
#define devec(a,n) { cout << #a << " = "; rep(_,n) cout << a[_] << ' '; cout << '\n'; }
#define all(ar) ar.begin(), ar.end()
#define rall(ar) ar.rbegin(), ar.rend()
#define pb push_back
#define pob pop_back()
#define pf push_front
#define pof pop_front()
#define mp make_pair
#define ff first
#define ss second
#define MOD 1000000007
 
auto clk=clock();
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const ll INF = 1e18L+5;
const int d4i[4]={-1, 0, 1, 0}, d4j[4]={0, 1, 0, -1};
const int d8i[8]={-1, -1, 0, 1, 1, 1, 0, -1}, d8j[8]={0, 1, 1, 1, 0, -1, -1, -1};
 
typedef pair<ll, ll> ii;
typedef pair<ll, ii> iii;
typedef vector<ii> vii;
typedef vector<ll> vi;
typedef vector<int> vint;
typedef vector<string> vs;
typedef vector<vi> vvi;

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

void solve(){
    int n;
    cin>>n;
    vi sp(n+1);
    sp[1] = 1;
    fr(i,1,n)
        sp[i] = i;
    fr(i,2,n/2)
        sp[2*i] = 2;
    for(ll i=3; i*i<=n; i++){
        if(sp[i]==i){
            for(ll j=i*i; j<=n; j+=i){
                sp[j] = i;
            }
        }
    }

    // devec(sp,20)

    vi f(n+1);
    fr(i,1,n){
        ll x = i;
        ll c = 1;
        set<ll> px;
        while(x!=1){
            px.insert(sp[x]);
            x = x/sp[x];
        }
        for(auto j : px){
            ll x = i;
            ll cj = 1ll;
            while(x%j==0){
                x = x/j;
                cj++;
            }
            c = c*cj;
        }
        f[i] = c;
        // if(i==9){
        //     for(auto j : px)
        //         cout<<j<<'\n';
        // }
    }

    ll ans = 0;
    rep(i,n)
        ans += f[i];

    cout<<ans;
}

 
int main (){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout<<setprecision(11);
 
    ll t = 1;
    // cin>>t;
    while(t--){
        solve();
    }
 
    // cout<<endl<<endl<<"Time elapsed: "<<((double)(clock()-clk)/CLOCKS_PER_SEC)*1000<<"ms"<<endl;
    return 0;
}

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

int main() {
  int N, M;
  cin >> N >> M;
  vector<string> A(N);
  vector<string> B(M);
  for(int i = 0; i < N; i++) {
    cin >> A.at(i);
  }
  for(int i = 0; i < M; i++) {
    cin >> B.at(i);
  }
  bool b = true;
  bool bb = false;
  for(int i = 0; i < N-M+1; i++) {
    for(int j = 0; j < N-M+1; j++) {
      b = true;
      for(int k = 0; k < M; k++) {
        for(int l = 0; l < M; l++) {
          if(B.at(k).at(l) != A.at(k+i).at(l+j)) {
          b = false;
          continue;
          }
        }
      }
      if(b) {
        bb = true;
        break;
      }
    }
  }
  if(bb) {
    cout << "Yes";
  }
  else {
    cout << "No";
  }
}


Measured memory_bytes: 256
s=int(input())
flag=0
z=0
for i in range(s):
    p= list(map(int, input().split()))
    if p[0]==p[1]:
        z+=1
        if z==3:
            flag=1
    else:
        z=0
if flag:
    print("Yes")
else:
    print("No")

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

namespace test
{
    class Program
    {
        static void Main(string[] args)
        {
            var L = ReadInt();
            var A = new int[L];
            for (int i = 0; i < L; i++) A[i] = ReadInt();
            var dp = new long[L + 1, 5];
            for (int i = 0; i < L; i++) dp[i + 1, 0] += dp[i, 0] + A[i];
            for (int i = 0; i < L; i++) dp[i + 1, 1] += Math.Min(dp[i, 1] + (A[i] == 0 ? 2 : A[i] % 2), dp[i + 1, 0]);
            for (int i = 0; i < L; i++) dp[i + 1, 2] += Math.Min(dp[i, 2] + (A[i] == 0 ? 1 : (A[i] + 1) % 2), dp[i + 1, 1]);
            for (int i = 0; i < L; i++) dp[i + 1, 3] += Math.Min(dp[i, 3] + (A[i] == 0 ? 2 : A[i] % 2), dp[i + 1, 2]);
            for (int i = 0; i < L; i++) dp[i + 1, 4] += Math.Min(dp[i, 4] + A[i], dp[i + 1, 3]);

            Console.WriteLine(dp[L, 4]);
            Console.ReadLine();
        }

        static string Read() { return Console.ReadLine(); }
        static int ReadInt() { return int.Parse(Read()); }
        static long ReadLong() { return long.Parse(Read()); }
        static int[] ReadArrayInt() { return Read().Split(' ').Select(s => int.Parse(s)).ToArray(); }
        static long[] ReadArrayLong() { return Read().Split(' ').Select(s => long.Parse(s)).ToArray(); }
    }
}

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

using namespace std;
const int V[10] = {512, 256, 128, 64, 32, 16, 8, 4, 2, 1};
int n;

void solve(){
    vector<int> w;
    for(int i=0; i<10; i++){
        int f = n/V[i];
        if(f!=0){
            n -= V[i];
            w.push_back(V[i]);
        }
    }
    for(int i=w.size()-1; i>=0; i--){
        if(i==0){
            cout<< w[i];
        }else{
            cout<< w[i]<< " ";
        }

    }
    cout<<endl;
}
int main(){
    while(cin>>n){
        solve();
    }
    return 0;
}

Measured memory_bytes: 1216
object Main{
  def main(args:Array[String]){
    val sc=new java.util.Scanner(System.in)
    val b=new scala.util.control.Breaks
    b.breakable{
      while(true){
        val n,x=sc.nextInt()
        if(n==0) b.break
        var ans=0
        for(i<-1 to n;j<-i+1 to n;k<-j+1 to n if i+j+k==x) ans+=1
        println(ans)
      }
    }
  }
}

Measured memory_bytes: 58064
package main

import (
	"fmt"
)

func main() {
	var n, d, x, a, r int
	fmt.Scan(&n, &d, &x)
	r = x
	for i := 0; i < n; i++ {
		fmt.Scan(&a)
		r += (d / a)
		if d%a > 0 {
			r++
		}
	}
	fmt.Println(r)
}


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

template<int mod> struct ModInt {
    int x;
    ModInt() : x(0) {}
    ModInt(long long y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}
    ModInt &operator+=(const ModInt &p) { if((x += p.x) >= mod) x -= mod; return *this; }
    ModInt &operator-=(const ModInt &p) { if((x += mod-p.x) >= mod) x -= mod; return *this; }
    ModInt &operator*=(const ModInt &p) { x = (int)(1LL*x*p.x%mod); return *this; }
    ModInt &operator/=(const ModInt &p) { *this *= p.inverse(); return *this; }
    ModInt operator-() const { return ModInt(-x); }
    ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }
    ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }
    ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }
    ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }
    bool operator==(const ModInt &p) const { return x == p.x; }
    bool operator!=(const ModInt &p) const { return x != p.x; }
    ModInt inverse() const {
        int a = x, b = mod, u = 1, v = 0, t;
        while(b > 0) { t = a / b; a -= t * b; swap(a, b); u -= t * v; swap(u, v); }
        return ModInt(u);
    }
    ModInt pow(long long e){
        long long a = 1, p = x;
        while(e > 0) {
            if (e & 1) {a = (a * p) % mod; e--;}
            else {p = (p * p) % mod; e /= 2;}
        }
        return ModInt(a);
    }
    friend ostream &operator<<(ostream &os, const ModInt<mod> &p) {
        return os << p.x;
    }
    friend istream &operator>>(istream &is, ModInt<mod> &a) {
        long long x;
        is >> x;
        a = ModInt<mod>(x);
        return (is);
    }
};

template<int mod> struct Combination {
    vector<ModInt<mod>> fact, ifact;
    Combination(int n) : fact(n+1), ifact(n+1) {
        fact[0] = 1;
        for (int i = 1; i <= n; i++) fact[i] = (fact[i - 1] * i);
        ifact[n] = fact[n].inverse();
        for (int i = n; i > 0; i--) ifact[i - 1] = ifact[i] * i;
    }
    ModInt<mod> operator() (int n, int r) {
        if (r < 0 or r > n) return 0;
        return fact[n] * ifact[n-r] * ifact[r];
    }
    constexpr ModInt<mod> &operator[] (int i) const {
        return fact[i];
    }
};

constexpr int MOD = 1000000007;
constexpr int MAX = 1000100;

int main() {
	Combination<MOD> binom(MAX);
	int n, k;
	cin >> n >> k;
	
	cout << binom(n - 1, k - 1) << '\n';
	
	return 0;
}


Measured memory_bytes: 10580
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
#include<iterator>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> IP;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)

int main() {
	int H, W, h, w;
	cin >> H >> W >> h >> w;
	cout << H * W - (h * W + H * w - h * w) << endl;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int a,b;
  
  while(cin>>a>>b){
    a+=b;
    b=1;
    for(int i=1;i<=7;i++){
      b*=10;
      if(a<b){
	cout<<i<<endl;
	break;
      }
    }
  }
  return 0;
}


Measured memory_bytes: 3112
Ns = [int(s) for s in input()]
order = len(Ns)

dp_just = [0 for _ in range(order + 1)]
dp_plus = [0 for _ in range(order + 1)]

dp_just[0] = 0
dp_plus[0] = 1

for o in range(order):
  n = Ns[o]
  dp_just[o+1] = min(dp_just[o] + n, dp_plus[o] + (10 - n))
  dp_plus[o+1] = min(dp_just[o] + n + 1, dp_plus[o] + (9 -n))
  
print(dp_just[-1])


Measured memory_bytes: 91788
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
#define REP(i,n) for (int i=0;i<(n);i++)
#define REP1(i,a,b) for(int i=(a);i<=(b);i++)
#define em emplace_back
#define ALL(x) (x).begin(),(x).end()
#define F first
#define S second
#define mkp make_pair
#define pii pair<int,int>
#define oi ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define pll pair<ll,ll>


int main(){
    //oi;
    int n,h,w;
    cin>>n>>h>>w;
    cout<<(n-h+1)*(n-w+1)<<"\n";
//    system("pause");
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main()
{
   int n,k;
   cin >> n >> k;
   string s;
   cin >> s;
   vector<int> vec;
   int now = 1;
   int cnt = 0;
   for(int i = 0; i < n; i++)
   {
       if (s[i] == (char)('0'+now)) {
           cnt++;
       }
       else
       {
           vec.push_back(cnt);
           now = 1 - now;
           cnt = 1;
       }
   }
   if (cnt != 0) {
       vec.push_back(cnt);
   }
   if (vec.size()%2 == 0) {
       vec.push_back(0);
   }
   int add = 2*k+1;
   int ans = 0;
   int left = 0;
   int right = 0;
   int tmp = 0;
   for(int i = 0; i < vec.size(); i+=2)
   {
       int nextleft = i;
       int nextright = min(i + add, (int)vec.size());
       while(nextleft > left){
           tmp -= vec[left];
           left++;
       }
       while(nextright > right){
           tmp += vec[right];
           right++;
       }
       
       ans = max(ans, tmp);
   }
   cout << ans << endl;
}

Measured memory_bytes: 1020
#include <iostream>
#include <cctype>
#include <cstdlib>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#define rep(i, n) for(int i = 0; i < n; ++i)
using namespace std;

int comp(const void* a, const void* b){
	return *(int*)a - *(int*)b;
}

int main() {
	int n;
	cin >> n;
	if(n == 1){
		cout << "Hello World" << endl;
	}else{
		int a, b;
		cin >> a >> b;
		cout << a+b << endl;
	}
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
  int n;
  scanf("%d", &n);
  n %= 10;
  switch(n) {
    case 2:
    case 4:
    case 5:
    case 7:
    case 9: puts("hon"); break;
    case 0:
    case 1:
    case 6:
    case 8: puts("pon"); break;
    case 3: puts("bon"); break;
  }
  return 0;
}

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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int n,m; cin>>n>>m;
	vector<int>first;
	set<int>last;
	for(int i=0;i<m;++i){
		int a,b; cin>>a>>b;
		if(a==1)first.emplace_back(b);
		else if(b==1)first.emplace_back(a);
		if(a==n)last.insert(b);
		else if(b==n)last.insert(a);
	}
	bool yes=false;
	for(auto&i:first){
		if(i==n||*last.find(i)==i)yes=true;
	}
	cout<<(yes?"POSSIBLE"s:"IMPOSSIBLE"s)<<"\n"s;
}

Measured memory_bytes: 5368
#ABC126

s = input()
a = s[:2]
b = s[2:]
if 1 <= int(a) <= 12:
    if 1 <= int(b) <= 12:
        print("AMBIGUOUS")
    else:
        print("MMYY")
else:
    if 1 <= int(b) <= 12:
        print("YYMM")
    else:
        print("NA")

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

#define int				long long
#define FOR( i, m, n )	for( int (i) = (m); (i) < (n); (i)++ )
#define REP( i, n )		FOR( i, 0, n )
#define REPR( i, m )	for( int (i) = (m); (i) >= 0; (i)-- )
#define REPONE( i, n )	FOR( i, 1, n + 1 )
#define ALL( a )		(a).begin(), (a).end()
#define MP				make_pair

typedef pair<int, int> P;

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

const int INF = 1e9;
const int MOD = 1e9 + 7;

int dp[31];

signed main(){
	dp[0] = dp[1] = 1;
	dp[2] = 2;
	FOR( i, 3, 31 ) {
		dp[i] = dp[i - 1] + dp[i - 2] + dp[i - 3];
	}

	int n;
	while( cin >> n, n ) {
		cout << dp[n] / 10 / 365 + 1 << endl;
	}

}



Measured memory_bytes: 3064