akhauriyash/Code-Regression huggingface dataset:
import numpy as np
N,M,Q = map(int,input().split())
S = [[0]*N for i in range(N)]
for i in range(M):
    L,R = map(int,input().split())
    S[L-1][R-1] += 1

S = np.cumsum(np.cumsum(np.array(S),axis=0),axis=1)

for i in range(Q):
    p,q = map(int,input().split())
    p -= 1
    q -= 1
    ans = S[q][q]
    if p > 0:
        ans += S[p-1][p-1]-S[p-1][q]-S[q][p-1]
    print(ans)

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

int main(){
    int n;
    cin >>n;
    int count = 0;
    vector<int> A(n);
    rep(i,n){
        cin >> A[i];
    }
    map<int,int> m;
    bool ans = true;
    for(int x :A){
        if(m.count(x)){
            ans =false;
        }else{
            m[x]=1;
        }
    }
    if(ans)
        cout<<"YES"<<endl;
    else
        cout<<"NO"<<endl;
}



Measured memory_bytes: 10368
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
//constexpr int MOD=1000000007;
constexpr int MOD=998244353;
#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define endl "\n"
#define rep(i,n) for(lint (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(lint (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
#define fi first
#define se second
typedef long long lint;
int dx[8]={1,1,0,-1,-1,-1,0,1};
int dy[8]={0,1,1,1,0,-1,-1,-1};
const int MAX_N=2e5+5;

int main(void){
    int N,S;
    cin >> N >> S;
    int A[N];
    rep(i,N) cin >> A[i];
    lint dp[N+10][S+10]={};
    dp[0][0]=1;
    for(int i=0;i<N;i++){
        for(int j=0;j<=S;j++){
            if(j+A[i]<=S) dp[i+1][j+A[i]]=(dp[i+1][j+A[i]]+dp[i][j])%MOD;
            dp[i+1][j]=(dp[i+1][j]+dp[i][j]*2)%MOD;
        }
    }
    cout << dp[N][S] << endl;
}


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

int main() {
	int N;
	cin >> N;
	int x[N];
	int c[N];
	for (int i = 0;i < N;i++) {
		cin >> x[i];
		c[i] = x[i];
	}
	sort(c,c+N);
	for (int i = 0;i < N;i++) {
		if (x[i] <= c[N/2-1]) {
			cout << c[N/2] << endl;
		} else {
			cout << c[N/2-1] << endl;
		}
	}
}

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

int main(){
	int a,b,c,buf;
	cin >> a >> b >> c;
	if(a>b){
		buf=a;
		a=b;
		b=buf;
	}
	if(b>c){
		buf=b;
		b=c;
		c=buf;
	}
	if(a>b){
		buf=a;
		a=b;
		b=buf;
	}
	cout << a << " "<< b << " " << c << endl;
	
	return 0;
}



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

ll modpow(ll a, ll b){ //a^b
	ll ret=1;
  while(b){
  	if(b&1) ret=ret*a % mod ;
  	a=a*a % mod;
    b>>=1;
  }
  return ret;
}


int main(){

  ll N,K,ans=0;
  cin>>N>>K;
  
  ll d[K+5];
  
  for(ll i=1;i<=K;i++){
    
    d[i]=modpow((K/i),N);
    
    //d[i]=exp(N*logl(K/i));
    //d[i] = powl(floor(K/i),N);
    //cout<<pow(K/i,N)<<endl;
  }
    
  for(ll i=K;i>0;i--){
  	for(ll j=i*2;j<=K;j+=i){
    	d[i] -= d[j];
      	
    }
  }
  
  for(ll i=1;i<=K;i++){
  	ans+=d[i]*i;
  }
 cout<<ans % mod; 
}

Measured memory_bytes: 4372
#include<iostream>
#include<string>
#include<algorithm>
#include<string.h>
using namespace std;
#define ll long long
string a[100001];
int main()
{
	int n;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		char b[11];
		cin>>b;
		sort(b,b+strlen(b));
		a[i]=b;
	}
	sort(a,a+n);
	ll count=0;
	ll sum=0;
	for(int i=0;i<n-1;i++)
	{
		if(a[i]==a[i+1])
		{
			count++;
		}
		else
		{
			if(count)
			{
				sum+=count*(count+1)/2;
			}
			count=0;
		}
	}
	if(count)
	{
		sum+=count*(count+1)/2;
	}
	cout<<sum<<endl;
	return 0;
} 

Measured memory_bytes: 5760
// B.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <vector>

using namespace std;

int main(int argc, char *argv[]) {
	string s;
	cin >> s;
	int ans = 0;
	for (int i = 0; i < (int)s.length() / 2; ++i) {
		ans += s[i] != s[s.length() - i - 1];
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
a=int(input())
b=int(input())
c=int(input())
X = int(input())
fifty = [x for x in range (0,X+1,500)][:a+1]
hundred = [x for x in range (0,X+1,100)][:b+1]
five_hundred = [x for x in range (0,X+1,50)][:c+1]
pattern = [x+y+z for x in fifty for y in hundred for z in five_hundred]
print(len(list(filter(lambda x:x==X,pattern))))

Measured memory_bytes: 7320
#include <iostream>
#include <queue>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define MAX_N 200000
using namespace std;

int main(void) {
  int N;
  cin >> N;
  //N = MAX_N;
  int64_t A[MAX_N];
  rep(i, N) { cin >> A[i]; }
  //rep(i, N) { A[i] = 1; }

  int64_t B[MAX_N];
  rep(i, N) { cin >> B[i]; }
  //rep(i, N) { B[i] = (i % 2) ? MAX_N : 1; }
  int64_t C[MAX_N];
  queue<int> queC;
  rep(i, N) { queC.push(i); }

  int64_t Ans = 0;
  while (1) {
    if (queC.empty())
      break;
    while (!queC.empty()) {
      auto item = queC.front();
      queC.pop();
      if (item == 0) {
        C[N - 1] = B[N - 1] - B[N - 2] - B[0];
        C[0] = B[0] - B[1] - B[N - 1];
        C[item + 1] = B[item + 1] - B[item + 0] - B[item + 2];
      } else if (item == 1) {
        C[0] = B[0] - B[1] - B[N - 1];
        C[item + 0] = B[item + 0] - B[item + 1] - B[item - 1];
        C[item + 1] = B[item + 1] - B[item + 0] - B[item + 2];
      } else if (item == (N - 1)) {
        C[item - 1] = B[item - 1] - B[item + 0] - B[item - 2];
        C[N - 1] = B[N - 1] - B[N - 2] - B[0];
        C[0] = B[0] - B[N - 1] - B[1];
      } else if (item == (N - 2)) {
        C[item - 1] = B[item - 1] - B[item + 0] - B[item - 2];
        C[item + 0] = B[item + 0] - B[item + 1] - B[item - 1];
        C[N - 1] = B[N - 1] - B[N - 2] - B[0];
      } else {
        C[item - 1] = B[item - 1] - B[item + 0] - B[item - 2];
        C[item + 0] = B[item + 0] - B[item + 1] - B[item - 1];
        C[item + 1] = B[item + 1] - B[item + 0] - B[item + 2];
      }
    }

    rep(i, N) {
      if (C[i] >= A[i]) {
        int64_t diff = B[i] - C[i];
        int d = (B[i] - A[i]) / (diff);
        Ans += d;
        B[i] = B[i] - diff * d;
        // B[i] = C[i];
        C[i] = 0;
        queC.push(i);
      }
    }
  }
  bool possible = true;
  rep(i, N) {
    if (A[i] != B[i]) {
      // cout << "i=" << i << " A=" <<A[i] << " B=" << B[i] << endl;
      possible = false;
      break;
    }
  }
  if (possible == false) {
    cout << "-1" << endl;
  } else {
    cout << Ans << endl;
  }
  return 0;
}

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

int main() {
  int n;
  cin >> n;
  int sum = 0;
  for(int i = 1; i<= n ;i++){
    sum+=i;
  }
  cout << sum << endl;
}

Measured memory_bytes: 3560
using System;
using System.Collections.Generic;
using System.Linq;

public class Solution
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine());
        var h = int.Parse(Console.ReadLine());
        var w = int.Parse(Console.ReadLine());

        int pattern = (n - h + 1) * (n - w + 1);

        Console.WriteLine(pattern);
    }
}

Measured memory_bytes: 11092
package main

import (
	"fmt"
	"strings"
)

func main() {
	var s, t string
	fmt.Scan(&s)
	fmt.Scan(&t)

	sl := strings.Split(s, "")
	tl := strings.Split(t, "")

	var sum int

	for i := 0; i < 3; i++ {
		if sl[i] == tl[i] {
			sum++
		}
	}

	fmt.Println(sum)
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#ifdef ONLINE_JUDGE
#define LLD "%I64d"
#else
#define LLD "%lld"
#endif
#define fu(a,b,c) for(int a=b;a<=(int)c;++a)
#define fd(a,b,c) for(int a=b;a>=(int)c;--a)
#define cu(a,b,c) for(int a=b;a<(int)c;++a)
#define cd(a,b,c) for(int a=b-1;a>=(int)c;--a)
#define gcd(a,b) __gcd(a,b) 
#define pii pair<int,int>
#define pll pair<long long,long long>
#define all(a) a.begin(),a.end()
#define F first
#define S second
#define pb push_back
#define pf push_front
#define MOD 1000000007 
#define MAXN 52
#define MAXH 20
#define MAXM 52
#define INF 100000000
#define ll long long
#define ull unsigned long long
#define RNG rng mt19937(time(NULL))
#define udist(a,b) uniform_int_distribution<uint32_t> distribution(a,b)
#define max3(a,b,c) max(a, max(b, c))
#define min3(a,b,c) min(a, min(b, c))
#define gmax(a,b) a = max(a, b)
#define gmin(a,b) a = min(a, b)
#define whatis(x) cerr << #x << " is " << x << endl;
#define fast_io() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define PI 3.1415926535897932384626433
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
const int N = 100005;
vector<int> g[N];
int cc = 0;
bool vis[N];

void dfs(int cur){
	if(!vis[cur]){
		vis[cur] = 1;
		for(int a:g[cur]){
			dfs(a);	
		}
	}
}


int main(){
	fast_io();
	int n,m;
	cin >> n >> m;
	int x,y,z;
	cu(i,0,m){
		cin >> x >> y >> z;	
		g[x].pb(y);
		g[y].pb(x);
	}
	fu(i,1,n){
		if(!vis[i]){
			++cc;
			dfs(i);
		}
	}
	cout << cc << '\n';
}


Measured memory_bytes: 8960
#include <iostream>
#include <cstring>
#include <vector>
using namespace std;
vector<int> Map[205];
void work(int l, int r) {
    if(r - l <= 1) return;
    int m = (l + r) >> 1;
    for(int i = m + 1; i < r; i++)
        Map[m].push_back(i);
    work(l, m);
    work(m, r);
}
int main() {
    int n, k, e = 0;
    cin >> n >> k;
    work(0, n);
    for(int i = 0; i < n; i++)
        e += Map[i].size();
    cout << e << endl;
    for(int i = 0; i < n; i++)
        for(int j = 0; j < Map[i].size(); j++)
            cout << i + 1 << " " << Map[i][j] + 1 << endl;
    while(k--) {
        int l = 0, r = n;
        string s;
        while(s != "Yes") {
            int m = (l + r) / 2;
            cout << m + 1 << endl;
            cin >> s;
            if (s == "Near")
                l = m;
            else if(s == "No")
                r = m;
        }
    }
    return 0;
}



Measured memory_bytes: 3324
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define forr(i,p,n) for(int i=p;i<n;i++)
#define tam 12000
#define offset 50000
using namespace std;
typedef long long  ll;
typedef pair<ll,ll> ii;
typedef pair<ll,ii> iii;
const ll MOD=1e9+7;
int main()
{
    ios::sync_with_stdio(false);cin.tie(0);
    int a,b;
    cin>>a>>b;
    for(int i=b-a+1;i<=b+a-1;i++)
        cout<<i<<" ";
    
}

Measured memory_bytes: 256
using System;
using System.Linq;

class B
{
	static void Main()
	{
		var n = int.Parse(Console.ReadLine());
		var d = new int[n].Select(_ => Console.ReadLine()).Select(s => s[0] == s[2]).ToArray();
		Console.WriteLine(Enumerable.Range(0, n - 2).Any(i => d[i] && d[i + 1] && d[i + 2]) ? "Yes" : "No");
	}
}


Measured memory_bytes: 28256
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<int, int> P;
const int inf = INT_MAX;
const ll INF = 1LL << 60;
const ll mod = 1e9+7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

// 079d

int main(){
    int h, w;
    cin >> h >> w;
    vector<vector<int>> c(10, vector<int>(10));
    vector<vector<int>> a(h, vector<int>(w));
    rep(i, 10)rep(j, 10) cin >> c[i][j];
    rep(i, h)rep(j, w) cin >> a[i][j];

    rep(k, 10)rep(i, 10)rep(j, 10) chmin(c[i][j], c[i][k] + c[k][j]);
    int ans = 0;
    rep(i, h)rep(j, w){
        if (a[i][j] != -1 and a[i][j] != 1){
            ans += c[a[i][j]][1];
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 384
/** 
 * THIS IS MOOONI'S CODE !
 * HACK IT IF YOU CAN !
**/
#include <bits/stdc++.h>
 
using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  int sum = accumulate(a.begin(), a.end(), 0);
  int k = (sum + 4 * m - 1) / (4 * m);
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    cnt += (a[i] >= k);
  }
  cout << (cnt >= m ? "Yes" : "No") << '\n';
  return 0;
}

Measured memory_bytes: 256
// https://atcoder.jp/contests/abc173/tasks/abc173_d
#include<bits/stdc++.h>
using namespace std;

int main(int argc, char* argv[]) {
	long long n;
	cin >> n;
	vector<long long> a (n);
	for (auto& x:a) {
		cin >> x;
	}
	sort(a.begin(), a.end());
	long long ans = 0;
	map<long long, list<pair<long long, long long>>> m;
	m[a[n-1]].push_back({a[n-1], a[n-1]});
	for (long long i = n-2; i >= 0; i--) {
		map<long long, list<pair<long long, long long>>>::iterator it;
		it = m.end();
		--it;
		ans += it->first;
		pair<long long, long long> p = it->second.back();
		it->second.pop_back();
		if (it->second.size() == 0) {
			m.erase(it->first);
		}
		m[min(p.first, a[i])].push_back({p.first, a[i]});
		m[min(p.second, a[i])].push_back({p.second, a[i]});
	}
	cout << ans << endl;
	return 0;
}

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

int main() {
  int N; cin >> N;
  ll a = 2, b = 1;
  while (N > 1) {
    ll tmp = b;
    b = a + b;
    a = tmp;
    --N;
  }
  cout << b << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include<vector>
#include <algorithm>
#include <queue>
#include<string>
#include <map>
#include <cmath>
#include <deque>
#include <list>
#include <stack>
#include <queue>
#include <utility>
#include <set>
#include <bitset>
typedef long long ll;
typedef long double ld;
#define PI  3.14159265358979323846

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

int main() {
    ll N, K;
    cin >> N >> K;
    ll ans = N%(K);
    while (true)
    {
        if (abs(ans-K)<ans) {
            ans = abs(ans - K);
        }
        else {
            break;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3596
/*
 * Author : Sadi
 * Sat 04/07/2020
 * 17:26:10.18
 */
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <bitset>
#include <cassert>

using namespace std;

#define    watch(x); cout << "\n" <<  #x << " is: " << x << "\n";
#define    all(a) (a).begin(), (a).end()
#define    fi first
#define    se second

template<class A, class B>
ostream& operator << (ostream& output, const pair<A, B>& p) {
    output << "(" << p.first << ", " << p.second << ")";
    return output;
}

template<class A>
ostream& operator << (ostream& output, const vector<A>& a) {
    output << "[";
    for(auto it = a.begin(); it != a.end(); ++it) {
        if(it != a.begin()) {
            output << ", ";
        }
        output << *it;
    }
    output << "]";
    return output;
}

using lld = long long;
using pii = pair<int, int>;
using pll = pair<lld, lld>;

//const int inf = 1e9;
//const int mod = 1e9 + 7;
//const double PI = acos(-1.0);
//const int mx = 1e5 + 5;



int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
#ifndef ONLINE_JUDGE
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
#endif // ONLINE_JUDGE

    int n, m;
    cin >> n >> m;
    vector<int> a(m);
    for(int i = 0; i < m; ++i) {
        cin >> a[i];
    }
    sort(all(a));
    vector<int> d(m - 1);
    for(int i = 1; i < m; ++i) {
        d[i - 1] = a[i] - a[i - 1];
    }
    sort(all(d), greater<int>());
    if(n >= m) {
        cout << 0 << endl;
    }
    else {
        int ans = a[m - 1] - a[0];
        for(int i = 0; i < n - 1; ++i) {
            ans -= d[i];
        }
        cout << ans << endl;
    }
    return 0;
}


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

#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif

const int inf=1e9;
const int64_t inf64=1e18;
const double eps=1e-9;

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

void solve(int h,int w){
    vector<string> vs(h);
    rep(i,0,h) cin >> vs[i];
    int dx[]={1,1,0,-1,-1,-1,0,1},dy[]={0,-1,-1,-1,0,1,1,1};
    set<string> st;
    vector<vector<bool>> used(h,vector<bool>(w));
    string s,ans;
    function<void(int,int,int)> dfs=[&](int y,int x,int i){
        if(st.find(s)!=st.end() and s.size()>=ans.size() and (s.size()>ans.size() or s<ans)) ans=s;
        st.insert(s);
        //rep(i,0,8){
        int ny=y+dy[i],nx=x+dx[i];
        if(ny==h) ny=0;
        if(ny<0) ny=h-1;
        if(nx==w) nx=0;
        if(nx<0) nx=w-1;
        if(used[ny][nx]) return;
        s.push_back(vs[ny][nx]);
        used[ny][nx]=true;
        dfs(ny,nx,i);
        s.pop_back();
        used[ny][nx]=false;
        //}
        return;
    };
    rep(y,0,h) rep(x,0,w) rep(i,0,8){
            s.push_back(vs[y][x]);
            used[y][x]=true;
            dfs(y,x,i);
            s.pop_back();
            used[y][x]=false;
    }

    if(ans.size()<2) cout << 0 << endl;
    else cout << ans << endl;
}
int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(10);
    for(;;){
        int h,w;
        cin >> h >> w;
        if(!h and !w) break;
        solve(h,w);
    }
    return 0;
}

Measured memory_bytes: 35812
#include<bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define mp make_pair
using namespace std;

using ll = long long;
using ii = pair<int, int>;
const int INF = (int)10e9;

vector<int> g[100005];
int dp[100005];

int N, M;

stack<int> ts;
bool vis[100005];

void dfs(int n) {
	if(!vis[n]) {
		vis[n] = true;
		for(int i = 0; i < g[n].size(); i++) dfs(g[n][i]);
		ts.push(n);
	}
}

int main() {
	std::ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	
	cin >> N >> M;
	
	for(int i = 0; i < M; i++){
		int a, b;
		cin >> a >> b;
		g[a].push_back(b);
	}
	
	for(int i = 1; i <= N; i++) {
		if(!vis[i]) dfs(i);
	}

	while(!ts.empty()) {
		int n = ts.top();
		for(int i = 0;i < g[n].size(); i++) dp[g[n][i]] = max(dp[g[n][i]], dp[n] + 1);
		ts.pop();
	}

	int res = 0;
	for(int i = 0; i <= N; i++) res = max(res, dp[i]);
	cout<<res<<endl;

    return 0;
}


Measured memory_bytes: 8064
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
static const LL INF = 1 << 31;
static const int MOD = 1e9 + 7;
static const int MAXN = 1e5 + 10;
LL inx[MAXN] , iny[MAXN] = {0};
int main()
{
    int n , m;
    scanf("%d%d" , &n , &m);
    for(int i = 1 ; i <= n ; ++i)
        scanf("%lld" , &inx[i]);
    for(int i = 1 ; i <= m ; ++i)
        scanf("%lld" , &iny[i]);
    LL sumx = 0 , sumy = 0;
    for(int i = 1 ; i <= n ; ++i)
        sumx = (sumx + ((i - 1) * inx[i] - (n - i) * inx[i]) % MOD) % MOD;
    for(int i = 1 ; i <= m ; ++i)
        sumy = (sumy + ((i - 1) * iny[i] - (m - i) * iny[i]) % MOD) % MOD;
    printf("%lld" , sumx * sumy % MOD);
}

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

int main(){
    int N, result;
    int P=0,W=0,G=0,Y=0;
    cin>>N;
    char *S = new char[N];

    for(int i;i<=N;i++){
        cin>>S[i];
        if(S[i]=='P') P=1; 
        if(S[i]=='W') W=1; 
        if(S[i]=='G') G=1; 
        if(S[i]=='Y') Y=1; 
    }

    result=P+W+G+Y;

    if(result==3){
    cout<<"Three"<<endl;
    }
    if(result==4){
    cout<<"Four"<<endl;
    }

    return 0;
}

Measured memory_bytes: 256
using System;
using static System.Console;

class Program
{
    public static void Main()
    {
	string s = ReadLine();
	int ans = 0;
	for (int i = 0; i < 3; i++)
	{
	    if (s[i] == '1'){ ans++; }
	}
	WriteLine(ans);
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
#include <math.h>
#include <cmath>

using namespace std;
using ll =long long;
using vi = vector<int>; 
using vvi = vector<vi>; 
using vl = vector<ll>; 
using vvl = vector<vl>; 
using vs = vector<string>;
using vvs = vector<vs>; 
using vc = vector<char>;
using vvc = vector<vc>; 
using vb = vector<bool>;
using vvb = vector<vb>; 

#define rep(i,n) ;for( int i =0; i < n ; i ++)
#define all(a) a.begin(),a.end()
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define f(i,a,b) for(int i=a;i<b;i++)
#define pri(a)  printf("%.14lf\n",a);
#define MOD 1000000007
bool is_int_lround(double x){
  return std::lround(x)==x;
}
ll keta(ll x){
  ll n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}

ll conbi(int n,int m){
  
  cin>>n>>m;
  vector<ll> a(100);
  a[0] =1;
  for(int i=0;i<14;i++){
    a[i+1]=a[i]*(i+1);
  }
  return a[n] /(a[m] *a[n-m]);
}

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;
}
ll kaijoMOD(ll x){
  ll z=1;
  if(x==0){
    return 1;
  }
  while(x>0){
    z *=x;
    z %=MOD;
    x--;
  }
  return z;
}
ll yakusu_num(ll n){
  vl yakusu(n+1,1);
  for(ll i=2;i*i<=n;i++){ 
    while(n%i==0){
      n /=i;
      yakusu[i]++;
    }
  }
  if(n!=1)yakusu[n]++;
  ll num=1;
  for(ll i=0;i<=n;i++){
    num*=yakusu[i];
  }
  return num;
}

int H,W;
vs s(50);
vi dv ={-1,0,1,0};vi du={0,-1,0,1};
int cnt=1;
int dfs(int u,int v){
  s[u][v]='.';
  
  rep(i,4){
   
      int nu =u +du[i],nv=v+dv[i];
      if(nu<0||nu>=H||nv<0||nv>=W)continue;
      if(s[nu][nv]=='.')continue;
      cnt ++;
      dfs(nu,nv);
    
  }
  return cnt;

}
int keta_wa(int x){
  int tot=0;
  while(x>0){
    tot +=x%10;
    x/=10;
  }
  return tot;
}

//vc alp ={'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'};
//cout<<""<<endl;
int main(){
 string A,B,C;cin>>A>>B>>C;
 if(A[A.size()-1]==B[0] &&B[B.size()-1] ==C[0])cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
}





Measured memory_bytes: 256
N, K = map(int, input().split())

nums = {}
for i in range(N):
    a,b = map(int, input().split())
    nums[a] = nums.get(a, 0) + b

keys = list(nums.keys())
keys.sort()

ans = 0
for key in keys:
    if K <= nums[key]:
        ans = key
        break
    else:
        K -= nums[key]

print(ans)

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

int main(){
  int n,m,X,Y,i;
  cin>>n>>m>>X>>Y;
  int x[n],y[m];
  for(i=0;i<n;i++){
    cin>>x[i];
  }
  for(i=0;i<m;i++){
    cin>>y[i];
  }
  sort(x,x+n);
  sort(y,y+m);
  for(i=-100;i<101;i++){
  	if(X<i && i<=Y && x[n-1]<i && i<=y[0]){
      cout<<"No War";
      return 0;
    }
  }
  cout<<"War";
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {

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

    ArrayList<Integer> aList = new ArrayList<Integer>();
    for(int i = 0;i < n;i++) {
      aList.add(sc.nextInt());
    }
    Collections.sort(aList);
    int max = Collections.max(aList);
    boolean[] bArray = new boolean[max+1];

    for(int i = 0;i < max+1 ; i++) {
        bArray[i] = true;
    }

    int num = 0;
    for(int i :aList) {
      if(bArray[i]) {
        if(num != n-1 && i == aList.get(num+1)) {
          bArray[i] = false;
        }
        for(int j = i*2;j <= max; j += i) {
          bArray[j] = false;
        }
      }
      num++;
    }

    int cnt = 0;
    for(int i :aList) {
      if(bArray[i]) {
        cnt++;
      }
    }
    System.out.println(cnt);
    }
}


Measured memory_bytes: 64768
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) {
        try {
            // 標準入力
            InputStreamReader isr = new InputStreamReader(System.in);
            BufferedReader br = new BufferedReader(isr);
            int n = Integer.parseInt(br.readLine());
            String str[] = br.readLine().split(" ");
            int arr[] = new int[100000];
            for (int i = 0; i < n; i++) {
                int temp = Integer.parseInt(str[i]);
                arr[temp]++;
            }
            int max = 0;
            for (int i = 0; i < 100000; i++) {
                int check = 0;
                if (i == 0) {
                    check = arr[i] + arr[i + 1];
                } else if (i == 100000 - 1) {
                    check = arr[i - 1] + arr[i];
                } else {
                    check = arr[i - 1] + arr[i] + arr[i + 1];
                }
                if (check > max) {
                    max = check;
                }
            }
            System.out.println(max);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}


Measured memory_bytes: 35668
#include<cstdio>
#include<algorithm>
using namespace std;
const int maxn=200005;
const int mod = 998244353;
int dp[maxn],n,k,l[12],r[12];
int main()
{
    scanf("%d%d",&n,&k);
    for (int i = 0; i < k; i++)
        scanf("%d%d",l+i,r+i);
    dp[1]=1;
    for (int i = 1; i < n; i++)
    {
        for (int j = 0; j < k; j++)
        {
            if (i + l[j] > n)
                continue;
            dp[i + l[j]] = (dp[i + l[j]] + dp[i]) % mod;
            dp[min(i + r[j] + 1, n + 1)] = (dp[min(i + r[j] + 1, n + 1)] - dp[i] + mod) % mod;

        }
        if(i>1)
            dp[i+1]= (dp[i+1] + dp[i]) % mod;
    }
    printf("%d\n",dp[n]);
    return 0;
}

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

 
int main(){

 
    long double A,B,H,M;
    cin >> A >> B >> H >> M;
    long double pi = 3.1415926535;
 
 
    long double theta = abs(0.5*(60*H-11*M)*pi/180);
    long double result;
 
    
        result = sqrt(pow(A,2) + pow(B,2) - 2 * A * B * cos(theta));
    
    cout << fixed << setprecision(15) << result;
}

Measured memory_bytes: 4164
#include <bits/stdc++.h>
    #define REP(i, n) for(int i = 0;i < n;i++)
    #define REPR(i, n) for(int i = n;i >= 0;i--)
    #define FOR(i, m, n) for(int i = m;i < n;i++)
    #define FORR(i, m, n) for(int i = m;i >= n;i--)
    #define SORT(v, n) sort(v, v+n);
    #define VSORT(v) sort(v.begin(), v.end());
    #define llong long long
    #define pb(a) push_back(a)
    #define INF 999999999
    using namespace std;
    typedef pair<int, int> P;
    typedef pair<llong, llong> LP;
    typedef pair<int, P> PP;
    typedef pair<llong, LP> LPP;

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

    int main()
    {
       int a,b,c;
       cin>>a>>b>>c;
       bool ans=false;
       for(int i=a; i<=a*b; i++)
       {
           if(i%a==0&&i%b==c) {
               ans=true;
               break;
           }
       }
       if(ans) cout<<"YES"<<endl;
       else cout<<"NO"<<endl;
    }



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

using namespace std;

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    fill( (T*)array, (T*)(array+N), val );
}

int main() {
    int n, b, f, r, v, state[4][3][10];
    Fill(state, 0);
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> b >> f >> r >> v;
        b--, f--, r--;
        state[b][f][r] += v;
    }
    for (int i = 0; i < 4; ++i) {
        for (int j = 0; j < 3; ++j) {
            for (int k = 0; k < 10; ++k) {
                cout << ' ' << state[i][j][k];
            }
            cout << endl;
        }
        if (i == 3) break;
        for (int j = 0; j < 20; ++j) cout << '#';
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3088
/* cerberus97 - Hanit Banga */

#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>

using namespace std;

#define pb push_back
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)

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

const int N = 2e5 + 10;

struct edge {
	int u, v; ll w;
	bool operator<(const edge &o) const {
		return w < o.w;
	}
};

int a[N], sz[N], par[N];
vector<edge> edges;

bool merge(int u, int v);
int get_root(int u);

int main() {
	fast_cin();
	int n; ll d;
	cin >> n >> d;
	for (int i = 1; i <= n; ++i) {
		cin >> a[i];
		sz[i] = 1;
		par[i] = i;
	}
	priority_queue<pll, vector<pll>, greater<pll>> q;
	for (int i = 1; i <= n; ++i) {
		while (!q.empty()) {
			int j = q.top().second;
			if (a[j] > a[i]) {
				q.pop();
				continue;
			} else {
				edges.pb({i, j, a[i] + a[j] + d * (i - j)});
				break;
			}
		}
		q.push({a[i] - d * i, i});
	}
	while (!q.empty()) {
		q.pop();
	}
	for (int i = n; i >= 1; --i) {
		while (!q.empty()) {
			int j = q.top().second;
			if (a[j] > a[i]) {
				q.pop();
				continue;
			} else {
				edges.pb({i, j, a[i] + a[j] + d * (j - i)});
				break;
			}
		}
		q.push({a[i] + d * i, i});
	}
	sort(edges.begin(), edges.end());
	ll ans = 0;
	for (auto &e : edges) {
		if (merge(e.u, e.v)) {
			ans += e.w;
		}
	}
	cout << ans;
}

bool merge(int u, int v) {
	u = get_root(u);
	v = get_root(v);
	if (u == v) {
		return false;
	}
	if (sz[u] < sz[v]) {
		swap(u, v);
	}
	sz[u] += sz[v];
	par[v] = u;
	return true;
}

int get_root(int u) {
	if (par[u] != u) {
		par[u] = get_root(par[u]);
	}
	return par[u];
}

Measured memory_bytes: 16548
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
const int INF = (int)1e9 + 7;

int main() {
    int n, m; cin >> n >> m;
    vector<int> d(m);   // denominations
    for (int i = 0; i < m; i++) cin >> d[i];

    vector<int> dp(n + 1, INF);
    dp[0] = 0;
    for (int i = 0; i < m; i++) {
        for (int j = 0; j + d[i] <= n; j++) {
            dp[j + d[i]] = min(dp[j + d[i]], dp[j] + 1);
        }
    }
    cout << dp[n] << endl;
    return 0;
}


Measured memory_bytes: 3172
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<ll, P> P3;
typedef pair<P, P> PP;
constexpr ll MOD = ll(1e9 + 7);
constexpr int IINF = INT_MAX;
constexpr ll LLINF = LLONG_MAX;
constexpr int MAX_N = int(1e5) + 5;
constexpr double EPS = 1e-9;
constexpr int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#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 SORTR(v) sort((v).rbegin(), (v).rend())
#define ALL(v) (v).begin(), (v).end()

int64_t power(int64_t x, int64_t n) {
    int64_t ans = 1;
    while (n > 0) {
        if ((n & 1) == 1) {
            ans = ans * x % MOD;
        }
        x = x * x % MOD;  //一周する度にx, x^2, x^4, x^8となる
        n >>= 1;          //桁をずらす n = n >> 1
    }
    return ans;
}

ll n, k, ans = 0;
vector<ll> a;

int main() {
    cin >> n >> k;
    a.resize(n);
    REP(i,n){
        cin >> a[i];
    }
    for(int i=0;i<n;i++){
        ll cnt = 0;
        for(int j=i+1;j<n;j++){
            if(a[i] > a[j]) cnt++;
        }
        ans += cnt*k % MOD;
        ans %= MOD;
    }
    SORT(a);
    for(int i=0;i<n;i++){
        ll cnt = n - (upper_bound(ALL(a), a[i]) - a.begin());
        ans += cnt * k%MOD*(k-1)%MOD*power(2,MOD-2)%MOD;
        ans %= MOD;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import time
startTimeProblem=time.time()

import fileinput, sys, itertools, functools
from math import *
from bisect import *
from heapq import *
from collections import *

def lcm(a, b):  
    return (a*b)/gcd(a, b)

class InputHelper:
    def __init__(self):
        self.myinput = fileinput.input()

    def isLocal(self):
        return not fileinput.isstdin()

    def int(self):
        return int(self.myinput.readline().rstrip())

    def ints(self):
        return [int(_) for _ in self.myinput.readline().rstrip().split()]

    def str(self):
        return self.myinput.readline().rstrip()

    def strs(self):
        return [_ for _ in self.myinput.readline().rstrip().split()]

class OutputHelper:
    def int(self, a):
        print(a)    

    def ints(self, a):  
        print(" ".join([str(_) for _ in a]))
    
    def intsNL(self, a):
        for _ in a:
            print(_)
    
    def str(self, s):
        print(s)

    def strs(self, s):
        print(" ".join([_ for _ in s]))

    def strsNL(self, s):
        for st in s:
            print(st)

class ListNode:
    def __init__(self, val):
        self.val = val
        self.next = None
        self.prev = None

In = InputHelper()
Out = OutputHelper()

######################################

X, K, D = In.ints()

X = abs(X)

howManyTimesDinX = X//D

if howManyTimesDinX > K:
    Out.int(X-K*D)
else:
    X = X-howManyTimesDinX*D
    K -= howManyTimesDinX

    if K%2==0:
        Out.int(X)
    else:
        X-=D
        X=abs(X)
        Out.int(X)
    


######################################

if len(sys.argv)>2 and sys.argv[2]=="TIMEIT":
    fin = (time.time()-startTimeProblem)*1000
    print("{:.2f}".format(fin) + "ms")

Measured memory_bytes: 68060
N = int(input())
A = input()
B = input()
C = input()
ans = 0
for i in range(N):
    if (A[i] is B[i]) & (A[i] is C[i]):
        ans += 0
    elif (A[i] is B[i]) | (B[i] is C[i]) | (A[i] is C[i]):
        ans += 1
    else:
        ans += 2
print(ans) 

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

using namespace std;

typedef long long int ll;

const int N = 2e5 + 5;

vector < int > parent (N);

int find (int u) {
  if (parent[u] == u) return u;
  return parent[u] = find (parent[u]);
}

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

  for (int i = 0; i < N; i++) parent[i] = i;

  int n, q;
  cin >> n >> q;
  vector < pair < int, pair < int, int > > > vec;
  for (int i = 0; i < n; i++) {
    int s, t, x;
    cin >> s >> t >> x;
    vec.push_back ({x, {s, t}});
  }

  sort (vec.begin(), vec.end());

  vector < int > d (q), ans (q, -1);
  for (auto &i : d) cin >> i;

  for (int i = 0; i < n; i++) {
    int x = vec[i].first, s = vec[i].second.first, t = vec[i].second.second;
    int idx = lower_bound (d.begin(), d.end(), s - x) - d.begin();
    idx = find (idx);
    while (idx < q) {
      if (s <= x + d[idx] && x + d[idx] < t) {
        ans[idx] = x;
        parent[idx] = idx + 1;
        idx++;
        if (idx >= q) break;
        idx = find (idx);
      } else {
        break;
      }
    }
  }

  for (auto i : ans) cout << i << '\n';
}


Measured memory_bytes: 10108
# -*- coding: utf-8 -*-
"""
https://beta.atcoder.jp/contests/abc079/tasks/abc079_d
AC
"""
import sys
from sys import stdin
input = stdin.readline


def warshallFloyd(V, dp):
    for k in range(V):
        for i in range(V):
            for j in range(V):
                if dp[i][k] + dp[k][j] < dp[i][j]:
                    dp[i][j] = dp[i][k] + dp[k][j]


def main(args):
    H, W = map(int, input().split())
    dp = []
    for i in range(10):
        temp = [int(x) for x in input().split()]
        dp.append(temp)

    warshallFloyd(10, dp)

    costs = [dp[i][1] for i in range(10)]
    total_cost = 0
    for _ in range(H):
        for i in map(int, input().split()):
            if i != -1:
                total_cost += costs[i]
    print(total_cost)


if __name__ == '__main__':
    main(sys.argv[1:])


Measured memory_bytes: 3444
n=int(input())
s=input()
w=s.count('W')
a=[0]*n
for i in range(n):
    p=1 if s[i]=='W' else 0
    if i==0:a[0]=p
    else:a[i] = a[i-1]+p
r=min(min(n-i-1-w+2*a[i]for i in range(n)),n-w)
print(r)

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

int main()
{
	long n, a, b; cin>>n>>a>>b;
	vector<int> h(n);
	for(int& e: h) cin>>e;

	auto x=1L<<30;
	auto res=2L*x-1;
	for(; x; x>>=1) {
		auto t=res-x;
		auto d=0L;
		for(int e: h)
			d+=(max(0L, e-t*b)+a-b-1)/(a-b);
		if (d<=t) res=t;
	}
	cout<<res<<endl;
}



Measured memory_bytes: 640
#include<stdio.h>
long long int max(long long int a, long long int b) {
  if (a >= b) return a;
  else return b;
}
int main() {
  int i, j, N;
  long long int n, k;
  int sum[5000];
  while (1) {
    n = -100001;
    scanf("%d", &N);
    if(!N) break;
    for (i = 0; i < N; i ++) scanf("%d", &sum[i]);
    for (i = 0; i < N; i ++) {
      k = 0;
      for (j = i; j < N; j ++) {
	k += sum[j];
	n = max(n, k);
      }
    }
    printf("%lld\n", n);
  }
  return 0;
}

Measured memory_bytes: 620
#include<bits/stdc++.h>
using namespace std;
int const MAXN=110, MAXW=100100;
#define ll long long int
int n, k, w[MAXN], v[MAXN];
ll memo[MAXN][MAXW];
ll dp(int i, int space){
	if(i==n)
		return 0;
	if(memo[i][space]!=-1)
		return memo[i][space];
	ll ans=dp(i+1,space); //sklpping this elemnt
	if(space+w[i]<=k)
		ans=max(ans,v[i]+dp(i+1,space+w[i]));
	return memo[i][space]=ans;
	
}
int main(){
	cin>>n>>k;
	for(int i=0;i<n;i++)
		cin>>w[i]>>v[i];
	for(int i=0;i<n;i++)
		for(int j=0;j<=k;j++)
			memo[i][j]=-1;
	cout<<dp(0,0);
}



Measured memory_bytes: 80128
#include<bits/stdc++.h>
#define ll long long 
#define pb push_back
#define endl '\n'
#define ff first
#define ss second
#define pi pair<int,int>
using namespace std;
int main(){
	ios_base::sync_with_stdio(0) ; 
	cin.tie(0) ;
	int k  ;
	cin>> k  ;
   ll ans = 0 ; 
     for(int i = 1 ; i <= k ; ++i){
		 for(int j = 1; j <=  k ; ++j){
			 for(int x = 1  ; x <= k ; ++x){
				 ans = ans + __gcd(i , __gcd(j , x)) ; 
        }
	}
  }
  cout<<ans<<endl;
 
 
 
  
  
  
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5+10;
vector<int>G[MAXN];
int step1[MAXN], step2[MAXN];
bool vis1[MAXN], vis2[MAXN];
int n, s1, s2, u, v;
void bfs(int k) {
    if (k == s1) {
        queue<int>q;
        q.push(k);
        step1[k] = 0;
        vis1[k] = true;
        while (!q.empty()) {
            int a = q.front();
            q.pop();
            for (int b : G[a]) {
                if (!vis1[b]) {
                    step1[b] = step1[a] + 1;
                    vis1[b] = true;
                    q.push(b);
                }
            }
        }
    }
    else if (k == s2) {
        queue<int>q;
        q.push(k);
        step2[k] = 0;
        vis2[k] = true;
        while (!q.empty()) {
            int a = q.front();
            q.pop();
            for (int b : G[a]) {
                if (!vis2[b]) {
                    step2[b] = step2[a] + 1;
                    vis2[b] = true;
                    q.push(b);
                }
            }
        }
    }
}
int main() {
    memset(vis1, false, sizeof(vis1));
    memset(vis2, false, sizeof(vis2));
    memset(step1, 0, sizeof(step1));
    memset(step2, 0, sizeof(step2));
    cin >> n >> s1 >> s2;
    for (int i = 0; i < n - 1; i++) {
        scanf("%d%d", &u, &v);
        G[u].push_back(v);
        G[v].push_back(u);
    }
    bfs(s1);
    bfs(s2);
    int ans = 0;
    for (int i = 1; i <= n; i++) {
        if (step1[i] < step2[i]) ans = max(ans, step2[i]);
    }
    cout << ans - 1;
    return 0;
}


Measured memory_bytes: 10220
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,A;
  A=0;
  cin>>N;
  for(int i=1;i<10;i++){
    for(int j=1;j<10;j++){
      if(i*j==N)A=1;
    }
  }
  if(A==0)cout<<"No"<<endl;
  else if(A==1) cout<<"Yes"<<endl;
  
    
  
}


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

int n,k;
vi a;

int main(){
	cin>>n>>k;
	a=vi(n);
	for(int i=0;i<n;i++) cin>>a[i];
	sort(a.rbegin(),a.rend());
	int res=0;
	for(int i=0;i<k;i++) res+=a[i];
	cout<<res<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define RI(X) scanf("%d", &(X))
#define RII(X, Y) scanf("%d%d", &(X), &(Y))
#define RIII(X, Y, Z) scanf("%d%d%d", &(X), &(Y), &(Z))
#define DRI(X) int (X); scanf("%d", &X)
#define DRII(X, Y) int X, Y; scanf("%d%d", &X, &Y)
#define DRIII(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)
#define RS(X) scanf("%s", (X))
#define CASET int ___T, case_n = 1; scanf("%d ", &___T); while (___T-- > 0)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define PII pair<int,int>
#define VI vector<int>
#define VL vector<long long>
#define VPII vector<pair<int,int> >
#define PLL pair<long long,long long>
#define VPLL vector<pair<long long,long long> >
#define F first
#define S second
typedef long long LL;
using namespace std;
const int MOD = 1e9+7;
const int SIZE = 1e6+10;
int main(){
    map<int,int>H;
    DRI(N);
    REP(i,N){
        DRI(x);
        H[x]++;
    }
    RI(N);
    REP(i,N){
        DRI(x);
        H[x]--;
        if(H[x]<0)return 0*puts("NO");
    }
    return 0*puts("YES");
}


Measured memory_bytes: 9600
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr = input.split("\n");
var arr = (Arr[1]).split(" ").map(Number);
var min = arr.reduce(function(a, b){ return Math.min(a,b); } );
var max = arr.reduce(function(a, b){ return Math.max(a,b); } );
var sum = arr.reduce(function(a, b){ return a+b; } );
console.log(min + " " + max + " " + sum);


Measured memory_bytes: 18172
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<string>
#include<numeric>
#include<set>
#include<math.h>
using namespace std;

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

    vector<int> L(N);
    for(int i = 0; i < N; i++) cin >> L[i];

    int cnt = 1;
    int P = 0;

    for(int i = 0; i < N; i++){
        P += L[i];
        if(P <= X) cnt++;
        else break;
    }

    cout << cnt << endl;

    return 0;
}

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

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

  int A, B;
  cin >> A >> B;
  if(A+B >= 10) cout << "error" << endl;
  else cout << A+B << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>   // By Vineet kumar on 09/05/2020
using namespace std;
#define endl "\n"
#define ll long long 
void solve(){
	string s;
	cin>>s;
	deque<char>d(begin(s),end(s));
	ll q;
	cin>>q;
	bool is_reverse=false;
	for(int i=0;i<q;i++){
		ll t;
		cin>>t;
		if(t==1){
			is_reverse=!is_reverse;
		}
		else{
			int f;
			char c;
			cin>>f>>c;
			if(f==1&&is_reverse ||f==2&&!is_reverse){
				d.push_back(c);
			}
			else{
				d.push_front(c);
			}
		}
	}
	if(is_reverse){
		reverse(begin(d),end(d));
	}
	copy(begin(d),end(d),ostreambuf_iterator<char>(cout));
	cout<<endl;
}
int main() {
	// your code goes here
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	solve();
	return 0;
}

Measured memory_bytes: 976
#include <stdio.h>
#include <stdlib.h>
int main(){
  int N,K,i,j,d,x,count;
  int A[101];
  for(i=0;i<101;i++) A[i]=0;
  scanf("%d %d",&N,&K);
  count=N;
  for(i=0;i<K;i++){
    scanf("%d",&d);
    for(j=0;j<d;j++){
      scanf("%d",&x);
      if(A[x-1]==0){
        A[x-1]=1;
        count--;
      }
    }
  }
  printf("%d",count);
  return 0;
}

Measured memory_bytes: 1732
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
#define pb push_back
#define sz(i) (int)(i.size())
#define F first
#define S second
#define L long double
#define P pair<int, int>
const int inf = 0x3f3f3f3f3f3f3f3LL;
const int mod = (int)1e9 + 7;
using namespace std;
#if LOCAL
#include "../../tr.h"
#else
#define tr(...)
#define endl '\n'
#endif
template<class T> void smin(T& a, T val) {if (a > val) a = val;}template<class T> void smax(T& a, T val) {if (a < val) a = val;}
const int N = 5*(int)1e5 + 10;

int n, a, b, c;
int vals[500];

int32_t main(){_

   cin>>a>>b>>c;

   for (int i = a; i <= 100; i+=a)
   {
      vals[i] += b;
   }
   
   for (int i = 1; i <= 100; ++i)
   {
      vals[i] += vals[i-1];
   }

   cout<<vals[c];

   return 0;
}

// Common sense: do smth instead of nothing
// Even a single second counts...
// If other's can do it, even I can do it. It wouldn't be that tough. Let me give it a try.
// Mistakes made in past
// -Ques. ask for max-min => think binary_search, DP, greedy
// -not reading question properly / skipping to read & understand all samples properly & wasting time in wrong direction.
// -Using wrong indexing in nested loops something like a[i], when it is supposed to be a[j](WA)
// -value of const int N is not correct (WA/RTE).
// -Did you memset dp to -1 ?
// -check for small edges cases and work on small test cases manually if WA
// -not deallocating memory to pointers can lead to MLE. Use delete :))
// -not reading problem statements of harder problems E,..., thinking it couldn't be solved, but it isn't the case.
// -Avoid using #define int long long as much as possible when it's dp problem and requires high memory say, O(N^2, N=5000) (MLE)
// -Check Bitwise Operator Precedence 
// -Use pragmas to optimize (by constant factor) when necessary..
// -Think before coding & starting to debug. Have patience to look inside code and actually see how it works

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))

ans = []

is_up = False
is_down = False
for i in range(n):
    if i == 0:
        ans.append(a[i])
        continue
    if is_up:
        if a[i - 1] <= a[i]:
            continue
        else:
            ans.append(a[i - 1])
            is_up = False
            is_down = True
    elif is_down:
        if a[i - 1] >= a[i]:
            continue
        else:
            ans.append(a[i - 1])
            is_up = True
            is_down = False
    else:
        if a[i - 1] < a[i]:
            is_up = True
        elif a[i - 1] > a[i]:
            is_down = True
ans.append(a[-1])

res = 1000
money = 1000
stock = 0
ans.append(-1)

for i in range(len(ans) - 1):
    if ans[i] < ans[i + 1]:
        stock += money // ans[i]
        money -= (money // ans[i]) * ans[i]
    elif ans[i] > ans[i - 1]:
        money += stock * ans[i]
        stock = 0
        res = max(res, money)
print(res)

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

int main()
{
    string S,T;
    cin>>S>>T;
    int a=S.size();
    for(int i=0;i<a;i++)
    {
        if(S[i]!=T[i])
        {
            cout<<"No";
            return 0;
        }
    }
    cout<<"Yes";
}

Measured memory_bytes: 3620