akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define Rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef int64_t intl;


intl modpow(intl a, intl n, intl p){
  intl res = 1;
  while (n > 0){
    if (n&1){res = (res * a) % p;}
	a = (a * a) % p;
    n >>= 1;
  }
  return res;
}

intl modinv(intl a, intl p){
  if (a==0){
    cout << "/0 at modinv"<<endl;
    exit(0);
  }
  if (a < 0){
    cout << "/- at modinv" <<endl;
    exit(0);
  }
  if (a==1){return 1;}
  if (a > p){return modinv(a%p, p);}

  return p - ( modinv(p%a,p) * (p/a) ) % p;
}

intl modcomb(intl n, intl k, intl p){
  if (k > n || k < 0 || n < 0){
    cout << "error at modcomb"<<endl;
    exit(0);
  }
  if (2*k > n){ k = n-k;}
  if (k ==0){return 1;}
  intl c=1;
  for (intl i = 0; i < k; i++){
    c =( c * ( (n-i) % p ) % p ) * modinv(i+1,p) % p;
  }
  return c;
}

int main(){
  intl N;
  intl RN=0;
  intl GN=0;
  intl BN = 0;
  cin >> N;
  vector <char> RGB (N);
  if (N < 3){cout << 0; return 0;}
  Rep(i,N){
    cin >> RGB.at(i);
    if (RGB.at(i) == 'R'){RN++;}
    if (RGB.at(i) == 'G'){GN++;}
    if (RGB.at(i) == 'B'){BN++;}
  }
  intl count = 0;
  Rep(d, (N-1)/2){
    for( int j=0 ; j + 2*(d+1) < N;  j ++){
      if (  !(  RGB.at(j) == RGB.at(j+d+1)  ||  RGB.at(j) == RGB.at(j+(d+1)*2)  || RGB.at(j+d+1) == RGB.at(j+(d+1)*2)  )){
        count ++;
      }
    }
  }
  cout << RN*BN*GN -count;
}
              
                                                                                                                

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  int n;
  cin >> n;
  int k[n];
  rep(i,n)cin >> k[i];
  priority_queue<int, vector<int>, less<int>> q;
  rep(i,n)q.push(k[i]);
  int m=q.top();
  q.pop();
  int s=q.top();
  rep(i,n){
    if(k[i]!=m)cout << m << endl;
    else cout << s << endl;
  }
}  


Measured memory_bytes: 3316
#include <iostream>
#include <iomanip>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
#include <numeric>
#include <queue>
#include <sstream>
#include <bitset>
#include<stack>

using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;

template<typename T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }

template<typename T>
map<T, T> getPrimeFactor(T n) {
	map<T, T> res;
	for (T i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			res[i] ++;
			n /= i;
		}
	}
	if (n != 1) res[n] = 1;
	return res;
}

template<typename T>
bool IsPrimeNumber(T num)
{
	if (num <= 2) return true;
	else if (num % 2 == 0) return false;

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	return true;
}

long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

#define rep(i,s,e) for(ll i=s;i<e;i++)
#define repeq(i,s,e) for(ll i=s;i<=e;i++)


int main() {
	ll N;
	std::cin >> N;

	for (ll h = 1; h <= 3500; h++) {
		for (ll n = 1; n <= 3500; n++) {

			if (4 * h * n - N * n - h * N > 0 && (N * h * n) % (4 * h * n - N * n - h * N) == 0) {
				ll w = (N * h * n) / (4 * h * n - N * n - N * h);
				std::cout << h << " " << n << " " << w << endl;
				return 0;
			
			}
				
			

		}
	}
	return 0;
}


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

using namespace __gnu_pbds;
using namespace std;

#define inf 1013161010
#define ninf -1013161010
#define mod 1000000007
#define ll long long
#define lf long double
#define in(x) scanf("%d",&x);
#define sz(x) ((int)x.size())
#define lld l64d
#define rep(i,n) for(i=0;i<n;i++)
#define rrep(i,n) for(i=n-1;i>=0;i--)
#define rep1(i,a,b) for(i=a;i<=b;i++)
#define rrep1(i,a,b) for(i=a;i>=b;i--)
#define stlfor(i,t) for(auto i =t.begin();i!=t.end();i++)
#define fr freopen("x.txt","r",stdin)
#define frc freopen("y.txt","w",stdout)
#define all(x) x.begin(),x.end()
#define set0(x) memset(x,0,sizeof(x))
#define dbg cout<<"yo "<<endl;
#define pset(n) fixed<<showpoint<<setprecision(n)

#define pii pair<int,int>
#define pll pair<ll,ll>
#define min_pq priority_queue<pll, vector<pll>, greater<pll> >
#define vpii vector<pair<int,int> >
#define vll vector<ll>
#define vpll vector<pair<ll,ll> >
#define si set<int>
#define mii map<int,int>
#define umii unordered_map<int,int>
#define vi vector<int>
#define pb push_back
#define ff first
#define ss second
#define mp make_pair
#define modulo %
#define moduloe %=

typedef tree<pii,null_type,less<pii>,rb_tree_tag,tree_order_statistics_node_update> OST;

ll toint(const string &s) { stringstream ss; ss << s; ll x; ss >> x; return x; }
ll add(ll a, ll b) {a+=b; while(a >= mod) a-= mod; while(a<0) a+= mod;}
ll mul(ll a, ll b) {return (a * 1LL *b % mod);}
string tostring ( ll number ){  stringstream ss; ss<< number; return ss.str();}

const lf pi = 2*acos(0);
const int nn = 500006;
const lf EPS = 0.000000001;

ll gcd(ll a,ll b){return (b==0)? a:gcd(b,a%b); }
void nope(int num = 0){ if(num==0) cout<<"NO"; else cout<<"-1"; exit(0); }

ll a[3010], dp[3010][3010];
ll r(ll x, ll y, ll turn)
{

    if(dp[x][y] != -1)
        return dp[x][y];
    if(x == y)
    {
        if(turn == 0)
            return a[x];
        else
            return -a[x];
    }

    if(turn == 0)
    {
        dp[x][y] = max( r(x+1, y, 1-turn) + a[x], r(x, y-1, 1-turn) + a[y]);
    }
    else
    {
        dp[x][y] = min(r(x+1, y, 1-turn) - a[x], r(x, y-1, 1-turn) - a[y]);
    }
    return dp[x][y];
}

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(0);
    ll i,j,n,tt;
    tt=1;
    //cin>>tt;
    while(tt--)
    {
        memset(dp, -1, sizeof(dp));
        cin>>n;
        rep(i, n)
            cin>>a[i];

        cout<<r(0, n-1, 0)<<endl;


    }
    return 0;
}

// read the question correctly (is y a vowel? what are the exact constraints?)
// look out for SPECIAL CASES (n=1?) and overflow (ll vs int?)


Measured memory_bytes: 71296
// https://atcoder.jp/contests/abc074/tasks/arc083_b
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()

int main() {
    int n;
    cin >> n;
    vector<vector<int>> d(n, vector<int>(n));
    vector<vector<bool>> b(n, vector<bool>(n));

    REP(i, n) REP(j, n) cin >> d[i][j];
    REP(i, n) REP(j, n) REP(k, n) {
        if (k == i || k == j)
            continue;
        // 3辺の一番長い辺が、それ以外の辺の合計より大きければ不成立
        if (d[i][j] > d[i][k] + d[k][j]) {
            cout << "-1\n";
            return 0;
        }
        // 等しければ辺を作らない
        if (d[i][j] == d[i][k] + d[k][j]) {
            b[i][j] = true;
        }
    }
    ll ans = 0;
    REP(i, n) FOR(j, i + 1, n) {
        if (!b[i][j]) {
            ans += d[i][j];
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 640
#include <stdio.h>

int main() {

long long int n;
long long int t;
scanf("%lld", &t);

long long int num[t];
long long int sum = 1;

for(long long int i = 0; i<t; i++){
	scanf("%lld", &n);
	num[i] = n;
}

for(long long int i = 0; i<t; i++){
	if(num[i]==0){
		printf("0\n");
		return 0;
	}
}

for(long long int i = 0; i<t; i++){
	if(num[i]<=1000000000000000000/sum){
	sum *= num[i];
	}
	else{ 
	printf("-1\n");
	return 0;
	}	
}

printf("%lld\n", sum);

    return 0;
}


Measured memory_bytes: 3848
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define rng(a) a.begin(),a.end()
using namespace std;
using ll = long long;
using P = pair<int,int>;


int main() {
  int n;
  cin >> n;
  int r[n+1], w[n+1];
  r[0] = 0;
  w[0] = 0;
  rep(i,n) {
    char c;
    cin >> c;
    r[i+1] = r[i];
    w[i+1] = w[i];
    if(c=='R') r[i+1]++;
    else w[i+1]++; 
  }
  int ans = 1001001001;
  rep(i,n) {
    int W = w[i];
    int R = r[n]-r[i+1];
    ans = min(ans,max(W,R));
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 5168
#include <stdio.h>

int main() {
	
  int n,q , i ,j,c=0 , lef,rig,mid ,k;

  scanf("%d",&n);
	
  int s[n];

  for ( i=0; i < n; i++){
    scanf("%d",&s[i]);

  }
  scanf("%d",&q);
	
  int t[q];

  for ( i=0; i < q; i++){
    scanf("%d",&t[i]);

  }

  for ( i=0; i < q; i++){
    k= t[i];
    lef = 0;
    rig = n;
    while ( lef < rig){
      mid = (lef + rig)/ 2;

      if ( s[mid] == k){c++;break;}
      else if ( s[mid] < k){ lef = mid +1;continue;}
      else if ( s[mid] > k){ rig = mid;continue;}
    }
  }
  printf("%d\n",c);	
	
  return 0;
}



Measured memory_bytes: 2280
// Aizu 2198: Moonlight Farm
// 2017.9.21 bal4u@uu

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>

#define EPS 1e-7

typedef struct { char nm[23]; double p; } T;
T tbl[53];

int cmp(T *a, T *b) {
	if (fabs(b->p - a->p) <= EPS) return strcmp(a->nm, b->nm);
	if (a->p <= b->p) return 1; else return -1;
}

int main()
{
	int n, i, p, a, b, c, d, e, f, s, m;
	int t, x;

	while (scanf("%d", &n) && n) {
		for (i = 0; i < n; i++) {
			scanf("%s%d%d%d%d%d%d%d%d%d", tbl[i].nm, &p, &a, &b, &c, &d, &e, &f, &s, &m);
			t = (a+b+c) +(d+e)*m;
			x = f*s*m - p;
			tbl[i].p = (double)x / (double)t;
		}
		qsort(tbl, n, sizeof(T), cmp);
		for (i = 0; i < n; i++) puts(tbl[i].nm);
		puts("#");
	}
	return 0;
}

Measured memory_bytes: 1752
#include <bits/stdc++.h>
using namespace std;
int main(){
  string a,b;
  cin>>a>>b;
  for(int i=0;i<b.size();i++){
    cout<<a.at(i)<<b.at(i);
  }
  if(a.size()>b.size())
    cout<<a.at(a.size()-1);
}

Measured memory_bytes: 256
input()
r=list(map(int,input().split()))[::-1]

#print(r)

temp=r[0]
flag=0
for item in r:
  if temp>=item:
    temp=item
  elif temp>=item-1:
    temp=item-1
  else:
    flag=1
    break
    
print("Yes" if flag==0 else "No")
    

Measured memory_bytes: 15020
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = 1<<30;

string s;
int main(){
  int n, a, b, c, d;cin>>n>>a>>b>>c>>d;
  a--;b--;c--;d--;
  cin>>s;
  bool pre=false, ans=true;
  for(int i=a;i<=c;i++){
  	char c=s[i];
    if(c=='#'&&pre){ans=false;break;}
    else if(c=='#')pre=true;
    else pre=false;
  }
  if(!ans){cout<<"No"<<endl;return 0;}
  pre=false;
  for(int i=b;i<=d;i++){
  	char c=s[i];
    if(c=='#'&&pre){ans=false;break;}
    else if(c=='#')pre=true;
    else pre=false;
  }
  if(!ans){cout<<"No"<<endl;return 0;}
  if(c>d){
    if(s[d-1]=='#'||s[d+1]=='#'){ // snuke must go first
      bool s_jump=!(s[b-1]=='#'||s[b+1]=='#');
      if(!s_jump){
        int count=1;
        for(int i=b+1;i<=d;i++){
          if(s[i]=='#')count=0;
          else count++;
          if(count>=3){s_jump=true;break;}
        }
        if(!s_jump)ans=false;
      }
    }
  }
  cout<<(ans?"Yes":"No")<<endl;
}


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

#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i,n) for(int i = 0; i < n; i++)
#define for1(i,n) for(int i = 1; i <= n; i++)
#define ford(i,n) for(int i = n-1; i >= 0; i--)
#define fore(i,a,b) for(int i = a; i <= b; i++)

using namespace std;

typedef long long ll;
typedef double ld;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<ll> vll;


const  int MAXn= 3e5+5;
const  long long INF= 1e18;
const long long mod= 1e9+7;

int solve(int arr[], int n) 
{ 
    multiset<int> last; 
  
    // last element in each  increasing subsequence  
    // found so far 
    for (int i = 0; i < n; i++) { 
  
        // here our current element is arr[i] 
        multiset<int>::iterator it = last.lower_bound(arr[i]); 
  
        // iterator to the first element larger  
        // than or equal to arr[i] 
        if (it == last.begin()) 
  
            // if all the elements in last larger 
            // than or to arr[i] then insert it into last 
            last.insert(arr[i]); 
  
        else { 
            it--; 
  
            // the largest element smaller than arr[i] is the number 
            // before *it which is it-- 
            last.erase(it); // erase the largest element smaller than arr[i] 
            last.insert(arr[i]); // and replace it with arr[i] 
        } 
    } 
    return last.size(); // our answer is the size of last 
} 

int main(){
	int n;
	cin>>n;
	int arr[n];
	forn(i,n) cin>>arr[i];
	cout<<solve(arr,n);
}
	


Measured memory_bytes: 5376
def main():
  a, b, c, d = list(map(int, input().split()))
  
  count1 = 0
  count2 = 0
  
  while c > 0:
    c -= b
    count1 += 1
    
  while a > 0:
    a -= d
    count2 += 1
    
  if count1 <= count2:
    print('Yes')
  else:
    print('No')
    
  
main()

Measured memory_bytes: 9100
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"

using namespace std;

const long long int MOD = 1000000007;
//const int MOD = 1000000007;
//const int MOD = 998244353;

long long int N, M, K, H, W, L, R;
//int N, M, K, H, W, L, R;




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

	int a, b, c, d, e;
	cin >> a >> b >> c >> d >> e >> K;
	if (e - a <= K) {
		cout << "Yay!\n";
	}
	else cout << ":(\n";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <math.h>

using namespace std;

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

    if ((A + B) % 2 == 0){
        cout << abs((A + B) / 2) << endl;
    }
    else{
        cout << "IMPOSSIBLE" << endl;
    }
}


Measured memory_bytes: 256
import java.io.*;

class Main{
public static void main(String[] args) throws IOException{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
String line="";
int[] ball={1,0,0};
while((line=br.readLine())!=null){
char[] c=line.toCharArray();
reverse(c[0],c[2],ball);
}
for(int i=0;i<ball.length;i++){
if(ball[i]==1){
switch(i){
case 0:System.out.println("A");
       break;
case 1:System.out.println("B");
       break;
case 2:System.out.println("C");
       break;
}
break;
}
}
}
private static void reverse(char c1,char c2,final int[] ball){
int a=ball[c1-'A'];
ball[c1-'A']=ball[c2-'A'];
ball[c2-'A']=a;
}
}

Measured memory_bytes: 16860
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
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; }

const int mod=1e9+7;
const int INF=1001001001;

const int M=1e6+5;
int main() {
  int N;
  cin>>N;
  vector<int>h(N);
  for(int i=0;i<N;i++){
    cin>>h[i];
  }
  vector<int>dp(N,INF);
  dp[0]=0;
  for(int i=0;i<N;i++){
    if(i<N-1){chmin(dp[i+1],dp[i]+abs(h[i+1]-h[i]));}
    if(i<N-2){chmin(dp[i+2],dp[i]+abs(h[i+2]-h[i]));}
  }
  cout<<dp[N-1]<<endl;
  return 0;  
}

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

#define REP(i,init, n) for(lli i=init;i<n;i++)
#define REPE(i,init, n) for(lli i=init;i<=n;i++)
#define REPIT(it,container) for(auto it = container.begin(); it != container.end(); it++)
#define REPIT_R(it,container) for(auto it = container.rbegin(); it != container.rend(); it++)

#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

typedef long long int lli;
typedef pair<lli, lli> P;


lli comb(lli p, lli a) {
    lli q = min(a, p-a);

    // pCq を返す。
    //cout <<"q: " <<  q << endl;
    vector <vector<lli> > v(p+1,vector<lli>(p+1,0));


    for(lli i = 0;i <v.size(); i++){
        v[i][0]=1;
        v[i][i]=1;
    }
    for(lli k = 1;k <v.size();k++){
        for(lli j = 1;j<32;j++){
            v[k][j]=(v[k-1][j-1]+v[k-1][j]) % 1000000007;
        }
    }

    return v[p][q] % 1000000007;
}

lli comb_table[4002][4002];

void cal() {
    for (int i = 0; i < 4002; i++)
        comb_table[i][0] = 1;

    for (int j = 0; j < 4002; j++)
        comb_table[j][j] = 1;


    for (int i = 2; i < 4002; ++i) {
        for (int j = 1; j < 4002 and j < i; ++j) {
            comb_table[i][j] = ( comb_table[ i-1 ][j] + comb_table[ i-1 ][ j-1 ] ) % 1000000007;
        }
    }
    return;
}

int main() {
    lli n, k;
    cin >> n >> k;
    cal();
    REP(i, 0, k) {
        if (i == 0)
            cout << n - k + 1 << endl;
        else {
            // i: 1 のとき、k は2つ、すきまは2C1、残りは左右 => 2C1 * (n-(k+i)) + 1
            lli ans;
            lli a = comb_table[k-1][i];
            lli b = comb_table[(i+1+n-k-i)][n-k-i];
            ans = a * b % 1000000007;
            //cout << "a: " << a;
            //cout << ", b: " << b << endl;
            //ans = comb_table[k-1][i] * (i+k-1);
            //cout << "comb: " << comb_table[k-1][i];
            //cout << ", (n-(k+i) + 1): " << (i+k-1) << endl;
            cout << ans << endl;

        }

    }
}


Measured memory_bytes: 123648
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define endl "\n"
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
#define fi first
#define se second
typedef long long lint;
int dx[8]={1,1,0,-1,-1,-1,0,1};
int dy[8]={0,1,1,1,0,-1,-1,-1};

int main(void){
    lint X,Y,A,B,C;
    cin >> X >> Y >> A >> B >> C;
    lint p[A],q[B],r[C];
    rep(i,A) cin >> p[i];
    rep(i,B) cin >> q[i];
    rep(i,C) cin >> r[i];
    sort(p,p+A,greater<lint>());
    sort(q,q+B,greater<lint>());
    sort(r,r+C),greater<lint>();
    multiset<lint> red,green,white;
    rep(i,X) red.insert(p[i]);
    rep(i,Y) green.insert(q[i]);
    rep(i,C){
        auto re=red.begin(),gr=green.begin();
        lint rdis=r[i]-*re,gdis=r[i]-*gr;
        if(rdis<=0 && gdis<=0) continue;
        if(rdis>gdis){
            red.erase(re);
            red.insert(r[i]);
        }
        else{
            green.erase(gr);
            green.insert(r[i]);
        }
    } 
    lint ans=0;
    while(!red.empty()){
        auto itr=red.begin();
        ans+=*itr;
        red.erase(itr);
    }
    while(!green.empty()){
        auto itr=green.begin();
        ans+=*itr;
        green.erase(itr);
    }
    cout << ans << endl;
}

Measured memory_bytes: 11008
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
    int n;
    string s;
    cin >> n >> s;
    int r = 0, w = 0;
    rep(i,n) if (s[i] == 'R') ++r;
    int ans = max(r,w);
    rep(i,n) {
        if (s[i] == 'R') --r;
        else ++w;
        int now = max(r,w);
        ans = min(ans,now);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3692
#include<bits/stdc++.h>
using namespace std;
#define int long
signed main(){
    int a, b, k;
    cin >> a >> b >> k;
    if(a<k){
        k -= a;
        a = 0;
    }
    else{
        a -= k;
        k = 0;
    }
    b -= k;
    cout << a << " " << max(b,0l);
}

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

void swap(int *x, int *y){
    int tmp;
    tmp = *x;
    *x = *y;
    *y = tmp;
}

int euclid(int small, int big){
    int res = 0;
    if(small > big) swap(&small,&big);

    while(true){
        res = big%small;
        if(res == 0) return small; 
        big = small;
        small = res;
    }
    return 0;
}

int main(){
    int x;
    cin >> x;
    long long sm=0;
    for(int i=1; i<=x; i++){
        for(int j=1; j<=x; j++){
            for(int k=1; k<=x; k++){
                sm = sm + euclid(euclid(i,j),k);
            }
        }
    }
    cout << sm << endl;
    return 0;
}

Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n, m; cin >> n >> m;
  for(int i = 1; i <= n; i++){
    for(int j = 1; j <= m; j++){
      string s; cin >> s;
      if(s == "snuke"){
      	cout << char('A'+j-1) << i << endl;
        return 0;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
#define rep(i, N) for(int i=0; i<N; ++i)
using ul = unsigned long;
using ll = long long;

int main() {
    int N;
    string s, t;
    cin >> N;
    cin >> s >> t;
    rep(i, N) {
        cout << s[i] << t[i];
    }
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
using namespace std;
static const int INFTY = (1 << 21);

int n, m[100][100];

int prim() {
    int u, minv;
    int d[100], p[100], color[100];
    
    for (int i = 0; i < n; i++) {
        d[i] = INFTY;
        p[i] = -1;
        color[i] = 0;
    }
    
    d[0] = 0;
    
    while(1) {
        minv = INFTY;
        u = -1;
        for (int i = 0; i < n; i++) {
            if (minv > d[i] && color[i] != 2) {
                u = i;
                minv = d[i];
            }
        }
        if (u == -1) break;
        color[u] = 2;
        for (int v = 0; v < n; v++) {
            if (color[v] != 2 && m[v][u] != INFTY) {
                if (d[v] > m[u][v]) {
                    d[v] = m[u][v];
                    p[v] = u;
                    color[v] = 1;
                }
            }
        }
    }
    int sum = 0;
    for (int i = 0; i < n; i++) {
        if(p[i] != -1) sum += m[i][p[i]];
    }
    
    return sum;
}
    
int main() {
    cin >> n;
    
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            int e;
            cin >> e;
            if (e == -1) {
                m[i][j] = INFTY;
            } else {
                m[i][j] = e;
            }
        }
    }
    
    cout << prim() << endl;
    
    return 0;
}


Measured memory_bytes: 3132
import java.io.*;
import java.util.*;

public class Main{
	static class FastReader{
		BufferedReader br;
		StringTokenizer st;
		public FastReader(){
			br = new BufferedReader(new InputStreamReader(System.in));
		}
		public String next(){
			try{
				while(st==null||!st.hasMoreElements()){
					st = new StringTokenizer(br.readLine());
				}
			}catch(Exception e){
				e.printStackTrace();
			}
			return st.nextToken();

		}
		public int nextInt(){
			return Integer.parseInt(next());
		}
		public long nextLong(){
			return Long.parseLong(next());
		}
		public double nextDouble(){
			return Double.parseDouble(next());
		}
		public String nextLine(){
			String s = "";
			try{
				s = br.readLine();
			}catch(Exception e){
				e.printStackTrace();
			}	
			return s;		
		}
	} 
	static ArrayList<Node> nodes = new ArrayList<>();
	static int count = 0;
	static int n;
	static class Node{
		ArrayList<Node> adj = new ArrayList<>();
		int i;
		Node(int i ){
			this.i = i;
		}
		
	}
	static void dfs(int src,boolean[] visited,int size){
		if(size==n)count++;
		for(Node adj :nodes.get(src).adj){
			if(!visited[adj.i]){
				visited[adj.i] = true;
				dfs(adj.i,visited,size+1);
				visited[adj.i] = false;
			}
		} 
	}
	public static void main(String[] args){
		FastReader in = new FastReader();
		PrintWriter out = new PrintWriter(System.out);
		n = in.nextInt();
		int m = in.nextInt();
		for(int i = 0 ; i < n; i++)nodes.add(new Node(i));
		for(int i = 0 ; i<m;i++){
			int v1 = in.nextInt()-1;
			int v2 = in.nextInt()-1;
			nodes.get(v1).adj.add(nodes.get(v2));
			nodes.get(v2).adj.add(nodes.get(v1));

		}
		int size = 1;
		boolean visited[] = new boolean[n];
		visited[0] = true;
		dfs(0,visited,size);
		out.println(count);
		out.flush();
		out.close();  
	}

}





Measured memory_bytes: 23380
/* 0013.c */
#include<stdio.h>
 
 
int main(void)
{
    int num, top;
    int train[1024];
    int i;
 
    top = 0;
 
    while (scanf("%d", &num) != EOF){
        if (num == 0){
            printf("%d\n", train[top - 1]);
            train[top - 1] = 0;
            top--;
        }
        else { 
            train[top] = num;
            top++;
        }
    }
 
    return 0;
}

Measured memory_bytes: 1032
n,m,c=gets.split.map(&:to_i)
b=gets.split.map(&:to_i)
count=0

n.times do
    a=gets.split.map(&:to_i)
    jdg=0
    a.zip(b).each {|i,j| jdg+=i*j}
    count+=1 if jdg+c > 0
end

p count


Measured memory_bytes: 1788
a,b = gets.split.map(&:to_i)
m = 0
n = 300000
ar = []
br = []
for num in 1..b do
  c,d = gets.split.map(&:to_i)
  if c == 1
     m = d
    ar << m
  end  
  if d == a
     n = c
    br << n
  end   
end  
if ar & br ==[]
  puts "IMPOSSIBLE"
else
  puts "POSSIBLE"
end

Measured memory_bytes: 9864
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main(){
    int s;
    cin >> s;
    int a = s / 100;
    int b = s % 100;
    if (1<=a && a<=12){
        if (1<=b && b<=12) cout << "AMBIGUOUS" << endl;
        else cout << "MMYY" << endl;
    }
    else {
        if (1<=b && b<=12) cout << "YYMM" << endl;
        else cout << "NA" << endl;
    }
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
using uint = unsigned int;
using lint = long long int;
using ulint = unsigned long long int;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T, class U> void assign(V<T>& v, int n, const U& a) { v.assign(n, a); }
template<class T, class... Args> void assign(V<T>& v, int n, const Args&... args) { v.resize(n); for (auto&& e : v) assign(e, args...); }


int main() {
  cin.tie(nullptr); ios_base::sync_with_stdio(false);
  int n; cin >> n;
  V<> a(n), b(n), c(n); for (int i = 0; i < n; ++i) cin >> a[i] >> b[i] >> c[i];
  V<> dpa(n + 1), dpb(n + 1), dpc(n + 1);
  for (int i = 0; i < n; ++i) {
    dpa[i + 1] = max(dpb[i], dpc[i]) + a[i];
    dpb[i + 1] = max(dpa[i], dpc[i]) + b[i];
    dpc[i + 1] = max(dpa[i], dpb[i]) + c[i];
  }
  cout << max({dpa[n], dpb[n], dpc[n]}) << '\n';
}

Measured memory_bytes: 2560
#include<iostream>
#include<string>

using namespace std;

int main(){
    int n, cnt = 0;
    string s;
    cin >> n >> s;
    for(int i=0;i<n-2;i++){
        if(s.substr(i, 3) == "ABC")cnt++;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<list>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<set>
#include<map>
#include<queue>
#include<cstring>
#include<sstream>
using namespace std;

typedef long long ll;

int main() {
  string s; cin >> s;
  int cnt = 0;
  for ( int i = 0; i < s.length()-1; i++ ) {
    if ( s[i] != s[i+1] ) cnt++;
  }
  cout << cnt << endl;
  return 0;
}


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

typedef long long ll;
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define debug(x) cerr << #x << ": " << x << '\n'

int main()
{
    ll A, B, K;
    cin >> A >> B >> K;
    ll Aorg = A;
    A = A - K;
    if (A < 0)
    {
        A = 0;
    }
    if ((K - A) < 0)
    {
        cout << A << " " << B << endl;
        return 0;
    }
    B = B - (K - Aorg);
    if (B < 0)
    {
        B = 0;
        cout << A << " " << B << endl;
        return 0;
    }
    cout << A << " " << B << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>    
#include<cmath>
#include<map>
#include<vector>
#include<math.h>
#include<stdio.h>
#define int long long
using namespace std;
int test[123][123];
signed main() {
	int n, a = 0, ans = 0; string s; cin >> n >> s;
	for (int h = 0; h < n; h++) {
		if (s[h] == 'A') {
			a = 1;
		}
		else if (a == 1) {
			if (s[h] == 'B') { a++; }
			else { a = 0; }
		}
		else if (a == 2) {
			if (s[h] == 'C') { a = 0; ans++; }
			else { a = 0; }
		}
	}
	cout << ans << endl;
}

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


int main() {
  int n;
  cin>>n;
  if(n%10==2||n%10==4||n%10==5||n%10==7||n%10==9)
    cout<<"hon"<<endl;
  if(n%10==0||n%10==1||n%10==6||n%10==8)
    cout<<"pon"<<endl;
  if(n%10==3)
    cout<<"bon"<<endl;
  
 
}

Measured memory_bytes: 3592
/** 
 * Dont raise your voice, improve your argument.
 * --Desmond Tutu
 */

#include <bits/stdc++.h>
using namespace std;

#define DEBUG
#ifndef DEBUG
#define endl "\n"
#endif

const double PI=3.1415926535897932384626433;
typedef long long ll;
#define fori(n) for(ll i=0; i<(n); i++)

#define cins(s) string s; cin>>s;
#define cini(i) int i; cin>>i;
#define cinll(l) ll l; cin>>l;
#define cind(d) double d; cin>>d;
#define cinai(a, n) vi a(n); fori(n) { cin>>a[i]; }
#define cinall(a, n) vll a(n); fori(n) { cin>>a[i]; }
#define cinas(s, n) vs s(n); fori(n) { cin>>s[i]; }

typedef pair<int, int> pii;
typedef pair<double,double> pdd;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<string> vs;
typedef vector<ll> vll;

void solve() {
    cini(n);
    int x1=n*100;
    x1/=108;
    int x2=x1-1;
    int x3=x1+1;
    if(x1*108/100==n)
        cout<<x1<<endl;
    else if(x2*108/100==n)
        cout<<x2<<endl;
    else if(x3*108/100==n)
        cout<<x3<<endl;
    else
        cout<<":("<<endl;
    
}

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



Measured memory_bytes: 256
//#include<bits/stdc++.h>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<stdlib.h>
#include<queue>
#include<map>
#include<vector>
#include<cmath>
#include<fstream>
#include <set>
//freopen(".in","r",stdin);
//freopen(".out","w",stdout);
//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);
const int  MAXN =2e5+10;
const int mod = 1e9 + 7;
const long long INF = 0x7f7f7f7f7f7f7f7f;
const int inf= 0x3f3f3f3f;
#define eps 1e-8
#define PI 3.1415926535898
#define lowbit(x) (x&(-x))
using namespace std ;
//getline(cin,s);
//set<ll>::iterator it;
//map<int,int>::iterator it;
//unordered_map
typedef long long ll;
int main()
{
	int a,b,c;
	scanf("%d %d %d",&a,&b,&c);
	if(b*c>=a) printf("Yes\n");
	else printf("No\n");
	return 0;
}

Measured memory_bytes: 3676
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e5 + 7;

bool a, b, c, d;
int main()
{
	ios::sync_with_stdio(false);

	string s;
	cin >> s;
	for (int i=0; i<(int)s.size(); i++)
		if (s[i] == 'N')
			a = 1;
		else if (s[i] == 'E')
			b = 1;
		else if (s[i] == 'W')
			c = 1;
		else
			d = 1;
	if (a == d && c == b)
		cout << "Yes\n";
	else
		cout << "No\n";
	

	return 0;
}

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

int main() {
 int N,i;
  cin >> N;
  string s;
  
  
 
  for(i=0;i<N;i++){
    cin >> s;
    
    if(s=="Y"){
      cout << "Four" << endl;
      break;
    }
    
  }
  
  if(s!="Y"){
    cout << "Three" << endl;
  }
}

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

const int MAXN = 100005;

int n;
int a[MAXN];
map<int,int> st;
set<int> del;
int q[MAXN], top = 0;

int main()
{
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) scanf("%d", &a[i]), st[a[i]]++;
	for (int i = 1; i <= n; i++)
		if (st[a[i]] >= 2 && !del.count(a[i])) q[++top] = a[i], del.insert(a[i]);
	sort(q+1, q+top+1, greater<int>());
	if (top < 2 && st[q[1]] < 4) puts("0");
	else {
		if (st[q[1]] >= 4) cout << (long long)q[1]*q[1] << endl;
		else cout <<  (long long)q[1]*q[2] << endl;
	}
	return 0;
}


Measured memory_bytes: 5376
#include<iostream>
#define _USE_MATH_DEFINES
#include<math.h>
#include<vector>
#include<array>
#include<algorithm>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<set>
#include<cstdio>
#include<cstring>
#include<string>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vector<ll>> mat;
typedef pair<ll,ll> P;
typedef map<ll,ll> MP;
typedef priority_queue<ll> PQ;
#define pb push_back
#define st first
#define nd second
#define SZ(x) ((int)(x).size())
#define FOR(i,s,n) for(int i=(int)(s); i< (int)(n); i++)
#define rep(i,n) FOR(i,0,n)
#define all(x) (x).begin(),(x).end()
#define each(x,c) for(auto x: (c))
#define LB(x,a) lower_bound(all(x), a)
#define UB(x,a) upper_bound(all(x), a)
const ll mod=1e9+7;
const ll INF=1e18;
const double EPS=1.0e-10;
const double PI=M_PI;

int main(){
    int N,K; scanf("%d %d",&N,&K);
    vec A(N),S(N+1),L(N+1),R(N+1);S[0]=L[0]=R[0]=0;
    rep(i,N){
        scanf("%lld",&A[i]);
        S[i+1]=S[i]+A[i];
        L[i+1]=L[i];
        if(A[i]>0) L[i+1]+=A[i];
    }
    rep(i,N){
        R[i+1]=R[i];
        if(A[N-1-i]>0) R[i+1]+=A[N-1-i];
    }
    ll ans=0;
    rep(i,N-K+1){
        ll x=max((ll)0,S[i+K]-S[i])+L[i]+R[N-i-K];
        ans=max(ans,x);
    }
    printf("%lld\n",ans);
    return 0;
}

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

int main() {

	int i = 0;

	int w, h;

	int nums[2][3000];

	while (true) {
		cin >> h >> w;

		if (w == 0 && h == 0) break;

		nums[0][i] = h;
		nums[1][i] = w;

		i++;
	}

	for (int j = 0; j < i; j++) {
		for (int y = 0; y < nums[0][j]; y++) {
			for (int x = 0; x < nums[1][j]; x++) {
				cout << "#";
			}
			cout << endl;
		}
		cout << endl;
	}

	return 0;
}


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

int r, g, b, angkatest;

int main (){
	cin>>r>>g>>b;
	angkatest=r*100+g*10+b;
	if (angkatest%4==0){
		cout<<"YES"<<endl;
	}else{
		cout<<"NO"<<endl;
	}
}

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

#define REP(i,m,n) for(int i=(m); i<(int)(n); i++)
#define RREP(i,m,n) for(int i=(int)((n)-1); i>=m; i--)
#define rep(i,n) REP(i,0,n)
#define rrep(i,n) RREP(i,0,n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define fi first
#define se second
#define debug(...) {cerr<<"[L"<<__LINE__<<"] "; _debug(__VA_ARGS__);}

template<typename T>
string join(const vector<T>&v, string del=", "){ stringstream s;
    for(auto x : v) s << del << x; return s.str().substr(del.size());
}
template<typename T>
ostream& operator<<(ostream& o, const vector<T>&v){
    if(v.size()) o << "[" << join(v) << "]"; return o;
}
template<typename T>
ostream& operator<<(ostream& o, const vector<vector<T> >&vv){
    int l = vv.size();
    if(l){ o<<endl; rep(i,l) o << (i==0 ? "[ " : ",\n  " ) << vv[i] << (i==l-1 ? " ]" : ""); }
    return o;
}
template<typename T1, typename T2>
ostream& operator<<(ostream& o, const pair<T1, T2>& p){
    return o << "(" << p.first << ", " << p.second << ")";
}
inline void _debug(){cerr<<endl;}
template<class First, class... Rest>
void _debug(const First& first, const Rest&... rest){cerr<<first<<" ";_debug(rest...);}

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;

const double PI = (1*acos(0.0));
const double EPS = 1e-9;
const int INF = 0x3f3f3f3f;
const ll INFL = 0x3f3f3f3f3f3f3f3fLL;
const ll mod = 1e9 + 7;

inline void finput(string filename) {
    freopen(filename.c_str(), "r", stdin);
}

int main(){
    ios_base::sync_with_stdio(0);
    // finput("./input");
    ll n; cin >> n;
    if(n == 2){
        cout << 0 << endl;
        return 0;
    }

    ll ans = 0;
    ll x = 1;
    while(n>=x*x){
        if(n % x == 0 && x < n/x-1){
            ans += n/x-1;
        }
        x++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3636
from collections import defaultdict

def main():
    N, M = map(int, input().split())
    a = [input().split() for _ in range(M)]
    ac_count = [0] * (N + 1)
    wa_count = defaultdict(lambda:0)
    ac, wa = 0, 0

    for q_no, ans in a:
        q_no = int(q_no)
        if ac_count[q_no] == 0:
            if ans == "AC":
                ac_count[q_no] = 1
                ac += 1
                wa += wa_count.get(q_no, 0)
            else:
                wa_count[q_no] += 1
    
    print(ac, wa)

if __name__ == '__main__':
    main()

Measured memory_bytes: 44420
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin>>s;
    if(s[0]=='Y'&&s[1]=='A'&&s[2]=='K'&&s[3]=='I')  cout<<"Yes";
    else  cout<<"No";
    cout<<endl;
	return 0; 
}

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

using namespace std;

const double PI = 3.141592653589;
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define pb push_back
#define mp make_pair
#define int long long
#define ll long long
#define all(c) (c).begin(),(c).end()
#define M 1000000007
#define INF LLONG_MAX
#define pr(...) dbs(#__VA_ARGS__, __VA_ARGS__)
template <class T> void dbs(string str, T t) {cerr << str << " : " << t << "\n";}
template <class T, class... S> void dbs(string str, T t, S... s) {int idx = str.find(','); cerr << str.substr(0, idx) << " : " << t << ", "; dbs(str.substr(idx + 1), s...);}
template <class S, class T>ostream& operator <<(ostream& os, const pair<S, T>& p) {return os << "(" << p.first << ", " << p.second << ")";}
template <class T>ostream& operator <<(ostream& os, const vector<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T>ostream& operator <<(ostream& os, const set<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class S, class T>ostream& operator <<(ostream& os, const map<S, T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T> void prc(T a, T b) {cerr << "["; for (T i = a; i != b; ++i) {if (i != a) cerr << ", "; cerr << *i;} cerr << "]\n";}
// Use pr(a,b,c,d,e) or cerr<<anything or prc(v.begin(),v.end()) or prc(v,v+n)
//  


int32_t main()
{
    fastio;
    //freopen("file.in", "r", stdin);
    //freopen("file.out", "w", stdout);
    int n;
    cin >> n;
    vector<double> p(n);
    for(int i=0;i<n;i++)
        cin >> p[i];
    vector<vector<double>> dp(n+1, vector<double>(n+1, 0.)); // dp[i][j] i: till index, j = wins
    dp[0][0] = 1; 
    for(int i=1;i<=n;i++) dp[i][0] = dp[i-1][0]*(1-p[i-1]);
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=i;j++)
        {
            dp[i][j] = dp[i-1][j-1]*p[i-1] + dp[i-1][j]*(1-p[i-1]);
        }
    }
    double ans = 0;
    for(int i=n/2 + 1;i<=n;i++)
    {
        ans += dp[n][i];
    }

    cout << fixed << setprecision(15) << ans << "\n";

    return 0;
}



Measured memory_bytes: 70784
N, M = map(int, input().split())
ok = [0, pow(10, 5)]

for i in range(M):
    l, r = map(int, input().split())
    if l >= ok[0]:
        ok[0] = l
    if r <= ok [1]:
        ok[1] = r
if ok[0] > ok[1]:
    print('0')
else:
    print(ok[1] - ok[0] +1)


Measured memory_bytes: 3188
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#define swap(type ,a ,b) {type t; t=a; a=b; b=t;}
#define forN(i,n) for(i=0;i<n;i++)
#define forR(i,s,n) for(i=s;i<n;i++)
#define ll long long
#define pb(t,d,n) {t p;int i;forN(i,n){cin>>p;d.push_back(p);}}

using namespace std;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int,int> pii;

typedef vector<pair<int,int>> vpii;

int main(){
    int a,b,c,tmp;
    cin >> a >> b >> c;
    cout << ((tmp=c+b-a)<0?0:tmp) << endl;
}

Measured memory_bytes: 888
S=input()
MOD=10**9+7
dp=[[0]*13 for i in range(len(S)+1)]
dp[0][0]=1
for i in range(len(S)):
    if S[i]=="?":
        for j in range(10):
            for k in range(13):
                dp[i+1][(10*k+j)%13]+=dp[i][k]%MOD
    else:
        a=int(S[i])
        for k in range(13):
            dp[i+1][(10*k+a)%13]+=dp[i][k]%MOD
print(dp[len(S)][5]%MOD)

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

bool ok (const string &s) {
    const int n = int(s.length()) - 1;
    bool ret = (s[n] == '0' and s[0] == '1');
    for (int i = 0; i < n; i++) {
        ret &= (s[i] == s[n - 1 - i]);
    }
    return ret;
}

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

    const int n = s.length();

    if (not ok(s)) {
        cout << -1 << '\n';
        return 0;
    }

    int v = 0;
    vector<pair<int, int>> edges;
    
    for (int i = 0; i < n - 1; i++) {
        edges.emplace_back(v, i + 1);
        if (s[i] == '1') v = i + 1;
    }

    for (const auto &e : edges) {
        cout << e.first + 1 << ' ' << e.second + 1 << '\n';
    }

    return 0;
}

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

using namespace std;
typedef long long ll;
#define int ll

template<typename T1,typename T2> inline void chmin(T1 &a, T2 b){ if(a > b) a = b; }
template<typename T1,typename T2> inline void chmax(T1 &a, T2 b){ if(a < b) a = b; }

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
const int MAX_N = 100010;

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

    string S, T;
    cin >> S >> T;
    if(S == T.substr(0, S.length())) {
        printf("Yes\n");
    }
    else {
        printf("No\n");
    }

    return 0;
}


Measured memory_bytes: 3644
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<math.h>
using namespace std;
#define mod (1000000000+7)
#define N (998244353)
#define INF 1e16
typedef long long ll;
typedef pair<ll,ll> P;

int p[200010];

int main(void){
    int n,a,length=0;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a;
        p[a]=i+1;
    }
    if(n==1){
        cout<<0<<endl;
        return 0;
    }
    for(int i=1;i<n;){
        int num=1;
        int j=i;
        while(true){
            if(i==n-1){
                if(p[i]<p[i+1]){
                    i++;
                    num=i-j+1;
                    length=max(length,num);
                    break;
                }
                else{
                    num=i-j+1;
                    length=max(length,num);
                    i++;
                    break;
                }
            }
            if(p[i]<p[i+1])i++;
            else{
                num=i-j+1;
                length=max(length,num);
                i++;
                break;
            }
        }
    }
    cout<<n-length<<endl;
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
#define all(q) (q).begin(),(q).end()
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll dg(ll a)
{
    int cnt=0;
    while(a>0)
    {
        a/=10;
        cnt++;
    }
    return cnt;
}
int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);
    ll n,ans=INT_MAX;
    cin>>n;
    for(int i=1; i<=sqrt(n); i++)
    {
        if(n%i==0)
        {
            ll x=i;
            ll y=n/x;
            ans=min(ans,max(dg(x),dg(y)));
        }
    }
    cout<<ans<<endl;

    return 0;
}


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

int main(){
	while(1){
		int n, x;
		cin >> n >> x;
		if(n == 0 && x == 0){
			break;
		}

		int m = 0;
		for(int a = 1; a <= n-2; a++){
			for(int b = a+1; b <= n-1; b++){
				int c;
				c = x-a-b;

				if(c <= n && a < b && b < c){
					m += 1;
				}
			}
		}
		cout << m << endl;
	}

	return(0);
}

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

constexpr int mod = 2019;

int main() {
    string s;
    cin >> s;
    vector<long long> prev(mod), current(mod);
    long long ans = 0;
    for (char c : s) {
        int n = c - '0';
        for (int r = 0; r < mod; ++r) {
            int nr = (r * 10 + n) % mod;
            current[nr] = prev[r];
        }
        current[n]++;
        ans += current[0];
        swap(current, prev);
    }
    cout << ans << endl;
}


Measured memory_bytes: 3692
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <cctype>
#include <cstdio>
#include <vector>
using namespace std;

int main()
{
    int numbers[12]={1,3,1,2,1,2,1,1,2,1,2,1};
    int x, y;
    cin >> x >> y;
    if(numbers[x-1]==numbers[y-1]){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    
    return 0;
}

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

int main() {
    string S;
    cin >> S;
    int min_abs = 753;
    for (int i = 0; i < S.size() - 2; i++){
        int a = (S[i] - '0') * 100 + (S[i+1] - '0') * 10 + (S[i+2] - '0');
        min_abs = min(min_abs, abs(a - 753));
    }
    cout << min_abs << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>

#define INF 2000000000

using namespace std;

int main(){
  int n; cin >> n;
  vector<pair<int,int> > px,py;
  //adjacent list
  vector<pair<int,int> > G[n+1];
  for(int i=1;i<=n;i++){
    int x,y; cin >> x >> y;
    px.push_back(make_pair(x,i));
    py.push_back(make_pair(y,i));
  }
  sort(px.begin(),px.end());
  sort(py.begin(),py.end());
  for(int i=0;i<n-1;i++){
    G[px[i].second].push_back(make_pair(px[i+1].second,px[i+1].first-px[i].first));
    G[px[i+1].second].push_back(make_pair(px[i].second,px[i+1].first-px[i].first));
    G[py[i].second].push_back(make_pair(py[i+1].second,py[i+1].first-py[i].first));
    G[py[i+1].second].push_back(make_pair(py[i].second,py[i+1].first-py[i].first));
  }
  /*for(int i=1;i<=n;i++){
    for(int j=0;j<G[i].size();j++){
      cout << i << " " << G[i][j].first << " " << G[i][j].second << endl;
    }
  }*/
  //minimum spanning tree
  //PQ has make_pair(d[id],id)
  priority_queue<pair<int,int>,vector<pair<int,int> >,greater<pair<int,int> > > PQ;
  int visited[n+1],d[n+1];
  for(int i=1;i<=n;i++){
    visited[i]=0;
    d[i]=INF;
  }
  d[1]=0;
  PQ.push(make_pair(0,1));
  int sum=0;
  while(PQ.empty()==false){
    int u=PQ.top().second;
    int u_cost=PQ.top().first;
    PQ.pop();
    if(u_cost>d[u]) continue;
    visited[u]=1;
    sum=sum+d[u];
    for(int i=0;i<G[u].size();i++){
      if(visited[G[u][i].first]==0){
        if(G[u][i].second<d[G[u][i].first]){
          d[G[u][i].first]=G[u][i].second;
          PQ.push(make_pair(d[G[u][i].first],G[u][i].first));
        }
      }
    }
  }
  cout << sum << endl;
}

Measured memory_bytes: 11756
#include <bits/stdc++.h>
// #pragma GCC optimize("unroll-loops,no-stack-protector")
// #pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout << (#x) << " is " << (x) << endl
#define debug cout << "hi" << endl

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

const int MOD = 1e9 + 7;
const int INF32 = 1<<30;
const ll INF64 = 1LL<<60;

int main()
{
	// #ifndef ONLINE_JUDGE
	// freopen(".in.txt", "r", stdin);
	// freopen(".out.txt", "w", stdout);
	// #endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll a, b; cin >> a >> b;
	ll g = __gcd(a, b);
	int ans = 0;
	for(ll i = 1; i <= sqrtl(g); i++) if(!(g % i))
	{
		bool p = 1;
		for(ll j = 2; j <= sqrtl(i); j++) if(!(i % j))
		{
			p = 0;
			break;
		}
		if(p) ans++;
		if(g/i == i) break;
		p = 1;
		for(ll j = 2; j <= sqrtl(g/i); j++) if(!(g/i % j))
		{
			p = 0;
			break;
		}
		if(p) ans++;
	}
	cout << ans << endl;

	return 0;
}

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

using namespace std;
using ll = long long;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int a, b, k;
  cin >> a >> b >> k;
  for (int i = 0; i < k; i++) {
    if (i % 2 == 0) {
      if (a % 2 == 1) {
        a--;
      }
      a /= 2;
      b += a;
    } else {
      if (b % 2 == 1) {
        b--;
      }
      b /= 2;
      a += b;
    }
  }
  cout << a << " " << b << endl;
  return 0;
}

Measured memory_bytes: 256