akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main(void)
{
    int n, i, j;
    cin >> n;
    char x, b;
    int y;
    int a[4][13];
    for(i=0;i<4;i++){
        for(j=0;j<13;j++){
            a[i][j] = 0;
        }
    }
    for(i=0;i<n;i++){
        cin >> x >> y;
        if(x=='S') a[0][y-1] = y;
        else if(x=='H') a[1][y-1] = y;
        else if(x=='C') a[2][y-1] = y;
        else if(x=='D') a[3][y-1] = y;
    }
    for(i=0;i<4;i++){
        for(j=0;j<13;j++){
            if(a[i][j]==0){
                if(i==0) b = 'S';
                else if(i==1) b = 'H';
                else if(i==2) b = 'C';
                else if(i==3) b = 'D';
                printf("%c %d\n",b, j+1);
            }
        }
    }
    return 0;
}


Measured memory_bytes: 3204
#include<stdio.h>
int main(void){
	int a, b, c;
	for(a = 1; a < 10; a++){
		for(b = 1; b <10; b++){
			c = a * b;
			printf("%dx%d=%d\n",a, b, c);
		}
	}
	return 0;
}

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

class Program
{
    static void Main()
    {
        Console.WriteLine(Solve());
        return;
    }

    public static string Solve()
    {
        int N = ReadInt();
        string s = Read();
        int rCnt = 0;
        int bCnt = 0;
        for(int i=0;i<N;i++)
        {
            if(s[i]=='R')
            {
                rCnt++;
            }
            else
            {
                bCnt++;
            }
        }
        if(rCnt>bCnt)
        {
            return "Yes";
        }
        return "No";
    }

    private static string Read() { return Console.ReadLine(); }
    private static int ReadInt() { return int.Parse(Read()); }
    private static long ReadLong() { return long.Parse(Read()); }
    private static double ReadDouble() { return double.Parse(Read()); }
    private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
    private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
    private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
struct edge {
    int to;     // 辺の行き先
    int weight; // 辺の重み
    edge(int t, int w) : to(t), weight(w) { }
};
using Graph = vector<vector<int>>;
using dou =long double;
string Yes="Yes";
string YES="YES";
string NO="NO";
string No="No";
#define rep(i, n)         for(int i = 0; i < (int)(n); i++)
#define brep(n)           for(int bit=0;bit<(1<<n);bit++)
#define erep(i,container) for (auto i : container)
#define irep(i, n)        for(int i = n-1; i >= (int)0; i--)
#define rrep(i,m,n) for(int i = m; i < (int)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define all(x) (x).begin(),(x).end()
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define res resize
#define as assign
#define fi first
#define se second
#define itn int
#define mp make_pair
#define sum(a) accumulate(all(a),0)
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));
 
typedef long long ll;
const int INF = 2000000000;
const ll INF64 = 922337203685477580ll;
const int mod = 1000000007ll;
const ll  MOD = 1000000007LL;
const double pi=3.1415926535897932384626;
int main(){
    string s,t;
    std::cin >> s>>t;
    vvector(dp,int,s.size()+1,t.size()+1,0);
    rep(i,s.size())rep(j,t.size()){
        //if(s[i]==t[j])dp[i+1][j+1]=max(dp[i][j]+1,dp[i+1][j+1]);
        if(s[i]==t[j])dp[i+1][j+1]=dp[i][j]+1;
        dp[i+1][j+1]=max(dp[i+1][1+j],dp[i][j+1]);
        dp[i+1][j+1]=max(dp[i+1][j+1],dp[i+1][j]);
    }
   // std::cout << dp[s.size()][t.size()] << std::endl;
    int i=s.size(),j=t.size();
    string ans;
    while(i>0&&j>0){
        if(dp[i][j]==dp[i-1][j]){
            i--;
        }
        else if(dp[i][j]==dp[i][j-1]){
            j--;
        }
        else{
            ans=s[i-1]+ans;
            i--;j--;
        }
    }
    std::cout << ans << std::endl;
}

Measured memory_bytes: 35584
#include<stdio.h>
int main(){
  int N,a,i,t,m=0,r[9]={0,0,0,0,0,0,0,0,0};
  scanf("%d",&N);
  for(i=0;i<N;i++){
    scanf("%d",&a);
    t=a/400;
    r[t<9?t:8]++;
  }
  for(i=0;i<8;i++)
    if(r[i])m++;
  printf("%d %d\n",m>0?m:1,m+r[8]);
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
# define ll int64_t
#define rep(i,n) for(ll i=0;i<n;i++)
#define rrep(i,n) for(ll i=1;i<=n;i++)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define mod 1000000007

using namespace std;

bool compare_by_b(pair<string,ll> a,pair<string,ll> b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}

bool my_compare(pair<string,ll> a,pair<string,ll> b){
    
    if(a.first != b.first) return a.first<b.first;
    if(a.second != b.second) return a.second>b.second;
    else return true;
}

int main(){
    ll n,k,q;
    cin>>n>>k>>q;
    vector<ll> a(q),b(n);
    rep(i,q) cin>>a[i];
    if(k-q>0) {
        rep(i,n) cout<<"Yes"<<endl;
        return 0;
    }
    else rep(i,n) b[i]=k-q;
    
    rep(i,q) b[a[i]-1]++;
    rep(i,n) {
        if(b[i]>0) cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }
    return 0;
}

Measured memory_bytes: 2176
#from collections import deque,defaultdict
printn = lambda x: print(x,end='')
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 10**18
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

import bisect
n = inn()
a = inl()
a.sort()
a.append(10**9+1)
b = inl()
b.sort()
b.append(10**9+1)
c = inl()
c.sort()
c.append(10**9+1)
sm = 0
for i in range(n):
    p = bisect.bisect_left(a,b[i])
    q = bisect.bisect_right(c,b[i])
    sm += p*(n-q)
print(sm)


Measured memory_bytes: 24180
#include <bits/stdc++.h>
#include <algorithm>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(x) (x).begin(), (x).end()
#define PB(x) push_back(x)
#define MP(x,y) make_pair(x,y)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

 
int main() {

    ll x;
    cin >> x;

    ll ans=0;
    ans=(x/500)*1000;
    ans+=((x-((x/500)*500))/5)*5;

    cout<<ans<<endl;

 return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <queue>
#include <stack>

using namespace std;

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

const ll mod = 1000000007;

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

  int x;
  cin >> x;

  if (x == 1) cout << 0 << endl;
  else cout << 1 << endl;

  return 0;
}


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

ll N,K,Y,X;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>K>>X>>Y;
	
	cout<<min(K,N)*X + max(N-K,0LL)*Y<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n';
	FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	solve(); return 0;
}


Measured memory_bytes: 256
X,N=map(int,input().split())
if N==0:
    print(X)
else:
    p=list(map(int,input().split()))
    d=set()
    for P in p:
        d.add(P)
    ans=0
    dmin=100
    for i in range(200):
        if i not in d:
            if abs(X-i)<dmin:
                dmin=abs(X-i)
                ans=i
    print(ans)

Measured memory_bytes: 9224
import java.util.*;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String line = sc.nextLine();
    String[] nums = line.split(" ");
    int W = Integer.parseInt(nums[0]);
    int H = Integer.parseInt(nums[1]);
    int x = Integer.parseInt(nums[2]);
    int y = Integer.parseInt(nums[3]);
    int r = Integer.parseInt(nums[4]);

    if(x + r > W || x - r < 0 || y + r > H || y - r < 0) {
      System.out.println("No");
    }else {
      System.out.println("Yes");
    }
  }
}



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


#define FOR(i, start, end) for(uint64_t i=start; i<end; i++)
#define REP(i, n) FOR(i, 0, n)

// 最大公約数gcd
// 最小公倍数lcm=m*n/gcd
uint64_t gcd(uint64_t m, uint64_t n) {
  uint64_t temp;
  while (m % n != 0){
    temp = n;
    n = m % n;
    m = temp;
  }
  return n;
}

uint64_t lcm(uint64_t m, uint64_t n) {
  return (m*n)/gcd(m,n);
}

void comb(vector<vector <uint64_t> > &v){
  for(uint64_t i = 0;i <v.size(); i++){
    v[i][0]=1;
    v[i][i]=1;
  }
  for(uint64_t k = 1;k <v.size();k++){
    for(uint64_t j = 1;j<k;j++){
      v[k][j]=(v[k-1][j-1]+v[k-1][j]);
    }
  }
}

// 掛け算オーバーフロー判定
bool is_product_overflow(uint64_t a, uint64_t b) {

	uint64_t prod = a * b;
	
	return (prod / b != a);
}

//素因数分解
void primeFactorization(uint64_t a, list<uint64_t> &factors){ //素因数分解を出力するプログラム
  long i,sq;
  if(a%2==0){ //偶数の場合
    factors.push_back(2);
    primeFactorization(a/2,factors); //2で割った値で再帰
    return;
  }
  sq = sqrt(a);
  for(i=3;i<=sq;i+=2){ //3以上√a以下の奇数の場合
	if(a%i==0){
	  factors.push_back(i);
      primeFactorization(a/i,factors); //割れた値で再帰
      return;
	}
  }
  //偶数でも3以上√a以下の奇数の場合でも割り切れない場合
  if(a!=1){ //aが1でないなら、a自身は素数
    factors.push_back(a);
  }
}

// 円周率
// M_PI

// #include <iomanip> // setprecisionを使用するのに必要
// cout << std::fixed << std::setprecision(15) << y << endl;

// 昇順
// priority_queue<int, vector<int>, greater<int> > queue;

signed main() {
  string w,s;
  getline(cin, w);
  transform(w.begin(), w.end(), w.begin(),
    [](unsigned char c){ return tolower(c); });
  int count = 0;
  while(true){
      getline(cin,s);
      if(s.compare("END_OF_TEXT")==0) break;
      transform(s.begin(), s.end(), s.begin(),
        [](unsigned char c){ return tolower(c); });
      size_t pos = 0;
      while(pos!=string::npos){
          pos = s.find(w,pos);
          if(pos!=string::npos){
              if(pos==0 || s[pos-1]==' '){
                  if(pos+w.length()==s.length() || s[pos+w.length()]==' ') count++;
              }
              pos += 1;
          }
      }
  }
  cout << count << endl;
 
  return 0;
}


Measured memory_bytes: 3204
S = list(input())
k = int(input())

for i, s in enumerate(S):
    if ord('z') - ord(s) + 1 <= k:
        S[i] = 'a'
        k -= (ord('z') - ord(s) + 1) % 26

S[-1] = chr((ord(S[-1]) + (k % 26)) % ord('a') % 26 + ord('a'))

print(str().join(S))

Measured memory_bytes: 4156
while(True):
    try:
        s, t = [input() for i in range(2)]
        if len(s) > len(t):
            print("GREATER")
        elif len(s) < len(t):
            print("LESS")
        else:
            print("GREATER" if s > t else "LESS" if s < t else "EQUAL")
    except EOFError:
        exit()


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

using namespace std;

string str_reverse(string s)
{
    string ret;
    int i = s.size() - 1;
    
    while (-1 < i) {
        ret += s[i--];
    }
    
    return ret;
}
 
int main() {
	string str;
	
	cin >> str;
	
	str = str_reverse(str);
	
	cout << str << endl;
	
	return 0;
}

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

class Program {
    static int ReadInt() { return int.Parse(Console.ReadLine()); }
    static int[] ReadInts() { return Console.ReadLine().Split().Select(int.Parse).ToArray(); }
    static string[] ReadStrings() { return Console.ReadLine().Split(); }

    static bool Match(int p, string s, string t) {
        if (p < 0 || p + t.Length > s.Length) return false;

        for (int i = 0; i < t.Length; i++) {
            if (s[p + i] != t[i])
                return false;
        }
        return true;
    }

    static bool Calc(string s) {
        var ts = new[] { "dream", "dreamer", "erase", "eraser" };
        int p = s.Length - 1;
        while (p >= 0) {
            bool found = false;
            foreach (var t in ts) {
                if (Match(p - t.Length + 1, s, t)) {
                    p -= t.Length;
                    found = true;
                    break;
                }
            }
            if (!found) return false;
        }
        return true;
    }

    static void Main() {
        var s = Console.ReadLine();
        Console.WriteLine(Calc(s) ? "YES" : "NO");
    }
}

Measured memory_bytes: 3032
#include "bits/stdc++.h"
#define hhh cerr<<"hhh"<<endl
#define see(x) cerr<<(#x)<<'='<<(x)<<endl
using namespace std;
typedef long long ll;
typedef pair<int,int> pr;
inline int read() {int x=0,f=1;char c=getchar();while(c!='-'&&(c<'0'||c>'9'))c=getchar();if(c=='-')f=-1,c=getchar();while(c>='0'&&c<='9')x=x*10+c-'0',c=getchar();return f*x;}

const int maxn = 3e5+7;
const int inf = 0x3f3f3f3f;
const int mod = 1e9+7;

int a[maxn];

int main() {
    ll n, k; cin>>n>>k;
    n%=k;
    cout<<min(k-n,k-(k-n))<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <unordered_map>
#include <deque>
#include <list>
#include <set>
#include <random>
#include <deque>

using namespace std;
using ll = long long;
const int BIG = 100000007;


int main(){
    for(int i = 1;i <= 5;++i){
        ll l;
        cin >> l;
        if(l - i != 0){
            cout << i << endl;
            return 0;
        }
    }
}




Measured memory_bytes: 3156
import sys
sys.setrecursionlimit(10000)
def dfs(x,y):
    for i in range(-1,2):
        if 0<=x+i<a[1]:
            for j in range(-1,2):
                if 0<=y+j<a[0]:
                    if G[x+i][y+j]==1:
                        G[x+i][y+j] = 0
                        dfs(x+i,y+j)
while  True:
    a = list(map(int, input().split()))
    if a[0] == 0:
        break
    G = []
    cnt = 0
    for i in range(a[1]):
        G.append(list(map(int, input().split())))
    for i in range(a[1]):
        for j in range(a[0]):
            if G[i][j] == 1:
                cnt += 1
                dfs(i,j)
    print(cnt)


Measured memory_bytes: 7996
#include <cstdio>
#include <algorithm>

typedef long long LL;
const int MN = 300005;

int N, A[MN];
LL Ans;

int main() {
	scanf("%d", &N), N *= 3;
	for (int i = 1; i <= N; ++i) scanf("%d", &A[i]);
	std::sort(A + 1, A + N + 1);
	for (int i = N / 3 + 1; i <= N; i += 2) Ans += A[i];
	printf("%lld\n", Ans);
	return 0;
}

Measured memory_bytes: 2896
#include<iostream>
#include<iomanip>
#include<math.h>
using namespace std;

int main(){
    int64_t i;//preparation for
    int n;
    int a[3];

    cin>>n;

    for(i=0;i<3;i++){
        a[i]=n%10;
        n=(n-a[i])/10;
        if(a[i]==7){
            cout<<"Yes";
            break;
        }
        else{}

        if(i==2){
            cout<<"No";
        }
        else{}
    }

    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
const int maxn=1005;

int n;
int data[maxn];

int main()
{
    while(~scanf("%d", &n)){
        for(int i=1;i<=n;i++)scanf("%d", &data[i]);
        sort(data+1, data+n+1);
        for(int i=1;i<=n;i++){
            if(i%2==0)data[i]=24-data[i];
        }
        sort(data+1, data+n+1);
        int ans=min(data[1], 24-data[1]);
        for(int i=1;i<=n;i++){
            ans=min(ans, data[i]-data[i-1]);
        }
        printf("%d\n", ans);
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>

namespace nt {
    template<typename T, typename U>
    T pow(T n, U p) {
        T res = 1;
        while (p > 0) {
            if (p % 2 == 1) {
                res *= n;
            }
            n *= n;
            p /= 2;
        }
        return res;
    }
}

int main() {
    int n;
    std::cin >> n;
    int m = nt::pow(2, n);
    std::vector<int> s(m);
    std::map<int, int> num;
    for (int i = 0; i < m; i++) {
        std::cin >> s[i];
        s[i] *= -1;
        num[s[i]]++;
    }
    std::sort(s.begin(), s.end());

    std::vector<int> now;
    now.push_back(s[0]);
    num[s[0]]--;
    if (num[s[0]] == 0) {
        num.erase(s[0]);
    }

    bool can = true;
    for (int i = 1; i <= n; i++) {
        int k = now.size();
        // k 個作る
        for (int j = 0; j < k; j++) {
            auto it = num.upper_bound(now[j]);
            if (it == num.end())  {
                can = false;
                goto end;
            }
            int cr = it->first;
            now.push_back(cr);
            num[cr]--;
            if (num[cr] == 0) {
                num.erase(cr);
            }
        }
    }

  end:
    if (can) {
        std::cout << "Yes" << std::endl;
    } else {
        std::cout << "No" << std::endl;
    }

    return 0;
}


Measured memory_bytes: 14716
#include <bits/stdc++.h>
using namespace std;
int main() {
    // insert code here...
    int N;
    int A;
    int B;
    cin>>N>>A>>B;
    if(N*A>=B){
        cout<<B<<endl;
    }
    else{
        cout<<N*A<<endl;
    }
}

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

#ifdef DEBUG
#include "inc/debug.hpp"
#else
#define debug(...) 42
#endif

bool sorted[200010];

class SegMin {
public:
    int n;
    vector<int> nodes;
    SegMin(int _n) {
        n = 1 << (int)ceil(log2(_n));
        nodes.resize(n*2-1, INT_MAX);
    }
    void update(int i, int x) {
        i += n-1;
        nodes[i] = x;
        while (i > 0) {
            i = (i - 1) / 2;
            nodes[i] = min(nodes[i*2+1], nodes[i*2+2]);
        }
    }
    int query(int l, int r) {
        return query(l, r, 0, n, 0);
    }
    int query(int l, int r, int tl, int tr, int k) {
        if (tr <= l || r <= tl) return INT_MAX;
        if (l <= tl && tr <= r) return nodes[k];
        int t1 = query(l, r, tl, (tl+tr)/2, 2*k+1);
        int t2 = query(l, r, (tl+tr)/2, tr, 2*k+2);
        return min(t1, t2);
    }
};

class SegMax {
public:
    int n;
    vector<int> nodes;
    SegMax(int _n) {
        n = 1 << (int)ceil(log2(_n));
        nodes.resize(n*2-1, -INT_MAX);
    }
    void update(int i, int x) {
        i += n-1;
        nodes[i] = x;
        while (i > 0) {
            i = (i - 1) / 2;
            nodes[i] = max(nodes[i*2+1], nodes[i*2+2]);
        }
    }
    int query(int l, int r) {
        return query(l, r, 0, n, 0);
    }
    int query(int l, int r, int tl, int tr, int k) {
        if (tr <= l || r <= tl) return -INT_MAX;
        if (l <= tl && tr <= r) return nodes[k];
        int t1 = query(l, r, tl, (tl+tr)/2, 2*k+1);
        int t2 = query(l, r, (tl+tr)/2, tr, 2*k+2);
        return max(t1, t2);
    }
};

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> P(N);
    for (int i=0; i<N; ++i) cin >> P[i];

    int res = 0;
    int cnt = 0;
    for (int i=0; i<N; ++i) {
        if (i == 0 || P[i-1] < P[i]) cnt ++;
        else cnt = 1;
        if (K <= cnt) {
            sorted[i-K+1] = true;
            res = 1;
        };
    }

    SegMin segmin(N);
    SegMax segmax(N);
    for (int i=0; i<N; ++i) {
        segmin.update(i, P[i]);
        segmax.update(i, P[i]);
    }

    if (!sorted[0]) res ++;
    for (int i=1; i+K-1<N; ++i) {
        if (sorted[i]) continue;
        int mn = segmin.query(i-1, i+K);
        int mx = segmax.query(i-1, i+K);
        if (P[i-1] == mn && P[i+K-1] == mx) continue;
        res ++;
    }
    cout << res << endl;

    return 0;
}

Measured memory_bytes: 5376
a, v = list(map(int, input().split()))
b, w = list(map(int, input().split()))
t = int(input())
if a > b:
  a, b = a-v*t, b-w*t
  # a = -1 * 10**9 if a < -1 * 10**9 else a
  # b = -1 * 10**9 if b < -1 * 10**9 else b
  if a <= b:
    print('YES')
  else:
    print('NO')
else:
  a, b = a+v*t, b+w*t
  # a = 10**9 if a > 10**9 else a
  # b = 10**9 if b > 10**9 else b
  if a >= b:
    print('YES')
  else:
    print('NO')


Measured memory_bytes: 9188
#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 fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//---------------------------------------------------------------------------------------------------
void _main() {
	int N,M;
	cin >> N >> M;
	int m[31] = { };
	rep(i, 0, N) {
		int K;
		cin >> K;
		rep(j, 0, K) {
			int A;
			cin >> A;
			m[A]++;
		}
	}

	int count = 0;
	rep(h, 1, M+1) {
		if (m[h] == N) count++;
	}
	cout << count << endl;
}

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

int main(){
  string s;
  cin >> s;
  int a[26] = {0};
  for(int i = 0;i < s.size();++i){
    a[s[i]-'a']++;
  }
  bool flag = false;
  for(int i = 0;i < 26;++i){
    if(a[i] == 0){
      cout << (char)('a' + i) << endl;
      flag = true;
      break;
    }
  }
  if(!flag) cout << "None" << endl;
  return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define show(x) {for(auto i: x){cout << i << " ";} cout << endl;}
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  int N;
  cin >> N;
  string S;
  cin >> S;
  string T;
  cin >> T;
  string ans;
  rep(i, N) {
    ans.push_back(S[i]);
    ans.push_back(T[i]);
  }
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 3520
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <functional>
#include <utility>
#include <fstream>

using namespace std;

#define ll long long
#define INF 2000000000
#define LINF 9000000000000000000
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define dum(x) cout<<#x<<'='<<x<<endl
#define dum2(x,y) cout<<#x<<'='<<x<<' '<<#y<<'='<<y<<'\n'<<endl
#define dum3(x,y,z) cout<<#x<<'='<<x<<' '<<#y<<'='<<y<<' '<<#z<<'='<<z<<'\n'<<endl
#define darr(arr,n) rep(i,(n-arr)){cout<<*(arr+i)<<' ';}cout<<endl
#define ddarr(arr,a,b) rep(i,a){rep(j,b){cout<<*(arr+i*b+j)<<' ';}cout<<endl;}

//ifstream in("Text.txt");cin.rdbuf(in.rdbuf());

ll a[100010];
int main() {
    int N;
    cin >> N;
    rep(i, N)cin >> a[i];

    int cou = 0;
    rep(i, N) {
        while (a[i] % 2 == 0) {
            
            a[i] /= 2;
            cou++;
        }
    }
    cout << cou << endl;
}

Measured memory_bytes: 384
import sys

readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)
INF = float('inf')

N, K = map(int, readline().split())
H = list(map(int, readline().split()))

dp = [INF] * N
dp[0] = 0

# 配るDP
for i in range(N):
    for j in range(1, K+1):
        if i+j < N:
            dp[i+j] = min(dp[i+j], dp[i]+abs(H[i] - H[i+j]))
    
ans = dp[-1]
print(ans)

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

using namespace std;

int n;
int calcCircleOf2Point(int x1, int y1, int x2, int y2, int x3, int y3, double *cx, double *cy, double *r)
{
	double 	ox, oy, a, b, c, d ;
	double 	r1, r2, r3 ;
	int		stat ;

	a = x2 - x1 ;
	b = y2 - y1 ;
	c = x3 - x1 ;
	d = y3 - y1 ;

	stat = -1 ;

	if  ((a && d) || (b && c)) {
		ox = x1 + (d * (a * a + b * b) - b * (c * c + d * d)) / (a * d - b * c) / 2 ;
		if  (b) {
			oy = (a * (x1 + x2 - ox - ox) + b * (y1 + y2)) / b / 2 ;
		} else {
			oy = (c * (x1 + x3 - ox - ox) + d * (y1 + y3)) / d / 2 ;
		}
		r1   = sqrt((ox - x1) * (ox - x1) + (oy - y1) * (oy - y1)) ;
		r2   = sqrt((ox - x2) * (ox - x2) + (oy - y2) * (oy - y2)) ;
		r3   = sqrt((ox - x3) * (ox - x3) + (oy - y3) * (oy - y3)) ;
		*cx = ox ;
		*cy = oy ;
		*r  = (r1 + r2 + r3) / 3 ;
		stat = 0 ;
	}

	return stat ;
}

int x[50],y[50];
int check(double cx,double cy,double r){
    for(int i = 0;i < n;i++){
        if(sqrt(pow(abs(x[i]-cx),2)+pow(abs(y[i]-cy),2)) > r+0.0000001){
            return 0;
        }
    }
    return 1;
}

void solve(){
    int i,j,k;
    cin >> n;
    for(i = 0;i < n;i++) cin >> x[i] >> y[i];
    double ans = 99999;
    for(i = 0;i < n;i++){
        for(j = i+1;j < n;j++){
            double cx,cy,r;
            cx = x[i]+x[j];
            cy = y[i]+y[j];
            cx /= 2; cy /= 2;
            r = sqrt(pow(abs(x[i]-x[j]),2)+pow(abs(y[i]-y[j]),2))/2;
            if(check(cx,cy,r)){
                ans = r;
                break;
            }
            for(k = 0;k < n;k++){
                if(k == i || k == j) continue;
                calcCircleOf2Point(x[i],y[i],x[j],y[j],x[k],y[k],&cx,&cy,&r);
                if(check(cx,cy,r)){
                    if(ans > r) ans = r;
                }
            }
        }
    }
    printf("%.9f\n",ans);
}

int main(){
    solve();
}


Measured memory_bytes: 256
#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
#define rep(i, a, b) for (int i = a; i < b; i++)
#define ff first
#define pii pair<int, int>
#define vii vector< pair<int,int> >
#define vi vector<int>
#define vvi vector< vector< int> >
#define ss second
#define mod 998244353
#define pb push_back
#define mp make_pair
#define int long long
#define all(a) a.begin(), a.end()
#define inf (1LL<<61)
#define ull unsigned long long
#define debug1(x) cerr << #x << ": " << x <<'\n'
#define debug2(x, y) cerr << #x << ": " << x << '\t' << #y << ": " << y <<'\n'
#define debug3(x, y, z) cerr << #x << ": " << x << '\t' << #y << ": " << y << '\t' << #z << ": " << z <<'\n'
using namespace std;
//int dx[]={1,0,-1, 0};int dy[]={0,1,0, -1}; //4 Direction
//int dx[]={1,1,0,-1,-1,-1,0,1};int dy[]={0,1,1,1,0,-1,-1,-1};//8 direction
bool compare(const pair<int,int> &a, 
              const pair<int,int> &b) 
{   
    if(a.ff == b.ff){
        return (b.ss < a.ss);
    }
    return (a.ff<b.ff); 
}

int n ,m;
int col[100005];
vi g[100005];
int ans[100005];
map<pair<int, int>, int> map1;
int32_t main()
{
    // IOS;
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt","r",stdin); 
    // freopen("output.txt","w",stdout);
    // #endif
    /********************* From here ***********************/
    double a,b,t;
    cin >> a >> b >> t;
    int ans = 0;
    int time = a;
    while(time < t+0.5){
        //cout << time << " " << ans;
        ans += b;
        time +=a;
    }
    cout << ans;

}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
template <class T>
using vc = vector<T>;
template <class T>
using vvc = vector<vector<T>>;
using vl = vector<ll>;

const ll MOD = 1e9 + 7;
const ll INF = 1e14;
const ld EPS = 1e-11;

#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (int i = (l); i < (r); i++)
#define reper(i, l, r) for (int i = (r)-1; i >= (l); i--)

void init() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
}
//--------------------------------------------------------------------------------//

int main() {
    init();
    ll a, b;
    cin >> a >> b;
    string s = "", t = "";
    rep(i, a) s += to_string(b);
    rep(i, b) t += to_string(a);
    if (s < t)
        cout << s << endl;
    else
        cout << t << endl;
    return 0;
}

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

const int N=2e5+5;
char s1[N],s2[N];
int a[N],b[N];

int main() {
	scanf( "%s %s" , s1 , s2 ) ;
	int len1=strlen(s1),len2=strlen(s2);
	if(len1!=len2)return puts("No"),0; 
	for(int i=1;i<len1;i++) {
		if(!a[s1[i]-'a']&&!b[s2[i]-'a'])a[s1[i]-'a']=s2[i]-'a',b[s2[i]-'a']=s1[i]-'a';
		if(a[s1[i]-'a']==s2[i]-'a'&&b[s2[i]-'a']==s1[i]-'a')continue;
		if(a[s1[i]-'a']!=(s2[i]-'a')||(b[s2[i]-'a']!=s1[i]-'a'))return puts("No"),0;
	}
	puts("Yes");
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define ll long long
#define io ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define fi first
#define se second

using namespace std;

int main() 
{
//	freopen("test.inp","r",stdin);
//	freopen("BAILAM.OUT","w",stdout);	
	io;
	int n, a = 0, t = 0, w = 0, r = 0;
	cin >> n;
	while (n--)
	{
		string s;
		cin >> s;
		if (s[0] == 'A') ++a;
		if (s[0] == 'T') ++t;
		if (s[0] == 'W') ++w;
		if (s[0] == 'R') ++r;
	}
	
	cout << "AC x " << a;
	cout << "\nWA x " << w;
	cout << "\nTLE x " << t;
	cout << "\nRE x " << r;	
    return 0;
}

Measured memory_bytes: 3656
#include <cstdio>
#include <algorithm>
#include <vector>
#include <set>
#include <queue>
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;

#define pb push_back
#define mk make_pair
#define f0(i,b) for(int i=0;i<(b);i++)
#define f1(i,b) for(int i=1;i<=(b);i++)
#define f2(i,a,b) for(int i=(a);i<=(b);i++)
#define sf(a) scanf("%d",&a);
#define sfl(a) scanf("%lld",&a);
#define pf(a) printf("%d\n",a);
#define pfl(a) printf("%lld\n",a);
#define TEST int test; cin >> test;while(test--)
#define ii pair<int,int>
#define iil pair<ll,ll>
#define loop(i,a,b) for(int i = a ; i < b ; i++)
#define INF 2147483647


int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};
int dx4[] = {0, 0, 1, -1};
int dy4[] = {1, -1, 0, 0};
const double pi = acos(-1.0);


void solve()
{
    int n, k, d, x, y;
    cin >> n >> k;
    int a[n+10];
    map<int,int>mp;

    for(int i = 1 ; i <= n ; i++)
        cin >> a[i];

    for(int j = 0 ; j < k ; j++)
    {
        cin >> x >> y;
        if(a[x] < a[y]) mp[x] = 1;
        else if(a[x] > a[y]) mp[y] = 1;
        else mp[x] = 1, mp[y] = 1;
    }

    int c = 0;
    for(int i = 1 ; i <= n ; i++)
    {
        if(mp.find(i) == mp.end())
        {
            c++;
        }
    }
    cout << c << endl;
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    //TEST
    solve();
    return 0;
}


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

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define rep(i, n) repd(i, 0, n)

using namespace std;

using ll = long long;
using ul = unsigned long long;
ll mod = 1000000007;

int main() {
source:
    ll n, k;
    ll r, s, p;
    string t;
    cin >> n >> k;
    cin >> r >> s >> p;
    cin >> t;
    char res[n];
    rep(i, n) { res[i] = t[i]; }

    for (int i = 0; i + k < n; i++) {
        if (res[i] == res[i + k]) {
            res[i + k] = 'x';
        }
    }

    ll ans = 0;
    rep(i, n) {
        switch (res[i]) {
        case 'r':
            ans += p;
            break;
        case 's':
            ans += r;
            break;
        case 'p':
            ans += s;
            break;
        }
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 512
#include <iostream>
    #include <string>
    using namespace std;
     
    int main()
    {
      int n;
      int sum;
      int min=999999;
      cin >> n;
      cin >> sum;
      for (size_t i = 0; i < n; i++) {
        int temp;
        cin >> temp;
        if (temp<min)
        {
          min=temp;
        }
        sum=sum-temp;
      }
      int ans=n+sum/min;
      cout << ans;
     
      return 0;
    }

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <functional>
#include <vector>
#include <queue>
#include <map>
#include <stack>
#include <string>
#include <bitset>
#include <cmath>

using namespace std;

typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)

int const N_MAX = 1e5;

int N;
ll K;
ll A[N_MAX + 1];

int main() {
  scanf("%d %lld", &N, &K);
  rep(i, N) scanf("%lld", &A[i]);

  int ones[41] = {};
  rep(i, N) {
    bitset<41> bi(A[i]);
    string s = bi.to_string();
    rep(j, 41) {
      if (s[j] == '1') ones[j]++;
    }
  }

  ll max_f = 0;
  ll x = 0;
  rep(i, 41) {
    ll base = pow(2, 40 - i);

    bool zero = ones[i] < (N - ones[i]);

    if (zero && (x + base) <= K) {
      x += base;
      max_f += base * (N - ones[i]);
    } else {
      max_f += base * ones[i];
    }
  }
  printf("%lld\n", max_f);
}


Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#define N 1000005
using namespace std;
typedef long long ll;
ll mod = 1000000007;
int n;
int a[102];
int main() {
	cin>>n;
	for (int i = 1; i <= n; ++i) {
		cin>>a[i];
	}
	sort(a+1, a+n+1);
	cout<<a[n]-a[1]<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
   int n;
   int temp;
   int ans;
   cin >> n;
   
   
   for(int i=1;i<=9;i++)
   {
       temp=n-111*i;
       
       if(temp<=0){ans=111*i;break;}
       
   }
   
   cout << ans<<endl; 
   
   return 0;
}

Measured memory_bytes: 256
from subprocess import*
call(('python3','-c',"""
import numpy
I=lambda:map(int,input().split())
W,H,N=I()
m=numpy.zeros((H,W),int)
while N:x,y,a=I();m[y*(a>3):H*(a^3)or y,x*(a==2):W*~-a or x]=1;N-=1
print(W*H-m.sum())
"""))

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

using namespace std;

#define ll long long
#define fi first
#define se second

void test_case(){
	int n,m;
	cin>>n>>m;
	int ans=0;
	if(n>=2){
		ans+=(n*(n-1))/2;
	}
	if(m>=2){
		ans+=(m*(m-1))/2;
	}
	cout<<ans<<"\n";
}

int main(){
	int t=1;
	//cin>>t;
	while(t--)test_case();
}


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

// マクロ //
#define rep(i,N) for(int i = 0; i < N; i++)
#define all(x) x.begin(), x.end()
#define sort(x) sort(all(x))
#define cou(x) cout << x << endl
#define y() cout << "Yes" << endl
#define n() cout << "No" << endl
#define Y() cout << "YES" << endl
#define N() cout << "NO" << endl
#define x2(x) x * x

// 型エイリアス //
using lint = long long;
using vi = vector<int>;
using vs = vector<string>;
using vb = vector<bool>;
using vvi = vector<vector<int>>;

// 関数 //
int gcd(int a, int b) {
    int t;
    while (b != 0) {
        t = a % b;
        a = b;
        b = t;
    }
    return a;
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}

// End of Template //

int main() {

	int N;
	cin >> N;

    if (N >= 2100)
        cou(1), exit(0);

    int X = N / 100;
    cou((X * 5 >= N - X * 100 ? 1 : 0));

}

Measured memory_bytes: 256
//
//  atcoder.cpp
//
//
//  Created by 中川阿津志 on 2018/12/05.
//
#include <bits/stdc++.h>
#define REP(i, N) for(int i=0; i<N; i++)
using namespace std;

//#include "atcoder.hpp"

long long gcd(long long a, long long b) {
    if (a>b) swap(a,b);
    
    auto r = b % a;
    
    return (r ? gcd(r, a) : a);
}
int main() {
    int K, A, B;
    
    cin >> K >> A >> B;
    
    if (B - A <= 2)
        cout << 1 + K << endl;
    else {
        K -= A - 1;
        long long result = A;
        result += (K / 2LL) * (B - A);
        if (K % 2 == 1) result++;
        cout << result << endl;
    }
    
    return 0;
}


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

int main(void){
    int n;
    cin >> n;
    map<int,int> mp;
    rep(i,n) {
        int x;
        cin >> x;
        mp[x]++;
    }
    int res = 0;
    int SIZE = 1000010;
    vector<bool> multi(SIZE);
    for(auto itr : mp){
        int x = itr.first;
        int cnt = itr.second;
        if (multi[x]) continue;
        for(int y = x; y < SIZE; y += x){
            multi[y] = true;
        }
        if (cnt == 1) res++;
    }
    cout << res << endl;
    return 0;
}


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

int dfs(int i, vector<int>& dp, vector<vector<int>>& adj)
{
    if (dp[i] >= 0) return dp[i];
    if (adj[i].size() == 0) {
        dp[i] = 0;
        return 0;
    }
    int ans = 0;
    for (int v : adj[i]) {
        ans = max(ans, 1 + dfs(v, dp, adj));
    }
    dp[i] = ans;
    return ans;
}

int main()
{
    int N, M;
    cin >> N >> M;
    vector<vector<int>> adj(N);
    for (int i = 0; i < M; i++) {
        int x, y;
        cin >> x >> y;
        adj[x - 1].push_back(y - 1);
    }
    vector<int> dp(N, -1);
    int ans = 0;
    for (int i = 0; i < N; i++) {
        if (dp[i] == -1) {
            ans = max(ans, dfs(i, dp, adj));
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 8832
#include<bits/stdc++.h>
#define REP(i,a,b) for(int i=(a);i<=(b);++i)
using namespace std;
inline int read(){
	int w=0;bool p=0;char c;
	while(!isdigit(c=getchar()))if(c=='-')p=1;
	while(isdigit(c))w=w*10+c-48,c=getchar();
	return p?-w:w;
}
const int N=107;
int n,num[N],num2[N],p[N],ha[N]; 
struct node{
	int x,y;
}a[N],b[N];
bitset<N> s[N],has,tmp;
bool cmp(int i,int j){
	return num[i]<num[j];
}
int main(){
	n=read();
	REP(i,1,n)a[i]=(node){read(),read()};
	REP(i,1,n)b[i]=(node){read(),read()};
	REP(i,1,n)s[i].reset();
	REP(i,1,n)REP(j,1,n)if(a[i].x<b[j].x&&a[i].y<b[j].y)
		s[i][j]=1,num[i]++,num2[j]++;
	REP(i,1,n)p[i]=i;
	sort(p+1,p+1+n,cmp);
	int ans=0;
	has.reset();
	REP(i,1,n){
		int &o=p[i];
		if(num[o]==0)continue;
		tmp=(s[o]|has)^has;
		int mn=10000,t;
		REP(j,1,n)if(tmp[j]&&num2[j]<=mn)
			mn=num2[t=j];
		if(mn!=10000)has[t]=1,++ans;
	}
	cout<<ans<<endl;
	return 0;
}


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

using namespace std;

int n, m, kol[100005], ok[100005], ans;

int main(){
	cin >> n >> m;
	ok[1] = 1;
	for(int i = 1; i <= n; i++){
		kol[i] = 1;
	}
	for(int i = 1; i <= m; i++){
		int l, r;
		cin >> l >> r;
		kol[r]++;
		kol[l]--;
		if(ok[l] == 1 && kol[l] == 0){
			ok[l] = 0;
			ok[r] = 1;
		}
		else if(ok[l] == 1){
			ok[r] = 1;
		}
	}
	for(int i = 1; i <= n; i++){
		if(ok[i] == 1)ans++;
	}
	cout << ans;
}

Measured memory_bytes: 1024
#[allow(unused_imports)]
use itertools::Itertools;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;

fn main() {
    input! {
        n: usize,
        a: [i64; n],
    }
    if a.iter().any(|&x| x == 0) {
        println!("0");
    } else {
        let mut res = 1i64;
        for a in a {
            res = res.saturating_mul(a);
            if res > 1_000_000_000_000_000_000 {
                println!("-1");
                return;
            }
        }
        println!("{}", res);
    }
}


Measured memory_bytes: 4524
N = int(input())
S = input()
count_E = 0
min_change = 0
change = 0
W_flag = True
if S[0] == 'E':
    W_flag = False
for i in range(1, len(S)):
    if W_flag:
        change += 1
    if S[i] == 'E':
        count_E += 1
        W_flag = False
        change -= 1
        min_change = min(change, min_change)
    elif S[i] == 'W':
        W_flag = True
ans = count_E + min_change
print(ans)


Measured memory_bytes: 3780
n = int(input())
# a:上段,b:中段,c:下段
a = sorted([int(i) for i in input().split()])
b = sorted([int(i) for i in input().split()])
c = sorted([int(i) for i in input().split()])
"""
a = [_a[0]]
for i in range(1, n):
    if _a[i] != _a[i-1]:
        a.append(_a[i])
b = [_b[0]]
for i in range(1, n):
    if _b[i] != _b[i-1]:
        b.append(_b[i])
c = [_c[0]]
for i in range(1, n):
    if _c[i] != _c[i-1]:
        c.append(_c[i])
"""
aCount = [0 for i in range(len(a))]
bCount = [0 for i in range(len(b))]
# print(a)
# print(b)
# print(c)
#まず各bに対し、選択可能なcの個数を計算O(n)
k = len(c) - 1
for j in reversed(range(len(b))):
    if j < len(b) - 1:
        bCount[j] = bCount[j+1]
    while k >= 0 and b[j] < c[k]:
        bCount[j] = len(b) - k
        # print("bCount[{}]:{}".format(j, bCount[j]))
        k -= 1
# print(bCount)
k = len(b) - 1
for j in reversed(range(len(a))):
    if j < len(a) - 1:
        aCount[j] = aCount[j+1]
    while k >= 0 and a[j] < b[k]:
        # aCount[j] = len(a) - k
        aCount[j] += bCount[k]
        # print("bCount[{}]:{}".format(j, bCount[j]))
        k -= 1
print(sum(aCount))

Measured memory_bytes: 23548
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c;
  cin >> a >> b >> c;
  if(a!=b && b!=c && c!=a){
    cout << 3 << endl;
  }else{
    if(a==b && b==c){
      cout << 1 << endl;
    }else{
      cout << 2 << endl;
    }
  }
}

Measured memory_bytes: 256
//A,Elebereth Gilthoniel mantae!
//For Temeria!
#include<iostream>
#include<algorithm>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<cstdio>
#include<map>
#include<stack>
#include<queue>
#include<cstring> 
using namespace std;
string s;int k;
set<string> se;
int main()
{
 	//freopen("","r",stdin);
	//freopen("","w",stdout);
	 cin>>s>>k;
	 int l=s.size();
	 for(int i=0;i<l;i++)
	 {
	 	string ss="";
	 	for(int j=i;j<l;j++)
	 	{
	 		ss+=s[j];
	 		se.insert(ss);if(se.size()>k) se.erase(--se.end());
	 	}
	 }
	 cout<<*(--se.end());
	return 0;
}

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

#define debug(x) cout <<"DEBUG"<<" "<< #x << ":" << x << '\n'

// n回繰り返し
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順
#define rep1(i,n) for(int i = 1; i <= ((int)(n)); i++) // 1-indexed昇順
#define rrep(i,n) for(int i = ((int)(n)-1); i >= 0; i--)  // 0-indexed降順
#define rrep1(i,n) for(int i = ((int)(n)); i >= 1; i--)   // 1-indexed降順
#define all(x) (x).begin(),(x).end()

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii;  // 2次元配列
typedef vector<ll> vll;
typedef vector<double> vd;
typedef pair<int, int> PII;

template<typename T>
using vec = vector<T>;
template<class T>
using maxheap = std::priority_queue<T>;
template<class T>
using minheap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

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

const ld Pi = std::acos(-1.0L);
const ll infll = (1LL<<62)-1;
const int inf = (1<<30)-1;
const int mod = 1000000007;
// const int mod = 998244353;


/*FUNCs=================================================*/


/*MAIN==================================================*/
signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化
    // cout << fixed << setprecision(15);

    string s, t;
    int n, m, r; cin >> n >> m>> r;
    bool can = 0;
    if(n==m&&m!=r) can = 1;
    if(n!=m&&m==r) can = 1;
    if(n==r&&m!=r) can = 1;
    cout <<  (can ? "Yes" : "No") << '\n';
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        String line = sc.nextLine();
        String line1 = sc.nextLine();
        int w = Integer.parseInt(line);
        int n = Integer.parseInt(line1);
        int[][] abs = new int[n][2];
        for(int i = 0; i < n; i++) {
            String ab = sc.nextLine();
            String[] absp = ab.split(",");
            abs[i][0] = Integer.parseInt(absp[0]);
            abs[i][1] = Integer.parseInt(absp[1]);
        }
        
        int[] ans = new int[w];
        for(int i = 1; i <= w; i++) {
            int now = i;
            for(int j = 0; j < n; j++) {
                if(now == abs[j][0]) {
                    now = abs[j][1];
                }else if(now == abs[j][1]) {
                    now = abs[j][0];
                }
            }
            ans[now-1] = i;
        }
        
        for(int i = 0; i < w; i++) {
            System.out.println(ans[i]);
        }
    }
}



Measured memory_bytes: 26060
function main(input){
    let args = input.split(" ").map(x=>parseInt(x));
    let a = args[0];
    let b = args[1];
    let angle = (args[2]/180)*Math.PI;



    let S = a*b*Math.sin(angle)*(1/2);
    console.log(S);
    let L = Math.sqrt(a*a+b*b-2*a*b*Math.cos(angle))+a+b;
    console.log(L);
    let H = b*Math.sin(angle);
    console.log(H);
    
}


main(require("fs").readFileSync("/dev/stdin","utf-8"));


Measured memory_bytes: 15244
#include <bits/stdc++.h>
using namespace std;
int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
int firstNumber,secondNumber;
char x;
cin>>firstNumber>>x>>secondNumber;
if(x=='+')cout<<firstNumber+secondNumber;
else cout<<firstNumber-secondNumber;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-11;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
typedef unsigned long long ul;

LP a[200000];
//最小値をとる可能性があるか判定。真なら取りえない
ll f(LP x, ll i) {
	return x.first*i + x.second;
}
bool check(LP x, LP y, LP z) {
	return (y.first - x.first)*(z.second - y.second) >= (y.second - x.second)*(z.first - y.first);
}
int deq[200001]; ll out[200001];
ll h[1 << 18];
int main() {
	int n; cin >> n; ll c; cin >> c;
	rep(i, n) {
		cin >> h[i];
		a[i] = { -2 * h[i],h[i]*h[i] + c };
	}
	deq[0] = 0;
	int s, t; s = 0; t = 1;
	rep1(i, n-1) {
		while (s + 1 < t&&f(a[deq[s]], h[i]) >= f(a[deq[s + 1]], h[i]))s++;
		out[i] = f(a[deq[s]], h[i]) + (ll)h[i]*h[i];
		a[i].second += out[i];
		while (s + 1 < t&&check(a[deq[t - 2]], a[deq[t - 1]], a[i]))t--;
		deq[t++] = i;
	}
	cout << out[n - 1] << endl;
	//stop
	return 0;
}

Measured memory_bytes: 7296
#include <bits/stdc++.h>
using namespace std;
 
int main() {
int N;
  string S;
  cin >> N;
  cin >> S;
  int result = 1;
  for(int a = 1;a < S.length();a++){
  if(S[a] != S[a-1])result += 1;
    
  }
    cout <<result<< endl;
 
}

Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>

using ll = long long;

using namespace std;

int main() {
    string s, t;
    cin >> s >> t;
    int cnt = 0;
    for (int i=0; i<3; i++) cnt += (s[i] == t[i]);
    cout << cnt << '\n';
    return 0;
}

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

typedef long long ll;
ll n, c, x, ans = 1, M = 1e9 + 7;
int main()
{
	cin >> n;
	while (n--) {
		scanf("%d", &x);
		if (x >= c * 2 + 1) c++;
		else ans = ans * (c + 1) % M;
	}
	while (c) ans = ans * c-- % M;
    cout << ans << endl;
    return 0;
}

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

int main(){

  int N; cin >> N;
  string S; cin >> S;
  int K; cin >> K;

  // cout << S << endl;

  // cout << N << "\t" << K << endl;
  char tmp = S[K-1];
  // cout << tmp << endl;

  
  for(int i = 0 ; i < N ; ++i){
    if(tmp != S[i]) S[i] = '*';
  }

  cout << S << endl;

}

Measured memory_bytes: 256