akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
 
template <class T1, class T2>
ostream& operator << (ostream& out, const pair <T1, T2> p)
{
	out << '(' << p.first << ',' << p.second << ')';
	return out;
}
 
template <class T1, class T2>
istream& operator >> (istream& in, pair<T1, T2> &p)
{
	in >> p.first >> p.second;
	return in;
}
 
template <class T>
istream& operator >> (istream& in, vector<T> &v)
{
	for (T &x : v)
		in >> x;
	return in;
}
 
template <class T>
ostream& operator << (ostream& out, const vector<vector<T> > &v)
{
	for (const vector<T> &x : v)
		out << x << '\n';
	return out;
}
 
template <class T>
ostream& operator << (ostream& out, const vector<T> &v)
{
	for (const T &x : v)
		out << x << ' ';
	return out;
}
 
 
#define ll long long
#define lf long double
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef pair <ll,ll > ii;
typedef vector <ll> vi;
typedef vector <ii> vii;
typedef vector <bool> vb;
typedef vector <vector <ll> > vv;
typedef vector <vector <vector<ll> > > vvv;
typedef vector <string> vs;
typedef vector <lf> vf;
#define sz(x) (ll)(x).size()
#define tr1(x) cerr << #x << ": " << x << nl
#define tr2(x, y) cerr << #x << ": " << x << " | " << #y << ": " << y << nl
#define tr3(x,y,z) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<nl
#define tr4(x,y,z,w) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<" | "<<#w<<": "<<w<<nl
#define trv(a) cerr<<#a<<": ";for(ll zz=0;zz<sz(a);zz++) cerr<<a[zz]<<" ";cerr<<nl
#define trset(s) cerr<<#s<<": ";for(auto &i:s) cerr<<i<<" ";cerr<<nl
#define epsilon 0.000000001L
#define inf 9999999999999999ll// ~ 10^16
#define nl endl
#define all(x) x.begin(), x.end()
#define r_all(x) x.rbegin(), x.rend()
#define fast()  ios_base::sync_with_stdio(false);cin.tie(NULL)
#define mod 1000000007ll
#define modulo 998244353ll
ll power(ll a,ll b){return b?power(a*a%mod,b/2)*(b%2?a:1)%mod:1;}


int main()
{
    fast();
    ll n;
    cin>>n;
    vi a(n);
    cin>>a;

    ll ans=0;
    map <ll,ll> count;
    for(ll j=0;j<n;j++)
    {
        if(count.find(j-a[j])!=count.end())
        {
            ans+=count[j-a[j]];
        }
        count[a[j]+j]++;
    }
    cout<<ans<<nl;
}


Measured memory_bytes: 17084
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include <cmath>
#include <tuple>
#include <bitset>

#define push emplace_back
#define each(i, x) for (auto i=0; i < x; i++)

using namespace std;
template <typename T> inline void dump(const T& x) { cout << "[" << x << "]" << endl; }
template <typename T> inline void dump(const vector<T>& x) { for (const auto v : x) { cout << v << " "; } cout << endl; }
template <typename T> inline void sort_asc(vector<T>& x) { std::sort(x.begin(), x.end()); }
template <typename T> inline void sort_desc(vector<T>& x) { std::sort(x.begin(), x.end(), greater<T>()); }

int main() {
  int n, k;
  vector<int> a, b;

  cin >> n >> k;

  const double x = double(n / 2.0);
  if (ceil(x) >= k) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }


  return 0;
}

Measured memory_bytes: 256
/**
 * author: moririn_cocoa       
**/

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <bitset>
using namespace std;

int main(void) {
  
  string C;
  
  cin >> C;
  
  if ( C == "a" ) {
    
    cout << "b" << endl;
  }
  
  else if ( C == "b" ) {
    
    cout << "c" << endl;
  }
  
  else if ( C == "c" ) {
    
    cout << "d" << endl;
  }
  
  else if ( C == "d" ) {
    
    cout << "e" << endl;
  }
  
  else if ( C == "e" ) {
    
    cout << "f" << endl;
  }
  
  else if ( C == "f" ) {
    
    cout << "g" << endl;
  }
  
  else if ( C == "g" ) {
    
    cout << "h" << endl;
  }
  
  else if ( C == "h" ) {
    
    cout << "i" << endl;
  }
  
  else if ( C == "i" ) {
    
    cout << "j" << endl;
  }
  
  else if ( C == "j" ) {
    
    cout << "k" << endl;
  }
  
  else if ( C == "K" ) {
    
    cout << "l" << endl;
  }
  
  else if ( C == "l" ) {
    
    cout << "m" << endl;
  }
  
  else if ( C == "m" ) {
    
    cout << "n" << endl;
  }
  
  else if ( C == "n" ) {
    
    cout << "o" << endl;
  }
  
  else if ( C == "o" ) {
    
    cout << "p" << endl;
  }
  
  else if ( C == "p" ) {
    
    cout << "q" << endl;
  }
  
  else if ( C == "q" ) {
    
    cout << "r" << endl;
  }
  
  else if ( C == "r" ) {
    
    cout << "s" << endl;
  }
  
  else if ( C == "s" ) {

    cout << "t" << endl;
  }
  
  else if ( C == "t" ) {
    
    cout << "u" << endl;
  }
  
  else if ( C == "u" ) {
    
    cout << "v" << endl;
  }
  
  else if ( C == "v" ) {
    
    cout << "w" << endl;
  }
  
  else if (C == "w" ) {
    
    cout << "x" << endl;
  }
  
  else if ( C == "x" ) {
    
    cout << "y" << endl;
  }
  
  else if ( C == "y" ) {
    
    cout << "z" << endl;
  }
  
  return 0;
}

Measured memory_bytes: 3584
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define REPR(i,n) for(int i=n-1;i>=0;i--)
#define FORR(i,n,m) for(int i=n-1;i>=m;i--)
#define all(in) in.begin(),in.end()
#define ALL(in,K) in,in+K
#define INF 1e18
#define MOD 100000007
#define SIZE 10005
#define PI 	3.14159265358979323846

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a,b;
    cin >> a >> b;
    cout << (b%a==0?a+b:b-a) << endl;
    return 0;
}

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

int main() {
  int k, t;
  std::cin >> k >> t;
  std::vector<int> a(t);
  for (int i = 0; i < t; i++) std::cin >> a[i];

  sort(a.begin(), a.end());
  std::cout << std::max(0, a[t - 1] - 1 - (k - a[t - 1])) << "\n";
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <cassert>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <complex>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <iterator>

using namespace std;

#define dump(n) cout<<"# "<<#n<<'='<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define iter(c) __typeof__((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();++i)
#define all(c) (c).begin(),(c).end()
#define mp make_pair

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef pair<double,double> pdd;

const int INFTY=1<<29;
const double EPS=1e-9;

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& a){
	os<<'[';
	rep(i,a.size()) os<<(i?" ":"")<<a[i];
	return os<<']';
}

int main()
{
	for(int tc=1,n;cin>>n,n;tc++){
		vd xs(n),ys(n),rs(n);
		rep(i,n) cin>>xs[i]>>ys[i]>>rs[i];
		
		vd Y;
		rep(i,n){
			Y.push_back(ys[i]-rs[i]);
			Y.push_back(ys[i]+rs[i]);
		}
		
		auto feq=[](double a,double b){return abs(a-b)<EPS;};
		auto fle=[](double a,double b){return a<b-EPS;};
		
		sort(all(Y),fle); Y.erase(unique(all(Y),feq),Y.end());
		
		vector<vector<pdd>> segs(Y.size());
		rep(i,n){
			int first=lower_bound(all(Y),ys[i]-rs[i]-EPS)-Y.begin();
			int last=lower_bound(all(Y),ys[i]+rs[i]-EPS)-Y.begin();
			repi(j,first,last)
				segs[j].emplace_back(xs[i]-rs[i],xs[i]+rs[i]);
		}
		
		rep(i,segs.size())
			sort(all(segs[i]),[fle,feq](pdd a,pdd b){return fle(a.first,b.first)||feq(a.first,b.first)&&fle(a.second,b.second);});
		
		double res=0;
		rep(i,segs.size()-1){
			double r=-INFTY;
			for(pdd seg:segs[i]){
				if(r<seg.second)
					res+=(Y[i+1]-Y[i])*(seg.second-max(seg.first,r));
				r=max(r,seg.second);
			}
		}
		
		printf("%d %.2f\n",tc,res);
	}
	
	return 0;
}

Measured memory_bytes: 1300
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

class Program {
    static void Main(string[] args) {
        //入力
        int a = int.Parse(Console.ReadLine());
        string s = Console.ReadLine();

        //int[] A = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();

        if (a >= 3200) {
            Console.WriteLine(s);
        } else {
            Console.WriteLine("red");
        }

        //出力
        //Console.WriteLine();


    }
}

Measured memory_bytes: 11092
#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--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

const ll mod = 1e9 + 7;

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

    ll n;
    cin >> n;

    if (n % 2) {
        cout << 0 << endl;
        return 0;
    }

    n /= 2;
    ll res = 0, five = 1;
    REP(i, 30) {
        five *= 5;
        if (five > n) break;
        res += n / five;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
//There was and will always be only one Chester
//RIP legend
#include<bits/stdc++.h>
#define Nilesh ios_base::sync_with_stdio(false)
using namespace std;
int main()
{
  Nilesh;
  int n;
  cin>>n;
  long long a[n];
  set<int>ok;
  for(int i=0;i<n;i++)
  {
        cin>>a[i];
        ok.insert(a[i]);
  }
  if(ok.size()>n-2)
  {
      cout<<0;
      return 0;
  }
  sort(a,a+n);
  long long first=0,second=0;
  for(int i=n-1;i>=0;i--)
  {
      //cout<<a[i]<<endl;
        if(a[i]==a[i-1] && first==0)
        {
            first=a[i];
           // cout<<"update"<<endl;
            i-=1;
        }
        else if(a[i]==a[i-1] && first!=0 && second==0)
        {
            second=a[i];
        }
  }
  long long answer=first*second;
  cout<<answer;
}


Measured memory_bytes: 5760
n, m = map(int, input().split())
a = [int(input()) for _ in range(m)]
MOD = 10**9+7
INF = MOD-1
dp = [INF]*(n+1)
if n == 1:
    if 1 in a:
        print(0)
    else:
        print(1)
    exit()

dp[0] = dp[1] = 1

if 0 in a:
    dp[0] = INF
if 1 in a:
    dp[1] = INF

for x in a:
    dp[x] = 0

for i in range(2, n+1):
    if dp[i] == 0:
        continue

    if dp[i-1] == INF and dp[i-2] == INF:
        break
    elif dp[i-1] == INF or dp[i-2] == INF:
        dp[i] = min(dp[i-1], dp[i-2])
    else:
        dp[i] = dp[i-1]+dp[i-2]
    dp[i] %= MOD


print(dp[n] if dp[n] != INF else 0)

Measured memory_bytes: 7848
#include <bits/stdc++.h>
#define mset(a,b) memset(a,b,sizeof a)
#define mcpy(a,b) memcpy(a,b,sizeof b)
#define lb(x) ((x)&(-(x)))
#define xx first
#define yy second
#define pb push_back
#define mp make_pair
#define pii pair<int,int> 
#define dalao 1000000007
#define inf 0x3f3f3f3f
#define N 100010
using namespace std;
typedef long long ll;
int n,m,no[N];
char s[N],t[N];
int main(){
	scanf("%s",s),n=strlen(s);
	for(int i=0;i<n;i++)if(s[i]!='x')no[m]=i,t[m++]=s[i];
	for(int i=0,j=m-1;i<j;i++,j--)if(t[i]!=t[j])return puts("-1"),0;
	if(!m)return puts("0"),0;
	int ans=0;
	if(m&1){
		for(int i=(m>>1)-1,j=(m>>1)+1;j<m;i--,j++){
			ans+=abs(no[i+1]-no[i]-(no[j]-no[j-1]));
		}
		ans+=abs(no[0]-(n-no[m-1]-1));
		cout<<ans;
	}else{
		for(int i=(m>>1)-2,j=(m>>1)+1;j<m;i--,j++){
			ans+=abs(no[i+1]-no[i]-(no[j]-no[j-1]));
		}
		ans+=abs(no[0]-(n-no[m-1]-1));
		cout<<ans;
	}
	return 0;
}

Measured memory_bytes: 768
k,s=map(int,input().split())
cnt=0
for l in range(k+1):
    for m in range(k+1):
        #2つが定まるともう一つの値は一意に定まる
        if 0<=s-l-m and s-l-m<=k:
            cnt+=1
            #print(l,m,n)
print(cnt)

Measured memory_bytes: 2940
N,M = map(int,input().split())
AB = [list(map(int,input().split())) for _ in [0]*M]

E = [[] for _ in [0]*N]
for a,b in AB:
    E[a-1].append(b-1)
    E[b-1].append(a-1)

done = [False]*N
ans = [[],[]]
for k in range(2):
    done[0] = False
    q = [0]
    while q:
        i = q.pop()
        if done[i]: continue
        done[i]=True
        for j in E[i]:
            if done[j]: continue
            q.append(j)
            ans[k].append(j+1)
            break
        else:
            break
ans = ans[0][::-1] + [1] + ans[1]
print(len(ans))
print(*ans)

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

int main(){
  long int n,J;
  cin >> n;
  J=0;
  long int k,i,j;
  
  for(i=2;i<448;i++){
    if(n==i*(i-1)/2){
      J=1;
      k=i;
    }
  }
  
  if(J==0){
    cout << "No" << endl;
  }else{
    cout << "Yes" << endl;
    cout << k << endl;
    vector<vector<long int>> s(k,vector<long int>(k-1));
    long int x=1;
    for(i=0;i<k-1;i++){
      for(j=i;j<k-1;j++){
        s.at(i).at(j)=x;
        s.at(j+1).at(i)=x;
        x++;
      }
    }
    for(i=0;i<k;i++){
      cout << k-1;
      for(j=0;j<k-1;j++){
        cout << " " << s.at(i).at(j);
      }
      cout << endl;
    }
  }
}

Measured memory_bytes: 2944
n = int(input())
a = input().split()
b = input().split()
c = input().split()
a = [int(i) for i in a] 
b = [int(i) for i in b] 
c = [int(i) for i in c] 

sut = 0
for i,ind in enumerate(a):
    sut += b[ind-1]
    if i>=1:
        if a[i-1]+1 == a[i]:
            sut += c[a[i]-2]
print(sut)

Measured memory_bytes: 3064
void main(){
	long n = _scan();
	auto a = assumeSorted(_scanln!long().sort!("a<b"));
	auto b = assumeSorted(_scanln!long().sort!("a<b"));
	auto c = assumeSorted(_scanln!long().sort!("a<b"));
	long ans;
	foreach(i; 0..n)ans += a.lowerBound(b[i]).length * c.upperBound(b[i]).length;
	ans.writeln();
}

import std.stdio, std.conv, std.algorithm, std.numeric, std.string, std.math, std.range;

// 1要素のみの入力
T _scan(T= int)(){
	return to!(T)( readln().chomp() );
}

// 1行に同一型の複数入力
T[] _scanln(T = int)(){
	T[] ln;
	foreach(string elm; readln().chomp().split()){
		ln ~= elm.to!T();
	}
	return ln;
}


Measured memory_bytes: 12792
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;


int main() {
  vector<int> a(3);
  cin >> a[0] >> a[1] >> a[2];
  sort(all(a));
  if (a[0]==5 && a[1]==5 && a[2]==7) cout << "YES" << endl;
  else cout << "NO" << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

int main() {
	char s[11] = {};
	char t[11] = "2019/04/30";
	scanf("%s", s);
	if (strcmp(s, t) <= 0)
		printf("Heisei");
	else
		printf("TBD");
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n,k) for(int i=(n);i<(k);i++)
#define ALL(a)  (a).begin(),(a).end()
ll ans=0;
void Main(){
    ll n;cin>>n;
    vector<pair<ll,ll>> a(n+1);
    a[0]=make_pair(1e9+7,1e9+7);
    For(i,1,n+1) {
        cin>>a[i].first;
        a[i].second=i;
    }
    sort(ALL(a));
    reverse(ALL(a));
    vector<vector<ll>> dp(n+1,vector<ll> (n+1,0));//dp[i][j]:i人目まで見て左にj人おいたときの最大値
    For(i,1,n+1){
        For(j,0,i+1){
            if(j==0){
                dp[i][j]=dp[i-1][j]+a[i].first*(n-(i-1-j)-a[i].second);
            }
            else if(j==i){
                dp[i][j]=dp[i-1][j-1]+a[i].first*(a[i].second-j);
            }
            else{
                dp[i][j]=max(dp[i-1][j]+a[i].first*(n-(i-1-j)-a[i].second),dp[i-1][j-1]+a[i].first*(a[i].second-j));
            }
        }
    }
    For(i,0,n+1){
        ans=max(ans,dp[n][i]);
    }
    cout<<ans<<endl;
}
int main(){
    Main();
    /*
    東方風神録は神が出てくるので当然神ゲー
    */
    return 0;
}

Measured memory_bytes: 34676
#!/usr/bin/env python3
#ABC142 E

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n,m = LI()
cost = []
key = []
for _ in range(m):
    a,b = LI()
    cost.append(a)
    c = LI()
    tmp = 0
    for i in c:
        tmp |= 1 << (i-1)
    key.append(tmp)
dp = [[inf]*(m+1) for _ in range(2**n)]
dp[0][0] = 0
for i in range(2**n):
    for j in range(m):
        dp[i][j+1] = min(dp[i][j+1],dp[i][j])
    for j in range(1,m+1):
        s = key[j-1]
        if i|s > i:
            dp[i|s][j] = min(dp[i|s][j],dp[i][j-1] + cost[j-1])
if min(dp[-1]) == inf:
    print(-1)
else:
    print(min(dp[-1]))

Measured memory_bytes: 133852
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC target("avx")
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int (i)=0;i<(n);i++)
#define rrep(i,n) for(int (i)=1;i<=(n);i++)
#define REP(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define MOD 1000000007
#define INF 1e18
#define int long long
#define endl "\n"
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)?"YES":"NO")
typedef long long ll;
typedef pair<int, int> P;
int gcd(int a,int b){return b?gcd(b,a%b):a;};
int lcm(int a,int b){return a/gcd(a,b)*b;};
int mod(int a,int b){return (a+b-1)/b;};
template<typename A, size_t N, typename T>
void Fill(A(&array)[N],const T &val){std::fill((T*)array,(T*)(array+N),val);}
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;};
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;};



signed main() {
	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(false);
	//cout << fixed << setprecision(15);
	
	int n;
	cin >> n;
	rep(i, n) cout << 1 << endl;
	return 0;
}

Measured memory_bytes: 3648
A,B,C,D=gets.split.map(&:to_i)
l=C.lcm(D)
cz = B/C - (A-1)/C
if A>B
  p 0
elsif C==D
  p B-A+1-cz
else
  dz = B/D - (A-1)/D
  lz = B/l - (A-1)/l
  p B-A+1-(cz+dz-lz)
end

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

int main() {
  int n,a,k;
  int ans=1000000;
  cin >>n;
  for(int i=0;i<n;i++){
    cin >> a;
    k=0;
    while(a%2==0){
      k++;
      a/=2;
    }
    ans=min(ans,k);
  }
  
  
  cout << ans << "\n";
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
    int x1,y1,x2,y2;
    cin>>x1>>y1>>x2>>y2;
    cout<<(x2-(y2-y1))<<" "<<(y2+(x2-x1))<<" "<<(x1-(y2-y1))<<" "<<(y1+(x2-x1))<<endl;
}

Measured memory_bytes: 256
///Bismillahir Rahmanir Rahim
#include "bits/stdc++.h"

#define                           ll                          long long
#define                           int                         ll
#define                           fi                          first
#define                           si                          second
#define                           mp                          make_pair
#define                           pb                          push_back
#define                           pi                          pair<ll,ll>
#define                           clr(x)                      memset(x,0,sizeof(x));
#define                           f(i,l,r)                    for(int i=l;i<=r;i++)
#define                           rf(i,r,l)                   for(int i=r;i>=l;i--)
#define                           done(i)                     cout<<"done = "<<i<<endl;
#define                           show(x,y)                   cout<<x<<" : ";for(auto z:y)cout<<z<<" ";cout<<endl;
#define                           fast                        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

using namespace std;

const ll inf=1e18;
const int mod=1e9+7;
const int M=100005;

 main()

{
    fast
    int n;
    cin>>n;
    int a[n+2];
    f(i,1,n)
    {
        cin>>a[i];
    }
    int ses=inf;
    for(int i=-100;i<=100;i++)
    {
        int cost=0;
        f(j,1,n)
        {
            int x=a[j];
            int tmp=(x-i)*(x-i);
            cost+=(tmp);
        }
        ses=min(ses,cost);
    }
    cout<<ses<<endl;
    return 0;

}





































Measured memory_bytes: 3592
import java.io.IOException;
import java.util.Arrays;
import java.util.Scanner;

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);
		h = scanner.nextInt();
		w = scanner.nextInt();
		K = scanner.nextInt();
		mask = (1 << (4 * K)) - 1;
		map = new char[h][w];
		for (int i = 0; i < h; i++)
			map[i] = scanner.next().toCharArray();
		dp = new int[4][h][w][1 << (K * 4)];
		for (int[][][] dp1 : dp)
			for (int[][] dp2 : dp1)
				for (int[] dp3 : dp2)
					Arrays.fill(dp3, -1);
		v = new boolean[mask + 1];
		loop: for (int i = 0; i <= mask; i++) {
			int py = 0;
			int px = 0;
			int bit = i;
			for (int j = 0; j < K * 2; j++) {
				py -= dy[bit & 3];
				px -= dx[bit & 3];
				if (py == 0 && px == 0) {
					v[i] = true;
					continue loop;
				}
				bit >>= 2;
			}
		}

		System.out.println(slove(K, 0, 0, 0));
	}

	private int slove(int k, int y, int x, int bit) {
		if (dp[k][y][x][bit] != -1)
			return dp[k][y][x][bit];
		if (y == h - 1 && x == w - 1 && k == 0)
			return 0;
		int ret = 0;
		if (!v[bit] && map[y][x] != '.')
			ret += map[y][x] - '0';
		int val = -(1 << 20);
		for (int i = 0; i < 4; i++) {
			if (k == 0 && i >= 2)
				break;
			int ny = y + dy[i];
			int nx = x + dx[i];
			if (!isOK(ny, nx))
				continue;
			if (map[ny][nx] == '#')
				continue;
			val = Math
					.max(val,
							slove(k - (i >= 2 ? 1 : 0), ny, nx,
									((bit << 2) | i) & mask) + ret);
		}
		return dp[k][y][x][bit] = val;
	}

	private boolean isOK(int ny, int nx) {
		return (0 <= ny && ny < h && 0 <= nx && nx < w);
	}

	int h, w, K, mask;
	boolean[] v;
	int[] dy = { 0, 1, 0, -1 };
	int[] dx = { 1, 0, -1, 0 };
	int[][][][] dp;
	char[][] map;
}

Measured memory_bytes: 226484
#include <stdio.h>
#include <assert.h>
#include <stdlib.h>
#include <string.h>

#define MAX_NUM 1234
#define MAX_STR_LEN (12 + 1)

struct Item {
    struct Item* next;
    char str[MAX_STR_LEN];
};

static struct Item* CreateItem(const char* str) {
    struct Item* p_item = malloc(sizeof(struct Item));

    p_item->next = NULL;
    strncpy(p_item->str, str, MAX_STR_LEN);
    p_item->str[MAX_STR_LEN - 1] = '0';

    return p_item;
}

static void DeleteItem(struct Item* p_item) {
    free(p_item);

    return;
}

static void InitializeDic(struct Item* p_dic[]) {
    int i;

    for ( i = 0; i < MAX_NUM; i++ ) {
        p_dic[i] = NULL;
    }

    return;
}

static void FinalizeDic(struct Item* p_dic[]) {
    int i;
    struct Item* p_item;

    for ( i = 0; i < MAX_NUM; i++ ) {
        if ( p_dic[i] ) {
            for ( p_item = p_dic[i]; p_item != NULL; ) {
                struct Item* p_next = p_item->next;

                DeleteItem(p_item);

                p_item = p_next;
            }
        }
    }

    return;
}

static inline int CtoV(int c) {
    switch (c) {
    case 'A':
        return 1;
    case 'C':
        return 2;
    case 'G':
        return 3;
    case 'T':
        return 5;
    }

    assert( 0 );
    
    return -1;
}


static int hash(const char* str) {
    int i;
    unsigned int v = 0;

    for ( i = 0; str[i] != '\0'; i++ ) {
        v = v * 7 + CtoV(str[i]);
    }

    return v % MAX_NUM;
}

static int find(struct Item* p_dic[], const char* str) {
    int h = hash(str);
    struct Item* p_item;

    for ( p_item = p_dic[h]; p_item != NULL; p_item = p_item->next ) {
        if ( strcmp(p_item->str, str) == 0 ) {
            return 1;
        }
    }

    return 0;
}

static void insert(struct Item* p_dic[], const char* str) {
    int h = hash(str);
    struct Item* p_item;

    if ( p_dic[h] == NULL ) {
        p_dic[h] = CreateItem(str);
    } else {
        if ( find(p_dic, str) == 0 ) {
/*            printf("X [%s] -> %d\n", str, h);*/
            p_item = CreateItem(str);
            p_item->next = p_dic[h];
            p_dic[h] = p_item;
        }
    }

    return;
}

int main(int argc, char* argv[]) {
    int n;
    struct Item* dic[MAX_NUM];
    char order[10];
    char str[MAX_STR_LEN];
    const char* result[] = { "no", "yes" };

    InitializeDic(dic);
    
    fscanf(stdin, "%d\n", &n);
    for ( int i = 0; i < n; i++ ) {
        fscanf(stdin, "%s %s\n", order, str);
        if ( strcmp(order, "insert") == 0 ) {
            insert(dic, str);
        } else if ( strcmp(order, "find") == 0 ) {
            int r = find(dic, str);
            printf("%s\n", result[r]);
        } else {
            assert( 0 );
        }
    }

    FinalizeDic(dic);

    return 0;
}



Measured memory_bytes: 10284
#[allow(unused_imports)]
use {
    proconio::{fastout, input, marker::*},
    std::cmp::*,
    std::collections::*,
    std::ops::*,
};

fn gcd(a: usize, b: usize) -> usize {
    if b == 0 {
        a
    } else {
        gcd(b, a % b)
    }
}

#[fastout]
fn main() {
    input! {
        n: usize,
        a: [usize; n]
    }
    let mut x = a[0];
    for i in 1..n {
        x = gcd(x, a[i]);
    }

    if x != 1 {
        println!("not coprime");
        return;
    }

    let mut exist = vec![false; 1000001];
    for &a in a.iter() {
        if exist[a] && a != 1 {
            println!("setwise coprime");
            return;
        }
        exist[a] = true;
    }

    let mut yet = vec![true; 1000001];
    for i in 2..=1000000 {
        if !yet[i] {
            continue;
        }
        let mut count = 0;
        for j in 1..=1000000 / i {
            yet[i * j] = false;
            if exist[i * j] {
                count += 1;
                if count == 2 {
                    println!("setwise coprime");
                    return;
                }
            }
        }
    }
    println!("pairwise coprime");
}


Measured memory_bytes: 18472
//#include <bits/stdc++.h>
#include<iostream>
#include<numeric>
#include<cstdio>
#include<string>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<ctype.h>
#include <fstream>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
using namespace std;
typedef long long ll;//int64
typedef unsigned long long ull;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
//----------program from here----------

int ctoi(char c) {
  if('0'<=c && c <= '9') return c-'0';
  return 0;
}

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

Measured memory_bytes: 256
sa=input()
sb=input()
sc=input()
tp='a'
while True:
    if tp=='a':
        if len(sa)==0:
            print('A')
            break
        else:
            tp=sa[0]
            sa=sa[1:]
    elif tp=='b':
        if len(sb)==0:
            print('B')
            break
        else:
            tp=sb[0]
            sb=sb[1:]
    elif tp=='c':
        if len(sc)==0:
            print('C')
            break
        else:
            tp=sc[0]
            sc=sc[1:]

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
const int INF = 1001001001;
const int MOD = 1000000007;
typedef long long ll;

template<typename T> void print(const T & v);


int main() {
    int N, M;
    cin >> N >> M;
    vector<int> A(M);
    rep(i, M) cin >> A[i];

    rep(i, M){
        N -= A[i];
    }
    if(N >= 0){
        cout << N << endl;
    }else{
        cout << -1 << endl;
    }
    return 0;
}






// Use For Debug
template <typename T>
void print(T const & v){
    for(int i = 0; i < v.size(); i++){
        if(i) cout << " ";
        cout << v[i];
    }
    cout << endl;
}


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

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int mod = (int)1e9 + 7;
void dbg(){ cerr << "\n"; }  template <typename T,typename ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }

map<ll, int> fctm( ll x ){
	map<ll, int> fmp;
	for( ;x>=4 && x%2==0; x/=2)  fmp[2]++;
	for(ll d=3, q=x/d; q>=d ; q=x/d){if(x%d==0) fmp[d]++, x=q; else d +=2;}
	if(x!=1) fmp[x]++;    //note: if x==1: {{1,1}}
	return fmp;
}
int main()
{
	//cin.tie(0); ios_base::sync_with_stdio(false);
	ll n, p;
	cin >>n >>p;
	if(p==1) {cout <<1 <<"\n"; return 0;}
	if(n==1) {cout <<p <<"\n"; return 0;}
	
	auto rc = fctm(p);
	//for(auto x :rc) printf("%d:%d, ",x.first,x.second); puts("");
	ll ans =1;
	for(auto x: rc){
		ll w = x.second / n;
		if(w<1) continue;
		ll z=1;
		rep(i,w) z*=x.first;
		ans *= z;
	
	}
	
	cout << ans << "\n";
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

//When Can We Meet?
public class Main{

	void run(){
		Scanner sc = new Scanner(System.in);
		for(;;){
			int n = sc.nextInt();
			int q = sc.nextInt();
			if((n|q)==0)break;
			int[] c = new int[101];
			while(n--!=0){
				int m = sc.nextInt();
				while(m--!=0)c[sc.nextInt()]++;
			}
			int a = 0;
			for(int i=1;i<=100;i++){
				if(c[i]<q)continue;
				if(c[a]<c[i])a=i;
			}
			System.out.println(a);
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 12000
import java.util.Arrays;
import java.util.Collections;
import java.util.Random;
import java.util.Scanner;

public class Main {
	private static Scanner sc = new Scanner(System.in);
	static void p(String ans) {System.out.println(ans);};
	static void p(int ans) {System.out.println(ans);};
	static void p(long ans) {System.out.println(ans);};
	public static void main(String[] args) {

		int x =sc.nextInt();
		int y =sc.nextInt();
		int a =sc.nextInt();
		int b =sc.nextInt();
		int c =sc.nextInt();
		Integer aa[]= new Integer[a];
		Integer bb[]= new Integer [b];
		Integer cc[]= new Integer[c];
		Integer ans1[]=new Integer[x+y+c];
		for(int i=0;i<x+y+c;i++) {
			ans1[i]=0;
		}
		for(int i=0;i<a;i++) {
			aa[i]=0;
		}
		for(int i=0;i<b;i++) {
			bb[i]=0;
		}
		for(int i=0;i<c;i++) {
			cc[i]=0;
		}
		
		
		
		
		
		
		
		for(int i=0;i<a;i++) {
			aa[i] =sc.nextInt();
		}
		Arrays.sort(aa, Collections.reverseOrder());
		for(int i=0;i<b;i++) {
			bb[i] =sc.nextInt();
		}
		Arrays.sort(bb,Collections.reverseOrder());
		for(int i=0;i<c;i++) {
			cc[i] =sc.nextInt();
		}
		Arrays.sort(cc,Collections.reverseOrder());
		
		for(int i=0;i<x;i++) {
			ans1[i]=aa[i];
		}
		for(int i=0;i<y;i++) {
			ans1[i+x]=bb[i];
		}
		int t=0;
		for(int i:cc) {
			ans1[x+y+t]=i;
			t++;
		}
		Arrays.sort(ans1,Collections.reverseOrder());
		long FinalAnswer=0;
		for(int i=0;i<x+y;i++) {
			FinalAnswer+=ans1[i];
		}
		p(FinalAnswer);
	}
}

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

int main(){
  int N,res=0;
  cin>>N;
  
  for (int i=0;i<N;i++){
    int a;
    cin>>a;
    
    while(a%2==0){
      a/=2;
      res++;
    }
    
  }
  
  cout << res;
}

Measured memory_bytes: 256
w,h,n = map(int,input().split())
Mx = w ; My = h
mx = 0 ; my = 0

for i in range(n):
    x,y,a = map(int,input().split())
    
    if a == 1:
        mx = max(mx,x)
    elif a == 2:
        Mx = min(Mx,x)
    elif a == 3:
        my = max(my,y)
    else:
        My = min(My,y)
        
s = (Mx - mx)*(My - my)
print(s if mx < Mx and my < My else 0)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
 
#pragma comment(linker, "/stack:200000000")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
#define FASTIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define IN freopen("input.txt", "r", stdin);
#define OUT freopen("output.txt", "w", stdout);
#define LL long long
#define MOD 1000000007
#define INF 1000000000000000000
#define all(x) (x).begin(), (x).end()
#define pb(x) push_back(x)
 
using namespace std;
 
const int N = 1e5+1;
int n, k, F[N], h[N];
 
int main()
{
	FASTIO;
	cin >> n >> k;
	for (int i=1; i<=n; i++) cin>>h[i];
	h[0] = -1e8;
	for (int i=2; i<=n; i++) {
		int V = INT_MAX;
		for (int j=1; j<=k and i>j; j++) 
			V = min(V, F[i-j]+abs(h[i]-h[i-j]));
		F[i] = V;
	}
	cout << F[n];
	return 0;
}

Measured memory_bytes: 1152
using System;
class Program
{
    static void Main(string[] args)
    {
        int ans = 0;
        // 整数の入力
        //int a = int.Parse(Console.ReadLine());
        // スペース区切りの整数の入力
        string[] input = Console.ReadLine().Split(' ');
        int N = int.Parse(input[0]);
        int M = int.Parse(input[1]);

        int[] arrB = { 0, 1, 1};
        Array.Resize(ref arrB, N+1);

        int[] arrR = { 0, 1, 0};
        Array.Resize(ref arrR, N+1);

        for (int i = 2; i <= N; i++)
        {
            arrB[i] = 1;
            arrR[i] = 0;
        }

        for (int i = 0; i < M; i++)
        {
            string[] input2 = Console.ReadLine().Split(' ');
            int x = int.Parse(input2[0]);
            int y = int.Parse(input2[1]);

            if (arrR[x] == 1)
            {
                if (arrB[x] == 1)
                {
                    arrR[x] = 0;
                    arrR[y] = 1;
                } else
                {
                    arrR[x] = 1;
                    arrR[y] = 1;
                }
            }
            arrB[x]--;
            arrB[y]++;
        }

        for (int i = 1; i <= N; i++)
        {
            ans += arrR[i];
        }

        // 文字列の入力
        string s = Console.ReadLine();
        //出力
        Console.WriteLine(ans);

        Console.ReadLine();
    }
}

Measured memory_bytes: 7512
/*
　　こんにちは。あたしはｶｳｶﾞｰﾙ。
　　RedcoderになるためAtCoderを巡る旅をしてます。

　　　 　＿_
　　　 ヽ|＿_|ノ　　　　ﾓｫ
　　　　||‘‐‘||ﾚ　　_)_, ―‐ 、
　　　　/(Ｙ (ヽ＿ /・ ヽ　　   ￣ヽ
　　　　∠ ＿ ゝ　 ｀^ヽ ﾉ.::::_(ノヽ
　　　　 _/ヽ　 　　  /ヽ￣￣￣/ヽ
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define dump(x) cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl

#define rep(i, n) REP(i, 0, n)                  // 0, 1, ..., n-1
#define REP(i, x, n) for(int i = x; i < n; i++) // x, x + 1, ..., n-1
#define FOREACH(x, a) for(auto &(x) : (a))

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()

#define COUT(x) cout << (x) << endl

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

const ll INF = 1e18;

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

    ll L, R; cin >> L >> R;
    ll ans = INF;
    for(ll i = L; i <= min(R, L + 2019); i++) {
        for(ll j = i + 1; j <= min(R, L + 2019); j++) {
            ans = min(ans, ((i % 2019) * (j % 2019)) % 2019);
        }
    }
    COUT(ans);
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    int n, m;
    int taro[101], hanako[101];
    int taro_sum, hanako_sum;

    while (cin >> n >> m) {
        if (!n && !m) { break; }
        taro_sum = 0; hanako_sum = 0;
        for (int i = 0; i < n; i++) {
            cin >> taro[i];
            taro_sum += taro[i];
        }
        for (int i = 0; i < m; i++) {
            cin >> hanako[i];
            hanako_sum += hanako[i];
        }
        int diff = taro_sum - hanako_sum;
        int ans[2] = {101, 101};
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                if ((taro[i] - hanako[j]) * 2 == diff && (taro[i] + hanako[j]) < (ans[0] + ans[1])) {
                    ans[0] = taro[i];
                    ans[1] = hanako[j];
                }
            }
        }
        if (ans[0] == 101) { cout << -1 << endl; }
        else { cout << ans[0] << " " << ans[1] << endl; }
    }
    return 0;
}


Measured memory_bytes: 3072
#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

int main(){
    vi v(4);
    cin >> v[0] >> v[1];
    v[2] = v[0]-1;
    v[3] = v[1]-1;
    sort(rall(v));
    cout << v[0] + v[1] << '\n';
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 1e+9
#define MOD (int)1e9+7
#define debug(x) cerr << #x << ": " << x << "\n";
using namespace std;
using ll = long long;
using P = pair<int, int>;

int a[100000], b[100000];

int main(void){
    int N, H; cin >> N >> H;
    int x = -1;
    for(int i = 0; i < N; i++){
        cin >> a[i] >> b[i];
        x = max(x, a[i]);
    }

    priority_queue<int> que;
    for(auto y: b){
        if(x < y) que.push(y);
    }

    int res = 0;
    while(not que.empty()){
        H -= que.top();
        que.pop();
        res++;
        if(H <= 0)break;
    }
    if(H > 0){
        res += (H + x - 1) / x;
    }
    cout << res << '\n';
    return 0;
}

Measured memory_bytes: 1660
n = int(input())
list1 = list(map(int,input().split()))

def count(n, list1):
    num0 = list1.count(0)
    statuslist = []
    answer = 1
    if num0 >= 4:
        return 0
    else:
        for i in range(len(list1)):
            if list1[i] == 0:
                    statuslist.append(0)
            else:
                pos = statuslist.count(list1[i]-1)
                answer *= pos
                try:
                    statuslist.remove(list1[i]-1)
                except ValueError:
                    return answer
                statuslist.append(list1[i])
        if num0 == 2 or num0 == 3:
            answer *= 6
        elif num0 == 1:
            answer *= 3  
        return (answer % 1000000007)
    # else:
    #     return 3
        

print(count(n, list1))

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

int main() {
    uint64_t N;
    std::cin >> N;

    uint64_t pf[N+1] = {0};    
    for (size_t i = 2; i <= N; ++i) {
        uint64_t b = i;
        for (size_t j = 2; j <= N; ++j) {
            while (b % j == 0) {
                b /= j;
                pf[j] += 1;
            }
        }
    }

    uint64_t ans = 1;
    for (size_t i = 0; i < N + 1; ++i) {
        if (pf[i] != 0) {
            ans *= (pf[i] + 1);
            ans %= 1000000007;
        }
    }

    std::printf("%lu\n", ans %= 1000000007);

    return 0;
}


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

const int MAXN = 20 + 5;
const int way[4][2] = {{0, 1}, {1, 0}, {-1, 0}, {0, -1}};

struct Node {
    int x;
    int y;
    int depth;
};

int h, w, ans;
bool vis[MAXN][MAXN];
string input[MAXN];

void bfs(int i, int j) {
    vis[i][j] = true;
    queue<Node> q;
    q.push({i, j, 0});
    while (!q.empty()) {
        Node now = q.front();
        q.pop();
        ans = max(ans, now.depth);
        for (int k = 0; k < 4; k++) {
            int tx = now.x + way[k][0];
            int ty = now.y + way[k][1];
            if (tx >= 0 && tx < h && ty >= 0 && ty < w &&
                input[tx][ty] == '.' && !vis[tx][ty]) {
                vis[tx][ty] = true;
                q.push({tx, ty, now.depth + 1});
            }
        }
    }
}

int main() {
    cin >> h >> w;
    for (int i = 0; i < h; i++) {
        cin >> input[i];
    }

    ans = 0;
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            if (input[i][j] == '.') {
                memset(vis, 0, sizeof(vis));
                bfs(i, j);
            }
        }
    }
    cout << ans << '\n';
}

Measured memory_bytes: 3628
#include "iostream"
#include "algorithm"
#include "string"
#include "vector"
#include "cmath"
#define lp(n) for (int i = 0; i < n; i++)
#define lop(n,i) for (int i = 0; i < n; i++)
#define INT_MAX 2147483647
#define LLINT_MAX 9223372036854775807
#define mod 1000000007
#define ll long long int
using namespace std;

int main() {
	char a[5], b[5];
	lp(5)cin >> a[i];
	lp(5)cin >> b[i];
	int cnt = 0;
	a[4]--;
	do {
		a[4]++;
		for (int i = 4; i > 0;i--)
			if (a[i] == ':') {
			a[i - 1]++;
			a[i] = '0';
		}
			else break;
			if (a[0] == a[4] && a[1] == a[3]) {
				cnt++;
			}
	} while (!(a[0] == b[0] && a[1] == b[1] && a[2] == b[2] && a[3] == b[3] && a[4] == b[4]));
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
vector<int>G[50];
int old[50],low[50];
bool vis[50];
int ans;
void dfs(int v,int p,int&k){
	vis[v]=true;
	old[v]=k++;
	low[v]=old[v];
	for(int i=0;i<G[v].size();i++){
		if(!vis[G[v][i]]){
			dfs(G[v][i],v,k);
			low[v]=min(low[v],low[G[v][i]]);
			if(old[v]<low[G[v][i]])
				ans++;
		}else if(G[v][i]!=p)
			low[v]=min(low[v],old[G[v][i]]);
	}
}
int main(){
    int n,m,a,b;
	cin>>n>>m;
	while(cin>>a>>b){
		G[--a].push_back(--b);
		G[b].push_back(a);
	}
	int k=0;
	dfs(0,-1,k);
	cout<<ans<<endl;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast") 

////////////////////////////////////////////////////////////////////////////////

#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define endl "\n"
#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#define bew ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define all(x) x.begin(),x.end()
#define pb push_back
#define fi first
#define se second
#define mod (long)(1e9+7)
#define ip(ar,n) for(int i=0;i<n;++i)cin>>ar[i];
#define op(ar,n) for(int i=0;i<n;++i)cout<<ar[i]<<" ";
#define test int t;cin>>t;while(t--)
#define tar(x) int x;cin>>x;
#define fil(ar,val) memset(ar,val,sizeof ar)
#define loop(n) for(int i=0;i<n;++i)

////////////////////////////////////////////////////////////////////////////////

typedef vector<int> vi; 
typedef pair<int, int> ii; 
typedef vector<ii> vii; 
typedef set<int> si;
typedef map<int,int> mi;

////////////////////////////////////////////////////////////////////////////////

int n;

int sum(int bit[],int ind)
{
    int ret=0;
    for(int i=ind;~i;i=(i&(i+1))-1)
        ret=max(ret,bit[i]);
    return ret;
}

void add(int bit[],int ind,int val)
{
    int x=sum(bit,ind);
    for(int i=ind;i<=n;i=i|(i+1))
        bit[i]=max(val+x,bit[i]);
}



signed main() {
bew;
    cin>>n;
    int h[n],ar[n];
    ip(h,n);
    ip(ar,n);
    
    map<int,int> m;
    int x=0;
    loop(n)
    m[h[i]]=0;
    int bit[n+1];
    memset(bit,0,sizeof bit);
    for(auto &a:m)
    a.second=x++;
    
    int ret=0;
    for(int i=0;i<n;++i)
    {
        add(bit,m[h[i]],ar[i]);
        ret=max(ret,sum(bit,m[h[i]]));
    }
    
    cout<<ret;













return 0;
}

Measured memory_bytes: 17408
n = int(input())
temparr = input()
temparr = temparr.split()
arr = []
for i in temparr:
    arr.append(float(i))
#print(arr)
nn = n + 1 
temparr = [0 for _ in range(nn)]
dp = [temparr[::] for _ in range(nn)]
#print(dp)

dp[0][0] = 1 

for i in range(1, nn):
    for j in range(0, nn):
        if j == 0 :
            dp[i][j] = dp[i - 1][j] *(1 - arr[i - 1])
            continue 
        else:
            dp[i][j] = dp[i - 1][j - 1] * arr[i - 1] + dp[i - 1][j] * (1 - arr[i - 1])
lastarr = dp[-1]

half = n // 2 + 1 

ans = 0 
for i in range(half, nn):
    ans += lastarr[i]
print(ans)
            
        

Measured memory_bytes: 202400
s = input()
ret = 0
for i in range(1 << (len(s)-1)):
    x = 0
    sum = 0
    for j in range(len(s)-1):
        if 1<<j & i :
            sum=sum+int(s[x:j+1])
            x = j+1
    sum=sum+int(s[x:])
    ret=ret+sum
print(ret)


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

int main(){
  int N, K;
  string S;
  cin >> N >> K;
  cin >> S;
  
  if(S[K-1] == 'A')
    S[K-1] = 'a';
  else if(S[K-1] == 'B')
    S[K-1] = 'b';
  else if(S[K-1] == 'C')
    S[K-1] = 'c';

  cout << S << endl;
  return 0;
}

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

int main()
{
  int x;
  cin >> x;
  for (int i=1; i < 361; ++i)
  {
    if ((x * i) % 360 == 0)
    {
      cout << i << endl;
      return 0;
    }
  }
}


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

using namespace std;

#define yes             cout << "yes\n"
#define no              cout << "no\n"
#define lop(n)          for(int i = 0; i < n; i++)
#define N               100009

int rep[N], n, m;

int findrep(int a)
{
    if(rep[a] == a)
        return a;

    return rep[a] = findrep(rep[a]);
}

void Union(int a, int b)
{
    rep[findrep(a)] = findrep(b);
}

int main()
{
    int u, v, q;

    cin >> n >> m;

    lop(n) rep[i] = i;

    lop(m)
    {
        cin >> u >> v;

        Union(u, v);
    }

    lop(n) u = findrep(i);

    cin >> q;

    lop(q)
    {
        cin >> u >> v;

        rep[u] == rep[v] ? yes : no;
    }

    return 0;
}



Measured memory_bytes: 5000
import sys


def input():
    return sys.stdin.readline().strip()


def main():
    N, M = map(int, input().split())
    A = list(map(int, input().split()))
    s = sum(A)
    A.sort(reverse=True)
    for i in range(M):
        if A[i] >= s / (4 * M):
            continue
        else:
            print("No")
            break
    else:
        print("Yes")


if __name__ == "__main__":
    main()


Measured memory_bytes: 3064