akhauriyash/Code-Regression huggingface dataset:
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"
 
using namespace std;

int main() {
  int N, K; cin >> N >> K;
  vector<int> l(N);
  for (auto &i : l) cin >> i;
  
  sort(l.begin(), l.end(), greater<int>());
  
  int ans=0;
  for (int i=0; i<K; i++) ans += l[i];
  cout << ans << endl;
}

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

using namespace std;

bool check(int x){
    bool res=true;
    string s=to_string(x);
    for(int i=0;i<(int )s.length()-1;i++){
        if(s[i]-'0'+1!=s[i+1]-'0') res=false;
    }
    return res;
}

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

  int n;cin>>n;
  std::vector<int> v(n);
  for(int i=0;i<n;i++) cin>>v[i];
  int ma=-1;
  sort(v.begin(),v.end());
  for(int i=0;i<n;i++){
      for(int j=i+1;j<n;j++){
          int tmp=v[i]*v[j];
          if(check(tmp)) ma=max(ma,tmp);
      }
  }
  cout<<ma<<endl;
}

Measured memory_bytes: 3272
#include <bits/stdc++.h>
using namespace std;
int h, w;
int vx[] = {0, 1, 0, -1};
int vy[] = {1, 0, -1, 0};
char field[100][100];
void solve(int x, int y, char mark){
    field[y][x] = '.';
    for(int i = 0; i < 4; ++i){

        int nx = x + vx[i];
        int ny = y + vy[i];
        if(nx >= 0 && nx < w && ny >= 0 && ny < h && field[ny][nx] == mark){
            solve(nx, ny, mark);
        }
    }
}
int main(){

    int cnt;
    while(cin >> h >> w){
        if(!(h || w)) break;
        cnt = 0;
        for(int i = 0; i < h; ++i){
            for(int j = 0; j < w; ++j){
                cin >> field[i][j];
            }
        }
        for(int i = 0; i < h; ++i){
            for(int j = 0; j < w; ++j){
                if(field[i][j] != '.'){
                    ++cnt;
                    solve(j, i, field[i][j]);
                }
            }
        }
        cout << cnt << endl;
    }
}

Measured memory_bytes: 1632
using System;

namespace codefestival_2016_qualB_a
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            string x = "CODEFESTIVAL2016";
            int ret = 0;
            for (int i = 0; i < 16; i++)
            {
                if (s[i] != x[i])
                {
                    ret++;
                }
            }
            Console.WriteLine(ret);
        }
    }
}

Measured memory_bytes: 2648
#include <iostream>
#include <fstream>
#include <iomanip>

#include <vector>
#include <set>
#include <bitset>
#include <map>
#include <deque>
#include <string>
#include <queue>

#include <algorithm>
#include <numeric>
#include <random>

#include <cstdio>
#include <cassert>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>

using namespace std;

#define forn(i, n) for (ll i = 0; i < static_cast<ll>(n); ++i)
#define sz(a) static_cast<int>((a).size())
#define pb emplace_back
#define endl '\n'
#define f first
#define s second

#ifdef LOCAL
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define dbg(...)
#endif

template<typename T>
void _dbg(const char* _s, T _h) { cerr << _s << " = " << _h << "\n"; }

template<typename T, typename... Ts>
void _dbg(const char*_s, T _h, Ts... _t) {
    int _b = 0;

    while (((_b += *_s == '(') -= *_s == ')') != 0 || *_s != ',')
        cerr << *_s++;

    cerr << " = " << _h << ",";
    _dbg(_s + 1, _t...);
}

using ll = long long;

const ll INF = static_cast<ll>(1e9) + 7ll;
const ll LINF = INF * INF;
const int MAXN = static_cast<int>(1e6) + 17;

int n;
ll x;
ll a[MAXN];

bool read() {
    if (!(cin >> n >> x))
        return false;

    forn (i, n) {
        cin >> a[i];
    }

    return true;
}

void solve() {
    sort(a, a + n);
    int ans = 0;

    for (int i = 0; i < n; ++i) {
        x -= a[i];

        if (x >= 0)
            ++ans;
    }

    if (ans == n && x > 0)
        --ans;

    cout << ans << endl;
}

int32_t main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);

#ifdef LOCAL
    //freopen("/Users/leemonage/CLionProjects/proj/file.in", "r", stdin);
#endif

    while (read())
        solve();

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N;scanf("%d",&N);
    long long A[N],B[N],C[N];
    for(int i=0;i<N;i++)scanf("%lld",&A[i]);
    for(int i=0;i<N;i++)scanf("%lld",&B[i]);
    for(int i=0;i<N;i++)scanf("%lld",&C[i]);
    sort(A,A+N),sort(B,B+N),sort(C,C+N);
    long long cntB[N];
    for(int i=0;i<N;i++){
        int left=-1,right=N;
        while(right-left>1){
            int middle=(left+right)/2;
            if(C[middle]<=B[i])left=middle;
            else right=middle;
        }
        cntB[i]=N-right;
    }
    for(int i=N-2;i>=0;i--)cntB[i]+=cntB[i+1];
    long long ans=0;
    for(int i=0;i<N;i++){
        int left=-1,right=N;
        while(right-left>1){
            int middle=(left+right)/2;
            if(B[middle]<=A[i])left=middle;
            else right=middle;
        }
        if(right!=N)ans+=cntB[right];
    }
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
#define REP(i, n) for(int i=0; i<(int)(n); i++)
#define REP1(i,a,b) for(int i=a; i<=(int)(b); i++)
#define ALL(x) begin(x),end(x)
#define PB push_back
using namespace std;
typedef int64_t LL;
typedef vector<int> VI;
typedef pair<int,int> PII;

template<class T> inline bool chmax( T &a, const T &b ) { return b>a ? a=b,true : false; }
template<class T> inline bool chmin( T &a, const T &b ) { return b<a ? a=b,true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;
template<class T, class F=less<T>> void sort_uniq( vector<T> &v, F f=F() ) {
    sort(begin(v),end(v),f);
    v.resize(unique(begin(v),end(v))-begin(v));
}

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

    LL a,b;
    cin >> a >> b;
    if(a%2) {
        if(b%2) {
            cout << (a^((b-a)/2 & 1)) << endl;
        } else {
            cout << ((a^b)^((b-a-1)/2 & 1)) << endl;
        }
    } else {
        if(b%2) {
            cout << ((b-a+1)/2 &1) << endl;
        } else {
            cout << (((b-a)/2&1) ^ b)<< endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <list>
#include <string>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <iomanip> // setprecisionを使用するのに必要 cout << fixed << setprecision(15) << p でpを小数点以下15桁表示
using namespace std;
#define REPD(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) REPD(i, 0, n)
typedef long long ll;
#define fin(ans) cout << (ans) << '\n'
/*

*/
int main()
{
    string S;
    cin >> S;
    bool ans = true;
    REP(i,S.length()){
        if(S[i] == S[S.length()-1-i])continue;
        else{ans = false; break;}
    }
    if(!ans) fin("No");
    else fin("Yes");
    return 0;
}

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

#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, a, b) for (int i = (int)(a); i >= (int)b; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
#define rep(i, l, r) for (int i = (l); i <= (r); i++)
#define per(i, r, l) for (int i = (r); i >= (l); i--)
#define ms(x, y) memset(x, y, sizeof(x))
 
using namespace std;
 
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;
 
template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }


 
int main() {
	ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.precision(10);
    cout << fixed;
#ifdef LOCAL_DEFINE
    freopen("in", "r", stdin);
#endif
	
	 i64 a, b, k;
	 cin >> a >> b >> k;
	 i64 tmp = min(a, k);
	 a -= tmp;
	 k -= tmp;
	 tmp = min(b, k);
	 b -= tmp;
	 k -= tmp;
	 cout << a << " " << b << endl;
		
#ifdef LOCAL_DEFINE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}

Measured memory_bytes: 256
s = input()

for bit in range(1 << 3):
    ans = int(s[0])
    f = s[0]

    for i in range(3):
        if bit & (1 << i):
            ans += int(s[i + 1])
            f += "+"
        else:
            ans -= int(s[i + 1])
            f += "-"
        f += s[i + 1]
    if ans == 7:
        print(f + "=7")
        exit()

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

int no_of_paths(vector< vector<char> > square)
{ 
  int H = square.size();
  int W = square[0].size();
  
  int no_of_path[H][W];
  no_of_path[0][0] = 1;
  
  for(int i=1; i<H; i++)
  {
    if(square[i][0] == '.')
      no_of_path[i][0] = no_of_path[i-1][0]; 
    else
      no_of_path[i][0] = -1;
  }
  
  for(int j=1; j<W; j++)
  {
    if(square[0][j] == '.')
      no_of_path[0][j] = no_of_path[0][j-1]; 
    else
      no_of_path[0][j] = -1;
  }
  
  no_of_path[H-1][W-1] = 0;
  
  for(int i=1; i<H; i++)
  {
    for(int j=1; j<W; j++)
    {
      if(square[i][j] == '.')
      {
        no_of_path[i][j] = 0;
        if(square[i-1][j] == '.' && no_of_path[i-1][j] >=0)
          no_of_path[i][j] = (no_of_path[i][j]%MOD + no_of_path[i-1][j]%MOD)%MOD;
        if(square[i][j-1] == '.' && no_of_path[i][j-1] >=0)
          no_of_path[i][j] = (no_of_path[i][j]%MOD + no_of_path[i][j-1]%MOD)%MOD;
      }
      else
        no_of_path[i][j] = -1;
    }
  } 
  
  return no_of_path[H-1][W-1]%MOD;
}

int main()
{
  int H,W;
  cin >> H >> W;
  
  vector< vector<char> > square(H, vector<char>(W));
  
  for(int i=0; i<H; i++)
    for(int j=0; j<W; j++)
      cin >> square[i][j];       
  
  cout << no_of_paths(square) << endl;
  
  return 0;
}

Measured memory_bytes: 6144
import java.util.*;
import java.io.*;
public class Main
{
    public static long pow(long x,int e,long m)
    {
        long ans=1;
        while(e>0)
        {
            if(e%2!=0)
            {
                ans*=x;
                ans%=m;
                e--;
            }
            else
            {
                x=x*x;
                e/=2;
                x%=m;
            }
        }
        return ans;
    }
    public static int countSetBits(long ans)
    {
        int cntr=0;
        while(ans>0)
        {
            if((ans&1)==1)
            cntr++;
            ans>>=1;
        }
        return cntr;
    }
    public static int steps(long ans)
    {
        int bits=countSetBits(ans);
        if(bits==0)
        return 0;
        return 1+steps(ans%bits);
    }
    public static void main(String args[])throws Exception
    {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        PrintWriter pw=new PrintWriter(System.out);
        int n=Integer.parseInt(br.readLine());
        char carr[]=br.readLine().toCharArray();
        int o=0;
        for(int i=0;i<n;i++)
        if(carr[i]=='1')o++;
        int m1=o-1,m2=o+1;
        long ans1=0,ans2=0;
        for(int i=n-1;i>=0;i--)
        {
            if(m1>0)
            {
                ans1+=(carr[i]-'0')*pow(2,n-1-i,m1);
                ans1%=m1;
            }
            ans2+=(carr[i]-'0')*pow(2,n-1-i,m2);
            ans2%=m2;
        }
        for(int i=0;i<n;i++)
        {
            long ans=0;
            if(carr[i]=='0')
            {
                ans=(ans2+pow(2,n-1-i,m2))%m2;
                ans=1+steps(ans);
            }
            else
            {
                if(m1>0)
                {
                    ans=(ans1-pow(2,n-1-i,m1)+m1)%m1;
                    ans=1+steps(ans);
                }
            }
            pw.println(ans);
        }
        pw.flush();
        pw.close();
    }
}

Measured memory_bytes: 47028
# C - Colorful Leaderboard
def main():
    _ = int(input())
    a = list(map(int, input().split()))
    cnt = 0
    ans = []

    for i in a:
        if i // 400 >= 8:
            cnt += 1
        else:
            ans.append(i//400)
    else:
        ans = set(ans)
        print(max(len(ans), 1), len(ans)+cnt)



if __name__ ==  "__main__":
    main()

Measured memory_bytes: 9188
import numpy as np

n, W = map(int, input().split())
w = [0] * n
v = [0] * n
for i in range(n):
    w[i], v[i] = map(int, input().split())

dp = np.full(10**5 + 1, W + 1, dtype=np.int64)
dp[0] = 0

for i in range(n):
    dp[v[i]:] = np.minimum(dp[: - v[i]] + w[i], dp[v[i]:])

print(np.where(dp <= W)[0][-1])


Measured memory_bytes: 29092
from sys import stdin
import itertools
import math
N = int(stdin.readline().rstrip())
road = []
for _ in range(N):
    x,y = [int(x) for x in stdin.readline().rstrip().split()]
    road.append((x,y))

dist = []
for i in itertools.permutations(road):
    d = 0
    for j in range(1,N):
        d += math.sqrt((i[j-1][0]-i[j][0])**2 +  (i[j-1][1]-i[j][1])**2)
    dist.append(d)

ans = sum(dist)/math.factorial(N)
print(ans)

Measured memory_bytes: 4400
#include <iostream>
#include <vector>
#include <deque>
#include <algorithm>
#include <numeric>
#include <string>
#include <cstring>
#include <list>
#include <unordered_set>
#include <tuple>
#include <cmath>
#include <limits>
#include <type_traits>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <set>
#include <bitset>
#include <regex>
#include <random>
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
#define rep(i,n)for(ll i=0;i<n;++i)
#define exout(x) printf("%.10f\n", x)
const double pi = acos(-1.0);
const ll MOD = 1000000007;
const ll INF = 1e18;
const ll MAX_N = 201010;

//最大公約数
ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}

ll lcm(ll x, ll y) {
	if (x == 0 || y == 0)return 0;
	return (x / gcd(x, y) * y);
}

ll dx[4] = { 0,0,-1,1 };
ll dy[4] = { -1,1,0,0 };
ll ans[110][110];
bool flag[2][110];

//long longしか使わない
//素数は1より大きい
//lower_boundは指定したkey以上の要素の一番左のイテレータをかえす
//upper_boundは指定したkeyより大きい要素の一番左のイテレータをかえす
int main() {
	ll n;
	cin >> n;
	vector<ll>a(n), sum(n);
	rep(i, n) {
		cin >> a[i];
		sum[i] = a[i];
	}
	rep(i, n - 1) {
		sum[i + 1] += sum[i];
	}
	ll ans = 0;
	rep(i, n-1) {
		ll res = sum[n - 1] - sum[i];
		res %= MOD;
		ans += res * a[i];
		ans %= MOD;
		//cout << ans << endl;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 6424
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		double a=sc.nextDouble();
		double b=sc.nextDouble();
		double c=sc.nextDouble();
		double si=Math.sin(c*(Math.PI/180));
		double co=Math.cos(c*(Math.PI/180));
		double S=a*b*si/2;
		double q=Math.sqrt(a*a+b*b-2*a*b*co);
		double L=a+b+q;
		double h=S*2/a;
		System.out.println(S+"\n"+L+"\n"+h);
		sc.close();
		}
	}


Measured memory_bytes: 28024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i <= (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(ll i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

ll n, c, a[500], b[500];
string s;

int main(){
	cin.tie(0); ios::sync_with_stdio(false);
	
	ll r[500][500];//c, pow
	memset(r, 0, sizeof(r));
	rep(i, 1, 400){
		r[i][0] = 1;
		rep(j, 1, 400){
			r[i][j] = r[i][j-1]*i;
			r[i][j] %= MOD;
		}
	}
	rep(j, 0, 400){
		rep(i, 1, 400){
			r[i][j] += r[i-1][j];
			r[i][j] %= MOD;
		}
	}
	
	cin >> n >> c;
	rep(i, 1, n){cin >> a[i];}
	rep(i, 1, n){cin >> b[i];}
	
	ll dp[500][500];
	memset(dp, 0, sizeof(dp));
	dp[0][0] = 1;
	rep(t, 1, n){
		rep(ci, 0, c){
			rep(di, 0, c-ci){
				ll tmp = r[b[t]][di]+MOD-r[a[t]-1][di];
				tmp %= MOD;
				tmp *= dp[t-1][ci];
				tmp %= MOD;
				dp[t][ci+di] += tmp;
				dp[t][ci+di] %= MOD;
			}
		}
	}
	
	print(dp[n][c])
	return 0;
}

Measured memory_bytes: 4224
M = 300005
ms = Array.new(M,false)
i = 0
while i <= M
    ms[i+1] = ms[i+6] = true
    i += 7
end

p = Array.new(M,true)
p[0] = p[1] = false
2.upto(M) do |i|
    next if !ms[i]
    j = i * 2
    while j <= M
        p[j] = false
        j += i
    end
end


loop do
    n = gets.to_i
    break if n == 1
    print "#{n}:"
    6.upto(n) do |i|
        print " #{i}" if ms[i] && p[i] && n % i == 0
    end
    puts
end

Measured memory_bytes: 10780
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n; cin >> n;
	vector<int> a(n);
	for(int & v : a) cin >> v;
	int sum = accumulate(a.begin(), a.end(), 0);
	int best = 1<<30, now = 0;
	for(int i = 0; i < n - 1; i++){
		sum -= a[i];
		now += a[i];
		best = min(best, abs(sum - now));
	}
	cout << best << endl;
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for(ll i=0; i<n; i++)
#define repr(i, s, e) for(ll i=s; i>=e; i--)
#define reps(i, s, e) for(ll i=s; i<=e; i++)
#define inf 1e18
#define all(v) v.begin(),v.end()
#define vsort(v) sort(v.begin(), v.end())
#define vsortr(v) sort(v.begin(), v.end(), greater<ll>())
#define ceil(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
#define sp << " " <<
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){ fill((T*)array, (T*)(array+N), val); }
template<typename T> inline bool chmax(T &a, T b){ if(a<b){ a=b; return true; } return false; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a){ a=b; return true; } return false; }
template<typename T> void vdebug(vector<T> v){ cout << "vdebug" << endl; for(auto vv : v){ cout << vv << " "; } cout << endl; }
template<typename T> void adebug(T arr[], ll n){ cout << "adebug" << endl; reps(i, 0, n){ cout << arr[i] << " "; } cout << endl; }
template<typename T1, typename T2> void mdebug(map<T1, T2> mp){ cout << "mdebug" << endl; for(auto const& m : mp){ cout << m.first sp m.second << endl; }}
template<typename T1, typename T2> void mldebug(multimap<T1, T2> mp){ cout << "mldebug" << endl; for(auto const& m : mp){ cout << m.first sp m.second << endl; }}
template<typename T1, typename T2> void mdebugr(map<T1, T2, greater<T1>> mp){ cout << "mdebug" << endl; for(auto const& m : mp){ cout << m.first sp m.second << endl; }}
template<typename T1, typename T2> void mldebugr(multimap<T1, T2, greater<T1>> mp){ cout << "mldebug" << endl; for(auto const& m : mp){ cout << m.first sp m.second << endl; }}
void ans(bool b){ if(b) cout << "Yes" << endl; else cout << "No" << endl; }
void ans2(bool b){ if(b) cout << "YES" << endl; else cout << "NO" << endl; }
int dx[] = {1, -1, 0, 0, 1, -1, 1, -1};
int dy[] = {0, 0, 1, -1, 1, -1, -1, 1};


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

    int n;
    ll a[100010];
    ll res = 0;

    cin >> n;
    rep(i, n){
        cin >> a[i];
    }

    rep(i, n){
        res += a[i]/2;
        a[i] %= 2;
        if(a[i] > 0){
            if(i != n-1 && a[i+1] > 0){
                res++;
                a[i]--;
                a[i+1]--;
            }
        }
    }

    cout << res << endl;

    //adebug(a, n-1);

    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <map>
#include <algorithm>

using namespace std;

int main(){
  int n;
  cin >> n;
  map<long,int> A;
  for(int i=0;i<n;++i){
    long a;
    cin >> a;
    A[a]++;
  }
  auto it = A.rbegin();
  long a=0,b=0;
  while(it!=A.rend()){
    if(a!=0&&it->second>=2){
      b = it->first;
      break;
    }

    if(a==0&&it->second>=4){
      a = b = it->first;
      break;
    }else if(it->second>=2){
      a = it->first;
    }
    it++;
  }

  std::cout << a*b << std::endl;
  return 0;
}

Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int N,M,all=0;
    cin >> N >> M;
    vector<int>A(M);
    for(int i=0;i<M;i++){
        cin >> A[i];
        all += A[i];
    }
    if(all > N)cout << "-1" << endl;
    else cout << N - all << endl; 
}


Measured memory_bytes: 3604
D, G = map(int, input().split())

N = []
C = []
for _ in range(D):
    n, c = map(int, input().split())
    N.append(n)
    C.append(c)

min_answered = 100**D + 5

# それぞれの配点の問題を完全に解くか、全く解かないかを決定する
for i in range(pow(2, D)):

    points = 0
    n_answered = 0
    rest_i = []  # 完全に解かない問題

    for j in range(D):
        # 2進数とした時、1であれば完全に解くとする
        if (i >> j) & 1:
            points += N[j] * (j+1) * 100 + C[j] # 問題数 x 配点 + ボーナス
            n_answered += N[j]

        # 全く解かない
        else:
            rest_i.append(j)

    # 全く解いていない配点の問題が残っている場合
    if rest_i:
        max_i = max(rest_i)  # 未完問題の最大添え字
        max_n = N[max_i]     # 未完最大配点問題の問題数
        max_p = 100 * (max_i + 1)  # 未完最大配点問題の点数

        # 目標に満たない場合、解いていない最大配点問題を中途半端に解く
        while points < G and max_n > 0:
            points += max_p
            n_answered += 1
            max_n -= 1

    # 目標を満たす場合のみ最小問題数を更新する
    if points >= G:
        min_answered = min(min_answered, n_answered)

print(min_answered)
    

Measured memory_bytes: 3064
#include <set>
#include <string>
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <limits>
#include <map>
#include <numeric>

#define ll long long
using namespace std;
static ll imin = std::numeric_limits<ll>::min();
static ll imax = std::numeric_limits<ll>::max();
#define rep(i, n) for(int i = 0; i<n; ++i)
#define rep1(i, n) for(int i = 1; i<n; ++i)
#define rev_rep(i, n) for(int i = n - 1; i >= 0; --i)
#define range(a, i, b) for(int i = a; i <b; ++i)
#define dump(x) cout << #x << ":" << x << "\n";
#define all(v) v.begin(), v.end()
#define readll(N) ll N; cin >> N
#define readlv(N, vec) vector<ll> vec(N); rep(i, N){cin >> vec[i];}

template<class T1, class T2>
std::ostream& operator << (std::ostream& os, std::map<T1, T2>& mp);
template<class T1, class T2>
std::ostream& operator << (std::ostream& os, std::pair<T1, T2>& pair);
template<class T>
std::ostream& operator << (std::ostream& os, std::vector<T>& vec);
template<class T1, class T2>
std::ostream& operator << (std::ostream& os, std::pair<T1, T2>& pair){
  os << '(' << pair.first << ',' << pair.second << ')';
  return os;
}

template<class T>
std::ostream& operator << (std::ostream& os, std::vector<T>& vec){
  std::size_t n = vec.size();
  if(n == 0){
    return os;
  }
  os << " ";
  for(int i = 0; i<n - 1; ++i){
    os << vec[i] << " ";
  }
  os << vec[n - 1];
  os << std::endl;
  return os;
}

template<class T1, class T2>
std::ostream& operator << (std::ostream& os, std::map<T1, T2>& mp){
  std::size_t n = mp.size();
  if(n == 0){
    return os;
  }
  os << " ";
  for(auto && x:mp){
    os << x << " ";
  }
  os << std::endl;
  return os;
}

template<class T>
std::ostream& operator << (std::ostream& os, std::set<T>& mp){
  std::size_t n = mp.size();
  if(n == 0){
    return os;
  }
  os << " ";
  for(auto && x:mp){
    os << x << " ";
  }
  os << std::endl;
  return os;
}

#ifndef BOOST_TEST_MAIN
int main(int const argc, char const** argv){
  readll(N);
  readlv(N, a);

  vector<ll> dp(N);

  dp[0] = 0;
  dp[1] = abs(a[1] - a[0]);
  range(2, i, N){
    dp[i] = min(dp[i - 2] + abs(a[i] - a[i - 2]),  dp[i - 1] + abs(a[i] - a[i - 1]));
  }

  // dump(dp);
  cout << dp[N - 1];
}
#endif


Measured memory_bytes: 1792
import java.util.Arrays;
import java.util.Scanner;


public class Main {
	final static int INF = 100000000;
	final static int abmax = 10;
	
	public static void warshallFloyd(int v, int[][] d) {
		for (int k = 0; k <= v; k++) {
			for (int i = 0; i <= v; i++) {
				for (int j = 0; j <= v; j++) {
					if (i == j)
						d[i][j] = 0;
					else
						d[i][j] = Math.min(d[i][j], d[i][k] + d[k][j]);
				}
			}
		}
	}
	
	public static int length(int v, int p, int[][] d) {
		int sum = 0;
		for (int i = 0; i <= v; i++) {
			sum += d[p][i];
		}
		return sum;
	}
	
	public static void main(String[] args) {
		int[][] d  = new int[abmax][abmax];
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		
		while (n != 0) {
			int v = 0;
			int minp = 0;
			int minsum = INF;
			for (int i = 0; i < abmax; i++) {
				Arrays.fill(d[i], INF);
			}
			
			for (int i = 0; i < n; i++) {
				int a = sc.nextInt();
				int b = sc.nextInt();
				int c = sc.nextInt();
				d[a][b] = c;
				d[b][a] = c;
				v = Math.max(v, Math.max(a, b));
			}
			warshallFloyd(v, d);
			for (int i = 0; i < v; i++) {
				if (minsum > length(v, i, d)) {
					minp = i;
					minsum = length(v, i, d);
				}
			}
			System.out.println(minp + " " + minsum);
			n = sc.nextInt();
		}
		sc.close();
	}
}


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

n,k = inpl()
a = inpl()
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort(reverse = True)
    return divisors
pr = make_divisors(sum(a))
def sol(p):
    mo = []
    pl = []
    for i in a:
        if i%p != 0:
            mo += [i%p]
            pl += [p-i%p]
    mo.sort(); pl.sort()
    m = 0; c = sum(pl)
    ln = len(mo)
    for i in range(ln):
        m += mo[i]
        c -= pl[ln-i-1]
        if max(m,c) <= k and m == c:
            return True
    return False
for p in pr:
    if sol(p):
        res = p
        break
else:
    res = 1
print(res)



Measured memory_bytes: 67928
from operator import itemgetter

n,m = map(int, input().split())

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

ab.sort(key=itemgetter(1))

fall = -1
ans = 0

for i in range(m):
    if fall < ab[i][0]:
        ans += 1
        fall = ab[i][1]-1

print(ans)

Measured memory_bytes: 21320
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c,d;string s;cin>>s;a=s[0]-'0';b=s[1]-'0';c=s[2]-'0';d=s[3]-'0';
    ///#####################################################################
    if(a+b+c+d==7)
    {
        cout<<a<<"+"<<b<<"+"<<c<<"+"<<d;
    }
    else if(a-b-c-d==7)
    {
        cout<<a<<"-"<<b<<"-"<<c<<"-"<<d;
    }
    else if(a+b+c-d==7)
    {
        cout<<a<<"+"<<b<<"+"<<c<<"-"<<d;
    }
    else if(a+b-c-d==7)
    {
        cout<<a<<"+"<<b<<"-"<<c<<"-"<<d;
    }
    else if(a+b-c+d==7)
    {
        cout<<a<<"+"<<b<<"-"<<c<<"+"<<d;
    }
    else if(a-b+c-d==7)
    {
        cout<<a<<"-"<<b<<"+"<<c<<"-"<<d;
    }
    else if(a-b+c+d==7)
    {
        cout<<a<<"-"<<b<<"+"<<c<<"+"<<d;
    }
    else if(a-b-c+d==7)
    {
        cout<<a<<"-"<<b<<"-"<<c<<"+"<<d;
    }
    /////////////
    cout<<"=7\n";
}


Measured memory_bytes: 3624
import sys
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def YesNo(x): return 'Yes' if x else 'No'
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()

def get(n, rates):
    rates.sort()
    r0, a0, b0 = rates[0]
    r1, a1, b1 = rates[1]
    r2, a2, b2 = rates[2]
    if r0 >= 1:
        return n
    if r1 >= 1 or a0 == a1 == a2 or r0 == r1 == r2:
        return (n % a0) + (n // a0) * b0
    if r2 >= 1 or r1 == r2 or a1 == a2 or r0 == r1 or a0 == a1 or a0 == a2:
        if r0 == r1 or a0 == a1:
            r1, a1, b1 = r2, a2, b2
        ret = n
        for m0 in range(n // a0 + 1):
            rem = n - m0 * a0
            d = rem % a1
            tmp = d + m0 * b0 + (rem // a1) * b1
            ret = max(ret, tmp)
        return ret
    ret = n
    for m0 in range(n // a0 + 1):
        d0 = m0 * b0
        rem = n - m0 * a0
        for m1 in range(rem // a1 + 1):
            n2 = rem - m1 * a1
            d = n2 % a2
            tmp = d + d0 + m1 * b1 + (n2 // a2) * b2
            ret = max(ret, tmp)
    return ret

def main():
    N = II()
    ga, sa, ba = LI()
    gb, sb, bb = LI()
    rates = [[ga / gb, ga, gb], [sa / sb, sa, sb], [ba / bb, ba, bb]]
    rates2 = [[gb / ga, gb, ga], [sb / sa, sb, sa], [bb / ba, bb, ba]]
    ans = N
    ans = get(ans, rates)
    ans = get(ans, rates2)
    return ans

print(main())

Measured memory_bytes: 39792
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<set>
#include<tuple>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)

using namespace std;

typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef tuple<int, int, int> tiii;


template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T& t, const V& v) { t = v; }
template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T& t, const V& v) {
	for (auto& e : t) fill_v(e, v);
}


#define ARRAY_MAX 100005
int dx[4] = { 1,0,0,-1 };
int dy[4] = { 0,1,-1,0 };
const ll MOD = 1e9 + 7;
const ll INF = 1e9 + 7;

struct hoge
{
	int index;
	string name;
	int num;

};

bool comp(const hoge& a, const hoge& b) {

	if (a.name == b.name) {
		return a.num > b.num;
	}
	else
	{
		return a.name < b.name;
	}

}

int main() {

	int n;
	cin >> n;
	vector<hoge> a(n);
	for (int i = 0; i < n; i++)
	{
		cin >> a[i].name >> a[i].num;
		a[i].index = i+1;

	}
	
	sort(a.begin(), a.end(), comp);

	for (int i = 0; i < n; i++)
	{
		cout << a[i].index << endl;
	}

	return 0;

}


Measured memory_bytes: 256
#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 _ 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,vector<T>,greater<T>>;
struct before_main_function {
    before_main_function() {
        cin.tie(nullptr); ios::sync_with_stdio(0);
        cout << setprecision(15) << fixed;
        // #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

signed main() {
    int N;
    cin >> N;
    cout << N * (N - 1) / 2 << endl;
    return (0^_^0);
}



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

using namespace std;

#define FAST_IO ios_base::sync_with_stdio(0); cin.tie(0)
#define FOR(i, a, b) for(int i = (a); i <= (b); i++)
#define REP(n) FOR(O, 1, (n))
#define pb push_back
#define f first
#define s second
typedef long double ld;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
typedef vector<int> vi;
typedef vector<pii> vii;
typedef vector<ll> vl;
typedef vector<piii> viii;

const int MAXN = 500100, MAXK = 30;
const ll MOD = 1e9+7;
const ll INF = 1e18;
const ld PI = asin(1) * 2;



int main()
{
    FAST_IO;
    //ifstream in ("pump.in");
    //ofstream out ("pump.out");

    ll n, a, b; cin >> n >> a >> b;
    ll d1 = a-1, d2 = b-a, d3 = n-b;

    if (d2%2 == 0) {
        ll ans = d2/2;
        cout << ans;
        return 0;
    }

    ll ans1 = 0, ans2 = 0;
    ans1 = d1 + 1 + (d2-1)/2;
    ans2 = d3 + 1 + (d2-1)/2;
    ll ans = min(ans1, ans2);
    cout << ans;

    //in.close();
    //out.close();
    return 0;
}


Measured memory_bytes: 256
n, a, b, k = map(int,input().split())

mod = 998244353
l = 3*10**5 + 3

M = [1]  # i!のmod
m = 1
for i in range(1, l):
    m = (m * i) % mod
    M.append(m)

def pow(x, y, mod):  # x**y の mod を返す関数
    ans = 1
    while y > 0:
        if y % 2 == 1:
            ans = (ans * x) % mod
        x = (x**2) % mod
        y //= 2
    return ans

def inv(x, mod):  # x の mod での逆元を返す関数
    return pow(x, mod-2, mod)

# print(inv(8,13))

MI = [0] * (l-1) +[inv(M[l-1], mod)]  # i!の逆元
for i in range(l-2, -1, -1):
    MI[i] = MI[i+1] * (i+1) % mod

def C(x, y):  # コンビネーション
    if y < 0 or y > x:
        return 0
    ans = M[x]
    ans = (ans * MI[y]) % mod
    return (ans * MI[x-y]) % mod

ans = 0
for i in range(n+1):
    c0n = i
    c1 = k-i*a
    if c1 % b == 0 and 0 <= c1 // b <= n:
        c1n = c1 // b
        # print(c0n,c1n)
        ans = (ans + C(n, c0n) * C(n, c1n)) % mod
print(ans%mod)

Measured memory_bytes: 66288
#include <algorithm>
#include <iostream> //入出力
#include <stdio.h>
#include <map>
#include <string>
#include <math.h>
#include <vector>
#include <cstdlib>
#include <queue>
#include <stack>
#include <list>
#include <iomanip> //小数点以下を表示させる(setprecision())
//#include <bits/stdc++.h>
using namespace std;
typedef long long ll; //64bit型

#define debug(x) cerr << x << " " \
                      << "(L:" << __LINE__ << ")" << '\n'
#define PRINT(V)                                   \
        {                                          \
                for (int i = 0; i < V.size(); i++) \
                {                                  \
                        cout << V[i] << " ";       \
                }                                  \
                cout << endl;                      \
        }

int gcd(int a, int b)
{
        return b ? gcd(b, a % b) : a;
}

int main()
{
        //input->compute->output//
        int N,T;
        cin >> N>>T;

        vector<int>vec(N,10000);
        for (int i = 0; i < N; i++)
        {
                int c, t;
                cin >> c >> t;
                if(t<=T){
                        vec.push_back(c);
                }

        }
        sort(vec.begin(),vec.end());
        if(vec[0]==10000){
cout<<"TLE"<<endl;
        } else{
                cout<<vec[0]<<endl;
        }

        return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int a,b,x;
    cin>>a>>b>>x;
    int flag=0;
    for (int i=0;i<=b;i++) {
        if (a+i==x) {
            cout<<"YES"<<endl;
            flag=1;
            break;
        }
    }
    if (flag==0) {
        cout<<"NO"<<endl;
    }
}


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

int main(){
    int a[3];cin >> a[0] >> a[1] >> a[2];
    int K; cin >> K;

    sort(a, a+3);

    for (int i=0;i<K;i++){
        a[2] = 2 * a[2];
    }

    cout << a[0] + a[1] + a[2] << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i, n) FOR(i, 0, (n))
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define LAR(a, b) ((a)=max((a),(b)))
#define SML(a, b) ((a)=min((a),(b)))
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pair<int, int>> vpii;
typedef pair<int, int> pii;
#define PB push_back
#define EB emplace_back
#ifdef LOCAL_DEBUG
#define DEBUG(...) printf(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

int x[20][20];

int main(){
	int n, d; scanf("%d%d", &n, &d);
	REP(i, n) REP(j, d) scanf("%d", x[i]+j);
	int ans = 0;
	REP(i, n){
		FOR(j, i+1, n){
			int sm = 0;
			REP(k, d){
				int t = x[i][k] - x[j][k];
				sm += t*t;
			}
			int rt = (int)(sqrt(sm)) -3;
			bool ok = false;
			REP(k, 10){
				int q = rt+k;
				if(q*q==sm) ok=true;
			}
			if(ok) ans+=1;
		}
	}
	printf("%d\n", ans);
}


Measured memory_bytes: 256
import itertools
import math
N = int(input())
xy = [list(map(int, input().split())) for _ in range(N)]
waru = math.factorial(N)
ans = 0
total = 0
for i in itertools.permutations(xy, N):
    for j in range(1, N):
        total += ((i[j - 1][0] - i[j][0]) ** 2 + (i[j - 1][1] - i[j][1]) ** 2) ** 0.5

print(total / waru)

Measured memory_bytes: 3064
def solve():
    n = int(input())
    A = [int(s) for s in input().split()]
    ans = A[0]
    for i in range(1,n):
        ans = gcd(A[i], ans)
    return ans

def gcd(a,b):
    a,b = max(a,b), min(a,b)
    while b > 0:
        a,b = b,a%b
    return a
    
if __name__ == '__main__':
    print(solve())

Measured memory_bytes: 14252
/*
https://blog.csdn.net/wxh010910/article/details/80388424
考虑如何表示一个串的所有子序列，建一个类似子序列自动机的东西，
比如 000110101可以转移到 0[00110101]或者1[10101] 
其中 s[t] 表示选了 s ，要在 t 中选一个子序列。建出一个DAG之后跑DP即可。

具体DP
	f[i][j][k]
	s的长度为i
	s[t]的长度为j
	s[t]为k
	的状态数

f[0][j][k]即初始数组
考虑钦定第1位
与[t]最高位相等->f[1][j][k]
与[t]最高位不等->f[1][j-g][k'] 
	[t]的最高g位相等,k'即k去除[t]最高g位后的结果

一下wxh的代码通过控制j的枚举顺序压掉了第一维 
*/
#include <bits/stdc++.h>

using namespace std;

#define X first
#define Y second
#define mp make_pair
#define pb push_back
#define Debug(...) fprintf(stderr, __VA_ARGS__)

typedef long long LL;
typedef long double LD;
typedef unsigned int uint;
typedef pair <int, int> pii;
typedef unsigned long long uLL;

template <typename T> inline void Read(T &x) {
  char c = getchar();
  bool f = false;
  for (x = 0; !isdigit(c); c = getchar()) {
    if (c == '-') {
      f = true;
    }
  }
  for (; isdigit(c); c = getchar()) {
    x = x * 10 + c - '0';
  }
  if (f) {
    x = -x;
  }
}

template <typename T> inline bool CheckMax(T &a, const T &b) {
  return a < b ? a = b, true : false;
}

template <typename T> inline bool CheckMin(T &a, const T &b) {
  return a > b ? a = b, true : false;
}

const int N = 1048580;
const int M = 25;

int n, m, len, ans, f[M][N], g[M][N];
char s[N];

int main() {
#ifdef wxh010910
  freopen("d.in", "r", stdin);
#endif
  Read(n), Read(m);
  for (int i = 0; i <= n; ++i) {
    scanf("%s", s);
    for (int j = 0; j < 1 << i; ++j) {
      if (s[j] == '1') {
        f[i][j] = 1;
      }
    }
  }
  for (int i = 1; i <= n; ++i) {
    for (int j = 0; j < 1 << i; ++j) {
      int b = j >> (i - 1) & 1, r = 0;
      for (; r < i && (j >> i - r - 1 & 1) == b; ++r);
      g[i][j] = r == i ? -1 : r;
    }
  }
  for (int i = 0; i <= n; ++i) {
    for (int j = 1; i + j <= n; ++j) {
      for (int k = 0; k < 1 << i + j; ++k) {
        f[i][k >> j] += f[i + j][k];
        int t = g[j][k & (1 << j) - 1];
        if (~t) {
          f[i + j - t][(k >> j << j - t) | (k & (1 << j - t) - 1)] += f[i + j][k];
        }
      }
    }
    for (int j = (1 << i) - 1; ~j; --j) {
      if (f[i][j] >= m) {
        len = i, ans = j;
      }
    }
  }
  for (int i = len - 1; ~i; --i) {
    putchar((ans >> i & 1) + '0');
  }
  putchar(10);
#ifdef wxh010910
  Debug("My Time: %.3lfms\n", (double)clock() / CLOCKS_PER_SEC);
#endif
  return 0;
}

Measured memory_bytes: 101632
#include <iostream>

using namespace std;

int main(void)
{
    long long A, B, A1, B1, r, x, y, tmp; //AはBより大きくする

    cin >> A >> B;

    if(B>A){
        tmp = B;
        B = A;
        A = tmp;
    }

    A1 = A;
    B1 = B;

   r = A % B;

    while(r != 0){
        A = B;
        B = r;
        r = A % B;
    }

    cout << A1*B1/B << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
// #pragma GCC optimize("O3")
// #pragma GCC target("avx")
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto& (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define cmx(x,y) x=max(x,y)
#define cmn(x,y) x=min(x,y)
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define spair(p) cout<<#p<<": "<<p.fi<<" "<<p.se<<endl
#define sar(a,n) cout<<#a<<":";rep(pachico,n)cout<<" "<<a[pachico];cout<<endl
#define svec(v) cout<<#v<<":";rep(pachico,v.size())cout<<" "<<v[pachico];cout<<endl
#define svecp(v) cout<<#v<<":";each(pachico,v)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl
#define sset(s) cout<<#s<<":";each(pachico,s)cout<<" "<<pachico;cout<<endl
#define smap(m) cout<<#m<<":";each(pachico,m)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl

using namespace std;

typedef pair<int,int> P;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<P> vp;
typedef vector<string> vs;

const int MAX_N = 200005;

int n, a[MAX_N];

bool possible(int cri)
{
    deque<int> id, val;
    int prv = 0;
    rep(i,n){
        if(a[i] <= prv){
            int num = id.end() - upper_bound(all(id),a[i]);
            rep(j,num){
                id.pop_back(), val.pop_back();
            }
            int ind = lower_bound(all(id),a[i]) - id.begin();
            if(ind == len(id)){
                id.pb(a[i]), val.pb(1);
                prv = a[i];
                continue;
            }
            while(true){
                // id[ind] が今見ている桁
                int ima = id[ind];
                if(val[ind] < cri-1){
                    val[ind]++;
                    break;
                }
                id.pop_back(), val.pop_back();
                if(ind == 0){
                    if(ima == 1) return false;
                    id.pb(ima-1), val.pb(1);
                    break;
                }
                if(id[ind-1] < ima-1){
                    id.pb(ima-1), val.pb(1);
                    break;
                }
                ind--;
            }
        }
        prv = a[i];
    }
    return true;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    int prv = -1;
    rep(i,n){
        cin >> a[i];
        if(prv >= a[i]){
            prv = INF;
        }else{
            prv = a[i];
        }
    }
    if(prv != INF){
        cout << "1\n";
        return 0;
    }
    int l = 1, r = n;
    while(r-l>1){
        int mid = (l+r)/2;
        if(possible(mid)){
            r = mid;
        }else{
            l = mid;
        }
    }
    cout << r << "\n";
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define INF LLONG_MAX
#define Int long long
#define rep(i,n) for(int i=0; i<n; ++i)
using namespace std;
template<class T> inline bool chmin(T& a, T b) { if(a>b) {a=b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) { if(a<b) {a=b; return true;} return false;}

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

  for(int i=0; i<=N; i+=4) {
    for(int j=0; j<=N; j+= 7) {
      if(N==i+j) {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
int main(){
    int n;
    string s;
    cin >> n >> s;
    int ans=1;
    for(int i=1;i<s.size();i++){
        if(s.at(i)!=s.at(i-1))ans++;
    }
    cout << ans << endl;
}


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

int main(){

int n,t,ci,ti,menor=1001;
cin >> n >> t;

while (n>0){

cin >> ci >>ti;
n--;
if (ti<=t){
    if (ci<menor){menor=ci;}
    }
}
if (menor>1000){cout << "TLE" << endl;}
else {cout<< menor << endl;}


return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
    int x;
    ll d;
    cin >> x >> d;
    int ans = 0;
    for (int i=1; i <=x; i++){
        ll a,b;
        cin >> a >> b;
        if((a*a+b*b)<=d*d)
            ans++;
    }
    cout << ans << endl;
}

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

typedef long long int ll;

int main(){

    ll n;

    cin >> n;
    ll t;
    ll d,ans=999999999999;


    for(long long int i=1;i*i<=n;i++){
        if(n%i==0){
            d=0;
            t=n/i;
            while(t!=0){
                t/=10;
                d++;
            }
            ans=min(ans,d);
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main() {

  int n,sum,s;
  int j,i;
  int min ;
  int max;


  while(1) {

  scanf("%d",&n);
  max = -1;
  min = 1000;
  if(n == 0) break;

  for(i=0;i<n;i++) {
    sum = 0;
    for(j=0;j<5;j++) {

      scanf("%d",&s);

      sum = sum + s;
    }

      if(sum < min) min = sum;
      if(sum > max) max = sum;
  }

  printf("%d %d\n",max,min);

  }

  return 0;

}

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

using namespace std;

#define ll long long
#define vi vector<int>
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

string S;

void solve(){
    if(S.substr(0,4) == "YAKI")
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

int main(){
    cin >> S;

    solve();
}


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

int main(){
  int s[]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51
};
  int n;cin>>n;
  cout<<s[n-1];
}

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

int main() {
    string S, T;
    cin >> S >> T;
    int N = S.size(), M = T.size();
    vector<vector<int>> dp(N + 1, vector<int>(M + 1));
    rep(i, N) rep(j, M) {
        if(S[i] == T[j]) dp[i + 1][j + 1] = dp[i][j] + 1;
        else dp[i + 1][j + 1] = max(dp[i + 1][j], dp[i][j + 1]);
    }
    string ans;
    int i = N, j = M;
    while(ans.size() < dp[N][M]) {
        if(S[i - 1] == T[j - 1]) {
            ans += S[i - 1];
            i--, j--;
        } else if(dp[i][j] == dp[i][j - 1]) j--;
        else i--;
    }
    reverse(ans.begin(), ans.end());
    cout << ans << '\n';
}


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

int main(void)
{
	int stu, che, i, j;
	int a[51], b[51], c[51], d[51];
	int dis[51][51], min[51], go[51];


	//学生の数、チェックポイントの数、学生の座標、チェックポイントの座標を入力

	scanf("%d %d", &stu, &che);
	for (i = 0; i < stu; i++) {
		scanf("%d %d", &a[i], &b[i]);
	}
	for (j = 0; j < che; j++) {
		scanf("%d %d", &c[j], &d[j]);
	}

	for (i = 0; i < stu; i++) {
		for (j = 0; j < che; j++) {
			dis[i][j] = abs(a[i] - c[j]) + abs(b[i] - d[j]);
		}
		min[i] = dis[i][0];
		go[i] = 1;
	}

	for (i = 0; i < stu; i++) {
		for (j = 0; j < che; j++) {
			if (dis[i][j] < min[i]) {
				min[i] = dis[i][j];
				go[i] = j + 1;
			}
		}
		printf("%d\n", go[i]);

	}
	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <vector>
using namespace std;
long long n, ans;
void dfs(long long a, long long b, long long c, long long d) {
	if (a > n) return;
	if (b&&c&&d) { ++ans; }
	dfs(10 * a + 7, b, c, 1);
	dfs(10 * a + 5, b, 1, d);
	dfs(10 * a + 3, 1, c, d);
}
int main() {
	cin >> n;
	dfs(0, 0, 0, 0);
	cout << ans << endl;
}

Measured memory_bytes: 256