akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

# define rep(i, n) for(int(i)=0;(i)<(n);(i)++)
# define reps(i, n) for(int(i)=1;(i)<=(n);(i)++)
# define rrep(i, n) for(int i=((int)(n)); i>0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>=0; --i)
# define ALL(v) v.begin(), v.end()
template<class T>inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
typedef long long ll;

int main(){
  while (1) {
    int H,W; cin >> H >> W;
    if (H == 0 && W == 0) break;
    string p1, p2;
    rep(i,W) {
      if (i % 2 == 0) {
        p1 += "#";
        p2 += ".";
      } else {
        p1 += ".";
        p2 += "#";
      }
    }
    rep(i,H) {
      if (i % 2 == 0) {
        printf("%s\n", p1.c_str());
      } else {
        printf("%s\n", p2.c_str());
      }
    }
    printf("\n");
  }
  
}



Measured memory_bytes: 3204
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstring>
#include <cmath>
#define ll long long
using namespace std;
int main()
{
  ios_base::sync_with_stdio(0);
  ll arr[3];
  for(ll i=0;i<3;i++)
    cin >> arr[i];
  sort(arr,arr+3);
  if(arr[0]+arr[1]==arr[2])
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
while True:
    m, f, r = map(int, input().strip().split())
    if m == f == r == -1: break

    if m == -1 or f == -1 or m + f < 30:
        print('F')
    elif m + f >= 80:
        print('A')
    elif m + f >= 65:
        print('B')
    elif m + f >= 50:
        print('C')
    elif m + f >= 30:
        print('C' if r >= 50 else 'D')

Measured memory_bytes: 6724
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
#define fi first
#define se second
using namespace std;
#define int long long
typedef pair<int,int> P;
string s[3];
int c;
P ch(int p,int x){
  P a;a=P(0,0);
  r(i,10)if(c+i)if(s[0][p]=='?'||s[0][p]==i+'0')
    r(j,10)if(c+j)if(s[1][p]=='?'||s[1][p]==j+'0'){
      int t=i+j+x;
      if(s[2][p]!='?'&&t%10!=s[2][p]-'0')continue;
      if(t>9)a.fi++;
      else a.se++;
    }
  return a;
}
main(){
  while(cin>>s[0],s[0]!="0"){
    cin>>s[1]>>s[2];c=1;
    r(i,3)reverse(s[i].begin(),s[i].end());
    int sum1=1,sum2=0,t;
    r(i,s[0].size()){
      if(i==s[0].size()-1)c--;
      P a1,a2;t=0;
      a1=ch(i,0);
      a2=ch(i,1);
      t=sum1*a1.se+sum2*a2.se;
      sum2=sum1*a1.fi+sum2*a2.fi;
      sum1=t;
      sum1=sum1%1000000007;
      sum2=sum2%1000000007;
    }
    cout<<sum1<<endl;
  }
}

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

int a[8] = {128,64,32,16,8,4,2,1};

int main() {

    while(1){

        double d;

        cin >> d;

        if(d < 0.0){
            break;
        }

        if(d>256){
            printf("NA\n");
            continue;
        }

        int r = (int)d;

        double few = d-(double)r;

        string sfew;


        if(few == 0.0){
            sfew = "0000";
        }
        else if(few == 0.5){
            sfew = "1000";
        }
        else if(few == 0.25){
            sfew = "0100";
        }
        else if(few == 0.125){
            sfew = "0010";
        }
        else if(few == 0.0625){
            sfew = "0001";
        }
        else if(few == 0.1875){
            sfew = "0011";
        }
        else if(few == 0.3125){
            sfew = "0101";
        }
        else if(few == 0.5625){
            sfew = "1001";
        }
        else if(few == 0.375){
            sfew = "0110";
        }
        else if(few == 0.625){
            sfew = "1010";
        }
        else if(few == 0.75){
            sfew = "1100";
        }
        else if(few == 0.4375){
            sfew = "0111";
        }
        else if(few == 0.6875){
            sfew = "1011";
        }
        else if(few == 0.8125){
            sfew = "1101";
        }
        else if(few == 0.875){
            sfew = "1110";
        }
        else if(few == 0.9375){
            sfew = "1111";
        }
        else{
            printf("NA\n");
            continue;
        }

        sfew = "." + sfew;

        string sr;

        for(int i=0;i<8;i++){
            if(r>=a[i]){
                r -= a[i];
                sr += "1";
            }
            else{
                sr += "0";
            }
        }

        cout << sr << sfew << endl;





    }

    return 0;
}

Measured memory_bytes: 3096
#include <iostream>
#include <iomanip>
#include <string>
#include <map>
#include <utility>
#include <algorithm>
#include <math.h>

using namespace std;

#define ll long long

int main(){
    ll N, M;
    cin >> N >> M;
    ll A;
    for(ll i = 0; i < M; i++){
        cin >> A;
        N -= A;
    }
    cout << (N>=0?N:-1) << endl; 
    return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define RFOR(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define REP(i,n) FOR(i,0,(n))
#define REPS(i,n) FOR(i,1,(n)+1)
#define RREP(i,n) RFOR(i,0,(n))
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define DEBUG(x)  cout << #x << " = " << (x) << endl;
#define SORT(x) sort(ALL(x));
#define RSORT(x) sort(RALL(x));
#define SUM(x) accumulate(ALL(x),0);
#define FI first
#define SE second
#define PB push_back
#define EB emplace_back
#define SZ(x) (int)(x).size()
#define BN(x) ((1<<x)-1)
#define DUP(x,y) (((x)+(y)-1)/(y))
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const ll mod = 1e9+7;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//cout << fixed << setprecision(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; }

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

vi to[200005];
vi ans;

void dfs(int v, int p = -1) {
  for (int u : to[v]) {
    if (u == p) continue;
    ans[u] += ans[v];
    dfs(u,v);
  }
  return;
}

int main () {
  int N, Q; cin >> N >> Q;
  REP(i,N-1) {
    int a, b; cin >> a >> b;
    --a; --b;
    to[a].push_back(b);
    to[b].push_back(a);
  }

  ans.resize(N);
  REP(i,Q) {
    int p, x; cin >> p >> x;
    --p;
    ans[p] += x;
  }

  dfs(0);
  REP(i,N) {
    cout << ans[i] << endl;
  }
  
  return 0;
}

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

int main(){
  int n, k ,x, y;
  cin >> n >> k >> x >> y;
  
  int total = 0;
  for(int i=0; i<n;i++){
    if(i < k) total += x;
    else total += y;
  }
  
  cout << total << endl;
  
  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++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define REP(i, m, n) for (int i = (int)(m); i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
typedef long long ll;

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 long long INF = 1LL << 60;

int main(){
  int n, m;
  cin >> n >> m;
  vector<string> a(n), b(m);
  rep(i, n) cin >> a[i];
  rep(i, m) cin >> b[i];

  rep(i, n-m+1) rep(j, n-m+1){
    int cnt = 0;
    rep(k, m) rep(l, m){
      if(a[i+k][j+l] == b[k][l]){
        cnt++;
      }
    }
    if(cnt == m*m){
      cout << "Yes" << endl;
      return 0;
    }
  }

  cout << "No" << endl;

  return 0;
}


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

using namespace std;
using int_vec = vector<int>;

void heapify(int_vec& v, int i) {
    int max;

    auto h = v.size();
    auto l = i * 2 + 1;
    auto r = i * 2 + 2;
    if (l < h && v[l] > v[i]) {
        max = l;
    } else {
        max = i;
    }
    if (r < h && v[r] > v[max]) {
        max = r;
    }

    if (max != i) {
        swap(v[i], v[max]);
        heapify(v, max);
    }
}

void heapify(int_vec& v) {
    for (int i = v.size() / 2 - 1; i >= 0; --i) {
        heapify(v, i);
    }
}

int main() {
    int n;
    cin >> n;

    int_vec v;
    for (auto i = 0; i < n; ++i) {
        int x;
        cin >> x;
        v.push_back(x);
    }
    heapify(v);

    for (auto& a: v) {
        cout << " " << a;
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 4852
s = int(input())
a = [0] * 1000000
a[0] = s

for i in range(1,1000000):
  if a[i-1] % 2 == 0:
    a[i] = a[i-1]//2
  else:
    a[i] = a[i-1]*3+1
  if a[i] in a[:i]:
    print(i+1)
    exit()

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

#define rep(i, j) for (int i = 0; i < j; i++)
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<pii> vpii;

ll x(ll a, ll b) {
    if (a < b) swap(a, b);
    while (a % b > 0) {
        ll c = a % b;
        a = b;
        b = c;
    }
    return b;
}

ll y(ll a, ll b) {
    return a * b / x(a, b);
}

int main() {

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout << fixed;

    int n;
    cin >> n;
    vll t(n), a(n);
    rep(i, n) cin >> t[i] >> a[i];

    ll l = 1, r = 1;
    rep(i, n) {
        ll x = l / t[i];
        ll y = r / a[i];
        if (max(x, y) == 0) {
            l = t[i], r = a[i];
        } else {
            if (l % t[i] > 0) x++;
            if (r % a[i] > 0) y++;
            l = t[i] * max(x, y);
            r = a[i] * max(x, y);
        }
    }

    cout << l + r << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a , b , c;
  cin >> a >> b >> c;
  vector<int> hash;
  hash.push_back(a);
  hash.push_back(b);
  hash.push_back(c);
  sort(hash.begin(),hash.end());
  if(hash[0]==5 && hash[1]==5 && hash[2]==7){
    cout<<"YES";
  }
  else{
    cout<<"NO";
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;


void d_m_c()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}

char grid[1002][1002];

int power(int n, int x)
{
	if (x == 0)
		return 1;

	int small = power(n, x / 2) % mod;
	small = (small * small) % mod;

	if (1 & x)
		small = (n * small) % mod;

	return small;
}

bool isPowerOfTwo(int n)
{
	return n && (!(n & (n - 1)));
}

int numberOfPaths(int h, int w)
{
	int dp[h + 1][w + 1];
	memset(dp, 0, sizeof dp);

	dp[h][w] = 1;

	for (int i = h; i >= 1; i--)
	{
		for (int j = w; j >= 1; j--)
		{
			if (i == h && j == w)
				continue;
			if (grid[i][j] == '#')
				dp[i][j] = 0;
			else {
				if (i != h)
					dp[i][j] = (dp[i + 1][j] + dp[i][j]) % mod;
				if (j != w)
					dp[i][j] = (dp[i][j] + dp[i][j + 1]) % mod;
			}
		}
	}

	return dp[1][1];
}

double dp[400][400][400];
double solve(int x, int y, int z, int n)
{
	if (x < 0 || y < 0 || z < 0)
		return 0;
	if (x == 0 && y == 0 && z == 0)
		return 0;

	if (dp[x][y][z] > -0.9)
		return dp[x][y][z];

	double exp = n + x * solve(x - 1, y, z, n) + y * solve(x + 1, y - 1, z, n) + z * solve(x, y + 1, z - 1, n);

	return dp[x][y][z] = exp / (x + y + z);
}

int32_t main()
{
	//d_m_c();

	int n;
	cin >> n;

	int a, x = 0, y = 0, z = 0;
	memset(dp, -1, sizeof dp);

	for (int i = 1; i <= n; i++)
	{
		cin >> a;
		if (a == 1)
			x++;
		if (a == 2)
			y++;
		if (a == 3)
			z++;
	}

	cout << fixed << setprecision(10) << solve(x, y, z, n);

	return 0;
}

Measured memory_bytes: 500352
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(false), cin.tie(0);
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define endl '\n'

using namespace std;

main()
{
    fast;
    int a,b,x;
    cin>>a>>b>>x;
    if (x>=a && (x-a)<=b)
        cout<<"YES\n";
    else
        cout<<"NO\n";
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		int[] v = new int[n];
		int[] w = new int[n];
		for (int i = 0; i < n; i++) {
			String[] sa = br.readLine().split(" ");
			v[i] = Integer.parseInt(sa[0]);
			w[i] = Integer.parseInt(sa[1]);
		}
		int q = Integer.parseInt(br.readLine());
		int[] x = new int[q];
		int[] l = new int[q];
		for (int i = 0; i < q; i++) {
			String[] sa = br.readLine().split(" ");
			x[i] = Integer.parseInt(sa[0]);
			l[i] = Integer.parseInt(sa[1]);
		}
		br.close();

		int end = Math.min(1 << 11, n + 1);
		int[][] dp = new int[end][100001];
		for (int i = 1; i < end; i++) {
			int i1 = i - 1;
			int pre = i / 2;
			for (int j = 0; j <= 100000; j++) {
				dp[i][j] = dp[pre][j];
			}
			for (int j = 100000 - w[i1]; j >= 0; j--) {
				dp[i][j + w[i1]] = Math.max(dp[i][j + w[i1]], dp[i][j] + v[i1]);
			}
		}

		PrintWriter pw = new PrintWriter(System.out);
		for (int i = 0; i < q; i++) {
			List<Integer> list = new ArrayList<>();
			int now = x[i];
			while (now >= end) {
				list.add(now - 1);
				now /= 2;
			}
			int ans = dp[now][l[i]];
			int size = list.size();
			int end2 = 1 << size;
			for (int j = 0; j < end2; j++) {
				int vs = 0;
				int ws = 0;
				for (int j2 = 0; j2 < size; j2++) {
					if ((j >> j2 & 1) == 1) {
						vs += v[list.get(j2)];
						ws += w[list.get(j2)];
					}
				}
				if (ws <= l[i]) {
					int val = vs + dp[now][l[i] - ws];
					ans = Math.max(ans, val);
				}
			}
			pw.println(ans);
		}
		pw.flush();
	}
}


Measured memory_bytes: 931024
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
using namespace std;
int main()
{
    string s, s1;
    cin >> s >> s1;
    ll n = stoi(s + s1);
    for(ll i = 1; i <= 1000; i ++)
    {
        if(i * i == n)
        {
            cout << "Yes";
            return 0;
        }
    }
    cout << "No";
}


Measured memory_bytes: 256
using System.Linq;
using System.Text;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Security.Cryptography.X509Certificates;
using System.Diagnostics;
using System.Reflection.Metadata;
using System.Threading;

namespace AtCoder
{
    class Program
    {

        struct Point
        {
            public int x;
            public int y;

            public Point(int x, int y)
            {

                this.x = x;
                this.y = y;

            }

        }


        const int BiggestMod = 1000000007;

        public static void Main()
        {

            var args = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            int r = args[0], g = args[1], b = args[2];
            var ans = "No";

            for (int i = 0, l = int.Parse(Console.ReadLine()); i < l; i++)
            {

                if (g <= r)
                {

                    g <<= 1;

                }
                else if (b <= g)
                {

                    b <<= 1;

                }

                if (r < g && g < b)
                {

                    ans = "Yes";
                    break;

                }

            }

            Console.WriteLine(ans);

        }

    }

}

Measured memory_bytes: 28260
n,m=map(int,input().split())
a=list(map(int,input().split()))

summ = sum(a)
minn = summ/(4*m)
count = 0
for i in range(0,n):
  if a[i] >= minn:
    count = count + 1
    
if count >= m:
  print('Yes')
  
else:
  print('No')


Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
using namespace std;

long long snuke (long long i) {
	long long ans = 0LL;
	while (0LL < i) {
		ans += i % 10LL;
		i /= 10LL;
	}
	return ans;
}
int main ()
{
	long long k;
	cin >> k;

	long long x = 1LL;
	long a = 1LL;
	for (long long l=0; l<k; ++l) {
		cout << a << endl;
		while (a + x > x * snuke(a + x)) {
			x *= 10LL;
		}
		a += x;
	}	
	return 0;
}

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

typedef unsigned long long ll;

ll DENOM = 1000000000LL + 7LL;
using namespace std;

int main(){
    int k,n;
    cin >> n >> k;
    vector<int> a(n);
    for (int i=0; i<n; ++i) cin >> a[i];
    sort(a.begin(), a.end());
    int ret = 0;
    for (int i=0; i<k; ++i){
        ret += a[i];
    }
    cout << ret << endl;
}

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

typedef long long ll;

void dfs(const vector<vector<int>> &G, int p, int pre_p, vector<ll> &cnt){

    for(auto next_p: G[p]){
        if(next_p != pre_p){
            cnt[next_p] += cnt[p];
            dfs(G, next_p, p, cnt);
        }
    }
}

int main(){
    int N, Q;
    cin >> N >> Q;
    vector<vector<int>> G(N);

    for(int i = 0; i < N-1; i++){
        int a, b;
        cin >> a >> b;
        G[a-1].push_back(b-1);
        G[b-1].push_back(a-1);
    }

    vector<ll> cnt(N, 0);

    for(int i = 0; i < Q; i++){
        int p, x;
        cin >> p >> x;
        cnt[p-1] += x;
    }

    dfs(G, 0, -1, cnt);
    
    for(int i = 0; i < N; i++){
        cout << cnt[i] << ' ';
    }
}

Measured memory_bytes: 30464
program name
    implicit none
    integer(4):: k,i
    integer(4),allocatable:: r(:)
    character(1),allocatable:: ans(:)

    read*, k

    allocate(r(1))
    r(1) = 0


    do while(k > 0)
        k=k-1
        r(1) = up(1)
    end do


    allocate(ans(size(r)))
    do i=1,size(r)
        ans(size(r)-i+1) = char(r(i) + ichar('1')-1)
    end do
    print*, ans(:)
contains
recursive function up(k) result(ret)
    integer(4):: k
    integer(4):: ret
    integer(4),allocatable:: tmp(:)

    if (k+1 > size(r)) then
        if (r(k) <= 8) then
            ret = r(k)+1
            return
        else
            allocate(tmp(size(r)))
            tmp(:) = r(:)
            deallocate(r)
            allocate(r(size(tmp)+1))
            r(1:size(tmp)) = 0
            r(size(tmp)+1) = 1
            ret = 0
            deallocate(tmp)
            return
        end if
    end if
    
    if (abs(r(k)+1 - r(k+1)) <= 1) then
        if (r(k) <= 8) then
            ret = r(k)+1
            return
        else
            r(k+1) = up(k+1)
            ret = max(0,r(k+1)-1)
            return
        end if
        
    end if

! 繰り上がり
    r(k+1) = up(k+1)
    ret = max(0,r(k+1) -1)

end function

end program name

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

int A[100001];

int main(void) {

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

	bool ng = false;

	long long min = 2;
	long long max = 2;
	for (int i = K; i > 0; i--) {
		if (((min%A[i])==0)
		 || ((max%A[i])==0)
		 || ((min/A[i]) < (max/A[i]))) {
			max = max/A[i]*A[i] + A[i]-1;
			min = (min+A[i]-1)/A[i]*A[i];
		} else {
			ng = true;
			break;
		}
	}
	if (ng) {
		cout << -1 << endl;
	} else {
		cout << min << " " << max << endl;
	}
	return 0;
}


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

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() {
	int n, d;
	cin >> n >> d;

	int w = d * 2 + 1;
	int ans = (n+w-1)/w;
	
	cout << ans << endl;
}


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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) (x).begin(),(x).end()
#define endl "\n"

using ll = long long;
using P = pair<int,int>;
using mp =  map<int,int>;

const int MOD = 1e9 + 7;

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

    int n;
    cin >> n;
    string s;
    cin >> s;

    vector<ll> cnt(26, 0);
    rep(i, n){
        cnt[s[i] - 'a']++;
    }

    ll ans = 1;
    for (auto& p : cnt) {
        ans *= p+1;
        ans %= MOD;
    }
    ans--;
    ans %= MOD;
    cout << ans << endl;

    return 0;
}


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

using namespace std;

typedef long long ll;

const int INF = 1e9;

int main()
{
  int n, m, l;
  fscanf(stdin, "%d %d %d", &n, &m, &l);
  vector<vector<ll> > mat1(n, vector<ll>(m)), mat2(m, vector<ll>(l));
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      fscanf(stdin, "%lld", &mat1[i][j]);
    }
  }
  for (int i = 0; i < m; ++i) {
    for (int j = 0; j < l; ++j) {
      fscanf(stdin, "%lld", &mat2[i][j]);
    }
  }
  vector<vector<ll> > mat3(n, vector<ll>(l));
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < l; ++j) {
      for (int k = 0; k < m; ++k) {
        mat3[i][j] += mat1[i][k] * mat2[k][j];
      }
    }
  }
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < l; ++j) {
      if (j) { fprintf(stdout, " "); }
      fprintf(stdout, "%lld", mat3[i][j]);
    }
    fprintf(stdout, "\n");
  }
  return 0;
}

Measured memory_bytes: 1408
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>

using namespace std;

#define int long long
#define rep(i,n) for(int i = 0; i < (n); i++)
#define INF (long long)(1e18)
#define MOD (int)(1e9+7)

#define yn(f) ((f)?"Yes":"No")
#define YN(f) ((f)?"YES":"NO")

signed main(){
	cout<<fixed<<setprecision(7);
	
	int N, M;
	int ans = 0;
	
	cin>>N>>M;
	
	if(N*2 >= M){
		ans = M/2;
	} else {
		ans += N;
		M -= N*2;
		ans += M/4;
		
	}
	
	cout<<ans<<endl;
	
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
//#include <algorithm>
// #include <iomanip>
#define ll long long

using namespace std;

const int MOD = 1000000007;

int l[2005][2005];
int r[2005][2005];
int u[2005][2005];
int d[2005][2005];

int main() {
  int h, w;
  scanf("%d %d", &h, &w);

  string lines[h];
  for (int i = 0; i < h; i++) {
    string s;
    cin >> s;

    lines[i] = s;
  }

  for (int y = 0; y < h; y++) {
    int last_wall = -1;
    for (int x = 0; x < w; x++) {
      char ch = lines[y][x];
      if (ch == '.') {
        l[x][y] = (x - last_wall - 1);
        // cout << l[x][y] << endl;
      } else {
        last_wall = x;
      }
    }
  }

  for (int y = 0; y < h; y++) {
    int last_wall = w;
    for (int x = w - 1; x >= 0; x--) {
      char ch = lines[y][x];
      if (ch == '.') {
        r[x][y] = (last_wall - x - 1);
        // cout << r[x][y] << endl;
      } else {
        last_wall = x;
      }
    }
  }

  for (int x = 0; x < w; x++) {
    int last_wall = -1;
    for (int y = 0; y < h; y++) {
      char ch = lines[y][x];
      if (ch == '.') {
        u[x][y] = (y - last_wall - 1);
        // cout << u[x][y] << endl;
      } else {
        last_wall = y;
      }
    }
  }
  for (int x = 0; x < w; x++) {
    int last_wall = h;
    for (int y = h - 1; y >= 0; y--) {
      char ch = lines[y][x];
      if (ch == '.') {
        d[x][y] = (last_wall - y - 1);
        // cout << d[x][y] << endl;
      } else {
        last_wall = y;
      }
    }
  }

  ll ans = 0;
  for (int x = 0; x < w; x++) {
    for (int y = 0; y < h; y++) {
      if (lines[y][x] == '#') {
        continue;
      }
      ll sum = l[x][y] + r[x][y] + u[x][y] + d[x][y];
      ans = max(ans, sum);
    }
  }

  cout << ans + 1 << endl;
}


Measured memory_bytes: 67072
#include<stdio.h>
int main(void)
{
	int a, b, c;
	a = 0;
	b = 0;
	c = 0;
	scanf("%d %d %d", &a, &b, &c);
	if ((a < b) && (b < c)) {
		printf("Yes\n");
	}
	else {
		printf("No\n");
	}
	return 0;

}


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

int main() {
  string S; cin >> S;
  int L = S.size();
  string A = S.substr(0, L/2);
  string B = S.substr((L+1)/2);
  reverse(B.begin(), B.end());
  int cnt = 0;
  for (int i = 0; i < A.size(); i++) {
    if (A.at(i) != B.at(i)) cnt++;
  }
  cout << cnt << endl;
}

Measured memory_bytes: 256
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <bitset>		//UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>		//do setprecision
#include <ctime>
#include <complex>
#include <chrono>
#include<unordered_map>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)
#define ALL(u) (u).begin(),(u).end()

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double

typedef pair<int, int> PII;

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;

const int MR = 6400;
const int MS = 81;

bool dp[MS][MS][MR];

int A[MS][MS], B[MS][MS];

bool done[MS][MS];

void go(int w, int h)
{
	if (done[w][h])
		return;

	done[w][h] = 1;
	if (!w && !h)
	{
		dp[w][h][abs(A[0][0] - B[0][0])] = dp[w][h][abs(B[0][0] - A[0][0])] = 1;
		return;
	}

	int d1 = A[w][h] - B[w][h], d2 = B[w][h] - A[w][h];
	if (w)
	{
		go(w - 1, h);
		REP(i, MR)
			if (dp[w - 1][h][i])
			{
				if (abs(i + d1) < MR)
					dp[w][h][abs(i + d1)] = 1;
				if (abs(i + d2) < MR)
					dp[w][h][abs(i + d2)] = 1;
			}
	}
	if (h)
	{
		go(w, h - 1);
		REP(i, MR)
			if (dp[w][h - 1][i])
			{
				if (abs(i + d1) < MR)
					dp[w][h][abs(i + d1)] = 1;
				if (abs(i + d2) < MR)
					dp[w][h][abs(i + d2)] = 1;
			}
	}
}

int main()
{
	int W, H;
	scanf("%d%d", &H, &W);
	REP(i, H)REP(j, W)
		scanf("%d", &A[i][j]);
	REP(i, H)REP(j, W)
		scanf("%d", &B[i][j]);

	H--; W--;
	go(H, W);

	int res = MR;
	REP(i, MR)
		if (dp[H][W][i])
		{
			res = i;
			break;
		}

	printf("%d\n", res);

	return 0;
}

// FOR GNU C++ use the following pattern:
// Uncomment the code below and change your main into main2
// It does not build in MS C++
// But it does increase the stack size from 256 MB on CF and uses GNU C++

//#include <Processthreadsapi.h>
//#include <iostream>
//#include <Synchapi.h>
//#include <windows.h>
//#include <process.h>
//
//DWORD WINAPI MyThreadFunction(LPVOID lpParam) {
//    main2(nullptr);
//    return 0;
//}
//int main() {
//    auto h = CreateThread(nullptr, 1024 << 20, MyThreadFunction, nullptr, STACK_SIZE_PARAM_IS_A_RESERVATION, nullptr);
//    WaitForSingleObject(h, INFINITE);
//}

Measured memory_bytes: 41088
#include<bits/stdc++.h>
#define F first
#define S second
#define LL long long
#define MP make_pair
#define PB push_back
#define I insert

const LL mod=1000000007, N=200005;
using namespace std;

LL n, m, i, j, k, l, r, t, ans;
string s;

int main(){
	cin >> s;
	n = s.size();
	for ( i = 0; i < n; ++i ){
		if ( s[i] != s[n-i-1] ) {
			cout << "No\n";
			return 0;
		}
	}
	for ( i = 0; i < (n-1)/2; ++i ){
		if ( s[i] != s[(n-1)/2-i-1] ) {
			cout << "No\n";
			return 0;
		}
	}
	cout << "Yes\n";

	return 0;
}
//      IIIIIIIII      OOOOO             A          NN        N    EEEEEEEEEE
//          I         O     O           A A         N N       N    E
//          I        O       O         A   A        N  N      N    E
//          I        O       O        A     A       N   N     N    E
//          I        O       O       AAAAAAAAA      N    N    N    EEEEEEEE
//          I        O       O      A         A     N     N   N    E
//          I        O       O     A           A    N      N  N    E
//          I         O     O     A             A   N       N N    E
//      IIIIIIIII      OOOOO     A               A  N        NN    EEEEEEEEEE ___ KAPANADZE




Measured memory_bytes: 256
// Author: Vamsi Krishna Reddy Satti
// With love for Competitive Programming!
 
#include <bits/stdc++.h>
using namespace std;
 
#define fast_io ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
#define cout_precision cout.setf(ios::fixed); cout.precision(32);
 
using ll = int64_t; using vll = vector<ll>; using vvll = vector<vll>;
using pll = pair<ll, ll>; using vpll = vector<pll>; using vvpll = vector<vpll>;
using ld = long double;
 
// ------------------------------------------------------------------------------------------------

ll a, b;
char op;

int main() {
    fast_io; cout_precision;
    cin >> a >> op >> b;
    if (op == '+') {
        cout << a + b << endl;
    } else {
        cout << a - b << endl;
    }
}

Measured memory_bytes: 256
s=input()
t=input()
ans="zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz"
n=len(s)-len(t)+1
ok=0
#print(len(s))
#print(len(t))

i_set=[]

for i in range(n):
    count=0

    for j in range(len(t)):
        if t[j]==s[n-i-1+j] or s[n-i-1+j]=="?":
            count=count+1
#            print(i,t[j], s[n-i-1+j], count)
    if count==len(t):
#        print(i)
        ok=1
#        break
        i_set.append(i)
#if t in s:
#    print(s.replace("?","a"))

if ok==1:
    for i in i_set:
#        ans0=s[0:n-i-1]+t
        ans0=s[0:n-i-1]+t+s[n-i-1+len(t):]

        ans1=ans0.replace("?","a")
#        for i in range(len(s)-len(ans1)):
#            ans1=ans1+"a"
        if ans>ans1:
            ans=ans1
#        print(ans)
    print(ans)
else:
    print("UNRESTORABLE")



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

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;

const long long INF = 1LL << 60;
const long long MOD = 1000000007;

int main()
{
    string S;
    cin >> S;

    int len = (int)S.size();
    vector<vector<ll>> dp(len + 1, vector<ll>(4, 0));
    dp[0][0] = 1;

    rep(i, len) {
        rep(j, 4) {
            if (S[i] == '?') {
                dp[i + 1][j] += (dp[i][j] * 3) % MOD;
            }
            else {
                dp[i + 1][j] += dp[i][j];
            }
            dp[i + 1][j] %= MOD;
        }
        if (S[i] == 'A' || S[i] == '?') dp[i + 1][1] += dp[i][0];
        if (S[i] == 'B' || S[i] == '?') dp[i + 1][2] += dp[i][1];
        if (S[i] == 'C' || S[i] == '?') dp[i + 1][3] += dp[i][2];
        rep(j, 4) {
            dp[i + 1][j] %= MOD;
        }
    }

    cout << dp[len][3] << endl;
    return 0;
}

Measured memory_bytes: 7424
#include <iostream>

using namespace std;
typedef long long ll;
const int MAXN = 1e5+10;

int n;
ll k;
ll a[MAXN];
int bitCount[50];
void solve() {
  for (int i=0;i<n;i++) {
    int bit = 0;
    ll tmp = a[i];
    while (tmp > 0) {
      if (tmp & 1) {
        bitCount[bit]++;
      }
      tmp >>= 1;
      bit++;
    }
  }
  ll sum = 0;
  for (ll i=50;i>=0;i--) {
    ll bitV = 1LL << i;
    if (k >= bitV) {
      if (bitCount[i] * 2 < n) {
        k -= bitV;
        sum += (n - bitCount[i]) * bitV;
      } else {
        sum += (bitCount[i]) * bitV;
      }
    } else {
      sum += bitCount[i] * bitV;
    }
  }
  cout << sum << endl;
}

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


Measured memory_bytes: 1024
n = int(input())
s = [input() for i in range(n)]
 
ab = 0
a = 0
b = 0
 
d = 0
for i in s:
	d += i.count('AB')
	if i[0] == 'B' and i[-1] == 'A':
		ab += 1
	elif i[-1] == 'A':
		a += 1
	elif i[0] == 'B':
		b += 1
 
if ab == 0:
	d += min(a,b)
elif a+b == 0:
	d += ab-1
else:
	d += ab+min(a,b)
print (d)

Measured memory_bytes: 3828
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<cctype>
#include<climits>
#include<string>
#include<bitset>
#include<cfloat>
#include<iomanip>
#include<numeric>

//#define int long long
#define repi(i,start,end) for(int (i)=(start),TemPNuM=(int)(end);(i)<TemPNuM;++(i))
#define rep(i,end) repi((i),0,(end))
#define rfor(x,v) for(auto& (x) : (v))
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define fsort(v,lambda) sort(all((v)),(lambda))
#define vin(v) rep(i,(v).size())cin >> (v)[i];
#define vpin(v) rep(i,(v).size())cin>>v[i].first>>v[i].second

using namespace std;
using ll =  long long;
using pint =  pair<int,int>;
using vint = vector<int>;
using vvint = vector<vint>;
using vpint = vector<pint>;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class T>void put_double(T a){if(cout.precision()!=12)cout<<setprecision(12);cout<<a<<endl;}
template<class T>void print(T a){cout << a << endl;}
//lambda: [](int x, int y){return x<y;}

signed main(void) {
    int n; cin >> n;
    string s; cin >> s;
    int ans = 0, x = 0;
    rfor(c, s) {
        if(c == 'I') x++;
        else x--;
        chmax(ans, x);
    }
    print(ans);

    return 0;
}



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

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

  vector<string> t1(h);
  for (int i = 0; i < h; i++) {
    cin >> t1.at(i);
  }

  vector<string> t2;
  for (int i = 0; i < h; i++) {
    string row = t1.at(i);
    if (row.find("#") != string::npos) {
      t2.push_back(row);
    }
  }

  for (int i = (w - 1); i >= 0; i--) {
    bool erasing = true;
    for (int j = 0; j < (int)t2.size(); j++) {
      if (t2.at(j).at(i) == '#') {
        erasing = false;
      }
    }

    if (erasing == true) {
      for (int j = 0; j < (int)t2.size(); j++) {
        t2.at(j).erase(i, 1);
      }
    }
  }

  for (string row : t2) {
    cout << row << endl;
  }
  return 0;
}

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

ll N, M;
string S, T;

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

int main() {
    cin >> N >> M >> S >> T;

    ll L = N*M/gcd(N, M);
    
    bool f = true;
    for (ll i = 0; i < N; i++) {
        if (i*M % N == 0 && S[i] != T[i*M/N]) {
            f = false;
            break;
        }
    }

    cout << (f ? L : -1) << 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;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef set<int> si;
typedef map<string, int> msi;
typedef greater<int> gt;
typedef priority_queue<int, vector<int>, gt> minq;
typedef long long ll;
const ll INF = 1e18L + 1;
//clang++ -std=c++11 -stdlib=libc++ 

int main() {
  string s,t; cin >> s>> t;
  cout << t << s<<endl;
  return 0;
}

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

namespace abc157_b
{
  class Program
  {
    static void Main(string[] args)
    {
      var A = CIn.ReadIntArray(9);
      var N = CIn.ReadInt();
      var b = CIn.ReadIntArray(N);

      var f = A.Select(e => b.Contains(e)).ToArray();

      if ((f[0] && f[1] && f[2])
       || (f[3] && f[4] && f[5])
       || (f[6] && f[7] && f[8])
       || (f[0] && f[3] && f[6])
       || (f[1] && f[4] && f[7])
       || (f[2] && f[5] && f[8])
       || (f[0] && f[4] && f[8])
       || (f[2] && f[4] && f[6]))
      {
        Console.WriteLine("Yes");
      }
      else
      {
        Console.WriteLine("No");
      }
    }
  }

  static class CIn
  {
    private static readonly Queue<string> fieldBuffer = new Queue<string>();

    public static string Read()
    {
      if (fieldBuffer.Count == 0)
      {
        foreach (var field in Console.ReadLine().Split())
        {
          fieldBuffer.Enqueue(field);
        }
      }
      return fieldBuffer.Dequeue();
    }

    public static int ReadInt() => int.Parse(Read());
    public static long ReadLong() => long.Parse(Read());
    public static double ReadDouble() => double.Parse(Read());

    public static string[] ReadStringArray(int n)
    {
      var array = new string[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = Read();
      }
      return array;
    }

    public static int[] ReadIntArray(int n)
    {
      var array = new int[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = ReadInt();
      }
      return array;
    }

    public static long[] ReadLongArray(int n)
    {
      var array = new long[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = ReadLong();
      }
      return array;
    }

    public static double[] ReadDoubleArray(int n)
    {
      var array = new double[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = ReadDouble();
      }
      return array;
    }

    public static char[,] ReadCharMatrix(int h, int w)
    {
      var array = new char[h, w];
      for (var i = 0; i < h; i++)
      {
        var l = Console.ReadLine().ToCharArray();
        for (var j = 0; j < w; j++)
        {
          array[i, j] = l[j];
        }
      }
      return array;
    }
  }
}


Measured memory_bytes: 13524
S = input()
N = len(S)

ans = [0] * N
r_num = 0
r_idx, l_idx = -1, -1
for i in range(N-1):
    if S[i:i+2] == 'RL':
        r_idx = i
        l_idx = i+1
        ans[r_idx] += r_num//2 + 1
        ans[l_idx] += r_num//2 + 1
        if r_num % 2 == 1:
            ans[l_idx] += 1
        r_num = 0
    elif S[i] == 'R':
        r_num += 1
    elif S[i-1:i+1] != 'RL':
        if (i - r_idx) % 2 == 0:
            ans[r_idx] += 1
        else:
            ans[l_idx] += 1
if S[N-2:N] != 'RL':
    if (N-1 - r_idx) % 2 == 0:
        ans[r_idx] += 1
    else:
        ans[l_idx] += 1

for i in range(N):
    print(ans[i], end=' ')
print()


Measured memory_bytes: 51416
import java.util.*;
import java.util.Map.Entry;
import java.io.*;
import java.lang.reflect.Array;
import java.math.BigInteger;
import java.rmi.server.UnicastRemoteObject;

import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
 
public class Main{
    static long mod=1000000007;
//    static int dx[]={-1,0,1,0};
//    static int dy[]={0,-1,0,1};

    public static void main(String[] args)   throws Exception, IOException{        
        Reader sc = new Reader(System.in);
        PrintWriter out=new PrintWriter(System.out);

        int k=sc.nextInt();       
        int x=sc.nextInt();
        
        for (int i = x-k+1; i <= x+k-1; i++) {
            out.print(i+" ");			
		}
        
        out.println();
        out.flush();
    }



    static boolean validpos(int x,int y,int r, int c){
        return x<r && 0<=x && y<c && 0<=y;
    }

    static void db(Object... os){
        System.err.println(Arrays.deepToString(os));
    }
}

class P {
	int x, y;
	P(int  x, int y) {
	  this.x=x;
	  this.y=y;
	}
}


//class P {
//    int id, d;
//    P(int  id, int d) {
//        this.id=id;
//        this.d=d;
//    }
//}

//class P implements Comparable<P>{
//    int a,b;
//    P(int a, int b) {
//    	this.b=b;
//    	this.a=a;
//    }
//
//    public int compareTo(P p){
//        return b-p.b;
//    }
//}

class Reader
{ 
    private BufferedReader x;
    private StringTokenizer st;
    
    public Reader(InputStream in)
    {
        x = new BufferedReader(new InputStreamReader(in));
        st = null;
    }
    public String nextString() throws IOException
    {
        while( st==null || !st.hasMoreTokens() )
            st = new StringTokenizer(x.readLine());
        return st.nextToken();
    }
    public int nextInt() throws IOException
    {
        return Integer.parseInt(nextString());
    }
    public int[] nextIntArray(int size) throws IOException{
        int r[] = new int[size];
        for (int i = 0; i < size; i++) {
            r[i] = this.nextInt(); 
        }
        return r;
    }
    public long[] nextLongArray(int size) throws IOException{
        long r[] = new long[size];
        for (int i = 0; i < size; i++) {
            r[i] = this.nextLong(); 
        }
        return r;
    }
    public long nextLong() throws IOException
    {
        return Long.parseLong(nextString());
    }
    public double nextDouble() throws IOException
    {
        return Double.parseDouble(nextString());
    }
}


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

namespace test
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = ReadArrayInt();
            var N = input[0];
            var M = input[1];
            var l = 1;
            var r = N;
            for (int i = 0; i < M; i++)
            {
                input = ReadArrayInt();
                var L = input[0];
                var R = input[1];
                if (L > l) l = L;
                if (R < r) r = R;
            }
            var ans = N;
            if (l > r) ans = 0;
            else ans = r - l + 1;

            Console.WriteLine(ans);
            Console.ReadLine();
        }

        static string Read() { return Console.ReadLine(); }
        static int ReadInt() { return int.Parse(Read()); }
        static long ReadLong() { return long.Parse(Read()); }
        static int[] ReadArrayInt() { return Read().Split(' ').Select(s => int.Parse(s)).ToArray(); }
        static long[] ReadArrayLong() { return Read().Split(' ').Select(s => long.Parse(s)).ToArray(); }
    }
}

Measured memory_bytes: 17480
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.IOException;
import java.lang.NumberFormatException;
import java.util.NoSuchElementException;
import java.util.TreeMap;
public class Main {
  public static void main(String[] args) {
    Main m = new Main();
    m.run();
  }
  private void run() {
    final FastScanner fs = new FastScanner();
    int n = fs.nextInt();
    int[] a = new int[n];
    for (int i=0;i<n;i++) a[i] = fs.nextInt();
    TreeMap<Integer,Integer> t = new TreeMap<>();
    t.put(-1,0);
    for (int i=0;i<n;i++) {
      int k = t.lowerKey(a[i]);
      if (k >= 0) {
        int v = t.get(k);
        if (v == 1) {
          t.remove(k);
        } else {
          t.put(k,v-1);
        }
      }
      if (t.containsKey(a[i])) {
        t.put(a[i],t.get(a[i])+1);
      } else {
        t.put(a[i],1);
      }
    }
    int m = 0;
    for (int v : t.values()) m += v;
    System.out.println(m);
  }
}
class FastScanner {
  private final InputStream in = System.in;
  private final byte[] buffer = new byte[1024];
  private int ptr = 0;
  private int buflen = 0;
  private boolean hasNextByte() {
    if (ptr < buflen) return true;
    ptr = 0;
    try {
      buflen = in.read(buffer);
    } catch (IOException e) {
      e.printStackTrace();
    }
    if (buflen <= 0) return false;
    return true;
  }
  private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
  private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
  private void skipUnprintable() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
  public boolean hasNext() { skipUnprintable(); return hasNextByte();}
  public int nextInt() { return (int)nextLong();}
  public String next() {
    if (!hasNext()) throw new NoSuchElementException();
    StringBuilder sb = new StringBuilder();
    int b = readByte();
    while (isPrintableChar(b)) {
      sb.appendCodePoint(b);
      b = readByte();
    }
    return sb.toString();
  }
  public long nextLong() {
    if (!hasNext()) throw new NoSuchElementException();
    long n = 0L;
    boolean minus = false;
    int b = readByte();
    if (b == '-') {
      minus = true;
      b = readByte();
    }
    if (b < '0' || '9' < b) throw new NumberFormatException();
    while(true) {
      if ('0' <= b && b <= '9') {
        n *= 10;
        n += b - '0';
      } else if (b == -1 || !isPrintableChar(b)) {
        return minus ? -n : n;
      } else {
        throw new NumberFormatException();
      }
      b = readByte();
    }
  }
}

Measured memory_bytes: 37020
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

typedef long long ll;

#define INF 1000000009LL

ll dp[105][100005];//dp[i][j]:i番目の品物までを使って価値jを持つ重さの最小値

int main() {
  int N, W; cin >> N >> W;
  vector<ll> w(N), v(N);
  ll sum_v = 0;
  
  for (int i = 0; i < N; i++) {
    cin >> w[i] >> v[i];
    sum_v += v[i];
  }
  
  for (int i = 0; i <= N; i++) {
    for (int j = 0; j <= sum_v; j++) {
      dp[i][j] = INF;
    }
  }
  
  dp[0][0] = 0;
  for (int i = 0; i < N; i++) {
    for (int j = 0; j <= sum_v; j++) {
      if (j - v[i] >= 0) dp[i+1][j] = min(dp[i][j-v[i]] + w[i], dp[i][j]);
      else dp[i+1][j] = dp[i][j];
    }
  }
  
  ll res;
  for (int i = 0; i <= sum_v; i++) {
    if (dp[N][i] <= W) {
      res = i;
    }
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 80128
//abc068_b.cpp
//Wed Oct 31 22:41:24 2018

#include <iostream>
#include <string>
#include <queue>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;

int main(){
	int n;
	cin >> n;

	int ans = 1;
	while (ans <= n){
		ans *= 2;
	}

	cout << ans/2 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//NOT TO SUBMIT IN WRONG PLACE OR BY WRONG COMPILER
//ABC 131, task c, 2020/08/14
//ms,
/*
*/

int main(void){
  int64_t a, b, c, d;
  int64_t ans;
  int64_t c_divided, d_divided, cd_divided;
  int64_t lcm_cd;

  cin >>a >>b >>c >>d;
  ans = b-a+1;

  c_divided = b/c - a/c + 1 - min((int64_t)1, a%c);
  d_divided = b/d - a/d + 1 - min((int64_t)1, a%d);
  lcm_cd = c / gcd(c, d) * d;
  cd_divided = b/lcm_cd - a/lcm_cd + 1 - min((int64_t)1, a%lcm_cd);

  ans = ans - c_divided - d_divided + cd_divided;
  cout <<ans <<endl;
  return 0;
}
/*
余事象を使うんだ。ひっくり返す。
*/


Measured memory_bytes: 3608