akhauriyash/Code-Regression huggingface dataset:
/*********************************************************************************************/
/**                                                                                          //
//                            _ooOoo_                                                        //
//                           o8888888o                                                       //
//                           88" . "88                                                       //
//                           (| -_- |)                                                       //
//                            O\ = /O                                                        //
//                        ____/`---'\____                                                    //
//                      .   ' \\| |// `.                                                     //
//                       / \\||| : |||// \                                                   //
//                     / _||||| -:- |||||- \                                                 //
//                       | | \\\ - /// | |                                                   //
//                     | \_| ''\---/'' | |                                                   //
//                      \ .-\__ `-` ___/-. /                                                 //
//                   ___`. .' /--.--\ `. . __                                                //
//                ."" '< `.___\_<|>_/___.' >'"".                                             //
//               | | : `- \`.;`\ _ /`;.`/ - ` : | |                                          //
//                 \ \ `-. \_ __\ /__ _/ .-` / /                                             //
//         ======`-.____`-.___\_____/___.-`____.-'======                                     //
//                            `=---='                                                        //
//                                                       //                                  //
//         .............................................                                     //
//                  佛祖保佑             永无BUG                                            //
********************************************************************************************/
#include<iostream>
#include<cstdlib>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<queue>
#include<algorithm>
#include<stack>
using namespace std;
const int mod=1000000009;
int vis[15];
int main()
{
    memset(vis,0,sizeof(vis));
    int n,k,m,i;
    cin>>n;
    cin>>k;
    int flag=0;
    for(i=1; i<=k; i++)
        cin>>m,vis[m]=1;
    for(i=n;;i++)
    {
        m=i;
        while(m)
        {
            int k=m%10;
            if(vis[k])
                break;
            m/=10;
        }
        if(!m)
        {
            cout<<i<<endl;
            break;
        }
    }
}


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

#define ll long long
#define ull unsigned long long
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(a,b) for(int a=0;a<(b);++a)
#define REP1(i,n) for(int i=1;i<=(n);++i)
#define debug(x) cerr<<#x<<": "<<x<<'\n'
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair
#define INF (1<<29)
#define PI 3.14159265358979
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

template<class T=int>
T in(){T x;cin>>x;return (x);}
template<class T>
void print(T& x){cout<<x<<'\n';}

const int MOD =(int)1e9+7;
const int MAX =510000;
ll fac[MAX],finv[MAX],inv[MAX];
void COMint(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(int i=2;i<MAX;i++){
        fac[i]=fac[i-1]*i%MOD;
        inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
        finv[i]=finv[i-1]*inv[i]%MOD;
    }
}
ll COM(int n,int k){
    if(n<k) return 0;
    if(n<0||k<0)return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}
ll gcd(ll a,ll b){
    if(b==0)return a;
    if(a>b){
        swap(a,b);
    }
    return gcd(a,b%a);
}
ll lcm(ll a,ll b){
    ll g;g=gcd(a,b);
    return a*b/g;
}
bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

bool compare_by_a(pair<int, int> a, pair<int, int> b) {
    if(a.first != b.first){
        return a.first < b.first;
    }else{
        return a.second < b.second;
    }
}

vector<pair<int,ll>> vec[100000];
ll cost[100000];
void dfs(int now,ll COST){
    cost[now]=COST;
    int next;
    REP(i,vec[now].size()){
        next=vec[now][i].first;
        if(cost[next]<0){
            dfs(next,COST+vec[now][i].second);
        }
    }
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    string S=in<string>();
    int l;l=S.length();
    int ans;ans=0;
    REP(i,l/2+l%2){
        if(S[i]!=S[l-1-i])ans++;
    }
    print(ans);
        return 0;
}


Measured memory_bytes: 3584
import sys
read = sys.stdin.buffer.read
input = sys.stdin.readline
input = sys.stdin.buffer.readline


#sys.setrecursionlimit(10**9)
#from functools import lru_cache

def RD(): return sys.stdin.read()
def II(): return int(input())
def MI(): return map(int,input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int,input().split()))
def LF(): return list(map(float,input().split()))
def TI(): return tuple(map(int,input().split()))
# rstrip().decode('utf-8')


#import numpy as np

def main():
	n,m=MI()
	li=[LI() for _ in range(m)]
	#print(li)
	li.sort(key=lambda x:x[1])
	#print(li)
	
	now=0
	ans=0
	
	for a,b in li:
		if now<=a:
			ans+=1
			now=b
	
	print(ans)
	
	

if __name__ == "__main__":
	main()


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

int main(){
  
  string S, T;
  cin >> S >> T;
  int ans = 0;
  
  for(int i = 0; i < 3; i++) {
    if(S.at(i) == T.at(i)) ans++;
  }
 
  cout << ans << endl;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
typedef bool boolean;

#define pii pair<int, int>

const int N = 1e5 + 5;

int n;
pii tmpA[N], tmpB[N];
boolean vis[N];
int A[N], B[N], L[N], p[N];

int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) {
		scanf("%d", A + i);	
		tmpA[i] = pii(A[i], i);
	}
	for (int i = 1; i <= n; i++) {
		scanf("%d", B + i);
		tmpB[i] = pii(B[i], i);
	}
	sort(B + 1, B + n + 1);
	sort(tmpA + 1, tmpA + n + 1);
	sort(tmpB + 1, tmpB + n + 1);
	for (int i = 1; i <= n; i++) {
		L[i] = upper_bound(tmpA + 1, tmpA + n + 1, pii(B[i], 1000000)) - tmpA - 1;
		if (L[i] < i) {
			puts("No");
			return 0;
		}
	}
	for (int i = 1; i <= n; i++)
		p[tmpA[i].second] = tmpB[i].second;
	int x = 1;
	while (!vis[x]) {
		vis[x] = true;
		x = p[x];
	}
	for (int i = 1; i <= n; i++) {
		if (!vis[i]) {
			puts("Yes");
			return 0;
		}
	}
	for (int i = 1; i <= n; i++) {
		if (L[i] > i) {
			puts("Yes");
			return 0;
		}
	}
	puts("No");
	return 0;
}


Measured memory_bytes: 3456
// PrintAFrame.c
// 以下のような、たてH cm よこ W cm の枠を描くプログラムを作成して下さい。
// ##########
// #........#
// #........#
// #........#
// #........#
// ##########
// 上図は、たて 6 cm よこ 10 cm の枠を表しています。
// 【入力】
// 入力は複数のデータセットから構成されています。各データセットの形式は以下のとおりです：
//   H W
// H, W がともに 0 のとき、入力の終わりとします。
// 【出力】
// 各データセットについて、たて H cm よこ W cm の枠を出力して下さい。
// 各データセットの後に、１つの空行を入れて下さい。
// 【制約】
// 3 ≤ H, W ≤ 300
// 【例】
// 入力：
// 3 4
// 5 6
// 3 3
// 0 0
// 出力：
// ####
// #..#
// ####
// 
// ######
// #....#
// #....#
// #....#
// ######
//
// ###
// #.#
// ###
#include<stdio.h>

int main( void) {
  int H, W;

  while ( 1) {
    scanf( "%d %d", &H, &W);

    if ( H == 0 && W == 0) break;

    for ( int w = 1; w <= W; w++) printf( "#");
    printf( "\n");

    for ( int h = 2; h <= H-1; h++) {
      printf( "#");
      for ( int w = 2; w <= W-1; w++) printf( ".");
      printf( "#\n");
    }

    for ( int w = 1; w <= W; w++) printf( "#");
    printf( "\n\n");
  }

  return 0;
}    
	


Measured memory_bytes: 2032
#include <iostream>
#include <cstdint>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <iomanip>
#include <sstream>
 
int main(void)
{
    int64_t n, m;
    std::cin >> n >> m;
 
    int64_t mod_n, mod_m;
    mod_n = n % 16;
    mod_m = m % 16;

    int64_t ans = mod_n;
    for (int64_t i = mod_n; i != mod_m;) {
        i++;
        if (i == 16) i = 0;
        ans ^= i;
    }

    if (n%2 == 1) {
        n &= 0xfffffffffffffff0;
    } else {
        n = 0;
    }

    if (m%2 == 0) {
        m &= 0xfffffffffffffff0;
    } else {
        m = 0;
    }

    std::cout << (n^m) + ans << std::endl;

    return 0;
}

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

int main(){
    int n;cin>>n;
    vector<int> d(n);for(int i=0;i<n;i++){cin>>d.at(i);}
    sort(d.begin(),d.end());
    cout<<d.at(n/2)-d.at(n/2-1)<<endl;
	return 0;
}

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

int main() {
  int N, D;
  cin >> N >> D;
  int ans;
  rep (i, N+1) {//i人を置くとする(1~N人)
    if ((2*D+1)*i >= N){
      ans = i;
      break;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cctype>
using namespace std;
int main(){
	string s,p;//s 元の文字列　p 文字列p
	cin >> s;
	s = s + s;
	cin >> p;
	int a = s.find(p);
	if (a == -1){
		cout << "No" << endl;
	}
	else{
		cout << "Yes" << endl;
	}
	return 0;
}


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

int main(){
	int w,h,x,y,r;
	cin >> w >> h >> x >> y >> r;
	if(x < 0 || y < 0) cout << "No" << endl;
	else if(abs(x+r)<=w && abs(y+r)<=h) cout << "Yes" << endl;
	else cout << "No" << endl;


	return 0;
}



Measured memory_bytes: 3136
#include <stdio.h>
#include <string.h>
int a, b;

int main(void) { 
	scanf("%d %d", &a, &b);
	if(b == 1) {
	    printf("0\n");
	    return 0;
	}
	int left = b - a;
    if(left <= 0) {
        printf("1\n");
        return 0;
    }
    int ans = left / (a - 1) + (left % (a - 1) != 0);
    printf("%d\n", ans + 1);
	return 0;
}

Measured memory_bytes: 128
#ifdef _MSC_VER
#include "stdc++.h"
#endif
#ifdef __GNUC__
#include<bits/stdc++.h>
#endif
using namespace std;

using ll = long long;

//vector
using vi = vector<int>;
using vii = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;

//constant
const double EPS = 1e-10;

#define REP(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, s, e) for (ll i = s; i < e; i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(), (x).rend()

//debug
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define DEBUG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl;

// vector
//template<typename T> vector<vector<T>> vv(ll H, ll W, T v) { return vector<vector<T>> vec(H, vector<T>(W, v)); }

// view vector
template<typename T> void view(T e) { cout << e << endl; }
template<typename T> void view(const vector<T>& v) { for (const auto& e : v) { cout << e << " "; } cout << endl; }
template<typename T> void view(const vector<vector<T> >& vv) { for (const auto& v : vv) { view(v); } }

// DP
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; }


int main(){

    ll N;
    cin >> N;
    vll A(N);
    set<ll> S, exclude;
    ll mx = 0;
    REP(i, N){
        cin >> A[i];
        chmax(mx, A[i]);
        if (S.find(A[i]) == S.end()) S.insert(A[i]);
        else exclude.insert(A[i]);
    }

    vector<bool> flag(mx + 1, false);

    for(ll s: S){
        for(ll j = 2; s * j <= mx; j++){
            flag[s * j] = true;
        }
    }

    ll ans = 0;
    for(ll s: S){
        if (exclude.find(s) != exclude.end()) continue;
        if (!flag[s]) ans++;
    }

    cout << ans << endl;



    return 0;
}


Measured memory_bytes: 14236
#include <bits/stdc++.h>
using namespace std;
int main() {
    int h, w;
    cin >> h >> w;
    vector<string> s(h);
    int light[h][w];
    for (int i=0; i<h; i++) {
        for (int j=0; j<w; j++) {
            light[i][j] = 0;
        }
    }

    for (int i=0; i<h; i++) {
        cin >> s[i];
    }
    for (int i=0; i<h; i++) {
        vector<int> memo(w);
        int cnt = 0;
        for (int j=0; j<w; j++) {
            if (s[i][j] == '.') {
                cnt++;
            } else {
                memo[j] = cnt;
                cnt = 0;
            }
        }
        for (int j=w-1; j>=0; j--) {
            if (memo[j] == 0 && s[i][j]!='#') {
                light[i][j] += cnt;
            } else {
                cnt = memo[j];
            }
        }
    }
    for (int j=0; j<w; j++) {
        vector<int> memo(h);
        int cnt = 0;
        for (int i=0; i<h; i++) {
            if (s[i][j] == '.') {
                cnt++;
            } else {
                memo[i] = cnt;
                cnt = 0;
            }
        }
        for (int i=h-1; i>=0; i--) {
            if (memo[i] == 0 && s[i][j]!='#') {
                light[i][j] += cnt;
            } else {
                cnt = memo[i];
            }
        }
    }
    //for (int i=0; i<h; i++) {
    //    for (int j=0; j<w; j++) {
    //        cout << light[i][j] << " ";
    //    }
    //    cout << endl;
    //}
    int ans = 0;
    for (int i=0; i<h; i++) {
        for (int j=0; j<w; j++) {
            ans = max(ans, light[i][j]);
        }
    }
    cout << ans-1 << endl;
    return 0;
}


Measured memory_bytes: 19968
#include <stdio.h>

int main(void){
    int N, Q; 
    scanf("%d%d", &N, &Q);
    char S[N + 1];
    scanf("%s", S);
    int s[N + 1];
    int count = 0;
    for (int i = 0; i < N; i++){
        s[i] = count;
        if(S[i] == 'A' && S[i + 1] == 'C'){
            count += 1;
        }
    }
    
    for(int i = 0; i < Q; i++){
        int l, r;
        int ans = 0;
        scanf("%d%d", &l, &r);
        ans = s[r-1] - s[l-1];
        printf("%d\n", ans);
    }
    return 0; 
}

Measured memory_bytes: 1280
#include<iostream>
#include<stdio.h>
using namespace std;

int main(){
	int i,o = 1;
	while ( cin >> i ){
		if ( i != 0 ){
			printf("Case %d: %d\n",o,i);
			o++;
		}
		else {
			break;
		}
	}
	return 0;
} 


Measured memory_bytes: 3124
#include <bits/stdc++.h>
#define INF 1000000005
#define mod 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i = 0; i < (n); ++i) /*0からn-1までのrep*/
#define rrep(i,n) for(int i = 1; i <= (n); ++i) /*1からnまでのrep*/
#define drep(i,n) for(int i = (n)-1; i >= 0; --i) /*n-1から0までのrep*/
#define srep(i,s,t) for (int i = s; i < t; ++i) /*sからt-1までのrep*/
#define each(a,b) for(auto& (a): (b)) /*よくわからん*/
#define all(v) (v).begin(),(v).end() /*全選択*/
#define sz(v) (int)(v).size() /*大きさ*/
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end()) /*重複削除*/
#define cmx(x,y) x=max(x,y) /*最大値*/
#define cmn(x,y) x=min(x,y) /*最小値*/
#define rev(v) reverse((v).begin(),(v).end()); /*逆順*/
#define so(v) sort((v).begin(), (v).end()); /*ソート*/
#define yn {puts("Yes");}else{puts("No");} /*はい・いいえ*/
#define fi first
#define se second
#define pb push_back

using namespace std;

using ll = long long;
using P = pair<int,int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vd = vector<double>;
using vp = vector<P>;
using vs = vector<string>; 

int main() {
    double a;
    cin >> a;
    a = a *2* 3.1415926535897932384626433832795028841971693993751058209;
    cout << setprecision(40) << a<<endl;
    return 0;
}

Measured memory_bytes: 3696
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef map<int, int> mi;
typedef set<int> si;
#define VV(T) vector<vector< T > >
#define dump(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl

#define rep(i, n) REP(i, 0, n)                              // 0, 1, ..., n-1
#define REP(i, x, n) for(int i = x; i < n; i++)             // x, x + 1, ..., n-1
#define invrep(i, n) for(int i = (n)-1; i >= 0; i--)        // n-1, n-2, ..., 0
#define invREP(i, x, n) for(int i = (n)-1; i >= (x; i--)    // n-1, n-2, ..., x
#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(v) (v).begin() , (v).end()
#define RALL(v) (v).rbegin(), (v).rend()

#define PB push_back

#define COUT(x) cout << (x) << endl
#define VECCIN(x) for(auto&youso_: (x) )cin>>youso_
#define VECCOUT(x) for(auto&youso_: (x) )cout<<youso_<<" ";cout<<endl

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; }


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

    mi m;
    rep(i, 4){
        int N; cin >> N;
        m[N]++;
    }

    if(m[1] && m[7] && m[9] && m[4]) COUT("YES");
    else COUT("NO");
}

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

using namespace std;

#define REP(var, n)  for (decltype(n) var = 0; var < (n); var++)
#define RREP(var, n)  for (auto var = n - 1; var != static_cast<decltype(var)>(-1); var--)
#define FOR(var, a, b)  for (auto var = (a); var < (b); var++)
#define RFOR(var, a, b)  for (auto var = b - 1; var != a; var--)

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;

#define all(c) begin(c),end(c)

template<typename T>
std::ostream &operator<<(std::ostream &out, const std::vector<T> &v) {
    if (!v.empty()) {
        out << '[';
        std::copy(v.begin(), v.end(), std::ostream_iterator<T>(out, ", "));
        out << "\b\b]";
    }
    return out;
}


auto solve() {
    vi C(3);
    for(auto&&c:C) {
        cin >>c;
    }

    if(any_of(all(C), [](int i){return i%2==0;}))
        return 0ll;
    sort(all(C));
    return (ll)C[0] * C[1];
}

int main() {
    cout << solve() << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long ans;
int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    int a;
    vector<vector<int> > A(20, vector<int>(N+1, 0));
    for (int i = 0; i < N; i++) {
        cin >> a;
        for (int j = 0; j < 20; j++) {
            A[j][i+1] = A[j][i]+(a>>j)%2;
        }
    }
    for (int i = 0; i < N; i++) {
        int temp = INT32_MAX;
        for (int j = 0; j < 20; j++) {
            auto it = lower_bound(A[j].begin(), A[j].end(), A[j][i]+2);
            temp = min(temp, (int)(it-A[j].begin())-i-1);
        }
        ans += temp;
    }
    printf("%lld\n", ans);
    return 0;
}

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

int main() {
	string s;
	string t = "CODEFESTIVAL2016";
	int ans=0;


	cin >> s;
	for (int i = 0; i<16; i++) {
		if (s[i] != t[i]) {
			ans++;
		}
	}

	cout << ans << endl;


	return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val N = readInputLine().toLong()
    
    println(N / 11L * 2L + if (N % 11L > 6L) 2L else if (N % 11L > 0L) 1L else 0L)
}

fun readInputLine(): String {
    return readLine()!!
}


Measured memory_bytes: 31424
#include <iomanip>
#include <iostream>
#include <queue>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;

int main(void) {
  ios::sync_with_stdio(false);
  int H, W;
  cin >> H >> W;
  int CH, CW;
  cin >> CH >> CW;
  CH--, CW--;
  int DH, DW;
  cin >> DH >> DW;
  DH--, DW--;
  vector<string> S(H);
  rep(i, H) cin >> S[i];

  priority_queue<tuple<int64_t, int, int>, vector<tuple<int64_t, int, int>>,
                 greater<tuple<int64_t, int, int>>>
      que;
  que.emplace(0, CH, CW);
  vector<vector<int64_t>> dist(H, vector<int64_t>(W, INT64_MAX));
  dist[CH][CW] = 0;
  const vector<pair<int, int>> dir = {{+1, 0}, {-1, 0}, {0, +1}, {0, -1}};

  while (!que.empty()) {
    int64_t warp;
    int y, x;
    tie(warp, y, x) = que.top();
    que.pop();
    if (y == DH && x == DW) {
      int64_t answer = warp / 1e10;
      cout << answer << endl;
      return 0;
    }
    for (auto& d : dir) {
      int ny = y + d.first;
      int nx = x + d.second;
      int64_t ndist = warp + 1;
      if (ny < 0 || nx < 0 || H <= ny || W <= nx) continue;
      if (S[ny][nx] != '.') continue;
      if (dist[ny][nx] <= ndist) continue;
      dist[ny][nx] = ndist;
      que.emplace(ndist, ny, nx);
    }
    for (int i = -2; i <= 2; ++i) {
      for (int j = -2; j <= 2; ++j) {
        if (i == 0 && j == 0) continue;
        int ny = y + i;
        int nx = x + j;
        int64_t nwarp = warp + (1 * 1e10);
        if (ny < 0 || nx < 0 || H <= ny || W <= nx) continue;
        if (S[ny][nx] != '.') continue;
        if (dist[ny][nx] <= nwarp) continue;
        dist[ny][nx] = nwarp;
        que.emplace(nwarp, ny, nx);
      }
    }
  }

  cout << -1 << endl;
  return 0;
}


Measured memory_bytes: 12492
n = int(input())
s_list = []

for i in range(n):
    x,y,h = map(int,input().split())
    s_list.append([x,y,h])

s_list.sort(key=lambda x: x[2])
s_list = list(reversed(s_list))

H = 0
flag = 0

for i in range(101):
    for j in range(101):
        flag = 0
        H = s_list[0][2] + abs(i-s_list[0][0]) + abs(j-s_list[0][1])
        for k in range(1,n):
            if s_list[k][2] != max(H - abs(s_list[k][0]-i) - abs(s_list[k][1]-j),0):
                flag = 1
                break
        if flag == 0:
            print(i,j,H)
            break


Measured memory_bytes: 9188
<?php
$input_line = trim(fgets(STDIN));
if ($input_line < 3200) {
	echo "red";
} else {
  for ($i = 0; $i < $input_line; $i++) {
      $s = trim(fgets(STDIN));
      $s = str_replace(array("\r\n","\r","\n"), '', $s);
      $s = explode(" ", $s);
      echo $s[0]; 
  }
}
?>

Measured memory_bytes: 3828
#include<bits/stdc++.h>
using namespace std;
int main()
{
   long long int x,d;
   unsigned long long int k;
   cin>>x>>k>>d;
   x=abs(x);
   unsigned long long int steps=k-min(k, (unsigned long long)x/d);
       x-=min(k*d, (unsigned long long int)(x/d)*d);
       k=steps;
       if(k%2==0) cout<<abs(x)<<endl;
       else cout<<abs(x-d)<<endl;
} 

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

int main(){
	int a, b, X;
        string d;
	while(1){
	cin>>a>>d>>b;
        if (d =="?")break;
	if (d == "+") X = a + b;
	if (d == "-") X = a - b;
        if (d == "*") X = a * b;
	if (d == "/") X = a / b;
	cout << X << endl;
	}



	return(0);
    }
  


Measured memory_bytes: 3104
import java.lang.Math.abs

fun main(args:Array<String>) {
    val (n,k) = readLine()!!.split(" ").map { it.toInt() }
    val  arr = readLine()!!.split(" ").map { it.toInt() }
    var ans = Int.MAX_VALUE
    for(i in 0 until k) {
        val l = (k + i - 1) % k
        val r = (i + 1) % k
        var ld =  if(l > i) n - (arr[l] - arr[i]) else arr[i] - arr[l]
        var rd = if(r < i) n - (arr[i] - arr[r]) else arr[r] - arr[i]
        ld = n - ld
        rd = n - rd
        val d = if(ld > rd) rd else ld
        if(ans > d) {
            ans = d
        }
    }
    print(ans)
}

Measured memory_bytes: 82808
/*
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
*/

#ifdef LOCAL
#include "debug.h"
#else
#include<bits/stdc++.h>
using namespace std;
#define debug(x...)
#endif
 
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<class T> 
using ordered_set= tree<T, null_type, 
		less<T>, 
		rb_tree_tag, tree_order_statistics_node_update> ;
template<class T> 		
using ordered_mset= tree<T, null_type, 
		less_equal<T>, 
		rb_tree_tag, tree_order_statistics_node_update> ;
		
*/
 
/*
 
PBDS
-------------------------------------------------
			0 based indexing
-------------------------------------------------			 
1) insert(value)
2) erase(value)
3) order_of_key(value) // Number of items strictly smaller than value
4) *find_by_order(k) : K-th element in a set (counting from zero)
 
*/
 
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
 
//mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());	

void solve()
{
	int n;
	cin>>n;
	
	vector<int>a(n);
	for(int &x: a) cin>>x;
	
	vector<int>b=a;
	
	for(int i=1;i<n;i++) b[i]=max(b[i],b[i-1]);
	
	ll ans=0;
	
	for(int i=0;i<n;i++) ans+=(b[i]-a[i]);
	
	cout<<ans;
}		

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	
	int testcase=1;
	//cin>>testcase;
	
	for(int i=1;i<=testcase;i++)
	{
		//cout<<"Case "<<i<<": ";
		solve();
	}
	
	#ifdef LOCAL
	cerr<<"\nTime elapsed: " << 1000.0 * clock() / CLOCKS_PER_SEC << " ms\n";
	#endif
	
	
	return 0;
}


Measured memory_bytes: 4728
#include <iostream>
#include <cmath>
#include <algorithm>
#include <climits>
#include <vector>
#include <string>
#include <set>
#include <iomanip>
#include <map>
#define REP(i,n) for (int i=0;i<(n);++i)
using namespace std;

int main(){
    int a, b, c;
    cin >> a >> b >> c;
    if((a + b) >= c) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
n, k = map(int, input().split())
lst = [int(i) for i in input().split()]

tele_lst = []
town_set = set()
town = 1
while True:
  if town not in town_set:
    tele_lst.append(town)
    town_set.add(town)
  else:
    break
  town = lst[town - 1]
ind = tele_lst.index(town)
length = len(town_set)
circle = length - ind
#print(ind, length)
#print(tele_lst)
if k < ind:
  town = tele_lst[k]
  print(town)
else:
  k -= ind
  k %= circle
  #print(k)
  town = tele_lst[ind + k]
  print(town)

Measured memory_bytes: 32768
s=input()
ans=[0]*2
a=int(s[:2])
b=int(s[2:])
if 1<=a<=12:
    ans[0]=1
if 1<=b<=12:
    ans[1]=1

if ans[0]==ans[1]==1:
    print('AMBIGUOUS')
elif ans[0]==ans[1]==0:
    print('NA')
elif ans[0]==1 and ans[1]==0:
    print('MMYY')
else:
    print('YYMM')

Measured memory_bytes: 9144
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import sys

input = sys.stdin.readline

def main():
    S = input().strip()
    T = input().strip()
    m = {}
    for i in range(len(T)):
        if T[i] in m:
            if m[T[i]] != S[i]:
                print("No")
                return
        m[T[i]] = S[i]

    T2 = T[:]
    for i in range(len(S)):
        if S[i] == T2[i]:
            continue
        from_c = T2[i]
        to_c = S[i]
        T2 = T2.translate(str.maketrans({from_c: to_c, to_c: from_c}))

    if S != T2:
        print("No")
    else:
        print("Yes")

main()


Measured memory_bytes: 4640
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        ArrayList<Long> list = new ArrayList<Long>(n);
        int count = 0;

        for(int i = 0;i < n;i++) {
            list.add(scan.nextLong());
        }

        Collections.sort(list);

        for(int i = 0;i < n - 2;i++) {
            for(int j = i + 1;j < n - 1;j++) {
                for(int k = j + 1;k < n;k++) {
                    if(list.get(i).equals(list.get(j)) || list.get(j).equals(list.get(k)) || list.get(i).equals(list.get(k))) {
                        continue;
                    }

                    if(list.get(i) + list.get(j) > list.get(k) && list.get(j) + list.get(k) > list.get(i) && list.get(k) + list.get(i) > list.get(j)) {
                        count++;
                    }
                }
            }
        }

        System.out.println(count);
    }
}


Measured memory_bytes: 38108
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);

		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int[] valus = {a, b, c};
		int min = valus[0];
		int max = valus[0];

		for(int i = 0; i < valus.length - 1; i++) {
			for(int j = 1; j < valus.length; j++) {
				min = Math.min(valus[i], valus[j]);
				max = Math.max(valus[i], valus[j]);

				valus[i] = min;
				valus[j] = max;

			}
		}

		for(int i = 0; i < valus.length; i++) {
			if(i == valus.length-1) {
				System.out.println(valus[i]);
			} else {
				System.out.print(valus[i] + " ");
			}
		}

	}

}


Measured memory_bytes: 26116
#pragma GCC optimize("O3") //コンパイラ最適化用

#define _GLIBCXX_DEBUG //配列に[]でアクセス時のエラー表示
#include <algorithm>   //sort,二分探索,など
#include <bitset>      //固定長bit集合
#include <chrono>      //実行時間計測
#include <cmath>       //pow,logなど
#include <complex>     //複素数
#include <deque>       //両端アクセスのキュー
#include <functional>  //sortのgreater
#include <iomanip>     //setprecision(浮動小数点の出力の誤差)
#include <iostream>    //入出力
#include <iterator>    //集合演算(積集合,和集合,差集合など)
#include <map>         //map(辞書)
#include <numeric>     //iota(整数列の生成),gcdとlcm,accumulate
#include <queue>       //キュー
#include <set>         //集合（順序保持）
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility> //pair
#include <vector>  //可変長配列
using namespace std;
typedef long long ll;
typedef long double ld;

#define REP(i, n) for (int i = 0; i < ll(n); i++)
#define REPD(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = a; i < ll(b); i++)
#define FORD(i, a, b) for (int i = a; i > ll(b); i--)
// xにはvectorなどのコンテナ
#define ALL(x) x.begin(), x.end()
#define SIZE(x) ll(x.size()) // sizeをsize_tからllに直しておく
const long long INF = 1e12;
const int MOD = 1e9 + 7;
#define MAXR 100000 // 10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define Umap unordered_map
#define Uset unordered_set
#define int long long
const unsigned int BIT_FLAG_0 = (1 << 0); // 0000 0000 0000 0001
const unsigned int BIT_FLAG_1 = (1 << 1); // 0000 0000 0000 0010
const unsigned int BIT_FLAG_2 = (1 << 2); // 0000 0000 0000 0100
const unsigned int BIT_FLAG_3 = (1 << 3); // 0000 0000 0000 1000
const unsigned int BIT_FLAG_4 = (1 << 4); // 0000 0000 0001 0000
const unsigned int BIT_FLAG_5 = (1 << 5); // 0000 0000 0010 0000
const unsigned int BIT_FLAG_6 = (1 << 6); // 0000 0000 0100 0000
const unsigned int BIT_FLAG_7 = (1 << 7); // 0000 0000 1000 0000
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

// https://qiita.com/Lily0727K/items/06cb1d6da8a436369eed#c%E3%81%A7%E3%81%AE%E5%AE%9F%E8%A3%85
void print() { cout << endl; }

template <class Head, class... Tail> void print(Head &&head, Tail &&... tail) {
    cout << head;
    if (sizeof...(tail) != 0)
        cout << " ";
    print(forward<Tail>(tail)...);
}

template <class T> void print(vector<T> &vec) {
    for (auto &a : vec) {
        cout << a;
        if (&a != &vec.back())
            cout << " ";
    }
    cout << endl;
}

template <class T> void print(vector<vector<T>> &df) {
    for (auto &vec : df) {
        print(vec);
    }
}

void add(long long &a, long long b) {
    a += b;
    if (a >= MOD)
        a -= MOD;
}
template <class T> inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

signed main() {

    vector<ll> count(8, 0);
    REP(i, 3) {
        int val;
        cin >> val;
        count[val]++;
    }

    if (count[5] == 2 && count[7] == 1) {
        print("YES");
    } else {
        print("NO");
    }
}


Measured memory_bytes: 3608
#include <iostream>
#include <stdlib.h>
#include <algorithm>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <string.h>
#include <string>
#include <cmath>
#include <cstdio>
#include <functional>
#include <map>
#include <typeinfo>
#include<bits/stdc++.h>
#define INF 1e9
using namespace std;
typedef long long ll;
typedef pair<int, int> pi;
typedef pair<double, double> pd;
typedef pair<ll, ll> pl;

int bricks[200001];

int main()
{
  FILE *inF, *outF;
  //inF = fopen("in", "r");
  //outF = fopen("out", "w");
  inF = stdin;
  outF = stdout;
  
  int n;
  fscanf(inF, "%d", &n);
  
  int idx = 1;
  int res = 0;
  
  for(int i = 0; i < n; i++)
  {
    fscanf(inF, "%d", &bricks[i]);
    if(bricks[i] != idx)
      res++;
    else
      idx++;
  }
  
  if(idx == 1)
    res = -1;
  
  printf("%d", res);
  
  
  return 0;
}


Measured memory_bytes: 1024
N = int(input())
Ai = list(map(int, input().split()))

i = []
for k in range(N):
    i.append(k+1)

res = zip(Ai, i)
res2 = sorted(res)

res3 = []
for i in range(len(res2)):
    res3.append(str(res2[i][1]))

print(' '.join(res3)) 

Measured memory_bytes: 26112
#include <math.h>
#include <algorithm>
#include <set>
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <string>
#include <cstring>
#include <functional>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <chrono>
#include <climits>
#include <bitset>
using namespace std ;
#define ld long double
#define int long long
#define ii pair<int,int>
#define FAST_IO ios_base::sync_with_stdio(false) ;cin.tie(NULL);cout.tie(NULL); clock_t beg = clock()
#define dbg(x) cerr << #x << " is " << x << endl;
#define ms(x,a) memset(x,(int)(a),sizeof(x))
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define vi vector<int >
#define pb push_back
#define endl '\n'
#define ff first
#define ss second
const int N = 3e5+7 ;
const int INF = 1e18 ;
const int MOD = 1e9 + 7 ;
string s ;

void solve(){
	int x,y,a,b,c ;
	cin >>x>>y>>a>>b>>c;
	vi p(a), q(b), r(c) ;
	for(auto& x : p) cin >> x ;
	for(auto& x : q) cin >> x ;
	for(auto& x : r) cin >> x ;
	sort(all(p)) ; sort(all(q)) ; sort(all(r)) ;
	reverse(all(p)) ; reverse(all(q)) ;
	for(int i = 0 ; i < a-x ; i++){
		p.pop_back() ;
	}
	for(int i = 0 ; i < b-y ; i++){
		q.pop_back() ;
	}
	p.insert(p.end(),all(q)) ;
	sort(all(p)) ;
	for(int i = 0 ; i < x+y ; i++){
		if(sz(r) && p[i]<r.back()){
			p[i] = r.back() ;
			r.pop_back() ;
		}
	}
	int ans = accumulate(all(p),0LL) ;
	cout << ans ;
} 

int32_t main(){
	FAST_IO ;
	int t = 1 ;
//	cin >> t ;
	while(t--){
		solve() ;
	}
    cerr << "\nExecution time: " << (clock() - beg) / 1000 << '\n';
}


Measured memory_bytes: 3968
#include <iostream>
#include <vector>
#include <string.h>
#include <algorithm>
#include <cstring>
#include <queue>
#include <assert.h>
#include <cmath>
#include <deque>
#include <set>
#include <unordered_map>
#include <complex>
#include <fstream>
using namespace std;
using ll = long long;
using ld = long double;
const int mxn = 110;

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

	int l, r, d; cin>>l>>r>>d;
	while(r%d) r--;
	while(l%d) l++;
	if(r<l) cout << 0 << '\n';
	else cout << (r-l)/d+1 << '\n';



	return 0;
}


Measured memory_bytes: 3196
// Template from https://techracho.bpsinc.jp/jhonda/2019_08_05/78537

// input macro for competive-programming from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };

    ($iter:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, bytes) => {
        read_value!($iter, String).into_bytes()
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    use std::io::Read;
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();

    println!("{}", solve(&s));
}

macro_rules! test {
    ($($input:expr => $output:expr),* $(,)*) => {
        #[test]
        fn solve_test() {
            $(
                assert_eq!(solve($input), $output);
            )*
        }
    };
}

test! {
r#"3 2 10 20
8 15 13
16 22"# => "No War",

r#"5 3 6 8
-10 3 1 5 -100
100 6 14"# => "War",
}

fn solve(src: &str) -> String {
    input! {
        source = src,
        n: usize, m: usize,
        x: isize, y: isize,

        xs: [isize; n],
        ys: [isize; m],
    }
    let mut ans = "War";

    for i in x + 1..y + 1 {
        if xs.iter().filter(|&j| j >= &i).count() == 0 && ys.iter().filter(|&j| j < &i).count() == 0 {
            ans = "No War";
            break;
        }
    }
    ans.to_string()
}

Measured memory_bytes: 4352
#include <iostream>

using namespace std;

const long long int MOD=1e9+7;

int main() {
    long long int ans=1;
    long long int N;
    cin >> N;
    
    for(long long int i=1; i<=N; i++) {
        ans *= i;
        ans %= MOD;
    }
    
    cout << ans << endl;

    return 0;
    
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
using namespace std;

#define pb         push_back
#define mp         make_pair
#define ll         long long
#define PI         acos(-1.0)
#define ALL(A)     ((A).begin(), (A).end())
#define vsort(v)   sort(v.begin(),v.end())
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)

int main(){
    string s;
    map<char, int> arab;
    arab['I'] = 1;
    arab['V'] = 5;
    arab['X'] = 10;
    arab['L'] = 50;
    arab['C'] = 100;
    arab['D'] = 500;
    arab['M'] = 1000;
    
    while(getline(cin, s)){
        int ans = 0;
        ans += arab[s[s.length()-1]];
        for(int i=s.length()-1; i>=1; i--){
            if(arab[s[i-1]] < arab[s[i]]) ans -= arab[s[i-1]];
            else ans += arab[s[i-1]];
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 3004
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace A2
{
    class Program
    {
        static void Main(string[] args)
        {
            int D = int.Parse(Console.ReadLine());
            int[] c_list = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            List<int[]> s_list = new List<int[]>();
            List<int> last_list = new List<int>();
            List<int> value_list = new List<int>();

            for (int i = 0; i < D; i++)
            {
                int[] s_array = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
                s_list.Add(s_array);
            }

            for (int i = 0; i < 26; i++)
            {
                last_list.Add(0);
                value_list.Add(0);
            }

            Random rand = new Random();

            for (int i = 1; i <= D; i++)
            {
                int type = rand.Next(1, 26);

                for (int j = 0; j < 26; j++)
                {
                    if (type - 1 == j)
                    {
                        value_list[j] += s_list[i - 1][j];
                        last_list[j] = i;
                    }
                    else
                    {
                        value_list[j] -= c_list[j] * (i - last_list[j]);
                    }
                }

                Console.WriteLine(type);
            }
        }
    }
}


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

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

using namespace std;

int main(){
	int n,k; cin>>n>>k;
	bool ng[10]={};
	rep(i,k){ int d; cin>>d; ng[d]=true; }

	while(1){
		char s[8]; sprintf(s,"%d",n);
		bool ok=true;
		for(int i=0;s[i];i++) if(ng[s[i]-'0']) ok=false;
		if(ok) break;
		n++;
	}

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

	return 0;
}


Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
  let stdin = 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")
}

fn read_n<T: FromStr>(n: usize) -> Vec<T> {
  read_n_logic::<T>(n, vec![])
}

fn read_n_logic<T: FromStr>(n: usize, mut a: Vec<T>) -> Vec<T> {
  match n {
    0 => a,
    _ => {
      a.push(read::<T>());
      read_n_logic(n - 1, a)
    }
  }
}

fn main() {
  let n = read::<usize>();
  let t = read::<f64>();
  let a = read::<f64>();
  let mut h = read_n::<f64>(n);

  for i in 0..h.len() {
    h[i] = t - h[i] as f64 * 0.006;
  }

  let mut near = (a - h[0]).abs();
  let mut answer = 0;

  for i in 1..h.len() {
    let distance = (a - h[i]).abs();
    if distance < near {
      near = distance;
      answer = i;
    }
  }

  println!("{}", answer + 1);
}


Measured memory_bytes: 4352
#!/usr/bin/env python3
# -*- coding: utf-8 -*-


def main():
    A, B, K = map(int, input().split())
    a = max(A - K, 0)
    K -= A - a
    b = max(B - K, 0)
    print(*[a, b])


if __name__ == "__main__":
    main()


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
int main(){
  int k;
  string s;
  cin>>k;
  cin>>s;
  if(s.size()>k){
    s.erase(k);
    cout<<s<<"..."<<endl;
  }else{
    cout<<s<<endl;
  }
}
  

Measured memory_bytes: 3624
#include<iostream>
#include<string>
#include<cmath>
#include<math.h>
//#include<array>
#include<algorithm>
#include<queue>
#include<deque>
#include<vector>
//#include<utility>
//#include<set>
//#include<map>
//#include<list>
//#include<bitset>
//#include<iomanip>

using namespace std;
using LLI = long long int;
LLI N;

//配列,座標
/*array<int, 8>dir_x = { 0,0,1,1,1,-1,-1,-1 };
array<int, 8>dir_y = { 1,-1,1,0,-1,1,0,-1 };
array<int, 4>dir_x2 = { 0,0,1,-1 };
array<int, 4>dir_y2 = { 1,-1,0,0 };
char alp[] = { 'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z' };*/

//Union Find
/*class UnionFind {
public:
	vector<int>data;
	UnionFind(int size) :data(size, -1) {};
	bool unionset(int x, int y) {
		x = root(x), y = root(y);
		if (x != y) {
			if (data[y] < data[x]) {
				swap(x, y);
			}
			data[x] += data[y];
			data[y] = x;
		}
		return x != y;
	}
	bool findset(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};*/

//最大公約数,最小公倍数
/*LLI gcd(LLI x, LLI y) {
	LLI  r;
	if (x < y) {
		swap(x, y);
	}
	r = x % y;
	while (r != 0) {
		x = y;
		y = r;
		r = x % y;
	}
	return y;
}
LLI lcm(LLI x, LLI y) {
	return x / gcd(x, y) * y;
}*/

//組み合わせ
/*long nCr(int n, int r) {
	long ans = 1;
	for (int i = n; i > n - r; i--) {
		ans = ans * i;
	}
	for (int i = 1; i < r + 1; i++) {
		ans = ans / i;
	}
	return ans;
}
long nHr(int n, int r) {
	n = n + r - 1;
	return nCr(n, r);
}*/

//素数判定
/*bool IsPrime(int num)
{
	if (num < 2) return false;
	else if (num == 2) return true;
	else if (num % 2 == 0) return false;

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			// 素数ではない
			return false;
		}
	}

	// 素数である
	return true;
}*/

//サンプル
/*const int n_max = 8;
array<array<bool, n_max>, n_max>graph;
int dfs(int v,int N,array<bool,n_max>visited) {
	int ret = 0;
	bool all_visited = true;
	for (int i = 0; i < N;i++) {
		if (visited[i] == false) {
			all_visited = false;
		}
	}
	if (all_visited) {
		return 1;
	}
	for (int i = 0; i < N;i++) {
		if (graph[v][i] == false) {
			continue;
		}
		if (visited[i] == true) {
			continue;
		}
		visited[i] = true;
		ret += dfs(i,N,visited);
		visited[i] = false;
	}
	return ret;
}*/

//サンプル
/*vector<vector<int>>sub;
int dfs(int id) {
	if (sub[id].size() == 0) {
		return 1;
	}
	int minP = (int)1e9;
	int maxP = 0;
	for (int i : sub[id]) {
		int P = dfs(i);
		minP = min(minP, P);
		maxP = max(maxP, P);
	}
	return minP + maxP + 1;
}*/

//#define debug(x) cerr << #x << " : " << x << endl
//#define debugv(x) cerr << #x << " : "; for(auto i:x) cerr << i << ", "; cerr<<endl

int main(void) {
	LLI A, B, res = 0;
	cin >> A >> B;
	res += A * B;
	if (A < B) {
		swap(A, B);
	}
	LLI tmp = A % B;
	while (tmp != 0) {
		A = B;
		B = tmp;
		tmp = A % B;
	}

	cout << res / B << endl;
}

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

using namespace std;

const int kMaxN = 100000;

int main() {
    int n;
    int A[kMaxN];

    cin >> n;

    int sum = 0;
    int x = 0;

    for (int i = 0; i < n; i++) {
        cin >> A[i];
        sum += abs(A[i] - x);
        x = A[i];
    }

    sum += abs(0 - A[n - 1]);

    for (int i = 0; i < n; i++) {
        if (i == 0) {
            x = 0;
        }
        else {
            x = A[i - 1];
        }

        int ans;

        if (i < n - 1) {
            ans = sum + abs(A[i + 1] - x) - (abs(A[i] - x) + abs(A[i + 1] - A[i]));
        }
        else {
            ans = sum + abs(0 - x) - (abs(A[i] - x) + abs(0 - A[i]));
        }

        cout << ans << endl;
    }
}


Measured memory_bytes: 1664
A,B = map(int,input().split())
if A==1 and B==1:
    A=14
    B=14
elif A==1 and B!=1:
    A=14
elif B==1 and A!=1:
    B=14
if A>B:
    print('Alice')
elif B>A:
    print('Bob')
elif A==B:
    print('Draw')


Measured memory_bytes: 3060
import sys
input = sys.stdin.readline
import fractions


def main():
    A, B, C, D = map(int, input().split())
    Aone = A - 1
    CDlcm = int(C /  fractions.gcd(C, D) * D)

    Bc = B // C
    Bd = B // D
    Blcm = B // CDlcm
    Bdec = B - Bc - Bd + Blcm

#    print(Bc,Bd,Blcm)

    Ac = Aone // C
    Ad = Aone // D
    Alcm = Aone // CDlcm
    Adec = Aone - Ac - Ad + Alcm

#    print(Ac,Ad,Alcm)

    print(Bdec - Adec)


main()

Measured memory_bytes: 5372
#include<bits/stdc++.h>
using namespace std;
int gcd(int a,int b){
	return b?gcd(b,a%b):a;
}
int x[100003];
int main(){
	int n,b,a,last;
	cin>>n;
	cin>>x[0];
	for(int i=1;i<=n;i++)
		cin>>x[i],
		a=gcd(max(a,max(x[i],x[i-1])-min(x[i],x[i-1])),min(a,max(x[i],x[i-1])-min(x[i],x[i-1])));
	cout<<a;
}

Measured memory_bytes: 640
#include <stdio.h>
#include <map>
#include <algorithm>

#define rep(i, n) for(int i=0; i<(int)(n); i++)
using namespace std;

int used[8];
char fie[50][50];
map<char, int> dict;
int minx[7], maxx[7], miny[7], maxy[7];
int c;

int H, W;

bool ok(int d) {
	if(d==c) return true;
	rep(i, c) if(used[i]==0) {
		used[i] = 1;
		bool f = true;
		for(int x=minx[i]; x<=maxx[i]; x++) {
			for(int y=miny[i]; y<=maxy[i]; y++) {
				if(used[dict[fie[x][y]]]==0) {
					f = false;
					goto loop_end;
				}
			}
		}
	loop_end:
		if(f) f = ok(d+1);
		used[i] = 0;
		if(f) return true;
	}
	return false;
}

int main()
{
	int N;
	scanf("%d", &N);
	rep(q, N) {
		dict.clear();
		fill_n(used, 8, 0);
		scanf("%d%d", &H, &W);
		c=0;
		rep(i, H) rep(j, W) {
			scanf(" %c", fie[j]+i);
			if(fie[j][i]!='.') {
				if(dict.find(fie[j][i])==dict.end()) {
					minx[c] = maxx[c] = j;
					miny[c] = maxy[c] = i;
					dict[fie[j][i]] = c++;
				}
				int d = dict[fie[j][i]];
				minx[d] = min(minx[d], j);
				maxx[d] = max(maxx[d], j);
				miny[d] = min(miny[d], i);
				maxy[d] = max(maxy[d], i);
			}
		}
		dict['.'] = 7;
		printf("%s\n", ok(0) ? "SAFE" : "SUSPICIOUS");
	}
	return 0;
}

Measured memory_bytes: 788
h, w = map(int, input().split(" "))
s = []
for i in range(h):
    s.append(str(input()))
d = [(1, 0), (0, 1), (-1, 0), (0, -1), (1, 1), (-1, 1), (1, -1), (-1, -1)]
ss = ["" for i in range(h)]
for i in range(w):
    for j in range(h):
        if s[j][i] == "#":
            ss[j] += "#"
            continue
        cnt = 0
        for dx, dy in d:
            if 0 <= i + dx < w and 0 <= j + dy < h:
                if s[j + dy][i + dx] == "#":
                    cnt += 1
        ss[j] = ss[j] + str(cnt)

for i in ss:
    print(i)


Measured memory_bytes: 9184