akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define int long long
#define endl '\n'

int32_t main()
{
    int n,x,t;
    cin>>n>>x>>t;
    cout<<t*(n/x+(n%x!=0));
}   

Measured memory_bytes: 3632
#include<bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp> 
//using namespace boost::multiprecision; 

using namespace std;

//#Rohitpratap311
//#Keep Calm And Stay Happy

typedef long long ll;
typedef long double ld;

bool ifprime(ll n)
{
    if(n==2||n==3) { return true ; }
    for(ll i=2;i<=sqrt(n);i++)
    {
        if(n%i==0) { return false; }
    }
    return true;
}

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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t=1;
    //cin>>t;
    while(t--)
    {
        string s,t;
        cin>>s>>t;
        ll minval=10000;
        for(int i=0;i<=s.size()-t.size();++i)
        {
            string tmp=s.substr(i,t.size());
            ll ans=0;
            for(int j=0;j<tmp.size();++j)
            {
                if(tmp[j]!=t[j])
                ++ans;

            }
            minval=min(ans,minval);
        }
        cout<<minval;
    }
    return 0;
}

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

#define M_PI       3.14159265358979323846   // pi

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> VI;
typedef pair<ll, ll> P;
typedef tuple<double, ll, ll> t3;
typedef tuple<ll, ll, ll, ll> t4;
typedef tuple<ll, ll, ll, ll, ll> t5;

#define rep(a,n) for(ll a = 0;a < n;a++)
#define repi(a,b,n) for(ll a = b;a < n;a++)

using namespace std;

static const ll INF = 1e15;

template<typename T>
static inline void chmin(T & ref, const T  value) {
	if (ref > value) ref = value;
}

template<typename T>
static inline void chmax(T& ref, const T value) {
	if (ref < value) ref = value;
}

const ll mod = 1000000007;

int main() {
	string s;
	cin >> s;
	int n = s.size();
	vector<bool> vs(n);
	rep(i, n) {
		vs[i] = (s[i] == '1');
	}
	vector<vector<ll>> dp(n, vector<ll>(2, 0));
	//dp[i][j]...j==true : eqal
	//dp[i][j]...j==false : lower
	dp[0][0] = 1;
	dp[0][1] = 2;
	for (int i = 1; i < n; i++) {
		if (vs[i]) {
			//00
			dp[i][0] += dp[i - 1][1];
			//00
			dp[i][0] += dp[i - 1][0];
			//10, 01
			dp[i][0] += 2 * dp[i - 1][0];

			//10, 01
			dp[i][1] += 2 * dp[i - 1][1];
		}
		else {
			//00
			dp[i][0] += dp[i - 1][0];
			//10, 01
			dp[i][0] += 2 * dp[i - 1][0];

			//00
			dp[i][1] += dp[i - 1][1];
		}
		rep(j, 2) {
			dp[i][j] %= mod;
		}
	}
	ll sum = dp[n - 1][0] + dp[n - 1][1];
	sum %= mod;
	cout << sum << endl;
	return 0;
}


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

#define ll long long

#define fr(i,a,b) for (ll i = (a), _b = (b); i <= _b; i++)
#define frr(i,a,b) for (ll i = (a), _b = (b); i >= _b; i--)
#define rep(i,n) for (ll i = 0, _n = (n); i < _n; i++)
#define repr(i,n) for (ll i = n - 1; i >= 0; i--)
#define fill(ar,val) memset(ar, val, sizeof(ar))
#define fill0(ar) fill((ar), 0)
#define debug(x) cout<<#x<<": "<<x<<endl

#define ld double
#define pb push_back
#define mp make_pair
#define ff first
#define ss second

typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef vector<ii> vii;
typedef vector<int> vi;

#define INF 1000000000000000000

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    long double pi= 3.14159265358979323846;
    ll n;
    string a,b,c;
    ll ans=0;
    cin>>n>>a>>b>>c;
    rep(i,n)
    {
        if(a[i]==b[i]&&b[i]==c[i])
        {}
        else if(a[i]==b[i])
        {
            ans++;
        }
        else if(b[i]==c[i]||c[i]==a[i])
        {
            ans++;
        }
        else
        {
            ans+=2;
        }
    }   
    cout<<ans<<endl;
    return 0;
}

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

int main(){
  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  int n; cin >> n;
  vector<vector<long long> > tab(n,vector<long long>(3));
  vector<vector<long long> > dp(n,vector<long long>(3));
  for(int i = 0; i < n; i++){
    cin >> tab[i][0] >> tab[i][1] >> tab[i][2];
  }
  dp[0][0] = tab[0][0];
  dp[0][1] = tab[0][1];
  dp[0][2] = tab[0][2];
  for(int i = 1; i < n; i++){
    dp[i][0] = max(dp[i-1][1],dp[i-1][2]) + tab[i][0];
    dp[i][1] = max(dp[i-1][0],dp[i-1][2]) + tab[i][1];
    dp[i][2] = max(dp[i-1][0],dp[i-1][1]) + tab[i][2];
  }
  cout << max({dp[n-1][0],dp[n-1][1],dp[n-1][2]});
}


Measured memory_bytes: 11264
#include <iostream>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <tuple>
#include <queue>
using namespace std;
typedef long long ll;

int main(void){
    ll k, a, b;
    cin >> k >> a >> b;
    
    if (b - a <= 2) cout << k + 1 << endl;
    else {
        if (k <= a - 1) cout << k + 1 << endl;
        else if (k % 2 == (a - 1) % 2) {
            cout << a + (k - (a - 1)) / 2 * (b - a) << endl;
        }
        else {
            cout << a + ((k - a) / 2) * (b - a) + 1 << endl;
        }
    }
    
    
}


Measured memory_bytes: 256
// This amazing code is by Eric Sunli Chen.
#include<bits/stdc++.h>
using namespace std;
template<typename T> bool get_int(T &x)
{
	char t=getchar();
	bool neg=false;
	x=0;
	for(; (t>'9'||t<'0')&&t!='-'&&t!=EOF; t=getchar());
	if(t=='-')neg=true,t=getchar();if(t==EOF)return false;
	for(; t<='9'&&t>='0'; t=getchar())x=x*10+t-'0';
	if(neg)x=-x;return true;
}
template<typename T> void print_int(T x)
{
	if(x<0)putchar('-'),x=-x;
	short a[20]= {},sz=0;
	while(x>0)a[sz++]=x%10,x/=10;
	if(sz==0)putchar('0');
	for(int i=sz-1; i>=0; i--)putchar('0'+a[i]);
}
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define get1(a) get_int(a)
#define get2(a,b) (get1(a)&&get1(b))
#define get3(a,b,c) (get1(a)&&get2(b,c))
#define printendl(a) print_int(a),puts("")
typedef long long LL;
typedef unsigned long long uLL;
typedef pair<int,int> pii;
typedef vector<int> vi;
const int inf=0x3f3f3f3f;
const LL Linf=0x3f3f3f3f3f3f3f3fll;
const double pi=acos(-1.0);

const int maxn=5111;

int n,a,b,p[maxn];
LL dp[maxn][maxn];
inline void upd(LL&x,LL y){if(x>y)x=y;}

int main()
{
	get3(n,a,b);
	for(int i=1;i<=n;i++)get1(p[i]);
	memset(dp,0x3f,sizeof(dp));
	dp[1][0]=0;
	for(int i=1;i<=n;i++)for(int j=0;j<=n;j++)
	{
		//go left
		upd(dp[i+1][max(j,p[i])],b+dp[i][j]);
		//stay
		if(p[i]>j)upd(dp[i+1][max(j,p[i])],dp[i][j]);
		//go right
		if(p[i]>j)upd(dp[i+1][j],dp[i][j]+a);
	}
	LL ans=Linf;
	for(int j=0;j<=n;j++)ans=min(ans,dp[n+1][j]);
	printendl(ans);
	return 0;
}

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

#define Q int t; scanf("%d", &t); for(int q=1; q<=t; q++)
typedef long long int lli;
typedef pair<int, int> pi;
typedef pair<lli, lli> pii;


int main()
{
    string s;
    cin >> s;
    int n = s.size();
    lli ans = 0, now = 0LL;
    for(int i=0; i<n;){
        lli cnt = 0;
        if(s[i] == '<'){
            while(i < n && s[i]  == '<'){
                cnt++;
                i++;
            }
            ans += (now+cnt)*(now+cnt+1)/2 - (now)*(now-1)/2;
            now = now+cnt;

        }
        else{
            while(i < n && s[i]  == '>'){
                cnt++;
                i++;
            }
            if(now >= cnt){
                ans += (cnt)*(cnt-1)/2;
                now  = 0;
            }
            else{
                ans -= now;
                ans += (cnt)*(cnt+1)/2;
                now = 0;
            }
        }
    }

    cout << ans << '\n';

    return 0;
}


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

using ll = long long;

const int MAXD = 2333;
const int MOD = 1e9 + 7;
int N, K;
int dp[MAXD];

int powmod(int a, int b) {
	int r = 1;
	while (b) {
		if (b & 1) {
			r = ll(r) * a % MOD;
		}
		a = ll(a) * a % MOD;
		b /= 2;
	}
	return r;
}

int main() {
	cin >> N >> K;

	vector<int> factors;
	for (int i = 1; i*i <= N; i++) {
		if (N % i == 0) {
			factors.push_back(i);
			if (i*i != N) {
				factors.push_back(N / i);
			}
		}
	}
	sort(factors.begin(), factors.end());

	for (size_t i = 0; i < factors.size(); i++) {
		dp[i] = powmod(K, (factors[i]+1)/2);
		for (size_t j = 0; j < i; j++) {
			if (factors[i] % factors[j]) continue;
			dp[i] -= dp[j];
			if (dp[i] < 0) dp[i] += MOD;
		}
	}

	int ans = 0;
	for (size_t i = 0; i < factors.size(); i++) {
		if (factors[i] % 2 == 0) {
			ans = (ans + ll(dp[i]) * factors[i] / 2) % MOD;
		} else {
			ans = (ans + ll(dp[i]) * factors[i]) % MOD;
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on 2019/3/24
@author: shinjisu
"""


# ABC 122
# import math
def getInt(): return int(input())
def getIntList(): return [int(x) for x in input().split()]
# def getIntList(): return np.array(input().split(), dtype=np.longlong)
def getIntLines(n): return [int(input()) for i in range(n)]
def getIntMat(n, m):  # n行に渡って、1行にm個の整数
    #mat = zeros((n, m))
    mat = zeros2(n, m)
    for i in range(n):
        mat[i] = getIntList()
    return mat

def zeros(n): return [0]*n
# def zeros(n): return np.zeros(n, dtype=np.longlong)
def zeros2(n, m): return [zeros(m) for i in range(n)] # obsoleted zeros((n, m))で代替

ALPHABET = [chr(i+ord('a')) for i in range(26)]
DIGIT = [chr(i+ord('0')) for i in range(10)]
N1097 = 10**9 + 7
INF = 10**18

class Debug():
    def __init__(self):
        self.debug = True
 
    def off(self):
        self.debug = False
 
    def dmp(self, x, cmt=''):
        if self.debug:
            if cmt != '':
                print(cmt, ':  ', end='')
            print(x)
        return x


def prob():
    d = Debug()
    d.off()
    T = input()
    d.dmp((T), 'T')
    AGCT = ('A', 'T', 'C', 'G', )
    mx = 0
    for i in range(len(T)):
        for j in range(i, len(T)):
            count = 0
            for k in range(i, j+1):
                if T[k] in AGCT:
                    count += 1
                else:
                    break
            mx = max(mx, count)
            #d.dmp((mx, count),'mx, count')
    return mx

ans = prob()
if ans is None:
    pass
elif type(ans) == tuple and ans[0] == 1:  # 1,ans
    for elm in ans[1]:
        print(elm)
else:
    print(ans)
    





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


int main(){
	int N;
	char S[4][N];
	int count[4] = {0}; 

	scanf("%d",&N);

	for(int i=0; i<N; i++){
		scanf("%s",S[i]);
		//printf("s[%d] = %s\n",i,S[i]);
		if(strcmp(S[i],"AC") == 0 ){
			count[0]++;
		}
		else if(strcmp(S[i],"WA") == 0 ){
			count[1]++;
		}
		else if(strcmp(S[i],"TLE") == 0 ){
			count[2]++;
		}
		else if(strcmp(S[i],"RE") == 0 ){
			count[3]++;
		}					
	}

		printf("AC x %d\n",count[0]);
		printf("WA x %d\n",count[1]);
		printf("TLE x %d\n",count[2]);
		printf("RE x %d\n",count[3]);
	return 0;
}

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

int main() {
  int n,a,b,c,d;
  cin >> n;
  
  a = n / 1000;
  b = n % 1000 / 100;
  c = n % 1000 % 100 / 10;
  d = n % 1000 % 100 % 10;
  
  if ((a == b) && (b == c) || (b == c) && (c== d) || (a == b) && (b == c) && (c == d)){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Split(bufio.ScanWords)

	n := nextInt()
	k := nextInt()
	fmt.Println(n * k)
}

// ---- readfunc
func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}
func nextStr() string {
	sc.Scan()
	return sc.Text()
}


Measured memory_bytes: 1760
N = int(input())
shougens = []
for _ in range(N):
    A = int(input())
    s = [] 
    for _ in range(A):
        s.append(tuple(map(int, input().split())))
    shougens.append(s)

maxcount = 0
for i in range(2**N):
    vi = [(i>>k) & 1 for k in range(N)]
    for j in range(N):
        ss = shougens[j]
        is_break = False
        if vi[j]:
            for x, y in ss:
                x -= 1
                if vi[x] ^ y:
                    is_break = True
                    break
        if is_break:
            break
    else:
        # iのビット1の数
        maxcount = max(maxcount, bin(i).count('1'))

print(maxcount)


Measured memory_bytes: 3064
def d(p, q):
    return pos[p] - pos[q]

def solve():
    p0, p1, p2 = 0, 0, 0
    best = 1
    while p0 < N:

        if p1 <= p0: p1 = p0 + 1
        while d(p1, p0) <= best and p1 - p0 < N:
            p1 += 1
        if d(p1, p0) <= best:
            p0 += 1
            while d(p2, p1) > d(p1, p0) and p2 > p1:
                p2 -= 1
            continue


        if p2 <= p1: p2 = p1 + 1
        while d(p2,p1) < d(p1, p0) and p2 - p0 < N:
            p2 += 1
        if d(p2, p1) < d(p1, p0):
            p0 += 1
            while d(p2, p1) > d(p1, p0) and p2 > p1:
                p2 -= 1
            continue

        if L - d(p2, p0) >= d(p1, p0):
            best = d(p1, p0)
            if best >= L//3:
                return best
        else:
            p0 += 1
            while d(p2, p1) > d(p1, p0) and p2 > p1:
                p2 -= 1
    return best

N = int(input())
A = [0] * N
L = 0
for i in range(N):
    A[i] = int(input())
    L += A[i]
pos = [0] * (2*N)
for i in range(1, 2*N):
    pos[i] = pos[i-1] + A[(i-1)%N]

print(solve())

Measured memory_bytes: 20948
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>

using namespace std;

int main() {
	int N, Y;
	cin >> N >> Y;

	int num10000=-1, num5000=-1, num1000=-1;
	for (int a=0; a <= N; a++) {
		for (int b=0; b+a <= N; b++) {
			if (Y == 10000 * a + 5000 * b + 1000 * (N - a - b)) {
				num10000 = a;
				num5000 = b;
				num1000 = N - a - b;
			}

		}
	}
	cout << num10000 << " " << num5000 << " " << num1000 << endl;


	return 0;
}

Measured memory_bytes: 384
#include<algorithm>
#include<iostream>
#include<string>

std::string enc[] = { "101", "000000", "000011", "10010001", "010001", "000001", "100101", "10011010", "0101", "0001", "110", "01001", "10011011", "010000", "0111", "10011000", "0110", "00100", "10011001", "10011110", "00101", "111", "10011111", "1000", "00110", "00111", "10011100", "10011101", "000010", "10010010", "10010011", "10010000" };
std::string str = " \',-.?ABCDEFGHIJKLMNOPQRSTUVWXYZ";
std::string symbol = " .,-\'?";

int bin( std::string s )
{
	std::reverse( s.begin(), s.end() );

	int ret = 0, w = 1;
	for( int i = 0; i != s.size(); ++i )
	{
		if( s[i] - '0' )
			ret += w;

		w <<= 1;
	}

	return ret;
}

int main()
{
	std::string s;
	while( std::getline( std::cin, s ) )
	{
		std::string code;
		for( int i = 0; i != s.size(); ++i )
			code += enc[ str.find( s[i] ) ];

		for( int i = 0; i < code.size(); i += 5 )
		{
			std::string t = code.substr( i, std::min( 5, (int)code.size() - i ) ) + std::string( std::max( 0, 5 - (int)code.size() + i ), '0' );
			int n = bin( t );
			std::cout << ( n + 6 < str.size() ? str[n + 6] : symbol[n + 6 - str.size()] );
		}

		std::cout << std::endl;
	}

	return 0;
}

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

int main(){
  long double x,y;
  cin >> x;
  ll a,b;
  
  for(int i=-1000; i<=1000; i++){
   for(int j=-1000; j<=1000; j++){
     ll num = pow(i,5)-pow(j,5);
     if(num==x) a=i,b=j;
   }
  }
  
  cout << a  << " " << b << endl;
}


Measured memory_bytes: 4152
#include <bits/stdc++.h>
using namespace std;
bool    d[11]={0};
int n,  k;
bool check(int n)
{
    while(n>0){
        int c= n%10;
        n/=10;
        if (d[c]) return 0;
    }
    return 1;
}
int main()
{
    cin>>n>>k;
    while(k--){
        int x;
        cin>>x;
        d[x]=1;
    }
    for(;n<1e9;n++) if (check(n)){
        cout<<n;
        return 0;
    }
    return 0;
}


Measured memory_bytes: 256
n = int(input())
box = [[0 for _ in range(n)] for _ in range(26)]
for i in range(n):
    s = input()
    for j in range(len(s)):
        box[ord(s[j]) - 97][i] += 1
strs = ''
for i in range(26):
    strs += (chr(97 + i)) * min(box[i])
print(strs)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define UM unordered_map
#define ALL(a) (a).begin(), (a).end()
typedef vector<ll> vi;
typedef vector<vector<ll>> vvi;
typedef pair<ll, ll> pii;
const ll INF = 1LL << 58;
const ll MOD = 1000000007;
typedef vector<pii> vpii;
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}

signed main()
{
    int N;
    pair<pair<string, int>, int> iSP[101];
    cin >> N;
    REP(i, N)
    {
        iSP[i].second = i + 1;
        cin >> iSP[i].first.first >> iSP[i].first.second;
        iSP[i].first.second *= -1;
    }
    sort(iSP, iSP + N);
    REP(i, N)
    cout << iSP[i].second << endl;

    // system("pause");
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<cmath>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<cstdio>
#include<numeric>
using namespace std;
using ll = long long;
int main(){
  int n;
  ll h;
  cin >> n >> h;
  vector<ll> a(n), b(n);
  for(int i = 0; i < n; i++) {
    cin >> a[i] >> b[i];
  }
  
  int maxi = *max_element(a.begin(), a.end());
  sort(b.rbegin(), b.rend());
  vector<ll> sum(n + 1, 0);
  int num = 0;
  for(int i = 0; b[i] > maxi; i++) {
    sum[i + 1] += sum[i] + b[i];
    num++;
  }
  
  if(h <= sum[num]){
    for(int i = 0; i <= num; i++){
      if(sum[i] >= h){
        cout << i << endl;
        return 0;
      }
    }
  }else{
    h -= sum[num];
    //cout << h << endl;
    cout << num + (h + maxi - 1) / maxi << endl;
  }
  /*
  cout << maxi << " ";
  for(int i = 0; i < n; i++){
    cout << sum[i] << " ";
  }
  cout << endl;
*/
  return 0;
}

Measured memory_bytes: 2560
import math
from collections import deque
from collections import defaultdict

def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()
def factorization(n):
	res = []
	if n%2==0:
		res.append(2)
	for i in range(3,math.floor(n//2)+1,2):
		if n%i==0:
			c = 0
			for j in res:
				if i%j==0:
					c=1
			if c==0:
				res.append(i)
	return res
def fact2(n):
	p = factorization(n)
	res = []
	for i in p:
		c=0
		z=n
		while 1:
			if z%i==0:
				c+=1
				z/=i
			else:
				break
		res.append([i,c])
	return res
def fact(n):#階乗
	ans = 1
	m=n
	for _i in range(n-1):
		ans*=m
		m-=1
	return ans
def comb(n,r):#コンビネーション
	if n<r:
		return 0
	l = min(r,n-r)
	m=n
	u=1
	for _i in range(l):
		u*=m
		m-=1
	return u//fact(l)
def combmod(n,r,mod):
	return (fact(n)/fact(n-r)*pow(fact(r),mod-2,mod))%mod
def printQueue(q):
	r=copyQueue(q)
	ans=[0]*r.qsize()
	for i in range(r.qsize()-1,-1,-1):
		ans[i] = r.get()
	print(ans)
class UnionFind():
	def __init__(self, n):
		self.n = n
		self.parents = [-1]*n

	def find(self, x): # root
		if self.parents[x]<0:
			return x
		else:
			self.parents[x] = self.find(self.parents[x])
			return self.parents[x]

	def union(self,x,y):
		x = self.find(x)
		y = self.find(y)

		if x==y:
			return

		if self.parents[x]>self.parents[y]:
			x,y = y,x

		self.parents[x]+=self.parents[y]
		self.parents[y]=x

	def size(self,x):
		return -1*self.parents[self.find(x)]

	def same(self,x,y):
		return self.find(x)==self.find(y)

	def members(self,x): # much time
		root = self.find(x)
		return [i for i in range(self.n) if self.find(i)==root]

	def roots(self):
		return [i for i,x in enumerate(self.parents) if x<0]

	def group_count(self):
		return len(self.roots())

	def all_group_members(self):
		return {r: self.members(r) for r in self.roots()} # 1~n
def bitArr(n):#ビット全探索
	x = 1
	zero = "0"*n
	ans = []
	ans.append([0]*n)
	for i in range(2**n-1):
		ans.append(list(map(lambda x:int(x),list((zero+bin(x)[2:])[-1*n:]))))
		x+=1
	return ans;
def arrsSum(a1,a2):
	for i in range(len(a1)):
		a1[i]+=a2[i]
	return a1
def maxValue(a,b,v):
	v2 = v
	for i in range(v2,-1,-1):
		for j in range(v2//a+1): #j:aの個数
			k = i-a*j
			if k%b==0:
				return i
	return -1
def copyQueue(q):
	nq = queue.Queue()
	n = q.qsize()
	for i in range(n):
		x = q.get()
		q.put(x)
		nq.put(x)
	return nq

a,b = readInts()
tar = int(str(a)+str(b))**0.5
if tar%1==0:
	print("Yes")
else:
	print("No")

Measured memory_bytes: 3444
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <list>
#include <stack>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi  vector<int> 
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   all(a) (a.begin(),a.end())
#define   ff   first
#define   ss   second
#define   pii  pair<int,int> 
#define   lcm(a,b) (a*b)/__gcd(a,b) 
using namespace std;

inline void solve(){
    int  n, k, ans = 0; 
    cin >> n >> k ;
    for (int b=1;b<=n;b++ ) {
        int m=n/b;
        ans += m*max(0LL,b-k); 
        ans += max(0LL,(n%b)-k+1);
    } 
    if (k==0) ans = n*n;
    cout << ans << endl;
}

signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}


Measured memory_bytes: 3568
#include<iostream>
#include<queue>
#include<map>
#include<algorithm>
using namespace std;

#define fs first
#define sc second
typedef pair<int,int> P;
typedef pair<P,P> P2;

int h,w,n,g[8],d[8],s[8],e[8];
int v[8][101];
char m[20][20];
int num,sy,sx,end;
int c[20][20][2][1<<8];
int dy[] = {-1,0,1,0}, dx[] = {0,1,0,-1};
map<int,int> b;

int main(){
  while(cin >> w >> h,w||h){
    for(int i=0;i<h;i++)
      for(int j=0;j<w;j++){
	cin >> m[i][j];
	if(m[i][j] == 'P'){
	  sy = i; sx = j;
	}
      }

    cin >> n;
    b.clear(); end = 0;
    for(int i=0;i<n;i++){
      cin >> g[i] >> d[i] >> s[i] >> e[i];
      if(b.find(g[i]) == b.end())b[g[i]] = (int)b.size()-1;
      end = max(end,e[i]);
    }
    num = b.size();

    for(int i=0;i<num;i++)
      for(int j=0;j<=100;j++)v[i][j] = 0;
    for(int i=0;i<n;i++)
      for(int j=s[i];j<e[i];j++)v[b[g[i]]][j] += d[i];
    
    for(int i=0;i<h;i++)
      for(int j=0;j<w;j++)
	  for(int l=0;l<(1<<num);l++)c[i][j][0][l] = -1;
    c[sy][sx][0][0] = 0;

    for(int k=0;k<end;k++){
      int od = k&1;
      for(int i=0;i<h;i++)
	for(int j=0;j<w;j++)
	  for(int l=0;l<(1<<num);l++)c[i][j][1-od][l] = -1;
      
      for(int i=0;i<h;i++){
	for(int j=0;j<w;j++){
	  for(int l=0;l<(1<<num);l++){
	    if(c[i][j][od][l]<0)continue;
	    for(int dir=0;dir<4;dir++){
	      int ty = i+dy[dir], tx = j+dx[dir];
	      if(ty<0 || tx<0 || h<=ty || w<=tx)continue;

	      if('0'<=m[ty][tx] && m[ty][tx]<='9'){
		int x = b[m[ty][tx]-'0'];
		if((l>>x)&1)continue;
		if(!v[x][k])continue;
		int ts = l|(1<<x);
		c[i][j][od][ts] = max(c[i][j][od][ts],c[i][j][od][l]+v[x][k]);
	      }else c[ty][tx][1-od][l] = max(c[ty][tx][1-od][l],c[i][j][od][l]);
	    }
	  }
	}
      }
    }

    int ans = 0;
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
	for(int k=0;k<(1<<num);k++)ans = max(ans,c[i][j][end&1][k]);
      }
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 2000
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<queue>
using namespace std;
const int mod = 1000000007;
#define ll long long

int main()
{
	ll N; cin >> N;
	for (ll i = 1; i <= 3500; i++) {
		for (ll j = 1; j <= 3500; j++) {
			ll num1, num2;
			num1 = (N * i * j);
			num2 = (4 * i * j) - (N * i) - (N * j);
			if (num1 * num2 > 0) {
				if (num1 % num2 == 0) {
					//cout << num1 << " "<<num2 << endl;
					cout << i << " " << j << " " << num1 / num2 << endl;
					return 0;
				}
			}
		}
	}
}



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

int main() {
	char c;
	char ans[5] = { 'a','i','u','e','o' };
	cin >> c;
	for (int i = 0; i < 5; i++) {
		if (c == ans[i]) {
			cout << "vowel" << endl;
			return 0;
		}
	}
	cout << "consonant" << endl;
	return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
input = sys.stdin.readline

n = int(input())
info = [list(map(int,input().split())) for i in range(n)]
info = [[0,0,0]] + info
#点iと点i-1の時間と距離の差を計算
dif_time_length = [0 for _ in range(n)]
cnt = 0
for pre_i,i in zip(info,info[1::]):
    dif_time_length[cnt] = (i[0]-pre_i[0],abs(i[1]-pre_i[1]) + abs(i[2]-pre_i[2]))
    cnt+=1

def solve():
    for i in info:
        if i[0]%2!=(i[1]+i[2])%2:
            return "No"
    for t,d in dif_time_length:
        if t<d:
            return "No"
    return "Yes"
print(solve())

Measured memory_bytes: 36860
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<int, int>;
using VI = vector<int>;

ll cuts(const vector<ll>& a, ll len) {
  ll c = 0;
  for (ll x: a) {
    c += (x - 1) / len;
  }
  return c;
}

int main() {
#ifdef LOCAL_EXEC
//	freopen("sample.in", "r", stdin);
//	freopen("sample.out", "w", stdout);
#else
  ios_base::sync_with_stdio(false); cin.tie(NULL);
#endif

  int n; ll k; cin >> n >> k;
  vector<ll> a(n);
  for (ll& x: a) cin >> x;

  ll lo = 1, hi = 1e9;
  while (lo < hi) {
    ll mid = (lo + hi) / 2;
    if (cuts(a, mid) <= k) {
      hi = mid;
    } else {
      lo = mid + 1;
    }
  }
  cout << lo << endl;

  return 0;
}


Measured memory_bytes: 4724
n = int(input())
s = input()

cnt = 0
for i in range(10):
    s_ = s
    if str(0) in s_:
        s_ = s_[s_.index(str(0))+1:]
        if str(0) in s_:
            s_ = s_[s_.index(str(0))+1:]
            if str(i) in s_:
                cnt += 1

for i in range(10,100):
    s_ = s
    if str(0) in s_:
        s_ = s_[s_.index(str(0))+1:]
        if str(i)[0] in s_:
            s_ = s_[s_.index(str(i)[0])+1:]
            if str(i)[1] in s_:
                cnt += 1

for i in range(100,1000):
    s_ = s
    if str(i)[0] in s_:
        s_ = s_[s_.index(str(i)[0])+1:]
        if str(i)[1] in s_:
            s_ = s_[s_.index(str(i)[1])+1:]
            if str(i)[2] in s_:
                cnt += 1  

print(cnt)

Measured memory_bytes: 3188
H, W, K = [int(x) for x in input().split()]

C = []
for i in range(H):
    C.append(input())

ans = 0
for h in range(2 ** H, 2 ** H + 2 ** H):
    bin_h = format(h, 'b')[1:]
    for w in range(2 ** W, 2 ** W + 2 ** W):
        bin_w = format(w, 'b')[1:]
        count = 0
        for i in range(H):
            for j in range(W):
                if bin_h[i] == '0' and bin_w[j] == '0' and C[i][j] == '#':
                    count += 1
        if count == K:
            ans += 1

print(ans)

Measured memory_bytes: 9132
#include<bits/stdc++.h>
 using namespace std;
#define INF 1000000000
#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
typedef long long LL;
LL N;
LL X;
LL x[200011];
LL s[200011];
LL t[200011];
int main(){
	cin>>N>>X;
	REP(i,N){
		cin>>x[i];
	}
	s[0]=0;
	REP(i,N){
		s[i+1]=s[i]+x[i];
	}
	
	t[0]=5;
	t[1]=5;
	for(int i=2;i<N+1;i++){
		t[i]=t[i-1]+2;
	}
	
	LL ans=1e17;
	REP(i,N){
		LL y=i+1;
		LL c=0;
		LL now=0;
		for(int j=N;j>0;j-=y){
			LL aa=max(j-y,LL(0));
			now+=(t[c]*(s[j]-s[aa]));
			//cout<<"miii"<<now<<endl;
			c++;
			if(now>ans)break;
		}
		if(now>ans)continue;
		now+=X*(y+N);
		//cout<<now<<" aaa"<<endl;
		ans=min(ans,now);
	}
	cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 4992
import itertools
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())
for v in itertools.combinations([a,b,c,d,e], 2):
    if v[1]-v[0] > k:
        print(':(')
        exit()

print('Yay!')


Measured memory_bytes: 3060
def gcd(a, b):
    while b != 0:
        a, b = b, a % b
    return a


K = int(input())
tot = 0
for a in range(1, K+1):
    for b in range(1, K+1):
        x = gcd(a, b)
        for c in range(1, K+1):
            y = gcd(x, c)
            tot += y
print(tot)

Measured memory_bytes: 68208
import bisect

n = int(input())

parts = [list(map(int,input().split())) for i in range(3)]

parts[0] = sorted(parts[0])
parts[2] = sorted(parts[2])

c = 0

for i in parts[1]:
    low = 0
    high = 0
    
    low = bisect.bisect_left(parts[0],i)
    high = n-bisect.bisect_right(parts[2],i)
    
    c += (low*high)

print(c)

Measured memory_bytes: 23328
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<cstring>
#include<functional>
#include<stack>
#include<queue>
#include <iomanip>
#include<map>
#include<limits>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<utility>
#include<complex>
#include<cstdlib>
#include<set>
#include<cctype>

#define DBG cerr << '!' << endl;
#define REP(i,n) for(int (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(int (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(int (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int i = 0;i < (n);i++)cerr << v[i] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(10)

using namespace std;

typedef long long ll;
typedef vector<int> iv;
typedef vector<iv> iiv;
typedef vector<string> sv;

int main()
{
	int n,a,b;
	cin >> n >> a >> b;
	
	cout << min(a*n,b) << endl;
	
	return 0;
}

Measured memory_bytes: 764
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
    string s;
    cin>>s;
    ll ans=0,cnt=0;
    int n=s.size();
    rep(i,n){
        if(s[i]=='W')ans+=cnt;
        else ++cnt;
    }
    cout<<ans<<endl;
    return 0;
}


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

int main(){
    int n;
     cin>>n;
     vector<double> v(n);
     rep(i, n) cin>>v[i];
     sort(v.begin(), v.end());
     reverse(v.begin(), v.end());
     double ans = 0.0;
     rep(i, n-1){
         rep(j, i+1){
             v[i] /= 2.0;
         }
         ans += v[i];
     }
    rep(i,n-1) v[n-1] /= 2.0;
    ans += v[n-1];
    cout << ans <<endl;
    return 0;
}

Measured memory_bytes: 256
def main():
    a, b, c, d = list(input())
    ops = ['+', '-']
    for op1 in ops:
        for op2 in ops:
            for op3 in ops:
                s = a + op1 + b + op2 + c + op3 + d
                if eval(s) == 7:
                    print(s + '=7')
                    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include <iostream>
#include <string>

using namespace std;

int main() {
	string S;
	cin >> S;
	int N = S.length();

	int ans = 0;
	for (int i = 1; i < N; ++i) {
		if (S[i - 1] == S[i]) {
			if (S[i] == '1') {
				S[i] = '0';
				ans++;
			} else {
				S[i] = '1';
				ans++;
			}
		}
	}

	cout << ans << endl;
}


Measured memory_bytes: 512
import sys
a = input()
for i in range(8):
    total = int(a[0])
    flag = []
    for j in range(3):
        if ((i >> j) & 1):
            total += int(a[j+1])
            flag.append('+')
        else:
            total -= int(a[j+1])
            flag.append('-')
    if total == 7:
        for k in range(3):
            print(a[k] + flag[k], end = '')
        print(a[3], end = '')
        print('=7')
        sys.exit()

Measured memory_bytes: 3064
/**
 * @brief 8パズル問題を扱う
 *
 * @date 2016/02/29
 */



//****************************************
// 必要なヘッダファイルのインクルード
//****************************************

#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <string>



//****************************************
// 型シノニム
//****************************************

using array1D = std::vector<int>;


//****************************************
// 大域変数の定義
//****************************************

static const int N  = 3;                           /**< 3x3の盤面を考える */
static const int NN = 9;                           /**< 3x3 = 9 */
static const array1D dx = { -1,  0,  1,  0 };      /**< 方向ベクトルのx成分 */
static const array1D dy = {  0, -1,  0,  1 };      /**< 方向ベクトルのy成分 */
static const char dir[] = { 'l', 'u', 'r', 'd' };  /**< 方向ベクトルのキー */



//****************************************
// 構造体の定義
//****************************************

struct puzzle {
    array1D state;
    int space;
    std::string path;

    puzzle() : state(NN) { }

    /**< @brief <演算子オーバーロード */
    bool operator < (const puzzle& p) const
    {
        for (int i = 0; i < NN; i++) {
            if (state[i] == p.state[i]) { continue; }
            return state[i] > p.state[i];
        }
        return false;
    }

    /**< @brief []演算子オーバーロード */
    int& operator [] (std::size_t i)
    {
        return state[i];
    }

     /**< @brief パズルの状態が解決済みか否か返す  */
    bool resolved()
    {
        for (int i = 0; i < NN; i++) {
            if (state[i] != (i + 1)) { return false; }
        }
        return true;
    }
};



/**< @brief 幅優先探索を行い8パズルを解く */
std::string bfs(puzzle s)
{
    std::queue<puzzle> Q;      // パズルを格納するキュー
    std::map<puzzle, bool> V;  // パズルをキーとした連想配列
    puzzle u, v;

    auto init  = [&]() -> void      { s.path = ""; Q.push(s); V[s] = true; };                     // 手続きと同時に始点sを発見
    auto visit = [&](int i) -> void { if (!V[v]) { V[v] = true; v.path += dir[i]; Q.push(v);} };  // 訪問済みの印を刻む

    init();
    while (!Q.empty()) {
        u = Q.front(); Q.pop();
        if (u.resolved()) { return u.path; }  // パズルが解決済みならそれまでの手を返す
        // 現在の空いているマスの座標を取得
        int spaceX = u.space % N;
        int spaceY = u.space / N;
        for (int i = 0; i <= N; i++) {  // 左、上、右、下方向の順にループする
            // ターゲットとなる座標を取得
            int targetX = spaceX + dx[i];
            int targetY = spaceY + dy[i];
            // パズルの範囲外なら隣接していないとみなす
            if (targetX < 0 || targetX >= N || targetY < 0 || targetY >= N) { continue; }
            // 以下、uの隣接リストに属するパズルの状態vを考える
            v = u;
            std::swap(v[u.space], v[targetY * N + targetX]);    // パズルの手を進める
            v.space = targetY * N + targetX;                    // 空いたマスを記憶
            visit(i);                                           // 未訪問ならば、訪問する
        }
    }
    return "unresovable";
}


int main()
{
    using namespace std;
    puzzle p;

    for (int i = 0; i < NN; i++) {
        cin >> p[i];
        if (p[i] == 0) {
            p[i] = NN;
            p.space = i;
        }
    }

    string ans = bfs(p);
    cout << ans.size() << endl;

    return 0;
}

Measured memory_bytes: 39064
H,W,D = list(map(int,input().split()))
mat = [0 for i in range(H*W)]
A = []
for h in range(H):
    a = list(map(int,input().split()))
    A.append(a)
    for w in range(W):
        mat[a[w]-1] = [h,w]
Q = int(input())
LR = [list(map(int,input().split())) for i in range(Q)]
dlist = [0 for i in range(H*W)]
for i in range(H*W):
    if i+1 > D:
        dlist[i] = abs(mat[i][0]-mat[i-D][0]) + abs(mat[i][1]-mat[i-D][1]) +dlist[i-D]
for l,r in LR:
    print(dlist[r-1]-dlist[l-1])

Measured memory_bytes: 45128
n = gets.to_i
a = gets.chomp.chars
b = gets.chomp.chars
c = gets.chomp.chars
res = 0
(0...n).each do |i|
  next if a[i] == b[i] && b[i] == c[i]
  if a[i] != b[i] && b[i] != c[i] && c[i] != a[i]
    res += 2
  else
    res += 1
  end
end
puts res

Measured memory_bytes: 1788
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include <math.h>
#include <limits.h>

int main(void){
    char s[120];
    long long k;
    int count=0;
    scanf("%s%lld",s,&k);
    for (int i=0; i<strlen(s); i++){
        if (s[i]=='1'){
            count++;
        } else {
            break;
        }
    }
    if (count>=k){
        printf("1\n");
    } else {
        printf("%c\n",s[count]);
    }
	return 0 ;
}

Measured memory_bytes: 128
#include<stdio.h>
int main(){
    int a[100],n,i=0,j;
    scanf("%d",&n);
    while(i<n){
        scanf("%d",&a[i]);
        i++;                             
    }
    j=i-1;                                  
    while(0<=j){
        printf("%d",a[j]);
        if(j!=0){
            printf(" ");
        }
        j--;
    }   
    printf("\n");
}

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

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) cin >> A.at(i);
  sort(A.begin(), A.end());
  A.erase(unique(A.begin(), A.end()), A.end());
  cout << ((A.size() % 2) ? A.size() : A.size() - 1) << "\n";
}

Measured memory_bytes: 3744
#include <bits/stdc++.h>
#define ll long long
#define PB push_back
#define MP make_pair

#define REP(i, n) for(int i=0;i<(int)(n);++i)
#define FOR(i,l,h) for(int i=(int)(l);i<=(int)(h);++i)
#define FORD(i,h,l) for(int i=(int)(h);i>=(int)(l);--i)

#define max(a,b) a>b?a:b
#define min(a,b) a>b?b:a

ll gcd(ll a, ll b) { return !b ? a : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }

#define dump(x)  cerr << #x << " = " << (x) << endl
#define ALL(t) (t).begin(),(t).end()

using namespace std;
//const ll int nax = 1000000000000000000;//1e18;

const ll int nax = 1e18;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;cin>>n;
    ll int a[n+2];
    int f = 0,f2 = 0;
    for (int i = 0; i < n; ++i)
    {
        cin>>a[i];
        if(a[i] == 0){
            f = 1;
        }


    }
    //sort(a,a+n);
    if(f == 1){
        cout<<0;
        return 0;
    }
    ll int ans = 1;
    for (int i = 0; i < n; ++i)
    {
        ans *= a[i];
        //dump(ans);
        if(ans > nax || ans <= 0){
            cout<<"-1";
            return 0;
        }

    }
    cout<<ans<<"\n";

    return 0;
}


Measured memory_bytes: 4424
import java.util.*;
public class Main {

	static Scanner sc = new Scanner(System.in);
	static int n, m;
	static double p;
	static int[] x;
	public static void main(String[] args) {
		while(read()){
			solve();
		}
	}
	
	static boolean read(){
		n = sc.nextInt();
		m = sc.nextInt();
		p = sc.nextDouble();
		if(n == 0 && m == 0 && p == 0)return false;
		x = new int[n];
		for(int i = 0; i < x.length; i++){
			x[i] = sc.nextInt();
		}
		return true;
	}
	
	static void solve(){
		double sum = 0.0;
		for(int i = 0; i < x.length; i++){
			sum += x[i];
		}
		sum *= 100;
		double per = p/100;
		sum -= sum*per;
		//System.out.println(sum);
		if(x[m-1] == 0){
			System.out.println(0);
		}else{
			int res = (int)sum/x[m-1];
			System.out.println(res);
		}
	}

}

Measured memory_bytes: 13000
N,M = map(int,input().split())
LRlist = [tuple(map(int,input().split())) for _ in range(M)]

min_n = 0
max_n = N
for l,r in LRlist:
    min_n = l if l>min_n else min_n
    max_n = r if r<max_n else max_n

ans = max_n-min_n+1
print(ans if ans>0 else 0)

Measured memory_bytes: 16624
fun main(args: Array<String>) {
  val (H, N) = readLine()!!.split(" ").map{it.toInt()}
  val A = readLine()!!.split(" ").map{it.toInt()}
  var atack_sum = 0
  var noFlag = true
  for(i in A) {
    atack_sum += i
    if(atack_sum >= H) {
      print("Yes")
      noFlag = false
      break
  	}
  }
  if(noFlag) {
  	print("No")
  }
}

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

#define rule(x) vec[0] % x == 0 && vec[1] % x == 0 && vec[2] % x == 0

int main() {
	int n; cin >> n; vector<int> vec(n);
	bool check = false;
	for (int i = 0; i < n; i++) cin >> vec[i];
	if (rule(2)) check = true;
	stable_sort(vec.begin(), vec.end());
	if (check == true) for (int i = 1; i <= vec[0]; i++) {
		if (rule(i)) cout << i << endl;
	}
	else for (int i = 1; i <= vec[0]; i += 2) {
		if (rule(i)) cout << i << endl;
	}
	return 0;
}


Measured memory_bytes: 3164
//#include <bits/stdc++.h>                          //include all library
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <map>
#include <sstream>
#include <vector>
#include <stack>
#include <queue>
#include <string.h>
#include <functional> // greater<int> はfunctionalヘッダ
using namespace std;

#define REP(i, n) for(int i = 0;i < n;i++)          //REP(i, 10){...} //i=0～i=9までのループ
#define REPR(i, n) for(int i = n;i >= 0;i--)        //REPR(i, 10){...} //i=10～i=0までのループ
#define FOR(i, m, n) for(int i = m;i < n;i++)       //FOR(i, 3, 10){...} //i=3～i=9までのループ
#define FORR(i, m, n) for(int i = m;i >= n;i--)     //FORR(i, 10, 3){...} //i=10～i=3までのループ
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
#define PI 3.141592653589
#define npos -1


int main(){
	int N, M;
	cin >> N >> M;

	vector<int> a(N+1, 1);    //その段が使えるかどうかを表す, 0ならその段は使えない
	for(int i=0; i<M; i++){
		int k=0;
		cin >> k;
		a[k] = 0;
	}

	vector<int> s(N+1, 0);
	s[0] = 1;
	s[1] = a[1];

	for(int i=2; i<N+1; i++){
		s[i] = (s[i-2] + s[i-1])*a[i]%1000000007;  //a[i]==0なら0, ==1なら二段分
	}

	cout << s[N] << endl;
}

Measured memory_bytes: 1024
n,k = map(int,input().split())
x = list(map(int, input().split()))
ans = 10 **10
rx = x[k-1:]
for i, j in zip(x,rx):
    if ans >= abs(i -j) + min(abs(i),abs(j)):
        ans = abs(i -j) + min(abs(i),abs(j))
print(ans)

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

using ll=long long;



void solve(){
    vector<int> a(3);
    for(auto& e:a)cin>>e;
    sort(a.begin(), a.end());
    cout<<a[1]+a[0]<<endl;
}

signed main(){
    //while(1)
    solve();
}

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

using namespace std;

int main(){
 string w;
  cin >> w;
  
  int cnt[26]={0};
  
  for(int i=0;i<w.length();i++){
   cnt[w[i]-'a']++;
  }
  bool res=true;
  
  for(int i=0;i<26;i++){
   if(cnt[i]%2!=0) res=false;
  }
    
  if(res)  cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
import sys
import os
import itertools

def file_input():
    f = open('ABC167/input.txt', 'r')
    sys.stdin = f

def main():
    #file_input()
    # int(input())
    N,M,X=map(int, input().split())
    C=[0]*N
    A=[[0 for j in range(M)] for i in range(N)]
    for i in range(N):
        tmp=list(map(int, input().split()))
        C[i]=tmp[0]
        A[i]=tmp[1:]

    sum=0
    min=100000000
    A_sum=[0]*M
    for i in range(N):
        for li in itertools.combinations(range(0,N),i+1):
            # print(li)
            sum=0
            A_sum=[0]*M
            for j in li:
                sum+=C[j]
                for l in range(M):
                    A_sum[l]+=A[j][l]
            # print(sum)
            for l in range(M):
                if A_sum[l]<X:
                    break
                if l==M-1 and min>sum:
                    min=sum

    if min==100000000:
        print(-1)
    else :
        print(min)

if __name__ == '__main__':
    main()


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

int main(){
    long long n,q;
    long long k;

    cin >> n >> k >> q;

    long long p[n];
    for(long long i=0;i<n;i++)    p[i] = k-q;

    long long a[q];
    for(long long i=0;i<q;i++)  cin >> a[i];

    for(long long i=0;i<q;i++){
        p[a[i]-1]++;
    }

    for(long long i=0;i<n;i++){
        if(p[i]>0)
            puts("Yes");
        else
        {
            puts("No");
        }
        
    }
}

Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define Mod  1000000007
ll fast(ll n,ll a,ll M)
{
    if(n==0)
        return 1;
    else if(n==1)
        return a;
    else
    {
        ll res=fast(n/2,a,M);
        if(n%2==0)
        {
            return ((res%M)*(res%M))%M;
        }
        else
        {
            return (((((res%M)*a)%M)*res)%M);
        }
    }
}
int main()
{
   ll N;
   cin>>N;
   ll i;
   ll ans=0;
   for(i=1;i<=N;i++)
   {
       if(i%3!=0&&i%5!=0)
       {
           ans+=i;
       }
   }
   cout<<ans;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,x;
  cin >> n >> x;
  int l[n];
  int d = 0;
  int ans = 1;
  for(int i = 0;i < n;i++){
    cin >> l[i];
    d += l[i];
    if(d <= x)ans++;
  }
  cout << ans << endl;
}
    
    

Measured memory_bytes: 256
/* ex 5_4
   KKOO */

#include <stdio.h>
#include <string.h>

int main(void){
    char sequence[11];
    int length, count=0, max=0;
    //count...連続で並んでいるATGCの数を数える
    //max...最も長いATGC文字列の長さを格納する

    scanf("%s", sequence);
    length = strlen(sequence);

    //i番目の文字がATGCのいずれかであればcountに1を加え、そうでなければcountの値をmaxに格納する
    //i=lengthの時sequence[i]はヌル文字になるので必ずelse文の操作を実行する
    for(int i=0; i<=length; i++){
        if(sequence[i]=='A' || sequence[i]=='C' || sequence[i]=='G' || sequence[i]=='T'){
            count ++;
        }
        else{
            if(max < count){
                max = count;
                count = 0;
            }
        }
    }

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

    return 0;
}


Measured memory_bytes: 1720
#include<stdio.h>
int main(){
  int h,w;
  int i,j;
  scanf("%d %d",&h,&w);
  while(h!=0||w!=0){
    for(i=0;i<h;i++){
      for(j=0;j<w;j++){
	if(i==0||i==h-1||j==0||j==w-1){
	  printf("#");
	}else{
	  printf(".");
	}
      }
      printf("\n");
    }
    printf("\n");
    scanf("%d %d",&h,&w);
  }
  return(0);
}

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

int main() {
	int A, B;
	int m, wa,sa,seki;
	
	cin >> A >> B;
	
	wa = A + B;
	sa = A - B;
	m = max(wa, sa);
	
	seki= A * B;
	
	m = max(m,seki);
	
	cout << m << endl;
	
	
	return 0;
}

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

bool isa(string s) {
    int pos = 2,cnt = 0;
    if(s[pos] != '=') return false;
    while(s[pos] == '=') pos++,cnt++;
    if(s[pos] != '#') return false;
    pos++;

    for(int i=0; i<cnt; ++i) {
        if(s[pos+i] != '=') return false;
    }
    pos += cnt;
    if(pos == s.length()-1 && s[pos] == '~') return true;
    return false;
}

bool isb(string s) {
    int pos = 2;
    if(s[2] != 'Q' || s[3] != '=') return false;
    for(; pos < s.length()-2; pos += 2)
        if(s[pos] != 'Q' || s[pos+1] != '=') return false;

    if(s[s.length()-1] == s[s.length()-2] && s[s.length()-1] == '~') return true;
    return false;
}

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

    string s;
    for(int i=0; i<n; ++i) {
        cin>>s;

        if(s.length() <= 2 || s[0] != '>') {
            cout<<"NA"<<endl;
        } else if(s[1] == '\'') {
            if(isa(s)) {
                cout<<"A"<<endl;
            }else{
                cout<<"NA"<<endl;
            }
        } else {
            if(isb(s)) {
                cout<<"B"<<endl;
            }else{
                cout<<"NA"<<endl;
            }
        }
    }
}

Measured memory_bytes: 0
#include <stdio.h>

int main(){
  int L, R, d;
  int cnt = 0;
  
  scanf("%d%d%d",&L,&R,&d);
  
  for(int i = L; i <= R; i++){
    if(i % d == 0) cnt++;
  }
  
  printf("%d\n", cnt);
  
  return 0;
}

Measured memory_bytes: 1736