akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstring>
using namespace std;
int aa,bb;
int main()
{
	string a;
	cin>>a;
	for(int i=0;i<a.length();i++)
	{
		if(a[i]=='C') aa++;
		if(a[i]=='F'&&aa>0) bb++;
	}
	if(aa==0||bb==0)
	cout<<"No";
	if(aa>0&&bb>0)
	cout<<"Yes";
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
  int a,b,c,d,s;
  scanf("%d%d%d",&a,&b,&c);
  d=0;
  s=0;
  while(s<c){
    d = d+1;
    s = s+a;
  if(d%7==0){
 s=s+b;
  }
  }
 printf("%d\n", d);
  return 0;
}


Measured memory_bytes: 2144
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
#include <math.h>
using namespace std;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
//No change above here

const ll maxi = 2 * 1e5 + 5;
ll mod = 1e9+7;
double pi = 3.141592653589793238;

//function for power
ll power(ll x, ll n) {
	ll res = 1;
	x %= mod;
	while (n) {
		if (n & 1)
			res = (res * x) % mod;
		x = (x * x) % mod;
		n >>= 1;
	}
	return res;
}

ll sum_digits(ll n)
{
	ll ret = 0;
	while (n)
	{
		ret += n % 10;
		n /= 10;
	}
	return ret;
}

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

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

ll max_subarray(vector<int>& v)
{
	if (v.empty())
		return 0;
	ll glob = v[0], loc = v[0];
	for (int i = 1; i < v.size(); ++i)
	{
		loc = max(v[i] + 0LL, loc + v[i]);
		glob = max(loc, glob);
	}
	return glob;
}

long long num_digits(long long x)
{
	long long ans = 0;
	while (x)
	{
		++ans;
		x /= 10;
	}
	return ans == 0 ? 1 : ans;
}

vector<int> topological_sort(vector<vector<int>>& graph, int n, vector<int>& indegree)
{
	vector<int> ans;
	stack<int> s;
	for (int i = 0; i < n; ++i)
		if (indegree[i] == 0)
			s.push(i);
	while (!s.empty())
	{
		int x = s.top();
		s.pop();
		ans.push_back(x);
		for (auto& adj : graph[x])
			if (--indegree[adj] == 0)
				s.push(adj);
	}
	return ans;
}

ll dir[4][2] = { {1, 0}, {-1, 0}, {0, 1}, {0, -1} };

ll p, q;
bool valid(ll i, ll j) { return i >= 1 && i <= p && j >= 1 && j <= q; }


//declare needed things here

//cabacc
//abc
int main()
{
	IOS;
	ll n,m,u,v;
	cin >> n>> m;
	vector<set<int>> graph(n);
	for (int i = 0; i < m; ++i)
	{
		cin >> u >> v;
		graph[u - 1].insert(v-1);
		graph[v - 1].insert(u-1);
	}
	vector<bool> visited(n, false);
	ll prev_visited = 0, cur_visited = 0,ans=0;
	for (int i = 0; i < n; ++i)
	{
		if (!visited[i])
		{
			cur_visited = prev_visited;
			queue<int> q;
			q.push(i);
			while (!q.empty())
			{
				int cur = q.front();
				visited[cur] = true;
				cur_visited++;
				q.pop();
				for (int edge : graph[cur])
				{
					if (!visited[edge])
					{
						q.push(edge);
						visited[edge] = true;
					}
				}
			}
			ans = max(ans, cur_visited - prev_visited);
		}
		
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 31616
public class Main {
    public static void main(String[] args) {

        java.util.Scanner sc = new java.util.Scanner(System.in);

        while (true) {
            String first = sc.next();
             if (first.equals("-")) { break; }
            int m = sc.nextInt();
            int h;

            StringBuilder sb = new StringBuilder();
            for (int i = 0; i < m; i ++)  {
                sb.delete(0, first.length());
                h = sc.nextInt();
                sb.append(first.substring(h, first.length()));
                sb.append(first.substring(0, h));
                first = sb.toString();
            }
            System.out.println(first);
        }
    }
}

Measured memory_bytes: 26384
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>

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

int N, M;
vector<vector<int> > G;
int dp[100001];
int rec(int v) {
   if (dp[v] != -1) return dp[v];

   int ans = 0;
   for (auto nv : G[v]) {
      chmax(ans, rec(nv) + 1);
   }
   return dp[v] = ans;
   
}

int main() {
   cin >> N >> M;
   G.assign(N, vector<int>());
   
   for (int i = 0; i < M; i++) {
      int x, y;
      cin >> x >> y;
      x--;
      y--;
      G[x].push_back(y);
   }

   for (int v = 0; v < N; v++) {
      dp[v] = -1;
   }

   int ans = 0;
   for (int v = 0; v < N; v++) {
      chmax(ans, rec(v));
   }
   
   cout << ans << endl;
   return 0;
}


Measured memory_bytes: 8192
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
using namespace std;

int main(){
    ll a,b;
    cin>>a>>b;
    string x,y;
    ll ans=0;
    for(ll i=a;i<=b;++i){
        x = to_string(i);
        y = x;
        reverse(y.begin(),y.end());
        if(x == y){
            ans++;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <utility>
#include <stack>
#include <string>
#include <algorithm> 
#include <set>
#include <sstream>
#include <list>
#include <bit>
#include <bitset>
#include <cstdint>
#include <iomanip>
#include <queue>
#include <initializer_list>
#include <stdio.h>
typedef long long int ll;
using namespace std;
int main() {
	int H, A; cin >> H >> A;
	int ans = H / A;
	if (H % A != 0)ans++;
	cout << ans << endl;

}

Measured memory_bytes: 3192
#define _CRT_SECURE_NO_WARNINGS
#include"bits/stdc++.h"
#ifdef _DEBUG
#define DBG(n) n
#else
#define DBG(n)
#endif
#define INF          1e9
#define INFLL        1e18
#define EPS          1e-9
#define MOD          1000000007
#define REP(i,n)     for(ll i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)    for(ll i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)    for(ll i=(n)-1;i>=0;--i)
#define REPR1(i,n)   for(ll i=(n);i>0;--i)
#define REPC(i,obj)  for(auto i:obj)
#define ALL(obj)     (obj).begin(),(obj).end()
#define SETP(n)      cout<<fixed<<setprecision(n)
#define VV(T,h,w)    move(vector<vector<T>>(h,move(vector<T>(w))))
#define VVI(T,h,w,i) move(vector<vector<T>>(h,move(vector<T>(w,i))))
using namespace std;
using ll = long long;
template<typename T = ll>inline T in() { T ret; cin >> ret; return ret; }

int main()
{
	ll n = in();
	string a, b, c; cin >> a >> b >> c;
	ll  ans = 0;
	REP(i, n) {
		ans +=
			a[i] == b[i] && b[i] == c[i] ? 0
			: a[i] == b[i] || b[i] == c[i] || c[i] == a[i] ? 1
			: 2;
	}
	cout << ans << endl;
}

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

#define INPUT freopen("input.txt", "r", stdin);

#define ll long long
#define ld long double

#define len(s) s.size()

#define fl(st, en, in) for (int i = st; i < en; i += in)
#define rfl(st, en, de) for (int i = st; i < en; i -= de)
#define ifl(st, en, in) for (int j = st; j < en; j += in)
#define fll fl(0, n, 1)

#define cy cout << "Yes" << endl;
#define cn cout << "No" << endl;
#define ci(s) cin >> s
#define co(s) cout << s << endl
#define nl cout << endl

#define vl vector<ll>
#define pb(x) push_back(x)

#define ms(arr, x) memset(arr, x, sizeof(arr))

#define inf INT_MAX
#define mx (ll)100000009
#define mod 1e9 + 7

//DSU

ll n, m;
ll par[mx];
ll sz[mx];

void make_set(ll v)
{
    par[v] = v;
    sz[v] = 1;
}

ll find_set(ll v)
{
    if (par[v] == v)
        return v;
    return par[v] = find_set(par[v]);
}

void union_set(ll a, ll b)
{
    a = find_set(a);
    b = find_set(b);
    if (a != b)
    {
        if (sz[a] < sz[b])
        {
            swap(a, b);
        }
        par[b] = a;
        sz[a] += sz[b];
    }
}
const string pc = "pairwise coprime";
const string sc = "setwise coprime";
const string nc = "not coprime";
const int A = 1e6 + 5;
void solve()
{
    int n;
    cin >> n;
    vector<int> a(n);
    vector<int> c(A);
    fll
    {
        cin >> a.at(i);
        c.at(a.at(i))++;
    }
    bool pairwise = true;
    fl(2, A, 1)
    {
        int cnt = 0;
        for (int j = i; j < A; j += i)
        {
            cnt += c.at(j);
        }
        if (cnt > 1)
            pairwise = false;
    }
    if (pairwise)
    {
        cout << pc << endl;
        return;
    }
    int g = 0;
    fll
    {
        g = gcd(g, a.at(i));
    }
    if (g == 1)
    {
        cout << sc << endl;
        return;
    }
    cout << nc << endl;
    return;
}

int main()
{
    // INPUT;
    // int t;
    // ci(t);
    // while (t--)
    solve();
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
#define MOD 1000000007
#define int long long int
#define FF first
#define pb push_back
#define SS second
#define double long double

typedef long long ll;

using namespace std;

int a[500005];
int dp[500005];
signed main()
{
 // freopen("input.txt" , "r" , stdin);
  //freopen("output.txt" , "w" , stdout);

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

  dp[0]=0;
  dp[1]=abs(a[1]-a[0]);
  for(int i=2;i<n;i++)
  {
    dp[i]=min(dp[i-1]+abs(a[i-1]-a[i]),dp[i-2]+abs(a[i-2]-a[i]));

  }
  cout<<dp[n-1]<<endl;
  return 0;
}

Measured memory_bytes: 5120
while True:
    H,W = map(int,input().split())
    if H == W == 0:
        break
    for h in range(H):
        if h % 2 == 0:
            line = "#."*(W//2+1)
        else:
            line = ".#"*(W//2+1)
        print("".join(line[:W]))
    print("")


Measured memory_bytes: 5616
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);
		final int N = Integer.parseInt(scan.nextLine());
		final int[] array = new int[N];
		for (int i = 0; i < N; i++) {
			array[i] = Integer.parseInt(scan.next());
		}
		scan.close();

		int count = 0;
		for (int i = 0; i + 2 < N; i++) {
			if (array[i] < array[i + 1] && array[i + 1] < array[i + 2]) {
				count++;
			} else if (array[i + 2] < array[i + 1] && array[i + 1] < array[i]) {
				count++;
			}
		}

		System.out.println(count);

	}

}

Measured memory_bytes: 21844
/* Author rumoisen */
/* created 2018/10/24 */

#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <string>
#include <cmath>
#include <iomanip>
#include <numeric>
#include <cmath>
 
using namespace std;
 
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define INF (ll)1e18
#define MOD (ll)1e9 + 7
#define pb push_back

void no(){cout<<"No"<<endl;exit(0);}
void yes(){cout<<"Yes"<<endl;exit(0);}
void No(){cout<<"NO"<<endl;exit(0);}
void Yes(){cout<<"YES"<<endl;exit(0);}

typedef long long ll;
typedef long long int llt;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

using namespace std;

int ketasu(long long int n)
{
    int a=0;
    while(n>0){
        a++;
        n/=10;
    }
    return a;
}
int main()
{
    llt n;
    cin>>n;
    int ans=1e9;
    for(llt i=1;i*i<=n;i++){
        if(n%i==0){
            ans=min(ans,max(ketasu(i),ketasu(n/i)));
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main{
	public static void main(String[] args) {
		Scanner stdIn=new Scanner(System.in);
		int n=stdIn.nextInt(),l,r,s=0,i;
		for(i=0;i<n;i++) {
			l=stdIn.nextInt();
			r=stdIn.nextInt();
			s+=r-l+1;
		}
		System.out.print(s);
	}
}

Measured memory_bytes: 24788
#include <iostream>
#include <vector>
#include <algorithm>

int main(){
    long long q, h, s, d, n;
    std::cin >> q >> h >> s >> d >> n;
    q = std::min(q * 4, std::min(h * 2,s));
    if(q * 2 <= d){
        std::cout << n * q << std::endl;
    }else{
        std::cout << n / 2 * d + n % 2 * q << std::endl;
    }
}


Measured memory_bytes: 256
import java.util.Scanner;
 
public class Main{
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int numa = scan.nextInt();
        int numb = scan.nextInt();
        int ans = 0;
        int i;
        
        for(i=0;i<=numb-1;i++){
           ans = ans +numa;
        }   
	    System.out.println(ans);
        scan.close();
    }
}

Measured memory_bytes: 35744
#include<bits/stdc++.h>
using namespace std;
long long M=1e9+7;
int solve(){
	int d,n;
	string s;
	cin>>s>>d;
	n=s.size();//first solve for n-1 digits upperbound is 9;
	long long dp[n][d];
	memset(dp,0,sizeof(dp));
	dp[0][0]=1;
	for(int i=1;i<n;i++){
		for(int j=0;j<d;j++){
			for(int x=0;x<=9;x++){
				dp[i][(j+x)%d]=(dp[i][(j+x)%d]+dp[i-1][j])%M;
			}
		}
	}
	long long ans=M-1; //subtracting 1 for zero;
	int t=0;
	for(int i=0;i<n;i++){
		for(int x=0;x<(s[i]-'0');x++){
			ans=(ans+(dp[n-i-1][(d-(x+t)%d)%d]))%M;
		}
		t+=(s[i]-'0');
	}
	if(t%d==0) ans++;
	return ans;
}
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout<<solve();
	
}

Measured memory_bytes: 11444
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_set>
#include <vector>

using namespace std;

#define FOR(i, N) for (int i = 0; i < (int)N; i++)
#define FORIN(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define MOD 1000000007
#define INF (1 << 29)
#define LLINF (1LL << 60)
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)

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

string to_string(string s) { return s; }

template <class S, class T>
string to_string(pair<S, T> p) {
  return "{" + to_string(p.first) + "," + to_string(p.second) + "}";
}

template <class S>
string to_string(unordered_set<S> s) {
  string ret = "{";
  for (S x : s) ret += to_string(x) + ",";
  return ret + "}";
}

template <class S, class T>
string to_string(map<S, T> m) {
  string ret = "{";
  for (pair<S, T> x : m) ret += to_string(x) + ",";
  return ret + "}";
}

template <class T>
string to_string(vector<T> v) {
  string ret = "{";
  for (int i = 0; i < (int)v.size() - 1; ++i) {
    ret += to_string(v[i]) + ",";
  }
  if (v.size() > 0) {
    ret += to_string(v.back());
  }
  ret += "}";
  return ret;
}

void debug() { cerr << endl; }

template <class Head, class... Tail>
void debug(Head head, Tail... tail) {
  cerr << to_string(head) << " ";
  debug(tail...);
}

void print() { cout << endl; }

template <class Head, class... Tail>
void print(Head head, Tail... tail) {
  cout << to_string(head);
  print(tail...);
}

int main() {
  cin.tie(0);
  int N;
  cin >> N;
  vector<Pi> p(N);
  FOR(i, N) cin >> p[i].first >> p[i].second;
  vector<int> order(N);
  iota(ALL(order), 0);
  double sum = 0;
  do {
    FOR(i, N - 1)
    sum += sqrt((p[order[i]].first - p[order[i + 1]].first) *
                    (p[order[i]].first - p[order[i + 1]].first) +
                (p[order[i]].second - p[order[i + 1]].second) *
                    (p[order[i]].second - p[order[i + 1]].second));
  } while (next_permutation(ALL(order)));
  FORIN(i, 2, N + 1) sum /= i;
  printf("%.10f\n", sum);
  return 0;
}

Measured memory_bytes: 256
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
mod2 = 998244353
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

n,k = inpl()
r = inpl()
t = input()
tt = [-1] * n
for i in range(n):
    if t[i] == 'r': tt[i] = 2
    elif t[i] == 's': tt[i] = 0
    else: tt[i] = 1
 
res = 0
for m in range(k):
    pre = -1
    for i in range(n)[m::k]:
        if tt[i] == pre:
            pre = -1
        else:
            res += r[tt[i]]
            pre = tt[i]
print(res)

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

int main(){
  int n, m;

  cin >> n;
  vector<string> b_card(n);
  for (int i = 0; i < n; i++)
  {
    cin >> b_card.at(i);
  }
  cin >> m;
  vector<string> r_card(m);
  for (int i = 0; i < m; i++)
  {
    cin >> r_card.at(i);
  }
  sort(b_card.begin(), b_card.end());
  sort(r_card.begin(), r_card.end());

  int cnt = 0;
  int index = 0;
  while (index < n){
    int buf = 1;
    int j = index;
    while(j < n-1 && b_card.at(j) == b_card.at(j+1)){
      buf++;
      j++;
    }
    index += buf;

    for(string s:r_card){
      if(s == b_card.at(index - 1))
        buf--;
    }

    cnt = max(buf, cnt);
  }
  cout << cnt << endl;

  
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
using namespace std;
constexpr int kMod = 1000000007;
typedef long long LL;

template<typename T>
auto makeNdVector(int n, const T& v) {
  return vector<T>(n, v);
}

template<typename T, typename N, typename... Tail>
auto makeNdVector(const N& n, const Tail&... tail) {
  auto vec = makeNdVector<T>(tail...);
  vector<decltype(vec)> vecs(n, vec);
  return vecs;
}

int main() {
  int R, C, K; cin >> R >> C >> K;
  auto A = makeNdVector<LL>(R, C, 0LL);
  auto B = makeNdVector<LL>(R, C, 3, 0LL);
  for (int i = 0; i < K; ++i) {
    int r, c, v; cin >> r >> c >> v; --r, --c;
    A[r][c] = v;
  }

#if 0
  for (int r = 0; r < R; ++r) {
    for (int c = 0; c < C; ++c) {
      cout << A[r][c] << " ";
    }
    cout << endl;
  }
#endif

  for (int k = 0; k < 3; ++k)
    B[0][0][k] = A[0][0];

  for (int r = 0; r < R; ++r) {
    for (int c = 0; c < C; ++c) {
      if (r == 0 && c == 0) continue;
      for (int k = 2; k >= 0; --k) {
        LL u = 0, l = 0;
        if (r > 0) u = B[r-1][c][2] + A[r][c];
        if (c > 0) {
          if (k > 0) l = max(B[r][c-1][k], B[r][c-1][k-1] + A[r][c]);
          else       l = max(B[r][c-1][k], A[r][c]);
        }
        B[r][c][k] = max(u, l);
      }
    }
  }

#if 0
  for (int r = 0; r < R; ++r) {
    for (int c = 0; c < C; ++c) {
      cout << B[r][c][0] << "/" << B[r][c][1] << "/" << B[r][c][2] << " ";
    }
    cout << endl;
  }
#endif
  cout << B[R-1][C-1][2] << endl;
}


Measured memory_bytes: 565920
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(ll i=0;i<n;++i)
#define P pair<ll,ll>
#define Graph vector<vector<P>>
#define fi first
#define se second
constexpr ll mod=1000000007;
constexpr ll INF=(1ll<<60);
constexpr double pi=3.14159265358979323846;
template<typename T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template<typename T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}

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

    ll ans=0;
    rep(i,n-2){
        if(s[i]=='A' && s[i+1]=='B' && s[i+2]=='C'){
            ans++;
        }
    }

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

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

#define ll long long
#define f first
#define se second
#define pb push_back
#define mp make_pair
#define boost cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0)
#define lb lower_bound
#define ub upper_bound
#define pii pair<int, int>

using namespace std;

const int N = 1e5 + 100, mod = 1e9, inf = 1e9 + 7;
int a[N], n, dp[N], k;

ll bin_pow(int x, int y){
    if(y == 0)
        return 1;
    if(y == 1)
        return x;
    if(y % 2 == 0){
        ll z = bin_pow(x, y / 2);
        return (z * z) % mod;
    }
    return (bin_pow(x, y - 1) * x) % mod;
}


int main(){
    boost;
    cin >> n >> k;
    for(int i = 1; i <= n; i++){
        cin >> a[i];
        dp[i] = 2e9;
    }
    int ans = 0;
    dp[1] = 0;
    for(int i = 2; i <= n; i++){
        for(int j = 1; j <= min(k, i - 1); j++){
            dp[i] = min(dp[i], dp[i - j] + abs(a[i] - a[i - j]));
        }
    }
    cout << dp[n];
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,d;
	cin>>n>>d;
    double *dd = new double[n];
	for(int i=0;i<n;i++){
      double p,q;
      cin >> p >> q;
       dd[i] = sqrt(p*p + q*q) *1.0; 
	}
	int c =0;
	//for(int i=0;i<n;i++){
//		cout << dd[i]<<" ";
	//}
	cout << endl;
	for(int i=0;i<n;i++){
      if(dd[i]<=d){
      	c++;
      }
	}
	cout << c << endl;
}

Measured memory_bytes: 5400
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f

#include <iostream>
#include <cstdio>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>
  
using namespace std;
  
typedef long long ll;
typedef pair <int,int> P;
  
static const double EPS = 1e-8;
  
static const int tx[] = {0,1,0,-1};
static const int ty[] = {-1,0,1,0};

class Cuboid{
public:
  ll ox[8]; //original x
  ll oy[8];
  ll od[8];

  int mx[8]; // mapped x
  int my[8];
  int md[8];

  Cuboid(int x1,int y1,int d1,
         int x2,int y2,int d2){
    ox[0] = x1;
    oy[0] = y1;
    od[0] = d1;

    ox[1] = x1;
    oy[1] = y2;
    od[1] = d1;

    ox[2] = x2;
    oy[2] = y2;
    od[2] = d1;

    ox[3] = x2;
    oy[3] = y1;
    od[3] = d1;

    ox[4] = x1;
    oy[4] = y1;
    od[4] = d2;

    ox[5] = x1;
    oy[5] = y2;
    od[5] = d2;

    ox[6] = x2;
    oy[6] = y2;
    od[6] = d2;

    ox[7] = x2;
    oy[7] = y1;
    od[7] = d2;
  }    

  void mapping(const vector<ll>& xs,
               const vector<ll>& ys,
               const vector<ll>& ds){
    for(int i=0;i<8;i++){
      mx[i] = lower_bound(xs.begin(),xs.end(),ox[i]) - xs.begin();
      my[i] = lower_bound(ys.begin(),ys.end(),oy[i]) - ys.begin();
      md[i] = lower_bound(ds.begin(),ds.end(),od[i]) - ds.begin();
    }
  }
};

int dp[101][101][101];

int main(){
  int total_fish;
  int lower;
  while(~scanf("%d %d",&total_fish,&lower)){

    vector<ll> xs;
    vector<ll> ys;
    vector<ll> ds;

    vector<Cuboid> cuboids;
    for(int fish_idx = 0; fish_idx < total_fish; fish_idx++){
      ll x1,y1,d1;
      ll x2,y2,d2;
      scanf("%lld %lld %lld",&x1,&y1,&d1);
      scanf("%lld %lld %lld",&x2,&y2,&d2);
      
      cuboids.push_back(Cuboid(x1,y1,d1,x2,y2,d2));
      xs.push_back(x1);       
      xs.push_back(x2);

      ys.push_back(y1);       
      ys.push_back(y2);

      ds.push_back(d1);       
      ds.push_back(d2);
    }

    sort(xs.begin(),xs.end());
    sort(ys.begin(),ys.end());
    sort(ds.begin(),ds.end());

    xs.erase(unique(xs.begin(),xs.end()),xs.end());
    ys.erase(unique(ys.begin(),ys.end()),ys.end());
    ds.erase(unique(ds.begin(),ds.end()),ds.end());

    memset(dp,0,sizeof(dp));
    for(int i=0;i<cuboids.size();i++){
      cuboids[i].mapping(xs,ys,ds);

      for(int x = cuboids[i].mx[0]; x < cuboids[i].mx[2]; x++){
        for(int y = cuboids[i].my[0]; y < cuboids[i].my[1]; y++){
          for(int d = cuboids[i].md[0]; d < cuboids[i].md[4]; d++){
            dp[x][y][d]++;
          }
        }
      }
    }

    ll res = 0;
    for(int x = 0; x < xs.size(); x++){
      for(int y = 0; y < ys.size(); y++){
        for(int d = 0; d < ds.size(); d++){
          if(dp[x][y][d] >= lower){
            res += (xs[x + 1] - xs[x])
              * (ys[y + 1] - ys[y])
              * (ds[d + 1] - ds[d]);
          }
        }
      }
    }

    printf("%lld\n",res);
  }
}

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

int main()
{
	int64_t h, w;
	cin >> h >> w;
	vector<vector<int>> ass(h, vector<int>(w)), bss(h, vector<int>(w));
	for (auto &&as : ass)
	{
		for (auto &&a : as)
		{
			cin >> a;
		}
	}
	for (auto &&bs : bss)
	{
		for (auto &&b : bs)
		{
			cin >> b;
		}
	}

	vector<vector<int>> css(h, vector<int>(w));
	for (int i = 0; i < h; i++)
	{
		for (int j = 0; j < w; j++)
		{
			css[i][j] = abs(ass[i][j] - bss[i][j]);
		}
	}

	vector<vector<bitset<160 * 80 * 80>>> dp(h, vector<bitset<160 * 80 * 80>>(w));
	int p = 80 * 80 * 80;

	dp[0][0][p - css[0][0]] = dp[0][0][p + css[0][0]] = 1;

	for (int i = 0; i < h; i++)
	{
		for (int j = 0; j < w; j++)
		{
			if (i + 1 < h)
			{
				dp[i + 1][j] |= (dp[i][j] << css[i + 1][j]) | (dp[i][j] >> css[i + 1][j]);
			}
			if (j + 1 < w)
			{
				dp[i][j + 1] |= (dp[i][j] << css[i][j + 1]) | (dp[i][j] >> css[i][j + 1]);
			}
		}
	}

	int ans = (1 << 30);
	for (int i = 0; i < 160 * 80 * 80; i++)
	{
		if (dp[h - 1][w - 1][i])
		{
			ans = min(ans, abs(p - i));
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 810748
#include <iostream>

using namespace std;

int main(int argc, char const *argv[])
{
    int a, b;
    cin >> a >> b;
    int max = a + b;
    max = max > a - b ? max : a - b;
    max = max > a * b ? max : a * b;
    cout << max << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int a,b,c,d,e,x,y,z;
	scanf("%d",&a);
	scanf("%d",&b);
	scanf("%d",&c);
	scanf("%d",&d);
	scanf("%d",&e);
	x=a*e;
	if(e<=c){
		y=b;
	}
	else{
		 z=e-c;
		 y=d*z+b;
	}
	if(x>y){
		printf("%d\n",y);
	}
	else{
		printf("%d\n",x);
	}
	return 0;
}

Measured memory_bytes: 1816
#include <stdio.h>
#include <stdlib.h>

int main()
{
	char S[500002];
	scanf("%s", S);
	
	int i = 0, j, up, down;
	long long sum = 0;
	while (S[i] != 0) {
		up = 0;
		down = 0;
		while (S[i] == '<') {
			up++;
			i++;
		}
		while (S[i] == '>') {
			down++;
			i++;
		}
		for (j = 0; j < up; j++) sum += j;
		for (j = 0; j < down; j++) sum += j;
		sum += (up < down)? down: up;
	}
	
	printf("%lld\n", sum);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 2196
ii = lambda:int(input())
mi = lambda:list(map(int,input().split()))
ix = lambda x:list(input() for _ in range(x))
mix = lambda x:list(li() for _ in range(x))
iix = lambda x:list(int(input()) for _ in range(x))
##########
def main(n,a,b):
    before = sum(a)
    for i in range(len(b)):
        if b[i] < a[i]:
            a[i] -= b[i]
        else:
            a[i+1] = max(0, a[i] + a[i+1] - b[i])
            a[i] = 0
    return before - sum(a)
            
n = ii()
a = mi()
b = mi()
print(main(n,a,b))

Measured memory_bytes: 19284
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n; cin>>n;
  int Alice, Bob;
  vector<int> a(n);
  for(int i=0; i<n; i++){
    cin>>a[i];
  }
  sort(a.begin(),a.end());
  Alice = Bob = 0;
//  for(vector<int>::iterator it=v.end(); it!=v.begin(); --it){
  bool is_Alice = true;
  for( int i=n-1; i>=0; --i){
    if(is_Alice){
      Alice+=a[i]; is_Alice = false;
    }
    else{
      Bob+=a[i]; is_Alice = true;
    }
  }
  cout << Alice - Bob <<endl;
  return 0;
}

Measured memory_bytes: 256
def check(a):
    flag=False
    for i in range(1,100000):
        if a==i*i:
            flag=True
    return flag
    

n,d=map(int,input().split())
X=[]
for i in range(n):
    x=list(map(int,input().split()))
    X.append(x)

ans=0
for i in range(n):
    for j in range(i+1,n):
        D=0
        for di in range(d):
            D+=(X[i][di]-X[j][di])**2
        if check(D):
            ans+=1

print(ans)

Measured memory_bytes: 3064
#include<forward_list>
#include<algorithm>
#include<iostream>
#include<iomanip>
#include<iterator> 
#include<sstream>
#include<fstream>
#include<istream>
#include<utility>
#include<vector>
#include<stack>
#include<cmath>
#include<queue>
#include<deque>
#include<list>
#include<map> 
#include<set>
#define TitansGo ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define all(v) v.begin(),v.end()
#define YES cout << "YES\n";
#define NO cout << "NO\n";
#define ll long long 
#define endl "\n"
#define S second
#define F first
using namespace std;

int main()
{
	TitansGo
		double r;
	cin >> r;
	//cout << fixed << setprecision(20);
	double pi = 3.1415926535;
	cout<<r*2*pi<<endl;









}

Measured memory_bytes: 3220
#include<iostream>
#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
#include <iomanip>//setprecision
#include<math.h>
#include <functional>
#include<climits>
using namespace std;
#define ll  long long 
#define rep(i, n)        for(ll i=0; i<(ll)(n); ++i)
#define mod 1000000007
  vector<ll>to[1000005];
int main(){
  ll a,b,c;cin>>a>>b>>c;
  char d[6][6];
  rep(i,a)rep(o,b)cin>>d[i][o];
  ll kotae=0;
  rep(i,1<<a)rep(o,1<<b){
    ll sum=0;
    rep(j,a)rep(g,b)if(i>>j&1 && o>>g&1 &&d[j][g]=='#')sum++;
    if(sum==c)kotae++;

  }
  cout<<kotae;
}


Measured memory_bytes: 27056
#include<stdio.h>
#include<cmath>
#include<stdlib.h>
#include<iostream>
int main()
{
    long long int a,b,c,n,min,x,y;
    while(scanf("%lld",&n)!=EOF){
    min=n;
    for(a=sqrt(n);a>=1;a--)
    {
        if(n%a==0)
        {
            b=n/a;
            break;
        }
    }
    printf("%lld\n",a+b-2);
    }
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <cmath>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#define rep(i,n) for (int i=0;i<n;i++)
using ll = long long;
using namespace std;

void solve(){

}
int main (){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    rep(i,n){
        string s;
        cin >> s;
        if(s[0]=='Y'){
            cout << "Four";
            return 0;
        }
    }
    cout << "Three";

    return 0;
}

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

#define pq priority_queue
#define mp make_pair
#define cauto const auto &

#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())

#define clr(ar, val) memset(ar, val, sizeof(ar))

typedef long long int64;
typedef long long lint;
typedef long long lli;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;

typedef pair<int, int> pint;
typedef pair<long, long> plong;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef pair<ll, ll> pll;

const int iinf = 1 << 29;
const long long linf = 1ll << 61;

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;
}
template <class T = int> T in() {
    T x;
    cin >> x;
    return (x);
}
template <class T> void print(T &x) {
    cout << x << '\n';
    return;
}

template <class T> ll iterate_sized_subset(T &comb) {
    T x = comb & -comb, y = x + comb;
    return ((comb & ~y) / x) >> 1 | y;
}

struct union_find {
    int size;
    vector<int> par;
    union_find(int N) : size(N), par(N) { REP(i, N) par[i] = i; }
    int root(int x) {
        if (par[x] == x)
            return x;
        else {
            par[x] = root(par[x]);
            return par[x];
        }
    }
    void unite(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if (rx == ry)
            return;
        else {
            par[rx] = ry;
            return;
        }
    }
    bool same(int x, int y) { return root(x) == root(y); }
};

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

int main() {
    int h,w,a,b;
    cin>>h>>w>>a>>b;
    cout<<(h-a)*(w-b)<<endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<vector>
#include<algorithm>
#include<functional>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<deque>
#include<tuple>
#include<iostream>
#include<string>
using namespace std;
#define REP(i,x) for (int i=0;i<x;i++)
#define REPP(i,x,y) for (int i=x;i<=y;i++)
#define SI(x) scanf("%d",&x)
#define SL(x) scanf("%lld",&x)
#define MX3(x,y,z) max(x,max(y,z))
#define MX4(x,y,z,p) max(x,max(y,max(z,p)))
#define MX5(x,y,z,p,q) max(x,max(y,max(z,max(p,q))))
#define MN3(x,y,z) min(x,min(y,z))
#define MN4(x,y,z,p) min(x,min(y,min(z,p)))
#define MN5(x,y,z,p,q) min(x,min(y,min(z,min(p,q))))
#define amax(x,y) x=max(x,y)
#define amin(x,y) x=min(x,y)
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef vector<vb> vvb;
typedef long double ld;
// #####################################################################

void solve() {
    int n;
    SI(n);
    vl rec;
    REP(i, n) {
        ll x;
        SL(x);
        rec.push_back(x);
    }
    vvl dp(n+1, vl(5, 0));
    REPP(i, 1, n) {
        // c1
        dp[i][0] = dp[i-1][0] + rec[i-1];
        // c2
        dp[i][1] = min(dp[i-1][0], dp[i-1][1]) + (rec[i-1] == 0 ? 2 : rec[i-1] % 2);
        // c3
        dp[i][2] = MN3(dp[i-1][0], dp[i-1][1], dp[i-1][2]) + (rec[i-1] + 1) % 2;
        // c4
        dp[i][3] = MN4(dp[i-1][0], dp[i-1][1], dp[i-1][2], dp[i-1][3]) + (rec[i-1] == 0 ? 2 : rec[i-1] % 2);
        // c5
        dp[i][4] = MN5(dp[i-1][0], dp[i-1][1], dp[i-1][2], dp[i-1][3], dp[i-1][4]) + rec[i-1];
    }
    printf("%lld\n", MN5(dp[n][0], dp[n][1], dp[n][2], dp[n][3], dp[n][4]));
}

void init() {

}

int main () {
    init();
    solve();
    return 0;
}


Measured memory_bytes: 15856
n = gets.to_i
l = gets.chomp.split(' ').map(&:to_i)
ans = 0
l.combination(3).to_a.each do |i|
    sort_i = i.sort
    if i.uniq.size < 3
        next
    end
    if (sort_i[-1] < sort_i[0] + sort_i[1])
        ans += 1
    end
end

puts ans

Measured memory_bytes: 26852
fn main() {
    let v = read_vec::<u64>();
    let n = v[0];
    let t = v[1];
    let ts = read_vec::<u64>();
    let mut ts2 = vec![];
    for i in 1..n as usize {
        ts2.push(ts[i] - ts[i - 1]);
    }
    let mut ans = 0;
    for t1 in ts2 {
        if t1 > t {
            ans += t;
        } else {
            ans += t1;
        }
    }
    println!("{}", ans + t);
}

#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
#[allow(dead_code)]
fn yn(result: bool) {
    if result {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 8444
#include<algorithm>
#include<cmath>
#include<functional> //sortのgreater
#include<iostream>
#include<numeric> //iota(整数列の生成),gcdとlcm(c++17)
#include<string> //文字列
#include<vector>

using namespace std;
typedef long long ll;

int main()
{
    // Input
    int a, b, c, d;
    cin >> a >> b >> c >> d;

    int ao = a / d;
    if (a % d > 0) ao++;
    int taka = c / b;
    if (c % b > 0) taka++;

    if (taka <= ao) {
        cout << "Yes";
    } else {
        cout << "No";
    }

    return 0;
}


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

int main(){
	int n,k; cin>>n;
	cin>>k;
	int pos=1;
	for(int i=0;i<n;i++){
		if(pos*2<pos+k){
			pos=pos*2;
		}
		else{
			pos=pos+k;
		}
	}
	cout<<pos<<endl;
	return 0;
}

Measured memory_bytes: 256
N,k = gets.split.map(&:to_i)
X = gets.split.map(&:to_i)

xsnega = []
xsposi = []
X.each{ |x|
  case
  when x > 0; xsposi << x
  when x < 0; xsnega << x
  else
    k -= 1
  end
}

if k == 0
  puts 0; exit
end

xsnega.reverse!

ans = []
#p xsnega, xsposi
xsposi.each_with_index{ |x,i|
  if i == k-1
    ans << x
    break
  end
  next if k-i-2 >= xsnega.size
  ans << (x*2 - xsnega[k-i-2])
}
xsnega.each_with_index{ |x,i|
  if i == k-1
    ans << -x
    break
  end
  next if k-i-2 >= xsposi.size
  ans << (-x*2 + xsposi[k-i-2])
}
puts ans.min


Measured memory_bytes: 10124
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;
import java.util.stream.Collectors;

public class Main {

    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        s.nextLine();
        List<Integer> A = Arrays.asList((s.nextLine().split(" "))).stream().map(Integer::parseInt)
                .collect(Collectors.toList());
        boolean t1 = A.stream().filter(a -> a % 2 == 0).allMatch(a -> a % 3 == 0 || a % 5 == 0);
        System.out.println(t1 ? "APPROVED" : "DENIED");
    }
}

Measured memory_bytes: 28244
#include <iostream>
#include <cmath>
#include <climits>
#include <string>
#include <numeric>
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
#include <functional>
#include <iomanip>


using namespace std;
using ll = long long;

template<typename T> void print(T t) { cout << t << endl; }

int main() {
	int N, K, a;
	cin >> N >> K;
	for (int i = 0; i < N; i++)cin >> a;
	print((N - 1 + K - 2) / (K-1));
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
typedef long long ll; //10^19 < 9223372036854775807
typedef unsigned long long ull; //10^20 < 18446744073709551615

#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
#define FORA(i,I) for(const auto& i:I)
#define ALL(x) x.begin(),x.end() 
#define SIZE(x) ll(x.size()) 

#define MOD 1000000007

int main(void)
{
    string S, T;
    cin >> S >> T;

    ll ans = T.size();

    for (int i = 0; i <= (int)(S.size() - T.size()); i++) {
        int num = 0;
        for (int j = 0; j < (int)T.size(); j++) {
            if (T[j] != S[i + j]) {
                num++;
            }

        }
        if (ans > num) {
            ans = num;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3612
#include <stdio.h>
#include <string.h>
int min(int x, int y){return x<y?x:y;}
int main(void){
	int n,i,j,num[50][26]={0};
	char s[51];
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%s",s);
		for(j=0;j<strlen(s);j++){
			num[i][s[j]-97]++;
		}
	}
	int x;
	char cha = 'a';
	for(i=0;i<26;i++){
		x=50;
		for(j=0;j<n;j++){
			x = min(x,num[j][i]);
		}
		for(j=0;j<x;j++){
			printf("%c",cha);
		}
		cha++;
	}
	printf("\n");
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
typedef long long ll;
#define MOD 1000000007
using namespace std;
int main()
{
    ll n, l;
    cin >> n >> l;
    vector<ll> a(n);
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    vector<ll> ans;
    for (int i = 0; i < n; i++)
    {
        if (a[i] + a[i + 1] >= l)
        {
            ans.push_back(i);
            break;
        }
    }
    if (ans.empty())
    {
        cout << "Impossible" << endl;
        return 0;
    }
    cout << "Possible" << endl;
    int ind = ans[0];
    for (int i = ind + 1; i < n - 1; i++)
    {
        ans.push_back(i);
    }
    for (int i = ind - 1; i >= 0; i--)
    {
        ans.push_back(i);
    }
    for (int i = n - 2; i >= 0; i--)
    {
        cout << ans[i] + 1 << endl;
    }
}


Measured memory_bytes: 2548
N, Ma, Mb = map(int, input().split())
Items = [list(map(int, input().split())) for _ in range(N)]

# dp[i][a][b] := i番目の薬品までみて、タイプA: xグラム, タイプB: yグラム を手に入れるために必要な最小費用
dp = [[[float('inf')] * 401 for j in range(401)] for i in range(N + 1)]
dp[0][0][0] = 0
for i, (a, b, c) in enumerate(Items):
    for x in range(401):
        for y in range(401):
            dp[i + 1][x][y] = min(dp[i + 1][x][y], dp[i][x][y])
            if x + a > 400 or y + b > 400:
                continue
            dp[i + 1][x + a][y + b] = min(dp[i + 1][x + a][y + b], dp[i][x][y] + c)

ans = float('inf')
i = 1
while Ma * i <= 400 and Mb * i <= 400:
    ans = min(ans, dp[-1][Ma * i][Mb * i])
    i += 1
print(ans if ans != float('inf') else -1)


Measured memory_bytes: 143412
#include <iostream>
#include <algorithm>
#include <vector>
#include <tuple>
using namespace std;

int main(){
    int N;
    cin>>N;
    vector<int64_t> A(N);
    for(auto &a:A) cin>>a;
    int64_t dp[2][N];//0:+, 1:-
    dp[0][1]=A[0]+A[1];
    dp[1][1]=-dp[0][1];
    for(int i=1;i<N-1;i++){
        dp[0][i+1]=max(dp[0][i],dp[1][i])+A[i+1];
        dp[1][i+1]=max(dp[0][i]-2*A[i]-A[i+1],dp[1][i]+2*A[i]-A[i+1]);
    }
    cout<<max(dp[0][N-1],dp[1][N-1])<<endl;

    return 0;
}

Measured memory_bytes: 2688
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin>>s;
  bool ok = true;
  if(s.size()%2==0){
  for(int i=0;i<s.size();i++){
    if(i%2==0){
      if(s.at(i)!='h'){
        ok = false;
      }
    }
    else{
      if(s.at(i)!='i'){
        ok = false;
      }
    }
  }
  }
  else{
    ok = false;
  }
  if(ok){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
  return 0;
}

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


int main() {
  string s;
  cin>>s;
  int n=s.size();
  vector<vector<ll>> dp(n+5,vector<ll>(13));
  dp[0][0]=1;
  rep(i,n){
    int c;
    if (s[i]=='?')  c=-1;
    else c=s[i]-'0';

    rep(j,10){
      if (c!=-1 && c!=j)continue;
      rep(k,13){
        dp[i+1][(k*10+j)%13]+=dp[i][k];
        dp[i][k]=dp[i][k]%MOD;
      }
    }
    rep(j,13){dp[i+1][j]=dp[i+1][j]%MOD;}

}
ll ans=dp[n][5]%MOD;
cout<<ans;


    }


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

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

Measured memory_bytes: 256
#include <stdio.h>

int main(int argc, char **argv){
	int a,b,c;
	
	scanf("%d %d %d",&a, &b, &c);
	
	if( a < b && b < c){
		printf("Yes\n");
	} else {
		printf("No\n");
	}
	
	return 0;
}

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

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

int main() {
    ll N, ans = 0;
    cin >> N;
    vector<ll> a(N), b(N), c(N), d(N);
    rep(i, N) cin >> a[i];
    rep(i, N) cin >> b[i];
    sort(b.begin(), b.end());
    rep(k, 30) {
        ll t = (1<<k);
        rep(i, N) c[i] = a[i]%(2*t);
        rep(i, N) d[i] = b[i]%(2*t);
        sort(d.begin(), d.end());
        ll tmp = 0;
        rep(i, N) {
            tmp += lower_bound(d.begin(), d.end(), 2*t-c[i]) - lower_bound(d.begin(), d.end(), t-c[i]);
            tmp += lower_bound(d.begin(), d.end(), 4*t-c[i]) - lower_bound(d.begin(), d.end(), 3*t-c[i]);
        }
        if (tmp%2) ans += t;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 6528
package main

import "fmt"

func main() {
	var s, t string
	fmt.Scan(&s, &t)

	var max_match, temp_max_match int
	max_match = 0
	for i:=0; i <= len(s)-len(t); i++ {
		temp_max_match = 0
		for j:=0; j < len(t); j++ {
			if s[j+i] == t[j]{
				temp_max_match++
			}
		}
		if temp_max_match > max_match {
			max_match = temp_max_match
		}
	}
	fmt.Println(len(t)-max_match)
}


Measured memory_bytes: 1784
package main

import (
	"fmt"
	"math"
)

func main() {


	var A,B,C,X,Y int

	fmt.Scan(&A,&B,&C,&X,&Y)

	//ABを使わない
	min := A*X+B*Y

	//ABいくつ使うか
	for i:=1;i<=max(X,Y)*2;i++{

		sum :=  i*C

		Acnt := int(math.Ceil(float64(X-(i/2))))
		Bcnt := int(math.Ceil(float64(Y-(i/2))))

		if Acnt<0{

			Acnt=0
		}

		if Bcnt<0{

			Bcnt=0
		}

		sum += Acnt*A + Bcnt*B


		if min > sum{

			min = sum
		} 
	}


	fmt.Println(min)
}

//max 最大値を返す
func max(a, b int) int {

	if a > b {

		return a
	}

	return b
}

Measured memory_bytes: 512
#include<cstdio>

const int MAX_M = 50;

int N,M;
int a[MAX_M],b[MAX_M];
int cnt[MAX_M];

int main(){
	scanf("%d %d",&N,&M);
	for(int i=0;i<N;i++){
		cnt[i] = 0;
	}
	for(int i=0;i<M;i++){
		scanf("%d %d",&a[i],&b[i]);
		cnt[a[i]-1]++;
		cnt[b[i]-1]++;
	}
	
	for(int i=0;i<N;i++){
		printf("%d\n",cnt[i]);
	}
	
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>

using namespace std;

int main(){
    double W, H, x, y;
    cin >> W >> H >> x >> y;

    cout << W * H / 2 << " ";

    if (x == W / 2 && y == H / 2){
        cout << 1 << endl;
    }else{
        cout << 0 << endl;
    }
    

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int x,y;
	scanf("%d %d",&x,&y);
	if(y==0)
	{
		if(x<0)
			printf("%d\n",-x);
		else
			printf("%d\n",x+1);
	}
	else if(x==0)
	{
		if(y>0)
			printf("%d",y);
		else
			printf("%d\n",-y+1);
	}
	else if(y>0)
	{
		if(x>0 && x<y)
			printf("%d\n",y-x);
		else if(y<x)
			printf("%d\n",x-y+2);
		else if(-x<y)
			printf("%d\n",y+x+1);
		else
			printf("%d\n",-x-y+1);
	}
	else
	{
		if(x<y)
			printf("%d\n",y-x);
		else if(x<0)
			printf("%d\n",x-y+2);
		else if(x<-y)
			printf("%d\n",-y-x+1);
		else
			printf("%d\n",y+x+1);
	}
	return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner scanner = new Scanner(System.in);
       		String[] strStdIn = new String[1];
		int i = 0;
		while (i != 1) {
			strStdIn[i] = scanner.nextLine();
			i++;
		}

		String target = strStdIn[0];

		Main e = new Main();

		boolean judge = e.search(target);
		
		if (judge) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
    	}

	private boolean search(String target) {

		String[] alphabet = new String[] {"a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"};
		for (int i=0; i < 26; i++) {
			int count = 0;
			int s = 0;
			int index = 0;
			while (index != -1) {
        			index = target.indexOf(alphabet[i], s);
				s = (index + alphabet[i].length());
       				if (index != -1) {
					count++;
				}
    			}
			if (count % 2 != 0) {
				return false;
			}
		}
		return true;
	}
}

Measured memory_bytes: 9556
N, K = [int(s) for s in input().split()]
L = [int(s) for s in input().split()]

def main():
    comb = []
    for l in L:
        if len(comb) < K:        
            comb.append(l)
        elif l > min(comb):
            comb[comb.index(min(comb))] = l
    print(sum(comb))

if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
// AOJ 2354 Fractional Knapsack
// 2018.3.17 bal4u

#include <stdio.h>
#include <stdlib.h>
#include <math.h>

// library
//#define getchar_unlocked()  getchar()
int in()
{
	int n = 0, c = getchar_unlocked();
	if (c == '-') {	c = getchar_unlocked();
		do n = 10*n + (c & 0xf), c = getchar_unlocked(); while (c >= '0');
		return -n;
	}
	do n = 10*n + (c & 0xf), c = getchar_unlocked(); while (c >= '0');
	return n;
}
// library

#define ZERO(a)  (fabs(a)<1e-7)

typedef struct { int w, v; double r; } T;
T tbl[100002]; int sz;

int cmp(T *a, T *b) { if (fabs(b->r - a->r)<1e-8) return 0; if (a->r <= b->r) return 1; return -1; }

int main()
{
	int N, i, w, v;
	double W, x, ans;

	N = in(), W = in();
	sz = 0, ans = 0;
	while (N--) {
		w = in(), v = in();
		if (w >= 0 && v <= 0) continue;
		if (w < 0 && v > 0) ans += v, W -= w;
		else {
			if ( w < 0) w = -w, v = -v, ans -= v, W += w; 
			tbl[sz].w = w, tbl[sz].v = v, tbl[sz++].r = (double)v/w;
		} 
	}
	qsort(tbl, sz, sizeof(T), cmp);

	for (i = 0; i < sz && !ZERO(W); i++) {
		x = W/tbl[i].w;	if (x > 1) x = 1;
		W -= x*tbl[i].w, ans += x*tbl[i].v;
	}
	printf("%lf\n", ans);
	return 0;
}


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

using namespace std;
typedef long long ll;

int S(int n) {
	int ans = 0;
	while (n > 0) {
		ans += n % 10;
		n /= 10;
	}
	return ans;
}

int main(void) {
	int n, s;
	cin >> n;
	s = S(n);
	if (n % s == 0)
		printf("Yes\n");
	else
		printf("No\n");
	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)) {
			int n = sc.nextInt();

			if (n == 1) {
				System.out.println("Hello World");
				return;
			}
			int result = 0;
			result += sc.nextInt();
			result += sc.nextInt();
			System.out.println(result);
		}
	}
}


Measured memory_bytes: 22740