akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <set>

using namespace std;

typedef long long ll;

int main() {
    ll n;  cin >> n;
    
    bool flag = false;
    ll k;
    for (k = 1; k * k <= 8*n + 1; k++) {
        if (k * k == 8*n+1) {
            flag = true;
            break;
        }
    }   
    if (!flag) {
        cout << "No" << endl;
        return 0;
    }
    cout << "Yes" << endl;
    k = (1+k)/2;
    cout << k << endl;
    vector<set<int> > s(k);
    ll x = 1;
    int i = 0;
    for (int i = 0; i < k-1; i++) {
        for (int j = i+1; j < k; j++) {
            s[i].insert(x);
            s[j].insert(x);
            x++;
        }
    }
    for (int i = 0; i < k; i++) {
        cout << k-1 << " ";
        for (auto x: s[i])
            cout << x << " ";
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 12996
#!/usr/bin/env python3
import sys


def solve(A: int, B: int, C: int, X: int):
    ans = 0
    for a in range(A+1):
        for b in range(B+1):
            for c in range(C+1):
                ans += (a * 500 + b * 100 + c * 50) == X
    return ans


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    X = int(next(tokens))  # type: int
    print(solve(A, B, C, X))

def test():
    import doctest
    doctest.testmod()

if __name__ == '__main__':
    #test()
    main()


Measured memory_bytes: 9032
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

# 110101以下の数は、以下のいずれかである
#
# 110101
# 110100 (1を一つ選んで0にする、それ以下の桁はなんでもよいので?とする)
# 1100?? 
# 10????
# 0?????
#
# 上の各パターンについて条件を満たすものをそれぞれ探し、maxをとる
# 各パターンでは、0になるべき桁が必ず0になるようにする
#
# 実装上は、?をすべて1で置換。orをとっても以下の数値を超えないようにする
#
# 110101
# 110011
# 101111
# 011111
#


import array
from bisect import *
from collections import *
import fractions
import heapq 
from itertools import *
import math
import re
import string

N, K = map(int, input().split())
A = []
B = []
for n in range(N):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)

ret = 0

# orをとって 110101 以下になるもののみretに足す
for n in range(N):
    if K | A[n] == K:
        ret += B[n]

# Kの下位ビットから順に見ていき、もし1があれば、その桁を0にして、その桁より下位をすべて1にする
for n in range(31):
    # n番目の桁が0なら、1にする
    if (K >> n) & 1 == 0:
        K |= (1 << n)
    else:
        # n番目の桁が1なら、0にする
        K ^= (1 << n)

        local_ret = 0
        for m in range(N):
            if K | A[m] == K:
                local_ret += B[m]
        ret = max(ret, local_ret)

        # また1に戻す
        K |= (1 << n)


print(ret)

    



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

pair<long, int> x[222222];
long b[222222];
int main() {
    int n, d, a;
    cin >> n >> d >> a;
    for(int i = 0; i < n; i++)
        cin >> x[i].first >> x[i].second,
            x[i].second = (x[i].second + a - 1) / a;
    sort(x, x + n);
    long c = 0, r = 0;
    for(int i = 0; i < n; i++) {
        c += b[i];
        auto t = x[i].second + c;
        if(t > 0) {
            r += t;
            c -= t;
            int j =
                upper_bound(x, x + n, make_pair(x[i].first + d + d, (int)1e9)) -
                x;
            if(j < n)
                b[j] += t;
        }
    }
    cout << r << endl;
    return 0;
}


Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
int main()
{
   int n,k;
  cin>>n>>k;
    int a[n];
     int b[n];
     for(int i=0;i<n;i++)
        cin>>a[i];
      b[0]=0;
      for(int i=0;i<n;i++)
        b[i]=10005;
      b[0]=0;
      for(int i=1;i<n;i++)
      {   int p;
        int c=0;
          for(int j=i-1;j>=0;j--)
          {
              c++;
              if(c>k)
                break;
              p=a[i]-a[j];
              if(p<0)
                p=-p;
                if(j==i-1)
                    b[i]=p+b[j];
                else
              b[i]=min(b[i],p+b[j]);
          }


      }
     /* for(int i=0;i<n;i++)
        cout<<b[i]<<" ";
        cout<<endl;*/
     cout<<b[n-1];
}



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

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

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; }

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

const int MAX = 200005;
const int INF = 1001001001;
const int MOD = 1000000007;

vector<int> G[MAX];
int dp[MAX];

int dfs(int v) {
    int res = -1;
    for (int u : G[v]) {
        if (dp[u] < 0) chmax(res, dfs(u));
        else chmax(res, dp[u]);
    }
    if (res < 0) return dp[v] = 0;
    return dp[v] = res + 1;
}

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

    rep(i, M) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        G[a].push_back(b);
    }

    rep(i, N) dp[i] = -1;
    rep(i, N) {
        if (dp[i] < 0) dfs(i);
    }

    int ans = 0;
    rep(i, N) chmax(ans, dp[i]);
    cout << ans << endl;
}

Measured memory_bytes: 10496
#include <iostream>

using namespace std;

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

int main(){
    int N;
    int x[200], y[200];
    x[0] = y[0] = 0;
    while(cin >> N, N){
        for(int i=0;i<N-1;i++){
            int ni, di; cin >> ni >> di;
            x[i+1] = x[ni] + dx[di];
            y[i+1] = y[ni] + dy[di];
        }
        int minx = 0, maxx = 0, miny = 0, maxy = 0;
        for(int i=0;i<N;i++){
            minx = min(minx, x[i]);
            maxx = max(maxx, x[i]);
            miny = min(miny, y[i]);
            maxy = max(maxy, y[i]);
        }
        cout << (maxx-minx+1) << " " << (maxy-miny+1) << endl;
    }
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define fi first
#define se second
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define pf push_front
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define SZ(x) (int)(x).size()
#define endl '\n'
#define FOR(a, b, c) for (auto(a) = (b); (a) < (c); ++(a))
#define ROF(a, b, c) for (auto(a) = (b); (a) > (c); --(a))
#define F0R(a, b) FOR ((a), 0, (b))
#define R0F(a, b) ROF ((a), (b), -1)
#define CEIL(a, b) ((a) + (b)-1) / (b)
#define SET(a, b) memset((a), (b), sizeof(a))
template <class t>
bool ckmin(t& a, const t& b) {
  return a > b ? a = b, true : false;
}
template <class t>
bool ckmax(t& a, const t& b) {
  return a < b ? a = b, true : false;
}
#ifndef DEBUG
#define DEBUG 0
#endif
#define dout if (DEBUG) std::cerr
#define dvar(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
template <class a, class b>
ostream& operator<<(ostream& o, const pair<a, b>& p);
template <class T>
struct IsC {
  template <class C>
  static char test(typename C::const_iterator*);
  template <class C>
  static int test(...);
  static const bool value = sizeof(test<T>(0)) == sizeof(char);
};
template <>
struct IsC<string> {
  static const bool value = false;
};
template <class C>
typename enable_if<IsC<C>::value, ostream&>::type operator<<(ostream& o, const C& c) {
  o << '[';
  for (auto it = c.begin(); it != c.end();)
      o << *it << (++it != c.end() ? ", " : "");
  return o << ']';
}
template <class a, class b>
ostream& operator<<(ostream& o, const pair<a, b>& p) {
  return o << '(' << p.fi << ", " << p.se << ')';
}

void solve() {
  FOR (i, 1, 6) {
    int a;
    cin >> a;
    if (a == 0) {
      cout << i << endl;
    }
  }

}

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

  int tt = 1;
  FOR (t, 1, tt + 1) {
      // cout << "Case #" << t << ": ";
      solve();
  }

  return 0;
}


Measured memory_bytes: 3612
import scala.io.StdIn.{readLine,readInt}
import scala.language.postfixOps

object Main {
  var cnt = 0
  val l = new Array[Int](250001)
  val r = new Array[Int](250001)

  def merge(a:Array[Int],left:Int,mid:Int,right:Int) = {
    val n1 = mid-left
    val n2 = right-mid
    Array.copy(a,left,l,0,n1)
    l(n1) = Int.MaxValue
    Array.copy(a,mid,r,0,n2)
    r(n2) = Int.MaxValue
    var i=0
    var j=0
    for(k<-left until right) {
      if(l(i)<=r(j)){
        a(k) = l(i)
        i += 1
      } else  {
        a(k)=r(j)
        j += 1
      }
      cnt += 1
    }
  }

  def scan(h:Int,l:List[IndexedSeq[(Int,Int)]]):List[IndexedSeq[(Int,Int)]] =
    if(h==0) l
    else scan(h-1,(for(i<-l.head;j<-List((i._1,(i._2+i._1)/2),((i._2+i._1)/2,i._2))) yield j)::l)

  def getSortIndex(n:Int):Iterator[IndexedSeq[(Int,Int)]] = {
    var w = n
    var h = 0
    while(w>1) {
      h += 1
      w /= 2
    }
    scan(h-1,List(IndexedSeq((0,n/2),(n/2,n)))).to[Iterator]
  }

  def main(args:Array[String]) = {
    val n = readInt
    val a = readLine.split(" ").map(_.toInt)
    val l = getSortIndex(n)
    for(e2<-l) {
      for(e<-e2) {
        val mid = (e._2+e._1)/2
        if(e._2-e._1>1)
          merge(a,e._1,mid,e._2)
      }
    }
    merge(a,0,n/2,n)
    println(a.mkString(" "))
    println(cnt)
  }
}

Measured memory_bytes: 320152
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    resolve(System.in, System.out);
  }

  private static final char RED = 'R';
  private static final char WHITE = 'W';

  static void resolve(InputStream is, PrintStream pw) {
    Scanner sc = new Scanner(is);
    int n = Integer.parseInt(sc.next());
    char c[] = new char[n];
    String s = sc.next();
    for (int i = 0; i < n; i++) {
      c[i] = s.charAt(i);
    }
    int rCount = 0;
    int wCount = 0;
    for (int i = 0; i < n; i++) {
      if (c[i] == RED) {
        rCount++;
      } else {
        wCount++;
      }
    }
    if (rCount == 0 || wCount == 0) {
      pw.println(0);
      return;
    }
    int ans = 0;
    for (int i = 0; i < rCount; i++) {
      if (c[i] == WHITE) {
        ans++;
      }
    }
    pw.println(ans);
  }
}


Measured memory_bytes: 40584
N, T = map(int, input().split())
c = [0]*N
t = [0]*N
for i in range(N):
    c[i], t[i] = map(int, input().split())
cc = []
for i in range(N):
    if t[i]<=T:
        cc.append(c[i])

if cc == []:
    print('TLE')
    exit()

print(min(cc))

Measured memory_bytes: 3060
#include "bits/stdc++.h"
using namespace std;
int tunnel[2][101];

int sim(int length)
{
	int ret[2]={-1,-1};
	//左向き
	for(int i=0;i<length+1;i++)
	{
		if(tunnel[0][i]!=-1)
		{
			tunnel[0][i-1]=tunnel[0][i];
			tunnel[0][i]=-1;
		}
		if(tunnel[0][0]!=-1)
		{
			ret[0]=tunnel[0][0];
			tunnel[0][0]=-1;
		}
	}
	//右向き
	for(int i=length;i>-1;i--)
	{
		if(tunnel[1][i]!=-1)
		{
			tunnel[1][i+1]=tunnel[1][i];
			tunnel[1][i]=-1;
		}
		if(tunnel[1][length]!=-1)
		{
			ret[1]=tunnel[1][length];
			tunnel[1][length]=-1;
		}
	}
	//鉢合わせ判定
	for(int i=0;i<length+1;i++)
	{
		if(tunnel[0][i]!=-1 && tunnel[1][i]!=-1)
		{
			int tmp=tunnel[0][i];
			tunnel[0][i]=tunnel[1][i];
			tunnel[1][i]=tmp;
		}
	}
	if(ret[0]==-1)
		return ret[1];
	else
		return ret[0];
}

int main()
{
	while(1)
	{
		int n,l;
		int dir[20];
		fill(tunnel[0],tunnel[2],-1);
		cin>>n>>l;
		if(n==0)
			break;
		for(int i=0;i<n;i++)
		{
			char d;
			int p;
			cin>>d>>p;
			if(d=='L')
				dir[i]=0;
			else
				dir[i]=1;
			tunnel[dir[i]][p]=i;
		}

		int ans=0;
		int last=0;
		while(1)
		{
			bool f=true;
			ans++;
			last=sim(l);
			//終了判定
			for(int i=0;i<2;i++)
			{
				for(int j=1;j<l+1;j++)
				{
					if(tunnel[i][j]!=-1)
					{
						f=false;
						break;
					}
				}
				if(!f)
					break;
			}
			if(f)
			{
				cout<<ans<<" "<<last+1<<endl;
				break;
			}
		}
	}
	return 0;
}


Measured memory_bytes: 3088
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
const int MOD=1000000007;

int main(){
    int n;
    cin>>n;
    if(n%2==1) cout<<n/2+1;
    else cout<<n/2;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.IO;
using System.Text;
using System.Collections;
using System.Collections.Generic;
using System.Text.RegularExpressions;
 
class Program
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        char[] s = Console.ReadLine().ToCharArray();
        int opening = 0, closing = 0;
        for (int i = 0; i < n; i++)
        {
            if (s[i] == '(') opening++;
            else if (s[i] == ')')
            {
                if (opening >= 1) opening--;
                else closing++;
            }
        }
        for (int i = 0; i < closing; i++) Console.Write('(');
        Console.Write(s);
        for (int i = 0; i < opening; i++) Console.Write(')');
        Console.WriteLine();
        // var result = new string(Enumerable.Concat(Enumerable.Concat(Enumerable.Repeat('(', closing).ToArray(), s), Enumerable.Repeat(')', opening).ToArray()).ToArray());
        // Console.WriteLine(result);
    }
}


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

int main()
{
	string s, t = "CF";
	cin >> s;
	int x = 0;
	for (int i = 0; i < s.length(); ++i) {
		if (s[i] == t[x]) ++x;
		if (x >= 2) {
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define fi first
#define se second
#define rep(i,s,n) for(int i = s;i<n;i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define all(v) (v).begin(),(v).end()
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0)
typedef long long ll;
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
const ll MOD=1000000007,INF=1ll<<60;
 
int N,W;
int dp[20002];

signed main() {
    IOS();
    cin>>N>>W;
    vint w(N),v(N);
    rep(i,0,N){
        cin>>v[i]>>w[i];
    }
    
    memset(dp,-1,sizeof(dp));
    dp[0]=0;
    rep(i,0,N){
        rep(j,0,W+1){
            if(dp[j]==-1)continue;
            chmax(dp[j+w[i]],dp[j]+v[i]);
        }
    }
    
    int ans=0;
    rep(i,0,W+1){
        chmax(ans,dp[i]);
    }
    cout<<ans<<endl;
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    return 0;
}


Measured memory_bytes: 3356
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define range(i,a,n) for(int i=(a);i<(n);i++)

#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

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

template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S acm(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}

ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}

double p,e,t,ans=0;
int k;

double rec(double l,double r,int div,double prob){
	double ret;
	if((t-e<l&&r<t+e))ret=prob;
	else if(r<t-e||t+e<l)ret=0;
	else{
	    double h=(l+r)/2;
	    if(div>=k){ret=((h>=t-e&&h<=t+e)?prob:0);}
		else if(t*2<=l+r){
			ret=rec(l,h,div+1,prob*(1-p))+rec(h,r,div+1,prob*p);
		}
		else{
			ret=rec(l,h,div+1,prob*p)+rec(h,r,div+1,prob*(1-p));
		}
	}
	return ret;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	double left,right;
	cin>>k>>left>>right>>p>>e>>t;
	ans=rec(left,right,0,1);
	fcout(12)<<ans<<endl;
}



Measured memory_bytes: 3300
N = int(input())
T,A = map(int, input().split())
H = [int(i) for i in input().split()]

dif = float("inf")

for i in range(N):
    temp = T - H[i] * 0.006
    dif2 = abs(A-temp)
    if dif2 < dif:
        dif = dif2
        ans = i

print(ans+1)

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

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

int dp[100];

//最大公約数
int gcd(int x, int y){
  if(x % y == 0) return y;
  return gcd(y, x % y);
}
//最小公倍数
int lcm(int x, int y){
  return x * y / gcd(x, y);
}
//フィボナッチ数列
//配列dpを-1で初期化する
int fib(int n){
  if(n == 0 || n == 1) return dp[n] = 1;
  if(dp[n] != -1) return dp[n];
  return dp[n] = fib(n - 1) + fib(n - 2);
}
//階乗計算(factorial)
int fact(int n){
  if(n = 1) return 1;
  return n * fact(n - 1);
}
//累乗計算(Exponentiation)
//x**y
ll expo(int x, int y){
  ll ans = 1;
  rep(i, y){
    ans *= x;
  }
  return ans;
}
//桁数
int keta(ll x){
  if(x == 0) return 1;
  int res = 0;
  while(x){
    x /= 10;
    res++;
  }
  return res;
}


int main(){
  while(1){
    int x, y;
    cin >> x >> y;
    if(x == 0 && y == 0) return 0;
    cout << min(x, y) << " " << max(x, y) << endl;
  }
}






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

int main() {
  string S;
  cin >> S;
  int out;
  if (S[0] == 'R') {
    if (S[1] == 'R') {
      if (S[2] == 'R') {
        out = 3;
      } else {
        out = 2;
      }
    } else {
      if (S[2] == 'R') {
        out = 1;
      } else {
        out = 1;
      }
    }
  } else {
    if (S[1] == 'R' && S[2] == 'R') {
      out = 2;
    } else if (S[1] == 'R' || S[2] == 'R') {
      out = 1;
    } else {
      out = 0;
    }
  }

  cout << out << endl;

  return 0;
}

Measured memory_bytes: 3596
N=int(input())
L=map(int,input().split())
L=list(L)
L_un=list(set(L))
Lunc=len(L_un)
b=0

for i in range(0,Lunc):
    for m in range(i+1,Lunc):
        for n in range(m+1,Lunc):
            if L_un[i]+L_un[m]>L_un[n] and L_un[m]+L_un[n]>L_un[i] and L_un[n]+L_un[i]>L_un[m]:
                c_i=L.count(L_un[i])
                c_m=L.count(L_un[m])
                c_n=L.count(L_un[n])
                
                b+=c_i*c_m*c_n

print(b)

Measured memory_bytes: 9088
from collections import deque
mod = 10**9 + 7
N = int(input())
C = [int(input()) for i in range(N)]
dq = deque()
dq.append(C[0])
for c in C:
    if c != dq[-1]:
        dq.append(c)
C = list(dq)
N = len(C)
dp = [0]*(N+1)
dp[0] = 1
acc = [0]*(2*pow(10,5)+1)
for i in range(1,N+1):
    dp[i] = dp[i-1]
    dp[i] += acc[C[i-1]]
    dp[i] %= mod
    acc[C[i-1]] += dp[i-1]
    acc[C[i-1]] %= mod
ans = dp[N]
print(ans)

Measured memory_bytes: 26248
import java.io.IOException;
import java.util.Scanner;
import java.util.TreeSet;

public class Main {

	public static void main(String[] args) throws IOException {

		new Main().run();
	}

	private void run() throws IOException {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		TreeSet<Time> set = new TreeSet<Time>();
		while (n-- > 0)
			set.add(new Time(scanner.nextInt(), scanner.nextInt()));

		int m = scanner.nextInt();
		while (m-- > 0)
			set.add(new Time(scanner.nextInt(), scanner.nextInt()));
		System.out.print(set.pollFirst());
		for (Time time : set)
			System.out.print(" " + time);
		System.out.println();

	}

	class Time implements Comparable<Time> {
		int h, m;

		public Time(int h, int m) {
			super();
			this.h = h;
			this.m = m;
		}

		@Override
		public String toString() {
			return String.format("%d:%02d", h, m);
		}

		@Override
		public int hashCode() {
			final int prime = 31;
			int result = 1;
			result = prime * result + getOuterType().hashCode();
			result = prime * result + h;
			result = prime * result + m;
			return result;
		}

		@Override
		public boolean equals(Object obj) {
			if (this == obj)
				return true;
			if (obj == null)
				return false;
			if (getClass() != obj.getClass())
				return false;
			Time other = (Time) obj;
			if (!getOuterType().equals(other.getOuterType()))
				return false;
			if (h != other.h)
				return false;
			if (m != other.m)
				return false;
			return true;
		}

		@Override
		public int compareTo(Time o) {
			if (this.h == o.h)
				return this.m - o.m;
			return this.h - o.h;
		}

		private Main getOuterType() {
			return Main.this;
		}

	}
}

Measured memory_bytes: 20992
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int qsort_int(const void *a, const void *b)
{
    return *(int *)a - *(int *)b;
}

int main(int argc, char *argv[])
{
    int n;
    int a[100000];
    int alive, offset;
    int need_sort;
    int check;
    int i, count;
    int ans;

    scanf("%d", &n);

    for (i = 0; i < n; i++) {
        scanf("%d", &a[i]);
    }

    qsort(a, n, sizeof(int), qsort_int);

    alive = n;
    offset = 0;
    check = 0;
    while(alive > 1) {
        need_sort = 0;
        count = a[offset + 1] / a[offset];
        if (a[offset] == 1) {break;}
        check = 0;
        for (i = offset + 1; i < n; i++) {
            a[i] -= a[offset] * count;
            if (a[i] < a[offset]) {need_sort = 1;}
            if (a[i] < 1) {alive--;}
            if (a[i] > 0 && a[i] % a[offset] == 0) {check++;}
        }
        if (check == alive - 1) {break;}
        if (need_sort) {
            qsort(a + offset, n - offset, sizeof(int), qsort_int);
            offset = n - alive;
        }
    }

    printf("%d\n", a[offset]);

    return 0;
}


Measured memory_bytes: 892
using System;
using System.Collections.Generic;
using System.Linq;
using System.Diagnostics;

class Program
{
    static void Main(string[] args)
    {
        const long MOD = 1000000007;
        var sc = new Scanner();
        int n = sc.nextInt();
        int k = sc.nextInt();
        var h = new int[n];
        for (int i = 0; i < n; i++)
        {
            h[i] = sc.nextInt();
        }

        var dp = new long[n];
        dp[0] = 0;
        for (int i = 1; i < n; i++)
        {
            long ans = long.MaxValue;
            for (int j = Math.Max(0, i - k); j < i; j++)
            {
                ans = Math.Min(ans, dp[j] + Math.Abs(h[i] - h[j]));
            }
            dp[i] = ans;
        }

        Console.SetOut(new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
        Console.WriteLine(dp[n - 1]);
        Console.Out.Flush();
    }
}

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

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

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

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

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

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

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

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

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

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

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

int main(){
  int A, B, C, K; // A枚+1, B枚0, C枚-1, K枚取る//
  cin >> A >> B >> C >> K;
  int sum = 0;

  if(K <= A){
    cout << 1 * K << endl;
  }
  else{
    if(K <= A + B){
      cout << A << endl;
    }
    else{
      if(K <= A + B + C){
        cout << A - (K - A - B) << endl;
      }
      else
        cout << "error" << endl;
    }
  }
}

Measured memory_bytes: 3596
#include <iostream>

using namespace std;

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

    int top,bottom;

    top=S/100;
    bottom=S%100;

    if(!(top>=1 && top<=12) && !(bottom>=1 && bottom<=12)){
        cout << "NA";
    }else{
        if((top>=1 && top<=12) && (bottom>=1 && bottom<=12)){
            cout << "AMBIGUOUS";
        }else{
            if((top>=1 && top<=12) && !(bottom>=1 && bottom<=12)){
                cout << "MMYY";
            }else{
                cout << "YYMM";
            }
        }
    }

}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

   else if (a*b>=a+b&&a*b>a-b){cout<< a*b<<endl;}
    
   else {cout<< a-b<<endl;}

    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream> 
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>

using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)
#define RREP(i, n) for(ll i = n - 1; i >= 0; i--)
#define REP2(i, n, k) for(ll i = 0; i < n; i += k)




int main() {
	int h, w;
	cin >> h >> w;
	REP(i, h) {
		REP(j, w) {
			string s;
			cin >> s;
			if (s == "snuke") {
				cout << (char)('A' + j) << i + 1 << endl;
				return 0;
			}
		}
	}
}

Measured memory_bytes: 256
N,A,B,C,D=map(int,input().split())
N=N-1
l=[]
for i in range(0,N+1):
    l.append(range(i*C-(N-i)*D,i*D-(N-i)*C+1))

for _ in l:
    if B-A in _:
        print("YES")
        break
else:
    print("NO")

Measured memory_bytes: 80408
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <numeric>
#include <complex>
#include <iomanip>
#include <cassert>
#include <random>


int main() {
    int n; std::cin >> n;
    std::vector<std::pair<long long, int>> p(n);
    for (int i = 0; i < n; i++) std::cin >> p[i].first, p[i].second = i;
    std::sort(p.rbegin(), p.rend());
    std::multiset<int> s;
    s.insert(-1); s.insert(-1);
    s.insert(n); s.insert(n);
    long long ans = 0;
    for (int i = 0; i < n; i++) {
        auto iter = s.lower_bound(p[i].second);
        long long r1 = *iter;
        long long r2 = *(++iter);
        long long l1 = *(--(--iter));
        long long l2 = *(--iter);
        ans += p[i].first*(r2 - r1)*(p[i].second - l1);
        ans += p[i].first*(r1 - p[i].second)*(l1 - l2);
        s.insert(p[i].second);
    }
    std::cout << ans << std::endl;
    return 0;
}


Measured memory_bytes: 6528
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		String s = sc.next();
		sc.close();
		
		int ans=0;
		for (int i=0; i<N; i++){
			
			int count=0;
			
			for (char c='a'; c<='z'; c++){
				boolean left=false;
				boolean right=false;
				
				for (int j=0; j<i; j++){
					if (s.charAt(j)==c)
						left=true;
				}
				
				for (int j=i; j<N; j++){
					if (s.charAt(j)==c)
						right=true;
				}
				
				if (left==true && right==true)
					count++;
				
			}
			
			ans = Math.max(ans, count);
			
		}
		System.out.println(ans);
	}

}


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

using namespace std;

int main(){
	int L, R, d;
	cin >> L >> R >> d;
	int count = 0;

	for(int i = 0; i < 200; i++){
		int ans = d * i;
		if(ans >= L && ans <= R){
			count++;
		}
		else if(ans > R){
			break;
		}
	}
	cout << count << "\n";
}


Measured memory_bytes: 3620
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long llong;
typedef unsigned long long ullong;

using namespace std;

int main()
{
	llong n;
	string s;
	set<string> _set;
	cin >> n;
	rep( i, n )
	{
		cin >> s;
		_set.insert( s );
	}

	auto ret = _set.size();
	cout << ret;

	return 0;
}


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

using namespace std;
using ll = long long;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(),(x).end()

#define READ(x) (cin >> (x))

#define WRITE_N(x) (cout << (x) << endl)
#define WRITE(x) (cout << (x))

#define DIVIDER 1000000007LL

ll binary_power_divided(ll x, ll y, ll divider) {
    if (x == 1) {
        return 1;
    }

    ll retv = 1;
    ll x_pow_2i = x;
    ll temp_y = y;

    while (temp_y > 0) {
        if (temp_y % 2 == 1) {
            retv = (retv * x_pow_2i) % divider;
        }
        x_pow_2i = (x_pow_2i * x_pow_2i) % divider;
        temp_y /= 2;
    }

    return retv;
}

int main() {
    // get values from input
    ll N, K;
    cin >> N >> K;

    // main procedure
    vector<ll> gcd_count(K);
    ll gcd_sum = 0;

    for (int n = K; n > 0; --n) {
        int i = n - 1;
        ll count = binary_power_divided(K / n, N, DIVIDER);

        for (int kn = 2 * n; kn <= K; kn += n) {
            int j = kn - 1;
            count = (count + DIVIDER - gcd_count[j]) % DIVIDER;
        }

        gcd_count[i] = count;

        gcd_sum = (gcd_sum + (count % DIVIDER) * (ll)n) % DIVIDER;
    }

    // output
    WRITE_N(gcd_sum);

    return 0;
}


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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    ll k;
    cin >> s >> k;
    char ans = '1';
    ll length = s.size();
    for(ll i = 0;i < min(k,length);i ++){
        if(s[i] != '1'){ans = s[i];break;}
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;
using ll = long long;

bool pairCompare(const pair<ll, ll>& firstElof, const pair<ll, ll>& secondElof)
{
    return firstElof.second > secondElof.second;
}

int main() {
    ll n, m;
    cin >> n >> m;

    priority_queue<ll, vector<ll>, greater<>> q;
    vector<pair<ll, ll>> p;

    for (int i = 0; i < n; ++i) {
        ll tmp;
        cin >> tmp;
        q.push(tmp);
    }

    for (int i = 0; i < m; ++i) {
        ll b, c;
        cin >> b >> c;
        p.emplace_back(b, c);
    }
    
    sort(p.begin(), p.end(), pairCompare);

    for (int i = 0; i < m; ++i) {
        ll b = p.at(i).first;
        ll c = p.at(i).second;

        if (c < q.top()) break;
        for (int j = 0; j < b; ++j) {
            if (q.top() < c) {
                q.pop();
                q.push(c);
            } else {
                break;
            }
        }
    }

    // calc and output
    ll sum = 0;
    for (int i = 0; i < n; ++i) {
        sum += q.top();
        q.pop();
    }

    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<char> vc;
typedef queue<ll> ql;
typedef deque<ll> dql;
typedef priority_queue<ll/*, vl, greater<ll>*/> pql; //降順(/*昇順*/)
typedef set<ll> sl;
typedef pair<ll, ll> pl;
typedef vector<vl> vvl;
typedef vector<pl> vpl;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
#define rep2(i, n) for(ll i = 1; i <= ll(n); i++)
//#define rep(i, k, n) for(ll i = k-1; i < ll(n); i++)
//#define rep2(i, k, n) for(ll i = k; i <= ll(n); i++)
#define all(v) (v).begin(), (v).end()
ll mod(ll a, ll b) {if(b == 0) return 0; return (a % b + b) % b;}
bool chmin(ll &a, ll b) {if(b < a) {a = b; return 1;} return 0;}
bool chmax(ll &a, ll b) {if(b > a) {a = b; return 1;} return 0;}
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;
const ll MAX = 1e9;
const char newl = '\n';

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

  ll n, x, y;
  char u;
  cin >> n;
  
  ll ans=INF;
  
  vector<pair<pl, char> > column[200001], row[200001], sum[400001], dif[400001];
  rep(_, n) {
    cin >> x >> y >> u;
    pair<pl, char> p = make_pair(pl(x, y), u);
    column[y].push_back(p);
    row[x].push_back(p);
    sum[x+y].push_back(p);
    dif[200000+x-y].push_back(p);
  }
  
  rep(i, 200001) sort(all(column[i]));
  rep(i, 200001) sort(all(row[i]));
  rep(i, 400001) sort(all(sum[i]));
  rep(i, 400001) sort(all(dif[i]));
  
  rep(i, 200001) {
    ll num=INF, l=0, r=INF;
    for(auto p: column[i]) {
      if(p.second=='L') l=p.first.first;
      if(p.second=='R') r=p.first.first;
      if(l>r) chmin(num, (l-r)*5);
    }
    chmin(ans, num);
  }
  
  rep(i, 200001) {
    ll num=INF, d=0, u=INF;
    for(auto p: row[i]) {
      if(p.second=='D') d=p.first.second;
      if(p.second=='U') u=p.first.second;
      if(d>u) chmin(num, (d-u)*5);
    }
    chmin(ans, num);
  }
  
  rep(i, 400001) {
    ll num=INF, l=0, r=INF, d=INF, u=0;
    for(auto p: sum[i]) {
      if(p.second=='L') l=p.first.first;
      if(p.second=='R') r=p.first.first;
      if(p.second=='D') d=p.first.first;
      if(p.second=='U') u=p.first.first;
      if(u>r) chmin(num, (u-r)*10);
      if(l>d) chmin(num, (l-d)*10);
    }
    chmin(ans, num);
  }
  
  rep(i, 400001) {
    ll num=INF, l=0, r=INF, d=0, u=INF;
    for(auto p: dif[i]) {
      if(p.second=='L') l=p.first.first;
      if(p.second=='R') r=p.first.first;
      if(p.second=='D') d=p.first.first;
      if(p.second=='U') u=p.first.first;
      if(d>r) chmin(num, (d-r)*10);
      if(l>u) chmin(num, (l-u)*10);
    }
    chmin(ans, num);
  }
  
  if(ans==INF) cout << "SAFE" << newl;
  else cout << ans << newl;
  return 0;
}

Measured memory_bytes: 60644
#include <iostream>
#include <limits>
#include <cmath>
#include <cstdio>

#define pf printf
// #define DEBUG true
#define DEBUG false
#define IFD if(DEBUG)
#define FOR(i,ii,n) for(long long i=ii; i<n; i++)
#define FORREV(i,ii,n) for(long long i=n-1; i>=ii; i--)
#define INF ((ll)1e15)

using namespace std;
typedef long long ll;

ll const NMAX = 4001;
// ll const NMAX = 41;
// ll mod = 998244353;
ll mod = 1e9 + 7;
ll fact[NMAX];
ll finv[NMAX];
ll comb(ll n,ll a){
	return fact[n] * finv[a] % mod * finv[n-a] % mod;
}
ll numk[NMAX];

void ppdp(ll N, ll M, ll dp[NMAX][NMAX]){
	FOR(i,0,N){
		FOR(j,0,M){
			printf("%lld ",dp[i][j]);
		}
		printf("\n");
	}
}

// 配列大きさ1000000レベルだとwandboxでsegfaultが起こる
// ll のprintfは%lld
int main(){
	ll N;
	ll M;
	ll S[NMAX];
	ll T[NMAX];
	ll DP[NMAX][NMAX];
	ll SUM[NMAX];
	ll SUMmin1[NMAX];
	// init
	cin >> N;
	cin >> M;
	// printf("%lld\n",hoge);
	FOR(i,0,N){
		cin >> S[i];
	}
	FOR(i,0,M){
		cin >> T[i];
	}
	FOR(s,0,N){
		SUMmin1[0] = SUM[0];
		if(S[s]==T[0]){
			DP[s][0] = 1;
			SUM[0] += 1;
		}
		FOR(t,1,M){
			DP[s][t] = DP[s][t-1];
			if(S[s]==T[t]){
				DP[s][t] += SUMmin1[t-1]+1;
				DP[s][t] %= mod;
			}
			SUMmin1[t] = SUM[t];
			SUM[t] += DP[s][t];
			SUM[t] %= mod;
		}
	}
	ll hoge = (SUM[M-1]+1)%mod;
	// ppdp(N,M,DP);
	printf("%lld\n",hoge);
}



Measured memory_bytes: 64384
"use strict";

function main(input) {
  input = input.trim().split(" ");
  let ans;
  for (let i in input) {
    if (parseInt(input[i]) === 0) {
      ans = parseInt(i) + 1;
    }
  }
  console.log(ans);
}

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


Measured memory_bytes: 29684
s = raw_input()

def find_unbalance():
    for i in range(ord('a'),ord('z')+1):
        for j in range(len(s)-1):
            if s[j] == chr(i) and s[j+1] == chr(i):
                return (j+1, j+2)
            if j < len(s)-2 and s[j] == chr(i) and s[j+2] == chr(i):
                return (j+1, j+3)
    return (-1, -1)
ans = find_unbalance()
print ans[0], ans[1]


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

int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	if (abs(a - c) <= d)cout << "Yes" << endl;
	else if (abs(a - b) <= d && abs(b - c) <= d)cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
	int c,r;
	while(cin >> c >> r){
		if(c==0&&r==0)break;
		int x=1,y=1,n;
		int angle=0;
		const int POSX[] = {0,1,0,-1};
		const int POSY[] = {1,0,-1,0};
		string s;
		while(cin>>s){
			if(s=="FORWARD"){
				cin >> n;
				int dx = n*POSX[angle];
				int dy = n*POSY[angle];
				
				int nx = dx + x;
				if(nx<1)x = 1;
				else if(nx>c)x=c;
				else x = nx;
				
				int ny = dy + y;			
				if(ny<1)y = 1;
				else if(ny>r)y=r;
				else y = ny;
				
			}else if(s=="BACKWARD"){
				cin >> n;
				int dx = n*POSX[angle];
				int dy = n*POSY[angle];
				
				int nx = x - dx;
				if(nx<1)x = 1;
				else if(nx>c)x=c;
				else x = nx;
				
				int ny = y - dy;
				if(ny<1)y = 1;
				else if(ny>r)y=r;
				else y = ny;
			}else if(s=="RIGHT") angle++;
			else if(s=="LEFT") angle--;
			else if(s=="STOP") break;
			
			angle = (angle + 4) % 4;
		}
		cout << x << " " << y << "\n";
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
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; }
typedef long long ll;
const long long INF = 1LL << 60;
const long long MOD = 1e9 + 7;
const int MAX = 1000001;
long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main()
{
    int X, Y;
    cin >> X >> Y;
    COMinit();

    ll ans = 0;
    if ((X + Y) % 3 == 0) {
        int i = (X + Y) / 3;
        int j = X - i;
        ans = COM(i, j);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 27092
S = list(input())
if S[0]  == "A" and S[1]  == "A" and S[2]  == "A":
  print("No")
elif S[0]  == "B" and S[1]  == "B" and S[2]  == "B":
  print("No")
else:
  print("Yes")
   

Measured memory_bytes: 2940
def main():
    n = int(input())
    a, b = map(int, input().split())
    p = list(map(int, input().split()))
    cnt = [0]*3
    for v in p:
        if v <= a:
            cnt[0] += 1
        elif v <= b:
            cnt[1] += 1
        else:
            cnt[2] += 1
    print(min(cnt))

if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
#include <stdio.h>
#include <algorithm>
#include <math.h>
int n;
long long x[100], y[100];
double z[100],zz[100];
int id[100], in[100];
double ans, w;
int g;
long long xx, yy;
long long inf = 2000000;
int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%lld%lld", x + i, y + i);
		if (x[i] == 0 && y[i] == 0) {
			n--;
			i--;
		}
	}
	for (int i = 0; i < n; i++) {
		if (x[i]) {
			z[i] = y[i];
			z[i] /= x[i];
		}
		if (!x[i]) {
			if (y[i] > 0)z[i] = inf;
			else z[i] = -inf;
		}
		if (x[i] >= 0)z[i] += 2 * inf;
		zz[i] = z[i];
		in[i] = -1;
		id[i] = -1;
	}
	std::sort(z, z + n);
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			if (z[i] == zz[j] && (in[j] == -1) && (id[i] == -1)) {
				id[i] = j;
				in[j] = 1;
			}
		}
	}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			g = i;
			xx = 0; yy = 0;
        	xx += x[id[g % n]];
			yy += y[id[g % n]];
			g++;
			while ((g % n) != j) {
				xx += x[id[g % n]];
				yy += y[id[g % n]];
				g++;
			}
			w = xx * xx + yy * yy;
			w = sqrt(w);
			if (w > ans)ans = w;
		}
	}
	printf("%.18lf", ans);
}

Measured memory_bytes: 128
#include <cstdio>
#include <cstring>
#include <string>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <queue>
#include <vector>
#include <stack>
#include <set>
#define inf 0x3f3f3f3f
using namespace std;

char a,b;

int main()
{
    scanf("%c %c",&a,&b);
    if(a=='H'&&b=='H')
        cout << 'H' << endl;
    else if(a=='D'&&b=='H')
        cout << 'D' << endl;
    else if(a=='D'&&b=='D')
        cout << 'H' << endl;
    else 
        cout << 'D' << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  while(1){
    string s;
    vector<string> v;
    cin>>s;
    if(s=="#")break;
    string tmp="";
    for(int i=0;i<(int)s.size();i++){
      if(s[i]=='/'){
        v.push_back(tmp);
        tmp="";
      }else if(s[i]=='b'){
        tmp+='o';
      }else{
        for(int j=0;j<(s[i]-'0');j++)
          tmp+='.';
      }
    }
    v.push_back(tmp);
     
    int ax,ay,bx,by;
    cin>>ax>>ay>>bx>>by;
    v[ax-1][ay-1]='.';
    v[bx-1][by-1]='o';
    string ans="";
    for(int i=0;i<(int)v.size();i++){
      int cnt=0;
      for(int j=0;j<(int)v[i].size();j++){
        if(v[i][j]=='o'){
          if(cnt)ans+=('0'+cnt),cnt=0;
          ans+='b';
        }else{
          cnt++;
        }
      }
      if(cnt)ans+=('0'+cnt);
      if(i+1<(int)v.size())ans+='/';
    }
 
    cout<<ans<<endl;
  }
  return 0;
}

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

using namespace std;

int main(){
    int N;
    int A[100001]={};
    cin>>N;
    for(int i=0;i<N;i++){
        int x;
        cin>>x;
        A[x]++;
    }
    int left=1;
    int right=1e5;
    while(right-left>=0){
        if(A[left]>1 && A[right]>1){
            A[left]--; A[right]--;
        }else if(A[left]<=1){
            left++;
        }else if(A[right]<=1){
            right--;
        }
    }
    int ans=0;
    for(int i=1;i<=1e5;i++){
        ans+=A[i];
    }
    cout<<ans<<endl;
    return 0;
}


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

int main(){
    long long n;
    cin >> n;

    long long ans = 1;

    for(int i = 1; i < n / 2 + 1; i++){
        if(i * i <= n){
            ans = i * i;
        }else{
            break;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n ; i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define whole(f, x, ...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x) // decltypeで型取得、引数があればva_argsのところに入れる
using namespace std;
typedef long long ll; // long longをllでかけるようにした
const int INF = 1e9;

bool compare_by_A(pair<ll, ll> a, pair<ll, ll> b){
    return a.first > b.first;
}

int main(void){
    ll n, m; cin >> n >> m;
    vector<pair<ll, ll>> A(n);
    REP(i, n){
        int a;
        cin >> a;
        A[i] = make_pair(a, 1);
    }
    REP(i, m){
        int a, b; cin >> a >> b;
        A.push_back(make_pair(b, a));
    }
    whole(sort, A, compare_by_A);
    ll ans = 0, sum = 0, i = 0;
    while(1){
        if(sum + A[i].second < n){
            sum += A[i].second; 
            ans += A[i].first * A[i].second;
        }
        else {
            ans += A[i].first * (n - sum);
            break;
        }
        i++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 7520
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	s := make([]string, n)
	for i := range s {
		fmt.Scan(&s[i])
	}

	m := make(map[string]bool)
	for _, v := range s {
		m[v] = true
	}
	fmt.Println(len(m))
}


Measured memory_bytes: 23352
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef long  l;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
const int INF=1000000001;
const double PI=3.141592653589;


int main(){
  int n; cin>>n;
  map<int,int> mp;
  rep(i,n){
    int a; cin>>a;
    mp[a-1]++;
    mp[a]++;
    mp[a+1]++;
  }
  int ans=-1;
  for(auto itr=mp.begin();itr!=mp.end();itr++){
    ans=max(ans,itr->sc);
  }
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 4736
import sys
from itertools import combinations


def resolve(in_):
    N = int(next(in_))
    L = list(map(int, next(in_).split()))
    L.sort()

    ans = 0
    for i, j, k in combinations(L, 3):
        if not (i < j < k):
            continue
        if i + j > k and j + k > i and k + i > j:
            ans += 1
    return ans

def main():
    answer = resolve(sys.stdin.buffer)
    print(answer)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9244
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    int arr[n],a[n];

    for(int i = 0;i<n;i++){
        cin>>arr[i];
    }
    a[n-1] = 0;
    a[n-2] = abs(arr[n-1] - arr[n-2]);
    for(int i = n-3;i>=0;i--){
        a[i] = min(abs(arr[i]-arr[i+1]) + a[i+1],abs(arr[i]-arr[i+2])+a[i+2]);
    }
    cout<<a[0];
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int i,j,a[100],b[100];
string s,t;
int main()
{
  for(cin>>s>>t;i<s.size();i++)a[i]=int(s[i]);for(;j<t.size();j++)b[j]=int(t[j]);
  sort(a,a+s.size());sort(b,b+t.size(),greater<int>());
  j=min(s.size(),t.size());
  for(i=0;i<j;i++){
    if(a[i]<b[i])return cout<<"Yes"<<endl,0;
    if(a[i]>b[i])return cout<<"No"<<endl,0;
  }
  cout<<(s.size()<t.size()?"Yes":"No")<<endl;
}

Measured memory_bytes: 256