akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i < (n);i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define SCANF(i) int i;scanf("%d",&i)
using namespace std;
using P = pair<int,int>;
const long long INF = 1LL << 60;
const int IINF=100000000;
const int MOD = (int)1e9 + 7;
typedef long long ll;
//約数列挙
vector<long long> divisor(long long n) {
    vector<long long> ret;
    for (long long i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) ret.push_back(n / i);
        }
    }
    //sort(ret.begin(), ret.end()); // 昇順に並べる
    return ret;
}
vector<int> dx={1,0,-1,0};vector<int> dy={0,-1,0,1};

signed main(){
    int h;
    while(cin>>h){
        if(h==0)break;
        vector<vector<int>> list(h,vector<int>(5));
        ll ans=0;bool roopflag=true;
        REP(i,h)REP(j,5)cin >> list[i][j];

        while(true){
            roopflag=false;
            REP(i,h){
                REP(j,3){
                    if(list[i][j] != 0 && list[i][j] == list[i][j+1] && list[i][j+1]==list[i][j+2]){
                        roopflag=true;
                        int cnt =3;int num = list[i][j];
                        FOR(k,j+3,5){
                            if(list[i][j]==list[i][k])cnt++;
                            else break;
                        }
                        //cout << cnt << endl;
                        FOR(d,j,j+cnt)list[i][d]=0;
                        ans+=cnt*num;
                    }
                }
            }
            if(!roopflag)break;
            for(int i=h-1;i>0;i--){
                for(int j=0;j<5;j++){
                    if(list[i][j]==0){
                        for(int q=i-1;q>=0;q--){
                            if(list[q][j]!=0){
                                swap(list[i][j],list[q][j]);
                                break;
                            }
                        }
                    }
                }
            }
        }
        printf("%lld\n",ans);
    }
}


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

int main(){
    int n;
    cin>>n;
    vector<pair<int,int>> r(n),b(n);
    vector<bool> rok(n,false),bok(n,false);
    for(int i=0;i<n;i++){
        int x,y;
        cin>>x>>y;
        r[i]=make_pair(y,x);
    }
    for(int i=0;i<n;i++){
        int x,y;
        cin>>x>>y;
        b[i]=make_pair(x,y);
    }
    sort(r.rbegin(),r.rend());
    sort(b.begin(),b.end());
    int ans=0;
    for(int i=0;i<n;i++){
        int bx=b[i].first;
        int by=b[i].second;
        for(int j=0;j<n;j++){
            int rx=r[j].second;
            int ry=r[j].first;
            if(rx<bx&&ry<by&&!rok[j]&&!bok[i]){
                ans++;
                rok[j]=true;
                bok[i]=true;
                break;
            }
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<cmath>
#define pb push_back
#define ld long double
#define mp make_pair
#define vl vector<ll> 
#define vd vector<double>
#define vld vector<long double>
#define ll long long int
#define pl pair<ll, ll>
#define all(a) a.begin(), a.end()
#define forr(i, n) for(ll i=0; i<n; i++) 
#define forr1(i, n) for(ll i=1; i<=n; i++)
using namespace std;
const ld PI =3.1415926535897923846;
const ll MOD = 1000000007;
const ll N=998244353;
ll power(ll x,ll n){ll res=1;while(n>0){if(n&1) res=res*x%MOD;x=x*x%MOD;n>>=1;}return res;}
ll modinverse(ll a){return power(a, MOD-2);}
void solve()
{
	ll n;
	cin>>n;
	string str;
	cin>>str;
	ll ans=0;
	ll red=0, white=0;
	forr(i, n)
	{
	    if(str[i]=='R')
	        red++;
	    else
	        white++;
	}
	if(red==0||white==0)
	{
	    cout<<0<<endl;
	    return;
	}
	ll change=0;
	forr(i, red)
	{
	    if(str[i]!='R')
	    change++;
	}
	cout<<min(change, min(red, white))<<endl;
}
int main()
{
    ll test=1;
    while(test--)
    {
        solve();
    }
}

Measured memory_bytes: 3756
//https://codeforces.com/contest/1323/problem/A
//BROWNIE TK

#include <bits/stdc++.h>
typedef long long int lli;
typedef unsigned long long int ulli;
typedef long double ldb;

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define pb push_back
#define popb pop_back()
#define pf push_front
#define popf pop_front()

#define si size()
#define be begin()
#define en end()
#define all(v) v.be, v.en

#define le length()
#define mp make_pair
#define mt make_tuple
#define acc(v) accumulate(all(v), 0)
#define F first
#define S second

#define pll pair<lli, lli>
#define pii pair<int, int>
#define pil pair<int, lli>

#define forz(i, n) for (int i = 0; i < n; i++)
#define fore(i, m, n) for (int i = m; i <= n; i++)
#define rforz(i, n) for (int i = n - 1; i >= 0; i--)
#define rfore(i, m, n) for (int i = n; i >= m; i--)

#define deci(n) fixed << setprecision(n)
#define high(n) __builtin_popcount(n)
#define highll(n) __builtin_popcountll(n)
#define parity(n) __builtin_parity(n)
#define ctz(n) __builtin_ctz(n)

#define bset(a, p) ((a) | (1ll << (p)))
#define bchk(a, p) ((a) & (1ll << (p)))
#define bxor(a, p) ((a) ^ (1ll << (p)));
#define brem(a, p) (bchk(a, p) ? (bxor(a, p)) : (a))
/*SOME BITMASK KNOWLEDGE
1)x & (x - 1):sets the last one bit of x to zero
power of two exactly when x & (x − 1) = 0.
2)x & -x:sets all the one bits to zero, except last one bit
3)x | (x - 1):inverts all the bits after the last one bit*/

#define lb lower_bound
#define ub upper_bound
#define er equal_range

#define findnot find_first_not_of

#define maxe *max_element
#define mine *min_element

#define mod 1000000007
#define mod2 998244353
#define gcd __gcd
#define kira ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)

#define endl "\n"
#define p0(a) cout << a << " "
#define p1(a) cout << a << endl
#define p2(a, b) cout << a << " " << b << endl
#define p3(a, b, c) cout << a << " " << b << " " << c << endl
#define p4(a, b, c, d) cout << a << " " << b << " " << c << " " << d << endl

#define oset tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define osetlli tree<lli, null_type, less<lli>, rb_tree_tag, tree_order_statistics_node_update>
//member functions :
//1. order_of_key(k) : number of elements sbtriectly lesser than k
//2. find_by_order(k) : k-th element in the set
#define ofk order_of_key
#define fbo find_by_order
using namespace std;

/*STD funcions*/
lli power(lli x, lli y, lli p)
{
    lli res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res;
}
lli modi(lli a, lli m) { return power(a, m - 2, m); }
/*CODE BEGINS*/

int main()
{
    kira;
    lli a,b,n;
    cin>>n>>a>>b;
    cout<<(n/(a+b))*a+min(a,n%(a+b));
    return 0;
}

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


int main()
{
long long n,q,h,s,d;
    cin>>q>>h>>s>>d;
    cin>>n;
if(2*q<h)
    h=2*q;
if(2*h<s)
    s=2*h;
    if(s*2<d)
    d=2*s;
    cout<<n/2*d+n%2*s;
    return 0;
}

Measured memory_bytes: 256
#include <stack>
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cmath>
#include <array>
#include <iomanip>
using namespace std;
int gcd(int a, int b)
{
   if (a%b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a%b));
   }
}
int main(){
    //std::stack<int> stack;
    int n;
    cin >> n;
    vector<int> a(n);
    long ans = 0;
    for(int i = 0; i < n; i++){
        cin >> a[i];
        ans += a[i] - 1;
    }
    cout << ans << endl;
    return 0;
}





Measured memory_bytes: 256
n,m = map(int,input().split())
par = [i for i in range(n+1)]

def find(x):
    if par[x] == x:
        return x
    else:
        par[x] = find(par[x]) #経路圧縮？
        return par[x]

def same(x,y):
    return find(x) == find(y) # Boolでreturn

def unite(x,y):
    x = find(x)
    y = find(y)
    if x == y:
        return 0
    par[x] = y

ans = 0
for i in range(m):
    a,b = map(int,input().split())
    unite(a,b)

for i in range(n):
    find(i+1)
par = par[1:]
ans = 0
from collections import Counter
t = Counter(par)
print(len(t)-1)

Measured memory_bytes: 81752
#include <iostream>
#include <cstdio>
#include <vector>
#include <cstring>
#include <bitset>
#include <cmath>
#include <iomanip>
#include <stack>
#include <set>
#include <queue>
#include <algorithm>
#include <deque>
#include <map>
#include <cmath>
using namespace std;

#define INF 1e18
#define int long long

signed main() {
    string s; cin >> s;
    vector<int> cnt(4, 0);
    for(int i = 0; i < s.size(); i++) {
        if(s[i] == 'N') cnt[0]++;
        if(s[i] == 'S') cnt[1]++;
        if(s[i] == 'W') cnt[2]++;
        if(s[i] == 'E') cnt[3]++;
    }

    if(cnt[0] > 0 && cnt[1] > 0 && cnt[2] > 0 && cnt[3] > 0) {
        cout << "Yes" << endl;
        return 0;
    }

    if(cnt[0] > 0 && cnt[1] > 0 && cnt[2] == 0 && cnt[3] == 0) {
        cout << "Yes" << endl;
        return 0;
    }
    if(cnt[0] == 0 && cnt[1] == 0 && cnt[2] > 0 && cnt[3] > 0) {
        cout << "Yes" << endl;
        return 0;
    }

    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
fn main() {
    proconio::input! {
        n: usize,
        s: [proconio::marker::Bytes;n],
    }
    let mut d: Vec<(i32,i32)>=Vec::with_capacity(n);
    let mut e: Vec<(i32,i32)>=Vec::with_capacity(n);
    for s in s {
        let mut m=0;
        let mut k=0;
        for c in s {
            k += if c==b'(' {1} else {-1};
            m = std::cmp::min(m,k);
        }
        if k>0 {
            d.push((m,k));
        }
        else {
            e.push((m,k));
        }
    }
    d.sort_by_key(|&(m,k)|(-m,-k));
    e.sort_by_key(|&(m,k)|m-k);
    d.extend(e);
    let mut i=0;
    let mut f=true;
    for (m,k) in d {
        if i+m>=0 && i+k>=0 {
            i+=k;
        }
        else {
            f=false;
            break;
        }
    }
    println!("{}", if f && i==0 {"Yes"} else {"No"});
}

Measured memory_bytes: 66444
n=int(input())

bp = [0] * (n+10)
for i in range(2, n+10):
    if bp[i] == 0:
        bp[i] = i
        for j in range(i*i, n+1, i):
            if bp[j]==0:
                bp[j] = i


def f(k):
    if k==1:
        return 1
    z=[]
    p=bp[k]
    cnt=1
    ans=1

    while k>=2:
        k//=p
        if p==bp[k]:
            cnt+=1
        else:
#            print(" ",k,p)
            ans*=cnt+1
            cnt=1
            p=bp[k]

    return ans

ans=0
for i in range(1,n+1):
    #print(i,f(i))
    ans += i*f(i)

print(ans)

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

using namespace std;

int main() {
    ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int t;
	char c1,c2;
	t = 1;
	while(t--) {
	 cin >> c1 >> c2;
	 if(c1 < c2)
	  cout << "<" << endl;
	 else if(c1 == c2)
	  cout << "=" << endl;
	 else
	  cout << ">" << endl;
	}
	return 0;
}



Measured memory_bytes: 256
<?php
list($a, $b) = explode(" ", trim(fgets(STDIN)));
if ($a === 'H' && $b === 'H') {
    echo 'H';
}
if ($a === 'D' && $b === 'H') {
    echo 'D';
}
if ($a === 'D' && $b === 'D') {
    echo 'H';
}
if ($a === 'H' && $b === 'D') {
    echo 'D';
}


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

using namespace std;


#define PI 3.14159265
#define int long long


int sqr(int x){
	return x * x;
}


main(){

	int n, m; cin >> n >> m;


	vector <int> s(m), c(m);

	for(int i = 0; i < m; i++){
		cin >> s[i] >> c[i];
		if(s[i] > n){
			cout << -1 << endl; return 0;
		}
	}

	// string ans;

	
		for(int i = 0; i < m; i++){
			for(int j = 0; j < m; j++){
				if(s[i] == s[j] and c[i] != c[j]){
					cout << -1 << endl; return 0;
				}
			}
		}
	if(n == 1){
		if(m)
			cout << c[0] << endl;
		else
			cout << 0 << endl;
		return 0;
	}

	string ans = "1";
	for(int i = 0; i < n - 1; i++) ans.push_back('0');

	for(int i = 0; i < m; i++){
		ans[s[i] - 1] = c[i] + '0';
	}

	if(ans[0] == '0'){
		cout << -1 << endl; return 0;
	}else{
		cout << ans << endl;
	}
	
	
	
	return 0;
}

Measured memory_bytes: 256
import sys

def solve():
    input = sys.stdin.readline
    L = [int(i) for i in input().split()]
    count = 0
    L.sort()
    addMin = (L[2] - L[0]) // 2  
    addMid = (L[2] - L[1]) // 2
    count = addMin + addMid
    L[0] += addMin * 2
    L[1] += addMid * 2
    if L[0] < L[2] and L[1] < L[2]: print(count + 1)
    elif L[0] == L[1] == L[2]: print(count)
    else: print(count + 2)
    #print(L)

    return 0

if __name__ == "__main__":
    solve()


Measured memory_bytes: 3064
s=input()
s=list(s)
for i in range(2**3):
  temp=[0]*3
  for j in range(3):
    if ((i >> j) & 1):
      temp[j]="+"
    else:
      temp[j]="-"
  a=[s[0],temp[0],s[1],temp[1],s[2],temp[2],s[3]]
  if eval("".join(a))==7:
    print("".join(a)+"=7")
    break

Measured memory_bytes: 3064
use std::io;

fn main() {
    let mut input = String::new();
    match io::stdin().read_line(&mut input) {
        Ok(_) => {
            execute(input.as_str());
        },
        Err(error) => {
            println!("{}", error);
        }
    }
}

fn execute(s: &str) {
    let values: Vec<i32> = s.trim().split(' ').map(|s| s.parse::<i32>().unwrap()).collect();
    let result = match values[0] * values[1] % 2 {
        0 => "Even",
        1 => "Odd",
        _ => panic!(),
    };

    println!("{}", result);
}

Measured memory_bytes: 4352
<?php
$s = str_split(trim(fgets(STDIN)));
$ans = "Yes";

for ($i = 0; $i < count($s); $i++) {
  if(count(array_keys($s, $s[$i])) != 2) {
    $ans = "No";
    break;
  }
}
echo $ans,PHP_EOL;

Measured memory_bytes: 4728
#include <iostream>


int main() {
    int A, B;
    std::cin >> A >> B;
    if (A >= 13) {
        std::cout << B << std::endl;
    } else if (A >= 6) {
        std::cout << B / 2 << std::endl;
    } else {
        std::cout << 0 << std::endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define endl "\n"
#define speed() ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define sz(x) (int)(x).size()
#define _USE_MATH_DEFINES
using namespace std;
typedef long long int lli;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

int main() {
    speed();
    string s; cin >> s;
    cout << s.rfind('Z') - s.find('A') + 1 << endl;
    return 0;
}

Measured memory_bytes: 720
#include<stdio.h>
#define INF 1000000
int graph[101][101],n,c,d;
void warshall_floyd(void);
int min(int,int);

int main(){
  int k,i,j,x,e,a,b;

  while(scanf("%d %d",&n,&k),n,k){
    for(i=1;i<=n;i++)
      for(j=1;j<=n;j++)
	graph[i][j]=i==j?0:INF;
    
    for(i=0;i<k;i++){
      if(scanf("%d",&x),x){
	scanf("%d %d %d",&c,&d,&e);

	if(graph[c][d]>e){
	graph[c][d]=graph[d][c]=e;
	warshall_floyd();
	}
      }else{
	scanf("%d %d",&a,&b);
	printf(graph[a][b]>=INF?"-1\n":"%d\n",graph[a][b]);
      }
    }
  }
  return 0;
}

void warshall_floyd(){
  int i,j;
  for(i=1;i<=n;i++)
    for(j=1;j<=n;j++)
      graph[i][j]=graph[j][i]=min(graph[i][j],graph[i][c]+graph[c][d]+graph[d][j]);
}

int min(int x,int y){
return x<y?x:y;
}

Measured memory_bytes: 456
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

struct task{
	int a;
	int b;

	bool operator<(const task &in) const{
		return b<in.b;
	};
};

int main(){

	int n, tim=0;
	vector<task> v;

	cin>> n;
	v.resize(n);
	
	for(int i=0;i<n;i++) cin>> v[i].a >> v[i].b;

	sort(v.begin(), v.end());
	
	for(int i=0;i<n;i++){
		tim+=v[i].a;
		if(v[i].b<tim){
			cout<< "No" << endl;
			return 0;
		}
	}

	cout<< "Yes" << endl;


}

Measured memory_bytes: 1792
#include<iostream>
#include <list>
#include<stack>
#include<queue>
#include <vector>
#include <set>
#include<algorithm>
#include<math.h>
#include<stdlib.h>
#include<string>
#include <functional>

#define FOR(k,m,n) for(int (k)=(m);(k)<(n);(k)++)
#define REP(i,n) FOR((i),0,(n))
#define LL long long
#define CLR(a) memset((a),0,sizeof(a))
#define SZ(x) (int((x).size()))
#define WAITING(str) int str;std::cin>>str;
#define DEBUGING(str) cout<<str<<endl
using namespace std;

const LL MOD = 1000000007;// 10^9+7
const int INF = (1 << 30);


//変数
LL N, K;






//サブ関数
//入力
void input()
{
	cin >> N >> K;
}

//nの約数を列挙
vector<int> enum_div(int n)
{
	vector<int>res;
	for (int i = 1; i*i <= n; i++) {
		if (n%i == 0) {
			res.push_back(i);
			if (i*i != n) {
				res.push_back(n / i);
			}
		}
	}
	return res;
}

//計算
void calc()
{
	LL ans;
	if (K == 0) {
		ans = N * N;
	}
	else {
		ans = 0;
		FOR(b, K + 1, N + 1)
		{
			LL set = b - K;
			LL c = N / b;

			ans += set * c;
			if (c*b + K <= N) {
				ans += N - c * b - K + 1;
			}
		}
	}
	
	cout << ans << endl;
}


//出力
void output()
{

}


//デバッグ
void debug()
{
	int N;
	cin>>N;
}


//メイン関数
int main()
{
	input();
	calc();
	output();
	debug();
	
	return 0;
}


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

void main_()
{
    ll N;
    cin >> N;
    vector<ll> Ls;
    Ls.reserve(N);
    copy_n(istream_iterator<ll>(cin), N, back_inserter(Ls));

    sort(begin(Ls), end(Ls));
    ll ans = 0;
    for (ll i = 0; i < N - 2; ++i) {
        for (ll j = i + 1; j < N - 1; ++j) {
            auto ab = Ls[i] + Ls[j];
            for (ll k = j + 1; k < N && Ls[k] < ab; ++k) {
                if (Ls[i] < Ls[k] + Ls[j] && Ls[j] < Ls[k] + Ls[i]) {
                    ans++;
                }
            }
        }
    }
    cout << ans << endl;
}
int main()
{
    cin.tie(nullptr);
    cout.tie(nullptr);
    ios_base::sync_with_stdio(false);
    main_();
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <numeric>
#include <tuple>
#include <stack>

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define print(s) cout << s << endl
typedef long long ll;
using namespace std;

int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

int main() {
	string s, t; cin >> s >> t;
	vector<int> sv, tv;
	rep(i,s.size()) sv.push_back(s[i] - 'a');
	rep(i, t.size()) tv.push_back(t[i] - 'a');
	sort(all(sv));
	sort(rall(tv));
	rep(i,101){
		if (sv[i] < tv[i]){
			print("Yes");
			return 0;
		}else if (sv[i] > tv[i]){
			print("No");
			return 0;;

		}
	}
	cout << (s.size() < t.size()? "Yes": "No") << endl;
}

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

int main()
{
  int d;
  cin >> d;
  if(d == 25) cout << "Christmas";
  if(d == 24) cout << "Christmas Eve";
  if(d == 23) cout << "Christmas Eve Eve";
  if(d == 22) cout << "Christmas Eve Eve Eve";
  
  return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
List = []
N, M = (int(x) for x in input().split())
for i in range(N):
    a, b = (int(x) for x in input().split())
    List.append([a, b])

num_of_drink, total_fee = 0, 0
List = sorted(List, key=lambda x:x[0])

temp_M = M
list_of_num = []
for i in range(N):
    if temp_M <= List[i][1]:
        list_of_num.append(temp_M)
        break
    else:
        list_of_num.append(List[i][1])
        temp_M += -List[i][1]
index = 0
for x in list_of_num:
    total_fee += List[index][0] * x
    index += 1
print(total_fee)

Measured memory_bytes: 22004
#include <stdio.h>
 
int main()
{
 
    int x1, x2, x3, x4, x5;
 
    scanf("%d %d %d %d %d", &x1, &x2, &x3, &x4, &x5);
 
    if (x1 == 0)
        printf("1");
    else if (x2 == 0)
        printf("2");
    else if (x3 == 0)
        printf("3");
    else if (x4 == 0)
        printf("4");
    else if (x5 == 0)
        printf("5");
 
    return 0;
}

Measured memory_bytes: 1624
#include <bits/stdc++.h>
#include <string.h>
#define endl '\n'
#include <vector>
#include <algorithm>

using namespace std;

int main() {
	double l;
	cin>>l;
	l /= 3;
	cout<<setprecision(12)<<fixed<<l*l*l<<endl;
} 

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <bitset>
#include <complex>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef long long int llint;
typedef pair<ll, ll> pa;
#define MM 1000000000
#define MOD MM+7
#define MAX 101000
#define MAP 110
#define initial_value -1
#define MAX_T 1001
#define pi pair<int,int>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
#define INF (1 << 29) //536870912

const long double PI = acos(-1);
const ll DEP = 1e18;
int dx[4] = {-1,0,1,0};
int dy[4] = {0,-1,0,1};
int GCD(int x,int y){
    return y ? GCD(y,x%y) : x;
}
ll N,M; 
ll L,R;
ll a[100010],imos[100010];
int main(){
    cin >> N >> M;
    for(int i = 0; i < M; i++){
        cin >> L >> R;
        a[L]++; a[R+1]--;
    }
    imos[0] = a[0];
    for(int i = 1; i < N+2; i++){
        imos[i] = imos[i-1]+a[i];
    }
    ll ans = 0;
    for(int i = 0; i < N+2; i++){
        if(imos[i] >= M){
            ans++;
        }
    }
    cout << ans << endl;
}



Measured memory_bytes: 1792
#スペース区切りの整数の入力
N, A, B = map(int, input().split())

S = int(N / (A+B))
ans = S*A

amari = N % (A+B)
if(amari <= A):
  ans = ans + amari
  print(int(ans))
else:
  ans = ans + A
  print(int(ans))

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

typedef long long LL;

const int maxn = 1e5 + 100;

int n, ans;
LL a[maxn];
std::map<LL, int> M;

int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; ++i) {
		scanf("%lld", a + i);
		for(LL y = 2; y * y * y <= a[i]; ++y) {
			while(a[i] % (y * y * y) == 0) {
				a[i] /= (y * y * y);
			}
		}
		if(M.find(a[i]) == M.end()) {
			M[a[i]] = 0;
		}
		++M[a[i]];
	}
	for (int i = 1; i <= n; ++i) {
		if(M.find(a[i]) == M.end()) {
			continue;
		}
		if(a[i] == 1) {
			++ans;
			M.erase(a[i]);
			continue;
		}
		LL m = a[i];
		LL y = 1;
		for (LL x = 2; x <= 2500; ++x) {
			if(a[i] % x == 0) {
				a[i] /= x;
				if(y > 10000000000ll / x) {
					y = 10000000001ll;
					break;
				}
				y *= x;
				if(a[i] % x == 0) {
					a[i] /= x;
				}
				else {
					y *= x;
				}
			}
		}
		if(y > 10000000000ll) {
			ans += M[m];
			M.erase(m);
			continue;
		}
		if(a[i] > 1) {
			LL x = (LL)(sqrt(1. * a[i]));
			while(x * x <= a[i]) {
				++x;
			}
			while(x * x > a[i]) {
				--x;
			}
			if(x * x != a[i]) {
				x = a[i];
				if(x > 10000000000ll / x) {
					ans += M[m];
					M.erase(m);
					continue;
				}
				x *= x;
			}
			if(y > 10000000000ll / x) {
				ans += M[m];
				M.erase(m);
				continue;
			}
			y *= x;
		}
		if(M.find(y) != M.end()) {
			ans += std::max(M[m], M[y]);
			M.erase(y);
			M.erase(m);
		}
		else {
			ans += M[m];
			M.erase(m);
		}
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 9344
#! env/bin/local python3

import sys

n = int(input())
a = list(map(int, input().split()))
a = sorted(a, key=lambda x: x)

result = 1

for ac in a:
    result *= ac
    if result > 10 ** 18:
        print(-1)
        sys.exit()
else:
    print(result)




Measured memory_bytes: 21632
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
 int A,B;
 cin>>A>>B;
 if(A+B<24)
 cout<< A+B <<endl;
 else {
   cout<< A+B - 24 <<endl;
 }
  }


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cassert>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#include <random>
#include <complex>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<long double,long double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-10;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

int n,k;
vvi a;

int main(){
	cin>>n>>k;
	a=vvi(k+1,vi(k+1));
	for(int i=0;i<n;i++){
		int x,y;
		char c;
		cin>>x>>y>>c;
		int X=k-x%k-1,Y=k-y%k-1;
		if(c=='W'^(x/k+y/k)%2==1){
			a[X][Y]++;
			a[k-1][k-1]++;
			a[k-x%k-1][k-y%k-1]++;
			a[k-1][k-y%k-1]--;
			a[k-x%k-1][k-1]--;
		}
		else{
			a[k-1][k-1]++;
			a[X][Y]--;
			a[k-1][k-1]--;
			a[k-x%k-1][k-y%k-1]--;
			a[k-1][k-y%k-1]++;
			a[k-x%k-1][k-1]++;
		}
	}
	int M=0,m=inf;
	for(int i=k-1;i>=0;i--) for(int j=k-1;j>=0;j--){
		a[i][j]+=a[i+1][j]+a[i][j+1]-a[i+1][j+1];
		M=max(M,a[i][j]);
		m=min(m,a[i][j]);
	}
	cout<<max(M,n-m)<<endl;
}

Measured memory_bytes: 4224
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
#include<iomanip>
#include<map>
#include<set>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
void init_io(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(10);
}
template <typename Monoid >
struct SegmentTree{
  using F = function< Monoid(Monoid,Monoid) >;

  ll sz;
  vector<Monoid> seg;

  const F f;
  const Monoid M;

  SegmentTree(ll n,const F f,const Monoid &M) : f(f),M(M){
    sz = 1;
    while(sz<n) sz<<=1;
    seg.assign(sz*2,M);
  }
  void set(ll k,const Monoid &v){
    seg[k+sz] = v;
  }
  void build(){
    for(ll k=sz-1;k>0;k--){
      seg[k] = f(seg[2*k],seg[2*k+1]);
    }
  }
  void update(ll k,const Monoid &v){
    k += sz;
    seg[k] = v;
    while(k >>= 1){
      seg[k] = f(seg[2*k],seg[2*k+1]);
    }
  }
  Monoid que(ll a,ll b){
    Monoid L=M,R=M;
    for(a+=sz, b+=sz;a<b;a>>=1,b>>=1){
      if(a&1) L = f(L,seg[a++]);
      if(b&1) R = f(seg[--b],R);
    }
    return f(L,R);
  }
  Monoid operator[](const ll &k) const{
    return seg[k+sz];
  }
};
signed main(){
  init_io();
  ll n;
  ll ans = 0;
  cin >> n;
  ll dp[n];
  vector<ll> h(n),a(n);
  SegmentTree<ll> seg(300000,[](ll a,ll b){return max(a,b);},0);
  for(ll i=0;i<n;i++){
    cin >> h[i];
  }
  for(ll i=0;i<n;i++){
    cin >> a[i];
  }
  for(ll i=0;i<n;i++){
    dp[i] = a[i] + seg.que(0,h[i]);
    ans = max(ans,dp[i]);
    seg.update(h[i],dp[i]);
  }
  cout << ans << endl;
}


Measured memory_bytes: 13184
#include<stdio.h>
#include<stdlib.h>

int main(void)
{
  char a[10] ;
  scanf("%s",&a);

  if(strcmp(a,"ABC") == 0 ){
    puts("ARC");
  }

  if(strcmp(a,"ARC") == 0 ){
    puts("ABC");
  }


    return 0;

}



Measured memory_bytes: 1664
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Globalization;
using System.Diagnostics;
using Pair = System.Collections.Generic.KeyValuePair<int, int>;
//using System.Numerics;

class Program
{
    static void Main()
    {
        Scanner cin = new Scanner();
        //Random rnd = new Random();
        //Stopwatch sw = new Stopwatch();

        // A B C
        /*
        int A = cin.Nextint;
        int B = cin.Nextint;
        int C = cin.Nextint;
        */
        int N = cin.Nextint;
        int M = cin.Nextint;
        int dif = Math.Abs(N-M);
        if (dif > 1)
        {
            Console.WriteLine(0);

            return ;
        }

        long factM = 1;
        for (long i=1; i<=M; i++)
        {
            factM = factM * i;

            if (factM > 1000000007)
            {
                factM = ((factM -1) % 1000000007) + 1;
            }
        }

        long factN = 1;
        for (long i=1; i<=N; i++)
        {
            factN = factN * i;

            if (factN > 1000000007)
            {
                factN = ((factN -1)% 1000000007)+1;
            }
        }


        if (dif == 0)
        {
            Console.WriteLine((factM * factN * 2 )% 1000000007 );
        }
        else
        {
            Console.WriteLine((factM * factN) % 1000000007 );

        }
            

        // N
        // a1 a2 ... aN
        /*
        int N;
        int[] A;

        N = cin.Nextint;
        A = cin.Scanint;
        */

        // N M
        // a1 b1
        // ...
        // aM bM
        /*
        int N;
        int M;
        int[] A = new int[M];
        int[] B = new int[M];

        N = cin.Nextint;
        M = cin.Nextint;

        for(int i=0; i<M; i++)
        {
            A[i] = cin.Nextint;
            B[i] = cin.Nextint;
        }
         */



        /** ここに記述 */

        //Console.WriteLine(result ? "Yes" : "No");
        Console.Out.Flush();
    }
}

class Scanner
{
    string[] s; int i;
    char[] cs = new char[] { ' ' };
    public Scanner() { s = new string[0]; i = 0; }
    public string[] Scan { get { return Console.ReadLine().Split(); } }
    public int[] Scanint { get { return Array.ConvertAll(Scan, int.Parse); } }
    public long[] Scanlong { get { return Array.ConvertAll(Scan, long.Parse); } }
    public double[] Scandouble { get { return Array.ConvertAll(Scan, double.Parse); } }
    public string Next
    {
        get
        {
            if (i < s.Length)
            {
                return s[i++];
            }
            string st = Console.ReadLine();
            while (st == "")
            {
                st = Console.ReadLine();
            }

            s 
            = st.
                Split
                (cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
            return Next;
        }
    }
    public int Nextint { get { return int.Parse(Next); } }
    public long Nextlong { get { return long.Parse(Next); } }
    public double Nextdouble { get { return double.Parse(Next); } }
}

Measured memory_bytes: 13268
#include<bits/stdc++.h>
 
using namespace std;
 
typedef long long int ll;
#define pB push_back
#define mp make_pair
#define N 200005
 
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
	
	ll R[N]={0},G[N]={0},B[N]={0};
	ll n,i,j;
	cin>>n;
	string s;
	cin>>s;
	
	ll ans=0;
	if(s[0]=='R')
		R[0]=1;
	if(s[0]=='G')
		G[0]=1;
	if(s[0]=='B')
		B[0]=1;
	
	for(i=1;i<n;i++){
		R[i]=R[i-1];
		G[i]=G[i-1];
		B[i]=B[i-1];
		if(s[i]=='R')
			R[i]++;
		if(s[i]=='G')
			G[i]++;
		if(s[i]=='B')
			B[i]++;
	}
	for(i=1;i<n;i++){
		if(s[i]=='R'){
			for(j=0;j<i;j++){
				if(s[j]=='G'){
					ans += (B[n-1]-B[i]);
					if(2*i-j < n && s[2*i-j]=='B'){
						ans--;
					}
				}
				if(s[j]=='B'){
					ans += (G[n-1]-G[i]);
					if(2*i-j < n && s[2*i-j]=='G'){
						ans--;
					}	
				}
			}	
		}
		if(s[i]=='G'){
			for(j=0;j<i;j++){
				if(s[j]=='R'){
					ans += (B[n-1]-B[i]);
					if(2*i-j < n && s[2*i-j]=='B'){
						ans--;
					}
				}
				if(s[j]=='B'){
					ans += (R[n-1]-R[i]);
					if(2*i-j < n && s[2*i-j]=='R'){
						ans--;
					}	
				}
			}	
		}
		if(s[i]=='B'){
			for(j=0;j<i;j++){
				if(s[j]=='G'){
					ans += (R[n-1]-R[i]);
					if(2*i-j < n && s[2*i-j]=='R'){
						ans--;
					}
				}
				if(s[j]=='R'){
					ans += (G[n-1]-G[i]);
					if(2*i-j < n && s[2*i-j]=='G'){
						ans--;
					}	
				}
			}	
		}
	}
	cout<<ans<<endl;



 	return 0;
}


Measured memory_bytes: 8344
import sys
input = sys.stdin.readline

def main():
  n, k = map(int, input().split())
  a_list = list(map(int, input().split()))
  dp = [False]*(k+1)

  for i in range(1,k+1):
    for j in range(n):
      if i-a_list[j] >= 0:
        dp[i] |= not(dp[i-a_list[j]])


  if dp[k]:
    print('First')
  else:
    print('Second')
main()

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

using namespace std;
#define taskname "TEST"
#define pb	push_back
typedef long double ld;
typedef long long ll;
const int maxn = 1e6;
int n ,W;
ll dp[(int)1e5 + 5];
ll inf = 1e18;
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	if(fopen(taskname".INP","r"))
        freopen(taskname".INP", "r",stdin) ,
        freopen(taskname".OUT", "w",stdout);
    cin >> n >> W;
    int res = 0;
    fill_n(dp,(int)1e5+5,inf);
    dp[0] = 0;
    for(int i = 1 ; i <= n ; ++i)
    {
        int w , v;
        cin >> w >> v;
        for(int i = 1e5 ; i >= 0 ; --i)
        {
            if(i >= v)dp[i] = min(dp[i],dp[i - v] + w);
            if(dp[i] <= W)res = max(res , i);
        }
    }
    cout << res;
}


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

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

    vector<int> bars(N);
    for (auto& bar : bars) cin >> bar;
    sort(bars.begin(), bars.end(), greater<int>());

    int sum = 0;
    for (int i = 0; i < K; ++i) {
        sum += bars[i];
    }
    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 256
/* Name of the class has to be "Main" only if the class is public. */
import java.util.Scanner;
import java.util.Arrays;

class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		int [] x = new int[10];
		
		Scanner cin = new Scanner(System.in);
		for (int i = 0; i < 10; i++) {
     		x[i] = cin.nextInt();
		}
		
		Arrays.sort(x);
		
		for (int i = 9; i >= 7; i--) {
			 System.out.println(x[i]);
		}
	}
}

Measured memory_bytes: 26204
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
#include <iomanip>
#include <climits>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
//typedef pair<ll, ll> P;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define revrep(i, n) for(int i = (n)-1; i >= 0; i--)
#define pb push_back
#define f first
#define s second
#define chmin(x, y) x = min(x, y);
#define chmax(x, y) x = max(x, y);

//const ll INFL = LLONG_MAX;//10^18 = 2^60
const ll INFL = 1LL<<60;
//const int INF = INT_MAX;
const int INF = 1 << 30;//10^9
ll MOD = 1000000007;
//ll MOD = 998244353;
double EPS = 1e-11;

vector<ll> dy = {0, 1, 0, -1, 1, 1, -1, -1, 0};
vector<ll> dx = {1, 0, -1, 0, 1, -1, 1, -1, 0};

void pres(double A){printf("%.12lf\n", A);}
void BinarySay(ll x, ll y = 60){rep(i, y) cout << (x>>(y-1-i) & 1); cout << endl;}
ll cnt_bit(ll x){return __builtin_popcountll(x);}

ll pow_long(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2) res *= x;
    x *= x; k /= 2;
  }
  return res;
}

ll pow_mod(ll x, ll k){
  x %= MOD;
  ll res = 1;
  while(k > 0){
    if(k % 2){
      res *= x; res %= MOD;
    }
    x *= x; x %= MOD;
    k /= 2;
  }
  return res;
}

ll inverse(ll x){return pow_mod(x, MOD - 2);};

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

ll lcm(ll x, ll y){
  ll res = x / gcd(x, y);
  res *= y;
  return res;
};


//コンビネーション
const int MAXcomb = 2000010;
ll fac[MAXcomb], finv[MAXcomb], inv[MAXcomb];
//facはn!,finvは1/n!
//invは逆元
void COMinit(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < MAXcomb; 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;
    }
}
ll comb(int n, int k){
    if(n < k) return 0;
    if(n < 0 || k < 0) return 0;
    return fac[n] * finv[k] % MOD * finv[n-k] % MOD;
}

const int MAXkai = 200010;
ll kai_memo[MAXkai];
ll kai(ll N){
  if(kai_memo[N] != 0) return kai_memo[N];
  if(N <= 1) return 1;
  return kai_memo[N] = N * kai(N-1) % MOD;
}

ll disit(ll s, ll base = 10){
  ll res = 0;
  while(s){
    res++;
    s /= base;
  }
  return res;
}

bool comp(pair<int, int> p, pair<int, int> q){
  if(p.f != q.f) return p.f >= q.f;
  return p.s <= q.s;
}

void solve(){
  int N;
  cin >> N;
  vector<int> A(N);
  rep(i, N) cin >> A[i];
  set<pair<int, int>> S;
  for(int i = 0; i < N; i++){
    if(S.size() == 0 || A[i] <= S.begin()->f){
      S.insert({A[i], i});
      continue;
    }
    auto itr = S.lower_bound(pair<int, int>{A[i], -1});
    itr--;
    pair<int, int> p = *itr;
    S.erase(p);
    S.insert({A[i], i});
  }
  cout << S.size() << endl;
}



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


Measured memory_bytes: 5376
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define INF INT_MAX/2

int cc[8];

int solve(vector<int> c)
{
	int s, t;
	int m = INF;

	rep(i1, 0, 4) rep(i2, 0, 4) rep(i3, 0, 4)
	{
		rep(i, 0, 8) cc[i] = c[i];

		rep(i, 0, i1)
		{
			t = cc[0];
			cc[0] = cc[4];
			cc[4] = cc[7];
			cc[7] = cc[3];
			cc[3] = t;

			t = cc[1];
			cc[1] = cc[5];
			cc[5] = cc[6];
			cc[6] = cc[2];
			cc[2] = t;
		}

		rep(i, 0, i2)
		{
			t = cc[0];
			cc[0] = cc[1];
			cc[1] = cc[5];
			cc[5] = cc[4];
			cc[4] = t;

			t = cc[3];
			cc[3] = cc[2];
			cc[2] = cc[6];
			cc[6] = cc[7];
			cc[7] = t;
		}

		rep(i, 0, i3)
		{
			t = cc[0];
			cc[0] = cc[1];
			cc[1] = cc[2];
			cc[2] = cc[3];
			cc[3] = t;

			t = cc[4];
			cc[4] = cc[5];
			cc[5] = cc[6];
			cc[6] = cc[7];
			cc[7] = t;
		}

		s = 0;
		rep(i, 0, 8) s = s * 10 + cc[i];
		m = min(m, s);
	}

	return m;
}

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

	string s[8];
	while (cin >> s[0])
	{
		rep(i, 1, 8) cin >> s[i];

		map<string, int> m;
		rep(i, 0, 8) m[s[i]] = 0;
		int i = 0;
		for (auto p : m)
		{
			m[p.first] = i;
			i++;
		}

		vector<int> c(8);
		rep(i, 0, 8) c[i] = m[s[i]];

		set<int> ans;
		sort(c.begin(), c.end());
		do
		{
			ans.insert(solve(c));
		} while (next_permutation(c.begin(), c.end()));
		
		cout << ans.size() << endl;
	}
}

Measured memory_bytes: 3172
n = int(input())
arr = list(map(int, input().strip().split()))

mem = [[0 for i in range(n)] for i in range(n)]
for i in range(n):
    mem[i][i] = arr[i]

for diff in range(1, n):
    for L in range(n-diff):
        H = L+diff
        mem[L][H] = max(arr[L]-mem[L+1][H], arr[H]-mem[L][H-1])

print(mem[0][n-1])

Measured memory_bytes: 153168
import math

N = int(input())
S = []
for i in range(N):
    S_tmp = str(input())
    S_tmp = list(S_tmp)
    S_tmp.sort()
    S.append("".join(S_tmp))
S.sort()

count=0
x = 0
tmp = S[0]
count_all = []
for i in S[1:]:
    if tmp==i:
        count+=1
    else:
        if count>0:
            x += math.factorial(count+1)//(math.factorial(count+1-2) * math.factorial(2))
        count = 0
    tmp = i
if count>0:
    x += math.factorial(count+1)//(math.factorial(count+1-2) * math.factorial(2))
        
    tmp = i
print(x)

Measured memory_bytes: 11476
#include<bits/stdc++.h>
#pragma O3
#define int long long
using namespace std;
map<pair<int,int>,int> mp;
int cnt[11];
int n,m,q,u,v,x,y;
int dx[9]={-1,-1,-1,0,0,0,1,1,1},dy[9]={-1,0,1,-1,0,1,-1,0,1};
signed main(){
//	freopen(".inp","r",stdin);
//	freopen(".out","w",stdout);
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin>>n>>m>>q;
	cnt[0]=(n-2)*(m-2);
	for(int i=0;i<q;i++){
		cin>>x>>y;
		for(int j=0;j<9;j++){
			u=x+dx[j];
			v=y+dy[j];
			if(u>1&&u<=n-1&&v>1&&v<=m-1){
				mp[{u,v}]++;
				cnt[mp[{u,v}]-1]--;
				cnt[mp[{u,v}]]++;
			}
		}
	}
	for(int i=0;i<10;i++){
		cout<<cnt[i]<<endl;
	}
}

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

long long int lucas(int N)
{
	int i, j, k;
	long long int result = 0, before;
	if (N == 1)
		return 1;
	else {	
		for (i = 1; i <= N; i++) {
			if (i == 1) {
				result = 1;
				before = 2;
			} else {
				long long int tmp = result;
				result = result + before;
				before = tmp;
			}
		}
		return result;
	}

}

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

	int i, j, k;

	printf("%lld\n", lucas(N));

	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
#define ALL(a)  (a).begin(),(a).end()
const ll INF = 1e18+18;
const ll MAX = 200000;
const ll MOD = 1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;



int main(){
  ll N, K;
  cin>>N>>K;
  vector<ll> A(N);
  rep(i, N){
    cin>>A[i];
  }
  for(ll i=K; i<N; i++){
    Yes(A[i-K]<A[i]);
  }
  return 0;
} 

Measured memory_bytes: 4760
#include <bits/stdc++.h>
using namespace std;
int a, b, k;

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

    // a < b
    if(a > b) swap(a, b);

    int br = 1;
    for(int i=a;i>=1;i--) {
        if(a % i == 0 && b % i == 0) {
            if(br == k) {
                cout<<i<<"\n";
                return 0;
            }
            br++;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#define rep(i, start, end) for (int i = (int)start; i < (int)end; ++i)
#define rrep(i, start, end) for (int i = (int)start - 1; i >= (int)end; --i)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return 0;}
template<typename T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return 0;}

template <class T>
class Bellmanford {
    private:
        struct edge {
            int from, to;
            T cost;
            edge(int from, int to, T cost):from(from), to(to), cost(cost) {}
        };
        T identity_;
        vector<edge> edges_;
        vector<T> dist_;
        vector<bool> in_negative_;
        bool negative_loop_;
    public:
        Bellmanford(int node_num, int edge_num, T identity):
        identity_(identity), dist_(vector<T>(node_num, identity)), in_negative_(vector<bool>(node_num, false)), negative_loop_(false) {}
        void addEdge(int from, int to, T cost) {
            edges_.emplace_back(from, to, cost);
        }
        void _calcShortestPath(int start_node) {
            dist_[start_node] = 0;
            int n = (int)dist_.size();
            int m = (int)edges_.size();
            for (int i = 0; i < n; ++i) {
                for (int j = 0; j < m; ++j) {
                    edge now_edge = edges_[j];
                    if (dist_[now_edge.from] != identity_ && dist_[now_edge.to] > dist_[now_edge.from] + now_edge.cost) {
                        dist_[now_edge.to] = dist_[now_edge.from] + now_edge.cost;
                        if (i == n - 1) {
                            negative_loop_ = true;
                            in_negative_[now_edge.to] = true;
                        }
                    }
                    if (in_negative_[now_edge.from]) {
                        in_negative_[now_edge.to] = true;
                    }
                }
            }
        }
        void calcShortestPath(int start_node) {
            _calcShortestPath(start_node);
            _calcShortestPath(start_node);
        }
        bool hasNegLoop() {
            return negative_loop_;
        }
        bool inNegLoop(int node) {
            return in_negative_[node];
        }
        T getDist(int node) {
            return dist_[node];
        }
};

const ll INF = 1LL << 50;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, M;
    ll P;
    cin >> N >> M >> P;
    int A, B;
    ll C;
    Bellmanford<ll> bf(N, M, INF);
    rep(i, 0, M) {
        cin >> A >> B >> C;
        --A, --B;
        bf.addEdge(A, B, P - C);
    }
    bf.calcShortestPath(0);
    if (bf.inNegLoop(N - 1)) {
        cout << -1 << endl;
    } else {
        cout << max(0LL, -bf.getDist(N - 1)) << endl;
    }
    return 0;
}

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

using namespace std;

int h, w, n, sr, sc;

bool check(vector<int>& A, vector<int>& B, int v, int ok)
{
  int l = 0, r = v;
  for (int i = 0; i < n; i++) {
    if (B[i] == 1) l = max(l-1, 0);
    if (B[i] == -1) r = min(r+1, v);
    if (A[i] == 1) r--;
    if (A[i] == -1) l++;
    if (l == r) return false;
  }
  return l <= ok && ok < r;
}

int main()
{
  cin >> h >> w >> n >> sr >> sc;
  string s1, s2;
  cin >> s1 >> s2;
  vector<int> Ar(n, 0), Ac(n, 0), Br(n, 0), Bc(n, 0);
  for (int i = 0; i < n; i++) {
    if (s1[n-1-i] == 'D') Ar[i] = 1;
    if (s1[n-1-i] == 'U') Ar[i] = -1;
    if (s1[n-1-i] == 'R') Ac[i] = 1;
    if (s1[n-1-i] == 'L') Ac[i] = -1;
    
    if (s2[n-1-i] == 'D') Br[i] = 1;
    if (s2[n-1-i] == 'U') Br[i] = -1;
    if (s2[n-1-i] == 'R') Bc[i] = 1;
    if (s2[n-1-i] == 'L') Bc[i] = -1;
  }
  if (check(Ar, Br, h, sr-1) && check(Ac, Bc, w, sc-1)) cout << "YES" << endl;
  else cout << "NO" << endl;
}


Measured memory_bytes: 3848
n=int(input())
h=list(map(int,input().split()))

dp = [float("inf")]*n #最小値求めるのでinfで初期化
dp[0]=0
dp[1]=abs(h[1]-h[0])
for i in range(2,n):
    dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]))
print(dp[-1])

Measured memory_bytes: 13980
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)
#define repa(i,n) for (auto& i: n)

template<class T> inline bool chmax(T &a, const T &b) {if (a<b) { a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a, const T &b) {if (b<a) { a=b; return 1;} return 0;}
struct init{init(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}}init_;

#ifdef DEBUG
template <class T, class N> void verr(const T& a, const N& n) { rep(i, n) cerr << a[i] << " "; cerr << "\n" << flush; }
ll dbgt = 1; void err() { cerr << "passed " << dbgt++ << "\n" << flush; }
template<class H, class... T> void err(H&& h,T&&... t){ cerr<< h << (sizeof...(t)?" ":"\n") << flush; if(sizeof...(t)>0) err(forward<T>(t)...); }
#endif

const ll INF = 4e18;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
// const ll MOD = 1e9 + 7;
const ll MOD = 998244353;
//--------------------------------------------------------------------------------//

int main() {
    ll N, K;
    cin >> N >> K;
    vc<pair<ll, ll>> P(K);
    rep(i, K) cin >> P[i].first >> P[i].second;
    sort(all(P));

    vl dp(N + 1), imos(N + 1);

    imos[1] = 1, imos[2] = -1;
    repe(i, 1, N + 1){
        (imos[i] += imos[i - 1]) %= MOD;
        dp[i] = imos[i];
        rep(k, K){
            auto [l, r] = P[k];
            if (i + l <= N) (imos[i + l] += dp[i]) %= MOD;
            if (i + r + 1 <= N) (imos[i + r + 1] += MOD - dp[i]) %= MOD;
        }
    }

    // verr(dp, N + 1), verr(imos, N + 1);
    cout << dp[N] << endl;
}

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

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

int main() {
    int n = 5;
    int answer = 0;
    rep(i, n){
        int tmp;
        cin >> tmp;
        if(tmp == 0){
            answer = i;
        }
    }
    cout << answer + 1 << endl;
    return 0;    
}


Measured memory_bytes: 3520
#include "iostream"
#include "algorithm"
#include "vector"
#include "string"
#include "cmath"
typedef long long ll;
using namespace std;

int main(int argc, char const *argv[]) {
  string SS;

  std::cin >> SS;

  // std::cout << SS << '\n';

  ll NN = SS.size();

  // std::cout << NN << '\n';

  ll counter=0, ans=0;

  for (size_t i = 0; i < NN; i++) {
    if (SS[i] == 'W') {
      ans += i - counter;
      counter++;
    }
  }

  // std::cout << counter << '\n';

  std::cout << ans << '\n';



  return 0;
}


Measured memory_bytes: 640
/**
 *    author:  math2do
 *    created: 02.05.2020 22:43:29 IST
**/

#include <bits/stdc++.h>

using namespace std;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  long long x;
  cin >> x;
  int t = 0;
  long long p = 100;
  while (p < x) {
    p = p + p / 100;
    t++;
  } 
  cout << t << endl;
  return 0;
}


Measured memory_bytes: 3652