akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define FOR(i,bg,ed) for(ll i=(bg);i<(ed);i++)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007
#define int long long
using namespace std;
typedef long long ll;
typedef vector<vector<ll>> mat;
const int INF = 1e9;
typedef pair<int, int> P;
 
int N, M, R;
int r[8];
int A[50505], B[50505], C[50505];
 
const int MAX_V = 210;
const ll LLINF = LLONG_MAX / 10;
int d[MAX_V][MAX_V];
 
signed main()
{
    cin >> N >> M >> R;
    REP(i,R) {
        cin >> r[i];
        r[i] -= 1;
    }
 
    REP(i,N) REP(j,N) {
        if (i == j) d[i][j] = 0;
        else d[i][j] = LLINF;
    }
 
    REP(i,M) {
        cin >> A[i] >> B[i] >> C[i];
        A[i]--; B[i]--;
        d[A[i]][B[i]] = d[B[i]][A[i]] = C[i];
    }
 
    REP(k,N) REP(i,N) REP(j,N) {
        d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
    }
 
    sort(r, r + R);
    int ans = LLINF;
    do {
        int sum = 0;
        REP(i,R-1) {
            sum += d[r[i]][r[i+1]];
        }
        ans = min(ans, sum);
    } while (next_permutation(r, r + R));
 
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
long long n, a, b, ans;
int main (){
ios::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
cin >> n >> a >> b;
ans = a*(n/(a+b));
ans += min(a, n%(a+b));
cout << ans;
return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define fi first
#define sec second 
#define MOD 1000000007
#define pb push_back
#define test cout<<"debuged\n";
#define INF 10000000000
#define si 1000000
#define debug(x) cout<<x<<"\n";


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
  
    string s,d;
    cin>>s>>d;
    ll n=s.size(),m=d.size();
    ll dp[n+10][m+10];
    vector<char> ans;    
    for(ll i=0;i<=n;i++)
      for(ll j=0;j<=m;j++)
        dp[i][j]=0;

   for(ll i=1;i<=n;i++)
   {
    for(ll j=1;j<=m;j++)
    {
      if(s[i-1]==d[j-1])
      {
        dp[i][j]=dp[i-1][j-1]+1;
      }
      else
      {
        dp[i][j]=max(dp[i-1][j] , dp[i][j-1]);
      }
    }
  }
  ll i=n,j=m;
     while(j>0 and i>0)
     {
      if(dp[i][j]==dp[i-1][j])
      {
        i--;
      }
      else if(dp[i][j]==dp[i][j-1])
      {
        j--;
      }
      else 
      {
          ans.pb(s[i-1]);
           i--;
          j--;
      }
     }
      reverse(ans.begin(),ans.end());
      for(auto x:ans)
       cout<<x; 
}

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

using namespace std;    
typedef long long ll;
typedef pair<ll, ll> pll;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
const bool DEBUG = true;


int main(){
    

    int k;
    string s;
    cin >> k >> s;

    if( s.size() <= k ){
        cout << s << endl;
    }
    else{
        for(int i = 0; i < k; i++) cout << s[i];
        cout << "..." << endl;
    }

    return 0;
}

Measured memory_bytes: 3596
n = gets.to_i
s = gets.chomp.split("")
loop{
  fin = true
  if s.size == 1
    puts 1
    exit
  end
  (1..s.size-1).each{|i|
    if s[i] == s[i-1]
      s.delete_at(i)
      fin = false
    end
  }
  break if fin
}
puts s.size

Measured memory_bytes: 6908
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <functional>

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) 42
#endif

#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define repp(i, m, n) for(int i = m, i##_len = (n); i < i##_len; ++i)
#define reprev(i, n) for(int i = (n-1LL); i >= 0; --i)
#define all(x) (x).begin(), (x).end()
template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> P;
typedef long double ld;
typedef pair<int, string> PP;

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    map<string, int> m;
    rep (i, n) {
        string s; cin >> s; m[s]++;
    }
    string ans; 
    vector<PP> sm;
    for (auto i : m) {
        sm.emplace_back(~i.second, i.first);
    }
    sort(all(sm));
    int best = sm[0].first;
    for (auto p : sm) {
        if (best == p.first) cout << p.second << "\n";
    }
    return 0;
}


Measured memory_bytes: 28400
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define pp pop_back
#define in insert
#define ff first
#define ss second
#define  show for(int j=0;j<v.size();j++) cout<<v[j]<<" ";
#define ld long double
#define e endl
#define bc __builtin_popcount
#define MOD 1000000007
#define INT_SIZE 32
#define me(x) memset(x,0,sizeof(x))
ll fast_expo(ll x,ll p)
{if(p==0) return 1;
else if(p%2==0){ ll t=fast_expo(x,p/2)%MOD;return (t*t)%MOD;} else return (x*(fast_expo(x,p-1))%MOD)%MOD;}
int main()
{
     fast;
   int n;
   cin>>n;
   ll ans=0;
   for(int i=1;i<=n;i++)
   {
        for(int j=1;j<=n;j++)
        {
             for(int k=1;k<=n;k++)
             {
                  ans+=__gcd(k,__gcd(i,j));
             }
        }
   }
   cout<<ans<<e;
}





Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define ll long long
#define pq priority_queue
using namespace std;
const ll INF=(ll)1e9;
const ll MOD=(ll)1e9+7;
const ll MAX=510000;
vector<int> dx={1,0,-1,0},dy={0,1,0,-1};
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; }

int main(){
    ll A,B,C,D;
    cin>>A>>B>>C>>D;
    while(1){
        C-=B;
        if(C<=0){
            cout<<"Yes"<<endl;
            break;
        }
        A-=D;
        if(A<=0){
            cout<<"No"<<endl;
            break;
        }
    }
}

Measured memory_bytes: 3628
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
#include<stdio.h>
#include <cstdint>
#include <stdlib.h> 
#include <time.h>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rrep(i,n) REP(i,1,n+1)
#define all(a) a.begin(), a.end()
#define fi first
#define se second
#define RNG(x, a, n) &((x)[a]), &((x)[n])
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
typedef long long ll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> PII;
typedef vector<ll> Vl;
typedef vector<int> VI;
typedef tuple<int, int, int> TT;
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(), v.end()
#define dmp(x,y) make_pair(x,y)
#define dmt(x, y, z) make_tuple(x, y, z)
#define pb(x) push_back(x)
#define pf(x) push_front(x)
const int MAX = 500000;
const int inf = 1000000007;
const ll mod = 1000000007;
const long double PI = (acos(-1));
const long double EPS = 0.0000000001;

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


int h, n;
int a[1005], b[1005];
int dp[1005][10005];

int main() {

	cin >> h >> n;

	rrep(i, n)cin >> a[i] >> b[i];

	rrep(i, h)dp[0][i] = inf;

	rrep(i, n) {
		rrep(j, h) {
			dp[i][j] = min(dp[i - 1][j], dp[i][max(0, j - a[i])] + b[i]);
		}
	}

	cout << dp[n][h] << endl;

	return 0;
}

Measured memory_bytes: 39424
#include <bits/stdc++.h>
 
using namespace std;
 
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define fileio freopen("in.in", "r", stdin),freopen("out.out", "w", stdout);
#define ll long long int
#define FF first
#define SS second
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define pll pair<long long int,long long int>
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define pd(x) printf("%d\n",x)
#define plld(x) printf("%lld\n",x)
#define pss printf
#define MOD 1000000007
#define INF 1e18
#define eps 0.00001
#define endl '\n'
#define debug(n1) cout<<n1<<endl
ll n;
ll a[100005];
ll cnt[3];
int main() {
 
slld(n);
for(int i=1;i<=n;i++)
{
	ll x;
	slld(x);
	ll c=0;
	while(x%2==0)c++,x>>=1;
	if(c>1)c=2;
	cnt[c]++;
}
if(cnt[2]>=cnt[0] ||(cnt[2]+1>=cnt[0]&&cnt[1]==0))
	pss("Yes\n");
else
	pss("No\n");

	return 0;
           } 

Measured memory_bytes: 256
#include<cstdio>
#include<vector>
#include<algorithm>

using namespace std;

using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
using vll=vector<ll>;
using vvll=vector<vll>;


int main(void)
{
	ll n;

	while(scanf("%lld", &n)==1)
	{
		ll m;
		ll ans=n*(n+1)/2;
		m=n/3;
		ans-=m*(m+1)/2*3;
		m=n/5;
		ans-=m*(m+1)/2*5;
		m=n/15;
		ans+=m*(m+1)/2*15;
		printf("%lld\n", ans);
	}
	return 0;
}


Measured memory_bytes: 1704
#include <stdio.h>

int main (void)
{
  char s[30];
  scanf("%s",s);
  
  for(int i = 0;s[i]!='\0';i ++){
    for(int j = i+1;s[j]!='\0';j ++){
      if(s[i]==s[j]){
        printf("no");
        return 0;
      }}}
  
  printf("yes");
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
 
// Optimization
 
//#pragma GCC optimize("O3")
#define endl '\n'
 
// Shortcut
 
#define int long long
#define eb emplace_back
#define pb push_back
#define pob pop_back
#define mp make_pair
#define upb upper_bound
#define lwb lower_bound
#define fi first
#define se second
#define For(i, l, r) for (int i = l; i < r; i++)
#define ForE(i, l, r) for (int i = l; i <= r; i++)
#define Ford(i, r, l) for (int i = r; i > l; i--)
#define FordE(i, r, l) for (int i = r; i >= l; i--)
#define Fora(i, a) for (auto i : a)
 
// I/O & Debug
 
#define PrintV(a) Fora(iiii, a) cout << iiii << ' '; cout << endl;
#define PrintVl(a) Fora(iiii, a) cout << iiii << endl;
#define PrintA(a, l, r) for (int iiii = l; iiii <= r; iiii++) cout << a[iiii] << ' '; cout << endl;
#define PrintAl(a, l, r) for (int iiii = l; iiii <= r; iiii++) cout << a[iiii] << endl;
#define Ptest(x) return cout << x, 0;
#define gl(s) getline(cin, s);
#define setpre(x) fixed << setprecision(x)
/*
#define debug(args...){ string _sDEB = #args; replace(_sDEB.begin(), _sDEB.end(), ',', ' '); stringstream _ssDEB(_sDEB); istream_iterator<string> _itDEB(_ssDEB); DEB(_itDEB, args); }
void DEB(istream_iterator<string> it) {}
template<typename T, typename... Args>
void DEB(istream_iterator<string> it, T a, Args... args){
    cout << *it << " = " << a << endl;
    DEB(++it, args...);
}
*/
 
// Functions
 
//#define isvowel(a) (a == 'a' || a == 'e' || a == 'i' || a == 'o' || a == 'u')
#define bend(a) a.begin(), a.end()
#define rbend(a) a.rbegin(), a.rend()
#define mset(a) memset(a, 0, sizeof(a))
#define mset1(a) memset(a, 1, sizeof(a))
#define msetn1(a) memset(a, -1, sizeof(a))
#define msetinf(a) memset(a, 0x3f, sizeof(a))
#define gcd __gcd
#define __builtin_popcount __builtin_popcountll
//mt19937 rando(chrono::steady_clock::now().time_since_epoch().count());
 
// Data Structure
 
#define pque priority_queue
#define mts multiset
#define y0 _y0_
#define y1 _y1_
#define div divi
typedef long long ll;
typedef long double ld;
typedef vector <int> vi;
typedef vector <ll> vll;
typedef vector <ld> vld;
typedef vector <string> vs;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector <vi > vvi;
typedef vector <vll > vvll;
typedef vector <pii > vpii;
typedef vector <pll > vpll;
 
const int N = 3e5 + 5, M = 1e6 + 5, mod = 1e9 + 7, mod1 = 998244353, mod2 = 1e9 + 9, inf = 1e18 + 7;
const ll infll = 1e18 + 7;
 
int n, m, k;
int x, y, z;
int ans, cnt, tmp, idx, mx = -inf, mn = inf;
string s, t;
int a[N], b[N];
 
signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    cin >> s;
    if (s[0] == s[1] && s[1] == s[2]) cout << "No";
    else cout << "Yes";
}
 
/*
==================================+
INPUT:                            |
------------------------------    |
 
------------------------------    |
==================================+
OUTPUT:                           |
------------------------------    |
 
------------------------------    |
==================================+
*/

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll MOD = 1000000007;
constexpr ll INF = 1ll<<60;

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

ll prime_fac(ll num)
{
	ll tmp = num;
	ll res{0};

	for (ll i = 2; i*i <= num; ++i)
	{
		if (tmp%i==0)
		{
			++res;
			while (tmp%i==0)
			{
				tmp/=i;
			}
		}
	}
	if (tmp!=1) ++res;
	return res;
}

int main(int argc, char **argv)
{
	ll A, B; cin >> A >> B;
	ll g = gcd(A, B);
	// std::cout << g << std::endl;
	std::cout << 1+prime_fac(g)  << std::endl;
}

Measured memory_bytes: 256
import sys
def main():
  if 'get_ipython' not in globals():  
    # For Subsession
    N,K = map(int, input().split())
    S = sys.stdin.readline()
  else:
    # For Test
    # N = 5
    # K = 1
    # S = "00010"
    # N = 14
    # K = 2
    # S = "11101010110011"
    # N = 1
    # K = 1
    # S = "1"
    N = 5
    K = 1
    S = "11111"
    
  SC = []
  i = 0
  if S[0] == "0":SC.append(0)
  while i < N :
    if S[i] == "0":
      j = S.find("1",i)
    else:
      j = S.find("0",i)
    if j == -1: j = N 
    cnt = j - i
    i = j
    SC.append(cnt)
    
  if 'get_ipython' in globals(): print(SC)
    
  SH = []
  cnt = 0
  for i in range(len(SC)):
    cnt += SC[i]
    SH.append(cnt)
  
  if 'get_ipython' in globals(): print(SH)
  
  lenSC = len(SC) - 1
  ans = 0
  for i in range(0,lenSC+1,2):
    k = i + K * 2
    if k > lenSC:
      k = lenSC
    if i != 0:
      cnt = SH[k] - SH[i-1]
    elif k == i:
      cnt = SH[k]
    else:
      cnt = SH[k] - SH[i]
    if ans < cnt: ans = cnt

  print(ans)

main()

Measured memory_bytes: 8088
l,r=map(int,input().split())
l1=l%2019
lm=l+2019-l1

if r>lm:
    ans=0
else:
    r1=r%2019
    ans=4072324
    for x in range(l1,r1+1):
        for z in range(x+1,r1+1):
            ansnow=x*z%2019

            if ansnow<ans:
                ans=ansnow
print(ans)


Measured memory_bytes: 2940
package main

import "fmt"

// 2018
// 218
func main() {

	var n int
	fmt.Scan(&n)

	var a int
	fmt.Scan(&a)

	amari := n%500
	if amari == 0 {
		fmt.Println("Yes")
		return
	}

	if amari <= a {
		fmt.Println("Yes")
		return
	}

	fmt.Println("No")


}


Measured memory_bytes: 512
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization("unroll-loops")


/*
ID: febrian3 
LANG: C++11 
PROB: task 
*/

#include <bits/stdc++.h>
using namespace std;
#define pi acos(-1)
#define IOS ios_base::sync_with_stdio(0); cin.tie(); cout.tie();
#define fi first
#define se second
#define pf push_front
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define debug(x) cerr<<#x<<": "<<(x)<<'\n'
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1e9+7;
const ll inf = 0x3f3f3f3f;
const ll nax = 0;

int main(){
		/*freopen("filename.in","r",stdin); 
		freopen("filename.out","w",stdout);*/ 
		IOS
		bool pair=1, sw=1;
		ll n; cin >> n;
		vector<ll>arr(n+1), cnt(1e6+5, 0);
		for(int i=0;i<n;++i){
			cin >> arr[i];
			cnt[arr[i]]++;
		}
		for(int i=2;i<=1e6;++i){
			ll ans=0;
			for(int j=i;j<=1e6;j+=i){
				ans+=cnt[j];
			}
			if(ans>1) pair=0;
			if(ans>=n) sw=0;
			if(!pair && !sw) break; 
		}
		if(pair){
			cout << "pairwise coprime" << '\n';
		}
		else if(sw){
			cout << "setwise coprime" << '\n';
		}
		else cout << "not coprime" << '\n';
	}


Measured memory_bytes: 18816
(defun solve (X K D)
  (when (oddp K)
    (decf K)
    (decf X D)
    (if (minusp X) (setf X (- X))))
  (multiple-value-bind (q r)
    (floor X (* 2 D))
    (if (>= (* 2 q) K) (- X (* K D))
        (min r (abs (- r (* 2 D)))))))

(princ (solve (abs (read)) (read) (read)))

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

int main(){
    string s,t;
    cin >> s >> t;
    sort(s.begin(), s.end());
    sort(t.begin(), t.end());
    reverse(t.begin(), t.end());
    if(s < t) cout << "Yes" << endl;
    else cout << "No" << endl;
}


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

void func(
    vector<int> &pos,
    vector<vector<int>> &r, 
    vector<int> &vis, 
    vector<int> &dis,
    vector<int> &sign)
{
    vector<int> next;
    for(int i = 0; i < pos.size(); ++i)
    {
        vis[pos[i]] = 1;
        for (int j = 0; j < r[pos[i]].size(); ++j)
        {
            if(vis[r[pos[i]][j]] == 0){
                next.push_back(r[pos[i]][j]);
                vis[r[pos[i]][j]] = 1;
            }
            if(dis[r[pos[i]][j]] > dis[pos[i]]+1)
            {
                dis[r[pos[i]][j]] = dis[pos[i]]+1;
                sign[r[pos[i]][j]] = pos[i];
            }
        }
    }
    if(next.size() > 0){
        func(next, r, vis, dis, sign);
    }
}

void Main()
{
    int n, m;
    cin >> n >> m;
    // n 部屋の数
    // m 通路の数
    int a, b;
    vector<vector<int>> r(n+1, vector<int>());
    vector<int> pos(1, 1); //いま探索の起点にする部屋
    vector<int> vis(n+1, 0); //訪れたかどうか
    vector<int> dis(n+1, n+100); //最短距離
    vector<int> sign(n+1, 0); //最短の隣の部屋
    for (int i = 0; i < m; i++)
    {
        cin >> a >> b;
        r[a].push_back(b);
        r[b].push_back(a);
    }

    dis[1] = 0;
    func(pos, r, vis, dis, sign);

    cout << "Yes" << endl;
    for (int i = 2; i <= n; ++i)
    {
        cout << sign[i] << endl;
    }
    
}

int main(int argc, char **argv)
{
    Main();
    return 0;
}


Measured memory_bytes: 26800
package main

import (
	"fmt"
)

func main() {
	var N int
	fmt.Scanf("%d", &N)

	sum := 0
	for i := 1; i <= N; i++ {
		if i%3 != 0 && i%5 != 0 {
			sum += i
		}
	}
	fmt.Println(sum)
}


Measured memory_bytes: 1816
#include<bits/stdc++.h>
#define int long long 
using namespace std;
signed main()
{
	int n,k,temp=0,i,x;
	vector<int> v;
	cin>>n>>k;
	int f=n;
	while(f--)
	{
		cin>>x;
		v.push_back(x);
	}
	sort(v.begin(),v.end());
	if(k>=n)
		cout<<"0"<<endl;
	else
	{
		for(i=0;i<n-k;i++)
			temp=temp+v[i];

	
	cout<<temp<<endl;
	}
	return 0;
}

Measured memory_bytes: 2420
Number=int(input())
Ctable=list()
for i in range(Number):
    mark,rank=input().split()
    rank = int(rank)
    if mark == "S":
        Ctable.append(rank + 0)
    elif mark == "H":
        Ctable.append(rank + 13)
    elif mark == "C":
        Ctable.append(rank + 26)
    else:
        Ctable.append(rank + 39)
for i in range(1,53):
    if not(i in Ctable):
        if i<=13:
            print("S {}".format(i - 0))
        elif i<=26:
            print("H {}".format(i-13))
        elif i<=39:
            print("C {}".format(i-26))
        else:
            print("D {}".format(i-39))



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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    ll A, B, C;
    ll count = 0;
    ll temp;
    ll gedoku = 0;
    cin >> A >> B >> C;
    temp = min(B, C);
    B -= temp;
    C -= temp;
    gedoku += temp;
    count += 2 * temp;
    temp = min(A, C);
    A -= temp;
    C -= temp;
    gedoku += temp;
    count += temp;
    count += B;
    if(count - gedoku <= gedoku) count += min(1LL, C);
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 256
def main():
    arg = getInput(input())
    # arg = getInput(input())
    ans = process(arg)
    print(ans)
    
def process(arg):
    cof = list('coffee')
    if arg[2] == arg[3] and arg[4] == arg[5]:
        ans = "Yes"
    else:
        ans = "No"

    return ans

def getInput(input):
    # 行数
    n = 1
    # 戻り値
    ret = None

    if n == 1:
        pass
        # ret = input
        ret = list(input)
        # ret = int(input)
        # ret = input.split()
        # ret = list(map(int, input.split()))
        # ret = input.split('T')
    else:
        for x in range(n):
            # 取得したい形式に変換
            ret = input[x]

    return ret

if __name__ == '__main__':
    main()

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

int main(){
  int A, B, K;
  cin >> A >> B >> K;
  
  if(A > B){swap(A,B);}
  
  int count = 0;
  
  for(int i = A; i > 0; i --){
     //cout << A % i <<" "<< B % i << endl;
    if(A % i == 0 && B % i == 0){
       count++;
     
       if(count == K){cout << i << endl; return 0;}
       
       
    }
  }

  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define ll long long
#define vi vector<int>
#define vll vector<long long>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define sll set<long long>
#define si set<int>
#define stk stack<int>
#define que queue<int>
#define pb push_back
#define ff first
#define ss second
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
 
using namespace std;
 
void solve(){
    int a,b;
    cin>>a>>b;

    cout<<a*b<<endl;

}
 
int main(){
    IOS;
    int q=1;
    //cin>>q;
    while(q--){
        solve();
    }
}

Measured memory_bytes: 3604
#include <algorithm>
#include <cassert>
#include <cstring>
#include <iostream>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define TRACE(x) cout << #x << " = " << x << endl
#define _ << " _ " <<

typedef long long llint;

const int B = 31;

int main(void) {
  int n;
  scanf("%d", &n);

  int total = 0;
  int have = 0;
  REP(i, n) {
    int x;
    scanf("%d", &x);
    total ^= x;
    int diff = x ^ (x - 1);
    int j = B-1;
    while (!(diff & (1<<j))) j--;
    have |= 1<<j;
  }

  int ans = 0;
  for (int i = B-1; i >= 0; --i) {
    if (total & (1<<i)) {
      if (have & (1<<i)) {
        ans++;
        total ^= (1<<(i+1)) - 1;
      } else {
        ans = -1;
        break;
      }
    }
  }

  printf("%d\n", ans);
  return 0;
}


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

int G[100][100];
int d[100] = {0};
int f[100];
int now_time = 1;
stack<int> search_stack;

int main() {
    // 制約見て！！！デカかったらlong longにすること！
    int n, u, k, v;
    cin >> n;
    rep(i, n) {
        cin >> u >> k;
        u--;
        rep(j, k) {
            cin >> v;
            v--;
            G[u][v] = 1;
        }
    }
    rep(i,n){
        if(d[i]==0){
            search_stack.push(i);
            d[i]=now_time++;
        }
        while(search_stack.size() > 0) {
            int s = search_stack.top();
            rep(i, n + 1) {
                if(i == n) {
                    f[s] = now_time++;
                    search_stack.pop();
                }
                else if(s != i && d[i] == 0 && G[s][i] == 1) {
                    search_stack.push(i);
                    d[i] = now_time++; 
                    break;
                }
            }
        }
    }
    rep(i, n) { printf("%d %d %d\n", i + 1, d[i], f[i]); }
}


Measured memory_bytes: 3208
from collections import OrderedDict
colors = OrderedDict()
colors['black'] = [0, 0, 0]
colors['blue'] = [0, 0, 255]
colors['lime'] = [0, 255, 0]
colors['aqua'] = [0, 255, 255]
colors['red'] = [255, 0, 0]
colors['fuchsia'] = [255, 0, 255]
colors['yellow'] = [255, 255, 0]
colors['white'] = [255, 255, 255]

while True:
    color = input()
    if color == '0':
        break
    r, g, b = (int(color[1:3], 16),
               int(color[3:5], 16),
               int(color[5:7], 16))
    near_color = ['', float('inf')]
    for k, v in colors.items():
        dk = ((v[0] - r) ** 2 +
              (v[1] - g) ** 2 +
              (v[2] - b) ** 2) ** .5
        if dk < near_color[1]:
            near_color = [k, dk]
    print(near_color[0])



Measured memory_bytes: 6040
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cmath>
#include<cstdio>
#include<tuple>
#include<bitset>

using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(x) x.begin(),x.end()
#define ll long long
typedef pair<int,int> P;
const int inf=1000000007;
const int MOD=1000000007;
signed main(){
  int n;cin>>n;
  vector<int> a(n);
  rep(i,n)cin>>a[i];
  sort(a.begin(),a.end());
  bool flag=true;
  rep1(i,n-1){
    if(a[i]==a[i-1])flag=false;
  }
  	if(flag){
      cout<<"YES"<<endl;
    }
    else{
      cout<<"NO"<<endl;
    }
  return 0;
}


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

using namespace std;
using ll = long long int;
using ii = pair<int, ll>;
using li = pair<ll, int>;
using vi = vector<int>;
using vii = vector<ii>;
using graph = vector<vii>;

const ll mod =  1000000007;
const int INF = 0x3f3f3f3f;
const ll INFL = 0x3f3f3f3f3f3f3f3f;
const int MAXN = 112345;
const double pi = 3.14159265359;
const double eps = 0.000000001;
int n;
int fq[4];
double dp[901][601][301];
bool seen[901][601][301];
double sol(int f1, int f2, int f3) {
    if (f1 < 0 || f2 < 0 || f3 < 0) return 0.;
    if (!f1 && !f2 && !f3) return 1.;
    bool &is = seen[f1][f2][f3];
    double &ans = dp[f1][f2][f3];
    if (is == 1) return ans;
    ans = (f1*sol(f1-1, f2, f3) + f2*sol(f1+1, f2-1, f3) + f3*sol(f1, f2+1, f3-1) + n)/(f1+f2+f3);
    is = 1;
    return ans;
}
int main() {
    scanf("%d", &n);
    for (int i = 1, x; i<=n; ++i) {
        scanf("%d", &x);
        fq[x]++;
    }
    printf("%.9lf\n", sol(fq[1], fq[2], fq[3])-1.);
}


Measured memory_bytes: 476544
N = int(input())
c = [0,0,0,0]
for i in range(N):
    s = input()
    if s == "AC":
        c[0] += 1
    elif s == "WA":
        c[1] += 1
    elif s == "TLE":
        c[2] += 1
    else:
        c[3] += 1
print("AC x", c[0])
print("WA x", c[1])
print("TLE x", c[2])
print("RE x", c[3])

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

int main(){
  int 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];
  }
  int a = 0;
  int b = 0;
  int array[N];
  for(int i = 0; i < N; i++) {
    array[i] = i + 1;
  }
  int num = 0;
  do {
    num++;
    int suma = 0;
    int sumb = 0;
   
    for(int i = 0; i < N; i++) {
      if(P[i] == array[i]) suma++;
    }
    if(suma == N) a = num;

    for(int i = 0; i < N; i++) {
      if(Q[i] == array[i]) sumb++;
    }
    if(sumb == N) b = num;

  }while(next_permutation(array, array + N));
  
  cout << abs(a - b);
 
 return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  long long n;
  cin >> n;
  long long ans = 100;
  for (int i = 0; ; i++) {
    ans *= 1.01;
    if (ans >= n) {
      cout << i+1 << '\n';
      return 0;
    }
  }
}

Measured memory_bytes: 3640
import java.util.*;

public class Main {
    static int MOD = 1000000007;
    
    public static void main(String[] args) throws Exception {
        // Your code here! 
        Scanner sc = new Scanner(System.in);
        String str = sc.next();
        char c[] = str.toCharArray();
        int n = c.length;
        
        // dp[n][0] + dp[n][1] = n桁までで非0がm個ある数の個数
        long[][] dp = new long[n+1][2];
        dp[0][0] = 1;
        for (int i = 0; i < n; i++) {
            for (int k = 0; k < 2; k++) {
                int d = c[i] - '0';
                
                if (k == 0) {
                    if (d == 0) {
                        dp[i+1][0] += dp[i][k];
                        dp[i+1][0] %= MOD;
                    } else {
                        dp[i+1][0] += (dp[i][k] * 2) % MOD;
                        dp[i+1][0] %= MOD;
                        dp[i+1][1] += dp[i][k];
                        dp[i+1][1] %= MOD;
                    }
                } else {
                    dp[i+1][1] += (dp[i][k] * 3) % MOD;
                    dp[i+1][1] %= MOD;
                }
            }
        }
        
        System.out.println((dp[n][0] + dp[n][1]) % MOD);
    }
}

Measured memory_bytes: 29780
n = int(input())
x = input().split()
a, v = x[0], x[1]
res=""
j=0
k=0
for i in range(2*n):
	if i%2==0:
		res +=a[j]
		j +=1
	else:
		res +=v[k]
		k+=1
print(res)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
const ll INF = 1e16;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)

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

#ifdef DEBUG
template <class T, class N> void verr(const T& a, const N& n) { rep(i, n) cout << a[i] << " "; cout << "\n"; }
template<class T> void verr(const vector<T>& v){ for(auto& a : v) cout << a << " "; cout << "\n"; }
ll dbgt = 1; void err() { cout << "passed " << dbgt++ << "\n"; }
template<class H, class... T> void err(H&& h,T&&... t){ cout<< h << (sizeof...(t)?" ":"\n"); if(sizeof...(t)>0) err(forward<T>(t)...); }
#endif

void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}
//--------------------------------------------------------------------------------//
template <typename T>
struct dijkstra{
    using P = pair<T, ll>;
    const T inf = numeric_limits<T>::max();
    vector<vector<pair<ll,T>>> G;
    vector<ll> beforev;
    vector<T> dist;
    ll N, start;
    priority_queue<P, vector<P>, greater<P>> pq;

    dijkstra(ll n) : N(n) {
        G.resize(n), beforev.assign(n, -1), dist.assign(n, inf);
    }

    void add_edge(ll u, ll v, T cost){
        G[u].emplace_back(v, cost);
    }

    void init(ll s){
        start = s;
        fill(beforev.begin(), beforev.end(), -1), fill(dist.begin(), dist.end(), inf);
        dist[start] = 0, pq.emplace(0, start);
        
        while(!pq.empty()){
            T c; ll from;
            tie(c, from) = pq.top(), pq.pop();
            if (dist[from] < c) continue;
            for(auto& e: G[from]){
                ll to; T cost;
                tie(to, cost) = e;
                if(dist[to]>dist[from]+cost){
                    dist[to] = dist[from] + cost;
                    beforev[to] = from;
                    pq.emplace(dist[to], to);
                }
            }
        }
    }

    vector<ll> get_route(ll goal){
        vector<ll> route;
        ll now = goal;
        while(now!=-1){
            route.emplace_back(now);
            now = beforev[now];
        }
        reverse(route.begin(), route.end());
        return route;
    }
};
int main() {
    init();
    ll N, M, S;
    cin >> N >> M >> S;
    dijkstra<ll> dj(N);
    rep(i,M){
        ll u, v, c;
        cin >> u >> v >> c;
        dj.add_edge(u, v, c);
    }
    dj.init(S);
    rep(i,N){
        ll d = dj.dist[i];
        if(d>=INF){
            cout << "INF" << '\n';
        }
        else{
            cout << d << '\n';
        }
    }
}


Measured memory_bytes: 20068
x1, y1, x2, y2 = map(int, input().split())

a, b = x2 - x1, y2 - y1
x3, y3 = x2 - b, y2 + a
x4, y4 = x1 - b, y1 + a

print(x3, y3, x4, y4)

Measured memory_bytes: 3060
#include<vector>
#include<iostream>
#include<algorithm>
#include<functional>
#include<string>
#include<limits.h>
#include<cmath>
#include<queue>
#include<map>
#define rep(i,n) for (int i=0; i<n; i++)
using namespace std;
typedef long long ll;

ll gcd(ll a,ll b){
  ll r;
  while ((r=a%b)){a=b;b=r;}
  return b;
}

int main(){

  int n; cin >> n;
  vector<int> h(n); rep(i,n){cin >> h[i];}
  int ans=1;

  for (int i=1; i<n; i++){
    int can=1;
    for (int j=0; j<i; j++){
      if (h[j]>h[i]){can=0;break;}
    }
    if (can==1){ans++;}
  }

  cout << ans;
  

  return 0;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		List<Integer> list = new ArrayList<>();
		
		in.nextInt();
		
		
		while(in.hasNext()) {
			list.add(in.nextInt());
		}
		in.close();
		
		Collections.sort(list);
		
		int ans = 0;
		for(int i = 0; i < list.size(); i++) {
			ans += list.get(i);
			i++;
		}
		System.out.println(ans);
	}

}


Measured memory_bytes: 21972
#include<bits/stdc++.h>//only adjacent swaps allowed
using namespace std;
int p[100*1000+3];
int mark[100*1000+3];
int main(){
   int n;cin>>n;
    for(int i=1;i<=n;++i){
        cin>>p[i];
    }
    int cnt=0;
    vector<int>v;
    for(int i=1;i<=n;++i)if(p[i]==i){mark[i]=1;cnt++;}//v.pb(i);}
    if(cnt==0){cout<<"0\n";return 0;}
    else if(cnt==1){cout<<"1\n";return 0;}
    //need to find how many are adjacent 
    /*int tom=0;
    for(int i=1;i<v.size();++i){
        if(v[i]==1+v[i-1])tom++;
    }*/
    int ans=0;
    for(int i=1;i<=n;++i){
        if(mark[i]==1){
            if(i+1<=n && mark[i+1]==1){
                ans++;
                mark[i]=0;
                mark[i+1]=0;
            }else {
                ans++;
                mark[i]=0;
            }
        }
    }
    cout<<ans<<"\n";
    
    //cout<<cnt<<"\n";
    return 0;
}

Measured memory_bytes: 1024
"""nを素因数分解"""
"""2以上の整数n => [[素因数, 指数], ...]の2次元リスト"""

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

N = int(input())

if(N == 1):
    print(0)
    exit()

fact = factorization(N)

ans = 0

for _,i in fact:
    cnt = 0
    j = 0
    while(True):
        if(cnt + j + 1 > i ):
            ans += j
            break
        j += 1
        cnt += j 
        
print(ans)

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

int main(){
    int n,k;
    cin>>n>>k;
    vector<long long> x(n);
    for(int i=0;i<n;i++) cin>>x[i];

    long long ans=1e9;
    for(int i=0;i<n-k+1;i++){
        ans=min(ans,min(abs(x[i]),abs(x[i+k-1]))+abs(x[i+k-1]-x[i]));
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1024
a = str(input())
if a == 'SUN':
    print (7)
if a == 'MON':
    print (6)
if a == 'TUE':
    print (5)
if a == 'WED':
    print (4)
if a == 'THU':
    print (3)
if a == 'FRI':
    print (2)
if a == 'SAT':
    print (1)

Measured memory_bytes: 3060
MOD = 1000000007

N = int(input())
A = [tuple(map(int, input().split())) for _ in range(N)]

dp = [0 for _ in range(1 << N)]
dp[0] = 1

for i in range(1, 1 << N):
    k = 0
    for j in range(N):
        if (i >> j) & 1:
            k += 1
    for j in range(N):
        if (i >> j) & 1 and A[k - 1][j]:
            dp[i] += dp[i ^ (1 << j)]
            dp[i] %= MOD

print(dp[-1])

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

#define SIZE 300005
#define MOD 1000000007LL
#define INF INT_MAX / 3
#define LLINF 1LL << 60
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define DOWN(i,b,a) for(int i=b;i>=a;i--)
#define SET(a,c) memset(a,c,sizeof a)
#define FORALL(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define FOREACH(i,c) for(auto (i) : (c))
#define BIT(i,j) ((i)>>(j))&1
#define ALL(o) (o).begin(), (o).end()
#define ERASE(o) (o).erase(unique((o).begin(),(o).end()), (o).end())
#define SQ(x) ((x)*(x))
using namespace std;
typedef long long ll;
typedef valarray<int> Array;
typedef pair<ll,ll> Pll;
typedef pair<int, int> Pii;
typedef pair<double, double> Pdd;
template<typename T> inline void priv(vector<T>a){REP(i,a.size()){cout<<a[i];if(i==a.size()-1)cout<<endl;else cout<<" ";}}
int gcd(int a,int b){int c=max(a,b);int d=min(a,b);return c==0||d==0?c:gcd(c%d,d);}
int lcm(int a,int b){return a==0||b==0?0:a*b/gcd(a,b);}

int a[10];

bool solve()
{
  bool ans = false;
  int s = 0, t = 0;
  REP(i,10) cin >> a[i];
  REP(i,10)
  {
    if(a[i] > s) s = a[i];
    else if(a[i] > t) t = a[i];
    else return false;
  }
  return true;
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n; cin >> n;
  REP(v,n) cout << (solve()?"YES":"NO") << "\n"; 
  return 0;
}

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

ll sum(int k, vector<int> e){
    ll sum = 0;
    rep(i,k) sum += e[i];
    return sum;
}

int main(){
    int n,k;
    cin >> n >> k;
    vector<int> p(n);
    rep(i,n) cin >> p[i];
    vector<int> e(n);
    rep(i,n) e[i] = p[i]+1;
    vector<ll> s(n-k+1);
    s[0] = sum(k,e);
    ll champ = s[0];
    rep(i,n-k){
        s[i+1] = s[i] - e[i] + e[i+k];
        if (s[i+1] > champ) champ = s[i+1];
    }
    double res = (double)(champ)/2;
    
    printf("%f\n",res);
    return 0;
}

Measured memory_bytes: 4096
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<functional>
#include<queue>
#include <iomanip>
#include<map>
#include<limits>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<utility>
#include<complex>
#include<cstdlib>
#include<set>
#include<cctype>

#define DBG cerr << '!' << endl;
#define REP(i,n) for(int (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(int (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(int (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int i = 0;i < (n);i++)cerr << v[i] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()

using namespace std;

typedef long long ll;
typedef vector<int> iv;
typedef vector<iv> iiv;
typedef vector<string> sv;

#define INF 10000000000000

int a[1010],b[1010];

ll dp[1010][1010];

int main()
{
	int n,m;cin >> n >> m;
	REP(i,n)cin >> a[i+1];
	REP(i,m)cin >> b[i+1];
	
	REP(i,1010)REP(j,1010)dp[i][j] = INF;
	
	dp[1][1] = 0;
	
	for(int i = 1;i <= m+1;i++)
	{
		for(int j = 1;j <= n+1;j++)
		{
			dp[i+1][j] = min(dp[i][j],dp[i+1][j]);
			if(dp[i][j] != INF)
			{
				dp[i+1][j+1] = min(dp[i][j] + a[j]*b[i],dp[i+1][j+1]);
			}
		}
	}
	
	//SHOW2d(dp,m+2,n+2);
	
	cout << dp[m+1][n+1] << endl;
	
	return 0;
}

Measured memory_bytes: 11080
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(I,A,B) for(int I = int(A); I < int(B); ++I)
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //ai>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //ai>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=1e18+7;
const ll MOD=1e9+7;
#define pri(a) cout << (a) << endl


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

	vector<int> v(4);
	FOR(i,0,4)cin>>v[i];
	SORT(v);
	if(v[0]==1&&v[1]==4&&v[2]==7&&v[3]==9)cout << "YES" << endl;
	else cout << "NO" << endl;


}


Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
#include<queue>
using namespace std;
char str[60][60];
int key[11][60][60];
char in[60][60];
int bfs[1<<10][60][60][2];
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
int main(){
	int a,b;scanf("%d%d",&b,&a);
	for(int i=0;i<a;i++)scanf("%s",str[i]);
	int c;scanf("%d",&c);
	for(int i=0;i<c;i++){
		for(int j=0;j<a;j++)scanf("%s",in[j]);
		for(int j=0;j<a;j++)for(int k=0;k<b;k++){
			if(in[j][k]=='*')key[i][j][k]=1;
		}
	}
	queue<pair<pair<int,int>,pair<int,int> > >Q;
	for(int i=0;i<(1<<c);i++)for(int j=0;j<a;j++)for(int k=0;k<b;k++)bfs[i][j][k][0]=bfs[i][j][k][1]=-1;
	for(int i=0;i<a;i++)for(int j=0;j<b;j++)if(str[i][j]=='%'){
		bfs[0][i][j][0]=0;
		Q.push(make_pair(make_pair(0,0),make_pair(i,j)));
	}
	while(Q.size()){
		int v=Q.front().first.first;
		int f=Q.front().first.second;
		int row=Q.front().second.first;
		int col=Q.front().second.second;
		Q.pop();
		for(int i=0;i<4;i++){
			if(0<=row+dx[i]&&row+dx[i]<a&&0<=col+dy[i]&&col+dy[i]<b&&!~bfs[v][row+dx[i]][col+dy[i]][f]&&
			str[row+dx[i]][col+dy[i]]!='#'){
				int H=0;if(str[row+dx[i]][col+dy[i]]=='^'||('A'<=str[row+dx[i]][col+dy[i]]&&str[row+dx[i]][col+dy[i]]<='Z'))H=1;
				for(int j=0;j<c;j++)if((v&(1<<j))&&key[j][row+dx[i]][col+dy[i]])H=!H;
				if(str[row+dx[i]][col+dy[i]]=='|'||H==f){
					bfs[v][row+dx[i]][col+dy[i]][f]=bfs[v][row][col][f]+1;
					Q.push(make_pair(make_pair(v,f),make_pair(row+dx[i],col+dy[i])));
				}
			}
		}
		if(str[row][col]=='|'&&!~bfs[v][row][col][!f]){
			bfs[v][row][col][!f]=bfs[v][row][col][f]+1;
			Q.push(make_pair(make_pair(v,!f),make_pair(row,col)));
		}
		if('a'<=(32|str[row][col])&&(32|str[row][col])<='z'){
			int H=f;
			if(key[(32|str[row][col])-'a'][row][col])H=!H;
			int to=v^(1<<((32|str[row][col])-'a'));
			if(!~bfs[to][row][col][H]){
				bfs[to][row][col][H]=bfs[v][row][col][f]+1;
				Q.push(make_pair(make_pair(to,H),make_pair(row,col)));
			}
		}
	}
	int ret=999999999;
	for(int i=0;i<a;i++)for(int j=0;j<b;j++)if(str[i][j]=='&'){
		for(int k=0;k<(1<<c);k++){
			int H=0;
			for(int l=0;l<c;l++)if((k&(1<<l))&&key[l][i][j])H=!H;
			if(~bfs[k][i][j][H])ret=min(ret,bfs[k][i][j][H]);
		}
	}
	if(ret>99999999)printf("-1\n");
	else printf("%d\n",ret);
}

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

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

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


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

    bool isodd = true;
    ll result = 0;
    for (ll i = 0; i < N; i++)
    {
        ll tmp;
        INX(tmp);

        if(isodd && tmp % 2 != 0)
        {
            result++;
        }

        isodd = !isodd;
    }
    OUTX(result);
    

    return 0;
}


Measured memory_bytes: 3616
using System;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        int[] nm = Console.ReadLine()
            .Split()
            .Select(int.Parse)
            .ToArray();

        int n = nm[0];
        int m = nm[1];

        Shop[] shops = new Shop[n];
        for (int i = 0; i < n; i++)
        {
            int[] ab = Console.ReadLine()
                .Split()
                .Select(int.Parse)
                .ToArray();
            shops[i] = new Shop(ab[0], ab[1]);
        }
        Array.Sort(shops, (v1, v2) => (int)v1.Price - (int)v2.Price);

        long count = 0;
        long totalPrice = 0;
        int index = -1;
        for (int i = 0; i < n; i++)
        {
            if (count + shops[i].Quantity >= m)
            {
                index = i;
                break;
            }
            count += shops[i].Quantity;
            totalPrice += shops[i].Price * shops[i].Quantity;
        }

        totalPrice += shops[index].Price * (m - count);
        Console.WriteLine(totalPrice);
    }

    class Shop
    {
        public long Price;
        public long Quantity;
        public Shop(int price, int quantity)
        {
            this.Price = price;
            this.Quantity = quantity;
        }
    }
}


Measured memory_bytes: 23100
n,k = map(int,input().split())

ans = 0
for i in range(k,n+1) :
  # i個使う場合の最小値
  min_i = (i-1)*i//2
  # i個使う場合の最大値
  max_i = (n-i+1+n)*i//2
  ans += (max_i-min_i+1)
  
print(ans%(10**9+7)+1)

Measured memory_bytes: 9180
#include <iostream>
#include <cmath>

using namespace std;

int main()
{
  long double A, B, ans;
  long long trueAns;
  cin >> A;
  cin >> B;
  B = round(B * 100);
  ans = A * B;
  ans /= 100;
  trueAns = (long long)ans;
  cout << trueAns << endl;
  return 0;
}

Measured memory_bytes: 3844
#include <bits/stdc++.h>
#define maxn 200005
#define INF 0x3f3f3f3f
#define mod 1000000007
#define rep(i, a, n) for (int i=(a); i<(n); i++)
#define per(i, a, n) for (int i=(a); i>(n); i--)
typedef long long ll;
using namespace std;

void slove()
{
	set<string> st;
	string s;
	int n;
	cin >> n;
	rep(i, 0, n) cin >> s, st.insert(s), s.clear();
	cout << st.size();
}

int main()
{
	ios_base::sync_with_stdio(false); cin.tie(0);
#ifdef DEBUG
	freopen("C:\\Users\\Fish_Brother\\Desktop\\in", "r", stdin);
	//freopen("C:\\Users\\Fish_Brother\\Desktop\\out", "w", stdout);
#endif
	slove();

	return 0;
}

Measured memory_bytes: 19196
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const ll mod = 1000000007;
const ll INF = 1001001001;
const ll LINF = 1001001001001001001;

void prvec(vector<ll> vec){
    ll n = vec.size();
    rep(i,n) cout << i << " " << vec.at(i) << "\n";
}

void pr2d(vector<vector<ll>> vvec){
    ll h = vvec.size();
    ll w = vvec.at(0).size();
    rep(i,h){
        rep(j,w){
            cout << vvec.at(i).at(j) << " ";
        }
        cout << "\n";
    }
}

int main(){
    ll x; cin >> x;
    if(x>=30){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3644
#INPUT
#S

#S は長さ 4 の数字列

#長さ 4 の数字列 S が与えられます。
#あなたは、この数字列が以下のフォーマットのどちらであるか気になっています。
#YYMM フォーマット: 西暦年の下 2 桁と、月を 2 桁で表したもの 
#                (例えば 1 月なら 01) をこの順に並べたもの
#MMYY フォーマット: 月を 2 桁で表したもの 
#                (例えば 1 月なら 01) と、西暦年の下 2 桁をこの順に並べたもの
#与えられた数字列のフォーマットとして考えられるものが
#YYMM フォーマットのみである場合 YYMM を、 
#MMYY フォーマットのみである場合 MMYY を、 
#YYMM フォーマット と MMYY フォーマットのどちらの可能性もある場合
#AMBIGUOUS を、 
#どちらの可能性もない場合 NA を出力してください。

#YYMM, MMYY, AMBIGUOUS, NA のうち正しいものを出力せよ。

def isMonth(x):
    num = int(x)
    return (1 <= num and num <= 12)

def isYear(x):
    num = int(x)
    return (0 <= num and num <= 99)

def isYYMM(head, tail):
    return (isYear(head) and isMonth(tail))

def isMMYY(head, tail):
    return (isMonth(head) and isYear(tail))

S = input()
head = S[0:2]
tail = S[2:4]

if (isYYMM(head, tail) and isMMYY(head, tail)):
    res = 'AMBIGUOUS'
elif isYYMM(head, tail):
    res = 'YYMM'
elif isMMYY(head, tail):
    res = 'MMYY'
else:
    res = 'NA'

print(res)



Measured memory_bytes: 3064