akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main() {
  long long A;
  float B;
  cin >> A; 
  cin >> B;
  int C=(B+0.001)*100;
  long long ans;
  ans=A*C/100;
  
  cout << ans <<endl;
  
  return 0;

}

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

#define FOR(i, j, k) for (int i = j; i < k; i++)
#define REP(i, j) FOR(i, 0, j)
typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;

int main() {

  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(10);
  cout << fixed;

  int n;
  string a, b, c;

  cin >> n >> a >> b >> c;

  vector<map<char, int>> vm(n);

  REP(i, n) {
    vm[i][a[i]]++;
    vm[i][b[i]]++;
    vm[i][c[i]]++;
  }

  int ans = 0;

  REP(i, n) {

    int m = 0;
    for (auto p : vm[i]) {
      m = max(m, p.second);
    }

    ans += 3 - m;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
class Enumerator:
    def __init__(self, N: int, MOD: int) -> None:
        self.fact = [1, 1]
        self.finv = [1, 1]
        self.invs = [0, 1]
        for i in range(2, N + 1):
            self.fact.append(self.fact[i - 1] * i % MOD)
            self.invs.append(-self.invs[MOD % i] * (MOD // i) % MOD)
            self.finv.append(self.finv[-1] * self.invs[-1] % MOD)
        self._MOD = MOD
        self._N = N

    def choose(self, n: int, k: int) -> int:
        if p := self.permutate(n, k):
            return p * self.finv[k] % self._MOD
        else:
            return 0

    def permutate(self, n: int, k: int) -> int:
        if n < k or n < 0 or k < 0:
            return 0
        assert n <= self._N and k <= self._N
        return self.fact[n] * self.finv[n - k] % self._MOD

    def choose_with_duplicates(self, n: int, k: int) -> int:
        return self.choose(n + k - 1, n)


N, K = map(int, input().split())
A = list(map(int, input().split()))
MOD = 1_000_000_007
A.sort()
e = Enumerator(N, MOD)
nck = e.choose(N, K)
ans = 0
for i in range(N - 1):
    ci = nck - e.choose(i + 1, K) - e.choose(N - i - 1, K)
    ans += ci * (A[i + 1] - A[i])
    ans %= MOD
print(ans)


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

int deg[100001];

int main() {
    int N;
    cin >> N;
    ll sum = 0;
    rep(i, N) {
        int x;
        cin >> x;
        deg[x]++;
        sum += x;
    }
    int Q;
    cin >> Q;
    rep(i, Q) {
        ll from, to;
        cin >> from >> to;
        sum += (to - from) * deg[from];
        deg[to] += deg[from];
        deg[from] = 0;
        cout << sum << endl;
    }
}

Measured memory_bytes: 3956
/* by Natsu Kinmoe */
#include <bits/stdc++.h>
using namespace std;
#define SZ(x)               ((int)(x).size())
#define all(x)              (x).begin(), (x).end()
#define loop(i, n)          for(int i = 0; i < (n); i++)
#define cont(i, n)          for(int i = 1; i <= (n); i++)
#define circ(i, a, b)       for(int i = (a); i <= (b); i++)
#define range(i, a, b, c)   for(int i = (a); ((c) > 0 ? i <= (b) : i >= (b)); i += (c))
#define foreach(it, v)      for(__typeof((v).begin()) it = (v).begin(); it != (v).end(); it++)
#define y0          y0O0OO00OO0OO0OO0OOO00OO0OO0O0O000OO0
#define y1          y1II11II11III11I1III11II111IIII1II1I1
#define pub         push_back
#define pob         pop_back
#define mak         make_pair
typedef long long   ll;
typedef long double lf;
const int   Inf = 0x3f3f3f3f;
const ll    INF = 0x3f3f3f3f3f3f3f3fll;
/* Source code starts here */

int n;
ll x[1 << 18], y[1 << 18];
ll a[1 << 18], b[1 << 18];

int main() {
	scanf("%d", &n);
	cont(i, n) scanf("%lld%lld", x + i, y + i);
	cont(i, n) a[i] = x[i] + y[i], b[i] = x[i] - y[i];
	sort(a + 1, a + n + 1); sort(b + 1, b + n + 1);
	printf("%lld\n", max(a[n] - a[1], b[n] - b[1]));
	return 0;
}


Measured memory_bytes: 10008
from heapq import heappush, heappop
from collections import deque,defaultdict,Counter
import itertools
from itertools import permutations
import sys
import bisect
import string
sys.setrecursionlimit(10**6)
def SI():
    return input().split()
def MI():
    return map(int,input().split())
def I():
    return int(input())
def LI():
    return [int(i) for i in input().split()]
YN=['Yes','No']
mo=10**9+7

n,m=MI()
ids=[0]*m
pref=[[] for i in range(1+n)]
for i in range(m):
    p,y=MI()
    pref[p]+=[(i,y)]
for p in range(1,n+1):
    ls=pref[p]
    ls.sort(key=lambda x:x[1])
    c=1
    for i,y in ls:
        pid='0'*(6-len(str(p)))+str(p)
        cid='0'*(6-len(str(c)))+str(c)
        c+=1
        ids[i]=pid+cid
        
for iid in ids:
    print(iid)


Measured memory_bytes: 80416
import java.util.Scanner;

class Main{
  public static void main(String[] args){
    Scanner stdIn = new Scanner(System.in);
    int n = stdIn.nextInt();
    int[] r = new int[n];
    for(int i = 0; i < n; i++)
      r[i] = stdIn.nextInt();

    int maxv = r[1] - r[0];
    int minv = r[0];
    for(int j = 1; j < n; j++){
      int diff = r[j] - minv;
      if(diff > maxv)
        maxv = diff;
      if(minv > r[j])
        minv = r[j];
    }

    System.out.println(maxv);
  }
}

Measured memory_bytes: 100936
#include <stdio.h>
#include <string.h>
#include <math.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main(void)
{
    char s[100001];
    int num[100001] = {0};
    int n;

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

    int lCnt = 0, rCnt = 0, p;
    char tmp[5];
    rep(i, n + 1)
    {
        if (i == n)
        {
            int tmp = rCnt / 2 + lCnt / 2;
            //printf("tmp:%d\n", tmp);
            num[i - 1 - lCnt] = tmp;
            num[i - lCnt] = tmp;
            if (rCnt % 2)
                ++num[i - 1 - lCnt];
            if (lCnt % 2)
                ++num[i - lCnt];
        }

        else
        {
            if (tmp[0] == 'R' && s[i] == 'L')
                p = i;

            if (tmp[0] == 'L' && s[i] == 'R')
            {
                int tmp = rCnt / 2 + lCnt / 2;
                //printf("tmp:%d\n", tmp);
                num[i - 1 - lCnt] = tmp;
                num[i - lCnt] = tmp;
                if (rCnt % 2)
                    ++num[i - 1 - lCnt];
                if (lCnt % 2)
                    ++num[i - lCnt];
                rCnt = 0;
                lCnt = 0;
            }

            if (s[i] == 'R')
            {
                rCnt++;
                tmp[0] = 'R';
            }
            else
            {
                lCnt++;
                tmp[0] = 'L';
            }
        }
    }

    /*rep(i, n)
        printf("%c ", s[i]);
    putchar('\n');*/
    rep(i, n)
        printf("%d ", num[i]);
    putchar('\n');

    return 0;
}

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

int main() {
    int d,t,s;
    cin >> d >> t >> s;

    if(s*t >= d) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <cmath>
#include <cassert>


using namespace std;


signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	long long a, b;
	cin >> a >> b;
	cout << a * b / __gcd(a, b);
	return 0;
}

Measured memory_bytes: 256
/*  HARD WORK FOREVER PAYS  */
#include<bits/stdc++.h>
#define pb push_back
#define mk make_pair
#define f first
#define s second
#define turbo(){	\
	ios_base::sync_with_stdio(false); \
	cin.tie(NULL); \
}
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
int main() 
{ 
	turbo();
	map<string,int> mp;
	int n,i;
	cin>>n;
	string s;
	mp["AC"]=0;
	mp["WA"]=0;
	mp["TLE"]=0;
	mp["RE"]=0;
	for(i=0;i<n;i++){
		cin>>s;
		mp[s]++;
	}
	cout<<"AC"<<" x "<<mp["AC"]<<"\n";
	cout<<"WA"<<" x "<<mp["WA"]<<"\n";
	cout<<"TLE"<<" x "<<mp["TLE"]<<"\n";
	cout<<"RE"<<" x "<<mp["RE"]<<"\n";
	return 0;	
}

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

#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define MOD 1000000007

typedef long long ll;

using namespace std;
int main()
{
    int A, B, C, D, E, F;
    cin >> A >> B >> C >> D >> E >> F;
    int ansWater = 0, ansSuger = 0;
    
    for (int a = 1; a <= F / (100 * A); ++a)
    {
        int maxB = (F - 100 * A * a) / (100 * B);
        for (int b = 0; b <= maxB; ++b)
        {
            int water = 100 * A * a + 100 * B * b;
            int sugerMax = water * E / 100;
            for (int c = 0; c <= sugerMax / C; ++c)
            {
                int maxD = (sugerMax - C * c) / D;
                for (int d = 0; d <= maxD; ++d)
                {
                    int suger = C * c + D * d;
                    if (suger <= sugerMax && suger + water <= F)
                    {
                        if (suger * (ansWater + ansSuger) >= ansSuger * (water + suger))
                        {
                            ansWater = water;
                            ansSuger = suger;
                        }
                    }
                }
            }
        }
    }

    cout << ansWater + ansSuger << " " << ansSuger << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>  
#include <cmath>

using namespace std;

vector <long long> v;

int main()
{
	int n;
	long long h;
	cin >> n >> h;
	long long max = 0;
	for (int i = 0; i < n; ++i)
	{
		long long a, b;
		cin >> a >> b;
		if (a > max)
			max = a;
		v.push_back(b);
	}
	sort(v.begin(), v.end());
	long long count = 0;
	int i = n - 1;
	while (i >= 0 && v[i] > max && h > 0)
	{
		h -= v[i];
		i--;
		count++;
	}
	if (h > 0)
		count += ceil(h*1.0 / max);
	cout << count;
}

Measured memory_bytes: 1400
class BinaryIndexedTree:
    def __init__(self, size):
        self.data = [0] * (size+1)
        self.msb = 1 << (size.bit_length()-1)
    
    def add(self, i, w):
        i += 1
        while i < len(self.data):
            self.data[i] += w
            i += i & -i
    
    def get_sum(self, i):
        res = 0
        while i > 0:
            res += self.data[i]
            i -= i & -i
        return res

    def __getitem__(self, i):
        """
        [0,i)
        """
        if isinstance(i, slice):
            return self.get_sum(i.stop) if i.start is None else self.get_sum(i.stop) - self.get_sum(i.start)
        else:
            return 0 # fake value
    
    __setitem__ = add
    
    def bisect_left(self, v):
        """
        return smallest i s.t v <= sum[:i]
        """
        i = 0
        k = self.msb
        while k > 0:
            i += k
            if i < len(self.data) and self.data[i] < v:
                v -= self.data[i]
            else:
                i -= k
            k >>= 1
        return i
    
    def bisect_right(self, v):
        """
        return smallest i s.t v < sum[:i]
        """
        i = 0
        k = self.msb
        while k > 0:
            i += k
            if i < len(self.data) and self.data[i] <= v:
                v -= self.data[i]
            else:
                i -= k
            k >>= 1
        return i
    
    bisect = bisect_right

def naive(P):
    def it():
        for i in range(len(P)-1):
            for j in range(i+1,len(P)):
                yield sorted(P[i:j+1])[-2]
    return sum(it())

def solve(P):

    def it():
        bit = BinaryIndexedTree(len(P))
        for cnt, (v,i) in enumerate(sorted(((v,i) for i,v in enumerate(P)), reverse=True)):
            bit[i] += 1
            c = bit.get_sum(i)
            low1 = -1 if c <= 0 else bit.bisect_left(c)
            low2 = -1 if c <= 1 else bit.bisect_left(c-1)
            up1 = len(P) if c > cnt-1 else bit.bisect_left(c+2)
            up2 = len(P) if c > cnt-2 else bit.bisect_left(c+3)
            yield v*((up1-i)*(low1-low2)+(i-low1)*(up2-up1))
    return sum(it())


if __name__ == '__main__':
    N = int(input())
    P = list(map(int,input().split()))
    print(solve(P))

Measured memory_bytes: 93500
H, W = map(int,input().split())

pic = []
for i in range(H):
    a = list(input())
    if a != ["." for i in range(W)]:
        pic.append(a)

H = len(pic)
        
delete = [0 for i in range(W)]
for i in range(W):
    white = 0
    for j in range(H):
        if pic[j][i] == ".":
            white += 1
        if white == H:
            delete[i] += 1

for i in reversed(range(W)):
    if delete[i] == 1:
        for j in range(H):
            pic[j] = pic[j][0:i] + pic[j][i+1:]

for i in range(H):
    print(*pic[i], sep="")


Measured memory_bytes: 9424
#include <bits/stdc++.h>
#define M 1000000007
#define ll long long
#define endl "\n"
using namespace std;

int n, m;

ll dp[1001][1001];

char mat[1001][1001];


ll countWays(int x, int y)
{

	if (mat[x][y] == '#')
		return 0;

	if (x == n - 1 && y == m - 1)
		return 1;

	if (x < 0 || x >= n || y < 0 || y >= m)
		return 0;


	if (dp[x][y] != -1)
		return dp[x][y];


	return dp[x][y] = (countWays(x, y + 1) % M + countWays(x + 1, y) % M) % M;


}





int32_t main()
{


	cin >> n >> m;


	for (int i = 0; i < n; ++i)
	{
		for (int j = 0; j < m; ++j)
			cin >> mat[i][j];
	}



	memset(dp, -1, sizeof(dp));



	cout << countWays(0, 0) % M << endl;



}

Measured memory_bytes: 12512
import java.util.Scanner;
 
public class Main {
 
	public static void main(String[] args) {
 
		Scanner sc = new Scanner(System.in);
 
		long x = sc.nextLong();
		long k = sc.nextLong();
		long d = sc.nextLong();
 
		long ans;
		x = Math.abs(x);
 
		if (x / d >= k) {
			ans = x - k * d;
		} else {
			long tmp = x % d;
			long remain = k - x / d;
 
			if (remain % 2 == 0) {
				ans = tmp;
			} else {
				ans = d -tmp;
			}
 
		}
 
		System.out.println(ans);
 
		sc.close();
	}
 
}

Measured memory_bytes: 35916
S = input()
ans = "AC"

if S[0] != "A":
    ans = "WA"

cnt = 0

for i in range(1, len(S)):
    s = S[i]
    if s.isupper():
        if i == 1 or i == len(S) - 1 or s != "C":
            ans = "WA"
        cnt += 1

if cnt != 1:
    ans = "WA"

print(ans)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#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())
#define CLR(a) memset((a), 0, sizeof(a))
#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl;
#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())

//using LL = long long;
using namespace std;

const int dy[] = {0, 0, 1, -1};
const int dx[] = {1, -1, 0, 0};
const double EPS = 1e-10;
const double PI = acos(-1.0);

struct Stack{
    Stack(){
        top = 0;
    }

    int top;
    static const int byFull = 1000;
    int v[byFull];

    bool is_Empty(){
        if (top == 0) return true;
        else return false;
    }
    bool is_Full(){
        if (top >= byFull-1) return true;
        else return false;
    }
    void push(int x){
        if(is_Full())return;
        else {
            top++;
            v[top] = x;
        }
    }
    int pop(){
        if(is_Empty())return 0;
        else {
            top--;
            return v[top+1];
        }
    }
};

int calc(int x,string op,int y){
  if(op=="+")return x+y;
  if(op=="-")return x-y;
  if(op=="*")return x*y;
  else return 0;
}


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

    Stack s;

    int numA, numB;
    string str;
    while(cin >> str){

        if(str=="+"||str=="-"||str=="*"){
            numA=s.pop();
            numB=s.pop();
            s.push(calc(numB,str,numA));
        }else{
            numA=0;

            for(int i=0;i<(int)str.size();i++){
                numA*=10;
                numA+=str[i]-'0';
            }

        s.push(numA);
        }
    }

  cout<<s.pop()<<endl;
     
}


Measured memory_bytes: 3160
package main

import "fmt"

func main() {
	var N int
	fmt.Scan(&N)
	var n int
	var sameSums = make(map[int]int) //部分和が同じものの個数を数え上げたもの

	// nums[0]の初期化
	fmt.Scan(&n)
	prevk := n
	sameSums[n]++

	//空な部分列の和は0
	sameSums[0]++

	for i := 1; i < N; i++ {
		fmt.Scan(&n)
		k := prevk + n
		sameSums[k]++
		prevk = k
	}

	cnt := 0
	for _, v := range sameSums {
		cnt += combination(v, 2)
	}

	fmt.Println(cnt)
}

func combination(n, r int) int {
	a := 1
	b := 1
	for i := 0; i < r; i++ {
		a *= n - i
		b *= r - i
	}
	return a / b
}

func scanNums(length int) (nums []int) {
	var num int
	for i := 0; i < length; i++ {
		fmt.Scan(&num)
		nums = append(nums, num)
	}
	return
}


Measured memory_bytes: 12800
#include <iostream>
#include <string>
#include <vector>

#define fastIO (cin.tie(0), cout.tie(0), ios::sync_with_stdio(false))
#define rep(i, n) for (int i = 0; i < (n); ++i)

using lint = long int;
using llint = long long int;
using namespace std;

int main() {
    fastIO;

    int n;
    cin >> n;
    vector<int> takoyaki(n);
    rep(i, n) cin >> takoyaki.at(i);

    int total = 0;
    for (size_t i = 0; i < takoyaki.size() - 1; i++) {
        for (size_t j = i + 1; j < takoyaki.size(); j++) {
            total += takoyaki.at(i) * takoyaki.at(j);
        }
    }
    cout << total << endl;
}



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

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

void solve() {
    ll N;
    cin >> N;
    Vl A(N);
    for (ll i = 0; i < N; i++) {
        cin >> A[i];
    }

    ll ans = L_INF;
    for (ll i = 0; i < N; i++) {
        ll cnt = 0;
        while (A[i] > 0 && A[i] % 2 == 0) {
            ++cnt;
            A[i] /= 2;
        }
        ans = min(ans, cnt);
    }
    cout << ans << "\n";
}

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

int main() {
#ifdef FASTIO
    cin.tie(0), cout.tie(0);
    ios::sync_with_stdio(false);
#endif
#ifdef FILEINPUT
    ifstream ifs("./in_out/input.txt");
    cin.rdbuf(ifs.rdbuf());
#endif
#ifdef FILEOUTPUT
    ofstream ofs("./in_out/output.txt");
    cout.rdbuf(ofs.rdbuf());
#endif
    solve();
    cout << flush;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
using namespace std;
int main()
{
	int a, b, c;
	cin >> a >> b >> c;
	if (a != b && b != c&&a!=c)
	{
		cout << 3 << endl;
	}
	else if (a == b && b == c)
	{
		cout << 1 << endl;
	}
	else
	{
		cout << 2 << endl;
	}
	return 0;
}
/*
死のマウス
.　　あり許せん！
　　　∧＿＿∧
　|| （＃｀Д´ ） ||
　|| ( |　 　| | |||
　从| |　 　| |从从
￣) ⊂ノ￣￣!_つ￣て
　フヘ(　　　　ヽヘ(＼

*/

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <numeric>
#include <map>
#include <queue>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

#define ALL(V) (V).begin(),(V).end()

using namespace std;

typedef pair<int,int> ii_t;

#define MAX 100010
#define RMAX 1000
char is_prime[MAX];
#define PMAX 100000
int prime[PMAX];

int main() {
    string op;
    cin >> op;
    int n = op.size(); 
    vector<long long> number(n+1, 600000);

    for (int i=0;i<n;i++) {
        if (i==0 && op[i] == '<') {
            number[i] = 0;
            for (int j=i+1;j<=n;j++) {
                if(op[j-1]=='<'){
                    if (number[j]==600000 || number[j] < number[j-1]+1){
                        number[j] = number[j-1]+1;
                    }
                } else break;
            }
        } else if (i == n-1 && op[i] == '>') {
            number[i+1] = 0;
            for (int j=i;j>=0;j--) {
                if(op[j]=='>'){
                    if (number[j]==600000 || number[j] < number[j+1]+1){
                        number[j] = number[j+1]+1;
                    }
                } else break;
            }
        } else if (i+1 < n && op[i]=='>' && op[i+1]=='<') {
            number[i+1] = 0;
            for (int j=i+2;j<=n;j++) {
                if(op[j-1]=='<'){
                    if (number[j]==600000 || number[j] < number[j-1]+1){
                        number[j] = number[j-1]+1;
                    }
                } else break;
            }
            for (int j=i;j>=0;j--) {
                if(op[j]=='>'){
                    if (number[j]==600000 || number[j] < number[j+1]+1){
                        number[j] = number[j+1]+1;
                    }
                } else break;
            }
        }
    }

//    for (int j=0;j<=n;j++) {
//        cerr << number[j] << endl;
//    }

    cout << accumulate(ALL(number),0LL) << endl;

    return 0;
}


Measured memory_bytes: 4728
#include<algorithm>
#include<cstring>
#include<cctype>
#include<cstdio>
#define rep(i,x,y) for(int i=x; i<=y; ++i)

using namespace std;
typedef long long LL;
const int N=100005;
int n,m,x[N],a[N],id[N],trf[N],trf1[N];
LL d[N],K;

int getint()
{
	char ch;
	int f=1;
	while(!isdigit(ch=getchar())) if(ch=='-') f=-1;
	int x=ch-48;
	while(isdigit(ch=getchar())) x=x*10+ch-48;
	return x*f;
}

LL getLL()
{
	char ch;
	int f=1;
	while(!isdigit(ch=getchar())) if(ch=='-') f=-1;
	LL x=ch-48;
	while(isdigit(ch=getchar())) x=x*10+ch-48;
	return x*f;
}

void change(int id[],int trf[])
{
	rep(i,1,n-1) trf1[i]=trf[id[i]];
	rep(i,1,n-1) id[i]=trf1[i];
}

int main()
{
	n=getint();
	rep(i,1,n) x[i]=getint();
	rep(i,1,n-1) d[i]=x[i+1]-x[i],id[i]=trf[i]=i;
	m=getint(),K=getLL();
	rep(i,1,m)
	{
		int p=getint();
		swap(trf[p-1],trf[p]);
	}
	while(K)
	{
		if(K&1) change(id,trf);
		change(trf,trf),K>>=1;
	}
	LL p=x[1];
	rep(i,1,n)
	{
		printf("%lld\n",p);
		p+=d[id[i]];
	}
	return 0;
}

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

ll f(int n){
  ll res = 1;
  while (n){
    res *= 2;
    n--;
  }
  return res;
}

int main(){
  ll h;
  cin >> h;
  int cnt = 0;
  ll ans = 1;
  while (h > 1){
    h /= 2;
    ++cnt;
    ans += f(cnt);
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<map>
#include<cstdio>
#include<stack>
#include<queue>
#include<fstream>
#include<cstdio>
#include<deque>
#include<iomanip>
#include <numeric>
//#include<bits/stdc++.h>

using namespace std;
#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;++i)
#define REP(i,s,n) for(int i=(s);i<(n);++i)
#define repr(i,n) for(int i=n-1;i>=0;--i)
#define REPR(i,s,n) for(int i=(s);i>=(n);--(i))
#define all(a) (a).begin(),(a).end()
#define reall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
const double pi = acos(-1.0);

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef deque<ll> dll;
typedef pair<ll, ll> P;
const ll mod = 1e9 + 7;
ll dx[4] = { 1,0,-1,0 };
ll dy[4] = { 0,1,0,-1 };

ll n, w, m, k, ans = 0;
ll dp[100010];
vvll G;

ll calc(ll v) {
	if (dp[v] != -1) return dp[v];

	ll res = 0;
	for (auto x : G[v]) {
		res = max(res, calc(x) + 1);
	}
	return dp[v] = res;
}

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

	string s, t;
	cin >> n >> m;
	rep(i,n) dp[i] = -1;
	G.assign(n, vll());
	rep(i, m) {
		ll a, b;
		cin >> a >> b;
		--a, --b;
		G[a].pb(b);
	}

	rep(i, n) ans = max(ans, calc(i));
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 8576
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  ll n;
  cin >> n;
  vl a(26, 1e9);
  rep(i, n) {
    string s;
    cin >> s;
    vl b(26, 0);
    rep(j, s.size()) b[s[j] - 'a']++;
    rep(j, 26) a[j] = min(a[j], b[j]);
  }
  rep(i, 26) rep(j, a[i]) cout << char(i + 'a');
  cout << endl;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

const (
	initialBufSize = 10000
	maxBufSize     = 1000000
)

func main() {
	var wtr = bufio.NewWriter(os.Stdout)
	/*
		var N, A, B int
		fmt.Scan(&N, &A, &B)
	*/
	var sc = bufio.NewScanner(os.Stdin)
	buf := make([]byte, initialBufSize)
	sc.Buffer(buf, maxBufSize)
	sc.Scan()
	//temp := strings.Split(sc.Text(), " ")
	//N, _ := strconv.Atoi(temp[0])
	sc.Scan()
	temp := strings.Split(sc.Text(), " ")

	minp := 10000000000000
	for _, v := range temp {
		a, _ := strconv.Atoi(v)
		p := 2
		w := 0
		for {
			if a%p != 0 {
				break
			}
			w++
			p *= 2
		}
		if w < minp {
			minp = w
		}
	}

	fmt.Fprintln(wtr, minp)
	_ = wtr.Flush()
}


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

using namespace std;

int H[100000];

int main(void) {
  int N;
  cin >> N;
  vector<int> H(N);
  for (int i = 0; i < N;++i) {
    cin >> H[i];
  }

  int ans = 0;
  int cnt = 0;
  for (int i = 0; i < N - 1; ++i) {
    if (H[i] >= H[i + 1]) {
      cnt++;
      ans = max(ans, cnt);
    } else {
      cnt = 0;
    }
  }
  cout << ans << endl;
}


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

using namespace std;

#define int long long

#ifndef bhupixb
    #define var(...)
    #define stl(...)
#endif

#define rep(i,a,b) for (int i = a; i <= (int)b; ++i)
#define f first
#define s second

#define single_test


const int N = 3e5 + 5;
int a[N];
int tree[N << 2];
struct seg_tree {
    int combine(int x, int y)  {
        return max(x, y);
    }
    int query(int l, int r, int ql, int qr, int node) {
        if (l > r) return 0;

        if (qr < l || r < ql)
            return 0;
        if (ql <= l and r <= qr) {
            return tree[node];
        }
        int mid = l + r >> 1, lc = node + node, rc = 1 + lc;
        return combine(query(l, mid, ql, qr, lc), query(mid + 1, r, ql, qr, rc));
    }
    void update(int l, int r, int pos, int val, int node) {
        if (pos < l || r < pos)
            return;
        if (l == r and l == pos) {
            tree[node] = val;
            return;
        }
        int mid = l + r >> 1, lc = node + node, rc = 1 + lc;
        update(l, mid, pos, val, lc);
        update(mid + 1, r, pos, val, rc);
        tree[node] = combine(tree[lc], tree[rc]);
    }
};

const int maxn = 2e5 + 4;
int dp[maxn];

void solve() {
    int n;
    cin >> n;
    seg_tree ins;
    vector<int> a(n + 1), b(n + 1);
    rep(i,1,n) cin >> a[i];
    rep(i,1,n) cin >> b[i];
    for (int i = 1; i <= n; ++i) {
        int x = a[i];
        dp[x] = b[i];
        int q = ins.query(1, n, 1, x - 1, 1);
        dp[x] = max(dp[x], dp[x] + q);
        ins.update(1, n, x, dp[x], 1);
    }
    cout << *max_element(dp + 1, dp + 1 + n) << '\n';
}

signed main() {
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t = 1;
    #ifndef single_test
        cin >> t;
    #endif
    for (int i = 1; i <= t; ++i) {
        // cout << "Case #" << i << ": ";
        solve();
    }

    return 0;
}

Measured memory_bytes: 12116
#include<bits/stdc++.h>
using namespace std;
using UL = unsigned int;
using ULL = unsigned long long;
using LL = long long;
#define rep(i,n) for(UL i=0; i<(n); i++)

UL N;
UL F[45];

int main() {
 cin>>N;
 F[0]=F[1]=1;
 for(UL i=2; i<=N; i++){ F[i]=F[i-1]+F[i-2]; }
 cout<<F[N]<<endl;
 return 0;
}



Measured memory_bytes: 3076
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

#[derive(PartialEq, PartialOrd)]
pub struct Total<T>(pub T);

impl<T: PartialEq> Eq for Total<T> {}

impl<T: PartialOrd> Ord for Total<T> {
    fn cmp(&self, other: &Total<T>) -> std::cmp::Ordering {
        self.0.partial_cmp(&other.0).unwrap() 
    }
}

//https://qiita.com/hatoo@github/items/fa14ad36a1b568d14f3e
fn main() {
    let n: u64 = read();
    let mut a: Vec<f64> = (0..n).map(|_| read()).collect();

    while a.len() > 1 {
        a.sort_by_key(|&x| Total(x));
        let first = a[0];
        let second = a[1];
        let gen = (first + second) / 2.0;
        a.remove(0);
        a.remove(0);
        a.push(gen);
    }

    println!("{}", a[0]);

}


Measured memory_bytes: 4352
def inpl():
    return list(map(int, input().split()))


N = int(input())
D = inpl()
D.sort()

if D[N // 2] == D[N // 2 - 1]:
    print(0)
    exit()

base = D[N // 2] - D[N // 2 - 1]

print(base)


Measured memory_bytes: 13992
x,y,z = map(int,input().split())
if x == 5 and y == 7 and z == 5:
  print('YES')
elif x == 5 and y == 5 and z == 7:
  print('YES')
elif x == 7 and y == 5 and z == 5:
  print('YES')
else:
  print('NO')

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define rep(i, k, n) for(ll i = k; i < ll(n); i++)
using ll = long long;
int a[12][12];
const int INF = 1001001001;

int main(){
    int n, m, x;
    cin >> n >> m >> x;
    vector<int> c(n);
    rep(i, 0, n){
        cin >> c[i];
        rep(j, 0, m) cin >> a[i][j];
    }
    int ans = INF;
    rep(s, 0, 1 << n){
        int cost = 0;
        vector<int> d(m);
        rep(i, 0, n){
            if (s >> i & 1){
                cost += c[i];
                rep(j, 0, m) d[j] += a[i][j];
            }
        }
        bool check = true;
        rep(j, 0, m) if (d[j] < x) check = false;
        if (check) ans = min(ans, cost);
    }
    if (ans == INF) cout << -1 << endl;
    else cout << ans << endl;
    return 0;    
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<(n);i++)
#define MOD 1000000007
#define all(n) (n).begin(),(n).end()
typedef long long ll;
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}else{return 0;}}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}else{return 0;}}
template <class T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <class T> inline T LCM(T a,T b){return a*b/GCD(a,b);}

int main(){
	int k,x;
	cin >> k >> x;
	int a=x-k+1;
	FOR(i,2*k-1){
		cout << a << " ";
		a++;
	}
	cout << endl;
	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long long lint;
#define rep(i,n) for(int i=0;i<n;++i)
#define repi(i,a,b) for(int i=a;i<b;++i)
#define repr(i,n) for(int i=n-1;i>=0;--i)
#define co(x) cout<<x<<"\n"
ll INF=1000000007;
ll md=INF;

lint powmod_h;
lint powmod(lint a,int p){
	if(!p)return 1;
	if(p%2)return powmod(a,p-1)* a % md;
	else{
		powmod_h = powmod(a,p / 2);
		return powmod_h*powmod_h % md;
	}
}
inline lint modmul(lint a,lint b){
	return (a%md)*(b%md)%md;
}
inline lint moddiv(lint a,lint b){
	return modmul(a,powmod(b,md-2));
}

lint fact[100010]={},
     revfact[100010]={};
lint setFact(lint n){
    fact[0]=1;
    repi(i,1,n){
        fact[i]=fact[i-1]*i;
        fact[i]%=md;
    }
    revfact[n-1]=powmod(fact[n-1],md-2);
    repr(i,n-1){
        revfact[i]=revfact[i+1]*(i+1);
        revfact[i]%=md;
    }
}
inline lint ncr(lint a, lint b){
    if(a<b)return 0;
    return (((fact[a]*revfact[b])%md)*revfact[a-b])%md;
}

int main(){
ll n;
cin>>n;
setFact(n+2);//co(revfact[n]);co(ncr(31,1));co(endl);
vector<ll>vec(n+1);
ll left,right;
vector<ll> dp(n+1,-1);
for(int i=0;i<=n;i++){
int k;
cin>>k;
if(dp[k]!=-1){left =dp[k];right=i;continue;}
dp[k]=i;
}


for(int i=1;i<n+2;i++){
ll ans=0;
ans+=ncr(n+1,i);
ans=(ans+INF-ncr(left+(n-right),i-1))%INF;
cout << ans << endl;
}

}



Measured memory_bytes: 4352
#include <algorithm>
#include <climits>
#include <cmath>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>
#include <deque>
 
// author:Swastik Banerjee
 
using namespace std;
 
typedef long long ll;
#define MOD 1000000007
 
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
 

 
 
  ll N,M; cin>>N>>M;

  ll ans= N*(N-1)/2 + M*(M-1)/2;

  cout<<ans;



  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
int h, w, k, x1, yy1, x2, y2, d[4] = {1,-1}, mp[2000005], qu[1000005], b, e, inf=1e9;
int main(){
	scanf("%d%d%d", &h, &w, &k); w++;
	scanf("%d%d%d%d", &x1, &yy1, &x2, &y2); x1--; x2--;
	memset(mp,-1,sizeof(mp));
	for(int i=0; i<h*w; i++) if(getchar() == '.') mp[i] = inf;
	mp[qu[e++] = x1*w+yy1] = 0;
	d[2] = w; d[3] = -w;
	while(b<e) for(int i=0, x=qu[b++]; i<4; i++) for(int nx=x+d[i], u=0; u<k && 0<=nx && mp[nx]>mp[x]; u++, nx+=d[i]) if(mp[nx] == inf) mp[qu[e++] = nx] = mp[x] + 1;
	printf("%d\n", mp[x2*w+y2] == inf ? -1 : mp[x2*w+y2]);
}

Measured memory_bytes: 14540
N = int(input())
s = [input() for _ in range(N)]
for i in range(0, N):
    s[i] = "".join(sorted(s[i]))
t = {}
c = 0
for i in range(0, N):
    if s[i] in t:
        c = c+t[s[i]]
        t[s[i]] = t[s[i]]+1
    else:
        t[s[i]] = 1
print (c)

Measured memory_bytes: 19476
#include<iostream>
#include<algorithm>
#include <iostream> 
#include <algorithm> 
#include<string>
#include<queue>
#include<utility>
#include<fstream>
#include<queue>
#include<set>
#include<stack>
#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define I(a) scanf("%d",&a)
#define I2(a,b) scanf("%d%d",&a,&b)
#define I3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define L(a) scanf("%lld",&a)
#define L2(a,b) scanf("%lld%lld",&a,&b)
#define L3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define PI(a) printf("%d",a)
#define PL(a) printf("%lld",a)
#define PT(t) printf("Case %d: ",t)
#define PB push_back
#define x first
#define y second
#define xx first.first
#define xy first.second
#define yx second.first
#define yy second.second
#define SC scanf
#define PC printf
#define NL printf("\n")
#define SET(a) memset(a,0,sizeof a)
#define SETR(a) memset(a,-1,sizeof a)
#define SZ(a) ((int)a.size())-1
#define f(i,a,b) for(int i=a;i<=b; i++)
#define fr(i,a,b) for(int i=a;i<=b; i++)
#define frr(i,a,b) for(int i=a;i>=b; i--)
#define frv(i,a)  for(int i=0;i<a.size();i++)
#define pi 2.0*acos(0.0)
#define R(a) freopen(a, "r", stdin);
#define W(a) freopen(a, "w", stdout);
#define CB(x) __builtin_popcount(x)
#define STN(a) stringtonumber<ll>(a)
#define lol printf("BUG\n")
#define Endl "\n"
#define mk make_pair
using namespace std;
template <class T> inline T BM(T p, T e, T M)
{
    ll ret = 1;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret * p) % M;
        p = (p * p) % M;
    }
    return (T)ret;
}
template <class T> inline T gcd(T a, T b)
{
    if(b == 0)return a;
    return gcd(b, a % b);
}
template <class T> inline T mdINV(T a, T M)
{
    return BM(a, M - 2, M);
}
template <class T> inline T PW(T p, T e)
{
    ll ret = 1;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret * p);
        p = (p * p);
    }
    return (T)ret;
}
 
 
template <class T>bool ISLEFT(T a, T b, T c)
{
    if(((a.xx - b.xx) * (b.yy - c.yy) - (b.xx - c.xx) * (a.yy - b.yy)) < 0.0)return 1;  //Uporer dike //A,b,c, x okkher ordera sorted
    else return 0;
}
 
 
typedef pair<int,int >P;
//////////////////////////
/////////////////////////
int main(){
  int n,m;
  cin>>n>>m;

  int ar[ n+2];
  for(int i=1;i<=n;i++)ar[i] = -1;
  
  for(int i=1;i<=m;i++){
      int x,y;
      I2(x,y);
      if(ar[x] ==-1 || ar[x] ==y)ar[x] =y;
      else {
          cout<<(-1)<<endl;
          return 0;
      }
  }
  if(n > 1 && ar[1] == 0)cout<<(-1)<<endl;
  else{
        if(n > 1 &&ar[1] == -1)ar[1] = 1;
        for(int i=1;i<=n;i++){
            if(ar[i] == -1)ar[i] = 0;
            cout<<ar[i];
        }
      cout<<endl;
  }
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <numeric>
#include <queue>
#include <string>
#include <vector>

using namespace std;
const double PI = 3.14159265358979323846;
int main() {
    int A, B;
    cin >> A >> B;
    cout << A * B << endl;
}


Measured memory_bytes: 3632
package main

import (
	"bufio"
	"os"
	"strconv"
	"fmt"
)

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024*1024), bufio.MaxScanTokenSize)
}

//func nextString() string {
//	sc.Scan()
//	return sc.Text()
//}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func nextUint64() uint64 {
	sc.Scan()
	i, e := strconv.ParseUint(sc.Text(), 10, 64)
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	n := nextInt()
	k := nextInt()
	a := make([]uint64, n, n)

	for i := 0; i < n; i++ {
		a[i] = nextUint64()
	}

	for j := k; j < n; j++ {
		if a[j] > a[j - k] {
			fmt.Println("Yes")
		} else {
			fmt.Println("No")
		}
	}
}

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

typedef long long ll;

int main() {
    ll n; cin >> n;
    ll a[n];
    set <ll> arr;
    for(ll i = 0; i < n; i++) {
        ll x;
        cin >> x;
        arr.insert(x);
    }

    if(arr.size() != n) cout << "NO";
    else cout << "YES";

    return 0;
}   

Measured memory_bytes: 9600
#include<iostream>
int main() {
		int a, b, c, d, n;
		std::cin >> n;
		a = n / 1000;
		b = n % 1000 / 100;
		c = n % 100 / 10;
		d = n % 10;
		if (a == b&&b == c) {
				std::cout << "Yes" << std::endl;
		
	}
		else if (b == c&&b == d) {
				std::cout << "Yes" << std::endl;
		
	}
		else {
			std::cout << "No" << std::endl;
	}
}


Measured memory_bytes: 256
/*
csc -debug B.cs && mono --debug B.exe <<< "2 10 20"
*/

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Reflection;

public class HelloWorld {
    public static void SolveCodeForces() {
        var r = cin.NextLong();
        var d = cin.NextLong();
        var x = cin.NextLong();

        for (var i = 1; i <= 10; i++) {
            x = r*x-d;
            System.Console.WriteLine(x);
        }
    }

    static Scanner cin = new Scanner();
    static StringBuilder cout = new StringBuilder();

    static public void Main () {
        SolveCodeForces();
        // IncreaseStack(SolveCodeForces);
        // System.Console.Write(cout.ToString());
    }

    public static void IncreaseStack(ThreadStart action, int stackSize = 128000000)
    {
        var thread = new Thread(action, stackSize);
        thread.Start();
        thread.Join();
    }
}

public static class Helpers {
    public static T[] CreateArray<T>(int length, Func<int, T> itemCreate) {
        var result = new T[length];
        for (var i = 0; i < result.Length; i++)
            result[i] = itemCreate(i);
        return result;
    }
}

public class Scanner
{
    private string[] line = new string[0];
    private int index = 0;

    public string Next() {
        if (line.Length <= index) {
            line = Console.ReadLine().Split(' ');
            index = 0;
        }
        var res = line[index];
        index++;
        return res;
    }

    public int NextInt() {
        return int.Parse(Next());
    }

    public long NextLong() {
        return long.Parse(Next());
    }

    public ulong NextUlong() {
        return ulong.Parse(Next());
    }

    public string[] Array() {
        line = Console.ReadLine().Split(' ');
        index = line.Length;
        return line;
    }

    public int[] IntArray(int emptyPrefixLen = 0) {
        var array = Array();
        var result = new int[emptyPrefixLen + array.Length];
        for (int i = 0; i < array.Length; i++)
            result[emptyPrefixLen + i] = int.Parse(array[i]);
        return result;
    }

    public long[] LongArray() {
        var array = Array();
        var result = new long[array.Length];
        for (int i = 0; i < array.Length; i++)
            result[i] = long.Parse(array[i]);
        return result;
    }

    public ulong[] UlongArray() {
        var array = Array();
        var result = new ulong[array.Length];
        for (int i = 0; i < array.Length; i++)
            result[i] = ulong.Parse(array[i]);
        return result;
    }
}

Measured memory_bytes: 13140
n, m = gets.split.map(&:to_i)
a, b = Array.new(m) { gets.split.map(&:to_i) }.transpose
o = Array.new(n + 1) { [] }
count = 0

a.zip(b).each do |a, b|
  o[a] << b
  o[b] << a
end

o = Marshal.dump(o)

a.zip(b).each do |a, b|
  g = Marshal.load(o)
  g[a].delete(b)
  g[b].delete(a)

  dist = Array.new(n + 1) { nil }
  dist[1] = 0
  q = [1]

  while q.any?
    v = q.shift

    g[v].each do |i|
      next if dist[i]

      dist[i] = dist[v] + 1
      q << i
    end
  end

  dist.shift
  count += 1 if dist.include?(nil)
end

puts count

Measured memory_bytes: 1788
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <time.h>
#include <set>


void bfs(const std::vector<std::vector<int> >& tree, const std::vector<int64_t>& cnt,int64_t add, int current,int parent,std::vector<int64_t>& ans){
    for(auto val:tree[current]) {
       if(val==parent) continue;
       ans[val] = add + cnt[val];
       bfs(tree,cnt,add + cnt[val],val,current,ans);
    }
}

int main() {
    int N,Q;
    std::cin >>N >>Q;
    std::vector<int64_t> cnt(N,0);
    std::vector<std::vector<int> > tree(N,std::vector<int>());
    int n = 1;
    while( n++<N) {
       int a,b;
        std::cin>> a >> b;
        tree[a-1].push_back(b-1);
        tree[b-1].push_back(a-1);
    }
    int q = 0;
    while( q++<Q) {
       int p,x;
        std::cin>> p >> x;
        cnt[p-1] += x;
    }
    std::vector<int64_t> ans(N,0);
    ans[0] = cnt[0];
    bfs(tree,cnt,cnt[0],0,-1,ans);
    for(auto val: ans) {
        std::cout << val << " ";
    }
}

Measured memory_bytes: 32128
#include <stdio.h>

int hoge[4][3][10];
int n; //???????????¶??°
int b; //?£???????
int f; //?????°
int r; //??¨?±???????
int v; //?????°
int i;
int j;
int k;

main(){
	scanf("%d",&n);
	int i = 0;
	while(1){
		if(i == n){
			break;
		}
		scanf("%d %d %d %d",&b,&f,&r,&v);
		b--;
		f--;
		r--;
		hoge[b][f][r]+= v;
		i++;
		}
	for(i=0; i<4; i++){
		for(j=0; j<3; j++){
			for(k=0; k<10; k++){
				printf(" %d",hoge[i][j][k]);
			}
			printf("\n");
		}
		if(i != 3){
			printf("####################\n");
		}
	}
	return 0;
}
		

Measured memory_bytes: 612
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define in(x) cin >> x
#define out(str) cout << str << endl

#define mod 1000000007

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

int N,four=0,two=0;

int main(){
    cin>>N;
    int a[N];
    rep(i,N){
        cin>>a[i];
        if(a[i]%4==0){
            four+=2;
        }
        else if(a[i]%2==0){
            two++;
        }
    }
    if(two)N-=two-1;
    N-=four+1;
    if(N<=0){
        out("Yes");
    }
    else{
        out("No");
    }
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(0)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
#define int long long
const int MOD=1e9+7;
const int N=2e5+5;
int a[N];
int32_t main()
{
    IOS;
    int n;
    cin>>n;
    map<int,int>mp;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
        mp[a[i]]++;
    }
    int ans1=0;
    for(auto it:mp)
    {
        if(it.ss==1)
            continue;
        if(it.ss%2==0)
        {
            ans1++;
        }
    }
    int ans=mp.size();
    if(ans1%2==0)
    {
        cout<<ans<<endl;
    }
    else
        cout<<ans-1<<endl;




}

Measured memory_bytes: 7296
#include<bits/stdc++.h>
using namespace std;
#define all(v) ((v).begin()),((v).end())
#define ll long long
#define fastIO cout << fixed << setprecision(9), ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)
double const EPS = 1e-9, PI = acos(-1);
const int N = 1e5 + 9, M = 1e3 + 9, OO = 1e9 + 7, MOD = 1e9 + 7;
const ll inf = 1e18;


ll add(ll a, ll b) {
  a += b;
  if(a >= MOD)
    a -= MOD;
  if(a < 0)
    a += MOD;
  return a;
}

char arr[M][M];
ll dp[M][M];

int main() {
  fastIO;
#ifdef LOCAL
  freopen("input.in", "rt", stdin);
#endif
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      cin >> arr[i][j];
    }
  }
  dp[0][0] = 1;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      if(arr[i][j] == '#') continue;
      if(i)
        dp[i][j] = add(dp[i][j], dp[i-1][j]);
      if(j)
        dp[i][j] = add(dp[i][j], dp[i][j-1]);
    }
  }
  cout << dp[n-1][m-1];
  return 0;
}


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

using namespace std;

#define rep(i,n) for(int i=0;i<(n);++i)
#define out(S) cout<<(S)<<endl;
#define ShowAll(collection) for(auto i:collection){out(i);}
#define beginend(v) v.begin(),v.end()

using pii=pair<int,int>;
using ll=long long;
using ull=unsigned long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vvc=vector<vector<char>>;
using ti3=tuple<int,int,int>;
template<typename T> void removeAt(vector<T>& v, int index) { v.erase(v.begin() + index); }

int N,M,K,D[16];
bool used[1<<16];
int G[101][101];

int solve(){
  cin >> N>>M>>K;
  rep(i,1<<16) used[i]=false;
  rep(i,M) cin>>D[i],D[i]--;
  rep(i,N)rep(j,K){
    int v;
    cin >> v;
    v--;
    G[i][j]=-1;
    rep(k,M) if(i==D[k]) rep(l,M) if(v==D[l]) G[i][j]=l;
  }

  queue<pii> Q;
  Q.push(pii((1<<M)-1,0));

  while(!Q.empty()){
    int s,distance;
    tie(s,distance)=Q.front();Q.pop();

    if(used[s]) continue;
    used[s]=true;
    if(s==0) return distance;

    rep(i,K){
      int t=0;
      rep(j,M) if(((s>>j)&1) && G[D[j]][i] >= 0) t|=1<<G[D[j]][i];
      Q.push(pii(t,distance+1));
    }
  }
  return 0;
}

int main(){
  out(solve());
}



Measured memory_bytes: 32548
#include <bits/stdc++.h>
using namespace std;
const int maxn=1e5+100;
int a[maxn],b[maxn];
int main()
{
    int n;
    cin>>n;
    for(int i=0;i<n;i++){
        int d;
        cin>>d;
        if(i%2==0){
            a[d]++;
        }
        else{
            b[d]++;
        }
    }
    int maxx=0,premax=0,maxid=0;
    for(int i=1;i<=1e5;i++){
        if(b[i]>maxx){
            maxx=b[i];
            maxid=i;
        }
    }
    b[maxid]=0;
    for(int i=1;i<=1e5;i++){
        premax=max(premax,b[i]);
    }
    int ans=0x3f3f3f3f;
    for(int i=1;i<=1e5;i++){
        int d;
        if(maxid==i){
            d=premax;
        }
        else d=maxx;
        ans=min(ans,n-a[i]-d);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1024