akhauriyash/Code-Regression huggingface dataset:
import std.stdio;
import std.string;
import std.math;
import std.conv;
import std.algorithm;
import std.bigint;

void main(){

    int[101] a;
    int maxvalue = 0;
    while(true){
	auto temp = chomp(readln());
	if(stdin.eof()) break;
	int s = to!int(temp);
	a[s]++;
	if(maxvalue < a[s]) maxvalue = a[s];
    }
    for(int i=0;i<101;i++){
	if(maxvalue == a[i]) writef("%d\n",i);
    }
}

Measured memory_bytes: 2424
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <cmath>
using namespace std;
typedef long long i64;
typedef long double ld;
typedef pair<int,int> P;
#define rep(i,s,e) for(int i = (s);i <= (e);i++)

int m;
int n;

struct Graph
{
	struct edge
	{
		int to;
		int cost;
	};

	int n;
	vector<vector<edge>> edges;

	Graph(int N)
	{
		n = N;
		edges.resize(n,vector<edge>());
	}

	int size() const
	{
		return n;
	}

	vector<edge>& operator[](int v)
	{
		return edges[v];
	}
	
};

vector<int> dist[101];

void dijk(Graph& g,int s)
{
	dist[s].resize(n + 1,1e9);
	priority_queue<P> que;
	que.push({0,s});
	dist[s][s] = 0;

	while(!que.empty())
	{
		int d = que.top().first;
		int v = que.top().second;
		que.pop();
		if(dist[s][v] < d) continue;

		for(auto& e : g[v])
		{
			if(dist[s][e.to] > d + e.cost)
			{
				dist[s][e.to] = d + e.cost;
				que.push({dist[s][e.to],e.to});
			}
		}
	}
}

int a[1001];
int b[1001];
int c[1001];

int main()
{
	cin >> n >> m;
	Graph g(n + 1);
	rep(i,1,m)
	{
		cin >> a[i] >> b[i] >> c[i];
		g[a[i]].push_back({b[i],c[i]});
		g[b[i]].push_back({a[i],c[i]});
	}

	rep(i,1,n)
	{
		dijk(g,i);
	}

	int res = 0;
	rep(i,1,m)
	{
		if(c[i] > dist[a[i]][b[i]])
		{
			res++;
		}
	}

	cout << res << endl;
	return 0;
}





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

#define ll long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define debug3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define debugB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

template<typename T>
void printA(vector<T> &printArray, char between = ' ') {
   int paSize = printArray.size();
   for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between;}
   if (between != '\n') {cerr << endl;}
}

// ------------------------------------------------------------------------------------------

int main() {
   int a, b;
   cin >> a >> b;
   int ans = 0;
   if (a <= b) {
      ans = a;
   } else {
      ans = a-1;
   }
   cout << ans << endl;

   return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <map>
#include <set>
#include <algorithm>
#include <vector>
#include <sstream>
#include <string>
#include <functional>
#include <queue>
#include <deque>
#include <stack>
#include <limits>
#include <unordered_map>
#include <unordered_set>
#include <math.h>
#include <fstream>
#include <iterator>
#include <random>
#include <chrono>
 
 
#define forr(i,start,count) for (int i = (start); i < (start)+(count); ++i)
#define set_map_includes(set, elt) (set.find((elt)) != set.end())
#define readint(i) int i; cin >> i
#define readll(i) ll i; cin >> i
#define readdouble(i) double i; cin >> i
#define readstring(s) string s; cin >> s

typedef long long ll;
 
using namespace std;

template<class T>
T fastpower(T a, long long n) {  // n must be >= 1
  if (n % 2 == 0) {  
      T halfpower = fastpower<T>(a, n/2);
      return halfpower*halfpower;
  } else {
      if (n == 1) {  return a; } else {  
          T halfpower = fastpower<T>(a, n/2);
          return (halfpower*halfpower)*a;
      }
  }
};


int main()   {
    cout.precision(17);
    ll modd = 1000 * 1000 * 1000 + 7;
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    uniform_int_distribution<int> rand_gen(0, modd);   // rand_gen(rng) gets the rand no
    ll infinit = 10000000000000000;

//    auto start = chrono::steady_clock::now();

//    readint(test_cases);
    int test_cases = 1;
    forr(t, 1, test_cases) {
        readll(n);
        bool odd_exists = false;
        forr(i,0,n) {
            readint(kk); if (kk%2==1) {odd_exists = true; break;}
        }

        if (odd_exists) {cout << "first" << endl;} else {cout << "second" << endl;}


    }

//    auto end = chrono::steady_clock::now();
//    cout << chrono::duration_cast<chrono::milliseconds>(end - start).count() << endl;

    return 0;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i,n,m) for(int i=(n);i<(m);i++)
#define REP(i,n) FOR(i,0,n)
#define REPR(i,n) for(int i=(n);i>=0;i--)
#define all(vec) vec.begin(),vec.end()
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using P=pair<ll,ll>;
using PP=pair<ll,P>;
using vp=vector<P>;
using vpp=vector<PP>;
using vs=vector<string>;
#define fi first
#define se second
#define pb push_back
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}
const ll MOD=1000000007LL;
const int INF=1<<30;
const ll LINF=1LL<<60;
int main(){
    int n,c;
    cin>>n>>c;
    vvi d(c,vi(c));
    REP(i,c){
        REP(j,c){
            cin>>d[i][j];
        }
    }
    vvi vec(n,vi(n));
    REP(i,n){
        REP(j,n){
            cin>>vec[i][j];
            vec[i][j]--;
        }
    }
    vvi a(c,vi(3));
    REP(i,c){
        REP(j,n){
            REP(k,n){
                a[i][(j+k)%3]+=d[vec[j][k]][i];
            }
        }
    }
    int ans=INF;
    REP(i,c){
        REP(j,c){
            if(i==j){
                continue;
            }
            REP(k,c){
                if(i==k||j==k){
                    continue;
                }
                chmin(ans,a[i][0]+a[j][1]+a[k][2]);
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1280
#include<stdio.h>
int main(void){
    int a,b,c,d,p;
    int x,y;

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

    x=a*p;
    if(p<=c) y=b;
    else y=b+(p-c)*d;

    if(x<y) printf("%d\n",x);
    else printf("%d\n",y);

    return 0;
}

Measured memory_bytes: 596
A, B, C, D = map(int, input().split())

t_turn = 1
while A > 0 and C > 0:
    if t_turn % 2 == 1:
        C -= B
    else:
        A -= D
    t_turn += 1

if A > 0:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 9172
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep2(i, s, n) for(int i=s; i<(n); ++i)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;

static const int INTINF = (2147483647 >> 1); // 10^9 + 5000
static const ll LLINF = (9223372036854775807 >> 1);
static const int MAX = 1e5+1;
static const ll MOD = 1e9+7;

namespace Kunitaka{
    template<
        typename TYPE,
        std::size_t SIZE
    >
    std::size_t array_length(const TYPE (&array)[SIZE])
    {
        return SIZE;
    }

    template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
    template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
}
using namespace Kunitaka;
namespace Printer{
    void br(){
        cout << endl;
    }

    void loop_cnt(int i){
        cout << "i = " << i << endl;
    }

    void loop_cnt(int i, int j){
        cout << "i = " << i << ", " << "j = " << j << endl;
    }

    template<class T>
    void print(T x){
        cout << x << endl;
    }

    template<class T, class S>
    void print(T x, S y){
        cout << x << "," << y << endl;
    }

    template<class T, class S, class U>
    void print(T x, S y, U z){
        cout << x << "," << y << "," << z << endl;
    }

    template<class T, class S>
    void print(pair<T, S> p){
        cout << p.first << ", " << p.second << endl;
    }

    template<
        typename TYPE,
        std::size_t SIZE
    >
    void print(const TYPE (&array)[SIZE]){
        int lim = array_length(array);
        for(int i=0; i<lim; i++){
            if(i) cout << " ";
            cout << array[i];
        }
        cout << endl;
    }

    template<class S>
    void print(vector<S> v){
        for(int i=0; i<v.size(); i++){
            if(i) cout << " ";
            cout<< v[i];
        }
        cout << endl;
    }

    template<class S>
    void print(vector<vector<S> > vv){
        for(int i=0; i<vv.size(); i++){
            for(int j=0; j<vv[i].size(); j++){
                if(j) cout << " ";
                cout << vv[i][j];
            }
            cout << endl;
        }
    }

    void yesno(bool x){
        if(x) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
};
using namespace Printer;

int main(int argc, const char * argv[]) {
    //提出時、消す----//
    //--------------//


    // input
    cout << fixed << setprecision(10);
    double L; cin >> L;

    double a = L/3;
    

    double res = a * a * a;

    printf("%.9lf\n", res);
    
    
    return 0;
}


Measured memory_bytes: 256
package main

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

const (
	initialBufSize = 10000
	maxBufSize     = 10000000
)

var (
	sc = func() *bufio.Scanner {
		sc := bufio.NewScanner(os.Stdin)
		buf := make([]byte, initialBufSize)
		sc.Buffer(buf, maxBufSize)
		sc.Split(bufio.ScanWords)
		return sc
	}()
)

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

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func nextFloat() float64 {
	sc.Scan()
	f, e := strconv.ParseFloat(sc.Text(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func powMod(a, n int) int {
	if n < 0 {
		log.Fatal("pow error")
	}
	if n == 0 {
		return 1
	}
	if n%2 == 0 {
		d := powMod(a, n/2) % mod
		return d * d % mod
	}
	return a * powMod(a, n-1) % mod
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

type key struct {
	Positive bool
	First    int
	Second   int
}

func toPositive(a, b int) (int, int, bool) {
	if a == 0 && b == 0 {
		return a, b, true
	}
	if a == 0 {
		if b > 0 {
			return a, b, true
		}
		return a, -b, false
	}

	if b == 0 {
		if a > 0 {
			return a, b, true
		}
		return -a, b, false
	}

	if a > 0 && b > 0 {
		return a, b, true
	}
	if a > 0 && b < 0 {
		return a, -b, false
	}
	if a < 0 && b > 0 {
		return -a, b, false
	}
	if a < 0 && b < 0 {
		return -a, -b, true
	}
	log.Fatal("positive error")
	return 0, 0, true
}

const mod = 1000000007

func main() {
	n := nextInt()
	a := make([]int, n)
	b := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = nextInt()
		b[i] = nextInt()
	}
	count := make(map[key]int)
	// twoZeroes, zeroOne, oneZero := 0, 0, 0
	twoZeroes := 0
	for i := 0; i < n; i++ {
		var val key
		pa, pb, pos := toPositive(a[i], b[i])
		g := gcd(pa, pb)
		if a[i] == 0 && b[i] == 0 {
			twoZeroes++
			continue
		} else if a[i] == 0 {
			val = key{true, 0, 1}
			// zeroOne++
		} else if b[i] == 0 {
			val = key{false, 1, 0}
			// oneZero++
		} else {
			val = key{pos, pa / g, pb / g}
			// count[val]++
		}
		count[val]++
	}
	// fmt.Println(count)

	// ans := (powMod(2, zeroOne) + powMod(2, oneZero) - 1 + mod) % mod
	ans := 1
	used := make(map[key]bool)
	for k, cnt := range count {
		if used[k] {
			continue
		}

		pair := key{!k.Positive, k.Second, k.First}
		if pcnt, ok := count[pair]; ok {
			ans *= (powMod(2, cnt) + powMod(2, pcnt) - 1 + mod) % mod
			used[pair] = true
		} else {
			ans *= powMod(2, cnt)
		}
		ans %= mod
	}
	ans += twoZeroes % mod
	ans = (ans - 1 + mod) % mod
	fmt.Println(ans)
}


Measured memory_bytes: 25888
x = int(input())

breakflag = False

a = 0
b = 0

for i in range(1000):
    for j in range(i):

        if x == i ** 5 + j ** 5:
            a = i
            b = -j
            breakflag = True
            break

        elif x == i ** 5 - j ** 5:
            a = i
            b = j
            breakflag = True
            break

    if breakflag:
        break

output = ' '.join([str(a), str(b)])
print(output)


Measured memory_bytes: 9188
// Aizu Vol-1 0124: League Match Score Sheet
// 2017.8.2

#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>

char *gets(char *);
char buf[100], *p;

typedef struct { char t[22]; int k, s; } T;
T term[15];

void getStr(char *w)
{
	while (isspace(*p)) p++;
	while (isalpha(*p)) *w++ = *p++;
	*w = 0;
}

int getInt(void)
{
	int n = 0;
	while (isspace(*p)) p++;
	while (isdigit(*p)) n = 10 * n + (*p++ - '0');
	return n;
}

int main()
{
	int i, j, k, n, f = 1;
	char w[22];

	while (1) {
		gets(p = buf); n = getInt();
		if (!n) break;
		for (i = 0; i < n; i++) {
			gets(p = buf); getStr(term[i].t); term[i].k = i;
			term[i].s = 3 * getInt(); getInt(); term[i].s += getInt();
		}
		for (i = 0; i < n; i++) {
			k = i;
			for (j = i + 1; j < n; j++) {
				if (term[j].s > term[k].s) k = j;
				else if (term[j].s == term[k].s && term[j].k < term[k].k) k = j;
			}
			if (k != i) {
				strcpy(w, term[k].t), strcpy(term[k].t, term[i].t), strcpy(term[i].t, w);
				j = term[k].k, term[k].k = term[i].k, term[i].k = j;
				j = term[k].s, term[k].s = term[i].s, term[i].s = j;
			}
		}
		if (f) f = 0;
		else putchar('\n');
		for (i = 0; i < n; i++) printf("%s,%d\n", term[i].t, term[i].s);
	}
	return 0;
}

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

int main() {
	while(true){

		vector<vector<int>> m(21);
		for(auto &mm : m){
			mm.resize(21,0);
		}
		
		int N,M;
		cin >> N;
		if(N==0)break;
		for(int i=0;i<N;i++){
			int x,y;
			cin >> x >> y;
			m[x][y]=1;
		}
		
		cin>>M;
		int x=10,y=10;
		for(int i=0;i<M;i++){
			char c;
			int d,dx=0,dy=0;
			cin >> c >> d;
			
			switch(c){
				case 'N':
					dy=1;
					break;
				case 'E':
					dx=1;
					break;
				case 'S':
					dy=-1;
					break;
				case 'W':
					dx=-1;
					break;
			}
			for(int j=0;j<d;j++){
				x+=dx;
				y+=dy;
				if(m[x][y]==1){
					m[x][y]=0;
					N--;
				}
			}
		}
		
		if(N==0){
			cout << "Yes" << endl;
		}else{
			cout << "No" << endl;
		}
		
	}
	return 0;
}

Measured memory_bytes: 1188
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define FOR(i) for(cin>>i;i>0;i--)
#define elif else if
#define pb push_back
#define ll long long
#define mp make_pair
#define all(x) x.begin(),x.end()
#define re(x) {cout<<x<<endl;return 0;}
#define x first
#define y second

using namespace std;
map<int,ll>a;
int n,k[200005];
ll ans=0;
int main()
{
	cin>>n;
	rep(i,n)
	{
		cin>>k[i];
		a[k[i]]++;
	}
	for(map<int,ll>::iterator it=a.begin();it!=a.end();it++) ans+=(it->y-1)*it->y/2;
	rep(i,n) cout<<ans-a[k[i]]+1<<endl;
	return 0;}

Measured memory_bytes: 10240
//IOI 2021
//this will accept, By the order of the peaky fucking blinders
#include <bits/stdc++.h>
using namespace std;

#define pb push_back
#define ff first
#define ss second

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

const int MAXN = 2 * 1000 * 1000 + 17;

ll n, k, ans, a[MAXN], p[MAXN];
map<ll, ll> mp;

int main() {
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> n >> k;
	for (ll i = 1; i <= n; i++)
		cin >> a[i], p[i] = p[i - 1] + a[i];

	if (k == 1) {
		return cout << 0 << endl, 0;
	}
	for (ll i = 1; i <= n; i++)
		p[i] = (p[i] - i + k) % k;
	mp[0]++;
	for (ll i = 1; i <= n; i++) {
		ans += mp[p[i]]++;
		if (i - k + 1 >= 0)
			mp[p[i - k + 1]]--;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 18432
#include<iostream>
#include<cstdio>
#include<cstdlib>
using namespace std;
int n;
long long C;
long long x[100010];
int v[100010];
long long ans;
long long c[100010],cc[100010];
long long cmx[100010],ccmx[100010];
int main()
{
	scanf("%d%lld",&n,&C);
	for(int i=1;i<=n;i++)scanf("%lld%d",x+i,v+i);
	for(int i=1;i<=n;i++)
	{
		c[i]=c[i-1]+v[i]-x[i]+x[i-1];
		cmx[i]=max(cmx[i-1],c[i]);
	}
	x[n+1]=C;
	for(int i=n;i>=1;i--)
	{
		cc[n+1-i]=cc[n-i]+v[i]-x[i+1]+x[i];
		ccmx[n+1-i]=max(ccmx[n-i],cc[n+1-i]); 
	}
	for(int i=0;i<=n;i++)
	{
		ans=max(ans,c[i]-x[i]+ccmx[n-i]);
		ans=max(ans,cc[i]-C+x[n+1-i]+cmx[n-i]);
	}
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 4480
use std::ascii::AsciiExt;

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn main() {
    let s: String = read();
    println!("{}",
        s.chars().map(|c| {
            match c {
                'a'...'z' => {
                    c.to_ascii_uppercase()
                },
                'A'...'Z' => {
                    c.to_ascii_lowercase()
                },
                _ => c
            }
        }).collect::<String>());
}


Measured memory_bytes: 5016
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 1e14;
const int ZERO = 0;
const int MOD = 1000000007;
const double PI = 3.1415926535897;
typedef pair<int,int> P;

int H,W;
int maze[440][440];
int dy[4] = {-1, 1, 0, 0};
int dx[4] = {0, 0, -1, 1};
int ret = 0;
int black = 0;
int white = 0;

void dfs(int a,int b,int c) {
    maze[a][b] = 2;
    if(c == 1) {
        black++;
        for(int i = 0;i < 4;i++) {
            int ny = a + dy[i];
            int nx = b + dx[i];
            if(maze[ny][nx] == 0) {
                dfs(ny, nx, 0);
            }
        }
    }
    else {
        white++;
        for(int i = 0;i < 4;i++) {
            int ny = a + dy[i];
            int nx = b + dx[i];
            if(maze[ny][nx] == 1) {
                dfs(ny, nx, 1);
            }
        }
    }
    return;
}

signed main() {
    cin >> H >> W;
    for(int i = 0;i < H + 2;i++) {
        for(int j = 0;j < W + 2;j++) {
            if(i == 0 || i == H + 1 || j == 0 || j == W + 1) {
                maze[i][j] = 2;
            }
            else {
                char A;
                cin >> A;
                if(A == '#') {
                    maze[i][j] = 1;
                }
                else {
                    maze[i][j] = 0;
                }
            }
        }
    }
    for(int i = 1;i < H + 1;i++) {
        for(int j = 1;j < W + 1;j++) {
            if(maze[i][j] == 1) {
                dfs(i, j, 1);
                ret += black * white;
                black = 0;
                white = 0;
            }
        }
    }
    cout << ret << endl;
}

Measured memory_bytes: 6656
<?php
fscanf(STDIN,"%d%d",$a,$b);
$sum=$a+$b;
if($sum==0){echo '0';exit;}
if($sum%2==1){echo 'IMPOSSIBLE';exit;}
$abs=abs($sum);
$x=$abs/2;
echo ($sum)>0?$x:$x*-1;

Measured memory_bytes: 3700
import java.util.Arrays;
import java.util.Scanner;

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

        for (int i = 0; i < n; i++) {
            p[i] = sc.nextInt();
        }

        int contest = n / 3;
        int no1 = 0;
        int no2 = 0;
        int no3 = 0;

        for (int i = 0; i < n; i++) {
            if (p[i] <= a) {
                no1 = no1 + 1;
            } else if (p[i] <= b) {
                no2 = no2 + 1;
            } else {
                no3 = no3 + 1;
            }
        }
        int m1 = Math.min(no1,no2);
        int m2 = Math.min(no2,no3);

        System.out.println(Math.min(m1,m2));
    }
}











Measured memory_bytes: 23764
N,M = map(int,input().split(" "))
A = []
for i in range(N):
    A.append(list(map(int,input().split(" "))))

ans = float('inf')
sport_num = M
adopt_sports = [1] * M
for it in [0]*M:
    participate_sports = [0] * M
    for n in range(N):
        for m in range(M):
            if adopt_sports[A[n][m]-1] == 1:
                participate_sports[A[n][m]-1] += 1
                break

    max_v = 0
    max_idx = -1
    for m in range(M):
        if participate_sports[m] > max_v:
            max_idx = m
            max_v = participate_sports[m]

    ans = min(max_v,ans)
    adopt_sports[max_idx] = 0

print(ans)


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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const ll INF = 1e9;
const ll MOD = 1e9+7;
const ll LINF = 1e18;

class UnionFind{
private:
  vector<ll> Parent; 
 public:
  UnionFind(ll N){
    Parent = vector<ll>(N, -1);
  }
  
  ll root(ll A){
    if(Parent[A] < 0) return A;
    return Parent[A] = root(Parent[A]);
  }
  
  ll size(ll A){
    return -Parent[root(A)]; 
  }
  
  bool connect(ll A, ll B){
    A = root(A);
    B = root(B);
    if(A == B){
      return false;
    }
    if(size(A) < size(B)) swap(A, B);
    Parent[A] += Parent[B];
    Parent[B] = A;
    return true;
  }
  
  bool isSame(ll A, ll B){
    return root(A) == root(B);
  }
};

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll n,m; cin>>n>>m;
  vpll ab(m);
  rep(i,m){
    ll a,b; cin>>a>>b; a--,b--;
    ab[i]={a,b};
  }
  
  ll ans=0;
  rep(i,m){
    UnionFind uf(n);
    rep(j,m){
      if(i==j) continue;
      uf.connect(ab[j].first, ab[j].second);
    }
    bool ok=false;
    rep(i,n){
      if(!uf.isSame(0,i)) ok=true;
    }
    if(ok) ans++;
  }
  cout<<ans<<endl;
}

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

using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define FILL(a,n,x); REP(i,(n)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define FILL2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define Liny "Yes\n"
#define Linn "No\n"
#define LINY "YES\n"
#define LINN "NO\n"

//cout << setfill('0') << right << setw(4) << 12; // "0012"
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
int __stoi(string s){ return atoi(s.c_str()); }
ll sum(ll a[],ll N){ return accumulate(a,a+N,0LL);}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a/gcd(a,b)*b;}
template<class T> void chmax(T& a, T b){ if(a<b){a=b;} }
template<class T> void chmin(T& a, T b){ if(a>b){a=b;} }
template<class T> bool isIn(T a,vector<T> v){ for(T x:v){ if(a==x){return true;}} return false;}
string strReplace(string s,string target, string replacement){
    if (!target.empty()) {
      std::string::size_type pos = 0;
      while ((pos = s.find(target, pos)) != std::string::npos) {
        s.replace(pos, target.length(), replacement);
        pos += replacement.length();
      }
    }
    return s;
}
const ll MOD = 1e9+7;
#define pii pair<int,int>
#define pll pair<ll,ll>
#define MP make_pair

bool DEBUG = 0;
template<class T> void dprint(T s){
  if(DEBUG){ cout << s << "\n"; }
}

int main(int argc, char *argv[]){
  if(argc>1 && argv[1][0]=='D'){ DEBUG = 1;}

  int N; cin>>N;
  ll a[N]; CINA(a,N);
  sort(a,a+N);
  ll ans = 0LL;
  for(int i=0;i<N;++i){
    for(int j=i+1;j<N;++j){
      for(int k=j+1;k<N;++k){
        if(a[i]==a[j] || a[j]==a[k]){continue;}
        if(a[i]+a[j]>a[k] && a[i]+a[k]>a[j] && a[k]+a[j]>a[i]){
          ++ans;
        }
      }
    }
  }
  cout << ans << "\n";

}

Measured memory_bytes: 3632
N = int(input())
def po(n,k):
    if k <= 0:
        return 0 <= n <= 1
    if k % 2 == 0 and -2*(2**k-1)//3 <= n <= (2**(k+2)-1)//3:
        return True
    elif k % 2 == 1 and -2*(2**(k+1)-1)//3 <= n <= (2**(k+1)-1)//3:
        return True
    return False

def f(n):
    k = 0
    while True:
        if po(n,k):
            break
        k += 1
    ls = []
    while k >= 0:
        if po(n-(-2)**k, k-1):
            n -= (-2)**k
            ls.append("1")
        else:
            ls.append("0")
        k -= 1
    return "".join(ls)
print(f(N))

Measured memory_bytes: 9100
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
int s,w;
cin >> s >> w;

if(w >= s){
 cout << "unsafe" << endl;
}else{
 cout << "safe" << endl;
}

return 0;

}


Measured memory_bytes: 3640
tbl = [[0 for j in range(4)] for i in range(2)]
while True:
    try: p = list(map(float, input().split()))
    except: break
    for i in range(2):
        if p[i] >= 1.1: tbl[i][0] += 1
        elif p[i] >= 0.6: tbl[i][1] += 1
        elif p[i] >= 0.2: tbl[i][2] += 1
        else: tbl[i][3] += 1
for i in range(4):
    print(tbl[0][i], tbl[1][i])


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

using namespace std;

#define INF 100000000
#define YJ 1145141919
#define INF_INT_MAX 2147483647
#define INF_LL 9223372036854775
#define INF_LL_MAX 9223372036854775807
#define EPS 1e-10
#define MOD 1000000007
#define MOD9 998244353
#define Pi acos(-1)
#define LL long long
#define ULL unsigned long long
#define LD long double

#define int long long

using II = pair<int, int>;

int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }
int extgcd(int a, int b, int &x, int &y) { int g = a; x = 1; y = 0; if (b != 0) g = extgcd(b, a % b, y, x), y -= (a / b) * x; return g; }

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(a)  begin((a)), end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())

signed main()
{
  string T; cin >> T;
  REP(t,T.size()) {
    if (T[t] == '?') {
      T[t] = 'D';
    }
  }

  cout << T << endl;

  return 0;
}


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

int main(void){

  int N;
  cin>>N;
  int A[N];
  for(int i=0;i<N;i++)
    cin>> A[i];
  sort(A,A+N);
  for(int i=0;i<N-1;i++){
    if(A[i]==A[i+1]){
      cout<< "NO";
      return 0;
    }
  }
  cout<<"YES";








  return 0;
}


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

#define rep(ver,n) rep2(ver,0,n)
#define rep2(ver,m,n) for(int ver=m;ver<(n);ver++)
#define dup(x,y) (((x)+(y)-1)/(y))
#define all(v) (v).begin(), (v).end()
#define debug(x) std::cerr<<#x<<": "<<x<<"\n"
#define debug2(x,y) std::cerr<<#x<<": "<<x<<", "<<#y<<": "<<y<<"\n"
#define debug3(x,y,z) std::cerr<<#x<<": "<<x<<", "<<#y<<": "<<y<<", "<<#z<<": "<<z<<"\n"

typedef long long ll;

ll nummemo[1000000] = {};
ll AddDiff(int num){
  if(num == 0)return 0;
  if(nummemo[num] == 0){
    nummemo[num] = AddDiff(num - 1) + num;
  }
  return nummemo[num];
}

int main(){
  string s;
  int a[1000000] = {};
  ll ans = 0;
  cin >> s;
  
  int p = 0;
  int num = 0;
  for(int i = 0; i < s.size() - 1; i++){
    a[p]++;
    if(s[i] == s[i + 1]){ }
    else{
      p++;
      num++;
    }
  }
  a[p]++;
  num++;
  
  if(s[0] == '<'){
    for(int i = 0; i < num; i += 2){
      ans += AddDiff(a[i] - 1);
      if(i + 1 < num){
        ans += AddDiff(a[i + 1] - 1);
        ans += max(a[i], a[i + 1]);
      }
      else{
        ans += a[i];
      }
    }
  }
  else{
    ans += AddDiff(a[0]);
    for(int i = 1; i < num; i += 2){
      ans += AddDiff(a[i] - 1);
      if(i + 1 < num){
        ans += AddDiff(a[i + 1] - 1);
        ans += max(a[i], a[i + 1]);
      }
      else{
        ans += a[i];
      }
    }
  }
  
  cout << ans;
  
  return 0;
}


Measured memory_bytes: 16644
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
#include<assert.h>
#include<string>
#include<cstdlib>
#include<cctype>
#include<unordered_map>
#include<sstream>
#include<numeric>
#include<stack>
// #include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
constexpr ll INF = 9e18;
constexpr int inf = 1e9;
const double INFD = 1e100;
const ll mod = 1000000007;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
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;
};

// intやllをstringに変換
template<typename T> inline string toString(const T &a){
  ostringstream oss;
  oss << a;
  return oss.str();
};
// ----------------------------------------------------------------------------

struct UnionFind {
  vector<int> par;
  UnionFind(int n) : par(n,-1) { }
  int root(int x){
    if(par[x] < 0) return x;
    return par[x] = root(par[x]);
  }
  bool issame(int x,int y){
    return root(x) == root(y);
  }
  bool merge(int x,int y){
    x = root(x);
    y = root(y);
    if(x == y) return false;
    if(par[x] > par[y]) swap(x,y);
    par[x] += par[y];
    par[y] = x;
    return true;
  }
  int size(int x){
    return -par[root(x)];
  }
};

int main(){
  ll N,M;
  cin >> N >> M;
  vector<P> p(M);
  for(int i=M-1; i>=0; i--){
    int a,b;
    cin >> a >> b;
    a--;
    b--;
    p[i] = make_pair(a,b);
  }
  UnionFind uf(N);
  vector<ll> ans(M);
  ll sum = (N*(N-1))/2;
  ans[0] = sum;
  for(int i=0; i<M-1; i++){
    int a,b;
    tie(a,b) = p[i];
    if(!uf.issame(a,b)){
      ll res = uf.size(a);
      res *= uf.size(b);
      sum -= res;
      uf.merge(a,b);
    }
    ans[i+1] = sum;
  }
  for(int i=M-1; i>=0; i--){
    cout << ans[i] << endl;
  }
  return 0;
}


Measured memory_bytes: 3328
#include <iostream>
#include <string>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define all(a) (a).begin(), (a).end()

using ll = long long;

constexpr ll mod = 1000000007;
const std::string ABC = "ABC";

std::string S;
ll dp[100010][4];

int main()
{
  std::cin >> S;

  dp[0][0] = 1;

  rep( i, S.size() ) rep( j, 4 )
  {
    bool fl = false;

    if( j < 3 && S[i] == ABC[j] )
      dp[i+1][j+1] = (dp[i+1][j+1] + dp[i][j]) % mod;
    
    if( S[i] == '?' ) rep( k, 3 )
    {
      if( k == j )
        dp[i+1][j+1] = (dp[i+1][j+1] + dp[i][j]) % mod;
      
      dp[i+1][j] = (dp[i+1][j] + dp[i][j]) % mod;
    }
    
    if( S[i] != '?' )
      dp[i+1][j] = (dp[i+1][j] + dp[i][j]) % mod;
  }

  printf( "%lld\n", dp[S.size()][3] );
  
  return 0;
}

Measured memory_bytes: 3584
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<ll> vec;
typedef vector<vec> mat;
int main(){
    int n,A[200001];
    cin>>n;
    rep(i,n) cin>>A[i];
    sort(A,A+n);
    int a=0,b=0,ans=0;
    rep(i,n){
        if(a==A[i]) b++;
        if(a!=A[i]){
            if(b<a) ans+=b;
            else ans+=b-a;
            a=A[i],b=1;
        }
    }
    if(b<a) ans+=b;
    else ans+=b-a;
    cout<<ans;
}


Measured memory_bytes: 640
#include <stdio.h>

int main(void)
{
	char c;
	scanf("%c",&c);
	if(c=='a'||c=='i'||c=='u'||c=='e'||c=='o'){
		printf("vowel\n");
	}
	else{
		printf("consonant\n");
	}
	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
int main(void){
  int i,j;
  int H,W;
  while(scanf("%d %d",&H,&W)){
      if (H==0&&W==0) break;
      for(i=0;i<H;i++){
          for(j=0;j<W;j++){
              putchar('#');
          }
          putchar('\n');
      }
      putchar('\n');
  }
  return 0;
}


Measured memory_bytes: 2064
#include<stdio.h>
int main(void){
  char s[10];
  int x=0,b=0,i;
  scanf("%s",s);
  for(i=0;i<10;i++){
    if(s[i]=='A' || s[i]=='C' || s[i]=='G' || s[i]=='T'){
      x ++;
    }else{
    x = 0;
    }
    if(x > b)
      b = x;
    if(s[i]==NULL)
      break;
  }
  printf("%d",b);
 
  return 0;
}


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

using namespace std;

int g1[81][81];
int g2[81][81];
bool dp[81][81][6560];


int main() {
	int H, W;
	cin>>H>>W;
	for (int i = 0;i < H;++i) {
		for (int j = 0;j < W;++j) {
			cin>>g1[i][j];
		}
	}
	
	for (int i = 0;i < H;++i) {
		for (int j = 0;j < W;++j) {
			cin>>g2[i][j];
		}
	}
	
	dp[0][0][abs(g1[0][0] - g2[0][0])] = true;

	for (int i = 0;i < H;++i) {
		for (int j = 0;j < W;++j) {
			for (int k = 0;k <= 6400;++k) {
				if (dp[i][j][k]) {
					dp[i][j+1][abs(k - abs(g1[i][j+1] - g2[i][j+1]))] = true;
					dp[i][j+1][abs(k + abs(g1[i][j+1] - g2[i][j+1]))] = true;
					dp[i+1][j][abs(k - abs(g1[i+1][j] - g2[i+1][j]))] = true;
					dp[i+1][j][abs(k + abs(g1[i+1][j] - g2[i+1][j]))] = true;
				}
			}
		}
	}
	
	for (int i = 0;i <= 6400;++i) {
		if (dp[H-1][W-1][i]) {
			cout<<i<<endl;
			break;
		}
	}
	
	return 0;
}


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

int main() {

    int a,b,c,d,e,k;
    cin >> a;
    cin >> b;
    cin >> c;
    cin >> d;
    cin >> e;
    cin >> k;

    if( k >= e - a) {
        cout << "Yay!";
    } else {
        cout << ":(";
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using pint = pair<int,  int>;
using pll = pair<ll, ll>;
using edge = pair<int, ll>;
using Graph = vector<vector<int>>; 
using WeightedGraph = vector<vector<edge>>;
const ll INF = 1LL << 60;
const int INF32 = 1 << 29;
const ll MOD = 1000000007;

int main(){
  int x,a,b;
  cin >> x >> a >> b;
  cout << (x-a)%b << endl;
}


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

bool isPrime(int x){
  if(x == 2) return true;
  
  if(x<2 || x%2==0) return false;
  
  int i = 3;
  while(i <= sqrt(x)){
    if(x%i == 0) return false;
    i += 2;
  }
  return true;
}

int main(){
  int n, prime=0, tmp;
  cin >> n;
  for(int i=0; i<n; i++){
    cin >> tmp;
    if(isPrime(tmp)) prime++;
  }
  cout << prime << endl;
  return 0;
}



Measured memory_bytes: 3104
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <complex>
#include <math.h>
using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<long, long> PLL;
typedef long long LL;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(long i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

const long double EPS = 1e-12;
const double INF = 1e12;

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

int main(){
	LL a,b;
	while(cin>>a>>b){
		cout<<gcd(a,b)<<" "<<a*b/gcd(a,b)<<endl;
	}
	return 0;
}

Measured memory_bytes: 1156
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int read()
{
    char ch=getchar();
    int x=0,f=1;
    while(ch<'0' || ch>'9')
    {
        if(ch=='-')
            f=-1;
        ch=getchar();
    }
    while(ch>='0' && ch<='9')
    {
        x=x*10+ch-'0';
        ch=getchar();
    }
    return x*f;
}
int main()
{
    string s;
    cin>>s;
    if(s[2]==s[3]&&s[4]==s[5])
        printf("Yes\n");
    else
        printf("No\n");

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<(int)(n);i++)
constexpr int INF = numeric_limits<int>::max()/2;
constexpr long long LINF = numeric_limits<long long>::max()/3;
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
template<typename T> ostream& operator<<(ostream& os,const set<T>& st){ os<<"{"; for(T v:st) os<<v<<","; os <<"}"; return os; }
template<typename T,typename U> inline void chmax(T &x,U y){ if(y>x) x = y; }
template<typename T,typename U> inline void chmin(T &x,U y){ if(y<x) x = y; }
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
//constexpr double eps = 1e-14; 
constexpr double eps = 1e-10; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

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

    ll ans = LINF;
    for(int i=0;i+K<=N;i++){
        int j = i + K - 1;

        ll L = x[i];
        ll R = x[j];

        if(L >= 0){
            ll sum = R;
            ans = min(ans,sum);
        }else if(R <= 0){
            ll sum = abs(L);
            ans = min(ans,sum);
        }else{
            ll sum = R - L + min(abs(L),abs(R));
            ans = min(ans,sum);
        }
    }
    cout << ans << endl;
}


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

#define NDEBUG
#include <cassert>


typedef long long ll;
typedef long double Double;
typedef unsigned long long ull;
typedef pair<int,int> ii;
typedef pair<ll,ll> llll;
typedef pair<double,double> dd;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ii> vii;
typedef vector<vector<ii>> vvii;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<long double> vD;

#define sz(a)  int((a).size())
#define pb  push_back
#define eb  emplace_back
#define FOR(var,from,to) for(int var=(from);var<=(to);++var)
#define rep(var,n)  for(int var=0;var<(n);++var)
#define rep1(var,n)  for(int var=1;var<=(n);++var)
#define repC2(vari,varj,n)  for(int vari=0;vari<(n)-1;++vari)for(int varj=vari+1;varj<(n);++varj)
#define ALL(c)  (c).begin(),(c).end()
#define RALL(c)  (c).rbegin(),(c).rend()
#define tr(i,c)  for(auto i=(c).begin(); i!=(c).end(); ++i)
#define found(s,e)  ((s).find(e)!=(s).end())
#define mset(arr,val)  memset(arr,val,sizeof(arr))
#define mid(x,y) ((x)+((y)-(x))/2)
#define IN(x,a,b) ((a)<=(x)&&(x)<=(b))
#define cons make_pair

#define PQ(T) priority_queue<T>
#define RPQ(T) priority_queue<T,vector<T>,greater<T>>

template<class T> inline void amin(T & a, T const & b) { a = min(a, b); }
template<class T> inline void amax(T & a, T const & b) { a = max(a, b); }

inline ll square(ll x) { return x * x; }
inline ll gcd(ll a, ll b) { while(a) swap(a, b%=a); return b; }
template <typename T>
inline T mod(T a, T b) { return ((a % b) + b) % b; }


const ll MOD=1000000007LL;

ll ADD(ll x, ll y) { return (x+y) % MOD; }
ll SUB(ll x, ll y) { return (x-y+MOD) % MOD; }
ll MUL(ll x, ll y) { return x*y % MOD; }
ll POW(ll x, ll e) { ll v=1; for(; e; x=MUL(x,x), e>>=1) if (e&1) v = MUL(v,x); return v; }
ll DIV(ll x, ll y) { /*assert(y%MOD!=0);*/ return MUL(x, POW(y, MOD-2)); }

#define INTSPACE 12
char _buf[INTSPACE*1000000 + 3];




int solve(int N, vs& s) {
    int ba=0, xa=0, bx=0;

    int cnt = 0;
    rep(i,N){
        int L=s[i].size();
        for (int c=0; c<L-1; ++c) {
            if (s[i][c]=='A' && s[i][c+1]=='B') ++cnt;
        }
        if (s[i][0]=='B' && s[i][L-1]=='A') ba++;
        else if (s[i][0]=='B') ++bx;
        else if (s[i][L-1]=='A') ++xa;
    }

    if (ba > 1) { cnt += (ba-1); ba = 1; }

    int u = min(xa, bx);
    if (ba) {
        if (u) {
            ++cnt;
            cnt += u;
        } else {
            if (xa || bx) ++cnt;
        }
    } else {
        cnt += u;
    }

    return cnt;
}

int main() {
    int N; cin >> N;
    vs s(N);
    rep(i,N) cin >> s[i];
    cout << solve(N,s) << endl;
    return 0;
}


Measured memory_bytes: 768
<?php

$n = trim(fgets(STDIN));
$h = explode(" ", trim(fgets(STDIN)));
// echo "t";

$i = 0;
$c = 0;
$max = 0;
while(true){
    // echo "c=0";
    $c = 0;
    while(true){
        if( !isset($h[($i + 1)] )) break;
        // echo $h[$i]." == ". $h[($i+1)]. "\n";
        if($h[$i] >= $h[($i+1)]){
            // echo "c++". "\n";
            $c++;
            $i++;
        }else{
            $i++;
            break;
        }
        // echo $i;
    }
    // echo "c = $c \n";
    if($max < $c) $max = $c;
    // $i += $c;
    // echo "step3 i=$i \n";
    if( !isset($h[($i + 1)] ) ) break;
}

echo $max."\n";

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

#define ntest 0

using namespace std;
int n;
int a[105];
long long res;
int ok(int x, int y, int z) {
    return (x + y > z && x + z > y && y + z > x);
}
int cal(int x, int y, int z) {
    return (x != z && x != y && y != z);
}
void solve() {
    cin >> n;
    for (int i = 1; i <= n; ++i) cin >> a[i];
    for (int i = 1; i <= n - 2; ++i)
        for (int j = i + 1; j <= n - 1; ++j)
        for (int k = j + 1; k <= n; ++k) if (ok(a[i],a[j], a[k])) res += cal(a[i], a[j], a[k]);
    cout << res;
}
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    if(ntest){
        int t;
        cin >> t;
        while(t--) solve();
    } else {
        solve();
    }

}




Measured memory_bytes: 3664
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
typedef vector<double> VD;
typedef vector<VD> VVD;

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

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

struct SegmentTree{
    const int INF = 1e9;
    int n, width;
    VI dat;

    void init(int x){
        n = x;
        width = 1;
        while (width < n) width *= 2;
        dat.resize(2*width-1);
        REP(i,2*width-1) dat[i] = INF;
    }

    void update(int i, int x){
        i += width - 1;
        chmin(dat[i], x);
        // dat[i] = x;
        while (i > 0){
            i = (i - 1) / 2;
            dat[i] = min(dat[i*2+1], dat[i*2+2]);
        }
    }

    int query(int a, int b, int k, int l, int r){
        if (r <= a || b <= l) return INF;
        if (a <= l && r <= b) return dat[k];
        int vl = query(a, b, k*2+1, l, (l+r)/2);
        int vr = query(a, b, k*2+2, (l+r)/2, r);
        return min(vl, vr);
    }

    // [l, r)
    int query(int l, int r){
        return query(l, r, 0, 0, width);
    }
};

int main() {
    int n;
    cin >> n;
    VI a(n), s0(n + 1), s1(n + 1);
    REP(i,n){
        a[i] = in();
        s0[i + 1] = s0[i] + (a[i] == 0);
        s1[i + 1] = s1[i] + (a[i] == 1);
    }
    int q;
    cin >> q;
    VVI r(n);
    REP(i,q){
        int x = in() - 1, y = in();
        r[x].push_back(y);
    }

    SegmentTree seg0, seg1;
    seg0.init(n + 1);
    seg1.init(n + 1);
    seg0.update(0, 0);
    seg1.update(0, 0);

    REP(i,n){
        for (int x : r[i]){
            int d = min(
                seg0.query(0, i) + s1[i] + s0[x] - s0[i],
                seg1.query(i, x) + s0[x]
            );
            seg0.update(x, d - s1[x]);
            seg1.update(x, d - s0[x]);
        }
    }

    int ans = seg0.query(0, n + 1) + s1[n];
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 15360
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>

using namespace std;

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

    int a[200];

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

    int count = 0;

    while (true) {
        int flg = 0;

        for (int i = 0; i < n; i++) {
            if (a[i] % 2 == 1) {
                flg = 1;
            }
            else {
                a[i] = a[i] / 2;
            }
        }

        if (flg == 1) break;

        count += 1;
    }

    cout << count << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

using namespace std;

#define int long long int
#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) (x).begin(), (x).end()
#define capi(x) int x;cin>>x

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

signed main() {
    capi(k);

    int r = 7;
    rep(i, k) {
        r %= k;
        if (r == 0) {
            cout << i + 1;
            return 0;
        }
        r *= 10;
        r += 7;
    }

    cout << -1;

    return 0;
}

Measured memory_bytes: 3192
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9+7;
int main() {
    ll n;
    cin >> n;
    vector<pair<ll,ll>>x(n);
    for(ll i=0;i<n;i++){
        ll a,b;
        cin >> a >> b;
        x[i]={a+b,a-b};
    }
    ll ans=0;
    ll cur=-MOD;
    sort(x.begin(),x.end());
    for(ll i=0;i<n;i++){
        if(cur<=x[i].second){
            ans++;
            cur=x[i].first;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 4828