akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <functional>
#include <ctime>
#include <cmath>
#include <limits>
#include <numeric>
#include <type_traits>
#include <iomanip>
#include <float.h>
#include <math.h>
using namespace std;
using ll = long long;


unsigned euclidean_gcd(unsigned a, unsigned b) {
    if (a < b) return euclidean_gcd(b, a);
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

class UnionFind {
public:
    vector <ll> par;
    vector <ll> siz;
    UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    ll root(ll x) {
        while (par[x] != x) {
            x = par[x] = par[par[x]];
        }
        return x;
    }
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) {
        return root(x) == root(y);
    }

    ll size(ll x) {
        return siz[root(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 modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}
void dfs() {

}

int main() {
    string n;
    ll k;
    cin >> n >> k;
    ll b = n.size();
    vector<vector<ll>> dp(b + 1, vector<ll>(k + 2));
    vector<vector<ll>> same(b + 1, vector<ll>(k + 2));
    same[0][1] = 1;
    for (int i = 0; i < b; i++) {
        for (int j = 1; j < k+2; j++) {
            if (n[i] == '0') {
                dp[i + 1][j] = dp[i][j] + dp[i][j - 1] * 9;
                same[i + 1][j] = same[i][j];
            }
            else {
                dp[i + 1][j] = dp[i][j] + dp[i][j - 1] * 9 + same[i][j]+same[i][j-1]*((n[i]-'0')-1);
                same[i + 1][j] = same[i][j-1];
            }
        }
    }
    cout << same[b][k+1] + dp[b][k+1] << endl;
}

Measured memory_bytes: 3660
n = int(input())
s = input()

cnt = 0
for i in range(1000):
    si = str(i).zfill(3)
    k = 0
    for cn in range(n):
        if s[cn] == si[k]:
            if k == 2:
                cnt += 1
                break
            else:
                k += 1
print(cnt)

Measured memory_bytes: 73736
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Joy
 */

#include <bits/stdc++.h>
#define REP(i, N) for (ll i = 0; i < (N); ++i)
#define ALL(x) (x).begin(), (x).end()
#define MOD 1000000007
#define INF 1e9
#define INFL 1e18
#define PB push_back
#define MP make_pair
using namespace std;
typedef long long ll;
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }

class A9x9 {
public:
	void solve(std::istream& in, std::ostream& out) {
	    int A, B;
	    in >> A >> B;
	    int ans;
	    if (A > 9 || B > 9) {
	        ans = -1;
	    } else {
	        ans = A * B;
	    }
        out << ans << '\n';
	}
};


int main() {
	A9x9 solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

using std::string;
using std::vector;
using std::set;
using std::multiset;
using std::unordered_set;
using std::map;
using std::multimap;
using std::unordered_map;
using std::pair;
using std::cin;
using std::cout;

using boost::multiprecision::cpp_int;
using cpp_dec_float_1000 = boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000>>;

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

constexpr char CRLF  = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 1000'000'007;
constexpr int MOD = 1000'000'007;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }
template<class T> T modinv(T a, T m) { T b = m, u = 1, v = 0; while (b) { T t = a / b; a -= t * b; boost::swap(a, b); u -= t * v; boost::swap(u, v); } u %= m; if (u < 0) u += m; return u; }

struct Tmp
{
public:
  Tmp(int N);
  vector<bool> dp;
};

Tmp::Tmp(int N)
  : dp(N, false)
{}

void solve(void)
{
  int N, K; cin >> N >> K;
  vector<int> A(N);
  for(auto& a : A) cin >> a;

  vector<int> dp(K+1, false);
  for (int i = 1; i <= K; ++i) {
    for (const auto& a : A) {
      if (i-a < 0) {
        continue;
      }
      dp[i] |= !dp[i-a];
    }
  }

  auto ans = dp[K];
  cout << (ans ? "First" : "Second") << CRLF;
  return;
}

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

  solve();

  return 0;
}


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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  long long n, sum = 0, ans=1000000000000000000LL;
  cin >> n;
  vector<long long> vec(n);
  for (int i = 0; i < n; i++) {
    cin >> vec[i];
    sum += vec[i];
  }
  long long x=0;
  for (int i = 0; i < n-1; i++) {
    x += vec[i];
    ans = min(abs(sum - 2*x), ans);
  }
  cout << ans << '\n';
}


Measured memory_bytes: 1792
#include <iostream>
#include <map>
int main() {
	int n;
	std::cin >> n;
	std::map<int, int> map;
	for (int i = n; i > 0; --i) {
		std::cin >> n;
		if (map.find(n) == map.end()) {
			map[n] = 1;
		}
		else {
			++map[n];
		}
	}
	std::cin >> n;
	bool can_make = true;
	for (int i = n; i > 0; --i) {
		std::cin >> n;
		if (map.find(n) == map.end()) {
			can_make = false;
			break;
		}
		else {
			if (--map[n] < 0) {
				can_make = false;
				break;
			}
		}
	}
	if (can_make) std::cout << "YES" << std::endl;
	else std::cout << "NO" << std::endl;
}


Measured memory_bytes: 9600
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
const ll MOD = 1000000007;

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

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

ll mulMod(ll a, ll b)
{
    return (((a % MOD) * (b % MOD)) % MOD);
}

const string YES = "YES";
const string NO = "NO";

void solve(long long a, long long b, long long c)
{
    if (b - a == c - b)
    {
        cout << YES << endl;
    }
    else
    {
        cout << NO << endl;
    }
}

int main()
{
    long long a;
    scanf("%lld", &a);
    long long b;
    scanf("%lld", &b);
    long long c;
    scanf("%lld", &c);
    solve(a, b, c);
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cassert>
#include<climits>
#include<algorithm>
#include<vector>
#include<cstring>
#include<deque>

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)

using namespace std;

#define MAX 100010
int n, a[MAX];
int state[MAX];
bool visited[MAX];

#define FAIL 0
#define SUCC 1


void compute() {
  memset(state,-1,sizeof state);
  rep(i,n) {
    if( state[i] != -1 ) continue;
    memset(visited, false ,sizeof visited);
    deque<int> deq;
    int cur = i;
    deq.push_back(i);
    visited[i] = true;
    while(1) {
      cur = ( cur + a[cur] ) % n;
      deq.push_back(cur);
      if( state[cur] != -1 ) { // fail
	deq.pop_back();
	while( !deq.empty() ) {
	  state[deq.front()] = FAIL;
	  deq.pop_front();
	}
	break;
      }
      if( visited[cur] ) {
	int stop = cur;
	deq.pop_back();
	state[cur] = SUCC;
	while( deq.back() != stop ) {
	  state[deq.back()] = SUCC;
	  deq.pop_back();
	}
	assert( deq.back() == stop );
	deq.pop_back();
	while( !deq.empty() ) {
	  assert( state[deq.back()] == -1 );
	  state[deq.back()] = FAIL;
	  deq.pop_back();
	}
	break;
      } else {
	visited[cur] = true;
      }
    }
  }
  int answer = 0;
  rep(i,n) answer += ( state[i] == SUCC );
  cout << answer << endl;
}

int main() {
  if( 0 ) {
    srand((unsigned int)time(NULL));
    n = 100000;
    cout << n << endl;
    rep(i,n) {
      if( i ) printf(" ");
      //cout << rand() % 1000000000 + 1;
      cout << 1000000000;
    } puts("");
    return 0;
  }
  cin >> n;
  rep(i,n) cin >> a[i];
  compute();
  return 0;
}

Measured memory_bytes: 4280
#include <stdio.h>

// min
int main(void){
  int a1 = 0, a2 = 0, a3 = 0;
  int sum = 0;
  scanf("%d%d%d", &a1, &a2, &a3);

  sum = a1 + a2 + a3;

  if(sum >= 22){
    printf("bust\n");
  }else{
    printf("win\n");
  }

  return 0;

}


Measured memory_bytes: 128
#include <iostream>
#include <algorithm>

using namespace std;

int main(void){
    int q, n;
    cin >> q;
    for(int i = 0; i < q; i++){
        cin >> n;
        int cnt = 0;
        while(n >= 10){
            int d = 10;
            int ma = 0;
            while(int s = n / d){
                ma = max(s * (n - s * d), ma);
                d *= 10;
            }
            n = ma;
            cnt++;
        }
        cout << cnt << endl;
    }
}

Measured memory_bytes: 1160
D = int(input())
c = list(map(int, input().split()))
sdi = [list(map(int, input().split())) for i in range(D)]

import numpy as np

lastdi = [0 for i in range(26)]
ans_c = []



d = 0
while True:
  if d == D:
    break
  if d < D - 3:
    day_s = sdi[d]
    
    sloss = [day_s[i] + c[i]*(d - lastdi[i]) for i in range(26) ]
    ans = sloss.index(max(sloss))
    ans_c.append( ans+1 )
    
    for i in range(26):
      if i != ans:
        lastdi[i] += 1
    lastdi[ans] = d
    d += 1
    
  else:
    
    a = [sdi[d][i] + sdi[d+1][i2] + sdi[d+2][i3] - 3 * sum([c[k]*( d - lastdi[k] + 1) for k in range(26) if k not in [i,i2,i3]] ) for i in range(26) for i2 in range(26) for i3 in range(26)]
    idx = a.index(max(a))
    best_i3 = idx % 26 + 1
    best_i2 = (idx // 26) % 26 + 1
    best_i1 = idx // 676 + 1
    
    ans_c.append(best_i1)
    ans_c.append(best_i2)
    ans_c.append(best_i3)
    lastdi[best_i1-1] = d
    lastdi[best_i2-1] = d+1
    lastdi[best_i3-1] = d+2
    
    d += 3

for i in range(D):
  print(ans_c[i])


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


int main()
{
    int n;
    cin>>n;
    int w=0,r=0;
    vector<int>rindex,windex;
    vector<char>color(n);
    for(int i=0;i<n;i++){
        char c;
        cin>>c;
        if(c=='R'){r++;rindex.push_back(i);}
        else {w++;windex.push_back(i);}
        color[i]=c;
    }
    if(w==0||r==0)cout<<0<<endl;

    else{
       int ans=0;     bool ok=false;int pa=0;int f=0;
     for(int i=n-1;i>=0;i--){
            if(color[i]=='W')w--;
      if(color[i]=='R'&&w>0){
            swap(color[i],color[windex[f]]);
      f++;
      w--;
      ans++;
            }
     }
     for(int i=0;i<n-1;i++){
        if(color[i]=='W'&&color[i]=='R')ans++;
     }
     cout<<ans;
    }
    return 0;
}


Measured memory_bytes: 4628
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <bitset>
#include <iomanip>
#include <iostream>
#include <istream>
#include <map>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>
using namespace std;
using ll = long long;
class Solution {
public:
    void solve(std::istream& in, std::ostream& out) {
        ll n, a;
        in >> n >> a;
        ll b = n % 500;
        out << (a >= b ? "Yes" : "No") << endl;
    }
};
void solve(std::istream& in, std::ostream& out) {
    out << std::setprecision(12);
    Solution solution;
    solution.solve(in, out);
}
#include <fstream>
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    istream& in = cin;
    ostream& out = cout;
    solve(in, out);
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main {
	long n;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		Main m = new Main(sc);
		m.solve();
		sc.close();
	}

	Main(Scanner sc) {
		n = sc.nextLong();
	}

	void solve() {
		int root = (int)Math.pow(n, 0.5);
		long a,b;
		int min = Integer.MAX_VALUE;
		for(int i=1;i<=root;i++){
			if(n%i==0){
				a = i;b = n / i;
				min = Math.min(min, f(a,b));
			}
		}
		System.out.println(min);
	}
	int f(long a,long b){
		if(a>b){
			return String.valueOf(a).length();
		} else {
			return String.valueOf(b).length();
		}
	}
}

Measured memory_bytes: 23892
#include<bits/stdc++.h>
  
#define lol long long
#define gcd(x,y) __gcd(x,y)
#define mt make_tuple
#define mp make_pair
#define fi first
#define se second
#define fixed fixed<<setprecision(14)
using namespace std;
using pii=pair<int,int>;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
template <class A> inline lol abs(A &a) { return (a < 0 ? -a : a); }
template <class A, class B> inline A max(A a, B b){return(a>b?a:b);}
template <class A, class B> inline A min(A a, B b){return(a<b?a:b);}
const lol inf=(1LL<<60);
const lol MOD=(1e9)+7;
const lol mod=998244353;
const int dx[]={1,0,-1,0,1,1,-1,-1};
const int dy[]={0,1,0,-1,1,-1,1,-1};
lol n,m,k,r;
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  lol ans=0;
  int a,b,c;
  cin >>a>>b>>c>>k;
  ans+=min(k,a);
  k-=min(k,a);
  k-=min(k,b);
  ans-=min(k,c);
  cout <<ans<<'\n';
  return (0);
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
ll GetDigit(ll num){ return log10(num)+1; } //numの桁数を求める

int main()
{
    int a, b;
    cin >> a >> b;
    cout << a + (b/2) <<endl; 
    return 0;
}

Measured memory_bytes: 3540
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)

#debug = True
debug = False

def dprint(*objects):
    if debug == True:
        print(*objects)

def solve():
    l = input().rstrip('\n')
    n = len(l)
    # 制約1 a+b は L 以下
    # 制約2 a と b で同じけたは 00 01 10 のいずれか

    mx = 10**9 + 7
    same = 1 # iまでの a+b が l と等しい（a+b <= L となるかは次の桁で気をつける必要あり）
    diff = 0 # iまでの a+b が l と異なっている（すでに a+b <= L が確定）

    for i in range(n):
        if l[i] == "1":
            same_tmp = same * 2
            diff_tmp = same * 1 + diff * 3
        else:
            same_tmp = same * 1
            # diff_tmp = same * 2 + diff * 3 ×sameで次の桁が0の場合、次の桁を1にはできない
            diff_tmp = diff * 3
        same = same_tmp % mx
        diff = diff_tmp % mx

        dprint(i, l[i], same, diff)

    print((same + diff) % mx)

solve()

Measured memory_bytes: 39792
#include<iostream>
#include<algorithm>
#include<string>
#include<math.h>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
#include<functional>
#include<map>
#include<set>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)

map<string, int> mp;

int main() {
    int n, k;
    cin >> n >> k;
    int ans = k;
    for (int i = 1; i < n;i++) {
        ans *= (k - 1);
    }
    cout << ans << endl;
}

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


int main() {
  int a,b;
  cin >> a >> b;
  if(1<=a && a<=9 && 1<=b && b<=9){
    cout << a*b << endl;
  }
  else{
    cout << "-1" << endl;
  }
}

        
      
      


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define FOR(i,a,b) for(int i=a;i<=b;++i)
using namespace std;

const int mn=100,mub=12806;
int a[mn][mn],b;
bool f[mn][mn][mub];

int main()
{
	int n,m;
	scanf("%d%d",&n,&m);
	FOR(i,1,n) FOR(j,1,m) scanf("%d",&a[i][j]);
	FOR(i,1,n) FOR(j,1,m) {scanf("%d",&b);a[i][j]=abs(a[i][j]-b);}
	f[1][1][a[1][1]]=1;
	FOR(i,1,n) FOR(j,1,m) {
		FOR(k,0,mub-6) {
			if(!f[i][j][k]) continue;
			f[i][j+1][k+a[i][j+1]]=f[i][j+1][abs(k-a[i][j+1])]=1;
			f[i+1][j][k+a[i+1][j]]=f[i+1][j][abs(k-a[i+1][j])]=1;
		}
	}
	FOR(k,0,mub-6) if(f[n][m][k]) {printf("%d",k);break;}
}

Measured memory_bytes: 100992
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
//for(int i = 0; i<n; i++)


int main()
{
    string s;
    cin>> s;
    vector<int> c(26,0);
    for(int i = 0; i<(int)s.size(); i++){
        c[s[i] - 'a']++;
    }
    int i;
    bool e = false;
    for(i = 0; i<26;i++){
        if(c[i] == 0) {e = true;break;}
    }
    if(e) cout << (char) (i + (int)'a') << endl;
    else cout << "None" << endl;
    return 0;
}

Measured memory_bytes: 512
gets;s=gets.strip;t=gets.strip;n,m=s.size,t.size;(puts -1;exit)if s[0]!=t[0];e=n.lcm m;h={};n.times{|i|h[i*e/n]=s[i]};m.times{|i|w=h[i*e/m];(puts -1;exit)if !w.nil?&&w!=t[i]};puts e

Measured memory_bytes: 11772
#include<stdio.h>
int main(void){
  int a,b,c;
  int o=0;
  int i=0;
  for(i=0;i<3;i++){
    scanf("%d %d %d",&a,&b,&c);
    for(i=a;i<=b;i++){
      if(c%i == 0){
	o++;
	  
    };
    };
  };
   printf("%d\n",o);
 return 0;
}

Measured memory_bytes: 596
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    istream& in(cin);
    ostream& out(cout);
    int n;
    in>>n;
    cout<<(n+1)/2<<endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;

namespace ABC084Test
{
    class Program
    {
        static void Main()
        {
            int Q = int.Parse(Console.ReadLine().Trim());
            const int maxnum = (int)1e5;
            List<int> l = new List<int>();
            List<int> r = new List<int>();
            l.Add(0);
            r.Add(0);
            for (int i = 1; i <= Q; i++) {
                var buff = Console.ReadLine().Trim().Split();
                l.Add(int.Parse(buff[0]));
                r.Add(int.Parse(buff[1]));
            }
            
            List<int> is_prime = new List<int>();
            List<int> is_prime2 = new List<int>();

            
            for (int i = 0; i <= maxnum; i++)
            {
                is_prime.Add(1);
                is_prime2.Add(0);
            }


            //エラストテネスのふるい
            int max = (int)Math.Sqrt(maxnum) +1;
            for (int k = 1; k <= max; k++) {
                if (k == 1) continue;
                for (int j = 1; k * j <= maxnum; j++) {
                    if (j == 1) continue;
                    int index = k * j;
                    is_prime[index] = 0;
                }
            }

            for (int k = 1; k <= maxnum; k++) {
                int u = (k + 1) / 2;
                if (is_prime[u] == 1) is_prime2[k] = 1;
            }

            List<int> sum = new List<int>();
            sum.Add(0); //sum[0]は0にしとく
            for (int k = 1; k <= maxnum; k++) {
                int sumbuff = sum[k - 1];
                if (k <= 2) {
                    sum.Add(sumbuff);
                    continue;
                }
                sum.Add(sumbuff + (is_prime[k] * is_prime2[k]));
            }

            //ここまで事前準備

            for (int i = 1; i <= Q; i++) {
                int rbuf = r[i];
                int lbuf = l[i]-1;
                int diff = sum[rbuf] - sum[lbuf];
                Console.WriteLine(diff);
            }


        }

    }

}


Measured memory_bytes: 43776
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
typedef long long ll;
const int inf = 1e9;
int main(){
    int n, k; 
    cin >> n >> k;
    vector<int> a(n), dp(n+1, 0);
    rep(i,n)cin >> a[i];
    REP(i,1,n){
        int mi = inf;
        REP(j, max(0, i-k), i){
            mi = min(mi, dp[j] + abs(a[i] - a[j]));
            //cout << dp[i-j] + abs(a[i] - a[j]) << ((j < i-1)?" ":"\n");
        }
        dp[i] = mi;
    }
    cout << dp[n-1] << endl;
    //rep(i,n)cout << dp[i] << ((i < n-1)?" ":"\n");
    return 0;
}

Measured memory_bytes: 1024
s=input()
flag = "AC"
if s[0] != "A":
    flag = "WA"
else:
    if not "C" in s[2:-1]:
        flag = "WA"
    else:
        ls = [c for c in s]
        ls.remove("A")
        ls.remove("C")
        for c in ls:
            if c.isupper():
                flag = "WA"
print(flag)

Measured memory_bytes: 38416
import java.util.*;

class Main{
    public static void main(String[] args){

        Scanner sc = new Scanner(System.in);
        int intInput1 = sc.nextInt();
        int intInput2 = sc.nextInt();
        int ans = 0;

        System.out.println(intInput2 * 2 - intInput1);

    }
}


Measured memory_bytes: 23380
#include <iostream>
#include <string>
#include <algorithm>

int main(void) {
  int n;

  std::string str;
  std::cin >> str;
  n = std::stoi(str);

  int count = 0;
  int sosuu[10000] = {0};
  //int index[55555]  = {0};

  for (int i = 2; i <= 55555; ++i) {
    bool is_sosuu = true;
    for (int j = 0; j < count; ++j) {
      if (i % sosuu[j] == 0) {
        is_sosuu = false;
      }
    }
    //if (count > 0) {
    //  //std::cout << sosuu[count - 1] + 1 << " --> " << i / 2 << std::endl;
    //  for (int j = sosuu[count - 1] + 1; j <= i / 2; ++j) {
    //    if (i % j == 0) {
    //      is_sosuu = false;
    //    }
    //  }
    //}
    if (is_sosuu) {
      sosuu[count++] = i;
      //index[i] = 1;
    }
  }

  //for (int i = 0; i < count; i++) {
  //  std::cout << i << " : " << sosuu[i] << std::endl;
  //}

  size_t ncount = 0;
  int result[n] = {0};
  for (size_t i = 0; i < count; i++) {
    if (sosuu[i] % 5 == 1) {
      result[ncount] = sosuu[i];
      ncount++;

      if (ncount == n) {
        break;
      }
    }
  }

  std::cout << result[0];
  for (size_t i = 1; i < n; i++) {
    std::cout << " " << result[i];
  }
  std::cout << std::endl;

  return 0;
}

Measured memory_bytes: 256
n, p = map(int, input().split())
a = list(map(int,input().split()))

odd = []
even = []
for i, aa in enumerate(a):
    if aa % 2 == 0:
        even.append(aa)
    else:
        odd.append(aa)
e = len(even)
o = len(odd)
ans = 2 ** e
od_list = [1]
bunsi = 1
bunbo = 1

for i in range(1,o+1):
    bunsi *= o - i + 1
    bunbo *= i
    od_list.append(bunsi//bunbo)
even_i = od_list[::2]
odd_i = od_list[1::2]
# print(o)
# print(od_list)
if p == 0:
    print(ans * sum(even_i))
    # print(even_i)
else:
    print(ans * sum(odd_i))


Measured memory_bytes: 3064
import java.util.*;
     
    public class Main {
    	public static void main(String[] args) {
    		Scanner sc = new Scanner(System.in);
    		int n = sc.nextInt();
    		boolean[] prime = new boolean[1000];
    		/*	prime[i - 1] : iが素数	*/
    		prime[1 - 1] = false;
    		for(int i = 2; i <= 1000; i++)
    			prime[i - 1] = true;
    		for(int i = 1; i <= 1000; i++) {
    			if(prime[i - 1]) {
    				for(int j = 2; i*j <= 1000; j++)
    					prime[i*j - 1] = false;
    			}
    		}
    		int[] counter = new int[1000];
    		/*	n!が素因数iをcounter[i - 1]個持つ	*/
    		for(int i = 1; i <= 1000; i++)
    			counter[i - 1] = 0;
    		for(int i = 1; i <= n; i++) {
    			for(int j = 1; j <= i; j++) {
    				if(prime[j - 1]) {
    					int x = i;
    					int count = 0;
    					while(x%j == 0) {
    						x = x/j;
    						count++;
    					}
    					counter[j - 1] += count;
    				}
    			}
    		}
    		long result = 1;
    		for(int i = 1; i <= 1000; i++)
    			result = (result*(counter[i - 1] + 1))%1000000007;
    		System.out.println(String.valueOf(result%1000000007));
    	}
    }

Measured memory_bytes: 9932
#include<iostream>
#include<math.h>
#include<bits/stdc++.h>
#define ll long long int
#define hell 1000000007LL
using namespace std;
ll power(ll x, ll y, ll z){ 
    if(y==0)
     return 1;
    else
    {
        ll p=power(x,y/2,z);
        if(y%2==0)
         return (p*p)%z;
        else
        return (x*((p*p)%z))%z;
    }}
ll gcd(ll x,ll y)
{
    if(y==0)
     return x;
    else
    return gcd(y,x%y);
}
ll po(ll x)
{
    ll c=0;
    while(x>0)
    {
        x=x&(x-1);
        c++;
    }
    return c;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(20);
    ll q,b;
    cin>>q>>b;
    if(q>=b)
    cout<<10;
    else
    cout<<0;}

Measured memory_bytes: 3660
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <stdio.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <sstream>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort(ALL(x))
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

int n;
int p[1001001], q[1001001];

signed main(){
	cin>>n;
  rep(i,n) cin>>p[i], q[p[i]]=i+1;
  int ret = 1, sub = 1;
  reps(i,n-1){
    if(q[i]<q[i+1]) ret++;
    else{
      sub = max(sub,ret);
      ret = 1;
    }
  }
  sub = max(sub,ret);
  cout << n-sub << endl;
	return 0;
}


Measured memory_bytes: 5120
x,y=z=[0,1].map{[0]*2e5}
`sed 1d`.split.map{|v|z[1&$.+=1][v.to_i]-=1}
a,b=x.sort
c,d=y.sort
p$..+a!=x[y.index c]?a+c:[a+d,b+c].min

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

int main() {
  int X;
  cin >> X;
  int m = X % 100;
  int cnt = (m / 5) + m % 5;
  if (X == 102 || X == 103 || X == 104 || cnt <= X / 100)
    cout << 1 << endl;
  else
    cout << 0 << endl;
  return 0;
}

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

using namespace std;

const long long int MOD = 1000000007;

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

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

	string s;
	cin >> s;
	cin >> N;
	for (int i = 0; i < s.size(); i += N)cout << s[i];
	cout << endl;
	return 0;
}

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

int main(void) {
	int N, A;
	cin >> N >> A;
	if (A>=499 ||  N % 500 <= A)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define int long long
const long long mod = 1000000007;
int x[100006];
signed main() {
	int n; cin >> n;
	rep(i, n)cin >> x[i];
	int now = 1;
	rep(i, n) {
		if (now <= x[i]) {
			x[i] = now; now += 2;
		}
		else {
			now = x[i] + 1;
		}
	}
	queue<int>Q;
	rep(i, n - 1) {
		if (x[i + 1] - x[i] == 1)Q.push(i);
	}
	int res = 1, rem = 0;
	while (Q.size()) {
		int q = Q.front(); Q.pop();
		if (Q.size())Q.pop();
		res *= (q + 2 - rem);
		res %= mod;
		rem++;
	}
	rep(i, n-rem) {
		res *= i + 1; res %= mod;
	}
	cout << res << endl;
}


Measured memory_bytes: 1792
import java.util.Scanner;

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

      int h = s / (60 * 60);
      s -= h * 60 * 60;

      int m = s / 60;
      s -= m * 60;

      System.out.println(h + ":" + m + ":" + s);
      sc.close();
  }
}


Measured memory_bytes: 26244
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <random>
#include <chrono>
#include <tuple>
#include <random>
#include <cmath>

using namespace std;

typedef long long ll;
typedef long double ld;
#define fastInp cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);

const ll SIZE = 1e6 * 2 + 10, INF = 1e9 * 1e9 + 10, MOD = 1e9 + 7;

ll dsu[SIZE], sz[SIZE];

ll find(int v) {
    if (dsu[v] == v) return v;
    else return dsu[v] = find(dsu[v]);
}

void uni(int v, int u) {
    v = find(v);
    u = find(u);
    if (u != v) {
        sz[v] += sz[u];
        dsu[u] = v;
    }
}

int main()
{
    fastInp;
    
    ll n;
    cin >> n;
    vector<ll> vec(n);
    for (int i = 0; i < n; i++) cin >> vec[i];

    ll s = 0, ans = 0;
    for (int i = 0; i < n; i++) {
        ans += s * vec[i];
        ans %= MOD;
        s += vec[i];
        s %= MOD;
    }

    cout << ans;

    return 0;
}

Measured memory_bytes: 4780
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    n,m=map(int, input().split())
    if n==1 and m==1:
        ans=1
    # n,m=1,1を除外してるからどっちか１だったら他方の-2でok
    elif m==1:
        ans=n-2
    elif n==1:
        ans=m-2
    else:
        ans=(n-2)*(m-2)
    print(ans)
resolve()


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
 
#define froop1(a,n) for(int i = a;i < n;i++)
#define froop2(a,n) for(int i = a;i > n;i--)
 
#define ll long long
 
#define pq(name,type) priority_queue<type> name
#define vec(name,type,length,value) vector<type> name(length,value)
#define vec2(name,type,length,width,value) vector<vector<type>> name(length,vector<type>(width,value));
 
int main(){
	int N;
	cin >> N;
  int c = N;
  froop1(1,3)
  {
    c *= N;
  }
  cout << c << endl; 
return 0;
}

Measured memory_bytes: 3644
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <string>
#include <queue>
using namespace std;
#define SZ(v) ((int)(v).size())
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repf(i, a, b) for (int i = (a); i <= (b); ++i)
const int maxint = -1u>>1;
const int maxm = 200000 + 2;
const int maxn = 20 + 1;

double f[maxn][maxm];
int n;
int a[maxn];

double calc(int a, int b) {
    return ((double)(abs(b - a)) / a);
}

int main() {
    //printf("%lf\n", calc(11, 12));
    while (scanf ("%d", &n) != EOF) {
        for (int i = 1; i <= n; ++i) {
            scanf("%d", &a[i]);
        }
        sort(a + 1, a + n + 1);
        for (int i = 0; i <= n; ++i) fill(f[i], f[i] + maxm, 1);
        f[0][1] = 0;
        for (int i = 0; i < n; ++i) {
            for (int j = 1; j < maxm; ++j) {
                for (int k = j; k < maxm; k += j) {
                    f[i + 1][k] = min(f[i + 1][k], max(f[i][j], calc(a[i + 1], k)));
                }
            }
        }
        double ans = 1;
        for (int i = 1; i < maxm; ++i) {
            ans = min(ans, f[n][i]);
        }
        printf("%.12lf\n", ans);
    }
    return 0;
}

Measured memory_bytes: 32000
#include "bits/stdc++.h"
using namespace std;

#define db(x) cerr << #x << " == " << x << endl
#define all(container) container.begin(), container.end()
#define mp(i,j) make_pair(i,j)
#define pb push_back

typedef pair<int,int> pii;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<pii> vii;

template<typename T>
void print_vector_debug(const T& t) {
	cout << "[DEBUG] VECTOR:";
	for (auto i = t.cbegin(); i != t.cend(); ++i) {
		if ((i + 1) != t.cend()) {
			cout << *i << " ";
		} else {
			cout << *i << endl;
		}
	}
}

#define MAXN 100005

int N;
int vals[MAXN][3];
int vis[MAXN][4], dp[MAXN][4];

int solve(int idx, int last)
{
	if (idx == N)
	{
		return 0;
	}
	
	if (vis[idx][last])
	{
		return dp[idx][last];
	}
	vis[idx][last] = 1;
	
	int res = 0;
	
	for (int i = 0; i < 3; i++)
	{
		if (i != last)
		{
			res = max(res, solve(idx + 1, i) + vals[idx][i]);
		}
	}
	
	dp[idx][last] = res;
	return res;
	
}

int main() 
{
	scanf("%d", &N);
	
	for (int i = 0; i < N; i++)
	{
		scanf("%d%d%d", &vals[i][0], &vals[i][1], &vals[i][2]);
	}
	
	printf("%d\n", solve(0, 3));
	
	return 0;
}


Measured memory_bytes: 12288
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        Set<Integer> set = new HashSet<>();
        for (int i = 0; i < k; i++) {
            int d = sc.nextInt();
            for (int j = 0; j < d; j++) {
                int a = sc.nextInt();
                set.add(a);
            }
        }
        int ans = 0;
        for (int i = 1; i <= n; i++) {
            if (!set.contains(i)) {
                ans++;
            }
        }
        System.out.println(ans);
    }

}


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

struct t{
    string cad;
    int score, pos;
};

bool order(t a, t b){

    if(a.cad < b.cad){
        return true;
    }
    else if(a.cad == b.cad){
        if(a.score > b.score) return true;
        else return false;
    }
    else{
        return false;
    }
}

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

    int n;
    while(cin>>n){
        t v[110];
        string c;
        int s;
        for(int i=0;i<n;i++){
            cin>>c>>s;
            v[i].cad = c;
            v[i].score = s;
            v[i].pos = i+1;
        }

        sort(v, v+n, order);

        for(int i=0;i<n;i++){
            cout<<v[i].pos<<endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
// typedef __int128_t Int;
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF =
    sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
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 (a > b) {
    a = b;
    return true;
  }
  return false;
}

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(12);

  string s;
  cin >> s;
  int w;
  cin >> w;
  string ans;
  for (int i = 0; i < s.size(); i += w) {
    ans += s.substr(i, 1);
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cstdint>
#include <cassert>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (size_t i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (size_t i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

i64 n;
vector<i64> p;
int main() {
  cin >> n;
  read_n(p, n, 1);
  i64 s = 0;
  for (i64 i = 1; i <= n; ++i) {
    if (i != p[i]) s++;
  }
  cout << (s <= 2 ? "YES\n" : "NO\n");
  return 0;
}


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

// def
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
#define repeat(i, a, b) for (int i = (a); i < (b); i++)
#define revrepeat(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define revrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define CYES cout << "Yes" << endl
#define CNO cout << "No" << endl
#define SPC(x) cout << fixed << setprecision(x)
#define ZERO(a) memset(a, 0, sizeof(a))
#define MINUS(a) memset(a, 0xff, sizeof(a))

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int>> vii;
typedef vector<ll> vl;
typedef vector<vector<ll>> vll;
typedef pair<int, int> P;
typedef complex<ld> Point;
const int MOD = 1e9 + 7;
const int INF = 1e9;
const int MAX_V = 1e5 + 5;
const int MAX_N = 1e5 + 5;
const double PI = acos(-1);

int main() {
    int n, k;
    cin >> n >> k;
    vi h(n);
    rep(i, n) cin >> h[i];
    int ans = 0;
    rep(i, n) if (h[i] >= k) ans++;
    out(ans);
    return 0;
}


Measured memory_bytes: 640
a,b=map(int,input().split())

if a%2==0:
    fa=(a//2)%2
else:
    fa=(((a-1)//2)%2)^(a-1)

if b%2==0:
    fb=((b//2)%2)^b
else:
    fb=((b+1)//2)%2
    
print(fb^fa)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define ld long double
#define mk make_pair
#define fi first
#define se second
#define vll vector<ll>
#define pii pair<ll,ll>
#define vvll vector< vector<ll> >
#define pb push_back
#define sz(v) (v).size()
#define inf 1e18
#define md 1000000007
#define all(v) (v).begin(),(v).end()
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define tel(a){cout<<a<<"\n";}
#define tell(a,b){cout<<a<<" | "<<b<<"\n";}
#define telll(a,b,c){cout<<a<<" | "<<b<<" | "<<c<<"\n";}
#define teln(v,n){cout<<"v- ";rep(i,0,n)cout<<v[i]<<" ";cout<<"\n";}
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define tihs if(fopen("inp.txt","r"))freopen("inp.txt", "r", stdin),freopen("out.txt", "w", stdout);
using namespace std;
#define TRACE
 
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
 

#define M 110
#define N 100010
ll n,k,a[M],dp[N];
ll f(ll x){
	if(!x) return 0;
	if(dp[x]!=-1) return dp[x];
	bool ok=0;
	rep(i,0,n)
	if(x>=a[i])ok |= !f(x-a[i]);
	// trace(x,ok);
	return dp[x]=ok;
}
int main(){
	IOS;
	tihs;
	memset(dp,-1,sizeof(dp));
	cin>>n>>k;
	rep(i,0,n)cin>>a[i];
	if(f(k))cout<<"First";
	else cout<<"Second";

	return 0;
}

Measured memory_bytes: 4224
// #[proconio::fastout]
fn main() {
    let a: Vec<usize> = (0..5).map(|_| read::<usize>()).collect();
    let mut cnt = 1;
    for e in a {
        if e == 0 {
            println!("{}", cnt);
            exit(0);
        }
        cnt += 1;
    }
}

// =========
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet};
#[allow(unused_imports)]
use std::process::exit;

#[allow(dead_code)]
const MOD: usize = 1000000007;

fn read<T: std::str::FromStr>() -> T {
    use std::io::Read;
    let stdin = std::io::stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

// =========


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

int main() {
  int a, b; cin >>a >>b;
  bool ans = false;
  if (a==1||a==3||a==5||a==7||a==8||a==10||a==12){
    if (b==1||b==3||b==5||b==7||b==8||b==10||b==12){
      ans = true;
    }
  }else if (a==4||a==6||a==9||a==11){
    if (b==4||b==6||b==9||b==11){
      ans = true;
    }
  }else if (a==2 && b==2){
    ans = true;
  }
  
  if (ans) cout <<"Yes" <<endl;
  else cout <<"No" <<endl;
}


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


int main(){

	int i, n, sc_t, sc_h, ret;
	char tc[101], hc[101];

	sc_t=0; sc_h=0;

	scanf( "%d", &n );

	for( i=0; i<n; i++ ){

		scanf( "%s %s", tc, hc );
		
		
		ret = strcmp( tc, hc);
		if( ret < 0) sc_h += 3;
		else if( ret > 0) sc_t += 3;
		else{ sc_t++; sc_h++; }

	}

	printf( "%d %d\n", sc_t, sc_h );

	return 0;

}

Measured memory_bytes: 604
var
	N,i:Longint;
	d:Array[1..100000]of Longint;
function bs(x:Longint):Longint;
var L,R,M,cnt,i:Longint;
begin
	L:=0;
	R:=100000;
	while R-L>1 do begin
		M:=(L+R)div 2;
		cnt:=0;
		for i:=1 to N do if d[i]<=M then inc(cnt);
		if cnt>=x then R:=M else L:=M;
	end;
	bs:=R;
end;
begin
	read(N);
	for i:=1 to N do read(d[i]);
	writeln(bs(N div 2+1)-bs(N div 2));
end.


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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

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

    ll N;
    cin >> N;
    vector<pll> A(N);
    REP(i, N){
    	cin >> A[i].first;
    	A[i].second = i;
    }
    sort(A.begin(), A.end());
    ll sum = 0;
    REP(i, N){
    	if(A[i].second%2 != i%2) sum++;
    }
    cout << sum/2 << endl;
    return 0;
}

Measured memory_bytes: 1792
#include"iostream"

using namespace std;

int main()
{
	int s;
	cin >> s;
	int a[100000] = { 0 };
	a[1] = s;
	int num = 1;
	int min = 1000;
	int c = 0;
	while (1) {
		if (a[num] % 2 == 0) {
			a[num + 1] = a[num] / 2;
		}
		else {
			a[num + 1] = a[num] * 3 + 1;
		}
		for (int i=1; i < num; i++) {
			if (a[i] == a[num + 1]) {
				c = 1;
			}
		}

		num++;
		if (c == 1) { cout << num << endl; break; }

	}

}

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

#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define reps(i, n) for (int i = 1; i <= (int)n; i++)
#define vi vector<int>

#define ll long long
#define vl vector<ll>
#define vll vector<vl>
#define pb push_back

const int INF = 1e9;

int main() {
	int n;
	cin >> n;
	vl a(n+1);
	rep(i, n+1) cin >> a[i];
	ll x=1, sum=0;
	rep(i, n+1) sum+=a[i];
	bool muri=false;
	ll ans=0;
	rep(i, n)
	{
		ans+=x;
		if(x<=a[i])
		{
			muri=true;
			break;
		}
		x-=a[i];
		sum-=a[i];
		if(x*2>=sum) x=sum;
		else x*=2;
	}
	if(!muri && x==sum)
	{
		ans+=a[n];
		cout << ans << endl;
	}
	else cout << "-1" << endl;
	return 0;
}

Measured memory_bytes: 4052
#include <bits/stdc++.h>
#include<cmath>
#define N 100005
#define A 1000005
#define MOD 1000000007 // //100000000 998244353 //
#define inf 1000000000000000000
#define ll long long
//#define M_PI 3.141592653589793238463

using namespace std;

#define pii pair<ll, ll>
#define piii pair<ll, pii>
#define ft first
#define sd second
#define pb push_back
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n-1; i >= 0; i--)
#define itr(it, x) for(auto it = x.begin(); it != x.end(); it++)
#define mem(a, b) memset(a, (ll)b, sizeof(a))
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define edge(v, x, y) v[x].pb(y); v[y].pb(x);
#define popcount __builtin_popcount
#define ANS(s) {cout << s << "\n"; return;}

//~~~~~~fancy print~~~~~~~//
#define printpii(a) cout << a.ft << " " << a.sd << endl;
#define printpiii(a) cout << a.ft << " " << a.sd.ft << " " << a.sd.sd << endl;
#define print(a, n) rep(i, n) cout << a[i] << " "; cout << endl;
#define printv(v) for(auto x: v)cout << x << " "; cout << endl;
#define printm(a, n, m) rep(i, n) { rep(j, m) cout << a[i][j] << "\t"; cout << endl;}

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

void fast(){ios_base::sync_with_stdio(false);cin.tie(0);cout << setprecision(12) << fixed;}


void solve(){
    ll n, m;
    cin >> n >> m;
    vector<pii> v;
    rep(i, n)
    {
        ll x, y; cin >> x >> y; v.pb({x, y});
    }
    sort(all(v));
    ll t = 0;
    rep(i, n)
    {
        ll k = min(m, v[i].sd);
        m -= k;
        t += k * v[i].ft;
    }
    cout << t;
}
main(){
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif*/
    fast();
    ll t = 1; //cin >> t;
    while(t--){
        solve();
    }
}


Measured memory_bytes: 2548
#include <time.h>

#include <stdlib.h>
#include <cstdint>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <limits>
#include <cstdint>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <limits>
#include <vector>
#include <map>
#include <set>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <bitset>
#include <iterator>
#include <deque>
using namespace std;
const int64_t INF=10000000000000000;

int main(){
	double n;
	cin>>n;
	cout<<ceil(n/2)<<endl;


}


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

#define rep(i, n) for ( int i = 0; i < (n); ++i )
using namespace std;
using ll =  long long;
using P = pair<int, int>;

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

	ll i;
	for ( i = 1; i <= 9; ++i ) {
		if ( ((n % i) == 0) && ((n / i) <= 9) ) {
			cout << "Yes" << endl;
			return 0;
		}
	}

	cout << "No" << endl;
	return 0;
}


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

#define REP(i,n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> pint;
template <class T> inline void chmax(T &a, const T b) { a = max(a, b); }
template <class T> inline void chmin(T &a, const T b) { a = min(a, b); }
template <class T> void pp(T v, int n) { REP(i,n) cout<<v[i]<< ' '; cout << endl; }

void inline TorF(bool tf, const string &trueMessage, const string &falseMessage) { 
  cout << (tf ? trueMessage : falseMessage) << endl;
}
void inline YESNO(bool tf) { TorF(tf, "YES", "NO"); }
void inline YesNo(bool tf) { TorF(tf, "Yes", "No"); }

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


Measured memory_bytes: 256