akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (int i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define pb push_back
using ll = long long;
using vin=vector<int>;
using vll=vector<ll>;
using vst=vector<string>;
using P = pair<int, int>;
const int inf=1e9+7;
const ll INF=1e18;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };


int main(){cout<<fixed<<setprecision(10);
		int n;
           cin>>n;
           vin a(n);
           rep(i,0,n)cin>>a[i];
           ll ans=0;
           //a[i]が偶数の時
           rep(i,0,n){
            if(i>0){
             if(a[i-1]==1&&a[i]>0){
              a[i]--;
               ans++;
             }
            }
             ans+=a[i]/2;
             a[i]%=2;
             
             
             
           }
           cout<<ans<<endl;
}

Measured memory_bytes: 3752
#include <stdio.h>
#include <string.h>

int main(void)
{
	char str[201];
	int i,j;
	
	scanf("%[^\n]",str);
	
	i = strlen(str);
	
	for(j = 0;j < i;j++){
		if(str[j] >= 'a' && str[j] <= 'z'){
			str[j] -= 0x20;
		}
	}
	printf("%s\n",str);
	
	return(0);
}

Measured memory_bytes: 524
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main() {
  ll n;
  cin >> n;
  vector<ll> a(n);
  for (ll i = 0; i < n; i++) cin >> a[i];
  a.emplace(a.begin(), 0);
  a.emplace_back(0);
  ll ans = 0;
  for (ll i = 1; i < (ll)a.size(); i++) ans += abs(a[i] - a[i - 1]);
  for (ll i = 1; i <= n; i++) {
    cout << ans - (abs(a[i] - a[i - 1]) + abs(a[i] - a[i + 1])) +
                abs(a[i + 1] - a[i - 1])
         << endl;
  }
  return 0;
}


Measured memory_bytes: 2032
#include <cstdlib>
#include <iostream>
#include <typeinfo>
#include <bits/stdc++.h>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
  int n;
  cin >> n;
  vector<vector<int>> a(2, vector<int>(n));
  for (int i = 0; i < 2; i++)
  {
    for (int j = 0; j < n; j++)
    {
      cin >> a.at(i).at(j);
    }
  }

  vector<vector<int>> sum(2, vector<int>(n + 1));
  for (int i = 0; i < 2; i++)
  {
    for (int j = 0; j < n; j++)
    {
      sum.at(i).at(j + 1) = a.at(i).at(j) + sum.at(i).at(j);
    }
  }

  int ans = 0;
  int tmp;

  for (int i = 0; i < n;i++){
    tmp = sum.at(0).at(i + 1) + sum.at(1).at(n) - sum.at(1).at(i);
    ans = max(ans, tmp);
  }

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

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
char o[4];
char u[4];
int main() {
    scanf("%s",o);
    scanf("%s",u);
    reverse(o, o+3);
    if(strcmp(o, u) == 0) printf("YES\n");
    else printf("NO\n");
    return 0;
}

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

int main() {
  int n;
  cin>>n;
  vector<int> q(n);
  vector<int> a(n);
  vector<int> z(n-1);
  int ans=0;
  for (int i=0;i<n;++i) {
    cin>>q[i];
  }
  for (int i=0;i<n;++i) {
    cin>>a[i];
    ans+=a[i];
  }
  for (int i=0;i<(n-1);++i) {
    cin>>z[i];
  }
  for (int i=0;i<(n-1);++i) {
    if ((q[i]+1)==q[i+1]) {
      int p=q[i];
      ans+=z[p-1];
    }
  }
  cout<<ans<<endl;
}



Measured memory_bytes: 256
import sys
input = sys.stdin.readline
s = input()
s1 = int(s[:2])
s2 = int(s[2:])
isS1MM = 1 <= s1 <= 12
isS2MM = 1 <= s2 <= 12
if isS1MM and isS2MM:
    print("AMBIGUOUS")
elif not isS1MM and isS2MM:
    print("YYMM")
elif isS1MM and not isS2MM:
    print("MMYY")
else:
    print('NA')

Measured memory_bytes: 3060
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列
using namespace std;

typedef long long ll;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000 //10^12
#define MOD 1000000007 //10^9+7
#define MAXR 100000 //10^5:最大のrange(素数列挙などで使用)


typedef map<string, int> map_type;
typedef pair<string, int> value_type;

struct second_order {
  bool operator()(const value_type& x, const value_type& y) const {
    if( x.second != y.second) return x.second < y.second;
    return x.first > y.first;
  }
};

typedef priority_queue<value_type, vector<value_type>, second_order> pqueue_type;


pqueue_type map_to_pqueue(map_type m) {
    pqueue_type que;
    for(auto it=m.begin(); it!=m.end(); ++it) {
        que.push(*it);
    }
    return que;
}


int main(void){
    int a, b;
    cin >> a >> b;
    string s;
    cin >> s;
    REP(i, a) {
        if(s[i] < '0' || s[i] > '9') {
            cout << "No" << endl;
            return 0;
        } 
    }
    if(s[a] != '-') {
            cout << "No" << endl;
            return 0;
    }
    REP(i, b) {
        if(s[i+a+1] < '0' || s[i+a+1] > '9') {
            cout << "No" << endl;
            return 0;
        } 
    }
    cout << "Yes" << endl;
    
    return 0;
}


Measured memory_bytes: 256
import numpy as np
N = int(input())
schedules = [list(map(int, input().split())) for _ in range(N)]
prices = [list(map(int, input().split())) for _ in range(N)]
# print(schedules)
# print(prices)
ans = -1 * float('inf')
for i in range(1, 1 << 10):
    my_schedule = list(map(int, bin(i)[2:].zfill(10)))
    score = 0
    for j, schedule in enumerate(schedules):
        count = 0
        for k in range(10):
            if my_schedule[k] == schedule[k] and schedule[k] == 1:
                count += 1
        score += prices[j][count]
    ans = max(ans, score)
print(ans)


Measured memory_bytes: 27196
h, w = map(int, input().split())
stage = [list(map(lambda s: {'#': False, '.': True}[s], input())) for _ in range(h)]
change_dp = [[float("inf") for _ in range(w)] for _ in range(h)]
change_dp[0][0] = not stage[0][0]
attention = {(0, 0)}
while len(attention):
    next_attention = set()
    for x, y in attention:

        if x + 1 < h:
            if stage[x][y] == stage[x + 1][y]:
                parent = change_dp[x][y]
            else:
                parent = change_dp[x][y] + 1

            if parent < change_dp[x + 1][y]:
                change_dp[x + 1][y] = parent
                next_attention.add((x + 1, y))

        if y + 1 < w:
            if stage[x][y] == stage[x][y + 1]:
                parent = change_dp[x][y]
            else:
                parent = change_dp[x][y] + 1

            if parent < change_dp[x][y + 1]:
                change_dp[x][y + 1] = parent
                next_attention.add((x, y + 1))

    attention = next_attention

print((change_dp[h - 1][w - 1] + 1) // 2)

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

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

  if (N / 10 % 111 == 0) {
    cout << "Yes" << endl;
  }
  else if (N % 1000 % 111 == 0) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}


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

using namespace std;

int main(){
    int A, B, K;
    cin >> A >> B >> K;
    for (int i=A; i<min(A + K, B + 1); i++){
        cout << i << endl;
    }
    for (int i=max(B + 1 - K, A + K); i<B + 1; i++){
        cout << i << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>
#include <tuple>


using namespace std;

int main(){

	long long  N, P;
	long long ans = 1;

	cin >> N >> P;

	if(N == 1){
		cout << P << endl;
		return 0;
	}

	long long xmax = (long long)sqrt(P) + 1;
	
	for(long long x = 2; x <= xmax; x++){
		long long count = 0;
		while(1){
			if( P % x == 0){
				count++;
				P/=x;
			} else {
				break;
			}
		}
		if(count > 0){
			ans *= pow(x, count/N);
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin,(obj).end()
#define SORT(list) sort(ALL((list)));
using namespace std;
using ll = long long;
int main(){
    string dream = "dream",dreamer = "dreamer",erase = "erase",eraser="eraser";
    string s;
    cin >> s;
    reverse(s.begin(),s.end());
    reverse(dream.begin(),dream.end());
    reverse(dreamer.begin(),dreamer.end());
    reverse(erase.begin(),erase.end());
    reverse(eraser.begin(),eraser.end());

    int i=0;
    bool ok=true;
    while(true){
        if(s.substr(i,dream.length())==dream){
            i+=dream.length();
        }
        else if(s.substr(i,dreamer.length())==dreamer){
            i+=dreamer.length();
        }
        else if(s.substr(i,erase.length())==erase){
            i+=erase.length();
        }
        else if(s.substr(i,eraser.length())==eraser){
            i+=eraser.length();
        }
        else{
            cout << "NO" << endl;
            return 0;
        }
        if(i==s.length()){
            break;
        }
    }
    cout << "YES" <<endl;

    return 0;
}

Measured memory_bytes: 512
#include <cstdio>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int main()
{
    for(;;){
        int s, d, m; // 甘味セットの種類、期間、予算
        if(!(cin >> s >> d >> m))
            return 0;
        
        vector<vector<int> > w(s), p(s); // 体重、値段
        for(int i=0; i<s; ++i){
            int k;
            cin >> k;
            w[i].resize(k);
            p[i].resize(k);
            for(int j=0; j<k; ++j)
                cin >> w[i][j] >> p[i][j];
        }

        vector<int> f(d);
        for(int i=0; i<d; ++i)
            cin >> f[i];

        vector<int> dp(m+1, 0);
        for(int i=0; i<d; ++i){
            vector<int> w2 = w[f[i]];
            vector<int> p2 = p[f[i]];
            int n = w2.size();

            for(int j=0; j<n; ++j){
                for(int k=0; k<=m; ++k){
                    if(k - p2[j] >= 0)
                        dp[k-p2[j]] = max(dp[k-p2[j]], dp[k] + w2[j]);
                }
            }
        }

        cout << dp[0] << ' ';
        int ret;
        for(int i=0; i<=m; ++i){
            if(dp[i] == dp[0])
                ret = m - i;
        }
        cout << ret << endl;
    }
}

Measured memory_bytes: 1244
cards={ 'S':[0]*13, 'H':[0]*13, 'C':[0]*13, 'D':[0]*13 } 

n=int(input()) 

for _ in range(n): 
	suit,val=input().split() 
	cards[suit][int(val)-1]=1 

for x in["S","H","C","D"]: 
	for y in range(13): 
		if cards[x][y]==0: 
			print(x,y+1)


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

int main()
{
  string a, b;
  cin >> a >> b;
  int n = stoi(a+b);
  for(int i = 1; i*i <= n; ++i){
    if(i*i == n){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
#define rep(i,a,b) for(int i=a;i<=b;i++)
const int N=1e2+5;
const int mod=1e9+7;
int a,b,f[N];
int main()
{
	rep(i,0,100)
	{
		rep(j,0,100)
		{
			int k=i*4+j*7;
			if(k<=100)f[k]=1;
			else continue;
		}
	}
	cin>>a;
	if(f[a])cout<<"Yes";
	else cout<<"No";
	return 0;
}


Measured memory_bytes: 256
//C
#include <cassert>
//#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>

//ここまで標準include

using namespace std;

long aCb(long a, long b) {
	long out = 1;
	for (long i = 1; i <= b; i++) {
		out = out * (a + 1 - i) / i;
	}
	return out;
}

int main() {
	int p, q, r;
	cin >> p >> q >> r;
	vector<int>data = { p, q, r };
	sort(data.begin(), data.end());
	cout << data[0] + data[1] << endl;
}


Measured memory_bytes: 256
/*
░░░░░▄▀▀▀▄░░░░░░░░░░░░░░░░
▄███▀░◐░░░▌░░░░░░░░░░░░░░
░░░░▌░░░░░▐░░░░░░░░░░░░░░░
░░░░▐░░░░░▐░░░░░░░░░░░░░░░
░░░░▌░░░░░▐▄▄░░░░░░░░░░░░░
░░░░▌░░░░▄▀▒▒▀▀▀▀▄░░░░░░░░
░░░▐░░░░▐▒▒▒▒▒▒▒▒▀▀▄░░░░░░
░░░▐░░░░▐▄▒▒▒▒▒▒▒▒▒▒▀▄░░░░
░░░░▀▄░░░░▀▄▒▒▒▒▒▒▒▒▒▒▀▄░░
░░░░░░▀▄▄▄▄▄█▄▄▄▄▄▄▄▄▄▄▄▀▄
░░░░░░░░░░░▌▌░▌▌░░░░░░░░░░
░░░░░░░░░░░▌▌░▌▌░░░░░░░░░░
░░░░░░░░░▄▄▌▌▄▌▌░░░░░░░░░░
*/

#include <bits/stdc++.h>

using namespace std;

#define boost 			ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define all(a) 			(a).begin(), (a).end()
#define sz(a) 			(int)(a).size()
#define FOR(a, b, c) 	for (int a = (b); a <= (c); a++)
#define FORR(a, b, c) 	for (int a = (b); a >= (c); a--)
#define ELO 			exit(0)
#define eb 				emplace_back
using ll = 				long long;
using ld = 				long double; // 'long double' is 2.2 times slower than double
using pii = 			pair<int, int>;
using pll = 			pair<ll, ll>;
using vi = 				vector<int>;
using vll = 			vector<ll>;

constexpr int MOD = 1e9 + 7; // 998244353
constexpr int INF = INT_MAX;
constexpr ll LLINF = LLONG_MAX;

template <class T> inline bool setmin(T &a, T b){if (a > b)return a = b, 1;return 0;}
template <class T> inline bool setmax(T &a, T b){if (a < b)return a = b, 1;return 0;}

namespace fastio {
	template <class T> istream &operator>>(istream &os, vector<T> &container){for (auto &u : container)os >> u;return os;}
	template <class T> ostream &operator<<(ostream &os, const vector<T> &container){for (auto &u : container)os << u << " ";return os;}
	template<class T1, class T2> inline istream& operator >> (istream& os, pair<T1, T2>& p) { return os >> p.first >> p.second; }
	template<class T1, class T2> ostream& operator << (ostream& os, const pair<T1, T2>& p) { return os << p.first << " " << p.second; }
}
using namespace fastio;

namespace debug {
	template < typename _T > inline void _debug(const char *s, _T x) { cerr << s << " = " << x << "\n"; }
	template < typename _T, typename... args > void _debug(const char *s, _T x, args... a) { while(*s != ',') cerr << *s++; cerr << " = " << x << ','; _debug(s + 1, a...); }
	
	#if 1
	#define debug(...) _debug(#__VA_ARGS__, __VA_ARGS__)
	#define cerr cout
	#else
	#define debug(...) 69
	#define cerr if(0) cout
	#endif
}
using namespace debug;

//////////////_________CODE_________//////////////

// jeszcze na chwilke spojrz na dol

const int N = 2e5 + 7;
int c[N];
ll dp[N];

int main(){// jeszcze na chwilke spojrz na dol
	boost;
    int m;
    cin >> m;
    int n = 0, pre = -1;

    FOR(i, 1, m) {
        int a;
        cin >> a;
        if(a != pre) {
            pre = a;
            c[n++] = a;
        }
    }

    dp[c[0]] = 1;
    ll res = 1;
    FOR(i, 1, n - 1) {
        ll teraz = res;
        res += dp[c[i]];
        res %= MOD;
        dp[c[i]] += teraz;
        dp[c[i]] %= MOD;
    }

    cout << res << "\n";

	ELO;
}// jeszcze na chwilke spojrz na dol


/*
Ty a na 100% wszystko mam dobrze ?
Na 100% hmmm ?
zadnego int*int >1e9 nie ma tak ?
a to 1e5 * 1e5 ? 
A jakis krytyczny przypadek hmm ? jakies n=1 ? hmm ?

We no zamiast nic nie robic to we cos zrob typie

zeby nie było "DomiKo zjazd" :C
*/

Measured memory_bytes: 2560
# -*- coding: utf-8 -*-
"""
Created on Sun Jun  2 20:33:28 2019

@author: Yamazaki Kenichi
"""

S = input()

T = []

i = 0
while i < len(S):
    if S[i] == 'A':
        T += [1]
        i += 1
    elif i < len(S) - 1 and S[i] == 'B' and S[i+1] == 'C':
        T += [2]
        i += 2
    else:
        T += [0]
        i += 1
#    print(i,S[i],T)

ans = 0
countA = 0
for c in T:
    if c == 1:
        countA += 1
    elif c == 2:
        ans += countA
    else:
        countA = 0
print(ans)

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

int main(){
	string s;	cin>>s;
	string weeks[7]={"SUN","MON","TUE","WED","THU","FRI","SAT"};

	for(int i=0;i<7;i++){
		if(weeks[i]==s){
			cout<<7-i<<endl;
			return 0;
		}
	}
	

	return 0;
}


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

using namespace std;

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

int main() {
    int N;
    int a[100000];
    int gcd_lower[100000] = {0};
    int gcd_upper[100000] = {0};
    int ans = 0;


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

    for (int i = 1; i < N; i++) {
        gcd_lower[i] = gcd(gcd_lower[i-1], a[i-1]);
    }

    for (int i = N-2; i >= 0; i--) {
        gcd_upper[i] = gcd(gcd_upper[i+1], a[i+1]);
    }

    for (int i = 0; i < N; i++) {
        ans = max(ans, gcd(gcd_lower[i], gcd_upper[i]));
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<ll, ll>;
using vi = vector<ll>;
using vvi = vector<vi>;
using vb = vector<bool>;
using vs = vector<string>;
using vp = vector<pii>;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define sz(x) (ll)((x).size())
#define all(x) (x).begin(), (x).end()
#define each(a, x) for (auto&& a : (x))
#define _overload4(_1, _2, _3, _4, name, ...) name
#define rep1(n) rep2(_, n)
#define rep2(i, n) rep3(i, 0, n)
#define rep3(i, a, n) rep4(i, a, n, 1)
#define rep4(i, a, n, s) for (ll i = (a); i < (n); i += (s))
#define rep(...) _overload4(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
const int INF = 1e9;
const int MOD = 1e9 + 7;
const double EPS = 1e-9;
const double PI = acos(-1.0);
const int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
const int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
template<typename T> inline void print(const T& x) {cout << x << "\n";}
template<typename T> inline bool chmax(T& a, const T& b) {if (a < b) a = b; return a < b;}
template<typename T> inline bool chmin(T& a, const T& b) {if (a > b) a = b; return a > b;}
struct Init {Init() {cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(10);}} init;

int main() {
    ll h, n;
    cin >> h >> n;
    vi a(n), b(n);
    rep(i, n) cin >> a[i] >> b[i];

    vvi dp(n + 1, vi(h + 1, INF));
    dp[0][0] = 0;

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

    print(dp[n][h]);
}

Measured memory_bytes: 81572
s=input()

if s=='SUN':
    ans='7'
elif s=='MON':
    ans='6'
elif s=='TUE':
    ans='5'
elif s=='WED':
    ans='4'
elif s=='THU':
    ans='3'
elif s=='FRI':
    ans='2'
elif s=='SAT':
    ans='1'

print(ans)

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

int main ()
{
  int row , s ;
  cin>> s;
  string arr[s];
  cin>> row ;
  for (int i=0 ; i < s ; i++){
      cin>>arr[i];
  }
  for (int i=0 ; i < s ; i++){
      cout << arr[i]<<endl;
      cout << arr[i]<<endl;}
     
  return 0;
}

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

int main(){
    int N;
    cin >> N;
    int ans;
    
    ans = N*N*N;
    cout << ans << endl;

    return 0;
}


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

#define N 4
#define S 16

typedef struct P{
  int f[S],space,m;
}Puzzle;

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

int MDT[S][S];

int limit;
int path[100];
Puzzle st;

int get(Puzzle Z){
  int i,sum=0;
  for(i=0;i<S;i++){
    if(Z.f[i] == S) continue;
    sum+=MDT[i][Z.f[i]-1];
  }
  return sum;
}

int max(int a,int b){
  if(a<b) return b;
  else return a;
}
int min(int a,int b){
  if(a<b) return a;
  else return b;
}
void swap(int *a,int *b){
  int t;
  t=*a;
  *a=*b;
  *b=t;
}

char dfs(int df,int p){
  int sx,sy,tx,ty,i;
  Puzzle tmp;

  if(st.m==0)return 1;
  if(df+st.m>limit)return 0;

  sx=st.space/N;
  sy=st.space%N;

  for(i=0;i<4;i++){
    tx=sx+dx[i];
    ty=sy+dy[i];

    if(tx<0||tx>=N||ty<0||ty>=N) continue;
    if(max(p,i)-min(p,i)==2)continue;
    tmp=st;

    st.m-=MDT[tx*N+ty][st.f[tx*N+ty]-1];
    st.m+=MDT[sx*N+sy][st.f[tx*N+ty]-1];

    //printf("st.m=%d\n",st.m);

    swap(&st.f[tx*N+ty],&st.f[sx*N+sy]);

    st.space=tx*N+ty;
    if(dfs(df+1,i)){
      path[df]=i;
      return 1;
    }
    st=tmp;
  }
  return 0;
}

int id(Puzzle in){
  int i;
  int ans=0;

  in.m=get(in);

  for(limit=in.m;limit<=100;limit++){
      //  printf("aaa\n");
    st=in;
    if(dfs(0,-100)){
      ans=0;;
      for(i=0;i<limit;i++) ans++;
      return ans;
    }
  }
  return -1;
}

int main(){
  int i,j;
  Puzzle in; 
  for(i=0;i<S;i++) for(j=0;j<S;j++) MDT[i][j]=abs(i/N-j/N)+abs(i%N-j%N);
  for(i=0;i<S;i++){
    //printf("aaa\n");
    scanf("%d",&in.f[i]);
    if(in.f[i]==0){
      in.f[i]=S;
      in.space=i;
    }
  }
  printf("%d\n",id(in));

  return 0;
}











Measured memory_bytes: 2104
N=int(raw_input())

S = ["" for i in range(N)]
T = [0 for i in range(N)]

for i in range(N):
    s = raw_input().split()
    S[i] = s[0]
    T[i] = int(s[1])

#print S, T

X = raw_input()

sleep = 0
time = 0
for i in range(N):
    if sleep == 1:
        time += T[i]
    elif S[i] == X:
        sleep = 1

print time


Measured memory_bytes: 2568
#include <stdio.h>

int main() {
    int x, y, z, temp;
    scanf("%d %d", &x, &y);
    
    if (x <= y) {       // swap
        temp = x;
        x = y;
        y = temp;
    }
    
    while (y > 0) {     // euclidean algorithm
        z = x % y;
        x = y;
        y = z;
    }
    
    printf("%d\n", x);
    return 0;
}



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

#ifdef _DEBUG
#define debug(x) cout<<#x<<": "<<x<<endl
#else
#define debug(x)
#endif

using namespace std;

#define mp make_pair

constexpr int64_t M = 1e9 + 7;

int64_t modpow(int64_t n, int64_t m) {
    if (m == 0) return 1;
    else if (m % 2 == 0) {
        int64_t r = modpow(n, m / 2);
        return (r * r) % M;
    } else {
        int64_t r = modpow(n, m / 2);
        return ((n * r) % M * r) % M;
    }
}

long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

int main() {
    int N;
    cin >> N;
    vector<int> as;
    for (int i = 0; i < N; ++i) {
        int ai;
        cin >> ai;
        as.push_back(ai);
    }
    vector<bool> is_prime(1001, true);
    is_prime[0] = is_prime[1] = false;
    for (int i = 2; i * i <= is_prime.size(); ++i) {
        if (is_prime[i]) {
            for (int j = i + i; j < is_prime.size(); j += i) {
                is_prime[j] = false;
            }
        }
    }
    vector<int> ps;
    for (int i = 0; i < is_prime.size(); ++i) {
        if (is_prime[i]) ps.push_back(i);
    }
    vector<int> prime_vec_max(1000001, 0);
    for (int i = 0; i < N; ++i) {
        int ai = as[i];
        vector<pair<int, int>> primes;
        while (ai != 1) {
            bool cont = false;
            for (const auto& p : ps) {
                if (ai % p == 0) {
                    if (primes.size() == 0 || primes.back().first != p) {
                        primes.push_back(make_pair(p, 1));
                    } else {
                        primes.back().second++;
                    }
                    ai /= p;
                    cont = true;
                    break;
                }
            }
            if (!cont) {
                if (primes.size() == 0 || primes.back().first != ai) {
                    primes.push_back(make_pair(ai, 1));
                } else {
                    primes.back().second++;
                }
                break;
            }
        }
        for (const auto kv : primes) {
            prime_vec_max[kv.first] = max(prime_vec_max[kv.first], kv.second);
        }
    }
    int64_t p = 1;
    for (int i = 0; i < prime_vec_max.size(); ++i) {
        if (i != 0) {
            p = (p * modpow(i, prime_vec_max[i])) % M;
        }
    }
    int64_t res = 0;
    for (const auto a : as) {
        res = (res + modinv(a, M)) % M;
    }
    cout << (p * res) % M << endl;
}

Measured memory_bytes: 4224
#include "stdio.h"
#include "stdlib.h"
#include <iostream>
#include <vector>

using namespace std;

#define INF (int)(1e9)

int mb[10];
int ms[10];
int m[10][100];
int mk;
int mmb[10];
int mms[10];
int mm[10][100];
int mmk;
int n[10][100];

vector<pair<int,int> > isi[150];

int main()
{
	while(1)
	{
		int nn,mn;
		scanf("%d %d",&nn,&mn);
		if(nn == 0 && mn == 0)
		{
			break;
		}
		for(int i = 0; i < nn; i++)
		{
			int k;
			scanf("%d",&k);
			for(int ii = 0; ii < k; ii++)
			{
				int x,d;
				scanf("%d %d",&x,&d);
				isi[i].push_back(make_pair(x,d));
			}
		}
		for(int i = 0; i < isi[0].size(); i++)
		{
			mb[i] = isi[0][i].first;
			ms[i] = 0;
			mmb[i] = isi[0][i].first;
			mms[i] = 0;
			for(int ii = 0; ii <= mn; ii++)
			{
				m[i][ii] = 0;
				mm[i][ii] = 0;
			}
		}
		mk = isi[0].size();
		mmk = isi[0].size();
		for(int i = 0; i < nn; i++)
		{
			if(i == 1)
			{
				for(int ii = 0; ii < isi[i].size(); ii++)
				{
					for(int iii = 0; iii <= mn; iii++)
					{
						mm[ii][iii] = 0;
					}
					mmb[ii] = isi[i][ii].first;
					mms[ii] = isi[i][ii].second;
				}
				mmk = isi[i].size();
			}
			for(int ii = 0; ii < isi[i].size(); ii++)
			{
				for(int iii = 0; iii <= mn; iii++)
				{
					int min = INF;
					for(int j = 0; j < mk; j++)
					{
						if(min > m[j][iii] + (ms[j] + isi[i][ii].second) * abs(mb[j] - isi[i][ii].first))
						{
							min = m[j][iii] + (ms[j] + isi[i][ii].second) * abs(mb[j] - isi[i][ii].first);
						}
					}
					n[ii][iii] = min;
				}
				for(int iii = 0; iii < mn; iii++)
				{
					int min = INF;
					for(int j = 0; j < mmk; j++)
					{
						if(min > mm[j][iii] + (mms[j] + isi[i][ii].second) * abs(mmb[j] - isi[i][ii].first))
						{
							min = mm[j][iii] + (mms[j] + isi[i][ii].second) * abs(mmb[j] - isi[i][ii].first);
						}
					}
					if(n[ii][iii + 1] > min)
					{
						n[ii][iii + 1] = min;
					}
				}
			}
			for(int ii = 0; ii < mk; ii++)
			{
				for(int iii = 0; iii <= mn; iii++)
				{
					mm[ii][iii] = m[ii][iii];
				}
				mmb[ii] = mb[ii];
				mms[ii] = ms[ii];
			}
			mmk = mk;
			for(int ii = 0; ii < isi[i].size(); ii++)
			{
				for(int iii = 0; iii <= mn; iii++)
				{
					m[ii][iii] = n[ii][iii];
				}
				mb[ii] = isi[i][ii].first;
				ms[ii] = isi[i][ii].second;
			}
			mk = isi[i].size();
		}
		int allmin = INF;
		for(int i = 0; i < mmk; i++)
		{
			for(int ii = 0; ii < mn; ii++)
			{
				if(allmin > mm[i][ii])
				{
					allmin = mm[i][ii];
				}
			}
		}
		for(int i = 0; i < mk; i++)
		{
			for(int ii = 0; ii <= mn; ii++)
			{
				if(allmin > m[i][ii])
				{
					allmin = m[i][ii];
				}
			}
		}
		printf("%d\n",allmin);
		for(int i = 0; i < nn; i++)
		{
			isi[i].clear();
		}
	}
	return 0;
}

Measured memory_bytes: 1232
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <math.h>
#include <bitset>
#include <queue>
#include <set>
#include <iomanip>
#include <math.h>
#include <assert.h>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr long long int infll = 1001001001001001LL;
constexpr int INF = 1000000007;
constexpr int inf = 1000000007;
const int mod = 1000000007;

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

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

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

inline double nCr(const int n, int r)
{
    if (n == 0)
    {
        return 0;
    }
    if (r == 0)
    {
        return 1;
    }
    if (r == 1)
    {
        return n;
    }
    if (n == r)
    {
        return 1;
    }

    if (r > n / 2)
    {
        r = n / 2;
    }

    double result = 1;
    for (double i = 1; i <= r; i++)
    {
        result *= (n - i + 1) / i;
    }

    return (result);
}

template <typename T>
T seinomi(T a)
{
    if (a > 0)
    {
        return a;
    }
    else
    {
        return 0;
    }
}

template <typename T>
map<T, T> soinsuubunkai(T n) //連想配列[素因数f.first][個数f.second]
{
    map<T, T> ret;
    for (T i = 2; i * i <= n; i++)
    {
        while (n % i == 0)
        {
            ret[i]++;
            n /= i;
        }
    }
    if (n != 1)
        ret[n] = 1;
    return ret;
}

template <typename T>
T ketasuu(T num)
{
    return std::to_string(num).length();
}

int kaizyou(int k)
{
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}

template <class ForwardIt, class T>
void iota(ForwardIt first, ForwardIt last, T value)
{
    while (first != last)
    {
        *first++ = value;
        ++value;
    }
}

//nの階乗を計算
int factorial(int n)
{
    int answer = 1;
    while (n > 1)
    {
        answer *= n;
        n--;
    }
    return answer;
}
int comb(int n, int r)
{
    return factorial(n) / (factorial(r) * factorial(n - r));
}

long long modpow(long long a, long long n, long long mod)
{
    long long res = 1;
    while (n > 0)
    {
        if (n & 1)
            res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

//小数点以下10桁テンプレート（main関数内の最初に貼付け）
//std::cout << std::fixed << std::setprecision(10);

//----------------------------------------------------------------


int main(){
ll x,y;
ll a=0,b=0,c=0;
cin>>x>>y;
if(x==2){
    c++;
}else if(x==4||x==6||x==9||x==11){
b++;
}
else{
    a++;
}

if(y==2){
    c++;
}else if(y==4||y==6||y==9||y==11){
b++;
}
else{
    a++;
}
if(a==2||b==2||c==2){
    cout<<"Yes"<<endl;
}else{
    cout<<"No"<<endl;
}
}









Measured memory_bytes: 256
import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;

import static java.lang.Math.*;
import static java.util.Arrays.*;

public class Main {

	Scanner sc = new Scanner(System.in);

	HashMap<String, Integer> map;
	String s;
	boolean unknown;

	void run() {
		map = new HashMap<String, Integer>();
		for (;;) {
			String s = sc.next();
			if (s.equals("END_OF_FIRST_PART")) {
				break;
			}
			int n = sc.nextInt();
			map.put(s, n);
		}
		for (;;) {
			s = sc.next();
			if (s.equals("0")) {
				break;
			}
			s += '\0';
			unknown = false;
			Result r = molecule(0);
			println(unknown ? "UNKNOWN" : r.value + "");
			debug(r.p, r.value);
		}
	}

	Result molecule(int p) {
		debug("molecule", p);
		Result r = new Result(p, 0);
		for (;;) {
			if (s.charAt(r.p) == '\0' || s.charAt(r.p) == ')') {
				return r;
			} else if (s.charAt(r.p) == '(') {
				Result r1 = molecule(r.p + 1);
				debug("MOLECULE", r1.p, r1.value);
				Result r2 = number(r1.p + 1);// skip '('
				debug("NUMBER", r2.p, r2.value);
				r.value += r1.value * r2.value;
				r.p = r2.p;
			} else {
				Result r1 = atom(r.p);
				debug("ATOM", r1.p, r1.value);
				Result r2 = number(r1.p);
				debug("NUMBER", r2.p, r2.value);
				r.value += r1.value * r2.value;
				r.p = r2.p;
			}
		}
	}

	Result atom(int p) {
		debug("atom", p);
		String atom = "";
		if (Character.isUpperCase(s.charAt(p))) {
			atom += s.charAt(p);
			p++;
			if (Character.isLowerCase(s.charAt(p))) {
				atom += s.charAt(p);
				p++;
			}
		}
		debug(atom);
		if (map.containsKey(atom)) {
			return new Result(p, map.get(atom));
		} else {
			unknown = true;
			debug("UNKNOWN", p, atom);
			return new Result(p, -1);
		}
	}

	Result number(int p) {
		debug("number", p);
		int value = 0;
		if (Character.isDigit(s.charAt(p))) {
			value = s.charAt(p) - '0';
			p++;
			if (Character.isDigit(s.charAt(p))) {
				value = value * 10 + s.charAt(p) - '0';
				p++;
			}
		} else {
			return new Result(p, 1);
		}
		return new Result(p, value);
	}

	class Result {
		int p, value;

		Result(int p, int value) {
			this.p = p;
			this.value = value;
		}
	}

	void debug(Object... os) {
		// System.err.println(Arrays.deepToString(os));
	}

	void print(String s) {
		System.out.print(s);
	}

	void println(String s) {
		System.out.println(s);
	}

	public static void main(String[] args) {
		// System.setOut(new PrintStream(new BufferedOutputStream(System.out)));
		new Main().run();
	}
}

Measured memory_bytes: 12000
#!/usr/bin/python3

import array
import math
import os
import sys


def main():
    A, B, X = read_ints()
    print(solve(A, B, X))


def solve(A, B, X):
    if A * A * B == X:
        return 0

    xa = X / A
    lb = 0.0
    ub = 90.0
    while ub - lb > 1e-12:
        mid = (ub + lb) / 2
        dprint(mid)
        theta = mid / 180 * math.pi
        dprint(theta)
        tan = math.tan(theta)
        if tan < B / A:
            a = A * B - A * A / 2 * tan
        else:
            a = B * B / 2 / tan
        dprint(a, xa)
        if a > xa:
            lb = mid
        else:
            ub = mid

    return (ub + lb) / 2


###############################################################################
# AUXILIARY FUNCTIONS

DEBUG = 'DEBUG' in os.environ


def inp():
    return sys.stdin.readline().rstrip()


def read_int():
    return int(inp())


def read_ints():
    return [int(e) for e in inp().split()]


def dprint(*value, sep=' ', end='\n'):
    if DEBUG:
        print(*value, sep=sep, end=end)


if __name__ == '__main__':
    main()


Measured memory_bytes: 38384
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
#define rad M_PI/3
#define N 200001
#define Max 10000

void swap(int *a,int *b){
    int tmp =*a;
    *a=*b;
    *b=tmp;
}
int partition(int *A,int p, int r){
    int x = A[r];
    int i = p;
    for(int j=p;j<r;j++){
        if(A[j]<=x){
            swap(&A[i++],&A[j]);
        }
    }
    swap(&A[i],&A[r]);
    for(int j=p;j<=r;j++){
        if(j>p) {
            printf(" ");
        }
        if(j==i){
            printf("[%d]",A[j]);
        }else{
            printf("%d",A[j]);
        }
    }
    printf("\n");
}
int main()
{
    int n;
    int A[N];
    int p=0;
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%d",&A[i]);
    }
    partition(A,p,n-1);

  return 0;
}


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

int main()
{
  int x[3][3];
  rep(i,3)
  {
    rep(j,3) cin >> x[i][j];
  }
  
  int a[3],b[3];
  for(int i = 0; i <= x[0][0]; i++)
  {
    b[0] = x[0][0] - i;
    b[1] = x[0][1] - i;
    b[2] = x[0][2] - i;
    
    if( x[1][0] - b[0] != x[1][1] - b[1] || x[1][0] - b[0] != x[1][2] - b[2] )
    {
      continue;
    }
    if( x[2][0] - b[0] != x[2][1] - b[1] || x[2][0] - b[0] != x[2][2] - b[2] )
    {
      continue;
    }
    
    cout << "Yes" << endl;
    return 0;
  }
  
  cout << "No" << endl;
    
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}

#ifdef DEBUG
void debug() { cerr << "\n"; }
template <class T> void debug(const T &x) { cerr << x << "\n"; }
template <class T, class... Args> void debug(const T &x, const Args &... args) {
    cerr << x << " ";
    debug(args...);
}
template <class T> void debugVector(const vector<T> &v) {
    for(const T &x : v) {
        cerr << x << " ";
    }
    cerr << "\n";
}
#else
template <class T, class... Args>
void debug(const T &x, const Args &... args) {}
template <class T> void debugVector(const vector<T> &v) {}
#endif

using ll = long long;
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
constexpr int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

int N, K;
vector<int> a;
int memo[2][101010];

// 0なら先手の負け、1なら勝ち
// 1が先手、0が後手
int dfs(int now, int turn) {
    if(now == 0) {
        return (!turn);
    }
    if(memo[turn][now] != -1) {
        return memo[turn][now];
    }
    bool win = false;
    for(int i = 0; i < N; i++) {
        if(now - a[i] >= 0) {
            win |= (dfs(now - a[i], 1 - turn) == turn);
        }
    }
    if(turn) {
        return memo[turn][now] = win;
    } else {
        return memo[turn][now] = (!win);
    }
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N >> K;
    a.resize(N);
    for(int i = 0; i < N; i++) {
        cin >> a[i];
    }
    for(int i = 0; i < 2; i++) {
        for(int j = 0; j < 101010; j++) {
            memo[i][j] = -1;
        }
    }
    bool win = dfs(K, 1);
    cout << (win ? "First" : "Second") << "\n";
}

Measured memory_bytes: 10636
#include <iostream>
using namespace std;
int main(void){
    int K,A,B;
    cin >> K >> A >> B;
    for(int i = A;i <= B;i++){
        if(i % K == 0){
            cout << "OK" << endl;
            return 0;
        }
    }
    cout << "NG"  << endl;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#define rep(i,n) for(int i=0; i<n; i++)
typedef long long ll;
typedef pair<int,int> P;
const ll MOD = (int)1e9+7;
const ll INF = MOD*MOD;
const ll powll = 1LL<<1;

int main(){
  int n,m; 
  cin >> n;
  int a[n]; rep(i,n) cin >> a[i];
  cin >> m;
  int b[m]; rep(i,m) cin >> b[i];

  int ans = 0;
  rep(i,m){
    int l = 0, r = n;
    bool f = false;
    do {
      int c = (l+r)/2;
      // cout << c << "\n";
      if(a[c] > b[i]) r = c-1;
      else if(a[c]==b[i]) {
        f = true;
        l = n+1;
      }else l = c+1;
    }while(l <= r);
    
    if(f) ans++;
  }
  cout << ans << "\n";
}


Measured memory_bytes: 3628
# (n - k, k) version of DPL_5_J.
if __name__ == "__main__":
    n, k = map(lambda x: int(x), input().split())
    if n < k:
        print(0)
        exit(0)
    modulo = 10 ** 9 + 7
    dp = [[0] * (n + 1 - k)] * (k + 1)
    dp[0][0] = 1
    for i in range(1, k + 1):
        for j in range(n + 1 - k):
            if i <= j:
                dp[i][j] = dp[i - 1][j] + dp[i][j - i]
            else:
                dp[i][j] = dp[i - 1][j]
    ans = dp[k][n - k] % modulo

    print(ans)



Measured memory_bytes: 5600
from collections import Counter
c = Counter()
for _ in range(3):
	a, b = map(int, input().split())
	c[a] += 1
	c[b] += 1
one, two = 0, 0
for i in range(1, 5):
	if c[i] == 1:
		one += 1
	elif c[i] == 2:
		two += 1
if (one, two) == (2, 2):
	print("YES")
else:
	print("NO")


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

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(), (v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x,n) bitset<n>(x)
#define PI 3.14159265358979323846

typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> PP;

struct edge {
	int to, cost;
	edge(int t,int c):to(t),cost(c) {}
};

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

ll mypow(ll x,ll n,ll m) {	//xのn乗をmで割った余り
	if(n==0) return 1;
	if(n%2==0) return mypow(x*x%m,n/2,m);
	else return x*mypow(x,n-1,m)%m;
}

//-----------------------------------------------------------------------------

int n;
ll a,b,c,d;

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

	cin>>n>>a>>b>>c>>d;
	n--;
	REP(i,n+1) {
		ll x=c*i-d*(n-i)+a,y=d*i-c*(n-i)+a;
		if(x<=b&&b<=y) {
			cout<<"YES"<<endl;
			return 0;
		}
	}

	cout<<"NO"<<endl;

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
#include<cstdio>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>

using namespace std;
typedef long long ll;
typedef double db;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define inf 0x3f3f3f3f
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll a[100];
bool buy[100];
bool sell[100];
signed main() {
	ll n, i, t, mx, pos;
	cin >> n;
	for (i = 1; i <= n; ++i)cin >> a[i];
	pos = n;
	for (i = n - 1; i >= 1; --i) {
		if (a[pos] < a[i]) {
			pos = i;
		}
		else {
			sell[pos] = 1;
			buy[i] = 1;
			pos = i;
		}
	}
	ll ans = 1000, cnt = 0;
	for (i = 1; i <= n; ++i) {
		if (buy[i] && sell[i])continue;
		else if (buy[i]) {
			ll t = ans / a[i];
			ans -= t * a[i];
			cnt += t;
		}
		else if (sell[i]) {
			ans += cnt * a[i];
			cnt = 0;
		}
	}
	cout << ans << endl;
	return 0;
}

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



int main() {
    ll a,b,n;
    cin>>a>>b>>n;
    ll ind=b-1;
    if(n<ind)ind=n;
    cout << a*ind/b-a*(ind/b) <<endl;
}

Measured memory_bytes: 3636
#include <stdio.h>
#include <string.h>

int main()
{
    char weather[3][8] = {"Sunny", "Cloudy", "Rainy"};
    char s[8];
    int ret_scanf;

    // フォーマットに従って標準入力から入力
    ret_scanf = scanf("%s", &s[0]);
    if (ret_scanf == 0) return 0;
    // printf("number of count = %d \n", n);

    for (int i = 0; i < 3; i++) {
    	if (strcmp(weather[i], s) == 0) {
    		if (i == 2) {
    			printf("%s", weather[0]);
    			break;
    		} else {
    			printf("%s", weather[i + 1]);
    			break;
    		}
    	}
    }
    return 0;
}



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

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

  vector<ll> dp(n);
  rep(i, n) dp[i] = 1e15;

  dp[0] = 0;
  rep(i, n) {
    for(int j=i+1;j<n && j<=i+k;j++) {
      if(j < n) dp[j] = min(dp[j], dp[i] + abs(h[i] - h[j]));
    }
  }
  cout << dp[n-1] << endl;
  return 0;
}


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

using namespace std;

#define pb push_back
#define mp make_pair
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
typedef long long LL;
typedef pair<int, int> PII;

const int MOD = int(1e9) + 7;

int n, k;
string s;
int p25[2000005], p26[2000005], fac[2000005], rfac[2000005];

void facInit() {
    p25[0] = p26[0] = fac[0] = rfac[0] = rfac[1] = 1;
    for (int i = 2; i < 2000005; ++i) {
        rfac[i] = (MOD - LL(MOD / i) * rfac[MOD % i] % MOD) % MOD;
    }
    for (int i = 1; i < 2000005; ++i) {
        p25[i] = 25ll * p25[i - 1] % MOD;
        p26[i] = 26ll * p26[i - 1] % MOD;
        fac[i] = (LL)i * fac[i - 1] % MOD;
        rfac[i] = (LL)rfac[i] * rfac[i - 1] % MOD;
    }
}

int C(int n, int k) {
    return (LL)fac[n] * rfac[k] % MOD * rfac[n - k] % MOD;
}

int main() {
    ios_base::sync_with_stdio(false);
    facInit();
    cin >> k >> s;
    n = s.length();
    int ans = 0;
    forn(i, k + 1) {
        ans = ((LL)p25[i] * p26[k - i] % MOD * C(n - 1 + i, n - 1) + ans) % MOD;
    }
    cout << ans << endl;
    return 0;
}


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

int main(){
	int n[100]={0};
	int h1=0, h2=0, h3=0;
	for(int i=0; i<10; i++) cin >> n[i];

	for(int i=0; i<10; i++){
		if( h1<n[i] ){
			h3=h2;
			h2=h1;
			h1=n[i];
		}else if( h2<n[i] ){
			h3=h2;
			h2=n[i];
		}else if( h3<n[i] ){
			h3=n[i];
		}
	}
	cout << h1 << "\n";
	cout << h2 << "\n";
	cout << h3 << "\n";
}

Measured memory_bytes: 3092
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
#define dec(x) cout << fixed << setprecision(x);
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;
 
 
int main(){
ll X,Y;
  cin >> X >> Y;
  vl vec(X+1);
  rep(i,X+1){
    vec.at(i) = 2*i + 4*(X-i);
  }
  ll ans =0;
  rep(i,X+1){
    if(vec.at(i) == Y){
      ans++;
    }
  }
if(ans != 0){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}
     

    

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REP(i,b) FOR(i,0,b)
#define RFOR(i,a,b) for (int i = a-1; i >= b; i--)
#define RREP(i,a) RFOR(i,a,0)
#define REPALL(i,v) for (int i = 0; i < v.size(); i++)
#define RREPALL(i,v) for (int i = v.size()-1; i >= 0; i--)
#define SORT(v) sort(v.begin(), v.end())
#define MIN_ELEMENT(v) min_element(v.begin(), v.end())
#define MAX_ELEMENT(v) max_element(v.begin(), v.end())
#define COUNT(v,n) count(v.begin(), v.end(), n);
void YES(bool flag) {cout<<(flag ? "YES" : "NO")<<endl;}
void Yes(bool flag) {cout<<(flag ? "Yes" : "No")<<endl;}
void yes(bool flag) {cout<<(flag ? "yes" : "no")<<endl;}
typedef long long ll;
typedef unsigned long long ull;
const int INF = 1e7;
const ll MOD = 1e9 + 7;

int main()
{
    string s, ans;
    cin>>s;
    if (stoi(s.substr(0,2)) <= 12 && stoi(s.substr(0,2)) > 0) {
        if (stoi(s.substr(2,2)) <= 12 && stoi(s.substr(2,2)) > 0) {
            ans = "AMBIGUOUS";
        } else {
            ans = "MMYY";
        }
    } else if (stoi(s.substr(2,2)) <= 12 && stoi(s.substr(2,2)) > 0) {
        ans = "YYMM";
    } else {
        ans = "NA";
    }
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	num, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return num
}

func main() {
	sc.Split(bufio.ScanWords)

	s := nextInt()
	w := nextInt()

	if s > w {
		fmt.Println("safe")
	} else {
		fmt.Println("unsafe")
	}
}


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

int main(){
  map<char, int> mp;
  for(int i=0;i<3;++i){
    char c;
    cin >> c;
    mp[c]++;
  }
  if(mp['a'] == 1 && mp['b'] == 1 && mp['c'] == 1)cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256