akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,n,s) for(int i = s; i < (n); ++i)
#define rsrep(i,n,s) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<x<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const int MOD = 1e9+7;

struct mint {
    ll x;
    mint(ll x=0):x(x%MOD){}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += MOD-a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= MOD;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res*=a;
    }
};

mint c[4005][4005];
void init() {
    c[0][0] = 1;
    for (int i = 0; i <= 4000; i++) {
        for (int j = 0; j <= i; j++) {
            c[i+1][j] += c[i][j];
            c[i+1][j+1] += c[i][j];
        }
    }
}
 
mint comb(int n, int k) {
    return c[n][k];
}
 
mint f2(int n, int k) {
    return comb(n+k-1, k-1);
}
 
mint f(int n, int k) {
    if (n < k) return 0;
    if (n == 0 && k == 0) return 1;
    if (k < 1) return 0;
    return f2(n-k, k);
}
 
int main() {
    int n, k;
    cin >> n >> k;
    init();
    for (int i = 1; i <= k; i++) {
        mint blue = f(k, i);
        mint red = f2(n-k-(i-1), i+1);
        mint ans = blue * red;
        cout << ans.x << endl;
    }
 
    return 0;
}

Measured memory_bytes: 125568
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
struct S{ll y,m,d;};
struct Ma{ll b,ka,t,w,ki;};

//12,1,2,3...11
int M[]={31,28,31,30,31,30,31,31,30,31,30,31};

bool check(ll y){return (y%4==0&&(y%100!=0||y%400==0));}

S M2S(ll b,ll ka,ll t,ll w,ll ki){
  ka+=b*20;
  t+=ka*20;
  w+=t*18;
  ki+=w*20;
  S res;
  res.y=2012,res.m=12,res.d=21+ki;
  if(res.d<=31) return res;
  
  while(res.d/(365+check(res.y+1)))res.y++,res.d-=(365+check(res.y));
  if(res.d==0) res.m--,res.d=M[res.m-1];
  if(res.d<=31) return res;

  res.y++,res.m=1,res.d-=31;
  while(res.d/(M[res.m-1]+(check(res.y)&&res.m==2))){
    res.d-=(M[res.m-1]+(check(res.y)&&res.m==2));
    res.m++;
  }
  if(res.d==0) res.m--,res.d=M[res.m-1]+(check(res.y)&&res.m==2);
  return res;
}

Ma S2M(ll y,ll m,ll d){
  y-=2012;
  if(y) d+=10; 
  else d=(d-21);
  
  for(int i=0;i<m-1&&y;i++) d+=(M[i]+(i==1&&check(y+2012)));
  y--;
  while(y>0)d+=(365+check(y+2012)),y--;

  Ma res;
  d%=13*20*20*18*20;
  res.ki=d;
  res.w =res.ki/20; res.ki%=20;
  res.t =res.w/18;  res.w %=18;
  res.ka=res.t/20;  res.t %=20;
  res.b =res.ka/20; res.ka%=20;
  return res;
}

int main(){
  while(1){
    string str;
    cin>>str;
    if(str=="#")break;
    vector <int> a;
    int i=0,num=0;
    while(str[i]){
      if(str[i]=='.')a.push_back(num),num=0;
      else num=num*10+str[i]-'0';
      i++;
    }
    a.push_back(num);
    
    if(a.size()==5){
      S ans=M2S(a[0],a[1],a[2],a[3],a[4]);
      cout << ans.y<<"."<<ans.m<<"."<<ans.d<<endl;
    }
    else {
      Ma ans=S2M(a[0],a[1],a[2]);
      cout<<ans.b<<"."<<ans.ka<<"."<<ans.t<<"."<<ans.w<<"."<<ans.ki<<endl;
    }
  }
  return 0;
}

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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define INF         INT_MAX/3
#define LLINF       LLONG_MAX/3
#define MOD         (1000000007LL)
#define MODA(a, b)  a=((a)+(b))%MOD
#define MODP(a, b)  a=((a)*(b))%MOD
#define inc(i, l, r)   for(int i=(l);i<(r);i++)
#define dec(i, l, r)   for(int i=(r)-1;i>=(l);i--)
#define pb          push_back
#define se          second
#define fi          first
#define mset(a, b)  memset(a, b, sizeof(a))

using LL  = long long;
using G   = vector<vector<int>>;

int di[] = {0, -1, 0, 1};
int dj[] = {1, 0, -1, 0};
// }}}

int main() {
    cin.tie(0);ios::sync_with_stdio(false);
    string s, t;cin >> s >> t;
    s = s+s;
    bool ans = s.find(t) != string::npos;
    cout << (ans ? "Yes" : "No") << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <iomanip>
#include <string>
#include <sstream>
#include <queue>
#include <algorithm>
#include <map>
#include <bits/stdc++.h>

using namespace std;
#define REP(i,n) FOR(i,0,n)
#define FOR(i,a,b) for(long long i=(a),i##Len_=(b);i<i##Len_;i++)
typedef long long ll;
static const ll MOD = 1000000007;
static const ll INF = 1000000000000000000LL;


//お金の順位をつけて、n位以内なら入れる
int main() {
    ll N,M;
    cin >> N >> M;

    vector <vector<ll>> A(M+1);

    ll tmpA,tmpB;
    REP(i,N)
    {
        cin >> tmpA >> tmpB;

        if(tmpA > M)continue;
        A[M-tmpA].push_back(tmpB);
    }
    
    ll res = 0;
    priority_queue<ll> q;
    for(ll i = M; i >= 0; --i)
    {
        REP(j,A[i].size())q.push(A[i][j]);

        if(!q.empty())
        {
            res += q.top();
            q.pop();
        }
    }

    cout << res <<endl;

    return 0;
}

Measured memory_bytes: 5632
#include<stdio.h>
#include<string.h>
int main(void)
{
	int i,j,n;
	char s[100],t[100],x;
	int flg;
	scanf("%s",&s);
	scanf("%s",&t);
	n=strlen(s);
	i=0;
	flg=0;
	while(i!=n){
		//printf("%d %d\n",i,n);
		x=s[n-1];
		for(j=n-1;j>0;j--){
			s[j]=s[j-1];
		}
		s[0]=x;
		//printf("%s\n",s);
		if(strcmp(s,t)==0){
			flg=1;
		}
		i++;
	}
	if(flg==1)		printf("Yes\n");
	else				printf("No\n");
	return 0;
}

Measured memory_bytes: 128
package main

import "fmt"

func main() {
	var N int
	fmt.Scan(&N)
	A := make([]int, N)
	for i := 0; i < N; i++ {
		fmt.Scan(&A[i])
	}

	var cnt, j int
	for i := 0; i < N; i++ {
		j = i + 1
		if j >= N {
			break
		}
		if A[i] == A[j] {
			cnt++
			i++
		}
	}
	fmt.Println(cnt)
}


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

using namespace std;

int main()
{
	long long ans = 0;
	int Q, H, S, D, N;
	cin >> Q >> H >> S >> D >> N;

	int min_value = min(min(4 * Q, H * 2), S);

	if (N == 1)
	{
		ans = min_value;
	}
	else if(N % 2 == 0)
	{
		ans = (long long)min(min_value * 2, D) * N / 2;
	}
	else
	{
		ans = (long long)min(min_value * 2, D) * (N - 1) / 2;
		ans += min_value;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
i = 0
while True:
    n = int(input())
    if n == 0:
        break
    
    j = 0
    a =[]
    while True:
        n = n//5
        a.append(n)
        if n//5 == 0:
            break
        j += 1
        
    i += 1

    print(sum(a))


Measured memory_bytes: 5592
using namespace std;
    #include <iostream>
    #include <math.h>
    int main(){
      int D, N, fact;
      cin >> D >> N;
      if ( D >= 0 && D <= 2){
        if( N <= 99 && N >= 1 )
      	  fact = pow(100, D) * N;
        else
          fact = pow(100, D) * 101;
      cout << fact << endl;
      }
      return(0);
    } 

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

#define debug(a) cerr << #a << " = " << (a) << endl;
#define fst first
#define snd second
#define sz(x) (int)(x).size()
#define all(X) begin(X), end(X)

typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<int, int> pii;

template<typename T, typename U> ostream& operator<<(ostream& o, const pair<T, U>& x) { 
  o << "(" << x.fst << ", " << x.snd << ")"; return o;
}

template<typename T> ostream& operator<<(ostream& o, const vector<T>& x) {
  o << "["; int b = 0; for (auto& a : x) o << (b++ ? ", " : "") << a; o << "]"; return o;
}

template<typename T> ostream& operator<<(ostream& o, const set<T>& x) {
  o << "{"; int b = 0; for (auto& a : x) o << (b++ ? ", " : "") << a; o << "}"; return o;
}

template<typename T, typename U> ostream& operator<<(ostream& o, const map<T, U>& x) {
  o << "{"; int b = 0; for (auto& a : x) o << (b++ ? ", " : "") << a; o << "}"; return o;
}

int n;
int dp[100005];
int A[100005];

int f(int i) {
  if(i == n) return 0;
  
  int& x = dp[i];
  if(x != -1) return x;
  
  if(i + 2 > n) x = abs(A[i] - A[i+1]) + f(i+1);
  else x = min(abs(A[i] - A[i+1]) + f(i+1), abs(A[i] - A[i+2]) + f(i+2));
  
  return x;
}

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

  cin >> n;
  for(int i = 1; i <= n; ++i) {
    cin >> A[i];
    dp[i] = -1;
  }

  cout << f(1) << endl;  
}



Measured memory_bytes: 3328
#include <iostream>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <bits/stdc++.h>
#define FIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ll long long
using namespace std;
using namespace __gnu_pbds;

typedef tree<pair<long long int,long long int>,null_type,less<pair<long long int,long long int> >,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

void go()
{
    int n;
    cin>>n;
    vector<vector<int> > a(n,vector<int>(3));
    vector<vector<int> > dp(n+1,vector<int>(3,0));
    for(int i=0;i<n;i++)
        cin>>a[i][0]>>a[i][1]>>a[i][2];
    dp[1][0]=a[0][0];
    dp[1][1]=a[0][1];
    dp[1][2]=a[0][2];
    for(int i=2;i<=n;i++)
    {
        dp[i][0]=max(dp[i-1][1]+a[i-1][0],dp[i-1][2]+a[i-1][0]);
        dp[i][1]=max(dp[i-1][0]+a[i-1][1],dp[i-1][2]+a[i-1][1]);
        dp[i][2]=max(dp[i-1][1]+a[i-1][2],dp[i-1][0]+a[i-1][2]);
    }
    cout<<max(dp[n][0],max(dp[n][1],dp[n][2]));
}
int main()
{
    FIO;
//    int t;
//    cin>>t;
//    while(t--)
        go();
    return 0;
}



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

int int_len(int n) {
  int s=0;
  while(n!=0) s++, n/=10;
  return s;
}

int int_sum(int n) {
  int m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(int i=s-1;i>=0;i--) m+=n/((int)pow(10,i))-(n/((int)pow(10,i+1)))*10;
  return m;
}






int gcd(int a,int b)
{
 
  int r, tmp;
 
  
 
  /* 自然数 a > b を確認・入替 */
  if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }
 
  /* ユークリッドの互除法 */
  r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
 
 
 
  return b;
}







int fac(int n){
  int m=1;
  while(n>=1) m*=n,n--;
  return m;
}

int vec_sum(vector<int> v){
  int n=0;
  for(int i=0;i<v.size();i++) n+=v[i];
  return n;
}
///////////////////////////
int main() {
  long long int n,ans=1;
  cin>>n;
  for(int i=1;i<=n;i++){
    ans*=i;
    ans%=1000000007;
  }
  cout<<ans<<endl;
}
///////////////////////////






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

constexpr int INF = 2147483647;
constexpr long long int INF_LL = 9223372036854775807;
constexpr int MOD = 1000000007;
using namespace std;
using ll = long long int;
using ull =  unsigned long long int;

// AB + AB
// ABAB
// SA BA
int main() {
	int N;
	cin >> N;
	int startB = 0, endA = 0, ans = 0, AandB = 0;
	for (int i = 0; i < N; i++) {
		string s;
		cin >> s;
		for (int j = 1; j < s.length(); j++) {
			if (s[j] == 'B' && s[j - 1] == 'A')ans++;
		}
		if (s[0] == 'B')startB++;
		if (s.back() == 'A')endA++;
		if (s[0] == 'B' && s.back() == 'A')AandB++;
	}
	startB -= AandB;
	endA -= AandB;
		if (endA != 0 && startB != 0) {
			cout << ans + AandB + min(startB - 1, endA - 1) + 1 << endl;
		}
		else if (endA == 0 && startB != 0) {
			cout << ans + AandB << endl;
		}
		else if (endA != 0 && startB == 0) {
			cout << ans + AandB << endl;
		}
		else {
			cout << ans + AandB - (AandB != 0) << endl;
		}
}


Measured memory_bytes: 256
NY = list(map(int,input().split()))
N = NY[0]
Y = NY[1]

counter = False

for s in range(N+1):
    for t in range(N-s+1):
        if s*10000 + t*5000 + (N-s-t)*1000 == Y:
            counter = True
            break
    if counter == True:
        break
if counter == False:
    output = "-1 -1 -1"
elif counter == True:
    output = "{0} {1} {2}".format(s,t,N-s-t)
print(output)


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

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

    if(2*n >= m){
        cout << m/2 << endl;
    }

    else{ //2n<m
        cout << (n + m/2)/2 << endl;
    }
}


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

#define loop(i,n) for(int i=0;i<n;i++)
int d[10002];

int main(){
  int n,a,b,c;
  cin>>n>>a>>b>>c;
  loop(i,n)cin>>d[i];
  sort(d,d+n,greater<int>());
  int pr=a,kr=c;
  int best=c/a;
  loop(i,n){
    pr+=b;
    kr+=d[i];
    if(kr/pr>=best)best=kr/pr;
    else break;
  }
  cout<<best<<endl;
  return 0;
}

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

using namespace std;

typedef long long ll;

const int N = 105;

const int mod = 1e9+7;

int n;

vector < ll > primeFactors(long long num){
    vector < ll > prm;
    while (num % 2 == 0){
        prm.push_back(2);
        num = num/2;
    }
    for (ll i = 3; i*i <= num; i = i + 2){
        while (num % i == 0){
            prm.push_back(i);
            num = num/i;
        }
    }
    if (num > 2)
        prm.push_back(num);
    return prm;
}

int main() {
    scanf("%d" , &n);
    map < int , int > cnt;
    for(int i = 1; i <= n; i++){
        vector < ll > f = primeFactors(i);
        for(auto v : f){
            cnt[v]++;
        }
    }
    long long ans = 1;
    for(auto it = cnt.begin(); it != cnt.end(); it++){
        ans = (ans * ((it->second) + 1)) % mod;
    }
    printf("%lld\n" , ans);
    return 0;
}


Measured memory_bytes: 3740
#include <iostream>
#include <algorithm>
#include <cstdlib>

using namespace std;

const int inf = 1000001;

int main()
{
  int n, mn, t, a[21], mask, s, u;

  while(cin>>n && n){
    t = 0;
    mn = inf;

    for(int i = 0; i < n; ++i){
      cin >> a[i];
      t += a[i];
    }

    mask = 1<<n;
    for(int i = 0; i < mask; i++){
      s = 0;
      for(int j = 0; j < n; j++){
	u = 1<<j;
	if(i&u) s += a[j];
      }  
      mn = min(mn, abs(s-(t-s)));
    }

    cout << mn << endl;
  }

  return 0;
}

Measured memory_bytes: 868
#include <iostream>

using namespace std;

int count[26];

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    char ch;
    while(cin>>ch) {
        if('a'<=ch && ch<='z') count[ch-'a']++;
        if('A'<=ch && ch<='Z') count[ch-'A']++;
    }
    for(int i=0; i<26; i++) {
        cout<<(char)(i+'a')<<" : "<<count[i]<<'\n';
    }
    return 0;
}

Measured memory_bytes: 1180
import glob
import os

bn = os.path.basename(__file__).split('.')[0]
dn = os.path.dirname(__file__).split('/')

# 問題ごとのディレクトリのトップからの相対パス
REL_PATH = dn[len(dn)-2] + '\\' + dn[len(dn)-1] + '\\' + bn

# テスト用ファイル置き場のトップ
TOP_PATH = 'C:\\AtCoder'

class Common:

    problem = []
    index = 0

    def __init__(self, rel_path):
        self.rel_path = rel_path

    def initialize(self, path):
        file = open(path)
        self.problem = file.readlines()
        self.index = 0
        return

    def input_data(self):
        try:
            IS_TEST
            self.index += 1
            return self.problem[self.index-1]

        except NameError:
            return input()

    def resolve(self):
        pass

    def exec_resolve(self):
        try:
            IS_TEST
            for path in glob.glob(TOP_PATH + '\\' + self.rel_path + '/*.txt'):
                print("Test: " + path)
                self.initialize(path)
                self.resolve()
                print("\n\n")
        except NameError:
            self.resolve()


class Solver(Common):

    def resolve(self):

        N = int(self.input_data())
        A = list(map(int, self.input_data().split()))
        A_sorted = sorted(A)

        check_list = [-1]*1000001

        for a in A:
            for i in range(a, 1000001, a):
                if i == a:
                    if check_list[i] == -1:
                        check_list[i] = 0
                    elif check_list[i] == 0:
                        check_list[i] = 1
                    else:
                        break
                    continue

                check_list[i] = 1


        result = 0
        for i in A_sorted:
            if check_list[i] < 1:
                result += 1

        print(str(result))

solver = Solver(REL_PATH)
solver.exec_resolve()


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
// #define int long long

using namespace std;

signed main()
{
    int N, M, C;
    cin >> N >> M >> C;
    int A[N][M];
    int B[M];
    rep(i, M) cin >> B[i];
    rep(i, N)
    {
        rep(j, M)
        {
            cin >> A[i][j];
        }
    }
    int count = 0;
    int s = 0;
    rep(i, N)
    {
        s = 0;
        rep(j, M)
        {
            s += A[i][j] * B[j];
        }
        s += C;
        if (s > 0)
        {
            count++;
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define uint unsigned int
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FORR(i, a, b) for (int i = (a); i >= (b); --i)
#define ALL(a) (a).begin(), (a).end()
#define ALLR(a) (a).rbegin(), (a).rend()
#define SZ(a) ((int)(a).size())
#define PB(a) push_back(a)
#define EMP emplace
#define EMPB(...) emplace_back(__VA_ARGS__)
#define MP(a, b) make_pair(a, b)
#define MT(...) make_tuple(__VA_ARGS__)
#define Bit(n) (1LL << (n))
using namespace std;
using pii = pair<int, int>;
template <class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template <class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
const int MOD = 1000000007;
const int INF = 1LL << 30;
const double EPS = 1e-10;

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  string s[3];
  REP(i, 3) cin >> s[i];
  int id[3] = {};
  int p = 0;
  while (1) {
    if (id[p] == s[p].size()) break;
    int nxt = s[p][id[p]]-'a';
    id[p]++;
    p = nxt;
  }
  cout << char(p+'A') << endl;

  return 0;
}

Measured memory_bytes: 256
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif

#include <bits/stdc++.h>

using namespace std;

typedef long double ld;

#ifdef DEBUG
#define eprintf(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#else
#define eprintf(...) ;
#endif

#define sz(x) ((int) (x).size())
#define TASK "text"

const int inf = (int) 1.01e9;
const long long infll = (long long) 1.01e18;
const ld eps = 1e-9;
const ld pi = acos((ld) -1);

mt19937 mrand(random_device{} ()); 

int rnd(int x) {
  return mrand() % x;
}

void precalc() {
}

const int mod = (int) 1e9 + 7;

int mul(int a, int b) {
  return (long long) a * b % mod;
}

void add(int &a, int b) {
  a += b;
  if (a >= mod) {
    a -= mod;
  }
}

int powMod(int x, int p) {
  int res = 1;
  while (p) {
    if (p & 1) {
      res = mul(res, x);
    }
    p >>= 1;
    x = mul(x, x);
  }
  return res;
}

const int maxn = 105;
int n;
int a[maxn];

int read() {
  if (scanf("%d", &n) < 1) {
    return false;
  }
  a[0] = 1;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
  }
  a[n + 1] = 1;
  n += 2;
  return true;
}

int cnt[maxn][maxn];
int dp[maxn];

void solve() {
  for (int i = 0; i + 1 < n; i++) {
    cnt[i][i] = 1;
  }
  for (int len = 1; len < n - 1; len++) {
    for (int i = 0; i + len + 1 < n; i++) {
      int j = i + len;
      int k = i + 1;
      for (int l = i + 2; l <= j; l++) {
        if (a[l] < a[k]) {
          k = l;
        }
      }
      if (a[k] <= min(a[i], a[i + 1]) || a[k] <= min(a[j], a[j + 1])) {
        cnt[i][j] = mul(cnt[i][k - 1], cnt[k][j]);
      } else {
        cnt[i][j] = mul(powMod(2, a[k] - max(min(a[i], a[i + 1]), min(a[j], a[j + 1]))), mul(cnt[i][k - 1], cnt[k][j]));
      }
    }
  }
  memset(dp, 0, sizeof(dp));
  dp[0] = 2;
  for (int i = 0; i + 1 < n; i++) {
    auto cur = dp[i];
    for (int j = i + 1; j + 1 < n; j++) {
      add(dp[j], mul(cur, cnt[i][j]));
    }
  }
  printf("%d\n", dp[n - 2]);
}

int main() {
  precalc();
#ifdef DEBUG
  assert(freopen(TASK ".in", "r", stdin));
  assert(freopen(TASK ".out", "w", stdout));
#endif
  while (read()) {
    solve();
#ifdef DEBUG
    eprintf("Time %.2f\n", (double) clock() / CLOCKS_PER_SEC);
#endif
  }
  return 0;
}


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

using namespace std;

using ll = long long;

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

    string s;
    cin >> s;
    int n = 0;
    for (auto c : s)
        if (c == '2') ++n;
    cout << n << endl;

    return 0;
}


Measured memory_bytes: 768
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<vector>
#include<string>
#include<cstring>
#include<iostream>
#include<algorithm>
#define fi first
#define se second
#define debug printf(" I am here\n");

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
const ll INF=0x3f3f3f3f3f3f3f3f;
const int N = 5e5+10, mod=1e9+7;
int t, n, m; 
int a[N];
bool st[N];

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	cin >> s;
	
	int cnt = 0, d;
	for(int i = 0 ; i < s.size() ; i ++)
	{
		if(s[i] == '>')
		{
			if(cnt == 0)
				d = i;
			cnt ++;
		}
		else
		{
			if(cnt != 0)
				a[d] = cnt;
			cnt = 0;
		}
	}
	if(cnt != 0)
		a[d] = cnt;	
	
	// < >>> << > <<<<< >>> <
	int j;
	bool flag = false;
	for(int i = 0 ; i < s.size() ; i ++)
	{
		if(s[i] == '>' && s[i+1] == '<')
			a[i+1] = 0, flag = false;
		else if(s[i] == '<' && a[i+1] <= a[i])
			a[i+1] = a[i] + 1, flag = false;
		else if(s[i] == '>')
		{
			if(!flag)
			{
				for(j = i ; s[j] == '>' && j < s.size(); j ++);
				j = j - i;				
			}
			a[i+1] = j - 1;	
			j --;
			flag = true;		
		}
	
	}
	/*cout << a[0];
	for(int i = 0 ; i < s.size() ; i ++)
		cout << s[i] << a[i+1];*/
	long long sum = 0;
	for(int i = 0 ; i <= s.size() ; i ++)
		sum += a[i];
	cout << sum << endl;
}

Measured memory_bytes: 5872
#include<bits/stdc++.h>
using namespace std;
const long long mod=1e9+7;
long long n,m;
long long s[2000+10],t[2000+10];
long long dp[2000+10][2000+10];
int main()
{
    cin>>n>>m;
    for(int i=1;i<=n;i++)    cin>>s[i];
    for(int i=1;i<=m;i++)    cin>>t[i];
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=m;j++)
        {
            dp[i][j]=(dp[i-1][j]+dp[i][j-1]-dp[i-1][j-1])%mod;
            if(s[i]==t[j])
            {
                dp[i][j]=(dp[i][j]+dp[i-1][j-1]+1)%mod;
            }
            if(dp[i][j]<0)
            {
                dp[i][j]=dp[i][j]+mod;
            }
        }
    }
    cout<<(dp[n][m]+1)%mod;
    return 0;
}

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

using namespace std;

int cnt[2019];

int main()
{
//    freopen("BOI2019.INP", "r", stdin);
//    freopen("BOI2019.OUT", "w", stdout);
    string s;
    cin >> s;
    reverse(s.begin(), s.end());
    int p = 1, t = 0;
    long long ans = 0LL;
    for (int i = 0; i < s.size(); ++i)
    {
        ++cnt[t];
        ans += cnt[t = (t + (s[i] - '0') * p) % 2019];
        p = (p * 10) % 2019;
    }

    cout << ans;
    return 0;
}


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

using ll = long long;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define REP(i, n) FOR(i, 0, n)
#define ALL(c) (c).begin(), (c).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;}
const int MOD = 1000000007;

int main() {
    int n;
    cin >> n;
    vector<int> p(n);
    REP(i, n) {
        cin >> p[i];
    }
    int c = 0;
    REP(i, n - 2) {
        if (max({p[i], p[i + 1], p[i + 2]}) != p[i + 1] && min({p[i], p[i + 1], p[i + 2]}) != p[i + 1]) {
            c++;
        }
    }
    cout << c << endl;
}


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

using namespace std;

int main(){
    int N,M,X,Y;
    cin>>N>>M>>X>>Y;
    vector<int> x(N+1),y(M+1);

    for(int i=0;i<N;i++){cin>>x[i];}
    for(int i=0;i<M;i++){cin>>y[i];}
    x[N]=X;y[M]=Y;
    sort(x.begin(),x.end());
    sort(y.begin(),y.end());

    if(x[N]>=y[0]){
        cout<<"War";
    }else{
        cout<<"No War";
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(long long i=0; i<n; i++)
#define REPR(i, n) for(long long i=n-1; i>=0; i--)
#define FOR(i, m, n) for(long long i=m; i<=n; i++)
#define FORR(i, m, n) for(long long 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()
#define FIN ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

using namespace std;
using ll = long long;
using ull = unsigned long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;
const ll mod = 1e9+7;
const ll inf = 1e15;
ll power(ll a,ll b){return b?power(a*a%mod,b/2)*(b%2?a:1)%mod:1;}


int main(){FIN
    ll n;cin>>n;
    vll a(n);REP(i,n)cin>>a[i];
    map<ll,ll>mp;
    REP(i,n) mp[a[i]]++;
    vll hen(n,0);
    for (auto p:mp){
        if (p.second>1) hen.push_back(p.first);
        if (p.second>3) hen.push_back(p.first);
    }
    VSORTR(hen);
    cout<<hen[0]*hen[1]<<endl;
    return 0;
}


Measured memory_bytes: 11904
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;

namespace AtCoder_Beginner_Contest_129
{
    class Program
    {
        static public int[] Sarray() { return ReadLine().Split().Select(int.Parse).ToArray(); }
        static public List<int> Slist() { return ReadLine().Split().Select(int.Parse).ToList(); }

        static void Main(string[] args)
        {
            var pqr = Slist();
            pqr.Sort();
            WriteLine(pqr[0] + pqr[1]);
        }
    }
}

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

int distance(int a, int b, int c, int d)
{
  return max(a,c) - min(a,c) + max(b,d) - min(b,d);
}

int main()
{
  int n,m;
  vector<pair<int,int>> stu,che;
  cin >> n >> m;

  for (int cnt = 0; cnt < n; cnt++) {
    int a,b;
    cin >> a >> b;
    stu.push_back(make_pair(a,b));
  }

  for (int cnt = 0; cnt < m; cnt++) {
    int c,d;
    cin >> c >> d;
    che.push_back(make_pair(c,d));
  }

  for (int s = 0; s < n; s++) {
    int rst = 1;
    int cls = distance(stu[s].first,stu[s].second,che[0].first,che[0].second);
    for (int t = 1; t < m; t++) {
      int tmp = distance(stu[s].first,stu[s].second,che[t].first,che[t].second);
      if (cls > tmp) {
        cls = tmp;
        rst = t + 1;
      }
    }
    cout << rst << endl;
  }

  return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {

  public static void main(String[] args) { 
      Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      int[][] arr = new int[n][2];

      long sumA = 0;
      for(int i = 0; i < n; i++) {
        arr[i][0] = sc.nextInt();
        sumA += arr[i][0];
      }

      long sumB = 0;
      for(int i = 0; i < n; i++) {
        arr[i][1] = sc.nextInt();
        sumB += arr[i][1];
      }

      if(sumA < sumB) {
        System.out.println(-1);
        return;
      }

      Arrays.sort(arr, (a1, a2) -> (a1[0] - a1[1]) - (a2[0] - a2[1]));
      int cnt = 0;
      long diffSum = 0;
      for(int i = 0; i < n; i++) {
        if(arr[i][0] >= arr[i][1]) break;
        cnt++;
        diffSum += arr[i][1] - arr[i][0];
      }

      for(int i = n - 1; i >= 0 && diffSum > 0; i--) {
        diffSum -= (arr[i][0] - arr[i][1]);
        cnt++;
      }
      System.out.println(cnt);
  }
}


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

using namespace std;

int main()
{
	int N, Q, t;
	int sum = 0;
	cin >> N;

	int S[100001];
	for (int i = 0; i < N; i++)
		cin >> S[i];

	cin >> Q;
	for (int i = 0; i < Q; i++)
	{
		cin >> t;

		// t??\????????????t????????????????????????????????????
		if (*lower_bound(S, S + N, t) == t)
			sum++;
	}

	cout << sum << endl;

	return 0;
}

Measured memory_bytes: 3480
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)

	var str string
	fmt.Scan(&str)

	var cnt, min int
	for i := 0; i < n; i++ {
		if str[i] == '(' {
			cnt++
		} else {
			cnt--
		}
		min = minFn(min, cnt)
	}
	for i := -min; i > 0; i-- {
		fmt.Print("(")
	}
	fmt.Print(str)
	for i := cnt - min; i > 0; i-- {
		fmt.Print(")")
	}
}

func minFn(a, b int) int {
	if a < b {
		return a
	}
	return b
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define loop(i,a,b) for(ll i=a;i<b;i++)
#define loope(i,a,b) for(ll i=a;i<=b;i++)
#define test() ull t;cin>>t;while(t--)
#define pll pair<ll,ll>
#define puu pair<ull,ull>
#define f first
#define s second
#define pb push_back
#define mkp make_pair
#define ins insert
#define Vint vector<int>
#define Vll vector<ll>
#define Vull vector<ull>
#define nl cout<<endl
#define sp cout<<" "
#define MOD 1000000007
#define all(x) x.begin(),x.end()
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};


int main() 
{
	// ios::sync_with_stdio(0);
	// cin.tie(0);
	// cout.tie(0);
	
	ll n,W;
	cin>>n>>W;
	vector<ll> w(n),v(n);
	loop(i,0,n)
		cin>>w[i]>>v[i];

	ll dp[W+1];

	memset(dp,0,sizeof(dp));

	loop(i,1,n+1){
		for(ll wl = W-w[i-1];wl>=0;wl--)
			dp[wl+w[i-1]] = max(dp[wl+w[i-1]],dp[wl] + v[i-1]);

	}
	ll ans = 0;

	loop(i,1,W+1)
		ans = max(ans,dp[i]);

	cout<<ans;
}

Measured memory_bytes: 4384
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int pow6[10],pow9[10];

void init()
{
	pow6[0] = 1;
	pow9[0] = 1;
	rep(i,9)
	{
		pow6[i+1] = pow6[i] * 6;
		pow9[i+1] = pow9[i] * 9;
	}
}

int main()
{
	init();
	int N;
	cin >> N;
	int ans = N;
	for (int i = 0; i*6 < 100005; ++i)
	{
		for (int j = 0; j*9 < 100005-i*6; ++j)
		{
			int temp = i*6+j*9, cnt = 0;
			int t = i;
			while(t > 0)
			{
				cnt += t % 6;
				t /= 6;
			}
			t = j;
			while(t > 0)
			{
				cnt += t % 9;
				t /= 9;
			}
			if (temp <= N)
			{
				ans = min(ans,cnt+N-temp);
				//cout << i << " " << j << " " << cnt << " " << temp << " " << cnt+N-temp << endl;
			}
		}
		
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3636
#include<stdio.h>

int main(){
		int a,b,c,d,e,f;
		scanf("%d%d%d%d%d%d",&a,&b,&c,&d,&e,&f);
		int ans[1000][2],i,j,k,l,counter=0;
		for(i=0;i<=f/100;i+=a){
				for(j=0;j<=f/100-i;j+=b){
						if(i+j!=0){
								ans[counter][0]=(i+j)*100;	
								counter++;
						}
				}
		}
		for(i=0;i<counter;i++)ans[i][1]=0;
		float max=0;int tmp=0,flag=0;
		for(i=0;i<counter;i++){
				k=f-ans[i][0];
				int king=0;
				for(j=0;j<f-ans[i][0];j+=d){
						for(l=0;d+l<=f-ans[i][0];l+=c){
								if(king<j+l&&(j+l)<=e*ans[i][0]/100&&j+l+ans[i][0]<=f)king=j+l;
						}
						
				}
				ans[i][1]=king;
//				printf("%d %d\t%f\n",ans[i][0],ans[i][1],((double)ans[i][1]/((double)ans[i][0]+(double)ans[i][1])));
				if(max<(double)ans[i][1]/((double)ans[i][0]+(double)ans[i][1])){
						max=(double)ans[i][1]/((double)ans[i][0]+(double)ans[i][1]);
						tmp=i;
				}
		}
		printf("%d %d\n",ans[tmp][0]+ans[tmp][1],ans[tmp][1]);
		return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,d=0,n,e,b,c=0;
    cin>>n;
    for(int i=1; i<=n; i++)
    {
    b=floor(log10(i)+1);

    if(b%2==1)
    {
        d++;
    }
    }

        cout<<d<<endl;

}


Measured memory_bytes: 512
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;

typedef long long ll;

const int N=3e5+1e3+7;

int n,a,b,ans[N];

int main()
{
	cin>>n>>a>>b;
	for(int i=1;i<=n;++i)
		ans[i]=i;
	if(a+b-n>1)
	{
		puts("-1");
		return 0;
	}
	if((n+a-1)/a>b)
	{
		puts("-1");
		return 0;
	}
	if(a==1)
	{
		for(int i=n;i>=1;--i)printf("%d ",i);
		return 0;
	}
	int len=(n-b)/(a-1);
	int ad1=(n-b)%(a-1);
	reverse(ans+1,ans+b+1);
	int now=b+1;
	for(int i=2;i<=a;++i)
		reverse(ans+now,ans+now+len+(ad1>0)),ad1--,now+=len+(ad1>=0);
	for(int i=1;i<=n;++i)
		printf("%d ",ans[i]);
}

Measured memory_bytes: 3328
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<map>
#include<set>
#include<bitset>
#include<vector>
#include<stack>
#include<queue>
#include<functional>
using namespace std;
typedef long long ll;
int inf = 1000000000;
ll n, a[100010], b[100010], c[100010], bb[100010];
ll ans = 0;
int main() {
	cin >> n;
	for (int i = 0; i < n; i++)cin >> a[i];
	for (int i = 0; i < n; i++)cin >> b[i];
	for (int i = 0; i < n; i++)cin >> c[i];
	sort(a, a + n);
	sort(b, b + n);
	sort(c, c + n);
	bb[0] = n - (lower_bound(c, c + n, b[0] + 1) - c);
	for (int i = 1; i < n; i++) {
		bb[i] = n - (lower_bound(c, c + n, b[i] + 1) - c);
		bb[i] += bb[i - 1];
	}
	for (int i = 0; i < n; i++) {
		ans += bb[n - 1] - bb[(upper_bound(b, b + n, a[i]) - b) - 1];
	}
	cout << ans << endl;
}

Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std ;
#define ll long long
#define ld long double
#define ff first
#define ss second
const ll mod =   1e9 + 7 ;
ll multiply(ll a, ll b ){ return ((a % mod) * (b % mod)) % mod; }
ll add(ll a, ll b) {     return ((a % mod) + (b % mod)) % mod; }
ll sub(ll a, ll b) { return ((a%mod) - (b % mod)+ mod) % mod ; }
////////////////////////////////////////////////////////////////
const int dx[] = {0,0,1,-1};
const int dy[] = {1,-1,0,0};
///////////////////////////////////////////////////////////////
void solve(){
    int n , m , k ;
    cin >> n >> m >> k ;
    vector < string > mat(n) ;
    int ans = 0;
    for( int i = 0 ; i<n; i++) cin >> mat[i] ;
    for( int i = 0 ; i < (1<<n); i++){
        for( int j = 0 ; j < (1<<m) ; j++){
            int local = 0 ;
            for( int a = 0 ; a < n ; a++){
                for( int b = 0 ; b < m ; b++){
                    if( i&(1<<a) || j&(1<<b) ) continue ;
                    if(mat[a][b]=='#')
                        local++;
                }
            }
            if(local==k)
                ans++;
        }
    }

    cout << ans ;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int t = 1 ;
   // cin >> t ;
    while(t--){
        solve( );
    }
}




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

int main()
{
    ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    
    int N;
    cin >> N;

    vector<int> L(N);
    rep(i,N) cin >> L[i];

    int max = *max_element(L.begin(), L.end());
    int sum = accumulate(L.begin(), L.end(), 0);

    string ans = (sum - max > max) ? "Yes" : "No";

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
n = int(input())
import collections
c = collections.Counter(list(map(int,input().split())))
k = list(c.keys())
v = list(c.values())
#print(k,v)
if len(k)==3 and k[0]^k[1]^k[2]==0 and v[0]==v[1]==v[2]:
  print("Yes")
elif len(k)==2 and k.count(0) and v[k.index(0)]==(sum(v)/3):
  print("Yes")
elif k == [0]:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 14484
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < int(n); i++)
using namespace std;
using ll = long long;
const int INF = (1<<30)-1;
const long long LINF = (1LL<<62)-1;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
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; }

const int MAX = 1000010;

vector<bool> prime_table(int n) {
  vector<bool> res(n + 1, true);
  res[0] = false;
  if (n >= 1) res[1] = false;
  for (int i = 2; i * i <= n; i++) {
    if (!res[i]) continue;
    for (int j = i + i; j <= n; j += i)
      res[j] = false;
  }
  return res;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int x;
  cin >> x;
  auto p = prime_table(MAX);
  for (int i = x; i < MAX; i++) {
    if (p[i]) {
      cout << i << endl;
      break;
    }
  }
  return 0;
}

Measured memory_bytes: 3808
#include<bits/stdc++.h>
using namespace std;
int main()
{
    char arr[6][6];
    int h,w,k;
    cin>>h>>w>>k;
    for(int i=0;i<h;i++)
        for(int j=0;j<w;j++)
            cin>>arr[i][j];

    int ans=0;
    for(int i=0;i<(1<<h);i++)
    {
        for(int j=0;j<(1<<w);j++)
        {
            int black=0;
            for(int r=0;r<h;r++)
            {
                for(int c=0;c<w;c++)
                {
                    if( ((i>>r)&1)==0 && ((j>>c)&1)==0 && arr[r][c]=='#')
                    {
                        black++;
                    }
                }
            }
            if(black==k)
                            ans++;
        }
    }
    cout<<ans;
}


Measured memory_bytes: 3548
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(unique(all(x)), x.end());
typedef long long ll;
typedef complex<double> Complex;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
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;
}
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for (int i = 0; i < sz(v); i++) {
        os << v[i];
        if (i < sz(v) - 1) os << " ";
    }
    return os;
}
int main() {
    int x, y;
    cin >> x >> y;
    for (int i = 0; i <= x; i++) {
        int j = x - i;
        if (2 * i + 4 * j == y) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 3616
#include<iostream>
#include<iomanip>
#include<climits>
#include<vector>
#include<list>
#include<functional>
#include<algorithm>
#include<string>
#include<cmath>
#include<complex>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

const int n = 200000;
int sum[n + 1];

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

	REP(i, n + 1) sum[i + 1] = sum[i] + i + 1;
	
	int N, K;
	cin >> N >> K;
	vector<double> tmp(N + 1);
	REP(i, N) {
		int p;
		cin >> p;
		tmp[i + 1] = tmp[i] + sum[p] / (double)p;
	}

	double res = 0;
	REP(i, N - K + 1) {
		res = max(res, tmp[i + K] - tmp[i]);
	}

	printf("%.8lf", res);

	return 0;
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
	int n; cin>>n;
	ll a[n];
	for(int i=0;i<n;i++)cin>>a[i];
	ll mx=-1;
	ll cnt=0;
	for(int i=0;i<n;i++)
	{
		mx=max(mx,a[i]);
		if(a[i]<mx)
		{
			cnt=cnt+(mx-a[i]);
		}
	}
	cout<<cnt;

}

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

#define INF 1001001001
#define LINF 1001001001001001001
#define MOD 1000000007
#define MOD2 998244353

#define all(a)  (a).begin(),(a).end()
#define dig(n)  to_string(n).length()

#define pb push_back
#define eb emplace_back
#define mkp make_pair

#define se second
#define fi first



typedef long long ll;
typedef pair<int,int> pii;
typedef pair<pii,pii> ppii;

int main(){

    bool flag=false;
    ll ans=0,sum=0;

    int r;
    cin >>r;
  
  	if(r < 1200){
    	cout << "ABC" << endl;
    }else if(r < 2800){
        cout << "ARC" << endl;
    }else{
        cout << "AGC" << endl;
    }

    //cout <<fixed<<setprecision(16)<< << endl;
    //cout << ans << endl;
    return 0;
}


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

int main() {
    char str[10];
    char str2[10];
    char str3[10];

    scanf("%s", str);
    scanf("%s", str2);
    scanf("%s", str3);


    printf("%c%c%c\n", str[0], str2[1], str3[2]);

    return 0;

}

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

using namespace std;

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

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

using pint = pair<int, int>;
using tint = tuple<int, int, int>;
using vint = vector<int>;

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

#define MAX_N 150000

int N;
vector<int> G[MAX_N];

double dp[MAX_N];

void dfs(int u, int p) {
  int sz = G[u].size(), ch = sz-1;
  if(!u) ch++;

  dp[u] = 0;
  for(int v : G[u]) {
    if(v == p) continue;
    dfs(v, u);
    dp[u] += dp[v]+1;
  }

  if(ch) dp[u] /= ch;
}

double ans[MAX_N];

void dfs2(int u, int p, double rev) {
  int sz = G[u].size(), ch = sz-1;

  if(u) ans[u] = (dp[u]*ch + rev) / sz; // ch/szの確率で子へ、残りは親へ
  else ans[u] = dp[u];

  for(int v : G[u]) {
    if(v == p) continue;
    if(u) { // 根以外
      double tmp = dp[u] * ch;
      tmp -= dp[v]+1; // T(v)以外の部分は再利用
      tmp += rev;
      tmp /= ch;
      dfs2(v, u, tmp+1);
    } else { // 根
      if(sz == 1) dfs2(v, u, 1);
      else {
	double tmp = dp[u] * sz;
	tmp -= dp[v]+1;
	tmp /= ch;
	dfs2(v, u, tmp+1);
      }
    }
  }
}


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

  cin >> N;
  rep(i, N-1) {
    int u, v;
    cin >> u >> v;
    --u, --v;
    G[u].push_back(v);
    G[v].push_back(u);
  }

  dfs(0, -1);
  dfs2(0, -1, 0);
  rep(i, N) cout << ans[i] << endl;

  return 0;
}


Measured memory_bytes: 21248
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
#include<iomanip>
#include<map>
#include<set>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
void init_io(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(10);
}
signed main(){
  init_io();
  ll n,k,can,ans=-1000000000000000,sum;
  cin >> n >> k;
  vector<ll> v(n),tmp;
  for(int i=0;i<n;i++){
    cin >> v[i];
  }
  for(int l=0;l<=k;l++){
    for(int r=0;l+r<=k;r++){
      can = k-l-r;
      sum=0;
      if(l+r>=n){
        for(int i=0;i<n;i++){
          tmp.push_back(v[i]);
          sum += v[i];
        }
      }else{
        for(int i=0;i<l;i++){
          tmp.push_back(v[i]);
          sum += v[i];
        }
        for(int i=0;i<r;i++){
          tmp.push_back(v[n-1-i]);
          sum += v[n-1-i];
        }
      }
      sort(tmp.begin(),tmp.end());
      for(auto p:tmp){
        if(can==0||p>=0) break;
        sum -= p;
        can--;
      }
      ans = max(sum,ans);
      tmp.clear();
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
'use strict';(function(input){
  
  input=input.trim().split(/\n+/);
  const N=input.shift();
  input=input.map(str=>str.split('').sort().join(''));
  
  const counter={};
  for(let i=0;i<N;i++){
    if(!counter.hasOwnProperty(input[i])){
      counter[input[i]]=1;
    }else{
      counter[input[i]]++;
    }
  }
  
  var ans=0;
  
  for(let str in counter){
    let n=counter[str];
    ans+=n*(n-1)/2;
  }
  
  
  console.log(ans);
})(require('fs').readFileSync('/dev/stdin','utf8'));


Measured memory_bytes: 60716
#include<iostream>
#include<cmath>
#include<cstdio>
using namespace std;
int main()
{
    double x1,x2,y1,y2,x,y,z;
    cin>>x1>>y1>>x2>>y2;
    x=x2-x1;
    y=y2-y1;
    x *=x;
    y *=y;
    z=sqrt(x+y);
    printf("%lf\n",z);
    return 0;
}

Measured memory_bytes: 3156
#include <iostream>
#define MAX_LEN 1001
using namespace std;

// in ASCII, num begin in 48

int main() {
//    freopen("in.txt", "r", stdin);

    char num[MAX_LEN], tmp;
    int pos, sum, value;
    bool flag;

    while (1) {

        for (int i = 0; i < MAX_LEN; ++i) {
            num[i] = '0';
        }

        pos = 0;
        while ((tmp = getchar()) != '\n' && tmp != -1) {
            num[pos++] = tmp;
        }

        flag = true;
        for (int i = 0; i < MAX_LEN; ++i) {
            if (num[i] != '0') {
                flag = false;
            }
        }
        if (flag) {
            return 0;
        }

        sum = 0;
        for (int i = 0; i < MAX_LEN; ++i) {
            sum += (int) num[i] - 48;
        }
        cout << sum << endl;
    }
}

Measured memory_bytes: 3112
// practice with kaiboy
import java.io.*;
import java.util.*;

public class Main extends PrintWriter {
	Main() { super(System.out, true); }
	Scanner sc = new Scanner(System.in);
	public static void main(String[] $) {
		Main o = new Main(); o.main(); o.flush();
	}

	static final int MD = 998244353;
	long power(long a, int k) {
		long p = 1;
		while (k > 0) {
			if ((k & 1) == 1)
				p = p * a % MD;
			a = a * a % MD;
			k >>= 1;
		}
		return p;
	}
	int[] ff, gg;
	void init(int n) {
		ff = new int[n];
		gg = new int[n];
		for (int f = 1, i = 0; i < n; i++) {
			gg[i] = (int) power(ff[i] = f, MD - 2);
			f = (int) ((long) f * (i + 1) % MD);
		}
	}
	long ch(int n, int k) {
		return (long) ff[n] * gg[k] % MD * gg[n - k] % MD;
	}
	void main() {
		int n = sc.nextInt();
		int m = sc.nextInt();
		int k = sc.nextInt();
		init(n);
		long ans = 0;
		for (int h = 0; h <= k; h++)
			ans = (ans + ch(n - 1, h) * m % MD * power(m - 1, n - 1 - h)) % MD;
		println(ans);
	}
}


Measured memory_bytes: 37120