akhauriyash/Code-Regression huggingface dataset:
s = [input() for i in range(4)]
coin500 = int(s[0]) 
coin100 = int(s[1])
coin50 = int(s[2])

list = []
for i in range(coin500 + 1):
  for j in range(coin100 + 1):
    for k in range(coin50 + 1):
      list.append(500 * i + 100 * j + 50 * k)

import collections
c = collections.Counter(list)
if c.get(int(s[3])) == None:
    print("0")
else:
    print(c.get(int(s[3])))

Measured memory_bytes: 82692
S = str(input())

a = int(S[0:2])
b = int(S[2:4])

if a == 0:
	if b == 0 or b > 12:
		ans = 'NA'
	elif 1 <= b <= 12:
		ans = 'YYMM'
elif 1 <= a <= 12:
	if b == 0 or b > 12:
		ans = 'MMYY'
	elif 1 <= b <= 12:
		ans = 'AMBIGUOUS'
elif a > 12:
	if b == 0 or b > 12:
		ans = 'NA'
	if 1 <= b <= 12:
		ans = 'YYMM'

print(ans)

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

int main() {
    long long n, k, i, ans = 0;
    cin >> n >> k;
    for(i = k; i <= n + 1; i++){
        ans += i*(2*n-i+1)/2 - i*(i-1)/2 + 1;
        ans %= 1000000007;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3620
import sys

N = int(input())
Xn = list(map(int, input().split()))


def cal(number):
    an = 0
    for X in Xn:
        an += (X - number)**2
    return an

ans = sys.maxsize
for i in range(min(Xn), max(Xn)+1, 1):
    ans = min(ans, cal(i))

print(ans)


Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <vector>

using namespace std;

long long p = 1e9+7;

int main(){
    string s;
    cin >> s;

    vector< vector<long long> > dp(s.size(), vector<long long>(13, 0));

    if(s[0] == '?'){
        for(int i = 0; i < 10; i++){
            dp[0][i] = 1;
        }
    }else{
        dp[0][s[0]-'0'] = 1;
    }

    for(int i = 0; i < s.size()-1; i++){
        if(s[i+1] == '?'){
            for(int j = 0; j < 13; j++){
                for(int k = 0; k < 10; k++){
                    dp[i+1][(j*10%13+k)%13] += dp[i][j];
                    dp[i+1][(j*10%13+k)%13] %= p;
                }
            }
        }else{
            for(int j = 0; j < 13; j++){
                dp[i+1][(j*10%13+(s[i+1]-'0'))%13] += dp[i][j];
                dp[i+1][(j*10%13+(s[i+1]-'0'))%13] %= p;
            }
        }
    }

    cout << dp[s.size()-1][5] << endl;
    

    return 0;
}

Measured memory_bytes: 13696
def main():
    N = int(input())
    S = input()

    if N % 2 != 0:
        print("No")
        return

    n1 = S[: N // 2]
    n2 = S[N // 2 :]

    if n1 == n2:
        print("Yes")
    else:
        print("No")


if __name__ == "__main__":
    main()


Measured memory_bytes: 2940
#include "bits/stdc++.h"

using namespace std;

using ll = long long;

template<typename T> using V = std::vector<T>;
using Vi = V<int>;
using VVi = V<V<int>>;
using Vl = V<ll>;
using VVl = V<V<ll>>;
using Vs = V<string>;

template<typename T1, typename T2> using P = std::pair<T1, T2>;
using Pii = P<int, int>;
using Pll = P<ll, ll>;
using Pdd = P<double, double>;

template<typename T1, typename T2> using M = std::map<T1, T2>;
using Mii = M<int, int>;
using Msi = M<string, int>;

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REP2(i,s,e) for(int i=(int)(s);i<(int)(e);++i)
#define RREP(i,s,e) for(int i=(int)(s);i>=(int)(e);--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin(),ie=(c).end();i!=ie;++i)
#define ALL(c) (c).begin(), (c).end()

const double PI = acos(-1);
const ll MOD = 1e9+7;

struct UFTree {
    static const int MAX_N = 1e6;
    int p[MAX_N], r[MAX_N];

    UFTree(int n) : p(), r() {
        for(int i = 0; i < n; ++i) {
            p[i] = i;
            r[i] = 0;
        }
    }

    int root(int x) {
        return p[x] == x ? x : (p[x] = root(p[x]));
    }

    bool same(int x, int y) {
        return root(x) == root(y);
    }

    void unite(int x, int y) {
        x = root(x);
        y = root(y);
        if(x == y) return;

        if(r[x] < r[y]) {
            p[x] = y;
        } else {
            p[y] = x;
            if(r[x] == r[y]) r[x]++;
        }
    }
};

int n, m, v, e, r;
string s;

int main() {
    cin >> v >> e >> r;

    V<V<Pii>> edges(v);
    REP(i, e) {
        int s,t,d;
        cin >> s >> t >> d;
        edges[s].push_back({d, t});
    }

    unordered_set<int> toUpdate;
    Vi d(v, 1e9);
    d[r] = 0;
    toUpdate.insert(r);

    REP(i, v) {
        unordered_set<int> toUpdateBuf(toUpdate);
        toUpdate.clear();
        FOR(j, toUpdateBuf) {
            int node = *j;
            FOR(k, edges[node]) {
                int dist = k->second;
                int cost = k->first;
                if (d[dist] > d[node] + cost) {
                    d[dist] = d[node] + cost;
                    toUpdate.insert(dist);
                    if (i == v - 1) {
                        cout << "NEGATIVE CYCLE" << endl;
                        return 0;
                    }
                }
            }
        }
        if (toUpdate.empty()) break;
    }

    REP(i, v) {
        if (d[i] != 1e9) {
            std::cout << d[i] << '\n';
        } else {
            std::cout << "INF" << '\n';
        }
    }

    return 0;
}



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

int main() {
  
  int N;
  cin >> N;
  
  vector<int> vec(N);
  for (int i = 0; i < N; i++) {
    cin >> vec.at(i);
  }
 
  sort (vec.begin(), vec.end());
  reverse(vec.begin(), vec.end());
  
  int sum = 0;
  
  for (int i = 0; i < vec.size(); i++){
    if (i % 2 == 0){
      sum += vec.at(i);
    }
    else{
      sum -= vec.at(i);
    }
  }
    
  cout << sum << endl; 
 
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
import math
from bisect import bisect_left
from bisect import bisect_right
import collections
import copy
import heapq
from collections import defaultdict
from heapq import heappop, heappush
import itertools
input = sys.stdin.readline

##### リストの 二分木検索 #####
# bisect_left(lists, 3)
# bisect_right(lists, 3)

##### プライオリティキュー #####
# heapq.heapify(a) #リストaのheap化
# heapq.heappush(a,x) #heap化されたリストaに要素xを追加
# heapq.heappop(a) #heap化されたリストaから最小値を削除＆その最小値を出力

# heapq.heappush(a, -x) #最大値を取り出す時は、pushする時にマイナスにして入れよう
# heapq.heappop(a) * (-1) #取り出す時は、-1を掛けて取り出すこと

##### タプルリストのソート #####
# sorted(ans) #(a, b) -> 1st : aの昇順, 2nd : bの昇順
# sorted(SP, key=lambda x:(x[0],-x[1])) #(a, b) -> 1st : aの昇順, 2nd : bの降順
# sorted(SP, key=lambda x:(-x[0],x[1])) #(a, b) -> 1st : aの降順, 2nd : bの昇順
# sorted(SP, key=lambda x:(-x[0],-x[1])) #(a, b) -> 1st : aの降順, 2nd : bの降順

# sorted(SP, key=lambda x:(x[1])) #(a, b) -> 1st : bの昇順
# sorted(SP, key=lambda x:(-x[1])) #(a, b) -> 1st : bの降順

def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))

def main():
	r = inputInt()
 
	a = r*r
	print(a)


if __name__ == "__main__":
	main()


Measured memory_bytes: 38384
import sys
from collections import Counter

N = int(sys.stdin.readline())
X = input().split()

odd = Counter(X[0::2])
even = Counter(X[1::2])

a = odd.most_common()
b = even.most_common()

oddNum = a[0][1]
evenNum = b[0][1]

# if most common nums are same
if a[0][0] == b[0][0]:
  if len(a) == 1 and len(b) == 1:
    oddNum = 0
    evenNum = N//2
  # if gap of odd is bigger
  elif a[0][1] - a[1][1] > b[0][1] - b[1][1]:
    oddNum = a[0][1]
    evenNum = b[1][1]
    
  else:
    oddNum = a[1][1]
    evenNum = b[0][1]

print(N - oddNum - evenNum)

Measured memory_bytes: 25580
from heapq import heappop, heappush
import sys
sys.setrecursionlimit(10 ** 7)

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N, M = map(int, readline().split())
AB = [[int(x) for x in readline().split()] for _ in range(N)]

AB.sort()

STOCK = []
ans = 0

idx = 0
for d in range(1, M+1):
    for i in range(idx, N):
        a, b = AB[i]
        if a <= d:
            heappush(STOCK, -b)

            if i == N - 1:
                idx = N
        else:
            idx = i
            break

    if STOCK:
        p = heappop(STOCK)
        p = -p
        ans += p


print(ans)


Measured memory_bytes: 25336
#pragma warning(disable:4996)
#pragma GCC diagnostic ignored "-Wunused-result"
#pragma GCC diagnostic ignored "-Wwrite-strings"
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#define MAX_STRING 100000

int main() {

	char sInput[MAX_STRING+1]="";
	char* psInput=NULL;
	int i=0;
	int j=0;
	int nLen=0;
	int nBlocks=0;
	int nTargetIsEven=0;
	int nRemoves=0;

	// read line 1
	gets(sInput);
	nLen=strlen(sInput);
	nBlocks=nLen/2;
	nTargetIsEven=nLen%2;

	for (i=1;i<nLen;i++){
		j=i-1;
		while(sInput[j]==' '&& j>0){
			j--;
		}
		if (j>=0){
			if( (sInput[j]=='1' && sInput[i]=='0') ||
				(sInput[j]=='0' && sInput[i]=='1')) {
					sInput[j]=' ';
					sInput[i]=' ';
					nRemoves=nRemoves+2;
			}
		}
	}	

	printf("%d\n",nRemoves);

    return 0;
}

Measured memory_bytes: 1740
let _ =
  let n = Scanf.scanf "%d\n" (fun n -> n) in
  let h_max = ref 0 in
  let res = ref 0 in
  for i = 0 to n - 1 do
    let h = 
      Scanf.scanf (if i <> n - 1 then "%d " else "%d\n") (fun h -> h) in
    if h >= !h_max then (res := !res + 1; h_max := h);
  done;
  print_int !res


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

int main()
{
    int H, W;
    cin >> H >> W;

    vector<vector<char>> a(H, vector<char>(W));
    for (int i = 0; i < H; i++)
    {
        for (int j = 0; j < W; j++)
        {
            cin >> a.at(i).at(j);
        }
    }

    vector<bool> remove_row(H, false);
    for (int i = 0; i < H; i++)
    {
        bool rm = true;
        for (int j = 0; j < W; j++)
        {
            if (a.at(i).at(j) == '#')
            {
                rm = false;
                break;
            }
        }
        if (rm)
        {
            remove_row.at(i) = true;
        }
    }

    vector<bool> remove_col(W, false);
    for (int j = 0; j < W; j++)
    {
        bool rm = true;
        for (int i = 0; i < H; i++)
        {
            if (a.at(i).at(j) == '#')
            {
                rm = false;
                break;
            }
        }
        if (rm)
        {
            remove_col.at(j) = true;
        }
    }

    for (int i = 0; i < H; i++)
    {
        if (remove_row.at(i))
        {
            continue;
        }
        else
        {
            for (int j = 0; j < W; j++)
            {
                if (remove_col.at(j))
                {
                    continue;
                }
                else
                {
                    cout << a.at(i).at(j);
                }
            }
            cout << endl;
        }
    }
}

Measured memory_bytes: 256
words = lambda t : list(map(t, input().split()))
n,k = words(int)
xs = words(int)

def divisor (x):
    ans = []
    for i in range(1, int(x**0.5)+1):
        if x % i == 0:
            ans.append(i)
            if i != x // i:
                ans.append(x//i)
    ans.sort()
    return list(reversed(ans))

s = sum(xs)
#print(s)
ds = divisor(s)
ans = 1
#print(ds)
for d in ds:
    ms = []
    for x in xs:
        ms.append(x%d)
    ms.sort()
    #print(d,ms)
    f = 0
    f_ttl = ms[f]
    b = len(ms)-1
    b_ttl = d - ms[b]
    while f != b:
        if f_ttl >= b_ttl:
            b -= 1
            b_ttl += d - ms[b]
        else:
            f += 1
            f_ttl += ms[f]
    if k >= f_ttl:
        ans = d
        break
print(ans)


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

from __future__ import print_function
import sys

x = 10 ** 9 + 7


def fact(n):
    r = 1
    while n > 0:
        r = (r * n) % x
        n -= 1
    return r


def main():
    n, m = map(int, sys.stdin.readline().strip().split(" "))
    if abs(n - m) > 1:
        print(0)
        return
    elif abs(n - m) == 0:
        print((2 * fact(n) * fact(m)) % x)
    else:
        print((fact(n) * fact(m)) % x)


if __name__ == '__main__':
    main()


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


int main(){
    int p,q,r;
    cin>>p>>q>>r;
    
    int ans= p+q+r;
    
    if(p>=q&&p>=r){
        ans -=p;
    }else if(q>=p&&q>=r){
        ans -=q;
    }else {
        ans -=r;
    }

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

Measured memory_bytes: 256
import java.io.PrintWriter;
import java.util.*;

public class Main {
    int n;
    Edges[] g;
    long[] counter;

    void run() {
        Scanner sc = new Scanner(System.in);

        n = sc.nextInt();
        int q = sc.nextInt();
        g = new Edges[n];
        counter = new long[n];

        for (int i = 0; i < n; i++) {
            g[i] = new Edges();
        }

        for (int i = 0; i < n - 1; i++) {
            int a = sc.nextInt() - 1, b = sc.nextInt() - 1;
            g[a].add(b);
            g[b].add(a);
        }

        for (int i = 0; i < q; i++) {
            int p = sc.nextInt() - 1, x = sc.nextInt();
            counter[p] += x;
        }

        dfs(0, 0, new boolean[n]);

        PrintWriter out = new PrintWriter(System.out);
        out.print(counter[0]);
        for (int i = 1; i < n; i++) {
            out.print(" " + counter[i]);
        }
        out.println();
        out.flush();


    }

    void dfs(int idx, long cnt, boolean[] visited) {
        counter[idx] += cnt;
        visited[idx] = true;

        for (int next: g[idx]) if (!visited[next]) {
            dfs(next, counter[idx], visited);
        }
    }

    class Edges extends ArrayList<Integer> {}

    void debug(Object... os) {
        System.err.println(Arrays.deepToString(os));
    }

    public static void main(String[] args) {
        new Main().run();
    }

}


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

signed main(){
    int X,Y,Z,K;
    cin >>X >>Y >>Z >>K;
    vector<int> A(X),B(Y),C(Z);
    for(auto&& a:A)cin>>a;
    for(auto&& b:B)cin>>b;
    for(auto&& c:C)cin>>c;

    sort(A.rbegin(),A.rend());
    sort(B.rbegin(),B.rend());
    sort(C.rbegin(),C.rend());
    vector<int> u;

    // for(int a:A)cout<<a<<endl;
    // for(int b:B)cout<<b<<endl;
    // for(int c:C)cout<<c<<endl;
    

    for(int a=0;a<X;a++){
        for(int b=0;b<Y;b++){
            if((a+1)*(b+1)>K)break;
            for(int c=0;c<Z;c++){
                if((a+1)*(b+1)*(c+1)>K)break;
                u.push_back(A[a]+B[b]+C[c]);
            }
        }
    }
    sort(u.rbegin(),u.rend());

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


Measured memory_bytes: 1404
#include <cstdio>
#include <map>
#include <vector>
using namespace std;
typedef pair<int, int> P;
typedef pair<int,P> Pa;

int a, b, c, n;
vector<Pa> test;
int A[100], B[100], C[100];

int main(){
	while(scanf("%d%d%d", &a, &b, &c)){
		if(a == 0 && b == 0 && c == 0) break;
		vector<Pa> test;
		for(int i = 0; i < 100; i++){
			A[i] = 2; B[i] = 2; C[i] = 2;
		}
		scanf("%d", &n);
		for(int i = 0; i < n; i++){
			int p, q, r, s;
			scanf("%d%d%d%d", &p, &q, &r, &s);
			q -= a; r -= (a+b);
			p--; q--; r--;
			if(s){
				A[p] = 1;
				B[q] = 1;
				C[r] = 1;
			} else{
				test.push_back(Pa(p,P(q,r)));
			}
		}
		for(int i = 0; i < test.size(); i++){
			if(A[test[i].first]==1&&B[test[i].second.first]==1) C[test[i].second.second] = 0;
			else if(A[test[i].first]==1&&C[test[i].second.second]==1) B[test[i].second.first] = 0;
			else if(B[test[i].second.first]==1&&C[test[i].second.second]==1) A[test[i].first] = 0;
		}
		for(int i = 0; i < a; i++) printf("%d\n", A[i]);
		for(int i = 0; i < b; i++) printf("%d\n", B[i]);
		for(int i = 0; i < c; i++) printf("%d\n", C[i]);
	}
}

Measured memory_bytes: 1056
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

struct Node{
    Node *parent, *left, *right;
    int key;
};
Node *NIL, *root;

void insertNode(int k){
    Node *y = NIL;
    Node *x = root;
    Node *z = (Node*) malloc(sizeof(Node)); 
    z->key = k;
    z->left = NIL;
    z->right = NIL;

    while(x != NIL){
        y = x;
        if(k < x->key)
            x = x->left;
        else
            x = x->right;
    }
    z->parent = y;
    if(y == NIL){
        root = z;
    }else{
        if(z->key < y->key){
            y->left = z;
        }
        else{
            y->right = z;
        }
    }
}

void inorder(Node *u){
    if(u == NIL) return;
    inorder(u->left);
    cout << " " << u->key;
    inorder(u->right);
}

void preorder(Node *u){
    if(u == NIL) return;
    cout << " " << u->key;
    preorder(u->left);
    preorder(u->right);
}

Node *find(int key){
    Node *x = root;
    while(x != NIL){
        if(x->key == key)
            return x;
        if(key < x->key)
            x = x->left;
        else
            x = x->right;
    }
    return x;
}

Node *getMinimum(Node *u){
    while(u->left != NIL) u = u->left;
    return u;
}

Node *getSuccessor(Node *u){
    if(u->right != NIL)
        return getMinimum(u->right);

    Node *y = u->parent;
    while(y != NIL){
        if(y->left == u)
            return y;
        u = y;
        y = y->parent;
    }
    return y;
}


void deleteNode(int key){
    Node *z = find(key);
    Node *x, *y;
    if(z->left == NIL || z->right == NIL)
        y = z;
    else
        y = getSuccessor(z);
   if(y->left != NIL)
       x = y->left;
   else
       x = y->right;

   if(x != NIL)
       x->parent = y->parent;
   
   if(y->parent == NIL)
       root = x;
   else{
       if(y == y->parent->left){
           y->parent->left = x;
       }
       else{
           y->parent->right = x;
       }
   }

   if(y != z)
       z->key = y->key;
   free(y);
}

int main(){
    int n;
    cin >> n;
    string cmd;
    int key;
    for(int i = 0; i < n; ++i){
        cin >> cmd;
        if(cmd[0] == 'i'){
            cin >> key;
            insertNode(key);
        }
        else{
            if(cmd[0] == 'f'){
                cin >> key;
                if(find(key) == NIL){
                    cout << "no" << endl;
                }
                else{
                    cout << "yes" << endl;
                }
            }
            else{
                if(cmd[0] == 'd'){
                    cin >> key;
                    deleteNode(key);
                }
                else{
                inorder(root);
                cout << endl;
                preorder(root);
                cout << endl;
                }
            }
        }
    }
    return 0;
}





Measured memory_bytes: 21880
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;
void compress(vector<int> &c){
    sort(c.begin(),c.end());
    c.erase(unique(c.begin(),c.end()),c.end());
}
int idx(int i,vector<int> &c){
    return lower_bound(c.begin(),c.end(),i)-c.begin();
}
int sum[5010][5010];
int main(){
    int xs[5000],ys[5000];
    int n,m;
    scanf("%d%d",&n,&m);
    vector<int>x(n),y(n);
    for(int i=0;i<n;i++){
        scanf("%d%d",xs+i,ys+i);
        x[i]=xs[i];
        y[i]=ys[i];
    }
    compress(x);compress(y);
    for(int i=0;i<n;i++){
        int fx=idx(xs[i],x);
        int fy=idx(ys[i],y);
        sum[fy+1][fx+1]++;
    }
    for(int i=0;i<y.size();i++){
        for(int j=0;j<x.size();j++){
            sum[i+1][j+1]+=sum[i][j+1]+sum[i+1][j]-sum[i][j];
        }
    }
    for(int i=0;i<m;i++){
        int x1,x2,y1,y2;
        scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
        x1=idx(x1,x);
        y1=idx(y1,y);
        x2=idx(x2+1,x);
        y2=idx(y2+1,y);
        printf("%d\n",sum[y2][x2]-sum[y2][x1]-sum[y1][x2]+sum[y1][x1]);
    }

    return 0;
}

Measured memory_bytes: 98976
#include<cstdio>
using namespace std;
int main(void)
{
	double xq,x1,x2,x,yq,y1,y2,y,a,b,a1,b1,a2,b2;
	while(scanf("%lf,%lf,%lf,%lf,%lf,%lf",&x1,&y1,&x2,&y2,&xq,&yq)!=EOF)	{
		if(x1==x2)	{
			y=yq;
			x=2.0*x1-xq;
		}
		else if(y1==y2)	{
			x=xq;
			y=2.0*y1-yq;
		}
		else {
			a=(y2-y1)/(x2-x1);
			b=y1-a*x1;
			a1=a;
			b1=a*xq+2.0*b-yq;
			a2=-1.0/a;
			b2=(xq+a*yq)/a;
			x=(b2-b1)/(a1-a2);
			y=a1*x+b1;
		}
		printf("%lf %lf\n",x,y);
	}
	return 0;
}


Measured memory_bytes: 1080
#include <stdio.h>
#define N 200000
int main()
{
  int n, a[N], i, max=0, min=0, j;
  scanf("%d",&n);
  for(i=0; i<n; i++) scanf("%d",&a[i]);

  min = a[0];
  max = a[1] - a[0];
  for(j=1; j<n; j++){
    if(max<(a[j]-min)) max = a[j]-min;
    if(min>a[j]) min = a[j];
  }
  printf("%d\n",max);
  return 0;
}

Measured memory_bytes: 1376
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<sstream>
#include<iomanip>
#include<limits>
#include<deque>
#include<map>
#include<list>
#include<set>
#include <unordered_set>
#include<vector>
#include<cmath>
#include<cstdio>
#include<memory>
#include<bitset>
#include<stack>
#include <functional>
#include <queue>
#include <regex>

using namespace std;

constexpr int MOD = 1000000007;
constexpr int INF = 1050000000;


int main() {

	int c; cin >> c;

	if (c < 1200) {
		cout << "ABC" << endl;
	}
	else {
		cout << "ARC" << endl;
	}








}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        String r = new StringBuilder(s).reverse().toString();

        int res = 0;
        for (int i = 0; i < s.length()/2; i++) {
            if(s.charAt(i) == r.charAt(i)) {
                continue;
            }
            res++;
        }
        System.out.println(res);
    }
}


Measured memory_bytes: 23764
n=int(input())
a=list(map(int,input().split()))
fg=[1,-1]
ret = [0]*2
tot = [0]*2
il = range(n)
jl = range(2)
for i in il:
  for j in jl:
    tot[j]+=a[i]
    if tot[j]*fg[j]<=0:
      ret[j] += abs(fg[j] - tot[j])
      tot[j] += fg[j] - tot[j]
    fg[j]*=-1
print(min(ret))

Measured memory_bytes: 14332
n = int(input())
strs = []
inter1 = {}
for _ in range(n):
    strs.append(input())

for char in strs[0]:
    if char in inter1:
        inter1[char] +=1
    else:
        inter1[char] = 1
        
for i in range(1,n):
    inter2 = {}
    for char in strs[i]:
        if (char in inter1):
            if char in inter2:
                if inter2[char] < inter1[char]:
                    inter2[char] +=1
            else:
                inter2[char] =1 
    inter1 = inter2

inter = sorted(inter1.items())
ans = ''
for char,i in inter:
    for _ in range(i):
        ans +=char
print(ans)
        
    



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

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
#define M_PI 3.14159265358979323846

#ifdef __LOCAL
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
#else
    #define DBG(X)
    #define SAY(X)
#endif

#ifdef __LOCAL
    #include <filesystem>
    namespace fs = std::filesystem;
#endif

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int dx[]={1, 0, -1, 0, 0};
int dy[]={0, 1, 0, -1, 0};
const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);
const int NIL = -1;
static mt19937 _g(time(nullptr));
 
std::string pad(int num){ char buffer[4]; std::snprintf(buffer, sizeof(buffer), "%03d", num); return buffer;}
inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline T fetch() { T ret; cin >> ret; return ret; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

int A,B;

void input(){
    fast_io();
    #ifdef __LOCAL
        fs::path p = __FILE__;
        fs::path input,output;
        input = output = p.parent_path();
        input += string("/input/") + string(p.stem()) + string(".txt");
        output += string("/output/") + string(p.stem()) + string(".txt");
        freopen(input.c_str(), "r", stdin);
        freopen(output.c_str(), "w", stdout);
    #endif
    cin >> A >> B;
}

void solve(){
    input();
    string ans;
    for(int i=0;i<max(A,B);i++){
        ans += to_string(min(A,B));
    }
    cout << ans << endl;
}

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


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int i,j,a,b,c,d=0,e=0,f=0;
    char s[100];
    scanf("%s",s);
    if(s[0]!='A') e=5;

    if(s[1]>='A' && s[1]<='Z') e=5;

    if(s[strlen(s)-1]>='A' && s[strlen(s)-1]<='Z') e=5;

    for(i=2;i<strlen(s)-1;i++)
    {
        if(s[i]=='C') d++;
        if(s[i]>='A' && s[i]<='Z' && s[i]!='C') e=5;

    }

    if(d!=1) e=5;

    if(e==5)
    {
        printf("WA\n");
    }
    else
    {
        printf("AC\n");
    }
    return 0;
}


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

template<class T> void vin(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
}

int n, m;
int s[400], l[400], p[400];
int w[400];

int dp[400][401];

int main() {
    cin >> n;
    rep(i, n) {
        cin >> s[i] >> l[i] >> p[i];
    }
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j <= 400; ++j) {
            dp[i+1][j] = max(dp[i+1][j], dp[i][j]);
            for (int k=s[i]; k<=l[i]; ++k) {
                if (j >= k) {
                    dp[i+1][j]=max({dp[i][j], dp[i+1][j], dp[i+1][j-k]+p[i]});
                }
                //else dp[i+1][j] = max(dp[i][j], dp[i+1][j]);
            }
        }
    }
    cin >> m;
    bool ok = true;
    rep(i, m) {
        cin >> w[i];
        if (dp[n][w[i]] == 0) {
            ok = false;
        }
    }
    if (!ok) {
        cout << -1 << endl;
        return 0;
    }
    rep(i, m) {
        cout << dp[n][w[i]] << endl;
    }
    return 0;
}



Measured memory_bytes: 3684
(defun fact (n)
  (let ((fact 1))
    (loop :for i :from 2 :to n
          :do (setf fact (* i fact)))
    fact))

(defun permutaions (n)
  (let ((table (make-hash-table :size (fact n) :test 'equalp))
        (order 0))
    (labels ((next (n use vec)
               (if (= (length vec) n)
                   (setf (gethash (copy-seq vec) table) (incf order))
                   (loop :for i :from 1 :to n
                         :unless (aref use i)
                         :do (progn
                               (setf (aref use i) t)
                               (vector-push i vec)
                               (next n use vec)
                               (vector-pop vec)
                               (setf (aref use i) nil))))))
      (next n 
            (make-array `(,(1+ n)) :initial-element nil)
            (make-array `(,n) :adjustable t :fill-pointer 0))
      table)))

(let* ((n (read))
       (p (make-array `(,n)))
       (q (make-array `(,n)))
       (m (permutaions n)))
  (loop :for i :from 0 :to (1- n)
        :do (setf (aref p i) (read)))
  (loop :for i :from 0 :to (1- n)
        :do (setf (aref q i) (read)))
  (format t "~A~%" (abs (- (gethash p m) (gethash q m)))))


Measured memory_bytes: 29248
N, K = map(int, input().split())
A = list(map(int, input().split()))
A.sort()
mod = 10**9+7

fac = [0]*(N+1)
finv = [0]*(N+1)
inv = [0]*(N+1)

fac[0], fac[1] = 1, 1
finv[0], finv[1] = 1, 1
inv[1] = 1

for i in range(2, N+1):
    fac[i] = (fac[i-1] * i) % mod
    inv[i] = (- inv[mod%i] * (mod//i)) % mod
    finv[i] = finv[i-1] * inv[i] % mod       
    
def modcomb(n, r, mod):
    if n<r: return 0
    if n<0 or r<0: return 0
    return fac[n] * finv[r]*finv[n-r] %mod

ans = 0
ma = 0
mi = 0
for j in range(1, N+1):

    ans += (-modcomb(N-j, K-1, mod)+modcomb(j-1, K-1, mod))*A[j-1]
    ans %= mod
print(ans)


Measured memory_bytes: 24616
#!/usr/bin/env python3
import sys


def solve(N: int, A: "List[int]"):
    left = [A[0]] * N
    right = [A[-1]] * N

    for i in range(1,N):
        if(A[i] > left[i-1]):
            left[i] = A[i]
        else:
            left[i] = left[i-1]

    for i in reversed(range(0,N-1)):
        if(A[i] > right[i+1]):
            right[i] = A[i]
        else:
            right[i] = right[i+1]

    for i in range(N):
        if(i == 0):
            print(right[1])
        elif(i == N-1):
            print(left[N-2])
        else:
            print(max(left[i-1], right[i+1]))


    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    solve(N, A)

if __name__ == '__main__':
    main()


Measured memory_bytes: 15596
is_able_make = [False] * 2000
n = int(input())
A = [int(i) for i in input().split()]
q = int(input())
M = [int(i) for i in input().split()]

for i in A:
    for j in range(2000-i, 0, -1):
        if is_able_make[j] == True:
            is_able_make[i+j] = True
    is_able_make[i] = True

for x in M:
    if is_able_make[x] == True:
        print('yes')
    else:
        print('no')

Measured memory_bytes: 7756
#include<bits/stdc++.h>
#define int long long int
#define pb push_back
#define inf 1e9
#define pp pop_back
#define pii pair<int,int>
#define vec vector<int>
#define mp make_pair
using namespace std;
int h[100001],dp[100001];
int ans(int n,int k)
{
  if(n==1)
    return 0;
  if(dp[n]!=-1)
    return dp[n];
  int res=inf;
  for(int i=1;i<=min(k,n-1);i++)
    res=min(res,abs(h[n]-h[n-i])+ans(n-i,k));
  return dp[n]=res;
}
int32_t main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int t=1;
  //cin>>t;
  while(t--)
  {
    memset(dp,-1,sizeof(dp));
    int n,k;
    cin>>n>>k;
    int i;
    for(i=1;i<=n;i++)
        cin>>h[i];
    cout<<ans(n,k);
  }
}


Measured memory_bytes: 12964
#include<stdio.h>

#define UD -1
#define SIZE 100
int memo[SIZE];

int fib(int n){
	if( memo[n] != UD ){ return memo[n]; }
	if( n <= 1 ){ return 1; }
	return (memo[n] = fib(n-1) + fib(n-2));
}

int main(){
	int n, i;
	scanf("%d", &n);
	for( i = 0; i < SIZE; i++ ){ memo[i] = UD; }
	printf("%d\n", fib(n));
	return 0;
}

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

#define int long long
#define counter(m)     for(int i=0;i<m;i++)
#define gcd            __gcd
#define endl           "\n"
#define pb             emplace_back
#define setbits(x)     __builtin_popcountll(x)
#define zrobits(x)     __builtin_ctzll(x)
#define mod            1000000007
#define mod2           998244353
#define maxe           *max_element
#define mine           *min_element
#define inf            1e18
#define deci(x, y)      fixed<<setprecision(y)<<x
#define w(t)           int t; cin>>t; while(t--)
#define nitin          ios_base::sync_with_stdio(false); cin.tie(NULL)
#define PI             3.141592653589793238
using namespace std;

int32_t main() {
    nitin;
    string s,t;
    cin>>s>>t;
    int ans=INT_MAX;
    for(int i=0;i<s.length();i++)
    {
        int si=i;
        int sj=0;
        int cnt=0;
        int temp=0;
        while(si<s.length() && sj<t.length())
        {
            cnt++;
            if(s[si]!=t[sj])
                temp++;
            si++;
            sj++;
        }
        if(cnt==t.length())
            ans=min(ans,temp);
    }
    cout<<ans<<endl;
    return 0;
}

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




int main() {

    int N, M;

    cin >> N >> M;

    int start = M / N;
    int ans = 1;

    for (int i = start; i >= 1; i--) {
        
        if ( (M - i * N) % i == 0 ) {
            ans = i;
            break;
        }
    }

    cout << ans << '\n';
}



Measured memory_bytes: 256
n = list(input())
flag =0
for i in range(len(n)):
  if i%2==0:#奇数
    if n[i]=="L":
      flag=1
  elif i%2==1:
    if n[i]=="R":
      flag=1
if flag==0:
  print("Yes")
else:
  print("No")


Measured memory_bytes: 2940
#include <iostream>

using namespace std;

int
main ()
{
  int n, x, y;
  int i, j;
  cin >> n >> x >> y;
  int dist[n - 1] = { 0 };
  for (i = 1; i <= n; i++)
    {
      for (j = i + 1; j <= n; j++)
	{
	  ++dist[min (abs (j - i), abs (x - i) + 1 + abs (y - j)) - 1];
	}
    }
  for (i = 0; i < n - 1; i++)
    {
      cout << dist[i] << endl;
    }
  return 0;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string str;
    cin>>str;
    str+="S";
    int cnt=0,mx=0;
    for(int i=0;i<str.size();i++) {
        if(str[i]=='R') cnt++;
        else {
            mx=max(cnt,mx);
            cnt=0;
        }
    }
    cout<<mx<<endl;

}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define rep(i, N) for(int i=0; i<N; i++)
typedef long long ll;

int main() {
    int a, b; cin >> a >> b;
    string s; cin >> s;

    if(a+b+1!=s.size()){
        cout << "No" << endl;
        return 0;
    }

    for(int i=0; i<s.size(); i++){
        if(s.at(i)=='-'&&i!=a){
            cout << "No" << endl;
            return 0;
        }

        if(s.at(i)!='-'&&i==a){
            cout << "No" << endl;
            return 0;
        }
    }

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define st string
#define dl double
#define wh while
#define ve(i) vector<i>
#define repi(i, m, n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i, n) repi(i, 0, n)
#define sz(v) ((int)(v).size()) 
#define each(i, n) for(auto&& i: n)
#define pr(n) cout << fixed << setprecision(n)
#define ci(n) cin >> n
#define ci2(n, o) cin >> n >> o
#define ci3(n, o, p) cin >> n >> o >> p
#define co(n) cout << n << endl
#define mp(n, o) map<n, o>
#define so(n) sort(n.begin(), n.end())

int main() {
  int n , a = 0;
  ci(n);
  ve(int) p(n);
  rep(i, n) {
    ci(p.at(i));
  }
  repi(i, 1, n - 1) {
    ve(int) q(3); 
    q = {p.at(i - 1), p.at(i), p.at(i + 1)};
    so(q);
    if(p.at(i) == q.at(1)) {
      a++;
    }
  }
  co(a);
} 

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

typedef long long llint;
typedef long double ld;
typedef pair<int,int> P;

#define inf 1e18
#define mod 1000000007
#define sort(v) sort(v.begin(),v.end())
#define reverse(v) reverse(v.begin(),v.end())


priority_queue<llint,vector<llint>,greater<llint> > que;
priority_queue<llint> Que;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }

void solve(){
    llint n;
    cin >> n;
    vector<llint>a(n),b(n),c(n);
    for(int i=0;i<n;i++)cin >> a[i];
    for(int i=0;i<n;i++)cin >> b[i];
    for(int i=0;i<n;i++)cin >> c[i];
    sort(a);
    sort(b);
    sort(c);
    llint ans=0;
    for(auto bb:b){
        auto m1=lower_bound(a.begin(),a.end(),bb);
        auto m2=upper_bound(c.begin(),c.end(),bb);
        ans+=distance(a.begin(),m1)*distance(m2,c.end());
    }
    cout << ans << endl;


}

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





Measured memory_bytes: 5612
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64
#define rep(i, n) for(int i=0; i<n; i++)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mk make_pair
#define fi first
#define se second
#define pb push_back
#define ALL(x) x.begin(), x.end()
#define V(T) vector<T>
typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef vector<int> vi;
typedef vector<vi> vvi;
int max(int a, int b) {if(b>a) return b; else return a;}
int min(int a, int b) {if(b<a) return b; else return a;}


signed main() {
    string s;
    cin >> s;

    int res = 0, t = 1;
    bool a = false;
    rep(i, s.size()) {
        if(s[i]=='A' && !a) {
            a = true;
        } else if(a) {
            t++;
            if(s[i]=='Z') {
                res = max(res, t);
            }
        }
    }

    cout << res << endl;
    
    return 0;
}

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

int main()
{
  int N, q = pow(10, 9) + 7;
  int64_t ans = 1;

  cin >> N;
  for (int i = 1; i <= N; i++)
  {
    ans *= i;
    ans %= q;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int a,b,i,count=0;
    scanf("%d%d",&a,&b);
    for(i=0;;i++)
    {
        count++;
        a=a-b;
        if(a<0 || a==0)
        {
            break;
        }
    }
    printf("%d",count);
    return 0;
}

Measured memory_bytes: 128
//atcoder 20190824 B
#include <bits/stdc++.h>
#define N 2005

using namespace std;

const long long mod = 1e9+7;
long long n, k;
long long c[N];

long long a[N], b[N];
long long num[N];
long long ans;

long long calc(int x) {
	long long res = 0;
	for (int i = n; i > x; --i)
		if (a[i] < a[x]) ++res;
	return res;
}

int main() {

	cin >> n >> k;
	for (int i = 1; i <= n; ++i)
		cin >> a[i], b[i] = a[i];

	sort(b + 1, b + n + 1);
	for (int i = 1; i <= n; ++i)
		num[i] = lower_bound(b + 1, b + n + 1, a[i]) - b - 1;

	for (int i = n; i; --i) {
		(ans += calc(i) * k % mod) %= mod;
		(ans += k * (k - 1) / 2 % mod * num[i] % mod) %= mod;
	}

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


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
typedef long long ll;
using namespace std;
int main()
{
	string a;
	cin >> a;
	if (a[0] == a[2]) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define IO_OP std::ios::sync_with_stdio(0); std::cin.tie(0);
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define EB emplace_back

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
typedef vector<int> vi;

const int INF = 1e9 + 7;

pi a[100005];

int main()
{
	IO_OP;
	
	int n, m;
	cin >> n >> m;
	for(int i=0;i<n;i++)
		cin >> a[i].S >> a[i].F;
	sort(a, a+n, greater<pi>());
	set<int> s;
	for(int i=0;i<=m;i++)
		s.insert(i);
	int ans = 0;
	for(int i=0;i<n;i++) {
		int l = m - a[i].S;
		if(s.upper_bound(l) == s.begin()) continue;
		int t = *prev(s.upper_bound(l));
		s.erase(t);
		ans += a[i].F;
	}
	cout << ans << endl;

}



Measured memory_bytes: 5760
#include <bits/stdc++.h>
using namespace std;
using ull=unsigned long long;
using ar=array<ull,26>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,a,n) for(int i=a;i<n;i++)
int main(){
	string s1,s2;
	ar ht; ht[0]=1;
	rep(i,25) ht[i+1]=ht[i]*10007;
	
	while(cin>>s1>>s2){
		if(s1.size()>s2.size()) swap(s1,s2);
		int n1=s1.size(), n2=s2.size();
		unordered_set<ull> list1;

		for(int l=n1;l>=1;l--){
			list1.clear();
			ull tmp=0;
			rep(i,n1) {
				tmp+=ht[s1[i]-'a'];
				if(i>=l) tmp-=ht[s1[i-l]-'a'];
				if(i>=l-1) list1.insert(tmp);
			}
			tmp=0;
			rep(i,n2){
				tmp+=ht[s2[i]-'a'];
				if(i>=l) tmp-=ht[s2[i-l]-'a'];
				if(i>=l-1) {
					if(list1.find(tmp) != list1.end()){
						cout<<l<<endl;
						goto end;
					}
				}
			}
		}
		cout<<0<<endl;
		end: ;
	}
	return 0;
}



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

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    vector<double> p(6), q(6);
    for (auto &x: p) { cin >> x; x /= 100; } 
    for (auto &x: q) { cin >> x; x /= 100; }
    auto f = [&](double x, double y) {
        double ret = 0;
        for (int i = 0; i < 6; i++) {
            ret += max(p[i]*x, q[i]*y);
        }
        return ret;
    };
    double lf = 0, rg = 1;
    for (int i = 0; i < 300; i++) {
        double s = (lf*2 + rg) / 3, t = (lf + rg*2) / 3;
        if (f(s, 1-s) < f(t, 1-t)) rg = t;
        else lf = s;
    }
    cout << setprecision(12) << f(lf, 1-lf) << "\n";
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int r = stdIn.nextInt();
		
		
		if(r < 1200) {
			System.out.println("ABC");
		}else if(r < 2800) {
			System.out.println("ARC");
		}else {
			System.out.println("AGC");
		}
		
	}

}


Measured memory_bytes: 21844
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int max, min;
		min = Math.min(a, b);
		min = Math.min(min, c);
		max = Math.max(a, b);
		max = Math.max(max, c);

		System.out.println(min + " " + max);
	}

}



Measured memory_bytes: 26256
//#include<bits/stdc++.h>
#include<algorithm>
#include<iostream>
#include<iomanip>
#include<cstring>
#include<cstdlib>
#include<utility>
#include<cctype>
#include<string>
#include<bitset>
#include<vector>
#include<cstdio>
#include<ctime>
#include<cmath>
#include<queue>
#include<deque>
#include<stack>
#include<list>
#include<set>
#include<map>
#define INF 1000000000
#define ll long long
#define mod 1000000007
#define pb push_back
using namespace std;
char *fs,*ft,buf[1<<15];
inline char getc()
{
	return (fs==ft&&(ft=(fs=buf)+fread(buf,1,1<<15,stdin),fs==ft))?0:*fs++;
}
inline ll read()
{
	ll x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
const ll MAXN=1000010<<1;
ll n=2000002,k,L,top;
ll fac[MAXN],w[MAXN],inv[MAXN],c[MAXN];
inline ll C(ll x,ll y)
{
	return fac[x]*inv[y]%mod*inv[x-y]%mod;
}
inline ll calc(ll x,ll y)
{
	ll ans=0;
	for(ll i=1;i<=x+1;++i)ans=(ans+C(i+y,y))%mod;
	return ans;
}
inline ll fast_pow(ll b,ll p)
{
	ll cnt=1;
	while(p)
	{
		if(p&1)cnt=cnt*b%mod;
		p=p>>1;
		b=b*b%mod;
	}
	return cnt;
}
int main()
{
	//freopen("1.in","r",stdin);
	fac[0]=1;
	for(ll i=1;i<=n;++i)fac[i]=fac[i-1]*i%mod;
	inv[n]=fast_pow(fac[n],mod-2);
	for(ll i=n-1;i>=0;--i)inv[i]=inv[i+1]*(i+1)%mod;
	ll x,y,xx,yy;
	x=read();y=read();xx=read();yy=read();
	printf("%lld\n",((calc(xx,yy)-calc(x-1,yy)-calc(xx,y-1)+calc(x-1,y-1))%mod+mod)%mod);
	return 0;
}


Measured memory_bytes: 36096
def myAnswer(N:int,V:list) -> float:
   ans = 0
   V.sort()
   while len(V)!=1:
      tmp = (V.pop(0)+V.pop(0))/2
      V.append(tmp)
      V.sort()

   return V[0]

def modelAnswer():
   tmp=1
def main():
   N = int(input())
   V = list(map(int,input().split()))
   print(myAnswer(N,V[:]))

if __name__ == '__main__':
   main()

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define N 110
using namespace std;
int d[N][N];
char s[N][N];
int main(){
	int n,m;
	scanf("%d%d",&n,&m);
	for(int i=0;i<n;i++){
		scanf("%s",s[i]);
	}
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			if(i||j) d[i][j]=10234567;
			if(i) d[i][j]=min(d[i][j],d[i-1][j]+(s[i][j]!=s[i-1][j]));
			if(j) d[i][j]=min(d[i][j],d[i][j-1]+(s[i][j]!=s[i][j-1]));
		}
	}
	int x=d[n-1][m-1];
	if(s[0][0]=='#') x++;
	if(s[n-1][m-1]=='#') x++;
	printf("%d\n",(x+1)/2);
	return 0;
}

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

using namespace std;

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(a) (a).begin(),(a).end()
#define PI 3.14159265358979323846264338327950L
#define INF 1050000000
#define INFL (long long)(4e18)

using vi = vector<int>;
using Graph = vector<vector<int>>;


int main() {

	int X, N;

	cin >> X >> N;

	vi p(N);

	REP(i, N) {
		cin >> p[i];
	}

	int k = 0;

	int ans;

	while (1) {

		if (find(ALL(p), X - k) == p.end()) {
			ans = X - k;
			break;
		}
		if (find(ALL(p), X + k) == p.end()) {
			ans = X + k;
			break;
		}

		k++;
	}

	cout << ans << endl;


	return 0;
}

Measured memory_bytes: 3644
def read_input():
    h, w = map(int, input().split())
    board = []

    for i in range(h):
        s = [c for c in input().strip()]
        board.append(s)

    return h, w, board


# マス(i, j)の上下左右のいずれかに黒が居るかどうか調べる
def check_neighbor(board, i, j):
    if i - 1 >= 0:
        if board[i - 1][j] == '#':
            return True
    if i + 1 < len(board):
        if board[i + 1][j] == '#':
            return True

    if j - 1 >= 0:
        if board[i][j - 1] == '#':
            return True
    if j + 1 < len(board[i]):
        if board[i][j + 1] == '#':
            return True
    return False


def submit():
    h, w, board = read_input()

    for i in range(h):
        for j in range(w):
            if board[i][j] == '#' and not check_neighbor(board, i, j):
                print('No')
                return

    print('Yes')


if __name__ == '__main__':
    submit()


Measured memory_bytes: 3064
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <string>
#include <cmath>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
using ll = long long;
using namespace std;
int main () {
    string s;
    cin >> s;
    // cout << s ;
    int len;
    len = s.size() -2;
    char a = s.front();
    char b = s.back();
    cout << a ;
    cout << len ;
    cout << b ;

    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>

#define ll long long
#define ull unsigned long long

using namespace std;

int main() {
	int N, K;
	cin >> N >> K;

	vector <int> P(N);
	for (int ii = 0; ii < N; ++ii){
		cin >> P[ii];
	}

	//単調増加部分を事前チェックしておく
	vector <bool> mono(N-K+1, false);
	int r = 0;
	int len = 0;
	for (int l = 0; l < N; ++l){
		//長さがKになるまで右端を動かす
		while(len < K) {
			if (r >= N) break;
			if (P[r] > P[r+1]) break;
			r++;
			len = r - l + 1;
		}
		//長さがKになっていたらメモ
		if (len == K) {
			mono[l] = true;
			len--;
		} else {
			l = r;
			r = r+1;
		}
	}

	//初期化
	set<int> s;
	for (int ii = 0; ii < K; ++ii){
		s.insert(P[ii]);
	}
	int ans = 1;
	int sameCnt = 0;
	if (mono[0]){
		sameCnt++;
	}

	for (int ii = 0; ii < N - K; ++ii){
		int valErase = P[ii];
		int valInsert = P[ii+K];

		auto itr1 = s.begin();
		bool cond1 = (*itr1 == valErase);
		auto itr2 = s.rbegin();
		bool cond2 = (*itr2 < valInsert);

		if (cond1 && cond2){
		} else {
			if (mono[ii+1]){
				if (sameCnt == 0){
					ans++;
				}
				sameCnt++;
			} else {
				ans++;
			}
		}
		s.erase(valErase);
		s.insert(valInsert);
	}

	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 10368
#include<iostream>
#include<algorithm>
#include<map>
#define F first
#define S second
using namespace std;

pair < int, int > p[1000010];

int main(){

  int n;
  int c1,m1,s1,m2,s2,m3,s3,m4,s4;

  while(cin >> n, n){

    for(int i=0;i<n;i++){
      cin >> c1 >> m1 >> s1 >> m2 >> s2 >> m3 >> s3 >> m4 >> s4;
      p[i].S = c1;
      p[i].F = (m1+m2+m3+m4)*60 + s1+s2+s3+s4;
    }

    sort(p, p+n);

    cout << p[0].S << endl << p[1].S << endl << p[n-2].S << endl;
  }
}

Measured memory_bytes: 8976