akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;

#define ul unsigned long int
#define ull unsigned long long
#define li long long int

int main()
{
  int n,m,l;
  cin >> n>>m>>l;
  ull m1[100][100], m2[100][100],m3[100][100];

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

  for (int i = 0; i < m; i++)
  {
    for (int j = 0; j < l; j++)
    {
      cin >> m2[i][j];
    }
  }

  for (int i = 0; i < n; i++)
  {
    for (int j = 0; j < l; j++)
    {
      m3[i][j]=0;
      for (int k=0;k<m;k++) m3[i][j]+=m1[i][k]*m2[k][j];
    }
  }

  for (int i = 0; i < n; i++)
  {
    for (int j = 0; j < (l-1); j++)
    {
        cout << m3[i][j] << " ";
    }
    cout << m3[i][l-1] << endl;
  }
  return 0;
}



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

using namespace std;

typedef long long LL;
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)

int main(){
	int N; cin >> N;
	vector<LL> D(N),dp(N,0);
	vector<int> s(N),sz(N,1),p(N,-1);
	map<LL,int> M;
	repp(i,0,N){
		cin >> D[i];
		M[D[i]] = i;
		s[i] = i;
	}
	sort(s.begin(),s.end(),[&](const int &i, const int &j){return D[i] > D[j];});
	repp(i,0,N-1){
		auto it = M.find(D[s[i]]-N+2+(sz[s[i]]-1)*2);
		if(it == M.end() || (*it).first >= D[s[i]]) return cout << -1 << endl, 0;
		p[s[i]] = (*it).second;
		dp[(*it).second] += sz[s[i]]+dp[s[i]];
		sz[(*it).second] += sz[s[i]];
	}
	if(D[s[N-1]] != dp[s[N-1]]) return cout << -1 << endl, 0;
	repp(i,0,N-1) cout << s[i]+1 << ' ' << p[s[i]]+1 << endl;
	return 0;
}


Measured memory_bytes: 12160
using System;
namespace Volume0_0000 {
    class Program {
        static void Main(string[] args) {
            for (int i = 1; i < 10; i++) {
                for (int j = 1; j < 10; j++) {
                    Console.WriteLine(i + "x" + j + "=" + (i * j).ToString());
                }
            }
        }
    }
}


Measured memory_bytes: 13704
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
using namespace std;

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

	if (a >= 3200)
	{
		cout << s;
	}
	else
	{
		cout << "red";
	}
	cout << endl;

	return 0;
}

Measured memory_bytes: 256
N,A,B,C = map(int,input().split())
L = [int(input()) for _ in range(N)]

minmp = 10**18

for i in range(4**N):
    mp = 0
    a = []
    b = []
    c = []
    d = []
    
    for j in range(N):
        if i>>(2*j) & 1:
            if i>>(2*j+1) & 1:
                a.append(j)
            else:
                b.append(j)
        else:
            if i>>(2*j+1) & 1:
                c.append(j)
            else:
                d.append(j)
                
    if not a or not b or not c:
        continue
        
    mp += (len(a)-1)*10
    mp += abs(A-sum([L[j] for j in a]))
    mp += (len(b)-1)*10
    mp += abs(B-sum([L[j] for j in b]))
    mp += (len(c)-1)*10
    mp += abs(C-sum([L[j] for j in c]))
    minmp = min(mp,minmp)

print(minmp)

Measured memory_bytes: 51036
#include <iostream>
//#include "std.h"

using namespace std;

int N;
int A[100];

void print(int *arr, int sz) {
	for (int i = 0; i < sz; ++i) {
		if (i == 0) cout << arr[i];
		else cout << " " << arr[i];
	}
	cout << endl;
}

void insert_sort() {
	print(A, N);
	for (int i = 1; i < N; ++i) {
		int k = A[i];
		int j = i-1;
		while (j >= 0 && A[j] > k) {
			A[j+1] = A[j];
			j--;
		}
		A[j+1] = k;
		print(A, N);
	}
}

int main() {
	cin >> N;
	for (int i = 0; i < N; ++i) {
		cin >> A[i];
	}
	insert_sort();
	return 0;
}


Measured memory_bytes: 3124
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        ArrayList<Long> List = new ArrayList<>();
        long bi_sum =0;
        for(int a=0;a<N;a++){
            long ai = sc.nextLong();
            long bi = sc.nextLong();
            long sum = ai+bi;
            bi_sum+=bi;
            List.add(sum);
        }
        Collections.sort(List,Comparator.reverseOrder());
        long sum_opt =0;
        sum_opt -=bi_sum;
        while(List.size()!=0){
            sum_opt+=List.get(0);
            List.remove(0);
            if(List.size()!=0) List.remove(0);
        }
        System.out.println(sum_opt);
    }
}


Measured memory_bytes: 89884
# coding: utf-8
import sys
import numpy as np

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

# 桁dp、√Nまでをlower、それ以降をup_range、Nをlowerで割ったものでまとめる
MOD = 10 ** 9 + 7
N, K = lr()
M = int(N ** .5)
A = np.arange(M+1, dtype=np.int64)
high_range = np.zeros(M+1, dtype=np.int64)
high_range[1:] = N // A[1:] - np.maximum(M, N // (A[1:] + 1))  # Mはlowerに入れるので0
low = np.zeros(M+1, dtype=np.int64)
high = np.zeros(M+1, dtype=np.int64)
low[1] = 1
for _ in range(K):
    prev_low = low.copy()
    prev_high = high.copy()
    prev_low_cum = prev_low.cumsum() % MOD
    prev_high_cum = prev_high.cumsum() % MOD
    low = np.zeros(M+1, dtype=np.int64)
    low[1:] += (prev_low_cum[-1] + prev_high_cum[-1])
    low[1:] -= prev_high_cum[:-1]
    high = prev_low_cum * high_range
    low %= MOD; high %= MOD

answer = (low[1:].sum() + high[1:].sum()) % MOD
print(answer % MOD)


Measured memory_bytes: 15684
import java.util.Scanner;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.Map;
import java.util.TreeMap;

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

    int n = sc.nextInt(); //県の数
    int m = sc.nextInt(); //市の数
    Map<Integer,int[]> map = new TreeMap<Integer,int[]>();

    for(int i=0; i<m; i++){
        int[] array = new int[2];
        array[0] = i;
        array[1] = sc.nextInt(); //県番号
        int b = sc.nextInt(); //誕生年
        map.put(b,array);
    }
    int[] ary = new int[n]; //県の数を格納
    String[] s = new String[m]; //IDを格納

    for(int[] num :map.values()){
      ary[num[1]-1]++;
      s[num[0]] = String.format("%06d%06d",num[1],ary[num[1]-1]);
    }

    StringBuilder sb = new StringBuilder();
    for(String ss: s){
      sb.append(ss+"\r\n");
    }
    System.out.println(sb);

  }
}

Measured memory_bytes: 178476
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}
#[allow(dead_code)]
struct Main {}

#[allow(dead_code)]
impl Main {}

fn main() {
    let x = read::<usize>();

    let mut m = 100;

    let mut cnt = 0;
    for _ in 0..1000000 {
        let plus = m / 100;
        m += plus;
        cnt += 1;
        if m >= x {
            break
        }
    }
    println!("{}", cnt);
}


Measured memory_bytes: 2140
# import sys
# import math #sqrt,gcd,pi
# import decimal
import queue # queue
# import bisect
# import heapq # priolity-queue
# import time
# from itertools import product,permutations,\
    # combinations,combinations_with_replacement
# 重複あり順列、順列、組み合わせ、重複あり組み合わせ
# import collections # deque
# from operator import itemgetter,mul
# from fractions import Fraction
# from functools import reduce

mod = int(1e9+7)
# mod = 998244353
INF = 1<<50

def readInt():
    return list(map(int,input().split()))

def main():
    s = input()
    t = input()
    ans = INF
    for i in range(len(s)-len(t)+1):
        res = 0
        for j in range(len(t)):
            if s[i+j]!=t[j]:
                res += 1
        ans = min(ans,res)
    print(ans)
    return

if __name__=='__main__':
    main()


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

using namespace std;

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

    vector<int> P(N), Q(N);
    for(int i=0; i<N; ++i){
        cin>>P[i];
    }
    for(int i=0; i<N; ++i){
        cin>>Q[i];
    }

    vector<int> a(N);
    for(int i=0; i<N; ++i){
        a[i] = i+1;
    }

    int idx = 0;
    int idx_p = 0;
    int idx_q = 0;
    bool eq_flag_p = true;
    bool eq_flag_q = true;
    do {
        eq_flag_p = true;
        for(int i=0; i<N; ++i){
            if(a[i] != P[i]){
                eq_flag_p = false;
            }
        }
        if(eq_flag_p==true){
            idx_p = idx;
        }

        eq_flag_q = true;
        for(int i=0; i<N; ++i){
            if(a[i] != Q[i]){
                eq_flag_q = false;
            }
        }
        if(eq_flag_q==true){
            idx_q = idx;
        }
        //cout<<eq_flag_p<<" "<<eq_flag_q<<endl;
        idx++;
    } while(next_permutation(a.begin(), a.end()));

    cout<<abs(idx_p-idx_q)<<endl;
    
    return 0;
}


Measured memory_bytes: 256
/* ***********************************************
Author        :axp
Created Time  :2015/5/15 23:46:43
File Name     :1.cpp
************************************************ */

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cstdlib>
#include <ctime>
using namespace std;

const int maxn = 1000010;
int ans;
int n,a,b;
bool v[maxn<<1];

int main()
{
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    while(cin>>n>>a>>b && n)
	{
		memset(v,0,sizeof(v));
		ans=0;
		v[0]=1;
		for(int i=0;i<=n;i++)
			if(v[i])
				v[i+a]=v[i+b]=1;
			else
				ans++;
		cout<<ans<<endl;
	}
    return 0;
}

Measured memory_bytes: 3120
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#define inf 1072114514
#define llinf 1145141919810364364
#define mod 1000000007

int max(int a,int b){if(a>b){return a;}return b;}
int min(int a,int b){if(a<b){return a;}return b;}
int zt(int a,int b){return max(a,b)-min(a,b);}
int round(int a,int b){if((a%b)*2 >= b){return (a/b)+1;}return a/b;}
int ceil(int a,int b){if(a%b==0){return a/b;}return (a/b)+1;}
int gcd(int a,int b){int c;while(b!=0){c=a%b;a=b;b=c;}return a;}
int lcm(int a,int b){int c=gcd(a,b);a/=c;return a*b;}
int nCr(int a,int b){int i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
int fact(int a){int i,r=1;for(i=1;i<=a;i++){r*=i;}return r;}
int pow(int a,int b){int i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}
long long llmax(long long a,long long b){if(a>b){return a;}return b;}
long long llmin(long long a,long long b){if(a<b){return a;}return b;}
long long llzt(long long a,long long b){return llmax(a,b)-llmin(a,b);}
long long llround(long long a,long long b){if((a%b)*2 >= b){return (a/b)+1;}return a/b;}
long long llceil(long long a,long long b){if(a%b==0){return a/b;}return (a/b)+1;}
long long llgcd(long long a,long long b){long long c;while(b!=0){c=a%b;a=b;b=c;}return a;}
long long lllcm(long long a,long long b){long long c=llgcd(a,b);a/=c;return a*b;}
long long llnCr(long long a,long long b){long long i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
long long llfact(long long a){long long i,r=1;for(i=1;i<=a;i++){r*=i;}return r;}
long long llpow(long long a,long long b){long long i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}
double dbmax(double a,double b){if(a>b){return a;}return b;}
double dbmin(double a,double b){if(a<b){return a;}return b;}
double dbzt(double a,double b){return dbmax(a,b)-dbmin(a,b);}
int sortfncsj(const void *a,const void *b){if(*(int *)a>*(int *)b){return 1;}if(*(int *)a==*(int *)b){return 0;}return -1;}
int sortfnckj(const void *a,const void *b){if(*(int *)a<*(int *)b){return 1;}if(*(int *)a==*(int *)b){return 0;}return -1;}
int llsortfncsj(const void *a,const void *b){if(*(long long *)a>*(long long *)b){return 1;}if(*(long long *)a==*(long long *)b){return 0;}return -1;}
int llsortfnckj(const void *a,const void *b){if(*(long long *)a<*(long long *)b){return 1;}if(*(long long *)a==*(long long *)b){return 0;}return -1;}
int dbsortfncsj(const void *a,const void *b){if(*(double *)a>*(double *)b){return 1;}if(*(double *)a==*(double *)b){return 0;}return -1;}
int dbsortfnckj(const void *a,const void *b){if(*(double *)a<*(double *)b){return 1;}if(*(double *)a==*(double *)b){return 0;}return -1;}

int main(void){
    int i,b[256]={0};
    char s[4];
    scanf("%s",s);
    for(i=0;i<3;i++){b[s[i]]++;}
    if(b['a']==1&&b['b']==1&&b['c']==1){printf("Yes\n");}else{printf("No\n");}
    return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

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

        int A = s.nextInt();
        int B = s.nextInt();

        int sum = 0;

        if (B > 1)
        {
            while (true) {
                sum++;
                if ((A - 1) * (sum - 1) + A >= B) break;
            }
        }

        System.out.println(sum);
        s.close();
    }
}

Measured memory_bytes: 21844
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}

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

  ll N ; cin >> N;
  vector<ld>t,limv;
  rep(i,N){
    ll inp; cin >> inp;
    t.pb(inp);
  }
  rep(i,N){
    ll inp; cin >> inp;
    limv.pb(inp);
  }
  

  vector<ld>v;
  //まずはvの初期値を入れる
  v.pb(0);
  for(ll i=0 ; i<N-1 ; i++){
    ld lim = min(limv[i], limv[i+1]);
    v.pb(lim);
  }
  v.pb(0);

  //次は左から順に見て行く。
  for(ll i = 0 ; i<v.size()-1 ; i++){
    if(v[i+1]>v[i])v[i+1] = min(v[i+1], v[i]+t[i]);
  }
  //次は右から順に見て行く。
  for(ll i =v.size()-1 ; i>=1 ; i--){
    if(v[i-1]>v[i])v[i-1] = min(v[i-1], v[i]+t[i-1]);
  }


  ld ans = 0.0;
  //両サイドの速度、その空間の制限速度より、そこの面積を出せる。
  //v[i]とv[i+1], limv[i]で囲む面積
  for(ll i = 0;i<v.size()-1;i++){
    ld l = v[i], r = v[i+1], lim = limv[i];
    if(l>r) swap(l,r);
    if(lim == r)
      ans += (l+(l+t[i]))*t[i]*0.5 - (l+t[i]-r)*(l+t[i]-r)*0.5;
    else{
      ld x = 0.5*(t[i]+r-l);
      ld y = 0.5*(t[i]-r+l);
      ld top = l+x-limv[i];
      if(top<0)top = 0;
      x -=top, y-=top;
      top*=2;
      
      if(top>0)	ans += ( (l+ l+x )*x*0.5 + (r+y + r)*y*0.5 + top*limv[i] ) ;
      
      else ans += ( (l+ l+x )*x*0.5 + (r+y + r)*y*0.5 );
      
      
    }
  }

  cout << fixed << setprecision(16) << ans << endl;
  return 0;
}


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

int main()
{
  int a, b;
  cin >> a >> b;
  int c = a * b;
  if (c == 3)
    cout << 2 << endl;
  if (c == 2)
    cout << 3 << endl;
  if (c == 6)
    cout << 1 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <vector>
using namespace std;
#define rep(i,b) loop(i,0,b)
#define loop(i,a,b) for(int i=(a);i<int(b);i++)

int s,d,m;
int k[128];
int w[128][64], p[128][64];
int f[128];
int dp[512];

void solve(){
    memset(dp,0,sizeof(dp));
    rep(i,d)rep(j,k[f[i]]){
        int p=::p[f[i]][j];
        int w=::w[f[i]][j];
        for(int l=m;;l--){
            if(l-p>=0)
                dp[l]=max(dp[l],dp[l-p]+w);
            else
                break;
        }
    }
    int ans=0;
    rep(i,m+1){
        if(dp[i]>dp[ans]){
            ans=i;
        }
    }
    cout<<dp[ans]<<" "<<ans<<endl;
}

int main(){
    while(cin>>s>>d>>m){
        rep(i,s){
            cin>>k[i];
            rep(j,k[i])cin>>w[i][j]>>p[i][j];
        }
        rep(i,d)cin>>f[i];
        solve();
    }
}

// fill_n( dp, m + 1, 0);
//         for(int i = 0 ; i < d ; i++ ){
//             int f;
//             cin >> f;
//             for(int j = 0 ; j < w[f].size(); j++){
//                 for(int k = m ; k - p[f][j] >= 0; k--){
//                     dp[k] = max( dp[k], dp[k - p[f][j]] + w[f][j]);
//                 }
//             }
//         }

//         int pos = 0;
//         for(int i = 0 ; i <= m ; i++ ){
//             if( dp[i] > dp[pos] ) pos = i;
//         }
//         cout << dp[pos] << " " << pos << endl;
//     }
// }

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

int bit_one(int b){
    int r = 0;
    while( b ){
        r += b%2;
        b >>= 1;
    }
    return r;
}

int dp[400][1 << 10];

void set(){
    for(int i = 0; i < 300; i++){
        for(int j = 0; j < (1 << 10); j++){
            dp[i][j] = 0;
        }
    }
    dp[0][0] = 1;
    for(int i = 0; i < 300; i++){
        for(int j = 0; j < (1 << 10); j++){
            for(int k = 0; k < 10; k++){
                if( dp[i][j] && (j >> k)%2 == 0 ){
                    dp[i + k * (bit_one(j) + 1)][j|(1 << k)] += dp[i][j];
                }
            }
        }
    }
}

int main(){
    set();
    int n, s;
    while( cin >> n >> s ){
        if( s >= 400 ){
            cout << 0 << endl;
            continue;
         }
        int ans = 0;
        for(int i = 0; i < (1 << 10); i++){
            if( bit_one( i ) == n ){
                ans += dp[s][i];
            }
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 2484
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INFLL LLONG_MAX // 9223372036854775807
#define EPS 1e-9
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
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; }
using namespace std;

int main(){
    Init();
    ll n, m, ans = 0; cin >> n >> m;
    vi x(n), y(n), z(n);
    rep(i, n) cin >> x[i] >> y[i] >> z[i];

    for(ll i=0; i<(1LL<<3); i++){
        vi sign(3, 1);
        vector<tuple<ll, ll, ll, ll>> score(n);
        for(ll m=0; m<3; m++) if(i&(1LL<<m)) sign[m] = -1;
        rep(i, n) score[i] = make_tuple(sign[0]*x[i] + sign[1]*y[i] + sign[2]*z[i], x[i], y[i], z[i]);
        sort(all(score), greater<tuple<ll, ll, ll, ll>>());
        ll xsum = 0, ysum = 0, zsum = 0;
        rep(i, m){
            xsum += get<1>(score[i]);
            ysum += get<2>(score[i]);
            zsum += get<3>(score[i]);
        }
        chmax(ans, abs(xsum)+abs(ysum)+abs(zsum));
    }
    cout << ans << endl;
}

Measured memory_bytes: 3648
import sys
 
stdin = sys.stdin
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()
nas = lambda: stdin.readline().split()

from collections import defaultdict

n = ni()

def f(x):
    a = x % 10
    b = 0
    while x:
        b = x
        x //= 10
    return (a, b)

freq = [10 * [0] for i in range(10)]
ans = 0

for i in range(1,n+1):
    p = f(i)
    freq[p[0]][p[1]] += 1

for i in range(1,n+1):
    p = f(i)
    q = (p[1], p[0])
    ans += freq[q[0]][q[1]]

print(ans)

Measured memory_bytes: 3316
#include <iostream>
#include <cmath>
#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>

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define pb(a) push_back(a)

typedef long long ll;
using namespace std;

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

//const int dy[] = { 0, 0, 1, -1 };
//const int dx[] = { 1, -1, 0, 0 };
const int dx[8] = { 1, 0, -1, 0, 1, -1, -1, 1 };
const int dy[8] = { 0, 1, 0, -1, 1, 1, -1, -1 };
ll gcd(ll a, ll b);
ll lcm(ll x, ll y);

vector<ll> a;

int main()
{
	ll n;
	ll ans=0;
	cin >> n;

	for(int i=1;i<=n;i++){
		if (i % 3 == 0) {

		}
		else if (i % 5 == 0) {

		}
		else {
			ans += i;
		}
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 3636
#include <algorithm>
#include <vector>
#include <cmath>

struct coor{ long double x, y;};
class smallest_enclosing_circle{
private:
    mutable std::vector<coor> points;
    coor c;
    long double r;

    long double dist(coor& P, coor& Q) const {
        long double dx = P.x - Q.x;
        long double dy = P.y - Q.y;
        return std::sqrt(dx*dx + dy*dy);
    }

    long double max_dist(long double& x, long double& y) const {
        long double res = 0;
        coor P = {x, y};
        for(coor& Q : points){
            res = std::max(res, dist(P, Q));
        } 
        return res;
    }

    long double min_y(long double& x) const {
        long double left = 0, right = 1000;
        for(int i = 0; i < 100; i++){
            long double y1 = (left*2 + right) / 3.0;
            long double y2 = (left + right*2) / 3.0;

            if(max_dist(x, y1) > max_dist(x, y2)) left = y1; 
            else right = y2;
        }
        return left; 
    }

public:
    smallest_enclosing_circle() = delete;
    smallest_enclosing_circle &operator=(const smallest_enclosing_circle) = delete;
    smallest_enclosing_circle(std::vector<coor>&& p) : points(p) {}
    void solve(){
        long double left = 0, right = 1000;
        for(int i = 0; i < 100; i++){
            long double x1 = (left*2 + right) / 3.0;
            long double x2 = (left + right*2) / 3.0;

            long double y1 = min_y(x1);
            long double y2 = min_y(x2);

            if(max_dist(x1, y1) > max_dist(x2, y2)) left = x1;
            else right = x2;
        }

        long double x = left;
        long double y = min_y(x);

        c = {x, y};
        r = max_dist(x, y);
    }

    coor center() const { return c; }
    long double radius() const { return r; }
};

#include<iostream>
#include<iomanip>
using namespace std;
int main(){
    int N;
    cin >> N;

    vector<coor> points(N);
    for(int i = 0; i < N; i++){
        long double x, y;
        cin >> x >> y;
        points[i] = {x, y};
    }

    smallest_enclosing_circle Sec(std::move(points));
    Sec.solve();

    cout << setprecision(12) << Sec.radius() << endl; 
}


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

int main() {
	int K;
	std::string S;
	std::cin >> K >> S;
	if (S.size() <= K) std::cout << S << std::endl;
	else {
		std::string answer = S.substr(0, K);
		answer += "...";
		std::cout << answer << std::endl;
	}
	return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define LLINF 9223372036854775807
#define MOD ll(998244353)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cerr<<#x<<": "<<x<<endl


int main(){
    ll n;
    cin >> n;
    vector<ll> d(n);
    for(int i = 0; i < n; i++){
        cin >> d[i];
    }
    map<ll,ll> mp;
    for(int i = 0; i < n; i++){
        mp[d[i]]++;
    }
    if(d[0] != 0){
        cout << 0 << endl;
        return 0;
    }
    if(mp[0] != 1){
        cout << 0 << endl;
        return 0;

    }
    ll ans = 1;
    ll end = (--mp.end())->first;
    for(int i = 1; i <= end; i++){
        ll t=1;
        for(int j = 0; j < mp[i]; j++){
            t *= mp[i-1];
            t %= MOD;
        }
        ans *= t;
        ans %= MOD;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 7296
#include <bits/stdc++.h>
 
#define rep(i,n) for(ll i=0;i<n;++i)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()

using namespace std;
using ll  = long long;
using pll = pair<ll, ll>;

const ll MOD  = 1e9 + 7;
const ll LINF = 1LL << 62;
const int INF = 1e9 + 7;

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

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

    sort(ALL(a));

    bool isok[a[n-1]];
    rep(i, a[n-1]+1)isok[i] = true;

    ll ans = 0;
    rep(i, n)if(isok[a[i]]){
        ans++;
        if(i < n-1 && a[i+1] == a[i])ans--;

        for(ll j = a[i]; j <= a[n-1]; j += a[i])isok[j] = false;
    }

    cout << ans << endl;
}

Measured memory_bytes: 5848
#include <bits/stdc++.h>
#define MOD 1000000007
#define endl "\n"
typedef long long ll;
using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cout.precision(10);
    set<int> st;
    int n;
    cin >> n;
    while(n--) {
        int a;
        cin >> a;
        if(st.find(a) != st.end()) {
            st.erase(a);
        } else {
            st.insert(a);
        }
    }
    cout << st.size() << endl;
    return 0;
}

Measured memory_bytes: 4992
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int m = sc.nextInt();
		int l = sc.nextInt();

		int[][] A = new int[n][m];
		int[][] B = new int[m][l];
		long[][] C = new long[n][l];

		//??????A?????£??\
		for(int i = 0; i < n; i++) {
			for(int j = 0; j < m; j++) {
				A[i][j] = sc.nextInt();
			}
		}
		//??????B?????£??\
		for(int i = 0; i < m; i++) {
			for(int j = 0; j < l; j++) {
				B[i][j] = sc.nextInt();
			}
		}


/*

		//???????¢??????¨ A?????????
		for(int i = 0; i < n; i++) {
			for(int j = 0; j < m; j++) {
				System.out.print("A[i][j] = "+ A[i][j]+" ");
			}
			System.out.println("");
		}

		System.out.println("###################################");

		//???????¢??????¨ B?????????
		for(int i = 0; i < m; i++) {
			for(int j = 0; j < l; j++) {
				System.out.print("B[i][j] = "+ B[i][j]+" ");
			}
			System.out.println("");
		}
*/
		for(int i = 0; i < n; i++) {
			for(int j = 0; j < l; j++) {
				for(int k = 0; k < m; k++) {
					C[i][j] += (long)A[i][k] * (long)B[k][j];
				}
				if(j+1 == l) {
					System.out.print(C[i][j]);
				}
				else {
					System.out.print(C[i][j]+" ");
				}
			}
			System.out.println("");
		}
	}
}

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

int main(){
  string s;
  string t = "CODEFESTIVAL2016";
  int res=0;
  cin >> s;
  for(int i=0; i<t.size(); i++){
    if(s[i] != t[i]) res++;
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-

"""
参考：https://img.atcoder.jp/abc121/editorial.pdf
　　　https://www.youtube.com/watch?v=igfVeTsGeYw
・公式解
"""

import sys, re
from collections import deque, defaultdict, Counter
from math import sqrt, hypot, factorial, pi, sin, cos, radians, log10
if sys.version_info.minor >= 5: from math import gcd
else: from fractions import gcd 
from heapq import heappop, heappush, heapify, heappushpop
from bisect import bisect_left, bisect_right
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul, xor
from copy import copy, deepcopy
from functools import reduce, partial
from fractions import Fraction
from string import ascii_lowercase, ascii_uppercase, digits
from datetime import date

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def round(x): return int((x*2+1) // 2)
def fermat(x, y, MOD): return x * pow(y, MOD-2, MOD) % MOD
def lcm(x, y): return (x * y) // gcd(x, y)
def lcm_list(nums): return reduce(lcm, nums, 1)
def gcd_list(nums): return reduce(gcd, nums, nums[0])
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

A,B=MAP()

def calc(n):
    # (0^1)^(2^3)^(4^5)..=>1^1^1..の部分で
    # 立ったビットの数の偶奇で0か1
    res=(n+1)//2%2
    # 最後の偶数部分
    if n%2==0:
        res^=n
    return res
# [A,B]の区間XOR
print(calc(B)^calc(A-1))


Measured memory_bytes: 5708
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define INSEG(l,x,r) ((l)<=(x)&&(x)<(r))
#define dump(...)
#define pb push_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) {
    ITR(i,begin(v),end(v))os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) 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> using heap=priority_queue<T,vector<T>,greater<T>>;
struct before_main_function {
    before_main_function() {
        cin.tie(0); ios::sync_with_stdio(false);
        cout << setprecision(15) << fixed;
        #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

signed main() {
    int A, B;
    cin >> A >> B;
    cout << (A & B & 1 ? "Yes" : "No") << endl;
    return (0^_^0);
}



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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

int N,K;
int A[222222];

signed main(){
    cin>>N>>K;
    rep(i,N){
        int a;cin>>a;A[a]++;
    }
    sort(A,A+222222);reverse(A,A+222222);
    cout<<N-accumulate(A,A+K,0ll)<<endl;
    return 0;
}


Measured memory_bytes: 1920
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(x) (x).begin(),(x).end()
#define dup(x,y) (((x)+(y)-1)/(y))
#define sz(x) (int)(x).size()
#define MOD 1000000007
using namespace std;
typedef long long ll;

int main(){
    int a, b;
    ll n, c;
    cin >> n;
    for(ll i = 1; i*i <= n; i++){
        if(n%i == 0) c = i;
    }
    cout << c+(n/c)-2 << endl;
    return 0;
}

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

using namespace std;

int main(){
    int a,b,c;
    int count;

    count = 0;
    cin >> a >> b >> c;

    for(int i = a; i <= b; i++){
        if((c%i) == 0){
            count++;
        }
    }

    cout << count << endl;

    return 0;
}


Measured memory_bytes: 3120
import math
n, d = map(int, input().split())
x = []
cnt = 0
for i in range(n):
    l = list(map(int, input().split()))
    x.append(l)
for i in range(n-1):
    for j in range(i+1, n):
        di = 0
        for k in range(d):
            di += (x[i][k] - x[j][k]) ** 2
        if math.sqrt(di).is_integer():
            cnt += 1
print(cnt)


Measured memory_bytes: 9104
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<cstdlib>
using namespace std;
char s[55][55];
int cnt[55][30];
int n;
int main(){
	scanf("%d", &n);
	for(int i = 1; i <= n; i++) scanf("%s", s[i] + 1);
	for(int i = 1; i <= n; i++){
		for(int j = 1; j <= strlen(s[i] + 1); j++)
			cnt[i][s[i][j] - 'a']++;
	}
	for(int i = 0; i < 26; i++) cnt[0][i] = 1 << 30;
	for(int i = 0; i < 26; i++){
		for(int j = 1; j <= n; j++)
			cnt[0][i] = min(cnt[0][i], cnt[j][i]);
	}
	for(int i = 0; i < 26; i++){
		while(cnt[0][i]--) printf("%c", i + 'a');
	}
	return 0;
}



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

int main(){
  int n, m;
  cin >> n >> m;
  double dp[1<<n][m], prob[n][m];
  for(int i = 0; i < (1<<n); ++i){
    fill(dp[i],dp[i]+m,0);
  }

  for(int i = 0; i < n; ++i){
    for(int j = 0; j < m; ++j){
      cin >> prob[i][j];
    }
  }
  
  for(int bit = 0; bit < (1<<n); ++bit){
    for(int i = 0; i < m; ++i){
      for(int j = 0; j < n; ++j){
	if(bit>>j & 1){
	  double t = 0, p = 1.0;
	  for(int k = i; k < m; ++k){
	    t += p*(1.0 - prob[j][k])*dp[bit-(1<<j)][k];
	    p *= prob[j][k];
	  }
	  t += p;
	  dp[bit][i] = max(dp[bit][i],t);
	}
      }
    }
  }

  double ans = dp[(1<<n)-1][0];
  printf("%.12f\n",ans);
  return 0;
}



Measured memory_bytes: 11480
#include <stdio.h>

int main() {
        int N, K, A;
        int S[101] = {0};
        int i, j, d;
        int ans = 0;
        scanf("%d %d", &N, &K);

        for(i = 0; i < K; i++) {
                scanf("%d", &d);

                for(j = 0; j < d; j++) {
                        scanf("%d", &A);
                        S[A]++;
                }
        }

        for(i = 1; i <= N; i++) {
                ans += S[i] == 0;
        }

        printf("%d\n", ans);

        return 0;
}


Measured memory_bytes: 1700
#include "bits/stdc++.h"
#define ll long long int
#define F first
#define S second
const ll mod = 1e9 + 7;
const ll INF = 10000000000000;
#define pb push_back
#define deb(x) cout << '>' << #x << ':' << x << endl;
#define fastio ios_base::sync_with_stdio(0); cin.tie(0);
using namespace std;
int main()
{
    fastio;
   string s;
   cin>>s;
   if(s=="ABC") cout<<"ARC";
   else cout<<"ABC";
}

Measured memory_bytes: 3608
#include <iostream>
#include <cstdio>
#include <queue>
#define INF 1e+18
#define int long long
using namespace std;

signed main(){
	int n,m;
	while(cin >> n,n){
		int field[21][21] = {};
		bool used[21][21] = {};
		for(int i = 0;i < n;i++){
			int x,y;
			cin >> x >> y;
			field[x][y] = 1;
		}
		cin >> m;
		int x = 10,y = 10;
		for(int i = 0;i < m;i++){
			char d;
			int l;
			cin >> d >> l;
			for(int j = 0;j < l;j++){
				if(d == 'N') used[x][++y] = true;
				else if(d == 'S') used[x][--y] = true;
				else if(d == 'E') used[++x][y] = true;
				else used[--x][y] = true;
			}
		}
		int cnt = 0;
		for(int i = 0;i <= 20;i++){
			for(int j = 0;j <= 20;j++){
				if(used[i][j]) cnt += field[i][j];
			}
		}
		if(cnt == n) cout << "Yes" << endl;
		else cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 3064
//Code by Anshuman Das Gupta

#include<bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define int long long
#define MOD 1000000007
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define loop(I,N) for(int i=I;i<N;i++)
#define sortvec(V) sort(V.begin(),V.end())
#define vec vector<int>
#define endl "\n"
using namespace std;
int fast_power(int base, int power) {
    int result = 1;
    while (power > 0) {

        if (power & 1) {
            result = (result * base) % MOD;
        }
        base = (base * base) % MOD;
        power = power >> 1;
    }
    return result % MOD;
}

bool isPrime(int x) {
    for (int i = 2; i <= sqrt(x); i++) {
        if (x % i == 0)
            return false;
    }
    if (x == 1)
        return false;
    return true;
}

int binsearch(int a[], int f, int r, int x) {
    while (f <= r) {
        int mid = (f + r) / 2;
        if (a[mid] == x)
            return mid;
        else if (a[mid] > x) {
            r = mid - 1;
        }
        else {
            f = mid + 1;
        }
    }
    return -1;
}
void sieve(int a[], int n) {
    a[0] = 0;
    a[1] = 0;
    for (int i = 2; i <= n; i++) {
        if (a[i] == 1) {
            for (int j = i + i; j <= n; j += i) {
                a[j] = 0;
            }
        }
    }
}
int32_t main() {
#ifndef ONLINE_JUDGE
    //for getting input from input.txt
    freopen("input.txt", "r", stdin);
    //for writing output to output.txt
    freopen("out.txt", "w", stdout);
#endif
    int t = 1;
    //cin >> t;
    while (t--) {
        int a, b, n;
        cin >> a >> b >> n;
        int x = min(b - 1, n);
        cout << ((a * x) / b) - (a * (x / b)) << endl;
    }
    return 0;
}


Measured memory_bytes: 3552
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {



		public static void main(String[] args) {
			BufferedReader input = new BufferedReader(new InputStreamReader(System.in));


			  try{
				  
				  String ab = input.readLine();
				  String[] strAry = ab.split(" ");

				  int W = Integer.parseInt(strAry[0]);
				 
				  int H = Integer.parseInt(strAry[1]);
				  
				  int x = Integer.parseInt(strAry[2]);
				  
				  int y =Integer.parseInt(strAry[3]);
				
				  int r=Integer.parseInt(strAry[4]);
				 

				  if(x+r>W||x-r<0||y+r>H||y-r<0){
					  System.out.println("No");
				  }else{
					  System.out.println("Yes");
				  }

			    }catch(IOException e) {   System.out.println("Exception : " + e);
			    }

		}
}

Measured memory_bytes: 24352
# include <bits/stdc++.h>
using namespace std;
namespace Base{
	# define mr make_pair
	typedef long long ll;
	typedef double db;
	const int inf = 0x3f3f3f3f, INF = 0x7fffffff;
	const ll  infll = 0x3f3f3f3f3f3f3f3fll, INFll = 0x7fffffffffffffffll;
	template<typename T> void read(T &x){
    	x = 0; int fh = 1; double num = 1.0; char ch = getchar();
		while (!isdigit(ch)){ if (ch == '-') fh = -1; ch = getchar(); }
		while (isdigit(ch)){ x = x * 10 + ch - '0'; ch = getchar(); }
	    if (ch == '.'){
	    	ch = getchar();
	    	while (isdigit(ch)){num /= 10; x = x + num * (ch - '0'); ch = getchar();}
		}
		x = x * fh;
	}
	template<typename T> void chmax(T &x, T y){x = x < y ? y : x;}
	template<typename T> void chmin(T &x, T y){x = x > y ? y : x;}
}
using namespace Base;

const int N = 310, P = 998244353;
int dp[N][N], f[N][N][N], n, ans;
vector <pair<int, int> > mp[N];
char s[N];
void join(int x, int y, int i){
	if (dp[x][y] != inf) return;
	dp[x][y] = i; 
	mp[i].push_back(mr(x, y));
}
int main(){
	scanf("\n%s", s + 1);
	n = strlen(s + 1);
	memset(dp, inf, sizeof(dp));
	dp[0][0] = 0;
	mp[0].push_back(mr(0, 0));
	for (int i = 2; i <= n; i++){
		for (unsigned j = 0; j < mp[i - 2].size(); j++){
			int x = mp[i - 2][j].first, y = mp[i - 2][j].second;
			if (s[i - 1] == '0' || s[i] == '0'){
				int tx = x + 1, ty = y;
				join(tx, ty, i);
			}
			if (s[i - 1] == '1' || s[i] == '1'){
				int tx = x, ty = y + 1;
				join(tx, ty, i);
			}
		}
		for (unsigned j = 0; j < mp[i - 1].size(); j++){
			int x = mp[i - 1][j].first, y = mp[i - 1][j].second;
			if (y > 0 && s[i] == '0'){
				int tx = x + 1, ty = y - 1;
				join(tx, ty, i);
			}
			if (x > 0 && s[i] == '1'){
				int tx = x - 1, ty = y + 1;
				join(tx, ty, i);
			}
		}
	}
	for (int i = n; i >= 0; i--)
		for (int j = n; j >= 0; j--)
			dp[i][j] = min(dp[i][j], min(dp[i + 1][j], dp[i][j + 1]));
	
	f[0][0][0] = 1;
	for (int i = 1; i <= n; i++){
		for (int j = 0; j <= i; j++)
			for (int k = 0; k <= i - j; k++){
				int t = i - j - k;
				if (dp[k][t] > n - j) continue;
				if (j > 0){
					if (s[n - j + 1] == '0'){
						f[j][k][t] = f[j - 1][k][t];
						if (t > 0) f[j][k][t] = (f[j][k][t] + f[j][k][t - 1]) % P;
					}
					else {
						f[j][k][t] = f[j - 1][k][t];
						if (k > 0) f[j][k][t] = (f[j][k][t] + f[j][k - 1][t]) % P;
					}
				}
				else {
					if (k > 0) f[j][k][t] = f[j][k - 1][t];
					if (t > 0) f[j][k][t] = (f[j][k][t] + f[j][k][t - 1]) % P;
				}
				if (j > 0){
					if (s[n - j + 1] == '0' && dp[k + 1][t] <= n - (j - 1)) continue;
					if (s[n - j + 1] == '1' && dp[k][t + 1] <= n - (j - 1)) continue;
				}
				ans = (ans + f[j][k][t]) % P;
			}
	}
	cout << ans << endl;
    return 0;
}


Measured memory_bytes: 32472
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=55,M=1e3+5,inf=0x3f3f3f3f,mod=1e9+7;
#define mst(a,b) memset(a,b,sizeof a)
#define lx x<<1
#define rx x<<1|1
#define reg register
#define PII pair<int,int>
#define fi first
#define se second
#define pb push_back
#define il inline
int n,A,B;
int a[N],b[N],c[N];
int dp[M][M];
int main(){
	cin>>n>>A>>B;
	int sa=0,sb=0;
	for(int i=1;i<=n;i++){
		cin>>a[i]>>b[i]>>c[i];
		sa+=a[i],sb+=b[i];
	}
	mst(dp,0x3f);
	dp[0][0]=0;
	for(int i=1;i<=n;i++){
		for(int j=sa;j>=a[i];j--)
		{
			for(int k=sb;k>=b[i];k--){
				dp[j][k]=min(dp[j][k],dp[j-a[i]][k-b[i]]+c[i]);
			}
		}
	}
	int ans=inf;
	for(int i=A,j=B;i<=sa&&j<=sb;i+=A,j+=B){
		ans=min(ans,dp[i][j]);
	} 
	if(ans==inf)puts("-1");
	else cout<<ans<<endl;
}

Measured memory_bytes: 7480
import std.stdio;
import std.ascii;
import std.c.stdio;
import std.range;
import std.array;
import std.functional;
import std.algorithm;
import std.conv;
import std.container;
import std.math;
import std.numeric;
import std.string;
import std.c.string;
import std.regex;
import std.typecons;

struct P {
    int y, x;
}

void main() {
    int H, W;
    scanf("%d %d\n", &H, &W);
    auto F = cast(char[][])(new string[H]);
    foreach (ref L; F) L = cast(char[])readln.chomp;

    auto X = new P[][26];
    foreach (i; 0 .. H) {
        foreach (j; 0 .. W) {
            if (F[i][j] == '.') continue;
            X[ F[i][j] - 'A' ] ~= P(i, j);
        }
    }
    //foreach (i; 0 .. 26) writeln(cast(char)('A' + i), " ", X[i]);

    bool check(P a, P b, int dy, int dx) {
        //writeln(a, " -> ", b, [dy, dx]);
        a.y += dy;
        a.x += dx;
        while (a != b) {
            if (F[a.y][a.x].isUpper) return false;
            a.y += dy;
            a.x += dx;
            //writeln(a);
        }
        return true;
    }

    int Ans = 0;
    auto used = new bool[26];
    foreach (t; 0 .. 26) {
        foreach (i; 0 .. 26) {
            if (X[i].empty) continue;
            if (used[i]) continue;
            auto a = X[i][0], b = X[i][1];
            int y = b.y - a.y,
                x = b.x - a.x;
            if (y == 0) {
                if (abs(x) == 1) continue;
                if (check(a, b, 0, x / abs(x))) {
                    F[a.y][a.x] = '.';
                    F[b.y][b.x] = '.';
                    Ans += 2;
                    used[i] = true;
                }
            } else if (x == 0) {
                if (abs(y) == 1) continue;
                if (check(a, b, y / abs(y), 0)) {
                    F[a.y][a.x] = '.';
                    F[b.y][b.x] = '.';
                    Ans += 2;
                    used[i] = true;
                }
            } else {
                auto p = P(a.y, b.x),
                     q = P(b.y, a.x);
                if ( (F[p.y][p.x] == '.' && 
                            check(a, p, 0, x / abs(x)) && 
                            check(p, b, y / abs(y), 0)) ||
                     (F[q.y][q.x] == '.' &&
                            check(a, q, y / abs(y), 0) && 
                            check(q, b, 0, x / abs(x))) ) {
                    F[a.y][a.x] = '.';
                    F[b.y][b.x] = '.';
                    Ans += 2;
                    used[i] = true;
                }
            }
        }
    }
    writeln(Ans);
}

Measured memory_bytes: 1336
import sys

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


def main():
    N = int(input())
    A = [int(input()) for _ in range(N)]

    if A[0] != 0:
        print(-1)
        return

    ans = 0
    for a, b in zip(A[0:], A[1:]):
        if b - a >= 2:
            print(-1)
            return
        elif b - a == 1 or (a == 1 and a == b):
            ans += 1
        else:
            ans += b

    print(ans)




if __name__ == '__main__':
    main()


Measured memory_bytes: 20028
#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int main(){
	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif
		string s;
		cin>>s;
		if( s[5]=='0' && s[6]<='4') cout<<"Heisei";
		else cout<<"TBD";
		return 0;
}


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

#define REP(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)

int main(){
  int tyo = 0, hisi = 0;
  int i, j, k;

  while(scanf("%d,%d,%d",&i,&j,&k) != EOF){
    if(i == j) hisi++;
    if(i*i + j*j == k*k) tyo++;
  }

  printf("%d\n%d\n",tyo,hisi);

  return 0;
}

Measured memory_bytes: 0
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

class Main {
	public static void main(String[] args) throws Exception {
		new Main().run();
	}
	
	void run() {
		Scanner sc=new Scanner(System.in);
		int a=sc.nextInt();
		int b=sc.nextInt();
		int c=sc.nextInt();
		System.out.println(b-a==c-b?"YES":"NO");
	}
	
	static void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}
	
}


Measured memory_bytes: 22996
import sys
input = sys.stdin.readline

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    a,b,c=MI()
    K=I()
    cnt=0
    while b<=a:
        b*=2
        cnt+=1
        
    while c<=b:
        c*=2
        cnt+=1
        
    if cnt<=K:
        print("Yes")
    else:
        print("No")

main()


Measured memory_bytes: 61968
class UnionFind:
    def __init__(self, n):
        self.parent = list(range(n)) #親ノード
        self.size = [1]*n #グループの要素数
 
    def root(self, x): #root(x): xの根ノードを返す．
        while self.parent[x] != x:
            x, self.parent[x] = self.parent[x], self.parent[self.parent[x]]
        return x 
 
    def merge(self, x, y): #merge(x,y): xのいる組とyのいる組をまとめる
        x, y = self.root(x), self.root(y)
        if x == y: return False
        if self.size[x] < self.size[y]: x,y=y,x #xの要素数が大きいように
        self.size[x] += self.size[y] #xの要素数を更新
        self.parent[y] = x #yをxにつなぐ
        return True
 
    def issame(self, x, y): #same(x,y): xとyが同じ組ならTrue
        return self.root(x) == self.root(y)
        
    def size(self,x): #size(x): xのいるグループの要素数を返す
        return self.size[self.root(x)]
#>>>>>>>>>>>>>>EhdCutHere>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

n,m = list(map(int,input().split()))
p = list(map(lambda x: int(x)-1,input().split()))

uf = UnionFind(n)
for i in range(m):
    x,y=list(map(int,input().split()))
    uf.merge(x-1,y-1)

ans = 0
for i in range(n):
    if uf.issame(i,p[i]):
        ans += 1

print(ans)
#print([uf.root(i) for i in range(n)])
#print([uf.parent[i] for i in range(n)])
#print([uf.size(i) for i in range(n)])



Measured memory_bytes: 66924
package main

import (
	"fmt"
)

func main() {
	a := make([]int, 5)
	for i := range a {
		fmt.Scan(&a[i])
	}
	var res int
	cnt := 10
	p := -1
	for i, v := range a {
		if v%10 == 0 {
			res += v
		} else {
			res += (v/10 + 1) * 10
			if v%10 < cnt {
				cnt = v % 10
				p = i
			}

		}
	}
	if p != -1 {
		res = res - (10 - a[p]%10)
	}
	fmt.Println(res)
}


Measured memory_bytes: 512