akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#define MOD 1000000007
#define INT long long int
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
//const long long INF = numeric_limits<long long>::max();


int main()
{
    int N,M;
    string S;
    cin >> N>>M;
    cin >> S;

    bool flag = false;
    int cnt = 0;
    REP(i,S.size()-1){
        if (S[i]=='1' && S[i+1] == '1'){
            if (flag){
                cnt++;
                if (cnt>=M){
                    cout<<-1<<endl;
                    return 0;
                }
            }else{
                cnt = 2;
                flag = true;
                if (cnt>=M){
                    cout<<-1<<endl;
                    return 0;
                }
            }
        }else{
            flag = false;
        }
    }
    if (M==1){
        for (char s:S){
            if (s=='1'){
                cout<<-1<<endl;
                return 0;
            }
            
        }
    }
    if (M>=N){
        cout<<N<<endl;
        return 0;
    }
    int dp[N+M];
    REP(i,N+M) dp[i] = MOD;
    dp[0] = 0;
    int keiro[N+M];
    REP(i,N+M) keiro[i] = 0;
    int upd=0;
    REP(i,N+1){
        if (S[i]=='1')continue;
        flag = true;
        if (i==0) {
            for (int j=1;j<M+1;j++){
                int nxt = i+j;
                if (S[nxt]!='1'){
                    upd = nxt;
                    if (dp[nxt] > dp[i]+1){
                        dp[nxt] = dp[i]+1;
                        keiro[nxt] = j;
                        if (nxt == N){
                            flag = false;
                            break;
                        }
                    }
                }
            }
        }else{
            for (int j=upd-i+1;j<M+1;j++){
                int nxt = i+j;
                if (S[nxt]!='1'){
                    upd = nxt;
                    if (dp[nxt] > dp[i]+1){
                        dp[nxt] = dp[i]+1;
                        keiro[nxt] = j;
                        if (nxt == N){
                            flag = false; 
                            break;
                        }
                    }
                }
            }
        }
        
        if (!flag){
            break;
        }
    }
    vector<int> ans;
    int idx = N;
    cnt = 0;
    while (idx>0){
        ans.push_back(keiro[idx]);
        idx -= keiro[idx];
        cnt++;
        if (cnt >= 1000000) break;
    }
    int L = ans.size()-1;
    REP(i,ans.size()){
        cout<<ans[L-i]<<' ';
    }
    cout<<endl;






    return 0;
}

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

//typedef
//------------------------------------------
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int MOD = 1000000007;

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

//main code

int main(int argc, char const* argv[])
{
	LL n,m;
	cin >> n >> m;
	LL ans = 0;
	for (LL i = 1; i <= LL(sqrt(m)) + 1; i++) {
		if (m % i == 0) {
			LL part = m / i;
			if ((m - i*n) >= 0 and (m - i*n) % i == 0) {
				ans = max(ans,i);
			}
			if ((m - part*n) >= 0 and (m - part*n) % part == 0) {
				ans = max(ans,part);
			}
		}
	}
	cout << ans << endl;
	return 0;
}


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

int main() {
  
  int N; cin >> N; int count = 1; vector<int> vec(N);
  
  for (int i = 0; i < N; i++) cin >> vec[i];
  
  sort(vec.begin(), vec.end());
  
  for (int i = 0; i < N - 1; i++) {
    if (vec[i] != vec[i + 1]) count++;
  }
  
  cout << count << endl;
  
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {

  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    String s = scanner.next();
    int count0 = 0;
    for (int i = 0; i < s.length(); i++) {
      if (s.charAt(i) == '0') {
        count0++;
      }
    }
    int ans = count0 <= s.length() / 2 ? count0 : s.length() - count0;
    System.out.println(ans * 2);
  }

}


Measured memory_bytes: 24200
# -*- coding: utf-8 -*-

N, Y = map(int, input().split())

for x in range(N+1):
    for y in range(N-x+1):
        z = N - x - y
        if 10000 * x + 5000 * y + 1000 * z == Y:
            print(x, y, z)
            break
    else:
        continue
    break
else:
    print(-1,-1,-1)

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

const int N = 105;
int n, m, a[N];
int main() {
	std::ios::sync_with_stdio(0), std::cin.tie(0);
	std::cin >> n >> m;
	for (int i = 1; i <= m; ++i) std::cin >> a[i];
	std::sort(a + 1, a + m + 1, [] (int x, int y) { return (x & 1) > (y & 1); });
	if (a[3] & 1) return std::cout << "Impossible" << '\n', 0;
	if (m > 1) std::swap(a[2], a[m]);
	for (int i = 1; i <= m; ++i) std::cout << a[i] << " \n"[i == m];
	std::cout << m - (a[1] == 1) + (m == 1) << '\n';
	if (a[1] > 1) std::cout << a[1] - 1 << ' ';
	for (int i = 2; i <= m; ++i)
		std::cout << a[i] + (i == m) << ' ';
	if (m == 1) std::cout << 1 << ' ';
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;

int main(){
  ll n,k;
  cin >> n >> k;
  vector<ll> a(n);
  for(ll i=0;i<n;i++) cin >> a[i];
  ll sum=0;
  for(ll i=0;i<n;i++) sum+=a[i];
  vector<ll> ok;
  for(ll i=1;i*i<=sum;i++){
    if(sum%i==0){
      ok.push_back(i);
      ok.push_back(sum/i);
    }
  }
  sort(ok.begin(),ok.end());
  ll t=ok.size();
  for(ll i=t-1;i>=0;i--){
    ll cnt=0;
    ll now=0;
    ll p[n];
    ll c[n];
    for(ll j=0;j<n;j++) p[j]=a[j]%ok[i];
    sort(p,p+n);
    for(ll j=0;j<n;j++){
      now+=p[j];
      c[j]=p[j];
    }
    for(ll j=n-1;j>=0;j--){
      if(now==0) break;
      now-=ok[i];
      c[j]=ok[i]-c[j];
    }
    for(ll j=0;j<n;j++) cnt+=c[j];
    if(cnt<=2*k){
      cout << ok[i] << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 256
/* ex2_3 
　　terakura */
 
#include <stdio.h>
 
int main (void){
  int N , A ;
  
  /* NとAの値を入力 */
  scanf("%d" ,&N );
  scanf("%d" ,&A );
  
   /*黒色に塗ることになるマスの個数を出力 */
  printf("%d\n" , N*N - A);
  
  return 0;
}


Measured memory_bytes: 128
total_stay = int(input())
normal_stay = int(input())
normal_cost = int(input())
discounted_cost = int(input())
if total_stay <= normal_stay:
  total_cost = total_stay * normal_cost
else:
  total_cost = normal_stay * normal_cost + (total_stay - normal_stay) * discounted_cost
print(total_cost)

Measured memory_bytes: 9176
#include <iostream>
#include <atcoder/segtree>

namespace ac = atcoder;

constexpr int M = 300000;

int max(int a, int b) { return std::max(a, b); }
int zero() { return 0; }

void solve() {
    int n, k;
    std::cin >> n >> k;

    ac::segtree<int, max, zero> dp(M + 1);  // 最初は全て0
    while (n--) {
        int a;
        std::cin >> a;

        int l = std::max(a - k, 0),
            r = std::min(a + k, M);

        int len = dp.prod(l, r + 1);  // 半開区間
        dp.set(a, len + 1);
    }

    // dp配列全体の最大値が答え
    std::cout << dp.all_prod() << "\n";
}

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

    solve();

    return 0;
}


Measured memory_bytes: 8476
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>

#define MAX_N (100000)
#define INF (1000000000)
 
using namespace std;
 
int main() {
  // read inputs
  int N, K, hs[MAX_N];
  scanf("%d %d", &N, &K);
  for (int i = 0; i < N; i++) {
    scanf("%d", &hs[i]);
  }

  // solve dp
  int dps[MAX_N];
  // initialize
  dps[N - 1] = 0;
  // update
  for (int i = N - 2; i >= 0; i--) {
    dps[i] = INF;
    for (int j = i + 1; j <= min(i + K, N - 1); j++) {
      dps[i] = min(dps[i], dps[j] + abs(hs[j] - hs[i]));
    }
  }
  printf("%d\n", dps[0]);
}

Measured memory_bytes: 896
#include <stdio.h>

static int p[ 1299710 ] = { 1, 1, 0 };
static int q[ 1299710 ] = { 1, 1, 0 };

/** Application main entry point. */
int
main (
  int     argc,
  char  * argv[ ]
  )
{
  int i, j;

  for ( i = 2; i * i <= 1299709; ++i )
  {
    if ( p[ i ] ) continue ;

    for ( j = i * i; j <= 1299709; j += i )
    {
      p[ j ] = 1;
    }
  }
  for ( i = 1299709; i >= 2; --i )
  {
    q[ i ] = !!( p[ i ] )
           ? q[ i + 1 ]
           : i;
  }
  for ( i = 2; i <= 1299709; ++i )
  {
    p[ i ] = !!( p[ i ] )
           ? p[ i - 1 ]
           : i;
  }

  for ( ; ; )
  {
    int n;

    scanf ( "%d", &n );
    if ( !( n ) ) break ;

    printf ( "%d\n", q[ n ] - p[ n ] );
  }

  return ( 0 );
}

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

int main()
{
   int d, g;
   cin >> d >> g;
   vector<int>p(d);
   vector<int>c(d);
   rep(i,d) {
      cin >> p[i] >> c[i];
   }

   vector<bool> used(d);
   int ans = INF;
   rep(i,1 << d)
   {
      int sum =0;
      int tmp = 0;
      rep(a,d) used[a] = false;
      rep(j, p.size())
      {
         if(i >> j&1)
         {
            //この配列を使う場合
            sum += p[j] * (j+1) * 100 + c[j];
            tmp += p[j];
            used[j] = true;
         }
      }
      int index = -1; 
      for(int k = p.size() -1; k >=0; k--)
      {
         if(!used[k])
         {
            index = k;
            break;
         }
      }
      if(index == -1) 
      {
         //全使用
         if(sum >= g) ans = min(ans, tmp);
      }
      else{
      rep(k,p[index]+1){
         if(sum >= g)
         {
            //全使用
            ans = min(ans, tmp);
            break;
         }
         sum += (index+1) * 100;
         tmp++;
      }
      }
   }
   cout << ans << endl;
}

Measured memory_bytes: 256
a = int(input())
b= int(input())
c= int(input())
d= int(input())
e= int(input())
k= int(input())

if b-a > k or c-b>k or d-c>k or e-d>k or c-a>k or d-a>k or e-a>k or d-b >k or e-b>k or e-c>k:
  print(':(')
else:
  print('Yay!')

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
	int n;
	cin >> n;
	long x, y, z;
	long long ans = 0;
	cin >> y;
	if (n > 2) {
		for (int i = 0; i < n - 2; i++) {
			x = y;
			cin >> y;
			if (i == 0) {
				ans += x;
			}
			ans += min(x, y);
			if (i == n - 3) {
				ans += y;
			}
		}
		cout << ans;
	}
	else { cout << 2*y; }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
long long N;
vector<long long> a(45000),b(45000),c(45000);
long long d[310][310];
bool q[310][310];
 
int main(){
  cin >> N; long long ans=0;
  for(int i=1;i<=N;i++){
    for(int j=1;j<=N;j++){
      cin >> d[i][j]; 
      ans+=d[i][j];
    }
  }
  
  for(int k=1;k<=N;k++){
    for(int i=1;i<=N;i++){
      for(int j=1;j<=N;j++){
        //最短距離ではなかった場合
        if(d[i][j]>d[i][k]+d[k][j]){cout << -1 << endl; return 0;}
        //他の道が最短距離と等しかった場合、直通路は不要
        if(d[i][j]==d[i][k]+d[k][j] && k!=i && k!=j){
          if(!q[i][j]){ans-=d[i][j]; q[i][j]=true;}
        }
      }
    }
  }
  ans/=2;
  cout << ans << endl;
}

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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define sll(x) scanf("%lld",&x)
#define prll(x) printf("%lld ",x)
#define pri(x) printf("%d ",x)
#define si(x) scanf("%d",&x)
#define el cout << "\n"
#define pb push_back
#define f first
#define s second
#define arrondi(a) (long long)floor(a+0.5);
#define NIL -1
ll N=500005;
ll MAX=9223372036854775807;
ll MOD=1000000007;
long double PI =4*atan(1);
ll n,m;
vector <string> A;
int dx[] = {1,0,0,-1};
int dy[] = {0,1,-1,0};
ll dist[30][30];
bool valid(int x,int y)
{
    return (x>=1 && x<=n && y>=1 && y<=m);
}
bool visited[30][30];
ll ans;
void bfs(pair<ll,ll> source)
{
    queue <pair<ll,ll> >q;
    q.push(source);
    dist[source.first][source.second]=0;
    visited[source.first][source.second]=true;
    while(!q.empty())
    {
        pair<ll,ll> v=q.front();
        q.pop();
        for (int i=0;i<4;i++)
        {
            ll row=v.first+dx[i];
            ll col=v.second+dy[i];
            if (valid(row,col) && A[row-1][col-1]=='.' && visited[row][col]==false)
            {
                visited[row][col]=true;
                dist[row][col]=dist[v.first][v.second]+1;
                ans=max(dist[row][col],ans);
                q.push(make_pair(row,col));
            }
        }
    }
}
int main()
{
    IOS;
    cout.precision(30);
    string s;
    cin >> n >> m;
    for (int i=1;i<=n;i++) for (int j=1;j<=m;j++){visited[i][j]=false; dist[i][j]=MAX;}

    for(int i = 1; i <= n; i++)
    {
        cin >> s;
        A.push_back(s);
    }
    ll ANS=0;
    for (int i=1;i<=n;i++)
    {
        for (int j=1;j<=m;j++)
        {
            if (A[i-1][j-1]=='.')
            {
                ans=0;
                bfs(make_pair(i,j));
                memset(visited,false,sizeof visited);
                ANS=max(ANS,ans);
            }
        }
    }
    cout << ANS << "\n";
}



Measured memory_bytes: 3652
#include<iostream>
#include<cstring>
#include<algorithm>
#include<vector>
#include<cstdio>
#include<cmath>
#define pb(in,tmp) in.push_back(tmp)
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,b) loop(i,0,b)
#define all(in) in.begin(),in.end()
using namespace std;
int main(){
int n;
while(cin>>n,n){
vector<int>in;
rep(i,n){
int tmp;
cin>>tmp;
pb(in,tmp);
}
sort(all(in));
int sum=0;
loop(i,1,in.size()-1)sum+=in[i];
cout<<(int)(sum/(n-2))<<endl;
}
}

Measured memory_bytes: 1220
#include<cstdio>
using ll = long long;
using ull = unsigned long long;

int main(){
	ull N;
	char B[5];
	scanf("%llu %s", &N, B);
	ull b = 0;
	b += (B[0] - '0')*100;
	b += (B[2] - '0')*10;
	b += (B[3] - '0');
	printf("%llu\n", N*b/100ULL);
	return 0;
}

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

char cmaps[1028][1028];
int maps[1028][1028];

int main(){
  int n;
  int ans;
  while(true){
    cin >> n;
    if(!n){
      break;
    }
    
    ans = 0;
    for(int i = 0; i < n; i++){
      for(int j = 0; j < n; j++){
	cin >> cmaps[i][j];
	if(cmaps[i][j] == '.'){
	  maps[i][j] = 1;
	  ans = 1;
	}
	else{
	  maps[i][j] = 0;
	}
      }
    }

    for(int i = 1; i < n; i++){
      for(int j = 1; j < n; j++){
	if(maps[i][j] && maps[i - 1][j - 1] && maps[i- 1][j] && maps[i][j - 1]){
	  int temp;
	  temp = min(maps[i][j - 1], maps[i - 1][j]);
	  maps[i][j] += min(temp, maps[i - 1][j - 1]);
	  ans = max(maps[i][j] , ans);
	}
      }
    }
    /*
    for(int i = 0; i < n; i++){
      for(int j = 0; j < n; j++){
	printf("%d ", maps[i][j]);
      }
      printf("\n");
    }
    */
    cout << ans << endl;
  }
  return 0;

}

Measured memory_bytes: 4772
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
class Program
{
    static void Main(string[] args)
    {
            // 入力
            string[] sS = System.Console.ReadLine().Trim().Split(' ');
            int iN = int.Parse(sS[0]);
            sS = System.Console.ReadLine().Trim().Split(' ');
            int iOut = 0;
            for (int i = 0; i < sS.Length; i++)
            {
                int iA = int.Parse(sS[i]);
                if (i % 2 == 0 && iA % 2 == 1) { iOut += 1; }               // マスが奇数(0始まりなので1ずれる)で中身も奇数
            }

            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
            sw.Start();

            // 解析 // 出力
            System.Console.WriteLine("{0}", iOut.ToString().Trim());

            sw.Stop();
#if DEBUG
            Console.WriteLine();
            Console.WriteLine("{0}", sw.Elapsed.ToString());
            Console.WriteLine("続行するには何かキーを押してください．．．");
            Console.ReadKey();
#endif
    }

}


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

int main() {
  int n = 3;
  int sum_arr = 0;
  vector<int> arr(n);
  for (int i = 0; i < n; ++i) {
    cin >> arr[i];
    sum_arr += arr[i];
  }
  sort(arr.rbegin(), arr.rend());
  int cnt = 0;
  while(sum_arr % 3 != 0 or sum_arr < arr[0] * 3) {
    ++cnt;
    sum_arr += 2;
  }
  cout << cnt << endl;
}


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

int main(){
    int n;
    cin>>n;
    map<string,int>T;
    rep(i,n){
        string s;
        cin>>s;
        T[s]++;
    }
    int mx=0;
    pair<string,int> item;
    for(map<string,int>::iterator it=T.begin();it!=T.end();it++){
        item=*it;
        mx=max(item.second,mx);
    }

    for(map<string,int>::iterator it=T.begin();it!=T.end();it++){
        item=*it;
        if(item.second==mx)cout<<item.first<<endl;
    }
    
}

Measured memory_bytes: 27280
#include<bits/stdc++.h>
using namespace std;
string s;
void up(int j){
  if(s[j]+1>'Z')s[j]='A';
  else s[j]++;
}
void down(int j){
  if(s[j]-1<'A')s[j]='Z';
  else s[j]--;
}
int main(){
  while(cin>>s,s!="."){
    reverse(s.begin(),s.end());
    for(int i=0;i<(int)s.size();i++)
      if(s[i]=='?'){
        for(int j=i+1;j<(int)s.size();j++)
	  if(s[j]=='+'||s[j]=='-')s.erase(s.begin()+j),j--;
          else break;
       s[i]='A';
      }
      else if(isalpha(s[i])){
        for(int j=i+1;j<(int)s.size();j++)
	  if(s[j]=='+')up(i),s.erase(s.begin()+j),j--;
          else if(s[j]=='-')down(i),s.erase(s.begin()+j),j--;
	  else break;
      }
    reverse(s.begin(),s.end());
    stack<int>st;
    for(int i=0;i<(int)s.size();i++){
      if(s[i]=='[')st.push(i),s.erase(s.begin()+i),i--;
      else if(s[i]==']'){
	int p=st.top();st.pop();
	s.erase(s.begin()+i);
	reverse(s.begin()+p,s.begin()+i--);
      }
    }
    cout<<s<<endl;
  }
}

Measured memory_bytes: 3140
#include<iostream>
#include<string>
using namespace std;
int main(void){
  int a, c;
  cin >> a >> c;
  if(a == c) cout << "Draw" <<endl;
  else if(a == 1) cout << "Alice" <<endl;
  else if(c == 1) cout << "Bob" <<endl;
  else if(a < c) cout << "Bob" <<endl;
  else cout << "Alice" <<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <climits>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstring>
#include <chrono>
#include <complex>
#define ll long long int
#define si(x) scanf("%d", &x)
#define sl(x) scanf("%lld", &x)
#define ss(s) scanf("%s", s)
#define pi(x) printf("%d\n", x)
#define pl(x) printf("%lld\n", x)
#define ps(s) printf("%s\n", s)
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define loop(i, L, R) for (int i = L; i < R; ++i)
#define looprev(i, L, R) for (int i = L; i > R; --i)
#define MAX(x, y) (x > y ? x : y)
#define MIN(x, y) (x < y ? x : y)
#define wh(t) while (t--)
#define pii pair<int, int>
#define ppi pair<int, pii>
#define pll pair<ll, ll>
#define ppl pair<ll, pll>
#define vii vector<int>
#define vvi vector<vii>
#define vl vector<ll>
#define vvl vector<vl>
#define maxHi priority_queue<int>
#define maxHl priority_queue<ll>
#define minHi priority_queue < int, vector<int>, greater<int>>
#define minHl priority_queue < ll, vector<ll>, greater<ll>>
#define mod 1000000007
#define inf 1000000000000000001
#define PI 3.1415926535897932384626
#define all(x) x.begin(), x.end()
#define sortall(x) sort(all(x))
#define mp(x, y) make_pair(x, y)
#define mem(a, val) memset(a, val, sizeof(a))
#define eb emplace_back
#define pb push_back
#define F first
#define S second
#define IOS ios_base::sync_with_stdio(false)
#define endl "\n"
using namespace std;

/*  AH SH*T,  HERE WE GO AGAIN.  */


void solve()
{
    ll i, j, n, m, q, a, b;


    sl(n);

    std::vector<ll> v(n);
    
    unordered_map<ll,ll> umap;

    ll sum = 0;


    loop(i, 0, n)
    {

        sl(v[i]);
        
        umap[v[i]]++;

        sum += v[i];
    }


    sl(q);



    while (q--)
    {


        sl(a);

        sl(b);


    
                
        sum = sum - a*umap[a] + b*umap[a];
        
       
        
        umap[b]+=umap[a];
        
         umap[a]=0;
        
 
        cout << sum << endl;


    }



}


int32_t main()
{

    IOS;
    cin.tie(NULL);

    int T = 1;


    wh(T)
    {

        solve();

    }
}

Measured memory_bytes: 7880
from itertools import combinations

n,k = map(int,input().split())
xy = [list(map(int,input().split())) + [i] for i in range(n)]
x_order = sorted(xy)
y_order = sorted(xy,key = lambda x:x[1])

pos = [[None]*2 for _ in range(n)]

for i,(x,y,j) in enumerate(x_order):
    pos[j][0] = i
for i,(x,y,j) in enumerate(y_order):
    pos[j][1] = i

count = [[0] * (n+1) for _ in range(n+1)]

for x,y in pos:
    count[y+1][x+1] += 1

for i in range(n+1):
    for j in range(1,n+1):
        count[i][j] += count[i][j-1]

for i in range(n+1):
    for j in range(1,n+1):
        count[j][i] += count[j-1][i]

ans = float('inf')
for x1,x2 in combinations(range(1,n+1),2):
    for y1,y2 in combinations(range(1,n+1),2):
        if count[y2][x2] - count[y2][x1-1] - count[y1-1][x2] + count[y1-1][x1-1] >=k:
            S = (x_order[x2-1][0] - x_order[x1-1][0]) * (y_order[y2-1][1] - y_order[y1-1][1])
            ans = min(ans, S)
print(ans)

Measured memory_bytes: 3188
#include<bits/stdc++.h>
#define Open(s) freopen(s".in","r",stdin);freopen(s".out","w",stdout);
#define inl inline
#define reg register
#define i64 long long 
using namespace std;
inl int read(){int x=0,f=0;char ch=0;while(!isdigit(ch))f|=(ch=='-'),ch=getchar();while(isdigit(ch))(x*=10)+=(ch^48),ch=getchar();return f?-x:x;}
inl void Ot(reg int x){if(x<0)x=-x,putchar('-');if(x>=10)Ot(x/10);putchar(x%10+'0');}
inl void Print(reg int x,char til='\n'){Ot(x);putchar(til);}
inl int Max(reg int x,reg int y){return x>y?x:y;}
inl int Min(reg int x,reg int y){return x<y?x:y;}
inl int Abs(reg int x){return x<0?-x:x;}
signed main(){
	#ifndef ONLINE_JUDGE
		//freopen("../../data.in","r",stdin);
	#endif
	char ch;
	scanf("%c",&ch);
	putchar(ch+1),putchar('\n');
	return 0;
}

Measured memory_bytes: 256
h, w, k = gets.split.map(&:to_i)
s = h.times.map{gets.chomp}

ans_table = Array.new(h){Array.new(w, 1)}
now = 1
h.times do |i|
  if s[i].include?('#')
    first_ichigo = false
    w.times do |j|
      ans_table[i][j] = now
      if s[i][j] == '#' && first_ichigo
        now += 1
        ans_table[i][j] = now
      elsif s[i][j] == '#'
        first_ichigo = true
      end
    end
    now += 1
  else
    if i > 0
      w.times do |j|
        ans_table[i][j] = ans_table[i - 1][j]
      end
    end
  end
end

h.times do |i|
  if h - i - 1 < h - 1 && !s[h - i - 1].include?('#')
    w.times do |j|
      ans_table[h - i - 1][j] = ans_table[h - i][j]
    end
  end
end

h.times do |i|
  puts ans_table[i].join(' ')
end


Measured memory_bytes: 3196
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    a = input().split()
    a = list(map(lambda x: x.capitalize(), a))
    a,b,c = a
    print(a[0]+b[0]+c[0])
    return

#B
def B():
    return

#C
def C():
    return

#D
def D():
    s = S()
    for i in range(len(s) - 1):
        if s[i] == s[i+1]:
            print(i + 1, i + 2)
            return
    for i in range(len(s) - 2):
        if s[i] == s[i + 2]:
            print(i + 1, i + 3)
            return
    print(-1, -1)

    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == '__main__':
    A()


Measured memory_bytes: 38640
#include<iostream>
#include<vector>
#include<cmath>

using namespace std;

int main(){
    int N, K;
    int s = 1;
    cin >> N >> K;
    while(N > 0){
        if(s < K){
            s *= 2;
        }else{
            s += K;
        }
        N--;
    }
    cout << s << endl;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int main(){
    int n,m;
    cin >> n >> m;
    vector<vector<int>> denkyu(m);
    vector<int> joken(m);
    int ans=0;
    rep(i,m){
        int k;
        cin >> k;
        rep(j,k){
            int s;
            cin >> s;
            s--;
            denkyu[i].push_back(s);
    }
    }
    rep(i,m){
        cin >> joken[i];
    }
    rep(bit,1<<n){
        vector<int> swichon(m);
        bool ok=true;
        rep(i,m){
            rep(j,denkyu[i].size()){
                if(bit>>denkyu[i][j]&1){
                    swichon[i]++;
                }
            }
        }
        rep(i,m){
            if(swichon[i] %2 != joken[i] ) ok=false;
        }
        if(ok) ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String s = br.readLine();
		String[] array = s.split(" ");
		int a = Integer.parseInt(array[0]);
		int b = Integer.parseInt(array[1]);

		if ((a + b) < 24) {
			System.out.println(a + b);
		} else {
			System.out.println((a + b) - 24);
		}
	}
}


Measured memory_bytes: 21332
using System;
using System.Linq;
namespace Sample
{
  class Sample
  {
    static void Main(string[] args)
    {
    string str=Console.ReadLine();
      int tmp=0;
      int ans=0;
      if(str=="RRR"){
        ans=3;
      }else if(str=="RRS"||str=="SRR"){
        ans=2;
      }else if(str=="SSS")
      {ans=0;
      }
      else{
       ans=1; 
      }
      Console.WriteLine(ans);
    }
    
  }

}


Measured memory_bytes: 25756
#include <bits/stdc++.h>
using namespace std;
int main(void){
    
    //*
    int cnt = 0;
    string a, b;
    cin >> a >> b ;
    //*/

    /*
    vector<int> vec(3);
    cin >> vec.at(0) >> vec.at(1) >> vec.at(2) ;

    sort(vec.begin(), vec.end());
    //*/
    
    for(int i = 0 ; i < a.size(); i++){
        if(a.at(i) != b.at(i)){
            cnt++;
        }
    }
    
    //*
    if( cnt == 0 ){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    //*/
    
    //cout << ((floor(a / 2) + fmod(a, 2)) / a) << endl;
    
    return 0; 
}


Measured memory_bytes: 3608
s=int(input())
e = set([s])
a = s
for i in range(1,1000000):
    if a%2 == 0:
        a = a//2
    else:
        a = 3*a+1
    
    e |= e^set([a])
    
    if len(e) == i:
        print(i+1)
        break
    

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;cin>>n;
  double jpy=0,btc=0;
  for(int i=0;i<n;i++){
    double s;string t;cin>>s>>t;
    if(t=="JPY") jpy+=s;else btc+=s;
  }
  cout<<setprecision(8)<<jpy+380000*btc<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mod 1000000007
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define nyan "(=^･ω･^=)"
#define mkp make_pair
#define lP pair<ll, ll>
#define iP pair<int,int>
typedef long long ll;
using namespace std;

int N;
double p, DP[3001], res;

int main() {
	cin >> N;
	DP[0] = 1;
	for (int i = 0; i != N; ++i) {
		cin >> p;
		for (int j = i; j != -1; --j) {
			DP[j + 1] += DP[j] * p;
			DP[j] = DP[j] * (1 - p);
		}
	}
	for (int i = N / 2 + 1; i != N + 1; ++i)
		res += DP[i];
	printf("%.10f",res);
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
    public static void main(String[]args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        for(int i = 0; i < n; i++){
            a[i] = sc.nextInt();
        }
        
        if(n%2 == 0){
            for(int i = n-1; i >= 0; i-=2){
                System.out.print(a[i]+" ");
            }
            for(int i = 0; i < n; i+=2){
                System.out.print(a[i]+" ");
            }
        }else{
            for(int i=n-1; i>=0; i-=2){
                System.out.print(a[i]+" ");
            }
            for(int i=1; i<n; i+=2){
                System.out.print(a[i]+" ");
            }
        }
    }
}

Measured memory_bytes: 91284
# -*- coding: utf-8 -*-

## Library

import sys
from fractions import gcd
import math
from math import ceil,floor
import collections
from collections import Counter
import itertools

## input

# n=int(input())
# A,B,C,D=map(int, input().split())
# string = input()
# yoko = list(map(int, input().split()))
# tate = [int(input()) for _ in range(N)]
# N, M = map(int,input().split()) 
#    P = [list(map(int,input().split())) for i in range(M)]

N = int(input())
A = [int(input()) for _ in range(N)]
C = collections.Counter(A)
data = list(C.values())

ans = 0

for i in range(len(data)):
    if data[i] % 2 == 1:
        ans+=1

print(ans)

Measured memory_bytes: 100008
#include <bits/stdc++.h>
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
 
typedef pair <int,int> pii;
typedef vector <int> vi;
typedef vector <vi> vvi;
typedef long long int lli;
typedef vector <lli> vlli;
typedef vector <vlli> vvlli;
typedef vector <string> vs;
typedef vector <bool> vb;
 
#define rep(i, n) for( i = 0; i < (n); ++i)
#define repA(i, a, n) for( i = a; i <= (n); ++i)
#define repD(i, a, n) for( i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sortr(x) sort(x.begin(),x.end(),greater <int> ())
#define mod 1000000007
#define ff first
#define ss second
#define fill(a,c)  memset(a, c, sizeof (a))
#define formap(i,v) for(auto &i: v)
#define dbg(x) cout << #x << " = " << x << '\n'
#define dbg2(x,y) cout<<#x<<" = "<<x<<" & "<<#y<<" = "<<y<<endl;
#define dbgstl(v) cout<<#v<<" = \n"; { int c=0; formap(it,v) \
cout<<"    "<<#v<<"["<< ++c <<"] = "<<it<<endl;} cerr<<endl
#define dbgstlp(v) cout<<#v<<" = \n"; { int c=0; formap(it,v) \
cout<<"    "<<#v<<"["<< ++c <<"] = "<<it.first<<" , "<<it.second<<endl;} cerr<<endl
#define PI  3.14159265358979323846
#define pb push_back




int main() {
	cin.sync_with_stdio(0);cin.tie(0);
    cin.exceptions(cin.failbit);
    
    int i;
    string s,ans;
    cin>>s;
    rep(i,3)ans+=s[i];
    cout<<ans<<endl;
    
    
    
    
    
    
	return 0;
	
}

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

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

int main() {
  ll n;
  cin >> n;
  vector<ll> a(n+1), b(n);
  rep(i, n+1) cin >> a[i];
  rep(i, n) cin >> b[i];
  ll ans = 0;
  repr(i, n+1) {
    //printf("b[i-1]: %lld, a[i]: %lld\n", b[i-1], a[i]);
    if (b[i-1] - a[i] >= 0) {
      b[i-1] -= a[i];
      //printf("b[%d]が%lld撃破\n", i-1, a[i]);
      ans += a[i];
      a[i] = 0;
    }
    else {
      a[i] -= b[i-1];
      //printf("b[%d]が%lld撃破\n", i-1, b[i-1]);
      ans += b[i-1];
      b[i-1] = 0;
    }
    //printf("b[i-1]: %lld, a[i-1]: %lld\n", b[i-1], a[i-1]);
    if (b[i-1] - a[i-1] >= 0) {
      b[i-1] -= a[i-1];
      //printf("b[%d]が%lld撃破\n", i-1, a[i-1]);
      ans += a[i-1];
      a[i-1] = 0;
    }
    else {
      a[i-1] -= b[i-1];
      //printf("b[%d]が%lld撃破\n", i-1, b[i-1]);
      ans += b[i-1];
      b[i-1] = 0;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <vector> //動的配列
#include <string>
#include <list> //双方向リスト
#include <map> //連想配列
#include <set> //集合
#include <stack>
#include <queue>
#include <deque>
#include <cmath>
#include <bitset>
#include <numeric>



typedef long long ll;


using namespace std;

typedef pair<int, int> P;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)



ll fast_pow(ll x,ll n,ll mod){
    if (n==0) return 1;
    ll res=fast_pow(x*x %mod,n/2,mod);
    if (n&1) res=res*x%mod;
    return res;
}

template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

//小さい順から取り出すヒープ
//priority_queue<ll, vector<ll>, greater<ll> > pque1;




int main(){
    int n;
    cin>>n;
    ll a[n+100];
    ll cnt=0;
    ll m;
    rep(i,n){
        cin>>m;
        cnt=cnt^m;
    }
    if (cnt==0){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
}


Measured memory_bytes: 256
import java.util.*;


public class Main {
	public static void main(String[]args) {
		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		int A[] = new int[N];
		List<Integer> list = new ArrayList<>();
		//リストにAの要素を入れて昇順に並び替える
		for(int i=0; i<N; i++) {
			A[i]= sc.nextInt();
			list.add(A[i]);
		}
		Collections.sort(list);
		
		//要素最大値のときは2番目の最大値を表示し、
		//それ以外は最大値を表示させればよい
		for(int i=0; i<N; i++) {
			if(A[i]==list.get(N-1)) {
				System.out.println(list.get(N-2));
			}else {
				System.out.println(list.get(N-1));
			}
		}
	}
}

Measured memory_bytes: 67080
#include <algorithm>
#include <climits>
#include <cmath>
#include <iostream>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <vector>

const int mod = 1e9 + 7;
const int kmax = 510000;

long long fact[kmax], fact_inv[kmax], inv[kmax];

int gcd(int a, int b)
{
    if (!b) {
        return a;
    }

    return gcd(b, a % b);
}

void init_comb()
{
    fact[0] = fact[1] = 1;
    fact_inv[0] = fact_inv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < kmax; i++) {
        fact[i] = fact[i - 1] * i % mod;
        inv[i] = mod - inv[mod % i] * (mod / i) % mod;
        fact_inv[i] = fact_inv[i - 1] * inv[i] % mod;
    }
}

long long comb(int n, int r)
{
    if (n < r) {
        return 0;
    }

    if (n < 0 || r < 0) {
        return 0;
    }

    return fact[n] * (fact_inv[r] * fact_inv[n - r] % mod) % mod;
}

int main()
{
    init_comb();

    int n, m, k;
    std::cin >> n >> m >> k;

    long long comb_value = comb(n * m - 2, k - 2);
    long long ans = 0;
    for (int x_distance = 1; x_distance < m; x_distance++) {
        ans += comb_value * n * n % mod * (m - x_distance) * x_distance % mod;
        ans %= mod;
    }

    for (int y_distance = 1; y_distance < n; y_distance++) {
        ans += comb_value * m * m % mod * (n - y_distance) % mod * y_distance % mod;
        ans %= mod;
    }

    std::cout << ans << std::endl;
}


Measured memory_bytes: 12160
// abc156_a
#include <iostream>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>

#define US unsigned short
#define UI unsigned int
#define UC unsigned char
#define UL unsigned long
#define ULL unsigned long long
using namespace std;

int main(int argc, char const *argv[])
{
    US n, r;
    cin >> n >> r;
    if (n >= 10)
    {
        cout << r << endl;
    }
    else
    {
        cout << r + 100 * (10 - n) << endl;
    }
}


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

int main()
{
  int N, K;
  cin >> N >> K;
  int ans = 1000000000;
  for (int bit = 0; bit < (1 << N); bit++)
  {
    int tmp = 1;
    for (int i = 0; i < N; i++)
    {
      if (bit & (1 << i))
      { 
        tmp *= 2;
      }
      else
        tmp += K;
    }
    ans = min(tmp, ans);
  }
  cout << ans << endl;
}

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

e_list = [[] for i in range(N)]

for i in range(N-1):
    u,v = list(map(int,input().split()))
    u,v = u-1,v-1
    e_list[u].append(v)
    e_list[v].append(u)

from collections import deque

vi = 0  #change
INF = float('inf')

Q = deque([vi])

checked_list = [False]*N
checked_list[vi]=True

parent_list = [-1]*N
while len(Q)>0:
    v = Q.pop()
    for v1 in e_list[v]:
        if not checked_list[v1]:
            checked_list[v1]=True
            Q.appendleft(v1)
            parent_list[v1] = v
ans = 0
for i in range(N):
    if parent_list[i]==-1:
        ans += (i+1)*(N-i)
    else:
        if parent_list[i]>i:
            ans += (i+1)*(parent_list[i]-i)
        else:
            ans += (i-parent_list[i])*(N-i)
print(ans)

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

namespace AtCoder_Project_CSharp
{
    class Program
    {
        
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            Console.WriteLine(n < 1000 ? "ABC" : "ABD");
        }
    }
}


Measured memory_bytes: 13140
/*
  Motto - try hard to become an expert
*/
#include <bits/stdc++.h>
#include <map>
#include <algorithm>
#include <vector>
#include <string.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <chrono>
#include <thread>
#include <iomanip>
 
//define
#define rep(i,n)    for(int i=0;i<n;i++)
#define repu(i,k,n) for(int i=k;i<=n;i++)
#define repd(i,k,n) for(int i=k;i>=n;i--)
#define se second
#define fi first
#define pb push_back
#define mp make_pair
#define INF (int)INT_MAX
#define all(v)  v.begin(), v.end()
#define endl "\n"
 
//typedef
typedef long long int ll;
typedef long double ld;
typedef std::pair<int, int> pii;
typedef std::vector<int> vi;
typedef std::vector< pii > vii;
typedef std::vector< ll > vll;
typedef std::vector< std::pair < pii, int > > vpp;
 
const int N = 2*1e5+5 ;
const long long MOD = 1e9 + 7;
const long long inf = 1e18;
 
using namespace std;
 

// ll modpow(ll x,ll n){
//     ll res=1;
//     while(n>0){
//         if(n&1) res=res*x%MOD;
//         x=x*x%MOD;
//         n>>=1;
//     }
//     return res;
// }
 
// ll modFact(ll n, ll p) 
// { 
//     if (n >= p) 
//         return 0; 
  
//     ll result = 1; 
//     for (ll i = 1; i <= n; i++) 
//         result = (result * i) % p; 
  
//     return result;  
// } 
 
// bool isPrime(int x)
// {
//     if(x%2==0)
//         return 0;
//     for(int i=3;i<=sqrt(x);i+=2)
//     {
//         if(x%i==0)
//             return 0;
//     }
//     return 1;
// }
 
// ll binomialCoeff(ll n, ll k) 
// { 
// 	ll C[n + 1][k + 1]; 
// 	ll i, j; 


// 	for (i = 0; i <= n; i++) 
// 	{ 
// 		for (j = 0; j <= min(i, k); j++) 
// 		{ 
			
// 			if (j == 0 || j == i) 
// 				C[i][j] = 1; 

// 			else
// 				C[i][j] = (C[i - 1][j - 1] + 
// 										C[i - 1][j])%MOD; 
// 		} 
// 	} 

// 	return C[n][k]; 
// }
// bool compare(const string &a , const string&b){
	
// }
// int a[N] ;
void solve()
{
	int ans= 0 ;
	int n ;
	int is_there  = -1 ;
	cin>>n ;
	int c[n] , v[n] ;
	
	rep(i , n)cin>>v[i] ;
	rep( i , n)cin>>c[i] ;
	rep( i , n){
		if(v[i]-c[i]>=0){
			is_there = 1 ;
			ans += v[i]-c[i] ;
		}
	}
	cout<<ans<<endl;
}
 
int main() {
    #ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
    #endif
    
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    int t = 1;
    // cin>>t;b
    while(t--)
    {
        solve();
    } 
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}

Measured memory_bytes: 3744
#include"bits/stdc++.h"

using namespace std; 

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef pair<LL, LL> PLL;
typedef vector<PLL> VPLL;
typedef priority_queue<int> PQ_DESC;
typedef priority_queue<int, vector<int>, greater<int>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;
typedef priority_queue<VL> PQ_DESC_VL;
typedef priority_queue<VL, vector<VL>, greater<VL>> PQ_ASC_VL;
typedef priority_queue<PLL> PQ_DESC_PLL;
typedef priority_queue<PLL, vector<PLL>, greater<PLL>> PQ_ASC_PLL;

#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define MP make_pair
#define SORT_ASC(c) sort(ALL(c))
//#define SORT_DESC(c) sort(ALL(c), greater<typeof(*((c).begin()))>())
#define SORT_DESC(c) sort((c).rbegin(),(c).rend())
#define REV(c) reverse((c).begin(), (c).end())
#define SIZE(a) int((a).size())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ROF(i,a,b) for(int i=(b-1);i>=(a);--i)
#define REP(i,n) FOR(i,0,n)
#define PER(i,n) ROF(i,0,n)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int LARGE_INT = 1e9+100;
const int INF = 2e9+100;
const LL INF_LL = (LL)INF*(LL)INF;
const int MOD = 1e9+7;

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

LL modpow(LL a, LL n) {
    LL res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

void Main()
{
    int x,y;cin>>x>>y;

    REP(i,x+1){
        int asi = y-i*2;
        if(asi<0){
            continue;
        }
        if(asi%4==0){
            if(asi/4 + i == x){
                cout<<"Yes"<<endl;
                return;
            }
        }

    }
    cout<<"No"<<endl;
    
	return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
    return 0;
}

Measured memory_bytes: 3684
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <deque>
#include <climits>
#include <functional>
#include <map>
#include <stack>
#define endl '\n'
#define ll long long
#define NCONS 16001

using namespace std;

int getsum(int a)
{
    auto str = to_string(a);
    auto ret = 0;
    for(int i = 0; i < str.length(); i++) ret += str[i] - '0';
    return ret;
}

int main(void)
{
    cin.tie(NULL); ios_base::sync_with_stdio(false);
    int N, A, B; cin >> N >> A >> B;
    
    int acc = 0;
    for(int i = 1; i <= N; i++)
    {
        auto ret = getsum(i);
        if(A <= ret && ret <= B)
        {
//            cout << i << endl;
            acc += i;
        }
    }
    cout << acc << endl;
    return 0;
}


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

using namespace std;

int const N = 1e5 + 41;

int n, a[N];
long long ans;


int main(){
	scanf("%d",&n);
	for(int i=0;i<n;++i){
		scanf("%d",&a[i]);
	}
	for(int i=0;i<n;++i){
		if(a[i] % 2 == 0){
			ans += a[i] / 2;
		}else{
			if(a[i+1] > 0){
				ans += a[i] / 2 + 1;
				--a[i+1];
			}else{
				ans += a[i] / 2;
			}
		}
	}
	printf("%lld\n",ans);



	return 0;
}

Measured memory_bytes: 640
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a) (a).begin(),(a).end()
#define pb emplace_back
#define INF (1e9+1)

int main(){
    int n;
    cin>>n;
    vector<int> v(n);
    rep(i,n)cin>>v[i];
    sort(all(v));

    int ans = 0;
    rep(i,v.size()-1)ans += v[i];
    ans+= v.back()/2;

    cout<<ans<<endl;
}


Measured memory_bytes: 256
package main

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

func main() {
	fsc := NewFastScanner()
	A, B, C := fsc.NextInt(), fsc.NextInt(), fsc.NextInt()
	res := A + B
	if res >= C {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

//template
type FastScanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewFastScanner() *FastScanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1024)
	return &FastScanner{r: rdr}
}
func (s *FastScanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *FastScanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *FastScanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *FastScanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *FastScanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}

func (s *FastScanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *FastScanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *FastScanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}

//Max,Min
func IntMax(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func Int64Max(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}
func Float64Max(a, b float64) float64 {
	if a < b {
		return b
	}
	return a
}

func IntMin(a, b int) int {
	if a > b {
		return b
	}
	return a
}

func Int64Min(a, b int64) int64 {
	if a > b {
		return b
	}
	return a
}
func Float64Min(a, b float64) float64 {
	if a > b {
		return b
	}
	return a
}

//Gcd
func IntGcd(a, b int) int {
	if a < b {
		b, a = a, b
	}
	if b == 0 {
		return a
	}
	return IntGcd(b, a%b)
}
func Int64Gcd(a, b int64) int64 {
	if a < b {
		b, a = a, b
	}
	if b == 0 {
		return a
	}
	return Int64Gcd(b, a%b)
}

func IntAbs(a int) int {
	if a < 0 {
		a *= -1
	}
	return a
}

func Int64Abs(a int64) int64 {
	if a < 0 {
		a *= -1
	}
	return a
}


Measured memory_bytes: 640