akhauriyash/Code-Regression huggingface dataset:
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
 
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}
 
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
 
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}
 
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
 
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
 
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
 
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
 
 
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
 // ABC086C - Traveling
// https://atcoder.jp/contests/abs/fasks/arc089_a
 
 
fn main() {
    /*     input! {
        n: usize,
        mut plan: [(i32, i32, i32); n],  // Vec<(i32, i32, i32)>
    }
 */
    input! {
        a: u32,
        b: u32,
    }
    let mut result = 0;
    if b == 1 {
     println!("{}",0);
     return;
    }
    for i in (1..21) {
    	let x = a * i - (i - 1) ;
        if x >= b {
        	println!("{}",i);
            return;
        }
    }
}

Measured memory_bytes: 4352
#include <stdio.h>

int main(){
	int h,m,s;
	while(1){
		scanf("%d %d %d",&h,&m,&s);
		if(h == -1 && m == -1 && s == -1) break;
		s = 7200 - (h * 3600 + m * 60 + s);
		h = s / 3600;
		m = (s - h * 3600) / 60;
		printf("%02d:%02d:%02d\n",h,m,s % 60);
		s *= 3;
		h = s / 3600;
		m = (s - h * 3600) / 60;
		printf("%02d:%02d:%02d\n",h,m,s % 60);
	}
	return 0;
}

Measured memory_bytes: 612
#include<stdio.h>
int main(){
   int A,B,C,K;
   scanf("%d %d %d %d",&A,&B,&C,&K);

if (A >= K){

   printf("%d",K);
}else if (A + B >= K){

   printf("%d",A);
}else{
  
    int  a = A - (K - A - B);
    printf("%d",a);
}
return 0;
}

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

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

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

  int a, b, h;
  cin >> a >> b >> h;

  cout << (a + b) * h / 2 << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional> 
#define int long long 
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
using namespace std;
using namespace __gnu_pbds; 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> hashing;
int pow(int x,int n,int mod){int res = 1;while (n){if (n&1){res = (res*x)%mod;n--;}else{x = (x*x)%mod;n/=2;}}return res;}
const int MOD = 1e9 + 7;

/////////////////////////////////////" Please Don't ruin it "//////////////////////////////////////



int32_t main(){

    int n,k;
    cin>>n>>k;

    int arr[n+1];
    for (int i=1;i<=n;i++) cin>>arr[i];

    vector<bool>vis(n+1,0);
    vector<int>hoho;
    
    int pt = 1;
    while (!vis[pt]){
        hoho.push_back(pt);
        vis[pt] = 1;
        pt = arr[pt];
    }

    int ind;
    int siz = hoho.size();

    for (int i=0;i<siz;i++){
        if (hoho[i] == pt) ind = i;
    }

    if (k<=ind){
        cout<<hoho[k]<<'\n';
        return 0;
    }

    k-=ind;

    int len = siz - ind;

    k%=len;

    cout<<hoho[k + ind]<<'\n';



    return 0;
}

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

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

using namespace std;
using ll = long long;
int mod = 1000000007;

void solve();

int main(void){
    int N; cin >> N;
    string res;
    int beg, end; //male -> 0, female -> 1
    int l, mid, r;
    l = 0; r = N-1;
    rep(i, 20){
        if(i == 0) {cout << 0 << endl; flush(cout);}
        else{
            cin >> res;
            if(i == 1){
                if(res == "Male") beg = 0;
                else if(res == "Female") beg = 1;
                else return 0;

                cout << N-1 << endl;
                flush(cout);
            }
            else if(i == 2){
                if(res == "Male") end = 0;
                else if(res == "Female") end = 1;
                else return 0;

                mid = N/2;
                cout << mid << endl;
                flush(cout);
            }
            else{
                int cur;
                if(res == "Male") cur = 0;
                else if(res == "Female") cur = 1;
                else return 0;

                //curはmidがMaleかFemaleかを示している
                //mid-lが偶数ならbeg=curであるべき
                bool same_beg_mid;
                if((mid-l) % 2 == 0) same_beg_mid = true;
                else same_beg_mid = false;
                if((same_beg_mid && beg == cur) || (!same_beg_mid && beg != cur)){
                    //前半は正しいとき
                    beg = cur;
                    l = mid;
                }
                else{
                    end = cur;
                    r = mid;
                }
                mid = (l+r) / 2;
                cout << mid << endl;
                flush(cout);
            }
        }
    }
    return 0;
}

void solve(){}

Measured memory_bytes: 852
import sys
input=sys.stdin.readline
N,W=map(int,input().split())
w,v=[0]*N,[0]*N

for i in range(N):
    w[i],v[i]=map(int,input().split())
V=sum(v)
dp=[[float('inf')]*(V+1) for i in range(N+1)] #初期化はfor より *の方が早い

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

for j in range(V+1):
    if dp[N][j]<=W:
        res=j
print(res)
# stdinあり

Measured memory_bytes: 312016
#include<stdio.h>
int main(){
int n,i=1,j,a[100002];
  scanf("%d",&n);
  for(j=1;j<=n;j++)scanf("%d",&a[j]);
  for(j=1;j<=n;j++){
    i=a[i];
    if(i==2){
    printf("%d",j);
      return 0;
    }  
  
  }
  printf("-1");
  return 0;

}

Measured memory_bytes: 512
use proconio::{input, fastout};
use proconio::marker::{Chars};
use proconio::marker::Usize1;
use std::cmp::*;

macro_rules! debug {
      ($($a:expr),*) => {
          eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
      }
  }

#[fastout]
fn main() {
    input!{
        a: usize,
        b: usize,
    }
    if a > b {
        println!("{}", a-1);
    } else {
        println!("{}", a);
    }

}


Measured memory_bytes: 2140
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pii;
typedef pair<double,double> pdd;
#define SQ(i) ((i)*(i))
#define MEM(a, b) memset(a, (b), sizeof(a))
#define SZ(i) int(i.size())
#define FOR(i, j, k, in) for (int i=j ; i<k ; i+=in)
#define RFOR(i, j, k, in) for (int i=j ; i>=k ; i-=in)
#define REP(i, j) FOR(i, 0, j, 1)
#define REP1(i,j) FOR(i, 1, j+1, 1)
#define RREP(i, j) RFOR(i, j, 0, 1)
#define ALL(_a) _a.begin(),_a.end()
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define X first
#define Y second
#ifdef tmd
#define TIME(i) Timer i(#i)
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<" ,";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,deque<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define TIME(i)
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0)
#endif
class Timer {
private:
    string scope_name;
    chrono::high_resolution_clock::time_point start_time;
public:
    Timer (string name) : scope_name(name) {
        start_time = chrono::high_resolution_clock::now();
    }
    ~Timer () {
        auto stop_time = chrono::high_resolution_clock::now();
        auto length = chrono::duration_cast<chrono::microseconds>(stop_time - start_time).count();
        double mlength = double(length) * 0.001;
        debug(scope_name, mlength);
    }
};

const ll MOD = 1000000007;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const int iNF = 0x3f3f3f3f;
const ll MAXN = 100005;

int n, t, a[MAXN], mn = iNF, mx = -iNF, mx_cnt;
/********** Good Luck :) **********/
int main()
{
    TIME(main);
    IOS();

    cin >> n >> t;
    REP (i, n) {
        cin >> a[i];
        int cp = a[i] - mn;
        if (cp > mx) {
            mx = cp;
            mx_cnt = 1;
        } else if (cp == mx) {
            mx_cnt++;
        }

        mn = min(mn, a[i]);
    }

    debug(mx);
    cout << mx_cnt << endl;
    return 0;
}


Measured memory_bytes: 640
class BipartiteMatching:
    def __init__(self, V):
        self.V = V
        self.G = [[] for _ in range(V)]

    def add_edge(self, u, v):
        self.G[u].append(v)
        self.G[v].append(u)

    def dfs(self, u):
        self.used[u] = True
        for v in self.G[u]:
            w = self.match[v]
            if w < 0 or (not self.used[w] and self.dfs(w)):
                self.match[u] = v
                self.match[v] = u
                return True
        return False

    def bipartite_matching(self):
        res = 0
        self.match = [-1] * self.V
        for v in range(self.V):
            if self.match[v] == -1:
                self.used = [False] * self.V
                if self.dfs(v):
                    res += 1
        return res

X, Y, E = map(int, input().split())
bm = BipartiteMatching(X+Y)
for _ in range(E):
    x, y = map(int, input().split())
    bm.add_edge(x, X + y)
print(bm.bipartite_matching())


Measured memory_bytes: 5792
fun main(args: Array<String>) {
    val N = readLine()!!.toInt()
    val A = readLine()!!.split(" ").map(String::toLong).toTypedArray()
    val B = readLine()!!.split(" ").map(String::toLong).toTypedArray()

    val sum = A.sum()
    for (i in B.indices) {
        val hero = B[i]
        val monster = A[i]
        when {
            monster < hero -> {
                A[i + 1] = Math.max(A[i + 1] + A[i] - hero, 0)
                A[i] = 0
            }
            monster == hero -> A[i] = 0
            monster > hero -> A[i] = A[i] - hero
        }
    }
    println(sum - A.sum())
}



Measured memory_bytes: 84920
#pragma GCC optimize("Ofast")   //Comment optimisations for interactive problems (use endl)
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>

using namespace std;

#define  fastio         ios:: sync_with_stdio(0);cin.tie(0);cout.tie(0);cout<<fixed;cout<<setprecision(10);
#define  randomINIT     mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define  foo(i,a,n)     for(ll i = (a); i <= n; i++)
#define  frr(i,a,n)     for(ll i = (a); i >= n; i--)
#define  fo(i,n)        for(ll i = 0; i < n; i++)
#define  all(x)         (x).begin(),(x).end()
#define  mset(x,val)    memset(x,val,sizeof(x))
#define  newl           cout<<"\n"
#define  pb             push_back
#define  mp             make_pair
#define  s              second
#define  f              first
#define  dline          cerr<<"///REACHED///\n";
#define  deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define  deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define  deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';

typedef  long long             ll;
typedef  long double           ld;
typedef  pair<ll,ll>           pll;
typedef  vector<ll>            vll;
typedef  vector<pll>           vpll;

const ll   MOD   =  1e+9+7;
const ll   INF   =  0x7f7f7f7f7f7f7f7f;
const int  INFi  =  0x7f7f7f7f;
const ll   MAXN  =  1e+5+7;

vll adj[MAXN];ll visit[MAXN]={};
int dx8[]={0,1,1,1,0,-1,-1,-1}, dy8[]={1,1,0,-1,-1,-1,0,1};
int dx4[]={0,1,0,-1}, dy4[]={1,0,-1,0};

//<<-----Declare Variable Here------->>//
int t=1;
ll n;
ll a[500];
map<string,ll>map1;
//<<-----Implement Functions Here---->>//


//<<-----Start of Main--------------->>//
void MAIN(){
		cin>>n;map1.clear();
		for(ll i=0;i<n;i++){
			string s;
			cin>>s;map1[s]++;
		}
		cout<<"AC "<<"x "<<map1["AC"]<<endl;
		cout<<"WA "<<"x "<<map1["WA"]<<endl;
		cout<<"TLE "<<"x "<<map1["TLE"]<<endl;
		cout<<"RE "<<"x "<<map1["RE"]<<endl;
}

int main(){
	fastio;randomINIT;

	//cin>>t;
	while(t--){
		MAIN();
	}

    #ifndef ONLINE_JUDGE
    cout<<"\nTime Elapsed: " << 1.0*clock() / CLOCKS_PER_SEC << " sec\n";
    #endif
}

Measured memory_bytes: 6004
#include<stdio.h>
#include<stdlib.h>

int partition(int *,int ,int);

int main() {
  int i,n,r,index;
  int *A;

  scanf("%d",&n);
  A = (int *)malloc(n * sizeof(int ));
  for(i=0 ; i<n ; i++) scanf("%d",&A[i]);

  index = partition(A,0,n-1);

  for(i=0 ; i<n ; i++){
    if(i == index){
      if(i != n-1)printf("[%d] ",A[i]);
      else printf("[%d]\n",A[i]);
    }
    else{
      if(i == n-1)printf("%d\n",A[i]);
      else printf("%d ",A[i]);
    }
  }
  return 0;
}


int partition(int *A,int p,int r){
  int x,i=-1,j,temp;
  x = A[r];

  for(j=p ; j<r ; j++){
    if(A[j]<=x){
      i++;
      temp = A[i];
      A[i]=A[j];
      A[j]=temp;
    }
  }
  temp = A[r];
  A[r] = A[i+1];
  A[i+1] = temp;

  return i+1;
}

Measured memory_bytes: 992
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int main(){
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    while(1){
        c-=b;
        if(c<=0){
            cout<<"Yes"<<endl;
            return 0;
        }
        a-=d;
        if(a<=0){
            cout<<"No"<<endl;
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 3624
addSumInfo :: [[Int]] -> [[Int]]
addSumInfo = addColumnSums . map (\xs -> xs ++ [sum xs]) where
    addColumnSums :: [[Int]] -> [[Int]]
    addColumnSums t = t ++ [[sum [c!!i | c <- t] | i <- [0..length (head t) -1]]]
printTable :: [[Int]] -> IO ()
printTable = mapM_ (putStrLn . unwords . map show)

main = do
    _ <- getLine
    getContents >>= printTable . addSumInfo . map (map read . words) . lines

Measured memory_bytes: 5584
#include <bits/stdc++.h>
#define int llint
#define rep(i, a, n) for(int (i) = (int)(a);(i) < (int)(n);++(i))
#define repe(i, a, n) for(int (i) = (int)(a);(i) <= (int)(n);++(i))
#define repif(i, a, x) for(int (i) = (int)(a);(x);++(i))
#define repr(i, a, n) for(int (i) = ((int)(a)-1);(i) >= (int)(n);--(i))
#define reper(i, a, n) for(int (i) = (int)(a);(i) >= (int)(n);--(i))
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define SIZE(x) ((int)(x).size())
#define ALL(x) (x).begin(), (x).end()
#define RNG(x, a, n) &((x)[a]), &((x)[n])
#define ADD(a, b) ((((a+MOD)%MOD)+((b+MOD)%MOD))%MOD)
#define MUL(a, b) ((((a)%MOD)*((b)%MOD))%MOD)
#define CEIL(x) ((int)ceil(((double)x)))
#define POW(x, y) ((int)pow(x, y))
#define UNIQUE(x) (x).erase(unique(ALL((x))), (x).end())
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define yes cout << "yes" << endl;
#define no cout << "no" << endl;
#define fcout cout << fixed << setprecision(10)
#define pb push_back
#define pf push_front
#define mp make_pair
#define mt make_tuple
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define EPS (1e-20)
#define INF INT_MAX
#define INFLL LLONG_MAX
#define MOD 1000000007
using llint = long long;
using VI = std::vector<int>;
using PII = std::pair<int, int>;
using SI = std::set<int>;
using MII = std::map<int, int>;
using TIII = std::tuple<int, int, int>;
using MCI = std::map<char, int>;
using VPII = std::vector<PII>;
using namespace std;


int H, W, A, B;
int fact[200010], invFact[200010];


void makeFact(){
	int N = 200010;
	fact[0] = 1;
	rep(i, 1, N) fact[i] = MUL(fact[i-1], i);
	int M = MOD-2;
	int pow = fact[N-1];
	invFact[N-1] = 1;
	do {
		if(M&1) invFact[N-1] = MUL(invFact[N-1], pow);
		pow = MUL(pow, pow);
	} while(M>>=1);
	repr(i, N-1, 0) invFact[i] = MUL(invFact[i+1], i+1);
}


int comb(int n, int k){
	if(n < 0 || k < 0 || n < k) return 0;
	return MUL(fact[n], MUL(invFact[k], invFact[n-k]));
}


int solve(){
	int ans = 0;
	rep(i, 0, H-A) ans = ADD(ans, comb(B-1+i, i)*comb(W-B-1+H-i-1, W-B-1));
	return ans;
}


signed main(){
	cin >> H >> W >> A >> B;

	makeFact();

	cout << solve() << endl;

	return 0;
}

Measured memory_bytes: 3328
A, B = list(map(int, input().split()))

flag = False

for a in range(12, 1263):
    if flag:
        break
    for b in range(10, 1001):
        a_tax = int(a * 0.08)
        b_tax = int(b * 0.10)
        if(a_tax == A and b_tax == B and a == b):
            print(a)
            flag = True
            
else:
    print(-1)

Measured memory_bytes: 66500
#include<cstdio>
#include<algorithm>
int main(){
    int N,K;scanf("%d%d",&N,&K);
    int x[N];
    int j;
    int ans=1<<29;
    for(int i=0;i<N;i++){
        scanf("%d",&x[i]);
    }
    for(int i=0;i+K-1<N;i++){
        ans=std::min(ans,x[i+K-1]-x[i]+std::min(abs(x[i+K-1]),abs(x[i])));
    }
    printf("%d",ans);
    return 0;
}


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

int main() {
    int H,W;
    cin >> H >> W;
    char s[H][W];
    for ( int i = 0; i < H; ++i){
        for ( int j = 0; j < W; ++j){
            cin >> s[i][j];
        }
    }
    
    vector<vector<int>> a(H,vector<int>(W,0)), b(H,vector<int>(W,0));
    
    for ( int i = 0; i < H; ++i){
        for ( int j = 0; j < W; ++j){
            if ( s[i][j] == '#' ){
                a.at(i).at(j) = 0;
            } else {
                if ( j-1 >= 0 ) {
                    a.at(i).at(j) = a.at(i).at(j-1) + 1;
                } else {
                    a.at(i).at(j) = 1;
                }
            }
        }
    }
    
    for ( int i = 0; i < H; ++i){
        for ( int j = W-1; j >= 0; --j){
            if ( a.at(i).at(j) != 0 and j != W-1 ){
                if ( s[i][j+1] == '.') {
                    a.at(i).at(j) = a.at(i).at(j+1);
                }
            }
        }
    }
    
    for ( int j = 0; j < W; ++j){
        for ( int i = 0; i < H; ++i){
            if ( s[i][j] == '#' ){
                b.at(i).at(j) = 0;
            } else {
                if ( i-1 >= 0 ) {
                    b.at(i).at(j) = b.at(i-1).at(j) + 1;
                } else {
                    b.at(i).at(j) = 1;
                }
            }
        }
    }
    
    for ( int j = 0; j < W; ++j){
        for ( int i = H-1; i >= 0; --i){
            if ( b.at(i).at(j) != 0 and i != H-1 ){
                if ( s[i+1][j] == '.') {
                    b.at(i).at(j) = b.at(i+1).at(j);
                }
            }
        }
    }
    
    int res = 0;
    for ( int i = 0; i < H; ++i){
        for ( int j = 0; j < W; ++j){
            res = max(res,a.at(i).at(j) + b.at(i).at(j));
        }
    }
    cout << res - 1 << endl;
    
    return 0;
}


Measured memory_bytes: 35584
#include <stdio.h>

int main(int argc, const char * argv[]) {
    // insert code here...
    int N,M;
    while(scanf("%d%d",&N,&M)==2){
        if(N==0 && M==0){
            break;
        }
        else
        {
            int a[110];
            int v[110];
            int sum = 0;
            int max;
            for(int i=0;i<N;i++){
                scanf("%d%d",&a[i],&v[i]);
            }
            for(int j=1;j<=N;j++){
             max = 0;
            for(int i=0;i<N;i++){
                if(a[i] == j && v[i]>max){
                    max = v[i];
                }
            }
                sum += max;
            }
            printf("%d\n",sum);
        }
    }
    return 0;
}



Measured memory_bytes: 2136
#include<stdio.h>
int main ()
{
  int S,h,m,s;
  scanf("%d",&S);
  h = S/3600;
  S = S-(3600*h);
  m = S/60;
  s = S-(60*m);
  printf("%d:%d:%d\n",h,m,s);
  return 0;
}

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

int main() {
  int N , A , B;
  cin >> N >> A >> B;
  
  if ( A*N < B ) {
    cout << A*N << endl;
  }
  else if ( A*N > B ) {
    cout << B << endl;
  }
  else if ( A*N == B ) {
    cout << B << endl;
  }  
}

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

int main() {
  string S;
  cin >> S;
  if (S == "Rainy"){
    cout << "Sunny" << endl;
  }
else if (S== "Cloudy"){
  cout << "Rainy" << endl;
}
else if  (S =="Sunny"){
  cout << "Cloudy" << endl;
}
      }


Measured memory_bytes: 256
a = gets.chomp.split("")
b = gets.chomp.split("")
c = gets.chomp.split("")

turn = "a"
loop do
    next_turn = nil
    case turn
    when "a" then
        next_turn = a.shift
    when "b" then
        next_turn = b.shift
    when "c" then
        next_turn = c.shift
    end
    if next_turn == nil
        puts turn.upcase
        exit
    else
        turn = next_turn
    end
end

Measured memory_bytes: 1788
#include<iostream>
using namespace std;
int n,m,i;
int a[55],b[55],c[55];
int main()
{
	cin>>n>>m;
	for(i=1;i<=m;i++)
	{
		cin>>a[i]>>b[i];
		c[a[i]]++;
		c[b[i]]++;
	}	
	for(i=1;i<=n;i++)
	{
		cout<<c[i]<<endl;
	}
	return 0;
} 

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

int main() {
  int n, h; cin >> n >> h;
  vector<string> vec(n);
  for (int i = 0; i < n; i++) {
    cin >> vec.at(i);
  }
  sort(vec.begin(), vec.end());
  string S;
  for (int i = 0; i < n; i++) {
    S += vec.at(i);
  }
  cout << S << endl;
}



Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
#include<set>
#include<iomanip>
#include<map>
#include<type_traits>
#include<tuple>
using namespace std;


typedef long long ll;
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)

const int mod = 1000000007;

int main(){
    int n;
    int m = INT_MAX;
    cin >> n;

    vector<int> p(n);

    rep(i, n){
        cin >> p[i];
    }

    int ans = 0;

    rep(i, n){
        if(m >= p[i]){
            ans++;
            m = p[i];
        }
    }

    cout << ans << endl;
    
}

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

using namespace std;

#define FOR(i, j, k) for(int i = j; i < k; ++i)
#define rep(i, j) FOR(i, 0, j)
#define FORr(i, j, k) for(int i = j; i >= k; --i)
#define repr(i, j) FOR(i, j, 0)
#define INF (1 << 30)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> Pi;

const int MOD = 1e9 + 7;
const int dy[]={0, 0, 1, -1};
const int dx[]={1, -1, 0, 0};

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

int main() {
	int x, a, b;
	scanf("%d %d %d", &x, &a, &b);
	(abs(x - a) > abs(x - b)) ? printf("B\n") : printf("A\n");
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <vector>
#include <assert.h>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <math.h>
#include <string>
#include <string.h>
#include <queue>
#include <complex>
#include <iomanip>
#include <stack>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
ll mod=1e9+7;
double eps=1e-7;
ll exp(ll x,ll y){if(y<0) return 0; ll ret=1;for(;y;y>>=1,x=(x*x)%mod){if(y&1)ret=(ret*x)%mod;}return ret;}
ull pexp(ull x,ull y){if(y<0) return 0; ull ret=1; for(;y;y>>=1,x=(x*x)){if(y&1)ret=(ret*x);}return ret;}
ll gcd(ll x,ll y){if(!x||!y) return x+y; return x%y==0?y:gcd(y,x%y);}
ll lcm(ll x,ll y){return x*(y/gcd(x,y));}
ll bsum(ll u,ll b){ll ret=0;if(u<b)return u;while(u){ret+=u%b;u/=b;}return ret;}
ll prival(ll u,ll p){ll cn=0;while(u%p==0){cn++;u=u/p;}return cn;}
ll minv(ll a,ll b){return 1<a?b-minv(b%a,a)*b/a:1;}
ll extm(ll a,ll b){ll ret=0;while(a!=0){if(a%2==1){ret+=b;ret%=mod;}a>>=1;b=(2*b)%mod;}return ret;}   
ll eaphi(ll x){ll t=x,ret=x,i;for(i=2;i*i<=x;i++){if(t%i==0){ret-=ret/i;while(t%i==0) t/=i;}}if(t!=1) ret-=ret/t;return ret;}
ll eadivc(ll x){ll ret=0;ll i;for(i=1;i*i<=x;i++){if(x%i==0 && i*i!=x) ret+=2;if(x%i==0 && i*i==x) ret+=1;}return ret;}
ll eadivs(ll x){ll ret=0;ll i;for(i=1;i*i<=x;i++){if(x%i==0 && i*i!=x) ret+=i+x/i;if(x%i==0 && i*i==x) ret+=i;}return ret;}
ll ndig(ll x, ll b){ll ret=0;while(x){x/=b; ret++;}return ret;}
ll rev(ll n, ll b){ll ret=0;while(n){ret=b*ret+n%b; n/=b;}return ret;}
ll sq(ll x){ll t=(ll)sqrt(x); for(ll i=t-2 ; i<=t+2 ; i++) if(i*i==x) return abs(i); return -1;}
ll extexp(ll x,ll y){if(y<0) return 0; ll ret=1;for(;y;y>>=1,x=extm(x,x)){if(y&1)ret=extm(ret,x);}return ret;}
bool isprime(ll x){if(x<=1) return false; for(ll i=2;i*i<=x;i++){if(x%i==0){return false;}}return true;}
ll a, b, c, x, y, ans=1e18;

int main(void)
{
	cin>>a>>b>>c>>x>>y; ll i;
	for(i=0 ; i<=222222 ; i+=2)
	{
		ll x_need=max(x-i/2,0LL);
		ll y_need=max(y-i/2,0LL);
		ans=min(ans,x_need*a+y_need*b+i*c);
	}
	cout<<ans; return 0;
}

// ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);

Measured memory_bytes: 256
'''
C - AB Substrings
'''

str_list = []
ab_num = 0
c1 = 0
c2 = 0
c3 = 0
for i in range(int(input())):
    str_list.append(input())
    ab_num += str_list[-1].count('AB')
    if str_list[-1].endswith('A') and str_list[-1].startswith('B'):
        c1 += 1
    elif str_list[-1].startswith('B'):
        c2 += 1
    elif str_list[-1].endswith('A'):
        c3 += 1

if c1 == 0:
    print(ab_num + min(c2, c3))
elif c2 + c3 == 0:
    print(ab_num + c1 - 1)
else:
    print(ab_num + c1 + min(c2, c3))


Measured memory_bytes: 3700
#include <iostream>
using namespace std;
int main(void){
  int H,W,i,j,n;
  cin >> H;
  cin >> W;
 
  while(H != 0 && W != 0){
      for(i = 0; i < H; i++){
          for(j = 0; j < W; j++){
              if((i + j) % 2 == 0){
                  cout << "#";
              }
              else{
                  cout << ".";
              }
          }
          cout << endl;
      }
      cin >> H;
      cin >> W;
      cout << endl;
  }
}


Measured memory_bytes: 3096
#include<stdio.h>
int main(){
	int K,N;
	int A[3];
	int Max=0;
	scanf("%d",&K);
	scanf("%d",&N);
	scanf("%d",&A[0]);
	A[2]=A[0];
	for(int i=0;i<N-1;i++){
		scanf("%d",&A[1]);
		if(A[1]-A[2]>Max){
			Max=A[1]-A[2];
		}
		A[2]=A[1];
	}
	if((K-A[1])+A[0]>Max)Max=(K-A[1])+A[0];
	printf("%d",K-Max);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main ()
{
	int n,m,c,ans=0,tot=0;
	cin>>n>>m>>c;
	int b[m];
	int a[n][m];
	for (int i=0; i<m; i++)
	{
		cin>>b[i];
	}
	for (int i=0; i<n; i++)
	{
		for (int j=0; j<m; j++)
		{
			cin>>a[i][j];
		}
	}
	for (int i=0; i<n; i++)
	{
		for (int j=0; j<m; j++)
		{
			tot+=b[j]*a[i][j];
		}
		tot+=c;
		if (tot>0)
		{
			ans++;
		}
		tot=0;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
//clock_t start=clock();clock_t end=clock();cout<<(double)(end-start)/CLOCKS_PER_SEC<<endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef pair<pii,pii> pippi;
typedef tuple<ll,ll,ll> tl;
typedef pair<double,double> pdd;
typedef vector<vector<ll>> mat;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll mod5=1000000009;
ll inf=1LL<<62;
int iinf=1<<30;
double pi=3.141592653589793238462643383279L;
double eps=1e-8;
#define rep(i,m,n) for(ll i=m;i<n;i++)
#define rrep(i,n,m) for(ll i=n;i>=m;i--)
#define srep(itr,st) for(auto itr=st.begin();itr!=st.end();itr++)
#define mrep(itr,mp) for(auto& itr:mp)
#define Max(a,b) a=max(a,b)
#define Min(a,b) a=min(a,b)
//#define endl "\n"
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
#define umh unordered_map<int,int,custom_hash>
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll lcm(ll a,ll b){
    ll c=gcd(a,b);
    return a*b/c;
}
ll Pow(ll n,ll k){
    if(k<0)return 0;
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}
ll beki(ll n,ll k,ll md){
  ll ret=1;
  ll now=n;
    now%=md;
  while(k>0){
    if(k%2==1){
      ret*=now;
      ret%=md;
    }
    now*=now;
    now%=md;
    k/=2;
  }
  return ret;
}
ll gyaku(ll n,ll md){
  return beki(n,md-2,md);
}
ll popcount(ll n){
    ll ret=0;
    ll u=n;
    while(u>0){
        ret+=u%2;
        u/=2;
        
    }
    return ret;
}

int main(){
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    map<string,int> mp;
    mp["AC"]=1;
    mp["WA"]=2;
    mp["TLE"]=3;
    mp["RE"]=4;
    int cnt[5];
    fill(cnt,cnt+5,0);
    int n;cin>>n;
    rep(i,0,n){
        string s;cin>>s;
        cnt[mp[s]]++;
    }
    string t[4]={"AC","WA","TLE","RE"};
    rep(i,0,4){
        cout<<t[i]<<" "<<"x"<<" "<<cnt[i+1]<<endl;
    }
}


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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < n; i++)
#define rep1(i, n) for (int i = 1; i < n + 1; i++)
#define repr(i, n) for (int i = n - 1; i >= 0; i--)
#define repr1(i, n) for (int i = n; i > 0; i--)
#define FOR(i, j, n) for (int i = j; i < n; i++)

int main()
{
    int64_t n;
    cin >> n;

    int64_t sum = 0;
    rep1(i, n)
    {
        if (i % 3 == 0 || i % 5 == 0)
        {
            continue;
        }
        else
        {
            sum += i;
        }
    }
    cout << sum << endl;
}

Measured memory_bytes: 3644
#include <stdio.h>

typedef struct{
  char M;
  int value;
}tc;

void BubbleSort(tc*, int);
void SelectionSort(tc*, int);
void isStable(tc*, tc*, int);

int main(){

  int i,j,n;
  tc g[36],s[36];

  scanf("%d",&n);

  for(i=0; i<n; i++){
    scanf(" %c%d",&g[i].M, &g[i].value); 
    s[i] = g[i]; 
  }

  BubbleSort(g,n);
  SelectionSort(s,n);

  return 0;
}

void BubbleSort(tc* g,int n){
  int i,j;
  tc temp;
  tc in[n];

  for(i=0; i<n; i++){
    in[i] = g[i]; 
  }
  
  for(i = 0; i <= n-1; i++){
    for(j = n-1; j >= i+1; j--){
      if(g[j].value < g[j-1].value){
	temp = g[j];
	g[j] = g[j-1];
	g[j-1] = temp;
      }
    }
  }

  for(i=0; i<n; i++){
    printf("%c%d",g[i].M,g[i].value);
    if(i!=n-1){
      printf(" ");
    }
  }
  printf("\n");
  isStable(in,g,n);
}

void SelectionSort(tc* s,int n){

  int i,j,minj;
  tc temp;
  tc in[n];

  for(i=0; i<n; i++){
    in[i] = s[i]; 
  }

  for(i = 0; i<= n-1; i++){
    minj = i;
    for(j = i;j <= n-1; j++){
      if(s[j].value < s[minj].value){
	minj = j;
      }
    }
    temp = s[i];
    s[i] =  s[minj];
    s[minj] = temp;
  }

  for(i=0; i<n; i++){
    printf("%c%d",s[i].M,s[i].value);
    if(i!=n-1){
      printf(" ");
    }
  }
  printf("\n");
  isStable(in,s,n);
}

void isStable(tc* in,tc* out,int n){

  int i,j,a,b,flag=1;

  for(i=0; i<n-1; i++){
    for(j= i+1; j<n-1;j++){
      for(a=0; a<n-1; a++){
	for(b=a+1; b<n-1; b++){
	  if(in[i].value==in[j].value&&in[i].value==out[b].value&&in[j].value==out[a].value&&in[i].M==out[b].M&&in[j].M==out[a].M){
	    flag = 0;
	  }
	}
      }   
    }
  }
  if(flag==1){
    printf("Stable\n");
  }
  else{
    printf("Not stable\n");
  }
}

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

int main(void) {
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  vector<int> A(N);
  rep(i, N) { cin >> A[i]; }

  const int64_t mod = 1e9 + 7;
  int64_t answer = 1;
  int hats[3] = {0, 0, 0};
  rep(i, N) {
    int idx = 0;
    int cases = 0;
    rep(j, 3) {
      if (A[i] == hats[j]) {
        idx = j;
        cases++;
      }
    }
    answer = (answer * cases) % mod;
    hats[idx]++;
  }
  cout << answer << endl;
  return 0;
}


Measured memory_bytes: 640
N = int(input())
H = list(map(int,input().split()))

dp = [0] * (N + 1)
dp[1] = abs(H[1] - H[0])
for i in range(2,N):
    dp[i] = min(abs(H[i] - H[i - 1]) + dp[i - 1],
                abs(H[i] - H[i - 2]) + dp[i - 2])

print(dp[N - 1])


Measured memory_bytes: 52208
#include <bits/stdc++.h>
using namespace std;
typedef long long llong;
#define MAX 200000

int Partition(vector<int>& vec_A, int p, int r)
{
    int x = vec_A[r];
    int i = p - 1;
    int tmp = 0;
    for (int j = p; j < r; j++)
    {
        if (vec_A[j] <= x) {
            i++;
            tmp = vec_A[i];
            vec_A[i] = vec_A[j];
            vec_A[j] = tmp;
        }
    }
    tmp = vec_A[i+1];
    vec_A[i+1] = vec_A[r];
    vec_A[r] = tmp;
    return i+1;
}

int main() {
    vector<int> vec;
    vec.reserve(MAX);
    int n = 0;
    int m = 0;
    scanf("%d",&n);

    for (int i = 0; i < n; i++)
    {
        scanf("%d",&m);
        vec.push_back(m);
    }

    int idx = 0;
    idx = Partition(vec, 0, n-1);

    for (int i = 0; i < n; i++)
    {
        if (i == n - 1)
        {
            printf("%d\n", vec[i]);
        } else if (i == idx) {
            printf("[%d] ", vec[i]);
        }
        else
        {
            printf("%d ", vec[i]);
        }
    }
}


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

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    long long int N, K;
    cin >> N >> K;
    vector<long long int> A(N);
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
    }
    vector<vector<long long int>> dp(100, vector<long long int>(2, -1));
    dp[55][0] = 0;
    bool check = false;

    for (int i = 55; i >= 0; --i) {
        long long int digit = (1LL << i);
        int flag = 0;
        for (int j = 0; j < N; ++j) {
            if (A[j] & digit) ++flag;
        }

        long long int costZero = digit * flag;
        long long int costOne = digit * (N - flag);

        if (dp[i + 1][1] != -1) {
            dp[i][1] = dp[i + 1][1] + max(costZero, costOne);
        }

        if (dp[i + 1][0] != -1) {
            // 1のときだけ。0のときは[i][0]で遷移してるので必要ない
            if (K & digit) dp[i][1] = max(dp[i][1], dp[i + 1][0] + costZero);
        }

        if (dp[i + 1][0] != -1) {
            if (K & digit) dp[i][0] = dp[i + 1][0] + costOne;
            else dp[i][0] = dp[i + 1][0] + costZero;
        }

        // cout << i << " " << dp[i][1] << " " << dp[i][0] << endl;
    }
    cout << max(dp[0][0], dp[0][1]) << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define NO  puts("-1"),exit(0)
using namespace std;

const int N=100010;
int n,m,a[N],b[N],c[2*N],ufs[2*N],ans;
map <int,int> M;

int find(int x){return ufs[x]==x?x:ufs[x]=find(ufs[x]);}

void work()
{
	scanf("%d",&n);
	for (int i=1; i<=n; i++)  scanf("%d",&a[i]),a[0]^=a[i];
	for (int i=1; i<=n; i++)  scanf("%d",&b[i]),b[0]^=b[i];
	for (int i=0; i<=n; i++)
		if (a[i]!=b[i])
			M[a[i]]++,M[b[i]]--,c[++m]=a[i],c[++m]=b[i];
	for (map <int,int> ::iterator x=M.begin(); x!=M.end(); x++)
		if ((*x).second)  NO;
	sort(c+1,c+m+1),m=unique(c+1,c+m+1)-c-1;
	for (int i=1; i<=n; i++)  a[i]=lower_bound(c+1,c+m+1,a[i])-c;
	for (int i=1; i<=n; i++)  b[i]=lower_bound(c+1,c+m+1,b[i])-c;
	ans=m;
	for (int i=1; i<=m; i++)  ufs[i]=i;
	for (int i=1; i<=n; i++)
		if (a[i]!=b[i])
			{
				if (find(a[i])!=find(b[i]))  ufs[find(a[i])]=find(b[i]);
				else  ans++;
			}
	for (int i=1; i<=m; i++)  if (c[i]==a[0])  ans--;
	printf("%d",ans);
}

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


Measured memory_bytes: 8448
#include<iostream>
#define _USE_MATH_DEFINES
#include<math.h>
#include<vector>
#include<array>
#include<algorithm>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<set>
#include<cstdio>
#include<cstring>
#include<string>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vec;
typedef vector<vector<ll>> mat;
typedef pair<ll,ll> P;
typedef map<ll,ll> MP;
typedef priority_queue<ll> PQ;
typedef stack<ll> ST;
typedef queue<ll> QUE;
#define pb push_back
#define st first
#define nd second
#define SZ(x) ((int)(x).size())
#define FOR(i,s,n) for(int i=(int)(s); i< (int)(n); i++)
#define rep(i,n) FOR(i,0,n)
#define all(x) (x).begin(),(x).end()
#define each(x,c) for(auto x: (c))
#define LB(x,a) lower_bound(all(x), a)
#define UB(x,a) upper_bound(all(x), a)
const ll mod=1e9+7;
const ll INF=1e18;
const double EPS=1.0e-10;
const double PI=M_PI;

int main(){
    ll K; cin>>K;
    int N; cin>>N;
    vec A(N+1);
    rep(i,N) cin>>A[i];
    A[N]=K+A[0];
    ll res=0;
    rep(i,N){
        res=max(res,A[i+1]-A[i]);
    }
    cout<<K-res<<endl;
    return 0;
}

Measured memory_bytes: 1792
// https://atcoder.jp/contests/abc072/tasks/abc072_b

#include <bits/stdc++.h>
#define REP(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define REPR(i, n) for (int(i) = (n); (i) >= 0; (i)--)
#define FOR(i, m, n) for (int(i) = (m); (i) < (n); i++)
#define INF 1e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;

int main()
{
  /* Magic word */
  // cin.tie(0);
  // ios::sync_with_stdio(false);
  /* ---------- */

  string s, r = "";

  cin >> s;

  int len = s.length();
  REP(i, len)
  {
    if (i % 2 == 0)
      r += s[i];
  }

  cout << r << '\n';

  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
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; }


#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ for(auto it : P) { s << "<" << it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ for(auto it : P) { s << "<" << it.first << "->" << it.second << "> "; } return s << endl; }






int M, D;

int main() {
    while (cin >> M >> D) {
        int res = 0;
        for (int m = 1; m <= M; ++m) {
            for (int d = 22; d <= D; ++d) {
                int a = d / 10;
                int b = d % 10;
                if (a >= 2 && b >= 2 && a * b == m) ++res;
            }
        }
        cout << res << endl;
    }
}


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

int main(void)
{
    string s, a, b;
    int ch, ans = 0;
    cin >> s;
    
    ch = s.size() % 2;
    a = s.substr(0, s.size() / 2);
    b = s.substr(s.size() / 2 + ch);
    
    reverse(b.begin(), b.end());
    for (int i = 0; i < a.size(); i++) if (a[i] != b[i]) ans++;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>

int main(int argc, char **argv) {
    int a, b;
    std::cin >> a >> b;
    if ((b-1) % (a-1)) {
        std::cout << (b-1)/(a-1) + 1 << std::endl;
    }else {
        std::cout << (b-1)/(a-1) << std::endl;
    }
}

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

#define LL long long

char st[10];

bool fuck(LL x) {
	printf("? %lld\n", x);
	fflush(stdout);
	scanf("%s", st);
	return st[0] == 'Y';
}

int main() {
	int l = 0, r;
	bool flag = 1;
	for (int i=1; i<=1e9; i*=10) {
		if (!fuck(i)) {
			flag = 0;
			if (l == 0) l = i / 10;
		}
	}

	if (flag) {
		for (int i=1; i<=1e9; i*=10) {
			if (fuck(i*10LL-1)) {
				printf("! %d\n", i);
				fflush(stdout);
				return 0;
			}
		}
	}

	r = l * 10 - 1;
	l = l + 1;
	// printf("%d %d", l, r);
	while (l < r) {
		int mid = (l + r) / 2;
		if (fuck(mid * 10LL + 1)) r = mid;
		else l = mid + 1;
	}

	printf("! %d\n", r);
	fflush(stdout);

	return 0;
}

Measured memory_bytes: 648
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll MOD = (1e+9)+7;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-11;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
typedef pair<P, int> PP;
char red[500][500], blue[500][500];
int main() {
	rep(i, 500) {
		rep(j, 500) {
			red[i][j] = blue[i][j] = '.';
		}
	}
	int h, w; cin >> h >> w;
	rep(i, h) {
		string s; cin >> s;
		rep(j, w) {
			if (s[j] == '#')red[i][j] = blue[i][j] = '#';
			if (j == 0 || j == w - 1 || i == 0 || i == h - 1)blue[i][j] = '#';
			if (i % 2 == 0 && j != 1)blue[i][j] = '#';
			if (j != 0 && j != w - 1 && i!=0&&i!=h-1&&(j == 1 || i % 2))red[i][j] = '#';
		}
	}
	rep(i, h) {
		rep(j, w) {
			cout << red[i][j];
		}
		cout << endl;
	}
	cout << endl;
	rep(i, h) {
		rep(j, w) {
			cout << blue[i][j];
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 1280
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("3 5");
            //0
        }
        else if (InputPattern == "Input2") {
            WillReturn.Add("7 5");
            //10
        }
        else if (InputPattern == "Input3") {
            WillReturn.Add("6 6");
            //10
        }
        else {
            string wkStr;
            while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
        }
        return WillReturn;
    }

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

        int[] wkArr = InputList[0].Split(' ').Select(pX => int.Parse(pX)).ToArray();
        int X = wkArr[0];
        int A = wkArr[1];

        if (X < A) {
            Console.WriteLine(0);
        }
        else {
            Console.WriteLine(10);
        }
    }
}


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

int main(){
    int x,n,ans=-1;
    cin >> x >> n;
    int aa;
    //int min1 = 101,min2=101;
    vector<bool> a(102,true);
    rep(i,n){
        cin >> aa;
        a[aa]=false;
    }
    //sort(a.begin(),a.end());
    for(int i=0;i<=101;i++){
        if(a[i]){
            if(abs(x-i)<abs(x-ans)){
                ans=i;
            }
            /*
            for(int i=0;i<=100;i++){
                if(x-i==min1 and min1!=0 and min1>0){
                    min1=x-i;
                }
                if(i-x==min2 and min2!=0 and min2>0){
                    min2=i-x;
                }
                if(min1==min2) ans=min1;
                else if(min1>min2)ans=min2;
                else ans=min1;

            }*/
        }//else ans=x;
    }
    cout << ans << endl;
    /*
    rep(i,100){
        rep(j,n){
            if(min > x-i and x-i >0){
                min=x-i;
                if(min==a[i]){
                    ans=temp;}
                    ans=i;
                temp=ans;
                
            }
        }
    }
    cout << ans << endl;*/
}

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

int gcd(int x, int y){
  if(y == 0){
    return x;
  }
  return gcd(y,x%y);
}

int main(){
  int n;
  cin >> n;
  
  int a[n];
  for(int i = 0; i < n; ++i){
    cin >> a[i];
  }
  
  int res = a[0];
  for(int i = 0; i < n; ++i){
    res = gcd(res,a[i]);
  }
  
  cout << res << endl;
}

Measured memory_bytes: 3964
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double llf;
#define ft first
#define sd second
const int N=2000+5;
int a[N];
bitset<2000005> f;
int main(){
	int n;
	scanf("%d",&n);
	f[0]=1;
	int s=0;
	for(int i=1,a;i<=n;++i){
		scanf("%d",&a);
		s+=a;
		f|=f<<a;
	}
	for(int i=s>>1;i>=0;--i)
		if(f[i]){
			printf("%d\n",s-i);
			return 0;
		}
}

Measured memory_bytes: 1024
from collections import deque

H, W = map(int, input().split())
grid = [input() for _ in range(H)]

offsets = [(1, 0), (-1, 0), (0, 1), (0, -1)]
graph = [[float('inf')] * W for _ in range(H)]
deq = deque()

for i in range(H):
    for j in range(W):
        if grid[i][j] == '#':
            graph[i][j] = 0
            deq.append((i, j))

while deq:
    x, y = deq.popleft()
        
    for i, j in offsets:
        if (not 0 <= x + i < H) or (not 0 <= y + j < W):
            continue

        if graph[x + i][y + j] < float('inf'):
            continue

        if grid[x + i][y + j] == '#':
            continue
            
        graph[x + i][y + j] = graph[x][y] + 1
        deq.append((x + i, y + j))
        
print(max(max(v) for v in graph))

Measured memory_bytes: 120672