akhauriyash/Code-Regression huggingface dataset:
using System;

namespace ALDS1_1_C {
    class Program {
        static void Main(string[] args) {
            int n = int.Parse(Console.ReadLine());
            int count = 0;
            for (int i = 0; i < n; i++) {
                int m = int.Parse(Console.ReadLine());
                if (IsPrime(m))
                    count++;
            }
            Console.WriteLine(count);
        }

        static bool IsPrime(int n) {
            if (n == 2)
                return true;
            if (n % 2 == 0)
                return false;

            int len = (int)Math.Sqrt(n);
            for(int i = 3; i <= len; i+=2) {
                if (n % i == 0)
                    return false;
            }
            return true;
        }
    }
}

Measured memory_bytes: 9172
import math


class Vector2():
    def __init__(self, x, y):
        self.x = x
        self.y = y

    def __add__(self, v):
        return Vector2(self.x+v.x, self.y+v.y)

    def __sub__(self, v):
        return Vector2(self.x-v.x, self.y-v.y)

    def __mul__(self, v):
        return Vector2(self.x*v, self.y*v)

    def __truediv__(self, v):
        return Vector2(self.x/v, self.y/v)

    def __abs__(self):
        return math.sqrt(float(self.x*self.x+self.y*self.y))

    def dot(self, v):
        return self.x*v.x+self.y*v.y

    def cross(self, v):
        return self.x*v.y-self.y*v.x

    def norm(self):
        d = abs(self)
        return Vector2(self.x/d, self.y/d)


def distanceLP(v1, v2, p):
    '''
    v1 -> v2の直線とpとの距離
    '''
    return abs((v2-v1).cross(p-v1))/abs(v2-v1)


def distanceSP(v1, v2, p):
    '''
    v1 -> v2の線分とpとの距離
    '''
    if (v2-v1).dot(p-v1) < 0.0:
        return abs(p-v1)
    if (v1-v2).dot(p-v2) < 0.0:
        return abs(p-v2)
    return distanceLP(v1, v2, p)


def intersect(p1, p2, p3, p4):
    '''
    p1p2とp3p4の交差判定
    '''
    t1 = (p1.x-p2.x)*(p3.y-p1.y)+(p1.y-p2.y)*(p1.x-p3.x)
    t2 = (p1.x-p2.x)*(p4.y-p1.y)+(p1.y-p2.y)*(p1.x-p4.x)
    t3 = (p3.x-p4.x)*(p1.y-p3.y)+(p3.y-p4.y)*(p3.x-p1.x)
    t4 = (p3.x-p4.x)*(p2.y-p3.y)+(p3.y-p4.y)*(p3.x-p2.x)
    return (t1*t2) < 0.0 and (t3*t4) < 0.0


def distance(a1, a2, b1, b2):
    '''
    線分a1a2とb1b2の距離
    '''
    if intersect(a1, a2, b1, b2):
        return 0.0
    return min([
        min([distanceSP(a1, a2, b1), distanceSP(a1, a2, b2)]),
        min([distanceSP(b1, b2, a1), distanceSP(b1, b2, a2)])
    ])


q = int(input())
for i in range(q):
    x0, y0, x1, y1, x2, y2, x3, y3 = map(int, input().split())
    p0 = Vector2(x0, y0)
    p1 = Vector2(x1, y1)
    p2 = Vector2(x2, y2)
    p3 = Vector2(x3, y3)
    s1 = p1-p0
    s2 = p3-p2
    print(f"{distance(p0, p1, p2, p3):.10f}")



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

using namespace std;

typedef long long ll;

ifstream fin ("hps.in");
ofstream fout ("hps.out");

#define f first
#define s second
#define pb push_back

int n, k, h[200002];
ll ans;


int main()
{
  cin >> n >> k;
  for (int i = 1; i <= n; i++) {
    cin >> h[i];
  }
  sort(h + 1, h + n + 1);
  for (int i = 1; i <= n - k; i++)
    ans += h[i];
  cout << ans;
  return 0;
}


Measured memory_bytes: 1024
while True:
    count=0
    n,x=map(int,input().split())
    if n==x==0:
        break
    else:
        for i in range(1,n-1):
            for j in range(i+1,n):
                for k in range(j+1,n+1):
                    if i+j+k==x:
                        count=count+1
        print(count)


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

def solve():
    S = input()

    def dfs(depth, s):
        if depth == len(S):
            # 計算する
            return sum(list(map(int, s.split("+"))))
        
        ret1 = dfs(depth+1, s+"+"+S[depth])
        ret2 = dfs(depth+1, s+S[depth])

        return ret1 + ret2

    ans = dfs(1, S[0])
    print(ans)

if __name__ == "__main__":
    solve()


Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
using namespace std;
int main() {
	int a, b, c, d, e = 0;
	cin >> a >> b >> c >> d;
	for (int h = 0; h <= a; h++) {
		for (int j = 0; j <= b; j++) {
			for (int k = 0; k <= c; k++) {
				if (h * 500 + j * 100 + k * 50 == d) {
					e++;
				}
			}
		}
	}
	cout << e << endl;
	cin >> e;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std;
#define pb push_back
#define ll long long int
#define vi vector<int>
#define ii pair<int,int>
#define vli vector<ll>
#define graph vector<vector< int > >
#define vpi vector<pair<int ,int> >
#define vpli vector<pair<ll ,ll> >
#define mp make_pair
#define F first
#define S second
#define mod 163577857
#define INF (ll)1e10
#define wh(a) cout<<#a<<"  is  "<<a<<endl;
#define MIN(a,b) ((a) < (b) ? (a) : (b))
#define MAX(a,b) ((a) > (b) ? (a) : (b))
#define INI(a) memset(a,0,sizeof(a))
#define LIMIT 8008

void solve(){
    int n,m,x;
    cin>>n>>m>>x;
    int cost[n];
    int a[n][m];
    for(int i=0;i<n;++i){
        cin>>cost[i];
        for(int j=0;j<m;++j){
            cin>>a[i][j];
        }
    }
    int all=((1<<n)-1);
    int ans=-1;
    for(int i=1;i<=all;++i){
        int curcost=0;
        int score[m];
        INI(score);
        // wh(i);
        for(int bit=0;bit<n;++bit){
            if((i&(1<<bit))!=0){
                curcost+=cost[bit];
                for(int j=0;j<m;++j){
                    score[j]+=a[bit][j];

                }
            }
            // wh(curcost);
        }
        bool pos=true;
        for(int j=0;j<m;++j){
            if(score[j]<x){
                pos=false;
            }
            // cout<<score[j]<<" ";
        }
        // cout<<endl;
        if(pos){
            if(ans==-1){
                ans=curcost;
            }
            else if(curcost<ans){
                ans=curcost;
            }
        }
        // wh(curcost);
        // wh(ans);
    }
    cout<<ans;
}

int main(){
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt", "r", stdin);
    // #endif
    int t=1;
    // cin>>t;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 3672
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };

int INF = INT_MAX / 2;
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int F[1001], C[1001][1001], D[1001][1001];

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

vector<vector<int> > f(int N, ll t) {
	vector<vector<int> > a(N + 1);
	for (int n = 1; n <= N; n++) {
		vector<int> dp(N / n + 1);
		dp[0] = 1;
		for (int i = 0; i <= N / n; i++)
			for (int j = 1; i + j <= N / n; j++) {
				if (gcd(t, j * n) != j) continue;
				ll x = dp[i];
				x = x * C[i + j - 1][j - 1] % MOD;
				x = x * F[j - 1] % MOD;
				x = x * D[n][j - 1] % MOD;
				dp[i + j] = (dp[i + j] + x) % MOD;
			}
		a[n] = dp;
	}
	return a;
}

int main() {
	F[0] = 1;
	for (int i = 1; i <= 1000; i++)
		F[i] = (ll)F[i - 1] * i % MOD;
	for (int i = 0; i <= 1000; i++) {
		C[i][0] = 1;
		for (int j = 1; j <= i; j++)
			C[i][j] = (C[i - 1][j - 1] + C[i - 1][j]) % MOD;
	}
	for (int i = 1; i <= 1000; i++) {
		D[i][0] = 1;
		for (int j = 1; j <= 1000; j++)
			D[i][j] = (ll)D[i][j - 1] * i % MOD;
	}
	int N; ll X, Y, Z;
	cin >> N >> X >> Y >> Z;
	vector<vector<int> > a = f(N, 2), b = f(N, abs(X - Y + Z));
	if (!X && !Y && !Z) {
		cout << (ll)a[1][N] * D[N][N] % MOD << endl;
		return 0;
	}
	vector<int> dp(N + 1);
	dp[0] = 1;
	for (int n = 1; n <= N; n++)
		for (int k = N; k >= 0; k--) {
			ll z = 1;
			for (int i = 1; k + i * n <= N; i++) {
				z = z * C[i * n - 1][n - 1] % MOD * F[n - 1] % MOD;
				ll x = dp[k];
				x = x * C[k + i * n][i * n] % MOD;
				x = x * z % MOD;
				x = x * a[n][i] % MOD;
				x = x * b[n][i] % MOD;
				dp[k + i * n] = (dp[k + i * n] + x) % MOD;
			}
		}
	cout << dp[N] << endl;
}

Measured memory_bytes: 11148
# コンビネーション
mod = 10**9+7
def cmb(n, r, mod=mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

NN = 10**5 # 使うデータによって変える
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, NN + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )


N, K = map(int, input().split())

for i in range(1, K+1):
    ans = cmb(K-1, K-i) * cmb(N-K+1, N-K-i+1) % mod
    print(ans)

Measured memory_bytes: 21008
#!/usr/bin/env python3
import sys
INF = float("inf")


def solve(x: int):
    counter = 2*(x//11)
    if 0 < x % 11 <= 6:
        counter += 1
    elif 6 < x % 11:
        counter += 2
    print(counter)

    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    x = int(next(tokens))  # type: int
    solve(x)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int n,b[200009],num=0;
ll tmp=0,c[200009],d[200009],tmp1=0;
char a[200009];
ll pow1(ll a,int n,ll m)
{
    ll ans=1;
    while(n)
    {
        if(n&1)
            ans=ans*a%m;
        a=a*a%m;
        n>>=1;
    }
    return ans;
}
void solve(int x)
{
    //cout<<x<<endl;
    int num=1;
    while(x)
    {
        int tmp=x,num1=0;
        while(tmp)
        {
            num1+=tmp%2;
            tmp/=2;
        }
        x%=num1;
        num++;
    }
    printf("%d\n",num);
}
int main()
{
    scanf("%d%s",&n,a);
    for(int i=0; i<n; i++)
        b[n-i-1]=a[i]-'0';
    for(int i=0; i<n; i++)
        num+=b[i];
    for(int i=0; i<n; i++)
    {
        if(num-1>0)
            c[i]=pow1(2,i,num-1);
        d[i]=pow1(2,i,num+1);
        if(b[i])
            tmp+=c[i],tmp1+=d[i];
    }
    for(int i=n-1; i>=0; i--)
    {
        if(b[i])
        {
            if(num-1!=0)
                solve((tmp-c[i])%(num-1));
            else
                printf("0\n");
        }
        else
            solve((tmp1+d[i])%(num+1));
    }
    return 0;
}


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

const long INF = 1 << 29;

int dp[100010];

int main(){
	int n;
	scanf("%d", &n);
	for(int i = 0; i <= n; i++)
		dp[i] = INF;
	dp[0] = 0;
	for(int i = 1; i <= n; i++) {
		for(int j = 1; j <= i; j*=6)
			dp[i] = min(dp[i], dp[i-j] + 1);
		for(int j = 1; j <= i; j*=9)
			dp[i] = min(dp[i], dp[i-j] + 1);
	}
	printf("%d\n", dp[n]);
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = 0x3f3f3f3f;
const int N = 50 + 5;

int main(){
	int n,m;
	cin >> n >> m;
	if(n%2 == 1){
		for(int i = 0; i < m; i++)
			cout << i+1 << " " << n-i << endl;
	}
	else{
		for(int i = 0; i < n/4; ++i){
			if(i == m)	break;
			cout << i+1 << " " << n-i << endl;
		}
		for(int i = n/4; i < m; ++i)
			cout << i+1 << " " << n-i-1 << endl;
	}
	return 0;
}

Measured memory_bytes: 3640
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <tuple>
#include <utility>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <iomanip>
#include <map>
#include <sstream>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
const int INF = 1e9 + 7;
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};

int main()
{
   int a,b;
   cin>>a>>b;

   cout << max(max(a+b,a-b),a*b)<<endl;


    return 0; 

}


Measured memory_bytes: 256
#include<cstdio>
    #include<algorithm>
    #include<cstring>
    #define fo(i,a,b) for(i=a;i<=b;i++)
    #define fd(i,a,b) for(i=a;i>=b;i--)
    using namespace std;
    const int maxn=2000+10;
    char s[maxn];
    int a[maxn],b[maxn],c[maxn],L[maxn],R[maxn];
    bool bz[maxn];
    int i,j,k,l,t,n,m,ans,num,sum,cnt,mx,mi,top;
    bool czy,gjx;
    bool cmpL(int x,int y){
        return L[x]<L[y];
    }
    bool cmpR(int x,int y){
        return R[x]<R[y];
    }
    int main(){
        scanf("%s",s+1);
        n=strlen(s+1);
        czy=1;
        fo(i,1,n){
            a[i]=s[i]-'0';
            if (a[i]) czy=0;
        }
        scanf("%s",s+1);
        gjx=1;
        fo(i,1,n){
            b[i]=s[i]-'0';
            if (b[i]) gjx=0;
        }
        if (gjx){
            if (czy) printf("0\n");else printf("-1\n");
            return 0;
        }
        fo(i,1,n){
            j=i;
            while (!b[j]){
                L[i]++;
                if (j==1) j=n;
                else j--;
            }
            j=i;
            while (!b[j]){
                R[i]++;
                if (j==n) j=1;
                else j++;
            }
        }
        ans=1000000000;
        fo(i,1,n){
            fo(j,1,n) bz[j]=0;
            sum=0;
            j=i;
            fo(k,1,n){
                if (a[j]!=b[k]) bz[j]=1,sum++;
                if (j==n) j=1;else j++;
            }
            cnt=(i==1?0:n-i+1);
            top=0;
            fo(j,1,n)
                if (bz[j]&&R[j]>cnt) c[++top]=j;
            sort(c+1,c+top+1,cmpL);
            mx=0;mi=5*n;
            if (top) mi=min(mi,L[c[top]]*2+cnt);
            fd(j,top,1){
                mx=max(mx,R[c[j]]);
                if (j>1) mi=min(mi,L[c[j-1]]*2+mx*2-cnt);
            }
            if (top) mi=min(mi,mx*2-cnt);
            if (!top) mi=cnt;
            num=mi;
            ans=min(ans,num+sum);
            cnt=i-1;
            top=0;
            fo(j,1,n)
                if (bz[j]&&L[j]>cnt) c[++top]=j;
            sort(c+1,c+top+1,cmpR);
            mx=0;mi=5*n;
            if (top) mi=min(mi,R[c[top]]*2+cnt);
            fd(j,top,1){
                mx=max(mx,L[c[j]]);
                if (j>1) mi=min(mi,R[c[j-1]]*2+mx*2-cnt);
            }
            if (top) mi=min(mi,mx*2-cnt);
            if (!top) mi=cnt;
            num=mi;
            ans=min(ans,num+sum);
        }
        printf("%d\n",ans);
    }

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;


public class Main {

	public static void main(String[] a){

		BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));

		String tmpString = null;

		try {
			if(null != (tmpString = bf.readLine())){
				char[] strings = convert(tmpString.toCharArray());
				String ans = new String(strings);
				System.out.println(ans);
			}
		} catch (IOException e) {
		}
	}


	private static char[] convert(char[] strings){
		int count = strings.length;
		for(int i = 0; i < count; i++){
			if((int)strings[i] >= (int)'a' && (int)strings[i] <= (int)'z'){
				strings[i] = (char)((int)strings[i] + ((int)'A' - (int)'a'));
			}
		}
		return strings;
	}
}

Measured memory_bytes: 9360
using System;

public class Test
{
	public static void Main()
	{
		string line = System.Console.ReadLine();
   		string[] ab = line.Split(' ');
   		int a = Convert.ToInt32(ab[0]);
   		int b = Convert.ToInt32(ab[1]);
   		if( a > b){
   			Console.WriteLine("a > b");
   		}else if( a < b){
   			Console.WriteLine("a < b");
   		}else{
   			Console.WriteLine("a == b");
   		}

	}
}

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

namespace AtCoderBeginnerContest177
{
    class Program
    {
        static void Main(string[] args)
        {

            // 課題A：Don't be late(2020/8/29)

            string[] input = Console.ReadLine().Split(' ');

            int length = int.Parse(input[0]);
            int time = int.Parse(input[1]);
            int speed = int.Parse(input[2]);

            long move = speed * time;

            if (move >= length) Console.Write("Yes");
            else Console.Write("No");

        }

    }
}


Measured memory_bytes: 27500
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed
#define pb push_back
#define pf push_front
#define eb emplace_back
using namespace std;
typedef long long ll;
template<class t,class u> bool chmax(t&a,u b){if(a<b){a=b; return true;} return false;}
template<class t,class u> bool chmin(t&a,u b){if(a>b){a=b; return true;} return false;}
template<class t,class u> t MAX(t a,u b){if(a>=b) return a; return b;}
template<class t,class u> t MIN(t a,u b){if(a<=b) return a; return b;}
template<class t> int SIZE(t s){return (int)s.size();}
template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;
using vvi=vc<vc<int>>;
using pi=pair<int,int>;
using vi=vc<int>;
void yes(){ cout << "Yes" << endl; }
void no(){ cout << "No" << endl; }
const long long INF = 1LL << 60;

int main(){
    cout << fixed << setprecision(20);
    ll n,m,x; cin >> n >> m >> x;
    vc<ll> pr(n);
    vvc<ll> c(n,vector<ll>(m,1));
    rep(i,n){
        cin >> pr[i];
        rep(j,m){
            cin >> c[i][j];
        }
    }
    ll ans = INF;
    rep(bit,(1<<n)){
        ll sum = 0;
        vc<ll> cur(m);
        for (ll i = 0; i < n; ++i) {
            if (bit & (1<<i)) {
                //cout << i << " ";
                sum += pr[i];
                rep(j,m){
                    cur[j] += c[i][j];
                }
            }
        }
        //cout << endl;
        bool ch = true;
        rep(i,m){
            if(cur[i] < x){
                ch = false;
                break;
            }
        }
        if(ch) chmin(ans,sum);
    }
    if(ans == INF) cout << -1 << endl;
    else cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3632
N,x = map(int,input().split())
A = [int(i) for i in input().split()]

res = 0
for i in range(N-1):
    if A[i] + A[i+1] > x:
        eat = A[i]+A[i+1]-x
        A[i+1] = max(0,A[i+1]-eat)
        res += eat
        if A[i+1]-eat < 0:
            A[i] -= abs(A[i+1]-eat)

#print(A)
print(res)

Measured memory_bytes: 14252
#include<iostream>
  
int main(){
    int h;
    int w;
  
    while(true){
        std::cin>>h;
        std::cin>>w;
        if(h==0&&w==0){
            break;
        }
        for(int i=0;i<h;i++){
            for(int j=0;j<w;j++){
                if(i==0||i==h-1||j==0||j==w-1){
                    std::cout<<"#";
                }else{
                    std::cout<<".";
                }
            }
            std::cout<<std::endl;
        }
        std::cout<<std::endl;
    }
    return 0;
}

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

int H,W;

signed main() {
  cin >> H >> W;
  if(H==1 || W==1) {puts("1"); return 0;}
  int a1 = (W+1)/2;
  int a2 = W/2;
  cout << a1 * ((H+1)/2) + a2 * (H/2) << endl;

}


Measured memory_bytes: 256
def inpl(): return list(map(int,input().split()))
 
N, W = inpl()
dp = [[0]*(W+1) for _ in range(N+1)]
for n in range(1,N+1):
  w, v = inpl()
  for x in range(W+1):
    if x < w:
      dp[n][x] = dp[n-1][x]
    else:
      dp[n][x] = max(dp[n-1][x], dp[n-1][x-w] + v)
print(dp[-1][-1])


Measured memory_bytes: 148936
n,m,c = map(int,input().split())

bs = list(map(int,input().split()))

ans = 0

for i in range(n):
    total = 0
    As = list(map(int,input().split()))
    for j in range(m):
        total+=As[j]*bs[j]
    if total+c>0: 
        ans+=1

print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <vector>

using namespace std;

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

    int tar;
    if (N % 2 == 0) {
        tar = N + 1;
    } else {
        tar = N;
    }

    int edge[105][105] = {0};
    int cnt = 0;
    for (int i = 1; i <= N; i++) {
        for (int j = i + 1; j <= N; j++) {
            if (i + j != tar) {
                edge[i][j] = 1;
                cnt++;
            }
        }
    }

    cout << cnt << endl;
    for (int i = 1; i <= N; i++) {
        for (int j = i + 1; j <= N; j++) {
            if (edge[i][j] == 1) {
                cout << i << " " << j << endl;
            }
        }
    }
}

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

using namespace std;

#define fst first
#define scd second
#define pb push_back
#define mp make_pair
#define chmin(a,b) a=min(a,b)
#define chmax(a,b) a=max(a,b)
#define rep(i,x) for(int i=0;i<(int)x;++i)
#define rep1(i,x) for(int i=1;i<=(int)x;++i)
#define rrep(i,x) for(int i=(int)x-1;i>=0;--i)
#define rrep1(i,x) for(int i=(int)x;i>=1;--i)
#define repf(i,a,x) for(int i=a;i<(int)x;++i)
#define repf1(i,a,x) for(int i=a;i<=(int)x;++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()

template<typename T> T get(){T a;cin >> a;return a;}
template<typename T> T rev(T & a){reverse(all(a));return a;}

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

const int inf = 1e9;
const ll linf = 1e18;

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

    string s;
    while (cin >> s, s[0] != '0') {
        map<string, bool> m;

        queue<string> q, r;

        q.push(s);

        int cnt = 0;

        while (q.size()) {
            while (q.size()) {
                string t = q.front(); q.pop();
                if (m[t]) continue;
                m[t] = true;
                bool f = true;
                rep(i, t.size() - 1) {
                    if ((t[i] == 'r' && t[i + 1] == 'b') || (t[i] == 'b' && t[i + 1] == 'r')) {
                        char c = t[i], d = t[i + 1];
                        t[i] = t[i + 1] = 'g';
                        r.push(t);
                        t[i] = c, t[i + 1] = d;
                        f = false;
                    } else if ((t[i] == 'b' && t[i + 1] == 'g') || (t[i] == 'g' && t[i + 1] == 'b')) {
                        char c = t[i], d = t[i + 1];
                        t[i] = t[i + 1] = 'r';
                        r.push(t);
                        t[i] = c, t[i + 1] = d;
                        f = false;
                    } else if ((t[i] == 'r' && t[i + 1] == 'g') || (t[i] == 'g' && t[i + 1] == 'r')) {
                        char c = t[i], d = t[i + 1];
                        t[i] = t[i + 1] = 'b';
                        r.push(t);
                        t[i] = c, t[i + 1] = d;
                        f = false;
                    }
                }
                if (f) {
                    cout << cnt << endl;
                    goto nxt;
                }
            }
            while (r.size()) {
                string t = r.front(); r.pop();
                q.push(t);
            }
            cnt++;
        }

        cout << "NA\n";
nxt:;
    }
}

Measured memory_bytes: 3328
#include <stdlib.h>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>


using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define CLR(a) memset((a), 0 ,sizeof(a))
#define REP(i,n) for(int i = 0; i < (int)(n); ++i)
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

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

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int a[10000];
int b[10000];
int main(){
	vector<int>aa;
	vector<int>bb;
	while(1){
	int n;
	cin>>n;
	if(n==0)break;
	REP(i,n)cin>>a[i]>>b[i];
	int ans_a=0,ans_b=0;
	REP(i,n){
		if(a[i]>b[i]){
			ans_a+=(a[i]+b[i]);
		}else if(a[i]<b[i]){
			ans_b+=(a[i]+b[i]);
		}else{
			ans_a+=a[i];
			ans_b+=b[i];
		}
	}
	aa.push_back(ans_a);
	bb.push_back(ans_b);
	}
	REP(i,aa.size()){
		cout<<aa[i]<<" "<<bb[i]<<endl;
	}
	return 0;
}

Measured memory_bytes: 1292
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.Scanner;

public class Main {
	//java11

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		String A = sc.next();
		String B = sc.next();

		BigDecimal bA = new BigDecimal(A);
		BigDecimal bB = new BigDecimal(B);
		BigDecimal ans = bA.multiply(bB);
		ans = ans.setScale(0, RoundingMode.DOWN);

		System.out.println(ans);

	}

}

Measured memory_bytes: 35964
gets
h = {
  "AC" => 0,
  "WA" => 0,
  "TLE" => 0,
  "RE" => 0,
}
ARGF.each_line { |l|
  h[l.strip] += 1
}

puts h.to_a.map { |a| a.join(" x ") }.join("\n")

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

int add(int n){
  int i =0;
  int keta[4];
  int ans=0;
  while(n>0){
    keta[i]=n%10;
    n/=10;
    ans+=keta[i];
    i++;
  }
  return ans;
}

int main(){
  int n,a,b;
  cin>>n;
  cin>>a;
  cin>>b;
  int sum=0;
  for(int i=0;i<=n;i++){
    int x=add(i);
    
    if(x>=a && x<=b){
      sum+=i;
    }
  }
  cout<<sum<<endl;
  return 0;
}
    
         
  
  

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int MOD=1e9+7;
//const int MOD=998244353;
const int INF=1e9;
const long long LINF=1e18;
#define int long long
//template
template <typename T>
void fin(T a){
  cout<<a<<endl;
  exit(0);
}
//main
signed main(){
  string s,t;cin>>s>>t;int ans=0;
  for(int i=0;i<3;i++)if(s[i]==t[i])ans++;
  cout<<ans<<endl;
}


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

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


Measured memory_bytes: 256
n,m,q = map(int,input().split())
dist = [list(map(int,input().split())) for i in range(m)]
query = [list(map(int,input().split())) for i in range(q)]

coord = [[0]*(n+1) for i in range(n+1)]

for i in range(m):
  coord[dist[i][0]][dist[i][1]] += 1

ruiseki = [[0]*(n+1) for i in range(n+1)]
for i in range(1,n+1):
  for j in range(1,n+1):
    ruiseki[i][j] = coord[i][j] + ruiseki[i-1][j]
 
for i in range(1,n+1):
  for j in range(1,n+1):
    ruiseki[i][j] = ruiseki[i][j]+ ruiseki[i][j-1]
#print(ruiseki)

for i,j in query:
  ans = ruiseki[j][j]-ruiseki[i-1][j]-ruiseki[j][i-1]+ruiseki[i-1][i-1]
  print(ans)

Measured memory_bytes: 79100
#include <stdio.h>

int main(){
	long long int number;
	scanf("%lld",&number);
	long long int total = 0;
	for (int i =1; i<=number; i++){
		if (i % 3 == 0 && i % 5 ==0){
			continue;
		}
		else if (i % 3 == 0){
			continue;
		}
		else if(i % 5 == 0){
			continue;
		}
		else{
			total += i;
		}
	}
	printf("%lld", total);
	return 0;
}



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

int main(){
    ll N,total=0;
    cin >> N;
    vector<ll> now(N);
    rep(i,N) cin >> now[i];
    for(int i=0;i<N-1;i++){
        for(int j=i+1;j<N;j++){
            total+=now[i]*now[j];
        }
    }
    
    cout << total << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <numeric>
#include <cmath>
#include <algorithm>
#include <string>
#include <queue>
#define myfor(i,N) for(i=0;i<N;i++)
#define myforFL(i,f,l) for(i=f;i<l;i++)

using namespace std;

int main(void){
	double R,ans;
	cin >> R;
	ans = 2.*M_PI*R;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3784
n = int(input())
a = [list(map(int, input().split())) for i in range(n)]
A = []
B = []
for i in range(n):
    A.append(a[i][0])
    B.append(a[i][1])
A = sorted(A)
B = sorted(B)
if n%2 == 0:
    ca = (A[int((n/2)-1)] + A[int(n/2)]) / 2
    cb = (B[int((n/2)-1)] + B[int(n/2)]) / 2
    ans = (cb - ca) * 2 + 1
else:
    ca = A[int(((n+1)//2)-1)]
    cb = B[int(((n+1)//2)-1)]
    ans = (cb - ca) + 1
print(int(ans))

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

int main(){
        long N,T;
        long sum=0;
        cin >> N >> T;

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

        int start=0;
        for(int i=0;i<N-1;){
                while(v[i]-v[start]<T && i<N-1){
                        i++;
                }
                sum+=(v[i-1]-v[start])+min(T,v[i]-v[i-1]);
                start=i;
        }
        sum+=T;
        cout << sum << endl;

        return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define ll long long int
#define INF 0x3f3f3f3f
#define pb push_back
#define se second
#define fi first
using namespace std;

int main()
{
	ios_base::sync_with_stdio(false); cin.tie(0);
	int n;cin>>n;
	ll ans=0;
	while(n--)
	{
		int x; cin>>x;
		ans+=x;
	}
	if(ans%2) cout<<"NO";
	else cout<<"YES";
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
// #define endl "\n"

ll recurse(ll i, ll j, const vector<ll>& arr, const vector<ll>& prefix, vector<vector<ll>>& dp) {
    if (i >= j) {
        return 0;
    }
    if (i == j-1) {
        return arr[i] + arr[j];
    }

    if (dp[i][j] != -1) {
        return dp[i][j];
    }

    ll cost = prefix[j];
    if (i > 0) {
        cost = cost - prefix[i-1];
    }
    ll added = LLONG_MAX;
    for (ll k = i; k < j; k++) {
        ll temp = recurse(i, k, arr, prefix, dp) + recurse(k+1, j, arr, prefix, dp);
        added = min(added, temp);
    }
    return dp[i][j] = cost + added;
}

int main(void) {
    // ios_base::sync_with_stdio(false);
    // cin.tie(NULL);
    // cout.tie(NULL);
    ll n;
    cin >> n;
    vector<ll> arr (n);
    ll summ = 0;
    vector<ll> prefix (n);
    for (ll i = 0; i < n; i++) {
        cin >> arr[i];
        prefix[i] = summ + arr[i];
        summ = prefix[i];
    }
    vector<vector<ll>> dp (n, vector<ll> (n, -1));
    cout << recurse(0, n-1, arr, prefix, dp) << endl;

    
    return 0;
}

    // ll cost = 0;
    // vector<ll> temp;
    // for (ll i = 0; i < n-1; i++) {
    //     ll minn = LLONG_MAX;
    //     ll minidx = -1;
    //     for (ll i = 0; i < arr.size()-1; i++) {
    //         if (arr[i] + arr[i+1] < minn) {
    //             minidx = i;
    //             minn = arr[i] + arr[i+1];
    //         }
    //     }
    //     cost = cost + arr[minidx] + arr[minidx+1];
    //     for (ll i = 0; i < arr.size(); i++) {
    //         if (i == minidx) {
    //             temp.push_back(arr[i] + arr[i+1]); // i won't be the last one
    //             i++;
    //         } else {
    //             temp.push_back(arr[i]);
    //         }
    //     }
    //     arr.clear();
    //     arr = temp; // automatically uses move
    //     temp.clear();
    // }
    // cout << cost << endl;

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

int main() {
  string S;
  cin >> S;
  if (S.at(0)=='a' ||S.at(0)=='e'||S.at(0)=='i'||S.at(0)=='o'||S.at(0)=='u'){
    cout << "vowel" << endl;
  }
  else {
    cout << "consonant" << endl;
  }

   
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#define llint long long
#define NODE(x, y) ((x)*1000+(y))
using namespace std;

llint n;
vector<llint> G[1100005];
llint a[1005][1005];

vector<int> topo;
bool used[1100005];
int dp[1100005];

void tpsort(int v)
{
	used[v] = true;
	for(int i = 0; i < G[v].size(); i++){
		if(!used[G[v][i]]) tpsort(G[v][i]);
	}
	topo.push_back(v);
}


int main(void)
{
	cin >> n;
	for(int i = 1; i <= n; i++){
		for(int j = 1; j <= n-1; j++){
			cin >> a[i][j];
		}
	}
	for(int i = 1; i <= n; i++){
		for(int j = 1; j < n-1; j++){
			llint u = i, v = a[i][j];
			if(u > v) swap(u, v);
			llint x = i, y = a[i][j+1];
			if(x > y) swap(x, y);
			G[NODE(u, v)].push_back(NODE(x, y));
		}
	}
	
	int S = 1, T = NODE(n, n);
	for(int i = S; i <= T; i++) if(!used[i]) tpsort(i);
	reverse(topo.begin(), topo.end());
	
	for(int i = S; i <= T; i++) used[i] = false;
	for(int i = 0; i < topo.size(); i++){
		int v = topo[i];
		used[v] = true;
		for(int j = 0; j < G[v].size(); j++){
			if(used[G[v][j]]){
				cout << -1 << endl;
				return 0;
			}
			dp[G[v][j]] = max(dp[G[v][j]], dp[v]+1);
		}
	}
	
	int ans = 0;
	for(int i = S; i <= T; i++) ans = max(ans, dp[i]);
	cout << ans+1 << endl;
	
	return 0;
}

Measured memory_bytes: 58992
from functools import lru_cache


@lru_cache(maxsize=None)
def get_dividers(n):
    """
    正の整数 n の約数を取得する
    """

    dividers = {i for i in range(1, int(n ** 0.5) + 1) if n % i == 0}
    return dividers | {n // d for d in dividers}


A, B = map(int, input().split(' '))

a_dividers = get_dividers(A)
b_dividers = get_dividers(B)
common_dividers = a_dividers & b_dividers
ans = []

for cd in sorted(common_dividers):
    dividers = get_dividers(cd) - {1}
    for d in ans:
        if d & dividers:
            break
    else:
        ans.append(dividers)

print(len(ans))


Measured memory_bytes: 119776
x, y = map(int, input().split())

for i in range(x + 1):
    kame = i
    turu = x - i
    kame_leg = i * 4
    turu_leg = (x -i) * 2
    if y == kame_leg + turu_leg:
        ans = 'Yes'
        break
    else:
        ans = 'No'
print(ans)

Measured memory_bytes: 9040
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <functional>
using namespace std;
#define int long long
#define All(v) (v).begin(),(v).end()

const int mod = 1000000007;
const int inf = mod*mod;
const int d5 = 100100;
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin>>n;
    vector<int> a(n);
    for(int i=0;i<n;i++)cin>>a[i];
    unordered_map<int,int> D;
    for(auto it:a){
        D[it]++;
    }
    int sum=0;
    for(auto it:D){
        sum+=it.second*(it.second-1)/2;
    }
    for(int i=0;i<n;i++){
        int res=sum;
        res-=D[a[i]]*(D[a[i]]-1)/2;
        res+=(D[a[i]]-2)*(D[a[i]]-1)/2;
        cout<<res<<endl;
    }
}

Measured memory_bytes: 9160
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <stdbool.h>
typedef long long LL;
typedef long double Lf;
#define Rep(i,a,n)for(LL i=(LL)(a);i<(LL)(n);i++)
#define rep(i,n)Rep(i,0,n)
#define Repp(i,l,r,k)for(LL i=(l);i<(r);i+=(k))
#define Ma(x,y) ((x)>(y)?(x):(y))
#define mi(x,y) ((x)<(y)?(x):(y))
#define MOD 998244353//1000000007,1000000009,998244353 
int upi(const void* a, const void* b) { return*(int*)a<*(int*)b ? -1 : *(int*)a> * (int*)b ? 1 : 0; }
int downi(const void* a, const void* b) { return*(int*)a<*(int*)b ? 1 : *(int*)a> * (int*)b ? -1 : 0; }
void sortupi(int* a, int n) { qsort(a, n, sizeof(int), upi); } //1,2,3,4,...
void sortdowni(int* a, int n) { qsort(a, n, sizeof(int), downi); }
int upLL(const void* a, const void* b) { return*(LL*)a<*(LL*)b ? -1 : *(LL*)a> * (LL*)b ? 1 : 0; }
int downLL(const void* a, const void* b) { return*(LL*)a<*(LL*)b ? 1 : *(LL*)a> * (LL*)b ? -1 : 0; }
void sortupLL(LL* a, int n) { qsort(a, n, sizeof(LL), upLL); }
void sortdownLL(LL* a, int n) { qsort(a, n, sizeof(LL), downLL); }
int cmp_char(const void* a, const void* b) { return *(char*)a - *(char*)b; } // a,b,c,d
int cmp_str(const void* a, const void* b) { return strcmp(*(const char**)a, *(const char**)b); } // aaa,aab
LL gcd(LL p, LL q) { while (q) { LL t = p % q; p = q; q = t; }return p; }
LL modpow(LL a, LL n, int m) { LL x = 1; for (a %= m; n; n /= 2)n & 1 ? x = x * a % m : 0, a = a * a % m; return x; }
#define invmodpow(b,p)modpow(b,p-2,p)// a/b≡a*b^{-1}(mod p)...return b^{-1}(mod p)
typedef struct fac { LL n, exp; }F;
LL fact(LL n,F*a){LL x,i,j,c=0;x=n;for(i=2;i*i<=x;i++){for(j=1;x%i==0;j++)x/=i;if(j>1){a[c].n=i;a[c].exp=j-1;c++;}}if(x-1){a[c].n=x;a[c].exp=1;c++;}return c;}

//snippet
#define N 100009

int main(){
  int n,m=0,a[N],b[N]={0};LL ans;
  scanf("%d",&n);
  rep(i,n){
    scanf("%d",a+i);
    b[a[i]]++;
    m=mi(m,a[i]);
  }
  ans=(a[0]||b[0]-1?0:1);
  rep(i,n-1)ans=(ans*b[a[i+1]-1])%MOD;
  printf("%lld",ans);
}

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,a,b) for(int i=(a);i<(b);i++)
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second

using vint=vector<int>;
using pint=pair<int,int>;
using vpint=vector<pint>;

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

template<class A,class B>
ostream& operator<<(ostream& ost,const pair<A,B>&p){
	ost<<"{"<<p.first<<","<<p.second<<"}";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost,const vector<T>&v){
	ost<<"{";
	for(int i=0;i<v.size();i++){
		if(i)ost<<",";
		ost<<v[i];
	}
	ost<<"}";
	return ost;
}

signed main(){
	int N,K;
	cin>>N>>K;

	double ans=0.0;
	for(int i=1;i<=N;i++){
		int x=(K+i-1)/i;
		int t;
		if(x>1)t=__lg(x-1)+1;
		else t=0;
		ans+=1.0/(1<<t);
	}
	ans/=N;
	printf("%.20f\n",ans);
	return 0;
}

Measured memory_bytes: 256
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**13
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)

class ModInt():
    def __init__(self, n):
        self.n = n

    def __add__(self, x):
        x = ModInt.xn(x)
        return ModInt((self.n+x) % mod)

    def __sub__(self, x):
        x = ModInt.xn(x)
        return ModInt((self.n-x) % mod)

    def __mul__(self, x):
        x = ModInt.xn(x)
        return ModInt((self.n*x) % mod)

    def __truediv__(self, x):
        x = ModInt.xn(x)
        return ModInt(self.n * pow(x, mod-2, mod) % mod)

    @classmethod
    def xn(cls, x):
        if isinstance(x, ModInt):
            return x.n
        return x

    def __str__(self):
        return str(self.n)

def M(n): return ModInt(n)

class RollingHash():
    def __init__(self, s):
        self.N = n = len(s)
        a = [ord(c) for c in s]
        self.A1 = a1 = [M(a[0])]
        self.A2 = a2 = [M(a[0])]
        for c in a[1:]:
            a1.append(a1[-1] * 997 + c)
            a2.append(a2[-1] * 991 + c)

    def get(self, l, r):
        if l == 0:
            return (self.A1[r].n, self.A2[r].n)
        t1 = (self.A1[r] - self.A1[l-1] * pow(997, r-l+1, mod)).n
        t2 = (self.A2[r] - self.A2[l-1] * pow(991, r-l+1, mod)).n
        return (t1, t2)

def main():
    rr = []

    def f(n,m):
        rs = set()
        s = S()
        qa = [S() for _ in range(m)]
        l = 0
        r = 0
        rh = RollingHash(s)
        for q in qa:
            if q == 'L++':
                l += 1
            elif q == 'L--':
                l -= 1
            elif q == 'R++':
                r += 1
            else:
                r -= 1
            rs.add((l,r))

        rrs = set()
        for l, r in rs:
            rrs.add(rh.get(l,r))
        return len(rrs)

    while 1:
        n,m = LI()
        if n == 0:
            break
        rr.append(f(n,m))
        # print('rr', rr[-1])
        break

    return '\n'.join(map(str,rr))


print(main())



Measured memory_bytes: 222604
c=0
i = 0
h = []
w = []
while c == 0:
    a = input().split()
    if int(a[0]) == 0:
        c = 1
    elif int(a[1]) == 0:
        c = 1
    else:
        h.append(a[0])
        w.append(a[1])
        i = int(i) + 1

for j in range(int(i)):
    for k in range(int(h[j])):
        for o in range(int(w[j])):
            if (int(k) % 2) == 0:
                if (int(o) % 2) == 0:
                    if o == int(w[j]) - 1:
                        print('#')
                    else:    
                        print('#',end='')
                else:
                    if o == int(w[j]) - 1:
                        print('.')
                    else:    
                        print('.',end='')
            else:
                if (int(o) % 2) == 0:
                    if o == int(w[j]) - 1:
                        print('.')
                    else:    
                        print('.',end='')
                else:
                    if o == int(w[j]) - 1:
                        print('#')
                    else:    
                        print('#',end='')

    print('')


Measured memory_bytes: 7008
#include <bits/stdc++.h>
#include <cstdlib>  // abs() for integer 驍ｨ・ｶ陝・ｽｾ陋滂ｽ､雎弱ｅ・∫ｹｧ繝ｻ笆ｽ
#include <cmath>    // abs() for float, and fabs()
#include <algorithm>
#include <vector>
#include <string>
#define rep(i,n) for(int i = 0; i < (n);i++)
#define SORT(a) sort((a).begin(),(a).end())
#define REV(a) reverse((a).begin(),(a).end())
using namespace std;
#define INF 2000000000
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; }
#define che(a,string) cout<<"//"<<string <<"=="<<(a)<<"//" <<endl;

int main(){
  int n;
cin>>n;
   int k ;
   cin>>k;
   vector<int> h(n);
   rep(i,n){
     cin>>h[i];
   }
   int ans = 0;
   rep(i,n){
     if(h[i]>=k){
       ans++;
     }
   }
   cout<<ans<<endl;

}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define RREP(i,a,b) for(int i=(a);i>=(b);i--)
#define pq priority_queue
#define P pair<int,int>
#define P2 pair<int,P>
#define P3 pair<int,P2>
typedef long long ll; typedef long double ld;
using namespace std;
const int INF=1e9, MOD=1e9+7, around[]={0,1,1,-1,-1,0,-1,1,0,0};
const ll LINF=1e18;
const ld PI=abs(acos(-1));
int n,x,y,a[3010];
bool used[3010];
vector<int> g[3010];

int dfs(int p,bool f){
	used[p]=true;
	
	bool win=false;
	for(auto e:g[p]){
		if(used[e] or a[e]>=a[p]) continue;
		win |= !dfs(e, !f);
	}
	
	return win;
}

int main(){
	cin >> n;
	REP(i,0,n) cin >> a[i];
	REP(i,0,n-1) cin >> x >> y,g[x-1].push_back(y-1),g[y-1].push_back(x-1);
	
	vector<int> vec;
	REP(i,0,n){
		REP(j,0,n) used[j]=false;
		if(dfs(i,true)) vec.push_back(i);
	}
	
	for(auto s:vec) cout << s+1 << " "; cout << endl;
	return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<stdio.h>
using namespace std;
int main(){
int a[10],i;
cin>>a[0];
cin>>a[1];
cin>>a[2];
cin>>a[3];
cin>>a[4];
cin>>a[5];
cin>>a[6];
cin>>a[7];
cin>>a[8];
cin>>a[9];
cout<<a[0]+a[1]+a[2]+a[3]+a[4]+a[5]+a[6]+a[7]+a[8]+a[9]<<endl;


         return 0;
      }

Measured memory_bytes: 1160
#include<iostream>
#include<algorithm>
#include<math.h>
#include<string>
using namespace std;
int main(){
long long int A, B, C, D ,E ,F, N,M;
long long V[10000000] = {};
long long G[10000000] = {};
string S,Sa,Sb,Sc;
bool ans = true;
cin >> S;
cout << S[0] << S.size() - 2 << S[S.size() - 1] << endl;

return 0; 
}


Measured memory_bytes: 256
import itertools as it

N = int(input())
L = list(map(int, input().split()))

tuple_comb = it.combinations(range(N), 3)
ans = 0
for tup in tuple_comb:
    i, j, k = tup
    if L[i] == L[j] or L[j] == L[k] or L[k] == L[i]:
        continue
    if L[i] + L[j] <= L[k] or L[j] + L[k] <= L[i] or L[k] + L[i] <= L[j]:
        continue
    ans += 1

print(ans)


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

int main() {
  string n;
  cin >> n;
  if (n.at(0) == n.at(1) && n.at(1) == n.at(2)
      || n.at(1) == n.at(2) && n.at(2) == n.at(3)) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
map<ll,ll> mp;
ll a[2*1000005];
vector<ll> v;
 
int main()
{
	int n;
	cin >>n;
	ll sum=0,ans=0;
	for(int i=0;i<n;i++) cin >>a[i],mp[a[i]]++;
	for(auto x : mp)
	{
		ll res=x.second;
		if(res>=2) sum+=res*(res-1)/2,v.push_back(res);
	}
	for(int i=0;i<n;i++)
	{
		ll x=a[i];
		if(mp[x]>=2)
		{
			ll res=mp[x];
			cout <<sum-res*(res-1)/2+(res-1)*(res-2)/2<<endl;
		}
		else cout <<sum<<endl;
	}
}

Measured memory_bytes: 11640
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

int main(){
  int n, m;
  cin >> n >> m;
  vector<int> h(n);
  rep(snip_i, n) cin >> h.at(snip_i);
  vector<bool> ans(n, true);
  rep(i, m){
    int a, b;
    cin >> a >> b;
    a--; b--;
    if(h.at(a) > h.at(b)) ans.at(b) = false;
    else if(h.at(a) < h.at(b)) ans.at(a) = false;
    else{
      ans.at(a) = ans.at(b) = false;
    }
  }
  int tot = 0;
  rep(i, n){
    if(ans.at(i) == true) tot++;
  }
  cout << tot << endl;
  return 0;
}

Measured memory_bytes: 3788
#include<iostream>
#include<vector>
#include<numeric>
#define INF (1<<23)
#define rep(i,n) for(int i=0;i<n;i++)
    using namespace std;
using ll = long long;
int main()
{
    int n, m, x;
    cin >> n >> m >> x;
    vector<int> c(n);
    vector< vector<int> > a(n, vector<int>(m));
    rep(i, n)
    {
        cin >> c[i];
        rep(j, m)
        {
            cin >> a[i][j];
        }
    }

    ll ans = INF;
    for (int bit = 0; bit < (1 << n); bit++)
    {
        ll total = 0;
        vector<ll> m_list(m, 0);
        vector<int> indexes;
        for (int i = 0; i < n; i++)
        {
            if (bit & (1 << i))
            {
                indexes.push_back(i);
                for (int j = 0; j < m; j++)
                {
                    m_list[j] += a[i][j];
                }
            }
        }
        bool flag = true;
        for (int j = 0; j < m; j++)
        {
            if (m_list[j] < x)
            {
                flag = false;
                break;
            }
        }
        if (flag)
        {
            for (int j = 0; j < indexes.size(); j++)
            {
                total += c[indexes[j]];
            }
            if (total < ans)
            {
                ans = total;
            }
        }
    }
    if(ans==INF)ans=-1;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3636