akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define LL long long
#define mp make_pair
#define pb push_back
#define VI vector<int>
#define pii pair<int,int>
using namespace std;
set<int> app[30];
const int MAXN = 5e5;
char S[MAXN+10];
int n, q;
char Q[2];
void q1(){
	int p;
	scanf("%d %s", &p, Q);
	char v = Q[0];
	p--;

	app[S[p]-'a'].erase(p);
	S[p] = v;
	app[S[p]-'a'].insert(p);
}

int q2(){
	int l, r;
	scanf("%d %d", &l, &r); l--; r--;
	int tot = 0;
	for(int i = 0; i < 26; i++){
		auto lb = app[i].lower_bound(l);
		if(lb != app[i].end() && *lb <= r) tot++;
	}
	return tot;
}
int main(){
	scanf("%d %s %d", &n, S, &q);
	for(int i = 0; i < n; i++){
		app[S[i]-'a'].insert(i);
	}
	for(int i = 0; i < q; i++){
		int qi;
		scanf("%d", &qi);
		if(qi == 1) q1();
		else printf("%d\n", q2());
	}
	return 0;
}

Measured memory_bytes: 26240
//#include <bits/stdc++.h>
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <climits>
#include <iomanip>
#include <regex>


#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define ROF(i, j, k) for(int i = (int)(j); i >= (int)(k); --i)
#define FORLL(i, n, m) for(long long i = n; i < (long long)(m); i++)
#define SORT(v, n) sort(v, v+n)
#define REVERSE(v) reverse((v).begin(), (v).end())

using namespace std;
using ll = long long;
const ll MOD=1000000007LL;
typedef pair<int, int> P;

ll ADD(ll x, ll y) { return (x+y) % MOD; }
ll SUB(ll x, ll y) { return (x-y+MOD) % MOD; }
ll MUL(ll x, ll y) { return x*y % MOD; }
ll POW(ll x, ll e) { ll v=1; for(; e; x=MUL(x,x), e>>=1) if (e&1) v = MUL(v,x); return v; }
ll DIV(ll x, ll y) { /*assert(y%MOD!=0);*/ return MUL(x, POW(y, MOD-2)); }

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;}


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

  string s;
  cin >> s;

  if(regex_match(s, regex("A?KIHA?BA?RA?"))) cout << "YES" << endl;
  else cout << "NO" << endl;

  return 0;
}


Measured memory_bytes: 384
<?php
while ($g = rtrim(fgets(STDIN))){ 
    $a = preg_split("/[\s,]+/", $g);
    // print_r($a);
    //あなたのカード合計
    $player_sum = $a[0] + $a[1];
    // print_r($player_sum);
    //20までの数字
    $player_left = 20 - $player_sum;
    // print $player_left;
    //相手カード
    // print $player_left;
    // print 'pl';
    // print PHP_EOL;
    $opponent_card = $a[2];
    // print $a[2];
    //残りのカード
    $card_all = [];
    for ($i=1; $i <= 10 ; $i++) {
        if ($i == $a[0]){
            $card_all[] = 0;
        } else if ($i == $a[1]){
            $card_all[] = 0;
        } else if ($i == $a[2]){
            $card_all[] = 0;
        } else {
            $card_all[] = $i;
        }
    }
    // print_r($card_all);
    // 各残りのカードが$player_leftより小さいか等しい数を数える。
    $count = 0;
    for ($i=0; $i < 10 ; $i++) { 
        if($card_all[$i] <= $player_left && $card_all[$i] !== 0){
            $count++;
        }
    }
    if ($count >= 4){
        print 'YES';
    } else {
        print 'NO';
    }
    print PHP_EOL;
    // $countが４以上であったら、Yes, それ以外はNoにする。

}


Measured memory_bytes: 9380
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define endl "\n"
#define se second
#define ls( s) (s&(-s))
#define ll long long
#define inf 0x3f3f3f3f
const ll N = 500030;
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
const ll mod =    1e9+7;
ll n,t;
ll arr[N];
ll mn[N],mx[N];
int main()
{
		ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	cin>>n>>t;
	rep(i,0,n)
	cin>>arr[i];
	ll mxx=arr[n-1];
ll mnn=arr[0];
	rep(i,n-1,0)
	{
		mn[i]=max(0ll,mxx-arr[i]);
		mxx=max(mxx,arr[i]);
	}
	rep(i,1,n)
	{
		mx[i]=max(0ll,arr[i]-mnn);
		mnn=min(mnn,arr[i]);
	}

	sort(mn,mn+n-1);

	sort(mx,mx+n);

	int cnt=n-2,c1=n-1;
	while(cnt>=00&&mn[cnt]==mn[n-2])
	cnt--;
	while(c1>=0&&mx[c1]==mx[n-1])
	c1--;
	cout<<min(n-2-cnt,n-1-c1);
	
}

Measured memory_bytes: 9216
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include <cassert>
#include <cmath>
#include<cstdint>

#define INF 1e9
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<int,int>;

vector<int>bitSearch(int bit,int n){
    vector<int>S;
    rep(i,n)if(bit&(1<<i))S.push_back(i);
    return S;
}


int dy[2] = {1,0};
int dx[2] = {0,1};
int h,w;
vector<string>s(10);

int main(){
    string s;cin>>s;
    if(s.size() != 26){
        vector<int>C(26, 0);
        for(char c : s){
            C[c - 'a']++;
        }
        char cc;
        rep(i, C.size()){
            if(C[i] == 0){
                cout << s + char('a' + i) << endl;
                return 0;
            }
        }
        cout << s + 'z' << endl;
    }
    else {
        string t = s;
        if(next_permutation( ALL(s) )){
            rep(i, s.size()){
                if(s[i] == t[i])cout << t[i];
                else{
                    cout << s[i] << endl;
                    return 0;
                }
            }
        }
        else cout << -1 << endl;
    }
}



Measured memory_bytes: 256
/* Simplicity and Goodness */
 
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>

// using namespace __gnu_pbds;
using namespace std;
// typedef tree<int, null_type, less<int>, rb_tree_tag,
//             tree_order_statistics_node_update> indexed_set;

void my_dbg() { cout << endl; }
template<typename Arg, typename... Args> void my_dbg(Arg A, Args... B) 
{ cout << ' ' << A; my_dbg(B...); }
#define dbg(...)  cout << "(" << #__VA_ARGS__ << "):", my_dbg(__VA_ARGS__)

#define scn(n) scanf("%d", &n)
#define lscn(n) scanf("%lld", &n)
#define pri(n) printf("%d ", (int)(n))
#define prin(n) printf("%d\n", (int)(n))
#define lpri(n) printf("%lld ", n)
#define lprin(n) printf("%lld\n", n)
#define rep(i,a,b) for(int i=(int)(a); i<(int)(b); i++)
#define pb push_back
#define mp make_pair
#define F first
#define S second

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;

const int inf = INT_MAX;
const int ninf = INT_MIN;
const int mod = 1e9+7;
const int N = 2e5+2;


void solve()
{   
    string s;
    cin >> s;

    int ans = (int) 1e9;

    for(char c = 'a'; c <= 'z'; c ++) {
        string w = s;
        for(int it = 0; ; it ++) {
            if(w.empty()) {
                break;
            }
            if(w == string(w.size(), c)) {
                ans = min(ans, it);
                break;
            }
            string nw = "";
            for(int i = 0; i < (int) w.size() - 1; i ++) {
                if(w[i] == c || w[i+1] == c) {
                    nw += c;
                } else {
                    nw += w[i];
                }
            }
            w = nw;
        }
    }

    prin(ans);
}

int main()
{
    int t = 1;
    // scn(t);

    while(t --) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3696
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;
 
int main() {
    int X, A; cin >> X >> A;
    if(X < A) cout << 0 << endl;
    else cout << 10 << endl;
    return 0;
}


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

using namespace std;

map< vector< int >, int > dp;

int M, N;
int bit[128];

int rec(vector< int > idx, int v)
{
  if(dp.count(idx)) return (dp[idx]);
  if(idx.size() <= 1) return (0);
  int ret = 1333;
  for(int i = 0; i < M; i++) {
    if((v >> i) & 1) continue;
    vector< int > latte, malta;
    for(int j : idx) ((bit[j] >> i) & 1 ? latte : malta).push_back(j);
    ret = min(ret, max(rec(latte, v | (1 << i)), rec(malta, v | (1 << i))) + 1);
  }
  return (dp[idx] = ret);
}

int main()
{
  while(cin >> M >> N, M) {
    for(int i = 0; i < N; i++) {
      string S;
      cin >> S;
      bit[i] = 0;
      for(int j = 0; j < M; j++) bit[i] |= (S[j] == '1') << j;
    }
    vector< int > idx(N);
    for(int i = 0; i < N; i++) idx[i] = i;
    dp.clear();
    cout << rec(idx, 0) << endl;
  }

}

Measured memory_bytes: 5320
S = input()
N = len(S)
MOD = 10**9 + 7

# dp[i+1][j] : 左からi番目の文字まで見たときに、13で割ってj余る場合の数
dp = [[0 for _ in range(13)] for _ in range(N+1)]
dp[0][0] = 1


"""
数字がabcで並んでいて、それを13で割った時の余りがpのときに、末尾にdが追加されると、
abcd = abc * 10 + d だから、これを13で割った余りは、 p*10 % 13 + d % 13 = (10 * p + d) % 13

"""

for i in range(N):
    for j in range(13):
        if S[i] == "?":
            # 0~9
            for n in range(10):
                dp[i+1][(10 * j + n) % 13] += dp[i][j]
                if dp[i+1][(10 * j + n) % 13] >= MOD:
                    dp[i+1][(10 * j + n) % 13] %= MOD
        else:
            dp[i+1][(10 * j + int(S[i])) % 13] += dp[i][j]
            if dp[i+1][(10 * j + int(S[i])) % 13] >= MOD:
                dp[i+1][(10 * j + int(S[i])) % 13] %= MOD


print(dp[-1][5])



Measured memory_bytes: 66396
# B - Shift Only
"""
import sys
import clipboard

# テストケースが複数行の場合、iOSだと一気に読み込んでしまうので
# 1行ずつ読み込むように、テキストファイルにいったんコピーする
if sys.platform == 'ios':
	sample = clipboard.get()
	file = open('input_file.txt', 'w')
	file.write(sample)
	file.close()
	sys.stdin = open('input_file.txt')
"""		
						
input()
A = list(map(int, input().split()))
count = 0
while all(a % 2 == 0 for a in A):
    A = [a/2 for a in A]
    count += 1
print(count)

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

/* short */
#define pb push_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) begin(v), end(v)
#define RALL(v) rbegin(v), rend(v)

/* REPmacro */
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define REP(i, n) for(int i = 0; i < (n); i++)
#define FOREACH(x, a) for(auto x : a)

/* function */
#define IN(x) cin >> x
#define DEBUG(x) cerr << (x) << " "
#define LN() cerr << "\n"
#define PRINT(x) cout << (x) << endl
#define BR cout << endl

/* const */
const int ARRAY = 100005;
const int INF = 1001001001; // 10^9
const ll LINF = 1001001001001001001; // 10^18
const int MOD = 1e9 + 7;



ll N = 0;
ll tmp;
ll ret = 0;
ll nec = LINF;

void input() {
  IN(N);
  REP(i, 5) {
    IN(tmp);
    nec = min(nec, tmp);
  }
}

void solve() {
  ret = (N/nec) + ((N%nec>0)?1:0);
  ret += 4;
  PRINT(ret);
}

int main(void){
  input();
  solve();
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define M 1000000007
#define ll long long 
#define pb push_back
#define fo(i,N) for(int i = 0 ; i < N ; i++)
#define foo(i,x,N) for (int i = x; i < N ; i++)
#define fill(a,val) memset(a,val,sizeof(a))
#define fastio()  ios_base::sync_with_stdio(false); cin.tie(NULL);
#define endl '\n'
#define ff first
#define ss second
#define MAX 1234567
#define pii pair<int,int> 
#define pll pair<ll,ll> 
#define inf 1e14+1
#define all(a) a.begin(),a.end()
string s;
ll dp[100001][101][2];
int D;

ll solve(int pos,int d,int tight)
{  
   if ( dp[pos][d][tight] != -1)
   {
    return dp[pos][d][tight];
   }
   
   int m = (tight) ? (int)(s[pos]-'0') : 9;
   if ( pos == s.length()-1)
   {
    ll ans = 0;

    fo(x,m+1)
    {
      if (x%D == d)
        ans++;
    }
    return ans;
   }

   ll ans = 0;

   fo(x,m+1)
   {
    ans = (ans + solve(pos+1,(D+d-(x%D))%D,(tight&&(x==m))))%M;
   }
   return dp[pos][d][tight] = ans;
   

}

int main()
{ 
  cin >> s;
  cin >> D;
  fill(dp,-1);

  cout << (M-1+solve(0,0,1))%M;
 
}

Measured memory_bytes: 158848
#include <stdio.h>

int
main(int argc, char *argv[])
{
  char w[101] = {};
  scanf("%s", w);

  int x = (int)'a';
  int y = (int)'z';

  int arr[100] = {}; int k;
  k = 0;
  while(w[k] != 0){
    arr[(int)w[k++] - x]++;
  }


  for(int i = 0; i <= y - x; i++){
    if(arr[i] % 2 == 1){
      printf("No\n");
      break;
    }
    else if(i == y - x) printf("Yes\n");
  }

  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <math.h>
#include <sstream>
#include <numeric>
#include <string>
#include <cassert>

using namespace std;
typedef long long ll;

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

  for (int i = 0; i < N - 1; ++i) {
    for (int j = i + 1; j < N; ++j) {
      for (int b = 0; b < 9; ++b) {
	int x = (i>>b) & 1;
	int y = (j>>b) & 1;
	if (x != y) {
	  cout << b + 1 << " ";
	  break;
	}
      }
    }
    cout << endl;
  }
  
  return 0;
}


Measured memory_bytes: 512
#include <stdio.h>

int n,M[100][100],color[100],d[100],f[100],time;

void dfs_visit(int u){
  int v;
  color[u]=1;
  d[u]=++time;
  for(v=0;v<n;v++){
    if(M[u][v]==0){
      continue;
    }
    if(color[v]==0){
      dfs_visit(v);
    }
  }
  color[u]=2;
  f[u]=++time;
}
void dfs(){
  int u;
  for(u=0;u<n;u++){
    color[u]=0;
  }
  time=0;
  for(u=0;u<n;u++){
    if(color[u]==0){
      dfs_visit(u);
    }
  }
  for(u=0;u<n;u++){
    printf("%d %d %d\n",u+1,d[u],f[u]);
  }
}
int main(void)
{
  int i,j,k,u,v;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      M[i][j]=0;
    }
  }
  for(i=0;i<n;i++){
    scanf("%d %d",&u,&k);
    u--;
    for(j=0;j<k;j++){
      scanf("%d",&v);
      v--;
      M[u][v]=1;
    }
  }
  dfs();

  return 0;
}

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

int main() {
  int a, b;
  cin >> a >> b;
  
  int sum=0;
  for(int n = a; n <= b; n++) {
    int temp_n = n;
    int rev_n = 0;
    while(temp_n > 0) {
      rev_n *= 10;
      rev_n += temp_n % 10;
      temp_n /= 10;
    }
    if(rev_n == n)
      sum++;
  }
  
  cout << sum << endl;

}


Measured memory_bytes: 256
n, a, b = map(int, input().split())
def powermod(a,n,p):
    bi=str(format(n,"b"))#2進表現に
    res=1
    for i in range(len(bi)):
        res=(res*res) %p
        if bi[i]=="1":
            res=(res*a) %p
    return res
def combimod(n, r, p):
    a = 1
    for i in range(n-r+1, n+1):
        a *= i
        a %= p
    b = 1
    for i in range(1, r + 1):
        b *= i
        b %= p
    return (a * powermod(b, p-2, p)) % p
print((powermod(2, n, 1000000007) - combimod(n, a, 1000000007) - combimod(n, b, 1000000007) - 1 + 3000000021) % 1000000007)

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

int isPrime(double );

int main(){
  int i,n,input,output=0;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&input);
  
    if(isPrime((double)input)) 
      output++;
  }
  printf("%d",output);
  printf("\n");

  return 0;
}
int isPrime(double x){
 int i;
 if( x==2 ) return 1;
 if( x<2 || (int)x%2==0 ) return 0;
 
 i = 3;
 
 while( i <= sqrt(x)){
   if( (int)x%i==0 )
     return 0;
   i = i+2;
 }
 return 1;
}

Measured memory_bytes: 600
/*  Success may not come to me immediately,
 *  but it will come definitely....
 */
#include<bits/stdc++.h>
//=====================================================================
using namespace std;
//=====================================================================
#define opt ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
//=====================================================================
#define li  int64_t
#define ld  double_t
#define ulli    uint64_t
//=====================================================================
#define rep(i,a,b)  for(i=a;i<b;i++)
#define repr(i,a,b) for(i=a;i>b;i--)
#define repi(i,v)   for(i=v.begin();i!=v.end();i++)
#define elif        else if
#define mset(a,b)   memset(a,b,sizeof(a))
#define nl      cout<<'\n'
//=====================================================================
typedef vector<li>       vli;
typedef vector<string>   vstr;
typedef pair<li,li>      pli;
typedef pair<li,pli >    ppli;
typedef pair<li,ppli >   pppli;
typedef vector<pli >     vpl;
typedef vector<ppli >    vppli;
typedef vector<pppli >   vpppli;
//=====================================================================
#define pb  push_back
#define pob pop_back
#define pf  push_front
#define pof pop_front
#define all(v)  v.begin(),v.end()
#define itr iterator
#define sz  size()
#define lb  lower_bound
#define ub  upper_bound
#define bs  binary_search
#define mp  make_pair
#define F   first
#define S   second
//=====================================================================
#define mod (li)(1e9+7)
#define inf (li)(1e18)
#define MX1 (li)(1e5+5)
#define MX2 (li)(1e6+5)
#define pi  acos(-1)
//=====================================================================
li power(li a,li b){li ans=1;while(b){if(b&1){ans=(ans*a)%mod;}
a=(a*a)%mod;b>>=1;}return ans;}
//=====================================================================
li mmi(li n){return power(n,mod-2);}
//=====================================================================
li two(li n){return 1<<n;}
//=====================================================================
void onbit(li &n,li x){n|=two(x);}
//=====================================================================
void offbit(li &n,li x){n&=~two(x);}
//=====================================================================
li cntbit(li n){li res=0;while(n and ++res)n-=n&-n;return res;}
//=====================================================================
li dx[]={-1,0,1,0},dy[]={0,-1,0,1};
//=====================================================================
/*------------------------MAIN CODE BEGINS NOW!------------------------*/

li n,k,a[MX1];

void solve(){
    li i;cin>>n>>k;
    rep(i,1,n+1) cin>>a[i];
    li g=a[1],m=a[1];
    rep(i,2,n+1){
        g=__gcd(g,a[i]);
        m=max(a[i],m);
    }
    if(k%g==0 and k<=m) cout<<"POSSIBLE";
    else cout<<"IMPOSSIBLE";
}

int main(){
    opt
    #ifndef ONLINE_JUDGE
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    #endif
    li t=1;
    //cin>>t;
    while(t--){
        solve();
    }
    return 0;
}


Measured memory_bytes: 1024
N = int(input())
A, B = map(int, input().split())
P = [int(i) for i in input().split()]
r = [0]*3
for p in P:
    if p<=A:
        r[0]+=1
    elif A<p<=B:
        r[1]+=1
    else:
        r[2]+=1
r = sorted(r, reverse=False)
print(r[0])

Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>
#include<vector>
#include<queue>
using namespace std;
const int MAX = 100000 + 24;
struct Node{
    int t, x, y;
    Node(int _t=0, int _x=0, int _y=0) : t(_t), x(_x), y(_y){}
};
int main(){
    int n;
    while(~scanf("%d",&n)){
        bool flag = true;
        Node cur,node;
        for(int i=0;i<n;i++){
            scanf("%d%d%d", &node.t, &node.x, &node.y);
            int needTime = abs(cur.x - node.x) + abs(cur.y - node.y);
            int temp = node.t - (cur.t + needTime);
            if((temp >= 0) && !(temp % 2) && flag){
                cur = node;
            }else{
                flag = false;
            }
        }
        printf(flag ? ("Yes\n") : ("No\n"));
    }
    return 0;
}

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

int main(){
  
  int e[4];

  cin>>e[0]>>e[1]>>e[2]>>e[3];

  sort(e, e+4);

  if(e[0]==e[1]&&e[2]==e[3]) cout<<"yes"<<endl;
  else cout<<"no"<<endl;
  
  
  return 0;
}

Measured memory_bytes: 3132
#-*-coding:utf-8-*-
import itertools

def main():
    n, m, q = map(int, input().split())
    arrys = [list(map(int, input().split())) for _ in range(q)]
    
    a = list(range(1, m+1))
    a_lists = list(itertools.combinations_with_replacement(a, n))
    score = 0
    
    for a_list in a_lists:
        tmp_score = 0
        for arry in arrys:
            if a_list[arry[1]-1] - a_list[arry[0]-1] == arry[2]:
                tmp_score += arry[3]
        score = max(score, tmp_score)
    print(score)



    
if __name__ == '__main__':
    main()

Measured memory_bytes: 21544
#include<stdio.h>
int main(void)
{
    long int h,n,a,i,sum = 0;
    scanf("%ld %ld",&h,&n);
    for(i = 1 ; i <= n ; i++)
    {
        scanf("%ld",&a);
        h -= a;
    }
    
    if(h<=0)
    {
        printf("Yes\n");
    }
    else
    {
        printf("No\n");
    }
    
    return 0;
}

Measured memory_bytes: 1648
/*
        |___________________________Arshit Mangukiya_____________________________|
        |_______________________________DA-IICT__________________________________|
        |_____________________________201801173__________________________________|
*/
        /*______________________WRITE  YOUR  CODE  HERE_________________________*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int  ll;            
typedef long double ld;
#define ff first
#define ss second
#define pi acos(-1)
#define mr_ad_0501 ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define pb push_back
#define all(a)      a.begin(),a.end()
#define F(i,n) for(ll i=0;i<n;i++)
#define MOD 1000000007
#define MAX 200007
#define LM LLONG_MAX
#define sz size()
#define p(x) 		cout<< x << " ";
#define pe(x)		cout<< x << endl ;
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
const int N=2e5+5;
    	/*	bool fun(pair<int,int>a , pair<int,int>b)
			{
				if(a.ff == b.ff)	return a.ss < b.ss;
				else			return a.ff > b.ff;
			}*/
 /*void bfs(ll x)
 {
 	queue<ll> q;
	q.push(x);
    while(!q.empty())
    {
        ll k=q.front();
        q.pop();
        for(auto X:v[k])
        {
            if(!vis[X])
            {
            	l[X]=l[k]+1;
                vis[X]=1;
                q.push(X);
            }
        }
    }
 }*/

void solve()
{
	ll a,b,n,x,ans;
	cin>>a>>b>>n;
	if(n<b)x=n;
	else x=b-1;
	ans=floor((a*x)/(b));
	cout<<ans;
}
int32_t main(){
	mr_ad_0501;
	ll t=1;
	//cin >> t;
	while(t--)
	{
		solve();
	}
}

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

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
 
#define FS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long int
#define ld long double
#define pb push_back
#define bp __builtin_popcount
#define sz size()
#define ff first
#define ss second
#define vll vector<ll>
#define vbool vector<bool>
#define vpll vector<pair<ll,ll>>
#define pll pair<ll,ll>
#define vllv vector<vector<ll>>
#define setpri(x) cout<<setprecision(x)<<fixed;
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define yesr {cout<<"YES"<<endl;return;}
#define nor {cout<<"NO"<<endl;return;}
// getline (std::cin,name);
ll MOD=1e9+7;
ll ceil1(ll n,ll x){if(n%x==0)return n/x; else return (n/x)+1;}
ll gcd(ll a,ll b){return __gcd(a,b);}
ll lcm(ll a,ll b){return (max(a,b)/gcd(a,b))*min(a,b);}
ll pow1(ll n,ll k,ll mm){
    if(k==0)return 1;
    if(k%2==0)return (pow1((n%mm)*(n%mm),k/2,mm))%mm;
    	return ((n%mm)*(pow1((n%mm)*(n%mm),k/2,mm)%mm))%mm;
}
ll pow2(ll n,ll k){ll ans=1;
    while(k>0){
        if(k%2==1)ans=ans*n;n=n*n;k/=2;
    }return ans;
}
ll modinv(ll n,ll mod){
    return pow1(n,mod-2,mod);
}
bool func(pair<ll,ll> &a,pair<ll,ll> &b ){
    if(a.ff != b.ff)return a.ff < b.ff;
    return a.ss > b.ss;
}
void solve(){
	
    ll i,j,k,l,n,m,x,y,z,r;
	ll a,b,c;
	cin>>a>>b>>c>>k;
	ll ans=min(a,k);
	if(a<k){
		if(a+b<k){
			ans-=(k-a-b);
		}
	}
	cout<<ans<<endl;
	
	
}
int main(){
    FS;
    ll i,j,k,n,m,x,y,z,q;
    q=1;
    // cin>>q;
    while(q--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
#define LL long long 
#define LLU long long unsigned
#define rarr(arr, n) for(int aab = 0; aab < n; aab++){cin >> arr[aab];}
#define parr(arr, n) for(int aab = 0; aab < n; aab++){cout << arr[aab] << " ";}
#define pb push_back
#define f first
#define s second
#define all(x) x.begin(), x.end()
#define debug(x) cout << #x << " = " << x << "\n";

#define freopen freopen("in.txt", "r", stdin);freopen("out.txt", "w", stdout);ios_base::sync_with_stdio(0);cin.tie(0);

int main(){
	int x, n, z, ans1 = 0, ans2 = 101;
	cin >> x >> n;
	bool arr[101] = {false};
	for(int i = 0; i < n; i++){
		cin >> z;
		arr[z] = true;
	}
	for(int i = x; i >= 0; i--){
		if(!arr[i]){
			ans1 = i;
			break;
		}
	}
	for(int i = x + 1; i <= 100; i++){
		if(!arr[i]){
			ans2 = i;
			break;
		}
	}
	if(abs(x - ans1) < abs(x - ans2)){
		cout << ans1;
	}
	else if(abs(x - ans1) > abs(x - ans2)){
		cout << ans2;
	}
	else{
		cout << ans1;
	}
} 

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

#define LL long long
#define int long long
#define PB push_back
#define N 500001
#define LG 22
#define MXQ 200001
#define M 1000000007
#define LB lower_bound
#define UB upper_bound
#define MP make_pair
#define LD double
#define F first
#define S second
#define ll long long
#define inf LLONG_MAX
#define endl "\n"

int32_t main()
{
    LL i,j,lt,d,z,v,c,r,l,q,x,y,m,n,x1,y1,t1,k;
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cin>>n;
    LL a[n];
    k=0;
    x=0;
    for(i=0;i<n;i++)
    {
        cin>>a[i];
        if(a[i]>=x)
            k++;
        x=max(x,a[i]);
    }
    cout<<k;
}       

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int MOD = 1e9+7;

int main(){
  
  string s,t; cin>>s>>t;
  vector<int> a(26),b(26);
  for(auto i:s){
    a.at(i-'a')++;
  }
  for(auto i:t){
    b.at(i-'a')++;
  }
  sort(a.begin(),a.end());
  sort(b.begin(),b.end());
  cout<<(a==b?"Yes":"No")<<endl;
  
}



Measured memory_bytes: 3916
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define lli long long int
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define se second;
#define fi first;
#define endl '\n';
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define REP(i,n) for (int i = 1; i <= n; i++)
template<typename T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<typename T> void chmin(T& a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T& a, T b) { if (a < b) a = b; }
typedef long long ll;
typedef vector<vector<ll> > matrix;
const lli MOD = 1000000007;
const lli INF = 1e9 + 7;
const lli N=2*1e5;
lli w[N],v[N];
lli dp[110][N];
int main(){
  _
  lli n,W;
  cin>>n>>W;
  for(lli i=1;i<=n;i++){
    cin>>w[i]>>v[i];
  }
  // memset(dp,100,sizeof(dp));
  for(lli i=0;i<=n;i++){
    for(lli j=1;j<=1e5;j++){
      dp[i][j] = 1e18;
    }
  }
  for(lli i=0;i<=n;i++){dp[i][0]=0;}
  for(lli i=1;i<=n;i++){
    for(lli j=1;j<=100000;j++){
      dp[i][j]=dp[i-1][j];
      if(j>=v[i]){
        dp[i][j]=min(dp[i][j],dp[i-1][j-v[i]]+w[i]);
      }
    }
  }
  for(lli i=1e5;i>=1;i--){
    if(dp[n][i]<=W){
      cout<<i<<endl;
      break;
    }
  }
}


Measured memory_bytes: 161280
from heapq import heappush, heappop
INF = 10 ** 20
n, m, r = map(int, input().split())
rList = list(map(int, input().split()))

edges = [[] for _ in range(n)]
for _ in range(m):
    a, b, c = map(int, input().split())
    a, b = a - 1, b - 1
    edges[a].append((b, c))
    edges[b].append((a, c))

def dijkstra(start):
    dist = [INF] * n
    dist[start] = 0
    que = []
    heappush(que, (0, start))
    while que:
        time, node = heappop(que)
        for to, cost in edges[node]:
            newTime = time + cost
            if newTime < dist[to]:
                dist[to] = newTime
                heappush(que, (newTime, to))
    return dist

rDist = [[] for _ in range(r)]
for i in range(r):
    dist = dijkstra(rList[i] - 1)
    rDist[i] = [dist[j - 1] for j in rList]

dic = {}
end = 2 ** r - 1
def minCost(state, pos):
    if (state, pos) in dic:
        return dic[(state, pos)]
    if state == end:
        return 0

    mask = 1
    ret = INF
    for to in range(r):
        if state & mask:
            mask <<= 1
            continue

        newState = state | mask
        ret = min(ret, rDist[pos][to] + minCost(newState, to))
        mask <<= 1

    dic[(state, pos)] = ret
    return ret

print(min([minCost(2 ** i, i) for i in range(r)]))

Measured memory_bytes: 6860
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <deque>
#include <string>
#include <cstring>
#include <iomanip>
#include <fstream>
#include <map>
#include <unordered_map>
#include <bitset>

#define _crt_secure_no_warnings
#define FREEELO ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back
#define mp make_pair
#define INF 0x3F3F3F3F3F3F3F3F
#define MAX 300001
#define ALPHABET 128
#define loop(i, n) for (int i = 1; i <= (n); i++)
#define loop0(i, n) for (int i = 0; i < (n); i++)
#define sz(x) (int)x.size()
#define all(v) v.begin(), v.end()
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<ll, ll> llll;
typedef pair<int, int> ii;
typedef unordered_map<int, int> umii;
typedef unordered_map<ll, ll> umll;


int main(){
    int n; cin >> n;
    cout << (1 ^ n) << endl;
}

Measured memory_bytes: 3224
/*
 * atcoder/dp_3rd/a.cpp
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>

using namespace std;

#define ll long long

#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
template <class T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template <class T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }

const int MAX = 100010;
const ll INF = 100000000000000000;
ll N;
vector<ll> A;
ll dp[MAX];

void input() {
  cin >> N;
  ll a;
  loop(n,0,N) {
    cin >> a;
    A.push_back(a);
  }
}

void solve() {
  loop(n,0,MAX) dp[n] = INF;
  dp[0] = 0;
  for (int n=0; n<N-1; n++) {
    chmin(dp[n+1], dp[n] + abs(A[n+1] - A[n]));
    if (n+2 < N) chmin(dp[n+2], dp[n] + abs(A[n+2] - A[n]));
  }
  cout << dp[N-1] << endl;
}

int main() {
  // cout.precision(15);
  input();
  solve();
  return 0;
}


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

int main()
{
  int n, y;
  cin >> n >> y;
  
  for(int man = 0; man <= n; man++){
    for(int gosen = 0; gosen <= n - man; gosen++){
      int sen = n - man - gosen;
      int sum = man * 10000 + gosen * 5000 + sen * 1000;
      if(sum == y){
        cout << man << ' ' << gosen << ' ' << sen << endl;
        return 0;
      }
    }
  }
  
  cout << -1 << ' ' << -1 << ' ' << -1 << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
using namespace std;
int main(){
    while(true){
        string s;
        int m;
         
        cin >> s;
        if(s == "-") break;
        cin >> m;
        for(int i=0; i<m; i++){
            int a;
            cin >> a;
             
            string add = s.substr(0,a);
            s = s + add;
            s = s.substr(a, s.size());
        }
         
        cout << s << endl;
    }
    return 0;
}


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

typedef long long ll;
const ll MOD = 1e9 + 7;

ll N, K;
// Dp[i][j][k]:
// seen i x's and i y's,
// j x's and j y's remain unpaired,
// the sum of known oddnesses is k
vector<vector<vector<ll>>> Dp;

void add(ll i, ll j, ll k, ll x) {
  if (k <= K) (Dp[i][j][k] += x) %= MOD;
}
int main() {
  cin >> N >> K;
  Dp.resize(N + 1);
  for (ll i = 0; i <= N; ++i) {
    auto &dpi = Dp[i];
    dpi.resize(i + 1);
    for (auto &dpij : dpi) {
      dpij.resize(K + 1);
    }
  }
  Dp[0][0][0] = 1;
  for (ll i = 0; i < N; ++i) {
    for (ll j = 0; j <= i; ++j) {
      for (ll k = 0; k <= K; ++k) {
        // straight
        add(i + 1, j, k + 2 * j, Dp[i][j][k]);
        // cross x, cross y
        if (j > 0) add(i + 1, j, k + 2 * j, 2 * j * Dp[i][j][k]);
        // cross both
        if (j > 0) add(i + 1, j - 1, k + 2 * (j - 1), j * j * Dp[i][j][k]);
        // no new pair
        add(i + 1, j + 1, k + 2 * (j + 1), Dp[i][j][k]);
      }
    }
  }
  cout << Dp[N][0][K] << endl;
  return 0;
}


Measured memory_bytes: 26240
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define FORE(x,c) for(auto &&x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define INSEG(l,x,r) ((l)<=(x)&&(x)<(r))
#define dump(...)
#define pb push_back
#define _ 0
const signed INF_=1001001001; const long long INF=1001001001001001001LL;
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v))os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a,const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a,const U &b){return a>b?a=b,1:0;}
template <class T> void PSUM(T& c) {partial_sum(begin(c), end(c), begin(c));}
template<class T> using heap=priority_queue<T,vector<T>,greater<T>>;
struct before_main_function {
    before_main_function() {
        cin.tie(0); ios::sync_with_stdio(0);
        cout << setprecision(15) << fixed;
        // #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

signed main() {
    int N, M, C;
    cin >> N >> M >> C;
    vector<int> B(M);
    cin >> B;
    int ans = 0;
    REP(i, N) {
        vector<int> A(M);
        cin >> A;
        int tmp = 0;
        REP(j, M) {
            tmp += A[j] * B[j];
        }
        tmp += C;
        if (tmp > 0) {
            ans++;
        }
    }
    cout << ans << endl;
    return (0^_^0);
}



Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<numeric>
#include<map>
#include<queue>
#include<deque>
#include<set>
#include<cstdio>
#include<cstring>
#include<string>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vector<ll>> mat;
ll p=pow(10,9)+7;

int main(){
    int N,M;cin>>N>>M;
    ll x[100010],y[100010];
    for(int i=1;i<=N;i++)cin>>x[i];
    for(int j=1;j<=M;j++)cin>>y[j];
    
    ll dpx[100010],dpy[100010];
    dpx[1]=0;dpx[2]=x[2]-x[1];
    dpy[1]=0;dpy[2]=y[2]-y[1];
    for(int i=3;i<=N;i++)
        dpx[i]=(dpx[i-1]+(ll)(i-1)*(x[i]-x[i-1])+dpx[i-1]-dpx[i-2]+p)%p;
    for(int j=3;j<=M;j++)
        dpy[j]=(dpy[j-1]+(ll)(j-1)*(y[j]-y[j-1])+dpy[j-1]-dpy[j-2]+p)%p;
    
    cout<<(dpx[N]*dpy[M])%p<<endl;
    return 0;
}

Measured memory_bytes: 3328
def getN():
    return int(input())

def getMN():
    a = input().split()
    b = [int(i) for i in a]
    return b[0],b[1]

def getlist():
    a = input().split()
    b = [int(i) for i in a]
    return b

n = getN()
arra = []
arrb = []
for i in range(n):
    a,b = getMN()
    arra.append(a)
    arrb.append(b)

ans = 0
for i in range(n):
    ind = n-i-1
    ans += (arrb[ind] - ((arra[ind] + ans) % arrb[ind])) % arrb[ind]

print(ans)

Measured memory_bytes: 11056
//First 3 submissions are of Mahir

#include <bits/stdc++.h>
using namespace std;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"

const int N=3e5+5;

int32_t main()
{
	IOS;
	string s;
	cin>>s;
	int n=s.size();
	int check=0;
	for(int i=0;i<n-1;i++)
	{
		if(s[i]=='A'&&s[i+1]=='C')
			check=1;
	}
	if(check)
		cout<<"Yes";
	else
	{
		cout<<"No";
	}
}

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

using namespace std;
#define SORT(a) sort((a).begin(), (a).end())
#define RSORT(a) reverse((a).begin(), (a).end())
#define rep(i, a, b) for (int64_t i = (a); i < (b); ++i)
const int MOD = 1e9 + 7;
typedef long long ll;
const long long INF = 1LL << 60;
using Graph = vector<vector<int>>;

int main() {
  char c;
  cin >> c;
  cout << (char)((int)c + 1) << endl;
}


Measured memory_bytes: 256
n,m,x=map(int,input().split())
A=[int(x) for x in input().split()]
start=0
goal=0
for i in range(x, n+1):
  for a in A:
    if i ==a:
      start+=1
for j in range(x):
  for a in A:
    if j ==a:
      goal+=1
print(min(start, goal))


Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <functional>
#include <ctime>
#include <fstream>
#include <cmath>
#include <limits>
#include <numeric>
#include <type_traits>
#include <iomanip>
#include <float.h>
#include <math.h>
using namespace std;
using ll = long long;



int main() {
  int a,b;
  cin >> a >> b;
  cout << a-b+1 << endl;
}

Measured memory_bytes: 3556
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define endl '\n'
int mod=1e9+7;
int mod2=998244353;

signed main(){
  while(true){
    int e;
    cin>>e;
    if(e==0)break;
    int ans=1e9;
    for(int i=0;i*i*i<=e;i++){
      for(int j=0;j*j<=e;j++){
        if(e-i*i*i-j*j>=0)ans=min(ans,i+j+(e-i*i*i-j*j));
      }
    }
    cout<<ans<<endl;
  }
}



Measured memory_bytes: 3080
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int t = sc.nextInt();
        
        int biscuit = 0;
        
        for(int i = 1; i < t + 0.5; i++){
            if(i % a == 0){
                biscuit += b;
            }
        }
        
        System.out.println(biscuit);
        
    }
}


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

int main(){

  string s,p;
  cin >> s >> p;
  int n=s.length();
  s = s + s;
  bool f=false;
  for(int i=0; i<n; i++){
    if(p == s.substr(i,p.length())) f = true;
  }
  if(f) cout << "Yes\n";
  else cout << "No\n";
  
}

Measured memory_bytes: 1184
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=1LL<<61;

int main() {
  ll n;
  cin >> n;
  vector<pll> a(n+1);
  for(ll i=1;i<=n;i++) {
    cin >> a[i].first;
    a[i].second=i;
  }
  sort(a.begin(),a.end());
  ll cnt=0;
  ll mn=inf;
  vec ans(n+1);
  for(ll i=n;i;i--) {
    cnt++;
    mn=min(mn,a[i].second);
    ans[mn]+=abs(a[i].first-a[i-1].first)*cnt;
  }
  for(ll i=1;i<=n;i++) cout << ans[i] << endl;
}

Measured memory_bytes: 3456
#include<bits/stdc++.h>
using namespace std;
int main()
{
 	int n,m,sum=0;
 	cin>>n>>m;
 	for(int i=0;i<m;i++)
 	{
 		int tmp;
		cin>>tmp;
		sum+=tmp;	
	}
	if(n-sum>=0)
	cout<<n-sum;
	else
	cout<<-1;
}

Measured memory_bytes: 3648
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
int main(){
  string s;
  cin >> s;
  int n = 0;
  n = s.size();
  vector<int> mod(s.size());
  ll now = 0;
  now = 1;
  mod[n - 1] = s[n - 1] - '0';
  for(int i = n - 2;i >= 0;i--){
    now *= 10;
    now %= 2019;
    //cout << i << " !" << now << endl;
    mod[i] = (int)(s[i] - '0') * now + mod[i + 1];
    mod[i] %= 2019;
  }
  //for(int i = 0;i < n;i++)cout << i << " " << mod[i] << endl;
  map<int,int> count;
  for(int i = 0;i < n;i++){
    count[mod[i]]++;
  }
  ll res = 0;
  for(auto& i:count){
    if(i.first == 0){
      res += (i.second + 1) * i.second / 2;
    }
    else{
      res += (i.second + 1) * i.second / 2 - i.second;
    }
  }
  cout << res << endl;
  return 0;
}

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

using namespace std;

int main() {
  int N, x;
  cin >> N >> x;
  vector<int> A(N);
  for (int i = 0; i < N; ++i) cin >> A[i];
  sort(A.begin(), A.end());
  int cnt = 0;
  for (int i = 0; i < N; ++i) {
    x -= A[i];
    if (x < 0) break;
    cnt++;
  }
  if (x > 0) cnt--;
  cout << cnt << endl;
}

Measured memory_bytes: 256
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"

using namespace std;

const long long int MOD = 1000000007;
//const int MOD = 998244353;

long long int N, M, K, H, W, L, R;
//int N, M, K, H, W, L, R


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

	cin >> N;
	string s;
	cin >> s;
	vector<int>p(9);
	vector<vector<int>>num(10, vector<int>(10));
	for (int i = 1; i < s.size(); i++) {
		num[s[i] - '0'][s[i - 1] - '0']++;
	}
	for (int i = 0; i < 9; i++)p[i] = i + 1;
	vector<int>ans(9);
	for (auto &i : ans)i = MOD;
	int cost = MOD;
	do {
		vector<pair<int,int>>place(10);
		for (int i = 0; i < 9; i++) {
			place[p[i]] = { i / 3,i % 3 };
		}
		int box = 0;
		for (int i = 1; i <= 9; i++) {
			for (int j = 1; j <= 9; j++) {
				box += (abs(place[i].first - place[j].first) + abs(place[i].second - place[j].second))*num[i][j];
			}
		}
		if (cost > box) {
			cost = box;
			ans = p;
		}
		else if (cost == box) {
			if (ans > p)ans = p;
		}
	} while (next_permutation(p.begin(), p.end()));
	for (int i = 0; i < 3; i++) {
		for (int j = 0; j < 3; j++) {
			cout << ans[i * 3 + j];
		}
		cout << endl;
	}
	return 0;
}



Measured memory_bytes: 3296
import java.util.Scanner;


public class Main {
	
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		
		final long a = sc.nextLong();
		final long b = sc.nextLong();
		final long c = sc.nextLong();
		
		if(a < b && b < c){
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}
		
		
		
		
	}
	
}

Measured memory_bytes: 17164
#!/usr/bin/env python
"""AtCoder Beginner Contest 167: B - Easy Linear Programming
https://atcoder.jp/contests/abc167/tasks/abc167_b
"""


def main():
    [A, B, C, K] = list(map(int, input().split()))

    a = min(A, K)
    b = min(B, K - a)
    c = min(C, K - a - b)

    print((a * 1) + (b * 0) + (c * -1))


if __name__ == '__main__':
    main()


Measured memory_bytes: 9188
n,x = map(int,input().split())
a = list(map(int,input().split()))
ans = 0

for i in range(n-1):
    if x  < a[i] + a[i+1]:
        ans += (a[i]+a[i+1])-x
        if a[i] <= x:
            a[i+1] = x - a[i]
        else:
            a[i+1] = 0

#print(a)
print(ans)

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

int main(){
    string s;
    cin >> s;
    int ans = 0;
    int cnt = 0;
    for(int i = 0; i < s.length(); i++){
        for(int j = i; j < s.length(); j++){
            if(s[j] == 'A' || s[j] == 'C' || s[j] == 'G' || s[j] == 'T'){
                cnt++;
            }
            else{
                break;
            }
        }
        ans = max(ans, cnt);
        cnt = 0;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <string>
#include <queue>
#include <numeric>
#include <ctype.h>
#include <limits>
#include <iomanip>

#define rep(i,n) for (int i = 0; i < n; i++)
#define all(x) (x).begin(),(x).end()
using namespace std;

typedef long long ll;

int main() {
	int N;
	cin >> N;
	cout << 180 * (N - 2);
	return 0;
}

Measured memory_bytes: 256
from collections import deque
s = deque(list(input()))
q = int(input())
t1 = 1
for i in range(q):
    t = input()
    if t == '1':
        t1 *= -1
    else:
        if t1 == 1:
            if t[2] == '1':
                s.appendleft(t[4])
            else:
                s.append(t[4])
        else:
            if t[2] == '2':
                s.appendleft(t[4])
            else:
                 s.append(t[4])

ans = ''
if t1 == -1:
    ans = ''.join(reversed(s))
else:
    ans = ''.join(s)

print(ans)

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

using namespace std;

typedef long long ll;

ll gcd(ll a, ll b){
    return (a%b ? gcd(b,a%b) : b);
}

int main(){
    ll a,b;
    while(cin >> a >> b){
	ll c = gcd(a,b);
	cout << c << " " << a/c*b << endl;
    }
    return 0;
}

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

using namespace std;

int abs(int x){
	if(x >0)
		return x;

	else return -x;
}

int main()
{
	int n;
	cin>>n;
	int a[n];

	for(int i=0;i<n;i++){
		cin>>a[i];
	}

	int dp[n];
	dp[0]=0;
	dp[1]=abs(a[1]-a[0]);

	for(int i=2;i<n;i++){
		dp[i] = min(dp[i-2] + abs(a[i]-a[i-2]), dp[i-1] + abs(a[i]-a[i-1]));
	}

	cout<<dp[n-1]<<endl;

	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main(){
    string s;
    cin >> s;
    if(s == "SUN")
        cout << 7 << endl;
    else if(s == "MON")
        cout << 6 << endl;
    else if(s == "TUE")
        cout << 5 << endl;
    else if(s == "WED")
        cout << 4 << endl;
    else if(s == "THU")
        cout << 3 << endl;
    else if(s == "FRI")
        cout << 2 << endl;
    else if(s == "SAT")
        cout << 1 << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include <cctype>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
typedef long long ll;

int main(){
    string a,b,c;
    cin >> a >> b >> c;
    cout << a[0] << b[0] << c[0] << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
int a, b, c;
scanf("%d %d %d", &a, &b, &c);
if (a<b) {
	if (b<c){
		printf("Yes\n");
	} else{
		printf("No\n");
	}
} else {
	printf("No\n");
}
	
return 0;
}

Measured memory_bytes: 580
#include<iostream>
#include<algorithm>
#define ll long long int

using namespace std;

main()
{
	ll x;
	cin>>x;
	if(x>=400 && x<=599)
		cout<<8<<endl;
	else 	if(x>=600 && x<=799)
		cout<<7<<endl;
		else 	if(x>=800 && x<=999)
		cout<<6<<endl;

	else 	if(x>=1000 && x<=1199)
		cout<<5<<endl;

	else 	if(x>=1200 && x<=1399)
		cout<<4<<endl;

	else 	if(x>=1400 && x<=1599)
		cout<<3<<endl;

	else 	if(x>=1600 && x<=1799)
		cout<<2<<endl;
	
	else 	if(x>=1800 && x<=1999)
		cout<<1<<endl;

	

	
	
}

Measured memory_bytes: 3628