akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <algorithm>
using namespace std;
#define ll long long
int main (){
    string a,b;
    cin >> a >> b;
    if (a<b) cout << "<" << endl;
    else if (a>b) cout << ">" << endl;
    else cout << "=" << endl;
    return 0;
}



Measured memory_bytes: 256
fun main(args: Array<String>) {
    var ans = nextLong()
    while (!isPrime(ans)) ans += 1
    println(ans)
}
fun next() = readLine()!!
fun nextLong() = next().toLong()
fun isPrime(n: Long): Boolean {
    if (n == 1L) return false
    for (k in 2 .. Math.sqrt(n.toDouble()).toLong()) {
        if (n % k == 0L) return false
    }
    return true
}

Measured memory_bytes: 31828
#pragma region head
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using pi = pair<int, int>;
using pll = pair<ll, ll>;
template <class T>
using vv = vector<vector<T>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rrep(i, n) for (int i = (int)(n)-1; i >= 0; i--)
#define rrepi(i, a, b) for (int i = (int)(b)-1; i >= (int)(a); i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define bit(n) (1LL << (n))
template <class T>
inline bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, const T &b) {
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}
const int INF = 1002003004;
const ll LINF = 1002003004005006007ll;
struct preprocess {
    preprocess() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} ____;
#pragma endregion head

#pragma region library
vector<ll> divisor(ll n) {
    vector<ll> res;
    for (ll i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            res.emplace_back(i);
            if (i * i != n) res.emplace_back(n / i);
        }
    }
    sort(res.begin(), res.end());
    return res;
}
// Time Complexity: O(log a)
template <typename T>
T extgcd(T a, T b, T &x, T &y) {
    // assert(a>=0 && b>=0);
    T d = a;
    if (b) {
        d = extgcd(b, a % b, y, x);
        y -= (a / b) * x;
    } else {
        x = 1;
        y = 0;
    }
    return d;
}
#pragma endregion library

int main() {
    ll n;
    cin >> n;
    vll div = divisor(2 * n);
    ll ans = LINF;
    if(n == 1){
        cout << 1 << '\n';
        return 0;
    }
    ll now = 1;
    bool flag = false;
    while(now*2 <LINF){
        now*=2;
        if(now==n){
            cout << now*2 - 1 << '\n';
            return 0;
        }
    }
    if(flag) n*=2;
    for (auto u : div) {
        ll v = 2 * n / u;
        if (v < u) continue;
        if (gcd(v, u) != 1) continue;
        ll x, y;
        ll x2, y2;
        extgcd(u, -v, x, y);
        extgcd(-u, v, x2, y2);
        if (y > 0 && x  > 0) {
            chmin(ans, v * y);
        }
        if (x2 > 0 && y2 > 0) {
            chmin(ans, x2 * u);
        }
    }
    cout << ans << '\n';
}


Measured memory_bytes: 3772
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
typedef long double lb;
#define int long long
#define double long double
typedef pair<int,int> P;
const int MOD = 1000000007;
const ll INF = 1e16;
const double EPS = 1e-10;
const double PI = 3.141592653589793;
template<class T> inline bool chmin(T& a, T b){if(a>b){a = b;return 1;}return 0;}
template<class T> inline bool chmax(T& a, T b){if(a<b){a = b;return 1;}return 0;}
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 


////////////////////////////////////////////////////////////////////
vector<ll> fac, finv, inv;
void COMinit(const int MAX = 10000000, const ll &MOD = MOD){
  fac.resize(MAX);finv.resize(MAX);inv.resize(MAX);
  fac[0] = fac[1] = finv[0] = finv[1] = inv[1] = 1;
  repd(i,2,MAX){
    fac[i] = fac[i-1] * i % MOD;
    inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
    finv[i] = finv[i-1] * inv[i] % MOD;
  }
}
ll COM(int n, int k){
  if(n < k)return 0;
  if(n < 0 || k < 0)return 0;
  return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD;
}

const int MAX = 2000005;
ll modFact[MAX];
ll modInv[MAX];
ll modFactInv[MAX];
 
// calc nCr % mod
ll comb(int n, int r) {
  return modFact[n] * (modFactInv[r] * modFactInv[n - r] % MOD) % MOD;
}
////////////////////////////////////////////////////////////////////

int g(int r, int c){
  return comb(r+c+2, r+1)-1;
}
signed main(){
  modFact[0] = modFact[1] = 1;
  modFactInv[0] = modFactInv[1] = 1;
  modInv[1] = 1;
  repd(i, 2, MAX) {
    modFact[i] = modFact[i - 1] * i % MOD;
    modInv[i] = MOD - modInv[MOD % i] * (MOD / i) % MOD;
    modFactInv[i] = modFactInv[i - 1] * modInv[i] % MOD;
  }
  int r1, c1, r2, c2;cin>>r1>>c1>>r2>>c2;
  int aa = g(r2, c2) + ((MOD - g(r1-1, c2)) % MOD);
  aa %= MOD;
  aa += (MOD - g(r2, c1-1))%MOD;
  aa %= MOD;
  aa += g(r1-1, c1-1);
  aa %= MOD;
  cout << aa << endl;
}





Measured memory_bytes: 47104
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#pragma GCC target ("avx2")
#pragma GCC optimization ("unroll-loops")
#define rep(i, n) for(int i=0;i<(int)(n);++i)
template <typename T> ll gcd(T a, T b) {return b?gcd(b, a%b):a;}
template <typename T> ll lcm(T a, T b) {return a * b / gcd(a, b);};
template <typename T> inline void chmin(T &a, const T& b){if(a>b)a=b;}
template <typename T> inline void chmax(T &a, const T& b){if(a<b)a=b;}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n, k, ans = 0;
  cin >> n >> k;
  while (n > 0) {
    n /= k;
    ans++;
  }
  cout << ans << '\n';
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ALL(v) v.begin(),v.end()

namespace Geometry{
    using namespace std;
    using ld=long double;
    using Point=complex<ld>;
    using P=Point;
    
    struct Line{
        Point a,b;
    };
using L=Line;
    struct Circle{
        Point p;
        ld r;
    };
    using C=Circle;
    const ld EPS=1e-9;
    const ld eps=EPS;
    inline bool EQ(Point a,Point b){return abs(a-b)<EPS;}
    ld dot(Point a,Point b){return real(a)*real(b)+imag(a)*imag(b);}
    ld cross(Point a,Point b){return real(a)*imag(b)-imag(a)*real(b);}
vector<Line> tangent_cp(Circle c,Point p){
        vector<Line> res;
        Point v=c.p-p;
        ld d=abs(v);
        if(abs(d-c.r)<EPS){
            Point dir=v*Point(0,1);
            res.push_back(Line{p,p+dir});
            return res;
        }
        if(d<c.r){
            return res;
        }
        ld l=sqrt(d*d-c.r*c.r);
        Point v0=v*Point(l/d,c.r/d);
        Point v1=v*Point(l/d,-c.r/d);
        res.push_back(Line{p,p+v0});
        res.push_back(Line{p,p+v1});
        return res;
    }


    vector<Line> tangent_cc(Circle c0,Circle c1){
        vector<Line> res;
        if(abs(c1.p-c0.p)>c0.r+c1.r-EPS){
            Point mp=(c0.p*c1.r+c1.p*c0.r)/(c0.r+c1.r);
            res=tangent_cp(c0,mp);
        }
        if(abs(c1.r-c0.r)>EPS){
            Point om=(-c0.p*c1.r+c1.p*c0.r)/(c0.r-c1.r);
            auto ret=tangent_cp(c0,om);
            res.insert(res.end(),ret.begin(),ret.end());
        }
        else{
            Point v=c1.p-c0.p;
            ld d=abs(v);
            Point p0=c0.p+v*Point(0,c0.r/d);
            Point p1=c0.p+v*Point(0,-c0.r/d);
            res.push_back(Line{p0,p0+v});
            res.push_back(Line{p1,p1+v});
        }        
        return res;
    }

    ld dist_lp(Line l,Point p){
        Point x=l.b-l.a;
        Point y=p-l.a;
        return abs(cross(x,y))/abs(x);
    }
}


using namespace Geometry;

int solve(int n){
    vector<Point> xy(n);
    vector<ld> r(n);
    vector<ld> m(n);
    vector<Circle> cs;
    for(int i=0;i<n;i++){
        ld x,y;
        cin>>x>>y>>r[i]>>m[i];
        xy[i]={x,y};
        cs.push_back(Circle{xy[i],r[i]});
        cs.push_back(Circle{xy[i],r[i]+m[i]});
    }
    int res=1;
    for(int i=0;i<cs.size();i++){
        for(int j=0;j<i;j++){
            if(cs[i].p==cs[j].p) continue;
            auto ls=tangent_cc(cs[i],cs[j]);
            for(int l=0;l<ls.size();l++){
                int sc=0;
                for(int k=0;k<n;k++){
                    ld d=dist_lp(ls[l],xy[k]);
                    if(r[k]-(1e-5)<d && d<r[k]+m[k]+(1e-5)){
                        sc++;
                    }
                    res=max(sc,res);
                }
            }
        }
    }
    return res;
}

int main(){
    int n;
    while(cin>>n,n){
        cout<<solve(n)<<endl;
    }
    return 0;
}


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

# 入力を各変数に格納
num_list = [int(i) for i in input().split()]
times = int(input())

# 3つの数値を昇順ソート
num_list.sort()
# リスト内最大値を一時変数へ
num_tmp = num_list[2]
# 操作回数分の*2をする
for i in range(times):
	num_tmp = num_tmp * 2
num_list[2] = num_tmp

# リスト内の数値を合計して出力
print(sum(num_list))

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

int main(){
  string N;
  cin>>N;
  
  for(int i=0; i<2; i++){
    if(N[i]==N[i+1]&&N[i+1]==N[i+2]){
      cout << "Yes " <<endl;
      return 0;
    }
  }
  
  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <map>
 
using namespace std;
 
typedef long long ll;
const int MAXN= 55555;
const int MOD = 1e9;
 
int a[6000];
int b[6000];
int y = 0;
void ss(){
	int f= 1;
	memset(a, 0, sizeof(a));
	for(int i= 2; i <= 55555; i++){
		int x = sqrt(i);
		for(int j = 2; j <= x; j++){
			if(i % j == 0){
				 f= 0;
				 break;
			}
		}
		if(f){
			a[y] = i ;
			y++;
		}
		f = 1;
	}
}
 
int main(){
	ss();
	memset(b, 0, sizeof(b));
	int n;
	scanf("%d", &n);
	int d = 5;
	int kk = 0, kkk = 0;
	for(int i = 0; i <= 6000; i++){
		if(a[i] % 10 == 3){
			b[kkk] = a[i];
			kkk++;
			//printf("%d \n", a[i]);
		//	kk++;
			d = a[i];
		}
	}
	for(int i = 0; i < n; i++)	
		printf("%d ", b[i]);
	printf("\n");
}

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,m;cin>>n>>m;
    if(n>=m/2)cout<<m/2<<endl;
    else {
        m-=2*n;
        cout<<m/4+n<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n,a[100005],dem;
bool b[100005];
int main(){
    cin >> n;
    dem=0;
    for(int i=0;i<=n;i++) b[i]=false;
    for(int i=1;i<=n;i++){
        cin >> a[i];
        if(a[i]==i){
            b[i]=true;
            dem++;
        }
    }
    for(int i=0;i<n;i++){
        if(b[i]==true && b[i+1]==true){
            dem--;
            b[i]=false;
            b[i+1]=false;
        }
    }
    cout << dem;
}


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

using namespace std;

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

    vector<int> note[10];
    for(int i = 0; i < n; i++) {
        note[s[i]-'0'].push_back(i);
    }

    int count = 0;
    for(int i = 0; i < 1000; i++) {
        int a = i / 100;
        int b = (i % 100) / 10;
        int c = i % 10;

        if(note[a].size() == 0) continue;
        int pos = note[a][0];
        auto itr = lower_bound(note[b].begin(), note[b].end(), pos+1);
        if(itr == note[b].end()) continue;
        pos = *itr;
        itr = lower_bound(note[c].begin(), note[c].end(), pos+1);
        if(itr == note[c].end()) continue;
        count++;
    }

    cout << count << endl;
}

Measured memory_bytes: 3812
import java.util.Scanner;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        // 整数の入力
        int a = sc.nextInt();
        int b = sc.nextInt();
        
        if(a%2 == 1 && b%2 == 1)
            System.out.println("Odd");
        else
            System.out.println("Even");
    }
}


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

void merge(int l,int mid,int r,vector<pair<int,int>> &array){
    int n = mid - l;
    int m = r - mid;
    vector<pair<int,int>> left_array(n),right_array(m);
    for(int i=0;i<n;i++){
        left_array.at(i) = array.at(l+i);
    }
    for(int i=0;i<m;i++){
        right_array.at(i) = array.at(mid+i);
    }
    pair<int,int> a = make_pair(1000000,1000000);
    left_array.push_back(a);
    right_array.push_back(a);
    int li=0,ri=0;
    for(int i=0;i<r-l;i++){
        if(left_array.at(li).first < right_array.at(ri).first){
            array.at(l+i) = left_array.at(li);
            li++;
        }else{
            array.at(l+i) = right_array.at(ri);
            ri++;
        }
    }

}

void mergesort(int l, int r, vector<pair<int,int>> &array){
    if(l+1 < r){
        int mid = (l+r)/2;
        mergesort(l,mid,array);
        mergesort(mid,r,array);
        merge(l,mid,r,array);
    }

}

int main(){
    int n;
    cin >> n;
    vector<pair<int,int>> array(n);
    for(int i=0;i<n;i++){
        cin >> array.at(i).first;
        array.at(i).second = i+1;
    }
    mergesort(0,n,array);
    for(int i=0;i<n;i++){
        cout << array.at(i).second << " ";
    }
    cout << endl;
}

Measured memory_bytes: 5584
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 4e6 + 10;
const int MOD = 1e9 + 7;
ll d[N];
ll qpow(ll x, ll k) { 
    ll r = 1;
    while(k) {
        if(k & 1) {
            r = r * x % MOD;
        }
        k >>= 1;
        x = x * x % MOD;
    }
    return r;
}
int main() {
    d[0] = 1;
    for(int i = 1; i < N; i++) {
        d[i] = d[i-1] * i % MOD;
    }
    ll a0, a1;
    cin >> a0 >> a1;
    if(2*a1 - a0 < 0 || 2*a0 - a1 < 0 || (2*a1 - a0) % 3 != 0 || (2*a0 - a1) % 3 != 0) {
        cout << 0 << endl;
        return 0;
    }
    ll x = (2*a1 - a0)/3, y = (2*a0 - a1)/3;
    cout << d[x+y] * qpow(d[x],MOD-2) % MOD * qpow(d[y], MOD-2) % MOD << endl;
    return 0;
}

Measured memory_bytes: 31616
N,M = map(int, input().split())
K_A = [list(map(int, input().split())) for _ in range(N)]

tmp = set(K_A[0][1:K_A[0][0]+1])
for i in range(1,N):
    tmp = tmp & set(K_A[i][1:K_A[i][0]+1])
print(len(tmp))


Measured memory_bytes: 38256
package main

import (
	"fmt"
)

func main() {
	var h, w int
	fmt.Scan(&h, &w)

	done := [1000][1000]int{}

	q := make([][2]int, 0)
	var a string
	for i := 0; i < h; i++ {
		fmt.Scan(&a)
		for j := 0; j < len(a); j++ {
			done[i][j] = -1
			if a[j] == '#' {
				q = append(q, [2]int{i, j})
				done[i][j] = 0
			}
		}
	}

	ans := 0
	dx := []int{-1, 1, 0, 0}
	dy := []int{0, 0, -1, 1}
	for len(q) > 0 {
		p := q[0]
		q = q[1:]
		c := done[p[0]][p[1]] + 1
		for i := 0; i < len(dx); i++ {
			x := p[1] + dx[i]
			y := p[0] + dy[i]
			if 0 <= x && x < w && 0 <= y && y < h && done[y][x] == -1 {
				done[y][x] = c
				if ans < c {
					ans = c
				}
				q = append(q, [2]int{y, x})
			}
		}
	}

	fmt.Println(ans)
}


Measured memory_bytes: 63360
import java.util.*;

public class Main{

     public static void main(String[] args){
         
         Scanner sc = new Scanner(System.in);
         int a = sc.nextInt();
         int b = sc.nextInt();
         
         if( Integer.lowestOneBit(a) != 1 || Integer.lowestOneBit(b) != 1){
            System.out.println("Even");
         } else{
            System.out.println("Odd");
         }
       
     }
}

Measured memory_bytes: 21844
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iomanip>
#include <limits>
using namespace std;
// 素因数分解
typedef pair<long long, long long> P;
vector<P> prime_factorize(long long n)
{
vector<P> res;
for (long long p = 2; p * p <= n; ++p)
{
if (n % p != 0)
continue;
int num = 0;
while (n % p == 0)
{
++num;
n /= p;
}
res.push_back(make_pair(p, num));
}
if (n != 1)
res.push_back(make_pair(n, 1));
return res;
}
// 因数分解
long long gcd(long long x, long long y)
{
  if (y == 0)
  {
    return x;
  }
  else
  {
    return gcd(y, x % y);
  }
}
const int MOD = 1000000007;
typedef long long int ll;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i, n) for (int i = 0; i < (n); i++)

int main()
{
    int h,a;
    cin >> h >> a;
    int ans = 0;
    while (h > 0)
    {
        h -= a;
        ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3588
g=[[0]*5 for _ in[0]*5]
for i in range(9):
 e=input()
 for j in range(4+i%2):
  if int(e[j]):
   if i%2:g[i//2][j]+=4;g[i//2+1][j]+=1
   else:r=g[i//2];r[j]+=2;r[j+1]+=8
y,x=0,1
k=1
a=[1]
while 1:
 k+=2
 for _ in[0]*4:
  k+=1
  if g[y][x]&int(2**(k%4)):a+=[k%4];break
 if k%2:x+=[1,-1][(k%4)>1]
 else:y+=[-1,1][(k%4)>0]
 if x+y==0:break
print(''.join('URDL'[c]for c in a))


Measured memory_bytes: 5612
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = n-1; i >= 0; i--)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
using P = pair<int,int>;
using VI = vector<int>;
using VVI = vector<vector<int>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VP = vector<P>;
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; }

int main(){
    string s;
    cin >> s;
    int n = s.size();
    char c = s[0];
    int ans = 0;
    for(int i = 1; i < n; i++){
        if (s[i] != c){
            ans++;
            c = s[i];
        }
    }
    c = s[n-1];
    int sum = 0;
    for(int i = n-2; i >= 0; i--){
        if (s[i] != c){
            sum++;
            c = s[i];
        }
    }
    ans = min(ans, sum);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3688
#include <stdio.h>
int main(void){

char  S[100000];
int i,j,ans=0;
  scanf("%s", S);
  for(j=0;S[j]!='\0';j++);
  for(i=1;i<=j;i++){
    if(S[i]==S[i-1]){
      if(S[i]=='0'){
        S[i]='1';
      }
     else{
        S[i]='0';
      }
      ans++;
    }
  }
  printf("%d",ans);
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

const ll P = 1000000007;
const long long INF = 1LL << 60;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

int main()
{
  cout << fixed << setprecision(10);
  ll Q,H,S,D,N;
  cin >> Q >> H >> S >> D >> N;
  ll sum = 0;
  if(2*Q<H)
  {
    H = 2*Q;
  }
  if(2*H<S)
  {
    S = 2*H;
  }
  if(2*S<D)
  {
    D = 2*S;
  }
  while(N>=2000)
  {
    N -= 2000;
    sum += D * 1000;
  }
  while(N>=2)
  {
    N -= 2;
    sum += D;
  }
  while(N>=1)
  {
    N -= 1;
    sum += S;
  }
  cout << sum << endl;
  return 0;
}


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

using namespace std;

int main() {
    long long int n,x,count;
    cin >> n;
    x = 100; count = 0;
    while (x<n) {
        x=floor(x*1.01);
        count++;
    }
    cout<<count;
    return 0;
}

Measured memory_bytes: 3744
from collections import Counter

n = int(input())
v = list(map(int, input().split(' ')))

v1 = v[::2]
v2 = v[1::2]

counter1 = dict(Counter(v1))
counter2 = dict(Counter(v2))
x1 = max(counter1, key=counter1.get)
x2 = max(counter2, key=counter2.get)
x1_c = counter1[x1]
x2_c = counter2[x2]
del counter1[x1]
del counter2[x2]
y1_c = 0
y2_c = 0
if len(counter1) != 0:
    y1_c = max(counter1.values())
if len(counter2) != 0:
    y2_c = max(counter2.values())

n = n//2
ans = 0
if x1 == x2:
    ans = min((n - x1_c) + (n - y2_c), (n - y1_c) + (n - x2_c))
else:
    ans = (n - x1_c) + (n - x2_c)

print(ans)

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

ans1,ans2 = 0,0
res = 0
for i in range(N):
    res += A[i]
    if i%2==1:
        if res >= 0:
            ans1 += res+1
            res = -1
    else:
        if res <= 0:
            ans1 -= res-1
            res = 1

res = 0
for i in range(N):
    res += A[i]
    if i%2==1:
        if res <= 0:
            ans2 -= res-1
            res = 1
    else:
        if res >= 0:
            ans2 += res+1
            res = -1

print(min(ans1,ans2))


Measured memory_bytes: 14332
// review
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>

using namespace std;

const int MAXN = 51;

int n;
int d[MAXN];

int calc(vector<int>& v) {
  int diff = 24;
  sort(v.begin(), v.end());
  for (int i=0;i<v.size()-1;i++) {
    diff = min(v[i + 1] - v[i], diff);
  }
  return diff;
}

void solve() {
  map<int, int> m;
  for (int i=0;i<n;i++) {
    m[d[i]]++;
    if (m[d[i]] > 2) {
      cout << 0 << endl;
      return;
    }
  }

  if (m[0] > 0 || m[12] > 1) {
    cout << 0 << endl;
    return;
  }

  int cnt = 0;
  for (int i=0;i<(1<<11);i++) {
    vector<int> v;
    v.push_back(0);
    v.push_back(24);
    for (int j=1;j<=11;j++) {
      if (m[j] == 2) {
        v.push_back(j);
        v.push_back(24 - j);
      } else if (m[j] == 1) {
        if ((i >> (j-1)) & 1) {
          v.push_back(j);
        } else {
          v.push_back(24 - j);
        }
      }
    }
    if (m[12] > 0) {
      v.push_back(12);
    }
    cnt = max(cnt, calc(v));
  }
  cout << cnt << endl;
}

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for(int (i)=0 ;i <(n); ++(i))
#define REP(i,m,n) for(int (i) = (m); (i) <= (n); ++(i))
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)? "YES":"NO")
typedef long long ll;
using namespace std;

int f(int n) {
  int res = 0;
  for(int i=0; i<=n; i++) {
    res+=i;
  }
  return res;
}

int main() {
  int n;
  cin >> n;
  cout << f(n) << endl;
  return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var a, b int
	fmt.Scan(&a, &b)

	if a < b {
		fmt.Println("a < b")
		return
	}

	if a > b {
		fmt.Println("a > b")
		return
	}

	fmt.Println("a == b")
}



Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a; i< (int)(b); ++i)
#define ALL(x) (x).begin(),(x).end()
#define rALL(x) (x).rbegin(),(x).rend()
typedef long double ld;
using ll=long long;
using namespace std;
const int mod=1e9+7;
const ll inf = 1LL << 60;
const ld pi = (acos(-1));
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }




int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  
  int s,w; cin >> s >> w;
  string ans="safe";
  if(s<=w) ans="unsafe";
  cout << ans << endl;
}

Measured memory_bytes: 3652
/* maybemaybemaybeno */
#include<bits/stdc++.h>
using namespace std ;
typedef long long ll ;
typedef long double lld ;
#define f(i,s,n) for(int i=s;i<(int)n;i++) 
const int MAXN = 1e5+5  ;
#define pb push_back 
#define X first 
#define Y second 
#define pii pair<int,int> 
#define pll pair<ll,ll> 
#define pli pair<ll,int> 
#define pil pair<int,ll> 
#define fio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);cout<<setprecision(10) ;
#define is(x) cout<<#x<<" : "<<x<<endl ;
// #define DEBUG
vector<int> al[MAXN] ;
vector<int> par ;
void bfs(int root)
{
    queue<int> q ;
    q.push(root);
    while(!q.empty())
    {
        int node = q.front() ;
        q.pop() ;
        for(auto x:al[node])
        {
            if(par[x]!=-1) continue ;
            par[x] = node ;
            q.push(x) ;
        }
    }
}
int main()
{
    fio ;
    /* ======================Start of code ================ */
    int n,m;cin>>n>>m ;
    par.resize(n,-1) ;
    f(i,0,m)
    {
        int a,b;
        cin>>a>>b;a--;b--;
        al[a].pb(b) ;
        al[b].pb(a) ;
    }
    par[0] = 0 ;
    bfs(0) ;
    bool pos = true ;
    f(i,0,n) if(par[i]==-1) {pos=false;break ;}
    if(!pos) cout<<"No\n" ;
    else 
    {
        cout<<"Yes\n" ;
        f(i,1,n) cout<<(par[i]+1)<<"\n" ;
    }
    /* ======================End of code ================== */
}

Measured memory_bytes: 10224
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<int,ll> pil;
typedef pair<ll,int> pli;
typedef pair<ll,ll> pll;

template<class T,class U>constexpr bool chmin(T&a,const U b){if(a<=b)return false;a=b;return true;}
template<class T,class U>constexpr bool chmax(T&a,const U b){if(a>=b)return false;a=b;return true;}
#define bit(n,k) ( (n>>k)&1 )

//デバッグ
template<class T>
void Vout(vector<T> &V){
    cout<<"\nstart\n";
    const int sz=V.size();
    for(int i=0;i<sz;i++){
        cout<<i<<" "<<V[i]<<'\n';
    }
    cout<<"end\n"<<endl;
}

template<class T>
void VPout(vector<T> &V){
    cout<<"\nstart\n";
    const int sz=V.size();
    for(int i=0;i<sz;i++){
        cout<<i<<" "<<V[i].first<<" "<<V[i].second<<'\n';
    }
    cout<<"end\n"<<endl;
}


//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++


constexpr int MAX=1<<30;
constexpr ll INF=1LL<<62;
constexpr int MOD=1e9+7;
int dx[]={1,-1,0,0},dy[]={0,0,-1,1};

//__builtin_popcount(S);
//#define int ll
//vector<vector<int>> data(3, vector<int>(4));
//vector.resize(a,vector<int>(b,-1));
//vector<vector<vector<要素の型>>> 変数名(要素数1, vector<vector<要素の型>>(要素数2, vector<要素の型>(要素数3, 初期値)));




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

    string S;
    cin>>S;
    for(int i=0;i<(int)S.size();i++){
        cout<<'x';
    }
    cout<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define _GLIBCXX_DEBUG
#define V vector<ll>
using namespace std;
using ll = long long;

int main(){
   int a,b,c,d,e;
   cin>>a>>b>>c>>d>>e;
   V v={a,b,c,d,e};
   int sum=0;
   bool f=false;
   rep(i,0,5){
      if(v[i]%10==0) sum+=v[i];
      else {
         sum+=((v[i]+10)/10)*10;
         f=true;
      }
   }
   if(f) sum-=10;
   ll m=1001001;
   rep(i,0,5){
      if(v[i]%10!=0){
         m=min(m,v[i]%10);
      }
   }
   if(m<=9) sum+=m; 
   cout<<sum<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int r;
  cin>>r;
  if(r<1200){
    cout<<"ABC"<<'\n';
  }
  if(r>=1200 && r<2800){
    cout<<"ARC"<<'\n';
  }
  if(r>=2800){
    cout<<"AGC"<<'\n';
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
    using namespace std;
    const long long INF = 1LL<<60;
    const int MAX = 16;
    int N;
    vector<long long> A;
     
    vector<vector<long long>> calc(const vector<long long> &a, int offset = 0) {
        vector<vector<long long>> dp(N+1, vector<long long>(MAX, INF));
        for (int j = 0; j < MAX; ++j) dp[0][j] = 0, dp[1][j] = j*2 + offset;
        for (int i = 1; i < N; ++i) {
            long long s = a[N-i-1];
            for (int j = 0; j < MAX; ++j) {
                long long t = a[N-i];
                int need = 0;
                while (s > t) ++need, t *= 4;
                long long add = 0;
     
                if (need >= MAX) {
                    add = (need - MAX + 1) * i * 2;
                    need = MAX-1;
                }
                dp[i+1][j] = min(dp[i][need] + j * 2 + add + offset , dp[i+1][j]);
                s *= 4;
            }
        }
        return dp;
    }
     
    long long solve() {
        const auto &right = calc(A);
        reverse(A.begin(), A.end());
        const auto &left = calc(A, 1);
        long long res = INF;
        for (int i = 0; i <= N; ++i) {
         res = min(res ,left[i][0] + right[N-i][0] );
        }
        return res;
    }
     
    int main() {
        cin >> N;
        A.resize(N);
        for (int i = 0; i < N; ++i) cin >> A[i];
        cout << solve() << endl;
    }

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

int n, a[100], ave, b, ans, Min = 1e9;

int main() {
    cin >> n;
    rep(i, n) {
        cin >> a[i];
        ave += a[i];
    }
    rep(i, n) {
        b = abs(a[i] * n - ave);
        if (b < Min) {
            Min = b;
            ans = i;
        }
    }
    cout << ans << endl;

    return 0;
}

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

int main(){
    int a, b;
    cin >> a >> b;
    cout << max(a+b,max(a-b,a*b)) << endl;
}

Measured memory_bytes: 3640
=begin
S
Q
Query 1
...
Query Q
=end

head = []
tail = []
flip = false

s = gets.chomp
q = gets.chomp.to_i

q.times do
  query = gets.chomp.split(" ")

  if query.first == "1"
    head, tail = tail, head
    flip = !flip
  else
    if query[1] == "1"
      if !flip
        head.unshift(query[2])
      else
        head << query[2]
      end
    else
      if !flip
        tail << query[2]
      else
        tail.unshift(query[2])
      end
    end
  end
  # p [head, s, tail, flip]
end

if flip
  puts(head.join.reverse + s.reverse + tail.join.reverse)
else
  puts(head.join + s + tail.join)
end


Measured memory_bytes: 17276
import java.util.Scanner;

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

		int N = sc.nextInt();
		int M = sc.nextInt();

		boolean[] clear = new boolean[N];
		int[] wa = new int[N];
		long waCnt = 0;
		int ac = 0;
		
		for (int i=0; i<M; i++) {
			int p = sc.nextInt() - 1;
			String S = sc.next();
			if (!clear[p]) {
				if (S.equals("AC")) {
					clear[p] = true;
					ac++;
					waCnt += wa[p];
				}
				else {
					wa[p]++;
				}
			}
		}
		
		System.out.println(ac + " " + waCnt);
	}
}

Measured memory_bytes: 62780
n = int(input())
lis = input().split()
dic = {}

for i in range(n):
  if lis[i] not in dic:
    dic[lis[i]] = 1
  else:
    dic[lis[i]] += 1
    
for x in dic.values():
  if x != 1:
    print("NO")
    exit()

print("YES")

Measured memory_bytes: 40724
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e16;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

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 ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
ll factorial(ll n) {
  if (n == 1) {
    return 1;
  }
  ll ans = factorial(n-1);
  return ans*n;
}
ll gcd(ll a, ll b) {
  if (b == 0) return a;
  return gcd(b, a%b);
}
ll lcm(ll a, ll b) {
  return (a/gcd(a, b))*b;
}
bool is_prime(ll n) {
  for (ll i = 2; i*i <= n; i++) {
    if (n%i == 0) return false;
  }
  return n != 1;
}
ll mod_pow(ll x, ll n, ll mod) {
  if (n == 0) return 1;
  ll res = mod_pow(x*x%mod, n/2, mod);
  if (n & 1) res = res * x % mod;
  return res;
}

int main() {
  ll n;
  cin >> n;
  vector <ll> v(n);
  rep(i, n) cin >> v.at(i);
  sort(v.begin(), v.end());
  vector <ll> sum(n, 0);
  sum.at(0) = v.at(0);
  rep(i, n-1) sum.at(i+1) = sum.at(i) + v.at(i+1);
  ll res = 1;
  for (ll i = n-2; i >= 0; i--) {
    if (v.at(i+1) <= 2*sum.at(i)) {
      res++;
    } else {
      break;
    }
  }
  cout << res << endl;
}

Measured memory_bytes: 1792
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<tuple>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-15
#define mp(a1,a2) make_pair(a1,a2)
typedef long long ll;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int K;
vpint adj[100001];
int d[100001],color[100001],p[100001];
void dijkstra(int s){
	priority_queue<pint> PQ;
	rep(i,K){
		d[i]=INF;
		color[i]=0;
	}
	d[s]=0;
	color[s]=1;
	PQ.push(mp(0,s));
	while(!PQ.empty()){
		pint f=PQ.top();
		PQ.pop();
		int u=f.second;
		color[u]=2;
		if(d[u]< -f.first) continue;
		rep(j,adj[u].size()){
			int v=adj[u][j].first;
			if(color[v]==2) continue;
			if(d[v]>d[u]+adj[u][j].second){
				d[v]=d[u]+adj[u][j].second;
				PQ.push(mp(-d[v],v));
				color[v]=1;
			}
		}
	}
}
int main(){
	scan(K);
	rep(i,K){
		if(i%10!=9) adj[i].push_back(mp((i+1)%K,1));
	}
	rep(i,K){
		adj[i].push_back(mp(i*10%K,0));
	}
	dijkstra(1);
	prin(d[0]+1);
	return 0;
}


Measured memory_bytes: 7164
import numpy as np
N = int(input())
A = list(input().split())

Af =  np.array(A,dtype='float64')
Afans = np.prod(Af,dtype='float64')

if Afans == 0.:
    print('0')
elif Afans >=2e18:
    print('-1')
else:
    Ai =  np.array(A,dtype='int64')
    Aians = np.prod(Ai,dtype='int64')
    if Aians <=np.int64(1e18) and Aians >=np.int64(0):
        print(Aians)
    else:
        print("-1")

Measured memory_bytes: 45484
//
//  main.cpp
//  ABC081-c
//
//  Created by hiroaki on 2019/02/17.
//  Copyright © 2019年 hiroaki. All rights reserved.
//

#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;

int fun(int x){
    return x/2;
}
int main(){
   /* int n,k;
    cin >>n>>k;
    map<int, int> a;*/
    int n;
    cin>>n;
    vector<int> a(n);
    for (int i=0; i<n; i++) {
        cin >>a.at(i);
    }
    int b[205]={0};
    for (int i=0; i<n; i++) {
        while (a[i]%2==0) {
            a[i]=a[i]/2;
            b[i]++;
        }
    }
    int c=1215752192;
    for (int i=0; i<n; i++) {
        if (b[i]<c) {
            c=b[i];
        }
    }
    cout<<c<<endl;
    return 0;
}


Measured memory_bytes: 256
N = int(input())
D = [list(map(int,input().split())) for i in range(N)]
ans = "No"
for i in range(N-2):
    if D[i][0] == D[i][1] and D[i+1][0] == D[i+1][1] and D[i+2][0] == D[i+2][1]:
        ans = "Yes"
print(ans)

Measured memory_bytes: 9188
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



int N;
map<string,ll> MAP;

int main(){

	scanf("%d",&N);

	char buf[11];
	int work[26];

	for(int i = 0; i < N; i++){

		for(int k = 0; k < 26; k++){
			work[k] = 0;
		}
		scanf("%s",buf);

		for(int k = 0; buf[k] != '\0'; k++){

			work[buf[k]-'a']++;
		}

		string tmp_str = "";
		for(int k = 0; k < 26; k++){

			tmp_str += to_string(work[k])+'@';
		}
		MAP[tmp_str]++;
	}

	ll ans = 0;

	for(auto at = MAP.begin(); at != MAP.end(); at++){

		ll num = at->second;
		ans += (num*(num-1))/2;
	}

	printf("%lld\n",ans);

	return 0;
}


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

class SumOf4Integers 
{
    static void Main()
    {
        var q =
            from n in GetProblems().Select( int.Parse )
            let abcd =
                from m in Enumerable.Range( 0, 10000 )
                select m.ToString().Sum( _ => _ - '0' )
            select abcd.Count( m => m == n ) + "\n";
        Console.Write( new string( q.SelectMany( _ => _ ).ToArray() ) );
    }

    static IEnumerable<string> GetProblems()
    {
        var buffer = "";
        while ( !string.IsNullOrEmpty( buffer = Console.ReadLine() ) )
            yield return buffer;
    }
}

Measured memory_bytes: 6144
#include <bits/stdc++.h>
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

typedef long long ll;
#define all(x) (x).begin(),(x).end()


int main(void){
	int n;
	cin >> n;
	vector<int> a(n);
	for(int i=0;i<n;i++)cin >> a[i];
	sort(all(a));
	int max=a[n-1];
	printf("%d ",max);
	int r = a[0];
	int mid=(max+1)/2;
	for(int i=0;i<n-1;i++){
		if(abs(mid-r) > abs(a[i]-mid)){
			r=a[i];
		}
	}
	printf("%d",r);
	
	return 0;
}

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

int main(){
    int S;
    int h, m, s;
    cin>> S;
    h=S/3600;
    m=(S-h*3600)/60;
    s=(S-h*3600)%60;
    cout<<h<<":"<<m<<":"<<s<<endl;
    return 0;
}

Measured memory_bytes: 3108
class SparseMatrix
	def initialize(m, n)
		@m, @n = m, n
		@rows = (1..m).map{ 0 }
		@cols = (1..n).map{ 0 }
	end

	def rank
		save = Marshal.load(Marshal.dump(self))
		rank = 0
		j = 0
		(0..@m-1).each{|i|
			pivot_idx = nil
			j += 1 until j >= @n || pivot_idx = @rows.index{|row| row[j] && row[j] != 0}
			break if j >= @n
			rank += 1

			pivot_row = @rows.delete_at(pivot_idx)
			a = pivot_row[j]
			
			@rows.each{|row|
				b = row[j]
				if b && b != 0
					r = b / a
					pivot_row.each{|k, val|
						row[k] -= r * val
						row.delete(k) if row[k] == 0
					}
				end
			}

			j += 1
		}		
		@rows = save.rows
		rank
	end

	def [](i, j)
		@rows[i][@n-1-j]
	end

	def []=(i, j, x)
		@rows[i] |= (x << (@n-1-j))
		@cols[j] |= (x << (@m-1-i))
	end

	def *(other)
		m = SparseMatrix.new(@m, @n)
		(0..@m-1).each{|i|
			(0..@n-1).each{|j|
				row = @rows[i]
				col = other.cols[j]
				m[i, j] = (row & col).to_s(2).count(?1) % 2
			}
		}
		m			
	end

	attr_reader :rows, :cols
end

def exp(n, k, mod = nil)
	x = SparseMatrix.new(n.rows.size, n.cols.size)
	(0..n.rows.size-1).each{|i|
		x[i,i] = 1
	}
	r = n
	while k > 0
		x *= r if k & 1 == 1
		r *= r		
		if mod
			x %= mod
			r %= mod
		end
		k >>= 1
	end
	x
end

n = gets.to_i
mat = SparseMatrix.new(n, n)
a = (0..n-1).map { gets.split.map &:to_i }
(0..n-1).each{|i|
	(0..n-1).each{|j|
		mat[i, j] = a[i][j]
	}
}
	
v = (1..n).map{ gets.to_i }
t = gets.to_i

mat = exp(mat, t)

a = [0] * n
(0..n-1).each{|i|
	(0..n-1).each{|j|
		a[i] |= (1 << j) if mat[i, j] == 1
	}
}
(0..n-1).each{|i|
	a[i] |= (v[i] << n)
}

require 'set'
used = Set.new
(0..n-1).each{|i|
	j = (0..n-1).find{|j| a[j][i] == 1 && !used.include?(j)}
	next if !j
	used << j
	(0..n-1).each{|k|
		next if k == j || a[k][i] == 0
		a[k] ^= a[j]
	}
}

if a.include?(1 << n) 
	puts 'none'
elsif a.include?(0)
	puts 'ambiguous'
else
	puts a.sort_by{|x| x & ((1 << n) -1 )}.map{|x| x >> n}.join(" ")
end

Measured memory_bytes: 11300
import sys
input = sys.stdin.readline

def main():
    N = int(input())
    ans = []
    for i in range(1, 10):
        for j in range(1, 10):
           ans.append(i * j)

    if N in ans:
        print("Yes")
    else:
        print("No")

    

if __name__ == '__main__':
    main()



Measured memory_bytes: 2940
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
#include <time.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


int N;
int in_num[101];
int tmp_depth;
vector<int> G[101],GROUP[101];

int boss[101],height[101];

int get_boss(int id){
	if(boss[id] == id)return id;
	else{
		return boss[id] = get_boss(boss[id]);
	}
}


void unite(int x,int y){
	int boss_x = get_boss(x);
	int boss_y = get_boss(y);

	if(boss_x == boss_y)return;

	if(height[x] > height[y]){

		boss[boss_y] = boss_x;

	}else if(height[x] < height[y]){

		boss[boss_x] = boss_y;

	}else{ //height[x] == height[y]

		boss[boss_y] = boss_x;
		height[x]++;
	}
}

void init(){
	for(int i = 1; i <= 100; i++){
		boss[i] = i;
		height[i] = 0;
	}
}

void recursive(bool visited[101],int node_id,int depth,int group_id){
	tmp_depth = max(tmp_depth,depth);

	for(int i = 0; i < G[node_id].size(); i++){
		if(visited[G[node_id][i]])continue;

		bool next_visited[101];
		for(int k = 0; k < GROUP[group_id].size(); k++)next_visited[GROUP[group_id][k]] = visited[GROUP[group_id][k]];	//???????????°?????????????????±?????????????¶??????°??????
		next_visited[G[node_id][i]] = true;
		recursive(next_visited,G[node_id][i],depth+1,group_id);
	}
}


void func(){

	for(int i = 1; i <= 100; i++){
		in_num[i] = 0;
		G[i].clear();
		GROUP[i].clear();
	}

	init();

	int from,to;
	for(int loop = 0; loop < N; loop++){
		scanf("%d %d",&from,&to);
		G[from].push_back(to);
		G[to].push_back(from);
		in_num[to]++;
		in_num[from]++;
		unite(from,to);
	}

	for(int i = 1; i <= 100; i++){
		if(in_num[i] == 0)continue;
		GROUP[get_boss(i)].push_back(i);
	}

	int max_depth = 1,min_in_num;
	bool visited[101];
	for(int i = 1; i <= 100; i++){
		if(GROUP[i].size() == 0 || GROUP[i].size() < max_depth)continue;

		min_in_num = BIG_NUM;
		for(int k = 0; k < GROUP[i].size(); k++){
			min_in_num = min(min_in_num,in_num[GROUP[i][k]]);
		}

		for(int k = 0; k < GROUP[i].size(); k++){
			if(in_num[GROUP[i][k]] == min_in_num){
				for(int p = 0; p < GROUP[i].size(); p++)visited[GROUP[i][p]] = false;
				visited[GROUP[i][k]] = true;
				tmp_depth = 0;
				recursive(visited,GROUP[i][k],1,i);
				max_depth = max(max_depth,tmp_depth);
			}
		}
	}
	printf("%d\n",max_depth);
}


int main(){

	while(true){
		scanf("%d",&N);
		if(N == 0)break;

		func();
	}

	return 0;
}

Measured memory_bytes: 3216
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int INF = 0x3f3f3f3f;
const ll inf = 0x3f3f3f3f3f3f3f3f;
const int N = 5e5 + 10;
const ll mod = 1e9 + 7;
int n;
ll a[N];
ll ans, mx;
int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) {
		scanf("%lld", &a[i]);
		ans += max(0ll, mx - a[i]);
		mx = max(mx, a[i]);
	}
	printf("%lld\n", ans);
	return 0;
}

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

using namespace std;

int main()
{
  long long n;
  scanf("%lld", &n);
  printf("%lld\n", n * (n - 1) / 2);
}


Measured memory_bytes: 3812
#include <stdio.h>

enum {
	LEFT,
	RIGHT,
	UP,
	DOWN
};

int iskabe(char[9][6],int,int,int);
int getleft(int);
int getright(int);
void move(int*,int*,int);
void printdir(int);

int main(void) {
	char kabe[9][6];
	int x,y;
	int direction;
	int i;
	for(i=0;i<9;i++)scanf("%s",kabe[i]);
	x=0;y=0;direction=RIGHT;
	move(&x,&y,direction);
	while(x!=0 || y!=0) {
		if(iskabe(kabe,x,y,getleft(direction)))
			direction=getleft(direction);
		else if(iskabe(kabe,x,y,direction));
		else if(iskabe(kabe,x,y,getright(direction)))
			direction=getright(direction);
		else direction=getright(getright(direction));
		move(&x,&y,direction);
	}
	printf("\n");
	return 0;
}

int iskabe(char kabe[9][6],int x,int y,int dir) {
	switch(dir) {
		case LEFT:
			if(x<=0)return 0;
			if(kabe[y*2][x-1]=='1')return 1; else return 0;
			break;
		case RIGHT:
			if(x>4)return 0;
			if(kabe[y*2][x]=='1')return 1; else return 0;
			break;
		case UP:
			if(y<=0)return 0;
			if(kabe[y*2-1][x]=='1')return 1; else return 0;
			break;
		case DOWN:
			if(y>4)return 0;
			if(kabe[y*2+1][x]=='1')return 1; else return 0;
			break;
	}
	return 0;
}

int getleft(int dir) {
	switch(dir) {
		case LEFT:return DOWN;break;
		case RIGHT:return UP;break;
		case UP:return LEFT;break;
		case DOWN:return RIGHT;break;
	}
	return 0;
}

int getright(int dir) {
	switch(dir) {
		case LEFT:return UP;break;
		case RIGHT:return DOWN;break;
		case UP:return RIGHT;break;
		case DOWN:return LEFT;break;
	}
	return 0;
}

void move(int* x,int* y,int dir) {
	switch(dir) {
		case LEFT:
			(*x)--;
			printf("L");
			break;
		case RIGHT:
			(*x)++;
			printf("R");
			break;
		case UP:
			(*y)--;
			printf("U");
			break;
		case DOWN:
			(*y)++;
			printf("D");
			break;
	}
}

Measured memory_bytes: 0
// include
// ------------------------------------------------
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

// func
// ------------------------------------------------
int CalcSumOfDigit(int n);      // 各桁の和を計算する。
string upper(string str);       // 英字を大文字に変換する。
string lower(string str);       // 英字を小文字に変換する。

// define
// ------------------------------------------------
#define all(a)        (a).begin(),(a).end()
#define rall(a)       (a).rbegin(),(a).rend()
#define pb            push_back
#define sz(a)         int((a).size())
#define rep(i,n)      for(int(i)=0;(i)<(n);(i)++)
#define repe(i,n)     for(int(i)=0;(i)<=(n);(i)++)
#define vsort(v)      sort((v).begin(),(v).end())
#define rvsort(v)     sort(rall((v)))
#define vi            vector<int>

const int INF = 1e9;

// code
// ------------------------------------------------
int main() {

  int n;cin>>n;

  cout << n / 3;



  return 0;
}

// funcの実体
// ------------------------------------------------
int CalcSumOfDigit(int n)
{
  int s = 0;
  while(n)
  {
    s += n % 10;
    n = n / 10;
  }
  return s;
}

string upper(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(97 <= *itr && *itr <= 122)
    {
      *itr = *itr - 32;
    }
  }
  return str;
}

string lower(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(65 <= *itr && *itr <= 90)
    {
      *itr = *itr + 32;
    }
  }
  return str;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>

using namespace std;

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = n;i >= m;i--)
#define REPO(i, n) for(int i = 1;i <= n;i++)
#define ll long long
#define INF 1999999999
#define MINF -1999999999
#define ALL(n) n.begin(),n.end()

int main() {
	int a;
	cin >> a;
	cout << 48 -   a << endl;
}

Measured memory_bytes: 384
Bingo_number = [list(map(int, input().split())) for i in range(3)]
N = int(input())
N_number = [list(map(int, input().split())) for i in range(N)]

for i in N_number:
    for j in Bingo_number:
        for k in range(len(Bingo_number)):
            if i[0] == j[k]:
                j[k] = "+"
# print(Bingo_number)

ans = 0
count2 = 0
count3 = 0

for i in range(3):
    count = 0
    count1 = 0
    for j in range(3):
        if Bingo_number[i][j] == "+":
            count += 1
        if Bingo_number[j][i] == "+":
            count1 += 1
        if i == j:
            if Bingo_number[i][j] == "+":
                count2 += 1
        if i + j == 2:
            if Bingo_number[i][j] == "+":
                count3 += 1
        # print(count, count1, count2, count3)
    if count == 3 or count1 == 3 or count2 == 3 or count3 == 3:
        ans += 1

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


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

int main(){
  int n,i,j;
  cin >> n;
  vector<char> c(10);
  vector<string> s(n);
  for(i=0;i<n;i++){
    for(j=0;j<10;j++){
      cin >> c.at(j);
    }
    sort(c.begin(),c.end());
    for(j=0;j<10;j++){
      s.at(i) += c.at(j);
    }
  }
  sort(s.begin(),s.end());
  ll x=1,a=0;
  /*cout << s.at(0) << " " << x << endl;*/
  for(i=1;i<n;i++){
    if(s.at(i)!=s.at(i-1)){
      a += x*(x-1)/2;
      x=1;
    }else{
      x++;
    }
    /*cout << s.at(i) << " " << x << endl;*/
  }
  a += x*(x-1)/2;
  
  cout << a << endl;
}

Measured memory_bytes: 6408