akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

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

std::mt19937 mt{ std::random_device{}() };

int randint(int lower, int upper)
{
    std::uniform_int_distribution<int> dist(lower, upper);
    return dist(mt);
}

int calc_score(int M, int D, vector<vector<int>> &S, vector<int> &T, vector<int> &C)
{
    int ans = 0;
    vector<int> last(M, -1);
    for(int i=0; i<D; i++)
    {
        ans += S[i][T[i]];
        last[T[i]] = i;
        for(int j=0; j<M; j++)
        {
            ans -= C[j] * (i - last[j]);
        }
    }
    return ans;
}

int main()
{
    int tstart = clock();
    ios::sync_with_stdio(false);
    cin.tie(0);
    int D;
    cin >> D;
    const int M = 26;
    vector<int> C(M);
    for(int i=0; i<M; i++) cin >> C[i];
    vector<vector<int>> S(D, vector<int>(M));
    for(int i=0; i<D; i++)
    {
        for(int j=0; j<M; j++)
        {
            cin >> S[i][j];
        }
    }
    vector<int> T(D);
    for(int i=0; i<D; i++)
    {
        int naxj = 0;
        int nax = S[i][0];
        for(int j=1; j<M; j++)
        {
            if(chmax(nax, S[i][j]))
            {
                naxj = j;
            }
        }
        T[i] = naxj;
    }
    int score = calc_score(M, D, S, T, C);
    while(1.0 * (clock() - tstart) / CLOCKS_PER_SEC < 1.95)
    {
        // cout << 1.0 * (clock() - tstart) / CLOCKS_PER_SEC << endl;
        int H = randint(0, D-1);
        int Q = randint(0, M-1);
        int tmp = T[H];
        T[H] = Q;
        int nscore = calc_score(M, D, S, T, C);
        if(score < nscore)
        {
            score = nscore;
        }
        else
        {
            T[H] = tmp;
        }
    }
    for(int i=0; i<D; i++)
    {
        cout << T[i] + 1 << '\n';
    }
    return 0;
}


Measured memory_bytes: 3736
using System;
using System.Collections.Generic;
using System.Text;

namespace AtTest.D_Challenge
{
    class ABC_089
    {
        static void Main(string[] args)
        {
            Method(args);
            Console.ReadLine();
        }

        static void Method(string[] args)
        {
            int[] hwd = ReadInts();
            var grid = new int[hwd[0]][];
            var posList = new List<int[]>();
            for(int i = 0; i < hwd[0]; i++)
            {
                grid[i] = ReadInts();
                for (int j = 0; j < hwd[1]; j++)
                {
                    posList.Add(new int[3] { grid[i][j], i, j });
                }
            }
            posList.Sort((a, b) => a[0] - b[0]);
            var costGrid = new int[hwd[0], hwd[1]];
            for(int i=0;i<posList.Count;i++)
            {
                int prevIndex = i - hwd[2];
                if (prevIndex < 0)
                {
                    costGrid[posList[i][1], posList[i][2]] = 0;
                }
                else
                {
                    int[] pos = posList[i];
                    int[] prevPos = posList[prevIndex];
                    costGrid[pos[1], pos[2]]
                        = costGrid[prevPos[1], prevPos[2]];
                    costGrid[pos[1], pos[2]]
                        += Math.Abs(pos[1] - prevPos[1])
                        + Math.Abs(pos[2] - prevPos[2]);
                }
            }

            int q = ReadInt();
            var lrs = new int[q][];
            for(int i = 0; i < q; i++)
            {
                lrs[i] = ReadInts();
            }
            for(int i = 0; i < q; i++)
            {
                int l = lrs[i][0];
                int r = lrs[i][1];
                int cost
                    = costGrid[posList[r - 1][1], posList[r - 1][2]]
                    - costGrid[posList[l - 1][1], posList[l - 1][2]];
                Console.WriteLine(cost);
            }
        }

        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


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

using namespace std;
typedef long long ll;
#define INF 1999999999
#define MODA 1000000007 
#define rep(i,n) for (long long i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

int main() {
  ll A, B, C, X, Y;
  cin >> A >> B >> C >> X >> Y;

  ll ans = 0;
  if (2*C < A+B) {
    ans += 2*C*min(X,Y);
  }
  else {
    ans += (A+B)*min(X,Y);
  }
  if(X > Y) {
    if(A < 2*C) ans += A*(X-Y);
    else ans += 2*C*(X-Y);
  }
  else {
    if(B < 2*C) ans += B*(Y-X);
    else ans += 2*C*(Y-X);
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3644
import sys
T=list(input())
Q=[i for i, x in enumerate(T) if x == '?']

if len(T)==1:
    print("D")
    sys.exit(0)

for i in Q:
    if i==0:
        if T[i+1]=="D" or T[i+1]=="?":
            T[i]="P"
        else:
            T[i]="D"
    elif i==len(T)-1:
        T[i]="D"
    else:
        if T[i-1]=="P":
            T[i]="D"
        elif T[i+1]=="D" or T[i+1]=="?":
            T[i]="P"
        else:
            T[i]="D"
print("".join(map(str, T)))

Measured memory_bytes: 20012
#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <cmath>
#define maxn 2005
#define Rint register int
#define INF 0x3f3f3f3f
using namespace std;
typedef long long lxl;

template <typename T>
inline void read(T &x)
{
	x=0;T f=1;char ch=getchar();
	while(ch<'0'||ch>'9') {if(ch=='-') f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9') {x=(x<<1)+(x<<3)+ch-'0';ch=getchar();}
	x*=f;
}

struct edge
{
	int u,v,next;
}e[maxn<<1];

int head[maxn],k;

inline void add(int u,int v)
{
	e[k]=(edge){u,v,head[u]};
	head[u]=k++;
}

int n,a[maxn];
int siz[maxn],dis[maxn],f[maxn];

inline void dfs(int u,int fa)
{
	siz[u]=a[u];
	dis[u]=0;
	int son=-1;
	for(int i=head[u];~i;i=e[i].next)
	{
		int v=e[i].v;
		if(v==fa) continue;
		dfs(v,u);
		siz[u]+=siz[v];
		dis[u]+=(dis[v]+=siz[v]);
		if(!~son||dis[son]<dis[v]) son=v;
	}
	if(!~son) return void(f[u]=0);
	if(dis[u]-dis[son]>=dis[son]) f[u]=dis[u]/2;
	else f[u]=dis[u]-dis[son]+min(f[son]*2,2*dis[son]-dis[u])/2;
}

char s[maxn];

int main()
{
	read(n);
	scanf(" %s",s+1);
	for(int i=1;i<=n;++i) a[i]=s[i]-'0';
	memset(head,-1,sizeof(head));
	for(int i=1,u,v;i<n;++i)
	{
		read(u),read(v);
		add(u,v);add(v,u);
	}
	int ans=-1;
	for(int i=1;i<=n;++i)
	{
		dfs(i,0);
		if(f[i]*2==dis[i]) ans=(!~ans||ans>f[i])?f[i]:ans;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 3352
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=1000005,INF=1<<30;

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    while(1){
        int N,M;cin>>N>>M;
        if(N+M==0) break;
        vector<int> A(N+1),B(M+1),cnt1(3000000),cnt2(3000000);
        for(int i=0;i<N;i++){
            cin>>A[i+1];
            A[i+1]+=A[i];
        }
        for(int i=0;i<M;i++){
            cin>>B[i+1];
            B[i+1]+=B[i];
        }
        
        for(int i=0;i<=N;i++){
            for(int j=i+1;j<=N;j++){
                cnt1[A[j]-A[i]]++;
            }
        }
        
        for(int i=0;i<=M;i++){
            for(int j=i+1;j<=M;j++){
                cnt2[B[j]-B[i]]++;
            }
        }
        
        ll ans=0;
        
        for(int i=0;i<=3000000;i++){
            ans+=cnt1[i]*cnt2[i];
        }
        
        cout<<ans<<endl;
    }
}



Measured memory_bytes: 26316
import sys


stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

n = ni()
s, t = input().split(" ")
ans = ""
for i in range(n):
    ans += s[i] + t[i]
print(ans)

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

int main() {
  int a , b;
  
  cin >> a >> b;
  
  if (a % 2 == 1 && b % 2 == 1) {
    cout << "Odd" << endl;
  }
  else {
    cout << "Even" << endl;
  }
}


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

using namespace std;

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define eee(a) (cerr << (#a) << ": " << (a) << endl);

using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
using mint = map<int, int>;

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

const char sp = ' ';
const char cmm = ',';
const int MOD = 1e9+7;
const int INF = 1e9;
const ll LINF = 1e18;

ll mod(ll a, ll b){
    return (a%b+b)%b;
}
ll gcd(ll a, ll b){
    return b ? gcd(b, a%b) : a;
}
ll lcm(ll a, ll b){
    return a*b/gcd(a, b);
}
void Yes(){
    cout << "Yes" << endl;
}
void No(){
    cout << "No" << endl;
}
void Judge(bool b){
    b ? Yes() : No();
}
void YES(){
    cout << "YES" << endl;
}
void NO(){
    cout << "NO" << endl;
}
void JUDGE(bool b){
    b ? YES() : NO();
}
ll powmod(ll b, ll e){
    ll r = 1; while(e > 0) {if(e&1) r = (r%MOD)*(b%MOD)%MOD; b = (b%MOD)*(b%MOD)%MOD; e >>= 1;} return r;
}
double distance(ll x1, ll y1, ll x2, ll y2){
    return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));
}

template<class T>bool chmax(T &a, const T &b) {
    if(a < b) { a = b; return 1; } return 0;
}
template<class T>bool chmin(T &a, const T &b) {
    if(b < a) { a = b; return 1; } return 0;
}
template<typename T>
void ppp(T n){
    cout << n << endl;
}
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {
    return s << "(" << p.first << ", " << p.second << ")";
}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
    int len = v.size();
    s << '[';
    for(int i = 0; i < len; ++i) {
        s << v[i]; if(i < len-1) s << ", ";
    }
    s << ']';
    return s;
}

struct aaa {
    aaa(){
        cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(15);
    };
} fastio;

int main(){

    string s;
    cin >> s;
    int n = s.size();
    vector<int> num(n, 0);
    int l = 0, r = 0;
    int st = 0, en;
    s += 'R';
    rep(i, n){
        if(s[i] == 'R' and s[i+1] == 'L') r = i, l = i+1;
        if(s[i] == 'L' and s[i+1] == 'R') {
            if(i == n) break;
            en = i;
            int len = en-st+1;
            num[r] += len/2;
            num[l] += len/2;
            if(len%2) {
                num[r] += (r-st+1)%2;
                num[l] += (l-st+1)%2;
            }
            st = i+1;
        }
    }
    for(int x : num) {
        cout << x << sp;
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 1104
N, M = map(int, input().split())
A = [int(input()) for _ in range(M)]
dp = [-1] * (N+1)
dp[0] = 1
dp[1] = 1

for a in A:
    dp[a] = 0

for i in range(2,N+1):
    if dp[i] == 0:
        pass
    else:
        dp[i] = dp[i-1] + dp[i-2]

print(dp[-1] % (1000000007)) 

Measured memory_bytes: 460020
def l_in(type_): return list(map(type_, input().split()))
def i_in(): return int(input())
def m_in(type_): return map(type_, input().split())
def r_in(n, type_): return [type_(input()) for _ in range(n)]
ans = None

def absmax(a, b):
    if abs(a) > abs(b): return a
    return b

def absmin(a, b):
    if abs(a) < abs(b): return a
    return b

a, b, c, d = m_in(int)
aa, bb, cc, dd = abs(a), abs(b), abs(c), abs(d)
x, y = 0, 0

abm = absmax(a, b)
cdm = absmax(c, d)
if (abm>0) == (cdm>0):
    ans = abm*cdm
else:
    abi = absmin(a, b)
    cdi = absmin(c, d)
    if (abi>0) == (cdm>0):
        k = abi*cdm
        if ans is None or k > ans: ans = k
    if (abm>0) == (cdi>0):
        k = abm*cdi
        if ans is None or k > ans: ans = k
    k = abi*cdi
    if ans is None: ans = k

print(ans)


Measured memory_bytes: 9264
#include <stdio.h>
#include <math.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <queue>
#include <map>
#include <utility>

using namespace std;

#define ll long long

void solve()
{
    ll N;
    string S;
    cin >> N;
    cin >> S;
    if (N % 2 != 0)
    {
        cout << "No" << endl;
        return;
    }

    if (S.substr(0, N / 2) == S.substr(N / 2))
    {
        cout << "Yes" << endl;
    }
    else
    {

        cout << "No" << endl;
    }

    return;
}

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


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

ans = 'No'
for i in range(n - m + 1):
    for j in range(n - m + 1):
        C = []
        for k in range(m):
            C.append(A[i + k][j : j + m])
        if B == C:
            ans = 'Yes'
            
print(ans)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define fastio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define ull unsigned long long
#define vi vector<int>
#define pi pair<int, int>
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define deb(x) cout << #x << ":" << x << endl;
/* freopen("input.txt", "r", stdin); */
/* freopen("output.txt", "w", stdout); */
const int MOD = 1000000007;


int main() {
	fastio();
	long double a, b;int h, m;
	cin >> a >> b >> h >> m;
	const long double PI = acos(-1);
	long double am = 6 * m;
	long double ah = (long double)h * 30.0 + (((long double)m / 60.0)*30);
	long double C = abs(am - ah);
	/* deb(am);deb(ah);deb(C); */
	if(C > 180.0)
		C = 360 - C;
	long double c = sqrt(a*a + b*b - 2*a*b*cos(C*PI/180));
	cout << setprecision(20) << c << "\n";

	return 0;
}


Measured memory_bytes: 4188
#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>

using namespace std;

int number;

int main(){
	vector<int> v;
 
	for(int i=0;i<5;i++){
		cin >> number;
		v.push_back(number);
	}

	sort(v.begin(), v.end(),greater<int>() );

	for(int i=0;i<5;i++){
		if(i<4){
			printf("%d ",v[i]);
		}else{
			printf("%d\n",v[i]);
		}
	}
}

Measured memory_bytes: 3160
#![allow(dead_code)]
use std::io;

fn main() {
    solve_b();
}

fn solve_b() {
    let mut num1 = String::new();
    io::stdin().read_line(&mut num1).unwrap();
    let num1: Vec<_> = num1.trim()
        .split_whitespace()
        .map(|s| s.parse::<u16>().unwrap())
        .collect();

    let mut n = String::new();
    io::stdin().read_line(&mut n).unwrap();
    let n = n.trim().parse::<usize>().unwrap();

    for _i in 0..n {
        let mut cmd = String::new();
        io::stdin().read_line(&mut cmd).unwrap();
        let cmd: Vec<_> = cmd.trim()
            .split_whitespace()
            .map(|s| s.parse::<u16>().unwrap())
            .collect();
        let mut num2 = num1.clone();
        for d in "HHHH N HHHH N HHHH N W HHHH W HHHH W HHHH W HHHH"
            .replace(" ", "")
            .chars()
        {
            let mut newnum = vec![0_u16; 6];
            if d == 'N' {
                // t 0 => N 4
                newnum[4] = num2[0];
                // s 1 => T 0
                newnum[0] = num2[1];
                // e 2 => e 2
                newnum[2] = num2[2];
                // w 3 => w 3
                newnum[3] = num2[3];
                // n 4 => b 5
                newnum[5] = num2[4];
                // b 5 => s 1
                newnum[1] = num2[5];
            } else if d == 'S' {
                // t 0 => s 1;
                newnum[1] = num2[0];
                // s 1 => b 5;
                newnum[5] = num2[1];
                // n 4 => t 0;
                newnum[0] = num2[4];
                // b 5 => n 4;
                newnum[4] = num2[5];

                newnum[2] = num2[2];
                newnum[3] = num2[3];
            } else if d == 'E' {
                // t 0 => e 2;
                newnum[2] = num2[0];
                // w 3 => t 0;
                newnum[0] = num2[3];
                // b 5 => w 3;
                newnum[3] = num2[5];
                // e 2 => b 5;
                newnum[5] = num2[2];

                newnum[1] = num2[1];
                newnum[4] = num2[4];
            } else if d == 'W' {
                // t 0 => w 3;
                newnum[3] = num2[0];
                // e 2 => t 0;
                newnum[0] = num2[2];
                // b 5 => e 2;
                newnum[2] = num2[5];
                // w 3 => b 5;
                newnum[5] = num2[3];

                newnum[1] = num2[1];
                newnum[4] = num2[4];
            } else {
                // t 0 => t 0;
                newnum[0] = num2[0];
                // b 5 => b 5;
                newnum[5] = num2[5];
                // s 1 => w 3;
                newnum[3] = num2[1];
                // w 3 => n 4;
                newnum[4] = num2[3];
                // n 4 => e 2;
                newnum[2] = num2[4];
                // e 2 => s 1;
                newnum[1] = num2[2];
            }
            num2 = newnum;

            if num2[0] == cmd[0] && num2[1] == cmd[1] {
                println!("{}", num2[2]);
                break;
            }
        }
    }
}



Measured memory_bytes: 5040
#include<bits/stdc++.h>
using namespace std;
int main(){
    long n,a,b,c,d;
    cin >> n >> a >> b >> c >> d;
    
    if(a>b)swap(a,b);
    
    bool chk = false;
    for(long i=0;i<=n-1;i++){
        long minn = c*i - d*(n-1-i);
        long maxx = d*i - c*(n-1-i);
        if(a+minn <= b && b <= a+maxx)chk=true;
    }
    if(chk)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    
}

Measured memory_bytes: 256
#include<bits/stdc++.h> 
#define REP(i, b) for(int i = 0; i < (b); i++)
#define REPS(i, b) for(int i = 1; i <= (b); i++)
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vb = vector<bool>;
const int INF = 1e9;
const int MOD = 1e9+7;

typedef struct
{
    ll u, v, w;
} Edge;

int N;
vector<vector<P>> adj;
vector<ll> d;

void dfs(int n, int dist)
{
    d[n] = dist;
    REP(i, adj[n].size())
    {
        if(d[adj[n][i].first] == INF) dfs(adj[n][i].first, dist+adj[n][i].second);
    }
}

signed main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    
    ll N; cin >> N;
    vector<bitset<60>> B;
    REP(i, N)
    {
        ll A; cin >> A;
        B.push_back(bitset<60>(A));
    }
    vector<int> b(60);
    REP(i, B.size())
    {
        REP(j, 60) if(B[i][j] == 1) b[j]++;
    }

    ll ans = 0;
    for(int i = 59; i >= 0; i--)
    {
        ans *= 2;
        ans += b[i] * (N-b[i]);
        ans %= MOD;
    }
    cout << ans << endl;
}

Measured memory_bytes: 6256
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define se second
#define fi first
#define ll long long
#define INF INT_MAX
#define mod 1000000007
#define chutiyaap ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using namespace std;
string str(ll i)
{
	return i<0?"":str((i/26)-1)+(char)(65+i%26);
}
int main()
{
	ll n;cin>>n;
	string su=str(n-1);
	transform(su.begin(), su.end(), su.begin(), ::tolower); 
	cout<<su;
}


Measured memory_bytes: 3596
a,b=map(int,input().split())
l=list(map(int,input().split()))
l[::-1]
s=0
f=0
for i in range(len(l)):
  s+=l[i]
  if s>=a:
    f=1
    break 
  else:
    continue
if f==1:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 20592
#include"bits/stdc++.h"
using namespace std;
using ll = int64_t;

int main() {
    ll N, X;
    cin >> N >> X;

    vector<ll> x(N);
    for (ll i = 0; i < N; i++) {
        cin >> x[i];
    }

    //逆順にして考える
    reverse(x.begin(), x.end());

    //累積和を取る
    vector<ll> sum(N + 1, 0);
    for (ll i = 0; i < N; i++) {
        sum[i + 1] = sum[i] + x[i];
    }

    //オーバーフローをansより大きいかで判定して回避するので
    //LLONG_MAXぴったりではなく多少余裕を持たせて初期化する
    ll ans = LLONG_MAX / 2;

    //k := 往復する回数
    for (ll k = 1; k <= N; k++) {
        //先頭k個は初めて取るので距離の5倍がかかる
        ll s = X * (N + k) + sum[k] * 5;

        //先頭以外
        for (ll i = k; i < N; i += k) {
            s += (sum[min(i + k, N)] - sum[i]) * ((i / k) * 2 + 3);
            if (s >= ans) {
                break;
            }
        }
        ans = min(ans, s);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3328
import java.util.*;

public class Main {
	
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		int max = 0;
		int sum = 0;
		for (int i = 0; i < N; i++) {
			int L = sc.nextInt();
			sum += L;
			if (L > max) {
				max = L;
			}
		}
		
		if (max < sum/2.0) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}


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

int main() {
  string S, T;
  cin >> S >> T;
  int sum = 0;
  if(S.at(0)==T.at(0)) sum++;
  if(S.at(1)==T.at(1)) sum++;
  if(S.at(2)==T.at(2)) sum++;
  cout << sum << endl;
  return 0;
}


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

const int MAX = 200;
int dx[4] = { -1,0,1,0 };
int dy[4] = { 0,-1,0,1 };

int main()
{
	while (true) {
		int n;
		cin >> n;

		if (n == 0) {
			break;
		}

		int x[MAX];
		int y[MAX];
		x[0] = 0;
		y[0] = 0;
		int maxx = 0, minx = 0, maxy = 0, miny = 0;

		for (int i = 1; i < n; i++) {
			int n, di;
			cin >> n >> di;

			x[i] = x[n] + dx[di];
			y[i] = y[n] + dy[di];

			maxx = max(maxx, x[i]);
			minx = min(minx, x[i]);
			maxy = max(maxy, y[i]);
			miny = min(miny, y[i]);
		}

		cout << maxx - minx + 1 << " " << maxy - miny + 1 << endl;

	}

	return 0;
}

Measured memory_bytes: 3068
import numpy as np


w, h, n = map(int, input().split())
rectangle = np.ones((w, h))

for j in range(n):
    x, y, a = map(int, input().split())
    if a == 1:
        rectangle[:x, :] = 0
    elif a == 2:
        rectangle[x:, :] = 0

    elif a == 3:
        rectangle[:, :y] = 0

    elif a == 4:
        rectangle[:, y:] = 0

print(int(np.sum(rectangle)))


Measured memory_bytes: 16020
/******************************************
* AUTHOR : GURUTEJA *
******************************************/
#include <bits/stdc++.h>
using namespace std;
#define LL long long
#define N 100005
#define MOD 1000000007
#define dd double
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep1(i,b) for(int i=1;i<=b;i++)
#define pb push_back
#define mp make_pair
#define clr(x) x.clear()
#define sz(x) ((int)(x).size())
#define F first
#define S second

void debug(){
	#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif 

}

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

    long long int a[4],x=-1e18;
    cin>>a[0]>>a[1]>>a[2]>>a[3];
    
    for(int i=0; i<2; i++){
    	for(int j=2; j<4; j++){
    		 x=max(x,(a[i]*a[j]));
    	}
    }


   cout<<x<<endl;

    return 0;
  }

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i<(int)(n); ++i)
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using Graph = vector<vi>;  // vi <=> vl
using vb = vector<bool>;
using boolGraph = vector<vb>;
using P = pair<int, int>;  // int <=> ll
const int MOD = 1e9+7;
const double EPS = 1e-9;

int main() {
  int n; cin >> n;
  vi arr(n);
  rep(i,n) cin >> arr[i];

  unordered_map<int, int> odd, even;
  rep(i,n) i%2 ? ++odd[arr[i]] : ++even[arr[i]];

  P odd1, odd2, even1, even2;
  odd1 = odd2 = even1 = even2 = P(0,0);

  for (auto p : odd) {
    if (p.second > odd2.second) {
      odd2 = p;
      if (odd2.second > odd1.second) swap(odd1, odd2);
    }
  }
  for (auto p : even) {
    if (p.second > even2.second) {
      even2 = p;
      if (even2.second > even1.second) swap(even1, even2);
    }
  }

  int keep = odd1.second + even1.second;
  if (odd1.first == even1.first) {
    int odd_dec = odd1.second - odd2.second;
    int even_dec = even1.second - even2.second;
    keep -= odd_dec < even_dec ? odd_dec : even_dec;
  }

  cout << n - keep << endl;
  return 0;
}


Measured memory_bytes: 4760
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<deque>
#include<queue>
#include<stack>
#include <ctime>
using namespace std;
#define int long long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define dup(x,y) (((x)+(y)-1)/(y))
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef pair<int, int>P;
const int MOD = 1e9 + 7;
//const int MOD = 998244353;
const int INF = 1e18;
const long double PI = (acos(-1));

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

signed main() {
	int H, W;
	int sh, sw, gh, gw;
	cin >> H >> W >> sh >> sw >> gh >> gw;
	vector<string>S(H);
	rep(i, H)cin >> S[i];
	sh--; sw--; gh--; gw--;
	deque<P>q;
	q.push_back(P(sh, sw));
	vector<vector<int>>d(H, vector<int>(W, INF));
	d[sh][sw] = 0;
	while (q.size()) {
		P p = q.front();
		q.pop_front();
		rep(i, 4) {
			int nh = p.first + dx[i];
			int nw = p.second + dy[i];
			int nd = d[p.first][p.second];
			if (nh < 0 || nh >= H || nw < 0 || nw >= W)continue;
			if (S[nh][nw] == '#')continue;
			if (d[nh][nw] <= nd)continue;
			q.push_front(P(nh, nw));
			d[nh][nw] = nd;
		}

		rep(i, 5)rep(j, 5) {
			if (abs(i - 2) + abs(j - 2) < 2)continue;
			int nh = p.first + i - 2;
			int nw = p.second + j - 2;
			int nd = d[p.first][p.second] + 1;
			if (nh < 0 || nh >= H || nw < 0 || nw >= W)continue;
			if (S[nh][nw] == '#')continue;
			if (d[nh][nw] <= nd)continue;
			q.push_back(P(nh, nw));
			d[nh][nw] = nd;
		}
	}
	if (d[gh][gw] == INF) cout << -1;
	else cout << d[gh][gw];
}

Measured memory_bytes: 13472
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define ll long long
#define ld long double
using namespace std;
const int N = 2e5 + 5;
vector<int>edges[N];
int n, m, u, v, ans[N];
bool vis[N];
void bfs(int node){
    queue<int>q;
    q.push(node);
    vis[node] = 1;
    while(!q.empty()){
        node = q.front();
        q.pop();
        for(auto i : edges[node]){
            if(vis[i]) continue;
            ans[i] = node;
            q.push(i);
            vis[i] = 1;
        }
    }
}
int main()
{
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    cin >> n >> m;
    for(int i = 0; i < m; i++){
        cin >> u >> v;
        edges[u].push_back(v);
        edges[v].push_back(u);
    }
    for(int i = 1; i <= n; i++){
        if(!vis[i]){
            bfs(i);
            if(i != 1) return cout << "No", 0;
        }
    }
    cout << "Yes\n";
    for(int i = 2; i <= n; i++)
        cout << ans[i] << '\n';
    return 0;
}


Measured memory_bytes: 12904
import java.util.Scanner;

public class Main {

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

		int H = Integer.parseInt(s.next());
		int N = Integer.parseInt(s.next());
		int n = Integer.parseInt(s.next());
		int h = Integer.parseInt(s.next());

		int trouts = H * N;
		int vm = H * h;
		int hm = n * N;
		int crossNum = h * n;

		System.out.println(trouts - (vm + hm - crossNum));
	}
}

Measured memory_bytes: 23124
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
#include <bitset>
#include <list>
#include <iomanip>
using namespace std;
#define rep(i,a,n) for(ll i=a;i<n;i++)
#define rrep(i,a,n) for(ll i=n;i>=a;i--)
#define elif else if
#define all(s) s.begin(),s.end()
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF = 1e+17;
const ll MODcdf = 998244353;
bool pairCompare(const P& firstElof,const P& secondElof){
    return firstElof.first<secondElof.first;
}
string A="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string a="abcdefghijklmnopqrstuvwxyz";
int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    ll n,k;cin>>n>>k;
    ll seki[n];
    ll we=0;
    rep(i,0,n)seki[i]=0;
    rep(i,0,n){
        ll memo=(i+1);
        //cout<<i+1<<"番目の計算開始"<<endl;
        while(1){
            //cout<<++we<<"回目"<<endl;
            //cout<<memo<<endl;
            if(memo>=k)break;
            memo*=2;
            seki[i]++;
            
        }
        we=0;
    }
    long double sum;
    long double ans=0.00000000000;
    rep(i,0,n){
        sum=pow(2,seki[i]);
        //cout<<"sum is "<<sum<<endl;
        ans+=1/sum;
        //cout<<"Now ans is "<<ans<<endl;
    }
    ans/=n;
    cout<<fixed<<setprecision(13)<<ans<<endl;
}


Measured memory_bytes: 1024
#include<stdio.h>

int main(){
    int N;
    int A[20];
    int B[20];
    int C[20];
    int i;
    while(~scanf("%d",&N)){
        for(i = 0; i < N; i++)
            scanf("%d",&A[i]);
        for(i = 0; i < N; i++)
            scanf("%d",&B[i]);
        for(i = 0; i < N-1; i++)
            scanf("%d",&C[i]);
        int sum = B[A[N-1]-1];
        for(i = 0; i < N-1; i++){
            sum+=B[A[i]-1];
            if(A[i+1] - A[i] == 1){
                sum+=C[A[i]-1];
            }
        }
        printf("%d\n",sum);
    }
    return 0;
}


Measured memory_bytes: 128
def vector(x, y)
  [y[0] - x[0], y[1] - x[1]]
end

def direction(x, y)
  x[0] * y[1] - x[1] * y[0] > 0 ? :+ : :-
end

STDIN.read.split("\n").each do |input|
  a, b, c, d = input.split(' ').map { |f| f.chomp.to_f }.each_slice(2).to_a

  result = [[a, b], [b, c], [c, a]].map do |s, e|
    direction(vector(s, e), vector(e, d))
  end
  puts result.uniq.size == 1 ? 'YES' : 'NO'
end

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


using namespace std;

int main() {
  int n,m; //n個, m枚
  cin >> n >> m;
  
  vector<int> a(n, 0);
  std::priority_queue<int> q;


  for(int i=0; i< n;i++){
    int l;
    cin >> l;
    q.push(l);
    a.at(i) = l;
  }
  
  int m_count = 0;
  while(m_count < m){
    int t;
    t = q.top();
    q.pop();
    q.push((int)t/2);
    m_count++;
  }
 
  long long count = 0;

  while(!q.empty()){
    count = count + q.top();
    q.pop();
  }
  
  cout << count << endl;
}

Measured memory_bytes: 1276
#include<bits/stdc++.h>
using namespace std;
int main()
{
    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
      
   	long long int a,h;
   	double b;
   	cin>>a>>b;
   	  h=a*b;
   	cout<<h;


    return 0;
}


Measured memory_bytes: 3704
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
      ll a,b,c;
      cin>>a>>b>>c;
      if(a<=(b*c))
      {
            cout<<"Yes"<<endl;
      }
      else
            cout<<"No"<<endl;
      return 0;
}


Measured memory_bytes: 3624
def readinput():
    s = input()
    return s

def compare(s):
    # dreameraser
    # dreamerase
    # dreamer
    # dream
    # eraser
    # erase
    if (s[0:11] == 'dreameraser'):
        return 11
    elif (s[0:10] == 'dreamerase'):
        return 10
    elif (s[0:7] == 'dreamer'):
        return 7
    elif (s[0:5] == 'dream'):
        return 5
    elif (s[0:6] == 'eraser'):
        return 6
    elif (s[0:5]=='erase'):
        return 5
    else:
        return 0

def main(s):
    p=0 # 比較する部分列の先頭
    while(p<=len(s)):
        if(p==len(s)):
            return True
        q = compare(s[p:])
        if(q==0):
            return False
        p += q
    return False

if __name__=='__main__':
    s = readinput()
    ans = main(s)
    if(ans == True):
        print('YES')
    else:
        print('NO')
 

Measured memory_bytes: 3188
#include<bits/stdc++.h>
    #define vll vector<ll>
    #define vi vector<int>
    #define vpll vector<pair<ll,ll>>
    #define pii pair<int,int>
    #define REP(i,a) for(int (i)=0; (i)<(a); (i)++)
    #define RREP(i,a) for(int (i)=a-1; (i)>=(0); (i)--)
    #define REP2(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
    #define MOD 1000000007
    #define ALL(v) v.begin(), v.end()
    #define m0(x) memset(x,0,sizeof(x))
    typedef long long ll;
     
    using namespace std;
     
    int gcd(int a,int b){return b?gcd(b,a%b):a;}
    int dx[4]={1,0,-1,0};
    int dy[4]={0,1,0,-1};
     
     
     
    int main(){
      ios_base::sync_with_stdio(false);
      cin.tie(NULL);
      ll N;
      cin >> N;
      cout << N*(N-1)/2;
      return 0;
    }

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>

using namespace std;
using ll = long long;

void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
int gcd(int a, int b){ return (b == 0) ? a : gcd(b, a % b); }
template<typename S, typename T> ostream& operator<<(ostream &os, const pair<S, T> &p){ cout << "[" << p.first << ", " << p.second << "]"; return os; }

#define Sq(x) (x)*(x)
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Search(rb, re, x) distance(rb, find(rb, re, x))
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Reverse(c) reverse(Range(c))
#define Unique(a) a.erase(unique(Range(a)), a.end())
#define Cusum(T, xs, sxs) vector<T> sxs(xs.size()+1); For(i, (int)xs.size()) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinss(T, n, m, xs) Vec2(T, n, m, xs); For(i, n) For(j, m) cin >> xs[i][j]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) { for(const auto &e : xs) cout << e << " "; cout << "\n"; }
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")
#define Return(expr) { Cout(expr); return 0; }
#define vc vector
#define Mini(a, x) a = min(a, x)
#define Maxi(a, x) a = max(a, x)

// constexpr int MOD = 1e9+7;

int main(void){
    Cin(int, a, b, c, d);
    Cout((b >= a) ? "unsafe" : "safe");
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
// memo  fixed  setprecision(20);
using vvll = vector<vector<ll>>;
ll mod =1000000007;
/*"itob" int to "N"base */           template<typename TypeInt> string itob(const TypeInt v, int base){static const char table[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";string ret;static numeric_limits<TypeInt> t;TypeInt n = v;if (t.is_signed) {if (v < 0) n *= -1;}while (n >= base) {ret += table[n%base];n /= base;}ret += table[n];if (t.is_signed) {if (v < 0 && base == 10) ret += '-';}reverse(ret.begin(), ret.end());return ret;}
/*"chmin" a = MAX*/                  template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
/*"chmax" a = MIN*/                  template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
/*"ctoi"  char to int*/              int ctoi(char c) {return c-'0';}
/*"gcd"   MAX*/                      int gcd(ll a,ll b){return b?gcd(b,a%b):a;}
/*"lcm"   MIN*/                      int lcm(ll a,ll b){return a*b/gcd(a,b);}
/*"primecheck"If prime,return true.*/bool primecheck(ll n){if(n < 2) return false;else{for(int i = 2; i * i <= n; i++){if(n % i == 0) return false;}return true;}}
string  reverserange(string s,ll a,ll b){reverse(s.begin()+a-1,s.begin()+b); return s;}

int main(){
    int k;
    cin >> k;
    queue<ll>que;
    for(int i=1;i<=9;i++){
        que.push(i);
    }
    ll che = 0;
    for(int i=0;i<k;i++){
        che = que.front();
        que.pop();
        ll keta  = che%10;
        ll now = che*10;
        if(keta==0){
            now+=keta;
            que.push(now);
            now++;
            que.push(now);
        }
        else if(keta==9){
            now+=keta;
            now--;
            que.push(now);
            now++;
            que.push(now);
        }
        else {
            now+=keta;
            now--;
            que.push(now);
            now++;
            que.push(now);
            now++;
            que.push(now);
        }
    }
    cout << che << endl;

}



Measured memory_bytes: 1792
program main
  implicit none
  integer :: n
  read(*, *) n
  if (mod(n, sn(n)) == 0) then
    write(*, "(a)") "Yes"
  else
    write(*, "(a)") "No"
  end if
  contains

  function sn(n)
    implicit none
    integer, intent(in) :: n
    integer :: sn, i, d
    character(10) :: st
    write(st, "(i10)") n  ! int to string
    sn = 0
    do i = 1, 10
      read(st(i:i), "(i1)") d  ! char to int
      sn = sn + d
    end do
  end function sn
end program main


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cassert>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#include <random>
#include <complex>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<P,int> pip;
typedef vector<pip> vip;
const int inf=1<<29;
const ll INF=1ll<<58;
const double pi=acos(-1);
const double eps=1e-7;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

class Graph{
	private:
	int V;
	vvi g;
	map<ull,ll> m;
	vi used;
	ull dfs(int v){
		used[v]=1;
		ull H=1;
		for(int i=0;i<g[v].size();i++){
			int u=g[v][i];
			if(!used[u]) H+=dfs(u)*mod;
		}
		m[H]++;
		return H;
	}
	public:
	Graph(int v){
		V=v;
		g=vvi(v);
	}
	void add_edge(int s,int t){
		g[s].push_back(t);
		g[t].push_back(s);
	}
	ll solve(){
		ll res=0;
		used=vi(V);
		dfs(0);
		for(auto i=m.begin();i!=m.end();i++){
			ll v=i->second;
			res+=v*(v-1)/2;
		}
		return res;
	}
};

int n;

int main(){
	cin>>n;
	Graph g(n);
	for(int i=1;i<n;i++){
		int u,v;
		cin>>u>>v;
		g.add_edge(u-1,v-1);
	}
	cout<<g.solve()<<endl;
}

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

#define ll long long
#define all(x) (x).begin(),(x).end()
#define dlog(x) cout<<#x<<'='<<x<<'\n'

using namespace::std;

int main(){
      ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
      int n,m; cin>>n>>m;
      puts(n==m?"Yes":"No");
      return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
using namespace std;

#define int long long
//typedef    long long          ll;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      P;
 
const int INF=1e+9;
const double EPS=1e-9;
const int MOD=1000000007;
 
const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

signed main(){
	int a,b,c,d;
	cin >> a >> b >> c >> d;
	cout << max(a * b,c * d) << endl;
	return 0;
}

Measured memory_bytes: 256
// D - Cake 123

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

ll A[1000], B[1000], C[1000];


int main() {
	ll X, Y, Z, K;
	cin >> X >> Y >> Z >> K;

	for (int i=0; i<X; i++) {
		cin >> A[i];
	}

	for (int i=0; i<Y; i++) {
		cin >> B[i];
	}

	for (int i=0; i<Z; i++) {
		cin >> C[i];
	}

	vector<ll> P;
	P.reserve(X*Y);
	for (int i=0; i<X; i++) {
		for (int j=0; j<Y; j++) {
			P.push_back(A[i] + B[j]);
		}
	}

	sort(P.begin(), P.end(), greater<ll>());

	vector<ll> Q;
	Q.reserve(K * Z);
	for (int i=0; i<min(K, X*Y); i++) {
		for (int j=0; j<Z; j++) {
			Q.push_back(P[i] + C[j]);
		}
	}

	sort(Q.begin(), Q.end(), greater<ll>());

	for (int i=0; i<K; i++) {
		cout << Q[i] << endl;
	}

	return 0;
}

Measured memory_bytes: 34652
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = pow(10, 9) + 7;
//const ll MOD = 998244353;
//const ll MOD = ;
ll mod(ll A, ll M) {return (A % M + M) % M;}
const ll INF = 1LL << 60;
template<class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
ll divceil(ll A, ll B) {return (A + (B - 1)) / B;}
ll myctoi(char C) {return C - '0';}
char myitoc(ll N) {return '0' + N;}
#define FINALANS(A) {cout << (A) << endl; exit(0);}

vector<vector<pair<ll, ll>>> G(111);
vector<bool> visited(111, false);
ll ng;
void dfs(ll V)
{
  if (visited.at(V))
    return;
  visited.at(V) = true;

  for (auto v : G.at(V))
  {
    if (ng != v.second)
      dfs(v.first);
  }
}

int main()
{
  ll N, M;
  cin >> N >> M;
  for (ll i = 0; i < M; i++)
  {
    ll a, b;
    cin >> a >> b;
    a--, b--;
    G.at(a).push_back(make_pair(b, i));
    G.at(b).push_back(make_pair(a, i));
  }

  ll ans = 0;
  for (ng = 0; ng < M; ng++)
  {
    visited = vector<bool>(111, false);
    dfs(0);

    for (ll i = 0; i < N; i++)
    {
      if (!visited.at(i))
      {
        ans++;
        break;
      }
    }
    //cerr << ng << " " << ans << endl;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <iostream>
#include <queue>
#include <set>
#include <string>
#include <utility>
using namespace std;

#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define RFOR(i, a, b) for (int i = a; i > b; --i)
#define REP(i, n) for (int i = 0; i < n; ++i)

int A, B, C, X;
int ans = 0;

void Sub(int b, int c, int x) {
  REP(i, b+1) {
    if (x - 100*i < 0) { break; }
    if (x - 100*i <= 50*c) { ++ans; }
  }
  return;
}

int main() {
  cin >> A >> B >> C >> X;

  REP(i, A+1) {
    if (X - 500*i < 0) { break; }
    Sub(B, C, X - 500*i);
  }

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


Measured memory_bytes: 256
while True:
    n,x=map(int,input().split())
    if n+x==0:break
    ans = 0
    for i in range(1,n+1):
      for j in range(i+1,n+1):
        for k in range(j+1,n+1):
          if i+j+k==x:ans+=1
    print(ans)


Measured memory_bytes: 5596
#include<iostream>
#include<string>
#include <cmath>
#include <ctype.h>
using namespace std;
string S;
int main() {
    cin >> S;
    
    int a=0, z=0;
    for(int i=0, n=S.size(); i<n; ++i){
        if(S[i]=='A'&&a==0) a=i+1;
        if(S[i]=='Z') z=i+1;
    }
    cout << z-a+1 << endl;
    return 0;
}

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



int main(){
	int n;
	cin>>n;
	int V[n], C[n];
	int ans[n];
	for (int i = 0; i <n ; ++i)cin>>V[i];
	for (int i = 0; i <n ; ++i)cin>>C[i];
	for (int i = 0; i < n; ++i)
		ans[i] = V[i]-C[i];
	sort(ans,ans+n);

	int maxi =0;
	for (int i = 0; i < n; ++i)
	{
		int suma =0;
		for (int j = i; j < n; ++j)
			suma +=ans[j];
		maxi = max(suma,maxi);
	}
	cout<<maxi;
}

Measured memory_bytes: 256
def resolve():
    s = int(input())
    hist = set([])
    idx = 1
    while True:
        if s in hist:
            print(idx)
            return
        hist.add(s)
        idx += 1
        if s%2==0:
            s //= 2
        else:
            s = 3*s + 1



if '__main__' == __name__:
    resolve()

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

int main(){
    while(1){
        int H,W;
        cin>>H>>W;
        if(H==0&&W==0)break;
        for(int i=0;i<H;i++){
            for(int j=0;j<W;j++){
                if(i%2==0&&j%2==0)cout<<'#';
                else if(i%2==0&&j%2==1)cout<<'.';
                else if(i%2==1&&j%2==0)cout<<'.';
                else cout<<'#';
            }
            cout << endl;
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3080
#include <bits/stdc++.h>
#define rep(i, a, b) for(ll i = ll(a); i < ll(b); i++)
#define rer(i, a, b) for(ll i = ll(a) - 1; i >= ll(b); i--)
#define sz(v) (int)(v).size()
#define pb push_back
#define sc second
#define fr first
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
using namespace std;
typedef long long int ll;
typedef pair <int, int> P;

const ll MOD=1000000007;
ll N;
vector<ll> C;
ll cnt[200010];
ll dp[200010];
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>N;
    rep(i,0,N){
        ll c;
        cin>>c;
        C.pb(c-1);
    }
    uniq(C);
    N=sz(C);
    dp[0]=1;
    cnt[C[0]]=1;
    rep(i,1,N){
        dp[i]=(dp[i-1]+cnt[C[i]])%MOD;
        cnt[C[i]]+=dp[i-1];
        cnt[C[i]]%=MOD;
    }
    cout <<dp[N-1]<<"\n";
}

Measured memory_bytes: 5104
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <tuple>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <numeric>
#include <string.h>
using namespace std;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const long long INFL = 1e18;
const int MOD = 1000000007;
string S, T;
const int MAX = 210000;
void calc(string& S) {
    map<char, char> to;
    char t = 'a';
    for (auto& c : S) to.count(c) ? c = to[c] : c = to[c] = t++;
}

void solve() {
    cin >> S >> T;
    calc(S);
    calc(T);
    puts(S == T ? "Yes" : "No");
    return;
}
//逆元を求める関数
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++) {
      fac[i] = fac[i-1] * i % MOD;
      inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
      finv[i] = finv[i-1] * inv[i] % MOD;
    }
}
//組み合わせ
long long COM (int n, int k) {
    if(n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD;
}
int main(int args, char* argv[]) {
    solve();
}



Measured memory_bytes: 776
import math
A, B, N = list(map(int, input().split(" ")))

def tgt(A,B,d):
    return math.floor(A * d / B)

if N >= B-1:
    d_max = B-1
else: # N< B-1
    d_max = N

ret = tgt(A,B,d_max)

print(ret)





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

int main(){
    int N, Q;
    string S;
    cin >> N >> Q >> S;
    int l[N], r[N];

    int where[N];
    int sum=0;
    for (int i=0; i<N; i++) where[i] = 0;
    for (int i=0; i<(N-1); i++){
        if (S.at(i) == 'A' && S.at(i+1) == 'C'){
            sum++;
        }
        where[i+1] = sum;
    }

    for (int i=0; i<Q; i++){
        cin >> l[i] >> r[i];
        l[i] -= 1;
        r[i] -= 1;

        cout << where[r[i]]-where[l[i]] << endl;
    }
}

Measured memory_bytes: 2176