akhauriyash/Code-Regression huggingface dataset:
A,B,C,D = list(map(int, input()))
flag = 0
for op1 in ["+", "-"]:
    if flag:
        break
    tmp1 = A+B if op1=="+" else A-B
    for op2 in ["+", "-"]:
        if flag:
            break
        tmp2 = tmp1+C if op2=="+" else tmp1-C
        for op3 in ["+", "-"]:
            if flag:
                break
            tmp3 = tmp2+D if op3=="+" else tmp2-D
            if tmp3==7:
                ans = str(A)+op1+str(B)+op2+str(C)+op3+str(D)+"=7"
                print(ans)
                flag = 1
                break

Measured memory_bytes: 61852
#1文とは限らない
alp ="abcdefghijklmnopqrstuvwxyz"

import sys

inpt = []
for _ in sys.stdin:
    inpt.append(_.lower())
#print(inpt)

ans = [0]*26

for strng in inpt:
    for i in range(len(strng)):
        for j in range(26):
            if strng[i] == alp[j]:
                ans[j] += 1
            
for j in range(26):
    print(alp[j],":",ans[j])



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

int main() {
    list<int> l;
    int n;
    string cmd;
    int x;

    cin >> n;
    for(int i=0; i<n; i++){
        cin >> cmd;
        if(cmd == "insert"){
            cin >> x;
            l.push_front(x);
        }else if(cmd == "delete"){
            cin >> x;
            auto it = find(begin(l), end(l), x);
            if(it != l.end()){
                l.erase(it);
            }
        }else if(cmd == "deleteFirst"){
            l.pop_front();
        }else{
            l.pop_back();
        }
    }
    for(auto it=l.begin(); it != l.end();){
        cout << *it;
        it++;
        if(it == l.end()){
            cout << endl;
        }else{
            cout << ' ';
        }
    }
}

Measured memory_bytes: 34448
#include<bits/stdc++.h>
#include"unistd.h"
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define all(v) v.begin(),v.end()
#define P pair<int,int>
#define len(s) (int)s.size()
#define pb push_back

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;
}
constexpr int mod = 1e9+7;
constexpr int inf = 3e18;

int gcd(int x,int y){
	return y?gcd(y,x%y):x;
}
signed main(){
	int T;cin>>T;
	while(T--){
		int a,b,c,d;cin>>a>>b>>c>>d;
		if(a<b)puts("No");
		else if(d<b)puts("No");
		else if(c>=b)puts("Yes");
		else {
			int mx=b-gcd(b,d)+a%gcd(b,d);
			if(mx>c%b)puts("No");
			else puts("Yes");
		}
	}
}


Measured memory_bytes: 256
from collections import defaultdict
H,W = map(int,input().split())
d = defaultdict(int)
for _ in range(H):
    for c in list(input()):
        d[c] += 1
for i in range((H-1)//2+1):
    for j in range((W-1)//2+1):
        s = set([(x,y) for x,y in [(i,j),(i,W-1-j),(H-1-i,j),(H-1-i,W-1-j)] if 0<=x<H and 0<=y<W])
        f = True
        for k,_ in sorted(d.items(),key=lambda x:x[1]):
            if d[k] >= len(s):
                d[k] -= len(s)
                f = False
                break
        if f:
            print("No")
            exit(0)
print("Yes")

Measured memory_bytes: 9416
#include<algorithm>
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<cstdio>
#include<vector>
#include<queue>
#include<stack>
#include<cmath>
#include<list>
using namespace std;

typedef struct{int a;int b;int c;} arr;
typedef pair<long long,long long> logg;

arr L[510],R[510];

int merge(arr a[],int l,int m,int r,char c)
{
	int n1=m-l;
	int n2=r-m;
	for(int i=0;i<n1;i++)
	{
		L[i]=a[l+i];
	}
	for(int i=0;i<n2;i++)
	{
		R[i]=a[m+i];
	}
	int i=0,j=0;
	if(c=='a')
	{
		L[n1].a=100000;R[n2].a=100000;
		for(int k=l;k<r;k++)
		{
			if(L[i].a<=R[j].a)
			{
				a[k]=L[i++];
			}
			else
			{
				a[k]=R[j++];
			}
		}
	}
	else
	{
		L[n1].c=100000;R[n2].c=100000;
		for(int k=l;k<r;k++)
		{
			if(L[i].c<=R[j].c)
			{
				a[k]=L[i++];
			}
			else
			{
				a[k]=R[j++];
			}
		}
	}
}

int mergeS(arr a[],int l,int r,char c)
{
	if(l+1<r)
	{
		int m=(l+r)/2;
		mergeS(a,l,m,c);
		mergeS(a,m,r,c);
		merge(a,l,m,r,c);
	}
}


int main()
{
	int n,j=1;cin>>n;
	arr a[1010];
	logg c[1010];
	for(int i=1;i<=n;cin>>a[i++].a);a[n+1].a==1;
	
	
	for(int i=1;i<=n;a[i].c=i,i++);
	mergeS(a,1,n+1,'a');
	int mm=a[1].a;
	for(int i=1;i<=n;a[i].b=i,i++);
	mergeS(a,1,n+1,'c');
	for(int i=1,m=100000;;)
	{
		if(a[i].b!=0)//.b
		{
			c[j].first++;
			c[j].second+=a[i].a;
			if(a[i].a<m)m=a[i].a;
			int l=a[i].b;//.b
			a[i].b=0;//.b
			i=l;
		}
		else
		{
			if(c[j].first==1)
			{
				c[j].second=0;
			}
			else if(c[j].first>=3)
			{
				int ss=c[j].second;
				c[j].second+=m*(c[j].first-2);
				if(ss+m+(c[j].first+1)*mm<c[j].second)c[j].second=ss+m+(c[j].first+1)*mm;
			}
			m=100000;
			j++;
			int s=0;
			for(int k=1;k<=n;k++)
			{
				s+=a[k].b;//a
				if(a[k].b!=0)i=k;//a
			}
			if(s==0)break;
		}
	}
	long long s=0;
	for(int i=1;i<=j;i++)
	{
		s+=c[i].second;
	}
	cout<<s<<endl;
	return 0;
}

Measured memory_bytes: 3100
#include <cstdio>
#include <algorithm>

using namespace std;

int main() {
    size_t n;
    scanf("%zu", &n);

    int min_=1<<30;
    int res=-min_;
    for (size_t i=0; i<n; ++i) {
        int R;
        scanf("%d", &R);

        if (i)
            res = max(res, R-min_);

        if (min_ > R)
            min_ = R;
    }

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

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

bool isprime(int n){
    double rootn = sqrt(n);
    if (n < 2){
        return false;
    }
    else if (n == 2){
        return true;
    }
    else if (n % 2 == 0){
        return false;
    }
    else{
        for(int i = 3; i <= rootn; i += 2){
            if(n % i == 0){
                return false;
            }
        }
        return true;
    }
}

// 空のベクトルを二つ渡す。N (>=2) 以下の素数を primes に順番に入れる。
void prime_vectors(int N, vector<int>& primes, vector<bool>& is_prime){
    primes = {};
    is_prime = {};
    for(int i=0; i<=N; i++){
        is_prime.push_back(true);
    }

    primes.push_back(2);
    for(int j=4; j<=N; j+=2){
        is_prime[j] = false;
    }

    int i;
    for(i=3; i*i<=N; i+=2){
        if(!is_prime[i]) continue;
        primes.push_back(i);
        for(int j=2*i; j<=N; j+=i){
            is_prime[j] = false;
        }
    }

    for(; i<=N; i+=2){
        if(is_prime[i]){
            primes.push_back(i);
        }
    }
}

signed main(){
    // cout << fixed << setprecision(10) << flush;

    int a, b, c, x, y;
    cin >> a >> b >> c >> x >> y;

    #if 0
    int min_price = x*a + y*b;
    for(int i=0; i<=max(x,y); i++){
        // AB を 2*i 枚, A を x - i or 0, B を y - i or 0
        int price = 0;
        price = a*max(x-i, 0) + b*max(y-i, 0) + c*2*i;
        min_price = min(min_price, price);
    }
    cout << min_price << endl;
    #else
    if(a+b < 2*c){
        cout << a*x + b*y << endl;
    }
    else{
        int i = min(x, y);
        cout << c*2*i + min(a, 2*c)*max(x-i, 0) + min(b, 2*c)*max(y-i, 0) << endl;
    }
    #endif

    return 0;
}

Measured memory_bytes: 3648
const lines=readlines()
input()=shift!(lines)
int(x)=parse(Int,x)
function intLine()
    s=input()|>split
    int(s[1]),int(s[2])
end
function bfs(n,e,s,t)
    f=ones(Int,(n,3))*-3
    f[s,1]=0
    q=Array{Pair{Int,Int}}([s=>1])
    while !isempty(q)
        v,m=shift!(q)
        if v==t&&m==1;break;end
        u=m>2?1:m+1
        for w=e[v]
            if f[w,u]<0
                f[w,u]=f[v,m]+1
                push!(q,w=>u)
            end
        end
    end
    f[t,1]÷3
end
function main()
    n,m=intLine()
    e=Array{Int,1}[[]for i=1:n]
    for i=1:m
        u,v=intLine()
        push!(e[u],v)
    end
    s,t=intLine()
    show(bfs(n,e,s,t))
end
main()

Measured memory_bytes: 166600
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

const ll INF = 1000000000000000000LL;
const int MAX_N = 200005;

int n;
ll h[MAX_N];
ll a[MAX_N];
ll t[4 * MAX_N];
ll dp[MAX_N];

void setValue(int i, int l, int r, int pos, ll val)
{
	if (l == r)
		t[i] = max(t[i], val);
	else
	{
		int mid = (l + r) / 2;
		if (pos <= mid)
			setValue(2 * i + 1, l, mid, pos, val);
		else
			setValue(2 * i + 2, mid + 1, r, pos, val);
		t[i] = max(t[2 * i + 1], t[2 * i + 2]);
	}
}

ll maxOnRange(int i, int l, int r, int lx, int rx)
{
	if (l == lx && r == rx)
		return t[i];
	else
	{
		int mid = (l + r) / 2;
		ll result = -INF;
		if (lx <= mid)
			result = max(result, maxOnRange(2 * i + 1, l, mid, lx, min(rx, mid)));
		if (rx > mid)
			result = max(result, maxOnRange(2 * i + 2, mid + 1, r, max(lx, mid + 1), rx));
		return result;
	}
}

int main()
{
	ios::sync_with_stdio(false);
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> h[i];
		h[i]--;
	}
	for (int i = 0; i < n; i++)
		cin >> a[i];

	for (int i = 0; i < 4 * MAX_N; i++)
		t[i] = -INF;
	for (int i = 0; i < n; i++)
	{
		dp[i] = a[i];
		ll val = maxOnRange(0, 0, n - 1, 0, h[i]);
		if (val != -INF)
			dp[i] = a[i] + val;
		setValue(0, 0, n - 1, h[i], dp[i]);
	}

	ll result = 0;
	for (int i = 0; i < n; i++)
		result = max(result, dp[i]);
	cout << result << endl;
}

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

int main()
{
	string s;
	int n, i;
	n = 0;
	while (cin>>s) {
		n++;
		for (i = 0; i < s.size()/2; i++) {
			if (s[i] != s[s.size()-i-1]) {
				n--;
				break;
			}
		}
	}
	cout<<n<<endl;
	return 0;
}

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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define MP make_pair
#define PB push_back
#define MOD 1000000007
#define INF (1LL << 30)
#define LLINF (1LL << 60)
#define PI 3.14159265359
#define EPS 1e-10
#define int ll

struct vector2D {long double x, y;};

long double multiply(vector2D a, vector2D b) {
  return a.x*b.x + a.y*b.y;
}

signed main(void) {
  long double x[4], y[4];
  while (cin >> x[0] >> y[0] >> x[1] >> y[1] >> x[2] >> y[2] >> x[3] >> y[3]) {
    vector2D a, b;
    a.x = x[1] - x[0];
    a.y = y[1] - y[0];
    b.x = x[3] - x[2];
    b.y = y[3] - y[2];

    if(multiply(a, b) == 0) {
      cout << "YES" << endl;
    } else {
      cout << "NO" << endl;
    }
  }

  return 0;
}

Measured memory_bytes: 3056
import java.util.Scanner;

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

    int[][] grids = new int[100][100];
    for (int i = 0; i < 50; i++) for (int j = 0; j < 100; j++) grids[i][j] = 1;

    for (int i = 1; i < 50 && A > 0; i += 2) {
      for (int j = 1; j < 99 && A > 0; j += 2) {
        grids[i][j] = 0;
        A--;
      }
    }
    for (int i = 51; i < 100 && B > 0; i += 2) {
      for (int j = 1; j < 99 && B > 0; j += 2) {
        grids[i][j] = 1;
        B--;
      }
    }

    System.out.println("100 100");
    for (int i = 0; i < 100; i++) {
      for (int j = 0; j < 100; j++) System.out.print(grids[i][j] == 0 ? '.' : '#');
      System.out.println();
    }
  }
}


Measured memory_bytes: 27476
package main

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

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string   { sc.Scan(); return sc.Text() }
func scanRunes() []rune    { return []rune(scanString()) }
func scanInt() int         { a, _ := strconv.Atoi(scanString()); return a }
func scanInt64() int64     { a, _ := strconv.ParseInt(scanString(), 10, 64); return a }
func scanFloat64() float64 { a, _ := strconv.ParseFloat(scanString(), 64); return a }

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = scanInt()
	}
	return res
}

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

//•*¨*•.¸¸♪main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)
func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	n, q := scanInt(), scanInt()
	c := scanInts(n)

	t := make([]triple, q)
	for i := 0; i < q; i++ {
		t[i] = triple{scanInt() - 1, scanInt() - 1, i}
	}
	sort.Slice(t, func(i, j int) bool { return t[i].b < t[j].b })

	d := make([]int, n)
	for i := 0; i < n; i++ {
		d[i] = -1
	}
	bit := make(binaryIndexedTree, n+1)

	idx := 0
	ans := make([]int, q)
	for i := 0; i < q; i++ {
		for idx <= t[i].b {
			bit.add(d[c[idx]-1], -1)
			d[c[idx]-1] = idx
			bit.add(idx, 1)
			idx++
		}
		ans[t[i].c] = bit.sum(t[i].b) - bit.sum(t[i].a-1)
	}
	for i := 0; i < q; i++ {
		fmt.Fprintln(wr, ans[i])
	}

}

type triple struct{ a, b, c int }

type binaryIndexedTree []int

func (t binaryIndexedTree) sum(i int) (s int) {
	for i++; i > 0; i -= i & -i {
		s += t[i]
	}
	return
}
func (t binaryIndexedTree) add(i, x int) {
	for i++; i < len(t) && i > 0; i += i & -i {
		t[i] += x
	}
}


Measured memory_bytes: 40828
#include <stdio.h>

int
main (
  int   argc,
  char *argv[ ]
  )
{
  int i, j;

  for ( ; ; )
  {
    int h, w;

    scanf ( "%d%d", &h, &w );
    if ( h == 0 && w == 0 ) break ;

    for ( i = 0; i < h; ++i )
    {
      for ( j = 0; j < w; ++j )
      {
        putchar ( '#' );
      }
      puts ( "" );
    }
    puts ( "" );
  }

  return ( 0 );
}

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

int main(int argc, char const *argv[]) {
	int n, x;
	int m[n];
	int min = 0;
	
	int count = 0;
	cin >> n >> x;
	for (int i = 0; i < n; ++i){
		cin >> m[i];
		x -= m[i];
	}
	min = m[0];
	for (int i = 0; i < n; ++i){
		if (min > m[i]) min = m[i];
	}
	count = x / min;
	cout << count + n << endl;
	
	
	
	
	return 0;
}

Measured memory_bytes: 256
from collections import deque
s=input()
n = int(input())

f=False
q= deque(s)

for _ in range(n):
    i = input()

    if i[0] == '1': f=False if f else True
    else:
        _,a,b =i.split()
        
        if f :
            if a == '1':q.append(b)
            else:q.appendleft(b)
        else:
            if a == '1':q.appendleft(b)
            else:q.append(b)

if f: q.reverse()

for i in q:print(i,end='')


Measured memory_bytes: 94296
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <chrono>
#include <random>
#include <tuple>
#include <utility>

const int INF = 1000000009;
const long LINF = 1123456789012345678;

bool found[26];
long cnt;
std::string s;

int main(){
	std::cin >> s;
	long same = (s[0] == s[s.length() - 1]);
	long even = s.length() % 2;
	if((same + even) % 2){
		printf("First\n");
	}else{
		printf("Second\n");
	}
	return 0;
}


Measured memory_bytes: 512
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Scanner;

public class Main {
    public static void main(final String[] args) {
        final Scanner scanner = new Scanner(System.in);
        final int n = scanner.nextInt();
        final int m = scanner.nextInt();
        final int k = scanner.nextInt();

        final int[] friendsArray = new int[n + 1];
        final FastUnionFindTree tree = new FastUnionFindTree(n);
        for (int i = 0; i < m; i++) {
            final int a = scanner.nextInt();
            final int b = scanner.nextInt();

            friendsArray[a]++;
            friendsArray[b]++;
            tree.unit(Math.min(a, b), Math.max(a, b));
        }

        final int[] blocksArray = new int[n + 1];
        for (int i = 0; i < k; i++) {
            final int c = scanner.nextInt();
            final int d = scanner.nextInt();

            if (tree.isSame(c, d)) {
                blocksArray[c]++;
                blocksArray[d]++;
            }
        }

        final Map<Integer, List<Integer>> preFriendMap = new HashMap<>();
        for (int i = 1; i <= n; i++) {
            final int root = tree.getRoot(i);
            preFriendMap.computeIfAbsent(root, v -> new ArrayList<>()).add(i);
        }

        final int[] answers = new int[n + 1];
        for (final List<Integer> value : preFriendMap.values()) {
            for (final int i : value) {

                answers[i] = value.size() - friendsArray[i] - blocksArray[i] - 1;
            }
        }

        for (int i = 1; i <= n; i++) {
            System.out.print(answers[i] + " ");
        }
    }

    static class FastUnionFindTree {
        private int[] nodes;
        private final List<Integer> indices = new ArrayList<>();

        FastUnionFindTree(final int numOfNodes) {
            this.nodes = init(numOfNodes);
        }

        private int[] init(final int numOfNodes) {
            final int[] array = new int[numOfNodes + 1];
            for (int i = 1; i <= numOfNodes; i++) {
                array[i] = i;
            }

            return array;
        }

        int getRoot(final int nodeNumber) {
            final int rootNode = nodes[nodeNumber];
            if (rootNode == nodeNumber) {
                for (final Integer index : indices) {
                    nodes[index] = rootNode;
                }
                indices.clear();
                return nodeNumber;
            }

            indices.add(nodeNumber);
            return getRoot(rootNode);
        }

        boolean isSame(final int nodeA, final int nodeB) {
            return getRoot(nodeA) == getRoot(nodeB);
        }

        void unit(final int nodeA, final int nodeB) {
            final int rootA = getRoot(nodeA);
            final int rootB = getRoot(nodeB);

            if (rootA == rootB) {
                return;
            }

            nodes[rootB] = rootA;
        }
    }
}


Measured memory_bytes: 126956
#include<iostream>
using namespace std;
typedef long long ll;
int main(){
    ll n;
    cin>>n;
    ll ans=0;
    ll ct=0;
    while(n>=10){
        ans+=n%10;
        n/=10;
        ct++;
    }
    ans+=n;
    cout<<max(ans, ct*9+n-1)<<endl;
    return 0;
}

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

ll f(ll a){//aまでのxor
  if(a==0)return 0;
  if(a%2==1){
    if(a%4==1)return 1;
    else return 0;
  }
  else return a^f(a-1);
}


int main(){
  ll a,b;cin >> a >> b;
  if(a==0)cout << f(b);
  else cout << (f(a-1)^f(b));
  cout << endl;
}

Measured memory_bytes: 3580
import java.util.*;

public class Main {
	static int N=26;
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		
		N = sc.nextInt();
		int kati=sc.nextInt();
		Tree tree[] =new Tree[N+1];
		int data[] =new int[(N-1)*2];
		int kati1[]=new int[N+1];
		int parent[]=new int[N+1];
		for(int i=0;i<(N-1)*2;i++) {
			data[i]=sc.nextInt();
		}
		for(int i=0;i<kati;i++) {
			int j=sc.nextInt();
			kati1[j]+=sc.nextInt();
					
		}
		
		
		

		
	
		for(int i=0;i<N-1;i++) {
			int j=data[i*2];
			Tree t =new Tree();
			tree[j]=t;
			if(tree[j].right==0) {
			tree[j].right = data[i*2+1];
			parent[data[i*2+1]]=j;
			}else {
		    tree[j].left = data[i*2+1];
		    parent[data[i*2+1]]=j;
			}
			
			
		}
		for(int i=1;i<tree.length;i++) {
			kati1[i] += kati1[parent[i]];	
			System.out.println(kati1[i]);
		}
		
		
		
		
		

	}
	public static class Tree{
		int left=0;
		int right=0;
		int parent=0;
		
	}

}



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



int main() {
    int H,N,ans=0;
    cin >> H >> N;
    vector<int> A(N);
    for(int i=0;i<N;i++){
        cin >> A.at(i);
        ans+=A.at(i);
    }
    if(H<=ans) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 640
#include "stdio.h"
int main(int argc, char const *argv[])
{
	int n,i,j,a,b,c,d,sum[10000],count,num;
	char number[1001];
	for(i=0;;i++){
		sum[i] = 0;
		scanf("%s",number);
		if(number[0] == '0' ){
			num = i;
			break;
		}
		 else{
		 	count =0;
		 	for(j=0;;j++){
		 		if(number[j] != '\0')
		 			count++;
		 		else
		 			break;
		 	}
		 	for(j=0;j<count;j++){
		 		sum[i] += number[j] - '0';
		 	}
		 }
	}

	for(i=0;i<num;i++){
		printf("%d\n",sum[i]);
	}

	return 0;
}


Measured memory_bytes: 544
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    from itertools import accumulate
    #素数判定用の関数を定義
    #素数だったら１、素数じゃなかったら０と返す
    def main(n):
        if n==1:
            return 0
        else:
            for j in range(2,int(n**0.5)+1):
                if n%j==0:
                    return 0
            return 1

    q = int(input())
    # 要素がｑ個あって要素が全部０のリストをl格納用とr格納用で２つ作る
    l=[0]*q
    r=[0]*q
    # 入力してlとrを塗り替えていく
    for i in range(q):
        l[i],r[i]=list(map(int, input().split()))

    # 素数判定する範囲を定めるためにminとmaxとる
    lmin=min(l)
    rmax=max(r)

    # min~maxの値について素数判定を行う
    # 素数だったら０、素数じゃなかったら１が入ってるリストを作る
    sosucheck=[]
    for i in range(lmin,rmax+1):
        if i%2==0:
            sosucheck.append(0)
        else:
            if main(i)==1 and main((i+1)/2)==1:
                sosucheck.append(1)
            else:
                sosucheck.append(0)

    # 累積和のリスト作る（最初を０にしたいから最初に０を足す）
    rui=[0]+sosucheck
    rui=list(accumulate(rui))

    #出力
    for i in range(q):
        sr=r[i]-lmin+1
        sl=l[i]-lmin
        print(rui[sr]-rui[sl])
resolve()

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

for i in range(n):
    if a[i] % 2 == 0:
        if a[i] % 3 == 0 or a[i] % 5 == 0:
            continue
        else:
            print('DENIED')
            exit()

print('APPROVED')


Measured memory_bytes: 2940
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <tuple>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i>b;i--)
#define vint vector<int> 
#define vvint vector<vint>
#define CST(x) cout<<fixed<<setprecision(x)//小数点以下の桁数指定
#define ct(a) cout<<a<<endl
static const double pi = 3.141592653589793;
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const int INF = 1e9+7;



vector<int>a;


bool isOK(int index, int key) {
	if (a[index] > key)return true;//ここの配列名を適宜変えよう！
	else return false;
}


int binary_search(int key,int up) {

	int left = up, right = (int)a.size() - 1;//ここの配列名を適宜変えよう！
	while (right - left > 1) {
		int mid = left + (right - left) / 2;

		if (isOK(mid, key))right = mid;
		else left = mid;
	}
	return right;
}

int main(){
	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(false);
	
	int N;
	cin >> N;
	int ans = 0;

	FOR(i, 0, N) {
		int A;
		cin >> A;
		a.push_back(A);
	}
	a.push_back(INF);
	sort(a.begin(),a.end());

	FOR(i, 0, N-2) {
		FOR(j, i+1, N - 1) {
			int b = a[i], c = a[j];
			int d = binary_search(c-b,j);
			int e = binary_search(c + b-1,j);
			ans += e - d;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define INF 0x6fffffff
#define INFL 0x7fffffffffffffffLL

int main() {
	int		r,g,b,i,j,k,n,m,x,y,ans = 0;
	string	s;

	cin >> n;
	vector<int> dp(n+1,INF);
	dp[0] = 0;
	vector<int> a = {1,6,6*6,6*6*6,6*6*6*6,6*6*6*6*6,6*6*6*6*6*6,9,9*9,9*9*9
					,9*9*9*9,9*9*9*9*9};
	//for(i=0;i<12;i++) cout << a[i] << endl;
	for(i=0;i<n;i++) {
		for(j=0;j<12;j++) {
			k = i+a[j];
			if (n<k) continue;
			dp[k] = min(dp[k], dp[i]+1); 
		}
	}
	cout << dp[n] << endl;

}


Measured memory_bytes: 640
import java.util.*;

public class Main {

  private static void solve(int N) {
    Map<Integer, Integer> map = new HashMap<>();
    for (int x = 1; x * x < N; x++) {
      for (int y = 1; y * y < N; y++) {
        for (int z = 1; z * z < N; z++) {
          int val = x * x + y * y + z * z + x * y + y * z + z * x;
          map.put(val, map.getOrDefault(val, 0) + 1);
        }
      }
    }
    for (int i = 1; i <= N; i++) {
      int res = 0;
      if (map.containsKey(i)) {
        res += map.get(i);
      }
      System.out.println(res);
    }
  }

  public static void main(String[] args) {
    int N = scanner.nextInt();
    solve(N);
  }

  private static final Scanner scanner = new Scanner(System.in);
}


Measured memory_bytes: 57848
# coding:utf-8

import sys

INF = float('inf')
MOD = 10 ** 9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()


a, b = LI()
print('Possible' if not all([a % 3, b % 3, (a + b) % 3]) else 'Impossible')

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

int hoge(string s, int b, int e){
  int j=0;
  b--;
  e--;
  for(int i = b; i < e; i++){
    if(s[i] != s[e-j]) return 0;
    j++;
  }
  return 1;
}

int main() {
	cin.tie(0);
  ios::sync_with_stdio(false);
 
	string s;
  cin>>s;
  if(hoge(s, 1, s.length()) && hoge(s, 1, (s.length()-1)/2) && hoge(s, (s.length()+3)/2, s.length()))
    cout<<"Yes";
  else
  {
    cout<<"No";
  }
  
  
  

  return 0;
}


Measured memory_bytes: 256
N = int(input())

s = []
s = [input() for i in range(N)]


sort = lambda str: ''.join(sorted(str))
wa = lambda n : int(0.5 * n * (n + 1))


sorted_s = map(sort, s)
counter = {}
for si in sorted_s:
    counter[si] = 1 if not si in counter else counter.get(si) + 1

nums = [wa(num - 1) for num in counter.values()]
answer = sum(nums)

print(answer)


Measured memory_bytes: 24976
#include <iostream>
#include<cstdio>
using namespace std;
int main(void){
  int n;
  cin>>n;
  int a[n];
  for(int i=0;i<n;i++){
     cin>>a[i];
   }
   for(int i=1;i<n;i++){
     cout<<a[n-i]<<" ";
   }
   cout<<a[0]<<endl;

}
   





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

namespace Practice
{
    class Program
    {
        static void Main(string[] args)
        {
            char[] K = Console.ReadLine().ToCharArray();
            int AA = int.Parse(new string(new char[] { K[0], K[1] }));
            int BB = int.Parse(new string(new char[] { K[2], K[3] }));
            int index = 0;
            // YYMMの可能性
            bool YYMM = (0 <= AA) && (AA <= 99) && (1 <= BB) && (BB <= 12);
            if (YYMM) index += 1;
            // MMYYの可能性
            bool MMYY = (0 <= BB) && (BB <= 99) && (1 <= AA) && (AA <= 12);
            if (MMYY) index += 2;
            string[] res = { "NA", "YYMM", "MMYY", "AMBIGUOUS" };
            Console.WriteLine($"{res[index]}");
        }
    }
}

Measured memory_bytes: 13140
#include "iostream"
using namespace std;

int main()
{
	char a;
	cin >> a;
	char b;
	cin >> b;
	char c;
	cin >> c;

	int d = 700;

	if (a == 'o')d += 100;
	if (b == 'o')d += 100;
	if (c == 'o')d += 100;

	cout << d << endl;

	return 0;
}



Measured memory_bytes: 256
N = int(input())
h = list(map(int,input().split()))
h.append(0)

cnt=0
flg=1
#flg=0  #0開始  1終わり
while max(h)>0:
    # print('h:',h)
    for i in range(N+1):
        if h[i] >=1:
            flg=0
        elif flg==0 and h[i]==0:
            flg=1
            cnt+=1
    for j in range(N):
        h[j]-=1
        if h[j]<0:
            h[j]=0

print(cnt)



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

int n,r,m;
cin>>n;
cin>>r;
if(n>=10)
{
    cout<<""<<r;
}
else
{
    m=10-n;
    m=m*100;
    r=r+m;
    cout<<""<<r;
}

}


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

int main()
{
	int n;
	int d[101];
	set<int> val;
	cin >> n;

	for(int i = 0; i < n; i++)
	{
		cin >> d[i];
	}
	for(int i = 0; i < n; i++)
	{
		val.insert(d[i]);
	}
	printf("%d\n", val.size());

	return 0;
}

Measured memory_bytes: 256
//بِسْمِ ٱللَّٰهِ ٱلرَّحْمَٰنِ ٱلرَّحِيمِ
#include <bits/stdc++.h>

using namespace std;

int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    if((a+b+c)>= 22){
        cout << "bust" << endl;
    }
        
    else{
        cout << "win" << endl;
    }    



    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
template<typename T>inline T read(){
	T x=0,f=0;char c=getchar();
	while(!isdigit(c)) f=c=='-',c=getchar();
	while(isdigit(c)) x=x*10+c-48,c=getchar();
	return f?-x:x;
}
namespace run{
	const int N=2e5+9,mod=1e9+7;
	inline int add(int x,int y){return x+y>=mod?x-mod+y:x+y;}
	inline int sub(int x,int y){return x>=y?x-y:x+mod-y;}
	inline int qpow(int x,int y){
		int ret=1;
		while(y){
			if(y&1) ret=1LL*ret*x%mod;
			x=1LL*x*x%mod;y>>=1;
		}
		return ret;
	}
	inline int inv(int x){return qpow(x,mod-2);}
	int fac[N],ifac[N];
	inline int C(int _n,int _m){
		if(_n<_m || _n<0 || _m<0) return 0;
		return 1LL*fac[_n]*ifac[_m]%mod*ifac[_n-_m]%mod;
	}

	int head[N],nex[N<<1],to[N<<1],cnt;
	inline void adde(int u,int v){
		nex[++cnt]=head[u];
		head[u]=cnt;to[cnt]=v;
	}
	int f[N],n,siz[N],ans[N];
	inline void dfs(int u,int _f){
		siz[u]=f[u]=1;
		for(int i=head[u];i;i=nex[i]){
			if(to[i]^_f){
				dfs(to[i],u);
				siz[u]+=siz[to[i]];
				f[u]=1LL*f[u]*C(siz[u]-1,siz[to[i]])%mod*f[to[i]]%mod;
			}
		}
	//	cout<<u<<" "<<f[u]<<endl;
	}
	inline void solve(int u,int _f){
		ans[u]=f[u];
		for(int i=head[u];i;i=nex[i]){
			if(to[i]^_f){
				int _u=f[u],_to=f[to[i]],su=siz[u],st=siz[to[i]];
				f[u]=1LL*f[u]*inv(C(siz[u]-1,siz[to[i]]))%mod*inv(f[to[i]])%mod;
				f[to[i]]=1LL*f[to[i]]*C(siz[u]-1,siz[u]-siz[to[i]])%mod*f[u]%mod;
				siz[to[i]]=su,siz[u]=su-st;
				solve(to[i],u);
				f[u]=_u,f[to[i]]=_to,siz[u]=su,siz[to[i]]=st;
			}
		}
	}
	int main(){
		n=read<int>();
		for(int i=1;i<n;i++){
			int u=read<int>(),v=read<int>();
			adde(u,v),adde(v,u);
		}

		fac[0]=ifac[0]=1;
		for(int i=1;i<=n;i++) fac[i]=1LL*fac[i-1]*i%mod;
		ifac[n]=qpow(fac[n],mod-2);
		for(int i=n-1;i;i--) ifac[i]=1LL*ifac[i+1]*(i+1)%mod;

		dfs(1,0);
	//	cout<<f[1]<<endl;
		solve(1,0);
		for(int i=1;i<=n;i++)
			printf("%d\n",ans[i]);
		return 0;
	}
}
int main(){
#ifdef my
	freopen(".in","r",stdin);
	freopen(".out","w",stdout);
#endif
	return run::main();
}

Measured memory_bytes: 9984
#include <iostream>
#include <algorithm>
#include <string>
#include <map>
#include <math.h>
#include <set>

using namespace std;
typedef long long  ll;
#define rep(i,s,n)for(ll i=s;i<n;i++)
#define repe(i,s,n)for(ll i=s;i<=n;i++)

static const double PI = 3.1415926535897932384626433;

///////////////////////////
////Prime Creator//////////
///////////////////////////
//bool Prime[100001] = {};
//void createPrime() {
//	ll n = 100001;
//	rep(i, 0, n) Prime[i] = true;
//	Prime[0] = false;
//	Prime[1] = false;
//	rep(i, 2, n) {
//		if (Prime[i]) {
//			rep(j, 2, n) {
//				if (j*i >= n)break;
//				Prime[j*i] = false;
//			}
//		}
//	}
//}
///////////////////////////
///////////////////////////

///////////////////////////
////Warshal Floyid/////////
///////////////////////////
////initialize`
////rep(i, 0, N)rep(j, 0, N) wf[i][j] = 1 << 29;
//static const ll WF_MAX = 300;
//ll wf[WF_MAX][WF_MAX];
//void WarshalFloyid(int size) {
//	rep(k, 0, size)rep(i, 0, size)rep(j, 0, size)wf[i][j] = min(wf[i][j], wf[i][k] + wf[k][j]);
//}

ll x[100001] = {};
ll y[100001] = {};
int main() {
	ll n, m; cin >> n >> m;
	repe(i, 1, n)cin >> x[i];
	repe(i, 1, m)cin >> y[i];
	//sort(x + 1, x + n);
	//sort(y + 1, y + n);
	ll MOD = 1000000007;
	ll X = 0;
	repe(k, 1, n) {
		X = (X + (2 * k - n - 1)*x[k]) % MOD;
	}
	ll Y = 0;
	repe(k, 1, m) {
		Y = (Y + (2 * k - m - 1)*y[k]) % MOD;
	}

	cout << X * Y % MOD << endl;
	return 0;
}

Measured memory_bytes: 1792
#include <algorithm>
//#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
#define ll long long
#define REP(i, a, b) for(int i = a; i < b; i++)
#define rep(i, n) REP(i, 0, n)
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<P> vp;
typedef vector<ll> vl;
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};

using namespace std;
int main() {
    string s;
    cin >> s;
    if(s.size() == 3) {
        rep(i, 3) cout << s[2 - i];
        cout << endl;
    } else {
        cout << s << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
int main()
{
    vector<int> N(4);
    cin >> N[0] >> N[1] >> N[2] >> N[3];
    sort(all(N));
    if (N[0] == 1 && N[1] == 4 && N[2] == 7 && N[3] == 9) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}

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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;  // or pb_ds;

using namespace std;

#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#ifndef DEBUG
#define endl "\n"
#endif
#define fff ff
#define sss ss.ff
#define ttt ss.ss
#define INF (1 << 30)
#define LLF (1ll << 60)
#define PRIME (1000000007)
#define FASTIO std::ios::sync_with_stdio(false)
#ifdef DEBUG
#define debug(x) cerr << #x << " = " << x << endl
#else
#define debug(x)
#endif
#define rep(i, begin, end)                            \
  for (__typeof(end) i = (begin) - ((begin) > (end)); \
       i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))

#define FILE_INPUT                  \
  freopen("input.txt", "r", stdin); \
  freopen("output.txt", "w", stdout)

#define all(x) x.begin(), x.end()

typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef tuple<int, int, int> iii;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<string> vs;

template <typename T, typename B = null_type>
using oset =
    tree<T, B, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
// find_by_order / order_of_key

const ld eps = 1e-12;

/*-----------------END TEMPLATE-----------------*/

int(((((((((((((((main)))))))))))))))() {
  FASTIO;
  int a, b, c;
  cin >> a >> b >> c;
  swap(a, b);
  swap(a, c);
  cout << a << ' ' << b << ' ' << c << endl;
}

/*

0 1 2 3 4 5 6
      B B C C

1 2 3 4 5
    A A A
B B B
      C C

*/

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
template<typename T>
void read(T &x)
{
    x=0;char c=getchar();bool p=0;
    for(;c<'0'||c>'9';c=getchar())if(c=='-')p=1;
    for(;c>='0'&&c<='9';c=getchar())x=(x<<3)+(x<<1)+(c^48);
    if(p)x=-x;
}
const ll MOD=1000000000+7;
ll f[2005][2005];
ll fac[4000005],inv[4000005];
int n,k;
ll ksm(ll basic,ll mi)
{
    ll tmp=1;
    while(mi)
    {
        if(mi&1)tmp=tmp*basic%MOD;
        mi>>=1;
        basic=basic*basic%MOD;
    }
    return tmp;
}
ll C(ll x,ll y)
{
    return fac[x]*inv[y]%MOD*inv[x-y]%MOD;
}
int main()
{
    read(n),read(k);
    fac[0]=inv[0]=1;
    for(ll i=1;i<=n*k;++i)fac[i]=fac[i-1]*i%MOD;
    inv[n*k]=ksm(fac[n*k],MOD-2);
    for(ll i=n*k-1;i;--i)inv[i]=inv[i+1]*(i+1)%MOD;
    if(k==1)
    {
        printf("1\n");
        return 0;
    }
    f[0][0]=1;
    for(int i=1;i<=n;++i)
    {
        f[i][0]=1;
        for(int j=1;j<=i;++j)
        {
            f[i][j]=(f[i][j]+f[i-1][j]+1ll*f[i][j-1]*(n-j+1)%MOD*C(n*k-i-(j-1)*(k-1)-1,k-2)%MOD)%MOD;
        }
    }
    printf("%lld\n",f[n][n]);
    return 0;
}

Measured memory_bytes: 88672
n = int(input())
x = list(map(float, input().split()))
y = list(map(float, input().split()))

xy_abs = [abs(x[i] - y[i]) for i in range(n)]
manhattan_distance = sum(xy_abs)
euclid_distance = sum([xy ** 2 for xy in xy_abs]) ** 0.5
p3_distance = sum([xy ** 3 for xy in xy_abs]) ** (1/3)
chebyshev_distance = max(xy_abs)

print(manhattan_distance)
print(euclid_distance)
print(p3_distance)
print(chebyshev_distance)




Measured memory_bytes: 5668
open System

// prelude
let readStr () = stdin.ReadLine()

let read f () = readStr() |> f
let reads f () = readStr().Split() |> Array.map f

let pair = function
| [|a; b|] -> (a, b)
| _ -> failwith "owatta"

let triple = function
| [|a; b; c|] -> (a, b, c)
| _ -> failwith "owatta"

let readPair f g () =
  let (a,b) = readStr().Split() |> pair
  (f a, g b)

let readTriple f g h () =
  let (a,b,c) = readStr().Split() |> triple
  (f a, g b, h c)

let inc n = n + 1
let dec n = n - 1

let inline flip f a b = f b a
let rec fix f = fun x -> (f (fix f)) x

module Option =
  let getOr defaultValue = function
  | Some x -> x
  | None -> defaultValue

module Array =
  let modify (arr: _ []) i f =
    arr.[i] <- f arr.[i]

module Array2D =
  let modify (arr: _ [,]) i j f =
    arr.[i, j] <- f arr.[i, j]

// ModInt
type ModInt = MVal of int64

[<RequireQualifiedAccess>]
[<CompilationRepresentation(CompilationRepresentationFlags.ModuleSuffix)>]
module ModInt =
  let modulo = 998244353L

  let inline init (x: ^a): ModInt =
    let x = (int64 x) % modulo
    match x with
    | _ when x < 0L -> MVal (x + modulo)
    | _ -> MVal x
  
  let value (MVal x) = x
  
type ModInt with
  static member inline ( + ) (lhs: ModInt, rhs: ModInt) =
    let (MVal x), (MVal y) = (lhs, rhs)
    ModInt.init (x+y)
  static member inline ( - ) (lhs: ModInt, rhs: ModInt) =
    let (MVal x), (MVal y) = (lhs, rhs)
    ModInt.init (x-y)
  static member inline ( * ) (lhs: ModInt, rhs: ModInt) =
    let (MVal x), (MVal y) = (lhs, rhs)
    ModInt.init (x*y)
  static member inline ( / ) (lhs: ModInt, rhs: ModInt) =
    let rec pow n m = (if (m&&&1L)=1L then n else ModInt.init 1) * (if m=0L then ModInt.init 1 else (pow (n*n) (m>>>1)))
    let invB = pow rhs (ModInt.modulo-2L)
    lhs * invB
// ModInt


// start
let (N,M,K) = readTriple int int int ()

let rec pow n k =
  if k=0 then ModInt.init 1
  else
    n * (pow n (k-1))

let facts = Array.zeroCreate (N+1)
facts.[0] <- ModInt.init 1
for i in 1..N do
  facts.[i]<-facts.[i-1]*(ModInt.init i)

let invFacts = facts |> Array.map (fun x -> (ModInt.init 1)/x)

let C n k = facts.[n]*invFacts.[n-k]*invFacts.[k] 

let cnt0 = Array.zeroCreate (N+1)
cnt0.[1]<-ModInt.init M
for i in 2..N do
  cnt0.[i]<-cnt0.[i-1]*(ModInt.init (M-1))

let rec cnt n k =
  if k=0 then
    cnt0.[n]
  else
    (C (n-1) k) * (cnt (n-k) 0)

[0..K]
|> List.fold (fun st k -> st + (cnt N k)) (ModInt.init 0)
|> ModInt.value
|> printfn "%d"

Measured memory_bytes: 67668
#include<stdio.h>
int main()
{
    int i,a[4];
   int max1,max2;
    for(i=0;i<4;i++)
     {
       scanf("%d",&a[i]);

}
max1=a[0];
max2=a[2];
if(a[1]<max1)
max1=a[1];
if(a[3]<max2)
max2=a[3];
printf("%d",max1+max2);
return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define all(v) v.begin(), v.end()
#define sz(v) v.size()
#define INF 100000000000000 //10^14 100兆
// aよりもbが大きいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}
// aよりもbが小さいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}

int main(){
  double a, b, x;
  cin >> a >> b >> x;
  double theta = 0;
  if(x <= a * a * b * 0.5){
    theta = atan(a * b * b * 0.5 / x);
  }
  else{
    theta = atan(2 * (b - x / (a * a)) / a);
  }
  cout << fixed << setprecision(10);
  cout << theta * 180 / M_PI << endl;
}

Measured memory_bytes: 256
# your code goes here
import numpy as np

def main():
	n = int(input())
	a = list(map(int, input().split()))
	m = np.mean(a)
	r = 0
	
	for i in range(n):
		if ((a[i]-m)**2 < (a[r]-m)**2):
			r = i
	print(r)
	
main()

Measured memory_bytes: 21268
import sys
from collections import deque
readline = sys.stdin.readline


N = int(readline())
A = []
X, Y = [], []
for i in range(N):
    a = int(readline())
    A.append(a)
    x, y = [], []
    for j in range(a):
        _x, _y = map(int, readline().split())
        x.append(_x - 1), y.append(_y)
    X.append(x)
    Y.append(y)

M = 2 ** N
count = 0
for code in range(M - 1, -1, -1):
    contra = False
    for i in range(N):
        if ((code >> i) & 1) == 1:
            x, y = X[i], Y[i]
            for j in range(len(x)):
                if y[j] != ((code >> x[j]) & 1):
                    contra = True
                    break
            if contra:
                break
    if not contra:
        _count = 0
        for i in range(N):
            _count += ((code >> i) & 1)
        count = max(count, _count)

print(count)









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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var vals = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).OrderBy(x => x).ToArray();
            // 中央値
            var a = vals[n / 2];
            var b = vals[n / 2 - 1];
            Console.WriteLine(a - b);
        }
    }
}


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

typedef long long ll;

int main() {
    int X, Y, Z, K;
    cin >> X >> Y >> Z >> K;
    vector<ll> A(X), B(Y), C(Z);
    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> AB;
    for (int i = 0; i < X; i++) {
        for (int j = 0; j < Y; j++) {
            AB.push_back(A[i] + B[j]);
        }
    }
    sort(AB.begin(), AB.end(), greater<ll>());
    vector<ll> ABC;
    for (int i = 0; i < K && i < AB.size(); i++) {
        for (int j = 0; j < Z; j++) {
            ABC.push_back(AB[i] + C[j]);
        }
    }
    sort(ABC.begin(), ABC.end(), greater<ll>());
    for (int i = 0; i < K; i++) {
        cout << ABC[i] << endl;
    }
}

Measured memory_bytes: 43368
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Deque;
import java.util.List;
import java.util.NoSuchElementException;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Scanner;
 
 
public class Main {

	static long MOD = 1_000_000_007;
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		//int N = Integer.parseInt(sc.next());
		//long L = Long.parseLong(sc.next());
		//char[] c = sc.next().toCharArray();
		int INF = Integer.MAX_VALUE;
		long ans = 0;
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		int M = Integer.parseInt(sc.next());
		long[] dp = new long[N+1];
		boolean[] hole = new boolean[N+1];
		Arrays.fill(hole, false);
		for(int i=0; i<M; i++){
			int m = Integer.parseInt(sc.next());
			hole[m] = true;
		}
		
		if(N==1){
			ans = 1;
		}
		dp[0] = 1;
	
		if(!hole[1]){
			dp[1] = 1;
		}
		
		for(int i=2;i<=N;i++){
			if(!hole[i-1])dp[i] += dp[i-1];
			dp[i] %= MOD;
			if(!hole[i-2])dp[i] += dp[i-2];
			dp[i] %= MOD;
			if(hole[i])dp[i] = 0;
			dp[i] %= MOD;
		}
		
		//Arrays.sort(W);
		
		ans = dp[N];
		System.out.println(ans);
		
	}
	
	
}



Measured memory_bytes: 46308
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define rep2(i, s, n) for (int i = s; i < (int)n; i++)
#define all(obj) obj.begin(), obj.end()
#define debug(x) cerr << #x << ":" << x << "\n"
#define vdebug(vec) cerr << #vec << ":"; for (auto e : vec) cerr << e << " "; cout << "\n"
#define YN(f) cout << (f ? "YES" : "NO") << endl
#define Yn(f) cout << (f ? "Yes" : "No") << endl
#define yn(f) cout << (f ? "yes" : "no") << endl
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;

int main () {
	int sum, p;
	while (true) {
		cin >> sum;
		if (sum == 0) break;
		rep(i, 9) {
			cin >> p;
			sum -= p;
		}
		cout << sum << endl;
	}	
}


Measured memory_bytes: 3104
#include<bits/stdc++.h>
using namespace std;
typedef double db;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pw(x) (1ll << (x))
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define rep(i,l,r) for(int i=(l);i<(r);++i)
#define per(i,l,r) for(int i=(r)-1;i>=(l);--i)
#define dd(x) cout << #x << " = " << x << ", "
#define de(x) cout << #x << " = " << x << endl

//-----
int a, b, c, d;
int dis(int a, int b) { return a - b >= 0 ? a - b : b - a; }
int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
  cin >> a >> b >> c >> d;
  cout << (dis(a, c) <= d || dis(a, b) <= d && dis(b, c) <= d ? "Yes" : "No") << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std ;
#define rep( i, s, t ) for( register int i = s; i <= t; ++ i )
#define re register
#define int long long
#define pb push_back
int gi() {
	char cc = getchar() ; int cn = 0, flus = 1 ;
	while( cc < '0' || cc > '9' ) {  if( cc == '-' ) flus = - flus ; cc = getchar() ; }
	while( cc >= '0' && cc <= '9' )  cn = cn * 10 + cc - '0', cc = getchar() ;
	return cn * flus ;
}
const int inf = 1e18 ; 
const int P = 998244353 ; 
const int N = 1e5 + 5 ; 
const int M = 1e5 + 5 ;
int n, m1, m2, m3, ans[N], h[N], f[N], g[N], f1[N], f2[N], f3[N], Ans ;
int book[N] ; 
vector<int> G1[N], G2[N], G3[N] ; 
signed main()
{
	n = gi(), ans[1] = inf % P ; 
	rep( i, 2, n ) ans[i] = ans[i - 1] * ans[1] % P ; 
	
	int x, y ; m1 = gi() ; 
	rep( i, 1, m1 ) x = gi(), y = gi(), ( x < y ) ? G1[x].pb(y) : G1[y].pb(x) ;
	m2 = gi() ; 
	rep( i, 1, m2 ) x = gi(), y = gi(), ( x < y ) ? G2[x].pb(y) : G2[y].pb(x) ;
	m3 = gi() ; 
	rep( i, 1, m3 ) x = gi(), y = gi(), ( x < y ) ? G3[x].pb(y) : G3[y].pb(x) ;
	
	for( re int i = n, l; i >= 1; -- i ) {
		for( int j : G1[i] ) book[f1[j]] = 1 ; l = 0 ;
		while( book[l] ) ++ l ; f1[i] = l ;
		for( int j : G1[i] ) book[f1[j]] = 0 ; 
		
		for( int j : G2[i] ) book[f2[j]] = 1 ; l = 0 ;
		while( book[l] ) ++ l ; f2[i] = l ;
		for( int j : G2[i] ) book[f2[j]] = 0 ; 
		
		for( int j : G3[i] ) book[f3[j]] = 1 ; l = 0 ;
		while( book[l] ) ++ l ; f3[i] = l ;
		for( int j : G3[i] ) book[f3[j]] = 0 ; 
		f[f1[i]] = ( f[f1[i]] + ans[i] ) % P, 
		g[f2[i]] = ( g[f2[i]] + ans[i] ) % P,
		h[f3[i]] = ( h[f3[i]] + ans[i] ) % P ; 
	}
	rep( i, 0, 500 ) rep( j, 0, 500 ) rep( k, 0, 500 ) 
	( ( i ^ j ^ k ) == 0 ) ? Ans = ( Ans + f[i] * g[j] % P * h[k] % P ) % P : Ans = Ans ; 
	
	cout << Ans << endl ; 
	return 0 ; 
}

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

using namespace std;
int main(int argc, char *argv[]) {
	int a, b;
	cin >> a >> b;
	
	int ans = -1;
	if (a < 10 && b < 10) {
		ans = a * b;
	}
	
	cout << ans << endl;
}

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

int main (){
    int A, B, C, D, E;
    cin >> A >> B >> C >> D;
    
    int ans = 0;
    for (size_t i = 0; i < 8; i++)
    {
        if (B > A)
        {
            break;
        }
        B *= 2;
        ans++;
        
    }
    for (size_t i = 0; i < 8; i++)
    {
        if (C > B)
        {
            break;
        }
        C *= 2;
        ans++;
        
    }
    if(ans <= D) {
    cout << "Yes" << endl;
    } else {
    cout << "No" << endl;
    }


    
}

Measured memory_bytes: 3632