akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
using namespace std;

int gcd(int x, int y)
{
    int r;
    if(x == 0 || y == 0) 
    {
        //fprintf(stderr, "引数エラーです。\n");
        return 0;
    }
    while((r = x % y) != 0) 
    {
        x = y;
        y = r;
    }
    return y;
}


int main(){

  int n;
  int m;
  int a;
  vector<int> list;
  cin >> n;
  for(int i=0; i<n; i++){
    cin >> m;
    //list.push_back(m);
   // cout << m << endl;
  if(i==0){a = m;}
  else{if(m>a) {a = gcd(m, a);} else {a = gcd(a, m);}}
    //cout << a << endl;
  }
  
  cout << a << endl;
  
  return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

int main() {
  string str;
  ll a;
  cin >> a >> str;

  string ans;
  if (a >= 3200) ans = str;
  else
    ans = "red";

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
//#include<bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<numeric>
#include<vector>
#include<set>
#include<map>
#include<unordered_map>
#include<stack>
#include<queue>
#include<list>
using namespace std;

typedef long long ll;

#define MOD 1000000007

class Comb{
private:
  ll *fac,*finv,*inv;
public:
  Comb(){
    fac = new ll[1000000];
    finv = new ll[1000000];
    inv = new ll[1000000];
    fac[0] = 1;
    for(int i=1;i<1000000;i++){
      fac[i] = i*fac[i-1];
      fac[i] %= MOD;
    }
    inv[1] = 1;
    for(int i=2;i<1000000;i++){
      inv[i] = MOD-inv[MOD%i]*(MOD/i)%MOD;
    }
    finv[0] = 1;
    for(int i=1;i<1000000;i++){
      finv[i] = inv[i]*finv[i-1];
      finv[i] %= MOD;
    }
  }
  ll calc(ll n,ll k){
    ll c = fac[n];
    c *= finv[k];c %= MOD;
    c *= finv[n-k];c %= MOD;
    return c;
  }
};

int main(){
  ll n,a,b;
  cin >> n >> a >> b;
  if(abs(a-b)%2==0){
    cout << abs(a-b)/2 << endl;
    return 0;
  }
  ll ans;
  ans = min((min(a,b)-1),n-max(a,b))+(abs(a-b)/2)+1;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<cmath>
#include<cstring>
#include<map>
#include<string.h>
#include<stdexcept>
using namespace std;

map<string,int>item;
vector<string>comb;

int main(){
  int n,f,m;
  string s[10];
  item.clear();
  scanf("%d %d",&n,&f);
  for(int i=0;i<n;i++){
    scanf("%d",&m);
    for(int j=0;j<m;j++){
      cin>>s[j];
    }
    sort(s,s+m);
    for(int j=0;j<m;j++){
      for(int k=j+1;k<m;k++){
	string temp;
	temp=s[j]+" ";
	temp+=s[k];
	if(!count(comb.begin(),comb.end(),temp)){
	  comb.push_back(temp);
	}
	item[temp]++;
      }
    }
  }

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

  int ans=0;
  string ansstr[500000];
  for(int i=0;i<comb.size();i++){
    if(item[comb[i]]>=f){
      ansstr[ans]=comb[i];
      ans++;
    }
  }

  printf("%d\n",ans);
  for(int i=0;i<ans;i++){
    cout<<ansstr[i]<<endl;
  }

  return 0;
}



Measured memory_bytes: 8004
from math import sin, cos, radians, sqrt

a, b, C = list(map(float, input().split()))

height = b * sin(radians(C))
area = a * height * 0.5
rem_a = a - b * cos(radians(C))
c = sqrt(rem_a ** 2 + height ** 2)
L = a + b + c

print("{:.10f}".format(area))
print("{:.10f}".format(L))
print("{:.10f}".format(height))


Measured memory_bytes: 5692
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <unordered_map>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}
const ll INF = 1e15;
const ll MOD = 1000000007;
const ll MOD2 = 998244353;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> tri;
typedef pair<double,double> point;
const ll MAX = 30000;
constexpr ll nx[8] = {1,0,-1,0,1,-1,1,-1};
constexpr ll ny[8] = {0,1,0,-1,1,1,-1,-1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    vector<ll> h(n);
    cins(all(h));
    h[0]--;
    rep(i,n-1){
        if (h[i] > h[i+1]){
            PRINT("No");
            return 0;
        }
        else if (h[i] < h[i+1]){
            h[i+1]--;
        }
    }
    PRINT("Yes");
}


Measured memory_bytes: 3968
#include <iostream>
#include <cmath>
#include <numeric>
#include <algorithm>
#include <deque>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <iomanip>
#include <map>
#include <stack>
#include <queue>
#include <functional>
#include <climits>
#include <numeric>
#include <bitset>
#include <random>
#include <tuple>
#include <initializer_list>
#include <fstream>
#include <cctype>
#include <string>
#include <cfloat>
#include <array>

int main() {
	long long int n, k; std::cin >> n >> k;
	n %= k;
	long long int min = n;
	for (auto i = 0; i < 10; ++i) {
		n = std::abs(n - k);
		min = std::min(min, n);
	}
	std::cout << min << std::endl;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define LLINF 9223372036854775807
#define MOD ll(1e9+7)

int main(){
    int n, h, w;
    cin >> n >> h >> w;




    cout << (n-h+1)*(n-w+1) << endl;

}


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

const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main(){
    int l, r, d;
    cin >> l >> r >> d;
    int ans = 0;
    for (int i=l; i<=r; ++i) if (i%d==0) ++ans;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin>>s;
  int a=0,b=0,c=0;
  for(int i=0;i<3;i++){
    if(s.at(i)=='a')
      a++;
    else if(s.at(i)=='b')
      b++;
    else
      c++;
  }
  cout<<(a==1&&b==1&&c==1?"Yes":"No");
}

Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
vector<vector<int> > ans;
vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));
//do {
//    print(v);
//  } while (std::next_permutation(v.begin(), v.end()));

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
	int H,W,cnt=0;
	int A[500][500];
	cin>>H>>W;
	ans=vector<vector<int> >(H*W, vector<int>(4,0));

	REP(i,H){
		REP(j,W)cin>>A[i][j];
	}
	REP(i,H-1){
		REP(j,W){
			if(A[i][j]%2==1){
				A[i+1][j]++;
				A[i][j]--;
				ans[cnt][0]=i+1;
				ans[cnt][1]=j+1;
				ans[cnt][2]=i+2;
				ans[cnt][3]=j+1;
				cnt++;
			}
		}
	}
	REP(i,W-1){
		if(A[H-1][i]%2==1){
			A[H-1][i]--;
			A[H-1][i+1]++;
			ans[cnt][0]=H;
			ans[cnt][1]=i+1;
			ans[cnt][2]=H;
			ans[cnt][3]=i+2;
			cnt++;
		}
	}
	cout<<cnt<<endl;
	REP(i,cnt){
		REP(j,3){
			cout<<ans[i][j]<<" ";
		}
		cout<<ans[i][3]<<endl;
	}
	
	return 0;
}




















Measured memory_bytes: 16768
while True:
    n = int(input())
    if n == 0:
        break
    short = [5, 7, 5, 7, 7]
    phase = 0
    res = -1
    arr = [0 for i in range(n)]
    for i in range(n):
        arr[i] = len(list(input()))
    for i in range(n):
        tmpsum = 0
        phase = 0
        for j in range(i, n):
            tmpsum += arr[j]
            if tmpsum > short[phase]:
                break
            if tmpsum == short[phase]:
                if phase == 4:
                    res = i + 1
                    break
                tmpsum = 0
                phase += 1
        if res > 0:
            print(res)
            break



Measured memory_bytes: 5616
N = int(input())
cards = list(input().split())
cards_list = [list(i) for i in cards]

for i in range(N):
	for j in reversed(range(i+1,N)):
		if j<N:
			if int(cards_list[j][1])<int(cards_list[j-1][1]):
				cards_list[j],cards_list[j-1]=cards_list[j-1],cards_list[j]
cards_t =[0 for i in range(N)]
for i in range(N):
	cards_t[i] = "".join(cards_list[i])			
print(" ".join(cards_t))
print("Stable")

cards_list_1 =[list(i) for i in cards]
for i in range(N):
	minj = i
	for j in range(i,N):
		if cards_list_1[j][1]<cards_list_1[minj][1]:
			minj = j
	cards_list_1[minj],cards_list_1[i] =cards_list_1[i],cards_list_1[minj]

cards_t =[0 for i in range(N)]
for i in range(N):
	cards_t[i] = "".join(cards_list_1[i])			
print(" ".join(cards_t))
if cards_list == cards_list_1:
	print("Stable")
else:
	print("Not stable")


Measured memory_bytes: 5612
// AOJ 0272: The Lonely Girl's Lie
// 2017.10.14 bal4u@uu
// 2017.11.25

#include <stdio.h>
#include <stdlib.h>

int a[40003], b[40003];

char buf[280002], *p;
int getint()
{
	int n = 0;
	while (*p >= '0') n = (n<<3) + (n<<1) + (*p++ & 0xf);
	return n;
}

int cmp(int *a, int *b) { return *b - *a; }

int main()
{
	int n, i, k, ans;

	while (fgets(p=buf, 10, stdin) && *p != '0') {
		n = getint();

		fgets(p=buf, sizeof(buf), stdin);
		for (i = 0; i < n; i++) a[i] = getint(), p++;
		fgets(p=buf, sizeof(buf), stdin);
		for (i = 0; i < n; i++) b[i] = getint(), p++;

		qsort(a, n, sizeof(int), cmp);
		qsort(b, n, sizeof(int), cmp);

		for (ans = n, i = k = 0; k < n; i++, k += 2) {
			if (a[k] > b[i]) { ans = k + 1; break; }
		}
		if (ans == n) puts("NA");
		else printf("%d\n", ans);
	}
	return 0;
}

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

int N, L[2000];

int main(){
  cin >> N;
  for(int i = 0; i < N; i++){
    cin >> L[i];
  }
  sort(L, L + N);

  long long ans = 0;
  for(int i = 0; i < N; i++){
    for(int j = 0; j < i; j++){
      auto idx = lower_bound(L, L + N, L[i] - L[j] + 1) - L;
      if(idx < j){
	ans += j - idx;
      }
    }
  }
  cout << ans << endl;


}


Measured memory_bytes: 888
n=int(input())
a=[]
for i in range(n):
    a.append(int(input()))
a.sort()
ans = 0
l=0
r=0

if(n%2==1):
    tmp1=-1*a[int(n/2)-1]-a[int(n/2)]
    tmp2=a[int(n/2)]+a[int(n/2)+1]
    for i in range(int(n/2)):
        tmp1 += 2*a[-i-1]
        tmp2 += -2*a[i]
    for i in range(int(n/2)-1):
        tmp1 += -2*a[i]
        tmp2 += 2*a[-i-1]
    if(tmp1>tmp2):
        print(tmp1)
    else:
        print(tmp2)
    
else:
    tmp1=a[int(n/2)]-a[int(n/2)-1]
    for i in range(int(n/2)-1):
        tmp1+=-2*a[i]+2*a[int(n/2)+i+1]
    print(tmp1)


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

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

using ll = long long;
constexpr ll INF = 10000000000;

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

using namespace std;

//fixed << setprecision(10)

/////////////////////////////////////////////////////////////////////////////////////////////////////////

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

	if (a + b == 3)cout << 3 << endl;
	if (a + b == 4)cout << 2 << endl;
	if (a + b == 5)cout << 1 << endl;

}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef  long long ll;
//double pi=3.1415926535898;
//double pi=acos(-1.0);
#define scarr(a,s,e) for(int i=s;i<=int(e);i++) scanf("%d ",&a[i]);
#define prarr(a,s,e) for(int i=s;i<=int(e);i++) printf("%d ",a[i]);
#define speed      ios::sync_with_stdio(false);cin.tie(NULL); cout.tie(NULL);
#define rng(i,a,b) for(int i=a;i>=int(b);i--)
#define rep(i,a,b) for(int i=a;i<=int(b);++i)
#define lop(i,n)   for(int i=0;i<int(n);i++)
#define ms(x,a)    memset(x,a,sizeof(x))
#define all(x)     (x).begin(),(x).end()
#define sz(x)      int(x.size())
#define pb         push_back
#define mkp        make_pair
#define sc(x)      scanf("%d",&x)
#define scl(x)     scanf("%lld",&x)
#define pr(x)      printf("%d ",x)
#define prl(x)     printf("%lld ",x)
#define prln(x)    printf("%d\n",x)
#define prlln(x)   printf("%lld\n",x)
#define r0         return 0;
#define CC         continue;
#define scd(x)     scanf("%lf",&x)
#define prd(x)     printf("%.10f\n",x)
#define bb(x)      cerr<< x <<endl;
#define pii        pair<int,int>
#define vi         vector<int>
#define fr         first
#define se         second
//#define max(a,b) a<b?b:a
//#define min(a,b) a<b?a:b
const ll M  = 1e9+7 ;
const ll inf = 1e18 ;
const int si = 1e6+9;
const int N = 3e4+1 ;
//////////////////////    Hi    ^_^  hack me if you can :P

int main()
{
    speed;
    int t;
    t=1;
    for(int T=1; T<=t; T++)
    {
        int n,a,b,c=0,d=0;
        string s ;
        cin>>n>>a>>b;
        cin>>s;
        lop(i,n)
        {
            if(s[i]=='c')
            {
                cout<<"No\n";
            }
            if(s[i]=='a')
            {
                if(c+d<a+b)
                {
                    cout<<"Yes\n";
                    c++;
                }
                else
                    cout<<"No\n";
            }
            if(s[i]=='b')
            {
                if(c+d<a+b&&d<b)
                {
                    cout<<"Yes\n";
                    d++;
                }
                else
                    cout<<"No\n";
            }
        }
    }

    r0;
}

/*

ll pwmod(ll a, ll n, ll mod) {
    ll ret = 1;
    while (n) {
        if (n & 1) ret = ret * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return ret;
}

*/
/*
freopen("output.txt","w",stdout);
freopen("input.txt","r",stdin);
for (int i=0;i<n;i++)            Hi    ^_^  hack me if you can :P
int mx[]= {0,0,1,-1, 1,1,-1,-1};
int my[]= {1,-1,0,0, 1,-1,1,-1};
bool inside (int i,int j) {return (i>=0 && i<n && j>=0 && j<m);}

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

void gcd(LL n,LL m,LL &d,LL &xx,LL &yy){
    if(!m) {d=n; xx=1; yy=0;}
    else {gcd(m,n%m,d,yy,xx); yy-=xx*(n/m);}
}

int getm(int l,int r)
{
    if(l>r)
        return N;
    if(l==r)
        return 0;
    if(l==r-1)
        return s[l] != s[r];
    if(s[l]==s[r])
        return getm(l+1,r-1);
    else
        return 1+min(getm(l+1,r),getm(l,r-1));
}


*/


Measured memory_bytes: 848
#include <bits/stdc++.h>
typedef long long int lint;

#define PI acos(-1)
#define INF64 1LL << 60
#define INF32 1 << 29
#define LIMIT(d_in, d_min, d_max) max(d_min, min(d_max, d_in))
#define all(a) (a).begin(), (a).end()
#define INV ((long long int)1000000007)

using namespace std;

void execute()
{
	int x, y, z;
	cin >> x >> y >> z;
	cout << z << " " << x << " " << y << endl;
	return;
}

int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	execute();

	int stop;
	cin >> stop;

	return 0;
}

Measured memory_bytes: 256
# coding: utf-8

def main():
	N, M = map(int, input().split())
	S = []
	for m in range(M):
		s = list(map(int, input().split()))
		S.append(s)
	p = list(map(int, input().split()))

	res = 0
	for bit in range(1<<N):
		s_check = True
		for i in range(M):
			cnt = 0
			for s in S[i][1:]:
				if bit & (1<<s-1):
					cnt += 1
			if cnt % 2 != p[i]:
				s_check = False
		if s_check == True:
			res += 1
	print(res)

if __name__ == '__main__':
	main()

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

using namespace std;

long long ps[410], dp[410][410];
int n, a[410];

int main() {
	cin >> n;
	for (int i = 0; i < n; i++) cin >> a[i];
	for (int i = 0; i < n; i++) ps[i + 1] = ps[i] + a[i];
	
	for (int i = n - 1; i >= 0; i--) {
		for (int j = i + 2; j <= n; j++) {
			dp[i][j] = LLONG_MAX;
			for (int k = i + 1; k < j; k++) {
				dp[i][j] = min(dp[i][k] + dp[k][j] + ps[j] - ps[i], dp[i][j]);
			}
		}
	}
	
	cout << dp[0][n] << '\n';
}


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

#define si(a) scanf("%d",&a)
#define sl(a) scanf("%lld",&a)
#define sd(a) scanf("%lf",&a)
#define sc(a) scahf("%c",&a);
#define ss(a) scanf("%s",a)
#define pi(a) printf("%d\n",a)
#define pl(a) printf("%lld\n",a)
#define pc(a) putchar(a)
#define ms(a) memset(a,0,sizeof(a))
#define repi(i, a, b) for(register int i=a;i<=b;++i)
#define repd(i, a, b) for(register int i=a;i>=b;--i)
#define reps(s) for(register int i=head[s];i;i=Next[i])
#define ll long long
#define ull unsigned long long
#define vi vector<int>
#define vc vector<char>
#define vs vector<string>
#define pii pair<int,int>
#define pll pair<long,long>
#define pil pair<int,long>
#define pli pair<long,int>
#define mii unordered_map<int,int>
#define msi unordered_map<string,int>
#define lowbit(x) ((x)&(-(x)))
#define ce(i, r) i==r?'\n':' '
#define pb push_back
#define fi first
#define se second
#define INF 0x3f3f3f3f
#define pr(x) cout<<#x<<": "<<x<<endl
using namespace std;

inline int qr() {
    int f = 0, fu = 1;
    char c = getchar();
    while (c < '0' || c > '9') {
        if (c == '-')fu = -1;
        c = getchar();
    }
    while (c >= '0' && c <= '9') {
        f = (f << 3) + (f << 1) + c - 48;
        c = getchar();
    }
    return f * fu;
}
int n,m,a;
int sum;
int main(){
    n=qr(),m=qr();
    repi(i,1,m){
        a=qr();
        sum+=a;
    }
    if(sum>n)puts("-1");
    else pi(n-sum);
    return 0;
}

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

int main() {
  int n;
  cin >> n;
  double a;
  double sum = 0;
  for(int i=0; i<n; i++) {
    cin >> a;
    sum += 1/a;
  }
  cout << fixed << setprecision(15) << 1/sum << endl;
}

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

int main(){
  int N, K, x;
  int sum = 0;
  cin >> N;
  cin >> K;

  // y軸上にボールを一つずつxの位置(x座標)に配置
  for(int i = 0; i < N; i++){
    cin >> x;
    // ロボットA(0,i)とロボットB(K, i)の距離が短い方を加算
    sum += min(x, K - x);
  }
  // 距離を往復にする
  cout << sum * 2 << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
long int n, m, x = 10000, y = 5000, z = 1000, i = 0, j = -1;
cin >> n >> m;
for (i = 0; i <= n + 1; i++){
	while (j < n && j + i < n){
		j++;
	
	if (x * i + y * j + (n - i - j) * z == m){
		cout << i << " " << j << " " << (n - i - j) <<endl;
		return 0;
	}
	}
	j = -1;
}
cout << -1 << " " << -1 << " " << -1 << endl;
return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) FOR(i,0,n)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define PB push_back
typedef vector<ll> vi;
typedef vector<vector<ll>> vvi;
const ll INF = (1ll << 60);
typedef pair<ll,ll> pii;

struct RSQRAQ{
  ll size;
  ll *t1,*t2;
  RSQRAQ(ll sz){
    ll logsize; for(logsize=0;(1ll<<logsize)<=sz;logsize++);
    size=(1ll<<logsize);
    t1=new ll[size*2-1];
    t2=new ll[size*2-1];
    REP(i,size*2-1) t1[i]=t2[i]=0;
  }
  void add(ll s,ll t,ll x){
    add(s,t,0,size,0,x);
  }
  void add(ll s,ll t,ll l,ll r,ll k,ll x){
    if(r<=s||t<=l||r<=l) return;
    if(l+1==r) {t1[k]+=x; return;}
    if(s<=l&&r<=t) {t1[k]+=x*(r-l); t2[k]+=x*(r-l); return;}
    t1[k]+=(min(r,t)-max(l,s))*x;
    ll mid=(l+r+1)/2;
    add(s,t,l,mid,k*2+1,x);
    add(s,t,mid,r,k*2+2,x);
  }
  ll getSum(ll s,ll t){
    return getSum(s,t,0,size,0);
  }
  ll getSum(ll s,ll t,ll l,ll r,ll k){
    if(r<=s||t<=l||r<=l) return 0;
    if(l+1==r) return t1[k];
    if(s<=l&&r<=t) return t1[k];
    ll mid=(l+r+1)/2;
    t1[k*2+1]+=t2[k]/2; t2[k*2+1]+=t2[k]/2;
    t1[k*2+2]+=t2[k]/2; t2[k*2+2]+=t2[k]/2;
    t2[k]=0;
    return getSum(s,t,l,mid,k*2+1)+getSum(s,t,mid,r,k*2+2);
  }
};

int main(){
  ll n,q; cin>>n>>q;
  RSQRAQ rsqraq(n);
  REP(i,q){
    ll com; cin>>com;
    if(com==0) {ll s,t,x; cin>>s>>t>>x; rsqraq.add(s,t+1,x);}
    else {ll s,t; cin>>s>>t; cout<<rsqraq.getSum(s,t+1)<<endl;}
  }
}

Measured memory_bytes: 7236
/*
If you want to aim high, aim high
Don't let that studying and grades consume you
Just live life young
******************************
What do you think? What do you think?
1st on Billboard, what do you think of it
Next is a Grammy, what do you think of it
However you think, I’m sorry, but shit, I have no fcking interest
*******************************
I'm standing on top of my Monopoly board
That means I'm on top of my game and it don't stop
til my hip don't hop anymore
https://www.a2oj.com/Ladder16.html
*******************************
300IQ as writer = Sad!
*/
import java.util.*;
import java.io.*;
import java.math.*;

   public class Main
   {
      public static void main(String hi[]) throws Exception
      {
         BufferedReader infile = new BufferedReader(new InputStreamReader(System.in));  
         StringTokenizer st = new StringTokenizer(infile.readLine());
         int N = Integer.parseInt(st.nextToken());
         int res = N+N*N+N*N*N;
         System.out.println(res);
      }
   }

Measured memory_bytes: 32620
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
const ll INF = 1LL << 60;



int main(){
   char a;
   cin >> a;
   if(isupper(a)){
       cout << 'A' << endl;
   }
   else{
       cout << 'a' << endl;
   }

}

Measured memory_bytes: 3632
n = int(input())
M = [[float("inf") for i in range(n)] for i in range(n)]
for i in range(n):
 L = list(map(int, input().split()))
 for j,v in enumerate(L):
  if v != -1:
   M[i][j] = v

def prim():
 color = [0] * n
 d = [float("inf")] * n
 d[0] = 0

 while True:
  minv = float("inf")
  u = -1
  for i in range(n):
   if minv > d[i] and color[i] != 2:
    u = i
    minv = d[i]
  if u == -1: break
  color[u] = 2
  for v in range(n):
   if color[v] != 2 and M[u][v] != float("inf"):
    if d[v] > M[u][v]:
     d[v] = M[u][v]
 return sum(d)

print(prim())

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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
#define SZ(x) ((int)(x).size())
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 55;
const int mod = 1000000007;
//const int mod = 998244353;

template <class T>inline bool chmin(T &a, const T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline bool chmax(T &a, const T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline void line_out(const vector<T> vec) {
  int n = SZ(vec);
  rep(i, n) {
    cout << vec[i];
    if(i < n-1) cout << " ";
  }
  cout << endl;
  return;
}

struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};

int main()
{
  int n; cin >> n;
  vector<double> a(n);
  rep(i, n) cin >> a[i];
  double ave = (double)accumulate(ALL(a), 0.0) / n;
  int ans;
  double diff = 1000000;
  rep(i, n) if(abs(ave-a[i]) < diff) {
    ans = i;
    diff = abs(ave-a[i]);
  }

  cout << ans << endl;

}

Measured memory_bytes: 3720
// 基本テンプレート

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define int long long int

template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}

typedef pair<int, int> pii;
typedef long long ll;

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
constexpr ll INF = 1001001001001001LL;
constexpr ll MOD = 1000000007LL;

int N, M;
int s[200010], t[200010];

signed main() {
    cin >> N >> M;
    rep(i,0,M) {
        int a, b; cin >> a >> b;
        if(a == 1) s[b]++;
        if(b == N) t[a]++;
    }
    rep(i,0,200010) {
        if(s[i] && t[i]) {
            cout << "POSSIBLE" << endl;
            return 0;
        }
    }
    cout << "IMPOSSIBLE" << endl;
    return 0;
}

Measured memory_bytes: 3328
#include<stdio.h>

int main(){
    int N,i,j;
    int A[100];
    
    scanf("%d",&N);
    for(i = 0;i < N;i++){
        scanf("%d",&A[i]);
    }
    trace(A,N);
    insertionSort(A,N);
    
    return 0;
}

void trace(int A[],int N){
    int i;
    for(i = 0;i < N;i++){
        if(i > 0){
            printf(" ");
        }
        printf("%d",A[i]);
    }
    printf("\n");
}

void insertionSort(int A[],int N){
    int j,i,v;
    for(i = 1;i < N;i++){
        v = A[i];
        j = i - 1;
        while(j >= 0 && A[j] > v){
            A[j + 1] = A[j];
            j--;
        }
        A[j + 1] = v;
        trace(A,N);
    }
}


Measured memory_bytes: 2056
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <numeric>
#define rep(i, m, n) for(int i = m;i < n;i++)
#define repr(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define INF 999999999
using namespace std;

int main(){
    long long x, y;
    cin >> x >> y;

    long long ans = 0;
    for(int i = x; y + 1; i++){
        if(x > y) break;
        ans += 1;
        x += x;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#![allow(unused_imports)]

use text_io::*;
use proconio::*;
use std::collections::*;
use std::process::exit;
use std::cmp::*;
use itertools::Itertools;


fn main() {
    input! {
    a:usize,
    b:usize,
    }
    let mut c =1;
    let mut d =0;
    while b/a>=c{
        c*=2;
        d+=1;
    }
    println!("{}",d)
}

Measured memory_bytes: 2096
#include<iostream>
#include<string>
#include<map>
using namespace std;
int main(){
    map<string,int> A;
    int n;
    string s;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>s;
        A[s]++;
    }
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>s;
        A[s]--;
    }
    int ans=0;
    for(auto itr = A.begin(); itr != A.end(); ++itr) if(itr->second>ans) ans=itr->second;
    cout<<ans;
}

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

const int MAXN = 100100;
int n;
int a, b, c;
long long int dp[MAXN][4];
int niz[MAXN][4];


int main() {

  cin >> n;
  for (int i = 0; i < n; i++) {
    scanf("%d%d%d", &niz[i][0], &niz[i][1], &niz[i][2]);
  }
  dp[0][0] = niz[0][0];
  dp[0][1] = niz[0][1];
  dp[0][2] = niz[0][2];

  for (int i = 0; i < n; i++) {
    dp[i][0] = max(dp[i - 1][1], dp[i - 1][2]) + niz[i][0];
    dp[i][1] = max(dp[i - 1][0], dp[i - 1][2]) + niz[i][1];
    dp[i][2] = max(dp[i - 1][0], dp[i - 1][1]) + niz[i][2];
  }
  cout << max(dp[n - 1][0], max(dp[n - 1][1], dp[n - 1][2]));
}


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

using ll = long long;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define REP(i, n) FOR(i, 0, n)
#define ALL(c) (c).begin(), (c).end()
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;}
const int MOD = 1000000007;

int main() {
    int n, d;
    cin >> n >> d;
    cout << (n + d * 2 + 1 - 1) / (d * 2 + 1) << endl;
}


Measured memory_bytes: 256
/*                    ___          |\    /|           ____   ____   ____  ____
   |     |    /\    /    \ |     | | \  / |    /\    |    \ |    \ |     |    \
   |_____|   /__\   \____  |_____| |  \/  |   /__\   |____/ |____/ |__   |____/
   |     |  /    \       \ |     | |      |  /    \  |      |      |     |   \
   |     | /      \ \____/ |     | |      | /      \ |      |      |____ |    \
*/
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define lb lower_bound
#define ub upper_bound
#define pf push_front
#define pb push_back
#define ll long long
#define pi pair<int,int>
#define pl pair<long long,long long>
#define pld pair<long double,long double>
#define endl '\n'
#define loop(i,n) for(ll i=0;i<n;i++)
#define mod ((ll)(1e9+7))
#define in(x) scanf("%lld",&x)
#define in2(x,y) scanf("%lld %lld",&x,&y)
#define in3(x,y,z) scanf("%lld %lld %lld",&x,&y,&z)
#define inv(v) for(auto&i:v) in(i)
#define vl vector<ll>
#define ml unordered_map<ll,ll> 
#define vpl vector<pair<ll,ll>>
#define INF 0x3f3f3f3f

bool  dp[int(1e5) +5];
int main() {
    dp[0]=1;
    ll n;
    in(n);
    for(ll i=1;i<=n;i++) {
        if(i>=100) dp[i] = max(dp[i],dp[i-100]);
        if(i>=101) dp[i] = max(dp[i],dp[i-101]);
        if(i>=102) dp[i] = max(dp[i],dp[i-102]);
        if(i>=103) dp[i] = max(dp[i],dp[i-103]);
        if(i>=104) dp[i] = max(dp[i],dp[i-104]);
        if(i>=105) dp[i] = max(dp[i],dp[i-105]);
    }
    cout<<dp[n]<<endl;
    return 0;
}

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

int main(){
  int X,Y;
  cin >> X >> Y;
  for(int i=0;i<=X;i++){
    int j=X-i;
    if(2*i+4*j==Y){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 3636
// -*- coding:utf-8-unix -*-

use proconio::input;
extern crate num;

fn calclate_score(D: i32, s: &mut Vec<Vec<i32>>, c: &mut Vec<i32>, out: &mut Vec<i32>) -> i32 {
    let mut sat = 0;
    let mut last = vec![0; 26];
    for d in 0..D {
        assert!(1 <= out[d as usize] && out[d as usize] <= 26);
        let j = out[d as usize] - 1;
        last[j as usize] = d + 1;
        for i in 0..26 {
            sat -= (d + 1 - last[i]) * c[i];
        }
        sat += s[d as usize][j as usize];
    }
    sat
}

fn main() {
    input! {
        D: i32,
        mut c: [i32; 26],
        mut s: [[i32; 26]; D],
        mut out: [i32; D],
        M: i32,
        mut d: [(i32,i32); M]
    }
    for i in 0..M {
        let (d0, q) = d[i as usize];
        out[(d0 - 1) as usize] = q;
        println!("{}", calclate_score(D, &mut s, &mut c, &mut out));
    }
}


Measured memory_bytes: 3400
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;

namespace AtCoder.B
{
    public class Program
    {
        public static void Main() { var r = GetResult(); Debug.WriteLine(r); Console.Write(r); }

        private static object GetResult()
        {
            var N = ReadLong();
            var S = ReadTexts();

            return S.Contains("Y") ? "Four" : "Three";
        }

        #region Console.Read

        public static string ReadText() { return Console.ReadLine(); }
        public static List<string> ReadTexts() { return Console.ReadLine().Split(' ').ToList(); }
        public static long ReadLong() { return long.Parse(Console.ReadLine()); }
        public static (long, long) Read2Longs() { var ls = ReadLongs(); return (ls[0], ls[1]); }
        public static (long, long, long) Read3Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2]); }
        public static (long, long, long, long) Read4Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3]); }
        public static (long, long, long, long, long) Read5Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3], ls[4]); }
        public static List<long> ReadLongs() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList(); }

        #endregion
    }
}


Measured memory_bytes: 28316
#include <iostream>
#include <stdlib.h>
#include <algorithm>

using namespace std;

int main(int argc, char **argv)
{
	int n, m, *a, t;
	
	while(1){
		cin >> n >> m;
		if(n == 0 && m == 0){
			break;
		}
		
		a = (int *)calloc(n+m+1, sizeof(int));
		for(int i = 0; i < n+m; i++){
			cin >> a[i];
		}
		sort(a, a+(n+m));
		
		t = a[0];
		for(int i = 1; i < n+m; i++){
			if(t < a[i]-a[i-1]){
				t = a[i]-a[i-1];
			}
		}
		cout << t << endl;
		
		free(a);
	}
	
	return 0;
}

Measured memory_bytes: 0
s = input()

p_count = 0
g_count = 0
win = 0

for i in list(s):
    if i == "g" and p_count + 1 <= g_count:
        p_count += 1
        win += 1
    elif i == "g":
        g_count += 1
    elif i == "p" and p_count + 1 <= g_count:
        p_count += 1
    else:
        g_count += 1
        win -= 1

print(win)


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

typedef long long ll;
typedef pair<ll,ll> pi;
typedef vector <ll> vi;
typedef vector <pi> vpi;
#define f first
#define s second
#define FOR(i,s,e) for(ll i=s;i<=ll(e);++i)
#define DEC(i,s,e) for(ll i=s;i>=ll(e);--i)
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define lbd(x, y) lower_bound(all(x), y)
#define ubd(x, y) upper_bound(all(x), y)
#define aFOR(i,x) for (auto i: x)
#define mem(x,i) memset(x,i,sizeof x)
#define fast ios_base::sync_with_stdio(false),cin.tie(0)
#define maxn 200001
#define int ll
int L,R,d;
int ans = 0;
int32_t main(){
	fast;
	int N;
	cin>>N;
	FOR(i,1,N){
		int a; cin>>a;
		if (i % 2 == 1 && a % 2 == 1) ans++;
	}
	cout<<ans;
		
	
	
}


Measured memory_bytes: 3644
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<complex>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
using namespace std;
using Complex = complex<double>;
using ll = long long;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll inf = 1145141919810364364LL;
double PI = acos(-1.0);
#define all(x) (x).begin(),(x).end()
#define puts(x) cout << x << endl
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)

const int MAX = 303030;
const ll MOD = 1000000007;
ll fac[MAX], finv[MAX], inv[MAX];

void combinit() {
	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;
	}
}
ll comb(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;
}
ll modpow(ll a, ll n) {
	ll res = 1;
	a %= MOD;
	while (n > 0) {
		if (n & 1) res = res * a % MOD;
		a = a * a % MOD;
		n >>= 1;
	}
	return res;
}


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

	
	int N, K;
	cin >> N >> K;
	int ans = 0;
	while (N > 0) {
		N /= K;
		ans++;
	}
	puts(ans);

	


	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;

int main(){

	string sa, sb, sc;
	cin >> sa;
	cin >> sb;
	cin >> sc;

	int a = 0;
	int b = 0;
	int c = 0;

	char tmp = sa[0];
	a++;
	while( true ){
		

		if( tmp == 'a' ){
			tmp = sa[ a ];
			if( a == sa.size() ){
				cout << "A" << endl;
				break;
			}
			a++;
		}else if( tmp == 'b' ){
			tmp = sb[ b ];
			if( b == sb.size() ){
				cout << "B" << endl;
				break;
			}
			b++;
		}else if( tmp == 'c' ){
			tmp = sc[ c ];
			if( c == sc.size() ){
				cout << "C" << endl;
				break;
			}
			c++;
		}
		
	}

	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 rrep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(unique(all(x)), x.end());
typedef long long ll;
typedef complex<double> Complex;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
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...));
}
int main() {
    string t;
    cin >> t;
    int n = 0, w = 0, s = 0, e = 0;
    for (char c : t) {
        if (c == 'N') n++;
        if (c == 'W') w++;
        if (c == 'S') s++;
        if (c == 'E') e++;
    }
    if ((n == 0 && s != 0) || (n != 0 && s == 0)) {
        cout << "No" << endl;
        return 0;
    }
    if ((w == 0 && e != 0) || (w != 0 && e == 0)) {
        cout << "No" << endl;
        return 0;
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <math.h>
#include <algorithm>
using namespace std;
#define ll long long

const ll INF = 7+(1e+10);
typedef ll Weight;
struct Edge {  //src:辺の始点,dst:辺の終点,weight:辺の重さ
  ll src, dst;
  Weight weight;
  Edge(ll src, ll dst, Weight weight) :
    src(src), dst(dst), weight(weight) { }
};
bool operator < (const Edge &e, const Edge &f) {
  return e.weight != f.weight ? e.weight > f.weight : //辺は重さが重いものを"小さい"と定義する
    e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

//引数 Graph:隣接リスト,dist:各頂点から各頂点までの距離が入る,inter:最短路木の親頂点が入る
//戻値 負閉路が存在しない場合:true,そうでないとき:false
bool shortestPath(const Graph &g,vector<vector<Weight> > &dist,vector<vector<ll> > &inter) {
  ll n = g.size();
  dist.assign(n,vector<Weight>(n,INF));
  for(ll i=0;i<n;i++){
    dist[i][i]=0;
  }
  for(ll i=0;i<n;i++){
    for(auto f=g[i].begin();f!=g[i].end();f++){
      dist[i][f->dst]=f->weight;
    }
  }
  inter.assign(n, vector<ll>(n,-1));
  for(ll k=0;k<n;k++){
    for(ll i=0;i<n;i++){
      for(ll j=0;j<n;j++){
        if(dist[i][k]<INF && dist[k][j]<INF && dist[i][j]>dist[i][k]+dist[k][j]){
          dist[i][j] = dist[i][k] + dist[k][j];
          inter[i][j] = k;
        }
      }
    }
  }
  for(ll i=0;i<n;i++){
    if(dist[i][i]<0){
      return false;
    }
  }
  return true;
}
void buildPath(const vector<vector<ll> > &inter,ll s,ll t,vector<ll> &path) {
  ll u = inter[s][t];
  if (u < 0) path.push_back(s);
  else buildPath(inter, s, u, path), buildPath(inter, u, t, path);
}
vector<ll> buildPath(const vector<vector<ll> > &inter,ll s,ll t) {
  vector<ll> path;
  buildPath(inter, s, t, path);
  path.push_back(t);
  return path;
}


int main(){
  ll h,w,v;
  cin>>h>>w;
  v=h*w;
  Graph g(v);
  vector<string>z;
  string zz;
  for(ll i=0;i<h;i++){
    cin>>zz;
    z.push_back(zz);
  }
  for(ll i=0;i<h;i++){
    for(ll j=0;j<w;j++){
      if(j!=w-1&&z[i][j]=='.'&&z[i][j+1]=='.'){
        g[i*w+j].push_back(Edge(i*w+j,i*w+j+1,1));
        g[i*w+j+1].push_back(Edge(i*w+j+1,i*w+j,1));
      }
      if(i!=h-1&&z[i][j]=='.'&&z[i+1][j]=='.'){
        g[i*w+j].push_back(Edge(i*w+j,(i+1)*w+j,1));
        g[(i+1)*w+j].push_back(Edge((i+1)*w+j,i*w+j,1));
      }
    }
  }
  vector<vector<Weight> >dist;
  vector<vector<ll> > inter;
  shortestPath(g,dist,inter);
  ll ans=0;
  for(ll i=0;i<v;i++){
    for(ll j=0;j<v;j++){
      if(dist[i][j]!=INF)ans=max(ans,dist[i][j]);
    }
  }
  cout<<ans<<endl;
}


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

int main(int argc, char const *argv[])
{
    int n,m;cin>>n>>m;
    vector<int> v;
    vector<int> bucket(31,0);
    for(int i=0;i<n;++i){
        int k;cin>>k;
        for(int j=0;j<k;++j){
            int t;
            cin>>t;
            bucket[t]++;
        }
    }
    int cnt =0;
    for(int x:bucket)if(x==n)cnt++;
    cout <<cnt<<endl;
    return 0;
}


Measured memory_bytes: 256
import std.stdio;
import std.conv, std.array, std.algorithm, std.string;
import std.math, std.random, std.range, std.datetime;
import std.bigint;
int n;
void main(){
	n = readln.chomp.to!int;
	bool[][] xss;
	foreach(i; 0 .. n){
		xss ~= readln.chomp.map!(x => (x == '#')).array;
		}
	
	int donecolumncount = 0;
	foreach(j; 0 .. n){
		bool f = 1;
		foreach(i; 0 .. n){
			if(!xss[i][j]) f = 0;
			}
		if(f) donecolumncount += 1;
		}
	
	int cmin = n + 1;
	foreach(i; 0 .. n){
		int c = 0;
		foreach(j; 0 .. n){
			if(!xss[i][j]){
				c += 1;
				if(i == j){
					int f = 1;
					foreach(ii; 0 .. n){
						if(xss[ii][j]) f = 0;
						}
					c += f;
					}
				}
			
			}
		if(c < cmin) cmin = c;
		}
	
	int ans;
	if(cmin > n) ans = -1;
	else ans = cmin + n - donecolumncount;
	
	ans.writeln;
	
	}


Measured memory_bytes: 892
int main()
{
  int a,b,c,x;
  scanf("%d%d%d",&a,&b,&c);
  if(b>c)
    {
      x=b;
      b=c;
      c=x;
    }
  if(a>b)
    {
      x=a;
      a=b;
      b=x;
    }
  if(b>c)
    {
      x=b;
      b=c;
      c=x;
    }
  printf("%d %d %d\n",a,b,c);
  return 0;
}

Measured memory_bytes: 596
import sys
import numpy as np
int1 = lambda x: int(x) - 1
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)

N, K = map(int, readline().split())
A = list(map(int, readline().split()))

ans = pow(10, 11)

for bit in range(1 << (N)):
    if bin(bit).count('1') < K:
        continue
    acc = 0
    pre = 0
    for i in range(N):
        if bit & (1 << i):
            if A[i] <= pre:
                acc += max(0, pre + 1 - A[i])
                pre += 1
        pre = max(pre, A[i])
    ans = min(ans, acc)
print(int(ans))

Measured memory_bytes: 12500
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,cnt=0;
    cin>>n;
    string s;
    cin>>s;

    for(int i=0;i<n-2;i++)
    {
         if(s.substr(i,3)=="ABC"){

            cnt++;
    }

    }


    cout<<cnt<<endl;
    exit(0);

}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 1000000000000000009
//#define INF 9223372036854775807
typedef long long ll;
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define rollcall cout<<"I'm Sucu."<<endl;
#define YES(s) s?cout << "YES" << endl:cout << "NO" << endl
#define Yes(s) s?cout << "Yes" << endl:cout << "No" << endl
#define Taka(s) s?cout << "Takahashi" << endl:cout << "Aoki" << endl
#define out(s,t,u) s?cout << t << endl:cout << u << endl
#define int ll
#define Endl endl
//#define P pair<int,int>

struct edge{int end;int cost;};
typedef pair<int,int> P;
int V,d[114514];
vector<edge> G[114514];

void dijkstra(int s){
    priority_queue<P,vector<P>,greater<P>> que;
    for(int i=0;i<114514;i++){d[i]=INF;}
    d[s]=0;
    que.push(P(0,s));
    while(!que.empty()){
        P p = que.top();
        que.pop();
        int v = p.second;
        if(d[v]<p.first)continue;
        for(int i=0;i<G[v].size();i++){
            edge e = G[v][i];
            if(d[e.end]>d[v]+e.cost){
                d[e.end] = d[v]+e.cost;
                que.push(P(d[e.end],e.end));
            }
        }
    }
}


signed main(){
    int N,Q,K;
    int a[114514],b[114514],c[114514],x[114514],y[114514];
    cin >> N;
    REP(i,N-1){
        cin >> a[i] >> b[i] >> c[i];
        a[i]--;b[i]--;
    }
    cin >> Q >> K;
    K--;
    REP(i,Q){
        cin >> x[i] >> y[i];
        x[i]--;y[i]--;
    }
    edge h;
    REP(i,N){
        h.end=b[i];
        h.cost=c[i];
        G[a[i]].push_back(h);
        h.end=a[i];
        G[b[i]].push_back(h);
    }
    dijkstra(K);
    REP(i,Q){
        cout << d[x[i]]+d[y[i]] << endl;
    }
    
    
	return 0;
}

Measured memory_bytes: 15856