akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
import java.util.stream.*;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
        // programming
        int x = Util.getInputInteger(sc);
        int y = Util.getInputInteger(sc);
        Util.output(String.valueOf(x+y/2));
	}
}

// =========common=========
class Util {
	public static String getInputString(Scanner sc) {
		return sc.next();
	}

	public static int getInputInteger(Scanner sc) {
		return Integer.parseInt(sc.next());
	}

	public static void output(String... params) {
		boolean isInit = true;
		String str = "";
		for (String s : params) {
			if (!isInit) {
				str += " ";
			}
			str += s;
			isInit = false;
		}
		System.out.println(str);
	}

    public static int[] toIntegerList(String[] ss) {
        return Stream.of(ss).mapToInt(Integer::parseInt).toArray();
    }

    public static String[] toList(String s) {
        String[] ret = s.split("");
        return ret;
    }

    public static int sum(int[] vals) {
        int sum = 0;
        for (int val : vals) {
            sum += val;
        }
        return sum;
    }

    public static int[] sort(int[] vals, boolean isAsc) {
        Arrays.sort(vals);
		if (isAsc) {
			return vals;
		}
        int[] ret = new int[vals.length];
        for (int i = 0; i < vals.length; i++) {
            ret[vals.length - i - 1] = vals[i];
        }
		return ret;
	}

    public static void gc() {
        System.gc();
    }
}

Measured memory_bytes: 25172
#include<bits/stdc++.h>
using namespace std;
using ll  = long long;
using vl  = vector<ll>;
using vi  = vector<int>;
#define _GLIBCXX_DEBUG
#define IO_STREAM cin.tie(0);ios::sync_with_stdio(false)
#define all(x) x.begin(),x.end()
#define rep(i,sta,end) for(int i=sta;i<end;++i)
#define lcm(a,b) (a)/__gcd((a),(b))*(b)
#define pb push_back
const ll INF = 1000000000000000;
const ll MOD = 1000000007;
const double PI = acos(-1);
//||
#define DBG(a,b,c,d) //cout<<a<<" "<<b<<" "<<c<<" "<<d<<" "<<endl
//DBG("","","","");

signed main(){
	IO_STREAM;
	int ans=0;
	int A;	cin>>A;
	ans+=A;
	cin>>A;
	ans+=A;
	cin>>A;
	ans+=A;
	if(ans>=22){
		cout<<"bust"<<endl;
	}
	else{
		cout<<"win"<<endl;
	}
	return 0;
}


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

int N, A, B;

bool check(int n) {
	int sum = 0;
	while (n > 0) {
		sum += n % 10;
		n = n / 10;
	}
	if (A <= sum && sum <= B) return true;
	else return false;
}


int main() {
	cin >> N >> A >> B;
	int ans = 0;
	for (int i = 1; i <= N; i++) {
		if (check(i)) ans += i;
	}

	cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int n,sum,ans,a[120],b[120];
int main(){
cin >> n;
for(int i=0;i<n;i++)
cin >> a[i];
for(int i=0;i<n;i++)
cin >> b[i];
for(int i=0;i<n;i++)
{
sum=a[0]+b[n-1];
for(int j=1;j<i;j++)
{sum=sum+a[j];}
for(int j=i-1;j<n-1;j++)
{sum=sum+b[j];}
ans=max(ans,sum);
}
cout << ans;
return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>


using namespace __gnu_pbds;
using namespace std;

#define pb                     push_back
#define ll                     long long
#define forn(i,n)              for(int i=0; i<(int)n; i++)
#define forn1(i,n)              for(int i=1; i<=(int)n; i++)

#define sfd(a)                 scanf("%d", &a)
#define sffd(a,b)              scanf("%d%d", &a, &b)
#define sffl(a,b)              scanf("%lld%lld", &a,&b)
#define sfl(a)                 scanf("%lld", &a)

#define pii                    pair<int , int>
#define pll                    pair<ll , ll>
#define ff                     first
#define ss                     second
#define mem(a, val)            memset(a, val, sizeof(a))
#define all(x)                 (x).begin(), (x).end()

//#define mx                     200005
#define INF_mx                 1e18
#define gcd(a,b)               __gcd(a, b)
#define lcm(a,b)               (a*b)/__gcd(a,b)
#define PRINT                  cout<<"hi"<<endl
#define PI acos(-1)
#define fast_in_out          ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define Q    int q; cin>>q; while(q--)
/*
const ll sz=1000001;
const ll N=1e12;
vector<ll>prime;
bool flag[sz+3];


void sieve(void)
{
    ll i,j,add;
    flag[0]=flag[1]=1;
    prime.push_back(2);
    for(i=4; i<sz; i+=2)
        flag[i]=1;
    for(i=3; i<sz; i+=2)
    {
        if(!flag[i])
        {
            prime.push_back(i);
            if(sz/i>=i)
            {
                add=i*2;
                for(j=i*i; j<sz; j+=add)
                    flag[j]=1;
            }
        }

    }
}

const int MOD = 1000000007 ;
long long int  bigmod ( long long B, int P, int M )
{
    if ( P == 0 )return 1;
    if ( P % 2 ) {
        return ( ( B % M ) * ( bigmod ( B, P-1, M))) % M;
    }
    else {
        long long mod = bigmod (B,P/2,M);
        return ((mod%M)*(mod%M))%M;
    }
}

*/

int main()
{
     int n;
     cin>>n;
     int prev=0, x;
     ll ans=0;
     for(int i=0; i<n; i++){
        cin>>x;
        if(i){
            if(x<prev){
                ans+=(prev-x);
            }
        }
        prev=max(prev, x);
     }
     cout<<ans<<endl;
    return 0;
}
/*


*/


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

using namespace std;

int main(int argc,char* argv[]){
  int A,B,C,max;
  cin >> A >> B >> C;
  max = 10*A+B+C;
  if(max < A+10*B+C) max = A+10*B+C;
  if(max < A+B+10*C) max = A+B+10*C;
  cout << max << endl;
  return 0;
}


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

using namespace std;

int q;
long long mul;

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

      while(q --){
            long long ans = 0, a, b;
            cin >> a >> b;
            mul = a * b;
            mul --;
            if(mul <= 0){
                  cout << 0 << endl;
                  continue;
            }

            long long lo = 0, hi = 1e9;

            while(hi - lo > 1){
                  long long md = (lo + hi) >> 1;
                  if(md * md <= mul)
                        lo = md;
                  else
                        hi = md;
            }

            if(hi * hi <= mul) lo = hi;

            long long sq = lo;

            ans = 2 * sq;

            if(a <= sq)
                  ans --;
            if(b <= sq)
                  ans --;
            if(sq == (mul / sq))
                  ans --;

            cout << ans << endl;
      }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int a,b,c,d;
    int e=0;
    cin>>a>>b>>c>>d;
    for(int i=0;i<100;i++){
        c-=b;
        a-=d;
        if(c<=0){
            break;
        }else if(a<=0){
            e=1;
            break;
        }
    }
    if(e==1){
        cout<<"No"<<endl;
    }else{
        cout<<"Yes"<<endl;
    }
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
int main(){
  int p[14];
  p[1] = p[3] = p[5] = p[7] = p[8] = p[10] = p[12] = 1;
  p[4] = p[6] = p[9] = p[11] = 2;
  p[2] = 3;
  int a, b;
  scanf("%d %d", &a, &b);
  printf("%s\n", (p[a] == p[b]) ? "Yes" : "No");
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pi;
const int MAXN = 1000050;
int N, A[MAXN], c[MAXN], cn[MAXN];
deque<int> unassigned;
set<int> col;
int main() {
    scanf("%d", &N);
    for (int i = 0; i < N; ++i) scanf("%d", &A[i]);
    int k1 = *min_element(A, A+N), k2 = *max_element(A, A+N);
    
    
    if (k2 - k1 > 1) return puts("No"), 0;
    if (k2 > N-1) return puts("No"), 0;
    if (k1 == k2) {
        if (k1 == N-1) puts("Yes");
        else if (k2 * 2 <= N) puts("Yes");
        else puts("No");
        return 0;
    }
    
    
    int c1 = 0, c2 = 0;
    for (int i = 0; i < N; ++i) {
        if (A[i] == k1) ++c1;
        if (A[i] == k2) ++c2;
    }
    if (c2 <= 1) return puts("No"), 0;
    if (c1 + 1 > k2) return puts("No"), 0;
    int d = k2 - c1;
    if (d*2 > c2) return puts("No"), 0;
    puts("Yes");

}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
template <class T> void chmin(T &a, const T &b) noexcept { if (b < a) a = b; }
template <class T> void chmax(T &a, const T &b) noexcept { if (a < b) a = b; }
void debug_out() { cout << "\n"; }
template <class T, class... Args>
void debug_out(const T &x, const Args &... args) { cout << x << " "; debug_out(args...);}
#ifdef _DEBUG
  #define debug(...) debug_out(__VA_ARGS__)
#else
  #define debug(...) 
#endif

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  string s,t;
  cin >> s >> t;
  int n = s.size();
  bool ok = true;
  rep(i,n) {
    if (s[i] != t[i]) ok = false;
  }
  cout << (ok ? "Yes" : "No") << endl;
  return 0;
}

Measured memory_bytes: 3656
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        C solver = new C();
        solver.solve(1, in, out);
        out.close();
    }

    static class C {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            int x = Integer.parseInt(in.next());

            // 出力
            boolean ok = false;

            for (int i = 1; i <= 1000; i++) {
                if (i * 100 <= x && x <= i * 105) ok = true;
            }
            out.println(ok ? 1 : 0);

        }

    }
}



Measured memory_bytes: 23636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<bool> vb;
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define INT(str) stoi((str), 0)
#define INTB(str) stoi((str), 0, 2) // 2進数の文字列を int に
//cout << fixed << setprecision(15);

int main() {
  char c;
  cin >> c;
  cout << ++c << endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define rep( i, n ) for( int ( i ) = 0; ( i ) < ( n ); ( i )++ )
#define repr( i, n ) for( int ( i ) = ( n ); ( i ) >= 0; ( i )-- )
#define FOR( i, m, n ) for( int ( i ) = ( m ); ( i ) < ( n ); ( i )++ )
#define all( x ) ( x ).begin(), ( x ).end()
typedef long long lint;
using namespace std;

int main( void ){
	
	lint a, b;
	
	cin >> a >> b;
	
	if( a > 8 || b > 8 ){
		cout <<":(" << endl;
	}else{
		cout <<"Yay!" << endl;
	}
	
	return 0;
	
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
    
    ll n;
    cin>>n;
    ll a[n];
    for(int i=0;i<n;i++)
    cin>>a[i];
   ll dp[n];
   dp[0]=0;
   for(int i=1;i<n;i++)
     dp[i]=1e9;
    for(int i=0;i<n-1;i++)
    {
        for(int j=i+1;j<i+3;j++)
          dp[j]=min(dp[j],abs(a[i]-a[j])+dp[i]);
    }
    cout<<dp[n-1];
    return 0;
}


Measured memory_bytes: 1792
using Yorukatsu038.Questions;
using Yorukatsu038.Extensions;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

namespace Yorukatsu038.Questions
{
    /// <summary>
    /// ABC049 C
    /// </summary>
    public class QuestionD : AtCoderQuestionBase
    {
        public override IEnumerable<object> Solve(TextReader inputStream)
        {
            var s = inputStream.ReadLine();
            var toErases = new string[] { "eraser", "erase", "dreamer", "dream" };
            foreach (var toErase in toErases)
            {
                s = s.Replace(toErase, string.Empty);
            }
            yield return s == string.Empty ? "YES" : "NO";
        }
    }
}


namespace Yorukatsu038
{
    class Program
    {
        static void Main(string[] args)
        {
            IAtCoderQuestion question = new QuestionD();    // 問題に合わせて書き換え
            var answers = question.Solve(Console.In);
            foreach (var answer in answers)
            {
                Console.WriteLine(answer);
            }
        }
    }
}

#region Base Classes

namespace Yorukatsu038.Questions
{

    public interface IAtCoderQuestion
    {
        IEnumerable<object> Solve(string input);
        IEnumerable<object> Solve(TextReader inputStream);
    }

    public abstract class AtCoderQuestionBase : IAtCoderQuestion
    {
        public IEnumerable<object> Solve(string input)
        {
            var stream = new MemoryStream(Encoding.Unicode.GetBytes(input));
            var reader = new StreamReader(stream, Encoding.Unicode);

            return Solve(reader);
        }

        public abstract IEnumerable<object> Solve(TextReader inputStream);
    }

}

#endregion

#region Extensions

namespace Yorukatsu038.Extensions
{
    internal static class TextReaderExtensions
    {
        internal static int ReadInt(this TextReader reader) => int.Parse(ReadString(reader));
        internal static long ReadLong(this TextReader reader) => long.Parse(ReadString(reader));
        internal static double ReadDouble(this TextReader reader) => double.Parse(ReadString(reader));
        internal static string ReadString(this TextReader reader) => reader.ReadLine();

        internal static int[] ReadIntArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(int.Parse).ToArray();
        internal static long[] ReadLongArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(long.Parse).ToArray();
        internal static double[] ReadDoubleArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(double.Parse).ToArray();
        internal static string[] ReadStringArray(this TextReader reader, char separator = ' ') => reader.ReadLine().Split(separator);
    }
}

#endregion

Measured memory_bytes: 12128
#include <bits/stdc++.h>
#define x real()
#define y imag()
using namespace std;
typedef complex<double> point;

double dot(point a,point b){return a.x*b.x+a.y*b.y;}
double cross(point a,point b){return a.x*b.y-a.y*b.x;}
int ccw(point a,point b,point c){
  point d = b-a,e = c-a;
  if(cross(d,e)>0) return 1;//"COUNTER_CLOCKWISE"
  if(cross(d,e)<0) return -1;//"CLOCKWISE"
  if(dot(d,e)<0) return 2;//"ONLINE_BACK"
  if(abs(d) < abs(e)) return -2;//"ONLINE_FRONT"
  return 0;//"ON_SEGMENT"
}

point crosspoint(point a,point b,point c,point d){
  a-=d;b-=d;c-=d;
  return d+a+(b-a)*imag(a/c)/imag(a/c-b/c);
}

vector<point> ConvexCut(vector<point> &polygon,point a,point b){
  vector <point> res;
  for(int i=0;i<polygon.size();i++){
    point A=polygon[i],B=polygon[(i+1)%polygon.size()];
    if(ccw(a,b,A)!=-1)res.push_back(A);
    if(ccw(a,b,A)*ccw(a,b,B)==-1)res.push_back(crosspoint(a,b,A,B));
  }
  return res;
}

double get_area(vector <point> &polygon){
  if(polygon.size()<3)return 0;
  double res=0;
  for(int i=0;i<polygon.size();i++)
    res+=cross(polygon[i],polygon[(i+1)%polygon.size()])/2;
  return res;
}

int main(){
  while(1){
    int v,n,d;
    vector <point> pl;
    cin>>n>>d>>v;
    if(!n&&!d&&!v) break;
    for(int i=0,a,b;i<n;i++) cin>>a>>b,pl.push_back(point(a,b));
    double V=min(get_area(pl)*d,(double)v),ans=0;
    
    for(int i=0;i<n;i++){
      double L=0,M,R=2010;
      int I=1000;
      while(I--){
	M=(L+R)/2;
	point h=pl[(i+1)%n]-pl[i],b=h;
	h=(point(0,M)*h/abs(h))+pl[i];
	vector<point> a=ConvexCut(pl,h+b,h);
	if(get_area(a)*d>=V)R=M;
	else L=M+0.000000001;
      }
      ans=max(ans,L);
    }
    printf("%f\n",ans);
  }
  return 0;
}

Measured memory_bytes: 1244
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
using namespace std;
const int mod = 1000000007;
#define ll long long

int main()
{
	ll A, B, C;
	cin >> A >> B >> C;
	ll an = B;
	an += min(C, A + B + 1);
	cout << an << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <map>

using namespace std;

int main() {
    int n, m;
    cin >> n >> m;
    vector< pair<int, int> > city(m);
    vector< vector<int> > years(n+1);
    for (int i=0; i<m; i++) {
        int p, y;
        cin >> p >> y;
        city[i] = make_pair(p, y);
        years[p].push_back(y);
    }

    map<int, int> mp;
    for (int i=1; i<=n; i++) {
        if (years[i].size() == 0) continue;

        sort(years[i].begin(), years[i].end());
        int count = 1;
        for (auto j : years[i]) {
            mp[j] = count;
            count++;
        }
    }

    for (auto i : city) {
        printf("%06d", i.first);
        printf("%06d\n", mp[i.second]);
    }
}


Measured memory_bytes: 12416
import java.util.*;
import java.util.ArrayList;
import java.util.List;
import java.util.Arrays;

public class Main {
    public static void main(String[] args) {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        long ans = 0;
        int h[] = new int[n]; 
        for(int i = 0; i < n; i++){
            h[i] = sc.nextInt();
            //System.out.println("a[i]"+a[i]);
        }
        Arrays.sort(h);
        for(int i = 0; i< n-k; i++){
            ans +=h[i];
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 63952
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int mod = 1e9 + 7;
const int inf = (1 << 30) - 1;
const ll infll = (1LL << 61) - 1;

template <typename T>
struct edge
{
    int src, to;
    T cost;
    edge(int to, T cost) : src(-1), to(to), cost(cost) {}
    edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}
    edge &operator=(const int &x)
    {
        to = x;
        return *this;
    }
    operator int() const { return to; }
};

template <typename T>
using Edges = vector<edge<T>>;

template <typename T>
using WeightedGraph = vector<Edges<T>>;

template <typename T>
using UnweightedGraph = vector<vector<T>>;

template <typename T>
using Matrix = vector<vector<T>>;

#include <vector>
#include <limits>

template <typename T>
vector<T> BellmanFrod(Edges<T> &edges, int N, int source)
{
    const auto INF = numeric_limits<T>::max();
    vector<T> dist(N, INF); //distance from source
    dist[source] = 0;
    for (int i = 0; i < N - 1; i++)
    {
        for (auto &e : edges)
        {
            if (dist[e.src] == INF)
                continue;
            dist[e.to] = min(dist[e.to], dist[e.src] + e.cost);
        }
    }

    // check for negative-weight cycles
    for (auto &e : edges)
    {
        if (dist[e.src] == INF)
            continue;
        if (dist[e.src] + e.cost < dist[e.to])
            return vector<T>();
    }
    dist.push_back(INF);
    return dist;
}

int main()
{
    int v, e, r;
    cin >> v >> e >> r;
    const auto INF = numeric_limits<int>::max();
    Edges<int> G;
    for (int i = 0; i < e; i++)
    {
        int s, t, d;
        cin >> s >> t >> d;
        G.emplace_back(s, t, d);
    }
    auto dist = BellmanFrod(G, v, r);
    if (dist.size() == 0)
    {
        cout << "NEGATIVE CYCLE" << endl;
        return 0;
    }
    for (int i = 0; i < v; i++)
    {
        if (dist[i] == dist[v])
        {
            cout << "INF" << endl;
        }
        else
        {
            cout << dist[i] << endl;
        }
    }
}


Measured memory_bytes: 3168
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
using namespace std;
int main(){
	while(1){
		int num,age,table[7]={0};
		cin>>num;
		if(num==0) break;

		for(int i=0;i<num;i++){
			cin>>age;
			if(0<=age && age<=9) table[0]++;
			else if(10<=age && age<=19) table[1]++;
			else if(20<=age && age<=29) table[2]++;
			else if(30<=age && age<=39) table[3]++;
			else if(40<=age && age<=49) table[4]++;
			else if(50<=age && age<=59) table[5]++;
			else if(60<=age) table[6]++;
		}

		for(int i=0;i<7;i++){
			cout<<table[i]<<endl;
		}

	}
	return 0;
}

Measured memory_bytes: 1156
#include <stdio.h>
#include <string.h>
#include <queue>
#include <vector>
#include <functional>
#include <utility>

using namespace std;

typedef pair<int,int> ip;

int k, d[100001];

int main() {
	memset(d,-1,sizeof(d));
	scanf("%d",&k);
	priority_queue<ip,vector<ip>,greater<ip> > q;
	for(int i=1;i<=9;i++) {
		if(d[i%k]<0) {
			d[i%k]=i;
			q.push(ip(i,i%k));
		}
	}
	while(!q.empty()) {
		int dis=q.top().first, u=q.top().second;
		q.pop();
		if(d[u]!=dis) continue;
		for(int i=0;i<=10;i++) {
			int v=(u*10+i)%k;
			if(d[v]<0 || d[v]>dis+i) {
				d[v]=dis+i;
				q.push(ip(d[v],v));
			}
		}
	}
	printf("%d\n",d[0]);
	return 0;
}

Measured memory_bytes: 2804
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,x) for(int i=0;i<x;i++)
#define put(ans)    cout << ans << endl;
#define reverse(s) reverse(s.begin(),s.end())

//最大公約数
ll gcd(ll a, ll b) {
    return b ? gcd(b, a%b) : a;
}
//最小公倍数
ll lcm(ll a, ll b) {
    return a / gcd(a, b) * b;
}
bool isPrime(int x){
    ll i;
    if(x < 2)return 0;
    else if(x == 2) return 1;
    if(x%2 == 0) return 0;
    for(i = 3; i*i <= x; i += 2) if(x%i == 0) return 0;
    return 1;
}

int main(){
    int n,m;
    cin >> n >> m;
    vector<vector<int>> vec(m);
    rep(i,m){
        int k;  cin >> k;
        vec[i].resize(k);
        rep(j,k){
            cin >> vec[i][j];
            vec[i][j]--;
        }
    }
    vector<int> p(m);
    rep(i,m){
        cin >> p[i];
    }
    int ans(0);
    rep(i,1<<n){
        bool c(true);
        rep(j,m){
            int x(0);
            for(int w: vec[j]){
                if((i>>w)&1){
                    x++;
                }
            }
            x %= 2;
            if(x!=p[j]) c = false;
        }
        if(c){
            ans++;
        }
    }
    put(ans);

    return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <array>
#include <queue>
#include <deque>
#include <set>
#include <unordered_set>
#include <list>
#include <map>
#include <stack>
#include <utility>
#include <bitset>
#include <complex>
#include <algorithm>
#include <numeric>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <climits>
#include <random>
#include <functional>
#include <sstream>
#include <iomanip>

using namespace std;

#define rep(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, m, n) for(int i=(m); i<(n); ++i)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define REVE(x) reverse((x).begin(),(x).end())
#define mp make_pair
#define pb push_back
#define Cout(x) cout << (x) << endl
#define Cout2(x, y) cout << (x) << " " << (y) << endl
#define dump(x) cout << #x << " = " << (x) << endl;
#define forauto(i, a) for(auto i : a)cout << i << " "; puts("");

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
typedef pair<double, double> PDD;
typedef complex<double> CD;

int main() {
	const LL inf = pow(10, 18);
	LL n, m, q; cin >> n >> m >> q;

	VL s(n + 2), t(m + 2);
	s[0] = -inf; t[0] = -inf;
	rep(i, n)cin >> s[i + 1];
	rep(i, m)cin >> t[i + 1];
	s[n + 1] = inf; t[m + 1] = inf;

	SORT(s); SORT(t);

	rep(i, q) {
		LL x; cin >> x;

		VL a(4);
		auto it = lower_bound(all(s), x);
		a[1] = *it; it--; a[0] = *it;
		auto it2 = lower_bound(all(t), x);
		a[3] = *it2; it2--; a[2] = *it2;

		VL ans(8);
		rep(i, 8) {
			int j = i < 4 ? 2 : 0; j += i % 2 == 0 ? 0 : 1;
			ans[i] = abs(x - a[i / 2]) + abs(a[i / 2] - a[j]);
		}
		Cout(*min_element(all(ans)));
	}
}

Measured memory_bytes: 2944
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
	ios_base::sync_with_stdio(false);
	string s;
	cin >> s;
	const int n = s.size();
	vector<int> h(26);
	for(const char c : s){ ++h[c - 'a']; }
	const int x = s[0] - 'a', y = s[n - 1] - 'a';
	bool answer = false;
	if(x == y){
		const int t = *min_element(h.begin(), h.end());
		if(h[x] == t){
			answer = ((n - t - (t - 1)) % 2 == 0);
		}else{
			answer = ((n - t - (t + 1)) % 2 == 0);
		}
	}else{
		const int t = min(h[x], h[y]);
		answer = ((n - t - t) % 2 == 0);
	}
	cout << (answer ? "Second" : "First") << endl;
	return 0;
}



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

#define mod 1000000007
#define INF (ll)9999999999999999

#define add emplace
#define eb emplace_back
#define all(x) begin(x), end(x)
#define len(x) ((int)(x).size())
#define exist(a, x) (a.find(x) != end(a))
#define log(x) cout << (x) << endl
#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define rrep(i,a,b) for (int i = (int)a; i >= (int)b; --i)
#define loop(i,a,b) for(int i = (int)(a); i < (int)(b); ++i)

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;



int main() {
    int n, x;
    cin >> n;
    vi a;
    map<int,int> cnt;

    rep (i, n) {
        cin >> x;
        if (!cnt[x]) a.eb(x);
        cnt[x]++;
    }

    int c = 0;
    rep (i, a.size()) {
        x = a[i];
        if (cnt[x] < x)
            c += cnt[x];
        else if (cnt[x] > x)
            c += cnt[x]-x;
    }

    log(c);

    return 0;
}





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

int main(){
  ll n;
  cin >> n;
  int ans = 10;
  for(ll a=1; a*a<=n; a++){
    if(n%a==0){
      ll b = n/a;
      int cnt = 0;
      while(b>0){
        cnt++;
        b/=10;
      }
      ans = min(ans, cnt);
    }
  }
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES

#include <bits/stdc++.h>

#define len(x) (int)((x).size())
#define endl '\n'
#define x first
#define y second
#define int long long
#define all(a) (a).begin(), (a).end()
#ifdef LOCAL
	#define dbg(x) cout << #x << " = " << x << endl;
#else 
	#define dbg(x)
#endif 

using namespace std;

void solve(); signed main() {
#ifdef LOCAL
    freopen("file1.txt", "r", stdin);                                       
    freopen("file2.txt", "w", stderr);
#endif
    srand(time(0));
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cout.setf(ios::fixed); cout.precision(6);
    solve();
}

const int INF = 1e9, MAXN = 1e5 + 10;                 	

void solve() {                         
	string s, t;
	cin >> s >> t;

	int cnt = 0;
	for (int i = 0; i < len(s); ++i) {
	 	if (s[i] == t[i]) {
	 	 	cnt++;
	 	}
	}

	cout << cnt << endl;
}	

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

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin >> n;
	int ans[100010];
	memset(ans, 0, sizeof ans);
	int mx = 0;
	for(int i = 0; i < n; ++i){
		int x;
		cin >> x;
		mx = max(mx,++ans[++x]);
		mx = max(mx,++ans[++x]);
		mx = max(mx,++ans[++x]);
	}
	cout << mx << endl;
}


Measured memory_bytes: 640
#include <string>
#include <iostream>

using namespace std;

int main() {
    string s;
    cin >> s;

    if (s.size() >= 4) {
        string head;
        head.assign(s, 0, 4);
        if (head == "YAKI") { cout << "Yes" << endl; }
        else { cout << "No" << endl; }
    }
    else { cout << "No" << endl; }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int N;
  cin>>N;
  switch(N){
  case 22: cout<<"Christmas Eve Eve Eve"<<endl; break;
  case 23: cout<<"Christmas Eve Eve"<<endl; break;
  case 24: cout<<"Christmas Eve"<<endl; break;
  case 25: cout<<"Christmas"<<endl; break;
  }
  return (!(0xF0>0x0E));
}


Measured memory_bytes: 256
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()
def rand_N(ran1, ran2):
    return random.randint(ran1, ran2)
def rand_List(ran1, ran2, rantime):
    return [random.randint(ran1, ran2) for i in range(rantime)]
def rand_ints_nodup(ran1, ran2, rantime):
  ns = []
  while len(ns) < rantime:
    n = random.randint(ran1, ran2)
    if not n in ns:
      ns.append(n)
  return sorted(ns)

def rand_query(ran1, ran2, rantime):
  r_query = []
  while len(r_query) < rantime:
    n_q = rand_ints_nodup(ran1, ran2, 2)
    if not n_q in r_query:
      r_query.append(n_q)
  return sorted(r_query)

from collections import defaultdict, deque, Counter
from sys import exit
from decimal import *
import heapq
import math
from fractions import gcd
import random
import string
import copy
from itertools import combinations, permutations, product
from operator import mul, itemgetter
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7

#############
# Main Code #
#############

N = getN()
A = getArray(N)

cnt = 0
for i in range(N - 1):
    # 一つから
    p = A[i] // 2
    cnt += p
    A[i] -= p * 2

    # 二つから
    u = min(A[i], A[i + 1])
    cnt += u
    A[i] -= u
    A[i + 1] -= u

p = A[-1] // 2
cnt += p
A[-1] -= p * 2
print(cnt)

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

int main() {
  int a, b, c, x, ans;
  cin >> a >> b >> c >> x;
  ans = 0;
  for(int i = 0; i <= a; i++)
    for(int j = 0; j <= b; j++)
      for(int k = 0; k <= c; k++)
        if(x == 500*i + 100*j + 50*k)
          ans++;
  cout << ans << endl;
}

Measured memory_bytes: 3628
//بسم الله الرحمن الرحيم
//اللہ کے نام سے شروع جو بڑا مہربان اور نہایت رحم والا ہے
//Allah in the name of The Most Affectionate, the Merciful
//अल्लाह के नाम से जो दयालु और कृपाशील है
#include<iostream>
#include<algorithm>
#include<climits>
#include<cmath>
#include<vector>
#include<map>
#include<stack>
#include<queue> 
#include<cstring>
#include<ctime>

using namespace std;
#define fastio ios::sync_with_stdio(0); cin.tie(0)
#define ll long long
#define ull unsigned ll
#define pb push_back

#define endl '\n'
#define mod 1000000007

#define FOR(i,k,n) for(int i=k; i<n; i++)
#define ROF(i,k,n) for(int i=k; i>=n; i--)
#define MEMSET(t) memset(t,0,sizeof(t));
#define time clock_t tStart 
#define Start clock()
#define Time printf("Time taken: %.3fs\n", (double)(clock() - tStart)/CLOCKS_PER_SEC)

int dp[1000001][3];

int maxH(int ar[][3], int n,int p)
{
    if(n==0) return 0;
  
    if(dp[n][p]!=-1 ) 
        return dp[n][p]; 
    int val; 
    if(p==1){
         dp[n][p]= max( ar[n-1][1]+maxH(ar,n-1,2),ar[n-1][2]+maxH(ar,n-1,3));
    }
    if(p==2){
         dp[n][p]= max( ar[n-1][0]+maxH(ar,n-1,1),ar[n-1][2]+maxH(ar,n-1,3)); 
    }
    if(p==3){
         dp[n][p]= max( ar[n-1][0]+maxH(ar,n-1,1),ar[n-1][1]+maxH(ar,n-1,2));
    }
    

    return dp[n][p];

}

int main()
{
    fastio;
    int t=1; //cin>>t;
    while(t--)
    {
        int n; cin>>n;
        int ar[n][3];
        for(int i=0;i<n; i++)
        {
            cin>>ar[i][0]>>ar[i][1]>>ar[i][2]; 
        }
        memset(dp,-1,sizeof(dp)); 
        cout<<max( ar[n-1][0]+maxH(ar,n-1,1), max( ar[n-1][1]+maxH(ar,n-1,2), ar[n-1][2]+maxH(ar,n-1,3))) <<endl;


    }
    return 0;
}


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

#define what_is(x)    cerr<<#x<<" is "<<x<<"\n";
#define rep(i,a,n)    for(int i=a; i<=n; ++i)
#define rep1(i,a,n)   for(int i=a; i>=n; --i)
#define pb            push_back
#define mp            make_pair
#define int           long long
#define fr            first
#define sc            second
#define vc            vector
#define all(x)        (x).begin(),(x).end()
#define rall(x)       (x).rbegin(),(x).rend()
#define M             1000000007
#define MM            998244353
#define PI            3.14159265358979

typedef vector<int> vi;
typedef pair<int,int> pii;
typedef map<int,int> mii;

int n,ans; string str;
int k,s;
int solve(){
    cin>>k>>s;
    rep(i,0,k){
        rep(j,0,k){
            int t=s-i-j;
            if(t>=0&&t<=k) ans++;
        }
    }
    cout<<ans;
    return 0;
}

signed main() {
    ios::sync_with_stdio(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int t=1;
    //cin>>t;
    while(t--) solve();
    return 0;
}

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

#define vt          vector
#define sz(x)       int((x).size())
#define all(x)      (x).begin(), (x).end()
#define rall(x)     (x).rbegin(), (x).rend()
#define fi          first
#define se          second

using ll = long long;
using pii = pair<int, int>;

const int mod = 1e9 + 7, maxn = 2e3 + 1;
ll dp[maxn];

void solve() {
    int s;
    cin >> s;

    dp[0] = 1;
    for (int i = 3; i <= s; i++) {
        for (int j = 0; j <= i - 3; j++) {
            dp[i] = (dp[i] + dp[j]) % mod;
        }
    }

    cout << dp[s];
}

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

    int tcs = 1;
    for (int tc = 1; tc <= tcs; tc++) {
        // cout << "Case " << tc << ": ";
        solve();
    }
}


Measured memory_bytes: 3664
n,k=gets.split(' ').map(&:to_i)
#h=gets.split(' ').map(&:to_i)
#tajigen = Array.new(4) { Array.new(2,0) }
#maze = h.times.map { gets.chomp }
ans = Array.new(n+1,0)
ans[0] = 1
k.times do
  s = gets.to_i
  #puts "s=#{s}"
  a=gets.split(' ').map(&:to_i)
  for i in 0..s-1
    ans[a[i]] = 1
  end

end
puts ans.count(0)


Measured memory_bytes: 14392
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int w = sc.nextInt();
		int n = sc.nextInt();
		int[] x = new int[w];
		String empty = sc.nextLine();

		for (int i = 0; i < x.length; i++) {
			x[i] = i + 1;
		}

		for (int i = 0; i < n; i++) {
			String str = sc.nextLine();
			String ints[] = str.split(",", 0);
			int a = Integer.parseInt(ints[0]) - 1;
			int b = Integer.parseInt(ints[1]) - 1;
			Swap(a, b, x);
		}
		for (int i = 0; i < x.length; i++) {
			System.out.printf("%d\n", x[i]);
		}
	}

	private static void Swap(int a, int b, int[] x) {
		// TODO Auto-generated method stub
		int tmp = 0;
		tmp = x[a];
		x[a] = x[b];
		x[b] = tmp;
	}

}

Measured memory_bytes: 26608
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;

int H, W;
char S[53][53];
int T[53][53] = {{0}};

int main() {
    cin >> H >> W;
    for (int i = 1; i < H + 1; i++) {
        for (int j = 1; j < W + 1; j++) cin >> S[i][j];
    }
    
    int x[8] = {-1,-1,-1,0,0,1,1,1}, y[8]={1,0,-1,1,-1,1,0,-1};
    for (int i = 1; i < H + 1; i++) {
        for (int j = 1; j < W + 1; j++) {
            if (S[i][j] == '#') {
                for (int k = 0; k < 8; k++) {
                    T[i+x[k]][j+y[k]]++;
                }
            }
        }
    }
    
    for (int i = 1; i < H + 1; i++) {
        for (int j = 1; j < W + 1; j++) {
            if (S[i][j] == '#') cout << '#';
            else cout << T[i][j];
        }
        cout << endl;
    }
}


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



int main(){

    int n,k,s;
    int tmp;

    cin>>k>>s;
    int ct=0;

    for(int i=0;i<=k;i++)
        for(int j=0;j<=k;j++){
            tmp = s - (i+j);
            if( tmp <=k && tmp>=0) ct++;
        }




    cout<<ct;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    private static final long MOD = 1_000_000_007;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        sc.nextLine();
        char[] str = sc.nextLine().toCharArray();
        int[] counts = new int[26];
        for (int i = 0; i < str.length; i++) {
            counts[str[i] - 'a']++;
        }
        long ans = counts[0]+1;
        for (int i = 1; i < counts.length; i++) {
            ans = (ans * (counts[i] + 1)) % MOD;
        }
        System.out.println(ans - 1);
    }
}


Measured memory_bytes: 25788
#include <iostream>
#include <numeric>
#include <stdio.h>
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
using ll = long long;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
int Max(int(a), int(b), int(c)) {
	return max(max(a, b), c);
}
int Min(int(a), int(b), int(c)) {
	return min(min(a, b), c);
}





int main() {
	string s;
	cin >> s;
	rep(i, 4) {
		cout << s.at(i) ;

	}
	cout << " ";
	rep(i, 8) {
		cout << s.at(i+4);

	}
	cout << endl;
}

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

using namespace std;

#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define pii pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< pii >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; cin >> x;
#define int2(x, y) Int(x); Int(y);
#define int3(x, y, z) Int(x); int2(y, z);
#define in(x, a, b) ((a) <= (x) && (x) < (b))
#define fir first
#define sec second
#define ffir first.first
#define fsec first.second
#define sfir second.first
#define ssec second.second
#define Decimal fixed << setprecision(10)

//int dxy[5] = {0, 1, 0, -1, 0};
// 01Trie BIT CHT DFT FFT avl cmd cusum dijkstra dinic geo2 gin graph kruskal lca lcm matrix ncm next_combination ppuf segtree st tmp topcoder uf vi 

struct RangeUpdateQuery {
	int n;
	vector<int> d;
	vector<int> timestamp;
	int time;
	RangeUpdateQuery(int m) {
		for (n = 1; n < m; n *= 2);
		d.assign(n * 2, -1);
		time = 0;
		timestamp.assign(n * 2, 0);
	}
	//[l, r)
	void update(int l, int r, int x) {
		time++;
		for (; l && l + (l&-l) <= r; l += l&-l) {
			d[(n + l) / (l&-l)] = x;
			timestamp[(n + l) / (l&-l)] = time;
		}
		for (; l < r; r -= r&-r) {
			d[(n + r) / (r&-r) - 1] = x;
			timestamp[(n + r) / (r&-r) - 1] = time;
		}
	}
	int get(int i) {
		int ret = d[n + i];
		int max_time = timestamp[n + i];
		for (int j = (n + i) / 2; j > 0; j >>= 1) {
			if (max_time > timestamp[j])continue;
			max_time = timestamp[j];
			ret = d[j];
		}
		return ret;
	}
};

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

    int2(n, m);
    vector<pair<int, pii>> data(n);
    rep(i, n) {
        int3(a, b, c);
        data[i].fir = c;
        data[i].sfir = a - c; data[i].ssec = b - c;
    }
    sort(all(data));
    reverse(all(data));

    vector<int> state(m);
    for (int i = 0; i < m; i++) {
        cin >> state[i];
    }

    RangeUpdateQuery funami(m);
    /*
    rep(i, m) {
        funami.update(i, -1);
    }
    */

    rep(i, data.size()) {
        int l = lower_bound(all(state), data[i].sfir) - state.begin(), 
            r = lower_bound(all(state), data[i].ssec) - state.begin();
        funami.update(l, r, data[i].fir);
        //cout << data[i].fir << " " << data[i].sfir << " "
        //    << data[i].ssec << " " << l << " " << r << endl;
    }

    rep(i, state.size()) {
        std::cout << funami.get(i) << std::endl;
    }

    return 0;
}


Measured memory_bytes: 17408
str = gets.chomp.split("")
word = str.count.to_i
even = []
odd = []

for i in 0..word-1
  if i%2 == 0 || i == 0
    odd.push(str[i])
  else
    even.push(str[i])
  end
end

unless even.include?("R")
  unless odd.include?("L") 
  	puts "Yes"
  else
    puts "No"
  end
else
  puts "No"
end

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

using namespace std;
using int64 = long long;

constexpr int DEBUG = 0;

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

  int n;
  int64 a, b;
  cin >> n >> a >> b;
  vector<int64> xs(n);
  for (int i = 0; i < n; i++) {
    cin >> xs[i];
  }

  int64 r = 0;
  for (int i = 0; i < n - 1; i++) {
    r += min(a * (xs[i + 1] - xs[i]), b);
  }
  cout << r << endl;
}

Measured memory_bytes: 1024
import java.util.*;
import java.util.Map.Entry;
 
class Main {
	 static int mod =  (int) (Math.pow(10,9)+7);
//	 static int mod = 998244353;
   public static void main(String[] args) {
	   
       Scanner sc = new Scanner(System.in);
       int N = sc.nextInt();
//       int B = sc.nextInt();
//       String S = sc.next();
//       String T = sc.next();
//       char[] s = S.toCharArray();
//       char[] t = T.toCharArray();
       int f = 0;
       int l = 0;
       int fl = 0;
       int cnt=0;
       for (int i=0 ; i<N; i++) {
           String S = sc.next();
           char[] s = S.toCharArray();
           if(s[0]=='B'&& s[s.length-1]=='A') {
        	   fl++;
           } else if(s[0]=='B') {
        	   f++;
           } else if(s[s.length-1]=='A') {
        	   l++;
           }
           while(S.indexOf("AB")!=-1) {
        	   S=S.substring(S.indexOf("AB")+2);
        	   cnt++;
           }
       }
       
       if(Math.max(f,l)==0) {
    	   	cnt=cnt+Math.max(0,fl-1);
       } else {
    		cnt=cnt+fl+Math.min(f,l);
       }
       System.out.println(cnt);
   }
      

}

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

int main() {
  int N;
  cin >> N;
  int a;
  a = N/500;
  int b;
  b = N-500*a;
  int c;
  c = b/5;
  if (N%500 == 0) {
    cout << 2*N <<endl;
  }
  else {
    cout << 1000*a + 5*c <<endl;
  }
  
}


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

lli getmax(vector<vector<int>> &h,int i,int prev,int n,vector<vector<int>> &cache)
{
    if(i>=n)
    {
        return 0;
    }

    if(i!=0 && cache[i][prev]!=-1)
    {
        return cache[i][prev];
    }


    lli maxi = 0;
    for(int j=0;j<3;j++)
    {
        if(j!=prev)
        {
            maxi = max(maxi,h[i][j]+getmax(h,i+1,j,n,cache));
        }
    }

    if(i!=0)
    {
        cache[i][prev] = maxi;
        return cache[i][prev];
    }

    return maxi;

}

void solve()
{
    int n;
    cin>>n;
    vector<vector<int>> h(n,vector<int> (3,0));
    vector<vector<int>> cache(n+1,vector<int> (3,-1));
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<3;j++)
        {
            cin>>h[i][j];
        }
    }

    lli res = getmax(h,0,-1,n,cache);
    cout<<res<<endl;
}

int main()
{
 solve();
}


Measured memory_bytes: 18944
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# FileName: 	single_source_shortest_path
# CreatedDate:  2020-06-08 21:54:58 +0900
# LastModified: 2020-06-08 22:28:47 +0900
#


import os
import sys
from collections import deque
#import numpy as np
#import pandas as pd


def main():
    n = int(input())
    graph = [[] for _ in range(n)]
    for _ in range(n):
        line = list(map(int,input().split()))
        u,k = line[0],line[1]
        path = line[2:]
        for i in range(0,2*k,2):
            graph[u].append([path[i+1],path[i]])
    
#    print(graph)
    s=0
    distance=[-1]*n
    Q = deque([s])
    distance[0]=0
    

    while Q:
        u = Q.popleft()
        for dis,v in graph[u]:
            if distance[v]==-1:
                distance[v]=distance[u]+dis
                Q.append(v)

            if distance[v]>distance[u]+dis:
                distance[v]=distance[u]+dis
                Q.append(v)
            


    for i,dis in enumerate(distance):
        print(i,dis)


if __name__ == "__main__":
    main()



Measured memory_bytes: 6500
n, m = map(int, input().split())
ab = [list(map(int, input().split())) for i in range(m)]
l = [0] * n
for i in range(m):
    l[ab[i][0]-1] += 1
    l[ab[i][1]-1] += 1
for i in range(n):
    print(l[i])

Measured memory_bytes: 9128
#include<bits/stdc++.h>
using namespace std;
const int N=310;
int n,m,a[N][N];
bool test(int x){
	static int cnt[N],p[N];
	bool erase[N];
	for (int i=1;i<=m;i++) erase[i]=0,cnt[i]=0;
	for (int i=1;i<=n;i++) cnt[a[i][p[i]=1]]++;
	int num=0;
	while (1){
		int k=0;
		for (int j=1;j<=m;j++) if (cnt[j]>x) k=j;
		if (!k) return 1;
		num++;
		if (num==m) return 0;
		cnt[k]=0;erase[k]=1;
		for (int j=1;j<=n;j++){
			cnt[a[j][p[j]]]--;
			while (erase[a[j][p[j]]]) p[j]++;
			cnt[a[j][p[j]]]++;
		}
	}
}
int main()
{
	scanf("%d%d",&n,&m);
	for (int i=1;i<=n;i++)
	for (int j=1;j<=m;j++)
		scanf("%d",&a[i][j]);
	int l=1,r=n;
	while (l<r){
		int mid=(l+r)>>1;
		if (test(mid)) r=mid;else l=mid+1;
	}
	printf("%d\n",l);
	return 0;
}

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

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

template<typename H> bool chmin(H& v1, const H v2) { if (v1 > v2) { v1 = v2; return true; } return false; }
template<typename H> bool chmax(H& v1, const H v2) { if (v1 < v2) { v1 = v2; return true; } return false; }
template<typename H> void read(H& head) { cin >> head; }
template<typename H, typename ...T> void read(H& head, T& ...tail) { cin >> head; read(tail...); }
template<typename H> void write(H head) { cout << head << '\n'; }
template<typename H, typename ...T> void write(H head, T ...tail) { cout << head << " "; write(tail...); }
template<typename ...T> void die(T ...tok) { write(tok...); exit(0); }

int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin.exceptions(cin.failbit);

	ll k, a, b;
	read(k, a, b);

	ll biscuits = 1, coins = 0;

	if (b - a > 2) {
		if (k >= a - 1) {
			biscuits += a - 1;
			k -= a - 1;

			// each 2 actions give (b - a) biscuits
			biscuits += (k / 2) * (b - a);
			biscuits += k % 2;
		} else {
			biscuits += k;
		}
	} else {
		biscuits += k;
	}

	die(biscuits);
}


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

int A[100001];
int n;
long long int res[100001];

struct data
{
	int val;
	int idx;
};

bool operator<(data a,data b)
{
	if(a.val==b.val)
	{
		return a.idx > b.idx;
	}
	return a.val < b.val;
}
int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);

	cin >> n;

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

	priority_queue <data> pque;
	for(int i=1;i<=n;i++)
	{
		data d;
		d.val = A[i];
		d.idx = i;
		pque.push(d);
	}

	int cnt = 0;
	int iidx = 1e9;
	while(1)
	{
		int idx = pque.top().idx;
		long long int val = pque.top().val;
		long long int val2 = 0;
		if(idx==1)
		{
			break;
		}

		while(!pque.empty())
		{
			if(pque.top().val < val)
			{
				val2 = pque.top().val;
				break;
			}
			iidx = min(iidx,pque.top().idx);
			cnt++;
			pque.pop();
		}

		res[iidx] += cnt*(val-val2);
	}

	for(int i=1;i<=n;i++)
	{
		if(A[i] < A[1])
		{
			res[1] += A[i];
		}
		else
		{
			res[1] += A[1];
		}
	}

	for(int i=1;i<=n;i++)
	{
		cout << res[i] << '\n';
	}
	
	return 0;
}

Measured memory_bytes: 3188
package main

import (
	"fmt"
	"math"
)

func main() {
	var N int
	fmt.Scan(&N)
	var t0 int = 0
	var t1 int
	var x0, y0 float64 = 0, 0
	var x1, y1 float64

	for range make([]int, N) {
		fmt.Scan(&t1, &x1, &y1)
		dt := t1 - t0
		dist := math.Abs(x1-x0) + math.Abs(y1-y0)

		if dt < int(dist) || dt%2 != int(dist)%2 {
			fmt.Println("No")
			return
		}

		t0, x0, y0 = t1, x1, y1
	}
	fmt.Println("Yes")
}


Measured memory_bytes: 5504