akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
using namespace std;
const int mod=1e9+7;
int m,yy[200005],loc[200005],nex[200005],cnt=1,fir[200005],vis[200005],ans[200005]; ll n;

int main()
{
    std::ios::sync_with_stdio(0); std::cin.tie(0);
	cin>>m>>n;
	for(int i=1;i<=m;++i)
	{
		cin>>yy[i];
		if(loc[yy[i]]) nex[loc[yy[i]]]=i;
		else fir[yy[i]]=i;
		loc[yy[i]]=i;
	}
	for(int i=1;i<=m;++i)
	{
		if(vis[i]!=0) continue;
		if(!nex[i]) vis[i]=i;
		else
		{
			int now=i;
			while(nex[now]) loc[++loc[0]]=now,now=nex[now]+1;
			if(now>m) now=-1; 
			for(int j=1;j<=loc[0];++j) vis[loc[j]]=now;
			loc[0]=0;
		}
	}
	int now=1;
	while(1)
	{
		ans[cnt++]=vis[now];
        now=fir[yy[vis[now]]]+1;
        if(vis[now]==-1||now>m) break; 
	}
	now=n%cnt;
	if(now!=0)
	{
		now=ans[now];
		while(now<=m)
		{
			if(!nex[now]) { cout<<yy[now]<<" "; now++;}
			else now=nex[now]+1;
		}
	}
	return 0;
}


Measured memory_bytes: 7936
def solve():
    N = int(input())
    As = list(map(int, input().split()))

    Bs = []

    for i in range(N):
        Bs.append(As[i]-i-1)

    Bs.sort()
    b = Bs[N//2]

    ans = 0

    for i in range(N):
        ans += abs(Bs[i]-b)

    print(ans)


# Solve
if __name__ == "__main__":
    solve()


Measured memory_bytes: 99668
#include <bits/stdc++.h>  // clang-format off
using Int = long long;
#define REP_(i, a_, b_, a, b, ...) for (Int i = (a), lim##i = (b); i < lim##i; i++)
#define REP(i, ...) REP_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
struct SetupIO { SetupIO() { std::cin.tie(nullptr), std::ios::sync_with_stdio(false), std::cout << std::fixed << std::setprecision(13); } } setup_io;
#ifndef dump
#define dump(...)
#endif  // clang-format on

/**
 *    author:  knshnb
 *    created: Sun Jun 14 18:27:55 JST 2020
 **/

signed main() {
    std::string s;
    std::cin >> s;
    Int n = s.size() + 1;
    std::vector<Int> a(n), b(n);
    REP(i, n - 1) {
        if (s[i] == '<') {
            a[i + 1] = a[i] + 1;
        }
    }
    for (Int i = n - 1 - 1; i >= 0; i--) {
        if (s[i] == '>') {
            b[i] = b[i + 1] + 1;
        }
    }
    Int ans = 0;
    REP(i, n) ans += std::max(a[i], b[i]);
    std::cout << ans << std::endl;
}


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

double x[10] = {0};
char  u[10][3] = {0};

int main()
{
	int n_person = 0;
	int i = 0;
	double sum = 0.0;
	scanf("%d", &n_person);
	for(i = 0; i < n_person; i++) {
		scanf("%lf %s", &x[i], &u[i][0]);
		if (u[i][0] == 'J') {
			sum += x[i];
		} else {
			sum += (x[i] * 380000.0);
		}
	}

	printf("%.4lf",sum);
	return 0;
}


Measured memory_bytes: 128
public class Main {
	public static void main(String args[]){
		System.out.println("1x1=1");System.out.println("1x2=2");System.out.println("1x3=3");System.out.println("1x4=4");System.out.println("1x5=5");
		System.out.println("1x6=6");System.out.println("1x7=7");System.out.println("1x8=8");System.out.println("1x9=9");

		System.out.println("2x1=2");System.out.println("2x2=4");System.out.println("2x3=6");System.out.println("2x4=8");System.out.println("2x5=10");
		System.out.println("2x6=12");System.out.println("2x7=14");System.out.println("2x8=16");System.out.println("2x9=18");

		System.out.println("3x1=3");System.out.println("3x2=6");System.out.println("3x3=9");System.out.println("3x4=12");System.out.println("3x5=15");
		System.out.println("3x6=18");System.out.println("3x7=21");System.out.println("3x8=24");System.out.println("3x9=27");

		System.out.println("4x1=4");System.out.println("4x2=8");System.out.println("4x3=12");System.out.println("4x4=16");System.out.println("4x5=20");
		System.out.println("4x6=24");System.out.println("4x7=28");System.out.println("4x8=32");System.out.println("4x9=36");

		System.out.println("5x1=5");System.out.println("5x2=10");System.out.println("5x3=15");System.out.println("5x4=20");System.out.println("5x5=25");
		System.out.println("5x6=30");System.out.println("5x7=35");System.out.println("5x8=40");System.out.println("5x9=45");

		System.out.println("6x1=6");System.out.println("6x2=12");System.out.println("6x3=18");System.out.println("6x4=24");System.out.println("6x5=30");
		System.out.println("6x6=36");System.out.println("6x7=42");System.out.println("6x8=48");System.out.println("6x9=54");

		System.out.println("7x1=7");System.out.println("7x2=14");System.out.println("7x3=21");System.out.println("7x4=28");System.out.println("7x5=35");
		System.out.println("7x6=42");System.out.println("7x7=49");System.out.println("7x8=56");System.out.println("7x9=63");

		System.out.println("8x1=8");System.out.println("8x2=16");System.out.println("8x3=24");System.out.println("8x4=32");System.out.println("8x5=40");
		System.out.println("8x6=48");System.out.println("8x7=56");System.out.println("8x8=64");System.out.println("8x9=72");

		System.out.println("9x1=9");System.out.println("9x2=18");System.out.println("9x3=27");System.out.println("9x4=36");System.out.println("9x5=45");
		System.out.println("9x6=54");System.out.println("9x7=63");System.out.println("9x8=72");System.out.println("9x9=81");
	}
}

Measured memory_bytes: 16824
#include<stdio.h>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
using namespace std;
int top,S[1000];

void push(int x){
 S[++top]=x;
}

int pop(){
 top--;
 return S[top+1];
}

int main(){
int v;
char n[100];
while (scanf("%s", n) != EOF){
  if (n[0] == '+'){
   push(pop() + pop());
  }else if (n[0] == '-'){
    int b=pop();
    int a=pop();
   push(a-b);
  }else if (n[0] == '*'){
   push(pop() * pop());
  }else {
   push(atoi(n));
  }
}
  printf("%d\n",pop());
  return 0;
}

Measured memory_bytes: 3216
#include<stdio.h>

int main(){
	int mise[5],i,j,s1,s2;
	while(~scanf("%d%d",&s1,&s2)){
		if(s1==0 && s2==0)break;
		mise[0]=s1+s2;
		j=0;
		for(i=0;i<4;i++){
			scanf("%d%d",&s1,&s2);
			if(s1+s2>mise[i]){
				mise[i+1]=s1+s2;
				j=i+1;
				continue;
			}
			mise[i+1]=mise[i];
		}
		printf("%c %d\n",'A'+j,mise[j]);
	}
	return 0;
}

Measured memory_bytes: 0
// Problem : B - Distance 
// Contest : AtCoder - AtCoder Beginner Contest 174
// URL : https://atcoder.jp/contests/abc174/tasks/abc174_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define int long long
#define db double
#define mod 1000000007
#define pb push_back
#define pp pair<int,int>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repe(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=b;i>=a;i--)
#define maxn 200005
#define ss second
#define ff first
#define all(a) a.begin(),a.end()
#define lb lower_bound
#define ub upper_bound
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
int inv(int a, int b){
 return 1<a ? b - inv(b%a,a)*b/a : 1;
}
void solve()
{
	int n;
	db d;
	cin >> n >> d;
	int cnt=0;
	rep(i,0,n)
	{
		int x,y;
		cin >> x >> y;
		db dis;
		dis = sqrt((db)x*x + (db)y*y);
		if(dis <= d)
		cnt++;
	}
	cout << cnt;
}
signed main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t=1;
    //cin >> t;
    while(t--)
    solve();
    return 0;
}


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

int dp[200001];
int a[100];
int n;
int k;
int level = 100000;

int main()
{
    ios::sync_with_stdio(false);
    cin >> n >> k;
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
        level = min(a[i], level);
    }
    for (int i = 0; i < 200001; i++)
    {
        dp[i] = -1;
    }

    for (int i = 0; i < level; i++)
        dp[i] = 0;

    for (int i = 0; i <= k; i++)
    {
        if (dp[i] == 0)
        {
            for (int j = 0; j < n; j++)
                dp[i + a[j]] = 1;
        }
        else if (dp[i] == -1)
        {
            int temp = 1;
            for (int j = 0; j < n; j++)
            {
                if (a[j] <= i)
                    temp &= dp[i - a[j]];
            }
            if (temp)
                dp[i] = 0;
            else
                dp[i] = 1;
            i--;
        }
    }
    if (dp[k])
        cout << "First" << endl;
    else
        cout << "Second" << endl;

    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  double A, B, H, M;
  cin >> A >> B >> H >> M;
  double Z;
  if (6 * M > 30 * H + 0.5 * M) {
    Z = 6 * M - 30 * H - 0.5 * M;
    if (Z > 180) {
      Z = 360 - Z; 
    }
  }
  if (6 * M < 30 * H + 0.5 * M) {
    Z = 30 * H + 0.5 * M - 6 * M;
    if (Z > 180) {
      Z = 360 - Z; 
    }
  }
  double pi = 3.141592653589793;
  double W = 180.0 / Z; 
  double Y = cos(pi/W);
  double X = A * A + B * B - 2 * A * B * Y;
  double Q = sqrt( X );
  cout << fixed << setprecision(16);
  cout << Q << endl;
}


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

using namespace std;

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

ll X[105];

int main() {
    ll N;
    cin >> N;
    REP(i, N) {
        cin >> X[i];
    }
    ll ans = INF;
    REP(i, 101) {
        ll m = 0;
        REP(j, N) {
            m += pow(X[j] - i, 2);
        }
        ans = std::min(ans, m);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
   int n, s, i, count=0, limit; 
   
   scanf("%d",&n);
   do{
       scanf("%d", &s);
       limit=(int)sqrt(s);
      for(i=limit; i>=2; i--){
          if(s%i==0) break;
      }
      if(i==1) count++;
      n=n-1;
   }while(n>0);
   printf("%d\n",count);
    
   return 0;
}



Measured memory_bytes: 2100
#include<algorithm>
#include <iostream>
#include<cstdio>
#include<cmath>
#include<iomanip>
#include<string>
using namespace std;
int main(){
   
    int n;
    cin>>n;
    
    if(n/10==9 || n%10==9){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
        
    return 0;
}






Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define FIND(s, e) ((s).find(e) != (s).end())
#define EB emplace_back

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

bool check(int n) {
    if (n < 10) return true;
    int now = n % 10;
    n /= 10;
    while (n) {
        int buf = n % 10;
        n /= 10;
        if (now - 1 != buf) return false;
        now = buf;
    }
    return true;
}

void solve(int N) {
    VI a(N);
    for_each(ALL(a), [](int &e){cin >> e;});
    int ans = -1;
    REP(i, N)REP(j, N) {
        if (i == j) continue;
        int buf = a[i] * a[j];
        if (check(buf)) ans = max(ans, buf);
    }
    cout << ans << endl;
    return;
}

signed main(void) {
    int n, m, p, a, b, c, x, y, z, q;
    string s;
    bool f = false;
    while (cin >> n, n) {
        solve(n);
        return 0;
    }
}

Measured memory_bytes: 3116
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;

using System.Collections;

class Program
{
    static void Main()
    {
        int[] nk = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
        int N = nk[0];
        int K = nk[1];

        double[] pList = new double[N + 1];

        for(int i = 1; i <= N; i++)
        {
            var p = 1 / (double)N;

            var val = i;

            while(val < K)
            {
                val *= 2;
                p /= 2;
            }

            pList[i] = p;
        }

        var ans = pList.OrderBy(p => p).Sum();

        Console.WriteLine(ans);
    }
    
}

Measured memory_bytes: 13920
#include<bits/stdc++.h>
using namespace std;
int main(void)
{
  string N;
  char c;
  cin>>N;
  c=N.at(N.size()-1);
  if(c=='3')return cout<<"bon"<<"\n",0;
  else if(c=='0'||c=='1'||c=='6'||c=='8')return cout<<"pon"<<"\n",0;
  else return cout<<"hon"<<"\n",0;
}

Measured memory_bytes: 3620
#ABC-142-C
N = int(input())
A = list(map(int, input().split()))
ans_dict = {}

for idx, item in enumerate(A):
    ans_dict[item] = idx+1
    
sorted_dict = sorted(ans_dict.items(), key = lambda x:x[0])

for i in sorted_dict:
    print(i[1], end = " ")

Measured memory_bytes: 25504
// clang-format off
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using pii = pair<int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
#define all(c) begin(c), end(c)
#define rall(c) rbegin(c), rend(c)
#define fore(x, c) for(auto &&x : c)
#define rep(i, a, n) for(int i = a, i##len = (int)(n); i < i##len; ++i)
#define rrep(i, a, n) for(int i = (int)(n - 1); i >= a; --i)
#define sz(c) ((int)c.size())
#define contains(c, x) (c.find(x) != end(c))
#define inseg(l, x, r) ((l) <= (x) && (x) < (r))
#define dump(...)
#define pb push_back
#define eb emplace_back
#define _ 0
const signed INF_ = 1001001001; const long long INF = 1001001001001001001LL;
const int DX[9] = {0,1,0,-1,1,1,-1,-1,0}, DY[9] = {-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os, const vector<T> &v) {
  for (auto i = begin(v); i != end(v); i++) os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is, vector<T> &v) {
  for (auto i = begin(v); i != end(v); i++) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
  is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a, const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a, const U &b){return a>b?a=b,1:0;}
template <class T> void psum(T& c) {partial_sum(begin(c), end(c), begin(c));}
template<class T> using heap = priority_queue<T, deque<T>, greater<T>>;
struct before_main_function {
  before_main_function() {
      cin.tie(nullptr); ios::sync_with_stdio(0);
      cout << setprecision(15) << fixed;
  }
} before_main_function;
// clang-format on
//------------------8<------------------------------------8<--------------------

signed main() {
  int N, K;
  cin >> N >> K;
  vi A(N);
  cin >> A;
  vi S = A;
  psum(S);

  dump(S);

  int ans = 0;
  map<int, int> cnt;
  vi lim(N, -1);
  cnt[1] = 1;
  if (-1 + K < N) lim[-1 + K] = 1;
  rep(i, 0, N) {
    dump(i);
    if (lim[i] != -1) {
      dump(lim[i]);
      cnt[lim[i]]--;
    }
    int x = (S[i] - i + K) % K;
    dump(x, cnt[x]);
    ans += cnt[x];
    cnt[x]++;
    if (i + K < N) lim[i + K] = x;
  }
  cout << ans << endl;
  return (0 ^ _ ^ 0);
}



Measured memory_bytes: 17408
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N = int(input())
As = list(mapint())

ALL = 0
for a in As:
    ALL ^= a
ans = [ALL^a for a in As]
print(*ans)

Measured memory_bytes: 114308
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <fstream>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <string>
#include <cstring>
#include <cctype>
#include <numeric>
#include <cstdio>
#include <math.h>
#include <functional>
using namespace std;
struct initon
{
    initon()
    {
        cin.tie(0);
        ios::sync_with_stdio(false);
    };
};
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvi = vector<vi>;
using vs = vector<string>;
using vl = vector<ll>;
using vvl = vector<vl>;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using vp = vector<P>;
using i8 = int8_t;
using u8 = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
using f80 = __float80;
constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for (i64 i = m; i < n; i++)
#define SORT(x) sort(x.begin(), x.end())
#define RS(x) rsort(x.begin(),x,end()))
#define REVE(x) reverse(x.begin(), x.end())
#define all(x) (x).begin(), (x).end()
#define fst first
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define pob pop_back
#define sw swap
#define UP(x) transform(x.begin(), x.end(), x.begin(), ::toupper);
#define LOW(x) transform(x.begin(), x.end(), x.begin(), ::tolower);
#define na(a, n) rep(i, n) cin >> a[i];
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}
vb d(10);
int ans(int x)
{
    while (x)
    {
        if (d[x % 10])
            return 0;
        x /= 10;
    }
    return 1;
}
//ここからメイン
int main()
{
 ll a,b;
  cin >> a>>b;
  cout << (a-1)*(b-1);
    }

Measured memory_bytes: 256
require 'prime'
require 'set'
require 'tsort'
include Math
ALP = ('a'..'z').to_a
INF = 0xffffffffffffffff
def max(a,b);              a > b ? a : b                              end
def min(a,b);              a < b ?  a : b                             end
def swap(a,b);             a, b = b, a                                end
def gif;                   gets.to_i                                  end
def gff;                   gets.to_f                                  end
def gsf;                   gets.chomp                                 end
def gi;                    gets.split.map(&:to_i)                     end
def gf;                    gets.split.map(&:to_f)                     end
def gs;                    gets.chomp.split.map(&:to_s)               end
def gc;                    gets.chomp.split('')                       end
def pr(num);               num.prime_division                         end
def pr?(num);              Prime.prime?(num)                          end
def digit(num);            num.to_s.length                            end
def array(s,ini=nil);      Array.new(s){ini}                          end
def darray(s1,s2,ini=nil); Array.new(s1){Array.new(s2){ini}}          end
def rep(num);              num.times{|i|yield(i)}                     end
def repl(st,en,n=1);       st.step(en,n){|i|yield(i)}                 end
 x = gif
 puts x % (eval(x.to_s.split('').join('+'))) == 0 ? 'Yes' : 'No'


Measured memory_bytes: 2300
#include <stdio.h>
int main(void) {
	int i, n, d, a;
	scanf("%d", &n);
	scanf("%d", &d);
	a = (d * 2) + 1;
	for (i = 1; i <= n; i++) {
		if (n <= (i * a)) {
			break;
		}
	}
	printf("%d", i);
	return 0;
}

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

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

Measured memory_bytes: 3552
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <numeric>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i, start, end) for(int i = start; i < end; i++)
#define all(x) (x).begin(), (x).end()
#define debug(x) cout << (x) << endl;
typedef long long ll;
const int MAX = 999999999;

int main(){
    int n;
    cin >> n;
    vector<string> blue_words(n);
    rep(i, n) cin >> blue_words[i];

    int m;
    cin >> m;
    vector<string> red_words(m);
    rep(i, m) cin >> red_words[i];

    vector<int> scores(blue_words.size());
    rep(i, blue_words.size()){
        scores[i] = count(all(blue_words), blue_words[i]) - count(all(red_words), blue_words[i]);
    }

    cout << max(0, *max_element(all(scores))) << endl;
}

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

int main(){
	int N;
	int X;
	int L[110];
	int D[110];
	
	cin >> N;
	cin >> X;
	for(int i=1;i<=N;i++){
		cin >> L[i];
	}
	
	int ans=1;
	D[1]=0;
	for(int i=2;i<=N+1;i++){
		D[i]=D[i-1]+L[i-1];
		if(D[i]>X)break;
		ans++;
	}
	
	cout << ans << endl;
	return 0;
}

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

int main()
{
    int N; cin>>N;
    vector<int> h(N);
    for(int i=0;i<N;i++) cin>>h[i];

    h[0]--;
    for(int i=1;i<N;i++){
        if(h[i-1]>h[i]){
            cout<<"No"<<endl;
            return 0;
        }
        assert(h[i]>=h[i-1]);
        if(h[i]-h[i-1]>=1){
            h[i]--;
        }
    }
    cout<<"Yes"<<endl;
    return 0;
}

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

template<typename T, typename U>
using pv=vector<pair<T,U>>;
template<typename T>
using pque=priority_queue<T>;
template<typename T>
using lpque=priority_queue<T,vector<T>,greater<T>>;

using ll=long long;
using intpair=pair<int,int>;
using llpair=pair<ll,ll>;
using ilpair=pair<int,ll>;
using lipair=pair<ll,int>;
using intvec=vector<int>;
using llvec=vector<ll>;
using intq=queue<int>;
using llq=queue<ll>;
using intmat=vector<intvec>;
using llmat=vector<llvec>;

#define PI 3.141592653589793
#define INTINF ((1<<30)-1)
#define LLINF ((1LL<<62)-1)
#define MPRIME 1000000007
#define MPRIME9 998244353
#define MMPRIME ((1ll<<61)-1)

#define len length()
#define pushb push_back
#define fi first
#define se second

#define setpr fixed<<setprecision(15)
#define all(name) name.begin(),name.end()
#define rall(name) name.rbegin(),name.rend()
#define gsort(vbeg,vend) sort(vbeg,vend,greater<>())

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;
}

template<class T>
inline void init(T& v) {
	for(auto &a: v) cin>>a;
}
template<class T, class U>
inline void init(vector<pair<T,U>>& v) {
	for(auto &a: v) cin>>a.first>>a.second;
}
template<class T, class N>
inline void init(T& v, N n) {
	v.resize(n);
	for(auto &a: v) cin>>a;
}
template<class T, class U, class N>
inline void init(vector<pair<T,U>>& v, N n) {
	v.resize(n);
	for(auto &a: v) cin>>a.first>>a.second;
}

inline void out() {
	cout<<endl;
}
template<class T, class... U>
inline void out(T a, U... alist) {
	cout<<a<<" ";
	out(forward<U>(alist)...);
}

template<class N>
void resiz(N n) {
	//empty
}
template<class N, class T, class... U>
void resiz(N n, T&& hd, U&&... tl) {
	hd.resize(n);
	resiz(n,forward<U>(tl)...);
}

bool isout(int h, int w, int H, int W) {
	return ( h<0 || h>=H || w<0 || w>=W );
}

ll binpow(ll a, ll ex, ll p) {
	ll result=1;
	while(ex>0) {
		if(ex&1) result=result*a%p;
		ex>>=1;
		a=a*a%p;
	}
	return result;
}


int N;
llvec ans;

void input() {
	cin>>N;
	ans.resize(N+1,0);
}

void solve() {
	ans[3]=1;
	for(int n=4; n<=N; n++) {
		ans[n]=1;
		for(int d=n-3; d>=3; d--) {
			ans[n] += ans[d];
			ans[n] %= MPRIME;
		}
	}

	cout<<ans[N]<<endl;
}

int main() {
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout<<fixed<<setprecision(15);
	int t=1;
	while(t) {
		input();
		solve();
		t--;
	}
}


Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld double
#define ff first
#define ss second
int main(){
	int n,k,x,y;
	scanf("%d%d%d%d",&n,&k,&x,&y);
	if(n<=k){
		printf("%d\n",n*x);
	}
	else printf("%d\n",k*x+(n-k)*y);
	return 0;
}


Measured memory_bytes: 3620
def main():
    word = input()

    cnt = 0
    while True:
        text = input()
        text = text.strip()
        if text == "END_OF_TEXT":
            break

        for t in text.split():
            if t.lower() == word:
                cnt += 1


    print(cnt)


if __name__ == '__main__':
    main()


Measured memory_bytes: 5556
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
#include <map>
#include <unordered_map>
#include <chrono>
#include <numeric>
using namespace std;
using ll = long long;
const ll INF = (ll)1e18+1;
const ll DIV = 1000000007;
//#define TEST
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
#ifdef TEST
    chrono::system_clock::time_point start, end;
    start = chrono::system_clock::now();
#endif
    ll N;
    cin >> N;
    vector<bitset<30>> a(N);
    ll A;
    vector<ll> bits(30);
    for(size_t i=0;i<N; i++)
    {
        cin >> A;
        a[i] = bitset<30>(A);
        for(ll b=29;b>=0; b--)
        {
            bits[b]+=a[i][b];
        }
    }
    ll count = 0;
    //while(pow(2, count) < pow(10, 9)) count++;
    //cerr << count << ":" << pow(2,count) << endl;
    for(auto i:a) cerr << i << endl;
    for(ll i=29;i>=0; i--)
    {
        cerr << bits[i];
    }
    cerr << endl;
    for(size_t i=0;i<N; i++)
    {
        string bit = "000000000000000000000000000000";
        for(ll b=29;b>=0; b--)
        {
            if(bits[b] % 2 == 0)
            {
                if(a[i][b]) bit[29 - b] = '1';
            }
            else
            {
                if(!a[i][b]) bit[29 - b] = '1';
            }
        }
        //cerr << bit << endl;
        cout << bitset<30>(bit).to_ullong() << " ";
    }
    cout << endl;
    //std::bitset<8> bs("00000011");
    //std::bitset<8> bs2("00000101");
    //cout << (bs^bs2).to_ullong() << endl;
    // 1の数が偶数回(0)でるか奇数回(1)かで値が変わる
#ifdef TEST
    end = chrono::system_clock::now();
    cerr << static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count() / 1000.0) << "[ms]" << endl;
#endif
    return 0;
}

Measured memory_bytes: 10372
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,a,b;
	cin>>n>>a>>b;
	cout<<min(a,b)<<' ';
	if(a+b<=n)
	    cout<<0<<endl;
	else
	   cout<<(a+b-n)<<endl;
	return 0;
}

Measured memory_bytes: 256
N=int(input())
AB=[[0 for i in range(2)] for j in range(N)]
for i in range(N):
    AB[i][0],AB[i][1]=map(int, input().split())
AB=sorted(AB, key=lambda x: x[1])
time=0
for i in range(N):
    time+=AB[i][0]
    if time>AB[i][1]:
        print("No")
        exit()
print("Yes")

Measured memory_bytes: 42776
#include <iostream>
#include <cmath>
#include <cstdio>
#include <bits/stdc++.h>
typedef long long int ll;
using namespace std;
int main(){
    ll a,b,c;
    cin>>a>>b>>c;
    if(b>a*c){
        cout<<c<<endl;
    }else{
        cout<<b/a<<endl;
    }
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>

int n, k, a[10];

bool ok(int x){
    while(x){
		if(a[x%10])	return 0;
		x/=10;
    }
    return 1;
}

int solve(){
	for(int i=n; ;i++){
		if(ok(i)){
			return i;
		}
	}
}

int main(){
	int x;
	while(~scanf("%d %d", &n, &k)){
		memset(a, 0, sizeof(a));
        while(k--){
			scanf("%d", &x);
			a[x] = 1;
        }
        printf("%d\n", solve());
	}
	return 0;
}


Measured memory_bytes: 128
n, k = gets.chomp.split(' ').map(&:to_i)

sum = (1..n).inject(0) do |s, i|
  if i < k
    s + (1r / n) * (1r / 2r) ** Math.log2(k.to_f / i).ceil
  else
    s + (1r / n)
  end
end

puts sum.to_f


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

int X;
using namespace std;
int getClosestGauss(int X) {
    int i;
    for (i = 0; i* (i + 1)/2 < X; i++) {
    }
    return i;
}
int main() {
    cin >> X;
    cout << getClosestGauss(X);
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
 
using namespace std;
 
int n, a[200020], w[1000010], in[1000010];
int MOD = 998244353;
vector<int> num[1000010];
vector<int> List[1000010];
 
int addMod(int x, int y) {
    return ((x + y) >= MOD ? x + y - MOD : x + y);
}
 
int subMod(int x, int y) {
    return ((x - y) < 0 ? x - y + MOD : x - y);
}
 
int mulMod(int x, int y) {
    return (int) (((long) x * y) % MOD);
}
 
int powMod(int x, long p) {
    if (p == 0) return 1;
    int t = powMod(x, p / 2);
    if ((p & 1) == 1)
        return mulMod(mulMod(t, t), x);
    return mulMod(t, t);
}
 
int inv(int x) {
    return powMod(x, MOD - 2);
}
 
int cal(vector<int> v) {
    int res = 0;
    int sum[v.size() + 1];
    sum[0] = 0;
    for (int i = 1; i <= v.size(); i++){
        sum[i] = 0;
        sum[i] = addMod(sum[i - 1], v[i - 1]);
    }
    for (int i = 1; i <= v.size(); i++)
        res = addMod(res, mulMod(v[i - 1], subMod(sum[v.size()], sum[i])));
    return res;
}
 
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cin >> n;
    in[1] = 1;
    for (int i = 2; i <= 1000000; i++) {
        in[i] = mulMod((MOD - MOD / i), in[MOD % i]);
    }

    for(int i = 1; i <= n; i++) 
        cin >> a[i];
    
    for(int i = 1; i <= n; i++) {
        for(int j = 1; j * j <= a[i]; j++) {
            if(a[i] % j == 0) {
                num[j].push_back(a[i]);
                if(a[i]/j != j){
                    num[a[i]/j].push_back(a[i]);
                }           
            }
        }
    }
    for (int i = 1; i <= 1000; i++)
        for (int j = i * i; j <= 1000000; j += i) {
            List[j].push_back(i);
        }

    w[1] = 1;
    for (int i = 2; i <= 1000000; i++) {
        int sum = 0;
        for (int j : List[i]) {
            sum = addMod(sum, w[j]);
            if (i / j != j) {
                sum = addMod(sum, w[i / j]);
            }
        }
        w[i] = subMod(in[i], sum);
    }
  
    
    int ans = 0;
    for(int i = 1; i <= 1000000; i++) if(num[i].size() != 0){
        ans = addMod(ans, mulMod(w[i], cal(num[i])));
    }
    cout << ans << "\n";
}   

Measured memory_bytes: 156388
import std.stdio, std.conv, std.string, std.range, std.array, std.algorithm;
import std.bigint;

int dp[45];

void main()
{
  int n = readln().chomp().to!int;
  dp[0 .. 45] = -1;
  writeln(fibo(n));
}

int fibo(int n)
{
  if (dp[n] != -1) return (dp[n]);
  if (n == 0 || n == 1) return (1);
  return (dp[n] = fibo(n - 1) + fibo(n - 2));
}

Measured memory_bytes: 2496
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
 
#define mod 1000000007
#define FOR(x,to) for(int x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define long long long
inline int rei(){int x;cin>>x;return x;}
inline long rel(){long x;cin>>x;return x;}
inline string res(){string x;cin>>x;return x;}
//------------------------------------------------------- 
double DP[301*301*301];
int A[4];
void Calc(){
	int N = rei();
	for(int i=0;i<N;i++){
		int a = rei();
		A[a]++;
	}
	DP[0] = 0;
	for(int a=0;a<=300;a++){
		for(int b=0;b<=300;b++){
			for(int c=0;c<=300;c++){
				if(a+b+c > 0){
					double ans = N;
					if(a != 0 && b != 300){
						ans += DP[(a-1)*301*301+(b+1)*301+c] * a;
					}
					if(b != 0 && c != 300){
						ans += DP[a*301*301+(b-1)*301+c+1] * b;
					}
					if(c != 0){
						ans += DP[a*301*301+b*301+c-1] * c;
					}
					DP[a*301*301+b*301+c] = ans / (a+b+c);
				}
			}	
		}	
	}
	printf("%1.10lf\n",DP[A[3]*301*301+A[2]*301+A[1]]);
}
int main(int argc,char** argv){
	ios::sync_with_stdio(false), cin.tie(0);
	cout.tie(0); Calc(); return 0;
}

Measured memory_bytes: 213376
def main():
    import sys
    input = sys.stdin.readline
    N, M = map(int, input().split())
    C = [list(map(int, input().split())) for i in range(N)]
    C = sorted(C)
    s = 0
    ans = 0
    
    for i in range(N):
        if s == M:
            break
        ans += C[i][0] * min(M-s,C[i][1])
        s += min(M-s,C[i][1])

    print(ans)
    
    
main()

Measured memory_bytes: 57180
#include<stdio.h>

int main(void) {
	int X, Y;
	int m = 0;
	scanf("%d%d", &X, &Y);
	if (X == 1)
		m += 300000;
	if (X == 2)
		m += 200000;
	if (X == 3)
		m += 100000;
	if (Y == 1)
		m += 300000;
	if (Y == 2)
		m += 200000;
	if (Y == 3)
		m += 100000;
	if (X == 1 && Y == 1)
		m += 400000;
	printf("%d\n", m);
	return 0;
}

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

int N;
int A[100000];

signed main()
{
	cin >> N;
	rep(i,N) cin >> A[i];

	int ans = 0;
	rep(i,N) {
		if (i != 0 && A[i-1] == 1 && A[i] >= 1) {
			ans++;
			A[i]--;
		}
		if (A[i] >= 2) {
			ans += A[i] / 2;
			A[i] %= 2;
		}
	}

	cout << ans << endl;
}


Measured memory_bytes: 1024
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
    
		// 文字列の入力
		String a = sc.next();
        String b = sc.next();
        String ans = "";
        if (a.equals("H")) {
          ans = b;
        } else {
          ans = b.equals("H") ? "D" : "H"; 
        }
    
		// 出力
		System.out.println(ans);
	}
}


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

long long l[87];

int main() {
    int N;
    cin >> N;
    l[0] = 2; l[1] = 1;
    for (int i=0; i<86; i++){
        l[i+2] = l[i+1] + l[i];
    }
    cout << l[N] << endl;
}

Measured memory_bytes: 256
import java.util.*;


public class Main {
	int n;
	boolean [][]  pass;
	int ans;
	int [] low, pre;
	int ind;
	
	private void dfs(int now,int prev){
//		debug(now, prev);
		pre[now] = ind;
		low[now] = ind;
		ind++;
		
		
		for(int i = 0; i < n; i++){
			if(i == prev) continue;
			if(pass[now][i] == false) continue;
			
			if(pre[i] != -1){
				low[now] = Math.min(low[now], low[i]);
				continue;
			};

			dfs(i, now);
			low[now] = Math.min(low[now], low[i]);
			if(pre[i] == low[i]){
				ans++;
			}
		}
	}
	
	
	private void doit(){
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){
			n = sc.nextInt();
			int m = sc.nextInt();
			pass = new boolean[n][n];
			for(int i = 0; i < m; i++){
				int a = sc.nextInt()-1;
				int b = sc.nextInt()-1;
				pass[a][b] = true;
				pass[b][a] = true;
			}
			ans = 0;
			ind = 1;
			low = new int[n];
			pre = new int[n];
			Arrays.fill(pre, -1);
			pre[0] = 0;
			low[0] = 0;
			
			dfs(0, -1);
			
			System.out.println(ans);
		}
	}



	private void debug(Object... o) {
		System.out.println("debug = " + Arrays.deepToString(o));
	}

	public static void main(String[] args) {
		new Main().doit();
	}

}


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

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> broken(n+1);
  vector<long long int> dp(n+2);

  for (int i = 0; i < m; i++) {
    int j = 0;
    cin >> j;
    broken[j] = 1;
  }
  
  dp[n] = 1;
  for (int i = n-1; i >= 0; i--) {
    if (broken[i]) {
      dp[i] = 0;
      continue;
    }
    dp[i] = (dp[i+2] + dp[i+1]) % 1000000007;
  }
  cout << dp[0] << endl;
  return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long int
ll solution(ll n) 
{
    ll count = 0; 
    for (ll i = 5; n / i >= 1; i *= 5) {
      ll temp = n/i;
      count += (temp/2); 
      //cout << "n and i : " << n << " " << i << " " << temp << '\n';
    }
    return count; 
} 
int main()
{
	SPEED
	ll n;
	cin >> n;
	if (n&1)			//if n is odd there will be no trailing 0s
	{
		cout << 0;
	}
	else if (n<10)
	{
		cout << 0;
	}
	else
	{
		cout << solution(n);
	}
	return 0;
}


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

const int MAXN = 3e3 + 3;
double p[MAXN], dp[MAXN][MAXN];
int n;

void input();
void solve();

int main() {
	ios:: sync_with_stdio(0), cin.tie(0), cout.tie(0);
	input();
	solve();
	return 0;
}

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

void solve() {
	dp[0][0] = 1;
	for (int i = 1; i <= n; i++)
		for (int j = 0; j <= i; j++) {
			if (j == 0)
				dp[i][j] = dp[i - 1][j] * (1.0 - p[i - 1]);
			else
				dp[i][j] = (dp[i - 1][j] * (1.0 - p[i - 1])) + (dp[i - 1][j - 1] * p[i - 1]);
		}
	double ans = 0.0;
	for (int i = (n + 1) / 2; i <= n; i++)
		ans += dp[n][i];
	cout.precision(10);
	cout << ans << endl;
}


Measured memory_bytes: 68992
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder.Abc
{
    class QuestionC
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            // 整数の入力
            var n = long.Parse(Console.ReadLine());

            // 整数配列の入力
            var a = Console.ReadLine().Split(' ').Select(q => long.Parse(q)).ToArray();

            string result = "YES";

            var numG = 0;
            var numK = 0;

            for(int i = 0; i < n; i++) {
                if(a[i] % 2 == 0) {
                    numG++;
                } else {
                    numK++;
                }
            }

            if(numK % 2 == 1) {
                result = "NO";
            }

            Console.WriteLine(result);

            Console.Out.Flush();
        }
    }
}


Measured memory_bytes: 22880
#include <iostream>
#include <math.h>
#include <string>
#include <vector>
#include <algorithm>


using namespace std;

typedef long long ll;

int main(int argc, char const *argv[])
{
    ll n, k;
    cin >> n >> k;
    vector<ll> h(n,0);
    for (int i = 0; i < n; ++i) scanf("%lld", &h[i]);

    sort(h.begin(), h.end(), std::greater<ll>());

    ll sum = 0;

    for (ll i = k; i < n; i++)
    {
        sum += h[i];
    }

    cout << sum << endl;
    

    return 0;
}


Measured memory_bytes: 4704
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		String t = sc.next();
		int a = sc.nextInt();
		int b = sc.nextInt();
		String u = sc.next();

		if (u.equals(s)) {
			System.out.println(a - 1 + " " + b);
		} else {
			int b1 = b - 1;
			System.out.println(a + " " + b1);
		}
	}
}

Measured memory_bytes: 23764
import sys
import collections

n, m = map(int, sys.stdin.readline().split())
p = list(range(n))
r = [1] * n


def li_(): return [int(x)-1 for x in sys.stdin.readline().split()]


def find(x):
    global p
    if p[x] != x:
        p[x] = find(p[x])
    return p[x]


def union(x, y):
    x, y = find(x), find(y)
    if y > x:
        x, y = y, x
    p[y] = x
    r[x] += r[y]
    r[y] = r[x]


flist = [0] * m
elist = [0] * m
for i in range(m):
    flist[i], elist[i] = li_()

flist.reverse()
elist.reverse()

ans = [0] * m
ans[-1] = int(n*(n-1)/2)

for i in range(m-1):
    a, b = flist[i], elist[i]
    if find(a) != find(b):
        ans[-i-2] = ans[-i-1] - r[find(a)]*r[find(b)]
        union(a, b)
    else:
        ans[-i-2] = ans[-i-1]
    if ans[-i-2] == 0:
        break

for i in range(m):
    print(ans[i])


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

int main (){

    int a, b, c, d, e;

    cin >> a >> b >> c >> d >> e;

   if (a == 0){
    cout << 1 << endl;
   } else if (b == 0){
    cout << 2 << endl;
   } else if (c == 0){
    cout << 3 << endl;
   } else if (d == 0){
    cout << 4 << endl;
   } else if (e == 0){
    cout << 5 << endl;
   } else {
    cout << 0 << endl;
   }
}


Measured memory_bytes: 3628
N, M = map(int, input().split())
items = []
for i in range(M):
    p, y = map(int, input().split())
    items.append((p, y, i))

items = sorted(items, key=lambda x:(x[0], x[1]))

ans = {}

ken = -1
cnt = 1
for item in items:
    if item[0] != ken:
        cnt = 1
        ans[item[2]] = str(item[0]).zfill(6) + str(cnt).zfill(6)
        ken = item[0]
    else:
        cnt += 1
        ans[item[2]] = str(item[0]).zfill(6) + str(cnt).zfill(6)

for i in range(M):
    print(ans[i])


Measured memory_bytes: 36180
#include <bits/stdc++.h>
using namespace std;
 
#define read(num) scanf("%d", &num)
#define readll(num) scanf("%lld", &num)
#define read2(num1, num2) scanf("%d%d", &num1, &num2)
#define read3(num1, num2, num3) scanf("%d%d%d", &num1, &num2, &num3)
#define reads(str) scanf("%s", str)
#define readc(ch) scanf("%c", &ch)
#define f first
#define se second
#define M 1000000007
#define pb push_back
#define mp make_pair
#define pii pair<long long, long long>
#define vi vector<int>
#define ll long long

vector<pair<pair<ll,ll>,ll>>seg;
int inf=1e9;

pair<pair<ll,ll>,ll> find(int st,int l,int r,int l1,int r1){
    if(l1>r||r1<l){
        return mp(mp(0,0),0);
    }
    if(l1<=l&&r1>=r){
        return seg[st];
    }
    if(l==r){
        //cout<<seg[st].first.second<<" "<<seg[st].first.first<<" "<<seg[st].second<<endl;
        return seg[st];
        
    }
    
    int mid=(l+r)/2;
    pair<pair<ll,ll>,ll> v1=find(st*2,l,mid,l1,r1);
    pair<pair<ll,ll>,ll> v2=find(st*2+1,mid+1,r,l1,r1);
    ll k=min(v1.first.first,v2.first.second);
    v1.second=v2.second+v1.second+2*k;
    v1.first.first=v1.first.first+v2.first.first-k;
    v1.first.second=v1.first.second+v2.first.second-k;
    //cout<<v1.second<<" "<<l<<" "<<r<<endl;
    return v1;

}
void update(int st,int pos,int l,int r,char val){
    if(l==r){
        if(val=='('){
            seg[st].first.first=1;
        }else {
            seg[st].first.second=1;
        }
        
        return;
    }
    int mid=(l+r)/2;
    if(pos<=mid){
        update(st*2,pos,l,mid,val);
        
    }else {
        update(st*2+1,pos,mid+1,r,val);
        //seg[st]=min(seg[st*2+1],seg[st*2+2]);
    }
    ll k=min(seg[st*2].first.first,seg[st*2+1].first.second);
    seg[st].second=seg[st*2].second+seg[st*2+1].second+2*k;
    seg[st].first.first=seg[st*2].first.first+seg[st*2+1].first.first-k;
    seg[st].first.second=seg[st*2].first.second+seg[st*2+1].first.second-k;
}


int main(){
  ll n;
  cin>>n;
  ll ans=0;
  for(int i=1;i<=n;i++){
      for(int j=1;j<=n;j++){
          for(int k=1;k<=n;k++){

              ans+=__gcd(i,__gcd(j,k));
          }
      }
  }
  cout<<ans;
} 


Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <ctype.h>
#include <map>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <cctype>
#include <queue>
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define REP1(j,n) for(int j=0;j<(int)n;++j)
#define REPD(i,n) for(int i=n;i>=0;--i)
#define REPD1(j,n) for(int j=n;j=>0;--j)
#define REPS(i,n) for(int i=1;i<=(int)n;++i)
#define REPS1(j,n) for(int j=1;j<=(int)n;++j)
#define rep(i,a,n) for(int i=a;i<=(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define DescSort(a) sort(a.begin(),a.end(),std::greater<int>())

using namespace std;
typedef long long ll;
const ll INF=1e9+7;

int main(void) {
	int a, b;
	char op;
	cin >> a >> op >> b;
	if (op == '+')cout << a + b << endl;
	else cout << a - b << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <sstream>
#include <vector>
#include <math.h>
#include <cstdlib>
#include <cctype>
#include <random>

using namespace std;

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

  int min_abs = 10000;
  for (int i=0; i<n; i++) {
    int sum_l=0;
    int sum_r=0;

    for (int j=0; j<i+1; j++) {
      sum_l += w[j];
    }
    for (int j=n-1; j>i; j--) {
      sum_r += w[j];
    }

    min_abs = min(min_abs, abs(sum_l - sum_r));
  }

  cout << min_abs << endl;


  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ;
#endif

#define EPS (1e-10)
#define equals(a,b) (fabs((a)-(b)) < EPS)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

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

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,K,Q; cin >> N >> K >> Q;
    int cnt[112345] = {};
    REP(i,Q){
        int a; cin >> a;
        cnt[a]++;
    }
    FOR(i,1,N+1){
        if(K-Q+cnt[i] > 0){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }

}


Measured memory_bytes: 1152
MAX_PRIME = 10**5 + 10
is_prime = [1] * MAX_PRIME
primes = []
is_prime[0] = 0
is_prime[1] = 0
for i in range(MAX_PRIME):
    if is_prime[i]:
        primes.append(i)
        for j in range(2, ((MAX_PRIME-1)//i) + 1):
            is_prime[i*j] = 0

def factorization(n):
    factor = {}
    for p in primes:
        if p ** 2 > n:
            break
        while n % p == 0:
            n //= p
            if p not in factor:
                factor[p] = 1
            else:
                factor[p] += 1
    if n > 1:
        factor[n] = 1
    return factor

n = int(input())

f = factorization(n)

def F(a, b):
    return max(len(str(a)), len(str(b)))

k = sorted(list(f.keys()))
def dfs(num, i):
    if i < len(k):
        m = 10 ** 18
        p = k[i]
        for j in range(f[p]+1):
            m = min(m, dfs(num * p ** j, i+1))
        return m
    return F(num, n // num)

print(dfs(1, 0))

Measured memory_bytes: 4192
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007

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

    if(N <= K) cout << 0 << endl;
    else{
        vector<int> H(N);
        for(int i = 0; i < N; i++) cin >> H.at(i);

        sort(H.begin(), H.end());
    
        int64_t sum=0;
        for(int i = 0; i < N-K; i++) sum += H.at(i);

        cout << sum << endl;
    }
}


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

const int MaxN = 1e5 + 15;
const int MOD = 1e9 + 7;

long long L[100];
int n;

int main()
{
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdou);

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

    L[0] = 2;
    L[1] = 1;

    cin >> n;

    for(int i = 2; i <= n; ++i)
        L[i] = L[i - 1] + L[i - 2];
    cout << L[n] << '\n';
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
const int INF = 1001001001;
int main() {
	int H,N;
	cin >> H>>N;
	//vector<vector<int>> DP0(K + 1, vector<int>(N.size())); 
	//DP0[0][0] = 1; 
	vector<int> DP(H + 1,INF);
	DP[0] = 0;
	for (int n = 0;n < N;++n) {
		int a, b;
		cin >> a >> b;
		for (int m = 0; m < H; ++m) {
			int nj = min(m + a, H);
			DP[nj] = min(DP[nj], DP[m] + b);
		}
	}
	cout << DP[H]<< endl;
	return 0;
}

Measured memory_bytes: 3664