akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;

#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

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; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
ostream& operator << (ostream &s, vector<string> P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s; }

const int MOD = 1000000007;
string S;

void add(long long &a, long long b) {
  a += b;
  if (a >= MOD) a -= MOD;
}

long long dp[210000][5];

int main() {
  while (cin >> S) {
	memset(dp, 0, sizeof(dp));
	dp[0][0] = 1;
	for (int i = 0; i <= S.size(); ++i) {
	  for (int j = 0; j < 5; ++j) {
		if (S[i] != '?') add(dp[i+1][j], dp[i][j]);
		else add(dp[i+1][j], dp[i][j] * 3 % MOD);

		//cout << i << ", " << j << ": " << dp[i][j] << endl;
	  }
	  if (i == S.size()) break;
	  if (S[i] == 'A' || S[i] == '?') add(dp[i+1][1], dp[i][0]);
	  if (S[i] == 'B' || S[i] == '?') add(dp[i+1][2], dp[i][1]);
	  if (S[i] == 'C' || S[i] == '?') add(dp[i+1][3], dp[i][2]);

	  
	}
	cout << dp[S.size()][3] << endl;
  }
}













Measured memory_bytes: 8704
#include <bits/stdc++.h>
//#include <boost/array.hpp>
//#include <boost/range/numeric.hpp>
//#include <boost/range/algorithm.hpp>
//#include <boost/multiprecision/cpp_int.hpp>

#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

using namespace std;
//using namespace boost::multiprecision;

constexpr long long INF = LLONG_MAX;
constexpr long long MOD = 1000000007;
constexpr long double PI = M_PI;

#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); ++i)
#define RFOR(i,n,r) for(ll i = (ll)(n-1); i >= r; --i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,n,0)
#define ALL(x) x.begin(),x.end()
#define CALL(x) x.cbegin(),x.cend()
#define RALL(x) x.rbegin(),x.rend()
#define CRALL(x) x.crbegin(),x.crend()

#define cout cout << fixed << setprecision(12)
#define dbglf cerr << '\n'

#define ACCM(arr) accumulate(ALL(arr),0LL)
#define Yes(ex) cout << ((ex) ? "Yes" : "No") << endl
#define YES(ex) cout << ((ex) ? "YES" : "NO") << endl

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using vi = vector<ll>;
using vvi = vector<vi>;
using vp = vector<pair<ll, ll>>;
using vs = vector<string>;
using vc = vector<char>;
using lst = list<ll>;
using pq = priority_queue<ll>;

template < typename T >
inline void veccin(vector<T>& v) {
    for (auto && e : v) { cin >> e; }
}

template < typename T >
inline void dbg(T a) { cerr << a << ' '; }

ll n, m, k;
ll ans = 0, sum = 0, cnt = 0;
//ld d;
string s/*1, s2, s3*/;
char c/*1, c2, c3*/;
bool flag = false;

/*--------------------template--------------------*/

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

    cin >> n >> m;
	int mi = n * 2, ma = n * 4;
	Yes(mi <= m && m <= ma && m % 2 == 0);

    //cout << ans << endl;
}


Measured memory_bytes: 3644
while True:
    h,w=list(map(int,input().split()))
    if h==w==0:
        break
    for i in range(h):
        for j in range(w):
            if (i+j)%2==0:
                print("#",end="")
            else:
                print(".",end="")
        print()
    print()
        


Measured memory_bytes: 7004
#include <bits/stdc++.h>
#define ll long long
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;
ll const Max=(ll)1e12;
ll ans;
int n,w;
int main() {
	fast;
	cin>>n>>w;
	int weight[n],value[n];
	vector<vector<ll>> dp(n,vector<ll>(100001,Max));
	for(int i=0;i<n;i++) cin>>weight[i]>>value[i];
	for(int i=n-1;i>=0;i--){
	   for(int j=0;j<=100000;j++){
	   	   if(j-value[i]<=0)
	   	      dp[i][j]=min(((i<n-1)?dp[i+1][j]:Max),(ll)weight[i]);
	   	   else if(i<n-1 and dp[i+1][j-value[i]]!=Max)
	   	   	  dp[i][j]=min((ll)(weight[i]+dp[i+1][j-value[i]]),dp[i+1][j]);
	   }
	}
	for(int i=100000;i>=0;i--){
	    if(dp[0][i]<=w){
	    	ans=i;
	    	break;
	    }
	}
	cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 79984
#include "bits/stdc++.h"
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;++i)

using namespace std;
typedef long long ll;


template<typename T>
T gcd(T a, T b){
   if (a%b == 0){
       return(b);
   }
   else{
       return(gcd(b, a%b));
   }
}

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


int main(void){
    ll dp[110][100020];//選ぶ個数：重さの合計値
    //dp[i][w]＝i個目(i-1個目)までから重さがwを超えないように選ぶ
    int N,W;
    cin>>N>>W;
    vector<vector<ll>>b(N);
    ll v,w;
    rep(i,N){
        cin>>w>>v;
        b[i].push_back(w);
        b[i].push_back(v);
    }
    rep(i,W+10){
        dp[0][i]=0;
    }
    rep(i,N){
        rep(w,W+1){
            if(w-b[i][0]>=0){//入る
                dp[i+1][w]=max(dp[i][w],dp[i][w-b[i][0]]+b[i][1]);
            }
            else{
                dp[i+1][w]=dp[i][w];
            }
        }
    }
    
    cout<<dp[N][W];
}
/*

*/

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

int main()
{

    int N;
    cin >> N;
    long long ans = 0;
    for (int i = 1; i <= N; i++)
    {
        if(i%3!=0&&i%5!=0){
            ans += i;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 3596
#include "bits/stdc++.h"

using namespace std;
const long long INF = 1LL << 60;

void chmin(long long &a,long long b){
    if(a>b)a=b;
    return;
}

int main()
{
    int n,k;
    cin >> n>>k;
    long long dp[n+1000];
    long long  h[n];
    for(int i=0;i<n;i++){
        cin >> h[i];
    }

    for(int i=0;i<n+1000;i++)dp[i]=INF;

    dp[0]=0;
    for(int i=0;i<n;i++){
        for(int j=1;j<=k;j++){
            chmin(dp[i+j],dp[i]+abs(h[i]-h[i+j]));
        }
    }
    cout << dp[n-1]<< endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
//#pragma GCC diagnostic error "-Wconversion"
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define all(vec) vec.begin(), vec.end()
#define mp(a, b) make_pair(a, b)
typedef long long ll;
const ll INF = 1LL << 60;
const ll MOD = (1e9 + 7);
using namespace std;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
ll dp[100010];
ll gcd(ll x, ll y){
  return y == 0 ? x : gcd(y, x % y);
}
ll lcg(ll x, ll y){
  return x * y / gcd(x, y);
}
ll digits(ll x){
  ll length = 0;
  while (x > 0){
    x /= 10;
    length++;
  }
  return length;
  if (x == 0) return 0;
}
map<ll, ll> factor(ll n){
  map<ll, ll> ans;
  ll a = 2;
  while (n >= a * a){
    if (n % a == 0){
      ans[a]++;
      n /= a;
    }
    else a++;
  }
  ans[n]++;
  return ans;
}
template<class T> inline bool chmin(T& a, T b){
  if (a > b){
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b){
  if (a < b){
    a = b;
    return true;
  }
  return false;
}

int main(){
  cout << fixed << setprecision(15);
  int ans = 0;
  //string ans = "No";

  string s; cin >> s;
  int i = 0;
  while(i < s.size()){
    cout << s[i]; i += 2;
  }

  //cout << ans << endl;
  return 0;
}

Measured memory_bytes: 512
#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);
}

vector<pll> g[100010];
int color[100010];
void dfs(int v, int p, int c){
    color[v] = c;
    for(auto pa : g[v]){
        int u = pa.fi, w = pa.se;
        if(u == p) continue;
        if(w % 2 == 0){
            dfs(u, v, c);
        }else{
            dfs(u, v, c^1);
        }
    }
}

int main(){
    ios_base::sync_with_stdio(0);
    // finput("./input");
    int n; cin >> n;
    rep(i,n-1){
        ll u,v,w;
        cin >> u >> v >> w;
        u--; v--;
        g[u].emplace_back(v, w);
        g[v].emplace_back(u, w);
    }
    dfs(0, -1, 0);

    rep(i,n){
        cout << color[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 13704
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdbool.h>
#include <math.h>

int max(int a, int b){
    if(a > b){
        return a;
    }else{
        return b;
    }
}

int main(void){

    int N, Z, W;

    scanf("%d%d%d", &N, &Z, &W);

    int a[N];

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

    if(N == 1){
        printf("%d\n", abs(a[0] - W));
    }else{
        printf("%d\n", max(abs(a[N-1] - W), abs(a[N-1] - a[N-2])));
    }

    return 0;
}

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

int main() {
  while(true){
  int n, x, ans = 0;
  cin >> n >> x;
  if(n==0&&x==0) break;
  for(int i = 1; i <= n; i++){
      for(int j = 1; j <= n;j++){
          for(int k = 1; k <= n; k++){
              if(i+j+k==x&& i<j&&j<k){
                  ans++;
                  //cout << i << j << k << endl;
              }
          }
      }
  }
  cout << ans << endl;
}
}



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

const int mod = 1000000007;

int main() {
    string s;
    cin >> s;
    long long dp[100001][4] = {};
    dp[0][0] = 1;

    for (int i = 0; i < s.length(); i++) {
        for (int j = 0; j < 4; j++) {
            dp[i + 1][j] = dp[i][j] * (s[i] == '?' ? 3 : 1);
            if (j >= 1 && (s[i] == '?' || s[i] == "ABC"[j - 1])) {
                dp[i + 1][j] += dp[i][j - 1];
            }
            dp[i + 1][j] %= mod;
        }
    }

    cout << dp[s.length()][3] << endl;
}

Measured memory_bytes: 3648
#include<iostream>
#include<queue>
#include<bitset>
#include<algorithm>
#include<climits>
#include<vector>
#include<deque>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define fill(x,y) memset(x,y,sizeof(x))
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define dump(a) rep(i,a.size()){ cout<<a[i]<<" "; } cout<<endl;
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define INF INT_MAX/3
#define EPS 1e-7


int main(){
  string s;
  cin >> s;
  int n = s.length();
  int m = s.length();
  rep(i,n-1){
    if(s[i]!=s[i+1]){
      m = mmin(mmax(i+1,n-i-1), m);
    }
  }
  cout<<m<<endl;
  return 0;
}


Measured memory_bytes: 512
#include "bits/stdc++.h"
#include <stdio.h>

using namespace std;

using ll = long long;

const int nax = 3005;

ll dp[nax][nax];

int main() {
    int n;
    scanf("%d", &n);
    vector<int> a(n);
    for(int i = 0; i<n; ++i){
        scanf("%d", &a[i]);
    }
    //dp[0][n-1] stores the answer
    for(int L = n - 1; L >=0; --L){
        for(int R = L; R < n; ++R){
            if(L == R){
                dp[L][R] = a[L];
            }else{
                dp[L][R] = max(a[L] - dp[L+1][R], a[R] - dp[L][R-1]);
            }
        }
    }
    printf("%lld", dp[0][n-1]);
}

Measured memory_bytes: 70016
#include <bits/stdc++.h>
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define ll long long int
#define ld long double
using namespace std;
const int N = 1e6 + 5;
const int MOD = 1e9 + 7;


int main(){
	fast;
	ld d, t, s;
	cin >> d >> t >> s;
	ld tym = d/s;
	if(tym <= t) cout << "Yes\n";
	else cout << "No\n";
	return 0;
}
// 								This code will self destruct in 5 seconds..		

Measured memory_bytes: 3728
let () =
  let n = Scanf.scanf "%d\n" (fun n -> n) in
  let lrs = Array.init n (fun _ -> Scanf.scanf "%d %d\n" (fun l r -> l, r)) in
  Array.fold_left (fun a (l, r) -> a + r - l + 1) 0 lrs
  |> Printf.printf "%d\n"

Measured memory_bytes: 1024
sx, sy, tx, ty = map(int, input().split())
dx, dy = tx-sx, ty-sy

# ーをかけると文字が消える
cmd1 = 'R' * dx + 'U' * dy
cmd2 = 'L' * dx + 'D' * dy
cmd3 = 'D' + 'R' * (dx+1) + 'U' * (dy+1) + 'L'
cmd4 = 'U' + 'L' * (dx+1) + 'D' * (dy+1) + 'R'
ans = cmd1 + cmd2 + cmd3 + cmd4
print(ans)


Measured memory_bytes: 9092
#include <stdio.h>
#include <algorithm>
#include <math.h>
using namespace std;
int main()
{
int n;
int a[12];
scanf("%d",&n);
for(int i=0;i<n;i++)
{
scanf("%d",&a[i]);
}
sort(a,a+n);
int ans=0;
for(int i=0;i<n;i++)
{
ans=ans+a[i];
if(i==n-1){ans=ans-a[i]/2;}
}
printf("%d\n",ans);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
int main(void){
    // Your code here!
 ll i,k,n,q,s,x;
 s=0;
 cin >> n >> k >> q;
 vector<ll> v(n,0);
 while(q--)
 {
  cin >> x;
  v[x-1]++;
 }
 for(auto it:v)
 s+=it;
 for(i=0;i<n;i++)
 {
  v[i]-=s;
  v[i]+=k;
 }
 for(auto it:v)
 cout << (it>0 ? "Yes" : "No") << '\n';
 return 0;
}

Measured memory_bytes: 4024
import java.util.*;
 
public class Main {
  public static void main(String...args) {
    final Scanner sc = new Scanner(System.in);
    final int N = sc.nextInt();
    final int H = sc.nextInt();
    final int W = sc.nextInt();
    System.out.println((N - H + 1) * (N - W + 1));
  }
}

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

int main() {
    int n;
    cin >> n;
    vector<long long> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    sort(a.begin(), a.end(), greater<long long>());

    long long cnt = 1, b = a[0], ans = 0, c = 0;
    for (int i = 1; i < n; i++) {
        if (b == a[i]) cnt++;
        
        if (i == n - 1 || b != a[i]) {
            if (cnt == 1) {
                b = a[i];
                continue;
            }
            else if (2 <= cnt && cnt <= 3) {
                cnt = 1;
                if (c == 0) c = b;
                else {
                    ans = c * b;
                    break;
                }
                b = a[i];
            }
            else {
                if (c == 0) ans = b * b;
                else ans = c * b;
                break;
            }
        }
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
  #include <complex>
  #include <vector>
  #include <string>
  #include <algorithm>
  #include <cstdio>
  #include <numeric>
  #include <cstring>
  #include <ctime>
  #include <cstdlib>
  #include <set>
  #include <map>
  #include <unordered_map>
  #include <unordered_set>
  #include <list>
  #include <cmath>
  #include <bitset>
  #include <cassert>
  #include <queue>
  #include <stack>
  #include <deque>
 #include <iomanip>
#include <fstream>
#include <climits>
 
  using namespace std;
   
 
//abcdefghijklmnopqrstuvwxyz
//ABCDEFGHIJKLMNOPQRSTUVWXYZ

  typedef long long ll;
  typedef long double lld;
  typedef unsigned long long ull;
  ll INF = INT_MAX;
  // ll mod = 1000000007;
  // lld PI = 3.141592653;
 


  int main()
  {
      ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
      // ifstream cin("input.txt");
      
     int n;
     cin>>n;
     vector<int> a(n);
     for (int i = 0;i<n;i++) cin>>a[i];
     ll ans = 0;
     int prev = a[0];
     for (int i = 1;i<n;i++){
      if (a[i]<prev){
        ans+= prev-a[i];
        a[i] = prev;
      }

      prev = a[i];
     } 
     cout<<ans<<"\n";

}

Measured memory_bytes: 3596
#include <stdio.h>
#define Mod 1000000007

long long pow_mod(long long a, long long k, long long M){
  if(k == 1) return a % M;
  if(k == 0) return 1;
  long long temp = pow_mod(a, k/2, M);
  if(k % 2 == 1) return ((a*temp%M) *temp)%M;
  return (temp*temp)%M;
}

int
main(int argc, char *argv[])
{
  long long k, n;
  scanf("%lld %lld", &n, &k);

  n = n - k;
  long long int a = n + 1; long long b;
  for(long long i = 1; i <= k; i++){
    printf("%lld\n", a);
    if(i == k) goto sdf;
    b = (k - i)*a%Mod;
    b = (n - i + 1)*b%Mod;
    b = b*pow_mod(i, Mod - 2, Mod)%Mod;
    b = b*pow_mod(i + 1, Mod - 2, Mod)%Mod;
    a = b;
  }

 sdf:

  return 0;

}


Measured memory_bytes: 128
from collections import deque

class Node:
    def __init__(self,idx,parent,child,depth):
        self.idx=idx
        self.parent=parent
        self.child=child
        self.depth=depth

n=int(input())

nodes=[Node(-1,-1,-1,-1) for _ in range(n)]

for i in range(n):
    id,k,*c=map(int,input().split())
    nodei=nodes[id]
    nodei.idx=id
    nodei.child=c
    for ci in c:
        nodes[ci].parent=id

q=deque()
root_i=-1
for ni in nodes:
    if(ni.parent==-1):
        root_i=ni.idx
        break

q.append([root_i,0])
while(len(q)>0):
    qi=q.popleft()
    node_idx=qi[0]
    node_depth=qi[1]
    nodes[node_idx].depth=node_depth
    node_child=nodes[node_idx].child
    for c in node_child:
        q.append([c,node_depth+1])


for nodei in nodes:
    print("node "+str(nodei.idx)+": ",end="")
    print("parent = "+str(nodei.parent)+", ",end="")
    print("depth = "+str(nodei.depth)+", ",end="")
    if(nodei.parent==-1):
        print("root, ",end="")
    elif(nodei.child==-1 or len(nodei.child)==0):
        print("leaf, ",end="")
    else:
        print("internal node, ",end="")
    print(nodei.child)






Measured memory_bytes: 48500
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<queue>
#include<stack>
#include<cmath>	
#include<list>
#include<set>

constexpr auto PI = 3.14159265359;

using namespace std;

int main() {
	int N;
	cin >> N;
	int fibonacci[45];
	fibonacci[0] = 1;
	fibonacci[1] = 1;
	for (int i = 2; i <= N; ++i) {
		fibonacci[i] = fibonacci[i - 1] + fibonacci[i - 2];
	}
	cout << fibonacci[N] << endl;

	return 0;
}


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


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

 int main()
 {
	int n,i;
        scanf("%d",&n);

	int il;
	il=0;
	bool in,de;
	in=true;
	de=true;
	
	int a,b;
       	b=-1;

	for(i=1;i<=n;i++)
	{
		scanf("%d",&a);

		if(b!=-1)
		{
			if(a>b)
			{
				de=false;
			}	

			if(a<b)
			{
				in=false;
			}
		}

		b=a;

		//printf("(%d %d)\n",in, de);

		if((!in)&&(!de))
		{
			//printf("|%d|\n",i);

			in=true;
			de=true;
			il++;
		}
	}

	printf("%d\n",il+1);
 } 


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <array>
#include <vector>
#include <utility>
#include <bitset>
#include <queue>
#include <unordered_map>
#include <unordered_set>

using namespace std;

using ll = long long;
using p = pair<ll, ll>;

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

    ll N;
    cin >> N;
    
    vector<ll> X(N), Y;
    for (auto&& x : X) {
        cin >> x;
    }
    Y = X;
    sort(X.begin(), X.end());

    ll lc = X[N / 2 - 1];
    ll rc = X[N / 2];

    for (auto y : Y) {
        if (y <= lc ) {
            cout << rc << endl;
        } else if (y >= rc) {
            cout << lc << endl;
        }
    }

    return 0;
}



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

int main(){
    ll k,ans=0; cin>>k;
    for(int i=1; i<=k; i++) {
        for(int j=1; j<=k; j++) {
            for(int l=1; l<=k; l++) {
                ans += __gcd(i,__gcd(j,l));
            }
        }
    }
    cout<<ans;
}

Measured memory_bytes: 3632
<?php
fscanf(STDIN, '%s', $line);
$panels = str_split($line);
$length = count($panels);

$answer = 0;

$count = array_count_values($panels);
if (!isset($count['1'])) {
    $target = '1';
} elseif (!isset($count['0']) && isset($count['1']) || $count['1'] > $count['0']) {
    $target = '0';
} elseif (!isset($count['1']) && isset($count['0']) || $count['1'] < $count['0']) {
    $target = '1';
} else {
    $target = $panels[0];
}

$flg = $panels[0] != $target;
foreach ($panels as $key => $panel) {
    if ($flg ? $panel == $target : $panel != $target) {
        if ($panel == '0') {
            $panels[$key] = '1';
        } elseif ($panel == '1') {
            $panels[$key] == '0';
        }
        $answer++;
    }
    $flg = !$flg;
}

echo $answer;

Measured memory_bytes: 14840
open Printf
open Scanf
open Num

let () =
  let h, w = scanf "%d %d\n" (fun x y -> (x, y)) in
  let f1 () = if h mod 3 = 0 then 0 else w in
  let f2 () = if w mod 3 = 0 then 0 else h in
  let f3 () =
    let w1 = w / 2 in
    let w2 = w - w1 in
    let rec loop a s =
      if a = h then s
      else
        let x = (num_of_int a) */ (num_of_int w) in
        let y = (num_of_int (h - a)) */ (num_of_int w1) in
        let z = (num_of_int (h - a)) */ (num_of_int w2) in
        let mi = min_num (min_num x y) z in
        let mx = max_num (max_num x y) z in
        if s >/ (mx -/ mi) then loop (a+1) (mx -/ mi) else loop (a+1) s in
    int_of_num (loop 1 (num_of_int w */ num_of_int h)) in
  let f4 () =
    let h1 = h /2 in
    let h2 = h - h1 in
    let rec loop a s =
      if a = w then s
      else
        let x = (num_of_int a) */ (num_of_int h) in
        let y = (num_of_int (w - a)) */ (num_of_int h1) in
        let z = (num_of_int (w - a)) */ (num_of_int h2) in
        let mi = min_num (min_num x y) z in
        let mx = max_num (max_num x y) z in
        if s >/ (mx -/ mi) then loop (a+1) (mx -/ mi) else loop (a+1) s in
    int_of_num (loop 1 (num_of_int w */ num_of_int h)) in
  min (min (f1 ()) (f2 ())) (min (f3 ()) (f4 ())) |> printf "%d\n"


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define si(x) int(x.size())
const int mod=1000000007,MAX=200005,INF=1<<29;

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N,P,Q;
    P=673;
    Q=3;
    string S;cin>>S;
    N=si(S);
    
    vector<pair<int,int>> right(N+1);
    vector<vector<int>> cnt(P,vector<int>(3));
    vector<int> rui10(N+1,1);
    for(int i=1;i<=N;i++){
        rui10[i]=rui10[i-1]*10;
        rui10[i]%=P;
    }
    for(int i=N-1;i>=0;i--){
        right[i].fi=right[i+1].fi+int(S[i]-'0')*rui10[N-1-i];
        right[i].fi%=P;
        right[i].se=(right[i+1].se+int(S[i]-'0'))%3;
    }
    
    ll ans=0;
    
    cnt[0][0]++;
    
    for(int i=N-1;i>=0;i--){
        ans+=cnt[right[i].fi][right[i].se];
        cnt[right[i].fi][right[i].se]++;
        
        //cout<<ans<<endl;
    }
    
    cout<<ans<<endl;
    
    //for(int i=N-1;i>=0;i--) cout<<right[i]<<endl;
}


Measured memory_bytes: 5896
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

void Main() {
  ll h,w,n;
  cin >> h >> w >> n;
  vector<ll> v[w+1];
  rep(i,n) {
    int x,y;
    cin >> x >> y;
    x--,y--;
    v[y].pb(x);
  }
  rep(i,w) v[i].pb(h);
  rep(i,h) v[w].pb(i);
  rep(i,w+1) sort(all(v[i]));
  ll x=0,ans=MAX;
  rep(y,w) {
    ll k=lower_bound(all(v[y]),x)-v[y].begin();
    ans=min(ans,v[y][k]);
    x++;
    while(1) {
      ll kk=lower_bound(all(v[y+1]),x)-v[y+1].begin();
      if(v[y+1][kk]==x) x++;
      else break;
    }
    if(x>=h) break;
  }
  pr(ans);
}

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

Measured memory_bytes: 14456
#pragma region ヘッダー
#define _CRT_SECURE_NO_WARNINGS

#ifdef _____MY_DEBUG_____
#define VS_ENDPAUSE()	(system("pause"))
#define DEBUG_OUT(...)  (printf(__VA_ARGS__))
#else
#define VS_ENDPAUSE()
#define DEBUG_OUT(...)
#endif

#include <stdio.h>
#include <string.h>
#include <iostream>
#include <math.h>
#include <cmath>
#include <vector>
#include <algorithm>
#include <string>
#include <functional>

using namespace std;
typedef signed char int8;
typedef signed short int16;
typedef signed int int32;
typedef signed long long int64;
typedef unsigned char uint8;
typedef unsigned short uint16;
typedef unsigned int uint32;
typedef unsigned long long uint64;
//#define int int64

#ifndef INT8_MIN
#define INT8_MIN	(-127)
#endif
#ifndef INT8_MAX
#define INT8_MAX	( 128)
#endif
#ifndef UINT8_MAX
#define UINT8_MAX	( 255)
#endif
#ifndef INT16_MIN
#define INT16_MIN	(-32768)
#endif
#ifndef INT16_MAX
#define INT16_MAX	( 32767)
#endif
#ifndef UINT16_MAX
#define UINT16_MAX	( 65535)
#endif
#ifndef INT32_MIN
#define INT32_MIN	(-2147483648)	// -2 * 10^9
#endif
#ifndef INT32_MAX
#define INT32_MAX	( 2147483647)	//  2 * 10^9
#endif
#ifndef UINT32_MAX
#define UINT32_MAX	( 4294967295)	//  4 * 10^9
#endif
#ifndef INT64_MIN
#define INT64_MIN	(-9223372036854775808)	// -9 * 10^18
#endif
#ifndef INT64_MAX
#define INT64_MAX	( 9223372036854775807)	//  9 * 10^18
#endif
#ifndef UINT64_MAX
#define UINT64_MAX	( 18446744073709551615)	// 18 * 10^18
#endif

void func(void);
#pragma endregion

int32 main(void)
{
    func();
    VS_ENDPAUSE();
    return 0;
}

//DEBUG_OUT("----\n");

void func(void)
{
    int N, A, B;
    cin >> N >> A >> B;

    int ans = min(N*A, B);
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cinttypes>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<string>
#include<stack>


#define FSCNd64 "%" SCNd64
#define FPRId64 "%" PRId64

using namespace std;

using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
using vll=vector<ll>;
using vvll=vector<vll>;
using vpii=vector<pii>;

#define PI 3.1415926535897932384626433832795

template<typename X>
bool max_u(X&m, X v)
{
	if(m<v)
	{
		m=v;
		return true;
	}
	return false;
}


template<typename X>
bool min_u(X&m, X v)
{
	if(m>v)
	{
		m=v;
		return true;
	}
	return false;
}


int msb(ll v)
{
	int i=0;
	for(;v>0;i++)
	{
		v>>=1;
	}
	return i;
}


struct solve
{
	solve(){}
	bool is_lose(int n, vll&w)
	{
		if(n==0) return true;

		bool ret=true;
		for(int i=0;i<n;i++)
		{
			int m=w[i];
			for(int j=1;m-j>0;j++)
			{
				w[i]-=j;
				if(is_lose(n, w)) ret=false;
				w[i]+=j;
			}
			swap(w[i], w[n-1]);
			if(is_lose(n-1, w)) ret=false;
			swap(w[i], w[n-1]);
		}
		return ret;
	}
	ll operator()(vll&a) {
		int n=a.size();
		ll x=0;
		ll a_max=a[0];
		for(int i=2;i<n;i++) x^=a[i];
		ll s=a[0]+a[1];

		a[0]=a[1]=0;
		if(msb(s)<msb(x)) return -1;
		vll b1(msb(s));
		for(int i=msb(s)-1;i>=0;i--)
		{
			ll c=1LL<<i;
			if(x&c)
			{
				b1.push_back(c);
				s-=c;
				if(s<0) break;
			}
			else
			{
				if(s>=c*2)
				{
					a[0]|=c;
					a[1]|=c;
					s-=c*2;
					if(a[0]>a_max) return -1;
				}
			}
		}
		for(auto m:b1)
		{
			if((a[0]|m)<=a_max)
			{
				a[0]|=m;
			}
			else
			{
				a[1]|=m;
			}
		}
		if(a[0]==0) return -1;
		if(s==0) return a_max-a[0];
		return -1;
	}
};

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

	for(;;)
	{
		int n;
		cin >> n;
		if(cin.fail()) break;
		vll a(n);
		for(auto&m:a) cin >> m;

		cout << solve()(a) << "\n";
	}
	return 0;
}


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

int main() {
  int k;
  string s;
  cin >> k >> s;
  if(s.size() <= k){
	cout << s << endl;
    return(0);
  }else{
    string tmp="";
    for(int i=0;i<k;i++){
      tmp += s.at(i);
    }
    tmp += "...";
    cout << tmp << endl; 
  }
  
  return(0);
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define f first
#define s second
#define pb push_back
#define eb emplace_back
#define mk make_pair
#define mt make_tuple
#define MOD 1000000007
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
#define all(x) x.begin(), x.end()
#define vi vector<int>
#define vl vector <long long int>
#define pii pair <int,int>
#define pll pair <long long int, long long int>
#define vpii vector< pair<int,int> >
#define vpll vector < pair <long long int,long long int> >
#define boost ios::sync_with_stdio(false); cin.tie(0)
using namespace std;
const int inf = 1e9 + 5;
const ll inf64 = 1e18 + 5;

const int N = 10;
vector <ll> v;
ll to_num(string s)
{
	ll res = 0;
	for(int i = 0; i < s.size(); i++) {
		res *= 10;
		int x = s[i] - '0';
		res += x;
	}
	return res;
}
void rec(string s)
{
	if(s.size() > N)
	return;
	
	if(s.size() > 0)
	v.pb(to_num(s));
	
	if(s.size() == 0) {
		for(int i = 1; i < 10; i++) {
			s += char(i + '0');
			rec(s);
			s.pop_back();
		}
	}
	else {
		int x = s.back() - '0';
		for(int i = max(0, x - 1); i <= min(9, x + 1); i++) {
			s += char(i + '0');
			rec(s);
			s.pop_back();
		}
	}
}
int main()
{
	boost;
	rec("");
	sort(all(v));
	int k;
	cin >> k;
	cout << v[k - 1] << '\n';
}


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

using namespace std;
typedef pair<int, int>P;
typedef long long ll;
#define rep(i,n)for(ll i=0;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const double pi = acos(-1.0);
const ll MOD = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 1010;
//max=({});
//条件式が真ならwhileの中身を回し続ける
//printf("%d\n", ans);

//pairの入力
//vector<pair<ll, ll>>work(n);
//rep(i, n) {
//	ll a, b;
//	cin >> a >> b;
//	work[i] = make_pair(a, b);
//for(auto p:mp)(mapの探索)
//printf("%.10f\n",なんちゃら)
//最大公約数
ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}

ll lcm(ll x, ll y) {
	if (x == 0 || y == 0)return 0;
	return (x / gcd(x, y) * y);
}

//組み合わせの余りを求める
ll fac[MAX_N], finv[MAX_N], inv[MAX_N];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX_N; 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;
	}
}

// 二項係数計算
long long COM(ll n, ll k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll dx[4] = { 0,0,-1,1 };
ll dy[4] = { -1,1,0,0 };
ll dp[101010];

//union-find木について
ll par[101010];
ll rank2[101010];

void init(ll n) {
	rep(i, n) {
		par[i] = i;
		rank2[i] = 0;
	}
}

ll find(ll x) {
	if (par[x] == x) {
		return x;
	}
	else {
		return par[x] = find(par[x]);
	}
}

void unite(ll x, ll y) {
	x = find(x);
	y = find(y);
	if (x == y)return;
	if (rank2[x] < rank2[y]) {
		par[x] = y;
	}
	else {
		par[y] = x;
		if (rank2[x] == rank2[y]) {
			rank2[x]++;
		}
	}
}

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

//long longしか使わない
//素数は1より大きい
int main() {
	ll n;
	cin >> n;
	vector<ll>a(n), b(n), c(n);
	rep(i, n) {
		cin >> a[i];
	}
	rep(i, n) {
		cin >> b[i];
	}
	rep(i, n) {
		cin >> c[i];
	}
	sort(a.begin(), a.end());
	sort(b.begin(), b.end());
	sort(c.begin(), c.end());
	ll ans = 0;
	rep(i, n) {
		ll left = -1;
		ll right = n;
		while (right - left > 1) {
			ll mid = (left + right) / 2;
			if (a[mid] < b[i]) {
				left = mid;
			}
			else {
				right = mid;
			}
		}
		ll left2 = -1;
		ll right2 = n;
		while (right2 - left2 > 1) {
			ll mid2 = (left2 + right2) / 2;
			if (c[mid2] <= b[i]) {
				left2 = mid2;
			}
			else {
				right2 = mid2;
			}
		}
		ans += right * (n - 1 - left2);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 2560
#include<stdio.h>

int main(){
  int n = 0;
  int i = 0;
  char str[100] = {};
  int flag =0;
  scanf("%d",&n);
  scanf("%s",str);
  if(n % 2 == 0){
    for(i = 0;i < n/2;i++){
      if(str[i] != str[n/2 + i]){
        flag = 1;
      }
    }
  }else{
    flag = 1;
  }
  if(flag == 1){
    printf("No");
  }else{
    printf("Yes");
  }
  return 0;
}

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

int main(){
    string s;
    cin>>s;
    int c=0;
    set<int> st;
    st.insert(0);
    for(auto x: s){
        if(x=='R') c++;
        else{
            st.insert(c);
            c=0;
        }
    }
    st.insert(c);
    cout<<*st.rbegin()<<endl;
}


Measured memory_bytes: 3628
#include <iostream>
#include <algorithm>
#include <vector>
#include <string.h>
using namespace std;
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void POSS(T condition){ if(condition) cout << "POSSIBLE" << endl; else cout << "IMPOSSIBLE" << endl; }
template<class T> inline void Poss(T condition){ if(condition) cout << "Possible" << endl; else cout << "Impossible" << endl; }
template<class T> inline void First(T condition){ if(condition) cout << "First" << endl; else cout << "Second" << endl; }
template<class T = string, class U = char>int character_count(T text, U character){ int ans = 0; for(U i: text){ ans += (i == character); } return ans; }
long power(long base, long exponent, long module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ long root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position move_pattern[4] = {{-1, 0}, {0, 1}, {1, 0}, {0, -1}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++){ ans += to_string(*i) + " "; } ans.pop_back(); cout << ans << endl; }
template<class itr> void cins(itr start, itr goal){ for(auto i = start; i != goal; i++){ cin >> (*i); } }
template<class T> T gcd(T a, T b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }} template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
#define mod long(1e9 + 7)
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl(long(n))
#define fcout cout << fixed << setprecision(10)
#define highest(x) (63 - __builtin_clzl(x))

int main(){
    int N, i;
    cin >> N >> i;
    cout << N - i + 1 << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int H, W;
  cin >> H >> W;
  int A[H][W];
  int B[H][W];
  for(int i=0; i<H; i++){
    for(int j=0; j<W; j++){
      cin >> A[i][j];
    }
  }
  for(int i=0; i<H; i++){
    for(int j=0; j<W; j++){
      cin >> B[i][j];
    }
  }
  int AB[H][W];
  for(int i=0; i<H; i++){
    for(int j=0; j<W; j++){
      AB[i][j] = A[i][j] - B[i][j];
    }
  }
  
  const int N_MAX = 80*160*2;
  const int ZERO = 80*160;
  
  bool dp[H][W][N_MAX];
  for(int i=0; i<H; i++){
    for(int j=0; j<W; j++){
      for(int k=0; k<N_MAX; k++){
        dp[i][j][k] = false;
      }
    }
  }
  
  dp[0][0][AB[0][0] + ZERO] = true;
  dp[0][0][AB[0][0]*-1 + ZERO] = true;
  
  for(int i=0; i<H; i++){
    for(int j=0; j<W; j++){
      for(int k=0; k<N_MAX; k++){
        if(dp[i][j][k]){
          if(i+1 < H){
            dp[i+1][j][k + AB[i+1][j]] = true;
            dp[i+1][j][k + AB[i+1][j]*-1] = true;            
          }
          if(j+1 < W){
            dp[i][j+1][k + AB[i][j+1]] = true;
            dp[i][j+1][k + AB[i][j+1]*-1] = true;
          }
        }
      }
    }
  }
  
  
  int ans = 100000000;
  
  
  for(int i=0; i<N_MAX; i++){
    if(dp[H-1][W-1][i]){
      ans = min(ans,abs(i-ZERO));
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 160256
/********************************************
 *Author*        :ZZZZone
 *Created Time*  : 日  3/11 20:18:45 2018
 * Ended  Time*  : 日  3/11 20:43:42 2018
*********************************************/

#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <stack>
using namespace std;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;

inline void OPEN(string s){
	freopen((s + ".in").c_str(), "r", stdin);
	freopen((s + ".out").c_str(), "w", stdout);
}

int main()
{
	int n, k;
	scanf("%d %d", &n, &k);
	if( k == 0) printf("%lld\n", 1LL * n * n);
	else{
		LL ans = 0;
		for(int i = k+1; i <= n; i++){
			int r = i-1, l = k;
			ans = ans + (r-l+1LL);
			while(r +k+1 <= n){
				l += i;
				r += i;
				ans = ans + (LL)(min(n, r)- min(n, l)+1LL);
			}
		}
		printf("%lld\n", ans);
	}
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int main()
{
    int N,M; cin >> N >>M;
    
    vector<vector<int>> vec(M);
    
    for(int i = 0;i<M;i++)
    {
        int k;
        cin >> k;
        vec[i].resize(k);
        for(int j = 0; j<k;j++)
        {
            cin >> vec[i][j];
            --vec[i][j];
        }
        
    }
    vector<int>p(M);
    for(int i = 0;i<M;i++)
        cin >>p[i];
    int ans = 0;
    for(int i = 0;i<(1<<N);i++)
    {
        bool ok = true;
        for(int j = 0;j <M;j++)
        {
            int c = 0;
            for(int id : vec[j])
            {
                if((i >> id) & 1)
                {
                    ++c;
                }
            }
            c%=2;
            if(c!=p[j])
            {
                ok = false;
            }
            
        }
        if(ok)
        {
            ++ans;
        }
    }
    cout << ans <<endl;
    
    return 0;
}

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

int main() {
  int N;
  std::cin >> N;
  std::vector<double> p(N);
  for (int i = 0; i < N; ++i)
    std::cin >> p[i];

  std::vector<std::vector<double>> dp(N + 7, std::vector<double>(N + 7, .0));
  dp[0][0] = 1.;
  for (int i = 0; i < N; ++i) {
    for (int k = 0; k <= i; ++k) {
      dp[i + 1][k + 1] += dp[i][k] * p[i];
      dp[i + 1][k] += dp[i][k] * (1. - p[i]);
    }
  }

  double res = .0;
  for (int k = N / 2 + 1; k <= N; ++k)
    res += dp[N][k];

  std::cout << std::setprecision(12);
  std::cout << res << std::endl;
}


Measured memory_bytes: 71040
#pragma region ヘッダー
#define _CRT_SECURE_NO_WARNINGS

#ifdef _____MY_DEBUG_____
#define VS_ENDPAUSE()	(system("pause"))
#define DEBUG_OUT(...)  (printf(__VA_ARGS__))
#else
#define VS_ENDPAUSE()
#define DEBUG_OUT(...)
#endif

#include <stdio.h>
#include <string.h>
#include <iostream>
#include <math.h>
#include <cmath>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;
typedef signed char int8;
typedef signed short int16;
typedef signed int int32;
typedef signed long long int64;
typedef unsigned char uint8;
typedef unsigned short uint16;
typedef unsigned int uint32;
typedef unsigned long long uint64;
#define int int64

#ifndef INT8_MIN
#define INT8_MIN	(-127)
#endif
#ifndef INT8_MAX
#define INT8_MAX	( 128)
#endif
#ifndef UINT8_MAX
#define UINT8_MAX	( 255)
#endif
#ifndef INT16_MIN
#define INT16_MIN	(-32768)
#endif
#ifndef INT16_MAX
#define INT16_MAX	( 32767)
#endif
#ifndef UINT16_MAX
#define UINT16_MAX	( 65535)
#endif
#ifndef INT32_MIN
#define INT32_MIN	(-2147483648)	// -2 * 10^9
#endif
#ifndef INT32_MAX
#define INT32_MAX	( 2147483647)	//  2 * 10^9
#endif
#ifndef UINT32_MAX
#define UINT32_MAX	( 4294967295)	//  4 * 10^9
#endif
#ifndef INT64_MIN
#define INT64_MIN	(-9223372036854775808)	// -9 * 10^18
#endif
#ifndef INT64_MAX
#define INT64_MAX	( 9223372036854775807)	//  9 * 10^18
#endif
#ifndef UINT64_MAX
#define UINT64_MAX	( 18446744073709551615)	// 18 * 10^18
#endif

void func(void);
#pragma endregion

int32 main(void)
{
    func();
    VS_ENDPAUSE();
    return 0;
}


void func(void)
{
//DEBUG_OUT("----\n");
    int32 x, a, b;
    cin >> x >> a >> b;

    if(abs(x-a) <= abs(x-b)){
        cout << "A" << endl;
    }else{
        cout << "B" << endl;
    }

    return;
}



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

int minCost(vector < int > &nums, int k) {
  int n = nums.size();
  vector < int > dp(n, -1);
  dp[0] = 0;
  int minCost = INT_MAX;
  for (int i = 1; i < n; i++) {
    minCost = INT_MAX;
    for (int j = 1; j <= k; j++) {
      if (i - j >= 0) {
        minCost = min(dp[i - j] + abs(nums[i] - nums[i - j]), minCost);
      }
    }
    dp[i] = minCost;
  }

  return dp[n - 1];
}

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

  cout<<minCost(nums, k)<<endl;

  return 0;
}


Measured memory_bytes: 3988
from collections import deque

V,E,r = map(int,input().split())
dlis = [[] for _ in range(V)]
mind = [10**10]*V

for _ in range(E):
  std = list(map(int,input().split()))
  dlis[std[0]].append([std[1],std[2]])
  
q = deque()
q.append([r,0])

while len(q) > 0:
  v = q.popleft()
  a = v[0]
  b = v[1]
  if mind[a] <= b:
    continue
  mind[a] = b
  for el in dlis[a]:
    aa = el[0]
    bb = b + el[1]
    if mind[aa] > bb:
      q.append([aa,bb])
    
for i in range(V):
  if mind[i] == 10**10:
    print("INF")
  else:
    print(mind[i])


Measured memory_bytes: 118204
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 85;
const int C = 165 * 165;
bitset<C> dp[2][N];
int a[N][N], b[N][N];
int main()
{
    int n,m;
    cin >> n >> m;
    for (int i = 0; i < n; ++i)
        for (int j = 0; j < m; ++j)
            cin >> a[i][j];
    for (int i = 0; i < n; ++i)
        for (int j = 0; j < m; ++j)
            cin >> b[i][j];
    dp[1][0][C/2] = 1;
    for (int i = 0; i < n; ++i) {
        int c = i & 1;
        for (int j = 0; j < m; ++j) {
            int d = abs(a[i][j] - b[i][j]);
            if (j == 0) {
                dp[c][j] = (dp[c^1][j] << d) | (dp[c^1][j] >> d);
            } else {
                dp[c][j] = (dp[c][j-1]<<d) | (dp[c][j-1]>>d);
                if (i)
                    dp[c][j] |= (dp[c^1][j] << d) | (dp[c^1][j] >> d);
            }
        }
    }
    int ans;
    auto & v = dp[n&1^1][m-1];
    for (ans = 0; !v[C/2+ans] && !v[C/2-ans]; ++ans);
    cout << ans << endl;
}


Measured memory_bytes: 896
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{   int n,k;
cin>>n>>k;
    string s;
    cin>>s;
    vector<pair<int,int>> a;
    vector<pair<int,int>> b;
    if(s[0]=='0'){
        b.push_back({0,0});
    }
    int i=0;
    while(i<s.size()){
        if(s[i]=='0'){
            int z=i;
            i++;
            while(s[i]=='0'){
                i++;
            }
            int x=i;
            a.push_back(make_pair(z,x));
        }
        else{
            int z=i;
            i++;
            while(s[i]=='1'){
                i++;
            }
            int x=i;
            b.push_back(make_pair(z,x));
        }
    }
    b.push_back({0,0});
//    for(int i=0;i<a.size();i++){
//        cout<<a[i].first<<" "<<a[i].second<<endl;
//    }
//    for(int i=0;i<b.size();i++){
//        cout<<b[i].first<<" "<<b[i].second<<endl;
//    }
    if(a.size()==0 || a[0].second-a[0].first==s.size() || a.size()<=k){
        cout<<s.size();
        return 0;
    }
    else{
        int m=INT_MIN,o=INT_MIN;
        for(int i=0;i+k<=a.size();i++){
            int l=0;
            for(int j=0;j<k;j++){
                if(!j){
                    l+=(b[i+j].second-b[i+j].first)+(a[i+j].second-a[i+j].first)+(b[i+j+1].second-b[i+j+1].first);
                }
                else{
                    l+=(a[i+j].second-a[i+j].first)+(b[i+j+1].second-b[i+j+1].first);
                }
            }
            m=max(m,l);
        }

        cout<<m;
        return 0;
    }
}

Measured memory_bytes: 1524
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <queue>
#include <list>
#include <stack>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <functional>
#include <iomanip> // std::std::setprecision(X)
#include <limits>  //std::numeric_limits<int>::max(), min()

typedef long long ll;

int main (void) {

  int N; std::cin >> N;
  std::vector<int> A(N+1); for(int i=0; i<=N; i++) std::cin >> A[i];

  ll ans = 0;
  for(int i=0; i<N; i++) {
    int B; std::cin >> B;
    if ( A[i] >= B ) ans += B;
    else {
      ans += A[i];
      B -= A[i];
      if ( A[i+1] >= B ) {
        ans += B;
        A[i+1] -= B;
      }
      else {
        ans += A[i+1];
        A[i+1] = 0;
      }
    }
  }

  std::cout << ans << std::endl;

  return 0;
}

Measured memory_bytes: 640
import numpy as np
n=int(input())
a=np.array(input().split(),dtype=np.int32)
b=np.array(input().split(),dtype=np.int32)
def f(t,a,b):
  power=1<<t
  mask=(power<<1)-1
  aa=a&mask
  bb=b&mask
  aa.sort()
  bb.sort()
  x1,x2,x3=(np.searchsorted(bb,v-aa).sum() for v in [power,power*2,power*3])
  zero_cnt=x1+(x3-x2)
  return (n-zero_cnt)%2
ans=0
for t in range(30):
  x=f(t,a,b)
  if x==1:
    ans+=1<<t
print(ans)


Measured memory_bytes: 38880
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
int a[200001],n;
int main()
{
	scanf("%d",&n);for(int i=1;i<=n;++i)scanf("%d",&a[i]);
	sort(a+1,a+1+n);for(int i=2;i<=n;++i)if(a[i]==a[i-1]){printf("NO\n");return 0;}printf("YES\n");return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;

int main(){
  int n;
  cin>>n;
  P a[101];
  for(int i=0;i<n;i++) cin>>a[i].second>>a[i].first,a[i].second*=-1;
  sort(a,a+n,greater<P>());
  cout << -a[0].second<<" "<<a[0].first<<endl;
  
  return 0;
}

Measured memory_bytes: 3088