akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx")
#include<bits/stdc++.h>

using namespace std;
using ll = long long;
const ll mod = 1000000007;


int main()
{
    int n;
    string s;
    cin >> n >> s;
    int ans = 0;
    vector<vector<bool>> chack(n, vector<bool>(n));

    for(int i = 0; i < n; i++){
        for(int j = i + 1; j < n; j++){


            int len = 0, start = j, itr = i, jtr = j;
            //bool res = false;
            while(s[itr] == s[jtr] && itr < start && jtr < n && !chack[itr][jtr]){
                chack[itr][jtr] = true;
                itr++;
                jtr++;
                len++;
                //res = true;
            }

            //j -= res;
            ans = max(len, ans);
        }
    }
    cout << ans << endl;

}


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

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

  if(a>=b && a>=c)cout<<b+c<<endl;
  else if(b>=a && b>=c)cout<<a+c<<endl;
  else cout<<a+b<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<iomanip>


#define MOD 1000000007
#define INF 1001001001
#define MIN -1001001001
#define rep(i,k,N) for(int i=k;i<N;i++)
#define MP make_pair
#define MT make_tuple //tie,make_tuple は別物
#define PB push_back
#define PF push_front
#define all(x) (x).begin(),(x).end()


using namespace std;
typedef long long ll;
typedef vector<ll> v;
typedef vector<vector<ll>> vv;

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
void YN(bool ans){
    if(ans)cout<<"No War"<<endl;
    else cout <<"War"<<endl;
    return;
}
int main(){
    ll N,M,X,Y;
    cin>>N>>M>>X>>Y;
    v x(N),y(M);
    ll min_x = X, min_y = Y;
    rep(i,0,N){
        cin>>x[i];
        min_x = max (min_x, x[i]);
    }
    rep(i,0,M){
        cin>>y[i];
        min_y = min (min_y, y[i]);
    }

    YN(min_x< min_y);
    return 0;
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQG = priority_queue<T, vector<T>, greater<T> >;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) {return a < b && (a = b, true);}
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) {return a > b && (a = b, true);}
template<typename T1, typename T2>
istream &operator>>(istream &is, pair<T1, T2> &p) { return is >> p.first >> p.second;}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) { return os << p.first << ' ' << p.second;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a, b, c;
    cin >> a >> b >> c;
    if(a == b and b == c and ~a&1) {
        cout << -1 << endl;
    } else {
        int j = 0;
        while(~a&1 and ~b&1 and ~c&1) {
            int aa = (b+c)>>1;
            int bb = (a+c)>>1;
            c = (a+b)>>1;
            a = aa;
            b = bb;
            j++;
        }
        cout << j << endl;
    }
}

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

#include <vector>
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)
using namespace std;

int main() {
  int x, y;
  cin >> x >> y;
  if ((y - 2 * x) % 2 == 0 && 0 <= (y - 2 * x) && (y - 2 * x) <= 2 * x) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
 
  
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int n;
	
	cin>>n;
	
	long x;
	long long ans = 0;
	
	for(int i=0;i<n;i++){
		cin>>x;
		while(x%2==0){ans++;x/=2;}
	}
	
	cout<<ans<<"\n";
}


Measured memory_bytes: 256
N = int(input())
ai_list = list(map(int, input().split()))

import math
from statistics import mean, median
mean_ai = mean(ai_list)
median_ai = median(ai_list)
mean_lo = math.floor(mean_ai)
mean_high = math.ceil(mean_ai)

ans_list = []
cost1 = 0
cost2 = 0
cost3 = 0
for n in ai_list:
  cost1 += (n - mean_lo)**2
  cost2 += (n - mean_high)**2
  cost3 += (n - median_ai)**2
ans_list.append(cost1)
ans_list.append(cost2)
ans_list.append(cost3)
print(min(ans_list))

Measured memory_bytes: 5148
#include <algorithm>
#include <cassert>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <list>
#include <numeric>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

using namespace std;

#define int long long int
#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) (x).begin(), (x).end()
#define capi(x) int x;cin>>x
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

using vi = vector<int>;

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

#define P (1'000'000'007)

using Graph = vector<vi>;

signed main() {
    string s;
    cin >> s;

    if (s == "SUN") {
        cout << 7;
    } else if (s == "MON") {
        cout << 6;
    } else if (s == "TUE") {
        cout << 5;
    } else if (s == "WED") {
        cout << 4;
    } else if (s == "THU") {
        cout << 3;
    } else if (s == "FRI") {
        cout << 2;
    } else if (s == "SAT") {
        cout << 1;
    }

    return 0;
}


Measured memory_bytes: 3128
use std::io;
#[allow(unused_macros)]
macro_rules! read {
    ($t: ty) => {
        {
            let mut input = String::new();
            io::stdin().read_line(&mut input).expect("could not read input");
            input.trim().parse::<$t>().unwrap()
        };
    };
    ($($t: ty),*) => {
        {
            let mut input = String::new();
            io::stdin().read_line(&mut input).expect("could not read input");
            let mut iter = input.trim().split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap()), *)
        };
    }
}
#[allow(unused_macros)]
macro_rules! read_vec {
    ($t: ty) => {
        {
            let mut input = String::new();
            io::stdin().read_line(&mut input).expect("could not read input");
            let iter = input.trim().split_whitespace();
            iter.map(|x| x.parse::<$t>().unwrap()).collect::<Vec<$t>>()
        };
    }
}
#[allow(unused_macros)]
macro_rules! read_chars {
    () => {
        {
            let mut input = String::new();
            io::stdin().read_line(&mut input).expect("could not read input");
            input.trim().chars().collect::<Vec<char>>()
        };
    }
}

fn main() {
    let chars = read_chars!();
    println!("{}", chars.into_iter().filter(|&c| c == '1').count());
}

Measured memory_bytes: 4352
/* https://tenka1-2019-beginner.contest.atcoder.jp/tasks/tenka1_2019_b */

#include <iostream>
#include <vector>
#include <string>

using namespace std;

/* {{{ Variables */
int N, K;
string S;
/* }}} */

int main(int argc, char *argv[])
{
  /* {{{ Input */
  cin >> N >> S >> K;
  /* }}} */

  /* {{{ Output */
  char s = S.at(K-1);

  for (char e: S) {
    cout << (e == s ? s : '*');
  }
  cout << endl;
  /* }}} */

  return 0;
}


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

using namespace std;

#define reps(i,s,n) for(int (i) = (s); (i) < (n); (i)++)
#define rep(i,n) reps(i,0,n)

typedef long long ll;
typedef vector<int> vi;

ll mod = 1e9+7;

ll solve() {
    int n; cin >> n;
    ll sum = 0;
    sum += (n / 500) * 1000;
    n %= 500;
    sum += (n / 5) * 5;
    return sum;
}

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

	cout << solve() << endl;
}


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

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

int main(){
  int w,h,n;
  cin >> w >> h >> n;

  vector<vector<int>> black(4,vector<int>(0));
  rep(i,n){
    int x,y,a;
    cin >> x >> y >> a;

    a--;
    if(a==0||a==1) black.at(a).push_back(x);
    else black.at(a).push_back(y);
  }

  black.at(0).push_back(0);
  black.at(1).push_back(w);
  black.at(2).push_back(0);
  black.at(3).push_back(h);

  sort(black.at(0).rbegin(), black.at(0).rend());
  sort(black.at(1).begin(), black.at(1).end());
  sort(black.at(2).rbegin(), black.at(2).rend());
  sort(black.at(3).begin(), black.at(3).end());

  int max_x=black.at(0).at(0);
  int min_x=black.at(1).at(0);
  int max_y=black.at(2).at(0);
  int min_y=black.at(3).at(0);

  int whitex=max(0,min_x-max_x);
  int whitey=max(0,min_y-max_y);
  
  //cout << max_x << " " << min_x << " " << max_y << " " << min_y << endl;

  cout << whitex*whitey;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long int
using namespace std;

int main() {
    fast();
    // ll t;
    // cin>>t;
    // while(t--)			
    // {
        
    // }
    ll n;
    cin>>n;
    if(n%1000==0)
    cout<<0<<endl;
    else
    cout<<1000-n%1000<<endl;
    
}


Measured memory_bytes: 3612
# -*- coding: utf-8 -*-
n, x, y = map(int, input().split())
x -= 1
y -= 1
ans = [0]*n
for i in range(n):
    for j in range(i + 1, n):
        dist1 = j - i
        dist2 = abs(x - i) + abs(y - j) + 1
        ans[min(dist1, dist2)] += 1
print(*ans[1:], sep='\n')


Measured memory_bytes: 3444
n,x,m = map(int,input().split())
ans = x
b = x
box = [x]
c= 0
for i in range(1,n):
    b= (b**2)%m
    if b == 0:
        print(ans)
        exit() 
    if b in box:
        c = box.index(b)
        break
    ans += b
    box.append(b)
# print(c)
# print(sum(box)*(n//len(box)) + sum(box[0:n%len(box)]))


print(sum(box[:c])+sum(box[c:])*((n-c)//len(box[c:])) + sum(box[c:c+(n-c)%len(box[c:])]))


Measured memory_bytes: 69628
#include <iostream>
using namespace  std;
int main(){
	int a, b, c, d, e;
	cin >> a >> b >> c >> d >> e;
	if (a < 40){ a = 40; }
	if (b < 40){ b = 40; }
	if (c < 40){ c = 40; }
	if (d < 40){ d = 40; }
	if (e < 40){ e = 40; }
	cout << (a + b + c + d + e) / 5 << endl;
	return 0;
}

Measured memory_bytes: 3064
N = int(input())
A = list(map(int,input().split()))
A.sort(reverse=True)
out = 0
i = 0
t = 1
cnt = 1
while cnt<=N-1:
    if t==1:
        out += A[i]
        t *= -1
        i+=1
    elif t==-1:
        out += A[i]
        t*=-1
    cnt+=1
print(out)

Measured memory_bytes: 94188
#include<stdio.h>
#include<iostream>
#include<string>
#include<map>

using namespace std;

int main()
{
    int n,i,tmp,count=0;
    
    scanf("%d",&n);
    
    for(i=1;i<=n;i++)
    {
        scanf("%d",&tmp);
        if(tmp != i)
        {
            count++;
        }
    }
    
    if(count <= 2)
    {
        printf("YES\n");
    }
    else
    {
        printf("NO\n");
    }
    
    return 0;
}


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

int gcd(int a, int b)
{
    int c;

    if (a < b) {
        a+=b; b=a-b; a-=b;
    }

    while (b != 0) {
        c = a % b;
        a = b;
        b = c;
    }

    return a;
}

int main(void){
    int a, b;
    cin >> a >> b;
    cout << (a - 1) * (b - 1) << endl;
}

Measured memory_bytes: 256
SENTINEL = 10**9 + 1


def merge_sort(alist):
    """Sort alist using mergesort.
    Returns a tuple of the number of comparisons and sorted list.

    >>> merge_sort([8, 5, 9, 2, 6, 3, 7, 1, 10, 4])
    (34, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10])
    """
    def _sort(left, right):
        count = 0
        if left + 1 < right:
            mid = (left + right) // 2
            count += _sort(left, mid)
            count += _sort(mid, right)
            count += merge(left, mid, right)

        return count

    def merge(left, mid, right):
        count = 0
        ll = alist[left:mid] + [SENTINEL]
        rl = alist[mid:right] + [SENTINEL]

        i = j = 0
        for k in range(left, right):
            count += 1
            if ll[i] <= rl[j]:
                alist[k] = ll[i]
                i += 1
            else:
                alist[k] = rl[j]
                j += 1

        return count

    comp = _sort(0, len(alist))
    return (comp, alist)


def run():
    _ = int(input())  # flake8: noqa

    li = [int(i) for i in input().split()]

    (c, s) = merge_sort(li)
    print(" ".join([str(i) for i in s]))
    print(c)


if __name__ == '__main__':
    run()



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

class UnionFindTree {
private:
    vector<int> parent;
    vector<int> count;
public:
    UnionFindTree(int n) : parent(n), count(n, 1) {
        // 最初は全てを根として初期化
        for(int i = 0; i < n; i++) parent[i] = i;
    }

    int get_root(const int x) {
        // データxが属する木の根を取得する
        if (parent[x] == x) return x;
        // 取得したものは直接木の根をつなぐ(経路圧縮)
        return parent[x] = get_root(parent[x]);
    }

    void unite(const int x, const int y) {
        // xとyの木を併合する
        int rx = get_root(x);
        int ry = get_root(y);
        // 元から同じ木に属している場合は何もしない
        if (rx == ry) return;
        // xの属する木をyの属する木につける
        parent[rx] = ry;
        count[ry] += count[rx];
        count[rx] = 0;
    }

    bool is_same_root(const int x, const int y) {
        return get_root(x) == get_root(y);
    }

    int get_size(const int x) {
        return count[get_root(x)];
    }

    void print() {
        for(auto elm : parent) cout << elm << " ";
        cout << endl;
        for(auto elm : count) cout << elm << " ";
        cout << endl;
    }
};

int main(){
    int n, m, ans = 0; cin >> n >> m;
    UnionFindTree tree(n);
    for (auto i = 0; i < m; i++) {
        int a, b; cin >> a >> b;
        tree.unite(a - 1, b - 1);
    }
    for (auto i = 0; i < n; i++) ans = max(ans, tree.get_size(i));
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 10964
loop do
    n, m = gets.split.map(&:to_i)
    break if n == 0 && m == 0
    d = n.times.map{gets.split.map(&:to_i)}
    d.sort!{|a,b| b[1]<=>a[1]}
    ans = 0
    d.each do |dd|
        if m >= dd[0]
            m -= dd[0]
            dd[0] = 0
        else
            dd[0] -= m
            m = 0
        end
        ans += dd[0] * dd[1]
    end
    p ans
end

Measured memory_bytes: 6792
#include <iostream>
#include <bits/stdc++.h>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
   int n; cin>>n;
   int a,b,c;
   a=n/100;
   b=(n-a*100)/10;
   c=n-a*100-b*10;
   if(a==7 || b==7 ||c==7) cout<<"Yes"<<endl;
   else cout<<"No"<<endl;
   return 0;
}

Measured memory_bytes: 3604
#include<iostream>

using namespace std;

int main(){

  int n, k, b, f;
  int s[110], sum[110];

  while(cin>>n>>k,n){

    for(int i=0;i<k;i++){
      cin>>s[i];
      sum[i]=0;
    }

    for(int i=0;i<n;i++){
      for(int j=0;j<k;j++){
        cin>>b;
        sum[j]+=b;
      }
    }

    f=0;
    for(int i=0;i<k;i++){
      if(sum[i]>s[i]){
        f=1;
        break;
      }
    }

    if(f) cout<<"No"<<endl;
    else cout<<"Yes"<<endl;

  }

  
  return 0;
}

Measured memory_bytes: 3084
use std::io::*;
use std::str::FromStr;

fn main() {
    let n: usize = read();
    let a: Vec<char> = read::<String>().chars().collect();
    let b: Vec<char> = read::<String>().chars().collect();
    let c: Vec<char> = read::<String>().chars().collect();
    
    let mut ans = 0;
    for i in 0..n {
        ans += 
            if a[i] == b[i] && b[i] == c[i] { 0 }
            else if a[i] == b[i] || b[i] == c[i] || c[i] == a[i] {1}
            else {2};
    }
    println!("{}", ans);
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}


Measured memory_bytes: 4352
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);

    long X = scanner.nextLong();
    long Y = scanner.nextLong();

    if(solve(X, Y)) {
      System.out.println("Alice");
    } else {
      System.out.println("Brown");
    }
  }

  private static boolean solve(long x, long y) {
    if (x > y) return solve(y, x);
    if ((y - x) % 3 == 0) {
      return (y - x) != 0;
    }
    return (y - x) != 1;
  }
}


Measured memory_bytes: 21844
import java.util.Scanner;
import java.util.Locale;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;

public class Main {
  public static void main(String[] args ){

    Scanner sc = new Scanner(System.in);
    int D = sc.nextInt();

    String msg = "";
    switch (D) {
      case 22:
        msg = "Christmas Eve Eve Eve";
        break;
      case 23:
        msg = "Christmas Eve Eve";
        break;
      case 24:
        msg = "Christmas Eve";
        break;
      case 25:
        msg = "Christmas";
        break;
    }

    System.out.println(msg);
  }
}


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

using namespace std;

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

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

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#define each(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define exist(s,e) ((s).find(e)!=(s).end())
#define range(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  range(i,0,n)
#define clr(a,b) memset((a), (b) ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double eps = 1e-10;
const double pi  = acos(-1.0);
const ll INF =1LL << 62;
const int inf =1 << 29;

int n;
string s;
size_t cur;

ll calc(ll a,ll b,char op){
	if(op=='+')
		return a+b;
	if(op=='-')
		return a-b;
	if(op=='*')
		return a*b;
	return 0;
}

ll digit(){
	return s[cur++]-'0';
}

ll number(){
	ll res=digit();
	while(isdigit(s[cur])) res=res*10+digit();
	return res;
}

ll expr1();
ll expr2();
ll expr3();
ll factor();

ll factor(){
	ll res=0;
	if(s[cur]=='('){
		cur++;
		res=expr1();
		cur++;
		return res;
	}else{
		res=number();
		return res;
	}
}

int op[3];

ll expr1(){
	ll res=expr2();
	bool update=true;
	while(cur<n&&update){
		update=false;
		if(op[0]==0&&s[cur]=='+'){
			cur++,update=true;
			ll b=expr2();
			res=calc(res,b,'+');
		}
		if(op[1]==0&&s[cur]=='-'){
			cur++,update=true;
			ll b=expr2();
			res=calc(res,b,'-');
		}
		if(op[2]==0&&s[cur]=='*'){
			cur++,update=true;
			ll b=expr2();
			res=calc(res,b,'*');
		}
		if(s[cur]==')')
			return res;
	}
	return res;
}

ll expr2(){
	ll res=expr3();
	bool update=true;
	while(cur<n&&update){
		update=false;
		if(op[0]==1&&s[cur]=='+'){
			cur++,update=true;
			ll b=expr3();
			res=calc(res,b,'+');
		}
		if(op[1]==1&&s[cur]=='-'){
			cur++,update=true;
			ll b=expr3();
			res=calc(res,b,'-');
		}
		if(op[2]==1&&s[cur]=='*'){
			cur++,update=true;
			ll b=expr3();
			res=calc(res,b,'*');
		}
		if(s[cur]==')')
			return res;
	}
	return res;
}

ll expr3(){
	ll res=factor();
	bool update=true;
	while(cur<n&&update){
		update=false;
		if(op[0]==2&&s[cur]=='+'){
			cur++,update=true;
			ll b=factor();
			res=calc(res,b,'+');
		}
		if(op[1]==2&&s[cur]=='-'){
			cur++,update=true;
			ll b=factor();
			res=calc(res,b,'-');
		}
		if(op[2]==2&&s[cur]=='*'){
			cur++,update=true;
			ll b=factor();
			res=calc(res,b,'*');
		}
	}
	return res;
}


int main(void){
	cin >> s;
	n=s.size();

	cur=0;
	ll ans=expr1();
	rep(i,3)rep(j,3)rep(k,3){
		op[0]=i,op[1]=j,op[2]=k;
		cur=0;
		ans=max(ans,expr1());
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod =(1e9)+7;
using P = pair<ll,ll>;

int main(){
    ll n;cin >>n;
    vector<ll>dp(n+1,INF);
    dp[1]=1;dp[0]=0;
    vector<ll>yen;
    yen.push_back(1);
    ll k=6;
    while(k<=n){
        yen.push_back(k);
        k*=6;
    }
    k=9;
    while(k<=n){
        yen.push_back(k);
        k*=9;
    }
    for (int i = 0; i < n; ++i) {
        for(auto u:yen){
            if(i+u>n)continue;
            dp[i+u]=min(dp[i+u],dp[i]+1);
        }
    }
    cout <<dp[n]<<endl;
    return 0;
}

Measured memory_bytes: 1024
import java.util.*;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		char[] s = sc.next().toCharArray();
		char[] t = sc.next().toCharArray();
		Arrays.sort(s);
		Arrays.sort(t);
		
		int ans = new String(s).compareTo(new StringBuilder(new String(t)).reverse().toString());
    System.out.println(ans < 0 ? "Yes" : "No");
	}
}

Measured memory_bytes: 21844
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<string>
#include<cstring>
#include<algorithm>
#include<functional>
#include<vector>
#include<map>

using namespace std;
#define endl '\n'
#define pb push_back
#define fst first
#define scd second
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define REP(i,n) for(int i = 0;i < (n);i++)
#define FOR(i,a,b) for(int i = (a);i <= (b);i++)
#define YES(n) cout << ((n) ? "YES" : "NO" ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No" ) << endl

constexpr int MOD = 1000000007;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vector<int>> vii;

template <class T = int> T in() { T x; cin >> x; return (x); }
template <class T = int> void out(T x) { cout << (x) << endl; }

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

ll bpow(int n) {
	ll x = 1;
	for (int i = 1; i <= n; i++) {
		x *= 2;
	}
	return x;
}

void solve() {

	int N, T;

	cin >> N >> T;

	int min = 10000;
	bool f = false;

	vi c(N), t(N);
	REP(i, N) {
		cin >> c[i] >> t[i];
		if (t[i] <= T) {
			f = true;
			if (min > c[i]) min = c[i];
		}
	}

	if(f)out(min);
	else out<string>("TLE");

	return;

}

int main() {

	cin.tie(0);
	ios::sync_with_stdio(false);

	solve();

	return 0;

}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<string>
#include<set>
#include<map>
#include<vector>
#include<deque>
#include<tuple>
#include<algorithm>
#include<numeric>
#include<limits>
#include<boost/multiprecision/cpp_int.hpp>
using namespace boost::multiprecision;
using namespace std;
#define BEGIN ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define END return EXIT_SUCCESS
#define rep(I,N) for(auto I=0;I<(N);++I)
#define up(I,A,B) for(auto I=(A);I<=(B);++I)
#define dw(I,A,B) for(auto I=(A);I>=(B);--I)
#define all(C) (C).begin(),(C).end()
#define rall(C) (C).rbegin(),(C).rend()
#define ft first
#define sd second
#define mp make_pair
#define mt make_tuple
#define pf push_front
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define rs resize
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
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;}
template<class T>inline void                                      in(T &p){cin>>p;}
template<class T1,class T2>inline void                            in(T1 &p1,T2 &p2){cin>>p1>>p2;}
template<class T1,class T2,class T3>inline void                   in(T1 &p1,T2 &p2,T3 &p3){cin>>p1>>p2>>p3;}
template<class T1,class T2,class T3,class T4>inline void          in(T1 &p1,T2 &p2,T3 &p3,T4 &p4){cin>>p1>>p2>>p3>>p4;}
template<class T1,class T2,class T3,class T4,class T5>inline void in(T1 &p1,T2 &p2,T3 &p3,T4 &p4,T5 &p5){cin>>p1>>p2>>p3>>p4>>p5;}
template<class T>inline void                                      ins(T &p){for_each(all(p),in<decltype(p[0])>);}
template<class T>inline void                             out(T p){cout<<p<<endl;}
template<class T1,class T2>inline void                   out(T1 p1,T2 p2){cout<<p1<<" "<<p2<<endl;}
template<class T1,class T2,class T3>inline void          out(T1 p1,T2 p2,T3 p3){cout<<p1<<" "<<p2<<" "<<p3<<endl;}
template<class T1,class T2,class T3,class T4>inline void out(T1 p1,T2 p2,T3 p3,T4 p4){cout<<p1<<" "<<p2<<" "<<p3<<" "<<p4<<endl;}
inline                                              void out(double p){printf("%.10f\n",p);}
template<class T>inline                             void outs(T p){for_each(all(p),out<decltype(p[0])>);}
template<class T>inline void outs(vector<T> V){int n=V.size();rep(i,n)cout<<V[i]<<" \n"[i==n-1];}
vector<long>r;
void rec(long n,long d,long l){
  if(l==11)return;
  for(int i=max(d-1,0L);i<=min(d+1,9L);i++){
    long t=n;
    t*=10;
    t+=i;
    r.pb(t);
    rec(t,i,l+1);
  }
}
inline void solve(void){
  int K;in(K);
  up(i,1,9){
    r.pb(i);
    rec(i,i,2);
  }
  sort(all(r));
  out(r[K-1]);
}
int main(int argc,char**argv){
  BEGIN;
  solve();
  END;
}


Measured memory_bytes: 3444
#include <cassert>
#include <cstdio>
#include <functional>
#include <queue>
#include <set>
#include <vector>
#define repeat(i, n) for (int i = 0; (i) < int(n); ++(i))
using namespace std;

int main() {
    // input
    int n, k; scanf("%d%d", &n, &k);
    vector<int> a(n);
    repeat (i, n) {
        scanf("%d", &a[i]);
        -- a[i];
    }

    // solve

    // // make the graphs
    int result = 0;
    if (a[0] != 0) {
        a[0] = 0;  // make the graph a tree
        ++ result;
    }
    vector<set<int> > b(n);  // backward digraph
    repeat (i, n) {
        b[a[i]].insert(i);
    }

    // // define things
    vector<int> valid(n, -1);
    function<void (int, int)> mark_valid = [&](int i, int limit) {
        if (valid[i] >= limit) return;
        valid[i] = limit;
        if (limit) {
            for (int j : b[i]) if (j != i) {
                mark_valid(j, limit - 1);
            }
        }
    };
    vector<int> depth(n, -1); {
        function<void (int)> go = [&](int i) {
            for (int j : b[i]) if (j != i) {
                depth[j] = depth[i] + 1;
                go(j);
            }
        };
        depth[0] = 0;
        go(0);  // connectivity is assumed
    }
    vector<bool> is_leaf(n);
    priority_queue<pair<int, int> > leaves;
    function<void (int)> update_leaf = [&](int i) {
        if (i == 0) return;
        if (not b[i].empty()) return;
        if (is_leaf[i]) return;
        is_leaf[i] = true;
        leaves.emplace(depth[i], i);
    };
    auto relink = [&](int i) {
        if (a[i] == 0) return;
        int a_i = a[i];
        ++ result;
        b[a[i]].erase(i);
        a[i] = 0;
        b[0].insert(i);
        mark_valid(i, k - 1);
        update_leaf(a_i);
    };
    auto k1th_parent = [&](int i) {
        repeat (iteration, k - 1) {
            i = a[i];
            if (i == 0) break;
        }
        return i;
    };

    // // run
    mark_valid(0, k);
    repeat (i, n) {
        update_leaf(i);
    }
    while (not leaves.empty()) {
        int i = leaves.top().second;
        leaves.pop();
        if (valid[i] == -1) {
            int j = k1th_parent(i);
            relink(j);
        }
        assert (valid[i] != -1);
    }

    // output
    printf("%d\n", result);
    return 0;
}


Measured memory_bytes: 17024
// AOJ ITP2_9_B Set Intersection
// 2019.3.8 bal4u

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#if 1
#define gc() getchar_unlocked()
#define pc(c) putchar_unlocked(c)
#else
#define gc() getchar()
#define pc(c) putchar(c)
#endif

int in()   // 非負整数の入力
{
	int n = 0, c = gc();
	do n = 10 * n + (c & 0xf), c = gc(); while (c >= '0');
	return n;
}

void out(int n)    // 非負整数の表示　最後に改行あり
{
	int i;
	char ob[20];

	if (!n) pc('0');
	else {
		//		if (n < 0) pc('-'), n = -n;
		i = 0; while (n) ob[i++] = n % 10 + '0', n /= 10;
		while (i--) pc(ob[i]);
	}
	pc('\n');
}

#define INF 1000000001
int n, m;
int a[200002], b[200002];

int main()
{
	int i, j;

	n = in();
	for (i = 0; i < n; i++) a[i] = in();
	a[i] = INF;
	m = in();
	for (j = 0; j < m; j++) b[j] = in();
	b[j] = INF;
	i = j = 0; while (1) {
		while (a[i] < b[j]) i++;
		while (b[j] < a[i]) j++;
		if (a[i] == INF) break;
		if (a[i] == b[j]) out(a[i++]), j++;
	}
	return 0;
}


Measured memory_bytes: 3084
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define all(n)      (n).begin(), (n).end()
#define ll long long

void solve() {
	int n, w; cin >> n >> w;
	if (w >= n) {
		cout << "unsafe" << endl;
	} else {
		cout << "safe" << endl;
	}


}


int main () {

	ios::sync_with_stdio(0);
	cin.tie(0);
	//Write from here.
	solve();

	return 0;
}

Measured memory_bytes: 3648
import java.io.File;
import java.io.FileInputStream;
import java.util.Scanner;
import java.util.Map.Entry;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.Deque;
import java.util.HashMap;
import java.util.List;
import java.util.NoSuchElementException;
import java.util.PriorityQueue;

public class Main {
	
	public static void main(String[] args) throws IOException {
		FastScanner sc = new FastScanner(System.in);
		
		int X = sc.nextInt();
		int Y = sc.nextInt();
		if(X % Y == 0) System.out.println(-1);
		else System.out.println(X);
	}
}

class FastScanner {
    private InputStream in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    public FastScanner(InputStream in) {
		this.in = in;
	}
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() {
    	if (hasNextByte()) return buffer[ptr++];
    	else return -1;
    }
    private static boolean isPrintableChar(int c){
    	return 33 <= c && c <= 126;
    }
    public boolean hasNext() {
    	while(hasNextByte() && !isPrintableChar(buffer[ptr]))
    		ptr++; return hasNextByte();
    }
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() {
    	return Double.parseDouble(next());
    }
}

Measured memory_bytes: 21972
import sys
sys.setrecursionlimit(10**9)
import time

t1 = time.time()

x,y = map(int,input().split())
kyori = x+y
if kyori % 3 !=0:
    print(0)
    exit()
    
mod = 10**9+7

nagasa = kyori // 3
dif = x - y

n_x = (nagasa + dif) // 2
n_y = nagasa - n_x

#print(nagasa,n_x,n_y)

if x != n_x * 2 + n_y * 1 or y != n_x * 1+ n_y*2:
    print(0)
    exit()

if n_x < 0 or n_y < 0:
    print(0)
    exit()
#H, W, A, B = map(int, raw_input().split())

def kj(n, x,y, mod):
    #if ( r<0 or r>n ):
     #   return 0
    #r = min(r, n-r)
    return g1[n] * g2[x] * g2[y] % mod

g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

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


a = kj(nagasa,n_x,n_y,mod)
print(a)

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

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

int N,K;
ll mo;
ll from[155][155][155];
ll to[155][155][155];

ll hoge(int N) {
	ll from[151]={};
	ll to[151];
	
	from[0]=1;
	int i,j;
	FOR(i,N) {
		ZERO(to);
		FOR(j,K+1) {
			(to[0]+=from[j])%=mo;
			if(j+1<=K) (to[j+1]+=from[j])%=mo;
		}
		
		swap(from,to);
	}
	
	ll ret=0;
	FOR(i,N+1) ret+=from[i];
	return ret%mo;
}

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>K>>mo;
	
	if(K%2==0) {
		K/=2;
		cout<<hoge(N/2)*hoge((N+1)/2)%mo<<endl;
	}
	else {
		from[0][1][154]=1;
		for(i=2;i<=N+1;i++) {
			ZERO(to);
			
			int a,b;
			for(a=0;a<i;a+=2) for(b=1;b<i;b+=2) for(j=max(a,b);j<=154;j++) if(from[a][b][j]) {
				ll v=from[a][b][j];
				//cout<<i<<" "<<a<<" "<<b<<" "<<j<<" "<<v<<endl;
				int nex;
				if(i%2==0) {
					// keep
					nex=j;
					if(b+2+K>=i) nex=154;
					(to[i][b][nex]+=v)%=mo;
					
					// remove
					if(i==j) continue;
					if(b+2<=i-K&&a+2+K<i) continue;
					nex=j;
					if(b==i-1) nex=j;
					else if(a==i-2) nex=min({154,j,i+K});
					(to[a][b][nex]+=v)%=mo;
				}
				else {
					// keep
					nex=j;
					if(a+2+K>=i) nex=154;
					(to[a][i][nex]+=v)%=mo;
					
					// remove
					if(i==j) continue;
					if(a+2<=i-K&&b+2+K<i) continue;
					nex=j;
					if(a==i-1) nex=j;
					else if(b==i-2) nex=min({154,j,i+K});
					(to[a][b][nex]+=v)%=mo;
				}
			
			}
			swap(from,to);
		}
		
		ll ret=0;
		FOR(x,155) FOR(y,155) FOR(j,155) ret+=from[x][y][j];
		cout<<ret%mo<<endl;
	}
}


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


Measured memory_bytes: 58496
import sys
x = [int(c) for c in input()]

d = {
    1: "+",
    -1: "-"
}
for op1 in [1, -1]:
    for op2 in [1, -1]:
        for op3 in [1, -1]:
            if x[0] + op1 * x[1] + op2 * x[2] + op3 * x[3] == 7:
                print(str(x[0]) + d[op1]+str(x[1]) +d[op2]+str(x[2])+d[op3]+str(x[3])+"=7")
                sys.exit()


Measured memory_bytes: 38384
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
#define pb push_back
#define pii pair < int, int >
#define F first
#define S second
#define int  long long int
#define sync ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#pragma GCC optimize ("Ofast")
#pragma GCC optimize ("unroll-loops")
using namespace std;
/// khodaya komak kon

/// ba z_func hatman dafe baad bezan

int32_t main(){
    ll ans=0;
    ll t=0;
    ll n;
    cin >> n;
    for (int i=1;i<1e6;i++){
        t+=i;
        ans++;
        if (t>=n){
            cout << ans << endl;
            return 0;
        }

    }
}


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

#define ln '\n'
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, a, b) for(int i = (a); i <= (int)(b); ++i)
#define FORR(i, a, b) for(int i = (a); i >= (int)(b); --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
typedef vector<P> VP;
typedef vector<PL> VPL;


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, h, w;
    cin >> n >> h >> w;
    cout << (n - h + 1) * (n - w + 1) << endl;
    return 0;
}


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

string s;

int main()
{
    cin >> s;
    int ans = 0;
    for (int i=0; i<s.size(); i++)
    {
        if ((i & 1) && (s[i] == 'g')) ans++;
        else if (!(i & 1) && (s[i] == 'p')) ans--;
    }
    cout << ans << endl;
}


Measured memory_bytes: 512
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var str = string.Join("", Console.ReadLine().Split().Reverse());

            Console.WriteLine(str);
        }
    }
}


Measured memory_bytes: 11220
n = int(input())
memo = [0]*87
def f(i):
    if memo[i]:
        return memo[i]
    if i==0:
        return 2
    elif i==1:
        return 1
    else:
        memo[i] = f(i-1)+f(i-2)
        return memo[i]
print(f(n))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
 
using namespace std;
typedef long long int lli;
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
typedef pair <lli,lli> pii;
#define ff first
#define ss second
#define MOD 1000000007
#define pb push_back
#define EPS 1e-6
 
 
 
int main(){
	fast;
	int n;
	cin>>n;
	vector<int> a(n);
	vector<int> c(n-1);
	int x;
	int sum=0, csum=0;
	for(int i=0; i<n; i++){ cin>>a[i];}
	for(int i=0; i<n; i++){ cin>>x; sum+=x;}
	for(int i=0; i<n-1; i++){ cin>>c[i]; }
	for(int i=0; i<n-1; i++){
	    if(a[i+1]==a[i]+1) sum+=c[a[i]-1];
	}
	cout<<sum;
	return 0;
}

Measured memory_bytes: 256
N, Y = map(int, input().split())
Y = Y // 1000

for y10 in range(0, N + 1):
    remain = N - y10
    if y10 * 10 > Y:
        break
    for y5 in range(0, remain + 1):
        y1 = N - y10 - y5
        t = y1 + y5 * 5 + y10 * 10
        if t == Y:
            print(y10, y5, y1)
            exit()
print(-1, -1, -1)


Measured memory_bytes: 3060
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>
  
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
  
using namespace std;
  
typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;
  
const int INF=1<<29;
const double EPS=1e-9;
  
const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};


int main() {
    string s;
    cin >> s;
    int ans = 0;
    for (int i = 0; i < s.size(); i++) {
        if (s[i] == '1') ans++; 
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
N, K = map(int, input().split())

agent = [False] * (N+1)
agent[0] = True
for _ in range(K):
    _ = input()
    A = list(map(int, input().split()))
    for a in A:
        agent[a] = True

# print(agent)

print(len(list(filter(lambda x: not x, agent))))


Measured memory_bytes: 9188
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int W = sc.nextInt();
		int H = sc.nextInt();
		int x = sc.nextInt();
		int y = sc.nextInt();
		int r = sc.nextInt();
		if(W >= x + r && H >= y + r && x > 0 && y > 0) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 26020
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
int main()
{
    int N;
    cin >> N;
    ll ans = 0, sum = 0;
    rep(i, N) {
        int A;
        cin >> A;
        if (A != 0) {
            sum += A;
        }
        else {
            ans += sum / 2;
            sum = 0;
        }
    }

    cout << ans + sum / 2 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <iostream>
using namespace std;
long long int a, b, i, j, k,  n, m;
int str[100005];
int main() {
	scanf("%lld", &n);
	cout << n * (n-1) / 2;
	return 0;
}

Measured memory_bytes: 256
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


n = int(input())
s = input()
from collections import Counter
c = Counter(s)
M = 10**9+7
ans = 1
for k,v in c.items():
    ans *= (v+1)
    ans %= M
ans -= 1
print(ans%M)

Measured memory_bytes: 73676
#include<bits/stdc++.h>
using namespace std; 
#define MOD 1000000007
#define f(i, n) for(ll i=0; i < (n); i++)
typedef long long int ll;
typedef vector<ll> llvec;
typedef vector<double> dvec;
typedef pair<int, int> P;
const ll mk = 1e5 ; 
int main(){
  int N , M ; cin >> N >> M ;
  vector<vector<P> > v(N);
  vector<ll> cost(N, 1e18);
  f(i,N-2){
    v[i+2].push_back(make_pair(i+1, 0));
  }
  f(i, M){
    ll l, r, c;
    cin >> l >> r >> c;
    l--;r--;
    v[l].push_back(make_pair(r,c));
  }
  
  cost[0]=0;
  priority_queue<P, vector<P>, greater<P> > Queue;
  llvec check(N, 0);
  Queue.push(make_pair(0, 0));
  while(!Queue.empty()){
    P p =Queue.top();
    Queue.pop();
    ll from = p.second;
    
    if(check[from]!=0)continue;
    check[from]=1;
    ll vnum = v[from].size();
    f(i, vnum){
      ll to = v[from][i].first;
      ll c = v[from][i].second;
      if(cost[to]>cost[from]+c){
        cost[to]=cost[from]+c;
        Queue.push(make_pair(cost[to], to));
      }
    }
  }
  
  cout << (cost[N-1]==1e18?-1:cost[N-1]);
  
  return 0;
}

Measured memory_bytes: 8700
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const ll INF = 1LL << 62;
const int inf = 1 << 30;
const ll MOD = 1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b, const ll mod=MOD) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b, const ll mod=MOD) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b, const ll mod=MOD) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b, const ll mod=MOD) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);

    string a, b, c; cin >> a >> b >> c;
    string res = {a[0], b[0], c[0]};
    for(auto& e : res){
        e = 'A' + e - 'a';
    }
    cout << res << endl;

    return 0;
}


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

int main()
{
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	
	if((a+b)>(c+d))
		cout<<"Left\n";
	else if((a+b)<(c+d))
		cout<<"Right\n";
	else
		cout<<"Balanced\n";
	
	return 0; 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INFLL (1LL<<62) // 9223372036854775807
#define EPS 1e-9
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
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; }
using namespace std;

struct Edge{
    long long src, dst, weight, capacity;
    Edge(): src(0), dst(0), weight(0), capacity(0) {}
    Edge(long long s, long long d, long long w): src(s), dst(d), weight(w) {}
    Edge(long long s, long long d, long long w, long long c): src(s), dst(d), weight(w), capacity(c) {}
};

class Graph{
public:
    long long size;
    vector<vector<Edge>> node;
    Graph(long long n): size(n), node(n) {}
    void addEdge(long long s, long long d, long long w = 1){
        node[s].emplace_back(s, d, w);
        node[d].emplace_back(d, s, w);
    }
};

ll bfs(Graph &g, ll sn, ll n){
    vi num(n, 0);
    queue<ll> que;
    que.push(sn);
    num[sn] = 1;
    ll maxVertex = -1;
    // その時点での頂点から直接到達可能な頂点に+1の番号を振る
    // 矛盾が生じた時点で-1を返す
    while(que.size()){
        auto node = que.front();
        que.pop();
        for(auto &edge: g.node[node]){
            // 未訪問なら
            if(num[edge.dst] == 0){
                num[edge.dst] = num[node] + 1;
                que.push(edge.dst);
                chmax(maxVertex, num[edge.dst]);
            }
            // 既に追加済みなら
            else{
                // 隣接部分と集合番号が一致したら矛盾
                if(num[edge.dst] == num[node]) return -1;
            }
        }
    }
    return maxVertex;
}

int main(){
    Init();
    ll n;
    cin >> n;
    Graph g(n);
    vector<string> s(n);
    rep(i, n){
        // 隣接リストの入力
        cin >> s[i];
        // 次数のカウントと辺の追加
        ll cnt = 0;
        rep(j, n){
            if(s[i][j] == '0') continue;
            cnt++;
            if(j <= i) continue;
            g.addEdge(i, j, 1);
        }
    }
    ll ans = -2;
    for(ll i=0; i<n; i++) chmax(ans, bfs(g, i, n));
    cout << ans << endl;
}

Measured memory_bytes: 4920
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef long  l;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
const int INF=1000000001;
const double PI=3.141592653589;
const ll LMAX=1000000000000001;
ll gcd(ll a,ll b){if(a<b)swap(a,b);while((a%b)!=0){a=b;b=a%b;}return b;}
int dx[]={-1,0,1,0};
int dy[]={0,1,0,-1};



int main(){
  string a,b; cin>>a>>b;
  if(a.size()==b.size()){
    if(a>b)
    puts("GREATER");
    else if(a<b)
    puts("LESS");
    else
    puts("EQUAL");
  }else if(a.size()>b.size())
  puts("GREATER");
  else
  puts("LESS");


  return 0;
}


Measured memory_bytes: 256
input_data = input().split(" ")
a, b, x = int(input_data[0]), int(input_data[1]), int(input_data[2])
def check(A, B, X):
    if (A > X) or (A+B < X):
        return print("NO")
    inb_cat = X - A
    if inb_cat > B:
        return print("NO")

    else:
        return print("YES")


check(a, b, x)


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

#define BR "\n"
#define SP " "

int main() {
  int S, h , m,  s;
  cin >> S;
  s = S % 60;
  m = (S / 60) % 60;
  h = S / 3600;
  cout << h << ":" << m << ":" << s << BR;
  return 0;
}


Measured memory_bytes: 3100