akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
using namespace std;

int main(){
    int h, w;
    cin >> h >> w;

    char c;
    int cnt[26] = {};

    for(int i = 0; i < h*w; i++){
        cin >> c;
        cnt[c-'a']++;
    }

    if(h == 1 || w == 1){
        if(h == 1)  swap(h, w);
        if(h == 1){
            cout << "Yes" << endl;
        }else{
            int odd = h%2;
            for(int i = 0; i < 26; i++) odd -= (cnt[i]%2);
            if(odd == 0)    cout << "Yes" << endl;
            else            cout << "No" << endl;
        }
        return 0;
    }

    auto f = [&](int a, int b) -> bool{
        for(int i = 0; i < 26 && b > 0; i++){
            while(cnt[i] >= 4 && b > 0)  cnt[i] -= 4, b--;
        }
        for(int i = 0; i < 26 && a > 0; i++){
            while(cnt[i] >= 2 && a > 0) cnt[i] -= 2, a--;
        }
        return (a == 0 && b == 0);
    };
    
    bool judge = true;
    if(h%2 + w%2 == 0){
        for(int x : cnt)    judge &= (x%4==0);
    }else if(h%2 + w%2 == 2){
        int want4 = (h-1)/2*(w-1)/2;
        int want2 = (h-1)/2 + (w-1)/2;
        judge = f(want2, want4);
        // 本当は1があるかどうかチェックしなければいけないが、自明なので省略
    }else{
        if(w%2) swap(h,w);
        int want4 = (h-1)/2*w/2;
        int want2 = w/2;
        judge = f(want2, want4);
    }

    cout << (judge ? "Yes" : "No") << endl;

    return 0;
}

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

int main(){
  char s[3];
  bool judge = 0;
 
  for(int i = 0;i < 3;i++){
    cin >> s[i];
  }
  for(int i = 0;i < 2;i++){
    if(s[i] != s[i + 1]){
      judge = 1;
    }
  }
  if(judge){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<pint> vpint;
#define mp make_pair
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)

int main(void){
	int N, A, B;
	cin >> N >> A >> B;
	string s; cin >> s;
	int cnta = 0, cntb = 0;
	vector<int> ans;
	rep(i, s.size()){
		if(s[i] == 'a'){
			if(cnta + cntb < A + B){
				ans.push_back(1);
				cnta++;
			}
			else ans.push_back(0);
		}
		if(s[i] == 'b'){
			if(cnta + cntb < A + B && cntb < B){
				ans.push_back(1);
				cntb++;
			}
			else ans.push_back(0);
		}
		if(s[i] == 'c') ans.push_back(0);

		// if(s[i] == 'a') cnta++;?
		// else if(s[i] == 'b')cn++;

	}
	rep(i, ans.size()){
		if(ans[i] == 1) printf("Yes\n");
		else printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 1272
// E - League
#include <bits/stdc++.h>

using namespace std;

int main(int argc, char *argv[])
{
	ios::sync_with_stdio(false); cin.tie(0);
	int n;
	cin >> n;
	vector<vector<int> > a(n, vector<int>(n - 1));
	for (int i = 0; i < n; i++)
		for (int j = 0; j < n - 1; j++) cin >> a[i][j];
	int ans = 0;
	vector<int> p(n), t;
	for (int i = 0; i < n; i++) t.push_back(i);
	for ( ; ; ) {
		bool found = false;
		vector<int> c(n), tt;
		for (int k = 0; k < t.size(); k++) {
			int i = t[k];
			if (p[i] < n - 1 && c[i] == 0) {
				int j = a[i][p[i]] - 1;
				if (p[j] < n - 1 && a[j][p[j]] == i + 1 && c[j] == 0) {
					found = true;
					p[i]++; p[j]++;
					c[i] = c[j] = 1;
					tt.push_back(i);
					tt.push_back(j);
				}
			}
		}
		if (!found) break;
		ans++;
		t = tt;
	}

	bool ok = true;
	for (int i = 0; i < n; i++)
		if (p[i] != n - 1) ok = false;

	cout << (ok ? ans : -1) << endl;

	return 0;
}


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

int main()
{
	int n, m;
	cin >> n >> m;
	vector<int> arr(m, 0);
	for (int i = 0; i < n; i++) {
		int k, cur;
		cin >> k;
		for (int j = 0; j < k; j++) {
			cin >> cur;
			arr[cur - 1]++;
		}
	}
	int ans = 0;
	for (int i = 0; i < m; i++) {
		if (arr[i] == n) ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
/**
 ____ ____ ____ ____ ____
||a |||t |||o |||d |||o ||
||__|||__|||__|||__|||__||
|/__\|/__\|/__\|/__\|/__\|

**/

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int N_MAX = 200002;

int n;

bool a[N_MAX];

int dp[N_MAX];

int ppc (int x)
{
    int ans = 0;
    while(x > 0)
    {
        if(x & 1)
            ans++;
        x >>= 1;
    }
    return ans;
}

int ppx0, ppx1, ppx2;

int pw0[N_MAX], pw2[N_MAX];

int md0, md2;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> n;
    string s;
    cin >> s;
    reverse(s.begin(), s.end());
    s = " " + s;
    for(int i = 1; i <= n; i++)
        a[i] = (s[i] == '1');
    for(int i = 1; i <= n; i++)
        dp[i] = dp[i % ppc(i)] + 1;
    for(int i = 1; i <= n; i++)
        ppx1 += a[i];
    ppx0 = max(1, ppx1 - 1);
    ppx2 = ppx1 + 1;
    pw0[0] = pw2[0] = 1;
    for(int i = 1; i <= n; i++)
    {
        pw0[i] = 1LL * pw0[i - 1] * 2 % ppx0;
        pw2[i] = 1LL * pw2[i - 1] * 2 % ppx2;
    }
    for(int i = 1; i <= n; i++)
    {
        md0 = (md0 + a[i] * pw0[i - 1]) % ppx0;
        md2 = (md2 + a[i] * pw2[i - 1]) % ppx2;
    }
    for(int i = n; i >= 1; i--)
    {
        if(a[i] == 1)
        {
            if(ppx1 == 1)
                cout << "0\n";
            else
            {
                int val = (md0 - pw0[i - 1] + ppx0) % ppx0;
                cout << dp[val] + 1 << "\n";
            }
        }
        else
        {
            int val = (md2 + pw2[i - 1]) % ppx2;
            cout << dp[val] + 1 << "\n";
        }
    }
    return 0;
}


Measured memory_bytes: 6316
import java.util.*;
public class Main {
    public static void main(String[] args ){
        Scanner sc = new Scanner(System.in);
        String s = sc.next(),t=sc.next();
        int count = 0;
        for(int i = 0;i<s.length();i++)if(s.charAt(i)!=t.charAt(i))count++;
        System.out.println(count);
}
}


Measured memory_bytes: 41188
module lib1

let allLines = seq{
    let mutable line = System.Console.ReadLine()
    while line <> null do
        yield line
        line <- System.Console.ReadLine()
}

let getSum y =
    let a = y / 10
    let b = y % 10 / 5
    let c = y % 10 % 5
    (a, b, c)


let mutable line = System.Console.ReadLine()

let data = 
    line.Split(' ')

let N = int data.[0]
let y = int data.[1] / 1000

if N * 10 < y || N > y then System.Console.WriteLine("-1 -1 -1")
else
    let mutable a, b, c = getSum y
    let mutable diff = N - (a + b + c)
    if diff = 0 then printf "%d %d %d\n" a b c
    else
        let mutable dp = diff / 9
        if dp > a then dp <- a
        a <- a - dp
        c <- c + dp * 10
        diff <- diff - dp * 9

        dp <- diff / 4
        if dp > b then dp <- b
        b <- b - dp
        c <- c + dp * 5
        diff <- diff - dp * 4

        dp <- diff
        if dp > a then dp <- a
        a <- a - dp
        b <- b + dp * 2
        diff <- diff - dp

        if diff <> 0 || a < 0 || b < 0 || c < 0 then System.Console.WriteLine("-1 -1 -1")
        else printf "%d %d %d\n" a b c

Measured memory_bytes: 14044
import numpy as np
N=int(input())
A=[]
for _ in range(N):
  A.append(int(input()))

A_sort_index=np.argsort(A)
ans=0

for i in range(N):
  if (A_sort_index[i]-i)%2==1:
    ans+=1

if ans%2==0:
    ans=ans//2
else:
    ans=ans//2+1
  
print(ans)

Measured memory_bytes: 17860
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std;

int main() {
  
  int a,b,c,d,x;
  double da,db;
  string s,ss,sss;
  
  int ans = 0;
  string anss = "";
  
  cin >> a >> b;
  
  int ab [] = {0 , 1 , 3 , 1 , 2 , 1 , 2 , 1 , 1 , 2 , 1 , 2 , 1};
  int result3 = std::max({a, b, c});
//--------------------------------------------------------------------------------
  
  if(a*b%2 == 0) anss = "Even";
  else anss = "Odd";

  cout << anss << endl;

}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int m,f,r,sum;
  while(1){
  scanf("%d%d%d",&m,&f,&r);
  if(m==-1 && f==-1 && r==-1) break;
  sum=m+f;
  
 if(m==-1 || f==-1) printf("F\n");
  
 else if(sum>=80){
    printf("A\n");
}

  else if(sum>=65){
    printf("B\n");
  }

  else if(sum>=50){
    printf("C\n");
  }

  else if(sum>=30){
    if(r>=50) printf("C\n");
    else printf("D\n");
  }  
   else  printf("F\n");

  }


  return 0;
}

Measured memory_bytes: 584
#include <vector> 
#include <list> 
 #include <map>
 #include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << '=' << (x) << endl;
#define debug(x) cerr << #x << '=' << (x) << '(L' << __LINE__ << ')' << ' ' << __FILE__ << endl;

int a[3];
bool b[3];
int main(){
    REP(i,3){
        cin>>a[i];
        REP(j,i){
            if(a[j]==a[i]){
                b[i]=b[j]=true;
            }
        }
    }
    REP(i,3){
        if(b[i]==false){
            cout<<a[i]<<endl;
        }
    }
    





}



Measured memory_bytes: 256
import sys

stdin = sys.stdin
 
ri = lambda: int(rs())
rl = lambda: list(map(int, stdin.readline().split()))
rs = lambda: stdin.readline().rstrip()  # ignore trailing spaces

N, M = rl()
nodes = [0] * (N+1) #0は使わない
for i in range(M):
    a, b = rl()
    nodes[a] += 1
    nodes[b] += 1

print('YES' if all(x%2==0 for x in nodes) else 'NO')

Measured memory_bytes: 3828
#include<iostream>
using namespace std;
const int MAX = 100;

void insertionSort(int A[], int N);
void showArray(int A[], int N);

int main() {
  int A[MAX], n;

  cin >> n;

  for ( int i = 0; i < n; i++ ) cin >> A[i];
  
  showArray(A, n);
  insertionSort(A, n);

  return 0;
}

void insertionSort(int A[], int N) {
  for ( int i = 1; i < N; i++ ) {
    int j = i - 1, v = A[i];

    while ( j >= 0 && A[j] > v ) {
      A[j + 1] = A[j];
      j--;
      A[j + 1] = v;
    }
  showArray(A, N);
  }

  return;
}

void showArray(int A[], int N) {
  cout << A[0];
  for ( int i = 1; i < N; i++) cout << " " << A[i];
  cout << endl;
  return;
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
using namespace std;
#define REP(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) REP(i, 0, n)
#define rrep(i, n) for (int i = (int)(n-1); i >= 0; i--)
#define sz(x) int(x.size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define INF 2e9
#define LINF 1e18
#define mod 1e9+7
template<class T> inline bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> P;


int main() {
    string s; cin >> s;
    int n = sz(s);
    int ans = 0;
    rep(i,n/2) {
        if (s[i]!=s[n-1-i]) ans++;
    }
    cout << ans << endl;
}

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

//
#define int long long
#define pb(x) push_back(x)
#define m0(x) memset((x), 0, sizeof(x))
#define mm(x) memset((x), -1, sizeof(x))

//container
#define ALL(x) (x).begin(), (x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
#define PERM(c) \
  sort(ALL(c)); \
  for (bool c##p = 1; c##p; c##p = next_permutation(ALL(c)))

// debug
#define GET_VAR_NAME(variable) #variable
#define test(x) cout << GET_VAR_NAME(x) << " = " << x << endl;

// bit_macro
#define bit(n) (1LL << (n))
#define bitset(a, b) (a) |= (1 << (b))
#define bitunset(a, b) (a) |= ~(1 << (b))
#define bitcheck(a, b) ((((a) >> (b)) & 1) == 1)
#define bitcount(a) __builtin_popcountll((a))

//typedef
typedef long long lint;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

//constant
const int INF = (int)1e18;
const int MOD = (int)1e9 + 7;
const double EPS = (double)1e-10;
const int dx[] = {-1, 0, 0, 1, 0, -1, -1, 1, 1};
const int dy[] = {0, -1, 1, 0, 0, 1, -1, 1, -1};

//
template <typename T>
void chmax(T &a, T b) { a = max(a, b); }
template <typename T>
void chmin(T &a, T b) { a = min(a, b); }
//
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

//
struct Accelerate_Cin {
  Accelerate_Cin() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);
  };
};

int N, p;

//Ｏ(√n)
//素因数分解
map<int, int> prime_factor(int n) {
  map<int, int> res; // map[i]:=ｎを素因数分解したときiは何乗か。
  for (int i = 2; i * i <= n; i++) {
    if (n % i == 0) {
      while (n % i == 0) {
        res[i]++;
        n /= i;
      }
    }
  }
  if (n != 1)
    res[n] = 1;
  return res;
}

signed main() {
  cin >> N >> p;
  if (N == 1) {
    cout << p << endl;
    return 0;
  }

  map<int, int> mp = prime_factor(p);

  int ans = 1;
  for (int i = 2; i * i <= p; i++) {
    if (mp[i] / N > 0) ans *= pow(i, mp[i] / N);
  }

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


Measured memory_bytes: 62720
#include<cstdio>
#include<cstdlib>
#include<string>
#include<iostream>
using namespace std;

struct Node {
    int key;
    Node *r,*l,*p;
};

Node *rootw, *NIL;

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

    z = (Node*)malloc(sizeof(Node));
    z->key = k;
    z->l = NIL;
    z->r = NIL;

    while(x != NIL){
        y=x;
        if(z->key < x->key){
            x=x->l;
        }
        else{
            x = x->r;
        }
    }
    z->p = y;
    if (y==NIL){
    rootw = z;
    }
    else{
        if(z->key < y->key){
            y->l = z;
        }
        else{
            y->r = z;
        }
    }
}

void inorder(Node *u){
    if(u == NIL)return;
    inorder(u->l);
    printf(" %d",u->key);
    inorder(u->r);
}
void preorder(Node *u){
    if(u == NIL)return;
    printf(" %d", u->key);
    preorder(u->l);
    preorder(u->r);
}

int main(){
    int ntw, i, x;
    string com;

    scanf("%d", &ntw);

    for(i = 0; i < ntw; i++){
        cin >> com;
        if(com == "insert"){
            scanf("%d", &x);
            insert(x);
        }
        else if (com == "print"){
            inorder(rootw);
            printf("\n");
            preorder(rootw);
            printf("\n");
        }
    }

    return 0;
}


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

// 2つの整数の場合
long long GetLeastCommonMultiple(long long a, long long b)
{
	long long m = a;
	long long n = b;
	long long temp;

	while (m % n != 0) {
		temp = n;
		n = m % n;
		m = temp;
	}
	return a / n * b;
}

int main() {

    ll n; cin >> n;

    vector<ll> t(n);
    for (ll i = 0; i < n; i++) {
        cin >> t[i];
    }

	// 3つ以上の整数の場合
	long long lcm = t[0];
	for (int i = 1; i < n; i++) {
		lcm = GetLeastCommonMultiple(lcm, t[i]);
	}

    cout << lcm << endl;
    return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"strconv"
)

func main() {
	var n string
	fmt.Scan(&n)
	N, _ := strconv.Atoi(n)

	var a string
	Al := []int{}
	for i := 0; i < N; i++ {
		fmt.Scan(&a)
		A, _ := strconv.Atoi(a)
		Al = append(Al, A)
	}

	isEven := func(x int) int {
		if x%2 == 0 {
			return 0
		} else {
			return 1
		}
	}

	areAllEven := func(l []int) bool {
		evenCount := 0
		for _, v := range l {
			evenCount += isEven(v)
		}
		if evenCount == 0 {
			return true
		} else {
			return false
		}
	}

	divide2 := func(l []int) []int {
		var nl []int
		for _, v := range l {
			nl = append(nl, v/2)
		}
		return nl
	}

	divedeNum := 0
	l := Al
	for {
		if areAllEven(l) == true {
			l = divide2(l)
			divedeNum += 1
		} else {
			break
		}
	}

	fmt.Println(divedeNum)
}


Measured memory_bytes: 640
//Aaryan Jagetia
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(),x.end()
#define mp(x,y) make_pair(x,y)
#define mod 1000000007
#define sc(x) scanf("%d", &x)
#define sl(x) scanf("%lld", &x)
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define test cin>>t;while(t--)
int main()
{    
    fast
ll h1,m1,h2,m2,s;
cin>>h1>>m1>>h2>>m2>>s;
ll var=h2-h1;
if(var==0){
    cout<<m2-s-m1;
}
else{
    if(m2>m1){
        ll var2=var*60+(m2-m1);
        cout<<var2-s;
    }
    else{
        ll var2=var*60-(m1-m2);
        cout<<var2-s;
    }
}

return 0;
}


Measured memory_bytes: 3648
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<map>
#include<numeric>
#include<set>
#include<string>
#include<utility>
#include<vector>

#define rep(i, a, n)  for(int i=a; i<n; i++)
#define per(i, a, n)  for(int i=n-1; i>=a; i--)
#define fill0(n)  setfill('0') << right << setw(n)
#define all(x)  (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define MAX 1000000000+7
using namespace std;
typedef long long ll;

int main(){
  ll N, x; cin >> N >> x;
  vector<ll> A(N+1, 0);
  rep(i, 1, N+1) cin >> A[i];
  ll ans = 0;
  rep(i, 1, N+1){
     if(A[i]+A[i-1]>x){
         ans  += ((A[i]+A[i-1])-x);
         A[i] -= ((A[i]+A[i-1])-x);
     }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1152
#include <iostream>

using namespace std;

int main(){
 int A,B;
  cin>>A;
  cin>>B;
  int ans = 0;
  if(B % A == 0){
    ans = A + B;
  }else{
    ans = B - A;
  }
  cout<<ans;
  
  return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.text.NumberFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map.Entry;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		BufferedReader inReader = new BufferedReader(new InputStreamReader(System.in));
		BufferedWriter outWriter = new BufferedWriter(new OutputStreamWriter(System.out));
		String finalOutput = "";
		String line;
		int noPair = 0;
		int count = 0;
		int sum = 0;
		HashMap<Integer, ArrayList<Integer>> mMap = new HashMap<>();
		finalOutput += " ";

		while ((line = inReader.readLine()) != null) {
			if (line.trim().compareTo("") == 0 || line == null || count == 3)
				break;

			switch (count) {
			case 0:
				// noPair = Integer.parseInt(line.trim());
				break;
			case 1:
				String[] tmp = line.split(" ");
				for (int i = 1; i <= tmp.length; i++) {
					ArrayList<Integer> tmpList = null;
					tmpList = mMap.get(Integer.parseInt(tmp[i - 1].trim()));
					if (tmpList == null) {
						tmpList = new ArrayList<>();
					}
					tmpList.add(i);
					mMap.put(Integer.parseInt(tmp[i - 1].trim()), tmpList);
				}

				break;
			}

			if (count == 1)
				break;
			++count;
		}
		noPair = 0;

		for (Entry<Integer, ArrayList<Integer>> e : mMap.entrySet()) {
			for (Integer i : e.getValue()) {
				if (mMap.get(i) != null && mMap.get(i).contains(e.getKey()))
					noPair++;
			}
		}
		noPair = noPair / 2;
		// outWriter.write("" + finalOutput);
		System.out.println(noPair + "");
		inReader.close();
		outWriter.close();

	}

}


Measured memory_bytes: 49976
#include "bits/stdc++.h"
using namespace std;
#define long int64_t

struct Solver {
	void solve() {
		int L, R, d;
		cin >> L >> R >> d;
		cout << R/d - (L-1)/d << endl;
	}
};

int main() {
	ios::sync_with_stdio( false );
	cout << fixed << setprecision( 10 );
	Solver().solve();
	return 0;
}


Measured memory_bytes: 3576
inpl = lambda: list(map(int,input().split()))
class SegmentTree:
    def __init__(self, value, N=0, comp=lambda x,y: x<=y):
        M = max(len(value),N)
        N = 2**(len(bin(M))-3)
        if N < M: N *= 2
        self.N = N
        self.node = [0] * (2*N-1)
        for i in range(N):
            self.node[N-1+i] = i
        self.value = [None] * N
        for i, v in enumerate(value):
            self.value[i] = v
        self.comp = lambda x, y: True if y is None else False if x is None else comp(x,y)
        for i in range(N-2,-1,-1):
            left_i, right_i = self.node[2*i+1], self.node[2*i+2]
            left_v, right_v = self.get_value(left_i), self.get_value(right_i)
            if self.comp(left_v, right_v):
                self.node[i] = left_i
            else:
                self.node[i] = right_i

    def set_value(self, n, v):
        self.value[n] = v
        i = (self.N-1) + n
        while i > 0:
            i = (i-1)//2
            left_i, right_i = self.node[2*i+1], self.node[2*i+2]
            left_v, right_v = self.get_value(left_i), self.get_value(right_i)
            if self.comp(left_v, right_v):
                new_i = left_i
            else:
                new_i = right_i
            if new_i == self.node[i] and new_i != n:
                break
            else:
                self.node[i] = new_i

    def get_value(self, n):
        return self.value[n]

    def get_min(self, a=0, b=-1):
        return self.value[self.get_min_index(a,b)]

    def get_min_index(self,
                     a=0, b=-1,
                     k=0, l=0, r=-1):
        if b < 0:
            b = self.N
        if r < 0:
            r = self.N
        if a <= l and r <= b:
            return self.node[k]
        elif r <= a or b <= l:
            return None
        else:
            left_i = self.get_min_index(a,b,2*k+1,l,(l+r)//2)
            right_i = self.get_min_index(a,b,2*k+2,(l+r)//2,r)
            left_v, right_v = self.get_value(left_i), self.get_value(right_i)
            if self.comp(left_v, right_v):
                return left_i
            else:
                return right_i

N = int(input())
partners = []
orders = [0]*N
for i in range(N):
    partners.append(set())
for i in range(N-1):
    a, b = inpl()
    a -= 1
    b -= 1
    partners[a].add(b)
    partners[b].add(a)
    orders[a] += 1
    orders[b] += 1
sg = SegmentTree(orders)
C = sorted(inpl())
D = [0]*N
M = 0
# print(sg.value, sg.node)
for i in range(N-1):
    k = sg.get_min_index()
    D[k] = C[i]
    M += C[i]
    for p in partners[k]:
        partners[p].remove(k)
        sg.set_value(p, sg.get_value(p)-1)
        # print(sg.value,sg.node)
    sg.set_value(k, None)
    # print(sg.value,sg.node)
k = sg.get_min_index()
D[k] = C[N-1]

print(M)
print(' '.join(map(str,D)))

Measured memory_bytes: 65624
#pragma GCC target("avx512f,avx512dq,avx512cd,avx512bw,avx512vl")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
 
int ri() {
	int n;
	scanf("%d", &n);
	return n;
}
 
int main() {
	int n = ri();
	std::string s;
	std::cin >> s;
	int64_t res = 0;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < i; j++) {
			if (s[i] == s[j]) continue;
			for (int k = 0; k < j; k++) if (j - k != i - j && s[k] != s[i] && s[k] != s[j]) res++;
		}
	}
	printf("%" PRId64 "\n", res);
	return 0;
}

Measured memory_bytes: 3800
#include <iostream>
#include <algorithm>
#pragma warning(disable : 4996)
#define rng(x1, y1, x2, y2) (sum[y2][x2] + sum[y1][x1] - sum[y2][x1] - sum[y1][x2])
using namespace std;
int H, W, ra, o, a[40][40], sum[40][40], dp[40][40][40][40];
inline int solve(int x1, int y1, int x2, int y2) {
	if (dp[y1][x1][y2][x2]) return dp[y1][x1][y2][x2];
	int ret = 1048576 + rng(x1, y1, x2, y2);
	for (int i = x1 + 1; i < x2; i++) {
		int petl = rng(x1, y1, i, y2), petr = rng(i, y1, x2, y2);
		if (min(petl, petr) >= o) {
			int resl = solve(x1, y1, i, y2);
			int resr = solve(i, y1, x2, y2);
			int res = ((resl + resr) >> 20 << 20) + min(resl & 1048575, resr & 1048575);
			ret = max(ret, res);
		}
	}
	for (int i = y1 + 1; i < y2; i++) {
		int petl = rng(x1, y1, x2, i), petr = rng(x1, i, x2, y2);
		if (min(petl, petr) >= o) {
			int resl = solve(x1, y1, x2, i);
			int resr = solve(x1, i, x2, y2);
			int res = ((resl + resr) >> 20 << 20) + min(resl & 1048575, resr & 1048575);
			ret = max(ret, res);
		}
	}
	return dp[y1][x1][y2][x2] = ret;
}
int main() {
	while (scanf("%d%d%d", &H, &W, &ra), H) {
		for (int i = 0; i < H; i++) {
			for (int j = 0; j < W; j++) scanf("%d", &a[i][j]);
		}
		for (int i = 0; i < H; i++) {
			for (int j = 0; j < W; j++) sum[i + 1][j + 1] = sum[i + 1][j] + sum[i][j + 1] - sum[i][j] + a[i][j];
		}
		for (int i = 0; i < H; i++) {
			for (int j = 0; j < W; j++) {
				for (int k = i + 1; k <= H; k++) {
					for (int l = j + 1; l <= W; l++) dp[i][j][k][l] = 0;
				}
			}
		}
		o = sum[H][W] - ra;
		int ret = solve(0, 0, W, H);
		printf("%d %d\n", (ret >> 20), ((ret - o) & 1048575));
	}
}

Measured memory_bytes: 9120
#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() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    int cntr = 0, cntw = 0;
    rep(i, 0, n) {
        if (s[i] == 'R') {
            cntr++;
        } else {
            cntw++;
        }
    }
    string ans = "";
    rep(i, 0, n) {
        if (i < cntr) {
            ans += 'R';
        } else {
            ans += 'W';
        }
    }
    int cnt = 0;
    rep(i, 0, cntr) {
        if (s[i] != ans[i]) cnt++;
    }
    // cout << ans << "\n";
    cout << cnt << "\n";
}

Measured memory_bytes: 3848
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rapido ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

void solve()
{
    int x;cin>>x;
    int ans=0;
    for(int i=x;;i+=x)
    {
        ans++;
        if(i%360==0)
        break;
    }
    cout<<ans<<endl;
}

int32_t main()
{
    rapido;
    //int t;cin>>t;
    int t=1;
    while(t--)
    solve();
}

Measured memory_bytes: 3580
/*
 * Created by KeigoOgawa
 */


#include <cstdio>
#include <iostream>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
#include <cassert>
#include <cmath>

#define INF 1e15
#define EPS 1e-10
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define MIN(a, b) (a > b ? b : a)
#define MAX(a, b) (a > b ? a : b)
#define debug(x) cout << #x << ": " << x << endl
#define all(a) (a).begin(), (a).end()

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> PII;

int xs, ys, xt, yt;
int N;
double dp[1002][1002];
ll  x[1002], y[1002], r[1002];
double d[1002];
bool used[1002];

double dist(int i, int j) {
  return sqrt((x[i] - x[j]) * (x[i] - x[j]) + (y[i] - y[j]) * (y[i] - y[j])) - (r[i] + r[j]);
}

void calcCost() {
  REP(i, N + 2) {
    REP(j, N + 2) {
      dp[i][j] = dist(i, j);
      if (dp[i][j] < 0) dp[i][j] = 0;
    }
  }
}

void dijkstra(int s) {
  fill(d, d + N + 2, INF);
  fill(used, used + N + 2, false);
  d[s] = 0;

  while (true) {
    int v = -1;

    // まだ使われていない頂点のうち距離が最小のものを探す
    for (int u = 0; u < N + 2; ++u) {
      if (!used[u] && (v == -1 || d[u] < d[v])) {
        v = u;
      }
    }

    if (v == -1) {
      break;
    }
    used[v] = true;

    for (int u = 0; u < N + 2; ++u) {
      d[u] = min(d[u], d[v] + dp[v][u]);
    }
  }
}

void solve() {
  calcCost();
  dijkstra(N);
  printf("%.10lf\n", d[N + 1]);
}

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

  cin >> xs >> ys >> xt >> yt;
  cin >> N;
  REP(i, N) {
    cin >> x[i] >> y[i] >> r[i];
  }
  x[N] = xs;
  y[N] = ys;
  r[N] = 0;
  x[N + 1] = xt;
  y[N + 1] = yt;
  r[N + 1] = 0;
  solve();
  return 0;
}


Measured memory_bytes: 8320
/*
float like a butterfly
sting like a Bee

?#%^*&~`!  YOUR ONLY LIMIT IS YOUR MIND

*/

#include <bits/stdc++.h>
#define lli long long int
#define pb push_back
#define pop pop_back
#define F first
#define S second
#define q '\n'

using namespace std;

int main() {
	int x[5], ans = 0;
	for (int i = 0; i < 5; i++){
		cin >> x[i];
		if (x[i] == 0){
			ans = i + 1;
		}
	}
	cout << ans;
}


Measured memory_bytes: 3632
#!/usr/bin/env python3
import sys

def main():
    N, P = map(int, input().split())
    ans = 1
    if N == 1:
        print(P)
        exit()
    for i in range(2,int(P**(1/N)+1)):
        count = 0
        tmp = P
        while tmp % i == 0:
            count += 1
            tmp = tmp // i
        ans *= i**(count // N)
        P = P // i**count
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cmath>
#include<cstdio>
#include<tuple>
#include<bitset>

using namespace std;
//#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(x) x.begin(),x.end()
#define ll long long
const int inf=1000000007;
const int MOD=1000000007;
signed main(){
  vector<int> a(3);
  cin>>a[0]>>a[1]>>a[2];
  sort(ALL(a));
  cout<<a[0]*a[1]/2<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define boost ios::sync_with_stdio(false);cin.tie(nullptr)
#define int long long 
#include "string"
int32_t main() {
	boost;

	int n;
	cin>>n;
	vector<int>a(n);
	int start = 0;
	int ans[n];
	for(int i=0;i<n;i++){
		cin>>a[i];
		if(i % 2 == 0)
			start += a[i];
		else
			start -= a[i];
	}
	a[0] -= start/2;
	a[n-1] -= start/2;
	ans[0] = start; 
	for(int i=1;i<n;i++){
		a[i] -= a[i-1];
		ans[i] = 2*a[i-1];
	}

	for(int i=0;i<n;i++)
		cout<<ans[i]<<" ";
	cout<<endl;
}

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

int main()
{
    int n;
    cin >> n;
    vector<int> v(n + 1,0);
    for(int i = 2; i <= n; i++)
    {
        cin >> v[i];
    }
    vector<int> counter(n + 1, 0);
    for(int i = 2; i <= n; i++)
    {
        counter[v[i]]++;
    }
    for(int i = 1; i < n + 1; i++)
    {
        cout << counter[i] << "\n";
    }
    

}

Measured memory_bytes: 4840
#-*-coding:utf-8-*-

import sys

def main():
    n = int(input())
    ans=0
    b=0

    for a in range(1,n):
        #A*B+C=n → A <= n-c//b
        #cは1<=c<=nなのでbで可変
        b=(n-1)//a
        ans+=b
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 9036
#include <iostream>

int main()
{
  using namespace std;
  string str;

  cin >> str;

  for (int i = 0; i < 3; i++) {
    if (str[i] == str[i+1]) {
      cout << "Bad" << endl;
      return 0;
    }
  }

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


Measured memory_bytes: 256
#include <stdio.h>
int n, x, y, z;
long long a[100000];
long long s, t, u, v;
int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%lld", a + i);
		s ^= a[i];
	}
	for (int i = 0; i < n; i++) {
		a[i] = a[i] & (~s);
	}
	for (int i = 0; i < 60; i++) {
		t = 1;
		t <<= (59 - i);
		z = 0;
		for (int j = x; j < n; j++) {
			if (a[j] & t) {
				y = j;
				z = 1;
				break;
			}
		}
		if (z) {
			u = a[y];
			a[y] = a[x];
			a[x] = u;
			for (int j = 0; j < n; j++) {
				if ((a[j] & t) && (j - x))a[j] ^= a[x];
			}
			x++;
		}
	}
	for (int i = 0; i < x; i++) {
		t = 1;
		t <<= 59;
		while (t > a[i])t /= 2;
		if (!(v & t))v ^= a[i];
	}
	printf("%lld\n", s + v * 2);
}

Measured memory_bytes: 896
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <limits.h>

int
main(void)
{
        int N;
        int K;

        scanf("%d %d\n", &N, &K);

        for (int i = 0; i < N; i++) {
                char c;
                scanf("%c", &c);
                printf("%c", (i == (K - 1)) ? tolower(c) : c);
        }

        return 0;
}



Measured memory_bytes: 128
def solution(n, x)
  ans = 0
  (1..n).each do |i|
    (i+1..n).each do |j|
      (j+1..n).each do |k|
        ans+=1 if x == (i+j+k)
      end
    end
  end
  puts ans
end

array = []

loop do
  n, x = gets.chomp.split().map(&:to_i)
  break if n == 0 and x == 0
  array << [n, x]
end

array.each do |n, x| 
  solution(n, x)
end


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

bool comp(pair<int, int> &a, pair<int, int> &b)
{
    if(a.second != b.second) return a.second < b.second;
    return a.first < b.first;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<pair<int, int>> sls(n);
    for(int i=0; i<n; i++)
    {
        int a, b;
        cin >> a >> b;
        sls.at(i) = make_pair(a-b, a+b);
    }
    sort(sls.begin(), sls.end(), comp);

    int res = 1;
    int cp = sls.at(0).second;
    for(auto &sl : sls)
    {
        if(sl.first >= cp)
        {
            res++;
            cp = sl.second;
        }
    }
    cout << res << '\n';


    return 0;
}

Measured memory_bytes: 1024
/* *>>>>>Anshit_Bhardwaj<<<<<* */
#include <bits/stdc++.h>
#define ll long long
#define f(i, x, n) for(int i = x; i < n; i++)
#define dbg(x) cout << x << endl
#define dbg2(x, y) cout << x << ' ' << y << endl
#define dbg3(x, y, z) cout << x << ' ' << y << ' ' << z << endl
#define mod 1000000007
using namespace std;

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int x, n, a;
    cin >> x >> n;
    vector<bool> arr(102, false);
    f(i, 0, n){
        cin >> a;
        arr[a] = true;
    }
    int ans;
    for(int i = x; i < arr.size(); i++){
        if(arr[i] == false){
            ans = i;
            break;
        }
    }
    for(int i = x; i >= 0; i--){
        if(arr[i] == false){
            if(abs(i - x) <= abs(ans - x)){
                ans = i;
            }
            break;
        }
    }
    if(abs(ans - x) > abs(x)){
        ans = 0;
    }
    cout << ans << endl;
}

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

int main() {
    string A, B, C;
    cin >> A >> B>> C;
    int a=0, b=0, c=0;
    char x='a';
    while (1){
        if (x=='a'){
            if (a==A.length()){
                cout << "A" << endl;
                return 0;
            }
            x=A.at(a);
            a++;
        }
        else if (x=='b'){
            if (b==B.length()){
                cout << "B" << endl;
                return 0;
            }
            x=B.at(b);
            b++;
        }
        if (x=='c'){
            if (c==C.length()){
                cout << "C" << endl;
                return 0;
            }
            x=C.at(c);
            c++;
        }
    }
}

Measured memory_bytes: 3640
#include<iostream>
#include<algorithm>
#include<iomanip>
using namespace std;
int N_MAX=200000;
int main()
{
  int n,k,i;
  long double res;
  long double p[N_MAX],s[N_MAX];
  cin >> n >> k;
  s[0]=k;
  for(i=0;i<k;i++){
    cin >> p[i];
    s[0]+=p[i];
  }
  for(i=k;i<n;i++){
    cin >> p[i];
    s[i-k+1]=s[i-k]+p[i]-p[i-k];
  }
  res=*max_element(s,s+n-k+1)/2;
  cout << setprecision(12) << res << endl;
  return 0;
}

Measured memory_bytes: 6528
#include "bits/stdc++.h"
using namespace std;
 
////////////// Prewritten code follows. Look down for solution. ////////////////

//#define int long long
#define endl '\n'
#define fs first
#define sc second
#define pb push_back
#define len(x) ((int)(x).size())     
#define all(x) (x).begin(), (x).end()
#define test int _; cin >> _; while(_--)
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

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

const ll LINF = 0x3f3f3f3f3f3f3f3f;
const int INF = 0x3f3f3f3f;
const ll MOD = 1e9+7;

ll gcd(ll a, ll b){return (b == 0LL ? a : gcd(b, a%b));}
inline ll mod(ll a, ll b){return ((a%b)+b)%b;}
inline ll expo(ll b, ll p, ll m = MOD){
  ll ans = 1; 
  while(p > 0){
    if(p&1LL) ans = mod(ans*b, m); 
    b = mod(b*b, m); 
    p >>= 1LL;
  } 
  return ans;
}
 
////////////////////////// Solution starts below. //////////////////////////////

const int N = 1e5+5;
vector<int> adj[N];
int branco[N], preto[N], root;

void dfs(int v, int p = -1){
  branco[v] = preto[v] = 1;
  for(int u : adj[v]) if(u != p){
    dfs(u, v);
    preto[v] = (preto[v]%MOD * branco[u]%MOD)%MOD;
    branco[v] = (branco[v]%MOD * (branco[u]%MOD + preto[u]%MOD)%MOD)%MOD;
  }
}

int32_t main(){
  fastio;
  int n;
  cin >> n;
  for(int i = 0; i < n-1; i++){
    int a, b;
    cin >> a >> b;
    adj[a].pb(b);
    adj[b].pb(a);
  }
  root = 1;
  dfs(root);
  if(n == 1) branco[root] = preto[root] = 1;
  cout << (branco[root]%MOD + preto[root]%MOD)%MOD << endl;
  return 0;
}

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

long long int a[4001];
long long int dp[4001][4001];

long long int dfs(int x,int y){
	if(y<x){
		return 0;
	}else{
		if(dp[x][y]<0){
			if(a[x]>a[y-1]){
				if(a[x+1]>a[y]){
					dp[x][y]=max(a[x]+dfs(x+2,y),a[y]+dfs(x+1,y-1));
				}else{
					dp[x][y]=max(a[x],a[y])+dfs(x+1,y-1);
				}
			}else{
				if(a[x+1]>a[y]){
					dp[x][y]=max(a[x]+dfs(x+2,y),a[y]+dfs(x,y-2));
				}else{
					dp[x][y]=max(a[x]+dfs(x+1,y-1),a[y]+dfs(x,y-2));
				}
			}
		}
		return dp[x][y];
	}
}

int main(){
	int n;
	long long int x=0;
	cin>>n;
	for(int i=1;i<=n;++i){
		cin>>a[i];
		a[n+i]=a[i];
		fill(dp[i],dp[i]+4001,-1);
	}
	for(int i=n+1;i<=2*n;++i){
		fill(dp[i],dp[i]+4001,-1);
	}
	for(int i=1;i<=n;i+=2){
		x=max(x,dfs(i,i+n-1));
	}
	cout<<x<<endl;
}

Measured memory_bytes: 126304
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
using namespace std;
#pragma warning (disable: 4996)

int A, B;

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

Measured memory_bytes: 3636
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        aa: [u64;n],
    }
    println!("{}", aa.into_iter().map(|x| x - 1).sum::<u64>());
}


Measured memory_bytes: 4352
#include <stdio.h>

int main(void)
{
	int a,b;
	
	scanf("%d %d",&a,&b);
	
	if(b % a == 0){
		printf("%d\n",a+b);
	}else{
		printf("%d\n",b-a);
	}
	
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <bitset>
#include <iomanip>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <algorithm>

//fixed << setprecision(8)

using namespace std;

#define ll long long
#define vec vector
#define vecll vector<long long>
#define vec2ll vector<vector<long long>>
#define forll(s,a,b) for(long long s = a;s < b;s++)
#define forllde(s,a) for(long long s = a;s > 0;s--)

int main()
{
	ll n,ans=1;
	string s;

	cin >> n;

	forll(i, 0, n)
	{
		ans *= i + 1;
		ans %= 1000000007;
	}

	cout << ans;
}

Measured memory_bytes: 256
// C++ code to find number of distinct numbers
// in a subarray
#include<bits/stdc++.h>
using namespace std;
#define FIO ios_base::sync_with_stdio (false) ;cin.tie(NULL);
const int MAX = 500010;

// structure to store queries
struct Query
{
	int l, r, idx;
};

// cmp function to sort queries according to r
bool cmp(Query x, Query y)
{
	return x.r < y.r;
}

// updating the bit array
void update(int idx, int val, int bit[], int n)
{
	for (; idx <= n; idx += idx&-idx)
		bit[idx] += val;
}

// querying the bit array
int query(int idx, int bit[], int n)
{
	int sum = 0;
	for (; idx>0; idx-=idx&-idx)
		sum += bit[idx];
	return sum;
}

void answeringQueries(int arr[], int n, Query queries[], int q)
{
	// initialising bit array
	int bit[n+1];
	memset(bit, 0, sizeof(bit));

	// holds the rightmost index of any number
	// as numbers of a[i] are less than or equal to 10^6
	int last_visit[MAX];
	memset(last_visit, -1, sizeof(last_visit));

	// answer for each query
	int ans[q];
	int query_counter = 0;
	for (int i=0; i<n; i++)
	{
		// If last visit is not -1 update -1 at the
		// idx equal to last_visit[arr[i]]
		if (last_visit[arr[i]] !=-1)
			update (last_visit[arr[i]] + 1, -1, bit, n);

		// Setting last_visit[arr[i]] as i and updating
		// the bit array accordingly
		last_visit[arr[i]] = i;
		update(i + 1, 1, bit, n);

		// If i is equal to r of any query store answer
		// for that query in ans[]
		while (query_counter < q && queries[query_counter].r == i)
		{
			ans[queries[query_counter].idx] =
					query(queries[query_counter].r + 1, bit, n)-
					query(queries[query_counter].l, bit, n);
			query_counter++;
		}
	}

	// print answer for each query
	for (int i=0; i<q; i++)
		cout << ans[i] << endl;
}

// driver code
int main()
{
	FIO;
	int n,q;
	cin>>n>>q;
	int arr[n];
	for(int i=0;i<n;i++){
	cin>>arr[i];
	}
	Query*brr=new Query[q];
	int a,b;
	for(int i=0;i<q;i++){
        cin>>a>>b;
    brr[i].l=a-1;
        brr[i].r=b-1;
        brr[i].idx=i;
	}

	sort(brr, brr+q, cmp);
	answeringQueries(arr, n, brr, q);
	return 0;
}


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

int main(){
    int r,c;
    cin >> r >> c;
    int a[r + 1][c + 1];

    for(int i = 0; i < r + 1; ++i){
        for(int j = 0; j < c + 1; ++j){
            a[i][j] = 0;
        }
    }

    for(int i = 0; i < r; ++i){
        for(int j = 0; j < c; ++j){
            cin >> a[i][j];
        }
    }

    for(int i = 0; i < r + 1; ++i){
        for(int j = 0; j < c; ++j){
            a[i][c] += a[i][j];
        }
    }

    for(int i = 0; i < c + 1; ++i){
        for(int j = 0; j < r; ++j){
            a[r][i] += a[j][i];
        }
    }
    
    for(int i = 0; i < r + 1; ++i){
        for(int j = 0; j < c + 1; ++j){
            if(j != 0) cout << " ";
            cout << a[i][j] << flush;
        }
        cout << endl;
    }
}

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


ll x;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin>>x;
    
    for (ll i=-1000; i<=1000; i++){
        for (ll j=-1000; j<=1000; j++){
            if (pow(i,5)-pow(j,5)==x) return cout<<i<<" "<<j,0;
        }
    }
    
    return 0;
}

Measured memory_bytes: 4124
#include <vector>
#include <cstdio>
using namespace std;
 
int belong[100000];
int value[100000];
 
int update(int idx) {
    if (idx == belong[idx])
        return idx;
    else {
        int t = belong[idx];
        belong[idx] = update(belong[idx]);
        value[idx] += value[t];
        return belong[idx];
    }
}

bool merge(int l ,int r, int d) {
    int lb = update(l);
    int rb = update(r);
    if (lb == rb) {
        if (value[r] != (value[l]+d)) return false;
    } else {
        belong[rb] = lb;
        value[rb] = value[l] + d - value[r];
    }
    return true;
}
 
int main() {
    int n, m;
    scanf("%d %d", &n, &m);
    for (int i = 0; i < n; i++) {
        belong[i] = i;
        value[i] = 0;
    }
    while(m--) {
        int l, r, d;
        scanf("%d %d %d", &l, &r, &d);
        l--; r--;
        if (!merge(l, r, d)) {
            printf("No\n");
            return 0;
        }
    }
    printf("Yes\n");
    return 0;
}

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

int main(){
  int H,W;
  cin >> H >> W;
  vector<string> A(10);
  for(int i=0;i<H;i++)cin >> A[i];
  int cnt=0;
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){if(A[i][j]=='#')cnt++;}
  }
  if(cnt==H+W-1){cout << "Possible" << endl;}
  else{cout << "Impossible" << endl;}
}

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    vector<short> pos;
    pos.assign(5, 0);
    for(int i = 0; i < 5; ++i){
        cin >> pos[i];
    }
    short k;
    cin >> k;
    bool flag = true;
    for(int i = 0; i < 5; i++){
        for(int j = i+1; j < 5; j++){
            if(pos[j]-pos[i] > k){
                flag = false;
                break;
            }
        }
        if(!flag)   break;
    }
    if(flag)    cout << "Yay!" << endl;
    else cout << ":(" << endl;
    return 0;
}

Measured memory_bytes: 256
def so():
    s=input()
    if s==s[::-1]:
        a=s[0:int((len(s)-1)/2)]
        if a==a[::-1]:
            b=s[int((len(s)+3)/2-1):]
            if b==b[::-1]:
                return "Yes"
    return "No"
print(so())

Measured memory_bytes: 3060
#!/usr/bin/env python3
import sys


def solve(N: int, a: "List[int]"):

    c = [0]*4
    for A in a:
        c[A] += 1

    J = min(c[2]+c[3]+1, N+1)
    I = min(c[1]+c[2]+c[3]+1, N+1)
    kitai = [[[0]*(I+1) for _ in range(J+1)]
             for _ in range(c[3]+1)]
    for k in range(c[3]+1):
        for j in range(J):
            for i in range(I):
                tot = i+j+k
                if tot == 0 or tot > N:
                    continue
                res = N + kitai[k][j][i-1]*i + \
                    kitai[k][j-1][i+1]*j + kitai[k-1][j+1][i]*k
                kitai[k][j][i] = res/tot
    print(kitai[c[3]][c[2]][c[1]])

    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    a = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, a)


if __name__ == '__main__':
    main()


Measured memory_bytes: 499208
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64
#define rep(i, n) for(int i=0; i<n; i++)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mk make_pair
#define fi first
#define se second
#define pb push_back
#define ALL(x) x.begin(), x.end()
#define V(T) vector<T>
typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef vector<int> vi;
typedef vector<vi> vvi;
int max(int a, int b) {if(b>a) return b; else return a;}
int min(int a, int b) {if(b<a) return b; else return a;}


signed main() {
    int a, b;
    cin >> a >> b;

    if((a*b)%2) cout << "Odd" << endl;
    else cout << "Even" << endl;
    
    return 0;
}

Measured memory_bytes: 384