akhauriyash/Code-Regression huggingface dataset:
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
#include <complex>
#include <cassert>
#include <array>
#include <bitset> 
#include <unordered_map>
#include <random>
using namespace std;
typedef long long LL;
typedef pair<LL,LL> P;
typedef array<array<int,26>, 26> M;


struct Node
{
	int child[26];
	int cnt=0;
	int index=-1;
	Node(){
		memset(child,0,sizeof(child));
	}
};
vector<Node> nodes;
void add(int p,int id, const char* c)
{
	//cerr << p << ", " << id << ", " << c << endl;
	nodes[p].cnt++;
	if(*c==0){
		nodes[p].index=id;
		return;
	}
	int v=*c-'a';
	//cerr << v << endl;
	if(!nodes[p].child[v]){
		nodes[p].child[v]=nodes.size();
		nodes.push_back(Node());
	}
	add(nodes[p].child[v],id,c+1);
}

const int L=400000+10;
vector<string> in;
vector<M> ms;
void f(int p, M& m)
{
	int pre=0;
	if (nodes[p].index>=0){
		ms[nodes[p].index]=m;
		pre=1;
	}
	for(int i=0;i<26;i++){
		if(!nodes[p].child[i]){
			continue;
		}
		for(int j=0;j<26;j++){
			if(j==i){
				m[i][j]+=pre;
				continue;
			}
			if(nodes[p].child[j]){
				m[j][i]+=nodes[nodes[p].child[j]].cnt;
			}
		}
		f(nodes[p].child[i],m);
		for(int j=0;j<26;j++){
			if(j==i){
				m[i][j]-=pre;
				continue;
			}
			if(nodes[p].child[j]){
				m[j][i]-=nodes[nodes[p].child[j]].cnt;
			}
		}
	}
}
int main(){
	nodes.reserve(L);
	int N;
	cin >> N;
	nodes.push_back(Node());
	in.reserve(N);
	for(int i=0;i<N;i++){
		string s;
		cin >> s;
		in.push_back(s);
		add(0,i,s.c_str());
	}
	ms.resize(N);
	M m={};
	f(0,m);
	int Q;
	cin >> Q;
	for(int i=0;i<Q;i++){
		int k;
		cin >> k;
		k--;
		char od[27];
		cin >> od;
		int ret=1;
		int b='a';
		for(int p=0;p<26;p++){
			for(int q=p;q<26;q++){
				ret+=ms[k][od[p]-b][od[q]-b];
			}
		}
		cout << ret << endl;
	}


    return 0;
}


Measured memory_bytes: 286336
#include <bits/stdc++.h>
using namespace std;
char s[500001];
int main(){
    scanf("%s", s+1);
    int n = strlen(s+1);
    int cnt = 1;
    vector<int> v;
    for(int i=2;i<=n;i++){
        if(s[i] != s[i-1]){
            v.push_back(cnt);
            cnt = 1;
        }
        else cnt++;
    }
    v.push_back(cnt);
    cnt = 0;
    if(s[1] == '<') cnt = 1;

    long long ans = 0;
    if(cnt == 0) ans += v[0];
    for(int i=0;i<v.size();i++){
        if(cnt == 1){
            if(i == v.size()-1){
                ans += v[i]*1ll*(v[i]+1)/2;
            }
            else{
                if(v[i] >= v[i+1]){
                    ans += v[i]*1ll*(v[i]+1)/2;
                }
                else{
                    v[i]--;
                    ans += v[i]*1ll*(v[i]+1)/2;
                    ans += v[i+1];
                }
            }
        }
        else{
            v[i]--;
            ans += v[i]*1ll*(v[i]+1)/2;
        }

        cnt++;
        cnt %= 2;
    }
    printf("%lld\n", ans);
}

Measured memory_bytes: 1912
#include <iostream>
#include <vector>
#include <cstdio>
#include <string>
#include <stack>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <numeric>
using namespace std;


int main(){
   int A,B;
   cin >> A >> B;

    int L = 0;
    int R = 0;
    int count = 0;

   for(int i = A;i<=B;i++){
        L = i / 1000;
        R = 10 * (i % 10) + (i % 100 - i % 10) / 10;
        if(L == R) {
            count = count + 1;
        }
   }

   cout << count << endl;
}


Measured memory_bytes: 256
kr :: [Int] -> [Int] -> Int
kr [] _ = 0
kr _ [] = 0
kr (x:xs) (y:ys) = if x /= y
                      then 1 + kr xs ys
                      else kr xs ys

main = do
    _ <- getLine
    p <- map read . words <$> getLine :: IO [Int]
    putStrLn $ if kr p [1..] <= 2
                then "YES"
                else "NO"


Measured memory_bytes: 764
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
 
int main() {
	cin.tie(0);
    ios::sync_with_stdio(false);

    int N;
    string S;
    cin >> N >> S;

    int count = 0;

    for(int i = 1; i < N; i++) {
        if(S[i] == 'E') count++;
    }

    int ans = count;

    //cerr << ans << endl;

    for(int i = 1; i < N; i++) {
        if(S[i] == 'E') count--;
        if(S[i - 1] == 'W') count++;
        ans = min(ans, count);
        //cerr << count << endl;
    }

    cout << ans << endl;
}

Measured memory_bytes: 720
N = int(input())
par = []
for i in range(1,N+1):
    par.append([j for j in range(i,N+1,i)])
A = [int(i) for i in input().split()]
List = [0 for i in range(N)]
for i in range(N-1,-1,-1):
    tmp = 0
    for j in par[i]:
        tmp += List[j-1]
    if A[i] == 1 and tmp%2==0:
        List[i] = 1
    elif A[i] == 0 and tmp%2==1:
        List[i] = 1
print(List.count(1))
ans = []
for i in range(len(List)):
    if List[i]==1:
        ans.append(i+1)
print(*ans)

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

int main(){

    vector<bool> alp(26);
    string s;
    cin >> s;

    for (int i = 0; i < s.size(); i++){
        alp[s[i] - 'a'] = true;
    }
    string ans = "None";
    for (int i = 0; i < 26; i++){
        if (!alp[i]){
            ans = 'a' + i;
            break;
        }
    }
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <vector>
#include <unordered_map>
#define ll long long

using namespace std;


void solve(){
    int n, d, res = 0;
    cin >> n >> d;
    vector<int> arr(n);
    for(int i = 0; i < n; i++)
        cin >> arr[i];
    sort(arr.begin(), arr.end());
    for(int i = 0; i < d; i++)
        res += arr[i];

    cout << res << endl;
  
}

int main()
{
    solve();
    return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
 
#define MAXN (int)(2 * 1e5 + 5)
#define MAXL 20
#define F first
#define S second
#define endl "\n"
#define MOD (lli)(1e9 + 7)
#define lli long long int
#define sz(a) int(a.size())
#define DEBUG if (0) cout << "aqui" << endl;
#define PI 2 * acos(0.0)
typedef pair<int, int> ii;
int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};
int dddx[] = {1, -1, 0, 0, 1, 1, -1, -1};
int dddy[] = {0, 0, 1, -1, 1, -1, 1, -1};

int main(){
  // ios_base::sync_with_stdio(false);
  // cin.tie(NULL);

  lli d;
  cin >> d;
  d *= 2;

  cout << PI*d << endl;


  return 0;
}

Measured memory_bytes: 3792
#include <bits/stdc++.h>
using namespace std; inline void fileio(const char* in, const char* out) { freopen(in, "r", stdin); freopen(out, "w", stdout); } 
#define TD typedef
#define forx(i,n) for(int i = 0; i < (n); ++i)
TD long long ll; TD long double ld; TD pair<int,int> pii; TD pair<ll, ll> pll; TD vector<int> VI; TD vector<bool> VB; TD vector<ll> VL;
const char nl = '\n'; const int INF = 0x3f3f3f3f; const ll LINF = 0x3f3f3f3f3f3f3f3fll; const ld EPS = 1e-9, PI = acos(-1);
#define ff first
#define ss second

const int N = 305;

int n;

ld DP[N][N][N];

// expected # of operations to eat all sushi
ld E(int i, int j, int k) {
  if (DP[i][j][k] == -1) {
    DP[i][j][k] = 1.0;
    if (i > 0) {
      DP[i][j][k] += E(i-1, j, k) * ((ld)i)/n;
    }
    if (j > 0) {
      DP[i][j][k] += E(i+1, j-1, k) * ((ld)j)/n;
    }
    if (k > 0) {
      DP[i][j][k] += E(i, j+1, k-1) * ((ld)k)/n;
    }
    DP[i][j][k] /= (i+j+k);
    DP[i][j][k] *= n;
  }
  return DP[i][j][k];
}

int main() {
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  // Emily <3
  cin >> n;
  int cnt[3] = {0,0,0};
  int t;
  forx(i,n) {
    cin >> t;
    cnt[t-1]++;
  }
  /*
  cerr << "init:";
  forx(i,3) cerr << " " << cnt[i];; cerr << nl;
  */
  forx(i,n+1) forx(j,n+1) forx(k,n+1) {
    DP[i][j][k] = -1;
  }
  DP[0][0][0] = 0;
  cout << fixed << setprecision(14) << E(cnt[0], cnt[1], cnt[2]) << nl;
  
  cerr << "Time: " << (ld)clock() / CLOCKS_PER_SEC << nl;
  return 0;
}



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

int main() {
 long long int X,ans;
  cin >> X;
  ans = (X/500*1000);
    X = X - (ans/1000*500);
  ans = ans + (X/5*5);
  cout << ans << endl;  
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int A[100000];

int partition(int p, int r){
  int x,i,j,tr;
  x = A[r];
  i = p-1;
  for (j = p; j <= r-1; j++){
    if (A[j] <= x){
      i = i+1;
      tr = A[i];
      A[i] = A[j];
      A[j] = tr;
    }
  }
    tr = A[i+1];
    A[i+1] = A[r];
    A[r] = tr;
    return i+1;
}

int main(){

  int n,i,a;
  scanf("%d",&n);
  for(i=0; i<n; i++) scanf("%d",&A[i]);

  a = partition(0,n-1);
  for(i=0; i<a; i++) printf("%d ",A[i]);
  printf("[%d] ",A[a]);
  for(i=a+1; i<n-1; i++) printf("%d ",A[i]);
  printf("%d\n",A[i]);
}


Measured memory_bytes: 2108
#include<stdio.h>
#define MAX 10010

int count2(int input) {
	int out = 0;
	int buf = input;
	while (buf % 2 == 0) {
		buf = buf / 2;
		out++;
	}
	return out;
}


int main() {
	int N;
	int A[MAX];
	int out = 0;

	scanf("%d", &N);
	for (int i = 0; i < N; i++) {
		scanf("%d", &A[i]);
		out += count2(A[i]);
	}
	printf("%d\n", out);
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
#include <list>
#include <limits>
#include <numeric>
#include <utility>
#include <deque>
#include <valarray>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#include <array>
#include <bitset>
#include <complex>
#include <tuple>

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

int main()
{
  int n;
  cin >> n;
  string s;
  cin >> s;
  int cnt[26] = {};
  for (int i = 0; i < n; ++i)
    cnt[s[i] - 'a']++;

  ll ans = 1;
  for (int i = 0; i < 26; ++i)
  {
    ans = ans * (cnt[i] + 1) % MOD;
  }
  ans--;
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 512
#include <bitset>
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <stack>
#include <algorithm>
#include <iostream>
#include <string>
#include <map>
#include <queue>
#include <stdio.h>
#include <math.h>

//#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

typedef vector<vector<int>> vvi;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef vector<ll> vll;

typedef pair<int, int> pii;

typedef queue<int> qi;
typedef queue<string> qs;


#define rep(i, n) for(int i=0; i<(n); ++i)
#define repp(i, a, b) for(int i = (a); i <= (b); i++)
#define repm(i, a, b) for(int i = (a); i >= (b); i--)

#define all(v) v.begin(), v.end()
//sort( all(v) )　などと使える

int main(){
    string s; cin >> s;
    if(s == "ABC") cout << "ARC" << endl;
    else cout << "ABC" << endl;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repI(i, d, n) for (int i = (d); i < (n); ++i)
#define reps1(i, n) for (int i = 1; i < (n); ++i)
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; }

using ll = long long;
using P = pair<int, int>;
using Pl = pair<ll, ll>;
using M = map<int, int>;
using Ml = map<ll, ll>;
ll const INF = 1ll<<61;
double pi = 3.141592653589793238;

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

  /*
  vector<ll> total(n+1);
  total[0] = 0;
  reps1(i, n+1) total[i] = total[i-1] + a[i-i];

  vector<ll> total_k(n-k+1);
  rep(i, n-k+1) total_k[i] = total[i+k] - total[k];
  */
  rep(i, n-k) {
    if (a[i+k] > a[i]) cout << "Yes" << endl;
    else cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 4840
q=int(raw_input())
for _ in xrange(q):
    gx,gy=map(int,raw_input().split())
    route=[[0]*(gy+1) for i in xrange(gx+1)]
    route[0][0]=1
    p=int(raw_input())
    ps=[]
    for i in xrange(p):
        x1,y1,x2,y2=map(int,raw_input().split())
        ps.append((x1,y1,x2,y2))
        ps.append((x2,y2,x1,y1))
    for i in xrange(gx+1):
        for j in xrange(gy+1):
            if i+1<=gx and not (i,j,i+1,j) in ps:
                route[i+1][j] += route[i][j]
            if j+1<=gy and not (i,j,i,j+1) in ps:
                route[i][j+1] += route[i][j]
    if route[gx][gy]==0: print "Miserable Hokusai!"
    else: print route[gx][gy]

Measured memory_bytes: 6392
K = int(input())
A = [1,2,3,4,5,6,7,8,9]
for i in range(len(A)):
    if A[i] != 9:
        for j in range(-1,2):
            a = int(str(A[i]) + str(A[i]+j))
            A.append(a)
    else:
        A.append(98)
        A.append(99)
A.append(100)
A.append(101)
L1 = len(A.copy())
for i in range(10,L1):
    B = A[i]
    if B % 10 == 0:
        A.append(int(str(B) + '0'))
        A.append(int(str(B) + '1'))
    elif B % 10 == 9:
        A.append(int(str(B) + '8'))
        A.append(int(str(B) + '9'))
    else:
        for j in range(-1, 2):
            a = int(str(B) + str((B % 10) + j))
            A.append(a)
L2 = len(A.copy())
for i in range(L1,L2):
    B = A[i]
    if B % 10 == 0:
        A.append(int(str(B) + '0'))
        A.append(int(str(B) + '1'))
    elif B % 10 == 9:
        A.append(int(str(B) + '8'))
        A.append(int(str(B) + '9'))
    else:
        for j in range(-1, 2):
            a = int(str(B) + str((B%10) + j))
            A.append(a)
L3 = len(A.copy())
for i in range(L2,L3):
    B = A[i]
    if B % 10 == 0:
        A.append(int(str(B) + '0'))
        A.append(int(str(B) + '1'))
    elif B % 10 == 9:
        A.append(int(str(B) + '8'))
        A.append(int(str(B) + '9'))
    else:
        for j in range(-1, 2):
            a = int(str(B) + str((B % 10) + j))
            A.append(a)
L4 = len(A.copy())
for i in range(L3,L4):
    B = A[i]
    if B % 10 == 0:
        A.append(int(str(B) + '0'))
        A.append(int(str(B) + '1'))
    elif B % 10 == 9:
        A.append(int(str(B) + '8'))
        A.append(int(str(B) + '9'))
    else:
        for j in range(-1, 2):
            a = int(str(B) + str((B % 10) + j))
            A.append(a)
L5 = len(A.copy())
for i in range(L4,L5):
    B = A[i]
    if B % 10 == 0:
        A.append(int(str(B) + '0'))
        A.append(int(str(B) + '1'))
    elif B % 10 == 9:
        A.append(int(str(B) + '8'))
        A.append(int(str(B) + '9'))
    else:
        for j in range(-1, 2):
            a = int(str(B) + str((B % 10) + j))
            A.append(a)
L6 = len(A.copy())
for i in range(L5,L6):
    B = A[i]
    if B % 10 == 0:
        A.append(int(str(B) + '0'))
        A.append(int(str(B) + '1'))
    elif B % 10 == 9:
        A.append(int(str(B) + '8'))
        A.append(int(str(B) + '9'))
    else:
        for j in range(-1, 2):
            a = int(str(B) + str((B % 10) + j))
            A.append(a)
L7 = len(A.copy())
for i in range(L6,L7):
    B = A[i]
    if B % 10 == 0:
        A.append(int(str(B) + '0'))
        A.append(int(str(B) + '1'))
    elif B % 10 == 9:
        A.append(int(str(B) + '8'))
        A.append(int(str(B) + '9'))
    else:
        for j in range(-1, 2):
            a = int(str(B) + str((B % 10) + j))
            A.append(a)
L8 = len(A.copy())
for i in range(L7,L8):
    B = A[i]
    if B % 10 == 0:
        A.append(int(str(B) + '0'))
        A.append(int(str(B) + '1'))
    elif B % 10 == 9:
        A.append(int(str(B) + '8'))
        A.append(int(str(B) + '9'))
    else:
        for j in range(-1, 2):
            a = int(str(B) + str((B % 10) + j))
            A.append(a)
print(A[K-1])

Measured memory_bytes: 11440
def main():
    N = int(input())
    A = tuple(map(int, input().split()))

    a = [0] * 100001
    for i in A:
        if i > 0:
            a[i-1] += 1
        a[i] += 1
        a[i+1] += 1

    print(max(a))

main()


Measured memory_bytes: 13964
#include<stdio.h>

int main(void){
    
    int i = 0;
    int a,b,c;
    scanf("%d %d %d",&a,&b,&c);
    
    while(1){
        
        if(c%a ==0){
            i +=1;
        }
        
        if(a == b){
            break;
        }
        
        a++;
        
        
    }
    printf("%d\n",i);
    
    return 0;
}


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

using namespace std;
#define DBG(x)                         \
    (void)(cout << "L" << __LINE__     \
                << ": " << #x << " = " \
                << (x) << '\n')
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
typedef long long ll;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const long double PI = (acos(-1));
const long double EPS = 0.0000000001;
const int INF = 0x3f3f3f3f;
const int maxn = 1100000;

void run_case()
{
    int x;
    cin >> x;
    if (x == 1)
        cout << 0 << "\n";
    else if (x == 0)
        cout << 1 << "\n";
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setiosflags(ios::fixed) << setprecision(12);
    run_case();
    cout.flush();
    return 0;
}

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

int main()
{
  int x=1;
  int count=1;
  
  while(1){
    cin >> x;
    if(x == 0){
      break;
    }
    cout << "Case " << count << ": " << x << endl;
    count++;
  }
  
  return 0;
} 

Measured memory_bytes: 1160
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<unordered_map>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())

#define MOD 1000000007
#define MAXN 200000
long long inv[MAXN + 1];//MODを法とする乗法の逆元
long long fact[MAXN + 1];//階乗
long long ifact[MAXN + 1];//階乗の逆元
void init() {
	inv[1] = 1;
	for (int i = 2; i <= MAXN; i++) inv[i] = inv[MOD % i] * (MOD - MOD / i) % MOD;
	fact[0] = ifact[0] = 1;
	for (int i = 1; i <= MAXN; i++) {
		fact[i] = i * fact[i - 1] % MOD;
		ifact[i] = ifact[i - 1] * inv[i] % MOD;
	}
}
long long C(int n, int r) {
	if (n < 0 || r < 0 || r > n)return 0;
	if (r > n / 2)r = n - r;
	return fact[n] * ifact[n - r] % MOD * ifact[r] % MOD;
}
long long H(int n, int k) { // multi-choose
	if (n < 0 || k < 0)return 0;
	return fact[n + k - 1] * ifact[k] % MOD * ifact[n - 1] % MOD;
}


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

	int n, k;
	init();

	cin >> n >> k;
	long long ans = 0;

	for (int i = max(1, n - k); i < n; i++) {
		ans += H(i, n - i) * C(n, i) % MOD;
	}
	if (k >= 2)ans = (ans + 1) % MOD;
	
	cout << ans % MOD << endl;

	return 0;
}

Measured memory_bytes: 4992
import sys

N=int(input())
H=list(map(int,input().split()))

for i in range(N-2,-1,-1):
    if H[i]>H[i+1]:
        H[i]-=1


for i in range(N-1):
    if H[i]>H[i+1]:
        print("No")
        sys.exit()

print("Yes")

Measured memory_bytes: 14396
function main(lines) {
  const N = n();

  for (let i = 1, cnt = 0; i <= N; i++) {
    const [d1, d2] = na();
    if (d1 === d2) cnt++;
    else cnt = 0;
    if (cnt === 3) return 'Yes';
  }
  
  return 'No';
}



const lines = require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");

let lineCount = 0;
const s = () => lines[lineCount++];
const n = () => Number(s());
const b = () => BigInt(s());
const sa = () => s().split(' ');
const na = () => sa().map(Number);
const ba = () => sa().map(BigInt);
const getLines = (n) => lines.slice(lineCount, lineCount += n);

const ans = main(lines);
console.log( ans );

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

using namespace std;

typedef long long ll;

double getTime() {
  return clock() / (double) CLOCKS_PER_SEC;
}

void read() {};

template<typename T, typename... Args>
void read(T& a, Args&... args) {
  cin >> a;
  read(args...);
}

void print() {};

template <typename T, typename... Args>
void print(T a, Args... args) {
  cout << a << " \n"[sizeof...(args) == 0];
  print(args...);
}

int main() {
  int a, b, k; cin >> a >> b >> k;
  set <int> s;
  int p = k;
  for(int i = a; i <= b and p > 0; i++, p--) {
    s.insert(i);
  }
  p = k;
  for(int i = b; i >= a and p > 0; i--, p--) {
    s.insert(i);
  }
  for(auto x : s) cout << x << '\n';
}

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


int find_prime(int X)
{
	int prime = (X % 2 == 0) ? X + 1 : X;
	bool judge = true;
	while (true) {
		for (int i = 2; i < sqrt(prime); i++) {
			if (prime%i == 0) {
				judge = false;
				break;
			}
		}
		if (judge == true)break;
		else { 
			judge = true;
			prime += 2; 
		}
	}

	return prime;
}

int main(void)
{
	int X; cin >> X;
	if (X == 2)cout << 2 << endl;
	else {
		int ans = find_prime(X);
		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 256
import numpy as np

h, n = map(int, input().split())
la, lb = [], []
for _ in range(n):
    a, b = map(int, input().split())
    la.append(a)
    lb.append(b)

aa = np.array(la)
ab = np.array(lb)
maxa = np.max(aa)

# min_magic[maxa + i] = min magic power to give damage >= i
min_magic = np.zeros(maxa + h + 1, int)

for i in range(1, h + 1):
    min_magic[maxa + i] = np.min(min_magic[maxa + i - la] + lb)

answer = min_magic[maxa + h]
print(answer)


Measured memory_bytes: 27404
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <unordered_map>

using namespace std;
using LL = long long;

constexpr int MOD = 1000000000 + 7;
constexpr int INF = 2000000000;

bool calc(pair<int, int> a, pair<int, int> b) {
	if (a.second == b.second) {
		return a.first < b.first;
	}
	else {
		return a.second > b.second;
	}
}

int main() {
	int n;
	int a, v;
	vector<pair<int, int>> W;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a >> v;
		W.emplace_back(a, v);
	}
	sort(W.begin(), W.end(), calc);
	cout << W[0].first << " " << W[0].second << endl;
}

Measured memory_bytes: 3104
import collections
n=int(input())
s=[]
ans=[]
for i in range(n):
    si=input()
    s.append(si)
s_new=collections.Counter(s)
s_most=s_new.most_common()
buf=s_most[0][1]
cnt=0
for i in range(len(s_new)):
    if s_most[i][1]==buf:
        ans.append(s_most[i][0])
        cnt+=1
    elif s_most[i][1]<buf:
        break
ans_sorted=sorted(ans)
for i in range(cnt):
    print(ans_sorted[i])

Measured memory_bytes: 49208
N = int(input())

if N < 105:
  ans = 0
elif N == 105:
  ans = 1
else:
  ans = 1
  for n in range(106, N+1):
    if n % 2 == 0:
      continue
    count = 0
    for i in range(1, int(n**(1/2))+1):
      if n % i == 0:
      	count += 1
    if count == 4:
      ans += 1
print(ans)


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

int const N = 100*1000 + 16;
int const M = 1000*1000*1000 + 7;

int n;
int a[N];

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

  cin >> n;
  map<int,int> m;
  for(int i = 0; i < n; ++i) {
    cin >> a[i];
    m[a[i]-1]++;
    m[a[i]]++;
    m[a[i]+1]++;
  }

  int best = 0;
  for(auto const& p : m)
    best = max(best, p.second);
  cout << best;
}

Measured memory_bytes: 5120
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <cstdint>
#include <map>
#include<iomanip>

using namespace std;
typedef long long ll; 


ll ans,mx,sum,mn=1e18,flag;

ll c[1000000];
int main(){
	ll n;
	cin>>n;
	ll a[n];
	for(ll i=0; i<n; i++){
		cin>>a[i];
		c[a[i]]++;
	}
	for(ll i=1; i<=n; i++){
		if(c[i]!=0) {
			ll temp = c[i]-1;
			ll d = (temp*(temp+1))/2;
			sum += d;
		}
	}
	for(ll i=0; i<n; i++){
		cout<<sum-(c[a[i]]-1)<<endl;
	}
}

Measured memory_bytes: 4736
import java.util.*;



import java.io.*;
public class Main {

	public static void main(String[] args) {
	FastScanner sc=new FastScanner();
	int n=sc.nextInt(),k=sc.nextInt();
	int a[]=sc.readArray(n);
	if(n<=1)
		System.out.println("0");
	else {
		int dp[]=new int[n];
		Arrays.fill(dp, Integer.MAX_VALUE);
		dp[0]=0;
		
		for(int i=1;i<n;i++) {
			for(int j=i-1;j>=0&&j>=i-k;j--) {
				dp[i]=Math.min(dp[i], dp[j]+Math.abs(a[i]-a[j]));
			}
		}
		System.out.println(dp[n-1]);
		
	}

	}
	static class FastScanner{
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		
		String next() {
			while (!st.hasMoreTokens())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}
		int nextInt() {
			return Integer.parseInt(next());
		}
		long nextLong() {
			return Long.parseLong(next());
		}
		int [] readArray(int n) {
			int a[]=new int[n];
			for(int i=0;i<n;i++) a[i]=nextInt();
			return a;
		}
		
		
	}
	

}



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

int main() {
    int s; cin >> s;
    long long mod = pow(10, 9) + 7;
    vector<long long> dp = {0, 0, 0, 1};
    for (int i=4; i<=s; i++) dp.push_back((dp[i-1]+dp[i-3]) % mod);
    cout << dp[s] << endl;
}

Measured memory_bytes: 3628
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define all(i,n) (i),(i+n)

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;

// --------------------------------------
int a, b;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin >> a >> b;

  if(a < b) {
    REP(i, b) cout << a;
  } else {
    REP(i, a) cout << b;
  }
  cout << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdlib>
#include <cstdio>
#include <queue>
#include <stack>
#include <list>
#include <utility>
#include <vector>
#include <set>
#include <algorithm>
#include <cmath>
#include <climits>


#define REP(i,N) for(auto i = 0; i <N; i++)
using namespace std;
typedef long long ll;


int in(){
    int temp;
    scanf("%d",&temp);
    return temp;
}

ll lin(){
    ll temp;
    scanf("%lld",&temp);
    return temp;
}



int main() {

    priority_queue<int> pq;
    
    pq.push(in());
    pq.push(in());
    pq.push(in());
    
    int A  = pq.top();
    pq.pop();
    int B  = pq.top();
    pq.pop();
    int C  = pq.top();
    pq.pop();
    
    int x = A-C;
    int y = B-C;
    
    int ans = 0;
    
    while (x >=2 && y >= 2){
        x -=2;
        y-=2;
        ans ++;
    }
    int greater = max(x, y);
    int lesser = min(x,y); // 0 or 1
    
    while(greater >=2){
        ans+=2;
        greater-=2;
    }
    
    if (lesser == 0 && greater == 0){
        cout << ans << endl;
        return 0;
    }else if (lesser == 1  && greater == 1){
        cout << ans + 2 << endl;
    }else{
        cout << ans + 1 << endl;

    }
 
    
    return 0;
}



                          





Measured memory_bytes: 256
"""
# 標準入力取得
## 文字列
 = sys.stdin.readline().rstrip()
 = list(sys.stdin.readline().rstrip())

## 数値
 = int(sys.stdin.readline())
 = map(int, sys.stdin.readline().split())
 = list(map(int, sys.stdin.readline().split()))
 = [list(map(int,list(sys.stdin.readline().split()))) for i in range(h)]  # 二次元配列入力　二次元マップみたいな入力のとき

# 0埋め, 小数点出力桁指定時のときの出力
a = 100
b = 0.987654321
print("{0:06d}-{1:6f}".format(a,b))
000100-0.987654

# 文字列をリストに格納
char_list = list("abcd") # ["a","b","c","d"]
"""

import math
import sys
import itertools
import queue
from fractions import gcd

def lcm(a, b):
    return a * b // gcd(a, b)

mod = 1000000007

if __name__ == "__main__":
    N,A,B= map(int, sys.stdin.readline().split())
    d=N*A
    t=B
    if d>t:
        ans=t
    else:
        ans=d
    print(ans)

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

#define DEBUG(x) cerr << #x << ": " << x << endl;
#define ll long long

int main() {
    string a, b;
    cin >> a >> b;

    if (a.size() > b.size()) {
        puts("GREATER");
        return 0;
    } else if (a.size() < b.size()) {
        puts("LESS");
        return 0;
    } else {
        for (int i = 0; i < a.size(); i++) {
            int x = a[i] - '0';
            int y = b[i] - '0';
            if (x > y) {
                puts("GREATER");
                return 0;
            } else if (x < y) {
                puts("LESS");
                return 0;
            }
        }

    }

    puts("EQUAL");

    return 0;
}

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



int h, w;
int t[1000][1000];
string s[1000];
int cnt = 0;
bool f(int y, int x) {
  return t[y][x]==t[h-1-y][x]&&
  t[y][x]==t[y][w-1-x]&&
  t[y][x]==t[h-1-y][w-1-x];
}
void change(int y, int x) {
  int yy = y, xx = x;
  int bf = f(yy, xx);
  cnt-=!bf;
  t[y][x]^=1;
  int af = f(yy, xx);
  cnt+=!af;
}

int main() {
  std::ios::sync_with_stdio(false), std::cin.tie(0);
  int n, q;
  cin >> q >> n;
  h = w = n;
  for(int i = 0; i < h; i++) {
    cin >> s[i];
    for(int j = 0; j < w; j++) {
      if(s[i][j] == '1') change(i, j);
    }
  }
  // cout << cnt << endl;
  int ans = 0;
  ans+=cnt==0;
  q--;
  while(q--){
    int d; cin >> d;
    while(d--){
      int y, x;
      cin >> y >> x;
      y--; x--;
      change(y, x);
    }
    ans+=cnt==0;
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 8012
#include <iostream>
#include <vector>
using namespace std;
int main() {
	int a, b;
	char k[105][105];
	cin >> a >> b;
	vector<bool>height(a, 0);
	vector<bool>width(b, 0);
	for (int i = 0; i < a; ++i) {
		for (int j = 0; j < b; ++j) {
			cin >> k[i][j];
			if (k[i][j] == '#') {
				height[i] = 1, width[j] = 1;
			}
		}
	}

	for (int i = 0; i < a; ++i) {
		if (height[i]) {
			for (int j = 0; j < b; ++j) {
				if (width[j]) cout << k[i][j];
			}
			cout << endl;
		}
	}
}

Measured memory_bytes: 256
#include <stdio.h>

int main() {
	int n;
	scanf("%d", &n);
	int temp = 0;
	for(int i = 1; i <= 9; i++){
		if((double)n/i <= 9 && (double)n/i >= 1 && n%i == 0){
			temp = 1;
			break;
		}
	}
	if(temp == 1){
		puts("Yes");
	}else{
		puts("No");
	}
	
	return 0;
}


Measured memory_bytes: 1660
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            if (n == 3) {
                out.println("2 5 63");
                return;
            }
            int[] a = new int[n];
            int p = 0;
            long s = 0;
            for (int i = 1; p < n; ++i)
                if (i % 2 == 0 || i % 3 == 0) {
                    a[p++] = i;
                    s += i;
                }
            for (int elast = 0; ; ++elast) {
                for (int eprev = 0; eprev <= elast; ++eprev) {
                    int u = a[n - 2] + eprev;
                    int v = a[n - 1] + elast;
                    if (u % 2 == 0 || u % 3 == 0) {
                        if (v % 2 == 0 || v % 3 == 0) {
                            if ((s + eprev + elast) % 6 == 0) {
                                a[n - 2] = u;
                                a[n - 1] = v;
                                for (int x : a) out.print(x + " ");
                                out.println();
                                return;
                            }
                        }
                    }
                }
            }
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 26324
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    long long sum=0;
    cin>>n;

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

            else
                sum+=i;
    }
    cout<<sum<<endl;
    exit(0);
}


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

ll n, m, q, a[100], b[100], c[100], d[100], cnt[20]; 

void kuri(){
	cnt[0]++;
	rep(i, 0, n-2){
		if(cnt[i] > cnt[i+1]){
			cnt[i] = 1;
			cnt[i+1]++;
		}
	}
	return;
}

bool fin(){
	return cnt[n-1] == m+1; 
}

ll cal(){
	ll res = 0;
	zep(i, 0, q){
		if(cnt[b[i]]-cnt[a[i]] == c[i]){
			res += d[i];
		}
	}
	return res;
}

int main(){
	cin.tie(0); ios::sync_with_stdio(false);
	
	cin >> n >> m >> q;
	zep(i, 0, q){
		cin >> a[i] >> b[i] >> c[i] >> d[i];
		a[i]--; b[i]--;
	}
	zep(i, 0, n)cnt[i] = 1;
	
	ll ans = 0;
	while(!fin()){
		//printa(cnt, 0, n-1)
		ans = max(ans, cal());
		kuri();
	}
	
	print(ans)
	return 0;
}

Measured memory_bytes: 3652
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef vector<ll> vll;
typedef vector<vector<ll> > vvll;
typedef deque<ll> dqll;

#define MOD 1000000007

int main() {
  ll N;

  cin >> N;

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

  queue<ll> que;
  for (int i = 0; i < N; i++) {
    ll idx1 = (i - 1 + N) % N;
    ll idx2 = (i + 1) % N;
    if (cur[i] > cur[idx1] + cur[idx2]) {
      que.push(i);
    }
  }  // i

  ll ans = 0;
  bool flag = false;
  while (!que.empty()) {
    ll tmp = que.front();
    que.pop();

    ll idx1 = (tmp - 1 + N) % N;
    ll idx2 = (tmp + 1) % N;

    ll tryval = cur[tmp] % (cur[idx1] + cur[idx2]);
    if (tryval < goal[tmp]) {
      ll checkval = cur[tmp] - goal[tmp];
      if (checkval % (cur[idx1] + cur[idx2]) != 0) {
        break;
      }
      cur[tmp] = goal[tmp];
      ans += checkval / (cur[idx1] + cur[idx2]);
    } else {
      ans += (cur[tmp] / (cur[idx1] + cur[idx2]));
      cur[tmp] %= (cur[idx1] + cur[idx2]);
    }

    ll idx1p = (tmp - 2 + N) % N;
    ll idx2p = (tmp + 2) % N;
    if (cur[idx1] > cur[idx1p] + cur[tmp]) que.push(idx1);
    if (cur[idx2] > cur[idx2p] + cur[tmp]) que.push(idx2);
  }  // while

  flag = true;
  for (int i = 0; i < N; i++) {
    if (goal[i] != cur[i]) {
      flag = false;
      break;
    }
  } // i

  if (!flag) {
    cout << -1 << endl;
  } else {
    cout << ans << endl;
  }

  return 0;
}


Measured memory_bytes: 4224
//
//  main.cpp
//

#include <algorithm>
#include <array>
#include <assert.h>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <math.h>
#include <memory>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

using ll = int64_t;
using ull = uint64_t;
constexpr ll LL_MAX = numeric_limits<ll>::max();
constexpr ull ULL_MAX = numeric_limits<ull>::max();

template<typename T>
vector<T> make_vec_nd(T init, ll size) {
	return vector<T>(size, init);
}
template<typename T, typename... Args>
auto make_vec_nd(T init, ll size, Args... rest) {
	auto inner = make_vec_nd(init, rest...);
	return vector<decltype(inner)>(size, inner);
}

#define rep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrep(i, a, b) for (ll i = (a)-1; i >= (b); i--)

int main() {
    ll N;
    cin >> N;
    set<ll> xs;
    rep(i,0,N) {
        ll x;
        cin >> x;
        xs.insert(x);
    }
    if (xs.size() == N) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
}


Measured memory_bytes: 9600
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int S=(1<<20)+5;
char buf[S],*H,*T;
inline char Get()
{
    if(H==T) T=(H=buf)+fread(buf,1,S,stdin);
    if(H==T) return -1;return *H++;
}
inline LL read()
{
    LL x=0;char c=Get();
    while(!isdigit(c)) c=Get();
    while(isdigit(c)) x=x*10+c-'0',c=Get();
    return x;
}
const int N=100010;
LL a[N],b[N][2];
bool mask[3010];
int prm[3010],tot=0,n;
unordered_map<LL,int> cc;
unordered_map<LL,bool> fucked;
LL maxc(const LL &a,const LL &b){return cc[a]>cc[b]?a:b;}
void preprework()
{
    for(int i=2;i<=2200;i++)
    {
        if(mask[i]) continue;
        prm[++tot]=i;
        for(int j=i;j<=2200;j+=i)
            mask[j]=1;
    }
}
void prework()
{
    for(int i=1;i<=n;i++)
    {
        LL x=1,y=1;
        for(int j=1;j<=tot;j++)
        {
            if(a[i]%prm[j]) continue;
            int cnt=0;
            while(a[i]%prm[j]==0)
                a[i]/=prm[j],cnt++;
            if(!(cnt%=3)) continue;
            for(int k=1;k<=cnt;k++) x=x*prm[j];
            for(int k=cnt+1;k<=3;k++) y=y*prm[j];
        }
        LL t=(LL)sqrt(a[i]);
        if(t*t==a[i]) x=x*t*t,y=y*t;
        else x=x*a[i],y=y*a[i]*a[i];
        b[i][0]=x;b[i][1]=y;
        if(!cc.count(x)) cc[x]=1;
        else cc[x]++;
    }
}
int main()
{
    LL ans=0;n=read();
    for(int i=1;i<=n;i++) a[i]=read();
    preprework();prework();
    for(int i=1;i<=n;i++)
    {
        LL c1=b[i][0],c2=b[i][1];
        if(fucked[c1]||fucked[c2]) continue;
        LL x=maxc(c1,c2);fucked[x]=1;
        ans+=(x==1)?1:cc[x];
    }
    cout<<ans<<endl;
    return 0;
}
/*请管理员见谅，仅仅用于测速*/

Measured memory_bytes: 20168
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {
	
		static int n;
		static int[] A;
		static int q;
		static int m;
		
		static int[][] dp;
	
	public static void main(String[] args) throws NumberFormatException, IOException {
		// TODO 自動生成されたメソッド・スタブ
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] str;
		
		n = Integer.parseInt(br.readLine());
		A = new int[n];
		
		str = br.readLine().split(" ");
		for(int i = 0; i < n; i++){
			A[i] = Integer.parseInt(str[i]);
		}
		
		q = Integer.parseInt(br.readLine());
		
		str = br.readLine().split(" ");
		for(int i = 0; i < q; i++){
			m = Integer.parseInt(str[i]);
			
			dp = new int[n][m + 2000];
			for(int[] array : dp){
				Arrays.fill(array, -1);
			}
			
			System.out.println(dfs(0, 0) == 1?"yes" : "no");
		}
		
	}
	
	public static int dfs(int i, int sum){
		
		if(sum == m) return 1;
		
		else if(i == n) return 0;
		
		else if(dp[i][sum] != -1) return dp[i][sum];
		
		else if(dfs(i + 1, sum) == 1) return dp[i][sum] = 1;
		
		else if(dfs(i + 1, sum + A[i]) == 1) return dp[i][sum] = 1;
		
		else return dp[i][sum] = 0;
	}
}


Measured memory_bytes: 57616
#include "bits/stdc++.h"
using namespace std;
int main(){
    double a,b,c,pi,S,L,h;
    cin >> a >> b >> c;
    pi = acos(-1.);
    c = c/180*pi;
    S = 0.5*a*b*sin(c);
    L=a+b+sqrt(a*a+b*b-2.0*a*b*cos(c));
    h = b*sin(c);
    printf("%.4lf\n%.4lf\n%.4lf\n",S,L,h);
    return 0;
}


Measured memory_bytes: 3588
#include <bits/stdc++.h>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
//using namespace __gnu_pbds;

#define ll       long long
#define DS       pair<ll, ll>
#define READ(f)  freopen(f, "r", stdin)
#define WRITE(f) freopen(f, "w", stdout)

const int N = 2e5 + 5;
const int MOD = 1e9 + 7;;
const double PI = 2 * acos(0.0);
//template<typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

int a[N];
vector<int> v;

int main() {
    //ios::sync_with_stdio(false);
    //cin.tie(0);
    int k, n;
    cin >> k >> n;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        if (i) {
            v.push_back(a[i] - a[i - 1]);
        }
    }
    int tmp = a[0] + (k - a[n - 1]);
    v.push_back(tmp);
    sort(v.begin(), v.end());
    int ans = 0;
    for (int i = 0; i < v.size() - 1; i++) {
        ans += v[i];
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 1912
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		double ans = 0;
		double num = 0;
		String s;
		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();

		for(int i = 0; i < N; i++) {
			num = sc.nextDouble();
			s = sc.next();

			if(s.equals("JPY")) {
				ans += num;
			} else {
				ans += num * 380000.0;
			}
		}

		System.out.println(ans);

		sc.close();
	}

}

Measured memory_bytes: 23124
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <valarray>
#include <vector>

#define EPS 1e-9
#define INF 1070000000LL
#define MOD 1000000007LL
#define fir first
#define foreach(it,X) for(__typeof((X).begin()) it=(X).begin();it!=(X).end();it++)
#define ite iterator
#define mp make_pair
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define pb push_back
#define sec second
#define sz(x) ((int)(x).size())

using namespace std;

struct timer{
	time_t start;
	timer(){start=clock();}
	~timer(){cerr<<1.*(clock()-start)/CLOCKS_PER_SEC<<" secs"<<endl;}
};

typedef istringstream iss;
typedef long long ll;
typedef pair<int,int> pi;
typedef stringstream sst;
typedef vector<int> vi;

int T,t[33],d=100,h[111];
int dp[111][33];

int f(int cur,int cycle){
	int& res=dp[cur][cycle];
	if(res!=-1)return res;
	if(cur==d)return res=0;
	if(h[cur]<t[cycle])return res=INF;
	return res=min(f(cur+1,(cycle+1)%T),1+f(cur+1,0));
}

int main(){
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	
	while(cin>>T && T){
		rep(i,T)cin>>t[i];
		rep(i,d)h[i]=INF;
		int N;
		cin>>N;
		rep(i,N){
			int D,M;
			cin>>D>>M;
			D--;
			h[D]=min(h[D],M);
		}
		memset(dp,-1,sizeof(dp));
		cout<<f(0,0)<<endl;
	}
}

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

int main()
{
    int n, m;
    cin >> n >> m;

    vector<uint64_t> a(n);

    for (int i = 0; i < n; i ++)
        cin >> a[i];
    
    // smallest to largest
    sort(a.begin(), a.end());

    uint64_t b, c;
    vector< pair<uint64_t, uint64_t> > cb;

    for (int i = 0; i < m; i++)
    {
        cin >> b >> c;
        cb.push_back( make_pair(c, b) );
    }

    //sorted from lowest c value to highest c value
    sort(cb.begin(), cb.end());


    vector<uint64_t> rep;
    for (int i = m-1; i >= 0; i--)
    {
        while (cb[i].second-- > 0)
        {
            rep.push_back(cb[i].first);
            if (rep.size() == a.size()) break;
        }
        if (rep.size() == a.size()) break;
    }   

    vector<pair <uint64_t, uint64_t>>().swap(cb);

    //int maxindex = n > rep.size() ? rep.size() : n;
    for (int i = 0; i < rep.size(); i++)
    {
        if (rep[i] > a[i]) a[i] = rep[i];
    }

    uint64_t sum = 0;
    for (int i = 0; i < n; i++)
        sum += a[i];

    //cout << accumulate(a.begin(), a.end(), 0) << endl;
    cout << sum << endl;
}


Measured memory_bytes: 4336
#include <bits/stdc++.h>
#define Int int64_t

using namespace std;

void chmax(Int& a, Int b) { if (a < b) { a = b; } }

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

	vector<Int> dp(N + 1, 0);
	dp[0] = 1000;
	for (int i = 1; i <= N; ++i) {
		chmax(dp[i], dp[i - 1]);
		for (int j = 1; j < i; ++j) {
			Int val = dp[j] / a[j] * a[i] + dp[j] % a[j];
			chmax(dp[i], val);
		}
	}
	cout << dp[N] << endl;

	return 0;
}


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

int main()
{
  int N,k;
  cin >> N;
  int ans=0;
  
  for(int i=0;i<N;i++)
  {
    cin >> k;
    if(k%2==0)
    {
      if((k%3==0)||(k%5==0))
      {
        
      }
      else
      {
        ans=1;
        
      }
    }
    if(ans==1)
    {
      break;
    }
    
  }
  
  if(ans==1)
  {
    cout << "DENIED" <<endl;
  }else
  {
    cout << "APPROVED" <<endl;
  }
  
  
  
}

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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"

using namespace std;
using ll = long long;

const ll MOD = 1000000007LL; // = 10^9 + 7
const double PI = 3.14159265358979;

void solve()
{
  string n;
  cin >> n;
  ll ans = 0;
  for(const auto& c : n)
  {
    ans += (int)(c - '0');
  }
  cout << ((ans % 9) == 0 ? "Yes" : "No");
}

int main()
{
  fastio;
  solve();

  return 0;
}

Measured memory_bytes: 3740
import sys

s = raw_input()

arr = []

temp = ord(s[0])
arr.append(temp)

for i in range(1, len(s)):
    temp = ord(s[i])
    if temp in arr:
        print "no"
        break
    else:
        temp = ord(s[i])
        arr.append(temp)
    if i == len(s) - 1:
        print "yes"

Measured memory_bytes: 2568
using System;
using System.Collections.Generic;
using System.Text;
using System.Numerics;
using System.IO;

namespace SolutionCS
{
    class Program
    {
        static long gcd(long a, long b)
        {
            if (a < b)
            {
                return gcd(b, a);
            }

            while (b != 0)
            {
                long rem = a % b;
                a = b;
                b = rem;
            }

            return a;
        }

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

        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split(' ');
            long A = long.Parse(s[0]);
            long B = long.Parse(s[1]);

            Console.WriteLine(lcm(A, B));
        }
    }
}



Measured memory_bytes: 13140