akhauriyash/Code-Regression huggingface dataset:
//abc113_a.cpp
//Sat Nov 10 12:19:24 2018

#include <iostream>
#include <string>
#include <queue>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;

int main(){
	int n,m;
	cin >> n >> m;
	cout << n+m/2<< endl;
}

Measured memory_bytes: 256
//CODING ME ACCHHA KARNEKA HAI TERKO TO BAS PRACTICE KARTE REH
#include <bits/stdc++.h>
#define pragma
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define pf push_front
#define aisort sort(a,a+n)
#define adsort sort(a,a+n,greater<ll>())
#define PI 2 * acos(0)

typedef pair<ll, ll> pii;
typedef pair<ll, pii> piii;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef vector<pii> vii;
typedef vector<piii> viii;
typedef set<ll> Set;

const ll maxs = 1e5+3;
const ll maxs1 = 1e3+4;
const ll mod = 1e9 + 7;

//MODULO OPEARTIONS
    inline ll add(ll a, ll b) { return (mod + a + b) % mod; }
    inline ll sub(ll a, ll b) { return (a - b + mod) % mod; }
    inline ll mul(ll a, ll b) { return (1ll * a * b) % mod; }

//POWER
    ll fastpow(ll x,ll y)
    {ll res = 1;x = x % mod;while (y > 0){ if (y & 1)res = (res * x) % mod; y = y >> 1 ; x = (x * x) % mod; } return res;}

//MODULAR INVERSE
    ll inv(ll x){ return fastpow(x , mod - 2);}
    
//PRIME
    bool isPrime(ll n) { if (n <= 1)  return false; if (n <= 3)  return true;if (n%2 == 0 || n%3 == 0) return false; for (int i=5; i*i<=n; i=i+6) if (n%i == 0 || n%(i+2) == 0) return false; return true; } 

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll n,m;
    cin>>n>>m;
    cout<<(n*(n-1))/2 + (m*(m-1))/2;
}




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

using namespace std;

int main(){
    int X,N;
    
    cin >> X >> N;
    vector<int> p(N);
    for(int i=0;i<N;i++){
        cin >> p[i];
    }

    for(int i=0;i<100;i++){
        bool ok1=true,ok2=true;
        for(int j=0;j<N;j++){
            if(X-i==p[j]){
                ok1 = false;
            }

            if(X+i==p[j]){
                ok2=false;
            }
        }

        if(ok1){
            cout << X-i << endl;
            return 0;
        }

        if(ok2){
            cout << X+i << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define mp make_pair
#define pb push_back
#define in insert
#define vll vector<ll>
#define endl "\n"
#define pll pair<ll,ll>
#define all(x) (x).begin() , (x).end()
#define f first
#define s second
#define pr(x) cout<<x<<endl;
#define pr2(x,y) cout<<x<<" "<<y<<endl;
#define pr3(x,y,z) cout<<x<<" "<<y<<endl;
#define prv(v) for(auto x:v) cout<<x<<" ";
#define ffs fflush(stdout);
#define int ll
#define sz(x) (ll)x.size()
using namespace std;
 
 
const ll MOD = 1e9+7;
const ll INF = 1e9;
const ll LOG = 29;
#define PI 3.141592653589793238 
 
 
 
const ll N =(5e6+5);
const ld ep = 1e-9;

ll fact[N];

long long binpow(long long a, long long b) {
     a%=MOD;    
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = (res * a)%MOD;
        a = (a * a)%MOD;
 
        
        b >>= 1;
    }
     res%=MOD;
    return res;
}
ll ncr(ll n,ll r){
    ll ret = fact[n];
    ret = (ret * binpow(fact[r],MOD-2))%MOD;
    ret = (ret * binpow(fact[n-r],MOD-2))%MOD;
    return ret;
}



void solve(){
    
    ll r1,c1,r2,c2;
    cin >> r1 >> c1 >> r2 >> c2;
    
    fact[0] = 1;
    for(int i = 1;i<N;i++){
        fact[i] = (fact[i-1] * i)%MOD;
    }
    ll ans = 0;
    for(int i = r1;i<=r2;i++){
        ans = (ans + (ncr(c2 + i + 1,i+1) - ncr(c1 + i,i + 1) + MOD))%MOD;
    }
    cout << ans << endl;
}


 
   
 
 
 /*
 2 3 4 5 6 
 3 6 10 15 21 
 4 10 20 35 56 
 5 15 35 70 126 
 6 21 56 126 252 
*/
 
 
signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    
       
 
    ll tt=1;
    while(tt--){
        solve();
    }    
}

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

using namespace std;

int main() {
  int N, K, Q;
  cin >> N >> K >> Q;
  vector<int> A(Q);
  for (auto &e : A) cin >> e;

  vector<int> points(N, K - Q); // 必ず Q 点減る
  for (auto &corrected : A) {
      points[corrected - 1] += 1;
  }

  for (auto &point : points) {
    if (point <= 0) {
      cout << "No\n";
    } else {
      cout << "Yes\n";
    }
  }
  return 0;
}


Measured memory_bytes: 1408
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <tuple>
using namespace std;

void print_board(vector<int> board, int W, int H) {
	if (0) {
		cout << "-----  board  -----\n";
		for (int h = 0; h < H; h++) {
			for (int w = 0; w < W; w++) {
				if (h % 2 == 0) {
					cout << board[h*W + w] << " ";
				}
				else {
					cout << board[h*W + W - 1 - w] << " ";
				}
			}
			cout << "\n";
		}
		cout << "-------------------\n";
	}
}

int main() {
	int H = 0, W = 0;
	cin >> H >> W;
	vector<int> board = vector<int>(H*W);

	for (int h = 0; h < H; h++) {
		for (int w = 0; w < W; w++) {
			if (h % 2 == 0) {
				cin >> board[h*W + w];
			}
			else {
				cin >> board[h*W + W - 1 - w];
			}
		}
	}

	string result = "";
	int op_size = 0;
	tuple<int, int, int, int> operation_list[500*500];
	//print_board(board, W, H);
	for (int h = 0; h < H; h++) {
		for (int w = 0; w < W; w++) {
			if (board[h*W + w] % 2 == 1 && (h*W + w) < (H*W) - 1) {
				board[h*W + w]--;
				board[h*W + w + 1]++;

				if (h % 2 == 0) {
					if (w == W - 1) {
						operation_list[op_size] = (make_tuple(h + 1, w + 1, h + 2, w + 1));
					}
					else {
						operation_list[op_size] = (make_tuple(h + 1, w + 1, h + 1, w + 2));
					}
					//print_board(board, W, H);
				}
				else {
					if (w == W - 1) {
						operation_list[op_size] = (make_tuple(h + 1, W - w, h + 2, W - w));
					}
					else {
						operation_list[op_size] = (make_tuple(h + 1, W - w, h + 1, W - w - 1));
					}
					//print_board(board, W, H);
				}
				op_size++;
			}
		}
	}
	//print_board(board, W, H);

	cout << op_size << "\n";
	//  cout << result;
	for (int i = 0; i < op_size; i++) {
		int a, b, c, d;
		tie(a, b, c, d) = operation_list[i];
		cout << a << " " << b << " " << c << " " << d << "\n";
	}
	return 0;
}

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

int main() {
  bool a = false;
  bool b = false;
  bool c = false;
  string s;
  cin >> s;
  for (int i = 0; i < 3; i++) {
    if (s.at(i) == 'a') a = true;
    if (s.at(i) == 'b') b = true;
    if (s.at(i) == 'c') c = true;
  }
  if (a && b && c) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
//by Sshwy
//#define DEBUGGER
#include<algorithm>/*{{{*/
#include<cctype>
#include<cassert>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<ctime>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<vector>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define ROF(i,a,b) for(int i=(a);i>=(b);--i)

#ifdef DEBUGGER

#define log_prefix() { fprintf(stderr, "\033[37mLine %-3d [%dms]:\033[0m  ", __LINE__,(int)clock()/1000);  }
#define ilog(...)    { fprintf(stderr, __VA_ARGS__); }
#define llog(...)    { log_prefix(); ilog(__VA_ARGS__); }
#define log(...)     { log_prefix(); ilog(__VA_ARGS__); fprintf(stderr,"\n");  }
#define red(...)     { log_prefix(); ilog("\033[31m"); ilog(__VA_ARGS__); ilog("\033[0m\n"); }
#define green(...)   { log_prefix(); ilog("\033[32m"); ilog(__VA_ARGS__); ilog("\033[0m\n"); }
#define blue(...)    { log_prefix(); ilog("\033[34m"); ilog(__VA_ARGS__); ilog("\033[0m\n"); }

#else

#define log_prefix() ;
#define ilog(...)    ;
#define llog(...)    ;
#define log(...)     ;
#define red(...)     ;
#define green(...)   ;
#define blue(...)    ;

#endif

namespace RA{
    int r(int p){return 1ll*rand()*rand()%p;}
    int r(int L,int R){return r(R-L+1)+L;}
}/*}}}*/
/******************heading******************/
const int N=1e5+5;
vector<int> g[N];

int n;

int w[N],dep[N],fa[N];
void dfs(int u,int p){
    w[u]=u>n?u-n:u;
    w[u]^=w[p];
    dep[u]=dep[p]+1;
    fa[u]=p;
    printf("u %d fa %d w %d\n",u,fa[u],w[u]);
    for(int v:g[u])if(v!=p)dfs(v,u);
}
int lca(int x,int y){
    while(x!=y){
        if(dep[x]<dep[y])swap(x,y);
        x=fa[x];
    }
    return x;
}
int main(){
    cin>>n;
    if(__builtin_popcount(n)==1)return cout<<"No"<<endl,0;
    assert(n>=3);
    vector< pair<int,int> > ans;
    for(int x=2;x<n;x+=2){
        ans.pb({1,x});
        ans.pb({x,n+x+1});
        ans.pb({1,x+1});
        ans.pb({x+1,n+x});
    }
    ans.pb({n+1,n+3});
    if(n%2==0){
        bool flag=0;
        FOR(x,2,n){
            int y=x^1^n;
            if(1<=y && y<=n){
                ans.pb({x,n});
                ans.pb({y,n+n});
                flag=1;
                break;
            }
        }
        assert(flag);
    }
    cout<<"Yes"<<endl;
    for(auto x:ans)cout<<x.fi<<" "<<x.se<<endl;
    //for(auto x:ans)g[x.fi].pb(x.se),g[x.se].pb(x.fi);
    //dfs(1,0);
    //FOR(i,1,n)assert(w[i]^w[n+i]^w[lca(i,n+i)]^w[fa[lca(i,n+i)]]==i);
    return 0;
}


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

int main(){
    int n,k;
    cin >> n >> k;
    vector <int> num(10,1);
    int d;
    rep(i,k){
        cin >> d;
        num[d]=0;
    }

    queue <int> q;
    rep(i,10){
        if(i!=0 and num[i]==1){
            q.push(i);
        }
    }

    int qq;
    while(1){
        qq=q.front();
        q.pop();
        if(qq>=n){
            cout << qq << endl;
            break;
        }
        rep(i,10){
        if(num[i]==1){
            q.push(10*qq+i);
        }
    }
    }
    
    
    

    return 0;
}

Measured memory_bytes: 3716
def updiv(a,b):

    if a % b == 0:
        return a // b
    else:
        return a // b + 1


N = int(input())

p = list(map(int,input().split()))


now = 0
ans = 0

for i in range(N):

    if p[i] == i + 1:
        now += 1
    else:
        ans += updiv(now , 2)
        now = 0

ans += updiv(now,2)

print (ans)
    


Measured memory_bytes: 53068
#include <bits/stdc++.h>
#define N 31
#define INF (1e9)
using namespace std;
typedef pair<double,int> P;
typedef  pair<P,int> PP;
struct dat{
  double cost;
  int pos,pre,v;
  bool operator > (dat x)const{return cost>x.cost;}
};
int n,m;
vector<PP> G[N];

double dijkstra(int s,int g){
  double D[N][N][N];
  for(int i=0;i<N;i++)
    for(int j=0;j<N;j++)
      for(int k=0;k<N;k++)D[i][j][k]=INF;
  priority_queue<dat,vector<dat>,greater<dat> >Q;
  Q.push((dat){0,s,-1,0});
  D[s][s][1]=0;
  while(!Q.empty()){
    dat t=Q.top();Q.pop();
    double cost=t.cost;
    int v=t.v;
    int pos=t.pos,pre=t.pre;
    if(D[pos][pre][v]<cost)continue;
    if(pos==g&&v==1) return cost;

    for(int i=max(1,v-1);i<=v+1;i++){
      for(int j=0;j<G[pos].size();j++){
	double ncost=cost+G[pos][j].first.first/i;
	int mxv=G[pos][j].first.second;
	int nx=G[pos][j].second;
	if(nx==pre||mxv<i||D[nx][pos][i]<=ncost)continue;
	Q.push((dat){ncost,nx,pos,i});
	D[nx][pos][i]=ncost;
      }
    }
  }
  return -1;
}

int main(){
  while(1){
    cin>>n>>m;
    if(!n&&!m)break;
    int s,g;
    cin>>s>>g;s--,g--;
    for(int i=0;i<n;i++)G[i].clear();
    for(int i=0,a,b,d,c;i<m;i++){
      cin>>a>>b>>d>>c;a--,b--;
      G[a].push_back(PP(P(d,c),b));
      G[b].push_back(PP(P(d,c),a));
    }
    double ans=dijkstra(s,g);
    if(ans==-1) cout<<"unreachable"<<endl;
    else printf("%.12f\n",ans);
  }
  return 0;
}

Measured memory_bytes: 3764
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=1; i<(int)(n); i++)
int D, c[27], s[366][27];

int saga(int d, vector<int> &L){
  int S=0;
  REP(i, 27){ S+=c[i]*(d-L[i]); }
  return S;
}

int main(){
  cin >> D; D++;
  REP(i, 27){ cin >> c[i]; }
  REP(i, D){ REP(j, 27){ cin >> s[i][j]; } }
  int t[D]={}; vector<int> last(27, 0);

  REP(i, D){
    int a=1, S=-1000000, u=0, m=0;
    REP(j, 27){
      u=s[i][j]; u-=saga(i, last); u+=c[j]*(i-last[j]);
      if(S<u){ a=j; S=u; }
    }
    t[i]=a; last[a]=i;
  }
  REP(i, D){ cout << t[i] << "\n"; }
}


Measured memory_bytes: 3660
from fractions import gcd

a,b,c,d=map(int,input().split())

ok1=b-a+1
ng1=b//c-a//c if a%c!=0 else b//c-a//c+1
ng2=b//d-a//d if a%d!=0 else b//d-a//d+1
lcm=(c*d)//gcd(c,d)
ok2=b//lcm-a//lcm if a%lcm!=0 else b//lcm-a//lcm+1

print(ok1-ng1-ng2+ok2)

Measured memory_bytes: 5048
program main
  implicit none
  character(len=100000) :: s
  integer :: n, q, i, j, k, l, r
  integer, allocatable :: a(:), ans(:)

  read *, n, q
  read *, s

  allocate (a(n), ans(q))
  ans(:) = 0
  a(:) = 0

  do i = 1, len_trim(s) - 1
    if (s(i:i+1) == 'AC') then
      a(i+1:) = a(i+1:) + 1
    end if
  end do 

  do k = 1, q
    read *, l, r
    ans(k) = a(r) - a(l)
  end do

  do k = 1, q
    print '(i0)', ans(k)
  end do

end

Measured memory_bytes: 1956
#include <cstdio>
#include <algorithm>
#include <utility>
#include <vector>
using namespace std;

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

    vector<pair<int, int>> pairs;
    int elem;
    for (int i = 0; i < n; i++) {
        scanf("%d", &elem);
        pairs.push_back(make_pair(elem, i));
    }

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

    int cont = 1, maxCont = 0;
    for (vector<pair<int, int>>::iterator it = pairs.begin(); it < pairs.end() - 1; it++) {
        if (it->second < (it+1)->second) {
            cont++;
        } else {
            if (cont > maxCont) {
                maxCont = cont;
            }
            cont = 1;
        }
    }
    if (cont > maxCont) {
        maxCont = cont;
    }
    
    printf("%d\n", n - maxCont);

    return 0;
}

Measured memory_bytes: 2420
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<functional>
#include<queue>
#include <iomanip>
#include<map>
#include<limits>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<utility>
#include<complex>
#include<cstdlib>
#include<set>
#include<cctype>
 
#define DBG cerr << '!' << endl;
#define REP(i,n) for(int (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(int (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(int (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int i = 0;i < (n);i++)cerr << v[i] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
 
using namespace std;
 
typedef long long ll;
typedef vector<int> iv;
typedef vector<iv> iiv;
typedef vector<string> sv;
 
int main()
{
	string str;cin >> str;
	string tmp = "AKIHABARA";
	
	if(str.size() > tmp.size())
	{
		cout << "NO" << endl;
		return 0;
	}
	
	int cou = 0;
	for(int i = 0;i < str.size() ;i++)
	{
		if(str[i] == tmp[cou])
		{
			cou++;
		}
		else if(tmp[cou] == 'A')
		{
			cou++;
			i--;
		}
		else
		{
			cout << "NO" << endl;
			return 0;
		}
	}
	
	if(cou == tmp.size() - 1 || cou == tmp.size())
	{
		cout << "YES" << endl;
	}
	else
	{
		cout << "NO" << endl;
	}
	
	
	return 0;
}

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

#define rep(i,n) for(int i = 0; i < (n); i++)
#define ll long long

using namespace std;

int main(){
  int h,w;cin>>h>>w;
  set<pair<int, int>> moved;
  rep(y, h){
    string s;cin>>s;
    rep(x,w){
      if(s[x]=='#')moved.insert(make_pair(y,x));
    }
  }

  bool f=true;
  rep(y, h){
    rep(x,w){
      bool d_r = !(moved.count(make_pair(y+1, x)) ^ moved.count(make_pair(y, x+1)));
      bool u_l = !(moved.count(make_pair(y-1, x)) ^ moved.count(make_pair(y, x-1)));

      if( (y==0 && x==0 && d_r) || (y==h-1 && x==w-1 && u_l) || !(y==0 && x==0)&&!(y==h-1 && x==w-1)&& 
 moved.count(make_pair(y,x)) && (u_l || d_r) ){
//cout<<y<<' '<<x<<'|'<<u_l<<' '<<d_r<<endl;
        f=false;break;
      }
    }
  }

  if(f) cout<<"Possible";
  else cout<<"Impossible";

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define all(vec) vec.begin(), vec.end()
#define END return 0
typedef int64_t ll;
const int mod7 = 1e9 + 7;
const int mod9 = 1e9 + 9;
const int inf = 1 << 30;
const ll INF = 1LL << 60;
template<typename T> T gcd(T a, T b) {return b ? gcd(b, a % b) : abs(a);}
template<typename T> T lcm(T a, T b) {return a / gcd(a, b) * b;}
template<typename T> bool chmax(T &a, T b) {if (a < b) {a = b; return true;} return false;}
template<typename T> bool chmin(T &a, T b) {if (a > b) {a = b; return true;} return false;}
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val) {fill((T*)array, (T*)(array+N), val);}

int n;
using P = pair<int, int>;
int l[100][100];
int d[100];

void dijkstra(int start) {
    fill(d, d + 100, inf);
    d[start] = 0;
    priority_queue<P, vector<P>, greater<P>> que;
    que.push({0, start});
    while(!que.empty()) {
        P p = que.top();
        que.pop();
        rep(i, n)
            if(chmin(d[i], p.first + l[p.second][i]))
                que.push({d[i], i});
    }
}

int main() {
    Fill(l, inf);
    cin >> n;
    rep(i, n) {
        int u, k;
        cin >> u >> k;
        rep(i, k) {
            int v, c;
            cin >> v >> c;
            l[u][v] = c;
        }
    }
    dijkstra(0);
    rep(i, n) cout << i << ' ' << d[i] << endl;
}


Measured memory_bytes: 3148
import java.io.PrintWriter

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun nextList() = next().split(" ")
fun nextIntList() = nextList().map(String::toInt)
fun nextLongList() = nextList().map(String::toLong)
fun nextDoubleList() = nextList().map(String::toDouble)

val pw = PrintWriter(System.out)
fun print(s: Any = "") = pw.print(s)
fun println(s: Any = "") = pw.println(s)

fun <T> Iterable<T>.join(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "") = joinToString(separator, prefix, postfix)
fun <T> Array<T>.join(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "") = joinToString(separator, prefix, postfix)

fun main(args: Array<String>) {
    main()
    pw.flush()
}

fun main() {
    val S = next()
    val T = next()
    println(if (T.startsWith(S)) "Yes" else "No")
}


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

#define ll long long int
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define inf  1e18
#define mk(arr,n,type) type *arr=new type[n];
#define ti(arr,n) for(ll i=0;i<n;++i)cin>>a[i];
#define ot(arr,n) for(ll i=0;i<n;++i)cout<<a[i]<<" ";
#define str(a) string a;cin>>a;
#define w(x) int x;cin>>x;while(x--)
int main()
{
    ll n;cin>>n;
    ll sum=0,ma=0,num;
    cin>>num;
    ma=num;
    for(ll i=1;i<n;++i)
    {
       cin>>num;
       if(num<ma)
       {
          sum=sum+(ma-num);
       }
       else if(num>ma)
          ma=num;
    }
    cout<<sum;

}


Measured memory_bytes: 3600
#include <stdio.h>
int main(){
  int a,b,c,x,cnt=0;

  scanf("%d %d %d",&a,&b,&c);
  
  for(x = a;x <= b;x++){
    
    if(c % x == 0){
      cnt++;
    }
    
  }
  
  printf("%d\n",cnt);
  
  return 0;
  
}

Measured memory_bytes: 596
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <string>
#include <cmath>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#define  ms(a,b) memset(a,b,sizeof(a))

using namespace std;
typedef long long LL;
const LL INF=1e17L;
const int inf=0x3f3f3f3f;
const int maxn=1e5+5;
const int Mod=1e9+7;
int n,a[maxn];
int main()
{
    cin>>n;
    for(int i=1;i<=n;i++)
        cin>>a[i];
    sort(a+1,a+n+1);
    cout<<a[n]-a[1]<<endl;
    return 0;
}


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

int main(){
	int N;
	scanf("%d",&N);
	int ans=0;
	
	while(N){
		int now=N%10;
		N/=10;
		if(now==2){
			ans++;
		}
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <array>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int main() {
    int n, a, b;
    cin >> n >> a >> b;
    cout << min(n*a, b) << endl;


    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main(){
    int a,b,x;
    cin >> a >> b >> x;
    if(x-a<=b && x-a>=0){
        cout << "YES" << endl;
    }else{
        cout<< "NO" << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <stack>
#include <complex>
#include <stdlib.h>
#include <stdio.h>
#include <functional>
#include <cfloat>
#include <math.h>
#include <numeric>
#include <string.h>
#include <sys/time.h>
#include <random>


#define fs first
#define sc second
#define endl "\n"

using namespace std;

typedef long long ll;
typedef unsigned int uint;
typedef pair<int, int> P;


int main(){
    char c; cin >> c;
    if(c == 'A')    cout << 'T' << endl;
    else if(c == 'T') cout << 'A' << endl;
    else if(c == 'G') cout << 'C' << endl;
    else cout << 'G' << endl;




    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int W,H,x,y,r;
    cin>>W>>H>>x>>y>>r;
    if(x+r>W||y+r>H){
        cout<<"No"<<endl;
    }
    else if(x-r<0||y-r<0){
        cout<<"No"<<endl;
    }
    else{
        cout<<"Yes"<<endl;
    }
}


Measured memory_bytes: 3092
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    if len(x) == 0:
        return []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False

def pow_k(x, n):
    ans = 1
    while n:
        if n % 2:
            ans *= x
        x *= x
        n >>= 1
    return ans

"""
def nibu(x,n,r):
    ll = 0
    rr = r
    while True:
        mid = (ll+rr)//2

    if rr == mid:
        return ll
    if (ここに評価入れる):
        rr = mid
    else:
        ll = mid+1
"""

a,b,c,k = m()



ans = 0

if a <= k:
    ans += a
    k -= a
    if b <= k:
        k -= b
        if k >= 0:
            ans -= k

else:
    ans += k



print(ans)


Measured memory_bytes: 65196
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define _GLIBCXX_DEBUG
static const int MAX = 20;

int main(){
  int N;
  cin >> N;
  int H[MAX];
  int count = 1;
  int Hmax;
  rep(i, N) cin >> H[i];
  Hmax = H[0];
  rep2(i, 1, N){
    if(Hmax <= H[i]) count++;
    Hmax = max(H[i], Hmax);
  }

  cout << count << endl;
}

Measured memory_bytes: 256
n=int(input())
ln = list(map(int, input().split()))
f = 0
for i in range(n):
  if ln[i]%2==0:
    if ln[i]%3!=0:
      if ln[i]%5!=0:
        f += 1

if f == 0:
  print("APPROVED")
else:
  print("DENIED")


Measured memory_bytes: 38576
#include<bits/stdc++.h>
#include<algorithm>
#define ll long long
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

using namespace std;
int main()
{
    fast_io
    ll t,i,j,n,a,b;
    char c;
    cin>>a>>c>>b;
    if(c=='+')
        cout<<a+b<<endl;
     else   cout<<a-b<<endl;

    return 0;
}





Measured memory_bytes: 3636
/*+lmake
 * STD = c++14
 * DEFINE += WAAUTOMATON
 */
#include <bits/stdc++.h>
using namespace std;
using LL=long long;
using ULL=unsigned long long;
#ifdef WAAUTOMATON
     #define debug(args...)            {dbg,args; cerr<<endl;}
#else
    #define debug(args...)              // Just strip off all debug tokens
#endif

struct debugger
{
    template<typename T> debugger& operator , (const T& v)
    {    
        cerr<<v<<" ";    
        return *this;    
    }
} dbg;
vector<pair<LL,int>> x;
void solve(long long N, vector<long long> A){
	for(int i=0; i<N; ++i) {
		x.push_back(make_pair(A[i],i+1));
	}
	sort(x.begin(),x.end());
	int cnt=0;
	for(int i=0; i<N; ++i) {
		debug(x[i].second);
		if (x[i].second%2==i%2) ++cnt;
	}
	cout<<cnt/2<<endl;
}

int main(){	
#ifdef WAAUTOMATON
	//freopen("in.txt","r",stdin);
#endif
	long long N;
	scanf("%lld",&N);
	vector<long long> A(N-1+1);
	for(int i = 0 ; i <= N-1 ; i++){
		scanf("%lld",&A[i]);
	}
	solve(N, A);
	return 0;
}



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

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

	string s;
	cin >> s;
	sort(s.begin(), s.end());
	if (s[0] == s[1]) {
		if (s[2] == s[3]) {
			if (s[1] != s[2]) {
				cout << "Yes";
			}
			else cout << "No";
		}
		else cout << "No";
	}
	else cout << "No";
}

Measured memory_bytes: 256
N, M = map(int, input().split())
E = [[int(x) - 1 for x in input().split()] for _ in range(M)]

ans = 0
for i in range(M):
    G = [set() for _ in range(N)]
    for j in range(M):
        if i == j:
            continue
        a, b = E[j]
        G[a].add(b)
        G[b].add(a)

    todo = [0]
    done = set()
    while todo:
        p = todo.pop()
        done.add(p)
        for np in G[p]:
            if not np in done:
                todo.append(np)

    if len(done) < N:
        ans += 1
print(ans)

Measured memory_bytes: 3188
#include<iostream>
#include<vector>
#include<cstdlib>
template<typename T>
void fin(T const& t){ std::cout << t << std::endl; exit(0); }

int main() {
  std::cin.tie(0); std::ios::sync_with_stdio(false);
  int N; std::cin >> N;
  std::vector<std::vector<int>> G(N);
  for(int i = 0; i < N-1; ++i) {
    int x, y; std::cin >> x >> y; --x; --y;
    G[x].push_back(y);
    G[y].push_back(x);
  }
  auto dfs = [&](auto&& f, int v, int p)->int {
    int res = 0;
    for(int c: G[v])if(c != p) res ^= f(f, c, v);
    return res+1;
  };
  int ans = dfs(dfs, 0, -1);
  fin(ans==1? "Bob": "Alice");
  return 0;
}


Measured memory_bytes: 8704
#include<iostream>
#include<string>

int main() {
  int N; std::string S; std::cin >> N >> S;
  int ans = 0;
  for(int i = 0; i < N-2; ++i) if(S[i]=='A' && S[i+1]=='B' && S[i+2]=='C') ++ans;
  std::cout << ans << std::endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
 
int main()
{
    int n, m, l;
    int a[100][100], b[100][100];
    long c[100][100];
 
    cin >> n >> m >> l;
 
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            cin >> a[i][j];
        }
    }
 
    for (int i = 0; i < m; i++) {
        for (int j = 0; j < l; j++) {
            cin >> b[i][j];
        }
    }
 
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            for (int k = 0; k < l; k++) {
                c[i][k] += a[i][j] * b[j][k];
            }
        }
    }
 
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < l; j++) {
            if (j == l - 1) {
                cout << c[i][j];
            } else {
                cout << c[i][j] << ' ';
            }
        }
 
        cout << endl;
    }
 
    return 0;
}

Measured memory_bytes: 1316
N, P = map(int, input().split())
S = list(input())

if P != 2 and P != 5:
    count = [0] * P
    ans = 0
    tmp = 0
    for i in range(N - 1, -1, -1):
        tmp += int(S[i]) * pow(10, (N - 1 - i), P)
        tmp %= P
        ans += count[tmp]
        count[tmp] += 1
    ans += count[0]

    # print (count)
    print (ans)

if P == 2:
    count = 0
    for index, s in enumerate(S):
        if int(s) % 2 == 0:
            count += (index + 1)
    print (count)

if P == 5: 
    count = 0
    for index, s in enumerate(S):
        if int(s) % 5 == 0:
            count += (index + 1)
    print (count)

Measured memory_bytes: 61936
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

signed main()
{
    string s; cin>>s;
    const int N=s.size();

    if(s[0]!='A'){
        cout<<"WA"<<endl;
        return 0;
    }

    int cnt=0;
    for(int i=2;i<=N-2;i++){
        if(s[i]=='C') cnt++;
    }
    if(cnt!=1){
        cout<<"WA"<<endl;
        return 0;
    }

    cnt=0;
    REP(i,N){
        if('a'<=s[i] and s[i]<='z') cnt++;
    }
    if(cnt<N-2){
        cout<<"WA"<<endl;
        return 0;
    }
    cout<<"AC"<<endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    Scanner scanner = new Scanner(System.in);

    public static void main(String[] args) {
        new Main().compute();
    }

    void compute() {
        int X=scanner.nextInt(),i=1;
        for(int sum=0;sum<X;i++){
            sum+=i;
        }
        System.out.println(i-1);
    }
}


Measured memory_bytes: 21844
use std::cmp;
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

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

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

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

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

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

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

fn main() -> () {
    input!{
        n: usize,
        k: usize,
        xs: [i32; n],
    }
    let mut ans = std::i32::MAX;
    for ni in 0..n-k + 1 {
        let len = xs[ni+k-1] - xs[ni];
        let a = len + cmp::min(xs[ni].abs(), xs[ni+k-1].abs());
        if (a < ans) {
            ans = a;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
int main(){
    int a[3][3];
    for(int i=0; i<3; i++){
        for(int j=0; j<3; j++){
            cin >> a[i][j];
        }
    }
    int n;
    cin >> n;
    int b[200];
    for(int i=0; i<n; i++){
        cin >> b[i];
    }
    bool isChecked[3][3];
    for(int i=0; i<3; i++){
        for(int j=0; j<3; j++){
            isChecked[i][j] = false;
        }
    }

    for(int i=0; i<n; i++){
        for(int j=0; j<3; j++){
            for(int k=0; k<3; k++){
                if(b[i] == a[j][k]){
                    isChecked[j][k] = true;
                }
            }
        }
    }

    bool hasBingo = false;

    for(int i=0; i<3; i++){
        if(isChecked[i][0] && isChecked[i][1] && isChecked[i][2]){
            hasBingo = true;
        }
        if(isChecked[0][i] && isChecked[1][i] && isChecked[2][i]){
            hasBingo = true;
        }
    }
    if(isChecked[0][0] && isChecked[1][1] && isChecked[2][2]){
        hasBingo = true;
    }
    if(isChecked[0][2] && isChecked[1][1] && isChecked[2][0]){
        hasBingo = true;
    }

    if(hasBingo){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int H, W, i, j = 0;
	
	while(1){
		scanf("%d %d", &H, &W);
		if(H == 0 && W == 0) break;
		for(i = 0; i < H; i++){
			for(j = 0; j < W; j++){
				if(i != 0 && i != H-1 && j != 0 && j != W-1){
					printf(".");
				} else {
					printf("#");
				}
			}
			printf("\n");
		}
		printf("\n");
	}
	return 0;
}
	
	


Measured memory_bytes: 2036
import java.util.Scanner;
import java.util.Arrays;

public class Main {

    public static void main(String[] args) {
        new Main().solve();
    }

    void solve() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        String[] s = new String[N];
        for (int i = 0; i < N; i++) {
            s[i] = sc.next();
        }
        int M = sc.nextInt();
        String[] t = new String[M];
        for (int i = 0; i < M; i++) {
            t[i] = sc.next();
        }
        Arrays.sort(s);
        Arrays.sort(t);
        int sa = 0;
        int ta = 0;
        int ans = 0;
        int tmp = 0;
        for (int i = 0; i < N; i++) {
            for (int j = 0; j < N; j++) {
                if (s[i].equals(s[j])) {
                    sa++;
                }
            }
            for (int k = 0; k < M; k++) {
                if (t[k].equals(s[i])) {
                    ta++;
                }
            }
            tmp = sa - ta;
            if (tmp < 0) {
                tmp = 0;
            }
            ans = Math.max(ans, tmp);
            sa=0;
            ta=0;
        }
         System.out.println(ans);
    }
   

}


Measured memory_bytes: 21972
n = int(input())
a = list(map(int, input().split()))
dic_a = {}

for i in a:
    if i not in dic_a:
        dic_a[i] = 1
    else:
        dic_a[i] += 1

dic_a = dic_a.items()
ans = 0

for j in dic_a:
    if j[0] <= j[1]:
        ans += j[1] - j[0]
    elif j[0] > j[1]:
        ans += j[1]

print(ans)

Measured memory_bytes: 17780
import java.io.*;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.NoSuchElementException;
import java.util.Scanner;
public class Main {
	static ArrayList<Integer> listX = new ArrayList<Integer>();
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		FastScanner sc = new FastScanner();
		
		makePrimeList(104730);
		while(true) {
			int n = (int) sc.nextLong();
			if(n == 0) break;
			
			System.out.println(listX.get(n-1));
		}
	}
	public static void makePrimeList(int n) {
		boolean[] isntPrime = new boolean[n];
		isntPrime[0] = isntPrime[1] = true;
		int sum = 2;
		listX.add(2);
		for(int i = 3; i < n; i+= 2) {
			if(!isntPrime[i]) {
				sum += i;
				listX.add(sum);
				for(int j = i + i; j < n; j+= i) {
					isntPrime[j] = true;
				}
			}
		}
	}

	
	
}
class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    private void skipUnprintable() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
    public boolean hasNext() { skipUnprintable(); return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
}

Measured memory_bytes: 19948
#include<stdio.h>
int main(){
	double a,b,c,d,e,f,bb,cc,ee,ff,x,y;
	for(;;){
		if(scanf("%lf",&a)==EOF){break;}
		scanf("%lf",&b);
		scanf("%lf",&c);
		scanf("%lf",&d);
		scanf("%lf",&e);
		scanf("%lf",&f);
		bb=b*d;
		cc=c*d;
		ee=e*a;
		ff=f*a;
		y=(cc-ff)/(bb-ee);
		x=(c-b*y)/a;
		printf("%.3lf %.3lf\n",x,y);
	}
	return 0;
}

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


bool vector_finder(std::vector<ll> vec, ll number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) {
    return true;
  }
  else {
    return false;
  }
}


int main() {
    ll K;
    string S;

    cin >> K >> S;

    ll L = S.size();

    if (L > K) S = S.substr(0, K) + "...";
    

    cout << S << endl;
    
    
    return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#include <string.h>
using namespace std;

int main (void){

  char a;
  int *A = new int[4];
  for(int i = 0;i < 4; i++){
    cin >> a;
    A[i] = a - '0';
  }
  int s1,s2;
  s1 = A[0]*10 + A[1];
  s2 = A[2]*10 + A[3];

  if(0 < s1 && s1 < 13 && 0 < s2 && s2 < 13){
    cout << "AMBIGUOUS";
  }else if(-1 < s1 && 0 < s2 && s2 < 13){
    cout << "YYMM";
  }else if(-1 < s2 && 0 < s1 && s1 < 13){
    cout << "MMYY";
  }else{
    cout << "NA";
  }

  printf("\n");
  delete[] A;
  return 0;
}

Measured memory_bytes: 256
N = int(input())
res = [0, 0, 0, 0]
for _ in range(N):
    s = input()
    if s == 'AC':
        res[0] += 1
    elif s == 'WA':
        res[1] += 1
    elif s == 'TLE':
        res[2] += 1
    else:
        res[3] += 1
print('AC x', res[0])
print('WA x', res[1])
print('TLE x', res[2])
print('RE x', res[3])

Measured memory_bytes: 69940
/*
 * @Author: Kaizyn
 * @Date: 2020-08-22 21:22:54
 * @LastEditTime: 2020-08-22 21:24:43
 */
#include <bits/stdc++.h>

// #define DEBUG

using namespace std;

const double eps = 1e-7;
const double PI = acos(-1);
typedef pair<int, int> pii;
const int MOD = 998244353;
const int INF = 0x3f3f3f3f;
const int N = 2e5+7;

int n;
int a[N], mv[N];

inline void solve() {
  cin >> n;
  long long res = 0;
  for (int i = 1; i <= n; ++i) {
    cin >> a[i];
    if (a[i] < mv[i-1]) res += mv[i-1]-a[i];
    mv[i] = max(mv[i-1], a[i]);
  }
  cout << res << endl;
}

signed main() {
  ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
  int T = 1;
  // cin >> T;
  for (int t = 1; t <= T; ++t) {
    solve();
  }
  return 0;
}

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

int main(){
  int a , b , c, d;
  cin >> a >> b >> c >> d;
  if(a + b > c + d) cout << "Left" << endl;
  else if(a + b == c + d) cout << "Balanced" << endl;
  else if(a + b < c + d) cout << "Right" << endl;

  return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            //print a b : a????????????b??????????????§???????????????
            //reverse a b : a????????????b??????????????§??????????????????
            //replace a b p :a????????????b??????????????§???p???????????????

            //?????????str?????\???
            string str = Console.ReadLine();
            //????????°q?????\???
            int q = int.Parse(Console.ReadLine());
            for (int i = 0; i < q; i++)
            {
                string[] comand = Console.ReadLine().Split(' ');
                int a = int.Parse(comand[1]);
                int b = int.Parse(comand[2]);

                switch(comand[0])
                {
                    case "print":
                        Console.WriteLine(str.Substring(a,b-a+1));
                        break;
                    case "reverse":
                        string s2 = str.Substring(a, b - a + 1);
                        char[] ch = str.ToCharArray(a,b-a+1);
                        Array.Reverse(ch);//??????ch????????????????????????
                        string s = new string(ch);
                        str = str.Replace(s2, s);
                        break;
                    /*case "replace":
                        string p = comand[3];
                        s2 = str.Substring(a, b - a + 1);
                        str = str.Replace(s2, p);
                        break;
                    */
                    case "replace":
                        string p = comand[3];
                        s2 = str.Substring(a, b - a + 1);
                        string str1 = str.Substring(0, a);
                        string str2 = str.Substring(b+1);
                        str = str1 + p + str2;
                        break;
                }
            }
        }
    }
}

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

using namespace std;

#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(obj)	(obj).begin(),(obj).end()

typedef unsigned int 			uint;
typedef unsigned long long int	ull;
typedef long long int 			ll;

typedef pair<int,int>			P;
typedef vector<int>				V;
typedef vector<V>				VV;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define LINF		((ll)1 << 63 -1)
#define INF 		(1<<29)
#define MINF		-2000000007
#define MAX 		100050

const int MOD = 1e9+7;
// テンプレ終了
//====================================================================//



//
int main(){
	int r;
	cin >> r;

	cout << (3*r*r) << endl;




	return 0;
}




Measured memory_bytes: 256
from collections import Counter
n=int(input())
ar=list(map(int,input().split()))
x=Counter(ar)
dct={}
y=list(set(ar))
pair=0
#print(x)
for i in y:
    ct=x[i]-1
    pair+=(ct*(ct+1))//2
#print(pair)
for i in range(n):
    el=ar[i]
    ct=x[el]-1
    add=((ct*(ct+1))//2)-(((ct-1)*((ct-1)+1))//2)
    #print("fff",add)
    print(pair-add)

Measured memory_bytes: 26780
#include<bits/stdc++.h>
#define fl(i,a,n)      for(int i=a;i<=n;i++)
#define pb             push_back
#define int            long long int
#define ump            unordered_map
#define pii            pair<int,int>
#define ff             first
#define ss             second
#define PI             3.1415926535898
#define inf            1e18
#define vi             vector<int>
#define endl           "\n"
#define print(a)       for(auto x:a){cout<<x<<" ";}cout<<endl;
#define mod            1000000007
#define MAXN 1000001
using namespace std;
template <typename Arg, typename... Args>
void db(Arg&& arg, Args&&... args) {
    cout << std::forward<Arg>(arg);
    using expander = int[];
    (void)expander{0, (void(cout << ',' << std::forward<Args>(args)), 0)...}; cout << endl;
}
inline int mymod(int A, int M) {return ((A % M) + M) % M;}

int spf[MAXN];
void sieve() {
    spf[1] = 1;
    for (int i = 2; i < MAXN; i++) {
        spf[i] = i;
    }
    for (int i = 4; i < MAXN; i += 2) {
        spf[i] = 2;
    }
    for (int i = 3; i * i < MAXN; i++) {
        if (spf[i] == i) {
            for (int j = i * i; j < MAXN; j += i) {
                if (spf[j] == j) {
                    spf[j] = i;
                }
            }
        }
    }
}
inline int gcd(int a, int b) {return (b == 0) ? a : gcd(b, a % b);}
inline void solve() {
    sieve();
    int n; cin >> n;
    vi v(n);
    cin >> v[0];
    int gcd_ = v[0];
    fl(i, 1, n - 1) {
        cin >> v[i];
        gcd_ = gcd(gcd_, v[i]);
    }
    bool one = 1, two = 0;
    if (gcd_ == 1) {
        two = 1;
    }
    ump<int, int>mp;
    fl(i, 0, n - 1) {
        int temp = v[i];
        while (temp != 1) {
            int p = spf[temp];
            bool hey = 0;
            while (temp % p == 0) {
                hey = 1;
                temp /= p;
            }
            if (hey) {
                if (mp.count(p) != 0) {
                    one = 0;
                    goto end;
                }
                mp[p]++;
            }
        }
    }
end:;
    if (one == 1) {
        cout << "pairwise coprime";
    }
    else if (two == 1) {
        cout << "setwise coprime";
    }
    else {
        cout << "not coprime";
    }
}
int32_t main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
   // freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif
    int t = 1;
    // cin >> t;
    fl(i, 1, t)
    {
        solve();
    }

    return 0;
}

Measured memory_bytes: 18764
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>

using namespace std;

typedef long long ll;
#define INF 100000000
#define MOD 1000000007

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

	// 開始時にいずれかが奇数なら0回
	if ((a % 2) != 0 || (b % 2) != 0 || (c % 2) != 0) {
		ans = 0;
	} else if (a == b && b == c && c == a) { // a,b,cが同じ偶数ならずっと続く
		ans = -1;
	} else {
		ans = 0;
		// a,b,cを2で割った数の偶奇が全て同じなら続行
		// そうでなければそこで終了
		while (1) {
			// いずれかの偶奇が異なればbreak;
			if ((a % 2) != (b % 2) || (b % 2) != (c % 2) || (c % 2) != (a % 2)) {
				break;
			}
			// 次のa,b,cは自分以外の数の1/2を足し合わせたもの
			ans++;
			int tmpa, tmpb, tmpc;
			tmpa = a;
			tmpb = b;
			tmpc = c;
			a = (tmpb + tmpc) / 2;
			b = (tmpc + tmpa) / 2;
			c = (tmpa + tmpb) / 2;
		}
	}
	cout << ans << endl;

	return (0);
}

Measured memory_bytes: 256
import sys

def solve():
    input = sys.stdin.readline
    H, W, N = map(int, input().split())
    s, r = map(int, input().split())
    S = input().strip("\n")
    T = input().strip("\n")
    Lb, Rb, Ub, Db = -1, W, -1, H
    for i in reversed(range(N)):
        if i != N - 1:
            if T[i] == "L": Rb = min(Rb + 1, W)
            elif T[i] == "R": Lb = max(Lb - 1, -1)
            elif T[i] == "U": Db = min(Db + 1, H)
            elif T[i] == "D": Ub = max(Ub - 1, 0)

        if S[i] == "L": Lb = Lb + 1
        elif S[i] == "R": Rb = Rb - 1
        elif S[i] == "U": Ub = Ub + 1
        elif S[i] == "D": Db = Db - 1

        if Lb >= W - 1 or Rb <= 0 or Ub >= H - 1 or Db <= 0:
            print("NO")
            break
    else:
        if Lb < r - 1 < Rb and Ub < s - 1 < Db: print("YES")
        else: print("NO")
    
    #print(Lb, Rb, Ub, Db)

    return 0

if __name__ == "__main__":
    solve()

Measured memory_bytes: 3888
#include<bits/stdc++.h>
using namespace std;
int main(){

 long long int a,b,c;
 cin>>a>>b>>c;
 vector<long long int>v;
 v.push_back(a);
v.push_back(b);
v.push_back(c);
sort(v.begin(),v.end());
cout<<v[0]+v[1]<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>

using namespace std;

int main() {
        int n, k;
        cin >> n >> k;
        vector<int> h(n);
        for(int i = 0; i < n; i++) cin >> h[i];

        sort(h.rbegin(), h.rend());

        long long ans = 0;
        for(int i = k; i < n; i++) ans += h[i];

        cout << ans << endl;
        return 0;
}

Measured memory_bytes: 1024