akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<math.h>
#include<vector>
#include<array>
#include<algorithm>
#include<numeric>
#include<map>
#include<queue>
#include<deque>
#include<set>
#include<cstdio>
#include<cstring>
#include<string>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vector<ll>> mat;
ll mod=pow(10,9)+7;

int main(){
    string L;cin>>L;
    int N=L.size();
    mat dp(2,vec(N+1));
    dp[0][1]=1,dp[1][1]=2;
    for(int i=2;i<=N;i++){
        if(L[i-1]=='0'){
            dp[0][i]=((2*dp[0][i-1])%mod+dp[0][i-1])%mod;
            dp[1][i]=dp[1][i-1];
        }
        else{
            dp[0][i]=(((2*dp[0][i-1])%mod+dp[0][i-1])%mod+dp[1][i-1])%mod;
            dp[1][i]=(2*dp[1][i-1])%mod;
        }
    }
    cout<<(dp[0][N]+dp[1][N])%mod<<endl;
    return 0;
}

Measured memory_bytes: 2816
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] ab = br.readLine().split(" ");
        int a = Integer.parseInt(ab[0]);
        int b = Integer.parseInt(ab[1]);
        
        
        
        System.out.println(Math.max(Math.max(a+b, a-b), a*b));
    }
}


Measured memory_bytes: 22228
#include <bits/stdc++.h>
using namespace std; 
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ll long long
long long min(long long x,long long y){return (x<y ? x:y);}
long long max(long long x,long long y){return (x>y ? x:y);}
#define ld long double
int stoi(string s) {return atoi(s.c_str());}
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}


int main(){
  int A,B,C; cin >> A>>B >> C;
  string r = (C>=A && C<=B ? "Yes":"No"); 
  cout << r << "\n";
}

Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main(void){
  int N,M,ad;
  cin>>N>>M;
  if(M<10){
      ad=10*N+M;
  }
  else if(M==100){
      ad=1000*N+M;
  }
  else{
      ad=100*N+M;
  }
  if(floor(sqrt(ad)) == sqrt(ad)){
      cout<<"Yes"<<endl;
  }
  else{
      cout<<"No"<<endl;
  }
  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>                          
using namespace std;
char s[300005];
int n,a[300005],b[300005],ans=1e6;
int main()
{
    cin>>n;
    for(int i=1;i<=n;i++)
    {
    	cin>>s[i];
        if(s[i]=='W')a[i]=a[i-1]+1;
        else a[i]=a[i-1];
    }
    for(int i=n;i>=1;i--)
    {
        if(s[i]=='E')b[i]=b[i+1]+1;
        else b[i]=b[i+1];
    }
    for(int i=1;i<=n;i++)
	    ans=min(ans,a[i]+b[i]-1);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 2944
def main2(s,x,q):
    res = s
    rev = 1 #-1なら反転中
    lstA = []
    lstB = []
    for op in q:
        if int(op[0]) == 1:
            rev = rev * -1
        elif int(op[1])*rev == 1 or int(op[1])*rev == -2:
            lstA.append(op[2])
        elif int(op[1])*rev == -1 or int(op[1])*rev == 2:
            lstB.append(op[2])
    if rev == 1:
        res = "".join(lstA[::-1])+res+"".join(lstB)
    else :
        res = "".join(lstB[::-1])+res[::-1]+"".join(lstA)
    return res

s = input()
x = int(input())
q = [input().split() for _ in range(x)]
print(main2(s,x,q))

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

void display(int A[], int N){
  for(int i=0;i<N;i++){
    if(i==N-1){
      cout << A[i];
    } else {
      cout << A[i] << " ";
    }
  }
  cout << endl;
}

void insertionSort(int A[], int N){
  for(int i=1;i<N;i++){
    int v = A[i];
    int j = i -1;
    while(j>=0 && A[j]>v){
      A[j+1] = A[j];
      j--;
    }
    A[j+1] = v;
    display(A, N);
  }
}

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

  int A[N];
  for(int i=0;i<N;i++){
    A[i] = 0;
  }

  for(int i=0;i<N;i++){
    cin >> A[i];
  }

  display(A, N);
  insertionSort(A, N);

}



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

using namespace std;

#define LL long long 
#define ULL unsigned LL
#define LD long double 

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	char c;
	cin>>c;
	if((int)c >= 97)
		cout<<"a";
	else
		cout<<"A";
}


Measured memory_bytes: 3648
/* Generated by powerful Codeforces Tool
 * You can download the binary file in here https://github.com/xalanq/cf-tool (Windows, macOS, Linux)
 * Author: alireza_kaviani
 * Time: 2020-04-16 18:37:38
**/
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;

#define all(x)                      (x).begin(),(x).end()
#define Sort(x)                     sort(all((x)))
#define X                           first
#define Y                           second
#define sep                         ' '
#define endl                        '\n'
#define SZ(x)                       ll(x.size())

ll poww(ll a, ll b, ll md) {
    return (!b ? 1 : (b & 1 ? a * poww(a * a % md, b / 2, md) % md : poww(a * a % md, b / 2, md) % md));
}

const ll MAXN = 1e6 + 10;
const ll LOG = 22;
const ll INF = 8e18;
const ll MOD = 1e9 + 7; // 998244353; // 1e9 + 9;

ll n , m;

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

    cin >> n >> m;
    cout << ((n - m) * 100 + m * 1900) * (1ll << m) << endl;

    return 0;
}
/*

*/


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,x,n) for(int i=x;i<(int)n;i++)
#define rep(i,n) REP(i,0,n)
#define sp(p) cout<<setprecision(16)<<fixed<<p<<endl;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define SORT(a) sort(all(a))
#define RSORT(a) sort(rall(a))
#define UNIQ(a) unique(all(a))
#define UNIQNUM(a) UNIQ(a)-a.begin()
#define UNIQIT(a) a.erase(UNIQ(a), a.end());
#define VOUT(v,i) cout<<#v<<": ";for(int i=0;i<(int)v.size();i++){cout<<v[i]<<" ";}cout<<"\n";
#define vout(v) VOUT(v,z);
#define vmin(v) *min_element(all(v))
#define vmax(v) *max_element(all(v))
#define vsum(v) accumulate(all(v), 0LL);
#define MOUT(m,r,c) rep(i,r){rep(j,c){cout<<m[i][j]<<" ";}cout<<endl;}
#define mout(m) MOUT(m,m.size(),m[0].size())
#define debg(a) cout<<#a<<": "<<a<<endl;
#define show(a) for(cont &y:a){for(cont &x:y){cout<<x<<" ";}cout<<endl;}
#define digit(a) to_string(a).length();
template<class T>inline int out(const T &t){ print(t); putchar('\n'); return 0; }
template<class T>inline T gcd(T a,T b){if(b==0)return a; return(gcd(b,a%b));}
template<class T>inline T lcm(T a,T b){return a/gcd(a,b)*b;}
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef vector<ll> V;
// const long long MOD=1000000007;
const long long INF = 1e18;
#define EPS (1e-7)
#define PI (acos(-1))
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) { a = b; return true; }
    return false;
}
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) { a = b; return true; }
    return false;
}

bool IsPrime(ll num){
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2) {
        if (num % i == 0) {
            return false;
        }
    }
    return true;
}

void solve(long long X){
    for (ll i = X; i <= 10e5; i++) {
        if(IsPrime(i)){
            cout << i << "\n";
            return;
        }
    }
}

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


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

int q, mode, a, b, SZ;
long long CONSTANT, ls, rs;
multiset <int> l, r;

void add (multiset <int> &, long long &, int);
void del (multiset <int> &, long long &, int);

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> q;
	
	while (q--) {
		cin >> mode;
		if (mode == 1) {
			cin >> a >> b;
			SZ++;
			CONSTANT += b;
			add (l, ls, a);

			while (l.size() && r.size() && *l.rbegin() > *r.begin()) {
				int ltor = *l.rbegin();
				int rtol = *r.begin();
				del (r, rs, rtol);
				del (l, ls, ltor);
				add (r, rs, ltor);
				add (l, ls, rtol);
			}

			while (r.size() < SZ / 2) {
				int v = *l.rbegin();
				del (l, ls, v);
				add (r, rs, v);
			}

			while (l.size() < (SZ + 1) / 2) {
				int v = *r.begin();
				del (r, rs, v);
				add (l, ls, v);
			}
		} else {
			long long x = *l.rbegin();
			long long f = (x * l.size()) - ls;
			f += rs - (x * r.size());
			cout << x << ' ' << f + CONSTANT << endl;
		}
	}
}

void add (multiset <int> &st, long long &sum, int v) {
	sum += v;
	st.insert(v);
}

void del (multiset <int> &st, long long &sum, int v) {
	sum -= v;
	st.erase(st.find(v));
}

// SamMHD :: Jun26-2019 :: Another Day with Shayan...

Measured memory_bytes: 9600
#include <bits/stdc++.h>
using namespace std;
#define SELECTER(_1, _2, _3, SELECT, ...) SELECT
#define REP1(i, n) for(int i=0; (i)<(n); (i)++)
#define REP2(i, a, b) for(int i=(a); (i)<(b); (i)++)
#define REP(...) SELECTER(__VA_ARGS__, REP2, REP1,) (__VA_ARGS__)
#define MOD 1'000'000'007

template <class T> ostream& operator<<(ostream& os, const vector<T>& v){ os << "{"; for(size_t i=0; i<v.size(); i++) os << v[i] << (i+1==v.size() ? "" : ", "); os << "}"; return os; }
template <class T, class U> ostream& operator<<(ostream& os, const pair<T, U>& p){ return os << "{" << p.first << ", " << p.second << "}"; }

int main(){
    int L, R, d;
    cin >> L >> R >> d;
    int ans = 0;
    for(int i=L; i<=R; i++){
        if(i%d==0) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3564
#include <stdio.h>

#define N 100

#define WHITE 0
#define BLACK 1
#define GRAY 2

int n,M[N][N];

int color[N],d[N],f[N],tt;

void DFS_visit(int u){ /*再帰関数による深さ優先探索*/
  int v;
  color[u]=GRAY;
  d[u]=++tt; /*最初の訪問*/

  for(v=0;v<n;v++){
    if(M[u][v]==0) continue;

    if(color[v]==WHITE){
      DFS_visit(v);
    }
  }
  color[u] = BLACK;
  f[u]=++tt; /*訪問終了*/
}

void DFS(){
  int u;
  for(u=0;u<n;u++){
    color[u]=WHITE;
    tt=0;
  }

  for(u=0;u<n;u++){/* 未訪問のuを始点として深さ優先探索 */
    if(color[u]==WHITE) DFS_visit(u);
  }

  for(u=0;u<n;u++){
    printf("%d %d %d\n",u+1,d[u],f[u]);
  }
}

int main(){
  int i,j,u,v,k;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      M[i][j]=0;
    }
  }
  
  for(i=0;i<n;i++){
    scanf("%d %d",&u,&k);
    u--;

  for(j=0;j<k;j++){
    scanf("%d",&v);
    v--;
    M[u][v]=1;
  }
}
DFS();

return 0;
}
    



Measured memory_bytes: 2108
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;
typedef long long ll;

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

    int ans = 1;
    for(int i=0; i<n-1; i++){
        if(s[i] != s[i+1]){
            ans++;
        }
    }

    cout << ans <<endl;
}

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

int main(){
  int n;
  cin >> n;
  int a,b,c;
  a = n/100;
  b = n/10%10;
  c = n%10;
  
  if (a==7||b==7||c==7){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 3628
//Andrew Yang
#include <iostream>
#include <stdio.h>
#include <sstream>
#include <fstream>
#include <string>
#include <string.h>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>	
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <climits>
using namespace std;
#define FOR(index, start, end) for(int index = start; index < end; ++index)
#define RFOR(index, start, end) for(int index = start; index > end; --index)
#define FOREACH(itr, b) for(auto itr = b.begin(); itr != b.end(); ++itr)
#define RFOREACH(itr, b) for(auto itr = b.rbegin(); itr != b.rend(); ++itr)
#define INF 1000000000
#define M 1000000007
typedef long long ll;
typedef pair<int, int> pii;
char grid[800][800];
bool visited[800][800];
int d[800][800];
int dx[] = { -1, 0, 1, 0 };
int dy[] = { 0, -1, 0, 1 };
int main(void)
{
	int h, w, k;
	scanf("%d%d%d", &h, &w, &k);
	int si = 0;
	int sj = 0;
	FOR(i, 0, h) {
		FOR(j, 0, w) {
			cin >> grid[i][j];
			if (grid[i][j] == 'S') {
				si = i;
				sj = j;
			}
			d[i][j] = INF;
		}
	}
	queue<int> q;
	q.push(si);
	q.push(sj);
	d[si][sj] = 0;
	visited[si][sj] = true;
	while (!q.empty())
	{
		int i = q.front();
		q.pop();
		int j = q.front();
			q.pop();
		FOR(x, 0, 4) {
			int i2 = i + dx[x];
			int j2 = j + dy[x];
			if (i2 < 0 || i2 >= h || j2 < 0 || j2 >= w || visited[i2][j2] || grid[i2][j2] == '#') {
				continue;
			}
			d[i2][j2] = d[i][j] + 1;
			visited[i2][j2] = true;
			q.push(i2);
			q.push(j2);
		}
	}
	int ans = INF;
	FOR(i, 0, h) {
		FOR(j, 0, w) {
			if (d[i][j] <= k) {
				ans = min(ans, min(min(i, h - 1 - i), min(j, w - 1 - j)));
			}
		}
	}
	if (ans % k == 0) {
		ans /= k;
	}
	else {
		ans = ans / k + 1;
	}
	cout << ans + 1 << endl;
}

Measured memory_bytes: 3968
#include <bits/stdc++.h>
#define FOR(i,a,b)  for(int (i)=(a);(i)<(b);(i)++)
#define REP(i,n)    FOR(i,0,n)
#define RER(i,n)    FOR(i,0,(n+1))
#define pb          push_back
#define mp(a,b)     make_pair((a),(b))
#define mset(m,v)   memset(m,v,sizeof(m))
using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pair<int, int> > vpii;
typedef long long ll;
typedef vector<ll> vl;
typedef pair<ll,ll> pll;
typedef vector<pair<ll, ll> > vpll;
typedef vector<string> vs;
typedef long double ld;
const double EPS    = 1e-10;
const int INF       = 1e+9;
const double PI     = acos(-1);


auto main() -> int
{
    string str;
    cin >> str;

    int a = str.find("C");
    int b = str.rfind("F");
    if ( a != string::npos && b != string::npos && a < b ) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}



Measured memory_bytes: 256
<?php
list($n) = fscanf(STDIN,'%d');
$h = array_map('intval', explode(" ",trim(fgets(STDIN))));

$ans = 1;
$max=$h[0];
//maxを保持し、maxより大きいhの数を求める
for($i=0; $i<$n-1; $i++){
    if($max<=$h[$i+1]){
        $max = $h[$i+1];
        $ans++;
    }
}
echo $ans;


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

using namespace std;

int main(){
        int N;
        cin>>N;
        bool flag[4];
        for(int i=0;i<4;i++){
                flag[i]=false;
        }
        string s="PWGY";
        for(int i=0;i<N;i++){
                char ss;
                cin>>ss;
                for(int j=0;j<4;j++){
                        if(s[j]==ss){
                                flag[j]=true;
                        }
                }
        }
        int cnt=0;
        for(int i=0;i<4;i++){
                if(flag[i]){
                        cnt++;
                }
        }
        if(cnt==3){
                cout<<"Three"<<endl;
        }
        else{
                cout<<"Four"<<endl;
        }
        return 0;
}


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

using namespace std;

#define sp(x) cout<<setprecision(x);
#define all(a) (a).begin(), (a).end()
#define inf 10000000
#define linf INT64_MAX*0.99
#define int long long
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define yes "Yes"
#define no "No"
#define divs 1000000007
#define dive 1000000009

typedef pair<int, int> P;

int n; 
vector<int> l;
bool isOK(int index, int key){
	if(l[index] >= key) return true;
	else return false;
}
int binary_search(int key){
	int ng = -1;
	int ok = (int)l.size();

	while(abs(ok-ng)>1){
		int mid = (ok + ng) /2;

		if(isOK(mid,key)) ok = mid;
		else ng = mid;
	}
	return ok;
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
	cin>>n;
	l.resize(n);
	REP(i,n) cin>>l[i];
	sort(all(l));
	int ans = 0;
	REP(i,n-1){
		FOR(j,i+1,n){
			int a = l[i];
			int b = l[j];
			int left = binary_search(max(a-b,b-a)+1);
			int right = binary_search(a+b);
			if(left<=i&&i<right) ans--;
			if(left<=j&&j<right) ans--;
			ans += right - left;
		}
	}
	cout<<ans/3<<endl;
    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# vim:fenc=utf-8 ff=unix


def solv(X, Y, Z):
    # A B C
    # Z X Y
    return " ".join([Z, X, Y])


if __name__ == "__main__":

    # X Y Z
    #
    X, Y, Z = input().split()
    ans = solv(X, Y, Z)

    print(ans)


Measured memory_bytes: 2940
#include<iostream>
#include<map>
using namespace std;
#define rep(i,j,k) for(int (i)=(j);(i)<(k);++(i))

int main(){
    int N,r;
    map<int,int> mp;
    cin>>N;
    rep(i,0,N){cin>>r;++mp[r];}
    r=0;
    for(auto i=mp.begin();i!=mp.end();++i){
        if(i->first>i->second) r+=i->second;
        else r+=i->second-i->first;
    }
    cout<<r<<endl;
}


Measured memory_bytes: 4736
open Batteries

let read_two () = Scanf.sscanf (read_line ()) "%d %d" (fun a b -> (a, b))

let read_three () =
  Scanf.sscanf (read_line ()) "%d %d %d" (fun a b c -> (a, b, c))

let read_four () =
  Scanf.sscanf (read_line ()) "%d %d %d" (fun a b c d -> (a, b, c, d))

let read_list () =
  read_line () |> String.split_on_char ' '
  |> List.map (fun s -> int_of_string s)

(* a**x *)
let pow a x =
  let rec aux acc = function 0 -> acc | n -> aux (acc * a) (n - 1) in
  aux 1 x

let rec pow2 n = if n mod 2 = 0 then 1 + pow2 (n / 2) else 0

let rec f n = if n mod 2 = 0 then n / 2 else (3 * n) + 1

module IntSet = Set.Make (struct
  let compare = Pervasives.compare

  type t = int
end)

let () =
  let n = read_int () |> ref in
  let ans = ref 1 and s = ref IntSet.empty in
  while IntSet.exists (fun x -> x = !n) !s |> not do
    s := IntSet.add !n !s;
    n := f !n;
    ans := !ans + 1
  done;
  print_int !ans;
  print_newline ()


Measured memory_bytes: 1152
import numpy as np
N,W = map(int,input().split())
V_sum = 0
w_l = []
v_l = []
for i in range(N):
    w,v = list(map(int,input().split()))
    V_sum+=v
    w_l.append(w)
    v_l.append(v)
dp = np.full(V_sum+1,W+1)
dp[0] = 0
for i in range(N):
    dp[v_l[i]:] = np.minimum(dp[v_l[i]:],dp[:-v_l[i]]+w_l[i])
for i in range(V_sum,-1,-1):
    if dp[i]<=W:
        print(i)
        break
    
    

Measured memory_bytes: 15656
#!/usr/bin/env python3

from sys import stdin, setrecursionlimit


def main():
    mod = 10 ** 9 + 7
    input = stdin.buffer.readline
    n = int(input())
    s1 = list(input()[:-1].decode())
    s2 = list(input()[:-1].decode())
    ans = 0
    if s1[0] == s2[0]:
        ans = 3
    else:
        ans = 6
    for i in range(1, n):
        if s1[i - 1] == s2[i - 1]:
            if s1[i] == s2[i]:
                ans *= 2
            else:
                ans *= 2
            ans %= mod
        else:
            if s1[i - 1] == s1[i] and s2[i - 1] == s2[i]:
                ans *= 1
            elif s1[i] != s2[i]:
                ans *= 3
            else:
                ans *= 1
            ans %= mod
    print(ans % mod)


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()


Measured memory_bytes: 61344
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#define llong long long
#define INF (__INT32_MAX__ / 2)
#define EPS 10e-8
#define MAX_N 500
#define MAX_C 30

using namespace std;
typedef pair<llong, llong> ipair;
llong modulo(llong left, llong right) { return (left % right + right) % right; }

int N, C;
int D[MAX_C][MAX_C], c[MAX_N][MAX_N];
int colcnt[3][MAX_C];

int main(int argc, char **argv) {
    cin >> N >> C;
    for(int i = 0; i < C; ++i)
        for(int j = 0; j < C; ++j)
            cin >> D[i][j];
    
    for(int i = 0; i < N; ++i)
        for(int j = 0; j < N; ++j) {
            cin >> c[i][j];
            c[i][j]--;
            colcnt[(i + j) % 3][c[i][j]]++;
        }
    
    int res = INF;
    for(int i = 0; i < C * C * C; ++i) {
        int colors[3];
        colors[0] = i % C;
        colors[1] = (i / C) % C;
        colors[2] = i / (C * C);

        if(colors[0] == colors[1] || colors[1] == colors[2] || colors[2] == colors[0])
            continue;

        int cur = 0;
        for(int j = 0; j < 3; ++j)
            for(int col = 0; col < C; ++col)
                cur += colcnt[j][col] * D[col][colors[j]];

        res = min(res, cur);
    }

    cout << res << endl;
}

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

typedef long long ll;
typedef pair<int,int> P;
typedef map<int,int> M;
typedef vector<int> V;
typedef queue<int> Q;
typedef pair<long,long> PLL;
typedef map<long,long> MLL;
typedef vector<long> VLL;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define MOD (1e9+7)
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n-1);i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define ROT(a) a.begin(),a.begin()+1,a.end()
#define RROT(a) a.begin(),a.end()-1,a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
/*--------------------------------------------*/

int main(){
    string s;cin>>s;
    string judge="AC";
    if(s[0]!='A')judge="WA";
    int cnt=0;
    for(int i=1;i<(int)s.size();i++){
        if(isupper(s[i])){//大文字の時
            //cout<<s[i]<<endl;
            if(s[i]!='C'||i==1||i==(int)s.size()-1)judge="WA";
            cnt++;//3~最後-1文字目にCがある時の数
        }
    }
    //printf("cnt=%d\n",cnt);
    if(cnt!=1)judge="WA";
    cout<<judge<<endl;
}


Measured memory_bytes: 256
// C - ID
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
#define rp(i,n) for(int i=0;i<(n);i++)
#define all(x) (x).begin(),(x).end()

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

	vector<tuple<int,int,int>> T;//[i]<prefecture,year,city-1>
	rp(i,M){
		int p,y; cin>>p>>y;
		T.emplace_back(p, y, i);
	}

	sort(all(T));

	vector<tuple<int,int,int>> ans;//[i]<city-1,h_id,l_id>
	vi p_count(N);//[prefecture-1]
	rp(i,M){
		int p,y,c; tie(p,y,c) = T[i];
		p_count[p-1]++;
		int h_id = p;
		int l_id = p_count[p-1];
		ans.emplace_back(c, h_id, l_id);
	}

	sort(all(ans));

	for(auto e:ans){
		int c,h,l; tie(c,h,l) = e;
		printf("%06d%06d\n", h,l);
	}
}

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

int parent(int index) {
    if (index == 1) {
        return 0;
    }

    return index / 2;
}

int get_left(int index) {
    return 2 * index;
}

int get_right(int index) {
    return (2 * index) + 1;
}

vector<int>vec;
void maxHeapify(int index) {
    int H = vec.size();
    int l = get_left(index);
    int r = get_right(index);
    int largest;
    if (l <= H && vec[l] > vec[index]) {
        largest = l;
    } else {
        largest = index;
    }

    if (r <= H && vec[r] > vec[largest]) {
        largest = r;
    }

    if (largest != index) {
        int tmp = vec[index];
        vec[index] = vec[largest];
        vec[largest] = tmp;
        maxHeapify(largest);
    }
}

void buildMaxHeap() {
    int size = vec.size() / 2;
    for (int i=size; i >= 1; i--) {
        maxHeapify(i);
    }
}

int main() {
    int N;
    cin >> N;
    vec.resize(N+1);
    for (int i=1; i <= N; i++) {
        cin >> vec.at(i);
    }

    buildMaxHeap();
    for (int i=1; i <= N; i++) {
        cout << " ";
        cout << vec[i];
    }

    cout << endl;
    return 0;
}


Measured memory_bytes: 4592
#include<bits/stdc++.h>
using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;

#define FOR(i,a,b) for (int i = a; i < b; ++i)
#define FORR(i,a,b) for (int i = b - 1; i >= a; --i)
#define REP(i,n) FOR(i,0,n)
#define REPR(i,n) FORR(i,0,n)

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

	switch (N % 10) {
		case 0:
			cout << "pon" << endl;
			break;
		case 1:
			cout << "pon" << endl;
			break;
		case 2:
			cout << "hon" << endl;
			break;
		case 3:
			cout << "bon" << endl;
			break;
		case 4:
			cout << "hon" << endl;
			break;
		case 5:
			cout << "hon" << endl;
			break;
		case 6:
			cout << "pon" << endl;
			break;
		case 7:
			cout << "hon" << endl;
			break;
		case 8:
			cout << "pon" << endl;
			break;
		case 9:
			cout << "hon" << endl;
			break;
	}

	return 0;
}

Measured memory_bytes: 3584
N = int(input())
a = [ int(v) for v in input().split(" ") ]
 
l = [0] * 9
 
for i in range(N):
  rate = a[i]
  
  if rate < 400:
    l[0] += 1
  elif rate < 800:
    l[1] += 1
  elif rate < 1200:
    l[2] += 1
  elif rate < 1600:
    l[3] += 1
  elif rate < 2000:
    l[4] += 1
  elif rate < 2400:
    l[5] += 1
  elif rate < 2800:
    l[6] += 1
  elif rate < 3200:
    l[7] += 1
  else:
    l[8] += 1
 
uniq_n = 0
for i in range(8):
  if l[i] != 0:
    uniq_n += 1
 
min_v = 1 if uniq_n == 0 else uniq_n
max_v = uniq_n + l[8]
print(min_v, max_v)

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

public class P
{
    public int x { get; set; }
    public int nx { get; set; }
    public int y { get; set; }
    public int ny { get; set; }
}

public class Hello
{
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var h = int.Parse(line[0]);
        var w = int.Parse(line[1]);
        var a = new int[h, w];
        for (int i = 0; i < h; i++)
        {
            line = Console.ReadLine().Trim().Split(' ');
            for (int j = 0; j < w; j++)
                a[i, j] = int.Parse(line[j]);
        }
        var ps = new List<P>();
        if (h == 1) goto h1;
        for (int i = 0; i < h - 1; i++)
            for (int j = 0; j < w; j++)
                if (a[i, j] % 2 == 1)
                {
                    a[i, j]--;
                    a[i + 1, j]++;
                    ps.Add(new P { x = i + 1, nx = i + 2, y = j + 1, ny = j + 1 });
                }
            h1:;
        for (int i = 0; i < w - 1; i++)
        {
            if (a[h - 1, i] % 2 == 1)
            {
                a[h - 1, i]--;
                a[h - 1, i + 1]++;
                ps.Add(new P { x = h, nx = h, y = i + 1, ny = i + 2 });
            }
        }
        var psc = ps.Count();
        Console.WriteLine(psc);
        for (int i = 0; i < psc; i++)
        {
            var t = ps[i];
            Console.WriteLine("{0} {1} {2} {3}", t.x, t.y, t.nx, t.ny);
        }
    }
}

Measured memory_bytes: 28064
package main
 
import (
	"fmt"
)
 
func main() {
	var a, b, c, d int
	fmt.Scanf("%d %d %d %d", &a, &b, &c, &d)
		
	var ac, ad, bc, bd int 

	ac = a * c
	ad = a * d
	bc = b * c
	bd = b * d

	var ans int 
	if ac < ad{
		ans = ad
	} else {
		ans = ac
	}

	if ans < bc{
		ans = bc
	} 

	if ans < bd{
		ans = bd
	}

	fmt.Printf("%d\n", ans)
}


Measured memory_bytes: 1836
#include<stdio.h>

int main(){
int A,B,M;
scanf("%d%d%d",&A,&B,&M);
int a[A],b[B];
int m[M][3];
int pay[M];
int min_a=200000,min_b=200000,min_pay=0;

for (int i = 0; i < A; i++){
  scanf("%d",&a[i]);
  if (min_a>a[i]) min_a=a[i];
}
for (int i = 0; i < B; i++){
  scanf("%d",&b[i]);
  if (min_b>b[i]) min_b=b[i];
}
for (int i = 0; i < M; i++){
  for (int j = 0; j < 3; j++){
    scanf("%d",&m[i][j]);
  }
}

min_pay = min_a + min_b;

for (int i = 0; i < M; i++){
  pay[i] = a[m[i][0]-1] + b[m[i][1]-1] - m[i][2];
  if (min_pay>pay[i])
  {
    min_pay = pay[i];
  }
}

printf("%d",min_pay);


return 0;

}


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

int main() 
{
	int a,b;
	cin>>a>>b;
	int ans;
	if((2*b)>=a){
		ans=0;
	}else{
		ans=a-(2*b);
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        long m = sc.nextLong();
        if (2 * n >= m) {
            System.out.println(m / 2);
            return;
        }
        System.out.println(n + (m - 2 * n) / 4);
    }

}


Measured memory_bytes: 23124
import java.util.Scanner;
public class Main {
public static void main(String[]srgs) {
	Scanner scan=new Scanner(System.in);
	int a=scan.nextInt();
	int b=scan.nextInt();
	int c=scan.nextInt();
	int d[]=new int[a];
	for(int i=0;i<a;i++) {
		d[i]=scan.nextInt();
	}
	for(int i=0;i<a;i++) {
		for(int j=0;;j++) {
			if((d[i]*j+1)<=b) {
				c++;
			}
			else {
				break;
			}
		}
	}
	System.out.println(c);
	scan.close();
}
}


Measured memory_bytes: 25044
A, B = map(int, input().split(" "))

ans = 0
tmp = 1
while True:
    tmp *= 2
    tmp_count0 = 0
    tmp_count1 = 0

    before_tmp = tmp//2
    loopB = (B+1) // tmp
    tmp_count0 += loopB*before_tmp
    tmp_count1 += loopB*before_tmp

    loopA = (A) // tmp
    tmp_count0 -= loopA*before_tmp
    tmp_count1 -= loopA*before_tmp

    leftB = (B+1) % tmp
    if leftB > before_tmp:
        tmp_count0 += before_tmp
        tmp_count1 += leftB-before_tmp
    else:
        tmp_count0 += leftB
    leftA = (A) % tmp
    if leftA > before_tmp:
        tmp_count0 -= before_tmp
        tmp_count1 -= leftA-before_tmp
    else:
        tmp_count0 -= leftA

    if tmp_count1 % 2 == 1:
        ans += before_tmp
    else:
        ans += 0
    # print(loopA,loopB,leftA,leftB)
    # print(tmp_count0, tmp_count1)
    if before_tmp >= B:
        break
print(ans)


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

using ll = long long int;

const int MOD = 1e9 + 7;

#define MAX(a, b) ((a > b) ? a : b)
#define MIN(a, b) ((a > b) ? b : a)

template <class T>
class my_array{
  private:
    int n;
    vector<T> A;
  public:
    my_array(int k){n = k; A.resize(n);}
    ~my_array(void){};
    // input a_0, a_1, ..., a_(n-1)
    void get(void){
      for(int i = 0; i < n; i++) cin >> A.at(i);
    }
    // sort A
    void sorted(bool flag = true){
      if(flag) sort(A.begin(), A.end());
      else sort(A.begin(), A.end(), greater<T>());
    }
    // print : a_0, a_1, ... a_(n-1)
    void show(void){
      for(int i = 0; i < n - 1; i++) cout << A.at(i) << " ";
      cout << A.at(n - 1) << "\n";
    }
    int solve(int a, int b){
      if(a >= b) return 0;
      int mn_idx = 0, min = 1e9;
      for(int i = a; i < b; i++) if(min > A.at(i)){
        min = A.at(i);
        mn_idx = i;
      }
      for(int i = a; i < b; i++) A.at(i) -= min;
      return solve(a, mn_idx) + min + solve(mn_idx + 1, b);
    }
};

/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */

string s1, s2, s3;

int mx_same(char p, char q, char r){
  if(p == q){
    if(q == r) return 3;
    else return 2;
  }
  else{
    if(p == r || q == r) return 2;
    else return 1;
  }
}

using vi = vector<int>;
using pii = pair<int, int>;
using vpi = vector<pii>;

int main(void){
  int n, a, b; cin >> n;
  vector<int> A(n), B(n);
  vpi C(n);
  for(int i = 0; i < n; i++){
    cin >> A.at(i) >> B.at(i);
    C.at(i) = make_pair(A.at(i) + B.at(i), i );
  }
  sort(C.begin(), C.end(), greater<pii>() );
  long long int res = 0;
  for(int i = 0; i < n; i++){
    if(i % 2 == 0) res += A.at(C.at(i).second);
    else res -= B.at(C.at(i).second);
  }
  cout << res << "\n";
  return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
typedef long long i64;
using std::cout;
using std::endl;
using std::cin;

int main(){
	int n, m; cin >> n >> m; m /= 100;
	
	int dp[n + 1][m + 1] = {};
	std::vector<int> a(n), b(n);
	for(int i = 0; i <= n; i++) for(int j = 0; j <= m; j++) dp[i][j] = 1e9; dp[0][0] = 0;
	for(int i = 0; i < n; i++) {
		cin >> a[i] >> b[i]; b[i] /= 100;
		
		for(int j = 0; j <= m; j++) {
			for(int k = 0; k < a[i]; k++) {
				int to = std::min(m, j + (i + 1) * k);
				dp[i + 1][to] = std::min(dp[i + 1][to], dp[i][j] + k);
			}
			int to = std::min(j + (i + 1) * a[i] + b[i], m);
			dp[i + 1][to] = std::min(dp[i + 1][to], dp[i][j] + a[i]);
		}
	}
	
	cout << dp[n][m] << endl;
	return 0;
}


Measured memory_bytes: 4736
import collections
N = int(input())
D = list(map(int, input().split()))
DC = collections.Counter(D)
M = int(input())
T = list(map(int, input().split()))
TC = collections.Counter(T)

for num, count in TC.items():
     if DC[num] < count:
         print('NO')
         exit()
print('YES')


Measured memory_bytes: 153208
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ALL(x) x.begin(), x.end()
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
random_device rnd;
mt19937 mt(rnd());
using ll = long long;
using lld = long double;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<ll>;
using VVL = vector<VL>;
using PII = pair<int, int>;
const int IINF = 1 << 30;
const ll INF = 1ll << 60;
const ll MOD = 1000000007;

int main()
{

    int h, w, k;
    cin >> h >> w >> k;
    vector<string> g(h);
    rep(i, h)
    {
        cin >> g[i];
    }
    VVI ans(h, VI(w, -1));
    int next = 1;
    rep(i, h)
    {

        int col = -1;
        rep(j, w)
        {
            if (g[i][j] == '#')
            {
                if (col == -1)
                {
                    rep(jj, j)
                    {
                        ans[i][jj] = next;
                    }
                }
                col = next;
                next++;
            }
            ans[i][j] = col;
        }
    }

    rep(loop, h)
    {
        rep(i, h) rep(j, w)
        {
            if (i != 0 && ans[i][j] == -1)
            {
                ans[i][j] = ans[i - 1][j];
            }
            if (i != h - 1 && ans[i][j] == -1)
            {
                ans[i][j] = ans[i + 1][j];
            }
        }
    }
    rep(i, h)
    {
        rep(j, w)
        {
            cout << ans[i][j] << " ";
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 4108
n = int(input())
s = list(input())

l_a = []
l_b = [0]
x = 0

for i in s:
    if i == 'I':
        l_a.append(1)
    else:
        l_a.append(-1)
        
for j in l_a:
    l_b.append(x + j)
    x += j

ans = max(l_b)

print(ans)

Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
int N;
int A[100010];
int main() {
	std::cin >> N;
	for (int i = 0; i < N; i++) {
		int tmp;
		std::cin >> tmp;
		A[tmp]++;
		A[tmp + 1]++;
		A[tmp + 2]++;
	}
	int ans = 0;
	for (int i = 0; i <= 1e5 + 1; i++) {
		ans = std::max(ans, A[i]);
	}
	std::cout << ans << std::endl;
	return 0;
}

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

int main() {

  string S;
  cin >> S;

  int e = 0,w = 0,n = 0,s = 0;
  for(int i = 0;i < S.size();i++) {
    if(S.at(i) == 'E') e++;
    if(S.at(i) == 'W') w++;
    if(S.at(i) == 'N') n++;
    if(S.at(i) == 'S') s++;
  }

  bool l = false,c = false;
  if(n == s || n > 0 && s > 0) l = true;
  if(e == w || e > 0 && w > 0) c = true;

  if(l && c) cout << "Yes" << endl;
  else cout << "No" << endl;

  
}



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

//#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

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> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};


signed main(){
    gearup;
    ll n;cin>>n;
    vl l(n);
    rep(i,n)cin>>l[i];
    sort(all(l));
    ll res = 0;
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            ll idx = lower_bound(all(l),l[i]+l[j]) - l.begin();
            if(idx - 1 > j) res += idx - 1 - j;
        }
    }
    out(res);
}



Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))

minus = sum(x < 0 for x in A)

absA = list(map(abs,A))
if minus % 2 == 0:
    ans = sum(absA)
else:
    ans = sum(absA) - (2 * min(absA))

print(ans)

Measured memory_bytes: 14284
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<random>
#include<stack>
#include<queue>
#include<bitset>
#include<sstream>

#define rep(i,n) for(int i=0;i<(n);i++) 
#define rep1(i,n) for(int i=1;i<(n);i++)
#define co(x) cout << x << endl
#define cosp(x) cout << x << " "

using namespace std;
using ll = long long;

int main(int argc, const char *argv[]){
    ll n,m;
    cin >> n >> m;
    vector<ll> a(n),b(n);
    rep(i,n) cin >> a[i];
    priority_queue<ll, vector<ll>> que;
    rep(i,n) que.push(a[i]);
    rep(i,m){
        ll x = que.top()/2;
        que.pop();
        que.push(x);
    }
    ll ans=0;
    rep(i,n){
        ans += que.top();
        que.pop();
    }
    co(ans);
    return 0;
}

Measured memory_bytes: 2936
# frozen_string_literal: true

n, a, b = gets.split(' ').map(&:to_i)

sum = 0
(1..n).each do |i|
  temp = 0
  i.to_s.split('').map(&:to_i).each do |i|
    temp += i
  end
  sum += i if temp >= a && temp <= b
end

puts sum


Measured memory_bytes: 2300
import java.util.*;

public class Main{

    public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
	
	int n = sc.nextInt();
	
	
	for(;n>0;n--){
	    int s = (a( sc.next().toCharArray())+ a( sc.next().toCharArray())); 
 	    System.out.println( b(s));
	}

    }
    
    static int a(char[] s){
	int m = 1000;
	int c = 100;
	int x = 10;
	int i = 1;
	
	int p = 1;
	int t=0;
	for(int k=0; k<s.length ; k++){
	    switch(s[k]){
	    case 'm':
		t+=p*m;
		p=1;
		break;
	    case 'c':
		t+=p*c;
		p=1;
		break;
	    case 'x':
		t+=p*x;
		p=1;
		break;
	     case 'i':
		t+=p*i;
		p=1;
		break;
	    default:
		p = Integer.parseInt("" + s[k]);
		break;
	    }
	}

	return t;
    }

    static String b(int t){
	String s = "";

	if( t/1000> 0 ){
	    if( t/1000> 1 ) s+= t/1000;
	    s+= 'm';
	    t%=1000;
	}
	
	if( t/100> 0 ){
	    if( t/100> 1 ) s+= t/100;
	    s+= 'c';
	    t%=100;
	}
	
	if( t/10> 0 ){
	    if( t/10> 1 ) s+= t/10;
	    s+= 'x';
	    t%=10;
	}
	
	if( t > 0 ){
	    if( t > 1 ) s+= t;
	    s+= 'i';
	}

	return s;
	
    }
    
    
}

Measured memory_bytes: 12000
#include <algorithm>
#include <iostream>
#include <utility>
#include <vector>
using namespace std;

int main() {
	int N, X, L;
	cin >> N;
	vector<pair<int, int>> a(N);
	for (pair<int, int>& i : a) {
		cin >> X >> L;
		i.first = X - L;
		i.second = X + L;
	}
	sort(a.begin(), a.end(), [](pair<int, int>& a, pair<int, int>& b) { return a.second < b.second; });
	vector<int> b{ a.front().second };
	for (int i = 1; i < N; i++) {
		if (b.back() <= a[i].first) b.push_back(a[i].second);
	}
	cout << b.size();
}

Measured memory_bytes: 1660
def main():
    N = int(input())
    A = list(map(int, input().split()))
    lst = [(i, a) for i, a in enumerate(A)]
    lst.sort(key=lambda x: x[1])
    ans = [x[0] + 1 for x in lst]
    print(*ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 23652
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int ans = c-(a-b);
        System.out.println(Math.max(ans,0));
	}
}


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

int main(){
    string s; int K; 
    cin >> s >> K;
    vector<string> S;
    int N = s.size();
    for(int i=0; i<N; i++){
        for(int j=0; j<K; j++){
            if(i+j>=N) continue;
            string a="";
            for(int l=i; l<=i+j; l++){
                a +=s.at(l);
            }
            S.push_back(a);
        }
    }
//    for(auto x:S) cout << x << endl;
//    cout << endl;
    sort(S.begin(), S.end());
    S.erase( unique(S.begin(),S.end()) , S.end() );
//    for(auto x:S) cout << x << endl;
    cout << S.at(K-1) << endl;
}

Measured memory_bytes: 1660
def main():

    N = int(input())
    A = list(map(int, input().split()))
    v1 = 0
    v2 = 0
    i, j = 0, 0
    ans = 0
    # print(A)
    while i < N:

        while i < N and v1 + A[i] == v2 ^ A[i]:
            v1 += A[i]
            v2 ^= A[i]
            i += 1

        if i < N:
            v1 += A[i]
            v2 ^= A[i]
            while j < i and v1!= v2:
                v1 -= A[j]
                v2 ^= A[j]
                ans += i-j
                j += 1
            i += 1
    ans += (i-j)*(i-j+1)//2
    return ans

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

Measured memory_bytes: 24840
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<char, int> P;
int cnt[100001];
int sum[100001];
int main() {
	int N, K;
	cin >> N >> K;
	string S;
	cin >> S;
	vector<P> vec;
	char ch = S[0];
	int len = 1;
	for (int i = 1; i < N; i++) {
		if (ch != S[i]) {
			vec.emplace_back(ch, len);
			ch = S[i];
			len = 1;
		}
		else {
			len++;
		}
	}
	vec.emplace_back(ch, len);
	int M = vec.size();
	cnt[0] = (vec[0].first == '1');
	sum[0] = vec[0].second;
	for (int i = 1; i < M; i++) {
		cnt[i] = cnt[i - 1] + (vec[i].first == '1');
		sum[i] = sum[i - 1] + vec[i].second;
	}
	sum[M] = sum[M - 1];
	int ans = 0;
	for (int i = 0; i < M; i++) {
		int j = lower_bound(cnt, cnt + M, cnt[i] + K) - cnt;
		int tmp = sum[j];
		if (i > 0) tmp -= sum[i - 1];
		ans = max(ans, tmp);
	}
	cout << ans << endl;
}


Measured memory_bytes: 2164
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0;i< (n);i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
//long long ccw(const Point& A, const Point& B, const Point& C) {
//	return 1LL * (B.x - A.x)*(C.y - A.y) - 1LL * (B.y - A.y)*(C.x - A.x);
//}

int main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	ll L, R; cin >> L >> R;

	if (((R / (ll)2019) - (L / (ll)2019)) > 0) {
		cout << 0 << '\n';
	}
	else {
		ll ans = 10000000;
		for (ll i = L; i < R; i++) {
			for (ll j = i + 1; j <= R; j++) {
				ll tmp = i % 2019; 
				tmp *= (j % 2019);
				tmp %= 2019;
				ans = min(ans, tmp);
			}
		}
		cout << ans << '\n';
	}
	
	




}

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

void show_array(int *array, int &N){

	for(int i=0; i<N; ++i){
		cout << array[i];
		if(i < N-1){
			cout << " ";
		}
	}	
	cout << endl;
}

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

	int A[N]; // define a static array

	// Input values in the array
	for(int i=0; i<N; i++){
   scanf("%d", &A[i]);
	}


	// Selection Sort
	int minj, temp; 
	int count = 0;
	for(int i= 0; i<N-1; ++i){
		minj = i;
		for(int j=i; j<=N-1; ++j){
			if(A[j] < A[minj]){
				minj = j;
			}
		}
		if(A[i] != A[minj]){
			count += 1;
			temp = A[minj];
			A[minj] = A[i];
			A[i] = temp;
		}
	}	

	show_array(A, N);
	cout << count << endl;

	return 0;

}


Measured memory_bytes: 3212
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
//#include<ext/pb_ds/assoc_container.hpp>
//#include<ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
using namespace std;

#define ll long long
#define ull unsigned long long
#define ld long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vi vector<int>
#define vll vector<ll>
#define vpll vector<pll>
#define vpii vector<pii>
#define pb push_back
#define eb emplace_back
#define mt make_tuple
#define MP make_pair
#define fs first
#define sc second
#define F first
#define S second
#define nl "\n"
#define asche cerr<<"Ekhane asche\n";
#define pf printf
#define sf scanf
#define mem(a,x) memset(a,x,sizeof(a))
#define SZ(v) (int)v.size()
#define all(v) v.begin(),v.end()
#define one(x) __builtin_popcount(x)
#define fout(x) fixed<<setprecision(x)
#define BeatMeScanf ios_base::sync_with_stdio(false)
//int dx[]={1,0,-1,0,1,-1,-1,1};
//int dy[]={0,1,0,-1,1,1,-1,-1};
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define debug(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); deb(_it, args); }
void deb(istream_iterator<string> it) {}
template<typename T, typename... Args>
void deb(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << endl;
    deb(++it, args...);
}
//template <typename T> using o_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
namespace IO
{
    #define in() ( { int a ; scanf("%d",&a); a; } )
    #define LL() ( { ll a ; scanf("%lld",&a); a; } )
       #define ULL() ( { ull a ; scanf("%llu",&a); a; } )
    #define DD() ({ double a; scanf("%lf", &a); a;})
    #define CC() ( { char a ; scanf("%c",&a); a; } )
    #define pf1(a) printf("%d\n",a)
    #define pf1ll(a) printf("%lld\n",a)
}
using namespace IO;

const int mod=1e9+7;
const int N=3e5+9;
const double eps=1e-9;
const double PI=acos(-1.0);
ll qpow(ll n,ll k) {ll ans=1;assert(k>=0);n%=mod;while(k>0){if(k&1) ans=(ans*n)%mod;n=(n*n)%mod;k>>=1;}return ans%mod;}

pii l[N],r[N];
pii yo(pii a,pii b)
{
    return MP(max(a.F,b.F),min(a.S,b.S));
}
int len(pii a)
{
    return max(0,a.S-a.F+1);
}
int check(vpii v)
{
    int n=SZ(v);
    l[0]=v[0];
    for(int i=1;i<n;i++) l[i]=yo(v[i],l[i-1]);
    r[n-1]=v[n-1];
    for(int i=n-2;i>=0;i--) r[i]=yo(r[i+1],v[i]);
    int ans=0;
    for(int i=0;i+1<n;i++){
        ans=max(ans,len(l[i])+len(r[i+1]));
        if(i&&i+1<n) ans=max(ans,len(v[i])+len(yo(l[i-1],r[i+1])));
    }
    return ans;
}
int32_t main()
{
    int n=in();
    vpii v(n);
    for(auto &x: v) x.F=in(),x.S=in();
    for(int i=1;i<n;i++) if(v[i].S>v[0].S) swap(v[0],v[i]);
    int ans=0;
    sort(all(v));
    ans=max(ans,check(v));
    pf1(ans);
    return 0;
}
///Before submit=>
///    *check for integer overflow,array bounds
///    *check for n=1



Measured memory_bytes: 4608
#include <iostream>
using namespace std;
int main(){
    string s,t;
    cin >> s >> t;
    int N = s.size(),count=0;
    for(int i=0;i<N;i++){
        if(s[i] != t[i]){
            count++;
        }
    }   
    cout << count <<endl;
	return 0;
}

Measured memory_bytes: 3836
li = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
n = int(input())
ans = ['a']
for i in range(1,n):
    ans_new = []
    for j in range(len(ans)):
        s = ans[j]
        ma = 0
        for l in range(len(s)):
            ma = max(ma,li.index(s[l]))
        for k in range(ma+2):
            ans_new.append(s+li[k])
    ans = ans_new
for a in ans:
    print(a)

Measured memory_bytes: 12984
# -*- coding: utf-8 -*-
from collections import deque
import sys
sys.setrecursionlimit(100000)


if __name__ == '__main__':

    n = int(input())
    pre = deque([int(i) for i in input().split(" ")])
    ino = deque([int(i) for i in input().split(" ")])

    post = []
    def reconstruction(l, r):
        if l >= r:
            return
        c = pre.popleft()
        m = ino.index(c)
        reconstruction(l, m)
        reconstruction(m+1, r)
        
        post.append(c)

    reconstruction(0, n)
    print(" ".join(map(str, post)))


Measured memory_bytes: 6012
#include"bits/stdc++.h"
using namespace std;
using ll = long long;

int main() {
    ll N, A, B, C, D;
    cin >> N >> A >> B >> C >> D;

    for (ll i = 0; i < N; i++) {
        //i回は大きくなり,N - 1 - i回は小さくなる
        ll max = A + i * D - (N - 1 - i) * C;
        ll min = A + i * C - (N - 1 - i) * D;
        if (min <= B && B <= max) {
            cout << "YES" << endl;
            return 0;
        }
    }

    cout << "NO" << endl;
}

Measured memory_bytes: 256