akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using static MyIO;

namespace atcoder
{
    class Program
    {
        static void Main(string[] args)
        {

            int N = GetInt();
            int M = GetInt();
            int X = GetInt();
            int[,] C = new int[12,13];

            int[] target = new int[12];

            for(int i=0;i<N; i++)
            {
                for(int j = 0; j <= M; j++)
                {
                    C[i, j] = GetInt();
                    if (j != 0)
                    {
                        target[j-1] += C[i, j];
                    }
                    
                }
            }

            bool isOK = true ;

            for(int i = 0; i < M; i++)
            {
                if (target[i] < X)
                {
                    isOK = false;
                }
            }

            if (!isOK)
            {
                Console.WriteLine(-1);
                return;
            }

            long cost = 0;
            long minCost = 2000000;

            for (int i = 0; i < (1 << N); i++)
            {
                cost = 0;
                target = new int[12];
                isOK = true;

                for (int j = 0; j < N; j++)
                {
                    if ((i >> j & 1) == 1) 
                    {
                        cost += C[j, 0];
                        for(int k = 0; k < M; k++)
                        {
                            target[k] += C[j, k+1];
                        }
                    }
                }

                for (int l = 0; l < M; l++)
                {
                    if (target[l] < X)
                    {
                        isOK = false;
                    }
                }

                if(isOK && cost <= minCost)
                {
                    minCost = cost;
                }

            }

            Console.WriteLine(minCost);
            
            return;
        }
    }
}


public static class MyIO
{
    private static string[] args = null;
    private static int num = -1;
    private static int used = -1;

    private static string getArg()
    {
        if (used == num)
        {
            args = Console.ReadLine().Split(' ');
            num = args.Length;
            used = 0;
        }
        return args[used++];
    }

    public static int GetInt() => int.Parse(getArg());
    public static long GetLong() => long.Parse(getArg());
    public static double GetDouble() => double.Parse(getArg());
    public static string GetString() => getArg();
    public static char GetChar() => getArg()[0];
    public static int[] GetInts(int N) => Enumerable.Range(0, N).Select(_ => GetInt()).ToArray();
    public static long[] GetLongs(int N) => Enumerable.Range(0, N).Select(_ => GetLong()).ToArray();
    public static double[] GetDoubles(int N) => Enumerable.Range(0, N).Select(_ => GetDouble()).ToArray();
    public static string[] GetStrings(int N) => Enumerable.Range(0, N).Select(_ => GetString()).ToArray();
}

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

public static class Bits
{
    public static int PopCount(this int bits)
    {
        bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
        bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
        bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
        bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
        return (bits & 0x0000ffff) + (bits >> 16 & 0x0000ffff);
    }
}

public class Solution
{
    public static int PopCount(string str)
    {
        return str.Count(c => c == '1');
    }

    public static int CalcF(int n)
    {
        var count = 1;
        while (n > 0)
        {
            n %= n.PopCount();
            count++;
        }
        return count;
    }

    public static void Main()
    {
        var N = int.Parse(Console.ReadLine());
        var X = Console.ReadLine();

        var pop = PopCount(X);
        var modA = pop + 1;
        var modB = pop - 1;
        if (modA == 0)
        {
            modA = 1;
        }
        if (modB == 0)
        {
            modB = 1;
        }

        int NA = 0;
        int NB = 0;
        foreach (var c in X)
        {
            NA *= 2;
            NB *= 2;
            if (c == '1')
            {
                NA++;
                NB++;
            }
            NA %= modA;
            NB %= modB;
        }
        var basisA = new int[N];
        var basisB = new int[N];
        int tA = 1;
        int tB = 1;
        for (int i = N - 1; i >= 0; i--)
        {
            basisA[i] = tA;
            basisB[i] = tB;
            tA = (tA * 2) % modA;
            tB = (tB * 2) % modB;
        }

        var answers = new int[N];
        for (int i = 0; i < N; i++)
        {
            var sign = X[i] == '0' ? 1 : -1;
            var p = pop + sign;
            if (p == 0)
            {
                answers[i] = 0;
            }
            else if (p == modA)
            {
                answers[i] = CalcF((NA + basisA[i] * sign) % p);
            }
            else if (p == modB)
            {
                answers[i] = CalcF((NB + basisB[i] * sign + p) % p);
            }
        }

        Console.WriteLine(string.Join(Environment.NewLine, answers));
    }
}

Measured memory_bytes: 32384
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;

vector<ll> divisor(ll n){
    vector<ll> ret;
    for(ll i = 1; i*i <=n; i++){
        if(n % i == 0) {
            ret.push_back(i);
            if(i != n/i) ret.push_back(n/i);
        }
    }
    
    return ret;
}

int main(void){
    // Your code here!
    ll N;
    cin >> N;
    vector<ll> d = divisor(N);
    ll ans = 0;
    for(int i = 0; i < d.size(); i++){
        if(d[i] == 1) continue;
        ll m = d[i]-1;
        ll x = N/m;
        if(x <= m) ans += m;
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define INF 1000000007

using namespace std;

const int MAX_N = 100005;

int l[MAX_N],r[MAX_N];

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n){
        cin >> a[i];
    }
    int ans = 0;
    rep(i,n){
        if(a[i] < 0){
            if(i){
                l[i] = min(max(0,l[i-1]-1),-a[i]);
            }else{
                l[0] = 0;
            }
        }else if(a[i] > 0){
            if(i){
                l[i] = max(l[i-1]-1,0);
            }else{
                l[0] = 0;
            }
        }else{
            l[i] = INF;
        }
    }
    for(int i=n-1;i>=0;i--){
        if(a[i] < 0){
            if(i < n-1){
                r[i] = min(max(0,r[i+1]-1),-a[i]);
            }else{
                r[n-1] = 0;
            }
        }else if(a[i] > 0){
            if(i < n-1){
                r[i] = max(0,r[i+1]-1);
            }else{
                r[n-1] = 0;
            }
        }else{
            r[i] = INF;
        }
    }
    rep(i,n){
        if(a[i] > 0) ans += min(a[i],max(l[i],r[i]));
    }
    cout << ans << "\n";
}



Measured memory_bytes: 3896
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<map>
#include<stack>
#include<cmath>
#include<iomanip>
#include<set>
#include<numeric>
#include<sstream>
#include<random>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, st, n) for (int i = st; i < n; ++i)
using pii = pair<int, int>;
const int inf = 1e9 + 7;
int dy[] = {0, 0, -1, 1, -1, 1, -1, 1};
int dx[] = {1, -1, 0, 0, -1, 1, 1, -1};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s; cin >> s;
    int a[3] = {0};
    rep(i, s.size()) {
        a[s[i] - 'a']++;
    }
    rep(i, 3) {
        if (a[i] == 0) break;
        if (i == 2) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}


Measured memory_bytes: 256
//a
#include <iostream>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <memory>
#include <functional>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>

#define REP(i,b,n) for(int i=b;i<n;i++)
#define REPR(i,b,n) for(int i=n-1;i>=b;i--)
#define CLR(mat) memset(mat, 0, sizeof(mat))
#define NCLR(mat) memset(mat, -1, sizeof(mat))
#define ALL(c) (c).begin(), (c).end()
#define RALL(c) (c).rbegin(), (c).rend()
#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 BIT(n, b) ((n>>b) & 1)
#define PB push_back
#define MP make_pair

using namespace std;

static const double PI = acos(-1.0);
static const double EPS = 1e-9;
typedef long long ll;
typedef pair<int, int> pii;



int main(){
	
	string s;
	
	cin>>s;
	
	int i=0, j=s.size()-1, cnt = 0;
	
	while(i<j){
		
		if( !((s[i]=='w'||s[i]=='i') && s[i]==s[j] 
			 || s[i]=='(' && s[j]==')'
			 || s[i]==')' && s[j]== '(' ) ){
			
			cnt++;
		}
		
		i++; j--;
	}
	
	if(s.size()%2 && s[s.size()/2] != 'w' && s[s.size()/2] != 'i'){
		cnt++;
	}
	
	cout << cnt << endl;
	
	return 0;
}

Measured memory_bytes: 1180
import sys

N, T = sys.stdin.readline().rstrip().split()
t_list = sys.stdin.readline().rstrip().split()

N = int(N)
T = int(T)
t_list = [int(x) for x in t_list]

t_old = t_list[0]
t_sum = T
for t in t_list:
    t_diff = t - t_old

    if t_diff >= T:
        t_sum += T
    else:
        t_sum += t_diff

    t_old = t

print(t_sum)


Measured memory_bytes: 26708
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,count,j=1;
  cin >> N;
  vector<int> in(N);
  for(int i=0;i<N;i++) cin >> in[i];
  for(;;){
    j = in[j-1];
    count++;
    if(j==2){
      cout << count << endl;
      break;
    }
    else if(count==N){
      cout << -1 << endl;
      break;
    }
  }
}

Measured memory_bytes: 640
'use strict'

function main(s) {
  s = s.split('\n');
  
  const a = Number(s[0].split(' ')[0]);
  const b = Number(s[0].split(' ')[1]);
  const zip = s[1].split('-');
  const ans = zip.length === 2 && zip[0].length === a && zip[1].length === b;

  console.log(ans ? 'Yes' : 'No');
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7372
program main
    implicit none
    integer(8)::A(6)=(/1,0,0,1,1,1/),a_count=0,flg=1,cur=1,i
    character(50)::S,T="KIHBR"
    read*,S
    if(len_trim(S)>9)flg=0
    do i=1,len_trim(S)
        if(S(i:i)=="A")then
            a_count=a_count+1
        else if(S(i:i)==T(cur:cur))then
            if(a_count>A(cur))then
                flg=0
                exit
            else
                a_count=0
                cur=cur+1
            end if
        else
            flg=0
            exit
        end if
    end do
    if(flg==1.and.a_count>A(6))flg=0
    if(flg==1.and.cur<6)flg=0
    if(flg==1)print'(A)',"YES"
    if(flg==0)print'(A)',"NO"
end program main

Measured memory_bytes: 2884
main = do
  cont <- getContents
  let [a, b] = map read $ words cont
      (h, w, answer) = solve a b
  putStrLn $ (show h) ++ " " ++ (show w)
  putStrLn $ unlines answer

halfNC = 50

solve :: Int -> Int -> (Int, Int, [String])
solve a b =
  let (ca, ra) = divMod (a-1) halfNC
      (cb, rb) = divMod (b-1) halfNC
  in (2*(1+ca+1+cb), 2*halfNC,
      sub ca ra '.' '#' ++ reverse (sub cb rb '#' '.'))

sub :: Int -> Int -> Char -> Char -> [String]
sub comp rem thisC thatC =
  remRows rem thisC thatC ++ compRows comp thisC thatC

remRows :: Int -> Char -> Char -> [String]
remRows rem thisC thatC =
  [ take (2 * rem) (cycle [thisC, thatC])
    ++ take (2 * (halfNC - rem)) (cycle [thatC, thatC])
  , take (2 * halfNC) $ repeat thatC
  ]

compRows :: Int -> Char -> Char -> [String]
compRows comp thisC thatC =
  take (2 * comp) $ cycle (f thisC thatC)
  where
    f thisC thatC = [ take (2 * halfNC) $ cycle [thisC, thatC]
                    , take (2 * halfNC) $ repeat thatC
                    ]


Measured memory_bytes: 764
#include "bits/stdc++.h"

using namespace std;
typedef long long ll;
#define rep(i,j,n) for (int i = j; i < (n); i++)
#define CLR(mat) memset(mat, 0, sizeof(mat))
#define IN(a, b, x) (a<=x&&x<b)
#define out(ans) cout << ans << endl
typedef pair<ll,ll>P;
const ll mod=1e9+7;
const ll INF = 1e9;

int main(){

  ll n,k;cin>>n>>k;
  P ab[n+10];rep(i,0,n)cin>>ab[i].first>>ab[i].second;

  sort(ab,ab+n);

  ll count=0;
  rep(i,0,n){
    count+=ab[i].second;
    if(k<=count){out(ab[i].first);break;}
  }

  return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const int INF=1e9;

int main(){
    int n; cin>>n;
    int a[3*n];
    for(int i=0;i<3*n;i++){
        cin>>a[i];
    }
    ll sum,sum1[n+1],sum2[n+1];
    priority_queue<int,vector<int>,greater<int>> pq1;
    sum=0;
    for(int i=0;i<n;i++){
        pq1.push(a[i]);
        sum+=a[i];
    }
    sum1[0]=sum;
    for(int i=n;i<2*n;i++){
        pq1.push(a[i]);
        sum=sum+a[i]-pq1.top();
        pq1.pop();
        sum1[i-n+1]=sum;
    }
    priority_queue<int> pq2;
    sum=0;
    for(int i=2*n;i<3*n;i++){
        pq2.push(a[i]);
        sum+=a[i];
    }
    sum2[n]=sum;
    for(int i=2*n-1;i>=n;i--){
        pq2.push(a[i]);
        sum=sum+a[i]-pq2.top();
        pq2.pop();
        sum2[i-n]=sum;
    }
    ll ans=-1e16;
    for(int i=0;i<=n;i++){
        ans=max(ans,sum1[i]-sum2[i]);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3832
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <vector>
#include <cstdio>
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <stdio.h>
#include <stack>
#include <queue>
#include <deque>
#include <numeric>
#include<bits/stdc++.h>
#include <utility>

#define ALL(obj) (obj).begin(), (obj).end()
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define RFOR(i,a,b) for(int i = (a); (b) <= i; i--)
#define REP(i,n) for(int i = 0; i < (n); i++)
#define RREP(i,n) for(int i = n; n <= i; i--)
#define ABS(a) ((a < 0) ? ((-1)*(a)) : (a))
#define elif else if
#define MOD 1000000007
#define INF (1<<29)

using namespace std;
using ll = long long;
map <int ,int> mpa,mpb;
typedef pair<ll, ll> P;
priority_queue<P, vector<P>, greater<P>> pque;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  int N;
  cin >> N;
  cout << "ABC" << N << endl;
  return 0;
}

Measured memory_bytes: 892
#include<iostream>
#include<cmath>
#include<cstdio>
#define EPS (1e-10)
#define equal(a,b)  fabs((a)-(b))<EPS
using namespace std;
struct Point{
	double x,y;
	Point(double _x,double _y):x(_x),y(_y){  }
	Point operator + (const Point &a){
		return Point(x+a.x,y+a.y);
	}
	Point operator - (const Point &a){
		return Point(x-a.x,y-a.y);
	}
	Point operator *(double k){
		return Point (k*x,k*y);
	}
	Point operator /(double k){
		return Point(x/k,y/k);
	}
	
	friend double norm(const Point &a){
		return a.x*a.x+a.y*a.y;
	}
	friend double abs(const Point &a){
		return sqrt(norm(a));
	}
	
	friend double dot(const Point &a,const Point &b){
		return a.x*b.x+a.y*b.y;
	}
	friend double cross(const Point &a,const Point &b){
		return fabs(a.x*b.y-b.x*a.y);
	}
};
typedef Point Vector;
bool isOrthogonal(const Vector &a,const Vector & b){
	return equal(cross(a,b),0.0);
}
bool isParallel(const Vector &a,const Vector &b){
	return equal(dot(a,b),0.0);
}

int main(){
	int x1,x2,y1,y2,q;
	cin>>x1>>y1>>x2>>y2>>q;
	Point a(x1,y1),b(x2,y2);
	while(q--){
		int x3,y3;
		cin>>x3>>y3;
		Point c(x3,y3);
		double t=dot(c-a,b-a)/abs(b-a);
		Vector det= (b-a) / abs(b-a) *t;
		Point ort=a+det;
		det=ort-c;
		ort=c+det*2;
		printf("%.10f %.10f\n",ort.x,ort.y);
	}
	return 0;
}


Measured memory_bytes: 3204
import java.util.*;
public class Main {
 public static void main(String[] args) {
  // TODO Auto-generated method stub
  Scanner sc = new Scanner(System.in);
  int N = sc.nextInt();
  double P = 1;
  for(int i=1;i<=N;i++){
   P = (P*i)%(Math.pow(10.0,9.0) + 7.0);
  }
  System.out.println((int)P);
 }
}

Measured memory_bytes: 21460
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <numeric>
#include <functional>
#include <sstream>
#include <iostream>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <cassert>
#include <cctype>
#include <cstdio>
#include <cassert>
using namespace std;

#define EPS 1e-12
#define ull unsigned long long
#define ll long long
#define VI vector<ll>
#define PII pair<ll, ll> 
#define VVI vector<vector<ll> >
#define VVVI vector<vector<vector<ll>>>
#define VVVVI vector<vector<vector<vector<ll>>>>
#define REP(i,n) for(ll i=0,_n=(n);(i)<(ll)_n;++i)
#define REPR(i,n) for(ll i=(ll)(n)-1;0<=(i);--i)
#define RANGE(i,a,b) for(ll i=(ll)a,_b=(ll)(b);(i)<_b;++i)
#define RANGER(i,a,b) for(ll i=(ll)(b)-1,_a=(ll)(a);(_a)<=i;--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define ALLR(c) (c).rbegin(), (c).rend()
#define PB push_back
#define MP(a, b) make_pair(a, b)
#define POPCOUNT __builtin_popcount
#define POPCOUNTLL __builtin_popcountll
#define CLEAR(table, v) memset(table, v, sizeof(table));
#define UNIFORM_DOUBLE(a, b) (((b-a)*(double)rand()/RAND_MAX)+a) // [a, b) 
#define UNIFORM_LL(a, b) (ll)UNIFORM_DOUBLE(a, b) // [a, b) 
#define IN(v, lo, hi) ((lo)<=(v) && (v)<(hi))
#define DD(v) cout<<#v<<": "<<v<<endl
#define FI first
#define SE second
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const map<T0, T1>& v) { for( typename map<T0, T1>::const_iterator p = v.begin(); p!=v.end(); p++ ){os << p->first << ": " << p->second << " ";} return os; }
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const pair<T0, T1>& v) { os << v.first << ": " << v.second << " "; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<T>& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << " "; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const set<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const deque<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<vector<T> >& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << endl; } return os; }
template<typename T>void maxUpdate(T& a, T b) {a = max(a, b);}
template<typename T>void minUpdate(T& a, T b) {a = min(a, b);}
string YN(bool v) { return v ? "Yes":"No"; }
void uniq(VI& es) { sort(ALL(es)); es.erase(unique(ALL(es)), es.end()); }

#define INF (1LL<<60)

ll gcd(ll a,ll b) { return b?gcd(b,a%b):a; }
ll lcm(ll a,ll b) { return a/gcd(a,b)*b; }
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll N,M,W,H,K;
	while(cin>>N) {
		VI T(N);
		REP(i, N) cin>>T[i];
		ll ans=T[0];
		RANGE(i, 1, N)ans=lcm(ans,T[i]);
		cout<<ans<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 256
get_number(Number) :-
    get_string(String),
    number_string(Number, String).

get_number(A, B) :-
    get_number(A),
    get_number(B).

get_number(A, B, C) :-
    get_number(A, B),
    get_number(C).

get_string(String) :-
    current_input(Input),
    read_string(Input, ' \n\r\t', '', _, String).

get_chars(Xs) :-
    get_string(S),
    string_chars(S, Xs).

get_numbers(0, []).
get_numbers(N, [X|Xs]) :- 
    get_number(X), 
    N2 is N - 1, 
    get_numbers(N2, Xs).

get_numbers_2(0, _, []).
get_numbers_2(N1, N2, [X|Xs]) :- 
    get_numbers(N2, X), 
    N12 is N1 - 1, 
    get_numbers_2(N12, N2, Xs).

put_numbers([]).
put_numbers([X|Xs]) :-
    writeln(X),
    put_numbers(Xs).

get_i_to_x_rbtree0(N, T) :-
    rb_empty(T2),
    get_i_to_x_rbtree(N, 0, T2, T).

get_i_to_x_rbtree1(N, T) :-
    rb_empty(T2),
    get_i_to_x_rbtree(N, 1, T2, T).

get_i_to_x_rbtree(0, _, T, T).
get_i_to_x_rbtree(N, I, T2, T) :-
    get_number(X),
    rb_insert(T2, I, X, T3),    
    N2 is N - 1,
    I2 is I + 1,
    get_i_to_x_rbtree(N2, I2, T3, T).

/* memo
    code(int)
    string_code(1, S, C), (C: code)
    char_code(X, Y) (X: char, Y: code)
    string_chars(S, S2) (S: string, S2: [char])
    to_lower(C, C2) (C: char? C2: code?)
    length(S, L),
    sub_string

    f(0, [], []).
    f(Z, [X|Xs], [Y|Ys]) :- X = Y, f(Z1, Xs, Ys), Z is Z1 + 1.
    f(Z, [_|Xs], [_|Ys]) :- f(Z, Xs, Ys).

    match: =, \=

    numeric: <,=<, >, >= (eval)
    lexicographically: @<. @=<, @>, @>=
    value?: =:=, =\= (eval)
    identical: ==, \==

    between(L,U,X): L <= X <= U
    nth0(I, Xs, Y), nth1(I, Xs, Y): (Xs,Y) -> I, (I, Xs) -> Y 

    sort(Key, Order, List, Sorted): Keyは通常0?, Orderは=なしが重複削除，=は重複保持
    \+ P(X) : not P(X)

    sum_list(Xs, Sum)

    orは!忘れに注意(末尾再帰なら直前)

    include(f, Xs, Ys) : filter f
*/

f(Xs, Z) :- f(Xs, 0, Z).

f([], C, C).
f([_], C, C).
f([_, _], C, C).
f([X1,X2,X3|Xs], C, Z) :- g(X1, X2, X3, C, C2), f([X2,X3|Xs], C2, Z).

g(X, Y, Z, C, C2) :- X < Y, Y < Z, !, C2 is C + 1.
g(X, Y, Z, C, C2) :- X > Y, Y > Z, !, C2 is C + 1.
g(_, _, _, C, C).

main :-
    get_number(N),
    get_numbers(N, Xs),
    f(Xs, Z),
    writeln(Z).

    % statistics(inferences, IC), writeln(IC).


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

int main(void)
{
    string n; cin >> n;
    bool flag = false;
    for (char p:n)
    {
        if (p == '7')
        {
            flag = true;
            break;
        }
    }
    if (flag) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,a,b,p=0,q=0,r=0;
  cin>>n>>a>>b;
  for(int i=0;i<n;++i){
    int k;
    cin>>k;
    if(k<=a)p++;
    else if(k<=b)q++;
    else r++;
  }
  cout<<min({p,q,r})<<"\n";
  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 a = sc.nextInt();
		int b = sc.nextInt();
    
		// 出力
		System.out.println(b % a == 0 ? a + b : b - a);
	}
}


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

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

int main(){

	ios::sync_with_stdio(false);
	cin.tie(NULL);
	
	int n, k;
	cin >> n >> k;

	string s;
	cin >> s;


	s[k - 1] = s[k - 1] + ('a' - 'A');
	cout << s;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fastIO (cin.tie(0), cout.tie(0), ios::sync_with_stdio(false))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define precise(i) fixed << setprecision(i)
using namespace std;

int main() {
    fastIO;
    int N, i;
    cin >> N >> i;
    cout << (N - i + 1);
}

Measured memory_bytes: 3628
s = input()[::-1]
n = len(s)

mod = [0]*2019
pre = 0
mod[pre] = 1
x = 1
for i in range(n):
    pre += int(s[i])*x
    pre %= 2019
    mod[pre] += 1
    x *= 10
    x %=2019
print(sum([m*(m-1)//2 for m in mod]))

Measured memory_bytes: 9352
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//cout << fixed << setprecision(17) << res << endl;
 
int main() {
    ll n, m, q;
    cin >> n >> m >> q;
    vector<tuple<ll,ll,ll,ll>> V(q);

    for (auto & v : V) {
        cin >> get<0>(v) >> get<1>(v) >> get<2>(v) >> get<3>(v);
        --get<0>(v);
        --get<1>(v);
    }

    ll res = 0;
    for (ll i0 = 1; i0 <= 1; ++ i0)
    for (ll i1 = i0; i1 <= m; ++ i1)
    for (ll i2 = i1; i2 <= m; ++ i2)
    for (ll i3 = i2; i3 <= m; ++ i3)
    for (ll i4 = i3; i4 <= m; ++ i4)
    for (ll i5 = i4; i5 <= m; ++ i5)
    for (ll i6 = i5; i6 <= m; ++ i6)
    for (ll i7 = i6; i7 <= m; ++ i7)
    for (ll i8 = i7; i8 <= m; ++ i8)
    for (ll i9 = i8; i9 <= m; ++ i9) {
        vector<ll> A = {i0, i1, i2, i3, i4, i5, i6, i7, i8, i9};
        //for (auto & a : A) {
        //    cerr << a << ",";
        //}
        //cerr << endl;
        ll point = 0;
        for (auto & v : V) {
            if ((A[get<1>(v)] - A[get<0>(v)]) == get<2>(v)) {
                point += get<3>(v);
            }
        }
        res = max(res, point);
    }
    cout << res << endl;
}


Measured memory_bytes: 3640
#include <iostream>
#include <vector>

using namespace std;

class range {
private:
  struct Iterator {
    int val;
    int operator*() {return val;}
    bool operator!=(Iterator &itr) {return val < itr.val;}
    void operator++() {++val;}
  };
  Iterator i, n;
public:
  range(int n) : i({0}), n({n}) {}
  range(int i, int n) : i({i}), n({n}) {}
  Iterator &begin() {return i;}
  Iterator &end() {return n;}
};

template<class T> T at(vector<T> v, int i) {return v[(i % (int)v.size() + v.size()) % v.size()];}

namespace Day {
  enum {MON, TUE, WED, THU, FRI, SAT, SUN};
  int leap_count(int year) {
    if (year < 0) return -leap_count(-year - 1) - 1;
    return year / 4 - year / 100 + year / 400;
  }
  int day_count(int year, int month, int day) {
    if (month <= 2) --year, month += 12;
    return year * 365 + leap_count(year) + (month * 153 + 3) / 5 + day;
  }
  bool is_leap(int year) {return leap_count(year) > leap_count(year - 1);}
};

#include <sstream>

template<class A, class B> B convert(A a) {
  stringstream ss;
  ss << a;
  B b;
  ss >> b;
  return b;
}

int parse(string s) {
  int year = convert<string, int>(s.substr(0, 4));
  int month = convert<string, int>(s.substr(5, 2));
  int day = convert<string, int>(s.substr(8));
  return Day::day_count(year, month, day);
}

int main() {
  int n;
  cin >> n;
  string title[n], auther[n], date[n];
  for (int i : range(n)) cin >> title[i] >> auther[i] >> date[i];
  int d[n];
  for (int i : range(n)) d[i] = parse(date[i]);
  int q;
  cin >> q;
  for (int i : range(q)) {
    if (i != 0) cout << endl;
    string q_title, q_auther, q_date_from, q_date_to;
    cin >> q_title >> q_auther >> q_date_from >> q_date_to;
    int from = -1;
    if (q_date_from != "*") from = parse(q_date_from);
    int to = -1;
    if (q_date_to != "*") to = parse(q_date_to);
    for (int j : range(n)) {
      if (q_title != "*" && title[j].find(q_title) == string::npos) continue;
      if (q_auther != "*" && auther[j].find(q_auther) == string::npos) continue;
      if (from != -1 && d[j] < from) continue;
      if (to != -1 && to < d[j]) continue;
      cout << title[j] << endl;
    }
  }
}

Measured memory_bytes: 1260
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };

ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int f(int n, int k, int sum, vector<int>& a, vector<bool>& zero, vector<bool>& used) {
	if (k == n) return sum == 0;
	int cnt = 0;
	for (int x = 0; x < 10; x++) {
		if (used[x] || (x == 0 && !zero[k])) continue;
		used[x] = true;
		cnt += f(n, k + 1, sum + a[k] * x, a, zero, used);
		used[x] = false;
	}
	return cnt;
}

int main() {
	for (;;) {
		int N; cin >> N;
		if (N == 0) break;
		int n = 0;
		vector<int> v(128, -1), a(10);
		vector<bool> zero(10, true);
		while (N--) {
			string s; cin >> s;
			int x = 1;
			for (int i = s.length() - 1; i >= 0; i--) {
				char c = s[i];
				if (v[c] == -1) v[c] = n++;
				int k = v[c];
				if (N) a[k] += x;
				else a[k] -= x;
				x *= 10;
			}
			if (s.length() >= 2) zero[v[s[0]]] = false;
		}
		vector<bool> used(10);
		cout << f(n, 0, 0, a, zero, used) << endl;
	}
}

Measured memory_bytes: 1208
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int x;
  cin >> x;
  if (x>=400 && x<=599){
    cout << 8 << endl;
  }
  else if (x>=600 && x<=799){
    cout << 7 << endl;
  }
  else if (x>=800 && x<=999){
    cout << 6 << endl;
  }
  else if (x>=1000 && x<=1199){
    cout << 5 << endl;
  }
  else if (x>=1200 && x<=1399){
    cout << 4 << endl;
  }
  else if (x>=1400 && x<=1599){
    cout << 3 << endl;
  }
  else if (x>=1600 && x<=1799){
    cout << 2 << endl;
  }
  else if (x>=1800 && x<=1999){
    cout << 1 << endl;
  }
}

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

struct UnionFind {
  vector<int> data;
	int count;
  UnionFind(int size) : data(size, -1), count(size - 1) { }
  bool unionSet(int x, int y) {
    x = root(x); y = root(y);
    if (x != y) {
      if (data[y] < data[x]) swap(x, y);
      data[x] += data[y]; data[y] = x;
		count--;
    }
    return x != y;
  }
  bool findSet(int x, int y) {
    return root(x) == root(y);
  }
  int root(int x) {
    return data[x] < 0 ? x : data[x] = root(data[x]);
  }
  int size(int x) {
    return -data[root(x)];
  }
};

int main() {
	int N, M;

	cin >> N >> M;
	UnionFind uf( N + 1 );
	for( int i = 0; i < M; i++ ) {
		int x, y, z;
		cin >> x >> y >> z;
		uf.unionSet( x, y );
	}

	int ans = uf.count;

	cout << ans << endl;

	return 0;
}


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



int main(){
	int H, N;
	cin >> H >> N;
	int s=0;
	rep(i,N){
		int buf;
		cin >> buf;
		s+= buf;
	}
	if(H <= s) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <set>
#include <algorithm>
#include <vector>
#include <stack>
#include <cstring>

#define X first
#define Y second
#define PB push_back
#define INS insert

using namespace std;

typedef pair < int, int > pii;
typedef set<pii>::iterator iter;

const int N = 2e4 + 500;

set < pii > s;
stack < int > st;
int poz[N], fl = 0, bio[N], cur = 1, d = -1, n;

void dfs(int x){
    bio[x] = cur;
    int lo, hi;
    if(!fl){
        lo = poz[x] - d;
        hi = poz[x] + d;
    }
    else{
        lo = poz[x ^ 1] - d;
        hi = poz[x ^ 1] + d;
    }
    iter it = s.lower_bound({lo, 0});
    for(;it != s.end() && it->X <= hi;){
        if(it->Y == (x^1)) {
            it++;continue;
        }
        int nxt = it->Y;
        s.erase(it);
        dfs(nxt);
        if(!fl)
            it = s.lower_bound({poz[nxt ^ 1], nxt});
        else
            it = s.lower_bound({poz[nxt], nxt});
    }
    if(!fl) st.push(x);
}

bool sat2(){
    memset(bio, 0, sizeof(bio));
    fl = 0;cur = 1;
    for(int i = 0;i<2 * n;i++)
        s.insert({poz[i ^ 1], i});
    for(int i = 0;i<2 * n;i++){
        if(bio[i]) continue;
        s.erase({poz[i ^ 1], i});
        dfs(i);
    }
    s.clear();
    memset(bio, 0, sizeof(bio));
    for(int i = 0;i<2 * n;i++)
        s.insert({poz[i], i});
    fl = 1;cur = 1;
    while(!st.empty()){
        if(!bio[st.top()]){
            s.erase({poz[st.top()], st.top()});
            dfs(st.top());
            cur++;
        }
        st.pop();
    }
    s.clear();
    for(int i = 0;i<2 * n;i++){
        if(bio[i] == bio[i ^ 1])
            return 0;
    }
    return 1;
}


int main(){
    scanf("%d", &n);
    for(int i = 0;i<2 * n;i++){
        scanf("%d", poz + i);
    }
    for(int i = 29;i>=0;i--){
        d += (1 << i);
        if(sat2()) continue;
        d -= (1 << i);
    }
    printf("%d\n", d + 1);
}


Measured memory_bytes: 2304
class UnionFind
  def initialize(n)
    @size = Array.new(n + 1, 1)
    @rank = Array.new(n + 1, 0)
    @parent = []

    (0..n).each do |i|
      @parent[i] = i
    end
  end

  def find(x)
    if @parent[x] == x
      x
    else
      @parent[x] = find(@parent[x])
    end
  end

  def unite(x, y)
    x = find(x)
    y = find(y)
    return if x == y

    if @rank[x] < @rank[y]
      @parent[x] = y
      @size[y] += @size[x]
    else
      @parent[y] = x
      @size[x] += @size[y]

      @rank[x] += 1 if @rank[x] == @rank[y]
    end
  end

  def same?(x, y)
    find(x) == find(y)
  end

  def size(x)
    @size[find(x)]
  end
end

class PriorityQueue
  attr_reader :size

  def initialize(order: :asc)
    @size = 0
    @nodes = []
  end

  def empty?
    @size.zero?
  end

  def push(node)
    index = size
    @size += 1

    while index > 0
      parent = (index - 1) / 2

      break if (@nodes[parent] <=> node) <= 0

      @nodes[index] = @nodes[parent]
      index = parent
    end

    @nodes[index] = node
  end

  alias_method :<<, :push

  def pop
    node = @nodes.first
    root = @nodes[size - 1]
    @size -= 1
    index = 0

    while index * 2 + 1 < @size
      left = 2 * index + 1
      right = left + 1

      if right < size && (@nodes[right] <=> @nodes[left]) <= 0
        left = right
      end

      break if (@nodes[left] <=> root) > 0

      @nodes[index] = @nodes[left]
      index = left
    end

    @nodes[index] = root
    node
  end

  def top
    @nodes.first
  end
end

Node = Struct.new(:v, :cost) do
  def <=>(node)
    cost <=> node.cost
  end
end

N, M = gets.split.map(&:to_i)
A = gets.split.map(&:to_i)

uf = UnionFind.new(N + 1)

M.times do
  x, y = gets.split.map(&:to_i)

  uf.unite(x, y)
end

trees = Hash.new { |h, k| h[k] = [] }

N.times do |v|
  trees[uf.find(v)] << v
end

trees = trees.sort_by { |_, list| -list.size }

base = trees.shift
ans = 0

pque = PriorityQueue.new

base.last.each do |v|
  pque.push(Node.new(v, A[v]))
end

while !trees.empty? && !pque.empty?
  tree = trees.shift
  stock = PriorityQueue.new

  tree.last.each do |v|
    stock.push(Node.new(v, A[v]))
  end

  v = pque.pop
  u = stock.pop

  ans += v.cost + u.cost

  until stock.empty?
    pque.push(stock.pop)
  end
end

if trees.empty?
  puts ans
else
  puts 'Impossible'
end


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

#define NDEBUG
#ifdef DEBUG
#include "../cout11.h"
#undef NDEBUG
#endif
#include <cassert>

typedef long long ll;
typedef long double Double;
typedef unsigned long long ull;
typedef pair<int,int> ii;
typedef pair<ll,ll> llll;
typedef pair<double,double> dd;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ii> vii;
typedef vector<vector<ii>> vvii;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<long double> vD;

#define sz(a)  int((a).size())
#define pb  push_back
#define FOR(var,from,to) for(int var=(from);var<=(to);++var)
#define rep(var,n)  for(int var=0;var<(n);++var)
#define rep1(var,n)  for(int var=1;var<=(n);++var)
#define repC2(vari,varj,n)  for(int vari=0;vari<(n)-1;++vari)for(int varj=vari+1;varj<(n);++varj)
#define ALL(c)  (c).begin(),(c).end()
#define RALL(c)  (c).rbegin(),(c).rend()
#define tr(i,c)  for(auto i=(c).begin(); i!=(c).end(); ++i)
#define found(s,e)  ((s).find(e)!=(s).end())
#define mset(arr,val)  memset(arr,val,sizeof(arr))
#define mid(x,y) ((x)+((y)-(x))/2)
#define IN(x,a,b) ((a)<=(x)&&(x)<=(b))

#define INFTY 40*1000+1

ll solve(int N,int Ma,int Mb,vi& a,vi& b,vi& c) {
    vvi p(401, vi(401, INFTY));
    p[0][0] = 0;
    rep(i,N){
        int ai=a[i],bi=b[i],ci=c[i];
        for(int x=400;x>=0;--x)
        for(int y=400;y>=0;--y) {
            if (p[x][y] == INFTY) continue;
            p[x+ai][y+bi] = min(p[x+ai][y+bi], p[x][y] + ci);
        }
    }
    int ans = INFTY;
    for (int i=Ma,j=Mb; i<=400&&j<=400; i+=Ma,j+=Mb) {
        ans = min(ans, p[i][j]);
    }
    return (ans == INFTY)? -1 : ans;
}

int main() {
    int N,Ma,Mb; cin >> N >> Ma >> Mb;
    vi a(N),b(N),c(N);
    rep(i,N){
        cin >> a[i] >> b[i] >> c[i];
    }
    cout << solve(N,Ma,Mb,a,b,c) << endl;
    // cout << (solve(N,a) ? "Yes":"No") << endl;
    return 0;
}


Measured memory_bytes: 896
n=int(input())
x=list(map(int,input().split()))
x.sort()
def sump(x,p):
  s=0
  for a in x:
    s+=(a-p)**2
  return s
m=min(x)
M=max(x)
ans=[]
for p in range(m,M+1):
  ans.append(sump(x,p))
print(min(ans))


Measured memory_bytes: 9060
/*Author - Shubham Gupta (@shubham107)*/
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef vector<ll> vl;      typedef vector<int> vi;
typedef vector<vl> vvl;     typedef vector<vi> vvi;
typedef pair<ll, ll> pll;   typedef pair<int, int> pii;
#define forn(i,n) for(int i=0;i<n;i++)
#define rforn(i,n) for(int i=n-1;i>=0;i--)
#define forne(i,n) for(int i=1;i<=n;i++)
#define forse(i,s,e) for(int i=s;i<e;i++)
#define rforse(i,s,e) for(int i=e-1;i>=s;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define MOD 1000000007
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define fill(a,x) memset(a,x,sizeof a);
#define trav(a,x) for(auto &a:x)
#define INF ll(1e18)
#ifdef SHUBHAM107
#include "../trace.h"
#else
#define trace(args...)
#endif
const int N = 2e5 + 5;
void solve() {
    int n, cnt = 0;
    string s;
    cin >> n >> s;
    for(char c: s) {
        cnt += (c == '1');
    }
    int p1 = 0, m1 = 0;
    for(char c: s) {
        p1 = (p1 * 2 + (c == '1')) % (cnt + 1);
        if(cnt > 1) {
            m1 = (m1 * 2 + (c == '1')) % (cnt - 1);
        }
    }
    vi dp(N, 0);
    for(int i = 1; i < N; i++) {
        dp[i] = dp[i % (__builtin_popcount(i))] + 1;
    }
    auto f = [&](int p, vi &po) {
        if(p <= 0)
            return;
        int x = 1;
        for(int i = 0; i < N; i++) {
            po[i] = x;
            x = (x * 2) % p;
        }
    };
    vi po1(N), po2(N);//+, -, 0
    f(cnt + 1, po1);
    f(cnt - 1, po2);
    // f(cnt, po3);
    for(int i = 0; i < n; i++) {
        char c = s[i];
        if(c == '1') {
            if(cnt == 1)
                cout << 0 << '\n';
            else {
                int nx = m1 - po2[n - 1 - i];
                if(nx < 0)
                    nx += (cnt - 1);
                cout << 1 + dp[nx] << '\n';
            }
        } else {
            int nx = p1 + po1[n - 1 - i];
            nx %= (cnt + 1);
            cout << 1 + dp[nx] << '\n';
        }
    }
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
#ifdef SHUBHAM107
    freopen("inp.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    freopen("err.txt", "w", stderr);
#endif
    int t = 1;
    // cin >> t;
    while (t--) {
        solve();
    }
}


Measured memory_bytes: 5984
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
#include <deque>

using namespace std;

#define mod 1000000007

int main()
{
	int n, k;
	cin >> n >> k;
	int cnt[200001] = {};
	for(int i = 0; i < n; i++){
		int a;
		cin >> a;
		cnt[a]++;
	}
	sort(cnt + 1, cnt + n + 1);
	int ans = 0;
	int tmp = 0;
	int zeronum = 1;
	while(cnt[zeronum] == 0) zeronum++;
	int now = zeronum;
	zeronum--;
	// cout << zeronum << endl;
	while(tmp < n - k - zeronum){
		// cout << cnt[now] << endl;
		ans += cnt[now];
		tmp++;
		now++;
	}
	cout << ans << endl;
}

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

using namespace std;
int main()
{
	long long s = 0;
    int i, j, ans = 0;
	int N = 0;
	long long K = 0;
	long long A[100001] = {};
	int a, b = 0;

	cin >> N;
    cin >> K;

	for (i = 0; i <= N-1; i++) {
		cin >> a;
		cin >> b;
		A[a] += b;
	}

	for (j = 1; j <= 100001; j++) {
		s += A[j];
		ans = j;
		if (s >= K)
			break;
	}

	cout << ans;

	return 0;
}

Measured memory_bytes: 1152
from collections import deque
from math import gcd
import sys

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

MOD = 10**9 + 7
n = int(input())
cnt = {}
zero_cnt = 0
ans = 1

for _ in range(n):
    a, b = map(int, input().split())
    if (a, b) == (0, 0):
        zero_cnt += 1
        continue
    g = gcd(abs(a), abs(b))
    if a == 0 or b == 0: g = max(abs(a), abs(b))
    a //= g
    b //= g

    rotate = 0
    while not (a > 0 and b >= 0):
        a, b = -b, a
        rotate += 1
    if (a, b) not in cnt:
        cnt[(a, b)] = [0, 0]

    cnt[(a, b)][rotate%2] += 1

for key in cnt:
    A, B = cnt[key]
    ans *= 1 + pow(2, A, MOD) - 1 + pow(2, B, MOD) - 1
    ans %= MOD

ans += zero_cnt
ans -= 1 #for empty set
print(ans % MOD)


Measured memory_bytes: 60632
#include <iostream>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)
using ll = long long;
constexpr ll MOD = 1e9 + 7;

int table[26];

int main() {
    int N;cin>>N;
    string S;cin>>S;
    REP(i,N) ++table[S[i]-'a'];
    ll ans = 1;
    REP(i,26) ans = (ans * (table[i]+1)) % MOD;
    ans = (ans - 1 + MOD) % MOD;
    cout << ans << endl;
    return 0;
}

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

int main(){
	int n,k,x,y;
    cin>>n>>k>>x>>y;
	if(n>k){
		cout<<k*x+(n-k)*y<<endl;
	}else{
		cout<<n*x<<endl;
	}
	return 0;
}

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

namespace attocoda
{
    class Program
    {
        static void Main(string[] args)
        {
            int a, b;
            var word = Console.ReadLine().Split(' ');
            a = int.Parse(word[0]);
            b = int.Parse(word[1]);
            if ((0 < a && a <= 9) && (0 < b && b <= 9))
                Console.WriteLine(a * b);
            else if ((a >= 10 || a == 0) && b <= 9)
                Console.WriteLine(-1);
            else if (a <= 9 && (b >= 10 || b == 0))
                Console.WriteLine(-1);
            else
                Console.WriteLine(-1);
            Console.ReadKey();
        }
    }
}


Measured memory_bytes: 13140
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <math.h>
#include <bitset>
#include <queue>
#include <set>
#include <iomanip>
#include <math.h>
#include <assert.h>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr int INF = 1000000007;
const int mod = 1000000007;

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

ll gcd(ll a, ll b)
{
    if (a % b == 0)
    {
        return (b);
    }
    else
    {
        return (gcd(b, a % b));
    }
}

ll lcm(ll a, ll b)
{
    return a / gcd(a, b) * b;
}

//----------------------------------------------------------------

int main()
{
    ll n;
    cin >> n;
    ll a;
    bool flag = false;
    for (int i = 0; i < n; i++)
    {
        cin >> a;
        if (a % 2 == 0)
        {

            if (a % 3 > 0 && a % 5 > 0)
            {
                flag = true;
            }
        }
    }
    if (flag)
    {
        cout << "DENIED" << endl;
    }
    else
    {
        cout << "APPROVED" << endl;
    }
}


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

/*int main(void){
    int n,x;
    set<int> a;
    a.insert(1);
    a.insert(3);
    a.insert(2);
    for(int i=0;i<a.size();i++){
        cout<<a.count(i)<<" ";
    }
}*/

int main(void){
    int n,x,ans=1;
    cin>>n;
    vector<int> vec(n);
    for(int i=0;i<n;i++){
        cin>>vec.at(i);
    }
    sort(vec.begin(),vec.end());
    for(int i=0;i<n-1;i++){
        if(vec.at(i)==vec.at(i+1)){
            ans=0;
            break;
        }
    }
    if(ans==1)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}

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

#define int long long
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define pb push_back
#define fi first
#define se second
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

signed main(){
    int e[12];rep(i,12)cin>>e[i];
    sort(e,e+12);

    for(int i=0;i<12;i+=4){
        for(int j=0;j<4;j++){
            if(e[i]!=e[i+j]){
                cout<<"no"<<endl;
                return 0;
            }
        }
    }
    cout<<"yes"<<endl;
    return 0;
}

Measured memory_bytes: 3084
#include <bits/stdc++.h>
#include <stdio.h>
#include <algorithm>
 
using namespace std;
#define rep(i,a,b) for (ll i = a; i < b; i++)
#define rrep(i,a,b) for (ll i = a; i >= b; i--)
#include <bits/stdc++.h>
#include <stdio.h>
#include <algorithm>
 
using namespace std;
#define rep(i,a,b) for (ll i = a; i < b; i++)
#define rrep(i,a,b) for (ll i = a; i >= b; i--)
#define l(s) s.length()
#define sort(v) sort(v.begin(), v.end());
#define scan(v,n) rep(i,0,n) {ll k; cin >> k; v.pb(k);}
#define print(v,n) {rep(i,0,n) cout << v[i] << " "; cout << endl;}
#define printstr(s,n) {rep(i,0,n) cout << s[i]; cout << endl;}
#define rev(a) reverse(a.begin(), a.end());
#define pb push_back
typedef long long ll;
typedef long double lld;
typedef vector<pair<ll,ll>> vpi;
typedef vector<ll> vi;
 
const ll mxN=1e5+1;
const ll N=1e18+7;
 
ll dp[mxN+1];
 
  int main() {
      int T=1;// cin >> T;
      while(T--){
          ll n,W,sum=0; cin >> n >> W;
          rep(i,1,100001) dp[i]=N;
          rep(i,0,n) {
              ll w,v;
              cin >> w >> v;
              sum+=v;
              rrep(x,100001,0) {
                  if(x>=v&&dp[x]>dp[x-v]+w) dp[x]=dp[x-v]+w;
              }
          }
          ll ans=0;
          rep(i,0,sum+1){
              if(dp[i]<=W&&ans<i) ans=i; 
          }
          cout << ans;
      } 
	 return 0;
}


Measured memory_bytes: 4412
#include<stdio.h>
int main()
{
  int a,b,c,i,j;
  scanf("%d%d%d",&a,&b,&c);
  for(i=a;i<=b;i++){
    if(c%i==0)
      j++;
  }
  printf("%d\n",j);
   return 0;
 }

Measured memory_bytes: 1028
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define INF 1000000000
#define mod 1000000007

int N, K;
map<int, bool> M;

bool check(int i){
    while(i){
        if(M[i%10]) return false;
        i /= 10;
    }
    return true;
}

int main() {
    cin >> N >> K;
    for(int i=0; i<K; i++){
        int d; cin >> d;
        M[d] = true;
    }

    while(!check(N)) N++;

    cout << N << endl;
    return 0;
}


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

const int N = 100005;

struct edge {
	int u; int v; int w;
	bool operator < (const edge &other) const {
		return w < other.w;
	}
} e[N];

int n, m;
int a[N];
bool can[N], used[N];
vector < pair<int,int> > g[N];

struct dsu {
	int par[N];
	long long sum[N];
	void init() {
		for (int i = 1; i <= n; ++i) par[i] = i, sum[i] = a[i];
	}
	int anc(int p) { return p == par[p] ? p : par[p] = anc(par[p]); }
	bool join(int p, int q) {
		p = anc(p), q = anc(q);
		if (p == q) return false;
		par[p] = q;
		sum[q] += sum[p];
		sum[p] = 0;
		return true;
	}
} d;

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	cin >> n >> m;
	for (int i = 1; i <= n; ++i) cin >> a[i];
	
	// build edges
	for (int i = 1; i <= m; ++i) {
		int u, v, w; cin >> u >> v >> w;
		e[i] = {u, v, w};
	}
	sort(e + 1, e + m + 1);
	for (int i = 1; i <= m; ++i) {
		g[e[i].u].push_back({e[i].v, i});
		g[e[i].v].push_back({e[i].u, i});
	}
	
	// solve
	d.init();
	for (int i = 1; i <= m; ++i) {
		d.join(e[i].u, e[i].v);
		int x = d.anc(e[i].u);
		if (d.sum[x] >= e[i].w) can[i] = true;
	}
	
	d.init();
	for (int i = m; i >= 1; --i) if (can[i] && !used[i]) {
		used[i] = true;
		queue <int> q;
		d.join(e[i].u, e[i].v);
		q.push(e[i].u); q.push(e[i].v);
		
		while(!q.empty()) {
			int u = q.front(); q.pop();
			for (auto &ed : g[u]) {
				if (ed.second <= i) {
					used[ed.second] = true;
					if (d.join(ed.first, u)) q.push(ed.first);
				} else break;
			}
		}
	}
	
	int res = 0;
	for (int i = 1; i <= m; ++i) if (!used[i]) ++res;
	
	cout << res << endl;
}


Measured memory_bytes: 9216