akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define int long long
#define endl '\n'
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define bug1( x ) {cerr << (#x) <<"="<< x << endl;}
#define bug2( x , y ) {cerr << (#x) <<"="<< (x) << "    " << (#y) << "="<< (y) << endl;}
#define bug3( x , y , z ) {cerr << (#x) <<"="<<(x) << "    " << (#y) <<"="<< (y) << "    " << (#z) <<"="<< (z) << endl;}
#define bug4( x , y , z , w) {cerr << (#x) <<"="<<(x) << "    " << (#y) <<"="<< (y) << "    " << (#z) <<"="<< (z) << "    " << (#w) <<"="<< w << endl;}
#define bug5( x , y , z , w ,p) {cerr << (#x) <<"="<<(x) << "    " << (#y) <<"="<< (y) << "    " << (#z) <<"="<< (z) << "    " << (#w) <<"="<< w << "    " << (#p) <<"="<< p << endl;}
#define bug6( x , y , z , w ,p , q) {cerr << (#x) <<"="<<(x) << "    " << (#y) <<"="<< (y) << "    " << (#z) <<"="<< (z) << "    " << (#w) <<"="<< w << "    " << (#p) <<"="<< p << "    " << (#q) <<"="<< q << endl;}
#define bugn( x , n ) {cerr << (#x) <<":";for(int i=0;i<n;i++)cerr << x[i] <<"  "; cerr << endl;}
#define bugnm( x , n , m ) {cerr << (#x)<<endl;for(int i=0;i<n;i++){cerr << "Row #" << i<< ":";for(int j=0;j<m;j++)cerr << x[i][j] << "   ";cerr << endl;}}
typedef long long ll;
typedef long double ld;
using namespace std;

struct box{
	int digit,cnt[10];
	box(){
		digit = 0;
		for(int i=0;i<10;i++){
			cnt[i]=0;
		}
	}
	bool operator >(const box other){
		if( digit != other.digit ) return digit > other.digit;
		for(int d = 9 ; d >= 1 ; --d ){
			if( cnt[d] != other.cnt[d] ) return cnt[d] > other.cnt[d];
		}
		return true;
	}
};
const int maxn = 1e4+10;
vector<box>dp(maxn);
vector<int>cost={0,2,5,5,4,5,6,3,7,6};
vector<int>par(maxn),pard(maxn);
int32_t main(){
	IOS	
	int n,m;cin>>n>>m;
	for(int i = 0; i< m; i++){
		int d;cin>>d;
		for(int j = 0; j + cost[d] <= n ; j++ ){
			if( j && !dp[j].digit )continue;
			box cur = dp[j];
			cur.digit++;
			cur.cnt[d]++;
			//bug5( i , d , cur.digit , dp[j+cost[d]].digit , (dp[j+cost[d]] < cur) );
			if( cur > dp[j+cost[d]]  ){
				dp[j+cost[d]] = cur;
				par[j+cost[d]] = j;
				pard[j+cost[d]] = d;
			}
		}
	}
	for(int d=9;d>=1;d--){
		while( dp[n].cnt[d] ){
			cout << d;
			dp[n].cnt[d]--;
		}
	}
	/*
	while( par[n] ){
		bug3( pard[n] , cost[pard[n]] , par[n] );
		n = par[n];
	}*/
}
/*
 * long long or int?
 * index out of bound? 
 * Tested on own test case?corner?
 * Make more general solution.
 * Read Read Read Read ....
 */


Measured memory_bytes: 4104
let contains num num_list =
  let str = string_of_int num
  and chr_list = List.map (fun x -> (string_of_int x).[0]) num_list in
  List.fold_left (fun x y -> x || (String.contains str y)) false chr_list

let unfold f init =
  let rec unfold_inner f init ret =
    match f init with
      Some (a, b) -> unfold_inner f b (a::ret)
    | None        -> ret
  in
  unfold_inner f init []

let make_list from to_ step =
  let accum x =
    if x > to_ then None else Some (x, x + step)
  in
  List.rev @@ unfold accum from

let solve n proh =
  let cand = make_list n (10*n) 1 in
  List.fold_left (fun x y -> if contains x proh then y else x) n cand

let read_list_of_int () =
  let rec read_list_of_int_inner lst =
    try let ans = (Scanf.scanf "%d " (fun x->x)) in
        read_list_of_int_inner (ans::lst)
    with End_of_file ->
      List.rev lst
  in
  read_list_of_int_inner []

let () =
  let n, k = Scanf.scanf "%d %d\n" (fun x y -> x,y) in
  let list = read_list_of_int () in
  let ans = solve n list in
  Printf.printf "%d\n" ans
;;


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

const int T = 60;
const int INF = 1e9;
const int dx[6] = {1, 1, 0, -1, -1, 0};
const int dy[6] = {0, 1, 1, 0, -1, -1};

int main() {
  int t, n;
  while (cin >> t >> n, t) {
    vector<vector<int>> g(2 * T + 1, vector<int>(2 * T + 1, INF));
    REP(i, n) {
      int x, y;
      cin >> x >> y;
      g[T + x][T + y] = -1;
    }
    int sx, sy;
    cin >> sx >> sy;
    int ans = 0;
    queue<P> q({{T + sx, T + sy}});
    g[T + sx][T + sy] = 0;
    while (!q.empty()) {
      int x = q.front().first;
      int y = q.front().second;
      q.pop();
      if (g[x][y] > t) continue;
      ans++;
      REP(i, 6) {
        int tx = x + dx[i];
        int ty = y + dy[i];
        if (g[tx][ty] == -1) continue;
        if (g[tx][ty] <= g[x][y] + 1) continue;
        g[tx][ty] = g[x][y] + 1;
        q.push({tx, ty});
      }
    }
    cout << ans << endl;
  }
}



Measured memory_bytes: 3132
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define all(V) V.begin(),V.end()
#define MOD 1000000007

ll C[2019];

int main() {
	for (int i = 0;i < 2019;i++)C[i] = 0;
	string S;
	cin >> S;
	int N = S.size();
	if (N < 4) {
		cout << 0 << endl;
		return 0;
	}
	vector<ll> R(N + 1, 0);
	ll d = 1;
	for (int i = N - 1;i >= 0;i--) {
		R[N - i] = (ll)(S[i] - 48) * d % 2019;
		d *= 10;
		d %= 2019;
	}
	for (int i = 0;i < N;i++) {
		R[i + 1] += R[i];
		R[i + 1] %= 2019;
	}
	for (int i = 0;i <= N;i++)C[R[i]]++;
	ll ans = 0;
	for (int i = 0;i < 2019;i++) {
		ans += C[i] * (C[i] - 1) / 2;
	}
	cout << ans << endl;
}

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

#define int long long
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define pb push_back
#define fi first
#define se second
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;}

int gcd(int a,int b){
    return b?gcd(b,a%b):a;
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}

int N,M;
int P[20];

signed main(){
    while(cin>>N>>M,N||M){
        rep(i,M)cin>>P[i];

        int cnt=0;
        int sum=0;
        reps(i,1,1<<M){
            int a=1;
            rep(j,M)if(i>>j&1){
                a=lcm(a,P[j]);
                if(a>N)break;
            }
            int popcnt=__builtin_popcountll(i);
            int tmp=(a+N)*(N/a)/2;
            if(popcnt&1){
                sum+=tmp;
                cnt+=N/a;
            }
            else{
                sum-=tmp;
                cnt-=N/a;
            }
        }
        sum=N*(N+1)/2-sum;
        cnt=N-cnt;

        if(cnt==0)printf("%.20f\n",0.0);
        else printf("%.20f\n",1.0*sum/cnt);
    }
    return 0;
}

Measured memory_bytes: 3212
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
int n,m,y,x;
vector<int>v[200001];
bool used[200001];
void dfs(int to,int depth){
  if(depth==2)return;
  rep(i,v[to].size()){
    int x=v[to][i];
    if(!used[x]){
      used[x]=1;
      dfs(x,depth+1);
    }
  }
}
main(){
  cin>>n>>m;
  rep(i,m){
    cin>>x>>y;
    v[x].push_back(y);
    v[y].push_back(x);
  }
  dfs(1,0);
  if(used[n])cout<<"POSSIBLE"<<endl;
  else cout<<"IMPOSSIBLE"<<endl;
}

Measured memory_bytes: 12144
#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.at(i);
  }
  
  vector<int> B(N);
  for(int i=0;i<N;i++){
    cin >> B.at(i);
  }
  
  vector<int> C(N-1);
  for(int i=0;i<N-1;i++){
    cin >> C.at(i);
  }
  
  int ans = 0;
  for(int i=0;i<N;i++){
    ans += B.at(A.at(i)-1);
    if(i >= 1 && A.at(i) - A.at(i-1) == 1){
      ans += C.at(A.at(i)-2);
    }
    //cout << i << ";" << ans << endl;
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

int main(){
	string s;
	cin >> s;
	int K;
	cin >> K;
	vector<vector<vector<int>>> dp(s.size()+1, vector<vector<int>>(K+1, vector<int>(2, 0)));
	dp.at(0).at(0).at(0) = 1;
	rep(i, s.size()){
		int now = s[i] - '0';
		int ni = i+1;
		rep(j, K+1)rep(k, 2)rep(l, 10){
			int nj = j, nk = k;
			if(l != 0) nj++;
			if(nj > K) continue;
			if(nk == 0){
				if(l > now) continue;
				else if(l < now) nk = 1;
			}
			dp.at(ni).at(nj).at(nk) += dp.at(i).at(j).at(k);
		}
	}
	// rep(i, s.size()+1){
	// 	rep(j, K+1){
	// 		cout << dp.at(i).at(j).at(0) << " ";
	// 	}
	// 	cout << endl;
	// }
	// cout << endl;
	// rep(i, s.size()+1){
	// 	rep(j, K+1){
	// 		cout << dp.at(i).at(j).at(1) << " ";
	// 	}
	// 	cout << endl;
	// }
	cout << dp.at(s.size()).at(K).at(0) +  dp.at(s.size()).at(K).at(1) << endl;
	return 0;
}

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

using namespace std;

using ll = long long;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> t(n + 1, 0), v(n);
    for (int i = 0; i < n; i++) {
        cin >> t[i + 1];
        t[i + 1] += t[i];
    }
    for (int i = 0; i < n; i++) cin >> v[i];
    double ans = 0, cur = 0;
    int tsum2 = 0;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < (t[i + 1] - t[i]) * 2; j++) {
            cur = min({cur + 0.5, (double)v[i], t[n] - t[i] - (j + 1) * 0.5});
            for (int k = i + 1; k < n; k++) {
                cur = min(cur, t[k] - t[i] - (j + 1) * 0.5 + v[k]);
            }
            ans += cur;
        }
    }
    ans /= 2;
    cout << fixed << setprecision(10) << ans << endl;
    return 0;
}

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

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

void solve(long long N, long long A, long long B, long long C, long long D) {
	for(int i = 0;i<N;i++){
    	if((-D)*i+((N-1-i)*C)<=B-A and B-A<=(D*(N-1-i)-C*i)){cout<<YES;return;}
    }
 cout<<NO;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You
// use the default template now. You can remove this line by using your custom
// template)
int main() {
  long long N;
  scanf("%lld", &N);
  long long A;
  scanf("%lld", &A);
  long long B;
  scanf("%lld", &B);
  long long C;
  scanf("%lld", &C);
  long long D;
  scanf("%lld", &D);
  solve(N, A, B, C, D);
  return 0;
}


Measured memory_bytes: 256
M=10**9+7
n,k=map(int,input().split())
a=c=p=1
for i in range(1,min(n,k+1)):
  c=c*(n-i+1)*(n-i)%M
  p=p*i*i%M
  a+=c*pow(p,M-2,M)
print(a%M)

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

using namespace std;
#define ll  long long
#define ld  long double

#define endl '\n'
#define FAST ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const ll mod = 1000000007;
const double PI = 3.141592653589793238463;

int freq[26];
bool vis[26];
int main()
{
   int a,b;
   cin>>a>>b;
   if((a+b)%3==0 || a%3==0 || b%3==0)
    cout<<"Possible"<<endl;
   else
    cout<<"Impossible"<<endl;



    return 0;
}


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

using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= (ll)(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= (ll)(b); i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(), (x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size())      //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))   //最大値を求める
#define MIN(x) *min_element(ALL(x))   //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 10000007      //10^9+7:合同式の法
#define MAXR 100000       //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first      //pairの一つ目の要素
#define S second     //pairの二つ目の要素

//for (auto& e : array) 



signed main()
{
    int K, A, B;
    cin >> K >> A >> B;
    
    if((int)(B/K)*K>=A){
        cout << "OK" << endl;
    } else {
        cout << "NG" << endl;
    }

}



Measured memory_bytes: 3636
"use strict"
let fs = require('fs');
let input = fs.readFileSync("/dev/stdin", "utf8").split(/\n/);

const V = input[1].split(' ');
const C = input[2].split(' ');

let ans = 0;

for(let i=0; i < +input[0]; i++) {
  ans += +V[i] > +C[i] ? +V[i] - +C[i] : 0;
}

console.log(ans);

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

// using mint = modint1000000007;
// using mint = modint998244353;

typedef int64_t Int;
#define all(x) (x).begin(), (x).end()
 
const double EPS = 1e-10;
const Int INF = 1e18;
const int inf = 1e9;
const Int mod = 1e9+7;

bool print_space_enable = false;
void print() { 
    cout << '\n'; 
    print_space_enable = false;
}

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
    if (print_space_enable) std::cout << " ";
    cout << fixed << setprecision(15) << head;
    print_space_enable = true;
    print(std::forward<Tail>(tail)...);
}

template<typename T>
void print(vector<T> v) {
    for (size_t i = 0; i < v.size(); i++) {
        if (i > 0) std::cout << " ";
        std::cout << v[i];
    }
    std::cout << '\n';
}

void solve() {
    Int n;
    cin >> n;
    Int res = 0;
    for (Int i = 1; i <= n; i++) {
        for (Int j = i; j <= n; j += i) {
            res += j;
        }
    }
    print(res);
}

int main() {
    solve();
    return 0;
}


Measured memory_bytes: 3636
local n = io.read("*n")
local t = {}
local ret = {}
for i = 1, n do
  t[i] = io.read("*n")
  ret[i] = 0
end
local found = false
for i = n, 1, -1 do
  found = false
  for k = i, 1, -1 do
    if t[k] == k then
      ret[i] = k
      table.remove(t, k)
      found = true
      break
    end
  end
  if not found then break end
end
if not found then print(-1)
else
  for i = 1, n do print(ret[i]) end
end

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

class Program
{
    static string InputPattern = "InputX";

    static List<string> GetInputList()
    {
        var WillReturn = new List<string>();

        if (InputPattern == "Input1") {
            WillReturn.Add("4 3");
            WillReturn.Add("1 2");
            WillReturn.Add("2 3");
            WillReturn.Add("1 4");
            //2
            //2
            //1
            //1
        }
        else if (InputPattern == "Input2") {
            WillReturn.Add("2 5");
            WillReturn.Add("1 2");
            WillReturn.Add("2 1");
            WillReturn.Add("1 2");
            WillReturn.Add("2 1");
            WillReturn.Add("1 2");
            //5
            //5
        }
        else if (InputPattern == "Input3") {
            WillReturn.Add("8 8");
            WillReturn.Add("1 2");
            WillReturn.Add("3 4");
            WillReturn.Add("1 5");
            WillReturn.Add("2 8");
            WillReturn.Add("3 7");
            WillReturn.Add("5 2");
            WillReturn.Add("4 1");
            WillReturn.Add("6 8");
            //3
            //3
            //2
            //2
            //2
            //1
            //1
            //2
        }
        else {
            string wkStr;
            while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
        }
        return WillReturn;
    }

    static void Main()
    {
        List<string> InputList = GetInputList();

        int[] wkArr = { };
        Action<string> SplitAct = pStr =>
            wkArr = pStr.Split(' ').Select(X => int.Parse(X)).ToArray();

        SplitAct(InputList[0]);
        int N = wkArr[0];

        int[] EdgeCntArr = new int[N + 1];
        foreach (string EachStr in InputList.Skip(1)) {
            SplitAct(EachStr);

            EdgeCntArr[wkArr[0]]++;
            EdgeCntArr[wkArr[1]]++;
        }

        for (int I = 1; I <= N; I++) {
            Console.WriteLine(EdgeCntArr[I]);
        }
    }
}


Measured memory_bytes: 13396
#include <bits/stdc++.h>
#include <stdio.h>
#include <math.h>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
#define rep(i, n) for(int i=0;i<n;i++)

int main(){
  int x;
  cin >> x;
  vector<VI> n(101,VI(12));
  int mxn=0;
  for(int i=1;i<101; i++){
    for(int j=2;j<12;j++){
      n.at(i).at(j)=pow(i,j);
      if(n.at(i).at(j) <=x){
     mxn = max(mxn,n.at(i).at(j));
      }
    }
  }
  cout << mxn <<endl;
}

Measured memory_bytes: 384
import java.util.*;

public class Main {

	public static void main(String[] args) {
		java.util.Scanner in = new java.util.Scanner(System.in);
		while(in.hasNext()) {
			int a = in.nextInt();
			int b = in.nextInt();
			int sum = a+b;
			String s = String.valueOf(sum);
			System.out.println(s.length());
		}
		
		
    }
}


Measured memory_bytes: 26504
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
typedef long long int ll;
typedef vector<ll> vi;
typedef vector<pair<ll, ll> > vp;
typedef vector<string> vs;
typedef vector<char> vc;
typedef list<ll> lst;
typedef pair<ll, ll> P;
const long long INF = numeric_limits<ll>::max();
const long long MOD = 1000000007;
const long double PI = 3.1415926;
template <class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <class T> T &chmax(T &a, const T &b) { return a = max(a, b); }
 
ll n, m, k, ans = 0, sum = 0, cnt = 0;
string s;
//char c;
 
#define Endl endl
 
/*--------------------template--------------------*/

int main() {
    int N;
    cin >> N;
    char S[N];
    FOR(i, 0, N) cin >> S[i];
    char K[N];
    int kinds = 0;
    FOR(i, 0, N) {
        ll num = 0;
        bool exists = false;
        FOR(j, 0, kinds) {
            if (K[j] == S[i]) {
                exists = true;
                break;
            }
        }
        if (!exists) K[kinds++] = S[i];
        FOR(j, 0, kinds) {
            FOR(k, i+1, N) {
                if (K[j] == S[k]) {
                    num++;
                    break;
                }
            }
        }
        ans = max(ans, num);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>

using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype

template <class T>
int __builtin_popcount(T n) { return n ? 1 + __builtin_popcount(n & (n - 1)) : 0; }
#endif

#define foreach(it, c) for (__typeof__((c).begin()) it=(c).begin(); it != (c).end(); ++it)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define popcount __builtin_popcount

template <class T> void max_swap(T& a, const T b) { a = max(a, b); }
template <class T> void min_swap(T& a, const T b) { a = min(a, b); }

const double EPS = 1e-10;
typedef long long ll;
typedef pair<int, int> pint;


int main()
{
	int n;
	while (scanf("%d", &n), n)
	{
		int m;
		scanf("%d ", &m);
		int res = 0, s = 0, seq = 0;
		static char in[1000100];
		scanf("%s", in);
		for (int i = 0; i < m; ++i)
		{
			if (in[i] == 'I')
			{
				if (s == 1)
					seq = 0;
				else if (s == 2)
				{
					if (++seq >= n)
						++res;
				}
				s = 1;
			}
			else
			{
				if (s == 1)
					s = 2;
				else
					s = 0, seq = 0;
			}
		}
		printf("%d\n", res);
	}
}

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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) for(i64 i = 1; i <= n; ++i)
#define RREP(i, n) for(i64 i = n - 1; i >= 0 ; --i)
#define RREPS(i, n) for(i64 i = n; i >= 1; --i)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define pb push_back
#define mp make_pair
#define F first
#define S second

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

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }


struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;

#define MAX_H 80
#define MAX_W 80
#define MAX_D 12800
i64 A[MAX_H][MAX_W];
i64 B[MAX_H][MAX_W];
i64 H, W;
bool dp[MAX_H + 1][MAX_W + 1][MAX_D + 1];

int main() {
    cin >> H >> W;
    REP(y, H) REP(x, W) cin >> A[y][x];
    REP(y, H) REP(x, W) cin >> B[y][x];

    dp[0][0][abs(A[0][0] - B[0][0])] = true;
    REP(y, H) {
        REP(x, W) {
            REP(d, MAX_D + 1) {
                if (!dp[y][x][d]) continue;
                REP(i, 2) {
                    i64 ny = y + (i % 2);
                    i64 nx = x + (i + 1) % 2;
                    if (ny >= H || nx >= W) continue;
                    i64 nd1 = abs(A[ny][nx] + d - B[ny][nx]);
                    i64 nd2 = abs(B[ny][nx] + d - A[ny][nx]);
                    if (nd1 <= MAX_D) dp[ny][nx][nd1] = true;
                    if (nd2 <= MAX_D) dp[ny][nx][nd2] = true;
                }
            }
        }
    }

    REP(d, MAX_D + 1) {
        if (dp[H - 1][W - 1][d]) {
            cout << d << endl;
            break;
        }
    }

    return 0;
}

Measured memory_bytes: 81408
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <algorithm>
#include <array>
#include <complex>
#include <string>
#include <utility>
#include <map>
#include <queue>
#include <list>
#include <functional>
#include <numeric>
#include <stack>
#include <tuple>
#include <fstream>
using namespace std;
int dx[4] = { -1,0,1,0 };
int dy[4] = { 0,1,0,-1 };
const int INF = 100000000;
const long long LINF = 1000000000000000000;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-6;
const double pi = 3.14159265359;
using pii = std::pair<int, int>;
using ll = long long;
using pLL = std::pair<ll, ll>;
#define SORT(v) std::sort(v.begin(), v.end())
#define RSORT(v) std::sort(v.rbegin(), v.rend())
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Rep(i, n) for (int i = (int)(n-1); i >= 0; i--)
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int A, B, C;
    cin >> A >> B >> C;
    cout << max(C - A + B, 0) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    int n,m;
    scanf("%d %d",&n,&m);
    int a[m];
    int sum=0;
    for(int i=0; i<m; i++){
        scanf("%d",&a[i]);
        sum+=a[i];
    }
    int ans=n-sum;
    if(ans<0){
        printf("-1\n");
    }else{
        printf("%d",ans);
    }
    return 0;
}

Measured memory_bytes: 2184
/* 実行時間1s制限の場合
  10^6 1,000,000   : 余裕をもって間に合う
  10^7 10,000,000  : おそらく間に合う
  10^8 100,000,000 : 非常にシンプルな処理でないと厳しい
 */
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#include <bits/stdc++.h>
using namespace std;

typedef long long ll; // long longはデータモデル(LLP64, LP64, ...)によらず64bit.
ll gcd(ll a, ll b) {return b ? gcd(b, a%b) : a;}  // Greatest Common Divisor ユークリッドの互除法（aが長辺）
vector<pair<ll,int>> factorize(ll n) {            // a,bの公約数 = GCD(a, b)の約数
    vector<pair<ll,int>> res;
    for (ll i = 2; i*i <= n; i++) { // √nまで探せばよい
        if (n%i) continue;
        res.emplace_back(i, 0);     // 割り切れたら
        while (n%i == 0) {
            n /= i;
            res.back().second++;
        }
    }
    if (n != 1) res.emplace_back(n, 1); // この時点で1でなかったら、残りは素数.
    return res;
}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}         // Least Commont Multiple オーバーフローしないように先に割る
ll ceil(ll a, ll b) {return (a+b-1)/b;}

const ll INF = LONG_MAX;
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(int argc, char* argv[])
{
#ifdef LOCAL
    // 以降 cin の入力元が 'xxx.txt' になる
    // std::ifstream in(argv[1]);
    //std::cin.rdbuf(in.rdbuf());
    std::ifstream in("b.txt");
    std::cin.rdbuf(in.rdbuf());
#endif

    int n;
    cin >> n;

    vector<int> h(n);
    rep(i, n) {
        cin >> h[i];
    }

    int ans = 1;
    repi(i, 1, n) {
        ans++;
        rep(j, i) {
            if (h[j] > h[i]) {
                ans--;
                break;
            }
        }
    }

    cout << ans;

    return 0;
}

/*
  - 1e9 : 10^9
  - container一般
    - 合計
      accumulate(a.begin(), a.end(), 0LL)  0LLはオーバーフロー用
  - vector
    vector<int> A(N, 0); // 0で初期化(省略可)
    - loop
      for  (int i = 0; i < A.size(); i++) {}
      for  (int elem : A) {}
    - sort
      std::sort(v.begin(), v.end());  // 昇順
      std::sort(v.begin(), v.end(), std::greater<int>()); //降順
      - vector<vector<int>> cnt(h, vector<int>(w))
    - sort(struct)
        struct st_t {
            string name;
            int p;
            bool operator<(const st_t& another) const {
                if (name == another.name)
                {
                    return p > another.p;
                }
                return name < another.name;
            }
        };
        vector<st_t> st(n);
        sort(st.begin(), st.end());
  - pair
    - pairのソートの定義 : firstが優先的に比較。同じだったらsecond。
    - pair<pair<string,int>,int> p[110];
      std::sort(p,p+a);
        こうすると、first.first -> first.second -> secondの順にソートされる
    - sort
      - sort(a.begin(), cb.end(), greater<pair<int, int>>());
  - map
    - for (auto x : map) {}  // x.first:key  x.second:value.
  - priority_queue<int> q;
    - q.top()に最大値が入っている
  - string
    - loop
      for (char& c : s) {}
 */



Measured memory_bytes: 256
#!/usr/bin/ruby
class TLLI
	def initialize
		@trianies=[nil,[0,0,0]]
	end
	def root_triany
		1
	end
	def allocate_triany
		siz=@trianies.size
		@trianies[siz]=[0,0,0]
		return siz
	end
	def set_a(id,value)
		return if !@trianies[id]
		@trianies[id][0]=value
	end
	def set_b(id,value)
		return if !@trianies[id]
		@trianies[id][1]=value
	end
	def set_c(id,value)
		return if !@trianies[id]
		@trianies[id][2]=value
	end
	def get_a(id)
		return if !@trianies[id]
		@trianies[id][0]
	end
	def get_b(id)
		return if !@trianies[id]
		@trianies[id][1]
	end
	def get_c(id)
		return if !@trianies[id]
		@trianies[id][2]
	end
end

class SETI <TLLI # a=>key, b=>left, c=>right
	def set_entry(key)
		x=root_triany
		y=0
		while x!=0&&!(x==root_triany&&get_a(x)==0)
			y=x
			if key<get_a(x)
				x=get_b(x)
			else
				x=get_c(x)
			end
		end
		if y==0
			set_a(root_triany,key)
		else
			leaf=allocate_triany
			set_a(leaf,key)
			if key<get_a(y)
				set_b(y,leaf)
			else
				set_c(y,leaf)
			end
		end
	end
	def find_entry(key)
		t=root_triany
		loop{
			return true if key==get_a(t)
			if key<get_a(t)
				t=get_b(t)
				return false if t==0
			else
				t=get_c(t)
				return false if t==0
			end
		}
	end
	def print2(t)
		return if t==0
		print2(get_b(t))
		Kernel.print(' ')
		Kernel.print(get_a(t))
		@first=false
		print2(get_c(t))
	end
	def print3(t)
		return if t==0
		Kernel.print(' ')
		Kernel.print(get_a(t))
		@first=false
		print3(get_b(t))
		print3(get_c(t))
	end
	def print
		@first=true
		print2(root_triany)
		Kernel.puts
		@first=true
		print3(root_triany)
		Kernel.puts
	end
end

dicti=SETI.new
sum=0
gets.to_i.times{
	gets
	if $_[0..0]=='i'
		a=$_.split
		dicti.set_entry(a[1].to_i)
	elsif $_[0..0]=='f'
		a=$_.split
		sum+=dicti.find_entry(a[1].to_i)
	elsif $_[0..0]=='p'
		dicti.print
	end
}

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

#define pb push_back
#define mp make_pair
#define all(n) (n).begin(),(n).end()
#define fi first
#define se second

typedef pair<int, int> PII;
typedef long long ll;

const int MOD = 1e9+7;

int main() {

	ios::sync_with_stdio(0);
	cin.tie(0);

	ll n,d;
	cin >> n >> d;
	ll ans = 0;
	for (int i = 0; i < n; i++) {
		ll a,b;
		cin >> a >> b;
		if (((a*a)+(b*b))<=(d*d)) ans++;
	}
	cout << ans << "\n";
}

Measured memory_bytes: 3644
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<map>
#include<cstdio>
#include<cstring>
#include<queue>
#include<deque>
#include<stack>
using namespace std;

const int INF=100005;

int n,ans;
int a[INF];

int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	if(a[n]==n){
		ans++;
		swap(a[n],a[n-1]);
	}
	for(int i=1;i<n;i++)
		if(a[i]==i){
			swap(a[i],a[i+1]);
			ans++;
		}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef vector<pii> vp;

int gcd(int a, int b){
    if(b==0) return a;
    return gcd(b,a%b);
}
int lcm(int a, int b){
    return a/gcd(a,b)*b;
}

int dp[2][10005][205];

signed main(void) {
    int n,ma;
    cin >> n >> ma;
    vi w(n);
    rep(i,n)cin >> w[i];
    sort(all(w));
    dp[0][0][204] = 1;
    rep(i,n)rep(j,ma+1)rep(k,205)if(dp[i%2][j][k]){
        //cout << i << " " << j << " " << k << endl;
        int ne = 1-i%2;
        if(k < n)(dp[ne][j][k] += dp[i%2][j][k]) %= MOD;
        else (dp[ne][j][i] += dp[i%2][j][k]) %= MOD;
        if(j + w[i] <= ma)(dp[ne][j + w[i]][k] += dp[i%2][j][k]) %= MOD;
        dp[i%2][j][k] = 0;
    }
    int ans = 0;
    rep(j,ma+1){
        rep(k,n)if(j + w[k] > ma){
            (ans += dp[n%2][j][k]) %= MOD;
        }
        (ans += dp[n%2][j][204]) %= MOD;
    }
    cout << ans << endl;
}



Measured memory_bytes: 29284
S=input()
c=0
d=0
for i in S:
    if i=="A":
        c+=1
    elif i=="C":
        c+=1
    elif i=="G":
        c+=1
    elif i=="T":
        c+=1
    else:
        c=0
    if c>d:
        d=c
print(d)

Measured memory_bytes: 9096
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/STACK:256000000")
#define _USE_MATH_DEFINES
#include<iostream>
#include<vector>
#include<string>
#include<stack>
#include<algorithm>
#include<cmath>
#include<set>
#include<queue>
#include<sstream>
#include<utility>
#include<map>
#include<ctime>
#include<cstdio>
#include<cassert>
#include<functional>
#include<unordered_map>
#include<deque>
#include<cmath>





using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef pair<char, char> pcc;
typedef pair<double, double> pdd;

#define show(x) cerr << x
#define debug(x) show(#x << ": " << (x) << endl)

const long double PI = 3.14159265358979323846;
const long double eps = 1e-5;
const ll INF = numeric_limits<int>::max();
const ll LINF = numeric_limits<ll>::max();
const ll mod = 1000 * 1000 * 1000 + 7;


void solve() {
    int w, a, b;
    cin >> w >> a >> b;
    if (a > b)
        swap(a, b);
    cout << max(0, b - a - w) << endl;

}


//#define LOCAL

int main() {
    ios_base::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif
    solve();



#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif	
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cmath>
#include <vector>
#include <queue>
#include <limits>
#include <algorithm>
#include <string>
#include <set>
using namespace std;

int main()
{
	string s;
	cin >> s;

	s[5] = ' ';
	s[13] = ' ';
	cout << s << endl;

	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	char s[3] = {0};
	for (int i = 0; i < 3; i++) {
		s[i] = getchar();
	}

	if (s[0]=='R'&&s[1]=='R'&&s[2]=='R') printf("3");
	else if (s[0] =='R'&& s[1] == 'R') printf("2");
	else if (s[1] =='R' && s[2] == 'R') printf("2");
	else if (s[0] == 'R') printf("1");
	else if (s[1] == 'R') printf("1");
	else if (s[2] == 'R') printf("1");
	else printf("0");

	return 0;
}

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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit32(x) (1 << (x))
#define bit64(x) (1ll << (x))

using namespace std;

using i32 = int;
using i64 = long long;
using u64 = unsigned long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vu64 = vector<u64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); return a / gcd(a, b) * b; }
inline u64 xorshift() { static u64 x = 88172645463325252ull; x = x ^ (x << 7); return x = x ^ (x >> 9); }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template <typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template <typename T> inline T exp(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> inline T bis(T ok, T ng, function<bool(T)> f, T eps = 1) { while (abs(ok - ng) > eps) { T mi = (ok + ng) / 2; (f(mi) ? ok : ng) = mi; } return ok; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }

i64 dp[1000002][2];

void solve() {
  string s;
  cin >> s;
  s = "0" + s;
  int n = s.size();
  rep(i, 1000002) rep(j, 2) dp[i][j] = 1e18;
  dp[n][0] = 0;
  rrep(i, n) rep(j, 2) {
    if (dp[i+1][j] == 1e18) {
      continue;
    }
    int x = s[i] - '0';
    if (j == 0) {
      amin(dp[i][0], dp[i+1][j] + x);
      if (x > 0) {
        amin(dp[i][1], dp[i+1][j] + (10 - x));
      }
    } else {
      amin(dp[i][0], dp[i+1][j] + x + 1);
      amin(dp[i][1], dp[i+1][j] + (9 - x));
    }
  }
  cout << dp[0][0] << endl;
}


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

int n, m;
vector<vector<int>> g;
vector<bool> vis; // 探索のときの目印が必要

int dfs(int i) {
	if(vis[i]) return 0;
	int res = 1;
	vis[i] = true;
	// for(int j=0;j<g[i].size();j++){
	// 	dfs(g[i][j]);
	// }
	for(auto j : g[i]){
		res += dfs(j);
	}
	return res;
}


int main() {
	cin >> n >> m;
	vector<int> a(m), b(m);
	for(int i=0;i<m;i++){
		cin >> a[i] >> b[i];
		a[i]--; b[i]--;
	}
	int cnt = 0;
	for(int i=0;i<m;i++){
		g.clear();  // 空にする
		g.resize(n); // サイズをnにする
		for(int j=0;j<m;j++){
			if(j==i) continue;
			g[a[j]].push_back(b[j]);
			g[b[j]].push_back(a[j]);
		}
		vis.clear();
		vis.resize(n, false);
		if(dfs(0)!=n) cnt++;
		//dfs(0);
		// for(int i=0;i<n;i++){
		// 	if(vis[i]==false){
		// 		cnt++;
		// 		break;
		// 	}
		// }
	}
	cout << cnt << endl;
	return 0;
}

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

#define ll long long int
#define llu unsigned long long int
#define f(n) for(ll i=0;i<n;i++)
#define fr(n) for(ll i=n-1;i>=0;i--)
#define endl "\n"
#define mod 1000000007

using namespace std;

int main()
{
	//#ifdef ONLINE_JUDGE
//freopen("input.txt","r",stdin);
//	freopen("output.txt","w",stdout);
	//#endif
	std::ios_base::sync_with_stdio(false);

	string s;
	cin>>s;
	f(s.length())
	{
		if(i%2==0)
		{
			if(s[i]!='h')
			{
				cout<<"No";
				return 0;
			}
		}
		if(i%2==1)
		{
			if(s[i]!='i')
			{
				cout<<"No";
				return 0;
			}
		}
	}
	if(s[0]!='h' || s[s.length()-1]!='i')
		cout<<"No";
	else if(s.length()%2==1)
		cout<<"No";
	else
		cout<<"Yes";
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    
    long long n;
    long long m;
    long long ans=0;
    
    cin >> n >> m;
    
    if(n==1&&m==1){
        
        ans = 1;
        
    } else if(n==1){
        
        ans = m - 2;
        
    } else if(m==1){
        
        ans = n - 2;
        
    } else {
        
        ans = (n-2) * (m-2);
        
    }
    
    cout << ans << endl;
    
    return 0;
    
}

Measured memory_bytes: 256
#if !defined(__clang__) && defined(__GNUC__)
#include <bits/stdc++.h>
#else
#include <cstdlib>
#include <climits>
#include <iostream>
#include <cstdint>
#include <vector>
#include <string>
#include <complex>
#include <bitset>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#endif //  !defined(__clang__) && defined(__GNUG__)
#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/math/common_factor_rt.hpp>

constexpr int64_t DIV1097 = 1000000007LL;

using namespace std;

int main()
{
    int64_t N;
    std::cin >> N;

    std::vector<int64_t> A;
    for (decltype(N) i = 0; i < N; ++i) {
        int64_t t;
        std::cin >> t;
        A.push_back(t);
    }

    std::sort(std::begin(A), std::end(A));

    auto B = A;
    std::reverse(std::begin(B), std::end(B));

    std::vector<int64_t> s, ss;
    if (N % 2 == 1) {
        s.push_back(A[N/2]);
        ss.push_back(B[N/2]);

        for (int64_t i = 0; i < N - 1; ++i) {
            if (i % 2 == 1) {
                s.push_back(A[i/2]);
                ss.push_back(B[i/2]);
            }
            else {
                s.push_back(B[i/2]);
                ss.push_back(A[i/2]);
            }
        }
    }
    else {
        s.push_back(A[N/2 - 1]);
        ss.push_back(B[N/2 - 1]);
        for (int64_t i = 0; i < N - 1; ++i) {
            if (i % 2 == 1) {
                s.push_back(A[i/2]);
                ss.push_back(B[i/2]);
            }
            else {
                s.push_back(B[i/2]);
                ss.push_back(A[i/2]);
            }
        }

    }

    int64_t p, q;
    p = q = 0;
    for (size_t i = 1; i < N; ++i) {
        p += std::abs(s[i] - s[i-1]);
        q += std::abs(ss[i] - ss[i-1]);
    }

    std::cout << std::max(p, q) << std::endl;

    return 0;
}


Measured memory_bytes: 4212
n=int(input())
ev=[]
for i in range(n):
    a=int(input())
    ev.append([list(map(int,input().split())) for _ in range(a)])
ans=0
for i in range(2**n):
    bit=(bin(i)[2:].zfill(n))
    flag=1
    for j in range(n):
        if bit[j]=="0":
            continue
        for e in ev[j]:
            if int(bit[e[0]-1])!=e[1]:
                flag=0
    if flag:
        ans=max(ans,bit.count("1"))
print(ans)

Measured memory_bytes: 9172
#include <iostream>
 
#include <string>
#include <vector>
 
using namespace std;
 
int main()
{
	int x, a, b;
 
	cin >> x >> a >> b;
 
 
	if (abs(x - a) > abs(x - b))cout << "B" << endl;
 
	else cout << "A" << endl;
 
 
	return 0;
 
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <algorithm>
using namespace std;
int main() {
	int n, m;
	int time = 0;
	while(cin >> n >> m) {
		time = (n - m) * 100 + m * 1900;
		for(int i = 1; i <= m; i++)
			time *= 2;
		cout << time << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>

 

using namespace std;

 

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


Measured memory_bytes: 3104
from heapq import heapify, heappop, heappush

N = int(input())
v = list(map(int, input().split()))

heapify(v)

for _ in range(1, N):
    a = heappop(v)
    b = heappop(v)
    heappush(v, (a+b)/2)

print(v[0])


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

using namespace std;

int main() {
  int N;
  cin >> N;
  unordered_set<string> S;
  for (int i = 0; i < N; i++) {
    string s;
    cin >> s;
    S.insert(s);
  }
  cout << S.size() << endl;

  return 0;
}


Measured memory_bytes: 17676
a = [[int(i) for i in input().split()] for i in range(3)]
n = int(input())
b = list(int(input()) for i in range(n))
a1 = []
for i in range(3):
    for j in range(3):
        a1.append(a[i][j])
for i in range(n):
    if b[i] in a1:
        w = a1.index(b[i])
        a1[w] = -1
ans = 0
if a1[0] == a1[1] == a1[2] == -1 or a1[3] == a1[4] == a1[5] == -1 or a1[6] == a1[7] == a1[8] == -1:
    ans = 1
elif a1[0] == a1[3] == a1[6] == -1 or a1[1] == a1[4] == a1[7] == -1 or a1[2] == a1[5] == a1[8] == -1:
    ans = 1
elif a1[0] == a1[4] == a1[8] == -1 or a1[2] == a1[4] == a1[6] == -1:
    ans = 1
if ans == 1:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3064
//let input = "codeforces\natcoder";

function main(input){
  input = input.trim();
  list = input.split("\n");
  let d = list[0];
  let s = list[1];
  let answer = 1000;
  let temp = 0;
  for(let i=0; i<d.length - s.length + 1; i++){
    temp = 0;
    for(let j=0; j<s.length; j++){
      let dStr = d.substr(i+j,1);
      let sStr = s.substr(j,1);
      if(dStr===sStr){
        //console.log(dStr + " " + sStr + " onaji");
      }else{
        //console.log(dStr + " " + sStr + " tigau");
        temp++;
      }
    } // j loop
    if(temp < answer){answer = temp;}
    //console.log(temp);
  } // i loop
  if(d===s){answer=0;}
  console.log(answer);
}
//main(input);
main(require("fs").readFileSync("/dev/stdin","utf8"));

Measured memory_bytes: 32476
from collections import deque

def bfs(maze,dist,sy,sx):
    #キューオブジェクトの生成
    queue = deque([[sy,sx]])
    dist[sy][sx] = 0
    md = 0
    l = []
    while queue:
        #先頭から要素を一つ削除する
        y,x = queue.popleft()
        for j, k in ([1,0],[-1,0],[0,1],[0,-1]):
            new_y, new_x = y+j, x+k
            #迷路内に収まっているか確かめる
            if 0 <= new_y < H and 0 <= new_x < W:
                #道かどうか確かめる
                if maze[new_y][new_x] == "." and dist[new_y][new_x] == -1:
                    dist[new_y][new_x] = dist[y][x] + 1
                    queue.append([new_y, new_x])
                    md = max(dist[new_y][new_x],md)
    return md
H, W = map(int,input().split())
maze = [input() for i in range(H)]

ans = 0
for i in range(H):
    for j in range(W):
        dist = [[-1]*W for j in range(H)]
        if maze[i][j] != "#":
            a = bfs(maze,dist,i,j)
            ans = max(a,ans)
print(ans)

Measured memory_bytes: 3316
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>

#include <cstdio>

typedef long long ll;
using namespace std;

int main(void){
    
    char c;

    while(1){
        scanf("%c",&c);
        if(c<='z'&&c>='a'){
            printf("%c",c-32);
        }
        else if(c<='Z'&&c>='A'){
            printf("%c",c+32);
        }
        else{
            cout<<c;
        }
        
        if (c=='\n') break;
    }

	return 0;
}


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

using namespace std;

int main(){
	int n;
	cin >> n;
	int a[n],tmp[n];
	for(int i=0;i<n;i++){
		cin >> a[i];
		tmp[i] = a[i];
	}
	sort(tmp,tmp+n);
	for(int i=0;i<n;i++){
		if(a[i] <= tmp[(n-1)/2]){
			cout << tmp[(n+1)/2] << endl;
		}
		else{
		cout << tmp[(n-1)/2] << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 3712
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a, b;
    cin>>a>>b;
    a=(a+12)%14;
    b=(b+12)%14;
    if(a<b) cout<<"Bob";
    else if(a==b) cout<<"Draw";
    else cout<<"Alice";

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int table[66];

int main(void)
{
	int dice[7];
	int q;
	int upper, front;
	int u, f;
	int i;

	table[12] = 3;
	table[13] = 5;
	table[15] = 4;
	table[14] = 2;
	
	table[62] = 4;
	table[63] = 2;
	table[65] = 3;
	table[64] = 5;
	
	table[21] = 4;
	table[24] = 6;
	table[26] = 3;
	table[23] = 1;
	
	table[51] = 3;
	table[54] = 1;
	table[56] = 4;
	table[53] = 6;
	
	table[31] = 2;
	table[32] = 6;
	table[36] = 5;
	table[35] = 1;
	
	table[41] = 5;
	table[42] = 1;
	table[46] = 2;
	table[45] = 6;

	for (i = 1; i <= 6; i++){
		scanf("%d", &dice[i]);
	}

	scanf("%d", &q);
	for (i = 0; i < q; i++){
		scanf("%d%d", &upper, &front);
		
		for (u = 1; dice[u] != upper; u++);
		for (f = 1; dice[f] != front; f++);
		
		printf("%d\n", dice[table[u * 10 + f]]);
	}
	
	return (0);
}



Measured memory_bytes: 2096
#include <stdio.h>

using namespace std;

int main(){
	int a,b;
	scanf("%d %d",&a,&b);
	if(a > b){
		printf("a > b\n");
	}else if(a < b){
		printf("a < b\n");
	}else{
		printf("a == b\n");
	}
}



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

namespace AtCoder
{
	class Program
	{
		static void Main(string[] args)
		{
			var Instance = new Minesweeper();
			Instance.Exec();
		}
	}

	public class Minesweeper
	{
		public int CharToInt(char c)
		{
			return c == '#' ? 1 : 0;
		}

		public void Exec()
		{
			var array = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();
			long h = array[0];
			long w = array[1];
			List<string> slist = new List<string>();

			string dummyStr = new string('-', (int)w + 2);
			slist.Add(dummyStr);
			for (int i = 0; i < h; ++i) {
				string str = "-" + Console.ReadLine() + "-";
				slist.Add(str);
			}
			slist.Add(dummyStr);

			for (int i = 1; i <= h; ++i) {
				for (int j = 1; j <= w; ++j) {
					int total = -1;
					if (CharToInt(slist[i][j]) == 1) {
						Console.Write("#");
					} else {
						total = CharToInt(slist[i - 1][j - 1])
							+ CharToInt(slist[i][j - 1])
							+ CharToInt(slist[i + 1][j - 1])
							+ CharToInt(slist[i - 1][j])
							+ CharToInt(slist[i + 1][j])
							+ CharToInt(slist[i - 1][j + 1])
							+ CharToInt(slist[i][j + 1])
							+ CharToInt(slist[i + 1][j + 1]);
						if (total < 0) {
							Console.Write("#");
						} else {
							Console.Write(total.ToString());
						}
					}
				}
				Console.WriteLine("");
			}

			Console.Out.Flush();

			Console.ReadKey();
		}
	}
}

Measured memory_bytes: 13396