akhauriyash/Code-Regression huggingface dataset:
import java.io.IOException;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.BufferedReader;
import java.util.StringTokenizer;

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);
        Task solver = new Task();
        solver.solve(in, out);
        out.close();
    }

    static class Task {
        void solve(InputReader in, PrintWriter out) {
            // write your code here
            int p[];
            int maxPrice = 0;
            int N = in.nextInt();
            p = new int[N];
            for (int i = 0; i < N; i++) {
                p[i] = in.nextInt();
                maxPrice = Math.max(p[i], maxPrice);
            }

            int sum = 0;
            boolean discounted = false;
            for (int i = 0; i < N; i++) {
                if (p[i] == maxPrice && !discounted) {
                    sum += p[i] / 2;
                    discounted = true;
                } else {
                    sum += p[i];
                }
            }

            out.println(sum);
        }
    }

    static class InputReader {
        BufferedReader reader;
        StringTokenizer tokenizer;

        InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream));
            tokenizer = null;
        }

        String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }
    }
}

Measured memory_bytes: 22740
n=int(input())
a=[list(map(int,input().split())) for _ in range(n)]
s=0
t=[]
for i in range(0,n):
    if a[i][0]==a[i][1]:
        s=s+1
    else:
        t.append(s)
        s=0
t.append(s)    
u=1   
for j in t:
    if u<j:
        u=j
if u>=3:
    print('Yes')
else:
    print('No')      

Measured memory_bytes: 9136
#include<stdio.h>
#include<string.h>

  char h[1<<21],k[256];
int main(int argc,char *argv[]){
  int fg;
  int vl,s,t;
  char c;
  
  k['T'] = 1;
  k['G'] = 2;
  k['C'] = 3;
  k['A'] = 4;
   
  scanf("%d", &vl);
  getchar();
  
  while (vl--) {
    s = 0;
    t = 1;
    fg = ( c = getchar() ) == 'i';
    while ( ( c = getchar() ) != ' ' );
    while ( ( c = k[getchar()] ) != 0 ) {
      s += c * t;
      t *= 4;
    }
    if (fg) h[s] = 1; else puts( h[s] ? "yes" : "no" );
  }

  
  
  return 0;
}



Measured memory_bytes: 3056
#include<stdio.h>
#include<string.h>
int main(){
    int a=0;
    char s[4],b,c,d=0,e=0;
    scanf("%s",s);
    b=s[0];
    for(int i=1;i<4;i++){
        if(strncmp(&b,&s[i],1)!=0){
            c=s[i];
            break;
        }
    }
    for(int j=0;j<4;j++){
        if(strncmp(&b,&s[j],1)==0){
            d++;
        }
        if(strncmp(&c,&s[j],1)==0){
            e++;
        }
    }
    if((d==2)&&(e==2)){
        printf("Yes\n");
    }
    else{
        printf("No\n");
    }
    return 0;
}


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

//#define int long long
typedef long long ll;
//const int INF = 2e9;
//const ll INF = 9e18;


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N, M;
    cin >> N >> M;
    vector<int> num(N);
    for (int i=0;i<M;i++){
        int a, b;
        cin >> a >> b;
        a--;b--;
        num[a]++;
        num[b]++;
    }
    bool ok = true;
    for (int i=0;i<N;i++){
        if (num[i]%2==1) {
            ok = false;
            break;
        }
    }
    if (ok) cout << "YES" << "\n";
    else cout << "NO" << "\n";
}

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

using ll = long long;
#define debug(x) cerr << #x << ": " << x << endl;
#define line() cerr << "---------------" << endl;

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

   ll ans = 0;
   for (;;) {
      if (x <= y) {
         ans++;
      } else {
         break;
      }
      x *= 2;
   }

   cout << ans << endl;

   return 0;
}

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

int main(){
    ll x; cin >> x;

    if( x > 29) put("Yes");
    else put("No");
}

Measured memory_bytes: 3636
#!/usr/bin/env python3

def main():
    s = input()
    t = input()

    s_bytes = sorted(s.encode())
    t_bytes = sorted(t.encode(), reverse = True)

    s_len = len(s)
    t_len = len(t)

    gt = s_len < t_len

    for i in range(len(s_bytes)):
        if t_len <= i:
            gt = False
            break
        if s_bytes[i] == t_bytes[i]:
            continue
        gt = s_bytes[i] < t_bytes[i]
        break

    print('Yes' if gt else 'No')


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <sstream>
#include <bitset>
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)

using namespace std;
typedef long long ll;
const ll MOD=1e9+7;

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

    ll i,j,h;

    vector<int> aa;
    string temp;
   ll N;
   ll a=0;
   ll b=0;
   ll c=0;
   ll d=0;
    cin >> N;
   rep(i,N){
       cin >> temp;
       if(temp == "AC")a++;
       else if(temp == "WA")b++;
       else if(temp == "TLE")c++;
       else if(temp == "RE")d++;

   }

  


   cout << "AC x "<< a<< endl;
   cout << "WA x "<< b<< endl;
   cout << "TLE x "<< c<< endl;
   cout << "RE x "<< d<< endl;
    return 0;
}

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

using namespace std;

const int NMAX = 3005;

//dp[i][j][k] = playing from ks perspective, the optimal play given the set a without [1..i] and [j..N]
//0 = Taro , 1 = Jiro
int N;
long long dp[NMAX][NMAX][2],a[NMAX];

inline long long DFS(int pref,int suf,int player)
{
    if(dp[pref][suf][player])
    {
        return dp[pref][suf][player];
    }
    else if(pref+suf == N)
    {
        dp[pref][suf][player] = 0;
        return dp[pref][suf][player];
    }
    else
    {
        long long v1,v2;
        DFS(pref+1 , suf , (player^1));
        DFS(pref , suf+1 , (player^1));
        if(player == 0)
        {
            v1 = a[pref+1] + dp[pref+1][suf][(player^1)];
            v2 = a[N-suf] + dp[pref][suf+1][(player^1)];
            dp[pref][suf][player] = max(v1,v2);
        }
        else
        {

            v1 = dp[pref+1][suf][(player^1)] - a[pref+1];
            v2 = dp[pref][suf+1][(player^1)] - a[N-suf];
            dp[pref][suf][player] = min(v1,v2);
        }
        return dp[pref][suf][player];
    }
}

int main()
{
    int i,j;
    cin>>N;

    for(i = 1 ; i <= N ; ++i)
        cin>>a[i];

    cout<<DFS(0,0,0);

}


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

#define FOR(i, a, b) for (int i = (a); i < static_cast<int>(b); i++)
#define FORR(i, a, b) for (int i = (a); i >= static_cast<int>(b); i--)
#define rep(i, n) FOR (i, 0, n)
#define repall(i, arr) for (auto& i : (arr))
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define dump(x) cerr << #x << " = " << (x) << '\n'
template <typename T>
void print(const vector<vector<T>> matrix);
template <typename T>
void print(const vector<T> vec);
template <typename Arg>
void print(const Arg arg);
template <typename Head, typename... Args>
void print(const Head head, const Args... args);
template <typename T>
using pq = priority_queue<T>;
template <typename T>
using pqr = priority_queue<T, vector<T>, greater<T>>;
const int INF = INT_MAX / 2;
using ll = long long;

ll N, K;

ll cnt(ll rem) { return (N + K - rem) / K; }

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

    bool even = K % 2 == 0;

    ll n = N / K;
    ll sum = n * n * n;

    if (even) {
        n = cnt(K / 2);
        sum += n * n * n;
    }
    print(sum);

    return 0;
}

//---------------------------------------------
template <typename T>
void print(const vector<vector<T>> matrix) {
    repall (vec, matrix)
        print(vec);
}
template <typename T>
void print(const vector<T> vec) {
    unsigned int len = vec.size();
    rep (i, len - 1)
        cout << vec[i] << ' ';
    cout << vec[len - 1] << '\n';
}
template <typename Arg>
void print(const Arg arg) {
    cout << arg << '\n';
}
template <typename Head, typename... Args>
void print(const Head head, const Args... args) {
    cout << head << " ";
    print(args...);
}


Measured memory_bytes: 256
#define _DEBUG 1
#define _GLIBCXX_DEBUG

#include <bits/stdc++.h>
using namespace std;

using ll = long long;

#ifdef _DEBUG
#define dump(x) cerr << #x << "=" << x << endl
#define dump2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define dump3(x, y, z)                                                     \
  cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z \
       << endl
#define check(s) cerr << s << endl
#else
#define dump(x)
#define dump2(x, y)
#define dump3(x, y, z)
#define check(s)
#endif

#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define unique(v) v.erase(unique(v.begin(), v.end()), v.end());

const ll LINF = 2e18;
const int INF = 1e9;

int H, W;
vector<vector<char>> s;

vector<int> mx = {0, 1, 0, -1};
vector<int> my = {1, 0, -1, 0};

struct point {
  int x;
  int y;

  bool operator==(const point& rhs) const { return (x == rhs.x && y == rhs.y); }
};
typedef struct point Point;

void solve() {
  queue<pair<Point, int>> q;
  vector<vector<int>> dist(H, vector<int>(W, -1));
  tuple<int, int> v;
  tuple<int, int> v2;

  Point start = {0, 0};
  Point goal = {W - 1, H - 1};

  q.push(make_pair(start, 0));

  while (!q.empty()) {
    auto v = q.front();
    q.pop();
    Point current = v.first;
    int d = v.second;

    if (dist.at(current.y).at(current.x) != -1) {
      continue;
    } else {
      dist.at(current.y).at(current.x) = d;
    }
    if (current == goal) {
      break;
    }

    rep(i, 4) {
      int nx = current.x + mx.at(i);
      int ny = current.y + my.at(i);
      if (nx < 0 || nx >= W || ny < 0 || ny >= H) {
        continue;
      }
      if (s.at(ny).at(nx) == '.') {
        Point next = {nx, ny};
        q.push(make_pair(next, d + 1));
      }
    }
  }

  if (dist.at(H - 1).at(W - 1) == -1) {
    cout << -1 << endl;
    return;
  }

  int count = 0;
  rep(i, H) {
    rep(j, W) {
      if (s.at(i).at(j) == '.') {
        count++;
      }
    }
  }
  int result = count - dist.at(H - 1).at(W - 1) - 1;
  cout << result << endl;
}

int main() {
  cin >> H >> W;
  s.resize(H);
  rep(i, H) {
    s.at(i).resize(W);
    rep(j, W) { cin >> s.at(i).at(j); }
  }

  solve();
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
int main(){
    
    int x = 0;
    std::cin >> x;
    
    if(x == 3||x == 5||x == 7){
     
        std::cout << "YES" << std::endl;
        
    }else{
        
        std::cout << "NO" << std::endl;
        
    }
    
}

Measured memory_bytes: 256
L, R = map(int, input().split())
from itertools import combinations

mod = 2019

if R - L >= mod:
    print(0)
else:
    mini = mod - 1
    for i, j in combinations(range(L, R+1), 2):
        mini = min(mini, i*j % mod)
        if mini == 0:
            break
    print(mini)

Measured memory_bytes: 3060
ans = 0
N = int(input())
A, B = zip(*list(list(map(int, input().split())) for _ in range(N)))
if A == B:
    print(0)
    exit()

Asum = sum(A)
ans = max(Asum - b for a, b in zip(A, B) if a > b)
print(ans)

Measured memory_bytes: 13852
N, M = map(int, input().split())
AC = [0 for i in range(N)]
WA = [0 for i in range(N)]
for i in range(M):
  p, s = input().split()
  p = int(p)
  if s == 'AC':
    AC[p-1] = 1
  elif AC[p-1] == 0:
    WA[p-1] += 1
a = sum(AC)
b = 0
for i in range(N):
  if AC[i] == 1:
    b += WA[i]
print(a, b, sep=' ')
  
  

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

const char wall = '#';
vector<vector<char>> fields;
vector<vector<bool>> used;
vector<vector<ll>> dist;
const int dx[4] = {0, -1, 0, 1};
const int dy[4] = {1, 0, -1, 0};

vector<ll> A;
// vectorのリサイズ
// A.resize(N);

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

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

  ll a, b, c;
  cin >> a >> b >> c;
  vector<ll> v;
  v.push_back(a);
  v.push_back(b);
  v.push_back(c);
  sort(v.begin(), v.end(), greater<ll>());
  cout << v[0]*10+v[1]+v[2] << endl;
  return 0;
}


Measured memory_bytes: 256
while True:
    h, w = map(int, input().split())
    if h == 0 and w == 0:
        break

    s1 = "#" * w
    s2 = "#" + "." * (w - 2) + "#"

    for i in range(h):
        if i == 0 or i == h - 1:
            print(s1)
        else:
            print(s2)
    print()


Measured memory_bytes: 5612
#include<bits/stdc++.h>
using namespace std;
int main()
{
  	int a,b;
  	cin>>a>>b;
  	string s;
  	cin>>s;
  	bool s10=true;
  	if(s[a]!='-')
    {
        s10=false;
        cout<<"No"<<endl;
        return 0;
    }
  	for(int i=0;i<s.size();i++)
        if(!(s[i]>='0' && s[i]<='9') && i!=a)
            s10=false;
    if(s10)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
  	return 0;
}


Measured memory_bytes: 256
A,B = list(map(int, input().split()))
Z1_l = A * 25 / 2
if (A % 2) == 1:
    Z1_l = int(Z1_l) + 1
else:
    Z1_l = int(Z1_l)
Z1_u = (A + 1) * 25 / 2
if ((A+1) % 2) == 1:
    Z1_u = int(Z1_u) + 1
else:
    Z1_u = int(Z1_u)
Z2_l = B * 10
Z2_u = (B + 1) * 10
if Z2_u <= Z1_l or Z1_u <= Z2_l:
    ans = -1
else:
    ans = int(max(Z1_l,Z2_l))

print(ans)

Measured memory_bytes: 3064
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

struct node{
  unsigned int key;
  struct node *next;
  struct node *prev;
};

typedef struct node *Pointer;

Pointer nil;

Pointer serch(int key){
  Pointer i= nil->next;

  while(i!=nil && i->key!=key){
    i = i->next;
  }
  return i;
}

void init(){
  nil = malloc(sizeof(struct node));
  nil->next = nil;
  nil->prev = nil;
}

void printList(){
  Pointer i = nil->next;
  int s = 1;
  while(1){
    if ( i == nil ) break;
    if ( s == 0)  printf(" ");
    printf("%d",i->key);
    i = i->next;
    s = 0;
  }
  printf("\n");
}

void deleteNode(Pointer t){

  if(t==nil)return;
  t->prev->next = t->next;
  t->next->prev = t->prev;
  free(t);
}

void deleteFirst(){
  Pointer t = nil->next;
  if ( t == nil ) return;
  deleteNode(t);
}

void deleteLast(){
  Pointer t=nil->prev;
  deleteNode(t);
}

void delete(int key){
  Pointer t=serch(key);
  deleteNode(t);
}


void insert(int key){
  Pointer x;
  x = malloc(sizeof(struct node));
  x->key = key;

  x->next = nil->next;
  nil->next->prev = x;
  nil->next = x;
  x->prev = nil;
}

int main(){
  int key, n, i;
  int size = 0;
  char com[20];
  int np = 0, nd = 0;
  scanf("%d", &n);
  init();
  for ( i = 0; i < n; i++ ){
    scanf("%s%d", com, &key);
    if ( com[0] == 'i' ) {insert(key); np++; size++;}
    else if ( com[0] == 'd' ) {
      if (strlen(com) > 6){
	if ( com[6] == 'F' ) deleteFirst();
	else if ( com[6] == 'L' ) deleteLast();
      } else {
	delete(key); nd++; 
      }
      size--;
    }
  }

  printList();
  return 0;
}




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

int gcd(int x, int y);

const int INF = 1001001001;

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

    // for prime mod
    mint inv() const { return pow(mod - 2); }
    mint& operator/=(const mint a) { return *this *= a.inv(); }
    mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream & is, const mint & a) { return is >> a.x; }
ostream& operator<<(ostream & os, const mint & a) { return os << a.x; }*/

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    map<int, int> mp;
    ll ans = 0;
    rep(i, n) {
        cin >> a[i];
        int wa = i + a[i];
        int sa = i - a[i];
        ans += mp[sa];
        mp[wa]++;
    }

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

/*���C�u�����ő����*/
//���[�O���b�h�̌ݏ��@
int gcd(int x, int y) {
    int num[3];
    num[0] = (x > y) ? x : y;
    num[1] = (x <= y) ? x : y;
    num[2] = num[0] % num[1];

    while (num[2]) {
        num[0] = num[1];
        num[1] = num[2];
        num[2] = num[0] % num[1];
    }

    return num[1];
}

Measured memory_bytes: 20960
sheet = [[0 for _ in range(10)] for _ in range(10)]

#小、中、大のインクの範囲
small_range = ((0, 0), (1, 0), (0, 1), (-1, 0), (0, -1))
middle_range = ((0, 0), (1, 0), (1, 1), (0, 1), (-1, 1), (-1, 0), (-1, -1), (0, -1), (1, -1))
large_range = ((0, 0), (1, 0), (2, 0), (1, 1), (0, 1), (0, 2), (-1, 1), (-1, 0), (-2, 0), (-1, -1), (0, -1), (0, -2), (1, -1))

#範囲内か判定してインクを足す
def drop(x, y, drop_range):
  for dx, dy in drop_range:
    newx, newy = x + dx, y + dy
    if 0 <= newx <= 9 and 0 <= newy <= 9:
      sheet[newx][newy] += 1

while True:
  try:
    x, y, s = map(int, input().split(","))

    if s == 1:
      drop(x, y, small_range)
    elif s == 2:
      drop(x, y, middle_range)
    else:
      drop(x, y, large_range)

  except EOFError:
    break

#0の個数
zero_cnt = 0

#インクの最大値
max_ink = 0

for x in range(10):
  for y in range(10):
    ink = sheet[x][y]

    if ink == 0:
      zero_cnt += 1

    if max_ink < ink:
      max_ink = ink

print(zero_cnt)
print(max_ink)


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

int main()
{
  string s;
  cin >> s;
  int c = 0;
  for(int i = 0; i < s.length(); i++)
  {
    if(s[i] == 'R' && s[i-1] != 'R')
    {
      c = 0;
      c++;
    }
    else if(s[i] == 'R' && s[i-1] == 'R')
    {
      c++;
    }
  }
  cout << c;
  return 0;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please


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


	int N;
	cin >> N;

	int kotae = 0;
	rep1(i, 9) {
		int kazu = pow(3, i) + 1e-9;
		rep(j, kazu) {
			int kazu2 = 0;
			int kazu3[3] = {};
			int kari = j;
			rep(k, i) {
				if (kari % 3 == 0) {
					kazu2 += 3 * pow(10, k) + 1e-9;
					kazu3[0]++;
				}
				else if (kari % 3 == 1) {
					kazu2 += 5 * pow(10, k) + 1e-9;
					kazu3[1]++;
				}
				else {
					kazu2 += 7 * pow(10, k) + 1e-9;
					kazu3[2]++;
				}
				kari /= 3;
			}
			if (kazu2 <= N && kazu3[0] > 0 && kazu3[1] > 0 && kazu3[2] > 0) kotae++;
		}
	}

	co(kotae);

	Would you please return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) {
        FastReader s = new FastReader();
        long N,A,B;
        N = s.nextLong();
        A = s.nextLong();
        B = s.nextLong();
        long total=(N/(A+B));
        N-=((A+B)*total);
        total*=A;
        if(A!=0){
            if(N>A)
                total+=A;
            else
                total+=(N%A);
        }

        System.out.println(total);

    }

    private static boolean isPrime(int n) {
        if (n == 2)
            return true;
        else if ((n % 2 == 0 && n > 2) || n < 2)
            return false;
        else {
            for (int i = 3; i <= (int) Math.sqrt(n); i += 2) {
                if (n % i == 0)
                    return false;
            }
            return true;
        }


    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }

}

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

using namespace std;

int near(vector<int> v, int i) {
  auto index1 = lower_bound(v.begin() + 1, v.end() - 1, i) - v.begin();
  auto index2 = index1 - 1;
  return abs(v[index1] - i) < abs(v[index2] - i) ? v[index1] : v[index2];
}

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

  vector<int> v(n);
  for (int i = 0; i < n; ++i) scanf("%d", &v[i]);

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

  int last = v.back();
  if (last % 2 == 1) ++last;

  printf("%d %d\n", v.back(), near(v, last / 2));
}


Measured memory_bytes: 1024
#include<iostream>
#include<string>
using namespace std;
#define rep(i, n) for ( int i = 0; i < n; i++)
#define N 5
int main(){
  bool G[N][N][4];
  char ch;
  rep(i, N) rep(j, N) rep(k, 4) G[i][j][k] = false;
  rep(i, 2*N-1){
    if (i%2){
      rep(j, N) {
	cin >> ch;
	if (ch == '1') G[(i+1)/2-1][j][3] = G[(i+1)/2][j][1] = true;
      }
    } else {
      rep(j, N-1) {
	cin >> ch;
	if (ch == '1') G[i/2][j][0] = G[i/2][j+1][2] = true;
      }
    }
  }
  
  string D = "RULD";
  int di[4] = {0, -1, 0, 1};
  int dj[4] = {1, 0, -1, 0};
  int pi = 0, pj = 0, dir = 0;
  
  while(1){
    if ( G[pi][pj][(dir+1)%4] ){
      dir = (dir+1)%4;
      pi += di[dir];
      pj += dj[dir];
      cout << D[dir];
    } else if ( G[pi][pj][dir] ){
      pi += di[dir];
      pj += dj[dir];
      cout << D[dir];
    } else dir = (dir+3)%4;
    if ( pi == 0 && pj == 0 ) break;
  }
  cout << endl;
}

Measured memory_bytes: 0
#include <iostream>
#include <math.h>
#include <algorithm>
using namespace std;
int main(void){
    int n,year,id,type,maxid;
    double r,maxrate,tmp;
    while(true){
        cin >> n;
        if(n==0)break;
        cin >> year;
        maxrate=0;
        for(int i=0;i<n;i++){
            cin >> id >> r >> type;
            if(type == 1){
                tmp = 100*((100+year*r)/100);
                if(tmp > maxrate){
                    maxrate = tmp;
                    maxid = id;
                }
            }else{
                tmp = 100*pow(((100+r)/100),year);
                if(tmp > maxrate){
                    maxrate = tmp;
                    maxid = id;
                }
            }
        }
        cout << maxid << endl;
    }
    return 0;
}


Measured memory_bytes: 3476
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned ui;
typedef unsigned long long ul;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
typedef pair<ul, ul> puu;
typedef vector<int> vi;
#define pb push_back
#define fi first
#define se second
#define ls (i << 1)
#define rs (i << 1 | 1)
#define mid (l + r >> 1)
#define enum(i, j, k) for(int i = j; i <= (k); i ++)
#define open(i, j, k) for(int i = j; i <  (k); i ++)
#define dec(i, j, k)  for(int i = j; i >= (k); i --)
#define ae(x) for(node *p = h[x]; p; p = p->nxt)
#define mfil(x, k) memset(x, k, sizeof x)
#define mcpy(x, y) memcpy(x, y, sizeof x)
#define fio(x) freopen(x".in", "r", stdin); freopen(x".out", "w", stdout)
template <class T> bool chkmin(T &x, T y)
{ return y < x ? (x = y, true) : false; }
template <class T> bool chkmax(T &x, T y)
{ return y > x ? (x = y, true) : false; }
struct __init { __init()
{
    ios::sync_with_stdio(false); cin.tie(0);
    cout.precision(16); cout << fixed;
    srand(time(0) ^ ui(ul(new char)));
} } static __init__;
/* default code ends here */

const int maxn = 2e5 + 10;
int n, k;
bool a[10 * maxn], lazy;
int front = 1;
int main()
{
    cin >> n >> k;
    if(k > 3 * n + 10)
        k -= (k - 3 * n) / 2 * 2 - 4;
    string foo;
    cin >> foo;
    enum(i, 1, n)
        a[i] = foo[i - 1] == 'A';
    while(k --)
    {
        if(a[front] ^ lazy)
        {
            a[front] ^= 1;
            continue;
        }
        front ++;
        lazy ^= 1;
        a[front + n - 1] = lazy ^ 1;
    }
    enum(i, front, front + n - 1)
        cout << (a[i] ^ lazy ? 'A' : 'B');
    
    return 0;
}

Measured memory_bytes: 1432
#include<bits/stdc++.h>
using namespace std;
int main(){
  string S,T;
  bool Ans=true;
  cin>>S>>T;
  for(int i=0;i<S.size(); i++){
    if(S.at(i)!=T.at(i)) Ans=false;
  }
  if(Ans) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 3552
#include<stdio.h>
int max(int a,int b)
{
	if(a>b)
		return a;
	else
		return b;
}
int main()
{
	int a,b,c;
	scanf("%d%d%d",&a,&b,&c);
	int x;
	x=max(max(a,b),c);
	if(a+b+c==2*x)
		printf("Yes\n");
	else
		printf("No\n");
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define FOR(i,a,n) for(i = a;i<n;++i)
#define ROF(i,a,n) for(i = n-1;i>=a;--i)
using namespace std;

int main(){
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    //ios_base::sync_with_stdio(0);
    //cin.tie(0);

    int n,a,b;

    cin>>n>>a>>b;

    if((b - a)%2 == 0){
        cout<<"Alice";
    }
    else{
        cout<<"Borys";
    }

    return 0;
}


Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var H, N int
	fmt.Scanf("%d %d", &H, &N)
	A := make([]int, N)
	sum := 0
	for i := 0; i < N; i++ {
		fmt.Scanf("%d", &A[i])
		sum += A[i]
	}
	if H > sum {
		fmt.Println("No")
	} else if H == sum {
		fmt.Println("Yes")
	} else {
		fmt.Println("Yes")
	}
}


Measured memory_bytes: 5504
/* ＵＴＦ－８ */
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <array>
#include <queue>
#include <stack>
#include <algorithm>
#include <tuple>
#include <numeric>
#include <type_traits>
#include <limits>

#include <unistd.h>
#include <fcntl.h>

int main()
{
        if (!getenv("DEBUG")) {
                int fd = open("/dev/null", O_WRONLY);
                dup2(fd, 2);
                close(fd);
        }

        int a;
        std::string s;

        std::cin >> a >> s;

        std::cerr << "hogehoge\n";

        if (a >= 3200)
                std::cout << s << "\n";
        else
                std::cout << "red\n";
}


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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<string> s(n);
    int c1 = 0, c2 = 0, c3 = 0, c4 = 0;
    for (int i = 0; i < n; i++) {
        cin >> s[i];
        if (s[i] == "AC") ++c1;
        else if (s[i] == "WA") ++c2;
        else if (s[i] == "TLE") ++c3;
        else if (s[i] == "RE") ++c4;
    }
    cout << "AC x " << c1 << '\n';
    cout << "WA x " << c2 << '\n';
    cout << "TLE x " << c3 << '\n';
    cout << "RE x " << c4 << '\n';
    return 0;
}

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

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

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

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

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

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

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

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

fn str_join<T: std::string::ToString>(s: &Vec<T>) -> String {
    s.iter()
        .map(|i| i.to_string())
        .collect::<Vec<_>>()
        .join(" ")
}
fn main() {
    input! { n:usize, a:[usize;n] }
    let mut a = a;
    for i in 0..n {
        let v = a[i];
        let mut j = i;
        while j > 0 && a[j - 1] > v {
            a[j] = a[j - 1];
            j -= 1;
        }
        a[j] = v;
        println!("{}", str_join(&a));
    }
}



Measured memory_bytes: 5048
#include <bits/stdc++.h>
#define pi pair<int,int>
#define ll long long
#define pll pair<ll,ll>
#define rep(i,a,b) for(int i = a ; i <= b;i++)
using namespace std;
void debug(int x){
    cerr<<x<<endl;
}
void debug(vector<int> v){
    for(int i = 0 ; i<v.size(); i++) cerr<<v[i]<<" ";
    cerr<<"\n";
}
void debug(int *A, int N){
    for(int i = 0 ; i < N;i++) cerr<<A[i]<<" ";
    cerr<<endl;
}
void debug(int *A, int i, int j){
    for(int k = i;k<=j;k++) cerr<<A[k]<<" ";
    cerr<<endl;
}
void scan(vector<int> &h,int N){
    for(int i = 0 ; i < N;i++){
        scanf("%d",&h[i]);
    }
}
ll dp[100][100005] = {0};
int main(){
            int N,W;
            cin>>N>>W;
            vector<ll> w(N),v(N);
            rep(i,0,N-1){
                cin>>w[i]>>v[i];
            }
            //initializing the dp[0][j] value
            for(int j = 0 ; j <=W; j++){
                dp[0][j] = (w[0] > j)?0:v[0];
               // cout<<"updated "<<0<<" j = "<<j<<" to "<<dp[0][j]<<endl;
            }
            for(int i = 1; i <N;i++){
                 for(int j = 0;j<=W;j++){
                     dp[i][j] = -1;
                    
                     if(j >=w[i]){
                         dp[i][j] = max(dp[i][j], dp[i-1][j-w[i]] + v[i]); //including the last value
                         dp[i][j] = max(dp[i][j], dp[i-1][j]); //excluding last value
                      }
                    else{
                         dp[i][j] = max(dp[i][j] , dp[i-1][j]); 
                         //excluding the last value ..since the last value cant be included
                    }
                  //   cerr<<"updated "<<i<<" "<<j<<" to "<<dp[i][j]<<"\n";
                 }
            }
            cout<<dp[N-1][W]<<"\n";
}

Measured memory_bytes: 78336
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mk make_pair
#define mod 1000000007
#define lb lower_bound
#define ub upper_bound
#define endl "\n"
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define prec(y,x) fixed<<setprecision(y)<<x
#define inf 1e18+7
#define pi 3.1415926535
vector<vector<ll>> v;
vector<ll> vis, dep1, dep2, dep3;

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	ll n,m,s;
	cin>>n>>m>>s;
	if(s>2500)
	s=2499;
	ll dp[n+1][2500];
	for(ll i=0;i<=n;i++)
	{
	    for(ll j=0;j<2500;j++)
	    dp[i][j]=inf;
	}
	vector<vector<pair<ll,pair<ll,ll>>>> v;
	v.resize(n+1);
	ll u,uu,a,b,c,d;
	for(ll i=0;i<m;i++)
	{
	    cin>>u>>uu>>a>>b;
	    v[u].pb(mk(uu,mk(a,b)));
	    v[uu].pb(mk(u,mk(a,b)));
	}
	vector<pair<ll,ll>> nod;
	nod.pb(mk(0,0));
	for(ll i=1;i<=n;i++)
	{
	    cin>>c>>d;
	    nod.pb(mk(c,d));
	}
	dp[1][s]=0;
	for(ll g=0;g<=n+1;g++)
	{
	    for(ll i=1;i<=n;i++)
	    {
	        for(ll j=0;j<v[i].size();j++)
	        {
	             u=v[i][j].ff;ll cs=v[i][j].ss.ff;
	             ll t=v[i][j].ss.ss;
	            for(ll k=0;k<2500;k++)
	            {
	                if(k-cs>=0)
	                {
	                    dp[i][k-cs]=min(dp[i][k-cs],dp[u][k]+t);
	                }
	            }
	       
	        }
	        for(ll j=0;j<2500;j++)
	        {
	            if(j>=nod[i].ff)
	            {
	                dp[i][j]=min(dp[i][j],dp[i][j-nod[i].ff]+nod[i].ss);
	            }
	        }
	    }
	}
    for(ll i=2;i<=n;i++)
    {
        ll mn=inf;
        for(ll j=0;j<2500;j++)
        mn=min(mn,dp[i][j]);
       // for(int j=0;j<=14;j++)
        //cout<<dp[i][j]<<" ";
         cout<<mn<<endl;
    }
	return 0;
}


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

#define REP(i, n) for(int64_t i = 0; i < n; i++)
#define REPR(i, n) for(int64_t i = n; i >= 0; i--)
#define FOR(i, m, n) for(int64_t i = m; i < n; i++)
#define FORR(i, m, n) for(int64_t i = m; i >= n; i--)
#define ALL(v) v.begin(), v.end()
typedef long long ll;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    fill( (T*)array, (T*)(array+N), val );
}
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 ll INF= 1ll << 60;
const ll MOD = 1000000007;
double EPS = 1e-10;
//----------------------------------------------------------

ll x;

int main(){
    cin >> x;
    ll y = 100;
    ll c=0;
    while(y<x)
    {
        c++;
        y=y*1.01;
    }
    cout << c << endl;
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define loop(i, a, n) for(int i = (a); i < (n); i++)
#define sorn(i, n) char((i == n-1)?'\n':' ')
#ifdef _DEBUG
#define dd(x) cout << #x << " : " << x << endl
#else
#define dd(x)
#endif
using namespace std;
using ll = int64_t;

int main(){
    ll n; cin >> n;
    ll sum = 0;
    vector<ll> a;
    rep(i, n) {
        ll tmp; cin >> tmp;
        sum ^= tmp;
        a.push_back(tmp);
    }

    int asize = a.size();
    rep(i, asize) {
        cout << (sum^a[i]) << sorn(i, asize);
    }

    return 0;
}

Measured memory_bytes: 5336
#include <cstdio>
#include <iostream>
using namespace std;
int main(){
	int n,a,b;
	scanf("%d%d%d",&n,&a,&b);
	if(a%n==0)printf("OK\n");
	else{
		a=(a/n+1)*n;
		if(a<=b)printf("OK\n");
		else printf("NG\n");
	}
	return 0;
}

Measured memory_bytes: 3688
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1e9;
const int MOD = INF+7;
const ll LINF = 1e18;
#define rep(i,N) for(int (i)=0;(i)<(N);++(i))
#define rrep(i,N) for(int (i)=(N-1);(i)>0;--i)
#define FOR(i,j,N) for(int (i)=(j);(i)<(N);++(i))
#define put(n) cout<<(n)<<endl;
#define VI vector<int>
#define VII vector<vector<int>>
#define all(v) v.begin(),v.end()
#define MP make_pair
#define pb(n) push_back(n)


int main(){
    int N,T;cin>>N>>T;
    int MIN = 1e9;
    rep(i,N){
        int c,t;
        cin>>c>>t;
        if(t<=T) MIN = min(MIN,c);
    }
    if(MIN == 1e9) cout<<"TLE"<<endl;
    else cout<<MIN<<endl;
}

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

using namespace std;
using ll =long long;
using vi = vector<int>; 
using vvi = vector<vi>; 
using vl = vector<ll>; 
using vvl = vector<vl>; 
using vs = vector<string>;
using vvs = vector<vs>; 
using vc = vector<char>;
using vvc = vector<vc>; 
using vb = vector<bool>;
using vvb = vector<vb>; 

#define rep(i,n) ;for( int i =0; i < n ; i ++)
#define all(a) a.begin(),a.end()
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define f(i,a,b) for(int i=a;i<b;i++)
#define pri(a)  printf("%.14lf\n",a);
#define sz(a) ((int)a.size())
#define MOD 1000000007
bool is_int_lround(double x){
  return std::lround(x)==x;
}
ll keta(ll x){
  ll n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}

ll conbi(int n,int m){
  
  cin>>n>>m;
  vector<ll> a(100);
  a[0] =1;
  for(int i=0;i<14;i++){
    a[i+1]=a[i]*(i+1);
  }
  return a[n] /(a[m] *a[n-m]);
}

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;//繰り返し二乗法
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
ll kaijoMOD(ll x){
  ll z=1;
  if(x==0){
    return 1;
  }
  while(x>0){
    z *=x;
    z %=MOD;
    x--;
  }
  return z;
}
ll div_num(ll n){
  vl div(n+1,1);
  for(ll i=2;i*i<=n;i++){ 
    while(n%i==0){
      n /=i;
      div[i]++;
    }
  }
  if(n!=1)div[n]++;
  ll num=1;
  for(ll i=0;i<=n;i++){
    num*=div[i];
  }
  return num;
}
vector<ll> divisor(ll n) {
  vector<ll> ret;
  for(ll i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

int keta_wa(int x){
  int tot=0;
  while(x>0){
    tot +=x%10;
    x/=10;
  }
  return tot;
}
long long lopow(ll a, long long n) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a ;
        a = a * a ;
        n >>= 1;
    }
    return res;
}


//vc alp ={'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'};
//vc Alp ={'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'};
//cout<<""<<endl;
vb seen(200001);
vvi G(200001);
vl pnt(200001);
void dfs(int unk){
  seen[unk] =true;
  for(int nu=0;nu<G[unk].size() ;nu++){
    if(seen[G[unk][nu]])continue;
    pnt[G[unk][nu]]+=pnt[unk];
    dfs(G[unk][nu]);
  }
  return;
}
int main(){
  int N,Q;cin>>N>>Q;vi a(N-1),b(N-1),p(Q),x(Q);
  rep(i,N-1)cin>>a[i]>>b[i];
  rep(i,Q)cin>>p[i]>>x[i];
  rep(i,N-1){
    G[a[i]].push_back(b[i]);
    G[b[i]].push_back(a[i]);
  }
  rep(i,Q)pnt[p[i]]+=x[i];
  rep(i,200001)seen[i]=false;
  dfs(1);
  for(int i=1;i<=N;i++){
    cout<<pnt[i];
    if(i!=N)cout<<" ";
  }
  cout<<endl;
  
    
}






Measured memory_bytes: 27392
#include <iostream>
#include <cstring>
#include <map>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
#include <queue>
#include <list>
#include <numeric>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <math.h>
#include <stack>
#include <climits>
#include <bitset>
#include <utility>


using namespace std;
typedef long long ll;

//最小公倍数
ll gcd(ll x, ll y) {
  ll tmp = 0;
  if (x < y){
    tmp=x;
    x=y;
    y=tmp;
  }
  while (y > 0) {
    ll r = x % y;
    x = y;
    y = r;
  }
  return x;
}

//最大公倍数
ll lcm(ll x,ll y){
  return x/gcd(x,y)*y;
}

//階乗
ll kaijo(ll k){
    ll sum = 1;
    for (ll i = 1; i <= k; ++i)
    {
        sum *= i;
        sum%=1000000000+7;
    }
    return sum;
}

//for(int i = ; i < ; i++){}

ll lmax(ll s,ll t){
  if(s>t){
    return s;
  }
  else{
    return t;
  }
}

ll lmin(ll s,ll t){
  if(s<t){
    return s;
  }
  else{
    return t;
  }
}
// ここから開始

int main(){
  int n,k;
  cin>>n>>k;
  ll sum = 0;
  for(int b = 1; b <= n; b++){
    int cnt = (n+1)/b;
    int md = (n+1)%b;
    sum+=cnt*max((b-k),0)+max((md-k),0);
    if(k==0) sum--;
  }
  cout<<sum<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast", "unroll-loops")
#define ll long long 
#define ull unsigned ll
#define REP(i,n) for (int i=0;i<(n);i++)
#define REP1(i,n) for(int i=1;i<=(n);i++)
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RREP(i,n) for (int i=n-1;i>=0;i--)
#define SZ(x) x.size()
#define ALL(x) x.begin(), x.end()
#define pb push_back 
#define pii pair<int, int>
#define SQ(x) (x)*(x)
#define ff first
#define ss second
#define endl '\n'
using namespace std;
main (){
	ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	int n; cin>>n; 
	vector<int> a(n), b(n), c(n-1);
	ll ans=0;
	REP(i,n) cin>>a[i]; 
	REP(i,n) {
		cin>>b[i]; 
		ans+=b[i];
	}
	REP(i,n-1) cin>>c[i];
	REP(i,n-1) if (a[i]+1==a[i+1]) ans+=c[a[i]-1];
	cout<<ans<<endl;

}
	


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

const ll mod = 1000000007;


int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
	int n, k; cin >> n >> k;
	double ans = 0;
	for(int i = 1; i <= n; i++){
		int score = i;
		double cnt = 1;
		while(score < k){
			score *= 2;
			cnt *= 2;
		}
		ans += 1/(n*cnt);
	}
	cout << fixed << setprecision(12) << ans << endl;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
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; }

int n;
vector<long long> dpall(1000100, 1e9);
vector<long long> dpodd(1000100, 1e9);
vector<long long> preall(220, 0);
vector<long long> preodd;

int main() {
    for(int i = 1; i <= 200; ++i) {
        preall.at(i-1) = (i*(i+1)*(i+2))/6;
        if(preall.at(i-1) % 2 != 0) {
            preodd.push_back(preall.at(i-1));
        }
    }
    int oddlen = preodd.size();

    dpall[0] = 0;
    for(int i = 1; i < 200; ++i) {
        for(int j = 0; j <= 1000010; ++j) {
            if(j-preall.at(i-1) >= 0) {
                chmin(dpall[j], dpall[j-preall.at(i-1)]+1);
            }
        }
    }

    dpodd[0] = 0;
    for(int i = 1; i < oddlen; ++i) {
        for(int j = 0; j <= 1000010; ++j) {
            if(j-preodd.at(i-1) >= 0) {
                chmin(dpodd[j], dpodd[j-preodd.at(i-1)]+1);
            }
        }
    }

    while(1) {
        cin >> n;
        if(n == 0) break;
        cout << dpall[n] << " " << dpodd[n] << endl;
    }
}


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

int main(){
  int n,a,b;
  cin >> n;
  while(n--){
    cin >> a >> b;

    if((a<0&&b<0) || (a>0&&b>0)){
      if(a<0){ a*=-1; b*=-1; swap(a,b);}
      int l = 0;
      while(a<b){
	int k = __builtin_ctz(a);
	while(a > b - (1<<k))k--;
	a += 1<<k;
	l++;
      }
      cout << l << endl;
    }else cout << __builtin_popcount(-a) + __builtin_popcount(b) << endl;
  }
}

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)  
#define ll long long
#define ld long double
#define repl(i, n) for (ll i = 0; i < (ll)(n); i++) 
#define forl(i, n, st) for (ll i = (ll)st; i < (ll)(n); i++) 

ll calc(string value, int keta)
{
  int MAX_N = 105;
  int MAX_K = 4;
  ll dp[2][MAX_N][MAX_K];
  dp[0][0][0] = 1;
  dp[1][0][0] = 1;
  
  rep(i, value.length() + 1)
  {
    
    rep(j, keta + 1)
    {
      rep(p, 2){
      	if(i < j)
        {
          dp[p][i][j] = 0;
        }
        else if(j == 0)
        {
          dp[p][i][j] = 1;
        }
        else{
          int x = i == 0 ? -1 : value[value.length()-i] - '0';
          if(p == 1){
            x = 9;
          }
          
          if(x == 0)
          {
              dp[p][i][j] = dp[p][i-1][j];
          }
          else
          {
            dp[p][i][j] = dp[p][i-1][j-1] + dp[1][i-1][j-1] * (x-1) + dp[1][i-1][j];
          }
        }
      }
    }
  }
  
  return dp[0][value.length()][keta];
}

int main()
{
  string n;
  int k;
  cin >> n >> k;
  cout << fixed << calc(n, k) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 1e9 + 7, MOD = 1e9 + 7;
const long long LINF = 1e18;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
int Digit_Sum(int n) {
	int Cmp = 0;
	while (n) {
		Cmp += n % 10;
		n /= 10;
	}
	return Cmp;
}
signed main() {
	int n;
	cin >> n;
	if (n % Digit_Sum(n) == 0)cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
/*  In the name of ALLAH */

#include<bits/stdc++.h>
using namespace std;
/*******  All Required define Pre-Processors and Constants    *******/

#define int long long
#define ull unsigned long long 
#define ld long double
#define mem(a, b) memset(a, (b), sizeof(a))
#define rep(i, j, k) for (int i = j ; i < k ; ++i)
#define rrep(i, j, k) for (int i = j; i > k; --i)
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define foreach(i, a) for(auto i: a)
#define forEach(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define in(A, B, C) assert( B <= A && A <= C)
#define debug(a) cout << #a << ": " << a << endl
#define Flag(n) cout << "here " << n << endl
#define w(x) int x;cin>>x;while(t--)
#define mp make_pair
#define pb push_back

#define endl '\n';
#define io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
const int POSITIVE_INFINITY = 9223372036854775807;
const int NEGATIVE_INFINITY = -9223372036854775807;
const int MOD = 1000000007;
const ld PI = acos(-1.0);
 

#define TRACE
#ifdef TRACE
#define see(...) __f(#__VA_ARGS__,__VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr<<name<<" : "<<arg1<<endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma=strchr(names+1,',');cerr.write(names,comma-names)<<" : "<<arg1<<" | ";__f(comma+1, args...);
}
#else
#endif



int32_t main() {
    io;
    // freopen("input.txt","r",stdin); 
    // freopen("output.txt","w",stdout);
  
    int n,x,t;
    cin>>n>>x>>t;
    int times = ceil(n*1.0/x);
    cout<<times*t<<endl;
    
 
    return 0;
}


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

int N;
int cnt = 0;
bool flg[10];

int main() {
   fill(flg, flg+10, false);
   cin >> N;
   for (int i = 0; i < N; i++) {
      int a;
      cin >> a;
      bool ok = false;
      for (int i = 1; i <= 8; i++) {
         if (a < 400 * i) {
            ok = true;
            flg[i-1] = true;
            break;
         }
      }
      if (!ok) cnt++;
   }

   int num = count(flg, flg+8, true);
   cout << max(1, num) << " ";
   cout << num + cnt << endl;

   return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <vector>
#include <cassert>

using namespace std; using ll=long long; const int INF=1e9;
typedef pair<int,int> P;

int main() {
  string s; cin>>s;
  if (s=="ABC") cout<<"ARC"<<endl;
  else cout<<"ABC";
}

Measured memory_bytes: 3592
n,x = map(int, input().split())
l = list(map(int, input().split()))

pos = 0
count = 0
i = 0

while i < len(l):
	if pos >= x:
		break
	pos += l[i]
	count += 1
	i += 1

if pos > x:
	print(count)
else:
	print(count+1)


Measured memory_bytes: 3060