akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include<vector>
#include<iomanip>
#include<map>
#include <queue>
#include<cmath>
#include<cstdio>
#include<iomanip>
#include<set>
#include <bits/stdc++.h>
 
using namespace std;
using ll = long long int;
 
#define REP(i,n) for(ll i=0;i<(ll)(n);i++) //REP(i, 5) cout<<i;
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define MOD 1000000007 //10^9+7
//#define MOD 1
 
ll gcd(ll a, ll b) {
  ll tmp;
  if ( b > a) {
    tmp = a;
    a = b;
    b = tmp;
  }
  while (a % b !=0) {
    tmp = b;
    b = a % b;
    a = tmp;
  }
  return b;
}
 
const int MAX = 1000;
 
ll table[MAX][MAX];
 
// テーブルを作る前処理
void COMinit() {
    table[0][0] = table[0][1] = 1;
    FOR(i, 1, MAX-1){
      FOR(j, 0, i+1){
        if(j==0) table[i][j] = 1;
        else if(j == i+1) table[i][j] = 1;
        else table[i][j] = table[i-1][j-1]+table[i-1][j];
      }
    }
}
 
// 二項係数計算
ll COM(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return table[n-1][k];
}

void sosuu(ll n, vector<ll> &v){

  vector<ll> num(n, 0);

  FOR(i, 1, sqrt(n)){
    if(num[i]==0){
      FOR(j, 0, n/i){
        num[i+(j*i)] = 1;
      }
    }
  }
  REP(i, n){
    if(num[i]==0) v.push_back(i+1);
  }
}

ll SORT(int n, vector<pair<ll, ll>> &v, int start){
  sort(v.begin()+start, v.end());
  return v[n-1].first;
}


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

  vector<ll> v(n);
  vector<ll> a(n);
  REP(i, n){
    ll x;
    cin>>x;
    v[i] = x;
    a[i] = x;
  }

  sort(v.begin(), v.end());
  ll piv1 = v[n/2 -1];
  ll piv2 = v[n/2];

  REP(i, n){
    if(a[i]<piv1) cout<<piv2;
    else if(a[i]==piv1) cout<<piv2;
    else if(a[i]==piv2) cout<<piv1;
    else cout<<piv1;
    cout<<endl;
  }

  


  
  return 0;

}

Measured memory_bytes: 5376
import sys

# 関数 solve は，もちろん，問題に応じて書き換える
def solve(N,i) :#107-A
    a = N-i
    anser = a+1
    return anser

# ここから下は，入力・出力形式が同じであれば，変えなくて良い．
def readQuestion():
    line = sys.stdin.readline().rstrip()
    [str_a, str_b] = line.split(' ')
    return (int(str_a), int(str_b))

def main():
    a, b = readQuestion()
    answer = solve(a, b)
    print(answer)
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define print(s) cout << s << endl
#define acc(v) accumulate(v.begin(), v.end(), 0)
#define cinv(n,v) rep(i,n) cin >> v[i]
using namespace std;
const int INF = 1e9;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vchar;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
int x_pos[4] = {1,0,-1,0}, y_pos[4] = {0,1,0,-1};
int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

char upper(char c){
	return c-0x20;
}

char lower(char c){
	return c+0x20;
}

void unique_vector(vector<int>& v){
	sort(all(v));
	v.erase(unique(all(v)), v.end());
}

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

bool check[410][410];

int main() {
    int h,w;cin>>h>>w;
    vector<string> s(h);
    rep(i,h)cin>>s[i];
    ll ans = 0;
    Fill(check,false);
    rep(i,h)rep(j,w){
        if(s[i][j]=='.')continue;
        if(check[i][j])continue;
        queue<pii> q;
        check[i][j] = true;
        q.push(pii(i,j));
        ll cnt = 0,blacks = 0;
        while(!q.empty()){
            pii now = q.front();q.pop();
            if (s[now.first][now.second]=='.')cnt++;
            else blacks++;
            rep(i,4){
                int x = now.second + x_pos[i],y = now.first + y_pos[i];
                if(0 > x || x >= w || 0 > y || y >= h)continue;
                if(s[now.first][now.second] == s[y][x] || check[y][x])continue;
                q.push(pii(y,x));
                check[y][x] = true;
            }
        }
        ans += cnt*blacks;
    }
    cout << ans << endl;
}



Measured memory_bytes: 640
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        
        Scanner sc = new Scanner(System.in);
        int r = sc.nextInt();
        int D = sc.nextInt();
        int x2000 = sc.nextInt();
        
        int[] x = new int[11];
        x[0] = x2000;
        
        for(int i = 1; i <= 10; i++){
            x[i] = r * x[i-1] - D;
            System.out.println(x[i]);
        }
    }
}


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

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


Measured memory_bytes: 256
N = gets.to_i

t = 0
x = 0
y = 0

N.times do
  p = gets.strip.split(" ").map(&:to_i)

  dt = p[0] - t
  dx = (p[1] - x).abs
  dy = (p[2] - y).abs

  if (dt < dx + dy) || (dt - dx - dy).odd?
    puts "No"
    exit 0
  end

  t, x, y = p
end

puts "Yes"


Measured memory_bytes: 1788
N, K = map(int, input().split())
A = [0] + list(map(int, input().split()))

visited = dict()
a = 1
ct = 0
while a not in visited:
    visited[a] = ct
    a = A[a]
    ct += 1
    if ct == K:
        print(a)
        exit()
inv_v = {v: k for k, v in visited.items()}
print(inv_v[(K - visited[a]) % (len(visited) - visited[a]) + visited[a]])


Measured memory_bytes: 36796
#include <stdio.h>

int n;
int A[101][101];

int d[101], f[101];
int cnt;

void dfs(int u) {
  int i;
  if(d[u]) return;
  d[u] = ++cnt;
  for(i = 0; i < n; i++) if(A[u][i] == 1) dfs(i);
  f[u] = ++cnt;
}

int main() {
  int i, j;

  scanf("%d", &n);
  for(i = 0; i < n; i++) {
    int u, k;
    scanf("%d %d", &u, &k);
    --u;
    for(j = 0; j < k; j++) {
      int v;
      scanf("%d", &v);
      --v;
      A[u][v] = 1;
    }
  }

  for(i = 0; i < n; i++) dfs(i);

  for(i = 0; i < n; i++) printf("%d %d %d\n", i+1, d[i], f[i]);

  return 0;
}

Measured memory_bytes: 636
use std::io;
use std::str::FromStr;

fn get_line() -> String {
  let mut line = String::new();
  io::stdin()
    .read_line(&mut line)
    .unwrap();
  line
}

fn parse<T: FromStr>(line: &str) -> T {
  line
    .trim().parse::<T>()
    .ok().unwrap()
}

fn line_to_vec<T: FromStr>(line: &str) -> Vec<T> {
  line
    .trim().split_whitespace()
    .map(|val| parse(val))
    .collect()
}

fn main() {
  let n: i64 = line_to_vec(&get_line())[0];
  let mut house = [[[0; 10]; 3]; 4];
  for _ in 0..n {
    let v: Vec<i32> = line_to_vec(&get_line());
    let (b, f, r, v) = (v[0] as usize, v[1] as usize, v[2] as usize, v[3]);
    house[b - 1][f - 1][r - 1] += v;
  }
  for i in 0..4 {
    for j in 0..3 {
      let line: Vec<String> = (&house[i][j][..])
        .to_vec()
        .iter()
        .map(|val| val.to_string())
        .collect();
      println!(" {}", line.join(" "));
    }
    if i != 3 {
      println!("{}", String::from("#").repeat(20));
    }
  }
}



Measured memory_bytes: 5036
#include<bits/stdc++.h>
#define maxn 777
 
using namespace std;
bool f[maxn][maxn],g[maxn][maxn*2],vis[maxn],flag,h[maxn];
int n,m,a[maxn],b[maxn],p,q,r,o;
 
void dfs(int u,bool d){
    h[u]=d; vis[u]=true; if (d) p++; else q++;
    for (int i=1;i<=n;i++) if (f[u][i]){
        if (!vis[i]) dfs(i,d^1);
        else if (d==h[i]) flag=true;
    }
}
 
int main(){
    cin >> n >> m;
    memset(f,true,sizeof(f));
    for (int i=1;i<=n;i++) f[i][i]=0;
    for (int i=0;i<m;i++){
        int u,v;
        scanf("%d%d",&u,&v);
        f[u][v]=f[v][u]=0;
    }
    for (int i=1;i<=n;i++) if (!vis[i]) {
        dfs(i,0); r++;
        a[r]=p; b[r]=q;
        p=0; q=0;
    }
    if (flag) {cout << -1 << endl; return 0;}
    g[0][n]=true;
    for (int i=1;i<=r;i++)
        for (int j=0;j<=n*2;j++)
            if (g[i-1][j]) g[i][j+b[i]-a[i]]=true,g[i][j-b[i]+a[i]]=true;
    o=n;
    for (int i=0;i<=n*2;i++) if (g[r][i]) o=min(o,abs(n-i));
    p=(n+o)/2; q=(n-o)/2;
    printf("%d\n",p*(p-1)/2+q*(q-1)/2);
    return 0;
}


Measured memory_bytes: 1920
let () =
  let open Queue in
  let que = create () in
  let (n, q) = Scanf.scanf "%d %d\n" (fun n q -> (n, q)) in
  let rec read i =
    if i >= n then ()
    else (Scanf.scanf "%s %d\n" (fun s t -> add (s, t) que); read (i + 1))
  in
  read 0;
  let rec doit cnt =
    if is_empty que then ()
    else begin
      let (s, t) = take que in
      let rest = t - q in
      if rest <= 0 then (let x = cnt + t in Printf.printf "%s %d\n" s x; doit x)
      else (add (s, rest) que; doit (cnt + q))
    end
  in
  doit 0

Measured memory_bytes: 13228
#include <iostream>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <vector>

typedef long long ll;
using namespace std;

int main()
{
    ll N, K, ans = 1000000000;
    cin >> N >> K;

    vector <ll> h(N, 0);

    for (int i = 0; i < N; i++) {
        cin >> h[i];
    }

    sort(h.begin(), h.end());

    for (int i = 0; i < N - K + 1; i++) {
        ans = min(h[i + K - 1] - h[i], ans);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1024
#include <algorithm>
#include <cmath>
#include <iostream>
#include <numeric>
#include <string>
#include <string.h>
#include <vector>

#define REP(i,x) for(int i{ 0 }; i < (int)(x); i++)
#define REPC(i,x) for(int i{ 0 }; i <= (int)(x); i++)
#define RREP(i,x) for(int i{ (int)(x) - 1 }; i >= 0 ;i--)
#define RREPC(i,x) for(int i{ (int)(x)}; i >= 0; i--)
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

typedef int64_t int64;
typedef int64_t ll;

const int dx[4] = { 1, 0, -1,  0 };
const int dy[4] = { 0, 1,  0, -1 };

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; }

using namespace std;


class B {
	int n;
	vector<int> order;
	vector<int> val;
	vector<int> bonus;
public:
	B()
	{
		cin >> n;
		order.resize(n);
		val.resize(n + 1);
		bonus.resize(n + 1);

		REP(i, n)
			cin >> order[i];
		REP(i, n)
			cin >> val[i + 1];
		REP(i, n)
			cin >> bonus[i + 1];
	}
	void solve()
	{
		ll ans{ 0 };
		int last{ -2 };
		REP(i, n)
		{
			int cur{ order[i] };
			ans += val[cur];

			if (cur == last + 1)
				ans += bonus[last];

			last = cur;
		}

		cout << ans << endl;
	}
};


int main()
{
	B solution;
	solution.solve();

	return 0;
}

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

const int m = 10;
int n;
vector<vector<ll>> s(m, vector<ll>(0));

int main()
{
    cin >> n;
    for(int i = 1; i <= 9; i++)
    {
        s[0].emplace_back(i);
    }
    
    for(int i = 1; i < m; i++)
    {
        for(auto x : s[i - 1])
        {
            ll p = x % 10;
            for(ll j = max(p - 1, 0LL); j <= min(p + 1LL, 9LL); j++)
            {
                s[i].emplace_back(x * 10LL + j);
            }
        }
    }
    
    set<ll> st;
    rep(i, m)
    {
        for(auto x : s[i])
        {
            st.insert(x);
        }
    }
    int cnt = 1;
    for(auto x : st)
    {
        if(cnt == n)
        {
            cout << x << endl;
            break;
        }
        cnt++;
    }
    
    return 0;
}

Measured memory_bytes: 11188
#include<iostream>
#include<string>
#include <algorithm>

using namespace std;


int main(){
    int i;
    int antenna[5];
    for(i = 0; i < 5; i++){
        cin >> antenna[i];
    }
    int k;
    cin >> k;
    int max;
    max = *max_element(antenna, antenna+5);
    int min;
    min = *min_element(antenna, antenna+5);
    if(max <= min+k){
        cout << "Yay!" << endl;
    }else{
        cout << ":(" << endl;
    }

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
 
int main() {
  string S, T;
  cin >> S >> T;
  int ans = 0;
  if(S[0] == T[0]) ans++;
  if(S[1] == T[1]) ans++;
  if(S[2] == T[2]) ans++;
  cout << ans<< endl;
}

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

#define int long long
#define ll long long
#define f1(i,a,b) for(int i=a;i<b;i++)
#define f2(i,a,b) for(int i=a;i>=b;i--)
#define endl '\n'
#define pb push_back
#define gp " "
#define ff first
#define ss second
#define mp make_pair
#define ld long double

const int mod = 1000000007;
const ld PI = acosl(-1.0);
ll temp;

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    int l[n];
    for(int i = 0; i < n; i++)
    cin>>l[i];
    int ans = 0;
    for(int i = 0; i < n; i++)
    {
        for(int j = i + 1; j < n; j++)
        {
            for(int k = j + 1; k < n; k++)
            {
                if(l[i] != l[j] && l[j] != l[k] && l[i] != l[k])
                {
                    if(l[i] + l[j] > l[k] && l[j] + l[k] > l[i] && l[i] + l[k] > l[j])
                    {
                        // cout<<i<<gp<<j<<gp<<k<<endl;
                        ans++;
                    }
                }
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3640
#include <iostream>
#include <string>
#include <cstdio>

using namespace std;

int cnt = 0;

void calc_point(int n, int card[10000][2], int point[10000][2]) {
	//get input
	for (int i = 0; i < n; i++){
		if (card[i][0] > card[i][1])
			point[cnt][0] += card[i][0]+card[i][1];
		else if(card[i][0] < card[i][1])
			point[cnt][1] += card[i][0]+card[i][1];
		else{
			point[cnt][0] += card[i][0];
			point[cnt][1] += card[i][1];
		}
	}
	cnt++;
}

int main(){
	int n = 1;
	int card[10000][2];
	int point[10000][2];
	while (1){
		scanf("%d", &n);
		if (n==0) break;
		for (int i = 0; i < n; i++){
			for (int j = 0; j < 2; j++)
				scanf("%d", &card[i][j]);
		}
		calc_point(n, card, point);
	}
	for (int i = 0; i < cnt; i++)
		cout << point[i][0] <<" "<< point[i][1] << endl;
}

Measured memory_bytes: 3140
n = int(input())
d = []
for i in range(n):
    d.append([int(s) for s in input().split()])

count = 0
ans = 'No'
for i in range(n):
    if d[i][0] == d[i][1]:
        count += 1
        if count >= 3:
            ans = 'Yes'
    else:
        count = 0
print(ans)

Measured memory_bytes: 9176
let partition (a : int array) p r =
  let x = a.(r) in
  let swap i j = let t = a.(i) in a.(i) <- a.(j); a.(j) <- t
  in
  let rec doit i j =
    if j >= r then i
    else begin
      if a.(j) <= x then (swap (i + 1) j; doit (i + 1) (j + 1))
      else doit i (j + 1)
    end
  in
  let i = doit (p - 1) p in
  swap (i + 1) r;
  i + 1

let () =
  let n = read_int () in
  let a = Array.init n (fun _ -> Scanf.scanf "%d " (fun i -> i)) in
  let k = partition a 0 (n - 1) in
  Array.iteri (fun i e ->
    Printf.printf (if i = 0 then "%d" else if i = k then " [%d]" else " %d") e) a;
  print_newline ()

Measured memory_bytes: 5404
#include<iostream>
#include<string>
using namespace std;
int main(){
  string s;
  while(cin >> s){
    while(s.find("@")!=-1){
      int x=s.find("@");
      string buf;
      for(int i=0;i<s[x+1]-'0';i++) buf+=s[x+2];
      s.replace(x,3,buf);
    }
    cout << s << endl;
  }
}


Measured memory_bytes: 3144
#include<stdio.h>
int main(){
	int a,b;
	char c;
	while(1){
		scanf("%d %c %d",&a,&c,&b);
		if(c == '+'){
			printf("%d\n",a+b);
		}
		else if(c == '-'){
			printf("%d\n",a-b);
		}
		else if(c == '*'){
			printf("%d\n",a*b);
		}
		else if(c == '/'){
			printf("%d\n",a/b);
		}
		else{
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 2680
#include <bits/stdc++.h>
#define For(i, a, b) for (i = a; i <= b; i++)
using namespace std;
inline int read() {
	int res = 0; bool bo = 0; char c;
	while (((c = getchar()) < '0' || c > '9') && c != '-');
	if (c == '-') bo = 1; else res = c - 48;
	while ((c = getchar()) >= '0' && c <= '9')
		res = (res << 3) + (res << 1) + (c - 48);
	return bo ? ~res + 1 : res;
}
const int N = 2005;
int n, a[N]; bitset<4000003> f, g;
int main() {
	int i, s = 0, p; n = read(); For (i, 1, n) s += (a[i] = read());
	p = s; s = (s + 1) / 2; f[0] = 1; For (i, 1, n) f = f | (f << a[i]);
	For (i, s, p) if (f[i]) return printf("%d\n", i), 0;
	return 0;
}

Measured memory_bytes: 2688
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            var p = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);

            int count = 0;
            for (int i = 1; i < n-1; i++)
            {
                if((p[i-1]<p[i] && p[i] < p[i + 1])||(p[i +1] < p[i] && p[i] < p[i - 1]))
                {
                    count++;
                }
            }

            Console.WriteLine(count);
        }
    }
}


Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    long long int n,y,a=-1,b=-1,c=-1,z;
    cin>>n>>y;
    z=n*10000-y;
    for(int i=0;i<=n;i++){
        for(int j=0;j<=n-i;j++){
            if(i*5000+j*9000==z){
                b=i;
                c=j;
                a=n-b-c;
            }
        }
    }
    cout<<a<<" "<<b<<" "<<c<<endl;
    return 0;
}


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

int main(){
  int a, b, c;
  cin>>a>>b>>c;
  if(a==b&&a!=c)
    cout<<"Yes"<<endl;
  else if(b==c&&a!=b)
    cout<<"Yes"<<endl;
  else if(a==c&&b!=a)
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
}

Measured memory_bytes: 3560
N = int(input())
S = 0
for i in range(N):
    if (i+1)%3 == 0 and (i+1)%5==0 or (i+1)%3 ==0 or (1+i)%5 ==0 :
        continue
    else:
        S = S+1+i

print(S)
    


Measured memory_bytes: 9156
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Deque;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;

public class Main{
	static Map<String, Integer> opPriority = new HashMap<String, Integer>(){
		{
			put("+", 2);
			put("-", 2);
			put("*", 3);
			put("/", 3);
		}
	};
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		for(int i = 0; i < n; i++) {
			String s = sc.next();
			List<String> list = make(s);
			Deque<Integer> stackNum = new ArrayDeque<Integer>();
			Deque<String> stackOp = new ArrayDeque<String>();
			for(String t : list) {
				if(t.equals("=")) break;
				if(t.matches("\\d+")) {
					stackNum.addFirst(Integer.parseInt(t));
				}else if(opPriority.containsKey(t)){
					while(stackOp.size() > 0) {
						String op = stackOp.removeFirst();
						if(opPriority.containsKey(op)) {
							if(opPriority.get(t) <= opPriority.get(op)) {
								int v2 = stackNum.removeFirst();
								int v1 = stackNum.removeFirst();
								stackNum.addFirst(calc(op, v1, v2));
							}else {
								stackOp.addFirst(op);
								break;
							}
						}else {
							stackOp.addFirst(op);
							break;
						}
					}
					stackOp.addFirst(t);
				}else if(t.equals("(")){
					stackOp.addFirst(t);
				}else if(t.equals(")")){
					while(stackOp.size() > 0){
						String op = stackOp.removeFirst();
						if(op.equals("(")) {
							break;
						}else {
							int v2 = stackNum.removeFirst();
							int v1 = stackNum.removeFirst();
							stackNum.addFirst(calc(op, v1, v2));
						}
					}
				}
			}
			while(stackOp.size() > 0) {
				String op = stackOp.removeFirst();
				if(opPriority.containsKey(op)) {
					int v2 = stackNum.removeFirst();
					int v1 = stackNum.removeFirst();
					stackNum.addFirst(calc(op, v1, v2));
				}
			}
			System.out.println(stackNum.removeFirst());
		}
		sc.close();
	}
	static int calc(String op, int v1, int v2) {
		if(op.equals("+")) {
			return v1 + v2;
		}else if(op.equals("-")) {
			return v1 - v2;
		}else if(op.equals("*")) {
			return v1 * v2;
		}else if(op.equals("/")){
			return v1 / v2;
		}else {
			return 0;
		}
	}
 	static List<String> make(String s){
		List<String> list = new ArrayList<String>();
		int l = s.length();
		int idx = 0;
		while(idx < l) {
			char c = s.charAt(idx);
			if(c == '=') {
				list.add("=");
				break;
			}
			if(c == '+' || c == '-' || c == '*' || c == '/' || c == '(' || c == ')') {
				list.add(String.valueOf(c));
				idx++;
			}else {
				int begin = idx;
				char t = s.charAt(idx);
				while(t >= '0' && t <= '9') {
					idx++;
					t = s.charAt(idx);
				}
				list.add(s.substring(begin, idx));
			}
		}
		return list;
	}
}


Measured memory_bytes: 27284
##templete
n = gets.chomp.to_i
a = gets.chomp.split(" ").map { |e| e.to_i }

res = []
ans = 0
index = 0
m = 10000000000

def summ(a)
  leng = a.length
  res = 0
  for i in 0..leng-1 do
    res += a[i]
  end
  res
end


for i in 0..n-1 do
  if a[i] < 0
    res[index] = a[i]
    index += 1
  else
    ans += a[i]
    m = a[i] if a[i] < m
  end
end

res = res.sort

leng = res.length

if leng % 2 == 0
  ans -= summ(res)
else
  for i in 0..leng-2 do
    ans += -res[i]
  end

  if -res[leng-1] > m
    ans -= res[leng-1]
    ans -= 2*m
  else
    ans += res[leng-1]
  end
end


puts ans


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

int main()
{
    string a, b;
    cin >> a >> b;
    if(a.size() > b.size()){
        cout << "GREATER" << endl;
        return 0;
    }else if(a.size() < b.size()){
        cout << "LESS" << endl;
        return 0;
    }
    
    for(int i=0; i<a.size(); i++){
        if(a[i] > b[i]){
            cout << "GREATER" << endl;
            return 0;
        }else if(a[i] < b[i]){
            cout << "LESS" << endl;
            return 0;
        }
    }
    
    cout << "EQUAL" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#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 SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

int main(){
  ll n;
  cin >> n;
  ll a, res = 0, odd = 0;
  REP(i, n){
    cin >> a;
    if(odd){
      if(a){
        res++;
        a--;
      }
    }
    if(a % 2) odd = 1;
    else odd = 0;
    res += a / 2;
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 384
N, M = map(int, input().split())
X, Y = [], []

for _ in range(M):
    xi, yi = map(int, input().split())
    X.append(xi)
    Y.append(yi)

possible = [True] + [False] * (N - 1)
count = [1] * N

for i in range(M):
    xi, yi = X[i] - 1, Y[i] - 1

    # xiに赤があれば，yiも赤にできる
    if possible[xi]:
        possible[yi] = True
    # 数の変化
    count[xi] -= 1
    count[yi] += 1
    # 0になったら，赤は存在しない
    if count[xi] == 0:
        possible[xi] = False

count = 0
for f in possible:
    if f:
        count += 1
print(count)

Measured memory_bytes: 63960
#include <iostream>
#include <algorithm>
#include <vector>
#include <functional>
#include <string>
#include <stdio.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep2(i,n) for (int i = 1; i < 40001; i+=2)
using namespace std;
using P = pair<int, int>;
using ll = long long;

int main (){
  int n, count = 0;
  scanf("%d", &n);
  int a[n];
  for (int i = 0; i < n; i++){
      scanf("%d", &a[i]);
  }
  for (int i = 0; i < n; i +=2) {
      if (a[i] % 2 != 0){
          count += 1;
      }
  }
  printf("%d\n", count);
}

Measured memory_bytes: 3808
// chalo phir code karthe hh bina koi backchodi ke 
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast") 
#define int long long
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back 
#define eb emplace_back
#define fn for(int i =0 ;i <n;i++)
#define fn1 for( int i =1;i<=n;i++)
#define fm for(int j =0 ;j <m;j++)
#define fm1 for(int j =1;j<=m;j++)
#define fi first
#define se second
#define endl '\n'
# define PI  3.14159265358979323846
#define MOD 1000000007
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
const int N = 2e6+5;
const int INF = 1e18L;
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}
int ar[N];
int dp[N];
signed main(){
	// #ifndef ONLINE_JUDGE
	// freopen("input.txt","r",stdin);
	// freopen("output.txt","w",stdout);
	// #endif
	IOS;
	int T=1;
	// cin >> T;
	while(T--){
		int n;
		cin >> n ;
		n%=10;
		string ans;
		if(n==2 || n==4 || n==5 || n==7 || n==9)ans="hon";
		else if(n==0 || n==1 || n==6 || n==8 )ans="pon";
		else ans="bon";
		cout <<ans;
	}
	return 0;
}

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


#define vi vector<int>
#define pb push_back
#define pii pair<int, int>
#define mp make_pair
#define ll long long


int soma_digitos( int x ) {
	string n = to_string(x);
	int s = 0;
	for ( int i = 0; i < n.size(); i++ ) {
		s += n[i] - '0';
	}
	return s;
}


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

    int n, a, b, soma, menor = 1e5;
    cin >> n;

    for ( int i = 1; i < n / 2 + 2; i++ ) {
    	a = i;
    	b = n - i;
    	soma = soma_digitos(a);
    	soma += soma_digitos(b);
    	if ( soma < menor ) {
    		menor = soma;
    	}
    }

    cout << menor << endl;

    return 0;
}


Measured memory_bytes: 384
N = int(input())
M = 10 ** 6
A = list(map(int, input().split()))
B = [0] * (M + 1)
for a in A:
    B[a] +=1
C = [1] * (M + 1)
A = set(A)
for i in A:
    for j in range(i, M + 1, i):
        if i == j:
            if B[i] > 1:
                C[i] = 0
        else:
            C[j] = 0
ans = 0
for a in A:
    if C[a]:
        ans += 1
print(ans)


Measured memory_bytes: 134692
import java.util.*;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int headB = 0;
        int tailA = 0;
        int headBandtailA = 0;
        int ABcount = 0;
        String[] S = new String[N];

        for (int i = 0; i < N; i++) {
            S[i] = sc.next();
        }

        for (int i = 0; i < N; i++) {
            String s = S[i];
            if (s.startsWith("B")) {
                if (s.endsWith("A")) {
                    headBandtailA++;
                } else {
                    headB++;
                }
            } else if (s.endsWith("A")) {
                tailA++;
            }

            int index = 0;
            while (index != -1) {
                index = s.indexOf("AB");
                if (index != -1) {
                    ABcount++;
                    if(s.length() >= index+2){
                        s = s.substring(index+2);
                    } else {
                        index = -1;
                    }
                }
            }
        }

        if (headB == 0 && tailA == 0) {
            if(headBandtailA > 0){
                System.out.println(ABcount + headBandtailA -1);
            } else {
                System.out.println(ABcount);
            }

        } else {
            System.out.println(ABcount + headBandtailA + Math.min(headB,tailA));
        }
    }
}


Measured memory_bytes: 32356
x, n = map(int, input().split(' '))
diff = x
result = 0

if n != 0:
    ls = list(map(int, input().split(' ')))
    ls_remaind = []
    for i in range(1, 102):
        if i not in ls:
            ls_remaind.append(i)
    for j in ls_remaind:
        if abs(x-j) == diff:
            result = min(result, j)
        elif abs(x-j) < diff:
            diff = abs(x-j)
            result = j
else:
    result = x

print(result)

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

#define ld long double
#define ll long long
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define MP make_pair
ll MOD = 1e9+7;
//ll MOD = 998244353;
ll INF = 1e18;
void chmin(ll &a,ll b){if(a>b)a=b;}
void chmax(ll &a,ll b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
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;}
void ans(bool x,ll y,ll z){if(x)cout<<y<<endl;else cout<<z<<endl;}
void anss(bool x,string y,string z){if(x)cout<<y<<endl;else cout<<z<<endl;}   
ll gcd(ll x,ll y){ll r;while((r=x%y)!=0){x=y;y=r;}return y;}

int main(){
  ll i,j,o;
  ll res=0,res1=0,res2=INF,buf=0,buf1=0,buf2=0,buf3=0,buf4=0;
  bool judge = true;
  ll a,b,c;cin>>a>>b>>c;
  ans1(c>=a&&c<=b);

  return 0;
}

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


def solve(A: int, B: int):
    print(A*B)
    return


# Generated by 1.1.7.1 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()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    solve(A, B)

if __name__ == '__main__':
    main()


Measured memory_bytes: 9012
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 2;
int arr[maxn],N;
int gcd(int a,int b){
	return b == 0 ? a : gcd(b,a%b);
}
int main(){
	scanf("%d",&N);
	for(int i = 0 ; i < N ; ++i) scanf("%d",arr+i);
	int pre = arr[0];
	for(int i = 1 ; i < N ; ++i){
		pre = gcd(pre,arr[i]);
	}
	printf("%d\n",pre);

	return 0;
}

Measured memory_bytes: 640
#include <algorithm>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>

using namespace std;
using LLONG = long long;

int main()
{
    int A, B, C;
    cin >> A >> B >> C;
    if (A <= C && C <= B)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define INF 1000000000
#define rep(i, n) for(int i = 0; i < n; i++)
#define ALL(x) (x).begin(), (x).end()  //昇順
#define RALL(x) (x).rbegin(), (x).rend() // 降順
const long long mod = 1e9+7;
typedef priority_queue<int> PQ;
typedef vector<long long> VL;
typedef vector<int> VI;  // VI a(n);
typedef vector<string> VS;  
typedef vector<char> VC; 
typedef vector<VS> VSS;
typedef vector<VC> VCC;    
typedef vector<VI> VVI;   // VVI a(n,vector<int>(m)) n * m 
typedef vector<VL> VVL;
typedef pair<int, int> PII;
typedef map<int, int> MP;   //MP a;
typedef vector<pair<int, int> > PS;
typedef long long ll;  //ll とdoubleは違う
template <class T>  // chmax(max, a);
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> //chmin(min,a)
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
template<typename T>   // operator << (cout,a);
ostream& operator << (ostream& os, vector<T>& v) {
    os << "{";
    rep(i, (int)v.size()) { os << v[i] << (i < v.size() - 1 ? ", " : ""); }
    os << "}";
    return os;
}

int main(){
    int x,y,n,m,h,k,max=0,min=0,max2=0,min2=0,ans=0,sum=0;
    string s,t;
    cin >> n;
    VI a(n);
    VI b(n+2);
    rep(i,n){
        cin >> a[i];
	}
    b[0]=0;
    for(int i=1;i<n+1;i++){
        b[i] = a[i-1];
    }
    b[n+1]=0;
    //operator << (cout,b);
    rep(i,n+1){
        sum += abs(b[i]-b[i+1]);
    }
    for(int i=1;i<n+1;i++){
        cout << sum+abs(b[i-1]-b[i+1]) - (abs(b[i-1]-b[i])+abs(b[i]-b[i+1])) << endl;
    }
    return 0;
}

Measured memory_bytes: 2048
#include<stdio.h>
int main(void)
{
	int t,s,f,n,i,g=0,a;
	/*0<=t<=22;
	1<=n<=10;
	6<=s;
	f<=22;*/
	while(1){
		scanf("%d",&t);
		if(t==0)break;
		scanf("%d",&n);
		for(i=1;i<=n;i++){
			scanf("%d %d",&s,&f);
			g=g+(f-s);
		}
		if(g<t){
			a=t-g;
			printf("%d\n",a);
		}
		else{
			printf("OK\n");
		}
		g=0;
	}
	return 0;
}


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

using namespace std;
#define inf             0x3f3f3f3f
#define INF             2e18
#define eps             1e-9

#define FastRead        ios_base::sync_with_stdio(0);cin.tie(0)
#define fRead           freopen("input.txt","r",stdin)
#define fWrite          freopen("output.txt","w",stdout)

#define LL              long long
#define ull            unsigned long long
#define PI              acos(-1.0)
#define pb              push_back
#define mk              make_pair
#define pii             pair<int,int>
#define pLL             pair<LL,LL>
#define ff              first
#define ss              second
#define all(a)          a.begin(),a.end()
#define SQR(a)          ((a)*(a))
#define min3(a,b,c)     min(a,min(b,c))
#define max3(a,b,c)     max(a,max(b,c))
#define min4(a,b,c,d)   min(min(a,b),min(c,d))
#define max4(a,b,c,d)   max(max(a,b),max(c,d))
#define max5(a,b,c,d,e) max(max3(a,b,c),max(d,e))
#define min5(a,b,c,d,e) min(min3(a,b,c),min(d,e))
#define vi              vector <int>
#define vL              vector <LL>
#define LB(a,x)         (lower_bound(all(a),x)-a.begin()) //  first element in the range [first,last) which does not compare less than val.
#define UB(a,x)         (upper_bound(all(a),x)-a.begin()) //  first element in the range [first,last) which compares greater than val.
#define prec(n)         fixed << setprecision(n)

#define MEM(a,x)        memset(a,x,sizeof(a))
#define SORT(v)         sort(v.begin(),v.end())
#define REV(v)          reverse(v.begin(),v.end())
#define Unique(a)       sort(all(a)),a.erase(unique(all(a)),a.end())

#define FOR(i,a,b)      for(int i=a;i<=b;i++)
#define ROF(i,a,b)      for(int i=a;i>=b;i--)
#define REP(i,b)        for(int i=0;i<b;i++)
#define IT(it,x)	    for(it=x.begin();it!=x.end();it++)


int main()
{
    string s;
    cin>>s;
    if(s=="Sunny")
        cout<<"Cloudy";
    else if(s=="Cloudy")
        cout<<"Rainy";
    else
        cout<<"Sunny";

}

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

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};


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

  string s;
  cin >> s;

  ll n = s.size();
  cout << s[0] << n-2 << s[n-1] << endl;
  
}


Measured memory_bytes: 256
import java.util.Scanner;
class Main{


	static char[][] map;
	static final int MOD = 1000000007;


	static long[][] c;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);			//文字の入力

		char[] cs = sc.next().toCharArray();


		for(int i = 0;i < cs.length/2;i++){			//逆じゅん
			char tmp = cs[i];
			cs[i] = cs[cs.length-1-i];	
			cs[cs.length-1-i] = tmp;
		}
		long[][] dp = new long[cs.length+1][13];
		dp[0][0] = 1;

		int keta = 1;
		for(int i = 0;i < cs.length;i++){
			int num = -1;
			if(cs[i] != '?'){
				num = cs[i] - '0';
			}
			
			if(num != -1){
				for(int j = 0;j < 13;j++){
					int m = (keta*num%13 + j)%13;
					dp[i+1][m] += dp[i][j]%MOD;
					dp[i+1][m] %= MOD;
				}
			}else{
				for(int k = 0;k < 10;k++){
					for(int j = 0;j < 13;j++){
						int m = (keta*k%13 + j)%13;
						m %= 13;
						dp[i+1][m] += dp[i][j]%MOD;
						dp[i+1][m] %= MOD;
					}
				}
			}
			
			keta *= 10;
			keta %= 13;
		}
		
		System.out.println(dp[cs.length][5]);


//		for(int i = 0;i < dp.length;i++){
//			for(int j = 0;j < 13;j++){
//				System.out.print(dp[i][j] + " ");
//			}
//			System.out.println();
//		}



	}



	static int gcd(int a,int b){				//最大公約数を返す
		if(b == 0){
			return a;
		}else{
			return gcd(b, a%b);
		}
	}
	static long gcd(long a,long b){
		if(b == 0){
			return a;
		}else{
			return gcd(b, a%b);
		}
	}



	static long lcm (long a, long b) {
		long g = gcd(a,b);
		return a/g*b;
	}




}



class Pair implements Comparable{
	int from;
	int end;
	@Override
	public int compareTo(Object other) {
		Pair otherpair = (Pair)other;

		return   end- otherpair.end;
	}








}






Measured memory_bytes: 38204
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <list>
#include <deque>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <algorithm>
#include <cmath>
#define ll long long
#define INF 0x3f3f3f3f
#define SIS std::ios::sync_with_stdio(false)
using namespace std;
ll fast_pow(ll a,ll b,ll mod)
{
    ll c=1;
    while(b>=2)
    {
        if(b%2==0)
            a*=a,b/=2;
        else
            c*=a,a*=a,b--,b/=2;
        a%=mod,c%=mod;
    }
    return (a*c)%mod;
}
bool cmp(ll a,ll b) {return a>b;}
int main()
{
    SIS;
    cin.tie(0);
    ll x,y,a,b,c;
    while(cin>>x>>y>>a>>b>>c)
    {
        vector <ll> r,g,l,eat;
        ll num;
        for(int i=0;i<a;i++)
        {
            cin>>num;
            r.push_back(num);
        }
        for(int i=0;i<b;i++)
        {
            cin>>num;
            g.push_back(num);
        }
        for(int i=0;i<c;i++)
        {
            cin>>num;
            l.push_back(num);
        }
        sort(r.begin(),r.end(),cmp);
        sort(g.begin(),g.end(),cmp);
        sort(l.begin(),l.end(),cmp);
        for(int i=0;i<x;i++)
            eat.push_back(r[i]);
        for(int i=0;i<y;i++)
            eat.push_back(g[i]);
        sort(eat.begin(),eat.end());
        ll now=0,ans=0;
        for(int i=0;i<x+y;i++)
        {
            if(eat[i]<l[now])
            {
                eat[i]=l[now];
                now++;
            }
        }
        for(int i=0;i<x+y;i++)
            ans+=eat[i];
        cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 5876
x = [int(i) for i in input().split()]
n, k = x[0], x[1]
ans = 0
for i in range(1, n+1):
  temp, cnt = i, 0
  while(temp < k):
    temp = temp*2
    cnt = cnt + 1
  ans = ans + 0.5 ** cnt
ans = ans / n
print(ans)
  

Measured memory_bytes: 2940
import sys
sys.setrecursionlimit(4100000)
import math
import itertools
INF = float('inf')
from heapq import heapify, heappop, heappush
import collections
import bisect

def main():
    n = int(input())
    count = 0
    D1 = []
    D2 = []
    for i in range(n):
        d1, d2 = map(int, input().split())
        D1.append(d1)
        D2.append(d2)
    for i in range(n):
        if D1[i] == D2[i]:
            count += 1
        else:
            count = 0
        if count == 3:
            print('Yes')
            return
    print('No')


if __name__ == '__main__':
    main()


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

#define rep(i, x, n) for (int i = x; i < n; i++)
typedef long long ll;

using namespace std;

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

  int sum = 0;
  int tmp = 0;
  if (l >= 0 && l + n - 1 >= 0) {
	// sum += l;
	rep (i, 1, n) {
	  sum += (l + i);
	}
  } else if (l < 0 && l + n - 1 >= 0) {
	rep (i, 0, n) {
	  sum += (l + i);
	}
  } else { // all minus
	rep (i, 0, n - 1) {
	  sum += (l + i);
	}
  }

  cout << sum << endl;
  return 0;
}


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

int main() {

	ll n; cin >> n;
	vector<ll> a(n);
	ll minusCnt = 0;
	ll minAbsValue = 10000000000;
	ll sum = 0;
	ll ans;
	for (ll i = 0; i < n; i++) {
		cin >> a[i];
		sum += abs(a[i]);
		if (a[i] < 0) minusCnt++;
		minAbsValue = min(minAbsValue, abs(a[i]));
	}
	if (minusCnt % 2 == 0) ans = sum;
	else {
		ans = sum - 2 * minAbsValue;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4016
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <fstream>
using namespace std;
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v;}
template<class T> inline string toStr(T x) { ostringstream sout; sout << x; return sout.str();}
typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,(n)-1)
const double EPS = 1e-12;
const double PI = acos(-1.0);
const int INF = INT_MAX/10;

string merge(string a, string b) {
	if(a.find(b) != string::npos) {
		return a;
	}
	if(b.find(a) != string::npos) {
		return b;
	}

	string res = a+b;

	int al = a.length(), bl = b.length();
	FOR(i, 1, min(al, bl)) {
		string as = a.substr(al-i);
		string bs = b.substr(0, i);
		if(as == bs) {
			res = a + b.substr(i);
		}
	}

	return res;
}

string minstr(string a, string b) {
	int al = a.length(), bl = b.length();
	if(al < bl) {
		return a;
	} else if(al > bl) {
		return b;
	} else if(a < b) {
		return a;
	} else {
		return b;
	}
}

bool exist(int st, int i) {
	return st&(1<<i);
}

int main() {
	int N;
	while(cin >> N, N) {
		vs str(N);
		REP(i, N) {
			cin >> str[i];
		}

		vector<vs> dp(1<<N, vs(N, string('z', 101)));
		REP(i, 1<<N) {
			if(i == 0) {
				REP(j, N) {
					dp[1<<j][j] = str[j];
				}
			} else {
				REP(j, N) {
					if(!exist(i, j)) {
						REP(k, N) {
							if(exist(i, k)) {
								dp[i|(1<<j)][j] = minstr(dp[i|(1<<j)][j], merge(dp[i][k], str[j]));
							}
						}
					}
				}
			}
		}

		string ans('z', 101);
		REP(i, N) {
			ans = minstr(ans, dp[(1<<N)-1][i]);
		}
		cout << ans << endl;
	}
	
	return 0;
}

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

int main() {
    string s;
    cin >> s;
    int n = s.size();
    int cnt1 = 0, cnt2 = 0;
    for (int i = 0; i < n; i++) {
        if (i & 1) {
            if (s[i] == '0') cnt1++;
            else cnt2++;
        }  else {
            if (s[i] == '1') cnt1++;
            else cnt2++;
        }
    }
    cout << min(cnt1, cnt2) << endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll MOD = 1000000007;

ll pow(ll x,ll y){
  if(y==0){
    return 1;
  }else if(y==1){
    return x%MOD;
  }else if(y%2==0){
    return pow(x,y/2)*pow(x,y/2)%MOD;
  }else{
    return pow(x,y-1)*x%MOD;
  }
}

int main(){
  string S;cin >> S;
  if(S=="ARC"){
    cout << "ABC" << endl;
  }else{
    cout << "ARC" << endl;
  }
}

Measured memory_bytes: 3568
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int N;
  cin >> N;
  int count = 0;
  for (int i = 0; i < N; i++)
  {
    int a;
    cin >> a;
    if (i % 2 == 0 && a % 2 == 1)
    {
      count++;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 3580
#include<algorithm>
#include<iostream>
#include<vector>
using namespace std;
int p[100005];
vector <int> a,b;
vector <int> g[100005];
bool tk[100005];
void dfs(int i)
{
	if(tk[i])
	    return;
	tk[i]=true;
	a.push_back(i);
	b.push_back(p[i]);
	for(int j=0;j<g[i].size();j++)
	    dfs(g[i][j]);
}
int main()
{
	int n,m;
	cin>>n>>m;
	for(int i=1;i<=n;i++)
	    cin>>p[i];
	for(int i=1;i<=m;i++)
    {
    	int x,y;
    	cin>>x>>y;
    	g[x].push_back(y);
    	g[y].push_back(x);
	}
	int res=0;
	for(int i=1;i<=n;i++)
	{
		dfs(i);
		int l=0,r=0;
		sort(a.begin(),a.end());
		sort(b.begin(),b.end());
		while(l<a.size()&&r<b.size())
		{
			if(a[l]<b[r])
			    l++;
			else
			if(a[l]>b[r])
			    r++;
			else
			    l++,r++,res++;
		}
		a.clear();
		b.clear();
	}
	cout<<res;
	return 0;
}

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

#define MAX_V 11
int d[MAX_V][MAX_V];//&#26435;&#20540;
int V;//定点数
int x[MAX_V];//x[i]表示以i&#20026;起点&#26102;最短路径之和
#define forn(i,n) for(int i=0;i<(int)n;++i)

void floyd_warshall(){
	forn(k, V)
		forn(i, V)
		forn(j, V)
		d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
}
int main(){
	int E;
	while (cin >> E, E){
		memset(d, 0x3f, MAX_V*MAX_V*sizeof(int));
		forn(i, MAX_V)
			d[i][i] = 0;
		V = 0;
		forn(i, E){
			int u, v, cost;
			cin >> u >> v >> cost;
			d[u][v] = cost;
			d[v][u] = cost;
			V = max(V, max(v, u) + 1);
		}
		floyd_warshall();
		memset(x, 0, V*sizeof(int));
		forn(i, V)
			forn(j, V)
			x[i] += d[i][j];
		int ans = min_element(x, x + V) - x;
		cout << ans << " " << x[ans] << "\n";
	}
	return 0;
}

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

const int mod = 998244353;
struct mint {
    ll x;  // typedef long long ll;
    mint(ll x = 0) : x((x % mod + mod) % mod) {}
    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*(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;
    }

    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;
    }
};

struct combination {
    vector<mint> fact, ifact;
    // init struct with "n" of "nCk" (maximum number in other words)
    combination(int n) : fact(n + 1), ifact(n + 1) {
        assert(n < mod);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i;
    }
    // c(n,k) returns mint that contains nCk (mod p (= 1e9+7)) in x
    // i.e.) mint num = c(n,k), then num.x == nCk (mod p (= 1e9+7))
    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n] * ifact[k] * ifact[n - k];
    }
};

ll modpow(ll a, ll n) {
    ll res = 1;
    while (n > 0) {
        if (n & 1)
            res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

int main() {
    ll n, m, k;
    cin >> n >> m >> k;
    combination nck(n);
    mint ans;
    for (int i = 0; i <= k; i++) {
        mint pat(m * modpow(m - 1, n - i - 1));
        pat *= nck(n - 1, i);
        ans += pat;
    }
    cout << ans.x << endl;
}

Measured memory_bytes: 6424
fn input() -> Vec<String> {
    let mut x = String::new();
    std::io::stdin().read_line(&mut x).unwrap();
    x.split_whitespace().map(String::from).collect()
}

fn main() {
	let k = input()[0].parse().unwrap();
	let s = String::from(&input()[0]);
	let l = s.len();
	if k >= l {
		println!("{}", s);
	} else {
		let s1 = &s[..k];
		println!("{}...", s1);
	}
}


Measured memory_bytes: 2072
n = int(input())
List = []
for i in range(n):
    Tmp = [i]+list(input().split())
    Tmp[2] = int(Tmp[2])
    List.append(Tmp)
List.sort(key=lambda x: x[2], reverse=True)
List.sort(key=lambda x: x[1])

for i in range(n):
    print(1+List[i][0])

Measured memory_bytes: 38384