akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>

void trace(int r[100], int n)
{
    int i;

    for(i = 0; i < n; i++){

        if(i > 0) printf(" ");

        printf("%d", r[i]);
    }
    printf("\n");
}

void co(int c){

    printf("%d\n", c);
}

int selectionsort(int r[100], int n)
{
    int i, j, a, minj;
    int count = 0;

    for(i= 0; i < n; i++){
        minj = i;

        for(j = i; j < n; j++){
            if(r[j] < r[minj]) minj = j; 
        }
        a          = r[i];
        r[i]       = r[minj];
        r[minj] = a;

        if(i != minj) count++;
    }
    trace(r, n);
    co(count);
}
         
int main()
{
    int i,  j, n, r[100];

    scanf("%d", &n);

    for(i = 0; i < n; i++){
        scanf("%d", &r[i]);
    }
    selectionsort(r, n);
    return 0;
}


Measured memory_bytes: 1984
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long int n;
	cin>>n;
	long int happy=0;
	int a=n%500;
	if(n>=500)
	{
		if(n%500==0)
		{
			happy=n*2;
		}
		else
		{
			int m=n/500;
			happy=m*1000;
		}
	}
	if(a>=5)
	{
		if(a%5==0)
		{
			happy+=a;
		}
		else
		{
			int p=a%5;
			p=a-p;
			happy+=p;
		}
	}
		cout<<happy<<endl;
		return 0;
}


Measured memory_bytes: 256
import sys; input = sys.stdin.buffer.readline
from collections import defaultdict
con = 10 ** 9 + 7; INF = float("inf")

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

#処理内容
def main():
	N, X, Y = getlist()
	X -= 1; Y -= 1
	D = defaultdict(int)
	for i in range(N):
		for j in range(i + 1, N):
			var = min(j - i, abs(X - i) + abs(Y - j) + 1)
			D[var] += 1

	for i in range(1, N):
		print(D[i])




if __name__ == '__main__':
	main()

Measured memory_bytes: 48860
#include<bits/stdc++.h>
#define F first
#define S second
#define endl '\n'
#define lcm( a, b ) ((a)/__gcd(a,b)*(b))
#define MP make_pair
#define pb push_back
#define all(x) (x).begin(),(x).end()

using namespace std;

typedef long long LL;
typedef pair<int, int> P;
typedef pair<int, P> i_P;
typedef pair< LL, LL > L_P;

const int INF = INT_MAX;
const int MIN = INT_MIN;
const LL LINF = LLONG_MAX;
const int MOD = 1000000000 + 7;
const int SIZE = 100005;

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

    while( true ) {
        int t;
        cin >> t;
        if( t == 0 ) break;
        int n;
        cin >> n;
        int res = 0;
        for( int i = 0; i < n; ++i ) {
            int s, f;
            cin >> s >> f;
            if( s > f ) {
                res += 24 - s + f;

            } else {
                res += f - s;

            }
        }

        if( res >= t ) cout << "OK";
        else cout << t - res;
        cout << endl;

    }
    return 0;
}




Measured memory_bytes: 3132
#include<bits/stdc++.h>
using namespace std;
int main(){
	string str;
	cin>>str;
	int res=0,cur_sum=0;
	for(int i=0;i<str.size();i++){
		if(str[i]=='A' || str[i]=='C' || str[i]=='G' || str[i]=='T'){
			cur_sum++;
			res=max(res,cur_sum);
		}else{
			cur_sum=0;
		}
	}
	cout<<res;
	return 0;
}

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

#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;

// 最大公約数 ユークリッドの互除法
ll gcd(ll a, ll b){
    if(b == 0) return a;
    return gcd(b, a % b);
}

int main() {
    int n; cin >> n;
    vector<ll> a(n);
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    sort(all(a));
    ll g = a[0];
    for(int i = 1; i < n; i++){
        g = gcd(g, a[i]);
    }
    cout << g << endl;
}


Measured memory_bytes: 1024
#include<iostream>
    #include<stdio.h>
    //#include <bits/stdc++.h>
    #include<vector>
    #include<float.h>
    #include<iomanip>
    #include<algorithm>
    #include<string>
    #include<cstring>
    #include<math.h>
    #include<cmath>
    #include<sstream>
    #include<set>
    #include<map>
    #include<queue>
    #include <cassert>
    #include <cmath>
    #include<cstdint>

    #define INF 1e7
    #define rep(i,n)for(int i=0;(i)<(int)(n);i++)
    #define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
    #define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
    #define vec(type,n) vector<type>(n)
    #define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))

    using namespace std;
    using ll = long long;
    using Graph = vector<vector<int>>;
    using P = pair<int,int>;

    int main(){
       int n,k;cin>>n>>k;
       int res = 0;
       rep(i,n){
           int h;cin>>h;
           if(h>=k)res++;
       }
       cout<<res;
    }
    


Measured memory_bytes: 256
<?php
$N = intval(fgets(STDIN));
$A = array_map("intval", explode(" ", trim(fgets(STDIN))));
for($i = 0; $i < $N; $i++){
    $B[$i] = $i * 30000+1;
    $C[$i] = ($N-$i-1) * 30000+1;
}
for($i = 0; $i < $N; $i++){
    $B[$A[$i]-1]+=$i;
}
echo implode(" ", $B),"\n";
echo implode(" ", $C),"\n";

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

#define int long long
#define rep(i,l,r) for(int i=(int)(l);i<(int)(r);i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
template<class T>bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,T b){if(a>b){a=b;return 1;}return 0;}

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;

const int inf = 1LL<<60;
const int mod = 1e9 + 7;
const double eps = 1e-9;

/*{
}*/

signed main()
{
	int n;
	string s;
	cin >> n >> s;

	vi t(n);
	rep(i, 0, 2) rep(j, 0, 2){
		t[0] = i;
		t[1] = j;
		
		rep(k, 1, n-1){
			if((s[k] == 'o' and t[k] == 0) or (s[k] == 'x' and t[k] == 1)){
				t[k+1] = t[k-1];	
			}else{
				t[k+1] = (t[k-1]+1)%2;
			}
		}

		if((s[0] == 'o' and t[0] == 0) or (s[0] == 'x' and t[0] == 1)){
			if(t[n-1] != t[1]) continue;
		}else{
			if(t[n-1] == t[1]) continue;
		}

		bool flag = false;
		if((s[n-1] == 'o' and t[n-1] == 0) or (s[n-1] == 'x' and t[n-1] == 1)){
			if(t[n-2] == t[0]) flag = true;
		}else{
			if(t[n-2] != t[0]) flag = true;
		}

		if(flag){
			for(int i : t) cout << "SW"[i];
			cout << endl;
			return 0;
		}
	}

	cout << -1 << endl;
	
	return 0;
}


Measured memory_bytes: 1408
import math
 


def nC2(i):
    if i<=1:
        return 0
    return i*(i-1)//2

def compute(count):
    total = 0
    for i in count:
        total += nC2(i)
    return total


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

count = [0] * (N+1)

for value in data:
    count[value] += 1
    
    
total = compute(count)    

for value in data:
    remove = nC2(count[value])
    add = nC2(count[value]-1)

    print(total-remove+add)


Measured memory_bytes: 85840
N = int(input())
task = [list(map(int, input().split())) for _ in range(N)]

task.sort(key=lambda x: x[1])

t = 0
ans = "Yes"

for i in range(N):
    a = task[i][0]
    b = task[i][1]
    t += a
    if t > b:
        ans = "No"
        break

print(ans)


Measured memory_bytes: 53600
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int R = sc.nextInt();
		if (R < 1200) {
			System.out.println("ABC");
		} else if (R < 2800) {
			System.out.println("ARC");
		} else {
			System.out.println("AGC");
		}
	}
}

Measured memory_bytes: 22868
#include<iostream>
#include<vector>
using namespace std;
int main(){
    int n;
    cin >> n;
    vector<long long> l(n);
    for(int i=0; i<n; i++){
        cin >> l[i];
    }
    int cnt=0;
    for(int i=0; i<n; i++){
        for(int j=i+1; j<n; j++){
            for(int k=j+1; k<n; k++){
                if( i != j && j != k && k != i){
                    long long a = l[i];
                    long long b = l[j];
                    long long c = l[k];
                    if( a != b && b != c && c != a){
                        if( a+b>c && b+c>a && c+a>b){
                            cnt++;
                        }
                    }
                }
            }
        }
    }
    cout << cnt << endl;

}



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

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

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

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 modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

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

    ll S;
    cin >> S;

    ll sqS;
    sqS = ceil(sqrt(double(S)));
    ll subS;
    subS = sqS * sqS - S;



    // cout << S << endl;

    // cout << abs(sqS*sqS - subS) << endl;

    cout << 0 << " " << 0 << " " << sqS << " " << 1 << " " << subS << " " << sqS << endl;
 

    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0; (i)<(n); (i)++)
#define ll long long
#define pp pair<int,int> 
//int 2×10の9乗

//vector<vector<int>> a(n, vector<int>(m));
  //rep(i,n){
    //rep(j,m) cin >> a[i][j]; 
  //}
 
int main() {
  ll n;
  cin >> n;
  ll ans = n*(n-1)/2;
  cout << ans << endl;
} 

Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cstring>
#include <cmath>
#include <climits>
#include <deque>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <array>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
using namespace std;
#define io() ios_base::sync_with_stdio(false); cin.tie(nullptr)
#define ll long long
#define ull unsigned long long
#define ui unsigned int
#define us unsigned short
#define fi first
#define se second
#define IN(i,l,r) (l<i&&i<r)
#define LINR(i,l,r) (l<=i&&i<=r)
#define LIN(i,l,r) (l<=i&&i<r)
#define INR(i,l,r) (l<i&&i<=r)
#define v(T) vector<T>
#define p(T, N) pair<T, N>
#define tp(A, B, C) tuple<A, B, C>
#define ii p(int, int)
#define vi v(int)
#define vii v(p(int, int))
#define vvi v(v(int))
#define vl v(long long)
#define vll v(p(long long, long long))
#define si set<int>
#define msi map<string, int>
#define rsz(a) resize(a)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define qsort(a) sort(all(a))
#define qsortd(a) sort(all(a), greater<>())
#define qsortf(a, f) sort(all(a), f)
#define qsortsi(v) sort(v.begin(), v.end(), [](pair<int, int> a, pair<int, int> b){return a.se < b.se;})
#define pb(n) push_back(n)
#define eb(n) emplace_back(n)
#define pp(a, b) emplace_back(make_pair(a, b))
#define pt(a, b, c) emplace_back(make_tuple(a, b, c))
#define elif else if
#define fori(i, n) for(ll i = 0; i < n; ++i)
#define foris(i, a, b) for(ll i = a; i < b; ++i)
#define forise(i, a, b) for(ll i = a; i <= b; ++i)
#define ford(i, n) for(ll i = n; i >= 0; --i)
#define fords(i, a, b) for(ll i = a; i >= b; --i)
#define fordse(i, a, b) for(ll i = a; i > b; --i)
#define fora(i, a) for (auto &i: a)
#define rev(a) reverse(a.begin(), a.end())
#define revf(a, b, c) (reverse(a.begin() + b, a.begin() + c))
#define umap unordered_map
#define uset unordered_set
#define pq(T) priority_queue<T>
#define rpq(T) priority_queue<T, vector<T>, greater<T> >
#define nl '\n'
#define fileio(in, out) freopen(in, "r", stdin); freopen(out, "w", stdout)
const int mod = 1000000007;
int digits(int n) {
  n = abs(n);
  if(n < 10) return 1;
  elif(n < 100) return 2;
  elif(n < 1000) return 3;
  elif(n < 10000) return 4;
  elif(n < 100000) return 5;
  elif(n < 1000000) return 6;
  elif(n < 10000000) return 7;
  elif(n < 100000000) return 8;
  elif(n < 1000000000) return 9;
  else return 10;
}


int main() {
  io();
  
  int n, k;
  cin >> n >> k;
  pq(ull) arr;
  fori(i, n) {
  	ull a;
    cin >> a;
    arr.push(a);
  }
  fori(i, min(n, k)) arr.pop();
  ull total = 0;
  while(!arr.empty()) {
  	total += arr.top();
    arr.pop();
  }
  cout << total;
  
  return 0;
}

Measured memory_bytes: 2676
#http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_1_D
#?????§??????
#??????????????????????????°???????????????????????¢?????´?????????????????????
def get_maximum_profit(value_list, n_list):
    minv = pow(10,10) + 1
    profit = -minv
    for v in value_list:
        profit = max(profit, v - minv) 
        minv = min(minv, v)
    return profit

def main():
    n_list = int(input())
    target_list = [int(input()) for i in range(n_list)]
    print(get_maximum_profit(target_list, n_list))
    
if __name__ == "__main__":
    main()

Measured memory_bytes: 15740
x,k,d=map(int,input().split())
count=0
import math
c=abs(x)//d
amari=abs(x)%d
if c<=k:
    if (k-c)%2==0:
        print(amari)
    else:
        print(abs(amari-d))
else:
    print(abs(x)-d*k)

Measured memory_bytes: 9156
#include <stdio.h>
#include <stdlib.h>
int main()
{
  int N,x,i,j,minj,count=0;

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

  for(i=0;i<=N-1;i++){
   minj=i;
   for(j=i;j<=N-1;j++){
      if( A[j]<A[minj]){ 
          minj=j;
}
}
          x=A[minj];
          A[minj]=A[i];
          A[i]=x;
if(A[minj]!=A[i])  count++;
     
}

    for(x=0;x<N;x++){
      if(x)printf(" ");
      printf("%d",A[x]);
    }
    printf("\n%d\n",count);

return 0;
}



Measured memory_bytes: 2144
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#define ll long long
using namespace std;

const int maxn = 200010;
int n, m1, m2, u, v;
int f1[maxn], f2[maxn], vis[maxn], cnt[maxn], res[maxn];
vector <int> G[maxn];

int Find1 (int x) {
	if (f1[x] == x) return x;
	return f1[x] = Find1(f1[x]);
}

int Find2 (int x) {
	if (f2[x] == x) return x;
	return f2[x] = Find2(f2[x]);
}

int main () {
	scanf ("%d%d%d", &n, &m1, &m2);
	for (int i = 1; i <= n; i++) f1[i]= f2[i] = i;
	for (int i = 0; i < m1; i++) {
        scanf ("%d%d", &u, &v);
        f1[Find1(u)] = Find1(v);
	}
	for (int i = 0; i < m2; i++) {
        scanf ("%d%d", &u, &v);
        f2[Find2(u)] = Find2(v);
	}
    for (int i = 1; i <= n; i++) G[Find1(i)].push_back(i);
    for (int i = 1; i <= n; i++) if(G[i].size()) {
        for (int j = 0; j < G[i].size(); j++) {
            int t = Find2(G[i][j]);
            if (vis[t] != i) {
                vis[t] = i;
                cnt[t] = 0;
            }
            cnt[t]++;
        }
        for (int j = 0; j < G[i].size(); j++) {
            int t = Find2(G[i][j]);
            res[G[i][j]] = cnt[t];
        }
    }
    for (int i = 1; i <= n; i++) printf("%d%c", res[i], i==n?'\n':' ');
	return 0;
}


Measured memory_bytes: 14720
import sys
input = sys.stdin.readline
'''
allinputs = iter(input().splitlines())
input = lambda : next(allinputs)
#'''

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

count = 0
max_h = 0

for i in range(N):
	if H[i] >= max_h:
		max_h = H[i]
		count += 1
		
print(count)


Measured memory_bytes: 38412
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int A1,A2,A3;
    cin>>A1>>A2>>A3;
    if(A1+A2+A3 >= 22)
        cout<<"bust"<<endl;
    else
        cout<<"win"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, a, n) for(ll i = ((ll) a); i < ((ll) n); i++)
using namespace std;
typedef long long ll;

ll N, A[100000], B[100000], C[100000];

int main(void) {
  cin >> N;
  REP(i, 0, N) cin >> A[i];
  REP(i, 0, N) cin >> B[i];
  REP(i, 0, N) cin >> C[i];

  sort(A, A + N);
  sort(B, B + N);
  sort(C, C + N);

  vector<ll> cnt(100000, 0);
  ll k = 0;
  REP(j, 0, N) {
    while(k < N && C[k] <= B[j]) k++;
    cnt[j] = N - k;
  }
  for(ll j = N - 1; j > 0; j--) cnt[j - 1] += cnt[j];

  ll ans = 0;
  ll j = 0;
  REP(i, 0, N) {
    while(j < N && B[j] <= A[i]) j++;
    ans += cnt[j];
  }

  cout << ans << endl;
}


Measured memory_bytes: 3328
#include<bits/stdc++.h>				//edit by thidailoc
using namespace std;				//team three wolves
typedef long long ll;
typedef vector<ll> vi;
#define fu(i,a,b)   for(ll i=a;i<b;i++)
#define fd(i,b,a)   for(ll i=b;i>=a;i--)
#define pb(i)	    push_back(i)
#define popb()    	pop_back()
#define sc(a) 	    scanf("%lld",&a)
#define sc2(a,b)    scanf("%lld%lld",&a,&b)
#define pr(a)	    printf("%lld ",a)
#define pr2(a,b)    printf("%lld %lld",a,b)
#define lowb(a,n,x) lower_bound(a,a+n,x) -a
#define lowb2(a,x)	lower_bound(a.begin(),a.end(),x) -a.begin()
#define all(x) 		(x).begin(), (x).end()
#define sz(a) 		(ll)a.size()
#define le			length()						
#define re 			return 	
#define debug(x)    cerr << #x << " = " << x << endl
#define INPUT       freopen("locin.txt", "r", stdin)
#define OUTPUT      freopen("locout.txt", "w", stdout)

double const eps = 1e-6;	//dung trong sai so
ll const Base=1e9+7;
ll arr[1000000],mark[1000000];

ll Solves(){
	//INPUT;
	ll n,k,cnt=0,ans=0,x,a,b,c;
	// PROCESSING IN HERE
	sc2(a,b); sc(c);
	if(c>=a and c<=b)cout<<"Yes";
	else cout<<"No";
	re 0;
}


int main(){
	Solves();
}

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  string s, t;
  cin >> n >> m >> s >> t;
  if (n < m) {
    swap(n, m);
    swap(s, t); 
  }
  long long lcm = 1LL * n * m / __gcd(n, m);
  int jump_s = lcm / m;
  int jump_t = lcm / n;
  for (int x = 0, y = 0; x < n; x += jump_s, y += jump_t)
    if (s[x] != t[y])
      return cout << -1 << '\n', 0;
  cout << lcm << '\n';
  return 0;
}

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

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define erep(i, n) for (ll i = 0; i <= (ll)(n); ++i)
#define FOR(i,a,b) for (ll i = (a); i < (ll)(b); ++i)
#define EFOR(i,a,b) for (ll i = (a); i <= (ll)(b); ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } }


int main() {
    int n; cin >> n;
    vector<int> t(n), x(n), y(n);
    rep(i, n) cin >> t[i] >> x[i] >> y[i];
    rep(i, n) {
        if(i == 0) {
            int tmpt = abs(x[i]) + abs(y[i]);
            if(t[i]-tmpt < 0) {
                cout << "No" << endl;
                return 0;
            }
            if((t[i]-tmpt)%2 != 0) {
                cout << "No" << endl;
                return 0;
            }
        } else {
            int tmpt = abs(x[i]-x[i-1]) + abs(y[i]-y[i-1]);
            if(t[i]-t[i-1]-tmpt < 0) {
                cout << "No" << endl;
                return 0;
            }
            if((t[i]-t[i-1]-tmpt)%2 != 0) {
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 1408
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Practice
{
    class Program
    {
        private static int ReadAndParseInt()
        {
            return int.Parse(Console.ReadLine());
        }
        private static int[] ReadAndParseIntArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
        }
        private static long ReadAndParseLong()
        {
            return long.Parse(Console.ReadLine());
        }
        private static long[] ReadAndParseLongArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
        }
        static void Main(string[] args)
        {
            SolveA(args);
            //SolveB(args);
            //SolveC(args);
            //SolveD(args);


        }

        static void SolveA(string[] args)
        {
            int[] ab = ReadAndParseIntArr();
            int a = ab[0];
            int b = ab[1];

            if( b >= a)
            {
                Console.WriteLine(a);
            }
            else
            {
                Console.WriteLine(a - 1);
            }
         }
    }
}


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

using namespace std;

int main(void) {
  string s1, s2, s3;
  cin >> s1 >> s2 >> s3;

  string ans;
  ans += s1[0];
  ans += s2[0];
  ans += s3[0];
  for(int i = 0; i < 3; i++) {
    ans[i] = ans[i] - 'a' + 'A';
  }
  cout << ans << endl;

}

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

const int needs[10] = {0, 2, 5, 5, 4, 5, 6, 3, 7, 6};

bool compare(vector<int>& a, vector<int>& b, int size) {
    int cnta = 0, cntb = 0;
    for (int i = 0; i < size; i++) {
        cnta += a[i];
        cntb += b[i];
    }
    if (cnta != cntb) {
        return cnta > cntb;
    } else {
        return a > b;
    }
}

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> A(M);
    for (int i = 0; i < M; i++) {
        cin >> A[i];
    }
    sort(A.begin(), A.end());
    reverse(A.begin(), A.end());

    vector<vector<int>> dp(N + 1, vector<int>(M, -1));
    for (int i = 0; i < M; i++) {
        dp[0][i] = 0;
    }
    for (int i = 0; i < N; i++) {
        for (int m = 0; m < M; m++) {
            if (dp[i][0] == -1) {
                continue;
            }
            vector<int> tmp = dp[i];
            tmp[m]++;
            if (i + needs[A[m]] <= N && compare(tmp, dp[i + needs[A[m]]], M)) {
                dp[i + needs[A[m]]] = tmp;
            }
        }
    }
    // for (int n = 0; n <= N; n++) {
    //     cout << "n = " << n << endl;
    //     for (int i = 0; i < M; i++) {
    //         cout << A[i] << " " << dp[n][i] << endl;
    //     }
    // }

    string ans = "";
    for (int i = 0; i < M; i++) {
        ans += string(dp[N][i], A[i] + '0');
    }
    sort(ans.begin(), ans.end());
    reverse(ans.begin(), ans.end());
    cout << ans << endl;
}


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


def main():
    n = list(map(int, input().split()))
    numbers = [1, 9, 7, 4]

    for number in numbers:
        if n.count(number) != 1:
            print('NO')
            exit()

    print('YES')


if __name__ == '__main__':
    main()


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

using namespace std;

typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = (ll)1e9 + 7;

int main()
{
  string s; cin >> s;
  int n = s.size();
  int start = -2, end = -2;
  for (int i = 0; i + 1 <= n; ++i) {
    if (s[i] == s[i + 1]) {
      start = i;
      end = i + 1;
      break;
    }
    if (i + 2 < n and s[i] == s[i + 2]) {
      start = i;
      end = i + 2;
      break;
    }
  }
  printf("%d %d\n", start + 1, end + 1);
  return 0;
}


Measured memory_bytes: 512
import java.util.Scanner;

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

		for (int i = 0; i < L.length; i++) {
			L[i] = sc.nextInt();
		}

		int cnt = 0;
		int d = 0;
		for (int i = 0; i < N; i++) {
			d += L[i];
			cnt++;
			if (d>X) {
				break;
			}
			if (i==N-1) {
				cnt++;
			}
		}
		System.out.println(cnt);
	}
}


Measured memory_bytes: 22228
fn get_input() -> String {
    let mut word = String::new();
    std::io::stdin().read_line(&mut word).unwrap();
    word.trim().to_owned()
}

fn main() {
    let ans:Vec<char> = get_input().chars().filter(|&c| c == '1').collect();
    println!("{}", ans.len());
}

Measured memory_bytes: 4352
#include<iostream>
#include<string>
#include<cmath>
#include<map>
using namespace std;
typedef pair< int , int > Pi;
string mas[] = {"ABC","DEF","GHI"},s;
map< char , Pi > mp;
const int dy[] = { 1, 0, -1, 0}, dx[] = { 0, 1, 0 , -1};

bool rec(int now){
  if( now == s.size()) return true;
  for(int i = 0 ; i < 4 ; i++ ){
    int ny = mp[s[now-1]].first + dy[i], nx = mp[s[now-1]].second + dx[i];
    if(nx >= 0 && nx < 3 && ny >= 0 && ny < 3 && mas[ny][nx] == s[now]){
      return rec(now+1);
    }
  }
  return false;
}

int main(){
  for(int i = 0 ; i < 3 ; i++ ){
    for(int j = 0 ; j < 3 ; j++ ) mp[mas[i][j]] = Pi(i,j);
  }
  for(int i = 0 ; i < 1000 ; i++ ){
    cin >> s;
    if(!rec(1)) continue;
    cout << s << endl;
  }
}

Measured memory_bytes: 1188
#include <bits/stdc++.h>
using namespace std;
#define INF 100000005
#define MAX 1004

int p[MAX], q[MAX*MAX];
int main(){
	int n, m, ans, qq;
	while(cin >> n >> m, n){
		for(int i = 1;i <= n;i++)cin >> p[i];
		ans = 0;p[0] = 0;qq = 0;
		
		for(int i = 0;i <= n;i++){
			for(int j = 0;j <= n;j++){
				q[qq++] = p[i] + p[j];
			}
		}
		sort(q, q+qq);
		int t;
		//for(int i = 0;i < qq;i++)cout << q[i] << endl;
		for(int i = 0;i < qq;i++){
			t = upper_bound(q, q+qq, (m-q[i]))-q;
			if(t-1 >= 0)ans = max(ans, q[i]+q[t-1]);
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 6972
N, *LR = [int(_) for _ in open(0).read().split()]
LR = sorted(set([(l, r + 1) for l, r in zip(LR[::2], LR[1::2])]))


class SegmentTree():
    def __init__(self, array, f, ti):
        """
        Parameters
        ----------
        array : list
            to construct segment tree from
        f : func
            binary operation of the monoid
        ti : 
            identity element of the monoid
        """
        self.f = f
        self.ti = ti
        self.n = n = 2**(len(array).bit_length())
        self.dat = dat = [ti] * n + array + [ti] * (n - len(array))
        for i in range(n - 1, 0, -1):  # build
            dat[i] = f(dat[i << 1], dat[i << 1 | 1])

    def update(self, p, v):  # set value at position p (0-indexed)
        f, n, dat = self.f, self.n, self.dat
        p += n
        dat[p] = v
        while p > 1:
            p >>= 1
            dat[p] = f(dat[p << 1], dat[p << 1 | 1])

    def operate_right(self, p, v):  # apply operator from the right side
        f, n, dat = self.f, self.n, self.dat
        p += n
        dat[p] = f(dat[p], v)
        while p > 1:
            p >>= 1
            dat[p] = f(dat[p << 1], dat[p << 1 | 1])

    def operate_left(self, p, v):  # apply operator from the left side
        f, n, dat = self.f, self.n, self.dat
        p += n
        dat[p] = f(v, dat[p])
        while p > 1:
            p >>= 1
            dat[p] = f(dat[p << 1], dat[p << 1 | 1])

    def query(self, l, r):  # result on interval [l, r) (0-indexed)
        f, ti, n, dat = self.f, self.ti, self.n, self.dat
        vl = vr = ti
        l += n
        r += n
        while l < r:
            if l & 1:
                vl = f(vl, dat[l])
                l += 1
            if r & 1:
                r -= 1
                vr = f(dat[r], vr)
            l >>= 1
            r >>= 1
        return f(vl, vr)


minr = min(r for l, r in LR)
lminr = max(l for l, r in LR if r == minr)
maxl = max(l for l, r in LR)
rmaxl = min(r for l, r in LR if l == maxl)
LR2 = [lr for lr in LR if lr not in [(minr, lminr), (maxl, rmaxl)]]
LR = [(minr, lminr)] + LR2 + [(maxl, rmaxl)]
M = len(LR)
if M == 1:
    ans = 2 * (LR[0][1] - LR[0][0])
elif M == 2:
    ans = sum(r - l for l, r in LR)
else:
    #(lminr,minr)と(maxl,rmaxl)が同一または同じ回
    ans = max(0, minr - maxl) + max(r - l for l, r in LR2)
    #(lminr,minr)と(maxl,rmaxl)が違う回 [0,i)と[i,M)に分けて施行すればよい(i∈[1,M))
    st = SegmentTree([r for l, r in LR], min, 10**10)
    for i in range(1, M):
        v1 = max(0, minr - max(lminr, LR[i - 1][0]))
        v2 = max(0, st.query(i, M) - maxl)
        ans = max(ans, v1 + v2)
print(ans)


Measured memory_bytes: 127652
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
#include<iomanip>
#include<map>
#include<set>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using TP = tuple<ll,ll,ll>;
void init_io(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(18);
}
#define MAX_N 52
#define INF 1e18
ll d[MAX_N][MAX_N*MAX_N];
struct edge{ll to,cost,coin;};
vector<edge> G[MAX_N];
vector<ll> c(MAX_N),di(MAX_N);
void dij(ll s){
  priority_queue<TP,vector<TP>,greater<TP>> que;
  fill(d[0],d[MAX_N],INF);
  s = min(s,MAX_N*MAX_N-1ll);
  d[0][s] = 0;
  que.push(TP(0,-s,0));
  while(!que.empty()){
    auto [dis,coin,v]=que.top();
    que.pop();
    coin *= -1;
    coin = min(coin,MAX_N*(MAX_N-1ll));
    if(d[v][coin]<dis) continue;
    ll n_d = dis + di[v];
    ll n_coin = min(coin+c[v],MAX_N*(MAX_N-1ll));
    if(d[v][n_coin]>n_d){
      que.push(TP(n_d,-n_coin,v));
      d[v][n_coin] = n_d;
    }
    for(ll i=0;i<(ll)G[v].size();i++){
      edge e=G[v][i];
      n_coin = coin - e.coin;
      if(n_coin>=0 && d[e.to][n_coin]>dis+e.cost){
        d[e.to][n_coin] = dis+e.cost;
        que.push(TP(d[e.to][n_coin],-n_coin,e.to));
      }
    }
  }
}
ll min_d[MAX_N][MAX_N];
signed main(){
  init_io();
  ll n,m,s;
  cin >> n >> m >> s;
  vector<ll> u(m),v(m),a(m),b(m);
  for(int i=0;i<m;i++){
    cin >> u[i] >> v[i] >> a[i] >> b[i];
    u[i]--;
    v[i]--;
    G[u[i]].push_back({v[i],b[i],a[i]});
    G[v[i]].push_back({u[i],b[i],a[i]});
  }
  for(int i=0;i<n;i++){
    cin >>c[i] >> di[i];
  }
  dij(s);
  for(int i=1;i<n;i++){
    ll ans = INF;
    for(int j=0;j<MAX_N*MAX_N;j++){
      ans = min(d[i][j],ans);
    }
    cout << ans << endl;
  }
}


Measured memory_bytes: 7440
s = input()
n = len(s)

if n == 1:
    sumofall = int(s)
else:
    sumofall = 0
    for i in range(1 << (n-1)):
        j_before = 0
        for j in range(1, n):
            if (1 << (j-1)) & i:
                sumofall += int(s[j_before:j])
                j_before = j
        sumofall += int(s[j_before:])

print(sumofall)
                

Measured memory_bytes: 3060
/*

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

using namespace std;
#define ll long long int
#define mp make_pair
#define pb push_back
#define fi first
#define si second
#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define F(a,n) for(int i=0;i<n;i++){cin>>a[i];}
#define F1(a,n) for(int i=1;i<=n;i++){cin>>a[i];}
#define P(a,n) for(int i=0;i<n;i++){cout<<a[i]<<' ';}cout<<endl;
#define P1(a,n) for(int i=1;i<=n;i++){cout<<a[i]<<' ';}cout<<endl;
#define NF(a,n,m) for(int i=0;i<n;i++){for(int j=0;j<m;j++){cin>>a[i][j];}}
#define NF1(a,n,m) for(int i=1;i<=n;i++){for(int j=1;j<=m;j++){cin>>a[i][j];}}
#define PNF(a,n,m) for(int i=0;i<n;i++){for(int j=0;j<m;j++){cout<<a[i][j]<<' ';}cout<<endl;}cout<<endl;
#define PNF1(a,n,m) for(int i=1;i<=n;i++){for(int j=1;j<=m;j++){cout<<a[i][j]<<' ';}cout<<endl;}cout<<endl;
const int nax = 1e4+5;
const int mod = 1e9+7;

int main(){
	fastIO
	ll n, k;
	cin>>n>>k;
	vector<ll> jump(n+1);
	vector<ll> V_turn(n+1, -1);
	F1(jump, n);
	if(k <= n){
		ll pos=1;
		while(k--){
			pos = jump[pos];
		}
		cout<<pos;
		return 0;
	}
	ll pos=1;
	ll turn=0;
	while(V_turn[pos]==-1){
		//cout<<turn<<" "<<pos<<" next is "<<jump[pos]<<endl;
		V_turn[pos] = turn++;
		pos = jump[pos];
	}

	ll starter = V_turn[pos];
	ll cyc = turn - starter;
	ll last = (k- starter)%cyc;
	while(last--){
		pos = jump[pos];
	}
	cout<<pos;
	return 0;
}

Measured memory_bytes: 6368
#include<bits/stdc++.h>
using namespace std;
int n,k,a[110],x,y,ans;
int main(){
	cin>>n>>k;
	for (int i=0;i<k;i++){
		cin>>x;
		for (int j=0;j<x;j++){
			cin>>y;
			a[y]=1;
		}
	}
	for (int i=1;i<=n;i++) if (a[i]==0) ans++;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3636
//繝・Φ繝励Ξ
#include <bits/stdc++.h>
//#define int long long
#define REP(i,n) for(int i = 0; i < (n); ++i)
#define FOR(i,a,b)  for(int i = (a); i <= (b); ++i)
#define ALL(v) (v).begin(),(v).end()
#define PAIR pair<int,int>
using namespace std;
//constexpr int MOD = 10e9+7;
//constexpr int INF = 1LL << 60;
template <class T> inline bool chmin(T& a, T b){if(a > b){ a = b; return 1;} return 0;}  
template <class T> inline bool chmax(T& a, T b){if(a < b){ a = b; return 1;} return 0;}  
//UP = 0;RIGHT = 1; DOWN = 2; LEFT =3;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
//



signed main (){
   ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
   int A,B;
   cin >> A >> B;
   if(B%A == 0)
   {
      cout << A+B << endl;
      return 0;
   }
   else 
   {
      cout << B-A <<endl;
      return 0;
   }
}



//驛ｨ蛻・・譛蟆丞､
//譖ｴ譁ｰ縺励↑縺・ｴ蜷遺・邏ｯ遨阪ｏ
//莠梧ｬ｡蜈・↓縺励◆縺・・縺・ｂ縺呎ｳ・
//荳邂・園繧剃ｽ募屓繧よ峩譁ｰ縺励◆縺・・Segment Tree(縺溘□縺怜叙蠕涌(logN))
//遽・峇繧剃ｽ募屓繧よ峩譁ｰ縺励◆縺・・Lazy Segment Tree


Measured memory_bytes: 256
N,M = map(int,input().split())
X = list(map(int, input().split()))
 
if N>=M: print(0)
else:
  X.sort()
  delta_X = [X[i]-X[i-1] for i in range(1,M)]
  delta_X.sort()
  print(sum(delta_X[0:M-N]))

Measured memory_bytes: 20560
n, x = [int(_) for _ in input().split()]

def p(n, x):
    if n == 0:
        return 1
    else:
        if x == 1:
            return 0
        elif x < (1 << n + 1) - 1:
            return p(n - 1, x - 1)
        elif x == (1 << n + 1) - 1:
            return 1 << n
        elif x < (1 << n + 2) - 3:
            return (1 << n) + p(n - 1, x - ((1 << n + 1) - 1))
        else:
            return (1 << n + 1) - 1

print(p(n, x))


Measured memory_bytes: 3060
import Control.Applicative
import Control.Monad
import Data.Array
import Data.Array.ST
import Data.Char
import Data.List
import qualified Data.Map as M
import qualified Data.Set as S
import Text.Printf

readInts :: IO [Int]
readInts = map read . words <$> getLine

main :: IO ()
main = do
  [x1,y1,x2,y2] <- map read . words <$> getLine
  print $ sqrt $ (x1 - x2)^2 + (y1 - y2)^2
  


Measured memory_bytes: 3964
#[allow(unused_imports)]
use proconio::{
    fastout, input,
    marker::{Bytes, Chars, Isize1, Usize1},
};

use std::cmp::Reverse;
use std::collections::HashSet;

fn main() {
    input! {
        h:usize,w:usize,m:usize,
    }
    let mut target = HashSet::new();
    let mut hv = vec![(0, 0); h];
    let mut wv = vec![(0, 0); w];

    for _ in 0..m {
        input! {
            y:Usize1,x:Usize1,
        }
        target.insert((y, x));
        hv[y].1 += 1_usize;
        wv[x].1 += 1_usize;
    }
    for i in 0..h {
        hv[i].0 = i;
    }
    for i in 0..w {
        wv[i].0 = i;
    }
    wv.sort_by_key(|z| Reverse(z.1));
    let mut ans = 0;
    if h == 1 {
        ans = hv[0].1;
    } else if w == 1 {
        ans = wv[0].1;
    } else {
        for i in 0..h {
            let buf = hv[i].1;
            let mut buf2 = wv[0].1;
            if target.contains(&(i, wv[0].0)) {
                buf2 -= 1;
            }
            ans = std::cmp::max(ans, buf + buf2);
            if target.contains(&(i, wv[0].0)) {
                for j in 1..w {
                    if wv[j].1 + 1 < wv[0].1 {
                        break;
                    }
                    if !target.contains(&(i, wv[j].0)) {
                        ans = std::cmp::max(ans, buf + wv[j].1);
                        break;
                    }
                }
            }
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 28584
import java.util.Scanner;

public class Main {

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

		Scanner sc = new Scanner(System.in);
		//入力表示
		int A=sc.nextInt();
		int B=sc.nextInt();
		
		if( A * B % 2 == 1){
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 27092
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<map>
#include<cstdio>
#include<stack>
#include<queue>
#include<fstream>
#include<cstdio>
#include<deque>
#include<iomanip>
#include <random>

using namespace std;
#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);(i)--)
#define all(a) (a).begin(),(a).end()
#define reall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
const double pi = acos(-1.0);

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef deque<ll> dll;
ll mod = 1e9 + 7;

int color[12][12];
int ourx, enemyx;
void dfs() {

}

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

	ll n, m, x;
	cin >> n >> m >> x;
	ll l = 0, r = 0;
	rep(i, m) {
		ll q;
		cin >> q;
		if (q < x) l++; //ok1 }
		else r++; //ok2 }
	}
	//cout << l << r;
	if (l < r) cout << l << endl;
	else cout << r << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int A, B, K;
  cin >> A >> B >> K;
  if(A >= K) {
    cout << A - K << " " << B << endl;
  }
  else if(A + B >= K){
    cout << 0 << " " << A + B - K << endl;
  }
  else {
    cout << 0 << " " << 0 << endl;
  }
}

Measured memory_bytes: 3636
using System;
using System.Linq;
using System.Collections.Generic;


namespace AtCoderPractice
{
    class Program
    {
        static void Main(string[] args)
        {
            long X = long.Parse(Console.ReadLine());
            long A = long.Parse(Console.ReadLine());
            long B = long.Parse(Console.ReadLine());

            //所持金K
            long K = X - A;

            while (K > 0)
            {
                K -= B;
                if (K < B) break;
            }
            Console.WriteLine(K);

        }
    }
}


Measured memory_bytes: 27452
m, d = map(int, input().split())
cnt = 0
for mm in range(1, m+1):
    for dd in range(10, d+1):
        d1 = dd // 10
        d2 = dd % 10
        if d1 < 2 or d2 < 2:
            continue
        if mm == d1 * d2:
            cnt += 1
print(cnt)

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

using namespace std;

#define rep(i,n) for(int i=0;i<(n);i++)
#define repr(i,x,n) for(int i=(x);i<(n);i++)
#define sortn(a) sort((a).begin(),(a).end())
#define sortr(a) sort((a).begin(),(a).end(),greater<int>())
#define MOD 1000000007

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;

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

    rep(i,s.size()){
        if(i%2 == 0){
            if(s[i] == 'L'){
                cout << "No" << endl;
                return 0;
            }
        }else{
            if(s[i] == 'R'){
                cout << "No" << endl;
                return 0;
            }
        }
    }

    cout << "Yes" << endl;
    
    return 0;
}



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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;

#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846

#define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define ASC(x) sort(ALL((x)))
#define DESC(x) sort(ALL((x)),greater<ll>())
#define REV(x) reverse(ALL((x)))
#define pb push_back

int main()
{
    string s, t;
    cin >> s >> t;

    ll Ns = SZ(s), Nt = SZ(t);
    map<char,vec> A;
    map<char,ll> I;
    REP(i,0,Ns) A[s[i]].pb(i);
    REP(i,0,26) I['a'+i] = 0;

    /*
    FORR(a,A) {
        PS(a.first);
        FORR(i,a.second) PS(i);
        PR("");
    }
    */

    ll j, k = 1;
    ll idx = -1, prev = 0;
    REP(i,0,Nt) {
        if(SZ(A[t[i]]) == 0) {
            k = -1;
            break;
        }
        I[t[i]] = upper_bound(ALL(A[t[i]]), idx) - A[t[i]].begin();
        if(I[t[i]] == SZ(A[t[i]])) {
            I[t[i]] = 0;
            idx = A[t[i]][I[t[i]]];
            k += Ns - prev + idx;
        }
        else {
            idx = A[t[i]][I[t[i]]];
            k += idx - prev;
        }
        // cout << t[i] << ":" << A[t[i]][I[t[i]]] << " ";
        prev = idx;
    }
    PR(k);

    return 0;
}

/*



*/

Measured memory_bytes: 4640
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b;
  int ans = 0;
  cin>>a;
  for(int i=105;i<=a;i=i+2)
  {
    b=0;
    for(int j=1;j<=i;j=j+2) 
    if(i%j==0) b++;
    if(b==8) ans++;
  }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<cmath>
#include<vector>
#include<algorithm>
#include <array>
using namespace std;


int main(){
	int n;
	vector<int> x;
	cin >> n;
	for(int i=0;i<n;i++){
		int tmp;
		cin >> tmp;
		x.push_back(tmp);
	}
	sort(x.begin(), x.end());
	int d=0;
	int result;
	for(int i=0;i<(n-1);i++){
		int tmp = min(x[i],x[n-1]-x[i]);
		if(d<tmp){
d =tmp;
			result = x[i];
		}
	}
	cout << x[n-1] <<" "<<result<<endl;
}

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

int main(){
  
  string N;
  cin >> N;
  
  if(N.at(0) == N.at(1) && N.at(1) == N.at(2) && N.at(2) ==N.at(0)){
    
    cout << "Yes" << endl;;
  }
  else if(N.at(1) == N.at(2) && N.at(2) == N.at(3) && N.at(3) == N.at(1)){
    
    cout << "Yes" << endl;
  }
  
  else{
    cout << "No" << endl;
  
  }
  
}

Measured memory_bytes: 3524
/*ex5-4
ryo_1129*/

#include <stdio.h>

int main(void){
    //入力の文字列は10文字以下なので\0を含めて11で定義する
    char str[11],*ptr;
    //ACGT配列の長さと、最長の長さをいれる変数
    int length_counter=0,max_length=0;
    scanf("%s",str);
    ptr = str;
    while(*ptr){
        //ACTGが続く間はlength_counterに部分文字列の長さを記録する
        if(*ptr=='A' || *ptr=='G' || *ptr=='C' || *ptr=='T'){
            length_counter++;
        //ACGT以外の文字が出てきたら、部分文字列が最長か比較しlength_counterをリセットする
        }else{
            if(max_length<length_counter){
                max_length = length_counter;
            }
            length_counter=0;
        }
        ptr++;
    }
//AGCTのみで文字列が構成されていた場合
if(max_length<length_counter){
    max_length = length_counter;
}

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

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
#define REPi(i, a, b) for(int i=int(a); i<int(b); i++)
#define MEMS(a,b) memset(a,b,sizeof(a))
#define mp make_pair
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll MOD = 1e9+7;
const ll INF = 1e13;

typedef tuple<ll, ll, ll> T;

ll N, M, S;
vector<ll> G[100];
ll C[100];
ll D[100];
ll A[100][100];
ll B[100][100];

// [N][S] -> v, s, d
vector<T> V[100][4000];
ll d[100][4000];
bool F[100][4000];

void min_path(ll silver){
    d[0][silver] = 0;
    priority_queue<T, vector<T>, greater<T>> que;
    que.push(make_tuple(0, 0, silver));
    while(!que.empty()){
        auto t = que.top();
        que.pop();
        ll time = get<0>(t);
        ll ver = get<1>(t);
        ll sil = get<2>(t);
        if(F[ver][sil]) continue;
        F[ver][sil] = true;
        for(auto&& t : V[ver][sil]){
            ll n, s, cost;
            n = get<0>(t);
            s = get<1>(t);
            cost = get<2>(t);
            if(d[n][s] > time + cost){
                d[n][s] = time + cost;
                que.push(make_tuple(d[n][s], n, s));
            }
        }
    }
}

int main(){
    cin >> N >> M >> S;
    REP(i,M){
        ll u, v, a, b;
        cin >> u >> v >> a >> b;
        u--, v--;
        G[u].emplace_back(v);
        G[v].emplace_back(u);
        A[u][v] = a;
        B[u][v] = b;
        A[v][u] = a;
        B[v][u] = b;
    }
    REP(i,N){
        ll c, d;
        cin >> c >> d;
        C[i] = c;
        D[i] = d;
    }

    REP(i,N){
        REP(j,3100){
            d[i][j] = INF;
        }
    }

    REP(v,N){
        ll c, d;
        c = C[v];
        d = D[v];
        REP(k,3100){
            //(v, k) -> (n, k-a);
            for(auto&& n : G[v]){
                ll a, b;
                a = A[v][n];
                b = B[v][n];
                if(k >= a){
                    V[v][k].emplace_back(n, k-a, b);
                }
            }

            //(v, k) -> (v, k+c);
            V[v][k].emplace_back(v, k+c, d);
        }
    }

    S = (S > 3000) ? 3000 : S;
    min_path(S);

    REPi(i, 1, N){
        ll ans = 1e13;
        REP(k,3000){
            chmin(ans, d[i][k]);
        }
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 43420
import sys
import numpy as np
input = sys.stdin.readline

N = int(input())
h = np.array(list(map(int, input().split())))

arr = np.array([0]*N)
for i in range(N):
    if i == 0:
        arr[i] = 0
    elif i == 1:
        arr[i] = abs(h[i]-h[i-1])
    else:
        A = arr[i-2] + abs(h[i] - h[i-2])
        B = arr[i-1] + abs(h[i] - h[i-1])
        arr[i] = A if A <= B else B
print(arr[-1])

Measured memory_bytes: 22680
#pragma target("avx")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef unordered_map<ll, ll> U_MAP;
typedef priority_queue<ll> pq;
typedef priority_queue<ll, vector<ll>, greater<ll>> rpq;
constexpr ll INF = 1e9, MOD = 1e9 + 7, ohara = 1e6 + 10;
constexpr ll LINF = 1e18;

#define rep(i, n) for (ll(i) = 0; (i) < (int)(n); (i)++)
#define rrep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrrep(i, a, b) for (ll i = (a); i >= (b); i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout << (x) << endl
#define doublecout(a) cout << fixed << setprecision(15) << a << endl;
#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string)s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto& x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

//------ Believe yourself as a genius!!!!!! ------

int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
// int dy[]={-1,0,1,-1,1,-1,0,1};int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"), s[ohara];
ll n, cnt, ans, a, b, c, d, tmp, m, h, w, x, y, sum, k, q;
map<string, ll> mp;

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

  cin >> n;
  rep(i, n) {
    cin >> s[i];
    sort(all(s[i]));
    mp[s[i]]++;
  }
  rep(i, n) {
    ans += mp[s[i]] * (mp[s[i]] - 1) / 2;
    mp[s[i]] = 0;
  }
  Cout(ans);
  return 0;
}

Measured memory_bytes: 23680
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;

int main(){
	int k, x;
	cin >> k >> x;
	for(int i = max(x-k+1, -1000000); i <= min(x+k-1, 1000000); i++){
		cout << i << " ";
	}
	cout << endl;
}

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

int main(void){
  int n,i,max,min;
  int *R;
  scanf("%d",&n);
  R=(int *)malloc(sizeof(int)*n);
  for(i=0;i<n;i++)
    scanf("%d",&R[i]);

  max=-2000000000;
  min=R[0];

  for(i=1;i<n;i++){
    if(max<R[i]-min)max=R[i]-min;
    if(min>R[i])min=R[i];
  }
  
  printf("%d\n",max);
  return 0;
}


Measured memory_bytes: 2568
n,m=map(int,input().split())
inf=10**9
cost=[inf for i in range(m)]
for i in range(m):
  a,b=map(int,input().split())
  c=[int(x)-1 for x in input().split()]
  s=0
  for j in c:
    s|=1<<j
  cost[i]=[s,a]
#print(cost)

dp=[inf]*(1<<n)
dp[0]=0
for s in range(1<<n):
  for bit,c in cost:
    dp[s|bit]=min(dp[s|bit], dp[s]+c)
#print(dp)
print(-1 if dp[-1]==inf else dp[-1])



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

int main()
{
	while (true) {
		int m, nmin, nmax;
		cin >> m >> nmin >> nmax;

		if (m == 0 && nmin == 0 && nmax == 0) {
			break;
		}

		vector<int> P;

		for (int i = 0; i < m; i++) {
			int temp;
			cin >> temp;
			P.push_back(temp);
		}

		sort(P.begin(), P.end());

		int gap = 0;
		int num;

		for (int i = nmin; i <= nmax; i++) {
			if (P[m - i] - P[m - 1 - i] >= gap) {
				gap = P[m - i] - P[m - 1 - i];
				num = i;
			}
		}

		cout << num << endl;
	}

	return 0;
}

Measured memory_bytes: 3064