akhauriyash/Code-Regression huggingface dataset:
<?php
list($n, $m) = explode(" ", trim(fgets(STDIN)));
$sum = $n*($n-1)/2;
for($i = 0; $i < $m; $i++){
    $data[] =  explode(" ", trim(fgets(STDIN)));
}
$data = array_reverse($data);

$uft = new UFT($n);
$sum = ($n * ($n-1)) / 2;
foreach($data as $row){
    $history[] = $sum;
    $s1 = $uft->size($row[0]);
    $s2 = $uft->size($row[1]);
    $uft->unite($row[0], $row[1]);
    $s3 = $uft->size($row[0]);
    if($s1 != $s3){
        $sum -= $s1 * $s2;
    }
}
echo implode("\n", array_reverse($history));

class UFT{
    public $parent;
    public $size;
    public $rank;
    public function __construct($size){
        for($i = 1; $i <= $size; $i++){
            $this->size[$i] = 1;
            $this->rank[$i] = 1;
            $this->parent[$i] = 0;
        }
    }
    public function dump(){
        o("--------------");
        o($this->parent);
        o($this->size);
        o($this->rank);
    }
    public function getRoot($i){
        if($this->parent[$i] == 0){
            return $i;
        }else{
            return $this->getRoot($this->parent[$i]);
        }
    }
    public function unite($i, $j){
        $rootI = $this->getRoot($j);
        $rootJ = $this->getRoot($i);
        if($rootJ == $rootI)return false;//元から同じグループ
        if($this->rank[$rootI] > $this->rank[$rootJ])list($rootI, $rootJ) = [$rootJ, $rootI];//Rank(J)>Rank(I)に揃えておく
        $this->parent[$rootI] = $rootJ;
        if($this->rank[$rootI] == $this->rank[$rootJ]){
            $this->rank[$rootJ]++;
        }
        $this->size[$rootJ]+=$this->size[$rootI];
        $this->size[$rootI] = '*';//不要な情報となるので潰す/デバッグ出力向けに*を入れている
        $this->rank[$rootI] = '*';//同上
    }
    public function size($i){return $this->size[$this->getRoot($i)];}
    public function isUnion($i, $j){return $this->getRoot($i) == $this->getRoot($j);}
}

//デバッグ用
function o($val){
    $trace = debug_backtrace();
    echo $trace[0]['line'].")";
    if(is_array($val)){
        if(count($val) == 0){
            echo "empty array";
        }elseif(!is_array(current($val))){
            echo "array:";
            echo implode(" ", $val)."\n";
        }else{
            echo "array:array\n";
            foreach($val as $row){
                echo implode(" ", $row)."\n";
            }
        }
    }else{
        echo $val."\n";
    }
}

Measured memory_bytes: 72684
#include <stdio.h>
int main() {
int s,res,ues;
scanf("%d",&s);
res=s/100;
ues=s%100;
if(ues<=12 && ues>=1){
  if(res<=12 && res>=1)printf("AMBIGUOUS");
else printf("YYMM");
}else{
  if(res<=12 && res>=1)
    printf("MMYY");
  else printf("NA");
  }

  return 0;
}


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

int main() {
  int N, M;
  cin >> N >> M;
  
  int first, last;
  first = 0;
  last = 100000;
  
  for (int i = 0; i < M; i++) {
    int L, R;
   	cin >> L >> R;
    
    if (L > first) first = L;
    if (R < last) last = R;
  }
  
  if (last >= first) {
    cout << last - first + 1 << endl;
  } else {
    cout << 0 << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string>
#include <string.h>

using namespace std;

int main (void)
{
	long n,a,b,x,y,z,p,q,r;
	cin >> n >> a >> x >> y >> z;
	
	if (n < 0)
	{
		p = 0;
		p = x * (0 - n);
	
	
		q = 0;
		q = y;
		
		r = 0;
		r = z * a;
		cout << p + q + r << endl;	
	}
	else if (n == 0)
	{
		p = 0;
		q = 0;
				q = y;
				
				r = 0;
				r = z * a;
				cout << p + q + r << endl;	
	}
	else if (n > 0)
	{p =0 ;
	q = 0;
		r = z * (a - n);
						cout << p + q + r << endl;	
			}
	}

Measured memory_bytes: 3076
s = input()

max = 0
count = 0

for i in range(len(s)):
  if s[i] == 'A' or s[i] == 'C' or s[i] == 'G' or s[i] == 'T':
    count += 1
    if max < count:
      max = count
  else:
    count = 0

print(max)
    

Measured memory_bytes: 9140
def solve(s, k):
    n = len(s)
    pdp = [[0] * (k + 1) for _ in range(n + 1)]
    for l in range(n - 1, -1, -1):
        dp = [[0] * (k + 1) for _ in range(n + 1)]
        for r in range(l, n):
            dpr, dpr1 = dp[r], pdp[r - 1]
            inc = 1 if l == r else 2
            is_same = s[l] == s[r]
            for p in range(k + 1):
                if is_same:
                    dpr[p] = dpr1[p] + inc
                else:
                    if p:
                        dpr[p] = max(pdp[r][p], dp[r - 1][p], dpr1[p - 1] + inc)
                    else:
                        dpr[p] = max(pdp[r][p], dp[r - 1][p])
        pdp = dp

    return pdp[-2][k]


print(solve(input(), int(input())))


Measured memory_bytes: 111580
def main():
    s = input()
    t = input()
    dp = [[0] * (len(t)+1) for _ in range(len(s)+1)]
    for i,x in enumerate(s):
        for j,y in enumerate(t):
            if x == y:
                dp[i+1][j+1] = dp[i][j] + 1
            else:
                dp[i+1][j+1] =  max(dp[i][j+1], dp[i+1][j])

    ans = ''
    i,j = len(s),len(t)
    while (i>0  and j>0):
        if dp[i][j] == dp[i-1][j]:
            i -= 1
        elif dp[i][j] == dp[i][j-1]:
            j -= 1
        else:
            ans += s[i-1]
            i -= 1
            j -= 1
    print(ans[::-1])

if __name__ == '__main__':
    main()

Measured memory_bytes: 111580
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <iomanip>
#include <set>
using namespace std;
typedef long long int ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define yes cout << "yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define no cout << "no" << endl

const int INF = 1001001001;
const int mod = 1000000007;
#define PI 3.14159265359;

void P(int x) {cout << x << endl;}
void P(long x) {cout << x << endl;}
void P(double x) {cout << x << endl;}
void P(ll x) {cout << x << endl;}
void P(string x) {cout << x << endl;}
void P(char x) {cout << x << endl;}

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int main() {
  int n;
  cin >> n;
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    string s = to_string(i);
    if (s.size() % 2 == 1) ans++;
  }
  P(ans);

  return 0;
}

Measured memory_bytes: 256
n = int(input())
A = list(map(int, input().split()))

abs_sum = 0
minus = 0
abs_list = []
for i in range(n):
    if A[i] < 0:
        minus += 1
    abs_list.append(abs(A[i]))
    abs_sum += abs_list[i]

if minus % 2 != 0:
    abs_sum -= min(abs_list)*2
print(abs_sum)


Measured memory_bytes: 15020
#include <iostream>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <new>
#include <utility>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <iomanip>

typedef long long ll;
typedef long double ld;

using namespace std;
using Graph = vector<vector<ll>>;

#define rep(i, N) for (ll i = 0; i < (ll)(N); ++i)
#define ALL(a) (a).begin(),(a).end()

const ll inf = 1e18+7;
const ll mod = 1e9+7;

ll GetDigit(ll num){
    unsigned digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
}

int main(){
    ll a,b;
    cin >> a >> b;
    if(a>b){
        cout << a+(a-1) << endl;
    }else if(a<b){
        cout << b+(b-1) << endl;
    }else{
        cout << a*2 << endl;
    }
    return 0;
}


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

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		int H = Integer.parseInt(reader.readLine().split("\\s")[0]);
		for (int j = 0; j < H; j++) {
			String[] line = reader.readLine().split("\\s");
			for (int k = 0; k < line.length; k++)
				if ("snuke".equals(line[k])) {
					System.out.println(String.format("%c%d", k+65, j+1));
					return;
				}
		}
	}
	
}


Measured memory_bytes: 8528
def check(S, T):
    for _ in range(len(S)):
        if S == T:
            return True
        S = S[-1] + S[:-1]
    return False


def main():
    S = input()
    T = input()
    if check(S, T):
        print("Yes")
    else:
        print("No")


if __name__ == "__main__":
    main()


Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
#define ALL(A) (A).begin(),(A).end()
#define ll long long
const ll mod = 1e9+7;
int main(void){
	int X,A;
	cin >> X >> A;
	if(X<A)cout <<"0"<<endl;
	else cout << "10" << endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python
"""
This file is part of https://github.com/Cheran-Senthil/PyRival.

Copyright 2018 Cheran Senthilkumar all rights reserved,
Cheran Senthilkumar <hello@cheran.io>
Permission to use, modify, and distribute this software is given under the
terms of the MIT License.

"""
from __future__ import division, print_function

import cmath
import itertools
import math
import operator as op
# import random
import sys
from atexit import register
from bisect import bisect_left, bisect_right
# from collections import Counter, MutableSequence, defaultdict, deque
# from copy import deepcopy
# from decimal import Decimal
# from difflib import SequenceMatcher
# from fractions import Fraction
# from heapq import heappop, heappush

if sys.version_info[0] < 3:
    # from cPickle import dumps
    from io import BytesIO as stream
    # from Queue import PriorityQueue, Queue
else:
    # from functools import reduce
    from io import StringIO as stream
    # from pickle import dumps
    # from queue import PriorityQueue, Queue


if sys.version_info[0] < 3:
    class dict(dict):
        """dict() -> new empty dictionary"""
        def items(self):
            """D.items() -> a set-like object providing a view on D's items"""
            return dict.iteritems(self)

        def keys(self):
            """D.keys() -> a set-like object providing a view on D's keys"""
            return dict.iterkeys(self)

        def values(self):
            """D.values() -> an object providing a view on D's values"""
            return dict.itervalues(self)

    input = raw_input
    range = xrange

    filter = itertools.ifilter
    map = itertools.imap
    zip = itertools.izip


def sync_with_stdio(sync=True):
    """Set whether the standard Python streams are allowed to buffer their I/O.

    Args:
        sync (bool, optional): The new synchronization setting.

    """
    global input, flush

    if sync:
        flush = sys.stdout.flush
    else:
        sys.stdin = stream(sys.stdin.read())
        input = lambda: sys.stdin.readline().rstrip('\r\n')

        sys.stdout = stream()
        register(lambda: sys.__stdout__.write(sys.stdout.getvalue()))


def gcd(x, y):
    """greatest common divisor of x and y"""
    while y:
        x, y = y, x % y
    return x


def main():
    n = int(input())
    h = int(input())
    w = int(input())

    print((n - h + 1)*(n - w + 1))


if __name__ == '__main__':
    sync_with_stdio(False)
    main()


Measured memory_bytes: 28908
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <list>
#include <map>
#include <iomanip>
#include <iostream>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define fi first
#define se second
#define pb push_back
//#define mp make_pair
#define rep(i,n) for(register int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
const int INF=0x3f3f3f3f;
const int dx[]={0,1,-1,0},dy[]={1,0,0,-1};
//const int MOD=998244353;
//const int N=2e5+10;

inline int read(){
	int ww=1,xx=0;char ch=getchar();
	while(!isdigit(ch)){if(ch=='-') ww=-ww;ch=getchar();}
	while(isdigit(ch)){xx=(xx<<1)+(xx<<3)+(ch^48);ch=getchar();}
	return ww*xx;
}


double ans,x;
int n;

signed main(){
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	n=read();
	for(int i=1;i<=n;i++){
		cin>>x;
		ans+=1/x;
	}
	printf("%.10lf\n",1/ans);
	return 0;
}


Measured memory_bytes: 256
r, g, b, n = gets.split.map(&:to_i)
r, g, b = [r, g, b].sort!

ans = 0

0.upto(n / r) do |x|
  0.upto((n - (r * x)) / g) do |y|
    balls = r * x + g * y
    rest = n - balls

    ans += 1 if rest % b == 0
  end
end

puts ans


Measured memory_bytes: 1788
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>

#define int long long
#define MOD 1000000007

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

using namespace std;

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

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

	vector<int> T(N);
	rep(i, N) cin >> T[i];

	sort(all(T));

	int ret = 0;
	int prev = - K - 10;
	int cnt = 0;
	for (int t : T) {
		if (t - prev > K) {
			ret++;
			prev = t;
			cnt = 1;
		} else {
			cnt++;
		}
		if (cnt == C) {
			prev = -K - 10;
			cnt = 0;
		}
	}

	cout << ret << endl;
}


Measured memory_bytes: 1024
K, N = map(int, input().split())
A = list(map(int, input().split()))
A.append(A[0]+K)
max_d = A[1] - A[0]
for i in range(N):
  d = A[i+1] - A[i]
  if max_d < d:
    max_d = d
print(K - max_d)


Measured memory_bytes: 26444
#include <bits/stdc++.h>
using namespace std;
#define MD 1000000007
#define INF 1000000000
typedef long long int ll;
typedef pair<ll, ll> P;
template <typename T>
std::string tostr(const T &t){std::ostringstream os;os << t;return os.str();}
int dx[4]={1, 0, -1, 0}, dy[4]={0, 1, 0, -1};

int ans=INF, n, a, b, c, dis[9];

void dfs(int aa, int bb, int cc, int mp, int num){
    if(num==n){
        //3本の竹に少なくとの一本は割り当てられていたら
        if(aa && bb && cc){
            //-30は，3本の竹に一本しか割り当てられないときも，合成魔法を利用している分を引いている
            ans=min(ans,mp+abs(a-aa)+abs(b-bb)+abs(c-cc)-30);
        }
        return;
    }
    dfs(aa+dis[num], bb, cc, mp+10, num+1);
    dfs(aa, bb+dis[num], cc, mp+10, num+1);
    dfs(aa, bb, cc+dis[num], mp+10, num+1);
    dfs(aa, bb, cc, mp, num+1);
}

int main()
{
    cin>>n>>a>>b>>c;
    for(int i=0;i<n;i++){
        cin>>dis[i];
    }    
    dfs(0, 0, 0, 0, 0);
    cout<<ans<<endl;
    return 0;
}

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

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors

l=make_divisors(n)
m=len(l)
if m%2==0:
    print(l[m//2-1]+l[m//2]-2)
else:
    print(2*l[m//2]-2)


Measured memory_bytes: 39152
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def digit_sum(n):
    res = 0
    while n > 0:
        res += n % 10
        n //= 10
    return res


def resolve():
    n = int(input())

    res = f_inf
    for a in range(1, n):
        b = n - a
        cnt = digit_sum(a) + digit_sum(b)
        res = min(res, cnt)

    print(res)


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 3188
using System;
using System.Collections.Generic;
using System.Linq;
using static Input;

public class Prog
{
    private const int INF = 1000000007;
    public static void Main()
    {
        int N = NextInt();
        int K = NextInt();
        if (K % 2 == 1)
        {
            int e = (int)Math.Floor(N / (K + .0));
            long ans = (long)Math.Pow(e, 3);
            Console.WriteLine(ans);
        }
        else
        {
            int a = (int)Math.Floor(N / (K + .0));
            int b = (int)Math.Floor((N + (K / 2)) / (K + .0));
            long ans = (long)Math.Pow(a,3) + (long)Math.Pow(b,3);
            Console.WriteLine(ans);
        }
    }
}

public class Input
{
    private static Queue<string> queue = new Queue<string>();
    private static void Confirm() { if (queue.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) queue.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(queue.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(queue.Dequeue()); }
    public static string NextString() { Confirm(); return queue.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(queue.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
}


Measured memory_bytes: 11220
// ਅਗਮਜੋਤ ਸਿੰਘ
// AGAMJOT SINGH

#include <bits/stdc++.h>
using namespace std; 
#define int long long
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define tc int t; cin >> t; while(t--)
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); 
#define CLK clock_t clk = clock();                                                                  //Start of main
#define OCLK cerr << "Time (in ms): " << (double)(clock() - clk) * 1000.0 / CLOCKS_PER_SEC << '\n'; //End of main
#define f(i,start,lessthan) for(int i=start;i<lessthan;i++)

// a_gamer

signed main(){
    int n, k;
    cin >> n >> k;
    int arr[n];
    int dp[k+3] = {0};
    f(i,0,n){
        cin >> arr[i];
    }
    // dp[0][0] = 0;
    // dp[0][1] = 1;
    f(i,1,k+1){
        f(j,0,n){
            if(arr[j] > i){
                continue;
            }
            else{
                if(dp[i - arr[j]] == 0 || i == arr[j]){
                    dp[i] = 1;
                }
            }
        }
    }
    if(dp[k] == 1){
        cout << "First \n";
    }
    else{
        cout << "Second\n";
    }
}

Measured memory_bytes: 1024
macro_rules! read_line {
    () => {{
        let mut input = String::new();
        std::io::stdin().read_line(&mut input).unwrap();
        input
    }};
}

fn read_to_vec<T: std::str::FromStr>() -> Vec<T> {
    read_line!().split_whitespace()
        .map(|e| e.parse::<T>().ok().unwrap())
        .collect()
}

fn main() {
    let input: Vec<i32> = read_to_vec();
    let mut count: i32 = 1;

    if input[0] != input[1] { count += 1 }
    if input[1] != input[2] && input[0] != input[2] { count += 1 }

    println!("{}", count)
}

Measured memory_bytes: 4352
#include<stdio.h>
#include<string.h>
#define LEN 100005

typedef struct pp{
  char name[100];
  int t;
}P;

P Q[LEN+1];
int head, tail, n;

void enqueue(P x){
  Q[tail] = x;
  tail++;
  if(tail == LEN+1) tail=0;
}

P dequeue(){
  head++;
  if(head == LEN+1) head=0;
  return Q[head];
}


int main(){
  int elaps = 0, c;
  int i,q;
  int time = 0;
  P u;
  scanf("%d %d", &n, &q);

  for ( i = 1; i <= n; i++){
    scanf("%s", Q[i].name);
    scanf("%d", &Q[i].t);
    enqueue(Q[i]);
  }

  while(head - tail != 0){
    if(Q[head].t > q){
      Q[head].t = Q[head].t - q;
      time += q;
      
      enqueue(Q[head]);
      dequeue();
    }
    else{
      time += Q[head].t;
      Q[head].t = time;
      printf("%s %d\n",Q[head].name, Q[head].t);
      dequeue();
    }
  }
  
  
  return 0;
}

Measured memory_bytes: 10756
#include <stdio.h>
#include <algorithm>
#include <string>
using namespace std;

char S[3030],T[3030]; int D[3030][3030];

int main()
{
	scanf ("%s %s",S+1,T+1);

	int n = 0, m = 0;
	while (S[n+1]) n++;
	while (T[m+1]) m++;

	for (int i=1;i<=n;i++) for (int j=1;j<=m;j++){
		if (S[i] == T[j]) D[i][j] = D[i-1][j-1] + 1;
		else D[i][j] = max(D[i-1][j], D[i][j-1]);
	}

	int i = n, j = m;
	string r;
	while (i && j){
		if (S[i] == T[j]){
			r += S[i];
			i--; j--;
		}
		else if (D[i-1][j] < D[i][j-1]) j--;
		else i--;
	}
	reverse(r.begin(),r.end());
	puts(r.c_str());

	return 0;
}

Measured memory_bytes: 35712
#include <bits/stdc++.h>
#define ll long long
#define pi pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define mod 1000000007
using namespace std;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int h, w, n;
	cin>>h>>w>>n;
	cout<<(n + max(h, w) - 1) / max(h, w)<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using pi = pair<int, int>;

int main()
{
    int n, m;
    cin >> n >> m;
    vector<pi> island(m);
    for (int i = 0; i < m; i++)
    {
        cin >> island[i].first >> island[i].second;
    }

    sort(island.begin(), island.end(), [](pi a, pi b) { return a.first < b.first; });

    int cur = island[0].second;
    int ans = 1;
    for (int i = 0; i < m; i++)
    {
        if (cur <= island[i].first)
        {
            ans++;
            cur = island[i].second;
            continue;
        }

        cur = min(cur,island[i].second);
    }

    cout << ans << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define endl '\n'
#define all(x) (x).begin(),(x).end()
const int INF=1000000000+5;
const int N=2e5+5;
const ll oo=1e18+5;
const ll mod=1e9+7;

void add_self(ll& a,ll b){
	a+=b;
	if(a>=mod) a-=mod;
}

void sub_self(ll& a,ll b){
	a-=b;
	if(a<0) a+=mod;
}

ll mult(ll a,ll b){
	return a*b%mod;
}

ll poww(ll a,ll b){
	ll r=1;
	while(b){
		if(b&1) r=mult(r,a);
		a=mult(a,a);
		b>>=1;
	}
	return r;
}


int main(){
	ios::sync_with_stdio(0); cin.tie(0);
	int n;
	cin>>n;
	vector<ll> a(n);
	for(ll& x:a) cin>>x;
	ll sum1=0,sum2=0;
	for(int i=0;i<n;++i){
		add_self(sum1,a[i]);
		add_self(sum2,mult(a[i],a[i]));
	}
	ll ans=mult(sum1,sum1);
	sub_self(ans,sum2);
	cout<<mult(ans,poww(2,mod-2));
	return 0;
}


Measured memory_bytes: 4800
package main

import (
	"fmt"
	"strings"
)

func main() {
	var s string
	fmt.Scan(&s)

	lower := strings.ToLower(s)

	if s != lower {
		// 大文字
		fmt.Println("A")
	} else {
		// 小文字
		fmt.Println("a")
	}
}


Measured memory_bytes: 1840
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m;
  int a[51], b[51], c[51], d[51];
  cin >> n >> m;
  for(int i=1;i<=n;i++){
    cin >> a[i] >> b[i];
  }
  for(int i=1;i<=m;i++){
    cin >> c[i] >> d[i];
  }
  for(int i=1;i<=n;i++){
    int mn = 300000000;
    int p = -1;
    for(int j=1;j<=m;j++){
      int crr = abs(a[i]-c[j]) + abs(b[i]-d[j]);
      if(crr < mn){
        mn = crr;
        p = j;
      }
    }
    cout << p << endl;
  }
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,l,n) for(int i=l;i<n;i++)
#define rer(i,l,n) for(int i=l;i<=n;i++)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define pb(a) push_back(a)
#define mk(a,b) make_pair(a,b)
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

int main(){
	int a,b;
	int n;
	while(cin>>a>>b>>n){
		int s=0;
		if(a>=b){
			a%=b;
		}
		rep(i,1,n+1){
			a*=10;
			//o(" "<<a);
			if(a/b==0) continue;
			else{
				s+=a/b;
				a%=b;
			}
		}
		o(s);
	}
}

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

namespace ITP1_8_B
{
    class Program
    {
        static void Main(string[] args)
        {
            //与えられた数xの各桁の和を計算する。

            while (true)
            {
                string str = Console.ReadLine();//.Trim();         //入力された文字列を読みこむ
                int ans = 0;                                    //答えの初期化

                if (str == "0")
                {
                    break;
                }
                else
                {
                    for (int i = 0; i < str.Length; i++)
                    {
                        ans += int.Parse(str[i].ToString());
                    }
                }
                Console.WriteLine(ans.ToString());
            }
        }
    }
}



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

using namespace std;
const int M = 1000000007;
class mll {
public:
	long long x;
	mll(long long x = 0) : x((x% M + M) % M) {};
	void operator += (const mll& a) {
		if ((x += a.x) >= M) x -= M;
	}
	void operator *= (const mll& a) {
		(x *= a.x) %= M;
	}
	mll operator + (const mll& a) const {
		mll ans = *this;
		ans += a;
		return ans;
	}
};

int main() {
	int N, M;
	cin >> N >> M;
	vector<int> A(M);
	for (int i = 0; i < M; i++) cin >> A[i];
	vector<int> B(M + 1);
	B[0] = (M > 0 ? A[0] : N + 1);
	int BMAX = B[0];
	for (int i = 1; i < M; i++) {
		B[i] = A[i] - A[i - 1] - 1;
		if (B[i] == 0) {
			cout << 0 << endl;
			return 0;
		}
		BMAX = max(B[i], BMAX);
	}
	if (M > 0) {
		B[M] = N - A[M - 1];
		BMAX = max(B[M], BMAX);
	}
	vector<mll>fib(BMAX + 1, 0);
	for (int i = 1; i <= BMAX; i++) {
		if (i == 1 || i == 2) fib[i] = mll(1);
		else fib[i] = fib[i - 1] + fib[i - 2];
	}

	mll ans = 1;
	for (int b : B) ans *= fib[b];
	cout << ans.x << endl;

}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define int long long
using namespace std;
main(){
    int a,b,c,d=0,y=1;
    cin>>a>>b>>c;
    int z=1;
    for(int i=0;i<b;i++)z*=(y+a);
    while(z<=c){
        int s=0,x=z;
        while(x)s+=x%10,x/=10;
        if(y==s)d++;
        y++;
        z=1;
        for(int i=0;i<b;i++)z*=(y+a);
    }
    cout<<d<<endl;
}


Measured memory_bytes: 3108
#include <iostream>
#include <vector>
#include <list>
#include <set>
#include <queue>
#include <map>
#include <algorithm>
#include <functional>
#include <string>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>
using namespace std;

#define REP(i,p,n) for(ll i=p;i<ll(n);++i)
#define rep(i,n) REP(i,0,n)

using ll = long long int;
using pll = pair<ll, ll>;

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

    cout << (s == "ABC" ? "ARC" : "ABC") << endl;

    return 0;
}


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

int main() {
    int n;
    cin >> n;
    double x[n], y[n];
    double dist = 0.0;
    for(int i = 0; i < n; ++i) cin >> x[i] >> y[i];
    for(int i = 0; i < n; ++i) {
        for(int j = 0; j < n; ++j) {
            if(i != j) {
                dist += pow( (pow((x[i]-x[j]), 2) + pow((y[i]-y[j]), 2)), 0.5);
            }
        }
    }
    printf("%20.10lf\n", dist/n);
}


Measured memory_bytes: 640
<?php
// Your code here!

    $N = intval(trim(fgets(STDIN)));
    
    $A = array_map('intval',explode(" ",trim(fgets(STDIN))));
    
    array_unshift($A,0);
    
    $count=0;
    for($i=1;$i<=$N;$i++){
        if($i%2==1){
            if($A[$i]%2==1){
                $count++;
            }
        }
    }
    echo $count;
?>

Measured memory_bytes: 16088
/**********************************************************************/
/********                                                      ********/
/********                     Writer:孙~~                      ********/
/********                       Lang:C++                       ********/
/********                     Status:Unknow                    ********/
/********                                                      ********/
/**********************************************************************/
#include <iostream>
#include <string>
#include <cstdio>
#include <vector>
#include <queue>
#include <list>
#include <cstdlib>
#include <algorithm>
#include <set>
#include <map>
#include <deque>
#include <cstring>
#include <cmath>
//#include<bits/stdc++.h>
using namespace std;

const int INF=0x3f3f3f3f;
const int SIZE=105;
const double EPS=1e-6;

int w[SIZE],v[SIZE];
long long dp[SIZE][100005];

int main(){
	/*main function start*/
	int n,W;
	scanf("%d%d",&n,&W);
	for(int i=1;i<=n;i++){
		scanf("%d%d",w+i,v+i);
	}
	for(int i=1;i<100005;i++) dp[0][i]=-1e12;
	for(int i=1;i<=n;i++){
		for(int j=0;j<=W;j++){
			dp[i][j]=dp[i-1][j];
			if(j-w[i]>=0) dp[i][j]=max(dp[i][j],dp[i-1][j-w[i]]+v[i]);
		}
	}
	long long ans=0;
	for(int i=0;i<=W;i++) ans=max(ans,dp[n][i]);
	printf("%lld\n",ans);
	return 0;
}


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

int main(){
  int n,m;
  bool judge = true;
  cin >> n >> m;
  int maxi = m,in = m;
  for(int i=1;i<=n;i++){
    int s1,s2; cin >> s1 >> s2;
    in += s1 - s2;
    maxi = max(maxi,in);
    if(in < 0) judge = false;
  }
  cout << ((judge)? maxi : 0) << endl;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(a) (a).begin(), (a).end()
typedef vector<int> vi;
const int INF = 1LL << 58;
const int MOD = 1000000007;
const int MAX_N = 200100;

signed main()
{
    //  以降 cin の入力元が 'input.txt' になる
    //std::ifstream in("input.txt");
    //std::cin.rdbuf(in.rdbuf());
    int A, B, C;
    cin >> A >> B >> C;

    bool flg = false;
    if (A == B)
    {
        if (B != C)
            flg = true;
    }
    if (C == B)
    {
        if (A != C)
            flg = true;
    }
    if (A == C)
    {
        if (B != C)
            flg = true;
    }
    if (flg)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

    return 0;
}

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

#define MOD 1000000007
#define ll long long int
#define vi vector<int>
#define vii vector< vector<int> >
#define PI 3.1415926535897932384626433832795
#define INF 9223372036854775807LL
#define endl "\n"

ll modpow(ll a, ll b) {
	if(b == 0) {
		return 1;
	}
	ll ans = modpow(a,b/2);
	ans = (ans*ans)%MOD;
	if(b%2) {
		ans = (ans*a)%MOD;
	}
	return ans;
}


int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin >> n;
	vector<ll> arr(n+1);
	for(int i = 1; i <= n; i++) {
		cin >> arr[i];
	}
	ll ans = 0;
	ll nfac = 1;
	for(int i = 2; i <= n; i++) {
		nfac = (nfac*i)%MOD;
	}
	vector<ll> nperifac(n+1,nfac);
	vector<ll> prefsum(n+1,nfac);
	for(int i = 2; i <= n; i++) {
		nperifac[i] = (nfac*modpow(i,MOD-2))%MOD;
		prefsum[i] = prefsum[i-1]+nperifac[i];
		if(prefsum[i] >= MOD) {
			prefsum[i]-= MOD;
		}
	}
	for(int i = 1; i <= n; i++) {
		int cn1 = i;
		int cn2 = n-i+1;
	//	cout << i << " " << cn1 << " " << cn2 << " " << prefsum[cn1] << " " << prefsum[cn2] << " " << nfac << endl;
		ans+= (arr[i]*(prefsum[cn1]+prefsum[cn2]-nfac))%MOD;
	}
	cout << ans%MOD;
	return 0;
}



Measured memory_bytes: 2560
#include<stdio.h>
int main()
{
	int a,b,c;
	while(~scanf("%d %d", &a, &b))
	{
		if(a<=0 && b>=0)
			printf("Zero\n");
		else if(a<0)
		{
			c=b-a;
			if(c==0 || c%2==1)
				printf("Positive\n");
			else
				printf("Negative\n");
		}
		else
			printf("Positive\n");		
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;
ll MOD=1000000007;
int main(){
  ll n;
  cin>>n;
  vector<ll> a(n);
  rep(i,n) cin>>a[i];
  ll max=0;
  ll ans=0;
  rep(i,n){
    if(a[i]>max) max=a[i];
    ans+=max-a[i];
  }
  cout<<ans;
return 0;
}

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

int main(){
  int N,c=0,a=0;
  vector<int> vec(8);
  cin>>N;

  vector<int> R(N);
  
  for(int i=0;i<N;i++){
    cin >> R.at(i);
  }
  
  for(int i=0;i<N;i++){
    if(R.at(i)<400){
      vec.at(0)=1;
    }else if(R.at(i)<800){
      vec.at(1)=1;
    }else if(R.at(i)<1200){
      vec.at(2)=1;
    }else if(R.at(i)<1600){
      vec.at(3)=1;
    }else if(R.at(i)<2000){
      vec.at(4)=1;
    }else if(R.at(i)<2400){
      vec.at(5)=1;
    }else if(R.at(i)<2800){
      vec.at(6)=1;
    }else if(R.at(i)<3200){
      vec.at(7)=1;
    }else{
      a++;
    }
  }
    
    for(int i=0;i<8;i++){
      if((vec.at(i))==1)
         c++;
    }
    
  if(c==0 &&a!=0) cout << 1 <<" " <<a<<endl;
  else cout <<c<<" "<<c+a<<endl;
  
    return 0;
  }
      

Measured memory_bytes: 256
N=int(input())
T,A=map(int,input().split())
lis=list(map(int,input().strip().split()))
kekka=[]
a=len(lis)
for i in range (0,a):
    b=T-lis[i]*0.006
    if A>=b:
        c=A-b
    else:
        c=b-A
    c=abs(c)
    kekka.append(c)
d=min(kekka)
e=kekka.index(d)
print(e+1)

Measured memory_bytes: 3064
#include <iostream>
int main()
{
  int N;
  std::cin >> N;
  std::string ANS[4]={"AC","WA","TLE","RE"};
  int C[4]={0,0,0,0};
  for(int i = 0; i < N; ++i )
  {
    std::string s;
    std::cin >> s;
    for(int j = 0; j <4;++j)
    {
      if(s==ANS[j])
      {
        ++C[j];
        break;
      }
    }
  }
  for(int i = 0; i < 4; ++i)
  {
    std::cout << ANS[i] << " x " << C[i] << std::endl;
  }
  return 0;
}

Measured memory_bytes: 3580
import java.util.*;

public class Main {

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

        final int N = sc.nextInt();
        final int M = 10000005;

        final int[] a = new int[N];

        for (int i = 0; i < N; i++) {
            a[i] = sc.nextInt();
        }

        Arrays.sort(a);

        final int[] cnt = new int[M];

        for (int x : a) {
            if (cnt[x] != 0) {
                cnt[x] = 2;
                continue;
            }
            for (int i = x; i < M; i += x) {
                cnt[i]++;
            }
        }

        int ans = 0;

        for (int x : a) {
            if (cnt[x] == 1) ans++;
        }

        System.out.println(ans);
    }
}


Measured memory_bytes: 99528
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

int main(){
	int N;
	cin >> N;
	ll l;
	vector<ll> X(N);
	vector<ll> Y(N);
	for (int i = 0;i< N;i++){
		cin >> l;
		X[i] = l;
		Y[i] = l;
	}
	sort(ALL(Y));
	ll L = Y[(N- 2)/2];
	ll R = Y[(N- 2)/2 + 1];
	for (int i = 0;i < N;i++){
		if (X[i] <= L){
			cout << R <<endl;
		}
		else{
			cout << L << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 5376
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

int D;
ll kotae = 0;
void keisan(ll A, int B, int C, vector<int> V) {
	if (B < C / 2) {
		ll k1 = 1, k2 = 1;
		rep(i, C - B - 1) k1 *= 10;
		rep(i, B) k2 *= 10;
		ll k = k1 - k2;
		if (A >= 0) {
			if (abs(A / k) < 10) {
				V.pb(A / k);
				keisan(A % k, B + 1, C, V);
				V.pop_back();
			}
			if (abs(A / k + 1) < 10) {
				V.pb(A / k + 1);
				keisan(A % k - k, B + 1, C, V);
			}
		}
		else {
			if (abs(A / k) < 10) {
				V.pb(A / k);
				keisan(A % k, B + 1, C, V);
				V.pop_back();
			}
			if (abs(A / k - 1) < 10) {
				V.pb(A / k - 1);
				keisan(A % k + k, B + 1, C, V);
			}
		}
	}
	else {
		if (A == 0) {
			ll kari = 1;
			rep(j, V.size()) {
				int kari2 = 0;
				if (j == 0) {
					rep1(k, 9) {
						if (k + V[j] < 10) kari2++;
					}
				}
				else {
					rep(k, 10) {
						if (k + V[j] >= 0 && k + V[j] < 10) kari2++;
					}
				}
				kari *= kari2;
			}
			if (C % 2) kari *= 10;
			kotae += kari;
		}
	}
}



int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);


	cin >> D;

	for (int i = 19; i >= 2; i--) {
		vector<int> V;
		keisan(D, 0, i, V);
	}

	co(kotae);

	Would you please return 0;
}

Measured memory_bytes: 256
from collections import Counter
N,M = map(int,input().split())
A = list(map(int,input().split()))

S = [0]*(N+1)
for i in range(N):
    S[i+1] = (S[i]+A[i]) % M

C = Counter(S)

Ans = 0
for v in C.values():
    if v != 1:
        Ans += v*(v-1)//2

print(Ans)

Measured memory_bytes: 16524
#D問題
A = list(str(input()))
N = len(A)

used = []
count = 0
for a in A:
    if a not in used:
        used.append(a)
        c = A.count(a)
        count+=(c*(c-1)//2)
            
ans = 1
for i in range(N):
    if i == 0:
        pass
    else:
        ans+=(N-i)
#print(ans,count)
ans-=count
print(ans)


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

int main(){
	int n;
	cin>>n;
	int minus=0;
	long long int ans=0;
	int temp;
	int m=1e+9+1;
	for (int i = 0; i < n; i++) {
		cin>>temp;
		if (temp<0) {
			minus++;
		}
		ans+=abs(temp);
		m=min(m,abs(temp));
	}
	if (minus%2==0) {
		cout<<ans<<endl;
	}else {
		cout<<ans-2*m<<endl;
	}
}

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

using namespace std;
using ll = long long;

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

	vector<int> s(M);
	vector<int> c(M);

	for (int i = 0; i < M; ++i) {
		cin >> s[i] >> c[i];
	}

	int num = 1;
	for (int i = 1; i < N; ++i) {
		num *= 10;
	}
 
	int ans = num * 10;
	int end = num * 10;
	if (num == 1) num = 0;
	for (int i = num; i < end; ++i) {
		bool flag = true;
		string digit = to_string(i);
		for (int j = 0; j < M; ++j) {
			if (digit[s[j] - 1] != '0' + c[j]) {
				flag = false;
				break;
			}
		}
		if (flag) {
			ans = min(ans, i);
		}
	}
	cout << (ans == end ? -1 : ans) << endl;
	return 0;
}


Measured memory_bytes: 3696
use std::cmp;
use std::fmt::Debug;
use std::str::FromStr;
#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where
    T: FromStr,
    <T as FromStr>::Err: Debug,
{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim()
        .split_whitespace()
        .map(|c| T::from_str(c).unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_as_string() -> String {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main() {
    let x = read_as_vec::<i32>()[0];
    if x == 0 {
        println!("1");
    } else {
        println!("0");
    }
}


Measured memory_bytes: 2108
#include<bits/stdc++.h>
#define mod 1000000007
using namespace std;
void U(int &x,int y){ if ((x+=y)>=mod) x-=mod; }
int n,m,f[2020][2020],c[2020][2020],s[2020][2020],ans;

int cal(int x,int y){
	return !y? !x: s[y-1][min(y-1,x-y)];
}
int main(){
	for (int i=0;i<=2000;i++){
		s[i][0]=c[i][0]=1;
		for (int j=1;j<=i;j++)
			c[i][j]=(c[i-1][j-1]+c[i-1][j])%mod,s[i][j]=(s[i][j-1]+c[i][j])%mod;
	}
	cin>>n>>m; ans=!m;
	for (int i=0;i<=n;i++)
		for (int j=0;j<=min(i,m);j++){
			f[i][j]=(f[max(0,i-1)][j]+cal(i,j))%mod;
			if (j!=m) U(ans,(long long)f[i][j]*c[m-1][m-j-1]%mod);
		}
	cout<<ans;
}

Measured memory_bytes: 46976
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <utility>
#include <cstdio>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#define my_abs(x) ((x) < 0 ? -(x) : (x))
#define mp std::make_pair
#define pb push_back
typedef long long ll;
int arr[100005], tmp[100005];
inline ll work(int n)
{
	int x = 0;
	std::sort(arr, arr + n);
	for (int i = (n >> 1) - 1; i >= 0; i--)
	{
		tmp[x] = arr[i];
		x += 2;
	}
	if (n & 1)
		tmp[x] = arr[n >> 1];
	x = 1;
	for (int i = n - 1; i >= n + 1 >> 1; i--)
	{
		tmp[x] = arr[i];
		x += 2;
	}
	ll ans = 0;
	for (int i = 0; i + 1 < n; i++)
		ans += my_abs(tmp[i] - tmp[i + 1]);
	return ans;
}
int main()
{
	// freopen("TK1-C.in", "r", stdin);
	int n;
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
		scanf("%d", arr + i);
	ll ans = work(n);
	for (int i = 0; i < n; i++)
		arr[i] *= -1;
	printf("%lld\n", std::max(ans, work(n)));
	return 0;
}

Measured memory_bytes: 1024
from scipy.sparse import*
f=csgraph.floyd_warshall
def main():
  n,m,l,*t=map(int,open(0).read().split())
  d=[[0]*(n+1)for _ in range(n+1)]
  for a,b,c in zip(*[iter(t[:m*3])]*3):d[a][b]=c
  d=f(f(d,0)<=l)-1
  d[d>n]=-1
  d=d.astype('i')
  print('\n'.join(map(str,[d[i]for i in zip(*[iter(t[m*3+1:])]*2)])))
main()

Measured memory_bytes: 42800
module ABC123

  ! <module>s to import
  use, intrinsic :: iso_fortran_env

  ! require all variables to be explicitly declared
  implicit none

  ! accessibility of <subroutine>s and <function>s in this <module>
  public :: ABC123_A

  ! constants for this <module>
  character(len=4, kind=1), parameter, private :: string_communicatable     = 'Yay!'
  character(len=2, kind=1), parameter, private :: string_NOT_communicatable = ':('
  integer(kind=INT8),       parameter, private :: num_antenna               = 5_INT8

  ! contained <subroutine>s and <function>s are below
  contains

  subroutine ABC123_A

    ! variables for this <subroutine>
    integer(kind=INT8) :: coordinate(1:num_antenna)
    integer(kind=INT8) :: distance_max

    ! support variables for this <subroutine>
    integer(kind=INT8) :: itr

    ! STEP.01
    ! read out the coordinate of the antennas
    do itr = 1, num_antenna, 1
      read(unit=INPUT_UNIT, fmt='(I3)') coordinate(itr)
    end do

    ! STEP.02
    ! read out the maximum communicatable distance
    read(unit=INPUT_UNIT, fmt='(I3)') distance_max

    ! STEP.03.A
    ! judge the antenna A & E
    if ( coordinate(5) - coordinate(1) .gt. distance_max ) then
      write(unit=OUTPUT_UNIT, fmt='(A)', advance='yes') string_NOT_communicatable
      return
    end if

    ! STEP.03.B
    ! judge the antenna B to d
    do itr = 2, 4, 1
      if ( coordinate(itr) - coordinate(1) .gt. distance_max .or. coordinate(5) - coordinate(itr) .gt. distance_max ) then
        write(unit=OUTPUT_UNIT, fmt='(A)', advance='yes') string_NOT_communicatable
        return
      end if
    end do

    ! STEP.END
    write(unit=OUTPUT_UNIT, fmt='(A)', advance='yes') string_communicatable
    return

  end subroutine ABC123_A

end module ABC123


program main

  ! <module>s to import
  use, non_intrinsic :: ABC123

  ! require all variables to be explicitly declared
  implicit none

  call ABC123_A

end program main

Measured memory_bytes: 256
import java.util.*;
public class Main {
	
	public static void main(String... args) {
		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		int K = sc.nextInt();
		
		String[] map = new String[K];
		for (int i = 0; i < K; i++) {
			map[i] = sc.next();
		}
		
		int min = Integer.MAX_VALUE;
		for (int i = N; i <= 100_000; i++) {
			String val = String.valueOf(i);
			boolean flg = false;
			for (String s : map) {
				if (val.contains(s)) {
					flg = true;
					break;
				}
			}
			
			if (!flg) {
				min = Math.min(i, min);
			}
		}
		
		System.out.println(min);
	}
}

Measured memory_bytes: 28628
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

    public static void main(String[] args) throws Exception
    {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        String s1=br.readLine().trim();
        String s2=br.readLine().trim();
        int n=s2.length()-1;
        String s3=s2.substring(0,n);

        if(s3.equals(s1) && !s1.equals(s2) && (s2.length()==s1.length()+1))
        {
            System.out.println("Yes");
        }
        else{
            System.out.println("No");
        }




    }

}


Measured memory_bytes: 32460
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define all(v) v.begin(), v.end()
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    int cnt[26] = {};
    rep(i, 0, n) {
        cnt[s[i] - 'a']++;
    }

    ll ans = 1;
    ll mod = 1e9 + 7;
    rep(i, 0, 26) {
        if (cnt[i] != 0) {
            ans *= (cnt[i] + 1);
            ans = ans % mod;
        }
    }

    ans--;

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


Measured memory_bytes: 512
#include <iostream>
#include <complex>
#include <climits>
using namespace std;

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

    int* s = new int[N];

    int sum = 0;
    for (int i = 0; i < N; ++i) {
        cin >> s[i];
        sum += s[i];
    }

    if (sum % 10 != 0) {
        cout << sum << endl;
    } else {
        int ex = INT_MAX;
        for (int i = 0; i < N; ++i) {
            if (s[i] % 10 != 0) {
                ex = min(ex, s[i]);
            }
        }
        if (ex != INT_MAX) {
            cout << (sum - ex) << endl;
        } else {
            cout << 0 << endl;
        }
    }

    delete[] s;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define int long long
#define double long double
#define PI 3.141592653589793
typedef long long ll;
const int MOD = 1000000007;
const int INF = LLONG_MAX;
const double EPS = 1e-10;
using namespace std;
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 

vector<int> divisor(int n){
  vector<int> ret;
  for(int i = 1;i*i <= n;i++){
    if(n%i == 0){
      ret.push_back(i);
      if(i*i != n)ret.push_back(n/i);
    }
  }
  sort(ret.begin(), ret.end());
  return ret;
}

int n;vector<int> v[110000];
int d1[110000], dn[110000];

void dfs1(int depth, int node, int pre){
  if(node == n)return; 
  d1[node] = depth;
  rep(i,v[node].size()){
    if(v[node][i] == pre)continue;
    dfs1(depth+1, v[node][i], node);
  }
}

void dfsn(int depth, int node, int pre){
  if(node == 1)return; 
  dn[node] = depth;
  rep(i,v[node].size()){
    if(v[node][i] == pre)continue;
    dfsn(depth+1, v[node][i], node);
  }
}

signed main(){
  cin>>n;
  rep(i,n-1){
    int a,b;cin>>a>>b;
    v[a].push_back(b);v[b].push_back(a);
  }
  rep(i,110000)d1[i] = dn[i] = INF;
  dfs1(0,1,-1);
  dfsn(0,n,-1);
  int fe = 0, su = 0;
  repd(i,1,n+1){
    (d1[i] <= dn[i] ? fe : su)++;
  }
  //rep(i,n)cout << d1[i+1] << (i == n-1 ? "\n": " ");
  //rep(i,n)cout << dn[i+1] << (i == n-1 ? "\n": " ");
  //cout << fe << " " << su << endl;
  cout << (fe > su ? "Fennec" : "Snuke") << endl;
}



Measured memory_bytes: 13952
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rep1(i, n) FOR(i, 1, n+1)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define whole(x) (x).begin(),(x).end()
#define rwhole(x) (x).rbegin(), (x).rend()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define P pair<int, int>
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define eb emplace_back
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};
 
struct Query {
    int l, r, i;
    Query(int l, int r, int i): l(l), r(r), i(i){}
};
 
template<typename T>
struct BIT {
  int n;
  vector<T> d;
  BIT(int n=0):n(n),d(n+1) {}
  void add(int i, T x=1) {
    for (i++; i <= n; i += i&-i) {
      d[i] += x;
    }
  }
  T sum(int i) {
    T x = 0;
    for (i++; i; i -= i&-i) {
      x += d[i];
    }
    return x;
  }
  T sum(int l, int r) {
    return sum(r-1) - sum(l-1);
  }
};
 
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
    int n, q;
    cin >> n >> q;
    vector<int> c(n);
    rep(i, n) cin >> c[i];
    vector<Query> query;
    rep(qi, q) {
        int l, r;
        cin >> l >> r;
        l--; r--;
        query.eb(l, r, qi);
    }
    auto comp = [](Query a, Query b) {
        return a.l<b.l;
    };
    sort(whole(query), comp);
    reverse(whole(query));
    vector<int> ans(q);
    vector<int> pi(n+1, -1);
    vector<P> p;
    rep(i, n) {
        int prev = pi[c[i]];
        if (prev!=-1) {
            p.emplace_back(prev, i);
        }
        pi[c[i]] = i;
    }
    BIT<int> bit(n+5);
    sort(whole(p));
    reverse(whole(p));
    int index = 0;
 
    rep(i, q) {
        int l = query[i].l;
        int r = query[i].r;
        int qi = query[i].i;
        while (index<p.size()) {
            if (p[index].first<l) break;
            bit.add(p[index].second, 1);
            index++;
        }
        int a = bit.sum(r);
        ans[qi] = r - l + 1- a;
    }
 
    rep(i, q) cout << ans[i] << endl;
    return 0;
}

Measured memory_bytes: 22944
import sys

# f = open('input.txt')
f = input()

N = int(f)


out = []
sum = 0
for i in range(0, N+1):
    sum = sum + i
    out.append(i)
    if sum > N:
        r = sum - N
        out.remove(r)
        break
    
out.remove(0)

for n in out:
    print(n)

# print(' '.join(map(str, out)))

Measured memory_bytes: 3572