akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <iostream>
#include <array>
#include <vector>
#include <deque>
#include <string>
#include <algorithm>
#include <functional>
#include <tuple>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <stack>
#include <utility>
#include <memory>
#include <valarray>
#include <climits>

using namespace std;

using ll = long long int;

#define REP(i, N) for (int i = 0; i < (N); ++i)
#define scanInt(x) int x; scanf("%d", &(x)); getchar();
#define scanLLInt(x) ll x; scanf("%lld", &(x)); getchar();
#define scanVecInt(A, N) vector<int> A(N); loop(i, N){scanf("%d", &(A[i])); getchar();}
#define scanVecLLInt(A, N) vector<ll> A(N); loop(i, N){scanf("%lld", &(A[i])); getchar();}

int main()
{
    scanInt(N); // 頂点の数
    scanInt(M); // 辺の数
    vector<unordered_map<int, ll>> edges(N); // 各頂点から出る辺
    vector<pair<int, int>> edges2;
    REP(i, M){ // 辺の数はM
        scanInt(ai); --ai;
        scanInt(bi); --bi;
        // scanInt(ci); // 辺の長さ
        edges[ai].emplace(bi, 1);
        edges[bi].emplace(ai, 1);
        edges2.emplace_back(ai, bi);
    }
    struct Node {
        int parent = -1; // 親ノードのi
        ll distance = -1; // 根からの距離
        vector<int> children; // 子ノード（複数）のi
    };
    int result = 0;
    REP(m, M){
        const int ai = get<0>(edges2[m]);
        const int bi = get<1>(edges2[m]);
        edges[ai].erase(bi);
        edges[bi].erase(ai);
        vector<Node> nodes(N); // 各ノード（木構造）
        function<void(int, ll)> makeTree = [&](int n, ll dist){ // 頂点n以下の木構造を作る
            nodes[n].distance = dist;
            for (auto& e : edges[n]){
                auto& next = e.first;
                if (next == nodes[n].parent) continue; // 親に戻らない
                if (nodes[next].distance != -1 || 0 < nodes[next].children.size()) continue; // 余分な辺がある場合は、既に訪れた頂点を弾く処理をする
                nodes[n].children.emplace_back(next);
                nodes[next].parent = n;
                makeTree(next, dist + e.second);
            }
        };
        const int R = 0;
        nodes[R].parent = -1; // 根の親は適当に入れておく
        makeTree(R, 0); // 根（距離0）から始める
        bool flag = false;
        REP(n, N){
            if (nodes[n].distance == -1){
                flag = true;
                break;
            }
        }
        if (flag) ++result;
        edges[ai].emplace(bi, 1);
        edges[bi].emplace(ai, 1);
    }
    printf("%d\n", result);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int x[2][100];
int main()
{
	int n,i,j,t,s,max;
	scanf("%d",&n);
	for(i=0;i<2;i++)
	{
		for(j=0;j<n;j++)
		{
			scanf("%d",&x[i][j]);
		}
	}
	max=x[0][0];
	for(i=0;i<n;i++)
	{
		max+=x[1][i];
	}
	for(i=1;i<n;i++)
	{
		t=0;
		s=0;
		for(j=0;j<n;j++)
		{
			s+=x[t][j];
			if(j==i)
			{
				t++;
				s+=x[t][j];
				
			}
		}
		if(s>max)
		{
			max=s;
		}
	}
	printf("%d",max);
	return 0;
}

Measured memory_bytes: 256
def wczytaj_liste(): 
    wczytana_lista = input()
    lista_znakow = wczytana_lista.split()
    ostateczna_lista = []
    for element in lista_znakow:
        ostateczna_lista.append(int(element))
    return ostateczna_lista 

def BFS(dziecko, listy_znajomosci): 
    do_przejrzenia = [dziecko]
    odleglosc = {dziecko:0}
    nr_przegladanego = 0 
    while nr_przegladanego < len(do_przejrzenia): 
        aktualnie_przegladany = do_przejrzenia[nr_przegladanego]
        for kumpel in listy_znajomosci[aktualnie_przegladany]: 
            if kumpel not in odleglosc: 
                do_przejrzenia.append(kumpel)
                odleglosc[kumpel] = odleglosc[aktualnie_przegladany] + 1 
        nr_przegladanego +=1
    return max(odleglosc.values())

def labirynt(): 
    H, W = wczytaj_liste()
    labirynt = []
    for i in range(H): 
        rzadek = [x for x in (input() + '#')]
        labirynt.append(rzadek)
    labirynt.append(['#']*W)
    lista_krawedzi = []
    for i in range(H):
        for j in range(W):
            if labirynt[i][j] == '.':
                if labirynt[i+1][j] == '.':
                    lista_krawedzi.append(((i,j),(i+1,j)))
                if labirynt[i][j+1] == '.':
                    lista_krawedzi.append(((i,j),(i,j+1)))
    listy_krawedzi = {}
    for x, y in lista_krawedzi:
        listy_krawedzi[x] = []
        listy_krawedzi[y] = []
    for x, y in lista_krawedzi:  
        listy_krawedzi[x].append(y)
        listy_krawedzi[y].append(x)
    maksymalny = 0
    for i in range(H):
        for j in range(W):
            if labirynt[i][j] == '.':
                kandydat = BFS((i,j),listy_krawedzi)
                if kandydat > maksymalny: 
                    maksymalny = kandydat
    print(maksymalny)

labirynt()

Measured memory_bytes: 41708
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <array>
#include <algorithm>
#include <utility>
#include <numeric>
#include <deque>
#include <stack>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cmath>
#include <limits>
#include <cassert>

#define for0(i, N)    for (int i = 0  ; i <  (N); ++i)
#define for1n(i, N)   for (int i = 1  ; i <= (N); ++i)
#define for1(i, N)    for (int i = 1  ; i <  (N); ++i)
#define forn(i, N)    for (int i = 0  ; i <= (N); ++i)
#define forx(i, N, x) for (int i = (x); i <  (N); ++i)
#define forl(i, N, x, a) for (int i = (x), a = 0; a < (N);  \
                              i = (i + 1) % (N), ++a)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef priority_queue<ll> pq;
typedef priority_queue<ll,vector<ll>, greater<ll>> pql;
typedef stack<ll> stk;
typedef queue<ll> qu;
typedef pair<ll, ll> pll;
typedef map<ll, ll> mll;
typedef unordered_map<ll, ll> umll;
typedef set<ll> sll;
typedef unordered_set<ll> usll;


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

    int n;
    string s;

    cin >> n >> s;

    for (auto c : s) {
        cout << (char)(c + n > 'Z' ? c + n - 'Z' + 'A' - 1 : c + n);
    }


    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n, count=0;
    string s;
    
    cin >> n >> s;
    
    for(int i=0; i<n; i++){
        
        if (1 < i) {
            
            if (s[i] == 'C' && s[i-1] == 'B' && s[i-2] == 'A') {
                count++;
            }
        }
    }
    
    cout << count << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
//using System.Linq;
using System.Diagnostics;

class Program
{
    static void Main(string[] args)
    {
        const long MOD = 1000000007;
        var sc = new Scanner();
        int n = sc.nextInt();
        int d = sc.nextInt();

        Console.WriteLine((int)Math.Ceiling((decimal)n / (2 * d + 1)));
    }
}

// chokudai's Scanner
class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }

    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }

    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}

Measured memory_bytes: 11092
alphabet = {0:"a",1:"b",2:"c",3:"d",4:"e",5:"f",6:"g",7:"h",8:"i",9:"j",10:"k",11:"l",12:"m",13:"n",14:"o",15:"p",16:"q",17:"r",18:"s",19:"t",20:"u",21:"v",22:"w",23:"x",24:"y",25:"z"}
N = int(input())
name = ""
while N != 0:
     index= int(N%26)
     if index == 0:
         name += alphabet[25]
     else:
         name += alphabet[index-1]
     N = int((N-1)/26)
print(name[::-1])


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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod = int(1e9)+7;
using V = vector<ll>;
using P = pair<ll,ll>;


int main(){
   string s;cin >>s;
   int ans=0;
    for (int i = 0; i < 6; ++i) {
        if(s[i]=='1')ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
from sys import exit, setrecursionlimit
from functools import reduce
from itertools import *
from collections import defaultdict
from bisect import bisect

def read():
  return int(input())

def reads():
  return [int(x) for x in input().split()]

class union_find:
  def __init__(self, n): self.par = [-1]*n
  def __repr__(self): return "union_find({0})".format(self.par)
  def unite(self, x, y):
    if self.root(x) != self.root(y):
      self.par[self.root(x)] = y
  def root(self, x):
    if self.par[x] == -1: return x
    else:
      self.par[x] = self.root(self.par[x])
      return self.par[x]
  def same(self, x, y): return self.root(x) == self.root(y)

setrecursionlimit(1000000)

(N, K, L) = reads()

rail = union_find(N)
road = union_find(N)

for _ in range(K):
  (p, q) = reads()
  (p, q) = (p-1, q-1)
  road.unite(p, q)

for _ in range(L):
  (p, q) = reads()
  (p, q) = (p-1, q-1)
  rail.unite(p, q)

d = defaultdict(int)
for i in range(N):
  d[road.root(i), rail.root(i)] += 1


results = (d[road.root(i), rail.root(i)] for i in range(N))
print(" ".join(str(n) for n in results))


Measured memory_bytes: 48844
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<math.h>
#include<string>
#include <iomanip>
#include<deque>
#include<queue>
#include<stack>
#include<set>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
const ll LINF = 1e18;
const int INF = 1e8;

//マクロ定義
#define vvint(vec,n,m,l) vector<vector<int>> vec(n, vector<int>(m,l));	// lで初期化
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>
#define pint pair<int,int>
#define rep(i,a) for(int i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()
#define debug system("pause")				//デバッグ用
#define ret return 0

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


int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	ll n, m;
	cin >> n >> m;

	vector<pair<pair<ll,ll>,ll>> p(m);
	rep(i, m)
	{
		cin >> p[i].first.first >> p[i].first.second;
		p[i].second = i;
	}
	vector<pair<ll, ll>> ans(m);

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

	ans[p[0].second].first = p[0].first.first;
	ans[p[0].second].second = 1;

	for (int i = 1; i < m; i++)
	{
		if (p[i].first.first == p[i - 1].first.first)
		{
			ans[p[i].second].first = p[i].first.first;
			ans[p[i].second].second = ans[p[i - 1].second].second + 1;
		}
		else
		{
			ans[p[i].second].first = p[i].first.first;
			ans[p[i].second].second = 1;
		}
	}
	rep(i, m)
	{
		cout << setfill('0') << right << setw(6) << ans[i].first;
		cout << setfill('0') << right << setw(6) << ans[i].second << endl;
	}



	return 0;
}

Measured memory_bytes: 5504
import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        char[] n = sc.next().toCharArray();
        char[] n2 = sc.next().toCharArray();

        if(n[0]<n2[0]){
        System.out.println("<");
        }
        if(n[0]==n2[0]){
            System.out.println("=");
        }
        if(n[0]>n2[0]){
            System.out.println(">");
        }
        

    }

}


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

const int N = 1e5;
struct Edge
{
	int nxt,v;
} e[(N<<1)+3];
int fe[N+3];
int fa[N+3];
bool vis[N+3];
int dep[N+3];
int a[N+3];
int s[N+3];
vector<int> vec;
int n,m,en,au,av,sum;
llong ans;

int absl(int x) {return x<0?-x:x;}

void addedge(int u,int v)
{
	en++; e[en].v = v;
	e[en].nxt = fe[u]; fe[u] = en;
}

void dfs(int u,int prv)
{
	a[u] = dep[u]&1?-1:1; sum += a[u]; s[u] = a[u];
	vis[u] = true;
	for(int i=fe[u]; i; i=e[i].nxt)
	{
		int v = e[i].v;
		if(v==prv) continue;
		if(vis[v])
		{
			au = u,av = v;
		}
		else
		{
			dep[v] = dep[u]+1;
			fa[v] = u;
			dfs(v,u);
			s[u] += s[v];
		}
	}
}

void dfs2(int u,int prv)
{
	s[u] = a[u];
	vis[u] = true;
	for(int i=fe[u]; i; i=e[i].nxt)
	{
		int v = e[i].v;
		if(v==prv) continue;
		if(vis[v])
		{
			au = u,av = v;
		}
		else
		{
			dep[v] = dep[u]+1;
			dfs2(v,u);
			s[u] += s[v];
		}
	}
}

int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1; i<=m; i++)
	{
		int u,v; scanf("%d%d",&u,&v);
		addedge(u,v); addedge(v,u);
	}
	sum = 0; dep[1] = 0; dfs(1,0);
	if(m==n-1)
	{
		if(sum) {puts("-1");}
		else
		{
			ans = 0ll;
			for(int i=1; i<=n; i++)
			{
				ans += absl(s[i]);
			}
			printf("%lld\n",ans);
		}
	}
	else if(m==n)
	{
		if(dep[au]>dep[av]) swap(au,av);
		if((dep[au]^dep[av])&1)
		{
			if(sum) {puts("-1");}
			else
			{
				vec.clear();
				int v = av;
				while(dep[v]>dep[au])
				{
					vec.push_back(-s[v]);
					v = fa[v];
				}
				sort(vec.begin(),vec.end());
				int x = vec[vec.size()>>1];
				a[au] -= x; a[av] += x;
				for(int i=1; i<=n; i++) vis[i] = 0;
				dfs2(1,0);
				ans = absl(x);
				for(int i=1; i<=n; i++)
					{
					ans += absl(s[i]);
				}
				printf("%lld\n",ans);
			}
		}
		else
		{
			if(absl(sum)&1) {puts("-1");}
			else
			{
				if(sum>0)
				{
					for(int i=1; i<=n; i++) s[i] = -s[i],a[i] = -a[i];
					sum = -sum;
				}
				int x = (-sum)>>1;
				a[au] += x; a[av] += x;
				for(int i=1; i<=n; i++) vis[i] = 0;
				dfs2(1,0);
				ans = x;
				for(int i=1; i<=n; i++)
				{
					ans += absl(s[i]);
				}
				printf("%lld\n",ans);
			}
		}
	}
	for(int i=1; i<=n; i++) fe[i] = vis[i] = fa[i] = 0;
	for(int i=1; i<=en; i++) e[i].v = e[i].nxt = 0;
	en = 0;
	return 0;
}

Measured memory_bytes: 9212
//{
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<ll,ll> ii;
#define REP(i,n) for(ll i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define FILL(i,n) memset(i,n,sizeof i)
#define X first
#define Y second
#define SZ(_a) (int)_a.size()
#define ALL(_a) _a.begin(),_a.end()
#define pb push_back
#ifdef brian
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<" ,";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // brian
//}


const ll MAXn=2e5+5,MAXlg=__lg(MAXn)+2;
const ll MOD=1000000007;
const ll INF=ll(1e15);

ll n, d[MAXn];

bool chk(ll k)
{
    vector<ii> stk;
    REP1(i,n-1)
    {
        if(d[i] > d[i-1])continue;
        if(k == 1)return 0;
        while(SZ(stk) && stk.back().X > d[i])stk.pop_back();
        ll it = d[i];
        while(1)
        {
            if(it == 0)return 0;
            if(SZ(stk) && stk.back().X == it)
            {
                if(stk.back().Y == k-1)
                {
                    it--;
                    stk.pop_back();
                    continue;
                }
                else stk.back().Y++;
            }
            else stk.pb(ii(it, 1));
            break;
        }
        //debug(i, stk);
    }
    return 1;
}

int main()
{
    IOS();
    cin>>n;
    REP(i,n)cin>>d[i];
    ll l = 0, r = n;
    while(l != r-1)
    {
        ll h = (l+r)/2;
        if(chk(h))r = h;
        else l = h;
    }
    cout<<r<<endl;
}


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

public class Hello
{
    private const int MOD_N = 1000000000 + 7;

    public static void Main()
    {
        var list = Console.ReadLine().Split(' ');

        var a = long.Parse(list[0]);
        var b = long.Parse(list[1]);

        if (a > b)
            Swap(ref a, ref b);

        long rem;
        var c = Math.DivRem(a + b, 2, out rem);

        Console.WriteLine(rem == 0 ? c.ToString() : "IMPOSSIBLE");
    }

    private static int GCD(int a, int b) => a > b ? GCD_impl(a, b) : GCD_impl(b, a);
    private static int GCD_impl(int a, int b) => b == 0 ? a : GCD_impl(b, a % b);
    private static long LCM(int a, int b) => (long)a * b / GCD(a, b);

    private static int Comb(int m, int n)
    {
        var t = m - n;
        if (n > t)
            n = t;

        long numerator = 1;
        for (int i = 0; i < n; ++i)
        {
            numerator *= m - i;
            numerator %= MOD_N;
        }
        long denominator = 1;
        for (; n != 0; --n)
        {
            denominator *= n;
            denominator %= MOD_N;
        }

        var inv_denominator = ModInv((int)denominator, MOD_N);
        var ret = (int)(numerator * inv_denominator % MOD_N);

        return ret >= 0 ? ret : ret + MOD_N;
    }

    private static int ModInv(int a, int m)
    {
        int b = m, x = 1, y = 0;
        while (b != 0)
        {
            var t = a / b;
            a -= t * b;
            Swap(ref a, ref b);
            x -= t * y;
            Swap(ref x, ref y);
        }
        x %= m;
        return x >= 0 ? x : x + m;
    }

    private static void Swap<T>(ref T a, ref T b)
    {
        var t = a;
        a = b;
        b = t;
    }
}


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

int N;
set<int> S;

int main(void) {
	cin >> N;

	S.clear();
	for (int i = 0; i < N; ++i) {
		int a;
		cin >> a;
		set<int>::iterator it = S.find(a);
		if (it != S.end())
			S.erase(a);
		else
			S.insert(a);
	}

	int ans = S.size();
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 4864
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var lines = input.split('\n');
var n = lines[0];

var A = lines[1].split(' ').map(function(i) {
	return i - 0;
});

var cnt = 0;
for (var i = 0; i < n; i++) {
	for (var j = n - 1; j > i; j--) {
		if (A[j] < A[j - 1]) {
			var tmp = A[j];
			A[j] = A[j - 1];
			A[j - 1] = tmp;

			cnt++;
		}
	}
}  

console.log(A.join(' '));
console.log(cnt);

Measured memory_bytes: 7904
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric, std.container, std.range;

void main()
{
    auto N = readln.chomp.to!int;
    auto cs = readln.chomp.to!(char[]);

    int c;
    int i, j = N-1;
    while (i < j) {
        while (i < N && cs[i] != 'W') ++i;
        while (j >= 0 && cs[j] != 'R') --j;
        if (i < j && j < N) {
            ++c;
            ++i;
            --j;
        }
    }
    writeln(c);
}

Measured memory_bytes: 3052
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
 
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
 
using namespace std;
 
 
int inputValue(){
    int a;
    cin >> a;
    return a;
};
 
void inputArray(int * p, int a){
    rep(i, a){
        cin >> p[i];
    }
};
 
void inputVector(vector<int> * p, int a){
    rep(i, a){
        int input;
        cin >> input;
        p -> push_back(input);
    }
}
 
template <typename T>
void output(T a, int precision) {
    if(precision > 0){
        cout << setprecision(precision)  << a << "\n";
    }
    else{
        cout << a << "\n";
    }
}
 
int main(int argc, const char * argv[]) {
    char s[5];
    scanf("%s",s);
    
    if(s[0] == s[1] && s[1] == s[2] or s[1] == s[2] && s[2] == s[3]){
        puts("Yes");
    }else{
        puts("No");
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,m,d;
    double a;
    cin>>n>>m>>d;
    a=(double)(n-d)*(m-1)/n/n;
    if(d) a*=2;
    printf("%6lf\n",a);
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      	String S = sc.next();
      	if(S.equals("ABC")){
        	System.out.println("ARC");
        }else{
        	System.out.println("ABC");
        }
    }
}

Measured memory_bytes: 26960
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (int i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define pb push_back
using ll = long long;
using vin=vector<int>;
using vll=vector<ll>;
using vst=vector<string>;
using P = pair<ll,ll>;
const int inf=1e9+7;
const ll INF=9e18;
template <typename T> bool chmin(T &a, const T& b){if(a > b){a = b;return true;}return false;}
template <typename T> bool chmax(T &a, const T& b){if(a < b){a = b;return true;}return false;}
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };

int main(){cout<<fixed<<setprecision(20);
		   ll n,t;
           cin>>n>>t;
           vll a(n);
           rep(i,0,n)cin>>a[i];
           int ans=0;
           ll mn=inf;
           ll mx=-1;
           rep(i,0,n){
             if(a[i]<mn)mn=a[i]; 
             /////////
             if(a[i]-mn==mx)ans++;
             else if(chmax(mx,a[i]-mn))ans=1;
           }
           cout<<ans<<endl;
}

Measured memory_bytes: 4028
#include<bits/stdc++.h>
#define fastio 	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long int
using namespace std;
int mod = 1e9 + 7;

vector<int> parent;
vector<int> rnk;
int Find(int i) {
	if (i == parent[i])
		return i;
	return parent[i] = Find(parent[i]);
}

void Union(int a, int b) {
	a = Find(a);
	b = Find(b);
	if (a == b)
		return;
	else {
		if (rnk[a] > rnk[b]) {
			parent[b] = a;
			rnk[a] += rnk[b];
		} else {
			parent[a] = b;
			rnk[b] += rnk[a];
		}
	}
}

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

	int n, m;
	cin >> n >> m;
	parent.resize(n + 1);
	rnk.resize(n + 1, 1);
	for (int i = 1; i <= n; i++)
		parent[i] = i;
	int a, b;
	for (int i = 0; i < m; i++) {
		cin >> a >> b;
		Union(a, b);
	}
	int max_size = 0;
	for (int i = 1; i <= n; i++)
		max_size = max(max_size, rnk[i]);
	cout << max_size;
	return 0;
}

Measured memory_bytes: 6328
#include <bits/stdc++.h>
using ll=long long;
using namespace std;
#define rep_i(i, n) for (int i = 0; i < (n); ++i)
#define rep_ll(i, n) for (long long i = 0; i < (n); ++i)
#define r_rep_i(i, start, end) for (int i = (start); i < (end); ++i)
#define r_rep_ll(i, start, end) for (long long i = (start); i < (end); ++i)
#define debug_vi(v) copy((v).begin(), (v).end(), ostream_iterator<int>(cout, " "));
#define debug_vll(v) copy((v).begin(), (v).end(), ostream_iterator<long long>(cout, " "));
#define debug_vd(v) copy((v).begin(), (v).end(), ostream_iterator<double>(cout, " "));
#define sort_v(v) sort((v).begin(), (v).end()); //昇順
#define d_sort_vi(v) sort((v).begin(), (v).end(), greater<int>()); //降
#define d_sort_vd(v) sort((v).begin(), (v).end(), greater<double>()); //昇順
#define say(t) cout << (t) << endl;
#define sum_vi(v) accumulate((v).begin(), (v).end(), 0);
#define sum_vll(v)accumulate((v).begin(), (v).end(), 0LL);

ll gcd(ll a, ll b) { return b?gcd(b, a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a, b)*b;}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  char hoge; cin >> hoge;
  vector<char> alphabet(26);
  iota(alphabet.begin(), alphabet.end(), 'a');
  for (int i = 0; i <= 25; i++){
    if(hoge == alphabet[i]){
      cout << alphabet[i + 1] << endl;
      return 0;
    }
  }
  

  // for (const auto& i : alphabet)
  // {
  //     std::cout << i << std::endl;
  // }
  // return 0;
}

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

vector<string> s;

void f(queue<int> &que, vector<vector<int>> &ans){
  if(que.empty()) return;
  int x = que.front();
  que.pop();
  if(x == (int)ans.size()-1){
    ans[ans.size()-1] = ans[ans.size()-2];
    return;
  }
  if(x != 0 && ans[x-1][0] != -1) ans[x] = ans[x-1];
  else if(que.front() == x+1){
    f(que, ans);
    ans[x] = ans[x+1];
  }
  else ans[x] = ans[x+1];
  if(!que.empty()) f(que, ans);
  return;
}

int main(){
  int h, w, k;
  cin >> h >> w >> k;
  s.resize(h);
  for(int i=0; i<h; ++i) cin >> s[i];
  vector<vector<int>> ans(h,vector<int>(w,-1));
  int g = 1;
  for(int i=0; i<h; ++i){
    for(int j=0; j<w; ++j){
      if(s[i][j] == '#'){
        ans[i][j] = g;
        for(int k=j-1; k>=0; --k){
          if(s[i][k] == '#') break;
          ans[i][k] = g;
        }
        for(int k=j+1; k<w; ++k){
          if(s[i][k] == '#') break;
          ans[i][k] = g;
        }
        ++g;
      }
    }
  }
  queue<int> que;
  for(int i=0; i<h; ++i){
    if(ans[i][0] == -1) que.push(i);
  }
  f(que, ans);
  for(int i=0; i<h; ++i) for(int j=0; j<w; ++j){
    if(j != w-1) cout << ans[i][j] << " ";
    else cout << ans[i][j] << endl;
  }
}

Measured memory_bytes: 4156
#include <iostream>
#include <cstdio>
#include <algorithm>

using namespace std;

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)

typedef long long ll;

int n, x;
int a[100000];


int main() {
	cin >> n >> x;
	
	ll ans = 0;
	REP(i, n) {
		scanf("%d", &a[i]);
		if (a[i] > x) ans += a[i] - x;
		a[i] = min(a[i], x);
	}
	
	REP(i, n - 1) {
		int sum = a[i] + a[i + 1];
		if (sum > x) {
			int tmp = sum - x;
			a[i + 1] = max(0, a[i + 1] - tmp);
			ans += tmp;
		}
	}
	
	cout << ans << endl;
	
	return 0;
}


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

using ll = long long;
#define repi(n) for (int i = 0; i < n; i++)
#define repj(n) for (int j = 0; j < n; j++)
#define repk(n) for (int k = 0; j < n; k++)
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, a, b) for (auto i = a; i < b; i++)
#define repv(itr) for (auto&& v : itr)
const int dx[] = {-1, 0, 0, 1, -1, -1, 1, 1};
const int dy[] = {0, -1, 1, 0, -1, 1, -1, 1};
template <typename T>
T minptr(T begin, T end) {
  T re = begin;
  for (T i = begin + 1; i != end; i++) {
    if (*i < *re) re = i;
  }
  return re;
}
template <typename T>
T maxptr(T begin, T end) {
  T re = begin;
  for (T i = begin + 1; i != end; i++) {
    if (*i > *re) re = i;
  }
  return re;
}
int __vmax(int x) {
  return INT_MAX;
}
double __vmax(double x) {
  return 1e+300;
}
ll __vmax(ll x) {
  return LLONG_MAX;
}
int __vmin(int x) {
  return INT_MIN;
}
double __vmin(double x) {
  return -1e+300;
}
ll __vmin(ll x) {
  return LLONG_MIN;
}
template <typename T>
vector<T> lis(T begin, T end, bool allowequal = false, bool lds = false) {
  using V = typename iterator_traits<T>::value_type;
  int n = end - begin;
  vector<V> a(n, lds ? __vmin(*begin) : __vmax(*begin));
  vector<int> id(n);
  if (lds && allowequal) {
    for (int i = 0; i < n; i++) {
      id[i] = n - 1 -
              (lower_bound(a.rbegin(), a.rend(), begin[i]) - 1 - a.rbegin());
      a[id[i]] = begin[i];
    }
  } else if (lds) {
    for (int i = 0; i < n; i++) {
      id[i] = n - 1 -
              (upper_bound(a.rbegin(), a.rend(), begin[i]) - 1 - a.rbegin());
      a[id[i]] = begin[i];
    }
  } else if (allowequal) {
    for (int i = 0; i < n; i++) {
      id[i] = upper_bound(a.begin(), a.end(), begin[i]) - a.begin();
      a[id[i]] = begin[i];
    }
  } else {
    for (int i = 0; i < n; i++) {
      id[i] = lower_bound(a.begin(), a.end(), begin[i]) - a.begin();
      a[id[i]] = begin[i];
    }
  }
  int m = *maxptr(id.begin(), id.end());
  vector<T> re(m + 1);
  for (int i = n - 1; i >= 0; i--) {
    if (id[i] == m) re[m--] = begin + i;
  }
  return re;
}

int main() {
  string s;
  cin >> s;
  cout << (s > "2019/04/30" ? "TBD" : "Heisei") << endl;
}


Measured memory_bytes: 256
//  RAKSHIT KADAM
//ALWAYS USE &IT FOR ITERATING USING AUTO ...
//USE COUNT(STARTING ADDRESS, ENDING ADRESS ,VALUE) FOR FINDING THE COUNT IN THE RESPECTIVE DATA STRUCTURE
//NOTE THAT MEMSET CANNOT ASSIGN A VALUE OF 10^18 IT WILL ASSIGN A LOWER VALUE THAN THAT!!!
 #include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// #define ordered_set tree< int ,  null_type ,  less<int> ,  rb_tree_tag ,  tree_order_statistics_node_update>
#warning !!!check the size of arrayss!!!

// NUMERIC DEFINITIONS :
    #define INF 2000000000000000005
    #define MOD  1000000007
    #define newMOD  998244353
    #define MAX 300006
    #define pi 3.1415926535897932384626433832795
 #define ll long long
 #define int long long
 #define P(gg) for(auto rax:gg){cout<<rax<<" ";}cout<<endl;
 #define Need_for_speed(activated) ios_base :: sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
 #define satisfy ll t; cin>> t; while(t--)
 #define inp(n) int n;cin >> n
 #define mp make_pair
 #define pb push_back
 #define endl "\n"
 #define x first
 #define y second
 #define fore(i,a,b) for(ll i=a;i<b;i++)
 #define forci(i,n) for(ll i=0;i<n;i++)
 #define vi vector<ll>
 #define Endl endl
 #define lb lower_bound
 #define ub upper_bound
#define pii pair<ll,ll>
 #define input freopen("input.txt", "r", stdin),freopen("output.txt", "w", stdout)
 #define time        cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
using namespace std;
ll gcd(ll a, ll b){if (b == 0)return a;return gcd(b, a % b);}
//int power(int x, unsigned int y, unsigned int m){ if (y == 0) return 1;int p = power(x, y/2, m) % m;  p = (p * p) % m;                                                  return (y%2 == 0)? p : (x * p) % m;}
//ll modInverse(int a, int m){int g = gcd(a, m); { return power(a, m-2, m);}}

void solve()
{
    ll n;cin>>n;
    ll a[n+2],b[n+3];
    for(ll i=0;i<=n;i++)
        cin>>a[i];
    for(ll i=0;i<n;i++)cin>>b[i];
    ll ans=0;
    for(ll i=0;i<n;i++)
    {
        if(a[i]<b[i])
        {
            ans+=a[i];b[i]-=a[i];
            ans+= min(a[i+1],b[i]);
            a[i+1] -=min(a[i+1],b[i]);
        }
        else
        {
            ans+=b[i];
        }
    }
    cout<<ans<<endl;
}
signed main()
{
 
    Need_for_speed(activated);
//satisfy
//    {
//   solve();
//    }

 solve();
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int main(){
  
  double n, t, a;
  cin >> n >> t >> a;
  
  vector<double> v(n);
  for(int i; i < n; i ++)
    cin >> v.at(i);//v.at(i)は、地点iにおける標高
  for(int i; i < n; i ++)
    v.at(i) = t - v.at(i) * 0.006;//v.at(i)は、地点iにおける平均気温
  
  vector<double> w(n);
  for(int i; i < n; i++)
    w.at(i) = max((v.at(i) - a), (a - v.at(i)));//w.at(i)は、地点iにおける気温とaの絶対値
  
  double j = 200000000;
  int k = 0;
  int l = 0;
  
  while(l < n){
    if(w.at(l) < j){
      j = w.at(l);
      k = l;
    }
    l++;
  }
  cout << k + 1 << endl;
}
    
    

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

using namespace std;

int main(void){
  string a,c;
  char b;
  cin >> a >> b >> c;
  if(b=='+'){
    cout << atoi(a.c_str()) + atoi(c.c_str())  << endl;
  }else{
    cout << atoi(a.c_str()) - atoi(c.c_str())  << endl;
  }
}

Measured memory_bytes: 256
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define ull unsigned long long
#define db long double
#define pb push_back
#define ppb pop_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()

void dout() { cerr << '\n'; }

template <typename Head, typename... Tail>
void dout(Head H, Tail... T) {
    cerr << " " << H;
    dout(T...);
}

#ifdef LOCAL
    #define dbg(...) cerr << #__VA_ARGS__, dout(__VA_ARGS__)
#else
    #define dbg(...) ;
#endif

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef pair <int, int> pii;



int main() {
    ios_base::sync_with_stdio(false), cin.tie(NULL);
    #ifdef LOCAL
        freopen("input.txt", "r", stdin);
    #endif

    ll ans = 0;
    int n, k;
    cin >> n >> k;
    for (int i = k + 1; i <= n; i++) {
        ans += (ll)(n / i) * (i - k);
        if (k == 0) {
            ans += max(0, n % i - k);
        }   else {
            ans += max(0, n % i - k + 1);
        }
    }
    cout << ans;
}


Measured memory_bytes: 256
S=input()
flag=True
for i in range(len(S)):
    if i%2==0:
        if S[i]!="h":
            flag=False
            break
    else:
        if S[i]!="i":
            flag=False
            break

if flag and len(S)%2==0:
    print("Yes")
else:
    print("No")
        
    

Measured memory_bytes: 2940
import sys
def input(): return sys.stdin.readline().rstrip()

def main():
    N, M = map(int, input().split())
    H = tuple(map(int, input().split()))
    AB = [list(map(int, input().split())) for _ in range(M)]

    data = [[0] for _ in range(N)]
    for a, b in AB:
        data[a - 1].append(H[b - 1])
        data[b - 1].append(H[a - 1])

    ans = 0
    for i, h in enumerate(H):
        if h > max(data[i]):
            ans += 1

    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 109904
a,b,c = map(int,input().split())
ab = 10*a+b+c
ac = 10*a+c+b
ba = 10*b+a+c
bc = 10*b+c+a
ca = 10*c+a+b
cb = 10*c+b+a
lists = [ab,ac,ba,bc,ca,cb]
print(max(lists))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main() {
    // 入力受け取り, 入次数も管理する
int n;
    cin >> n;
int data[n],datan[n];

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

sort(data,data+n);
int flag=0;
int flag2=0;
for(int i=0;i<n;i++){
if(data[i]!=datan[i])flag++;
if(data[i]==datan[i])flag2++;

}
if(flag==2 || flag2==n)
cout <<"YES";
else
cout <<"NO";





}




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

#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define ALL(v) v.begin(), v.end()
#define SZ(x) ((ll)(x).size())

const double PI  = acos(-1.0);
const double EPS = 1e-9;
const int INF = 1e9+10;
const ll mod = 998244353;
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; }
#define print(x) cerr << #x << " is " << x << endl;
//#define print(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl; 
ll A[100005], NODE[100005], ARC[100005], S[100005];

// segmenttree double ��max���̂�o�[�W����(�����l0)
const int MAX_N = 1 << 18;
int n;
int dat[2 * MAX_N - 1];

void init(int n_){
    n = 1;
    while(n < n_) n *= 2;
    for (int i = 0; i < 2 * n - 1; i++) dat[i] = 0; // �����l
}

void update(int k, int a){
    k += n - 1;
    bool right_flag = false;
    while(k > 0){
        int knew = (k - 1)/2;
        //fprintf(stderr, "%d->%d\n", k, knew);
        if (k == knew * 2 + 1){
            if (!right_flag)
                dat[k]+= a;
            right_flag = true;
        } else {
            if (right_flag)
            dat[k - 1] += a;
                //fprintf(stderr, "hoge2 %d\n", a);
#if 0
            if (right_flag){
            
                
            } else {
                //fprintf(stderr, "hoge %d\n", a);
                //dat[knew] += a;
            }
            left_flag = true;
#endif
        }
        k = knew;
    }
#if 0    
    dat[k] = a;
    while(k > 0){
        k = (k - 1)/2;
        dat[k] = max(dat[k * 2 + 1], dat[k * 2 + 2]);
    }
#endif
}
// [a, b)�̍ő�l�����߂�
// �O����́Aa, b, 0, 0, n)�Ƃ��ČĂ� n��2�ׂ̂�

#if 0
int query(int a, int b, int k, int l, int r){

    if (r <= a || b <= l) return 0.0;
    if (a <= l && r <= b) return dat[k];
    else {
        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 vl + vr + dat[k];
    }
}
#endif
int query(int k){
    k += n - 1;
    int ans = dat[k];
    while(k > 0){
        k = (k - 1)/2;
        ans += dat[k];
    }
    return ans;
}

int main() {
    int N, K;
#if 1
    cin >> N >> K;
    vector<ll> A(N);
    rep(i, N)cin >> A[i];
#else    
    
    N = K = 100000;
    vector<ll> A(N);
    rep(i, N)A[i] = 20000;
#endif
    init(N);
    int k;
    for (k = 0; k < K; k++){
        init(N);
        for (int i = 0; i < N; i++){
            int j_min = max(0, i - (int)A[i]);
            int j_max = min(N - 1, i + (int)A[i]);
            update(j_max, 1);
            if (j_min > 0){
                update(j_min - 1, -1);
            }
        }
        bool flag = false;
        for (int i = 0; i < N; i++){
            A[i] = query(i);
            if (A[i] != N)flag = true;
        }
        if (flag == false){
            break;
        }
    }
    rep(i, N){
        cout << A[i] << " ";
    }
    //cout << "hoge " << k << " " << N;;
       
    return 0;
}


Measured memory_bytes: 6876
#include <iostream>

#define N 55

using namespace std;

int main(void)
{

	int n,p;

	int m[N];

	int s;

	int i1;

	while(1){

		cin >> n >> p;
		if (n==0 && p==0) break;

		for(i1=0;i1<N;i1++){
			m[i1]=0;
		}

		i1=0;
		s=p;
		
		while(1){
			if(s>0){
				m[i1]++;
				s--;

				if (s==0 && m[i1]==p) break;
			}
			else{
				s+=m[i1];
				m[i1]=0;
			}

			if (i1==n-1){
				i1=0;
			}
			else i1++;
		}

		cout << i1 << endl;

	}


	return 0;
}

Measured memory_bytes: 1160
from sys import stdin

n,m = [int(x) for x in stdin.readline().rstrip().split()]
li = [list(map(int,stdin.readline().rstrip().split())) for _ in range(m)]

lin = [0]*n

for i in li:
    lin[i[0]-1] +=1
    lin[i[1]-1] += 1

for i in lin:
    print(i)

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <cstring>
#include <algorithm>
#include <numeric>

using namespace std;

const int N = 100101;

inline int ord(char c) {
  return c - '0';
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int target = 753;
  string s; cin >> s;
  int n = s.length();
  int best = 1010101;
  for(int i = 0; i + 2 < n; ++i) {
    int got = ord(s[i]) * 100 + ord(s[i + 1]) * 10 + ord(s[i + 2]);
    best = min(best, abs(got - target));
  }
  cout << best << endl;
}


Measured memory_bytes: 760
a,b = gets.chomp.split(" ").map(&:to_i);

def get_bigger(a,b)
  if a <= b
    b
  elsif a > b
    a
  end
end

def decrement_num(a,b)
  if a <= b
    [a, b - 1]
  elsif a > b
    [a -1, b]
  end
end

ans = get_bigger(a, b)
a, b = decrement_num(a,b)
ans += get_bigger(a, b)
print ans

Measured memory_bytes: 1788
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
using namespace std;
#define int long long
int H,W;
int32_t main() {
    cin >> H >> W;
    if(H == W)
        cout << "Yes\n";
    else
        cout << "No\n";
    return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.Scanner;
import java.util.Arrays;
import java.lang.Math;

class Main {
    static Scanner sc = new Scanner(System.in);
    public static void main(String[] args) throws IOException {
        double r = ReadDouble();
        String res1 = String.format("%.8f", r * r * Math.PI);
        String res2 = String.format("%.8f", 2 * r * Math.PI);
        System.out.println(res1 + " " + res2);
    }
    static int ReadInt() throws IOException {
        return Integer.parseInt(sc.next());
    }
    static double ReadDouble() throws IOException {
        return sc.nextDouble();
    }
}

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

#define      pb    push_back
#define      ff    first
#define      ss    second
#define      ll    long long int
#define      endl  "\n"
#define      FASTIO        ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);


#define      TEST    int t ; cin >> t ; while( t -- )

const ll big = 10e17 + 11 ;

int  main (  ) {

    FASTIO ;

    int n ;
    cin >> n ;

    set < string > s ;
    string st ;

    while( n-- ){

        cin >> st ;

        s.insert( st ) ;
    }

    cout << s.size( ) ;


    return  0 ;
}


Measured memory_bytes: 19296
#include "bits/stdc++.h"
#define ALL(obj) (obj).begin(),(obj).end()
#define RALL(obj) (obj).rbegin(),(obj).rend()
#define REP(i, n) for(int i = 0; i < int(n); i++)
#define FOR(i,n,m) for(int i = int(n); i < int(m); i++)
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;
const int INF = MOD - 1;
const ll LLINF = 4e18;

// 最大流O(V^2E)
struct Dinic {
private:
    struct edge {
        int to;
        ll cap;
        int rev;
        bool isrev;
        int idx;
    };

    vector< vector< edge > > graph;
    vector< int > min_cost, iter;


    bool bfs(int s, int t) {
        min_cost.assign(graph.size(), -1);
        queue< int > que;
        min_cost[s] = 0;
        que.push(s);
        while (!que.empty() && min_cost[t] == -1) {
            int p = que.front();
            que.pop();
            for (auto &e : graph[p]) {
                if (e.cap > 0 && min_cost[e.to] == -1) {
                    min_cost[e.to] = min_cost[p] + 1;
                    que.push(e.to);
                }
            }
        }
        return min_cost[t] != -1;
    }

    ll dfs(int idx, const int t, ll flow) {
        if (idx == t) return flow;
        for (int &i = iter[idx]; i < graph[idx].size(); i++) {
            edge &e = graph[idx][i];
            if (e.cap > 0 && min_cost[idx] < min_cost[e.to]) {
                ll d = dfs(e.to, t, min(flow, e.cap));
                if (d > 0) {
                    e.cap -= d;
                    graph[e.to][e.rev].cap += d;
                    return d;
                }
            }
        }
        return 0;
    }
public:

    Dinic(int V) : graph(V) {}

    void add_edge(int from, int to, ll cap, int idx = -1) {
        graph[from].push_back({to, cap, (int)graph[to].size(), false, idx});
        graph[to].push_back({from, 0, (int)graph[from].size() - 1, true, idx});
    }


    // from s to t
    ll max_flow(int s, int t) {
        ll flow = 0;
        while (bfs(s, t)) {
            iter.assign(graph.size(), 0);
            ll f = 0;
            while ((f = dfs(s, t, INF)) > 0) flow += f;
        }
        return flow;
    }

    void output() {
        for (int i = 0; i < graph.size(); i++) {
            for (auto &e : graph[i]) {
                if (e.isrev) continue;
                auto &rev_e = graph[e.to][e.rev];
                cout << i << "->" << e.to << " (flow: " << rev_e.cap << "/" << e.cap + rev_e.cap << ")" << endl;
            }
        }
    }
};

//gcd
template<typename T>
T gcd(T a, T b) {
    return b ? gcd(b, a%b) : a;
}

int main() {
    int n, m;
    while (true) {
        scanf("%d %d", &n, &m);
        if (n == 0 && m == 0) break;
        vector<int> a(n), b(m);
        REP(i, n) scanf("%d", &a[i]);
        REP(i, m) scanf("%d", &b[i]);
        Dinic din(n + m + 2);
        REP(i, n) {
            din.add_edge(n + m, i, 1);
            REP(j, m) {
                if (gcd(a[i], b[j]) > 1) {
                    din.add_edge(i, j + n, 1);
                }
            }
        }
        REP(i, m) din.add_edge(i + n, n + m + 1, 1);
        printf("%lld\n",din.max_flow(n + m, n + m + 1));
    }
    return 0;
}


Measured memory_bytes: 13364
from collections import Counter


def main():
    n = int(input())
    v = [int(i) for i in input().split()]
    ans = 0
    odd = Counter(v[1::2])
    even = Counter(v[::2])
    odd_mosts = odd.most_common(2)
    even_mosts = even.most_common(2)
    if odd_mosts[0][0] == even_mosts[0][0]:
        if len(odd) == len(even) == 1:
            ans = n//2
        else:
            ans_sel = []
            ans_sel.append(n//2-odd_mosts[0][1]+n//2-even_mosts[1][1])
            ans_sel.append(n//2-odd_mosts[1][1]+n//2-even_mosts[0][1])
            ans = min(ans_sel)
    else:
        ans+=(n//2-odd_mosts[0][1])
        ans+=(n//2-even_mosts[0][1])
    print(ans)

if __name__ == '__main__':
    main()

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

using namespace std;

#define ll long long
#define ld long double
#define P pair<ll, ll>

#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)

#define all(v) v.begin(), v.end()

#define sortAl(v) sort(all(v))
#define sortAlr(v)          \
  sort(v.begin(), v.end()); \
  reverse(v.begin(), v.end())

#define cout(n) cout << fixed << setprecision(n)

#define rep(i, n) for (ll i = 0; i < n; i++)
#define REP(i, n) for (ll i = 1; i < n; i++)

template <class T>
inline void chmax(T &a, T b) {
  a = std::max(a, b);
}
template <class T>
inline void chmin(T &a, T b) {
  a = std::min(a, b);
}

#define mod (ll)(1e9 + 7)
#define INF LLONG_MAX

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

  ll n, l;
  cin >> n >> l;

  vector<ll> a(n);
  rep(i, n) {
    a[i] = l + i;
  }

  ll ans = INF;
  ll min_d = INF;

  ll sum = accumulate(all(a), 0);
  rep(i, n) {
    ll d = abs(a[i]);
    if (min_d > d) {
      min_d = d;
      ans = sum - a[i];
    }
  }

  cout << ans << 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 rep1(i, n) for(int i=1; i<=n; i++)
#define repr(i, n) for(int i=n-1; i>=0; i--)
#define repr1(i, n) for(int i=n; i>=1; i--)
#define all(v) v.begin(),v.end()
using ll = long long;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
const double EPS = 1e-10;
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; }

int h, w;
string s[30][30];

int main() {
    cin >> h >> w;
    rep(i, h) rep(j, w) cin >> s[i][j];
    rep(i, h) rep(j, w) {
        if (s[i][j] == "snuke") {
            printf("%c%d\n", 'A' + j, i + 1);
            return 0;
        }
    }
}


Measured memory_bytes: 256