akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#include<cmath>
#include<iostream>

int main () {
    double A,B,H,M;
    std::cin >> A >> B >> H >> M;

    double subX = A * std::cos((30 * H + M / 2) / 360 * (2 * M_PI)) - B * std::cos(6 * M / 360 * (2 * M_PI))  ;
    double subY = A * std::sin((30 * H + M / 2) / 360 * (2 * M_PI)) - B * std::sin(6 * M / 360 * (2 * M_PI))  ;

    double ans = std::sqrt(subX * subX + subY*subY);

    printf("%.10lf",ans );

    return 0;
}

Measured memory_bytes: 4084
#include <stdio.h>
int main(void)
{
int H ,W;
int i, j;
while(1){
scanf("%d %d" ,&H ,&W);
if(H == 0 && W == 0) break;
for ( i = 0; i < H; i++ ){
for ( j = 0; j < W; j++ ){
if(j==0||j==W-1||i==0||i==H-1){
printf("#");
}else{
printf(".");
}
}
printf("\n");
}
puts("");
}
return 0;
}

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

ll mod = 1e9+7;

ll gcd(ll a,ll b){
	if(b==0)return a;return gcd(b,a%b);
}
ll expo(ll base,ll pow){
    ll ans = 1;
    while(pow!=0){
        if(pow&1==1){ans = ans*base;ans = ans%mod;}
        base *= base;base%=mod;pow/=2;}return ans;
}
ll inv(ll x){return expo(x,mod-2);}

int b[223456], a[213456];

int main(){
    //freopen("input.txt", "rt", stdin);
    //freopen("output.txt", "wt", stdout);
    //cin.sync_with_stdio(false);
    //cin.tie(0); cout.tie(0);

    ll n;
    cin >> n;
    map <ll, int> mp;
    map <ll, int> :: iterator it;
    vector <ll> vec(n);

    for(int i = 0; i < n; i++){
        cin >> vec[i];
        mp[vec[i]]++;
    }
    ll max1 = 0, max2 = 0;

    for(it = mp.begin(); it !=mp.end(); it++){
        if((*it).second > 1){
            max2 = max1;
            max1 = (*it).first;
            if((*it).second > 3) max2 = max1;
            //cout << max1 << " " << max2 << endl;
        }
        
    }
    cout << max1*max2;
}


Measured memory_bytes: 7296
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_map>
#include<climits>
#include<cstdlib>
#include<cmath>
#include<string>
#include<iomanip>
#include<bitset>
#include<list>

using namespace std;

#define ll long long int

ll const MOD = 1000000007;
ll const INF = (long long int)1 << 61;

ll mypow(ll x,ll n){
    ll ret = 1;
    while(n > 0){
        if(n&1){
            ret = (ret*x)%MOD;
        }
        x = (x*x)%MOD;
        n >>= 1;
    }
    return ret;
}

list<ll> solve(ll w,ll h,ll n,ll m){
    vector<vector<ll>> paper(20*h+1,vector<ll>(20*w+1,0));

    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            paper[i][j] = 1;
        }
    }

    vector<ll> a(n),b(n),c(m),d(m);
    for(int i = 0; i < n; i++){
        cin >> a[i] >> b[i];
    }
    for(int i = 0; i < m; i++){
        cin >> c[i] >> d[i];
    }

    ll hb = 0;
    ll wb = 0;

    for(int i = 0; i < n; i++){
        if(a[i] == 1){
            for(int j = 0; j < b[i]; j++){
                for(int k = 0; k < 20*h+1; k++){
                    paper[k][(b[i] + wb) + abs(b[i] - j) - 1] += paper[k][wb + j];
                    paper[k][wb + j] = 0;
                }
            }
            wb += b[i];
        }else{
            for(int j = 0; j < b[i]; j++){
                for(int k = 0; k < 20*w+1; k++){
                    paper[(b[i] + hb) + abs(b[i] - j) - 1][k] += paper[hb + j][k];
                    paper[hb + j][k] = 0;
                }
            }
            hb += b[i];
        }
    }

    list<ll> ans;

    for(int i = 0; i < m; i++){
        ans.push_back(paper[hb + d[i]][wb + c[i]]);
        paper[hb + d[i]][wb + c[i]] = 0;
    }
    return ans;
}

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

    vector<list<ll>> ans;
 
    while(true){
        ll a,b,c,d;
        cin >> a >> b >> c >> d;
        if(a == 0 && b == 0 && c == 0 && d == 0){
            break;
        }
        ans.push_back(solve(a,b,c,d));
    }

    for(auto &x: ans){
        for(auto itr = x.begin(); itr != x.end(); itr++){
            cout << *itr << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 6160
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
  string s,t;
  cin>>s>>t;
  int l1=s.length();
  int l2=t.length();
  vector<vector<int> >V(l1+1,vector<int>(l2+1,0));
  for(int i=0;i<=l1;i++)
  {
      for(int j=0;j<=l2;j++)
      {
          if(i==0 || j==0)
          {V[i][j]=0; continue;}
            if(s[i-1]==t[j-1])
            {
                V[i][j]=V[i-1][j-1]+1;
            }
            else
            V[i][j]=max(V[i-1][j],V[i][j-1]);
      }
  }
  vector<char>ans;
  int i=l1,j=l2;
  while(i>0 && j>0)
  {
      if(s[i-1]==t[j-1])
      {
          ans.push_back(s[i-1]);
          i--;
          j--;
      }
      else if(V[i-1][j]>=V[i][j-1])
      {
          i--;
      }
      else j--;
  }
  reverse(ans.begin(),ans.end());
  for(int i=0;i<ans.size();i++)
  cout<<ans[i];
  
    
    return 0;
}

Measured memory_bytes: 35584
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<climits>//long long型の最大値(LLONG_MAX)など
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;
typedef long double ld;

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

int main() {
    string S;
    cin >> S;
    ll K;
    cin >> K;

    ll sizeS = S.size();
    ll lls = 1;

    sizeS = min(sizeS,K);
    rep(i,sizeS){
        if(S[i] != '1'){
            lls = S[i] - '0';
            break;
        }
    }

    cout << lls << endl;
    
}


Measured memory_bytes: 3560
x,y=map(int,input().split())

r=0

if x==3:
  r+=100000
elif x==2:
  r+=200000
elif x==1:
  r+=300000
  
if y==3:
  r+=100000
elif y==2:
  r+=200000
elif y==1:
  r+=300000
  
if x==1 and y==1:
  r+= 400000

print(r)
 

Measured memory_bytes: 38384
#include <bits/stdc++.h>
#define REP(i, n) for (long long i = 0; i < (long long)n; i++)
//#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using Vl = vector<ll>;
using vi = vector<int>;
using Graph = vector<vi>;
Graph ans;
int step = 0;
void add(int i, int j) {
  vi t = {i, j, i, j + 1};
  ans.push_back(t);
  step++;
}
void next(int i, int j) {
  vi t = {i, j, i + 1, j};
  ans.push_back(t);
  step++;
}

int main() {
  //  cin.tie(0);
  // ios::sync_with_stdio(false);
  // std::cout << std::fixed << std::setprecision(15); //"for float-base
  // problem"
  int H, W;
  Graph a;
  cin >> H >> W;

  REP(i, H) {
    vi tmp(W);
    REP(j, W) cin >> tmp.at(j);
    a.push_back(tmp);
  }
  REP(i, H) {
    REP(j, W) {
      if (a.at(i).at(j) % 2 == 0) continue;
      if (j == W - 1 && i < H - 1) {
        next(i, j);
        a.at(i + 1).at(j)++;
      } else if (j == W - 1 && i == H - 1)
        continue;
      else {
        add(i, j);
        a.at(i).at(j + 1)++;
      }
    }
  }

  cout << step << endl;
  for (auto x : ans) {
    printf("%d %d %d %d\n", x[0] + 1, x[1] + 1, x[2] + 1, x[3] + 1);
  }
  return 0;
}

Measured memory_bytes: 10032
integer(16) N,M,K
integer(16) waruno
integer(16) ans,tmp,i,j,com
read*,N,M,K
waruno=10**9+7
com=combination(N*M-2,K-2,waruno)
ans=0
do i=0,M-1
  do j=0,N-1
    tmp=mod((i+j)*(M-i)*(N-j)*com*merge(1,2,i*j==0),waruno)
    ans=mod(ans+tmp,waruno)
  end do
end do
print"(i0)",ans

contains

function combination(n,k,l)
implicit none
integer(16),intent(in)::n,k,l
integer(16) combination,i
integer(16),allocatable,dimension(:)::Kaijo
allocate(Kaijo(0:N))
Kaijo(0)=1
do i=1,N
  Kaijo(i)=mod(Kaijo(i-1)*i,l)
end do

combination=mod(Kaijo(N)*inv(Kaijo(K),l)*inv(Kaijo(N-K),l),l)

end function combination

function inv(K,L)
integer(16),intent(in)::k,l
integer(16) l2,y
integer(16) inv
inv=1
l2=l-2
y=k
do
  if(and(l2,1)==1)inv=mod(inv*y,l)
  y=mod(y*y,l)
  l2=rshift(l2,1)
  if(l2==0)exit
end do
end function inv
end


Measured memory_bytes: 3328
#include<atcoder/all>
using namespace atcoder;

#include<bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
#define rep(i,n) for(int i=0; i<(n); i++)

using MLL = modint998244353;
struct RQV { MLL v, z; };
RQV RQ_e() { return { 0,0 }; }
RQV RQ_op(RQV a, RQV b) { return { a.v + b.v, a.z + b.z }; }
struct RQRV { MLL b, c; };
RQV RQ_map(RQRV f, RQV a) { return { a.v * f.b + a.z * f.c, a.z }; }
RQRV RQ_con(RQRV a, RQRV b) { return { a.b * b.b, a.c + a.b * b.c }; }
RQRV RQ_id() { return { 1,0 }; }

int main() {
    int N, Q; scanf("%d%d", &N, &Q);
    vector<RQV> A(N); rep(i, N) { int a; scanf("%d", &a); A[i] = { a,1 }; }
    lazy_segtree<RQV, RQ_op, RQ_e, RQRV, RQ_map, RQ_con, RQ_id> G(A);

    rep(q, Q) {
        int c; scanf("%d", &c);
        if (c == 0) {
            int l, r, b, c; scanf("%d%d%d%d", &l, &r, &b, &c);
            G.apply(l, r, { b,c });
        }
        if (c == 1) {
            int l, r; scanf("%d%d", &l, &r);
            MLL ans = G.prod(l, r).v;
            printf("%u\n", ans.val());
        }
    }

    return 0;
}

Measured memory_bytes: 19284
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0134

"""
import sys
from sys import stdin

input = stdin.readline


def main(args):
    n = int(input())
    total = 0
    for _ in range(n):
        total += int(input())
    print('{}'.format(total//n))


if __name__ == '__main__':
    main(sys.argv[1:])

Measured memory_bytes: 7688
#include <math.h>

#include <algorithm>
#include <iostream>
#include <string>
#include <vector>

#define rep(inc, bgn, end) for (int inc = bgn; inc < end; ++inc)
#define repe(inc, bgn, end) for (int inc = bgn; inc <= end; ++inc)

using ll = long long;
using namespace std;

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

    swap(x, y);
    swap(x, z);

    cout << x << " " << y << " " << z << endl;

    return 0;
}


Measured memory_bytes: 3596
#include <iostream>
#include <cmath>
using namespace std;
 
int main(void)
{
    int n;
    cin >> n;
    
    string result = "No";
    for(int i = 0; i < 4; i++){
        if(n % 4 == 0){
            result = "Yes";
            break;
        }else if(n < 7){
            break;
        }else{
            n -= 7;
        }
    }
    
    cout << result << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i, n) for(int i = n; i >= 0; i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define SORT(v) sort((v).begin(), (v).end())
#define REV(v) sort((v).begin(), (v).end(), greater<int>())
#define INF 1000000007
typedef long long ll;
typedef pair<int, int> P;
int gcd(int a,int b){return b?gcd(b,a%b):a;};
int lcm(int a,int b){return a * b / gcd(a, b);};
int month[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){std::fill( (T*)array, (T*)(array+N), val );};


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

  int n;
  cin >> n;
  double a[n];
  rep(i, n) cin >> a[i];
  double s;
  rep(i, n) {
    s += 1 / a[i];
  }
  cout << fixed << 1 / s << endl;
  return 0;
}


Measured memory_bytes: 256
N,M=map(int,input().split())
a=list(map(int,input().split()))
SUM=sum(a)
ninnki=SUM/(4*M)
count=0

for i in a:
    if i>=ninnki:
        count+=1
        
if count>=M:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll n, m;
    cin>>n;
    ll t[n],sum=0;
    for(ll i=0;i<n;i++)
    {
        cin>>t[i];
        sum=sum+t[i];
    }
    cin>>m;
    ll p[m],x[n];
    for(ll i=0;i<m;i++)
    {
        cin>>p[i]>>x[i];
        cout<<(sum-t[p[i]-1]+x[i])<<"\n";
    }
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int sma, n, t, a, pro, res;
int main(void){
    // Your code here!
    cin >> n >> t >> sma;
    for (int i = 1; i < n; i++) {
        cin >> a;
        if (pro < a - sma) {
            pro = a - sma;
            res = 1;
        } else if (pro == a - sma) {
            res++;
        }
        sma = min(sma, a);
    }
    cout << res << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include<iomanip>
#include <map>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#define INF 1e9+7
#define rep(i,n) for(ll i=0;i<n;i++)
#define NO cout<<"NO"<<endl;
#define YES cout<< "YES"<<endl;
#define No cout<< "No"<<endl;
#define Yes cout<< "Yes"<<endl;
#define all(a) a.begin(),a.end()
#define P pair<int,int>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

//(int)'a'は97 (int)'A'は65 (int)'1'は49
//おまじない

const int maxn=2000;

ll dp[maxn+1][maxn+1]={0};
ll s[maxn+1];
ll t[maxn+1];
ll n,m;
ll mod = INF;

int main(){
    
    cin >> n>>m;
    
    rep(i,n)cin >> s[i+1];
    rep(i,m)cin >> t[i+1];
    
//    for(int i=0;i<=n;i++)dp[i][0]=1;
//    for(int j=0;j<=m;j++)dp[0][j]=1;
    
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            if(s[i]==t[j]){
                dp[i][j]=(dp[i][j-1]+dp[i-1][j]+1)%mod;
                if(dp[i][j]<0)dp[i][j]+=mod;
            }else{
                dp[i][j]=(dp[i][j-1]+dp[i-1][j]-dp[i-1][j-1])%mod;
                if(dp[i][j]<0)dp[i][j]+=mod;
            }
        }
    }
    
    cout << (dp[n][m]+1)%mod<<endl;
    
    return 0;
}


Measured memory_bytes: 31488
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
    string S;cin>>S;
    int flg=0;
    string m = S.substr(0,2);
    if(stoi(m)<=12&&stoi(m)>0)flg=1;
    m = S.substr(2,2);
    if(stoi(m)<=12&&stoi(m)>0){
        if(flg==1)cout<<"AMBIGUOUS"<<endl;
        else cout<<"YYMM"<<endl;
        return 0;
    }
    if(flg==1) cout<<"MMYY"<<endl;
    if(flg==0) cout<<"NA"<<endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <cmath>
using namespace std;
int dayCanW[200];
int dayM[200][200];
int days,clothes;
int clothD[200][3];
int temple[200];
int Redirector[201][101];
int bestCloth(int Nowday,int yesterday){
  int point=0;
  int pointM=0;
  if(Nowday<days ){
    if(Redirector[Nowday][yesterday]==-1){
    for(int i=0;i<clothes;i++){
      if(temple[Nowday]>=clothD[i][0] && temple[Nowday]<=clothD[i][1]){
	point=bestCloth(Nowday+1,clothD[i][2]);
	if (Nowday!=0){
	  point+=(int)abs((double)clothD[i][2]-yesterday);
	}
	if(point>pointM){
	  pointM=point;
	}
      }
    }

  Redirector[Nowday][yesterday]=pointM;
  }
    else{
    }
  }
  else{
    return 0;
  }

  return  Redirector[Nowday][yesterday];//;//自分の今までの派手さ絶対値の合計（今日ー昨日まで）

}
int main(void){
  for(int i=0;i<201;i++){
    for(int j=0;j<101;j++){
      Redirector[i][j]=-1;
    }
  }
  cin >> days;
  cin >> clothes;
  for(int i=0;i<days;i++){
    cin >> temple[i];
  }
  for(int i=0;i<clothes;i++){
    cin >> clothD[i][0];
    cin >> clothD[i][1];
    cin >> clothD[i][2];
  }
  for(int i=0;i<days;i++){
	dayCanW[i] = 0;
    for(int j=0;j<clothes;j++){
	dayM[i][j] = 0;
    }
  }
 
  cout << bestCloth(0,0) << endl;
  return 0 ;
}

Measured memory_bytes: 1416
#include<bits/stdc++.h>
using namespace std;
#define fi 			first
#define se 			second
#define pb 			push_back
#define pf 			push_front
#define mod 		1000000007
//#define mod 998244353
//#define mod 1000000009
#define Pi 			3.14159265359
#define eps 		1e-9
#define all(v) 		v.begin(),v.end()
#define sz(v) 		((int)(v).size())
#define each(x, v)  for (auto &x : v)
using pii    =    pair<int,int>;
using vi     =    vector<int>;
using vvi    =    vector<vi>;
using vii    =    vector<pii>;
using mi     =    map<int,int>;
using mii    =    map<pii,int>;
#define endl        '\n'
#define rep(i,a,b)  for(int i=a;i<b;i++)

using ll = long long;
ll pow(ll a, ll b)
{
    ll ans = 1;
    while(b)
    {
        if(b & 1)
            ans = (ans * a) % mod;
        a = (a * a) % mod;
        b >>= 1;
    }
    return ans;
}
void solve();

int main(){
    int T = 1;
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
//    cin>>T;
    while(T--){
        solve();
    }

    return 0;
}
unsigned  long long a[100050];
void solve(){
    unsigned long long ans = 1;
    int n;
    cin>>n;
    for (int i = 0; i < n; ++i) {
        cin>>a[i];
        if (a[i]==0){
            cout<<0<<endl;
            return;
        }
    }
    for (int j = 0; j < n; ++j) {
        if( log2(ans)+log2(a[j]) >=64 || ans * a[j] > 1000000000000000000)
        {
            cout<<-1<<endl;
            return;
        }
        else{
            ans*=a[j];
        }
    }
    cout<<ans<<endl;
}

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

int main() {
  int k;
  string n;
  cin >> k >>  n;
  if(n.size() <= k) cout << n << endl;
  else{
  for(int i = 0; i < k; i++){
    cout << n.at(i);
  }
    cout << "..." << endl;
  }
}

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

int main() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  rep(i,s.size()) {
    s[i] = (s[i]-'A' + n)%26 + 'A';
  }
  cout << s << endl;
  return 0;
}

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

//プロセスを表す構造体
typedef struct pp{
  char name[100];
  int t;
}P;

//Pの構造体をLEN+1個作って、その群れをQ列（データが格納されるキュー）と名付ける
P Q[LEN+1];
int head, tail, n;

void enqueue(P x){
    Q[tail] = x;
    tail = (tail+1) % LEN;
}

P dequeue(){
    P x = Q[head];
    head = (head+1) % LEN;
    return x;
}

int min(int a, int b){
    return a < b ? a : b;
}

int main(){
  //情報の入力
  int elaps = 0, c;
  int i, q;
  P u;
  scanf("%d %d", &n, &q);

  for ( i = 1; i <= n; i++){
    scanf("%s", Q[i].name);
    scanf("%d", &Q[i].t);
}

head = 1;
tail = n+1;

//計算
while(head != tail){
    u = dequeue(); //処理するプロセスの取り出し
    c = min(q, u.t);
    u.t -= c; //必要時間　と 処理時間の 小さい方を必要時間から引く
    elaps += c;
    if(u.t > 0) enqueue(u);
    else{
        printf("%s %d\n", u.name, elaps);
    }
}
  return 0;
}


Measured memory_bytes: 13304
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Atc_0028
{
    class Program
    {
        static void Main(string[] args)
        {
            string str = Console.ReadLine();

            int A = int.Parse(str.Split(' ')[0]);

            int B = int.Parse(str.Split(' ')[1]);

            if (A * B <= (A + B) && A - B <= (A + B))
            {
                Console.WriteLine(A + B);
            }
            else if ((A + B) <= A * B && (A - B) <= A * B)
            {
                Console.WriteLine(A * B);

            }
            else
            {
                Console.WriteLine(A - B);
            }
        }
    }
}


Measured memory_bytes: 27420
import java.util.Arrays;
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner stdIn=new Scanner(System.in);
		int N=stdIn.nextInt();
		int M=stdIn.nextInt();
		long A[][]=new long[N][2];
		int z=0,y=0;
		long man=0,cou=0;
		while(z<N){
			A[z][0]=stdIn.nextInt();
			A[z][1]=stdIn.nextInt();
			z++;
		}z=0;
		Arrays.sort(A, (a, b) -> Long.compare(a[0], b[0]));
		while(z<N){
			if(cou<M)
				if(M>=A[z][1]+cou){
					cou+=A[z][1];
					man+=A[z][0]*A[z][1];
				}
				else{
					man+=A[z][0]*(M-cou);
					break;
				}
			else
				break;
			z++;
		}
		System.out.println(man);
	}

}

Measured memory_bytes: 95180
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.stream.IntStream;
import java.util.StringTokenizer;
import java.io.IOException;
import java.util.InputMismatchException;
import java.io.BufferedReader;
import java.util.OptionalInt;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int[] a = in.nextIntArray(n);

            out.println(IntStream.of(a).sum() - IntStream.of(a).max().getAsInt() / 2);
        }

    }

    static class InputReader {
        private BufferedReader br;
        private StringTokenizer st;

        public InputReader(InputStream inputStream) {
            br = new BufferedReader(new InputStreamReader(inputStream));
            st = new StringTokenizer("");
        }

        public String nextString() {
            while (!st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine(), " ");
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(nextString());
        }

        public int[] nextIntArray(int n) {
            int[] res = new int[n];
            for (int i = 0; i < n; i++) {
                res[i] = nextInt();
            }
            return res;
        }

    }
}



Measured memory_bytes: 28244
#include <bits/stdc++.h>
using namespace std;
int main () {
  int N, M, K;
  cin >> N >> M >> K;
  long count, sub;
  for(int i = 0; i <= N; i++){
    count = 0;
    count += M * i;
    for(int j = 0; j <= M; j++){
      sub = count;
      sub -= i * j;
      sub += (N - i) * j;
      if(sub == K){
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
// type alias
typedef long long LL;
typedef pair<int,int> II;
typedef tuple<int,int,int> III;
typedef vector<int> VI;
typedef vector<string> VS;
typedef unordered_map<int,int> MAPII;
typedef unordered_set<int> SETI;
template<class T> using VV=vector<vector<T>>;
// minmax
template<class T> inline T SMIN(T& a, const T b) { return a=(a>b)?b:a; }
template<class T> inline T SMAX(T& a, const T b) { return a=(a<b)?b:a; }
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// collection
#define ALL(c) (c).begin(),(c).end()
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// stdout
#define println(args...) fprintf(stdout, ##args),putchar('\n');
// debug cerr
template<class Iter> void __kumaerrc(Iter begin, Iter end) { for(; begin!=end; ++begin) { cerr<<*begin<<','; } cerr<<endl; }
void __kumaerr(istream_iterator<string> it) { (void)it; cerr<<endl; }
template<typename T, typename... Args> void __kumaerr(istream_iterator<string> it, T a, Args... args) { cerr<<*it<<"="<<a<<", ",__kumaerr(++it, args...); }
template<typename S, typename T> std::ostream& operator<<(std::ostream& _os, const std::pair<S,T>& _p) { return _os<<"{"<<_p.first<<','<<_p.second<<"}"; }
#define __KUMATRACE__ true
#ifdef __KUMATRACE__
#define dump(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); __kumaerr(_it, args); }
#define dumpc(ar) { cerr<<#ar<<": "; FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }
#define dumpC(beg,end) { cerr<<"~"<<#end<<": "; __kumaerrc(beg,end); }
#else
#define dump(args...)
#define dumpc(ar)
#define dumpC(beg,end)
#endif

// $ cp-batch PowersOfTwo | diff PowersOfTwo.out -
// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG -fsanitize=address PowersOfTwo.cpp && ./a.out

/*

 7/29/2020

 22:08-22:52 pause

 8/4/2020

 9:01-

 */

const int MAX_N=1e6+1;
int A[MAX_N];
int N;

void solve() {
  int res=0;
  map<int,VI> ps;
  VI viz(N,0);
  sort(A,A+N);
  REP(i,N) ps[A[i]].push_back(i);
  for(int i=N-1; i>=0; --i) if(!viz[i]) {
    REP(k,31) if(A[i]<(1<<k)) {
      int p2=1<<k,rem=p2-A[i];
      //dump(i,A[i],p2,rem);
      assert(ps[A[i]].back()==i);
      ps[A[i]].pop_back();
      if(ps.count(rem)&&SZ(ps[rem])) {
        res++;
        viz[ps[rem].back()]=1;
        ps[rem].pop_back();
      }
      break;
    }
  }

  cout<<res<<endl;
}

void solve_wrong() {
  LL res=0;
  map<LL,int> cnt;
  REP(i,N) cnt[A[i]]++;
  REP(k,31) {
    LL p2=1LL<<k;
    REP(i,N) if(p2-A[i]>0) {
      LL x=p2-A[i];
      if(A[i]>x) continue;
      if(cnt.count(x)) {
        int ans=0;
        if(x==A[i]) ans=cnt[x]-1;
        else ans=cnt[x];
        dump(x,A[i],p2,ans);
        res+=ans;
      }
    }
  }
  cout<<res<<endl;
}

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

  cin>>N;
  REP(i,N) cin>>A[i];
  solve();

  return 0;
}


Measured memory_bytes: 26708
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner reader = new Scanner(System.in);
		int A = reader.nextInt();
		int B = reader.nextInt();
		int C = reader.nextInt();
		int safe = A + B;
		int danger = C;
		int ans = Math.min(safe + 1, danger);
		ans += B;

		reader.close();
		System.out.print(ans);
	}
}



Measured memory_bytes: 21844
#include<stdio.h>
#define MAX 9999999

int setchDepth(int u);
void print(int u);

struct Node{
  int p, l, r;
};

struct Node T[MAX];
int n, k=0, Depth[MAX];

void print(int u){
  int i, c;
  printf("node %d: ", u);
  printf("parent = %d, ", T[u].p);
  printf("depth = %d, ", Depth[u]);

  if ( T[u].p == -1 ) printf("root, ");
  else if ( T[u].l == -1 ) printf("leaf, ");
  else printf("internal node, ");

  printf("[");
  for(i = 0, c = T[u].l; c != -1; i++, c = T[c].r){
    if (i != 0) printf(", ");
    printf("%d", c);
  }
  printf("]\n");
}

int serchDepth(int u){
  int depth = 0;
  
  for(; T[u].p != -1;depth++){
    u = T[u].p;
  }
  
  return depth;
}


int main(){
  int i, j, k, sec, deg, ele;
  
  scanf("%d", &n);
  for ( i = 0; i < n; i++ ){
    T[i].p = -1;
    T[i].l = -1;
    T[i].r = -1;
  }
  
  for ( i = 0; i < n; i++ ){
    scanf("%d %d", &sec, &deg);
    for ( j = 0; j < deg; j++ ){
      scanf("%d", &ele);
      if ( j == 0 ) T[sec].l = ele;
      else T[k].r = ele;
      k = ele;
      T[ele].p = sec;
    }
  }

  for ( i = 0; i < n; i++ ){
    Depth[i] = serchDepth(i);
    
    if ( Depth[i] > k ) k = Depth[i];
  }

  for ( i = 0; i < n; i++ ) print(i);
  
  return 0;
}



Measured memory_bytes: 3284
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define l long
#define pb push_back
#define mp make_pair
#define mt make_tuple
int main() {
	// your code goes here
	//ifstream cin("input.txt");
	//ofstream cout("output.txt");
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
	int n,r; cin>>n>>r;
	if(n>=10) cout<<r;
	else
	{
	    r += 100*(10-n);
	    cout<<r;
	}
	
	return 0;
}


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

int main(){
	std::string O, E; std::cin >> O >> E;
	if (O.size() == E.size()) {
		for (int i = 0; i < O.size(); ++i)
			std::cout << O[i] << E[i];
		std::cout << std::endl;
	}
	else {
		for (int i = 0; i < E.size(); ++i)
			std::cout << O[i] << E[i];
		std::cout << O[O.size() - 1] << std::endl;
	}
	return 0;
}

Measured memory_bytes: 3556
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <functional>

using namespace std;
using ll = long long;
using P = pair<int,int>;
#define rep(i, n) for(int i = 0; i < n; i++)


int main() {
    int n, p[10] = {0,};
    cin >> n;

    rep(i,n) cin >> p[i];

    int total = 0;
    rep(i,n) {
        total +=p[i];
    }
    
    int max = 0;
    rep(i,n) {
        if(max < p[i]) max = p[i];
    }

    cout << total - max/2 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

	if (n < 1200)
	{
		cout << "ABC" << endl;
	}
	else if (n >= 1200 && n < 2800)
	{
		cout << "ARC" << endl;
	}
	else
	{
		cout << "AGC" << endl;
	}
}

Measured memory_bytes: 256
#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>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
using namespace std;
using ll = long long;
#define MAX_N 1010
#define MAX_M 100010
const long long mod = pow(10,9)+7;
#define vec vector<int>
#define vecll vector<ll>
#define vecllvec vector<vector<ll>>
#define vecb vector<bool>
#define vecBvec vector<vector<bool>>
#define vecst vector<string>
#define veche vector<char>
#define vecd vector<double>
#define vecvec vector<vector<int>>
#define vecDvec vector<vector<double>>
#define vecHvec vector<vector<char>>
#define all(x) (x).begin(),(x).end()
#define ent cout<<endl
#define printvec(vec) for(int aqw=0;aqw<vec.size();aqw++){cout<<vec[aqw]<<" ";}ent;
#define rep1(n) for(ll i = 0; i < (n); ++i)
#define rep2(i, n) for(ll i = 0; i < (n); ++i)
#define rep3(i, a, b) for(ll i = (a); i < (b); ++i)
#define rep4(i, a, b, c) for(ll i = (a); i < (b); i += (c))
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; }
#define INF 1e+9
#define print(x) cout<<x<<endl;
using P = pair<int, int>;
#define PLL pair<ll, ll>;
#define MAX_V 10010
#define PI 3.141592653589793
#define vecP vector<P>
// cout << setprecision(15) << std::fixed;


int main() {
	string s, t;
	cin >> s >> t;
	int a, b;
	cin >> a >> b;

	string st;
	cin >> st;
	if (st == s) {
		cout << a - 1 << " " << b;
	}
	else {
		cout << a << " " << b - 1;

	}
} 




Measured memory_bytes: 256
a = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
n = int(input())
print (a[n-1])

Measured memory_bytes: 2940
#include <iostream>
#include <algorithm>

using namespace std;

int main(){

	int N, a[10001];
	
	cin >> N;

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

	int count = 0;
	for (int i = 0; i < N; i++){
		while (a[i] % 2 == 0){
			a[i] /= 2;
			count++;
		}

	}

	cout << count << endl;

	return 0;
}


Measured memory_bytes: 256
N, T = list(map(int, input().split()))
A = list(map(int, input().split()))

minA = A[0]
benefit = 0
maxBenefit = 0
cost = 0

for i in range(N):
    if A[i] < minA:
        minA = A[i]
    else:
        benefit = A[i] - minA
        if benefit > maxBenefit:
            maxBenefit = benefit
            cost = 1
        elif benefit == maxBenefit:
            cost += 1

print(cost)

Measured memory_bytes: 15020
def main():
    S = input()
    T = input()
    N = len(S)
    M = len(T)
    for i in range(N-M+1)[::-1]:
        for s, t in zip(S[i:i+M], T):
            if s != t and s != "?":
                break
        else:
            return print(S[:i].replace("?", "a") + T + S[i+M:].replace("?", "a"))
    print("UNRESTORABLE")


if __name__ == '__main__':
    main()


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

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

  int t = N;
  int c = 0;
  while(t > 0)
  {
    c += t % 10;
    t /= 10;
  }
  
  if(N % c == 0){cout << "Yes" << endl;}
  else{cout << "No" << endl;}
}

Measured memory_bytes: 256
def solve(string):
    s, k = string.split()
    if len(s) == 1:
        return s
    k = int(k)
    for _s in s[:k]:
        if _s != "1":
            return _s
    else:
        return "1"


if __name__ == '__main__':
    print(solve('\n'.join([input(), input()])))


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

#define REP(i,n) for(int i=0;i<(int)(n);i++)

using namespace std;

int main() {
  while(1) {
    int n;
    cin>>n;
    if(!n)break;
    int cnt = 0;
    REP(i,n/2) {
      string s1,s2;
      cin>>s1>>s2;
      if (s1=="lu"&&s2=="ru") ++cnt;
      if (s1=="ru"&&s2=="lu") ++cnt;
      if (s1=="ld"&&s2=="rd") ++cnt;
      if (s1=="rd"&&s2=="ld") ++cnt;
    }
    if(n%2) {
      string s1;
      cin>>s1;
    }
    cout << cnt << endl;
  }
  return 0;
}

Measured memory_bytes: 1208
#include <bits/stdc++.h>
using namespace std;
#define x first
#define y second
#define dbg(x) cout << #x << '=' << x << '\n';
#define ll long long
#define pi pair<int,int>
#define pl pair<long long,long long>
#define lg length()
#define pb push_back
ifstream in("file.in");
ofstream out("file.out");
#define MAXN 100005
#define INF 1000000005
#define LINF 1000000000000000005

int n,a,b,x[200005],m;

int32_t main(){
    ios_base :: sync_with_stdio(0);
    cin >> n >> m;
    for(int i=1;i<=m;i++){
        cin >> a >> b;
        if(a==1) x[b]++;
        if(b==n) x[a]++;
        if(x[a]==2 || x[b]==2){
            cout << "POSSIBLE";
            return 0;
        }
    }
    cout << "IMPOSSIBLE";
}


Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<vector>
using lint=int64_t;
using namespace std;

int N;
vector<vector<pair<int,int>>> edge;
int col[100010];

void dfs(int cur,int prev,int ccol)
{
	col[cur]=ccol;

	for(auto&& i:edge[cur])
	{
		if(i.first==cur || i.first==prev)
			continue;
		if(col[i.first]!=-1)
			continue;

		if(i.second%2==0)
			dfs(i.first,cur,ccol);
		else
			dfs(i.first,cur,1-ccol);
	}
	return;
}

int main()
{
	cin >> N;

	edge.resize(N);
	for(int i=0;i<N-1;i++)
	{
		int u,v,w;
		cin >> u >> v >> w;
		u--;
		v--;
		edge[u].push_back(make_pair(v,w));
		edge[v].push_back(make_pair(u,w));
	}

	for(int i=0;i<N;i++)
		col[i]=-1;
	
	dfs(0,-1,0);

	for(int i=0;i<N;i++)
		cout << col[i] << endl;
	return 0;
}


Measured memory_bytes: 8960
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
ll int n,m,i,a,b;
priority_queue<ll int>pq;
int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	cin >> n >> m;
	for(i=0;i<n;i++){
		cin >> a;
		pq.push(a);
	}
	while(m){
		m--;
		a=pq.top();
		pq.pop();
		pq.push(a/2);
	}
	while(pq.size()){
		b+=pq.top();
		pq.pop();
	}
	cout<<b;
}

Measured memory_bytes: 1400
use std::io;
use std::io::prelude::*;
use std::str::FromStr;

fn check(size: i32, maxv: i32, vec_t: &Vec<i32>, vec_a: &Vec<i32>, vl: i32) -> bool {
    let mut vec_rt = vec_t.clone();
    vec_rt.reverse();
    let mut vec_ra = vec_a.clone();
    vec_ra.reverse();
    let mut iter_t = vec_rt.iter();
    let mut iter_a = vec_ra.iter();
    let mut curmin = 0;
    let mut curmax = maxv;
    for i in 0..size {
        let action = iter_a.next().unwrap();
        if *action == -1 {
            curmax = std::cmp::min(maxv, curmax + 1);
        } else if *action == 1 {
            curmin = std::cmp::max(0, curmin - 1);
        }
        let action = iter_t.next().unwrap();
        if *action == -1 {
            curmin += 1;
        } else if *action == 1 {
            curmax -= 1;
        }
        if curmin > curmax {
            return true;
        }
    }
    if curmin <= vl && vl <= curmax {
        return false;
    }
    true
}

fn main() {
    let stdin = io::stdin();
    let mut data = stdin.lock().lines();
    let (h, w, n) = {
        let line = data.next().unwrap().unwrap();
        let mut line_split = line.split(' ');
        (i32::from_str(line_split.next().unwrap()).unwrap(),
         i32::from_str(line_split.next().unwrap()).unwrap(),
         i32::from_str(line_split.next().unwrap()).unwrap())
    };
    let (r, c) = {
        let line = data.next().unwrap().unwrap();
        let mut line_split = line.split(' ');
        (i32::from_str(line_split.next().unwrap()).unwrap(),
         i32::from_str(line_split.next().unwrap()).unwrap())
    };
    let mut vec_t_lr = Vec::new();
    let mut vec_t_ud = Vec::new();
    {
        let line = data.next().unwrap().unwrap();
        let mut add_lr = 0;
        let mut add_ud = 0;
        for wd in line.chars() {
            if wd == 'L' {
                add_lr = -1;
            } else if wd == 'R' {
                add_lr = 1;
            }
            if wd == 'U' {
                add_ud = -1;
            } else if wd == 'D' {
                add_ud = 1;
            }
            vec_t_lr.push(add_lr);
            vec_t_ud.push(add_ud);
            add_lr = 0;
            add_ud = 0;
        }
    };
    let mut vec_a_lr = Vec::new();
    let mut vec_a_ud = Vec::new();
    {
        let line = data.next().unwrap().unwrap();
        let mut add_lr = 0;
        let mut add_ud = 0;
        for wd in line.chars() {
            if wd == 'L' {
                add_lr = -1;
            } else if wd == 'R' {
                add_lr = 1;
            }
            if wd == 'U' {
                add_ud = -1;
            } else if wd == 'D' {
                add_ud = 1;
            }
            vec_a_lr.push(add_lr);
            vec_a_ud.push(add_ud);
            add_lr = 0;
            add_ud = 0;
        }
    };
    if check(n, h - 1,&vec_t_ud, &vec_a_ud, r - 1) {
        println!("NO");
    } else if check(n, w - 1, &vec_t_lr, &vec_a_lr, c - 1) {
        println!("NO");
    } else {
        println!("YES");
    }
}

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

int main() {
  int a[3];
  cin >> a[0] >> a[1] >> a[2];
  int count5 = 0, count7 = 0;
  for (int i = 0; i < 3; i++) {
    if (a[i] == 5) count5++;
    if (a[i] == 7) count7++;
  }

  if (count5 == 2 && count7 == 1)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}

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

namespace AtCoder
{
    class Program
    {
        static void Main()
        {
            var X = long.Parse(ReadLine());

            var a = 100L;

            for (int i = 1; ; i++)
            {
                a = (long)(a * 1.01);
                if(a >= X)
                {
                    WriteLine(i);
                    return;
                }
            }
        }
    }
}


Measured memory_bytes: 27480
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define ll long long
#define f first 
#define s second
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);
#define MAX 1000005
#define pb push_back
int flag[1000006];
ll gcd(ll a, ll b)
{
  if(a == 0)
    return b;
  return gcd(b%a,a);
}
bool cmp(pair<ll,ll>&a,pair<ll,ll>&b)
{
  if(a.f!=b.f)
    return a.f > b.f;
  return a.s > b.s;
}
int p[11],a[11][11],m,k[11],r[11];
bool check(int p[])
{
  int count = 0;
  for (int i = 0; i < m; ++i)
  {
    count = 0;
    for (int j = 0; j < k[i]; ++j)
    {
      count += p[a[i][j]-1];
    }
    // cout << count << " ";
    if((count%2) != r[i])
      return false;
  }
  return true;
}
int main(){
  FIO;
  int n;
  cin >> n >> m;
  for (int i = 0; i < m; ++i)
  {
    cin >> k[i];
    for (int j = 0; j < k[i]; ++j)
    {
      cin >> a[i][j];
    }
  }
  for (int i = 0; i < m; ++i)
  {
    cin >> r[i];
  }
  int ans = 0;
  for(int i = 0;i < (1<<n); i++)
  {
    for (int j = 0; j < n; ++j)
    {
      if((i&(1<<j)) != 0)
        p[j] = 1;
      else
        p[j] = 0;
    }
    // for (int k = 0; k < n; ++k)
    // {
    //   cout << p[k] << " "; 
    // }
    // cout << "\n";
    if(check(p))
    {
      ans++;
      // for (int k = 0; k < n; ++k)
      // {
      //   cout << p[k] << " ";
      // }
      // cout << "\n";
    }
  }
  cout << ans << " ";
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,a,b;
  cin>>n>>a>>b;
  vector<int> c(n);
  for(int i=0;i<n;i++) cin>>c[i];
  if(n==1){
    cout<<abs(b-c[0]);
  }else{
    cout<<max(abs(b-c[n-1]),abs(c[n-1]-c[n-2]));
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
using ll = long long;
using P = pair<int,int>;
using PP = pair<int,pair<int,int>>;
using T = tuple<string,int,int>;
const ll INF = 1LL<<60;

bool func(int x){
  int temp = x;
  int y = 0;
  while(temp){
    y += temp%10;
    temp /= 10;
  }
  if(x % y == 0) return true;
  return false;
}

int main(){
  int n; cin >> n;
  if(func(n)) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


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

int main() {
	
	int d;
	cin >> d;
	cout << "Christmas";
	d = 25 - d;
	while(d){
		cout << " Eve";
		d--;
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
import sys 
from copy import deepcopy
from collections import deque
sys.setrecursionlimit(10**6)
def S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def LS(): return list(sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def R(x):
    r = round(x)
    if r+0.5 <= x:
        r += 1
    return r

def main():
    tmp = deque(LI())
    a,v = tmp.popleft(),tmp.popleft()
    tmp = deque(LI())
    b,w = tmp.popleft(),tmp.popleft()
    t = I()
    dist = abs(a-b)
    vect = v-w
    if vect<0:  
        print('NO')
    elif vect == 0 and dist==0:
        print('YES')
    else:
        if dist<=vect*t:
            print('YES')
        else:
            print('NO')
    return

if __name__=='__main__':
    main()

Measured memory_bytes: 9640
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < n; ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
#define FORV(i, v) for (auto i = v.begin(); i != v.end(); i++)
using namespace std;

typedef int64_t ll;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const int INF = 1001001001;
const long long INFL = (1LL<<60);
const double eps = (1e-9);

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

ll lcm(ll x, ll y) {
  return x / gcd(x, y) * y;   // (x * y) / gcd(x, y) だと x*y でオーバフローする可能性あり
}

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

  ll n, m;
  cin >> n >> m;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];
  sort(ALL(a));

  ll xx = 2;
  rep(i, n) {
    xx = lcm(xx, a[i]);
  }

  rep(i, n) {
    if ((xx / a[i]) % 2 == 0) {
      puts("0");
      return 0;
    }
  }

  ll ans = (2 * m) / xx;
  ans = (ans + 1) / 2;
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1024
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

#define U1 unsigned char
#define S1 char
#define	S4 int
#define S8 long
#define DU double

#define TRUE					      (1)
#define FALSE					      (0)

#define MAX_VECTOR_ELM                (1000)     /* ベクトルの最大要素数 */

/* qsort用比較関数 */
int comp(const void* vd_ap_var1, const void* vd_ap_var2)
{
	return *(S4*)vd_ap_var1 - *(S4*)vd_ap_var2;
}

DU du_d_calcManhattan(DU* du_ap_x, DU* du_ap_y, S4 s4_a_numElm)
{
	DU du_t_distance;
	S4 s4_t_index;		/* 距離計算用ループのインデックス */

	du_t_distance = (DU)0;

	for (s4_t_index = (S4)0; s4_t_index < s4_a_numElm; s4_t_index++)
	{
		du_t_distance += fabs(du_ap_x[s4_t_index] - du_ap_y[s4_t_index]);
	}

	return(du_t_distance);
}

DU du_d_calcEuclid(DU* du_ap_x, DU* du_ap_y, S4 s4_a_numElm)
{
	DU du_t_distance;
	DU du_t_delta;
	S4 s4_t_index;		/* 距離計算用ループのインデックス */
	
	du_t_distance = (DU)0;

	for (s4_t_index = (S4)0; s4_t_index < s4_a_numElm; s4_t_index++)
	{
		du_t_delta = fabs(du_ap_x[s4_t_index] - du_ap_y[s4_t_index]);
		du_t_distance += (du_t_delta * du_t_delta);
	}
	du_t_distance = sqrt(du_t_distance);

	return(du_t_distance);
}

DU du_d_calcP3(DU* du_ap_x, DU* du_ap_y, S4 s4_a_numElm)
{
	DU du_t_distance;
	DU du_t_delta;
	S4 s4_t_index;		/* 距離計算用ループのインデックス */

	du_t_distance = (DU)0;

	for (s4_t_index = (S4)0; s4_t_index < s4_a_numElm; s4_t_index++)
	{
		du_t_delta = fabs(du_ap_x[s4_t_index] - du_ap_y[s4_t_index]);
		du_t_distance += (du_t_delta * du_t_delta * du_t_delta);
	}
	/* 3乗根を計算 */
	du_t_distance = pow(du_t_distance, ((DU)1.0 / (DU)3.0));

	return(du_t_distance);
}

DU du_d_calcChebyshev(DU* du_ap_x, DU* du_ap_y, S4 s4_a_numElm)
{
	DU du_t_distance;
	DU du_t_delta;
	S4 s4_t_index;		/* 距離計算用ループのインデックス */

	du_t_distance = (DU)0;

	for (s4_t_index = (S4)0; s4_t_index < s4_a_numElm; s4_t_index++)
	{
		du_t_delta = fabs(du_ap_x[s4_t_index] - du_ap_y[s4_t_index]);
		if (du_t_delta > du_t_distance)
		{
			du_t_distance = du_t_delta;
		}
	}

	return(du_t_distance);
}

S4 main()
{
	DU du_tp_x[MAX_VECTOR_ELM];
	DU du_tp_y[MAX_VECTOR_ELM];

	S4 s4_t_indexX;
	S4 s4_t_indexY;
	S4 s4_t_numElm;

	//s4_t_numElm = (S4)MAX_VECTOR_ELM;
	(void)scanf("%d", &s4_t_numElm);

	/* xベクトルの入力 */
	for (s4_t_indexX = (S4)0; s4_t_indexX < s4_t_numElm; s4_t_indexX++)
	{
		(void)scanf("%lf", &du_tp_x[s4_t_indexX]);
	}

	/* yベクトルの入力 */
	for (s4_t_indexY = (S4)0; s4_t_indexY < s4_t_numElm; s4_t_indexY++)
	{
		(void)scanf("%lf", &du_tp_y[s4_t_indexY]);
	}

	printf("%f\n", du_d_calcManhattan(du_tp_x, du_tp_y, (S4)MAX_VECTOR_ELM));
	printf("%f\n", du_d_calcEuclid(du_tp_x, du_tp_y, (S4)MAX_VECTOR_ELM));
	printf("%f\n", du_d_calcP3(du_tp_x, du_tp_y, (S4)MAX_VECTOR_ELM));
	printf("%f\n", du_d_calcChebyshev(du_tp_x, du_tp_y, (S4)MAX_VECTOR_ELM));

	return((S4)0);
}




Measured memory_bytes: 2100