akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>


int main(void)
{
    int i[1000];
    int s,n,o,p,k;
    
    scanf("%d%d",&s,&n);
    
    for(o=0;o<=s;o++){
        scanf("%d",&i[o]);
    }
    
    for(o=0;o<s;o++){
        for(p=o+1;p<s;p++){
            if(i[o]>i[p]){
                k=i[o];
                i[o]=i[p];
                i[p]=k;
            }
        }
    }
    
    p=0;
    
    for(o=0;o<n;o++){
        p+=i[o];
    }
    printf("%d",p);
    return 0;
}

Measured memory_bytes: 2160
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REP1(i, n) for (int i = 1; i < n + 1; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
#define SZ(x) ((int)(x).size())
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))
using namespace std;
typedef long long ll;
using p = pair<int, int>;
using P = pair<ll, ll>;
using V = vector<int>;
using VV = vector<vector<int>>;
using VVV = vector<vector<vector<int>>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VVVL = vector<vector<vector<ll>>>;
using Graph = VV;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int x;
    cin >> x;
    if (x % 200 == 0)
        cout << (2000 - x) / 200 << endl;
    else
        cout << (2000 - x) / 200 + 1 << endl;
}


Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
#define f first
#define se second
#define pb push_back
#define mp make_pair
#define vi vector<int>
#define pi pair<int,int>
#define all(x) x.begin(),x.end()
#define lp(i,n) for(int i =0;i<n;i++)
#define mem(a,v) memset(a,v,sizeof(a))
#define X real()
#define Y imag()
#define angle(a) (atan2(a.Y , a.X))
#define vec(a,b) ((b)-(a))
//#define length(a) (hypot(a.Y , a.X))
#define normalize(a) (a)/length(a)
#define dotP(a,b) ((conj(a)*b).X)
#define crossP(a,b) ((conj(a)*b).Y)
#define same(p1,p2) (dotP(vec(p1,p2),vec(p1,p2))<EPS)
#define lengthSqr(a)   dotP(a,a)
#define rotate0(p,ang) ((p)*exp(point(0,ang)))
#define rotateA(p,ang,about) (rotate0(vec(about,p),ang)+about)
#define reflect0(v,m) conj(v/m)*m
const double PI = acos(-1.0);
const double EPS = (1e-10);
const long long int INF = 0x3f3f3f3f;
const long long mod  = (1e9)+7;
typedef long long int ll;
typedef unsigned long long ull;
typedef complex<double> point;
ll my_mod(ll num,ll mod){
    ll ret = num%mod;
    while(ret<0)ret+=mod;
    return ret;
}
int freq[100005];
int main(){
	//ios::sync_with_stdio(false);
    int n;
    cin>>n;
    int ans = n;
    lp(i,n){
        int x;
        cin>>x;
        freq[x]++;
    }
    for(int i = 1 ; i<= 100000 ; i++){
        if(!freq[i])continue;
        int h = freq[i];
        if(freq[i]%2){
            freq[i] = 1;
            ans-= (h-1);
        }else{
            freq[i] =2;
            ans-= (h-2);
        }
    }
    
    
    
    
    int cnt1=0,cnt2=0;
    for(int i = 1 ; i<= 100000 ; i++){
        if(!freq[i])continue;
       //cout<<i<<" "<<freq[i]<<endl;
       if(freq[i] == 2)cnt2++;
        else cnt1++;
    }
    int odd = cnt2%2;
    ans-= cnt2/2*2;
    if(odd)ans-=2;
    
    cout<<ans;
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <map>
using namespace std;
int main(int argc, char* argv[])
{
	int N;
	long long K;
	cin>>N>>K;
	int i;
	long long a,b;
	map<long long,long long> Array;
	map<long long,long long>::iterator mit;
	for (i=0;i<N;i++){
		cin>>a>>b;
		mit=Array.find(a);
		if (mit!=Array.end()){
			//find
			Array[a] += b;
		}else{
			Array[a] = b;
		}
	}
	long long k=K;
	for (mit=Array.begin();mit!=Array.end();mit++){
		k-=(*mit).second;
		if (k<=0){
			cout<<(*mit).first<<endl;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 4224
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int n = sc.nextInt();
		Integer[] array = new Integer[n];
		for(int i=0;i<n;i++) {
			array[i] = sc.nextInt();
		}
		sc.close();

		Arrays.sort(array);
//		for(int a : array) {
//			System.out.println(a);
//		}

		List<Integer> list = Arrays.asList(array);
		if(!(list.contains(x))) {
			System.out.println(x);
			return;
		}

		int ans=10000000;
		for(int i=1;i<=100;i++) {
			int min1 = Math.abs(x-i);
			if(!(list.contains(min1))) {
				System.out.println(min1);
				return;
			}
			int max1 = x+i;
			if(!(list.contains(max1))) {
				System.out.println(max1);
				return;
			}
		}

	}
}


Measured memory_bytes: 35940
#include<bits/stdc++.h>
typedef long long ll;
typedef long double ld;
using namespace std;
 
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
 
#define REP(i, l, n) for(ll i=(l), i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(),(x).end()
#define pb push_back
 
ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
 
char alpha[26] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};
 
int dx[4] = {-1, 1, 0, 0};
int dy[4] = {0, 0, 1, -1};
ld k = 1000000000000000000;
 
int main(){
    int n; cin >> n;
    ld ans = 1;
    vector<ld> lis(n);
    REP(i, 0, n){
        cin >> lis[i];
        if(lis[i] == 0){
            cout << 0 << endl;
            return 0;
        }
    }
    REP(i, 0, n){
        ld a = lis[i];
        ans = ans * a;
        if(ans > k){
            cout << -1 << endl;
            return 0;
        }
    }
    cout << (ll)ans << endl;
}

Measured memory_bytes: 4840
#include "bits/stdc++.h"
using namespace std;
const auto start_time = std::chrono::high_resolution_clock::now();
void timecalculater(){
    #ifndef ONLINE_JUDGE
    auto end_time = std::chrono::high_resolution_clock::now();
    std::chrono::duration<double> diff = end_time-start_time;
    cerr<<"Time Taken : "<<diff.count()<<"\n";
    #endif
}//continue break
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
void __print(int x) {cout << x;}
void __print(long x) {cout << x;}
void __print(long long x) {cout << x;}
void __print(unsigned x) {cout << x;}
void __print(unsigned long x) {cout << x;}
void __print(unsigned long long x) {cout << x;}
void __print(float x) {cout << x;}
void __print(double x) {cout << x;}
void __print(long double x) {cout << x;}
void __print(char x) {cout << '\'' << x << '\'';}
void __print(const char *x) {cout << '\"' << x << '\"';}
void __print(const string &x) {cout << '\"' << x << '\"';}
void __print(bool x) {cout << (x ? "true" : "false");}
template<typename T, typename V>
void __print(const pair<T, V> &x) {cout << '{'; __print(x.first); cout << ','; __print(x.second); cout << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cout << '{'; for (auto &i: x) cout << (f++ ? "," : ""), __print(i); cout << "}";}
void _print() {cout << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cout << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define dbg(x...) cout << "[" << #x << "] = ["; _print(x)
#else
#define dbg(x...)
#endif
#define fastio  cin.sync_with_stdio(0); cin.tie(0);cin.exceptions(cin.failbit);
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repA(i, a, n) for(int  i = a; i <= (n); ++i)
#define all(x) x.begin(), x.end()
#define sz(x) (int) (x).size()
#define fill(a,v) memset(a, v, sizeof(a))
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define endl '\n'
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef vector<int> vi;
typedef vector<long long int> vll;
typedef vector<pii> vpii;
ll p=1e9+7;
const int N=2e5+5;
int main() {
    
    fastio;
    int T=1;
    // cin>>T;
    while(T--){
        int n;cin>>n;
        string s;cin>>s;
        int ans=n;
        int cnt=0;
        rep(i,n)if(s[i]=='W')cnt++;
        int u=0;
        for(int i=0;i<=cnt;i++){
            int temp=0;
            temp=i-u+(cnt-i);
            if(i<n&&s[n-i-1]=='W')u++;
            ans=min(ans,temp);
        }
        cout<<ans;
    }   
    timecalculater();
    return 0;   
} 

Measured memory_bytes: 3780
N,A,B,C,D=map(int,input().split())
S=input()
#0-indexedにするため
A-=1;B-=1;C-=1;D-=1
'''
A→C
B→D
順序としてありえるのは
A<B<D<C
A<B<C<D
A<C<B<D
C<Dなら飛び越える必要がない
C>Dなら飛び越える必要がある
飛び越えを成功させるためには3連続の.が途中にあることが必要十分である
'''
if C<D:
    #ここは飛び越える必要がないとき
    Snuke=[0 for i in range(N)]
    Fnuke=[0 for i in range(N)]
    Snuke[A]=1
    Fnuke[B]=1
    for i in range(1,N):
        if S[i]=="#":
            continue
        if Snuke[i-1]==1:
            Snuke[i]=1
        if i>1 and Snuke[i-2]==1:
            Snuke[i]=1
        if Fnuke[i-1]==1:
            Fnuke[i]=1
        if i>1 and Fnuke[i-2]==1:
            Fnuke[i]=1
    if Snuke[C]==1 and Fnuke[D]==1:
        print("Yes")
    else:
        print("No")
else:
    #A<B<D<C
    #ここは飛び越える必要があるとき
    Snuke=[0 for i in range(N)]
    Fnuke=[0 for i in range(N)]
    Snuke[A]=1
    Fnuke[B]=1
    for i in range(1,N):
        if S[i]=="#":
            continue
        if Snuke[i-1]==1:
            Snuke[i]=1
        if i>1 and Snuke[i-2]==1:
            Snuke[i]=1
        if Fnuke[i-1]==1:
            Fnuke[i]=1
        if i>1 and Fnuke[i-2]==1:
            Fnuke[i]=1
    flag=0
    for i in range(B,D+1):
        if S[i-1]=="." and S[i]=="." and S[i+1]==".":
            flag=1
            break
    if Snuke[C]==1 and Fnuke[D]==1 and flag==1:
        print("Yes")
    else:
        print("No")


Measured memory_bytes: 55192
#include <iostream>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <string>
#include <sstream>
#include <vector>
#include <stack>
#include <memory>
#include <stdlib.h>
#include <cstring>
using namespace std;

stack<int> a;
void solve();
int main(){
    //freopen("/Users/mac/Desktop/C++?¨????/test/test.txt", "r", stdin);
    solve();
    cout<<a.top()<<endl;
    return 0;
}
void solve()
{
    char c[10];
    while (cin>>c) {
        if (strncmp(c, "+", 1)==0) {
            int n1,n2,n3;
            n2=a.top();
            a.pop();
            n1=a.top();
            a.pop();
            n3=n1+n2;
            a.push(n3);
        }
        else if (strncmp(c, "-", 2)==0) {
            int n1,n2,n3;
            n2=a.top();
            a.pop();
            n1=a.top();
            a.pop();
            n3=n1-n2;
            a.push(n3);
        }
        else if (strncmp(c, "*", 1)==0) {
            int n1,n2,n3;
            n2=a.top();
            a.pop();
            n1=a.top();
            a.pop();
            n3=n1*n2;
            a.push(n3);
        }
        else if (strncmp(c, "/", 1)==0) {
            int n1,n2,n3;
            n2=a.top();
            a.pop();
            n1=a.top();
            a.pop();
            n3=n1/n2;
            a.push(n3);
        }
        else{
            int n=atoi(c);
            a.push(n);
        }
    }
}

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

#define mp make_pair
#define eb emplace_back
#define ff first
#define ss second

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#ifdef ONPC
mt19937 rnd(228);
#else
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#endif


const int MAXN = 100;
//#define int long long
const int INF = 1e9;

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

    string s, t;
    cin >> s >> t;
    int n = (int) s.size();

    for (int i = 0; i < n; i++) if (s[i] != t[i]) {
      cout << "No\n";
      return 0;
    }

    cout << "Yes\n";

    return 0;
}


Measured memory_bytes: 3656
#include <cstdio>
#include <cstring>
#include <cassert>
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

#define TRACE(x) cerr << #x << " = " << x << endl
#define REP(i, n) for (int i=0; i<n; i++)
#define FOR(i, a, b) for (int i=(a); i<(b); i++)
#define _ << " " <<

typedef long long ll;
typedef pair<int, int> P;
#define X first
#define Y second

const int MAX = 1<<17;

vector <int> V[MAX];
int bio[MAX], col[MAX];

int dfs(int x, int cl)
{
  if (bio[x]++) return col[x] == cl;
  col[x] = cl;
  int ret = 1;
  for (auto it : V[x]) ret &= dfs(it, 1^cl);
  return ret;
}

int main()
{
  int n, m;
  scanf("%d%d", &n, &m);

  REP(i, m) {
    int a, b;
    scanf("%d%d", &a, &b); a--; b--;
    V[a].push_back(b);
    V[b].push_back(a);
  }

  ll rje = 0;
  int praz = 0;
  int br[2] = {0, 0};
  REP(i, n) {
    if (!bio[i]) {
      if (V[i].empty()) { praz++; continue; }
      int tmp = dfs(i, 0);
      br[tmp]++;
      rje += tmp + 1;
    }
  }

  rje += (ll) br[0] * (br[0] - 1) / 2 * 2;
  rje += (ll) br[1] * (br[1] - 1) / 2 * 4;
  rje += (ll) br[0] * br[1] * 2;
  rje += (ll) praz * (praz + 2*(n-praz));
  printf("%lld\n", rje);

  return 0;
}


Measured memory_bytes: 11136
#include<stdio.h>
int main()
{
    int m,n;
    scanf("%d%d",&m,&n);
    {
        if(m>8 || n>8)
        {
             printf(":(\n");
        }
        else
        {

              printf("Yay!\n");

        }
    }
    return 0;
}


Measured memory_bytes: 128
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);
  std::cerr << std::fixed << std::setprecision(6);

  long long N, K;

  std::cin >> N >> K;

  N %= K;

  std::cout << std::min(N, std::abs(N - K)) << std::endl;

  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <numeric>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <utility>
#include <string>

using namespace std;

typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ul;

const int iinf = 1 << 29;
const long long linf = 1l << 61;

bool water[200];
bool suger[3100];

int main(int argc, char* argv[])
{
	int A, B, C, D, E, F;
	scanf("%d %d %d %d %d %d", &A, &B, &C, &D, &E, &F);

	water[0] = true;
	for(int i = 0; i <= F / 100 + 1; i++)
	{
		if(!water[i]) continue;
		water[i + A] = true;
		water[i + B] = true;
	}

	suger[0] = true;
	for(int i = 0; i <= F; i++)
	{
		if(!suger[i]) continue;
		suger[i + C] = true;
		suger[i + D] = true;
	}

	double M = (double)E / (100 + E);
	double m = -1;
	int maxw;
	int maxs;
	for(int i = 0; i <= F / 100 + 1; i++)
	{
		if(!water[i]) continue;
		for(int j = 0; j <= F; j++)
		{
			if(!suger[j] || i * 100 + j > F) continue;
			double r = (double)j / (100 * i + j);
			if(r <= M && m < r)
			{
				m = r;
				maxw = i * 100;
				maxs = j;
			}
		}
	}
	printf("%d %d", maxw + maxs, maxs);

	return 0;
}


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

#define ll long long
const int N = 505;

int cntr1[N], cntr2[N];
int A[N][N];

int main(){
	int n;
	cin>>n;
	string s[N];
	bool ok = 0;
	for(int i = 1; i <= n; i++){
		cin>>s[i];
		for(int j = 1; j <= n; j++){
			if(s[i][j - 1] == '#'){
				cntr1[i]++, cntr2[j]++;
				ok = 1;
			}
		}
	}

	if(!ok){
		cout<<-1<<endl;
		return 0;
	}

	int lol = 0, ans = INT_MAX;

	for(int i = 1; i <= n; i++){
		if(cntr2[i] != n)	lol++;
	}

	for(int i = 1; i <= n; i++){
		if(cntr1[i] == n){
			cout<<lol<<endl;
			return 0;
		}
	}

	for(int i = 1; i <= n; i++){
		for(int j = 1; j <= n; j++){
			int tot = n - cntr1[j] + lol;
			if(s[i][j - 1] == '.')	tot++;
			ans = min(tot, ans);
		}
	}

	if(ans == INT_MAX)	ans = -1;
	cout<<ans<<endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; ++i)
#define REPP(i, n) for(int i = 1; i <= n; ++i)
#define REPR(i, n) for(int i = n; i >= 0; --i)
#define FOR(i, m, n) for(int i = m; i < n; ++i)
#define ALL(v) v.begin(), v.end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1000000007;
const ll INF = 1000000000;

int main() {
    int n; cin >> n;
    map<ll, ll> d;
    REP(i,n) {
        int tmp; cin >> tmp;
        d[tmp]++;
    }
    int m; cin >> m;
    vector<ll> t(m);
    REP(i,m) cin >> t[i];
    bool ans = true;
    REP(i,m) {
        auto itr = d.find(t[i]);
        if(itr != d.end()) {
            d[t[i]] --;
            if(d[t[i]]==0) d.erase(itr);
        }
        else {
            ans = false;
            break;
        }
    }
    cout << (ans ? "YES" : "NO") << endl;
    return 0;
}

Measured memory_bytes: 14336
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>

#define int long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
#define REMOVE(v,a) v.erase(remove(v.begin(), v.end(), a), v.end())
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
using namespace std;

int N;
vector<int> t[100000] = {};
vector<int> route;
bool flg[100000] = {};
bool is_end = false;

void get_route(int b, int n, stack<int>& s)
{
	if (is_end) return;
	flg[n] = true;

	s.push(n);

	if (n == b)
	{
		is_end = true;
		while (s.size() > 0)
		{
			route.push_back(s.top());
			s.pop();
		}
		reverse(route.begin(), route.end());
		return;
	}

	for (int m : t[n])
	{
		if (!flg[m])
		{
			get_route(b, m, s);
			if (is_end) return;
		}
	}

	s.pop();
}

bool map[100000] = {};

int count(queue<int>& q)
{
	int cnt = q.size();

	while (q.size() > 0)
	{
		int qs = q.size();
		for (int i = 0; i < qs; i++)
		{
			int n = q.front();
			q.pop();
			for (int m : t[n])
			{
				if (!map[m])
				{
					map[m] = true;
					cnt++;
					q.push(m);
				}
			}
		}
	}

	return cnt;
}


signed main()
{
	cin >> N;
	REP(i, N - 1)
	{
		int a, b;
		cin >> a >> b;
		t[a - 1].push_back(b - 1);
		t[b - 1].push_back(a - 1);
	}

	stack<int> s;
	get_route(N - 1, 0, s);

	int sunuke_n = route.size() / 2;;
	int fene_n = route.size() - route.size() / 2;

	for (int i = 0; i < route.size(); i++)
	{
		map[route[i]] = true;
	}

	queue<int> q1;
	for (int i = 0; i < fene_n; i++)
	{
		q1.push(route[i]);
	}
	int cnt1 = count(q1);

	queue<int> q2;
	for (int i = fene_n; i < route.size(); i++)
	{
		q2.push(route[i]);
	}
	int cnt2 = count(q2);

	if (cnt1 <= cnt2)
	{
		cout << "Snuke" << endl;
	}
	else
	{
		cout << "Fennec" << endl;
	}
}

Measured memory_bytes: 13860
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
 
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
	template <class Arg1> void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 << endl; }
	template <class Arg1, class... Args>
	void __f(const char* names, Arg1&& arg1, Args&&... args) {
		const char* sep = strchr(names + 1, ',');
		cerr.write(names, sep - names) << " : " << arg1 << "  ";
		__f(sep + 1, args...);
	}
#else
#define trace(...) 0
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("popcnt")
#pragma GCC target("avx2,sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS
#endif
 
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<int,pii> piii;
typedef pair<char,int> pci;
typedef pair<ll,ll> pll;
typedef pair<ll,pll> plll;
 


#define pb push_back
 
// order_of_key (k), find_by_order(k)
#define fi first
#define se second
#define input_arr(a,n) for(__typeof (n) i=0; i<n; ++i) {cin>>a[i];}
#define debug_arr(a,n) {{for(__typeof (n) i=0; i<n; ++i) {cout<<a[i]<<" ";}cout<<"\n";}}
#define maxheap priority_queue<ll>
#define minheap priority_queue<ll,vector<ll> ,greater<ll>>
#define initialise(a, x) memset(a, x, sizeof(a))
#define endl '\n'
#define ordered_set tree<pll, null_type,less<pll>, rb_tree_tag,tree_order_statistics_node_update>
#define MAX 1000020
#define maxn 200050
#define eps 0.0000001

const ll mod=1e9+7;
const ll inf=1e18;


bool prime[MAX];
int count1[MAX];
int a[MAX];




signed main()
{

	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

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

	int flg=0;

	int n,tp;
	cin>>n;

	for(int i=0;i<n;i++)
	{
		cin>>tp;
		a[tp]++;
		if(a[tp]>1 and tp!=1)
		{
			flg=1;
		}
	}

	if(!flg)
	{
		prime[0]=1;
		prime[1]=1;

		for(int i=2;i<MAX;i++)
		{
			if(!prime[i])
			{
				if(a[i]) count1[i]++;
				int j=i+i;
				while(j<MAX)
				{
					prime[j]=1;
					if(a[j]) count1[i]++;
					j+=i;
				}
			}
		}

		for(int i=2;i<MAX;i++)
		{
			if(count1[i]>1 and prime[i]==0)
			{
				flg=1;
			}
		}

	}

	if(!flg)
	{
		cout<<"pairwise coprime\n";
		return 0;
	}

	int gc=0;
	for(int i=0;i<MAX;i++)
	{
		if(a[i]) gc=__gcd(gc,i);
	}

	if(gc==1)
	{
		cout<<"setwise coprime\n";
	}
	else
	{
		cout<<"not coprime\n";
	}




	
	
	
	


	return 0;
}

Measured memory_bytes: 12400
int swap(int *x, int *y){
    int temp;
    
    temp = *x;
    *x = *y;
    *y = temp;
}

int main(){
    int a, b, c;
    
    scanf("%d%d%d", &a, &b, &c);
    
    if(a > b)
    swap(&a, &b);
    
    if(b > c)
    swap(&b, &c);
    
    if(a > b)
    swap(&a, &b);
    
    printf("%d %d %d\n", a, b, c);
    
    return 0;
}


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

using namespace std;

const int Nmax = 2e5 + 5;
const int Mod = 1e9 + 7;
const int oo = 1e9;

long long x;

int main()
{
/**
    #ifndef ONLINE_JUDGE

        ifstream cin("test.in");

    #endif // ONLINE_JUDGE
*/

    cin >> x;

    long long sol = 100, nrd = 0;
    while(sol < x)
    {
        sol += sol/100;
        nrd++;
    }

    cout << nrd;
    return 0;
}


Measured memory_bytes: 3592
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

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

    static class DLazyFaith {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int a = in.nextInt(), b = in.nextInt(), q = in.nextInt();

            long[] s = new long[a];
            for (int i = 0; i < a; i++) {
                s[i] = in.nextLong();
            }
            long[] t = new long[b];
            for (int i = 0; i < b; i++) {
                t[i] = in.nextLong();
            }

            for (int query = 0; query < q; query++) {
                long answer = Long.MAX_VALUE;

                long x = in.nextLong();

                int i = Arrays.binarySearch(s, x);
                if (i < 0) {
                    i = -i - 1;
                }
                int j = Arrays.binarySearch(t, x);
                if (j < 0) {
                    j = -j - 1;
                }

                for (int si = i - 1; si <= i; si++) {
                    for (int ti = j - 1; ti <= j; ti++) {
                        if (si >= 0 && si < a && ti >= 0 && ti < b) {
                            answer = Math.min(answer, Math.abs(s[si] - x) + Math.abs(t[ti] - s[si]));
                            answer = Math.min(answer, Math.abs(t[ti] - x) + Math.abs(t[ti] - s[si]));
                        }
                    }
                }

                out.println(answer);
            }
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

    }
}



Measured memory_bytes: 53584
#include <stdio.h>

int main(void) {
  int red = 100000;
  int n, i, temp;
  scanf("%d", &n);
  for(i = 0; i < n; i++) {
    red += red * 5 / 100;
    temp = red % 1000;
    if(temp > 0) {
      red = red - temp + 1000;
    }
  }
  printf("%d\n", red);
  return 0;
}

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

int main(){
    int N;
    cin >> N;
    int max = 0;
    int sum = 0;
    int p;

    for(int i = 0; i < N; i++){
        cin >> p;
        if(max < p){
            max = p;
        }
        sum += p;
    }
    sum -= max / 2;
   

    cout << sum << endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;


public class Main{

	public static void main(String[] args) throws IOException {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer in=new StringTokenizer(br.readLine());
        String S1 =in.nextToken().substring(0, 1);
        String S2 =in.nextToken().substring(0, 1);
        String S3 =in.nextToken().substring(0, 1);
        String ans = S1 + S2 + S3;


        in = null;

		br=null;
		System.out.println(ans.toUpperCase());

	}



}

Measured memory_bytes: 22996
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;

int main(int argc, char* argv[]) {
	while(1){
		int H, W;
		cin >> H >> W;
		if(H == 0 && W == 0) break;

		for(int i = 0; i < H; i++){
			for(int j = 0; j < W; j++){
				printf("#");
			}
			printf("\n");
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 1112
#include <cstdio>
#include <iostream>

int R,C;	// (1 <= R <= 10, 1 <= C <= 10 000)
const int MAX_ROW = 10;
const int MAX_COL = 10000;
bool is_flipped[MAX_ROW + 1][MAX_COL + 1];

int solve()
{
	int min_score = R*C;
	for(int i=0;i<1<<R;i++)
	{
		int score = 0;
		for(int c=0;c<C;c++)
		{
			int column_sum = 0;
			for(int r=0;r<R;r++)
				if(is_flipped[r][c] ^ ((i>>r)&1)) column_sum++;
			score += std::min(column_sum, R-column_sum);
		}
		min_score = std::min(min_score,score);
	}
	return R*C-min_score;
}

int main()
{
	scanf("%d %d", &R, &C);
	int input;
	while(C!=0 || R!=0)
	{
        for (int r = 0; r < R; r++)
            for (int c = 0; c < C; c++)
			{
                scanf("%d", &input);
				is_flipped[r][c] = input==1;
			}
        printf("%d\n", solve());
        scanf("%d %d", &R, &C);
    }
	return 0;
}

Measured memory_bytes: 3320
#include <algorithm>
#include <iostream>
#include <map>
#include <set>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

// vector<int> dp; // 頂点 i から始まるパスで最長のものの長さ
int dp[100001];        // メモ化再帰
multimap<int, int> mp; // 入力値(from, to)

// 一番遠い場所を探す
int rec(int from) {
    if (dp[from] != 0) {
        return dp[from];
    }
    int res = 0;
    // キーを持つ値を列挙する
    auto p = mp.equal_range(from);
    for (auto it = p.first; it != p.second; ++it) {
        res = max(res, rec(it->second) + 1);
    }
    return dp[from] = res;
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m, ans = 0;
    cin >> n >> m;
    // dp.resize(n + 1, 0);
    for (int i = 1; i <= m; i++) {
        int x, y;
        cin >> x >> y;
        mp.emplace(x, y);
    }
    for (int i = 1; i <= n; i++) {
        ans = max(ans, rec(i));
    }
    cout << ans << endl;
    return 0;
}

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

struct Frac {
    int num, den;
    inline Frac(int _num, int _den) {
        int gcd = __gcd(_num, _den);
        num = _num / gcd;
        den = _den / gcd;
    }
    inline Frac operator+(const Frac &o) const {
        return Frac(num * o.den + o.num * den, den * o.den);
    }
    inline Frac operator-(const Frac &o) const {
        return Frac(num * o.den - o.num * den, den * o.den);
    }
    inline Frac operator*(int n) const {
        return Frac(num * n, den);
    }
    inline bool operator<(const Frac &o) const {
        return num * o.den < o.num * den;
    }
    inline bool operator<(int n) const {
        return num < den * n;
    }
};

inline int count_pat(int min_den, Frac f, int a, int n) {
    if (f.num == 0) return 1;
    if (f < 0) return 0;
    if (min_den > a) return 0;
    if (n == 0) return 0;
    if (Frac(1, min_den) * n < f) return 0;
    int sum = 0;
    for (int i = min_den; i <= a; i++) {
        if (Frac(1, i) * n < f) break;
        sum += count_pat(i, f - Frac(1, i), a/i, n-1);
    }
    return sum;
}

int main() {
    int p, q, a, n;
    while (cin >> p >> q >> a >> n) {
        if (!(p || q || a || n)) break;
        cout << count_pat(1, Frac(p, q), a, n) << endl;
    }
    return 0;
}

Measured memory_bytes: 1168
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
const int N = 1e5 + 5;
int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    string s;
    cin >> s;
    int cnt = 0 , ans = 0;
    for(auto &i : s) {
        if(i == 'R')
            cnt++;
        else
            ans = max(ans , cnt) , cnt = 0;
    }
    ans = max(ans , cnt);
    cout << ans;
    return 0;
}

Measured memory_bytes: 3608
n=int(input())
s=input()

sumBlack = [0]*(n+1)
sumWhite = [0]*(n+1)
for i in range(1,n+1):
    sumBlack[i] = sumBlack[i-1]
    if s[i-1] == '#':
        sumBlack[i] += 1

for i in range(n-1,-1,-1):
    sumWhite[i] = sumWhite[i+1]
    if s[i] == '.':
        sumWhite[i] += 1

ans = 12345678901234
for i in range(n+1):
    ans = min(ans,sumBlack[i]+sumWhite[i])
print(ans)

Measured memory_bytes: 43744
package main

// https://ja.wikipedia.org/wiki/%E3%83%9D%E3%83%A9%E3%83%BC%E3%83%89%E3%83%BB%E3%83%AD%E3%83%BC%E7%B4%A0%E5%9B%A0%E6%95%B0%E5%88%86%E8%A7%A3%E6%B3%95

// TLE at `echo -e "999993031" | go run scripts/ntl/1_A_factorization.go`

import (
	"bufio"
	"fmt"
	"math"
	"math/rand"
	"os"
	"strconv"
	"strings"
)

func modularExponentiation(a, b, n int) int {
	c := 0
	d := 1
	bits := fmt.Sprintf("%b", b)
	k := len(bits)
	for i := 0; i < k; i++ {
		c = 2 * c
		d = (d * d) % n
		if bits[i] == '1' {
			c++
			d = (d * a) % n
		}
	}
	return d
}

func isPrimeMillerRabin(n, s int) bool {
	if n%2 == 0 {
		return false
	}

	for j := 0; j < s; j++ {
		a := rand.Intn(n-1) + 1
		isComp := witness(a, n)
		// fmt.Println(a, n, isComp)
		if isComp {
			return false
		}
	}
	return true
}

func witness(a, n int) bool {
	t := 0
	u := n - 1
	for u%2 == 0 {
		t++
		u = u / 2
	}

	// fmt.Printf("a=%v, n=%v, t=%v, u=%v\n", a, n, t, u)

	x0 := 0
	x1 := modularExponentiation(a, u, n)
	// fmt.Printf("x0=%v, x1=%v\n", x0, x1)
	for i := 1; i <= t; i++ {
		x0 = x1
		x1 = (x1 * x1) % n
		// fmt.Printf("x0=%v, x1=%v, x1*x1=%v\n", x0, x1, x1*x1)
		if x1 == 1 && x0 != 1 && x0 != n-1 {
			return true
		}
	}

	return x1 != 1
}

var scanner = bufio.NewScanner(os.Stdin)

func nextString() string {
	scanner.Scan()
	return scanner.Text()
}

func nextInt() (int, error) {
	return strconv.Atoi(nextString())
}

func abs(n int) int {
	if n < 0 {
		return -n
	}
	return n
}

func gcd(x, y int) int {
	for {
		if x < y {
			tmp := x
			x = y
			y = tmp
		}
		if x%y == 0 {
			return y
		}
		x = x % y
	}
}

func g(x, n int) int {
	return (x*x + 1) % n
}

func getOneOfPrimeFactors(n int) int {
	x := 2
	y := 2
	d := 1
	for d == 1 {
		// fmt.Println(x, n)
		x = g(x, n)
		y = g(g(y, n), n)
		// fmt.Println(x, y)
		if x == y {
			break
		}
		d = gcd(abs(x-y), n)
	}
	if d == n-1 {
		return 1
	}
	return d
}

func appendPrimeFactors(primeFactors map[int]int, n int) {
	for i := 2; i <= n; i++ {
		for {
			if n%i != 0 {
				break
			}
			cnt, ok := primeFactors[i]
			if ok {
				primeFactors[i] = cnt + 1
			} else {
				primeFactors[i] = 1
			}
			n = n / i
		}
	}
}

func main() {
	scanner.Split(bufio.ScanWords)

	n, _ := nextInt()
	nOrig := n

	if isPrimeMillerRabin(nOrig, 50) {
		fmt.Printf("%v: %v\n", nOrig, nOrig)
		return
	}

	primeFactors := map[int]int{}

	for {
		// fmt.Println("n =", n)
		if n == 0 || n == 1 {
			break
		}
		f := getOneOfPrimeFactors(n)
		if f == 1 {
			appendPrimeFactors(primeFactors, n)
			break
		}
		// fmt.Printf("n=%v, f=%v\n", n, f)
		appendPrimeFactors(primeFactors, f)
		// fmt.Println(primeFactors)
		n = n / f
	}

	fmt.Print(nOrig, ":")
	output := ""
	nReconstructed := 1.0
	for i := 2; i <= nOrig; i++ {
		if primeFactors[i] > 0 {
			msg := " " + strconv.Itoa(i)
			output += strings.Repeat(msg, primeFactors[i])
			nReconstructed *= math.Pow(float64(i), float64(primeFactors[i]))
		}
		if int(nReconstructed) >= nOrig {
			break
		}
	}
	fmt.Println(output)
}



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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
	return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
	for(auto &e:u) fill_v<T>(e,v...);
}

template<typename F>
struct FixPoint : F{
  FixPoint(F&& f):F(forward<F>(f)){}
  template<typename... Args>
  decltype(auto) operator()(Args&&... args) const{
    return F::operator()(*this,forward<Args>(args)...);
  }
};
template<typename F>
inline decltype(auto) MFP(F&& f){
  return FixPoint<F>{forward<F>(f)};
}
vector<PII> G[112345];
vector<int64> a;
vector<int> res;
vector<int> visited;

int dfs(int64 v) {
  visited[v] = 1;
  int cnt = 0;
  for (auto &u : G[v]) {
    if (visited[u.fs]) continue;
    int x = dfs(u.fs);
    if (x) {
      res.push_back(u.sc);
      cnt++;
    }
  }
  return (cnt+a[v])%2;
}

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int64 N, M;
	cin >> N >> M;
	vector<PII> AB(N);
	REP(i, N) {
	  cin >> AB[i].fs >> AB[i].sc;
	}
	sort(all(AB));
	a.resize(N+1, 0);
	vector<int64> l(M), r(M);
	REP(i, N) {
	  a[i] = AB[i].sc;
	}
	for (int64 i = N; i >= 1; i--) {
	  a[i] = a[i] != a[i-1];
	}
	REP(i, M) {
	  cin >> l[i] >> r[i];
	  l[i] = lower_bound(all(AB), PII(l[i], -INF))-AB.begin(); r[i] = upper_bound(all(AB), PII(r[i], INF))-AB.begin();
	  if (l[i] == r[i]) continue;
	  G[l[i]].push_back({r[i], i+1}); G[r[i]].push_back({l[i], i+1});
	}
  visited.resize(N+1, 0);


	REP(i, N+1) {
	  if (visited[i]) continue;
	  if (dfs(i)) {
	    cout << -1 << endl;
	    return 0;
	  }
	}
	cout << res.size() << endl;
	sort(all(res));
	REP(i, res.size()) {
	  cout << res[i] << " ";
	}
	cout << endl;
}


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

int main() {
  int N;
  cin >> N;
  
    vector<int>  A(N);
  
  for(int i=0;i<N;i++){
  cin >> A.at(i);
  }
  
  for(int i=0;i<N;i++){
   
    if(A.at(i)%2==0){
      
      if(A.at(i)%3==0){
       continue; 
      }
      else if(A.at(i)%5==0){
      continue;
      }
      
      else{
      cout << "DENIED" << endl;
        exit(0);
      }

    }
     
    else{
    continue;
    }
  }
      
    
 

  cout << "APPROVED" << endl;
}


Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Xml.Schema;
using static System.Console;

namespace ConsoleApp2
{
    class Program
    {
        static public double[] Sarray() { return ReadLine().Split().Select(double.Parse).ToArray(); }
        static public List<int> Slist() { return new List<int>(ReadLine().Split().Select(int.Parse)); }
        static void Main(string[] args)
        {
            var WHxy = Sarray();
            var W = WHxy[0];
            var H = WHxy[1];
            var x = WHxy[2];
            var y = WHxy[3];
            var ans = W * H / 2;
            var ans2 = W / 2 == x && H / 2 == y ? 1 : 0;
            WriteLine($"{ans} {ans2}");
        }
    }
}

Measured memory_bytes: 13396
input = gets.chop.to_s

def gen_checker(start, length)
    ret = ""
    length.times do |i|
        ret = ret + ((i+start)%2).to_s
    end
    return ret
end


def distance(str1, str2)
    ret = 0
    str1.length.times do |k|
        if (str1[k] != str2[k]) then
           ret +=1
        end
    end
    return ret
end

p [
    distance(gen_checker(0,input.to_s.length), input),
    distance(gen_checker(1,input.to_s.length), input)
].min

Measured memory_bytes: 95664
def solve(n, k, x):
    ans = 2 * (max(x) - min(x))
    for i in range(n-k+1):
        left = x[i]
        right = x[i+k-1]
        if left * right >= 0:
            d = max(abs(right), abs(left))
        else:
            d = min(
                2 * abs(left) + abs(right),
                abs(left) + 2 * abs(right)
            )
        ans = min(ans, d)
    return ans

n, k = map(int, input().split())
x = list(map(int, input().split()))
print(solve(n, k, x))

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

string A, B, C;
using P = pair<char, int>;
vector<P> a, b, c;

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  getline(cin, A);
  getline(cin, B);
  getline(cin, C);
  char x;
  int y;
  stringstream ssa(A), ssb(B), ssc(C);
  while (ssa >> x >> y, x != '$') {
    a.emplace_back(x, y);
  }
  while (ssb >> x >> y, x != '$') {
    b.emplace_back(x, y);
  }
  while (ssc >> x >> y, x != '$') {
    c.emplace_back(x, y);
  }
  int az = a.size(), bz = b.size(), cz = c.size();
  int pos = -1;
  for (int i = 0; i + bz - 1 < az; i++) {
    if (a[i].first != b[0].first) continue;
    if (a[i].second < b[0].second) continue;
    if (a[i + bz - 1].first != b[bz - 1].first) continue;
    if (a[i + bz - 1].second < b[bz - 1].second) continue;
    int no = 0;
    for (int j = 1; j < bz - 1; j++) {
      if (a[i + j] != b[j]) no = 1;
    }
    if (!no) {
      pos = i;
      break;
    }
  }
  if (pos == -1) {
    for (int i = 0; i < az; i++) {
      cout << a[i].first << " " << a[i].second << " ";
    }
    cout << "$" << endl;
    return 0;
  }
  vector<P> v;
  for (int i = 0; i < pos; i++) {
    v.emplace_back(a[i]);
  }
  if (bz != 1 && a[pos].second - b[0].second) {
    v.emplace_back(a[pos].first, a[pos].second - b[0].second);
  }
  for (int i = 0; i < cz; i++) {
    v.emplace_back(c[i]);
  }
  if (a[pos + bz - 1].second - b[bz - 1].second) {
    v.emplace_back(a[pos + bz - 1].first, a[pos + bz - 1].second - b[bz - 1].second);
  }
  for (int i = pos + bz; i < az; i++) {
    v.emplace_back(a[i]);
  }
  vector<P> ans;
  int l = 0, r = 0;
  while (l < v.size()) {
    int sum = 0;
    while (r < v.size() && v[r].first == v[l].first) {
      sum += v[r++].second;
    }
    ans.emplace_back(v[l].first, sum);
    l = r;
  }
  for (int i = 0; i < ans.size(); i++) {
    cout << ans[i].first << " " << ans[i].second << " ";
  }
  cout << "$" << endl;

  return 0;
}


Measured memory_bytes: 3324
#include<bits/stdc++.h>
#define ll          long long int
#define lld          long double
#define pb          push_back
#define pii         pair<ll,ll>
#define mi          map<ll,ll>
#define vec         vector<ll>
#define all(a)     (a).begin(),(a).end()
#define F           first
#define S           second
#define mod         1000000007
#define rep(i,a,b)	for(ll  i=a;i<b;i++)
#define repi(i,a,b)	for(ll  i=a;i<=b;i++)
#define per(i,a,b)  for(ll i=a;i>=b;i--)
#define mp          make_pair
#define mit         map<ll,ll>::iterator
#define sit         set<ll>::iterator
#define pit         pair<ll,ll>::iterator
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
using namespace std;
ll xo(ll x, ll y) 
{ 
   return (x | y) & (~x | ~y); 
}  
ll bin_Expo(ll x,ll n)
{
		if(x==0)
		return 0;
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return bin_Expo(x*x,n/2);
    else                             //n is odd
        return x*bin_Expo(x*x,(n-1)/2);
}
ll mod_Expo(ll x,ll n,ll M)
{
		if(x==0)
		return 0;
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return mod_Expo((x*x)%M,n/2,M);
    else                             //n is odd
        return (x*mod_Expo((x*x)%M,(n-1)/2,M))%M;
 
}
ll NcR(int n, int r) 
{ 
    ll p = 1, k = 1; 
    if (n - r < r) 
        r = n - r; 
  
    if (r != 0) { 
        while (r) { 
            p *= n; 
            k *= r; 
            ll m=__gcd(p, k); 
            p /= m; 
            k /= m; 
            n--; 
            r--; 
        } 
    } 
    else
        p = 1; 
    return p;
}
bool prime_check(ll x)
{
    bool prime = (x >= 2);
    for (ll i = 2; i * i <= x; i++) 
    {
        if (x % i == 0) 
        {
            prime = false;
            break;
        }
    }
    return prime;
}
ll logg(ll base,ll x)
{
    return (ll)(log(x)/log(base));
}
bool cc(ll a, ll b, ll c)
{
	if((a+b<=c) || (a+c<=b) || (b+c<=a)) 
	return false;
	return true;
}
bool cd(ll a,ll b,ll c)
{
	if(a==b || b==c || a==c) return false;
	return true;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int TESTS=1;
//	cin>>TESTS;
    while(TESTS--)
    {
    	ll i,j,m,k,n,x,y;
    	cin>>n;
    	ll l[n]; x=0;
    	rep(i,0,n) cin>>l[i];
    	rep(i,0,n)
    	{
    		rep(j,i+1,n)
    		{
    			rep(k,j+1,n)
    			{
    				if(cd(l[i],l[j],l[k])==true && cc(l[i],l[j],l[k])==true) x++;
				}
			}
		}
    	cout<<x;
    } 
	return 0;
}













Measured memory_bytes: 3700
#include<bits/stdc++.h>
#define int long long
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef pair<int,int>P;
typedef pair<P,int>P2;
vector<P2>v[5000];
int MAX=1e15;
int dp[51][51],h,w;
int dy[]={0,1};
int dx[]={1,0};
string s[99];
int f=0;
void make_graph(int y,int x){
  r(i,51)r(j,51)dp[i][j]=0;
  dp[y][x]=s[y][x]-'0';
  for(int i=y;i<h;i++){
    for(int j=x;j<w;j++)if(isdigit(s[i][j])&&dp[i][j]){
      r(k,2){
	int yy=i+dy[k];
	int xx=j+dx[k];
	if(yy<0||xx<0||yy>=h||xx>=w)continue;
	if(s[yy][xx]=='+')continue;
	r(l,2){
	  int yyy=yy+dy[l];
	  int xxx=xx+dx[l];
	  dp[yyy][xxx]=max(dp[yyy][xxx],dp[i][j]*(s[yyy][xxx]-'0'));
	}
      }
    }
  }
   for(int i=y;i<h;i++){
    for(int j=x;j<w;j++)if(isdigit(s[i][j])){
	v[y*100+x].push_back(P2(P(i,j),dp[i][j]));
	if(dp[i][j]>MAX)f++;
    }
  }
}
signed main(){
  cin>>h>>w;
  r(i,h)cin>>s[i];
  r(i,h)r(j,w)if(isdigit(s[i][j]))make_graph(i,j);
  memset(dp,0,sizeof(dp));
  dp[0][0]=s[0][0]-'0';
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      if(dp[i][j]>MAX)f++;
      r(k,2){
	int y=i+dy[k];
	int x=j+dx[k];
	if(y<0||x<0||y>=h||x>=w)continue;
	if(s[y][x]=='*')continue;
	r(l,2){
	  int yy=y+dy[l];
	  int xx=x+dx[l];
	  dp[yy][xx]=max(dp[yy][xx],dp[i][j]+s[yy][xx]-'0');
	}
      }
      r(k,v[i*100+j].size()){
	int y=v[i*100+j][k].first.first;
	int x=v[i*100+j][k].first.second;
	int cost=v[i*100+j][k].second;
	dp[y][x]=max(dp[y][x],dp[i][j]+cost-(s[i][j]-'0'));
      }
    }
  }
  if(f)cout<<-1<<endl;
  else cout<<dp[h-1][w-1]<<endl;
}

Measured memory_bytes: 15312
def main():
    import sys
    from collections import defaultdict
    input = sys.stdin.readline

    N = int(input())
    A = list(map(int, input().split()))

    ans = 0
    flg = 0
    for i in range(N):
        if A[i] == i+1:
            if not flg:
                ans += 1
                flg = 1
            else:
                flg = 0
        else:
            flg = 0
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 52892
n=int(input())
A,B,C=map(int,input().split())
for x in range(n-1):
    a,b,c=map(int,input().split())
    a+=[B,C][B<C]
    b+=[A, C][A < C]
    c+=[B, A][B < A]
    A,B,C=a,b,c
print(max([A,B,C]))

Measured memory_bytes: 3064
#include <cstdio>

using namespace std;

int main() {
       // freopen("testcase", "r", stdin);

        int a, b, c;
        scanf("%d%d%d", &a, &b, &c);

        int cnt = 0;
        while (true) {
               
                if (a % 2 == 1 || b % 2 == 1 || c % 2 == 1) {
                        printf("%d\n", cnt);
                        return 0;
                }
                if (a == b && b == c) {
                        printf("-1\n");
                        return 0;
                }
                int ta = (b + c) / 2;
                int tb = (a + c) / 2;
                int tc = (a + b) / 2;
                cnt++;
                a = ta;
                b = tb;
                c = tc;

        }
        return 0;
}

Measured memory_bytes: 128
#include "bits/stdc++.h"
using namespace std;

int main(void) {
    string s;
    cin >> s;
    int m = atoi(s.substr(5, 2).c_str());
    if (m >= 5) {
        cout << "TBD";
    }
    else {
        cout << "Heisei";
    }
    return 0;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))

d = {}
for a in A:
    if a in d:
        d[a] += 1
    else:
        d[a] = 1

s = 0
for k in d:
    s += d[k] * (d[k] - 1) // 2

for i in range(N):
    t = d[A[i]]
    print(s - t * (t - 1) // 2 + (t - 1) * (t - 2) // 2)


Measured memory_bytes: 25716
#include <time.h>
char s[99];
struct tm T;
main(i,j,a,b,c,d,e){
	if(sizeof(time_t)!=8)exit(1);
	time_t t,t0=1356015600;
	for(;scanf("%s",s),*s!='#';){
		for(j=i=0;i<strlen(s);i++)if(s[i]=='.')j++;
		if(j==2){
			sscanf(s,"%d.%d.%d",&a,&b,&c);
			T.tm_year=a-1900;
			T.tm_mon=b-1;
			T.tm_mday=c;
			t=(mktime(&T)-t0)/86400%1872000;
			printf("%lld.%lld.%lld.%lld.%lld\n",t/144000,t/7200%20,t/360%20,t/20%18,t%20);
		}else{
			sscanf(s,"%d.%d.%d.%d.%d",&a,&b,&c,&d,&e);
			t=(a*144000LL+b*7200+c*360+d*20+e)*86400+t0;
			localtime_r(&t,&T);
			printf("%d.%d.%d\n",T.tm_year+1900,T.tm_mon+1,T.tm_mday);
		}
	}
exit(0);}

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

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

scanf("%d %d %d",&a,&b,&c);

if(a<=b)
 {
  if(c<=b)
  {
   printf("%d\n",a+c);
  }else{
   printf("%d\n",a+b);
  }
 }else{
  if(c<=b)
  {
   printf("%d\n",b+c);
  }else{
   if(a<=c)
   { 
     printf("%d\n",b+a);
   }else{
     printf("%d\n",b+c);
   }
  }
 }

return 0;
}


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

int A,B,C,X,Y;
void input()
{
    cin >> A >> B >> C >> X >> Y;
}

void solve()
{
    int MIN = min(X,Y);
    int ans = min(A + B, C * 2) * MIN;
    X -= MIN;
    Y -= MIN;
    ans += min(A, C * 2) * X + min(B, C * 2) * Y;
    cout << ans << endl;
}

int main()
{
    cin.tie();
    ios::sync_with_stdio(false);
    input();
    solve();
    return 0;
}

Measured memory_bytes: 3624