akhauriyash/Code-Regression huggingface dataset:
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys  # {{{
import os
import time
import re
from pydoc import help
import string
import math
from operator import itemgetter
from collections import Counter
from collections import deque
from collections import defaultdict as dd
import fractions
from heapq import heappop, heappush, heapify
import array
from bisect import bisect_left, bisect_right, insort_left, insort_right
from copy import deepcopy as dcopy
import itertools
# }}}

# pre-defined{{{
sys.setrecursionlimit(10**7)
INF = 10**20
GOSA = 1.0 / 10**10
MOD = 10**9+7
ALPHABETS = [chr(i) for i in range(ord('a'), ord('z')+1)]  # can also use string module
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def DP(N, M, first): return [[first] * M for n in range(N)]
def DP3(N, M, L, first): return [[[first] * L for n in range(M)] for _ in range(N)]
from inspect import currentframe
# }}}

def solve():
    s = input()
    if s == "ABC":
        print("ARC")
    else:
        print("ABC")

    return 0

if __name__ == "__main__":# {{{
    solve()

# vim: set foldmethod=marker: }}}


Measured memory_bytes: 79640
#include <stdio.h>

#define debug  
#define NMAX 100010
#define NIL -1

int left[NMAX];
int right[NMAX];
int parent[NMAX];
int depth[NMAX];

void setDepth(int i, int d) {
    debug("setDepth %d %d\n", i, d);
    if (i == NIL) {
        return;
    }
    depth[i] = d;
    setDepth(left[i], d + 1);
    setDepth(right[i], d);
}

int main() {
    int n, k, id, prev, x;
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        parent[i] = NIL;
        left[i] = NIL;
        right[i] = NIL;
    }
    for (int i = 0; i < n; i++) {
        scanf("%d %d", &id, &k);
        for (int j = 0; j < k; j++) {
            scanf("%d", &x);
            parent[x] = id;
            if (j == 0) {
                left[id] = x;
            } else {
                right[prev] = x;
            }
            prev = x;
        }
    }
    int root = 0;
    for (int i = 0; i < n; i++) {
        if (parent[i] == NIL) {
            root = i;
            break;
        }
    }
    setDepth(root, 0);
    for (int i = 0; i < n; i++) {
        printf("node %d: ", i);
        printf("parent = %d, ", parent[i]);
        printf("depth = %d, ", depth[i]);
        if (parent[i] == NIL) {
            printf("root, ");
        } else if (left[i] == NIL) {
            printf("leaf, ");
        } else {
            printf("internal node, ");
        }
        printf("[");
        k = left[i];
        while (k!=NIL) {
            printf("%d", k);
            if (right[k] != NIL) {
                printf(", ");
            }
            k = right[k];
        }
        printf("]\n");
    }

    return 0;
}


Measured memory_bytes: 4128
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.math;


void main() {
    int n, q;
    scan(n, q);

    auto sd = SqrtDecomp(n);

    foreach (_ ; 0 .. q) {
        auto line = readln.split.to!(int[]);
        if (line[0] == 0) {
            sd.add(line[1] - 1, line[2]);
        }
        else {
            writeln(sd.sum(line[1] - 1, line[2]));
        }
    }
}

struct SqrtDecomp {
    private {
        int sqrtN;
        int N, K;
        int[] bucketSum;
        int[] data;
    }

    this(int n) {
        N = n;
        sqrtN = sqrt(n.to!real).to!int;
        K = (N + sqrtN - 1) / sqrtN;
        bucketSum = new int[](K);
        data = new int[](K * sqrtN);
    }

    void add(int i, int x) {
        int k = i / sqrtN;
        data[i] += x;
        bucketSum[k] += x;
    }

    int sum(int l, int r) {
        int res;
        foreach (k ; 0 .. K) {
            int bl = k * sqrtN, br = (k + 1) * sqrtN;
            if (r <= bl || br <= l) continue;
            if (l <= bl && br <= r) {
                res += bucketSum[k];
            }
            else {
                foreach (i ; max(l, bl) .. min(r, br)) {
                    res += data[i];
                }
            }
        }
        return res;
    }
}



void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}



void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}



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

#define rep(i, a, b) for(int i = (a); i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define endl '\n'

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;

const ll mod = 1000000007;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
// head

const int nax = 3001;
ll dp[nax][nax][4];
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);

    int r, c, k;
    cin >> r >> c >> k;
    vector<vector<int>> g(r, vector<int>(c, 0));
    rep(i,0,k) {
        int y, x, v;
        cin >> y >> x >> v;
        y--;
        x--;
        g[y][x] = v;
    }
    memset(dp,0,sizeof(dp));

    auto selfmax = [&](ll& a, ll b) {
        a = max(a, b);
    };
    rep(i,0,r) {
        rep(j,0,c) {
            rep(k,0,4) { // squares on this row i can take
                if (g[i][j] > 0 && k > 0) {
                    if(i + 1 < r) {
                        selfmax(dp[i + 1][j][3], dp[i][j][k] + g[i][j]);
                    }
                    if(j + 1 < c) {
                        selfmax(dp[i][j + 1][k - 1], dp[i][j][k] + g[i][j]);
                        selfmax(dp[i][j + 1][k], dp[i][j][k]);
                    }
                } else {
                    if(i + 1 < r)
                        selfmax(dp[i + 1][j][3], dp[i][j][k]);
                    if(j + 1 < c)
                        selfmax(dp[i][j + 1][k], dp[i][j][k]);
                }
            }
        }
    }
    ll ans = 0;
    for(int i = 0; i < 4; i++) {
        if(i > 0)
            selfmax(ans, dp[r - 1][c - 1][i] + g[r - 1][c - 1]);
        else selfmax(ans, dp[r - 1][c - 1][i]);
    }
    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 320020
#include <bits/stdc++.h>
using namespace std;
using lint = long long;

void Main() {
  int N;
  unordered_map<string, int> S;
  cin >> N;
  S.reserve(N);

  lint ans = 0;
  string s;
  for (int i = 0; i<N; ++i) {
    cin >> s;
    sort(s.begin(), s.end());
    ans += S[s]++;
  }
  cout << ans << "\n";
}

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  Main();
}


Measured memory_bytes: 10496
# -*- coding: utf-8 -*-
import numpy as np

n = int(input())
a = np.array(input().split(), dtype='int')

a_sort = np.sort(a)
ans = ''

for i in range(n - 1):
    if a_sort[i] == a_sort[i + 1]:
        ans = 'NO'
        break
    
if ans == 'NO':
    print(ans)
else:
    print('YES')

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

int main() {
    int n, ans = 0;
    cin >> n;
    ans += n / 25;
    n = n % 25;
    ans += n / 10;
    n = n % 10;
    ans += n / 5;
    n = n % 5;
    ans += n; 

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


Measured memory_bytes: 3112
#include<iostream>
using namespace std;
int main(){
	
	int res=0,all=0;
	int n,x[10005];
	cin >> n >>all;
	res += n;
	
	for(int i=0;i<n;i++){
		cin >> x[i];
		all -= x[i];
	}
	int min_a = x[0],min_b = 0;
	for(int i=0;i<n;i++){
		if(x[min_b] > x[i]){
			min_b = i;
			min_a = x[i];
		}
	}
	while(all > 0){
		if(all < min_a){
			break;
		}else {
			all -=min_a;
			res++;
		}
	}
	cout << res;
	
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
namespace Capp
{
    class Program
    {
        public enum En
        {
            a
            ,b
            ,c
            ,d
            ,e
            ,f
        }

        
        static void Main(string[] args)
        {
            var c = new Solve();
            c.S();

        }
    }

    public class Solve
    {
        List<int>[] es = new List<int>[10];
        List<List<int>> es2;
        int n;
        int m;
        int res = 0;
        // 訪問管理
        bool[] visit = new bool[10];
        private void rec(int x)
        {
            bool ok = true;
            for (int i = 0; i < n; i++)
            {
                if (!visit[i])
                    ok = false;
            }
            if (ok)
            {
                res++;
                return;
            }

            foreach (var v in es[x])
            {
                if (visit[v]) continue;

                visit[v] = true;

                rec(v);
                visit[v] = false;
            }
        }
        public void S()
        {
            var nm = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            n = nm[0];
            m = nm[1];
            es2 = new List<List<int>>();
            for (int i = 0; i < 10; i++)
            {
                es2.Add(new List<int>());
                es[i] = new List<int>();
            }
            for (int i = 0; i < m; i++)
            {
                var s = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
                var a = s[0] - 1;
                var b = s[1] - 1;
                es[a].Add(b);
                es[b].Add(a);

                es2[a].Add(b);
                es2[b].Add(a);
            }
            visit[0] = true;
            rec(0);
            Console.WriteLine(res);
        }
    }

    public class Test<T> : ITest<T>
    {
        public string S { get; set; }
    }

    public interface ITest<out T>
    {
        string S { get; set; }
    }

    struct c
    {
        public string s { get; set; }
        private dynamic _d;
        public dynamic d { get { return _d; }}
        public void Setd(dynamic d)
        {
            _d = d;
        }
    }
    class AsTest
    {
        internal async Task<int> AsyncMethod(int x)
        {
            var t1 = Task.Run(() =>
            {
                Thread.Sleep(10000);
                return 10 * x;
            });
            var res = await t1;
            Console.WriteLine($"asyncmethod {res}");


            return res;
        }

    }
}


Measured memory_bytes: 13396
m=100

gets.to_i.times{m=(m*1.05).ceil}

puts m*1000



#浮動小数点数の切り捨てはfloorメソッドを用いる
#(例)1.4.floor→1  -1.4.floor→-2 (負数の場合は、絶対値が大きい方に丸められる)
#浮動小数点数の切り上げはceilメソッドを用いる
#(例)1.4.ceil→2 -1.4.ceil→-1 (負数の場合は、絶対値が小さい方に丸められる)

#小数点以下 N 桁の切り捨て・切り上げの場合は、BigDecimal を使用する
#require 'bigdecimal'
#BigDecimal(1.23456.to_s).floor(2).to_f # 1.24
#BigDecimal((1.23456).to_s).ceil(2).to_f # 1.24

#BigDecimal のオブジェクトを生成するときは、引数に String を指定しなければならないので、
#to_s で Float を String に変換しています。さらに最後に to_f で Float に戻しています。

#四捨五入には、 round メソッドを使用する。
#1.4.round→1　1.23456.round(2)→1.23  小数点以下N桁の四捨五入ではBigDecimalは不要




Measured memory_bytes: 6860
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {

  public static void main(String[] args) throws Exception {
    try (final var stdin = new InputStreamReader(System.in);
         final var br = new BufferedReader(stdin)) {
      br.readLine();
      final var l = Arrays.stream(br.readLine().split(" "))
        .mapToLong(Long::parseLong)
        .toArray();

      var count = 0;
      for (int i = 0; i < l.length; i++) {
        for (int j = i + 1; j < l.length; j++) {
          for (int k = j + 1; k < l.length; k++) {
            if (l[i] == l[j] || l[j] == l[k] || l[k] == l[i]) continue;

            final var l0 = Math.min(Math.min(l[i], l[j]), l[k]);
            final var l2 = Math.max(Math.max(l[i], l[j]), l[k]);
            final var l1 = l[i] + l[j] + l[k] - l0 - l2;

            if (l0 + l1 <= l2) continue;

            count++;
          }
        }
      }

      System.out.println(count);
    }
  }
}


Measured memory_bytes: 34780
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

string s;

int main(void)
{
	cin >> s;
	reverse(s.begin(), s.end());
	
	int pos = 0;
	while(1){
		if(pos == s.size()) goto yes;
		if(s.size() - pos >= 5 && s.substr(pos, 5) == "esare") pos += 5;
		else if(s.size() - pos >= 5 && s.substr(pos, 5) == "maerd") pos += 5;
		else if(s.size() - pos >= 6 && s.substr(pos, 6) == "resare") pos += 6;
		else if(s.size() - pos >= 7 && s.substr(pos, 7) == "remaerd") pos += 7;
		else goto no;
	}
	
	yes:
	cout << "YES" << endl;
	return 0;
	
	no:
	cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 512
def main():
  s = input().strip()
  prevs = s[0]
  is_aa = False
  for _s in s[1:]:
    if prevs == _s:
      is_aa = True
      break
    prevs = _s
  if is_aa:
    print('Bad')
  else:
    print('Good')

if __name__ == '__main__':
  main()


Measured memory_bytes: 2940
// AtCoder.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//


#define _USE_MATH_DEFINES
#include<math.h>

//#include<cmath>

#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
#include<stack>
#include<memory>



//#include "Ants.h"
using namespace std;
typedef long long ll;
#define rad_to_deg(rad) (((rad)/2/M_PI)*360)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i,n) for(int i=0;i<n;i++)
#define show(s) cout<<s<<endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define LINF (1000000000000000000ll)

typedef pair < int, int> P;
int a, b;

int main()
{
	cin >> a >> b;
	rep(i, 3) {
		if (a != i+1 && b != i+1) {
			cout << i + 1 << endl;
			return 0;
		}
	}
	
	
}

Measured memory_bytes: 256
d, g = map(int, input().split())
pc = [list(map(int, input().split())) for _ in range(d)]


def dfs(i, sum, count, nokori):
    global ans
    if i == d:#全ての最後の問題セットにたどり着いたら,　全ての葉を確認
        if sum < g:
            use = max(nokori)#選んでいない種類で最大のスコアの問題を選ぶ
            #-(-(g-sum)//(use*100)) <- (g-sum)//(use*100)
            n = min(pc[use-1][0], -(-(g-sum)//(use*100)))#その難易度の問題の数 または 残りの必要スコア/その難易度の問題1問の点数　の最小値をとる->余計に問題を解かない＆問題数を超えてとかない
            count += n
            sum += n * use * 100

        if sum >= g:#全ての葉の達成してる最小の答えを記録
            ans = min(ans, count)

    else:
        dfs(i+1, sum, count, nokori)#選ばなかった場合
        dfs(i+1, sum + pc[i][0] * (i+1) * 100 + pc[i][1], count + pc[i][0], nokori - {i+1})#全て解いた番号をセットから抜いて、合計&countを更新

ans = float("inf")
dfs(0, 0, 0, set(range(1, d+1)))
print(ans)


Measured memory_bytes: 9236
#include<iostream>
#include<cstring>
using namespace std;
int main(){
  int k; cin >> k;
  char *n = new char[11*100010]; memset(n,0,11*100010);
  for(int i=0;i<9;i++) n[i*11]='1'+i;
  int ps=0; int pe=9; int cr=1;
  do {
    int pc=pe;
    for(int p=ps;p<pe;p++){
      if( n[p*11+cr-1] == '0' ){
        memcpy(&n[pc*11],&n[p*11],cr); n[pc*11+cr] = '0'; pc++;
        memcpy(&n[pc*11],&n[p*11],cr); n[pc*11+cr] = '1'; pc++;
      }else if( n[p*11+cr-1] == '9' ){
        memcpy(&n[pc*11],&n[p*11],cr); n[pc*11+cr] = '8'; pc++;
        memcpy(&n[pc*11],&n[p*11],cr); n[pc*11+cr] = '9'; pc++;
      }else{
        memcpy(&n[pc*11],&n[p*11],cr); n[pc*11+cr] = n[p*11+cr-1]-1; pc++;
        memcpy(&n[pc*11],&n[p*11],cr); n[pc*11+cr] = n[p*11+cr-1]; pc++;
        memcpy(&n[pc*11],&n[p*11],cr); n[pc*11+cr] = n[p*11+cr-1]+1; pc++;
      }
      if( pc >= k ) goto finish;
    }
    cr++;
    ps=pe;
    pe=pc;
  } while( true );
  finish:
  printf("%s\n",&n[(k-1)*11]);
  return 0; 
}
  


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

const ll MAX = 200000;
const ll INF = 1001001001;
const ll MOD = 1000000007;
const double PI=3.1415926535897932;

ll N, ans=0, tmp=0;
vector<vector<ll>> G;

ll dfs(ll id) {
    vector<ll> v;
    for(int i=0;i<G[id].size();i++) {
        v.push_back(dfs(G[id][i]));
    }
    sort(v.begin(), v.end());
    reverse(v.begin(), v.end());
    tmp = 0;
    for(int i=0;i<v.size();i++) {
        tmp = max(tmp, 1+i+v[i]);
    }
    return tmp;
}

signed main(){
    cin >> N;
    G.resize(N);
    for(int i=0;i<N-1;i++) {
        ll a;
        cin >> a;
        a--;
        G[a].push_back(i+1);
    }
    cout << dfs(0) << endl;
    return 0;
}

Measured memory_bytes: 17760
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.nextLine());
		Set<String> set = new HashSet<String>();
		for(int i =0 ; i < n;i++) {
			set.add(sc.nextLine());
		}
		System.out.println(set.size());
	}

}


Measured memory_bytes: 79636
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(x) x.begin(), x.end()
#define mod 1000000007
typedef long long ll;

int main() {
    ll num;
    cin >> num;
    ll money = 100;
    ll count = 0;
    while(true){
        if(money >= num){
            cout << count << endl;
            return 0;
        }
        money *= 1.01;
        count++;
    }
    return 0;
}

Measured memory_bytes: 3632
require'matrix'
eval'H,W,K='+`dd`.split*?,
f=1,1,2,3,5,8,13,21
A=Matrix[
	*(1..W).map{|i|
		(1..W).map{|j|
			if i==j
				f[i-1]*f[W-i]
			elsif i+1==j
				f[i-1]*f[W-j]
			elsif i==j+1
				f[i-2]*f[W-i]
			else
				0
			end
		}
	}
]
p (A**H)[0,K-1].%10**9+7

Measured memory_bytes: 3444
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
int main(){
    int n;
    double sum=0;
    cin >> n;
    for(int i=0; i<n; i++){
        double a;
        cin >> a;
        sum += 1/a;
    }
    cout << 1/sum << endl;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
a = [0] * M
b = [0] * M
c = []
for i in range(M):
    a[i], b[i] = map(int, input().split())
    c.append(a[i])
    c.append(b[i])

for i in range(N):
    print(c.count(i+1))


Measured memory_bytes: 3060
import java.util.Scanner;

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

		int intNum = sc.nextInt();


		if(1000 <= intNum) {
			System.out.println("ABD");
		}
		else {
			System.out.println("ABC");
		}

	}
}


Measured memory_bytes: 21844
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
struct data{
    char c;int cnt;
    data(char a,int b){
        c=a;cnt=b;
    }
    data(){}
};
int main(){
    int Max=0;
    vector<data>V;
    string str;
    cin>>str;
    char lc=str[0];
    int cnt=0;
    for(int i=0;i<str.length();i++){
        if(str[i]!=lc){
            V.push_back(data(lc,cnt));
            lc=str[i];
            cnt=1;
        }
        else cnt++;
    }
    V.push_back(data(lc,cnt));
    for(int i=1;i<V.size()-1;i++){
        data d=V[i];
        if(d.c=='O'){
            if(V[i+1].cnt>=d.cnt&&V[i-1].cnt>=d.cnt&&V[i-1].c=='J'&&V[i+1].c=='I'){
                Max=max(Max,d.cnt);
            }
        }
    }
    cout<<Max<<endl;
}

Measured memory_bytes: 12640
#include <stdio.h>          // printf(), fprintf(), scanf()
#include <stdlib.h>         // exit(), atoi()
#include <string.h>         // strcmp()

#define STACK_SIZE 100

int stack[STACK_SIZE];
int sp;

void
cleanup(int ecode)
{
	exit(ecode);
}

int
stack_size()
{
	return sp;
}

void
push(int x)
{
	if (sp >= STACK_SIZE)
	{
		fprintf(stderr, "Stack area overflow. size:%d\n", STACK_SIZE);
		cleanup(1);
	}

	stack[sp++] = x;
}

int
pop()
{
	if (sp <= 0)
	{
		fprintf(stderr, "Stack underflow\n");
		cleanup(1);
	}

	sp--;
	return stack[sp];
}

int
main(int argc, char** argv)
{
	char str[20];
	int a, b;

	sp = 0;
	while (scanf("%s", str) != EOF)
	{
		if (strcmp(str, "+") == 0)
		{
			b = pop();
			a = pop();
			push(a + b);
		}
		else if (strcmp(str, "-") == 0)
		{
			b = pop();
			a = pop();
			push(a - b);
		}
		else if (strcmp(str, "*") == 0)
		{
			b = pop();
			a = pop();
			push(a * b);
		}
		else
			push(atoi(str));
	}

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

Measured memory_bytes: 548
//@@@@@@@@@@ JAI BAJRANG BALI @@@@@@@@@

// COMPILE BY:) NAMAN


#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define maxn 10000001
#define endl "\n"
#define inf INT_MAX
#define vec vector <ll>
#define mps map <ll,ll>
#define ppl vector<pair<ll,ll>> 
#define fi first
#define si second
#define pr pair<ll,ll> 
#define mvec map<ll,vector <ll>>
#define all(v) v.begin(),v.end()
#define infi LLONG_MAX
#define pi 3.141592653
#define ninf INT_MIN
#define ninfi LLONG_MIN
#define lbn lower_bound
#define ubn upper_bound
#define memset(a,b) memset(a,(b),sizeof(a))
  
int main()
{
 
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s;
    cin>>s;
    if(s=="ABC")
    	cout<<"ARC"<<endl;
    else
    	cout<<"ABC"<<endl;

return 0;
}


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

using namespace std;

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define RREP(i,s,n) for(lli i=s;i>=n;i--)
#define MOD 1000000007
#define NUM 2520
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define INF (1LL<<50)

signed main(){

	lli A,B,m;
	cin>>A>>B>>m;

	vector<lli> a(A),b(B);
	lli minA = INF,minB = INF;
	REP(i,0,A){
		cin>>a[i];
		minA = min(a[i],minA);
	}
	REP(i,0,B){
		cin>>b[i];
		minB = min(b[i],minB);
	}

	lli cost = minA+minB;

	REP(i,0,m){
		lli x,y,c;
		cin>>x>>y>>c;
		x--,y--;
		cost = min(cost,a[x]+b[y]-c);
	}
	cout<<cost<<endl;


	return 0;
}

Measured memory_bytes: 1792
# include "iostream"
# include "cstdio"

using namespace std;

const int Mod=1e9+7;
const int maxm=1e4+10;

int H,W;
long long DP[maxm][maxm];
char Map[maxm][maxm];

int main(){
	register int i,j;
	scanf("%d%d",&H,&W);
	DP[1][1]=1;
	for(i=1;i<=H;i++) scanf("%s",Map[i]+1);
	for(i=1;i<=H;i++){
		for(j=1;j<=W;j++){
			if(i==1 && j==1) continue;
			DP[i][j]=(DP[i][j-1]*(Map[i][j-1]=='.')+(DP[i-1][j])*(Map[i-1][j]=='.'))%Mod;
		}
	}
	printf("%lld",DP[H][W]);
	return 0;
}

Measured memory_bytes: 89344
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#define Max 10000
int main(){
  int n,y,i,l,cnt=0;
  int a[Max];
  scanf("%d",&n);
  if(n<1 || n>Max){
    exit(1);
  }
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
    }
  
  for(i=0;i<n;i++){
    y=sqrt(a[i]);
    //printf("y:%d\n",y);
    for(l=2;l<=y;l++){
      if(a[i]%l==0){
	//printf("a:%d l:%d\n",a[i],l);
	cnt++;
	break;
      }
    }
  }
  printf("%d\n",n-cnt);

  return 0;
}



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

int main(){
	int N;
  string str;
  cin >> N;
  cin >> str;
  if(N%2!=0){cout << "No" << endl;return 0;}
  
  rep(i,N/2){
  	if(str[i]!=str[i+(N/2)]){cout << "No" << endl;return 0;}
  }
  
  cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <limits.h>
#include <math.h>
#include <functional>
#include <bitset>

#define repeat(i,n) for (long long i = 0; (i) < (n); ++ (i))
#define debug(x) cerr << #x << ": " << x << '\n'
#define debugArray(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i] << '\n'
#define debugArrayP(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i].first<< " " << x[i].second << '\n'

using namespace std;

typedef long long ll;
typedef pair<int,int> Pii;
typedef vector<int> vint;
typedef vector<ll> vll;
const ll INF = LLONG_MAX/10;
const ll MOD = 1e9+7;

int main(){
  ll N;cin >> N;
  vll A(N);
  repeat(i,N){
    cin >> A[i];
  }
  ll ans = 0;
  ll maxA = 0;
  repeat(i,N){
    ans += (A[i]-1)/(maxA+1);
    if(i==0||A[i] == maxA+1){
      maxA++;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <fstream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <cstdlib>
#include <cstdio>
#include <string>
#include <cstring>
#include <cassert>
#include <utility>
#include <iomanip>

using namespace std;

#define sz(x) (int) x.size()
#define unique(x) x.erase(unique(x.begin(), x.end()), x.end())
#define all(a) a.begin(), a.end()
#define sqr(x) ((x) * (x)) 
#define y1 aksjdaskdjksjfksdjf
#define left kdnvldvoiwejifejg
#define right lkdsjflksdjfdjfk
#define prev asdasfsadjkjsdfjs
#define tm aklsjdasjdasjdkdjjf

int main() { 

  int x;
  cin >> x;
  if (x == 3 || x == 5 || x == 7) {
    puts("YES");
  } else {
    puts("NO");
  }

  return 0;
}


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


int main() {
	int n, r1[110], r2[110];
	cin >> n;
	for (int i=0; i<n; i++) cin >> r1[i] ;
	for (int i=0; i<n; i++) cin >> r2[i] ;
	
	int max_c = 0;
	for (int i=0; i<n; i++) {
		int cntc = 0;
		for (int j=0; j<i+1; j++) cntc+=r1[j];
		for (int k=i; k<n; k++) cntc+=r2[k];
		max_c=max(max_c, cntc);
	}
	cout << max_c << endl;

}


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

using namespace std;


int main() {
    long long a, b, c, k;
    cin >> a >> b >> c >> k;
    if(k % 2 == 1) {
        cout << b - a << "\n";
    } else {
        cout << a - b << "\n";
    }
    return 0;
}

Measured memory_bytes: 3564
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")

#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define pii pair<int,int>
#define pli pair<long long int,int>
#define pbi pair<bool,int>
#define pob pop_back
#define all(a) a.begin(),a.end()
#define fio ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0);
#define i64 long long int
#define mem(x,y) memset(x,y,sizeof(x))
#define fill(arr,b) fill(arr, arr+sizeof(arr)/sizeof(arr[0]), b)
#define maxarr(n,arr,m) m =-1e9;for(int i=0;i<n;i++)if(arr[i]>m) m=arr[i];
#define read freopen("input.txt","r",stdin);
#define sf second.first
#define ss second.second
const double pi = acos(-1.0);
const int maxn = (i64)1e9+7;
map<string,int>mp;
int main()
{
    int n,cnt=0;
    cin >> n;
    string s;
    while(n--)
    {
        cin >> s;
        if(mp[s]==0) cnt++;
        mp[s] = 1;
    }
    cout << cnt;


    return 0;
}


Measured memory_bytes: 19228
a,b =map(int,input().split()) # 1 3

start = b-a+1+1000000
end = b+a+1000000

if start<0:
   start =0
if end>2000001:
   end = 2000001
num = list(range(-1000000,1000001))
ans = num[start: end]
print(*ans)

Measured memory_bytes: 83956
n = gets.chomp.to_i
boss_numbers = gets.chomp.split(" ").map(&:to_i)
res = []
boss_numbers.each do |t|
  res[t-1]||=0
  res[t-1]+=1
end
n.times do |t|
  puts res[t] ? res[t] : 0
end

Measured memory_bytes: 35856
#include <bits/stdc++.h>
#define loop(i, a, b) for(int i = a; i < b; i++)
using namespace std;
void O_o() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
 }

int main()
{
    O_o();
    int n, x;
    cin >> n;
    map <int, int> m;
    for(int i = 0; i < n; i++){
        cin >> x;
        m[x]++;
    }

   cout << n - 2 * (ceil((n - m.size()) / 2.0));
    return 0;
}


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

int main(){
  int n, X,*k;
  int sum = 0, min = 1001;
  cin >> n >> X;
  k = new int(n);
  for(int i = 0; i < n; i++){
    cin >> k[i];
    if(k[i] < min) min = k[i];
    sum += k[i];
  }
  cout << n + (X - sum) / min <<endl;
  return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;

public class Program
{
    public static void Main(string[] args)
    {
        new C().test();
    }
}

public class C
{
	public void test()
	{
		// 整数の入力
		decimal input = CommonRead.ReadDecimal();

		var divinput = decimal.Divide(input, 3.000000m);
		//出力
		Console.WriteLine(Decimal.Multiply(Decimal.Multiply(divinput, divinput), divinput));
	}
}

static class CommonRead
{
    public static string ReadStr()
    {
        return Console.ReadLine();
    }
    public static string[] ReadStrA()
    {
        return ReadStr().Split(' ');
    }
    public static List<string> ReadStrL()
    {
        return ReadStrA().ToList();
    }
    public static int ReadInt()
    {
        return Convert.ToInt32(ReadStr());
    }
    public static int[] ReadIntA()
    {
        return ReadStrA().Select(s => Convert.ToInt32(s)).ToArray();
    }
    public static List<int> ReadIntL()
    {
        return ReadStrA().Select(s => Convert.ToInt32(s)).ToList();
    }
    public static long ReadLong()
    {
        return Convert.ToInt64(ReadStr());
    }
    public static long[] ReadLongA()
    {
        return ReadStrA().Select(s => Convert.ToInt64(s)).ToArray();
    }
    public static List<long> ReadLongL()
    {
        return ReadStrA().Select(s => Convert.ToInt64(s)).ToList();
    }

    public static decimal ReadDecimal()
    {
        return Convert.ToDecimal(ReadStr());
    }
    public static decimal[] ReadDecimalA()
    {
        return ReadStrA().Select(s => Convert.ToDecimal(s)).ToArray();
    }
    public static List<decimal> ReadDecimalL()
    {
        return ReadStrA().Select(s => Convert.ToDecimal(s)).ToList();
    }

    public static double ReadDouble()
    {
        return Convert.ToDouble(ReadStr());
    }
    public static double[] ReadDoubleA()
    {
        return ReadStrA().Select(s => Convert.ToDouble(s)).ToArray();
    }
    public static List<double> ReadDoubleL()
    {
        return ReadStrA().Select(s => Convert.ToDouble(s)).ToList();
    }

}


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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)
#define mp make_pair

struct UnionFind{
    vector<int32> par;
    // map<int32,int32> mp;
    int64 ans;
    UnionFind(int64 n){
        par = vector<int32>(n, -1);
        // mp[1] = n;
        ans = n * n - n;
    }

    int32 root(int32 x){
        if(par[x] < 0)return x;
        return par[x] = root(par[x]);
    }

    bool unite(int32 x, int32 y){
        x = root(x);
        y = root(y);
        if(x == y)return false;
        // mp[deg(x)]--;
        // mp[deg(y)]--;
        // mp[deg(x)+deg(y)]++;
        ans += deg(x) * deg(x);
        ans += deg(y) * deg(y);
        ans -= (deg(x) + deg(y)) * (deg(x) + deg(y));
        par[x] += par[y];
        par[y] = x;
        return true;
    }

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

    int32 deg(int32 x){
        return -par[root(x)];
    }

    int64 calc(int32 n){
        // int64 retval = n * n;
        // for(auto p : mp){
        //     retval -= p.first * p.first * p.second;
        // }
        // return retval / 2;
        return ans / 2;
    }
};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int32 n,m;
    cin >> n >> m;
    vector<pii> ab(m);
    REP(i,m){
        int32 a,b;
        cin >> a >> b;
        a--;b--;
        ab[i] = pii(a, b);
    }
    UnionFind uf(n);
    vector<int32> ans(m,1);
    FORR(i,m-1,0){
        ans[i] = uf.calc(n);
        uf.unite(ab[i].first, ab[i].second);
    }
    REP(i,m)cout << ans[i] << endl;
    return 0;
}

Measured memory_bytes: 4480
#include <bits/stdc++.h>
using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
// typedef __int128_t Int;
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF =
    sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
using pii = pair<int, int>;
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(12);

  int N;
  cin >> N;
  vector<int> v(N);
  rep(i, 0, N) { cin >> v[i]; }

  auto me = max_element(all(v));
  if (*me <= 0) {
    cout << *me << endl << N - 1 << endl;
    for (int i = N - 1; i > me - v.begin(); i--)
      cout << i + 1 << endl;
    loop(distance(v.begin(), me)) cout << 1 << endl;
    return 0;
  }

  vector<int> odd, even;
  int odd_sum = 0, even_sum = 0;
  rep(i, 0, N) {
    if (v[i] > 0)
      if (i & 1) {
        odd.push_back(i);
        odd_sum += v[i];
      } else {
        even.push_back(i);
        even_sum += v[i];
      }
  }
  cout << max(odd_sum, even_sum) << endl;
  vector<int> s = (odd_sum < even_sum ? even : odd);
  vector<bool> a(N, 0);
  for (auto e : s) {
    a[e] = 1;
  }

  vector<int> ans;
  auto f = [&](int x) {
    vector<bool> _a;
    if (x == 0) {
      rep(i, 1, a.size()) { _a.push_back(a[i]); }
    } else if (x == a.size() - 1) {
      rep(i, 0, a.size() - 1) { _a.push_back(a[i]); }
    } else {
      rep(i, 0, a.size()) {
        if (i == x - 1 or i == x + 1)
          continue;
        else if (i == x) {
          _a.push_back(a[i - 1]);

        } else
          _a.push_back(a[i]);
      }
    }
    swap(a, _a);
    ans.push_back(x);
  };

  while (a[0] == 0)
    f(0);
  while (a.back() == 0)
    f(a.size() - 1);

  int i = 1;
  while (a.size() > 1) {
    if (a[0] == a[2])
      f(1);
    else
      f(2);
  }

  cout << ans.size() << endl;
  for (auto e : ans)
    cout << e + 1 << endl;

  return 0;
}


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

using namespace std;

int main(int argc, char* argv[]) {
  unsigned long long A, B, C;
  cin >> A >> B >> C;

  unsigned long long ans = 0;
  if ((A%2 != 0) && (B%2 != 0) && (C%2 != 0)) {
    vector<unsigned long long> v;
    if (C != 1) {
      v.push_back(A*B);
    }
    if (B != 1) {
      v.push_back(A*C);
    }
    if (A != 1) {
      v.push_back(B*C);
    }
    sort(v.begin(), v.end());

    
    ans = v[0];
  }

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


Measured memory_bytes: 256
//
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ar array
#define vec vector 

int gcd(int a, int b) { 
    if (b == 0) 
        return a; 
    return gcd(b, a % b);  
} 
void solve(){
    ll k, sum = 0;;
    cin >> k;
    for(int i = 1; i <= k; ++i){
        for(int j = 1; j <= k; ++j){
            for(int l = 1; l <= k; ++l){
                sum += gcd(gcd(i,j),l);
            }
        }
    }
    cout << sum << endl;
}

int main(){
    solve();
}



Measured memory_bytes: 3628
/* https://atcoder.jp/contests/abc123/tasks/abc123_b */

#include <iostream>
#include <cmath>
#include <vector>

std::vector<int> X(5);


void solve()
{
  int min_cost = 1e9;

  for (int i = 0; i < 5; ++i) {
    int cost_i = std::ceil(X.at(i)*0.1)*10;
    for (int j = 0; j < 5; ++j) {
      if (i == j) {
        continue;
      }
      int cost_j = std::ceil((cost_i+X.at(j))*0.1)*10;
      for (int k = 0; k < 5; ++k) {
        if (j == k || i == k) {
          continue;
        }
        int cost_k = std::ceil((cost_j+X.at(k))*0.1)*10;
        for (int l = 0; l < 5; ++l) {
          if (k == l || j == l || i == l) {
            continue;
          }
          int cost_l = std::ceil((cost_k+X.at(l))*0.1)*10;
          for (int m = 0; m < 5; ++m) {
            if (l == m || k == m || j == m || i == m) {
              continue;
            }
            int cost_m = cost_l + X.at(m);
            min_cost = std::min(cost_m, min_cost);
          }
        }
      }

    }
  }

  std::cout << min_cost << std::endl;

  return;
}

int main(int argc, char *argv[])
{
  // Input
  for (int& e: X) {
    std::cin >> e;
  }

  // Output
  solve();

  return 0;
}


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

int main() {
  int n;cin>>n;
  vector<ll> a(n);
  rep(i,n)cin>>a[i];
  ll ans=1,x=1e18;
  sort(all(a));
  rep(i,n){
    if(a[i]==0){
      cout<<0<<endl;
      return 0;
    }
    if(x/ans<a[i]){
      cout<<-1<<endl;
      return 0;
    }
    ans*=a[i];
  }
  cout<<ans<<endl;
}

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

int main(){
  ll N;
  cin >> N;
  ll sum=0;
  vector<ll> a;
  rep(i,N){
    sum+=i;
    a.push_back(i);
    if(N<sum){
      ll rm_i=sum-N;
      a.erase(a.begin()+rm_i-1);
      break;
    }else if(N==sum){
      break;
    }
  }
  for(const auto& v :a){
    cout << v <<endl;
  }
}

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

using namespace std;

using i64 = long long;

const i64 MOD = 1e9 + 7;
const i64 INF = i64(1e18) + 7;


template <typename T>
bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

template <typename T>
bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}


signed main(){

    int n, p;
    string s;
    cin >> n >> p >> s;

    if(p <= 10){
        vector<vector<int>> dp(n + 1, vector<int>(p, 0));
        i64 ans = 0;
        for(int i = 0; i < n; ++i){
            ++dp[i][0];
            for(int j = 0; j < p; ++j){
                dp[i + 1][(j * 10 + s[i] - '0') % p] += dp[i][j];
            }
            ans += dp[i + 1][0];
        }
        cout << ans << endl;
        return 0;
    }

    vector<int> table(n + 1, 0);
    vector<int> table_10(n + 1, 1);
    for(int i = 0; i < n; ++i)
        table_10[i + 1] = table_10[i] * 10 % p;
    int diff = 0;
    for(int i = n - 1; i >= 0; --i){
        table[i + 1] = diff;
        diff += table_10[n - 1 - i] * (s[i] - '0');
        diff %= p;
    }
    table[0] = diff;
    reverse(table.begin(), table.end());

    i64 ans = 0;
    vector<int> v(p, 0);
    ++v[table[n]];
    for(int i = n - 1; i >= 0; --i){
        int q = table[i];
        ans += v[q];
        ++v[table[i]];
    }

    cout << ans << endl;
}


Measured memory_bytes: 14468
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;cin>>n;
  float result = 0;
  for(int i=0;i<n;++i){
    float x;cin>>x;
    result += 1/x;
  }
  cout<<1/result<<endl;
  return 0;
}

Measured memory_bytes: 256
def is_int(numstr):
    return all(map(lambda c: c in ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"], numstr))


def main():
    a, b = map(int, input().split())
    s = input()
    haifun = s[a]
    mae = s[:a]
    ushiro = s[-b:]
    if is_int(mae) and haifun == "-" and is_int(ushiro):
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,n) for(long long i=0;i<n;++i)
#define REPP(i,m,n) for(long long i=m;i<n;++i)
#define rep(i,n) for(long long i = n-1;i>=0;--i)
#define repp(i,n,m) for(long long i = n-1; i >= m; --i)
#define ALL(N) (N.begin(),N.end())
#define de cout << "line : " << __LINE__ << " debug" << endl;
#define pb push_back
#define pq priority_queue
#define Dcout(N) cout << setprecision(20) << N << endl
constexpr long long MOD = 1000000007;
constexpr long long INF = 2147483647;
constexpr long long INFF = 9223372036854775807;

long long gcd(long long X,long long Y){
    if(X < Y) swap(X,Y);
    if(Y == 0) return X;
    return gcd(Y,X%Y);
}

long long lcm(long long a,long long b){
    return a / gcd(a,b) * b;
}

long long k(long long a){
    int cnt = 0;
    while(1){
        if(a % 2 == 1) break;
        a /= 2;cnt++;
    }
    return cnt-1;
}

signed main() {
    cin.tie(0);
	ios::sync_with_stdio(false);
    long long N,M;cin >> N >> M;
    vector<long long> A(N);
    REP(i,N) cin >> A[i];
    sort ALL(A);A.erase(unique(A.begin(), A.end()), A.end());
    int kosu = k(A[0]);
    int h = (1 << kosu);//cout << h << endl;
    REP(i,N){
        A[i] /= 2;
        if(A[i] % h != 0 || (A[i]/h) % 2 != 1){
            cout << 0 << endl;
            return 0;
        }
    }
    long long cnt = A[0];
    REP(i,N){
        cnt = lcm(A[i],cnt);
        if(cnt > M){
            cout << 0 << endl;
            return 0;
        }
    }
    cout << M / cnt - (M/cnt / 2)<< endl;
}

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

int main(){
  int n;
  cin >> n;
  vector<int> d(n);
  for ( int i = 0; i < n; i++) cin >> d[i];
  
  sort(d.begin(), d.end());
  int a = d[n/2-1];
  int b = d[n/2];
  
  int ans = b - a;
  
  
  cout << ans << endl;
}

Measured memory_bytes: 640
import sys
input = sys.stdin.readline

n,k = map(int,input().split())
a = list(map(int,input().split()))
cnt = 0
for i in range(n-1):
  for j in range(i+1,n):
    if a[i] > a[j]:
      cnt += k*(k+1)//2

b = list(reversed(a))
for l in range(n-1):
  for m in range(l+1,n):
    if b[l] > b[m]:
      cnt += (k-1)*k//2
      
x = 10**9 + 7
print(int(cnt%x))

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=200010;
const ll mod=1e9+7;


int main(){
  string s,t;
  cin >> s >> t;
  int n=s.size();
  if(s==t.substr(0,n)){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, n) for(int i = 0; i < (n); i++)
#define MEM(a, x) memset(a, x, sizeof(a))
#define ALL(a) a.begin(), a.end()
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())
typedef long long ll;

int n, m;
vector<int> g[55];
bool vis[55];

void dfs(int cur) {
	vis[cur] = true;
	FOR(i, g[cur].size()) {
		if (!vis[g[cur][i]]) dfs(g[cur][i]);
	}
}

bool check(int s, int t) {
	fill(vis, vis+n, false);
	vis[s] = true;
	FOR(i, g[s].size()) {
		if (g[s][i] == t) continue;
		dfs(g[s][i]);
	}
	return !vis[t];
}

int main(int argc, char const *argv[]) {
	ios_base::sync_with_stdio(false);
	cin >> n >> m;
	vector<pair<int, int> > p(m);
	FOR(i, m) {
		int u, v;
		cin >> u >> v;
		g[u-1].push_back(v-1);
		g[v-1].push_back(u-1);
		p[i] = {u-1, v-1};
	}
	int cnt = 0;
	FOR(i, m) {
		if (check(p[i].first, p[i].second)) cnt++;
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,ans; //組数と答え
  int l,r; //席lから席r
  cin >> N;
  for (int i = 0;i < N;++i){
    cin >> l >> r;
    ans += r - l + 1;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod = pow(10, 9) + 7;

int main(){
    int n;
    cin >> n;
    ll ans = 1;
    for(int i = 1; i <= n; i++){
        ans *= i;
        ans %= mod;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3584
#include<bits/stdc++.h>
using namespace std;
int main() {
  int N, K;
  cin >> N >> K;
  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 ans = 0;
  for (int i = 0; i < K; i++) {
    ans += vec.at(i);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import sys,collections,math;sys.setrecursionlimit(10**7)
def Is(): return [int(x) for x in sys.stdin.readline().split()]
def Ss(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

lis = []
for i in range(6):
    lis.append(I())
k = lis[5]
if lis[4] - lis[0] > k:
    print(":(")
else:
    print("Yay!")


Measured memory_bytes: 3316
def solve():
  while True:
    m, n  = int(input()), int(input())
    if not m:
      break
    ices = [[0] + list(map(int,input().split())) + [0] for _ in range(n)]
    ices.insert(0, [0] * (m + 2),)
    ices.append([0] * (m + 2))
    score = [[0] * (m + 2) for _ in range(n + 2)]
    
    for x in range(1, n + 1):
      for y in range(1, m + 1):
        if ices[x][y]:
          score[x - 1][y] += 1
          score[x + 1][y] += 1
          score[x][y - 1] += 1
          score[x][y + 1] += 1
    
    def bfs(x, y, imap, acc):
      imap[x][y] = 0
      acc += 1
      a = b = c = d = 0
      if imap[x - 1][y]:
        a = bfs(x - 1, y, imap, acc)
      if imap[x + 1][y]:
        b = bfs(x + 1, y, imap, acc)
      if imap[x][y - 1]:
        c = bfs(x, y - 1, imap, acc)
      if imap[x][y + 1]:
        d = bfs(x, y + 1, imap, acc)
      imap[x][y] = 1
      return max(acc, a, b, c, d)
    
    ans = 0
    for x in range(1, n + 1):
      for y in range(1, m + 1):
        if score[x][y] in [1, 2] and ices[x][y]:
          a = bfs(x, y, ices, 0)
          if ans < a:
            ans = a
    
    print(ans)

solve()


Measured memory_bytes: 5808
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#define m(a,b) memset(a,b,sizeof a)
#define en '\n'
using namespace std;
typedef long long ll;
const int N=2e5+5;
int a[N];
int main()
{
    int n;scanf("%d",&n);
    for(int i=1;i<=n;i++)
        scanf("%d",&a[i]);
    int l=1,r=1,tmp=0;ll sum=0;
    while(r<=n)
    {
        while((a[r]^tmp)==(a[r]+tmp)&&r<=n)
            tmp^=a[r],r++;
        if(r!=n+1)
            sum+=r-l;
        else
            sum+=(ll)(r-l)*(ll)(r-l+1)/(ll)2;
        tmp^=a[l],l++;
    }
    printf("%lld\n",sum);
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define rep(i, a, b) for(int i=(a); i<(b); i++)
#define per(i, a, b) for(int i=(b)-1; i>=(a); i--)
#define sz(a) (int)a.size()
#define de(a) cout << #a << " = " << a << endl
#define dd(a) cout << #a << " = " << a << " "
#define all(a) a.begin(), a.end()
#define pw(x) (1ll<<(x))
#define endl "\n"
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
vi p;
int res[1000000 + 10];
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	ll n;
	cin >> n;
	rep(i, 2, 1000000 + 10){
		int flag = 0;
		for(int  j = 2 ; j * j <= i; j ++){
			if(i % j == 0) {
				flag = 1;
				break;
			}
		}
		if(!flag) p.pb(i);
	}
	int ans = 0;
	for(auto i :p){
		if(n % i == 0){
			while(n % i == 0){
				res[i] ++;
				n /= i;
			}
		}
	}
	if(n != 1) ans = 1;
	for(auto i : p){
		if(res[i]){
			rep(j, 1, 100){
				if(j * (1 + j) / 2 > res[i]){
					ans += j - 1;
					break;
				}
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3884
#include <stdio.h>
#include <stdlib.h>
#include "time.h"
#include "unistd.h"
#include "string.h"
#include <math.h>
int ans;
int main(int argc, char* argv[]){
  long int a=0,b=0,c=0,d=0;
  scanf("%d %d",&a,&b);
  scanf("%d %d",&c,&d);
  printf("%d\n",a*b-(c*b)-(d*a)+(c*d));
}


Measured memory_bytes: 128