akhauriyash/Code-Regression huggingface dataset:
#include <iostream> 
#include <bits/stdc++.h> 
using namespace std; 
int a,b,c,d;
int main () 
{
  int n; 
  cin >> n; 
  
  string cases; 
  for (int i=0; i<n; i++)
  {
    cin >> cases; 
    if (cases == "AC") a++; 
    if (cases == "WA") b++; 
    if (cases == "TLE") c++; 
    if (cases == "RE") d++;
    }
  
  cout << "AC x " << a << endl; 
  cout << "WA x " << b << endl; 
  cout << "TLE x " << c << endl; 
  cout << "RE x " << d << endl; 
  
  return 0; 
}

Measured memory_bytes: 3560
#pragma GCC positionimize(3,"Otrst","inline")
//#include "emplace.hpp"
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;
const int N=2e5+10;
const int INF=0x3f3f3f;
const double pi = 3.141592653;
const double E = 2.71828182846;
const ll mod=1e9+7;
const int M=1e4+5;
const double eps=1e-8;
#define ci(x) scanf("%d",&x)
#define co(x) printf("%d\n",x)
inline int read()
{
    int f=1,x=0;
    char c=getchar();
    while(c<'0' || c>'9')
    {
        if(c=='-')
            f=-1;
        c=getchar();
    }
    while(c>='0' && c<='9')
    {
        x=x*10+c-'0';
        c=getchar();
    }
    return f*x;
}
map<string,int>ma;
map<string ,int>::iterator it;
int main()
{
    ios::sync_with_stdio(false);
    int max_fre=0;
    string s;
    int n;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>s;
        ma[s]++;
        max_fre=max(max_fre,ma[s]);
    }
    for(it=ma.begin();it!=ma.end();it++)
    {
        if(it->second == max_fre)
            cout<<it->first<<endl;
    }
    return 0;
}



Measured memory_bytes: 23808
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<utility>
#include<set>
#include<stack>
#include<list>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cstring>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<cmath>
#include<cctype>


#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define ren(i,a,b) for(int i=a;i>=b;i--)
#define ff first
#define ss second
#define pll pair<long long int,long long int>
#define pii pair<int,int>
#define vll vector<long long int>
#define vii vector<int>
#define gi(n) scanf("%d",&n)
#define gll(n) scanf("%lld",&n)
#define gstr(n) scanf("%s",n)
#define gl(n) cin >> n
#define oi(n) printf("%d",n)
#define oll(n) printf("%lld",n)
#define ostr(n) printf("%s",n)
#define ol(n) cout << n
#define os cout<<" "
#define on cout<<"\n"
#define o2(a,b) cout<<a<<" "<<b
#define all(n) n.begin(),n.end()
#define present(s,x) (s.find(x) != s.end())
#define cpresent(s,x) (find(all(s),x) != s.end())
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
using namespace std;

typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
typedef vector<vector<ll> > mat;

int n;
ll x[100005],a[100005],s;

ll go(int l,int r)
{
	if(s<=x[l])
	return x[r]-s;
	if(s>=x[r])
	return s-x[l];
	ll kk=x[r]-x[l];
	if(a[l]>=a[r])
	{
		while(l<r&&a[l]>=a[r])
		{
			a[l]+=a[r];
			r--;
		}
		return kk+go(l,r);
	}
	while(l<r&&a[l]<a[r])
	{
		a[r]+=a[l];
		l++;
	}
	return kk+go(l,r);
}

int main()
{ios_base::sync_with_stdio(false);

cin>>n>>s;
rep(i,1,n)cin>>x[i]>>a[i];
ol(go(1,n));

return 0;
}



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

# define REP(i,n) for (int i=0;i<(n);++i)
# define rep(i,a,b) for(int i=a;i<(b);++i)
# define p(s) std::cout << s ;
# define pl(s)  std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
# define yes(j) std::cout << (j ? "yes" : "no") << endl;
# define all(v) v.begin(),v.end()
# define showVector(v) REP(i,v.size()){p(v[i]);p(" ")} pl("")
template<class T> inline bool chmin(T &a, T b){ if(a > b) { a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b){ if(a < b) { a = b; return true;} return false;}
typedef long long int ll;
typedef pair<int,int> P_ii;
typedef pair<double,double> P_dd;

template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}

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

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}


const int MOD = 1000000007;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;

void addM(long long &a, long long b) {
    a += b;
    if (a >= MOD) a -= MOD;
}

void mulM(long long &a, long long b) {
    a = ((a%MOD)*(b%MOD))%MOD ;
}

// a^b mod M
long myPow(long a,long b,int M) {
    long ret = 1;
    long tmp = a;
    while(b>0) {
        if((b&1)==1) ret = (ret * tmp) % M;
        tmp = (tmp * tmp) % M;
        b = b>>1;
    }
    return ret;
}

 // nCk mod M
int nCk(int n,int k,int M) {
    long ret = 1;
    int mi = min(k, n-k);
    for(int i=1;i<=mi;i++) {
        ret = (ret * myPow(i,M-2,M)) % M;
    }
    for(int i=n-mi+1;i<=n;i++) {
        ret = (ret * i) % M;
    }
    return (int)ret;
};

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

    vector<int> a(N);
    vector<vector<int>> v(200005);
    REP(i, N){
        cin >> a[i];
        v[a[i]].push_back(i);
    }

    ll t = 1;
    int idx = 0;
    while(1){
        int nxt = lower_bound(all(v[a[idx]]), idx) - v[a[idx]].begin() + 1;
        if(nxt == v[a[idx]].size()){
            nxt = 0;
            ++t;
        }
        idx = (v[a[idx]][nxt] + 1) % N;
        if(idx == 0)break;
    }

    K %= t;
    if(K == 0) return 0;

    idx = 0;
    K -= 1;
    while(K){
        int nxt = lower_bound(all(v[a[idx]]), idx) - v[a[idx]].begin() + 1;
        if(nxt == v[a[idx]].size()){
            nxt = 0;
            --K;
        }
        idx = (v[a[idx]][nxt] + 1) % N;
    }

    vector<int> ans;
    vector<int> cnt(200005);
    for(int i = idx; i < N; i++){
        if(!cnt[a[i]]){
            ++cnt[a[i]];
            ans.push_back(a[i]);
        }
        else {
            while(cnt[a[i]]){
                int x = ans.back();
                ans.pop_back();
                --cnt[x];
            }
        }
    }
    
    for(auto e : ans) cout << e <<" ";
    cout << endl;
    
    return 0;
}

Measured memory_bytes: 14968
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    HashMap<Long, Integer> map = new HashMap<Long, Integer>();
    for(int i = 0; i < n; i++) {
      long a = sc.nextLong();
      if(map.containsKey(a)) {
        map.put(a, map.get(a) + 1);
      } else {
        map.put(a, 1);
      }
    }
    ArrayList<Long> list = new ArrayList<Long>();
    long ans = 0;
    for(long key : map.keySet()) {
      int t = map.get(key);
      while(t > 1) {
        list.add(key);
        t -= 2;
      }
    }
    Collections.sort(list);
    if(list.size() > 1) {
      ans = (list.get(list.size() - 1)) * (list.get(list.size() - 2));
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 63776
#include <iostream>
    #include <algorithm>
    #include <vector>
    #include <functional>
     
    std::vector<int> scc(const std::vector<std::vector<int>> &g) {
      const int n = g.size();
      std::vector<int> post;
      std::vector<bool> vis(n);
      std::vector<std::vector<int>> rg(n);
     
      std::function<void(int)> dfs = [&](int u) {
        vis[u] = true;
        for (int v : g[u]) {
          if (!vis[v]) dfs(v);
          rg[v].push_back(u);
        }
        post.push_back(u);
      };
      for (int i = 0; i < n; i++) {
        if (!vis[i]) dfs(i);
      }
     
      std::reverse(post.begin(), post.end());
     
      int k = 0;
      std::vector<int> ret(n, -1);
      std::function<void(int)> dfs2 = [&](int u) {
        ret[u] = k;
        for (int v : rg[u]) if (ret[v] == -1) dfs2(v);
      };
     
      for (int u : post) {
        if (ret[u] == -1) {
          dfs2(u);
          k++;
        }
      }
      return ret;
    }
     
    // c=(i,ii,j,jj), x[i]==ii and x[j]==jj
    std::vector<bool> sat2(int n, std::vector<std::tuple<int, int, int, int>> cs) {
      std::vector<std::vector<int>> g(n * 2);
     
      for (auto c : cs) {
        int i, ii, j, jj;
        std::tie(i, ii, j, jj) = c;
        // not a -> b = a or b
        g[i * 2 + 1 - ii].push_back(j * 2 + jj);
        g[j * 2 + 1 - jj].push_back(i * 2 + ii);
      }
     
      std::vector<int> sid = scc(g);
      std::vector<bool> ret(n);
     
      for (int i = 0; i < n; i++) {
        if (sid[i * 2] == sid[i * 2 + 1]) return {};
        ret[i] = sid[i * 2] < sid[i * 2 + 1];
      }
     
      return ret;
    }
     
    using namespace std;
     
    int dist(int a, int b) {
      a %= 24;
      b %= 24;
      if (a > b) swap(a, b);
      return min(b - a, 24 - (b - a));
    }
     
    int main() {
      int n;
      cin >> n;
     
      vector<int> a(n + 1);
      for (int i = 0; i < n; i++) {
        cin >> a[i + 1];
      }
     
      for (int ans = 12; ans >= 0; ans--) {
        vector<tuple<int, int, int, int>> cs;
        for (int i = 0; i <= n; i++) {
          for (int j = i + 1; j <= n; j++) {
            if (dist(a[i], a[j]) < ans) {
              cs.emplace_back(i, 1, j, 1);
            }
            if (dist(a[i], 24 - a[j]) < ans) {
              cs.emplace_back(i, 1, j, 0);
            }
            if (dist(24 - a[i], 24 - a[j]) < ans) {
              cs.emplace_back(i, 0, j, 0);
            }
            if (dist(24 - a[i], a[j]) < ans) {
              cs.emplace_back(i, 0, j, 1);
            }
          }
        }
        if (!sat2(n + 1, cs).empty()) {
          cout << ans << endl;
          return 0;
        }
      }
      cout << 0 << endl;
    }

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define REP(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) REP(i, 0, n)
#define rrep(i, n) for (int i = (int)(n-1); i >= 0; i--)
#define sz(x) int(x.size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define INF 2e9
#define LINF 1e18
template<class T> inline bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> P;
 
int main() {
    int n; cin >> n;
    vector<int> dp(n+1, 100010);
    dp[0] = 0;
    rep(i, n) {
        int power = 1;
        while (power <= i+1) {
            chmin(dp[i+1], 1+dp[i+1-power]);
            power *= 6; 
        }
        power = 1;
        while (power <= i+1) {
            chmin(dp[i+1], 1+dp[i+1-power]);
            power *= 9;
        }
    }
    cout << dp[n] << endl;
}

Measured memory_bytes: 640
//A.cpp
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <math.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b!=0?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
const ll mod=1e9+7;

int main(){
  int n;
  cin >> n;
  int ans = 0;
  for(int i = 1; i <= n; i++){
    int a = i;
    int len = 0;
    while(a!=0){
      a/=10;
      len++;
    }
    if(len%2==1) ans++;
  }
  printf("%d\n", ans);
  return 0;
}


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

using namespace std;

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<string> vst;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;

const ll mod=1e9+7;
const ll inf=1e16; 
#define rep(i,m,n) for(ll i=m;i<n;i++)
#define repr(i,m,n) for(ll i=m;i>=n;i--)
ll n,q;
string s;
vector<set<ll>> st;


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

  cin >> n >> s >> q;
  st.assign(26,set<ll>({inf}));
 
 rep(i,0,n) st[s[i]-'a'].insert(i);
 
  while(q--){
   int x;
    cin >> x;
    if(x==1){
     int l;
     char r;
      cin >> l >> r;
      --l;
      st[s[l]-'a'].erase(l);
      st[r-'a'].insert(l);
      s[l]=r;
    }
    else {
      int l,r;
      cin >> l >> r;
      l--;
      int res=0;
      rep(j,0,26) {
        if(st[j].empty()) continue;
        if(*st[j].lower_bound(l)<*st[j].lower_bound(r)) res++;
      }
        cout << res << endl; 
    }
  }
  
  
}


Measured memory_bytes: 24220
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    var zero = false
    val a = readLine()!!.split(' ').map {
        val aa = it.toLong()
        if (aa == 0L) zero = true
        aa
    }
    val max = 1000000000000000000L
    if (!zero) {
        var ans = 1L
        var i = 0
        while (i < n && ans <= max) {
            if (ans < Long.MAX_VALUE/a[i]) {
                ans *= a[i]
            } else {
                println(-1)
                return
            }
            i++
        }
        if (ans > max) println(-1)
        else println(ans)
    } else {
        println(0)
    }
}


Measured memory_bytes: 63220
//#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define IN(a, b, x) (a<=x&&x<b)
#define MP make_pair
#define PB push_back
#define MOD 1000000007
#define INF (1LL<<30)
#define LLINF (1LL<<60)
#define PI 3.14159265359
#define EPS 1e-12
//#define int ll

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

int a[305][305], cnt[305], idx[305];
bool erase[305];
signed main(void)
{
  int n, m;
  cin >> n >> m;
  REP(i, n) REP(j, m) cin >> a[i][j], a[i][j]--;

  int ret = INF;
  REP(i, m) {
    memset(cnt, 0, sizeof(cnt));
    // cout << "idx:";
    // 各スポーツの人数
    REP(j, n) {
      cnt[a[j][idx[j]]]++;
      // cout << idx[j] << " ";
    }
    // cout << endl << "cnt:";
    // 参加人数が最大のスポーツ
    int ma = 0, sport = -1;
    REP(j, m) {
      // cout << cnt[j] << " ";
      if(ma < cnt[j]) {
        ma = cnt[j];
        sport = j;
      }
    }
    // cout << endl << "spo:";
    // REP(j, m) cout << erase[j] << " "; cout << endl;
    // cout << ma << "," << sport << endl;
    ret = min(ret, ma);
    // sportを消す
    erase[sport] = true;
    REP(j, n) {
      while(idx[j] < m && erase[a[j][idx[j]]]) idx[j]++;
    }
  }

  cout << ret << endl;

  return 0;
}


Measured memory_bytes: 640
n = int(input())
a = list(map(int, input().split()))
a.append(0)

x = 1000
y = 0

for i in range(n):
    if a[i] < a[i+1]:
        y += x // a[i]
        x %= a[i]
    elif a[i] > a[i+1]:
        x += y * a[i]
        y = 0

print(x)


Measured memory_bytes: 9084
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0; i < n; ++i)
#define ALL(v) v.begin(), v.end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100000000;
const int MAX = 510000;
const int MOD = 1000000007;

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

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}




int main()
{
	COMinit();
	ll n;ll m;
	cin >> n >> m;
	vector<int> fac;
	for(ll i=2;i*i<=m;i++)
	{
		if(m%i==0)
		{
			fac.push_back(0);
			while(m%i==0)
			{
				fac.back()++;
				m/=i;
				//cout<<m<<endl;
			}
		}
	}
	if(m!=1)fac.push_back(1);
	ll ans = 1;
	//rep(i,fac.size())cout<<fac[i]<<endl;
	rep(i,fac.size())
	{
		ans =ans * COM(fac[i]+n-1,fac[i]);
		ans %= (ll)1e9+7;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 12160
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pull = pair<ull, ll>;
using pis = pair<int, string>;
#define INF 1000000000
#define LLINF 10000000000000000ll
#define MOD 1000000007LL

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n;
  cin >> n;
  string x;
  cin >> x;
  int ones = 0;
  for (int i = 0; i < n; i++) if (x[i] == '1') ones++;

  //ones++
  int t = ones+1;
  int dt = 0;
  for (int i = 0; i < n; i++) {
    dt = (2 * dt + (x[i] == '1')) % t;
  }

  //ones--
  int s = ones-1;
  int ds;
  if (s == 0) ds = 0;
  else {
    ds = 0;
    for (int i = 0; i < n; i++) {
      ds = (2 * ds + (x[i] == '1')) %s;
    }
  }
  
  vector<int> twos(n, 1);
  if (s != 0) for (int i = 1; i < n; i++) twos[i] = (twos[i-1] * 2) % s;
  vector<int> twot(n, 1);
  for (int i = 1; i < n; i++) twot[i] = (twot[i-1] * 2) % t;  

  //cout << dt << " " << ds << endl;

  for (int i = 0; i < n; i++) {
    if (x[i] == '1') {
      if (s == 0) {
        cout << 0 << endl;
        continue;
      }
      int nx = (ds - twos[n-1-i] + s) % s, cnt = 1;
      while(nx != 0) {
        nx %= bitset<64>(nx).count();
        cnt++;
      }
      cout << cnt << endl;
    }
    else {
      int nx = (dt + twot[n-1-i]) % t, cnt = 1;
      while(nx != 0) {
        nx %= bitset<64>(nx).count();
        cnt++;
      }
      cout << cnt << endl;
    }
  }
}


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

string devide[4] = {"dream", "dreamer", "erase", "eraser"};

int main() {
    string s;
    cin >> s;
    reverse(s.begin(), s.end());
    for (int i = 0; i < 4; i++) {
        reverse(devide[i].begin(), devide[i].end());
    }
    bool can = true;
    for (int i = 0; i < s.size();) {
        bool can2 = false;
        for (int j = 0; j < 4; ++j) {
            string d = devide[j];
            if (s.substr(i, d.size()) == d) {
                can2 = true;
                i += d.size();
            }
        }
        if (!can2) {
            can = false;
            break;
        }
    }
    if (can)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
    return 0;
}


Measured memory_bytes: 3736
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
using namespace std;
const long long int INF = 1e6;
typedef pair<ll,ll> pairs;
vector<pairs> p;


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

ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

// ------------------------------------

int main(){
    ll n;
    cin>>n;
    vector<ll> a(n);
    ll ans=0;
    for(ll i=0;i<n;++i){
        cin>>a[i];
        if(i==0){
            continue;
        }
        if(a[i]==a[i-1]){
            a[i] = -1;
            ans++;
        }
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>

int main(void){
    long long int n;
    std::vector<int> st;
    int keta = 1;
    long long int tmp = 26;
    char moji = 'a';
    std::cin >> n;
    n--;


    while(true){
	if(n / tmp < 1) break;
	n -= tmp;
	keta++;
	tmp = tmp * 26;
    }

    for(int i = 0; i < keta; i++){
	st.push_back(n % 26);
	n /= 26;
    }


    for(int i = st.size()-1; i >= 0; i--){
	for(int j = 0; j < st[i]; j++){
	    moji++;
	}
	std::cout << moji;
	moji = 'a';
    }
    std::cout << std::endl;

    return 0;
}


Measured memory_bytes: 3588
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, _s, n) for(int i = _s, i##_len = (n); i < i##_len; ++i)
#define ALL(x) (x).begin(), (x).end()
using namespace std;

#define repi(itr, ds) for(auto itr = ds.begin(); itr != ds.end(); itr++)
// vector
template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
  for(T &x : vec) is >> x;
  return is;
}
// pair
template <typename T, typename U>
ostream &operator<<(ostream &os, pair<T, U> &pair_var) {
  os << "(" << pair_var.first << ", " << pair_var.second << ")";
  return os;
}
// vector
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  os << "{";
  for(int i = 0; i < vec.size(); i++) {
    os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
  }
  os << "}\n   ";
  return os;
}
// map
template <typename T, typename U>
ostream &operator<<(ostream &os, map<T, U> &map_var) {
  os << "{";
  repi(itr, map_var) {
    os << *itr;
    itr++;
    if(itr != map_var.end()) os << ", ";
    itr--;
  }
  os << "}";
  return os;
}
// set
template <typename T>
ostream &operator<<(ostream &os, set<T> &set_var) {
  os << "{";
  repi(itr, set_var) {
    os << *itr;
    itr++;
    if(itr != set_var.end()) os << ", ";
    itr--;
  }
  os << "}";
  return os;
}

#define DUMPOUT cerr

void dump_func() { DUMPOUT << endl; }
template <class Head, class... Tail>
void dump_func(Head &&head, Tail &&... tail) {
  DUMPOUT << head;
  if(sizeof...(Tail) > 0) {
    DUMPOUT << ", ";
  }
  dump_func(std::move(tail)...);
}
#ifdef DEBUG_
#define DEB
#define dump(...)                                                             \
  DUMPOUT << "  " << string(#__VA_ARGS__) << ": "                             \
          << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]" << endl \
          << "    ",                                                          \
      dump_func(__VA_ARGS__)
#else
#define DEB if(false)
#define dump(...)
#endif

typedef long long int ll;

int main() {
  double PI = 3.1415926535;
  double a, b, x;
  cin >> a >> b >> x;

  double v = a * a * b * 1.0;
  dump(v);
  if(v / 2 >= x) {
    double rad = atan((a * b * b * 1.0) / x / 2.0);
    double ans = rad * 180 / PI;
    cout << fixed << setprecision(10) << ans << endl;
  } else {
    double rest = v - x;
    double rad = atan(rest * 2.0 / (a * a * a));
    double ans = rad * 180 / PI;
    cout << fixed << setprecision(10) << ans << endl;
  }
}


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


int main() {
	int a, b, c;
	cin >> a >> b >> c;

	bool poor = false;
	if (a == b) {
		if (b != c) poor = true; 
	}
	if (!poor && a == c && a != b) poor = true;
	if (!poor && b == c && a != b) poor = true;
	if (poor) cout << "Yes" << endl;
	else cout << "No" << endl;
}


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

using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define ll long long
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
using pii = pair<int, int>;
// template<class T> ostream &operator<<(ostream &os,T &t){dump(t);return os;}
template <typename T, typename S>istream &operator>>(istream &is, pair<T, S> &p) { is >> p.first >> p.second; return is; }
//template <typename T, typename S>ostream &operator<<(ostream &os, pair<T, S> &p) {os << p.first << " " << p.second;return os;}

template <typename T> void printvv(const vector<vector<T>> &v) {
	cerr << endl;
	rep(i, 0, v.size()) rep(j, 0, v[i].size()) {
		if (typeid(v[i][j]).name() == typeid(INF).name() and v[i][j] == INF) {
			cerr << "INF";
		}
		else
			cerr << v[i][j];
		cerr << (j == v[i].size() - 1 ? '\n' : ' ');
	}
	cerr << endl;
}

#ifndef _DEBUG
#define printvv(...)
#endif
void YES(bool f) { cout << (f ? "YES" : "NO") << endl; }
void Yes(bool f) { cout << (f ? "Yes" : "No") << endl; }
template <class T, class U>bool chmin(T& a, U b) { if (a > b) { a = b; return true; }return false; }
template <class T, class U>bool chmax(T& a, U b) { if (a < b) { a = b; return true; }return false; }

struct UnionFind {
	vector<int> parent;
	int size;
	UnionFind(int n) :parent(n, -1), size(n) {}
	bool unite(int x, int y) {
		x = root(x); y = root(y);
		if (x == y)return false;
		if (size_of(x) < size_of(y))swap(x, y);
		parent[x] += parent[y]; parent[y] = x; size--;
		return true;
	}
	bool same(int x, int y) { return root(x) == root(y); }
	int root(int x) { return parent[x] < 0 ? x : parent[x] = root(parent[x]); }
	int size_of(int x) { return -parent[root(x)]; }
};

signed main(signed argc, char *argv[]) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(12);

	int N, M; cin >> N >> M;
	vector<int>X(M), Y(M), Z(M); rep(i, 0, M) { cin >> X[i] >> Y[i] >> Z[i]; }

	UnionFind uf(N);

	rep(i, 0, M) {
		X[i]--, Y[i]--;
		Z[i] %= 2;

		uf.unite(X[i], Y[i]);
	}

	cout << uf.size << endl;


	return 0;
}


Measured memory_bytes: 3456
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define pf push_front

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

#define mp make_pair
#define fi first
#define se second
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
double pi = 3.141592653589793;
ll mod = 1000000007;
ll INF = 1000000001;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;



int main(){
    int n,l,ans=0;
    cin>>n>>l;
    rep(i,n){
        ans+=l+i;
    }
    if(l>0)ans-=l;
    else if(l+n-1<0)ans-=(l+n-1);
    else ;
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define rep2(i,n) for(int i=0;i<=n;i++)
#define repr(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define P pair<long long,long long>
#define uni(e) e.erase(unique(e.begin(),e.end()),e.end())
#define double long double
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int INF=1e10;
int MOD=1e9+7;
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void yesno(T b){if(b)out("yes");else out("no");}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
template<class T> void YESNO(T b){if(b)out("YES");else out("NO");}
template<class T> void noyes(T b){if(b)out("no");else out("yes");}
template<class T> void NoYes(T b){if(b)out("No");else out("Yes");}
template<class T> void NOYES(T b){if(b)out("NO");else out("YES");}
int keta(int a){
  double b=a;
  b=log10(b);
  int c=b;
  return c+1;
}
int kurai(int a,int b){
  int m=pow(10,b),n=pow(10,b-1);
  return (a%m)/n;
}
int ketawa(int a){
  int k=0;
  rep(i,keta(a)){
  k+=kurai(a,i+1);
  }
  return k;
}
int gcd(int a,int b){
  if(a%b==0)
    return b;
  return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
int mid(int a,int b,int c){
  vector<int> k(3);
  k[0]=a;k[1]=b;k[2]=c;
  sort(all(k));
  return k[1];
}
bool sosuu(int a){
  bool b=1;
  if(a<=1)
    return 0;
  else{
  rep1(i,sqrt(a)-1){
  if(a%(i+1)==0)
  b=0;
  }
  return b;
  }
}
int modpow(int a,int b,int m=MOD){
 if(!b)return 1; if(b&1)return modpow(a,b-1,m)*a%m;
 int memo = modpow(a,b>>1,m);
 return memo*memo%m;
}
int fact_mod(int n) {
    int f=1; 
for(int i=2;i<n+1;i++) f=f*(i%MOD)% MOD;
    return f;
}
int mod_pow(int x,int n) {
    int res=1;
    while(n>0){
        if(n&1) res=(res*x)%MOD; 
        x=(x*x)%MOD;        
n>>=1; 
    }
    return res;
}
int c_mod(int n, int r) {
    if(r>n-r) r=n-r;
    if(r==0) return 1;
    int a=1;
    rep(i,r) 
a=a*((n-i)%MOD)%MOD;
    int b=mod_pow(fact_mod(r), MOD-2);
    return (a%MOD)*(b%MOD)%MOD;
}
signed main(){
  int a;
  cin>>a;
  int b=0;
  int c=0;
  rep1(i,1000000000){
  b+=i;
    if(b>=a){
    c=i;
      break;
    } 
    
      
  }
  out(c);
}

Measured memory_bytes: 3640
#include <iostream>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
 
int a[10];
int n;
 
bool dfs(int i,int left,int right){
    if(i==10) return true;
    if(a[i]>left){
        return dfs(i+1,a[i],right);
    }
    if(a[i]>right){
        return dfs(i+1,left,a[i]);
    }
    return false;
}
 
void solve(){
    rep(i,10) cin >> a[i];
    if(dfs(0,0,0)) cout << "YES" << endl;
    else cout << "NO" << endl;
    return;
}
 
int main(){
    cin >> n;
    rep(i,n){
        solve();
    }
    return 0;
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
using ll = int_fast64_t;

template<typename T>
struct Segtree{
        using F = std::function<T(T,T)>;
        std::vector<T> seg;
        int size;
        T unit;
        F func;

        Segtree(int n, T u, F f): unit(u), func(f) {
                size = 1;
                while(size<n) size <<= 1;
                seg.assign(2*size-1, unit);
                for(int k=size-2; k>=0; k--) seg[k] = func(seg[2*k+1], seg[2*k+2]);
        }

        void update(int idx, T x){
                idx += size-1;
                seg[idx] = x;
                while(idx>0){
                        idx = (idx-1) / 2;
                        seg[idx] = func(seg[2*idx+1], seg[2*idx+2]);
                }
        }

        T query(int a, int b, int k=0, int l=0, int r=-1){
                if(r<0) r = size;
                if(b<=l or r<=a) return unit;
                if(a<=l and r<=b) return seg[k];
                T lvalue = query(a, b, 2*k+1, l, (l+r)/2);
                T rvalue = query(a, b, 2*k+2, (l+r)/2, r);
                return func(lvalue, rvalue);
        }

        T operator[](int i){
                return seg[size-1+i];
        }
};

int main(){
        int n, q;
        scanf("%d %d", &n, &q);
        Segtree<ll> seg(n, 0, [](ll a, ll b){return a+b;});
        for(int i=0; i<q; i++){
                int com, x, y;
                scanf("%d %d %d", &com, &x, &y);
                if(com==0) seg.update(x-1, seg[x-1]+y);
                else printf("%ld\n", seg.query(x-1, y));
        }
        return 0;
}


Measured memory_bytes: 4932
#include <bits/stdc++.h>
#include <math.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1001001001;


int main() {
  int a,b;
  string s;
  while(1) {
    cin >> a >> s >> b;
    if(s=="?") break;
    if(s=="+") {
      cout << a+b << endl;
    } else if(s=="-") {
      cout << a-b << endl;
    } else if(s=="*") {
      cout << a*b << endl;
    } else if(s=="/") {
      cout << a/b << endl;
    }
  }
  return 0;
}



Measured memory_bytes: 3148
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int r = sc.nextInt();

		if (r < 1200) {
			System.out.print("ABC");
		} else if (r < 2800) {
			System.out.print("ARC");
		} else {
			System.out.print("AGC");
		}
	}
}

Measured memory_bytes: 21972
#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;


typedef long long int lli;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef pair<float, float> ff;
typedef vector<ii> vii; 
typedef vector<ff> vff;


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin>>n;
    cout<<n*n*n<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) unique(v.begin(), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

#define MAX_V 1000000

#define MAX_N 40
int n;
ll w[MAX_N], v[MAX_N];
ll W;

pair<ll, ll> ps[1 << (MAX_N / 2)];

void solve() {
	int n2 = n / 2;
	for(int i = 0; i < 1 << n2; i++) {
		ll sw = 0, sv = 0;
		for(int j = 0; j < n2; j++) {
			if(i >> j & 1) {
				sw += w[j] ;
				sv += v[j];
			}
		}
		ps[i] = make_pair(sw, sv);
	}
	sort(ps, ps + (1 << n2));
	int m = 1;
	for(int i = 1; i < 1 << n2; i++) {
		if(ps[m - 1].second < ps[i].second) ps[m++] = ps[i];
	}

	ll res = 0;
	for(int i = 0; i < 1 << (n - n2); i++) {
		ll sw = 0, sv = 0;
		for(int j = 0; j < n - n2; j++) {
			if(i >> j & 1) {
				sw += w[n2 + j];
				sv += v[n2 + j];
			}
		}

		if(sw <= W) {
			ll tv = (lower_bound(ps, ps + m, make_pair(W - sw, INF)) - 1)->second;
			res = max(res, sv + tv);
		}
	}

	cout << res << endl;
}

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

	cin >> n >> W;
	rep(i, 0, n) cin >> v[i] >> w[i];
	solve();
}



Measured memory_bytes: 19604
def abc112_b():
    n, t_lim = map(int,input().split())
    c = []
    for _ in range(n):
        ci, t = map(int, input().split())
        if t <= t_lim:
            c.append(ci)
    if c == []:
        return "TLE"
    else:
        return min(c)


print(abc112_b())

Measured memory_bytes: 3060
#include<stdio.h>
int main()
{
	int a,b,c,d,s,i;
	scanf("%d%d%d%d",&a,&b,&c,&d);
	if(b>d)
	b=d;
	if(a<c)
	a=c;
	s=b-a;
	if(b<c||d<a)
	printf("0");
	else
	printf("%d",s);
	return 0;
}

Measured memory_bytes: 128
N = int(input())
A_0 = list(map(int, input().split()))
A_1 = list(map(int, input().split()))

max_ = 0
for i in range(1, N+1):
    ame = 0
    ame += sum(A_0[:i])
    ame += sum(A_1[i-1:])
    max_ = max(max_, ame)

print(max_)


Measured memory_bytes: 3060
N=int(input())
A=[list(map(int,input().split())) for i in range(N)]
res=0
flag=[[False]*N for i in range(N)]
for k in range(N):
    for i in range(N):
        for j in range(N):
            if A[i][j]>A[i][k]+A[k][j]:
                print(-1)
                exit()
            elif k!=i and k!=j and A[i][j]==A[i][k]+A[k][j] and not flag[i][j] and not flag[j][i]:
                flag[i][j]=True
                flag[j][i]=True
                res-=A[i][j]
ans=sum(sum(A[i]) for i in range(N))//2+res

print(ans)

Measured memory_bytes: 46044
#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 equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
//const ll mod = 1000000007;
//const ll mod = 998244353;
const int inf = 1e9 + 10;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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 dp[305][305][305];

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(25);

  string s;
  int k;
  cin >> s >> k;

  int n = s.length();
  rep(i, n) {
    dp[i][i][k] = 1;
    if (i < n - 1) {
      dp[i][i + 1][k] = 1 + (s[i] == s[i + 1]);
      if (k) dp[i][i + 1][k - 1] = 2;
    }
  }
  FOR(i, 1, n + 1) {
    rep(l, n - i + 1) {
      int r = l + i - 1;
      rep(c, k + 1) {
        if (l) chmax(dp[l - 1][r][c], dp[l][r][c]);
        if (r < n - 1) chmax(dp[l][r + 1][c], dp[l][r][c]);
        if (l && r < n - 1) {
          if (dp[l][r][k]) {
            chmax(dp[l - 1][r + 1][c], dp[l][r][c] + 2 * (s[l - 1] == s[r + 1]));
          }
          else {
            chmax(dp[l - 1][r + 1][c], 1 + (s[l - 1] == s[r + 1]));
          }
          if (c) chmax(dp[l - 1][r + 1][c - 1], dp[l][r][c] + 2);
        }
      }
    }
  }
  int ans = 0;
  rep(i, k + 1) chmax(ans, dp[0][n - 1][i]);
  cout << ans << '\n';


  
  return 0;
}

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

typedef long long int llint;

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

  if(s[0] == s[1] && s[1] == s[2]  ||
     s[1] == s[2] && s[2] == s[3] ) { 
    cout<< "Yes" <<endl;
  } else {
    cout<< "No" <<endl;
  }
  

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define For(i, a, b) for (int i = a; i <= b; i++)
#define DFor(i, a, b) for (int i = a; i >= b; i--)
using namespace std;

int n;
set < pair <int, int> > s;
set < pair <int, int> > :: iterator it; 
int main()
{
    scanf ("%d", &n);
    For (i, 1, n) For (j, i + 1, n) s.insert(make_pair(i, j));
    
    For (i, 1, n / 2) s.erase(s.find(make_pair(i, n - i + (n % 2 == 0))));
    
    printf ("%d\n", s.size());
    for (it = s.begin(); it != s.end(); it++) printf ("%d %d\n", it -> first, it -> second);
    return 0;
}

Measured memory_bytes: 3968
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define mt make_tuple
#define pqueue priority_queue
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

struct SegmentTree {
  vector<int> Tree[20];

  void maxinit() {
    for(int i=0;i<20;++i) {
      Tree[i].resize((1<<i));
      for(int j=0;j<Tree[i].size();++j) {
        Tree[i][j] = -1;
      }
    }
  }

  void mininit() {
    for(int i=0;i<20;++i) {
      Tree[i].resize((1<<i));
      for(int j=0;j<Tree[i].size();++j) {
        Tree[i][j] = inf;
      }
    }
  }

  void maxupdate(int index, int x) {
    for(int i=19;i>=0;--i) {
      Tree[i][index] = max(Tree[i][index], x);
      index /= 2;
    }
  }

  void minupdate(int index, int x) {
    for(int i=19;i>=0;--i) {
      Tree[i][index] = min(Tree[i][index], x);
      index /= 2;
    }
  }

  int maxfind(int ql, int qr, int pos1=0, int pos2=0, int sl=0, int sr=(1<<19)) {
    if(qr<=sl || sr<=ql) return -1;
    if(ql<=sl && sr<=qr) return Tree[pos1][pos2];
    return max(maxfind(ql, qr, pos1+1, 2*pos2, sl, (sl+sr)/2), maxfind(ql, qr, pos1+1, 2*pos2+1, (sl+sr)/2, sr));
  }

  int minfind(int ql, int qr, int pos1=0, int pos2=0, int sl=0, int sr=(1<<19)) {
    if(qr<=sl || sr<=ql) return inf;
    if(ql<=sl && sr<=qr) return Tree[pos1][pos2];
    return min(minfind(ql, qr, pos1+1, 2*pos2, sl, (sl+sr)/2), minfind(ql, qr, pos1+1, 2*pos2+1, (sl+sr)/2, sr));
  }
};

int main() {
  int N, K;
  cin>>N>>K;
  int P[N];
  for(int i=0;i<N;++i) cin>>P[i];
  int l=0, r=1;
  int nochange = 0;
  while(l<N) {
    while(P[r-1]<P[r] && r<N) r++;
    if(r-l>=K) nochange++;
    l = r;
    r = l+1;
  }

  SegmentTree maxtree, mintree;
  maxtree.maxinit();
  mintree.mininit();

  for(int i=0;i<N;++i) {
    maxtree.maxupdate(i, P[i]);
    mintree.minupdate(i, P[i]);
  }
  int tmp = 0;
  for(int i=0;i<N-K;++i) {
    if(mintree.minfind(i, i+K)!=P[i] || maxtree.maxfind(i+1, i+K+1)!=P[i+K]) tmp++;
  }
  cout<<tmp+1-max(nochange-1, 0)<<endl;
}


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

#define REP( i, n )     for( int (i) = 0; (i) < (n); (i)++ )
#define ALL( a )        (a).begin(), (a).end()

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

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

const int INF = 1e9;
const ll LINF = 1e18;
const int MOD = 1e9 + 7;

int main(){
    int a, b, x; cin >> a >> b >> x;
    if( a <= x && x <= a + b ) cout << "YES" << endl;
    else cout << "NO" << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
  int a[4]={0,0,0,0};
  int b[6];
  int i;
  for(i=0;i<6;i++){
  scanf("%d",&b[i]);
  }
  int k;
  for(k=0;k<6;k++){
    a[b[k]-1]=a[b[k]-1]+1;
  }
  if(a[0]>0 && a[0]<3 && a[1]>0 && a[1]<3 && a[2]>0 && a[2]<3 && a[3]>0 && a[3]<3){
    printf("YES\n");
  }else{
        printf("NO\n");
        }
}




Measured memory_bytes: 128
#include<iostream>
#include<cmath>
#include<map>

int main() {
   long long int n, m;
   std::cin >> n >> m;
   long long int a[n];
   long long int s[n+1];
   s[0] = 0;
   std::map<long long int, long long int> map;
   map[0]++;
   for (long long int i = 0; i < n; i++) {
      std::cin >> a[i];
      s[i + 1] = (s[i] + a[i]) % m;
      map[s[i + 1]]++;
      // std::cout << s[i + 1] << std::endl;
   }
   long long int ans = 0;
   for (std::map<long long int, long long int>::iterator it = map.begin(); it != map.end(); ++it) {
      // std::cout << it->first << " " << it->second << std::endl;
      long long int tmp = it->second;
      ans += tmp * (tmp - 1) / 2;
   }
   std::cout << ans << std::endl;
   return 0;
}


Measured memory_bytes: 5760
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<vector>
#include<map>
#include<queue>
#include<algorithm>
#include<functional>

using namespace std;

using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
using vll=vector<ll>;
using vvll=vector<vll>;


int main(void)
{
	int n;

	while(scanf("%d", &n)==1)
	{
		double ans=0.0;

		for(int i=0;i<n;i++)
		{
			double x;
			char u[10];

			scanf("%lf%3s", &x, u);

			if(strcmp(u, "BTC")==0) ans+=x*380000.0;
			else ans+=x;
		}
		printf("%.6f\n", ans);
	}

	return 0;
}


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

int main() {
    int q, y;
    int max = 1;
    int top;
    cin >> q >> y;
    if (q > y) {
        top = y;
    } else {
        top = q;
    }

    for (int i = 1; i < top / 2; i++) {
        if ((q % i == 0) && (y % i == 0)){
            if (i > max) {
                max = i;
            }
        }
    }
    if(q == y) {
        max = q;
    }

    cout << max << endl;

}


Measured memory_bytes: 3088
#include<iostream>
#include<vector>
#include<cmath>
#include<string>
#include<algorithm>
#include<map>
#include<utility>
#include<cstdio>
#include<bits/stdc++.h>

using namespace std;
using ll = long long;
const long long INF = 1LL<<60;

typedef pair<ll,ll> Pair;
int main(){

string S,T;
ll ans = 0;

cin >> S >> T;

ll N = S.length() - T.length();
ll M = T.length();

for (ll i = 0; i <= N;++i){

    string tmpstring = S.substr(i, T.length());
    ll tmpcnt = 0;
    
    for (ll j = 0; j < M;++j){

        if(tmpstring[j] == T[j]){  
            ++tmpcnt;
        }
    }

    ans = std::max(ans, tmpcnt);
    
}

cout << T.length() - ans << endl;

return 0;

}


Measured memory_bytes: 3616
import collections

n, m = [int(i) for i in input().split()]
ka = []
counter = 0

for i in range(n):
    l = list(int(i) for i in input().split())
    for j in l[1:]:
        ka.append(j)
        
c = collections.Counter(ka).most_common()

for i in c:
    if i[1] == n:
        counter += 1
print(counter)

Measured memory_bytes: 3316
N, M = map(int, input().split())
l = []
for i in range(M):
  l.append(list(map(int, input().split())))
  
class UnionFindVerSize():
    def __init__(self, N):
        """ N個のノードのUnion-Find木を作成する """
        # 親の番号を格納する。自分が親だった場合は、自分の番号になり、それがそのグループの番号になる
        self._parent = [n for n in range(0, N)]
        # グループのサイズ（個数）
        self._size = [1] * N

    def find_root(self, x):
        """ xの木の根(xがどのグループか)を求める """
        if self._parent[x] == x: return x
        self._parent[x] = self.find_root(self._parent[x]) # 縮約
        return self._parent[x]

    def unite(self, x, y):
        """ xとyの属するグループを併合する """
        gx = self.find_root(x)
        gy = self.find_root(y)
        if gx == gy: return

        # 小さい方を大きい方に併合させる（木の偏りが減るので）
        if self._size[gx] < self._size[gy]:
            self._parent[gx] = gy
            self._size[gy] += self._size[gx]
        else:
            self._parent[gy] = gx
            self._size[gx] += self._size[gy]

    def get_size(self, x):
        """ xが属するグループのサイズ（個数）を返す """
        return self._size[self.find_root(x)]

    def is_same_group(self, x, y):
        """ xとyが同じ集合に属するか否か """
        return self.find_root(x) == self.find_root(y)

    def calc_group_num(self):
        """ グループ数を計算して返す """
        N = len(self._parent)
        ans = 0
        for i in range(N):
            if self.find_root(i) == i:
                ans += 1
        return ans
      
uf = UnionFindVerSize(N+1)
for i in range(M):
  a, b = l[i][0], l[i][1]
  uf.unite(a, b)
  
a = uf.calc_group_num()
print(a-2)

Measured memory_bytes: 31956
import sys 
input = sys.stdin.readline
from heapq import *
def main():
  n, m = map(int, input().split())
  a = list( map(int, input().split()) )
  card = []
  for _ in range(m):
    card.append(list(map(int, input().split())))

  heapify(a)
  card.sort(key=lambda x:x[1], reverse=True)

  for i in range(m):
    for _ in range(card[i][0]):
      if a[0]<card[i][1]:
        heappushpop(a, card[i][1])
      else:
        break
  print(sum(a))

if __name__ == '__main__':
  main()


Measured memory_bytes: 32920
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
const ll INF=1e16;
struct edge {int to; long long int cap; int rev;} ;
 
vector<edge> G[2510];
int level[2510];
int iter[2510];
 
void add_edge(int from, int to, long long int cap){
	edge e;
	e.to=to, e.cap=cap, e.rev=G[to].size();
	G[from].push_back(e);
	e.to=from, e.cap=0, e.rev=G[from].size()-1;
	G[to].push_back(e);
}
 
void bfs(int s){
	memset(level, -1, sizeof(level));
	queue<int> que;
	level[s]=0;
	que.push(s);
	while(!que.empty()){
		int v=que.front();
		que.pop();
		for(int i=0; i<G[v].size(); i++){
			edge e=G[v][i];
			if(e.cap>0 && level[e.to]<0){
				level[e.to]=level[v]+1;
				que.push(e.to);
			}
		}
	}
}
 
long long int dfs(int v, int t, long long int f){
	if(v==t) return f;
	for(int &i=iter[v]; i<G[v].size(); i++){
		edge &e=G[v][i];
		if(e.cap>0 && level[v]<level[e.to]){
			long long int d=dfs(e.to, t, min(f, e.cap));
			if(d>0){
				e.cap-=d;
				G[e.to][e.rev].cap+=d;
				return d;
			}
		}
	}
	return 0;
}
 
long long int max_flow(int s, int t){
	long long int flow=0;
	while(1){
		bfs(s);
		if(level[t]<0) return flow;
		memset(iter, 0, sizeof(iter));
		long long int f;
		while((f=dfs(s, t, INF))>0){
			flow+=f;
		}
	}
}

int main()
{
    int h, w; ll W;
    cin>>h>>w>>W;
    int s=(h-1)*(w-1), t=(h-1)*(w-1)+1;
    for(int i=0; i<h-1; i++){
        for(int j=0; j<w-1; j++){
            if((i+j)&1) continue;
            if(i&1) add_edge(i*(w-1)+j, t, W);
            else add_edge(s, i*(w-1)+j, W);
        }
    }
    ll b[51][51];
    ll sum=0;
    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            cin>>b[i][j];
            sum+=b[i][j];
            if(i==0) add_edge(j-j%2, t, b[i][j]);
            else if(j==0) add_edge((i-i%2)*(w-1), t, b[i][j]);
            else if(i==h-1) add_edge((h-2)*(w-1)+j-j%2, t, b[i][j]);
            else if(j==w-1) add_edge((i-i%2)*(w-1)+w-2, t, b[i][j]);
            else if((i&1) && !(j&1)) add_edge((i-1)*(w-1)+j, i*(w-1)+j-1, b[i][j]);
            else if(!(i&1) && (j&1)) add_edge(i*(w-1)+j-1, (i-1)*(w-1)+j, b[i][j]);
            else if((i&1) && (j&1)) add_edge((i-1)*(w-1)+j-1, i*(w-1)+j, b[i][j]);
            else add_edge(i*(w-1)+j, (i-1)*(w-1)+j-1, b[i][j]);
        }
    }
    cout<<sum-max_flow(s, t)<<endl;
    return 0;
}


Measured memory_bytes: 3424