akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;
int main(){
  int m,f,r;
  for(int i=0;i<51;i++){
    cin >> m >> f >> r;
    if((m==-1 && f==-1) && r==-1) break;
    else if(m==-1 || f==-1) cout << "F" << endl;
    else{
      if(80<=(m+f)) cout << "A" << endl;
      else if(65<=(m+f) && (m+f)<80) cout << "B" << endl;
      else if(50<=(m+f) && (m+f)<65 || r>=50) cout << "C" << endl;
      else if(30<=(m+f) && (m+f)<50) cout << "D" << endl;
      else if((m+f)<30) cout << "F" << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 3104
import           Control.Applicative (liftA2)
import           Control.Monad       (replicateM)

main :: IO ()
main = do
  antennas <- replicateM 5 readLn
  k <- readLn
  putStrLn $ toOutput $ solve k antennas

toOutput :: Bool -> String
toOutput False = ":("
toOutput True  = "Yay!"

solve :: Int -> [Int] -> Bool
solve k antennas = all (k >=) $ liftA2 distance antennas antennas

distance :: Num a => a -> a -> a
distance x y = abs $ x - y


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

using namespace std;

int main(){

    int n,maior=0,soma=0,soma_acumulada=0;
    int a[100],b[100];

    cin >> n;

    for(int i=1;i<=n;i++){
        cin >> a[i];
    }
    for(int j=1;j<=n;j++){
        cin >> b[j];
    }
    for(int k=1;k<=n;k++){
        soma_acumulada+=a[k];
        soma=soma_acumulada;
        for(int l=k;l<=n;l++){
            soma+=b[l];
        }
        maior=max(maior,soma);
    }

    
    cout << maior << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
const int INF=1e9;
const int MOD=1e9+7;
//const int MOD=998244353;
const long long LINF=1e18;
using namespace std;
#define int long long
//template
int dp[105][100005];
//main
signed main(){
  int N,K;cin>>N>>K;
  std::vector<int> v;
  for(int i=1;i*i<=N;i++)v.push_back(N/i-N/(i+1));
  int sum=0;
  for(int p:v)sum+=p;
  while(sum++<N)v.push_back(1);
  int S=v.size();
  memset(dp,0,sizeof(dp));
  dp[0][0]++;
  for(int i=0;i<K;i++){
    for(int j=0;j<S-1;j++)dp[i][j+1]+=dp[i][j],dp[i][j+1]%=MOD;
    for(int j=0;j<S;j++)dp[i+1][j]=dp[i][S-1-j]*v[S-1-j]%MOD;

  }
  int ans=0;
  for(int j=0;j<S;j++)ans+=dp[K][j],ans%=MOD;
  cout<<ans<<endl;
}


Measured memory_bytes: 82936
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define vii vector<int>
#define vll vector<ll>
#define mat vector<vector<ll>>
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define eb emplace_back
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (ll) (x).size()
#define pq priority_queue<ll>
#define pqg priority_queue<ll,vector<ll>,greater<ll>>
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) sort(v.begin(),v.end());v.erase(unique(v.begin(),v.end()),v.end())
#define int ll
// #define ll int
using namespace std;
const ll INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
const ll mod = 998244353;
const ll MAX = 2100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[8] ={1,0,-1,0,1,-1,1,-1};
ll dy[8] ={0,1,0,-1,1,-1,-1,1};
 
template<class T> 
inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> 
inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


void solve(){
    ll n,k,a[200010];
    cin>>n>>k;
    rep(i,n) cin>>a[i];
    rep2(i,k,n){
        if(a[i-k]<a[i]) cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
        

    }
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    
     

    solve(); 


    return 0;
}


Measured memory_bytes: 5216
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int N;
    cin >> N;
    int ma = 0;
    int resmax = 0;
    
    if (N == 1) ma = 1;
    for (int i = N; 0 < i; --i){
        int P = i;
        int res = 0;

        while(true){
            if (P % 2 == 0)
            {
                ++res;
                P = P / 2;
            } else {
                break;
            }
        }
        if (res > resmax){
            ma = i;
            resmax = res;
        }
    }
    cout << ma << endl;
}

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;

const ll MOD = 1e9 + 7;
const int MAX = 2e5 + 1;

ll fac[MAX];
void init() {
    fac[0] = 1;
    for (int i = 1; i < MAX; i++) {
        fac[i] = fac[i - 1] * i % MOD;
    }
}

ll rep_pow(int n, int p) { // n^p
    if (p == 0) {
        return 1;
    }
    if (p % 2 == 0) {
        ll t = rep_pow(n, p / 2);
        return t * t % MOD;
    } else {
        return n * rep_pow(n, p - 1) % MOD;
    }
}

ll com(int n, int k) {
    if (n < k || n < 0 || k < 0) {
        return 0;
    }
    return fac[n] * rep_pow(fac[k], MOD - 2) % MOD * rep_pow(fac[n - k], MOD - 2) % MOD;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    init();
    ll n, k;
    cin >> n >> k;
    ll lim = min(k, n - 1);
    vector<int> dp(lim + 1, 1);
    for (int i = 1; i <= lim; i++) {
        dp[i] = dp[i - 1] + com(n, i) * com(n - 1, n - i - 1) % MOD;
        dp[i] %= MOD;
    }
    cout << dp[lim] << endl;
    return 0;
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
#define rep(i, x, n) for(int i = x; i < n; i++)
#define repr(i, x, n) for(int i = x; i > n; i--)
#define pii pair<int,int>
#define ll long long
const long long iinf = 1e18;
const int inf = 1e9;
const int MOD = (1e6+3);
int dir4[4][2] = {{1,0},{-1,0},{0,1},{0,-1}};
int knight[8][2] = {{2,1},{2,-1},{-2,1},{-2,-1},{1,2},{-1,2},{1,-2},{-1,-2}};

using namespace std;

void solve()
{
    char c;
    cin >> c;
    if( c >= 'a' && c <= 'z') cout << 'a';
    else cout << 'A';

}
//new line is printed in the main

int main()
{
    int t = 1;
        // cin >> t; // comment out if no test case is required
    // int i = 1;
    while(t--){
        //cout << "Case " << i++ << ": ";
        solve();
        // printf("\n");
    }
    return 0;
}


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

int main(){
  string S,T;
  cin>>S>>T;
  for(int i=0;i<T.size();i++){
        cout<<S.at(i)<<T.at(i);
     }
  if(S.size()==T.size()){
    cout<<endl;
  }
  if(S.size()!=T.size()){
    cout<<S.at(S.size()-1)<<endl;
  }
}

Measured memory_bytes: 256
nums = sorted(list(map(int,input().split())))
group1 = []
group2 = []
ans = 0
for i in range(3):
 if nums[i] % 2==0:
     group1.append(i)
 else:
     group2.append(i)
max_len = max(len(group1),len(group2))
if max_len != 3:
    ans += 1
    if len(group1) == 2:
        for i in group1:
            nums[i] += 1
    else:
        for i in group2:
            nums[i] += 1
ans += (nums[2]-nums[0])//2 + (nums[2]-nums[1])//2
print(ans)

Measured memory_bytes: 38256
#include<stdio.h>
#include<algorithm>

int main()
{
	long long n, ans=1e12+1;
	scanf("%lld", &n);

	for (long long i=1; i*i<=n; i++){
		if(n%i==0){
			ans = std::min(ans, i+n/i-2);
		}
	}

	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define show(x) {for(auto i: x){cout << i << " ";} cout << endl;}
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  string S;
  cin >> S;
  map<char, int> mp;
  rep(i, 4) mp[S[i]]++;
  bool bl = true;
  for (auto p : mp) {
    if (p.second != 2) bl = false;
  }
  puts(bl ? "Yes" : "No");
  return 0;
}

Measured memory_bytes: 3628
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <stack>
#include <queue>
#include <string>
#include <math.h>

#define REP(i,n)for (int i=0;i<(n);i++)
#define PB push_back
#define MP make_pair
#define ALL(a) (a).begin(),(a).end()
#define ll long long
using namespace std;
typedef pair<int,int> P;

bool kage[41][21];

int main(){
	int n,r;
	while(1){
		cin>>r>>n;
		if(r+n==0)break;
		memset(kage,false,sizeof(kage));
		REP(i,n){
			int x1,x2,h;
			cin>>x1>>x2>>h;
			for(int x=x1+20;x<x2+20;x++){
				for(int y=0;y<h;y++){
					kage[x][y]=true;
				}
			}
		}
		bool w=false;
		double ans=0.0;
		REP(i,21){
			int c=0;
			while(kage[20+c][i]&&kage[19-c][i])c++;
			if(c==0){
				ans=min((double)i,ans);
				break;
			}
			if(c>=r){
				ans=(double)(i+1);
			}else{
				double res=(double)(r)-sqrt((double)(r*r)-(double)(c*c));
				if(w){
					ans=min((double)i+res,ans);
				}else{
					ans+=res;
					w=true;
				}
			}
		}
		printf("%.4f\n",min(ans,20.0));
	}
}


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

int main(){
    int number;
    cin >> number;
    char info[number];
    cin >> info;

    int i = 0;
    int red = 0;

    while(info[i] != '\0'){
        if(info[i] == 'R'){
            red++;
        }
        i++;
    }

    if(red == number / 2){
        cout << "No" << endl;
    }else if(red > number / 2){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}




Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iterator>
#include <set>
#include <queue>
#include <iostream>
#include <sstream>
#include <stack>
#include <deque>
#include <map>
#include <cmath>
#include <memory.h>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <algorithm>
#include <utility>
#include <time.h>

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,b,a) for(int i=(b)-1;i>=(a);--i)
#define FILL(A,val) memset(A,val,sizeof(A))
#define ITER(it,a) for(__typeof(a.begin()) it=a.begin();it!=a.end();++it)
#define DBG1(a) cerr<<#a<<" = "<<(a)<<"\n"
#define DBG2(a,b) cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<"\n"

#define ALL(V) V.begin(),V.end()
#define SZ(V) (int)V.size()
#define PB push_back
#define MP make_pair
#define y1 frgrwegreg

typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef pair<int, int> PII;
typedef pair<double, double> PDD;

const double PI = acos(-1.0);
const int MOD = 1000 * 1000 * 1000 + 7;
const int MAX = 100017;


int main()
{
	//freopen("C.in", "r", stdin);
	//freopen("out.txt", "w", stdout);
	//ios::sync_with_stdio(0); cin.tie(0);

	string s, s2 = "CODEFESTIVAL2016";
	cin >> s;
	int ans = 0;
	FOR (i,0,s.size())
	if (s[i] != s2[i]) ans++;
	cout << ans << endl;
	return 0;

}


Measured memory_bytes: 256
#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;

using Edge = pair<int, int>;
using Graph = vector<vector<Edge>>;

#pragma endregion

Graph G;

vector<int> res;

void dfs(int v, int p, int c) {
    res[v] = c;
    for (auto e:G[v]) {
        if (e.first == p) continue;
        if (e.second & 1) dfs(e.first, v, 1-c);
        else dfs(e.first, v, c);
    }
}

int main(){
    int n;
    cin >> n;
    G.assign(n, vector<Edge>());
    res.assign(n, 0);
    REP(i, n-1){
        int u, v, w;
        cin >> u >> v >> w;
        u--, v--;
        G[u].push_back(Edge(v, w));
        G[v].push_back(Edge(u, w));
    }
    dfs(0, -1, 1);
    for (auto v:res) cout << v << endl;
    return 0;
}

Measured memory_bytes: 11740
n,*cc = map(int, open(0).read().split())
MOD = 10**9+7

from collections import defaultdict
d = {}
dp = defaultdict(lambda: 1)

for i,c in enumerate(cc):
    dp[i] = dp[i-1]
    if c in d:
        j = d[c]
        if i - j > 1:
            dp[i] += dp[j]
            dp[i] %= MOD
    d[c] = i

print(dp[n-1])

Measured memory_bytes: 154104
#include <iostream>
#include <vector>
#include <deque>

using namespace std;

int N,K;
vector<int> P;


int main()
{
	int ans = 1;

	cin >> N;
	cin >> K;

	P = vector<int>(N);
	for (int i = 0; i < N; i++) {
		cin >> P.at(i);
	}


	int sc = 1;
	bool sorted = false;
	deque<int> deq_min,deq_max;
	for (int i = 0; i < N; i++) {
		while (!deq_min.empty() && P.at(deq_min.back()) >= P.at(i)) {
			deq_min.pop_back();
		}
		deq_min.push_back(i);

		if (deq_min.front() == i - K - 1) {
			deq_min.pop_front();
		}

		while (!deq_max.empty() && P.at(deq_max.back()) <= P.at(i)) {
			deq_max.pop_back();
		}
		deq_max.push_back(i);

		if (deq_max.front() == i - K - 1) {
			deq_max.pop_front();
		}


		if (i > 0 && P.at(i) > P.at(i - 1)) {
			sc++;
			if (sc >= K) {
				sorted = true;
			}
		}
		else {
			sc = 1;
		}


		if (i >= K) {
			if (!(deq_min.front() == i - K
					&& deq_max.front() == i)
				&& sc < K 
				){
				ans++;
			}
		}
		else if (i == K - 1) {
			if (sc >= K) { ans--; }
			
		}
	}

	if (sorted) { ans++; }


	cout << ans << endl;


	return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i, a) for (int i = (int)0; i < (int)a; ++i)
#define rrep(i, a) for (int i = (int)a - 1; i >= 0; --i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define RREP(i, a, b) for (int i = (int)a - 1; i >= b; --i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
using ll = long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;

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

ll gcd(ll n, ll m)
{
	ll tmp;
	while (m != 0)
	{
		tmp = n % m;
		n = m;
		m = tmp;
	}
	return n;
}

ll lcm(ll n, ll m)
{
	return abs(n) / gcd(n, m) * abs(m); //gl=xy
}

using namespace std;


void solve()
{
	int h1,m1,h2,m2,k;
	cin>>h1>>m1>>h2>>m2>>k;
	h1+=k/60;
	m1+=k%60;
	if(m1>=60){
		h1++;
		m1%=60;
	}
	cout<<(h2-h1)*60+m2-m1<<"\n";
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(15);
	solve();
	return 0;
}


Measured memory_bytes: 3652
m=gets.to_i
n=gets.to_i
e=Array.new(m+1){[]}
n.times do
  x,y=gets.split.map &:to_i
  e[x]<< y
end
r=[2]
while r.size<m
  1.upto(m) do |i|
    next if r.include? i
    catch(:a){
      e[i].each do |j|
        throw :a if !r.include? j
      end
      r<< i
    }
  end
end
puts r.reverse

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

int main() {
    int N;
    string S;

    cin >> N;
    cin >> S;

    string i = "000";
    int cnt = 0;

    int ans = 0;

    while(cnt<1000){
        bool flag0 = true;
        bool flag1 = false;
        bool flag2 = false;
        for(int j=0; j<N; j++){
            if(flag0){
                if(S[j]==i[0]){
                    flag0 = false;
                    flag1 = true;
                }
            }
            else if(flag1){
                if(S[j]==i[1]){
                    flag1 = false;
                    flag2 = true;
                }
            }
            else if(flag2){
                if(S[j]==i[2]){
                    ans++;
                    break;
                }
            }
        }

        // 数字を1進める
        if(i[2]=='9'){
            i[2] = '0';
            if(i[1]=='9'){
                i[1] = '0';
                i[0] += 1;
            } else{
                i[1] += 1;
            }
        } else{
            i[2] += 1;
        }
        cnt++;
        // while文の終わり
    }

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

Measured memory_bytes: 256
def moji(x):
    return chr(x + 96)

n = int(input())
s = ""

cnt = 0
a = 26
i = 1

while(1):
    if n <= a:
        cnt = i
        break
    i += 1
    a = 26 ** i + a



for i in range(1, cnt+1):
    if i != 1:
        n = n - (26**(i-1))
    if i == 1:
        k = n % 26
        if k == 0:
            k = 26
        s += moji(k)
    else:
        if n %  (26 ** (i-1)) == 0:
            k = (n // (26 ** (i-1))) % 26
        else:
            k = (n // (26 ** (i-1))) % 26 + 1
        if k == 0:
            k = 26
        s += moji(k)

print(s[::-1])

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

#define REP(i, n) for(int i = 0; i < n; i++)
using namespace std;

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

    vector<long int> ai(1e5);

    REP(i, n) {
        long int a;
        cin >> a;

        ai[a+1]++;

    }

    long ans = 0;

    REP(i, ai.size()+2) {
        ans = max(ans, ai[i] + ai[i+1] + ai[i+2]);
    }

    cout << ans << endl;

}

Measured memory_bytes: 1024
n = $stdin.gets.chomp.to_i
arr = gets.chomp.split(' ').map(&:to_i)

flag = 0
n.times do |k|
  if arr[k] % 2 == 0
    if arr[k] % 3 == 0 || arr[k] % 5 == 0
    # フラグはそのまま
    else
      flag = 1
      break
    end
  end
end

if flag == 0
  puts "APPROVED"
else
  puts "DENIED"
end

Measured memory_bytes: 14260
A=int(input())
B=int(input())
C=int(input())
X=int(input())
counter =0
for i in range(A+1):
    for j in range(B+1):
        for k in range(C+1):
            if 500*i+100*j+50*k == X:
                counter+=1
print(counter)

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

#define int long long
#define fi first
#define se 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 rep11(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define repm(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end())
#define vdelete(v) (v).erase(unique(all(v)), (v).end())
#define pb(n) push_back(n)
#define mp make_pair
#define MOD 1000000007
#define INF 9223372036854775807

int n,k;

signed main() {
    cin >> n >> k;
    cout << n-k+1 << endl;
}












Measured memory_bytes: 256
# ABC054C - One-stroke Path
from itertools import permutations as perm


def main():
    N, M, *A = map(int, open(0).read().split())
    E = {(i, j) for i, j in zip(A[::2], A[1::2])}
    E |= {(j, i) for i, j in zip(A[::2], A[1::2])}  # add reversed paths
    ans = 0
    for path in perm(range(2, N + 1), N - 1):  # check all possible paths (O(N!))
        path = (1,) + path
        if all((i, j) in E for i, j in zip(path, path[1:])):
            ans += 1
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define inf (int)(1e9+7)
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }



int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    
   
    int l, k;
    cin >> l >> k;
    
    ll dp[104][2] = {0};
    dp[1][0] = 1;
    dp[k][0] = 1;
    
    rep(i, l) rep(j, 2) {
        if (dp[i][j] == 0) continue;
        dp[i + 1][j ^ 1] += dp[i][j];
        if (j == 1) dp[i + k][j ^ 1] += dp[i][j];
    }
    
    ll ans = 0;
    rep(i, l + 1) ans += dp[i][0];
    cout << ans << endl;
}





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

int main()
{
	int *s, *t;
	int nums, numt;
	cin>>nums;
	s=new int[nums];
	for( int i=0; i<nums; i++ ){
		cin>>s[i];
	}

	cin>>numt;
	t=new int[numt];
	for( int i=0; i<numt; i++ ){
		cin>>t[i];
	}


	int ans=0;
	bool isfind=false;

	for( int i=0; i<numt; i++ ){

		for( int j=0; j<nums; j++ ){
			if( s[j] == t[i] ){
				ans++;
				break;


			}
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 1224
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
int INF = 1e9+7;
int mod = 1e9+7;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int gcd(int X,int Y) {
    if(X%Y == 0) {
        return Y;
    }
    else {
        return gcd(Y,X%Y);
    }
}
signed main() {
    int N,M;
    cin >> N >> M;
    string S,T;
    cin >> S >> T;
    int X = gcd(N,M);
    for(int i = 0; i < X; i++) {
        if(S[N/X*i] != T[M/X*i]) {
            cout << -1 << endl;
            return 0;
        }
    }
    cout << N/X*M << endl;
}


Measured memory_bytes: 3728
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<vector>
using namespace std;

int main(){
    int N, K;
    cin >> N >> K;
    vector<int> p(N);
    for (int i = 0; i < N; i++){
        cin >> p[i];
    }
    sort(p.begin(), p.end());
    int ans = 0;
    for(int i = 0; i < K; i++) ans += p[i];
    cout << ans << endl;
    return 0;
    
}

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

int main(){
    using namespace std;
    unsigned long N, M;
    cin >> N >> M;
    for(unsigned long i{0}, j{1}, k{N}; i < M; ++i, j += ~N & (j == N / 4 + 1))cout << j++ << " " << k-- << endl;
    return 0;
}

Measured memory_bytes: 3564
// finish date: 2018/01/21
#include <iostream>
#include <cmath>
#include <vector>
#include <bitset>
#include <algorithm>
#include <stack>
#include <map>
#include <climits>

using namespace std;

#define FOR(i, a, b) for(int (i)=a;(i)<(b);(i)++)
#define rep(i, n)  FOR(i,0,n)
#define ll long long
#define bigmod 1000000007
#define INF 500000000


int main() {
    int N, A, B;
    cin >> N >> A >> B;
    int n, sum;
    int ans=0;
    rep(i, N+1) {
        n = i;
        sum = 0;
        while (n != 0) {
            sum += n % 10;
            n /= 10;
        }
        if (A <= sum && sum <= B) ans+=i;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
int max(int x,int y){
	return x>y?x:y;
}
char ch;
int sum,ans;
int main(){
	for(int i=1;i<=3;++i){
		ch=getchar();
		if(ch=='S'){
			ans=max(ans,sum);
			sum=0;
		}
		else sum++;
	}
	ans=max(ans,sum);
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 3152
#pragma optimization_level 3
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#define F first
#define S second
#define vec vector
#define pb push_back
#define pll pair<ll,ll>
#define pdd pair<ld, ld>
#define pq priority_queue
#define umap unordered_map
#define uset unordered_set
#define pii pair<int, int>
#define pnn pair<Node*, Node*>
#define uid uniform_int_distribution
#define FILE ifstream in("input.txt");ofstream out("output.txt");
#define fast cin.tie(0);cout.tie(0);cin.sync_with_stdio(0);cout.sync_with_stdio(0);
using namespace std;
typedef string str;
typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

int main() {
    fast;
    ll a,k; cin>>a>>k;
    vec<pll> m(a);
    for(int q=0;q <a; q++){
        cin>>m[q].F>>m[q].S;
    }
    vec<ll> dp(k+1);
    for(int q=0; q<a; q++){
        ll w = m[q].F, c = m[q].S;
        auto was = dp;
        for(int e=w; e<=k; e++) dp[e] = max(dp[e], was[e-w]+c);
    }
    ll o = 0;
    for(ll i : dp) o = max(o, i);
    cout<<o;
}

Measured memory_bytes: 1804
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int inf = 1001001001;


vector<pair<ll,ll>> prime_factorize(ll n){
    vector<pair<ll,ll>> res;
    for(ll p=2; p*p<=n; p++){
        if(n%p!=0) continue;
        int num=0;
        while(n%p==0){
            n/=p;
            num++;
        }
        res.push_back(make_pair(p,num));
    }
    if(n!=1) res.push_back(make_pair(n,1));
    return res;
}
int main(){

    ll n;
    cin >> n;
    auto sayuri=prime_factorize(n);
    ll ans=0;
    for(auto x : sayuri){
        ll y=x.second;
        ll a=0,b=1;
        while(y>=b){
            y-=b;
            b++;
            a++;
        }
        ans+=a;
    }

    cout << ans << endl;
 
}

Measured memory_bytes: 3632
//g++  7.4.0

#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main()
{
    ll N; cin>>N;
    ll mx = 0;
    ll ans = 0;
    
    for(ll i=0;i<N;++i)
    {
        ll val; cin>>val;
        ans += max(0LL,mx - val);
        mx = max(mx,val);
    }
    
    cout<<ans<<endl;
    
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
int myabs(int x){return x<0?-x:x;}
int main()
{
	int x,a,b;
	scanf("%d%d%d",&x,&a,&b);
	if(myabs(x-a)>myabs(x-b)) printf("B\n");
	else printf("A\n");
	return 0;
}


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

int main(void){
  int n;
  long long ans=0,cnt[5]={0};
  
  cin >> n;
  for (int i=0; i<n; i++){
    string s;
    cin >> s;
    if (s[0]=='M') cnt[0]++;
    else if (s[0]=='A') cnt[1]++;
    else if (s[0]=='R') cnt[2]++;
    else if (s[0]=='C') cnt[3]++;
    else if (s[0]=='H') cnt[4]++;
  }
  // ハードコード許して
  ans += cnt[0]*cnt[1]*cnt[2];
  ans += cnt[0]*cnt[1]*cnt[3];
  ans += cnt[0]*cnt[1]*cnt[4];
  ans += cnt[0]*cnt[2]*cnt[3];
  ans += cnt[0]*cnt[2]*cnt[4];
  ans += cnt[0]*cnt[3]*cnt[4];
  ans += cnt[1]*cnt[2]*cnt[3];
  ans += cnt[1]*cnt[2]*cnt[4];
  ans += cnt[1]*cnt[3]*cnt[4];
  ans += cnt[2]*cnt[3]*cnt[4];
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define VS vector<string>
#define VB vector<bool>
#define VP vector<pair<ll,ll>>
#define VVL vector<vector<ll>>
#define VVP vector<vector<pair<ll,ll>>>
#define PL pair<ll,ll>
#define ALL(v) (v).begin(), (v).end()
ll d1[4] = {1, -1, 0, 0};
ll d2[4] = {0, 0, 1, -1};

int main(){
    string s;
    ll x, y;
    cin >> s >> x >> y;
    s.push_back('T');
    VL ax, ay;
    ll f = 0, c = 0;
    for(auto e : s){
        if(e == 'T'){
            if(f % 2 == 0) ax.push_back(c);
            else ay.push_back(c);
            c = 0;
            f++;
        }else{
            c++;
        }
    }
    vector<VB> dpx(8010, VB(16010, false)), dpy(8010, VB(16010, false));
    dpx[0][8000] = true;
    dpy[0][8000] = true;
    rep(i, 0, ax.size()){
        rep(j, 0, 16010){
            if(dpx[i][j]){
                dpx[i+1][j+ax[i]] = true;
                if(i != 0) dpx[i+1][j-ax[i]] = true;
            }
        }
    }
    rep(i, 0, ay.size()){
        rep(j, 0, 16010){
            if(dpy[i][j]){
                dpy[i+1][j+ay[i]] = true;
                dpy[i+1][j-ay[i]] = true;
            }
        }
    }
    if(dpx[ax.size()][x+8000] && dpy[ay.size()][y+8000]) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 35416
// Last Change: 04/03/2019 22:16:50.
#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using ll = long long;

namespace NS {
void LoopUntilZeroInpput() {
  int hogegegege = 0;
  while (cin >> hogegegege && hogegegege != 0) {
  }
}
} // namespace NS

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

  bool ans = true;
  int C = 0;
  const int sSize = S.size();
  for (int i = 0; i < sSize; ++i) {
    if (i == 0) {
      if (S[i] != 'A') {
        ans = false;
      }
    } else if (i >= 2 and i <= sSize - 2) {
      if (S[i] == 'C') {
        ++C;
      } else {
        if (S[i] >= 'A' and S[i] <= 'Z') {
          ans = false;
        }
      }
    } else {
      if (S[i] >= 'A' and S[i] <= 'Z') {
        ans = false;
      }
    }
  }

  if (C != 1) {
    ans = false;
  }

  if (ans) {
    cout << "AC" << endl;
  } else {
    cout << "WA" << endl;
  }

  //NS::LoopUntilZeroInpput();
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;
int a[100],sum = 0;
int main(){
	int i,j,n;
	cin >> n;
	for(i=0;i<n;i++){
		cin >> a[i];
	}
	for(i=0;i<n;i++){
		for(j=i + 1;j<n;j++){
			sum += a[i]*a[j];
		}
	}
	cout << sum << endl;
}

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

using ll = long long;
const int mod = 1e9 + 7;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N, K;
    cin >> N >> K;
    int ans = 0;
    while (N) {
        N /= K;
        ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

ll n,k;
ll dp[101][50001][2];

int main(void){
	scanf("%lld%lld",&n,&k);
	int sq=0;
	while(sq*sq<=n)sq++;
	sq--;
	for(int i=1;i<=sq;i++){
		dp[1][i][0]=1;
		dp[1][i][1]=n/i-max((n)/(i+1),(ll)sq);
		if(dp[1][i][1]<0)dp[1][i][1]=0;
		//printf("%lld %lld\n",1LL,dp[1][i][1]);
	}
	for(int i=1;i<k;i++){
		// 0 -> 0
		ll su=0;
		for(int j=1;j<=sq;j++){
			su=(su+dp[i][j][0])%MOD;
		}
		for(int j=1;j<=sq;j++){
			dp[i+1][j][0]=su;
		}
		// 0 -> 1
		su=0;
		for(int j=1;j<=sq;j++){
			su=(su+dp[i][j][0])%MOD;
			ll v1=(ll)su*dp[1][j][1]%MOD;
			dp[i+1][j][1]=(dp[i+1][j][1]+v1)%MOD;
		}
		// 1 -> 0
		su=0;
		for(int j=sq;j>=1;j--){
			su=(su+dp[i][j][1])%MOD;
			dp[i+1][j][0]=(dp[i+1][j][0]+su)%MOD;
		}
	}
	ll ans=0;
	for(int i=1;i<=sq;i++){
		ans=(ans+dp[k][i][0])%MOD;
		ans=(ans+dp[k][i][1])%MOD;
	}
	printf("%lld\n",ans);
	return 0;
}


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

#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define endl '\n'

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, int> pdi;

const ll INF = 2e18;
const int MOD = 1e9 + 7;
const int MAXN = 2e5 + 5;

int N, M, A[MAXN], ans[MAXN];
int comp[MAXN];
vector<int> G[MAXN];

struct SEG {
	int T[MAXN * 4];
	int update(int x, int v, int l, int r, int n) {
		if(r < x || x < l) return T[n];
		if(l == r) return T[n] = v;
		int mid = l + r >> 1;
		return T[n] = max(update(x, v, l, mid, n*2), update(x, v, mid+1, r, n*2+1));
	}
	int query(int x, int y, int l, int r, int n) {
		if(x > y || r < x || y < l) return 0;
		if(x <= l && r <= y) return T[n];
		int mid = l + r >> 1;
		return max(query(x, y, l, mid, n*2), query(x, y, mid+1, r, n*2+1));
	}
} seg;

int geti(int val) { return lower_bound(comp+1, comp+1+N, val) - comp; }

void dfs(int x, int p) {
	int cur = seg.query(1, geti(A[x])-1, 1, N, 1) + 1;
	ans[x] = max(ans[p], cur);
	int tmp = seg.query(geti(A[x]), geti(A[x]), 1, N, 1);
	seg.update(geti(A[x]), cur, 1, N, 1);

	for(int i : G[x]) if(i != p) dfs(i, x);

	seg.update(geti(A[x]), tmp, 1, N, 1);
}

int main() {
	ios::sync_with_stdio(0); cin.tie(0);
	cin >> N;
	for(int i=1; i<=N; i++) cin >> A[i], comp[i] = A[i];
	sort(comp+1, comp+1+N);

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

	dfs(1, 0);
	for(int i=1; i<=N; i++) cout << ans[i] << endl;
}


Measured memory_bytes: 39032
#include <stdio.h>

int main(void)
{
  int k;
  int a,b;
  scanf("%d", &k);
  scanf("%d %d", &a, &b);
  for(int i=a;i<=b;i++){
    if(i%k==0){
      printf("OK\n");
      break;
    }
    if(i==b){
      printf("NG\n");
    }
  }
  return 0;
}


Measured memory_bytes: 1648
#include<iostream>
#include<algorithm>
#include<vector>

using namespace std;

int main(void)
{
	int n;
	cin >> n;
	
	vector<long long> a;

	for(int i=1;i<=n;i++)
	{
		int tmp;
		cin >> tmp;
		a.push_back(tmp);
	}

	sort(a.begin(),a.end());
	reverse(a.begin(),a.end());

	long long h=0,w=0;
	bool flag=false;
	bool flag2=false;

	for(int i=1;i<=n;i++)
	{
		if(flag==false)
		{
			if(h==a[i-1])
			{
				flag=true;
			}
			h=a[i-1];
		}
		else
		{
			if(w==a[i-1])
			{
				w=a[i-1];
				flag2=true;
				break;
			}
			w=a[i-1];
		}
	}

	cout << (flag2 ? h*w:0) << endl;
}


Measured memory_bytes: 1400
#include<stdio.h>
#include<math.h>

int main()
{

    double x1,x2,y1,y2,distance;
    scanf("%lf %lf %lf %lf",&x1,&y1,&x2,&y2);
    distance=((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1));
    printf("%lf\n",sqrt(distance));
    return 0;
}



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

int main() {
    int n, x;
    cin >> n >> x;
    vector<int> l(n);
    for (auto& e : l) cin >> e;

    int d = 0;
    int ans = 1;
    for (auto e : l) {
        if (d + e > x) break;

        d += e;
        ans++;
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        String[] tenki = { "Sunny", "Cloudy", "Rainy" };
        String s = sc.next();
        if (s.equals(tenki[0])) {
            System.out.println(tenki[1]);
        }
        if (s.equals(tenki[1])) {
            System.out.println(tenki[2]);
        }
        if (s.equals(tenki[2])) {
            System.out.println(tenki[0]);
        }
    }
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    private int readByte() {
        if (hasNextByte())
            return buffer[ptr++];
        else
            return -1;
    }

    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr]))
            ptr++;
        return hasNextByte();
    }

    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public long nextLong() {
        if (!hasNext())
            throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }

    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
            throw new NumberFormatException();
        return (int) nl;
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}


Measured memory_bytes: 21204
#include<bits/stdc++.h>
using namespace std;
int isprime(int a)
{
    for(int i=2;i*i<=a;i++)
        if(a%i==0)
            return 0;
        return 1;
    }
    int main()
    {
        int n;
        cin>>n;
        int ans=0;
        while(n--)
        {
            int num;
            cin>>num;
            ans+=isprime(num);
        }
        cout<<ans<<"\n";
    return 0;
}



Measured memory_bytes: 3080
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
import random

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)


def main():
    m,k = LI()
    if m == 1:
        if k == 0:
            return '1 1 0 0'
        return -1

    t = pow(2,m)
    if k >= t:
        return -1
    a = list(range(t))
    r = a[:k] + a[k+1:] +[k] + a[k+1:][::-1] + a[:k][::-1] + [k]

    return ' '.join(map(str, r))


print(main())




Measured memory_bytes: 31052
#include <iostream>
#include <vector>
#include <deque>
#include <algorithm>
#include <numeric>
#include <string>
#include <cstring>
#include <list>
#include <unordered_set>
#include <tuple>
#include <cmath>
#include <limits>
#include <type_traits>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <set>
#include <bitset>
#include <regex>
#include <random>
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
#define rep(i,n)for(ll i=0;i<n;++i)
#define exout(x) printf("%.12f\n", x)
const double pi = acos(-1.0);
const ll MOD = 1000000007;
const ll INF = 1e18;
const ll MAX_N = 1010101;

//組み合わせの余りを求める
ll fac[MAX_N], finv[MAX_N], inv[MAX_N];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX_N; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(ll n, ll k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

//最大公約数
ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}

ll lcm(ll x, ll y) {
	if (x == 0 || y == 0)return 0;
	return (x / gcd(x, y) * y);
}

ll dx[8] = { 1,-1,0,0,1,1,-1,-1 };
ll dy[8] = { 0,0,1,-1,1,-1,1,-1 };
ll d[110][2];

//long longしか使わない
//素数は1より大きい
//lower_boundは指定したkey以上の要素の一番左のイテレータをかえす
//upper_boundは指定したkeyより大きい要素の一番左のイテレータをかえす
int main() {
	ll n, k;
	cin >> n >> k;
	double ans = 0;
	for (ll i = 1;i <= n;++i) {
		ll res = i;
		double target = 1 / (double)n;
		while (res < k) {
			res *= 2;
			target /= (double)2;
		}
		ans += target;
	}
	exout(ans);
	return 0;
}


Measured memory_bytes: 3724
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <cmath>
#include <string>
#include <bitset>
#include <functional>
#include <set>
#include <map>
#include <array>

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define fst first
#define snd second
#define pb push_back
#define ALL(obj) (obj).begin(), (obj).end()
#define debug(x) cout << #x << ": " << x << endl
//#define int long long int
const int MOD = 1000000007;
const int INF = 1001001000;
const double EPS = 0.000000001;

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

bool pairCompare(const P& pair1, const P& pair2) {
    return pair1.second > pair2.second;
}

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, m;
  vector<int> l;
  vector<int> r;
  cin >> n >> m;
  REP(i, m){
    int a, b;
    cin >> a >> b;
    l.push_back(a);
    r.push_back(b);
  }
  sort(ALL(l), greater<int>());
  sort(ALL(r));
  int ans = r[0] - l[0] + 1;
  if (ans < 0) ans = 0;
  cout << ans << endl;
  return 0;
}


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

int main() {
  string n;
  cin >> n;
  
  
  if(n[1]==n[2] && (n[1]==n[0] || n[1]==n[3]))
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
char mape[111][111];
int m,n;
int co;
int da[]={0,0,1,-1};
int db[]={1,-1,0,0};
void dfs(int x,int y,char c){
  mape[x][y]=0;
  for(int i=0;i<4;i++)
    if(x+da[i]>=0&&x+da[i]<m&&y+db[i]>=0&&y+db[i]<n&&mape[x+da[i]][y+db[i]]==c)
      dfs(x+da[i],y+db[i],c);
}
int main(){
  while(cin>>m>>n&&m+n>0){
    for(int i=0;i<m;i++)
      for(int j=0;j<n;j++)
	cin>>mape[i][j];
    co=0;
    for(int i=0;i<m;i++)
      for(int j=0;j<n;j++)
	if(mape[i][j]>0){
	  co++;
	  dfs(i,j,mape[i][j]);
	}
    cout<<co<<"\n";
  }
}

Measured memory_bytes: 1640
# https://atcoder.jp/contests/abc064/tasks/abc064_c
# C - Colorful Leaderboard

n = int(input().split()[0])
a_list = list(map(int, input().split()))

start, end = 0, 399
rate_dict = {}
rate_id = 0

while end < 3200:
    # 灰色が1-399ではなく0-399になるが
    # 影響はないので0-で実装
    data = dict(start=start, end=end)
    rate_dict[rate_id] = data
    rate_id += 1
    start += 400
    end += 400

count_dict = {rate_id: 0 for rate_id in rate_dict.keys()}

for a in a_list:
    for rate_id, v in rate_dict.items():
        if v['start'] <= a <= v['end']:
            count_dict[rate_id] += 1

count_over = n - sum(count_dict.values())
ALL_COLOR_N = len(count_dict.keys())  # 8色

# 0人の色数
zero_color_n = len([v for v in count_dict.values() if v == 0])

# 最小値
if count_over == n:
    # 全員オーバー
    min_n = 1
else:
    # すでに人がいる色に割り振れば良いので、色数は増えない
    min_n = ALL_COLOR_N - zero_color_n

# 最大値
# オーバーの人は、既存の8色以外も選べる
max_n = (ALL_COLOR_N - zero_color_n) + count_over

ans = ' '.join([str(min_n), str(max_n)])
print(ans)


Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <iterator>

using namespace std;

int main()
{
    int N; cin >> N;
    vector<int> V(N, 0), C(N, 0);
    int ans = 0;

    for (int i = 0; i < N; i++)
        cin >> V[i];
    for (int i = 0; i < N; i++)
        cin >> C[i];
    
    for (int i = 0; i < N; i++)
    {
        V[i] -= C[i];
        if (V[i] > 0)
            ans += V[i];
    }

    cout << ans << endl;
}

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

int main() {
  ll n, k;
  cin >> n >> k;
  ll cnt = 0;
  for(ll i=k+1; i<=n; i++){
    if(n%i == 0) cnt += (i-k)*(n/i);
    else{
      cnt += (i-k)*(n/i);
      if(n%i>=k) cnt += n%i-k+1;
      if(k == 0) cnt--;
    }
  }
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 3644
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int r = sc.nextInt();
		// スペース区切りの整数の入力
		int d = sc.nextInt();
		int x = sc.nextInt();
		// 出力
		
		int o = x;
		
		
		for(int i=1;i<=10;i++){		
			o = r * o - d;
				System.out.println(o);
				
		}
	}
}

Measured memory_bytes: 21972
#include<stdio.h>
int main(void)
{
	int n,i,x;
	char s[100001];
	scanf("%d",&n);
	scanf("%s",s);
	i=0;
	x=0;
	while(1){
		if(s[i]!=s[i+1]){
			if(i+1<n){
				x++;
				i++;
			}	
		}
		i++;
		if(i>=n){
			break;
		}
	}
	printf("%d\n",x);
	return 0;
}


Measured memory_bytes: 2148
#include<iostream>
#include<vector>
#include<string>
#include<map>
#include<math.h>
#include<algorithm>
#include<iomanip>
#include<deque>

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
const ll LINF = 1e18;
const int INF = 1e8;

using namespace std;

#define vvint(vec,n,m,l) vector<vector<int>> vec(n,vector<int>(m,l));
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>;
#define pint pair<int,int>;
#define rep(i,a) for(int i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()
#define debug system("pause")

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

	int a, b;
	cin >> a >> b;
	if ((a + 12) % 14 < (b + 12) % 14)
	{
		cout << "Bob";
	}
	else if (a == b)
	{
		cout << "Draw";
	}
	else
	{
		cout << "Alice";
	}
	cout << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end))) // rep(i, 1, 5) --> {1,2,3,4} // rep(i, 5, 1) --> {4,3,2,1} // rep(it, end(v), begin(v)) --> *it

using namespace std;

bool verify(string s)
{
    string s1 = s.substr(0, s.size()/2);
    string s2 = s.substr(s.size()/2, s.size());
    return s1 == s2;
}

int main()
{
    string s;
    cin >> s;
    ll n = s.size();
    rep(i, 0, n)
    {
        s = s.substr(0, s.size()-1);
        // cout << s.size() << endl;
        if (verify(s))
            return cout << s.size(), 0;
    }
    cout << 1;
    return 0;
}

Measured memory_bytes: 256
#include<set> 
#include<map> 
#include<stack> 
#include<cmath> 
#include<cstdio> 
#include<queue> 
#include<vector> 
#include<climits> 
#include<cstring> 
#include<iostream> 
#include<algorithm> 
using namespace std; 
#define LL long long 
#define MAXN 10000
#define INF INT_MAX 
int read(){ 
    int f=1,x=0; 
    char c=getchar(); 
    while(c<'0'||'9'<c){if(c=='-')f=-1;c=getchar();} 
    while('0'<=c&&c<='9'){x=x*10+c-'0';c=getchar();} 
    return f*x; 
}
int main(){
	int a=read(),b=read();
	printf("%d\n",(b-a)*(b-a+1)/2-b);
    return 0; 
} 


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long N;
  long long K;
  cin>>N>>K;
  vector<long long> vec(N);
  for(long long i=0;i<N;i++){
    cin>>vec.at(i);
  }
  for(long long i=0;i<N-K;i++){
    if(vec.at(i)<vec.at(K+i)){
      cout<<"Yes"<<endl;
    }
    else{
      cout<<"No"<<endl;
  }
  }
}

Measured memory_bytes: 4840
from collections import defaultdict
n = int(input())
ss = list(input() for _ in range(n))
m = int(input())
tt = list(input() for _ in range(m))
dic = defaultdict(int)

for s in ss:
    dic[s] += 1
for t in tt:
    dic[t] -= 1

ans = 0
for k in dic.values():
    ans = max(ans, k)
print(ans)

Measured memory_bytes: 3316
#include <iostream>
#include <string>
#include <cstdint>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <bitset>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <climits>
#include <numeric>
#include <algorithm>
#include <cassert>

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

using namespace std;

double f(double a, double b, double x)
{
    return floor(a*x/b) - a*floor(x/b);
}

void solution()
{
    int64_t a,b,n;
    cin >> a >> b >> n;
    cout << f(a,b,min(b-1,n)) << '\n';
}

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


Measured memory_bytes: 3800
#include<stdio.h>

int main() {
	int a, N, ans;
	scanf("%d", &N);
	a = N / 100;
	ans = a * 100 + a * 10 + a;
	if(ans < N) {
		a++;
		ans = a * 100 + a * 10 + a;
	}
	printf("%d\n", ans);
	
	return 0;
}

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

int main()
{
    long long a, b;
    long long x;

    cin >> a >> b >> x;

    cout << (b / x + 1) - (a - 1 < 0 ? 0 : (a - 1) / x + 1) << endl;
    
    return 0;
}


Measured memory_bytes: 256
int main()
{
    int W, H;
    int x, y, r;
 
    scanf("%d%d%d%d%d", &W, &H, &x, &y, &r);
    W -= r, H -= r;
    if (r <= x && x <= W && r <= y && y <= H) printf("Yes\n");
    else printf("No\n");
    return 0;
}


Measured memory_bytes: 2112