akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
#include<utility>
#include<cstdio>
#include<set>
#include<string>
#include<map>
#include<queue>
#include<stack>
#include <bitset>
using namespace std;
const int mod=1e9+7;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,x,n) for (int i= x;i<n;i++)
#define all(v) v.begin(), v.end()
#define nepe(v) next_permutation(all(v))
#define F first 
#define S second
#define PB push_back 
#define MP make_pair
using ll = long long;
using vi = vector<int>; 
using vvi = vector<vi>;
using vp =vector<pair<int,int>>;

typedef pair<int,int> P;
string s;
int k;
ll INF = 10000000000000000;

int main(){
    int R,G,B,N;
    cin >>R>>G>>B>>N;
    int ans=0;
    rep(i,N/R+1){
        rep(j,(N-i*R)/G+1){
            if((N-i*R-j*G)%B==0) ans++;
        }
    }
    cout <<ans<<endl;
}

Measured memory_bytes: 256
n = int(input())
p = [list(map(int, input().split())) for i in range(n)]

dpa, dpb, dpc = [0]*(n+1), [0]*(n+1), [0]*(n+1)
dpa[0] = dpb[0] = dpc[0] = 0

for i in range(n):
    dpa[i + 1] = max(dpb[i] + p[i][0], dpc[i] + p[i][0])
    dpb[i + 1] = max(dpc[i] + p[i][1], dpa[i] + p[i][1])
    dpc[i + 1] = max(dpa[i] + p[i][2], dpb[i] + p[i][2])

print(max(dpa[n], dpb[n], dpc[n]))

Measured memory_bytes: 42156
Imports System.Collections.Generic
Imports System.Console

Module Program
    Sub Main()
        Dim X As String = NextString()
        Dim s_cnt, ans As Integer

        For Each v As Char In X
            Select Case v
                Case "S"c
                    s_cnt += 1
                Case "T"c
                    If s_cnt = 0 Then
                        ans += 1
                    Else
                        s_cnt -= 1
                    End If
            End Select
        Next

        ans += s_cnt
        WriteLine(ans)
    End Sub

    Function NextString() As String
        Dim result As New List(Of Char)
        Do
            Dim tmp As Integer = Read()
            If tmp < 0 Then Exit Do
            Dim nextChar As Char = Chr(tmp)

            If Not Char.IsWhiteSpace(nextChar) Then
                result.Add(nextChar)
            ElseIf nextChar <> vbCr Then
                Exit Do
            End If
        Loop
        Return New String(result.ToArray())
    End Function

End Module


Measured memory_bytes: 24284
#include <iostream>
#include <cstdio>
#include <vector>
using namespace std;
int n, k;
vector<int> v;
int memo[60][60][110];
int dp(int l,int r, int num)
{
    if(l>r||num<0)   return -1000000007;
    if(num==0)  return 0;
    if(l==r)  return memo[l][r][num]=max(v[l],0);
    if(memo[l][r][num]!=-100000000)  return memo[l][r][num];
    int x=-99999999,y=-99999999,z,t;
    if(v[l]<0) x=dp(l+1,r,num-2);
    if(v[r]<0) y=dp(l,r-1,num-2);
    z=dp(l+1,r,num-1)+v[l];
    t=dp(l,r-1,num-1)+v[r];
    return memo[l][r][num]= max(max(max(x,y),max(z,t)),0);
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    //freopen("inp","r",stdin);
    cin>>n>>k;
    v.resize(n);
    for(int i=0;i<=n;++i)
        for(int j=0;j<=n;++j)
            for(int x=0;x<=k;++x)  memo[i][j][x]=-100000000;
    for(int i=0;i<n;++i) cin>>v[i];
    printf("%d",dp(0,n-1,k));
    return 0;
}


Measured memory_bytes: 1536
#include<iostream>
using namespace std;
int n,t,a,h;
int main(){
  cin>>n>>t>>a;
  int ans=0;
  int ss=100000000;
  for(int i=1;i<=n;i++){
    cin>>h;
    int d=a*1000-t*1000+h*6;
    if(d<0)d=-d;
    if(ss>d){
      ss=d; ans=i;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#define N 50
#define MIN(a,b) ((a<b)?(a):(b))

int main(void){
        char work[N][N];
        int map[N][N];
        int n,m;
        int i,j;
        int dp[N][N];
        scanf("%d %d",&n,&m);
        for(i=0;i<n;i++){
                scanf("%s",work[i]);
                for(j=0;j<m;j++){
                        map[i][j]=work[i][j]-'0';
                        dp[i][j]=0;
                }
        }

        for(i=1;i<n;i++) dp[i][0]=map[i][0]+dp[i-1][0];
        for(i=1;i<m;i++) dp[0][i]=map[0][i]+dp[0][i-1];

        for(i=1;i<n;i++){
                for(j=1;j<m;j++){
                        dp[i][j]=MIN(dp[i-1][j],dp[i][j-1])+map[i][j];
                }
        }

        printf("%d\n",dp[n-1][m-1]);
        return 0;
}

Measured memory_bytes: 620
#include<stdio.h>
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;



int main(){

	int W,Q;int x,w;
	string str;
	while(1){
		int N[101]={};
		for(int i=0;i<101;i++)
			N[i]=999;


	cin>>W>>Q;if(W==0&&Q==0)break;
	for(int i=0;i<Q;i++){
		cin>>str;
		if(str=="s"){
		cin>>x>>w;bool f=false;
		for(int I=0;I<W;I++){int L=0;if(f==true)break;
			for(int J=I;J<W;J++)
				if(N[J]==999){L++;if(L==w){f=true;cout<<I<<endl;
					for(int j=I;j<I+w;j++)
						N[j]=x;
						L=0;break;	}
					}
				else{L=0;break;}
		}
		if(f==false)cout<<"impossible"<<endl;
		}
		else{
		cin>>x;
		for(int I=0;I<101;I++)
			if(N[I]==x)N[I]=999;
		
		
		}
		//for(int I=0;I<W;I++)
			//cout<<N[I]<<endl;
	}
	cout<<"END"<<endl;
	}
	return 0;
	}

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

using namespace std;

int main(void) {
  char X, Y; cin >> X >> Y;
  
  if (X < Y) {
    cout << "<" << endl;
  } else if (X > Y) {
    cout << ">" << endl;
  } else {
    cout << "=" << endl;
  }

  return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    static Scanner scanner = new Scanner(System.in);

    public static void main(String[]$) {
        int n = scanner.nextInt();
        int[] a = new int[n + 1];
        long sum1 = 0;
        for (int i = 0; i < n; i++) {
            a[i] = scanner.nextInt();
            sum1 += a[i];
        }
        a[n] = a[0];
        long[] d = new long[n];
        for (int i = 1; i < n; i++) {
            d[2 * i % n] = d[(2 * i - 2) % n] + (a[(2 * i - 1) % n] - a[(2 * i - 2) % n]) * 2;
        }
        long sum2 = 0;
        for (int i = 0; i < n; i++) {
            sum2 += d[i];
        }

        for (int i = 0; i < n; i++) {
            System.out.println(d[i] + (sum1 - sum2) / n);
        }
    }
}

Measured memory_bytes: 66980
#pragma GCC target("avx512f,avx512dq,avx512cd,avx512bw,avx512vl")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}

int main() {
	int n = ri();
	std::string s;
	std::cin >> s;
	int64_t res = 0;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < i; j++) {
			if (s[i] == s[j]) continue;
			res += j - std::count(s.begin(), s.begin() + j, s[i]);
			if (s[i] != s[j]) res -= std::count(s.begin(), s.begin() + j, s[j]);
			if (j + j - i >= 0 && (s[j + j - i] != s[i] && s[j + j - i] != s[j])) res--;
		}
	}
	printf("%" PRId64 "\n", res);
	return 0;
}


Measured memory_bytes: 3800
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
int main(void){
  int n;
  cin>>n;
  vector<ll> a(n),b(n),c(n);
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  for(int i=0;i<n;i++){
    cin>>b[i];
  }
  for(int i=0;i<n;i++){
    cin>>c[i];
  }
  sort(a.begin(),a.end());
  sort(c.begin(),c.end());
  ll ans=0;
  for(int i=0;i<n;i++){
    auto it=lower_bound(a.begin(),a.end(),b[i]);
    ll Adis=distance(a.begin(),it);
    it=upper_bound(c.begin(),c.end(),b[i]);
    ll Cdis=distance(it,c.end());
    ans+=(Adis*Cdis);
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 5580
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define vi vector<int>
#define ff first
#define ss second
#define file_se_input  freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define pp long long int
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define pb push_back
#define mp make_pair
#define pi 3.141592653589793238
#define eb emplace_back
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define zip(i,a,b) for(int i=a;i<b;i++)
#define rzip(i,a,b) for(int i=a;i>=b;i--)
#define ll unsigned long long int
#define test int t;cin>>t; while(t--)
#define um unordered_map
#define en '\n'
#define us unordered_set
typedef pair<int, int>     pii;
typedef pair<char, int>    pci;
typedef pair<char, char>   pcc;
typedef vector<pii>       vii;
typedef long double ld;
#define all(v) v.begin(), v.end()
#define INF (1e18+5)
#define inf (1e9+5)
#define mod 1000000007


bool check_prime(long long n)
{
	int flag = 0;
	for (long long i = 2; i * i <= n; i++)
	{
		if (n % i == 0)
		{
			flag = 1;
			break;
		}
	}
	if (n == 1)
		return false;
	else if (flag == 0 || n == 2 || n == 3)
	{
		return true;
	}
	else
	{
		return false;
	}

}

int BE(int x, int n, int m) //function to calculate x raise to power n modulo m
{
	int result = 1;
	while (n > 0)
	{
		if (n % 2 == 1)
			result = result * x % m;
		x = x * x % m;
		n = n / 2;
	}
	return result;
}

int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(0);
#ifndef ONLINE_JUDGE
	if (fopen("input.txt", "r"))
	{
		freopen ("input.txt" , "r" , stdin);
		freopen ("output.txt" , "w" , stdout);
	}
#endif
	//_______________________________-code starts-_______________________________________________

	int n, k;
	cin >> n >> k;
	double ans = 0 ;
	cout << fixed << setprecision(10);
	double x, y;
	int a;
	double p = 0;
	rep(i, 1, n)
	{
		//x = i;
		y = 1.0 / n;
		int now = i;
		while (now < k)
		{
			now *= 2;
			y /= 2;
		}
		ans += y;
	}
	cout << ans << en;



	return 0;
}



Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#define rep(i, n) for(int i = 0;i < n;i++)
#define repb(i, n) for(int i = n;i >= 0;i--)
#define reps(i, m, n) for(int i = m;i < n;i++)
#define repsb(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;

int total_day(int y,int m,int d){
	int day=0;

	for(int i=1; i < y; i++){
		for(int j=1; j<=10; j++){
			if(i%3==0||j%2==1) day+=20;
			else day+=19;
		}
	}
	for(int j=1; j < m; j++){
		if(y%3==0||j%2==1) day+=20;
		else day+=19;
	}
	day+=d;

	return day;
}
int main(){
	int n,a;
	cin>>n;
	int y[100],m[100],d[100];
	rep(i,n){
		cin>>y[i]>>m[i]>>d[i];
	}
	rep(i,n){
		a=total_day(1000,1,1)-total_day(y[i],m[i],d[i]);
		cout<<a<<endl;

	}

	return 0;
}


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

int main() {
  int N, K;
  cin >> N >> K;
  long long ans = 0;
  long long d = 0;
  for (int i = 1; i <= N; i++) {
    if (K % 2 == 0) {
      if (i % K == 0) ans++;
      else if (i % (K/2) == 0) d++;
    } else {
      if (i % K == 0) ans++;
    }
  }
  cout << ans * ans * ans + d * d * d << endl;
}


Measured memory_bytes: 256
using System;

class InOut
{
    int[, ,] univ = new int[4, 3, 10];
    public InOut(int n)
    {
        for (int i = 0; i < n; i++)
        {
            string[] s = Console.ReadLine().Split(' ');
            int building = int.Parse(s[0]);
            int floor = int.Parse(s[1]);
            int room = int.Parse(s[2]);
            int person = int.Parse(s[3]);
            inout(building,floor,room,person);
        }
    }
    public void inout(int build,int floor,int room,int person)
    {
        univ[build - 1, floor - 1, room - 1] += person;
    }
    public void GetResult()
    {
        for(int i=0;i<4;i++)
        {
            for(int j =0;j<3;j++)
            {
                for(int k=0;k<10;k++)
                {
                    Console.Write(" "+univ[i,j,k]);
                }
                Console.WriteLine("");
            }
            if(i!=3)
                Console.WriteLine(new string('#',20));
        }
    }
}
class Program
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        InOut io = new InOut(n);
        io.GetResult();
    }
}

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

int main() {
    int k, s;
    cin >> k >> s;

    int res = 0;
    for (int i = 0; i <= k; ++i)
        for (int j = 0; j <= k; ++j) {
            int x = s - i - j;
            if (0 <= x and x <= k) res++;
        }
    cout  << res << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define n 100005
ll mod=1e9+7;
vector<ll> adj[n];
ll N;
ll dp[n][2];
//0 -black and 1-white
void dfs(ll s,ll p)
{
	for(ll i=0;i<adj[s].size();i++)
	{
		ll v=adj[s][i];
		if (v!=p)
		{
			dfs(v,s);
		}
	}
	ll q=1;
	vector<ll> a[2];
	for(ll i=0;i<adj[s].size();i++)
	{
		ll v=adj[s][i];
		if (v!=p)
		{
			a[0].push_back(dp[v][0]);
			a[1].push_back(dp[v][1]);
			q*=dp[v][1];
			if (q>=mod)
				q%=mod;
		}
	}
	dp[s][0]=q;
	ll sz=adj[s].size();
	if ((sz==1 and s!=0) or (sz==0 and s==0))
	{
		dp[s][1]=1;
	}
	else
	{
		ll dp2[2][sz];
		memset(dp2,0,sizeof(dp2));
		dp2[0][0]=a[0][0];
		dp2[1][0]=a[1][0];
		for(ll i=1;i<a[0].size();i++)
		{
			dp2[0][i]+=dp2[0][i-1]*a[0][i];
			if (dp2[0][i]>=mod)
				dp2[0][i]%=mod;
			dp2[0][i]+=dp2[1][i-1]*a[0][i];
			if (dp2[0][i]>=mod)
				dp2[0][i]%=mod;

			dp2[1][i]+=dp2[0][i-1]*a[1][i];
			if (dp2[1][i]>=mod)
				dp2[1][i]%=mod;
			dp2[1][i]+=dp2[1][i-1]*a[1][i];
			if (dp2[1][i]>=mod)
				dp2[1][i]%=mod;
		}
		ll sz2=a[0].size();
		dp[s][1]=(dp2[0][sz2-1]+dp2[1][sz2-1])%mod;
	}
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>N;
	ll a,b;
	ll m=N-1;
	while(m--)
	{
		cin>>a>>b;
		a--;b--;
		adj[a].push_back(b);
		adj[b].push_back(a);
	}
	memset(dp,0,sizeof(dp));
	dfs(0,-1);
	cout<<(dp[0][0]+dp[0][1])%mod;
}

Measured memory_bytes: 21248
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n = I()
x = LI()
ans = inf
for i in range(101):
    s = 0
    for j in range(n):
        s += (i-x[j])**2
    ans = min(ans,s)
print(ans)

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

int main() {
	int N;
	cin >> N;
  	set<int> d;
    int nd;
  	for(int i = 0; i < N; i++) {
      cin >> nd;
      d.insert(nd);
    }
  cout << d.size() << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long int solve(vector<long long int> &v, vector<long long int> &dp, long long int i, long long int n)
{
    if(i==n-1)
    {
        return 0;
    }
    if(dp[i]!=-1)
    {
        return dp[i];
    }

    long long int one = INT_MAX;
    long long int two = INT_MAX;
    if(i+1<n)
    {
        one = solve(v,dp,i+1,n)+abs(v[i+1]-v[i]);
    }
    if(i+2<n)
    {
        two = solve(v,dp,i+2,n)+abs(v[i+2]-v[i]);
    }
    return dp[i] =  min(one,two);
}
int main() {	
    long long n,i,j;
    cin>>n;
    vector<long long int> a(n);
    for(long long int i=0;i<n;i++) {
        cin>>a[i];
    }
    
    vector<long long int> dp(n+1,-1);
    int ans = solve(a,dp,0,n);
    cout<<ans<<endl;	
	return 0;
}

Measured memory_bytes: 11148
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define inf 1000000000000000000
#define lli long long int
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    lli n;
    cin>>n;
    lli arr[n],dp[n];
    for(int i=0; i<n; i++)
        cin>>arr[i];
    dp[0]=0, dp[1]=abs(arr[1]-arr[0]);
    for(int i=2; i<n; i++)
        dp[i]=min(dp[i-1]+abs(arr[i]-arr[i-1]), dp[i-2]+abs(arr[i-2]-arr[i]));
    cout<<dp[n-1];
    return 0;
}

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

using namespace std;

const int maxn = 105;

int main() {

    int N[maxn];

    int num;

    cin >> num;

    for(int i=0; i<num; i++){

        cin >> N[i];

    }

    long mini = 1e9 + 8;

    for(int j= -100; j<101; j++){

        long sum = 0;

        for(int i=0; i<num; i++){

            sum += (j-N[i]) * (j-N[i]) ;

        }

        mini = min(mini,sum);

    }

    cout << mini << endl;

	return 0;
}


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

#define lint long long
#define P pair<int, int>
#define LLP pair<long long, long long>
#define REP(i, x, n) for(int i = (x), i##_len = (int)(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = (int)(n) ; i < i##_len ; ++i)
#define repr(i, n) for(int i = (int)(n) - 1 ; i >= 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())

const int IINF = 1e9 + 100;
const long long LLINF = 2e18 + 129;
const long long MOD = 1e9 + 7;
const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};
const double EPS = 1e-8;

void eratosthenes(int n, vector<bool> &isPrime){
    isPrime.resize(n + 1, true);
    for(int i = 0 ; i < 2 ; ++i){
        isPrime[i] = false;
    }
    for(int i = 2 ; i * i <= n ; ++i){
        if(isPrime[i]){
            for(int j = i ; i * j <= n ; ++j){
                isPrime[i * j] = false;
            }
        }
    }
    return;
}

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

    int n;
    cin >> n;

    vector<bool> isPrime;
    eratosthenes(n + 2, isPrime);

    lint ans = 0;
    REP(i, 3, n + 1){
        ans += (lint)(isPrime[i] && isPrime[i + 2]);
    }
    ans *= 2LL;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 4092
//k_tourist
#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long
#define mx 500005
#define non __builtin_popcount
#define ml map<ll, ll> 
#define uml unordered_map<ll, ll>
#define ms map<string , ll> 
#define all(a) (a).begin(),(a).end()
#define ff first
#define ss second
#define pl pair<ll, ll>
#define vl vector<ll>
#define vll vector<pl>
#define tpl pair<ll, pl>
#define vlll vector<tpl>
#define vs vector<string>
#define pb push_back
#define mk make_pair
#define M_PI 3.14159265358979323846
#define endl '\n'
#define fst ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define si(x) scanf("%d",&x)
#define sl(x) scanf("%I64d",&x)
#define inf ((ll)1e18 + 1)
#define bs binary_search
#define pq priority_queue
#define ub upper_bound
#define lb lower_bound
#define pow powr
#define rep(i,a,b)  for (i=(a);i<(b);i++)
#define nrep(i,a,b) for (i=(a);i>(b);i--)
using namespace std;
 
bool isp[mx];
 
void sv(){
 
	ll i,j;
	memset(isp, true, sizeof(isp));
	
	isp[1]= false;
	for(i=2;i*i<mx;i++){
		if(isp[i]){
			for(j=i*i;j<mx;j+=i)
			isp[j]= false;
		}
	}
}
 
ll powr(ll a,ll b)
{
	ll res=1;
	while(b)
	{
		if(b&1)res=(res*a)%mod;
		a=(a*a)%mod;
		b>>=1;
	}
	return res;
}

void bta_de_yarr(){
    
	string s, t;
    cin>>s>>t;
    cout<<t<<s;
	
	cout<<endl;
}

int main(){
    fst
	ll t;
    t= 1;
	//cin>>t;
    while(t--){
        bta_de_yarr();
    }
    return 0;
}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Measured memory_bytes: 256
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inpl(): return list(map(int, input().split()))
def inpl_s(): return list(input().split())

S = input()
S1 = S2 = S

S1 = S1.replace('dreamer','')
S1 = S1.replace('dream','')
S1 = S1.replace('eraser','')
S1 = S1.replace('erase','')

S2 = S2.replace('eraser','')
S2 = S2.replace('erase','')
S2 = S2.replace('dreamer','')
S2 = S2.replace('dream','')

if S1 == '' or S2 == '':
	print('YES')
else:
	print('NO')


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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
template<class T>bool chmin(T&a,const T&b){return a>b?(a=b,true):false;}
template<class T>bool chmax(T&a,const T&b){return a<b?(a=b,true):false;}

int nextInt() { int x; scanf("%d", &x); return x;}

int a[10010];
int t[101][101];

int main2() {
  int H = nextInt();
  int W = nextInt();
  int N = nextInt();
  REP(i, N) a[i] = nextInt();

  int color = 0;
  REP(h, H) REP(w, W) {
    t[h][w] = (color + 1);
    --a[color];
    if (a[color] == 0) color++;
  }
  REP(h, H) {
    if (h % 2 == 1) reverse(t[h], t[h] + W);
    REP(w, W) {
      if (w > 0) printf(" ");
      printf("%d", t[h][w]);
    }
    printf("\n");
  }

  return 0;
}

int main() {
  for (;!cin.eof();cin>>ws) main2();
  return 0;
}



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

using namespace std;

int main(){
    int n, m;
    cin >> n >> m;
    vector<vector<bool>> edge(n, vector<bool>(n, false));
    for(int i = 0; i < m; i++){
        int a, b;
        cin >> a >> b;
        edge[a - 1][b - 1] = edge[b - 1][a - 1] = true;
    }
    vector<int> move;
    for(int i = 1; i < n; i++){
        move.push_back(i);
    }
    int ans = 0;
    do{
        bool check = true;
        int now = 0;
        for(auto&& i : move){
            if(!edge[now][i]){
                check = false;
                break;
            }
            now = i;
        }
        ans += check;
    }while(next_permutation(begin(move), end(move)));
    cout << ans << "\n";
}

Measured memory_bytes: 256
# include <bits/stdc++.h>
# define ll long long
using namespace std;
const int N = 4e5 + 10, M = 2e7 + 100, mod = 1e9 + 7;
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    string s;
    cin >> s;
    if(s == "AAA" || s == "BBB"){
        cout << "No\n";
    }else{
        cout << "Yes\n";
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
typedef long long int ll;
#define pb         push_back
#define mp         make_pair
#define F          first
#define S          second
#define fl(i,a,b)  for(ll i=a;i<b;i++)
#define pll        pair<ll,ll>
#define pii        pair<int,int>
#define all(v)     v.begin(),v.end()
#define M          1000000321

using namespace std;
bool isPrime(ll n)
{
    if(n<=1)
        return false;
    if(n<=3)
        return true;
    if(n%2==0 || n%3==0)
        return false;

    for(ll i=5;i*i<=n;i=i+6)
        if(n%i==0|| n%(i+2)==0)
            return false;

    return true;
}

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

}

bool sortbydesc(const pair<ll,ll> &a, const pair<ll,ll> &b)
{
    if(a.S < b.S)
        return true;
    else
        return false;
}



int main()
{
 ios::sync_with_stdio(0);
 cin.tie(0);
 cout.tie(0);
 ll n,w;
 cin >> n >> w;
 vector<ll> we,v;
 ll a,b;
 we.pb(0);
 v.pb(0);
 fl(i,0,n)
 {
    cin >> a >> b;
    we.pb(a);
    v.pb(b);
 }
 ll dp[n+1][w+1];
 memset(dp,-1,sizeof(dp));
 dp[1][w]=0;
 if(w-we[1]>=0)
    dp[1][w-we[1]]=v[1];
 fl(i,2,n+1)
 {
    fl(j,0,w+1)
    {
        if(j-we[i]>=0 && dp[i-1][j]!=-1)
            dp[i][j-we[i]]=max(dp[i-1][j-we[i]],dp[i-1][j]+v[i]);
        dp[i][j]=max(dp[i][j],dp[i-1][j]);
    }
 }
 ll ans=0;
 fl(i,0,w+1)
    ans=max(ans,dp[n][i]);
cout << ans;
}

Measured memory_bytes: 79232
//

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// const int INF = 2147483647;
// const ll INF = 9223372036854775807;
// const ll MOD = 1e9 + 7;

int main(){
	double L;
	cin >> L;

	double ans = L * L * L / 27;

	cout << fixed << setprecision(10);
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <stdlib.h>
#include <cmath>
#include <cstdio>
#include <cstdint>
#include <string>
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
using namespace std;

int main(){
  long long N;
  cin >> N;
  set<string> S;
  string temp;
  for(int i=0;i<N;i++){
    cin >> temp;
    S.insert(temp);
  }

 cout << S.size() << endl;
  
  return 0;
}

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

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

Measured memory_bytes: 256
n, q = map(int, input().split())
s = input()
count = [0]*n
for i in range(1, n):
    count[i] = count[i-1]
    if s[i - 1: i + 1] == "AC":
        count[i] += 1

for i in range(q):
    l, r = map(int, input().split())
    print(count[r-1]-count[l-1])


Measured memory_bytes: 6140
#include<stdio.h>

long long abss(long long x){
	if(x < 0)
		return x*(-1);
	else
		return x;
}
int main(){
	long long  n,k;
	scanf("%lld %lld",&n,&k);
	
	n%= k;
	if(n > k-n)
		printf("%lld\n",k - n);
	else
		printf("%lld\n",n);
	
	return 0;
}

Measured memory_bytes: 1708
#include <bits/stdc++.h>
using namespace std;
#define forr(i, a, b) for(int i = (a); i < (int) (b); i++)
#define forn(i, n) forr(i, 0, n)
#define forall(it, v) for(auto it = v.begin(); it != v.end(); ++it)
#define dforn(i, n) for(int i = ((int) n) - 1; i >= 0; i--)
#define db(v) cerr << #v << " = " << v << endl
#define pb push_back
#define mp make_pair
#define sz(x) ((int)x.size())
#define ff first
#define ss second
typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
const int MAXN = 1000;


int n, m, ans;
vector<ii> T;
bool I[MAXN][MAXN];

bool pass[MAXN], col[MAXN];
bool bfs(int p){
//    printf("bfs en %d\n", p);
    queue<int> Q; Q.push(p);
    int B = 1, N = 0;
    pass[p] = true; col[p] = 0;
    while(Q.size()){
        int t = Q.front(); Q.pop();
//        printf("procesamos %d\n", t);
        forn(i, n)if( i != t && I[t][i]){
//            printf("  va a %d\n", i);
            if(pass[i] && (col[t] == col[i]))return true;
            if(!pass[i]){
//                printf("  metemos %d\n", i);
                pass[i] = true; col[i] = !col[t];
                if(col[i])N++; else B++;
                Q.push(i);
            }
        }
    }
//    db(B); db(N);
    T.pb({B, N});
    return false;
}

int H[MAXN], N[MAXN];
ll Knap(){
    forn(i, MAXN)H[i] = 0; H[0] = 1;
    forn(i, T.size()){
        forn(i, MAXN)N[i] = 0;
        int a = T[i].ff, b = T[i].ss;
        forn(i, MAXN)if(H[i]){
            N[i+a] = 1;
            N[i+b] = 1;
        }
        forn(i, MAXN)H[i] = N[i];
    }
    int ans = 0;
//    forn(i, n)if(H[i])printf("%d ", i);puts("");
    forn(i, MAXN){
        if(H[i] && abs(n/2-i) <= abs(n/2 - ans))ans = i;
    }
    return ans;
}

int main(){
//	freopen("input.txt", "r", stdin);
	while(scanf("%d %d", &n, &m) >= 1){
        forn(i, MAXN)forn(j, MAXN)I[i][j] = 1;
        forn(i, m){
            int u, v; scanf("%d %d", &u, &v);
            u--; v--;
            I[u][v] = I[v][u] = 0;
        }
//        forn(i, n){
//            forn(j, n)printf("%d ", I[i][j]);
//            puts("");
//        }puts("");
        T.clear(); bool shit = false;
        forn(i, MAXN)pass[i] = col[i] = 0;
        forn(i, n)if(!pass[i] && bfs(i)){
            shit = true; break;
        }
        if(shit){ printf("-1\n"); continue; }
        ll a = Knap(), b = n-a;
//        db(a); db(b);
        printf("%lld\n", a*(a-1)/2 + b*(b-1)/2);
    }
	return 0;
}


Measured memory_bytes: 1280
N, M, K = list(map(int, input().split()))
if K > N * M // 2: K = N * M - K
can = {k * (N - l) + l * (M - k) for k in range(M//2 + 1) for l in range(N//2 + 1)}
print("Yes") if K in can else print("No")

Measured memory_bytes: 11924
s = list(input())
flg = 'WA'
if s[0] == 'A':
    if 'C'in s[2:len(s)-1]:
        s.remove('A')
        s.remove('C')
        s = ''.join(s)
        if s.islower() == True:
            flg = 'AC'
print(flg)


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

int func(int x){
	if(x % 2 != 0) return 0;
	return func(x/2)+1;	
}

int main(){        
	int n;
	cin >> n;
	int ans = 1;
	for(int i = 1; i <= n; i++){
		if(func(i) >= func(ans))
			ans = i;	 	
	}

	cout << ans << endl;

	return 0;
}              

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;

#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }

typedef long long  ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
    ll N,T;
    ll t[200010];
    cin>>N>>T;
    for(int i=0;i<N;i++){
        cin>>t[i];
    }
    ll sum=t[N-1]+T;
    for(int i=0;i<N-1;i++){
        if(t[i]+T<=t[i+1]){
            sum-=t[i+1]-(t[i]+T);
        }
        
    }
    cout<<sum<<endl;

    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;

#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }

typedef long long  ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {

    int n, l;
    cin >> n >> l;
    ll sum = 0;
    for (int i = 0; i < n; i++)
    {
        sum += l + i;
    }
    ll m = abs(l);
    ll m2 = abs(l + n-1);
    if (l >= 0)
        cout << sum - l << endl;
    else if(l+n-1>=0){
        cout << sum << endl;
    }
    else{
        cout << sum -(l+n-1) << endl;
    }

    return 0;
}

Measured memory_bytes: 384
package main

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

const maxBuf = 200100

var debug = false

var buf []byte = make([]byte, maxBuf)
var sc = bufio.NewScanner(os.Stdin)

func init() {
	if debug {
		testFile, _ := os.Open("./test/sample-3.in")
		sc = bufio.NewScanner(testFile)
	}
	sc.Split(bufio.ScanWords)
	sc.Buffer(buf, maxBuf)
}

func readString() string {
	sc.Scan()
	return sc.Text()
}

func readInt() int {
	sc.Scan()
	r, _ := strconv.Atoi(sc.Text())
	return r
}

func readFloat64() float64 {
	sc.Scan()
	r, _ := strconv.ParseFloat(sc.Text(), 64)
	return r
}

/* #### main #### */
func main() {
	N := readInt()
	A := readInt()
	B := readInt()

	S := readString()

	ans := make([]string, N)
	kakutei := 0
	kaigai := 0
	for i, person := range S {
		switch string(person) {
		case "a":
			if kakutei < A+B {
				ans[i] = "Yes"
				kakutei++
			} else {
				ans[i] = "No"
			}
		case "b":
			if kakutei < A+B && kaigai < B {
				ans[i] = "Yes"
				kakutei++
				kaigai++
			} else {
				ans[i] = "No"
			}
		case "c":
			ans[i] = "No"
		}
	}

	for _, v := range ans {
		fmt.Println(v)
	}

}


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

//#define debug(...)   printf( __VA_ARGS__ )
#define debug(...)   /****nothing****/

#define ll long long
#define ull unsigned long long
#define pb push_back
#define mem(arr,val)    memset(arr,val,sizeof(arr))
#define mp make_pair
#define pii pair<int,int>
#define F first
#define S second
#define sz(x) (int)(x).size()
#define nopos string::npos
#define fr(i,a,b) for(i=a;i<=b;i++)
#define frn(i,a,b) for(i=a;i>=b;i--)
#define MX 200007
int ans[MX],leftt[MX],rightt[MX],i,j,k,n,ar[MX],t;

int main()
{
    while(scanf("%d",&n)==1)
    {
        stack<int> stk;

        ll sum=0;

        fr(i,0,n-1)
         scanf("%d",ar+i) ,  rightt[i]=n , leftt[i]=-1 , ans[i+1]=0 , sum+=ar[i];

        fr(i,0,n-1)
         {
             while(!stk.empty() && ar[stk.top()]>ar[i])
                rightt[stk.top()]=i , stk.pop();

             stk.push(i);
         }

         while(!stk.empty())
            stk.pop();

        fr(i,0,n-1)
         debug("%d ",rightt[i]);

        debug("\n");

        frn(i,n-1,0)
         {
             while(!stk.empty() && ar[stk.top()]>ar[i])
                leftt[stk.top()]=i , stk.pop();

             stk.push(i);
         }

        while(!stk.empty())
            stk.pop();

        fr(i,0,n-1)
         debug("%d ",leftt[i]);

        debug("\n");

        fr(i,0,n-1)
         {
             ll len=((i-leftt[i]-1)+1LL*(i-leftt[i])*(rightt[i]-i-1));
             debug("left=%d right=%d\n",(i-leftt[i]-1),(rightt[i]-i-1));
             sum+=len*ar[i];
         }

        printf("%lld\n",sum);

    }



    return 0;
}






Measured memory_bytes: 4224
#include <stdio.h>

int main(void){

    int L = 0;
    double d_L = 0.0;

    scanf("%d", &L);

    d_L = (double)L / 3.0;

    d_L = d_L * d_L * d_L;

    printf("%lf\n", d_L);

    return 0;
}

Measured memory_bytes: 128
def pintarr(arr):
    arr = [str(c) for c in arr]
    print(' '.join(arr))


def bub_sort(it, key):
    count = 0
    for start_ind in range(len(it)):
        for target_ind in range(len(it)-1, start_ind, -1):
            if it[target_ind] < it[target_ind-1]:
                it[target_ind], it[target_ind-1] = it[target_ind-1], it[target_ind],
                count += 1
    pintarr(it)
    print(count)


if __name__ == '__main__':

    t = int(input())
    a = input()
    a = [int(c) for c in a.split(' ')]
    bub_sort(a, t)



Measured memory_bytes: 5604
#include<stdio.h>
#include<string.h>
#define N 1001
int main()
{
  int n,i,j;
  char sum[N],num[N];
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%s",sum);
    scanf("%s",num);
    printf("%d\n",xu(sum,num));
  }
  return 0;
}

int xu(char *S,char *A)
{
  int c[N][N],i,j,a,b;
  a=strlen(S)+1;
  b=strlen(A)+1;
  for(i=1;i<a;i++)c[0][i]=0;
  for(i=0;i<b;i++)c[i][0]=0;
  
  for(i=1;i<a;i++){
    for(j=1;j<b;j++){
      if(S[i-1]==A[j-1])c[i][j]=c[i-1][j-1]+1;
      else if(c[i-1][j]>=c[i][j-1])c[i][j]=c[i-1][j];
      else c[i][j]=c[i][j-1];
    }
  }
  return c[a-1][b-1];
}



Measured memory_bytes: 5716
n = input()
v = [n.lower() for n in n.split()]

stack = []
idx = 0
loop_cnt = 0

for num in v:
    try:
        if int(num):
            stack.append(num)
    except:
        if num == "+":
            calc = int(stack[idx - 2]) + int(stack[idx - 1])
        elif num == "-":
            calc = int(stack[idx - 2]) - int(stack[idx - 1])
        elif num == "*":
            calc = int(stack[idx - 2]) * int(stack[idx - 1])

        for i in range(0,2):
            stack.pop(idx - 1)
        stack.append(calc)
        idx = 0
        loop_cnt = 0

print(stack[0])






Measured memory_bytes: 5604
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s,t;
    cin>>s>>t;
    int a,b;
    cin>>a>>b;
    map<string,int>mp;
    mp[s] = a;
    mp[t] = b;
    string u;
    cin>>u;
    mp[u]--;
    cout<<mp[s]<<" "<<mp[t]<<endl;
}


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

int main()
{
  int n, yes = 0;
  string s;
  cin >> n >> s;
  if (n % 2 == 0 && s.substr(0, n / 2) == s.substr(n / 2, n / 2))
    yes = 1;
  cout << (yes ? "Yes" : "No") << endl;
}

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

ret = [0] * (n-1)
for i in range(1, n):
    for j in range(i+1, n+1):
        p1 = j-i
        p2 = abs(i - x) + 1 + abs(j - y)
        p3 = abs(i - y) + 1 + abs(j - x)
        if p1 > p2:
            p1 = p2
        if p1 > p3:
            p1 = p3
        ret[p1-1] += 1

for data in ret:
    print(data)


Measured memory_bytes: 3444
#include <bits/stdc++.h>
#include <iomanip> 
using namespace std; 
#define rep(i,a,b)		for(long int i=a;i<=b;i++)
#define MOD 1e9+7

int ds(int n)
{
	int ans =0;
	while(n)
		ans+=n%10,n/=10;
	return ans;
}

int n;
int main() 
{ 
	ios::sync_with_stdio(false);
    cin.tie(NULL);  
    
	cin>>n;
	if(n%(ds(n))==0)
		cout<<"Yes";
	else
		cout<<"No";
}
	

Measured memory_bytes: 3628
/*
有这么一种不关心紫色格子具体是哪些的构造思路：
首先把网格图中每个格子填上红色或蓝色，使得红色格子和蓝色格子分别四联通
同时需要满足条件，对于红色格子，把任意多个（不在边界上的）蓝色格子换成红色格子后，红色格子仍然四联通；对于蓝色格子同理
那么可以考虑这么构造：对于奇数行，最后一个格子是蓝色格子，其余是红色格子；对于偶数行，第一个格子是红色格子，其余是蓝色格子。如下图所示 
RRRRRRRRB
RBBBBBBBB
RRRRRRRRB
RBBBBBBBB
RRRRRRRRB
容易发现，不论把哪个（不在边界上的）蓝色格子换成红色格子，红色格子都仍然联通；对于蓝色格子同理
所以在两个图中把紫色格子强制染上对应的颜色，就是一个合法的方案 
*/ 

#include <cstdio>

using namespace std;
const int Max_HW(505);

int H, W;
char input[Max_HW], R[Max_HW][Max_HW], B[Max_HW][Max_HW];

int main()
{
	scanf("%d%d", &H, &W);
	for (int i = 1;i <= H;++i)
	{
		scanf("%s", input + 1);
		for (int j = 1;j <= W;++j)
		{
			R[i][j] = B[i][j] = '.';
			if (input[j] == '#')
				R[i][j] = B[i][j] = '#';
			if (i & 1)
				if (j == W)
					B[i][j] = '#';
				else
					R[i][j] = '#';
			else
				if (j == 1)
					R[i][j] = '#';
				else
					B[i][j] = '#';
		}
	}
	for (int i = 1;i <= H;++i)
		printf("%s\n", R[i] + 1);
	printf("\n");
	for (int i = 1;i <= H;++i)
		printf("%s\n", B[i] + 1);
	return 0;
}

Measured memory_bytes: 1152
#include<iostream>
#include<cmath>
using namespace std;
const int MAX_N = (1 << 16);

bool square[MAX_N] = {false};

int main(){
    for(int i = 1; i * i < MAX_N; i++){
        square[i * i] = true;
    }
    int n;
    while(cin >>n){
        if(n == 0) break;

        int cnt = 0, tmp;

        for(int i = 0; ; i++){
            tmp = n - (i * i);
            if(tmp < i * i) break;

            for(int j = i; ; j++){
                tmp = n - (i * i + j * j);
                if(tmp < j * j) break;

                for(int k = j; ; k++){
                    int tmp = n - (i * i + j * j + k * k);
                    if(tmp < k * k) break;

                    if(square[tmp]) cnt++;
                }
            }
        }
        cout <<cnt <<endl;
    }
    return 0;
}

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

using namespace std;

#define int long long

#define rep(i,x) for(int i=0;i<x;++i)
#define all(a) begin(a),end(a)
#define PB push_back

int P[1010];

signed main()
{
    int N, M;
    
    while (cin >> N >> M, N) {
        rep(i, N) {
            cin >> P[i];
        }

        vector<int> arr;

        rep(i, N) {
            arr.PB(P[i]);

            rep(j, i+1) arr.PB(P[i] + P[j]);
        }

        arr.PB(0);
        sort(all(arr));

        int ma = 0;

        rep(i, arr.size()) {
            int a = arr[i];
            int b = *(lower_bound(all(arr), M - a + 1) - 1);
            if (a + b <= M) ma = max(ma, a + b);
        }

        cout << ma << endl;
    }
}

Measured memory_bytes: 10652
import math

nsum = 0 
naverage = 0 
i = 0 
while True:
    try:

        price,num = map(int,raw_input().split(","))
        nsum += num*price
        naverage += num 
        i += 1

    except EOFError:
        break

print nsum
print int(round(float(naverage)/float(i)))               

Measured memory_bytes: 4380
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;

int	main()
{
	int	n;
	cin >> n;
	Graph	graph(n);
	int	u;
	for (int i = 0; i < n; ++i) {
		int	k, v;
		cin >> u >> k;
		--u;
		for (int j = 0; j < k; ++j) {
			cin >> v;
			--v;
			graph.at(u).push_back(v);
		}
	}
	vector<int>	cost(n, -1);
	queue<int>	que;
	cost.at(0) = 0;
	que.push(0);
	int	cost_u;
	while (!que.empty()) {
		u = que.front();
		que.pop();
		cost_u = cost.at(u);
		for (int v : graph.at(u)) {
			if (cost.at(v) != -1) continue;
			cost.at(v) = cost_u + 1;
			que.push(v);
		}
	}
	for (int i = 0; i < n; ++i) {
		cout << i + 1 << " " << cost.at(i) << endl;
	}
}





Measured memory_bytes: 3104
#!/usr/bin/env python
# -*- coding: utf-8 -*-

NX = input()
N = int(NX.split(' ')[0])
X = int(NX.split(' ')[1])

L = map(int, input().split(' '))
cnt = 0
result = 1
for i in L:
    cnt += i
    if cnt <= X:
        result += 1

print(result)

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

int main()
{
    string a,b,c;
    int j=0;
    cin>>a;
    cin>>b;
    for(int i=0; i<b.size()-1; i++)
    {
        c+=b[i];

    }
    if(a==c)
        cout<<"Yes"<<endl;
    else    cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 3600
const input=require('fs').readFileSync('/dev/stdin', 'utf8').split(/[\s]/);const nin=()=>{const r = input[0];input.shift();return Number(r)};const nrin=(n)=>{const a:number[]=[];rep(n,()=>a.push(nin()));return a};const sin=()=>{const r = input[0];input.shift();return String(r)};const out=(...a)=>{console.log(...a)};const floor=(a)=>{return Math.floor(a)};const abs=(a)=>{return Math.abs(a)};const min=(...a)=>{return Math.min(...a)};const max=(...a)=>{return Math.max(...a)};const rep=(n, callback)=>{for(let i = 0;i < n; i++){callback()}};const strrep=(s, i, v)=>{return s.slice(0, i)+v+s.slice(i+1);};const permutation=({result=[],pre=[],post,n=post.length})=>{if(n>0){post.forEach((_,i)=>{const rest=[...post];const elem=rest.splice(i, 1);permutation({result, pre: [...pre,...elem],post:rest,n:n-1})})}else{result.push(pre)}return result};const sw=(s,a:any[],op:'=='|'>='|'>'|'<='|'<'='==')=>{for(let i=0;i<a.length;i+=2){if(op==='=='){if(s==a[i])return a[i+1]}else if(op==='>='){if(s>=a[i])return a[i+1]}else if(op==='<='){if(s<=a[i])return a[i+1]}else if(op==='>'){if(s>a[i])return a[i+1]}else if(op==='<'){if(s<a[i])return a[i+1]}}return a[a.length-1];};const or=(a,...b)=>{for(let i=0;i<b.length;i++)if(a==b[i])return true;return false};const maxindex=(...a)=>{return a.indexOf(Math.max.apply(null,a))};const asc=(ar:number[])=>{return ar.sort((a,b)=>{return a-b})};const desc=(ar:number[])=>{return ar.sort((a,b)=>{return b-a})};const ceil=a=>{return Math.ceil(a)};const srin=s=>{const a:string[]=[];rep(s,()=>a.push(sin()));return a};let ssinteger=-1;const ssin=()=>{ssinteger++;return input[0][ssinteger]};
const main = ()=>{
  let[a,b,c]=srin(3)
  out(a[0]+b[0]+c[0])
}
main()

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

if len(str(n))==1:
  print(n)
elif len(str(n))==2:
  print(9)
elif len(str(n))==3:
  print(n - 90)
elif len(str(n))==4:
  print(909)
elif len(str(n))==5:
  print(n - 9090)
else:
  print(90909)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long n,a[1000],ans1=0,ans2=1000000;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  for(int j=-100;j<=100;j++){
    for(int i=0;i<n;i++){
      ans1+=(a[i]-j)*(a[i]-j);
    }
    if(ans2>ans1){
      ans2=ans1;
    }
    ans1=0;
  }
  cout<<ans2<<endl;
  return(0);
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int sort[3] = {0, 0, 0};
	int i;
	int temp;
	
	for(i = 0; i < 10; i++){
		scanf("%d", &temp);
		if(temp > sort[0]){
			sort[2] = sort[1];
			sort[1] = sort[0];
			sort[0] = temp;
		}
		else if(temp> sort[1]){
			sort[2] = sort[1];
			sort[1] = temp;
		}
		else if(temp> sort[2]){
			sort[2] = temp;
		}
	}
	printf("%d\n%d\n%d\n", sort[0], sort[1], sort[2]);
	
	return 0;
	
}

Measured memory_bytes: 1028
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;

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

const ll INF=1e15;

int main(){
    ll a,b,h;
    cin >>a >> b >> h;
    cout << (a+b)*h/2 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

// useage : swap(&int1,&int2);
// 値入れ替え
int swap(int *c1,int *c2){
  int tmp;
  tmp=*c1;
  *c1=*c2;
  *c2=tmp;
  return 0;
}

int main(void) {
 
  // 入力
  int n;
  scanf("%d",&n);
  int list[n];
  for(int i=0;i<n;i++){
    scanf("%d",&list[i]);
  }
  
  for(int i=1;i<n;i++){
      if(list[i-1]>list[i]){
        int j = i-1;
        while(i<n-1){
          if(list[i]>list[i+1]){
            swap(&list[i+1],&list[j]);
            break;
          }
          i+=1;
        }
        break;
      }
  }
  
  int flg=1;
  for(int i=1;i<n;i++){
    if(list[i-1]>list[i]){
      flg=0;
      break;
    }
  }
  
  if(flg==1)printf("YES\n");
  else      printf("NO\n");

  return 0;
}

Measured memory_bytes: 128
/*
AuThOr GaRyMr
*/
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;++a)
#define rl(a,b,c) for(int a=b;a>=c;--a)
#define LL long long
#define IT iterator
#define PB push_back
#define II(a,b) make_pair(a,b)
#define FIR first
#define SEC second
#define FREO freopen("check.out","w",stdout)
#define rep(a,b) for(int a=0;a<b;++a)
#define KEEP while(1)
#define SRAND mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define random(a) rng()%a
#define ALL(a) a.begin(),a.end()
#define POB pop_back
#define ff fflush(stdout)
#define fastio ios::sync_with_stdio(false)
using namespace std;
const int INF=0x3f3f3f3f;
typedef pair<int,int> mp;
typedef pair<mp,mp> superpair;
vector<string> res; 
int n;
void dfs(string s,char las){
	if(s.length()==n){
		res.PB(s);
		return;
	}
	for(char c='a';c<=las+1;c++){
		dfs(s+c,max(c,las));
	}
}
int main(){
	fastio;
	cin>>n;
	sort(ALL(res));
	dfs("",char('a'-1));
	for(string it:res){
		cout<<it<<endl;
	} 
	return 0;
}


Measured memory_bytes: 7796