akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
	return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
	for(auto &e:u) fill_v<T>(e,v...);
}

::std::vector<::std::pair<::std::int64_t, ::std::int32_t>> primeFactors(::std::int64_t x) {
  ::std::vector<::std::pair<::std::int64_t, ::std::int32_t>> res;
  for (::std::int64_t i = 2; i*i <= x; ++i) {
    if (x % i == 0) {
      res.emplace_back(i, 1);
      x /= i;
      while (x % i == 0) x /= i, res.back().second++;
    }
  }
  if (x != 1) res.emplace_back(x, 1);
  return res;
}


int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int64 N;
  cin >> N;
  vector<int64> A(N), B(N);
  REP(i, N) {
    cin >> A[i] >> B[i];
    if (N%2 == 0) A[i]*=2, B[i]*=2;
//    zx[2*i] = A[i]; zx[2*i+1] = B[i];
  }
  sort(all(A)), sort(all(B), greater<int64>());
  if (N%2 == 0) {
    cout << (B[N/2] + B[N/2-1])/2 - (A[N/2] + A[N/2-1])/2 +1 << endl;
  } else {
    cout << B[N/2] - A[N/2] + 1 << endl;
  }
//  sort(all(zx)); zx.erase(unique(all(zx)), zx.end());
//  REP(i, N) {
//    A[i] = lower_bound(all(zx), A[i]) - zx.begin();
//    B[i] = lower_bound(all(zx), B[i]) - zx.begin();
//  }
//  vector<int64> suml(zx.size()+1, 0), sumr(zx.size()+1, 0);
//  REP(i, N) {
//    suml[A[i]]++;
//    sumr[B[i]]++;
//  }
//  REP(i, suml.size()-1) suml[i+1] += suml[i];
//  for (int i = sumr.size()-1; i > 0; i--) sumr[i-1] += sumr[i];
//  int64 l = INF, r = 0;
//  REP(i, suml.size()) {
//
//  }
}


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

int main()
{
	int n;
	int y, m, d;
	int count;
	cin >> n;
	for (int j = 0; j < n; j++) {
		cin >> y >> m >> d;
		count = 0;
		if ((y % 3 == 0) || (m % 2 == 1)) {
			count += 21 - d;
		} else {
			count += 20 - d;
		}
		for (int i = m + 1; i<= 10; i++) {
			if ((y % 3 == 0) || (i % 2 == 1)) {
				count += 20;
			} else {
				count += 19;
			}
		}
		for (int i = y + 1; i < 1000; i++) {
			if (i % 3 == 0) {
				count += 200;
			} else {
				count += 195;
			}
		}
		cout << count << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
int main()
{
	char n[20];
	int flag=1,i;
	scanf("%s",n);
	for(i=1;i<strlen(n);i++)
	{
		if(n[i]!='9')
			flag=0;
	}
	printf("%d",(strlen(n)-1)*9+(flag?n[0]-'0':n[0]-'1'));
	return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
// type alias
typedef long long LL;
typedef pair<int,int> II;
typedef tuple<int,int,int> III;
typedef vector<int> VI;
typedef vector<string> VS;
typedef unordered_map<int,int> MAPII;
typedef unordered_set<int> SETI;
template<class T> using VV=vector<vector<T>>;
// minmax
template<class T> inline T SMIN(T& a, const T b) { return a=(a>b)?b:a; }
template<class T> inline T SMAX(T& a, const T b) { return a=(a<b)?b:a; }
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// collection
#define ALL(c) (c).begin(),(c).end()
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// stdout
#define println(args...) fprintf(stdout, ##args),putchar('\n');
// debug cerr
template<class Iter> void __kumaerrc(Iter begin, Iter end) { for(; begin!=end; ++begin) { cerr<<*begin<<','; } cerr<<endl; }
void __kumaerr(istream_iterator<string> it) { (void)it; cerr<<endl; }
template<typename T, typename... Args> void __kumaerr(istream_iterator<string> it, T a, Args... args) { cerr<<*it<<"="<<a<<", ",__kumaerr(++it, args...); }
template<typename S, typename T> std::ostream& operator<<(std::ostream& _os, const std::pair<S,T>& _p) { return _os<<"{"<<_p.first<<','<<_p.second<<"}"; }
#define __KUMATRACE__ true
#ifdef __KUMATRACE__
#define dump(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); __kumaerr(_it, args); }
#define dumpc(ar) { cerr<<#ar<<": "; FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }
#define dumpC(beg,end) { cerr<<"~"<<#end<<": "; __kumaerrc(beg,end); }
#else
#define dump(args...)
#define dumpc(ar)
#define dumpC(beg,end)
#endif

// $ cp-batch AlmostEverywhereZero | diff AlmostEverywhereZero.out -
// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG -fsanitize=address AlmostEverywhereZero.cpp && ./a.out

/*
 
 4/6/2020
 
 21:13-
 
 */

const int MAX_N=101;
string S;
int K;

LL dp[MAX_N][5][2];
void solve() {
  ZERO(dp);
  dp[0][0][0]=1;
  int N=SZ(S);
  REP(i,N) {
    REPE(k,K)REP(less,2) {
      int curd=S[i]-'0';
      int lb=k>0?0:1,hb=less?9:curd;
//      dump(i,k,less,lb,hb,dp[i][k][less]);
      FORE(d,lb,hb) dp[i+1][k+(d!=0)][less|(d<curd)]+=dp[i][k][less];
    }
    dp[i+1][0][1]+=1;
  }
  cout<<dp[N][K][0]+dp[N][K][1]<<endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout<<setprecision(12)<<fixed;
  
  cin>>S>>K;
  solve();
  
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=200010,L=25;
int st[N][L],n,k;
int summ(int i,int j,int len){
	if(i>j) return 0;
	while(i+(1<<len)-1>j) --len;
	return st[i][len]+summ(i+(1<<len),j,len-1);
}
int main()
{
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;++i){
		int x;
		scanf("%d",&x);
		st[i][0]=x;
	}
	for(int j=1;j<L;++j){
		for(int i=1;i+(1<<j)-1<=n;++i){
			st[i][j]=st[i][j-1]+st[i+(1<<(j-1))][j-1];
		}
	}
	int ans=-1;
	for(int i=1,j=k;j<=n;++i,++j){
		int tmp=summ(i,j,L-3);
		if(tmp>ans) ans=tmp;
	}
	double maxi=(double)ans/2+(double)k/2;
	printf("%.12lf",maxi);
}

Measured memory_bytes: 19712
n = int(input())
a = list(map(int, input().split()))
o_cnt=0
t2_cnt=0
t4_cnt=0
for i in a:
    if i%2==1:
        o_cnt += 1
    elif i%4==0:
        t4_cnt += 1
    else:
        t2_cnt += 1

if t4_cnt > 0:
    if t4_cnt >= (o_cnt-n%2):
        print('Yes')
    else:
        print('No')
else:
    if t2_cnt==n:
        print('Yes')
    else:
        print('No')

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

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  
  int l = a + b;
  int r = c + d;
  
  if (l == r){
    cout << "Balanced" << endl;
  }
  else if (l > r) {
    cout << "Left" << endl;
  }
  else if (l < r) {
    cout << "Right" << endl;
  }

}

Measured memory_bytes: 256
//
#include <vector>
#include <set>
#include <array>
#include <iostream>
#include <cstdio>
#include <cstdint>
#include <algorithm>
#include <numeric>
#include <bitset>
//
using ll = long long;
using namespace std;
#define rep(i,n) for(ll i=0;i<(n);++i)
inline void yes(bool cond) { cond ? puts("Yes") : puts("No"); }
template<typename Type> inline void chmin(Type& a, Type b) { if (a > b) a = b; }
template<typename Type> inline void chmax(Type& a, Type b) { if (a < b) a = b; }
#define BIGP   1000000007
#define INF_I  std::numeric_limits<ll>::max()
#define INF_F  std::numeric_limits<float>::infinity()
//
int main()
{
    cin.tie(0); ios::sync_with_stdio(false);
    ll N;
    struct T
    {
    public:
        ll a;
        ll b;
        ll c;
    };
    vector<T> t;
    cin >> N;
    rep(i, N)
    {
        ll a, b, c;
        cin >> a >> b >> c;
        t.push_back({a,b,c});
    }
    vector<T> h(N, {0,0,0});
    //
    h[0].a = t[0].a;
    h[0].b = t[0].b;
    h[0].c = t[0].c;
    //
    for(ll i=1;i<N;++i)
    {
        ll i1 = i - 1;
        h[i].a = t[i].a + max(h[i1].b, h[i1].c);
        h[i].b = t[i].b + max(h[i1].a, h[i1].c);
        h[i].c = t[i].c + max(h[i1].a, h[i1].b);
    }
    auto& l = h.back();
    cout << max({ l.a, l.b, l.c });
}

Measured memory_bytes: 7564
n,x,y = map(int,input().split())

ans = [0 for i in range(n)]

for i in range(1,n+1):
    for j in range(i+1,n+1):
        p1 = j-i
        p2 = abs(i-x)+abs(j-y)+1
        ans[min(p1,p2)] += 1
for i in range(1,n):
    print(ans[i])


Measured memory_bytes: 3444
from collections import defaultdict,deque
import numpy as np
import sys,heapq,bisect,math,itertools,string,queue,copy,time
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(input())
def inpl(): return list(map(int, input().split()))
def inpl_str(): return list(input().split())

N = inp()
abc = [inpl() for _ in range(N)]
dp = [[0]*3 for _ in range(N)]
dp[0] = abc[0]

for i in range(1,N):
    a,b,c = abc[i]
    dp[i][0] = max(dp[i-1][1],dp[i-1][2])+a
    dp[i][1] = max(dp[i-1][2],dp[i-1][0])+b
    dp[i][2] = max(dp[i-1][0],dp[i-1][1])+c

print(max(dp[-1]))


Measured memory_bytes: 57664
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int main() {
    ll n,m;
    cin >> n >> m;
    vector<ll> vec(n);
    rep(i,n) cin >> vec[i];
    ll count=0;
    ll x=vec[0];
    while(x%2==0){
        count++;
        x/=2;
    }
    ll y=pow(2,count);
    rep(i,n){
        if(vec[i]%y==0&&vec[i]%(y*2)!=0){
            vec[i]/=2;
        }
        else{
            cout << 0 << endl;
            return 0;
        }
    }
    ll ans=1;
    rep(i,n){
        ans=lcm(ans,vec[i]);
        if(ans>10000000000){
        cout << 0 << endl;
        return 0;
        }
    }
    ll fans=0;
    if(m>=ans)fans=(m-ans)/(2*ans)+1;
    cout << fans << endl;
}

Measured memory_bytes: 4440
#include <bits/stdc++.h>
#include <stdio.h>
#include <math.h>
using namespace std;
using vi = vector<int>;
using vll = vector<long long int>;
using vb = vector<bool>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<long long int>>;
using ll = long long int;

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

Measured memory_bytes: 3628
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
	int n;
  cin>>n;
  int p[10];
  int mx=0;
  int sum=0;
  for(int i=0; i<n; i++){
    cin>>p[i];
    sum+=p[i];
    mx=max(p[i], mx);
  }
  cout<<sum-mx/2<<endl;
	return 0;
}

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

#define pb push_back
#define F first
#define S second
#define ALL(a) (a).begin(),(a).end()
#define SKY ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define int long long int
void solve()
{
    int X,K,D;
    cin >> X >> K >> D;
    // 7 4 3
    int X1=abs(X);
    int req = X1/D;
    if(req<=K)
    {
        K-=req;
        X1-=req*D;
        if(K&1)
            cout << min(abs(X1+D),abs(X1-D));
        else cout << X1 << "\n";
    }
    else
    {
        X1-=(K*D);
        cout<<X1;
    }
    return;
    
}
int32_t main()
{
    SKY;
    int T = 1;
    //cin >> T;
    for(int i = 1 ; i <= T ; i++)
        solve();
    return 0;
}
/*
 Umang Agrawal
 */


Measured memory_bytes: 3648
#include <iostream>
#include <stdio.h>
 
using namespace std;
 
int main(){
 	while(1){
 		int A[10000],n,count=0,t=0;
 		cin >> n;
 		if(n == 0) break;

 		for(int i = 0;i<n;i++){
 			cin >> A[i];
 			if(A[i]<2){
 				count++;
 			}
 			if(A[i]==0){
 				t++;
 			}
 		}

 		if(count == n) cout << "NA" <<endl;
 		else if(n==1) cout << "2"<<endl;
 		else cout << n+1-t <<endl;
 	}
    return 0;
}


Measured memory_bytes: 3152
import sys
import math
from collections import deque

sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7
input = lambda: sys.stdin.readline().strip()
NI = lambda: int(input())
NMI = lambda: map(int, input().split())
NLI = lambda: list(NMI())
SI = lambda: input()


def make_grid(h, w, num): return [[int(num)] * w for _ in range(h)]


def main():
    N = NI()
    D = {"AC": 0, "WA": 0, "TLE": 0, "RE": 0}
    for i in range(N):
        D[SI()] += 1
    for x, y in D.items():
        print("{0} x {1}".format(x, y))


if __name__ == "__main__":
    main()

Measured memory_bytes: 9496
n = int(input())
a = [int(input()) for i in range(n)]
ans = 0
if a[0]!=0:
    print(-1)
    exit()
for i in range(1,n):
    if a[i]>a[i-1]+1:
        print(-1)
        exit()
    if a[i] == a[i-1] +1:
        ans += 1
    elif a[i] <= a[i-1]:
        ans += a[i]
print(ans)

Measured memory_bytes: 11052
#define _USE_MATH_DEFINES
#include <iomanip>
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <tuple>
#include <climits>
#include <algorithm>
#include <cmath>
using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<double> VD;
typedef vector<LL> VLL;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<vector<int>> VVI;
typedef vector<vector<long long>> VVLL;
typedef vector<vector<bool>> VVB;
typedef vector<vector<double>> VVD;

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

const int MOD = 1000000007;

template<class T>bool chmax(T &a, const T &b){
	if(a<b){
		a=b;
		return true;
	}
	return false;
}

template<class T>bool chmin(T &a, const T &b){
	if(a>b){
		a=b;
		return true;
	}
	return false;
}

void debug(VI &arr){
	int n=arr.size();
	rep(i,n){
		cout<<arr.at(i)<<endl;
	}
}

void debug(VVI &board){
	int h = board.size();
	int w = board.at(0).size();
	rep(i,h){
		rep(j,w){
			cout << board.at(i).at(j) << " ";
		}
		cout<<endl;
	}
}

void debug(VVLL &board){
	int h = board.size();
	int w = board.at(0).size();
	rep(i,h){
		rep(j,w){
			cout<<board.at(i).at(j)<<" ";
		}
		cout<<endl;
	}
}

void debug(VS &board){
	int h = board.size();
	rep(i,h){
		cout<<board.at(i)<<endl;
	}
	return;
}

LL gcd(LL a,LL b){
	return b==0?a:gcd(b,a%b);
}

LL lcm(LL a,LL b){
	return a*b/gcd(a,b);
}

int main(){
	//cout<<fixed;
	//cout<<setprecision(9)<<...
	LL n;
	cin>>n;
	LL ans=0;
	for(LL i=1;i<=n;i++){
		if(i%3==0 or i%5==0)continue;
		ans+=i;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3640
# -*- coding:utf-8 -*-
"""解説
二分探索 O(log(N))

あるxの地点での寺と神社に行くパターン数は、
・西に行き、寺か神社に行く
・東に行き、寺か神社に行く

その後、
・西に行き、寺か神社に行く
・東に行き、寺か神社に行く

の8パターンしかない。

"""
import bisect

def solve():
    A, B, Q = list(map(int, input().split()))
    S, T, X = [], [], []
    for i in range(A):
        S.append(int(input()))
    for i in range(B):
        T.append(int(input()))
    for i in range(Q):
        X.append(int(input()))
    INF = 10**11+1
    S.append(INF)
    S.append(-INF)
    T.append(INF)
    T.append(-INF)
    S.sort()
    T.sort()
    
    """
    ・x -> 最寄りのS -> 最寄りのT
    ・x -> 最寄りのT -> 最寄りのS
    のどちらか最小値が答え？
    """
    for q in range(Q):
        x = X[q]

        # x -> 左の神社 -> 寺パターン
        index = bisect.bisect_left(S, x)
        l_s_index, r_s_index = index-1, index

        tmp_ans = abs(S[l_s_index]-x)
        index_t = bisect.bisect_left(T, S[l_s_index])
        l_t_index, r_t_index = index_t-1, index_t
        ans = tmp_ans + abs(T[l_t_index]-S[l_s_index])
        ans = min(ans, tmp_ans + abs(T[r_t_index]-S[l_s_index]))

        # x -> 右の神社 -> 寺パターン
        tmp_ans = abs(S[r_s_index]-x)
        index_t = bisect.bisect_left(T, S[r_s_index])
        l_t_index, r_t_index = index_t-1, index_t
        ans = min(ans, tmp_ans+abs(T[l_t_index]-S[r_s_index]))
        ans = min(ans, tmp_ans+abs(T[r_t_index]-S[r_s_index]))

        # x -> 左の寺 -> 神社パターン
        index_t = bisect.bisect_left(T, x)
        l_t_index, r_t_index = index_t-1, index_t

        tmp_ans = abs(T[l_t_index]-x)
        index_s = bisect.bisect_left(S, T[l_t_index])
        l_s_index, r_s_index = index_s-1, index_s
        ans = min(ans, tmp_ans+abs(S[l_s_index]-T[l_t_index]))
        ans = min(ans, tmp_ans+abs(S[r_s_index]-T[l_t_index]))

        # x -> 右の寺 -> 神社パターン
        tmp_ans = abs(T[r_t_index]-x)
        index_s = bisect.bisect_left(S, T[r_t_index])
        l_s_index, r_s_index = index_s-1, index_s
        ans = min(ans, tmp_ans+abs(S[l_s_index]-T[r_t_index]))
        ans = min(ans, tmp_ans+abs(S[r_s_index]-T[r_t_index]))

        print(ans)


if __name__ == "__main__":
    solve()


Measured memory_bytes: 16104
import re
a, b = map(int, input().split())
s = input()
#a文字目までとハイフン以降b文字目までで分ける
s_a = s[0:a]
s_b = s[a+1:]
#print(s_a, s_b)
#正規表現でs_aとs_bがすべて数字ならOK(数字でない場合はNone)
if s[a] == '-' and re.fullmatch(r'[0-9]+', s_a) != None and re.fullmatch(r'[0-9]+', s_b):
    print('Yes')
else:
    print('No')


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

int main(){
  string S;
  long long K;
  cin >> S >> K;
  for(int i=0;i<min(( long long)S.size(),K);i++){
    if(S[i] >= '2'){
      cout << S[i] << endl;
      return 0;
    }
  }
  cout << '1' << endl;
}


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

int main() {
  long long N, x; cin >> N >> x;
  long long A[N]; for (int i = 0; i < N; i++) cin >> A[i];
  
  sort(A, A + N);
  long long count = 0;
  for (long long i = 0; i < N; i++){
    if (i == N - 1){
      if (A[i] == x) count++;
      break;
    }
    if (A[i] <= x){
      count++;
      x -= A[i];
    }
  }
  cout << count << endl;
}

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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;++A)
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////
ll A,B;

ll i, j, k;
int main(){
    scanf("%lld%lld", &A, &B);
    if(A+B<=9){
        printf("%lld\n", A + B);
    }else{
        printf("error\n");
    }

    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define PF push_front
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double
#define pii pair<int,int>
#define pll pair<LL,LL>
#define vi vector<int>
#define vl vector<LL>
#define vii vector<vi>
#define vll vector<vl>

const double pi = 3.14159265358979323846264;
const int mod=1000000007;

int main(){
	int k,q;
    cin>>k>>q;
    vi d(k);
    FOR(i,0,k){
        cin>>d[i];
    }
    vi n(q),x(q),m(q);
    FOR(i,0,q){
        cin>>n[i]>>x[i]>>m[i];
        LL ans=n[i]-1;
        vi aa(d),a(d);
        LL sm=0,cnt=0;
        LL n_mod_k=(n[i]-1)%k,nw=x[i]%m[i],rep=(n[i]-1)/k;
        FOR(j,0,k){
            aa[j]=aa[j]%m[i];
            if(aa[j]==0)cnt++;
            sm+=aa[j];
            if(j<n_mod_k){
                //cerr<<"j:"<<j<<" aa[j]:"<<aa[j]<<" nw:"<<nw<< endl;
                LL nx=(nw+aa[j])%m[i];
                if(nw>=nx){
                    ans--;
                }
                nw=nx;
            }
        }
        FOR(i,0,k){
            a[i]=aa[(i+n_mod_k)%k];
        }
        LL t=(nw+rep*sm)/m[i];
        //cerr<<"ans:"<<ans<<" t:"<<t<<" rep:"<<rep<<" sm:"<<sm<<" n_mod_k:"<<n_mod_k<< endl;
        ans-=t+rep*cnt;



        cout<<ans<<endl;
    }

}


Measured memory_bytes: 384
import java.util.*;

public class Main {
    static Scanner scanner = new Scanner(System.in);

    public static void main(String[]$) {
        int s = scanner.nextInt();
        boolean yymm = false;
        boolean mmyy = false;

        if (s % 100 <= 12 && s % 100 > 0) {
            yymm = true;
        }
        if (s / 100 <= 12 && s / 100 > 0) {
            mmyy = true;
        }

        if (yymm && mmyy) {
            System.out.println("AMBIGUOUS");
        } else if (yymm) {
            System.out.println("YYMM");
        } else if (mmyy) {
            System.out.println("MMYY");
        } else {
            System.out.println("NA");
        }
    }
}

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

#define endl "\n"

#define pi 2*acos(0)
#define INF 1e16
#define MIN 1e-9
#define min(a,b) (((a)<(b))?(a):(b))
#define max(a,b) (((a)>(b))?(a):(b))
#define m_p make_pair
#define p_b push_back
#define ff first
#define ss second
#define n_p(a) next_permutation(all(a))
#define all(v) v.begin(),v.end()
#define ii pair<int, int>
#define vi vector<int>
#define vii vector<ii>
#define vvi vector<vi>
#define rev(s) reverse(all(s))
#define ull unsigned long long
#define ll long long
#define MOD 1000000007
#define mem(a,k) memset(a,k,sizeof a)
#define REP(i, a, b) for (int i = int(a); i <= int(b); i++)
#define u_b(X,V) upper_bound(X.begin(),X.end(),V)
#define l_b(X,V) lower_bound(X.begin(),X.end(),V)
#define cnt(s,c) count(all(s),c)

//bitwise helpers
#define isOn(S, j) (S & (1 << j))
#define setBit(S, j) (S |= (1 << j))
#define clearBit(S, j) (S &= ~(1 << j))
#define toggleBit(S, j) (S ^= (1 << j))
#define lowBit(S) (S & (-S))
#define setAll(S, n) (S = (1 << n) - 1)

#define modulo(S, N) ((S) & (N - 1))
#define isPowerOfTwo(S) (!(S & (S - 1)))
#define nearestPowerOfTwo(S) ((int)pow(2.0, (int)((log((double)S) / log(2.0)) + 0.5)))
#define turnOffLastBit(S) ((S) & (S - 1))
#define turnOnLastZero(S) ((S) | (S + 1))
#define turnOffLastConsecutiveBits(S) ((S) & (S + 1))
#define turnOnLastConsecutiveZeroes(S) ((S) | (S - 1))

using namespace std;

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

    int t;

    //cin >> t;
    t = 1;
    for(int test = 1; test <= t ; test++) {
        int n;
        cin >> n;
        int v[n], c[n];
        int res = 0;
        for(int i = 0; i < n; i++)
            cin >> v[i];
        for(int i = 0; i < n; i++) {
            cin >> c[i];
            if(v[i] > c[i])
                res += (v[i] - c[i]);
        }
        cout << res << endl;
    }

    return 0;
}


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

int main(){
    int i, n;
    char c[100];
    cin >> n >> c;

    if(n % 2 != 0){
        cout << "No" << endl;
        return 0;
    }

    for(i=0; i<n/2; i++){
        if(c[i] != c[n/2 + i]){
            cout << "No" << endl;
            return 0;
        }
    }

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

Measured memory_bytes: 256
//-------------
//include
//-------------
#include <map>
#include <list>
#include <cmath>
#include <vector>
#include <string>
#include <cctype>
#include <cstdlib>
#include <iostream>
#include <algorithm>
using namespace std;
//-------------
//typedef
//-------------
typedef  long long LL;
typedef  vector<int> VI;
typedef  vector<double> VD;
typedef  string STR;
typedef  pair<int, int> PII;
typedef  vector<int, int> VII;
typedef  map<string, int> MSI;
//-------------
//utillty
//-------------
#define ALL(a)  (a).begin(),(a).end()
#define MK make_pair
#define PB push_back
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define COUT(a) cout<<a<<endl
#define POW2(a) pow(a, 2.0)
//-------------
//repetition
//-------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
//-------------
//debug
//-------------
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define dumpl(c) REP(i,SZ(c))cerr<<#c<<i<<"="<<(c[i])<<endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const int MOD = 1000000007;
int main()
{
	int a, b;
	cin >> a>> b;
	COUT((b*2)-a);
#ifdef _DEBUG
	while(1);
#endif // _DEBUG

	return 0;
}

Measured memory_bytes: 256
// warm heart, wagging tail,and a smile just for you!
//                                                                     ███████████
//                                                                   ███╬╬╬╬╬╬╬╬╬╬███
//                                                                ███╬╬╬╬╬████╬╬╬╬╬╬███
//                                            ███████████       ██╬╬╬╬╬████╬╬████╬╬╬╬╬██
//                                      █████████╬╬╬╬╬████████████╬╬╬╬╬██╬╬╬╬╬╬███╬╬╬╬╬██
//                               ████████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬██╬╬╬╬╬╬╬██
//                             ████╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬╬╬╬╬╬██
//                           ███╬╬╬█╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬███╬╬╬╬╬╬╬█████
//                         ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬████████╬╬╬╬╬██
//                       ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬╬╬╬╬███
//                     ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬██
//                 ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬████
//     █████████████╬╬╬╬╬╬╬╬██╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬██████
//   ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬██████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████╬╬╬╬╬╬╬███████████╬╬╬╬╬╬╬╬██╬╬╬██╬╬╬██
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬█╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬██
// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬▓▓▓▓▓▓╬╬╬████╬╬████╬╬╬╬╬╬╬▓▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬███
// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████▓▓▓▓▓▓▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬█████
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████████
//   ███╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██
//       ██████████████  ████╬╬╬╬╬╬███████████████████████████╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████
//                         ███████                           █████  ███████████████████  
//
#include "bits/stdc++.h"
using namespace std;
#define INF (1<<30)
#define LINF (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 << " " << 
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
#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 tuple<int,int,int> T;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

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

  double x,y;
  cin >> x >> y;

  cout << fixed << x*y/(x+y) << endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <cassert>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <algorithm>
#include <utility>
#define llint long long
#define inf 1e18
#define rep(x, s, t) for(llint (x) = (s); (x) < (t); (x)++)
#define Rep(x, s, t) for(llint (x) = (s); (x) <= (t); (x)++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))

using namespace std;
typedef pair<llint, llint> P;

struct edge{
	llint to, cost;
	edge(){}
	edge(llint a, llint b){
		to = a, cost = b;
	}
};

llint n;
string s[55], revs[55];
llint c[55];
vector<edge> G[10005];
llint dist[10005];

inline llint get(llint i, llint j, llint k)
{
	return k + 30 * j + 80 * i;
}

bool pali(string &s)
{
	for(int i = 0; i < s.size(); i++){
		if(s[i] != s[(int)s.size()-1-i]) return false;
	}
	return true;
}

bool check(string &s, string &t)
{
	for(int i = 0; i < min(s.size(), t.size()); i++){
		if(s[i] != t[i]) return false;
	}
	return true;
}

void dijkstra(vector<edge> G[], llint S, llint dist[])
{
	for(int i = 0; i <= 10000; i++) dist[i] = inf;
	dist[S] = 0;
	
	priority_queue< P, vector<P>, greater<P> > Q;
	Q.push( make_pair(0, S) );
	
	llint v, d;
	while(Q.size()){
		d = Q.top().first;
		v = Q.top().second;
		Q.pop();
		if(dist[v] < d) continue;
		for(int i = 0; i < G[v].size(); i++){
			if(dist[G[v][i].to] > d + G[v][i].cost){
				dist[G[v][i].to] = d + G[v][i].cost;
				Q.push( make_pair(dist[G[v][i].to], G[v][i].to) );
			}
		}
	}
}

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n;
	for(int i = 1; i <= n; i++){
		cin >> s[i] >> c[i];
		revs[i] = s[i];
		reverse(revs[i].begin(), revs[i].end());
	}
	
	llint S = 8000, T = 8001;
	for(int i = 1; i <= n; i++){
		for(int j = 0; j < 2; j++){
			for(int k = 0; k < s[i].size(); k++){
				
				llint v = get(i, j, k);
				string str;
				if(j == 0) str = s[i].substr(k);
				else str = revs[i].substr(k);
				
				if(pali(str)) G[v].push_back(edge(T, 0));
				
				for(int l = 1; l <= n; l++){
					string str2;
					if(j == 0) str2 = revs[l];
					else str2 = s[l];
					
					if(!check(str, str2)) continue;
					//cout << str << " " << str2 << endl;
					if(str.size() == str2.size()) G[v].push_back(edge(T, c[l]));
					else if(str.size() > str2.size()){
						G[v].push_back(edge(get(i, j, k+str2.size()), c[l]));
					}
					else{
						G[v].push_back(edge(get(l, 1-j, (llint)str.size()), c[l]));
					}
				}
			}
		}
	}
	for(int i = 1; i <= n; i++){
		for(int j = 0; j < 2; j++){
			G[S].push_back(edge(get(i, j, 0), c[i]));
		}
	}
	
	dijkstra(G, S, dist);
	
	/*for(int i = 1; i <= n; i++){
		for(int j = 0; j< 2; j++){
			for(int k = 0; k <= s[i].size(); k++){
				cout << i << " " << j << " " << k << " " << dist[get(i, j, k)] << endl;
			}
		}
	}*/
	
	if(dist[T] > inf/2) cout << -1 << endl;
	else cout << dist[T] << endl;
	
	return 0;
}

Measured memory_bytes: 3992
#include<algorithm>
#include<cstdio>

using namespace std;

int read()
{
    int x=0;        bool f=0;        char k=getchar();
    while(k< '0'||k> '9') (k=='-')&&(f=1),k=getchar();
    while(k>='0'&&k<='9') x=(x*10)+(k&15),k=getchar();
    return (f)?(-x):(x);
}

const int maxn=1e5+5;
int tong[maxn];

signed main()
{
    int n=read();
    for(int i=1;i<=n;i++)
    {
        int x=read();
        tong[x]=i;
    }
    for(int i=1;i<=n;i++)
    {
        printf("%d ",tong[i]);
    }
}

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

int main() {
  int n;
  string s;
  cin >> n >> s;
  bool echo = true;
  if (n % 2) echo = false;
  rep(i, n/2) if (s[i] != s[n/2+i]) echo = false;
  if (echo) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

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

int main()
{
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++)
	{
		int x = i;
		if (x%3 == 0)
		{
			cout << " " << i;
		}
		else
		{
			while (x > 0)
			{
				if (x % 10 == 3)
				{
					cout << " " << i;
					break;
				}
				x /= 10;
			}
		}
	}
	cout << "\n";
	return 0;
}



Measured memory_bytes: 3088
import java.util.*;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int pizaA = sc.nextInt();
    int pizaB = sc.nextInt();
    int pizaAB = sc.nextInt();
    int pieceOfA = sc.nextInt();
    int pieceOfB = sc.nextInt();
    if (pizaA + pizaB <= 2 * pizaAB) {
      System.out.println(pizaA * pieceOfA + pizaB * pieceOfB);
    } else {
      if (pieceOfA > pieceOfB) {
        System.out.println(2 * pizaAB * pieceOfB + 
                                                  (pieceOfA - pieceOfB) * Math.min(pizaA, 2 * pizaAB));
      } else if (pieceOfA == pieceOfB) {
        System.out.println(2 * pizaAB * pieceOfA);
      } else {
        System.out.println(2 * pizaAB * pieceOfA +
                                                 (pieceOfB - pieceOfA) * Math.min(pizaB, 2 * pizaAB));
      }
      
      
      
    }
  }
}

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

int  main()
{
	char b; cin >> b;
	map<char,char> mp;
	mp['A'] = 'T'; mp['T'] = 'A';
	mp['C'] = 'G'; mp['G'] = 'C';
	cout << mp[b] << endl;
	return (0);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 1LL << 60;
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; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};


int main() {
    char N;
    cin >>N;
    if(N>='A' && N<='Z'){
        cout<<'A'<<endl;
    }else{
        cout<<'a'<<endl;
    }



    return 0;
    

}

Measured memory_bytes: 3632
K, N = map(lambda x: int(x), input().split(" "))
As = list(map(lambda x: int(x), input().split(" ")))

result_list = []
for i in range(len(As)-1):
    result_list.append(As[i+1]-As[i])
result_list.append(K-As[-1]+As[0])

result = sum(result_list) - max(result_list)

print(result)


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

template<typename T, typename U>
using pv=vector<pair<T,U>>;
template<typename T>
using matrix=vector<vector<T>>;
template<typename T>
using pque=priority_queue<T>;
template<typename T>
using lpque=priority_queue<T,vector<T>,greater<T>>;

using ll=long long;
using intpair=pair<int,int>;
using llpair=pair<ll,ll>;
using ilpair=pair<int,ll>;
using lipair=pair<ll,int>;
using intvec=vector<int>;
using llvec=vector<ll>;
using intq=queue<int>;
using llq=queue<ll>;
using intmat=vector<intvec>;
using llmat=vector<llvec>;

#define PI 3.141592653589793
#define INTINF ((1<<30)-1)
#define LLINF 1LL<<60
#define MPRIME 1000000007
#define MPRIME9 998244353
#define MMPRIME (1ll<<61)-1

#define len length()
#define pushb push_back
#define fi first
#define se second

#define setpr fixed<<setprecision(15)
#define all(name) name.begin(),name.end()
#define rall(name) name.rbegin(),name.rend()
#define gsort(vbeg,vend) sort(vbeg,vend,greater<>())

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

template<class T>
inline void init(T& v) {
	for(auto &a: v) cin>>a;
}
template<class T, class U>
inline void init(vector<pair<T,U>>& v) {
	for(auto &a: v) cin>>a.first>>a.second;
}
template<class T, class N>
inline void init(T& v, N n) {
	v.resize(n);
	for(auto &a: v) cin>>a;
}
template<class T, class U, class N>
inline void init(vector<pair<T,U>>& v, N n) {
	v.resize(n);
	for(auto &a: v) cin>>a.first>>a.second;
}

inline void out() {
	cout<<endl;
}
template<class T, class... U>
inline void out(T a, U... alist) {
	cout<<a<<" ";
	out(forward<U>(alist)...);
}

template<class N>
void resiz(N n) {
	//empty
}
template<class N, class T, class... U>
void resiz(N n, T&& hd, U&&... tl) {
	hd.resize(n);
	resiz(n,forward<U>(tl)...);
}

bool isout(int h, int w, int H, int W) {
	return ( h<0 || h>=H || w<0 || w>=W );
}

ll binpow(ll a, ll ex, ll p) {
	ll result=1;
	while(ex>0) {
		if(ex&1) result=result*a%p;
		ex>>=1;
		a=a*a%p;
	}
	return result;
}


int H,W;
char mp[50][50];
int dy[]={0,-1,-1,-1,0,1,1,1},
	dx[]={1,1,0,-1,-1,-1,0,1};

void input() {
	cin>>H>>W;
	for(int i=0; i<H; i++) for(int j=0; j<W; j++) {
		cin>>mp[i][j];
	}
}

void solve() {
	for(int h=0; h<H; h++) for(int w=0; w<W; w++) {
		if(mp[h][w]=='#') continue;
		int num=0;
		for(int i=0; i<8; i++) {
			int nh=h+dy[i], nw=w+dx[i];
			if(isout(nh,nw,H,W)) continue;
			if(mp[nh][nw]=='#') num++;
		}
		mp[h][w]=char('0'+num);
	}

	for(int i=0; i<H; i++) {
		for(int j=0; j<W; j++) {
			cout<<mp[i][j];
		}
		cout<<'\n';
	}
	cout<<flush;
}

int main() {
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout<<fixed<<setprecision(15);
	int t=1;
	while(t) {
		input();
		solve();
		t--;
	}
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define pii pair<int, int>
#define pll pair<ll, ll>
#define F first
#define S second
#define pb push_back
#define pp pop_back
#define ubo upper_bound
#define lbo lower_bound
#define VI vector<int>
#define VL vector<ll>
#define VP vector<pii >
#define all(x) x.begin(), x.end()
#define M vector<VI >

using namespace std;

int main(){

	string s, t;
	cin >> s >> t;
	int n = s.size(), ans = 0;
	for(int i=0; i<n; i++) if(s[i] != t[i]) ans++;
	cout << ans << '\n';

	return 0;
}


Measured memory_bytes: 3856
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using P = pair<int, int>;
using vec = vector<lint>;
using mat = vector<vector<int>>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"

constexpr int MOD = 1000000007;
const int INF = 1 << 30;

lint dp[110][200010];

int main() {
    int n, W;
    cin >> n >> W;
    vec w(n), v(n);
    rep(i, n) cin >> w[i] >> v[i];

    rep(i, n) {
        int ni = i+1;
        for (int j = 0; j <= W; j++) {
            dp[ni][j] = max(dp[ni][j], dp[i][j]);
            dp[ni][j + w[i]] = max(dp[ni][j + w[i]], dp[i][j] + v[i]);
        }
    }

    lint res = 0;
    for (int i = W; i >= 0; i--) res = max(res, dp[n][i]);
    cout << res << endl;
    return 0;
}

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

int main(){
    int n;
    cin>>n;
    vector<int> a(n);
    for(int i=0;i<n;i++)cin>>a[i];
    for(int i=0;i<n;i++){
        for(int j=0;i<n;j++){
            if(a[j]==i+1){cout<<j+1<<" ";break;} 
        }
    }
    
}

Measured memory_bytes: 1152
readInt() = parse(Int,readline())

sigma(a,n) = div((n+1)n*a,2)

function solve()
    ans = 0
    N = readInt()
    f = fill(0, N)
    for i in 1:N
        ans += sigma(i,div(N,i))
    end
    println(ans)
end

solve()

Measured memory_bytes: 236656
def BF(N, edges, start):
    D = {}
    P = {}
    for i in range(N):
        P[i] = None
        if i == start:
            D[i] = 0
        else:
            D[i] = float("inf")

    for i in range(N-1):
        for edge in edges:
            a, b, c = edge
            if D[b] > D[a] + c:
                D[b] = D[a] + c
                P[b] = a

    ret = (D, P)

    Nega = {}
    for i in range(N):
        Nega[i] = False
    
    for i in range(N):
        for edge in edges:
            a, b, c = edge
            if Nega[a] == True:
                Nega[b] = True
            if D[b] > D[a] + c:
                D[b] = D[a] + c
                P[b] = a
                Nega[b] = True
        
    return (D, P, Nega)


N,M = (int(i) for i in input().split())
edges = []
for i in range(M):
    a,b,c = (int(i) for i in input().split())
    edges.append((a-1, b-1, -c))

D, P, Nega = BF(N, edges, 0)

if Nega[N-1]:
    print("inf")
else:
    print(-D[N-1])

Measured memory_bytes: 48600
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
using ld = long double;
const ll ATCODER_AMARI = 1000000007; //10^9 + 7
const ll INF = 10000000000000;

//階乗関数　ATCODER_AMARIに注意
ll factorial(ll k){
  ll sum = 1;
  for(int i = 1 ; i < k + 1; i++) {
    sum *= i;
    //sum = sum % ATCODER_AMARI;
  }
  return sum;
}

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

  if(400 <= x && 599 >= x) {
    cout << 8 << endl;
  }
  else if(600 <= x && 799 >= x) {
    cout << 7 << endl;
  }
  else if(800 <= x && 999 >= x) {
    cout << 6 << endl;
  }
  else if(1000 <= x && 1199 >= x) {
    cout << 5 << endl;
  }
  else if(1200 <= x && 1399 >= x) {
    cout << 4 << endl;
  }
  else if(1400 <= x && 1599 >= x) {
    cout << 3 << endl;
  }
  else if(1600 <= x && 1799 >= x) {
    cout << 2 << endl;
  }
  else if(1800 <= x && 1999 >= x) {
    cout << 1 << endl;
  }
  
  
}



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

using namespace std;

const double inf = (int)1e8;

int main(){
    int h, w, n;
    cin >> h >> w >> n;

    vector<string> field(h);
    int d[h][w];
    int mx, my;
    for(int i=0; i< h; i++){
        cin >> field[i];
        for(int j=0; j < field[i].size(); j++) if(field[i][j] == 'S'){mx = i; my = j; field[i][j] = '.';}
    }
    int count = 0;
    for(int i = 1; i <= n; i++){
        for(int j=0; j< h; j++)for(int k=0; k < w; k++) d[j][k] = inf;
        queue<pair<int, int>> q;
        q.push(make_pair(mx, my));
        d[mx][my] = 0;
        while(q.size()){
            pair<int, int> p = q.front(); q.pop();
            if(field[p.first].substr(p.second, 1) == to_string(i)){count += d[p.first][p.second]; mx = p.first; my = p.second; break;}
            int dx[4] = {1, 0, -1, 0};
            int dy[4] = {0, 1, 0, -1};
            for(int j=0; j < 4; j++){
                int nx = p.first+dx[j], ny = p.second+dy[j];
                if(0 <= nx && nx < h && 0 <= ny && ny < w && field[nx][ny] != 'X' && d[nx][ny] == inf){
                    q.push(make_pair(nx, ny));
                    d[nx][ny] = d[p.first][p.second] + 1;
                }
            }
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 5944
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		int N = S.length();
		int R_index = 0;
		int L_index = 0;
		int now_R = 0;
		int even_count = 0;
		int odd_count = 0;
		int[] ans = new int[N];
		int len = 0;
		int R_first=0;

		for (int i=0;i<N;i++) {
			if (S.charAt(i)=='R') {
				if (now_R==0) {
					// if ((i-R_index)%2==0) {
					// 	even_count++;
					// } else if((i-R_index)%2==1) {
					// 	odd_count++;
					// }
					len++;
				} else {
					now_R=0;
					// ans[L_index]+=even_count;
					// ans[R_index]+=odd_count;
					// odd_count=0;
					// even_count=1;
					if ((R_index-R_first)%2==0) {
						ans[R_index]+=len/2;
						if (len%2==1) {
							ans[R_index]++;
						}
						ans[L_index]+=len/2;
					} else {
						ans[L_index]+=len/2;
						if (len%2==1) {
							ans[L_index]++;
						}
						ans[R_index]+=len/2;
					}
					R_first=i;
					len=1;
				}
			} else if (S.charAt(i)=='L') {
				if (now_R==1) {
					// if ((i-L_index)%2==0) {
					// 	even_count++;
					// } else if((i-L_index)%2==1) {
					// 	odd_count++;
					// }
					len++;
				} else {
					now_R=1;
					R_index = i-1;
					L_index = i;
					len++;
					// if ((i-R_index%2)==0) {
					// 	ans[L_index]+=even_count;
					// 	ans[R_index]+=odd_count;
					// } else {
					// 	ans[L_index]+=odd_count;
					// 	ans[R_index]+=even_count;
					// }
					// odd_count=0;
					// even_count=1;
				}
			}
			if (i==N-1) {
				// ans[L_index]+=odd_count;
				// ans[R_index]+=even_count;
					if ((R_index-R_first)%2==0) {
						ans[R_index]+=len/2;
						if (len%2==1) {
							ans[R_index]++;
						}
						ans[L_index]+=len/2;
					} else {
						ans[L_index]+=len/2;
						if (len%2==1) {
							ans[L_index]++;
						}
						ans[R_index]+=len/2;
					}
			}
		}
		for (int i=0;i<N;i++) {
			if (i==N-1) {
				System.out.print(ans[i]);
			} else {
				System.out.print(ans[i] + " ");
			}
		}
	}
}

Measured memory_bytes: 45668
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true) {
			int H = sc.nextInt();
			int W = sc.nextInt();
			if(H==0 && W==0) {
				break;
			}
			for(int i=0;i<H;i++) {
				for(int j=0;j<W;j++) {
					System.out.printf("#");
				}System.out.printf("\n");
			
			}System.out.println();
		}
		sc.close();
	
}

}



Measured memory_bytes: 60396
A,B,C,K = map(int, input().split())
#4 0 2   3
#3 2 4   5
#1 0 -1
ans = 0

if A < K:
    K -= A
    ans += A
else:
    ans = K
    K = 0

K -= B

if K > 0:
    ans -= K

print(ans)

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

using namespace std;

#define eb emplace_back
#define ii pair<int, int>
#define OK (cerr << "OK" << endl)
#define debug(x) cerr << #x " = " << (x) << endl
#define ff first
#define ss second
#define int long long
#define tt tuple<int, int, int>
#define all(x) x.begin(), x.end()
#define Matrix vector<vector<int>>
#define Mat(n, m, v) vector<vector<int>>(n, vector<int>(m, v))
#define endl '\n'

constexpr int INF = 2e18;
constexpr int MOD = 1e9 + 7;
constexpr int MAXN = 2e5 + 3;

void solve() {

  vector<int> arr(3);
  for (int &x : arr)
    cin >> x;
  int k;
  cin >> k;

  for (int i = 0; i < k; ++i) {
    for (int j = 1; j < 3; ++j) {
      if (arr[j] <= arr[j - 1]) {
        arr[j] *= 2;
        break;
      }
    }
  }

  for (int i = 1; i < 3; ++i) {
    if (arr[i] <= arr[i - 1]) {
      cout << "No" << endl;
      return;
    }
  }
  cout << "Yes" << endl;
}

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

  int t = 1;
#ifdef MULTIPLE_TEST_CASES
  cin >> t;
#endif
  while (t--)
    solve();
}

Measured memory_bytes: 3608
#include <stdio.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 FOR(i,a,b) for(int i = (a); i < (b); i++)
#define RFOR(i,b,a) for(int i = (b) - 1; i >= (a); i--)
#define STRS(i,str) for(int i = 0; (str)[i]; i++)
#define MAX(a,b) ((a) > (b) ? (a) : (b))
#define MIN(a,b) ((a) < (b) ? (a) : (b))
#define MAXI(a,b) if(a < (b)) a = (b)
#define MINI(a,b) if(a > (b)) a = (b)

int main(){
	int n;
	int a;
	int min, max;
	scanf("%d%d%d", &n, &min, &a);
	max = a - min;
	MINI(min, a);
	FOR(i, 2, n){
		scanf("%d", &a);
		MAXI(max, a - min);
		MINI(min, a);
	}
	printf("%d\n", max);
}

Measured memory_bytes: 2720
import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string;

auto rdsp(){return readln.splitter;}
void pick(R,T)(ref R r,ref T t){t=r.front.to!T;r.popFront;}
void readV(T...)(ref T t){auto r=rdsp;foreach(ref v;t)pick(r,v);}

void main()
{
  int a, b; readV(a, b);
  writeln(a%3 == 0 || b%3 == 0 || (a+b)%3 == 0 ? "Possible" : "Impossible");
}


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

#define ABS(x) ( (x)>0 ? x : -(x) )
#define MIN(x,y) ( (x) < (y) ? (x) : (y) )

#define INF 1000000000

void swap(int* x, int *y)
{
	int t;

	t = *x;
	*x = *y;
	*y = t;
}

int binary_search(int p[], int n, int key)
{
	int left, right, middle;

	left = 0;
	right = n-1;


	while (left <= right)
	{
		middle = (left + right) / 2;

		if (p[middle] == key)
			return middle;
		else if (p[middle] > key)
		{
			right = middle - 1;
		}
		else if (p[middle] < key)
		{
			left = middle + 1;
		}
	}

	return -1;

}

void bubble_sort(int p[], int n)
{
	int i, j;

	for (i = 0; i < n-1; i++)
	{
		for (j = 0; j < n - i - 1; j++)
		{
			if (p[j] > p[j + 1])
				swap(&p[i], &p[i + 1]);
		}
	}
}

int main()
{
	int W, H, x, y, r;

	scanf("%d%d%d%d%d", &W, &H, &x, &y, &r);

	if(x+r<=W && x-r >= 0 && y+r <= H && y-r >= 0)
		printf("Yes\n");
	else
		printf("No\n");

}


Measured memory_bytes: 2148