akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(var,cnt) for(int (var)=0; (var)<(int)(cnt); ++(var))
#define REP(var,init,cnt) for(int (var)=(init); (var)<(cnt); ++(var))
#define ran(var,vec) for(auto &(var):(vec))
#define all(v) (v).begin(),(v).end()
#define TF(flag) (flag)?1:0
using namespace std;

using ll = long long;
using ull = unsigned long long;
using pi = pair<int,int>;
using pl = pair<ll,ll>;
using ti = tuple<int,int,int>;
using tl = tuple<ll,ll,ll>;

template<typename T>
using vec = vector<T>;
template<typename T>
using mat = vector<vec<T>>;
template<typename T>
using cub = vector<mat<T>>;
template<typename T>
using val = valarray<T>;

template<typename T>
using pq = priority_queue<T>;
template<typename T>
using rpq = priority_queue<T,vec<T>,greater<T>>;

template<typename T1,typename T2>
ostream &operator<<(ostream &os, const pair<T1,T2> &p){
  os<<"P("<<p.first<<", "<<p.second<<") ";
  return os;
}

template<typename T1,typename T2>
istream &operator>>(istream &is, pair<T1,T2> &p){
  is>>p.first>>p.second;
  return is;
}

template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v){
  cout<<"V{";
  for(int i=0; i<(int)v.size(); ++i){
    os<<v[i]<<(i+1!=v.size()?" ":"");
  }
  cout<<"}";
  return os;
}

template<typename T>
istream &operator>>(istream &is, vector<T> &v){
  for(T &in:v) is>>in;
  return is;
}

template<typename T>
ostream &operator<<(ostream &os, const valarray<T> &v){
  cout<<"V{";
  for(int i=0; i<(int)v.size(); ++i){
    os<<v[i]<<(i+1!=v.size()?" ":"");
  }
  cout<<"}";
  return os;
}

template<typename T>
istream &operator>>(istream &is, valarray<T> &v){
  for(T &in:v) is>>in;
  return is;
}

// Usual Template End ================================================

// Template End ======================================================

int main(void){
  vec<string> s(3); cin>>s;
  std::locale l = std::locale::classic();
  cout<<toupper(s[0][0],l)<<toupper(s[1][0],l)<<toupper(s[2][0],l);
}














Measured memory_bytes: 256
#include<iostream>
#include"bits/stdc++.h"
using namespace std;
#define ll long long
#define FOR(i, j, k, in) for (ll i=j ; i<k ; i+=in)
#define RFOR(i, j, k, in) for (int i=j ; i>=k ; i-=in)
#define rep(i, j) FOR(i, 0, j, 1)
#define rrep(i, j) RFOR(i, j, 0, 1)
#define MP make_pair
#define PB push_back
#define INF (int)1e9
#define endl "\n"
#define MOD 1000000007
#define DEB(x) cout<<"##"<<x<<"##"<<endl;
void fastio()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
void solve1()
{
	int r;
	cin>>r;
	cout<<2*((double)(r))*(3.141592653589793238);
}
void solve()
{
	ll n,k;
	cin>>n>>k;
	ll sum=0;
	for(ll i=0;i<=n-k+1;i++)
	{
		sum=sum+1+(n*(n+1))/2-((i-1)*i)/2-((n-i)*(n-i+1))/2;	
		sum=sum%MOD;
	}	
	cout<<sum;
}
void solve2()
{
	int n;
	cin>>n;
	int ar[n+1];
	rep(i,n)
	cin>>ar[i+1];

}
int main()
{
	fastio();
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif
	solve();

	return 0;

	
}

Measured memory_bytes: 3688
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

class queue{
    int *time;
    char (*name)[11];
    int head, tail, size;
public:
    queue(int n){
        size = n;
        time = new int [size];
        name = new char [size][11];
        head = 0;
        tail = 0;
    };
    bool isEmpty(){
        return head==tail;
    };
    bool isFull(){
        return tail==head+size;
    };
    int &enqueue(char *s);
    int dequque(char *s);
};

int &queue::enqueue(char *s){
    if(isFull()){
        printf("queue is full.\n");
        exit(1);
    }
    strcpy(name[(tail)%size],s);
    tail = (tail+1) % (2*size);
    return time[(tail-1)%size];
}

int queue::dequque(char *s){
    if(isEmpty()){
        printf("queue is empty.\n");
        exit(1);
    }
    strcpy(s,name[(head)%size]);
    head = (head+1) % (2*size);
    return time[(head-1)%size];
}

int main(){
    int time, i, n, q;
    char name[11];
    int total = 0;
    scanf("%d",&n);
    scanf("%d",&q);
    queue ob(n);
    for(i=0;i<n;i++){
        scanf("%s %d",name,&time);
        ob.enqueue(name) = time;
    }
    while(!ob.isEmpty()){
        time = ob.dequque(name);
        if(time>q){
            ob.enqueue(name) = time-q;
            total += q;
        }else{
            total += time;
            printf("%s %d\n",name,total);
        }
    }
    return 0;
}



Measured memory_bytes: 3464
//
//$$$$$$$$$$$$$$$$$$$$$$
//$$                  $$
//$$   gyoubu_oniwa   $$
//$$                  $$
//$$$$$$$$$$$$$$$$$$$$$$
//
#include<bits/stdc++.h>
using namespace std;
#define DBG(a) if(DBGDO) cout<<#a<<':'<<a<<endl;
#define PB push_back
#define EB emplace_back
#define btoe(v) (v).begin(),(v).end()
#define etob(v) (v).rbegin(),(v).rend()
#define F first
#define S second
#define SZ size()
#define pow(a,b) (pow(a,b)+0.5)

typedef unsigned long long int ulli;
typedef long long int lli;
typedef long double ldbl;
#define f(i,a,b) for(int i=(a); i<(b); ++i)
#define fr(i,a,b) for(int i=(a); i>(b); --i)
#define fl(i,a,b) for(lli i=(a); i<(b); ++i)
#define flr(i,a,b) for(lli i=(a); i>(b); --i)
#define w(x) lli x; cin>>x; while(x--) 
#define inpn(n,v,T) T n; cin>>n; vector<T> v(n); fl(i,0,n) cin>>v[i];
#define inp(n,v,T) vector<T> v(n); fl(i,0,n) cin>>v[i];

typedef pair<int,int> pii;typedef vector<int> vi;typedef vector<vi> vvi;typedef vector<pii> vpii;typedef vector<vector<pii>> vvpii;typedef pair<lli,lli> plli;typedef vector<lli> vlli;typedef vector<vlli> vvlli;typedef vector<plli> vplli;typedef vector<vector<plli>> vvplli;typedef vector<bool> vb;typedef vector<string> vs;typedef vector<vector<string>> vvs;

#define unmp unordered_map

#define PRIME ((lli)(1e9+7ll))
#define PRIME2 (998244353ll)
const lli TEN_18 = 1e18;
const lli TEN_9 = 1e9;
const lli TEN_5 = 1e5;

inline void debugORfast(int a=1,int b=1){
    if(a){
        #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
        #endif
    }
    if(b){ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
}}

template<typename T>
void print(const T &v, int begin=-1, int end=-1, int w=2)
{
	if(begin<=end){
		if(begin==-1) fl(i,0,v.SZ) cout<<setw(w)<<v[i]<<' ';
		else if(end==-1) fl(i,begin,v.SZ) cout<<setw(w)<<v[i]<<' ';
		else fl(i,begin,end) cout<<setw(w)<<v[i]<<' ';
		cout<<endl;}
	else{
		if(begin==-1) flr(i,v.SZ-1,-1) cout<<setw(w)<<v[i]<<' ';
		else if(end==-1) flr(i,begin,-1) cout<<setw(w)<<v[i]<<' ';
		else flr(i,begin,end) cout<<setw(w)<<v[i]<<' ';
		cout<<endl;
	}
}

void pans(char v){
	switch(v){
		case 'y' : cout<<"yes"<<endl; break;
		case 'n' : cout<<"no"<<endl; break;
		case 'Y' : cout<<"Yes"<<endl; break;
		case 'N' : cout<<"No"<<endl; break;
		case 'B' : cout<<"YES"<<endl; break;
		case 'S' : cout<<"NO"<<endl; break;
	}
}

int DBGDO=0;

lli brute(){
	return 0;
}

lli solve(){
    return 0;
}

int main()
{
	debugORfast(0,1);
	//w(ttt)
	{
		lli n; cin>>n;
		string s;
		DBGDO=0;
		while(n){
			n--;
			DBG(n);
			s.PB((char)('a'+(n%26)));
			n/=26;
		}
		reverse(btoe(s));
		cout<<s<<endl;
	}
	return 0;
}


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


def solve(X, A):
    if X < A:
        print(0)
    else:
        print(10)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    X = int(next(tokens))  # type: int
    A = int(next(tokens))  # type: int
    solve(X, A)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
using System;

namespace Queue
{
	struct Process
	{
		public string name;
		public int remainTime;

		public Process(string name, int remainTime) {
			this.name = name;
			this.remainTime = remainTime;
		}
	}
	
	class Queue
	{
		private Process[] ringBuffer;
		private int head, tail;

		public Queue(int bufferSize) {
			ringBuffer = new Process[bufferSize];
			head = 0;
			tail = 0;
		}

		public void Enqueue(Process p) {
			ringBuffer[tail] = p;
			++tail;
			if (tail == ringBuffer.Length)
				tail = 0;
		}

		public Process Dequeue() {
			Process headProcess = ringBuffer[head];
			++head;
			if (head == ringBuffer.Length)
				head = 0;
			return headProcess;
		}

		public bool isEmpty() {
			return tail == head;
		}
	}

	class MainClass
	{
		public static void Main (string[] args)
		{
			Queue queue = new Queue (100000);

			// ??\??????????????????
			string[] n_q = Console.ReadLine ().Split (' ');
			int n = int.Parse(n_q [0]);
			int q = int.Parse(n_q [1]);
			for (int i = 0; i < n; ++i) {
				string[] name_time = Console.ReadLine ().Split(' ');
				queue.Enqueue (new Process (name_time [0], int.Parse(name_time [1])));
			}

			// ?????????????????????
			int passedTime = 0;
			while (!queue.isEmpty ()) {

				Process p = queue.Dequeue ();

				if (p.remainTime <= q) {
					// ?????????????????§????????????
					passedTime += p.remainTime;

					// ??????
					Console.WriteLine (p.name + " " + passedTime);
				} else {
					// ?????????????????????
					p.remainTime -= q;
					queue.Enqueue (p);
					passedTime += q;
				}

			}
				
		}
	}
}

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

signed main(){
	int N;
	cin >> N;
	vector<int> P(N);
	vector<int> Q(N);
	vector<int> tmp(N);
	for(int i=0;i<N;i++){
		cin >>P[i];
		tmp[i]=i+1;
	}
	for(int i=0;i<N;i++){
		cin>>Q[i];
	}
	int a,b,t;
	t=1;
	do{
		bool prop =true;
		bool proq=true;
		for(int i=0;i<N;i++){
			if(tmp[i]!=P[i])prop=false;
			if(tmp[i]!=Q[i])proq=false;
		}
		if(prop)a=t;
		if(proq)b=t;
		t++;
		if(prop && proq)break;
	}while(next_permutation(tmp.begin(),tmp.end()));
	
	cout<<abs(a-b)<<endl;
}



Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<utility>
#include<queue>
#include<string>
using namespace std;
typedef pair<int, int> P;
#define _CRT_SECURE_NO_WARNINGS
int N;
char s[502];
int dp[502][502];
bool Serch(int l,int r) {
	if (l>r) {
		return true;
	}
	if (s[l] != 'm') {
		return false;
	}
	if (s[r] !='w') {
		return false;
	}
	if (dp[l][r]!=-1) {
		if (dp[l][r]==0) {
			return false;
		}
		else {
			return true;
		}
	}
	bool ans = false;

	for (int i = l + 1; i < r;i++) {
		if (s[i]=='e') {
			if (Serch(l + 1, i - 1) && Serch(i+1,r-1) ) {
				dp[l][r] = 1;
				ans = true;
				break;
			}
		}
	}
	if (ans==false) {
		dp[l][r] = false;
	}

	return ans;
	
}

int main() {
	bool ans;
	int end;
	
		scanf("%s", s);
	for (int i = 0; i < 500; i++) {
		if (s[i]!='m' && s[i] != 'e'&& s[i] != 'w') {
			end = i;
			for (int k = 0; k < i;k++) {
				for (int j = 0; j < i;j++) {
					dp[j][k] = -1;
				}
			}
			break;
		}
	}
	ans = Serch(0,end-1);

	if (ans) {
		printf("Cat\n");
	}
	else {
		printf("Rabbit\n");
	}
	return 0;
}

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

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  if (a == b) {
    cout << c << endl;
  } else if (a == c) {
    cout << b << endl;
  } else {
    cout << a << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int X;
  cin >> X;
  int a=1;
  int b=1;
  for(int i=1;i<40;i++){
    b=1;
    for(int j=2;j<11;j++){
      b=b*i;
      if(b<=X && b>a){a=b;}
    }
  }
  if(X==10){cout << 9 << endl;}
  else{cout << a << endl;}
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
    int a,b,i,k;
	while(scanf("%d %d",&a,&b)!=EOF){
		a=a+b;
		for(i=1;i<8;i++){
			if(a<10) break;
			a=a/10;
		}
		printf("%d\n",i);
	}
	return 0;
}

Measured memory_bytes: 2600
#include <iostream>
#include <cmath>
int main(int argc, char const *argv[])
{
	double x1,y1,x2,y2;
	std::cin >> x1 >> y1 >> x2 >> y2;
	double res = (double)sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));
	printf("%.7lf\n",res);
	return 0;
}

Measured memory_bytes: 3292
/**
*    author:  yuya1234
*    created: 11.07.2020 21:00:17
**/

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)

#define SORT(x) sort(x.begin(),x.end())
#define SORTD(x) sort(x.rbegin(),x.rend())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define SZ(x) ll(x.size())

#define MEMSET(v, h) memset((v), h, sizeof(v))

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

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

  int l,r,d;
  cin>>l>>r>>d;

  int ans;
  ans=r/d-(l-1)/d;
  cout<<ans<<endl;

  return 0;
}

Measured memory_bytes: 3632
import collections


def main():
    N, M = map(int, input().split())

    count = collections.defaultdict(int)
    count_sccess = collections.defaultdict(bool)

    for _ in range(M):
        p, S = input().split()
        p = int(p)

        if S == "WA" and not count_sccess[p]:
            count[p] += 1
        if S == "AC" and not count_sccess[p]:
            count[p] += 0
            count_sccess[p] = True

    ans1 = 0
    ans2 = 0
    for a, b in zip(count, count_sccess):
        if count_sccess[b]:
            ans1 += 1
            ans2 += count[a]

    print(ans1, ans2)


main()


Measured memory_bytes: 21576
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan0
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/














int N, U[201010], V[201010];
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> N;
    rep(i, 0, N - 1) cin >> U[i] >> V[i];

    ll ans = 0;
    rep(L, 1, N + 1) ans += 1LL * L * (L + 1) / 2;
    rep(i, 0, N - 1) {
        if (U[i] > V[i]) swap(U[i], V[i]);
        ans -= 1LL * U[i] * (N - V[i] + 1);
    }
    cout << ans << endl;
}







Measured memory_bytes: 5216
#include<iostream>
#include<string>
#include<typeinfo>
#include<vector>
#include<algorithm>
using namespace std;
int main()
{
	int N;
	cin >> N;
	vector<int> L(2*N);
	for(int i=0; i<2*N; i++){
		cin >> L.at(i);
	}
	
	int sum = 0;
	sort(L.begin(), L.end());
	for(int i=0; i<N; i++){
		sum += L.at(2*i);
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
typedef vector<int> vi;
typedef queue<int> qi;
typedef long long ll;
typedef pair<int, int> pii;
typedef double db;


int main()
{
	int n; cin >> n;
	int val = n % 10;
	string a = "hon", b = "pon", c = "bon";
	if(val == 2 || val == 4 || val == 5 || val == 7 || val == 9) cout << a << endl;
	else if(val == 3) cout << c << endl;
	else cout << b << endl;

	return 0;
}


Measured memory_bytes: 3636
import java.util.*;
import java.io.*;
import java.lang.*;

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

        int a = sc.nextInt();
        int b = sc.nextInt();

        int at = 0;
        int bt = 1;
        int ans = 1;
        for (int i = 1; i<1000; i++){
            at = at+i;
            bt = bt + i + 1;
            if ((at-a)==(bt-b)){
                ans = at-a;
                break;
            }
        }

        System.out.println(ans);
    }
}

Measured memory_bytes: 35640
//void _(){
//    int n;
//    cin >> n;
//    vi arr(n);
//    cin >> arr;
//    int ans = MOD;
//    rep(i,-100,100){
//        int cur = 0;
//        for(int x : arr)
//            cur += (x-i)*(x-i);
//        ans = min(ans,cur);
//    }
//    print(ans);
//}
//
#include <iomanip>
#include <algorithm>
#include <cassert>
#include <vector>
#include <utility>
#include <iostream>
#include <string>
#define REP_INT(i,l,r) for(int i = l; i <= r; ++i)
#define GET_REP_MACRO(_1,_2,_3,_4,NAME,...) NAME
#define rep(...) GET_REP_MACRO(__VA_ARGS__,REP_ANY,REP_INT)(__VA_ARGS__)
#define all(v) (v).begin(), (v).end()
#define T1 template<typename T> static
using namespace std;
typedef long long ll;
typedef vector<int> vi;
const ll MOD = 1e9 + 7;
T1 ostream& operator<<(ostream& stream, const vector<T>& t);
T1 istream& read(T, T, istream& = cin);
T1 istream& operator>>(istream& stream, vector<T>& t){
    return read(all(t), stream);
}
T1 istream& read(T b, T e, istream& stream){
    for(T it = b; it != e; ++it)
        stream >> *it;
    return stream;
}
T1 void print(T x, string end = "\n"){
    cout << x << end;
}
void _(){
    int n;
    cin >> n;
    vi arr(n);
    cin >> arr;
    int ans = MOD;
    rep(i,-100,100){
        int cur = 0;
        for(int x : arr)
            cur += (x-i)*(x-i);
        ans = min(ans,cur);
    }
    print(ans);
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);
        _();
}


Measured memory_bytes: 256
n = int(input())
number = ""

while n != 0:
    a = n % 26
    if a == 0:
        number += (chr(a + 26 + 96))
        n = n // 26 - 1
    else:
        number += (chr(a + 96))
        n = n // 26
number = number[::-1]
print(number)

Measured memory_bytes: 9056
#include "stdio.h"
  
int c[200];
int c2[200];
  
int main()
{
int n;
scanf("%d",&n);
int m;
scanf("%d",&m);
for(int i = 0; i < 2 * n; i++)
{
c[i] = i + 1;
}
for(int i = 0; i < m; i++)
{
int w;
scanf("%d",&w);
if(w == 0)
{
for(int i = 0; i < n; i++)
{
c2[i * 2] = c[i];
c2[i * 2 + 1] = c[n + i];
}
}
else
{
int h = 0;
for(int i = w; i < 2 * n; i++)
{
c2[h] = c[i];
h++;
}
for(int i = 0; i < w; i++)
{
c2[h] = c[i];
h++;
}
}
for(int i = 0; i < 2 * n; i++)
{
c[i] = c2[i];
}
}
for(int i = 0; i < 2 * n; i++)
{
printf("%d\n",c[i]);
}
return 0;
}

Measured memory_bytes: 1028
/*
オーダー
10**6	余裕を持って間に合う	
10**7	おそらく間に合う	余裕を持って間に合う
10**8	非常にシンプルな処理でない限り厳しい	おそらく間に合う
10**9		非常にシンプルな処理でない限り厳しい
logn	:OK
n		:10^7
nlogn	:10^6
n**2	:10^4
n**3	:300
2**n	:20
n!		:10



// 各桁の和を計算する関数
int findSumOfDigits(int n) {
  int sum = 0;
  while (n > 0) { // n が 0 になるまで
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

sort(a, a + N, greater<int>());  // a[0:N] を大きい順にソート

int num[110] = {0};  // バケット
for (int i = 0; i < N; ++i) {
    num[d[i]]++;  // d[i] が 1 個増える
}

map<string, int> mp; // 連想配列 map<キー型, 値型> オブジェクト名
for (int i = 0; i < N; ++i) {
    auto itr = mp.find(s[i]);        // s[i] が設定されているか？
    if(itr != mp.end() ) {
         mp[s[i]] += 1;
    }
    else {
         mp[s[i]] += 1 ;
    }
}
stack<int> s;	//intをデータとするスタックを用意
s.push(1);		//{} -> {1}
printf("%d\n", s.top());	// 3
s.pop();

queue<int> que;	//intをデータとするキューを用意
que.push(1);		//{} -> {1}
printf("%d\n", que.front());	// 1
que.pop();
*/

#include <iostream>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <string.h>

using namespace std;

// #define for(i,a,b) for (int i=(a);i<(b);++i)
typedef long long ll;
typedef pair<ll,ll> P;
#define REP(i,n) for(long long i = 0; i < (long long)(n); i++)
#define pb push_back // vectorに要素追加
#define INF (ll)1e18
// int 
// // 各桁の和を計算する関数
// int findSumOfDigits(int n) {
//   int amari = 0;
//   int keta = 0;
//   while (n > 0) { // n が 0 になるまで
//     amari += n % 2;
//     if (keta%2==0)
//     n /= 10;
//   }
//   return sum;
// }
 
ll gcd(ll a, ll b) {
	if(b == 0) return a;
	return gcd(b, a % b);
}

// const ll MAX_N = 1e5;
// ll N;
// ll h[MAX_N];
// ll dp[MAX_N+1]; // メモ化テーブル
 
// // i番目以降の品物から重さの総和がj以下になるように選ぶ
// void rec(ll i){
// 	if (i==0) dp[i] = 0;
// 	else if (i==1) dp[i] = abs(h[1]-h[0]);
// 	else dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2]));
// 	return;
// }
 
 
int main() {
	// 入力
	ll N;
	cin >> N;
	ll a[3*N];
	for (ll i = 0; i < 3*N; ++i) cin >> a[i];
 
	// 解法
	sort(a, a+3*N, greater<ll>());
	// REP(i,N*3)printf("%lld ", a[i]);
	// printf("\n");
	ll ans = 0;
	REP(i,N) ans += a[i*2+1];
	
	//出力
	cout << ans << endl;
}


Measured memory_bytes: 2560
#include <iostream>
#include <stdio.h>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <set>
#include <map>
#include <deque>
#include <math.h>
#include <string>
#include <iomanip>
#include <locale>
#include <list>
#include <bitset>
using namespace std;
#define FORN(i,m,n) for(ll i=(m); i<ll(n); i++)
#define PRINTVEC(v) FORN(i,0,v.size()) cout<<v[i]<<" "; cout<<endl
#define PRINTMAT(m) FORN(j,0,m.size()) {PRINTVEC(m[j]);}
#define PB(x) push_back(x)
#define MP(a,b) make_pair(a,b)
typedef long long ll;
 
ll n,k;
vector<ll> v, sum;
 
ll Test(ll cur){
  ll cnt = 0;
  FORN(i,0,n) cnt += v.end() - lower_bound(v.begin(),v.end(),cur - v[i]);
  return cnt;
}
 
int main(){
  ios_base::sync_with_stdio(false); cin.tie(NULL);
  cin>>n>>k;
  v = sum = vector<ll> (n);
  FORN(i,0,n) cin>>v[i];
  sort(v.begin(),v.end());
  sum[0] = v[0];
  FORN(i,1,n) sum[i] = sum[i-1] + v[i];
  ll l = 0, r = 1e18, m;
  while(l <= r){
    m = (l + r) >> 1;
    if(Test(m) < k) r = m - 1;
    else l = m + 1;
  }
  ll ans = 0;
  FORN(i,0,n){
    int cur = upper_bound(v.begin(),v.end(),r - v[i]) - v.begin();
    if(cur < n){
      ans += sum[n-1] + v[i] * (n - cur);
      if(cur) ans -= sum[cur-1];
      k -= n - cur;
    }
  }
  ans += k * r;
  cout<<ans<<endl;
}

Measured memory_bytes: 1792
import itertools
n = int(input())
P = list(map(int,input().split()))
Q = list(map(int,input().split()))
cnt = 0
ans = []
for per in itertools.permutations(range(1,n+1)):
  cnt += 1
  if list(per) == P:
    ans.append(cnt)
  elif list(per) == Q:
    ans.append(cnt)

print(max(ans)-min(ans))

Measured memory_bytes: 9032
from collections import defaultdict
from heapq import heappop, heappush


class Graph(object):
    """
    隣接リストによる有向グラフ
    """

    def __init__(self):
        self.graph = defaultdict(list)

    def __len__(self):
        return len(self.graph)

    def add_edge(self, src, dst, weight=1):
        self.graph[src].append((dst, weight))

    def get_nodes(self):
        return self.graph.keys()


class Dijkstra(object):
    """
    ダイクストラ法（二分ヒープ）による最短経路探索
    計算量: O((E+V)logV)
    """

    def __init__(self, graph, start):
        self.g = graph.graph

        # startノードからの最短距離
        # startノードは0, それ以外は無限大で初期化
        self.dist = defaultdict(lambda: float('inf'))
        self.dist[start] = 0

        # 最短経路での1つ前のノード
        self.prev = defaultdict(lambda: None)

        # startノードをキューに入れる
        self.Q = []
        heappush(self.Q, (self.dist[start], start))

        while self.Q:
            # 優先度（距離）が最小であるキューを取り出す
            dist_u, u = heappop(self.Q)
            if self.dist[u] < dist_u:
                continue
            for v, weight in self.g[u]:
                alt = dist_u + weight
                if self.dist[v] > alt:
                    self.dist[v] = alt
                    self.prev[v] = u
                    heappush(self.Q, (alt, v))

    def shortest_distance(self, goal):
        """
        startノードからgoalノードまでの最短距離
        """
        return self.dist[goal]

    def shortest_path(self, goal):
        """
        startノードからgoalノードまでの最短経路
        """
        path = []
        node = goal
        while node is not None:
            path.append(node)
            node = self.prev[node]
        return path[::-1]


g = Graph()
#N, M = [int(i) for i in input().split()]
N = int(input())

for i in range(N-1):
    u, v = [int(i) for i in input().split()]
    g.add_edge(u-1, v-1, 1)
    g.add_edge(v-1, u-1, 1)

d1 = Dijkstra(g, 0)
d2 = Dijkstra(g, N-1)

ans = 0

#print(d1.dist)
#print(d2.dist)

for i in range(N):
    if d1.dist[i] <= d2.dist[i]:
        ans += 1

if ans > N - ans:
    print("Fennec")
else:
    print("Snuke")

Measured memory_bytes: 77772
#include <iostream>
#include <vector>
#include <utility>
#include <string>
#include <cmath>
#include <algorithm>
#include <string>


using namespace std;
using ll = long long;
using ull = unsigned long long;


#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,a,b) for(ll i=a-1;i>=b;i--)

int main() {

	ll n, k;

	cin >> n >> k;

	n = n % k;


	ll pren = n;
	while (true) {
		n = abs(n-k);
		if (n > pren || pren == 0) {
			cout << pren << endl;
			break;
		}
		pren = n;

	}

	return 0;
}



Measured memory_bytes: 256
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>
#include <stack>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = n - 1; i >= 0; i--)
#define repone(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define each(i, mp) for(auto i:mp)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll half_inf = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);

ll N, M, Q;
vector<ll> l, r, p, q;

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

    scanf("%lli%lli%lli", &N, &M, &Q);
    l.resize(M), r.resize(M), p.resize(Q), q.resize(Q);
    ll d[N + 1][N + 1];
    fill(d[0], d[N + 1], 0);
    rep(i, M) {
        scanf("%lli%lli", &l[i], &r[i]);
        d[l[i]][r[i]]++;
    }
    ll dp[N + 1][N + 1];
    fill(dp[0], dp[N + 1], 0);

    repone(i, N)repone(j, N) dp[i][j] = dp[i][j - 1] + d[i][j];

    rep(i, Q) {
        scanf("%lli%lli", &p[i], &q[i]);
        ll ans = 0;
        for (ll j = p[i]; j <= q[i]; ++j) {
            ans += dp[j][q[i]] - dp[j][p[i] - 1];
        }
        printf("%lli\n", ans);
    }
    return 0;
}

Measured memory_bytes: 9600
fun main(args: Array<String>) {
    val (n, q) = readLine()!!.split(" ").map(String::toInt)
    val s = readLine()!!
    val lrs = Array(q) { readLine()!!.split(" ").map(String::toInt) }
    val ts = Array(n+1) { 0 }

    for (i in 0..n-2) {
        if (s[i] == 'A' && s[i + 1] == 'C') {
            ts[i + 1] = ts[i] + 1
        } else {
            ts[i + 1] = ts[i]
        }
    }

    for (lr in lrs) {
        println(ts[lr[1] - 1] - ts[lr[0] - 1])
    }
}


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

if H % 3 == 0 or W % 3 == 0:
    print(0)

else:
    result = []
    for i in range(1, H):
        s1 = i * W
        if (H - i) % 2 == 0 or W % 2 == 0:
            s2 = (H - i) * W // 2
            result.append(max(s1, s2) - min(s1, s2))
        else:
            s2 = (H - i) // 2 * W
            s3 = (H - i) * W - s2
            result.append(max(s1, s2, s3) - min(s1, s2, s3))
            s2 = (H - i) * (W // 2)
            s3 = (H - i) * W - s2
            result.append(max(s1, s2, s3) - min(s1, s2, s3))

    for i in range(1, W):
        s1 = i * H
        if (W - i) % 2 == 0 or H % 2 == 0:
            s2 = (W - i) * H // 2
            result.append(max(s1, s2) - min(s1, s2))
        else:
            s2 = (W - i) // 2 * H
            s3 = (W - i) * H - s2
            result.append(max(s1, s2, s3) - min(s1, s2, s3))
            s2 = (W - i) * (H // 2)
            s3 = (W - i) * H - s2
            result.append(max(s1, s2, s3) - min(s1, s2, s3))

    print(min(result))


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

N, X, Y = map(int, input().split())

mid = (X + Y + 1) * 0.5

# GUCHOKU
ans = [0] * N

for i in range(1, N):
    for j in range(i, N + 1):
        dis = min(abs(i - X) + abs(j - Y) + 1, j - i)
        ans[dis] += 1

print(*ans[1:], sep='\n')


Measured memory_bytes: 45532
#include <algorithm>
#include <iostream>
#include <string>
#include <cstring>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iomanip>
#include <limits>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <iterator>
#include <queue>
#include <stack>
#include <vector>
#include <utility>

#define FOR(i,k,n) for(int (i) = (k); (i) < (n); ++(i))
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
#define all(v) begin(v), end(v)
#define debug(x) cerr << #x << ": " << x << endl
#define debug2(x,y) cerr << #x << ": " << x << ", " << #y << ": " << y << endl

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<i_i, int> p_i;
typedef vector<int> vi;
typedef vector< vector<int> > vvi;
template<class T> using vv=vector< vector<T> >;
typedef deque<int> di;
typedef deque< deque<int> > ddi;

#define INF 2000000000

int main() {
    cin.tie(0);
    priority_queue<i_i> Q; //cost, to
    int V, E, r;
    vector<i_i> VP[100005]; //cost, to  
    int cost[100005];
    set<int> S;
    cin >> V >> E >> r;

    rep(i,E) {
        int s, t, c;
        scanf("%d%d%d", &s,&t,&c);
        VP[s].pb(mp(-1 * c,t));
    }

/*
    rep(i,V) {
        rep(j,VP[i].size()){
            debug2(VP[i][j].first, VP[i][j].second);
        }
    }
*/

    Q.push(mp(0,r));

    while(!Q.empty()) {
        if(Q.empty()) {
            break;
        }
        i_i q = Q.top();
        Q.pop();
        if(S.find(q.second) != S.end()) {
            continue;
        }
        cost[q.second] = q.first;
        
        S.insert(q.second);
        rep(i,VP[q.second].size()) {
            Q.push(mp(q.first + VP[q.second][i].first, VP[q.second][i].second));
        }
    }

    rep(i,V) {
        if(r == i || (cost[i] > -INF && cost[i] != 0)) {
            printf("%d\n",-1 * cost[i]); 
        } else {
            printf("INF\n");
        }
    }

	return 0;
}

Measured memory_bytes: 18428
#include <iostream>
#include <string>
#include <algorithm>
 
using namespace std;
 
 
int main()
{
int N,M;
cin>>N;
cin>>M;
int K[N];
int A[N][M];
int min=30;
int num=0;
for(int j=0;j<N;j++){
  cin>>K[j];
  if(min>K[j]){
    min=K[j];
    num=j;
  }
  for(int i=0;i<K[j];i++){
cin>>A[j][i];
  }
}
int count=0;
int sum=0;
for(int k=0;k<min;k++){
  count=0;
  for(int j=0;j<N;j++){
    for(int i=0;i<K[j];i++){
if(A[num][k]==A[j][i])count=count+1;
    }
  }
  if(count==N)sum=sum+1;
}
 
cout<<sum<<endl;
return 0;
}

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

if n >= 64:
    print(64)
elif n >= 32:
    print(32)
elif n >= 16:
    print(16)
elif n >= 8:
    print(8)
elif n >= 4:
    print(4)
elif n >= 2:
    print(2)
else:
    print(1)

Measured memory_bytes: 3060
def judge_color(n):
  if 1 <= n <= 399:
    return "gray"
  elif 400 <= n <= 799:
    return "brown"
  elif 800 <= n <= 1199:
    return "green"
  elif 1200 <= n <= 1599:
    return "sky"
  elif 1600 <= n <= 1999:
    return "blue"
  elif 2000 <= n <= 2399:
    return "yellow"
  elif 2400 <= n <= 2799:
    return "orange"
  elif 2800 <= n <= 3199:
    return "red"
  else:
    return "free"

n = int(input())
a = list(map(int, input().split()))

d = {}
for each in a:
  color = judge_color(each)
  d[color] = d.get(color, 0) + 1
  
c = d.get("free",0)
l = len(d)
if c == 0:
  print(l, l)
else:
  print(max(l-1,1), l-1+c)

Measured memory_bytes: 3188
import java.io.*;
import java.util.Arrays;
import java.util.StringTokenizer;

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

        int n = in.nextInt();
        int k = in.nextInt();
        Integer[] hs = new Integer[n];
        for (int i=0; i<n; i++)  {
            hs[i] = in.nextInt();
        }
        Arrays.sort(hs);
        int min = Integer.MAX_VALUE;
        int[] del = new int[n - k + 1];
        for (int i=0; i<n - k + 1; i++) {
            del[i] = hs[i + k - 1] - hs[i];
            min = del[i] < min ? del[i]: min;
        }
        out.println(min);



        out.close();
        //INT OVERFLOW -> USE LONG
        //ARR OUT OF BOUNDS
    }

    static class Scanner {
        StringTokenizer st;
        BufferedReader br;

        public Scanner(InputStream s) {
            br = new BufferedReader(new InputStreamReader(s));
        }

        public Scanner(String s) {
            try {
                br = new BufferedReader(new FileReader(s));
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            }
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

        public String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }

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

        public double nextDouble() {
            return Double.parseDouble(next());
        }

        public int[] nextIntArray(int n) {
            int[] arr = new int[n];
            for (int i = 0; i < n; i++) {
                arr[i] = nextInt();
            }
            return arr;
        }

        public double[] nextDoubleArray(int n) {
            double[] arr = new double[n];
            for (int i = 0; i < n; i++) {
                arr[i] = nextDouble();
            }
            return arr;
        }

        public long[] nextLongArray(int n) {
            long[] arr = new long[n];
            for (int i = 0; i < n; i++) {
                arr[i] = nextLong();
            }
            return arr;
        }

        public char[] nextCharArray(int n) {
            char[] arr = nextLine().trim().replaceAll("\\s", "").toCharArray();
            return arr;
        }

        public String[] nextStringArray(int n) {
            String[] arr = new String[n];
            for (int i = 0; i < n; i++) {
                arr[i] = next();
            }
            return arr;
        }
    }
}


Measured memory_bytes: 39088
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>
#include <cstring>
#include <cassert>


using namespace std;
#define SZ(x) (int)(x.size())
#define REP(i, n) for(int i=0;i<n;++i)
#define FOR(i, a, b) for(int i=a;i<b;++i)
#define RREP(i, n) for(int i=n-1;i>=0;--i)
#define RFOR(i, a, b) for(int i=b-1;i>=a;--i)

#define all(x) begin(x),end(x)
#define dump(x) cerr<<#x<<" = "<<(x)<<endl
#define debug(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<< endl;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<int, int>;
const double eps = 1e-8;
const ll MOD = 1000000007;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;

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

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


template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> p) {
    os << p.first << ":" << p.second;
    return os;
}

template<class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
    os << "[";
    REP(i, SZ(v)) {
        if (i) os << ", ";
        os << v[i];
    }
    return os << "]";
}

template<class T1, class T2>
ostream &operator<<(ostream &os, const map<T1, T2> &mp) {
    os << "[";
    for (auto it = mp.begin(); it != mp.end(); ++it) {
        if (it != mp.begin()) {
            os << ", ";
        }
        os << *it;
    }
    return os << "]";
}

// edit

void solve() {
    int N;
    cin >> N;

    vector<int> a(N);
    REP(i, N) cin >> a[i];

    int ans = 0;
    REP(i, N) {
        if (i % 2 == 0 && a[i] % 2 == 1) ans++;
    }

    cout << ans << endl;
}


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
//    std::ifstream in("input.txt");
//    std::cin.rdbuf(in.rdbuf());

    solve();


    return 0;
}


Measured memory_bytes: 3192
#include<stdio.h>
int main()
{
	int n;
	scanf("%d",&n);
	if(n == 1){
		printf("Hello World\n");
	}
	else if(n == 2){
		int a,b;
		scanf("%d %d",&a,&b);
		printf("%d\n",a+b);
	}

		return 0;
	}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

int main(){
	ll n;
	cin >> n;
	ll x;
	vector<ll> a(n);
	for(int i = 0; i < n; i++) {
		cin >> x;
		a[i] = x;
	}
	sort(ALL(a));
	ll ans = 0;
	ll tmp= 1;
	for(int i = 1; i < n; i++) {
		if(a[i - 1] == a[i]){
			tmp++;
		}
		else if(a[i - 1] != a[i]){
			if(tmp>a[i - 1]){
				ans += (tmp - a[i - 1]);
				tmp = 1;
			}
			else if(tmp < a[i - 1]){
				ans += tmp;
				tmp = 1;
			}
			else{
				tmp = 1;
			}
		}
		// cout << tmp << endl;
	}
	if(tmp>a[n - 1]){
			ans += (tmp - a[n - 1]);
	}
	else if(tmp < a[n - 1]){
			ans += tmp;
	}
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>

using namespace std;

typedef long long ll;

ll s[500005];
ll dp[2][(1 << 20)];
ll cnt[(1 << 20)];

const ll mod = 1e9 + 7;
ll p(ll a, ll x) {
  ll res = 1;
  while(x > 0) {
    if(x & 1) res = res * a % mod;
    a = a * a % mod;
    x >>= 1;
  }
  return res % mod;
}

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


  for(int i = 0; i < n; i++) {
    ll A;
    cin >> A;
    s[i+1] = s[i] ^ A;
  }

  //for(int i = 1; i <= n; i++) cout << s[i] << endl;

 
  for(int i = 1; i <= n; i++) {
    dp[0][s[i]] = 1;
  }
  
  ll z = 0;
  for(int i = 1; i <= n; i++) {
    if(s[i] == 0) z++;
    dp[0][s[i]] = (dp[0][s[i]] + (dp[1][s[i]] * (z - cnt[s[i]]) % mod)) % mod;
    dp[1][s[i]] = (dp[1][s[i]] + dp[0][s[i]]) % mod;
    cnt[s[i]] = z;
  }

  ll ans = 0;
  if(s[n] == 0) {
    ans += p(2,z-1);
    for(int i = 1; i  < (1 << 20); i++) {
      ans = (ans + dp[1][i]) % mod;
    }
  }
  else {
    ans = dp[0][s[n]];
  }

  cout << ans << endl;
}
  


Measured memory_bytes: 28672
#include<stdio.h>

int main(){
  int n = 0;
  int a[100] = {};
  int b[100] = {};
  int i = 0;
  int j = 0;
  int cnt = 0;
  int maxcnt = 0;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
  }
  for(i=0;i<n;i++){
    scanf("%d",&b[i]);
  }
  for(i=0;i<n;i++){
    cnt = 0;
    for(j=0;j<n;j++){
      if(i>j){
        cnt += a[j];
      }else if(i==j){
        cnt += a[j] + b[j];
      }else{
        cnt += b[j];
      }
    }
    if(cnt > maxcnt){
      maxcnt = cnt;
    }
  }
  
  printf("%d",maxcnt);
  return 0;
}
       

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

L = [0 for _ in range(10 ** 5 + 2)]

for a in A:
    L[a] += 1

ans = 0
for i in range(1,100001):
    ans = max(ans,L[i-1]+L[i]+L[i+1])

print(ans)

Measured memory_bytes: 13964
#include <bits/stdc++.h>
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <errno.h>
#include <stdlib.h>
#include <time.h>
#include <assert.h>
using namespace std;
int main()
{
    long long unlambda;
    long long prolog;
    cin>>unlambda>>prolog;
    cout<<unlambda*prolog<<"\n";
    return 0;
}

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

class UnionFind {
  public:
    // 親の番号を格納する。親だった場合は-(その集合のサイズ)
    vector<int> Parent;
    vector<int> diff;

    // 作る時はParentの値を全て-1にする
    // こうすると全てバラバラが表現できる。
    UnionFind(int N) {
      Parent = vector<int>(N, -1);
      diff = vector<int>(N, 0);
    }

    // Aがどのグループに属しているか調べる
    int root(int A) {
      if(Parent[A] < 0) return A;
      else {
        int r = root(Parent[A]);
        diff[A] += diff[Parent[A]];
        return Parent[A] = r;
      }
    }

    int size(int A) {
      return -Parent[root(A)]; // 親を取ってきたい
    }

    int weight(int x) {
      root(x);
      return diff[x];
    }

    bool connect(int A, int B, int w) {
      w += weight(A); w -= weight(B);
      // AとBを直接繋ぐのではなく、root(A)をroot(B)をくっつける
      A = root(A);
      B = root(B);
      if(A == B) {
        //すでにくっついているからくっつけない
        return false;
      }

      // 大きい方に小さい方をくっつけたい
      // 代償が逆だったらひっくり返す
      if(size(A) < size(B)) swap(A, B), w = -w;
      // Aのsizeを更新
      Parent[A] += Parent[B];
      // Bの親をAに変更する
      Parent[B] = A;
      diff[B] = w;

      return true;
    }

    int dif(int x, int y) {
      return weight(y) - weight(x);
    }
};

int main() {
  int N, M; cin >> N >> M;
  UnionFind uni(N);
  for(int i = 0; i < M; ++i) {
    int L, R, D; cin >> L >> R >> D; L--, R--;
    if(uni.root(L) != uni.root(R)) {
      uni.connect(L, R, D);
    } else {
      if(uni.dif(L, R) != D) {
        cout << "No" << endl;
        return 0;
      }
    }
  }
  cout << "Yes" << endl;
  return 0;
}


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

long long int lnCookie[2];
int operation(int who);

int main() {
    int nCnt = 0, Who = 0;
    cin >> lnCookie[0] >> lnCookie[1] >> nCnt;  //前一个0是高桥，后一个1是青木
    while (Who < nCnt) {
        operation(Who % 2);
        ++Who;
    }
    cout << lnCookie[0] << " " << lnCookie[1];
    return 0;
}

int operation(int who) {
    if (lnCookie[who] % 2) --lnCookie[who];
    lnCookie[who] = lnCookie[who] / 2;
    lnCookie[who ? 0 : 1] += lnCookie[who];
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string.h>
#define rep(i, n) for(int i = 0; i<(n); i++)
using namespace std;
typedef long long ll;
static const int MAX = 200000; 
//pi = 3.14159265358979323846

int main() {

	int n, a, b;
  	cin >> n >> a >> b;
  	cout << min(n * a, b) << endl;
  	
  	
}


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

int main(){
    char a[4],b[4];
    int count = 0;
    cin >> a >> b;
    
    for(int i = 0; i < 3; i++){
        if(a[i] == b[i]){
            count++;
        }
    }
    
    cout << count << endl;
    
    return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
n,a,b,c = map(int,input().strip().split())
cc = []
for i in range(n):
  ff = input().strip()
  cc.append((ff))
  
chk = True
ans = []
for num,q in enumerate(cc):
  if q[0] == 'A' and q[1] == 'B':
    m = max(a,b)
    if m < 1:
      chk = False
      break
    if a == 1 and b == 1:
      if num == n-1:
        ans.append('A')
      else:
        if cc[num+1][0] == 'A':
          a += 1
          b -= 1
          ans.append('A')
        else:
          a -= 1
          b += 1
          ans.append('B')       
    elif m == a:
      a -= 1
      b += 1
      ans.append('B')
    else:
      a += 1
      b -= 1
      ans.append('A')      
  if q[0] == 'A' and q[1] == 'C':
    m = max(a,c)
    if m < 1:
      chk = False
      break
    if c == 1 and a == 1:
      if num == n-1:
        ans.append('A')
      else:
        if cc[num+1][0] == 'A':
          a += 1
          c -= 1
          ans.append('A')
        else:
          a -= 1
          c += 1
          ans.append('C')       
    elif m == a:
      a -= 1
      c += 1
      ans.append('C')       
    else:
      a += 1
      c -= 1
      ans.append('A')       
  if q[0] == 'B' and q[1] == 'C':
    m = max(b,c)
    if m < 1:
      chk = False
      break
    if c == 1 and b == 1:
      if num == n-1:
        ans.append('B')
      else:      
        if cc[num+1][1] == 'C':
          c += 1
          b -= 1
          ans.append('C')
        else:
          c -= 1
          b += 1
          ans.append('B')       
    elif m == b:
      b -= 1
      c += 1
      ans.append('C')
    else:
      b += 1
      c -= 1
      ans.append('B')
      
if not chk:
  print('No')
else:
  print('Yes')
  print(*ans,sep='\n')


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

int main() {
  char c;
  cin >> c;
  if (c == 'a') {
    cout << "vowel" << endl;
  }
  else if (c == 'i') {
    cout << "vowel" << endl;
  }
  else if (c == 'u') {
    cout << "vowel" << endl;
  }
  else if (c == 'e') {
    cout << "vowel" << endl;
  }
  else if (c == 'o') {
    cout << "vowel" << endl;
  }
  else {
    cout << "consonant" << endl;
  }
}


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

int main()
{
    long long int x;

    cin >> x;

    long long int money = 100;

    int year = 0;

    while(1){
        year++;
        money = 1.01 * money;
        if(money >= x) break;
    }

    cout << year << endl;

    return 0;
}

Measured memory_bytes: 3180
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

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

void solve() {
  int n;
  cin >> n;
  map<int, int> dp;
  while(n--) {
    int t;
    cin >> t;
    dp[t]++;
  }
  int ret = 0;
  for(auto x: dp) ret += x.second % 2;
  cout << ret << "\n";
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  /*
  int t;
  cin >> t;
  for(int i = 1; i <= t; i++) {
    cout << "Case #" << i << ": ";
    solve();
  }
  */
  solve();
}


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

int main(){
  string s, t;
  
  cin >> s;
  cin >> t;
  
  if(s.size() != t.size() - 1){
    cout << "No" << endl;
    return 0;
  }
  
  for(int i = 0; i < s.size(); i++){
    if(s[i] != t[i]){
      cout << "No" << endl;
      return 0;
    }
  }
  
  cout << "Yes" << endl;
  
  return 0;
}

Measured memory_bytes: 3608
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
//const ll mod=998244353;
const ll mod=1000000007;
ll GCD(ll a,ll b) {return b ? GCD(b,a%b):a;}
ll LCM(ll c,ll d){return c/GCD(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int main(){
    int n;
    cin>>n;
    V<ll> a(n);
    ll now=0;
    for(int i=0;i<n;i++){
        cin>>a[i];
        now^=a[i];
    }
    for(int i=0;i<n;i++){
        cout<<(now^a[i])<<" ";
    }
    cout<<"\n";
}


Measured memory_bytes: 4720