akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String s = sc.next();
		int x=0,max=0;
		for(int i=0;i<n;i++) {
			if(s.charAt(i)=='I')x+=1;
			if(s.charAt(i)=='D')x-=1;
			if(max<x) max=x;
		}
		System.out.println(max);

	}

}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
 #define len length
// smile :)
using namespace std;
typedef long long ll;

int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
int x;
bool flag=false;
cin>>x;
for(ll i=-500;i<=500;i++)
{
    for(ll j=-500;j<=500;j++)
     {
         if(i*i*i*i*i-j*j*j*j*j==x)
          {
            cout<<i<<" "<<j;
            flag =true;
            break;
          }
          if(flag) break;
     }
}
 return 0;
}


Measured memory_bytes: 3608
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<queue>
#include<cstring>
#include<string>
#include<cmath>
#include<map>
#include<set>
#include<vector>
#define ll long long 
using namespace std;
int n, m, x, y;
int a[105], b[105];
int main()
{
	cin >> n >> m >> x >> y;
	for (int i = 0; i < n; i++)
		cin >> a[i];
	for (int i = 0; i < m; i++)
		cin >> b[i];
	sort(a, a + n);
	sort(b, b + m);
	if ((x < y) && (a[n - 1] < b[0]))
	{
		if ((x + 1 <= a[n - 1] + 1 && a[n - 1] + 1 <= y) || (a[n - 1] <= x && x + 1 <= b[0]))
			cout << "No War";
		else
			cout << "War";
	}
	else
		cout << "War";
	return 0;
}

Measured memory_bytes: 256
N = int(input())
D = [list(map(int, input().split())) for _ in range(N)]
count = 0
for a, b in D:
    if a == b:
        count += 1
    else:
        count = 0
    if count >= 3:
        ans = 'Yes'
        break
else:
    ans = 'No'

print(ans)

Measured memory_bytes: 62488
#include <bits/stdc++.h>
using namespace std;
int main() {
   // cout<<"Hello World!";
   int n;
   cin>>n;
   int arr[n];
   for(int i=0;i<n;i++){
     cin>>arr[i];
   }
   sort(arr,arr+n);
   double ans = (arr[0]+arr[1])/2.0;
   for(int i=2;i<n;i++){
       ans = (ans+arr[i])/2.0;
   }
   cout<<fixed<<setprecision(12)<<ans<<endl;

   return 0;
}


Measured memory_bytes: 256
//clear adj and visited vector declared globally after each test case
//check for long long overflow
//while adding and subs check if mod becomes -ve
//while using an integer directly in a builtin function add ll

#include <bits/stdc++.h>
#define int long long
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);cout.precision(dbl::max_digits10);
#define pb push_back
#define mod 1000000007 //998244353
#define lld long double
#define mii map<int, int>
#define mci map<char, int>
#define msi map<string, int>
#define pii pair<int, int>
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define rep(i,x,y) for(int i=x; i<y; i++)
#define fill(a,b) memset(a, b, sizeof(a))
#define vi vector<int>
#define setbits(x) __builtin_popcountll(x)
typedef std::numeric_limits< double > dbl;
using namespace std;
const long long N=200005, INF=2000000000000000000;
int power(int a, int b, int p)
    {
        if(a==0)
        return 0;
        int res=1;
        a%=p;
        while(b>0)
        {
            if(b&1)
            res=(res*a)%p;
            b>>=1;
            a=(a*a)%p;
        }
        return res;
    }

int32_t main()
{
    IOS;
    int k,a,b;
    cin>>k>>a>>b;
    for(int i=a;i<=b;i++)
    {
        if(i%k==0)
        {
            cout<<"OK";
            return 0;
        }
    }
    cout<<"NG";
    return 0;
}

Measured memory_bytes: 3640
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>

using namespace std;

int main()
{
    char c[5];
    scanf("%s",c);
    int s=0;
    for (int i=0;i<3;i++)
        if (c[i]=='a') s++;
        else if (c[i]=='b') s++;
        else if (c[i]=='c') s++;
    if (s==3&&c[0]!=c[1]&&c[1]!=c[2]&&c[0]!=c[2]) printf("Yes\n");
    else printf("No\n");
    return 0;
}


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

int main() {
    int X, Y, A, B, C; cin >> X >> Y >> A >> B >> C;
    vector<int> p(A), q(B), r(C);
    rep(i, A){
        cin >> p[i];
    }
    rep(i, B){
        cin >> q[i];
    }
    rep(i, C){
        cin >> r[i];
    }
    sort(p.begin(), p.end());
    sort(q.begin(), q.end());
    sort(r.begin(), r.end());

    int cntA = 0;
    int cntB = 0;
    int total = 0;

    int pnum = A-1;
    int qnum = B-1;
    int rnum = C-1;

    ll ans = 0;
    while(total < X+Y){
        int pnow = 0;
        if(pnum != -1){
            pnow = p[pnum];
        }
        int qnow = 0;
        if(qnum != -1){
            qnow = q[qnum];
        }
        int rnow = 0;
        if(rnum != -1){
            rnow = r[rnum];
        }
        if(cntA == X)pnow = 0;
        if(cntB == Y)qnow = 0;
        if(rnow >= pnow && rnow >= qnow){
            total++;
            ans += rnow;
            rnum--;
        } else if(pnow > qnow){
            total++;
            cntA++;
            ans += pnow;
            pnum--;
        } else {
            total++;
            cntB++;
            ans += qnow;
            qnum--;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 4564
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		int D = sc.nextInt();
		int E = sc.nextInt();
		int K = sc.nextInt();
		if (K>=E-A) {
			System.out.println("Yay!");
		} else {
			System.out.println(":(");
		}
	}
}


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

typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;

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

const ll INF = 1e18;
const ll MOD = 998244353;
const ll MX = 1000001;

int N; 
ll ans = 1;

void solve() {
    cin >> N; vector<char> a(N);
    for (auto& i : a) cin >> i;
    for (int i = 1; i < N; i++) ans += (a[i] != a[i - 1]);
    cout << ans;
}

int main() {
	cin.sync_with_stdio(0); cin.tie(0);
    ll testCases = 1; // cin >> testCases;
    while (testCases--) solve();
    return 0;
    // You should actually read the stuff at the bottom
}

/* Stuff to Look For
 * -----------------
 * Int overflow, array bounds
 * Initializing all variables, avoid weird behavior
 * Edge cases(n = 0, n = 1)
 * Just return 0 after result
 */


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std; 
#define int long long
#define ff first
#define ss second
#define ld long double
#define f(i,x,n) for(int i=x;i<n;++i)
int32_t main() 
{ 
	ld a,b; cin>>a>>b;	
	a*=b;
	int c=a;
	cout<<c<<"\n";
	return 0; 
} 




Measured memory_bytes: 3728
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <time.h>
#include <iostream>
#include <algorithm>
#include <fstream>
#include <iomanip>
#include <vector>
#include <bitset>
#include <stack>
#include <queue>
#include <set>
#include <map>

using namespace std;

int n,p;
int cnt[2];

int main()
{
	cin >> n >> p;
	for (int a,i = 1;i <= n;i++)
	{
		cin >> a;
		cnt[a & 1]++;
	}
	if (p == 1 && !cnt[1])
		cout << 0 << endl;
	else if (p == 0 && !cnt[1])
		cout << (1ll << cnt[0]) << endl;
	else
		cout << (1ll << (cnt[1] - 1 + cnt[0])) << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int W, H, N;
  cin>>W>>H>>N;
  int x, y, a;
  int maxx=W, minx=0, maxy=H, miny=0;
  for(int i=0;i<N;++i){
    cin>>x>>y>>a;
    if(a==1){
      minx = max(minx, x);
    }
    if(a==2){
      maxx = min(maxx, x);
    }
    if(a==3){
      miny = max(miny, y);
    }
    if(a==4){
      maxy = min(maxy, y);
    }
  }
  if(maxx<=minx || maxy<=miny) cout<<0<<endl;
  else cout<<max(0, (maxx-minx)*(maxy-miny))<<endl;
}



Measured memory_bytes: 3588
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long  n;
    cin>>n;
    long long sum=0;
    for(int i=1;i<=n;i++)
    {
        if(i%3!=0&&i%5!=0)
            sum+=i;
    }
    cout<<sum<<endl;
}


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

using namespace std;

int main()
{
	string str;
	while(getline(cin , str))
	{
		stringstream ss;
		ss << str;
		string s;
		stack<long double>data;
		while(ss >> s)
		{
			if(s == "+")
			{
				auto a = data.top(); data.pop();
				auto b = data.top(); data.pop();
				data.push(b + a);
			} else if(s == "-")
			{
				auto a = data.top(); data.pop();
				auto b = data.top(); data.pop();
				data.push(b - a);
			} else if(s == "*")
			{
				auto a = data.top(); data.pop();
				auto b = data.top(); data.pop();
				data.push(b * a);
			} else if(s == "/")
			{
				auto a = data.top(); data.pop();
				auto b = data.top(); data.pop();
				data.push(b / a);
			} else
			{
				data.push(atoi(s.c_str()));
			}
		}
		cout << fixed << setprecision(20) << data.top() << endl;
	}
}

Measured memory_bytes: 1284
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#pragma comment(linker, "/STACK:16777216")
#pragma warning( disable : 6031)
#include <climits>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <iostream>
#include <map>
#include <stack>
#include <set>
#include <queue>
#include <numeric>
#include <algorithm>
#include <utility>
#include <bitset>
#include <cmath>
#include <sstream>
#include <functional>
#include <iomanip>
#include <limits>

#define all(a) (a).begin(),(a).end()
#define sz(a) (int)(a).size()
#define eps (1e-9)
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector< vi > vvi;
typedef vector<double> vd;
typedef vector< vd > vvd;
typedef vector< string > vs;
typedef pair< int, int > pii;
typedef vector< pii > vpii;
typedef tuple<int, int, int> tiii;
const long long inf = 1e12;



int main()
{
#ifdef LOCAL_MACHINE
	freopen("input.txt", "rt", stdin);
	freopen("output.txt", "wt", stdout);
#endif
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); cout << setprecision(18) << fixed;
	int n;
	cin >> n;
	vi a(n);
	for (int i = 0; i < n; i++)
		cin >> a[i];
	int res = 0;
	for (int i = 1; i < n - 1; i++)
	{
		vi t(3);
		t[0] = a[i - 1];
		t[1] = a[i];
		t[2] = a[i + 1];
		sort(all(t));
		if (t[1] == a[i])
			res++;
	}
	cout << res;
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
 
using namespace std;
using ll = long long;
using pi = pair<int, int>;
using vi = vector<int>;
 
const ll linf = 1LL << 62;
const int inf = 99999999;
const int dx[4] = { 1,0,-1,0 };
const int dy[4] = { 0,1,0,-1 };
const ll atcoder = 1e9 + 7;
 
#define Endl endl
#define mp make_pair
#define all(v) v.begin(),v.end()
#define pb push_back
#define pr(x) cout << x << endl
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
#define rep(i,n) for(int i= 0;i<n;i++)
 
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T &val) {
	std::fill((T*)array, (T*)(array + N), val);
}
 
ll gcd(ll a, ll b) {//最大公約数
	if (a < b)swap(a, b);
	if (a%b == 0)return b;
	else gcd(b, a%b);
}
 
ll lcm(ll a, ll b) {//最小公倍数
	if (a < b)swap(a, b);
	return (a / gcd(a, b))*b;
}
 
int main() {
 
	int n;
	string t = "MARCH";
	ll a[5] = { 0 };
 
	cin >> n;
	rep(i, n) {
		string s;
		cin >> s;
		rep(j, t.length())if (s[0] == t[j])a[j]++;
	}
	ll ans = 0;
	for (int i = 0; i < 5; i++) {
		for (int j = i + 1; j < 5; j++) {
			for (int k = j + 1; k < 5; k++) {
				ans += a[i] * a[j] * a[k];
			}
		}
	}
 
	pr(ans);
 
	//system("pause");
	return 0;
}

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

int main()
{
    int a,b;
    cin >> a >> b;
    if(a<b){
        rep(i, b) cout << a;
    }else{
        rep(i, a) cout << b;
    }
    cout << endl;
}

Measured memory_bytes: 256
import math
import sys

def getinputdata():

    # 配列初期化
    array_result = []
    
    data = input()

    
    array_result.append(data.split(" "))

    flg = 1

    try:


        while flg:

            data = input()

            array_temp = []

            if(data != ""):
                
                array_result.append(data.split(" "))

                flg = 1

            else:

                flg = 0
    finally:


        return array_result





arr_data = getinputdata()

a = int(arr_data[0][0])
op = arr_data[0][1]
b = int(arr_data[0][2])


print(a+b if op=="+" else a-b)




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

using namespace std;

int n, a[100005];

int main() {
	scanf("%d", &n);
	
	for (int i = 0; i < n; i++) scanf("%d", &a[i]);
	
	int neg = 0;
	long long sum = 0;
	int mn = 2e9;
	bool zero = 0;
	
	for (int i = 0; i < n; i++) {
		if (a[i] < 0) {
			neg++;
		}
		sum += abs(a[i]);
		mn = min(mn, abs(a[i]));
		if (a[i] == 0) zero = 1;
	}
	
	if (neg % 2 == 0 || zero) return 0 * printf("%lld\n", sum);
	printf("%lld\n", sum - 2LL * mn);
}


Measured memory_bytes: 640
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    n=int(input())
    A=[int(_) for _ in input().split()]
    cunt,ans=0,0
    min_a=10**9
    for a in A:
        if a<0:
            cunt+=1
            ans+=-a
            min_a=min(-a,min_a)
        else:
            ans+=a
            min_a=min(a,min_a)
    if cunt%2==1:
        print(ans-2*min_a)
    else:
        print(ans)

if __name__=='__main__':
    main()

Measured memory_bytes: 14412
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define ll long long
using namespace std;
//typedef vector<unsigned int>vec;
//typedef vector<ll>vec;
//typedef vector<vec> mat;
typedef pair<int, int> P;
typedef pair<ll,ll> LP;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int INF = 1000000000;
const ll LINF = 1000000000000000000;//1e18
const ll  MOD = 1000000007;
const double PI = acos(-1.0);
const double EPS = 1e-10;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
//template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N, K;
    cin >> N >> K;
    vector<ll> A(N);
    REP(i,N) cin >> A[i];
    sort(A.begin(), A.end());
    auto f = [&](ll tar, ll a) -> ll{
        ll l = -1, r = N;
        while(r - l > 1){
            ll m = (r + l) >> 1;
            if(a * A[m] <= tar){
                if(a < 0) r = m;
                else l = m;
            }
            else{
                if(a < 0) l = m;
                else r = m;
            }
        }
        if(a < 0) return N - r;
        else return r;
    };

    ll l = -LINF, r = LINF;
    while(r - l > 1){
        ll m = (l + r) >> 1;
        ll cnt = 0;
        REP(i,N){
            cnt += f(m, A[i]);
            if(A[i] * A[i] <= m) cnt--;
        }
        cnt /= 2;
        if(cnt >= K) r = m;
        else l = m;
    }
    cout << r << endl;
}


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

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

    char c[110][110];
    for(int i = 0;i < h;i++) cin >> c[i];

    int four, two, one;
    four = two = one = 0;

    if(h % 2 == 1 && w % 2 == 1){
        one = 1;
        two = w/2 + h/2;
    }else if(h % 2 == 1){
        two = w/2;
    }else if(w % 2 == 1){
        two = h/2;
    }

    four = (h*w-two*2-one)/4;

    map<char, int> mp;
    for(int i = 0;i < h;i++){
        for(int j = 0;j < w;j++){
            mp[c[i][j]]++;
        }
    }

    for(int i = 'a';i <= 'z';i++){
        four -= mp[i]/4;
        mp[i] %= 4;
        if(four < 0){
            mp[i] += -four*4;
            four = 0;
        }
        two -= mp[i]/2;
        mp[i] %= 2;
        one -= mp[i];
    }

    if(four == 0 && two == 0 && one == 0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <sstream>
#include <map>
#include <set>

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1<<30
#define pb push_back
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int main() {
	vector<int> v(3);
	int a = 0, b = 0, c = 0, d = 0;

	while(cin >> v[0] >> v[1] >> v[2]) {
		sort(v.begin(), v.end());

		int d = v[0] * v[0];
		int e = v[1] * v[1];
		int f = v[2] * v[2];

		if(v[0] + v[1] <= v[2]) break;

		if(f < d + e) a++;
		else if(f == d + e) b++;
		else c++;
	}

	cout << a + b + c << " " << b << " " << a << " " << c << endl;
	return 0;
}

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

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

        int[] R = new int[N];
        for (int i = 0; i < N; i++) {
            R[i] = int.Parse(Console.ReadLine());
        }

        int min = R[0];
        int Max = R[1] - R[0];

        for (int i = 1; i < N; i++) {
            Max = Math.Max(Max, R[i] - min);
            min = Math.Min(min, R[i]);

            //Console.Write("i : " + i);
            //Console.Write(" min : " +min);
            //Console.WriteLine(" Max : " + Max);
        }

        Console.WriteLine(Max);
    }
}


Measured memory_bytes: 20296
#include <bits/stdc++.h>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
using namespace std; 
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }
const int INF = 1<<29;
typedef long long int ll;
inline int two(int n) { return 1 << n; }
inline int test(int n, int b) { return (n>>b)&1; }
inline void set_bit(int & n, int b) { n |= two(b); }
inline void unset_bit(int & n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res; }
template<class T> void chmax(T & a, const T & b) { a = max(a, b); }
template<class T> void chmin(T & a, const T & b) { a = min(a, b); }
const int MOD=1000000007;

bool isPowerOfTwo (ll x)  
{  
    return x && (!(x&(x-1)));  
}
bool isPrime(int n) 
{ 
    if (n <= 1)  return false; 
    if (n <= 3)  return true; 
    if (n%2 == 0 || n%3 == 0) return false; 
  
    for (int i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false; 
  
    return true; 
}
int highestPowerof2(unsigned int n) 
{ 
    // Invalid input 
    if (n < 1) 
        return 0; 
  
    int res = 1;
    for (int i=0; i<8*sizeof(unsigned int); i++) 
    { 
        int curr = 1 << i; 
        if (curr > n) 
           break; 
  
        res = curr; 
    } 
  
    return res; 
} 
long long binpow(long long a, long long b) {
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}
const int dx[] = {1,0,-1,0,1,1,-1,-1};
const int dy[] = {0,-1,0,1,1,-1,-1,1};
/*lcm(gcd(N1, M), gcd(N2, M), ..., gcd(Nk, M)) = gcd(lcm(N1, ..., Nk), M)
gcd(lcm(N1, M), lcm(N2, M), ..., lcm(Nk, M)) = lcm(gcd(N1, ..., Nk), M).

If gcd(N1, N2) = 1, then
gcd(N1·N2, M) = gcd(N1, M)·gcd(N2, M)
lcm(N1·N2, M) = lcm(N1, M)·lcm(N2, M)/M.

lcm(M, N, P) · gcd(M, N) · gcd(N, P) · gcd(P, M) = NMP · gcd(N, M, P).
*/
////////////////////////////////////////////////////////////////////

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);  
  cout.tie(NULL);
  int t=1;
  while(t--)
  {
    int n;string s;
    cin>>n>>s;
    ll ans=0;
    for(int i=0;i<1000;i++)
    {
        int c[3]={i/100,(i/10)%10,i%10};
        int f=0;
        REP(j,n)
        {
            if(s[j]==('0' + c[f]))f++;
            if(f==3)break;
        }
        if(f==3)ans++;
    }
    cout<<ans;
  }  
  return 0;
}
/* Look for:
* the exact constraints (multiple sets are too slow for n=10^6 :( )
* special cases (n=1?)
* 1LL<<i and not 1<<i
* overflow (int vs ll?)
* array bounds
* if you have no idea just guess the appropriate well-known algo instead of doing nothing :/
*/

Measured memory_bytes: 384
#include<stdio.h>
int main(){
  long long n,i,m=1e18;
  scanf("%lld",&n);
  for(i=1;i*i<=n;i++){
    if(n%i==0){
      if(m>i+n/i)m=i+n/i;
    }
  }
  printf("%lld\n",m-2);
  return 0;
}


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

using namespace std;
int max(int a , int b)
{
    if(a>=b)
    {
        return(a);
    }
    return(b);
}
int main()
{
    int a,b,c,i,j,n,m ;
	string str1,str2 ;
    cin>>str1>>str2 ;
    n = str1.size() ;
    m = str2.size() ;
    int lcs[n+1][m+1] ;
    string str = "" ;
    for(i=0 ; i<n+1 ; i=i+1)
    {
    	lcs[i][0] = 0 ;
	}
	for(j=0 ; j<m+1 ; j=j+1)
	{
		lcs[0][j] = 0 ;
	}
	for(i=1 ; i<n+1 ; i=i+1)
	{
		for(j=1 ; j<m+1 ; j=j+1)
		{
			if(str1[i-1]==str2[j-1])
			{
				lcs[i][j] = 1 + lcs[i-1][j-1] ;
			}
			else
			{
				lcs[i][j] = max(lcs[i-1][j],lcs[i][j-1]) ;
			}
		}
	}
	//cout<<lcs[n][m]<<endl ;
	for(i=n,j=m ;  ;)
	{
		
		if(lcs[i][j]==1+lcs[i-1][j-1] && str1[i-1]==str2[j-1])
		{
			str = str + str1[i-1] ;
			i = i - 1 ;
			j = j - 1 ;
		}
		else if(lcs[i][j]==lcs[i-1][j])
		{
			i = i - 1 ;
		}
		else
		{
			j = j - 1 ;
		}
		if(i<=0 || j<=0)
		{
			break ;
		}
	}
	for(i=str.size()-1 ; i>=0 ; i=i-1)
	{
		cout<<str[i] ;
	}
}

Measured memory_bytes: 35456
#import<cstdio>
int N,id[8<<15],dp[8<<15],x,i;main(){scanf("%d",&N);for(;i<N;id[x]=i,++i)scanf("%d",&x);x=N;for(;--i;)if(dp[i+1]){dp[i]=dp[i+1];if((id[i]<id[i+1])^(id[i+1]<id[x])^(id[x]<id[i])){++dp[i];x=i+1;}}else{dp[i]=dp[i + 1]+(id[i]>id[i+1]);if(id[i]<id[i+1])--x;}printf("%d",dp[1]);}

Measured memory_bytes: 1792
x, y = map(int, input().split())
ans = 0

if x == 3:
        ans += 100000
elif x == 2:
        ans += 200000
elif x == 1:
        ans += 300000

if y == 3:
        ans += 100000
elif y == 2:
        ans += 200000
elif y == 1:
        ans += 300000

if x == 1 and y == 1:
        ans += 400000

print(ans)


Measured memory_bytes: 3060
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
            int D = sc.nextInt();
            int T = sc.nextInt();
            int S = sc.nextInt();

            double d = (double)D;
            double s = (double)S;
            if ((d/s) <= T)
                System.out.println("Yes");
            else
                System.out.println("No");
    }
}

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

using namespace std;

using LL = long long;           using PII = pair<int, int>;
using ll = long long;           using DBL = double;
using VI = vector<int>;         using VD = vector<DBL>;
using VVI = vector<VI>;         using VVD = vector<VD>;
#define FOR(i,a,b) for(int i = a; i < b; i++)
#define REP(i,n) FOR(i,0,n)
#define SZ(a) ((int)((a).size()))
#define ALL(x) (x).begin(), (x).end()
#define SET(a,v) memset((a), (v), sizeof(a))
#define EB emplace_back #define PB push_back
#define MP make_pair  #define ST first  #define ND second

// #define trace(...) {__f(#__VA_ARGS__, __VA_ARGS__);}
// template<typename Arg> void __f(const char* name, Arg&& arg) {
//   cerr << name << " = " << arg << std::endl;
// } template <typename Arg1, typename... Args>
// void __f(const char* names, Arg1&& arg1, Args&&... args) {
//   const char* comma = strchr(names + 1, ',');
//   cerr.write(names, comma - names) << " = " << arg1<<" | ";__f(comma+1, args...); }
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds; // OST: find_by_order, order_of_key
// typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// #pragma GCC optimize("Ofast")
// optimize("unroll-loops")
// target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
// /*** RNGS ***/
// SEED=chrono::steady_clock::now().time_since_epoch().count();
// // or high_resolution_clock
// mt19937 rng(SEED); /*or*/ random_device rd; mt19937 rng(rd());
// uniform_int_distribution<> dis(MIN, MAX);// usage: dis(rng)
// struct chash {int operator()(int x) const {return x^SEED;}};
// gp_hash_table<int,int,chash>m;//use cc if very less updates
// /*** FAST IO ***/
// inline int scan(){ bool y=0; int x=0; char c=getchar_unlocked();
// while(c<'0'||c>'9'){ if(c=='-')y=1; c=getchar_unlocked();} 
// while(c>='0'&&c<='9'){x=(x<<1)+(x<<3)+c-'0';c=getchar_unlocked();}
// return y?-x:x; }

int dp[402][402], dp_sum[402][402], pwa[402][402];
int a[402], b[402];
const int MOD = 1000000007;

inline int diff(int a, int b) {
	return (a >= b ? a - b : a - b + MOD);
}

int sum(int a, int p) {
	int &y = dp_sum[a][p];
	if(y != -1) return y;
	if(a == 0) return y = 0;
	y = sum(a-1, p);
	y += pwa[a][p];
	if(y >= MOD) y -= MOD;
	return y;
}

int calc(int n, int c) {
	int &y = dp[n][c];
	if(y != -1) return y;
	if(n == 0) return y = (c == 0);
	y = 0;
	for(int i=0; i<=c; ++i) {
		y = (y + diff(sum(b[n], i), sum(a[n]-1, i)) * 1ll * calc(n-1, c-i)) % MOD;
	}
	return y;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int n, c;
	cin >> n >> c;
	for(int i=1; i<=n; ++i) {
		cin >> a[i];
	}
	for(int i=1; i<=n; ++i) {
		cin >> b[i];
	}
	for(int i=1; i<=400; ++i) {
		pwa[i][0] = 1;
		for(int j=1; j<=400; ++j) {
			pwa[i][j] = (pwa[i][j-1] * 1ll * i) % MOD;
		}
	}
	SET(dp, -1);
	SET(dp_sum, -1);
	cout << calc(n, c) << endl;
	return 0;
}

Measured memory_bytes: 2176
#include <iostream>

using namespace std;

int main() {
    int n, count = 0;
    bool ren = false;
    cin >> n;

    for (int i = 0; i < n; i++) {
        int tmp1, tmp2;
        cin >> tmp1 >> tmp2;
        if (tmp1 == tmp2) {
            count++;
        } else {
            count = 0;
        }

        // cout << count << endl;

        if (count >= 3) {
            ren = true;
        }
    }

    if (ren) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3632
if __name__ == '__main__':
    A, B, C, X = [int(input()) for x in range(4)]
    count = 0
    
    for A_coin in range(A + 1):
        
        for B_coin in range(B + 1):
            
            for C_coin in range(C + 1):
                
                if ((A_coin * 500) + (B_coin * 100) + (C_coin * 50)) == X: count += 1
                    
    print(count)

Measured memory_bytes: 3060
import sys
input = sys.stdin.readline

def main():
    n, d = map(int, input().split())
    x = [list(map(int, input().split())) for i in range(n)]
    ans = 0
    for i in range(n):
        for j in range(i+1, n):
            tmp = 0
            for k in range(d):
                tmp += (x[i][k] - x[j][k])** 2
            if (tmp ** 0.5).is_integer():
                ans += 1
    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
dleft = {}
dright = {}
count = 0
pre_right = None
n = int(input())

for i in range(n):
  x,l = list(map(int,input().split()))
  dleft[i+1] = x - l
  dright[i+1] = x + l

#print(dright)
sort_dright = sorted(dright.items(), key=lambda x:x[1])
#print(sort_dright)
for i in sort_dright:
  #print(pre_right)
  #print(dleft[i[0]])
  if pre_right is not None:
    if pre_right <= dleft[i[0]]:
      count += 1
      pre_right = dright[i[0]]
  else:
    count += 1
    pre_right = dright[i[0]]
print(count)

Measured memory_bytes: 36752
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define N 1000000007
#define pll pair<ll,ll>

int main() {

    ll n,k;
    cin>>n>>k;

    string s;
    cin>>s;

    ll a =  0;
    for(int i=1;i<n;i++) {
    	if(s[i]=='L' && s[i-1]=='L')
    		a++;
    	if(s[i]=='R' && s[i-1]=='R')
    		a++;
    }

    
    cout<<min(n-1,a+k*2)<<endl;

    return 0;
}


Measured memory_bytes: 512
using System;
namespace AtCoder
{
    class Program
    {
        static void Main()
        {
            var inp = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
            Console.WriteLine(Math.Abs(inp[2] - inp[0]) <= inp[3] || (Math.Abs(inp[1] - inp[0]) <= inp[3] && Math.Abs(inp[2] - inp[1]) <= inp[3]) ? "Yes" : "No");
        }
    }
}

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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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

const ll INF = 1e9;
const ll MOD = 1e9+7;
const ll LINF = 1e18;



signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  
  ll a,b,c; cin>>a>>b>>c;
  cout<<min(c,b/a)<<endl;
  
}

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

const int MAXN = 100;

int factors[MAXN + 1];
int is_prime[MAXN + 1];
vector<int> primes;

void sieve(int N){
	memset(is_prime, true, sizeof is_prime);
	is_prime[0] = false; is_prime[1] = false;
	for (int i = 2; i * i <= N; ++i){
		if (is_prime[i]){
			for (int j = i * i; j <= N; j+=i){
				is_prime[j] = false;
			}
		}
	}
	for (int i = 2; i <= N; ++i){
		if (is_prime[i]){
			primes.push_back(i);
		}
	}
}

int main(){
	int n; cin >> n;
	sieve(n);
	memset(factors, 0, sizeof factors);
	for (int i = 2; i <= n; ++i){
		int temp = i;
		while(temp > 1){
			for (int p : primes){
				while(temp % p == 0){
					temp /= p;
					factors[p]++;
				}
			}
		}
	}

	int answer = 0;
	for (int i = 0; i < (int)primes.size(); ++i){
		for(int j = 0; j < (int)primes.size(); ++j){
			for (int k = j + 1; k < (int)primes.size(); ++k){
				if (i == j or i == k) continue;
				int a = primes[i], b = primes[j], c = primes[k];
				if (factors[a] >= 2 and factors[b] >= 4 and factors[c] >= 4){
					answer++;
				}
			}
		}
	}
	
	for (int i = 0; i < (int)primes.size(); ++i){
		for (int j = 0; j < (int)primes.size(); ++j){
			if (i == j) continue;
			int a = primes[i], b = primes[j];
			if (factors[a] >= 2 and factors[b] >= 24) answer++;
			if (factors[a] >= 4 and factors[b] >= 14) answer++;
		}
	}
	
	for (int i = 0; i < (int)primes.size(); ++i){
		if (factors[i] >= 74) answer++;
	}
	cout << answer << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
		int h = sc.nextInt();
		int w = sc.nextInt();
		int magic[][] = new int[10][10];
		for (int i = 0; i < 10; i++) {
			for (int j = 0; j < 10; j++) {
				magic[i][j] = sc.nextInt();
			}
		}
		int ans[] = new int[10];
		for (int i = 0; i < 10; i++) {
			ans[i] = solve(magic, i);
		}
		int wall,sum = 0;
		for(int i = 0; i < h; i++) {
			for(int j = 0; j < w; j++) {
				wall = sc.nextInt();
				if(wall != -1) {
					sum += ans[wall];
				}
			}
		}
		System.out.println(sum);
	}

	private static int solve(int[][] magic, int start) {
		boolean[] fixed = new boolean[10];
		int[] distance = new int[10];
		Arrays.fill(distance, Integer.MAX_VALUE);
		distance[start] = 0;
		while (true) {
			int marked = minIndex(distance, fixed);
			if (marked == -1)
				break;
			fixed[marked] = true;
			if (fixed[1])
				break;
			for (int i = 0; i < 10; i++) {
				distance[i] = Math.min(distance[i], magic[marked][i] + distance[marked]);
			}
		}
		return distance[1];
	}

	private static int minIndex(int[] distance, boolean[] fixed) {
		int idx = 0;
		for (; idx < 10; idx++) {
			if (!fixed[idx])
				break;
		}
		if (idx == 10)
			return -1;
		int mindistance = distance[idx];
		for (int i = idx + 1; i < 10; i++) {
			if (mindistance > distance[i] && !fixed[i]) {
				mindistance = distance[i];
				idx = i;
			}
		}
		return idx;
	}
}


Measured memory_bytes: 44832
#include<iostream>

using namespace std;

int main()
{
    int a,b;

    cin>>a>>b;

    cout<<"a"<<" ";

    if(a>b)
    {
        cout<<">";
    }else if(a<b)
    {
        cout<<"<";
    }else
    {
        cout<<"==";
    }

    cout<<" "<<"b"<<endl;

    return 0;
}



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

int main()
{
    int n, rest_table[4][2][4] = {
        {{2, 3, 4, 6}, {2, 3, 4, 9}},
        {{6}, {3}},
        {{2, 4}, {3, 6}},
        {{2, 4, 6}, {2, 3, 4}}
    };
    scanf("%d", &n);
    if (n == 3)
    {
        printf("2 3 25\n");
        return 0;
    }
    for (int i = 0; i < n - 4; i += 4)
    {
        printf("%d %d %d %d ", i / 4 * 6 + 2, i / 4 * 6 + 3, i / 4 * 6 + 4, i / 4 * 6 + 6);
    }
    int quo_rest = n / 4 % 2, rest = n % 4;
    for (int i = 0; i < (rest + 3) % 4 + 1; i++)
    {
        if (i) printf(" ");
        printf("%d", (n - 1) / 4 * 6 + rest_table[rest][quo_rest][i]);
    }
    printf("\n");

    return 0;
}

Measured memory_bytes: 384
s=input()
k=int(input())
ans=["zzzzzz"]*k
for i in range(len(s)):
  for j in range(i,min(i+8,len(s))):
    A=s[i:j+1]
    if A>ans[k-1]:
      continue
    if A in ans:
      continue
    for ii in range(k):
      if A<ans[ii]:
        break
    for jj in range(k-1,ii,-1):
      ans[jj]=ans[jj-1]
    ans[ii]=A
print(ans[-1])

Measured memory_bytes: 3064
#include <bits/stdc++.h>
// iostream is too mainstream
#include <cstdio>
// bitch please
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <cmath>
#include <iomanip>
#include <time.h>
#define dibs reserve
#define OVER9000 1234567890123456789LL
#define ALL_THE(CAKE,LIE) for(auto LIE =CAKE.begin(); LIE != CAKE.end(); LIE++)
#define tisic 47
#define soclose 1e-8
#define chocolate win
// so much chocolate
#define patkan 9
#define ff first
#define ss second
#define abs(x) ((x < 0)?-(x):x)
#define uint unsigned int
#define dbl long double
#define pi 3.14159265358979323846
using namespace std;
// mylittledoge

typedef long long cat;

#ifdef DONLINE_JUDGE
	// palindromic tree is better than splay tree!
	#define catd I64d
#endif

int main() {
	cin.sync_with_stdio(0);
	cin.tie(0);
	cout << fixed << setprecision(10);
	cat C[4];
	for(int i = 0; i < 4; i++) cin >> C[i];
	cat N;
	cin >> N;
	N *= 4;
	for(int i = 0; i < 3; i++) C[i+1] = min(C[i+1], 2*C[i]);
	cat ans = 0;
	for(int i = 0; i < 4; i++) {
		cat n = (i == 3) ? (N>>i) : ((N>>i)&1);
		ans += n * C[i];
		N -= n * (1<<i);
	}
	cout << ans << "\n";
	return 0;}

// look at my code
// my code is amazing


Measured memory_bytes: 256
mod = 10**9 +7

n, k = map(int, input().split())
a = [list(map(int, input().split()))  for _ in range(n)]

def matmul_nn(a,b):
    #aもbもn*nの二次元リスト
    n = len(a)
    ret = [[0]*n for _ in range(n)]
    for i in range(n):
        for j in range(n):
            temp = 0
            for k in range(n):
                temp += a[i][k]*b[k][j]
                temp = temp % mod
            ret[i][j] = temp
    return ret

k_bin = str(bin(k))[2:]
k_bin = k_bin[::-1]
k_len = len(k_bin)

a_2 = [0]* k_len
a_2[0] = a

for i in range(1,k_len):
    a_2[i] = matmul_nn(a_2[i-1],a_2[i-1])

a_k = a_2[k_len-1]
for i in range(k_len-1):
    if( k_bin[i] == '1'):
        a_k = matmul_nn(a_k, a_2[i])

ans = 0
for i in range(n):
    ans += sum(a_k[i])
    ans = ans % mod

print(ans)


Measured memory_bytes: 44524
# -*- coding: utf-8 -*-
import sys
import math
from bisect import bisect_left
from bisect import bisect_right
import collections
import copy
import heapq
from collections import defaultdict
from heapq import heappop, heappush
import itertools
input = sys.stdin.readline

##### リストの 二分木検索 #####
# bisect_left(lists, 3)
# bisect_right(lists, 3)

##### プライオリティキュー #####
# heapq.heapify(a) #リストaのheap化
# heapq.heappush(a,x) #heap化されたリストaに要素xを追加
# heapq.heappop(a) #heap化されたリストaから最小値を削除＆その最小値を出力

# heapq.heappush(a, -x) #最大値を取り出す時は、pushする時にマイナスにして入れよう
# heapq.heappop(a) * (-1) #取り出す時は、-1を掛けて取り出すこと

##### タプルリストのソート #####
# sorted(ans) #(a, b) -> 1st : aの昇順, 2nd : bの昇順
# sorted(SP, key=lambda x:(x[0],-x[1])) #(a, b) -> 1st : aの昇順, 2nd : bの降順
# sorted(SP, key=lambda x:(-x[0],x[1])) #(a, b) -> 1st : aの降順, 2nd : bの昇順
# sorted(SP, key=lambda x:(-x[0],-x[1])) #(a, b) -> 1st : aの降順, 2nd : bの降順

# sorted(SP, key=lambda x:(x[1])) #(a, b) -> 1st : bの昇順
# sorted(SP, key=lambda x:(-x[1])) #(a, b) -> 1st : bの降順

def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))

def main():
	r = inputInt()

	a = r*r
	print(a)



if __name__ == "__main__":
	main()


Measured memory_bytes: 38384
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
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; }

ll MOD = 1000000007;
int n;
int a[50];

int kansu(int i,int m){
  if(m == 0){
    return 1;
  }
  if(i >= n){
    return 0;
  }
  int res = kansu(i+1,m) || kansu(i+1,m-a[i]);
  return res;
}

int main(void){
  cin >> n;
  rep(i,n){
    cin >> a[i];
  }
  int q; cin >> q;
  int m[q];
  rep(i,q){
    cin >> m[i];
  }
  for(int i = 0; i < q; i++){
    if(kansu(0,m[i])) cout << "yes" << endl;
    else cout << "no" << endl;
  }
  return 0;
}



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

int n;
int possible[22][22];
ll Sum[1<<21];
const ll M = 1e9 + 7;

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

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

  Sum[0] = 1;

  for (int S = 1; S < (1<<n); S++) {
    for (int i = 0; i < n; i++) {
      int w = __builtin_popcount(S);
      // w (-1) is the man being paired
      if (possible[w - 1][i]) {
        Sum[S] += Sum[S ^ (1 << i)];
        Sum[S] %= M;
      }
    }
  }

  ll res = Sum[(1<<n)-1];
  if (res < 0) res += M;
  cout<<res<<"\n";
}

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

int a[100000];
int main() {
	int n, t; scanf("%d%d", &n, &t);
	rep(i, n)scanf("%d", &a[i]);
	priority_queue<P>se;
	map<int, vector<P>>mp;
	for (int i = n - 2; i >= 0; i--) {
		se.push(P(a[i + 1], i + 1));
		mp[se.top().first - a[i]].push_back(P(i, se.top().second));
	}
	vector<P>v = (*mp.rbegin()).second;
	set<int>s[2];
	for (auto p : v) {
		s[0].insert(p.first);
		s[1].insert(p.second);
	}
	printf("%d\n", min(s[0].size(), s[1].size()));
}

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

int main()
{
    int N;
    cin >> N;
    vector<int> A(N);
    vector<int> B(N);
    rep(i, N) cin >> A[i];
    rep(i, N) cin >> B[i];
    int ans = 0;
    vector<int> C(N - 1);
    rep(i, N - 1) cin >> C[i];
    ans = accumulate(B.begin(), B.end(), 0);
    rep(i, N - 1)
    {
        if (A[i] == A[i + 1] - 1)
        {
            ans += C[A[i] - 1];
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>

int main(int argc, const char * argv[]) {
    int cards[4][13] = {{},{}};
    char marks[4] = {'S', 'H', 'C', 'D'};
    int n;
    std::cin >> n;
    char mark;
    int number;
    for (int i = 0; i < n && std::cin >> mark >> number; i++) {
        switch (mark)
        {
        case 'S' : cards[0][number - 1] = 1; break;
        case 'H' : cards[1][number - 1] = 1; break;
        case 'C' : cards[2][number - 1] = 1; break;
        case 'D' : cards[3][number - 1] = 1; break;
        default: continue;
        }
    }
    for (int j = 0; j < 4; j++) {
        for (int i = 0; i < 13; i++) {
            if (cards[j][i] == 0) {
                std::cout << marks[j] << " " << (i + 1) << std::endl;
            }
        }
    }
    return 0;
}

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

#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define MOD 1000000007

using namespace std;

typedef long long ll;

int main()
{
    int N;
    cin >> N;
    int xIn[N], yIn[N], hIn[N];
    int checkIndex;
    REP(i, N)
    {
        cin >> xIn[i] >> yIn[i] >> hIn[i];
        if (hIn[i] >= 1) checkIndex = i;
    }

    for (int x = 0; x <= 100; ++x)
    {
        for (int y = 0; y <= 100; ++y)
        {
            int h = hIn[checkIndex] + abs(x - xIn[checkIndex]) + abs(y - yIn[checkIndex]);
            bool isCorrect = true;
            REP(i, N)
            {
                if (i != checkIndex)
                {
                    if (max(h - abs(x - xIn[i]) - abs(y - yIn[i]), 0) != hIn[i])
                    {
                        isCorrect = false;
                        break;
                    }
                }
            }
            if (isCorrect)
            {
                cout << x << " " << y << " " << h << endl;
                return 0;
            }
        }
    }
}


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


using namespace std;


#define ll long long
#define mk make_pair
#define pb push_back
#define fi first
#define se second
#define all(x) x.begin(), x.end()
#define sz(x) (int) (x).size()


ll sum(int n);


void go(){
   int a,b;cin>>a>>b;
   string aa="";
   string bb="";
   for(int i=0;i<b;i++) {
		aa+=to_string(a);
   }
   for(int j=0;j<a;j++) {
		bb+=to_string(b);
   }
   string ans=aa>bb?bb:aa;
   cout << ans;
}
int main(){
   
   ios_base::sync_with_stdio(0);
   cin.tie(0);
   cout.tie(0);

   go();

   return 0;
}

ll sum(int n){                
   if(n == 0){
      return n;
   }else{
      return sum(n/10) + n%10;
   }
}


Measured memory_bytes: 256
h,w,k=map(int,input().split())
p=[sum(('11'in str(bin(j)))^1for j in range(1<<i))for i in range(8)]
dp=[w*[0]for _ in[0]*-~h]
dp[0][0]=1
for i in range(1,h+1):
    for j in range(w):
        t=u=0
        if j:
            t=p[max(0,j-2)]*p[max(0,w-j-2)]
            dp[i][j]+=dp[i-1][j-1]*t
        if j<w-1:
            u=p[max(0,j-1)]*p[max(0,w-j-3)]
            dp[i][j]+=dp[i-1][j+1]*u
        dp[i][j]=(dp[i][j]+dp[i-1][j]*(p[w-1]-t-u))%(10**9+7)
print(dp[-1][k-1])

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

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

const string al = "abcdefghijklmnopqrstuvwxyz";

void solve(void){
  ll n; cin >> n;

  string res = "";
  while(n > 0) {
    --n;
    res += al[n % 26];
    n /= 26;
  }

  reverse(res.begin(), res.end());
  cout << res << endl;
}

int main(void) {
  solve();
  return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define inf 1001001001
#define mod 1000000007
#define mod2 998244353
#define pi acos(-1)
#define all(x) (x).begin(),(x).end()
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; }

int main() {
    cin.tie(0); cin.sync_with_stdio(false);
    int p, q, r;
    cin >> p >> q >> r;
    cout << min(min(p + q, q + r), r + p) << endl;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int A,B,K;
    cin >> A >> B >> K;
  	int count = 0;

    while(true){
        if (A%2 == 1){
            A = A - 1;
          	B = B + A / 2;
            A = A / 2;
        }
        else{
            B = B + A / 2;
          	A = A / 2;
        }
      	count++;
      	if (count >= K){
        	break;
        }
      
		//cout << A << B << endl;

        if (B%2 == 1){
            B = B - 1;
          	A = A + B / 2;
            B = B / 2;
        }
        else{
            A = A + B / 2;
          	B = B / 2;
        }
      	count++;
      	if (count >= K){
        	break;
        }
      	//cout << A << " " << B <<endl;
    }
  	
  	cout << A << " " << B << endl;
}  

Measured memory_bytes: 256
import sys
from functools import lru_cache

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    S = readline().strip()
    N = len(S)

    ans = 0
    for bit in range(1 << (N - 1)):
        vec = []
        for i, s in enumerate(S):
            vec.append(s)
            if bit & (1 << i):
                vec.append('+')
        ans += sum(map(int, ''.join(vec).split('+')))

    print(ans)
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 9536
#include <bits/stdc++.h>
using namespace std;
#define     LL      long long int
vector<int>v,vv;

int main()
{
    int n,a[106],sum=0,num=0,m;
    cin>>n>>m;
    for(int i=0;i<n;i++){
        cin>>a[i];
        sum+=a[i];
    }
    for(int i=0;i<n;i++){
        if(a[i]*m*4>=sum){
            num++;
        }
    }
    if(num>=m){
        cout<<"Yes"<<endl;
    }
    else cout<<"No"<<endl;
     return 0;
}


Measured memory_bytes: 3608
#include<stdio.h>
int main(){
int N,x,c=0,x1=0;
scanf("%d",&N);
for(int i=0;i<N;i++)
{
scanf("%d",&x);
int ii=i+1;
printf("Case %d:\n",ii);
for(int j=0;j<10;j++)
{
x=x*x;
x1=x;c=1;

while((x1/10)>0){
x1=x1/10;c++;
//printf("%d",x1);
}
if(c<=2)x=0;
else if(c==3)x=x/100;
else if(c==4)x=x/100;
else if(c==5)x=x/100;
else if(c==6)x=x/100;
else if(c==7){x=x%1000000;x=x/100;}
else if(c==8){x=x%1000000;x=x/100;}
printf("%d\n",x);
}
}
return 0;

}

Measured memory_bytes: 1020
#include<bits/stdc++.h>
using namespace std;
int a,b;
int main()
{
	ios_base::sync_with_stdio(false);
	cin>>a>>b;
	int ans=0;
	if(a>0)ans=1;
	else if(b<0)
	{
		if((b-a+1)%2)ans=-1;
		else ans=1;
	}
	if(ans==1)cout<<"Positive"<<endl;
	else if(ans==0)cout<<"Zero"<<endl;
	else cout<<"Negative"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a[1000100];
int main()
{
	int n,k;scanf("%d%d\n",&n,&k);k=min(k,2*n+2+k);
	for (int i=1;i<=n;i++) a[i]=(getchar()=='A');a[n+1]=1;
	int now=1,rol=0;
	while (k--)
	{
		if ((a[now]^rol)) a[now]^=1;
		else
		{
			now++;if (now>n) now=1;
			rol^=1;
		}
	}
	for (int i=now;i<=n;i++) putchar((a[i]^rol)?'A':'B');
	for (int i=1;i<now;i++) putchar((a[i]^rol)?'A':'B');
}

Measured memory_bytes: 1280
n = int(input())
ans = [[] for i in range(n)]
for i in range(n):
    ss,pp = map(str,input().split())
    ans[i].append(ss)
    ans[i].append(int(pp))
    ans[i].append(i+1)
ans.sort(key=lambda x: (x[0],-x[1]))
for i in range(n):
    print(ans[i][2])

Measured memory_bytes: 3064