akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pp;
const int INF = 1e9;
const int MOD = 1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
 
struct Unionfind{
  vector<int> parents;
  int m;
  Unionfind(int n):parents(n,-1){
    m = n;
  }

  int find(int x){
    if(parents.at(x) < 0){
      return x;
    }else{
      parents.at(x) = find(parents.at(x));
      return parents.at(x);
    }
  }

  void unite(int x,int y){
    x = find(x);
    y = find(y);

    if(x==y) return;
    if(parents.at(x) > parents.at(x))swap(x,y);
    parents.at(x) += parents.at(y);
    parents.at(y) = x;
  }

  int size(int x){
    return -parents.at(find(x));
  }

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

  vector<int> members(int x){
    int root = find(x);
    vector<int> A;
    for(int i=0;i<m;i++){
      if(find(i) ==root ){
        A.push_back(i);
      }
    }
    return A;
  }
};

int main(){
  int n,m;
  cin >> n >> m;
  int ans = n-m;
  Unionfind uf(n);
  rep(i,m){
    int a,b,c;
    cin >> a >> b >> c;
    --a; --b;
    if(uf.same(a,b)) ans ++;
    uf.unite(a,b);
  }
  cout << ans << endl;
  
  return 0;
}

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

namespace B_012_49
{
    internal class Program
    {
        private static void Main(string[] args)
        {
            new Logic_A().Start();

        }

        public class Logic_A
        {
            public void Start()
            {
                var str = Console.ReadLine();

                Console.WriteLine("aeiou".Contains(str) ? "vowel" : "consonant");
            }
        }
    }
}

Measured memory_bytes: 13140
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.TreeMap;

public class Main {
	public static void main(String args[]) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String str[] = br.readLine().split(" ");

		long n = Long.parseLong(str[0]);
		long k = Long.parseLong(str[1]);

		TreeMap<Long, Long> map = new TreeMap<>();

		for (long i = 0; i < n; i++) {
			str = br.readLine().split(" ");

			long a = Long.parseLong(str[0]);
			long b = Long.parseLong(str[1]);

			if (map.containsKey(a)) {
				map.put(a, map.get(a) + b);
			} else {
				map.put(a, b);
			}
		}

		long count = 0;
		for (long key : map.keySet()) {
			count += map.get(key);
			if (count >= k) {
				System.out.println(key);
				return;
			}
		}
	}

}


Measured memory_bytes: 47080
//BISMILLAHIR RAHMANIR RAHIM
//RHYTHM_086_NS_01
//ALAN_IS_ON....

#include <bits/stdc++.h>

#define                boost_                         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define                iter_(i,n)                     for (int i = 0; i < int(n); i++)
#define                for_n(i, n)                    for (int i = 1; i <= int(n); i++)
#define                pb                             push_back
#define                mp                             make_pair
#define                itr                            ::iterator
#define                s_sort(s)                      sort(s.begin(),s.end())
#define                n_sort(a)                      sort(a,a+n)
#define                thank_you                      return 0
#define                precise_impact                 cout<<setprecision(10)<<fixed;

using namespace std;

typedef long long int ll;
typedef double db;
#define MOD 1000000007

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

}
void solve();


int main()
{
    boost_;
    precise_impact;
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    //Here we go...
    solve();

    thank_you;
}


void solve()
{
    int n;
    cin>>n;
    int a[n],count=0;
    iter_(i,n){
        cin>>a[i];
        if(a[i]%2==1&&(i+1)%2==1)
            count++;
    }
    cout<<count<<endl;

}



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

using namespace std;
 
typedef long long ll;
const ll MOD = 1e9+7;
const ll INF = 1e18;


#define PB push_back
#define MP make_pair
#define F first
#define S second

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

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

map<ll,ll> prime_factor(ll n){ //素因数分解
	map<ll,ll> ret;
	for(ll i=2;i*i<=n;i++){
		while(n%i==0){
			ret[i]++;
			n /=i;
		}
	}
	if(n!=1) ret[n] =1;
	return ret;
} 

int main(){
  	ll n,ans=0;
    cin >> n;
    vector<ll> a,b;
    for(ll i=1;i<=n;i++){
        ll tmp;
        cin >> tmp;
        a.PB(i+tmp);
        b.PB(i-tmp);
    }
    sort(a.begin(),a.end());
    sort(b.begin(),b.end());

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

        ans += distance(b.begin(),upper_bound(b.begin(),b.end(),a[i])) - distance(b.begin(),lower_bound(b.begin(),b.end(),a[i]) );
    }
    cout << ans<<endl;;
    return 0;

}


Measured memory_bytes: 6652
#include <iostream>
#include <string>

using namespace std;

int main()
{
    string s;
    int64_t k;
    int i;

    cin >> s;
    cin >> k;

    for (i = 0; i < k; i++)
    {
        if(s[i] != '1') {
            cout << s[i] << endl;
            return 0;
        }
    }

    cout << 1 << endl;

    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S;
    cin >> S;
    int W = 0;
    int move = 0;
    rep(i, S.size()) {
        if (S[i] == 'W') {
            W++;
            move += i;
        }
    }
    cout << move - (W * (W - 1) / 2) << endl;

    return 0;
}


Measured memory_bytes: 720
#include <bits/stdc++.h>
#include <random>
#include <time.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep1(i,n) for (int i = 1; i <= (n); ++i)

using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using ull= unsigned long long;
const ll K_MAX=1e5+5;
const ll Lmax=ll(1e18);
const int Nmax=2e5+1;
const int Nd=61;
const int INF=1e5;


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

  if(x==0){
    cout<<1;
  }else{
    cout<<0;
  }

}


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

dx = x2 -x1
dy = y2 -y1

x3 = x2 -dy
y3 = y2 +dx
x4 = x3 -dx
y4 = y3 -dy

print(x3, y3, x4, y4)

Measured memory_bytes: 3060
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N;
    bool a = true;
    cin >> N;
    vector<int> A(N);
    for(int i = 0;i <N ;i++){
        cin >> A.at(i);
    }
    for(int i = 0;i <N ;i++){
        if(A.at(i)%2 == 0){
        if(A.at(i)%3 != 0 && A.at(i)%5 != 0){
            a = false;
            break;
        }
        }
    }
    if(a){
    cout << "APPROVED" << endl;}
    else{
    cout << "DENIED" << endl;}
}

Measured memory_bytes: 256
<?php
// Your code here!
$times = fgets(STDIN);
$nums = explode(" ",trim(fgets(STDIN)));

$ans = 1;
foreach ($nums as $num) {
    $ans *= $num;
}
if($ans > 10 ** 18){
    $ans = -1;
}
echo (int)$ans;
?>

Measured memory_bytes: 25404
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define inf 0x3f3f3f3f
using namespace std;

const int maxn = 100050;

int main(){
    string s;
    cin>>s;
    map<int,int>st;
    for(int i=0;i<s.size();i++){
        st[s[i]]++;
    }
    if(st.size()==2&&(*st.begin()).second==2)puts("Yes");
    else puts("No");
}


Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;

int main() {
    int n;
    cin >> n;
    vi l(n);
    rep(i, n) {
        cin >> l[i];
    }

    vi aa;
    rep(i, n) {
        rep(j, i) {
            aa.push_back(l[i]+l[j]);
        }
    }
    sort(all(aa));

    ll ans = 0;
    rep(i, n) {
        vi::iterator itr = upper_bound(all(aa), l[i]);
        ans += itr - aa.begin();
    }

    cout << (ll)n*(n-1)*(n-2)/6 - ans << endl;
}

Measured memory_bytes: 10608
building = [[[0 for _ in range(10)] for _ in range(3)] for _ in range(4)]
n = int(input())

for _ in range(n):
    b, f, r, v = map(int, input().split())
    building[b-1][f-1][r-1] += v

for i in range(4):
    for j in range(3):
        print(' ' + ' '.join(map(str, building[i][j])))
    if i != 3:
        print('#' * 20)


Measured memory_bytes: 5604
using System;
using System.Linq;

namespace Tenka_B
{
    class Program
    {
        static void Main(string[] args)
        {
            var ABK = Console.ReadLine().Split().Select(long.Parse).ToArray();
            var A = ABK[0];
            var B = ABK[1];
            var K = ABK[2];

            var cnt = 0;
            while (cnt != K)
            {
                cnt++;
                if (cnt % 2 == 1)
                {
                    if (A % 2 == 1) A--;
                    B += A / 2;
                    A /= 2;
                }
                else
                {
                    if (B % 2 == 1) B--;
                    A += B / 2;
                    B /= 2;
                }
            }
            Console.WriteLine(A + " " + B);
        }
    }
}


Measured memory_bytes: 13396
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define sp(n) cout << fixed << setprecision(n)
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; }
typedef long long ll;
using namespace std;
int main(void){
    int n;cin>>n;
    string s;cin>>s;
    vector<int> w(n,0),e(n,0);
    rep(i,n){
        if(s[i]=='W')w[i]++;
    }
    reverse(s.begin(),s.end());
    rep(i,n){
        if(s[i]=='E')e[i]++;
    }
    rep(i,n-1){
        w[i+1]+=w[i];
        e[i+1]+=e[i];
    }
    reverse(e.begin(),e.end());
    ll res=1e9;
    rep(i,n){
        ll buf=e[i]+w[i];
        chmin(res,buf);
    }
    cout<<res-1<<endl;
}


Measured memory_bytes: 6064
# coding: utf-8


def solve(*args: str) -> str:
    n, k, s = map(int, args[0].split())

    A = [0]*n
    m = n-k+1
    if 0 < s//m:
        for i in range(n):
            A[i] = s//m
            if i % m == 0:
                A[i] += s % m
    else:
        for i in range(n):
            if i < k:
                A[i] = s
            else:
                A[i] = 10**9

    return ' '.join(map(str, A))


if __name__ == "__main__":
    print(solve(*(open(0).read().splitlines())))


Measured memory_bytes: 15300
import bisect,collections,copy,itertools,math,string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())

n,q = LI()
root = [[] for _ in range(n+1)]
quest = [0 for _ in range(n+1)]

for _ in range(n-1):
    a,b = LI()
    root[a].append(b)
    root[b].append(a)

for _ in range(q):
    p,x = LI()
    quest[p] += x

stock = collections.deque([1])
explored = set()

while len(stock) != 0:
    next = stock.pop()
    explored.add(next)
    for i in root[next]:
        if i not in explored:
            stock.append(i)
            quest[i] += quest[next]
print(*quest[1:])


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

using ll = long long;
using pii = pair<ll, ll>;
using vi = vector<ll>;
using vvi = vector<vi>;

template <class T>
using max_heap = priority_queue<T>;
template <class T>
using min_heap = priority_queue<T, vector<T>, greater<T>>;

template <class T, class U>
void chmax(T &a, U b) {
    if (a < b) a = b;
}
template <class T, class U>
void chmin(T &a, U b) {
    if (b < a) a = b;
}

#define rep(i, j) for (int i = 0; i < j; i++)
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
#define debug(x) cerr << #x << ": " << x << endl;
#define int ll

const ll mod = 1e9 + 7;
const ll inf = (1LL << 50);

int N, ans;
int taken[100];
vector<long long> D;

void dfs(int v) {
    // debug(v);
    // debug(D[v]);
    if (v == N) {
        int last = 0;
        int x = 24;
        for (int i = 1; i < 24; i++) {
            if (taken[i] > 0) {
                chmin(x, i - last);
                last = i;
            }
        }
        chmin(x, 24 - last);
        chmax(ans, x);
        return;
    }
    if (!taken[D[v]]) {
        taken[D[v]]++;
        dfs(v + 1);
        taken[D[v]]--;
    }
    int other = (24 - D[v]) % 24;
    if (other != D[v] and !taken[other]) {
        taken[other]++;
        dfs(v + 1);
        taken[other]--;
    }
}

void solve() {
    if (N > 24) {
        cout << 0 << endl;
        return;
    }
    rep(i, 100) taken[i] = 0;
    taken[0] = 1;
    ans = 0;
    dfs(0);
    cout << ans << endl;
    return;
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout << fixed;
    scanf("%lld", &N);
    D = std::vector<long long>(N);
    for (int i = 0; i < N; i++) {
        scanf("%lld", &D[i]);
    }
    solve();
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include <iostream>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<complex>
#include <cstring>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<numeric>
#include<limits>
#include<climits>
#include<cfloat>
#include<functional>
#include<iterator>
#include <random>
#define inf  1000000000
#define mod  1073741824
#pragma GCC optimization ("O3")
using namespace std;
const int N = 100*1000+5;
#define all(x) begin(x),end(x)
int main()
{
   
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    //ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    long long int n,a,b,c=0,m =1e18;
    cin >> n >> a;
    vector<long long int> v(a);
    for (int i = 0; i < a; ++i)
    {
        cin >> v[i];
    }   
    sort(v.begin(),v.end());
    reverse(v.begin(),v.end());
    for (int i = 0; i < a; ++i)
    {
        c += v[i];
       if (c >= n)
       {
         cout <<"Yes\n";
         return 0;
       }
    }
    cout << "No\n";
    return 0;
}


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

int main(){
  int N, M;
  cin >> N >> M;
  vector<tuple<int, int, int>> T(M);
  int P, Y;
  for(int i=0; i<M; i++){
    cin >> P >> Y;
    T.at(i)=make_tuple(P, Y, i);
  }
  sort(T.begin(), T.end());
  int Now=1;
  for(int i=0; i<M; i++){
    if(i==0){
    }
    else if(get<0>(T.at(i))!=get<0>(T.at(i-1))){
      Now=1;
    }
    else{
      Now++;
    }
    get<1>(T.at(i))=Now;
  }   
  vector<pair<int, int>> K(M);
  for(int i=0; i<M; i++){
    K.at(get<2>(T.at(i)))=make_pair(get<0>(T.at(i)), get<1>(T.at(i)));
  }
  for(int i=0; i<M; i++){
    cout << setfill('0') << right << setw(6) << K.at(i).first;
    cout << setfill('0') << right << setw(6) << K.at(i).second << endl;
  }
}

Measured memory_bytes: 3456
N,K = list(map(int, input().split()))
A = list(map(int, input().split()))
 
B = [1]
go = [0]*N
hop = 0
ans = 0
for n in range(N):
    nc = A[B[n]-1]
    if go[nc-1] == 1:
        idx = B.index(nc)
        loop = B[idx:]
        break
    B.append(nc)
    K -= 1
    go[nc-1] = 1
    ans = nc
    if K < 1:
        break
 
if K > 0:
    L = len(loop)
    K = K % L
    K -= 1
    ans = loop[K]
print(ans)

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

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

const double PI = acos(-1);
#define MOD 1000000007

#define pb push_back
#define F first
#define S second
#define test int tc; cin>>tc; while(tc--)
#define forn(i,n) for(i=0;i<n;i++)
#define rforn(i,n) for(i=n-1;i>=0;i--)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define sz(x) x.size()
#define el <<'\n'
#define sp <<' '

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

#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);

int main()
{
    ///optimize();
    double r;
    while(cin>>r){
        cout<<fixed<<setprecision(12)<<2*r*PI el;
    }




return 0;

}





///Brainless people are gonna understand this code.




///Brainless_Loco Terminates Here!


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

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            Console.WriteLine(n * n * n);
        }

        public static int[] ReadIntArray()
        {
            return Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
        }

        public static int ReadInt()
        {
            return int.Parse(Console.ReadLine());
        }
    }
}


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

int main () {
    int A, B, C, D;

    cin >> A >> B >> C >> D;

    if (A + B > C + D)
        cout << "Left" << endl;
    else if (A + B == C + D)
        cout << "Balanced" << endl;
    else 
        cout << "Right" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <math.h>
#include <cmath>
#include <limits.h>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <functional>
#include <stdio.h>
using namespace std;

long long MOD = 1000000007;

int main() {
    
    int N,A;
    cin >> N >> A;
    
    cout << N*N - A << endl;
    
    return 0;
}

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

using namespace std;

int main( ){
  int i,j,k,n;
  cin>>n;
  if(n%1000){
    k=n/1000+1;
  }
  else{
    k=n/1000;
  }
  cout<<k*1000-n<<endl;
  return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v).begin(), (v).end()
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define DEBUG
#define int long long
#define INF 1e18
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; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<"\n";}
typedef long long ll;

signed main()
{
    vector<int>a(4);
    REP(i,4) cin>>a[i];
    sort(ALL(a));
    cout<<abs(a[0]+a[3] - (a[1]+a[2]))<<endl;

    
    return 0;
}


Measured memory_bytes: 3172
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

typedef long long lint;

using namespace std;

int main(){
  int N,M;
  cin>>N>>M;
  REP(i,M){
    int l=((i%2==0?0:N/2)-i/2+N)%N;
    int r=(l+i+1)%N;
    cout<<l+1<<" "<<r+1<<endl;
  }
  return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define db(x) cerr << __LINE__ << ": " << #x << " = " << (x) << endl
#define ll long long
#define ld long double
#define pll pair<ll, ll>
#define MOD 1000000007
using namespace std;
const long long INF = 3*1e18;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    ll N, M;
    cin >> N >> M;
    ll ans = ((N * (N - 1)) + (M * (M - 1))) / 2;
    cout << ans << "\n";
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

typedef struct rope{
	long long int len;
	int connect;
}rope;

int main(){
	int i,key = 0;
	int n;
	long long int l;
	rope *a;
	int *res;
	int res_length = 0;
	scanf("%d %lld",&n,&l);
	a = calloc(sizeof(rope),n+1);
	res = calloc(sizeof(rope),n);

	for(i = 1;i <= n;i++){
		scanf("%lld",&(a[i].len));
		a[i].connect = 1;
	}
	for(i = 1;i < n;i++){
		if(a[i].len + a[i+1].len >= l){
			key = i;
			break;
		}
	}
	if(!key){
		printf("Impossible\n");
		return 0;
	}else{
		printf("Possible\n");
	}
	for(i = 1;i < key;i++){
		res[res_length++] = i;
	}
	for(i = n-1;i > key;i--){
		res[res_length++] = i;
	}
	res[res_length++] = key;
	for(i = 0;i < res_length;i++){
		printf("%d\n", res[i]);
	}


	return 0;
}

Measured memory_bytes: 2816
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using mti = vector<vector<int>>;
using vl = vector<ll>;
using mtl = vector<vector<ll>>;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (int i = j; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define n_p(v) next_permutation(v.begin(),v.end())
#define print(a) cout<<(a)<<endl;
#define to_ll(b) stoll(b)
#define MOD 1000000007

int main(){
	string S,T; cin>>S>>T;
	rep(i,0,S.size()){
		if(S[i]!=T[i]){
			cout<<"No";
			return 0;
		}
	}
	cout<<"Yes";
	return 0;
	
	
}

Measured memory_bytes: 3620
#include <stdio.h>

int main(void)
{
	double m, n;

	while (scanf("%lf %lf", &m, &n) != EOF)
	{
		if (m < 35.5 && n < 71)
			printf("AAA\n");
		else if (m < 37.5 && n < 77)
			printf("AA\n");
		else if (m < 40 && n < 83)
			printf("A\n");
		else if (m < 43 && n < 89)
			printf("B\n");
		else if (m < 50 && n < 105)
			printf("C\n");
		else if (m < 55 && n < 116)
			printf("D\n");
		else if (m < 70 && n < 148)
			printf("E\n");
		else
			printf("NA\n");
	}

	return 0;
}

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

#define F first
#define S second
#define llong long long
#define ullong unsigned long long
#define mp make_pair
#define pb push_back
#define sz(v) (int)v.size()

using namespace std;

const int MXN = (int)1e6 + 10;
const int INF = (int)1e9 + 7;
const llong LINF = (llong)1e18 + 10;
const double EPS = (double)1e-9;
const double PI = (double)acos(-1.0);

bool b1[MXN], b2[MXN];
int n, m;

int main(){
	#ifdef LOCAL
		freopen("input.txt", "r", stdin);
	#endif
	scanf("%d%d", &n, &m);
  for(int i = 1; i <= m; ++i){
  	int u, v;
  	scanf("%d%d", &u, &v);
  	if(u > v)
  		swap(u, v);
  	if(u == 1)
  		b1[v] = true;
  	if(v == n)
  		b2[u] = true;	
  }
  for(int i = 2; i < n; ++i){
  	if(b1[i] == b2[i] && b1[i] == true){
  		printf("POSSIBLE");
  		return 0;
  	}
  }
  printf("IMPOSSIBLE");
  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
using ll=long long;
int main(){
    int n;
    cin>>n;
    vector<int>p(n),q(n);
    rep(i,n)cin>>p[i];
    rep(i,n)cin>>q[i];
    vector<int>a(n);
    rep(i,n)a[i]=i+1;
    map<vector<int>,int>mp;
    do{
        mp[a]=mp.size();
    }while(next_permutation(a.begin(),a.end()));
    int ans=abs(mp[p]-mp[q]);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 5248
import java.util.Scanner;
 
public class Main {
 
    public static void main(String[] args) {
 
        Scanner in = new Scanner(System.in);
 
        int A = in.nextInt();
        int B = in.nextInt();
 
        printOutcome(A, B);
    }
 
    private static void printOutcome(int A, int B) {
 
 
        String outcome = ((A * B) % 2 == 0) ? "No" : "Yes";
 
        System.out.println(outcome);
 
    }
}

Measured memory_bytes: 23636
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ii = pair<ll, ll>;
using iii = pair<ll, ii>;
#define vt vector
#define pq priority_queue
#define pb push_back
#define mp make_pair
#define fi first
#define se second
// #define multicase
const ll MOD = 1e9 + 7;
const ll INF = 2e9;
const ll N = 2e3 + 5;

ll n;
ll dp[N];

ll add(ll x, ll y) {
    return ((x % MOD) + (y % MOD)) % MOD;
}

void computeDP() {
    dp[0] = 1;
    for(ll i = 1; i <= n; i++) {
        ll &sol = dp[i];
        for(ll j = 3; j <= i; j++) {
            sol = add(sol, dp[i - j]);
        }
    }
}

void solve() {
    ll T = 1;
  #ifdef multicase
    cin >> T;
  #endif
    while(T--) {
        cin >> n;
        computeDP();
        cout << dp[n] << "\n";
    }
}

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


Measured memory_bytes: 3616
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

  public static void main(String[] args) throws IOException {
    
    try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {

      int n = Integer.parseInt(br.readLine());
      int minv = Integer.parseInt(br.readLine());
      int n1   = Integer.parseInt(br.readLine());
      int maxv = n1- minv;
      if ( n1 < minv ) minv = n1;

      for( int i=2,r,mv; i<n; i++) {
        r = Integer.parseInt(br.readLine());
        if ( r < minv ) minv = r;
        else if ( (mv = r-minv) > maxv ) maxv = mv;
      }

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


Measured memory_bytes: 42676
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.PriorityQueue;

public class Main{
	public static void main(String[] args)throws IOException{
		InputStreamReader isr = new InputStreamReader(System.in);
		BufferedReader reader = new BufferedReader(isr);
		String string;
		int n, sum;
		
		while(!(string = reader.readLine()).equals("0")){
			PriorityQueue<Pair> que = new PriorityQueue<Pair>();
			n = Integer.valueOf(string);
			for(int i = 0; i < n; i++){
				String s[] = reader.readLine().split(" ");
				sum = 0;
				for(int j = 1; j < 9; j++){
					sum += Integer.valueOf(s[j]) * (j % 2 == 0 ? 1 : 60);
				}
				que.add(new Pair(sum, Integer.valueOf(s[0])));
			}
			for(int i = 0; i < 3; i++){
				if(i == 2){
					for(int j = i; j < n - 2; j++) que.poll();
				}
				System.out.println(que.poll().second);
			}
		}
		reader.close();
	}
}

class Pair implements Comparable<Pair>{
	int first, second;
	Pair(int first, int second){
		this.first = first;
		this.second = second;
	}
	@Override
	public int compareTo(Pair o) {
		return first - o.first;
	}
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(a)     (a).begin(),(a).end()
#define MOD 1000000007

typedef long long int ll;

const ll INF=(ll)1e19;
//const int INF=(1<<30);


int main(){
  int N, A, B;
  cin >> N >> A >> B;
  cout << min(N*A,B)<< endl;
}



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

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

    bool res = false;
    rep(i, 10)rep(j, 10) {
        if(i*j == n) res = true;
    }

    if (res == true) cout << "Yes" << endl;
    else cout << "No" << endl;

	return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
int a[N];
long long s[N], p[N];
int main() {
	int n, k;
	scanf("%d%d", &n, &k);
	for (int i = 1; i <= n; ++ i) {
		scanf("%d", &a[i]);
		s[i] = s[i - 1] + a[i];
		p[i] = p[i - 1] + (a[i] > 0 ? a[i] : 0);
	}
	long long ans = 0;
	for (int i = 1; i + k - 1 <= n; ++ i) {
		ans = max(ans, p[i - 1] + p[n] - p[i + k - 1] + max(0LL, s[i + k - 1] - s[i - 1]));
	}
	cout << ans << endl;
}



Measured memory_bytes: 2176
//ヘッダー
#include<bits/stdc++.h>
using namespace std;

//型定義
typedef long long ll;

//定数
const int INF=1e+9;
const int MOD=1e+9+7;

//REPマクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define REP2(i,a,b) for(ll i=a;i<(ll)(b);i++)
#define REPD2(i,a,b) for(ll i=a;i>(ll)(b);i--)

//vectorの扱い
#define ALL(x) (x).begin(),(x).end() //sortなどの引数省略
#define SIZE(x) ((ll)(x).size()) //size
#define MAX(x) *max_element(ALL(x)) //最大値
#define MIN(x) *min_element(ALL(x)) //最小値

using Graph = vector<vector<int>>;

int main(){
    ll N,K;
    cin >>N>>K;
    
    // グラフ入力受取 (ここでは無向グラフを想定)
    Graph G(N);
    for (int i = 0; i < N-1; ++i) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    
    // BFS のためのデータ構造
    vector<int> dist(N, -1); // 全頂点を「未訪問」に初期化
    queue<int> que;
    
    // 初期条件 (頂点 0 を初期ノードとする)
    dist[0] = 0;
    que.push(0); // 0 を橙色頂点にする
    ll ans=K;
    // BFS 開始 (キューが空になるまで探索を行う)
    while (!que.empty()) {
        int v = que.front(); // キューから先頭頂点を取り出す
        que.pop();
        ll cnt=0;
        // v から辿れる頂点をすべて調べる
        for (int nv : G[v]) {
            if (dist[nv] != -1) continue; // すでに発見済みの頂点は探索しない
            if(v==0) ans*=max((ll)0,K-1-cnt);
            else ans*=max((ll)0,K-2-cnt);
            ans%=MOD;
            cnt++;
            // 新たな白色頂点 nv について距離情報を更新してキューに追加する
            dist[nv] = dist[v] + 1;
            que.push(nv);
        }
    }
    cout << ans <<endl;

    
}

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

int main()
{
  int N; cin>>N;
  vector<Type> taste(N);
  rep(i,N)
  {
    cin>>get<0>(taste.at(i))>>get<1>(taste.at(i));
    get<2>(taste.at(i))=i+1;
  }
  sort(taste.begin(),taste.end(),[](Type const& x,Type const& y)
       {
         //第一要素が同一ならば第二要素の大きい方を返す
         return get<0>(x)==get<0>(y)?get<1>(x)>get<1>(y):get<0>(x)<get<0>(y);
       }
      );
  rep(i,N){cout<<get<2>(taste.at(i))<<endl;}
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		
		long[] a = new long[n];
		
		long[] start = new long[n];
		long[] end = new long[n];
		
		for(int i = 0; i < n; i++)a[i] = sc.nextLong();

		long res = 0;
		start[0] = 0;
		
		for(int i = 1; i < n; i++) {
			start[i] = gcd(start[i-1],a[i-1]);
		}
		
		end[n-1] = 0;
		
		for(int i = n-2; i >= 0; i--) {
			end[i] = gcd(end[i+1],a[i+1]);
		}
		
		
		for(int i = 0; i < n; i++) {
			res=Math.max(res, gcd(start[i],end[i]));
		}
		System.out.println(res);
		
	}
	
	private static long gcd(long m, long n) {
	    if(m < n) return gcd(n, m);
	    if(n == 0) return m;
	    return gcd(n, m % n);
	}
}

Measured memory_bytes: 60116
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include <memory.h>
#include <math.h>

#define MAX(a, b) (((a) > (b)) ? (a) : (b))
#define MIN(a, b) (((a) > (b)) ? (b) : (a))
#define SWAP(t, a, b) do{t c = a; a = b; b = c;}while(0)

int main (int argc, char **argv)
{
  char *s = NULL;
  int64_t *ans = NULL;
  int64_t len = 0;
  int64_t i = 0;
  int64_t j = 0;

  s = (char *)malloc(1000001 * sizeof(char));

  scanf("%s", s);
  len = strlen(s);

  ans = (int64_t *)calloc(len, sizeof(int64_t));

  while(i < len)
  {
    int64_t d = 0;
    int64_t a = 0;

    for(j = i + 1; (j < len) && (s[j] == 'R'); j++) {}
    d = j - i;
    a = d / 2;
    ans[j - 1] += a + (d & 1);
    ans[j] += a;

    for(i = j + 1; (i < len) && (s[i] == 'L'); i++) {}
    d = i - j;
    a = d / 2;
    ans[j - 1] += a;
    ans[j] += a + (d & 1);
  }

  for(i = 0; i < len; i++)
  {
    printf("%lld ", ans[i]);
  }
  printf("\n");

  free(s);
  free(ans);

  return 0;
}


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

#define MAX 410000
#define MOD 1000000007

long long modpow(long long a,long long n,long long mod){
  long long res=1;
  while(n>0){
    if(n&1){       //nのbitと...00001を比較  nが2で割り切れるならtrue
      res=(res*a)%mod;
    }
    a=(a*a)%mod;
    n>>=1;
  }
  return res;
}

long long modinv(long long a,long long mod){
  return modpow(a,mod-2,mod);
}

long long fac[MAX],finv[MAX],inv[MAX];

void COMinit(){
  fac[0]=fac[1]=1;
  finv[0]=finv[1]=1;
  inv[1]=1;
  for(int i=2;i<MAX;i++){
    fac[i]=(fac[i-1]*i)%MOD;
    inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
    finv[i]=finv[i-1]*inv[i]%MOD;
  }
}

long long COM(int n,int k){
  if(n<k){
    return 0;
  }
  if(n<0||k<0){
    return 0;
  }
  return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}

int main(){
  COMinit();
  long long n,k;
  cin>>n>>k;
  long long ans=0;
  if(k>=n-1){
    ans+=COM(2*n-1,n);
  }else{
    for(int i=0;i<=k;i++){
      ans+=COM(n,i)*COM((n-i-1)+i,i);
      ans%=MOD;
    }
  }
  cout<<ans<<endl;

}


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

int main(){
    int N,K;cin >> N >> K;
    LL ans = 1;
    LL weight = 1;
    LL ins = 0;
    N--;
    while(N != 0){
      //  cout<<weight<<endl;
        if(ins == 0){
            ins++;
            N--;
        }else
        if(1.0*weight/ins <= K){
            weight += ins;
            ins = 0;
            ans++;
        }else{
            ins++;
            N--;
        }
    }
    cout<<ans + (1.0*weight/ins <= K?1:0)<<endl;
}


Measured memory_bytes: 3124
#include<bits/stdc++.h>
typedef long long ll; 
#define pb push_back
#define mp make_pair
#define mod 998244353
#define vi vector <ll>
using namespace std ; 
ll power(ll x,ll y,ll m)
{            //power(x,y)=x^y  %m;
	ll res=1%m;
	while(y)
	{
	    if(y&1)
	    res=(res*x)%m;
	    x=(x*x)%m;
	    y=(y>>1)%m;
	}
	return res;
}
ll mod_inverse(ll x,ll m)
{
	return power(x,m-2,m);
}
vector<vector<ll> >g;
   vector<ll>v;
   ll vis[2005];
   vector<ll>v1;
void dfs(ll i)
{
    vis[i]=1;
    v1.pb(i);
    for(ll j=0;j<g[i].size();j++)
    {
        if(!vis[g[i][j]])
        dfs(g[i][j]);
        
    }
}
int main ()
{
    ios_base :: sync_with_stdio ( false );
    cin.tie( NULL );
    cout.tie( NULL );
ll t = 1 ;
//cin>>t;
while ( t--)  
{
  ll l,r,d;
  cin>>l>>r>>d;
  ll cnt=0;
  for(ll i=l;i<=r;i++)
  {
      if(i%d==0)
      cnt++;
  }
  cout<<cnt<<"\n";
}
 

 return 0;
}

Measured memory_bytes: 3616
import java.awt.Point;
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws java.io.IOException {
		Scanner sc = new Scanner(System.in);
		while (true) {
			int n = sc.nextInt();
			if (n == 0)
				break;
			Point[] tile = new Point[n];
			tile[0] = new Point(0, 0);

			for (int i = 1; i <= n - 1; i++) {
				tile[i] = new Point();
				int near = sc.nextInt();
				int d = sc.nextInt();
				switch (d) {
				case 0:
					tile[i].x = tile[near].x - 1;
					tile[i].y = tile[near].y;
					break;
				case 1:
					tile[i].x = tile[near].x;
					tile[i].y = tile[near].y - 1;
					break;
				case 2:
					tile[i].x = tile[near].x + 1;
					tile[i].y = tile[near].y;
					break;
				case 3:
					tile[i].x = tile[near].x;
					tile[i].y = tile[near].y + 1;
					break;

				}

			}
			int w_max = 0;
			int h_max = 0;
			int w_min = 0;
			int h_min = 0;
			for (Point p : tile) {
				w_max = Math.max(w_max, p.x);
				w_min = Math.min(w_min, p.x);
				h_max = Math.max(h_max, p.y);
				h_min = Math.min(h_min, p.y);
			}
			// System.out.println(h_max);
			// System.out.println(h_min);
			w_max++;
			// w_min--;
			h_max++;
			// h_min--;
			// System.out.println(Arrays.toString(tile));
			System.out.println((w_max - w_min) + " " + (h_max - h_min));
		}
	}
}

Measured memory_bytes: 12000
#include<stdio.h>
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std;


int main() {
  int N;
  cin >> N;
  long long A[N];
  for(int i=0;i<N;++i) cin >> A[i];

  sort(A,A+N,greater<long long>());

  for(int i=0;i<N-1;++i){
    if(A[i]==A[i+1]){
      cout << "NO" << endl;
      return 0;
    }
  }

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



Measured memory_bytes: 1792
import java.util.*;

public class Main {
    static final long DIV = 998244353;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        int sum = 0;
        for(int i=0; i<n; i++){
            a[i] = sc.nextInt();
            sum += a[i];
        }
        sc.close();

        int half = sum / 2;
        if(sum % 2 == 0) half -= 1;

        long[][] dp1 = new long[n+1][sum+1];
        dp1[0][0] = 1;
        for(int i=0; i<n; i++){
            for(int j=0; j<sum+1; j++){
                dp1[i+1][j] = dp1[i][j]* 2;
                if(j >= a[i]){
                    dp1[i+1][j] += dp1[i][j - a[i]];
                }
                dp1[i+1][j] %= DIV;
            }
        }

        long osum = 0;
        for(int i=half+1; i<sum+1; i++){
            osum += dp1[n][i];
            osum %= DIV;
        }

        long pown = 1;
        for(int i=0; i<n; i++){
            pown *= 3;
            pown %= DIV;
        }

        for(int i=0; i<3; i++){
            pown -= osum;
            if(pown < 0) pown += DIV;
        }

        if(sum % 2 == 0){
            long[][] dp2 = new long[n+1][sum+1];
            dp2[0][0] = 1;
            for(int i=0; i<n; i++){
                for(int j=0; j<sum+1; j++){
                    dp2[i+1][j] = dp2[i][j];
                    if(j >= a[i]){
                        dp2[i+1][j] += dp2[i][j - a[i]];
                    }
                    dp2[i+1][j] %= DIV;
                }
            }
            pown += dp2[n][half+1] * 3;
            pown %= DIV;
        }

        System.out.println(pown);
    }
}

Measured memory_bytes: 448408
s = input()
t = input()
dct = dict()

bool =True
for a,b in zip(s,t):
    if a in dct and dct[a]!=b:
        bool =False
        break
    dct[a]=b
#print(dct)
#print(len(dct.values()))
#print(len(dct))
a =dct.values()
if len(a)!=len(set(a)):
    bool =False
print('Yes' if bool else 'No')

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

typedef long long int ll;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define all(v) (v).begin(), (v).end()
#define sz(x) int(x.size())
const ll mod = 1000000007;
const ll INF = 1001001001001001000;

int main() {
    ll n; cin >> n;
    ll a[n]; rep(i,n) cin >> a[i];
    ll ans = 0;
    ll b = 1;
    rep(i,62) {
        ll cnt = 0;
        rep(j,n) {
            if ((a[j]>>i)&1) cnt++;
        }
        ll p = cnt*(n-cnt)%mod;
        ans = (ans + p*b%mod)%mod;
        b = (b*2)%mod;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 5904
#include<bits/stdc++.h>
using namespace std;
 
string solve(string s,string t,int n,int r){
     string g="";
    if(n==0 || r==0)return g;
    int arr[n+1][r+1]={0};
  for(int i=0;i<=n;i++){
        
        for(int j=0;j<=r;j++){
            if(i==0||j==0)arr[i][j]=0;
            else if(s[i-1]==t[j-1])arr[i][j]=arr[i-1][j-1]+1;
            else arr[i][j]=max(arr[i-1][j],arr[i][j-1]);
        }
}

int q=r,i=n,j=r;
  while(i>0 && j>0){
   
      
  if(s[i-1]==t[j-1]){
     
      
  g+=s[i-1];
  i--;
  j--;
    
  }
  else if(arr[i][j-1]>arr[i-1][j])j--;
   else  i--;
  
  
  }
  string l="";
   for(int k=g.length()-1;k>=0;k--){
   l+=g[k];
   }
     
    
    return l;
    
    
}
 
 
int main(){
    string s,t;
    cin>>s>>t;
    
   string y=solve(s,t,s.length(),t.length());
    cout<<y;
    
    
}

Measured memory_bytes: 35456
n, m = map(int, input().split())

if n < m:
  n, m = m, n
if m == 1:
  if n == 1:
    print(1)
  else:
    print(n-2)
    
elif m == 2:
  print(0)
  
else:
  print(n*m-2*(n+m)+4)

Measured memory_bytes: 61748
#pragma region ヘッダー
#define _CRT_SECURE_NO_WARNINGS

#ifdef _____MY_DEBUG_____
#define VS_ENDPAUSE()	(system("pause"))
#define DEBUG_OUT(...)  (printf(__VA_ARGS__))
#else
#define VS_ENDPAUSE()
#define DEBUG_OUT(...)
#endif

#include <stdio.h>
#include <string.h>
#include <iostream>
#include <math.h>
#include <cmath>
#include <vector>
#include <algorithm>
#include <string>
#include <functional>

using namespace std;
typedef signed char int8;
typedef signed short int16;
typedef signed int int32;
typedef signed long long int64;
typedef unsigned char uint8;
typedef unsigned short uint16;
typedef unsigned int uint32;
typedef unsigned long long uint64;
//#define int int64

#ifndef INT8_MIN
#define INT8_MIN	(-127)
#endif
#ifndef INT8_MAX
#define INT8_MAX	( 128)
#endif
#ifndef UINT8_MAX
#define UINT8_MAX	( 255)
#endif
#ifndef INT16_MIN
#define INT16_MIN	(-32768)
#endif
#ifndef INT16_MAX
#define INT16_MAX	( 32767)
#endif
#ifndef UINT16_MAX
#define UINT16_MAX	( 65535)
#endif
#ifndef INT32_MIN
#define INT32_MIN	(-2147483648)	// -2 * 10^9
#endif
#ifndef INT32_MAX
#define INT32_MAX	( 2147483647)	//  2 * 10^9
#endif
#ifndef UINT32_MAX
#define UINT32_MAX	( 4294967295)	//  4 * 10^9
#endif
#ifndef INT64_MIN
#define INT64_MIN	(-9223372036854775808)	// -9 * 10^18
#endif
#ifndef INT64_MAX
#define INT64_MAX	( 9223372036854775807)	//  9 * 10^18
#endif
#ifndef UINT64_MAX
#define UINT64_MAX	( 18446744073709551615)	// 18 * 10^18
#endif

void func(void);
#pragma endregion

int32 main(void)
{
    func();
    VS_ENDPAUSE();
    return 0;
}

void func(void)
{
//DEBUG_OUT("----\n");
    int N;
    cin >> N;

    int64 L0 = 2;
    int64 L1 = 1;
    int64 l = L1;

    for(int i=0; i<N-1; i++){
        l = L1 + L0;
        L0 = L1;
        L1 = l;
    }

    cout << l << endl;
}



Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;
 
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		
		long[] map = new long[N];
		for (int i = 0; i < N; i++) {
			map[i] = sc.nextInt();
			
			if (map[i] == 1) {
				System.out.println(1);
				return;
			}
		}
		
		Arrays.sort(map);
		
		int index = 1;
		int minIndex = 0;
		long min = map[0];
		while(true) {
			long nextMin = min;
			for (int i = index; i < N; i++) {
				long dm = map[i] % min;
				
				if (dm == 0)
					continue;
				
				if (dm < nextMin) {
					nextMin = dm;
					minIndex = i;
				}
				
			}
			
			if (min == nextMin)
				break;
			else {
				min = nextMin;
				map[minIndex] = min;
				index = 0;
			}
				
				
		}
		
		System.out.println(min);
	}
	
}


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

int main(){
  long long N;
  cin >> N;
  long long t = 998244353;
  vector<long long> D(N);
  long long max = 0;
  for(long long i = 0; i < N; i++){
    cin >> D.at(i);
  }
  vector<long long> count(N, 0);
  for(long long i = 0; i < N ; i++){
    count.at(D.at(i))++;
  }
  if(N == 1 && D.at(0) == 0){
    cout << 1 << endl;
  }
  else{
  	long long ans = 1;
  	if(count.at(0) != 1 || D.at(0) != 0){
      cout << 0 << endl;
  	}
  	else{
      for(int i = 1; i < N; i++){
        long long u = 1;
        for(long long j = 0; j < count.at(i); j++){
          u *= count.at(i - 1);
          u = u % t;
        }
        ans = ans % t;
        ans *= u;
      }
      cout <<setprecision(20) << ans % t << endl;
    }
  }
}

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

int main(){
	int a,b,c,k;
	std::cin>>a>>b>>c>>k;

	int count=0;

	while(b<=a){
		b*=2;
		count++;
	}

	while(c<=b){
		c*=2;
		count++;
	}

	if(count<= k)
		std::cout<<"Yes"<<std::endl;
	else
		std::cout<<"No"<<std::endl;

	return 0;
}

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

const int INF = 987654321;

int main() {
  int N, M, R;
  cin >> N >> M >> R;
  vector<int> r(R);
  for (int i = 0; i < R; i++) {
    cin >> r[i];
    r[i]--;
  }
  sort(r.begin(), r.end());

  vector<vector<int>> dist(N, vector<int>(N));
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      dist[i][j] = INF;
    }
    dist[i][i] = 0;
  }

  int A, B, C;
  for (int i = 0; i < M; i++) {
    cin >> A >> B >> C;
    A--, B--;
    dist[A][B] = dist[B][A] = C;
  }

  for (int k = 0; k < N; k++) {
    for (int i = 0; i < N; i++) {
      for (int j = 0; j < N; j++) {
        dist[i][j] = min(dist[i][k] + dist[k][j], dist[i][j]);
      }
    }
  }

  int ret = INF;
  do {
    int tmp = 0;
    for (int i = 0; i < R - 1; i++) {
      tmp += dist[r[i]][r[i + 1]];
    }
    ret = min(ret, tmp);
  } while (next_permutation(r.begin(), r.end()));
  cout << ret << endl;
}

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

def digit_sum_simple(n):
    
    max_sum = -1

    for i in range(10**(len(str(n))-1)-1, n+1):
        
        i_parts = []
        for i_part in str(i):
            i_parts.append(int(i_part))

        this_sum = sum(i_parts)
        
        if max_sum < this_sum:
            max_sum = this_sum
            max_sum_i = i

    return max_sum, max_sum_i

def digit_sum_temp(n):
    max_sum_i = int(str(int(str(n+1)[0])-1) + "9"*(len(str(n+1))-1))
    max_sum = sum([int(j) for j in str(max_sum_i)])

    return max_sum

print(digit_sum_temp(n))

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;

double dist(double x1, double y1, double x2, double y2) {  // (x1, y1) と (x2, y2) のユークリッド距離
    return sqrt( (x1-x2)*(x1-x2) + (y1-y2)*(y1-y2) );
}

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

    vector<double> x(n), y(n);
    rep(i, n) {
        cin >> x[i] >> y[i];
    }

    double ans = 0;
    rep(i, n) {
        for(int j = i+1; j < n; j++) {
            ans += dist(x[i], y[i], x[j], y[j]);
        }
    }

    ans = ans*2.0/n;

    printf("%.10f\n", ans);
    return 0;
}

Measured memory_bytes: 256
A = [0b11000000, 0b11000000]
B = [0b10000000, 0b10000000, 0b10000000, 0b10000000]
C = [0b11110000]
D = [0b01000000, 0b11000000, 0b10000000]
E = [0b11000000, 0b01100000]
F = [0b10000000, 0b11000000, 0b01000000]
G = [0b01100000, 0b11000000]

def match(source, target, width)
  return false  if source.length != target.length
  
  (9 - width).times{|n|
    found = true
    source.length.times{|l| found = false   if source[l] ^ target[l] >> n != 0 }
    return true  if found
  }
  return false
end

def cutFigure(figure)
  subFigure = Array.new
  figure.each{|n| subFigure << n  if n != 0 }
  return subFigure
end

def findFigure(source)
  return 'A'  if match(source, A, 2)
  return 'B'  if match(source, B, 1)
  return 'C'  if match(source, C, 4)
  return 'D'  if match(source, D, 2)
  return 'E'  if match(source, E, 3)
  return 'F'  if match(source, F, 2)
  return 'G'  if match(source, G, 3)
end

begin
  figure = Array.new
  8.times{ figure << $stdin.gets.to_i(2) }
  puts findFigure(cutFigure(figure))
end while $stdin.gets

Measured memory_bytes: 6108
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<queue>
#include<cstring>
using namespace std;
#define LL long long
#define maxn 10000010
#define inf 0x3f3f3f3f

int a,b;

int main(){
	cin>>a>>b;
	cout<<a-b+1<<endl;
	
	return 0;
}


Measured memory_bytes: 256