akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<ll,ll> ii;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define RST(i,n) memset(i,n,sizeof i)
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(),a.end()
#define X first
#define Y second
#define mkp make_pair
#define pb push_back
#define eb emplace_back
#define pob pop_back
#ifdef cold66
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<", ";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // cold66
//}
template<class T> inline bool chkmax(T &a, const T &b) { return b > a ? a = b, true : false; }
template<class T> inline bool chkmin(T &a, const T &b) { return b < a ? a = b, true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;

const ll MAXn=1e5+5,MAXlg=__lg(MAXn)+2;
const ll MOD=1000000007;
const ll INF=0x3f3f3f3f;

int main(){
    IOS();
    ll n;
    string s;
    cin >> n >> s;
    ll r = 0;
    REP (i,n) if (s[i] == 'R') r++;
    if (r > n-r) cout << "Yes" << endl;
    else cout << "No" << endl;
}


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

void captilize(string& s) {
    rep(i,s.size()) {
        s[i] = 'A'+(s[i]-'a');
    }
}

int main() {
    string a,b,c;
    cin >> a >> b >> c;
    string s = {a[0],b[0],c[0]};
    captilize(s);
    cout << s << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int N = scanner.nextInt();
		int M = scanner.nextInt();
		int X = scanner.nextInt();
		int P = (int)Math.pow(2, N);
		long[] tC = new long[P];
		long[][] Xs = new long[P][M];
		for(int i = 0; i < N; i++) {
			int C = scanner.nextInt();
			int[] A = new int[M];
			int mask = (int)Math.pow(2, i);
			for(int j = 0; j < M; j++) {
				A[j] = scanner.nextInt();
			}
			for(int j = 0; j < P; j++) {
				if((j & mask) > 0) {
					tC[j] += C;
					for(int k = 0; k < M; k++) Xs[j][k] += A[k];
				}
			}
		}
		long answer = Long.MAX_VALUE;
		boolean found = false;
		for(int i = 0; i < P; i++) {
			long sum = tC[i];
			if(sum > answer) continue;
			boolean isPossible = true;
			for(int j = 0; j < M; j++) {
				if(Xs[i][j] < X) {
					isPossible = false;
					break;
				}
			}
			if (isPossible) {
				answer = sum;
				found = true;
			}
		}
		System.out.println(found ? answer : -1);
	}
}


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

    //関数
    int cut_length(string s){
        int result=0;
        if(s.size()>=5&&(s.substr(s.size()-5,5)=="dream" || s.substr(s.size()-5,5)=="erase")){
            result=5;
            
        }
        if(s.size()>=7&&(s.substr(s.size()-7,7)=="dreamer")){
            result=7;
        }
        if(s.size()>=6&&(s.substr(s.size()-6,6)=="eraser")){
            result=6;
        }
        return result;
    }
    
    
    
    
    //main関数
    

int main() {
    
    
    
    //入力
    string S;
    cin>>S;
    
    
    
    
    
    
    
    
    
    
    
    
    //計算
    bool yet=true;
    //cout<<S<<cut_length(S)<<endl;
    while(yet){
        S=S.substr(0,S.size()-cut_length(S));
        //cout<<S<<cut_length(S)<<endl;
        if(cut_length(S)==0){
            yet=false;
        }
    }
    
    
    
    
    
    
    
    
    
    
    
    
    //出力
    if(S.size()>0){
        cout<<"NO"<<endl;
    }else{
        cout<<"YES"<<endl;
    }
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(c, i, n) for (int i = c; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

int main()
{
    int A, B, C;
    cin >> A >> B >> C;
    if (C - A + B >= 0)
    {
        cout << C - A + B << endl;
    }
    else
    {
        cout << 0 << endl;
    }
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N; cin >> N;
  ll ans = 1;
  FOR(i,0,N) {
    int a; cin >> a;
    if(a % 2 == 0) ans *= 2;
    else ans *= 1;
  }
  cout << pow(3, N) - ans << endl;
  return 0;
}

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

using namespace std;

typedef long long ll;

const int MOD = 998244353;
const int MAX = 2010101;
const ll INF = 1LL<<60;

ll fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
        fac[0] = fac[1] = 1;
        finv[0] = finv[1] = 1;
        inv[1] = 1;
        for (int i=2; i<MAX; i++) {
                fac[i] = fac[i - 1] * i % MOD;
                inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
                finv[i] = finv[i - 1] * inv[i] % MOD;
        }
}

ll COM(int n, int k) {
        if (n < k) return 0;
        if (n < 0 || k < 0) return 0;
        return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll mypow(ll x, ll n) {
        ll ans = 1;
        while(n) {
                if(n & 1) ans = (ans * x) % MOD;
                x = (x * x) % MOD;
                n>>=1;
        }
        return ans;
}


int main(int, char**) {
	COMinit();
	int n, m, k; cin >> n >> m >> k;
	ll ret = 0;
	for (int i=0; i<k+1; i++) {
		ret += ((m * mypow(m - 1, n - 1 - i))%MOD * COM(n - 1, i))%MOD;
		ret %= MOD;
	}
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 50724
import itertools
import sys
import math
import fractions
from collections import deque
from itertools import combinations
from functools import reduce
from functools import lru_cache
sys.setrecursionlimit(10**9)

def get_lcm(num):
    return reduce(lambda x,y:(x * y) // fractions.gcd(x, y), num, 1)

def main():
    N = int(input())
    A = list(map(int,input().split()))

    lcm = get_lcm(A)
    sum = 0
    for a in A:
      sum += lcm // a
    _, ans = divmod(sum, (10**9+7))

    print(ans)

if __name__ == "__main__":
  main()


Measured memory_bytes: 6136
#include <iostream>
#include <string>
#include <string.h>
#include <math.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <deque>
#include <queue>

#define rep(i, n) for(int i = 0; i < n; ++i)
#define REP(i, m, n) for(int i = m; i < n; ++i)
#define rrep(i,n) for(int i = n; i >= 0; --i)
#define RREP(i, m, n) for(int i = n; i >= m; --i)

typedef long long ll;
typedef unsigned long long ull;
typedef std::pair<int, int> pii;
typedef std::pair<long long, long long> pll;

using namespace std;

const long long mod = 1000000007;

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

	int a, b;
	cin >> a >> b;

	if (a > 9 || b > 9) {
		cout << -1 << "\n";
	}
	else {
		cout << a * b << "\n";
	}

    return 0;
}


Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <unordered_map>
#include <climits>
#include <set>
#include <unordered_set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <complex>
#include <regex>
#include <locale>
#include <random>
#include <type_traits>

using namespace std;

#define SHOW_VECTOR(v) {std::cerr << #v << "\t:";for(const auto& xxx : v){std::cerr << xxx << " ";}std::cerr << "\n";}
#define SHOW_MAP(v){std::cerr << #v << endl; for(const auto& xxx: v){std::cerr << xxx.first << " " << xxx.second << "\n";}}

using LL = long long;

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

int main() {

    int N;
    cin >> N;

    vector<int> A(N);
    for (int i = 0; i < N; i++) scanf("%d", &A[i]);

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

    LL ans = 0;
    for (int i = 0; i < N; i++) {
        for (int j = i + 1; j < N; j++) {
            for (int k = j + 1; k < N; k++) {
                if(A[k] < A[i] + A[j]){
                    ans++;
                }
            }
        }
    }

    printf("%d", ans);

    return 0;
}





















































Measured memory_bytes: 256
from functools import lru_cache
counter = 0
@lru_cache(maxsize=1024)

def fib(n):
    global counter
    counter += 1
    if n in [0, 1]:
        return 1
    return fib(n - 1) + fib(n - 2)

if __name__ == '__main__':
    print(fib(int(input())))

Measured memory_bytes: 6296
import sys

N=int(input())
W=[input() for i in range(N)]

from collections import Counter
counter=Counter(W)

if max(counter.values())>1:
    print("No")
    sys.exit()

for i in range(1,N):
    if W[i][0]!=W[i-1][-1]:
        print("No")
        sys.exit()

print("Yes")

Measured memory_bytes: 3316
#include <iostream>
#include <stdio.h>
#include <string>
#include <map>       // 連想配列用 
using namespace std;         

int main()
{
  int N, i;
  string gacha; 
  map <string, int> mp;       // ローカル変数として、mp を生成
  
  cin >> N; 

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

  cout << mp.size() << endl;
 }


Measured memory_bytes: 19188
#include <functional>
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <queue>
#include <string>
#include <cstring>
#include <math.h>
using namespace std;


int main() {
    int n;
    int m;
 
   cin >> n >> m;
  
  if(m%n==0){
    cout << n+m << endl;
  }else{
     cout << m-n << endl;
  }
  
  
  
  return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){

    int n,m;

    int s[5],c[5];

    cin >> n >> m;
    for(int i=0;i<m;i++) cin >> s[i] >> c[i]; 

    int l=10000;

    int q;

    if(n==1){
        for(int i=0;i<10;i++){
            q=0;
            for(int j=0;j<m;j++){
                if(s[j] == 1 && c[j]==i)
                    q++;
            }
            if (q == m) 
                l =min(l,i);
        }
    }    
    else if(n==2){
        for(int i=10;i<100;i++){
            q=0;
            for(int j=0;j<m;j++){
                if(s[j] == 1 && c[j] == i/10 )
                    q++;
                else if(s[j] == 2 && c[j] == i%10)
                    q++;
            }
            if (q==m)
                l = min(l,i);
        }
    }
    else if(n==3){
        for(int i=100;i<1000;i++){
            q=0;
            for(int j=0;j<m;j++){
                if(s[j] == 1 && c[j] == i/100 )
                    q++;
                else if(s[j] == 2 && c[j] == (i/10)%10)
                    q++;
                else if(s[j] == 3 && c[j] == i%10)
                    q++;
            }
            if (q==m)
                l = min(l,i);
        }
    }

    if(l == 10000)
        l = -1;


    cout << l << endl;

    
}

Measured memory_bytes: 256
def main():
    S = input()
    ST = set(S)
    ans = 100
    for st in ST:
        count = 0
        T = list(S)
        tmp = ''
        while len(set(T)) > 1:
            for i in range(len(T) - 1):
                if st in [T[i], T[i + 1]]:
                    tmp += st
                else:
                    tmp += T[i]
            T = tmp
            tmp = ''
            count += 1
        ans = min(ans, count)
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9096
import java.util.*;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = Integer.parseInt(sc.nextLine());
    int ans = 0;
    for(int i = 1; i <= N; i++) {
      int count = 0;
      if(i % 2 == 0) { continue; }
      for(int j = 1; j <= i; j++) {
        if(i % j == 0) {
          count++;
        }
      }
      if(count == 8) { ans++; }
    }
    System.out.println(ans);
  }
}

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

int main(){
  int i,j,k=0;
  int N;
  int a,b;
  scanf("%d",&N);
  
  for(i=0;i<N;i++){
    scanf("%d %d",&a,&b);
    k += (b-a+1);
    }
    
    printf("%d\n",k);
  return 0;
}

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

long long gcd(long long m, long long n) {
    return n != 0 ? gcd(n, m % n) : m;
}

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

    if (n == 2) {
        cout << max(a[0], a[1]) << endl;
        return 0;
    }

    vector<int> g(n, 0);
    vector<int> h(n, 0);
    g[1] = a[0];
    h[n-2] = a[n-1];
    for (int i = 2; i < n; i++) {
        g[i] = gcd(g[i - 1], a[i - 1]);
        h[n - i - 1] = gcd(h[n - i], a[n - i]);
    }

    int mx = max(g[n-1], h[0]);
    for (int i = 1; i < n - 1; i++) {
        mx = max(mx, (int)gcd(g[i], h[i]));
    }

    cout << mx << endl;
}

Measured memory_bytes: 1408
from collections import deque

S=deque(input())
flag=0
Q=int(input())

for queries in range(Q):
    q=list(input().split())

    if q[0]=="1":
        flag=1-flag
    else:
        x,y=q[1],q[2]

        if (flag+int(x))%2==0:
            S.append(y)
        else:
            S.appendleft(y)

if flag==0:
    print("".join(S))
else:
    print("".join(list(S)[::-1]))
    

Measured memory_bytes: 10100
// stuff_project.cpp : Defines the entry point for the console application.
//
//#include "stdafx.h"


#include<iostream>
#include<vector>
#include<algorithm>
#include<string>


#define INF 1000010000
#define nl '\n'
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define fi first
#define se second
#define pii pair<int,int>
#define pdd pair<double,double>
#define all(c) (c).begin(), (c).end()
#define SORT(c) sort(all(c))
#define sz(c) (c).size()
#define rep(i,n) for( int i = 0; i < n; ++i )
#define repi(i,n) for( int i = 1 ; i <= n; ++i )
#define repn(i,n) for( int i = n - 1 ; i >= 0 ; --i )
#define repf(j,i,n) for( int j = i ; j < n ; ++j )
#define die(s) {std::cout << s << nl;}
#define dier(s) {std::cout << s; return 0;}
#define vi vector<int>
typedef long long ll;
#define MAXN 1010101
using namespace std;


int go(string s, char c, int res = 0) {
	int ck = 0;

	int n = sz(s);
	rep(i, n) {
		if (s[i] == c) {
			++ck;
		}
	}
	if (!ck)return -1;
	if (ck == n)return res;
	string nxt = "";
	rep(i, n - 1) {
		if (s[i] == c) {
			nxt += c;
		}
		else if (s[i + 1] == c) {
			nxt += c;
		}
		else {
			nxt += s[i];
		}
	}
	return go(nxt, c, res + 1);
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.precision(0);

	string s;
	cin >> s;
	int ans = sz(s) - 1;
	repf(i, 'a', 'z' + 1) {
		string ss = s;
		int cur = go(ss, (char)i);
		if (cur != -1) {
			ans = min(ans, cur);
		}
	}


	cout << ans;

//	system("pause");
	return 0;
}

Measured memory_bytes: 256
n,m = map(int, input().split())
ps = [input().split() for _ in range(m)]

problem = [0] * n
pp = [0]*n
b = ""
for p,s in ps:
    if problem[int(p)-1] == 0:
        if s == "WA":pp[int(p)-1] += 1
        else: problem[int(p)-1] = 1
ac = 0
pe = 0
for i in range(n):
    if problem[i] == 1:
        ac += 1
        pe += pp[i]
print(ac,pe)

Measured memory_bytes: 33692
import Data.List (tails)

main :: IO ()
main = do
    n <- read <$> getLine
    s <- getLine
    t <- getLine
    answer $ solve n s t

type Answer = Int
answer :: Answer -> IO ()
answer = print

solve :: Int -> String -> String -> Answer
solve n s t = inner $ zip [0 ..] (tails s)
  where
    isPrefixOf xs ys     = length xs == length (takeWhile id $ zipWith (==) xs ys)
    inner           []   = undefined
    inner ((r, u) : xs)
      | u `isPrefixOf` t = r + length t
      | otherwise        = inner xs


Measured memory_bytes: 508
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
using P = pair<int, int>;
 
int main() {
  double n,k;
  cin >> n >> k;
  double ans = 0;
 
  for (double i = 1; i <= n; i++) {
    double cnt = 1;
    double tmp = i;
    while(tmp < k) {
      tmp *= 2;
      cnt *= 2;
    }
    ans += ((1/n) * (1/cnt));
  }
  printf("%.12f\n", ans);
  return 0;
}

Measured memory_bytes: 3720
//ABC043_D
#include <bits/stdc++.h>
using namespace std;
string N;
int main(){
  cin >> N;
  for(int i=0;i<N.size()-1;i++){
    if(N[i]==N[i+1]){
      cout << (i+1) << " " << (i+2) << endl;
      return 0;
    }
    if(N[i]==N[i+2]){
      cout << (i+1) << " " << (i+3) << endl;
      return 0;
    }
  }
  cout << "-1" << " " << "-1" << endl;
  return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <cstring>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <math.h>
#include <string>

using namespace std;

int main()
{
    string s;
    cin >> s;
    int c=0, t=stoi(s);

    for(int i=0; i<s.size(); i++){
        c+=s[i]-'0';
    }
    if(t%c==0){
        cout << "Yes";
    }else{
        cout << "No";
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/


int N;
string S;
int dp[501010];
//---------------------------------------------------------------------------------------------------
int nxt[501010], bak[501010];
void _main() {
    cin >> N >> S;
    S += "#";
 
    int bk = -1;
    rep(i, 0, N) {
        bak[i] = bk;
        if (S[i] == '0') bk = i;
    }

    int nx = N;
    rrep(i, N - 1, 0) {
        nxt[i] = nx;
        if (S[i] == '0') nx = i;
    }
 
    rep(i, 0, N) {
        dp[i + 1] = max(dp[i + 1], dp[i]);

        // 1011111...
        if (S[i] == '1') {
            if (1 <= bak[i] && S[bak[i] - 1] == '1') {
                int c = i - bak[i];
                dp[i + 1] = max(dp[i + 1], dp[bak[i] - 1] + c);
            }
        }
 
        if (S[i] == '1') {
            // ...1111101
            if (nxt[i] < N - 1 && S[nxt[i] + 1] == '1') {
                int c = nxt[i] - i;
                dp[nxt[i] + 2] = max(dp[nxt[i] + 2], dp[i] + c);
            }
        }
    }
 
    //rep(i, 0, N + 1) printf("dp[%d] = %d\n", i, dp[i]);
 
    cout << dp[N] << endl;
}

Measured memory_bytes: 6812
import sys
input = sys.stdin.readline

n, k, q = map(int, input().split())
point = [0 for _ in range(n)]
for l in sys.stdin:
    point[int(l)-1] += 1

# print(point)


for p in point:
    if p >= (q - k) + 1:
        print('Yes')
    else:
        print('No')


Measured memory_bytes: 47904
//#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast,no-stack-protector") 
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>
/*#include <x86intrin.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template <typename T> using ordered_set = tree<T, null_type, std::less<T>, rb_tree_tag, tree_order_statistics_node_update>;*/
#define ll long long
#define ull unsigned long long
//#define int long long
#define ld long double
#define rep(i, l, r) for (int i = l; i <= r; i++)
#define repb(i, r, l) for (int i = r; i >= l; i--)
#define sz(a) (int)a.size()
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define ret(a) {cout << a; exit(0);}

using namespace std;

mt19937 mrand(random_device{}()); 
const ll mod=1000000009;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b,ll mod) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
                                                                    
typedef pair < int , int > pii ;
typedef pair < long long  , long long > pll ;

const int N = 2e5 + 5;
int n, m;
int a[N];
string s;
main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int m1 , d1 , m2 , d2;
	cin >> 	m1 >> d1 >> m2 >> d2;
	ret((int)(m1 != m2));
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int sss;
  cin >> sss;
  
  int s1, s2, s3;
  s1 = sss / 100;
  s2 = (sss - s1 * 100) / 10;
  s3 = sss - s1 * 100 - s2 * 10;
  cout << s1 + s2 + s3 << endl;
}

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

int main() {

	int N, M;
	std::cin >> N >> M;

	std::vector<std::vector<int>> road(M, std::vector<int>(2, 0));

	for (int i = 0; i < M;i++) {
		for (int j = 0; j < 2; j++) {
			std::cin >> road[i][j];
		}
	}

	std::vector<int> town(N+1);

	for (int i = 0; i < M; i++) {
		for (int j = 0; j < 2; j++) {
			town[road[i][j]]++;
		}
	}

	for (int i = 1; i <= N; i++) {
		std::cout << town[i] << std::endl;
	}

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main() {
  ll n,d;
  cin >> n >> d;
  int ans=0;
  for(int i=0;i<n;++i){
    ll x,y;
    cin >> x >> y;
    ll res=d*d-(x*x+y*y);
    if(res>=0){
      ans++;}
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
class BIT{
public:
  int n,bit[500010];
  BIT(){fill(bit,bit+500010,0);}
  void add(int i,int x){
    while(i<=n){
      bit[i]+=x;
      i+=i&-i;
    }
  }
  int sum(int i){
    int s=0;
    while(i>0){
      s+=bit[i];
      i-=i&-i;
    }
    return s;
  }
};
 
int main() {
  ll d[111111],mod=1000000007;
  d[0]=1;
  for(int i=1; i<111111; i++) {
    d[i]=d[i-1]*i;
    d[i]%=mod;
  }
  int n;
  while(cin >> n && n) {
    int a[n];
    for(int i=0; i<n; i++) a[i]=i+1;
    int T;
    cin >> T;
    while(T--) {
      int x,y;
      cin >> x >> y;
      x--,y--;
      swap(a[x],a[y]);
    }
    BIT b=BIT();
    b.n=n;
    for(int i=1; i<=n; i++) b.add(i+1,1);
    ll ans=0;
    for(int i=0; i<n; i++) {
      ll x=b.sum(a[i]);
      ans+=x*d[n-i-1];
      ans%=mod;
      b.add(a[i],-1);
    }
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 6292
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i,a,b) for(int64_t i=(a); i<(b); ++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int64_t i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define INF 1000000000000
#define MOD 1000000007LL
#define RANGE(a,b,c) (a).begin()+(b),(a).begin()+(c) // [b,c) イテレータ
typedef pair<int64_t, int64_t> PII;
typedef vector<int64_t> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;
typedef int64_t i64;

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

i64 N, K; 
cin >> N >> K;


i64 cnt = 0;
rep(b, 1, N+1)
    cnt += N / b * max((i64)0, b - K) + max((i64)0, N%b - K + 1);


cout << ((K==0) ? N*N : cnt)  << endl;

}
// 書いて考える．場合分け
// 境界，出力文字列 チェック
// 可読性優先．高速化次点．
// まずは全探索，分割統治，次にDP
// 制限を見る．境界に注意．求めたい量の変域．動かせる量．
// 偶奇，逆から，ソート，出現回数，出現位置，DP， 余事象，包除
// データ構造． 問題の特徴量．単調性，二分探索
// 存在判定：構成方法，入力の特徴
// gcd, lcm ,素因数分解．
// 例外を十分に含む一般化．想像力の限界
// 小さい系から例示
// 代数的処理．前処理によるクエリ高速化．
// 始めは過剰に例示・場合分けしてもいい．各場合を確実に対処．
// 自明な例から処理，除外．
// 小数のときは，精度の設定する．doubel 変数に数値を入力するときは 123. とする．
// テストケース作成は数表あり
// 実行エラー：vector添え字超え．0割り．



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

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (int i = 0; i < int(n); i++)
#define forn1(i,n) for (int i = 1; i <= int(n); i++)
#define popcnt __builtin_popcount
#define ffs __builtin_ffs

using namespace std;

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
using pil = pair<int,ll>;
using pll = pair<ll,ll>;
template <typename T> using vec = vector<T>;
using vi = vec<int>;
using vl = vec<ll>;
template <typename T> using que = queue<T>;
template <typename T> using deq = deque<T>;

template <typename T> T id(T b) {return b;};
template <class It> bool all(It f,It l){return std::all_of(f,l,id<bool>);}
template <class It> bool any(It f,It l){return std::any_of(f,l,id<bool>);}
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}
void fastio() { ios_base::sync_with_stdio(false); cin.tie(nullptr); }
constexpr ll TEN(int n) { if (n == 0) return 1LL; else return 10LL*TEN(n-1); }

const int MAX_N = 1000;
int n,m;
vi g[MAX_N], ig[MAX_N];
bool path[MAX_N];
vec<pii> edges;
vi p;
int ne[MAX_N];
bool inc[MAX_N];

bool dfs(int u) {
  if (path[u]) {
    inc[u] = true;
    int c = u;
    for (int i = p.size()-1; i >= 0 && p[i] != u; i--) {
      inc[p[i]] = true;
      ne[p[i]] = c;
      c = p[i];
    }
    ne[u] = c;

    return true;
  }

  path[u] = true;
  p.push_back(u);

  for (int v : g[u]) {
    if (dfs(v)) return true;
  }

  p.pop_back();
  path[u] = false;

  return false;
}

bool idfs(int x, int v) {
  if (x == v) return true;

  inc[x] = true;

  for (int y : ig[x]) {
    ne[x] = y;
    if (idfs(y, v)) return true;
  }

  inc[x] = false;

  return false;
}

int main()
{
  fastio();

  cin >> n >> m;
  forn(i,m) {
    int a,b; cin >> a >> b;
    a--,b--;
    g[a].push_back(b);
    edges.emplace_back(a,b);
  }

  bool found = false;
  forn(i,n) {
    if ((found = dfs(i))) break;
  }

  if (!found) {
    cout << -1 << endl;
    return 0;
  }

  while (true) {
    int u = -1, v = -1;

    for (auto e : edges) {
      if (inc[e.fst] && inc[e.snd] && ne[e.fst] != e.snd) {
        u = e.fst;
        v = e.snd;
      }
    }

    if (u < 0) break;

    forn(i,n) ig[i].clear();

    for (auto e : edges) {
      if (inc[e.fst] && inc[e.snd]) {
        ig[e.fst].push_back(e.snd);
      }
    }

    fill_n(inc,n,false);
    idfs(v,u);
    inc[u] = true;
    ne[u] = v;
  }

  int ans = count(inc,inc+n,true);
  cout << ans << "\n";
  forn(i,n)
    if (inc[i]) cout << i+1 << "\n";

  return 0;
}


Measured memory_bytes: 384
/*
 * src.cpp
 *
 *  Created on: 2016/08/08
 *      Author: joi
 */

#include <bits/stdc++.h>

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)

typedef long long ll;

char S[64];

int cal[12]={31,28,31,30,31,30,31,31,30,31,30,31};

bool may(){
	int len=strlen(S);
	int cnt=0;
	REP(i,len){
		if (S[i]=='.'){
			cnt++;
		}
	}
	return cnt==4;
}

struct seireki{
	int y,m,d;
	seireki(int y=2012,int m=12,int d=21):y(y),m(m),d(d){}
	bool operator !=(const seireki &a){
		if (y!=a.y || m!=a.m || d!=a.d){
			return true;
		}
		return false;
	}
	void tom(){
		//?????\?????????
		if (y%4==0 && (y%100!=0 || y%400==0)){
			cal[1]=29;
		}
		if (cal[m-1]==d){
			d=1;
			if (m==12){
				y++;
				m=1;
			}else{
				m++;
			}
		}else{
			d++;
		}
		cal[1]=28;
	}
};

int main(){
	do{
		scanf("%s",S);
		if (S[0]!='#'){
			if (may()){
				ll b,ka,t,w,ki;
				b=ka=t=w=ki=0;
				int a;
				a=0;
				while (S[a]!='.'){
					b*=10;
					b+=S[a]-'0';
					a++;
				}
				a++;
				while (S[a]!='.'){
					ka*=10;
					ka+=S[a]-'0';
					a++;
				}
				a++;
				while (S[a]!='.'){
					t*=10;
					t+=S[a]-'0';
					a++;
				}
				a++;
				while (S[a]!='.'){
					w*=10;
					w+=S[a]-'0';
					a++;
				}
				a++;
				while (S[a]){
					ki*=10;
					ki+=S[a]-'0';
					a++;
				}
				ka+=b*20;
				t+=ka*20;
				w+=t*18;
				ki+=w*20;
				seireki se;
				while(ki>146097){
					se.y+=400;
					ki-=146097;
				}
				REP(i,ki){
					se.tom();
				}
				printf("%d.%d.%d\n",se.y,se.m,se.d);
			}else{
				seireki in(0,0,0),se;
				ll b,ka,t,w,ki;
				b=ka=t=w=ki=0;
				int a;
				a=0;
				while (S[a]!='.'){
					in.y*=10;
					in.y+=S[a]-'0';
					a++;
				}
				a++;
				while (S[a]!='.'){
					in.m*=10;
					in.m+=S[a]-'0';
					a++;
				}
				a++;
				while (S[a]){
					in.d*=10;
					in.d+=S[a]-'0';
					a++;
				}
				while (in.y>se.y+400){
					se.y+=400;
					ki+=146097;
				}
				while (in!=se){
					se.tom();
					ki++;
				}
				w+=ki/20;
				ki%=20;
				t+=w/18;
				w%=18;
				ka+=t/20;
				t%=20;
				b+=ka/20;
				ka%=20;
				b%=13;
				printf("%lld.%lld.%lld.%lld.%lld\n",b,ka,t,w,ki);
			}
		}
	}while (S[0]!='#');
	return 0;
}

Measured memory_bytes: 1132
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int A = scanner.nextInt();
        int B = scanner.nextInt();

        int price;
        double stop;
        int answer = -1;
        if (A > B) {
            price = A * 10;
            stop = (A+1) / 8.0 * 100.0;
        } else {
            price = B * 10;
            stop = (B + 1) / 10.0 * 100.0;
        }
        while (price < stop) {
            double first = price * 0.08;
            double second = price * 0.1;
            if ((int) first == A && (int) second == B) {
                answer = price;
                break;
            }
            price++;
        }
        System.out.println(answer);
    }
}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
std::string replaceStringAll(std::string str,
                             const std::string &replace,
                             const std::string &with)
{
  if (!replace.empty())
  {
    std::size_t pos = 0;
    while ((pos = str.find(replace, pos)) != std::string::npos)
    {
      str.replace(pos, replace.length(), with);
      pos += with.length();
    }
  }
  return str;
}
int count(string T)
{
  int k = 0;
  for (int i = 0; i < T.length(); i++)
  {
    char Now = T.at(i);
    static bool flag = false;
    switch (Now)
    {
    case 'P':
      flag = true;
      break;
    case 'D':
      k++;
      if (flag)
      {
        k++;
        flag = false;
      }
      break;
    }
  }
  return k;
}
int main(void)
{
  string T;
  cin >> T;
  T = replaceStringAll(T, "?", "D");
  cout << T << endl;
  return 0;
}

Measured memory_bytes: 3924
import java.io.*;
import java.util.Arrays;
class Main{
    public static void main(String[] args) throws IOException {
        int i,tmp;
        int[] A = new int[100];
        String str;
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        for(;(str=in.readLine())!=null;){
            char[] c = str.toCharArray();
            for(i=0;i<c.length;i++){
                tmp = (int)c[i];
                if(64 < tmp && tmp <91) tmp+=32;
                tmp-=97;
                if(tmp < 0 || 27 < tmp) continue;
                A[tmp]+=1;
            }
        }
        for(i=0;i<26;i++){
            System.out.println((char)(97+i)+" : "+A[i]);
        } 
        System.out.flush();
    }
}

Measured memory_bytes: 24448
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int main(void)
{
    char s[11];
    char y[5];
    char m[3];
    char d[3];
    scanf("%s",s);
    strncpy(y,s,4);
    strncpy(m,s+5,2);
    strncpy(d,s+8,2);
    y[4]=0;
    m[2]=0;
    d[2]=0;
    int yi, mi, di;
    yi = atoi(y);
    mi = atoi(m);
    di = atoi(d);
    if(yi > 2019)
    {
        printf("TBD");
        return 0;
    } else if(yi < 2019)
    {
        printf("Heisei");
        return 0;
    }
    else
    {
        if(mi > 4)
        {
            printf("TBD");
            return 0;
        }
        else
        {
            printf("Heisei");
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 128
import Control.Applicative ((<$>), (<*>))
import Control.Monad
import Data.List

main :: IO ()
main = do
  n <- getl toInt
  unless (n == 0) $ do
    unwords . map show . solve <$> replicateM n (getl $ wrds toInt) >>= putStrLn
    main

solve :: [[Int]] -> [Int]
solve = foldl f [0,0]
  where
    f [sa,sb] [ta,tb]
      | ta > tb = [sa+ta+tb,sb]
      | ta < tb = [sa,sb+ta+tb]
      | otherwise = [sa+ta,sb+tb]

toInt :: String -> Int
toInt = read

wrds :: (String -> a) -> String -> [a]
wrds f = map f . words

getl :: (String -> a) -> IO a
getl f = f <$> getLine

Measured memory_bytes: 8180
import sys
 
def main():
    input = sys.stdin.readline
    N = int(input())
    A = [0] + list(map(int, input().split()))
 
    M = 0
    ans = []
    B = [0] * (N+1)
    for i in range(N, 0, -1):
        cnt = 0
        for j in range(2*i, N+1, i):
            cnt += B[j]
 
        if A[i] != cnt % 2:
            B[i] += 1
            M += 1
            ans.append(i)
 
    if M == 0:
        print(0)
    else:
        ans = ans[::-1]
        print(M)
        print(' '.join(map(str, ans)))
 
 
if __name__ == '__main__':
    main()


Measured memory_bytes: 19976
#include<iostream>
#include<algorithm>
#include<cmath>

static const int MAX = 2000000;
// using namespace std;

int main() {
  int R[MAX], size;

  std::cin >> size;
  for (int  i = 0; i < size; i++) std::cin >> R[i];

  int ans = - 2 * std::pow(10, 9);
  int min_value = R[0];

  for (int  i = 1; i < size; i++) {
    ans = std::max(ans, R[i] - min_value);
    min_value = std::min(min_value, R[i]);
  }

  std::cout << ans << std::endl;
  // std::cout << "ans:" <<  ans << std::endl;
  return 0;
}


Measured memory_bytes: 3900
#include <complex>
#include <cmath>
#include <algorithm>

using Real = long double;

const Real EPS = 1e-10;

// 宇宙船演算子
inline Real compare(Real a, Real b) {
    if (std::abs(a - b) < EPS) return 0;
    return a - b > 0 ? 1 : -1;
}

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


using Point = std::complex<Real>;
using Segment = std::pair<Point, Point>;

inline Real dist(Point a, Point b) {
    return std::abs(a - b);
}

inline Real length(Segment s) {
    return dist(s.first, s.second);
}

// inner product
inline Real dot(Point x, Point y) {
    return std::real(std::conj(x) * (y));
}

// outer product
inline Real cross(Point x, Point y) {
    return std::imag(std::conj(x) * (y));
}

// lに対するxの正射影
Point proj(Segment s, Point p) {
    Real ratio = dot(s.second - s.first, p - s.first) / sq(length(s));
    return s.first + (s.second - s.first) * ratio;
}

// lを軸としてxに対称な点
Point refl(Segment s, Point p) {
    Point t = proj(s, p);
    return t + (t - p);
}

// lに対するpの位置
// counter clockwise -> 1, clockwise   -> -1
// online front      -> 2, online back -> -2
// on segment        -> 0
int side(Segment s, Point p) {
    Real c = cross(s.second - s.first, p - s.first);
    if (compare(c, 0) != 0) return compare(c, 0);

    Real d = dot(s.second - s.first, p - s.first);
    if (compare(d, 0) < 0) return -2;

    return (compare(length(Segment(s.first, p)), length(s)) > 0 ? 2 : 0);
}

inline bool isorthogonal(Segment s1, Segment s2) {
    return compare(dot(s1.second - s1.first, s2.second - s2.first), 0) == 0;
}

inline bool isparallel(Segment s1, Segment s2) {
    return compare(cross(s1.second - s1.first, s2.second - s2.first), 0) == 0;
}

inline bool intersect(Segment s1, Segment s2) {
    return (side(s1, s2.first) * side(s1, s2.second) <= 0) &&
           (side(s2, s1.first) * side(s2, s1.second) <= 0);
}

Point intersection(Segment s1, Segment s2) {
    Real c1 = cross(s2.second - s2.first, s1.second - s1.first);
    Real c2 = cross(s2.second - s2.first, s1.first - s2.first);
    return s1.first + (s1.second - s1.first) * (-c2 / c1);
}

Real dist(Segment s, Point p) {
    Point t = proj(s, p);
    if (side(s, t) == 0) return dist(p, t);
    return std::min(dist(p, s.first), dist(p, s.second));
}

Real dist(Segment s1, Segment s2) {
    if (intersect(s1, s2)) return 0;
    return std::min({dist(s1, s2.first),
                     dist(s1, s2.second),
                     dist(s2, s1.first),
                     dist(s2, s1.second)});
}


#include <iostream>
#include <iomanip>

using namespace std;

int main() {
    cout << fixed << setprecision(10);

    int Q;
    cin >> Q;

    for (int q = 0; q < Q; ++q) {
        Segment s[2];
        for (int i = 0; i < 2; ++i) {
            Point p[2];
            for (int j = 0; j < 2; ++j) {
                Real x, y;
                cin >> x >> y;
                p[j] = Point(x, y);
            }
            s[i] = Segment(p[0], p[1]);
        }

        cout << dist(s[0], s[1]) << endl;
    }
    return 0;
}



Measured memory_bytes: 3324
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

int main()
{
    int n;
    int cnt(0);
    cin >> n;
    vector <int> a(n);
    for(int i = 0; i < n; i++)
    {
        cin >> a[i];
        while(a[i] % 2 == 0)
            a[i] /= 2, cnt++;
    }
    cout << cnt;
}


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

using namespace std;

int main(){

    int N, M;
    cin >> N >> M;
    vector<int> A(N);
    priority_queue<int> pq;

    for (int i = 0; i < N; i ++){
        cin >> A[i];
        pq.push(A[i]);
    }

    long long sum = 0;
    int max;

    for (int i = 0; i < M; i++){
        max = pq.top(); // O(1)
        pq.pop(); // O(logN)
        max = max / 2;
        pq.push(max); // O(logN)
    }

    for (int i = 0; i < N; i++){
        sum += pq.top(); // O(1)
        pq.pop(); // O(logN)
    }

    cout << sum << endl;

    return 0;
}


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

int N, A[5000];
vector<int> edges[5000];

const int64_t INF = 1e18;
int64_t dp[5000][5001][2], sub[5001][2];
int num[5000];
void chmin(int64_t& a, int64_t b){
    a = min(a, b);
}

void dfs(int i, int par){
    for(int j : edges[i]) if(j != par) dfs(j, i);

    int sum = 1;
    dp[i][0][A[i] < 0] = A[i];

    for(int j : edges[i]) if(j != par){

        for(int n1=0; n1<sum; n1++){
            for(int n2=0; n2<num[j]; n2++){
                for(int k1=0; k1<2; k1++){
                    for(int k2=0; k2<2; k2++){
                        // 辺を繋ぐ場合
                        chmin(sub[n1+n2][k1|k2], dp[i][n1][k1] + dp[j][n2][k2]);
                        // 辺を切る場合
                        if((k2==0 && dp[j][n2][k2] < INF) || dp[j][n2][k2] < 0) chmin(sub[n1+n2+1][k1], dp[i][n1][k1]);
                    }
                }
            }
        }

        sum += num[j];
        for(int n=0; n<sum; n++) for(int k=0; k<2; k++){
            dp[i][n][k] = sub[n][k];
            sub[n][k] = INF;
        }
    }

    num[i] = sum;
}

int main(){
    cin >> N;
    for(int i=0; i<N; i++) cin >> A[i];
    for(int i=0; i<N-1; i++){
        int a, b;
        cin >> a >> b;
        edges[a-1].push_back(b-1);
        edges[b-1].push_back(a-1);
    }

    for(int j=0; j<N; j++) for(int k=0; k<2; k++){
        for(int i=0; i<N; i++) dp[i][j][k] = INF;
        sub[j][k] = INF;
    }

    dfs(0, -1);

    int ans = N-1;
    for(int n=0; n<N; n++){
        if(dp[0][n][0] < INF) ans = min(ans, n);
        if(dp[0][n][1] < 0) ans = min(ans, n);
    }
    cout << ans << endl;
    return 0;
}


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

#define mk make_pair
#define sc second
#define fr first
#define pb emplace_back
#define all(s) s.begin(), s.end()
#define sz(s) ( (int)s.size() )
#define Scan(a) scanf ("%I64d", &a)
#define scan(a) scanf ("%d", &a)

using namespace std;

const int inf = (int)1e9 + 7;
const int N = (int)2e5 + 7;

string a;
int k;
int cn;

main () {
      cin >> a;
      cin >> k;

      for (int i = 0; i < a.size(); i ++) {
            if (a[i] == '1') cn ++;
            else {
                  cout << a[i] << " ";
                  return 0;
            }
            if (cn == k) {
                  cout << "1";
                  return 0;
            }

      }
}


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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define deb(x) cout << #x << " --> " << x << endl;
#define print(x)                         \
    for (auto _x : x) cout << _x << " "; \
    cout << endl
#define pb push_back
typedef long long ll;
using namespace std;

void solve() {
    int i, j, k, n;
    char ch;
    cin >> ch;
    (isupper(ch)) ? cout << "A" : cout << "a";
}
int32_t main() {
    ios::sync_with_stdio(0);
    cout.tie(0);
    cin.tie(0);
    // int tc; cin >> tc; while(tc--)
    solve();
    return 0;
}

Measured memory_bytes: 3620
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include <deque>
using namespace std;
typedef long long ll;
int a[200001];
int b[200001];
int c[200001];
int main()
{
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	int n, p; cin >> n >> p;
	string s; cin >> s;
	if (p == 2 || p == 5) {
		ll ans = 0;
		for (int i = 0; i < n; i++) {
			if ((s[i] - '0') % p == 0) {
				ans += (ll)(i + 1);
			}
		}
		cout << ans << '\n'; return 0;
	}
	int ss = 0;
	ll ans = 0;
	int sum = 0;
	c[0] = 1;
	int ten = 1;
	for (int i = s.size() - 1; i >= 0; i--) {
		int t = (s[i] - '0');
		t *= ten; t %= p;
		sum += t; sum %= p;
		ans += (ll)c[sum];
		c[sum] += 1; ten *= 10; ten %= p;
	}
	cout << ans << '\n';


}




Measured memory_bytes: 720
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int k;
    int a[6];
    for(int i=1;i<=5;i++)
    {
        cin>>a[i];
    }
    cin>>k;
    for(int i=1;i<=5;i++)
    {
        for(int j=i+1;j<=5;j++)
        {
            if(a[j]-a[i]>k)
            {
                cout<<":("<<endl;
                return 0;
            }


        }
    }
    cout<<"Yay!"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pi 2*asin(1.0)
 
int main() {

int X,N,min;
int flg=0;
cin>>X>>N;
vector<int> p(N);
vector<int> d(102,1);
for(int i=0;i<N;i++){
cin>>p.at(i);
d.at(p.at(i))=0;
}
for(int i=0;i<=101;i++){

    if(d.at(X-i)==1){
        cout<<X-i<<endl;
        break;
    }
    if(d.at(X+i)==1){
        cout<<X+i<<endl;
        break;
    }


}

}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int,int> pint;
typedef vector<pint> vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=n-1;i>=(0);i--)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define all(v) (v).begin(),(v).end()
#define eall(v) unique(all(v), v.end())
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
const int MOD = 1e9 + 7;
const int INF = 1e9;
const ll INFF = 1e18;

int N, Q;
int A[100010], B[100010];
map<int, int> ps; // ps[i] := i番目の位置にあるコップの番号
int main(void){
	cin >> N >> Q;
	rep(i, Q) cin >> A[i] >> B[i];
	reps(i, 1, N + 1) ps[i] = i;
	set<int> ans;
	int d = 1; // コップ1の位置
	ans.insert(1), ans.insert(2);
	rep(i, Q){
		if(ps[A[i]] == 1) d = B[i];
		else if(ps[B[i]] == 1) d = A[i];
		swap(ps[A[i]], ps[B[i]]);
		
		if(d == 1) ans.insert(ps[2]);
		else if(d == N) ans.insert(ps[N - 1]);
		else ans.insert(ps[d - 1]), ans.insert(ps[d + 1]);
	}
	printf("%d\n", (int)ans.size());
	return 0;
}

Measured memory_bytes: 5760
def solve():
    seq1 = raw_input()
    seq2 = raw_input()
  
    a, b = len(seq1), len(seq2)
    x1 = [0 for i in range(b+1)]
    for i in range(a):
        e1 = seq1[i]
        x2 = x1+[]
        for j in range(b):
            if e1 == seq2[j]:
                x1[j+1] = x2[j] + 1
            elif x1[j+1] < x1[j]:
                x1[j+1] = x1[j]
    return x1[-1]
  
n = input()
for i2 in range(n):
    print solve()

Measured memory_bytes: 6532
#include <iostream>
#include <vector>
using namespace std;
#define ll long long int
const ll mod = 998244353;
const ll maxn = 3005;
ll dp[maxn][maxn][2];
// #define debug
int main(){
    ll n, s;
    cin >> n >> s;
    vector<ll> num;
    for(ll i = 0; i < n; ++i){
        ll c;
        cin >> c;
        num.push_back(c);
    }
    ll ans = 0;
    for(ll i = 0; i <= s; ++i){
        dp[0][i][0] = dp[0][i][1] = 0;
    }
    dp[0][0][0] = 1;
    dp[0][0][1] = 0;
    dp[0][num[0]][0] = dp[0][num[0]][1] = 1;
    for(ll i = 1; i < n; ++i){
        ll cur_num = num[i];
        for(ll j = 0; j <= s; ++j){
            ll a = dp[i - 1][j][0];
            ll b_1 = dp[i - 1][j][1];
            ll b_2;
            if(j < cur_num){
                b_2 = 0;
            }
            else if(j > cur_num){
                b_2 = dp[i - 1][j - cur_num][1];
            }
            else{
                b_2 = i + 1;
            }
            dp[i][j][0] = (a + b_1 + b_2) % mod;
            dp[i][j][1] = (b_2 + b_1) % mod;
        }
    }
    #ifdef debug
        for(int i = 0; i < n; ++i){
            cout << "i = " << i << endl;
            for(int j = 0; j <= s; ++j){
                cout << " " << "j = " << j << endl;
                cout << "  " << dp[i][j][0] << " " << dp[i][j][1] << endl;
            }
        }
    #endif
    cout << dp[n - 1][s][0] << endl;
    return 0;
}

Measured memory_bytes: 141184
# -*- coding: utf-8 -*-
N = int(input())
c = list(input())

n_red = len([each for each in c if each=='R'])
n_red_in_left = len([c[i] for i in range(len(c)) if i<=n_red-1 and c[i]=='R'])

print(n_red-n_red_in_left)

Measured memory_bytes: 100528
#include<iostream>
#include<sstream>
#include<vector>
#include<iterator>
#include<algorithm>
using namespace std;

int main(void)
{
	vector<int> A(3);
	for(int i=0; i<3; i++)
		cin >> A[i];

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

	int ret = 0;
	for(int i=0; i<2; i++)
		ret += A[i+1] - A[i];

	cout << ret << 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)
using ll = long long;
using P = pair<int, int>;
//int choose2(ll x){
	//	return x*(x-1)/2;}
const int INF = 1001001001;

int main() {
	string A;
	cin >> A;
	if (A == "ABC") {
		cout << "ARC";
	}
	else cout << "ABC";
		
	
}

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

using namespace std;

int main( ) {
    ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int t,a,b;
	t = 1;
	while(t--) {
	 cin >> a >> b;
	 if(a == 1)
	  a = 14;
	 if(b == 1)
	  b = 14;
	 if(a > b)
	  cout << "Alice" << endl;
	 else if(a < b)
	  cout << "Bob" << endl;
	 else
	  cout << "Draw" << endl;
	}
	return 0;
}



Measured memory_bytes: 256