akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
using namespace std;

int main() {
    int n;
    cin >> n;
    vector<pair<int , int >> v;
    vector<int> num(n);

    for(int i = 0; i < n; i++) {
        int x, y;
        cin >> x >> y;
        v.push_back(make_pair(x, y));
    }

    for(int i = 0; i < n; i++) {
        num[i] = i;
    }

    vector<double> val;
    do {
        double sum = 0;
        for(int i = 0; i < n-1; i++) {
            double tmp1 = (v[num[i+1]].first-v[num[i]].first);
            double tmp2 = (v[num[i+1]].second-v[num[i]].second);
            sum += sqrt(tmp1*tmp1 + tmp2*tmp2);
        }
        val.push_back(sum);
    } while(next_permutation(num.begin(), num.end()));

    //sort(val.begin(), val.end());
    double ave = 0;
    for(int i = 0; i < val.size(); i++) {
        ave += val[i];
    }

    cout << setprecision(11) <<  ave / val.size() << endl;

    return 0;
}

Measured memory_bytes: 892
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <random>

using namespace std;


int main()
{
	int AB,BC,CA;

	cin >> AB >> BC >> CA;

	int ans = AB * BC / 2;

	printf("%d", ans);

	return 0;
}



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

int main(){
  int N, Q;
  cin >> N >> Q;
  string st;
  cin >> st;
  vector<int> rui(N);
  int ans = 0;
  rui.at(0) = 0;
  for(int i=1; i<N; i++){
    if(st.at(i-1) == 'A' && st.at(i) == 'C') ans++;
    rui.at(i) = ans;
  }
  rep(i, Q){
    int l, r;
    cin >> l >> r;
    ans = rui.at(r-1) - rui.at(l-1);
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
 
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
 
#define fi first
#define se second
#define FIO {ios::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);}
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
 
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef long double ld;

int main(){
  FIO
 int n;
 cin>>n;
 string s;
 int maxi=INT_MIN;
 map<string,int> m;
 forn(i,n)
 {
  cin>>s;
  m[s]++;
 }
 for(auto i=m.begin();i!=m.end();i++)
 {
  maxi=max(maxi,i->second);
 }
 for(auto i=m.begin();i!=m.end();i++)
 {
  if(i->second==maxi)
  {
    cout<<i->first<<endl; 
  }
 }
 
}

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

int main()
{
    unsigned long a, b, k;
    cin >> a >> b >> k;
    if (k > a + b)
    {
        a = 0;
        b = 0;
    }else if (k > a){
        b = b - (k - a);
        a = 0;
    }else{
        a = a - k;
    }
    

    cout << a << " " << b << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
using namespace std;
typedef long long ll;
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
static const ll maxLL = (ll)1 << 62;
 
int main() {
int n,y,a,b;
cin>>n>>y;

bool can =false;
int sum =0;
for(int i=0;i<=n;i++){
    for(int j=0;j<=n-i;j++){
        if(i*10000+j*5000+(n-i-j)*1000==y) {
            can=true;
            a=i;
            b=j;
        }
    }
}
if(can) cout<<a<<" "<<b<<" "<<n-a-b<<endl;
else cout<<"-1 -1 -1"<<endl;
return 0;
}

Measured memory_bytes: 384
import qualified Data.ByteString.Char8 as B

main :: IO ()
main = do
  s <- B.getLine
  putStrLn $ if solve s then "Yes" else "No"

solve :: B.ByteString -> Bool
solve s
  | s  /= B.reverse s  = False
  | s1 /= B.reverse s1 = False
  | s2 /= B.reverse s2 = False
  | otherwise          = True
  where
    n = B.length s
    s1 = B.take ((n - 1) `div` 2) s
    s2 = B.drop ((n + 1) `div` 2) s


Measured memory_bytes: 380
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;
public class Main {
 
	public static void main(String[] args) {
 
		Scanner scan = new Scanner(System.in);
 
		int N = scan.nextInt();
		int[] suretuP = new int[N];
		int[] suretuQ = new int[N];
 
		ArrayList<Integer> integer1 = new ArrayList<>();
		ArrayList<Integer> integer2 = new ArrayList<>();
 
		for(int i=0;i<N;i++) {
 
			suretuP[i] = scan.nextInt();
		}
 
		for(int i=0;i<N;i++) {
			suretuQ[i] = scan.nextInt();
		}
 
 
		for(int i=1;i<=N;i++) {
			integer1.add(i);
		}
 
		int countP = 0;
 
		for(int i=0;i<N-1;i++) {
			countP += integer1.indexOf(suretuP[i])*fact(N-i-1);
			integer1.remove((Integer)suretuP[i]);
			Collections.sort(integer1);
		}
 
		for(int i=1;i<=N;i++) {
			integer2.add(i);
		}
		int countQ = 0;
 
		for(int i=0;i<N-1;i++) {
			countQ += integer2.indexOf(suretuQ[i])*fact(N-i-1);
			integer2.remove((Integer)suretuQ[i]);
			Collections.sort(integer2);
		}
 
		System.out.println(Math.abs(countP-countQ));
		scan.close();
 
	}
 
	public static int fact(int num) {
 
		int i=1;
		for(int j=1;j<=num;j++) {
			i *= j;
		}
		return i;
	}
 
}

Measured memory_bytes: 27128
#include <algorithm>
#include <complex>
#include <iostream>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using std::cin;
using std::cout;
using std::endl;
using std::cerr;

using std::string;
using std::to_string;
using std::vector;
using std::set;
using std::queue;
using std::stack;
using std::priority_queue;

using std::min;
using std::max;
using std::sort;
using std::abs;

typedef long long int ll;
const int MOD = 1e9 + 7;

int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int l = a + b;
    int r = c + d;
    if(l < r){
        cout << "Right" << endl;
    }else if(l > r){
        cout << "Left" << endl;
    }else{
        cout << "Balanced" << endl;
    }
    return 0;
}



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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2019/04/03  Problem: ABC 049 A / Link: http://abc049.contest.atcoder.jp/tasks/abc049_a  ----- */



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

	char c; cin >> c;
	string s = "aeiou";
	LL ans = s.find(c) != string::npos;

	cout << (ans ? "vowel" : "consonant") << "\n";

	return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#pragma target("avx")
#pragma optimize("O3")
#pragma optimize("unroll-loops")
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,n) for(int i=1;i<=(int)(n);i++)
#define all(V) V.begin(),V.end()
typedef long long lint;
typedef std::pair<lint, lint> P;
constexpr int INF = INT_MAX / 2;
constexpr lint LINF = LLONG_MAX / 2;
constexpr double eps = 1e-9;
template<class T>
class prique :public std::priority_queue<T, std::vector<T>, std::greater<T>> {};
template <class T, class U>
inline bool chmax(T& lhs, const U& rhs) {
	if (lhs < rhs) {
		lhs = rhs;
		return 1;
	}
	return 0;
}
template <class T, class U>
inline bool chmin(T& lhs, const U& rhs) {
	if (lhs > rhs) {
		lhs = rhs;
		return 1;
	}
	return 0;
}
inline lint gcd(lint a, lint b) {
	while (b) {
		lint c = a;
		a = b; b = c % b;
	}
	return a;
}
inline lint lcm(lint a, lint b) {
	return a / gcd(a, b) * b;
}
bool isprime(lint n) {
	if (n == 1)return false;
	for (int i = 2; i * i <= n; i++) {
		if (n % i == 0)return false;
	}
	return true;
}
lint mypow(lint a, lint b) {
	if (!b)return 1;
	if (b & 1)return mypow(a, b - 1) * a;
	lint memo = mypow(a, b >> 1);
	return memo * memo;
}
lint modpow(lint a, lint b, lint m) {
	if (!b)return 1;
	if (b & 1)return modpow(a, b - 1, m) * a % m;
	lint memo = modpow(a, b >> 1, m);
	return memo * memo % m;
}
template<typename T>
void printArray(std::vector<T>& vec) {
	rep(i, vec.size() - 1)std::cout << vec[i] << " ";
	std::cout << vec.back() << std::endl;
}
template<typename T>
void printArray(T l, T r) {
	T rprev = r;
	rprev--;
	for (T i = l; i != rprev; i++) {
		std::cout << *i << " ";
	}
	std::cout << *rprev << std::endl;
}
std::string to_string(std::vector<int>& vec) {
	std::string res = "[";
	rep(i, vec.size() - 1)res += std::to_string(vec[i]) + ", ";
	res += std::to_string(vec.back()) + "]";
	return res;
}
int n,m,x,c[15],a[15][15],b[15];;
int main() {
	std::cin>>n>>m>>x;
	rep(i,n){
		std::cin>>c[i];
		rep(j,m)std::cin>>a[i][j];
	}
	int ans=INF;
	rep(i,1<<n){
		int cnt=0;
		std::fill(b,b+m,0);
		rep(j,n){
			if(i&(1<<j)){
				cnt+=c[j];
				rep(k,m)b[k]+=a[j][k];
			}
		}
		if(*std::min_element(b,b+m)>=x)chmin(ans,cnt);
	}
	if(ans==INF)std::cout<<-1<<std::endl;
	else std::cout<<ans<<std::endl;
	return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <stack>
#include <cctype>
#include <complex>
#include <vector>
#include <functional>
#include <algorithm>

using namespace std;


bool solve(){
	vector<int> a(5);
	for(int i=0;i<5;i++){
		cin>>a[i];
	}
	sort(a.begin(),a.end(),greater<int>());
	for(int i=0;i<5;i++){
		cout<<a[i];
		if(i!=4) cout<<" ";
	}
	cout<<endl;
	return true;
}

int main(){
	cout.setf(ios::fixed);
	cout.precision(10);
	solve();

	return 0;
}

 

Measured memory_bytes: 1212
# -*- coding: utf-8 -*-
"""



"""
import sys


def solve(W, H, x, y):
    if y == 0 or x == 0 or y == H or x == W:
        return W*H/2.0, 0

    if x == W/2:
        if y == H/2:
            return W*H/2.0, 1
        return W*H/2.0, 0
    if y == H/2:
        return W*H/2.0, 0

    w1 = x * H
    w2 = (W-x) * H
    ww1 = min(w1, w2)

    w3 = y * W
    w4 = (H-y) * W
    ww2 = min(w3, w4)
    if ww1 == ww2:
        return ww1, 1
    return W*H/2, 0


def main(args):
    W, H, x, y = map(int, input().split())
    ans = solve(W, H, x, y)
    print(*ans)


if __name__ == '__main__':
    main(sys.argv[1:])


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

#define ll long long

int main() {
    int A, B;
    cin >> A >> B;
    if(13 <= A) {
        cout << B << endl;
    } else if (6 <= A) {
        cout << B/2 << endl;
    }else{
        cout << 0 << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

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

    static void solve(Scanner sc) {
        String s = sc.nextLine();
        for (char i = 'a'; i <= 'z'; i++) {
            if (s.indexOf(i) == -1) {
                System.out.println(i);
                return;
            }
        }

        System.out.println("None");
    }
}

Measured memory_bytes: 26992
import java.util.*;
import java.io.*;
import java.nio.charset.StandardCharsets;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);
		Main ins = new Main(in);
		ins.calc();
		ins.showResult();
	}

	int N, K;
	int[] A;

	static class Tuple {
		int val, len;

		Tuple(int val, int len) {
			this.val = val;
			this.len = len;
		}
	}

	Main(BufferedReader in) throws IOException {
		String[] tokens = in.readLine().split(" ");
		N = Integer.parseInt(tokens[0]);
		K = Integer.parseInt(tokens[1]);
		A = new int[N];
		for (int i = 0; i < N; ++i) {
			A[i] = Integer.parseInt(in.readLine());
		}
	}

	void calc() {
		Queue<Tuple> que = new PriorityQueue<>(new Comparator<Tuple>() {
			@Override
			public int compare(Tuple o1, Tuple o2) {
				return -1 * Integer.compare(o1.len, o2.len);
			}
		});

		que.add(new Tuple(A[0], 1));
		List<Tuple> list = new ArrayList<>(N);
		for (int i = 1; i < N; ++i) {
			// 追加できるやつを探す
			Tuple tuple = null;
			while (!que.isEmpty()) {
				if (Math.abs(A[i] - que.peek().val) <= K) {
					tuple = que.poll();
					break;
				} else {
					list.add(que.poll());
				}
			}
			if (tuple == null) {
				// 見つけられなかった
				que.addAll(list);
				que.add(new Tuple(A[i], 1));
			} else {
				// 見つけられた
				que.add(new Tuple(A[i], tuple.len + 1));
				que.add(tuple);
				que.addAll(list);
			}
			list.clear();
		}
		System.out.println(que.peek().len);

	}

	void showResult() {
	}
}

Measured memory_bytes: 59360
using System;
using System.Linq;
using System.Collections.Generic;
using System.Collections;
public class Program {
  public static void Main() {
    char[] S = ReadCharArray();
    Console.WriteLine(Math.Min(S.Count(i => i == '0'), S.Count(i => i == '1')) * 2);
  }

  private static string ReadStr() { return Console.ReadLine(); }
  private static int ReadInt() { return int.Parse(Console.ReadLine()); }
  private static double ReadDouble() { return double.Parse(Console.ReadLine()); }
  private static long ReadLong() { return long.Parse(Console.ReadLine()); }
  private static char ReadChar() { return Console.ReadLine()[0]; }
  private static string[] ReadStringArray() { return Console.ReadLine().Split(' '); }
  private static int[] ReadIntArray() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
  private static double[] ReadDoubleArray() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
  private static long[] ReadLongArray() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
  private static char[] ReadCharArray() { return Console.ReadLine().ToArray(); }
  private static string[] ReadCharStringArray() { return Console.ReadLine().ToCharArray().Select(c => c.ToString()).ToArray(); }
  private static int[] ReadCharIntArray() { return Console.ReadLine().ToCharArray().Select(c => int.Parse(c.ToString())).ToArray(); }
}


Measured memory_bytes: 13280
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
namespace AtCoder
{
    class Program
    {
        static StreamReader sr;

        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static long Mod = (long)998244353;
        static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            var N = Sarray()[0];
            var Sij = new string[N];
            for (var i = 0; i < N; ++i)
                Sij[i] = ReadLine();
            var ans = 0L;
            for (var i = 0; i < N; ++i)
            {
                var q = new Queue<long>();
                var no = Enumerable.Repeat(-1, (int)N).ToArray();
                q.Enqueue(i);
                no[i] = 0;
                while (q.Any())
                {
                    var r = q.Dequeue();
                    for (var j = 0; j < N; ++j)
                    {
                        if ('0' == Sij[r][j]) continue;
                        if (-1 == no[j])
                        {
                            no[j] = no[r] + 1;
                            q.Enqueue(j);
                        }
                        if (Abs(no[j] - no[r]) != 1)
                        {
                            WriteLine(-1);
                            return;
                        }
                    }
                }
                ans = Max(ans, no.Max());
            }
            WriteLine(ans + 1);
            //Out.Flush();
        }
    }
}

Measured memory_bytes: 15572
import sys

h, w, k = map(int, input().split())
c = [i.split() for i in sys.stdin.readlines()]
ans = [0]

def dfs(A):
    if len(A) == h+w:
        tmp = ""
        cnt = 0
        for i in range(h+w):
            if i < h:
                if A[i]:
                    tmp += "".join(c[i])
            else:
                if A[i]:
                    cnt += tmp[i-h::w].count("#")
        if cnt == k:
            ans[0] += 1
        return

    for v in range(2):
        A.append(v)
        dfs(A)
        A.pop()

dfs([])
print(ans[0])


Measured memory_bytes: 9216
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int which_color(int rate){
  if(1<= rate && rate <= 399) return 0;
  if(400<= rate && rate <= 799) return 1;
  if(800<= rate && rate <= 1199) return 2;
  if(1200<= rate && rate <= 1599) return 3;
  if(1600<= rate && rate <= 1999) return 4;
  if(2000<= rate && rate <= 2399) return 5;
  if(2400<= rate && rate <= 2799) return 6;
  if(2800<= rate && rate <= 3199) return 7;
  return 8;
}
int main(){
  int N;
  int num_colors = 9;
  int colors[9] = {};
  vector<int> a;
  cin >> N;
  int tmp = 0;
  for(int i=0;i<N;i++){
    cin >> tmp;
    colors[which_color(tmp)]++;
  }
  int min_colors = 0, max_colors = 0;
  for(int i=0;i<num_colors-1;i++)
    if(colors[i]!=0) min_colors++;

  if(min_colors == 0 && colors[num_colors-1]!=0) {
    min_colors += 1;
    max_colors = colors[num_colors-1];
  } else {
    max_colors = min_colors+colors[num_colors-1];
  }
  cout << min_colors << " "<< max_colors << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long double a, b, c;
  cin >> a >> b >> c;
  
  long double eps = 1.0E-14;
  
  if ( sqrt(a) + sqrt(b) + eps < sqrt(c)) {
    cout << "Yes" << endl; 
  }
  else {
    cout << "No" << endl; 
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define fi first
#define se second
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define pf push_front
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ge(a, b) get<(b)>((a))
#define SZ(x) (x).size()
#define ft front()
#define bk back()
#define endl '\n'
#define FOR(a, b, c) for (auto(a) = (b); (a) < (c); ++(a))
#define ROF(a, b, c) for (auto(a) = (b); (a) > (c); --(a))
#define F0R(a, b) FOR ((a), 0, (b))
#define R0F(a, b) ROF ((a), (b), -1)
#define CEIL(a, b) ((a) + (b)-1) / (b)
#define SET(a, b) memset((a), (b), sizeof(a))
#ifndef DEBUG
#define DEBUG 0
#endif
#define dout \
    if (DEBUG) std::cerr
const int xd[4] = {0, 1, 0, -1}, yd[4] = {1, 0, -1, 0};
template <typename t>
bool ckmin(t& a, const t& b) {
    return a > b ? a = b, true : false;
}
template <typename t>
bool ckmax(t& a, const t& b) {
    return a < b ? a = b, true : false;
}

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

    int n;
    cin >> n;
    ll sum = 0;
    FOR (i, 1, n + 1)
        if (i % 3 && i % 5) sum += i;
    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 3640
import java.util.*;

public class Main{
  public static void main(String[]args){
    Scanner sc = new Scanner(System.in);
    int N = Integer.parseInt(sc.nextLine());
    boolean first = true;
    boolean check = false; //true = +, false = -,
    int count = 1;
    int n = Integer.parseInt(sc.next());;
    for(int i = 0; i < N-1; i++){
      int m = Integer.parseInt(sc.next());
      if(first){
        if(n > m){
          check = true;  
          first = false;
          n = m;
        }else if(n < m){
          check = false;
          first = false;
          n = m;
        }
      }else{
        if((check && n > m) || (!check && n < m)){
          n = m;
        }else if((check && n < m) || (!check && n > m)){
          count++;
          first = true;
          n = m;
        }
      }
    }
    System.out.println(count);
  }
}

Measured memory_bytes: 47096
#include <bits/stdc++.h> //C++の標準ライブラリを一行で一括でインクルードする
#include <math.h> //数学関数と数学定数を利用する
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}

const int MOD = 1000000007;

int main(){
  ll a,b; cin >> a >> b;
  if(a<b){
    swap(a,b);
  }
  if((a-b)%2){
    cout << "IMPOSSIBLE" << endl;
  }else{
    cout << a-(a-b)/2 << endl;
  }
  return 0;
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long int ll;
#define pb push_back
#define FOR(i, a, b) for (ll i = (signed)(a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define EREP(i, n) for (int i = (n)-1; i >= 0; --i)
#define MOD 1000000007
#define INF 93193111451418101
#define MIN -93193111451418101
#define EPS 1e-11
using namespace std;

char grid[51][51];
ll n, h, w;

bool check(vector<ll> &v, ll lx[50], ll ly[50], ll rx[50], ll ry[50], ll c) {
  ll itr = 0;
  itr = find(v.begin(), v.end(), c) - v.begin();
  FOR(i, ly[c], ry[c] + 1) {
    FOR(j, lx[c], rx[c] + 1) {
      if (grid[i][j] == '.')
        return 0;
      if (grid[i][j] != c + 'A') {
        REP(k, (signed)v.size()) {
          if (v[k] + 'A' == grid[i][j] && k > itr)
            return 0;
        }
      }
    }
  }
  return 1;
}

int main() {
  cin >> n;
  string str = "";
  REP(loop, n) {
    ll lx[50] = {}, ly[50] = {}, rx[50] = {}, ry[50] = {};
    REP(i, 50) { lx[i] = 100, ly[i] = 100; }
    vector<ll> v;
    cin >> h >> w;
    REP(i, h) {
      REP(j, w) { cin >> grid[i][j]; }
    }
    REP(i, h) REP(j, w) {
      const char c = grid[i][j];
      const ll cl = grid[i][j] - 'A';
      if (c == '.')
        continue;
      v.pb(cl);
      lx[cl] = min(lx[cl], j);
      ly[cl] = min(ly[cl], i);
      ry[cl] = max(ry[cl], i);
      rx[cl] = max(rx[cl], j);
    }
    sort(v.begin(), v.end());
    v.erase(unique(v.begin(), v.end()), v.end());
    bool ff = 0;
    do {
      ff = 0;
      for (auto &a : v) {
        if (check(v, lx, ly, rx, ry, a) == 0) {
          ff = 1;
          break;
        }
      }
      if (!ff) {
        printf("%s\n", "SAFE");
        break;
      }
    } while (next_permutation(v.begin(), v.end()));
    if (ff)
      printf("%s\n", "SUSPICIOUS");
  }
}



Measured memory_bytes: 3172
#include <bits/stdc++.h>
#define Mem(a,b) memset(a,b,sizeof(a))
#define ll long long
#define lson root<<1
#define rson root<<1|1
#define Mid int mid=(l+r)>>1
#define FREI freopen("in.txt","r",stdin)
#define FREO freopen("out.txt","w",stdout)
#define inf 0x3f3f3f3f
#define mod 1000000007
#define PB push_back
using namespace std;
const int MAXN=1e7+10;
int n;
int vis[200];
struct fc{
    int v,cost;
};
vector<int>point;
vector<int>X,Y;
vector<fc>G[110];
bool used[220];
int pre[220];
void pretreat(){
    Mem(vis,0);
    point.clear();
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%d",&vis[i]);
    }
    sort(vis,vis+n);
    for(int i=0;i<n;i++){
        if(i==0) point.PB(vis[i]);
        if(i>0&&vis[i]!=vis[i-1]+1) {
            point.PB(vis[i]);
            //cout<<i<<' '<<vis[i]<<endl;
        }
        if(vis[i+1]!=vis[i]+1){
            point.PB(vis[i]+1);
            //cout<<vis[i]+1<<endl;
        }
    }
    for(auto u:point){
        //cout<<u<<' ';
        if(u&1) Y.push_back(u);
        else X.push_back(u);
    }
    //cout<<endl;
//    for(auto u:X){
//        cout<<u<<' ';
//    }
//    cout<<endl;
//    for(auto v:Y){
//        cout<<v<<' ';
//    }
//    cout<<endl;
}
bool isprime(int x){
    if(x==1||x==2) return false;
    for(int i=2;i*i<=x;i++){
        if(x%i==0) return false;
    }
    return true;
}
void build_graph(){
    for(int i=0;i<X.size();i++){
        for(int j=0;j<Y.size();j++){

            if(isprime(abs(Y[j]-X[i]))){
                G[i+1].PB({j+1,abs(Y[j]-X[i])});
                //cout<<abs(Y[j]-X[i])<<' '<<X[i]<<' '<<Y[j]<<endl;
            }

        }
    }
}

bool dfs(int u){
    for(int i=0;i<G[u].size();i++){
        int v=G[u][i].v,cost=G[u][i].cost;

        if(!used[v]){
            used[v]=1;
            if(!pre[v]||dfs(pre[v])){
                pre[v]=u;
                return true;
            }
        }
    }
    return false;
}
int solve(){
    Mem(pre,0);
    int ans=0;
    for(int i=1;i<=X.size();i++){
        Mem(used,0);
        if(dfs(i)) ans++;
    }
    //for(int i=1;i<=Y.size();i++) cout<<pre[i]<<endl;
    //cout<<ans<<endl;
    //cout<<X.size()<<endl;
    return ans+(X.size()-ans)/2*2+(Y.size()-ans)/2*2+((X.size()-ans)%2)*3;
}
int main() {
    //FREI;
    //cout<<isprime(165)<<endl;
    pretreat();
    build_graph();
    printf("%d\n",solve());
    return 0;
}


Measured memory_bytes: 256
N = int(input())
d = dict()
cities = set()
for n in range(N):
    i = n + 1
    S, P = [s for s in input().split(' ')]
    cities.add(S)
    P = int(P)
    Ps = d.get(S, [])
    Ps.append((P, i))
    d[S] = Ps
for city in sorted(d.keys()):
    rs = d[city]
    for r, i in sorted(rs, reverse=True):
        print(i)


Measured memory_bytes: 3064
//#include <tourist>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = 1e9;
const ll LINF = ll(1e18);
const int MOD = 1000000007;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define debug(v)          \
    cout << #v << ":";    \
    for (auto x : v)      \
    {                     \
        cout << x << ' '; \
    }                     \
    cout << endl;
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;
}
//cout<<fixed<<setprecision(15);有効数字15桁
//-std=c++14
//-std=gnu++17
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; }
int n, d;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >>d >>n;
    if(n==100)n++;
    ll ans=n;
    rep(i,d){
        ans*=100;
    }
    cout<<ans<<"\n";
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    long long a, v, b, w, t;
    cin >> a >> v >> b >> w >> t;
    cout << ((a <= b && a + v * t >= b + w * t) || (a > b && a - v * t <= b - w * t) ? "YES" : "NO") << endl;
}


Measured memory_bytes: 3632
import collections
H, W = map(int, input().split())
table = collections.defaultdict(int)
for i in range(H):
    for x in input():
        table[x] += 1

tmp = 0

for x in table:
    if table[x] % 2 == 1:
        table[x] -= 1
        tmp += 1
num = [0, 0]
for x in table:
    num[1] += table[x] // 4
    if table[x] % 4 != 0:
        num[0] += 1


if H % 2 == 1 and W % 2 == 1:
    if tmp != 1:
        print("No")
        exit(0)
    else:
        if H+W - 2 < num[0] * 2:
            print("No")
            exit(0)
        else:
            if ((H+W - 2) - num[0]*2) % 4 != 0:
                print("No")
                exit(0)

elif H % 2 == 1 or W % 2 == 1:
    if tmp != 0:
        print("No")
        exit(0)
    else:
        if W % 2 == 1:
            H, W = W, H
        if W < num[0]*2:
            print("No")
            exit(0)
        else:
            if (W - num[0]*2) % 4 != 0:
                print("No")
                exit(0)

else:
    if num[0] != 0 or tmp != 0:
        print("No")
        exit(0)


print("Yes")


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

const int DIM = 5e5 + 5;

bool lef[DIM], rig[DIM];
char str[DIM]; int prf[DIM];

void solve( char str[DIM], bool arr[DIM], int n ) {
    
    for( int i = 2, l = 0; i <= n; i ++ ) {
        while( l != 0 && str[i] != str[l + 1] )
            l = prf[l];
        
        if( str[i] == str[l + 1] )
            l ++;
        
        prf[i] = l;
        arr[i] = ( l != 0 && i % (i - l) == 0 );
    }
    
    return;
}

int main( void ) {
    
    cin >> ( str + 1 );
    int n = (int) strlen( str + 1 );
    
    solve( str, lef, n );
    reverse( str + 1, str + n + 1 );
    
    solve( str, rig, n );
    reverse( rig + 1, rig + n + 1 );
    
    if( lef[n] == false )
        cout << "1\n1\n";
    else
    if( count( str + 1, str + n + 1, str[1] ) == n )
        cout << n << "\n1\n";
    else {
        int ans = 0;
        for( int i = 1; i < n; i ++ )
            ans += ( lef[i] == false && rig[i + 1] == false );
    
        cout << "2\n" << ans << "\n";
    }
    
    return 0;
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
using namespace std;

int main (void) {
  int n;
  cin >> n;
  string s;
  cin >> s;
  // 自分より西側で西を向いている人の数
  vector<int> a(n);
  // 自分より東側で東を向いている人の数
  vector<int> b(n);
  FOR(i, 1, n) {
    int j = n - i - 1;
    // cerr << j << endl;
    if (s[i - 1] == 'W')
      a[i] = a[i - 1] + 1;
    else
      a[i] = a[i - 1];
    if (s[j + 1] == 'E')
      b[j] = b[j + 1] + 1;
    else
      b[j] = b[j + 1];
  }
  int ans = 999999999;
  REP(i, n) {
    ans = min(ans, a[i] + b[i]);
    // cerr << a[i] << ", " << b[i] << endl;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3076
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  int h, w;
  cin >> h >> w;
  int a, b;
  cin >> a >> b;
  rep(i, h){
    rep(j, w){
      bool f1 = (j < a);
      bool f2 = (i < b);
      if((f1 ^ f2) == true) cout << 0;
      else cout << 1;
    }
    cout << endl;
  }

  return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;

#define INX(x) (cin >> x)
#define OUTX(x) (cout << x << endl)

#define ADD emplace_back
#define MP make_pair
#define VVEC(type) vector<vector<type>>


int main()
{
    ll N;
    INX(N);

    vll cnt(10001, 0);
    for (ll x = 1; x < 101; x++)
    {
        ll x2 = x * x;
        for (ll y = 1; y < 101; y++)
        {
            ll y2 = y * y;
            ll xy = x * y;
            ll xpy = x + y;
            for (ll z = 1; z < 101; z++)
            {
                ll tmp = x2 + y2 + z * z + xy + xpy * z;
                if(tmp <= 10000)
                {
                    cnt[tmp]++;
                }
            }
        }
    }

    for (ll i = 1; i <= N; i++)
    {
        OUTX(cnt[i]);
    }
    

    return 0;
}


Measured memory_bytes: 3692
n, m = map(int, input().split())

a = [[0] * n for i in range(n)]

for i in range(m):
    b = list(map(int, input().split()))
    a[b[0]-1][b[1]-1] = 1
    a[b[1]-1][b[0]-1] = 1

def dfs(v, n, visited):
    all_visited = 1
    for i in range(n):
        if visited[i] == 0:
            all_visited = 0

    if all_visited == 1:
        return 1

    ret = 0
    for i in range(n):
        if a[v][i] == 0:
            continue
        if visited[i] == 1:
            continue

        visited[i] = 1
        ret += dfs(i, n, visited)
        visited[i] = 0

    return ret

visited = [0] * n
visited[0] = 1
print(dfs(0, n, visited))


Measured memory_bytes: 3064
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 998244353
dd = [(0,-1),(1,0),(0,1),(-1,0)]
ddn = [(0,-1),(1,-1),(1,0),(1,1),(0,1),(-1,-1),(-1,0),(-1,1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    rr = []
    n = I()
    ni = 0

    while ni < n:
        ni += 1
        a = []
        while len(a) < 9:
            a += LS()
        t = int(a[-1],16)
        a = list(map(lambda x: int(x,16), a[:-1]))
        r = 0
        for i in range(32):
            ii = 2**i
            iii = 2**(i+1)
            b = t & ii
            c = 0
            for d in a:
                c += d^r
            if (c & ii) != b:
                r += ii

        rr.append('{:0x}'.format(r))

    return '\n'.join(map(str, rr))


print(main())




Measured memory_bytes: 9048
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCorder
{
    class Program
    {
        static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }
        public void Solve(ConsoleInput cin)
        {
            var x = cin.ReadInt;
            var a = cin.ReadInt;
            var b = cin.ReadInt;

            if (Abs(a - x) > Abs(b - x))
            {
                WriteLine("B");
            }
            else
            {
                WriteLine("A");
            }
        }

        /*public long C(long n, long r)
        {
            if (r == 0 || r == n) return 1L;
            if (n < r) return 0L;
            long[,] Pascal = new long[n + 1, n + 1];
            Pascal[0, 0] = 1;
            for (long i = 1; i <= n; i++)
            {
                Pascal[i, 0] = 1;
                Pascal[i, i] = 1;
                for (long j = 1; j < n; j++)
                {
                    Pascal[i, j] = Pascal[i - 1, j] + Pascal[i - 1, j - 1];
                }
            }
            return Pascal[n, r];
        }*/

        public class ConsoleInput
        {
            private readonly System.IO.TextReader _stream;
            private char _separator = ' ';
            private Queue<string> inputStream;
            public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
            {
                this._separator = separator;
                this._stream = stream;
                inputStream = new Queue<string>();
            }
            public string Read
            {
                get
                {
                    if (inputStream.Count != 0) return inputStream.Dequeue();
                    string[] tmp = _stream.ReadLine().Split(_separator);
                    for (int i = 0; i < tmp.Length; ++i)
                        inputStream.Enqueue(tmp[i]);
                    return inputStream.Dequeue();
                }
            }
            public string ReadLine { get { return _stream.ReadLine(); } }
            public int ReadInt { get { return int.Parse(Read); } }
            public long ReadLong { get { return long.Parse(Read); } }
            public double ReadDouble { get { return double.Parse(Read); } }
            public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
            public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
            public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
        }
    }
}


Measured memory_bytes: 11220
#include <iostream>
#include <string> 
#include <vector> 
#include <algorithm> 
#include <utility> 
#include <tuple> 
#include <cstdint> 
#include <cstdio> 
#include <map> 
#include <queue> 
#include <set> 
#include <stack> 
#include <deque> 
#include <unordered_map> 
#include <unordered_set> 
#include <bitset> 
#include <cctype> 
#include <math.h>
using namespace std;

#define int long long
#define endl "\n"
#define fir first
#define sec second
#define fro front
#define m_p make_pair
#define mod 1000000007
#define rep(i,n)  for(int i=0; i<(int) (n); i++)
#define all(v)  v.begin(),v.end()
#define vecin(v) for(int i=0; i<(int)v.size(); i++)cin>>v[i];
using namespace std;

const int MAX = 510000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
int jousu(int x00, int y00) {
	int z00 = 1;
	for (int i = 0; i < y00; i++) {
		z00 *= x00;
	}
	return z00;
}
int keta(int x00) {
	int z00 = x00;
	int w00 = 0;
	while (z00 != 0) {
		z00 /= 10;
		w00++;
	}
	return w00;
}

int modinv(int a, int m) {
	int b = m, u = 1, v = 0;
	while (b) {
		int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
int modpow(int a, int n) {
	int res = 1;
	while (n > 0) {
		if (n & 1) res* a% mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}
int gcd(int xx, int yy) {
	int p = xx;
	int q = yy;
	if (q > p)swap(p, q);
	while (p % q != 0) {
		p %= q;
		swap(p, q);
	}
	return q;
}
int lcm(int xx, int yy) {
	return xx * yy / gcd(xx, yy);
}
bool prime(int xx) {
	int a = xx;
	for (int i = 2; i * i <= xx; i++) {
		if (xx % i == 0) {
			return 0;
		}
	}
	return 1;
}
int com(int xx, int yy) {
	int zz = 1;
	for (int i = xx; i > xx - yy; i--) {
		zz *= i;
		zz %= mod;
	}
	for (int i = 1; i <= yy; i++) {
		zz *= modinv(i, mod);
		zz %= mod;
	}
	return zz;
}



signed main() {
	int a,n, m, t = 0;
	cin >> n >> m;
	rep(i, m) {
		cin >> a;
		t += a;
	}
	if (t > n) {
		cout << -1 << endl;
		return 0;
	}
	cout << n - t << endl;
}



Measured memory_bytes: 3600
function Main(input) {
    var N = parseInt(input[0], 10);
    var A = input.slice(1).map(a => parseInt(a, 10));

    var goodArray = new Array(N);
    var sum = 0;
    var times = 2;
    var index = 0;

    for (var i = N; i > 0; i--) {
        sum = 0;
        times = 2;
        index = times * i;
        while(index <= N) {
            sum += goodArray[index - 1];
            times++;
            index = times * i;
        }
        if ((A[i - 1]) % 2 === 0) {
            goodArray[i - 1] = sum % 2 === 0 ? 0 : 1;
        } else {
            goodArray[i - 1] = sum % 2 === 0 ? 1 : 0;
        }
    }

    var result = 0;
    for (var j = 0; j < N; j++) {
        result += goodArray[j];
    }

    if (result === 0) {
        return console.log(0);
    } else {
        console.log(result);
    }

    var resultArray = goodArray.map((num, index) => {
        return num === 1 ? index + 1 : 0;
    })

    console.log(resultArray.filter(num => num !== 0).join(' '));
  }

  Main(require("fs").readFileSync("/dev/stdin", "utf8").trim().split(/\n|\s/));

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

using namespace std;

int main(){
    int a, b;

    cin >> a >> b;

    if((a % 3 == 0) || (b % 3 == 0) || ((a+b) % 3 == 0)){
        cout << "Possible";
    }else{
        cout << "Impossible";
    }
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iostream>
#include <set>
#include <string>
#include <vector>

using namespace std;
typedef long long ll;
int main(void) {
  int N;
  cin >> N;
  vector<pair<ll, ll> > points(N);
  vector<ll> pos(N), neg(N);
  for (int i = 0; i < N; i++) {
    cin >> points[i].first >> points[i].second;
    pos[i] = (points[i].first + points[i].second);
    neg[i] = (points[i].second - points[i].first);
  }
  sort(pos.begin(), pos.end());
  sort(neg.begin(), neg.end());
  cout << (int)(max(fabs(pos[0] - pos[N - 1]), fabs(neg[0] - neg[N - 1])))
       << endl;
  return 0;
}

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

int main() {
  int N, C;
  cin >> N >> C;
  vector<vector<int>> dp(10200, vector<int>(C + 200, -1));
  vector<int> a(N), b(N), c(N);
  for (int i = 0; i < N; i++) cin >> a[i] >> b[i] >> c[i];
  dp[0][0] = 0;
  for (int k = 0; k < N; k++) {
    for (int i = 9999; i >= 0; i--) {
      for (int j = C - 1; j >= 0; j--) {
        if (dp[i][j] == -1) continue;
        dp[i + b[k]][j + c[k]] = max(dp[i + b[k]][j + c[k]], dp[i][j] + a[k]);
        dp[i + a[k]][j + c[k]] = max(dp[i + a[k]][j + c[k]], dp[i][j] + b[k]);
      }
    }
  }
  int maxi = 0;
  for (int i = 0; i <= 10000; i++) {
    for (int j = 0; j <= C; j++) maxi = max(maxi, min(i, dp[i][j]));
  }
  cout << maxi << endl;
}



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

#define LL long long
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(x) (x).begin(),(x).end()
const int IINF = 1e9;
const LL LINF = 1e18;
const LL mod = 1e9+7;

int main() {
    string s;
    cin >> s;
    if(s == "Sunny") {
        cout << "Cloudy" << endl;
    }else if(s == "Cloudy") {
        cout << "Rainy" << endl;
    }else{
        cout << "Sunny" << endl;
    }
    return 0;
}



Measured memory_bytes: 256
#include<cstdio>
#include<bits/stdc++.h>
typedef long long int ll;
#define REP(i, n) for(int i = 0; i < (n); i++)
#define FOR_IN(i, a, b) for(int i = (a); i < (b); i++)
#define BETWEEN(x, a, b) ((x) >= (a) && (x) <= (b))
#define BIT(b, i) (((b) >> (i)) & 1)
#define LOG_F 1
#define LOG(...) if(LOG_F) fprintf(stderr, __VA_ARGS__)

using namespace std;

ll pow(int x, int n){
  return n == 0 ? 1 : x * pow(x, n - 1);
}


/*
100
 */
int n;

int main(){
  cin>>n;

  int k=1;
  for(; k*2<=n; k*=2);

  cout<<k<<endl;

  return 0;
}


Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstring>
#include <fstream>
#include <functional>
#include <iostream>
#include <iomanip>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

#define ll long long int
#define FOR(i, a, b) for(int i=(a);i<=(b);++i)
#define REP(i, n) for(int i=0;i<n;++i)
#define FOREACH(x, a) for(auto& (x) : (a))
#define ALL(a) (a).begin(),(a).end()
#define OUT(x) out << (x) << endl;
#define M0(x) memset(x,0,sizeof(x))
#define MINF(x) memset(x,0x3f,sizeof(x))
#define MMINUS(a) memset(a,0xff,sizeof(a))
#define ten(n) ((int)1e##n)

const int INF = 0x3f3f3f3f;
const int MOD = 1e9+7;
const ll LINF = 1e18;
const double EPS = 1.0/LINF;
const char ENDL = '\n'; // for JetBrains IDE only supports yen

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 gcd(int a,int b){return b?gcd(b,a%b):a;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}

using namespace std;

class ANewYear {
public:
    int M;

    void solve(std::istream& in, std::ostream& out) {
        in >> M;
        OUT(48-M);
    }
};


int main() {
    ANewYear solver;
    std::istream& in(std::cin);
    std::ostream& out(std::cout);
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){int len=d.size();rep(i,len){s<<d[i];if(i<len-1) s<<" ";}return s;}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){int len=d.size();rep(i,len){s<<d[i]<<endl;}return s;}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T> ostream& operator<<(ostream& s,const multiset<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){s<<"{"<<endl;for(auto itr=m.begin();itr!=m.end();++itr){s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;}s<<"}"<<endl;return s;}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double EPS=1e-10;
const double PI=acos(-1);

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    ll n,p;
    cin>>n>>p;
    string s;
    cin>>s;
    ll ans=0;
    if(p==2 || p==5){
        for(int i=n-1;i>=0;i--){
            if(int(s[i]-'0')%p==0){
                ans+=i+1;
            }
        }
        cout<<ans<<endl;
        return 0;
    }
    ll ten=1;
    ll now=0;
    map<ll,ll> mp;
    mp[0]++;
    for(int i=n-1;i>=0;i--){
        now+=(int(s[i]-'0')*ten);
        now%=p;
        ten*=10;
        ten%=p;
        ans+=mp[now];
        mp[now]++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1044