akhauriyash/Code-Regression huggingface dataset:
use std::io::*;
use std::str::FromStr;

//https://qiita.com/tubo28/items/e6076e9040da57368845
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

//https://onlinejudge.u-aizu.ac.jp/solutions/problem/ALDS1_5_B/review/2709881/arsenic28/Rust
trait Joinable {
    fn join(self, sep: &str) -> String;
}

impl<U: ToString, T: Iterator<Item = U>> Joinable for T {
    fn join(self, sep: &str) -> String {
        self.map(|x| x.to_string()).collect::<Vec<_>>().join(sep)
    }
}

fn main() {
    let N: usize = read();
    let a: Vec<u64> = (0..N).map(|_| read()).collect();
    let a_sum: u64 = a.iter().sum();

    let mut m: Vec<u64> = Vec::new();

    let mut b = 0;
    for i in 0..(N - 1) / 2 {
        b += a[i * 2 + 1];
    }
    m.push(a_sum - 2 * b);

    for i in 1..N {
        m.push(2 * a[i - 1] - m[i - 1]);
    }

    println!("{}", m.iter().join(" "));
}


Measured memory_bytes: 10024
#include <stdio.h>

int main(void)
{
    unsigned long int input, i, rectangle, area;

    while (scanf("%lu", &input) == 1){
        i = 1;
        rectangle = input;
        area = 0;
        while (i < (600 / input)){
            area += rectangle * rectangle * input;
            rectangle += input; 
            i++;
            //printf("rectangleX : %lu area : %lu\n", rectangle, area);   
        }
        printf("%lu\n", area);
    }

    return (0);
}


Measured memory_bytes: 2028
module.exports=function(t){var r={};function n(e){if(r[e])return r[e].exports;var i=r[e]={i:e,l:!1,exports:{}};return t[e].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=t,n.c=r,n.d=function(t,r,e){n.o(t,r)||Object.defineProperty(t,r,{enumerable:!0,get:e})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,r){if(1&r&&(t=n(t)),8&r)return t;if(4&r&&"object"==typeof t&&t&&t.__esModule)return t;var e=Object.create(null);if(n.r(e),Object.defineProperty(e,"default",{enumerable:!0,value:t}),2&r&&"string"!=typeof t)for(var i in t)n.d(e,i,function(r){return t[r]}.bind(null,i));return e},n.n=function(t){var r=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(r,"a",r),r},n.o=function(t,r){return Object.prototype.hasOwnProperty.call(t,r)},n.p="",n(n.s=0)}([function(t,r,n){"use strict";var e=n(1);n(2)(e.readFileSync("/dev/stdin","utf8"))},function(t,r){t.exports=require("fs")},function(t,r,n){"use strict";var e=n(3),i=n(5);t.exports=function(t){var r=new e(t);i(r)}},function(t,r,n){"use strict";var e=n(4);t.exports=class{constructor(t){var r=t.trim().split(/\s+/g);this.inp=new e(r)}inr(){return this.inp.deq()}in(){return parseInt(this.inp.deq(),10)}fin(){this.inp.clear()}}},function(t,r,n){"use strict";t.exports=class{constructor(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];this.size=t.length,this.items=t,this.ind=0}enq(t){this.size+=1,this.items.push(t)}deq(){var t=this.items[this.ind];return this.size-=1,this.ind+=1,t}clear(){this.items=[],this.size=0,this.ind=0}}},function(t,r,n){"use strict";function e(t,r){return function(t){if(Array.isArray(t))return t}(t)||function(t,r){var n=[],e=!0,i=!1,o=void 0;try{for(var a,u=t[Symbol.iterator]();!(e=(a=u.next()).done)&&(n.push(a.value),!r||n.length!==r);e=!0);}catch(t){i=!0,o=t}finally{try{e||null==u.return||u.return()}finally{if(i)throw o}}return n}(t,r)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}()}function i(t,r){return null==t||null==r?9999999999999:t<=0&&r>=0||t>=0&&r<=0?2*Math.min(Math.abs(t),Math.abs(r))+Math.max(Math.abs(t),Math.abs(r)):Math.max(Math.abs(t),Math.abs(r))}function o(t,r){for(var n=-1,e=t.length;Math.abs(n-e)>1;){var i=Math.floor((n+e)/2);t[i]<=r?n=i:e=i}for(var o=-1!=n?t[n]-r:void 0,a=t.length,u=-1;Math.abs(a-u)>1;){var s=Math.floor((a+u)/2);r<=t[s]?a=s:u=s}return[o,a!=t.length?t[a]-r:void 0]}t.exports=function(t){for(var r=t.in(),n=t.in(),a=t.in(),u=new Array(r),s=0;s<r;s++)u[s]=t.in();for(var l=new Array(n),c=0;c<n;c++)l[c]=t.in();for(var f=[],h=0;h<a;h++){var d=t.in(),p=e(o(u,d),2),v=p[0],b=p[1],y=e(o(l,d),2),m=y[0],M=y[1],g=i(b,M),x=i(b,m),j=i(v,M),w=i(v,m);f.push(Math.min(g,x,j,w))}console.log(f.join("\n"))}}]);


Measured memory_bytes: 75016
#include <bits/stdc++.h>
#define DAU  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define PLEC exit(0);
using namespace std;
int k, n;
int main() {
    DAU
    cin >> k >> n;
    for (int i = n - k + 1; i < n + k; ++i)
        cout << i << ' ';
    PLEC
}


Measured memory_bytes: 3648
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int vol = sc.nextInt();
		int sum = 0;
		int index = 0;
		int[] array = new int[vol];
		while (sc.hasNextInt()) {
			int n = sc.nextInt();
			sum += n;
			array[index] = n;
			index += 1;
		}

		int sum1 = 0;
		int sum2 = 0;
		index = 0;

		while (sum1 < sum / 2) {
			sum1 += array[index];
			index += 1;
		}

		sum2 = sum1 - array[index - 1];
		int result = Math.min(Math.abs(sum - 2 * sum1),Math.abs(sum - 2 * sum2));

		System.out.println(result);

	}

}


Measured memory_bytes: 21716
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <ctype.h>
#include <limits.h>	
#define inf (INT_MAX-1)
#define INF 9223372036854775807
#define EPS 1e-10
#define sq(n) ((n)*(n))
#define rep(i,n) for(i=0;i<n;i++)
#define rev(i,n) for(i=n-1;i>=0;i--)
#define sort(a,n) qsort(a,n,sizeof(TYPE),cmp)
#define sort_r(a,n) qsort(a,n,sizeof(TYPE),cmp_r);
#define chsort(s,n) qsort(s,n,sizeof(char),cmp)
#define chsort_r(s,n) qsort(s,n,sizeof(char),char_cmp_r);
#define TYPE int
#define MEMSET(a) memset(a,0,sizeof(a))
const int mod=(int)1e09+7;

int in(void){
	int i;scanf("%d",&i);
	return i;
}
long long llin(void){
	long long i;scanf("%lld",&i);
	return i;
}
double din(void){
	double i;scanf("%lf",&i);
	return i;
}
void chin(char s[]){
	scanf("%s",s);
}
void print(int a){
	printf("%d\n",a);
}
void llprint(long long a){
	printf("%lld\n",a);
}
void dprint(double a){
	printf("%.10f\n",a);
}
void print2(int a,int b){
	printf("%d %d\n",a,b);
}
long long max(long long a,long long b){
	return a>b?a:b;
}
long long min(long long a,long long b){
	return a<b?a:b;
}
long long llabs(long long a){
	return a>0?a:-a;
}
double dmax(double a,double b){
	return a>b?a:b;
}
int cmp(const void *a,const void *b){
	return *(TYPE *)a-*(TYPE *)b;
}
int cmp_r(const void *a,const void *b){
	return *(TYPE *)b-*(TYPE *)a;
}
int char_cmp(const void *a,const void *b){
	return strcmp((char *)a,(char *)b);
}
int char_cmp_r(const void *a,const void *b){
	return strcmp((char *)b,(char *)a);
}
void swap(int *a,int *b){
	int t=*a;
	*a=*b;
	*b=t;
}
long long gcd(long long x,long long y){
	return x%y?gcd(y,x%y):y;
}
long long lcm(long long x,long long y){
	return x/gcd(x,y)*y;
}

// konoshita kara kaku

int main(void){
	int s=0,t=0,i,l;
	char x[200010];
	chin(x);
	l=strlen(x);
	rep(i,l){
		if(x[i]=='S')s++;
		else{
			if(s)s--;
			else t++;
		}
	}
	print(s+t);
	return 0;
}

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

int main(){
  int n;
  cin >> n;
  vector<double> v;
  double x[n],y[n];
  for(int i=0; i<n; i++){
    cin >> x[i] >> y[i];
  }
  for(int i=0; i<n; i++){
    for(int j=0; j<n; j++){
      if(i!=j){
        v.push_back(sqrt(pow(x[i]-x[j],2)+pow(y[i]-y[j],2)));
      }
    }
  }
  double sum = accumulate(v.begin(), v.end(), 0.0);
  double ans = sum/double(n);
  printf("%.10f\n",ans);
  return 0;
}

Measured memory_bytes: 256
import sys
S = []
N = int(input())

for i in sys.stdin:
    S.append(i.replace("\n",""))

AC = []
WA = []
TLE = []
RE = []

S.sort()
P = [AC,TLE,RE,WA]

for i in S:
    if i == "AC":
        AC.append(0)
    elif i == "WA":
        WA.append(0)
    elif i == "TLE":
        TLE.append(0)
    else:
        RE.append(0)    
print("AC x ",len(AC))
print("WA x ",len(WA))
print("TLE x ",len(TLE))
print("RE x ",len(RE))

Measured memory_bytes: 16940
#include <stdio.h>
#include <vector>
#include <algorithm>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define MOD (1000003LL)
typedef long long Int;

int n, mi, cs[60000][2], dp[60000][2][2];
vector<int> g[60000];
bool has[60000];

inline int f(int k, int x, int y) { return k == -1 ? x==y : dp[k][x][y]; }

void add(int p, int q) {
    if (p > q) swap(p, q);
    g[p].push_back(q);
}

int pre(int p, int q) {
    if (p+1 == q) return -1;
    const int k = mi++;
    has[k] = 0;
    if (g[p].back() == q) has[k] = 1, g[p].pop_back();
    const int r = g[p].back();
    cs[k][0] = pre(p, r);
    cs[k][1] = pre(r, q);
    return k;
}

int main() {
    for (;;) {
        int m, a, b;
        scanf("%d%d", &n, &m);
        if (n == 0) return 0;
        rep (_, m) {
            scanf("%d%d", &a, &b);
            add(a-1, b-1);
        }
        rep (i, n) add(i, (i+1)%n);
        rep (i, n) sort(g[i].begin(), g[i].end());
        mi = 0;
        pre(0, n-1);
        for (int k = mi-1; k >= 0; k--) {
            const int p = cs[k][0], q = cs[k][1];
#define F(x, y) ((Int)f(p, x, 0)*f(q, 1, y) + (Int)f(p, x, 1)*f(q, 0, y))
            dp[k][0][0] = F(0, 0) % MOD;
            dp[k][0][1] = F(0, 1) % MOD;
            dp[k][1][0] = F(1, 0) % MOD;
            Int a = F(1, 1);
            if (has[k]) a += dp[k][0][0];
            dp[k][1][1] = a % MOD;
        }
        printf("%d\n", dp[0][1][1]);
    }
}

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

map< pair<ll, ll>, ll > memo;
const ll mod = 1000000007LL;

ll func(ll S, ll X) {

    if (S < 0 or X < 0) return 0;

    if (S == 0 and X >= 0) {
        return 1;
    }
    else if (S == 1 and X == 0) {
        return 1;
    }
    else if (S == 1 and X > 0) {
        return 2;
    }

    if (memo.count({S, X})) {
        return memo[{S, X}];
    }

    return memo[{S, X}] = (func(S/2, X/2) + func((S-1)/2, (X-1)/2) + func((S-2)/2, X/2)) % mod;
}

int main() {
    ll N;
    cin >> N;
    cout << func(N, N) << endl;
}


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

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

//qsort(str, n, sizeof(int), up_comp);
int up_comp(const void *a, const void *b){return *(int*)a - *(int*)b;}
int down_comp(const void *a, const void *b){return *(int*)b - *(int*)a;}
int int_sort( const void * a , const void * b ) {return strcmp(( char * )a , ( char * )b );}
int count_digit(int a){int i=0;while(a!=0){a=a/10;i++;}return i;}
int euclid( int a, int b ){int temp;if(a<b){temp=a;a=b;b=temp;}if(b<1)return -1;if(a%b==0) return b;return euclid(b,a%b);}

int main(void){
 
    int a, b;
    
    scanf("%d%d", &a, &b);
    
    if (a<=8&&b<=8) {
        printf("Yay!");
    } else {
        printf(":(");
    }
    
    return 0;
}



Measured memory_bytes: 1692
#include<iostream>

using namespace std;
int main(){
    int x,y,flag = 0;
    cin >> x >> y;
    for(int i=0; i<=x ; i++){
        if((i*2 + (x-i)*4) == y){
            flag = 1;
            break;
        }
    }
    if(flag != 1)cout << "No" << endl;
    else cout << "Yes" << endl;

    return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<int> a(n),s(n);
  for(int i=0;i<n;i++){
    cin>>a[i];
    s[i]=a[i];
  }
  sort(s.begin(),s.end());
  reverse(s.begin(),s.end());
  for(int i=0;i<n;i++){
    int ans=s[0];
    if(a[i]==ans){
      ans=s[1];
    }
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 4804
#include <bits/stdc++.h>
#include <string.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for(int i = m; i < n; i++) 
#define mod 1000000007
#define pi 3.1415926535
typedef long long ll;
int main(){
    int N;
    cin>>N;
    string S;
    map<string,int>ma;
    rep(i,N){
        cin>>S;
        ma[S]++;
    }
    cout<<"AC x "<<ma["AC"]<<endl;
    cout<<"WA x "<<ma["WA"]<<endl;
    cout<<"TLE x "<<ma["TLE"]<<endl;
    cout<<"RE x "<<ma["RE"]<<endl;
    return 0;
}

Measured memory_bytes: 3664
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define range(a) a.begin(), a.end()

ll f(ll n) {
  return n * (n - 1) / 2;
}

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  int N; cin >> N;
  map<int, ll> mp;
  vector<int> A(N); rep(i, N) cin >> A[i], mp[A[i]]++;
  ll ans = 0;
  for (auto kv : mp) {
    ans += f(kv.second);
  }
  rep(i, N) {
    ans -= f(mp[A[i]]);
    mp[A[i]]--;
    ans += f(mp[A[i]]);
    cout << ans << '\n';
    ans -= f(mp[A[i]]);
    mp[A[i]]++;
    ans += f(mp[A[i]]);
  }
}

Measured memory_bytes: 10368
#include<bits/stdc++.h>
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
#define watch(x) cout<<(#x)<<" is "<<x<<endl;
#define ll long long int
#define pb push_back
#define in insert
#define mp make_pair
#define F first
#define S second
#define N 1000000
#define MOD 1000000007
#define PI acos(-1)
int main()
{
	IOS
	int n,k;
	cin>>n>>k;
	int a[n+1]={0};
	int i;
	int d;
	int x;
	for(i=0;i<k;i++)
	{
		cin>>d;
		for(int j=0;j<d;j++)
		{
			cin>>x;
			a[x]=1;
		}
	}
	int ans=0;
	for(i=1;i<=n;i++)
	{
		if(a[i]==0)
		ans++;
	}
	cout<<ans;
}

Measured memory_bytes: 3656
import math
K = int(input())
A = list(map(int, input().split()))
def check(init, A):
    cnt = init
    for a in A:
        group = cnt // a
        cnt = group * a
    return cnt

l,r = 0, 2**100
while r-l > 1:
    mid = (l+r)//2
    if check(mid, A) > 2:
        r = mid
    else:
        l = mid
maxcnt = l

l,r = 0, 2**100
while r-l > 1:
    mid = (l+r)//2
    if check(mid, A) < 2:
        l = mid
    else:
        r = mid
mincnt = r


if check(mincnt, A) == check(maxcnt, A) == 2:
    print(mincnt, maxcnt)
else:
    print(-1)



Measured memory_bytes: 84956
import java.util.*;
import static java.lang.System.*;

public class Main {

	
//	class P {
//		int a, b;
//		P(int a, int b) {
//			this.a = a;
//			this.b = b;
//		}
//		
//		public boolean equals(Object obj) {
//			if(obj instanceof P){
//				P p=(P)obj;
//				return this.a == p.a && this.b == p.b;
//			}
//			return false;
//		}
//	}
	
	Scanner sc = new Scanner(in);
	
	char[] eq;
	int len;
	
//	Map<P, Set<Integer>> memo = new HashMap<P, Set<Integer>>();
	
	Set<Integer> calc(int a, int b) {
//		P p = new P(a, b);
//		if (!memo.containsKey(p)) {
		boolean flag = true;
			Set<Integer> set = new HashSet<Integer>();
			if (eq[a] == '(' && eq[b] ==')') {
				int k = 1;
				boolean f = true;;
				for (int i = a+1; i <= b-1; i++) {
					if (eq[i] == '(') k++;
					else if (eq[i] == ')') k--;
					
					if (k == 0) {
						f = false;
						break;
					}
				}
				if (f)
					return calc(a+1, b-1);
			}
			
			int count = 0;
			for (int i = a; i <= b; i++) {
				switch(eq[i]) {
				case '+':
					if (count == 0) {
						flag = false;
						for (int k : calc(a, i-1))
							for (int l : calc(i+1, b))
								set.add(k+l);
					}
					break;
				case '-':
					if (count == 0) {
						flag = false;
						for (int k : calc(a, i-1))
							for (int l : calc(i+1, b))
								set.add(k-l);
					}
					break;
				case '*':
					if (count == 0) {
						flag = false;
						for (int k : calc(a, i-1))
							for (int l : calc(i+1, b))
								set.add(k*l);
					}
					break;
				case '/':
					if (count == 0) {
						flag = false;
						for (int k : calc(a, i-1))
							for (int l : calc(i+1, b))
								if (l != 0)
									set.add(k/l);
					}
					break;
				case '(':
					count++; break;
				case ')':
					count--; break;
				}
	
			}
			
			if (flag) {
				int value = 0;
				for (int i = a; i <= b; i++) {
					value = 10*value + Character.getNumericValue(eq[i]);
				}
				set.add(value);
			}
			
//			memo.put(p, set);
//		}
		
//		return memo.get(p);
			return set;
	}
	
	void run() {
		String s;
		while (true) {
			s = sc.nextLine();
			if (s.equals("#")) break;
			eq = s.toCharArray();
			len = eq.length;
//			memo.clear();
			out.println(calc(0, len-1).size());
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}

}

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

string match(string &s) {
  if (s.size()>=5 && s.substr(s.size()-5, s.size()) == "dream") {
    s = s.substr(0, s.size()-5);
  }
  
  else if (s.size()>=5 &&s.substr(s.size()-5, s.size()) == "erase") {
    s = s.substr(0, s.size()-5);
  }
  
  else if (s.size()>=7 &&s.substr(s.size()-7, s.size()) == "dreamer") {
    s = s.substr(0, s.size()-7);
  }
  
  else if (s.size()>=6 && s.substr(s.size()-6, s.size()) == "eraser") {
    s = s.substr(0, s.size()-6);
  }
  else if (s.size() == 0){
    s = "YES";
  }
  else {
    s = "NO";
  }
  return s;
}
int main() {
  string s;
  cin >> s;
  while (true){
    s = match(s);
    if ((s=="YES")||(s=="NO")) {
      break;
    }
  }
  cout << s << endl;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


int N,K;
bool check[10];


int main(){

	scanf("%d %d",&N,&K);

	for(int i = 0; i <= 9; i++){

		check[i] = true;
	}

	int tmp;
	for(int i = 0; i < K; i++){

		scanf("%d",&tmp);
		check[tmp] = false;
	}

	tmp = N;
	bool FLG;

	while(true){

		int work = tmp;

		FLG = true;

		while(work > 0){

			if(!check[work%10]){

				FLG = false;
				break;
			}
			work /= 10;
		}

		if(FLG){

			printf("%d\n",tmp);
			return 0;
		}
		tmp++;
	}

	return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <queue>
#include <bitset>

using ll = long long int;
using ul = unsigned long long int;

namespace lamlib
{
	// Absolute
	template<class T> inline T abs(const T &a){ return (a>0) ? a : -a; }
	// GCD: a > b
	ul gcd(ul a,ul b) { return (!b) ? a : gcd(b,a%b); }
}

int main(int argc,char *argv[])
{
	ll h,n;
	std::cin >> h >> n;
	
	ll tmp = h*n;
	if (h == 1 || n == 1) std::cout << 1 << std::endl;
	else if(!(tmp%2)) std::cout << tmp/2 << std::endl;
	else std::cout << tmp/2 + 1 << std::endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <sstream>
#include <map>
#include <queue>
#include <set>
#define rep(i,n) for(int i = 0; i < n; i++)
#define rep1(i,n) for(int i = 1; i <= n; i++)
#define co(x) cout << x <<endl
#define cs(x) cout << x <<" "
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
using namespace std;
ll mod = 1e9 + 7;
ll INF = 1e10;

int main()
{
	vector<string> words = { "dream","dreamer","erase","eraser" };
	rep(i, 4) reverse(ALL(words[i]));
	string s;
	cin >> s;
	reverse(ALL(s));
	while (s.size()>0)
	{
		if (s.substr(0, 5) == words[0] || s.substr(0, 5) == words[2])
		{
			s.erase(0, 5);
		}
		else if (s.substr(0, 6) == words[3])
		{
			s.erase(0, 6);
		}
		else if (s.substr(0, 7) == words[1])
		{
			s.erase(0, 7);
		}
		else
		{
			co("NO");
			return 0;
		}
	}
	co("YES");
	return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
using namespace std;
const long long mod=1e9+7;
int main(){
  int n,m;
	cin >> n >> m;
	vector<bool> isBroken(n+1,false);
	for(int i=0;i<m;i++){
		int a;
		cin >> a;
		isBroken[a]=true;
	}

	vector<long long> dp(n+1);
	dp[0]=1;
	for(int i=0;i<n;i++){
		for(int next=i+1;next<=min(n,i+2);next++){
			if(!isBroken[next]){
				dp[next]+=dp[i];
				dp[next]%=mod;
			}	
		}
	}

	cout << dp[n] << endl;
  return 0;
}


Measured memory_bytes: 1024
a = list(input())

f = int("".join(a[0]+a[1]))
g = int("".join(a[2]+a[3]))
if 1<= f and f <= 12:
     if 1<= g and g <= 12:
          print("AMBIGUOUS")
     else:
          print("MMYY")
elif 1<= g and g <= 12:     
     print("YYMM")
else:
     print("NA")

Measured memory_bytes: 38384
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
INF = 10**9
mod = 10**9+7

N = i()
print(N*800-N//15*200)

Measured memory_bytes: 77392
size = STDIN.gets.to_i
$ary1 = STDIN.gets.split.map(&:to_i)
$ary2 = STDIN.gets.split.map(&:to_i)

def dist(n)
  $ary1.zip($ary2).reduce(0){|sum, a| sum + (a[0] - a[1]).abs ** n} ** (1 / n)
end

puts "%.8f" % dist(1.0)
puts "%.8f" % dist(2.0)
puts "%.8f" % dist(3.0)

puts "%.8f" % $ary1.zip($ary2).map{|a| (a[0] - a[1]).abs }.max

Measured memory_bytes: 8864
fun main() {
    var aList = readLine()!!.toCharArray().toMutableList()
    var bList = readLine()!!.toCharArray().toMutableList()
    var cList = readLine()!!.toCharArray().toMutableList()
    var nextPlayer = 'a'

    loop@ while (true) {
        when (nextPlayer) {
            'a' -> {
                if (aList.size == 0) break@loop
                nextPlayer = aList[0]
                aList = aList.drop(1).toMutableList()
            }
            'b' -> {
                if (bList.size == 0) break@loop
                nextPlayer = bList[0]
                bList = bList.drop(1).toMutableList()
            }
            'c' -> {
                if (cList.size == 0) break@loop
                nextPlayer = cList[0]
                cList = cList.drop(1).toMutableList()
            }
        }


    }

    println(
            when (nextPlayer) {
                'a' -> "A"
                'b' -> "B"
                else -> "C"
            }
    )
}

Measured memory_bytes: 39520
#include <bits/stdc++.h>
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--) // [a, b)
#define reprev(i,n) reprrev(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

const ll mod = 1e9+7;


void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n==0) return 1;
    ll res=modpow(x, n/2);

    if(n%2==0) return res*res%mod;
    else return res*res%mod*x%mod;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };

// 線分 ab の偏角 返り値は[-π, π]
double argument(const pair<double, double> &a, const pair<double, double> &b){
    double ax=a.first, ay=a.second, bx=b.first, by=b.second;
    return atan2(by-ay, bx-ax);
}

/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */


/* 注意 

    1LL<<60 * N とかのオーバーフローに気を付けろ
    制約がヒントになる、ちゃんと全ての制約を見ろ

*/


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

    ll H, W, N; cin >> H >> W >> N;
    map<pair<int, int>, ll> mp;

    rep(i, N) {
        int a, b; cin >> a >> b;
        rep(i, 3) rep(j, 3) {
            int x = a-i;
            int y = b-j;
            if (1<=x && x<=H-2 && 1<=y && y<=W-2) {
                mp[make_pair(x, y)]++;
            }
        }
    }

    vector<ll> ans(10, 0);
    ans[0] = (H-2)*(W-2);
    for (auto itr=mp.begin(); itr!=mp.end(); ++itr) {
        ans[itr->second]++;
        ans[0]--;
    }

    rep(i, 10) cout << ans[i] << endl;

    return 0;
}


Measured memory_bytes: 56576
use proconio::marker::Usize1;
use proconio::*;

fn main() {
    input! {
        d: usize,
        c: [i64; 26],
        s: [[i64; 26]; d],
    };
    let mut t = vec![26; d];
    let mut lasts = [-1; 26];
    let mut score = 0;

    for i in 0..d {
        let mut high = -10000;
        for j in 0..26 {
            let tmp = calc_score(i, j, &c, &s, &mut lasts);
            if tmp > high {
                high = tmp;
                t[i] = j;
                lasts[j] = i as i64;
            }
        }

        score += high;
    }

    for &v in &t {
        println!("{}", v + 1);
    }
}

fn calc_score(i: usize, j: usize, c: &Vec<i64>, s: &Vec<Vec<i64>>, lasts: &mut [i64; 26]) -> i64 {
    let mut res = s[i][j];
    let tmp = lasts[j];
    lasts[j] = i as i64;

    for j in 0..26 {
        let i = i as i64;
        let last = lasts[j];
        res -= c[j] * (i - last);
    }

    lasts[j] = tmp;
    res
}


Measured memory_bytes: 2304
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

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

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>

using namespace std;

int main()
{
	int i,a,b,c;

	cin >> a >> b >> c;

	if((b-a)==(c-b)){
	cout << "YES";
	}else{
		cout << "NO";
	}
	return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String[] args) throws java.io.IOException{
        Scanner scan = new Scanner(System.in);
       
        while(true){
        	int n = scan.nextInt();
        	if(n==0)break;
        	System.out.println(collatz(n,0));
        	

        }
    }
    public static int collatz(int n,int c){
    	if(n==1)return c;
    	
    	if(n%2==0)return collatz(n/2,c+1);
    	else return collatz(3*n+1,c+1);
    }
}

Measured memory_bytes: 12000
#include<bits/stdc++.h>
using namespace std;
int n;long long ans;
char a[11];
map<string,int>mp;
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%s",a);
		sort(a,a+10);
		ans+=mp[a];
		mp[a]++;
	}
	printf("%lld",ans);
}

Measured memory_bytes: 11136
#include <iostream>
#include <stdlib.h>
#include <string.h>
#include <vector>
#include <math.h>
using namespace std;

int main(){

    int N;
    string S;
    string alpha={"abcdefghijklmnopqrstuvwxyz"};
    //N=3 abc
    cin>>N>>S;
    bool flag=true;
    //cout<<alpha[3];ng
    //no size=N.size();
    //int sum[N]={};
    //cout << sum[1];
    if(1<=N&&N<=100&&N%2==0){
      //cadcad1 4 6 (N)/2 aiueoaieoo
      for(int i=0;i<N/2;i++){

        //flag=false;//012 345
        //12345678 s[3] s[7]
        if(S[i]!=S[(N/2)+i]){
          flag=false;
          if(flag==false){
            cout << "No";
            return 0;
          }
          //sum[i]++;
          //cout <<i<<"\n";
          //cout<<sum[i]<<"\n";
        }
        /*
        else{
          sum[i]=0;
        }
        */
      }
      cout << "Yes";
      return 0;
    }
    cout << "No";
    return 0;
    /*
    int j=0;
    for(j;j<N;j++){
      sum[j]*=sum[j];
    }
    cout << sum[j];
    if(sum[j]==1){
      cout << "Yes";
      return 0;
    }*/




    }


Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = (ll)(1e9 + 7);
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(int)(n); (i)++)
#ifdef LOCAL
#define debug(x) cerr << #x << ": " << x << endl
#else
#define debug(x)
#endif
int dx[4] ={ 1,0,-1,0 };
int dy[4] ={ 0,1,0,-1 };

int N;
string S;

inline vector<int> Z_algorithm(string S) {
	vector<int> Z(S.size());
	Z[0] = S.size();
	int i = 1, j = 0;
	while(i < S.size()){
		while(i + j < S.size() && S[j] == S[i + j]) j++;
		Z[i] = j;

		if(j == 0){
			i++;
			continue;
		}
		int k = 1;
		while(k < j && k + Z[k] < j){
			Z[i + k] = Z[k];
			k++;
		}
		i += k;
		j -= k;
	}
	return Z;
}

signed main() {
	cin >> N >> S;
	ll ans = 0;
	rep(i, N) {
		string T = S.substr(i, N - i);
		vector<int> v = Z_algorithm(T);
		for(int j = 1; j < v.size(); j++) {
			if(v[j] <= j) ans = max(ans, (ll)v[j]);
		}
	}
	cout << ans << endl;
}


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

#define MAXNUM 1000001

bool prime[MAXNUM];
bool price[MAXNUM];

int main()
{
	prime[0]=prime[1]=false;
	for(int i=2; i<MAXNUM; i++)
	{
		prime[i]=true;
	}
	
	for(int i=2; i*i<MAXNUM; i++)
	{
		if(prime[i])
		{
			for(int j=i*i; j<MAXNUM; j+=i)
			{
				prime[j]=false;
			}
		}
	}

	int n,x,p;
	while(cin >> n >> x, (n||x))
	{
		price[0] = true;
		for(int i=1; i<=x; i++)
		price[i] = false;

		while(n--)
		{
			cin >> p;
			for(int i=p; i<=x; i++)
			{
				if(price[i-p]) price[i]=true;
			}
		}

		int j;
		for(j=x; j>1; j--)
		{
			if(price[j]&&prime[j])
			{
				cout << j << endl;
				break;
			}
		}
		if(j==1) cout << "NA" << endl;
	}
}

Measured memory_bytes: 2816
#include<cstdio>
#include<iostream>
#include<utility>

using namespace std;

int main(void){

	int n;
	pair<int,int> inp;
	pair<int,int> max;

	cin>>n;

	cin>>max.first>>max.second;
	for(int i=1;i<n;i++){
		cin>>inp.first>>inp.second;
		if(inp.second>max.second||(inp.second==max.second&&inp.first<max.first)) max=inp;
	}

	cout<<max.first<<" "<<max.second<<endl;

	return 0;
}

Measured memory_bytes: 1168
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
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); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

//こたつがめさんの提出を見ました。
const int cm = 2200010;
char cn[cm], * ci = cn, ct;

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


	int M = fread_unlocked(cn, 1, cm, stdin);
	int N = 0;
	while ((ct = *ci++) >= '0') N = N * 10 + ct - '0';
	auto c = ci;

	ll kotae = 0;
	for (ci = cn + M - 1; ci > c;) {
		int a = 0, b = 0;
		int k = 1;
		while (*(--ci) >= '0') {
			b += k * (*ci - '0');
			k *= 10;
		}
		k = 1;
		while (*(--ci) >= '0') {
			a += k * (*ci - '0');
			k *= 10;
		}

		ll kari = (kotae + a + b - 1.0) / b;
		kotae = kari * b - a;
	}

	printf("%lld\n", kotae);

	Would you please return 0;
}

Measured memory_bytes: 2304
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cmath>
#include <string>
using namespace std;

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

int main() {
  string s;
  cin >> s ;
  s[3] = '8';
  cout << s << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    std::ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    string s;
    string t;
    int ans=0;
    cin>>s;
    cin>>t;
    for(int i=0;i<3;i++){
        if(s[i]==t[i]) ans++;
    }
    cout<<ans;
}

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

#define ll long long

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    ll n,wi;
    cin>>n>>wi;
    ll w[n+1],v[n+1];
    for(int i=1;i<=n;i++)
        cin>>w[i]>>v[i];
    ll dp[n+1][wi+1];
    memset(dp,0,sizeof dp);
    for(int i=1;i<=n;i++){
        for(int j=1;j<=wi;j++){
            if(w[i]>j)
                dp[i][j]=dp[i-1][j];
            else{
                dp[i][j]=max(dp[i-1][j],dp[i-1][j-w[i]]+v[i]);
            }
        }
    }
    cout<<dp[n][wi]<<endl;
}



Measured memory_bytes: 79232
#include <bits/stdc++.h>
#define int long long
using namespace std;

constexpr int MOD = 1e9 + 7;

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

  int ans = 1;
  for (int i = 1; i <= N; i++) {
    ans *= i;
    ans %= MOD;
  }

  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int Maxn=100005;
int len,sz[Maxn];
vector<int>e[Maxn],path;
vector<int>gen(){
    vector<int>ans;
    for(int i=1,j=0;i<=len;i++){
        int cur=++j;
        for(int k=1;k<=sz[i];k++)ans.push_back(++j);
        ans.push_back(cur);
    }
    return ans;
}
pair<int,int>dfs1(int x,int fa,int dis){
    pair<int,int>ret(dis,x);
    for(int y:e[x]){
        if(y==fa)continue;
        ret=max(ret,dfs1(y,x,dis+1));
    }
    return ret;
}
bool dfs2(int x,int fa,int t){
    if(x==t)return path.push_back(x),true;
    for(int y:e[x]){
        if(y==fa)continue;
        if(dfs2(y,x,t))return path.push_back(x),true;
    }
    return false;
}
int main(){
    int n;scanf("%d",&n);
    for(int i=1;i<n;i++){
        int x,y;scanf("%d%d",&x,&y);
        e[x].push_back(y);
        e[y].push_back(x);
    }
    int a=dfs1(1,0,1).second;
    int b=dfs1(a,0,1).second;
    dfs2(a,0,b);
    len=path.size();
    for(int i=1;i<=len;i++)
        sz[i]=e[path[i-1]].size()-1-(i!=1&&i!=len),sz[0]+=sz[i];
    if(sz[0]+len!=n){
        cout<<"-1\n";
        return 0;
    }
    auto ans1=gen();
    reverse(sz+1,sz+len+1);
    auto ans2=gen();
    auto ans=min(ans1,ans2);
    for(int i=0;i<n;i++)
        cout<<ans[i]<<" \n"[i==n-1];
    return 0;
}

Measured memory_bytes: 16120
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <cmath>
#include <deque>
#include <iterator>
#include <map>
#include <queue>
#include <string>
#include <tuple>
#include <utility>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
template<class T> inline bool chmax(T& a, T b) {if (a<b) {a=b; return true;} return false;}
template<class T> inline bool chmin(T& a, T b) {if (a>b) {a=b; return true;} return false;}

vll parent(100);
vll size(100);

ll root(ll i) {
  if (parent.at(i) != i) parent.at(i) = root(parent.at(i));
  return parent.at(i);
}

bool same(ll i, ll j) {
  return root(i) == root(j);
}

void unite(ll i, ll j) {
  ll pi = root(i), pj = root(j);
  if (pi == pj) return;
  if (size.at(pi) < size.at(pj)) parent.at(pi) = pj;
  else if (size.at(pi) > size.at(pj)) parent.at(pj) = pi;
  else {
    if (pi < pj) {
      parent.at(pj) = pi; size.at(pi)++;
    } else {
      parent.at(pi) = pj; size.at(pj)++;
    }
  }
}

int main() {
  ll n; cin >> n;
  REP(i, n) parent.at(i) = i;
  priority_queue<vll, vvll, greater<vll> > pq;
  REP(i, n) REP(j, n) {
    ll c; cin >> c;
    if (i >= j) continue;
    if (c != -1) {
      vll p; p.push_back(c); p.push_back(i); p.push_back(j);
      pq.push(p);
    }
  }
  ll ans = 0;
  while (!pq.empty()) {
    vll q = pq.top(); pq.pop();
    if (root(q.at(1)) == root(q.at(2))) continue;
    else {
      ans += q.at(0);
      unite(q.at(1), q.at(2));
    }
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 3236
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <numeric>
#include <iterator>

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int,int> PII;
typedef vector<PII> VPII;
typedef istringstream ISS;
typedef ostringstream OSS;

#define REP( i, m, n ) for ( int i = (int)( m ); i < (int)( n ); ++i )
#define FOR( v, c ) for ( auto &v : c )
#define EACH( it, c ) for ( auto it = c.begin(); it != c.end(); ++it )
#define ALL( c ) (c).begin(), (c).end()
#define DRANGE( c, p ) (c).begin(), (c).begin() + p, (c).end()

#define PB( n ) push_back( n )
#define MP( a, b ) make_pair( ( a ), ( b ) )
#define EXIST( c, e ) ( (c).find( e ) != (c).end() )

#define fst first
#define snd second

#define DUMP( x ) cerr << #x << " = " << ( x ) << endl
#define DEBUG( x ) cerr << __FILE__ << ":" << __LINE__ << ": " << #x << " = " << ( x ) << endl

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

	for ( int n, m; cin >> n >> m, n | m; )
	{
		VI cs( m ), xs( n );
		FOR( c, cs )
		{
			cin >> c;
		}
		FOR( x, xs )
		{
			cin >> x;
		}

		VVI dp( n + 1, VI( 256, INT_MAX / 2 ) );
		dp[0][128] = 0;

		REP( i, 0, n )
		{
			REP( j, 0, 256 )
			{
				REP( k, 0, m )
				{
					int nextx = j + cs[k];
					nextx = min( nextx, 255 );
					nextx = max( nextx, 0 );
					dp[ i + 1 ][ nextx ] = min( dp[ i + 1 ][ nextx ], dp[i][j] + ( xs[i] - nextx ) * ( xs[i] - nextx ) );
				}
			}
		}

		cout << *min_element( ALL( dp.back() ) ) << endl;
	}

	return 0;
}

Measured memory_bytes: 22008
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
int main() {
  int n;
  cin>>n;
  char c;
  string ans="Three";
  rep(i,n){
    cin>>c;
    if(c=='Y'){
      ans="Four";
      break;
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
#define MOD 1000000007
int main(){
  int n;
  string s;
  cin >> n >> s;
  int a[26];
  for(int i=0;i<26;i++) a[i]=1;
  for(int i=0;i<n;i++){
    a[(int)s.at(i)-(int)'a']++;
  }
  long long res=1;
  for(int i=0;i<26;i++){
    res*=a[i];
    res=res%MOD;
  }
  res=res-1;
  if(res<0){
    res=MOD-1;
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 512
N = int(input())

alphabet = [chr(i) for i in range(97, 97+26)]
name = []

def naming(N):
    if(N == 0):
        name.reverse()
        print(''.join(name))
    else:
        a = N // 26
        b = N % 26
        if(b == 0):
            b = 26
            a -= 1
        name.append(alphabet[b-1])

        naming(a)

naming(N)


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

#define INF 1000000007
#define LINF 1000000000000000007

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;


int h, w, a[501][501];
vector<P> v1, v2;

int main(){
	cin >> h >> w;
	for(int i = 0; i < h; i++){
		for(int j = 0; j < w; j++){
			cin >> a[i][j];
			a[i][j] %= 2;
		}
	}
	
	for(int i = 0; i < h; i++){
		for(int j = 0; j < w; j++){
			if(!a[i][j]) continue;
			else if(j < w-1){
				a[i][j] = 0;
				if(a[i][j+1]) a[i][j+1] = 0;
				else a[i][j+1] = 1;
				v1.push_back(make_pair(i,j));
				v2.push_back(make_pair(i,j+1));
			}
			else if(i < h-1){
				a[i][j] = 0;
				if(a[i+1][j]) a[i+1][j] = 0;
				else a[i+1][j] = 1;
				v1.push_back(make_pair(i,j));
				v2.push_back(make_pair(i+1,j));
			}
		}
	}
	
	cout << v1.size() << endl;
	for(int i = 0; i < v1.size(); i++){
		cout << v1[i].first+1 << " " << v1[i].second+1 << " " << v2[i].first+1 << " " << v2[i].second+1 << endl;
	}
	
	return 0;
}

Measured memory_bytes: 7268
b=int(input())
a = [int(i) for i in input().split()]
a.insert(0,0)
for i in range(1,b+1):
  if a[i-1] == a[i]:
    continue
  else:
    a[i] -= 1

for i in range(b):
  if a[i] > a[i+1]:
    print('No')
    exit()
print('Yes')

Measured memory_bytes: 14396
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#define mymalloc(p,n) {p = malloc((n)*sizeof(*p));if ((p)==NULL) {printf("not enough memory?\n"); exit(1);};}

typedef struct obj{
	struct obj *prev;
	struct obj *next;
	char *name;
	int time;
}obj;

typedef struct{
	struct obj *root;
	struct obj *last;
}queue;

obj *createObj(char *name, int time){
	obj *ob;
	mymalloc(ob,1);
	ob->prev=NULL;
	ob->next=NULL;
	ob->name=name;
	ob->time=time;
	return ob;
}

queue *createQueue(){
	queue *Q;
	mymalloc(Q,1);
	Q->root=NULL;
	Q->last=NULL;
}

void enqueue(queue *Q,obj *input){
	if(Q->root==NULL){
		Q->root=input;
		Q->last=input;
	}
	else{
		Q->root->prev=input;
		input->next=Q->root;
		Q->root=input;
	}
}

obj *dequeue(queue *Q){
	obj *output;
	if(Q->last==NULL){
		return NULL;
	}
	else{
		output=Q->last;
		if(Q->last->prev==NULL){
			Q->last=NULL;
			Q->root=NULL;
		}
		else{
			Q->last=Q->last->prev;
		}
		return output;
	}
}
	
main(){
	int i,n,q,time;
	int clock;
	char buf[12],*name;
	obj *prcs,*prcs2;
	queue *Q;
	Q=createQueue();
	scanf("%d	%d",&n,&q);
	
	for(i=1;i<=n;i++){
		scanf(" %s %d",buf,&time);
		name=strdup(buf);
		enqueue(Q,createObj(name,time));
	}
	
	
	clock=0;
	prcs=dequeue(Q);
	while(prcs!=NULL){
		if(prcs->time<=q){
			clock+=prcs->time;
			printf("%s %d\n",prcs->name,clock);
		}
		else{
			clock+=q;
			prcs2=createObj(prcs->name,prcs->time-q);
			enqueue(Q,prcs2);
		}
		prcs=dequeue(Q);
	}
	return 0;
}

Measured memory_bytes: 11036
#include<stdio.h>
#include<iostream>
#include<cstdlib>
using namespace std;

int a,b,c,d;
int main (){
    cin >> a >> b >> c >> d;
    if( abs(a - c) <= d || (abs(a-b) <=d && abs(b-c) <=d)) cout << "Yes" << endl;
    else {
        cout << "No" << endl;
    }
    return 0;
}


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

using namespace std;

void solve() {
    int n; cin >> n;
    for (int i = 0; i < n; i++) {
        int v; cin >> v;
        if (v % 2 == 0 && !(v % 3 == 0 || v % 5 == 0)) {
            cout << "DENIED"; return;
        }
    }
    cout << "APPROVED";
}

int main() {
    ios::sync_with_stdio(NULL), cin.tie(0), cout.tie(0);
    cout.setf(ios::fixed), cout.precision(20);
    solve();
}


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

int main()
{
    ll n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n)
    {
        cin >> a[i];
    }
    ll s = a[0];
    ll l = 0;
    ll r = 1;
    ll ans = n;
    while (r < n)
    {
        while (s & a[r])
        {
            s -= a[l++];
        }
        ans += (r - l);
        s += a[r];
        r++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 1792
from collections import deque

d=deque()
cur=0
n=int(input())

for i in range(n):
    q=list(map(int,input().split()))
    if q[0]==0:
        d.append(q[1])
    elif q[0]==1:
        d.rotate(q[1])
        cur-=q[1]
    else:
        d.pop()
        
d.rotate(cur)
d.reverse()

for i in d:
    print(i)


Measured memory_bytes: 21672
#include <bits/stdc++.h>
#define fio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;
typedef long long ll;
int main() {fio; // remove during scanf
	ll N;
	cin >> N;
	vector <ll> A(N);
	map <ll, ll> cnt;
	ll ans = 0;
	ll cur = 0;
	cnt[0] = 1;
	for(int i = 0; i < N; i++) {
		cin >> A[i];
		cur += A[i];
		ans += cnt[cur];
		cnt[cur]++;
	}

	cout << ans;
    return 0;
}

Measured memory_bytes: 14336
#include <bits/stdc++.h>
using namespace std;
#define REP(i, s, n) for (int i = s; i < n; ++i)
#define rep(i, n) REP(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG true
// sort(a.begin(), a.end(), std::greater<int>());

/*
std::vector<std::string> split(const std::string &input, char delimiter)
{
    std::istringstream stream(input);

    std::string field;
    std::vector<std::string> result;
    while (std::getline(stream, field, delimiter))
    {
        result.push_back(field);
    }
    return result;
}
*/
/*
int dfs(int foo, int timer)
{
    //foo is node number
    if (finds[foo].first != -1)
        return timer;
    finds[foo].first = ++timer;
    int result = timer;
    if (data[foo].size() != 0)
    {
        rep(i, data[foo].size())
        {
            result = dfs(data[foo][i], result);
        }
    }
    finds[foo].second = ++result;
    return result;
}
*/

int main()
{

    string a,b;
    cin>>a>>b;
    if(a[0]==b[2] &&a[1]==b[1]&&a[2]==b[0])
    {
        cout<<"YES"<<endl;
    }
    else{
        cout<<"NO"<<endl;
    }
    return 0;
}


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

#define ln '\n'
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define FOR(i, a, b) for (int i = (a); i <= (int)(b); ++i)
#define FORR(i, a, b) for (int i = (a); i >= (int)(b); --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef vector<P> VP;
typedef vector<PL> VPL;
typedef vector<string> VS;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int r;
    cin >> r;
    cout << 3 * r * r << ln;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,b,a) for(int i=b;i>=a;i--)
#define fori(a) for(auto i : a )
#define all(a) begin(a), end(a)
#define set(a,b) memset(a,b,sizeof(a))
#define vi vector<int>
#define vvi vector<vector<int>>
#define ll long long
#define ull unsigned long long
#define pb push_back
#define PF push_front //deque
#define mp make_pair
#define pq priority_queue
#define mod 1000000007
#define f first
#define s second
#define pii pair< int, int >
#define tc int t; cin >> t; while(t--)
using namespace std;
void fastio()
{
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
}
int main()
{
    fastio();
    int n;
    cin>>n;
    vector<int> a(n);
    for(int i = 0; i<n; i++)cin>>a[i];
    int dp[n];
    dp[0] = 0;
    dp[1] = abs(a[1]-a[0]);
    for(int i = 2; i<n; i++)
    {
        dp[i] = min(dp[i-1]+abs(a[i]-a[i-1]),dp[i-2]+abs(a[i]-a[i-2]));
    }
    cout<<dp[n-1];
}


Measured memory_bytes: 1024
#include<iostream>
#include<bits/stdc++.h>
#include<iomanip>
#include<math.h>
#include<vector>
#include<cctype>
#include<string>
#include<set>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
std::string line;
typedef long long ll;

int main(){
   int n;
   cin >> n;
   vector<int> l(n);
   vector<int> r(n);
   rep(i,n) cin >> l[i] >> r[i];

   int ans = 0;
   rep(i,n){
      ans += r[i] - (l[i]-1);
   }
   cout << ans << endl;

   return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <vector>
#include <string>
#include <sstream>

using namespace std;

class edge {
public:
  int weight;
  int nodeIdx;
  edge(int w, int i) {
    weight = w;
    nodeIdx = i;
  }
};

class node {
public:
  vector<edge> next;
  int height;
  int diameter;
  bool visited;

  node() {
    height = 0;
    diameter = 0;
    visited = false;
  }
};

void solve(vector<node> &tree, int idx) {
  //cout << "called for node: " << idx << endl;
  // if (tree[idx].visited) return;
  tree[idx].visited = true;

  int bestHeight  = 0, bestHeight2 = 0, bestDiameter = 0, h;

  for (int i = 0; i < tree[idx].next.size(); i++) {
    int nextIdx = tree[idx].next[i].nodeIdx;
    if (tree[nextIdx].visited) continue;

    //cout << idx << " next-> " << nextIdx << endl;
    solve(tree, nextIdx);

    bestDiameter = max(bestDiameter, tree[nextIdx].diameter);
    int h = tree[nextIdx].height + tree[idx].next[i].weight;

    if (h > bestHeight) {
      bestHeight2 = bestHeight;
      bestHeight = h;
    } else if (h > bestHeight2) {
      bestHeight2 = h;
    }
  }

  tree[idx].height = bestHeight;
  tree[idx].diameter = max(bestDiameter, bestHeight + bestHeight2);
  //cout << "Node: " << idx << " H: " << tree[idx].height << " D: " << tree[idx].diameter << " bestDiameter: " << bestDiameter << endl << endl;
}

int main() {

  int n;
  cin >> n;

  vector<node> tree(n);

  for (int i = 0, s, t, w; i < n - 1; i++) {
    cin >> s >> t >> w;

    tree[s].next.push_back(edge(w, t));
    tree[t].next.push_back(edge(w, s));
  }

  solve(tree, 0);
  cout << tree[0].diameter << endl;


  return 0;
}



Measured memory_bytes: 17524