akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;
using namespace std::chrono;
        
typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
        
#define print(a) {for(auto xxxxx : (a)) cout << xxxxx << ' '; cout << '\n';}
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

ll next(){ll x; cin >> x; return x;}
const int maxn = 3e5 + 5, intf = 2e9;
const ll inf = 1e18, mod = 998244353;
const ld eps = 1e-9;



void solve(){
  string s; cin >> s;
  for (auto c : s){
    if (c == 'D' || c == '?')
      cout << 'D';
    else 
      cout << 'P';
  }
}

signed main(){
  ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cout.precision(20);
  
  for (int t = 1; t--;) {
    solve();
  }
        
  return 0;
}
/*

*/


Measured memory_bytes: 3732
#include<iostream>
#include<cmath>
#include<vector>
#include<set>
#include<algorithm>
#include<tuple>
#include<utility>
#include<cctype>
using namespace std;

#define REP(i,n) for(int i=0;i<n;++i)
#define RUP(a,b) ((a+b-1)/(b))
#define enter "\n"

typedef long long ll;


int abc100_a(){
    //入力
    int a,b;
    cin >> a >> b;
    
    //出力
    if(a>8 || b>8) cout << ":(" << enter;
    else cout << "Yay!" << enter;
    return 0;
}

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


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

main()
{
    int t=1;
    while(t--){
    ll n,k,ans;
    cin>>n>>k;
    ll x=n%k;
    ans=abs(x-k);
    ans=min(ans,abs(ans-k));
    cout<<min(ans,n)<<endl;
    }
}


Measured memory_bytes: 3632
function main (s) {
	var a=s.split(" ");
	for(var i=0;i<a.length;i++)a[i]=parseInt(a[i]);
	if(a[0]+a[1]>=a[2])console.log("Yes\n");
	else console.log("No\n");
}
 
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7372
def gcd(a, b):
    a, b = max([a, b]), min([a, b])
    if b == 0:
        return a
    return gcd(b, a % b)
N = int(input())
current_lcm = None
for _ in range(N):
    t = int(input())
    if current_lcm is None:
        current_lcm = t
        continue
    current_lcm = current_lcm * t // gcd(current_lcm, t)
print(current_lcm)

Measured memory_bytes: 3068
#include <algorithm>
#include <iostream>
#include <cassert>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cstdio>
#include <string>
#include <vector>
#include <cmath>
#include <ctime>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include<bitset>

using namespace std;

typedef long long ll;
typedef pair < int, int > pii;
const int inf = 1e9 + 7;

#define nd second
#define st first
#define mp make_pair
#define pb push_back

const int N = 1e6 + 6;
const int logN = 17;

int n, m, arr[123][123], h1[123], h2[123];
char c, cc[123][123];

int main() {
    scanf("%d %d", &n, &m);
    for(int i = 1; i <= n; i++)
        for(int j = 1; j <= m; j++) {
            scanf(" %c", &c);
            if(c == '.') arr[i][j] = 0;
            else arr[i][j] = 1;
            cc[i][j] = c;
        }
    for(int i = 1; i <= n; i++) {
        int t = 0;
        for(int j = 1; j <= m; j++)
            t += arr[i][j];
        if(t == 0) h1[i] = 1;
    }
    for(int i = 1; i <= m; i++) {
        int t = 0;
        for(int j = 1; j <= n; j++)
            t += arr[j][i];
        if(t == 0) h2[i] = 1;
    }
    for(int i = 1; i <= n; i++)
        if(!h1[i]) {
            for(int j = 1; j <= m; j++)
                if(!h2[j]) {
                    cout << cc[i][j];
                }
            cout << endl;
        }
}

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

int dp[1 << 12];
int prices[1000];
int box_flags[1000];

int main() {
  int N, M;
  std::cin >> N >> M;

  for (int i = 0; i < M; ++i) {
    int box_count;
    std::cin >> prices[i] >> box_count;
    for (int j = 0; j < box_count; ++j) {
      int box;
      std::cin >> box;
      box_flags[i] |= 1 << (box - 1);
    }
  }

  const int INVALID_PRICE = 1500000;
  dp[0] = 0;
  for (int i = 1; i < (1 << N); ++i) {
    dp[i] = INVALID_PRICE;
  }
  for (int i = 0; i < (1 << N); ++i) {
    for (int key = 0; key < M; ++key) {
      const int ij = i | box_flags[key];
      if (ij != i) {
        dp[ij] = std::min(dp[ij], dp[i] + prices[key]);
      }
    }
  }

  if (dp[(1 << N) - 1] == INVALID_PRICE) {
    std::cout << "-1";
  } else {
    std::cout << dp[(1 << N) - 1];
  }
  return 0;
}


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

bool correct(int other, int next, int turn){
  if(turn == 1){
    return other > next;
  }else{
    return other < next;
  }
    
}

int main(int argc, char *argv[]){
  string s;

  while(cin >> s){
    if(s == "#")break;
    int foot[2];//left, right
    bool turn = 0;// 0 is left, 1 is right
    int violate = 0;
    int Min = 1e8;
    //left start
    for (int t = 0; t < 2; t++) {
      foot[0] = 0;
      foot[1] = 2;
      turn = t;
      violate = 0;
      for (int i = 0; i < s.length(); i++) {
        //correct left foot motion
        char tmp = s[i];
        int next = atoi(&tmp) - 1;
        if(correct(foot[(turn + 1)&1]%3, next%3, turn)){
          violate++;
          turn = !turn;
        }
        //std::cout << violate << std::endl;
        foot[turn&1] = next;
        //std::cout << "left:" << next_foot[0] << std::endl;
        turn = !turn;
      }
      Min = min(Min, violate);
    }
    std::cout << Min << std::endl;
  }
  return 0;
}

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

int N;
int t[1000000];

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

  for(int i=1;i<N;i++){
    if(0!=t[i]&&t[i]!=2){
      cout<<0<<endl;
      return 0;
    }
  }
  
  long long ans=1;
  long long mod=1e9+7;
  for(int i=0;i<N/2;i++){
    ans=(ans*2LL)%mod;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 640
def main():
    n = int(input())
    a = [int(x) for x in input().split()]

    m = []
    l = [0] * (n+1)
    r = [0] * (n+1)
    for i in range(0, n):
        l[i+1] = gcd(a[i], l[i])
        r[(-i-1)-1] = gcd(a[-i-1], r[-i-1])

    for i in range(0, n):
        m.append(gcd(l[i], r[-n+i]))

    print(max(m))

def gcd(a, b):
    if a < b:
        a, b = b, a
    if b == 0:
        return a
    r = a % b
    return gcd(b, r)


if __name__ == "__main__":
    main()

Measured memory_bytes: 14056
#pragma region
#include <bits/stdc++.h>
using namespace std;
inline void ci(void){
  return;
}
template <typename First, typename... Rest>
void ci(First& first, Rest&... rest){
  cin >> first;
  ci(rest...);
  return;
}
inline void co(void){
  cout << endl;
  return;
}
template <typename First, typename... Rest>
void co(First first, Rest... rest){
  cout << first << "";
  co(rest...);
  return;
}
#define ll long long
#define ld long double
#define st string
#define wh while
#define ve vector
#define mp make_pair
#define tp tuple
#define mt make_tuple
#define pb push_back
#define pof pop_front
#define pob pop_back
#define pf push_front
#define fr front
#define ft first
#define sc second
#define tos to_string
#define len length
#define rt return
#define br break
#define con continue
#define lcm(n, m) (n * m / __gcd(n, m))
#define np next_permutation
#define repi(i, m, n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i, n) repi(i, 0, n)
#define revi(i, m, n) for(int i=(int)(m) - 1;i>=(int)(n);i--)
#define rev(i, m) revi(i, m, 0)
#define sz(v) ((int)(v).size()) 
#define each(i, n) for(auto&& i: n)
#define all(n) n.begin(), n.end()
#define allr(n) n.rbegin(), n.rend()
#define sp(n) cout << fixed << setprecision(n)
#define pi 3.14159265358979323846
#define inf 1000000007
#pragma endregion
// sqrt ルート, int 2*10^9, gcd　最大公約数
// __builtin_popcount bitの個数

ve<int> dx = {0, 0, 1, -1}, dy = {1, -1, 0, 0};

int main() {
  st s;
  ci(s);
  rep(i, 3){
    cout << s.at(i);
  }
  cout << endl;
}


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

using ll = long long;
const ll amari = 1e9+7;
#define ben(a) a.begin(),a.end()
#define pb(a,b) a.push_back(b)

int main(){
	int a;
	cin >> a;
	if(a < 1200)cout << "ABC" << endl;
	else cout << "ARC" << endl;
	return 0; 
}

Measured memory_bytes: 256
N = gets.to_i
x, y, h = N.times.map{gets.split.map(&:to_i)}.transpose
loops = 1
for i in 0..100
  for j in 0..100
    wr = 0
    id = 0
    for k in 0..(N-1)
      if h[k] != 0
        id = k
        break
      end
    end
    hei = (x[id] - i).abs + (y[id] - j).abs + h[id]
    for k in 0..(N-1)
      if k != id
        if h[k] == 0
          if hei - (x[k] - i).abs - (y[k] - j).abs > 0
            wr += 1
            break
          end
        else
          if (x[k] - i).abs + (y[k] - j).abs + h[k] != hei
            wr += 1
            break
          end
        end
      end
    end
    if wr == 0
      puts "#{i} #{j} #{hei}"
      loops = 0
      break
    end
  end
  if loops == 0
    break
  end
end

Measured memory_bytes: 3836
#include <iostream>

int gcd(int x, int y){
  if(y > x) std::swap(x, y);
  int r = x % y;
  while(r != 0){
    x = y;
    y = r;
    r = x % y;
  }
  return y;
}

int main(){
  int n;
  std::cin >> n;
  unsigned long long ans = 0;
  
  for(int i=1; i<=n; i++){
  	for(int j=1; j<=n; j++){
      for(int k=1; k<=n; k++){
       	 ans += gcd(gcd(i, j), k);
      }
    }
  }
  
  std::cout << ans << std::endl;
  
  return 0;
}

Measured memory_bytes: 3620
function split(text, delimiter)
  if text.find(text, delimiter) == nil then
    return { text }
  end 

  local splited_texts = {}
  local last_position

  for splited_text, position in text:gmatch("(.-)"..delimiter.."()") do
    table.insert(splited_texts, splited_text)
    last_position = position
  end 
  table.insert(splited_texts, string.sub(text, last_position))
  return splited_texts
end

local a = io.read()
local list = split(a, " ")
local have_money = tonumber(list[1]) + tonumber(list[2])
local price = tonumber(list[3])

if (have_money-price) >= 0 then
    print("Yes")
else
    print("No")
end

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<iomanip>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
#define LINF (long long)4e18

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;



int main(){
  ll N,A,B; cin >> N >> A >> B;
  if(A > B){
     cout << 0 << endl;
     return 0;
  } 
  if(B == A && N == 1){
     cout << 1 << endl;
     return 0;
  }
  if(N == 1){
     cout << 0 << endl;
     return 0;
  }
  ll m = A * (N-1) + B;
  ll M = B * (N-1) + A;
  ll ans = M - m + 1;
  cout << ans << endl;



}



Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;
typedef long long int ll;

int main(){
    vector<ll> v;
    int n, q;
    ll t, r;
    int c, b, e;
    scanf("%d", &n);
    for (int i = 0; i < n; i++){
        scanf("%lld", &t);
        v.push_back(t);
    }
    scanf("%d", &q);
    auto itr = v.begin();
    for (int i = 0; i < q; i++){
        scanf("%d %d %d", &c, &b, &e);
        if(c == 0){ // min
            r = *min_element(itr+b, itr+e);
        }else{  // max
            r = *max_element(itr+b, itr+e);
        }
        printf("%lld\n", r);
    }
}


Measured memory_bytes: 2740
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mk make_pair
using namespace std;

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

       int t=1;
       //cin>>t;
       while(t--)
       {
               string s,t;
               cin>>s>>t;
               int flag=0;
               for(int i=0;i<s.size();++i)
               {
                    if(s[i]!=t[i])
                    {
                         flag=1;
                         break;
                    }
               }
               if(flag==1)
                    cout<<"No";
               else
                    cout<<"Yes";
       }
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define _abs(x)((x) < 0 ? (x) * -1 : (x))
#define _max(x, y)(max(0, max((x), (y))))
#define _min(x, y)(max(0, min((x), (y))))

static const ll MOD = 1e9 + 7;

int main()
{
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    //freopen("debug.txt", "w", stderr);

    cin.tie(0);
    ios::sync_with_stdio(false);

    string n;

    cin >> n;

    if (n[0] == '9' || n[1] == '9') cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}


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

int main(){
	int x1,x2,y1,y2;
	cin>>x1>>y1>>x2>>y2;

	cout<<x2+(y1-y2)<<" "<<y2+(x2-x1)<<" "<<x1+(y1-y2)<<" "<<y1+(x2-x1)<<endl;
}

Measured memory_bytes: 256
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){
            System.out.println("a < b");
        }else if(a==b){
            System.out.println("a == b");
        }else{
            System.out.println("a > b");
        }
    }
}



Measured memory_bytes: 26220
#include <algorithm>
#include <iostream>
#include <vector>

#ifdef DBG
    #define D(y) y
#else
    #define D(y)
#endif

using namespace std;

const long long inf = 1023456789;
const long long INF = inf * inf;

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

    int N;
    long long K;
    cin >> N >> K;

    vector<long long> positives, negatives;
    for (int i = 0; i < N; ++i) {
        int x;
        cin >> x;
        if (x < 0) {
            negatives.push_back(-x);
        } else {
            positives.push_back(x);
        }
    }
    sort(negatives.begin(), negatives.end());
    sort(positives.begin(), positives.end());

    long long non_positive_products = positives.size() * (long long) negatives.size();

    auto count_less_or_eq_helper = [](
        long long threshold,
        const vector<long long> v1,
        const vector<long long> v2,
        bool subtract_dups
    ) {
        long long count = 0;

        int v2_idx = v2.size() - 1;
        for (int v1_idx = 0; v1_idx < v1.size(); ++v1_idx) {
            while (v2_idx >= 0 && v1[v1_idx] * v2[v2_idx] > threshold) {
                v2_idx--;
            }

            count += v2_idx + 1;
        }

        if (subtract_dups) {
            for (int v1_idx = 0; v1_idx < v1.size(); ++v1_idx) {
                if (subtract_dups && v1[v1_idx] * v1[v1_idx] <= threshold) {
                    count--;
                }
            }

            count /= 2;
        }

        return count;
    };

    auto count_greater_or_eq_helper = [&](
        long long threshold,
        const vector<long long> v1,
        const vector<long long> v2
    ) {
        long long less_or_eq_count = count_less_or_eq_helper(threshold - 1, v1, v2, false);
        long long overall_count = v1.size() * (long long) v2.size() - less_or_eq_count;
        return overall_count;
    };

    auto count_less_or_eq = [&](long long threshold) {
        if (threshold >= 0) {
            long long count = 0;
            count += non_positive_products;
            count += count_less_or_eq_helper(threshold, negatives, negatives, true);
            count += count_less_or_eq_helper(threshold, positives, positives, true);
            return count;
        } else {
            long long count = count_greater_or_eq_helper(-threshold, positives, negatives);
            return count;
        }
    };

    // find first number such that # products <= is >= K
    long long low = -INF, high = INF;
    while (low < high) {
        long long mid = low + (high - low) / 2;

        if (count_less_or_eq(mid) < K) {
            low = mid + 1;
        } else {
            high = mid;
        }
    }

    cout << high << endl;

    return 0;
}


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

using namespace std;

int cal(int x) {
  int cnt = 0;
  while (x % 100 == 0) {
    x /= 100;
    cnt++;
  }

  return cnt;
}

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

  int val = 0, cnt = 0;
  while (cnt < N) {
    val++;
    if (cal(val) == D) cnt++;
  }

  cout << val;
}

Measured memory_bytes: 256
n = int(input())
v = [int(x) for x in input().split()]

dp = [float("inf") for i in range(n+10)]
dp[0] = 0
dp[1] = abs(v[1]-v[0])
for i in range(n-2):
    dp[i+2] = min(dp[i+1]+abs(v[i+1]-v[i+2]),dp[i]+abs(v[i]-v[i+2]))

print(dp[n-1])


Measured memory_bytes: 13928
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll inf=1000000000;
double pi=2*acos(0);
#define rep(i,m,n) for(ll i=m;i<n;i++)
#define rrep(i,n,m) for(ll i=n;i>=m;i--)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
ll lmax(ll a,ll b){
    if(a<b)return b;
    else return a;
}
ll lmin(ll a,ll b){
    if(a<b)return a;
    else return b;
}
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll Pow(ll n,ll k){
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}
ll beki(ll n,ll k,ll md){
  ll ret=1;
  ll now=n;
  while(k>0){
    if(k%2==1){
      ret*=now;
      ret%=md;
    }
    now*=now;
    now%=md;
    k/=2;
  }
  return ret;
}
ll gyaku(ll n,ll md){
  return beki(n,md-2,md);
}

int main(){
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int h,w;cin>>h>>w;
    int a[h][w],b[h][w],c[h][w];
    rep(i,0,h){
        rep(j,0,w)cin>>a[i][j];
    }
    rep(i,0,h){
        rep(j,0,w){
            cin>>b[i][j];
            c[i][j]=a[i][j]-b[i][j];
        }
    }
    bool dp[h][w][26000];
    memset(dp,false,sizeof dp);
    dp[0][0][c[0][0]+13000]=true;
    dp[0][0][-c[0][0]+13000]=true;
    rep(i,0,h){
        rep(j,0,w){
            rep(k,0,26000){
                if(dp[i][j][k]==false)continue;
                //cout<<i<<" "<<j<<" "<<k<<endl;
                if(i<h-1){
                    if(k+c[i+1][j]<26000&&k+c[i+1][j]>=0){
                        dp[i+1][j][k+c[i+1][j]]=true;
                        dp[i+1][j][k-c[i+1][j]]=true;
                    }
                }
                if(j<w-1){
                    if(k+c[i][j+1]<26000&&k+c[i][j+1]>=0){
                        dp[i][j+1][k+c[i][j+1]]=true;
                        dp[i][j+1][k-c[i][j+1]]=true;
                    }
                }
            }
        }
    }
    //rep(i,12995,13005)cout<<dp[1][0][i]<<" ";
    
    int ans=1000000000;
    rep(i,0,26000){
        if(dp[h-1][w-1][i])ans=min(ans,abs((int)i-13000));
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 162816
#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;
    vector<string>s;
    rep(i,n){
        string t;cin>>t;
        s.push_back(t);
    }
    sort(s.begin(),s.end());
    
    int tmp = 1;
    int m = 1;
    rep(i,n-1){
        if(s[i+1]==s[i])++tmp;
        else{
            m=max(m,tmp);
            tmp=1;
        }
    }
    m=max(m,tmp);
    tmp = 1;

    rep(i,n-1){
        if(s[i+1]==s[i])++tmp;
        else{
            if(tmp==m)cout<<s[i]<<endl;
            tmp=1;
        }
    }
    if(tmp==m)cout<<s[n-1]<<endl;
 	return 0;
}

Measured memory_bytes: 11644
#include<iostream>
#include<algorithm>
#include<string>
#include<math.h>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
#include<functional>
#include<map>
#include<set>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)

map<string, int> mp;

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

Measured memory_bytes: 256
object Main extends App {
  var input = scala.io.StdIn.readLine()
  val array = input.split(" ").map(_.toInt)

  if((array(0) <= array(2) && array(1) >= array(2)) || (array(1) <= array(2) && array(0) >= array(2))) {
    print("Yes")
  } else {
    print("No")
  }
}

Measured memory_bytes: 25416
#include <stdio.h>
int a[100000];
int main(void){
    int n,i,max=0;
    int h[100000];
    scanf("%d",&n);
    for(i=0;i<n;i++) scanf("%d",&h[i]);
    for(i=1;i<n;i++){
        if(h[i]<=h[i-1]) a[i]=a[i-1]+1;
        else{
            a[i]=0;
            if(max<a[i-1]) max = a[i-1];
        }
    }
    if(max<a[i-1]) max = a[i-1];
    printf("%d",max);
    return 0;
}

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

#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
using ll = long long;


int main() {
    int n, k; cin >> n >> k;
    if(k <= (n + 1) / 2) cout << "YES" << endl;
    else cout << "NO" << endl;

    return 0;
}


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


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

    bool h1[200010], h2[200010];
    memset(h1, 0, sizeof(h1));
    memset(h2, 0, sizeof(h2));

    rep(i,m){
        int a, b;
        cin >> a >> b;
        if (a == 1) h1[b] = true;
        else if (b == n) h2[a] = true;
    }
    bool flag = false;
    rep(i,n){
        if(h1[i] && h2[i]) flag = true;
    }
    if (flag) cout << "POSSIBLE" << endl;
    else cout << "IMPOSSIBLE" << endl;
    return 0;
}

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

using namespace std;

int main(int argc, char const *argv[])
{
	ios::sync_with_stdio(0);
	cin.tie(0);

	int n;
	cin >> n;
	if (n>=30){
    	cout << "Yes";
    }
  	else {
    	cout << "No";
    }
	return 0;
}

Measured memory_bytes: 3632
from bisect import bisect_left
from bisect import bisect_right

n = int( input() )
a = sorted( list( map( int, input().split() ) ) )

ai = a[-1]
a.pop(-1)
aj = 0
middle = ai//2 if ai % 2 == 0 else ai//2+1
if len(a) == 1:
    aj = a[0]
elif a[bisect_left(a, middle)] == middle:
    aj = middle
elif abs(a[bisect_left(a, middle)]-middle) < abs(a[bisect_right(a, middle)-1]-middle):
    aj = a[bisect_left(a, middle)]
else:
    aj = a[bisect_right(a, middle)-1]

print(ai,aj)

Measured memory_bytes: 62704
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pr;
typedef vector<ll> vc;
#define rep(i,a,b) for(ll i=a;i<=b;i++)
#define repr(i,a,b) for(ll i=a;i>=b;i--)
#define reps(i,v) for(ll i=0;i<v.size();i++)

int main() {
    // your code goes here
    ll n,x,y,ans[2005]={0};
    cin >> n >> x >> y;
    rep(i,1,n-1){
        rep(j,i+1,n){
            if(j<=x){
                ans[j-i]++;
            } else if(i>=y){
                ans[j-i]++;
            } else if(i<=x&&y<=j) {
                ans[(x-i)+1+(j-y)]++;
            } else if(x<=i&&j<=y) {
                ll m=min(j-i,(i-x)+1+(y-j));
                ans[m]++;
            } else if(i<=x){
                ll m=min(j-i,(x-i)+1+(y-j));
                ans[m]++;
            } else {
                ll m=min(j-i,(i-x)+1+(j-y));
                ans[m]++;
            }
        }
    }
    rep(i,1,n-1) cout << ans[i] << endl;
    return 0;
}

Measured memory_bytes: 256
package main

import (
    "fmt"
    "math"
)

func main() {
    var N int
    fmt.Scan(&N)
    ans := -1
    for i := 1; i <= int(math.Sqrt(float64(N))); i++ {
        d := N / i
        m := N % i
        if m == 0 {
            ans = d + i - 2
        }
    }
    fmt.Println(ans)
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long

using namespace std;

int main() {
    //freopen("a.in", "r", stdin);
    //freopen("a.out", "w", stdout);

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

    string a, b;
    cin >> a >> b;
    a = b + a;
    cout << a;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
#define double long double
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef vector<pii> VP;
typedef vector<string> VS;
typedef priority_queue<int> PQ;
template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
#define eps 1e-12 
//priority_queue<int,vector<int>, greater<int> > q2;




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

	int N, R, L; cin >> N >> R >> L;
	set<pii>S;
	REP(i, N) S.emplace(pii(0, -i));
	VI score(N, 0);
	VI ans(N, 0);
	int bf = 0;
	REP(i, R) {
		int id, now, p; cin >> id >> now >> p;
		id--;
		auto it = S.rbegin();
		//it--;
		//cout << it->second << endl;
		ans[-it->second] += (now - bf);
		S.erase(pii(score[id], -id));
		score[id] += p;
		S.emplace(score[id], -id);
		bf = now;
	}
	
	auto it = S.rbegin();
	//it--;
	ans[-it->second] += (L - bf);
	
	int res = -1;
	int tmp = 0;
	REP(i, N) {
		if (ans[i] > tmp) {
			tmp = ans[i];
			res = i;
		}
	}
	cout << res + 1 << endl;
	return 0;
}




Measured memory_bytes: 10668
//https://atcoder.jp/contests/abc116/tasks/abc116_a
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
#ifdef BTK
#define DEBUG if(1)
#else
#define CIN_ONLY if(1)
struct cww {cww() {CIN_ONLY{ios::sync_with_stdio(false); cin.tie(0);}}}star;
#define DEBUG if(0)
#endif
#define ALL(v) (v).begin(),(v).end()
#define REC(ret, ...) std::function<ret (__VA_ARGS__)>
template <typename T>inline bool chmin(T &l, T r){bool a = l>r; if (a)l = r; return a;}
template <typename T>inline bool chmax(T &l, T r){bool a = l<r; if (a)l = r; return a;}
template <typename T>istream& operator>>(istream &is, vector<T> &v){for (auto &it : v)is >> it;return is;}
class reverse_range {private:struct I {int x;int operator*() {return x-1;}bool operator!=(I& lhs) {return x>lhs.x;}void operator++() {--x;}};I i, n;public:reverse_range(int n) :i({ 0 }), n({ n }){}reverse_range(int i, int n) :i({ i }), n({ n }){}I& begin() {return n;}I& end() {return i;}};
class range {private: struct I { int x; int operator*() { return x; }bool operator!=(I& lhs) { return x<lhs.x; }void operator++() { ++x; } }; I i, n;public:range(int n) :i({ 0 }), n({ n }) {}range(int i, int n) :i({ i }), n({ n }) {}I& begin() { return i; }I& end() { return n; }reverse_range operator!(){return reverse_range(*i,*n);}};


int main(){
    int a,b;
    cin>>a>>b;
    cout<<(a*b)/2<<endl;
    return 0;
}

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

using namespace std;

int main()
{
  int N, M;
  cin >> N >> M;
  vector<vector<int>> v(N);
  
  for (int i = 0; i < M; i++) {
    int a, b;
    cin >> a >> b;
    a--; b--;
    v[a].push_back(b);
    v[b].push_back(a);
  }
  
  for (int i = 0; i < N; i++) {
    cout << v[i].size() << endl;
  }
  
  return 0;
}
  


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

int main()
{
	ll N, W;
	cin >> N >> W;
	vector<pair<ll, ll>> vw(N);
	for (int i = 0; i < N; i++) {
		cin >> vw[i].first >> vw[i].second;
	}
	int x = N / 2, y = N - N / 2;
	vector<pair<ll, ll>> A(1 << x), B(1 << y);
	for (int i = 0; i < (1 << x); i++) {
		for (int j = 0; j < x; j++) {
			if (i & (1 << j)) {
				A[i].second += vw[j].first;
				A[i].first += vw[j].second;
			}
		}
	}
	sort(A.begin(), A.end());
	for (int i = 1; i < (1 << x); i++) {
		A[i].second = max(A[i].second, A[i - 1].second);
	}
	for (int i = 0; i < (1 << y); i++) {
		for (int j = 0; j < y; j++) {
			if (i & (1 << j)) {
				B[i].second += vw[x + j].first;
				B[i].first += vw[x + j].second;
			}
		}
	}
	ll res = 0;
	for (auto b : B) {
		auto elb = upper_bound(A.begin(), A.end(), pair<ll, ll>(W - b.first, 1000000000000000000ll));
		if(elb != A.begin())
			res = max(res, b.second + (elb - 1)->second);
	}
	cout << res << endl;
	return 0;
}

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

int main() {
  string s;
  cin >> s;
  if ((s.at(0) =='7') || (s.at(1) == '7') || (s.at(2) == '7'))
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Measured memory_bytes: 3628
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func main() {
	// 標準入力読み取り
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Scan()
	scanner.Scan()
	line := scanner.Text()

	words := strings.Split(line, " ")
	results := "APPROVED"

	for _, word := range words {
		a, _ := strconv.Atoi(word)
		if a%2 == 0 && a%3 != 0 && a%5 != 0 {
			results = "DENIED"
			break
		}
	}

	fmt.Println(results)

}


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

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

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;


//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}


int main(){
  int N,K;
  cin >> N >> K;
  vector<PLL> sushi(N);
  VLL kindsMax;
  rep(i,N){
    int t,d;
    cin >> t >> d;
    t--; // kinds is 0 origin
    sushi[i]= make_pair(t,d);
  }

  sort(all(sushi));
  map<int,int> kinds;
  int cnt = -1;
  rep(i,N){
    kinds[sushi[i].first]++;
    if(kinds[sushi[i].first] == 1){
      cnt++;
      kindsMax.push_back(sushi[i].second);
    }else{
      kindsMax[cnt] = max(kindsMax[cnt],sushi[i].second);
    }
  }

  sort(sushi.rbegin(),sushi.rend());
  VLL sumSushi;
  rep(i,N){
    if(i == 0) continue;
    if(sushi[i].first != sushi[i-1].first) continue;
    sumSushi.push_back(sushi[i].second);
  }

  sort(sumSushi.rbegin(), sumSushi.rend());
  sort(kindsMax.rbegin(),kindsMax.rend());

  // sumSuhsi累積和構築
  rep(i,sumSushi.size()-1){
    sumSushi[i+1] += sumSushi[i];
  }

  // kindsMax累積和構築
  rep(i,kindsMax.size()-1){
    kindsMax[i+1] += kindsMax[i];
  }

  ll ans = 0;
  for(ll i = 1 ; i <= K; i++){
    //cout << ans << endl;
    if(kindsMax.size() < i) continue;
    if(sumSushi.size() <= K-i-1) {
      ans = max(kindsMax[i-1]  + i * i , ans);
    }else{
      ans = max(kindsMax[i-1] + sumSushi[K-i-1] + i * i , ans);
    }
  }

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


Measured memory_bytes: 7284
a=list(map(int,input().split()))
b=[]
c=10000
for i in range(a[0]):
    b.append(list(map(int,input().split())))
for j in range(a[0]):
    if b[j][1]<=a[1] and c>b[j][0]:
        c=b[j][0]
if c!=10000:
    print(c)
else:
    print("TLE")

Measured memory_bytes: 3060
import java.io.*;

class Main{
	public static void main(String[] args) throws IOException{
		BufferedReader r = new BufferedReader(new InputStreamReader(System.in));
		String s=r.readLine();
		try {
			for(int i=s.length()-1;i>=0;i--){
				System.out.print(s.charAt(i));
			}
			System.out.println("");
		} catch (Exception err) {
			System.exit(0);
		}
	}
}

Measured memory_bytes: 9368
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

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

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

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), "={:?} "),*), $($a),*);
    }
}

#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
    input!{
      n: usize,
      aa: [i64; n],
    }
    let mut aa = aa;
    aa.sort();

    let mut s = vec![0; n];
    let mut j = aa.len() - 1;
    let mut k = 0;
    for i in 1..n {
        if i % 2 == 1 {
            s[i] = aa[j];
            j -= 1;
        } else {
            s[i] = aa[k];
            k += 1;
        }
    }
    s[0] = aa[k];
    let mut ans1 = 0;
    for i in 0..n-1 {
        ans1 += (s[i+1] - s[i]).abs();
    }


    let mut j = aa.len() - 1;
    let mut k = 0;
    for i in 1..n {
        if i % 2 == 1 {
            s[i] = aa[k];
            k += 1;
        } else {
            s[i] = aa[j];
            j -= 1;
        }
    }
    s[0] = aa[k];
    let mut ans2 = 0;
    for i in 0..n-1 {
        ans2 += (s[i+1] - s[i]).abs();
    }

    println!("{}", max(ans1, ans2));
}


Measured memory_bytes: 6396
N = int(input())

alphabet = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i',
            'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r',
            's', 't', 'u', 'v', 'w', 'x', 'y', 'z']

name = ''
while N != 0:
    
    name += alphabet[(N-1) % 26]
    N = (N-1) // 26
print(name[::-1])

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

bool comp(const P &a, const P &b) {
  return a.second > b.second;
}

int main(){
  int n, k;
  cin >> n >> k;
  vector<P> sushi;
  rep(i,n) {
    int t, d;
    cin >> t >> d;
    sushi.push_back({t,d});
  }
  sort(sushi.begin(), sushi.end(), comp);
  map<int,int> check;
  ll res = 0;
  rep(i,k) {
    check[sushi[i].first]++;
    res += sushi[i].second;
  }
  priority_queue<ll> que;
  ll now = check.size();
  /*まだ選んでないネタの最大値 */
  for (int i = k; i < n; i++) {
    if (check.find(sushi[i].first) == check.end()) que.push(sushi[i].second),check[sushi[i].first]++;
  }
  ll cur = res;
  res += now*now;
  for (int i = k-1; i >= 0; i--) {
    if (que.empty()) continue;
    P a = sushi[i];
    ll b = que.top();
    if (check[a.first] == 1) continue;
    cur -= a.second;
    now++;
    check[a.first]--;
    cur += b;
    que.pop();
    res = max(cur + now*now ,res);
  }
  cout << res << endl;
  return 0;
} 

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

using namespace std; 
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>; 

#define INF 100000000
#define MOD 10007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()

struct UnionFindTree{
  vector<int>par,rank;

  void init(int n){
    par.resize(n);
    rank.resize(n);
    for(int i=0;i<n;i++){
      par[i]=i;
      rank[i]=-1;
    }
  }

  int find(int x){
    if(par[x]==x)return x;
    else return par[x]=find(par[x]);
  }

  void unite(int x,int y){
    x=find(x);
    y=find(y);
    if(x==y)return;
    if(rank[x]>rank[y]){
      par[x]=y;
      if(rank[x]<0)rank[x]*=-1;
      rank[y]-=abs(rank[x]);
    }
    else{
      par[y]=x;
      rank[x]-=abs(rank[y]);
      if(rank[y]<0)rank[y]*=-1;
      if(rank[x]==rank[y])rank[x]--;
    }
  }

  bool same(int x,int y){
    return find(x)==find(y);
  }

};

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

  int N,M;
  cin>>N>>M;
  vector<ll>A(M),B(M);
  for(int i=0;i<M;i++)cin>>A[i]>>B[i];
  UnionFindTree uf;
  uf.init(N+1);

  ll ANS = 0;
  for(int i=0;i<N;i++)ANS+=i;

  vector<ll>ans(M+1);
  for(int i=M;i>0;i--){
    if(i==M){
      ans[i]=ANS;
    }
    else{
      if(uf.same(A[i],B[i]))ans[i]=ans[i+1];
      else{
        ll a = -uf.rank[uf.find(A[i])];
        ll b = -uf.rank[uf.find(B[i])];
        uf.unite(A[i],B[i]);
        ans[i]=ans[i+1]-a*b;
      }
      //for(int i=1;i<=N;i++)cout<<uf.rank[i]<<" ";
    }
    //cout<<endl;
  }
  for(int i=1;i<=M;i++)cout<<ans[i]<<endl;
  return 0;
}


Measured memory_bytes: 4480
#include <functional>
#include <algorithm>
#include <iostream>
#include <sstream>
#include <cstring>
#include <iomanip>
#include <fstream>
#include <climits>
#include <cctype>
#include <cstdio>
#include <string>
#include <vector>
#include <bitset>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <deque>
#include <list>
#include <map>
#include <set>
using namespace std;

/*** typedef ***/
typedef long long LL;
typedef unsigned int ui;
typedef unsigned long long ULL;
typedef pair < int , int > ii;
typedef pair < LL  , LL  > ll;
typedef vector <int>  vint;
typedef vector <bool> vbool;
typedef vector <long> vlong;

/*** define ***/
#define sz(x)			((int)x.size())
#define tin(x)			scanf("%d",&x)
#define all(x)			x.begin(),x.end()
#define Set(b,a)		memset(b,a,sizeof b)
#define print1(x)		printf("Case %d:",x++)
#define tin2(x,y)		scanf("%d%d",&x,&y)
#define tin3(x,y,z)		scanf("%d%d%d",&x,&y,&z)
#define loop(i,i0,in)	for(int i=i0 ; i<in ; i++)
#define rep(i,n)		for(int i=0 ; i<(n) ; i++)
#define _rep(i,n)		for(int i=n-1 ; i>=0 ; i--)
#define _loop(i,in,i0)	for(int i=in-1 ; i>=i0 ; i--)
#define Fore(it, x)		for(typeof (x.begin()) it = x.begin(); it != x.end (); it++)
     
int main()  
{  
#ifdef Online_Judge
	freopen("a.in","r",stdin);
#endif
	int k=1,n;
	while(cin>>n && n)
		printf("Case %d: %d\n",k++,n);
	return 0;
}

Measured memory_bytes: 1144
N, K = map(int, input().split())
A = list(map(int, input().split()))
Acum = 0
mod = 10 ** 9 + 7


dp = [0]*(K+1)
dp[0] = 1

for a in A:
    Acum += a
    newDP = [0]*(K+1)
    for i in range(min(Acum, K) + 1):
        if i == 0:
            newDP[i] = 1
            continue
        dp[i] += dp[i - 1]
        newDP[i] = dp[i]
        if i > a:
            newDP[i] -= dp[i - a - 1]
        newDP[i] %= mod
    dp = newDP[::]

ans = dp[K]
print(ans)


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


int main(){
  int n,a,b,c,d,i;
  cin >> n >> a >> b >> c >> d;
  string s;
  cin >> s;
  s="#"+s+"#";
  bool ni=true;
  bool san=false;
  if(d>c){
    for(i=a;i<=c-1;++i){
      if(s[i]=='#' && s[i+1]=='#'){
        ni=false;
      }
    }
    for(i=b;i<=d-1;++i){
      if(s[i]=='#' && s[i+1]=='#'){
        ni=false;
      }
    }
    if(ni==true){
      cout << "Yes" << endl;
    }else{
      cout << "No" << endl;
    }
  }else{
    for(i=a;i<=c-1;++i){
      if(s[i]=='#' && s[i+1]=='#'){
        ni=false;
      }
    }
    for(i=b;i<=d-1;++i){
      if(s[i]=='#' && s[i+1]=='#'){
        ni=false;
      }
    }
    for(i=b;i<=d;++i){
      if(s[i-1]=='.' && s[i]=='.' && s[i+1]=='.'){
        san=true;
      }
    }
    if(ni==true && san==true){
      cout << "Yes" << endl;
    }else{
      cout << "No" << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 772
def min(a):
    tmp = a[0]
    for i in a:
        if i < tmp:
            tmp = i
    return tmp

def max(a):
    tmp = a[0]
    for i in a:
        if i > tmp:
            tmp = i
    return tmp

def sum(a):
    tmp = 0
    for i in a:
        tmp = tmp + i
    return tmp

n = int(input())
a = [int(i) for i in input().split(" ")]
print (min(a), max(a), sum(a))


Measured memory_bytes: 6604
#include<iostream>
using namespace std;
int main() {
	int l;
	while (cin >> l&&l != 0) {
		int m = 0, n = 0, g=10000;
		bool h = false;
		for (int i = 0; i < 12; i++) {
			int a, b;
			cin >> a >> b;
			a -= b;
			m++;
			n += a;
			if (n >= l&&h == false) {
				g = m;h = true;
			}
		}
		if (g == 10000)
			cout << "NA" << endl;
		else {
			cout << g << endl;
		}
	}
}

Measured memory_bytes: 3016
import math
def factor(x):
    for i in range(2, x+1):
        count = 0
        while x % i == 0:
            x = x / i
            count = count + 1
        else:
            L[i - 1] = L[i - 1] + count
N = int(input())
L = [0] * N
for i in range(1, N):
    factor(i+1)
M = 1
for i in range(N):
    M = M * (L[i]+1)
print(M % (10 ** 9 +7))


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 2e5 + 7;
int a[N], h[N];
int main()
{
	/*#ifndef ONLINE_JUDGE
	freopen("input.txt","r", stdin);
	freopen("output.txt","w", stdout);
	freopen("error.txt","w", stderr);
	#endif*/
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	
	int n; cin>>n;
	for(int i = 0; i <= n; i++) {
		a[i] = 0;
		h[i] = 0;
	}

	for(int i = 0; i < n-1; i++) {
		cin>>a[i];
		h[a[i]]++;
	}
	for(int i = 1; i <= n; i++) {
		cout<<h[i]<<"\n";
	}
	return 0;
}

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

int a[200100];
int main () {
    int n,k;
    cin>>n>>k;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    sort(a,a+n);
    ll res=0;
    for(int i=0;i<n-k;i++)
        res+=a[i];
    cout<<res;
}

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

#define uint        unsigned int
#define ld          long double
#define int         long long
#define showoff     ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb          push_back
#define pii         pair<int,int>
#define FOR(i,a,b)  for(int i=a;i<b;++i)
#define RFOR(i,a,b) for(int i=a;i>b;--i)
#define f           first
#define se          second
#define maxn        200005
#define all(v)      v.begin(),v.end()
#define sz(x)       (int)x.size()
#define mod         1000000007
#define pqueue      priority_queue<int>
#define pdqueue     priority_queue< int,vector<int> ,greater< int >>

using namespace std;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
//const int md = 998244353;

/*const int mod = 998244353;
int power(int a,int n)
{
    if(n == 1)return a%mod;
    if(n == 0)return 1;
    if(n&1)return ((a%mod)*(power((a*a)%mod,n/2))%mod)%mod;
    return power((a*a)%mod,n/2)%mod;
}
*/


signed main()
{
    showoff;
    int n;
    string a,b,c;
    cin >> n >> a >> b >> c;
    int ans = 0;
    FOR(i,0,n){
    if(a[i] == b[i] && b[i] == c[i])continue;
    if(a[i] == b[i] || a[i] == c[i] || b[i] == c[i])ans++;
    else ans += 2;
    }
    cout << ans;
    return 0;
}


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


int main()
{
    ll a,b,n,i,j,k,cnt=0,mx=0,pp;

    cin>>n;
   cnt=n/500;
   pp=n-(cnt*500);
   pp=pp/5;
   mx=(pp*5)+(cnt*1000);
   cout<<mx<<endl;

}








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

int main()
{
    int n;
    double ans;

    cin >> n;
    vector<int> nn(n);
    vector<int> x(n), y(n);
    rep(i, n) {
        nn[i] = i;
        cin >> x[i] >> y[i];
    }

    int cnt = 0;
    long double l=0;
    do {
        rep(i, n - 1) {
            l += sqrt(pow(x[nn[i]] - x[nn[i + 1]], 2) + pow(y[nn[i]] - y[nn[i + 1]], 2));
        }
        ++cnt;
    } while (next_permutation(nn.begin(), nn.end()));

    ans = l / cnt;
    cout << fixed << setprecision(10)  << ans << endl;
}

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

#define ull unsigned long long

using namespace std;

struct Item {

    int cost, number;
};

bool cmp(Item a, Item b) {

    return b.cost > a.cost;
}

int main() {

    int n, m;
    cin >> n >> m;
    
    Item a[n];
    for(int i = 0; i < n; i++)
        cin >> a[i].cost >> a[i].number;
    
    sort(a, a + n, cmp);
    
    int iterator = 0;
    ull sol = 0;
    while(m > 0) {
        int temp = min(m, a[iterator].number);
        
        m -= temp;
        sol += (ull)a[iterator++].cost * (ull)temp;
    }
    
    cout << sol << endl;
    return 0;
}

Measured memory_bytes: 1024
# include <bits/stdc++.h>
# define  long          long long
# define  all(vc)       vc.begin(),vc.end()
# define  allr(vc)      vc.rbegin(),vc.rend()
# define  pb            push_back
# define  fi            first 
# define  se            second
# define  pi            pair <long, long>    
# define  lcm(a, b)     (a * b) / __gcd(a, b)
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        using namespace std;
void read(){freopen("input.txt" , "r" , stdin );freopen("output.txt", "w" , stdout );}
void solve(){
        double a, b, n;
        cin >> a >> b >> n;
        long x = 0;
        if( n < b ) x = n;
        else x = b - 1;
        cout << floor(a * x / b) - a * floor(x / b) << '\n';
}
int32_t main(){
ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); 
        long T = 1;
        //cin >> T;
        while( T-- ){
            solve();
            cout<<'\n';
        }
cerr << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";    
}

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

int main() {
    int h, w, k;
    cin >> h >> w >> k;
    vector<vector<char>> c(h, vector<char>(w));
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            cin >> c[i][j];
        }
    }
    int ans = 0;
    for (int bit1 = 0; bit1 < (1 << h); bit1++) {
        for (int bit2 = 0; bit2 < (1 << w); bit2++) {
            int black = 0;
            for (int i = 0; i < h; i++) {
                if (bit1 & (1 << i)) {
                    continue;
                }
                for (int j = 0; j < w; j++) {
                    if (bit2 & (1 << j)) {
                        continue;
                    }
                    if (c[i][j] == '#') {
                        black++;
                    }
                }
            }
            if (black == k) {
                ans++;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3600