akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

//School Road
public class Main{

	void run(){
		Scanner sc = new Scanner(System.in);
		while(true){
			int w = sc.nextInt();
			int h = sc.nextInt();
			if((w|h)==0)break;
			boolean[][] u = new boolean[h][w];
			int n = sc.nextInt();
			while(n--!=0){
				int a = sc.nextInt()-1;
				int b = sc.nextInt()-1;
				u[b][a] = true;
			}
			long[][] dp = new long[h][w];
			dp[0][0] = 1;
			for(int i=0;i<h;i++){
				for(int j=0;j<w;j++){
					if(u[i][j])continue;
					if(i>0)dp[i][j]+=dp[i-1][j];
					if(j>0)dp[i][j]+=dp[i][j-1];
				}
			}
			System.out.println(dp[h-1][w-1]);
		}
	}

	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 12000
import math
n,h=map(int,input().split())
a=sorted([list(map(int,input().split()))for i in range(n)],key=lambda x:x[1])[::-1]
r=0
d=0
p=0
k=float("inf")
while p<n:
    r+=a[p][1]
    d=max(d,a[p][0])
    k=min(k,p+1+math.ceil(max(0,(h-r))/d))
    p+=1
    if r>=h:
        break
print(k)

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

int main() {

    int n,k;
    cin >> n >> k;
    int h[n];
    for(int i=0; i<n; i++){
    	cin >> h[i];
    }
    sort(h, h+n, greater<int>());
    for(int i=0; i<n; i++){
    	if(k>0){
    		h[i] = 0;
    		k -= 1;
    	}
    }
    long ans = 0;
    for(int i=0; i<n; i++){
    	ans += h[i];
    }
    cout << ans << endl;
} 

Measured memory_bytes: 1024
NM = [int(i) for i in input().split()]
N, M = NM[0], NM[1]
cakes = [[int(i) for i in input().split()] for _ in range(N)]
ans = 0

for i in range(8):
    cakeList = []
    if i == 0:
        cakes.sort(key=lambda cake:cake[0]+cake[1]+cake[2])
    elif i == 1:
        cakes.sort(key=lambda cake:cake[0]+cake[1]-cake[2])
    elif i == 2:
        cakes.sort(key=lambda cake:cake[0]-cake[1]+cake[2])
    elif i == 3:
        cakes.sort(key=lambda cake:0-cake[0]+cake[1]+cake[2])
    elif i == 4:
        cakes.sort(key=lambda cake:cake[0]-cake[1]-cake[2])
    elif i == 5:
        cakes.sort(key=lambda cake:0-cake[0]+cake[1]-cake[2])
    elif i == 6:
        cakes.sort(key=lambda cake:0-cake[0]-cake[1]+cake[2])
    elif i == 7:
        cakes.sort(key=lambda cake:0-cake[0]-cake[1]-cake[2])
    cakes.reverse()

    x, y, z = 0, 0, 0
    for counta, cake in enumerate(cakes):
        if counta >= M:
            break
        x += cake[0]
        y += cake[1]
        z += cake[2]
    point = abs(x) + abs(y) + abs(z)

    if point > ans:
        ans = point
print(ans)

Measured memory_bytes: 3304
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)



int main(){
    int n, k;
    char dat[10000];
    REP(i, n) { dat[i] = 0; }
    cin >> n >> k;
    REP(i, k){
        int d;
        cin >> d;
        int a;
        REP(j, d){
            cin >> a;
            dat[a-1] = 1;
        }
    }
    int res = 0;
    REP(i, n){
        if(dat[i] == 0) { res++; }
    }
    cout << res << endl;
}



Measured memory_bytes: 3568
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

const ll INF = 1e16;
const int inf = 1e9;
ll MOD = 1e9+7;

struct mint {
    ll x; // typedef long long ll;
    mint(ll x=0):x((x%MOD+MOD)%MOD){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += MOD-a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= MOD;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    // for prime MOD
    mint inv() const {
        return pow(MOD-2);
    }
    mint& operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res/=a;
    }
};

ostream& operator << (ostream& os, const mint a) {
    os << a.x;

    return os;
}

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

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    
    ll N, K;
    cin >> N >> K;

    mint ans = 0;
    mint cm[K+1];
    for(int i=K; i > 0; --i) {
        cm[i] = mint(K / i).pow(N);

        for(int j=i+i; j <= K; j+=i) {
            cm[i] -= cm[j];
        }

        ans += cm[i] * i;
    }

    cout << ans << endl;
    
}


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

using namespace std;

#define all(x) x.begin(), x.end()
#define sz(x) (int) x.size()
#define pb push_back
#define endl '\n'
#define snd second
#define fst first
#define fastio cin.tie(NULL),cout.sync_with_stdio(true)

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

const int mod = 1e9 + 7;
const ll INF = (1LL<<50);
const double EPSILON = 0.001;
const int N = 100005;
int main(){
	fastio;
	int n;
	cin >> n;
	while(n--){
		cout << "ACL";
	}cout << endl;
	return 0;
}


Measured memory_bytes: 3636
loop do
  name,type = gets.split
  break if type =='X'
  if name.include?('_')
    words = name.split('_')
  else
    name.gsub!(/([A-Z])/,' \1')
    words = name.split
  end
  case type
  when 'U'
    puts  words.map(&:capitalize).join
  when 'L'
    words.map!(&:capitalize)
    words[0].downcase!
    puts words.join
  when 'D'
    words.map!(&:downcase)
    puts words.join('_')
  end
end

Measured memory_bytes: 2476
#include <bits/stdc++.h>
#define rep(i,l,n) for(int i=l;i<n;i++)
#define rer(i,l,n) for(int i=l;i<=n;i++)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int,int> pii;

int main(){
	int l;
	char c;
	string s;
	while(cin>>s){
		rep(i,0,s.size()){
			if(s[i]=='@'){
				l=s[i+1]-'0'; c=s[i+2];
				s.replace(i,3,l,c);
			}
		}
		o(s);
	}
}

Measured memory_bytes: 1192
#include<cstdio>
int main(){
    double d;
    while(scanf("%lf",&d)!=-1){
        double sum=d;
        for(int i=2;i<=10;i++){
            if(i%2==0) d*=2;
            else d/=3;
            sum+=d;
        }
        printf("%lf\n",sum);
    }
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define ll long 
 
using namespace std;
 
main(){
    int n,m=0,c=0;
    cin>>n;
    int a[n+1];
    for(int i=1;i<=n;i++){
        cin>>m;
        a[m]=i;
    }
    for(int i=1;i<=n;i++) cout<<a[i]<<" ";
    return 0;
}

Measured memory_bytes: 1152
import java.util.*;

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

        int N = sc.nextInt();
        int i, j = 0;
        i = N;
        while(i>0){
            j = j + i%10;
            i = i/10;
        }
        if(N%j == 0){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 21716
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <cassert>
#include <cstdarg>
#include <sys/time.h>
#include <fstream>
//#include "cout.h"

using namespace std;

#define SZ(x) ((int)x.size())
#define MSET(x,a) memset(x, a, (int)sizeof(x))
#define PB push_back
#define VI vector < int >
#define PII pair < int, int >
#define LL long long
#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(), (v).end()
#define FIT(it,v) for (__typeof((v).begin()) it = (v).begin(); it != (v).end(); it++)
#define OUT(A) cout << #A << " = "<< (A) << endl
#define OUT2(A, B) cout << "(" << #A << ", " << #B << ") = (" << (A) << ", "<< (B) << ")" << endl
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }

#define present(c, e) ((c).find((e)) != (c).end())
#define cpresent(c, e) (find(ALL(c), (e)) != (c).end())


void solve() {
  int n, k;
  cin >> n >> k;
  int now = (n-1)*(n-2)/2;
  if (k > now) {
    cout << -1 << endl;
    return;
  }
  cout << (n-1) + now-k << endl;
  FOR(i, 1, n) cout << 1 << " " << i+1 << endl;
  FOR(i, 1, n) FOR(j, i+1, n) {
    if (now == k) continue;
    cout << i+1 << " " << j+1 << endl;
    now--;
  }
}

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


Measured memory_bytes: 256
def f(n):
    a = []
    while n > 0:
        n -= 1
        a.append(chr(ord('a') + n % 26))
        n //= 26
    return a

if __name__ == "__main__":
    n = int(input())
    a = f(n)
    print(''.join(a[::-1]))


Measured memory_bytes: 9128
#テストファイルで実行する時
import sys
if sys.platform =='ios':
    sys.stdin=open('input_file.txt')
    

n = int(input())
t = list(map(int,input().split()))
m = int(input())
p = [list(map(int,input().split())) for i in range(m)]

#print(p)
#print(p[0][0])
#print(p[1][1])

#リストのコピーをするとき 
import copy

for i in range(m):
	test = copy.copy(t)#リストのコピー
	test[p[i][0]-1] = p[i][1]
	#print(t)
	#print(test)
	print(sum(test))




Measured memory_bytes: 3568
#include <iostream>
#include <vector>
#include <unordered_map>
using namespace std;
#define repeat(i,n) for (int i = 0; (i) < (n); ++(i))

unordered_map<int,int> memo;
int rec(int used, vector<vector<bool> > const & e, vector<int> const & c) {
    if (memo.count(used)) return memo[used];
    int n = e.size();
    vector<int> top;
    repeat (i,n) if (not (used & (1 << i))) {
        bool ok = true;
        repeat (j,i) if (not (used & (1 << j))) {
            if (e[j][i]) {
                ok = false;
                break;
            }
        }
        if (ok) top.push_back(i);
    }
    int result = 0;
    repeat (ti,top.size()) {
        int i = top[ti];
        repeat (tj,ti) {
            int j = top[tj];
            if (c[i] == c[j]) {
                result = max(result, rec(used ^ (1<<i) ^ (1<<j), e, c) + 2);
            }
        }
    }
    return memo[used] = result;
}
int solve(vector<vector<bool> > const & e, vector<int> const & c) {
    memo.clear();
    return rec(0, e, c);
}

template <typename T>
T sq(T x) { return x*x; }
struct circle_t { int x, y, r; };
bool is_intersect(circle_t a, circle_t b) {
    return sq(a.x - b.x) + sq(a.y - b.y) < sq(a.r + b.r);
}
int main() {
    while (true) {
        int n; cin >> n;
        if (n == 0) break;
        vector<circle_t> p(n);
        vector<int> c(n);
        repeat (i,n) {
            cin >> p[i].x >> p[i].y >> p[i].r >> c[i];
        }
        vector<vector<bool> > e(n, vector<bool>(n));
        repeat (i,n) {
            repeat (j,i) {
                if (is_intersect(p[i], p[j])) {
                    e[i][j] = e[j][i] = true;
                }
            }
        }
        cout << solve(e, c) << endl;
    }
    return 0;
}

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

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

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

int main(){
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  int N;
  cin >> N;
  int t;
  int z=0;
  ll ans;
  while(N>0){
    t=N%10;
    if(t==1){
      ans+=9*pow(10,z);
      z++;
    }else{
      ans+=1*pow(10,z);
      z++;
    }
    N/=10;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <utility>
#include <string>
#include <vector>

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

#define is_boin(c) ((c)=='a'||(c)=='i'||(c)=='u'||(c)=='e'||(c)=='o')
#define is_muse(c) ((c)=='k'||(c)=='s'||(c)=='t'||(c)=='h'||(c)=='p'||(c)=='*')

using namespace std;

int main(void)
{
	string word;
	while(cin >> word, word[0] != '#'){
		word.push_back('*');
		vector<pair<string, char>> p;
		int i = 0;
		bool flag = false;
		//拍に切り分ける
		while(word[i] != '*'){
			string s;
			char b;
			if(word[i] != 'n'){
				while(is_boin(word[i]) == false){
					s.push_back(word[i++]);
				}
				b = word[i++];
				p.push_back(make_pair(s, b));
			}else{
				s.push_back(word[i++]);
				if (is_boin(word[i])){
					b = word[i++];
				}else if(word[i] == 'y'){
					s.push_back(word[i++]);
					b = word[i++];
				}else if(word[i] == '\''){
					b = '\'';
					i++;
				}else{
					b = ' ';
				}
				p.push_back(make_pair(s, b));
			}
		}
		p.push_back(make_pair("*", ' '));
		rep(j, p.size()-1){
			if (flag){
				if (p[j].second != ' '){
					cout << p[j].first << p[j].second;
				}else{
					cout << p[j].first;
				}
				flag = false;
				continue;
			}
			//第一規則
			if (p[j].second == 'i' || p[j].second == 'u'){
				if (is_muse(p[j].first[0]) && is_muse(p[j+1].first[0])){
					cout << p[j].first << '(' << p[j].second << ')';
					flag = true;
					continue;
				}
			}
			//第二規則
			if (p[j].second == 'a' || p[j].second == 'o'){
				if (p[j].second == p[j+1].second){
					if (is_muse(p[j].first[0]) && is_muse(p[j+1].first[0])){
						if (p[j+1].first[0] != p[j+1].first[1]){
							cout << p[j].first << '(' << p[j].second << ')';
							flag = true;
							continue;
						}
					}
				}
			}
			if (p[j].second != ' '){
				cout << p[j].first << p[j].second;
			}else{
				cout << p[j].first;
			}
		}
		cout << endl;
	}
	return 0;
}


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

int main(void){
	string str;
	while(std::getline(cin,str),str!="END OF INPUT"){
		std::vector<int> v;
		int c=0;
		for(int i=0;i<str.length();i++){
			if(str[i]==' '){
				v.push_back(c);
				c=0;
			}else{
				c++;
			}
		}
		if(c!=0)v.push_back(c);
		for(vector<int>::iterator it=v.begin();it!=v.end();it++){
			cout<<*it;
		}
		cout<<endl;
	}
	return 0;
}

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

using namespace std;

using ll = long long;

ll gdb(ll a,ll b)
{
    if(a==0 && b==0)
    {}
    else if(a==0)
    {
        return b;
    }
    else if(b==0)
    {
        return a;
    }
    else
    {
        if(a > b)
        {
            return gdb(a%b,b);
        }
        if(a == b)
        {
            return a;
        }
        if(a < b)
        {
            return gdb(a,b%a);
        }
    }
}

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

int main()
{
    ll A,B,C,D;
    cin >> A >> B >> C >> D;

    ll total = B - A + 1;

    ll Cdiv = B/C - (A-1)/C;

    ll Ddiv = B/D - (A-1)/D;

    ll CDdiv = B/lcm(C,D) - (A-1)/lcm(C,D);

    ll answer = total - Cdiv - Ddiv + CDdiv;

    cout << answer << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl;
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}
typedef long long ll;
#define int ll
 
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(int)(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.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 (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const long double pi = 3.1415926535897932384626433832795028841971L;
#define Sp(p) cout<<setprecision(25)<< fixed<<p<<endl;
// int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
// int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
vi dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};
vi dx2 = { 1,1,0,-1,-1,-1,0,1 }, dy2 = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
// const ll MOD = 1000000007;
const ll MOD = 998244353;
// #define mp make_pair
//#define endl '\n'

signed main() {
	fio();
	int x;
	cin >> x;
	double th = x * pi / 180;
	using P = complex<double>;
	P now(0, 0);
	P dir(0, 1);
	int ans = 0;
	while (true) {
		now += dir;
		ans++;
		if (abs(now) < 1e-7) break;
		dir = dir * P(cos(th), sin(th));
	}
	cout << ans << endl;
}

Measured memory_bytes: 3924
#include<iostream> 
#include<stdio.h>
#include<string>
#include<iomanip> 
#include<vector> 
#include<map> 
#include<set> 
#include<algorithm> 
#include<numeric> 
#include<limits> 
#include<bitset> 
#include<functional> 
#include<type_traits> 
#include<queue> 
#include<stack> 
#include<array> 
#include<random> 
#include<utility> 
#include<cstdlib> 
#include<ctime>
//#define _LIBCPP_DEBUG 0
//#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define all(a) (a).begin(),(a),end()
#define rep(i,n) for (ll i = 0; i < (n); ++i)	
//setprecision(16)

void outi(int x) { cout << x << endl; }
void outl(ll x) { cout << x << endl; }
void outs(string x) { cout << x << endl; }
ll max(ll a, ll b) {
	ll max;
	if (a > b) max = a;
	else max = b;
	return max;
}
ll min(ll a, ll b) {
	ll min;
	if (a < b) min = a;
	else min = b;
	return min;
}
//---------------------------------------------------------------

int main() {

	
	int ans[6];

	rep(i, 5) cin >> ans[i];
	int res;
	rep(i, 5) {
		if (ans[i] == 0) {
			res = i;
		}
	}
	cout << res + 1 << endl;
	return 0;
}

Measured memory_bytes: 3620
#include <iostream>
#include <algorithm>
#include <vector>
#include <climits>

using namespace std;

int main() {
	int m,f,r;

	cin >> m >> f >> r;
    while (!((m == -1) && (f == -1) && (r == -1))) {
    	int s = m + f;
    	string score;
    	if (( m==-1)||(f==-1)) score = "F";
    	else if (s >= 80) score = "A";
    	else if (s >= 65) score = "B";
    	else if (s >= 50) score = "C";
    	else if (s >= 30) {
    		              score = "D";
    		if (r >= 50)  score = "C";
    	}	
    	else              score = "F";

    	cout << score << endl;	
		cin >> m >> f >> r;
    }
	return 0;
}




Measured memory_bytes: 3164
n,k = map(int,input().split())
ls = list(map(int,input().split()))
#二分探索
#適切にokとngを定めていきましょう
def is_ok(arg):
    # 条件を満たすかどうか？問題ごとに定義
    num = 0
    for i in range(n):
        num += -(-ls[i] // arg) -1
    if num <= k:
        return True
    return False
def meguru_bisect(ng, ok):
    '''
    初期値のng,okを受け取り,is_okを満たす最小(最大)のokを返す
    まずis_okを定義すべし
    ng ok は  とり得る最小の値-1 とり得る最大の値+1
    最大最小が逆の場合はよしなにひっくり返す
    '''
    while (abs(ok - ng) > 1):
        mid = (ok + ng) // 2
        if is_ok(mid):
            ok = mid
        else:
            ng = mid
    return ok
print(meguru_bisect(0, max(ls)+1))


Measured memory_bytes: 104520
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
using namespace std;
typedef long long int ll;

// clang-format off
#ifdef _DEBUG_
#define dump(...) do{ cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; PPPPP(__VA_ARGS__); cerr << endl; } while(false)
template<typename T> void PPPPP(T t) { cerr << t; }
template<typename T, typename... S> void PPPPP(T t, S... s) { cerr << t << ", "; PPPPP(s...); }
#else
#define dump(...)
#endif
template<typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template<typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); }
template<typename T>
bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false;}
template<typename T>
bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false;}
// clang-format on

class UnionFind {
public:
    vector<int> par;
    int N;
    UnionFind(int n) {
        par.resize(n, -1);
        N = n;
    }
    int Find(int n) {
        return par[n] < 0 ? n : par[n] = Find(par[n]);
    }
    bool Union(int x, int y) {
        x = Find(x);
        y = Find(y);
        if (x == y) return false;
        if (-par[x] < -par[y]) swap(x, y);
        par[y] += par[x];
        par[x] = y;
        N--;
        return true;
    }
    bool Same(int x, int y) {
        return Find(x) == Find(y);
    }
    int size(int x) {
        return -par[Find(x)];
    }
    int size() {
        return N;
    }
};

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    vector<ll> a(n);
    REP(i, 0, n) {
        cin >> a[i];
    }
    UnionFind uf(n);
    REP(i, 0, m) {
        int x, y;
        cin >> x >> y;
        uf.Union(x, y);
    }
    vector<vector<ll>> rt(n);
    REP(i, 0, n) {
        rt[uf.Find(i)].push_back(a[i]);
    }
    vector<ll> rest;
    ll ans = 0;
    REP(i, 0, n) {
        if (rt[i].size() == 0) continue;
        sort(rt[i].begin(), rt[i].end());
        REP(j, 1, rt[i].size()) {
            rest.push_back(rt[i][j]);
        }
        ans += rt[i][0];
    }
    sort(rest.begin(), rest.end());
    int sz = uf.size() - 1;
    if (n < 2 * sz) {
        cout << "Impossible" << endl;
        return 0;
    }
    REP(i, 0, sz - 1) {
        ans += rest[i];
    }

    if (n - 1 == m) ans = 0;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 6912
#include <bits/stdc++.h>
using namespace std;
#define pi acos(-1)
#define IOS ios_base::sync_with_stdio(0); cin.tie(); cout.tie();
#define ff first
#define ss second
#define pb push_back
#define debug(val) cerr << "The Value Of " << #val << " is : " << val << '\n';
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1e9 + 7;
const ll inf = 0x3f3f3f3f;
const ll mininf = -922337203685477;
const ll nax = 0;
ld n, k, ans=0;
	
int main(){
	IOS
	cin >> n >> k;
	for(int i=1;i<=n;i++){
		ld d=1.0/n;
		ll now=i;
		while(now<k){
			now*=2;
			d*=0.5;
		}
		ans+=d;
	}
	cout << setprecision(9) << fixed;
	cout << ans << '\n';
}


Measured memory_bytes: 3840
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<ll,ll>;
const ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define pow(x,y) modpow(x,y)
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REPS(i,n) for(ll (i)=1;(i)<=(n);(i)++)
#define RREP(i,n) for(ll (i)=(n-1);(i)>=0;(i)--)
#define RREPS(i,n) for(ll (i)=(n);(i)>0;(i)--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());

template<class T> inline void chmin(T& a, T b){
    if (a > b){
        a = b;
    }
}

template<class T> inline void chmax(T& a, T b){
    if (a < b){
        a = b;
    }
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    int S , W;
    cin >> S >> W;
    cout << (S <= W ? "unsafe" : "safe") << "\n";
}

Measured memory_bytes: 3652
MOD = 10 ** 9 + 7
n, m = map(int, input().split())
s = list(map(int, input().split()))
t = list(map(int, input().split()))

dp = [0] * n
for tj in t:
    acc = 0
    for i, si in enumerate(s):
        acc = (acc + dp[i]) % 1000000007
        if si == tj:
            dp[i] = (acc + 1) % 1000000007
ans = 1
for x in dp:
    ans = (ans + x) % MOD
print(ans)


Measured memory_bytes: 3316
import math


def cmb(n,r):
    return math.factorial(n) // (math.factorial(n-r)*math.factorial(r))

def main():
    
    n,k = map(int, input().split())

    c = 10**9+7

    for i in range(k):
        try:
            print(((cmb(k-1,i)*cmb(n - k+1,i+1))%c))
        except:
            print(0)
            
if __name__ == "__main__":
    main()

Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
typedef int ll;
typedef vector<ll> vl;
#define MOD 1000000007
#define INF 1000000000
#define pb push_back
#define endl '\n'
void fast() { ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL); }
const long long INFll=1ll*INF*INF;
const long double PI=3.141592653589793238462643383279502884197169399375105820974944;
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))

int main(){
    
    fast();
    //#ifndef ONLINE_JUDGE
    //freopen("E:\\c++\\IO\\input.txt", "r", stdin);
    //freopen("E:\\c++\\IO\\output.txt", "w", stdout);
    //#endif

    ll n,i,j;
    cin>>n;

    vector<vector<long double>> dp(n+1,vector<long double>(n+1));
    vector<long double> vect(n+1);
    for(i=1;i<=n;i++){cin>>vect[i];}

    dp[0][0]=1;
    for(i=1;i<=n;i++){dp[i][0]=dp[i-1][0]*(1-vect[i]);}
    for(i=1;i<=n;i++){
        for(j=1;j<=n;j++){
            if(j>i){continue;}
            else{
                dp[i][j]=dp[i-1][j-1]*vect[i]+dp[i-1][j]*(1-vect[i]);
            }
        }
    }
    long double sum=0;
    for(i=(n+1)/2;i<=n;i++){sum+=dp[n][i];}
    cout<<setprecision(9)<<sum<<endl;
    // for(i=0;i<=n;i++){
    //     for(j=0;j<=n;j++){cout<<dp[i][j]<<" ";}cout<<endl;
    // }

    return 0;
}


Measured memory_bytes: 144500
#pragma region Macros
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

#define REP(i, n) for(int i=0; i<(n); i++)
#define REPS(i, n) for(int i=0; i<=(n); i++)
#define FOR(i, a, b) for(int i=a; i<(b); i++)
#define FORS(i, a, b) for(int i=a; i<=(b); i++)
// for container x
#define ALL(v) (v).begin(),(v).end()
#define RALL(v) (v).rbegin(),(v).rend()
#define SIZE(v) ((ll)(v).size())
#define MAX(v) *max_element(ALL(v))
#define MIN(v) *min_element(ALL(v))
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end())

struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
#pragma endregion

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

    vector<int> ord(n);
    iota(ALL(ord), 1);

    int ans = 0;
    do {
        bool all_ok = true;
        REP(i, n-1) {
            bool ok = false;
            if (ord[i] < ord[i+1]) {
                REP(j, m) if (a[j]==ord[i] && b[j]==ord[i+1]) ok=true;
            }
            else {
                REP(j, m) if (a[j]==ord[i+1] && b[j]==ord[i]) ok=true;
            }
            if (ok) continue;
            else {
                all_ok=false;
                break;
            }
        }
        if (all_ok) ans++;
    } while(next_permutation(ord.begin()+1, ord.end()));
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3640
#include <iostream>
#include<algorithm>
#include<string>
#include <cmath>
#include <vector>
#include <map>
#include <cstdio>
#pragma region Macros
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define int long long
#define all(x) (x).begin(),(x).end()
#define swap(a,b) (a += b,b = a - b,a -= b)
#define ceil(a,b) ((a+b-1)/b)
int gcd(int a, int b) // assuming a,b >= 1
{
    if (a < b)
        swap(a, b);
    if (b == 0)
        return a;
    if (a % b == 0)
        return b;
    return gcd(b, a % b);
}
int lcm(int a, int b) // assuming a,b >= 1
{
    return  a * b / gcd(a, b);
}
using namespace std;
#pragma endregion
signed main() {
    string S;
    cin >> S;
    if (S[0] != S[1] && S[1] != S[2] && S[2] != S[0])
        cout << "Yes";
    else
        cout << "No";
}

Measured memory_bytes: 632
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do():
    n=INT()
    get=[]
    ct=0
    for i in range(n):
        get.append(STR())
    m=INT()
    lost=[]
    for i in range(m):
        lost.append(STR())
    get_set=set(get)
    for gs in get_set:
        temp=get.count(gs)-lost.count(gs)
        ct=max(ct,temp)
    print(ct)
        
if __name__ == '__main__':
    do()

Measured memory_bytes: 3064
#include <algorithm>
#include<iostream>
#include<vector>
#include<deque>
#include<queue>
#include<list>
#include<stack>
#include<map>
#include<set>
#include<string>
#include <sstream>
#include<bitset>

#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<limits.h>

using namespace std;

int cnt;

int gcd(int x,int y){
  int mi,ma;
  ma = max(x,y);
  mi = min(x,y);
  if(ma % mi == 0){
    return mi;
  }
  else{
    return gcd(mi,ma % mi);
  }
}

int insertionSort(vector<int>* a,int n,int g){
  int ii,jj;
  int v;
  //int cnt = 0;

  for (ii=g;ii<n;ii++){
    v = a->at(ii);
    jj = ii - g;

    while( jj >= 0 && a->at(jj) > v){
      //cout << "jj:" << jj << "jj+g:" << (jj+g) << endl;
      a->at(jj+g) = a->at(jj);
      jj = jj - g;
      cnt++;
      
    }
    
    a->at(jj+g) = v;
    
  }
  return 0;

}

vector<int> makeG(int n){
  vector<int> a;
  int val = n;

  while(true){
    if(val -1 <= 0){
      a.push_back(1);
      break;
    }
    else{
      a.push_back(val/2);
      val = val/2;
    }
  }
  return a;
}

int shellSort(vector<int>* a,int n,vector<int>* g){
  int ii;
  int m =g->size();
  //int g[] = {4,1};


  
  for(ii=0;ii<m;ii++){
    insertionSort(a,n,g->at(ii));
  }
  return 0;
}




int main(){
  long ii,jj,kk;
  vector<int> a;
  int n;

  
  cin >> n;
  a.resize(n);
  for(ii=0;ii<n;ii++){
    cin >> a[ii];
  }
  cnt = 0;
  vector<int> ret = makeG(n);
  shellSort(&a,n,&ret);


  cout << ret.size() << endl;

  for(ii=0;ii<ret.size();ii++){
    cout << ret[ii];
    if(ii != ret.size() -1){
      cout << " ";
    }
  }

  cout << endl;
  
  cout << cnt << endl;
  
  for(ii=0;ii<n;ii++){
    cout << a[ii] << endl;
  }
  return 0;
}



Measured memory_bytes: 6716
#include <iostream>
#include <cstdio>
#include <cassert>
#include <cstring>
#include <cmath>
#include <functional>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>
#include <map>
#include <set>
#ifdef XLor
  #define dbg(args...) cout << "\033[32;1m" << #args << " -> ", err(args)
  void err() { std::cout << "\033[39;0m" << std::endl; }
  template<typename T, typename...Args>
  void err(T a, Args...args) { std::cout << a << ' '; err(args...); }
#else
  #define dbg(...)
#endif
#define ms(a,b) memset(a,b,sizeof(a))
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
const int mod = 998244353;
const ll inf = 1ll << 60;
const int maxn = 200000 + 5;

int n, a[maxn];
vector<PII> edge[maxn];

int vis[maxn], siz[maxn], sum, mn, rt;
void getsz(int u, int f) {
  siz[u] = 1; int mx = 0;
  for (auto& x: edge[u]) {
    int v = x.first;
    if (v == f || vis[v]) continue;
    getsz(v, u);
    siz[u] += siz[v];
    mx = max(mx, siz[v]);
  }
  mx = max(mx, sum - siz[u]);
  if (mx < mn) {
    mn = mx; rt = u;
  }
}
int getsz(int u) {
  sum = siz[u]; mn = 1e9;
  getsz(u, 0); return rt;
}

vector< tuple<ll,int,int> > egs;
void solve(int u) {
  vis[u] = 1;
  ll mn = inf; int y;
  function<void(int,int,ll)> dfs = [&](int u, int f, ll d) {
    if (d + a[u] < mn) {
      mn = d + a[u]; y = u;
    }
    for (auto& x: edge[u]) {
      int v = x.first;
      if (v == f || vis[v]) continue;
      dfs(v, u, d + x.second);
    }
  };
  dfs(u, 0, 0);
  dfs = [&](int u, int f, ll d) {
    egs.emplace_back(mn + d + a[u], u, y);
    for (auto& x: edge[u]) {
      int v = x.first;
      if (v == f || vis[v]) continue;
      dfs(v, u, d + x.second);
    }
  };
  dfs(u, 0, 0);
  for (auto& x: edge[u]) {
    if (vis[x.first]) continue;
    solve(getsz(x.first));
  }
}

int pre[maxn];
int find(int x) {
  return x == pre[x] ? x : pre[x] = find(pre[x]);
}
int join(int x, int y) {
  x = find(x); y = find(y);
  if (x == y) return false;
  pre[x] = y;
  return true;
}

int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", a + i);
  }
  for (int i = 2, u, v, w; i <= n; i++) {
    scanf("%d%d%d", &u, &v, &w);
    edge[u].emplace_back(v, w);
    edge[v].emplace_back(u, w);
  }
  siz[1] = n; solve(getsz(1));
  for (int i = 1; i <= n; i++) pre[i] = i;
  sort(begin(egs), end(egs));
  for (auto& e: egs) {
    ll w; int u, v; tie(w, u, v) = e;
    dbg(w, u, v);
  }
  ll ans = 0;
  for (auto& e: egs) {
    ll w; int u, v; tie(w, u, v) = e;
    if (join(u, v)) {
      ans += w;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 96356
n = gets.chomp.to_i
s = []
n.times do
  s.push(gets.chomp.split('').sort.join(''))
end

h = s.group_by(&:itself).map{ |key, value| [key, value.count] }.to_h

ans = 0
h.each_value do |v|
  next if v == 1
  ans += (v * (v - 1)) / 2
end
p ans


Measured memory_bytes: 51068
#include <iostream>
#include<algorithm>
using namespace std;
int main(void){
    int ill[100001]={0};
    int ren[100001]={0};
    int n,count=0;
    int ans=0;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>ill[i];
        if(i==0||ill[i-1]!=ill[i]){
            ren[count]++;
        }
        else{
            count++;
            ren[count]++;
        }
    }
    ans=max(ren[0]+ren[1],ren[count]+ren[count-1]);
    for(int i=1;i<=count-1;i++){
        ans=max(ans,ren[i-1]+ren[i]+ren[i+1]);
    }
    if(count==0)cout<<n<<endl;
    else cout<<ans<<endl;
    
}



Measured memory_bytes: 3884
S = list(input())
count = 0
for i in range(len(S)):
    if i % 2 == 0:
        if S[i]=="R" or S[i]=="U" or S[i]=="D":
            count += 1
    else:
        if S[i]=="L" or S[i]=="U" or S[i]=="D":
            count += 1
if count == len(S):
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3060
while True:
	try:
		ins = input().split(" ")
		N = int(ins[0])
		T = int(ins[1])
		a = []
		inx = input().split(" ")
		for i in range(0, N):
			a.append(int(inx[i]))
		ans = 0
		end = 0
		for x in range(0, N):
			if a[x] < end:
				 ans = ans + a[x] + T - end
				 end = a[x] + T
			elif a[x] > end:
				ans += T
				end = a[x] + T
			else:
				ans += T
				end += T
		print(ans)
	except:
		break

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

using namespace std;

const int INF=1e9+10;

typedef vector<int> Vec;
typedef vector<Vec> Mat;


int main()
{
    int V,E;
    while(cin>>V>>E)
    {
        int tot=0;
        Vec degree(V);
        Mat dist(V,Vec(V));
        for(int i=0;i<V;i++)
        {
            fill(dist[i].begin(),dist[i].end(),INF);
            dist[i][i]=0;
        }
        for(int i=0;i<E;i++)
        {
            int a,b,c;
            cin>>a>>b>>c;
            dist[a][b]=dist[b][a]=min(dist[a][b],c);
            degree[a]++;
            degree[b]++;
            tot+=c;
        }
        Vec res;
        for(int i=0;i<V;i++)
        {
            if(degree[i]%2)
            {
                res.push_back(i);
            }
        }
        for(int k=0;k<V;k++)
        {
            for(int i=0;i<V;i++)
            {
                for(int j=0;j<V;j++)
                {
                    dist[i][j]=min(dist[i][j],dist[i][k]+dist[k][j]);
                }
            }
        }
        int sz=res.size();
        Vec dp(1<<sz);
        fill(dp.begin(),dp.end(),INF);
        dp[0]=0;
        for(int s=0;s<(1<<sz);s++)
        {
            for(int i=0;i<sz;i++)
            {
                if(!(s&(1<<i)))
                {
                    for(int j=i+1;j<sz;j++)
                    {
                        if(!(s&(1<<j)))
                        {
                            dp[s|(1<<i)|(1<<j)]=min(dp[s|(1<<i)|(1<<j)],dp[s]+dist[res[i]][res[j]]);
                        }
                    }
                }
            }
        }
        cout<<tot+dp[(1<<sz)-1]<<endl;
    }

    return 0;
}



Measured memory_bytes: 3184
#include <bits/stdc++.h>
using namespace std;
const int sz=1e5+9;
int dp[11][sz];
int n,m;
int a[11];
int cost[]={0,2,5,5,4,5,6,3,7,6};
int have[11];
int ans[11];

int solve(int idx,int rem){
    int &ret=dp[idx][rem];
    if(~ret) return ret;
    if(!rem) return ret=0;
    if(!idx) return ret=-1e5;
    ret=solve(idx-1,rem);
    if(rem>=cost[a[idx]]) ret=max(ret,1+solve(idx,rem-cost[a[idx]]));
    return ret;
}

void print_sol(int idx,int rem){
    if(!rem) return;
    if(!idx) return;
    if(rem>=cost[a[idx]]&&dp[idx][rem]==1+dp[idx][rem-cost[a[idx]]]){
        printf("%d",a[idx]);
        print_sol(idx,rem-cost[a[idx]]);
    }else print_sol(idx-1,rem);
}

int main()
{
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    scanf("%d %d",&n,&m);
    for(int i=1;i<=m;i++){
        scanf("%d",&a[i]);
    }
    memset(dp,-1,sizeof(dp));
    sort(a+1,a+m+1);
    solve(m,n);
    print_sol(m,n);
    return 0;
}
// 1 2 3 4 5 6 7 8 9
// 2 5 5 4 5 6 3 7 6


Measured memory_bytes: 4736
loop do
    n = gets.to_i
    break if n == 0
    n.times do
        points = gets.split.map(&:to_i)
        avg = points.inject(:+) / 3
        if points.any? {|x| x == 100} || points[0..1].inject(:+) / 2 >= 90 || avg >= 80
            puts ?A
        elsif avg >= 70 || (avg >= 50 && points[0..1].any?{|x| x >= 80})
            puts ?B
        else
            puts ?C
        end
    end
end


Measured memory_bytes: 6868
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <stack>
using namespace std;

int main()
{
	stack<int> a;
	char input[100];
	while(scanf("%s",input)!=EOF)
	{
		
		if(input[0]=='+')
		{
			int t=a.top();
			a.pop();
			int res=t+a.top();
			a.pop();
			a.push(res);
		}else if(input[0]=='-')
		{
			int t=a.top();
			a.pop();
			int res=a.top()-t;
			a.pop();
			a.push(res);
		}else if(input[0]=='*')
		{
			int t=a.top();
			a.pop();
			int res=t*a.top();
			a.pop();
			a.push(res);
		}else  
		{
			int t=atoi(input);
			a.push(t);
		}
		char ch=getchar();
		if(ch=='\n') break;
	}
	printf("%d\n",a.top());  
	return 0;
}


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

int main () {
  int ans = 0 ;
    
  int N ;
  cin >> N ;
  
  for ( int  i = 0 ; i < N ; i++ ) {
    int a , b ;
    cin >> a >> b ;    
    ans += b - a + 1 ;   
  }
  
  cout << ans << endl ;
}


Measured memory_bytes: 256
#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 ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;
int main()
{
  int n; ll k;
  cin >> n >> k;
  vector<ll> a(n);
  REP(i,n) cin >> a[i];
  
  ll ans = 0;
  for(int d=40; d>=-1; d--){
    if(d!=-1 && !(k & (1LL<<d))) continue;
    
    ll tmp = 0;
    REPR(e,40){
      ll mask = 1LL<<e;
      int num = 0;
      REP(i,n) if(a[i] & mask) num++;
      
      if(e>d){
        if(k & mask) tmp += mask * (n-num);
        else tmp += mask * num;
      }else if(e==d){
        tmp += mask * num;
      }else{
        tmp += mask * max(num, n-num);
      }
    }
    ans = max(ans, tmp);
  }
  cout << ans << '\n';
  return 0;
}


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

#define     int long long
#define     pii pair<int,int>
#define     x first
#define     y second
#define     __FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define     MOD 1000000007
#define     INF 100000000
#define     nll cout << "\n"
#define     nl "\n"
#define     MAX 1000003
#define     print(v) cout << v << " "
#define     dbgv(v) cout << v << nl
#define     asdf(v) cout << v << nl
#define     pasdf(p) cout << p.x << " " << p.y << nl
#define     dbg cout << "dbg\n"
#define     vi vector<int>
#define     vl vector<ll>
#define     pb push_back
#define     con continue

int xx[] = {1, -1, 0, 0};
int yy[] = {0, 0, -1, 1};

vector<int>prime;
bitset<1000005>isPrime;

void seive(){
    isPrime.set();
    for(int i = 2; i < MAX; i++){
        if(isPrime[i]){
            prime.pb(i);
            for(int j = i*2; j < MAX; j+=i)isPrime[j] = false;
        }
    }
}

bool utilFun(int n){
    for(int i = 0; prime[i] <= sqrt(n); i++){
        if(n%prime[i] == 0){
            return false;
        }
    }
    return true;
}

int32_t main(){
    seive();
    int n, m;
    while(cin >> n >> m){
        map<int, bool>mp;
        for(int i = 0; prime[i] <= sqrt(n); i++){
            int pf = prime[i];
            if(n%pf == 0){
                mp[pf] = true;
                while(n%pf == 0)n /= pf;
            }
        }
        if(n > 1){
            mp[n] = true;
        }
        int cnt = 1;
        for(int i = 0; prime[i] <= sqrt(m); i++){
            int pf = prime[i];
            if(m%pf == 0){
                if(mp[pf] == true)cnt++;
                while(m%pf == 0)m/=pf;
            }
        }
        if(m > 1){
            if(mp[m])cnt++;
        }
        asdf(cnt);
    }
}


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

using namespace std;

#define ll long long
#define sf scanf
#define pf printf 
#define nl printf("\n")
#define pi acos(-1)

int main()
{
    #ifndef ONLINE_JUDGE
        //freopen("in.txt","r",stdin);
        //freopen("out.txt","w",stdout);
    #endif

    int n,x;
    while(sf("%d",&n)==1){
        vector<int> vec[n+2];
        for(int i=2; i<=n; i++){
            sf("%d",&x);
            vec[x].push_back(i);
        }
        for(int i=1; i<=n; i++){
            pf("%d\n",(int)vec[i].size());
        }
        for(int i=0; i<n+2; i++) vec[i].clear();
    }
    return 0;
}

Measured memory_bytes: 14696
using System;
using System.Collections.Generic;
using System.Linq;
using static Input;
using NX = System.Int64;


public class Prog
{
    public static void Solve()
    {
        int A = NextInt(), B = NextInt();
        Console.WriteLine((A < 10 && B < 10) ? A * B : -1);
    }
    public static void Main()
    {
        var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
        Console.SetOut(sw);
        Solve();
        Console.Out.Flush();
        return;
    }

}
public class Input
{
    public const long MOD = 1000000007;
    public const int INF = 1000000007;
    private static Queue<string> q = new Queue<string>();
    private static void Confirm() { if (q.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) q.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(q.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(q.Dequeue()); }
    public static string NextString() { Confirm(); return q.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(q.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
    public long Abs(long a, long b) => Math.Abs(a - b);
}


Measured memory_bytes: 13268
inputs = STDIN.readlines.map{|line|line.strip.split()}
input = inputs.shift
hh = input[0].to_i
ww = input[1].to_i
input = inputs.shift

h = input[0].to_i
w = input[1].to_i

answer = hh * ww - (hh * w + ww * h) + h * w
puts(answer)

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

int main(){
    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;
    int dx = tx - sx;
    int dy = ty - sy;
    string ans = "";

    //1回目
    for(int i=0; i<dx; i++){
        ans += "R";
    }
    for(int i=0; i<dy; i++){
        ans += "U";
    }
    //2回目
    for(int i=0; i<dx; i++){
        ans += "L";
    }
    for(int i=0; i<dy; i++){
        ans += "D";
    }
    //3回目
    ans += "D";
    for(int i=0; i<dx+1; i++){
        ans += "R";
    }
    for(int i=0; i<dy+1; i++){
        ans += "U";
    }
    ans += "L";
    //4回目
    ans += "U";
    for(int i=0; i<dx+1; i++){
        ans += "L";
    }
    for(int i=0; i<dy+1; i++){
        ans += "D";
    }
    ans += "R";
    
    cout << ans << endl;
    return 0;
}

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

using namespace std;

void
call(int n) {
  int i = 1;
 CHECK_NUM:
  int x = i;
  if ( x % 3 == 0 ){
    cout << " " << i;
    goto END_CHECK_NUM;
  }
 INCLUDE3:
  if ( x % 10 == 3 ){
    cout << " " << i;
    goto END_CHECK_NUM;
  }
  x /= 10;
  if ( x ) goto INCLUDE3;
 END_CHECK_NUM:
  if ( ++i <= n ) goto CHECK_NUM;

  cout << endl;
}

void
structured_call(int n)
{
  int i, x;
  for (i = 1; i <= n; i++) {
    x = i;
    if (x % 3 == 0) {
      cout << " " << i;
    } else {
      while (x) {
        if (x % 10 == 3) {
          cout << " " << i;
          break;
        }
        x = x / 10;
      }
    }
  }
  cout << endl;
  return;
}

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

  // call(n);
  structured_call(n);
  return 0;
}



Measured memory_bytes: 3080
#include<iostream>
#include<cstdio>
#include<queue>
#include<vector>
#include<string.h>
#include<algorithm>
#include<cmath>
#include<map>

using namespace std;

int i,j,k,n,m,Nh,Nw,H,W,K,c[10][10],d[10][10],ans,fact[10],temp;

char S[10];

int main()
{
  cin>>H>>W>>K;
  
  for(i=0;i<H;i++)
  {
    cin>>S;
    
    for(j=0;j<W;j++)
    {
      if(S[j]=='.')c[i][j]=0;
      else c[i][j]=1;
    }
  }
  
  
  fact[0]=1;
  for(i=1;i<10;i++)
  {
    fact[i]=fact[i-1]*2;
  }
  Nh=fact[H];
  Nw=fact[W];
  ans=0;
  for(i=0;i<Nh;i++)
  {
    for(n=0;n<Nw;n++)
    {
      temp=0;
      
      for(j=0;j<H;j++)
      {
        for(k=0;k<W;k++)
        {
          d[j][k]=c[j][k];
        }
      }
      
      for(j=0;j<H;j++)
      {
        for(k=0;k<W;k++)
        {
          if((fact[j]&i)==fact[j])d[j][k]=0;
        }
      }
      for(j=0;j<H;j++)
      {
        for(k=0;k<W;k++)
        {
          if((fact[k]&n)==fact[k]) d[j][k]=0;
          
        }
      }
      
      for(j=0;j<H;j++)
      {
        for(k=0;k<W;k++)
        {
          temp+=d[j][k];
        }
      }
      
      if(temp==K) 
      {
        
        ans++;
      }
    
    
    }
  }
  
  cout<<ans;

}

Measured memory_bytes: 3588