akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define REP1(i, n) for(int i = 1; i <= (n); i++)
#define REPD(i,a,b) for (int i=(a);i<(b);i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef set<int> si;
typedef vector<si> vsi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<int, int> pi;
typedef queue<int> qi;
typedef queue<pi> qpi;
typedef pair<ll, ll> pll;
typedef queue<pll> qpll;
typedef vector<pi> vpi;
typedef vector<pll> vpll;
const int mod = 1000000007;
const int INF = 1001001001;
// 小数点　<< fixed << setprecision(0) <<
// sort降順　sort(ALL(),greater<int>());
// 円周率　M_PI
// 文字判定　isupper islower
// 文字変換　
// 順列　do {} while(next_permutation(ALL(X)));
// 最大値　LLONG_MAX
// a内でx以上　auto iter = lower_bound(ALL(a), x);
// a内でxより大きい　auto iter = upper_bound(ALL(a), x);
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
struct edge {
    int from; //出発点
    int to;   //到達点
    int cost; //移動コスト
};
typedef struct edge se;
typedef vector<edge> ve;
unsigned Euclidean_gcd(unsigned a, unsigned b) {
  if(a < b) return Euclidean_gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

vpll PrimeFactorization(ll n) {
  vpll res;
  for (ll i=2; i*i<=n; i++) {
    if(n%i!=0) continue;
    ll ex=0;
    while(n%i==0) {
      ex++;
      n/=i;
    }
    res.push_back(pll(i,ex));
  }
  if(n!=1) res.push_back(pll(n,1));
  return res;
}

int main() {
  ll n;
  cin >> n;
  vll a(n);
  vll check(10000001,-1);
  REP(i,n) {
    cin >> a[i];
  }
  ll ans=0;
  sort(ALL(a));
  ll max=a[n-1]+1;
  REP(i,n) {
    if(i>0&&a[i]==a[i-1]) check[a[i]]++;
    if(check[a[i]]!=-1) continue;
    int temp=a[i];
    while(max>=temp) {
      temp+=a[i];
      check[temp]++;
    }
  }
  REP(i,n) {
    if(check[a[i]]==-1) {
      ans++;
    }
    
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 82984
import sys
from bisect import bisect_left as bl
input = sys.stdin.readline
N, M = map(int, input().split())
a = set(map(int, input().split()))
b = set(map(int, input().split()))
sa = sorted(a)
sb = sorted(b)
mod = 10 ** 9 + 7
res = 1
if len(a) < N or len(b) < M:
  print(0)
  exit(0)
for x in range(N * M, 0, -1):
  y = N * M - x
  if x in a and x in b:
    continue
  elif x in a:
    ind = bl(sb, x)
    res *= M - ind
    res %= mod
  elif x in b:
    ind = bl(sa, x)
    res *= N - ind
    res %= mod
  else:
    xa = N - bl(sa, x)
    xb = M - bl(sb, x)
    res *= xa * xb - y
    res %= mod
print(res)

Measured memory_bytes: 43868
// Problem Link: 
// Tutorial Link: 

#include<bits/stdc++.h>
 
using namespace std;
 
#define LL long long
#define ll  long long
#define all(v) v.begin(), v.end()
#define pb push_back
#define pLL pair<LL,LL>
#define ff first
#define ss second
#define rep(i,a,b) for(LL i=a;i<b;++i)
#define repb(i,a,b) for(LL i=a;i>b;--i)
#define ld double
#define mp make_pair
#define vLL vector<LL>
#define vpLL vector<pLL>
#define vld vector<ld>
#define pld pair<ld,ld>
#define vpld vector<pld>
#define SLL set<LL>
#define SpLL set<pLL>
#define FIO ios::sync_with_stdio(false)
#define mod 100000000007

LL mx = -mod, mn = -mod;
map<LL, LL> mxmm, mnmm;
LL n;

int main()
{
	FIO;
	cin >> n;
	rep(i,0,n) {
		LL x, y;
		cin >> x >> y;
		if(mxmm.find(x) == mxmm.end()) {
			mxmm[x] = y;
		}
		else mxmm[x] = max(mxmm[x], y);
		if(mnmm.find(x) == mnmm.end()) {
			mnmm[x] = y;
		}
		else mnmm[x] = min(mnmm[x], y);
	}
	LL ans = -mod;
	for(auto pr: mxmm) {
		LL x = pr.ff;
		ans = max(ans, mxmm[x]+x+mn);
		ans = max(ans, x+mx-mnmm[x]);
		ans = max(ans, mxmm[x]-mnmm[x]);
		mx = max(mx, mxmm[x]-x);
		mn = max(mn, -mnmm[x]-x);
	}
	cout << ans << endl;
}

Measured memory_bytes: 28612
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <string>
#include <vector>
#include <limits>
#include <algorithm>
#include <utility>
#include <sstream>
#include <numeric>
#include <iterator>

using namespace std;

#define repd(i,a,b) for (int i=(a);i<(b);++i)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
typedef pair<int, int> P;

int main(int argc, const char * argv[]) {
  string s;
  cin >> s;
  long long k;
  cin >> k;
  char ans;
  int count = 0;
  rep(i, s.size()){
    if(s[i] == '1'){
      count++;
    }else{
      ans = s[i];
      break;
    }
  }
  if(count >= k){
    cout << 1 << endl;
  }else{
    cout << ans << endl;
  }
  return 0;
}


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



int main()
{
	ios::sync_with_stdio(false);
	string s[10] = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
	int cnt = 0;
	string str; cin >> str;
	for(int i = 0; i < 7; i++){
		if(str == s[i]){
			cnt = i;
			break;
		}
	}
	cout << 7 - cnt << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#define N 100000
int main()
{

    int a;
    unsigned long long z = 1;
    scanf("%d", &a);
    unsigned long long  s[N];
    unsigned long long n = 0;
    int count = 0;
    int flag = 0;
    for (int i = 0; i < a; i++)
    {
        scanf("%lld", &s[i]);
        if(s[i]==0){
            flag = 1;
            break;
        }
        if (s[i] > 1000000000000000000){
            flag = 2;
            
        }
        n = s[i];
        for (int j = 0; j < 18; j++)
        {
            break;
            n = s[i] / 10;
            if (n > 10)
                count++;
        }
    }



    if (flag == 1){
        printf("0");
    }
    else if (flag == 2 || count>=18){
        printf("-1");
    }
    else{
         for (int i = 0; i < a; i++)
        {
            if (1000000000000000000/s[i]<z){
                flag = 3;
                break;
            }
            if (s[i] * z > 1000000000000000000)
            {
                printf("-1");
                flag = 3;
                break;
                }
                else
                    z = s[i] * z;
        }
        if(flag==3)
            printf("-1");

        if(flag==0){
            printf("%lld", z);
        }
    }

  
    printf("\n");
}

Measured memory_bytes: 2936
h, w = gets.chomp.split.map(&:to_i)
answer = Array.new(h){Array.new(w, nil)}
h.times{|j|
    prev = nil
    gets.chomp.split("").each_with_index{|c, i|
        if c == "c"
            answer[j][i] = 0
            prev = 1
        else
            if prev
                answer[j][i] = prev
                prev += 1
            else
                answer[j][i] = -1
            end
        end
    }
}
answer.each{|ans| puts ans.join(" ")}


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

using namespace std;
#define int long long
int MOD = 1000000007;

signed main(){
    int W,a,b;
    cin >> W >> a >> b;
    
    if(b+W<a) cout << a-(b+W) << endl;
    else if(a+W<b) cout << b-(a+W) << endl;
    else cout << 0 << endl;
    
    return 0;
}


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

int main() {
	long n,pro=3;
	string s,r;
	cin>>n>>s>>r;
	if(n!=2){
	for(int i=1;i<n;++i){
		if(s.at(i-1)==r.at(i-1)){
			if(i==1){
				pro=3;
			}
			if(s.at(i)==r.at(i)){
				pro*=2;
			}
			else{
				pro*=2;
				i++;
			}
		}
		else{
			if(i==1){
				i++;
				pro=6;
			}
			
			if(s.at(i)==r.at(i)){
				
			}
			else{
				pro*=3;
				i++;
			}
		}
	pro=pro%1000000007;	
	}
	
	cout<<pro<<endl;
	}
	else{
		cout<<6<<endl;
	}
}

Measured memory_bytes: 256
H, W, K = map(int, input().split())
grid = []
for _ in range(H):
    grid.append(input())

ans = [[0 for _ in range(W)] for _ in range(H)]
k = 0
for i in range(H):
    flg = 0
    for j in range(W):
        s = grid[i][j]
        if s == '#':
            flg = 1
            k += 1
        if flg:
            ans[i][j] = k
for i in range(H):
    if sum(ans[i]) == 0:
        continue
    for j in range(W-1, -1, -1):
        if ans[i][j] == 0:
            ans[i][j] = ans[i][j+1]

for i in range(1, H):
    for j in range(W):
        if ans[i][j] == 0:
            ans[i][j] = ans[i-1][j]
for i in range(H-1, -1, -1):
    for j in range(W):
        if ans[i][j] == 0:
            ans[i][j] = ans[i+1][j]

for i in range(H):
    print(' '.join(map(str, ans[i])))


Measured memory_bytes: 46188
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vout(x) {rep(i,x.size()) cout << x[i] << " "; cout << endl;}
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9+7;
const ll inf_l = 1e18;
const int MAX = 1e6;

int main() {
    int a; cin >> a;
    cout << a + pow(a,2) + pow(a,3) << endl;
}

Measured memory_bytes: 4288
#include <cstdio>

int student[30];

int main()
{
    for (int i = 0; i < 28; i++){
        int n;

        scanf("%d", &n);
        student[n - 1] = 1;
    }

    for (int i = 0; i < 30; i++){
        if (student[i] == 0){
            printf("%d\n", i + 1);
        }
    }

    return (0);
}

Measured memory_bytes: 1024
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#define FOR(i,n,a) for(int i = a;i<n;i++)
#define rep(i,n) FOR(i,n,0)
#define UNFOR(i,n,a) for(int i = a;i>n;i--)
#define unrep(i,n) UNFOR(i,0.n)
typedef long long ll;
using namespace std;
int a[1000000];
int b[1000000];
int main(){
	int N,H;
	cin >> N >> H;
	int count = 0;
	int amax = 0;
	rep(i, N) {
		cin >> a[i] >> b[i];
		amax = max(amax, a[i]);
	}
	sort(b,b+N, greater<int>());
	rep(i, N) {
		if (H <= 0) {
			cout << count << endl;
			return 0;
		}
		if (amax > b[i])break;
		count++;
		H -= b[i];
	}
	if (H <= 0) {
		cout << count << endl;
		return 0;
	}
	if (H % amax != 0)count++;
	count += H / amax;
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 4736
/* << IN THE NAME OF GOD >> */
#include <bits/stdc++.h>
using namespace std;

#define err(x) cerr << #x << " = " << x << '\n'
const int maxn = 1e8;

int h ,w ,k ,a[600][600] ,b[maxn] ,c[maxn] ,d[maxn] ,e[maxn];

int  main(){ios::sync_with_stdio(0) ,cout.tie(0) ,cin.tie(0);
    cin >> h >> w;
    for(int i = 1; i <= h; i++)
        for(int j = 1; j <= w; j++)
            cin >> a[i][j];

    for(int i = 1; i <= h; i++)
        for(int j = 1; j <= w; j++)
            if(a[i][j] & 1 && j != w)
                a[i][j + 1]++ ,b[k] = i ,c[k] = j ,d[k] = i ,e[k] = j + 1 ,k++;
            else if(a[i][j] & 1 && i != h)
                a[i + 1][j]++ ,b[k] = i ,c[k] = j ,d[k] = i + 1 ,e[k] = j ,k++;

    cout << k << '\n';

    for(int i = 0; i < k; i++)
        cout << b[i] << " "<< c[i] << " " << d[i] << " " << e[i] << endl;
    return 0;
}








Measured memory_bytes: 11904
n=int(input())
#正直者を1で正直者じゃない人を0で表しbit表を作る
bit=[]
for i in range(2**n):
    b=[]
    for j in range(n):
        if (i>>j & 1):
            b.append(1)
        else:
            b.append(0)
    bit.append(b)
    
#データの入力
honest=[[] for i in range(n)]
for i in range(n):
  a=int(input())
  for j in range(a):
    x,y=list(map(int,input().split()))
    honest[i].append(x)
    honest[i].append(y)

ans=[]

#順番に全探索していく
for i in bit:
  flg=False
  for j in range(n):
    if i[j]==1:
      k=0
      while k<len(honest[j]):
        if i[honest[j][k]-1]!=honest[j][k+1]:
          flg=True
          break
        k=k+2
      if flg:
        break
    if flg:
      break
  if flg==False:
    ans.append(i.count(1))
  

print(max(ans))


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

//定数
const long long MOD1=1000000007;
const long long MOD2=998244353;
const long double PI=3.1415926535897932;
const long long MAXLL=9223372036854775807;
const long long INF=2305843009213693951;
const long long dx[]={0,1,0,-1,1,-1,1,-1};
const long long dy[]={1,0,-1,0,1,1,-1,-1};

//型名省略
#define ll long long
#define ull unsigned long long
#define ld long double
#define uld unsigned long double
#define pll pair<long long,long long>
#define tll(n) array<long long,(int)(n)>
#define pcc pair<char,char>
#define vl vector<long long>
#define vvl vector<vector<long long>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vp vector<pair<long long,long long>>
#define vt(n) vector<array<long long,(int)(n)>>
#define umap unordered_map
#define uset unordered_set
#define Lqueue priority_queue<long long>
#define Squeue priority_queue<long long,vector<long long>,greater<long long>>
#define Fi first
#define Se second
#define mp make_pair
#define eb emplace_back

//マクロ
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define rbf(a,x) for(auto& a:x)
#define rep(i,n) for(long long i=0;i<(long long)(n);i++)
#define rep2(i,s,n) for(long long i=(s);i<(long long)(n);i++)
#define bitrep(i,s,n) for(long long i=(s);i<(1LL<<(n));i++)
#define Maxe(x) *max_element((x).begin(),(x).end())
#define Mine(x) *min_element((x).begin(),(x).end())
#define Size(x) ((long long)(x).size())
#define lin(s) getline(cin,(s))
#define Ssort(v) sort((v).begin(),(v).end(),[](auto &left,auto &right){return left.second<right.second;})

//Yes,No
void Yes(bool a){cout<<(a?"Yes":"No")<<endl;}
//YES.NO
void YES(bool a){cout<<(a?"YES":"NO")<<endl;}

//MAX,MIN
template<class T,class U> auto max(T a,U b){return a>b?a:b;}
template<class T,class U> auto min(T a,U b){return a<b?a:b;}

//最大公約数,最小公倍数
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcm(long long a,long long b){return a/gcd(a,b)*b;}

//累乗
template<typename t>
constexpr t mypow(t a,long long b){
    if(b==0)return 1;
    if(a==0)return 0;
    t x=1;
    while(b>0){
        if(b&1LL)x*=a;
        a*=a;
        b>>=1LL;
        }
    return x;
}
#define pow mypow

//chmin,chmax
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;}

//組み合わせ O(r)
template<typename t>
constexpr t nCr(t n,long long r){
    if(r==0)return 1;
    if(n==0)return 0;
    if(n<r)return 0;
    t x=1;
    for(long long i=1;i<=r;i++){
        x*=n-i+1;
        x/=i;
    }
    return x;
}

vl A;
ll n,k;

ll solve(ll l,ll r){
    if(r-l<=1)return r;
    ll m=(l+r)/2;
    ll c=0;
    rep(i,Size(A)){
        c+=(A[i]+m-1)/m-1;
    }
    if(c>k){
        return solve(m,r);
    }
    else{
        return solve(l,m);
    }
}

//main関数
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cin>>n>>k;
    A.resize(n);
    rep(i,n)cin>>A[i];
    ll L=0;
    ll R=Maxe(A)+1;
    cout<<solve(L,R)<<endl;
}

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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;++A)
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////
ll X, Y, A, B, C,ABC, P[101010], Q[101010], R[101010];
pll PQR[303030];
ll i, j, k;

int main(){
    scanf("%lld%lld%lld%lld%lld", &X,&Y,&A,&B,&C);
    ABC = A + B + C;
    fornum(i,0,A){
        ll p;
        scanf("%lld",&p);
        PQR[i] = {p, 0};
    }
    fornum(i,0,B){
        ll p;
        scanf("%lld",&p);
        PQR[i+A] = {p, 1};
    }
    fornum(i,0,C){
        ll p;
        scanf("%lld",&p);
        PQR[i+A+B] = {p, 2};
    }
    sort(PQR, PQR + ABC);
    ll a = 0, b = 0, c = 0;
    ll ans = 0;
    for (i = ABC-1; i >= 0;--i){
        pll pq = PQR[i];
        if(pq.second==0){
            if(a<X){
                ans += pq.first;
                ++a;
            }
        }else if(pq.second==1){
            if(b<Y){
                ans += pq.first;
                ++b;
            }
        }else{
            ans += pq.first;
            ++c;
        }


        if(a+b+c==X+Y)
            break;
    }
    printf("%lld\n", ans);

    return 0;
}

Measured memory_bytes: 6400
#include <iostream>
#include <sstream>
#include <vector>
#include <algorithm>
int main()
{
    int A,B,C;
    std::cin >> A >> B >> C;
    if(A>B && A>C){
        std::cout << B*C/2 << std::endl;
    }
    if(B>A && B>C){
        std::cout << A*C/2 << std::endl;
    }
    if(C>A && C>B){
        std::cout << A*B/2 << std::endl;
    }
    return 0;
}

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

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

  vector<vector<int>> X(N, vector<int>(D));
  rep( i, 0, N ) {
    rep( j, 0, D ) cin >> X.at(i).at(j);
  }

  int Ans = 0;
  rep( i, 0, N ) {
    rep( j, i+1, N ) {
      int Norm = 0;
      rep( k, 0, D ) {
        int Diff = abs( X.at(i).at(k) - X.at(j).at(k) );
        Norm += Diff * Diff;
      }
      bool flag = false;
      rep( k, 0, Norm+1 ) {
        if ( k * k == Norm ) flag = true;
      }
      if ( flag ) Ans++;
    }
  }
  cout << Ans <<endl;
}


Measured memory_bytes: 256
N = gets.chomp.to_i
A = gets.chomp.split.map(&:to_i)
B = gets.chomp.split.map(&:to_i)

total = A.inject(&:+)
# p A
# p B
# p total

0.upto(B.size - 1).each do |i|
  amount = [B[i], A[i]].min
  B[i] -= amount
  A[i] -= amount
  
  # Try A[i+1]
  amount2 = [B[i], A[i+1]].min
  B[i] -= amount2
  A[i+1] -= amount2
end

# For Debug
# p A
# p B

p total - A.inject(&:+)


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

int main() {
  int N;
  cin >> N;
  
  vector<int> P(N);
  for (int i = 0; i < N; i++){
    cin >> P[i]; 
  }
  
  int count = 1;
  int min = P.at(0);
  for(int i = 1; i < N; i++){
    if (P.at(i) < min ){
      min = P.at(i);
      count++;
    }  
  }
  cout << count << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define max3(x,y,z) max(x,max(y,z))
ll dp[100009]= {-1};
ll inf = 1e9;
ll n,k;
ll arr[100009];


int main()
{
  cin >> n>>k;
 for(int i=0;i<n;i++)
 dp[i]=inf;
  for(int i=0;i<n;i++)
  {
    cin>>arr[i];
  }  
 dp[0]=0;

 for(int i=1;i<n;i++)
 {

   for(int j=1;j<=i&&j<=k;j++)
  {//cout<<dp[i]<<" "<<dp[i-j]+abs(arr[i]-arr[i-j])<<" "<<i<<" "<<j<<endl;;
     dp[i]=min(dp[i],dp[i-j]+abs(arr[i]-arr[i-j]));

  }

 }

cout<<dp[n-1];

}

Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
#include <set>
#include <utility>
using namespace std;

int main()
{
    int n,m,i,j,temp1,temp2;
    cin >> n >> m;
    vector<vector<int>> a(n,vector<int>(m,0));
    for(i = 0;i < n;++i){
        cin >> temp1;
        for(j = 0;j < temp1;++j){
            cin >> temp2;
            a.at(i).at(temp2-1) = 1;
        }
    }
    int ans = 0;
    bool flag = true;
    for(i = 0;i < m;++i){
        for(j = 0;j < n;++j){
            if(a.at(j).at(i)){
                continue;
            }else{
                flag = false;
                break;
            }
        }
        if(flag){
            ++ans;
        }else{
            flag = true;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <set>
#include <map>
#include <list>
#include <stack>
#include <queue>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>

using namespace std;

typedef long long ll;

const double EPS = 1e-9;
const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, 1, -1};

typedef vector<int> vi;
typedef pair<int, int> pi;

#define rep(i, n) for(int i = 0;i < n;i++)
#define repr(i, n) for(int i = n;i >= 0;i--)
#define ALL(v) (v).begin(), (v).end()

int main(){
  int x,a,b;
  scanf("%d %d %d", &x, &a, &b);

  if(a-b >= 0){
    printf("delicious\n");
  }
  else if(b-a <= x){
    printf("safe\n");
  }
  else{
    printf("dangerous\n");
  }

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
#include <math.h>
 
using namespace std;

int main(){
  int a,b;
  cin >> a >> b;
  int ans=0;
  int c=max(a+b,2*a-1);
  int d=max(c,2*b-1);
  
  cout << d << endl;

}

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

#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = (n)-1; i >= 0; i--)
#define rep1(i,n) for(int i = 1; i <= (n); i++)
#define rrep1(i,n) for(int i = (n); i > 0; i--)

#define ll long long
#define pi pair<int, int>
#define pll pair<ll, ll>

#define MOD 1000000007
#define INF 1000000000000000LL

using namespace std;

ll dp[3001][3001];
ll dps[3001][3001];

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

  dp[0][0]=1;
  rep(i, n-1){

    dps[i][0]=dp[i][0];
    rep1(j, i+1){
      dps[i][j] += dps[i][j-1] + dp[i][j];
      dps[i][j] %= MOD;
    }

    rep(j, i+2){

      if(s[i]=='<'){
        if(j)dp[i+1][j] += dps[i][j-1];
      }else{
//cout<<i<<' '<<j<<' '<<dps[i][i]<<' '<<dps[i][j-1]<<endl<<"="<<endl;

//cout<<"---"<<endl;
//rep(i, n+1){
//  rep(j, n+1)cout<<dps[i][j]<<' ';cout<<endl;
//}cout<<"---"<<endl;

        dp[i+1][j] += dps[i][i];
        if(j)dp[i+1][j] -= dps[i][j-1];
      }

      dp[i+1][j] %= MOD;
    }
  }

  ll result=0;
  rep(j, n)result += dp[n-1][j];

  while(result<0)result+=MOD;

  cout<<result%MOD<<endl;

  return 0;

rep(i, n+1){
  rep(j, n+1)cout<<dp[i][j]<<' ';cout<<endl;
}cout<<"---"<<endl;

  return 0;
}


Measured memory_bytes: 95828
import collections
def main():

    N, M, K = map(int, input().split())
    friend = collections.defaultdict(set)
    for _ in range(M):
        A, B = map(int, input().split())
        friend[A].add(B)
        friend[B].add(A)
    block = collections.defaultdict(set)
    for _ in range(K):
        C, D = map(int, input().split())
        block[C].add(D)
        block[D].add(C)

    visited = set()
    ans = [0 for _ in range(N)]
    for i in range(1, N+1):
        if i not in visited:
            group = set([i])
            cur = set([i])
            while cur:
                temp = set()
                for j in cur:
                    for k in friend[j]:
                        if k not in group:
                            temp.add(k)
                            group.add(k)
                cur = temp

            for j in group:
                ans[j-1] = len(group) - len(friend[j]) - 1
                for k in block[j]:
                    if k in group: ans[j-1] -= 1
            visited |= group
    return " ".join(map(str, ans))

if __name__ == '__main__':
    print(main())

Measured memory_bytes: 132348
readline = open(0).readline
Q = int(readline())
ans = []
M = {}
C = [M.__setitem__, lambda key, push=ans.append: push("%s\n" % M[key])].__getitem__
for q in range(Q):
    t, *a = readline().split()
    C(int(t))(*a)
open(1, 'w').writelines(ans)


Measured memory_bytes: 41860
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	
	int n, l; cin >> n >> l;
	vi v;
	rep(i, n) v.pb(l + i);
	
	if(binary_search(all(v), 0)){
		cout << accumulate(all(v), 0) << endl;
	}
	else if(v[0] > 0){
		cout << accumulate(all(v), 0) - v[0] << endl;
	}
	else{
		cout << accumulate(all(v), 0) - v.back() << endl;
	}
	
	return 0;
}

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

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

Measured memory_bytes: 3608
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <functional>
using namespace std;

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
    string a, b, c;
    cin >> a >> b >> c;
    int cntA = 0, cntB = 0, cntC = 0;
    int index = a[0];
    cntA++;
    while(true) {
        switch(index) {
            case 'a':
                if (cntA == a.size()){
                    cout << 'A' << endl;
                    return 0;
                }
                cntA++;
                index = a[cntA]; break;
            case 'b':
                if (cntB == b.size()) {
                    cout << 'B' << endl;
                    return 0;
                }
                cntB++;
                index = b[cntB]; break;
            default :
                if (cntC == c.size()) {
                    cout << 'C' << endl;
                    return 0;
                }
                cntC++;
                index = c[cntC]; break;
            }
    }
    return 0;
}

Measured memory_bytes: 256
import sys

s = list(input())
if s[0] == 'A' and s[1] == 'A' and s[2] == 'A':
  print('No')
  sys.exit()
if s[0] == 'B' and s[1] == 'B' and s[2] == 'B':
  print('No')
  sys.exit()
print('Yes')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
struct Fast { Fast() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20);} } fast;

vector<int> read_vec(int n){
    vector<int> ret(n);
    for (int i = 0; i < n; i++){
        cin >> ret[i];
    }
    return ret;
}

int main() {
    long long n, m, a = 0, b = 0, c = 1, d = 1;
    cin >> n >> m;
    if (n > m){
        a = n;
        b = m;
    }else{
        a = m;
        b = n;
    }
    if (a - b > 1){
        cout << 0 << endl;
        return 0;
    }
    for (int i = a; i > 0; i--){
        c *= i;
        c = c % 1000000007;
    }
    for (int i = b; i > 0; i--){
        d *= i;
        d = d % 1000000007;
    }
    if (m != n){
        cout << (c * d) % 1000000007<< endl;
    }else{
        cout << (c * d * 2) % 1000000007<< endl;
    }
}

Measured memory_bytes: 256
data class Test(val b: Long, val l: Long, val u: Long)

fun divCeil(x: Long, y: Long): Long = (x + y - 1) / y

fun main(args: Array<String>) {
  val (nRaw, x) = readLine()!!.split(" ").map { it.toLong() }
  val n = nRaw.toInt()
  val tests = Array(n, {
    val (b, l, u) = readLine()!!.split(" ").map { it.toLong() }
    Test(b, l, u)
  })
  var currentDiff = tests.map { -it.l * it.b }.sum()
  fun maxGain(test: Test): Long = test.l * test.b + test.u * (x - test.b)
  fun requiredScore(test: Test, score: Long): Long {
    if (score > maxGain(test)) throw RuntimeException()
    if (score <= test.l * test.b) {
      return divCeil(score, test.l)
    } else {
      return test.b + divCeil(score - test.l * test.b, test.u)
    }
  }
  tests.sortByDescending { maxGain(it) }

  var ans = 0L
  for (i in 0 until n) {
    if (currentDiff + maxGain(tests[i]) <= 0) {
      ans += x
      currentDiff += maxGain(tests[i])
    } else {
      var min = x
      for (k in i until n) {
        if (currentDiff + maxGain(tests[k]) >= 0) {
          min = Math.min(min, requiredScore(tests[k], -currentDiff))
        }
      }
      for (k in 0 until i) {
        val tmpDiff = currentDiff + maxGain(tests[i]) - maxGain(tests[k])
        min = Math.min(min, requiredScore(tests[k], -tmpDiff))
      }
      ans += min
      break
    }
  }

  // if (currentScore < 0) throw RuntimeException()

  println(ans)
}

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

int main() {
  int A; cin >> A; // 入力値Ａ（左）
  int B; cin >> B; // 入力値Ｂ（左）
  int C; cin >> C; // 入力値Ｃ（右）
  int D; cin >> D; // 入力値Ｄ（右）
  
  if ( A+B > C+D ) {
    cout << "Left" << endl;
  } else if ( A+B < C+D ) {
    cout << "Right" << endl;
  } else {
    cout << "Balanced" << endl;
  }


}



Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
int i,n;
double x1,y1,x2,y2,x3,y3,x4,y4;
cin>>n;
for(i=0;i<n;i++){
cin>>x1>>y1>>x2>>y2>>x3>>y3>>x4>>y4;
if((x2-x1)*(y4-y3)==(x4-x3)*(y2-y1))cout<<"YES"<<endl;
else cout<<"NO"<<endl;
}
return 0;
}

Measured memory_bytes: 1224
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <complex>
#include <valarray>
#include <fstream>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <random>

#define _overload(a, b, c, d, ...) d
#define _rep1(X, A, Y) for (int (X) = (A);(X) <= (Y);++(X))
#define _rep2(X, Y) for (int (X) = 0;(X) < (Y);++(X))
#define rep(...) _overload(__VA_ARGS__, _rep1, _rep2)(__VA_ARGS__)
#define rrep(X,Y) for (int (X) = Y-1;(X) >= 0;--(X))
#define all(X) (X).begin(),(X).end()
#define len(X) ((int)(X).size())
#define mod(n, m) (((n)%(m)+(m))%m)
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
const int INFINT = 1 << 30;                          // 1.07x10^ 9
const ll INFLL = 1LL << 60;                          // 1.15x10^18
const double EPS = 1e-10;
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};


int N, K;
string S;

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

  cin >> N >> K;
  cin >> S;

  if (S[K-1] == 'A') {
      S[K-1] = 'a';
  } else if (S[K-1] == 'B') {
      S[K-1] = 'b';
  } else {
      S[K-1] = 'c';
  }

  cout << S << endl;

  return 0;
}


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

#define forn(i, n) for (int i = 0; i < int(n); ++i)
#define for1(i, n) for (int i = 1; i <= int(n); ++i)
#define fore(i, l, r) for (int i = int(l); i <= int(r); ++i)
#define ford(i, n) for (int i = int(n)-1; i >= 0; --i)
#define pb push_back
#define eb emplace_back
#define ms(a, x) memset(a, x, sizeof(a))
#define F first
#define S second
#define endl '\n'
#define all(x) (x).begin(),(x).end()

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 0x3f3f3f3f;
mt19937 gen(chrono::high_resolution_clock::now().time_since_epoch().count());

vector<ll> a;
void dfs(int len,ll x){
    if(len>10) return;
    a.pb(x);
    int a=x%10;
    if(a>0) dfs(len+1,x*10+a-1);
    dfs(len+1,x*10+a);
    if(a<9) dfs(len+1,x*10+a+1);
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
	int K;
    cin>>K;
    for1(i,9) dfs(1,i);
    sort(all(a));
    unique(all(a));
    cout<<a[K-1];
    return 0;
}



Measured memory_bytes: 2420
N, M = map(int, input().split())
a_dict = dict()
for _ in range(M):
    a = int(input())
    a_dict[a] = 1

LARGE = 10**9 + 7

r_arr = [0]*(N+1)
r_arr[0] = 1
if a_dict.get(1, 0) == 1:
    r_arr[1] = 0
else:
    r_arr[1] = 1

for i in range(2, N+1):
    if a_dict.get(i, 0) == 1:
        pass
    else:
        r_arr[i] = (r_arr[i-1] + r_arr[i-2]) % LARGE

print(r_arr[-1])

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

int main() {
	int n; scanf("%d", &n);
	int c4 = 0, c2 = 0, c1 = 0;
	for(int i = 0; i < n; i++) {
		int k; scanf("%d", &k);
		if(k % 4 == 0) c4++;
		else if(k % 2 == 0) c2++;
		else c1++;
	}
	if(c4 >= c1) puts("Yes");
	else {
		if(c4 + 1 == c1 && !c2) puts("Yes");
		else puts("No");
	}
	return 0;
}


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

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

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

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

    long long ans = 0;
    if(n % 2 == 0){
        for(int i = 0; i < n; i++){
            if(i < n / 2){
                if(i == n / 2 - 1) ans -= A[i];
                else ans -= A[i] * 2;
            }else{
                if(i == n / 2) ans += A[i];
                else ans += A[i] * 2;
            }
        }
    }else{
        for(int i = 0; i < n; i++){
            if(i <= n / 2){
                if(i < n / 2 - 1) ans -= A[i] * 2;
                else ans -= A[i];
            }else{
                ans += A[i] * 2;
            }
        }

        long long t = 0;
        for(int i = 0; i < n; i++){
            if(i < n / 2){
                t -= A[i] * 2;
            }else{
                if(i < n / 2 + 2){
                    t += A[i];
                }else{
                    t += A[i] * 2;
                }
            }
        }
        ans = max(ans, t);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1152
#include <stdio.h>
#include <string.h>
int m[100000][2];
int main(){
  int n,i,j,t;
  for(;;){
    scanf("%d",&n);
    if(n==0) break;
    memset(m,-1,sizeof(m));
    t = 0;
    for(i=1;i<=n;i++){
      scanf("%d",&j);
      if(i % 2 == 1){
	if(m[t][1] == -1){
	  m[t][1] = j;
	  m[t][0] = 1;
	}else if(m[t][1] == j){
	  m[t][0]++;
	}else{
	  m[++t][1] = j;
	  m[t][0] = 1;
	}
      }else{
	if(m[t][1] == j){
	  m[t][0]++;
	}else{
	  if(t == 0){
	    m[t][1] = j;
	    m[t][0]++;
	  }else{
	    m[t-1][0] += m[t][0] + 1;
	    t--;
	  }
	}
      }
    }
    j = 0;
    while(t>=0){
      if(m[t][1] == 0) j += m[t][0];
      t--;
    }
    printf("%d\n",j);
  }
  return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
//INSERT ABOVE HERE
signed main(){
  Int n;
  cin>>n;
  priority_queue<Int,vector<Int>,greater<Int> > pq;
  for(Int i=0;i<n;i++){
    Int m;
    cin>>m;
    for(Int j=0;j<m;j++){
      Int c;
      cin>>c;
      pq.emplace(c);
      if(j) pq.pop();
    }
  }
  Int ans=0;
  while(!pq.empty()) ans+=pq.top(),pq.pop();
  cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 6888
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdlib>
using namespace std;

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//infinity
#define INTINF 2000000000
#define LONGINF 2000000000

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int main(){
	int N, K;
	cin >> N >> K;
	int c[N];
	REP(i, N){
		cin >> c[i];
	}

	int t = N - K;
	if(t <= 0){
		cout << 1 << endl;
		return 0;
	}

	int count = 1;
	while(t > 0){
		t -= (K-1);
		count++;
	}
	cout << count << endl;
	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define fore(i,a,b) for(int i=a,thxicesi=b; i<thxicesi;i++)
#define FIN ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0)
#define sz(s) int(s.size())
using namespace std;

int main()
{FIN;
    int n,m; cin>>n>>m;
    int sum = 0;
    fore(i,0,m){
        int a; cin>>a;
        sum+= a;
    }
    n-= sum;
    if(n<0)cout<<"-1\n";
    else cout<<n<<"\n";
    return 0;
}


Measured memory_bytes: 3688
using System;
class p
{
  static void Main()
  {
    string[] input = Console.ReadLine().Split(' ');
    int A = int.Parse(input[0]);
    int B = int.Parse(input[1]);
    int X = int.Parse(input[2]);
    Console.WriteLine((A <= X) && (X <= A + B) ? "YES" : "NO");
  }
}

Measured memory_bytes: 13140
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int ans = 0;
		boolean G = false,W = false,P = false,Y = false;
		for(int i = 0;i < n;i++) {
			String s = sc.next();
			if(s.equals("G") && !G) {G = true; ans++;}
			if(s.equals("P") && !P) {P = true; ans++;}
			if(s.equals("W") && !W) {W = true; ans++;}
			if(s.equals("Y") && !Y) {Y = true; ans++;}
		}
		if(ans == 3) System.out.println("Three");
		else if(ans == 4) System.out.println("Four");
	}
}

Measured memory_bytes: 21716
#include <stdio.h>
#include <string.h>
#include <ctype.h>

int main(void)
{
	char W[11] = {0};
	char TMP_W[11] = {0};
	char T[1001] = {0};
	char TMP_T[1001] = {0};
	int i, cnt=0;
	
	scanf("%s", TMP_W);
	for (i = 0; i < strlen(TMP_W); ++i) {
		W[i] = toupper(TMP_W[i]);
	}

	while (1) {
		memset(T, '\0', 1001);
		memset(TMP_T, '\0', 1001);
		scanf("%s", TMP_T);
		if (strcmp(TMP_T, "END_OF_TEXT") == 0) {
			break;
		}
		for (i = 0; i < strlen(TMP_T); ++i) {
			T[i] = toupper(TMP_T[i]);
		}

		if (strlen(T) == strlen(W) && strstr(T, W)) {
//			printf("%d\n", cnt);
//			printf("%s\n", W);
//			printf("%s\n", T);
			++cnt;
		}
	}
	printf("%d\n", cnt);
	return 0;
}

Measured memory_bytes: 548
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <cmath>

using namespace std;
#define PI 3.1415926535897932384626433832795
#define MOD (1000000007)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
typedef long long ll;
typedef unsigned long long ull;

ll v[50];
ll combination[51][51];

int main()
{
	int N, A, B;
	ll ans = 0, vthr;
	double avg = 0;
	map<ll, int> cnt, inner_cnt;

	cin >> N >> A >> B;
	rep(i, N) {
		cin >> v[i];
		if (cnt.count(v[i]) == 0) cnt[v[i]] = 1;
		else cnt[v[i]]++;
	}

	sort(v, v + N, greater<ll>());

	repc(n, 1, N) {
		repc(r, 0, n) {
			if (r == 0 || r == n) combination[n][r] = 1;
			else combination[n][r] = combination[n - 1][r - 1] + combination[n - 1][r];
		}
	}

	repc(i, A, B) {
		ll add = 1;
		map<ll, bool> checked;

		if (i == A) {
			ll sum = 0;

			rep(j, i) {
				sum += v[j];
				if (inner_cnt.count(v[j]) == 0) inner_cnt[v[j]] = 1;
				else inner_cnt[v[j]]++;
			}
			avg = (double)sum / (double)i;

			vthr = v[0];
		}
		else {
			if (v[i - 1] < vthr) break;
			inner_cnt[v[i - 1]]++;
		}

		rep(j, i) {
			if (checked.count(v[j]) >= 1) continue;

			add *= combination[cnt[v[j]]][inner_cnt[v[j]]];
			checked[v[j]] = true;
		}
		ans += add;
	}

	printf("%.10lf\n", avg);
	cout << ans << endl;

	return 0;
}

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

using namespace std;

int main() {
    int K, A, B;
    bool fg = false;
    cin >> K;
    cin >> A >> B;

    for (int i = A; i <= B; i++) {
        if (i % K == 0) {
            cout << "OK" << endl;
            fg = true;
            break;
        }
    }

    if (!fg)cout << "NG" << endl;


}


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

int main() {
	int n;
	long long ans=0;;
	cin>>n;
	char s[n][10];
	long long f[5];
	for(int i=0;i<5;i++){
		f[i]=0;
	}
	for(int i=0;i<n;i++){
		cin>>s[i];
		if(s[i][0]=='M'){
			f[0]++;
		}else if(s[i][0]=='A'){
			f[1]++;
		}else if(s[i][0]=='R'){
			f[2]++;
		}else if(s[i][0]=='C'){
			f[3]++;
		}else if(s[i][0]=='H'){
			f[4]++;
		}
	}
	for(int i=0;i<5;i++){
//		cout<<f[i]<<endl;
	}
	for(int i=0;i<3;i++){
		for(int j=i+1;j<4;j++){
			for(int k=j+1;k<5;k++){
				ans=ans+f[i]*f[j]*f[k];
//				cout<<ans<<endl;
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 1280
s = input()
def ispalindrome(str): return 1 if str == str[::-1] else 0

n = len(s)
front = s[:(n-1)//2]
back = s[(n+3)//2-1:]

if ispalindrome(s) and ispalindrome(front) and ispalindrome(back):
    print('Yes')
else:
    print('No')


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define mo 1000000007
using namespace std;
int n,m,kk,pointnum,edgenum,tim,num,top;
int dfn[100010],low[100010],po[100010],p[100010],q[100010];
int vis[100010];
vector <int> des[100010];
set<int> mp[100010];
pair<int,int> st[100010];
void tarjan(int s,int pre=0)
{
	dfn[s]=low[s]=++tim;
	for (int k=0;k<des[s].size();k++) if (des[s][k]!=pre)
	{
		if (!dfn[des[s][k]])
		{
			st[++top]=make_pair(s,des[s][k]);
			tarjan(des[s][k],s);
			if (low[des[s][k]]>=dfn[s])
			{
				num++;
				while (st[top]!=make_pair(s,des[s][k]))
				{
					mp[st[top].first].insert(num);mp[st[top].second].insert(num);
					top--;
				}
				mp[st[top].first].insert(num);mp[st[top].second].insert(num);top--;
			}
			low[s]=min(low[s],low[des[s][k]]);
		}
		else low[s]=min(low[s],dfn[des[s][k]]);
	}
	//cerr<<s<<' '<<pre<<' '<<dfn[s]<<' '<<low[s]<<endl;
}
long long getmi(int a,int x)
{
	long long ans=1;
	while (x)
	{
		if (x&1) ans=ans*a%mo;
		a=(long long)a*a%mo;
		x>>=1;
	}
	return ans;
}
long long fac[100010],nifac[100010];
long long C(int n,int m){return fac[n]*nifac[m]%mo*nifac[n-m]%mo;}
long long polya(int n)
{
	long long ans=0;
	for (int i=1;i<=n;i++) ans=(ans+getmi(kk,__gcd(i,n)))%mo;
	return ans*getmi(n,mo-2)%mo;
}
int pp[100010],qq[100010];
int main()
{
	//freopen("in.txt","r",stdin);
	scanf("%d%d%d",&n,&m,&kk);
	fac[0]=nifac[0]=1;
	for (int i=1;i<=m+kk;i++){fac[i]=fac[i-1]*i%mo;nifac[i]=getmi(fac[i],mo-2);}
	for (int i=1;i<=m;i++)
	{
		scanf("%d%d",&p[i],&q[i]);
		des[p[i]].push_back(q[i]);des[q[i]].push_back(p[i]);
	}
	
	for (int i=1;i<=n;i++) if (!dfn[i]) tarjan(i);
	
	for (int i=1;i<=n;i++)
	for (set<int>::iterator it=mp[i].begin();it!=mp[i].end();it++) pp[*it]++;
	
	for (int s=1;s<=n;s++)
	for (int k=0;k<des[s].size();k++)
	{
		int t=des[s][k];
		for (set<int>::iterator it=mp[s].begin();it!=mp[s].end();it++) if (mp[t].count(*it)) {qq[*it]++;break;}
	}
	
	long long ans=1;
	for (int i=1;i<=num;i++)
	{
		qq[i]/=2;
		if (pp[i]>qq[i]) ans=ans*kk%mo;
		else if (pp[i]==qq[i]) ans=ans*polya(pp[i])%mo;
		else ans=ans*C(qq[i]+kk-1,kk-1)%mo;
	}
	cout<<ans<<endl;
}
	
		

Measured memory_bytes: 10624
/*
Arthor : Ender_zzm
E-mail zzm_ender_wiggin@outlook.com
Blog oi.ender-zzm.pro
*/
#include <bits/stdc++.h>
using namespace std;

template<class T>
inline void read(T &a) {
    register T x = 0, flag = 1;
    register char ch;
    while (!isdigit(ch = getchar())) if (ch == '-') flag = -1;
    while (x = x * 10 + (ch & 15), isdigit(ch = getchar()));
    a = x * flag;
}

template <class T>
inline void write(T x) {
    if (x < 0)
        putchar('-'), x = -x;
    if(x >= 10) write(x / 10); 
    putchar(x % 10 + '0');
}

template<class T> inline bool Chkmax(T& x, const T& y) { return x < y ? x = y, true : false; }
template<class T> inline bool Chkmin(T& x, const T& y) { return x > y ? x = y, true : false; }

#define For(i, a, b) for (int i = (a); i <= (b); i++) 
#define Rep(i, a, b) for (int i = (a); i >= (b); i--) 
#define For_edge(x) for (int i = head[x]; i; i = net[i])
#define mem0(a) memset(a, 0, sizeof a)

int a, b, c, k;
int main() {
	cin >> a >> b >> c >> k;
	int ans = 0;
	For (i, 1, 3) {
		if (i == 1) {
			int pos = min(a, k);
			ans += pos * 1;
			k -= min(a, k);
		}
		if (i == 2) {
			int pos = min(b, k);
			ans += pos * 0;
			k -= min(b, k);
		}
		if (i == 3) {
			int pos = min(c, k);
			ans += pos * -1;
			k -= min(c, k);
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 3632
#include <stdio.h>
#include <stdlib.h>
#define MAX 2000001
#define VMAX 10000

int main(){
  unsigned short *A, *B;
  int C[VMAX+1];
  int n, i, j;
  int a,b;

  scanf("%d", &n);

  A = malloc(sizeof(short)*n+1);
  B = malloc(sizeof(short)*n+1);

  /* your code */

  for(i = 0; i <= VMAX; i++) C[i] = 0;
  for(i = 0; i < n; i++){
    scanf("%hd",&A[i + 1]);
    a = A[i+1];
    C[a]++;
  }
  for(i = 1; i <= VMAX; i++) C[i] = C[i] + C[i - 1];

  for(j = 1; j <= n; j++){
    b = A[j];
    B[C[b]] = b;
    C[b]--;
  }

  for(i = 1; i <= n; i++){
    if(i > 1) printf(" ");
    printf("%d",B[i]);
  }

  printf("\n");

  return 0;
}



Measured memory_bytes: 9564
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
inline int read() {
	int x=0,f=1;char c=getchar();
	while (c<'0'||c>'9') {if (c=='-') f=-1;c=getchar();}
	while (c>='0'&&c<='9') x=x*10+c-'0',c=getchar();
	return x*f;
}
ll x;
char sta[104];
int tot;
int main() {
//	freopen("in.txt","r",stdin);
	cin>>x;
	while (x) {
		ll cur=x%26;
		if (cur==0) cur=26;
		x-=cur;
		sta[tot++]='a'+cur-1;
		x/=26;
	}
	for (int i=tot-1;~i;--i)
		printf("%c",sta[i]);
	return 0;
}

Measured memory_bytes: 3624
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {

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

    if ((a + b) >= 10) {
      System.out.println("error");
    } else {
      System.out.println(a + b);
    }

  }
}

Measured memory_bytes: 35740
#include<iostream>
#include<iomanip>
#include<math.h>
#include<cstdlib>
#include<algorithm>
#include<string>
#include<set>
#include<vector>
using namespace std;

#define INF 1<<21
#define MOD 1000000007

int main(){
    int n,m;
    double mm;
    int k;
    int ans=0;
    cin>>n>>m;
    k=m*1900+(n-m)*100;
    m=pow(2,m);
    cout<<k*m<<endl;
    return 0;
}


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

using namespace std;
long long mod = 1000000007;
int main(){
	ios_base::sync_with_stdio(false);
	int n;
	cin >> n;
	n *= 2;
	string s;
	cin >> s;
	
	int cnt = 0;
	for(int i = 0;i < n;i++){
		if(s[i] == 'B') cnt++;
		else cnt--;
	}
	if(cnt % 2 != 0){
		cout << "0";
		return 0;
	}
	
	long long pre = 0;
	bool start[n];
	for(int i = 0;i < n;i++){
		if(s[i] == 'B'){
			if(pre % 2 == 0){
				start[i] = true;
				pre++;
			}
			else{
				start[i] = false;
				pre--;
			}
		}
		else{
			if(pre % 2 == 0){
				start[i] = false;
				pre--;
			}
			else{
				start[i] = true;
				pre++;
			}
		}
	}
	
	cnt = 0;
	for(int i = 0;i < n;i++){
		if(start[i]) cnt++;
		else cnt--;
		if(cnt < 0){
			cout << "0";
			return 0;
		}
	}
	if(cnt != 0){
		cout << "0";
		return 0;
	}
	
	long long ans = 1;
	pre = 0;
	for(int i = 0;i < n;i++){
		if(start[i]) pre++;
		else{
			ans *= pre;
			pre--;
			ans %= mod;
		}
	}	
	
	for(long long x  = 1;x <= n/2;x++){
		ans *= x;
		ans %= mod;
	}
	cout << ans;
}


Measured memory_bytes: 788
using System;

public class Problem_A
{
  public static void Main()
  {
    var inputs = Console.ReadLine().Split();
    if (inputs[0] == inputs[1]) Console.WriteLine(inputs[2]);
    else if (inputs[0] == inputs[2]) Console.WriteLine(inputs[1]);
    else if (inputs[1] == inputs[2]) Console.WriteLine(inputs[0]);
  }
}


Measured memory_bytes: 13140
N, K = (int(x) for x in input().split())

S_true = input()

S = list(S_true)

if 'A' in S[K-1] :
    S[K-1] = S[K-1].lower()
elif 'B' in S[K-1]:
    S[K-1] = S[K-1].lower()
else : S[K-1] = S[K-1].lower()

S_ans = "".join(S)

print(S_ans)


Measured memory_bytes: 3060