akhauriyash/Code-Regression huggingface dataset:
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列
using namespace std;

typedef long long ll;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000 //10^12
#define MOD 10000007 //10^9+7
#define MAXR 100000 //10^5:最大のrange(素数列挙などで使用)

int main(void){
    int n, a, b;
    cin >> n >> a >> b;
    string s;
    cin >> s;
    int x=0, y=0;
    REP(i, n) {
        if(s[i] == 'c' || x+y == a+b) {
            cout << "No" << endl;
            continue;
        }

        if(s[i] == 'a') {
            x++;
            cout << "Yes" << endl;
        } else if(s[i] == 'b'){
            if(y<b) {
                y++;
                cout << "Yes" << endl;
            }else {
                cout << "No" << endl;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 896
fn main(){
    let mut s=String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    let mut x:i32=s.trim().parse().unwrap();
    let y=x;
    let mut ans=0;
    while x>0{
        ans+=x%10;
        x/=10;
    }
    match y%ans{
        0 => print!("Yes"),
        _ => print!("No"),
    }
}

Measured memory_bytes: 4352
#include <iostream>
#include <cmath>
#include<cstdio>
#include<string>
#include<vector>
#include<iomanip>
using namespace std;


int main(){
    int n;
    cin >> n;
    int a[n];
    for (int i = 0; i < n; i++) cin >> a[i];
    int vm[n];
    vm[0] = a[0];
    int vm2[n];
    vm2[0] = 0;
    int frag = 0;
    for (int i = 1; i < n; i++){
        if (a[i] > vm[i-1]) {
            vm[i] = a[i];
            vm2[i] = vm[i-1];
            frag = 0;
        }
        else {
            vm[i] = vm[i-1];
            vm2[i] = vm2[i-1];
            if (a[i] > vm2[i-1]) {
                vm2[i] = a[i];
                frag = 1;
                }
        }
    }
    for (int i = 0; i < n; i++){
        if (vm[n-1] != a[i]) cout << vm[n-1] << endl;
        else  cout << vm2[n-1] << endl;
    }

    return 0;
}

Measured memory_bytes: 3968
#include <cstdio>
#include <climits>
#include <cassert>
#include <cmath>
#include <iostream>
#include <string>
#include <algorithm>
#include <numeric>
#include <functional>
#include <tuple>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <vector>
#include <iterator>
#include <regex>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define FOR(x,xs) for(auto &x: xs)

using namespace std;
typedef long long ll;
typedef pair<int,int> PI;
typedef pair<ll,ll> PL;
typedef vector<int> VI;
typedef vector<ll> VL;

template <class T, template <class, class> class C, class charT = char>
void vdump(const C<T, allocator<T>> &v, const charT* delimiter = ", ",
           ostream &stream = cout) {
  copy(v.begin(), v.end(), ostream_iterator<T>(stream, delimiter));
  stream << endl;
}

ll ext_gcd(ll a, ll b, ll &x, ll &y) {
  if(b == 0) {
    x = 1;
    y = 0;
    return a;
  }
  ll q = a / b;
  ll gcd = ext_gcd(b, a - q * b, x, y);
  ll z = x - q * y;
  x = y;
  y = z;
  return gcd;
}

constexpr ll MOD = 998244353;

int main() {
  ios::sync_with_stdio(false);
  int n;
  ll a, b, k;
  cin >> n >> a >> b >> k;
  VL fact(n+1);
  fact[0] = 1;
  REP(i,1,n+1) {
    fact[i] = (fact[i-1] * i) % MOD;
  }
  VL inv_fact(n+1);
  ll x, y;
  ext_gcd(fact[n], MOD, x, y);
  inv_fact[n] = (x + MOD) % MOD;
  for(int i=n-1; i>=0; i--) {
    inv_fact[i] = (inv_fact[i+1] * (i+1)) % MOD;
  }

  ll ans = 0;
  for(ll i=0; i<n+1; i++) {
    ll x = a * i;
    if(k - x < 0 || (k - x) % b != 0) {
      continue;
    }
    ll j = (k - x) / b;
    if(j > n) continue;
    ll ca = ((fact[n] * inv_fact[i]) % MOD * inv_fact[n-i]) % MOD;
    ll cb = ((fact[n] * inv_fact[j]) % MOD * inv_fact[n-j]) % MOD;
    ans = (ans + (ca * cb) % MOD) % MOD;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n,k,ans;
  cin>>n>>k;
  vector<int> vec(n);
  for (int i=0;i<k;i++){
    int d;
    cin>>d;
    for(int j=0;j<d;j++){
      int a;
      cin>>a;
      vec.at(a-1)=1;
    }
  }
  ans=0;
  for(int i=0;i<n;i++){
    if(vec.at(i)!=1){
      ans++;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3600
#ifndef LOCAL
#pragma GCC optimize("O3")
#endif
#include "bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
typedef long long ll;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set; 
int n , m ; 
vector<int> p ; 
int main(){
    fastio
    cin >> n >> m ;
    vector<vector<int> > g(n) ; 
    for(int i=0;i<m;i++){
    	int x , y ; 
    	cin >> x >> y ; 
    	x--,y-- ;
    	g[x].push_back(y);
    	g[y].push_back(x);
    }
    for(int &c : g[0]){
    	if ( c == n-1 ) {
    		puts("POSSIBLE");
    		return 0 ;
    	}
    	for(int &p : g[c]){
    		if ( p == n-1 ) {
    			puts("POSSIBLE");
    			return 0 ;
    		}
    	}
    }
    puts("IMPOSSIBLE");
    return 0 ;
}


Measured memory_bytes: 12016
#include <iostream>
#include <vector>
#define swap(type,x,y) do{type t=x;x=y;y=t;}while(0)
using namespace std;

struct Card{char suit,value;};

void BubbleSort(vector<Card> &c,int n){
  	int t;
	for(int i=0;i<n;i++){
    	for (int j=n-1;j>i;j--){
        	if (c.at(j).value<c.at(j-1).value){
          		swap(Card,c.at(j),c.at(j-1));
            }
        }  
    }
}

void SelectionSort(vector<Card> &c,int n){
      for(int i=0;i<n;i++){
      	int minj=i;
        for(int j=i;j<n;j++){
       		if(c.at(j).value<c.at(minj).value){
            	minj=j;
            }
        }
        swap(Card,c.at(i),c.at(minj));
       }
}
void print(vector<Card> c,int n){
	for(int i=0;i<n;i++){
    	cout<<c.at(i).suit<<c.at(i).value;
      	if(i!=n-1){cout<<" ";}
      	else{cout<<endl;}
    }
}

int main(){
	int n;cin>>n;
  	vector<Card> c1(n);
  	vector<Card> c2(n);
  	char ch;
  for(int i=0;i<n;i++){
  	cin>>c1.at(i).suit>>c1.at(i).value;
  }
  c2=c1;
  
  BubbleSort(c1,n);
  print(c1,n);
  cout<<"Stable"<<endl;
  
  SelectionSort(c2,n);
  print(c2,n);
  for(int i=0;i<n;i++){
  	if(c1.at(i).suit!=c2.at(i).suit){cout<<"Not stable"<<endl;return 0;}
  }
  cout<<"Stable"<<endl;
}


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

int main() {
	int n;
	while(cin >> n && n){
		long long sum = 1;
		int ans = 0;
		while(n >= 5){
			n /= 5;
			ans += n; 
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <map>
#include <set>

using namespace std;

#define Rep(i,a,b) for(int i = a; i < b; i++)
#define rep(i,b) Rep(i,0,b)
#define rrep(i,a) for(int i = a; i >= 0; i--)
#define allof(a) (a).begin(), (a).end()
#define pb push_back

typedef long long ll;
const int inf = 1e9+7;
const ll infll = 1 << 60LL;
const ll mod = 1e9 + 7;
// 0~3までは左右前後 4~7までは斜め
constexpr int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
constexpr int dy[] = { 0, -1, 0, 1, 1, -1, -1, 1 };

// 型による変数のオーバーフローに気をつけろ！！
// 悩んだら図やグラフを書け！！悩む前から書け！！

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

	int n, k;
	cin >> n >> k;
	vector<ll> x(n);
	rep(i, n) cin >> x[i];

	// 右と左どっちに行くか
	// 連続するk個のろうそくに火をつける
	ll time = inf;

	ll l;
	ll r; // r = l + k;

	rep(i, n) {
		l = i;
		r = l + k - 1;
		if (r >= n) break;

		ll _time;
		_time = abs(x[r] - x[l]) + abs(x[r]);
		time = min(time, _time);
		_time = abs(x[r] - x[l]) + abs(x[l]);
		time = min(time, _time);
	}

	cout << time << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
vector<int>v;
bool vis[100005];
int dfs(int u){
	if(u == 1)return 0;
	vis[u] = 1;
	if(vis[v[u]]){
		puts("-1");
		exit(0);
	}
	return dfs(v[u]) + 1;
}
int main(){
	//freopen("readin.txt","r",stdin);
	int n;
	scanf("%d",&n);
	for(int i = 0;i < n;i++){
		int a;
		scanf("%d",&a);
		v.push_back(--a);
	}
	printf("%d\n",dfs(0));
}

Measured memory_bytes: 892
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

struct node{
  int key;
  struct node *next,*previous;
};
typedef struct node Node;
void deleteNode(Node *);
Node *listSearch(int);
Node *nil;

void insert(int key){
  Node *node=(Node *)malloc(sizeof(Node));
  node->key=key;
  node->next=nil->next;
  nil->next->previous=node;
  nil->next=node;
  node->previous=nil;
}
void deleteKey(int key){
  deleteNode(listSearch(key));
}
void deleteLast(){
  deleteNode(nil->previous);
}
void deleteFirst(){
  deleteNode(nil->next);
}
void deleteNode(Node *t){
  if(t==nil)return;
  t->previous->next=t->next;
  t->next->previous=t->previous;
  free(t);
}
Node *listSearch(int key){
  Node *node=nil->next;
  while(node!=nil && node->key!=key){
    node=node->next;
  }
  return node;
}
void echoooo(void){
  Node *now=nil->next;
  while(1){
    if(now==nil)break;
    printf("%d",now->key);
    if(now->next!=nil)printf(" ");
    now=now->next;
  }
  printf("\n");
}
int main(void){
  //nd is node delete count
  int key,n,i;
  char command[12];
  //initialization
  nil=(Node *)malloc(sizeof(Node));
  nil->next=nil;
  nil->previous=nil;
  
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%s",command);
    if(command[0]=='i'){
      scanf("%d",&key);
      insert(key);
    }
    else if(command[0]=='d'){
      if(strlen(command)>6){
        if(command[6]=='F')deleteFirst();
        else if(command[6]=='L')deleteLast();
      }else {
        scanf("%d",&key);
        deleteKey(key);
      }
    }
  }

  echoooo();
  return 0;
}


Measured memory_bytes: 32988
N,M = map(int,input().split())

x = [0 for i in range(M)]
y = [0 for j in range(M)]
for k in range(M):
    x[k],y[k] = map(int,input().split())
    x[k] -= 1
    y[k] -= 1

ball = [1 for i in range(N)]
red = [0 for j in range(N)]
red[0] = 1

for i in range(M):
    ball[x[i]] -= 1
    ball[y[i]] += 1
    if red[x[i]] == 1:
        red[y[i]] = 1
    if ball[x[i]] == 0:
        red[x[i]] = 0

print(sum(red))

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

using namespace std;
using ll = long long;
using vi = vector<int>;
using ii = pair<int, int>;

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	string s, t;
	cin >> s >> t;
	int cnt = 0;
	for(int i = 0; i < min(s.size(), t.size()); i++){
		if(s[i] != t[i]) cnt++; 
	}
	cout << cnt << endl;
}




Measured memory_bytes: 3820
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func main() {
	s := bufio.NewScanner(os.Stdin)
	s.Scan()

	rgb := strings.Split(s.Text(), " ")
	r, _ := strconv.ParseInt(rgb[0], 10, 64)
	g, _ := strconv.ParseInt(rgb[1], 10, 64)
	b, _ := strconv.ParseInt(rgb[2], 10, 64)

	if (r*100+g*10+b)%4 == 0 {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}

}

Measured memory_bytes: 640
import java.util.Scanner;

public class Main {
	
	private void calc(){
		Scanner scanner = new Scanner(System.in);
		int x=scanner.nextInt();
		int y=scanner.nextInt();
		int z=scanner.nextInt();
		int count=0;
		for(int i=x; i<=y; i++){
			if(z%i==0){
				count++;
			}
		}
		System.out.println(count);
		
	}
	
	public static void main(String[] args) {
		Main run =new Main();
		run.calc();

	}	

}

Measured memory_bytes: 17232
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <utility>
#include <numeric>
#include <iterator>

using namespace std;

using ll = long long;
using ull = unsigned long long;

const ll inf = 1ll << 60;
const ll mod = (ll)1e9 + 7;

#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

#define print(s) cout << s;
#define println(s) cout << s << endl;
#define printd(s, f) cout << fixed << setprecision(f) << s << endl;


int main()
{
	ll x;
	cin >> x;

	println(bitset<32>(x));
	println(~bitset<32>(x));
	println((bitset<32>(x) << 1));
	println((bitset<32>(x) >> 1));
}


Measured memory_bytes: 3148
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<utility>

#define lli long long
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(),i.rend()
#define rep0(i,j) for(int i=0;i<j;i++)
#define rep1(i,j) for(int i=1;i<=j;i++)
#define rep0d(i,j) for(int i=j-1;i>=0;i--)
#define MAX 1000000007

using namespace std;


int main() {
	int n, a, b, c, d;
	cin >> n >> a >> b >> c >> d;
	char s[200005];
	int other = -1,brock=1;
	cin >> s;
	if (b < a && c < d) {
		for (int i = a - 1; i < c; i++) {
			if (s[i-1] == '.'&&s[i] == '.'&&s[i + 1] == '.')other = 1;
			if (s[i] == '#'&&s[i + 1] == '#') {
				brock = -1;
				break;
			}
		}
		for(int i=b-1;i<d-1;i++)if (s[i] == '#'&&s[i + 1] == '#') {
			brock = -1;
			break;
		}

	}
	else if (a < b && d < c) {
		for (int i = b - 1; i < d; i++) {
			if (s[i - 1] == '.'&&s[i] == '.'&&s[i + 1] == '.')other = 1;
			if (s[i] == '#'&&s[i + 1] == '#') {
				brock = -1;
				break;
			}
		}
		for (int i = a - 1; i < c - 1; i++)if (s[i] == '#'&&s[i + 1] == '#') {
			brock = -1;
			break;
		}
	
	}
	else {
		other = 1;
		for (int i = a - 1; i < c - 1; i++)if (s[i] == '#'&&s[i + 1] == '#') {
			brock = -1;
			break;
		}

		for (int i = b - 1; i < d - 1; i++)if (s[i] == '#'&&s[i + 1] == '#') {
			brock = -1;
			break;
		}
	}

	if (brock == -1 || other == -1)cout << "No";
	else cout << "Yes";
	return 0;
}


Measured memory_bytes: 384
w = gets.to_i
n = gets.to_i

a = []
b = []
n.times { |i|
	a[i], b[i] = gets.split(',').map(&:to_i)
}

r = []

w.times { |i|
	k = i + 1
	n.times{ |j|
		if a[j] == k then
			k = b[j]
		elsif b[j] == k then
			k = a[j]
		end
	}
	r[k-1] = i + 1
}

r.each{ |k| puts(k) }

Measured memory_bytes: 6100
N,M,X=map(int,input().split())
C=[list(map(int,input().split())) for _ in range(N)]

ans=inf=float('inf')
def dfs(idx,tt,l):
    global ans
    for i in range(idx,N):
        ntt=tt+C[i][0]
        nl=[l[j]+C[i][j+1] for j in range(M)]
        for x in nl:
            if x<X: break
        else:
            ans=min(ans,ntt)
        dfs(i+1,ntt,nl)
        
dfs(0,0,[0]*M)

print(ans if ans<inf else -1)


Measured memory_bytes: 9128
#include <bits/stdc++.h>
#define INF (1<<30)
#define MOD 1000000007
#define l_ength size
using ll = long long;
using namespace std;

int main(){
	string s; cin >> s;
	int ans = INF;
	for( char trg = 'a'; trg <= 'z'; ++trg ){
		string t = s;
		int cntmax = 0;
		int cnt = 0;
		for( auto c : t ){
			if( c != trg ){
				++cnt;
				cntmax = max(cnt, cntmax);
			} else {
				cnt = 0;
			}
		}
		ans = min(cntmax, ans);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<long long> vll;
typedef pair<int,int> pint;
typedef pair<long long, long long> pll;

#define MP make_pair
#define PB push_back
#define ALL(s) (s).begin(),(s).end()
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P) 
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P) 
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P) 
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }



string str;
string aidu = "AIDUNYAN", aizu = "AIZUNYAN";


bool same(string s) {
    sort(ALL(s));
    sort(ALL(aidu));
    
    return (s == aidu);
}

int main() {
    while (cin >> str) {
        int n = str.size();
        for (int i = 0; i <= n-8;) {
            string sub = str.substr(i, 8);
            if (same(sub)) {
                for (int j = 0; j < 8; ++j) str[i+j] = aizu[j];
                i += 8;
            }
            else ++i;
        }
        cout << str << endl;
    }
    
    return 0;
}


Measured memory_bytes: 1208
N,m=map(int,input().split())
M=3*N
DP=[[0]*(N+5) for i in range(M+5)]
DP[0][0]=1
for i in range(1,M+1):
    for j in range(N+1):
        DP[i][j]=(DP[i-1][j]+(M-i+1)*DP[i-2][j-1]+(M-i+1)*(M-i+2)*DP[i-3][j-1])%m
print(sum(DP[3*N][:N+1])%m)

Measured memory_bytes: 168552
function Main(input) {
  	input = input.split("\n");
  	var n = parseInt(input[0], 10);
  	s = input[1];
  	var char=new Array(26);
  	var l=new Array(26);
  	var r=new Array(26);
  	for (var i=0; i<26; i++){
      
      for (l[i]=0; l[i]<n; l[i]++){
          if (s.charCodeAt(l[i])==i+97){
           break; 
          }
      }
      
      for (r[i]=n; r[i]>=l[i]; r[i]+=-1){
          if (s.charCodeAt(r[i])==i+97){
           break; 
          }
       }
    }
  var counter;
  var max=0;
  for (var j=0;j<n;j++){
    counter=0;
    for (var k=0; k<26; k++){
      if (j>=l[k] && j<r[k]){
       counter++; 
      }
    }
    if (counter>max){
     max=counter; 
    }
  }
  console.log('%d',max);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
int INF = 1e9+7;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
signed main() {
    int M,D;
    cin >> M >> D;
    int ans = 0;
    for(int i = 1; i <= M; i++) {
        for(int j = 22; j <= D; j++) {
            if(j/10 <= 1 || j%10 <= 1) {
                continue;
            }
            if((j/10)*(j%10) == i) {
                ans++;
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3600
using System;

namespace atcoderA
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            int[] input = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            int A = input[0];
            int B = input[1];
            int C = input[2];
            Console.WriteLine((A + B) >= C ? "Yes" : "No");
        }
    }
}

Measured memory_bytes: 11092
#include <cstdint>
#include <iostream>

namespace null_null {

using i32 = std::int_fast32_t;
using i64 = std::int_fast64_t;
using u32 = std::uint_fast32_t;
using u64 = std::uint_fast64_t;
using usize = std::size_t;

} // namespace null_null

namespace null_null {

void main_() {
  i32 N;
  std::cin>>N;
  std::cout<<N*N*N<<std::endl;
}

} // namespace null_null

int main() {
  std::cin.tie(nullptr);
  std::ios::sync_with_stdio(false);
  null_null::main_();
  return 0;
}

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

int main(){
    int a[5];
    while(scanf("%d%d%d%d%d", a, a+1, a+2, a+3, a+4)!=EOF){
        int b = 0;
        for(int x = 0; x < 5; x++){
            b = b | (1 << (a[x]-1));
        }
        if( b == 1 || b == 2 || b == 4 || b == 7){
            printf("3\n3\n3\n3\n3\n");
        }else if( b == 3 ){
            for(int x = 0; x < 5; x++){
                printf("%d\n", (a[x]-1)?2:1);
            }
        }else if( b == 5 ){
            for(int x = 0; x < 5; x++){
                printf("%d\n", (a[x]-3)?2:1);
            }
        }else if( b == 6 ){
            for(int x = 0; x < 5; x++){
                printf("%d\n", (a[x]-2)?2:1);
            }
        }
    }
    return 0;
}

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

struct Puddle
{
  int start;
  int end;
  int area;
};

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

  stack<int> st;
  stack<Puddle> puddles;
  for (int i = 0; i < str.length(); i++)
  {
    if (str[i] == '\\')
      st.push(i);
    else if (str[i] == '/' && !st.empty())
    {
      int start = st.top();
      st.pop();

      Puddle cur = {start, i, i - start};

      while (!puddles.empty() &&
             start < puddles.top().start && puddles.top().end < i)
      {
        cur.area += puddles.top().area;
        puddles.pop();
      }

      puddles.push(cur);
    }
  }

  int sum_of_area = 0;
  int count = 0;
  string s = "";
  while (!puddles.empty())
  {
    Puddle p = puddles.top();
    puddles.pop();
    sum_of_area += p.area;
    s = to_string(p.area) + s;
    count++;

    if (puddles.empty())
      break;
    else
      s = " " + s;
  }

  cout << sum_of_area << endl;
  cout << count;
  if (s.length() > 0)
    cout << " " << s;
  cout << endl;
  return 0;
}

Measured memory_bytes: 3364
using System;
using System.Collections.Generic;
using System.Linq;
class Program{
	static bool?[] h;
	static long ans=0;
	static List<int>[] li;
	static void Main(){
		long[] s=Array.ConvertAll(Console.ReadLine().Split(),long.Parse);
		li=new List<int>[s[0]+1];
		h=new bool?[s[0]+1];
		for(int i=1;i<=s[0];i++){li[i]=new List<int>();}
		for(int i=0;i<s[1];i++){
			int[] q=Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
			li[q[0]].Add(q[1]);
			li[q[1]].Add(q[0]);
		}
		fu(1,true);
		if(ans==1){ans=s[0]*(s[0]-1)/2;}
		else{
			for(int i=1;i<=s[0];i++){
				if(h[i]==true){ans++;}
			}
			ans=ans*(s[0]-ans);
		}
		Console.WriteLine(ans-s[1]);
	}
	static void fu(int a,bool b){
		h[a]=b;
		for(int i=0;i<li[a].Count&&ans==0;i++){
			if(h[li[a][i]]==null){fu(li[a][i],!b);}
			else if(h[li[a][i]]==b){
				ans=1;
				break;
			}
		}
	}
}

Measured memory_bytes: 30728
#include"bits/stdc++.h"
using namespace std;


int main() {
	int n, k;
	string s;
	cin >> n >> k >> s;

	int cnt = 0;
	char pre = s[0];
	for (int i = 1;i < n;i++) {
		if (s[i] == pre) {
			cnt++;
		}
		else {
			pre = s[i];
		}
	}
	cout << min(n-1, cnt+2*k) << endl;
	
	return 0;
}


Measured memory_bytes: 512
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>

int main(){

    char parte_1[55],parte_2[55];
    int a,b,maior;
    scanf("%s",parte_1);
    scanf("%s",parte_2);

    a=strlen(parte_1);
    b=strlen(parte_2);

    if(a>b){
      maior=a;
    }else maior=b;

    for(int i=0;i<maior;i++){
      if(a!=0){
        printf("%c",parte_1[i]);
        a--;
      }

      if(b!=0){
        printf("%c",parte_2[i]);
        b--;
      }
    }
    puts("");
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define pb(a) push_back(a)
using namespace std;
typedef long long ll;

int main()
{
    int N, M;
    cin >> N >> M;
    vector<vector<int>> data(M);

    REP(i, M)
    {
        int k;
        cin >> k;
        REP(j, k)
        {
            int s;
            cin >> s;
            s--;
            data.at(i).pb(s);
        }
    }

    vector<int> p(M);
    REP(i, M)
    {
        cin >> p.at(i);
    }

    int ans = 0;
    REP(i, 1 << N)
    {
        bool ok = true;
        REP(j, M)
        {
            int c = 0;
            for (int id : data.at(j))
            {
                if ((i >> id) & 1)
                {
                    c++;
                }
            }
            if (c % 2 != p.at(j))
            {
                ok = false;
                break;
            }
        }
        if (ok)
        {
            ans++;
        }
    }

    cout << ans;
}

Measured memory_bytes: 256
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "iomanip"

using namespace std;

const long long int MOD = 1000000007;

long long int N, M, K, H, W, L, R;


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

	L = 0;
	R = 1000000001;
	cin >> N >> H >> W;
	vector<long long int>num(N);
	for (int i = 0; i < N; i++) {
		cin >> num[i];
	}
	while (R - L > 1) {
		long long int mid = (L + R + 1) / 2;
		long long int box = 0;
		for (auto i : num) {
			long long int bag = i - mid*W;
			if (bag < 0)continue;
			box += max((long long int)0, bag / (H - W) + !!(bag % (H - W)));
		}
		if (box > mid) {
			L = mid;
		}
		else {
			R = mid;
		}
	}
	cout << R << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
#define int long long
using namespace std;
vector<int>v[100009];
string s[100009];
int n,mod=1000000007;

int dfs(int now,int pre){
    //cout<<now<<endl;
    if(s[now][0]=='E'){
        int res=1;
        r(i,v[now].size()){
            int nex=v[now][i];
            if(nex==pre)continue;
            res*=dfs(nex,now);
            res%=mod;
        }
        if(s[now].size()==2)res++,res%=mod;
        //cout<<now<<' '<<res<<endl;
        return res;
    }
    if(s[now][0]=='A'){
        int res=0;
        r(i,v[now].size()){
            int nex=v[now][i];
            if(nex==pre)continue;
            res+=dfs(nex,now);
            res%=mod;
        }
        if(s[now].size()==2)res++;
        res%=mod;
        return res;
    }
    if(s[now][0]=='R'){
        int res=0,a[11],cnt=0;
        r(i,v[now].size()){
            int nex=v[now][i];
            if(nex==pre)continue;
            a[cnt++]=dfs(nex,now);
        }
        for(int i=0;i<(1<<cnt);i++){
            if(i==0)continue;
            int rex=1;
            r(j,cnt)if(i&(1<<j)){
                rex*=a[j];
                rex%=mod;
            }
            res+=rex;
            res%=mod;
        }
        //cout<<res<<endl;
        if(s[now].size()==2)res++,res%=mod;
        return res;
    }
}

signed main(){
    cin>>n;
    r(i,n)cin>>s[i];
    r(i,n-1){
        int a,b;
        cin>>a>>b; a--; b--;
        v[a].push_back(b);
        //v[b].push_back(a);
    }
    cout<<dfs(0,-1)<<endl;
}


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

using namespace std;

int main() {
  int n;
  scanf("%d", &n);
  vector<int> a(2 * n);
  for (int i = 0; i < n; ++i) {
    scanf("%d%d", &a[i * 2], &a[i * 2 + 1]);
  }
  sort(a.begin(), a.end());
  int ans = 0;
  for (int i = 0; i < n; ++i) {
    ans += min(a[i * 2], a[i * 2 + 1]);
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<algorithm>
#include<stdint.h>
#include<vector>
#include<string>
#include<time.h>
#include<random>
#include<bitset>
using namespace std;

using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;

struct edge {
	int l1;
	int l2;
	int color;
};
struct node {
	vector<int> link;
	int parent_color;
};

int main() {
	int n;
	cin >> n;
	vector<node> nod(n);
	vector<edge> ed(n - 1);
	for (int i = 0; i < n - 1; ++i) {
		int a, b;
		cin >> a >> b;
		ed[i].l1 = min(a-1, b-1);
		ed[i].l2 = max(a-1, b-1);
		ed[i].color = -1;
		nod[a - 1].link.push_back(i);
		nod[b - 1].link.push_back(i);//edのindex!!!!!!!!1
	}
	int ind = 0;
	int maxsize = 0;
	for (int i = 0; i < n; ++i) if (nod[i].link.size() > maxsize) {
		maxsize = nod[i].link.size();
		ind = i;
	}
	int colored_edge = 0;
	vector<int> s_st;
	for (int i = 0; i < maxsize; ++i) {
		int top = nod[ind].link[i];
		ed[top].color = i;
		++colored_edge;
		s_st.push_back(ed[top].l1 != ind ? ed[top].l1 : ed[top].l2);
		nod[s_st.back()].parent_color = i;
	}
	for (int i = 0; i < s_st.size() && colored_edge < n - 1; ++i) {
		int next_color = -1;
		for (int j : nod[s_st[i]].link) {
			if (ed[j].color != -1) continue;
			++next_color;
			if (next_color == nod[s_st[i]].parent_color) ++next_color;
			ed[j].color = next_color;
			++colored_edge;
			s_st.push_back(ed[j].l1 != s_st[i] ? ed[j].l1 : ed[j].l2);
			nod[s_st.back()].parent_color = next_color;
		}
	}
	cout << maxsize << endl;
	for (int i = 0; i < n - 1; ++i)cout << ed[i].color + 1 << endl;
	return 0;
}

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

#define F first
#define S second
#define P push
#define pb push_back
#define MEM(dp,i) memset(dp,i,sizeof(dp))
#define W while
#define R return
#define C continue
#define SI size()
#define ll long long
#define ld long double
#define pll pair<ll,ll>
#define pii pair<int,int>
#define SF(x) scanf("%Id",&x)
#define SF2(x,y) scanf("%Id%Id",&x,&y)
#define SF3(x,y,z) scanf("%I64d%I64d%I64d",&x,&y,&z)
#define SF4(x,y,z,o) scanf("%I64d%I64d%I64d%I64d",&x,&y,&z,&o)
#define all(v) v.begin(),v.end()

using namespace std;
const long long INF = 1e9;
const long long MOD = 1e9+7;
const int MX=100015;


int n;
int dp[3][1005];
int a[3][1005];
int DP(int x,int y){
    if(x==2)R 0;
    if(y==n)R 0;
    int &ret=dp[x][y];
    if(ret!=-1)R ret;
    ret=a[x][y];
    ret+=max(DP(x+1,y),DP(x,y+1));
    R ret;
}
int main()
{
    cin>>n;
    MEM(dp,-1);
    for(int i=0;i<2;i++){
        for(int j=0;j<n;j++)cin>>a[i][j];
    }
    cout<<DP(0,0);
}


Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;
use utils::*;

pub fn main() {
    let i = stdin();
    let mut o = Vec::new();
    run(i.lock(), &mut o);
    stdout().write_all(&o).unwrap();
}

fn run<R: BufRead, W: Write>(i: R, o: &mut W) {
    let mut i = CpReader::new(i);
    let n = i.read::<usize>();

    let mut edges = vec![Vec::new(); n];
    for _ in 0..n - 1 {
        let (u, v, w) = i.read3::<usize, usize, usize>();
        let (u, v, w) = (u - 1, v - 1, (w % 2) as u8);

        edges[u].push((v as u32, w));
        edges[v].push((u as u32, w));
    }
    fn go_next(p: usize, u: usize, d: u8, edges: &[Vec<(u32, u8)>], ds: &mut [u8]) {
        ds[u] = d;
        for &(v, w) in &edges[u] {
            let v = v as usize;
            if v != p {
                let d = d ^ w;
                go_next(u, v, d, edges, ds);
            }
        }
    }
    let mut ds = vec![0; n];
    go_next(0, 0, 0, &edges, &mut ds);
    for d in ds {
        writeln!(o, "{}", d).unwrap();
    }
}

mod utils {
    use super::*;

    pub struct CpReader<R: BufRead> {
        r: R,
        s: String,
    }

    macro_rules! fn_read {
        { $f:ident($($t:ident),*) } => {
            #[allow(dead_code)]
            pub fn $f<$($t: FromStr),*>(&mut self) -> ($($t),*) {
                let i = &mut self.read_line().split(' ');
                ($(read_next::<$t,_>(i)),*)
            }
        };
    }

    impl<R: BufRead> CpReader<R> {
        pub fn new(r: R) -> Self {
            CpReader {
                r: r,
                s: String::new(),
            }
        }
        pub fn read_line(&mut self) -> &str {
            self.s.clear();
            self.r.read_line(&mut self.s).unwrap();
            self.s.trim()
        }

        pub fn read<T: FromStr>(&mut self) -> T {
            self.read_line().parse().ok().unwrap()
        }
        fn_read! { read2(T1, T2) }
        fn_read! { read3(T1, T2, T3) }
        fn_read! { read4(T1, T2, T3, T4) }
        fn_read! { read5(T1, T2, T3, T4, T5) }
    }
    fn read_next<'a, T: FromStr, I: Iterator<Item = &'a str>>(i: &mut I) -> T {
        i.next().unwrap().parse().ok().unwrap()
    }

}


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

using namespace std;

#define rep(i, a, b)  for(int i = (a); i < (b); i++)
#define rrep(i, a, b) for(int i = (a); i > (b); i--)
#define sq(x) ((x) * (x))
#define bit(x) bitset<8>(x)
#define vsort(v)  sort(v.begin(), v.end())
#define rvsort(v) sort(v.begin(), v.end(), greater<int>())
#define debug(x) cout << #x << " " << (x) << endl
#define ln cout<< '\n'
#define pb push_back
#define fi first
#define se second
#define MOD 1e9+7

typedef long long int llint;
typedef pair<int, int> pii;
typedef pair<llint, llint> pll;
typedef vector<int> vi;
typedef vector<llint> vl;
typedef vector<pii> vii;
typedef vector<pll> vll;


template<typename Tn> Tn __lcm(Tn a, Tn b)
{
    return a / __gcd(a, b) * b;
}

int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};
//int dx[] = {0, 1, 1, 1, 0, -1, -1, -1};
//int dy[] = {-1, -1, 0, 1, 1, 1, 0, -1};

int main()
{
    int n, m, x;
    int c[13];
    int a[13][13];

    cin >> n >> m >> x;
    
    rep(i, 0, n) {
	cin >> c[i];
	rep(j, 0, m) {
	    cin >> a[i][j];
	}
    }

    int ans = -1;
    
    rep(i, 0, 2 << n) {
	int sum[13] = {};
	int val = 0;
	rep(j, 0, n) {
	    if(i & (1 << j)) {
		val += c[j];
		rep(k, 0, m) sum[k] += a[j][k];
	    }
	}

	//check
	rep(j, 0, m) {
	    if(x > sum[j]) break;
	    if(j == m - 1) {
		if(ans == -1) ans = val;
		else          ans = min(ans, val);
	    }
	}
    }

    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 3644
#include <iostream>
#include <cassert>
#include <algorithm>
#define N int(1e5+10)
using namespace std;

typedef int ti[3];
ti dt[N],f[N];

int main(int argc,char ** argv)
{
    int n;
    cin>>n;
    for(int i=0;i<n;++i){
        for(int j=0;j<3;++j){
            cin>>dt[i+1][j];
        }   
    }
    for(int i=1;i<=n;++i){
        for(int j=0;j<3;++j){
            for(int k=0;k<3;++k){
                if(j==k)continue;
                f[i][j]=max(f[i-1][k],f[i][j]);
            }
            f[i][j]+=dt[i][j];
        }
    }
    int ans=0;
    ans=max({f[n][0],f[n][1],f[n][2]});
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 5940
#include<stdio.h>

int main(){
    int N, R;
    int ans;

    scanf("%d%d", &N, &R);

    if( N >= 10 ){
        ans = R;
    }
    else{
        ans = R + 100*(10-N);
    }

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

    return 0;
}


Measured memory_bytes: 128
#include <iostream>

using namespace std;

int a[210];
int main(){
	int N;
	cin>>N;
	for(int i=0;i<N;i++){
		cin >> a[i];
	}
	
	int ans = 0;
	while(1){
		bool odd = false;
		for(int i=0;i<N;i++){
			if(a[i]%2 == 1) odd = true;
		}
		if(odd) break;
		ans++;
		for(int i=0;i<N;i++){
			a[i] /= 2;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
'''
Created on 2020/08/23

@author: harurun
'''
def main():
  from collections import Counter
  import sys
  pin=sys.stdin.readline
  pout=sys.stdout.write
  perr=sys.stderr.write

  ans=0
  N=int(pin())
  A=list(map(int,pin().split()))
  c=Counter(A)
  t=max(A)
  dp=[True]*t
  for i in A:
    if dp[i-1]:
      n=2*i
      while n<=t:
        dp[n-1]=False
        n+=i
  for k in A:
    if c[k]==1 and dp[k-1]:
      ans+=1
  print(ans)
  return
main()


Measured memory_bytes: 38368
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
#define Mod 1000000007
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<ll>; using VVI = vector<VI>; using VVVI = vector<VVI>;
#define INF 1234567890

ll n;
VVI g(202020);
vector<ll> s(202020,0);

void dfs(ll x,ll par){
    ll i;
    for(i=0;i<g[x].size();i++){
        if(g[x][i]==par) continue;
        s[g[x][i]]+=s[x];
        dfs(g[x][i],x);
    }
}

int main(){
    ll i,j;
    ll q;
    cin>>n>>q;
    for(i=0;i<n-1;i++){
        ll a,b;
        cin>>a>>b;
        a--;
        b--;
        g[a].pb(b);
        g[b].pb(a);
    }
    for(i=0;i<q;i++){
        ll p,x;
        cin>>p>>x;
        p--;
        s[p]+=x;
    }

    dfs(0,-1);

    for(i=0;i<n;i++){
        if(i==0) cout<<s[0];
        else cout<<" "<<s[i];
    }
    cout<<endl;
    return 0;
}

Measured memory_bytes: 24320
n = int(input())
a = [int(x) for x in input().split()]

dp = [[0 for _ in range(n+1)] for _ in range(n+1)]

for i in range(1, n+1):
    for l in range(n):
        if l+i > n:
            continue
        else:
            if i % 2 == n % 2:
                dp[l][l+i] = max(a[l]+dp[l+1][l+i], a[l+i-1]+dp[l][l+i-1])
            else:
                dp[l][l+i] = min(-a[l]+dp[l+1][l+i], -a[l+i-1]+dp[l][l+i-1])

print(dp[0][n])


Measured memory_bytes: 120284
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        long N = scan.nextLong();
        HashMap<Long, Long> factorizations = new HashMap<>();
        long current = N;
        for (long i = 2; i * i <= current; i++) {
            while (current % i == 0) {
                factorizations.merge(i, 1L, Long::sum);
                current /= i;
            }
        }
        if (current != 1) {
            factorizations.merge(current, 1L, Long::sum);
        }
        long ans = 0;
        for (long prime : factorizations.keySet()) {
            long count = factorizations.get(prime);
            long left = 1;
            long right = count;
            while (left <= right) {
                long mid = (left + right) / 2;
                if (mid * (mid + 1) <= 2 * count) {
                    left = mid + 1;
                } else {
                    right = mid - 1;
                }
            }
            ans += right;
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 35996
/*
    STARK_BOY
*/
#include <bits/stdc++.h>
#include <fstream>
using namespace std;
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define repe(i,a,b) for(ll i=a;i<=b;i++)
#define bac(i,a,b) for(ll i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef long long ll;
typedef vector< ll > vi;
typedef vector<pair<ll,ll> > vpii;
typedef pair<ll,ll> pii;
#define all(c) c.begin(),c.end()
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define PI           3.14159265358979323846  /* pi */
mt19937 rng32(chrono::steady_clock::now().time_since_epoch().count());
#define N 1000005
//Variables Start
ll inf=1e18,MOD=1e9+7;
//Variables End


void solve(){
	 string s,t;cin>>s>>t;
	 for(int i=0;i<s.length();i++){
		if(s[i]!=t[i]){
			cout<<"No"<<endl;
			return;
		}
	 }
	 cout<<"Yes"<<endl;
	 return;
}
int main()
{
    ios
    int ti=1;
    //cin>>ti;
    for(int i=1;i<=ti;i++)
    {
		solve();        
    }
    return 0;
        
}


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

int main(){
  int n,q;
  string s;
  cin >> n >> q >> s;
  string k;
  k='0'+s+'1';
  char a[q],b[q];
  for(int i=0;i<q;i++){
    cin >> a[i] >> b[i];
  }
  int l_1=-1,r_1=n+2;
  while(r_1-l_1>1){
    int mid=(r_1+l_1)/2;
    int x=mid;
    char c=k.at(x);
    for(int i=0;i<q;i++){
      if(a[i]==c){
        if(b[i]=='L'){
          x--;
          c=k.at(x);
        }
        else{
          x++;
          c=k.at(x);
        }
      }
    }
    if(c=='0'){
      l_1=mid;
    }
    else{
      r_1=mid;
    }
  }
  int l_2=-1,r_2=n+2;
  while(r_2-l_2>1){
    int mid=(r_2+l_2)/2;
    int x=mid;
    char c=k.at(x);
    for(int i=0;i<q;i++){
      if(a[i]==c){
        if(b[i]=='L'){
          x--;
          c=k.at(x);
        }
        else{
          x++;
          c=k.at(x);
        }
      }
    }
    if(c=='1'){
      r_2=mid;
    }
    else{
      l_2=mid;
    }
  }
  cout << r_2-r_1 << endl;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> h(N);
  for (int i = 0; i < N; ++i) {
    cin >> h[i];
  }
  
  int result = 0;
  while (true) {
    int l = N, r;
    int cnt = 0;
    bool flg = false;
    for (int i = 0; i < N; ++i) {
      int hi = h[i];
      if (0 < hi) {
        l = min(l, i);
        flg = true;
      }
      if (hi == 0 && flg) {
        r = i - 1;
        for (int j = l; j <= r; ++j) {
          --h[j];
        }
        ++result;
        break;
      } else if (i == N - 1 && flg) {
        r = i;
        for (int j = l; j <= r; ++j) {
          --h[j];
        }
        ++result;
      } else if (hi == 0) {
        ++cnt;
      }
    }
    if (cnt == N) {
      break;
    }
  }
  cout << result << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    int M,N,sum=0;//N:偶数

    scanf("%d %d",&N, &M);

    if(N >= 2){
        sum += N*(N-1)/2;
    }

    if(M >= 2){
        sum += M*(M-1)/2;
    }


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

    return 0;
}

Measured memory_bytes: 128
import java.util.LinkedList;
import java.util.Scanner;

/**
 * Created by sd on 2016/11/22.
 */
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        LinkedList<String> stack = new LinkedList<>();
        while(sc.hasNext()){
            String c = sc.next();

            switch(c){
                case "+":
                case "-":
                case "*":
                    int a = Integer.parseInt(stack.pop()), b = Integer.parseInt(stack.pop());
                    switch(c) {
                        case "+":
                            stack.push(a+b+"");
                            break;
                        case "-":
                            stack.push(-a+b+"");
                            break;
                        case "*":
                            stack.push(a*b+"");
                            break;
                    }
                    break;
                default:
                    stack.push(c);
                    break;
            }
//
//            for(int i=0; i<stack.size(); i++){
//                System.out.print(stack.get(i)+", ");
//            }
//            System.out.println();

        }
        System.out.println(stack.pop());

    }
}

Measured memory_bytes: 26212
#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define repreverse(i, start, end) for (long long i = start; i >= end; --i)
#define all(x) (x).begin(), (x).end()
#define len(x) ((long long)(x).size())
#define g(a, b) __gcd((a), (b))
#define l(a, b) ((a) / __gcd((a), (b)) * (b))
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vllvll = vector<vll>;
using pll = pair<ll, ll>;
template<class T>void print1d(T x,ll n=-1){if(n==-1)n=x.size();rep(i,0,n){cout<<x[i]<<' ';}cout<<'\n';}
template<class T>void print2d(T x,ll r=-1,ll c=-1){if(r==-1)r=x.size();if(c==-1)c=x[0].size();rep(i,0,r)print1d(x[i],c);}
template<class T, class U>bool haskey(T mp, U key) { return mp.find(key) != mp.end(); }
template<class T, class U>bool isin(T el, U container) { return find(all(container), el) != container.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; }
template<class T>ld deg2rad(T deg) { return M_PI * deg / 180.0; }
template<class T>ld rad2deg(T rad) { return 180.0 * rad / M_PI; }
ll intpow(ll a,ll n){ll p=1;while(n){if(n&1)p*=a;a*=a;n>>=1;}return p;}
const long double pi = M_PI;
const long long big = 1LL << 50;
const long long inf = 1LL << 60;
const long long mod = 1e9 + 7;



int main()
{
        ll N;
        string S;
        cin >> N >> S;
        ll left = count(all(S), '(');
        ll right = count(all(S), ')');

        stack<char> s1;
        stack<char> s2;
        ll cnt1 = 0;
        ll cnt2 = 0;
        rep(i, 0, N) {
                if (S[i] == '(') {
                        s1.push('(');
                } else if (not s1.empty()) {
                        ++cnt1;
                        s1.pop();
                }
        }

        repreverse(i, N-1, 0) {
                if (S[i] == ')') {
                        s2.push(')');
                } else if (not s2.empty()) {
                        ++cnt2;
                        s2.pop();
                }
        }
        string lp(right - cnt1, '(');
        string rp(left - cnt2, ')');
        cout << lp + S + rp << endl;
}


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

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

    cout<<a+a*a+a*a*a<<endl;
  
  return 0;
}


Measured memory_bytes: 3608
#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 a, b, c, k;
    cin >> a >> b >> c;

    cin >> k;
    while(k > 0){
        if(b <= a){
            b *= 2;
        }else if(c <= b){
            c *= 2;
        }        
        k--;
    }
    if(a < b && b < c){
        cout << "Yes" << endl;
    }  else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3616
#include <cstdio>
#define re register
inline int read() {
	int s = 0; char ch = getchar(), f = ' ';
	while(ch < '0' || ch > '9') { if(ch == '-') f = '-'; ch = getchar();}
	while(ch >= '0' && ch <= '9') s = (s << 3) + (s << 1) + (ch ^ 48), ch = getchar();
	return f == '-' ? -s : s;
}
const int Max = 120;
int n, a[Max], ans;
int main() {
	n = read();
	for(re int i = 1; i <= n; ++ i) a[i] = read();
	for(re int i = 1; i <= n; ++ i)
		for(re int j = 1; j <= n; ++ j)
			if(i != j)
				ans += a[i] * a[j];
	printf("%d", ans / 2);
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
using namespace std;
int main()
{
	int a, b, c, ans;
	for (int i = 0; i < 4; i++)
	{
		cin >> a >> b;
		if (a ==1)
		{
			ans = 6000 * b;
			cout << ans << endl;
		}
		if (a == 2)
		{
			ans = 4000 * b;
			cout << ans << endl;
		}
		if (a == 3)
		{
			ans = 3000 * b;
			cout << ans << endl;
		}
		if (a == 4)
		{
			ans = 2000 * b;
			cout << ans << endl;
		}
		
	}
}

Measured memory_bytes: 1160
#include <iostream>
#include <string>
#include <array>
#include <vector>
#include <list>
#include <deque>
#include <set>
#include <math.h>
#include <algorithm>

using namespace std;


int main() {

	int H, W, N;
	cin >> H >> W >> N;

	int r, c;
	cin >> r >> c;

	string S, T;
	cin >> S >> T;

	int R = c, L = c, D = r, U = r;

	auto Sitr = S.begin(), Send = S.end();
	auto Titr = T.begin(), Tend = T.end();
	for (; Sitr != Send; Sitr++, Titr++){
		switch (*Sitr) {
		case 'R':
			R++; break;
		case 'L':
			L--; break;
		case 'D':
			D++; break;
		case 'U':
			U--; break;
		}
		if (U < 1 ||
			D > H ||
			L < 1 ||
			R > W) {
			cout << "NO" << endl;
			return 0;
		}
		switch (*Titr) {
		case 'R':
			if (L < W)
			L++; break;
		case 'L':
			if (R > 1)
			R--; break;
		case 'D':
			if (U < H)
			U++; break;
		case 'U':
			if (D > 1)
			D--; break;
		}
	}


	cout << "YES" << endl;

	return 0;
}

Measured memory_bytes: 776