akhauriyash/Code-Regression huggingface dataset:
// インクルード
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <iomanip>

// 名前空間省略
using namespace std;

// メイン
int main()
{
	// 入出力の高速化
	ios::sync_with_stdio(false);
	cin.tie(nullptr);

	// 表示精度変更
	cout << fixed << setprecision(16);

	vector<string> s(3);
    for(int i=0;i<3;i++) cin >> s[i];
    
    int check_person = 0;
    vector<int> cnt(3,0);
    
    while(1){
        cnt[check_person]++;
        if(cnt[check_person]>s[check_person].length()){
            if(check_person == 0) cout << "A" << endl;
            if(check_person == 1) cout << "B" << endl;
            if(check_person == 2) cout << "C" << endl;
            return 0;
        }

        //cout << check_person << ":" << cnt[check_person] << endl;
        if(s[check_person][cnt[check_person]-1] == 'a'){
            check_person = 0;
        }
        else if(s[check_person][cnt[check_person]-1] == 'b'){
            check_person = 1;
        }
        else if(s[check_person][cnt[check_person]-1] == 'c'){
            check_person = 2;
        }
    }
}

Measured memory_bytes: 256
# Template 1.0
import sys, re
from collections import deque, defaultdict, Counter, OrderedDict
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, log
from heapq import heappush, heappop, heapify, nlargest, nsmallest
def STR(): return list(input())
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def list2d(a, b, c): return [[c] * b for i in range(a)]
def sortListWithIndex(listOfTuples, idx):   return (sorted(listOfTuples, key=lambda x: x[idx]))
def sortDictWithVal(passedDic):
    temp = sorted(passedDic.items(), key=lambda kv: (kv[1], kv[0]))
    toret = {}
    for tup in temp:
        toret[tup[0]] = tup[1]
    return toret
def sortDictWithKey(passedDic):
    return dict(OrderedDict(sorted(passedDic.items())))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

s = input()

print('x'*len(s))

Measured memory_bytes: 70916
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <tuple>
#include <stdio.h>
#include <bitset>
#include <limits.h>
#include <complex>
#include <deque>
#include <iomanip>
#include <list>
#include <cstring>
using namespace std;
#define pi pair<int,int>
#define pl pair<long long,long long>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
#define en cout << endl //セミコロンつけろ
//#define MM 1000000000
//#define MOD MM+7
typedef long long ll;
const int MM = 1e9;
const int MOD = MM+7;
const long double PI = acos(-1);
const long long INF = 1e15;
int dx[8] = {-1,0,1,0,-1,-1,1,1};
int dy[8] = {0,-1,0,1,-1,1,1,-1};
// 'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122
template<typename T>
T GCD(T u,T v){
    return v ? GCD(v,u%v) : u;
}
template<typename T>
T LCM(T x,T y){
    T gc = GCD(x,y);
    return x*y/gc;
}
struct edge {
    ll to,cost;
};
/*
const int COM_MAX = 500500;
long long fac[COM_MAX],finv[COM_MAX],inv[COM_MAX];
void init(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < COM_MAX; i++){
        fac[i] = fac[i-1]*i%MOD;
        inv[i] = MOD - inv[MOD%i]*(MOD/i)%MOD;
        finv[i] = finv[i-1]*inv[i]%MOD;
    }
}
long long COM(int n,int k){
    if(n < k || n < 0 || k < 0) return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}
*/

ll a[100010];
int main(){
    int N,M; cin >> N >> M;
    priority_queue<ll> pq;
    vector<ll> a(N);
    for (int i = 0; i < N; i++){
        cin >> a[i];
        pq.push(a[i]);
    }
    //cout << "size : " << pq.size() << endl;
    for (int i = 0; i < M; i++){
        ll Top = pq.top();
        pq.pop();
        Top /= 2;
        pq.push(Top);
    }
    ll ans = 0;
    while(pq.size()){
        ll t = pq.top();
        pq.pop();
        ans += t;
    }
    cout << ans << endl;
}

Measured memory_bytes: 2168
#include<bits/stdc++.h>
#define ll long long
#define uint unsigned
#define ull unsigned ll
#define db double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pli pair<ll,int>
#define vi vector<int>
#define vpi vector<pii >
#define IT iterator
 
#define PB push_back
#define MK make_pair
#define LB lower_bound
#define UB upper_bound
#define y1 wzpakking
#define fi first
#define se second
#define BG begin
#define ED end
 
#define For(i,j,k) for (int i=(int)(j);i<=(int)(k);i++)
#define Rep(i,j,k) for (int i=(int)(j);i>=(int)(k);i--)
#define UPD(x,y) (((x)+=(y))>=mo?(x)-=mo:233)
#define CLR(a,v) memset(a,v,sizeof(a))
#define CPY(a,b) memcpy(a,b,sizeof(a))
#define sqr(x) (1ll*x*x)
 
#define LS3 k*2,l,mid
#define RS3 k*2+1,mid+1,r
#define LS5 k*2,l,mid,x,y
#define RS5 k*2+1,mid+1,r,x,y
#define GET pushdown(k);int mid=(l+r)/2
#define inf 2147480000
using namespace std;
const int mo=1000000007;
const int N=200005;
int n,a[N],S[N],f[N];
int main(){
	scanf("%d",&n);
	For(i,1,n) scanf("%d",&a[i]);
	f[0]=1;
	For(i,1,n){
		f[i]=f[i-1];
		if (a[i]!=a[i-1]){
			f[i]=(f[i]+S[a[i]])%mo;
			S[a[i]]=(S[a[i]]+f[i-1])%mo;
		}
	}
	printf("%d\n",f[n]);
} 

Measured memory_bytes: 2560
#include<stdio.h>
#include<stdlib.h>
#include<math.h>

typedef long long int int64;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))

void run(void){
  int h,w,d;
  scanf("%d%d%d",&h,&w,&d);
  int *x=(int *)malloc(sizeof(int)*(h*w+1));
  int *y=(int *)malloc(sizeof(int)*(h*w+1));
  int i,j;
  for(i=1;i<=h;i++){
    for(j=1;j<=w;j++){
      int n;
      scanf("%d",&n);
      x[n]=i;
      y[n]=j;
    }
  }
  int *dp=(int *)calloc(h*w+1,sizeof(int));
  for(i=d;i<=h*w;i++){
    dp[i]=dp[i-d]+ABS(x[i]-x[i-d])+ABS(y[i]-y[i-d]);
  }
  int q;
  scanf("%d",&q);
  for(i=0;i<q;i++){
    int l,r;
    scanf("%d%d",&l,&r);
    printf("%d\n",dp[r]-dp[l]);
  }
  return;
}

int main(void){
  run();
  return 0;
}


Measured memory_bytes: 2048
# -*- coding: utf-8 -*-
a, b, c, d = map(int, input().split())
T = [a, b]
A = [c, d]
flagT = 0
flagA = 0
while 1:
    A[0] -= T[1]
    if A[0] <= 0:
        flagA = 1
        break
    T[0] -= A[1]
    if T[0] <= 0:
        flagT = 1
        break
if flagT == 1:
  print("No")
if flagA == 1:
  print("Yes")

Measured memory_bytes: 61808
a = int(input())
b = int(input())
c = int(input())
x = int(input())

i = 0
p = 0
while i <= a:
    j = 0
    while j  <= b:
        k = 0
        while k <= c:
            if x == 500 * i + 100 * j + 50 * k:
                p += 1
            k += 1
        j += 1
    i += 1
print(p)


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

int main(){
   int n,seq[100];

   cin >> n;

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

   for(int j=n-1; j>=0; j--){
	if(j != n-1){
		cout << " ";
	}

	cout << seq[j];
   }

   cout << endl;

   return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(var, begin, end) for (int var = (begin); var <= (end); var++)
#define RFOR(var, begin, end) for (int var = (begin); var >= (end); var--)
#define REP(var, length) FOR(var, 0, length - 1)
#define RREP(var, length) RFOR(var, length - 1, 0)
#define EACH(value, var) for (auto value : var)
#define SORT(var) sort(var.begin(), var.end())
#define REVERSE(var) reverse(var.begin(), var.end())
#define RSORT(var) SORT(var); REVERSE(var)
#define OPTIMIZE_STDIO ios::sync_with_stdio(false);cin.tie(0);cout.precision(10);cout << fixed
#define endl '\n'

const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
struct mint {
    ll x;
    mint() : x(0) {}
    mint(ll x) : x((x % MOD + MOD) % MOD) {}
    mint& operator+=(const mint& r) { if ((x += r.x) >= MOD) { x -= MOD; } return *this; }
    mint& operator-=(const mint& r) { if ((x -= r.x) < 0) { x += MOD; } return *this; }
    mint& operator*=(const mint& r) { if ((x *= r.x) > MOD) { x %= MOD; } return *this; }
    mint& operator++() { if ((++x) >= MOD) { x -= MOD; } return *this; }
    mint operator++(int) { mint ret = x; if ((++x) >= MOD) { x-= MOD; } return ret; }
    mint& operator--() { if ((--x) < 0) { x += MOD; } return *this; }
    mint operator--(int) { mint ret = x; if ((--x) < 0) { x += MOD; } return ret; }
    mint operator+(const mint& r) { mint ret; return ret = x + r.x; }
    mint operator-(const mint& r) { mint ret; return ret = x - r.x; }
    mint operator*(const mint& r) { mint ret; return ret = x * r.x; }
    mint operator-() { return mint() - *this; }
    bool operator<(const mint& a) { return x < a.x; }
    bool operator>(const mint& a) { return x > a.x; }
    bool operator<=(const mint& a) { return x <= a.x; }
    bool operator>=(const mint& a) { return x >= a.x; }
    bool operator==(const mint& a) { return x == a.x; }
    bool operator!=(const mint& a) { return x != a.x; }
};
ostream& operator<<(ostream& os, const mint& r) { os << r.x; return os; }
ostream& operator>>(ostream& os, const mint& r) { os >> r.x; return os; }

mint dp[100005];

void solve(istream& cin, ostream& cout) {
  int n, m;
  cin >> n >> m;
  map<int, int> d;
  REP(i, m) {
    int a;
    cin >> a;
    if(!d.count(a)) d[a] = 1;
  }
  REP(i, 100005) dp[i] = 0;
  dp[0] = 1;
  dp[1] = 1;
  FOR(i, 2, n) {
    if (d.count(i)) continue;
    if (!d.count(i - 1)) dp[i] += dp[i - 1];
    if (!d.count(i - 2)) dp[i] += dp[i - 2];
  }
  mint ans = dp[n];
  cout << ans << endl;
}

#ifndef TEST
int main() {
  OPTIMIZE_STDIO;
  solve(cin, cout);
}
#endif


Measured memory_bytes: 5760
import sys,math
n = int(input())
a = list(map(int,input().split()))
select = [0 for _ in range(n+1)]
mark = [0 for _ in range(n+1)]
c = 0
for i in range(n-1,0,-1):
    if a[i] ==0 and mark[i+1]%2==1:
        c += 1
        select[i + 1] = 1
        l = 1
        r = (i + 1)
        m = math.sqrt(i+1)
        m = int(m)
        while (l <=m):
            if (i + 1) % l == 0:
                mark[l] += 1
                r = (i + 1) // l
                if l != r:
                    mark[r] += 1
            l += 1
    if a[i] and mark[i+1]%2==0:
        c+=1
        select[i + 1] = 1
        l = 1
        r = (i + 1)
        m = math.sqrt(i + 1)
        m = int(m)
        while (l <= m):
            if (i + 1) % l == 0:
                mark[l] += 1
                r = (i + 1) // l
                if l!=r:
                    mark[r] += 1
            l += 1
if a[0]==0 and mark[1]%2==1:
    c+=1
    select[1]=1
    mark[1]+=1
elif a[0]==1 and mark[1]%2==0:
    c += 1
    select[1] = 1
    mark[1] += 1
print(c)
for i in range(1,n+1):
    if select[i]:
        sys.stdout.write('{} '.format(i))

Measured memory_bytes: 72168
import java.util.Scanner;

/**
 * Created by sonetsuyoshi on 2016/07/31.
 */
public class Main {

    static public void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.nextLine().split(" ")[1];

        System.out.println("A" + s.charAt(0) + "C");
    }
}

Measured memory_bytes: 10192
#include <bits/stdc++.h>
#include <algorithm>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(x) (x).begin(), (x).end()
#define PB(x) push_back(x)
#define MP(x,y) make_pair(x,y)
using namespace std;
using P = pair<int,int>;
typedef long long ll;
 
int main() {

    int k,x;
    cin >> k >> x;

    int sum=k*500;
    if(sum>=x)  cout<<"Yes"<<endl;
    else    cout<<"No"<<endl;
    
 return 0;
}

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

int main() {
	string s,t;
	cin>>s>>t;
	int ans=0;
	for(int i=0;i<s.size();i++){
		if(s[i]!=t[i]){
			ans++;
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 3892
#define _USE_MATH_DEFIMES
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <clocale>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

const int MOD = 1'000'000'007;
const int INF = 1'000'000'000; //1e9
const int NIL = -1;
const long long LINF = 1'000'000'000'000'000'000; // 1e18
const long double EPS = 1E-10;

template<class T, class S> inline bool chmax(T &a, const S &b){
    if(a < b){
        a = b; return true;
    }
    return false;
}
template<class T, class S> inline bool chmin(T &a, const S &b){
    if(b < a){
        a = b; return true;
    }
    return false;
}








int main(){
    int N, K; std::cin >> N >> K;
    std::vector<int> A(N);
    for(int i(0); i < N; ++i) std::cin >> A[i];
    
    int ng(0), ok(INF);
    while(ok > ng + 1){
        int mid((ng + ok) / 2), cnt(0);
        for(int i(0); i < N; ++i){
            cnt += (A[i] - 1) / mid;
        }
        if(cnt <= K) ok = mid;
        else ng = mid;
    }
    std::cout << ok << std::endl;
    return 0;
}


Measured memory_bytes: 3900
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#define numarr 12
using namespace std;

int main() {
	int a, b, c, ans;
	cin >> a >> b >> c;
	ans = a * b / 2;
		cout << ans << endl;
}

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

#define pi 3.14159265358979323846264

#define ll long long
#define fori(n) for(long long i=0;i<n;i++)
#define forj(n) for(long long j=0;j<n;j++)

#define sp(n) setprecision(n)
#define d7 1000000007
#define mkp make_pair
#define mkt make_tuple

using namespace std;

bool isPrime(long long k){
    if(k<=1){return false;}
    if(k==2){return true;}
    if(k%2==0){return false;}
    long long i = 3;
   while (i*i <= k) {if (k % i == 0) {return false;}i += 2;}
return true;
}

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]);}}}
    return C[n][k];
 }

ll gcd(ll a, ll b){if (b == 0)
        return a;return gcd(b, a % b);}

ll srihrg(ll n,ll k,ll m){
    ll ans;
    ans=1;
    fori(k){
        ans=(ans*n)%m;
    }
    return ans;
}


int main(int argc, const char * argv[]) {
 //cout<<"Om\n";
 //Praise to Lord
 //make cin/cout faster
 ios_base::sync_with_stdio(false);
 cin.tie(NULL);cout.tie(NULL);
// code now
   
    ll n;
    cin>>n;
    double d=(n);
    d=d/3;
    double d1=d*d*d;
    cout<<sp(15)<<d1;
    
    
//code ends
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
  using namespace std;
  #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #define endl "\n"
  #define int long long
  #define all(v) v.begin(),v.end()
  #define f first
  #define s second
  #define PB push_back
  #define MP make_pair
  #define double long double
  #define trace1(x)                cerr<<#x<<": "<<x<<endl
  #define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
  #define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
  #define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
  #define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
  #define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
  #define cases int testcases;cin>>testcases; while(testcases--)
  #define MOD 1000000007
  #define N 1000001
  

int32_t main()
{



  int n,p;
  cin >> n >> p; 


  string s;
  cin >> s;

  int arr[n+1];

  for(int i = 1; i <= n; i++)
  {
    arr[i] = s[i-1] -'0';
  } 

  if(10%p == 0)
  {
    int ans = 0;

    for(int i = 1; i <= n; i++)
    {
      if(arr[i]%p == 0)ans +=i;
    }
    cout << ans;
    return 0;
  }

  int pre[n+1];
  pre[n] = arr[n]%p;

  int poww = 10;
  for(int i = n-1; i >= 1; i--)
  {
      pre[i] = (pre[i+1]%p + ((poww)*arr[i]) %p)%p;
    poww = (10*poww)%p;
  }

  pre[0] = 0;


  reverse(pre+1,pre+n+1);

  //   for(int i = 0; i <= n; i++)
  // {
  //   trace2(i,pre[i]);
  // }
  int ans = 0;

  vector<int> mp(p,0);

  for(int i = 0; i <=n; i++)
  {
    ans += mp[pre[i]];
    mp[pre[i]]++;
  }
  cout << ans;


  return 0;
}

Measured memory_bytes: 3716
n, k = map(int, input().split())
A = [*map(int, input().split())]
A.sort(reverse=True)
ng, ok = 0, 1<<30
while ok - ng > 1:
    m = (ng + ok) // 2
    c = 0
    for a in A:
        d = (a - 1) // m
        if d > 0: c += d
        else: break
    if c <= k: ok = m
    else: ng = m
print(ok)


Measured memory_bytes: 30760
import java.util.*;
 public class Main {
	public static void main(String[] args){
      Scanner sc = new Scanner(System.in);

      int a = sc.nextInt();
      int b = sc.nextInt();
 
      if(a <= b){
       for(int i = 0;i < b;i++){
        System.out.print(a);
       }
       
      }else{
        for(int i = 0;i < a;i++){
        System.out.print(b);
       }
      }
      

      
   }
 }

Measured memory_bytes: 35652
#include <bits/stdc++.h>
#define ll long long
#define ii pair<ll, ll>
#define vi vector<ll>
#define vii vector<ii>
#define vs vector<string>
#define si set<ll>
#define endl "\n"
#define pb push_back
#define x first
#define y second
//g++ -std=c++11 -Wall -Wextra -pedantic-errors main.cpp -o main
const int ms = 2*1e5 + 5, base = 31, mod = 1e9 + 7;
using namespace std;

int main(){
	ios::sync_with_stdio(false), cin.tie(0);
	
	int n; cin >> n;
	si arr;
	bool ok = true;
	while(n--){
		ll a; cin >> a;
		if (arr.count(a)) ok = false;
		arr.insert(a);
	}
	
	if (ok) cout << "YES\n";
	else cout << "NO\n";
	
	return 0;
}

Measured memory_bytes: 9600
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<algorithm>
#include<functional>
#include<utility>
#include<bitset>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<cstdio>

using namespace std;

#define REP(i,n) for(int i=0;i<int(n);i++)
#define foreach(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
typedef long long ll;
typedef pair<int,int> P;

int main(void){
	          int i;

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

	          int N;
	          cin >> N;
	          int od=0;
	          for(i=1;i<=N;i++){
	        	  int a;
	        	  cin >> a;
	        	  if(a%2==1) od++;
	          }

	          if(od==0) cout << "second" << endl;
	          else cout << "first" << endl;

	          return 0;
}


Measured memory_bytes: 256
program Project1;

{$APPTYPE CONSOLE}

uses
  SysUtils,Classes;
var
  i,j,min:Integer;
  w:string;
  sw:Char;
  beau:Boolean;
begin
  try
    { TODO -oUser -cConsole Main : ここにコードを記述してください }
    Readln(w);

    for i := 1 to Length(w) do begin
      min := i;
      for j := i+1 to Length(w) do begin
        if w[j] < w[min] then
        min := j;
      end;
      sw:=w[i];
      w[i]:=w[min];
      w[min]:=sw;
    end;

    beau:=True;
    if Length(w) mod 2 = 1 then
      beau:=false
    else begin
      i:=1;
      while i<Length(w) do
        if w[i]=w[i+1] then
          i:=i+2
        else begin
          beau:=false;
          Break;
        end;
    end;

    if beau then   
      Writeln('Yes')
    else
      Writeln('No');
    Readln;
  except
    on E: Exception do
      Writeln(E.ClassName, ': ', E.Message);
  end;
end.


Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
#define LL long long
#define PB push_back
#define MP make_pair
#define MOD 1e9+7

int N;
LL A[100001], B[100000];
int main(){
	cin >> N;
	for(int i=0; i<N+1; i++) cin >> A[i];
	for(int i=0; i<N; i++) cin >> B[i];

	LL ans = 0;
	for(int i=0; i<N; i++){
		if(A[i] >= B[i]){
			ans += B[i];
			A[i] -= B[i];
			B[i] = 0;
		}
		else{
			ans += A[i];
			B[i] -= A[i];
			A[i] = 0;
		}

		if(A[i+1] >= B[i]){
			ans += B[i];
			A[i+1] -= B[i];
			B[i] = 0;
		}
		else{
			ans += A[i+1];
			B[i] -= A[i+1];
			A[i+1] = 0;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 1920
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int i = 0;
		int total = 0;
		int N = scan.nextInt(); //夏休みは　Ｎ　日間
		int M = scan.nextInt(); //宿題はM個
		
		while(true) {
			if(i == M) break;
			int A = scan.nextInt(); //日数
			total += A;
			i++;
		}
		if(N >= total) {
			N -= total;
			System.out.println(N);
		} else if(N < total) {
			System.out.println("-1");
		}
		
	}

}

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


int main() {
  string s;
  cin >> s;
  int price = 700;
  if(s[0] == 'o') price=price+100;
  if(s[1] == 'o') price=price+100;
  if(s[2] == 'o') price=price+100;
  cout << price << endl;
}



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

#define rep(l, r) for (int i = (l); i < (r); i++)

typedef long long ll;
 
using namespace std;

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

    int happy = 0;
    happy += (x / 500) * 1000;
    happy += (x % 500 / 5) * 5;

    cout << happy << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 1e18
int main()
{
	ll n,weight;
	cin>>n>>weight;
	ll w[n],val[n],sum=0;
	for(int i=0;i<n;i++)
	{
		cin>>w[i]>>val[i];
		sum+=val[i];
	}
	ll dp[n+1][sum+1];
	for(int i=0;i<=n;i++)
	dp[i][0]=0;
	for(int j=1;j<=sum;j++)
	dp[0][j]=inf;
	
	for(ll int i=1;i<=n;i++)
	{
		for(ll int j=1;j<=sum;j++)
		{
			if(j-val[i-1]>=0)
			dp[i][j]=min(dp[i-1][j],w[i-1]+dp[i-1][j-val[i-1]]);
			else
			dp[i][j]=min(dp[i-1][j],w[i-1]);
		}
	}
	ll ans=0;
	for(int i=sum;i>=0;i--)
	{
		if(dp[n][i]<=weight)
		{
			ans=i;
			break;
		}
	}
	cout<<ans<<endl;
}

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

int n, P, binom[3005][3005], s2[3005][3005];

int power(int a, int x, int P) {
	int ans = 1;
	for (; x; x >>= 1, a = 1ll * a * a % P)
		if (x & 1) ans = 1ll * ans * a % P;
	return ans;
}

int main() {
	scanf("%d%d", &n, &P);
	s2[0][0] = 1;
	for (int i = 0; i <= n + 1; ++i)
		for (int j = binom[i][0] = 1; j <= i; ++j) {
			s2[i][j] = (s2[i - 1][j - 1] + 1ll * s2[i - 1][j] * j) % P;
			binom[i][j] = (binom[i - 1][j] + binom[i - 1][j - 1]) % P;
		}
	int ans = 0;
	for (int i = 0; i <= n; ++i) {
		int e = power(2, n - i, P), pw = 1, s = 0;
		for (int j = 0; j <= i; ++j, pw = 1ll * pw * e % P)
			s = (s + 1ll * s2[i + 1][j + 1] * pw) % P;
		ans = (ans + (i & 1 ? -1ll : 1ll) * s * binom[n][i] % P * power(2, power(2, n - i, P - 1), P)) % P;
	}
	printf("%d\n", (ans + P) % P);
	return 0;
}


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

int h,w;
char p[101][101];

void dfs(int x,int y){
	char c=p[x][y];
	p[x][y]='0';
	int dx[4]={1,-1,0,0},dy[4]={0,0,1,-1};
	for(int k=0;k<4;++k){
		if(0<x+dx[k]&&x+dx[k]<=h&&0<y+dy[k]&&y+dy[k]<=w&&p[x+dx[k]][y+dy[k]]==c){
			dfs(x+dx[k],y+dy[k]);
		}
	}
}

int main(){
	while(true){
		int n=0;
		cin>>h>>w;
		if(h==0&&w==0){
			break;
		}
		for(int i=1;i<=h;++i){
			for(int j=1;j<=w;++j){
				cin>>p[i][j];
			}
		}
		for(int i=1;i<=h;++i){
			for(int j=1;j<=w;++j){
				if(p[i][j]!='0'){
					dfs(i,j);
					++n;
				}
			}
		}
		cout<<n<<endl;
	}
}

Measured memory_bytes: 1944
A, B, C, K = map(int, input().split())

ans = 0

nokori = K

# まず1の札を取れるだけ取る
if A >= K:
  # Aのほうが多い場合
  ans = ans + K
  K = 0
else:
  # Aのほうが少ない場合
  ans = A
  K = K - A

# 次に0の札を取れるだけ取る
K = K - B

# まだ取れる枚数が残っている場合、最大C枚取る
if K > 0:
  ans = ans - min(C, K)

print(ans)




Measured memory_bytes: 9172
import java.util.Scanner;
public class Main {
	 public static void main(String args[]){
	Scanner scanner = new Scanner(System.in);

	int n=0;
	int m=0;
	 int bird=2;
	 int tirtle=4;
	 int sum=scanner.nextInt();
	 int legs=scanner.nextInt();

	 for(int i=0;i<=sum;i++) {
		 n=bird*i;
		 m=tirtle*(sum-i);
		 if(n+m==legs) {
			 System.out.println("Yes");
			 break;
		 }
		 if(i==sum) {
			 System.out.println("No");
		 }
	 }
	 }
}

Measured memory_bytes: 35672
package main

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

const mod = 1000000007
const facNum = 300001

func main() {
	sc := newScanner(os.Stdin)
	x := sc.is(5)
	for i, v := range x {
		if v == 0 {
			fmt.Println(i + 1)
		}
	}
}

// I/O
type scanner struct {
	sc *bufio.Scanner
}

func newScanner(input io.Reader) *scanner {
	sc := bufio.NewScanner(input)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &scanner{sc}
}

func (s *scanner) s() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *scanner) i() int {
	i, e := strconv.Atoi(s.s())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *scanner) f() float64 {
	f, e := strconv.ParseFloat(s.s(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *scanner) bs() []byte {
	return []byte(s.s())
}

func (s *scanner) is(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.i()
	}
	return res
}

func (s *scanner) fs(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.f()
	}
	return res
}

//const factorial = new
func Pow(a, n int) int {
	ans := 1
	for n > 0 {
		if (n & 1) == 1 {
			ans = ans * a % mod
		}
		a = a * a % mod
		n = n >> 1
	}
	return ans
}

func Gcd(a, b int) int {
	if a < b {
		return Gcd(b, a)
	}
	for b != 0 {
		a, b = b, a%b
	}
	return a
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func combination(n, k int, fac, ifac []int) int {
	if n < k || n < 0 {
		return 0
	}
	if k == 0 {
		return 1
	}
	//while n != 0
	ans := ifac[k] * ifac[n-k] % mod
	return ans * fac[n] % mod
}

// 階乗: factorial
// コンビネーションを計算する際に前もって計算しておく
// fac[k] => k! (mod M)
// ifac[k] => k!^(M-2) (mod M)
// n: ex. 2 * 10^5 => 200001
// fac, ifac := factorial()
func factorial() (fac []int, ifac []int) {
	fac = make([]int, facNum)
	fac[0] = 1
	ifac = make([]int, facNum)
	ifac[0] = 1
	for i := 1; i < facNum; i++ {
		fac[i] = fac[i-1] * i % mod
		ifac[i] = ifac[i-1] * Pow(i, mod-2) % mod
	}
	return
}

// vs: sorted slice int value
func lowerBound(vs []int, v int) (index int) {
	n := len(vs) / 2
	m := len(vs)
	for m != n {
		if vs[n] < v {
			n = (m-n+1)/2 + n
			//m = m
		} else {
			m = n
			n = n / 2
		}
	}
	return n
}

func IntSlice(n, init int) []int {
	r := make([]int, n)
	for i := range r {
		r[i] = init
	}
	return r
}


Measured memory_bytes: 1752
s = input()
s_list = list(s)
part = 1
for i in range(len(s_list)):
  if (i+1)%2 == 0 and s_list[i] == "R":
    part = 0
  elif (i+1)%2 == 1 and s_list[i] == "L":
    part = 0
if part ==0:
    print("No")
else:
    print("Yes")

Measured memory_bytes: 3060
N = gets.strip.to_i
c = gets.strip
s = 0
r_pos = 0
w_pos = N-1

if c.include?('R') && c.include?('W')
  while(r_pos<N && c[r_pos]=='R')
    r_pos+=1
  end
  while(w_pos>0 && c[w_pos]=='W')
    w_pos-=1
  end
  while(true)
    break if r_pos>=w_pos
    s+=1
    c[w_pos] = 'W'
    c[r_pos] = 'R'
    while(r_pos<N && c[r_pos]=='R')
      r_pos+=1
    end
    while(w_pos>0 && c[w_pos]=='W')
      w_pos-=1
    end
  end
end

puts s

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

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

    int a, b;
    std::unordered_map<int, int> m;
    for (int i = 0; i < M; ++i) {
        std::cin >> a >> b;
        m[a] += 1;
        m[b] += 1;
    }

    for (const auto& p : m) {
        if (p.second % 2 != 0) {
            std::cout << "NO" << std::endl;
            return 0;
        }
    }

    std::cout << "YES" << std::endl;

    return 0;
}


Measured memory_bytes: 3876
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#include<vector>
#define MaxN 100000+100
using namespace std;
int a[MaxN];
int p[MaxN];
int b[MaxN];
int fa[MaxN];
vector<int>qq[MaxN];
vector<int>uu[MaxN];
int find(int x)
{
	if(fa[x]<0)
		return x;
	else
		return fa[x]=find(fa[x]);
 } 
 void merge(int a,int b)
 {
 	int ra=find(a);
 	int rb=find(b);
 	if(ra!=rb)
	{
		if(-fa[ra]>-fa[rb])
		{
			fa[ra]+=fa[rb];
			fa[rb]=ra;
		}
		else
		{
			fa[rb]+=fa[ra];
			fa[ra]=rb;
		}
	}
 }
int main()
{
	memset(fa,-1,sizeof(fa));
	int N;
	int M;
	scanf("%d",&N);
	scanf("%d",&M);
	for(int i=1;i<=N;i++)
		scanf("%d",&p[i]);
	while(M--)
	{
		int a,b;
		scanf("%d %d",&a,&b);
		merge(a,b);
	}
	int sum=0;
	for(int i=1;i<=N;i++)
	{
		qq[find(i)].push_back(i);
		uu[find(i)].push_back(p[i]);
	}
	for(int i=1;i<=N;i++)
	{
		if(fa[i]<0)
		{
			int len=0;
			for(int k=0;k<qq[i].size();k++)
			{
				a[len]=qq[i][k];
				b[len++]=uu[i][k];
			} 	
			sort(a,a+len);
			sort(b,b+len);
			int s_a,s_b;
			s_a=s_b=0;
			while(s_a< len && s_b <len)
			{
				if(a[s_a]==b[s_b])
					sum++,s_a++,s_b++;
				else
					if(a[s_a]<b[s_b])
						s_a++;
					else 
						s_b++;
			}
		}
	}
	printf("%d\n",sum);
	return 0;
 } 

Measured memory_bytes: 12672
#include <bits/stdc++.h>
#define endl '\n';

typedef long long ll;

using namespace std;

const string YES = "";
const string NO  = "";

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

    int n, a, b;

    cin >> n;

    if (n == 1) {
        cout << "Hello World";
    } else {
        cin >> a >> b;
        cout << a + b;
    }
    cout << endl;

    return 0;
}



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

int main ()
{
	int x;
	cin >> x;
	if (x == 7 || x == 5 || x == 3)
	{
		cout << "YES\n";
	}
	else
	{
		cout << "NO\n";
	}
	
	
	return 0;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Scanner;

public class Main {
	static boolean[] visited;
	static int[] ans;
	static ArrayList<Integer> tempRail, tempRoad;
	static ArrayList<Integer>[] road, rail;
	static int [] colorRoad, colorRail;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		int l = sc.nextInt();
		
		//idea: construct a union-find with all the roads only
		//then, for each node, run dfs on it, and add nodes to the 
		//set if and only if they're in the same road-component 
		//and theres an edge between them
		//able to count all the members in the set exactly once and 
		//at the same time; if a and b are in the same set, then 
		//their count is equal; othewrise, it might be different
		road = new ArrayList[n];
		for(int i=0;i<n;i++) {
			road[i] = new ArrayList<>();
		}
		for(int i=0;i<k;i++) {
			int p = sc.nextInt()-1;
			int q = sc.nextInt()-1;
			road[p].add(q);
			road[q].add(p);
		}
		rail = new ArrayList[n];
		for(int i=0;i<n;i++) {
			rail[i] = new ArrayList<>();
		}
		for(int i=0;i<l;i++) {
			int r = sc.nextInt()-1;
			int s = sc.nextInt()-1;
			rail[r].add(s);
			rail[s].add(r);
		}
		visitedRail = new boolean[n];
		visitedRoad = new boolean[n];
		colorRail = new int[n];
		colorRoad = new int[n];
		int c1 = 0;
		int c2 =0;
		for(int i=0;i<n;i++) {
			if(!visitedRail[i]) {
				tempRail = new ArrayList<>();
				dfsRail(i);
				for(int x : tempRail) {
					colorRail[x] = c1;
				}
				c1++;
			}
			if(!visitedRoad[i]) {
				tempRoad = new ArrayList<>();
				dfsRoad(i);
				for(int x : tempRoad) {
					colorRoad[x] = c2;
				}
				c2++;
			}
		}
		HashMap<Node, Integer> freq=  new HashMap<>();
		for(int i=0;i<n;i++) {
			freq.put(new Node(colorRail[i],colorRoad[i]), freq.getOrDefault(new Node(colorRail[i],colorRoad[i]),0)+1);
		}
		int ans[] = new int[n];
		for(int i=0;i<n;i++) {
			ans[i] = freq.get(new Node(colorRail[i],colorRoad[i]));
		}
		
		StringBuilder sb = new StringBuilder();
		for(int i=0;i<n;i++) {
			sb.append(ans[i]);
			sb.append("\n");
		}
		System.out.println(sb.toString());
	}
	static boolean [] visitedRail, visitedRoad;
	static void dfsRail(int i) {
		visitedRail[i] = true;
		tempRail.add(i);
		for(int j : rail[i]) {
			if(!visitedRail[j]) {
				dfsRail(j);
			}
		}
	}
	static void dfsRoad(int i) {
		visitedRoad[i] = true;
		tempRoad.add(i);
		for(int j : road[i]) {
			if(!visitedRoad[j]) {
				dfsRoad(j);
			}
		}
	}
	static class Node{
		int a;
		int b;
		public Node(int a,int b) {
			this.a = a;
			this.b = b;
		}
		@Override
		public int hashCode() {
			return a*129621+b*3692893;
		}
		@Override
		public boolean equals(Object o) {
			Node x = (Node)o;
			return x.a==a && x.b==b;
		}
	}
	
}


Measured memory_bytes: 98620
import java.util.*;

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

        int n = sc.nextInt();
        String str = String.valueOf(n);

        int len = str.length();

        int count = 0;
        for (int i=1; i<=n; i++){
            String st = String.valueOf(i);
            if (st.length()%2!=0){
                count++;
            }
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 28244
#include<bits/stdc++.h>
using namespace std;
const int N=1050;
int a[N],b[N],col,n,m,com,tot;
const long long mod=1e9+7;
long long ans=0;
bool vis[2][N*N];
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++) {
		scanf("%d",&a[i]);
		vis[0][a[i]]=true;
	}
	for(int j=1;j<=m;j++) {
		scanf("%d",&b[j]);
		vis[1][b[j]]=true;
	}
	sort(a+1,a+n+1);
	sort(b+1,b+m+1);
	ans=1;
	for(int i=1;i<n;i++) if(a[i]==a[i+1]) ans=0;
	for(int j=1;j<m;j++) if(b[j]==b[j+1]) ans=0;
	col=n;com=m;
	for(int i=m*n;i>=1;i--){
		while(col>=1&&a[col]>=i) col--;
		while(com>=1&&b[com]>=i) com--;
		tot=(n-col)*(m-com)-(n*m-i);
		if(tot<=0) ans=0;
		if(vis[0][i]&&vis[1][i]) tot=1;
		else if(vis[0][i]) tot=m-com;
		else if(vis[1][i]) tot=n-col;
		ans=ans*tot%mod;
	}
	printf("%lld\n",ans);
	
	
}

Measured memory_bytes: 256
import sys
from collections import Counter
INF = 10**18
N, K = [int(i) for i in sys.stdin.readline().split()]
len_k = len(bin(K)[2:])
A_ls = [bin(int(i))[2:] for i in sys.stdin.readline().split()]
max_len = max([len(i) for i in A_ls] + [len_k])
K = bin(K)[2:].zfill(max_len)
A_ls = [A.zfill(max_len) for A in A_ls]
# i番目の解
memo_ls = [0 for i in range(max_len)]
# i番目のみの最適解を考えた時の和
memo_ls2 = [0 for i in range(max_len)]
for i in range(max_len):
    ct = Counter([A[-1-i] for A in A_ls])
    # i番目のけたとして0を選んだ時の和
    ans_0 = 2**i*ct["1"]
    ans_1 = 2**i*ct["0"]
    ct.clear()
    memo_ls[-1-i] = (ans_0, ans_1)
    memo_ls2[-1-i] = max(ans_0, ans_1)
# i-1番目までの解の最大
# memo_ls3[i][j] j : 答えが決まっている時1, いない時0
memo_ls3 = [[0 for i in range(2)] for i in range(max_len + 1)]
memo_ls3[0][1] = -INF
for i, j in enumerate(K, 1):
    if j == "0":
        memo_ls3[i][0] = memo_ls3[i-1][0] + memo_ls[i-1][0]
        memo_ls3[i][1] = memo_ls3[i-1][1] + memo_ls2[i-1]
    else:
        memo_ls3[i][0] = memo_ls3[i-1][0] + memo_ls[i-1][1]
        memo_ls3[i][1] = max(memo_ls3[i-1][1] + memo_ls2[i-1], memo_ls3[i-1][0] + memo_ls[i-1][0])
res = max(memo_ls3[-1])
print(int(res))

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

int main(void)
{
  int X;
  cin >> X;

  int happy = 0;
  happy += (X / 500) * 1000;
  X -= (X / 500) * 500;
  happy += (X / 5) * 5;

  cout << happy << endl;
}

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

int main(){
  int n;
  cin>>n;
  for(int i=0;i<n;i++){
    int t,a[100];
    cin>>t;
    for(int j=0;j<t;j++){
      cin>>a[j];
    }
    int x=0,y=0;
    for(int j=0;j<t-1;j++){
      if(a[j+1]-a[j]>x ){
	x=a[j+1]-a[j];
      }
      if(a[j]-a[j+1] >y){
	y=a[j]-a[j+1];
      }
    }
    cout<<x<<" "<<y<<endl;
  }
  return 0;
}



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

using namespace std;

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

//===

const ll mod = 1e9 + 7;


int main() {
	string S;
	cin >> S;
	int lenS = static_cast<int>(S.size());
	const int r[] = { 1, 10, 9, 12, 3, 4 };


	ll r_num[13];
	for (int i = 0; i < 13; ++i) {
		r_num[i] = 0;
	}
	r_num[0] = 1;

	ll r_num_prev[13];


	int rt[10][13];
	for (int i = 0; i < 10; ++i) {
		for (int j = 0; j < 13; ++j) {
			rt[i][j] = i * j % 13;
		}
	}


	for (int i = lenS - 1; i >= 0; --i) {
		int k = lenS - 1 - i;

		memcpy(r_num_prev, r_num, sizeof(ll) * 13);
		for (int i = 0; i < 13; ++i) {
			r_num[i] = 0;
		}

		if (S[i] == '?') {
			for (int j = 0; j < 10; ++j) {
				int rnow = rt[j][r[k % 6]];
				for (int jj = 0; jj < 13; ++jj) {
					int jmod = (jj + rnow) % 13;
					r_num[jmod] = (r_num[jmod] + r_num_prev[jj]) % mod;
				}
			}
		}
		else {
			int d = static_cast<int>(S[i] - '0');
			for (int jj = 0; jj < 13; ++jj) {
				int rnow = rt[d][r[k % 6]];
				int jmod = (jj + rnow) % 13;
				r_num[jmod] = r_num_prev[jj];
			}
		}
	}

	cout << r_num[5] << endl;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#define ll long long
#define endl "\n"
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	int n,k;
	cin>>n>>k;
	n=n*3;
	k+=n;
	cout<<k/2<<endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<map>
using namespace std;
int main(){
  int n,ma=0;
  long long d[200001],cnt=0;
  map<long long,int> mp;
  scanf("%d",&n);
  for(int i=0;i<n;i++){
    scanf("%lld",&d[i]);
    cnt += d[i];
    if(mp.find(cnt) == mp.end()){
      if(cnt == 0) ma = i+1;
      else mp[cnt]=i;
    }else ma = max(ma,i-mp[cnt]);
  }
  printf("%d\n",ma);
  return(0);
}



Measured memory_bytes: 16684
#include<stdio.h>
int main(){
    char X,Y;
    scanf("%c %c",&X,&Y);
    if(X<Y){
        //printf("%d<%d.\n",X-55,Y-55);
        printf("<\n");
    }else if(X>Y){
        //printf("%d>%d.\n",X-55,Y-55);
        printf(">\n");
    }else{
        //printf("%d=%d.\n",X-55,Y-55);
        printf("=\n");
    }
    return 0;
}


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

using namespace std;

int main(void) {

    int a, b, c;
    int n[3];

    cin >> n[0] >> n[1] >> n[2];
    
    sort(n, n + 3);
    
    if(n[0] + n[1] == n[2]) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;

}

Measured memory_bytes: 256
#define _GIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;


int main(void) {
  string a, b, c;
  cin >> a >> b >> c;
  if (a.back() == b.front() && b.back() == c.front()) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
  
  return 0;
}

Measured memory_bytes: 3616
n,k = map(int,input().split())
List = [False for i in range(n)]
for i in range(k):
    d = int(input())
    tmp = [int(i) for i in input().split()]
    for i in tmp:
        List[i-1] = True
ans = 0
for i in range(n):
    if List[i]==False:
        ans += 1
print(ans)

Measured memory_bytes: 9196
#include <bits/stdc++.h>
#define m_k make_pair
#define inf 0x3f3f3f3f
using namespace std;
int x,ans;
int main()
{
	scanf("%d",&x);
	while (x>=500)
	{
		x-=500;
		ans+=1000;
	}
	while (x>=5)
	{
		x-=5;
		ans+=5;
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;int main(){long n,s,a,k,j,m=998244353,d[3001]={};cin>>n>>s;for(;n--;){cin>>a;for(j=s;j>=a;j--)d[j]=(d[j]+d[j-a])%m;d[a]++;d[0]++;k+=d[s];}cout<<k%m;}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int bfs(int, int, int);
int a[10];
int main(void){

	int n;

	cin >> n;
	for (int n_count = 0; n_count < n; n_count++){

		for (int i = 0; i < 10; i++){

			cin >> a[i];
		}

		if (bfs(0, 0, 0) == 1)
			cout << "YES" << endl;
		else
			cout << "NO" << endl;
	}
}

int bfs(int i, int l, int r){

	int ans = 0;

	if (i == 10)
		ans = 1;

	if (l < a[i])
		ans = bfs(i + 1, a[i], r);

	if (r < a[i])
		ans = bfs(i + 1, l, a[i]);

	return ans;
}

Measured memory_bytes: 1148
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pi 3.141592653589793238
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define pb push_back
#define bg begin()
#define end end()
#define sz size()
#define vi vector<int>
#define vl vector<long long int>
#define mod 1000000007
int main(){
	fast;
	string s;
	int len=0;
	cin>>s;
	while(1){
		s=s.substr(0,s.length()-2);
		if(s.substr(0,s.length()/2)==s.substr(s.length()/2,s.length())){
			cout<<s.length();
			return 0;
		}
	}
}



Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 1000000000

int main(){
	
	int N;
	cin>>N;
	
	int ans  =0;
	for(int i=0;i<N;i++){
		int a;
		cin>>a;
		if(i%2==0&&a%2==1)ans++;
	}
	
	cout<<ans<<endl;
	return 0;
}


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


struct Node {
    int key;
    Node *right,*left,*parent;
    };

Node *root,*NIL;

void insert(int k){
    Node *y=NIL;
    Node *x=root;
    Node *z;

    z=(Node *)malloc(sizeof(Node));
    z->key=k;
    z->left=NIL;
    z->right=NIL;

    while(x!=NIL){
        y=x; 
        if(z->key < x->key){
            x=x->left;
        }else{
            x=x->right;
        }
    }
    z->parent=y;
    if(y==NIL){
        root=z;
    }else{
        if(z->key < y->key){
            y->left=z;
        }else{
            y->right=z;
        }
    }
}
/*Node* find(Node *u,int k){
    while(u!=NIL&&k!=u->key){
        if(k<u->key)u=u->left;
        else u=u->right;
    }
    return u;
}*/
bool find(int k){
    Node* x=root;
    int a=0;
    bool judge=false;
    while(x!=NIL){
        if(x->key==k){
            judge=true;
            break;
        }
        else if(x->key<k){
            //if(a==2) break;
           // a=1;
            x=x->right;

        }else if(x->key>k){
            //if(a==1)break;
            x=x->left;
            //a=2;
        }
    }
    return judge;
}

void preorder(Node* u){
    if(u==NIL)return;
    cout<<" "<<u->key;
    preorder(u->left);
    preorder(u->right);
}
void inorder(Node *u){
    if(u==NIL)return;
    inorder(u->left);
    cout<<" "<<u->key;
    inorder(u->right);
}

int main(){
    int m;
    cin>>m;
    string s;
    int k;
    rep(i,m){
        cin>>s;
        if(s=="insert"){
            cin>>k;
            insert(k);
        }else if(s=="find"){
            cin>>k;
            /*Node* t=find(root,k);
            if(t!=NIL)cout<<"yes"<<endl;
            else cout<<"no"<<endl;*/
            if(find(k))cout<<"yes"<<endl;
            else cout<<"no"<<endl;
        }
        else if(s=="print"){
            inorder(root);
            cout<<endl;
            preorder(root);
            cout<<endl;
        }
    
    }
        return 0;
}

    


Measured memory_bytes: 21908
#include <bits/stdc++.h>
#define REP(i, n) for(int i=0;i<int(n);++i)
using namespace std;
template<class A>void pr(A a){cout << a << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;p(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;p(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;p(b,c,d);}
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
int INF=numeric_limits<int>::max();
// for(int j=0;j<N;++j) {}

int main(void) {
  string s;cin>>s;
  map<char,int> M;
  REP(i,s.length()) {
    M[s[i]] = 0;
  }

  REP(i,s.length()) {
    M[s[i]] += 1;
  }

  for(auto m:M) {
    if(m.second != 2) {
      pr("No");
      return 0;
    }
  }
  pr("Yes");
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
using namespace std;
typedef long long ll;
typedef pair<int, int> P; 
const int inf = 1<<21;
const ll INF = 1LL << 60;
const ll mod = 1e9+7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

// DAME:

class UnionFind {
    // 経路圧縮によるrank更新はなし
    public:
        vector<int> rank, par, size; // rank[x]: xの高さ, par[x]: xの親のノード, size[x]: x

    // 初期化
    UnionFind() {}
    UnionFind(int size){
        rank.resize(size, 0);
        par.resize(size, 0);
        rep(i, size) makeSet(i);
    }

    void makeSet(int x){
        par[x] = x;
        rank[x] = 1;
    }

    // 根を再帰的に求める(経路圧縮)
    int findRoot(int x){
        if(x != par[x]){
            par[x] = findRoot(par[x]);
        }
        return par[x];
    }

    // 根が同じかどうか
    bool same(int x, int y){
        return findRoot(x) == findRoot(y);
    }

    //  xとyの木を併合
    bool unite(int x, int y){
        x = findRoot(x);
        y = findRoot(y);
        if(x==y) return false;
        if(rank[x]<rank[y]) swap(x, y);

        // 単純に繋げない場合, makeSetのrank[x] = 0にするのを忘れずに
        // if(rank[x]==rank[y]) rank[x]++;


        // 単純に一列につなげる場合
        rank[x] += rank[y];


        par[y] = x;
        return true;
    }

    int getRank(int x){
        return rank[findRoot(x)];
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    vector<int> p(n);
    rep(i, n){
        int tmp;
        cin >> tmp;
        tmp--;
        p[i] = tmp;
    }
    UnionFind ds = UnionFind(n);
    rep(i, m){
        int x, y;
        cin >> x >> y;
        x--; y--;
        ds.unite(x, y);
    }
    int ans = 0;
    rep(i, n){
        if (ds.same(i, p[i])) ans++;
    }

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

Measured memory_bytes: 1408
import java.io.File;
import java.io.IOException;
import java.util.*;
 
public class Main {
 
	public static void main(String[] args) throws IOException {
		//File file = new File("input.txt");
		//Scanner sc = new Scanner(file);
		
		Scanner sc = new Scanner(System.in);
		
		int X = sc.nextInt();
		int Y = sc.nextInt();
		int Z = sc.nextInt();
		System.out.println((X - Z) / (Y + Z));
	}
}

Measured memory_bytes: 22996
#include <iostream>
#include <vector>
#define eol '\n'
using namespace std;

vector< vector<int> > list;
vector<int> group;

void bfs(int v, int g) {
  if (group[v] != 0) {
    return;
  }
  group[v] = g;
  for (int i = 0; i < list[v].size(); i++) {
    bfs(list[v][i], g);
  }
}

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

  int n,m,s,t,q;
  cin >> n >> m;

  list = vector< vector<int> >(n, vector<int>());
  group = vector<int>(n,0);
  
  for (int i = 0; i < m; i++) {
    cin >> s >> t;
    list[s].push_back(t);
    list[t].push_back(s);
  }

  int g = 1;
  for (int i = 0; i < n; i++) {
    if (group[i] == 0) {
      bfs(i, g);
      g++;
    }
  }

  cin >> q;
  for (int i = 0; i < q; i++) {
    cin >> s >> t;
    if (group[s] == group[t]) {
      cout << "yes" << eol;
    } else {
      cout << "no" << eol;
    }
  }
  return 0;
}

Measured memory_bytes: 11792
#include <bits/stdc++.h>
#include<math.h>
#define rep(i,n) for (int i = 0; i < (n) ; ++i)
using namespace std;
using ll = long long ;
using P = pair<int, int> ;
#define PI 3.14159265358979323846264338327950
#define INF 1e18 


int main () {
    int n ;
    cin >> n ;
    vector<string> s (n) ;
    rep(i, n){
        cin >> s[i] ;
    }
    rep(i, n){
        sort(s[i].begin(), s[i].end()) ;
    }
    sort(s.begin(), s.end()) ;
    string first = s[0] ;
    ll num = 0 ;
    ll ans = 0 ;
    rep(i, n){
        if(first == s[i]){
            num++ ;
        }
        else if(i != n -1) {
            first = s[i] ;
            ans += num*(num-1)/2 ;
            num = 1 ;
        }
        if(i == n -1) {
            ans += num*(num-1)/2 ;
        }
    }
    cout << ans << endl ;
} 


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

using namespace std;
int main(){
    int a,b; cin>>a>>b;
    map<int,int> m;
    m[a]++;m[b]++;
    for(int i = 1; i<4;i++){
        if(m[i]==0) cout << i <<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
using namespace std;
#define N 505
long long f[N][N],su1[N][N],su2[N][N],dp[N][N],n,su;
long long Max(long long a,long long b){return a>b?a:b;}
int main()
{
	scanf("%lld",&n);for(int i=1;i<=n;i++)for(int j=1;j<=n;j++)if(i!=j)scanf("%lld",&f[i][j]),su+=f[i][j];
	for(int i=1;i<=n;i++)for(int j=1;j<=n;j++)su1[i][j]=f[i][j]*(i<j)+su1[i][j-1]+su1[i-1][j]-su1[i-1][j-1],su2[i][j]=f[i][j]*(i>j)+su2[i][j-1]+su2[i-1][j]-su2[i-1][j-1];
	for(int i=1;i<=n;i++)dp[1][i]=su2[i][i];
	for(int i=1;i<=n;i++)for(int j=1;j<=n;j++)for(int k=j+1;k<=n;k++)dp[j+1][k]=Max(dp[j+1][k],dp[i][j]+su1[j][k]-su1[j][j]+su2[k][k]-su2[k][i-1]-su2[j][k]+su2[j][i-1]);
	long long as=0;for(int i=1;i<=n;i++)as=Max(as,dp[i][n]);printf("%lld\n",su-as);
}

Measured memory_bytes: 8192