akhauriyash/Code-Regression huggingface dataset:
import std.stdio;
import std.conv, std.array, std.algorithm, std.string;
import std.math, std.random, std.range, std.datetime;
import std.bigint;
import std.container;
string read(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }

long r, c, n;
void main(){
	r = read.to!long;
	c = read.to!long;
	n = read.to!long;
	
	// debug writeln([pos(0, 0), pos(0, 1), pos(0, c - 1), pos(0, c), pos(1, c), pos(r - 1, c), pos(r, c), pos(r, c - 1), pos(r, 1), pos(r, 0), pos(r - 1, 0), pos(1, 0)]);
	
	long[long] uset;
	foreach(i; 0 .. n){
		long x1 = read.to!long;
		long y1 = read.to!long;
		long x2 = read.to!long;
		long y2 = read.to!long;
		
		if(!isOnEdge(x1, y1) || !isOnEdge(x2, y2)) continue;
		
		uset[pos(x1, y1)] = i;
		uset[pos(x2, y2)] = i;
		}
	debug uset.writeln;
	
	long[] ks = uset.keys.dup;
	ks.sort();
	
	long[] us = ks.map!(k => uset[k]).array;
	debug us.writeln;
	
	auto sta = new long[](ks.length);
	int j = -1;
	foreach(u; us){
		if(j < 0 || sta[j] != u) j += 1, sta[j] = u;
		else j -= 1;
		}
	
	string ans = (j >= 0)? "NO": "YES";
	
	ans.writeln;
	
	}

long pos(long x, long y){
	if(x == 0) return y;
	if(y == c) return c + x;
	if(x == r) return c + r + c - y;
	if(y == 0) return c + r + c + r - x;
	return 0;
	}

bool isOnEdge(long x, long y){
	return x == 0 || y == c || x == r || y == 0;
	}

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

#define INF (1 << 30)
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define out(x) cout << x << endl;
#define all(x) (x).begin(),(x).end()
typedef long long ll;
using namespace std;

int main(){
    int h, w;
    cin >> h >> w;
    string s[h];
    int dy[] = {1,1,1,0,0,-1,-1,-1};
    int dx[] = {-1,0,1,-1,1,-1,0,1};
    char mat[h+2][w+2];
    int ans[h][w];
    rep(i, h+2){
        rep(j, w+2){
            mat[i][j] = 'y';
        }
    }
    rep(i, h){
        rep(j, w){
            ans[i][j] = 0;
        }
    }
    rep(i, h){
        cin >> s[i];
        rep(j, s[i].length()){
            mat[i+1][j+1] = s[i][j];
        }
    }
    rep(i, h){
        rep(j, w){
            rep(k, 8){
                if(mat[i+1+dy[k]][j+1+dx[k]] == '#'){
                    ans[i][j]++;
                }
            }
        }
    }
    rep(i, h){
        rep(j, w){
            if(mat[i+1][j+1] == '.'){
                cout << ans[i][j];
            }else{
                cout << '#';
            }
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define ph push
#define ptc putchar
#define enter putchar('\n')
using namespace std;
typedef pair<int,int> pii;
typedef double db;
typedef long double ldb;
typedef long long ll;
typedef long long lnt;
inline int read(){
	int x = 0;char c = getchar();
	while (!isdigit(c)) c = getchar();
	while (isdigit(c)) x = (x << 1) + (x << 3) + c - '0' , c = getchar();
	return x;
}
inline void write(int x){
	if (!x){
       ptc('0');
       return;
	}
	int dg[20] , len = 0;
	while (x) dg[len++] = x % 10 , x /= 10;
	while (len--) ptc(dg[len]+'0');
}
inline void writeln(int x){
	write(x);
	ptc('\n');
}

const int N = 2e5 + 10;
int n , k ;

struct permutation{
	int a[N];
	inline int& operator [] (int x){return a[x];}
};

inline permutation operator * (permutation A,permutation B) {
	permutation C;
	for (int i = 1;i <= n;i++){
		C[i] = A[B[i]];
	}
	return C;
}

inline permutation operator ^ (permutation A,int y) {
	permutation C;
	for (int i = 1;i <= n;i++) C[i] = i;
	while (y){
		if (y & 1) C = C * A;
		A = A * A;y >>= 1;
	}
	return C;
}

inline permutation inv(permutation A){
	permutation B;
	for (int i = 1;i <= n;i++){
		B[A[i]] = i;
	}
	return B;
}

void Print(permutation x){
    for(int i=1;i<=n;i++)
        printf("%d ",x.a[i]);
    puts("");
}

permutation p , q , ip , iq , A , B , ans;
int main(){
	scanf("%d%d",&n,&k);
	for (int i = 1;i <= n;i++){
		scanf("%d",&p[i]);
	}
	for (int i = 1;i <= n;i++){
		scanf("%d",&q[i]);
	}
	
	ip = inv(p) , iq = inv(q);
	
	
    int f = (k - 1) / 6 , g = k - f * 6;
    permutation h = q * ip * iq * p;
    A = h ^ f;
    
	if(g == 1){
        B = p;
    }else 
	if(g == 2){
        B = q;
    }else 
	if(g == 3){
        B = q * ip;
    }else 
	if(g == 4){
        A = A * q;
        B = ip;
    }else 
	if(g == 5){
        A = A * q * ip;
        B = iq;
    }else{
        A = A * q * ip;
        B = iq * p;
    }
    
    ans = A * B * inv(A);
    Print(ans);
	return 0;
}

Measured memory_bytes: 38016
#ライブラリインポート
from collections import defaultdict

con = 10 ** 9 + 7
#入力受け取り
def getlist():
	return list(map(int, input().split()))

#処理内容
def main():
	a, b, c = getlist()
	if c - a - b > 0 and (c - a - b) ** 2 - 4 * a * b > 0:
		print("Yes")
	else:
		print("No")


if __name__ == '__main__':
	main()

Measured memory_bytes: 38384
n,a,b,c,d=map(int,input().split())
s=input()
if c<d:
    for i in range(a,d-2):
        if s[i]=="#" and s[i+1]=="#":
            print("No")
            exit()
    print("Yes")
else:
    for i in range(a,c-2):
        if s[i]=="#" and s[i+1]=="#":
            print("No")
            exit()
    i=b-2
    temp=0
    while i<=d:
        if s[i]==".": temp+=1
        else: temp=0
        if temp==3:
            print("Yes")
            exit()
        i+=1
    print("No")

Measured memory_bytes: 9496
import itertools
n = int(input())
p = tuple(int(x) for x in input().split())
q = tuple(int(x) for x in input().split())

pn = 0
qn = 0

a = list(itertools.permutations(range(1, n+1)))
# print(a)

ans = abs(a.index(p) - a.index(q))
print(ans)


Measured memory_bytes: 13720
def resolve():
    """ recursive function"""

    def func(i, sum, cnt, rem):
        nonlocal ans
        if i == D:
            if sum < G:
                use = max(rem)
                n = min(lst[use - 1][0], -(-(G - sum) // ((use) * 100)))
                sum += n * use * 100
                cnt += n
            if sum >= G:
                ans = min(ans, cnt)
        else:
            func(i + 1, sum, cnt, rem)
            func(
                i + 1,
                sum + lst[i][0] * (i + 1) * 100 + lst[i][1],
                cnt + lst[i][0],
                rem - {i + 1})

    D, G = map(int, input().split())
    lst = [list(map(int, input().split())) for x in range(D)]
    ans = float('inf')

    func(0, 0, 0, set(range(1, D + 1)))
    print(ans)

if __name__ == "__main__":
    resolve()

Measured memory_bytes: 9148
#include "bits/stdc++.h"
//#include <atcoder/all>

using namespace std;
//using namespace atcoder;

#define int long long
#define ll long long

ll INF = (1LL << 60);

signed main() {
	int a, b, c, d; cin >> a >> b >> c >> d;
	ll ans = max({ a*c,a*d,b*c,b*d });
	if (a <= 0 && 0 <= b)ans = max(ans, 0LL);
	if (c <= 0 && 0 <= d)ans = max(ans, 0LL);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <cmath>
#include <iomanip>

using namespace std;

int main() {
    ios::sync_with_stdio(false);

    int n;
    cin >> n;
    int x[n], y[n];
    for (int i = 0; i < n; i++) {
        cin >> x[i] >> y[i];
    }

    double tot = 0;
    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            tot += sqrt(pow(x[i] - x[j], 2) + pow(y[i] - y[j], 2));
        }
    }
    tot = tot * 2 / n;

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

    return 0;
}


Measured memory_bytes: 256
n, a = map(int, input().split())
x = list(map(lambda x: int(x) - a, input().split()))
dp = [[0 for j in range(100 * n + 1)] for i in range(n + 1)]
dp[0][50 * n] = 1
for i in range(n):
    for j in range(50, 100 * n + 1 - 50):
        dp[i + 1][j] = dp[i][j] + dp[i][j - x[i]]
print(dp[n][50 * n] - 1)


Measured memory_bytes: 5748
#include<bits/stdc++.h>
#include<string>
#define pii pair<int,int>
#define fr(j,n) for(int j=0;j<n;j++)
#define f(n) for(int i=0;i<n;i++)
#define rt return 0;
#define sc second
#define fi first
#define i(n) int n;cin>>n;
#define pb(i) push_back(i);
#define rt return 0;
#define sz(v) v.size()
#define allv v.begin(),v.end()
#define ff(i,in,fi) for(int i=in;i<fi;i++)
//#define df int n;cin>>n;int a[n];fr(n){cin>>a[i];}5 8 7 14 55 19 9 2
using namespace std;
#define trav(a, x) for(auto& a : x)
#define display(x) trav(a,x) cout<<a<<" ";cout<<endl
#define invect(data,n,commands) for(int xxx = 0;xxx<n;xxx++){int tmp;cin>>tmp;data.pb(tmp);commands}
#define ll long long int
#define p(s) cout<<#s<<":"<<s<<'\n';
#define here(n) cout<<"here"<<n<<endl;
#define ios         ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    std::cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
std::vector<int> v[1006];
int n;
int check()
{
	ff(i,1,n+1)
	{
		if(sz(v[i]))
		{
			return 1;
		}
	}
	return 0;
}
int main()
{
	ios;
	cin>>n;
	f(n)
	{
		int a;
		fr(j,n-1)
		{
			cin>>a;
			v[i+1].pb(a);
		}
	}
	int days=0;
	int vis[n+1];
	while(check())
	{
		f(n+1)
		vis[i]=0;
		int flag=0;
		ff(i,1,n+1)
		{
			if(i==v[v[i][0]][0]&&vis[i]==0&&vis[v[i][0]]==0&&v[i].size()&&v[v[i][0]].size())
			{
				flag=1;		
				vis[i]=1;
				vis[v[i][0]]=1;
				v[v[i][0]].erase(v[v[i][0]].begin());
				v[i].erase(v[i].begin());
			}
		}
		days++;
		if(flag==0)
		{
			cout<<-1;
			rt;
		}
	}
	cout<<days;
}


Measured memory_bytes: 6400
N, W = map(int, input().split())
w = [0]
v = [0]
for _ in range(N):
    x, y = map(int, input().split())
    w.append(x)
    v.append(y)

dp = [[0 for _ in range(10**5 + 1)] for _ in range(N+1)]
for i in range(1, 10**5 + 1):
    dp[0][i] = float('inf')

for i in range(1, N+1):
    for j in range(10**5 + 1):
        dp[i][j] = dp[i-1][j]
        if j - v[i] >= 0:
            dp[i][j] = min(dp[i][j], dp[i-1][j-v[i]] + w[i])

ans = 0
for k in range(10**5 + 1):
    if dp[N][k] <= W:
        ans = max(ans, k)

print(ans)

Measured memory_bytes: 323664
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
const int maxn=100100;
int n,a[maxn],c[3];
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	for(int i=1;i<=n;i++)
	{
		int tmp=0;
		while(a[i]%2==0&&tmp<2)
		{
			a[i]/=2;
			tmp++;
		}
		c[tmp]++;
	}
	int last=2;
	for(int i=1;i<=n;i++)
	{	
		bool pd=0;
		for(int j=2-last;j<=2;j++)
			if(c[j]>0)
			{
				pd=1;
				c[j]--;
				last=j;
				break;
			}
		if(pd==0) {puts("No");exit(0);}	
	}	
	puts("Yes");
	return 0;
	
} 

Measured memory_bytes: 640
n = int(input())
a = list(map(int, input().split()))

a = list(enumerate(a))
a.sort(key = lambda x: x[1])

DP = [[0 for i in range(n+1)] for j in range(n+1)]
DP[0][0] = 0
for i in range(1, n+1):
    pos, val = a.pop()
    pos = pos + 1

    DP[0][i] = DP[0][i-1] + abs(val * (n - i + 1 - pos))
    DP[i][0] = DP[i-1][0] + abs(val * (pos - i))
    for x in range(1, i):
        y = i - x
        DP[x][y] = max(DP[x-1][y] + abs(val * (pos - x)),  \
            DP[x][y-1] + abs(val * (n - y + 1 - pos)))

ans = 0
for i in range(n+1):
    ans = max(ans, DP[i][n-i])

print(ans) 

Measured memory_bytes: 136900
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
#define ll long long
#define mx 2000000
//#define mod 1000000007
#define max(x,y) ((x)>(y)?(x):(y))
#define min(x,y) ((x)<(y)?(x):(y))
#define fur(i,x,y) for(i=x;i<=y;i++)
#define fdr(i,x,y) for(i=x;i>=y;i--)
#define Fur(i,x,y) for(ll i=x;i<=y;i++)
#define Fdr(x,y) for(ll i=x;i>=y;i--)
#define in2(x,y) in(x);in(y)
#define in3(x,y,z) in2(x,y);in(z)
#define in4(a,b,c,d) in2(a,b);in2(c,d)
#define clr(x,y) memset(x,y,sizeof(x))
#define cpy(x,y) memcpy(x,y,sizeof(x))
using namespace std;
/*---------------------------------------*/
namespace fib{char b[300000]= {},*f=b;}
#define gc ((*fib::f)?(*(fib ::f++)):(fgets(fib::b,sizeof(fib::b),stdin)?(fib::f=fib::b,*(fib::f++)):-1))
inline void in(ll &x){x=0;char c;bool f=0;while((c=gc)>'9'||c<'0')if(c=='-')f=!f;x=c-48;while((c=gc)<='9'&&c>='0')x=x*10+c-48;if(f)x=-x;}
namespace fob{char b[300000]= {},*f=b,*g=b+300000-2;}
#define pob (fwrite(fob::b,sizeof(char),fob::f-fob::b,stdout),fob::f=fob::b,0)
#define pc(x) (*(fob::f++)=(x),(fob::f==fob::g)?pob:0)
struct foce{~foce(){pob;fflush(stdout);}} _foce;
namespace ib{char b[100];}
inline void out(ll x){if(x==0){pc(48);return;}if(x<0){pc('-');x=-x;}char *s=ib::b;while(x) *(++s)=x%10,x/=10;while(s!=ib::b) pc((*(s--))+48);}
inline void outn(ll x){out(x);pc('\n');}
/*------------------------------------------------------------------------------------------------*/

/*------------------------------------------------------------------------------------------------*/
int main(){
	ll n,t=0,x=0,y=0,pt,px,py,nt,nx,ny,k;in(n);
	while(n--){
		in3(nt,nx,ny);
		pt=nt-t;px=abs(nx-x);py=abs(ny-y);
		k=pt-px-py;
		if((k<0)||(k&1)){printf("No\n");return 0;}
		t=nt;x=nx;y=ny;
	}
	printf("Yes\n");
}
/*

*/

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#include<cmath>

#define REP(i,n) for (int i = 0; (i) < (n); ++ (i))
#define FOR(i,n) for (int i = 1; (i) <= (n); ++ (i))
#define dump(x)  cout << #x << " = " << (x) << endl;
#define pb push_back
#define int long long

const int INF = 1e18;
const int MOD = 1e9+7;
//const lint LINF = 1e18;
const double eps = 0.000000001;//もとの値の10^(-16)まで

using namespace std;

typedef pair<int, int> P;
//priority_queue< P, vector<P>, greater<P> > q;//ダイクストラの時、greaterで小さい順
//cout << fixed << setprecision(10) << ans << endl;
//int gcd(int a,int b){return b?gcd(b,a%b):a;}

int a[3000];
int dp[2005][2005];
vector<P> narabi;
signed main(){
    int n;
    cin >> n;
    for(int i=1;i<=n;i++){
        int a1;
        cin >> a1;
        narabi.pb(P(a1,i));
    }
    sort(narabi.begin(),narabi.end());
    reverse(narabi.begin(),narabi.end());
    for(int i=1;i<=n;i++){
        P ne = narabi[i-1];
        for(int j=0;j<=i;j++){
            int m1,m2;
            if(j==0) m1 = -1;
            else{
                m1 = dp[j-1][i-j] + abs(j-ne.second) * ne.first;
            }
            if(i-j == 0) m2 = -1;
            else{
                m2 = dp[j][i-j-1] + abs(n-(i-j)+1-ne.second) * ne.first;
            }
            dp[j][i-j] = max(m1,m2);
        }
    }
    int ans = -1;
    for(int j=0;j<=n;j++){
        ans = max(ans,dp[j][n-j]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 26316
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main(){
 string s,t,ss,tt;
 cin >> s>>t;
ss=s;tt=t;
reverse(s.begin(),s.end());
reverse(t.begin(),t.end());
if(t==ss&&tt==s) cout <<"YES"<<endl;
else cout <<"NO"<<endl;
}


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

int main(){
  int N;
  cin >> N;
  vector<float> vec(N);
  vector<float> g(N);
  for(int i=0;i<N;i++){
    cin >> vec.at(i);
    g.at(i) = 1/vec.at(i);
  }
  float sum;
  for(int i = 0;i<N;i++){
    sum += g.at(i);
  }
  cout << 1/sum << endl;
  return 0;
}

Measured memory_bytes: 256
def solve():
    N = int(input())
    A = list(map(int,input().split()))
    B = list(map(int,input().split()))
    ans = 0

    remain = []
    lack = 0
    for i in range(N):
        diff = A[i] - B[i]
        if diff > 0:
            remain.append(diff)
        if diff < 0:
            lack += abs(diff)
            ans += 1

    if lack == 0:
        print("0")
        return
    
    remain.sort(reverse=True)
    sm = 0
    for r in remain:
        sm += r
        ans += 1
        if sm >= lack:
            print(ans)
            break
    else:
        print("-1")
    
if __name__ == '__main__':
    solve()

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

LL iabs(LL x) { return x >= 0 ? x : -x; }

int main() {
    int n, m;
    scanf("%d%d", &n, &m);
    printf("%lld\n", iabs(1LL * (n - 2) * (m - 2)));
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;
//using Debug;
//using static System.Globalization.CultureInfo;
//using Edge = Pair<long, int>;
using System.Text;
class Program
{ 
    static void Main(string[] args)
    {
        Solve();
        //WriteLine(Solve());
    }
    static void Solve()
    {
        var num = Input.num;
        var ar = Input.ar1D(num);
        var dic = ar.OrderBy(v => v).Select((v, i) => new KeyValuePair<int, int>(v, i)).ToDictionary(p => p.Key, p => p.Value);
        var th = new bool[num];var ct = 0;
        for (var i = 0; i < num; i++)
            if (i % 2 != dic[ar[i]] % 2)
                ct++;
        WriteLine(ct/2);
    }
}

public class Input
{
    public static string read => ReadLine().Trim();
    public static int[] ar => read.Split(' ').Select(int.Parse).ToArray();
    public  static int num => ToInt32(read);
    public static long[] arL => read.Split(' ').Select(long.Parse).ToArray();
    public  static long numL => ToInt64(read);
    public static char[][] gred(int h) 
        => Enumerable.Repeat(0, h).Select(_ => read.ToCharArray()).ToArray();
    public static int[] ar1D(int n)
        => Enumerable.Repeat(0, n).Select(_ => num).ToArray();
    public static long[] arL1D(int n)
        => Enumerable.Repeat(0, n).Select(_ => numL).ToArray();
    public static int[][] ar2D(int n)
        => Enumerable.Repeat(0, n).Select(_ => ar).ToArray();
    public static long[][] arL2D(int n)
        => Enumerable.Repeat(0, n).Select(_ => arL).ToArray();
    public static T getValue<T>(string g)
    {
        var t = typeof(T);
        if (t == typeof(int))
            return (T)(object)int.Parse(g);
        if (t == typeof(long))
            return (T)(object)long.Parse(g);
        if (t == typeof(string))
            return (T)(object)g;
        if (t == typeof(char))
            return (T)(object)char.Parse(g);
        if (t == typeof(double))
            return (T)(object)double.Parse(g);
        if (t == typeof(bool))
            return (T)(object)bool.Parse(g);
        return default(T);
    }
    public const long Inf = (long)1e18;
    public const double eps = 1e-6;
    public  const string Alfa = "abcdefghijklmnopqrstuvwxyz";
    public  const int MOD = 1000000007;
}


Measured memory_bytes: 23516
N = int(input())
A = list(map(int,input().split()))
B = N*[0]

for n in range(N):
  if n%2==0:
    B[0]+=A[n]
  else:
    B[0]-=A[n]

for n in range(N):
  if n==0:
    pass
  elif 1<=n<=N-1:
    B[n] = 2*A[n-1]-B[n-1]
  else:
    B[n] = 2*A[n]-B[0]

print(*B)

Measured memory_bytes: 20500
import java.util.Arrays;
import java.util.Scanner;

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

        int n = scanner.nextInt();
        int k = scanner.nextInt();

        int[] prices = new int[n];
        for (int i = 0; i < n; i++) {
            prices[i] = scanner.nextInt();
        }

        Arrays.sort(prices);

        int price = 0;
        for (int i = 0; i < k; i++) {
            price += prices[i];
        }

        System.out.println(price);
    }
}


Measured memory_bytes: 39000
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define mp(a,b) make_pair(a,b)
#define vi vector<int>
#define mii map<int,int>
#define mpi map<pair<int,int>,int>
#define vp vector<pair<int,int> >
#define pb(a) push_back(a)
#define fr(i,n) for(i=0;i<n;i++)
#define rep(i,a,n) for(i=a;i<n;i++)
#define F first
#define S second
#define endl "\n"
#define fast std::ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define mod 1000000007
#define dom 998244353
#define pi 3.14159265
#define sl(a) (int)a.length()
#define sz(a) (int)a.size()
#define all(a) a.begin(),a.end()
#define pii pair<int,int> 
#define mini 2000000000000000000
#define time_taken 1.0 * clock() / CLOCKS_PER_SEC
//mt19937_64 mt(chrono::steady_clock::now().time_since_epoch().count());
void shikhar7s(int cas)
{
    int n,m,i,s;
    cin>>n>>m>>s;
    int c;
    vi a(n+1,0),b(m+1,0);
    fr(i,n)
    {
        cin>>c;
        a[i+1]=a[i]+c;
    }
    fr(i,m)
    {
        cin>>c;
        b[i+1]=b[i]+c;
    }
    int j,ans=0;
    fr(i,n+1)
    {
        c=s-a[i];
        if(c<0)
            break;
        j=upper_bound(all(b),c)-b.begin();
        j--;
        ans=max(ans,i+j);
    }
    cout<<ans;
}
signed main()
{
    fast;
    int t=1;
    //cin>>t;
    int cas=1;
    while(cas<=t)
    {
    shikhar7s(cas);
    cas++;
    }
    return 0;
}

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

int main() {
  string s; cin >> s;
  int a = s[0] - '0', b = s[1] - '0', c = s[2] - '0', d = s[3] - '0';
  if (a+b+c+d == 7) cout << a << "+" << b << "+" << c << "+" << d << "=" << 7 << endl;
  else if (a+b+c-d == 7) cout << a << "+" << b << "+" << c << "-" << d << "=" << 7 << endl;
  else if (a+b-c+d == 7) cout << a << "+" << b << "-" << c << "+" << d << "=" << 7 << endl;
  else if (a+b-c-d == 7) cout << a << "+" << b << "-" << c << "-" << d << "=" << 7 << endl;
  else if (a-b+c+d == 7) cout << a << "-" << b << "+" << c << "+" << d << "=" << 7 << endl;
  else if (a-b+c-d == 7) cout << a << "-" << b << "+" << c << "-" << d << "=" << 7 << endl;
  else if (a-b-c+d == 7) cout << a << "-" << b << "-" << c << "+" << d << "=" << 7 << endl;
  else if (a-b-c-d == 7) cout << a << "-" << b << "-" << c << "-" << d << "=" << 7 << endl;
  return 0;
}

Measured memory_bytes: 256
import std;
enum inf(T)()if(__traits(isArithmetic,T)){return T.max/4;}
T scan(T=long)(){return readln.chomp.to!T;}
void scan(T...)(ref T args){auto input=readln.chomp.split;foreach(i,t;T)args[i]=input[i].to!t;}
T[] scanarr(T=long)(){return readln.chomp.split.to!(T[]);}
alias Queue=DList;auto enq(T)(ref Queue!T q,T e){q.insertBack(e);}T deq(T)(ref Queue!T q){T e=q.front;q.removeFront;return e;} 
alias Stack=SList;auto push(T)(ref Stack!T s,T e){s.insert(e);}T pop(T)(ref Stack!T s){T e=s.front;s.removeFront;return e;} 
struct UnionFind(T){T[T]u;ulong[T] rank;@property{bool inc(T e){return e in u;}auto size(){return u.keys.length;}auto dup(){T[] child=u.keys;T[] parent=u.values;auto res=UnionFind!T(child);child.each!(e=>res.add(e));size.iota.each!(i=>res.unite(child[i],parent[i]));return res;}}this(T e){e.add;}this(T[] es){es.each!(e=>e.add);}auto add(T a,T b=a){assert(b.inc);u[a]=a;rank[a];if(a!=b)unite(a,b);}auto find(T e){if(u[e]==e)return e;return u[e]=find(u[e]);}auto same(T a,T b){return a.find==b.find;}auto unite(T a,T b){a=a.find;b=b.find;if(a==b)return;if(rank[a]<rank[b])u[a]=b;else{u[b]=a;if(rank[a]==rank[b])rank[a]++;}}}
struct PriorityQueue(T,alias less="a<b"){BinaryHeap!(T[],less) heap;@property{bool empty(){return heap.empty;}auto length(){return heap.length;}auto dup(){return PriorityQueue!(T,less)(array);}T[] array(){T[] res;auto tp=heap.dup;foreach(i;0..length){res~=tp.front;tp.removeFront;}return res;}void push(T e){heap.insert(e);}void push(T[] es){es.each!(e=>heap.insert(e));}}T look(){return heap.front;}T pop(){T tp=look;heap.removeFront;return tp;}this(T e){ heap=heapify!(less,T[])([e]);}   this(T[] e){ heap=heapify!(less,T[])(e);}}
//END OF TEMPLATE

void main(){
    auto r=scan!long;
    (2*r*3.14159265).writeln;
}


Measured memory_bytes: 3860
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef pair<ll, ll>pll;
ll n, sum;
int main()
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> n;
    for(int i = 1;i <= n;++i)
        for(int j = 1;j <= n;++j)
            for(int k = 1;k <= n;++k)
                sum += __gcd(i, __gcd(j, k));
    cout << sum;
    return 0;
}


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

int main(){
    
    int N;
    std::cin >> N;
    
    long H[N];
    for (int i = 0 ; i < N ; i++){
        std::cin >> H[i];
        if (N == 1){
        std:: cout << "Yes" << std::endl;
        return 0;
        }
        if (i == 0){
            H[i]--;
        }else{
            if (H[i]  > H[i-1] ) H[i]--;
            else if (H[i] == H[i-1]) continue;
            else{
                std ::cout << "No" << std::endl;
                return 0;
            }
        }
    }

    std ::cout << "Yes" << std::endl;
    return 0;
}

Measured memory_bytes: 1024
#include <cstdio>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>

int main(void) {
    int a, b, c, d;
    std::scanf("%d %d %d %d", &a, &b, &c, &d);
    std::puts(a + b > c + d ? "Left" : a + b < c + d ? "Right" : "Balanced");
    return 0;
}

Measured memory_bytes: 256
l = [[] for _ in range(3)]
for i in range(0, 3):
    l[i] = [int(_) for _ in input().split()]
t = [0, 0, 0]
for i in range(0, 3):
    for j in range(0, 3):
        t[i] += l[j][i]
p = (t[0] - t[1]) / 3
q = (t[0] - t[2]) / 3
if l[0][0]-p == l[0][1] and l[0][0]-q == l[0][2] and l[1][0]-p == l[1][1] and l[1][0]-q == l[1][2] and l[2][0]-p == l[2][1] and l[2][0]-q == l[2][2]:
    print('Yes')
else:
    print('No') 

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

#define ll long long
using namespace std;

int main() {
    ll k, a, b;
    cin >> k >> a >> b;
    ll punch=1+k;
    ll magic=0;
    if(k>=a-1){
        k-=a-1;
        magic=a;
        magic+=(k/2)*(b-a);
        magic+=k%2;
    }
    cout<<max(punch,magic)<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    int a,b,c,t;
    cin>>a>>b>>c;
    if(a>b){t=a;a=b;b=t;}
    if(b>c){t=b;b=c;c=t;}
    if(a>b){t=a;a=b;b=t;}
    cout<<a<<" "<<b<<" "<<c<<endl;
    return 0;
}

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

using namespace std;

using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using vb = vector<bool>;
using P = pair<ll, ll>;
template <typename T> using pq = priority_queue<T>;
template <typename T> using minpq = priority_queue<T, vector<T>, greater<T>>;
template <typename T, typename K> using ump = unordered_map<T, K>;
const ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll e5 = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for (ll i = ll(n - 1); i >= 0; i--)
#define each(i, mp) for (auto &i : mp)
#define eb emplace_back
#define F first
#define S second
#define all(obj) (obj).begin(), (obj).end()

template <class T> ostream &operator<<(ostream &out, const vector<T> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << ' ';
    return out;
}

template <class T> istream &operator>>(istream &in, vector<T> &list) {
    ll n = list.size();
    rep(i, n) in >> list[i];
    return in;
}

template <class T> ostream &operator<<(ostream &out, const vector<vector<T>> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << '\n';
    return out;
}

/* ------------- ANSWER ------------- */
/* ---------------------------------- */

void solve() {
    ll n, m;
    cin >> n >> m;
    cout << n * (n - 1) / 2 + m * (m - 1) / 2 << '\n';
}

int main() {
    solve();
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define reps(i, m, n) for (int i = m; i < n; i++)
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

int main(void){
    int n, k;
    scanf("%d %d", &n, &k);
    
    vector<vector<int> > white(4*k+1, vector<int>(4*k+1, 0));
    vector<vector<int> > black(4*k+1, vector<int>(4*k+1, 0));

    int x, y;
    char s;
    char key = 'B';
    rep(i, n){
        scanf("%d %d ", &x, &y);
        scanf("%c", &s);
        if (s == key){
            black[x%(2*k)+1][y%(2*k)+1] += 1;
            black[x%(2*k)+1+2*k][y%(2*k)+1] += 1;
            black[x%(2*k)+1][y%(2*k)+1+2*k] += 1;
            black[x%(2*k)+1+2*k][y%(2*k)+1+2*k] += 1;
        }
        else{
            white[x%(2*k)+1][y%(2*k)+1] += 1;
            white[x%(2*k)+1+2*k][y%(2*k)+1] += 1;
            white[x%(2*k)+1][y%(2*k)+1+2*k] += 1;
            white[x%(2*k)+1+2*k][y%(2*k)+1+2*k] += 1;
        }
    }


    rep(i, 4*k)rep(j, 4*k){
        white[i+1][j+1] += white[i][j+1]+white[i+1][j]-white[i][j];
        black[i+1][j+1] += black[i][j+1]+black[i+1][j]-black[i][j];
    }
    
    int ans = 0;
    int p, q, sub;
    rep(i, 2*k)rep(j, 2*k){
        int p, q, x, y;
        p = i+k;
        q = j+k;
        x = p+k;
        y = q+k;
        
        sub =white[p][q]+white[i][j]-white[p][j]-white[i][q]+white[x][y]+white[p][q]-white[x][q]-white[p][y]+black[x][q]+black[p][j]-black[p][q]-black[x][j]+black[p][y]+black[i][q]-black[i][y]-black[p][q];
        if (ans < sub){
            ans = sub;
        }
    }
    
    printf("%d\n", ans);
    
    return 0;
}



Measured memory_bytes: 128640
#include<stdio.h>

int main(void)
{
	int a, b;
	//aはカーテンの横幅

	//入力
	scanf("%d %d", &a, &b);

	if (b * 2 >= a) {
		printf("0\n");
	}
	else {
		printf("%d\n", a - b * 2);
	}

	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
#include <string>
#include <cmath>
#include <map>
#define INF 1000000009
#define double long double
#define all(a) a.begin(),a.end()
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<P, ll> PP;
typedef pair<ll, double> PD;
ll mod = 1000000007;

int main() {
	int n;
	cin >> n;
	for (int i = 1; i <= 50000; i++) {
		int k = i * 1.08;
		if (k == n) {
			cout << i << endl;
			return 0;
		}
	}
	cout << ":(" << endl;
}

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

using namespace std;

int n;

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cin >> n;
	for (int i=1; i<=9; i++) {
		for (int j=1; j<=9; j++) {
			if (i * j == n) {
				cout << "Yes" << endl;
				exit(0);
			}
		}
	}
	cout << "No" << endl;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
N = int(input())
B = list(map(int,input().split()))
A = []
for i in range(N-1):
    if i == 0:
        A.append(B[0])
    else:
        A.append(min(B[i],B[i-1]))
A.append(B[-1])
print(sum(A))

Measured memory_bytes: 38384
#include <stdio.h>

int main()
{
    int N;
    int H[101];
    int ans = 1;
    scanf("%d", &N);
    for (int i = 0; i < N; i++) {
        scanf("%d", &H[i]);
    }
    for (int j = 1; j < N; j++) {
        for (int k = 0; k < j; k++) {
            if (H[k] > H[j]) {
                break;
            }
            if (k == j - 1) {
                ans++;
            }
        }
    }
    printf("%d\n", ans);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1<<29;
const int MOD = 1e9+7;
const ll LINF = 1e18;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
    REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
    REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}

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

const int dx4[4] = {1, 0, -1, 0};
const int dy4[4] = {0, 1, 0, -1};

const int dx8[8] = {1,1,0,-1,-1,-1,0,1};
const int dy8[8] = {0,1,1,1,0,-1,-1,-1};

vector< vector<int> > Graph;
vector< int > value;





int main(int argc, const char * argv[]) {
    
    // remove the bottom 3 lines when you submit this code.
    std::ifstream in("sample.txt");
    std::cin.rdbuf(in.rdbuf());

    cin.tie(0);
    ios::sync_with_stdio(false);
    string march = "MARCH";
    int n; cin >> n;
    map<char,ll> NameMap{};
    rep(i,n){
        string s; cin >> s;
        bool ischeck = false;
        rep(i,5) {if(march[i]==s[0]) ischeck = true;}
        if(ischeck) NameMap[s[0]]++;
    }
    
    long long Ans = 0;
    
    if(NameMap.size() == 3){
        Ans = 1;
        for(auto it = NameMap.begin(); it != NameMap.end(); it++) Ans *= it->second;
    }else if(NameMap.size() == 4){
        long long t = 1;
        for(auto it = NameMap.begin(); it != NameMap.end(); it++) t *= it->second;
        for(auto it = NameMap.begin(); it != NameMap.end(); it++){
            Ans += (t/(it->second));
            
        }
        
    }else if(NameMap.size() == 5){
        vector<long long> Num(5);
        Num[0] = NameMap['M'];
        Num[1] = NameMap['A'];
        Num[2] = NameMap['R'];
        Num[3] = NameMap['C'];
        Num[4] = NameMap['H'];
        
        for (int i = 0; i < 5; i++) {
            
            for (int j = i; j < 5; j++) {
                if(i==j) continue;
                long long t = 1;
                
                for (int k = 0; k < 5; k++) {
                    if(k == i || k == j) continue;
                    t *= Num[k];
                }
                
                Ans += t;
                
            }
        }
        
        
    }
    
    cout << Ans << endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <stack>
#include <queue>
#include <vector>

using namespace std;

typedef vector<string> vs;
typedef vector<int> vi;

#define rep(i,b) loop(i,0,b)
#define loop(i,a,b) for(int i=(a); i<int(b); i++)
#define all(c) (c).begin(), (c).end()

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

int h,w;
inline bool in(int x, int y){
    return 0<=x && 0<=y && x<w && y<h;
}

vi id{0,1,2,3};
bool solve(vs const& g1, vs const& g2){
    int sx1, sy1, sx2, sy2;
    rep(i,h)rep(j,w){
        if(g1[i][j]=='L'){
            sx1=j;sy1=i;
        }
        if(g2[i][j]=='R'){
            sx2=j;sy2=i;
        }
    }
    queue<vi> q;
    static bool vis[64][64][64][64];
    memset(vis,0,sizeof(vis));
    q.push(vi{sx1,sy1,sx2,sy2});
    while(q.size()){
        vi s=q.front();q.pop();
        int x1=s[0],y1=s[1],x2=s[2],y2=s[3];
        if(vis[x1][y1][x2][y2])continue;
        vis[x1][y1][x2][y2]=true;
        if(g1[y1][x1]=='%' && g2[y2][x2]=='%') return true;
        if(g1[y1][x1]=='%' || g2[y2][x2]=='%') continue;

        random_shuffle(all(id));
        rep(i,4){
            int d=id[i];
            int nx1=x1+dx[d],ny1=y1+dy[d];
            int nx2,ny2;
            if(d&1){
                nx2=x2+dx[d],ny2=y2+dy[d];
            }else{
                nx2=x2-dx[d],ny2=y2-dy[d];
            }
            if(!in(nx1,ny1) || g1[ny1][nx1]=='#')nx1=x1,ny1=y1;
            if(!in(nx2,ny2) || g2[ny2][nx2]=='#')nx2=x2,ny2=y2;
            q.push(vi{nx1,ny1,nx2,ny2});
        }
    }
    return false;    
}

int main(){
    while(cin>>w>>h && w|h){
        vs g1(h), g2(h);
        rep(i,h) cin>>g1[i]>>g2[i];
        vs ans{"No","Yes"};
        cout << ans[solve(g1,g2)] << endl;
    }
}

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

int main(){
    int N; cin >> N;
    deque<int> dq;
    deque<int>::iterator itr = dq.begin();
    while(N--){
        int type; cin >> type;
        switch(type){
            case 0:
                int which, x; cin >> which >> x;
                if(which) dq.push_back(x);
                else dq.push_front(x);
                break;
            case 1:
                int i; cin >> i;
                itr = dq.begin() + i;
                cout << *itr << endl;
                break;
            case 2:
                int w; cin >> w;
                if(w) dq.pop_back();
                else dq.pop_front();
                break;
            default:
                cout << "Error" << endl;
        }
    }
    return 0;
}


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

class Dijkstra {
#define MAX_V 102
  typedef pair<int, int> P;

private:
  const int INF = 1e9 + 10;
  struct Edge {
    int to, cost;
    Edge(int to, int cost): to(to), cost(cost) { }
  };

  int V;
  vector<Edge> G[MAX_V];

public:

  Dijkstra(int V): V(V) { 
    if (V >= MAX_V) {
      assert(false);
    }
  }

  void AddEdge(int from, int to, int cost) {
    G[from].push_back(Edge(to, cost));
  }

  vector<int> Solve(int s) {
    priority_queue<P, vector<P>, greater<P>> que;
    vector<int> d(V, INF);
    d[s] = 0;
    que.push(P(0, s));

    while (!que.empty()) {
      P p = que.top(); que.pop();
      int v = p.second;
      if (d[v] < p.first) {
        continue;
      }
      for (int i = 0; i < G[v].size(); i++) {
        Edge e = G[v][i];
        if (d[e.to] > d[v] + e.cost) {
          d[e.to] = d[v] + e.cost;
          que.push(P(d[e.to], e.to));
        }
      }
    }

    return d;
  }
};


int main() {
  int n;
  cin >> n;
  Dijkstra dijkstra(101);
  
  for (int i = 0; i < n; i++) {
    int r, k;
    cin >> r >> k;
    for (int j = 0; j < k; j++) {
      int t;
      cin >> t;
      dijkstra.AddEdge(r, t, 1);
    }
  }

  int p;
  cin >> p;

  for (int i = 0; i < p; i++) {
    int s, d, v;
    cin >> s >> d >> v;
    vector<int> dists = dijkstra.Solve(s);
    int dist = dists[d];
    if (dist >= v) {
      cout << "NA" << endl;
    } else {
      cout << dist + 1 << endl;
    }
  }
  
  
  return 0;
}

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

using namespace std;

int main()
{
	long long sum = 0, maxx = 0, k;
	for (int i = 0; i < 3; i++)
	{
		long long x;
		cin >> x;
		sum += x;
		maxx = max(maxx, x);
	}
	cin >> k;
	sum += maxx*(1 << k) - maxx;
	cout << sum << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<numeric>
#include<string>
#include<cmath>
#include<set>
#include<queue>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cctype>
#include<map>

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,a,b) for (int (i)=a;(i)<(b);(i)++)
#define all(x) (x).begin(),(x).end()

using namespace std;
const int inf = 1001001000;
const long long int Inf = 1001001001001001000;

void print(vector<vector<int>> a){
	for (int i=0;i<a.size();i++){
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<vector<long long int>> a){
	for (int i=0;i<a.size();i++){
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(set<int> a){
	for (auto x:a)
		cout << x << " ";
	cout << endl;
}

//幅優先探索のテンプレ.デフォルトではstartからの距離を返す.
//graphは隣接リスト.startは探索開始地点
vector<int> bfs(vector<vector<int>> &graph, int start){
	queue<int> todo;
	vector<int> dist(graph.size(),-1);
	dist[start] = 0;
	todo.push(start);
	while(!todo.empty()){
		int now = todo.front();
		todo.pop();
		for (int i=0;i<graph[now].size();i++){
			int nxt = graph[now][i];
			if (dist[nxt] != -1) continue;
			dist[nxt] = dist[now] + 1;
			todo.push(nxt);
		}
	}
	return dist;
}

int main()
{
	int n, x, y;
	cin >> n >> x >> y;
	x--;
	y--;
	vector<vector<int>> graph(n, vector<int>());
	rep(i,n){
		if (i == 0){
			graph[i].push_back(i + 1);
		}
		else if (i == n - 1)
		{
			graph[i].push_back(i-1);
		}
		else
		{
			graph[i].push_back(i + 1);
			graph[i].push_back(i - 1);
		}
	}
	graph[x].push_back(y);
	graph[y].push_back(x);
	vector<int> ans(n, 0);
	rep(i, n-1)
	{
		vector<int> dist = bfs(graph, i);
		rep2(j,i+1,n){
			ans[dist[j]]++;
		}
	}
	rep2(i,1,n){
		cout << ans[i] << endl;
	}

	return 0;
}

Measured memory_bytes: 384
import java.util.*;
import javax.lang.model.util.ElementScanner6;
import java.lang.Math;

class Main
{

    public static void main(final String args[])
    {
        final Scanner sc = new Scanner(System.in);
        
       
        
        int h1=sc.nextInt();
        int m1=sc.nextInt();
        int h2=sc.nextInt();
        int m2=sc.nextInt();
        int k=sc.nextInt();
        
   int s=h1*60+m1;
        int g=h2*60+m2;
        
        int result=g-s-k;
 
        
        System.out.print(result);
    }
}    

Measured memory_bytes: 35668
import java.util.Scanner;

public class Main{
  public static void main(String arg[]){
    Scanner scan = new Scanner(System.in);
    
    String abc = scan.nextLine();
    
    if(abc.equals("ABC")){
      System.out.println("ARC");
    }else{
      System.out.println("ABC");
    }
  }
}

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


int main() {
  int n;
  cin >> n;
  if (n%2 == 0) {
    cout << n / 2;
  } else {
    cout << (n / 2) + 1;
  }
}


Measured memory_bytes: 3640
n=int(input())
s=[]
for i in range(n):
    st=input()
    if st in s:
        print('No')
        exit()
    s.append(st)

for i in range(1,n):
    if s[i][0]!=s[i-1][-1]:
        print('No')
        exit()
print('Yes')
    

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

int main()
{
    string sa, sb, sc;
    int c;

    cin >> sa >> sb;
    c = stoi(sa + sb);

    for (int i = 0; i < 1000; i++) {
        if (i * i == c) {
            cout << "Yes" << endl;
            return 0;
        }
    }

    cout << "No" << endl;
    return 0;
}

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

int main()
{
	long long x, y;
	long long ans = 0;

	scanf("%lld %lld", &x, &y);

	if ((x < 0 && y < 0 && llabs(x) < llabs(y)) ||
			(x > 0 && y > 0 && llabs(x) > llabs(y))) {
		ans++;
		
		x = -x;
	}

	ans = ans + llabs( llabs(x) - llabs(y) );
	x = x + llabs( llabs(x) - llabs(y) );

	if (x != y) {
		ans++;
	}

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


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

namespace ConsoleApplication1 {
     class Program {
          static void Main(string[] args) {
               int x = int.Parse(Console.ReadLine());
               if(x < 1200) {
                    Console.WriteLine("ABC");
               }else {
                    Console.WriteLine("ARC");
               }
          }
     }
}


Measured memory_bytes: 2648
import java.util.Scanner;
import java.util.ArrayDeque;
import java.util.ArrayList;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		long k=sc.nextInt();
		long mod=1000000007;
		long ans=1;
		ArrayList<Integer>[] list=new ArrayList[n];
		for(int i=0; i<n; i++){
			list[i]=new ArrayList<>();
		}
		for(int i=0; i<n-1; i++){
			int a =sc.nextInt()-1;
			int b =sc.nextInt()-1;
			list[a].add(b);
			list[b].add(a);
		}
		boolean[] visited=new boolean[n];
		ArrayDeque<Integer>  que=new ArrayDeque<>();
		que.add(0);
		int count1=1;
		int count2=0;
		int count3=0;
		int[] kk=new int[n];
		int[] yy=new int[n];
		int cv=0;
		while(!que.isEmpty()){
			int j=que.poll();
			visited[j]=true;
			for(int i:list[j]){
				if(!visited[i]){
					count3++;
					cv++;
					que.add(i);
					yy[i]=j;
				}
			}
			kk[j]=cv-1;
			cv=0;
			if(count1==1){
				ans=(ans*k)%mod;
			}else if(count1==2){
				ans=(ans*(k-1-kk[yy[j]]))%mod;
				kk[yy[j]]--;
			}else{
				ans=(ans*(k-2-kk[yy[j]]))%mod;
				kk[yy[j]]--;
			}
			if(count2==0){
				count2=count3-1;
				count3=0;
				count1++;
			}else{
				count2--;
			}
		}
		System.out.println(ans);
	}
}




Measured memory_bytes: 105996
'use strict'

function Main(input) {
  let array = input.split("\n")[1].split(" ").map(e => parseInt(e, 10));
  let count = 0;
  while (array.every(e => (e % 2) === 0)) {
    array = array.map(e => e / 2);
    count++;
  }
  console.log(count);
}

//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7500
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define inf (int)(1e9+7)
#define abs(x) (x >= 0 ? x : -(x))
#define ceil(a, b) a / b + !!(a % b)
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }
// template<typename T> T pow(T a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }



int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    
    rep(i, n) cin >> a[i];
    
    
    int ans = inf;
    rep3(i, -100, 100 + 1) {
        int tmp = 0;
        rep(j, n) {
            tmp += (a[j] - i) * (a[j] - i);
        }
        chmin(ans, tmp);
    }
    cout << ans << endl;
    
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
    int Cards[4][14] = {{}}, i, j, n, Num;
    char Mark; 

    scanf("%d", &n);

    for(i = 0; i < 2 * n; i++)
    {
        scanf("%c ", &Mark);
        scanf("%d", &Num);
        
        if(Mark == 'S')
        {
            Cards[0][Num - 1] = 1;
        }

        else if(Mark == 'H')
        {
            Cards[1][Num - 1] = 1;
        }

        else if(Mark == 'C')
        {
            Cards[2][Num - 1] = 1;
        }

        else if(Mark == 'D')
        {
            Cards[3][Num - 1] = 1;
        }
    }

    for(j = 1; j < 14; j++)
    {
        if(Cards[0][j - 1] != 1)
        {
            printf("S %d\n", j);
        }
    }

    for(j = 1; j < 14; j++)
    {
        if(Cards[1][j - 1] != 1)
        {
            printf("H %d\n", j);
        }
    }

    for(j = 1; j < 14; j++)
    {
        if(Cards[2][j - 1] != 1)
        {
            printf("C %d\n", j);
        }
    }

    for(j = 1; j < 14; j++)
    {
        if(Cards[3][j - 1] != 1)
        {
            printf("D %d\n", j);
        }
    }
    
    return 0;
}


Measured memory_bytes: 2040
#include <stdio.h>
#include <algorithm>
#include <string.h>
#include <math.h>
#include <map>
const int N = 2e5+10;
#define ll long long
int h[N], n; ll ans;
std::map<int, int> mp;
int main() {
	scanf("%d", &n);
	for (int i=1; i<=n; i++) scanf("%d", &h[i]);
	for (int i=n; i>0; i--) {
		ans += mp[i+h[i]];
		++mp[i-h[i]];
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 21084
using System;
using System.Collections.Generic;
using System.Text.RegularExpressions;
class Program
{
    static int x;
    static List<long> h = new List<long>();
    static string result;
    static void Main()
    {
        string tmp2 = Console.ReadLine();
        x=int.Parse(tmp2);
        string[] tmp = Console.ReadLine().Split(' ');
        for (int i = 0; i < x; i++) { h.Add(long.Parse(tmp[i])); }
        bool OK=true;
        //左より大きければ１下げる。
        if (h[0] > 1) { h[0]--; }//条件がよーわからん。ダメならけせ
        for (int i=0;i<x-1;i++) { if (h[i + 1] < h[i]) { OK = false;break; } if (h[i + 1] > h[i]) { h[i+1]--; } }
        if (OK == true) { result = "Yes"; } else { result = "No"; }
            Console.WriteLine(result);
            Console.Out.Flush();
        
    }

 


}

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

int main() {
    int k, s;
    cin >> k >> s;
    
    int ans = 0;
    for(int x = 0; x <= k; ++x) {
        for(int y = 0; y <= k; ++y) {
            int z = s - x - y;
            if(0 <= z && z <= k) ++ans;
        }
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 256