akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

const int A_MAX = 1000000;

int main(void) {
    int N;
    cin >> N;
    vector< int > A(N), num(A_MAX + 1, 0);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
        ++num[A[i]];
    }
    sort(A.begin(), A.end());
    int ans = 0;
    vector< bool > T(A[N - 1] + 1, true);
    for (int i = 0; i < N; i++) {
        if (!T[A[i]]) {
            continue;
        }
        if (num[A[i]] == 1) {
            ++ans;
        }
        for (int j = A[i]; j <= A[N - 1]; j += A[i]) {
            T[j] = false;
        }
    }
    printf("%d\n", ans);

    return 0;
}


Measured memory_bytes: 8044
def calc(x,y,op):
    if op=="+":
        return x+y
    else:
        return x-y

if __name__ == '__main__':
    ABCD=input()
    A=int(ABCD[0])
    B=int(ABCD[1])
    C=int(ABCD[2])
    D=int(ABCD[3])
    operators=["+","-"]
    ans=[A,B,C,D,"=7"]
    import itertools

    for ops in itertools.product(operators,repeat=3):
        temp=calc(A,B,ops[0])
        temp=calc(temp,C,ops[1])
        temp=calc(temp,D,ops[2])
        if temp==7:
            print("{}{}{}{}{}{}{}=7".format(A,ops[0],B,ops[1],C,ops[2],D))
            break





Measured memory_bytes: 3064
// https://atcoder.jp/contests/abc132/tasks/abc132_e
#include <bits/stdc++.h>
#define rep(i,x) for(int i=0;i<x;i++)
using namespace std;
typedef long long ll;

using Graph = vector<vector<int>>;
using pint = pair<int,int>;

int N,M;
Graph G;
int s,t;


void solve(){
  vector<vector<ll>> dist(N,vector<ll>(3,-1));
  queue<pint> que;
  dist[s][0] = 0;
  que.push(pint(s,0));

  while(!que.empty()){
    auto p = que.front();que.pop();
    int v = p.first;
    int parity = p.second;

    for(auto nv:G[v]){
      int nparity = (parity+1) % 3;
      if(dist[nv][nparity] == -1){
        dist[nv][nparity] = dist[v][parity] + 1;
        que.push(pint(nv,nparity));
      }
    }
  }

  if(dist[t][0] == -1) cout<< -1;
  else cout<< dist[t][0]/3;
}





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

  G.assign(N,vector<int>());

  rep(i,M){
    int u,v;
    cin>>u>>v;
    u--,v--;
    G[u].push_back(v);
  }
cin>>s>>t;
s--,t--;
  solve();
}


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

int main(){
    int n, k;
    cin >> n >> k;
    
    // 入力 -------------------------------
    vector<double> vec(n);
    for (int i = 0; i < n; i++) {
        cin >> vec.at(i);
    }
    
    // 期待値の計算 -----------------------
    vector<double> vec2(n);
    for (int i = 0; i < n; i++) {
        vec2.at(i) += (1.0 + vec.at(i)) / 2.0;
    }
    
    // 累積和の計算 -----------------------
    vector<double> vec3(n);
    vec3.at(0) = vec2.at(0);
    for (int i = 1; i < n; i++) {
        vec3.at(i) = vec3.at(i - 1) + vec2.at(i);
    }
    
    // 累積和を使用して最大値の探索 -------
    double maxsum = 0;
    for (int i = k - 1; i < n; i++) {
        double sum = 0;
        if (i == k - 1) {
            sum = vec3.at(k - 1);
        } else {
            sum = vec3.at(i) - vec3.at(i - k);
        }
        // cout << sum << endl;
        maxsum = max(maxsum,sum);
    }
    
    cout << fixed << setprecision(8) << maxsum << endl;
    return 0;
}


Measured memory_bytes: 4992
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		String T = sc.next();
		sc.close();
		T = T.substring(0,T.length()-1);
		if(S.equals(T)) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}

}

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

#define f(i,a,b) for( ll  i = a; i < (ll) b ; i++ ) 
#define af(i,a,b) for( ll i = a; i >= b ; i--)
#define rep(i,a,b,k) for(ll i = a; i < b ; i+= k )
#define arep(i,a,b,k) for( ll i = a; i >= b ; i-= k)
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz(a) (ll) a.size()
#define all(a) a.begin(), a.end()
#define sor(a) sort( a.begin(), a.end() )
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define inter   ios::sync_with_stdio(false);cin.tie(0)

// policy-based



using namespace std;


typedef long long ll; // int or long long
typedef long double ld;
typedef pair<ll,ll> ii ;
typedef vector<ll>  vi ;
typedef vector<ii> vii ;



 
const ll MAX = 3e5+100;
const ll inf = 1e9;
const ll mod = 1e9+7;

ll bp(ll a,ll e){
	if(e == 0) return 1;
	if(e&1) return (a*bp(a,e-1))%mod;
	ll x = bp(a,e>>1);
	return (x*x)%mod;
}

int main(){
	fastio;
	ll n;
	cin >> n;
	if(n == 1) cout << "0\n";
	else if(n == 2) cout << "2\n";
	else{
		cout << (2*mod+bp(10,n)-2*bp(9,n)+bp(8,n) )%mod << endl;
	}
	return 0;
}

Measured memory_bytes: 3648
n = int(input())
b = list(map(int, input().split()))
ans = []
for i in reversed(range(n)):
    for j in reversed(range(i+1)):
        if b[j]==j+1:
            ans.append(b[j])
            b.pop(j)
            break

        if j==0:
            print(-1)
            exit()
for i in reversed(range(n)):
    print(ans[i])

Measured memory_bytes: 3060
#include<stdio.h>
#define N 501
#define INFTY (1<<21)

int main()
{
  int M[N][N];
  int n,u,k,v;
  int i,j;

  scanf("%d",&n);

  for(i=0;i<n;i++)
    {
      for(j=0;j<n;j++)
	{
	  M[i][j]=0;
	}
    }

  for(i=0;i<n;i++)
    {
      scanf("%d %d",&u,&k);
      u--;
      for(j=0;j<k;j++)
	{
	  scanf("%d",&v);
	  v--;
	  M[u][v]=1;
	}
    }

  for(i=0;i<n;i++)
    {
      for(j=0;j<n;j++)
	{
	  if(j) printf(" ");
	  printf("%d",M[i][j]);
	}
      printf("\n");
    }
  return 0;
}



Measured memory_bytes: 2052
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順

int main() {
    string a, b;
    cin >> a >> b;
    string d = a + b;
    int e = atoi(d.c_str());
    int c = (int)sqrt(e);
    if (c * c == e) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
map<string,int>m;
map<string,int>::iterator it; 
int main(){
	int n;
	cin>>n;
	long long ret = 0;
	while(n--){
		string s;
		cin>>s;
		sort(s.begin(),s.end());
		it = m.find(s);
		if(it!=m.end()){
			ret+=it->second;
			it->second+=1;
		}
		else m.insert(make_pair(s,1));
	}
	cout<<ret;
}

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

int main() {
	int N; cin >> N;
	vector<int>price(N);
	vector<int>valley;
	long long int money=1000,stock=0;
	int num = 0;
	for (int i = 0; i < N; i++)cin >> price[i];

	for (int i = 0; i < N - 1; i++) {
		num++;
		if (num == N)break;
		if (price[i] == price[i + 1])price.erase(price.begin() + i),i--;
	}

	int temp = 0;
	bool down = true;

	while (true) {
		while (down) {
			if (temp >= price.size()-1)break;
			if (price[temp] > price[temp + 1]) { 
				temp++; 
			}
			else {
				down = false;
				break;
			}
		}
		stock = money/price[temp];
		money -= stock * price[temp];
		while (!down) {
			if (temp >= price.size()-1)break;
			if (price[temp] < price[temp + 1]) {
				temp++;
			}
			else {
				down = true;
				break;
			}

		}
		money += stock * price[temp];
		stock = 0;
		if (temp >= price.size()-1)break;
	}
	cout << money << endl;
}

Measured memory_bytes: 3132
#include <iostream>
#include <vector>
#include <deque>
#include <climits>
#include <cmath>
#include <algorithm>
#include <string>
using namespace std;
#define ll long long int
#define ld long long double
#define vi vector<long long int>
#define vc vector<char>
#define vs vector<string>
#define pb push_back
#define mp make_pair
#define f(i,a,n) for(i = (a); i < (n); i++)
#define fi(i,a,n) for(i = (a); i <= (n); i++)
#define F first
#define S second
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    double n,k;
    cin>>n>>k;

    double sum = 0;

    for(ll i=1;i<=n;i++){

        if(i>=k){
            sum += (1/n);
        }
        else{
            double p = ceil(log2(k/i));
            double t = 1/pow(2,p);
            double s = t/n;
            //cout<<p<<" "<<t<<" "<<s<<endl;
            sum += s;
        }

    }

    printf("%.12lf",sum);
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define REP(i,a) for(int i = 0; i < (a);i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;
using Graph = vector < vector<int>>;
long int sum[200020] = {};
int main() {
	int N;
	cin >> N;
	vector<int> up;
	int upsum = 0;
	vector<int> down;
	vector<int> goukei;
	int downsum = 0;
	int total = 0;
	for (int i = 0; i < N; i++) {
		int a;
		cin >> a;
		upsum = upsum + a;
		up.push_back(a);
	}
	for (int i = 0; i < N; i++) {
		int b;
		cin >> b;
		downsum = downsum + b;
		down.push_back(b);
	}
	upsum = upsum + down[N - 1];
	int ko = upsum;
	if (N == 1) {
		cout << up[N - 1] + down[N - 1];
		return 0;
	}
	else {
		for (int i = 0; i < N; i++) {
			total = total + up[i];
			/*if (i == N - 1) {
				cout << total + down[N - 1];
				break;
				
			}*/
			upsum = upsum - up[i];
			/*if (downsum > upsum) {
				cout << total + downsum;
				return 0;
			}*/
			goukei.push_back(total + downsum);
			downsum = downsum - down[i];
		}
	}
	sort(goukei.begin(), goukei.end());
	cout << max(goukei[N - 1],ko) << endl;;
}

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

int main() {
  int N;
  cin >> N;
  
  int count=0;
  for(int i=0 ; i<N ; i++){
    int a;
    cin >> a;
    while(a%2==0){
      count++;
      a>>=1;
    }
  }
  
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 3648
#include"bits/stdc++.h"
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define eb emplace_back

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

void Main(){
	int D, G;
	cin >> D >> G;
	G /= 100;
	vi p(D), c(D);
	rep(i, D) {
	    cin >> p[i] >> c[i];
	    c[i] /= 100;
	}

	// bit全探索, 1 <= D <= 10
	int ans = INT_MAX;

	rep(bit, (1<<D)){
	    int tot = 0;
	    int num = 0;
	    vector<bool> flag(D, false);
	    
	    rep(i, D) {
	        if(bit & (1<<i)){
	            // i 番目の問題を全完してコンプリートボーナスをもらう
	            // i 番目の問題の基本点 = (i+1) 点
	            tot += (i+1) * p[i] + c[i];
	            num += p[i];
	            flag[i] = true;
	        }
	    }
	    
	    bool pos = true;
	    while(tot < G && pos){
	        // 点数の高い問題から貪欲
	        // i = D-1 -> 0; 点数は D 点 -> 1 点
	        // flag[i] = true のときはスルー
	        // flag[i] = false のときは pc[i].fi-1 問まで解いて良い
	        rep3rev(i, D-1, 0){
	            if(flag[i]) continue;
	            if(tot + (i+1) * (p[i]-1) < G){
	                tot += (i+1) * (p[i]-1);
	                num += p[i]-1;
	            }
	            else{
	                // (G-tot)/(i+1) を切り上げた問題数を解いて終了
	                int cnt = (G-tot+i)/(i+1);
	                tot += (i+1) * cnt;
	                num += cnt;
	                break;
	            }
	            if(i == 0 && tot < G) pos = false;
	        }
	    }
	    
	    // cout << "bit = " << bit << ", num = " << num << ", tot = " << tot << endl;
	    if(pos) ans = min(ans, num);
	}
	
	cout << ans << endl;
	return;
}

int main(){
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <string>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <tuple>
#include <numeric>
#include <stdlib.h>
#include <time.h>
#include <chrono>
#define rep(i, s, g) for ((i) = (s); (i) < (g); ++(i))
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = (1ll << 60);

ll d;
vector<ll> c(26 + 1);
vector<vector<ll>> s(365 + 1, vector<ll>(26 + 1, 0));

ll scoring(vector<int> t)
{
    ll ans = 0;
    vector<ll> last(d + 1, 0);

    for (int i = 1; i <= d; i++)
    {
        ans += s[i][t[i]];
        last[t[i]] = i;

        for (int j = 1; j <= 26; j++)
        {
            ans -= c[j] * (i - last[j]);
        }
    }

    return ans;
}

int main(void)
{
    srand(time(NULL));
    cin >> d;

    for (int i = 1; i <= 26; i++)
    {
        cin >> c[i];
    }

    for (int i = 1; i <= d; i++)
    {
        for (int j = 1; j <= 26; j++)
        {
            cin >> s[i][j];
        }
    }

    vector<int> BestT(d + 1, 1);

    for (int i = 1; i <= d; i++)
    {
        BestT[i] = rand() % 26 + 1;
    }

    // printf("%lld\n", scoring(BestT));

    double BestScore = scoring(BestT);

    auto start = chrono::system_clock::now();
    vector<int> t(d + 1);

    double T0 = 1e6;
    double T1 = 1e4;
    double TL = 1950;

    ll count = 0;

    while (1)
    {
        auto end = chrono::system_clock::now(); // 計測終了時刻を保存
        auto dur = end - start;                 // 要した時間を計算
        auto msec = chrono::duration_cast<chrono::milliseconds>(dur).count();

        if (msec >= 1950)
        {
            break;
        }

        double T = powf(T0, 1 - msec / TL) * powf(T1, msec / TL);

        t = BestT;

        t[rand() % d + 1] = rand() % 26 + 1;

        double score = scoring(t);

        if (exp((score - BestScore) / T) > 0.5)
        {
            BestT = t;
            BestScore = score;
        }
    }

    for (int i = 1; i <= d; i++)
    {
        printf("%d\n", BestT[i]);
    }

    // printf("%lld\n", scoring(BestT));
}


Measured memory_bytes: 4460
#include<bits/stdc++.h>
using namespace std;
using lli = long long;
using pii = pair<int, int>;

#define rep(i,k,n) for(int i=(k); i != int(n); ++i)
#define sz(x) x.size()
#define all(x) x.begin(), x.end()

#define dbg(x) cout << #x << '=' << x << '\n'
#define dbg2(x, y) cout << #x << '=' << x << ' ' << #y << '=' << y << '\n' 

#define input() (*istream_iterator<int>(cin))
#define strin() (*istream_iterator<string>(cin))
#define output(x) cout << x << '\n' 

int main(){
    ios::sync_with_stdio(false);
    int n = input();
    set<string> type;
    while(n--) type.insert(strin());
    cout << sz(type);
}

Measured memory_bytes: 19248
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <bitset>
#include <complex>
#include <cstdint>
#include <unordered_set>
#include <unordered_map>
using namespace std;
typedef long long i64;
typedef vector<int> ivec;
typedef vector<string> svec;

//?????°?????£?¨?
i64 cnt = 0;
int l;
int A[1000000];
int N;
ivec G;

//??¢??°??????
void insertionSort(int A[], int N, int g){
    for (int i=g; i<N; i++){
        int v = A[i];
        int j = i - g;
        while (j >= 0 && A[j] > v){
            A[j+g] = A[j];
            j -= g;
            cnt++;
        }
        A[j+g] = v;
    }
}

void shellSort(int A[], int N){
    for (int h = 1;;){
        if (h > N) break;
        G.push_back(h);
        h = 3*h + 1;
    }

    for (int i=G.size()-1; i>=0; i--){
        insertionSort(A, N, G[i]);
    }
}




int main(){
    //?????????????????????
    scanf("%d", &N);
    for(int i = 0; i < N; i++) scanf("%d", &A[i]);

    //?????????


    //??¢?????´?????????
    shellSort(A, N);


    //??????
    printf("%d\n", G.size());

    for(int i = G.size()-1; i>=0; i--){
        if (i != G.size()-1) printf(" ");
        printf("%d", G[i]);
    }
    printf("\n");
    
    printf("%d\n", cnt);

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


    return 0;
}

Measured memory_bytes: 5100
import java.util.Scanner;

public class Main{
	public static void main(String args[]){
		  Scanner scanner = new Scanner(System.in);
          int a = scanner.nextInt();
          int b = scanner.nextInt();
      
      if(a * b % 2 == 0){
      	System.out.println("Even");
      }else{
        System.out.println("Odd");
      }
	}
}

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

int main() {
	int n;
	string s;
	int k;
	cin >> n >> s >> k;
	k--;
	for(int i = 0; i < n; i++){
		if(s[k] != s[i]){
			cout << "*" ;
		}else{
			cout << s[i];
		}
	}
	cout << endl;
	
	// your code goes here
	return 0;
}


Measured memory_bytes: 256
import copy
N = int(input())
p = list(map(int, input().split()))
p_sorted = copy.copy(p)
p_sorted.sort()
diff = []
for i in range(N):
    if p[i] != p_sorted[i]:
        diff.append([p[i], i])
if len(diff) <= 2:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 3444
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = (s); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) for(int i = (n); i >= 0; i--)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(void)
{
    IOS
    ll A; string B;
    cin >> A >> B;
    auto d = B.find('.');
    ll b1 = stoll(B.substr(0,d));
    ll b2 = stoll(B.substr(d+1));
    ll b = b1*100 + b2;
    ll ans = A * b / 100;
    cout << ans << '\n';

    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll l;
    cin >> l;
    double ans = 0;
    for(double i = 0; i < l; i += 0.0001) {
        double x = (l - i) / 2;
        double tmp = i * x * x;
        ans = max(ans, tmp);
    }
    printf("%.10f\n", ans);
    return 0;
}


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

using namespace std;


int main(void)
{
    int N,M; cin >> N >> M;

    priority_queue<int> a;
    for(int i = 0; i < N; i++){
        int x; cin >> x;
        a.push(x);
    }

    for(int i = M; i > 0; i--)
    {
        int y = a.top();
        a.pop();
        a.push(y/2);
    }

    int64_t sum = 0;
    while(a.size() != 0)
    {
        sum += a.top();
        a.pop();
    }

    cout << sum << endl;
}

Measured memory_bytes: 892
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <string>
#include <vector>
#include <limits>
#include <algorithm>
#include <utility>
#include <sstream>
#include <numeric>
#include <iterator>

using namespace std;

#define repd(i,a,b) for (int i=(a);i<(b);++i)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
typedef pair<int, int> P;

int main(int argc, const char * argv[]) {
  int n;
  cin >> n;
  vector<vector<int> > vec(100, vector<int> (n, 0));
  rep(i, n){
    int x;
    cin >> x;
    rep(j, 100){
      vec[j][i] = pow(x - (j+1), 2);
    }
  }
  int min_sum = INT_MAX;
  rep(i, 100){
    // rep(j, n){
    //   cout << vec[i][j] << endl;
    // }
    int sum1 = accumulate(vec[i].begin(), vec[i].end(), 0);
    // cout << sum1 << endl;
    if (min_sum > sum1){
      min_sum = sum1;
    }
  }
  cout << min_sum << endl;
  return 0;
}


Measured memory_bytes: 888
#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long
using namespace std;
int main()
{
ll n,m;
cin>>n>>m;
ll mx=1;
for(ll i=m-2*(n-1);i>=2;i--)
{
if((i%2==0 && m%2!=0))
{
continue;
}
ll u=m-i*(n-1);
if(u<=0)
{
continue;
}
if(u%i==0)
{
mx=i;
break;
}
}
cout<<mx<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#include <cmath>
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <utility>
#include <map>
#include <unordered_map>
#include <string>

using namespace std;

#define REP(var, n)  for (decltype(n) var = 0; var < (n); var++)
#define RREP(var, n)  for (auto var = n - 1; var != static_cast<decltype(var)>(-1); var--)
#define FOR(var, a, b)  for (auto var = (a); var < (b); var++)
#define RFOR(var, a, b)  for (auto var = b - 1; var != a; var--)
#define all(c) begin(c),end(c)
#define vmax(c) *max_element(all(c))
#define vmin(c) *min_element(all(c))
 
template<typename T>
std::ostream &operator<<(std::ostream &out, const std::vector<T> &v) {
    if (!v.empty()) {
        out << '[';
        std::copy(v.begin(), v.end(), std::ostream_iterator<T>(out, ", "));
        out << "\b\b]";
    }
    return out;
}

template <typename T1, typename T2>
std::ostream &operator<<(std::ostream &out, const std::pair<T1, T2> &p) {
    out << "[" << p.first << ", " << p.second << "]";
    return out;
}

template<typename T1, typename T2>
std::ostream &operator<<(std::ostream &out, const std::map<T1, T2>& map)
{
    for (typename std::map<T1, T2>::const_iterator it = map.begin();
         it != map.end();
         ++it)
    {
        out << (*it);
    }
    return out;
}

typedef long long int ll;
typedef vector<int> vi;
typedef vector<ll> vll;

const long long INF = 0x3f3f3f3f3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9; 

// 2次元配列を作る
// vector<vi> my_vector(n, vi(m, 0));

// 多次元配列の dump
// for (auto v : my_vector) {
//     cout << v;
// }

ll N;

auto solve() {
    ll N, K;
    cin >> N >> K; 
    // cout << N;
    // cout << K;
    return N - (K - 1);
}

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

Measured memory_bytes: 256
S = str(input())
n = len(S)
ans1 = 0
ans2 = 0
for i in range(n):
    if i % 2 == 0:
        tmp1 = '1'
    else:
        tmp1 = '0'
    if S[i] != tmp1:
        ans1 += 1
    else:
        ans2 += 1
print(min(ans1, ans2))


Measured memory_bytes: 3188
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<vector>
#include<functional>
#include<iomanip>
#include<cmath>
#include<queue>
#include<limits>
#include<cassert>
#include<set>
#include<tuple>
#include<map>

#define PB push_back
#define ALL(a)  (a).begin(),(a).end()
#define DWN(a)  (a).begin(),(a).end(), greater<int>()
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

using namespace std;
typedef long long ll;

int main()
{
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	int min1, min2;
	if (a < b) min1 = a;
	else min1 = b;
	if (c < d) min2 = c;
	else min2 = d;
	cout << min1 + min2 << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
	int Height, Width;
	int i, j;
	do{
		scanf("%d%d",&Height,&Width);
		if(Height==0&&Width==0)break;
		for(i=0;i<Height;i++){
			for(j=0;j<Width;j++){
				putchar('#');
			}
			putchar('\n');
		}
		putchar('\n');
	}while(1);
}

Measured memory_bytes: 1816
#include <stdio.h>


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

    int data[num];
    for (int i=0; i<num; i++) {
        scanf("%d", &data[i]);
    }

    int sub = 0;
    int result = 0;
    for (int i=0; i<num-1; i++) {
        for (int j=0; j<num; j++) {
            result = (data[i] > data[j]) ? data[i]-data[j] : data[j]-data[i];
            if (sub < result) sub = result;
        }
    }

    printf("%d\n", sub);

    return 0;
}


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

int main(){
    int n; cin>>n;
    vector<int> p(n),q(n);
    for(int i=0;i<n;i++) cin>>p[i];
    for(int i=0;i<n;i++) cin>>q[i];

    vector<int> v;
    for(int i=0;i<n;i++) v.push_back(i+1);

    int cnt=0,a=0,b=0;
    do{
        bool flaga=true,flagb=true;
        cnt++;
        for(int i=0;i<n;i++){
            if(p[i]!=v[i]) flaga=false;
            if(q[i]!=v[i]) flagb=false;
        }
        if(flaga) a=cnt;
        if(flagb) b=cnt;
    }while(next_permutation(v.begin(),v.end()));
    cout<<abs(a-b)<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int main()
{
    int n,a[15],i,j,l,sum=0,k;
    scanf("%d",&n);
    k=n;
    i=0;
    while (n>=10){
        a[i]=n%10;
        n=n/10;
        i++;
    }
    a[i]=n;
    l=i;
    for(j=0;j<=l;j++){
        sum+=a[j];
    }
    if(k%sum==0){
        printf("Yes\n");
    }
    else printf("No\n");

    return 0;
}


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

int main() {
	int ans = 0,s,e,n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> s >> e;
		ans += e - s + 1;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define MAX_N 200005
using namespace std;
typedef long long ll;
const int DAT_SIZE=(1<<19)-1;

ll data[DAT_SIZE],datb[DAT_SIZE];

void add(int a,int b,int x,int k=0,int l=0,int r=(1<<18)){
  if(a<=l&&r<=b)data[k]+=x;
  else if(l<b&&a<r){
    datb[k]+=(min(b,r)-max(a,l))*x;
    add(a,b,x,k*2+1,l,(l+r)/2);
    add(a,b,x,k*2+2,(l+r)/2,r);
  }
}

ll sum(int a,int b,int k=0,int l=0,int r=(1<<18)){
  if(b<=l||r<=a)return 0;
  else if(a<=l&&r<=b)return data[k]*(r-l)+datb[k];
  else{
    ll res=(min(b,r)-max(a,l))*data[k];
    res+=sum(a,b,k*2+1,l,(l+r)/2);
    res+=sum(a,b,k*2+2,(l+r)/2,r);
    return res;
  }
}

ll Get(int x){
  return sum(x,x+1);
}


int n,q,A[MAX_N];
ll s,t;
ll B[MAX_N],ans=0;


ll f(ll x){
  if(x<0)return x*s;
  return x*t;
}

int main(){  
  cin>>n>>q>>s>>t;
  for(int i=0;i<=n;i++){
    cin>>A[i];
    add(i,i+1,A[i]);
  }
  for(int i=0;i<n;i++){
    ll cal=A[i]-A[i+1];
    B[i]=f(cal);
    ans+=B[i];
  }

  
  /*  for(int j=0;j<n;j++){
    cout<<B[j]<<' ';
  }
  cout<<endl<<endl;*/

  
  int l,r,x;
  for(int i=0;i<q;i++){
    cin>>l>>r>>x;
    r++;
    ans-=B[l-1];
    ans-=B[r-1];
    add(l,r,x);

    
    B[l-1]=f(Get(l-1)-Get(l));
    
    B[r-1]=f( Get(r-1) - Get(r) );
    if(r-1==n)B[r-1]=0;
    ans+=B[l-1]+B[r-1];
    
    /*    for(int j=0;j<n;j++){
      cout<<B[j]<<' ';
    }
    cout<<endl<<endl;*/
    cout<<ans<<endl;
  }
  return 0;
}

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

const int N = 300000;
#define debug(a) cout << #a << " = " << a << endl;
#define pii pair<int,int>

// const int N = 300000;

int lazy[N],ans[N];
vector<int>graph[N];

void dfs(int u,int par,int val){
	//cout << "Hello \n";
	val += lazy[u];
	ans[u] = val;
	for(int v: graph[u]){
		if(v == par)continue;
		dfs(v,u,val);
	}
}

int main(int argc, char const *argv[])
{
	int n,a,b,Q;
	scanf("%d %d",&n,&Q);
	for(int i = 1; i < n;i++){
		scanf("%d %d",&a,&b);
		graph[a].push_back(b);
		graph[b].push_back(a);
	}	
	while(Q--){
		scanf("%d%d",&a,&b);
		lazy[a] += b;
	}
	
	dfs(1,0,0);
	
	for(int i = 1; i <= n;i++){printf("%d",ans[i]);if(i != n)printf(" ");}
	printf("\n");


	return 0;
}

Measured memory_bytes: 26752
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,s,n) for(int i=(s); i<(n); i++)
#define all(v) v.begin(),v.end()
#define outve(v) for(auto i : v) cout << i << " ";cout << endl
#define outmat(v) for(auto i : v){for(auto j : i) cout << j << " ";cout << endl;}
#define in(n,v) for(int i=0; i<(n); i++){cin >> v[i];}
#define out(n) cout << (n) << endl
#define fi first
#define se second
#define pb push_back
#define mod 1000000007
#define infi 1900000000
#define infl 1100000000000000000
#define cyes cout << "Yes" << endl
#define cno cout << "No" << endl
#define csp << " " <<
#define outset(n) cout << fixed << setprecision(n);
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vs = vector<string>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vvp = vector<vector<pair<int,int>>>;
template<typename T> using ve = vector<T>;
template<typename T> using pq2 = priority_queue<T>;
template<typename T> using pq1 = priority_queue<T,vector<T>,greater<T>>;
template<typename T> bool chmax(T &a, T b) {if(a < b) {a = b;return 1;}return 0;}
template<typename T> bool chmin(T &a, T b) {if(a > b) {a = b;return 1;}return 0;}

int N;
double dp[320][320][320];


double rec(int i, int j, int k){
    
    if(dp[i][j][k] >= 0) return dp[i][j][k];
    if(i == 0 && j == 0 && k == 0) return 0.0;
    double res = 0.0;
    if(i > 0) res += rec(i-1,j,k)*i;
    if(j > 0) res += rec(i+1,j-1,k)*j;
    if(k > 0) res += rec(i,j+1,k-1)*k;
    
    res += N;
    res *= (1.0/(double)(i+j+k));
    
    return dp[i][j][k] = res;
    
}


int main(){

    cin >> N;
    int a = 0,b = 0, c = 0;
    rep(i,N){
        int n;
        cin >> n;
        if(n == 1) a++;
        else if(n == 2) b++;
        else c++;
    }
    
    memset(dp,-1,sizeof(dp));
    
    
    outset(10);
    cout << rec(a,b,c) << endl;
    

    return 0;
}


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

int main(){
    string n;
    cin>>n;
    deque<int> s;
    for( int i =0; i<n.size(); i++){
        if(n[i]=='1'){
            s.push_back(1);
        }
        else if(n[i]=='0'){
            s.push_back(0);
        }
        else{
            if(!s.empty())
            s.pop_back();
        }
    }
    int size = s.size();
    for( int i =1; i<=size; i++){
        cout<<s.front();
        s.pop_front();
    }

    return 0;
}

Measured memory_bytes: 256
package main

import (
	. "fmt"
	"math"
	"sort"
)

// github.com/EndlessCheng/codeforces-go
func run(io func(int) bool) (ans int) {
	allNine := true
	for i := 0; ; i++ {
		d := sort.Search(9, func(d int) bool { return (i > 0 || d > 0) && io((ans+d+1)*int(math.Pow10(11-i))-1) })
		if d < 9 {
			allNine = false
		}
		ans += d
		if ok := io(ans + 1); allNine && !ok || !allNine && ok {
			return
		}
		ans *= 10
	}
}

func main() {
	Println("!", run(func(q int) bool {
		Println("?", q)
		var s []byte
		Scan(&s)
		return s[0] == 'Y'
	}))
}


Measured memory_bytes: 852
#include <bits/stdc++.h>
#include <numeric>
#define rep(i, n) for(int i=0; i < n; i++)
#define reps(i, n) for(int i=1; i <= n; i++)
#define ALL(v) v.begin(), v.end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)

using namespace std;
using ll=long long;

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

const ll INF=1LL << 60;
int dp[100005][3];
int a[100005][3];

int main() {
  int n;cin >> n;
  rep(i,n)rep(j,3)cin >> a[i][j];

  rep(i,n){
    rep(j,3){
      rep(k,3){
        if(j==k)continue;
        chmax(dp[i+1][k],dp[i][j]+a[i][k]);
      }
    }
  }
  int ans=max(max(dp[n][0],dp[n][1]),dp[n][2]);
  cout <<ans<< endl;
}

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

using namespace std;
typedef long long ll;

int n;
ll k;
const int maxn = 50+5;
const ll maxk = 1e18;
const ll MOD = 1e9+7;
ll a[maxn][maxn];

class Matrix //square matrix
{
public:
  int n;
  ll a[maxn][maxn];

  Matrix(int n)
  {
    this->n = n; //use global ok?
    memset(a, 0ll, sizeof(a));
  }
  Matrix operator * (Matrix const& rhs) //n*n
  {
    Matrix res(n);
    for(int i = 0; i < n; i++)
    for(int j = 0; j < n; j++)
    {
      res.a[i][j] = 0ll;
      for(int k = 0; k < n; k++)
        res.a[i][j] += a[i][k]*rhs.a[k][j], res.a[i][j] %= MOD;
    }
    return res;
  }
  friend ostream& operator<<(ostream&, const Matrix&);
};

ostream& operator<<(ostream& out, const Matrix& A) {
  int n = A.n;
  for(int i = 0; i < n; i++, cout << endl)for(int j = 0; j < n; j++)
    cout << A.a[i][j] << ' ';
  return out;
}

Matrix fastpow(Matrix A, ll k)
{
  Matrix ret(n);
  for(int i = 0; i < n; i++) ret.a[i][i] = 1ll;
  //cout << ret;
  for(;k;k>>=1)
  {
    if(k&1ll) ret = ret*A;
    A = A*A;
  }
  //cout << ret;
  return ret;
}

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0);
  cin >> n >> k;
  Matrix A(n);
  for(int i = 0; i < n; i++)for(int j = 0; j < n; j++) cin >> A.a[i][j];
  //cout << A;
  Matrix ret(n);
  ret = fastpow(A, k);
  ll sum = 0ll;
  for(int i = 0; i < n; i++)for(int j = 0; j < n; j++)
    sum = (sum + ret.a[i][j])%MOD;
  cout << sum << endl;

  return 0;
}


Measured memory_bytes: 384
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner scanner = new Scanner(System.in);
		String a = scanner.next();
		String b = scanner.next();
		System.out.println((a.equals("H") && b.equals("H")) || (a.equals("D") && b.equals("D")) ? "H":"D");
	}
}

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

struct Tree{
	vector<int> edge;
	int n = 0;
	int c = 0;
};

int main(void){
	int n;
	cin >> n;
	Tree t[n+1];
	for(int i = 0; i < n-1; ++i){
		int a, b;
		cin >> a >> b;
		t[a].edge.push_back(b); t[a].n++;
		t[b].edge.push_back(a); t[b].n++;
	}
	queue<int> q;
	vector<int> c(n);
	for(int i = 0; i < n; ++i){
		cin >> c[i];
	}
	sort(c.rbegin(), c.rend());
	int now = 1;
	int ans = 0;
	while(true){
		if(t[now++].n==1){
			q.push(now-1);
			break;
		}
	}
	now = 0;
	while(!q.empty()){
		int i = q.front();
		q.pop();
		if(t[i].c==0){
			t[i].c = c[now++];
		}
		for(auto x : t[i].edge){
			if(t[x].c==0){
				t[x].c = c[now++];
				ans += min(t[i].c, t[x].c);
				q.push(x);
			}
		}
		//cout << endl;
	}
	cout << ans << endl;
	for(int i = 1; i <= n; ++i){
		cout << t[i].c << " ";
	}
	cout << endl;
	//cout << "now = " << now << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <cstring>
#include<cstdio>
using namespace std;

int ans = -1000000000;
int a[10];
int n, f[100][10], p[100][11];
//int max(int ans, int score)
//{
//	if (ans > score)
//		return ans;
//	else
//		return score;
//}
void func(void){
	int score = 0, cnt;
	for (int i = 0; i < n; i++){
		cnt = 0;
		for (int j = 0; j < 10; j++){
			if (a[j] == 1 && f[i][j] == 1)
				cnt++;
		}
			score += p[i][cnt];
	}
	ans = max(ans, score);
}
void dfs(int pos)
{
	int flag = 0;
	if (pos == 10){
		for (int i = 0; i < 10; i++){
			if (a[i] == 1)
				flag = 1;
		}
		if (flag)
		func();
		return;
	}
		a[pos] = 0; dfs(pos + 1);
		a[pos] = 1; dfs(pos + 1);

}

int main()
{
	cin >> n;

	for (int i = 0; i < n; i++){
		for (int j = 0; j < 10; j++)
			scanf("%d", &f[i][j]);
	}

	for (int i = 0; i < n; i++)
		for (int j = 0; j < 11;j++)
		scanf("%d", &p[i][j]);

	dfs(0);
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>

using namespace std;

typedef long long ll;

#define  kak 1000000000000;



int main(){
    ll N;
    cin >> N;
    ll oldx = 0;
    ll oldy = 0;
    int oldt = 0;
    int dis = 0;
    int t = 0;
    int x,y;
    for (int i = 0; i < N; ++i) {
        cin >> t;
        cin >> x;
        cin >> y;
        dis = abs(x-oldx) + abs(y-oldy);
        int k = (t-oldt) - dis;
        if(t-oldt >= dis){
            if(k % 2 == 0) {
                oldx = x;
                oldy = y;
                oldt = t;
                continue;
            }
            else {
                cout << "No";
                return 0;
            }
    }else {
            cout << "No";
            return 0;
        }

    }


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




Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<cstdlib>

int main()
{
    int N;
  	int	num=0;
    int i=0;
    double x,y=0;
    double Distance,D=0;

    std::cin >> N >> D;
    double X[N],Y[N]={0};

    for(i=0; i<N; i++)
    {
        std::cin >> X[i] >> Y[i];
        x=X[i]*X[i];
        y=Y[i]*Y[i];
        Distance = std::sqrt(x+y);
        if( Distance <= D)
        {
            num++;
        }
    }
  
    std::cout << num;

    return 0;
}

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

const int MAXN = 200005;
int A[MAXN];
ll left_here[MAXN];
ll here_left_here[MAXN];
ll here_right[MAXN];
ll here_right_here[MAXN];
ll sum[MAXN];

int main() {
	// freopen("./input.txt", "r", stdin);
    int L;
    cin >> L;
    sum[0] = 0;
    for (int i = 1; i <= L; ++i) {
        cin >> A[i];
        sum[i] = sum[i - 1] + A[i];
    }
    left_here[0] = here_left_here[0] = 0;
    for (int i = 1; i <= L; ++i) {
        int here_left_here_cost = 0;
        int left_here_cost = 0;
        if (A[i] == 0) {
            left_here_cost = 1;
            here_left_here_cost = 2;
        } else if (A[i] % 2 == 0) {
            left_here_cost = 1;
        } else {
            here_left_here_cost = 1;
        }
        here_left_here[i] = min(here_left_here[i - 1] + here_left_here_cost, sum[i]);
        left_here[i] = min(left_here_cost + left_here[i - 1], here_left_here[i]);
    }
    here_right[L] = here_right_here[L] = 0;
    for (int i = L - 1; i >= 0; --i) {
        int here_right_cost = 0;
        int here_right_here_cost = 0;
        if (A[i + 1] == 0) {
            here_right_cost = 1;
            here_right_here_cost = 2;
        } else if (A[i + 1] % 2 == 0) {
            here_right_cost = 1;
        } else {
            here_right_here_cost = 1;
        }
        here_right_here[i] = min(here_right_here[i + 1] + here_right_here_cost, sum[L] - sum[i]);
        here_right[i] = min(here_right_cost + here_right[i + 1], here_right_here[i]);
    }
    ll ans = LLONG_MAX;
    for (int i = 0; i <= L; ++i) {
        ans = min(ans, min(left_here[i], here_left_here[i]) + min(here_right[i], here_right_here[i]));
    }
    cout << ans << endl;
 	return 0;
}

Measured memory_bytes: 8832
# coding: utf-8
# Your code here!

def main():
    number_of_human,number_of_sweets = map(int,input().split())
    
    human_own_information_list = []
    
    for sweets_number in range(number_of_sweets):
        number_of_own_human = int(input())
        own_human_list = list(map(int,input().split()))
        for own_human in own_human_list:
            if not own_human in human_own_information_list:
                human_own_information_list.append(own_human)
    
    result = 0
    for human_number in range(1,number_of_human+1):
        if not human_number in human_own_information_list:
            result += 1
    
    print(result)


if __name__ == "__main__":
    main()
    


Measured memory_bytes: 9132
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using vpii = vector<pair<int, int>>;
using vpll = vector<pair<ll, ll>>;
// ceil() 切り上げ, floor() 切り捨て
// next_permutation(all(x))

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

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

	int ans = 0;
	for(int i = 1; i < 100000-1;i++)
	{
		int l = S[i-1];
		int r = S[i+1];
		ans = max(ans, l+S[i]+r);
	}
	cout << ans << endl;
}



Measured memory_bytes: 640
h,w=map(int,input().split())
mapdata=[]
re=0
for i in range(h):
  line=str(input())
  line2=list(line)
  mapdata.append(line2)
def jugde(i,j):
  count=0
  for x in (i-1,i+1):
    if 0<=x<=h-1:
      if mapdata[x][j]=='#':
        count+=1
  for y in (j-1,j+1):
    if 0<=y<=w-1:
      if mapdata[i][y]=='#':
        count+=1
  if count!=0:
    return True
for i in range(h):
  for j in range(w):
    if mapdata[i][j]=='#':
      if jugde(i,j)==True:
        pass
      else:
        re+=1
if re==0:
  print('Yes')
if re!=0:
  print('No')

Measured memory_bytes: 3064
#import numpy as np
#import math
#from decimal import *
#from numba import njit

#@njit
def main():
    A,B,C = map(int, input().split())
    K=int(input())

    while K > 0:
        if B <= A:
            B = B*2
        elif C <= B:
            C = C*2
        K -= 1

    if A < B and B < C:
        print('Yes')
    else:
        print('No')
main()


Measured memory_bytes: 9168
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <math.h>
#include <cmath>
#include <limits.h>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <functional>
#include <stdio.h>
using namespace std;

long long MOD = 1000000007;

int main() {
    
    double z = -1;
    long long x = 0;
    long long y = 0;
    
    long long A,B,C,D,E,F;
    cin >> A >> B >> C >> D >> E >> F;
    
    long long w;
    for ( long long a = 0; a <= 30; a++ ) {
    for ( long long b = 0; b <= 30; b++ ) {
        
        if ( !a && !b ) { continue; }
        
        w = 100*A*a + 100*B*b;
        
        if ( F < w ) { continue; }
        
        long long s = min( (A*a + B*b)*E, F-w );
        
        long long m = 0;
        for ( long long c = 0; c <= 1500; c++ ) {
        for ( long long d = 0; d <= 1500; d++ ) {
            if ( c*C+d*D > s ) { continue; }
            m = max( m, (c*C+d*D) );
        }
        }
        
        s = m;
        
        double zs = (100*static_cast<double>(s))/(static_cast<double>(s)+static_cast<double>(w));
        
        if ( z < zs ) {
            x = w+s;
            y = s;
            z = zs;
        }
    }
    }
    
    if ( !x ) {
        cout << A*100 << " " << 0 << endl;
    }
    else {
        cout << x << " " << y << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] x = new int[n];
        int[] y = new int[n];

        List<Pair> pairs = new ArrayList<Pair>();
        for (int i = 0; i < n; i++) {
            x[i] = sc.nextInt();
            y[i] = sc.nextInt();
            pairs.add(new Pair(x[i], y[i]));
        }
        // 入力
        Collections.sort(pairs);
        sc.close();
        int ans = 0;
        for (int i = 0; i < n; i++) {
            for (int j = i + 1; j < n; j++) {
                if (i == j) {
                    continue;
                }
                int difx = pairs.get(i).x - pairs.get(j).x;
                int dify = pairs.get(i).y - pairs.get(j).y;
                int tmp = 0;
                for (int k = 0; k < n; k++) {
                    for (int h = k + 1; h < n; h++) {
                        int sax = pairs.get(k).x - pairs.get(h).x;
                        int say = pairs.get(k).y - pairs.get(h).y;
                        if (difx == sax && dify == say) {
                            tmp++;
                        }
                    }

                }
                if (tmp > ans) {
                    ans = tmp;
                }
            }

        }
        ans = n - ans;
        if (n == 1) {
            ans = 1;
        }
        System.out.println(ans);
        sc.close();
    }
}

class Pair implements Comparable<Pair> {
    // x , y 昇順ソート
    int x;
    int y;

    Pair(int x, int y) {
        this.x = x;
        this.y = y;
    }

    @Override
    public int compareTo(Pair other) {
        if (this.x == other.x) {
            return this.y - other.y;
        }
        return this.x - other.x;
    }
}


Measured memory_bytes: 24532
def slove():
    import sys
    input = sys.stdin.readline
    n, t = list(map(int, input().rstrip('\n').split()))
    mt = 10 ** 9
    for i in range(n):
        c1, c2 = list(map(int, input().rstrip('\n').split()))
        if c2 <=t:
            mt = min(mt, c1)
    if mt == 10 ** 9:
        print("TLE")
    else:
        print(mt)


if __name__ == '__main__':
    slove()


Measured memory_bytes: 38384
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define MAX 99
int top=0,S[1000000];
int pop();
void push(int);
int main()
{
  int x=0,a,b;
  char s[100];
  while(scanf("%s",s)!=EOF)
    {
      if(s[0] == '+')
	{
	  a=pop();
	  b=pop();
	  push(a+b);
	}
      else if(s[0] == '-')
	{
	  a=pop();
	  b=pop();
	  push(b-a);
	 	}
      else if(s[0] == '*')
	{
	  a=pop();
	  b=pop();
	  push(a*b);
	 	}
      else
	{
	  push(x=atoi(s));
	}
    }
  printf("%d\n",pop());
  return 0;
}
void push(int x)
{
       top++;
      S[top]=x;
 }
int pop()
{
       top--;
   return S[top+1];
}



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

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)
#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using ll = long long;
using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using ld = long double;
using str = string;

#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

long int M = 1e+9+7;
int inf = 1e+9;

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

    int n,m,c;
    cin >> n >> m >> c;
    vi b(m);
    vvi a(n,vi(m));
    rep(i,m){
        cin >> b[i];
    }
    rep(i,n){
        rep(j,m){
            cin >> a[i][j];
        }
    }
    int ans=0;
    rep(i,n){
        int sum=0;
        rep(j,m){
            sum+=(a[i][j]*b[j]);
        }
        sum+=c;
        if (sum > 0) ans++;
        
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
  int n;
  int b,f,r,v;
  //a[棟][階][部屋]
  int a[4][3][10] = {};
  cin >> n;
  for(int i = 0; i < n; i++){
    cin >> b >> f >> r >> v;
    a[b-1][f-1][r-1] += v;
  }
  for(int i = 0; i < 4; i++){
    for(int j = 0; j < 3;j++){
      for (int k = 0;k < 10;k++){
        cout <<" "<< a[i][j][k];

      }
      cout << endl;
    }
    if(i != 3){
      cout << "####################" << endl;
    }
  }
  return 0;
}



Measured memory_bytes: 3080
#include "bits/stdc++.h"
#pragma GCC optimize("Ofast")


using namespace std;
using ll = long long;

int main(){
    string s;
    cin >> s;
    int a;
    if(s == "SAT"){
        a = 1;
    }
    if(s == "SUN"){
        a = 7;
    }
    if(s == "MON"){
        a = 6;
    }
    if(s == "TUE"){
        a = 5;
    }
    if(s == "WED"){
        a = 4;
    }
    if(s == "THU"){
        a = 3;
    }
    if(s == "FRI"){
        a = 2;
    }
    cout<<a<<endl;
}


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

int main() {
  int n,k;
  cin >> n>>k;
  vector<string>a(n);
  rep(i,n){
    cin>>a.at(i);
  }
  sort(a.begin(),a.end());
  rep(i,n){
   cout<<a.at(i);
  }
}

Measured memory_bytes: 256
import sys
from heapq import heappush, heappop
def input(): return sys.stdin.readline().strip()


def main():
    N, A, B = map(int, input().split())
    X = list(map(int, input().split()))
    ans = 0
    now = X[0]
    for i in range(1, N):
        ans += min(B, A * (X[i] - now))
        now = X[i]
    print(ans)




if __name__ == "__main__":
    main()


Measured memory_bytes: 84748