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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
typedef pair<int,int> pii;
typedef pair<long long, int> pli;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

ll mod = 998244353;

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

  int n,m,x;
  cin >> n >> m >> x;
  vi c(n);
  vvi a(n,vi(m));

  rep(i,n){
    cin >> c[i];
    rep(j,m){
      cin >> a[i][j];
    }
  }

  int ret = INT_MAX;
  bool found = false;

  rep(i, 1 << n){
    int cond = i;
    int cost = 0;
    vi skill(m);
    rep(j, n){
      if(cond & 1){
        cost += c[j];
        rep(k,m){
          skill[k] += a[j][k];
        }
      }
      cond /= 2;
    }

    bool check = true;
    rep(j,m){
      if(skill[j] < x){
        check = false;
      }
    }
    if(check){
      ret = min(ret,cost);
      found = true;
    }
  }

  if(found)cout << ret << endl;
  else cout << -1 << endl;
}

Measured memory_bytes: 3664
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define MOD 1000000007
#define pii pair<int,int>
#define LL long long

using namespace std;

int main () {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int r,c;
    cin >> r >> c;
    int cost[10][10];
    for (int i=0;i<=9;i++) {
      for (int j=0;j<=9;j++) {
        cin >> cost[i][j];
      }
    }
    int cnt[10];
    memset (cnt,0,sizeof(cnt));
    for (int i=1;i<=r;i++) {
      for (int j=1;j<=c;j++) {
        int x;
        cin >> x;
        if (x!=-1) cnt[x]++;
      }
    }
    vector<pii> adj[10];
    for (int i=0;i<=9;i++) {
      for (int j=0;j<=9;j++) {
        adj[i].pb(mp(cost[i][j],j));
      }
    }
    int v[10];
    for (int i=0;i<=9;i++) {
      int vis[10];
      for (int j=0;j<=9;j++) {
        vis[j]=INT_MAX;
      }
      //cout << "_________" << endl;
      priority_queue<pii,vector<pii>,greater<pii> > pq;
      vis[i]=0;
      pq.push(mp(0,i));
      while(!pq.empty()) {
        pii cur=pq.top();
        //cout << cur.fi << " " << cur.se << endl;
        pq.pop();
        for (int j=0;j<adj[cur.se].size();j++) {
          pii next=adj[cur.se][j];
          //cout << next.fi << " " << next.se << endl;
          if (vis[cur.se]+next.fi<vis[next.se]) {
            //cout << "YAY";
            vis[next.se]=vis[cur.se]+next.fi;
            pq.push(next);
          }
        }
      }
      v[i]=vis[1];
    }
    int ans=0;
    for (int i=0;i<=9;i++) ans+=cnt[i]*v[i];
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
  int A,B;
  int x = 0;
  scanf("%d %d",&A,&B);
  while (x < 1000000000)
  {
  	if ((((float)x*0.08 >= A) && ((float)x*0.08 < A + 1)) && (((float)x*0.1 >= B) && ((float)x*0.1 < B + 1)))
  	{
    	printf("%d",x);
      	return (0);
  	}
    x++;
  }
  printf("%d",-1);
}

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

void ReplaceAll(string& s, string from, string to){
  string::size_type p = 0;
  while(p=s.find(from,p), p!=string::npos){
    s.replace(p, from.length(), to);
    p += to.length();
  }
}

int main(void){
  int n;
  string x;
  char tmp[1024];

  cin>>n;
  cin.get();
  while(n--){
    cin.getline(tmp,1024);
    x = tmp;
    ReplaceAll(x,"Hoshino","Hoshina");
    cout<<x<<endl;
  }

  return 0;
}

Measured memory_bytes: 0
import math
def sieve(n):
    if n < 2:
        is_prime = [False for _ in range(n+1)]
        return is_prime
 
    is_prime = [True for _ in range(n+1)]
    is_prime[0] = False
    is_prime[1] = False
 
    for i in range(2, int(n**0.5)+1):
        if is_prime[i]:
            for j in range(i*2, n+1, i):
                is_prime[j] = False
 
    return is_prime

N=10**5
prime=sieve(N)
a=[0]*(N)
for i in range(2,N):
	if prime[i] and prime[(i+1)//2]: a[i]=a[i-1]+1
	else: a[i]=a[i-1]

for i in range(int(input())):
	l,r=map(int,input().split())
	print(a[r]-a[l-1])

Measured memory_bytes: 5144
#ifdef _MSC_VER
#define _CRT_SECURE_NO_WARNINGS
#endif

#include <bits/stdc++.h>

using namespace std;

#define POW2(X) (1<<(X))
#define CKBIT(S,X) (((S)&POW2(X))!=0)

template<class T> inline void nlmin(T &a,T b){ a=min(a,b); }
template<class T> inline void nlmax(T &a,T b){ a=max(a,b); }
template<class T> inline T sqr(T x){ return x*x; }
#define SIZE(A) ((int)A.size())
#define LENGTH(A) ((int)A.length())

#define PB(X) push_back(X)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(A) A.begin(),A.end()
template<class T> int CMP(T a[],const T b[],int n) { return memcmp(a,b,n*sizeof(T)); }
template<class T> void COPY(T a[],const T b[],int n) { memcpy(a,b,n*sizeof(T)); }
template<class T> void SET(T a[],int val,int n) { memset(a,val,n*sizeof(T)); }
using uint=unsigned int;
using int64=long long;
using uint64=unsigned long long;
using pii=pair<int,int>;
using VI=vector<int>;
using VII=vector<VI>;
using VD=vector<double>;
constexpr int kmod = 1000000007;


int main() {
    int N;
    cin >> N;
    VI v(N + 1);
    VI dp(N + 1);
    FOR (i, 1, N + 1) {
            cin >> v[i];
    }

    dp[1] = 0;
    dp[2] = abs(v[2] - v[1]);
    FOR (i, 3, N + 1) {
            dp[i] = min(dp[i-1] + abs(v[i] - v[i-1]), dp[i-2] + abs(v[i] - v[i-2]));
    }
    cout << dp[N] << endl;
    return 0;
}

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

#define ff first
#define ss second
#define pb push_back
#define sz size()
#define mp make_pair
#ifndef ONLINE_JUDGE 
#include "/home/asif/Codes/Library/debug.h"
#endif
/*--------------------------------------------------------------------*/

const int N = 1e5 + 5;
const int MOD = 1e9 + 7;

int main() {

  ll a, b;
  cin >> a >> b; cout << a * b << endl;

  return 0;
}

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


int main() {
  int a,b,m;cin>>a>>b>>m;
  int p[a];int q[b];
  int pmin=1000000;int qmin=1000000;
  for (int i=0; i<a;i++){cin>>p[i];if(pmin>p[i]){pmin=p[i];}}
  for (int i=0; i<b;i++){cin>>q[i];if(qmin>q[i]){qmin=q[i];}}
  int tmp=pmin+qmin;
  int x,y,c;
  for(int i=0;i<m;i++){
    cin>>x>>y>>c;
    if(p[x-1]+q[y-1]-c<tmp){tmp=p[x-1]+q[y-1]-c;}
  }
int ans = tmp;
cout<<ans<<endl;

}


Measured memory_bytes: 1024
#include <iostream>
using namespace std;
int main(void){
    int a,b;
    char op;
    while(true){
    cin>>a>>op>>b;
    if(op=='+'){
        cout<<(a+b)<<endl;
    }
    if(op=='-'){
        cout<<(a-b)<<endl;
    }
    if(op=='*'){
        cout<<(a*b)<<endl;
    }
    if(op=='/'){
        cout<<(a/b)<<endl;
    }
            if(op=='?'){
        break;
    }
}
    
}


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

const ll MOD = 1000000007;
const ll MAX = 100100;
const double PI = 3.1415926;

#define vll vector<ll>
#define max_heap priority_queue<int>
#define min_heap priority_queue<int , vector<int>, greater<int> >
#define pb push_back
#define all(container) container.begin(), container.end()
#define pll pair<ll,ll>
// #define traverse( container, it) for( typeof(container.begin()) it = container.begin(); it!=container.end(); it++)
int n;
ll arr[410];
ll prefix[410];
ll dp[410][410];

ll fill(ll i, ll j)
{
	if (i + 1 == j)
		return 0;
	if (dp[i][j] != -1)
		return dp[i][j];

	ll c = 1e18;
	for(int h = i + 1; h < j; h++)
		c = min(c, fill(i,h) + fill(h,j) + prefix[j] - prefix[i] );
	dp[i][j] = c;
	return c;
}

int main()
{
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	memset(dp,-1,sizeof(dp));
	cin >> n;
	for(int i = 0; i < n; i++)
		cin >> arr[i];
	prefix[0] = 0;
	prefix[1] = arr[0];
	for(int i = 1; i < n; i++)
		prefix[i+1] = prefix[i] + arr[i];
	cout << fill(0,n) << endl;
	return 0;
}


Measured memory_bytes: 1664
#include <iostream>
#include <map>
#include <string>
#include <algorithm>
#include <queue>
using namespace std;

int dx[] = {1, -1, 4, -4};
map<string, int> cache;

void make_cache() {
    queue<string> q; q.push("01234567");
    cache["01234567"] = 0;
    while (!q.empty()) {
        string s = q.front(); q.pop();
        int zero_p = s.find('0');
        for (int i = 0; i < 4; i++) {
            if (zero_p  < 4 && i == 3) continue;
            if (zero_p >= 4 && i == 2) continue;
            if (zero_p % 4 == 0 && i == 1) continue;
            if (zero_p % 4 == 3 && i == 0) continue;
            string t = s;
            swap(t[zero_p], t[zero_p+dx[i]]);
            if (cache[t] != 0 || t == "01234567") continue;
            q.push(t);
            cache[t] = cache[s] + 1;
        }
    }
}

int main() {
    make_cache();
    string str;
    while (getline(cin, str)) {
        str.erase(remove(str.begin(), str.end(), ' '), str.end());
        cout << cache[str] << endl;
    }
   return 0;
}

Measured memory_bytes: 2192
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
      Scanner scn = new Scanner(System.in);
      boolean a[]=new boolean[scn.nextInt()+1];
      int k=scn.nextInt();
      int ans=-1;
      for(int i=0;i<k;i++){
          for(int j=scn.nextInt();j>0;j--){
              a[scn.nextInt()]=true;
          }
      }
      for (int i=0;i<a.length;i++){
          if(!a[i]) ans++;
      }
      System.out.println(ans);
    }
}


Measured memory_bytes: 46112
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define M 100001

ll n, a[M], b[M], c[M], d[M], f[M], ans = 0;

int main(){
    cin >> n;
    for (int i = 0; i < n; i++) cin >> a[i];
    for (int i = 0; i < n; i++) cin >> b[i];
    for (int i = 0; i < n; i++) cin >> c[i];
    sort(a, a+n);
    sort(b, b+n);
    sort(c, c+n);
    for (int i = 0; i < n; i++){
        ll x = upper_bound(c, c+n, b[i]) - c;
        d[i] = n - x;
    }
    f[0] = d[0];
    for (int i = 1; i < n; i++) f[i] = d[i] + f[i-1];
    for (int i = 0; i < n; i++){
        ll x = upper_bound(b, b+n, a[i]) - b;
        ans += f[n-1] - f[x-1];
    }
    cout << ans;
}

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

int ctoi(const char c){
  switch(c){
    case '0': return 0;
    case '1': return 1;
    case '2': return 2;
    case '3': return 3;
    case '4': return 4;
    case '5': return 5;
    case '6': return 6;
    case '7': return 7;
    case '8': return 8;
    case '9': return 9;
    default : return -1;
  }
}

bool ok = false;

void seven_equal(int value, string ABCD, string plus_minus, int digit){

  if(digit == ABCD.size()){
    if(value == 7 && ok == false){
      cout << plus_minus << "=7" << endl;
      ok = true;
    }
    return;
  }
  
  int minus_value = value;
  string minus = plus_minus;
  
  plus_minus = plus_minus + '+' + ABCD.at(digit);
  seven_equal(value += ctoi(ABCD.at(digit)), ABCD, plus_minus, digit+1);
  
  minus = minus + '-' + ABCD.at(digit);
  seven_equal(minus_value -= ctoi(ABCD.at(digit)), ABCD, minus, digit+1);
  
}


int main(){
  string ABCD;
  cin >> ABCD;
  
  string plus_minus = {ABCD.at(0)};

  seven_equal(ctoi(ABCD.at(0)), ABCD, plus_minus, 1);

}
  

Measured memory_bytes: 256
//Coded by Abhijay Mitra
#include <iostream>
#include <stdlib.h>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <numeric>
#include <vector>
#include <iterator> 
#include <map>
#include <set>
#include <climits>
#include <queue>
#include <cmath>
#include <stack>
#include <cctype>
#include <bitset>
// #include <bits/stdc++.h>
#define double long double
#define int long long int
#define ll int
#define ibs ios_base::sync_with_stdio(false)
#define cti cin.tie(0)
#define bp __builtin_popcount
#define pb emplace_back
#define koto_memory(a) cout<<(sizeof(a)/1048576.0)<<" MB";
#define res(v) sort(all(v)),v.erase(unique(all(v)), v.end());
#define timer cerr << "Time elapsed : " << 1.0 * clock() / CLOCKS_PER_SEC << " sec \n";
#define deb(x) cout<<"\n["<<#x<<" = "<<x<<"]\n";
using vi = std::vector<int>;
using vvi = std::vector<vi>;
using pii = std::pair<int,int>;
using vpii = std::vector<pii>;
using vvpii = std::vector<vpii>;
#define mp         make_pair
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define per(i,b,a) for (int i = b; i >= a; i--)
#define all(x)     x.begin(), x.end()
using namespace std;
const int N=2e6+10;
const int inf = /*0x3f3f3f3f*/1e18+10;
// const ll M = 998244353 ; // Mulo
// const int M = 1e9+7 ; // Mulo
const double Pi = 3.14159265;
#define F first
#define S second
int n,z,cnt;double tmp;
void solve(){
	cin>>n;map<pii,int>m;
	rep(i,1,n){
		cin>>tmp;int c1=0,c2=0;
		z=llround(tmp*1e9);
		while((z%2)==0)z/=2,c1++;
		while((z%5)==0)z/=5,c2++;
		m[mp(c1,c2)]++;
	}
	for(auto i:m)
		for(auto j:m){
			if(i<j){
				if(i.F.F+j.F.F>=18 and i.F.S+j.F.S>=18)cnt+=i.S*j.S;
			}
			if(i==j){
				if(i.F.F+j.F.F>=18 and i.F.S+j.F.S>=18)cnt+=i.S*(j.S-1)/2;
			}
		}
	cout<<cnt;
}
int32_t main()
{
  ibs;cti;
  solve();return 0;
  /*,cout<<"\n"*/;
  // cout<<"\n";
  int xx=0;
  int t;cin>>t;while(t--){/*xx++;cout<<"Case "<<xx<<":\n"*/;solve();cout<<"\n";}
  return 0;
}

Measured memory_bytes: 3760
// IO
#include <cstdio>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm
#include <algorithm>
#include <cmath>
#include <numeric>

// container
#include <vector>
#include <string>
#include <tuple>
#include <set>
#include <map>
#include <unordered_map>
#include <stack>
#include <queue>
#include <deque>

// others
#include <random>
#include <limits>
#include <functional>
#include <ctime>
#include <cassert>

// type alias
using lint = long long;
using ldouble = long double;
template <class T>
using greater_priority_queue = std::priority_queue<T, std::vector<T>, std::greater<T>>;


/* ----- class ----- */

template <class Cost = int>
struct Edge {
    int src, dst;
    Cost cost;
    Edge(int src = -1, int dst = -1, Cost cost = 1)
        : src(src), dst(dst), cost(cost){};

    bool operator<(const Edge<Cost>& e) const { return this->cost < e.cost; }
    bool operator>(const Edge<Cost>& e) const { return this->cost > e.cost; }
};

template <class Cost = int>
using Edges = std::vector<Edge<Cost>>;

template <class Cost = int>
using Graph = std::vector<std::vector<Edge<Cost>>>;


/* ----- debug ----- */

#if __has_include("../setting/source/debug.hpp")
#include "../setting/source/debug.hpp"
#endif


/* ----- short functions ----- */

template <class T>
inline T sq(T a) { return a * a; }

template <class T>
inline T iceil(T n, T d) { return (n + d - 1) / d; }

template <class T>
T gcd(T a, T b) {
    while (b > 0) {
        a %= b;
        std::swap(a, b);
    }
    return a;
}

template <class T, class U>
T ipow(T b, U n) {
    T ret = 1;
    while (n > 0) {
        if (n & 1) ret *= b;
        n >>= 1;
        b *= b;
    }
    return ret;
}

// 0-indexed
template <class T, class U>
inline T kthbit(T a, U k) { return (a >> k) & 1; }

template <class T, class U>
inline T mask(T a, U k) { return a & ((1 << k) - 1); }

template <class T>
std::map<T, int> compress(std::vector<T>& v) {
    std::sort(v.begin(), v.end());
    v.erase(std::unique(v.begin(), v.end()), v.end());

    std::map<T, int> rev;
    for (int i = 0; i < v.size(); ++i) rev[v[i]] = i;
    return rev;
}

template <class T>
T Vec(T v) { return v; }

template <class T, class... Ts>
auto Vec(size_t l, Ts... ts) {
    return std::vector<decltype(Vec<T>(ts...))>(l, Vec<T>(ts...));
}


/* ----- constants ----- */

// const int INF = std::numeric_limits<int>::max() / 3;
// const lint INF = std::numeric_limits<lint>::max() / 3;
// const ldouble PI = acos(-1);
// const ldouble EPS = 1e-10;
// std::mt19937 mt(int(std::time(nullptr)));


using namespace std;

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

    K -= (N - 1) * (N - 2) / 2;
    if (K > 0) {
        cout << -1 << endl;
        return 0;
    }

    vector<pair<int, int>> edges;
    for (int v = 1; v < N; ++v) {
        edges.emplace_back(v, N);
        for (int u = v + 1; u < N; ++u) {
            if (K < 0) {
                edges.emplace_back(u, v);
                ++K;
            }
        }
    }

    cout << edges.size() << endl;
    for (auto e : edges) {
        cout << e.first << " " << e.second << endl;
    }
    return 0;
}


Measured memory_bytes: 384
#include <stdio.h>

int main()
{
	long long W, H, x, y;
	scanf("%lld %lld %lld %lld", &W, &H, &x, &y);
	printf("%f ", W * H / 2.0);
	if (W == x * 2 && H == y * 2) printf("1\n");
	else printf("0\n");
	fflush(stdout);
	return 0;
}

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

using namespace std;

int a, b, c;

int main()
{
    cin>>a>>b>>c;
    bool flag = (a == b && b != c) || (a == c && b != c) || (b == c && a != b);
    if(flag) cout<<"Yes";
    else cout<<"No";
    //system("pause");
    return 0;
}

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

int main(){
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  
  int s = a > c ? a:c;
  int e = b < d ? b:d;
  if(e - s < 0){
    cout << 0 << endl;
  }
  else{
    cout << e-s << endl;
  }
 
}

Measured memory_bytes: 256
/*
    Bismillahir Rahmanir Raheem
    Think Twice Code Once
    author : reaziii
*/
#include<bits/stdc++.h>
#define sc(x)        scanf("%lld",&x)
#define pcase(x)     printf("Case %d: ",x++)
#define pn           printf("\n")
#define fri(f)       for(int i=0;i<f;i++)
#define frj(f)       for(int j=0;j<f;j++)
#define reset(x,e)   memset(x,e,sizeof(x))
#define all(x)       x.begin(),x.end()
#define input        freopen("input.txt","r",stdin);
#define output       freopen("output.txt","w",stdout)
#define infi         INT_MAX
#define m_v          3000000
#define pii          pair<int,int>
#define pch          pair<char,char>
#define pll          pair<ll,ll>
#define mgraph       map<int,vector<int> >
#define mp           make_pair
#define pb           push_back
#define clr(x)       memset(x,0,sizeof(x))
#define frx(x,y)     for(int x=0;x<y;x++)
#define deb(x)       cout<<x
#define ideb(i,x)    cout<<i<<" "<<x
#define F            first
#define S            second
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
bool checkbitt(ll num,int pos);
ll setbitt(ll num,ll pos);
ll resetbitt(ll num,int pos);
 //.................___Start from here___.................//
//.................._____________________................//
int x,y;

int dp[10000][110];
bool sol(int sum=0,int pos=0){
    if(pos==x && sum==y) return 1;
    else if(pos>=x || sum>=y) return 0;
    if(dp[sum][pos]!=-1) return dp[sum][pos];
    return dp[sum][pos] = sol(sum+2,pos+1) | sol(sum+4,pos+1);
}



void solve(){

    cin>>x>>y;
    reset(dp,-1);
    if(sol()) cout<<"Yes";
    else cout<<"No";
    cout<<" ";
}




int main(){
    solve();
}






bool checkbitt(ll num,int pos){
    return (num>>pos) & 1;
}

ll setbitt(ll num,ll pos){
    return (1<<pos) | num;
}

ll resetbitt(ll num,int pos){
    if(!checkbitt(num,pos)) {
        return num;
    }
    else{
        return (1<<pos)^num;
    }
}





Measured memory_bytes: 7816
def solve(w)
  ws = []
  9.downto(0) do |i|
    if w >= 2**i
      ws.unshift(2**i)
      w -= 2**i
    end
  end
  ws.join(" ")
end

gets(nil).chomp.split("\n").each do |s|
  puts solve(s.to_i)
end

Measured memory_bytes: 6100
#include <iostream>
#include <cmath>
using namespace std;
int N;
int keta;
int ans = 0;

void dfs(int sum, int now_Keta, bool seven, bool five, bool three){
    //cout << now_Keta << endl;
    if(now_Keta == 0){
        if(sum <= N && seven && five && three){
            ans++;
            return;
        }
        else return;
    }

    dfs(sum * 10 + 7, now_Keta-1, true, five, three);
    dfs(sum * 10 + 5, now_Keta-1, seven, true, three);
    dfs(sum * 10 + 3, now_Keta-1, seven, five, true);
    return;
    
}

int main(void){
    
    cin >> N;
    keta = log10(N)+1;
    for(int i = 1; i <= keta; i++){
        dfs(0, i, false, false, false);
    }

    cout << ans << endl;
    
}


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

#define ll long long
#define INF 99999999
#define INF_LL 1LL << 60
#define MOD (ll)1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, a, n) for(int i = a; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

void put_double(double obj){printf("%.12f\n",obj);};

template < typename T > std::string to_string( const T& n )
{
    std::ostringstream stm ;
    stm << n ;
    return stm.str() ;
}

int main()
{
    ll a,b;
    cin >> a >> b;
    if( a*b%2 == 0 ) cout << "Even" << endl;
    else cout << "Odd" << endl;
}


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

using namespace std;

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  
  while (a && c) {
    c -= b;
    if (c <= 0) {
      cout << "Yes";
      return 0;
    }
    a -= d;
    if (a <= 0) {
      cout << "No";
      return 0;
    }
  }
  
  return 0;
}

Measured memory_bytes: 3584
#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++)
using ll = long long;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using P = pair<ll, ll>;

// chmin, chmax関数
template<typename T, typename U, typename Comp=less<>>
bool chmax(T& xmax, const U& x, Comp comp={}) {
    if(comp(xmax, x)) {
        xmax = x;
        return true;
    }
    return false;
}
template<typename T, typename U, typename Comp=less<>>
bool chmin(T& xmin, const U& x, Comp comp={}) {
    if(comp(x, xmin)) {
        xmin = x;
        return true;
    }
    return false;
}

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

int main(){
    string s;
    cin >> s;
    int n = s.size();
    bool flag = true;
    int n1 = (n-1)/2, n2 = (n+1)/2;
    rep(i, n1){
        if(s[i] != s[n1-1-i]) flag = false;
        if(s[n2+i] != s[n-1-i]) flag = false;
    }
    rep(i,n){
        if(s[i] != s[n-1-i]) flag = false;
    }
    if(flag) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

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

int main(void) {
	int n;
	int p[100001];
	int cnt = 0;
	int temp;

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

	for (int i = 1; i <= n; i++) {
		if (p[i] == i) {
			cnt++;
			if (i != n) {
				temp = p[i];
				p[i] = p[i + 1];
				p[i + 1] = temp;
			}
			else {
				temp = p[i];
				p[i] = p[1];
				p[1] = temp;
			}
		}
	}
	printf("%d", cnt);
	return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;
ll inf = 1000000000;
typedef pair<ll, ll> P;
int a[100005];
int main() {
	ll n, y;
	cin >> n >> y;
	
	ll ans;
	for (int i = 0; i <= n; i++) {
		for (int j = 0; j <= n; j++) {
			ans = (n - (i + j)) * 10000 + i * 5000 + j * 1000;
			if (ans == y&&i+j<=n) {
				
				cout << (n - i -j) << " " << i << " " << j << " " << endl;
				return 0;
			}
		}
	}
	cout << -1 << " " << -1 << " " <<-1<< endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;


public class Main {

    public static void main(String[] args) {

    	Main main=new Main();

    	main.run();

    }

    void run() {

    	Scanner sc=new Scanner(System.in);
    	
    	int a=sc.nextInt();
    	int b=sc.nextInt();
    	int c=sc.nextInt();
    	
    	if(a==b) {
    		System.out.println(c);
    	}else if(a==c) {
    		System.out.println(b);
    	}else {
    		System.out.println(a);
    	}
    }
}


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

int main(){
    int m,n;
    scanf("%d %d",&n,&m);
    if(n>1 && m>1){
        printf("%lld",1LL*n*m-2*n-2*(m-2));
        return 0;
    }

    else if(n==1 && m==1){
        printf("1\n");
        return 0;
    }

    if(n==1){
        printf("%d\n",m-2);
    }

   else if(m==1){
       printf("%d\n",n-2);
   } 


}

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

#define mset(x, v) memset(x, v, sizeof(x));
#define fi first
#define se second
#define pb push_back
#define be begin()
#define en end()
#define mp make_pair

#define sd(x) scanf("%lld",&x);
#define sd2(x,y) scanf("%lld %lld",&x,&y);
#define sd3(x,y,z) scanf("%lld %lld %lld",&x,&y,&z);

#define pf(x) printf("%lld\n", x);
#define pf2(x,y) printf("%lld %lld", x,y);
#define pf3(x,y,z) printf("%lld %lld %lld", x,y,z);

using namespace std;

typedef long long ll;

typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<pll> vpll;
typedef set<ll> sll;
typedef queue<ll> qll;

template<class U, class V>
ostream& operator<<(ostream& os, const pair<U, V>& p) {os << "(" << p.first << ", " << p.second << ")";return os;}

template<class U, class V>
istream& operator>>(istream& in, pair<U, V>& p) {in >> p.first >> p.second;return in;}

int main ()
{
    ll n, k; sd2 (n, k);
    ll h[n], dp[n]; for (ll i = 0; i < n; i++)  sd (h[i]);
    mset (dp, 0);
    for (ll i = 1; i < n; i++)
    {
        ll mi = INT_MAX;
        for (ll j = 1; j <= k && i-j >= 0; j++)
        {
            mi = min (mi, dp[i-j] + abs (h[i] - h[i-j]));
        }
        dp[i] = mi;
    }
    pf (dp[n-1]);
    return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>
#include <math.h>

#define N 3

int search(int board[N][N],int min,int limit,int r,int c);

int main(int argc, char *argv[]){
  int board[N][N];
  int md;
  int i,j,r,c,x,y,found;
  int res;
  for (i=0;i<N;i++) {
    for (j=0;j<N;j++)
    scanf("%d",&board[i][j]);
  }
  md=0;
  for(i=0;i<N*N;i++) {
    found=0;
    for(r=0;r<N;r++){
      for(c=0;c<N;c++) {
	       if(board[r][c]==i){
	          if(i==0){
	             x=r;
	              y=c;
	             }
               else md+=(int)abs((i-1)/N-r)+(int)abs((i-1)%N-c);
	              found=1;
	               break;
	        }
      }
      if (found == 1) break;
      }
  }

  for(i=0;;i+=2){
    if((x+y)%2==0){
      if(md%2==0)res=search(board,md,md+i,x,y);
      else res=search(board,md,md+i+1,x,y);
    }
    else{
      if(md%2==0)res=search(board,md,md+i+1,x,y);
      else res=search(board,md,md+i,x,y);
    }
    if(res!=-1)break;
  }
  printf("%d\n",res);
  return 0;
}

int search(int board[N][N],int min,int limit,int x, int y){
  int md_c,num,res[4];
  if(min==0)return 0;
  if(x!=0){
    md_c=min;
    num=board[x-1][y];
    md_c-=(int)abs((num-1)/N-(x-1))+(int)abs((num-1)%N-y);
    md_c+=(int)abs((num-1)/N-x)+(int)abs((num-1)%N-y);
    if(md_c<=limit-1){
      board[x-1][y]=0;
      board[x][y]=num;
      res[0]=search(board,md_c,limit-1,x-1,y);
      if(res[0]==-1){
	board[x-1][y]=num;
	board[x][y]=0;
      }
      else res[0]++;
    }
    else res[0]=-1;
  }
  else res[0]=-1;
  if(x!=N-1){
    md_c=min;
    num=board[x+1][y];
    md_c-=(int)abs((num-1)/N-(x+1))+(int)abs((num-1)%N-y);
    md_c+=(int)abs((num-1)/N-x)+(int)abs((num-1)%N-y);
    if(md_c<=limit-1){
      board[x+1][y]=0;
      board[x][y]=num;
      res[1]=search(board,md_c,limit-1,x+1,y);
      if(res[1]==-1){
	       board[x+1][y]=num;
	       board[x][y]=0;
      }
      else res[1]++;
    }
    else res[1]=-1;
  }
  else res[1]=-1;

  if(y!=0){
    md_c=min;
    num=board[x][y-1];
    md_c-=(int)abs((num-1)/N-x)+(int)abs((num-1)%N-(y-1));
    md_c+=(int)abs((num-1)/N-x)+(int)abs((num-1)%N-y);
    if(md_c<=limit-1){
      board[x][y-1]=0;
      board[x][y]=num;
      res[2]=search(board,md_c,limit-1,x,y-1);
      if(res[2]==-1){
	       board[x][y-1]=num;
	       board[x][y]=0;
      }
      else res[2]++;
    }
    else res[2]=-1;
  }
  else res[2]=-1;
  if (y!=N-1){
    md_c=min;
    num=board[x][y+1];
    md_c-=(int)abs((num-1)/N-x)+(int)abs((num-1)%N-(y+1));
    md_c+=(int)abs((num-1)/N-x)+(int)abs((num-1)%N-y);
    if(md_c<=limit-1) {
      board[x][y+1]=0;
      board[x][y]=num;
      res[3]=search(board,md_c,limit-1,x,y+1);
      if(res[3]==-1){
        board[x][y+1]=num;
        board[x][y]=0;
      }
      else res[3]++;
    }
    else res[3]=-1;
  }
  else res[3]=-1;

  if(res[0]==-1&&res[1]==-1&&res[2]==-1&&res[3]==-1) return -1;
  else if(res[0]!=-1)return res[0];
  else if(res[1]!=-1)return res[1];
  else if(res[2]!=-1)return res[2];
  else return res[3];
}



Measured memory_bytes: 2112
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<ctime>
#include<map>
#include<bitset>
#include<set>
#include<assert.h>
#define LL long long
#define mp(x,y) make_pair(x,y)
#define pll pair<long long,long long>
#define pii pair<int,int>
#define SZ(x) ((int)x.size())
using namespace std;
inline LL read()
{
	LL f=1,x=0;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
int stack[20];
template<typename T>inline void write(T x)
{
	if(x<0){putchar('-');x=-x;}
    if(!x){putchar('0');return;}
    int top=0;
    while(x)stack[++top]=x%10,x/=10;
    while(top)putchar(stack[top--]+'0');
}
template<typename T>inline void pr1(T x){write(x);putchar(' ');}
template<typename T>inline void pr2(T x){write(x);putchar('\n');}
template<typename T>inline void chkmin(T &x,T y){x=x<y?x:y;}
template<typename T>inline void chkmax(T &x,T y){x=x>y?x:y;}
const int MAXN=2005;
vector<int> nxt[MAXN];
void ins(int x,int y){nxt[x].emplace_back(y);}
int f[MAXN],sz[MAXN],mx[MAXN],tot[MAXN];
bool vis[MAXN];
void init(int x,int fa)
{
	sz[x]=vis[x];mx[x]=tot[x]=0;
	for(auto y:nxt[x])if(y^fa)init(y,x),chkmax(mx[x],tot[y]+sz[y]),tot[x]+=tot[y]+sz[y],sz[x]+=sz[y];
}
int n;
void dp(int x,int fa)
{
	f[x]=0;for(auto y:nxt[x])if(y^fa)dp(y,x);
	if(2*mx[x]<=tot[x])f[x]=tot[x]>>1;
	else
	{
		int u=-1;for(auto y:nxt[x])if(tot[y]+sz[y]==mx[x])u=y;assert(u!=-1);
		f[x]=tot[x]-mx[x];int t=mx[x]-(tot[x]-mx[x]);
		f[x]+=min(t>>1,f[u]);
	}
}
int solve(int rt)
{
	init(rt,0);
	if(tot[rt]&1)return 1e9;
	dp(rt,0);if(2*f[rt]==tot[rt])return f[rt];
	return 1e9;
}
char ch[MAXN];
int main()
{
	n=read();scanf("%s",ch+1);
	for(int i=1;i<=n;i++)vis[i]=ch[i]-'0';
	for(int i=1;i<n;i++)
	{
		int x=read(),y=read();
		ins(x,y);ins(y,x);
	}int ans=1e9;
	for(int i=1;i<=n;i++)
		chkmin(ans,solve(i));
	pr2(ans==1e9?-1:ans);
	return 0;
}


Measured memory_bytes: 512
ll= lambda : list(map(int,input().split()))
testcases=1
# testcases=int(input())
for testcase in range(testcases):
	[n,x]=ll()
	l=ll()
	d=[0]
	for i in range(0,n):
		d.append(d[-1]+l[i])
	ans=0
	for i in d:
		if i <= x:
			ans+=1
	print(ans)



Measured memory_bytes: 3060
n = gets.chomp.to_i
a = gets.chomp.split.map(&:to_i)

def color(rate)
  if rate < 400
    1
  elsif rate < 800
    2
  elsif rate < 1200
    3
  elsif rate < 1600
    4
  elsif rate < 2000
    5
  elsif rate < 2400
    6
  elsif rate < 2800
    7
  elsif rate < 3200
    8
  end
end

colors = []
god = 0
a.each do |rate|
  if rate >= 3200
    god += 1
  else
    colors.push(color(rate))
  end
end

min = colors.uniq.count
max = min + god
if min == 0
  min = 1
end

puts "#{min} #{max}"


Measured memory_bytes: 1788
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cmath>
using namespace std;
using ll = long long;

int main() {
    int k, x;
    cin >> k >> x;

    cout << (k * 500 >= x ? "Yes" : "No") << endl;

    return 0;
}

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

long long MOD = 1000000007;

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

    cout << ( N%K == 0 ? 0 : 1 ) << endl;

    return 0;
}

Measured memory_bytes: 768
/*
AizuOnline A0032
Plastic Board
*/
#include <stdio.h>


main()
{
  int h1,h2,t;
  int rect;
  int hisi;

  rect=0;hisi=0;

  while(EOF != scanf("%d,%d,%d",&h1,&h2,&t))
    {
      if(h1 == h2 && 2*h1 > t)
	hisi++;
      if(h1*h1+h2*h2==t*t)
	rect++;
    }
  printf("%d\n",rect);
  printf("%d\n",hisi);
return(0);
}

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

int main() {
  int a, b;
  cin >> a >> b;
  int ans = 0;

  for (a ; a <= b; a++) {
    string c = to_string(a);
    reverse(c.begin(), c.end());
    if (to_string(a) == c) ans++;
  }

  cout << ans << endl;
}

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

#define pb push_back
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define REP(i,n) for(int _n=n, i=0;i<_n;++i)
#define FOR(i,a,b) for(int i=(a),_b=(b);i<=_b;++i)
#define FORD(i,a,b) for(int i=(a),_b=(b);i>=_b;--i)
using ull = uint64_t;
using ll = int64_t;
using PII = pair<int, int>;
using VI = vector<int>;

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__)

int main() {
    ios::sync_with_stdio(false), cin.tie(0);
    int H, W, N;
    cin >> H >> W >> N;
    VI V(N);
    REP(i, N) cin >> V[i];
    int idx = 0;
    vector<VI> ans(H, VI(W));
    REP(i, H) {
        if (i % 2 == 0) {
            REP(j, W) {
                while (V[idx] == 0) idx++;
                ans[i][j] = idx + 1;
                V[idx]--;
            }
        } else {
            FORD(j, W - 1, 0) {
                while (V[idx] == 0) idx++;
                ans[i][j] = idx + 1;
                V[idx]--;
            }
        }
    }
    REP(i, H) {
        REP(j, W) {
            cout << ans[i][j] << " ";
        }
        cout << "\n";
    }
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define N 1024
using namespace std;

int main(){
  int n;
  string s;
  while(1){
    cin>>n;
    if(!n)break;
    int die[6]={1,2,3,4,5,6};
    for(int i=0;i<n;i++){
      cin>>s;
      if(s[0]=='n'){
	swap(die[0],die[4]);
	swap(die[4],die[5]);
	swap(die[5],die[1]);
      }
      if(s[0]=='s'){
	swap(die[0],die[1]);
	swap(die[1],die[5]);
	swap(die[5],die[4]);
      }
      if(s[0]=='w'){
	swap(die[0],die[3]);
	swap(die[3],die[5]);
	swap(die[5],die[2]);
      }
      if(s[0]=='e'){
	swap(die[0],die[2]);
	swap(die[2],die[5]);
	swap(die[5],die[3]);
      }
    }
    cout<<die[0]<<endl;
  }
}

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

typedef long long ll;

struct Node{
    int key;
    Node* next;
    Node* pre;
};

struct List{
    Node *first;

    void init(){
        first = (Node*)malloc(sizeof(Node));
        first->key=0;
        first->next=first;
        first->pre=first;
    }

    void insert(int x){
        Node *nextnode = (Node*)malloc(sizeof(Node));
        nextnode->key = x;
        nextnode->next = first->next;
        first->next->pre = nextnode;
        first->next = nextnode;
        nextnode->pre = first;
    }

    void delete_x(int x){
        for(Node* p=first->next; p != first; p = p->next){
            if(p->key == x){
                p->next->pre = p->pre;
                p->pre->next = p->next;
                free(p);
                return;
            }
        }
    }

    void deleteFirst(){
        Node *p = first->next;
        p->next->pre = p->pre;
        first->next = p->next;
        free(p);
    }

    void deleteLast(){
        Node *p = first->pre;
//        for(p = first; p->next != first; p=p->next);
        p->pre->next = p->next;
        p->next->pre = p->pre;
    }

    void print_list(){
        bool flg=false;
        for(Node* p=first->next; p != first ; p=p->next){
            if(flg)cout << " ";
            cout << p->key;
            flg=true;
        }
        cout << endl;
    }

};

int main(){
    ios::sync_with_stdio(false);

    int n;
    cin >> n;
    List list;
    list.init();
    string s;
    int k;
    for(int i=0;i<n;i++){
        cin >> s;
        if(s=="insert"){
            cin >> k;
            list.insert(k);
        }else if(s=="delete"){
            cin >> k;
            list.delete_x(k);
        }else if(s=="deleteFirst"){
            list.deleteFirst();
        }else{
            list.deleteLast();
        }
    }
    list.print_list();
}



Measured memory_bytes: 34368
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, x, n) for (int i = x; i < (n); i++)
#define all(n) begin(n), end(n)
struct cww
{
    cww()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
} star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template <typename T, typename... Ts>
auto make_v(size_t a, Ts... ts)
{
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }

template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v)
{
    for (auto &e : t)
        fill_v(e, v);
}
int main()
{
    ll N, x;
    cin >> N >> x;
    vll a(N);
    for (size_t i = 0; i < N; i++)
    {
        cin >> a[i];
    }
    ll ans = 0;
    if(a[0]>x)
    {
        ans += a[0]-x;
        a[0]=x;
    }
    for (size_t i = 0; i < N - 1; i++)
    {
        if (a[i] + a[i + 1] > x)
        {
            ans += a[i + 1] - (x - a[i]);
            a[i + 1] = x - a[i];
        }
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 1024
#region using directives
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static System.Console;
using static System.Convert;
#endregion

class Program
{
    static void Main()
    {
        int n = ToInt32(ReadLine());
        List<string> temp_input = ((ReadLine()).Split()).ToList();
        int d = ToInt32(temp_input[0]);
        int x = ToInt32(temp_input[1]);
        int answ = 0;

        for(int i = 0; i < n; i++)
        {
            int a = ToInt32(ReadLine());
            int k = 1;
            int t = 1;
            while(t <= d)
            {
                answ++;
                t = k * a + 1;
                k++;
            }
        }

        WriteLine(answ + x);
    }
}


Measured memory_bytes: 11220
def gcd(a, b):
    while b!=0:
        a, b = b, a%b
    return a

def pf(n):
    a, odd = {1}, 3
    while n%2==0:
        a.add(2)
        n //= 2
    while odd**2<=n:
        if n%odd==0:
            a.add(odd)
            n //= odd
        else:
            odd += 2
    a.add(n)
    return a

def main():
    a, b = map(int, input().split())
    print(len(pf(gcd(a, b))))

if __name__ == "__main__":
    main()


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

using namespace std;

int main()
{
    int nn[51]={0},n,m,a,b;
    scanf("%d%d",&n,&m);
    for(int i=0;i<m;i++){
        scanf("%d%d",&a,&b);
        nn[a]++;
        nn[b]++;
    }
    for(int i=1;i<=n;i++){
        printf("%d\n",nn[i]);
    }
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
   
int main(){
       
    int x, h, m, s;
   
    scanf("%d\n", &x);
   
    h = x / 3600;
    m = (x - h*3600) / 60;
    s = x - h*3600 - m*60;
  
    printf("%d:%d:%d\n", h, m, s);
  
    return 0;
}

Measured memory_bytes: 1780
a,b,c,k=map(int,input().split())
sum=0
while k>0:
    if a>0:
        if k>=a:
            sum+=a
            k=k-a
            a=0
        else:
            sum+=k
            k=0

    elif b>0:
        if k>=b:
            sum+=0
            k=k-b
            b=0
        else:
            sum+=0
            k=0
    else:
        sum-=k
        k=0
print(sum)

Measured memory_bytes: 61864
#include<cstdio>
#include<cstring>
int main()
{
	int t=0;
	char a[10000];
	scanf("%s",a);
	for (int i=0;i<strlen(a);i++)
	{
		if(a[i]=='C') t++;
		if(t!=0&&a[i]=='F')
		{
			printf("Yes");
			return 0;
		}
	}
	printf("No");
	return 0;
}

Measured memory_bytes: 128
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

s = list(input())
K = INT()

def ctoi(c):
	return ord(c) - ord('a')

for i in range(len(s)):
	x = ctoi(s[i])
	if x == 0 or 26-x > K:  continue
	K -= 26-x
	s[i] = "a"
if K:
	s[-1] = ascii_lowercase[(ctoi(s[-1])+K)%26]
print("".join(s))


Measured memory_bytes: 6352
#include <iostream>
#include <vector>
#include <string>
#include <array>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>
#include <stack>
#include <utility>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <climits>
#include <bitset>
#include <random>
#include <functional>
#include <sstream>
#include <iomanip>
#include <chrono>
#include <ctime>

using namespace std;

#define _CRT_SECURE_NO_WARNINGS
#define rep(i, n) for(int (i)=0; (i)<(n); (i)++)
#define FOR(i, m, n) for(int (i)=(m);(i)<(n);(i)++)
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define REVE(x) reverse((x).begin(),(x).end())
#define MP make_pair
#define PB push_back

typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
typedef long long LL;

int main() {
	string s;
	cin >> s;
	int sum1 = 0;
	for (auto c : s) {
		sum1 += c - '0';
	}
	int sum2 = 9 * (SZ(s) - 1) + (s[0] - '0' - 1);
	printf("%d\n", sum1 < sum2 ? sum2 : sum1);
}

Measured memory_bytes: 256
import sys
import math
from collections import deque

sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7
input = lambda: sys.stdin.readline().strip()
NI = lambda: int(input())
NMI = lambda: map(int, input().split())
NLI = lambda: list(NMI())
SI = lambda: input()


def make_grid(h, w, num): return [[int(num)] * w for _ in range(h)]


# Nの素因数分解を辞書で返す
def prime_fact(n):
    root = int(math.sqrt(n))
    prime_dict = {}
    for i in range(2, root+1):
        cnt = 0
        for j in range(root+1):
            if n % i == 0 and n != 0:
                cnt += 1
                n = n // i
            else:
                break
        if cnt:
            prime_dict[i] = cnt
    if n != 1:
        prime_dict[n] = 1
    return prime_dict


def main():
    N = NI()
    A = NLI()
    L = {}
    primes_a = {}
    for a in A:
        prime_a = prime_fact(a)
        primes_a[a] = prime_a
        for p, n in prime_a.items():
            L.setdefault(p, 0)
            L[p] = max(L[p], n)
    ans = 0
    l = 1
    for p, n in L.items():
        l = l * pow(p, n, MOD) % MOD

    for i, a in enumerate(A):
        ans += l * pow(a, MOD-2, MOD) % MOD
    print(ans % MOD)



if __name__ == "__main__":
    main()

Measured memory_bytes: 78544
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <queue>
#include <cmath>
#include <map>
#include <set>
#include <deque>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int mod = 1e9+7;
const int inf = 1<<30;
typedef pair<int, int> P;

int main() {
  int n; cin >> n;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];
  ll ans = 0;
  rep(i, 60) {
    ll x = 0;
    rep(j, n) if(a[j] >> i & 1) ++x;
    ll now = x * (n-x) % mod;
    rep(j, i) now = now * 2 % mod;
    ans += now;
    ans %= mod;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 2560
N,K,Q = map(int,input().split())
A = list(map(int,input().split()))

R = sorted(set(A))
ans = 10**9
for i in range(len(R)):
    temp = []
    temp2 = []
    l = 0
    for j in range(N):
        if A[j] < R[i]:
            if l >= K:
                temp += sorted(temp2)[:min(l,max(0,l - K + 1))]
            temp2 = []
            l = 0
        else:
            temp2.append(A[j])
            l += 1
    if l >= K:
        temp += sorted(temp2)[:min(l,max(0,l - K + 1))]

    if len(temp) > Q - 1:
        temp = sorted(temp)
        ans = min(ans,temp[Q - 1] - R[i])
    else:
        break
        
print(ans)
    


Measured memory_bytes: 3316
N=int(input())
if N>=400 and 599>=N:
  print('8')
if N>=600 and 799>=N:
  print('7')
if N>=800 and 999>=N:
  print('6')
if N>=1000 and 1199>=N:
  print('5')
if N>=1200 and 1399>=N:
  print('4')
if N>=1400 and 1599>=N:
  print('3')
if N>=1600 and 1799>=N:
  print('2')
if N>=1800 and 1999>=N:
  print('1')

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

int main() {
  int N;
  cin >> N;
  int num = N;
  int H=0;
  while(num){
    H += num % 10;
    num /= 10;
  }
  if(N%H==0){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}


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

int main(){
    ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);

    int n, m;
    cin>>n>>m;

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

    vector<int> adj[n];
    for (int i=0; i<m; i++){
        int o1, o2;
        cin>>o1>>o2;
        adj[o1-1].push_back(o2-1);
        adj[o2-1].push_back(o1-1);
    }
    int cnt = 0;
    for (int i=0; i<n; i++){
        int ok = 1;
        for (int j=0; j<adj[i].size(); j++){
            if (h[adj[i][j]]>=h[i]){
                ok = 0;
                break;
            }
        }
        cnt+=ok;
    }
    cout<<cnt;
    return 0;
}



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

int main()
{

  int n, k, cnt = 0;

  cin >> n >> k;

  while(n != 0){
    cnt++;
    n /= k;
  }

  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip> //! for setprecision(10)
#include <math.h>
#include <algorithm>
#include <functional> 
#include <string>
#include <vector>

#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <utility>

using namespace std;

typedef long long LL;

#define dump(c) { for (auto it = c.begin(); it != c.end(); ++it) if (it == c.begin()) cout << *it; else cout << ' ' << *it; cout << endl; } 
#define rep(i,n) for (int i = 0; i < (n); ++i)

const int MOD = 1000000007;

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

    int N, K, R, S, P;
    string T;
    cin >> N >> K >> R >> S >> P >> T;

    LL ans = 0;
    for (int o = 0; o < K; ++o) {
        int prevR = 0;
        int prevS = 0;
        int prevP = 0;
        for (int i = o; i < N; i += K) {
            int currR = R * (T[i] == 's' ? 1 : 0) + max(prevS, prevP);
            int currS = S * (T[i] == 'p' ? 1 : 0) + max(prevP, prevR);
            int currP = P * (T[i] == 'r' ? 1 : 0) + max(prevR, prevS);
            prevR = currR;
            prevS = currS;
            prevP = currP;
        }
        ans += max(prevR, max(prevS, prevP));
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 512