akhauriyash/Code-Regression huggingface dataset:
import Control.Arrow
import Control.Monad
import Data.List
import qualified Data.ByteString.Char8 as B

main :: IO ()
main = readLine >>= main'
    where
        main' [n, k] = getLine >>= print . solve k

solve :: Int -> String -> Int
solve k ss = check acc0 acc0 ns xs0
    where
        ns = map ((,) <$> head <*> length) . group $ map (== '1') ss
        (acc0, xs0) = count k 0 ns

        check acc pcc pps@((pb, pl) : ps) xxs@(_ : _)
            | pb = check (max acc rcc) rcc ps ys
            | otherwise = check (max acc rcc2) rcc2 ps ys2
            where
                rcc = pcc - pl + bls
                (bls, ys) = count 0 0 xxs

                rcc2 = pcc - pl + bls2
                (bls2, ys2) = count 1 0 xxs
        check acc _ _ _ = acc

        count n acc xxs@((b, l) : xs)
            | b = count n (acc + l) xs
            | n > 0 = count (n - 1) (acc + l) xs
            | otherwise = (acc, xxs)
        count _ acc _ = (acc, [])

readLine :: IO [Int]
readLine = unfoldr (fmap (second (maybe B.empty snd . B.uncons)) . B.readInt) <$> B.getLine


Measured memory_bytes: 16764
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque, OrderedDict
from copy import deepcopy
from functools import lru_cache, reduce
from math import ceil, floor
from sys import setrecursionlimit

import heapq
import itertools
import operator


inf = float('inf')


# globals
N, A, B, C = 0, 0, 0, 0
L = []


def set_inputs():
    global N, A, B, C, L
    N, A, B, C = get_li()
    L = get_data(N, [int])
    return


def main():
    setrecursionlimit(100000)
    set_inputs()
    ans = inf
    for x in itertools.product(range(4), repeat=N):
        take = [[], [], [], []]
        for i in range(N):
            take[x[i]].append(L[i])
        if len(take[0]) == 0 or len(take[1]) == 0 or len(take[2]) == 0:
            continue
        cost = 0
        cost += abs(sum(take[0]) - A)
        cost += abs(sum(take[1]) - B)
        cost += abs(sum(take[2]) - C)
        cost += (len(take[0]) - 1) * 10
        cost += (len(take[1]) - 1) * 10
        cost += (len(take[2]) - 1) * 10
        ans = min(ans, cost)
    print(ans)
    return


def get_int():
    return int(input())


def get_float():
    return float(input())


def get_str():
    return input().strip()


def get_li():
    return [int(i) for i in input().split()]


def get_lf():
    return [float(f) for f in input().split()]


def get_lc():
    return list(input().strip())


def get_data(n, types):
    if len(types) == 1:
        return [types[0](input()) for _ in range(n)]
    return zip(*(
        [t(x) for t, x in zip(types, input().split())]
        for _ in range(n)
    ))


if __name__ == '__main__':
    main()


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



int main() {
  ll n;
  cin >> n;
  vector<ll> a(n), b(n), c(n);
  rep(i, n) cin >> a[i];
  rep(i, n) cin >> b[i];
  rep(i, n) cin >> c[i];
  sort(all(a));
  sort(all(c));
  
  ll ans = 0;
  rep(i, n) {
    ll B = b[i];
    if (a[0] >= B) continue;
    if (c[n-1] <= B) continue;
    ll a_max = lower_bound(a.begin(), a.end(), B) - 1 - a.begin();
    ll c_min = upper_bound(c.begin(), c.end(), B) - c.begin();
    ans += (a_max+1)*(n-c_min);
  }
  cout << ans << endl;
  return 0;
}

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

int main(){
    string s;
    cin >> s;
    bool ans = false;
    if (s[0] == s[1] && s[2] == s[3] && s[0] != s[2]) ans = true;
    if (s[0] == s[2] && s[1] == s[3] && s[0] != s[1]) ans = true;
    if (s[0] == s[3] && s[2] == s[1] && s[0] != s[1]) ans = true;
    
    if (ans) puts("Yes");
    else puts("No");
}

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

using namespace std;
using ll = long long;
using pii = pair<int, int>;

map<string, char> mp;

void init() {
  mp["11"] = 'a';
  mp["12"] = 'b';
  mp["13"] = 'c';
  mp["14"] = 'd';
  mp["15"] = 'e';
  mp["21"] = 'f';
  mp["22"] = 'g';
  mp["23"] = 'h';
  mp["24"] = 'i';
  mp["25"] = 'j';
  mp["31"] = 'k';
  mp["32"] = 'l';
  mp["33"] = 'm';
  mp["34"] = 'n';
  mp["35"] = 'o';
  mp["41"] = 'p';
  mp["42"] = 'q';
  mp["43"] = 'r';
  mp["44"] = 's';
  mp["45"] = 't';
  mp["51"] = 'u';
  mp["52"] = 'v';
  mp["53"] = 'w';
  mp["54"] = 'x';
  mp["55"] = 'y';
  mp["61"] = 'z';
  mp["62"] = '.';
  mp["63"] = '?';
  mp["64"] = '!';
  mp["65"] = ' ';
}

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  init();
  string s;
  while (cin >> s) {
    string ans = "";
    int sz = s.size(), na = sz & 1;
    for (int i = 0; i < sz; i += 2) {
      string t = s.substr(i, 2);
      na |= mp.find(t) == mp.end();
      ans += mp[s.substr(i, 2)];
    }
    cout << (na ? "NA" : ans) << endl;
  }

  return 0;
}


Measured memory_bytes: 3152
import numpy as np
n,k,q = map(int, input().split())
a = [int(input()) for i in range(q)]
win = [0 for _ in range(n)]
for ai in a:
  win[ai-1] += 1
for w in win:
  if k-q+w<=0: print('No')
  else: print('Yes')

Measured memory_bytes: 17616
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

class Main{
	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)){
			int q = sc.nextInt();
			List<Integer> A = new ArrayList<>();
			for(int i=0;i<q;i++) {
				int query = sc.nextInt();
				if(query==0) {
					A.add(sc.nextInt());
				}
				else if(query==1) {
					System.out.println(A.get(sc.nextInt()));
				}
				else if(query==2) {
					A.remove(A.size()-1);
				}
			}
		}
	}
}


Measured memory_bytes: 140764
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define rep(i,n) for(int i = 0; i < n; i++)
#define reps(i,j,n) for(int i = j; i < n; i++)
#define rrep(i,j,n) for(int i = j-1; i >= n; i--)
#define prec(n) fixed << setprecision(n)
#define print_array(v) rep(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define fi first
#define se second
using namespace std;

int inf = 2147483647;
int64_t inf64 = 9223372036854775807;
int mod = 1e+7;

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

  int64_t q, h, s, d, n;
  cin >> q >> h >> s >> d >> n;

  int64_t mini = min({q*8, h*4, s*2, d});
  int64_t res = 0;
  while(n != 0 && n != 1) {
    n -= 2;
    if(mini == q*8) res += q*8;
    if(mini == h*4) res += h*4;
    if(mini == s*2) res += s*2;
    if(mini == d)   res += d;
  }
  if(n == 1) res += min({q*4, h*2, s});
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 384
#include "bits/stdc++.h"
using namespace std;
int main(){
  int n;
  cin >> n;
  int a,b,c[n];
  long long int ans=0;
  for(int i=0;i<n;i++){
    cin >> a >> b;
    ans += a;
    c[i] = a+b; //減少分、お互いに数字が取れなくなるので原点はa[i]+b[i]
  }
  sort(c,c+n,greater<>());
  for(int i=1;i<n;i+=2){
    ans -= c[i];
  }
  cout << ans;
}


Measured memory_bytes: 640
x1, y1, x2, y2 = map(int,input().split())

x3 = x2 - (y2 - y1)
y3 = y2 + (x2 - x1)
x4 = x3 - (y3 - y2)
y4 = y3 + (x3 - x2)

print(x3,y3,x4,y4)

Measured memory_bytes: 2940
using System;

namespace atcorder
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            string s = Console.ReadLine();
            int a = int.Parse(s.Split(' ')[0]);
            int b = int.Parse(s.Split(' ')[1]);
            int r;
            if (a > b) r = a - 1;
            else r = a;
            Console.WriteLine(r);
        }
    }
}


Measured memory_bytes: 13140
N=int(input())
H=list(map(int,input().split()))

dp=[0 for i in range(N)]
dp[1]=abs(H[1]-H[0])

for i in range(2,N):
    dp[i]=min(dp[i-1]+abs(H[i]-H[i-1]),dp[i-2]+abs(H[i]-H[i-2]))
print(dp[N-1])

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

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


cout << (1+n)*n/2-n << endl;
return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, b) for(ll i = ll(a); i < ll(b); i++)
#define rer(i, a, b) for(ll i = ll(a) - 1; i >= ll(b); i--)
#define sz(v) (int)(v).size()
#define pb push_back
#define sc second
#define fr first
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
using namespace std;
typedef long long int ll;
typedef pair <int, int> P;

const ll MOD=1000000007;
ll N;
ll A[100000];
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>N;
    ll sum=0;
    rep(i,0,N){
        cin>>A[i];
        sum+=A[i];
    }
    if(sum%((N+1)*N/2)){
        cout <<"NO"<<"\n";
        return 0;
    }
    ll t=sum/((N+1)*N/2);
    ll res=0;
    rep(i,0,N){
        ll d=A[(i+1)%N]-A[i];
        if((t-d)%N||t<d){
            cout <<"NO"<<"\n";
            return 0;
        }
        else{
            res+=(t-d)/N;
        }
    }
    if(res==t) cout <<"YES"<<"\n";
    else cout <<"NO"<<"\n";
}

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

int main()
{
  char pattern[8][8];
  for (int i=0; i<8; i++)
  {
    for (int j=0; j<8; j++)
    {
      cin >> pattern[i][j];
    }
  }

  char pattern2[8][8];
  for (int n=1; n<=3; n++)
  {
    for (int i=0; i<8; i++)   //回転
    {
      for (int j=0; j<8; j++)
      {
        pattern2[j][7-i] = pattern[i][j];
      }
    }


    cout << n*90 << endl;
    for (int i=0; i<8; i++)   //表示 
    {
      for (int j=0; j<8; j++)
      {
        cout << pattern2[i][j] << flush;
      }
      cout << endl;
    }
    for (int i=0; i<8; i++)   //代入
    {
      for (int j=0; j<8; j++)
      {
        pattern[i][j] = pattern2[i][j];
      }
    }

  }
}

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

using namespace std;
 
const long long inf = 1e18;
#define ll long long
#define fr(i,a,n) for (int i=a;i<n;i++)
#define rfr(i,n,a) for (int i=n;i>=a;i--)
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll,ll> 
#define endl "\n"
typedef vector<int> VI;
typedef vector<ll> VL;

ll n,m,k;
ll dp[101][100001];
vector <pair<int,int> > in;

int main() {
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n >> k;
	fr(i,0,n) {
		int w,v;
		cin >> w >> v;
		in.pb({w,v});
	}
	fr(i,0,n) {
		fr(j,0,k+1) {
			if (in[i].first + j <= k) {
				dp[i+1][in[i].first + j] = max(dp[i+1][in[i].first + j],dp[i][j] + in[i].second);
			}
			dp[i+1][j] = max(dp[i+1][j],dp[i][j]);
		}
	}
	ll ans = 0;
	for (int i = 0;i <= k;i++) {
		ans = max(ans,dp[n][i]);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 78336
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    int a[n];
    for(int i = 0;i<n;i++){
        cin >> a[i];
    }
    sort(a,a+n);
    for(int i = 0;i<n-1;i++){
        if(a[i] == a[i+1]){
            cout << "NO";
            return 0;
        }
    }
    cout << "YES";
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
#define MOD 1000000007
#define M_PI 3.14159265358979323846
#define ALL(X) (X).begin(),(X).end()

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

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

using namespace std;

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

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

int main()
{
    #ifdef __LOCAL
      fs::path p = __FILE__;
      fs::path input,output;
      input = output = p.parent_path();
      input += string("/input/") + string(p.stem()) + string(".txt");
      output += string("/output/") + string(p.stem()) + string(".txt");
      freopen(input.c_str(), "r", stdin);
      freopen(output.c_str(), "w", stdout);
    #endif

    double a,b,x;
    cin >> a >> b >> x;
    double V = a*a*b;
    double theta;
    if(2*x>V) theta=atan(2*b*(1-x/V)/a)*180/M_PI;
    else theta = 90-atan(2*x*a/(b*V))*180/M_PI;
    cout << fixed << setprecision(20) << theta << endl;

    return 0;
}


Measured memory_bytes: 256
import math
from functools import reduce

n = int(input())
a_list = list(map(int, input().split()))
max = 10 ** 6 + 1
memo = [0] * max

for a in a_list:
    memo[a] += 1

for i in range(2, max):
    if sum(memo[i::i]) > 1:
        if reduce(math.gcd, a_list) == 1:
            print("setwise coprime")
            exit()
        else:
            print("not coprime")
            exit()

print("pairwise coprime")


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

int ret(int i){
	switch (i)
	{
	case 2:
		return 3;
		break;
	case 4:
	case 6:
	case 9:
	case 11:
		return 2;
	default:
		return 1;
	}
}

int main(){
	int x, y;
	while (cin >> x >> y) {
		if (ret(x) == ret(y)) {
			cout << "Yes" << endl;
		}
		else cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

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

        // 入力(a b c)
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();

        System.out.println((b - a == c - b) ? "YES" : "NO");
        sc.close();
    }
}

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

const int inf = 1e9;
int g[100][100];
int gg[100][100];

int main() {
	int n, m;
	cin >> n >> m;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			g[i][j] = inf;
		}
		g[i][i] = 0;
	}
	for (int i = 0; i < m; i++) {
		int u, v, w;
		cin >> u >> v >> w;
		u--; v--;
		gg[u][v] = g[u][v] = min(g[u][v], w);
		gg[v][u] = g[v][u] = min(g[v][u], w);
	}
	for (int k = 0; k < n; k++) {
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				g[i][j] = min(g[i][j], g[i][k] + g[k][j]);
			}
		}
	}

	int ans = m;
	for (int i = 0; i < n; i++) {
		for (int j = i + 1; j < n; j++) {
			if (gg[i][j] != inf && g[i][j] == gg[i][j]) {
				ans--;
			}
		}
	}
	cout << ans << endl;
}

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

int main() {
    int n;
    long long k;
    cin >> n >> k;
    vector<long long> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a.at(i);
        a.at(i)--;
    }

    vector<long long> sum(n + 1);
    for (int i = 0; i < n; i++) {
        sum.at(i + 1) = (sum.at(i) + a.at(i)) % k;
    }

    map<long long, long long> m;
    long long ans = 0;
    for (int i = 0; i < n + 1; i++) {
        if (k <= i) m[sum.at(i - k)]--;

        ans += m[sum.at(i)];
        m[sum.at(i)]++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 15872
#include <bits/stdc++.h>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define REPA(x, v) for(auto&& x:v)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(v.rbegin(),v.rend())
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> void pr_vec(vector<T> &v, char ep=' '){int n=v.size();REP(ni,n){cout<<v[ni];if(ni!=n-1)cout<<ep;}cout<<endl;};
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

template<uint32_t mod>
struct ModInt{
    uint32_t a;
    ModInt& s(uint32_t vv){
        a=vv<mod?vv:vv-mod;
        return *this;
    }
 
    ModInt(int64_t x=0){s(x%mod+mod);}
 
    ModInt& operator+=(const ModInt &x){return s(a+x.a);}
    ModInt& operator-=(const ModInt &x){return s(a+mod-x.a);}
    ModInt& operator*=(const ModInt &x){
        a=uint64_t(a)*x.a%mod;
        return *this;
    }
    ModInt& operator/=(const ModInt &x){
        *this*=x.inv();
        return *this;
    }
 
    ModInt operator+(const ModInt &x)const{return ModInt(*this)+=x;}
    ModInt operator-(const ModInt &x)const{return ModInt(*this)-=x;}
    ModInt operator*(const ModInt &x)const{return ModInt(*this)*=x;}
    ModInt operator/(const ModInt &x)const{return ModInt(*this)/=x;}
    bool operator==(const ModInt &x)const{return a==x.a;}
    bool operator!=(const ModInt &x)const{return a!=x.a;}
    bool operator<(const ModInt &x)const{return a<x.a;}
 
    ModInt operator-()const{return ModInt()-*this;}
    ModInt pow(int64_t n)const{
        ModInt res(1),x(*this);
        while(n){
            if(n&1)res*=x;
            x*=x;
            n>>=1;
        }
        return res;
    }
 
    ModInt inv()const{return pow(mod-2);}
};
 
template<uint32_t mod>
istream& operator>>(istream& in,ModInt<mod>& a){
    return (in>>a.a);
}
template<uint32_t mod>
ostream& operator<<(ostream& out,const ModInt<mod>& a){
    return (out<<a.a);
}
using mint=ModInt<MOD>;

int main(void)
{
    int N;
    cin >> N;
    vector<mint> A(N);
    REP(i,N) cin >> A[i];
    
    mint t;
    REP(i,N) t += A[i];

    mint ans;
    REP(i, N){
        t -= A[i];
        ans += A[i] * t;
    }
    pr(ans);
}

Measured memory_bytes: 4044
/* “Whether you think you can or you think you can’t, you’re right” - Henry Ford */

#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define all(x) x.begin(), x.end()
#define F first
#define S second
#define pb push_back
#define pl pair<ll, ll>
#define vl vector<ll>
#define vi vector<int>
#define endl '\n'

template <typename T, typename TT>
ostream &operator<<(ostream &os, const pair<T, TT> &t) {
    return os << t.first << " " << t.second;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &t) {
    for (auto &i : t) os << i << " ";
    return os;
}
template <typename T>
istream &operator>>(istream &is, vector<T> &v) {
    for (T &t : v) is >> t;
    return is;
}
template <typename T1, typename T2>
istream &operator>>(istream &is, vector<pair<T1, T2>> &v) {
    for (pair<T1, T2> &t : v) is >> t.first >> t.second;
    return is;
}

const ll mod = 1e9 + 7;

void solve() {
    string s, t;
    cin >> s >> t;
    ll n1 = s.size(), n2 = t.size(), ans = 1e18;
    for(int i = n2 - 1; i < n1; i++) {
        ll c = 0;
        for(int j = 0; j < n2; j++) {
            c += (s[i - n2 + j + 1] != t[j]);
        }
        ans = min(ans, c);
    }
    cout << ans << endl;
}

int main()
{
    fast;
    ll t = 1;
    // cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}


Measured memory_bytes: 3616
/* AtCoder Beginner Contest abc132
 * Problem A
 * Au: SJoshua
 */
#include <cstdio>
#include <vector>
#include <string>
#include <iostream>
#include <algorithm>

using namespace std;

int main(void) {
	vector <char> vec(4);
	for (int i = 0; i < 4; i++) {
		scanf(" %c", &vec[i]);
	}
	sort(vec.begin(), vec.end());
	cout << ((vec[0] == vec[1] && vec[1] != vec[2] && vec[2] == vec[3]) ? "Yes" : "No") << endl;
	return 0;
}



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

int main(){
  int n;
  cin>>n;
  vector<int> d(n);
  for(int i =0; i<n; i++)cin>>d[i];
  sort(d.begin(), d.end());
  d.insert(d.begin(),0);
  int ans=0;
  for(int i=0; i<n; i++){
  if(d[i]==d[i+1])continue;
   ans++ ;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define Nmax 100008
ll n,m,x,y ,k,e,t,r,a,b,nb,q,c,test;
ll tab[Nmax], bi[Nmax]  ;
long double h,l;
string s , s1 ;

int main()
{
    cin>> s ;
    for(int i = 0 ;i<s.size() ; i++) {
        if (i%2==1 && s[i]=='R') return cout << "No",0 ;
        if (i%2==0 && s[i] == 'L') return cout << "No",0 ;
    }
    cout << "Yes" ;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string>
#include <iostream>
#include <iomanip>
#include <map>
#include <algorithm>
#include <vector>
#include <math.h>
#define MOD (long long)1000000007
#define INF (long long)998244353
using namespace std;

int main(void){
    int a,b;
    cin >> a >> b;
    int ans=-1;
    if(a<=9 && b<=9)ans=a*b;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
#define mset(a,b) memset(a,b,sizeof a)
#define mcpy(a,b) memcpy(a,b,sizeof b)
#define swap(a,b) a^=b^=a^=b
#define lb(x) ((x)&(-(x)))
#define dalao 1000000007
#define inf 0x3f3f3f3f
#define N 200010
using namespace std;
typedef long long ll;
int n,m;
set<int> s[N];
int main(){
	cin>>n>>m;
	while(m--){
		int a,b;scanf("%d%d",&a,&b);
		s[a].insert(b),s[b].insert(a);
	}
	for(int i=1;i<=n;i++)if(s[i].count(1)&&s[i].count(n))return puts("POSSIBLE"),0;
	puts("IMPOSSIBLE");
	return 0;
}

Measured memory_bytes: 28416
//C
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>

//C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>

//Others
template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
const int dx[8] = { -1,0,1,-1,1,-1,0,1 };
const int dy[8] = { 1,1,1,0,0,-1,-1,-1 };


//LOVE NyantakoGG	https://www.youtube.com/channel/UC6XdFs8T6Ei54O0FYl3PVVA


using namespace std;



int main() {
	int A, B;
	cin >> A >> B;
	int ans = 0;
	vector<char>data(5);
	for (int i = A; i <= B; i++) {
		for (int j = 0; j < 5; j++) {
			string s = to_string(i);
			data[j] = s[j];
		}
		if (data[0] == data[4] && data[1] == data[3]) {
			ans++;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a[101],b[101];
int suma[101],sumb[101];
int main()
{
    int n;
    while(cin>>n){
        for(int i=0;i<n;i++){
            cin>>a[i];
        }
        for(int i=0;i<n;i++){
            cin>>b[i];
        }
        suma[0]=a[0];sumb[0]=b[0];
        for(int i=1;i<n;i++){
            suma[i]=suma[i-1]+a[i];
            sumb[i]=sumb[i-1]+b[i];
        }
        int maxn=suma[0]+sumb[n-1];
        for(int i=1;i<n;i++){
            int sum=suma[i]+sumb[n-1]-sumb[i-1];
            maxn=max(maxn,sum);
        }
        cout<<maxn<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void) {
   int i;
   int n[5];
   for(i = 0; i < 5; i++) {
      scanf("%d",&n[i]);
   }

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

   return 0;
}

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

const int M = 1e9+7;

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

    int n , m;
    cin >> n >> m;
    string mat[n+1];
    for(int i = 1; i <= n; i++) cin >> mat[i];
    vector<vector<int>> dp(n+1 , vector<int>(m+1 , 0));
    for(int i = 1; i <= n; i++) {
        for(int j = 1; j <= m; j++) {
            if(i == 1 && j == 1) dp[i][j] = 1;
            else if(mat[i][j-1] == '.') {
                dp[i][j] = (dp[i][j] + dp[i-1][j])%M;
                dp[i][j] = (dp[i][j-1] + dp[i][j])%M;
            }
        }
    }
    cout << dp[n][m] << "\n";

    return 0;
}

Measured memory_bytes: 9216
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define PI 3.1415926535
#define MOD 1000000007
 
int main(){
  
  ll X;
  cin >> X;
  
  ll cnt = 0;
  ll bank = 100;
  while(bank < X){
    bank = (ll)(bank / 100.0 * 101);
    cnt++;
  }
  
  cout << cnt << endl;
  return 0;
}


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

int main()
{
    string arr,frr;
    cin>>arr>>frr;
    int mn=1e9;
    for(int i=0;i<arr.size();i++)
    {
        if(i+frr.size()-1<arr.size())
        {
            int cnt=0;
            for(int j=0;j<frr.size();j++)
            {
                if(frr[j]!=arr[i+j])cnt++;
            }
            mn=min(mn,cnt);
        }
    }
    cout<<mn<<endl;
}


Measured memory_bytes: 3608
#include <iostream>
#include <algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<iomanip>
#define sqr(x) (x)*(x)
using namespace std;
int n,m,i,j,a[5][105],dp[5][105];
int main()
{
	cin>>n;
	for (i=1;i<=2;i++)
	{
		for (j=1;j<=n;j++)
		{
			cin>>a[i][j];
		}
	}
	for (i=1;i<=2;i++)
	{
		for (j=1;j<=n;j++) dp[i][j]=max(dp[i-1][j],dp[i][j-1])+a[i][j];
	}
	cout<<dp[2][n];
	return 0;
}

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

typedef vector<int> vi;

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(0);
    int n,a,b;
    vi v;
    while(cin >> n)
    {
        v = vi(n);
        for(int i = 0; i < n; i++)
            cin >> v[i];
        sort(v.rbegin(), v.rend());
        a = b = 0;
        for(int i = 0; i < n; i++)
            if(i % 2 == 0)
                a += v[i];
            else
                b += v[i];
        cout << a-b << '\n';
    }
    return 0;
} 

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {

	var S, T string
	fmt.Scanf("%s", &S)
	fmt.Scanf("%s", &T)

	var count int = 0
	for i := 0; i < 3; i++ {
		if S[i] == T[i] {
			count++
		}
	}

	fmt.Println(count)
}


Measured memory_bytes: 1832
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include <math.h>

using namespace std;

bool is_prime(int u)
{
    if(u == 0 || u == 1) return false;
    if(u == 2) return true;
    if(u%2 == 0) return false;
    for(int i=3; i <= sqrt(u) ;i+=2)
    if(u%i==0) return false;
    return true;
}

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

  for(; ; a++)
  {
    if(is_prime(a))
    {
      cout<<a<<endl;
      return 0;
    }
  }
  return 0;
}


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

void fnInput(string& rsNumStr)
{
  cin >> rsNumStr;
}

int fnMinDiffChk(string sNumStr)
{
  const int cnnNum = 753;
  int nMinDiff = INT_MAX;

  for (int i = 0; i < sNumStr.size() - 2; i++)
  {
    int nNum = (sNumStr[i]     - '0') * 100 +
               (sNumStr[i + 1] - '0') * 10  +
               (sNumStr[i + 2] - '0');         // char → int 変換

    nMinDiff = min(nMinDiff, abs(nNum - cnnNum));
  }
  return nMinDiff;
}

int main()
{
  string sNumStr;

  fnInput(sNumStr);
  cout << fnMinDiffChk(sNumStr) << endl;

  return 0;
}

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

#define x first
#define y second

using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> ii;
typedef pair<ll,ll> pll;

const int mod=1000000000+7;

int addm(int& a,int b) {return (a+=b)<mod?a:a-=mod;}

template<class T,class U> bool smin(T& a,U b) {return a>b?(a=b,1):0;}
template<class T,class U> bool smax(T& a,U b) {return a<b?(a=b,1):0;}

int dp[27][500002];
int step[23][500002];
string s;
int n,q;

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

	cin >> s;
	fill(dp[0],dp[27],s.size()+1);
	n=s.size();

	for (int j=n-1;j>=0;j--) {
		dp[s[j]-'a'][j]=j+1;
		for (int i=s[j]-'a'+1,p=i-1,ct=0;ct<26;ct++) {
			if (i<s[j]-'a') dp[i][j]=dp[i][dp[26][j]];
			else dp[i][j]=dp[p][dp[p][j]];
			p=i++;
			if (i==27) i=0;
		}
	}

	for (int i=0;i<500002;i++) step[0][i]=dp[26][i];
	for (int k=1;k<23;k++) for (int i=0;i<500002;i++) step[k][i]=step[k-1][step[k-1][i]];

	cin >> q;
	while (q--) {
		int l,r;
		cin >> l >> r;l--;
		for (int k=22;k>=0;k--) if (step[k][l]<=r) l=step[k][l];
		if (l==r) cout << "Yes\n";
		else cout << "No\n";
	}

}

Measured memory_bytes: 98972
#include<stdio.h>
#include<stdlib.h>
#define NIL NULL

struct node{
    struct node *right;
    struct node *left;
    struct node *parent;
    int key;
};
typedef struct node * Node;

Node root;

// Node treeMinimum(Node x){ 
//
// }

Node treeSearch(Node u, int k){

    if(u == NIL) return NIL;

    // 見つかった
    if(u->key == k) return u;

    // 右か左か
    if(k < u->key) return treeSearch(u->left, k);
    if(k > u->key) return treeSearch(u->right, k);
}

// Node treeSuccessor(Node x){
//
//
// }
//
// void treeDelete(Node z){
//   Node y; // node to be deleted
//   Node x; // child of y
//
//
//
// }

void insert(int k){
    Node y = NIL;
    Node x = root;
    Node z;

    // node生成
    z = malloc(sizeof(struct node));
    z->key = k;
    z->left = NIL;
    z->right = NIL;

    while (x != NIL) {
        // 下に降りていく
        y = x;
        if(z->key < x->key) x = x->left;
        else x = x->right;
    }

    z->parent = y;

    // 根
    if(y == NIL) root = z;

    // yよりzが小さければ左の子に
    else if(z->key < y->key) y->left = z;

    // yよりzが大きければ右の子に
    else y->right = z;
}

void inorder(Node u){
    if(u->left != NIL) inorder(u->left);
    printf(" %d", u->key);
    if(u->right != NIL) inorder(u->right);
}

void preorder(Node u){
    printf(" %d", u->key);
    if(u->left != NIL) preorder(u->left);
    if(u->right != NIL) preorder(u->right);
}


int main(){
    int n, i, x;
    char com[20];
    scanf("%d", &n);

    for ( i = 0; i < n; i++ ){
        scanf("%s", com);

        // find
         if ( com[0] == 'f' ){
           scanf("%d", &x);
           Node t = treeSearch(root, x);
           if ( t != NIL ) printf("yes\n");
           else printf("no\n");
           } 

        // insert
        else if ( com[0] == 'i' ){
            scanf("%d", &x);
            insert(x);
        } 

        // print
        else if ( com[0] == 'p' ){
            inorder(root);
            printf("\n");
            preorder(root);
            printf("\n");
        } 

        /* else if ( com[0] == 'd' ){
           scanf("%d", &x);
           treeDelete(treeSearch(root, x));
           } */
    }

    return 0;
}

Measured memory_bytes: 19364
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<n;i++)
#define why(n,x) int n;while(cin >>n,n!=x)
#define iFOR(i,x,n)for(int i=x;i<n;i++)
#define fin <<'\n'
#define __ <<" "<<
#define ___ <<" "
#define bash push_back
#define ALL(x) x.begin(),x.end()
#define SWAP(a,b) ((a != b) && (a += b,b = a - b,a -= b))
//#define int long long
typedef long long ll;
typedef pair < int , int >  pii;
typedef vector < int > vit;
typedef map < string , int > mstit;
typedef vector < pii > vpi ;
typedef greater < pii > gpi;
typedef priority_queue < pii , vpi , gpi > dijk ;
static const signed int INF = 0x3f3f3f3f;
static const signed long long LINF = 0x3f3f3f3f3f3f3f3fLL;
static const signed int SMOD = 1000000007;
static const signed int NMOD = 1000000009;
static const signed int dx[]={1,0,-1,0,1,1,-1,-1};
static const signed int dy[]={0,-1,0,1,-1,1,-1,1};

bool inside(int x,int y,int w,int h){return (x>=0 && y>=0 && x<w && y<h);}
template<class T>T abs(T &x){return x<0 ? -x : x;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}


inline void solve(){
    int h, w;
    cin >> h >> w;
    vector<string> mas(h);
    for(int i = 0; i < h;i++){
        cin >> mas[i];
    }
    int m[1005][1005]={};
    memset(m,-1,sizeof(m));
    queue<pii> que;
    for(int i = 0; i < h; i++){
        for(int j  =0; j < w; j++)
            if(mas[i][j]=='#'){
                m[i][j] = 0;
                que.push(pii(i,j));
            }
    }

    while(!que.empty()){
        int y = que.front().first;
        int x = que.front().second;
        que.pop();
        for(int i = 0; i < 4; i++){
            int ny = y + dy[i];
            int nx = x + dx[i];
            if(inside(nx,ny,w,h) && m[ny][nx] == -1){
                que.push(pii(ny,nx));
                m[ny][nx] = m[y][x] + 1;
            }
        }
        
    }
    int maxi = -INF;
    for(int i = 0; i < h; i++){
        for(int j = 0;j < w; j++){
    
            chmax(maxi,m[i][j]);
        }
        
    }

    cout << maxi << endl;
    
}
struct xyz{ xyz(){ cin.tie(0), ios::sync_with_stdio(false); cout <<fixed<<setprecision(12);};}xyzzy;signed main(){solve();return 0;}


Measured memory_bytes: 13456
import java.util.Scanner;

 class Main {
	@SuppressWarnings("resource")
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int x;
		int y;
		
		while(true){
			x = scan.nextInt();
			y = scan.nextInt();
			if(x == 0 && y == 0)break;
			if(x > y){
				System.out.println(y + " " + x);
			}
			else if(x < y){
				System.out.println(x + " " + y);
			}
			if(x == y ){
				System.out.println(x + " " + y);
			}
		}
	}	
}

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

const int MAXN = 405;
const int MX = 400;
const int mod = 1e9 + 7;

int N, C;
int A[MAXN], B[MAXN];
int Pow[MAXN][MAXN];
int f[MAXN][MAXN];

int main() {
	cin >> N >> C;
	for (int i = 1; i <= N; ++i) cin >> A[i];
	for (int i = 1; i <= N; ++i) cin >> B[i];
	for (int i = 1; i <= MX; ++i) Pow[i][0] = i;
	for (int i = 1; i <= MX; ++i) {
		for (int j = 1; j <= MX; ++j)
			Pow[j][i] = (Pow[j - 1][i] + 1LL * (Pow[j][i - 1] - Pow[j - 1][i - 1] + mod) * j) % mod;
	}
	f[0][0] = 1;
	for (int i = 1; i <= N; ++i) {
		for (int j = 0; j <= C; ++j) {
			for (int k = 0; k <= j; ++k) f[i][j] = (f[i][j] + 1LL * f[i - 1][j - k] * (Pow[B[i]][k] - Pow[A[i] - 1][k] + mod)) % mod;
		}
	}
	cout << f[N][C] << endl;
}

Measured memory_bytes: 1536
// C++ 14
#include <bits/stdc++.h>
using namespace std;
template <typename T>  ostream& operator<<(ostream& os, const vector<T>& v)  {  os << "[";  for (int i = 0; i < v.size(); ++i) {  os << v[i];  if (i != v.size() - 1)  os << ", ";  }  os << "]";  return os;  }
template <typename T> void print(T v, string s = "\n") { cout << v << s; }
template <typename T> void in(T& v) { cin >> v; }
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)

int main() {
  int n, K;in(n),in(K);
  vector<ll> X(n),Y(n);
  loop(i,0,n) in(X[i]),in(Y[i]);
  loop(i,0,n-1) loop(j,i+1,n) {
    X.push_back(X[i]);
    Y.push_back(Y[j]);
    X.push_back(X[j]);
    Y.push_back(Y[i]);
  }
  int m = X.size();
  
  ll ans = 9000000000000000000;
  loop(i,0,m-1) loop(j,i+1,m) {
    ll x1 = X[i], x2 = X[j], y1 = Y[i], y2 = Y[j];
    if (x1 == x2 or y1 == y2) continue;
    if (x1 > x2) swap(x1, x2);
    if (y1 > y2) swap(y1, y2);
    int cnt = 0;
    loop(k,0,n) {
      cnt += x1 <= X[k] and X[k] <= x2 and y1 <= Y[k] and Y[k] <= y2;
    }
    
    if (cnt >= K) {
      ans = min(ans, (x2-x1)*(y2-y1));
    }
  }
  print(ans);
  return 0;
}


Measured memory_bytes: 3656
n=int(input())
l=[list(map(int,input().split())) for _ in range(n)]
a=[]
for x in range(101):
  for y in range(101):
    c=[]
    for t in l:
      if t[2]:
        c.append(t[2]+abs(x-t[0])+abs(y-t[1]))
    f=0
    if len(set(c))==1:
      f=1
      h=c[0]
      for t in l:
        if t[2]==0:
          if h-abs(x-t[0])-abs(y-t[1])>0:
            f=0
    if f:
      print(x,y,h)
      exit()

Measured memory_bytes: 3064
//I am so vegetable
//#define err
#pragma GCC optimize(2)
#include <bits/stdc++.h>
#define FIO ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define PB push_back
#define IN insert
#define ER erase
#define CT count
#define EP empty
#define _for(i,a,b) for(int i = (a);i<(b);++i)
#define _rfor(i,a,b) for(int i = (a);i>(b);--i)
#define _sfor(p,st) for(auto &p:st)
using namespace std;
typedef long long ll;
const int INF = 0x3f3f3f3f;
const int MOD = 1e9+7;
const double eps = 1e-6;
const double pi = acos(-1.0);
int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }
ll qpow(ll x, ll y) { ll ans = 1; for (; y > 0; y >>= 1) { if (y & 1)ans *= x; x *= x; }return ans; }
ll qpow(ll x, ll y, int MOD) { ll ans = 1; for (; y > 0; y >>= 1) { if (y & 1)ans = ans*x%MOD; x = x*x%MOD; }return ans; }
void exgcd(ll a,ll b,ll &x,ll &y){
    if(!b){x=1;y=0;return;}
    exgcd(b,a%b,x,y);
    ll X=x;
    x=y; y=X-a/b*y;
}
ll inv(ll x, int mod = MOD) { return qpow(x, mod - 2) % mod; }
ll m_m(ll a){ return (a%MOD+MOD)%MOD; }


int main() {
	//ofstream cout("E:\\acm dream\\out.txt",ios::out);
	FIO;
    #ifdef err
	double be = clock();
    #endif
    int a,b,c,d,k;cin>>a>>b>>c>>d>>k;
    b+=a*60,d+=c*60;
    cout<<d-b-k;
    #ifdef err
	double en = clock();
    cout<<"time: "<<fixed<<setprecision(8)<<en-be;
    #endif
	return 0;
}

Measured memory_bytes: 3668
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll inf = 1e18;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define per(i, a, b) for (int i = b - 1; i >= a; i--)
#define int ll
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

signed main() {
    string s, t;
    cin >> s >> t;
    cout << t << s << "\n";
}

Measured memory_bytes: 3556
from itertools import combinations
import math

n, d = map(int, input().split())
xs = []
for i in range(n):
    xs.append(list(map(int, input().split())))

seq = combinations(xs, 2)
count = 0
for xs in seq:
    sum = 0
    for a, b in zip(xs[0], xs[1]):
        sum += abs(a - b)**2

    sum2 = int(math.sqrt(sum))**2
    if sum == sum2:
        count += 1

print(count)



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

int main() {
  int N;
  cin >> N;
  string color;
  int flag = 0;
  for(int i=0; i<N; i++){
    cin >> color;
    if(color == "Y"){
      flag=1;
      break;
    }
  }
  if(flag == 1) cout << "Four" << endl;
  else cout << "Three" << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+5;
set<int>s[N];
map<pair<int,int>,int> ma;
pair<int,int> q[N];
int n,h,t,fa[N];
int get(int x){
	if(fa[x]==x) return x;
	return fa[x]=get(fa[x]);
}
int main(){
	//freopen("B.in","r",stdin);
	//freopen("B.out","w",stdout);
    scanf("%d",&n);
    for (int i=1;i<=n*2-2;i++){
        int u,v;
        scanf("%d%d",&u,&v);
        s[u].insert(v); s[v].insert(u);
        ma[make_pair(u,v)]++; ma[make_pair(v,u)]++;
        if (ma[make_pair(u,v)]==2) q[++t]=make_pair(u,v);
    }
    for (int i=1;i<=n;i++) fa[i]=i;
    set<int>::iterator it;
    while (h<t){
        int u=q[++h].first,v=q[h].second;
        u=get(u); v=get(v);
        s[u].erase(v); s[v].erase(u);
        if (s[u].size()<s[v].size()) swap(u,v);
        for (it=s[v].begin();it!=s[v].end();++it){
            int to=(*it);
            ma[make_pair(to,v)]=ma[make_pair(v,to)]=0;
            s[to].erase(v); s[to].insert(u);
            ma[make_pair(to,u)]++; ma[make_pair(u,to)]++; 
            if (ma[make_pair(to,u)]==2) q[++t]=make_pair(to,u);
            s[u].insert(to);
        }
        fa[v]=u;
        s[v].clear();
    }
    int s=0;
    for (int i=1;i<=n;i++) s+=fa[i]==i;
    if (s==1) printf("YES\n"); else printf("NO\n");
    return 0;
}

Measured memory_bytes: 56576
import java.io.*;
import java.util.*;

public class Main {
  private static void execute(ContestReader reader, PrintWriter out) {
    out.println(6 - reader.nextInt() - reader.nextInt());
  }
  
  public static void main(String[] args) {
    ContestReader reader = new ContestReader(System.in);
    PrintWriter out = new PrintWriter(System.out);
    execute(reader, out);
    out.flush();
  }
}

class ContestReader {
  private BufferedReader reader;
  private StringTokenizer tokenizer;
  
  ContestReader(InputStream in) {
    reader = new BufferedReader(new InputStreamReader(in));
  }
  
  public String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }
  
  public int nextInt() {
    return Integer.parseInt(next());
  }
  
  public long nextLong() {
    return Long.parseLong(next());
  }
  
  public double nextDouble() {
    return Double.parseDouble(next());
  }
  
  public String[] next(int n) {
    String[] array = new String[n];
    for (int i = 0; i < n; i++) {
      array[i] = next();
    }
    return array;
  }
  
  public int[] nextInt(int n) {
    int[] array = new int[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextInt();
    }
    return array;
  }
  
  public long[] nextLong(int n) {
    long[] array = new long[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextLong();
    }
    return array;
  }
  
  public double[] nextDouble(int n) {
    double[] array = new double[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextDouble();
    }
    return array;
  }
  
  public char[] nextCharArray() {
    return next().toCharArray();
  }
  
  public int[][] nextInt(int n, int m) {
    int[][] matrix = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextInt();
      }
    }
    return matrix;
  }
  
  public long[][] nextLong(int n, int m) {
    long[][] matrix = new long[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextLong();
      }
    }
    return matrix;
  }
  
  public double[][] nextDouble(int n, int m) {
    double[][] matrix = new double[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextDouble();
      }
    }
    return matrix;
  }
  
  public char[][] nextCharArray(int n) {
    char[][] matrix = new char[n][];
    for (int i = 0; i < n; i++) {
      matrix[i] = next().toCharArray();
    }
    return matrix;
  }
}


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

#ifndef DEBUG
#define DEBUG false
#endif

#define REP(t,i,a,b) for(t i = a; i < b; ++i)

typedef long long ll;

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

    std::string s, t;
    std::cin >> s >> t;

    int count=0;
    REP(int, i, 0, 3) {
       if(s[i] == t[i]) count++;
    }

    std::cout << count << std::endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;
#define N 10000000
#define p 1000000007
int a[N+5];
int main()
{
    a[1]=0;
    int n;

    for(int i=1; i<=N; i++)
        for(int j=1; j<=N/i; j++)
        {
            a[j*i]++;
        }
    long long ans=0; cin>>n;
    for(int i=1;i<=n;i++)
        ans=((long long)a[i]*i+ans);
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 42680
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=5e18;

int main() {
  string s;
  cin >> s;
  ll n=s.size();
  ll ans=1;
  ll size=1;
  for(ll i=1;i<n;i++) {
    if(size==1) {
      if(s[i]==s[i-1]) {
        if(i==n-1) {
          break;
        }
        size=2;
        i++;
        ans++;
      }
      else {
        ans++;
      }
    }
    else {
      ans++;
      size=1;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define __ <<" "<<
#define ___ <<" "
#define bash push_back
#define ALL(x) x.begin(),x.end()
//#define int long long

struct IoSetup {
    IoSetup() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout <<fixed<<setprecision(12);
        cerr <<fixed<<setprecision(12);
    }
}IoSetup;

typedef long long ll;
typedef pair < int , int >  pii;
static constexpr const signed int INF = 0x3f3f3f3f;
static constexpr const signed long long LINF = 0x3f3f3f3f3f3f3f3fLL;
static constexpr const signed int SMOD = 1000000007;
static constexpr const signed int NMOD = 998244353;
static constexpr const signed int dx[]={1,0,-1,0,1,1,-1,-1};
static constexpr const signed int dy[]={0,-1,0,1,-1,1,-1,1};

inline bool inside(int x,int y,int w,int h){return (x>=0 && y>=0 && x<w && y<h);}
template<class T>bool chmax(T &a, const T &b){return(a=max(a,b))==b;}
template<class T>bool chmin(T &a, const T &b){return(a=min(a,b))==b;}
inline int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}



signed main() {

    int n, m, x;
    cin >> n >> m >> x;
    int r[111], tmp;
    int s = 0, t = 0;
    for(int i = 0; i < m; i++) {
        cin >> tmp;
        if(tmp < x) s++;
        else t++;
    }

    cout << min(s, t) << endl;


  
    return 0;
}



Measured memory_bytes: 256