akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;

namespace ProgramingStydying
{
    class Program
    {
        static int[,] moveCounter;
        static bool[,] visited;
        static int h, w;
        static string[] field;


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

        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split();
            h = int.Parse(input[0]);
            w = int.Parse(input[1]);

            field = new string[h];

            for (int i = 0; i < h; i++)
            {
                field[i] = Console.ReadLine();
            }

            var ans = 0;

            for(int i = 0; i < h; i++)
            {
                for(int j = 0; j < w; j++)
                {
                    if(field[i][j] == '.')
                    {

                        visited = new bool[h, w];
                        moveCounter = new int[h, w];

                        bfs(i, j);
                        
                        if(twoDimentionalArrayMaximum(moveCounter) > ans)
                        {
                            ans = twoDimentionalArrayMaximum(moveCounter);
                        }
                    }
                }
            }
            Console.WriteLine(ans);
        }

        static void bfs(int i, int j)
        {
            var que = new Queue<(int,int)>();

            visited[i, j] = true;
            que.Enqueue((i, j));

            while (que.Count > 0)
            {
                var (x, y) = que.Dequeue();

                for (int a = 0; a < 4; a++)
                {
                    var nx = x + dx[a];
                    var ny = y + dy[a];

                    if (nx < 0 || nx >= h)
                    {
                        continue;
                    }
                    if (ny < 0 || ny >= w)
                    {
                        continue;
                    }
                    if (visited[nx, ny])
                    {
                        continue;
                    }
                    if (field[nx][ny] == '#') 
                    {
                        continue;
                    }

                    visited[nx, ny] = true;
                    que.Enqueue((nx, ny));
                    moveCounter[nx, ny] = moveCounter[x, y] + 1;
                }
            }
            return;
        }

        static int twoDimentionalArrayMaximum(int[,] a)
        {
            var ans = 0;

            for(int i = 0; i < h; i++)
            {
                for(int j = 0; j < w; j++)
                {
                    if(a[i,j] > ans)
                    {
                        ans = a[i, j];
                    }
                }
            }
            return ans;
        }
    }
}


Measured memory_bytes: 28384
import math
s = input()
n = len(s)
count = 0
a = [0 for i in range(2019)]
a[0] = 1
k = 0
b = [0 for i in range(n)]
b[0] = 1
for i in range(1, n):
    b[i] = b[i-1]*10 % 2019

#print(b)
for i in reversed(range(0, n)):
 #   print((b[n-i-1])*int(s[i]) % 2019)
    k += (b[n-i-1])*int(s[i]) % 2019
  #  print(k, k % 2019)
    a[k % 2019] += 1

for i in range(len(a)):
    if a[i] >= 2:
        count += (a[i])*(a[i]-1)//2
print(count)


Measured memory_bytes: 16340
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <map>
#include <string>
#include <queue>
#include <stack>
#include <math.h>
#define log(x) cout<<x<<endl
#define pb push_back
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
typedef long long lint;
using namespace std;

int main()
{
    int n;
    cin>>n;
    if(n%2==0){
        log(n/2);
    }
    else if(n!=1){
        log((n+1)/2);
    }
    else {
        log("1");
    }
}


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

using namespace std;

typedef long long ll;
typedef long double Double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

// chmax, chmin
template<class T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}

template<class T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}

int const inf = 1e9;

set<int> row[100010], col[100010];

struct Container {
    set<int> xx;
    set<int> yy;

    void update(int x, int y) {
        xx.insert(x);
        yy.insert(y);
    }
};

map<pair<int, int>, int> visited;

void dfs(int x, int y, Container &cont, int &counter) {
    if (abs(x) == inf || abs(y) == inf) return;
    if (visited.count({x, y})) return;
    cont.update(x, y);
    visited[{x, y}] = true;
    counter++;
    dfs(*row[y].upper_bound(x), y, cont, counter);
    dfs(*--row[y].lower_bound(x), y, cont, counter);
    dfs(x, *col[x].upper_bound(y), cont, counter);
    dfs(x, *--col[x].lower_bound(y), cont, counter);
}

void solve(long long N, std::vector<long long> x, std::vector<long long> y) {
    for (int i = 0; i < 100010; i++) {
        row[i].insert(-inf);
        row[i].insert(+inf);
        col[i].insert(-inf);
        col[i].insert(+inf);
    }
    for (int i = 0; i < N; i++) {
        row[y[i]].insert(x[i]);
        col[x[i]].insert(y[i]);
    }
    ll ans = 0;
    for (int i = 0; i < N; i++) {
        if (!visited.count({x[i], y[i]})) {
            auto c = Container();
            int counter = 0;

            dfs(x[i], y[i], c, counter);
            ans += 1ll * (c.xx.size()) * (c.yy.size()) - counter;
        }
    }
    cout << ans << endl;

}

int main() {
    long long N;
    scanf("%lld", &N);
    std::vector<long long> x(N);
    std::vector<long long> y(N);
    for (int i = 0; i < N; i++) {
        scanf("%lld", &x[i]);
        scanf("%lld", &y[i]);
    }
    solve(N, std::move(x), std::move(y));
    return 0;
}


Measured memory_bytes: 61056
#include<iostream>
#include<stdio.h>
#include<string.h>
using namespace std;
int main(){
	double a,b,r;
	scanf("%lf",&r);
	a=r*r*3.14159265359;
	b=(2*3.14159265359)*r;
	printf("%.5lf %.5lf\n",a,b);
	
	return 0;
}

Measured memory_bytes: 1236
#include<bits/stdc++.h>
#include<time.h>
#include<cctype>
#include<iostream>
#include<ostream>
#include<cstdio>
#include<algorithm>
#include<iomanip>
#include<cstring>
#include<string>
#include<cmath>
#include<stack>
#include<queue>
#include<vector>
#include<set>
#include<map>
using namespace std;
typedef long long ll;
const int inf=0x3f3f3f3f;//1061109567
const int INF=0x7fffffff;//2147483647
const int SUP=0x80000000;//-2147483648
#define MAX 1000000
ll a[MAX]={0},b[MAX]={0};
int main()
{
    int n;
    ll t;
    ll sum=0;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>t;
        if(i+t<=n)a[i+t]++;
        if(i-t>=1)b[i-t]++;
    }
    for(int i=1;i<=n;i++)
    {
        sum+=a[i]*b[i];
    }
    cout<<sum;
    return 0;
}


Measured memory_bytes: 6736
package main

import (
	"fmt"
)

func main() {
	var a, b int
	fmt.Scan(&a, &b)
	if a >= 13 {
		fmt.Println(b)
	} else if 6 <= a && a <= 12 {
		fmt.Println(b / 2)
	} else {
		fmt.Println(0)
	}
}


Measured memory_bytes: 512
import sys
import math
import collections
from collections import deque
from functools import reduce
import heapq
#x = int(input())
n, m, x = map(int, sys.stdin.readline().split())
#s = input()
#h = list(map(int, sys.stdin.readline().split()))

l = []
for i in range(n):
    l.append(list(map(int, sys.stdin.readline().split())))

ans = 10 ** 7

for j in range(2 ** n):
    bi = format(j, "b")
    if len(bi) != n:
        for k in range(n-len(bi)):
            bi = "0" + bi

    p = [0 for i in range(m+1)]
    for k in range(n):
        if bi[k] == "1":
            for i in range(m+1):
                p[i] += l[k][i]


    for i in range(m):
        if p[i+1] < x:
            break

        if i == m-1:
            if ans > p[0]:
                ans = p[0]

if ans == 10 ** 7:
    print(-1)
else:
    print(ans)





Measured memory_bytes: 9612
n=int(input())
list1=[[0 for i in range(n)] for j in range(n)]
#print(list1)

for i in range(n):
	a=list(map(int,input().split()))
	#print(a)
	if a[1]>0:
		for j in range(2,len(a)):
			list1[i][a[j]-1]=1
			
for i in range(n):
	print(*list1[i])



Measured memory_bytes: 6384
n = int(input())
s = [list(input()) for i in range(n)]
ans = 0
for a in range(n):
    check = True
    for x in range(n):
        for y in range(x):
            if s[(x+a)%n][y] != s[(y+a)%n][x]:
                check = False
                break
        if check == False:
            break
    if check:
        ans += n
    
print(ans)

Measured memory_bytes: 77484
N = int(input())
A = [int(a) for a in input().split()]
mod = 10**9+7
SUM = 0

maxA = max(A)
d = 0
while 1:
    if maxA < 2**d:
        break
    d += 1

BitSumB = 0
for i in range(d):
    tmp = 0
    for n in range(N):
        tmp += (A[n] >> i) & 1
    BitSumB += (2**i) * tmp * (N - tmp)



"""
BitA = [[0]*d for _ in range(N)]
for i in range(N):
    BitA[i] = list(map(int, format(bin(A[i])[2:], '0>{}'.format(d))))

BitSumB = 0
for i in range(d):
    tmp = sum([BitA[j][i] for j in range(N)])
    BitSumB += 2 ** (d-i-1) * (tmp * (N - tmp))
    #BitSumB = BitSumB % mod
"""

print(BitSumB % mod)


Measured memory_bytes: 122936
package main

import (
	"fmt"
	"math"
)

func abs(a int) int {
    return int(math.Abs(float64(a)))
}

func main() {
	var (
		a, b, c, d int
	)
	fmt.Scan(&a, &b, &c, &d)
	if abs(a-c) <= d || (abs(a-b) <= d && abs(b-c) <= d )  {
		fmt.Println("Yes")
		return
	}
	fmt.Println("No")
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#include<string>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <stdlib.h>
#include<string>
#define mp make_pair
#define ss second
#define ff first
#define pb push_back
#define io ios_base::sync_with_stdio;cin.tie(0);cout.tie(0)
#define READ freopen("input.txt","r", stdin)
#define mem(a,b)     memset(a, b, sizeof(a))
#define snd(a) scanf("%d",&a)
#define snl(a) scanf("%lld",&a)
#define snul(a) scanf("%ull",&a)
#define rep(i,k,n) for(int i=k;i<n;i++)
#define rev(j,n,k) for(int j=n;j>=k;j--)
#define TC int tc;cin>>tc;while(tc--)
#define FastRead ios_base::sync_with_stdio(false);cin.tie(NULL);

#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) ((a / __gcd(a, b) ) * b)

#define PI 2*acos(0.0)
#define MAX 1000000000
#define inf 1e18
#define MOD 1000000007
#define case(i) "Case "<<i++<<": "
#define nscase(i) "Case "<<i++<<":"
#define base(n,b) floor(log(n)/log(b))+1
#define onecnt(x) __builtin_popcount(x)
#define to_binary(n) bitset<8>(n).to_string()
#define endl '\n'
#define esc cout<<"\n"

/*------------------------------Graph Moves----------------------------*/
///const int fx[]= {+1,-1,+0,+0};
///const int fy[]= {+0,+0,+1,-1};
///const int fx[]= {+0,+0,+1,-1,-1,+1,-1,+1};  // Kings Move
///const int fy[]= {-1,+1,+0,+0,+1,+1,-1,-1}; // Kings Move
///const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
///const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move
/*---------------------------------------------------------------------*/

using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<long,long> pll;
typedef std::map<long long,int> mli;
typedef std::map<long long,long long> mll;
typedef std::map<int,int> mii;
using namespace __gnu_pbds;
typedef tree<
ll,
null_type,//set to another type while using map
less<ll>,
rb_tree_tag,
tree_order_statistics_node_update> ordered_set;

template <typename T>
std::string toString( T Number )
{
    std::ostringstream ss;
    ss << Number;
    return ss.str();
}


const ll ten5=100000;
const ll ten6 =1000000;
const ll ten7 =10000000;
const ll ten8 =100000000;
const ll ten9 =1000000000;
const ll mod=1000000007;


int main()
{
    io;
    char b,c;
    cin>>b;
    if(b=='A')c='T';
    else if(b=='T')c='A';
    else if(b=='C')c='G';
    else if(b=='G')c='C';
    cout<<c<<endl;
    return 0;
}


Measured memory_bytes: 3556
#include<stdio.h>
#include<math.h>
int main()
{
   long long int n,d,i,x,y,count=0;
   double result;

   scanf("%lld %lld",&n,&d);

   for(i=0;i<n;i++)
   {

       scanf("%lld %lld",&x,&y);

       result = sqrt((x*x)+(y*y));

       if(result<=d)
       {
           count++;
       }
   }
   printf("%lld\n",count);
   return 0;
}

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

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

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


ll gcd(ll a, ll b){
   if (a%b == 0){
       return(b);
   }else{
       return(gcd(b, a%b));
   }
}

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

void solve() {
    ll A, B; cin >> A >> B;
    cout << lcm(A, B) << endl;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout << fixed << setprecision(10);
  //init_f();
  //init();
  //int t; cin >> t; rep(i, t)solve();
  solve();
//   stop
    return 0;
}


Measured memory_bytes: 4352
#include<iostream>
using namespace std;
int main() {

	int a, b;
	cin >> a >> b;

	if (a<b) {
		cout << "a < b" << endl;
	}
	else if (a>b) {
		cout << "a > b" << endl;
	}
	else if (a == b) {
		cout << "a == b" << endl;
	}

	return 0;
}


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

using namespace std;

int main()
{
	int N;
	cin >> N;
	vector<int> L(2 * N);
	for (auto &x : L) {
		cin >> x;
	}
	sort(L.begin(), L.end());
	int ans = 0;
	for (int i = 0; i < 2 * N; i += 2) {
		ans += min(L[i], L[i + 1]);
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
<?php

	fscanf(STDIN, "%d %d %d", $a, $b, $c);
	$args = [];
	$args[0] = $a;
	$args[1] = $b;
	$args[2] = $c;
	$i = NULL;

	switch($a){
		case 5.7:$a = $args[0];
				break;
		default:break;
	}
	switch($b){
		case 5.7:$b = $args[0];
				break;
		default:break;
	}
	switch($c){
		case 5.7:$c = $args[0];
				break;
		default:break;
	}
	$i = $args[0]+$args[1]+$args[2];

	if($i == 17){
		echo "YES";
	}else{
		echo "NO";
	}
?>

Measured memory_bytes: 3828
n,m=map(int,input().split())
L=[];l=[]
for k in range(n):
  L.append(0)
for i in range(m):
  x=list(map(int,input().split()))
  l.append(x)
  if x[0]==1:
    L[x[1]]+=1
  if x[1]==1:
    L[x[0]]+=1
  if x[0]==n:
    L[x[1]]+=1
  if x[1]==n:
    L[x[0]]+=1
if max(L)==2:print('POSSIBLE')
else:print('IMPOSSIBLE')

Measured memory_bytes: 53332
#include <bits/stdc++.h>
#include <algorithm>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(x) (x).begin(), (x).end()
#define PB(x) push_back(x)
#define MP(x,y) make_pair(x,y)
using namespace std;
using P = pair<int,int>;
typedef long long ll;
#define MOD 1000000007

int main() {

    int n,m;
    cin>>n>>m;
    vector<int> a(n+2);
    rep(i,m)    cin>>a.at(i);
    vector<int>p(n+2);
    rep(i,n+2)    p.at(i)=true;
    rep(i,m)    p[a[i]]=false;

    p[0]=1;
    if(p[1]==true)  p[1]=1;
    else    p[1]=0;
    for(int i=2;i<n+1;i++) {
        if(p[i]==true)  p[i]=(p[i-1]+p[i-2])%MOD;
        else    p[i]=0;
    }
    
    cout<<p[n]<<endl;
    
 return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<climits>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<numeric>
#include<map>
#include<set>
#define REP(i,m,n) for(int i = m; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define LL long long
template<class T> void chmax(T & a, T b) { if (a < b) { a = b; } }
template<class T> void chmin(T& a, T b) { if (a > b) { a = b; } }
using namespace std;

int main(void) {
	int N, W;
	cin >> N >> W;

	vector<LL> weight(110);
	vector<LL> value(110);
	for (int i = 1; i <= N; i++) {
		cin >> weight[i] >> value[i];
	}

	vector<vector<LL> > dp(110, vector<LL>(100010));
	
	for (int i = 1; i <= N; i++) {
		for (int w = 0; w <= W; w++) {
			if (w >= weight[i]) {
				dp[i][w] = max(dp[i - 1][w - weight[i]] + value[i], dp[i - 1][w]);
			}
			else {
				dp[i][w] = dp[i - 1][w];
			}
		}
	}

	cout << dp[N][W] << endl;
}

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

/* * * *   * * *   	* * * */
#define ll long long
#define ld long double
#define II pair<int, int>
#define LL pair<ll, ll>
#define VI vector<int>
#define VB vector<bool>
#define VL vector<ll>
#define VII vector<II>
#define VLL vector<LL>
#define PB push_back
#define B begin()
#define E end()
#define F first
#define S second
#define SZ size()
#define P complex <ll> 
#define X real()
#define Y imag()
const int oo = 1e9;
const ll mod = 1e7;
/* * * *   * * *   	* * * */

/* *
 *
 * Author: Hamkor
 *
 * */

int main(){
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int a, b; cin>>a>>b;
	cout<<a*b - b-a+1;
	return 0;
}


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

typedef long long ll;

int main(){
    ll n;
    cin >> n;

    ll i = 1LL;
    ll ans = LLONG_MAX;
    while (i*i <= n) {
        if (n%i == 0) {
            ll x = i;
            ll y = n / x;
            if (x+y < ans) {
                ans = x+y;
            }
        }
        i++;
    }

    cout << ans - 2;

    return 0;
}


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

int main(){
    int n;
    ll x; cin >> n >> x;
    vector<ll> a(n); rep(i,n) cin >> a[i];
    ll ans = 0;
    rep(i,n-1){
        if(a[i]+a[i+1] > x){
            ans += min(a[i+1], a[i]+a[i+1]-x);
            a[i+1] -= min(a[i+1], a[i]+a[i+1]-x);
            if(a[i]+a[i+1] > x){
                ans += a[i]+a[i+1]-x;
                a[i] -= a[i]+a[i+1]-x;
            }
        }else{
            continue;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1e9)
#define PI (acos(-1))
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl

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

    vector<int> num(N, 0);
    rep(i, N) {
        int cnt = 0;
        int temp = i+1;
        rep(j, i) {
            if (temp % 2 == 0) {
                cnt++;
                temp = temp / 2;
            }
            else break;
        }
        num[i] = cnt;
    }

    vector<int>::iterator maxIt = max_element(all(num));
    print(1 + distance(num.begin(), maxIt));
}




Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <climits>
#include <cstdio>
#include <math.h>

#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define INF INT_MAX

typedef long long ll;

using namespace std;

//ベクトルの定義
struct Vector2D{
	double x;
	double y;
};

//ベクトルの長さを計算する
double get_vector_length(Vector2D v) {
	return pow((v.x * v.x) + (v.y * v.y), 0.5);
}

//ベクトル内積
double dot_product(Vector2D vl, Vector2D vr) {
	return vl.x * vr.x + vl.y * vr.y;
}

//２つのベクトルABのなす角度θを求める
double AngleOf2Vector(Vector2D A, Vector2D B)
{
	//　※ベクトルの長さが0だと答えが出ませんので注意してください。

	//ベクトルAとBの長さを計算する
	double length_A = get_vector_length(A);
	double length_B = get_vector_length(B);

	//内積とベクトル長さを使ってcosθを求める
	double cos_sita = dot_product(A, B) / (length_A * length_B);

	//cosθからθを求める
	double sita = acos(cos_sita);

	//ラジアンでなく0～180の角度でほしい場合はコメント外す
	sita = sita * 180.0 / M_PI;

	return sita;
}


int main(void){
	ll n; cin >> n;
	vector<Vector2D> xy(n);
	rep(i, n) cin >> xy[i].x >> xy[i].y;
	
	vector<int> perm(n);
	rep(i, n) perm[i] = i;
	double ans = INF;
	do{
		double sum = 0;
		Vector2D prev{1, 0};
		rep(i, perm.size()){
			Vector2D v1{(prev.x), (prev.y)};
			Vector2D v2;
			if(i==0) v2 ={xy[perm[i]].x, xy[perm[i]].y};
			else v2 ={xy[perm[i]].x - xy[perm[i-1]].x, xy[perm[i]].y - xy[perm[i-1]].y};
			sum += AngleOf2Vector(v1, v2);
			prev = {v2.x, v2.y};
		}
		Vector2D l1{(prev.x), (prev.y)};
		Vector2D l2;
		l2 ={0 - xy[perm[perm.size()-1]].x, 0 - xy[perm[perm.size()-1]].y};
		sum += AngleOf2Vector(l1, l2);
		prev ={l2.x, l2.y};

		ans = min(ans, sum);

	}while(next_permutation(perm.begin(), perm.end()));
	printf("%.20lf\n", ans);

	return 0;
}


Measured memory_bytes: 3416
#include <cstdio>
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <cmath>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#define rep(i,n) for (int i=0;i<n;i++)
using ll = long long;
using namespace std;

void solve(){

}
int main (){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> h(n);
    int ans = 0;
    int v = 0;
    rep(i,n) cin >> h[i];
    rep(i,n){
        if(h[i]>=v){
            ans += h[i] - v;
            v = h[i];
        }else{
            v = h[i];
        }
    }
    cout << ans << endl;
    return 0;
}

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

#define rep(i, a, b) for (int i = a; i < (int)(b); ++i)
#define rrep(i, a, b) for (int i = b - 1; i >= (int)(a); --i)

using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;

constexpr int MOD = 1000000007;

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

    int h, a;
    cin >> h >> a;

    cout << (h + a - 1) / a << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define int long long
#define ll long long
#define pb emplace_back
#define mp make_pair
#define f(i,a,n) for(int i=a ; i<n ; i++)
#define F first
#define S second
#define fast ios:: sync_with_stdio(false),cin.tie(0);

const int N = 3005;
int dp[N][N][2];
int a[N],n;
int solve(int l , int r,int turn)
{
    if(l > r)   return 0;
    if(l == r && turn)  return -a[l];
    if(l==r)          return a[l];
    if(dp[l][r][turn]!=-1)   return dp[l][r][turn];
    ll ans = 0;
    if(turn%2)   ans = min(-a[l]+solve(l+1,r,turn^1),-a[r]+solve(l,r-1,turn^1));
    else
    ans = max(a[l]+solve(l+1,r,turn^1),a[r]+solve(l,r-1,turn^1));
    return dp[l][r][turn] = ans;
}
int32_t main(){
	fast;
    cin >> n;
    for(int i=1 ; i<=n ; i++)   cin >> a[i];
    memset(dp,-1,sizeof(dp));
    int ans = solve(1,n,0);
    cout << ans;
}

Measured memory_bytes: 141568
#include <iostream>
#include <stdio.h>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <stack>
#include <queue>
#include <algorithm>
#include <string.h>
#include <string>
#include <math.h>
#include <iomanip>
using namespace std;

#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define pb push_back

typedef pair<int, int> pii;
typedef long long ll;
typedef unsigned long long ull;

const int mod = (int)1e9 + 7;
const int mod2 = 998244353;

ll exp(ll taban, ll us) {
    ll carpan = taban % mod;
    ll temp = us;
    ll res = 1;
    while(temp){
        if(temp % 2) res = (res*carpan) % mod;
        temp /= 2;
        carpan = (carpan*carpan) % mod;
    }
    return res;
}
 
ll ebob(ll a, ll b){
    if(!a)return b;
    return ebob(b%a, a);
}

ll ekok(ll a, ll b){
    return (a*b)/ebob(a, b);
}
ll fonk(ll n){
	return n*n*n*n*n;
}
int main(){
    ios_base::sync_with_stdio(false); cin.tie(NULL);
	ll x; cin>>x;
	for(ll i = -1e3; i <= 1e3; i++){
		for(ll j = -1e3; j <= 1e3; j++){
			if(fonk(j) - fonk(i) == x){
				cout<<j<<" "<<i<<endl;
				return 0;
			}
		}
	}
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define FOR(i, s, n) for (int i = (s); i < (n); i++)
#define rep(i, n) FOR(i, 0, n)
#define repi(i, n) FOR(i, 1, n + 1)
#define pp(v) cout << #v "=" << (v) << endl;
#define ppa(v) cout << "----\n"; rep(i,v.size()) cout << #v << "[" << i << "] = " << v[i] << endl;
#define div_ceil(a,b) ((a) + ((b) - 1)) / (b)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
using namespace std;
using Graph = vector<vector<int>>;
using ll = long long;

int main() {
  int a,b,c;cin>>a>>b>>c;
  bool ans = a+b==c||b+c==a||c+a==b; 
  cout << (ans?"Yes":"No") << endl;
}


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

using namespace std;

int main(){
    int a,b;
    cin >> a >> b;
    
    if(a%b==0){
        cout << "0";
    }else{
        cout << "1";
    }
    
    
    
    
    return 0;
}

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

def divisor(n):
     ass = []
     for i in range(1,int(n**0.5)+1):
         if n%i == 0:
             ass.append(i)
             if i**2 == n:
                 continue
             ass.append(n//i)
     return ass

ans = float("inf")
for i in divisor(n):
    j = n//i
    ans = min(ans, i-1+j-1)
print(ans)


Measured memory_bytes: 39664
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define PI acos(-1)
#define pcnt __builtin_popcountll
#define rng(a) a.begin(), a.end()
#define sz(x) (int)(x).size()
#define v(T) vector<T>
#define vv(T) v(v(T))
#define fi first
#define se second

using namespace std;
using ll = long long;
using P = pair<int, int>;
using LP = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;

template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) {if (a > b) { a = b; return true; } return false; }

ll INF = 1001001001;
ll LINF = 1001001001001001001ll;

vvl to;

void dfs(ll v, vector<bool>& visited) {
    if (visited[v]) return;

    visited[v] = true;
    for (auto nv : to[v]) {
        dfs(nv, visited);
    }
}

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

    ll n, m;
    cin>>n>>m;

    to = vvl(n);
    rep(i, m) {
        ll x, y, z;
        cin>>x>>y>>z; x--; y--;
        to[x].emplace_back(y);
        to[y].emplace_back(x);
    }
    vector<bool> visited(n);
    ll cnt = 0;
    rep(i, n) {
        if (visited[i]) continue;
        dfs(i, visited);
        cnt++;
    }
    cout<<cnt<<endl;
}

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

using namespace std;
using llong = long long;
using P = pair<llong, llong>;

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

const llong inf = llong(1e18)+7;
const llong mod = 1e9+7;

int main(){
	string s;
	cin >> s;
	string ss;
	for(int i = 0; i < (int)s.size(); i++){
		if(s[i] == 'K' || s[i] == 'B' || s[i] == 'R'){
			if(s[i-1] != 'A')
				ss += 'A';
		}
		ss += s[i];
	}
	if(ss[(int)ss.size()-1] != 'A')
		ss += 'A';

	if(ss == "AKIHABARA")
		cout << "YES" << endl;
	else
		cout << "NO" << endl;

	return 0;
}


// A KIHA BA RA

Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int m = sc.nextInt();

        HashMap<Integer, ArrayList<Integer>> map = new HashMap<>();
        int[] array = new int[n];
        int count = 0;
        for (int i = 0; i < m; i++) {
            int start = sc.nextInt();
            int end = sc.nextInt();
            map.computeIfAbsent(start, k -> new ArrayList<>()).add(end);
            map.computeIfAbsent(end, k -> new ArrayList<>()).add(start);
        }

        Deque<Integer> deque = new ArrayDeque<>();
        deque.add(1);
        while (!deque.isEmpty()) {
            int parent = deque.poll();
            ArrayList<Integer> list = map.get(parent);
            if (list == null) {
                continue;
            }
            for (Integer v: list
                 ) {
                if (array[v - 1] == 0) {
                    array[v - 1] = parent;
                    deque.add(v);
                    count++;
                }
            }
        }
        if (count != n) {
            System.out.println("No");
        } else {
            System.out.println("Yes");
            for (int i = 1; i < n; i++) {
                System.out.println(array[i]);
            }
        }
    }
}

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

int main() {
	string S;
	cin >> S;
	int ans = 0, temp = 0;
	for (int i = 0; i < S.length(); i++) {
		if (S[i] == 'R') {
			temp++;
		}
		else {
			ans = max(temp, ans);
			temp = 0;
		}

	}
	ans = max(temp, ans);
	temp = 0;
	cout << ans << endl;
	return 0;

}

Measured memory_bytes: 3592
n,k=map(int,input().split())
a=[[0]*n for _ in range(100)]
A=list(map(int,input().split()))
for i,j in enumerate(A):
    a[0][i]=j-1
i=1
while 2**i<k:
    for x,y in enumerate(a[i-1]):
        a[i][x]=a[i-1][y]
    i+=1
x=0
for j in range(i):
    if k>>j&1:
        x=a[j][x]
print(x+1)

Measured memory_bytes: 247704
#include<cstdio>
#include<functional>
#include<algorithm>
using namespace std;
int main(void)
{
	int i,n,q,s[100000],cnt,t[50000],j,flg;
	scanf("%d",&n);
	for(i=0;i<n;i++)	scanf("%d",&s[i]);
	scanf("%d",&q);
	for(i=0;i<q;i++)	scanf("%d",&t[i]);
	sort(t,t+q);
	cnt=0;	i=0;	j=0;
	while(i<n && j<q)	{
		if(s[i]==t[j])	{
			cnt++;	i++;	j++;
		}
		else if(s[i]<t[j])	i++;
		else j++;
	}
	printf("%d\n",cnt);
	return 0;
}


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

int main() {
  long long N, S=0; cin >> N;
  vector<int> A(N),B(N);
  for(int i=0;i<N;++i) {
    cin >> A[i]; S+=A[i];
  }
  if(S%(N*(N+1)/2)) {
    cout << "NO" << endl; return 0;
  }
  int a=S/(N*(N+1)/2);
  for(int i=0;i<N;++i) B[i] = A[(i+1)%N]-A[i];
  for(int i=0;i<N;++i) {
    if((B[i]-a)%N||B[i]>a) {
      cout << "NO" << endl; return 0;
    }
  }
  cout << "YES" << endl;
  return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cmath>
#include <set>
#include <string>
#include <algorithm>
#include <vector>
#include <bitset>
#include <iomanip>
#include <map>
#include <queue>

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;
using std::bitset;

#define rep(i,n)    for(int i=0; i<(int)n; i++)
#define reps(i,s,e) for(int i=s; i<(int)e; i++)
typedef long double ld;
typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef std::pair<int, int> pii;
typedef std::pair<ll, ll> pll;

template<class T>
using Graph = vector<vector<T>>;

void printFixedDouble(double d, int fix) {
    cout << std::fixed;
    cout << std::setprecision(fix) << d << endl;
}

int main() {
    ll A, B, K;
    cin >> A >> B >> K;
    if (A >= K) {
        A -= K;
        cout << A << " " << B << endl;
    } else {
        K -= A;
        B = std::max(0ll, B - K);
        cout << "0 " << B << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>
#include <cmath>
#include <complex>
#include <map>
#include <climits>
#include <sstream>
using namespace std;
 
#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define EPS 1e-8
#define F first
#define S second
#define mkp make_pair
 
static const double PI=6*asin(0.5);
typedef long long ll;
typedef complex<double> CP;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vint;
static const int INF=1<<24;
 
template <class T>
void initvv(vector<vector<T> > &v,int a,int b, const T  &t = T()){
    v.assign(a,vector<T>(b,t));
}
 
//v.erase(unique(v.begin(),v.end()),v.end());

int main(){
	int n;
	while(cin>>n){
		ll ans=0;
		int large=n;
		int small=max(n-1000,0);
		rep(i,1001){
			if(i>n) break;
			// cout<<i<<endl;
			rep(j,1001){
				// if(i+j>=1990) cout<<i<<" "<<j<<endl;
				if(i+j>n) continue;
				if(n-i-j>2000) continue;
				int a=min(large-i-j,1000),b=max(small-i-j,0);
				// if(i+j==2000) cout<<a<<" "<<b<<endl;
				if(a<0||b>1000) continue;
				// if(i+j==2000) cout<<a<<" "<<b<<" "<<i+j<<endl;
				ans+=(ll)a-b+1;
				
			}
		}
		cout<<ans<<endl;
	}
}

/*
10
20
8436
*/

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

int main() {
  int N, A, B; cin >> N >> A >> B;
  int count=0, d;
  for(int i=1; i<=N; i++){
    d=(i%10)+((i/10)%10)+((i/100)%10)+((i/1000)%10)+((i/10000)%10);
    if(d>=A&&d<=B) count+=i;
  }
  cout << count << endl;
}

Measured memory_bytes: 256
H, W, K = map(int, input().split())
S = []
for _ in range(H):
  S.append(input())
hsummation = [[int(S[0][k])]for k in range(W)]
for k in range(W):
  for j in range(1, H):
    hsummation[k].append(hsummation[k][j-1] + int(S[j][k]))
#print(hsummation)
ans = float('inf')
anskouho = 0
h = 2**(H-1)
for j in range(2**(H-1)):
  h -= 1
  binh = "0"*(H-len(str(bin(h)))+1)+str(bin(h))[2:]
  hlist=[]
  for k in range(H-1):
    if binh[-k-1] == '1':
      hlist.append(k)
  hlist.append(-1)
  #print(hlist)
  anskouho = len(hlist)-1
  now = 0
  while now < W:
    counter = [0 for _ in range(len(hlist))]
    while now < W:
      for l in range(len(hlist)):
        if l == 0:
          counter[l] += hsummation[now][int(hlist[l])]
          continue
        else:
          counter[l] += - hsummation[now][hlist[l-1]] + hsummation[now][hlist[l]]
      if max(counter) > K:
        anskouho += 1
        break
      else:
        now += 1
    if anskouho > ans:
      break
  else:
    ans = min(ans, anskouho)
 
      #print(counter)
#print(anskouho)
print(ans)

Measured memory_bytes: 9312
#include <utility> // pair make_pair
using std::swap; // c++11
using std::pair;
using std::make_pair;
#include <tuple> // tuple(c++11) make_tuple(c++11)
using std::tuple; // get<address>(variable)
using std::make_tuple;
#include <string> // string stoi(c++11) stoll(c++11) to_string(c++11)
using std::string;
using std::stoi;
using std::stoll;
using std::to_string;
#include <queue> // queue priority_queue
using std::queue;
using std::priority_queue;
#include <stack> // stack
using std::stack;
#include <vector> // vector
using std::vector;
#include <map> // map
using std::map;
#include <set> // set
using std::set; // insert erase find count
#include <algorithm> // min max
using std::sort;
using std::lower_bound; // iterator,  >=
using std::upper_bound; // iterator,  >
using std::min;
using std::max;
using std::min_element; // iterator
using std::max_element; // iterator
#include <complex> // complex
using std::complex; // real imag
#include <iostream> // cin cout
using std::cin;
using std::cout;
using std::endl;
#include <iomanip> // setprecision fixed(manipulator)
using std::setprecision;
using std::fixed;
#include <cmath>
#include <cstdio>

#define lli long long int
#define INF (int)1e09
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define EFOR(i, m, n) for (int i = m; i <= n; i++)
#define RFOR(i, m, n) for (int i = m; i > n; i--)
#define REFOR(i, m, n) for (int i = m; i >= n; i--)
#define VSORT(v) sort((v).begin(), (v).end()) // sort vector
typedef pair<int, int> PI;
typedef tuple<int, int, int> TI;
template <typename T> using Vec = vector<T>; // c++11

int main(void) {
    int n;
    cin >> n;
    Vec<int> a(n);
    FOR (i, 0, n) {
        cin >> a[i];
    }
    int count = 0;
    bool pos;

    while (1) {
        pos = true;
        FOR (i, 0, n) {
            if (a[i] % 2 == 0) {
                a[i] /= 2;
            } else {
                pos = false;
            }
        }
        if (pos == true) {
            count++;
        } else {
            break;
        }
    }
    cout << count << endl;
    return 0;
}


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();
        String s = String.valueOf(N);
        int l = s.length();
        int sum = 0;

        for(int i=0; i<l; i++){
            sum += Integer.parseInt(s.substring(i, i+1));
        }

        if(N%sum==0){
            System.out.println("Yes");
        }
        else{
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 23508
#include<bits/stdc++.h>
#define LL long long
using namespace std;
int a[100001];
int b[100001];
int sum[100001]={0};
int main(void){
	int n,m;
	int i;
	int front,back;
	LL sgm;
	cin>>n>>m;
	a[1]=0;
	for(i=2;i<=n;i++)	cin>>a[i];
	for(i=1;i<=m;i++)	cin>>b[i];
	for(i=1;i<=n;i++){
		sum[i]=sum[i-1]+a[i];
	}
	//for(i=1;i<=n;i++)	cout<<sum[i]<<endl;
	sgm=0;
	front=1;
	for(i=1;i<=m;i++){
		back=front+b[i];
		sgm+=abs(sum[back]-sum[front]);
		front=back;
	}
	cout<<sgm%100000<<endl;
	return 0;
}
	


Measured memory_bytes: 4268
private fun readInts() = readLine()!!.split(" ").map { it.toInt() }
private fun readLongs() = readLine()!!.split(" ").map { it.toLong() }

private fun gcd(a: Long, b: Long): Long = when {
    a < b -> gcd(b, a)
    b == 0L -> a
    else -> gcd(b, a % b)
}

private fun lcm(a: Long, b: Long) = a / gcd(a, b) * b
private fun gcd(a: Int, b: Int) = gcd(a.toLong(), b.toLong()).toInt()
private fun lcm(a: Int, b: Int) = lcm(a.toLong(), b.toLong()).toInt()

fun main(args: Array<String>) {
    val (A, B, C) = readInts()
    println(if (setOf(A, B, C).size == 1) "Yes" else "No")
}

Measured memory_bytes: 35956
# cook your dish here

num = int(input())
arr = list(map(int,input().split(" ")));

maxi = 1000000000000000000

val = 1;
arr.sort()

if arr[0]==0:
        print(0)

else:
        for i in arr:
                val = val*i;
                if val>maxi:
                        val = -1
                        break
        
        
        print(val)
        
                


        

Measured memory_bytes: 21592
Imports System

Module Program
    Sub Main(args As String())
        Dim tmp As String() = Split(Console.ReadLine(), " ")
        Dim H1 As Integer = CInt(tmp(0))
        Dim M1 As Integer = CInt(tmp(1))
        Dim H2 As Integer = CInt(tmp(2))
        Dim M2 As Integer = CInt(tmp(3))
        Dim K As Integer = CInt(tmp(4))

        Dim WAKE As Integer = H1 * 60 + M1
        Dim LastStart As Integer = H2 * 60 + M2 - K

        Console.WriteLine(LastStart - WAKE)

    End Sub
End Module


Measured memory_bytes: 28176
#include <iostream>
#include <vector>
#include <list>
#include <algorithm>
#include <string>
#include <stack>
#include <iomanip>
#include <numeric>
#include <queue>

using namespace std;
using ll = long long;
#define MOD 1000000007
#define INF 1LL << 59

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

    int n;
    cin >> n;

    while (n--)
    {
        string s, t;
        cin >> s >> t;
        //cout << s << " " << t << endl;
        int carry = 0;
        string ans = "";
        while (!s.empty() || !t.empty())
        {
            int lastDigit_1 = (s.empty()) ? 0 : s.back() - '0';
            int lastDigit_2 = (t.empty()) ? 0 : t.back() - '0';

            int sum = lastDigit_1 + lastDigit_2 + carry;
            ans.push_back((char)('0' + sum % 10));
            carry = sum / 10;

            if (!s.empty())
                s.pop_back();
            if (!t.empty())
                t.pop_back();
        }

        if (carry)
            ans.push_back((char)('0' + carry));

        reverse(ans.begin(), ans.end());

        if (ans.size() > 80)
            cout << "overflow" << endl;
        else
            cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 3108
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author lstd
 */

#include <iostream>
#include <fstream>

#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <bitset>
#include <random>
#include <chrono>
#include <complex>
#include <algorithm>
#include <utility>
#include <functional>
#include <cmath>
#include <cstring>
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <ctime>

using namespace std;

#define sqr(x) ((x)*(x))
#define mp make_pair
#define pb push_back
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define RE(i, n) FOR(i,1,n)
#define REP(i,n) FOR(i, 0, (int)(n)-1)
#define fst first
#define snd second

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef long double ld;

string to_string(string s) {
    return '"' + s + '"';
}

string to_string(const char* s) {
    return to_string((string) s);
}

string to_string(bool b) {
    return (b ? "true" : "false");
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
    return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for (const auto &x : v) {
        if (!first) {
            res += ", ";
        }
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}



void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}

int XMOV[4] = {0, 0, 1, -1};
int YMOV[4] = {1, -1, 0, 0};

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

using namespace std;

class CGreenBin {
public:
	void solve(std::istream& in, std::ostream& out) {
		int n;
		in >> n;
		map<string, ll> m;
		string s;

		for (int i = 0; i < n; i++)
			in >> s, sort(s.begin(), s.end()), m[s]++;

		ll ans = 0;
		for (auto it = m.begin(); it != m.end(); ++it){
			ans += it->snd * (it->snd-1) / 2;
		}

		out << ans;

	}
};

int main() {
	CGreenBin solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}

Measured memory_bytes: 11136
#include <bits/stdc++.h>
using namespace std;
const int maxn = 3000;

double p[maxn], np[maxn];
double dp[maxn][maxn];

int main()
{
#ifdef LOCAL
    freopen("data.txt", "r", stdin);
#endif
    int n;
    scanf("%d", &n);
    for (int i = 1; i <= n; ++i)
        scanf("%lf", &p[i]), np[i] = 1.0 - p[i];
    dp[1][0] = 1.0;
    double ans = 0.0;
    for (int i = 1, i_ = (n >> 1) + 1; i <= i_; ++i)
        for (int j = 1; j <= n; ++j) {
            dp[i][j] = dp[i][j - 1] * p[j] + dp[i - 1][j - 1] * np[j];
            if (j == n)
                ans += dp[i][j];
        }
    printf("%.10f\n", ans);
}

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

int main() {
    int N; cin >> N;
    vector<ll> a(N);
    ll s = 0;
    for (int i = 0; i < N; i++) {
        cin >> a[i];
    }
    vector<ll> r1(N), r2(N);
    r1[0] = a[0]; r2[N-1] = a[N-1];
    for (int i = 1; i < N; i++) {
        r1[i] = r1[i-1] + a[i];
        r2[N-1-i] = r2[N-i] + a[N-1-i];
    }
    ll ans = INF;
    for (int i = 0; i < N-1; i++){
        ans = min(abs(r2[i+1] - r1[i]), ans);
    }
    cout << ans << endl;
}


Measured memory_bytes: 4992
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int k  = in.nextInt();
		int n  = in.nextInt();
		int[] ary = new int[n];
		for(int i=0; i<n; i++){
			ary[i] = in.nextInt();
		}
		int result = 10000000;
		for(int i=0; i<n; i++){
			if(i == 0){
				result = Math.min(result, ary[n-1]- ary[i]);
			} else {
				result = Math.min(result, k - ary[i] + ary[i-1]);
			}
		}
		System.out.println(result);
	}
}


Measured memory_bytes: 85248
N,K=map(int,input().split())
R,S,P=map(int,input().split())
T=input()

TKlist=[]
for i in range(K):
  TKlist.append([])  

for i in range(N):
  TKlist[i%K].append(T[i])
#print(TKlist)

answer=0
for i in range(K):
  lastChar="#"
  for j in range(len(TKlist[i])):
    if TKlist[i][j]!=lastChar:
      lastChar=TKlist[i][j]
      if TKlist[i][j]=='r':        
        answer+=P
      elif TKlist[i][j]=='s':        
        answer+=R
      elif TKlist[i][j]=='p':        
        answer+=S
    else:
      lastChar="#"
      answer+=0

print(answer)

Measured memory_bytes: 13428
t=input()
s=list(t)
k=int(input())
if s==[s[0]]*len(s):
  print((len(s)*k)//2)
  exit()
b=[1]
for i in range(1,len(s)):
  if s[i-1]==s[i]:b[-1]+=1
  else:b.append(1)
ans=0
for i in b:ans+=i//2*k
if t[0]==t[-1] and (b[0]+b[-1])%2==0:ans+=k-1
print(ans)


Measured memory_bytes: 9048
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<int, int>;
using VI = vector<int>;

int main() {
#ifdef LOCAL_EXEC
//	freopen("sample.in", "r", stdin);
//	freopen("sample.out", "w", stdout);
#else
  ios_base::sync_with_stdio(false); cin.tie(NULL);
#endif

  int n; cin >> n;
  ll ans = 1;
  const ll lim = 1e18;
  while (n--) {
    ll x; cin >> x;
    if (x == 0) {
      ans = 0;
      break;
    }
    if (ans != -1) {
      if (ans > lim / x) {
        ans = -1;
      } else {
        ans *= x;
      }
    }
  }
  cout << ans << endl;

  return 0;
}


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


using namespace std;

typedef long long ll;
#define SWAP(x,y,z) {if ( y > z ) swap(y,z); if ( x > y ) swap(x,y); if (y > z) swap(y,z);}

double const eps = 1e-10;
ll const mod = 1e9+7;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    unsigned short int a,b;
    cin >> a >> b;
    cout << (a+b)%24;

    return 0;

    // 274751WM
}


Measured memory_bytes: 256