akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i) = 0; (i) < (n); ++(i))
#define rrep(i,n) for(int (i) = (n) - 1; (i) >= 0; --(i)) //Reversi rep
#define nfor(i,a,b) for(int (i) = (a); (i) < (b); ++(i)) //Natural for
#define rfor(i,a,b) for(int (i) = (b) - 1; (i) >= (a); --(i)) //Reversi for
#define ll long long
#define mod (1000000007)
#define YES cout << "YES" << endl;
#define Yes cout << "Yes" << endl;
#define yes cout << "yes" << endl;
#define NO cout << "NO" << endl;
#define No cout << "No" << endl;
#define no cout << "no" << endl;

int asc(const void *a, const void *b) {
    return *(int *)a - *(int *)b;
}

int desc(const void *a, const void *b) {
    return *(int *)b - *(int *)a;
}

int main()
{
    int n,d,ans = 0;
    double cnt = 0;
    cin >> n >> d;
    int x[n][d];
    rep(i, n)rep(j, d)cin >> x[i][j];
    rep(i, n){
        nfor(j, i + 1, n){
            cnt = 0;
            rep(k, d){
                cnt += abs((x[i][k] - x[j][k]) * (x[i][k] - x[j][k]));
            }
            cnt = sqrt(cnt);
            if (cnt == (int)cnt) {
                ++ans;
            }
        }
    }
    cout << ans << endl;
    return 0;
}


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

double func(double x){
    return x * x;
}

double rectangle_method(double a, double b, int n) {
  double acc = 0, d = (b - a) / n;
  for (int i = 0; i < n; i++) {
    acc += func(a + i * d) * d;
  }
  return acc;
}

int main(){
    int d;
    while(scanf("%d",&d) != EOF){
        cout << (int)rectangle_method(0, 600, 600/d) << endl;
    }

    return 0;
}


Measured memory_bytes: 3144
#include <bits/stdc++.h>
#define F first
#define S second

using namespace std;
typedef long long int64;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int n, m;
	cin >> n >> m;
	int64 sum = 0;
	for (int i = 0; i < m; ++ i) {
		int64 a;
		cin >> a;
		sum += a;
	}
	cout << (sum > n ? -1 : n - sum);	
}

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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) (x).begin(),(x).end()

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

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



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

    int k;
    string s;
    cin >> k >> s;

    if(s.size() <= k){
        cout << s << "\n";
    }else{
        for (int i = 0; i < k; ++i) {
            cout << s[i];
        }
        cout << "..." << "\n";
    }


    return 0;
}


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

#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

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

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const int dy[] = {0, 1, 0, -1, -1, 1, 1, -1};
const int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};

inline bool inside(int y, int x, int H, int W) {
    return (y >= 0 && x >= 0 && y < H && x < W);
}

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  string s; cin>>s;
  int n=s.size();
  map<char,int> m;
  rep(i,n){
    m[s[i]]++;
  }
  rep(i,n){
    for(auto c: m){
      char now=c.first;
      bool ok=true;
      rep(j,n-i){
        bool tmp=false;
        for(int k=0; k<=i; k++){
          if(s[j+k]==now) tmp=true;
        }
        if(!tmp){
          ok=false;
          break;
        }
      }
      if(ok){
        cout<<i<<endl;
        return 0;
      }
    }
  }
}

Measured memory_bytes: 256
<?php

while ($stdin = fgets(STDIN)) {
    $line[] = trim($stdin);
}
foreach ($line as $key => $value) {
    $data[] = explode(' ', $value);
}

//foreach ($data as &$line) {
//    $line = array_map(function($val) { return (int)$val; }, $line);
//}

$N = $data[0][0];
$A = $data[1];

$min = null;
$sum = 0;
$minusCnt = 0;
for ($i = 0; $i < $N; $i++) {
    $abs = abs($A[$i]);
    if (is_null($min) || $min > $abs) {
        $min = $abs;
    }
    $sum += $abs;
    if ($A[$i] < 0) {
        $minusCnt++;
    }
}

if ($minusCnt % 2 === 1) {
    $sum -= $min * 2;
}
$ans = $sum;

printf('%d', $ans);

?>


Measured memory_bytes: 14840
def main():
  N,M = map(int,input().split())
  MOD = 10**9 + 7
  if abs(N-M) > 1:
    print(0)
    return
  if N == M:
    ret = 2
    for i in range(2,N+1):
      ret = (ret*i*i)%MOD
  else:
    ret = 1
    M,N = min(M,N),max(M,N)
    for i in range(2,M+1):
      ret = (ret*i*i)%MOD
    for i in range(M+1,N+1):
      ret = (ret*i)%MOD
  print(ret)

main()

Measured memory_bytes: 3188
"""
    こんにちは。これはクシャルです
    
    Author : thekushalghosh (クシャル)
    Team   : CodeDiggers
 
    I prefer Python language over the C++ language :p :D
        
    Visit my website : thekushalghosh.github.io
"""
import sys,math,cmath,time
start_time = time.time()
##########################################################################
################# ---- THE ACTUAL CODE STARTS BELOW ---- #################

def solve():
    a = inlt()    
    print(a.index(0) + 1)
            
################## ---- THE ACTUAL CODE ENDS ABOVE ---- ##################
##########################################################################
 
def main():
    global tt
    if not ONLINE_JUDGE:
        sys.stdin = open("input.txt","r")
        sys.stdout = open("output.txt","w")
    t = 1
    for tt in range(t):
        solve()
    if not ONLINE_JUDGE:
        print("Time Elapsed :",time.time() - start_time,"seconds")
        sys.stdout.close()
    
#---------------------- USER DEFINED INPUT FUNCTIONS ----------------------#
def inp():
    return(int(input()))
def inlt():
    return(list(map(int,input().split())))
def insr():
    return(input().strip())
def invr():
    return(map(int,input().split()))
 
#------------------ USER DEFINED PROGRAMMING FUNCTIONS ------------------#
def counter(a):
    q = [0] * max(a)
    for i in range(len(a)):
        q[a[i] - 1] = q[a[i] - 1] + 1
    return(q)
 
def string_counter(a):
    q = [0] * 26
    for i in range(len(a)):
        q[ord(a[i]) - 97] = q[ord(a[i]) - 97] + 1
    return(q)

def power_two(n):
    if n == 1:
        return(True)
    sttr = str(n)
    len_str = len(sttr)
    sttr = list(sttr)
    num = 0
    if (len_str == 1 and sttr[len_str - 1] == '1'): 
        return(False)
    while (len_str != 1 or sttr[len_str - 1] != '1'):
        if ((ord(sttr[len_str - 1]) - ord('0')) % 2 == 1):
            return(False)
        j = 0; 
        for i in range(len_str):  
            num = num * 10 + (ord(sttr[i]) - ord('0')); 
            if (num < 2): 
                if (i != 0):  
                    sttr[j] = '0'
                    j += 1
                continue
  
            sttr[j] = chr((num // 2) + ord('0'))
            j += 1; 
            num = (num) - (num // 2) * 2
        len_str = j
    return(True)

def getLeftmostBit(n): 
    m = 0
    while (n > 1) : 
        n = n >> 1
        m += 1
    return(m)
def getNextLeftmostBit(n, m) : 
    temp = 1 << m 
    while (n < temp) : 
        temp = temp >> 1
        m -= 1
    return m
def bitcounter(n) :
    m = getLeftmostBit(n) 
    return _countSetBits(n, m) 
def _countSetBits(n, m) :
    if (n == 0) : 
        return 0
    m = getNextLeftmostBit(n, m)
    if (n == (1 << (m + 1)) - 1) : 
        return ((m + 1) * (1 << m))
    n = n - (1 << m)
    return (n + 1) + bitcounter(n) + m * (1 << (m - 1)) 

def log_two(n): 
    return(math.log(n) / math.log(2))

#-----------------------------------------------------------------------#
        
ONLINE_JUDGE = __debug__
if ONLINE_JUDGE:
    input = sys.stdin.readline
    
main()

Measured memory_bytes: 62876
def main():
    N = int(input())
    S = []
    for _ in range(N):
        S.append(int(input()))
    S = sorted(S)
    tot = sum(S)
    if tot % 10 != 0: return tot
    for i in range(len(S)):
        if S[i] % 10 != 0:
            return tot - S[i]
    return 0

if __name__ == '__main__':
    print(main())


Measured memory_bytes: 3060
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string A; cin >> A;
    int cnt[26] = {};
    rep(i, A.length()) cnt[A[i] - 'a']++;
    int len = A.length();
    int ans = len * (len - 1) / 2;
    rep(i, 26) ans -= cnt[i] * (cnt[i] - 1) / 2;
    cout << ans + 1 << endl;

    return 0;
}


Measured memory_bytes: 720
#include <bits/stdc++.h> 
using namespace std;
int main() {
  int a,b,c;
  cin>> a >> b >>c;
  int A=a+b;
  int B=b+c;
  int C=c+a;
  int minimum = min(min(A,B),C);
  cout<<minimum<<endl;
}

Measured memory_bytes: 256
// warm heart, wagging tail,and a smile just for you!
//                                                                     ███████████
//                                                                   ███╬╬╬╬╬╬╬╬╬╬███
//                                                                ███╬╬╬╬╬████╬╬╬╬╬╬███
//                                            ███████████       ██╬╬╬╬╬████╬╬████╬╬╬╬╬██
//                                      █████████╬╬╬╬╬████████████╬╬╬╬╬██╬╬╬╬╬╬███╬╬╬╬╬██
//                               ████████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬██╬╬╬╬╬╬╬██
//                             ████╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬╬╬╬╬╬██
//                           ███╬╬╬█╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬███╬╬╬╬╬╬╬█████
//                         ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬████████╬╬╬╬╬██
//                       ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬╬╬╬╬███
//                     ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬██
//                 ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬████
//     █████████████╬╬╬╬╬╬╬╬██╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬██████
//   ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬██████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████╬╬╬╬╬╬╬███████████╬╬╬╬╬╬╬╬██╬╬╬██╬╬╬██
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬█╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬██
// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬▓▓▓▓▓▓╬╬╬████╬╬████╬╬╬╬╬╬╬▓▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬███
// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████▓▓▓▓▓▓▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬█████
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████████
//   ███╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██
//       ██████████████  ████╬╬╬╬╬╬███████████████████████████╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████
//                         ███████                           █████  ███████████████████  
//
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF (1LL<<60)
#define fs first
#define sc second
#define int long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i = (b-1);i>=(a);--i)
#define REP(i,n)  FOR(i,0,(n))
#define RREP(i,n) RFOR(i,0,(n))
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SP << " " << 
#define MSB(x) (63-__builtin_clzll(x))
#define pcnt(x) (__builtin_popcountll(x))
#define parity(i,j) (i&(1LL<<j))
typedef pair<int,int> P;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

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

  int n,m;
  cin >> n >> m;

  cout << n*m/__gcd(n,m) << endl;
 
  return 0;
}

Measured memory_bytes: 256
//c++ -std=gnu++14 a.cpp
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
#include <iomanip>
#include <climits>
#include <fstream>
#include <random>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
//typedef pair<ll, ll> P;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define revrep(i, n) for(int i = (n)-1; i >= 0; i--)
#define pb push_back
#define f first
#define s second
#define chmin(x, y) x = min(x, y);
#define chmax(x, y) x = max(x, y);
#define sz(x) ((int)(x).size())

//const ll INFL = LLONG_MAX;//10^18 = 2^60
const ll INFL = 1LL<<60;
//const int INF = INT_MAX;
const int INF = 1 << 30;//10^9
//const int MOD = 1000000007;
const int MOD = 998244353;
//int MOD = 1000000007;
double EPS = 1e-10;

vector<ll> dy = {0, 1, 0, -1, 1, 1, -1, -1, 0};
vector<ll> dx = {1, 0, -1, 0, 1, -1, 1, -1, 0};

void pres(double A){printf("%.12lf\n", A);}
void BinarySay(ll x, ll y = 60){rep(i, y) cout << (x>>(y-1-i) & 1); cout << endl;}
ll cnt_bit(ll x){return __builtin_popcountll(x);}

ll pow_long(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2) res *= x;
    x *= x; k /= 2;
  }
  return res;
}

ll pow_mod(ll x, ll k){
  x %= MOD;
  ll res = 1;
  while(k > 0){
    if(k % 2){
      res *= x; res %= MOD;
    }
    x *= x; x %= MOD;
    k /= 2;
  }
  return res;
}

ll inverse(ll x){return pow_mod(x, MOD - 2);};

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

ll lcm(ll x, ll y){
  ll res = x / gcd(x, y);
  res *= y;
  return res;
};


//コンビネーション
const int MAXcomb = 200010;
ll fac[MAXcomb], finv[MAXcomb], inv[MAXcomb];
//facはn!,finvは1/n!
//invは逆元
void COMinit(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < MAXcomb; i++){
        fac[i] = fac[i-1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
        finv[i] = finv[i-1] * inv[i] % MOD;
    }
}
ll comb(int n, int k){
    if(n < k) return 0;
    if(n < 0 || k < 0) return 0;
    return fac[n] * finv[k] % MOD * finv[n-k] % MOD;
}

const int MAXkai = 200010;
ll kai_memo[MAXkai];
ll kai(ll N){
  if(kai_memo[N] != 0) return kai_memo[N];
  if(N <= 1) return 1;
  return kai_memo[N] = N * kai(N-1) % MOD;
}

ll disit(ll s, ll base = 10){
  ll res = 0;
  while(s){
    res++;
    s /= base;
  }
  return res;
}

//約数の列挙O(√n)
vector<int> divisor(int n){
    vector<int> res(0);
    for(int i = 1; i * i <= n; i++){
        if(n % i == 0){
            res.push_back(i);
            if(i != n/i) res.push_back(n/i);
        }
    }
    sort(res.begin(), res.end());
    return res;
}



void solve(){
  ll N, A, B;
  cin >> N >> A >> B;
  ll ans = N / (A + B) * A;
  N %= (A + B);
  ans += min(A, N);
  cout << ans << endl;
}

int main(){
  ios_base::sync_with_stdio(0);
  cin.tie(0), cout.tie(0);
  solve();
}


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

#define ll long long
#define int long long
#define pii pair<int, int>

const int N = 2e5 + 10, MOD = 1e9 + 7;
int tree[N], n, m;

int query(int idx) { int res = 0; while (idx > 0) { res += tree[idx]; idx -= idx & (-idx); } return res; }
void update(int idx, int val) { while (idx <= m) { tree[idx] += val; idx += idx & (-idx); } }

int fun(int day) {
    int left = 1, right = day;
    int last = query(right);
    if (last == 0)
        return -1;
    int res = -1;
    while (left <= right) {
        int mid = (left + right) >> 1;
        if (query(mid) >= last) {
            res = mid;
            right = mid - 1;
        } else {
            left = mid + 1;
        }
    }
    return res;
}

inline bool cmp(pii a, pii b) {
    if (a.first == b.first)
        return a.second < b.second;
    return a.first < b.first;
}

signed main() {
    scanf("%d%d", &n, &m);
    vector<pair<int, int> > ar(n);
    for (int i = 0; i < n; i++)
        scanf("%d%d", &ar[i].second, &ar[i].first);
    for (int i = 1; i <= m; i++)
        update(i, 1);
    sort(ar.begin(), ar.end(), cmp);
    int res = 0;
    while (ar.size()) {
        int day = ar.back().second;
        int reward = ar.back().first;
        ar.pop_back();
        int temp = fun(m - day + 1);
        if (temp != -1) {
            update(temp, -1);
            res += reward;
        }
    }
    printf("%d\n", res);
    return 0;
}


Measured memory_bytes: 2560
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
    	//System.out.println("数字を入力してください");
    	Scanner sc = new Scanner(System.in);
    	int a = Integer.parseInt(sc.next());
    	int b = Integer.parseInt(sc.next());
        System.out.println(a*b+" "+(a+b)*2);
    }
}



Measured memory_bytes: 25956
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		int K = sc.nextInt();
		if (K <= A) {
			System.out.println(K);
		} else if (K <= A + B) {
			System.out.println(A);
		} else {
			System.out.println(A - (K - A - B));
		}
	}

}


Measured memory_bytes: 35772
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    vector<int>v(n);
    for(int &x:v){
        cin >> x;
    }
    map<int,int>odds, evens;
    for(int i = 0,vs=n;i < vs;i++){
        if((i+1) % 2 == 0)evens[v[i]]++;
        else odds[v[i]]++;
    }
    pair<int, int>omax[2], emax[2];
    for(pair<int, int> p:odds){
        if(omax[0].second <= p.second){
            omax[1] = omax[0];
            omax[0] = p;
        }
        else if(omax[1].second <= p.second){
            omax[1] = p;
        }
        //cout << p.first << "**" << p.second << "\n";
    }
    for(pair<int, int> p:evens){
        if(emax[0].second <= p.second){
            emax[1] = emax[0];
            emax[0] = p;
        }
        else if(emax[1].second <= p.second){
            emax[1] = p;
        }
        //cout << p.first << "***" << p.second << "\n";
    }
    if(omax[0].first == emax[0].first){
        if(omax[0].second > emax[0].second){
            emax[0] = emax[1];
            // cout << emax[1].first << "**" << emax[1].second << "\n";
        }
        else if(omax[0].second < emax[0].second){
            omax[0] = omax[1];
        }
        else{
            if(omax[1].second > emax[1].second){
                omax[0] = omax[1];
            }
            else{
                emax[0] = emax[1];
            }
        }
    }
    //cout << omax[0].second << "*" << emax[0].second << "\n";
    cout << n-(omax[0].second+emax[0].second) << "\n";
    return 0;
}

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

signed main(void){ 
  
  int n,m; cin >> n >> m;
  
  bool flag = true;
  
  if( n % 2 == 1 ) { 
    int cnt = 0;
    for(int a = 1,b = n; a < b; a++, b--){ 
      cout << a << " " << b << endl;
      cnt++;
      if( cnt >= m ){ break;}
    }
  } 
  else{ 
    int cnt = 0;
    for(int a = 1, b = n; a < b; a++, b--){ 
      if( b-a <= n/2 && flag){ a++; flag = false;}
      cout << a << " " << b << endl;
      cnt++;
      if( cnt >= m ){ break;}
      
    }
      
    return 0;
  }
  
  
}

Measured memory_bytes: 3684
/*dismint|jjc*/
#include <bits/stdc++.h>
using namespace std;
#define forl(V, S, E) for(int V = S; V < E; V++)
#define ford(V, S, E) for(int V = S; V >= E; V--)
#define fore(E, X) for(auto &E:X)
#define println(X) cout << X << endl
#define printe(X) for(auto &E:X) cout << E << " "; cout << endl
typedef unordered_map<int, unordered_set<int>> graph;
typedef long long ll;

int main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	int n; string s; cin >> n >> s;
	if(n%2) { println("No"); return 0; }
	forl(i, 0, n/2) {
		if(s[i] != s[i+n/2]) { println("No"); return 0; }
	}
	println("Yes");
}


Measured memory_bytes: 256
module M = Set.Make(struct type t = int * int let compare = compare end)
let inf = 1010101010101010

let () =
  Scanf.scanf "%d" @@ fun n ->
  let g = Array.init (n+1) (fun _ -> []) in
  for _ = 1 to n-1 do
    Scanf.scanf " %d %d %d" @@ fun a b c ->
    g.(a) <- (b, c) :: g.(a);
    g.(b) <- (a, c) :: g.(b);
  done;

  Scanf.scanf " %d %d" @@ fun q k ->

  let dist = Array.make (n+1) inf in
  dist.(k) <- 0;

  let rec loop pqi =
    if M.is_empty pqi then () else
    let (d, u) = M.min_elt pqi in
    let pqi' = M.remove (d,u) pqi in

    if d > dist.(u) then loop pqi' else
      g.(u) |> List.fold_left (fun pq (v, c) ->
        if d+c < dist.(v) then begin
          dist.(v) <- d+c;
          M.add (d+c, v) pq
        end else pq) pqi'
    |> loop
  in loop (M.singleton (0, k));

  for _ = 1 to q do
    Scanf.scanf " %d %d" @@ fun x y ->
    dist.(x) + dist.(y) |> Printf.printf "%d\n"
  done

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N;
int A[101010];

int V[101010];
int num[101010];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	
	cin>>N;
	multiset<int> M;
	FOR(i,N) {
		cin>>x;
		auto it=M.lower_bound(x);
		if(it==M.begin()) M.insert(x);
		else {
			it--;
			M.erase(it);
			M.insert(x);
		}
	}
	cout<<M.size()<<endl;
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 4992
W,H,N=list(map(int, input().split()))
wl=[0]
wh=[W]
hl=[0]
hh=[H]
for i in range(N):
  l=list(map(int, input().split()))
  if l[2]==1:
    wl.append(l[0])
  elif l[2]==2:
    wh.append(l[0])
  elif l[2]==3:
    hl.append(l[1])
  else:
    hh.append(l[1])
w=min(wh)-max(wl)
h=min(hh)-max(hl)
if w>0 and h>0:
  print(w*h)
else:
  print(0)

Measured memory_bytes: 62600
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
int main(){
    vector<int> a = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int k;
    cin >> k;
    cout << a.at(k-1) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
const ll INF=1000000000000000001;
struct edge{int to,cost;};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};

int a[101];

int main() {

	int k,t;
	cin>>k>>t;
	int total=0;
	int ma=0;
	rep(i,t){
		cin>>a[i];
		ma=max(ma,a[i]);
		total+=a[i];
	}
	if(total-ma<ma-1)cout<<ma-1-total+ma<<endl;
	else cout<<"0"<<endl;

	return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n); for(int i = 0;i < (n);i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
long double pi = acos(-1);
const int INF = 1001001001;
const int N_MAX = 100001;
const int modint = 1000000007;

// 最小公倍数を求める
int euqlid (int a, int b){
  int temp;
  temp = a % b;
  if(temp == 0)return b;
  return euqlid(b,temp);
}
ll conbination(ll a,ll b){
  ll u = 1;
  ll d = 1;
  while(b != 0){
    u *= a;
    d *= b;
    a--;
    b--;
  }
  return u / d;
}
int strtoint(char s){
  return (int(s-'0'));
}
char changeS(char alpha){
  if(0x41 <= alpha and alpha <= 0x5A)return (alpha + 0x20);
  else if(0x61 <= alpha and alpha <= 0x7A)return (alpha - 0x20);
  return alpha;
}
int fact(int n){
  if(n == 1)return 1;
  return n * fact(n-1);
  }
int ceil(int a,int b){
  // a/bの切り上げを考える
  return (a+b-1)/b;
}

int main(){
  int n;
  cin >> n;
  vector <int> m;
  int i = 0;
  while(true){
    int temp = pow(6,i);
    if(temp > 100000)break;
    else m.push_back(temp);
    i++;
  }
  i = 1;
  while(true){
    int temp = pow(9,i);
    if(temp> 100000)break;
    else m.push_back(temp);
    i++;
  }
  int dp[m.size()][n+1];
  rep(i,int(m.size())){
    rep(j,n)dp[i][j] = INF;
  }
  dp[0][0] = 0;
  for(int i = 1;i < n+1;i++)dp[0][i] = dp[0][i-1] + 1;


  for(int i = 1;i < m.size();i++){
    for(int j = 0;j < n+1;j++){
      if(j-m[i] < 0)
        dp[i][j] = dp[i-1][j];
      else
        dp[i][j] = min(dp[i-1][j],dp[i][j-m[i]]+1); 
    }
  }

  cout << dp[m.size()-1][n] << endl;
}

Measured memory_bytes: 8576
# -*- coding: utf-8 -*-

N = int(input())
V = sorted(list(map(int, input().split())), reverse=True)

while len(V)>1:
    min1 = V.pop(-1)
    min2 = V.pop(-1)

    V.append((min1+min2)/2)
    V = sorted(V, reverse=True)

print(V[0])

Measured memory_bytes: 3060
#include <bits/stdc++.h>
template <typename T>
class BIT {
    int sz;
    std::vector<T> node;
public:
    BIT(int sz): sz(sz+1), node(std::vector<T>(sz+1, 0)) {}
    void add(int idx, T val) {
        while(idx < sz) {
            node[idx] += val;
            idx += idx & -idx;
        }
    }
    int sum(int idx) {
        T res = 0;
        while(idx > 0) {
            res += node[idx];
            idx -= idx & -idx;
        }
        return res;
    }
};
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;
template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}
int check(const vector<vector<int>> &mat, const P &p, vector<BIT<int>> &bit) {
  int res = 0;
  int n = (int)(mat.size());
  int r = p.first, c = p.second;
  bit[r].add(c+1, 1);
  if(bit[r].sum(n) == n) res++;
  bit[n + c].add(r+1, 1);
  if(bit[n + c].sum(n) == n) res++;
  if(r == c) {
    bit[2*n].add(c+1, 1);
    if(bit[2*n].sum(n) == n) res++;
  }
  if(r == n - c - 1) {
    bit[2*n+1].add(c+1, 1);
    if(bit[2*n+1].sum(n) == n) res++;
  }
  return res;
}
int main() {
  cin.tie(0);
  cout << fixed << setprecision(10);
  int n, u, v, m; cin >> n >> u >> v >> m;
  vector<vector<int>> usa(n, vector<int>(n)), neko(n, vector<int>(n));
  map<int, P> usamp, nekomp;
  map<int, bool> usasel, nekosel;
  for(int i=0;i<n;++i) {
    for(int j=0;j<n;++j) {
      cin >> usa[i][j];
      usamp[usa[i][j]] = {i, j};
      usasel[usa[i][j]] = true;
    }
  }
  for(int i=0;i<n;++i) {
    for(int j=0;j<n;++j) {
      cin >> neko[i][j];
      nekomp[neko[i][j]] = {i, j};
      nekosel[neko[i][j]] = true;
    }
  }
  vector<int> tra(m);
  for(int i=0;i<m;++i) {
    cin >> tra[i];
  }
  vector<BIT<int>> usabit(2*n+2, BIT<int>(n+1)), nekobit(2*n+2, BIT<int>(n+1));
  int usacnt = 0, nekocnt = 0;
  bool usawin = false, nekowin = false;
  for(int i=0;i<m;++i) {
    if(usasel[tra[i]]) {
      if(n == 1) {
        usacnt++;
      } else {
        P usap = usamp[tra[i]];
        usacnt += check(usa, usap, usabit);
      }
      if(usacnt >= u) usawin = true;
    }
    if(nekosel[tra[i]]) {
      if(n == 1) {
        nekocnt++;
      } else {
        P nekop = nekomp[tra[i]];
        nekocnt += check(neko, nekop, nekobit);
      }
      if(nekocnt >= v) nekowin = true;
    }
    if(usawin || nekowin) break;
  }
  if(usawin && nekowin) {
    cout << "DRAW" << endl;
  } else if(usawin) {
    cout << "USAGI" << endl;
  } else if(nekowin) {
    cout << "NEKO" << endl;
  } else {
    cout << "DRAW" << endl;
  }
}



Measured memory_bytes: 38976
#include <stdio.h>
#include <iostream>
#include <math.h>
#include <string>
#include <vector>
#include <algorithm>
#include <tuple>

//#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back

int main() {
  int N, K;
  cin >> N >> K;
  string s;
  cin >> s;
  char LR[s.size()];

  for(int i=0; i<s.size();i++){
      LR[i] = s.at (i);
  }
  int happy = 0;
  int flag = 0;
  for(int i = 0; i < N - 1; i++){
      if(LR[i] == LR[i+1]) happy++;
      else if(LR[i] != LR[i+1]) flag++;
  }

  for(int j = 0; j < K; j++){
    if(flag == 0) break;
    else if (flag == 1) {
        happy++;
        flag--;
    }
    else {
        happy +=2;
        flag -=2;
    }
  }
  
  cout << happy << endl;

}


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

int main()
{
    int n;
    cin >> n;
    map<string, int> memo;

    rep(i, n)
    {
        string s;
        cin >> s;

        // 初期化してないからatではエラー
        memo[s] += 1;
    }

    int maxv = 0;
    for (const auto &x : memo)
    {
        int v = x.second;
        if (v > maxv)
        {
            maxv = v;
        }
    }
    for (auto itr : memo)
    {
        if (itr.second == maxv)
        {
            cout << itr.first << endl;
        }
    }
}

/* ちょっとだけメモリ使用量が少ない？
for (auto it = memo.begin(); it != memo.end(); it++)
{
    cout << it->first << " : " << it->second << endl;
}

for (auto itr : memo)
{
    cout << itr.first << " : " << itr.second << endl;
}
*/

Measured memory_bytes: 25216
N,W = map(int,input().split())
w,v = [0]*N,[0]*N
for i in range(N):
    w[i],v[i] = map(int,input().split())
V = sum(v)
dp = [[float("inf")]*(V+1) for _ in range(N+1)]
dp[0][0] = 0

for i in range(N):
    for j in range(V+1):
        if j-v[i] >= 0:
            dp[i+1][j] = dp[i][j-v[i]]+w[i]
        dp[i+1][j] = min(dp[i+1][j], dp[i][j])

for i,d in enumerate(dp[N]):
    if d <= W:
        ans = i

print(ans)


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


//defines...
#define ll long long
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define mp make_pair
#define in insert
#define pi 2*acos(0.0)1
#define srt(s) sort(s.begin(),s.end())
#define rsrt(s) sort(s.rbegin(),s.rend())
#define all(x) x.begin(),x.end()

const ll mod=1e9+7;
const ll MX=2e5+5;

//code goes from here...



int main()
{
#ifndef ONLINE_JUDGE
    //freopen("input.txt", "r", stdin);

    freopen("output.txt", "w", stdout);
#endif

    boost
    //---------------------------------
    ll n,k;
    cin >> n >> k;
    if(n%k==0) cout  << 0 << endl;
    else cout << min((n%k),(k-(n%k))) << endl; 
    
    
    //---------------------------------
    
    return 0;
}


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

int main() {
    long n, t, a;
    cin >> n >> t >> a;
    long H[1000];
    for (long i = 0; i < n; i++) {
        cin >> H[i];
    }

    double min_sub = 10000;
    long min_idx;
    for (long i = 0; i < n; i++) {
        double sub = (double) abs(a - (t - H[i] * 0.006));
        if (sub < min_sub) {
            min_sub = sub;
            min_idx = i + 1;
        }
    }

    cout << min_idx << endl;

    return 0;
}


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

#define waru 1000000007
//int comb(int n, int a) {
//	long long kai=1;
//
//	for (int i = 1; i <= a; i++) {
//		kai*= i;
//		kai %= waru;
//	}
//	long long bunsi = 1;
//	for (int i = 0; i < a; i++) {
//		bunsi *= (n - i);
//	}
//
//
//}
//int main() {
//
//	int n,a,b;
//	long long ans = 0;
//	cin >> n>>a>>b;
//
//	for (int i = 1; i<1 << (n); i++) {
//		long long cnt = 0;
//		for (int j = 0; j < n; j++) {
//			if (i >> j & 1)cnt++;
//		}
//		if (cnt != a && cnt != b)ans++;
//	}
//
//	cout<<ans%()
//}

using ll = long long;
const int mod = 1000000007;
struct mint {
    ll x; // typedef long long ll;
    mint(ll x = 0) :x((x% mod + mod) % mod) {}
    mint operator-() const { return mint(-x); }
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this; }
    mint operator+(const mint a) const { return mint(*this) += a; }
    mint operator-(const mint a) const { return mint(*this) -= a; }
    mint operator*(const mint a) const { return mint(*this) *= a; }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod - 2); }
    mint& operator/=(const mint a) { return *this *= a.inv(); }
    mint operator/(const mint a) const { return mint(*this) /= a; }
};

mint f(int n) {
    if (n == 0)return 1;
    mint x = f(n / 2);
    x *= x;
    if (n % 2 == 1)x *= 2;
    return x;
}
mint choose(int n, int a) {
    mint x = 1, y = 1;
    for (int i = 0; i < a; i++) {
        x *= n - i;
        y *= i + 1;
    }
    return x / y;
}
int main() {
    int n, a, b;
    cin >> n >> a >> b;

    mint ans = f( n);
    ans -= 1;
    ans -= choose(n, a);
    ans -= choose(n, b);
    cout << ans.x << endl;
    return 0;
}

Measured memory_bytes: 3640
require 'set'
MOD = 10 ** 9 + 7
N, M = gets.split.map(&:to_i)
a_list = M.times.map { gets.to_i }
a_set = Set.new(a_list)

dp = Array.new(N + 1) { 0 }
dp[0] = 1
(0..(N - 1)).each do |i|
  next if a_set.include?(i)
  j = i + 1
  if !a_set.include?(j)
    dp[j] = (dp[j] + dp[i]) % MOD
  end
  j = i + 2
  if j <= N && !a_set.include?(j)
    dp[j] = (dp[j] + dp[i]) % MOD
  end
end
puts dp[N]


Measured memory_bytes: 9980
// 2011/09/08 Tazoe

#include <iostream>
using namespace std;

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

	int K;
	cin >> K;

	for(int i=0; i<K; i++){
		int a, b;
		cin >> a >> b;

		if(a>(N+1)/2)
			a = N-a+1;
		if(b>(N+1)/2)
			b = N-b+1;

		if(a<b)
			cout << (a-1)%3+1 << endl;
		else
			cout << (b-1)%3+1 << endl;
	}

	return 0;
}

Measured memory_bytes: 0
#include<iostream>
using namespace std;
int main()
{
    int n;
	cin>>n;
	int s=0, m=n;
    while(m!=0)
	{
    s+=m%10;
    m/=10;
    }
    if(n%s==0) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

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

const char *p;

string parse(){
	string s, t;
	while(*p && *p != ']'){
		if(*p == '['){
			++p;
			t = parse();
			++p;
			reverse(t.begin(), t.end());
			s += t;
		}
		else{
			int c = 0;
			for(;; ++p){
				if(*p == '+'){
					++c;
				}
				else if(*p == '-'){
					--c;
				}
				else{
					break;
				}
			}

			if(*p == '?'){
				s += '?';
			}
			else{
				s += char(((*p - 'A') + c % 26 + 26) % 26 + 'A');
			}
			++p;
		}
	}
	return s;
}

int main(){
	string s, t;
	while(cin >> s, s[0] != '.'){
		p = s.c_str();
		t = parse();
		replace(t.begin(), t.end(), '?', 'A');
		cout << t << '\n';
	}
}

Measured memory_bytes: 1176
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <set>
#include <cstdlib>
#include <deque>
#include <stack>
#include <sstream>

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


long long modpow(long long a, long long n,long long mod) {
  long long res = 1;
  while(n > 0) {
    if(n % 2 == 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);
}

long long conbi(long long n,long long k) {
  long long res = 1;
  long long inv;
  for(long long i = n-k+1; i <= n; i++) {
    res *= i;
    res %= P;
  }
  for(long long i = 1; i <= k; i++) {
    inv = modinv(i,P);
    res *= inv;
    res %= P;
  }
  return res;
}

long long factorial(long long n) {
  long long res = 1;
  for(long long i = n; i >= 2; i--) {
    res *= i;
    res %= P;
  }
  return res;
}

int main() {
  long long n,m;
  cin >> n >> m;
  int a[n],b[n];
  long long ans;
  if(abs(n-m) == 1) {
    ans = factorial(n) * factorial(m);
    ans %= P;
  }else if(n == m){
    ans = factorial(n) * factorial(m) * 2;
    ans %= P;
  }else {
    ans = 0;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <utility>
#include <vector>
#include <algorithm>
using namespace std;

#define gcu getchar_unlocked
#define pcu putchar_unlocked
#define _T template <typename T>
#define _HT template <typename H, typename... T>
#define _il inline
#define _in _il int in
#define _sc _il bool scan
_T T in(int c){T n=0;bool m=false;if(c=='-')m=true,c=gcu();
	do{n=10*n+(c-'0'),c=gcu();}while(c>='0');return m?-n:n;} //&&c<='9'
_in() {return in<int>(gcu());}
_T T scan(T &n){int c=gcu();return c==EOF?false:(n=in<T>(c),true);}
_sc(char &c){c=gcu();gcu();return c!=EOF;}
//_sc(string &s){int c;s="";
//	for(;;){c=gcu();if(c=='\n'||c==' ')return true;else if(c==EOF)return false;s+=c;}}
_HT _sc(H &h, T&&... t){return scan(h)&&scan(t...);}
#define _vo _il void out
#define _vl _il void outl
_vo(const char *s){while(*s)pcu(*s++);}
_vo(char c){pcu(c);}
//_vo(string &s){for(char c:s)pcu(c);}
//_vo(string s){for(char c:s)pcu(c);}
_T _vo(T n){static char buf[20];char *p=buf;
	if(n<0)pcu('-'),n*=-1;if(!n)*p++='0';else while(n)*p++=n%10+'0',n/=10;
	while (p!=buf)pcu(*--p);}
_vl(){out('\n');}
_T _vo(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);outl();}
_HT _vo(H&& h, T&&... t){out(h);out(move(t)...);}
template <typename... T> _vl(T&&... t){out(move(t)...);outl();}

int main() {
	vector<int> A(in());
	for (int &a :A)
		a = in();
	for (int i = in(); i; i--)
		outl(distance(A.begin(), lower_bound(A.begin(), A.end(), in())));
}


Measured memory_bytes: 2624
#include <cstdio>
#include <cstring>

const int kMaxn = 1e5 + 10;

typedef int IAr[kMaxn];

int n, k;
IAr p, q, a[7], ip, iq, B, IB, buf;

void SetId(int ar[]) {
	for (int i = 1; i <= n; i++) ar[i] = i;
}
void Inv(int ar[], int rs[]) {
	for (int i = 1; i <= n; i++) rs[ar[i]] = i;
}
void Mul(int ar[], int m[]) {
	for (int i = 1; i <= n; i++) buf[i] = ar[m[i]];
	memcpy(ar, buf, sizeof(int) * (n + 1));
}
void Mul(int ar[], int m[], int ret[]) {
	for (int i = 1; i <= n; i++) buf[i] = ar[m[i]];	
	memcpy(ret, buf, sizeof(int) * (n + 1));
}
void FPow(int ar[], int ex);
void Print(int ar[]);

int main() {
	scanf("%d%d", &n, &k);
	for (int i = 1; i <= n; i++) scanf("%d", p + i);
	for (int i = 1; i <= n; i++) scanf("%d", q + i);

	memcpy(a[1], p, sizeof(int) * (n + 1));
	memcpy(a[2], q, sizeof(int) * (n + 1));
	for (int i = 3; i <= 6; i++) {
		Inv(a[i - 2], buf);
		Mul(a[i - 1], buf, a[i]);
	}

	if (k <= 6) {
		Print(a[k]);
		return 0;
	}
	SetId(B);
	Inv(q, iq), Inv(p, ip);
	Mul(B, q), Mul(B, ip), Mul(B, iq), Mul(B, p);
	Inv(B, IB);

	int ex = (k - 1) / 6;
	FPow(B, ex), FPow(IB, ex);
	Mul(B, a[(k - 1) % 6 + 1]), Mul(B, IB);

	Print(B);
	return 0;
}

void FPow(int ar[], int ex) {
	static IAr bs, ret;
	memcpy(bs, ar, sizeof(int) * (n + 1));
	SetId(ret);
	for (; ex; Mul(bs, bs), ex >>= 1)
		if (ex & 1) Mul(ret, bs);
	memcpy(ar, ret, sizeof(int) * (n + 1));
}

void Print(int ar[]) {
	for (int i = 1; i <= n; i++) {
		printf("%d ", ar[i]);
	}
	putchar('\n');
}


Measured memory_bytes: 6912
s=input()
l=list(s)
m=0
for i in range(len(l)):
    if l[i]!="A" and l[i]!="T" and l[i]!="C" and l[i]!="G":
        l[i]="."

ss="".join(l)
ll=ss.split(".")
lll=[0]
for i in ll:
    lll.append(len(i))
print(max(lll))

Measured memory_bytes: 3064
using System;
using System.Collections.Generic;
using System.Linq;

namespace ConsoleApplication
{
    public class Program
    {
        public static void Main(string[] args)
        {
            var result = Utilities.ReadInts().Distinct().Count();
            System.Console.WriteLine(result);
        }
    }

    public static class Utilities
    {
        #region Extensions for IO
        public static int ReadInt()
            => ReadInts().First();
        public static IEnumerable<int> ReadInts()
            => ReadStrings().Select(int.Parse);

        public static string ReadString()
            => ReadStrings().First();
        public static IEnumerable<String> ReadStrings()
            => Console.ReadLine().Split(' ');
        #endregion

        #region Extensions of int
        public static bool IsOdd(this int n)
            => !n.IsEven();

        public static bool IsEven(this int n)
            => n % 2 == 0;
        
        public static bool CanDivideWith(this int n, int divisor)
            => n % divisor == 0;
        #endregion

        public static int ToInt(this string str)
            => int.Parse(str);
    }
}


Measured memory_bytes: 3032
x = input().split()
A = int(x[0])
B = int(x[1])
M = int(x[2])
a = input().split()
b = input().split()

a = [int(l) for l in a]
b = [int(l) for l in b]

c = min(a) + min(b)

for i in range(M):
    z = input().split()
    c1 = a[int(z[0])-1] + b[int(z[1])-1] - int(z[2])
    if c > c1:
        c = c1

print(c)

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

int main()
{
  int res=1;
  int N;
  cin >> N;
  vector<int> M(N);

  for (int i = 0; N > i; ++i) cin >> M[i];

  for (int c = 1;N>c; ++c) {
    int i = 0;
    while (c>i) {
      if (M[i] > M[c]) break;
      ++i;
    }
    if (i == c) ++res;
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 384
S=input()
if S=='SUN':
  print(7)
elif S=='MON':
  print(6)
elif S=='TUE':
  print(5)
elif S=='WED':
  print(4)
elif S=='THU':
  print(3)
elif S=='FRI':
  print(2)
elif S=='SAT':
  print(1)

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

int main(){
	char x[1002];
	scanf("%s",&x);
	int k=0;
	while(x[k]!='\0'){
		if('A'<=x[k]&&x[k]<='C')printf("%c",x[k]+23);
		else printf("%c",x[k]-3);
		k++;
	}
	printf("\n");
}

Measured memory_bytes: 1096
import bisect
import heapq
import itertools
import math
import operator
import os
import re
import string
import sys
from collections import Counter, deque, defaultdict
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter, mul, add, xor

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7

N = int(sys.stdin.readline())
S = sys.stdin.readline().rstrip()
T = sys.stdin.readline().rstrip()

ans = 0
while S != T:
    S = S[1:]
    T = T[:-1]
    ans += 2
print(ans + len(S))


Measured memory_bytes: 13660
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include <algorithm>
#include <array>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

int main() {
    int N,A;
    cin>>N>>A;
    cout<<N*N-A<<endl;
    return 0;
}

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

string card[3];

int main()
{
    cin >> card[0];
    cin >> card[1];
    cin >> card[2];
    int len[3] = {}, pos[3] = {};
    len[0] = card[0].size();
    len[1] = card[1].size();
    len[2] = card[2].size();
    int cur = 0;
    while (pos[cur] < len[cur])
    {
        // cout << char(cur + 'A') << " ";
        char c = card[cur][pos[cur]];
        pos[cur]++;
        cur = c - 'a';
    }
    // cout << endl;
    cout << char(cur + 'A') << endl;
    return 0;
}

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

using namespace std;

int f(int n, int a) {
    return n * n - a;
}

int main() {

    int n;
    cin >> n;

    int a;
    cin >> a;

    int result = f(n, a);
    cout << result << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int m = scan.nextInt();
		int[][] a = new int[n][m];
		for(int i = 0; i < n; i++){
			for(int j = 0; j < m; j++){
				a[i][j] = scan.nextInt();
			}
		}
		int[] b = new int[m];
		for(int j = 0; j < m; j++){
			b[j] = scan.nextInt();
		}
		for(int i = 0; i < n; i++){
			int num = 0;
			for(int j = 0; j < m; j++){
				num += a[i][j] * b[j];
			}
			System.out.println(num);
		}
	}
}

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

//レベルNバーガーの下からX層までに含まれるパティの数を返す関数
long int patti(int N, long int X, long int p[], long int l[]);

int main(void){
  int N;
  long int X;
  long int p[100] = {};//p[i]はレベルiバーガーに含まれるパティの数
  long int l[100] = {};//l[i]はレベルiバーガーの層の数
  int i, j, k;
  scanf("%d %ld", &N, &X);
  p[0] = 1;
  l[0] = 1;
  for(i = 1; i <= N; i++){
    p[i] = 2*p[i-1] + 1;
    l[i] = 2*l[i-1] + 3;
  }
  printf("%ld\n", patti(N, X, p, l));
  return 0;
}

long int patti(int N, long int X, long int p[], long int l[]){
  int count;

  if(N == 0){
    return 1;
  }
  if(N >= 1){
    if(X == 1){
      return 0;
    }
    else if(X <= l[N-1] + 1){
      return patti(N-1, X - 1, p, l);
    }
    else if(X == l[N-1] + 2){
      return p[N-1] + 1;
    }
    else if(X <= 2*l[N-1] + 2){
      return p[N-1] + 1 + patti(N-1, X - l[N-1] - 2, p, l);
    }
    else if(X == 2*l[N-1] + 3){
      return 2*p[N-1] + 1;
    }
  }
  return -1;
}


Measured memory_bytes: 128
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <cstring>
#include <regex>
#include <sstream>

typedef long long ll;
constexpr double PI = 3.141592653589793;
constexpr ll INF = 1e18 + 10;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}

using namespace std;
//    cout << setprecision(20) << ans << "\n";

vector<pair<ll, ll>> primeFactorize(ll N)
{
    vector<pair<ll, ll>> res;
    for (ll a = 2; a * a <= N; ++a)
    {
        if (N % a != 0)
            continue;
        ll ex = 0;

        while (N % a == 0)
        {
            ++ex;
            N /= a;
        }
        res.push_back({a, ex});
    }

    if (N != 1)
        res.push_back({N, 1});
    return res;
}

int main()
{
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    string s;
    cin >> s;
    char ans = 'a';
    for (int i = 0; i < 26; i++)
    {
        char c = 'a' + i;
        string str{c};
        const std::regex r(str);
        stringstream result;
        regex_replace(ostream_iterator<char>(result), s.begin(), s.end(), r, "");
        if (s.size() == result.str().size()){
            ans = c;
            cout << c << "\n";
            return 0;
        }
    }
    cout << "None"
         << "\n";
    return 0;
}


Measured memory_bytes: 3780