akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
using System.Numerics;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            //Out.Flush();
            Read();
        }

        static void Solve()
        {
            var N = Sarray()[0];
            var ai = Sarray();
            var nums = new long[(long)1e5 + 2];
            foreach (var a in ai)
            {
                ++nums[1 + a - 1];
                ++nums[1 + a];
                ++nums[1 + a + 1];
            }
            WriteLine(nums.Max());
        }

        static long Mod = (long)1e9 + 7;
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static public (T1 a, T2 b) Slice<T1, T2>()
        {
            var t = ReadLine().Split();
            return (
            (T1)Convert.ChangeType(t[0], typeof(T1)),
            (T2)Convert.ChangeType(t[1], typeof(T2)));
        }
        static public (T a, T b) Slice2<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)));
        }
        static public (T a, T b, T c) Slice3<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)),
            (T)Convert.ChangeType(t[2], typeof(T)));
        }
    }
}

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

#define ll long long
#define INF_LL 1LL << 60
#define INF 99999999
#define MOD (ll)1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, a, n) for(int i = a; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

void put_double(double obj){printf("%.12f\n",obj);};

template < typename T > std::string to_string( const T& n )
{
    std::ostringstream stm ;
    stm << n ;
    return stm.str() ;
}

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }


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

    int ans = 2;
    while( ans*2 <= N ) ans *= 2;
    cout << min(ans, N) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

int main(void){
    string s,t; cin>>s>>t;
    int n = s.size(), m = t.size();
    vector <vector<int>> dp(n+10 ,vector <int>(m+10 ));
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            if(s[i]==t[j]) dp[i+1][j+1] = dp[i][j] + 1;
            else chmax(dp[i+1][j+1], max(dp[i][j+1], dp[i+1][j]));
        }
    }
    //復元
    string  res = "" ;
    int i = (int)s.size(), j = (int)t.size();
    while(i>0&&j>0){
      // (i-1, j) -> (i, j) と更新されていた場合
        if (dp[i][j] == dp[i-1][j]) {
            --i; // DP の遷移を遡る
        }

        // (i, j-1) -> (i, j) と更新されていた場合
        else if (dp[i][j] == dp[i][j-1]) {
            --j; // DP の遷移を遡る
        }

        // (i-1, j-1) -> (i, j) と更新されていた場合
        else {
            res = s[i-1] + res; // このとき s[i-1] == t[j-1] なので、t[j-1] + res でも OK
            --i, --j; // DP の遷移を遡る
        }  
    }
    cout<<res<<endl;
}


Measured memory_bytes: 35712
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define INF (1LL<<50)
#define MOD 1000000007

int main(){
    int x;
    cin >> x;
    cout << (x+1)%2 << endl;
    return 0;
}

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

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


int main() {
    int n;
    int a[110];


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

    rep(i, n) {
        if (a[i] % 2 == 0) {
            if (a[i] % 3 != 0 && a[i] % 5 != 0) {
                cout << "DENIED" << endl;
                return 0;
            }
        }
    }

    cout << "APPROVED" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define sz(x) int(x.size())
#define pb push_back
#define eb emplace_back
using ll=long long;
using P = pair<int,int>;
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
const ll MOD=1000000007;



int main() {
    int K;
    string S;
    cin>>K>>S;
    int l=S.size();
    if(l<=K){cout<<S<<endl;}
    else{
        rep(i,K){
            cout<<S.at(i);
        }
        cout<<"..."<<endl;
    }
}

Measured memory_bytes: 3632
package main

import "fmt"

func main() {
  var n, a, b int
  fmt.Scan(&n, &a, &b)
  c := 0
  for i := 1; i <= n; i++ {
    s := 0
    t := i
    for t > 0 {
      s += t % 10
      t /= 10
    }
    if a <= s && s <= b {
      c += i
    }
  }
  fmt.Println(c)
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define int long long
void solve(){
	int x;cin>>x;
    if(x>=30) cout<<"Yes";
    else cout<<"No";
}
int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL); 
	int T=1;
	// cin>>T;
	while(T--){
		solve();
	}
	return 0;
}


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

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

  ll N; cin >> N;
  vector<ll> A(N); for (ll i = 0; i < N; i++) cin >> A[i];
  vector<ll> cnt(1000005, 0);
  vector<ll> primes(1000005, 0);

  for (ll i = 0; i < N; i++) {
    ll a = A[i];
    for (ll j = 2; j * j <= a; j++) {
      if (a % j == 0) {
        primes[j] = 1;
        cnt[j]++;
        if (primes[a] == 1) {
          a == 1;
          break;
        }
        for (ll k = 0; k < 100000; k++) {
          a /= j;
          if (a % j != 0) break;
        }
      }
    }
    if (a != 1) {
      cnt[a]++;
    }
  }

  ll check = 0;
  for (ll i = 0; i < 1000005; i++) {
    check = max(check, cnt[i]);
  }

  string ans = "pairwise coprime";
  if (check >= N) ans = "not coprime";
  else if (check > 1) ans = "setwise coprime";
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 26660
#include <bits/stdc++.h>
using namespace std;
int main () {
    int N;
    cin >> N;
    vector<long long> A(N), B(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i] >> B[i];
    }
    long long k = 0;
    for (int i = N-1; i >= 0; i--) {
        A[i] += k;
        if (A[i] % B[i] != 0) {
            k += B[i]-(A[i] % B[i]);
        }
    }
    cout << k << endl;
}

Measured memory_bytes: 1792
#pragma GCC optimize(2)
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<map>
#include<string> 
#include <math.h>
#include<bits/stdc++.h> 
using namespace std;
typedef long long ll; 
inline int read()
{
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
ll a,b,c;
ll min(ll x,ll y){
	if(x>y){
		return y;
	}
	else{
		return x; 
	}
}
void inint(){
	cin>>a>>b>>c;
}
int main(){
	inint();
	if(a%2==0||b%2==0||c%2==0){
		printf("0\n");
	}
	else{
		ll t1=a*b;
		ll t2=a*c;
		ll t3=b*c;
		printf("%lld\n",min(t1,min(t2,t3)));
	}
} 

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <assert.h>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <unordered_map>
#include <numeric>
#include <functional>
#include <atcoder/all>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(i,a) for(ll i=ll(a-1);i>=0;--i)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using namespace atcoder;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}

const int INF = 1e9;
const ll MOD = 1000000007;
const ll MOD2 = 998244353;
const ll MOD3 = 1e6;
const ll EPS = 1e-10;
int sgn(const double a){
    return (a < -EPS ? -1 : (a > EPS ? +1 : 0));
}
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> tri;
typedef pair<long double,long double> point;
typedef complex<long double> Point;
const ll MAX = 100005;
constexpr ll nx[4] = {-1,0,1,0};
constexpr ll ny[4] = {0,1,0,-1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,q;
    cin >> n >> q;
    fenwick_tree<ll> g(n);
    rep(i,n){
        ll a;
        cin >> a;
        g.add(i,a);
    }
    ll t,l,r;
    rep(i,q){
        cin >> t >> l >> r;
        if (t == 0){
            g.add(l,r);
        }
        else{
            PRINT(g.sum(l,r));
        }
    }
}


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

int main(void){
  int N;
  cin >> N;
  vector<string>vec_N(N);
  for(int i=0; i<N; ++i){
    cin >> vec_N.at(i);
  }
  
  int M;
  cin >> M;
  vector<string>vec_M(M);
  for(int j=0; j<M; ++j){
    cin >> vec_M.at(j);
  }
 
  //単語リスト作成
  int CheckCnt=0;
  string bWord;
  vector<string>vec_Word;
  for(int i=0; i<N; ++i){
    if(i==0)
    {
      vec_Word.push_back(vec_N.at(i));
      bWord=vec_N.at(i);
    }
    else
    {
      if(bWord!=vec_N.at(i)){
        for(int j=0; j<vec_Word.size(); ++j){
          if(vec_N.at(i) == vec_Word.at(j)){
            CheckCnt=1;
          }
        }
      }
    }
    if(bWord!=vec_N.at(i) && CheckCnt==0)
    {
       vec_Word.push_back(vec_N.at(i));
       bWord=vec_N.at(i);
     }
   CheckCnt=0;
  }
  
  for(int i=0; i<vec_M.size(); ++i){
    for(int j=0; j<vec_Word.size(); ++j){
      if(vec_M.at(i)==vec_Word.at(j)){
        CheckCnt++;
      }
    }
    if(CheckCnt==0){
      vec_Word.push_back(vec_M.at(i));
    }
    CheckCnt=0;
  }
  
  //青と赤のカウント
  int answer=0;
  for(int i=0; i<vec_Word.size(); ++i){
    int BlueCnt=0;
    for(int j=0; j<vec_N.size(); ++j){
      if(vec_Word.at(i) == vec_N.at(j)){
        BlueCnt++;
      }
    }
    int RedCnt=0;
    for(int k=0; k<vec_M.size(); ++k){
      if(vec_Word.at(i) == vec_M.at(k)){
        RedCnt++;
      }
    }
    int sumPrice = BlueCnt - RedCnt;
    if(answer < sumPrice){
      answer=sumPrice;
    }
  }
  //答えを出力
  if(answer < 0){
    answer=0;
  }
  cout << answer << endl;
}

Measured memory_bytes: 256
n = int(input())
h = list(map(int,input().split()))
c = [0]*n
c[1]=abs(h[1]-h[0])
for i in range(2,n):
    c[i]=min(c[i-2]+abs(h[i]-h[i-2]),c[i-1]+abs(h[i]-h[i-1]))
print(c[n-1])


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

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

Measured memory_bytes: 3580
r,g,b,N=map(int,input().split())
c=0
for i in range(N//r+1):
    for j in range(N//g + 1):
        t = (N-i*r-j*g)
        if t%b ==0 and t>=0:
            #print(i,j,t//b)
            c+=1
print(c)

Measured memory_bytes: 40684
s = input()

idx_of_a = idx_of_z = -1
for i in range(len(s)):
    if s[i] == 'A' and idx_of_a == -1:
        idx_of_a = i
    elif s[i] == 'Z' and i > idx_of_z:
        idx_of_z = i

print(idx_of_z - idx_of_a + 1)


Measured memory_bytes: 3516
#include <bits/stdc++.h>
using namespace std;
#define N 200100

int n,L,R,x,y;
int d[2][N][20],a[N],pos[N],Log[N],t1[N],t2[N];
priority_queue<int,vector<int>,greater<int> > S;

void build() {
	for (int i=2;i<=n;i++) Log[i]=Log[i>>1]+1;
	for (int i=1;i<=n;i++) d[i&1][i][0]=a[i],d[(i&1)^1][i][0]=n+1;
	for (int i=1;i<=18;i++)
		for (int j=1;j+(1<<i)-1<=n;j++)
			for (int k=0;k<2;k++)
				d[k][j][i]=min(d[k][j][i-1],d[k][j+(1<<(i-1))][i-1]);
}

int query(int o,int l,int r) {
	//printf("%d %d %d\n",o,l,r);
	int len=Log[r-l+1];
	return min(d[o][l][len],d[o][r-(1<<len)+1][len]);
}

int query_begin(int x) {
	int ret=0;
	for (;x;x-=x&(-x)) ret=max(ret,t1[x]);
	return ret;
}

void begin_add(int x) {
	int tmp=x;
	for (;x<=n;x+=x&(-x)) t1[x]=max(t1[x],tmp);
}

int query_end(int x) {
	int ret=n+1;
	for (;x<=n;x+=x&(-x)) ret=min(ret,t2[x]);
	return ret;
}

void end_add(int x) {
	int tmp=x;
	for (;x;x-=x&(-x)) t2[x]=min(t2[x],tmp);
}

void Push(int l,int r) {
	if (l>r) return;
	S.push(query(l&1,l,r));
}

int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;i++) scanf("%d",&a[i]),pos[a[i]]=i;
	build();
	S.push(query(1,1,n));
	for (int i=1;i<=n;i++) t2[i]=n+1;
	while (!S.empty()) {
		x=S.top(); S.pop();
		L=query_begin(pos[x]-1);
		R=query_end(pos[x]+1);
		y=query((pos[x]&1)^1,pos[x]+1,R-1);
		printf("%d %d ",x,y);
		Push(L+1,pos[x]-1);
		Push(pos[x]+1,pos[y]-1);
		Push(pos[y]+1,R-1);
		begin_add(pos[x]); begin_add(pos[y]);
		end_add(pos[x]); end_add(pos[y]);
	}
	return 0;
}

Measured memory_bytes: 36988
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)

	mm := make([]map[rune]int, n)
	for i := 0; i < n; i++ {
		var s string
		fmt.Scan(&s)
		mm[i] = make(map[rune]int)
		for _, c := range s {
			mm[i][c]++
		}
	}

	cs := make([]int, 26)
	for i := 0; i < 26; i++ {
		cs[i] = 999999
	}

	for i := 0; i < 26; i++ {
		for j := 0; j < n; j++ {
			t := mm[j][rune('a'+i)]
			if t < cs[i] {
				cs[i] = t
			}
		}
		for j := 0; j < cs[i]; j++ {
			fmt.Printf("%c", 'a'+i)
		}
	}
	fmt.Println()
}


Measured memory_bytes: 512
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <sstream>
#include <cassert>
using namespace std;
static const double EPS = 1e-5;
typedef long long ll;
typedef pair<int,int> PI;
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define MP make_pair
#define PB push_back

main(){
  int n;
  while(cin>>n,~n){
    string str;
    if(n==0)str+='0';
    while(n){
      str+=n%4+'0';
      n/=4;
    }
    reverse(str.begin(),str.end());
    cout<<str<<endl;
  }
}

Measured memory_bytes: 0
#include<stdio.h>

#define MAX 100005
#define NIL -1

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

struct Node T[MAX];
int n,D[MAX],H[MAX];


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

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

  printf("[");

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

void rec(int u,int p){
  D[u]=p;
  if(T[u].r!=NIL)rec(T[u].r,p);
  if(T[u].l!=NIL)rec(T[u].l,p+1);}

int main(){
  int i,j,d,v,c,l,r;
  scanf("%d",&n);
  for(i=0;i<n;i++)
    T[i].p=T[i].l=T[i].r=NIL;

  for(i=0;i<n;i++){
   scanf("%d%d",&v,&d);
    for(j=0;j<d;j++){
      scanf("%d",&c);
	if(j==0)T[v].l=c;
	else T[l].r=c;
	l=c;
	T[c].p=v;
      }
    }
    for(i=0;i<n;i++){
      if(T[i].p==NIL)r=i;
    }

    rec(r,0);

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



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

int main() {
  int n;
  cin >> n;
  vector<int> d(n);
  for (int i = 0; i < n; i++) {
    cin >> d[i];
  }
  sort(d.begin(), d.end());
  cout << d[n / 2] - d[n / 2 - 1] << endl;
  return 0;
}


Measured memory_bytes: 640
#include<iostream>

int main(void){
    signed long long x;
    signed long long k;
    signed long long d;
    signed long long a;
    std::cin >> x;
    std::cin >> k;
    std::cin >> d;
    if(x < 0){
        x = -x;
    };
    if(x / d >= k){
        a = x - (d * k);
    }
    else{
        if(((k - (x / d)) % 2) == 0){
            a = x % d;
        }
        else{
            a = -((x % d) - d);
        };
    };
    std::cout << a << std::endl;
    return 0;
};


Measured memory_bytes: 3584
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);    
    
    int A, B; cin >> A >> B;
    cout << max(A+B, max(A-B, A*B)) << endl;
    
    
    return 0;
}

// read the question correctly (ll vs int)
// template by bqi343


Measured memory_bytes: 256
def main(n, k, h):

    h.sort()

    for i in range(k):
        try:
            h.pop()
        except IndexError:
            pass

    print(sum(h))


if __name__ == "__main__":
    n, k = map(int, input().split())
    h = list(map(int, input().split()))

    main(n, k, h)


Measured memory_bytes: 26024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
//#define ll long long
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define rep(i, n) REP(i, 0, n)
#define rep_rev(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define all(x) (x).begin(),(x).end()
ll t1,t2,t3;
const ll mod = 1000000007;
const int INF = 1e9;
const ll INFLONG = 1e18;
void swap(ll *x,ll *y) {
  ll tmp;
  tmp = *x;
  *x = *y;
  *y = tmp;
}

int main(){
  ll x;
  cin >> x;
  t1 = x / 500;
  t2 = x% 500;
  t2 /= 5;
  cout << t1 * 1000 + t2 * 5 << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <limits.h>
#include <math.h>
int acs(const void *a, const void *b) { return *(int *)a - *(int *)b; }                            /* 1,2,3,4.. */
int des(const void *a, const void *b) { return *(int *)b - *(int *)a; }                            /* 8,7,6,5.. */
int cmp_char(const void *a, const void *b) { return *(char *)a - *(char *)b; }                     /* a,b,c,d.. */
int cmp_str(const void *a, const void *b) { return strcmp(*(const char **)a, *(const char **)b); } /* aaa,aab.. */
#define min(a, b) (a < b ? a : b)
#define max(a, b) (a > b ? a : b)
#define rep(i, n) for (int i = 0; i < n; i++)
#define MAX 100001
#define MOD 1000000007

typedef long long int lli;

int main(void)
{
  int a, b;
  scanf("%d %d", &a, &b);

  if (a > 9 || b > 9)
  {
    printf("-1\n");
    return 0;
  }

  printf("%d\n", a * b);
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <cmath>
#include <unordered_map>

using LL = int;
inline LL R(){
    char c='!';LL x=0,z=1;
    for( ; c>'9'||c<'0';c=getchar()) if(c=='-')z=-1;
    for(;c>='0'&&c<='9';c=getchar()) x=x*10+c-'0';
    return x*z;
}

size_t A[200000];
int main(void) {
  int n;

  std::cin >> n; /* 1 to 3*10^5 */

  //int* A = new int[n];
  for (size_t i = 0; i < n; i++) {
    A[i] = R();
    //std::cin >> A[i];
  }

  size_t count = 0;

  size_t lsum = 0;
  size_t rsum = 0;
  size_t l, r;
  size_t offset = 0;
  size_t i = 0;
  while(i < n) {
    size_t lcount = 0;
    for (size_t j = i + offset; j < n; ++j) {
      l = lsum ^ A[j];
      r = rsum + A[j];
      if (l != r) {
        break;
      }
      lcount++;
      lsum = l;
      rsum = r;
    }

    count += lcount + offset;

#if 0
    if (lcount + offset > 1) {
      offset = lcount + offset - 1;
    } else {
      offset = 0;
    }
#else
    offset += lcount;
    if (offset) {
      --offset;
    }
#endif
    lsum ^= A[i];
    rsum -= A[i];
    ++i;
  }

  std::cout << count << std::endl;;

  return 0;
}

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

int main()
{
  int a1,a2,a3;
  cin>>a1>>a2>>a3;
  
  if((a1 + a2 + a3)>=22)
  {
    cout<<"bust"<<endl;
  }
  else
  {
    cout<<"win"<<endl;
  }
  
}


Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
    long long sum = 0;
    for (int i = 1; i <= n; i++)
    {
        if (i % 15 == 0 || i % 3 == 0 || i % 5 == 0)
            continue;
        else
        {
            sum += i;
        }
    }
    cout << sum;
}

Measured memory_bytes: 3604
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>

#define int long long
#define MOD7 1000000007
#define MOD9 1000000009

#define rep(i, n) for (int i = 0; i < (n); i++)
#define itrep(i, a) for (auto i = (a).begin(); i != (a).end(); i++)
#define REP(i, a, n) for (int i = (a); i <= (n); i++)
#define all(a) (a).begin(), (a).end()
#define mp(a, b) make_pair((a), (b))

using namespace std;

int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, -1, 0, 1 };

template<class T> void inputVector(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < v.size(); i++) cin >> v[i];
}

signed main() {
    vector<int> v(4);
    rep(i, 4) cin >> v[i];

    sort(all(v));

    if (v[0] == 1 && v[1] == 4 && v[2] == 7 && v[3] == 9) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
using namespace std;

string S;
int K, N;

int main() {
	cin >> S >> K;
	N = S.size();
	vector<string> ss;   //K文字だけ
	for (int n = 0; n < N; n++) {
		ss.push_back(S.substr(n, min(K, N - n)));
	}
	//2文字目以降を見て昇順
	sort(ss.begin(), ss.end(), [](string a, string b) {
		for (int n = 0; n < min(a.size(), b.size()); n++) {
			if (a[n] != b[n])return a[n] < b[n];
		}
		return a.size() < b.size();
		});
	set<string> sset;   //今まで見た文字列の保存用
	for (int s = 0; s < ss.size(); s++) {
		for (int n = 1; n <= ss[s].size(); n++) {
			sset.insert(ss[s].substr(0, n));
			if (sset.size() == K) {
				cout << ss[s].substr(0, n) << endl;
				return 0;
			}
		}
	}
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define rrep(i, n) for (int i = (int)n-1; i >= 0; --i)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

__attribute__ ((constructor))
void init() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
}

signed main(){
    int n, x, t;
    cin >> n >> x >> t;
    cout << ((n + x - 1) / x) * t << endl;
    return 0;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define int long long

using namespace std;

const int O = 1e6 + 5;

main(){
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int a, b; cin >> a >> b;
    int Val1 = (a * 100) / 8;
    int Val2 = b * 10;
    for (int i = min(Val1, Val2); i <= max(Val1, Val2) + 100; ++ i){
        int l = i * 8 / 100;
        int r = i / 10;
        if (l == a && r == b){
            cout << i;
            return 0;
        }
    }
    cout << -1;
}

Measured memory_bytes: 256
import sys
import heapq
input = sys.stdin.readline


def dijkstra(s, n, edge):
    d = [float("inf")] * n
    d[s] = 0
    q = []
    for e in edge[s]:
        heapq.heappush(q, e)
    while q:
        minedge = heapq.heappop(q)
        v = minedge[1]
        if d[v] < minedge[0]:
            continue
        d[v] = minedge[0]
        for e in edge[v]:
            heapq.heappush(q, [e[0]+d[v], e[1]])
    return d


def main():
    N = int(input())
    E = [[] for _ in range(N)]
    for _ in range(N-1):
        u, v, w = map(int, input().split())
        E[u-1].append([w, v-1])
        E[v-1].append([w, u-1])
    D = dijkstra(0, N, E)
    for d in D:
        print(d % 2)


if __name__ == '__main__':
    main()


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

#define F first
#define S second

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;

const int N = 1010, M = 3, INF = 0x3f3f3f3f;

int n, m;
LL w[N][M];
LL val[N];

int main()
{
	scanf("%d%d", &n, &m);
	for (int i = 0; i < n; i ++ )
		for (int j = 0; j < M; j ++ )
			scanf("%lld", &w[i][j]);
	
	LL res = -1e18;
	for (int t = 0; t < 1 << M; t ++ )
	{
		for (int i = 0; i < n; i ++ )
		{
			val[i] = 0;
			for (int j = 0; j < M; j ++ )
			{
				if ((t >> j) & 1) val[i] += w[i][j];
				else val[i] -= w[i][j];
			}
		}
		sort(val, val + n);
		reverse(val, val + n);
		
		LL s = 0;
		for (int i = 0; i < m; i ++ ) s += val[i];
		res = max(res, s);
	}
	printf("%lld\n", res);
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)
int main() {
    int n, k;
    cin >> n >> k;
    vector<double> exp(n);
    rep(i, n) {
        int p;
        cin >> p;
        double tmp_exp = 0.0;
        for ( int i = 1; i <= p; ++i ) {
            tmp_exp += i / (double)p;
        }
        if ( i == 0 ) exp[0] = tmp_exp;
        else          exp[i] = tmp_exp + exp[i-1];
    }
    double max_exp = 0.0;
    rep(i, n - k + 1 ) {
        if ( i == 0 ) max_exp = max(exp[k-1], max_exp);
        else          max_exp = max(exp[k-1+i] - exp[i-1], max_exp);
    }
    printf("%.6lf", max_exp);
    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <fstream>
#include <algorithm>
#include <vector>
#include <string>
#include <functional>
#include <array>
#include <stack>
#include <queue>
#include <chrono>
#include <numeric>
#include <memory.h>

#pragma warning(disable:4996)
#define REP(i,n) for(int i = 0 ; i < n ; ++i)
typedef long long Int;

using namespace std;


int dx[4] = { 0, -1, 0, 1 };
int dy[4] = { 1, 0, -1, 0 };

const Int M_H(20);
const Int M_W(20);

short tile[M_H][M_W];
int H, W;

struct point{
	Int x, y, step;
	short tile[M_H][M_W];
	point(Int x_, Int y_, Int s,short tile_[M_H][M_W]) :x(x_), y(y_), step(s)
	{
		memcpy(tile, tile_, sizeof(tile));
	}
};

queue<point> que;

int solve()
{
	while (!que.empty()){
		auto now = que.front();
		que.pop();

		if (now.step >= 10)
			continue;

		int i(4);
		while (i--){
			int x = now.x + dx[i];
			int y = now.y + dy[i];
			if (now.tile[y][x] == 1)
				continue;
			if (now.tile[y][x] == 4)
				continue;
			while(now.tile[y][x] == 0){
				x += dx[i];
				y += dy[i];
				if (x >= M_W || x < 0 || y >= M_H || y < 0)
					break;
			} 
			if (x >= M_W || x < 0 || y >= M_H || y < 0)
				continue;
			if (now.tile[y][x] == 1){
				short temp[M_H][M_W];
				memcpy(temp, now.tile, sizeof(temp));
				temp[y][x] = 0;
				que.emplace(x - dx[i], y - dy[i], now.step + 1, temp);
			}
			if (now.tile[y][x] == 3)
				return now.step + 1;

			if (now.tile[y][x] == 4)
				continue;
		}
	}
	return -1;
}

int main()
{
	cin.tie(0); ios::sync_with_stdio(false);
	//fstream fs("input.txt");
	////////////ここから開始///////////
	//fs >> W >> H;
	 
	while (cin >> W >> H,H){
		REP(i, M_H)REP(j, M_W){ tile[i][j] = 4;}

		REP(i, H)REP(j, W)cin >> tile[i][j];

		que = {};

		REP(i, H)REP(j, W){
			if (tile[i][j] == 2){
				tile[i][j] = 0;
				que.emplace(j, i, 0, tile);
			}
		}
		cout << solve() << endl;
	}

	return 0;
}

Measured memory_bytes: 62024
n = int(input())

s = input()
t = input()
ans = n
flag = 1
for i in range(n):
    f = 1
    for j in range(n-i):
        if s[i+j] != t[j]:
            f = 0
            break
    if f == 1:
        ans += i
        flag = 0
        break
        
if flag == 1:
    ans += n
print(ans)

Measured memory_bytes: 3060
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main(){
	string input;
	cin>>input;
	int num;
	cin>>num;
	int flag=0;
	for(int i=0;i<num;i++){
		int t;
		cin>>t;
		if(t==1){
			flag=!flag;
		}else{
			int f;
			char target;
			cin>>f>>target;
			if(flag==0){
				if(f==1){
					input.insert(input.begin(),target);
				}else{
					input.insert(input.end(),target);
				}
			}else{
				if(f==1){
					input.insert(input.end(),target);
				}else{
					input.insert(input.begin(),target);
				}
			}	
		}
	}
	if(!flag) cout<<input;
	else{
		for(int i=input.length()-1;i>=0;i--){
			cout<<input[i];
		}
	}
	
	return 0;
}

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

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

using namespace std;
using lint=long long;

const int INF=1<<29;

class segment_tree_dual{
	int n;
	vector<int> seg;

	void update(int l,int r,int a,int b,int u,int x){
		if(l<=a && b<=r){ seg[u]=min(seg[u],x); return; }
		int c=(a+b+1)/2;
		if(l<c && a<r) update(l,r,a,c,2*u  ,x);
		if(l<b && c<r) update(l,r,c,b,2*u+1,x);
	}

public:
	segment_tree_dual(int N){
		for(n=1;n<N;n*=2);
		seg.assign(2*n,INF);
	}

	void update(int l,int r,int x){ update(l,r,0,n,1,x); }

	int get(int u){
		u+=n;
		int res=seg[u];
		for(u/=2;u>=1;u/=2) res=min(res,seg[u]);
		return res;
	}
};

int main(){
	int n,q; scanf("%d%d",&n,&q);

	segment_tree_dual R(n),C(n);
	R.update(1,n-1,n-2);
	C.update(1,n-1,n-2);

	lint ans=(n-2LL)*(n-2LL);
	rep(_,q){
		int type,x; scanf("%d%d",&type,&x); x--;
		if(type==1){
			int val=C.get(x);
			ans-=val;
			R.update(1,val+1,x-1);
		}
		else{
			int val=R.get(x);
			ans-=val;
			C.update(1,val+1,x-1);
		}
	}
	printf("%lld\n",ans);

	return 0;
}


Measured memory_bytes: 7456
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i<(int)(n); i++)
#define all(vec) vec.begin(),vec.end()
#define MOD 1000000007
#define int long long

signed main(){
    int n,d,x;cin>>n>>d>>x;
    int ans=0;
    rep(i,n){
        int a;cin>>a;
        ans+=(d+a-1)/a;
    }
    cout<<ans+x<<endl;
}

Measured memory_bytes: 256
import sys
n,m,x=map(int,input().split())
A=[]
for i in range(n):
    ca=list(map(int,input().split()))
    A.append(ca)
ans=10**7

for i in range(2**n):#n冊をそれぞれ選ぶか選ばないか
    tmp=[0]*m
    cost=0
    for j in range(n):#ある選び方
        if (1<<j)&i:
            cost+=A[j][0]
            for k in range(m):
                tmp[k]+=A[j][k+1]
    check=True
    for l in range(m):#理解度がx以上か判定
        if tmp[l]<x:
            check=False
            break
    #else:
    if check:
        ans=min(ans,cost)#すべてのアルゴリズムの目標理解度を満たすとき
                        #(for文が最後まで実行されるとelseが実行)
if ans==10**7:#ansが更新されない場合
    ans=-1
print(ans)




Measured memory_bytes: 9132
#include <iostream>
#include<cstdlib>
#include<queue>
#include<set>
#include<vector>
#include<stack>
#include<map>
#include<list>
#include<string>
#include<algorithm>
#include<cstdio>
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)
#define mp make_pair
#define pb push_back

#define ll __int64
#define P pair<ll,ll>
//#define __int64 long long

int h,w;
string t[1000];
int cnt[50];
int a,b,c;
int aa,bb,cc;
int main(){	
	cin>>h>>w;
	rep(i,h)cin>>t[i];
	a=h*w;

	if(h&1&&w&1){

		b+=h+w-2;
		a-=h+w-2;
	}
	else if(h&1){
		b+=w;
		a-=w;
	
	}

	else if(w&1){
		b+=h;
		a-=h;
	}
	a/=4;
	b/=2;
	
	bool ok=1;
	rep(i,h){
		rep(j,w)cnt[(int)(t[i][j]-'a')]++;
	}
	
	//rep(i,26)cout<<cnt[i]<<endl;

	rep(i,26){
		aa+=cnt[i]/4;
		cnt[i]-=cnt[i]/4*4;
	}

	rep(i,26){
		bb+=cnt[i]/2;
		cnt[i]-=cnt[i]/2*2;
	}

	if(a<=aa){
		bb+=(aa-a)*2;
	}
	//cout<<a<<" "<<b<<" "<<aa<<" "<<bb<<endl;
	
	if(a<=aa&&b<=bb)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;



	return 0;

}


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

char s[100005];
int main(){
	int n;scanf("%d",&n);
	scanf("%s",s);
	int ans = 0;
	for(int i=0;i<n;i++)
		if(i==0 || s[i]!=s[i-1])
			ans ++;
	printf("%d\n",ans);
}

Measured memory_bytes: 384
#include <stdio.h>
#include <iostream>
using namespace std;
int main()
{
    int n, m;
    while(cin >> n >> m)
    {
        int tmp = 1900 * m + 100 * (n - m);
        int add = 1;
        for(int i = 0; i < m; i++) add *= 2;
        cout << tmp * add << endl;
    }
    return 0;
}


Measured memory_bytes: 256
def main():
  n, l = map(int, input().split())
  total = sum([l + i for i in range(n)])
  mina = pow(10, 9)
  for i in range(n):
    _l = l + i
    if abs(_l) < abs(mina):
      mina = _l
  print(total - mina)


if __name__ == '__main__':
  main()


Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include<algorithm>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define repm(i, m, n) for (int i = (m); i < (n); i++)
#define rep_rev(i, n) for (int i = int (n); i >= 0; i--)
typedef long long ll;
using namespace std;

int main() {
	int n, h[100000];
	cin >> n;
	rep(i, n)cin >> h[i];

	bool flag = true;
	int max_num = h[0];
	rep1(i, n) {
		if (h[i] - 1 > max_num) {
			h[i]--;
			max_num = h[i];
		}
		else if (h[i] == max_num) {
			h[i]--;
		}
		else if (h[i] < max_num) {
			flag = false;
			break;
		}
	}
	if(flag) cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}

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

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

Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    string s;
    cin>>n>>s;
    if(s.length()>n){
    for(int i=0;i<n;++i)
        cout<<s[i];
    cout<<"..."<<endl;
    }
    else cout<<s<<endl;
}


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

int main(void){
  char *s;
  s = (char *)malloc(sizeof(char));
  scanf("%s", s);
  
  int count = 0;
  int n = strlen(s);
  for(int i = 0; i < n; i++){
    if(s[i] != s[n-1-i]) count++;
  }
  printf("%d", count/2);
  return 0;
}

Measured memory_bytes: 128
def solve(CC):
    R = [sum(CC[i]) for i in range(3)]
    C = [sum(CC[j][i] for j in range(3)) for i in range(3)]
    checked = all((R[i] - R[i - 1]) % 3 == 0 for i in range(3))
    checked &= all((C[i] - C[i - 1]) % 3 == 0 for i in range(3))
    return 'Yes' if checked else 'No'

_CC = [list(map(int, input().split())) for _ in range(3)]
print(solve(_CC))


Measured memory_bytes: 3064
import java.util.Scanner;

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

        int N = sc.nextInt();
        int M = sc.nextInt();
        char[][] A = readGrid(sc, N);
        char[][] B = readGrid(sc, M);

        System.out.println(solve(A, B) ? "Yes" : "No");

        sc.close();
    }

    static char[][] readGrid(Scanner sc, int size) {
        char[][] result = new char[size][size];
        for (int r = 0; r < size; ++r) {
            String line = sc.next();
            for (int c = 0; c < size; ++c) {
                result[r][c] = line.charAt(c);
            }
        }

        return result;
    }

    static boolean solve(char[][] A, char[][] B) {
        int N = A.length;
        int M = B.length;

        for (int minR = 0; minR + M <= N; ++minR) {
            for (int minC = 0; minC + M <= N; ++minC) {
                if (isSame(A, B, minR, minC)) {
                    return true;
                }
            }
        }

        return false;
    }

    static boolean isSame(char[][] A, char[][] B, int minR, int minC) {
        int M = B.length;

        for (int r = 0; r < M; ++r) {
            for (int c = 0; c < M; ++c) {
                if (A[minR + r][minC + c] != B[r][c]) {
                    return false;
                }
            }
        }

        return true;
    }
}

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

using namespace std;

int k, a, b;
int main() {
    ios_base::sync_with_stdio(0);
    cin >> k;
    cin >> a >> b;

    if((b/k) -  ((a - 1) / k ) > 0) {
        cout << "OK" << endl;
    }
    else {
        cout << "NG"  << endl;
    }

    

    return 0;
}


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


int main() {
  long n;
  cin>>n;
  vector<long>a(n);
  rep(i,n){
    cin>>a.at(i);
  }
  sort(a.begin(),a.end());
  reverse(a.begin(),a.end());
  priority_queue<long>p;
  long ans=0;
  p.push(a[0]);
  rep2(i,1,n){
    ans+=p.top();
    p.pop();
    p.push(a[i]);
    p.push(a[i]);
  }
  cout<<ans<<endl;
}




Measured memory_bytes: 6932
#include <stdio.h>
#include <string.h>
#define N 2000

int n, q, in;
char dp[2][40001];

void swap(int* a, int* b){
  int tmp = *a;
  *a = *b;
  *b = tmp;
}

main(){
  while(scanf("%d", &n) != EOF){
    int i, j, next = 1, cur = 0;
    for(i=0;i<2;i++) for(j=0;j<=40000;j++) dp[i][j] = 0;
    dp[0][0] = 1;
    for(i=0;i<n;i++){
      scanf("%d", &in);
      for(j=0;j<=40000;j++){
        if(dp[cur][j]){
          dp[next][j+in] = 1;
          dp[next][j] = 1;
        }
      }
      swap(&next, &cur);
    }
    scanf("%d", &q);
    for(i=0;i<q;i++){
      scanf("%d", &in);
      printf("%s\n", (dp[cur][in] ? "yes" : "no"));
    }
  }
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
#define int     long long
#define F       first
#define S       second
#define _READ   freopen("input.txt","r", stdin);
#define _FAST   ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
vector<int> edges [2005];
map<int,set<pair<int,int>>> mp;
void bfs(int n,int i)
{
	int source=i;
	vector<int> dist(n+1,0),visited(n+1,0);
	queue<int> q;
	dist[i]=0;
	visited[i]=1;
	q.push(i);
	while(!q.empty())
	{
		i=q.front(); q.pop();
		for(auto j:edges[i])
		{
			if(visited[j]==0)
			{
				visited[j]=1;
				dist[j]=dist[i]+1;
				q.push(j);
				mp[dist[j]].insert({min(j,source),max(j,source)});
			}
		}
	}
}
void solve()
{
	int n,x,y;
	cin>>n>>x>>y;
	for(int i=2;i<=n;i++)
	{
		edges[i-1].push_back(i);
		edges[i].push_back(i-1);
	}
	edges[x].push_back(y);
	edges[y].push_back(x);
	for(int i=1;i<=n;i++)
		bfs(n,i);
	for(int i=1;i<=n-1;i++)
	{
		if(!mp.count(i))
		{
			cout<<"0\n";
			continue;
		}
		cout<<mp[i].size()<<"\n";
	}
}
int32_t main()
{
    int t;
    t=1;
    while(t--)
        solve();
    return 0;
}
/*
===FOR N-Dimensional Vector===
https://codeforces.com/blog/entry/76149
g++ -std=c++17 -Wshadow -Wall -g -fsanitize=address -fsanitize=undefined a.cpp -o a -D_GLIBCXX_DEBUG
*/

Measured memory_bytes: 126336
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<iomanip>
#include<math.h>
#include<bitset>
using namespace std;
using ll=long long;
using ld=long double;
using P=pair<ll,ll>;
#define MOD 1000000007LL
#define INF 1000000000LL
#define EPS 1e-10
#define FOR(i,n,m) for(ll i=n;i<(ll)m;i++)
#define REP(i,n) FOR(i,0,n)
#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define ALL(v) v.begin(),v.end()
#define UNIQUE(v)  sort(ALL(v));v.erase(unique(ALL(v)),v.end());
#define pb push_back

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll x, y;
	cin >> x >> y;
	cout << x + y / 2 << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;  
typedef long long ll;
int main() {
  ll N,Y;
  cin >> N >> Y;
  
  ll a=-1,b=-1,c=-1,y=Y/1000;
  for (ll i=0;i<=y/10;i++) {
    for (ll j=0;j<=(y-10*i)/5;j++) {
      if (y-N == 9*i+4*j) {
        a = i;
        b = j;
        c = N-a-b;
        break;
      }
    }
  }
  
  cout << a << ' ' << b << ' ' << c;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
int main()
{
  double x1,x2,y1,y2;
  int i,j;
  scanf("%lf %lf %lf %lf",&x1,&y1,&x2,&y2);
  double ans=hypot(x2-x1,y2-y1);
  printf("%f\n",ans);
  return 0;
}

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

using namespace std;

int v[500000];
int temp[500000];

vector <int> r;

int main () {
        int n, k, q;

        scanf("%d %d %d", &n, &k, &q);

        for(int i = 0; i < n; i++) {
                scanf("%d", &v[i]);
        }
        int resp = 2000000007;
        
        for (int i = 0; i < n; i++) {
                int x = v[i];
                int first = 0;
                int last = -1;
                int endi = 0;
                
                while (last < n - 1) {
                //printf("%d %d %d\n", first, last, i);
                        if (v[last + 1] < x) {
                                if (last - first + 1 >= k) {
                                        sort(temp, temp + endi);
                                        for(int j = 0; j < endi - k + 1; j++) {
                                                r.push_back(temp[j]);
                                        }
                                }
                                last++;
                                first = last + 1;
                                endi = 0;
                        } else {
                                temp[endi++] = v[last+1];
                                last++;
                        }
                }
                //printf("%d %d %d\n", first, last, i);
                //printf("%d\n\n", endi);
                if (last - first + 1 >= k) {
                        sort(temp, temp + endi);
                        for(int j = 0; j < endi - k + 1; j++) {
                                r.push_back(temp[j]);
                        }
                }
                sort(r.begin(), r.end());

                /*printf("%d\n", i);
                for (int x : r) {
                        printf("%d ", x);
                }
                printf("\n");*/

                if (r.size() >= q) {
                        //printf("%d %d %d\n", r[q-1], r[0], q);
                        resp = min(resp, r[q - 1] - r[0]);
                }
                r.clear();

        }
 
        printf("%d\n", resp);

        return 0;
}

Measured memory_bytes: 384
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String a = sc.next();
		if(a.equals("ABC") ) {
			System.out.println("ARC");
		}
		else {
			System.out.println("ABC");
			}

    }
}


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

int main(void){
    long long n, w;
    cin >> n >> w;
    vector<long long> va(n+10), we(n+10);
    vector<long long> w1;
    vector<long long> w1wa(n+10);
    vector<long long> w2;
    vector<long long> w2wa(n+10);
    vector<long long> w3;
    vector<long long> w3wa(n+10);
    vector<long long> w4;
    vector<long long> w4wa(n+10);
    cin >> we[0] >> va[0];
    w1.push_back(va[0]);
    w2.push_back(0);
    w3.push_back(0);
    w4.push_back(0);
    for(long long i=1;i<n;++i){
        cin >> we[i] >> va[i];
        switch(we[i]-we[0]){
            case 0: w1.push_back(va[i]); break;
            case 1: w2.push_back(va[i]); break;
            case 2: w3.push_back(va[i]); break;
            case 3: w4.push_back(va[i]); break;
        }
    }
    sort(w1.begin(), w1.end(), greater<long long>());
    w1wa[0] = 0;
    for(long long i=1;i<=w1.size();++i){
        w1wa[i] = w1wa[i-1] + w1[i-1];
    }
    sort(w2.begin(), w2.end(), greater<long long>());
    w2wa[0] = 0;
    for(long long i=1;i<=w2.size();++i){
        w2wa[i] = w2wa[i-1] + w2[i-1];
    }
    sort(w3.begin(), w3.end(), greater<long long>());
    w3wa[0] = 0;
    for(long long i=1;i<=w3.size();++i){
        w3wa[i] = w3wa[i-1] + w3[i-1];
    }
    sort(w4.begin(), w4.end(), greater<long long>());
    w4wa[0] = 0;
    for(long long i=1;i<=w4.size();++i){
        w4wa[i] = w4wa[i-1] + w4[i-1];
    }
    long long ans = 0;
    for(long long i=0;i<=w1.size();++i){
        for(long long j=0;j<=w2.size();++j){
            for(long long k=0;k<=w3.size();++k){
                for(long long l=0;l<=w4.size();++l){
                    long long sum = 0, wei = 0;
                    sum += w1wa[i];
                    sum += w2wa[j];
                    sum += w3wa[k];
                    sum += w4wa[l];
                    wei = (i)*we[0]+(j)*(we[0]+1)+(k)*(we[0]+2)+(l)*(we[0]+3);
                    if(wei <= w){
                        if(ans < sum) ans = sum;
                    }
                }
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 384