akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
int num[27];char c[300100];
long long ans=0;
int main()
{
	scanf("%s",c+1);int n=strlen(c+1);
	for(int i=n;i>=1;i--)ans+=(n-i)-num[c[i]-'a']++;
	printf("%lld",ans+1);return 0;
 } 

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define int long long
#define FOR(i, m, n) for(int i = m;i < n;i++)
typedef vector<int> VI;
typedef vector<VI> VVI;
const int MOD=1000000007;
const long long INF = 1LL << 60;
//----------------------------------------------
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
int g(int x, int c, int d){
    int num = x;
    num -= x / c;
    num -= x / d;
    num += x / lcm(c,d);
    return num;
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int a,b,c,d; cin >> a >> b >> c >> d;
    int ans = g(b,c,d) - g(a - 1,c,d);
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = ((int)(n)-1); i >= 0; i--)
#define all(x) (x).begin(),(x).end()
 
using namespace std;
using ll = long long;
 
struct edge { int to, cost; };
 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> P;
 
const int INF = 1e9;
const int MOD = 1e9+7;
const double EPS = 1.0e-10;
const double PI = acos(-1.0);
 
const int mx4[] = {0,1,0,-1};
const int my4[] = {1,0,-1,0};
const int mx8[] = {0,1,1,1,0,-1,-1,-1};
const int my8[] = {1,1,0,-1,-1,-1,0,1};

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

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		int K = scan.nextInt();
		int X = scan.nextInt();
		int Y = scan.nextInt();
		
		int Hi = N - K;
		int Yen;
		
		if (Hi > 0){
			Yen = K * X;
			Yen = Yen + (Hi * Y);
			System.out.println(Yen);
		}
		else{
			Yen = N * X;
			System.out.println(Yen);
		}
		scan.close();
	}
}


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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
//const ull mod = 1e9 + 7;
const ll mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

// debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

// conversion number to bit
string num2bit(ll num, ll len){
  string bit = "";
  REP(i, len){
    bit += char('0'+(num>>i & 1));
  }
  return bit;
}

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

    string x;
    cin >> x;
    REP(i, x.size()) cout << 'x';
    cout << endl;
    return 0;
}

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

bool balance(int x, int y){
    return ((x >= 0) && (y >= 0)) || ((x <  0) && (y <  0));
}

bool isminus(int x){ return x < 0;}
bool isplus(int x){ return x >= 0;}

int solve(int x, int y, int step){
    if(x == y) return step;
    if(isplus(x) && isplus(y)){ // + && +
        if(x > y) return solve(-x, y, step+1);
        if(x < y) return solve(x+(y-x), y, step+(y-x));
    } else if(isplus(x) && isminus(y)){ // + && -
        if(x >= abs(y)) return solve(-x, y, step+1);
        return solve(x+(abs(y)-x), y, step+(abs(y)-x));
    } else if(isminus(x) && isplus(y)){ // - && +
        if(abs(x) > y) return solve(x+(abs(x)-y), y, step+(abs(x)-y));
        return solve(-x, y, step+1);
    } else if(isminus(x) && isminus(y)){
        if(x < y) return solve(x+(y-x), y, step+(y-x));
        if(x > y) return solve(-x, y, step+1);
    }
}

int main() {
    int x, y, ans;
    cin >> x >> y;
    cout << solve(x,y,0) << endl;
}



Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int a, b, c, i, count = 0;
  scanf("%d %d %d", &a, &b, &c);
  for(i = a; i <= b; i++){
    if(c % i == 0)
      count++;
  }

  printf("%d\n", count);
  return 0;
}



Measured memory_bytes: 2148
#include<iostream>
#include<iomanip>
#include<string>
#include<array>
#include<cmath>
#include<vector>
#include<utility>
#include<algorithm>
#include<ctype.h>
using namespace std;


int main() {
	string s;
	cin >> s;
	for (int i = 0; i < s.size();i++) {
		s[i] = 'x';
	}
	cout << s << endl;
}

Measured memory_bytes: 256
a = list(map(int,input().split()))
one = a[0]
zero = a[1]
mone = a[2]
num = a[3]
 
ans = 0
if one >= num:
    print(num)
else:
    ans += one
    num -= one
    if zero >= num:
        print(ans)
    else:
        num -= zero
        print(one - num)

Measured memory_bytes: 9116
from functools import reduce

def gcd(x,y):
    while y: x,y = y,x%y
    return x

def lcm(x,y):
    return x//gcd(x,y)*y

def ex_euclid(x,y):
    c0,c1 = x,y
    a0,a1 = 1,0
    b0,b1 = 0,1
    while c1:
        a0,a1 = a1,a0-c0//c1*a1
        b0,b1 = b1,b0-c0//c1*b1
        c0,c1 = c1,c0%c1
    return c0,a0,b0

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

if N == 1:
    a = A[0]
    print((M-a//2%a)//a+1)

else:
    LCM = reduce(lcm,A)

    SCMs = []
    flag = True

    for i in range(N-1):
        c,a,b = ex_euclid(A[i],-A[i+1])
        if (A[i+1]-A[i])//2%c == 0:
            SCMs.append(A[i]*((A[i+1]-A[i])//2//c)*a+A[i]//2)
        else:
            flag = False
            break

    print((M-reduce(lcm,SCMs)%LCM)//LCM+1 if flag else 0)

Measured memory_bytes: 14864
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;


//      DEEP

using namespace std;
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define all(v) v.begin(),v.end()
#define pb push_back
#define endl '\n'
#define mp make_pair

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef pair<int,int> pi;
typedef pair<long long,long long> pll;
typedef set<int> si;


/*
typedef tree<int,null_type,less<int>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set;
*/
/*
typedef tree<
pair<int, int>,
null_type,
less<pair<int, int>>,
rb_tree_tag,
tree_order_statistics_node_update> ordered_set;
*/

const ll mod = 1e9 + 7;
const ll modl=998244353;
const double pie=3.1415926535;
                                                    //power
ull power(ull x,ull y){
   if(y==0) return 1;
   else{
     if(y%2==0) return power(x*x,y/2);
     else return x*power(x*x,(y-1)/2);
   }
}

                        //                    Modular Exponentiation

ll mod_power(ll x, ll y, ll m)
{
    ll r = 1;     // Initialize result

    x = x % m; // Update x if it is more than or equal to m

    if (x == 0) return 0; // In case x is divisible by m;

    while (y > 0)
    {
        // If y is odd, multiply x with result
        if (y & 1)
            r = (r*x) % m;

        // y must be even now
        y = y/2;
        x = (x*x) % m;
    }
    return r;
}

                                                      //GCD
ll gcd(ll x,ll y){
   if(y==0)return x;
   return gcd(y,x%y);
}
                                              // SIEVE

/*
bool isPrime[100001];
void sieve(int N) {

        for(int i = 0; i <= N;++i) {
            isPrime[i]=true;
        }
        isPrime[0]=false;
        isPrime[1]=false;

        for(int i = 2; i * i <= N; ++i) {
             if(isPrime[i] == true) {
                 for(int j = i * i; j <= N ;j += i)
                     isPrime[j] = false;
            }
        }
    }
*/

int main(){
    boost;
    int TESTS=1;
    //cin>>TESTS;
    while(TESTS--){
        string s;
        cin>>s;
        for(char i : s)cout<<'x';
          cout<<endl;
      }
}















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


typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef long double ld;

typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
const int MAXN = 1e6 + 3;

#define _  %  MOD
#define __ %= MOD

#define      each(it,s)        for(auto it = s.begin(); it != s.end(); ++it)
#define      sortA(v)          sort(v.begin(), v.end())
#define      sortD(v)          sort(v.begin(), v.end(), greater<auto>())
#define      fill(a)           memset(a, 0, sizeof (a))

#define      swap(a,b)        {a=a+b;b=a-b;a=a-b;}
#define      rep(i, n)         for(int i = 0; i < (n); ++i)
#define      repA(i, a, n)     for(int i = a; i <= (n); ++i)
#define      repD(i, a, n)     for(int i = a; i >= (n); --i)
#define watch(x) cout << (#x) << " is " << (x) <<endl

#define fi first
#define se second
#define mp make_pair
#define pb push_back

#define fbo find_by_order
#define ook order_of_key

ll gcd(ll a,ll b){if(b==0) return a; else return gcd(b,a%b);}
ll power(ll x,ll y){ll res=1; while(y>0){if(y&1) res=res*x;y=y>>1;x=x*x;}return res;} // modular exponent

int main()
{
    ios_base::sync_with_stdio(false); // don't use printf and scanf
    cin.tie(NULL); // cout<<fixed<<setprecision
    ll n,w;
    cin>>n>>w;
    ll wt[n+1],v[n+1];
    repA(i,1,n) cin>>wt[i]>>v[i];
    ll dp[n+1][w+1];
    fill(dp);
    for(ll i=1;i<=n;i++)
    {
        for(ll j=1;j<=w;j++)
        {
            if(wt[i]<=j) dp[i][j]=max(dp[i-1][j-wt[i]]+v[i],dp[i-1][j]);
            else dp[i][j]=dp[i-1][j];
        }
    }
    cout<<dp[n][w]<<'\n';
    return 0;
}


Measured memory_bytes: 79232
def main():
    n, m = map(int, input().split())
    x = list(map(int, input().split()))

    if n >= m:
        print(0)
        return


    x.sort()
    x1 = x[1:]
    x2 = x[:-1]
    xs = [_x1 - _x2 for _x1, _x2 in zip(x1, x2)]


    argxs = sorted(enumerate(xs), key=lambda y: y[1])

    a = []
    for i in range(1, n):
        a.append(argxs[-i][0])
    
    tmp = 0
    ans = 0

    for _a in a:
        ans += x[_a] - x[tmp]
        tmp = _a + 1
    ans += x[-1] - x[tmp]
    print(ans)


if __name__ == '__main__':
    main()
    


Measured memory_bytes: 20688
#include <iostream>

using namespace std;

int main() {
  int a, b;
  cin >> a >> b;
  for (int i=1; i<=10000; i++) {
    if ((int)(i * 0.08) == a && (int)(i * 0.1) == b) {
      cout << i << endl;
      return 0;
    }
  }
  cout << -1 << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
int main()
{
    int n,k;
    std::cin >> n >> k;
    int p[n];

    for (int i = 0; i < n; i++)
        std::cin >> p[i];
        std::sort(p,p+n);
        int ans=0;

    for (int i = 0; i < k; i++)
        ans+=p[i];
        std::cout << ans << std::endl;
}
    

Measured memory_bytes: 3640
#include "bits/stdc++.h"
#define double long double
#define int long long
#define mii map<int,int>
#define low lower_bound
#define upp upper_bound
#define inf 1000000007 //10^9+7
#define rep(i,n) for(int i=0;i<n;i++)
#define all(vec) vec.begin(),vec.end()
#define sort(vec) sort(all(vec));
#define rever(vec) reverse(all(vec));
#define unsort(vec) sort(vec); rever(vec);
#define bisea binary_search
#define cend cout<<endl;
#define F first
#define S second
using namespace std;
signed main() {
  int n,m;
  cin>>n>>m;
  int p[m],y[m];
  vector<int>vec[n+1];
  unordered_map<int,int>mp;
  rep(i,m) {
    cin>>p[i]>>y[i];
    mp[y[i]]=p[i];
    vec[p[i]].push_back(y[i]);
  }
  rep(i,n) {
    sort(vec[i+1]);
  }
  rep(i,m) {
    printf("%06Ld",mp[y[i]]);
    printf("%06Ld\n",low(all(vec[p[i]]),y[i])-vec[p[i]].begin()+1);
  }
}


Measured memory_bytes: 12580
#pragma optimization_level 3
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
#include<bits/stdc++.h>
#define F first
#define S second
#define vec vector
#define ms multiset
#define pb push_back
#define pll pair<ll,ll>
#define pdd pair<ld, ld>
#define pq priority_queue
#define umap unordered_map
#define uset unordered_set
#define pii pair<int, int>
#define pnn pair<Node*, Node*>
#define uid uniform_int_distribution
#define FILE ifstream in("input.txt");ofstream out("output.txt");
#define fast cin.tie(0);cout.tie(0);cin.sync_with_stdio(0);cout.sync_with_stdio(0);
using namespace std;
typedef string str;
typedef long long ll;
typedef long double ld;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count()); //uid<int> u1(5, 10); u1(rnd);

int main(){
    fast;
    int a; cin>>a;
    vec<ld> m(a);
    for(int q=0; q<a; q++) cin>>m[q];
    ld x = 0;
    for(ld i : m) x+=1.0/i;
    cout.precision(12);
    cout<<fixed;
    cout<<1.0/x;
}

Measured memory_bytes: 256
fn main() {
    proconio::input! {
        n: usize,
        k: usize,
    }
    let mut c = vec![0;n];
    for _ in 0..k {
        proconio::input! {
            d: usize,
            a: [proconio::marker::Usize1; d],
        }
        for a in a {
            c[a]+=1;
        }
    }
    println!("{}",c.into_iter().filter(|&c|c==0).count());
}

Measured memory_bytes: 2176
while True:
    l = input().split()

    a = int(l[0])
    op = l[1]
    b = int(l[2])

    if op == '?':
        break

    if op == '+':
        print("%d"%(a+b))
    elif op == '-':
        print("%d"%(a-b))
    elif op == '/':
        print("%d"%(a/b))
    else:
        print("%d"%(a*b))



Measured memory_bytes: 5592
#create date: 2020-07-20 13:34

import sys
stdin = sys.stdin

def ns(): return stdin.readline().rstrip()
def ni(): return int(ns())
def na(): return list(map(int, stdin.readline().split()))

def main():
    n = ni()
    p = na()
    ans = 0
    for i in range(1, n-1):
        a = p[i-1:i+2]
        if p[i] != max(a) and p[i] != min(a):
            ans += 1
    print(ans)
    
if __name__ == "__main__":
    main()

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

int main() {
  string s;
  cin >> s;
  sort(s.begin(), s.end());
  if(s.at(0) == s.at(1) && s.at(2) == s.at(3) && s.at(2) != s.at(1))
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Measured memory_bytes: 256
import sys


def input():
    return sys.stdin.readline()[:-1]

# N = int(input())
# A = [int(x) for x in input().split()]
# a, b, c = map(int, input().split())
# name1 = str(input())
# alph = {"A": 1, "B": 2, "C": 3, "D": 4, "E": 5}

a,b,c=map(int,input().split())
if b//a >=c:
    print(c)
else:
    print(b//a)


Measured memory_bytes: 2940
#include <iostream>
#include <vector>
#include <math.h>
#include <algorithm>

using namespace std;

int main(){
	int N;
	cin >> N;
	
	char* P = (char*)calloc(N+1, sizeof(char));
	char* Q = (char*)calloc(N+1, sizeof(char));
	int p, q;
	for(int i = 0; i < N; i++){
		cin >> P[i];
	}
	p = atoi(P);
	for(int i = 0; i < N; i++){
		cin >> Q[i];
	}
	q = atoi(Q);
	
	vector<int> a(N);
	vector<int> nums;//順列が入る
	for(int i = 0; i < N; i++) a.at(i) = i+1;
	/*順列を生成には、next_permutationを使えばよい*/
	do{
		char* num_c = (char*)calloc(N+1, sizeof(char));
		for(int i = 0; i < N; i++){
			num_c[i] = a.at(i) + 48;
		}
		nums.push_back(atoi(num_c));
	}while(next_permutation(a.begin(), a.end()));
	
	
	int a_num=0, b_num=0;
	for(int i = 0; i < nums.size(); i++){
		if(nums.at(i) == p) a_num = i;
		if(nums.at(i) == q) b_num = i;
	}
	cout << abs(a_num-b_num) << endl;
	
}


Measured memory_bytes: 4832
#include <bits/stdc++.h>
#include <fstream>
#include <vector>
#include <bitset>
#include <unordered_map>
#include <algorithm>
#include <queue>
#include <math.h>
#include <iomanip>

using namespace std;

/********** TEMPLATE STARTS HERE ***********/

#define IOS ios::sync_with_stdio(false), cin.tie(0);
#define all(v) v.begin(), v.end()
#define F first
#define S second
#define pb push_back
#define PI 3.1415926535897932384626433832795
#define gcd __gcd 
#define digits(n) (int)(log10(n) + 1)

typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector <int> vi;
typedef vector <long long> vl;
typedef vector <pll> vll;
typedef vector <pii> vii;

const int INF = 0x3f3f3f3f;
const int LINF = 0x3f3f3f3f3f3f3f3f;

template <typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template <typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }

/********** TEMPLATE ENDS HERE ***********/

int v[200];

main()
{
	IOS
	
	int n, m, x;
	cin >> n >> m >> x;
	
	x++;
	
	for(int i = 1; i <= m; i++)
	{
		int e;
		cin >> e;
		
		v[e + 1] = 1;
	}
	
	for(int i = 2; i < x; i++)
		v[i] += v[i - 1];
	
	for(int i = n; i > x; i--)
		v[i] += v[i + 1];
	
	cout << min(v[x - 1], v[x + 1]);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
    ll n,k;
    cin>>n>>k;
    ll a[n];
    for(ll i=0;i<n;i++){
        cin>>a[i];
    }
    ll dp[n];
    dp[0] = 0;
    dp[1] = abs(a[1] - a[0]);
    for(ll i=2;i<n;i++){
        dp[i] = INT_MAX;
        for(ll j = i-1;j>=0 && i-j <= k ;j--){
            dp[i] = min(dp[i],abs(a[i]-a[j]) + dp[j]);
        }
    }  
    cout<<dp[n-1]<<endl;
    return 0;
}

Measured memory_bytes: 5172
#include <bits/stdc++.h>
using namespace std;
int main(){
  int A,B,C,D,E,F;
  cin >>A>>B>>C>>D>>E>>F;
  vector<double> W,S;
  for(int i=0; i<=F/A; i++){
    for(int j=0; j<=(F-i*A)/B; j++){
      int x=(i*A+j*B)*100;
      if(x>F) break;
      W.push_back(x);
    }
  }
  int z=F*E/(100+E);
  for(int i=0; i<=z/C; i++){
    for(int j=0; j<=(z-i*C)/D; j++){
      int x=i*C+j*D;
      if(x>z) break;
      S.push_back(x);
    }
  }
  sort(W.begin(), W.end());
  sort(S.begin(), S.end());
  for(int i=0; i<W.size()-1; i++){
    if(W[i]==W[i+1]){
      W.erase(W.begin()+i);
      i--;
    }
  }
  for(int i=0; i<S.size()-1; i++){
    if(S[i]==S[i+1]){
      S.erase(S.begin()+i);
      i--;
    }
  }
  double per=0;
  int ans1=W[1], ans2=0;
  for(int i=1; i<W.size(); i++){
    for(int j=1; j<S.size(); j++){
      if(W[i]+S[j]>F) break;
      if(S[j]>E*W[i]/100) break;
      double c=S[j]*100/(W[i]+S[j]);
      if(per<c) per=c, ans1=W[i]+S[j], ans2=S[j];      
    }
  }
  cout <<ans1 <<" " <<ans2 <<endl;
}


Measured memory_bytes: 892
def selectionSort(A,N):
  
    count = 0
    for i in range(N):
        
        minj = i
        
        for j in range(i,N,1):
           
            if A[j] < A[minj]:
                minj = j
                
        
        if minj != i:
            count = count + 1
            tmp = A[i]
            A[i] = A[minj]
            A[minj] = tmp
    print(' '.join(map(str,A)))
    print(count)
    
N = int(input())
A = input()
A = list(map(int,A.split()))   
selectionSort(A,N)


Measured memory_bytes: 5600
import java.util.*;

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

		int[][] red = new int[n][2];
		int[][] blue = new int[n][2];
		for (int i = 0; i < n; i++) {
			red[i][0] = sc.nextInt();
			red[i][1] = sc.nextInt();
		}
		for (int i = 0; i < n; i++) {
			blue[i][0] = sc.nextInt();
			blue[i][1] = sc.nextInt();
		}

		Arrays.sort(red, (a, b) -> Integer.compare(a[0], b[0]));
		Arrays.sort(blue, (a, b) -> Integer.compare(a[0], b[0]));

		NavigableSet<int[]> set = new TreeSet<>((a, b) -> Integer.compare(a[1], b[1]));
		int ri = 0;
		int answer = 0;
		for (int bi = 0; bi < n; bi++) {
			while (ri < n && red[ri][0] < blue[bi][0]) {
				set.add(red[ri++]);
			}
			if (set.isEmpty()) continue;
			int[] x = set.lower(blue[bi]);
			if (x == null) continue;
			set.remove(x);
			answer++;
		}

		System.out.println(answer);
	}
}


Measured memory_bytes: 27092
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define LOOP(i,x,n) for(int i=x;i<n;i++)
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define MP make_pair
#define FIR first
#define SEC second
#define int long long
using namespace std;
const int MOD=1000000007;
const int INF=1000000009;

signed main(){
  char a[2][3],b[2][3];
  REP(i,2)REP(j,3){
    cin>>a[i][j];
    b[1-i][2-j]=a[i][j];
  }
  REP(i,2)REP(j,3){
    if(a[i][j]!=b[i][j]){
      cout<<"NO"<<endl;
      return 0;
    }
  }
  cout<<"YES"<<endl;
  return 0;
}


Measured memory_bytes: 256
class Tree():
    def __init__(self):
        self.root = None
    def insert(self, key):
        z = Node(key)
        y = None
        x = self.root
        while x:
            y = x
            if z.key < x.key:
                x = x.left
            else:
                x = x.right
        z.parent = y
        if y == None:
            self.root = z
        elif z.key < y.key:
            y.left = z
        else:
            y.right = z

    def print(self):
        print('', ' '.join(map(str, self.root.inwalk())))
        print('', ' '.join(map(str, self.root.prewalk())))

    def find(self, x, k):
        while x != None and k != x.key:
            if k < x.key:
                x = x.left
            else:
                x = x.right
        return x

    def delete(self, k):
        z = self.find(tree.root, k)
        y = self.successor(z) if z.left and z.right else z
        x = y.left if y.left else y.right

        if x:
            x.parent = y.parent
        if y.parent == None:
            self.root = x
        elif y == y.parent.left:
            y.parent.left = x
        else:
            y.parent.right = x
        if y != z:
            z.key = y.key

    def successor(self, x):
        if x.right:
            return self.minimum(x.right)
        y = x.parent
        while y and x == y.right:
            x = y
            y = y.parent
        return y

    def minimum(self, x):
        while x.left:
            x = x.left
        return x

class Node():
    def __init__(self, key):
        self.key = key
        self.parent = self.left = self.right = None

    def prewalk(self):
        ret = [self.key]
        if self.left:
            ret += self.left.prewalk()
        if self.right:
            ret += self.right.prewalk()
        return ret

    def inwalk(self):
        ret = []
        if self.left:
            ret += self.left.inwalk()
        ret += [self.key]
        if self.right:
            ret += self.right.inwalk()
        return ret

tree = Tree()
n = int(input())
for i in range(n):
    com = input().split()
    if com[0] == "insert":
        tree.insert(int(com[1]))
    elif com[0] == "find":
        ans = tree.find(tree.root, int(com[1]))
        if ans != None:
            print("yes")
        else:
            print("no")
    elif com[0] == "delete":
        tree.delete(int(com[1]))
    else:
        tree.print()


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

int main(){
    ll a, b, c;
    cin >> a >> b >> c;
    if(a % 2 && b % 2 && c % 2){
        cout << min({a*b, b*c, c*a}) << endl;
    } else {
        cout << 0 << endl;
    }
    return 0;
}

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

int main() {
	int N;
	ll s = 0, t = 0, u;
	cin >> N;
	vector<ll> A(N);
	vector<ll> B(N);
	for (int i = 0;i < N;i++) {
		cin >> A[i];
		s += A[i];
		if (i % 2) t += A[i];
	}
	u = s - t * 2;//これが1番目の山
	B[0] = u;
	ll now;
	for (int i = 0;i < N - 1;i++) {
		B[i + 1] = A[i] * 2 - B[i];
	}
	for (int i = 0;i < N;i++)
		cout << B[i] << " ";
	cout << endl;
}

Measured memory_bytes: 2944
#!/usr/bin/env python

N = input()
N = int(N)

A = []
A = input().split()
A = [int(n) for n in A]
#A.append(0)

B = []
B = input().split()
B = [int(n) for n in B]
B.append(0)
#B.append(0)

#print('N=',n)
#print('A=',A)
#print('B=',B)

monster = 0

for i in range(N) :
	if A[i] < B[i] :
		monster = monster + A[i]
		B[i] = B[i] - A[i]
		if A[i+1] < B[i] :
			monster = monster + A[i+1]
			A[i+1] = 0
		elif A[i+1] >= B[i] :
			monster = monster + B[i]
			A[i+1] = A[i+1] - B[i]
	elif A[i] >= B[i] :
		monster = monster + B[i]

print(monster)



Measured memory_bytes: 19648
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll M =1000000007;
//MOD??
long long mod(long long val, long long m) {
  long long res = val % m;
  if (res < 0) res += m;
  return res;
}
ll mpow(ll x, ll n){ //x^n(mod M) ????pow(x,n)?????????????mod??
    ll ans = 1;
    while(n != 0){
        if(n&1) ans = ans*x % M;
        x = x*x % M;
        n = n >> 1;
    }
    return ans;
}
int main (){
  int i;
  int k;
  string s;
  cin>>k>>s;
  for(i=0;i<s.length();i++){
    if(k==i){
      cout<<"..."<<endl;
      return 0;
    }
    cout<<s[i];
  }
  cout<<endl;
  return 0;
}




Measured memory_bytes: 3628
n = int(input())
s = input()
chkR = 0
chkB = 0
chkG = 0
if n == 1 or n==2:
  print(0)
  exit()
  
for i in range(n):
  if s[i] =='R':
    chkR+=1
  if s[i] =='B':
    chkB+=1
  if s[i] =='G':
    chkG+=1
    
ans = chkR*chkB*chkG

m = (n-3)//2
for i in range(m+1):
  for j in range(n-2-2*i):
    if s[j]!=s[j+i+1] and s[j+i+1]!=s[j+2*i+2] and s[j+2*i+2]!=s[j]:
      ans -= 1
      
print(ans)

Measured memory_bytes: 9228
#include <iostream>
#include <unordered_map>
#include <string>
#include <memory>

class Counter
{
private:
	std::unordered_map<std::string, int> table;

public:

	Counter() 
	{
		table.emplace("AC", 0);
		table.emplace("WA", 0);
		table.emplace("TLE", 0);
		table.emplace("RE", 0);
	}

	void set_string(std::string str)
	{
		table[str]++;
	}

	void print()
	{
		std::cout << "AC x " << table["AC"] << std::endl;
		std::cout << "WA x " << table["WA"] << std::endl;
		std::cout << "TLE x " << table["TLE"] << std::endl;
		std::cout << "RE x " << table["RE"] << std::endl;
	}
};

int main(void)
{
	int input_num = 0;
	std::cin >> input_num;

	std::shared_ptr<Counter> counter(new Counter());

	for (int i = 0; i < input_num; i++) 
	{
		std::string str;
		std::cin >> str;
		counter->set_string(str);
	}

	counter->print();

	return 0;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, m, n) for (ll i = m; i < n; ++i)
#define FORR(i, m, n) for (ll i = m; i >= n; --i)
#define ALL(v) (v).begin(),(v).end()
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF=1LL<<60;
const int inf=(1<<30)-1;
const int mod=1e9+7;
int dx[8]={1,0,-1,0,-1,-1,1,1};
int dy[8]={0,1,0,-1,-1,1,-1,1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,W;cin >> n >> W;
    vector<int> w(n),v(n);
    REP(i,n){
        cin >> w[i] >> v[i];
    }
    int u=w[0];
    vector<vector<vector<int>>> dp(n+1,vector<vector<int>>(n+1,vector<int>(n*3+1,-1)));
    dp[0][0][0]=0;
    REP(i,n){
        REP(j,n){
            REP(k,n*3+1){
                if(dp[i][j][k]==-1){
                    continue;
                }
                chmax(dp[i+1][j][k],dp[i][j][k]);
                if(j*u+k+w[i]<=W){
                    chmax(dp[i+1][j+1][k+w[i]-u],dp[i][j][k]+v[i]);
                }
            }
        }
    }
    int ans=0;
    REP(i,n+1){
        REP(j,n*3+1){
            chmax(ans,dp[n][i][j]);
        }
    }
    cout << ans << endl;
}

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

int main()
{
    map<char,int>mp;
    string s;
    cin >> s;
    bool mk = 0;
    for(int i=0; i<s.size(); i++)
        mp[s[i]]++;

    for(char i = 'a'; i<='z'; i++)
    {
        if(mp[i]%2){mk = 1;break;}
    }
    if(!mk)cout << "Yes" << endl;
    else cout << "No" << endl;

 }


Measured memory_bytes: 3584
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
#define ALL(obj) (obj).begin(), (obj).end()
const double PI = acos(-1);
const double EPS = 1e-15;
long long INF=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;
bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd_(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}

int main(){
  
  long long n;
  cin>>n;
  
  long long max_v;
  for(long long i=0;i<=n;i++){
    if((i+1)*i/2>=n){
      max_v = i;
      break;
    }
  }
  
  long long limit = (max_v+1)*max_v/2;
  long long diff = limit - n;
  for(long long i=1;i<=max_v;i++){
    if(i==diff)continue;
    cout<<i<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
import math

a = [1]*1000000
for i in range(2,1000000):
    for j in range(i+i,1000000)[::i]:
        a[j] = 0

b = [0]*1000000
b[0] = b[1] = 0
for i in range(2,1000000):
    if a[i] == 1:
        b[i] = b[i-1] + 1
    else:
        b[i] = b[i-1]

while True:
    try:
        print(b[int(input())])
    except EOFError:
        break
    


Measured memory_bytes: 23760
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<complex>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<double,ll> pdl;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;


ll n;
vector<ll> a;

//0-origen
bool is_good(ll x){
    map<ll,ll> M;
    for(int i=1;i<a.size();i++){
        if(a[i-1]<a[i]){continue;}
        auto I=M.upper_bound(a[i]);
        while(I!=M.end()){
            I=M.erase(I);
        }
        bool done=false;
        for(ll w=a[i];w>0;w--){
            if(M[w]+1==x){M[w]=0;}
            else{M[w]++; done=true; break;}
        }
        if(!done){return false;}
    }
    return true;
}



int main(){
    cin>>n;
    a.resize(n);
    for(int i=0;i<n;i++){cin>>a[i];}
    ll l=2,r=10000000;
    for(int i=1;i<=n;i++){
        if(i==n){cout<<1<<endl; return 0;}
        if(a[i-1]>=a[i]){break;}
    }
    while(r-l>3){
        ll m=l+(r-l)/2;
        if(is_good(m)){r=m;}
        else{l=m+1;}
    }
    for(ll i=l;i<=r;i++){
        if(is_good(i)){
            cout<<i<<endl; return 0;
        }
    }
    
    
    return 0;
}


Measured memory_bytes: 1792
# coding: utf-8
# Your code here!

def greedy():
    cnt = 0
    while len(E) > 0:
        edge = E.pop()
        cnt += 1
        while len(E) > 0 and E[-1][0] < edge[1]:
            E.pop()
    
    return cnt
    

N , M = map(int, input().split())
E = []
for i in range(M):
    E.append(list(map(int, input().split())))
    
E.sort(key=lambda x:x[1], reverse = True)

result = greedy()
print(result)






Measured memory_bytes: 64856
#include <bits/stdc++.h>
#define f first
#define s second
#define pb push_back
#define ENDL '\n'
#define sz(a) (int)(a.size())
#define deb(a) cout << #a << ": " << a << ENDL
#define all(a) begin(a), end(a)
#define fore(i, a, b) for(int i(a), ThkMk(b); i < ThkMk; ++i)
#define _ ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

using namespace std;

typedef long long lli;
typedef long double ld;
typedef pair<lli, lli> ii;
typedef vector<lli> vi;

ld EPS = 1e-6;

struct pt {  // for 3D add z coordinate
	double x,y;
	pt(double x, double y):x(x),y(y){}
	pt(){}
	double norm2(){return *this**this;}
	double norm(){return sqrt(norm2());}
	bool operator==(pt p){return abs(x-p.x)<=EPS&&abs(y-p.y)<=EPS;}
	pt operator+(pt p){return pt(x+p.x,y+p.y);}
	pt operator-(pt p){return pt(x-p.x,y-p.y);}
	pt operator*(double t){return pt(x*t,y*t);}
	pt operator/(double t){return pt(x/t,y/t);}
	double operator*(pt p){return x*p.x+y*p.y;}
//	pt operator^(pt p){ // only for 3D
//		return pt(y*p.z-z*p.y,z*p.x-x*p.z,x*p.y-y*p.x);}
	double angle(pt p){ // redefine acos for values out of range
		return acos(*this*p/(norm()*p.norm()));}
	pt unit(){return *this/norm();}
	double operator%(pt p){return x*p.y-y*p.x;}
	// 2D from now on
	bool operator<(pt p)const{ // for convex hull
		return x<p.x-EPS||(abs(x-p.x)<=EPS&&y<p.y-EPS);}
	bool left(pt p, pt q){ // is it to the left of directed line pq?
		return (q-p)%(*this-p)>EPS;}
	pt rot(pt r){return pt(*this%r,*this*r);}
	pt rot(double a){return rot(pt(sin(a),cos(a)));}
};

ld to2(ld u) {
    return u * u;
}

ld dist(pt u, pt v) {
    return sqrt(to2(u.x - v.x) + to2(u.y - v.y));
}

int main()
{   _
    ld a, b; cin >> a >> b;
    pt u(0.0, a);
    pt v(0.0, b);
    lli h, m; cin >> h >> m;
    m += h * 60LL;
    ld hFrac = 1.0 / 720.0;
    ld fullAngle = 2.0 * acos(-1);
    ld mFrac = 1.0 / 60.0;
    ld hAngle = m * hFrac * fullAngle;
    m %= 60;
    ld mAngle = m * mFrac * fullAngle;
    u = u.rot(hAngle);
    v = v.rot(mAngle);
    cout << setprecision(10) << fixed << dist(u, v) << ENDL;
    return 0;
}


Measured memory_bytes: 4104
# -*- coding: utf-8 -*-
"""
Created on Sat Jun  1 20:46:31 2019

@author: Yamazaki Kenichi
"""
import time

N, A, B, C = map(int,input().split())
mod = 10**9+7

tnow = time.time()

def cmb(n, r, mod):
    if (r < 0 or r > n):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

g1 = [1, 1] # 元テーブル
g2 = [1, 1] # 逆元テーブル
inv = [0, 1] # 逆元テーブル計算用テーブル
for i in range(2, 2*10**5+1):
    g1.append((g1[-1] * i) % mod)
    inv.append((-inv[mod % i] * (mod//i)) % mod)
    g2.append((g2[-1] * inv[-1]) % mod)
#逆元求める
#def g(a,mod):
def g(a):
    b, u, v = mod, 1,0
    while b:
        t = a//b
        a -= t * b
        u -= t * v
        a,b,u,v = b,a,v,u
        u %= mod
    return u if u > 0 else u + mod
def modpow(a, n, mod):
    res = 1
    while n > 0:
        if n & 1:
            res = res * a % mod
        a = a * a % mod
        n >>= 1
    return res

p1,p2 = A * g(A + B) % mod, B * g(A + B) % mod
#p1,p2 = A * g(100) % mod, B * g(100) % mod
p3 = (100 - C) * g(100) % mod

#p1,p2のべき乗のリスト
P1, P2 = [1], [1]
for i in range(N+1):
    P1.append(P1[-1] * p1 % mod)
    P2.append(P2[-1] * p2 % mod)

ans = 0
for i in range(N):
    ans += (N+i) * cmb(N+i-1, i, mod) * P1[N] * P2[i]
    ans += (N+i) * cmb(N+i-1, i, mod) * P1[i] * P2[N]
    ans %= mod
ans = ans * g(p3) % mod

#ans = 0
#for i in range(N):
#    ans += (N+i)*cmb(N+i-1,i,mod)*((modpow(p1,N,mod) * modpow(p2,i,mod) 
#                                 +(modpow(p2,i,mod) * modpow(p2,N,mod)))%mod)
#    ans %= mod
#ans = ans * g(p3) % mod
print(ans)

#tnow = time.time()
#pow(p1,100000)

#tnow2 = time.time()
#tnow3 = time.time()
#print(tnow2 - tnow)
#print(tnow3 - tnow2)

Measured memory_bytes: 34824
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
using namespace std;

int main(){
    int n, m;
    cin >> n >> m;
    if(m==0){
        if(n==1) cout << 0 << endl;
        else cout << pow(10,n-1) << endl;
        return 0;
    }
    vector<int> s(m), c(m);
    for(int i = 0 ; i < m; i++){
        cin >> s[i] >> c[i];
    }
    for(int i = 0; i < m; i++){
        if(c[i] == 0 && n > 1 && s[i] == 1){
            cout << -1 << endl;
            return 0;
        }
        for(int j = i+1; j < m; j++){
            if(s[i] == s[j] && c[i] != c[j]){
                cout << -1 << endl;
                return 0;
            }
        }
    }
    vector<int> ans(n, 0);
    for(int i = 0; i < m; i++){
            ans[s[i]-1] = c[i];
    }
    if(ans[0]==0&&n>1) ans[0]=1;
    for(int i = 0; i < n; i++){
        cout << ans[i];
    }
    cout << endl;
    return 0;


}

Measured memory_bytes: 888
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/math/common_factor_rt.hpp>

#define rep_ui(k,n)      for(ui  i = (k); i < (n); ++i)
#define rep_si(k,n)      for(int i = (k); i < (n); ++i)
#define rep_ul(k,n)      for(ul  i = (k); i < (n); ++i)
#define rep_sl(k,n)      for(ll  i = (k); i < (n); ++i)
#define rep_ui_down(k,n) for(ui  i = (k); i > (n); --i)
#define rep_si_down(k,n) for(int i = (k); i > (n); --i)
#define rep_ul_down(k,n) for(ul  i = (k); i > (n); --i)
#define rep_sl_down(k,n) for(ll  i = (k); i > (n); --i)

#define rep_uj(k,n)      for(ui  j = (k); j < (n); ++j)
#define rep_sj(k,n)      for(int j = (k); j < (n); ++j)
#define rep_uj_down(k,n) for(ui  j = (k); j > (n); --j)
#define rep_sj_down(k,n) for(int j = (k); j > (n); --j)

#define rep(k,n)         rep_ui(k,n)

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

template<class T>
std::ostream& operator<<(std::ostream& os, const std::vector<T>& vc)
{
  for (auto it = vc.begin(); it != vc.end(); ++it)
  {
    if (std::next(it) == vc.end())
      os << *it;
    else
      os << *it << ' ';
  }
  return os;
}

template<class T1, class T2>
inline
std::ostream & operator<<(std::ostream & os, const std::pair<T1, T2> & p)
{
  return os << p.first << ' ' << p.second;
}

void solve(void)
{
  using std::string;
  using std::vector;
  using std::map;
  using std::pair;
  using std::cin;
  using std::cout;
  ui N{}; std::cin >> N;
  vector<ll> H(N);
  rep(0, N) cin >> H[i];

  vector<ll> dp(N);
  dp[0] = 0;
  dp[1] = std::abs(H[1] - H[0]);
  rep(2, N)
  {
    auto cost0 = dp[i - 2] + std::abs(H[i] - H[i - 2]);
    auto cost1 = dp[i - 1] + std::abs(H[i] - H[i - 1]);
    dp[i] = std::min(cost0, cost1);
  }

  auto ans = dp[N - 1];
  cout << ans << '\n';
  return;
}

int main(void)
{
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(0);

  solve();

  return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define REP2(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(v) (v).begin(),(v).end()
#define INF 2e9
typedef long long ll;

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

  sort(ALL(w));
  int cnt=1,l=w.size();
  if(l==1){
    cout<<"No"<<endl;
    return 0;
  }
  REP(i,l){
    if(i==0) continue;
    if(w[i-1]==w[i]) cnt++;
    if(w[i-1]!=w[i] || i==l-1){
      if(cnt%2){
        cout<<"No"<<endl;
        return 0;
      }
      cnt=1;
    }
  }
  cout<<"Yes"<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <map>
#include <cmath>
#include <vector>
#include <queue>
using namespace std;
typedef long long LL;
const LL N = 1000000007;

LL n,m,k,tt,ans = 0;
LL a[500005];
LL mx[1000005] = {0},cnt[1000005] = {0};
LL yz[500005] = {0},yzc = 0;
LL vyz[1000005] = {0};

void decc(LL x){
	for(LL i = 2;i * i <= x;i ++){
		if(x % i == 0){
			if(!vyz[i]) yz[++ yzc] = i;
			vyz[i] = 1;
			cnt[i] = 0;
			while(1){
				x /= i;
				cnt[i] ++;
				if(x % i) break;
			}
			mx[i] = max(mx[i],cnt[i]);
		}
	}
	if(x > 1){
		cnt[x] = 1;
		if(!vyz[x]) yz[++ yzc] = x;
		vyz[x] = 1;
		mx[x] = max(mx[x],cnt[x]);
	}	
}

int main(){
	ios::sync_with_stdio(false);
	cin >> n;
	for(LL i = 1;i <= n;i ++){
		cin >> a[i];
		decc(a[i]);
	}
//	for(LL i = 1;i <= 20;i ++) cout << i << ' ' << mx[i] << endl;
//	for(LL i = 1;i <= yzc;i ++) cout << yz[i] << (i == yzc ? '\n' : ' ');
	for(LL i = 1;i <= n;i ++){
		tt = 1;
		for(LL j = 1;j <= yzc;j ++) cnt[yz[j]] = 0;
		decc(a[i]);
		for(LL j = 1;j <= yzc;j ++){
			for(LL k = cnt[yz[j]] + 1;k <= mx[yz[j]];k ++){
				tt *= yz[j];
				tt %= N;
			}
		}
//		cout << tt << endl;
		ans += tt; ans %= N;
	}
	cout << ans << endl;
	return 0;
}

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

int main(){
  int N;
  cin >> N;
  vector<vector<int>> A(2, vector<int>(N));
  for(int i=0; i<2; i++){
    for(int j=0; j<N; j++){
      cin >> A.at(i).at(j);
    }
  }
  int ans = 0;
  for(int i=0; i<N; i++){
    int sum = 0;
    for(int j=0; j<N; j++){
      if(j<=i){
        sum += A.at(0).at(j);
      }
      if(j>=i){
        sum += A.at(1).at(j);
      }
    }
    ans = max(ans,sum);
  }
  cout << ans;
  return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <algorithm>
#define maxn 105
#define ll long long
#define ld double
#define mod 998244353
using namespace std;
char s[maxn];
char t[10] = "keyence";
int main()
{
	scanf("%s", s);
	int n = strlen(s);
	for(int i = 0; i < n; i++)
		for(int j = i - 1; j < n; j++)
		{
			int nl = 0, fl = 1;
			for(int k = 0; k < n; k++)
				if(k >= i && k <= j) continue;
				else if(s[k] != t[nl]) fl = 0;
				else
					nl++;
			if(nl != 7) fl = 0;
			if(fl)
			{
				printf("YES\n");
				return 0;
			}
		}
	printf("NO\n");
	return 0;
}

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

const int mod=1e9+7;

int n,a,ans,pre;

int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a;
        ans=(ans+(long long)pre*a)%mod;
        pre=(pre+a)%mod;
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 3652
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <algorithm>

int main()
{
    int64_t A, V, B, W, T;

    std::cin >> A >> V >> B >> W >> T;

    if (V > W && abs(A - B) <= T * (V - W)) {
        std::cout << "YES" << std::endl;
    }
    else {
        std::cout << "NO" << std::endl;
    }

    return 0;
}


Measured memory_bytes: 3592
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int INF = 1LL << 30;
int MOD = 1e9+7;
main(){
    string S;
    int N;
    cin >> S >> N;
    set<string> st;
    /*
    bool flag[26] = {};
    for(char c:S){
        flag[c-'a'] = 1;
    }
    queue<int> que;
    int cnt = 0;
    for(int i = 0;i < 26;i++){
        if(!flag[i])continue;
        char next = i + 'a';
        for(int j = 0;j < S.size();j++){
            if(S[j] == next)que.push(j);
        }

    }
    */
    
    for(int i = 0;i < S.size();i++){
        for(int j = 1;j <= 5 && i+j <= S.size();j++){
            st.insert(S.substr(i,j));
        }
    }
    for(string s:st){
        N--;
        if(N == 0){
            cout << s << endl;
            return 0;
        }
    }
}

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

const int maxn = 22;
int h, w;
char grid[maxn][maxn];

int dist[maxn][maxn];

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

bool valid(int r, int c) {
    return 0 <= r && r < h && 0 <= c && c < w;
}

int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    cin >> h >> w;
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            cin >> grid[i][j];
        }
    }
    int ans = 0;
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            if (grid[i][j] == '#') continue;
            queue<pair<int,int>> q;
            memset(dist,-1,sizeof dist);
            q.push({i,j});
            dist[i][j] = 0;
            while (!q.empty()) {
                auto p = q.front(); q.pop();
                ans = max(ans,dist[p.first][p.second]);
                for (int k = 0; k < 4; k++) {
                    int ni = p.first+dx[k];
                    int nj = p.second+dy[k];
                    if (!valid(ni,nj) || grid[ni][nj] == '#') continue;
                    if (dist[ni][nj] == -1 || dist[ni][nj] > dist[p.first][p.second] + 1) {
                        dist[ni][nj] = dist[p.first][p.second] + 1;
                        q.push({ni,nj});
                    }
                }
            }
        }
    }
    cout << ans << '\n';
}



Measured memory_bytes: 256
{-# LANGUAGE BangPatterns, MagicHash #-}
import Control.Monad
import Control.Applicative
import Data.List
import Data.Maybe
import Data.Bits
import qualified Data.IntMap.Strict as M
import qualified Data.ByteString.Char8 as B
import qualified Data.Vector.Unboxed as V
import Data.Vector.Unboxed ((!))
import Data.Tuple
import Data.Ord (Down(..))
import Data.Coerce
                                 
query :: Int -> [(Int,Int)] -> Int
query n = snd . foldl' loop (Nothing,0) . sortOn snd
  where
    loop (Nothing,i) (_,b) = (Just b, i+1)
    loop (Just x, i) (a,b) | a < x = (Just x, i)
                           | otherwise = (Just b, i+1)
     
main :: IO ()
main = do
  [n,m] <- map read . words <$> getLine
  ls <- map ((\[x,y]->(x,y)) . unfoldr (B.readInt . B.dropWhile (== ' ')))
          . B.lines
        <$> B.getContents
  putStrLn $ show $ query n ls

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

using namespace std;

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

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

int n, m;
int r;
vector<int> e[100010];
vector<int> topo;
// bool used[100010];
int in[100010];
int parent[100010];

void init() {

}

// void dfs(int i) {
//   if (used[i]) return;
//   used[i] = true;
//   REP(j, SZ(e[i])) dfs(e[i][j]);
//   topo.push_back(i);
// }
//
// void makeTopo() {
//   topo.clear();
//   REP(i, n) dfs(i);
//   reverse(ALL(topo));
// }

void input() {
  REP(i, 100010) {
    e[i].clear();
    parent[i] = -1;
    in[i] = 0;
  }
  cin >> n >> m;
  REP(i, n+m-1) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    e[a].push_back(b);
    in[b]++;
  }
  queue<int> q;
  REP(i, n) if (in[i] == 0) q.push(i);
  while(!q.empty()) {
    int i = q.front();
    // topo.push_back(i);
    q.pop();
    REP(j, SZ(e[i])) {
      in[e[i][j]]--;
      if (in[e[i][j]] == 0) {
        q.push(e[i][j]);
        parent[e[i][j]] = i;
      }
    }
  }
  // REP(i, n) {
  //   REP(j, SZ(e[topo[i]])) {
  //     parent[e[topo[i]][j]] = topo[i];
  //   }
  // }
  REP(i, n) printf("%d\n",parent[i]+1);
}

void solve() {

}

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


Measured memory_bytes: 7040