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

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

#define IOS             ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define read            freopen("in.txt","r",stdin)
#define write           freopen("out.txt","w",stdout)
#define loop(i,a,b)     for (ll i = a; i <= b; i++)
#define rloop(i,a,b)    for (ll i = a; i >= b; i--)
#define ms(a,x)         memset(a,x,sizeof a)
#define ll              long long int
#define ff              first
#define ss              second
#define all(a)          a.begin(),a.end()
#define rall(a)         a.rbegin(),a.rend()
#define pb              push_back
#define nl              cout<<"\n"
#define gcd(a,b)        __gcd((a),(b))
#define lcm(a,b)        ((a)*(b))/(gcd(a,b))
#define sq(a)           (a)*(a)
#define sz(a)           a.size()
#define mod             1000000007
#define PI              2*acos(0.0)


int main()
{
    IOS
    int T=1;
    //cin>>T;
    while(T--)
    {
        ll n,m;
        cin>>n>>m;
        ll a[n];
        loop(i,0,n-1)
        {
            cin>>a[i];
            a[i]/=2;
        }
        ll t=__builtin_ctz(a[0]);
        loop(i,0,n-1)
        {
            if(__builtin_ctz(a[i])!=t)
            {
                cout<<0;
                return 0;
            }
            a[i]>>=t;
        }
        m>>=t;
        ll lm=1;
        loop(i,0,n-1)
        {
            lm=lcm(lm,a[i]);
            if(lm>m)
            {
                cout<<0;
                return 0;
            }
        }
        //debug(m,lm);
        m/=lm;
        cout<<(m+1)/2;
    }
    return 0;
}


Measured memory_bytes: 4408
function Dice(num) {
  this.top    = num[0];
  this.front  = num[1];
  this.right  = num[2];
  this.left   = num[3];
  this.back   = num[4];
  this.bottom = num[5]

  this.roll = function(direction) {
    var tmp;
    switch (direction) {
      case 'E':
        tmp         = this.top;
        this.top    = this.left;
        this.left   = this.bottom;
        this.bottom = this.right;
        this.right  = tmp;
        break;
      case 'N':
        tmp         = this.top;
        this.top    = this.front;
        this.front  = this.bottom;
        this.bottom = this.back;
        this.back   = tmp;
        break;
      case 'S':
        tmp         = this.top;
        this.top    = this.back;
        this.back   = this.bottom;
        this.bottom = this.front;
        this.front  = tmp;
        break;
      case 'W':
        tmp         = this.top;
        this.top    = this.right;
        this.right  = this.bottom;
        this.bottom = this.left;
        this.left   = tmp
        break;
    }
  }

  this.turn = function(direction) {
    switch (direction) {
      case 'R':
        tmp        = this.front;
        this.front = this.right;
        this.right = this.back;
        this.back  = this.left;
        this.left  = tmp;
        break;
      case 'L':
        tmp        = this.front;
        this.front = this.left;
        this.left  = this.back;
        this.back  = this.right;
        this.right = tmp
        break;
    }
  }

  this.setTop = function(topNum) {
    switch (topNum) {
      case this.top:
        break;
      case this.front:
        this.roll('N');
        break;
      case this.right:
        this.roll('W');
        break;
      case this.left:
        this.roll('E');
        break;
      case this.back:
        this.roll('S');
        break;
      case this.bottom:
        this.roll('N');
        this.roll('N');
        break;
    }
  }

  this.setFront = function(frontNum) {
    switch (frontNum) {
      case this.top:
        break;
      case this.front:
        break;
      case this.right:
        this.turn('R');
        break;
      case this.left:
        this.turn('L');
        break;
      case this.back:
        this.turn('R');
        this.turn('R');
        break;
      case this.bottom:
        break;
    }
  }
}


var input = ""
process.stdin.resume();
process.stdin.setEncoding('utf-8');
process.stdin.on('data', function(chunk) {
  input += chunk;
});
 
process.stdin.on('end', function() {
  input = input.split("\n");

  var dice = new Dice(input[0].split(' ').map(Number));
  var q = Number(input[1]);

  for (var i = 2; i < 2 + q; i++) {
    var n = input[i].split(' ').map(Number);
    dice.setTop(n[0]);
    dice.setFront(n[1]);
    console.log(dice.right);
  }
});

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

int simple(int money, int year, double per, int cost) {
	int add = 0;
	for (int i = 0; i < year; i++) {
		add += money * per;
		money -= cost;
	}
	return money + add;
}

int multi(int money, int year, double per, int cost) {
	for (int i = 0; i < year; i++) {
		money += money * per - cost;
	}
	return money;
}

int main() {
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		int money, year, pattern;
		cin >> money >> year >> pattern;
		int maxResult = 0;
		for (int j = 0; j < pattern; j++) {
			int way;
			cin >> way;
			double per;
			cin >> per;
			int cost;
			cin >> cost;
			
			maxResult = max(maxResult, (way) ? multi(money, year, per, cost) : simple(money, year, per, cost));
		}
		cout << maxResult << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
int n, cnt, ans;
string s;
set<char> a, b;
int main() {
	cin >> n >> s;
	for (int i = 1; i < n; i++) {
		a.clear();
		b.clear();
		cnt = 0;
		for (int j = 0; j < i; j++)
			a.insert(s[j]);
		for (int j = i; j < n; j++)
			b.insert(s[j]);	
		for (char c: a)
			cnt += (b.find(c) != b.end());
		ans = max(ans, cnt);		
	}
	cout << ans;
	return 0;
}

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

int main() {
  int N;
  string S;
  cin >> N >> S;
  
  int ans = 0;
  for (char a = '0'; a <= '9'; ++a) {
    for (char b = '0'; b <= '9'; ++b) {
      for (char c = '0'; c <= '9'; ++c) {
        int A = -1;
        int B = -1;
        int C = -1;
        int count = 0;
        while (count < N) {
          if (S[count] == a) {
            A = count;
            break;
          }
          ++count;
        }
        if (A == -1) continue;
        count = A + 1;
        while (count < N) {
          if (S[count] == b) {
            B = count;
            break;
          }
          ++count;
        }
        if (B == -1) continue;
        count = B + 1;
        while (count < N) {
          if (S[count] == c) {
            C = count;
            break;
          }
          ++count;
        }
        if (C == -1) continue;
        ++ans;
      }
    }
  }
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
n,m=map(int,input().split())
s=[]
for _ in range(m):
  a=list(map(int,input().split()))
  s.append(a)
p=list(map(int,input().split()))
i_b=[]
for i in range(2**n):
  i_b.append(str(bin(i))[2:].zfill(n))
ans=0
for i in i_b:
  i_a=[]
  for j in range(m):
    j_s=0
    for k in range(1,s[j][0]+1):
      j_s+=int(i[s[j][k]-1])
    i_a.append(j_s%2)
  if i_a==p:
    ans+=1
print(ans)


Measured memory_bytes: 3064
#include<stdio.h>
int main(void)
{
	int a,b,c,d,p,x,y;
	scanf("%d",&a);
	scanf("%d",&b);
	scanf("%d",&c);
	scanf("%d",&d);
	scanf("%d",&p);
	x=a*p;
	if(p>c)	y=((p-c)*d)+b;
	else	y=b;
	if(x<=y)	printf("%d\n",x);
	else	printf("%d\n",y);
	return 0;
}



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

const int N = 1e5 + 10;
long long n, x, m, tmp, ans, t;
int a[N], b[N], h[N];
string s, p;
bool mark[N];


int main() 
{
	cin >> s;
	for (int i = 0; i < s.size(); i++) {
		tmp += s[i] - '0';
	}
	if (tmp % 9)
		cout << "No";
	else
		cout << "Yes";
	return 0;
}


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

int main() {
  string s;cin>>s;
  vector<string> weather = {"Sunny", "Cloudy", "Rainy"};
  int itr = find(weather.begin(), weather.end(), s)-weather.begin();
  cout<<weather[(itr+1)%3]<<endl;
}


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

int N;
int order[10];
int l[11];
int r[11];

bool dfs(int i, int b, int c){
    
    if(i == 10)
        return true;
    
    if(order[i] > l[b-1]){
        l[b] = order[i];
        return dfs(i+1, b+1, c);
    }
        
    if(order[i] > r[c-1]){
        r[c] = order[i];
        return dfs(i+1, b, c+1);
    }  
    
    return false;
}

int main(){
    cin >> N;
    while(N--){
        
        for(int i = 0; i < 10; i++){
            cin >> order[i];
            l[i] = -1;
            r[i] = -1;
        }
        
        if(dfs(0, 1, 1))
            cout << "YES\n";
 
        else
            cout << "NO\n";
    }
    return 0;
}


Measured memory_bytes: 2976
#include <iostream>

using namespace std;

typedef long long ll;

#define ii pair<ll, ll>
#define fi first
#define sc second

ii cal(ll n) {
	ii res = ii(n, 1ll);
	for (ll i = 10ll; i <= n; i *= 10ll) {
		ii c = cal(n / i);
		res.fi += c.fi + (n % i) * c.sc;
		res.sc += c.sc;
	}
	return res;
}

int main() {
#ifdef _DEBUG
	freopen("_in" , "r", stdin );
	freopen("_out", "w", stdout);
#endif
	ll n; cin >> n;
	cout << cal(n).fi << '\n';
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<vector>
#include<algorithm>
#include<queue>
#include<cmath>
#include<cstdlib>
#define LL long long
#define LD long double
using namespace std;
const int NN=200000 +117;
const int MM=200000 +117;
int read(){
	int fl=1,x;char c;
	for(c=getchar();(c<'0'||c>'9')&&c!='-';c=getchar());
	if(c=='-'){fl=-1;c=getchar();}
	for(x=0;c>='0'&&c<='9';c=getchar())
		x=(x<<3)+(x<<1)+c-'0';
	return x*fl;
}
void open(){
	freopen("a.in","r",stdin);
	//freopen("a.out","w",stdout);
}
void close(){
	fclose(stdin);
	fclose(stdout);
}


int m,n;
int a[NN]={};
struct node{
	int p,v;
}s[NN]={};
bool chk(int x){
	int top=0;
	for(int i=1;i<=n;++i){
		if(a[i]<=a[i-1]){
			int now=a[i];
			while(top&&s[top-1].p>now)--top;
			bool fl=1;
			while(top&&s[top-1].p==now){
				++s[top-1].v;
				if(s[top-1].v<x){
					fl=0;
					break;
				}
				--top;
				--now;
			}
			if(fl){
				if(now==0)return false;
				s[top].p=now;
				s[top].v=1;
				++top;
			}
		}
	}
	return true;
}
int main(){
	//open();
	n=read();
	for(int i=1;i<=n;++i){
		a[i]=read();
	}
	bool fl=0;
	for(int i=2;i<=n;++i){
		if(a[i]<=a[i-1]){
			fl=1;
		}
	}
	if(!fl){
		printf("1\n");
		return 0;
	}
	int l=2;
	int r=n;
	while(l!=r){
		int mid=(l+r)>>1;
		if(chk(mid)){
			r=mid;
		}
		else l=mid+1;
	}
	printf("%d\n",l);
	close();
	return 0;
}

Measured memory_bytes: 1024
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;

#define INF 1LL << 55
#define MAX (1LL << 31) -1
#define MOD 1000000007
typedef long long ll;
typedef pair<ll,int> P;
typedef pair<pair<int,int>,ll> p;
#define bit(n, k) ((n >> k) & 1) /*nのk bit目*/
#define rad_to_deg(rad) (((rad) / 2 / M_PI) * 360)
struct edge{ll to,cost,val;};
template<class T,class U>bool chmin(T&a,const U&b){if(a<=b)return false;a=b;return true;}
template<class T,class U>bool chmax(T&a,const U&b){if(a>=b)return false;a=b;return true;}
//__builtin_popcount(S);
//C.erase(unique(C.begin(),C.end()),C.end());
//#define int ll
int dx[]={1,-1,0,0},dy[]={0,0,-1,1};
//#define F function<T(T,T)>

bool flag[2100];

signed main(){
    int N,K,Q;
    cin>>N>>K>>Q;
    vector<ll> A(N+1);
    for(int i=1;i<=N;i++) cin>>A[i];
    vector<P> V;
    for(int i=1;i<=N;i++){
        V.push_back(P(A[i],i));
    }
    sort(V.begin(),V.end());
    ll ans=INF;
    flag[N+1]=true;
    for(int i=0;i<N;i++){
        priority_queue<ll> que;
        vector<ll> v;
        int count=0;
        for(int j=1;j<=N+1;j++){
            if(flag[j]){
                for(int k=0;k<count-K+1;k++){
                    v.push_back(que.top()*(-1));
                    que.pop();
                }
                while(!que.empty()) que.pop();
                count=0;
            }else que.push(-A[j]),count++;
        }
        sort(v.begin(),v.end());
        if(v.size()>=Q) chmin(ans,v[Q-1]-v[0]);
        flag[V[i].second]=true;
    }
    cout<<ans<<endl;

}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
#include <random>
#include <string>
#include <cmath>
#include <sstream>
#include <istream>
#include <iomanip>
#include <typeinfo>
#include <stack>
#include <map>
#include <queue>
#include <functional>

using namespace std;
typedef long long int ll;

int main(){

    ll N = 0;
    cin >> N;
    vector<ll > v(N, 0);
    vector<ll > c(N, 0);
    ll ans = 0;
    ll flg = 0;

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

    for(ll i = 0; i < N; i++){
        //同じ数字が続くとき
        while(i+1 < N && v[i] == v[i+1]) i++;

        if(v[i] < v[i+1]){
            //単調増加
            while(i+1 < N && v[i] <= v[i+1]) i++;

        }else if(v[i] > v[i+1]){
            //単調減少
            while(i+1 < N && v[i] >= v[i+1]) i++;
        }
        ans++; 
    }


    cout << ans << endl;

} 

Measured memory_bytes: 1792
#line 1 "c.cpp"
// -----------------------------------
// author   : MatsuTaku
// country  : Japan
// created  : 08/29/20 20:54:54
// -----------------------------------

#include <bits/stdc++.h>
#line 3 "/mnt/c/Users/tkmma/competitive_programming/CPBF/library/include/modular.hpp"

template <long long MOD>
class Modular {
 private:
  long long val_;

 public:
  constexpr Modular() : val_(0) {}
  constexpr Modular(long long v) : val_(v%MOD) {
    if (val_ < 0) val_ += MOD;
  }

  constexpr long long val() const { return val_; }
  constexpr Modular operator+(Modular x) const { return (val() + x.val())%MOD; }
  constexpr Modular operator+=(Modular x) { return *this = *this + x; }
  constexpr Modular operator++() { return *this += 1; }
  constexpr Modular operator++(int) { Modular c = *this; ++(*this); return c; }
  constexpr Modular operator-(Modular x) const { return (val() + MOD - x.val())%MOD; }
  constexpr Modular operator-=(Modular x) { return *this = *this - x; }
  constexpr Modular operator--() { return *this -= 1; }
  constexpr Modular operator--(int) { Modular c = *this; --(*this); return c; }
  constexpr Modular operator*(Modular x) const { return (val() * x.val())%MOD; }
  constexpr Modular operator*=(Modular x) { return *this = *this * x; }
  friend constexpr Modular pow(Modular x, long long p) {
    Modular t = 1;
    Modular u = x;
    while (p) {
      if (p & 1)
        t *= u;
      u *= u;
      p >>= 1;
    }
    return t;
  }
  constexpr Modular operator/(Modular x) const { return *this * pow(Modular{x}, MOD-2); }
  constexpr Modular operator/=(Modular x) { return *this = *this / x; }

  constexpr bool operator==(Modular x) const { return val() == x.val(); }
  constexpr bool operator!=(Modular x) const { return val() != x.val(); }
  constexpr bool operator<(Modular x) const { return val() < x.val(); };
  constexpr bool operator<=(Modular x) const { return val() <= x.val(); };
  constexpr bool operator>(Modular x) const { return val() > x.val(); };
  constexpr bool operator>=(Modular x) const { return val() >= x.val(); };

  friend std::ostream& operator<<(std::ostream& os, const Modular& x) {
    return os << x.val();
  }
  friend std::istream& operator>>(std::istream& is, Modular& x) {
    return is >> x.val_;
  }

};

#line 9 "c.cpp"

using namespace std;
using ll = long long;
constexpr int MOD = 1e9+7;
using mint = Modular<MOD>;

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

  int n; cin>>n;
  vector<mint> A(n); for (auto& a:A) cin>>a;
  mint ans = 0;
  mint cum = A[n-1];
  for (int i = n-2; i >= 0; i--) {
    ans += A[i] * cum;
    cum += A[i];
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 4748
#include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
int imos1[200009],imos2[200009],ans,sum,SUM;
vector<int>v;
string s;
stack<int>st;
int main(){
  cin>>s;
  r(i,s.size()){
    if(s[i]=='_')continue;
    if(s[i]=='\\')st.push(i);
    if(s[i]=='/'){
      if(st.empty())continue;
      int x=st.top();st.pop();
      imos1[x]+=(i-x);
      imos2[i]-=(i-x);
    }
  }
  r(i,200009){
    sum+=imos1[i];
    ans+=imos1[i];
    sum+=imos2[i];
    if(sum==0){
      SUM+=ans;
      if(ans!=0)v.push_back(ans),ans=0;
    }
  }
  cout<<SUM<<endl<<v.size();
  r(i,v.size()) cout<<' '<<v[i];
  cout<<endl;
}


Measured memory_bytes: 3388
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, m;
	cin >> n >> m;
	set<int> se;
	map<int, int> wa;
	rep(i,m){
		int p;
		string s;
		cin >> p >> s;
		if(s == "AC") se.insert(p);
		else{
			if(se.find(p) == se.end()) wa[p]++;
		}
	}
	cout << se.size() << " ";
	int ans = 0;
	for(auto p : se){
		ans += wa[p];
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 9600
//inlclude before define 
#define _USE_MATH_DEFINES

//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<type_traits>
#include<numeric>
#include<assert.h>
//#include<deque>
#include<iomanip>
#include<set>
#include<tuple>
#include<map>

using namespace std;

//typedef
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef pair<int, int> P1;
typedef long long int ll;

//define
#define INF 1e9
#define NUM 1000000007
#define all(x) begin(x),end(x)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define REP(i,a,b) for(int i=int(a);i<int(b);i++)
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))

//function

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

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

int main() {
	string s;
	cin >> s;
	int cnt = 0;
	rep(i, s.size()) {
		if (s[i] == '2')cnt++;
	}
	cout << cnt << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define x1 jfkljfewlkjfwekl
#define x2 jkfwejklfwej
#define y1 kfewfe
#define y2 jfwekj3w3e
 
int bomb[50][50];
 
 int counter = 0;
int a[50][50] = {
	{0,0,0,0},
	{0,0,0,0},
	{1,1,0,0},
	{1,1,0,0},
};
int myquery(int x1,int x2,int y1,int y2){
	int sum = 0;
	for(int i = y1 ; i <= y2 ; i++)
		for(int j = x1 ; j <= x2 ; j++)
			sum += a[i][j];
	return sum;
}
int query(int x1,int x2,int y1,int y2){
	counter++;
	cout << "? " << y1 << " " << x1 << " " << y2 << " " << x2 << endl;
	//return myquery(x1,x2,y1,y2);
	int sum;
	cin >> sum;
	return sum;
}
int dfs(int x1,int x2,int y1,int y2,int prv){
	if( x1 > x2 or y1 > y2 ) return 0;
	
	int ask = prv == -1 ? query(x1,x2,y1,y2) : prv;
	//cout << ask << endl;
	if( ask == (x2-x1+1) * (y2-y1+1) ){
		int ans = 0;
		for(int i = y1 ; i <= y2 ; i++)
			for(int j = x1 ; j <= x2 ; j++)
				bomb[i][j] = 1;
		return ask;
		
	}else if( ask == 0 ){
		 return 0;
	}
	int X = (x1+x2) / 2;
	int Y = (y1+y2) / 2;
	
	int a = dfs(x1,X,y1,Y,-1);
	if( a == ask ) return ask;
	int b = dfs(X+1,x2,y1,Y,-1);
	if( a+b == ask ) return ask;
	int c = dfs(x1,X,Y+1,y2,-1);
	if( a+b+c == ask ) return ask;
	int d = dfs(X+1,x2,Y+1,y2,ask-a-b-c);
	return ask;
	
}
signed main(){
	int H,W,N,K;
	cin >> H >> W >> N >> K;
	//for(int i = 0 ; i < N ; i++)
	//	a[rand()%H][rand()%W] = 1;
	//dfs(0,W-1,0,H-1,-1);
	
	long long ans = 0;
	long long w = 1;
	int ww = 50;
	for(int i = 0 ; i < H ; i+=ww){
		for(int j = 0 ; j < W ; j += ww){
			dfs(i,min(i+ww-1,H-1),j,min(j+ww-1,W-1),-1);
		}
	}
	for(int i = 0 ; i < H ; i++){
		for(int j = 0 ; j < W ; j++){
			ans += w * bomb[i][j];
			ans %= K;
			w *= 2;
			w %= K;
		}
	}
	
	cout << "!" << " " << ans << endl;
	//cout << counter << endl;
}

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

int main(){
string n,ans;
cin >> n;
for(int i=0;i<3;++i){
if(n.at(i) == '1')ans.push_back('9');
if(n.at(i) == '9')ans.push_back('1');
}
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define pll pair<ll,ll>
#define all(x) x.begin(), x.end()
#define ed cout << "\n"
#define vll vector<ll>
#define sll set<ll>
#define vpll vector<pll>
#define ar array
#define sz(x) (int)x.size()
#define forn(a,b,c) for(int a = b; a < c; a++)
#define rfor(a,b,c) for(int a = b; a >= c; a--)
#define fors(a,b,c,d) for(int a = b; a < c; a+=d)
#define rfors(a,b,c,d) for(int a = b; a >= c; a-=d)
#define yes cout << "Yes"
#define no cout << "No"
#define NAME ""
bool isFile = 0;
 
typedef long long ll;
typedef long double ld;
 
const ll INF=1e9+1234;                                                   
const int N = 4e5 + 5; 
const ll MOD=998244353;
const ll mod=1e9+7;                                            
double EPS = 3e-18;
const double PI = acos(-1);  
 
 
void faster()
{
	if(isFile)
	{
		freopen(NAME".in","r",stdin);
		freopen(NAME".out","w",stdout);
	}
	ios_base::sync_with_stdio(false);        
    cin.tie(NULL);                                         
    cout.tie(NULL);                                
}                                                     

int d[71234],s[71234],q[71234];


void solve() 
{			  			 																	 									 	  	                      
	int x;
	cin >> x;
	int a = x/500;
	int b = x%500;
	b /= 5;
	cout << a*1000 + b*5;	
}                         
                           
int main()                                     
{                            
	faster();                 
	int t = 1;
	//cin >> t;	
	while(t--)
	{               	
		solve();
		ed;
	}
	return 0;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))



signA = sum([1 for a in A if a<0])

absA = [abs(a) for a in A]
absA.sort()

sumA = sum(absA)
      
         
if any([a==0 for a in A]):
  print(sumA)
elif signA%2==0:
  print(sumA)
elif signA%2!=0:
  print(sumA - 2*absA[0])

Measured memory_bytes: 14332
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
const ld eps = 1e-9;

//// < "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\a.txt" > "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\b.txt"

int N;
int getans(const vector<int>&l, int start,bool used) {
	if (all_of(l.begin(), l.end(), [](const int n) {return n; })) {
		return l.size();
	}
	else {
		int ans = 0;
		{

			int nextnum = (start + N-1) % l.size();
			vector<int>nextl(l);
			nextl.erase(nextl.begin() + nextnum);
			ans = max(ans, getans(nextl, nextnum, used));
		}
		if (!used) {

			int nextnum = (start + N) % l.size();
			vector<int>nextl(l);
			nextl.erase(nextl.begin() + nextnum);
			ans = max(ans, getans(nextl, nextnum, true));
		}
		return ans;
	}
}

int main() {
	int K; cin >> K;
	while (K--) {
		cin >> N;
		string st; cin >> st;
		vector<int>v;
		for (int i = 0; i < st.size(); ++i) {
			v.push_back(st[i] == 'B');
		}
		int ans = getans(v, 0, false);
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 3240
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <utility>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>

using namespace std;

using ll = long long;
using P = pair<int, int>;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mkp(a, b) make_pair(a, b)
const int inf = 1e+9;

const ll mod = 1000000007;

/*
i < j
A_i + A_j = j - i
A_i + i =  j - A_j

j < i 
A_i + A_j = i - j
i - A_i = A_j + j 



(n * n - n) / 2; 
*/

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

	int a[n];
	map<int, ll> ma;
	
	rep(i, n) {
		cin >> a[i];
		ma[a[i] + i + 1] ++; 
	}
	ll ans = 0;
	rep(i, n) {
		ans = ans + ma[i + 1  - a[i]];
	}
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 26668
def main():
    import sys
    readline = sys.stdin.readline
    # readlines = sys.stdin.readlines
    N, T = map(int, input().split())
    A = list(map(int, readline().split()))

    L = float('inf')
    cnt = 0
    profit = 0
    for a in A:
        if a - L > profit:
            cnt = 1
            profit = a - L
        elif a - L == profit:
            cnt += 1
        
        if a < L:
            L = a
    
    print(cnt)


if __name__ == "__main__":
    main()


Measured memory_bytes: 14252
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
using namespace std;
//using Graph = vector<vector<int>>;
typedef long long ll;
using Graph = vector<vector<pair<ll,ll>>>;
const int mod =1e+9+7;

const int dy[4]={0,1,0,-1};
const int dx[4]={1,0,-1,0};
const ll INF=1e10;

int main(){
    ll a; cin>>a;
    rep(i,a){
        cout<<"ACL";
    }
    cout<<endl;
}











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

using ll = long long;
using P = pair<int, int>;

const int INF = 1e9;
const int MOD = 1e9 + 7;

// 4近傍、8近傍
int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int main() {
  // 入力
  int a, b;
  cin >> a >> b;

  int ans = 0;
  for (int i = a; i <= b; i++) {
    string s = to_string(i);
    string tmp = s;
    reverse(tmp.begin(), tmp.end());
    if (s == tmp) ans++;
  }

  // 解答
  cout << ans << endl;

  return 0;
}


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

int main(void) {
	int N;
	long int date[100] = { 0 };
	long int ans = 0;
	cin >> N;
	for (int i = 0;i < N;i++)
		cin >> date[i];
	sort(date,date+N);
	cout << date[N-1] -date[0] << endl;
	return 0;
}


Measured memory_bytes: 256
A, B = map(int, input().split())

count = 0
for i in range(A, B + 1):
    s = str(i)
    L = len(s)
    if (s[L - 1] == '0'):
        # print(s)
        continue
    r = list(reversed(s))
    ner = ''.join(r)
    # print(ner)
    # print(s)
    if (s == ner):
        # print('done')
        count += 1

print(count)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define LL               long long
#define PB               push_back
using namespace std;
const unsigned LL M = 1000000007;

int main(){
    LL n,m;cin>>n>>m;
    LL mat[n][m];
    LL dp[n][m]={0};
    
    for (LL i=0;i<n;i++){
        string s; cin>>s;
        for (LL j=0;j<m;j++){
            if (s[j]=='#') mat[i][j]=0;
            else mat[i][j]=1;
            dp[i][j]=0;
        }
    }
    dp[0][0]=1;
    for (LL i=0;i<n;i++){
        for (LL j=0;j<m;j++){
            if (i==0 && j==0) continue;
            if (mat[i][j]==0) continue;
            if (i>0) dp[i][j]+=dp[i-1][j];
            if (j>0) dp[i][j]+=dp[i][j-1];
            dp[i][j]%=M;
            // cout<<mat[i][j]<< " ";
        }
        // cout<<endl;
    }
    cout<<dp[n-1][m-1];
}

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

void Main(){
    ll n, s, i, j;
    cin >> n >> s;
    vector<ll> a(n);
    for (i=0; i<n; i++){
        cin >> a.at(i);
    }
    vector<vector<ll>> t(n, vector<ll>(s+1));
    for (ll i=0; i<n; i++){
        t[i][0] = i+2;        
    }
    if (a[0] <= s){
        t[0][a[0]] = 1;
    }
    for (i=1; i<n; i++){
        for (j=1; j<s+1; j++){
            t[i][j] = t[i-1][j];
            if (j - a[i] >= 0){
                t[i][j] += t[i-1][j-a[i]];
                t[i][j] %= 998244353;
            }
        }
    }
    ll sum = 0;
    for (vector<ll> v: t){
        // for (ll x : v){
        //     cout << x;
        // }
        // cout << endl;
        sum += v[s];
        sum = sum % 998244353;
    }
    cout << sum;
}

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

Measured memory_bytes: 70784
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <functional>
using namespace std;
using namespace __gnu_pbds;

#define ll long long
#define mk make_pair

template <class key, class cmp = std::less<key>>
using ordered_set = tree<key, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
const ll mod = 1e9 + 7;



void solve()
{       
    ll n,m;
    cin>>n>>m;
    ll sum=0;
    for(int i=0;i<m;i++)
    {
        ll a;
        cin>>a;
        sum+=a;
    }

    if(sum>n)
    {
        cout<<"-1"<<endl;
    }
    else
    {
        cout<<n-sum<<endl;
    }
    
}   

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

    // ll t;
    // cin >> t;

    // while (t--)
    // {
    //     solve();
    // }
    solve();
    return 0;
}

Measured memory_bytes: 3672
import std.algorithm;
import std.bigint;
import std.bitmanip;
import std.concurrency : generator = Generator, yield;
import std.container;
import std.conv;
import std.functional;
import std.format;
import std.math;
import std.meta;
import std.numeric;
import std.random;
import std.range;
import std.stdio;
import std.string;
import std.traits;
import std.typecons;


auto solve(long N, long[] a) {
    long wannaPreserve = 1;
    long preserved;

    foreach (ai; a) {
        if (ai == wannaPreserve) {
            preserved++;
            wannaPreserve++;
        }
    }

    if (preserved == 0)
        return -1;

    return N - preserved;
}


void main() {
    auto input = stdin.byLine.map!split.joiner;

    long N;
    N = input.front.to!long;
    input.popFront;

    long[] a = new long[](cast(size_t) (N));
    foreach (i; 0 .. cast(size_t) (N)) {
        a[i] = input.front.to!long;
        input.popFront;
    }

    static if (is(ReturnType!solve == void))
        solve(N, a);
    else {
        auto ans = solve(N, a);

        static if (isFloatingPoint!(ReturnType!solve))
            writeln(format("%.9f", ans));
        else static if (is(ReturnType!solve == bool))
            writeln(ans ? YES : NO);
        else
            writeln(ans);
    }
}


Measured memory_bytes: 19600
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

map<ll, ll> prime_factorization(ll n){
  map<ll, ll> ans;
  ll a = 2;
  while(n >= a*a){
    if(n % a == 0){
      ans[a]++;
      n /= a;
    }else{
      a++;
    }
  }
  ans[n]++;

  return ans;
}

int main(){
  ll n, p;
  cin >> n >> p;
  auto mp = prime_factorization(p);
  ll ans = 1;
  for(auto p : mp){
    ll add = p.second/n;
    add = pow(p.first, add);
    ans *= add;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 4056
package main

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

var sc = bufio.NewScanner(os.Stdin)

func ri() (n int) {
	sc.Scan()
	for _, v := range sc.Bytes() {
		n = n*10 + int(v-48)
	}
	return
}

func rs() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	sc.Split(bufio.ScanWords)
	n := ri()

	h := make([]int, n)
	for i := 0; i < n; i++ {
		h[i] = ri()
	}

	ans := 0
	max := 0
	for _, v := range h {
		if v >= max {
			ans++
		}

		if v > max {
			max = v
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 640
n,k=map(int,input().split())
ans=0	
for i in range(1,n+1): #出る目[1,n]について調べる
	l=0
	while i*2**l<k:
		l+=1
	ans+=1/n*(1/2)**l
print('{:.10f}'.format(ans)) #小数点以下8桁表示

Measured memory_bytes: 2940
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#define llint long long

using namespace std;
//typedef pair<llint, llint> P;
typedef pair<llint, string> P;

llint w, h;
char c[75][75];
string dp[75][75];

string getmax(string s, string t)
{
	if(s.size() < t.size()) return t;
	if(t.size() < s.size()) return s;
	return max(s, t);
}

int main(void)
{
	while(1){
		cin >> w >> h;
		if(w == 0 && h == 0) break;
		
		for(int y = 1;  y<= h; y++){
			for(int x = 1; x <= w; x++){
				cin >> c[x][y];
			}
		}
		
		for(int y = 1; y <= h; y++){
			for(int x = 1; x <= w; x++){
				dp[x][y] = "";
			}
		}
		for(int y = 1; y <= h; y++){
			for(int x = 1; x <= w; x++){
				if(c[x][y] < '0' || c[x][y] > '9') continue;
				dp[x][y] = getmax(dp[x-1][y]+c[x][y], dp[x][y-1]+c[x][y]);
				if(dp[x][y] == "0") dp[x][y] = "";
			}
		}
		
		string ans = "0";
		for(int y = 1; y <= h; y++){
			for(int x = 1; x <= w; x++){
				ans = getmax(ans, dp[x][y]);
			}
		}
		cout << ans << endl;
	}
	
	return 0;
}


Measured memory_bytes: 3400
#include <bits/stdc++.h>
#include <string>
#include <cstdint>
#include <iterator>
#include <algorithm>
#include <fstream>
#include <unordered_map>

using namespace std;

#define FAST_IO ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define Int int_fast64_t

int main()
{
    FAST_IO;

    Int k,count=1,temp=7;
    cin >> k;
    temp=7%k;
    if(k%2==0 || k%5==0)
        count=-1;
    else
    {
        for(;;)
        {
            if(temp%k==0)
                break;
            else
            {
                temp*=10;
                temp+=7;
                temp=temp%k;
                count++;
            }
        }
    }
    cout << count << endl;

    return 0;
}


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

#define BUF_SIZE 102
int main(void) {
  char line[BUF_SIZE];
  FILE *fp;
  fp = stdin;
  if(!fgets(line, BUF_SIZE, fp)) return 0;
  size_t len = strlen(line);
  if(line[len-1] == '\n') {
    len--;
  }
  printf("%c%d%c\n", line[0], (int)len-2, line[len-1]);

  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <queue>
#define prin(num) cout << num << endl
#define max(a, b) ((a)>(b) ? (a):(b))
#define min(a, b) ((a)<(b) ? (a):(b))
#define mp make_pair
#define INF 1000000000000000000
#define MOD 1000000007LL
#define MAX 100005
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef map<ll, ll> Map;

int main(void) {
    string s, t;
    cin >> s >> t;
    ll i;
    ll start[26]={}, goal[26]={};
    for(i=0; i<26; i++) {
        start[i]=-1;
        goal[i]=-1;
    }
    
    
    for(i=0; i<s.size(); i++) {
        ll a=s[i]-'a';
        ll b=t[i]-'a';
        
        if(start[a]==-1 && goal[b]==-1) {
            start[a]=b;
            goal[b]=a;
        }else if(goal[b]!=a) {
            puts("No");
            return 0;
        }
    }
    
    puts("Yes");
    
}

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


int main(){
    int x, y, z;
    cin >> x >> y >> z;
    for(int i = 1;; i++){
        if(i*y + z*(i+1) > x){
            cout << i - 1 << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 256
A,B,K = map(int,input().split())
if B-A+1 <= K*2:
    for i in range(A,B+1):
        print(i)
else:
    for i in range(A,A+K):
        print(i)
    for i in range(B-K+1,B+1):
        print(i)

Measured memory_bytes: 3060
n = int(input())

cards = []
have = []
nothave = []

for j in range(1, 14):
    cards.append(("S", j))
for j in range(1, 14):
    cards.append(("H", j))
for j in range(1, 14):
    cards.append(("C", j))
for j in range(1, 14):
    cards.append(("D", j))

for i in range(n):
    a, b = input().split()
    have.append((a, int(b)))

for i in range(52):
    if cards[i] not in have:
        nothave.append(cards[i])

for i in nothave:
    print(i[0], i[1])
    
        
  




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

int main(int argc, const char * argv[])
{

    int stdnum;
    char blood[4];
    int cnt[4] = {0};
    int i;
    
    while (scanf("%d%s", &stdnum, blood) != EOF) {
        if (strcmp(blood,",A") == 0) cnt[0]++;
        else if (strcmp(blood,",B") == 0) cnt[1]++;
        else if (strcmp(blood,",AB") == 0) cnt[2]++;
        else if (strcmp(blood,",O") == 0) cnt[3]++;
    }
    for (i = 0; i < 4; i++) {
        printf("%d\n", cnt[i]);
    }
    return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main()
{
    ll n, c;
    cin >> n >> c;
    vector<ll> x(n+2);
    vector<ll> v(n+2);
    x[0] = 0;
    v[0] = 0;
    x[n+1] = c;
    v[n+1] = 0;
    for(int i = 1; i <= n; i++)
    {
        cin >> x[i] >> v[i];
    }

    vector<ll> fa(n+1);
    vector<ll> fb(n+1);
    for(int i = 1; i <= n; i++)
    {
        fa[i] = fa[i-1] + v[i] - x[i] + x[i-1];
    }
    for(int i = 1; i <= n; i++)
    {
        fb[i] = fb[i-1] + v[n+1-i] - abs(c-x[n+1-i]) + abs(c-x[n+2-i]);
    }
    vector<ll> ma(n+1);
    vector<ll> mb(n+1);
    for(int i = 1; i <= n; i++)
    {
        ma[i] = max(ma[i-1], fa[i]);
    }
    for(int i = 1; i <= n; i++)
    {
        mb[i] = max(mb[i-1], fb[i]);
    }

    ll ans = 0;
    // 0->a->0->b
    for(int i = 0; i <= n; i++)
    {
        ans = max(ans, fa[i] - x[i] + mb[n-i]);
    }
    // 0->b->0->a
    for(int i = 0; i <= n; i++)
    {
        ans = max(ans, fb[i] - abs(c-x[n+1-i]) + ma[n-i]);
    }
    cout << ans << endl;
}


Measured memory_bytes: 4992
def main():
    N = int(input())
    reds = [list(map(int, input().split(' '))) for _ in range(N)]
    blues = [list(map(int, input().split(' '))) for _ in range(N)]
    blues.sort(key=lambda b: b[0])
    used_reds = [0 for _ in range(N)]
    for b in blues:
        candidates = [(i, reds[i]) for i in range(N) \
                      if used_reds[i] == 0 and reds[i][0] < b[0] and reds[i][1] < b[1]]
        if len(candidates) == 0:
            continue
        highest_index, highest_h = None, -1
        for i, r in candidates:
            if r[1] > highest_h:
                highest_h = r[1]
                highest_index = i
        used_reds[highest_index] = 1
    print(sum(used_reds))


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
n = int(input())
k = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(k[n-1])

Measured memory_bytes: 3060
n = int(input())
s = [int(c) for c in input().split()]
def solution(s):
    cost = 0
    mean = round(sum(s)/len(s))
    for i in s:
        cost += abs(i-mean) ** 2
        #print(f"DEBUG >> {mean} {i} {cost}")
    return cost
  
print(solution(s))

Measured memory_bytes: 2940
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
  int k,i,res=0;
  int a[3];
  for(i=0;i<3;i++)
    cin >> a[i];
  cin >> k;
  sort(a,a+3,greater<int>());
  for(i=0;i<k;i++)
    a[0]*=2;
  for(i=0;i<3;i++)
    res+=a[i];
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 256
import sys
if sys.version_info[0]>=3: raw_input=input

def judge(n):
  ma=0
  mi=1000
  s=0
  for i in range(0,n):
    x=int(raw_input())
    if x<mi:
      mi=x
    if x>ma:
      ma=x
    s+=x
  print((s-ma-mi)//(n-2))

while 1:
  n=int(raw_input())
  if n==0:
    break
  judge(n)

Measured memory_bytes: 4216
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int N=1e6;
int n,m;
char a[N];
int sum=0;
inline int read()
{
    int x=0,f=1;
    char ch=getchar();
    while(ch<'0'||ch>'9')
	{
        if(ch=='-') f=-1;
        ch=getchar();
    }
    while(ch>='0'&&ch<='9')
	{
        x=(x<<1)+(x<<3)+(ch^48);
        ch=getchar();
    }
    return x*f;
}
int main()
{
//    freopen("input.in","r",stdin);
//    freopen("output.out","w",stdout);
	n=read();
	scanf("%s",a+1);
	for(int i=1;i<=n;i++)
	{
		if(a[i]!=a[i-1]) sum++;
	}
	printf("%d",sum);
    return 0;
}


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

const long double PI = acos(-1);
 
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return a * b / gcd(a, b); }

int main(){
    ll a, b, k;
    cin >> a >> b >> k;

    if (a > k){
        a -= k;
    }else{
        k -= a;
        a = 0;
        if(b > k){
            b -= k;
        }else{
            b = 0;
        }
    }


    cout << a << " " << b << endl;
    return 0;
}

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

using namespace std;

int n, m, s;

array<array<array<int, 3001>, 2001>,2>memo;


int main()
{
	for (;;)
	{
		scanf("%d %d %d",&n,&m,&s);
		if (n == 0)break;
		for (int i = 0; i <= n*n; ++i)
		{
			for (int j = 0; j <= m; ++j)
			{
				for (int k = 0; k <= s; ++k)
				{
					int ans = 0;
					if (i == 0)
					{
						if (j == 0 && k == 0)ans = 1;
						else ans = 0;
					}
					else
					{
						if (j <= 0 || k < j)
						{
							ans = 0;
						}
						else
						{
							ans = memo[(i - 1) % 2 ][j - 1][k - j] + memo[i % 2][j - 1][k - 1];
						}
					}
					memo[i % 2][j][k] = ans % 100000;
				}
			}
		}
		int ans = 0;
		for (int i = 0; i <= m; ++i)
		{
			ans += memo[(n*n) % 2][i][s];
			ans %= 100000;
		}
		printf("%d\n", ans);
	}
	return 0;
}

Measured memory_bytes: 49564
p = 10**9+7
N,K = map(int,input().split())
A = list(map(int,input().split()))
cnt_in = 0
for i in range(N-1):
    for j in range(i+1,N):
        if A[i]>A[j]:
            cnt_in += 1
A = A+A
cnt_out=0
for i in range(2*N-1):
    for j in range(i+1,2*N):
        if A[i]>A[j]:
            cnt_out += 1
cnt_out = cnt_out-2*cnt_in
cnt = K*cnt_in
cnt = (cnt+cnt_out*(K*(K-1))//2)%p
print(cnt)

Measured memory_bytes: 68200
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define ld double
#define ll long long
#define all(x) x.begin(),x.end()
const int mod=1e9+7;
#define fi first
#define se second
#define sync  ios_base::sync_with_stdio(false);cin.tie(NULL);
#define inf (ll)1e16

const ld pi=(4.0*atan(1));
ll n;
vector<pair<ll,ll>> v;

ll po(ll x,ll y,ll md=mod){
    ll res=1;
    x%=md;
    
    while(y>0){
        if (y&1){
            res=(res*x)%md;
        }
        
        y>>=1;
        x=(x*x)%md;
    }
    return res;
}
void solve(){
   ll n,m,x;
   cin>>n>>m>>x;
   
   vector<ll> cost(n);
   vector<vector<ll>> arr(n,vector<ll>(m));
   for (ll i=0;i<n;i++){
       cin>>cost[i];
       for (ll j=0;j<m;j++){
           cin>>arr[i][j];
       }
   }
   
   bool flag=false;
   ll cnt=inf;
   
   for (ll i=0;i<(1ll<<n);i++){
       ll msk=i;
       bitset<15> bi(msk);
       vector<ll> algo(m,0);
       ll val=0;
       for (int bt=0;bt<n;bt++){
           if (bi[bt]){
               for (ll j=0;j<m;j++){
                   algo[j]+=arr[bt][j];
               }
               val+=cost[bt];
           }
       }
       ll ech=0;
       for (ll j=0;j<m;j++){
           if (algo[j]>=x)
           ech++;
       }
       if (ech==m){
           flag=true;
           cnt=min(cnt,val);
       }
   }
   if (flag)
   cout<<cnt<<"\n";
   else
   cout<<"-1\n";
}

int main() {
    
    sync
    ll tt=1;
    //cin>>tt;
    cout<<fixed<<setprecision(12);
    for (ll tc=1;tc<=tt;tc++){
       solve();
    }
    
	return 0;
}

Measured memory_bytes: 3672
import sys,itertools
input = sys.stdin.readline


n,m,q = map(int,input().split())
seq = list(range(n+m-1))
p = list(itertools.combinations(seq,n))

a = [0]*q
b = [0]*q
c = [0]*q
d = [0]*q

for i in range(q):
    a[i],b[i],c[i],d[i] = map(int,input().split())

#print(p)

res = 0
for i in range(len(p)):
    t = [0]*n
    pp = sorted(p[i])
    idx = 0
    for e in pp:
        t[idx] = 1+e-idx
        idx += 1
    
    tmp = 0
    for j in range(q):
        if t[b[j]-1] - t[a[j]-1] == c[j]:
            tmp += d[j]
    
    res = max(res,tmp)

print(res)



Measured memory_bytes: 87704
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <cmath>

#define rep(x,to) for(x=0;x<to;x++)
#define rep2(x,from,to) for(x=from;x<to;x++)

using namespace std;
int main(void){

int ho,ka;
char mz;
double x=0,y=0,oka;
double pi=3.141519;
	oka=0;
	while(cin >> ho >>mz >> ka){
		if(ho == 0 && ka == 0) break;
		x += sin(oka*pi/180) * ho;
		y += cos(oka*pi/180) * ho;
		oka += ka;
	}
	cout << (int)x <<endl;
	cout << (int)y <<endl;
	
	return 0;
}

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

int main () {
  string a , b ;
  a = "CODEFESTIVAL2016" ;
  cin >> b ;
  int answer = 0 ;
  
  for ( int i = 0 ; i < 16 ; i ++ ) {
    if(a.at(i) != b.at(i)) answer++ ;
  }
  cout << answer << endl ;
}


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

int main(void){
	ll k, a, b;
	cin >> k >> a >> b;
	if(a - b >= -2 || k - 1 < a){
		cout << k + 1 << endl;
		return 0;
	}
	k -= a - 1;
	ll ans = (b - a) * (k / 2) + a;
	if(k % 2 == 1) ans++;
	cout << ans << endl;
	return 0;
}

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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
typedef long long ll;


int main() {
    string S; cin >> S;
    int K; cin >> K;

    int N = S.size();
    set<string> dic;

    REP(n,K){
        REP(i,N-n){
            string s;
            REP(j,n+1){
                s.push_back(S[i+j]);
            }
            dic.insert(s);
        }
    }


    auto itr = dic.begin();
    REP(i,K-1) itr++;

    cout << *itr << endl;

    return 0;
}

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

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(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 SORT(c) sort((c).begin(),(c).end())
#define INF 999999999
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int main()
{
	int n,m,input,output;
	vector<int> a;
	cin >> n;
	REP(i,n) {
		cin >> input;
		a.push_back(input);
	}
  	output = 0;
	REP(i,n) {
		output += a[i]-1 % a[i];
	}
	cout << output << endl;
	return 0;
}

Measured memory_bytes: 256
from collections import Counter

N,K = map(int,input().split())
A = list(map(int,input().split()))
total = 0

C = Counter(A)

for i,c in enumerate(sorted(C.items(), key=lambda x: -x[1])):
	total += c[1]
	if i == K-1:
		break
print(N-total)

Measured memory_bytes: 39320
while True:
    m, f, r = map(int,input().split())
    
    if m == -1 and f == -1 and r ==-1:
        break
    if m == -1 or f == -1:
        print('F')    
    elif m+f >= 80:
        print('A')
    
    elif m+f >= 65:
        print('B')
    
    elif m+f >= 50:
        print('C')
    
    elif m+f >= 30:
        if r >= 50:
            print('C')
        else:
            print('D')
    
    elif m+f < 30:
        print('F')
    

        



Measured memory_bytes: 5596