akhauriyash/Code-Regression huggingface dataset:
n = int(input())
H = list(map(int,input().split()))
seq = []
K = []
ans = 0
for i in H:
    if i != 0:
        K.append(i)
    else:
        if K:
            seq.append(K)
            K = []
else:
    if K:
        seq.append(K)
while seq:
    L = seq.pop()
    ans += min(L)
    S = [n-min(L) for n in L]
    K = []
    for i in S:
        if i!= 0:
            K.append(i)
        else:
            if K:
                seq.append(K)
                K = []
    else:
        if K:
            seq.append(K)
else:
    print(ans)
    

Measured memory_bytes: 3064
import { readFileSync } from "fs";

const read = () =>
  readFileSync(0, "utf8")
    .split("\n")
    .map((line) => line.split(" "));

const main = (input: string[][]) => {
  const [, K] = input[0].map(Number);
  const P = input[1].map(Number);

  return P.sort((a, b) => a - b)
    .slice(0, K)
    .reduce((sum, p) => sum + p);
};

console.log(main(read()));


Measured memory_bytes: 29752
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#pragma warning(disable:4996)
using namespace std;

int main()
{
	int d;
	cin >> d;
	if (d == 25)
		printf("Christmas");
	else if (d == 24)
		printf("Christmas Eve");
	else if (d == 23)
		printf("Christmas Eve Eve");
	else if (d == 22)
		printf("Christmas Eve Eve Eve");
}

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

int main(){
	int i,j,h,num,len;
	char word[402],tmp1[201],tmp[201];
	
	while(1){
		scanf("%s",word);
		if(strcmp(word,"-") == 0)  break;
		len = strlen(word);
		scanf("%d",&num);
		for(i=0;i<num;i++){
			scanf("%d",&h);
			for(j=0;j<h;j++) word[len+j] = word[j];
			for(j=0;j<len;j++) word[j] = word[j+h];
			word[len] = '\0';
		}
		printf("%s\n",word);
	}
	return 0;
}

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

#define LL long long

#define FOR(INDEX, START, END) for (int INDEX = (START); INDEX < (END); ++INDEX)
#define REP(INDEX, COUNT) for (int INDEX = 0; INDEX < (COUNT); ++INDEX)

int main()
{
	int x, y, z;
	cin >> x >> y >> z;

	if (x == y) {
		cout << z << endl;
	}
	else if (x == z) {
		cout << y << endl;
	}
	else {
		cout << x << endl;
	}

	return 0;
}


Measured memory_bytes: 256
// Stable Sort
#include <stdio.h>
#include <stdlib.h>

#define MAX 36

typedef struct{
  char suit;
  int value;
}card;

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

int main(){
  int i, n;
  card StableA[MAX], NonStableA[MAX];

  scanf("%d", &n);
  for(i=0; i < n; i++){
    scanf(" %c%d", &StableA[i].suit, &StableA[i].value);
    NonStableA[i].suit = StableA[i].suit;
    NonStableA[i].value = StableA[i].value;
  }
  BubbleSort(StableA, n); // バブルソートを実行
  SelectionSort(NonStableA, n); // 選択ソートを実行
  
  for(i=0; i < n; i++){
    if(i)printf(" ");
    printf("%c%d", StableA[i].suit, StableA[i].value);
  }
  printf("\nStable\n"); // バブルソートは安定なソート
  
  for(i=0; i < n; i++){
    if(i)printf(" ");
    printf("%c%d", NonStableA[i].suit, NonStableA[i].value);
  }
  // 安定なソートであるバブルソートから実行した選択ソートが安定であったかどうかを判定
  if(isStable(StableA, NonStableA, n))printf("\nStable\n");
  else printf("\nNot stable\n");
  
  return 0;
}

void BubbleSort(card *A, int n){
  int i, flag;
  card swp;
  flag = 1; // 逆の隣接要素が存在する
  while(flag){
    flag = 0;
    for(i=n-1; i > 0; i--){
      if(A[i].value < A[i-1].value){ // A[i]とA[i-1]を交換する
      swp = A[i];  A[i] = A[i-1];  A[i-1] = swp;
      flag = 1;
      }
    }
  }
}

void SelectionSort(card *A, int n){
  int i, j, min;
  card swp;
  for(i=0; i < n; i++){
    min = i;
    for(j=i; j < n; j++){
      if(A[j].value < A[min].value)min = j;
    }
    swp = A[i];  A[i] =A[min];  A[min] = swp;
  }
}

// ソートの結果が安定であったか調べる(A、Bの少なくともどちらか１つは安定なソートであることが前提)
int isStable(card *A, card *B, int n){
  int i;
  for(i=0; i < n; i++){
    if(A[i].suit != B[i].suit)return 0;
  }
  return 1;
}


Measured memory_bytes: 2104
#include <iostream>
#include <fstream>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <unordered_set>
#include <bitset>
#include <limits>
#include <algorithm>

int MOD_BIG = 1000000007;
int MOD_BIG2 = 998244353;
using std::string;
using std::cin;
using std::cout;
using std::cerr;
using std::endl;
using ll = long long;
using pint = std::pair<int, int>;
using pll = std::pair<ll, ll>;
using std::vector;

#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)

//////////////////////////////////////

//////////////////////////////////////

int main() {
    
    ll N;
    cin >> N;
    int i = 1;
    int r = 26;
    ll ri = 26;
    while ((ri*r - r) < N * (r - 1)) {
        ri *= r;
        i++;
    }
    ll num = N - (ri - r) / (r - 1) - 1;
    //cerr << i << ", " << num << endl;
    vector<char> ans(i);
    IREP(j, i) {
        ans[j] = num%r;
        num /= r;
    }
    REP(j, i) {
        cout << char('a'+ans[j]);
    }
    cout << endl;
    
    return 0;
}


Measured memory_bytes: 3624
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

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

const int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

// -------------------------------------------------------

int N;
ll K;

int main()
{
    cin >> N >> K;
    vector<ll> A(N);
    rep(i, 0, N)
    {
        cin >> A[i];
    }

    ll res = 0;
    for (int d = 60; d >= -1; d--)
    {
        if (d != -1 && !(K & (1LL << d)))
            continue;

        ll tmp = 0;
        for (int e = 60; e >= 0; e--)
        {
            ll mask = 1LL << e;
            int num = 0;
            for (auto elem : A)
                if (elem & mask)
                    num++;

            if (e > d)
            {
                if (K & mask)
                {
                    tmp += mask * (N - num);
                }
                else
                {
                    tmp += mask * num;
                }
            }
            else if (e == d)
            {
                tmp += mask * num;
            }
            else
            {
                tmp += mask * max(num, N - num);
            }
        }
        chmax(res, tmp);
    }
    cout << res << endl;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define REP(i, n) for(int i=0; i<(n); ++i)
#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 DEBUG(x) cout<<#x<<": "<<(x)<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

template<typename T> inline void CHMAX(T& a, const T b) {if(a<b) a=b;}
template<typename T> inline void CHMIN(T& a, const T b) {if(a>b) a=b;}

constexpr ll MOD=1000000007ll;
// constexpr ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	// cout<<setprecision(10)<<fixed;
	int n;
	string w[110];
	cin>>n;
	REP(i, n){
		cin>>w[i];
	}
	bool ok=true;
	REP(i, n-1){
		if(w[i][w[i].size()-1]!=w[i+1][0]){
			ok=false;
		}
	}
	sort(w, w+n);
	REP(i, n-1){
		if(w[i]==w[i+1]){
			ok=false;
		}
	}
	cout<<(ok ? "Yes" : "No")<<'\n';
	return 0;
}


Measured memory_bytes: 256
a,b,c=map(int,input().split())
while a!=-1 or b!=-1 or c!=-1:
    if a==-1 or b==-1:
        print('F')
    else:
        if a+b>=80:
            print('A')
        elif 80>a+b>=65:
            print('B')
        elif 65>a+b>=50:
            print('C')
        elif 50>a+b>=30:
            if c>=50:
                print('C')
            else:
                print('D')
        else:
            print('F')
    a,b,c=map(int,input().split())


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

int main() {
  double D;
  int T,S;
  cin >> D>>T>>S;

  if (D/S<=T) {
    cout << "Yes" << endl;
  }
  else if (D/S>T) {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3720
#include <stdio.h>
#include <stdlib.h>
int compare_int(const void *a, const void *b){
    return *(int*)a - *(int*)b;
}
int main(){
    int n,m,k,a[200001]={0},kind=0,cnt=0;
    scanf("%d%d",&n,&k);
    for(int i=0; i<n; i++){
        scanf("%d",&m);
        if(!a[m]){ kind++; }
        a[m]++;
    }
    if( kind <= k ){ printf("0\n"); return 0; }

    qsort( a, 200001, sizeof(int), compare_int );
    for(int i=0; i<200000; i++){
        if( a[i] ){ cnt+=a[i]; kind--; }
        if( kind <= k ){ break; }
    }
    printf("%d\n",cnt);
    return 0;
}

Measured memory_bytes: 3084
//BUGSBUNNY
//IIT ROORKEE
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace std; 
using namespace __gnu_pbds;
#define int long long
#define ll long long
#define double long double
#define ld long double
#define endl '\n'
#define vi vector<int>
#define vvi vector<vi>
#define vs vector<string>
#define vl vector<long long>
#define vpii vector<pii>
#define vpipii vector<pipii>
#define vb vector<bool>
#define pb push_back
#define pob pop_back
#define mp make_pair
#define pii pair<int,int>
#define pipii pair<int,pii>
#define piipi pair<pii,int>
#define pld pair<long double,long double>
#define mod 1000000007 
// #define mod 998244353
#define rep(i,n) for (ll i = 0; i < n; i++)
#define repp(i,a,b) for(ll i = a ; i<b ; i++)
#define reppr(i,a,b) for(ll i = a-1 ; i>=b ; i--)
#define repr(i,n) for (ll i = n - 1; i >= 0; i--)
#define ff first
#define ss second
#define pc putchar_unlocked
#define gc getchar_unlocked
#define inf 9223372036854775807
#define infn -9223372036854775807
#define pi 3.14159265358979323846
#define eps 0.0000000001
#define sp << " " <<
#define setprec(x) cout << fixed << setprecision(x);
#define REVERSE(a) reverse(all(a));
#define SORT(a) sort(all(a));
#define all(n) n.begin(),n.end()


int dp[2001][2001],n; 
int vis[2001][2001];
vpii a(2001);

int hehe(int l , int r , int ind)
{
    if(ind<0) return 0;
    if(vis[ind][l]==1) return dp[ind][l];
    vis[ind][l] = 1;
    int left = abs(a[ind].ss - l) , right = abs(r - a[ind].ss);
    dp[ind][l] = max( left*a[ind].ff + hehe(l+1,r,ind-1) , right*a[ind].ff + hehe(l,r-1,ind-1) );
    return (dp[ind][l]);        
}

void solve();

signed main()
{
    //-------------------------------------------------------------------------------   
        ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
        clock_t clk = clock();
        
    //-------------------------------------------------------------------------------   
    


    //-------------------------------------------------------------------------------
        int t = 1 , codejam = 0;
        // cin >> t;    
        rep(i,t)
        {
            // cout << "Case #" << i+1 << ": ";
            solve();
        }
    //-------------------------------------------------------------------------------
        clk = clock() - clk;
        cerr << fixed << setprecision(12) << "Time: " << ((double)clk)/CLOCKS_PER_SEC;
    //-------------------------------------------------------------------------------
}

void solve()
{
    cin >> n;
    a.resize(n);
    rep(i,n)
        cin >> a[i].ff , a[i].ss = i;
    SORT(a);
    cout << hehe(0,n-1,n-1)<<endl;
}

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

using namespace std;

int main()
{
    int n; cin >> n;
    queue<int> q;
    vector<int> v;
    for(int i =0;i < n; i++)
    {
       int x; cin >> x ;
       v.push_back(x);
    }
    long long sum = 0;
    sort(v.begin(), v.end());
    q.push(v[n-1]);
    for(int i = n-2; i >= 0; i--)
    {
       sum += q.front();
       q.pop();
       q.push(v[i]);
       q.push(v[i]);
    }
    cout << sum;

}


Measured memory_bytes: 4852
# coding: utf-8
def solve(sides):
    ans = [0, 0, 0, 0]

    for a, b, c in sides:
        # is_triangle
        if a + b > c and b + c > a and c + a > b:
            ans[0] += 1
            # right-angled
            if c ** 2 == a ** 2 + b ** 2:
                ans[1] += 1
            # Obtuse
            elif c ** 2 < a ** 2 + b ** 2:
                ans[2] += 1
            # acute
            elif c ** 2 > a ** 2 + b ** 2:
                ans[3] += 1
        else:
            break

    return ' '.join(map(str, ans))


if __name__ == '__main__':
    while True:
        sides = []
        try:
            while True:
                temp = list(map(int, input().split()))
                sides.append(sorted(temp))
        except EOFError:
            break
    
    print(solve(sides))



Measured memory_bytes: 5612
#include<iostream>
#include <cstring>
#include <map>
#include <queue>
using namespace std;

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

char lab[10][10];
struct NODE{
	int x,y;
	int px[3],py[3];
	int dead;
	int cdead;
	NODE(){
		x = y = 0;
		px[0] = px[1] = px[2] = 0;
		py[0] = py[1] = py[2] = 0;
		dead = 0;
		cdead = 0;
	}
};
bool operator < (const NODE &a,const NODE &b){
	if( a.x != b.x ) return a.x < b.x;
	if( a.y != b.y ) return a.y < b.y;
	if( a.px[0] != b.px[0] ) return a.px[0] < b.px[0];
	if( a.px[1] != b.px[1] ) return a.px[1] < b.px[1];
	if( a.px[2] != b.px[2] ) return a.px[2] < b.px[2];
	if( a.py[0] != b.py[0] ) return a.py[0] < b.py[0];
	if( a.py[1] != b.py[1] ) return a.py[1] < b.py[1];
	if( a.py[2] != b.py[2] ) return a.py[2] < b.py[2];
	if( a.dead != b.dead ) return a.dead < b.dead;
	if( a.cdead != b.cdead ) return a.cdead < b.cdead;
	return false;
}

int main(){
	int H,W;
	while( cin >> H >> W && H ){
		int wx[3],wy[3];
		map<NODE,int> done;
		NODE fst; int cc = 0 , ww = 0;
		for(int i = 0 ; i < H ; i++){
			for(int j = 0 ; j < W ; j++){
				cin >> lab[i][j];
				if( lab[i][j] == '@' ) fst.x = j , fst.y = i;
				if( lab[i][j] == 'c' ){
					fst.px[cc] = j;
					fst.py[cc++] = i;
				}
				if( lab[i][j] == 'w' ){
					wx[ww] = j;
					wy[ww++] = i;
				}
			}
		}
		priority_queue< pair<int,NODE> , vector< pair<int,NODE> > , greater<  pair<int,NODE> >  > Q;
		done[fst] = 0;
		Q.push(make_pair(0,fst));
		
		while( Q.size() ){
			NODE q = Q.top().second;
			int cost = Q.top().first;
			Q.pop();
			if( done[q] != cost ) continue;
			if( lab[q.y][q.x] == 'E' ){
				cout << cost << endl;
				goto exit;
			}
			for(int d = 0 ; d < 4 ; d++){
				int tx = q.x + dx[d];
				int ty = q.y + dy[d];
				if( lab[ty][tx] == '#' ) continue;
				int fail = 0;
				for(int i = 0 ; i < ww ; i++){
					if( !(q.dead >> i & 1) && tx == wx[i] && ty == wy[i] ) fail = 1;
				}
				if(fail) continue;
				
				NODE next = q;
				for(int i = 0 ; i < cc ; i++){
					if( !(q.cdead >> i & 1) && tx == q.px[i] && ty == q.py[i] ){
						int mx = tx;
						int my = ty;
						while( lab[my+dy[d]][mx+dx[d]] != '#' ){
							int br = 0;
							for(int j = 0 ; j < cc ; j++){
								if( !(q.cdead >> j & 1) && mx+dx[d] == q.px[j] && my+dy[d] == q.py[j] )
									br = 1;
							}
							if(br) break;
							mx += dx[d];
							my += dy[d];
							for(int j = 0 ; j < ww ; j++){
								if( !(q.dead >> j & 1) && mx == wx[j] && my == wy[j] ){
									br = 1;
									next.cdead |= (1<<i);
									next.dead |= (1<<j);
									mx = 0;
									my = 0;
									break;
								}
							}
							if(br) break;
						}
						next.px[i] = mx;
						next.py[i] = my;
						tx = q.x;
						ty = q.y;
					}
				}
				int diff = q.y != ty || q.x != tx;
				next.x = tx , next.y = ty;
				if( !done.count(next) || done[next] > cost+diff ){
					Q.push(make_pair(diff+cost,next));
					done[next] = cost+diff;
				}
			}
		}
		cout << -1 << endl;
		exit:;
		
	}
}

Measured memory_bytes: 7912
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<unordered_map>
#include<array>
#include<map>
#include<bitset>
#include<iomanip>
#include<list>
#include <numeric>
using namespace std;
typedef unsigned long long int ulint;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
#define RE return 0
//ios::sync_with_stdio(false);
//std::cin.tie(0);
//<< setprecision(20)
const int mod=(int)1e9+7;
const llint big=(llint)(2.19e12+1);
const long double pai=3.141592653589793238462643383279502884197;
const long double ena=2.71828182845904523536;
const long double eps=1e-7;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
template <class T> void soun(T& ar)
{sort(ar.begin(),ar.end());ar.erase(unique(ar.begin(),ar.end()),ar.end());}
llint gcd(llint a,llint b){if(a%b==0){return b;}else{return gcd(b,a%b);}}
llint lcm(llint a,llint b){return a/gcd(a,b) *b;}
template<class T,class U> auto LB(T& ve,U in){return lower_bound(ve.begin(),ve.end(),in);}
template<class T,class U> auto UB(T& ve,U in){return upper_bound(ve.begin(),ve.end(),in);}
template<class T,class U> auto LBI(T& ve,U in){return LB(ve,in)-ve.begin();}
template<class T,class U> auto UBI(T& ve,U in){return UB(ve,in)-ve.begin();}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
int main(void){
	int W,H,x,y,r;cin>>W>>H>>x>>y>>r;
	if(x<r||W-r<x||y<r||H-r<y){cout<<"No"<<endl;}
	else{cout<<"Yes"<<endl;}
	RE;
}


Measured memory_bytes: 3116
h,w,m=map(int,input().split())
objs=[tuple(map(int,input().split())) for i in range(m)]
setobj=set(objs)
xs,ys=zip(*objs)
from collections import Counter as co
xs,ys=co(xs),co(ys)
xim,yim=xs.most_common(1)[0][1], ys.most_common(1)[0][1]
A=len([1 for u in xs.values() if u==xim])* len([1 for u in ys.values() if u==yim])
for a,b in setobj:
  if xs[a]==xim and ys[b]==yim:A-=1

print(xim+yim-1+int(A>0))

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

int main(){
  char exp[100] = {}, *el;
  double stack[100] = {};
  int i;
  while(fgets(exp, sizeof(exp), stdin) != NULL){
    i = 0;
    for(el = strtok(exp, " \n");el != NULL;el = strtok(NULL, " \n")){
      if(*el == '+') stack[i - 2] += stack[--i];
      else if(*el == '-' && strlen(el) == 1) stack[i - 2] -= stack[--i];
      else if(*el == '*') stack[i - 2] *= stack[--i];
      else if(*el == '/') stack[i - 2] /= stack[--i];
      else stack[i++] = atof(el);
    }
    printf("%.6f\n", stack[0]);
  }
  return 0;
}

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

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
typedef pair<ll,ll> pll;
const ll INF = 2e18;
const int inf = 1e9+10;
const int maxN = 200010;
const int maxD = 15;
const int maxH = 100; 
const int MOD = 1000000007;

int T;
char s[maxN];
int a[maxN];
int main()
{
	int k;
	scanf("%d",&k);
	int x,y;
	scanf("%d%d",&x,&y);
	for(int i=x;i<=y;i++)
	{
		if(i%k == 0)
		{
			puts("OK");
			return 0;
		}
	}
	puts("NG");
	return 0;
}

Measured memory_bytes: 3772
x, y, a, b ,c = map(int, input().split())
pList = sorted(list(map(int, input().split())), reverse=True)
qList = sorted(list(map(int, input().split())), reverse=True)
rList = sorted(list(map(int, input().split())), reverse=True)

xyList = sorted(pList[:x] + qList[:y]) # 小さい順

for i, r in enumerate(rList):
  if len(xyList) <= i:
    break;
  if xyList[i] > r:
    break;
  xyList[i] = r
print(sum(xyList))

Measured memory_bytes: 22720
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <functional>

using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;

#define repi(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,a) repi(i,0,a)
#define rrep(i,a) for(ll i=a-1;i>=0;i--)

int main(){
  ll H, W;
  cin >> H >> W;
  ll board[H*W];
  rep(h, H) rep(w, W){
    if(h % 2) cin >> board[W * h + W - 1 - w];
    else cin >> board[W * h + w];
  }

  vector<vector<ll>> ans;
  ll tmp = -1;
  rep(pos, H * W){
    if(board[pos] % 2 == 0) continue;
    if(tmp < 0) tmp = pos;
    else{
      repi(i, tmp, pos){
        ll x = min(i % (2*W) + 1, 2*W - i % (2*W)), y = i / W + 1;
        ll x_ = min((i+1) % (2*W) + 1, 2*W - (i+1) % (2*W)), y_ = (i+1) / W + 1;
        vector<ll> v{y, x, y_, x_};
        ans.push_back(v);
        tmp = -1;
      }
    }
  }
  cout << ans.size() << endl;
  for(auto a : ans)
    printf("%lld %lld %lld %lld\n", a[0], a[1], a[2], a[3]);

  return 0;
}


Measured memory_bytes: 12848
using System;

public class test
{
  static void Main(string[] args)
  {
    string n = Console.ReadLine();
    char[] c = n.ToCharArray();

    if (char.IsLower(c[0]) == true)
    {
	    Console.WriteLine("a");
    }
    else
    {
	    Console.WriteLine("A");
    }
  }
}

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

int n;
int a[110];
int c;

int main()
{
	cin >> n;
	for( int i= 0; i < n; i++ ) cin >> a[i];
	
	for( int i= 0; i < n-1; i++ ) {
		if( a[i] == a[i+1] ) {
			c++; i++;
		}
	}
	cout << c << endl;
}


Measured memory_bytes: 256
//
// Created on 2020/09/12.
//


#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <ios>
#include <iomanip>
#include <numeric>

#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
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; }
typedef long long ll;
using namespace std;
const long long LINF =1e18;
const int INF = 1e9;



int main() {
    vector<vector<int>>c(3,vector<int>(3,0));
    for (int i = 0; i < 3; ++i) {
        for (int j = 0; j < 3; ++j) {
            cin>>c[i][j];
        }
    }

    for (int one = -60; one < 60; ++one) {
        for (int two = -60; two < 60; ++two) {
            for (int three = -60; three < 60; ++three) {
                for (int four = -60; four < 60; ++four) {

                    if(one + four != c[0][0])continue;
                    if(two + four != c[1][0])continue;
                    if(three + four != c[2][0])continue;
                    for (int five = -60; five < 60; ++five) {

                        if(one + five != c[0][1])continue;
                        if(two + five != c[1][1])continue;
                        if(three + five != c[2][1])continue;
                        for (int six = -60; six < 60; ++six) {

                            if(one + six != c[0][2])continue;
                            if(two + six != c[1][2])continue;
                            if(three + six != c[2][2])continue;

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

            }
        }
    }
    cout<<"No"<<endl;

    return 0;
}


Measured memory_bytes: 3612
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}
#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}
#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

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

fn main() {
    input! {
        x: u32,
        y: u32,
        z: u32,
        k: usize,
        avals: [u64; x],
        bvals: [u64; y],
        cvals: [u64; z],
    }
    let mut cvals: Vec<u64> = cvals.into_iter().collect();
    cvals.sort();
    let mut vals: Vec<u64> = Vec::new();
    for a in avals.iter() {
        for b in bvals.iter() {
            vals.push(a + b);
        }
    }
    vals.sort();
    let mut ans_vals: Vec<u64> = Vec::new();
    for (i, val) in vals.iter().rev().enumerate() {
        if i == k {
            break;
        }
        for (ci, c) in cvals.iter().rev().enumerate() {
            if ci == k {
                break;
            }
            ans_vals.push(val + c);
        }
    }
    ans_vals.sort();
    for (i, val) in ans_vals.iter().rev().enumerate() {
        if i == k {
            break;
        }
        println!("{}", val);
    }
}


Measured memory_bytes: 44276
#include <bits/stdc++.h>
using namespace std;
#define int long long
int answer = 1e9;
int c[40];
vector<int> g[40];
int n,m;
vector<int> route;
int done[40];
int wf[40][40];

int tl = 10000000;

void dfs(int x,int bit,int cost){

	if( done[x] ) return;
	int nextBit = bit;
	int diff = 0;
	if( !(bit >> x&1) ){
		diff += c[x];
		nextBit |= (1ll<<x);
	}

	for( auto i : g[x] ){
		if( !(bit >> i & 1) ){

			nextBit |= (1ll<<i);
			diff += c[i];
		}
	}
	int nextCost = cost + diff;
	if( nextCost >= answer ){
		return;
	}
	if( x == n - 1 ){
		answer = nextCost;
		return;
	}
	tl--;
	if( tl <= 0 ) return;
	done[x] = 1;
	route.push_back(x);
	//cout << "(" << nextBit << ")" << nextCost << " = ";
	//for( auto i : route) cout << i << " ";
	//cout << endl;
	
	random_shuffle(g[x].begin(),g[x].end());
	for( auto i : g[x] ){
		if( (bit >> i & 1) == 0 ) dfs(i,nextBit,nextCost);
	}
	route.pop_back();
	done[x] = 0;
}

signed main(){
	for(int i = 0 ; i < 40 ; i++)
		for(int j = 0 ; j < 40 ; j++)
			wf[i][j] = i == j ? 0 : 1e9;

	cin >> n >> m;
	for(int i = 0 ; i < n ; i++){
		cin >> c[i];
	}


	for(int i = 0 ; i < m ; i++){
		int a,b;
		cin >> a >> b;
		--a,--b;
		g[a].push_back(b);
		g[b].push_back(a);
		//wf[a][b] = a;
		//wf[b][a] = b;
	}
	dfs(0,0,0);
	cout << answer << endl;


}

Measured memory_bytes: 3192
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdlib.h>
#include <math.h>
#include <numeric>


int main() {
	int n;

	std::cin >> n;

	std::vector<std::pair<int, int> > v(100001), v2(100001);

	for (size_t i = 0; i < n; i++)
	{
		int a;
		std::cin >> a;
		if (i % 2 == 0) {
			v[a].first++;
			v[a].second = a;
		}
		else {
			v2[a].first++;
			v2[a].second = a;
		}
	}

	std::sort(v.begin(), v.end());
	std::sort(v2.begin(), v2.end());

	std::reverse(v.begin(), v.end());
	std::reverse(v2.begin(), v2.end());


	if (v[0].second != v2[0].second) {
		std::cout << (n / 2 - v[0].first) + (n / 2 - v2[0].first) << std::endl;
	}
	else {
		if (v[0].first > v2[0].first) {
			std::cout << (n / 2 - v[0].first) + (n / 2 - v2[1].first) << std::endl;
		}
		else if (v[0].first < v2[0].first) {
			std::cout << (n / 2 - v[1].first) + (n / 2 - v2[0].first) << std::endl;
		}
		else {
			if (v[1].first > v2[1].first) {
				std::cout << (n / 2 - v[1].first) + (n / 2 - v2[0].first) << std::endl;
			}
			else {
				std::cout << (n / 2 - v[0].first) + (n / 2 - v2[1].first) << std::endl;
			}
		}
	}


	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

ll dfs(vector<ll> &d, ll n, ll ans, int i);

int main()
{
    string S;
    cin >> S;
    vector<ll> d(S.size());
    for (int i = 0; i < S.size(); i++)
    {
        d.at(i) = (ll)(S.at(i) - '0');
    }
    ll ans = dfs(d, d.at(0), 0, 0);
    cout << ans << endl;
}

ll dfs(vector<ll> &d, ll n, ll ans, int i)
{
    if (i == d.size() - 1)
    {
        return n + ans;
    }
    return dfs(d, d.at(i + 1), ans + n, i + 1) + dfs(d, 10 * n + d.at(i + 1), ans, i + 1);
}


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

int main(){
  
  int a,b;
  cin>>a>>b;
  
  if(b==1){
    cout<<"0";
    return 0;
  }
  

  int  cnt=1;
  int sum=a-1;
    
  while(true){
        sum=sum+a-1;
        if(sum>=b)
            break;
        cnt++;
   }
   sum = sum+1;
   sum = sum-a+1;
   if(sum<b)
       cnt++;
   cout<<cnt;
    
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <math.h>
#include <stack>
using namespace std;
typedef long long ll;

int dp[1<<16];
int t[18][18];


int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	while(1){
		int n; cin >> n;
		if(n==0)break;
		for(int i=0;i<n;i++){
			for(int j=0;j<=n;j++){
				cin >> t[i][j];
			}
		}
		for(int j=0;j<(1<<n);j++){
			dp[j]=1e9;
		}
		dp[0]=0;
		for(int i=0;i<(1<<n);i++){
			for(int j=0;j<n;j++){
				if((i>>j)&1)continue;
				int mi=t[j][0];
				for(int k=0;k<n;k++){
					if((i>>k)&1){
						mi=min(mi,t[j][k+1]);
					}
				}
				dp[i+(1<<j)]=min(dp[i+(1<<j)],dp[i]+mi);
			}
		}
		cout << dp[(1<<n)-1] << endl; 
	}
}


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

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rep2(i, a, b) for (ll i = (a); i < (b); i++)
#define chmax(x, v)                                                            \
  do {                                                                         \
    x = max(x, v);                                                             \
  } while (0)
#define chmin(x, v)                                                            \
  do {                                                                         \
    x = min(x, v);                                                             \
  } while (0)
typedef uint64_t ull;
typedef int64_t ll;
typedef std::pair<ll, ll> PLL;

using namespace std;

signed main() {
  ll N;
  cin >> N;
  vector<ll> v(N);
  rep(i, N) cin >> v[i];
  ll ans = 0, _min = 10000000000;
  rep(i, N) {
    if (v[i] <= _min)
      ans++;
    chmin(_min, v[i]);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1792
import java.util.*;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        int K = sc.nextInt();
        int X = sc.nextInt();

        if(500*K>=X){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}


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

#define LL long long
#define RG register

using namespace std;
template<class T> inline void read(T &x) {
	x = 0; RG char c = getchar(); bool f = 0;
	while (c != '-' && (c < '0' || c > '9')) c = getchar(); if (c == '-') c = getchar(), f = 1;
	while (c >= '0' && c <= '9') x = x*10+c-48, c = getchar();
	x = f ? -x : x;
	return ;
}
template<class T> inline void write(T x) {
	if (!x) {putchar(48);return ;}
	if (x < 0) x = -x, putchar('-');
	int len = -1, z[20]; while (x > 0) z[++len] = x%10, x /= 10;
	for (RG int i = len; i >= 0; i--) putchar(z[i]+48);return ;
}
const int N = 2e4;
int a[N], n;
int main() {
	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);
	read(n);
	LL ans = 0;
	for (int i = 1; i <= n; i++) read(a[i]);
	sort(a + 1, a + 1 + n);
	for (int i = 3; i <= n; i++)
		for (int j = 2; j < i; j++) {
			int k = upper_bound(a + 1, a + j, a[i] - a[j]) - a;
			ans += j - k;
		}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <iomanip>
#include <array>
#include <numeric>
#include <regex>
#include <bitset>
#include <deque>

using namespace std;
typedef long long ll;
typedef pair<int, int> p_ii;

const int INF = 1e9;
const double PI = acos(-1.0);
const ll MOD = 1e9 + 7;

vector<int> prime = {
		2, 3, 5, 7, 11, 13,
		17, 19, 23, 29, 31,
		37, 41, 43, 47, 53,
		59, 61, 67, 71, 73,
		79, 83, 89, 97,
};

int main() {
	int N; cin >> N;
	map<int, int>pcnt;

	for (int x = 1; x <= N; x++)
	{
		for (int i = 0; i < prime.size(); i++)
		{
			int t = 0, target = x;
			while (target != 0 && target%prime[i]==0) {
				target /= prime[i];
				t++;
			}
			pcnt[prime[i]] += t;
		}
	}

	int res = 0;
	vector<int> p24 = { 2, 3, 5 };
	if (pcnt[2] >= 74)res++;
	int c2 = 0, c4 = 0, c14 = 0, c24 = 0;
	for (auto i : pcnt) {
		if (i.second >= 24)c24++;
		if (i.second >= 14)c14++;
		if (i.second >= 4)c4++;
		if (i.second >= 2)c2++;
	}

	res += c24 * (c2 - 1);
	res += c14 * (c4 - 1);
	res += c4 * (c4 - 1) / 2 * (c2 - 2);

	cout << res << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()
using ll = long long;
const ll mod = 1000000007;
const ll INF = 100000000000000000LL;
signed main(){
    int x,a,b;
    cin>>x>>a>>b;
    if(abs(x-a)<abs(x-b))cout<<'A'<<endl;
    else cout<<'B'<<endl;
}


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

int main(void){

  int a = 0, b = 0;
  char s[10]={0};

  scanf("%d %d", &a, &b);
  scanf("%s", s);
  char c = '-';
  int cnt = 0;

  if(s[a] != '-'){
    printf("No\n");
    return 0;
  }

  int i = 0;
  for( i = 0; i<strlen(s); i++){

    if(s[i] == c)
      cnt++;

  }

  if(cnt == 1){
    printf("Yes\n");
  }else{
    printf("No\n");
  }

  return 0;
}


Measured memory_bytes: 128
#include<cstdio>
#define maxn 100005
int n,k,a[maxn],x;
int main()
{
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++) 
	{
		scanf("%d",&a[i]);
		if(a[i]==1) x=i;
	}
	printf("%d\n",(n-k+k-2)/(k-1)+1);
}

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

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define replrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) replrev(i,0,n)
#define repi(itr,ds) for(auto itr = ds.begin(); itr != ds.end(); ++itr)
#define mp make_pair
#define INF 2000000000
#define MOD 1000000007
#define PI 3.1415926536
typedef long long ll;
typedef pair<int, int> P;

vector<int> A, par;
vector<ll> num;
vector<vector<int>> T;
int root;
int N;

ll dfs() {
	vector<int> ord(N);

	stack<int> s;
	s.push(root);
	par[root] = -1;
	int cnt = 0;
	
	while (!s.empty()) {
		int pos = s.top();
		s.pop();
		ord[cnt] = pos;
		cnt++;
		rep(i, T[pos].size()) {
			if (T[pos][i] == par[pos])continue;
			par[T[pos][i]] = pos;
			s.push(T[pos][i]);
		}
	}

	reprev(i, N) {
		int p = ord[i];
		if (T[p].size() == 1) {
			num[p] = A[p];
		}
		else {
			ll sum = 0;

			if (T[p].size() == 1) {
				num[p] = A[p];
				continue;
			}
			// 子同士のペアがi個
			// s-2i=A-i, i=s-A, A-i=2A-s
			int zero = 0;
			ll m = 0;
			rep(i, T[p].size()) {
				if (T[p][i] == par[p])continue;
				sum += num[T[p][i]];
				m = max((ll)m, num[T[p][i]]);
				if (num[T[p][i]] == 0)zero++;
			}

			if (2 * A[p] - sum < 0 || sum < A[p] || A[p] < m)return -1;
			
			if (p != root && T[p].size() - zero == 2) {
				if (A[p] == sum) {
					num[p] = A[p];
				}
				else {
					return -1;
				}
			}
			else {
				num[p] = 2 * A[p] - sum;
			}
		}
	}
	return num[root];
}

int main() {
	cin >> N;
	A = vector<int>(N);
	par = vector<int>(N);
	num = vector<ll>(N);
	T = vector<vector<int>>(N);
	rep(i, N) {
		cin >> A[i];
	}
	rep(i, N - 1) {
		int a, b;
		cin >> a >> b;
		a--;
		b--;
		T[a].push_back(b);
		T[b].push_back(a);
	}
	if (N == 2) {
		if (A[0] == A[1]) {
			cout << "YES" << endl;
		}
		else {
			cout << "NO" << endl;
		}
		return 0;
	}
	rep(i, N) {
		if (T[i].size() > 1) {
			root = i;
			break;
		}
	}

	if (dfs() == 0) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}

	return 0;
}

Measured memory_bytes: 7808
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int main(){
    int n;
    cin>>n;
    string s;
    cin>>s;
    int ans=0;
    	for(int i=1;i<n;i++){
    		int cnt=0;
    		for(char c='a';c<='z';c++){
    			bool left=false,right=false;
    			for(int j=0;j<i;j++)
    				if(s[j]==c)
    					left=true;
    			for(int j=i;j<n;j++)
    				if(s[j]==c)
    					right=true;
    			if(left&&right)
    				cnt++;
    		}
    		if(ans<cnt)
    			ans=cnt;
    	}
    	cout<<ans<<endl;
    }

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

int main() {
  int n;
  cin >> n;
  vector<pair<int, int>> v(n);
  for(int i = 0; i < n; i++){
    int a;
    cin >> a;
    v.at(i) = make_pair(a, i);
  }
  sort(v.begin(), v.end());
  for(int i = 0; i < n; i++){
    cout << v.at(i).second+1;
    if(i == n - 1)
      cout << endl;
    else cout << " ";
  }
}


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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef vector<ll> vll;

#define PI (2*acos(0.0))
#define eps 1e-9
#define pb push_back
#define endl "\n"
#define watch(x) cout << (#x) << " is " << (x) << endl;
#define show(v) for(int fi = 0; fi < v.size(); fi++) cout << v[fi] << " "; cout << endl;
#define showpair(v) for(int fi = 0; fi < v.size(); fi++) cout << v[fi].first << " " << v[fi].second << endl;
#define ff first
#define ss second
#define fu cout << "lol" << endl;
#define precision(n) cout << fixed << setprecision(n);
#define lb lower_bound
#define up upper_bound
#define vscan for(i = 0;i<n;i++){cin>>in; v.pb(in);}
#define all(a) a.begin(), a.end()
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define mem(a,val) memset(a,val,sizeof(a))
#define loop(i,n) for(i = 0; i < n; i++)
#define TC ull T; cin>>T; while(T--)
#define IN(x) {scanf("%d",&x);}
#define LL(x) {scanf("%lld",&x);}
#define CC(x) {scanf("%c",&x);}
#define pfl(x) printf("%d\n",x)
#define pfll(x) printf("%lld\n",x)
#define newl puts("")
#define space printf(" ")
#define MOD 1000000007
#define speed ios_base::sync_with_stdio(false); cin.tie(NULL);

int main()
{
    speed;
    int i = 0, j = 0, cs = 0, in;
    int h, w; cin>>h>>w;
    int m; cin>>m;
    vi row(h+5), col(w+5);
    map<ii,int> mp;
    while(m--){
        int a, b; cin>>a>>b;
        row[a]++, col[b]++;
        mp[ {a,b} ]++;
    }
    int maxrow = *max_element(all(row));
    int maxcol = *max_element(all(col));
    vi rowlist, collist;
    for(i = 0; i <= h; i++) if(row[i] == maxrow) rowlist.pb(i);
    for(i = 0; i <= w; i++) if(col[i] == maxcol) collist.pb(i);
    int ans = 0;
    for(i = 0; i < rowlist.size(); i++){
        for(j = 0; j < collist.size(); j++){
            int x = maxrow+maxcol;
            if(mp[{ rowlist[i], collist[j] }]) x--;
            ans = max(ans, x);
            if(!mp[{ rowlist[i], collist[j] }]) break;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 45524
#include<iostream>
#include<algorithm>
#include<functional>
using namespace std;
int main(){
	int w,ans=0,mae=4280;
	while(cin>>w,w!=-1){
		if(w<10){
		ans=1150;
		}
		else if(w>=10&&w<20){
			ans=1150+125*(w-10);
		}
		else if(w>=20&&w<30){
			ans=1150+1250+140*(w-20);
		}
		else {
			ans=1150+1250+1400+160*(w-30);
		}
		cout<<mae-ans<<endl;
		//mae=ans;
		//ans=0;
	}
}

Measured memory_bytes: 1160
import sys
import os
import math
import bisect
import collections
import itertools

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: x * y / math.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    s = iss()
    print('ABC' if s != 'ABC' else 'ARC')


if __name__ == '__main__':
    main()


Measured memory_bytes: 9492
import java.util.*;
 
class Main {
        public static void main(String args[]) {
                Scanner sc = new Scanner(System.in);
                        int N = sc.nextInt();
                        boolean[][] A = new boolean[N][N];
                        for (int i = 0; i < N; i++) {
                                int now = sc.nextInt() - 1;
                                int M = sc.nextInt();
                                for (int j = 0; j < M; j++) {
                                        A[now][sc.nextInt() - 1] = true;
                                }
                        }
                        for (int i = 0; i < N; i++) {
                                for (int j = 0; j < N; j++) {
                                        if (A[i][j]) {
                                                System.out.print(1);
                                        } else {
                                                System.out.print(0);
                                        }
                                        if (j == N - 1) {
                                                System.out.print("\n");
                                        } else {
                                                System.out.print(" ");
                                        }
                                }
                        }
                }
        
}


Measured memory_bytes: 34516
#include <bits/stdc++.h>
#define N 100010
using namespace std;
vector<int> G[N];
int n;
int used[N];

int dfs(int pos,int pre){
  if(pos == n-1) return used[pos] = 1;
  //cout<<pos<<endl;  
  for(int nx:G[pos]){
    if(nx == pre)continue;
    if(dfs(nx,pos)) return used[pos] = 1;
  }
  return 0;
}

typedef pair<int,int> P;

int dfs2(int pos,int pre){
  int cnt = 1;
  for(int nx:G[pos]) if(nx!=pre) cnt+= dfs2(nx,pos);
  return cnt;
}

int bfs(){
  queue<P> Q;
  Q.push(P(0,0));
  Q.push(P(n-1,1));
  int used2[N] = {};
  used2[0] = used2[n-1] = 1;
  int cnt[2] = {};
  while(!Q.empty()){
    P t = Q.front();Q.pop();
    int pos = t.first;
    int col = t.second;
    //cout<<pos<<" "<<col<<endl;
    for(int nx:G[pos]){
      if(used[nx] == 1 && used2[nx] == 0) cnt[col]++,Q.push(P(nx,col)),used2[nx] = 1;
      else if(used[nx] !=1 )cnt[col] += dfs2(nx,pos);
    }
  }
  //cout<<cnt[0]<<" "<<cnt[1]<<endl;
  return cnt[0]<=cnt[1];
}



int main(){
  cin>>n;
  for(int i=0;i<n-1;i++){
    int a,b;
    cin>>a>>b;
    a--,b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  used[0] = dfs(0,-1);

  //for(int i=0;i<10;i++)cout<<used[i]<<" ";cout<<endl;
  assert(used[0] == 1);
  int ans = bfs();
  cout<<(!ans? "Fennec":"Snuke")<<endl;
  
  
  

  return 0;
}


Measured memory_bytes: 10752
e1,e2,e3,e4 = map(int,input().split())
if e1 == e3 and e2 == e4:
    print('yes')
elif e1 == e2 and e3 == e4:
    print('yes')
elif e1 == e4 and e2 == e3:
    print('yes')
else:
    print('no')


Measured memory_bytes: 5596
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
 
namespace aoj
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                string a = "";
                string b = "";
                string c = "";
                int d = 0;
                string k = Console.ReadLine();
                if (k == null) break;
                for (int i = 0; i <= k.Length - 1; i++)
                {
                    if (k.Substring(i, 1) == " ") d += 1;
                }
                if (d >= 2)
                {
                    if (k == null) break;
                    for (int i = 0; i <= k.Length - 1; i++)
                    {
                        if (k.Substring(i, 1) == " ") d += 1;
                        if (d == 2 && k.Substring(i, 1) != " ") a = a + k.Substring(i, 1);
                        if (d == 3 && k.Substring(i, 1) != " ") b = b + k.Substring(i, 1);
                        if (d == 4 && k.Substring(i, 1) != " ") c = c + k.Substring(i, 1);
                    }
                    int x = int.Parse(a) * int.Parse(a);
                    int y = int.Parse(b) * int.Parse(b);
                    int z = int.Parse(c) * int.Parse(c);
                    if (x + y == z || y + z == x || x + z == y)
                    {
                        Console.WriteLine("YES");
                    }
                    else
                    {
                        Console.WriteLine("NO");
                    }
                }
            }
        }
    }
}

Measured memory_bytes: 5428
#include <iostream>
#include <sstream>
#include <stack>
#include <iomanip>
#include <string>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <queue>
#include <cmath>

#define BEGIN(x) x.begin()
#define END(x) x.end()
#define ALL(x) BEGIN(x), END(x)
#define PAIR make_pair
#define VEC(type) vector<type >

#define FOR(i, A, B) for(auto i = (A);i != (B); i++)
#define FORD(i, A, B) for(auto i = (A);i != (B); i--)

#define READRANGE(begin, end) FOR(it, begin, end) cin >> *it
#define READVEC(V) READRANGE(BEGIN(V), END(V))

using namespace std;

typedef long long lint;
typedef pair<int, int> Pii;
typedef pair<int, lint> Pil;
typedef pair<lint, lint> Pll;
typedef pair<lint, int> Pli;

// ---- BEGIN LIBRARY CODE ----
// ---- END LIBRARY CODE ----
void io_init()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
};

int main(int argc, char **argv)
{
    io_init();

    // Actual program code starts here.
    string S;
    int N, Q;
    cin >> N >> Q;
    cin >> S;
    VEC(int) acs;
    FOR(i, 0, S.size() - 1)
        if (S[i] == 'A' && S[i + 1] == 'C')
            acs.push_back(i);
    while (Q--) {
        int l, r;
        cin >> l >> r;
        l--;r--;
        int ret = lower_bound(ALL(acs), r) - lower_bound(ALL(acs), l);
        cout << ret << endl;
    }

    return 0;
};


Measured memory_bytes: 1228