akhauriyash/Code-Regression huggingface dataset:
//
//  ROIGold.cpp
//  Main calisma
//
//  Created by Rakhman on 05/02/2019.
//  Copyright © 2019 Rakhman. All rights reserved.
//

#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cassert>
#include <iterator>

#define ios ios_base::sync_with_stdio(0), cout.tie(0), cin.tie(0);
#define S second
#define F first
#define pb push_back
#define nl '\n'
#define NL cout << '\n';
#define EX exit(0)
#define all(s) s.begin(), s.end()
#define FOR(i, start, finish, k) for(int i = start; i <= finish; i += k)

const int MXN = 1e6 + 200;
const long long MNN = 2e3 + 200;
const long long MOD = 1e9 + 7;
const long long INF = 1e18;
const int OO = 1e9 + 500;

typedef long long llong;
typedef unsigned long long ullong;

using namespace std;

llong n, k, ans;

int main () {
    ios;
    cin >> n >> k;
    for(llong b = k + 1; b <= n; b++){
        llong lol = n / b;
        ans += lol * (b - k);
        if(lol * b + k <= n){
            ans += n - (lol * b + k) + 1;
        }
        if(k == 0){
            ans--;
        }
    }
    cout << ans;
    return 0;
}


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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define POSSIBLE cout << ((n) ? "POSSIBLE\n" : "IMPOSSIBLE\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int32 n;
  cin >> n;
  string s;
  cin >> s;
  int32 x=0,ans=0;
  REP(i,n){
    if(s[i] == 'I'){
      x++;
    }else{
      x--;
    }
    ans = max(ans, x);
  }
  ANS(ans);
  return 0;
}

Measured memory_bytes: 256
N = int(input())
a = [int(input()) for i in range(N)]
t = 0
c = set([1])
n = 1
f = False
while t < len(c):
    t +=1
    n = a[n-1]
    if n == 2:
        f = True
        break
    c.add(n)
print(len(c) if f else -1)

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

using namespace std;
using ll = long long;
using ull = unsigned long long;
constexpr int inf = 1<<30;
constexpr int mo = 1e9+7;
constexpr ll infl = 1ll<<60;

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    int n,m;
    cin>>n>>m;
    vector<ll> s(n);
    map<ll,ll> mc;
    for(auto & a : s) cin>>a,a%=m;
    for(int i=1;i<n;++i){
        s[i] += s[i-1];
        s[i] %=m;
    }
    ll count = 0;
    ll ret = 0;
    for(int i=0;i<n;++i){
        if(s[i] == 0){
            ret += count++;
            ret++;
        }else {
            if(mc.count(s[i])){
                ret += mc[s[i]];
            }
        }
        mc[s[i]]++;
    }
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 7776
#include <cstdio>
#include <algorithm>
#include <vector>
#include <map>

using namespace std;

int main() {

    int n;
    scanf("%d", &n);

    vector<int> a(n), b(n), c(n);
    for (int i = 0; i < n; i++) {
        scanf("%d", &a[i]);
    }
    for (int i = 0; i < n; i++) {
        scanf("%d", &b[i]);
    }
    for (int i = 0; i < n; i++) {
        scanf("%d", &c[i]);
    }

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

    long long ans = 0LL;
    for (int i = 0; i < n; i++) {
        int it_a = lower_bound(a.begin(), a.end(), b[i]) - a.begin();
        int it_c = n - (upper_bound(c.begin(), c.end(), b[i]) - c.begin());

        ans += (long long)it_a * it_c;
    }
    printf("\n%lld\n", ans);

    return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <functional>
#include <queue>
using namespace std;
vector<vector<int>> vec;
int h,w;

int main(){
    cin >> h >> w ;
    int c=0;
    vec.resize(h,vector<int>(w));
    for(int i=0;i<h;i++){
        string s;
        cin >> s;
        for(int j=0;j<w;j++){
            vec[i][j]=s[j];
            if(s[j]=='#'){
                c++;
            }
        }
    }
    queue<pair<int,int>> q;
    vector<vector<int>> reg(h,vector<int>(w));
    q.push(pair<int,int>(0,0));
    reg[0][0]=0;
    bool h1=true;
    while(!q.empty()){
        int y=q.front().first;
        int x=q.front().second;
        q.pop();
        bool h2=false;
        vec[y][x]='.';
        if(y+1<h){
            if(vec[y+1][x]=='#'){
                q.push(pair<int,int>(y+1,x));
                reg[y+1][x]=reg[y][x]+1;
                h2=true;
            }
        }
        if(x+1<w){
            if(vec[y][x+1]=='#'){
                q.push(pair<int,int>(y,x+1));
                reg[y][x+1]=reg[y][x]+1;
                if(h2){
                    h1=false;
                    break;
                }
            }
        }
    }
    if(vec[h-1][w-1]=='#'||reg[h-1][w-1]!=h+w-2||(c-1)!=reg[h-1][w-1]){
        cout<<"Impossible"<<endl;
    }else{
        cout<<"Possible"<<endl;
    }
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
	static class FastReader{
		BufferedReader br;
		StringTokenizer st;
		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}
		public String next() {
			while(st==null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
					
				}
				catch(IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}
		int nextInt() {
			return Integer.parseInt(next());
		}
		long nextLong() {
			return Long.parseLong(next());
		}
		double nextDouble() {
			return Double.parseDouble(next());
		}
	}
	public static void main(String[] args) {
		FastReader ob = new FastReader();
		int n = ob.nextInt();
		int r = ob.nextInt();
		if(n>=10) {
			System.out.println(r);
		}
		else {
			System.out.println(r+(100*(10-n)));
		}
	}

}


Measured memory_bytes: 21204
/****************************
/////  Shubham Singhal
/////  LNMIIT
*****************************/
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// #include <functional> 
// using namespace __gnu_pbds;
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define ppb pop_back
#define pf push_front
#define ppf pop_front
#define eb emplace_back
#define lwr lower_bound
#define upr upper_bound
#define pq priority_queue
#define umap unordered_map
#define rep(i,n) for(i=0; i<n;i++)
#define repp(i,a,n) for(i=a; i<n;i++)
#define precise(x) cout<<fixed<<setprecision(x)
#define all(x) x.begin(),x.end()
#define lcm(a,b) (a*b)/__gcd(a,b)
#define prn(x) cout<<x<<"\n"
#define prn2(x, y) cout<<x<<" "<<y<<"\n"
#define prn3(x, y, z) cout<<x<<" "<<y<<" "<<z<<"\n"
#define prn4(x, y, z, a) cout<<x<<" "<<y<<" "<<z<<" "<<a<<"\n"
#define prnv(x) for(auto i:x) cout<<i<<" "; cout<<"\n"
#define MOD 1000000007
#define MaX 300005
using namespace std;

 
typedef unsigned long long ull;
typedef long long ll;
typedef double ld;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd; 
typedef vector<int> vi;
typedef vector<long> vl;
typedef vector<char> vc;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pii> vpii;
typedef vector<pil> vpil;
typedef vector<pli> vpli;
typedef vector<pll> vpll;
const long long INF64 = 1e18;
clock_t time_p=clock();
void time()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
void doc()
{
   	freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
}
void fast()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
}
// typedef tree<int, null_type, less<int>, rb_tree_tag, 
//              tree_order_statistics_node_update> 
//     new_data_set; 
bool isprime(ll n) 
{ 
    if (n <= 1) 
        return false; 
    if (n <= 3) 
        return true; 
    if (n % 2 == 0 || n % 3 == 0) 
        return false; 
  
    for (ll i = 5; i * i <= n; i = i + 6) 
        if (n % i == 0 || n % (i + 2) == 0) 
            return false; 
    return true; 
}
int main()
{
	fast();
	ll n,q,i,sum=0;
	cin>>n;
	ll a[n];
	umap<ll,ll> m;
	rep(i,n)
	{
		cin>>a[i];
		m[a[i]]++;
		sum+=a[i];
	}
	//ll q;
	cin>>q;
	while(q--)
	{
		ll x,y;
		cin>>x>>y;
		ll rem=m[x]*x;
		sum-=rem;
		sum+=m[x]*y;
		m[y]+=m[x];
		m[x]=0;
		cout<<sum<<'\n';
	}
}






/*
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⡀⠀⠀⠀⠀⢀⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⣠⡖⠁⠀⠀⠀⠀⠀⠀⠈⢲⣄⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⣼⡏⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢹⣧⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⣸⣿⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⣿⣇⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⣿⣿⡇⠀⢀⣀⣤⣤⣤⣤⣀⡀⠀⢸⣿⣿⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⢻⣿⣿⣔⢿⡿⠟⠛⠛⠻⢿⡿⣢⣿⣿⡟⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⣀⣤⣶⣾⣿⣿⣿⣷⣤⣀⡀⢀⣀⣤⣾⣿⣿⣿⣷⣶⣤⡀⠀⠀⠀⠀
⠀⠀⢠⣾⣿⡿⠿⠿⠿⣿⣿⣿⣿⡿⠏⠻⢿⣿⣿⣿⣿⠿⠿⠿⢿⣿⣷⡀⠀⠀
⠀⢠⡿⠋⠁⠀⠀⢸⣿⡇⠉⠻⣿⠇⠀⠀⠸⣿⡿⠋⢰⣿⡇⠀⠀⠈⠙⢿⡄⠀
⠀⡿⠁⠀⠀⠀⠀⠘⣿⣷⡀⠀⠰⣿⣶⣶⣿⡎⠀⢀⣾⣿⠇⠀⠀⠀⠀⠈⢿⠀
⠀⡇⠀⠀⠀⠀⠀⠀⠹⣿⣷⣄⠀⣿⣿⣿⣿⠀⣠⣾⣿⠏⠀⠀⠀⠀⠀⠀⢸⠀
⠀⠁⠀⠀⠀⠀⠀⠀⠀⠈⠻⢿⢇⣿⣿⣿⣿⡸⣿⠟⠁⠀⠀⠀⠀⠀⠀⠀⠈⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣼⣿⣿⣿⣿⣧⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠐⢤⣀⣀⢀⣀⣠⣴⣿⣿⠿⠋⠙⠿⣿⣿⣦⣄⣀⠀⠀⣀⡠⠂⠀⠀⠀
⠀⠀⠀⠀⠀⠈⠉⠛⠛⠛⠛⠉⠀⠀⠀⠀⠀⠈⠉⠛⠛⠛⠛⠋⠁⠀⠀⠀⠀⠀
*/

Measured memory_bytes: 7908
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do():
    n,m=INTM()
    ct=[0  for i in range(100001)]
    li=[]
    check=[0  for i in range(100001)]
    for i in range(m):
        p,s=STRM()
        p=int(p)
        li.append([p,s])
    for i in range(len(li)):
        if check[li[i][0]]==0:
            if li[i][1]=='WA':
                ct[li[i][0]]+=1
            else:
                check[li[i][0]]=1
        else:
            pass
    for i in range(100001):
        if check[i]==0:
            ct[i]=0
        else:
            pass
    
    ct_s=sum(ct)
    ck_s=sum(check)
    print(ck_s,ct_s)
if __name__ == '__main__':
    do()

Measured memory_bytes: 23476
$n = gets.to_i
INF = 1 << 30
$m = Array.new($n){ Array.new }
$n.times do
  l = gets.split.map(&:to_i)
  (1..l[1]).each{ |i| $m[l[0]] << l[2*i,2] }
end
$n.times{ |i| $m[i].sort! }

def dijkstra(x)
  cost = Array.new($n, INF)
  cost[x] = 0
  used = Array.new($n)
  loop do
    m = INF
    $n.times{ |i| m = cost[i] if !used[i] && m > cost[i] }
    break if m == INF 
    $n.times do |i|
      if m == cost[i]
        used[i] = true
        $m[i].each do |r|
          u, w = r
          cost[u] = cost[i] + w if cost[u] > cost[i] + w 
        end
      end
    end
  end
  cost
end
ret = dijkstra(0)
ret.each_index{ |i| puts "#{i} #{ret[i]}" }

Measured memory_bytes: 45348
#include <iostream>

int main() {
  const int l_suits = 4, l_num = 13;
  char suits[l_suits]{'S', 'H', 'C', 'D'};
  bool cards[l_suits][l_num] = {};

  int n, j, num;
  char suit;
  std::cin >> n;
  for (int i = 0; i < n; i++) {
    std::cin >> suit >> num;
    j = 0;
    while (suits[j] != suit) {
      j++;
    }
    cards[j][num - 1] = true;
  }

  for (int i = 0; i < l_suits; i++) {
    for (int j = 0; j < l_num; j++) {
      if (!cards[i][j])
        std::cout << suits[i] << " " << j + 1 << std::endl;
    }
  }
}



Measured memory_bytes: 3076
h, w = map(int, input().split())

f = (h-h%2)*(w-w%2)//4
t = 0
one = 0
if h%2==1:
    t += w//2
if w%2==1:
    t += h//2
if h%2==1 and w%2==1:
    one = 1

dic = {}
for i in range(h):
    a = list(input())
    for j in a:
        if j in dic:
            dic[j] += 1
        else:
            dic[j] = 1

result = True
for i, j in dic.items():
    if j%2==1:
        if one == 1:
            j -= 1
            one -= 1
        else:
            result = False
    if j==0:
        continue
    while f > 0 and j>=4:
        j -= 4
        f -= 1
        if j==0:
            break
    if j==0:
        continue
    while t > 0 and j>=2:
        j -= 2
        t -= 1
        if j==0:
            break
    if j==0:
        continue
    else:
        result = False

    if result == False:
        break

if result:
    print("Yes")
else:
    print("No")

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

using namespace std;

#define int long long

void solve()
{
	int n, a, b;
	cin >> n >> a >> b;
	
	if(a > b)
		swap(a, b);
	
	if((b - a) % 2 == 0)
	{
		cout << (b - a) / 2;
		return ;
	}
	
	cout << min(a - 1, n - b) + (b - a + 1) / 2;
}

main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	
	int t = 1;
//	cin >> t;
	
	while(t--)
	{
		solve();
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std ;
#define IOS         ios_base::sync_with_stdio(false);   cin.tie(NULL);
#define FOR(i,n)     for(ll i=0;i<n;i++)
#define REP(i,k,n)  for(ll i=k;i<n;i++)
#define nl         "\n"
#define BUFFER         cin.ignore(numeric_limits<streamsize>::max(),'\n');
#define SORT        sort(a,a+n);
#define mod         1000000007
#define pb          push_back
typedef long long ll;
bool d(const pair<int,int> &a, 
                   const pair<int,int> &b) 
{ 
       return a.second>b.second; 
} 
int main()
{
    ll n;
    cin>>n;
    string s,s1="",s2="";
    cin>>s;
    FOR(i,n/2)
    s1+=s[i];
    for(ll i=n/2;i<n;i++)
    s2+=s[i];
    if(s1==s2)
    cout<<"Yes"<<nl;
    else
    cout<<"No"<<nl;
    
    
return 0;
}


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

#include <bits/stdc++.h>
#define DEBUG true
#ifdef ONLINE_JUDGE
#undef DEBUG
#define DEBUG false
#endif 

using namespace std;

#define TRACE(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); cerr << endl;}

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << "[" << *it << " = " << a << "]";
	err(++it, args...);
}

#define MAXN ((int)6208)
#define MOD ((int)1e9 + 7)
#define INF ((int)1e9 + 9)
#define ll long long
#define _ << " " <<
#define CLEAR(a, b) memset(a, b, sizeof(a))
#define LOG(x) if(DEBUG) cerr << x << endl;
#define pb push_back
#define all(x) x.begin(), x.end()
#define endl "\n"
#define pii pair<int,int>
#define mid ((l+r)/2)
ll fast(ll a,ll b)
{
	ll res=1;
	while(b)
	{
		if(b&1LL)
		{
			res*=a;
		}
		b>>=1LL;
		a*=a;
	}
	return res;
}

ll x;
unordered_map <ll, ll> mp;

void pre()
{
	for (ll i = -MAXN; i <= MAXN; ++i)
		mp[fast(i, 5)] = i;
}

ll is_valid(ll a)
{
	if(mp.count(a))
		return mp[a];
	return -1;
}

signed main()
{
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	pre();

	cin >> x;

	for (ll i = -MAXN; i <= MAXN; ++i)
	{
		ll val = is_valid(x + fast(i, 5));
		if(val != -1)
		{
			cout << val _ i << endl;
			return 0;
		}
	}
}

/* stuff you should look for
	* int overflow, array bounds
	* special cases (n=1?)
	* do smth instead of nothing and stay organized
	* WRITE STUFF DOWN
*/

Measured memory_bytes: 4092
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
using namespace std;

int main(int argc, char* argv[])
{
    int n;
    scanf("%d", &n);

    vector<pair<int,int> > z;
    vector<int> a(n);
    int i;
    for(i=0; i<n; i++) {
        scanf("%d", &a[i]);
        z.push_back(make_pair(a[i],i));
    }
    sort(z.rbegin(), z.rend());

    vector<int> v(n*4, -1);
    for(i=0; i<n; i++) {
        v[4*i+2]=n;
        v[4*i+3]=n;
    }

    {
        set<int> ss;
        for(i=0; i<n; i++) {
            int id=z[i].second;
            auto it=ss.insert(id).first;
            {
                auto it2=it;
                it2++;
                if(it2!=ss.end()) {
                    v[4*id+2]=(*it2);
                    it2++;
                    if(it2!=ss.end()) {
                        v[4*id+3]=(*it2);
                    }
                }
            }
            {
                auto it2=it;
                if(it2!=ss.begin()) {
                    it2--;
                    v[4*id+1]=(*it2);
                    if(it2!=ss.begin()) {
                        it2--;
                        v[4*id]=(*it2);
                    }
                }
            }
        }
    }

    ll ans=0;
    for(i=0; i<n; i++) {
        int tmp0=v[4*i+1]-v[4*i];
        int tmp1=i-v[4*i+1];
        int tmp2=v[4*i+2]-i;
        int tmp3=v[4*i+3]-v[4*i+2];
        ans += ((ll)tmp0*tmp2 + (ll)tmp1*tmp3)*a[i];
    }
    printf("%lld\n", ans);

    return 0;
}


Measured memory_bytes: 7668
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
typedef long long ll;
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,num,n) for(int i=num, i##_len=(n); i<i##_len; ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define print(x) (cout << (x) << endl)
#define pb push_back
#define mp make_pair
#define sz(x) int(x.size())
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
#define fs first
#define sc second

const int INF = 1e9;
const ll LLINF = 1e16;
const ll MOD = 1e9+7;
template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}
 
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
 

// 指定した文字cが文字列に何文字入ってるか
ll stringcount(string s, char c) {
    return count(s.cbegin(), s.cend(), c);
}


// 割り算の切り上げ処理
template<typename T>
T rp(T a, T b) {
  return (a + b - 1) / b;
}

// 桁和
template<typename T>
T digsum(T n) {
    T res = 0;
    while(n > 0) {
        res += n%10;
        n /= 10;
    }
    return res;
}

// 回文判定
bool kai (string s) {
    string t{s};
    reverse(begin(t), end(t));
    return s == t;
}

using pint = pair<int, int>;
using pll = pair<ll, ll>;



int dp[30][100000];

int main(void)
{
    cout.tie(0);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    int n,m;
    cin >> n >> m;
    vector<int> c(m);
    rep(i, m) {
        cin >> c[i];
    }
    rep(i, 30) rep(j, 100000) dp[i][j] = INF;
    dp[0][0] = 0;
    rep(i, m){
        rep(j, n + 1){
            chmin(dp[i + 1][j], dp[i][j]);
            chmin(dp[i + 1][j + c[i]], dp[i + 1][j] + 1);
        }
    }
    print(dp[m][n]);


}



Measured memory_bytes: 14876
/*
Looking from a window above
It's like a story of love
Can you hear me?
Came back only yesterday
I'm moving further away
Want you near me
All I needed was the love you gave
All I needed for another day
And all I ever knew
Only you
Sometimes when I think of her name
When it's only a game
And I need you
Listen to the words that you say
It's getting harder to stay
When I see you
All I needed was the love you gave
All I needed for another day
And all I ever knew
Only you, only you
Uh uh uh only you, only you
Only you, only you, only you
This is going to take a long time
And I wonder what's mine
Can't take no more
Wonder if you'll understand
It's just the touch of your hand
Behind a closed door
And all I needed was the love you gave
All I needed for another day
And all I ever knew
Only you, only you, only you
All I needed was the love you gave
All I needed for another day
And all I ever knew
Only you, only you, only you
Only you
*/

#include <bits/stdc++.h>

using namespace std;

#define int long long
#define ld long double
#define endl '\n'
#define rep(x,s,e) for(int x=s;x<=(e);x++)
#define repn for(int x=0;x<n;x++)
#define rep1n for(int x=1;x<=n;x++)
#define rep1m for(int y=1;y<=m;y++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(), x.rend()
#define precise(x) cout << fixed << setprecision(x)
#define bits(x) __builtin_popcountll(x)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define sz(x) ((int)(x.size()))
#define test int t; cin>>t; while(t--)
#define FAST                          \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL)

typedef vector<int> vi;
typedef vector<pair<int,int>> vii;
typedef pair<int,int> pii;


void __print(int x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}


template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define see(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define see(x...)
#endif

const int inf = 3e18;
const int N = 5e5 + 100;




int32_t main(){ 
   FAST;
   int n , m;
   cin >> n >> m;
   cout << (n == m ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> P;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)
/*
vector<char>al(26);
al = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
vector<char>AL(26);
AL = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
vector<char>NUM(10);
	NUM = { '0','1','2' ,'3' ,'4' ,'5' ,'6' ,'7' ,'8' ,'9' };
*/



int main() {
	vector<int>V(3);
	rep(i, 3) {
		cin >> V[i];
	}
	sort(V);
	int ans = 0;
	ans += V[2] * 10;
	ans += V[0];
	ans += V[1];
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; i++)
#define repo(i, n) for(int i=1; i<=n; i++)
#define INF 1001001001
#define INFll 100100100100100
// debug用
#define PrintVec(x) for (auto elementPrintVec: x) { cout << elementPrintVec << " "; } cout << endl;

using namespace std;
using ull = unsigned long long;
using ll = long long;
using P = pair<int, int>;
const int mod = 1000000007;
const int MAX = 510000;//階乗の配列数
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; 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(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

// mod. m での a の逆元 a^{-1} を計算する
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

int main() {
    // 前処理
    COMinit();
    int n, m;
    cin >> n >> m;
    ll ans=0;
    rep(i, n+1){
      ll l=COM(n, i);
      l*=fac[m];
      l%=MOD;
      l*=finv[m-n];
      l%=MOD;
      l*=finv[m-n];
      l%=MOD;
      l*=fac[m-i];
      l%=MOD;
      if(i%2==0){
        ans+=l;
        ans%=MOD;
      } else {
        ans-=l;
        ans+=MOD;
        ans%=MOD;
      }

    }
    // 計算例
    cout << ans << endl;
}


Measured memory_bytes: 15528
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <cmath>
#include <set>
#include <bitset>
#include <limits>

using namespace std;

#define ll long long

int main(void){
    double r;
    cin >> r;

    printf("%.9lf", 2*M_PI*r);

    return 0;
}

Measured memory_bytes: 3784
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <cmath>
#include <climits>
#include <algorithm>
#include <utility>
 
using namespace std;
using Int = long long int;
using UInt = unsigned long long int;
using VI = vector<long long int>;
// 基本的な演算
namespace BasicMath {
    // 分数の Ceil を求める関数
    static UInt Ceil(const UInt a, const UInt b);
    // 二つの値の最小値を求める関数
    static Int Min(const Int a, const Int b);

    // 分数の Ceil を求める関数
    UInt Ceil(const UInt a, const UInt b) {
        if (a % b == 0) {
            return a / b;
        } else {
            return a / b + 1;
        }
    }

    // 二つの値の最小値を求める関数
    Int Min(const Int a, const Int b) {
        if (a <= b) {
            return a;
        } else {
            return b;
        }
    }
}
using namespace BasicMath;

int main(void) {
    Int n, a, b, c, d, e;
    cin >> n >> a >> b >> c >> d >> e;
    Int min_value = a;
    min_value = Min(min_value, b);
    min_value = Min(min_value, c);
    min_value = Min(min_value, d);
    min_value = Min(min_value, e);
    cout << 5 + Ceil(n, min_value) - 1 << endl;
    return 0;
}



Measured memory_bytes: 3580
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> PA;
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
queue<PA> que;
int main(){
  int n,ans;
  char m[13][13];
  
  while(cin >> m[0]){
    
    for(int j = 0;j < 12;j++){
      if(j==0) continue;
      cin >> m[j];
    }
    ans = 0;
    for(int j = 0;j < 12;j++){
      for(int k = 0;k < 12;k++){
	if(m[j][k] == '1'){
	  que.push(PA(j,k));
	  while(!que.empty()){
	    PA p=que.front();que.pop();
	    m[p.first][p.second] = '0';
	    for(int l = 0;l < 4;l++){
	      int y = p.first+dy[l];
	      int x = p.second+dx[l];
	      if(x<0||y<0||x>=12||y>=12||m[y][x]=='0') continue;
	      que.push( PA(y,x) );
	    }
	  }
	  ans++;
	}
      }
    }
    cout << ans << endl;
  }
  return (0);
}

Measured memory_bytes: 8768
N, M, C = map(int, input().split())
B = list(map(int, input().split()))

ans = 0
for i in range(N):
    A = list(map(int, input().split()))
    total = C
    for j in range(M):
        total += A[j]*B[j];
    if total > 0:
        ans += 1

print(ans)

Measured memory_bytes: 3064
// Problem : B - Judge Status Summary
// Contest : AtCoder - AtCoder Beginner Contest 173
// URL : https://atcoder.jp/contests/abc173/tasks/abc173_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#define DEBUG fprintf(stderr, "Passing [%s] line %d\n", __FUNCTION__, __LINE__)
#define File(x) freopen(x".in","r",stdin); freopen(x".out","w",stdout)

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef pair <int, int> PII;
typedef pair <int, PII> PIII;

inline int gi()
{
    int f = 1, x = 0; char c = getchar();
    while (c < '0' || c > '9') {if (c == '-') f = -1; c = getchar();}
    while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
    return f * x;
}

inline LL gl()
{
    LL f = 1, x = 0; char c = getchar();
    while (c < '0' || c > '9') {if (c == '-') f = -1; c = getchar();}
    while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
    return f * x;
}

const int INF = 0x3f3f3f3f, N = 100003, M = N << 1;

int n, m;
int ton[5];

int main()
{
    //File("");
    n = gi();
    for (int i = 1; i <= n; i+=1)
    {
    	string s;
    	cin >> s;
    	char x = s[0];
    	if (x == 'A') ++ton[0];
    	else if (x == 'W') ++ton[1];
    	else if (x == 'T') ++ton[2];
    	else ++ton[3];
    }
    printf("AC x %d\nWA x %d\nTLE x %d\nRE x %d\n", ton[0], ton[1], ton[2], ton[3]);
    return 0;
}

Measured memory_bytes: 3724
#include<bits/stdc++.h>
using namespace std;
int main()
{
vector<int> h(3);
  for(int i=0;i<3;++i)
  {
  cin >> h.at(i);
  }  
  sort(h.begin(),h.end());
  cout << h.at(0)+h.at(1)+h.at(2)*10;
return 0;
}

Measured memory_bytes: 3592
//
//東京海上日動　プログラミングコンテスト2020
//A - Nickname
//

#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <ctime>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <functional>
#include <cassert>

using namespace std;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define SIZE(x) (int)(x).size()
#define SIZEL(x) (ll)(x).size()
#define MSG(a) cout << #a << " " << a << endl;

using ll = long long;
using ld = long double;

const double PI = 3.14159265358979323846;

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

int main()
{
    string s;
    cin >> s;
    cout << s.substr(0,3) << endl;
    return 0;
}


Measured memory_bytes: 3592
#include<bits/stdc++.h>
    #include<algorithm>
    using namespace std;
    #define mod 1e9+7
    #define FOR(a,c)   for ( long long int (a)=0; (a)<(c); (a)++)
    #define FORL(a,b,c)  for ( long long int (a)=(b); (a)<=(c); (a)++)
    #define FORR(a,b,c)  for (  long long int (a)=(b); (a)>=(c); (a)--)
    #define INF 1000000000000000003
    typedef long long int ll;
    typedef vector<long long int> vi;
    typedef pair<long long int,long long int> pi;
    typedef priority_queue<long long int> max_pq;
    typedef priority_queue<long long int, vector<long long int>, greater<long long int>> min_pq;
    #define F first
    #define S second
    #define PB push_back
    #define POB pop_back
    #define MP make_pair
    #define pi 3.1415926535
    #define buff cin.ignore(numeric_limits<streamsize>::max(),'\n')

    // Use inbuilt function  __gcd(a,b), __builtin_popcount(n), Use (x&-x) for last set Bit;

    void dfs(ll node, vector<ll> v[], ll *dp, bool vis[])
    {
        vis[node]=true;
        for(ll i=0;i<v[node].size();i++)
        {
            if(!vis[v[node][i]])
                dfs(v[node][i],v,dp,vis);
            dp[node]=max(dp[node],1+dp[v[node][i]]);
        }
    }

    
    int main()
    {
        ios::sync_with_stdio(NULL);
        cin.tie(NULL);
        cout.tie(NULL);

        ll n,m,x,y;
        cin>>n>>m;
        vector<ll> v[n+5];
        FOR(i,m)
        {
            cin>>x>>y;
            v[x].PB(y);
        }
        ll dp[n+1];
        memset(dp,0,sizeof(dp));
        bool vis[n+1];
        memset(vis,false,sizeof(vis));

        for(ll i=1;i<=n;i++)
        {
            if(!vis[i])
                dfs(i,v,dp,vis);
        }

        ll ans=0;
        for(ll i=1;i<=n;i++)
            ans=max(ans,dp[i]);
        cout<<ans<<endl;

        return 0;
    }

Measured memory_bytes: 9984
import sys
# sys.setrecursionlimit(10**6)
input = sys.stdin.buffer.readline
# arr = [[int(el) for el in input().split()] for i in range(n)]

def cal(x):

    bl = 100
    c = 0

    while bl < x:
        c += 1
        bl = int(bl * 1.01)

    return c


x = int(input())

print (cal(x))

Measured memory_bytes: 63396
#include <iostream>
#include <map>
#include <algorithm>
#include <string>
#include <vector> 
#include <numeric>
#include <cmath>
#include <queue>
#include <iomanip>
#include <functional>


#define CHMAX(a,b) a = std::max(a,b)
#define CHMIN(a,b) a = std::min(a,b)
#define MAXMIN(a,b,c) std::max(a,min(b,c))
#define CHABS(a) a = std::abs(a) 
#define COUT(a) std::cout << a << std::endl
#define CERR(a) std::cerr << a << std::endl
#define FOR(n) for(lli i = 0; i < n; i++)

using namespace std;
using lli = long long int;
using pll = pair<lli, lli>;
using tlll = tuple<lli, lli, lli>;
using vll = vector<lli>;

lli mod197 = 1000000007LL;
lli INF = 10000000000000;

// ax + by = gcd(a,b) 最大公約数
template< typename T >
T extgcd(T a, T b, T& x, T& y) {
	T d = a;
	if (b != 0) {
		d = extgcd(b, a % b, y, x);
		y -= (a / b) * x;
	}
	else {
		x = 1;
		y = 0;
	}
	return d;
}

int main(void) {

	lli n, k;
	cin >> n >> k;
	int count = 0;
	while (n != 0) {
		count++;
		n /= k;
	}

	cout << count << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
#define PI 3.14159265
using namespace std;


int main()
{
    int a,b;
    double x;
    cin >> a >> b >> x;
    cout.precision(10);
    if (x <= a*a*b/2)
    {
        cout << atan((a*b*b/x)/2)*180.0/PI;
    }
    else
    {
        cout << atan(2*(a*a*b-x)/(a*a*a))*180.0/PI;
    }
    return 0;
}


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

using namespace std;

template<typename T>
ostream& operator<<(ostream& os, vector<T> v) {
  os << "[";
  for (T &i: v) os << i << ",";
  os << "]";
  return os;
}

template<class TH> void _dbg(const char *sdbg, TH h){ cout<<sdbg<<'='<<h<<endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cout<<*sdbg++;
  cout<<'='<<h<<','; _dbg(sdbg+1, a...);
}

#ifdef __DJKIM613
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) (__VA_ARGS__)
#endif

string S;
int main(void){
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr), cout.tie(nullptr);

  cin >> S;

  int cnt = 0;
  for(int i = 0 ; i < S.length() ; i++) if(S[i] =='o') cnt++;

  if(cnt + (15 - S.length()) >= 8) cout << "YES\n";
  else cout << "NO\n";

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
#define ll long long
#define endl "\n"
#define fastio ios::sync_with_stdio(0), cin.tie(0);
using namespace std;
ll ans = 1;
vector<ll> arr;
int main()
{
    int n;
    cin >> n;
    arr.resize(n);
    for (int i = 0; i < n; i++)
    {
        cin >> arr[i];
        if (arr[i] == 0)
        {
            cout << 0;
            return 0;
        }
    }
    for (int i = 0; i < n; i++)
    {
        if (1000000000000000000ll / ans < arr[i])
        {
            cout << -1;
            return 0;
        }

        ans *= arr[i];
    }
    cout << ans;
}


Measured memory_bytes: 4000
#![allow(non_snake_case, unused)]
use std::cmp::*;
use std::collections::*;
use std::f64::consts::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        mut a: [[usize1; n-1]; n],
    }

    let mut cnt = vec![0; n];
    let mut m_cnt = 0;
    while m_cnt != n * (n - 1) / 2 {
        let mut no_fight = true;

        for i in 0..n {
            if a[i].is_empty() {
                continue;
            }
            let p_a = *a[i].last().unwrap();
            if a[p_a].is_empty() {
                return println!("-1");
            }

            if *a[p_a].last().unwrap() == i {
                m_cnt += 1;
                no_fight = false;
                let acc = max(cnt[i] + 1, cnt[p_a] + 1);
                cnt[i] = acc;
                cnt[p_a] = acc;
                a[i].pop();
                a[p_a].pop();
            }
        }

        if no_fight {
            return println!("-1");
        }
    }
    println!("{}", cnt.iter().max().unwrap());
}


Measured memory_bytes: 12540
#include<bits/stdc++.h>
#define LL long long
#define REP(i, n) for(int i=0;i<(n);++i)
#define REPA(i, n) for(int i=1;i<(n);++i)
#define lp(i, n) for(int i=-;i<(n);++i)
#define PII pair<int, int>
#define PLL pair<long long, long long>
#define MOD ((int)1e9 + 7)
#define INF ((int)1e9)
#define DEKAI ((int)1e9+7)
#define ALL(x) (x).begin(), (x).end()
#define BIT(x) (1<<(x))
#define foreach(i, n) for(auto &i:(n))
using namespace std;

int main(){
    int ans=0;
    vector<int> line(1, 0);
    int N;
    cin >> N;
    REP(i, N){
        int d;
        cin >> d;
        if(line.back() < d){
            line.push_back(d);
            ++ans;
        }else{
            while(line.back() > d)line.pop_back();
            if(line.back()!=d){
                line.push_back(d);
                ++ans;
            }
        }
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3912
#include<bits/stdc++.h>
using namespace std;
#define inf 1000000000
#define INF 1000000000000000
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
#define IN(a,n) rep(i,n){ cin>>a[i]; }
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
#define vi vector<int>

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

  int n;
  cin>>n;

  vector<int> v(n);
  rep(i,n){
    cin>>v[i];
  }

  map<int,int> mp;
  rep(i,n){
    mp[v[i]]++;
  }

  vector<P> a;
  for(auto m:mp){
    a.PB(m);
  }

  /*
  cout<<a[0].F<<a[1].F<<a[2].F<<endl;
  cout<<(a[0].F^a[1].F)<<endl;
  */

  if(n%3==0&&a.size()==3&&(a[0].F^a[1].F)==a[2].F&&a[0].S==n/3&&a[1].S==n/3&&a[2].S==n/3){
    cout<<"Yes"<<endl;
  }else if(a.size()==1&&a[0].F==0){
    cout<<"Yes"<<endl;
  }else if(a.size()==2&&n%3==0&&a[0].F==0&&a[0].S==n/3){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }

}


Measured memory_bytes: 7924
def main():
    n, k = map(int, input().split())
    LRs = [list(map(int, input().split())) for _ in range(k)]
    dp = [0, 1] + [0] * n

    for i in range(2, n+1):
        dp[i] = dp[i-1]
        for l, r in LRs:
            dp[i] += dp[max(i-l, 0)] - dp[max(i-r-1, 0)]
            dp[i] %= 998244353

    print((dp[n]-dp[n-1]) % 998244353)


if __name__ == '__main__':
    main()


Measured memory_bytes: 70760
(defun main ()
  (let ((a (make-array 0 :element-type 'integer
                         :adjustable t
                         :fill-pointer 0)))
    (dotimes (i 3)
      (vector-push-extend (read) a))
    (setf a (sort a #'<))
    (format t "~A~%" (+ (if (oddp (- (aref a 1) (aref a 0))) 2 0) (floor (- (aref a 1) (aref a 0)) 2) (- (aref a 2) (aref a 1))))))

(main)



Measured memory_bytes: 24388
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int M = 2e5+10;
char s[M];
int main(){
    while(scanf("%s",s)!=EOF){
        ll ans = 1,len=strlen(s);
        sort(s,s+len);
        for(ll i=0,t;i<len;i=t){
            t=upper_bound(s+i+1,s+len,s[i])-s;
            if(t==len) break;
            ans+=(t-i)*(len-t);
        }
        cout<<ans<<endl;
    }
    return 0;
}

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

int main(){
    int n;
    cin >> n;
    vector<int> c(100000);
    rep(i, n){
        int a;
        cin >> a;
        c[a - 1] ++;
    }
    int ans = 0;
    int res = 0;
    rep(i, 100000){
        if (c[i]) ans++;
        if (c[i] && c[i] % 2 == 0) res++;
    }
    if (res % 2 != 0) ans--;
    cout << ans << endl;
}

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

int g[15][15];

int main() {
  int n;
  cin >> n;
  rep(i, n) rep(j, n) g[i][j] = -1;
  rep(i, n) {
    int m;
    cin >> m;
    rep(j, m) {
      int a, x;
      cin >> a >> x;
      --a;
      g[i][a] = x;
    }
  }

  int ans = 0;
  rep(i, 1 << n) {
    vector<int> d(n);
    rep(j, n) if (i >> j & 1) d[j] = 1;
    bool ok = true;

    rep(j, n) {
      if (d[j]) {
        rep(k, n) {
          if (g[j][k] == -1) continue;
          if (g[j][k] != d[k]) ok = false;
        }
      }
    }
    if (ok) ans = max(ans, (int)bitset<32>(i).count());
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		int[] t=new int[10];
		int B=0;
		int C=0;

		for(int i=1; i<=n; i++){
			for(int j=0;j<10; j++){
				t[j]=sc.nextInt();

			}

			System.out.println(solve(t));
		}
	}
	public static String solve(int[] t															){
		int B=0;
		int C=0;
		for(int i=0; i<10; i++){
			if(t[i]>B){
				B=t[i];
			}else if(t[i]>C){
				C=t[i];
			}else{

				return "NO";


			}
		}
		return "YES";
	}


}



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

using ll = long long int;
using P = std::pair<int, int>;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rag(con) std::begin(con), std::end(con)

constexpr ll mod = 1e9 + 7;

ll pow(ll x, ll m)
{

    ll re = 1, y = 1;

    for (int i = 0; i < 60; ++i)
    {
        if (m & y)
            re = re * x % mod;
        x = x * x % mod;
        y *= 2;
    }

    return re;
}

ll inv(ll x)
{

    return pow(x, mod - 2);
}

class mint
{
    ll num = 0;

public:
    mint(ll x = 0) : num(x) {}

    mint operator+(const mint &rhs) const
    {
        return (num + rhs.num) % mod;
    }
    mint operator*(const mint &rhs) const
    {
        return num * rhs.num % mod;
    }
    mint operator-(const mint &rhs) const
    {
        return (num - rhs.num + mod) % mod;
    }
    mint operator/(const mint &rhs) const
    {
        return num * inv(rhs.num) % mod;
    }
    mint operator+=(const mint &rhs)
    {
        return *this = *this + rhs;
    }
    mint operator*=(const mint &rhs)
    {
        return *this = *this * rhs;
    }
    mint operator-=(const mint &rhs)
    {
        return *this = *this - rhs;
    }
    mint operator/=(const mint &rhs)
    {
        return *this = *this / rhs;
    }
    friend std::ostream &operator<<(std::ostream &os, const mint &rhs);
};

std::ostream &operator<<(std::ostream &os, const mint &rhs)
{

    os << rhs.num;

    return os;
}

int main()
{
    int n;

    std::cin >> n;

    mint p8 = 1, p9 = 1, p10 = 1;

    rep(i, n)
    {
        p8 *= 8;
        p9 *= 9;
        p10 *= 10;
    }

    std::cout << (p10 + p8 - p9 * 2) << std::endl;

    return 0;
}

Measured memory_bytes: 3620
#include <iostream>

using namespace std;

#define FOR(i, a, b) for (int i = a; i < b; i++)
#define REP(i, n) for (int i = 0; i < n; i++)

int main() {
  int T, X;
  cin >> T >> X;

  cout << (double)T / X << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
using str = string;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
const double PI = 3.141592653589793238;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define REP(i, m, n) for (int i = m; i < (int)n; i++)
#define all(a) (a).begin(), (a).end()
#define allg(a) (a).begin(), (a).end(), greator<>()
#define d20 std::setprecision(20)
#define veci vector<int>
#define vecll vector<long long int>
#define vecb vector<bool>
#define vecd vector<double>
template <typename T>
T lcm(T a, T b)
{
	return a / __gcd(a, b) * b;
}
void comb(vector<vector<long long int>> &v)
{
	for (size_t i = 0; i < v.size(); i++)
	{
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (size_t k = 1; k < v.size(); k++)
	{
		for (size_t j = 1; j < k; j++)
		{
			v[k][j] = (v[k - 1][j - 1] + v[k - 1][j]);
		}
	}
}
ll repeat_squaring(ll n, ll p, ll m)
{
	if (p == 0)
		return 1;
	if (p % 2 == 0)
	{
		ll t = repeat_squaring(n, p / 2, m);
		return t * t % m;
	}
	return n * repeat_squaring(n, p - 1, m);
}

int main()
{
	int n, k;
	cin >> n >> k;
	str s;
	cin >> s;
	k--;
	for (size_t i = 0; i < s.size(); i++)
	{
		if (i == k)
			cout << (char)(s[i] + 0x20);
		else
			cout << s[i];
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>

using namespace std;

inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v;}
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str();}

typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EACH(t,i,c) for(t::iretator i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

const double EPS = 1e-10;

int main() {
	int n;

	while(cin >> n, n) {
		int num = 0;
		
		FOR(i, 1, n/2+1) {
			int sum = 0;
			int j = i;
			int m = 0;
			
			while(sum < n) {
				sum += j;
				j++;
				m++;
			}
			if((sum == n) && (m > 1)) {
				num++;
			}
		}

		cout << num << endl;
	}
}

Measured memory_bytes: 0
from itertools import permutations

N, M = map(int, input().split())

path_matrix = [[0]*N for _ in range(N)]
for _ in range(M):
    a, b = map(int, input().split())
    path_matrix[a-1][b-1] = 1
    path_matrix[b-1][a-1] = 1

cnt = 0
for each in permutations(range(N)):
    if each[0] != 0:
        break

    factor = 1
    for i in range(N-1):
        factor *= path_matrix[each[i]][each[i+1]]
    cnt += factor

print(cnt)

Measured memory_bytes: 3064
N = int(input())
X = list(map(int,input().split()))
T = 0
for i in range(N):
	T += X[i]
Square_Total = 0
for i in range(N):
	Square_Total += X[i]**2
K = int(N-2*T)
for i in range(100):
	K = min(N*(i**2)-2*T*int(i),K)
print(Square_Total+K)

Measured memory_bytes: 3064