akhauriyash/Code-Regression huggingface dataset:
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {

		new Main().run();
	}

	@SuppressWarnings("unchecked")
	private void run() throws IOException {
		Scanner scanner = new Scanner(System.in);
		while (true) {
			int n = scanner.nextInt();
			int k = scanner.nextInt();
			if ((n | k) == 0)
				break;
			List<Edge>[] lists = new ArrayList[n];
			for (int i = 0; i < n; i++)
				lists[i] = new ArrayList<Edge>();
			while (k-- > 0) {
				int a = scanner.nextInt();
				if (a == 1) {
					int b = scanner.nextInt() - 1;
					int c = scanner.nextInt() - 1;
					int d = scanner.nextInt();
					lists[b].add(new Edge(c, d));
					lists[c].add(new Edge(b, d));
				} else {
					int s = scanner.nextInt() - 1;
					int g = scanner.nextInt() - 1;
					PriorityQueue<Edge> pq = new PriorityQueue<Edge>();
					pq.offer(new Edge(s, 0));
					int ans = -1;
					int[] cost = new int[n];
					Arrays.fill(cost, 1 << 30);
					cost[s] = 0;

					while (!pq.isEmpty()) {
						Edge edge = pq.poll();
						if (edge.to == g) {
							ans = edge.cost;
							break;
						}
						if (cost[edge.to] < edge.cost)
							continue;
						for (Edge e : lists[edge.to]) {
							if (cost[e.to] < e.cost + edge.cost)
								continue;
							cost[e.to] = e.cost + edge.cost;
							pq.offer(new Edge(e.to, e.cost + edge.cost));
						}
					}
					System.out.println(ans);
				}
			}
		}
	}

	class Edge implements Comparable<Edge> {
		@Override
		public String toString() {
			return "Edge [to=" + to + ", cost=" + cost + "]";
		}

		public Edge(int to, int cost) {
			super();
			this.to = to;
			this.cost = cost;
		}

		int to, cost;

		@Override
		public int compareTo(Edge o) {
			return this.cost - o.cost;
		}

	}
}

Measured memory_bytes: 64220
using System;
using System.Collections.Generic;

namespace ABC063_B_Varied
{
	internal class Program
	{
		public static void Main(string[] args)
		{
			string s = Console.ReadLine();
			List<string> sArr = new List<string>(s.Length);
			bool sMatched = false;
			for (int i = 0; i < s.Length; i++)
			{
				sArr.Add(s.Substring(i, 1));
				//Console.Write(sArr[i]);
			}
			
			sArr.Sort();
			for (int index = 0; index < s.Length - 1; index++)
			{
				for (int j = index + 1; j < s.Length; j++)
				{
					if (sArr[index] == sArr[j])
						sMatched = true;
				}		
			}
			
			if(!sMatched) Console.WriteLine("yes");
			else Console.WriteLine("no");
		}
	}
}

Measured memory_bytes: 13408
#include <iostream>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;

int main(void) {
  int A, B;
  cin >> A >> B;
  string S;
  cin >> S;
  if (S[A] != '-') {
    cout << "No" << endl;
    return 0;
  }
  rep(i, A + B + 1) {
    if (i != A && !isdigit(S[i])) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,m,i=0,j=0,c=0,d=0;
    int a[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    cin>>n;
    cout<<a[n-1];

}


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

#define MAX_VALUE 50000

using namespace std;
int main(){
    int N, T, t, min = MAX_VALUE;
    cin >> N;
    int W[N], S1 = 0, S2 = 0;
    for(int i = 0; i < N; i++) cin >> W[i];
    for(T = 0; T < N; T++){
        for(t = 0; t < T; t++){
            S1 += W[t];
        }
        for(; t < N; t++){
            S2 += W[t];
        }
        if(abs(S1 - S2) <= min) min = abs(S1 - S2);
        S1 = S2 = 0;
        
        
    }
    cout << min << endl;
    return 0;
}

Measured memory_bytes: 256
#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;


#define ll long long int
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(a) a.begin(),a.end()

typedef tree <ll, null_type, less <ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// order_of_key(val): returns the number of values less than val
// find_by_order(k): returns an iterator to the kth largest element (0-based)
bitset<26> seg[20000007];
string s;
bitset<26> merge(bitset<26> a, bitset<26> b) {
	return a | b;
}
void build(ll pos, ll l, ll r) {
	if(l > r) {
		return;
	} else if(l == r) {
		seg[pos][s[l] - 'a'] = 1;
		return;
	}
	ll mid = (l + r)/2;
	build(2*pos + 1, l, mid);
	build(2*pos + 2, mid + 1, r);
	seg[pos] = merge(seg[2*pos + 1], seg[2*pos + 2]);
	return;
}
void update(ll pos, ll l, ll r, ll x, char c) {
	if(l > r) {
		return;
	} else if(r < x || x < l) {
		return;
	} else if(l == r) {
		seg[pos].reset();
		seg[pos][c - 'a'] = 1;
		return;
	}
	ll mid = (l + r)/2;
	update(2*pos + 1, l, mid, x, c);
	update(2*pos + 2, mid + 1, r, x, c);
	seg[pos] = merge(seg[2*pos + 1], seg[2*pos + 2]);
	return;
}
bitset<26> query(ll pos, ll l, ll r, ll l1, ll r1) {
	if(l > r) {
		bitset<26> temp;
		return temp;
	} else if(r1 < l || r < l1) {
		bitset<26> temp;
		return temp;
	} else if(l1 <= l && r <= r1) {
		return seg[pos];
	}
	ll mid = (l + r)/2;
	return merge(query(2*pos + 1, l, mid, l1, r1), query(2*pos + 2, mid + 1, r, l1, r1));
}
int main(void)
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n, q;
    cin>>n;
    cin>>s;
    build(0, 0, n-1);
    cin>>q;
    while(q--) {
    	ll t;
    	cin>>t;
    	if(t == 1) {
    		ll i;
    		char c;
    		cin>>i>>c;
    		i--;
    		update(0, 0, n-1, i, c);
    	}
    	else {
    		ll l, r;
    		cin>>l>>r;
    		l--, r--;
    		bitset<26> temp = query(0, 0, n-1, l, r);
    		cout<<temp.count()<<'\n';
    	}
    }
}

Measured memory_bytes: 11164
import sys

def height(id):
    if children[id]==[]:
        return 0
    if children[id][0]==-1 and children[id][1]==-1:
        return 0
    return max(height(children[id][0]),height(children[id][1]))+1

n = int(sys.stdin.readline())
parent = [-1 for _ in range(n)]
children = [[] for _ in range(n)]
nodes = []
for _ in range(n):
    id, left, right = list(map(int, sys.stdin.readline().split()))
    nodes.append(id)
    children[id] = [left, right]
    if left>=0:  parent[left] = id
    if right>=0: parent[right] = id

for n in sorted(nodes):
    h = height(n)
    p = parent[n]
    if p==-1:    type='root'
    else:
        if h==0: type='leaf'
        else:    type='internal node'
        
    depth = 0
    k=n
    while parent[k]>=0:
        k = parent[k]
        depth+=1

    ss=children[parent[n]]
    if ss[0]==-1 or ss[1]==-1:
        s=-1
    elif n==ss[0]:
        s=ss[1]
    else:
        s=ss[0]

    deg = 0
    if children[n][0]>=0: deg +=1
    if children[n][1]>=0: deg +=1
            
    print('node {0}: parent = {1}, sibling = {2}, degree = {3}, depth = {4}, height = {5}, {6}'.format(n, p, s, deg, depth, h, type))


Measured memory_bytes: 5620
#include <iostream>
#include<string>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<vector>
using namespace std;
int main(){
    int a,b;
    while(cin>>a){
        b=a%39;
        if(b==0){
            printf("3C39");
            cout<<endl;
        }else{
            printf("3C%02d",b);
            cout<<endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3124
#include <cstdio>
#include <algorithm>

int f(int n) {
    if (n%2 == 0) {
        return n/2;
    } else {
        return 3*n+1;
    }
}

int main() {
    int a[1000000], i;
    scanf("%d", &a[0]);
    for (i=1; i<1000000; i++) {
        a[i] = f(a[i-1]);
        auto result = std::find(a, a+i, a[i]);
        if (result != a+i) {
            printf("%d\n", i+1);
            return 0;
        }
    }
    return 1;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
	string s;
	cin >> s;
	int num[3];
	for(int i = 0; i < 3; i++) num[i] = 0;
	for(int i = 0; i < s.size(); i++){
		num[s[i] - 'a']++;
	}
	if(abs(num[0] - num[1]) <= 1 && abs(num[1] - num[2]) <= 1 && abs(num[2] - num[0]) <= 1){
		cout << "YES" << endl;
	}
	else cout << "NO" << endl;
	return 0;
}

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

template<long long mod>
class modint{
private:
  long long a;
public:
  constexpr modint(const long long x = 0) noexcept : a(x%mod) {}
  constexpr long long& value() noexcept { return a; }
  constexpr const long long& value() const noexcept { return a; }
  constexpr modint operator+(const modint rhs) const noexcept {
    return modint(*this) += rhs;
  }
  constexpr modint operator-(const modint rhs) const noexcept {
    return modint(*this) -= rhs;
  }
  constexpr modint operator*(const modint rhs) const noexcept {
    return modint(*this) *= rhs;
  }
  constexpr modint operator/(const modint rhs) const noexcept {
    return modint(*this) /= rhs;
  }
  constexpr modint& operator+=(const modint rhs) noexcept {
    a += rhs.a;
    if(a >= mod) a -= mod;
    return *this;
  }
  constexpr modint &operator-=(const modint rhs) noexcept {
    if(a < rhs.a) a += mod;
    a -= rhs.a;
    return *this;
  }
  constexpr modint& operator*=(const modint rhs) noexcept {
    a = a*rhs.a%mod;
    return *this;
  }
  constexpr modint& operator/=(modint rhs) noexcept {
    long long k = mod-2;
    while(k > 0){
      if(k&1){
        *this *= rhs;
      }
      rhs *= rhs;
      k /= 2;
    }
    return *this;
  }
  friend ostream& operator<<(ostream &os, const modint &X){
    return os << X.a;
  }
  friend istream& operator>>(istream &is, modint &X){
    is >> X.a;
    X.a %= mod;
    if(X.a < 0) X.a += mod;
    return is;
  }
};

using mint = modint<(int)1e9+7>;

mint dfs(const vector<vector<int>> &G, const int v, const int prev, int K, int d){
  d = min(d,2);
  int t = K-d;
  mint ret(t);
  int d_ = min(d+1,2);
  int s = 0;
  for(auto v_: G[v]){
    if(v_ == prev) continue;
    ret *= dfs(G,v_,v,K,d_)/(K-d_)*(K-d_-s);
    ++s;
  }
  return ret;
}

int main(){
  int N, K;
  cin >> N >> K;
  vector<vector<int>> G(N);
  for(int i = 1; i < N; ++i){
    int u, v;
    cin >> u >> v;
    --u,--v;
    G[u].push_back(v);
    G[v].push_back(u);
  }
  mint ans = dfs(G,0,-1,K,0);
  cout << ans << endl;
}


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

int main() {
	int n;
	cin >> n;
	int a[220];
	for (int i = 0; i < n; ++i) cin >> a[i];
	int count = -1;
	bool flag = true;
	while (flag) {
		for (int i = 0; i < n; ++i) {
			if (a[i] % 2 != 0) {
				flag = false;
			}
			a[i] /= 2;
		}
		++count;
	}

	cout << count << endl;
}

Measured memory_bytes: 3192
import itertools 
n=int(input())
a=[]
for i in range(n):
    a.append(str(input()))
march=[0]*5

for i in range(n):
    if a[i][0:1]=='M':
        march[0]+=1
    if a[i][0:1]=='A':
        march[1]+=1
    if a[i][0:1]=='R':
        march[2]+=1
    if a[i][0:1]=='C':
        march[3]+=1
    if a[i][0:1]=='H':
        march[4]+=1
#三人を選ぶほうほうのそれぞれのかずを懸けあわっせる
#print(march)

kumi_list=list(itertools.combinations([0,1,2,3,4],3))
#print(kumi_list)
ans=0
for i in kumi_list:
    b,c,d= i
    #print(b,c,d) 
    ans+=march[b]*march[c]*march[d]
print(ans)

Measured memory_bytes: 56920
n=int(input())
l=list(map(int,input().split()))

c_4=0
even=0
odd=0

for i in l:
  if i%4==0:
    c_4+=1
  elif i%2==0:
    even+=1
  else:
    odd+=1
  
if even==0 and odd-1 <= c_4:
  ans="Yes"
else:
  ans="No"
  
if even>0 and odd <= c_4:
  ans="Yes"
elif even>0:
  ans="No"

print(ans)


Measured memory_bytes: 20028
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define rep2(i, l, r) for (ll i = (l); i < (r); i++)
#define ALL(x) (x).begin(), (x).end()     //昇順
#define RALL(x) (x).rbegin(), (x).rend()  // 降順
#define pri(x) cout << (x) << "\n"
#define pri2(x, y) cout << (x) << " " << (y) << "\n"
#define pri3(x, y, z) cout << (x) << " " << (y) << " " << (z) << "\n"
const long long mod = 1e9 + 7;
typedef long long ll;
typedef priority_queue<int> PQ;
typedef vector<long long> VL; // VL a(n);
typedef vector<bool> VB;
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<char> VC;
typedef vector<VS> VSS;
typedef vector<VC> VCC;
typedef vector<VL> VLL; // VII a(n,VI(m)) n * m
typedef pair<ll, ll> PL;
typedef map<ll, ll> MP; // MP a;
typedef vector<pair<ll, ll>> PS; // PS a(n);

template <class T, class U>
bool chmax(T &a, U b) {
  if (a <= b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T, class U>
bool chmin(T &a, U b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) { os << v[i] << (i < v.size() - 1 ? ", " : ""); }
  os << "}";
  return os;
}

// g++ -std=c++11 prac.cpp
// operator << (cout,a);
// chmin(min,a)
ll sum(ll n){return n*(n+1)/2;} 

int main() {
  ll n,k,m,x=0,y=0,z=0,cnt=0,h=0,w=0,ans=0,Max=-1, Min=3e9+1;
  string s,t;
  cin >> n;
  for(int i=1; i<=n; i++){ // n=8のとき
    ans += sum(n/i)*i;    // 2+4+6+8 → 2(1+2+3+4)
  }                       // sum(8/3),つまりsum(2) → 3(1+2)
  pri(ans);
  return 0;
}

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

int main() {
  int A, B;
  scanf("%d%d", &A, &B);
  if (A + B == 15)
    	puts("+");
  else if (A * B == 15)
    	puts("*");
  else 
    	puts("x");
  return 0;
} 

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

class dsu{
    vector<int>par;
public:
    dsu(int n){
        par.resize(n);
        iota(par.begin(), par.end(), 0);
    }

    int find(int u){
        if(u==par[u])return u;
        return par[u]=find(par[u]);
    }

    void join(int a, int b){
        a=find(a);
        b=find(b);
        if(a!=b)par[b]=a;
    }
};

const int nax=1000123;
vector<vector<int>>v;
void pre(){
    v=vector<vector<int>>(nax);
    for(int i=2;i<nax;i++){
        if(v[i].empty()){
            for(int j=i;j<nax;j+=i){
                v[j].push_back(i);
            }
        }
    }
}

signed main(){
    pre();
    int n;
    cin>>n;
    vector<int>a(n);
    for(auto &i:a)cin>>i;
    int g=0;
    for(auto i:a)g=__gcd(g, i);
    if(g!=1)cout<<"not coprime"<<endl;
    else {
        unordered_map<int, int>u;
        for(int i:a)for(auto j:v[i])u[j]++;
        bool ok=true;
        for(auto i:u)if(i.second>1)ok=false;
        if(ok)cout<<"pairwise coprime\n";
        else cout<<"setwise coprime\n";
    }
}

Measured memory_bytes: 82404
import java.util.*;

class Main{
    public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int[] array;
    	array = new int[3];
		array[0] = sc.nextInt();
		array[1] = sc.nextInt();
		array[2] = sc.nextInt();
    	Arrays.sort(array);
    	for(int i = 0; i < array.length; i++){
    		if(i == array.length -1 ) System.out.printf("%d",array[i]);
    		else System.out.printf("%d ",array[i]);
    	}
    	System.out.printf("\n");
    }
}


Measured memory_bytes: 26504
# -*- coding: utf-8 -*-
import itertools
import numpy as np
x = int(input())
# hani = int(pow(x, 1/5))
# for a in range(-hani-1, hani+1):
#     for b in range(-hani-1, hani+1):
#         if (pow(a, 5) - pow(b, 5) == x):
#             print(a, b)
#             exit()
max_x = pow(10, 18)
v = 0
v_lis = [0]
i = 1
while max_x > v:
    v = pow(i, 5)
    v_lis.append(v)
    v_lis.append(-v)
    i += 1

for a5, b5 in itertools.combinations_with_replacement(v_lis, 2):
    if (a5 - b5 == x):
        if (a5 < 0):
            a = int(pow(a5*-1, 1 / 5)) * -1
        else:
            a = int(pow(a5, 1 / 5))
        if (b5 < 0):
            b = int(pow(b5*-1, 1/5))*-1
        else:
            b = int(pow(b5, 1/5))
        print(a, b)
        exit()


def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])

    if temp != 1:
        arr.append([temp, 1])

    if arr == []:
        arr.append([n, 1])

    return arr


# arr = factorization(x)
# fact = []
# for prime, idx in arr:
#     fact.extend([prime]*idx)

# print(fact)


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

// エイリアス
using  ll = long signed long;
using ull = long unsigned long;
using  ld = long double;
using   P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;

// 汎用マクロ
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOREACH(i,q) for (auto &i : q)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
#define SZ(x) ((int)(x).size())
template <class T>inline bool chmin(T &a, const T b) {if (a > b) { a = b; return true;} return false;}
template <class T>inline bool chmax(T &a, const T b) {if (a < b) { a = b; return true;} return false;}
template <class T>inline void line_out(const vector<T> vec) {int n = SZ(vec); rep(i, n) { cout << vec[i]; if(i < n-1) cout << " ";}cout << endl;}
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 55;
const int mod = 1000000007;
//const int mod = 998244353;
struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};

int main()
{
  int q; cin >> q;
  vector<int> l(q), r(q);
  rep(i, q) cin >> l[i] >> r[i];
  vector<bool> prime(100010, true);
  prime[0] = prime[1] = false;
  for(ll i = 2; i <= 100000; ++i) {
    if(!prime[i]) continue;
    for(ll j = i*i; j <= 100000; j += i) prime[j] = false;
  }

  vector<int> vec(100010, 0);
  for(int i = 1; i <= 100000; ++i) {
    if(i%2==0) continue;

    if(prime[i] && prime[(i+1)/2]) ++vec[i];
  }
  rep(i, 100000) vec[i+1] += vec[i];
  rep(i, q) cout << vec[r[i]] - vec[l[i]-1] << endl;
}


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

using namespace std;
using ll = long long;

int main(void) {
  int n, k;
  cin >> n >> k;
  vector<int> vec(n);
  for (int i = 0; i< n; i++) {
    cin >> vec[i];
  }
  sort(vec.begin(), vec.end());
  int m = abs(vec[k - 1] - vec[0]);
  for (int i = 1; i <= n - k; i++) {
    m = min(m, abs(vec[i + k - 1] - vec[i]));
  }
  cout << m << endl;
  return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <cstdio>
#include <algorithm>
#include <utility>
#include <string>
#include <cmath>
#include <set>
#include <functional>
#include <map>
#include <queue>
#include <cstring>
#include <stack>
#include <iomanip>
#include <climits>
#include <numeric>
#include <cassert>
#include <unordered_map>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define show(x) cout << #x << " = " << x << endl;
typedef long long ll;
typedef pair<int,int> pii;
int a[100002];
int main(){
    int n;
    cin >> n;
    int b;
    rep(i,n){
        cin >> b;
        a[b]++;
    }
    int temp = -1;
    int hoge = -1;
    for(int i = 0; i <= 100000; i++){
        if(i==0){
            temp = a[0]+a[1];
        }else temp = a[i-1]+a[i]+a[i+1];
        if(hoge<temp){
            hoge = temp;
        }
    }
    cout << hoge<< endl;
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define db(x) cout << (x) << '\n';
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pii;
typedef pair<double,ll> pdi;
typedef pair<string,ll> psi;
typedef pair<ll,string> pls;
typedef pair<string,string> pss;
typedef pair<ll,pii> pip;
typedef pair<pii,pii> ppp;

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

    int k;
    cin >> k;
    int n,m;
    cin >> n >> m;
    if((n-1)/k!=m/k)
        db("OK")
    else
        db("NG")

    return 0;
}


Measured memory_bytes: 3636
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
using namespace std;
#define int long long


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

    int a,b,c; cin >> a >> b >>c;

    int ans = 0;

    if(a == b && b == c && a % 2 == 0){
        cout << -1 << endl;
        return 0;
    }

    while(a%2==0 && b%2==0 && c%2==0){
        int d = a;
        int e = b;
        int f = c;

        a = (e+f)/2;
        b = (d+f)/2;
        c = (d+e)/2;

        ans ++;

    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  for(int i = 0; i < 3; i++){
    for(int j = 0; j < 3; j++){
      char c;
      cin >> c;
      if(i == j)
        cout << c;
    }
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

/**
 * キュー
 * @author nobu
 * @see <a href="http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_3_B&lang=ja">ALDS1_3_B</a>
 */
public class Main {

	private static final int LEN = 100005;
	private static int head, tail;
	private static P Q[] = new P[LEN];

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

		for (int i = 0; i < LEN; i++) {
			Q[i] = new P();
		}

		for (int i = 1; i <= n; i++) {
			Q[i].name = sc.next();
			Q[i].t = sc.nextInt();
		}

		head = 1;
		tail = n + 1;

		P u;
		int elapse = 0;
		while (head != tail) {
			u = dequeue();
			int c = Math.min(q, u.t);
			u.t -= c;
			elapse += c;
			if (0 < u.t) {
				enqueue(u);
			} else {
				System.out.println(u.name + " " + elapse);
			}
		}

		sc.close();
	}

	private static void enqueue(P x) {
		Q[tail] = x;
		tail = (tail + 1) % LEN;
	}

	private static P dequeue() {
		P x = Q[head];
		head = (head + 1) % LEN;
		return x;
	}

}

class P {
	String name;;
	int t;
}


Measured memory_bytes: 81988
($N,$M)=glob<>;
($a[$_],$b[$_])=glob<>for 0..$M-1;
$c[$_]=++$i[$a[$_]] for sort{$b[$a]-$b[$b]}0..$M-1;
printf"%06d%06d\n",$a[$_],$c[$_]for 0..$M-1

Measured memory_bytes: 33396
from collections import defaultdict
n = int(input())
tuples = []
for i in range(n):
    a,b,c = map(int,input().split())
    tuples.append((a,b,c))
dp = [defaultdict(int) for _ in range(n+1)]
dp[0][3] = 0
for i in range(n):
    abc = tuples[i]
    for j in range(3):
        for k in dp[i].keys():
            if k != j:
                dp[i+1][j] = max(dp[i][k]+abc[j],dp[i+1][j])
print(max(dp[n].values()))


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

int main() {
 
  int n;
  cin >> n;
  long total = 0;
  
  for (int i = 1; i <= n; i++){
    if(i % 5 != 0 && i % 3 != 0){
      total = total + i;
    }
  }
  
  cout << total << endl;
  
  
 

}

Measured memory_bytes: 3632
using System;
using System.Linq;
using System.Collections.Generic;

public static class Program {
    static int mod=1000000007;
    public static void Main() {
        int n=int.Parse(Console.ReadLine());
        bool[,]a=new bool[n,n];
        for(int i=0;i<n;i++){
            int j=0;
            foreach(int x in Console.ReadLine().Split().Select(int.Parse)) {
                a[i,j++]=x==1;
            }
        }

        int N=1<<n;
        List<int>[]Bs=Enumerable.Range(0,n+1).Select(_=>new List<int>()).ToArray();
        for(int bs=0;bs<N;bs++){
            int pc=0;
            for(int i=0;i<n;i++){
                pc+=(bs>>i)&1;
            }
            Bs[pc].Add(bs);
        }

        int[]dp=new int[N];
        dp[0]=1;
        for(int i=0;i<n;i++){
            foreach(int bs in Bs[i]){
                for(int j=0;j<n;j++){
                    if(a[i,j]&&(bs>>j&1)==0){
                        Add(ref dp[bs|1<<j],dp[bs]);
                    }
                }
            }
        }
        Console.WriteLine(dp[N-1]);
    }
    public static void Add(ref int x, int y){
        x+=y;
        if(mod<=x)x-=mod;
    }
}


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

int main() {
  int N , A , B , sum;
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> A >> B;
    A =B - A + 1;
    sum += A;
  }

  cout << sum << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;

int main(){
  int n;
  cin >> n;
  vi a(n+1), ans(n+1);
  rep(i,n) cin >> a[i+1];
  for(int i = n; i > 0; i--){
    int cnt = 0;
    for(int j = i; j <= n; j+=i){
      if(ans[j] == 1) cnt++;
    }
    if((cnt + a[i])%2 == 0) continue;
    else ans[i]++;
  }
  int m = 0;
  rep(i,n){
    if(ans[i+1] == 1) m++;
  }
  cout << m << endl;
  rep(i,n){
    if(ans[i+1] == 1) cout << i+1 << " ";
  }
}


Measured memory_bytes: 4792
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <numeric>
#include <sstream>
#include <set>
#include <map>

using namespace std;
using ll = long long;

int main() {
	ll argN, argK;
	cin >> argN >> argK;

	map<int, int> mapN;
	for (ll i = 0; i < argN; ++i) {
		ll tmp;
		cin >> tmp;

		if (mapN.find(tmp) != mapN.end()) {
			mapN.at(tmp)++;
		}
		else {
			mapN.emplace(tmp, 1);
		}
	}

	vector<int> vecN;
	for (auto itr = mapN.begin(); itr != mapN.end(); ++itr) {
		vecN.push_back(itr->second);
	}

	if (vecN.size() <= argK) {
		cout << 0 << endl;
		return 0;
	}

	sort(vecN.begin(), vecN.end());
	ll ret = 0;
	for (ll i = 0; i < vecN.size() - argK; ++i) {
		ret += vecN.at(i);
	}

	cout << ret << endl;
}

Measured memory_bytes: 10744
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
using namespace std;

string int2str(int i)
{
	string out;
	stringstream ss;

	ss << i;
	ss >> out;

	return out;
}

int main()
{
	int n;
	string in;
	int i, j, k=0, len=0, mul=0;
	string out = string();
	vector<string> outs;

	while(1)
	{
		cin >> n;
		if( n == 0 )
			break;
		cin >> in;

		for( i = 0 ; i < n ; i++)
		{
			len = in.length();
			for( j = 0 ; j < len ; j++)
			{
		
				for(k = j ;; k++)
				{
					if(in[k] == in[j])
					 mul++;
					else
					 break;
				}
/*
				cout << mul << endl;
				cout << in[j] << endl;
*/
				out += int2str(mul) + in[j];
				j = k-1;
				mul = 0;
			}
			in = out;
			out = string();
		}

		outs.push_back(in);
		in = string();
	}

	n = outs.size();

	for( i = 0 ; i < n ; i++)
		cout << outs.at(i) << endl;


	return 0;
}

Measured memory_bytes: 1032
import java.util.Arrays;
import java.util.Objects;
import java.util.Scanner;

public class Main {
    public static class Can implements Comparable<Can> {
        long a;
        long b;
        public Can() {
            this.a = 0;
            this.b = 0;
        }
        public Can(long a, long b) {
            this.a = a;
            this.b = b;
        }

        @Override
        public boolean equals(Object o) {
            if (this == o) return true;
            if (o == null || getClass() != o.getClass()) return false;
            Can can = (Can) o;
            return a == can.a &&
                    b == can.b;
        }

        @Override
        public int hashCode() {
            return Objects.hash(a, b);
        }

        @Override
        public int compareTo(Can o) {
            if (this.a < o.a) {
                return -1;
            } else if (this.a > o.a) {
                return 1;
            } else {
                return 0;
            }
        }
    }
    public static void main(String [] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int m = scanner.nextInt();
        Can[] cans = new Can[n];
        for (int i = 0; i < n; ++i) {
            long a = scanner.nextLong();
            long b = scanner.nextLong();
            cans[i] = new Can(a, b);
        }
        Arrays.sort(cans);
        int buy = 0;
        long money = 0;
        int i = 0;
        while (buy < m) {
            int currentBuy = (int)Math.min(m - buy, cans[i].b);
            money += currentBuy * cans[i].a;
            buy += currentBuy;
            ++i;
        }
        System.out.println(money);

    }

}


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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef pair<ll, ll> P;

#define rep(a,n) for(int a = 0;a < n;a++)

struct UnionFind {
public:
	vector <ll> par; // 
	vector <ll> siz; // 

	UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) {
		for (ll i = 0; i < sz_; ++i) par[i] = i;
	}
	void init(ll sz_) {
		par.resize(sz_);
		siz.assign(sz_, 1LL);
		for (ll i = 0; i < sz_; ++i) par[i] = i;
	}

	ll root(ll x) {
		while (par[x] != x) {
			x = par[x] = par[par[x]];
		}
		return x;
	}

	bool merge(ll x, ll y) {
		x = root(x);
		y = root(y);
		if (x == y) return false;
		if (siz[x] < siz[y]) swap(x, y);
		siz[x] += siz[y];
		par[y] = x;
		return true;
	}

	bool issame(ll x, ll y) {
		return root(x) == root(y);
	}

	ll size(ll x) {
		return siz[root(x)];
	}
};

int main(void)
{
	ll n,m;
	cin >> n >> m;
	UnionFind uf(n);
	rep(i, m) {
		ll x, y, z;
		cin >> x >> y >> z;
		x--;
		y--;
		uf.merge(x, y);
	}
	unordered_set<ll> s;
	rep(i, n) {
		s.insert(uf.root(i));
	}
	cout << s.size() << endl;
	return 0;
}

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

#define endl '\n'
#define lfs cout<<fixed<<setprecision(10)
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define fi first
#define se second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define EB emplace_back
#define rep(i,n,m) for(ll i = (n); i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = (m) - 1; i >= (ll)(n); i--)
using ll = long long;
using ld = long double;
const ll MOD1 = 1e9+7;
const ll MOD9 = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T>
bool chmin(T &a,T b){if(a>b){a=b;return true;}else return false;}
template<typename T>
bool chmax(T &a,T b){if(a<b){a=b;return true;}else return false;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>
void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
template<typename T>
void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>&v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>
void debug(vector<T>&v,ll n){if(n!=0)cout<<v[0];
for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>
vector<vector<T>>vec(ll x, ll y, T w){
  vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
vector<ll>dx={1,0,-1,0,1,1,-1,-1};
vector<ll>dy={0,1,0,-1,1,-1,1,-1};
template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2>&p){
  return os << p.first << " " << p.second;
}  
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  ll res=0,buf=0;
  bool judge = true;
  ll n;cin>>n;
  if(n==1){
    cout<<1<<endl;
    cout<<0<<endl;
  }
  else if(n==2){
    cout<<2<<endl;
    cout<<0<<endl;
    cout<<11<<endl;
  }
  else{
    cout<<n-1<<endl;
    rep(i,0,n-1){
      cout<<"0"+string(i,'1')+"0"<<endl;
    }
  }
  return 0;
}


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

#define rep(i, a, b) for (int i = (a), i##end = (b); i <= i##end; ++i)
#define per(i, a, b) for (int i = (a), i##end = (b); i >= i##end; --i)

mt19937 Rnd(chrono::high_resolution_clock::now().time_since_epoch().count());

template <typename T>
inline void chkmax(T &x, T y) { if (x < y) x = y; }

template <typename T>
inline void chkmin(T &x, T y) { if (x > y) x = y; }

inline int read() {
  #define nc getchar()
  int x = 0;
  char c = nc;
  while (c < 48) c = nc;
  while (c > 47) x = x * 10 + (c ^ 48), c = nc;
  return x;
  #undef nc
}

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

const int maxn = 1010, P = 1e9 + 7;

int Inc(int x, int y) {
  return x + y < P ? x + y : x + y - P;
}

int Dec(int x, int y) {
  return x < y ? x - y + P : x - y;
}

void Add(int &x, int y) {
  x += y;
  if (x >= P) x -= P;
}

void Sub(int &x, int y) {
  x -= y;
  if (x < 0) x += P;
}

int qp(int a, int k) {
  int res = 1;
  for (; k; k >>= 1, a = 1ll * a * a % P) {
    if (k & 1) res = 1ll * res * a % P;
  }
  return res;
}

void solve() {
  int n;
  cin >> n;
  int ans = (ll) (qp(10, n) - qp(9, n) * 2 % P + P + qp(8, n)) % P;
  cout << ans << endl;
}

signed main() {
//  int T = read();
//  while (T--) solve();
  solve();
  return 0;
}

Measured memory_bytes: 3620
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
#include <iomanip>
#include <map>
#include <cstdlib>
using namespace std;
int main()
{
    char x, y;
    cin >> x >> y;
    if (x == y)
    {
        cout << "=" << endl;
    }
    else if (x > y)
    {
        cout << ">" << endl;
    }
    else
    {
        cout << "<" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
/*#include <iostream>
using namespace std;
int n,m,r,l,x[100005]={0},ans=0;
int main()
{
	cin>>n>>m;
	for(int i=1;i<=m;++i)
	{
		cin>>l>>r;
		for(int j=l;j<=r;++j)
		{
			x[j]++;
		}
	}
	for(int i=1;i<=n;++i)
	{
		if(x[i]==m)	ans++;
	}
	cout<<ans;
	return 0;
} 
*/

#include<bits/stdc++.h>
#define inf 2147483647
using namespace std;

int n,m,a,b,l=0,r=inf;
int main()
{
	cin>>n>>m;
	for(int i=1;i<=m;++i)
	{
		cin>>a>>b;
		l=max(l,a);
		r=min(r,b);
	}
	if(r>=l)
		cout<<r-l+1;
	else
		cout<<0;
	return 0;
} 


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

int main(){
  int N,K;
  string S;
  cin >> N >> S >> K;
  for(int i=0;i<N;i++){
    if(S[i]!=S[K-1]) S[i]='*'; 
  }
  cout << S << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define roop0(n) for(long long i = 0;i < n;i++)
#define roop1(n) for(long long i = 1;i < n;i++)
#define rep(i,a,b) for(long long i = a; i < b; i++)
#define print(a) for(auto x : a) cout << x << " "; cout << "\n"

using namespace std;
using vi   = vector<int>;
using vll  = vector<long long>;
using vs   = vector<string>;
using vvi  = vector<vector<int>>;
using vvll = vector<vector<long long>>;
using vvs  = vector<vector<string>>;

const static string el = "\n";
long long result = 0;

int main () {
  long int n,k; cin >> n >> k;
  vll A = vll(n);
  roop0(n) {
    long long tmp; cin >> tmp; 
    A[i] = tmp;
  }

  long long index = 0;
  long long tmp; // K学期との比較用
  for (long long i = k;i < n;i++) {
    tmp = A[index]; 
    if (tmp < A[i]) cout << "Yes" << endl;
    else cout << "No" << endl;
    index++;
    tmp = A[index];
  }
  return 0;
}

Measured memory_bytes: 4840
#include <bits/stdc++.h>
#define f first
#define s second
using namespace std;
using ll = long long;
using ii = pair<int, int>;

int sz[100001];
vector<int> G[100001];

bool dfs(int u, int p) {
    sz[u] = 1;
    int cnt = 0;
    for (int v : G[u]) if (v != p) {
        if (dfs(v, u)) return true;
        cnt += sz[v], sz[u] ^= sz[v];
    }
    return cnt > 1;
}

int main() {
    if (fopen("in", "r")) freopen("in", "r", stdin), freopen("out", "w", stdout);
    ios_base::sync_with_stdio(0), cin.tie(0);

	int N; cin >> N;
    for (int i = 1; i < N; ++i) {
        int a, b; cin >> a >> b;
        G[a].push_back(b), G[b].push_back(a);
    }
    cout << ((N & 1) || dfs(1, 0) ? "First" : "Second");
}

Measured memory_bytes: 9560
package main

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

var sc = bufio.NewScanner(os.Stdin)

func Scan() string {
	sc.Scan()
	return sc.Text()
}
func iScan() int {
	n, _ := strconv.Atoi(Scan())
	return n
}
func fScan() float64 {
	n, _ := strconv.ParseFloat(Scan(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func SScan(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scan()
	}
	return a
}
func iSScan(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = iScan()
	}
	return a
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func sum(a []int) int {
	x := 0
	for _, v := range a {
		x += v
	}
	return x
}

var mod int = 1000000007

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	n, q := iScan(), iScan()
	s := Scan()
	x := make([]int, n)
	y := make([]int, n)
	for i := 0; i < n-1; i++ {
		if s[i:i+2] == "AC" {
			x[i]++
			y[i]++
		}
	}
	for i := 1; i < n; i++ {
		x[i] += x[i-1]
	}
	for i := 0; i < q; i++ {
		l, r := iScan()-1, iScan()-1
		ans := x[r]
		if l != 0 {
			ans -= x[l-1]
		}
		if y[r] == 1 {
			ans--
		}
		fmt.Println(ans)
	}
}


Measured memory_bytes: 6192
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cstdlib>
#include<queue>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define P pair<int, int>

int h, w;
string s[20];
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};

int maze(int a, int b){
    int dis[h][w];
    rep(i, h)rep(j, w) dis[i][j] = -1;
    dis[a][b] = 0;
    queue<P> que;
    que.push(P(a, b));
    int res = 0;
    while(!que.empty()){
        P p = que.front();
        int x = p.first, y = p.second;
        int d = dis[x][y];
        que.pop();
        rep(i, 4){
            int nx = x + dx[i], ny = y + dy[i];
            if (0 <= nx && nx < h && 0 <= ny && ny < w && s[nx][ny] == '.' && dis[nx][ny] == -1){
                que.push(P(nx, ny));
                dis[nx][ny] = d + 1;
                res = max(res, d + 1);
            }
        }
    }
    return res;
}


int main(){
    cin >> h >> w;
    rep(i, h) cin >> s[i];
    int ans = 0;
    rep(i, h)rep(j, w){
        if (s[i][j] == '.'){
            ans = max(ans, maze(i, j));
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
// https://beta.atcoder.jp/contests/abc115

#define SUBMIT

#include <bits/stdc++.h>
using namespace std;

int main() {
#ifdef SUBMIT
    auto& in = cin;
#else
    stringstream in(R"(3
100000
30000
20000
)");
#endif
    int n;
    in >> n;
    vector<int> a(n);
    for (int i = 0; i < n; ++i) in >> a[i];

    auto all_even = true;
    for (int j = 0; j < n; ++j) {
        if (a[j] % 2 == 1) {
            all_even = false;
        }
    }

    cout << (all_even ? "second" : "first") << endl;
    return 0;
}

Measured memory_bytes: 640
import java.util.Scanner;
 
public class Main {
    private static int partition(int[] a, int p, int r) {
        int x = a[r];
        int i = p - 1;
        for(int j = p; j < r; j++) {
            if(a[j] <= x) {
                i++;
                int tmp = a[i];
                a[i] = a[j];
                a[j] = tmp;
            }
        }
        int tmp = a[i + 1];
        a[i + 1] = a[r];
        a[r] = tmp;
        return i + 1;
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
 
        int n = sc.nextInt();
        int[] a = new int[n];
        for(int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }

        int q = partition(a, 0, n - 1);

        StringBuilder sb = new StringBuilder();
        for(int i = 0; i < n; i++) {
            if(i != 0) sb.append(" ");
            if(i == q) sb.append("[").append(a[i]).append("]");
            else sb.append(a[i]);
        }
        System.out.println(sb);

        sc.close();
    }
}



Measured memory_bytes: 68312
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/adaptor/indexed.hpp>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)
#define ALL(x) begin(x),end(x)

using namespace std;
using namespace boost::adaptors;
using namespace std::string_literals;
using ll = int64_t;
using vecint = vector<int>;
using vecll = vector<ll>;
using boost::irange;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n,m;
  cin>>n>>m;
  int a=1, b=n, c=1 + (n+1) / 2, d = c-2;
  REP(i,m) {
    if (i%2 == 0) {
      cout<<a<<" "<<b<<"\n";
      ++a;--b;
    } else {
      cout<<c<<" "<<d<<"\n";
      ++c;--d;
    }
  }
  return 0;
}


Measured memory_bytes: 3608
#!/usr/bin/perl
use POSIX qw(floor);

my ($n) = map { $_ - 0 } split(/\s+/,<STDIN>);

my $r = 'No';
my $c = 0;
for(my $i=0;$i<$n;$i++){
  my ($d1,$d2) = map { $_ - 0 } split(/\s+/,<STDIN>);
  if( $d1 == $d2 ){
    $c++ ; 
  } else {
    $c = 0;
  }
  if( $c == 3 ){
    $r = 'Yes';
  }
}

print "$r\n";


Measured memory_bytes: 6632
#include <algorithm>
#include <stdio.h>
using namespace std;
using ll = long long;

int n, m, s[2010], t[2010];
ll dp[2010][2010];
const ll mod = 1e9 + 7;
int main() {
	scanf("%d %d", &n, &m);
	for (int i = 1; i <= n; i++)
		scanf("%d", s + i);
	for (int i = 1; i <= m; i++)
		scanf("%d", t + i);

	dp[0][0] = 1;
	for (int i = 1; i <= n; i++)
		dp[i][0] = 1;
	for (int i = 1; i <= m; i++)
		dp[0][i] = 1;
	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= m; j++) {
			dp[i][j] = (dp[i - 1][j] + dp[i][j - 1] - dp[i - 1][j - 1] + (s[i] == t[j] ? dp[i - 1][j - 1] : 0)) % mod;
			if (dp[i][j] < 0)
				dp[i][j] += mod;
		}
	printf("%lld\n", dp[n][m]);
}

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

#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;

int main() {
    int n; cin >> n;
    deque<int> d;
    for(int i = 0; i < n; i++){
        int a; cin >> a;
        if(i % 2 == 0) d.push_front(a);
        else d.push_back(a);
    }
    if(n % 2 == 0) reverse(all(d));
    for(int i = 0; i < n; i++){
        if(i == n - 1) cout << d.front() << endl;
        else cout << d.front() << " ";
        d.pop_front();
    }
}


Measured memory_bytes: 2944
from copy import deepcopy
from sys import exit,setrecursionlimit
import math
from collections import defaultdict,Counter,deque
from fractions import Fraction as frac

setrecursionlimit(1000000)


def main():
	n = int(input())
	v = list(map(int,input().split()))
	v.sort(reverse = True)
	for i in range(n-1):
		a = v.pop()
		b = v.pop()
		v.append((a+b)/2)
	print(v[0])

def zip(a):
	mae = a[0]
	ziparray = [mae]
	for i in range(1,len(a)):
		if(mae != a[i]):
			ziparray.append(a[i])
			mae = a[i]
	return ziparray

def is_prime(n):
	if n < 2: return False

	for k in range(2, int(math.sqrt(n)) + 1):
		if n % k == 0:
			return False

	return True

def list_replace(n,f,t):
	return [t if i==f else i for i in n]

def base_10_to_n(X, n):
	X_dumy = X
	out = ''
	while X_dumy>0:
		out = str(X_dumy%n)+out
		X_dumy = int(X_dumy/n)
	if(out == ''): return '0'
	return out

def gcd(l):
	x = l.pop()
	y = l.pop()
	while(x%y!=0):
		z = x%y
		x = y
		y = z
	l.append(min(x,y))
	return gcd(l) if len(l) > 1 else l[0]

class Queue():
	def __init__(self):
		self.q = deque([])
	def push(self,i):
		self.q.append(i)
	def pop(self):
		return self.q.popleft()
	def size(self):
		return len(self.q)
	def debug(self):
		return self.q

class Stack():
	def __init__(self):
		self.q = []
	def push(self,i):
		self.q.append(i)
	def pop(self):
		return self.q.pop()
	def size(self):
		return len(self.q)
	def debug(self):
		return self.q

class graph():
	def __init__(self):
		self.graph = defaultdict(list)
	def addnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].append(t)
		self.graph[t].append(f)
	def rmnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].remove(t)
		self.graph[t].remove(f)
	def linked(self,f):
		return self.graph[f]

class dgraph():
	def __init__(self):
		self.graph = defaultdict(set)
	def addnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].append(t)
	def rmnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].remove(t)
	def linked(self,f):
		return self.graph[f]

main()


Measured memory_bytes: 5196
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REV(c) reverse(ALL(c))
#define sz(v) (int)v.size()
#define endl '\n'
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
template<class T> inline void printv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << (i == n - 1 ? endl : ' ');}
template<class T> inline void printvv(vector<vector<T>>& v) {for (auto u : v) printv(u);}
template<class T> inline void printlnv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << endl;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
 
void solve();
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

template<typename T>
T calc_mod(string s, T d) {
    T r = 0;
    int n = sz(s);
    REP(i, n) r = (r * 10 + (s[i] - '0')) % d;
    return r;
}

void solve() {
    ll a, b;
    cin >> a >> b;
    a--;

    auto f = [](ll n) {
        if (n % 4 == 0) return n;
        else if (n % 4 == 1) return 1LL;
        else if (n % 4 == 2) return n + 1;
        else if (n % 4 == 3) return 0LL;
    };

    ll x = f(b);
    ll y = f(a);
    if (a == -1) cout << x << endl;
    else cout << (x ^ y) << endl;
}


Measured memory_bytes: 256