akhauriyash/Code-Regression huggingface dataset:
#![allow(unused_imports)]
// use itertools::Itertools;
use proconio::{input, marker::*};

fn main() {
    input! {
        a: isize,
        op: char,
        b: isize
    };
    let rs = match op {
        '+' => a + b,
        '-' => a - b,
        _ => unreachable!(),
    };
    println!("{}", rs);
}


Measured memory_bytes: 2096
#include <bits/stdc++.h>
#define lol long long
using namespace std;
int main(){
    lol a,ans[100]={};
    string s,t;
    cin>>a;
    ans[0]=2;
    ans[1]=1;
    for(lol i=2;i<=a;i++){
        ans[i]=ans[i-1]+ans[i-2];
    }
    cout<<ans[a]<<"\n";
    return(0);
}

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

int main() {
    int A1,A2,A3;
    cin >> A1 >> A2 >> A3;

    int B1 = abs(A1 - A2);
    int B2 = abs(A2 - A3);
    int B3 = abs(A3 - A1);
    
    cout << min({B1+B2, B2+B3, B3+B1}) << endl;
}

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

int main() {
    long long int N, M, K;
    cin >> N >> M >> K;

    vector<long long int> desk_A(N);
    vector<long long int> desk_A_total(N + 1, 0);
    vector<long long int> desk_B(M);
    vector<long long int> desk_B_total(M + 1, 0);

    for (long long int i = 0; i < N; ++i) {
        cin >> desk_A[i];
        desk_A_total[i + 1] = desk_A_total[i] + desk_A[i];
    }

    for (long long int i = 0; i < M; ++i) {
        cin >> desk_B[i];
        desk_B_total[i + 1] = desk_B_total[i] + desk_B[i];
    }

    long long int ans = 0;
    long long int j = M;

    for (long long int i = 0; i < N + 1; ++i) {
        if (desk_A_total[i] > K) {
            break;
        }

        while (desk_B_total[j] + desk_A_total[i] > K) {
            j -= 1;
        }

        ans = max(ans, i + j);
    }

    cout << ans << endl;

}

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

int main(){
  
  string a;
  cin >> a;
  
  if( a.at(2) == a.at(3) && a.at(4) == a.at(5) ){
    
    cout << "Yes" << endl;
    
  }
  
  else{
    
    cout << "No" << endl;
    
  }
  
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define lop(i, n) for(i=0; i<n; i++)

int main()
{
	int n, i, sum, sum1=0, sum2=0, min=100, dif, T=1;
	int W[100];
	
	scanf("%d", &n);
	lop(i, n){ scanf("%d", &W[i]); }
	
	while(T<=n){
		for(i=0; i<T; i++){
			sum1+=W[i];
		}
		for(i=T; i<n; i++){
			sum2+=W[i];
		}
		sum=sum1-sum2;
		dif=abs(sum);
		if(dif<min){ min=dif; }
		sum1=0; sum2=0;
		T++;
	}
	
	printf("%d", min);
	
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define all(a)  (a).begin(),(a).end()
typedef long long ll;
ll mod=1000000007;

int main() {
  int n,a,b;cin>>n>>a>>b;
  if(a==1 && b-a-1==0){
    cout << "Borys" << endl;
  } else{
    if( (b-a-1)%2==0){
      cout << "Borys" << endl;
    } else {
      cout << "Alice" << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 636
import numpy as np

N = int(input())
A = np.array([input().split() for _ in range(N)], dtype=np.int64).reshape(N,N)

INF = 10**15
np.fill_diagonal(A, INF)

ans = 0
for i in range(N-1):
    for j in range(i+1,N):
        detour = np.min(A[i]+A[j])
        if detour > A[i][j]:
            ans+=A[i][j]
        elif detour < A[i][j]:
            print(-1)
            exit()
print(ans)

Measured memory_bytes: 24680
#include <bits/stdc++.h>
#define DUMP(x)  cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define IFOR(i, m, n) for(int i = n - 1; i >= m; i-- )
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
const ll INF = LLONG_MAX;
/* テンプレートここまで */

int main() {
  ll N, K; cin >> N;
  vector<ll> cnt(1e5+1, 0);
  REP(i, N){
    ll a;
    cin >> a;
    cnt[a]++;
  }
  ll x = 0;
  ll y = 0;
  REP(i, 1e5+1){
    if(cnt[i] == 0) continue;
    if(cnt[i]%2 == 0) y++;
    else x++;
  }

  cout << x + y - y%2 << endl;


}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll MOD = 1000000007;
const ll INF = 9999999999;
template<class T> inline bool chmin(T& a, T b){if (a>b){a = b; return true;}return false;}
template<class T> inline bool chmax(T& a, T b){if (a<b){a = b; return true;}return false;}
template<class T> inline T powerM(T a,T b){if (b==0) return a;
  T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }

int main() {
  int n,m; cin >>n >>m;
  vector<bool> ac(n, false);
  vector<int> penalty(n, 0);
  for (int i=0; i<m; i++){
    int p; cin >>p; p--;
    string s; cin >>s;
    if (s == "AC") ac.at(p) = true;
    if (s == "WA" && !ac.at(p)) penalty.at(p)++;
  }
  int accnt = 0, pencnt = 0;
  for (int i=0; i<n; i++){
    accnt += ac.at(i);
    if (ac.at(i)) pencnt += penalty.at(i);
  }
  cout <<accnt <<" " <<pencnt <<endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
long long s[100007],t[100007];
int main(){
    long long n,m,q;
    scanf("%lld%lld%lld",&n,&m,&q);
    for(int i=1;i<=n;i++)
        scanf("%lld",&s[i]);
    s[n+1]=1e18;
    s[0]=-1e18;
    sort(s,s+n+2);
    for(int i=1;i<=m;i++)
        scanf("%lld",&t[i]);
    t[m+1]=1e18;
    t[0]=-1e18;
    sort(t,t+m+2);
    long long x=0;
    long long tmp1=0,tmp2=0;
    long long ans=0;
    for(int i=1;i<=q;i++){
        scanf("%lld",&x);
        tmp1=lower_bound(s,s+n+2,x)-s;
        tmp2=lower_bound(t,t+m+2,x)-t;
        ans=1e18;
        for(int j=tmp1-1;j<tmp1+1;j++){
            for(int k=tmp2-1;k<tmp2+1;k++){
                long long tmp3=labs(x-s[j])+labs(s[j]-t[k]);
                long long tmp4=labs(x-t[k])+labs(s[j]-t[k]);
                ans=min(ans,tmp3);
                ans=min(ans,tmp4);
            }
        }
        printf("%lld\n",ans);
    }
    return 0;
}


Measured memory_bytes: 2816
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
using namespace std;
#define INF 2147483647
#define LINF 9223372036854775807
#define MOD 1000000007
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define repb(i,n) for(int i=n-1;i>=0;i--)
#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
typedef pair<int,int> P;
//typedef long long int ll;

int ans; 

signed main(){

	int k,n;
	cin>>n>>k;
	cout<<n-k+1<<endl;

}


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

int main(){
    char c;
    cin >> c;
    
    if((c == 'a') || (c == 'i') || (c == 'u') || (c == 'e') || (c == 'o')){
        //母音のとき
        cout << "vowel" << endl;
    }else{
        //子音のとき
        cout << "consonant" << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
using namespace std;
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef long double ld;
const ll inf=1e9+7;
const ll mod=1e9+7;
int main(){
    ll n;cin>>n;
    ll nowt=1,nowa=1;
    rep(i,n){
        ll t,a;cin>>t>>a;
        ll now=inf*inf;
        if(((nowt-1)/t+1)*a>=nowa){
            now=min(now,((nowt-1)/t+1)*(t+a));
        }
        if(((nowa-1)/a+1)*t>=nowt){
            now=min(now,((nowa-1)/a+1)*(t+a));
        }
        nowt=now/(t+a)*t;
        nowa=now/(t+a)*a;
    }
    cout<<nowa+nowt<<endl;
}

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

int main(){
    int k,a,b;
    cin>>k>>a>>b;
    ll ans=0;
    if(k<=a||b-a<=2)ans=k+1;
    else{
        if(k%2==a%2)ans=a+ll(b-a)*((k-a+1)/2)+1;
        else ans=a+ll(b-a)*((k-a+1)/2);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		String string="";
		int o=0;
		for(;;) {
			String str=sc.next();
			if(str.equals("-"))break;
			int i=sc.nextInt();
			int [] a=new int[i];
			for(int j=0;j<i;j++) {
				a[j]=sc.nextInt();
			}
			for(int k=0;k<i;k++) {
				char [] ch=str.toCharArray();
				char [] ch1=new char [a[k]];
				for(int u=0;u<a[k];u++) {
					ch1[u]=ch[u];
					ch[u]='\u0000';
				}
				String str1=String.valueOf(ch);
				String str2=String.valueOf(ch1);
				str=str1.trim()+str2;
			}
			if(o==0) {
				string=string+str;
			}
			else {
				string=string+"\n"+str;
			}
			o++;
		}
		System.out.println(string);
		sc.close();
	}
}


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

using namespace std;

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

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

int N;
int H[16], W[16];
char C[4][4];
int c[4][4];

string clr = "RGB";

signed main()
{
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  cin >> N;
  rep(i, N) cin >> H[i] >> W[i];

  rep(i, 4) rep(j, 4) cin >> C[i][j], c[i][j] = clr.find(C[i][j]);

  int d[1<<16];
  memset(d, -1, sizeof(d));
  d[0] = 0;
  queue<int> que;
  que.push(0);
  while(!que.empty()) {
    int bit = que.front(); que.pop();
    if(bit == (1<<16)-1) break;
    rep(i, 3) rep(j, N) {
      reps(k, -H[j]+1, 4) reps(l, -W[j]+1, 4) {
	int nbit = bit;
	reps(y, max(k, 0LL), min(k+H[j], 4LL)) {
	  reps(x, max(l, 0LL), min(l+W[j], 4LL)) {
	    int mask = 1<<(y*4+x);
	    if(c[y][x] == i && !((bit >> (y*4+x)) & 1) ||
	       c[y][x] != i && (bit >> (y*4+x)) & 1) {
	      nbit ^= mask;
	    }
	  }
	}
	if(d[nbit] == -1) {
	  d[nbit] = d[bit] + 1;
	  que.push(nbit);
	}
      }
    }
  }

  cout << d[(1<<16)-1] << endl;

  return 0;
}

Measured memory_bytes: 3784
using System;
using System.Collections.Generic;
using System.Linq;
using static Atcoder;
using System.Threading.Tasks;
using System.ComponentModel;

public class Hello
{
    private const int INF = 1000000007;
    public static void Main()
    {
        int[] inp = IntLine();
        int N = inp[0], K = inp[1];
        int[] h = IntLine();
        int[] dp = new int[100010];
        for (int i = 0; i <= N; i++) dp[i] = INF;
        dp[0] = 0;
        for (int i = 0; i < N; i++)
        {
            for (int k = 1; k <= K; k++)
            {
                if (i + k == N) break ;
                dp[i + k] = Math.Min(dp[i + k], dp[i] + Math.Abs(h[i + k] - h[i]));
                //Console.WriteLine(i + " -> " + (i + k) + " : " + Math.Abs(h[i + k] - h[i]));
            }
        }
        Console.WriteLine(dp[N - 1]);
    }
}



public class Atcoder
{
    public static void Swap<T>(ref T a, ref T b)
    {
        var t = a;
        a = b;
        b = t;
    }
    public static int GCD(int a, int b)
    {
        if (a < b) Swap(ref a, ref b);
        int d = a % b;
        while (b != 0)
        {
            d = a % b;
            a = b;
            b = d;
        }
        return a;
    }
    public static long LCM(int a, int b)
    {
        return (long)a * b / GCD(a, b);
    }
    public static string StrReverce(string s)
    {
        return new string(s.Reverse().ToArray());
    }
    public static int IntRead()
    {
        return int.Parse(Console.ReadLine());
    }
    public static bool IsPrime(int n)
    {
        if (n < 2) return false;
        if (n == 2) return true;
        if (n % 2 == 0) return false;

        //double sqrtNum = Math.Sqrt(n);
        for (int i = 3; i < n; i += 2)
        {
            if (n % i == 0) return false;
        }
        return true;
    }
    public static string[] SpRead(char c)
    {
        return Console.ReadLine().Split(c);
    }
    public static long[] LSRead()
    {
        return Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
    }
    public static long Combination(int n, int r)
    {
        if (n == r) return 1;
        return
            Enumerable.Range((n - r + 1), r).ToList().Aggregate((now, next) => now * next) /
            Enumerable.Range(1, r).ToList().Aggregate((now, next) => now * next);
    }
    public static long Permutation(int n, int r)
    {
        if (n == r) return 1;
        return
            Enumerable.Range((n - r), r).ToList().Aggregate((now, next) => now * next);
    }
    public static long LongRead()
    {
        return long.Parse(Console.ReadLine());
    }
    public static long[] LongLine()
    {
        return Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
    }
    public static int[] IntLine()
    {
        return Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
    }
}


Measured memory_bytes: 19808
#include <algorithm>
#include <string.h>
#include <iostream>
#include <stdio.h>
#include <string>

using namespace std;

typedef long long ll;

const ll N = 110;

ll d[N][3];
ll n;

int main() {
	cin >> n;

	for (ll i = 1; i <= n; i++) {
		cin >> d[i][1] >> d[i][2];
	}

	ll idx = 0;
	for (ll i = 1; i <= n; i++) {
		if (d[i][1] == d[i][2]) {
			idx++;
		}
		else {
			idx = 0;
		}

		if (idx >= 3) {
			cout << "Yes" << endl;
			return 0;
		}
	}

	cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(c) begin(c), end(c)
#define dump(x) cerr << __LINE__ << ":\t" #x " = " << (x) << endl

int main(){
    int n, m, t;
    while(cin >> n >> m >> t && n){
        int a[110];
        a[0] = 0;
        rep(i, n) cin >> a[i+1];
        a[n+1] = t;
        int ans = 0;
        rep(i, n+1) ans += max(0, a[i+1] - a[i] - ((i==0 || i==n) ? m : 2*m));
        cout << ans << endl;
    }
}

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

int main(){ 
    string s; cin>>s;
    int ans=0;

    for(int i=0;i<3;i++){
        if(s.at(i)=='1'){ ans++;
        }
        }

    cout<<ans<<endl;
    return 0;
    }


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int const nax = 3e5 + 10, m = 10000;
int f[nax];

int g (int x, int y, int z) {
    return x * x + y * y + z * z + x * y + y * z + z * x;
}

int main () {

    for (int x = 1 ; x <= 100 ; ++ x)
    for (int y = 1 ; y <= 100 ; ++ y)
    for (int z = 1 ; z <= 100 ; ++ z) {
        f[g(x, y, z)] ++ ;
    }

    int n;
    scanf("%d", &n);

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

}
/*
    Good Luck
        -Lucina
*/


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

int main() {
    int N; cin >> N;
    vector<int> A(N+1);
    vector<int> index(N+1);
    for (int i = 1; i <= N; i++) {
        cin >> A[i];
        index[A[i]] = i;
    }
    ll ans = 0;
    set<int> position;
    for (int i = 1; i <= N; i++) {
        auto itr = position.upper_bound(index[i]);
        ll l, r;
        if (itr == position.end()) r = N + 1 - index[i];
        else r = (*itr) - index[i];

        if (itr == position.begin()) l = index[i];
        else l = index[i] - *(--itr);

        ans += i * l * r;
        position.insert(index[i]);
    }
    cout << ans << endl;
}


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

int main(void){
    long k, x;
    
    cin >> k >> x;

    long left = max<long>((long)-1000000, x-k+1);
    long right = min<long>((long)1000000, x+k-1);


    for (long i = left; i <= right; i++){
        cout << i << " ";
    }
    cout << endl;
}

Measured memory_bytes: 256
#coding=UTF-8

mozir=input()
hyo=mozir.split(' ')

ans=True
for idx in range(0,2,1):
    ras=hyo[idx][len(hyo[idx])-1]
    cap=hyo[idx+1][0]
    if ras != cap:
        ans = False

if ans:
    print('YES')
else:
    print('NO')


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define ll long long
#define rep(X,N) for(int X = 0; X < N; X++)
#define repvin(V,N) for(int i = 0; i < N; i++) {int tmp; cin >> tmp; V.push_back(tmp);}

using namespace std;

int main(){

    ll n,k;
    cin >> n >> k;

    //a,b,cがそれぞれkの倍数か,余りがk/2のとき成立するので

    ll ans = 0;
    ll tmp = n / k;
    ans = tmp * tmp * tmp;

    if(k % 2 == 0){
        if(n - (n / k) * k >= k / 2){
            tmp = n / k + 1;
            ans = ans + tmp * tmp * tmp;
        }else{
            ans = ans * 2;
        }
    }

    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <string>
#include <iomanip>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <complex>
#include <ctime>


using namespace std;

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

//マクロ定義
#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; }

using Graph = vector<vector<ll>>;

#define ketasitei setprecision(15) //15桁表示

const ll MOD = 1000000007;
const double PI = 3.1415926535897932;


int main(void)

{
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << ketasitei;

	int k, a, b;
	cin >> k >> a >> b;
	for (int i = 1; i < 10000; i++)
	{
		if (a <= k * i && k * i <= b)
		{
			cout << "OK" << endl;
			ret;
		}
	}
	cout << "NG" << endl;

	return 0;
}

Measured memory_bytes: 3648
#include <stdio.h>
#include <vector>
#include <algorithm>

using namespace std;

typedef long long lli;

int a[100001], b[100001], n;

lli dnc(int l, int r) {
	if (l > r) return 0;
	if (l == r) return b[l] > 0;
	int mid = (l + r) / 2;
	lli ret = dnc(l, mid) + dnc(mid + 1, r);
	vector<int> L, R;
	int cur = 0;
	for (int i = mid; i >= l; i--) {
		cur += b[i];
		L.push_back(cur);
	}
	cur = 0;
	for (int i = mid + 1; i <= r; i++) {
		cur += b[i];
		R.push_back(cur);
	}
	sort(L.begin(), L.end());
	for (int i = 0; i < R.size(); i++) {
		if (L[0] >= -R[i]) ret += L.size();
		else if (L.back() < -R[i]) continue;
		else{
			int lo = 0, hi = L.size() - 1;
			while (lo + 1 < hi) {
				int mid = (lo + hi) / 2;
				if (L[mid] >= -R[i]) hi = mid;
				else lo = mid;
			}
			ret += L.size() - hi;
		}
	}
	return ret;
}

lli f(int k) {
	for (int i = 1; i <= n; i++) {
		if (a[i] < k) b[i] = -1;
		else b[i] = 1;
	}
	return dnc(1, n);
}

int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; i++)
		scanf("%d", &a[i]);
	lli C = (lli)n*(n + 1LL) / 2;
	int lo = 1, hi = 1000000001;
	while (lo + 1 < hi) {
		int mid = (lo + hi) / 2;
		if (f(mid) >= (C + 1) / 2) lo = mid;
		else hi = mid;
	}
	printf("%d\n", lo);
	return 0;
}

Measured memory_bytes: 1728
#include<iostream>
using namespace std;
int n,s[3][105],x,ans;
int main()
{
    cin>>n;
    for(int i=1;i<=2;i++)
        for(int j=1;j<=n;j++)
            cin>>x,s[i][j]=s[i][j-1]+x;
    for(int i=1;i<=n;i++)
        ans=max(ans,s[1][i]+s[2][n]-s[2][i-1]);
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define i64 long long
using namespace std;
int main() {
	int n,m,k, item_no, cnt[32]={0};
	cin>>n>>m;
	for(int i=0;i<n;i++){
		cin>>k;
		while(k--){
			cin>>item_no;
			cnt[item_no]++;
		}
	}
	int ans = 0;
	for(int i=1;i<=m;i++) if(cnt[i]==n) ans++;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <climits>
#include <algorithm>
using namespace std;
int main(void){
    // Your code here!
    int A, B, M;
    int x, y, c;
    int ans;
    int a[100000], b[100000], P, amin, bmin;
    
    scanf("%d %d %d", &A, &B, &M);
    
    for(int i = 0; i < A; i++)
    {
        if(i == 0)
        {
            scanf("%d", &a[i]);
            amin = a[i];
        }
        else
        {
            scanf("%d", &a[i]);
            amin = (amin > a[i])? a[i]:amin;
        }
    }
    
    for(int i = 0; i < B; i++)
    {
        if(i == 0)
        {
            scanf("%d", &b[i]);
            bmin = b[i];
        }
        else
        {
            scanf("%d", &b[i]);
            bmin = (bmin > b[i])? b[i]:bmin;
        }
    }
    
    for(int i = 0; i < M; i++)
    {
        scanf("%d %d %d", &x, &y, &c);
        P = a[x-1] + b[y-1] - c; 
        if(i == 0)
        {
            ans = P;
        }
        else
        {
            ans = (ans > P)? P:ans;
        }
    }
    
    printf("%d\n", (ans < amin + bmin)? ans:(amin+bmin));
}


Measured memory_bytes: 1024
#include <iostream>
#include <queue>
#include <vector>
#include <cstdio>

using namespace std;

int main() {

  while(1) {
  
    int n;
    cin >> n;
    int m;
    cin >> m;

    if(n==0 && m ==0) break;
  
    vector <int> re[502];

    queue <int > Q;
    int a, b;
    for(int i=0;i<m;i++) {
      cin >> a >> b;
      re[a].push_back(b);
      re[b].push_back(a);
    }

    int t;
    int count = -1;
    Q.push(1);

    int dis[502];
    for(int i=0;i<=n;i++) dis[i] = -1;
  
    
  
    while(Q.empty() != 1){
    
      t = Q.front();
      Q.pop();
    
      for(int i=0;i<re[t].size();i++) {
	if(dis[re[t][i]] == -1 && dis[t]+1 < 2) {
	  dis[re[t][i]] = dis[t] + 1;
	  count++;
	  //  printf("dis[i%d](%d) | dis[t%d](%d) | re[%d][%d](%d)\n",i,dis[re[t][i]],t,dis[t],t,i,re[t][i]);
	  Q.push(re[t][i]);
	  //cout << "Q.front == " << Q.front() << endl;
	}
      }
    }
  
    cout << count << endl;
  
  }

  return 0;
}

Measured memory_bytes: 1360
package main

import (
	"fmt"
	"strings"
)

func scanInput() (n int, slice []int) {
	fmt.Scanf("%d", &n)
	slice = make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scanf("%d", &slice[i])
	}
	return
}

func printSlice(slice []int) {
	fmt.Println(strings.Trim(strings.Join(strings.Fields(fmt.Sprint(slice)), " "), "[]"))
}

func main() {
	_, slice := scanInput()

	printSlice(slice)

	solve(slice)
}

func solve(nums []int) {
	l := len(nums)
	for i := 1; i < l; i++ {
		v := nums[i]
		j := i - 1
		for j >= 0 && nums[j] > v {
			nums[j+1] = nums[j]
			j--
		}
		nums[j+1] = v

		printSlice(nums)
	}
}



Measured memory_bytes: 1572
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <array>
#include <vector>
#include <utility>
#include <bitset>
#include <queue>
#include <unordered_map>
#include <unordered_set>

using namespace std;

using ll = long long;
using p = pair<ll, ll>;
char list[5] = {'M', 'A', 'R', 'C', 'H'};
unordered_map<char, ll> m;

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

    for (ll i = 0; i < N; i++) {
        string s;
        cin >> s;
        m[s[0]]++;
    }

    ll ans = 0;
    for (ll i = 0; i < 3; i++) {
        for (ll j = i + 1; j < 4; j++) {
            for (ll k = j + 1; k < 5; k++) {
                ans += m[list[i]] * m[list[j]] * m[list[k]];
            }
        }
    }

    cout << ans << endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <tuple>
#include <bitset>
#include <memory>
#include <cmath>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <cfloat>
#include <cassert>
#include <random>

struct Edge {
	int to, distance;
};
int main() {
	int n, r; std::cin >> n >> r;
	std::vector<std::vector<Edge>> machines(n + 1);
	std::vector<int> calories(n);
	for (auto i = 0; i < n; ++i) {
		int t, e; std::cin >> t >> e;
		machines[0].push_back(Edge{ i + 1, t });
		calories[i] = e;
	}
	for (auto i = 0; i < r; ++i) {
		int a, b, c; std::cin >> a >> b >> c;
		machines[b].push_back(Edge{ a, c - 1 });
	}
	std::vector<int> min_time(n + 1, INT_MAX); min_time[0] = 0;
	auto comparator = [](const std::pair<int, int>& a, const std::pair<int, int>& b) {return a.first > b.first; };
	std::priority_queue<std::pair<int, int>, std::vector<std::pair<int, int>>, decltype(comparator)> queue(comparator); queue.emplace(0, 0);
	while (!queue.empty()) {
		auto top = queue.top(); queue.pop();
		if (min_time[top.second] != top.first) continue;
		for (const auto& e : machines[top.second]) {
			if (min_time[e.to] > top.first + e.distance) {
				min_time[e.to] = top.first + e.distance;
				queue.emplace(min_time[e.to], e.to);
			}
		}
	}
	long long int sum = 0;
	for (auto i = 0; i < n; ++i) {
		sum += static_cast<long long int>(calories[i]) * min_time[i + 1];
	}
	std::cout << sum << '\n';
}



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

using namespace std;

int main () {
  int N, M;
  cin >> N >> M;
  int K[M];
  int s[M][11];
  for (int i=0; i<M; i++) {
    cin >> K[i];
    for (int j = 0; j<K[i]; j++) cin >> s[i][j];
  }  
  int p[M];
  for (int i = 0; i< M; i++) cin >> p[i];
  
  int ans = 0;
  for (int i = 0; i< pow(2,N); i++) {
    bool flag = true;
    for (int j=0; j<M; j++) {
      int c = 0;
      for (int k = 0; k <K[j]; k++) {
        if (1<<(s[j][k]-1) & i) c++;
      }
      if (c%2 != p[j]) flag = false;
      //cout << "**" << c << "**" << endl; 

    }
    if (flag) ans++;
  }

  cout << ans;
}

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

int main() {
  int N, M;
  cin >> N >> M;
  int count;
  count = (N + M)*(N + M - 1)/2 - M*N;
  cout << count << endl;
  
}


Measured memory_bytes: 256
#include <cstdio>

int main(void){
    char str[3];
    int num[3];
    num[0] = 0;
    num[1] = 0;
    num[2] = 0;
    scanf("%s", str);
    for(int i = 0; i < 3; i++){
        num[str[i] - 'a'] = 1;
    }
    if(num[0] == 0 || (num[1] == 0 || num[2] == 0)){
        printf("No\n");
    }else{
        printf("Yes\n");
    }
    return 0;

}

Measured memory_bytes: 128
#include <stdio.h>
#include <algorithm>
#include <deque>
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 main() {

	deque<int> DEQ;

	int num_query;
	scanf("%d", &num_query);

	int command, A, B;

	for (int loop = 0; loop < num_query; loop++) {
		scanf("%d", &command);

		switch (command) {
		case 0:

			scanf("%d %d", &A, &B);
			if (A == 0) {
				DEQ.push_front(B);
			}
			else {
				DEQ.push_back(B);
			}
			break;
		case 1:

			scanf("%d", &A);
			printf("%d\n", DEQ[A]);

			break;
		case 2:
			scanf("%d", &A);
			if (A == 0) {
				DEQ.pop_front();
			}
			else {
				DEQ.pop_back();
			}
			break;
		}
	}

	return 0;
}



Measured memory_bytes: 4108
while true
  h, w = gets.chomp.split.map(&:to_i)
  break if h == 0 && w == 0
  for i in 1..h
    if i == 1 || i == h
      puts "#" * w
    else
      puts "#" + "." * (w - 2) + "#"
    end
  end
  print "\n"
end

Measured memory_bytes: 8812
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
using namespace std;

#define rep(i, e) for (int i = 0; i < e; i++)
#define repp(i, s, e) for (int i = s; i < e; i++)
#define N_Max 100
#define Card_Max 36
#define ll long long

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

int main()
{
    int n; ll l[100] ={};
    cin>>n;
    l[0] = 2; l[1] = 1;
    repp(i,2,n+1){
        l[i] = l[i-1] + l[i-2];
    }
    cout << l[n] << endl;
}

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

const int MOD = 1000000007;

const int INF_32 = 1LL << 30;
const int64_t INF_64 = 1LL << 60;

int main()
{
    int A, B, C;
    cin >> A >> B >> C;

    cout << max(C - (A - B), 0) << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
#define MAX 100000
#define SENTINEL 2000000000

typedef struct {
  char suit;
  int value;
}card;

card L[MAX/2 +2],R[MAX/2 +2];

void merge(card A[],int n,int left,int mid,int right){
int  n1 = mid - left;
int  n2 = right - mid;
  for(int i = 0; i<n1; i++) L[i] = A[left + i];
  for(int i = 0; i<n2; i++) R[i] = A[mid + i];
  L[n1].value = R[n2].value = SENTINEL;
  int i = 0,j = 0;
  for(int k = left; k < right ; k++){
    if(L[i].value <= R[j].value){
      A[k] = L[i++];
    }else{
      A[k] = R[j++];
    }
  }
}

void mergeSort(card A[],int n,int left,int right){
  if(left+1 < right){
    int mid = (left + right)/2;
    mergeSort(A,n,left,mid);
    mergeSort(A,n,mid,right);
    merge(A,n,left,mid,right);
  }
}


int partition(card A[],int n,int p,int r){
  card x = A[r];
  int i = p - 1;
  for(int j = p ; j < r ; j++){
    if(A[j].value <= x.value){
      i=i +1;
      swap(A[i],A[j]);
    }
  }
  swap(A[i+1],A[r]);
  return i + 1;
}

void quicksort(card A[],int n,int p,int r){
  int q;
  if(p < r){
    q = partition(A,n,p,r);
    quicksort(A,n,p,q-1);
    quicksort(A,n,q+1,r);
  }
}

int main(){
  int n,v;
  card A[MAX],B[MAX];
  char S[10];
  int stable = 1;

  cin >> n;
  for(int i = 0;i < n;i++){
    cin >> S >> v;
    A[i].suit = B[i].suit = S[0];
    A[i].value = B[i].value = v;
  }
  mergeSort(A,n,0,n);
  quicksort(B,n,0,n-1);
  for(int i = 0;i < n;i++){
    if(A[i].suit != B[i].suit) stable = 0;
  }
  if(stable == 1) cout << "Stable" << "\n";
  else cout << "Not stable" << "\n";
  for(int i = 0;i < n;i++){
    cout << B[i].suit << " " <<B[i].value<< "\n";
  }
  return 0;
}



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

/// read the question correctly (is y a vowel?)
/// look out for SPECIAL CASES (n=1?) and overflow (ll vs int?)
#define fi first
#define se second
#define SZ 1000005
const int mx = 1234567;
const double eps = 1e-6;
const int md = 1e9+7;
const double pi = acos(-1.0);

typedef long long ll;

int dr[8] = {-1,-1,+0,+1,+1,+1,+0,-1};// counter clockwise
int dc[8] = {+0,-1,-1,-1,+0,+1,+1,+1};

int ar[mx],xar[mx],uses[mx];
ll arr[mx];
int tab[1000][1000];
string st[1000];
map<int ,int>mpii;
map<int ,char>mpic;
map<char ,int>mpci;
pair<int, int>pr[mx];

int ar1[mx],ar2[mx],ar3[mx],ar4[mx];

int main(){

    int tk=1,n,m;
//    freopen("in.txt","r", stdin);
//    freopen("out.txt","w", stdout);

//    while(scanf("%d",&n)==1){
//
//    }
    map<string,int>mp;
    string s1,s2,s3;
    cin>>s1;
    for(int i = 0; i < s1.size(); i++){
        cout<<'x';
    }cout<<endl;

    return 0;
}


Measured memory_bytes: 2304
S=input()
N=len(S)
ans=[]

def calc(R_count,L_count,ans):
  ans += [0]*(R_count-1)
  ans.append( (R_count+1)//2 + (L_count//2) )  
  ans.append( (L_count+1)//2 + (R_count//2) )
  ans += [0]*(L_count-1)
  return

R_count=0
L_count=0
i=0

while i<N:
  #print(i,S[i])
  if S[i]=="R":
    R_count += 1
    i += 1
  else:
    while i<N and S[i]=="L":
      #print(i,S[i])
      L_count +=1
      i += 1
    calc(R_count,L_count,ans)
    R_count=0
    L_count=0

#print(ans)
print(*ans)

Measured memory_bytes: 6400
using System;
using System.Collections.Generic;
namespace I_am_the_brown_coder{
    class Inonoa{
        static void Main(){
            string[] n_m = Console.ReadLine().Split();
            int n = int.Parse(n_m[0]);
            int m = int.Parse(n_m[1]);

            bool[] broken = new bool[n];
            for(int i=0;i<m;i++){
                broken[int.Parse(Console.ReadLine())-1] = true;
            }

            if(n==1){
                Console.WriteLine(1);
                return;
            }

            long[] dp = new long[n];
            if(broken[0]){
                dp[0] = 0;
            }else{
                dp[0] = 1;
            }
            
            if(broken[1]){
                dp[1] = 0;
            }else{
                if(broken[0]){ //1段目が壊れてたら飛ばすしかない
                    dp[1] = 1;
                }else{
                    dp[1] = 2;
                }
            }

            for(int i=2;i<n;i++){
                if(broken[i]){
                    dp[i] = 0;
                }else{
                    dp[i] = (dp[i-2] + dp[i-1])%1000000007;
                }
            }

            Console.WriteLine(dp[n-1]);

        }
    }
}

Measured memory_bytes: 13144
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); i++)
int main() {
  int n,ans=0;
  cin>>n;
  vector<int> a(n),b(n);
  rep(i,n) cin>>a[i];
  rep(i,n) cin>>b[i];
  rep(i,n){
    if(a[i]>b[i]){
      ans+=a[i]-b[i];
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <iomanip>
using namespace std;

#define rep(i,n)  for (int i = 0; i < (n); ++i)
#define MAX 12000000



int research_book(int N, int M, int X, vector<int> C,vector<vector<int>> A){
	int ans = MAX;
	rep(s, 1<<N){
		vector<int> S(M);
		int cost = 0;
		rep(i, N){
			if(s>>i&1){
				cost += C[i];
				rep(j, M) S[j] += A[i][j];
			}
		}
		bool ok =true;
		rep(j,M) if(S[j] < X) ok =false;
		if(ok) ans = min(ans, cost);
	}
	return ans;
}

int main() {
	int N, M, X;
	
	cin >> N >> M >> X;

	vector<int> C(N);
	vector<vector<int>> A(N, vector<int> (M, 0));
	
	int Finalans = -1;

	rep(i, N) {
		cin >> C[i];
		rep(j, M) cin >> A[i][j];
	}

	int ans;
	ans = research_book(N, M, X, C, A);

	if(ans == MAX){
		cout << -1;
	} 
	else {
		cout << ans;
	}
	return 0;
}

Measured memory_bytes: 3636
import sys
N = int(input())
A = list(map(int, input().split()))
if len(A) == 2:
  print(max(A),min(A))
  sys.exit()
a = max(A)
b = a/2
import numpy as np
def getNearestValue(list, num):
    idx = np.abs(np.asarray(list) - num).argmin()
    return list[idx]
c = getNearestValue(A,b)
print(a,c)

Measured memory_bytes: 17980
#include<cstdio>
int i,j,n[99];int main(){n[1]=1;n[2]=2;n[3]=4;for(i=4;i-31;i++)n[i]=n[i-1]+n[i-2]+n[i-3];for(;scanf("%d",&i)&&i;printf("%d\n",n[i]/3650+(n[i]%3650?1:0)));}

Measured memory_bytes: 1028
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;

int main(){
  int H,W,N;
  cin>>H>>W>>N;

  if(H>W) swap(H,W);
  int sum=0;
  for(int i=0;i<H;i++){
    sum+=W;
    if(sum>=N){
      cout<<i+1<<endl;
      return 0;
    }
  }

  return 0;
}


Measured memory_bytes: 764
//  Created by conan1024hao in 2019.
//  Copyright © 2019 conan1024hao. All rights reserved.
//  専用ライブラリです、自由にコピーして構いません。
//  感谢看我的代码！Wechat:conan1024hao QQ:810396815
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define IINF 10e8
#define INF 10e16
#define MOD 1000000007
#define  mod 1000000007
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
//using Int=int_fast64_t;
typedef long long int ll;
typedef pair<ll,ll>Pll;
typedef pair<int,int>Pin;
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[8]={-1,0,1,0,1,1,-1,-1};
int dy[8]={0,-1,0,1,1,-1,1,-1};
char dir[4]={'u','l','d','r'};
ll cmp1(pair<ll,string>a,pair<ll,string> b){
        if(a.fi!=b.fi)
        return a.fi<b.fi;
        else
        return a.se<b.se;
}
//--------------------------------------------------------------------------

//---------------------------------------------------------------------------
int main(){//問題をちゃんと見ろ!!!!!!!!!!!!!!!!!      llか??????????        memset()!!!!!!!!!!!!       ペナを減らせ!!!!!!!!!!!!!
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------
    int h,w;cin>>h>>w;
    char hw[100][100];
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cin>>hw[i][j];
        }
    }
    for(int i=0;i<w+2;i++)
        cout<<'#';
    cout<<endl;
    for(int i=0;i<h;i++){
        cout<<'#';
        for(int j=0;j<w;j++)
            cout<<hw[i][j];
        
        cout<<'#'<<endl;
    }
    for(int i=0;i<w+2;i++)
        cout<<'#';
    cout<<endl;
    //-------------------------------
    return 0;
}
//---------------------------------------------------------------------------






Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;

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

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

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

  double T, A;
  cin >> T >> A;

  vector<double> H(N);
  rep(i, N) cin >> H[i];

  double min = INF;
  double ans;

  rep(i, N)
  {
    if (chmin(min, abs(A - (T - H[i] * 0.006))))
      ans = i + 1;
  }

  cout << ans << endl;
}

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

using namespace std;

int main()
{
    int n;
    cin >> n;
    long long sum = 0;
    int root = floor(sqrt(n));
    for (int i = 1; i <= root; i++)
    {
        sum += (n/i - (i-1)) * 2 - 1;
        if (n % i == 0) sum -= 2;
    }
    if (root * root == n) sum++;
    cout << sum;
    return 0;
}


Measured memory_bytes: 3668
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long n,m,i,sum=0,p;
    cin>>n;
    for(i=0;i<n-1;i++)
    {
        cin>>m;
        if(i==0)
            sum+=m;
        else
            sum+=(min(p,m));
        p=m;
    }
    cout<<sum+p<<endl;
}






Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;

int main()
{
    int n; cin>>n;
    string s; cin>>s;
    int r=0, b=0;
    for(int i=0; i<n; i++){
        if(s[i]=='R') r++;
        else b++;
    }
    if(r>b) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
	int n,x;
	int i,j,k;
	int num=0;

	while(1){
		scanf("%d %d",&n,&x);
		if(n==0 && x==0)
			break;

		for(i=1; i<=n; i++){
			for(j=1; j<=n; j++){
				for(k=1; k<=n; k++){
					if(i+j+k==x && i!=j && i!=k && j!=k)
						num++;
				}
			}
		}
		printf("%d\n",num/6);
		num=0;
	}

	return 0;
}

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

//def
#define debug(x) cout << #x << ": " << x << '\n'
#define out(x) cout << x << '\n'
#define repeat(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define revrepeat(i, a, b) for (int i = (int)(b)-1; i >= (int)(a); i--)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define revrep(i, n) for (int i = (int)(n)-1; i >= 0; i--)
#define foreach(e, v) for (auto &e : v)
#define all(x) (x).begin(), (x).end()
#define CYES cout << "Yes" << endl
#define CNO cout << "No" << endl
#define SPC(x) cout << fixed << setprecision(x)
#define ZERO(a) memset(a, 0, sizeof(a))
#define MINUS(a) memset(a, 0xff, sizeof(a))

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int>> vii;
typedef vector<ll> vl;
typedef vector<vector<ll>> vll;
typedef pair<int, int> P;
constexpr int MOD = 1e9 + 7;
constexpr int INF = __INT_MAX__;               // 2^31 - 1
constexpr long long INFLL = __LONG_LONG_MAX__; // 2^61 - 1
constexpr int MAX_N = 1e5 + 5;
constexpr double PI = acos(-1);

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

    int k, a, b;

    cin >> k >> a >> b;

    bool ok = false;
    repeat(i, a, b + 1) {
        if (i % k == 0)
            ok = true;
    }

    if (ok)
        out("OK");
    else
        out("NG");
    return 0;
}


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

int main() {
	int judge[] = { 1,3,1,2,1,2,1,1,2,1,2,1 };
	int x, y;
	cin >> x >> y;
	if (judge[x - 1] == judge[y - 1]) {
		cout << "Yes" << endl;
		return 0;
	}
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

typedef std::pair<int, int> P;

std::string solve(const P &s, const P & t) {
    std::string ans;
    int x = s.first, y = s.second;
    // First lap
    while (x++ < t.first)  ans += 'R';
    while (y++ < t.second) ans += 'U';
    while (--x > s.first)  ans += 'L';
    while (--y > s.second) ans += 'D';
    // Second lap
    ans += 'D';
    while (x++ < t.first+1)  ans += 'R';
    while (y++ < t.second+1) ans += 'U';
    ans += 'L';
    ans += 'U';
    while (--x > s.first)  ans += 'L';
    while (--y > s.second) ans += 'D';
    ans += 'R';
    return ans;
}

int main() {
    P s, t;
    std::cin >> s.first >> s.second >> t.first >> t.second;
    std::cout << solve(s, t) << std::endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
  public static void main(String[] args){

  Scanner sc = new Scanner(System.in);
  int i = 1;
  while(true){
;
    int x = sc.nextInt();
    if(x == 0){
      break;
    }else{

      System.out.println("Case "+ i+": "+x);
    }
    i++;
    }
  }
}



Measured memory_bytes: 42644
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int maxn = 200000 + 10;
const int maxm = 100;
ll ans;
int C[maxm][maxm];
inline int lowbit(const int & x) { return x & (-x);}
int sum(int x, int y)
{
	int ret = 0;
	x += 50;
	y += 50;
	for(int i = x; i < maxm; i += lowbit(i))
		for(int j = y; j < maxm; j += lowbit(j))
			ret += C[i][j];
	return ret;
}
void add(int x, int y)
{
	x += 50;
	y += 50;
	for(int i = x; i; i -= lowbit(i))
		for(int j = y; j; j -= lowbit(j))
			++C[i][j];
}
int main()
{
	int n;
	scanf("%d", &n);
	for(int i = 1; i <= n; ++i)
	{
		double q;
		cin >> q;
		ll x = q * 1e9 + 0.5;
		int cnt2 = 0, cnt5 = 0;
		while(x % 2 == 0) x /= 2, ++cnt2;
		while(x % 5 == 0) x /= 5, ++cnt5;
		cnt2 -= 9;
		cnt5 -= 9;
		ans += sum(-cnt2, -cnt5);
		add(cnt2, cnt5);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3800
#include <iostream>
#include <vector>
#include <algorithm>
#define MAX(a,b) ((a>b)? a:b)
using namespace std;

string proc(string buf,int k){
    string ou;
    for(auto it=buf.begin();it!=buf.end()&&ou.size()<k;it++){
        if(it==buf.begin()){
            ou.push_back(*it);
        }
        else{
            if(*(it-1)=='a' || *(it-1)=='i' || *(it-1)=='u' || *(it-1)=='e' || *(it-1)=='o'){ou.push_back(*it);}
        }
    }
    return ou;
}

int main(){
    int i,j,n,k,c,fin,sz;
    string buf,tg,p;
    vector<string> rd,prc;
    while(1){
        rd.clear();
        cin >> n;
        if(!n){break;}
        sz=0;
        for(i=0;i<n;i++){
            cin >> buf;
            sz=MAX(sz,buf.size());
            rd.push_back(buf);
        }
        k=0;
        while(k<=sz){
            k++;
            prc.clear();
            for(auto it=rd.begin();it!=rd.end();it++){
                p=proc(*it,k);
                auto ps=find(prc.begin(),prc.end(),p);
                if(ps!=prc.end()){break;}
                else{prc.push_back(p);}
            }
            if(prc.size()==rd.size()){break;}
        }
        if(k>sz){k=-1;}
        cout << k << endl;
    }
    return 0;
}




Measured memory_bytes: 3184
from collections import Counter


def main():
  n = int(input())
  m = map(int, input().split())
  lst1, lst2 = zip(*zip(m, m))
  c1, c2 = sorted(Counter(lst1).items(), key=lambda x: x[1], reverse=1), sorted(Counter(lst2).items(), key=lambda x: x[1], reverse=1)
  c1.append((0, 0)), c2.append((0, 0))
  if c1[0][0] != c2[0][0]:
    print(n - c1[0][1] - c2[0][1])
  else:
    print(n - max(c1[1][1] + c2[0][1], c1[0][1] + c2[1][1]))


if __name__ == '__main__':
  main()

Measured memory_bytes: 20396
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Edge = pair<int, int>;
using Graph = vector<vector<Edge>>;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
const ll MOD = 1000000007;
const ll nmax = 8;
const ll INF = 1e9;
bool graph[nmax][nmax];
vector<vector<ll>> dist = vector<vector<ll>>(nmax, vector<ll>(nmax, INF));
void warshall_floyd(ll n)
{
    for (size_t i = 0; i < n; i++)
    {
        for (size_t j = 0; j < n; j++)
        {
            for (size_t k = 0; k < n; k++)
            {
                dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
            }
        }
    }
}

class UnionFind
{
public:
    vector<ll> Parent;

    UnionFind(ll N)
    {
        Parent = vector<ll>(N, -1);
    }
    ll find(ll A)
    {
        if (Parent[A] < 0)
            return A;
        return Parent[A] = find(Parent[A]);
    }

    ll size(ll A)
    {
        return -Parent[find(A)];
    }

    bool Union(ll A, ll B)
    {
        A = find(A);
        B = find(B);
        if (A == B)
        {
            return false;
        }
        if (size(A) < size(B))
            swap(A, B);

        Parent[A] += Parent[B];
        Parent[B] = A;

        return true;
    }
};

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

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

ll mulMod(ll a, ll b)
{
    return (((a % MOD) * (b % MOD)) % MOD);
}

ll powMod(ll a, ll p)
{
    if (p == 0)
    {
        return 1;
    }
    else if (p % 2 == 0)
    {
        ll half = powMod(a, p / 2);
        return mulMod(half, half);
    }
    else
    {
        return mulMod(powMod(a, p - 1), a);
    }
}

ll ceil(ll a, ll b)
{
    return (a + b - 1) / b;
}

void solve(long long N, long long M, std::vector<long long> L, std::vector<long long> R)
{
    vector<ll> cards(N + 10,0);

    for (int i = 0; i < M; i++)
    {
        cards[L[i]]++;
        cards[R[i] + 1]--;
    }

    ll ans = 0;
    for (int i = 1; i < N + 1; i++)
    {
        cards[i] += cards[i-1];
        if(cards[i] == M) ans++;
    }

    cout << ans << endl;
}

// Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main()
{
    long long N;
    scanf("%lld", &N);
    long long M;
    scanf("%lld", &M);
    std::vector<long long> L(M);
    std::vector<long long> R(M);
    for (int i = 0; i < M; i++)
    {
        scanf("%lld", &L[i]);
        scanf("%lld", &R[i]);
    }
    solve(N, M, std::move(L), std::move(R));
    return 0;
}


Measured memory_bytes: 2560