akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n, a, b, c, d;
int main() {
    cin >> n >> a >> b >> c >> d;
    n--;
    if (c <= abs((double)(b - a) / (double)n) && abs((double)(b - a) / (double)n) <= d)
        return printf("YES"), 0;
    for (int i = 0; i < n; i++) {
        ll l = a + (ll)i * (ll)c - b, r = a + (ll)i * (ll)d - b, mid;
        while (l <= r) {
            mid = (l + r) >> 1;
            if (c * (n - i) > mid) l = mid + 1;
            else if (d * (n - i) < mid) r = mid - 1;
            else return printf("YES"), 0;
        }
    }
    return printf("NO"), 0;
}

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

int CalcSumOfDigit(int n){
  int sum = 0;
  while(n > 0){
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

int main() {
  int N;
  cin >> N;
  
  int sum_sum = 0;
  int sum_min = 100000;
  for(int i=1;i<N;i++){
    sum_sum = CalcSumOfDigit(i) + CalcSumOfDigit(N-i);
    if(sum_sum < sum_min ){
      sum_min = sum_sum;
    }
  }
  cout << sum_min << endl;
}

Measured memory_bytes: 256
from sys import stdin
import numpy as np
N = int(stdin.readline().rstrip())
data = [int(x) for x in stdin.readline().rstrip().split()]
top = 0
flag = True
for i in data:
    if (top - i) > 1:
        flag = False
    if i > top:
        top = i
if flag:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 23096
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace  std;

#define ll long long
#define ull unsigned long long
#define f first
#define s second
typedef pair<int , int > pii;
typedef pair<ll,ll> pll;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// find_by_order(k)  returns iterator to kth element starting from 0;
// order_of_key(k) returns count of elements strictly smaller than k;
// erase,insert same as normal set

const ll MOD = 1e9+7;


void min_self(ll &a , ll b){a=min(a,b);}
void max_self(ll &a, ll b){a=max(a,b);}
ll add(ll x, ll y){return (x + y) % MOD;}
ll sub(ll x, ll y){return add(x, MOD - y);}
ll mul(ll x, ll y){return (x * 1ll * y) % MOD;}
ll binpow(ll x, ll y)
{
    ll z = 1;
    while(y > 0)
    {
        if(y % 2 == 1)
            z = mul(z, x);
        x = mul(x, x);
        y /= 2;
    }
    return z;
}
ll inv(ll x){return binpow(x, MOD - 2);}
const int MXN = 1e6+10;
ll fact[MXN];
void fac_pre()
{
    fact[0]=1;
    for(ll i=1; i<MXN; i++){
        fact[i]=mul(fact[i-1],i);
    }
}
ll C(ll n, ll k)
{
    return mul(fact[n], inv(mul(fact[k], fact[n - k])));
}

ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
///--//
int  main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("input.txt", "r", stdin);
    /* KEEP IN MIND
     * take care when sorting a 1 based indexed vector
     * const int N is defined way above in the starting
    */
    int n; cin>>n;
    int ans=0;
    for(int i=1; i<=n; i++){
        int x; cin>>x;
        if( i % 2 == 1 && x % 2 == 1) ans++;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3624
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
#include<iomanip>
#include<tuple>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<LL,int> LP;
const int INF=1<<30;
const LL MAX=1e9+7;

void array_show(int *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%d%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(LL *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%lld%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(vector<int> &vec_s,int vec_n=-1,char middle=' '){
	if(vec_n==-1)vec_n=vec_s.size();
	for(int i=0;i<vec_n;i++)printf("%d%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}
void array_show(vector<LL> &vec_s,int vec_n=-1,char middle=' '){
	if(vec_n==-1)vec_n=vec_s.size();
	for(int i=0;i<vec_n;i++)printf("%lld%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}

int main(){
	int n,m;
	int i,j,k;
	int a,b,c;
	cin>>a>>b;
	cout<<b*2-a<<endl;
}

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

#define ll long long
#define MAX 300005
#define pp pair<int,pair<int,pair<int,int>>>
#define pb push_back
#define mod 1000000007

using namespace std;

/*
 * author: Kruti_20
 */

ll power(ll x, ll y);

ll gcd(ll a, ll b);

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s, t;
    cin >> s >> t;
    vector<int> v[26];
    for (int i = 0; i < s.length(); i++) v[s[i] - 'a'].push_back(i);
    for (int i = 0; i < t.length(); i++) {
        if (v[t[i] - 'a'].size()) continue;
        else {
            cout << "-1\n";
            return 0;
        }
    }
    ll count = 0;
    ll prev_idx = 0;
    ll idx = 0;
    for (int i = 1; i < t.length(); i++) {
        idx = lower_bound(v[t[i] - 'a'].begin(), v[t[i] - 'a'].end(), v[t[i - 1] - 'a'][prev_idx] + 1) - v[t[i] - 'a'].begin();
        if (idx == v[t[i] - 'a'].size()) {
            count++;
            idx = lower_bound(v[t[i] - 'a'].begin(), v[t[i] - 'a'].end(), 0) - v[t[i] - 'a'].begin();
        }
        prev_idx = idx;
    }
    cout << count * s.length() + v[t[t.length() - 1] - 'a'][prev_idx] + 1ll;
    return 0;
}

ll power(ll x, ll y) {
    ll res = 1;
    x = x % mod;
    while (y > 0) {
        if (y & 1) res = (res * x) % mod;
        y = y >> 1;
        x = (x * x) % mod;
    }
    return res;
}

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

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

ll a[100009], mod = 1e9+7;

ll bigmod(ll b, ll p)
{
    if(p == 0)
        return 1;
    ll x = 1, y;
    if(p&1)
        x = b%mod;
    y = bigmod(b, p>>1);
    return ((y*y)%mod*x)%mod;
}



int main()
{
    ll n, k, i, j;
    cin >> n >> k;
    for(i = 0; i < n; i++)
        cin >> a[i];
    sort(a, a+n);
    ll p = 1, ans = a[k-1] - a[n-k];
    for(i = k; i <= n-1; i++)
    {
        p = (p*(i*bigmod(i-k+1, mod-2)%mod))%mod;
        ans = (ans + p*(a[i] - a[n - i - 1])%mod)%mod;
    }

    cout << (ans + mod)%mod;
}


Measured memory_bytes: 1024
import sys
import math
from collections import defaultdict

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N,num):
    if N<=0:
        return [[]]*num
    elif num==1:
        return [I() for _ in range(N)]
    else:
        read_all = [tuple(II()) for _ in range(N)]
        return map(list, zip(*read_all))

#################

N,u,v = II()
A,B = Line(N-1,2)

def edges_to_pt(s,t,n,directed=False):
    pt = [[] for _ in range(n)]
    for i in range(len(s)):
        pt[s[i]-1].append(t[i]-1)
        if directed==False:
            pt[t[i]-1].append(s[i]-1)
    return pt

def bfs(pt,v):
    n = len(pt)
    d = [-1]*n
    d[v] = 0
    q = [v]
    c = 1
    while q:
        q1 = []
        for i in q:
            for j in pt[i]:
                if d[j]==-1:
                    d[j] = c
                    q1.append(j)
        q = q1
        c += 1
    return d

pt = edges_to_pt(A,B,N)
du = bfs(pt,u-1)
dv = bfs(pt,v-1)

ans = 0
for i in range(N):
    if du[i]>=dv[i]:
        continue
    elif len(pt[i])>=2:
        continue
    else:
        ans = max(ans,dv[i]-1)

print(ans)

Measured memory_bytes: 72924
n, m = map(int, input().split())
d = [int(input()) for _ in range(n)]
c = [int(input()) for _ in range(m)]
h = [[0 for _ in range(m)] for _ in range(n)]
for i in range(n):
    for j in range(i, m):
        if i == j:
            h[i][j] = h[i -1][j - 1] + d[i] * c[j]
        else:
            h[i][j] = min(h[i][j - 1], h[i - 1][j - 1] + d[i] * c[j])
            
print(h[n - 1][m - 1])


Measured memory_bytes: 19652
#include <cstring>
#include <iostream>
#include <string>
using namespace std;

int main() {
	int n;
	while (cin >> n, n) {
		int g[10];
		memset(g, 0, sizeof(g));
		for (int i = 0; i < n; i++) {
			int x;
			cin >> x;
			g[x]++;
		}
		for (int i = 0; i < 10; i++) {
			if (g[i] == 0) cout << '-' << endl;
			else {
				cout << string(g[i], '*') << endl;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 1196
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author varunvats32
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BDigits solver = new BDigits();
        solver.solve(1, in, out);
        out.close();
    }

    static class BDigits {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int k = in.nextInt();

            int count = 0;

            while (n > 0) {
                n = n / k;
                count++;
            }

            out.println(count);
        }

    }
}



Measured memory_bytes: 23120
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<algorithm>
#include<iostream>
#include<string>
#include<cstring>

using namespace std;

int main()
{
	int a,b,c,d;
	while(~scanf("%d %d %d %d",&a,&b,&c,&d))
	{
		if(a+b>c+d)
			printf("Left\n");
		if(a+b<c+d)
			printf("Right\n");
		if(a+b==c+d)
			printf("Balanced\n");
	}
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

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

		long result = (long)a * b / gcd(a, b);
		System.out.println(result);
	}

	public static int gcd(int a, int b) {
		return b == 0 ? a : gcd(b, a % b);
	}
}

Measured memory_bytes: 23892
//abc147_a.cpp
//Sun Dec  8 21:00:16 2019

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;

int main(){
	int n,m,l;
	cin >> n >> m >> l;

	if (n+m+l>=22){
		cout << "bust"<< endl;
	}else {
		cout << "win" << endl;
	}
//	printf("%.4f\n",ans);
}

Measured memory_bytes: 256
import sys
from collections import *
import heapq
import math
import bisect
from itertools import permutations,accumulate,combinations,product
from fractions import gcd
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]

n,m=map(int,input().split())
x=list(map(int,input().split()))
y=list(map(int,input().split()))

tmp1=0
tmp2=0
for i in range(n-1):
    tmp1+=(i+1)*(n-1-i)*(x[i+1]-x[i])
    tmp1%=mod
for j in range(m-1):
    tmp2+=(j+1)*(m-1-j)*(y[j+1]-y[j])
    tmp2%=mod
# print(tmp1,tmp2)

print(tmp1*tmp2%mod)

Measured memory_bytes: 100244
program reconciled;
uses math;
const
  md: int64 = 1000000007;
  f10000: int64 = 531950728;
  f20000: int64 = 368774859;
  f30000: int64 = 548996970;
  f40000: int64 = 422550956;
  f50000: int64 = 737935835;
  f60000: int64 = 309944332;
  f70000: int64 = 296716438;
  f80000: int64 = 65533322;
  f90000: int64 = 851076783;
  f100000: int64 = 457992974;
function fact(n: int64): int64;
var
  i, k, f: int64;
begin
  f := f100000;
  k := 100001;
  if n < 100000 then
  begin
    f := f90000;
    k := 90001;
  end;
  if n < 90000 then
  begin
    f := f80000;
    k := 80001;
  end;
  if n < 80000 then
  begin
    f := f70000;
    k := 70001;
  end;
  if n < 60000 then
  begin
    f := f50000;
    k := 50001;
  end;
  if n < 50000 then
  begin
    f := f40000;
    k := 40001;
  end;
  if n < 40000 then
  begin
    f := f30000;
    k := 30001;
  end;
  if n < 30000 then
  begin
    f := f20000;
    k := 20001;
  end;
  if n < 20000 then
  begin
    f := f10000;
    k := 10001;
  end;
  if n < 10000 then
  begin
    f := 1;
    k := 1;
  end;
  for i := k to n do
    f := i*f mod md;
  fact := f;
end;
var
  n, m, x: int64;
begin
  read(n, m);
  if abs(n-m) > 1 then
  begin
    writeln(0);
    halt(0);
  end;
  x := ifthen(n = m, 2, 1);
  x := x*fact(n) mod md;
  x := x*fact(m) mod md;
  writeln(x);
end.

Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <tuple>
#include <queue>
#include <bitset>
#include <set>
#include <map>
#include <list>

using ll = long long;
using ld = long double;
using namespace std;
const int INF = 1e9+100;
const ll INF64 = 7e18l;
const int mod = 1000000007;
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(a) (a).begin(), (a).end()
#define FIN ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);

vector<pair<long long, long long> > prime_factorize(long long n) {
    vector<pair<long long, long long> > res;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0) { ++num; n /= p; }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}



int main(){
    FIN;
    ll n; cin >> n;
    auto pf = prime_factorize(n);

    ll ans = 0;
    for(auto p : pf){
        ans += (sqrt(1+8*p.second)-1)/2;
    }

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



Measured memory_bytes: 3664
import std.stdio, std.string, std.conv, std.range;
import std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, std.random, core.bitop;

enum inf = 1_001_001_001;
enum infl = 1_001_001_001_001_001_001L;

void main() {
    int N, M;
    scan(N, M);
    auto a = readln.split.to!(int[]);
    auto rem = N - a.sum();
    writeln(rem >= 0 ? rem : -1);
}

void scan(T...)(ref T args) {
    auto line = readln.split; // @suppress(dscanner.suspicious.unmodified)
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront;
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;
    foreach (arg; args)
        if (x > arg) {
            x = arg;
            isChanged = true;
        }
    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;
    foreach (arg; args)
        if (x < arg) {
            x = arg;
            isChanged = true;
        }
    return isChanged;
}

void yes(bool ok, string y = "Yes", string n = "No") {
    return writeln(ok ? y : n);
}


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

ll item[3005][3005];
ll dp[3005][3005][4];

int main(){
  int r,c,k;
  cin>>r>>c>>k;
  rep(i,r) rep(j,c) item[i][j]=-1;
  rep(i,k){
    int r,c,v;
    cin>>r>>c>>v;
    r--; c--;
    item[r][c]=v;
  }

  rep(i,r) rep(j,c) rep(k,4){
    dp[i][j][k]=-1;
  }
  dp[0][0][0]=0;
  if(item[0][0]!=-1) dp[0][0][1]=item[0][0];
  rep(i,r) rep(j,c){
    if(i>0){
      rep(k,4){
	if(dp[i-1][j][k]!=-1){
	  dp[i][j][0]=max(dp[i][j][0],dp[i-1][j][k]);
	  if(item[i][j]!=-1) dp[i][j][1]=max(dp[i][j][1],dp[i-1][j][k]+item[i][j]);
	}
      }
    }
    if(j>0){
      rep(k,4){
	if(dp[i][j-1][k]!=-1){
	  dp[i][j][k]=max(dp[i][j][k],dp[i][j-1][k]);
	}
      }
      rep(k,3){
	if(dp[i][j-1][k]!=-1){
	  if(item[i][j]!=-1) dp[i][j][k+1]=max(dp[i][j][k+1],dp[i][j-1][k]+item[i][j]);
	}
      }
    }
  }

  /*
  rep(k,4){
    rep(i,r){
      rep(j,c){
	cout<<dp[i][j][k]<<' ';
      }
      cout<<endl;
    }
    cout<<endl;
  }
  */
  
  ll ans=0;
  rep(i,4) ans=max(dp[r-1][c-1][i],ans);
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 355456
n = int(input())
a = list(map(int, input().split()))

a.append(0)

money = 1000
h = a[0]
l = a[0]

for i in a:
  if h < i:
    h = i
  elif h > i and h > l:
    money = money//l * h + money%l
    h = l = i
  elif h > i:
    h = i
  if l > i:
    l = i

print(money)

Measured memory_bytes: 9200
import math
A, B, H, M = map(int, input().split())

dig = abs((30*H+(M/60)*30)-6*M)
dig = min(dig, 360-dig)
rad = math.radians(dig)
c=math.sqrt(A**2+B**2-2*A*B*math.cos(rad))
print(c)

Measured memory_bytes: 9316
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long n,m;
	scanf("%lld %lld",&n,&m);
	if(n == 1 && m == 1)
		printf("1\n");
	else if(n == 1)
		printf("%lld\n",n*m - 2);
	else if( m == 1)
		printf("%lld\n",n*m - 2);
	else
		printf("%lld\n",n*m - (2*n+2*m-4));
	return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define gc getchar
#define rint register int
#define rep(i,u,z) for(rint i=u;i<=z;++i)
#define reb(i,u,z) for(rint i=u;i>=z;--i)
#define inf 0x7fffffff

using namespace std;
typedef long long ll;

int n,m;

inline int readint(){
	int rt=0,sign=1;
	char ch=gc();
	while(ch<'0'||ch>'9'){
		if(ch=='-')sign=-1;
	    ch=gc();
	}
	while(ch>='0'&&ch<='9'){
		rt=(rt<<3)+(rt<<1)+ch-48;
		ch=gc();
	}
	return rt*sign;
}
int main(){
	n=readint(),m=readint();
	if(m%n==0){
		printf("%d",m/n);
		return 0;
	}
	rint p=m/n;
	while(m%p)--p;
	printf("%d",p);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    long long x, k, d;
    long double y;
    cin >> x >> k >> d;
    if(x>0){
        y = (long double) x / (long double) d;
        if(y > k){
            cout << abs(x - k * d);
        }
        else if(y == k || ((long long)y == y && (k - (long long)y) % 2 == 0)){
            cout << 0;
        }
        else{
            if((k - (long long)y) % 2 == 0){
                cout << abs(x - (long long)y * d);
            }
            else{
                cout << abs(x - ((long long)y + 1) * d);
            }
        }
    }
    else{
        y = -(long double) x / (long double) d;
        if(y > k){
            cout << abs(x + k * d);
        }
        else if(y == k || ((long long)y == y && (k - (long long)y) % 2 == 0)){
            cout << 0;
        }
        else{
            if((k - (long long)y) % 2 == 0){
                cout << abs(x + (long long)y * d);
            }
            else{
                cout << abs(x + ((long long)y + 1) * d);
            }
        }    
    }    
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(i,n) for(int i = 1; i <= (int)(n); i++)
#define pb push_back
#define all(v) v.begin(),v.end()
#define fi first
#define se second
#define mp make_pair
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<string> vs;
typedef vector<char> vc;
typedef long long ll;
typedef unsigned long long ull;

//const ll mod = 1000000007;
//const ll INF = mod * mod;

int main() {
    int k,a,b;
    cin >> k >> a >> b;
    bool ok = false;
    for(int i = a; i <= b; i++) {
        if(i % k == 0) {
            ok = true;
            break;
        }
    }
    if(ok) puts("OK");
    else puts("NG");
}

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

#define int long long
#define uint unsigned int
#define pii pair<int, int>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FORR(i,a,b) for(int i=(a);i>=(b);--i)
#define REP(i,n) FOR(i,0,n)
#define REPR(i,n) FORR(i,n,0)
#define EACH(i,c) for (auto i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()

#define PB(a) push_back(a)
#define EMPB(...) emplace_back(__VA_ARGS__)
#define EMP(...) emplace(__VA_ARGS__)
#define MP(a,b) make_pair(a,b)
#define MT(...) make_tuple(__VA_ARGS__)

#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define MINF(a) memset(a,0x3f,sizeof(a))

#define PW(n) (1LL << (n))

using namespace std;

template <class T> inline bool CHMIN(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template <class T> inline bool CHMAX(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> inline void SORT(T &a) { sort(a.begin(), a.end()); }
template <class T> inline void REV(T &a) { reverse(a.begin(), a.end()); }
template <class T> inline void UNI(T &a) { sort(a.begin(), a.end()); a.erase(unique(a.begin(), a.end()), a.end()); }

template <class S, class T> ostream& operator << (ostream& os, const pair<S, T> v) {
  os << "(" << v.first << ", " << v.second << ")"; return os;
}

const int MOD = 1000000007;
const int INF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-10;

/* ---------------------------------------------------------------------------------------------------- */

int N;
int a[100010];
vector<int> v;

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  cin >> N;
  REP(i, N) cin >> a[i];
  REP(i, N) v.PB(a[i]^(a[i]-1));
  UNI(v);
  REV(v);
  int s = 0;
  int ans = 0;
  REP(i, N) s ^= a[i];
  REP(i, v.size()) {
    int w = v[i]^(v[i]>>1);
    if (s & w) {
      s ^= v[i];
      ans++;
    }
  }
  if (s) cout << -1 << endl;
  else cout << ans << endl;

  return 0;
}

Measured memory_bytes: 2168
#include<iostream>

using namespace std;

int main() {
	int a, b, c;

	cin >> a >> b >> c;

	if (a == b && b == c ){

		cout << 1 << endl;
	}
	else if ((a == b && b != c) || (a == c && c != b) || (b == c && c != a)) {
		cout << 2 << endl;
	}
	else {
		cout << 3 << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout<<(ans)<<endl
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);};};
const int MOD = 1000000007;
const int INF = INT_MAX;
const ll LLINF = 1LL<<62;

int num=0;

void dfs(vi &score,vi &c,vvi &G,int pos){
    score[pos] = c[num];
    for(int i=0;i<G[pos].size();i++){
        if(score[G[pos][i]]==-1){
            num++;
            dfs(score,c,G,G[pos][i]);
        }
    }
    return;
}

int main(void) {

    int n;
    cin>>n;
    vvi G(n);
    vi l(n-1),r(n-1);
    rep(i,n-1){
        int a,b;
        cin>>a>>b;
        G[a-1].push_back(b-1);
        G[b-1].push_back(a-1);
        l[i]=a-1;
        r[i]=b-1;
    }
    vi c(n);
    rep(i,n)cin>>c[i];
    Rort(c);
    vi score(n,-1);

    dfs(score,c,G,0);
    ll ans=0;
    for(int i=0;i<n-1;i++){
        ans+=min(score[l[i]],score[r[i]]);
    }
    fin(ans);
    for(int i=0;i<n;i++){
        if(i==0)cout<<score[i];
        else cout<<" "<<score[i];
    }
    cout<<endl;



}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
#define ll long long

using namespace std;

ll n,m,res;

int main() {
    cin>>n>>m;
    if (n>m) swap(n,m);
    if (n==1) cout<< n*(max(m-2,1ll));
    else cout<<(n-2)*(m-2);
}


Measured memory_bytes: 256
#import<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef struct{int x;int y;}H;
int a,b,i,j,k,l,m,n,s,sz,t,pv[200040],vi[200040],d[200040],u[200040],z[200040];
H e[400005];
int C(H a,H b){return a.x<b.x;}
void dfs(int v,int k)
{
	vi[v]=1;
	d[v]=k;
	if(k)a++;
	else b++;
	for(int i=pv[v];i<pv[v+1];i++)
	{
		if(!vi[e[i].y])dfs(e[i].y,!k);
	}
}
main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin>>n;
	for(;i<n-1;i++)
	{
		cin>>e[i].x>>e[i].y;
		e[i+n-1].x=e[i].y;
		e[i+n-1].y=e[i].x;
	}
	sz=2*n-2;
	sort(e,e+sz,C);
	for(i=0;++i<sz;)
	{
		if(e[i].x>e[i-1].x)
		{
			for(j=e[i-1].x;j++<e[i].x;)
			{
				pv[j]=i;
			}
		}
	}
	for(j=e[sz-1].x;j++<n+1;)pv[j]=sz;
	dfs(1,1);
	{
		if(a<b)
		{
			for(i=0;i++<n;)d[i]=!d[i];
			swap(a,b);
		}
		if(b<=n/3)
		{
			for(i=0,k=3;i++<n;)
			{
				if(!d[i])
				{
					z[i]=k;
					u[k]=1;
					k+=3;
				}
			}
			for(i=0,l=1;i++<n;)
			{
				if(d[i])
				{
					z[i]=l++;
					if(u[l])l++;
				}
			}
		}
		else
		{
			for(i=0,k=1;i++<n;)
			{
				if(d[i])
				{
					z[i]=k;
					k+=3;
					if(k>n)k=3;
				}
			}
			for(i=0,l=2;i++<n;)
			{
				if(!d[i])
				{
					z[i]=l;
					l+=3;
					if(l>n)l=k;
				}
			}
		}
		for(i=0;i++<n;)cout<<z[i]<<' ';
	}
}

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

// dp[i]: モンスターの体力をi減らすために消耗する魔力の最小値

int main()
{
    int h, n;
    cin >> h >> n;
    vector<int> dp(h + 1, 1001001001);
    dp[0] = 0; // モンスターの体力を0減らすために消耗する魔力の最小値は0
    for (int i = 0; i < n; i++)
    {
        int a, b;
        cin >> a >> b; // 魔力をb消耗してモンスターの体力をa減らせる
        for (int j = 0; j < h; j++)
        {
            int nj = min(j + a, h);
            dp[nj] = min(dp[nj], dp[j] + b);
        }
    }
    cout << dp[h] << endl;
    return 0;
}

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


int main () {

  int N, X;
  
  cin >> N >> X;

  vector<int> L (N);
  for (int i = 0; i < N ; ++i) cin >> L[i];

  
  int jumpNb = 1;
  long d = 0;
  int i = 0;

   while (i < N && d <= X ) {
     d += L[i];
     if ( d <= X)jumpNb++;
     else break;
     i++;
   }
   

   cout << jumpNb << "\n";





  return 0;
}


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

/*
*****************code written By**********************
..................Marajul islam.......................
...................BSMRSTU,CSE........................
*/

int sc1() {int x; scanf("%d", &x); return x;}

long long sc2() {long long x; scanf("%lld", &x); return x;}



#define  gcd(a,b)         __gcd(a,b)
#define  lcm(a,b)         (a*b)/gcd(a,b)
#define  Int              sc1()
#define  LL               sc2()
#define  For(n)           for(int i=0;i<n;i++)
#define  Forj(n)          for(int j=0;j<n;j++)
#define  Fork(n)          for(int k=0;k<n;k++)
#define  For1(n)          for(int i=1;i<=n;i++)
#define  ll               long long
#define  vi               std::vector<int>
#define  vll              std::vector<ll>
#define  qui              qu
#define  pb               push_back
#define  mpsi             std::map<string, int>
#define pii pair<int,int>

const int mod           = 1e9 + 7;
const int inf           = (int)2e9 + 5;
const ll  Inf           = (ll)1e18 + 5;
const int N             = 5e6 + 5;

inline int add(int a, int b) {a += b; return a >= mod ? a - mod : a;}
inline int sub(int a, int b) {a -= b; return a < 0 ? a + mod : a;}
inline int mul(int a, int b) {return (ll)a * b % mod;}
int fx[]={1,-1,0,0};
int fy[]={0,0,1,-1};
string s[20];
int dis[21][21];
int vis[21][21];
int h,w;
int bfs(int i,int j){
    for(int g1=0;g1<h;g1++){
        for(int g2=0;g2<w;g2++){
            vis[g1][g2]=0;
            dis[g1][g2]=0;
        }
    }
    queue<pii>q;
    vis[i][j]=1;
    q.push({i,j});
    while(!q.empty())
	{
		pii top=q.front(); q.pop();
		for(int k=0;k<4;k++)
		{
			int tx=top.first+fx[k];
			int ty=top.second+fy[k]; //Neighbor cell [tx][ty]
			if(tx>=0 and tx<h and ty>=0 and ty<w and s[tx][ty]!='#' and vis[tx][ty]==0) //Check if the neighbor is valid and not visited before.
			{
				vis[tx][ty]=1;
				dis[tx][ty]=dis[top.first][top.second]+1;
				q.push(pii(tx,ty)); //Pushing a new pair in the queue
			}
		}
	}
	int ans=0;
	for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            ans=max(ans,dis[i][j]);
        }
	}
	return ans;
}

int solve() {

    h,w;
    cin>>h>>w;
    for(int i=0;i<h;i++){
        cin>>s[i];
    }
    int ans=0;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(s[i][j]=='.'){
                ans=max(ans,bfs(i,j));

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




int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);

	int test = 1, tc = 0;
	//scanf("%d", &test);
	//cin >> test;
	while (test--) {
		//printf("Case %d: ", ++tc);
		solve();
	}

	return 0;




}



Measured memory_bytes: 256
import java.util.Scanner;

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

        scanner.nextLine();
        String[] array = scanner.nextLine().split(" ");

        String prep = "";
        int count = 0;
        int current = 0;

        for (String anArray : array) {
            if (anArray.equals(prep)) {
                ++current;
            } else {
                count += current / 2;
                prep = anArray;
                current = 1;
            }
        }
        count += current / 2;
        System.out.println(count);
    }
}

Measured memory_bytes: 23124
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
vector<int> input(int N) {
  vector<int> vec(N);
  for (int i = 0; i < N; i++) {
    cin >> vec.at(i);
  }
  return vec;
}

int main() {
  int n,sum=0;
  cin >> n;
  vector<int> v = input(n);
  rep(i,n){
    rep(j,n){
      if(i!=j){
        sum += v[i]*v[j];
      }
    }
  }
  cout << sum/2 << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<string>
using namespace std;

int main() {
	string sentence;
	getline(cin, sentence);
	for (int i = 0;i<sentence.size() ; i++) {
		if (sentence[i] >= 97 && sentence[i] <= 122)sentence[i] = sentence[i] - 32;
	}
	cout << sentence << endl;
}

Measured memory_bytes: 3172
/*..........AAKASH GOYAL............*/
/*............DAIICT................*/
 
#include <bits/stdc++.h>
using namespace std;

#define    int                      long long int

#define    f(i,j,n)                 for(int i = j; i <= n; i++)
#define    r(i,n,j)                 for(int i = n; i >= j; i--)
#define    mod                      1000000007
#define    speed                    ios_base::sync_with_stdio(false);
#define    upp                      cin.tie(NULL);
#define    pb                       push_back
#define    mp                       make_pair
#define    T                        int tt; cin >> tt; while(tt--)
#define    ff                       first
#define    ss                       second
#define    all(container)           container.begin() , container.end()
#define    sz(container)            (int)container.size()
#define    pii                      pair <int , int>
#define    ppi                      pair <int , pii>               
#define    sp(x)                    setprecision(x)

int32_t main()
{
    speed upp
    int n;
    cin>>n;
    int a[n+10];
    int ff[n+100];
    f(i,0,n+29)
        ff[i]=0;
    f(i,0,n-1)
    {
        cin>>a[i];
        ff[a[i]]++;
    }
    int ans=0;
    f(i,0,n)
    {
        ans+=(ff[i]*(ff[i]-1))/2;
        //cout<<ff[i]<<"  ";
    }
    f(i,0,n-1)
    {
        int tt=ans-  (ff[a[i]]*(ff[a[i]]-1))/2;
        int x=ff[a[i]]-1;
        if(x>0)
            tt +=(x*(x-1))/2;
        cout<<tt<<endl;
    }

}

Measured memory_bytes: 5760
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<vector>
#include<cstdlib>
#include<map>
#include<queue>
#include<stack>
#include<deque>
#include<fstream>
#include<string>
#include<sstream>
#include<iomanip>
#include<numeric>
#include<cctype>
using namespace std;

#define Yes(a) a ? "Yes" : "No";
#define YES(a) a ? "YES" : "NO";
#define rep(i,n) for(int i=0;i<n;i++)

void sout(string* a, string* b) {
	if (*a > * b) {
		string c = *a;
		*a = *b;
		*b = c;
	}
}

int combination(int n, int k) {
	if (n > k && k > 0) {
		return (combination(n - 1, k) + combination(n - 1, k - 1));
	}
	else
		return 1;
}

int main() {
	int n, check = 0;
	cin >> n;
	vector<char> s(n);
	for (int i = 0; i < n; i++) {
		cin >> s.at(i);
		if (s.at(i) == 'Y')
			check++;
	}
	if (check == 0)
		cout << "Three" << endl;
	else
		cout << "Four" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <memory>

int main()
{
	int N, T;
	std::cin >> N >> T;
	const int MinCostMax = 1000;
	int minCost = MinCostMax + 1;
	for (int i = 0; i < N; i++) {
		int c, t;
		std::cin >> c >> t;
		if (c < minCost && t <= T)
		{
			minCost = c;
		}
	}
	if (minCost > 1000)
	{
		std::cout << "TLE";
		return 0;
	}
	std::cout << minCost;
	return 0;
}


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

int main(){
    int n;
    cin >> n;
    vector<long long> a(n);
    for (int i = 0;i < n;i++){
        cin >> a[i];
        a[i]--;
    }
    vector<long long> c(n,0);
    for (int i = 0;i < n;i++){
        c[a[i]]++;
    }
    long long sum = 0;
    for (int i = 0; i < n; i++){
        sum += c[i]*(c[i]-1)/2;
    }
    //cout << sum << endl;

    for (int i = 0; i < n; i++){
        long long ans = sum;
        ans -= (c[a[i]])*(c[a[i]]-1)/2;
        ans += (c[a[i]]-1)*(c[a[i]]-2)/2;
        cout << ans << endl;
    }
}

Measured memory_bytes: 6408
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define inf 10e17
#define rep(i,n) for(long long i=0; i<n; i++)
#define repr(i,n,m) for(long long i=m; i<n; i++)
#define mod 1000000007
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<long long>())
#define debug(x) std::cerr << (x) << std::endl;
#define roll(x) for (auto&& itr : x) { cerr << (itr) << " "; }

template <class T> inline void chmax(T &ans, T t) { if (t > ans) ans = t;}
template <class T> inline void chmin(T &ans, T t) { if (t < ans) ans = t;}

int main() {
  ll n;
  cin >> n;
  vector<ll> x(n);
  rep(i, n) {
    cin >> x[i];
  }

  ll ans = inf;
  for (int i = 1; i <= 100; ++i) {
    ll temp = 0;
    for (int j = 0; j < n; ++j) {
      ll t = abs(x[j] - i);
      // cout << t << endl;
      temp += t * t;
    }
    chmin(ans, temp);
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;

inline void up(ll &x, ll y) { x < y ? x = y : 0; }

int main() {
	ll a, b, n, ans = 0;
	std::cin >> a >> b >> n;
	if (b - 1 <= n) std::cout <<  a * (b - 1) / b - a * ((b - 1) / b) << '\n';
	else std::cout << a * n / b - a * (n / b) << '\n';
	return 0;
}










Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()

const int N = 1e5 + 5;

int n, m;
pair<int, int> arr[N];

int main()
{
  ios::sync_with_stdio(false);
  cin >> n >> m;
  for(int i = 0 ; i < n ; i++){
    cin >> arr[i].first >> arr[i].second;
  }
  sort(arr, arr + n);
  int j = 0, len = 1;
  priority_queue<int> pq;
  int ans = 0;
  for(int i = m - 1 ; i >= 0 ; i--){
    while(j < n && arr[j].first <= len){
      pq.push(arr[j].second);
      j++;
    }
    if(!pq.empty()){
      int t = pq.top();
      pq.pop();
      ans += t;
    }
    len++;
  }
  cout << ans << endl;
  return 0;
}


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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef long long ll;

int main() {
    int N;
    cin >> N;
    map<int, int> mp;
    rep(i, N) {
        int a;
        cin >> a;
        mp[a - 1]++;
        mp[a]++;
        mp[a + 1]++;
    }

    int ans = 0;
    for(auto p: mp) {
        chmax(ans, p.second);
    }
    cout << ans << endl;
}

Measured memory_bytes: 4736
# -*- coding: utf-8 -*-
n = int(input())
p = [int(x) for x in input().split()]
cnt = 0

for i in range(n):
    if i+1==p[i]:
        cnt += 1
        if i==0:
            p[i],p[i+1] = p[i+1],p[i]
        elif i==n-1:
            p[i-1],p[i] = p[i],p[i-1]
        elif i+2==p[i+1]:
            p[i],p[i+1] = p[i+1],p[i]
        elif i+1!=p[i-1] and i!=p[i]:
            p[i-1],p[i] = p[i],p[i-1]
        else:
            p[i],p[i+1] = p[i+1],p[i]

# print(p)
print(cnt)


Measured memory_bytes: 13880
#include<bits/stdc++.h>
//#include<iostream>
//#include<cstdio>
//#include<cstring>
//#include<string>
//#include<queue>
//#include<cmath>
//#include<algorithm>
#define debug1 cout<<"?"<<endl;
#define debug2 cout<<"?"<<i<<endl;
#define PII pair<int,int>
typedef long long ll;
const int maxn=2e5+9;
const double pi=acos(-1);
const int mod=1e9+7;
const int INF=0x3f3f3f3f;
const double ep=1e-7;
using namespace std;
int main()
{
	ll n,m;
	scanf("%lld%lld",&n,&m);
	if(n==1||m==1)
	{
		puts("1");return 0;
	}
	ll ans=(n/2)*m;
	if(n&1)ans=ans+(m+1)/2;
	printf("%lld\n",ans);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define st first
#define nd second
#define pb push_back
#define ppb pop_back
#define umax(x,y) x=max(x,y)
#define umin(x,y) x=min(x,y)
#define ll long long
#define ii pair<int,int>
#define iii pair<int,ii>
#define iiii pair<ii,ii>
#define sz(x) ((int) x.size())
#define orta ((bas+son)>>1)
#define all(x) x.begin(),x.end()
#define dbgs(x) cerr<<(#x)<<" --> "<<(x)<<" "
#define dbg(x) cerr<<(#x)<<" --> "<<(x)<<endl;getchar()
#define pw(x) (1ll<<(x))
#define inf 2005000
#define MOD 1000000007
#define N 200005
#define M 1000005
#define LOG 60
#define KOK 4000000
using namespace std;

int H,W,h,w;
int val[505*505],mat[505][505];

int main() {

	//freopen("input.txt","r",stdin);	

	scanf("%d %d %d %d",&H,&W,&h,&w);

	if(H%h==0 && W%w==0) {

		printf("No");

		return 0;

	}

	int rh=H%h;
	int rw=W%w;

	int total=rh*w+rw*h-rh*rw;
	int oth=H*W-total;

	val[1]=-505*total-1;

	int cnt=0;

	printf("Yes\n");

	for(int i=1;i<=h;i++) {

		for(int j=1;j<=w;j++) {

			if(i<=rh || j<=rw) mat[i-1][j-1]=505;
			else {

				mat[i-1][j-1]=val[++cnt];

			}

		}

	}

	for(int i=0;i<H;i++) {

		for(int j=0;j<W;j++) {

			printf("%d ",mat[i%h][j%w]);

		}

		puts("");

	}

}



Measured memory_bytes: 2176
N=1e7,a[10010000];main(i,j){for(i=j=2;i*i<N;a[i]||j>N?j=++i:a[j+=i]++);for(;i=~scanf("%d",&N);N&&printf("%d\n",N))for(;a[N]+a[N-2]+a[N-6]+a[N-8]&&N--;);}

Measured memory_bytes: 0
import java.util.Scanner;
import java.util.List;
import java.util.ArrayList;
import java.util.Objects;

public class Main {
  public static void main(String[] args ){

    Scanner sc = new Scanner(System.in);

    String S = sc.next();

    boolean repetNum = false;
    for (int i = 0; i < S.length() - 1; i++) {
      if(S.charAt(i) == S.charAt(i + 1)) repetNum = true;
    }

    System.out.println(repetNum ? "Bad" : "Good");

  }
}


Measured memory_bytes: 23380
#include<iostream>
#include<string>
 
using namespace std;
 
int main(){
  int N, M, total, total_;
  int *p;
  int *pp;
  int *pp_;
  string S;

  cin >> N >> M;

  p = new int[M];

  pp = new int[N]; pp_ = new int[N];

  for(int i = 0; i < N; i++){
    pp[i] = 0;  pp_[i] = 0;
   }

  for(int i = 0; i < M; i++){
    cin >> p[i] >> S;

    if(S == "AC") pp[p[i]-1]+=1;
    else {
      if(pp[p[i]-1]==0) pp_[p[i]-1]+=1;
      else continue;
    }
  }
  total = 0; total_ = 0;
  for(int i = 0; i < N; i++) {
    if(pp[i]>0) {
      
      total_ += 1;
      total += pp_[i];
    }
    
    else continue;
  }

  cout << total_ <<  " " << total;

}

Measured memory_bytes: 1408
import scala.collection.mutable
import java.io.{BufferedReader, InputStreamReader}

object Main extends App {
  val in = new BufferedReader(new InputStreamReader(System.in))
  val map = mutable.HashMap[Int,Int]()
  val n = in.readLine.toInt
  Iterator.continually(in.readLine)
    .take(n)
    .map(_.toInt)
    .foreach(e => {
      if(!map.contains(e)) map += e -> 1
      else map(e) += 1
    })

  val ans = map.count(e => (e._2&1)==1)

  println(ans)
}

Measured memory_bytes: 45656
#include <iostream>      // cout, endl, cin
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <bits/stdc++.h> // isupper, islower, isdigit, toupper, tolower
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> Pl;
typedef pair<int, int> P;

int main()
{
  ll N, K;
  cin >> N >> K;
  N %= K;
  N = min(N, abs(N - K));

  cout << N << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, T;
  cin >> N >> T;
  vector <int> time(N);
  for (int i = 0; i < N; i++) {
    cin >> time.at(i);
  }
  int sum = 0;
  for (int i = 0; i < N-1; i++) {
    if ((time.at(i+1) - time.at(i)) >= T) {
      sum += T;
    }
    else {
      sum += (time.at(i+1) - time.at(i));
    }
  } 
  cout << sum + T << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define PB push_back
#define FST first
#define SCD second
#define retunr return
#define modp 1000000007
#define MODP 1000000
#define EPS 1e-6
#define INF 0x3f3f3f3f
#define MAX2 113
#define MAX3 5013
#define MAX4 10013
#define MAX5 200013
#define MAX6 2000013
#define MAXN 100013
#define MANX MAXN
using namespace std;
typedef long long LL;
typedef unsigned int UI;
const UI tb[32] = {13, 0, 27, 1, 28, 18, 23, 2, 29, 21, 19, 12, 24, 9, 14, 3, 30, 26, 17, 22, 20, 11, 8, 13, 25, 16, 10, 7, 15, 6, 5, 4};
#define LOG(x) tb[(UI(x) * (UI)263572066) >> 27]
typedef pair<int,int> PA;
typedef pair<double,double> PAf;
int n,m,tot;

struct E
{
    int a, nxt;
    // E(){}
    // E(int x, int y, int z) : a(x), nxt(y), c(z) {}
};

int q[MAX3];
std::vector<PA> v;

int main()
{
#ifndef ONLINE_JUDGE
    // freopen("in.txt", "r", stdin);
    // freopen("out.txt", "w", stdout);
#endif
    int TT = 1;
    // scanf("%d",&TT);
    for (int ci=1;ci<=TT;++ci) {
    // while (scanf("%d", &n)!=EOF) {
        scanf("%d", &n);
        tot = 0;
        m = -1;
        for (int i=0;i<n;++i) {
            int x;
            scanf("%d", &x);
            q[i] = x;
            if (abs(x)>tot) tot = abs(x), m = i;
        }
        v.clear();
        for (int i=0;i<n;++i) {
            if (q[m]!=0&&i!=m) {
                q[i] += q[m];
                v.push_back(PA(m,i));
            }
        }
        int s,t,d;
        if (q[m]>0) s=0, t=n, d=1;
        else s=n-1, t=-1, d=-1;
        // cout<<s<<", "<<t<<","<<d<<endl;
        if (q[m]!=0)
        for (int i=s+d;i!=t;i+=d) {
            q[i]+=q[i-d];
            v.push_back(PA(i-d,i));
        }
        cout<<v.size()<<endl;
        for (int i=0;i<v.size();++i) {
            printf("%d %d\n", v[i].FST+1, v[i].SCD+1);
        }
    }
    return 0;
}


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

void solve(long long M)
{
    cout << (48 - M) << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main()
{
    long long M;
    scanf("%lld", &M);
    solve(M);
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
 
using namespace std;
 
int main(){
    int H,W;
    while(true){
        scanf("%d %d",&H,&W);
        if(H == 0 && W == 0) break;
        for(int i = 0; i < H; i++){
            for(int j = 0; j < W; j++){
                if((i+j)%2 == 0) printf("#");
                else{
                    printf(".");
                }
            }
            printf("\n");
        }
        printf("\n");
    }
}


Measured memory_bytes: 2564
#include<iostream>
using namespace std;
int main(){
    int n, q, t, c = 0;
    cin >> n;
    int S[n];
    for (int i = 0; i < n; i++) cin >> S[i];
    cin >> q;
    for (int i = 0; i < q; i++) {
        cin >> t;
        for (int j = 0; j < n; j++) {
            if (S[j] == t) { c++; break; }
        }
    }
    cout << c << endl;
    return 0;
}


Measured memory_bytes: 3056
// A - Connection and Disconnection
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

ll f(string &S){
	ll c = 0;
	int i = 1;
	while(i < S.size()){
		if(S[i-1] == S[i]){
			i++;
			c++;
		}
		i++;
	}
	return c;
}

int main(){
	string S; cin>>S;
	ll K; cin>>K;

	string S2 = S + S;
	string S3 = S2 + S;

	ll s1 = f(S);
	ll s2 = f(S2);
	ll s3 = f(S3);

	ll d1 = s2 - s1;
	ll d2 = s3 - s2;

	ll ans = 0;
	if(K == 1) ans = s1;
	else if(K == 2) ans = s2;
	else if(K == 3) ans = s3;
	if(K <= 3){
		cout<< ans <<endl;
		return 0;
	}

	if(d1 == d2) ans = s1 + d1 * (K-1);
	else
		if(K % 2) ans = s1 + (d1+d2) * ((K+2-1)/2-1);
		else ans = s2 + (d1+d2) * (K/2-1);
	cout<< ans <<endl;
}

Measured memory_bytes: 256
from copy import deepcopy
ss=list(input())
ans=float("inf")
n=len(ss)
for i in range(n):
    s=deepcopy(ss)
    t=ss[i]
    flg=True
    while flg:
        tmp=""
        if all(s[k]==t for k in range(len(s))):
            tt=len(ss)-len(s)
            if tt<ans:
                ans=tt
            flg=False
            break
        for j in range(len(s)-1):
            
            if s[j]==t or s[j+1]==t:
                tmp+=t
            else:
                tmp+=s[j]
        s=tmp
print(ans)

Measured memory_bytes: 9280
N = int(input())
CSF = [list(map(int, input().split())) for i in range(N - 1)]
ans = []
for i in range(N - 1):
    temp = 0
    for j in range(i, N - 1):
        c, s, f = CSF[j][0], CSF[j][1], CSF[j][2]
        if temp <= s:
            temp += s - temp
            temp += temp % f
        else:
            temp += (f - ((temp - s) % f)) % f
        temp += c
    ans.append(temp)
for i in range(N - 1):
    print(ans[i])
print(0)


Measured memory_bytes: 9236
#include <iostream>

const int MAX_N = 100000;

int f[MAX_N + 1], h[MAX_N + 1];

struct IO {
  IO &operator>>(int &x) {
    char c;
    do
      c = std::cin.rdbuf()->sbumpc();
    while (!isdigit(c));
    for (x = 0; isdigit(c); c = std::cin.rdbuf()->sbumpc())
      x = x * 10 + (c ^ 48);
    return *this;
  }
} io;

int main() {
  int n;
  io >> n;
  for (int i = 1; i <= n; ++i) io >> h[i];
  f[2] = std::abs(h[2] - h[1]);
  for (int i = 3; i <= n; ++i)
    f[i] = std::min(f[i - 1] + std::abs(h[i] - h[i - 1]),
                    f[i - 2] + std::abs(h[i] - h[i - 2]));
  std::cout << f[n];
  return 0;
}

Measured memory_bytes: 1024
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.Scanner;

public class Main {

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

		BigDecimal a = new BigDecimal(sc.next());
		BigDecimal b = new BigDecimal(sc.next());

		System.out.println(a.multiply(b).setScale(0, RoundingMode.DOWN).toString());

		sc.close();

	}

}

Measured memory_bytes: 35920
#include<iostream>
#include<string>
using namespace std;
int main()
{
	string w, s;
	int i;
	cin >> w;
	for (i = 0; i < w.size(); i++)
		if (w[i] <= 'z'&&w[i] >= 'a')
			w[i] -= 'a' - 'A';
	cin >> s;
	int o = 0;
	while (s != "END_OF_TEXT")
	{
		for (i = 0; i < s.size(); i++)
			if (s[i] <= 'z'&&s[i] >= 'a')
				s[i] -= 'a' - 'A';
		if (w == s)o++;
		cin >> s;
	}
	cout << o << endl;
	return 0;
}


Measured memory_bytes: 3184