akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <math.h>
#include <cmath>
using namespace std;

int main()
{
	int n;
	double x[100] = { 0 }, y[100] = { 0 }, p_1 = 0, p_2 = 0, p_3 = 0, p_infinity = -1;
	scanf("%d", &n);
	for (int i = 0; i < n; i++) scanf("%lf", &x[i]);
	for (int i = 0; i < n; i++) scanf("%lf", &y[i]);

	for (int i = 0; i < n; i++) {
		p_1 += abs(x[i] - y[i]);
		p_2 += pow(abs(x[i] - y[i]), 2.0);
		p_3 += abs((x[i] - y[i])*(x[i] - y[i])*(x[i] - y[i]));
		p_infinity = (p_infinity >= abs(x[i] - y[i])) ? p_infinity : abs(x[i] - y[i]);
	}
	printf("%.6lf\n",p_1);
	printf("%.6lf\n",sqrt(p_2));
	printf("%.6f\n", cbrt(p_3));
	printf("%.6lf\n", p_infinity);
    return 0;
}




Measured memory_bytes: 2940
#include<cstdio>

int n, m;
int s[111111];

int main() {
	scanf("%d%d", &n, &m);
	for(int i=0;i<m;i++) {
		int a, b;
		scanf("%d%d", &a, &b);
		s[a] = 1 - s[a];
		s[b] = 1 - s[b];
	}
	for(int i=1;i<=n;i++) {
		if(s[i]) {
			puts("NO");
			return 0;
		}
	}
	puts("YES");
	
	return 0;
}

Measured memory_bytes: 512
#include<cstdio>
#include<algorithm>
using namespace std;
int H, W, n, sx, sy;
int w[201000][2];
char p[201000], q[201000];
bool OK(int K, int M) {
	int i, t = K;
	for (i = 1; i <= n; i++) {
		if (w[i][0] == 1)t++;
		if (t > M)return true;
		if (w[i][1] == -1 && t > 1)t--;
	}
	return false;
}
int main() {
	int i;
	scanf("%d%d%d%d%d", &H, &W, &n, &sx, &sy);
	scanf("%s", p + 1);
	scanf("%s", q + 1);
	for (i = 1; i <= n; i++) {
		if (p[i] == 'U')w[i][0] = -1;
		else if (p[i] == 'D')w[i][0] = 1;
		else w[i][0] = 0;
		if (q[i] == 'U')w[i][1] = -1;
		else if (q[i] == 'D')w[i][1] = 1;
		else w[i][1] = 0;
	}
	if (OK(sx, H)) {
		puts("NO");
		return 0;
	}
	for (i = 1; i <= n; i++) {
		if (p[i] == 'U')w[i][0] = 1;
		else if (p[i] == 'D')w[i][0] = -1;
		else w[i][0] = 0;
		if (q[i] == 'U')w[i][1] = 1;
		else if (q[i] == 'D')w[i][1] = -1;
		else w[i][1] = 0;
	}
	if (OK(H-sx+1, H)) {
		puts("NO");
		return 0;
	}
	for (i = 1; i <= n; i++) {
		if (p[i] == 'L')w[i][0] = -1;
		else if (p[i] == 'R')w[i][0] = 1;
		else w[i][0] = 0;
		if (q[i] == 'L')w[i][1] = -1;
		else if (q[i] == 'R')w[i][1] = 1;
		else w[i][1] = 0;
	}
	if (OK(sy, W)) {
		puts("NO");
		return 0;
	}
	for (i = 1; i <= n; i++) {
		if (p[i] == 'L')w[i][0] = 1;
		else if (p[i] == 'R')w[i][0] = -1;
		else w[i][0] = 0;
		if (q[i] == 'L')w[i][1] = 1;
		else if (q[i] == 'R')w[i][1] = -1;
		else w[i][1] = 0;
	}
	if (OK(W-sy+1, W)) {
		puts("NO");
		return 0;
	}
	puts("YES");
}

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

#define loop(i,a,b) for(ll i=a; i<b; i++)
#define rloop(i,a,b) for(ll i=a; i>b; i--)
#define all(var) var.begin(), var.end()
#define eloop(var) for(auto elem : var)
#define debug(x) cerr<<#x<<" ----> "<<x<<endl;
#define TC ll tt; cin>>tt; while(tt--)
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ size()
#define SET(a) memset(a,-1,sizeof(a))
#define CLR(a) memset(a, 0, sizeof(a))
#define INF 0x7fffffff
#define LINF 2000000000000000007
#define MOD 1000000007
#define MAX 100005
typedef long long ll;
typedef long double ld;
#define pll pair<ll,ll>
#define vll vector<ll>
#define vpl vector< pll >

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    // TC
    {
        ll n, c;
        cin>>n>>c;
        vll v(n);
        loop(i,0,n) cin>>v[i];
        sort(all(v));

        ll cnt=0;
        loop(i,0,c)
            cnt+= v[i];
        cout<<cnt<<'\n';
    }
    return 0;
}

Measured memory_bytes: 3580
#include <iostream>
#include <vector>
#include <queue>
#include <sstream>
#include <algorithm>
#include <bitset>
#include <limits>
#include <map>
#include <set>
#include <iomanip>
#include <cmath>

using namespace std;

typedef long long int ll;
typedef std::numeric_limits<double> dbl;
const long long int LL_INF=1LL<<60;

vector<string> split(const string& input, char delimiter)
{
    stringstream stream(input);
    
    string field;
    vector<string> result;
    while (getline(stream, field, delimiter)) {
        result.push_back(field);
    }
    return result;
}

//#define DEBUG

ll A, B, M, N, D, K, Q, W, H, T, X, Y;

int main()
{
    cin >> N;
    vector<ll> poll(N);
    for (auto& p : poll)
        cin >> p;

    sort(poll.rbegin(), poll.rend());

    vector<ll> HW;
    for (int i = 1; i < poll.size(); ++i) {
        if (poll[i-1] == poll[i]) {
            HW.push_back(poll[i]);
            ++i;
        }
        if (HW.size() == 2)
            break;
    }

    if (HW.size() < 2)
        cout << 0 << endl;
    else
        cout << HW[0] * HW[1] << endl;

    return 0;
}

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<vi> vvi;
typedef vector<ll> vl;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

#define INF 1<<30
#define LINF 1ll<<60ll
#define MOD 1000000007
#define pb(a) push_back(a)

#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) _repi(i,0,n)
#define _repi(i,a,b) for(int i=a, i##_len=(b); i<i##_len; ++i)
#define REP(...) _overload3(__VA_ARGS__,_repi,_rep,)(__VA_ARGS__)

#define REPR(i, n) for(int i = n;i >= 0;--i)
#define REPARR(i, v) for(int i = 0;i < sz(v);++i)

#define all(vec) (vec.begin()),(vec.end())
#define sz(x) ((int)(x).size())
#define bit(n) (1ll<<(n))

template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}

#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define yes(n) cout<<((n)?"yes":"no")<<endl
#define poss(n) cout<<((n)?"possible":"impossible")<<endl
#define Poss(n) cout<<((n)?"Possible":"Impossible")<<endl


int main(){
    string s;
    cin>>s;
    while(sz(s)){
        if(s.substr(0,8)=="dreamera")s=s.substr(5);
        else if(s.substr(0,7)=="dreamer")s=s.substr(7);
        else if(s.substr(0,6)=="eraser")s=s.substr(6);
        else if(s.substr(0,5)=="erase")s=s.substr(5);
        else if(s.substr(0,5)=="dream")s=s.substr(5);
        else{
            YES(0);
            return 0;
        }
    }
    YES(1);
    return 0;
}


Measured memory_bytes: 512
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn read_vec2<T: std::str::FromStr>(n: usize) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

fn read_col<T: std::str::FromStr>(n: usize) -> Vec<T> {
    (0..n).map(|_| read()).collect()
}

fn main() {
    let nm: Vec<usize> = read_vec();
    let n = nm[0];
    let m = nm[1];
    let av: Vec<usize> = read_col(m);
    let mut dp: Vec<u64> = vec![1; 100001];
    for a in av {
        dp[a] = 0;
    }

    for i in 2..(n + 1) {
        if dp[i] > 0 {
            dp[i] = (dp[i - 2] + dp[i - 1]) % 1000000007;
        }
    }

    println!("{}", dp[n]);
}


Measured memory_bytes: 6396
#include <bits/stdc++.h>
using namespace std;
#define repr(i,k,n) for(int i = (k); i < (n); i++)
#define rep(i,n) repr(i,0,n)
#define ALL(a) begin(a),end(a)
const int MOD = 1000000007;
typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
int ctoi(const char c){
  switch(c){
    case '0': return 0;
    case '1': return 1;
    case '2': return 2;
    case '3': return 3;
    case '4': return 4;
    case '5': return 5;
    case '6': return 6;
    case '7': return 7;
    case '8': return 8;
    case '9': return 9;
  }
}
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int A, P;
    cin >> A >> P;
    cout << (A*3+P) / 2 << endl;
}

Measured memory_bytes: 256
// #define _CRT_SECURE_NO_WARNINGS
// #define _USE_MATH_DEFINES	// M_PI=3.1415...
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <locale>
#include <cctype>
#include <sstream>
#include <iomanip>	// 20桁出力 cout << setprecision(20) << double;
#include <queue>
#include <bitset>	// bitset<8> bs1(131uL); // 10000011 bs1[0]は1 01stringからビット集合生成可
using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<LL> VL;
typedef map<int, int> MAPII;
typedef multimap<int, char, greater<int> > MuMAPIC;
typedef vector<pair<int, int> > VPII;
typedef multimap<int, string, greater<int> > MuMIS;
typedef pair<int, int> P;
typedef pair<int, pair<P, P> > PP;

#define INF 999999999999999997;
#define MP make_pair
#define FAST_IO  cin.tie(0); ios::sync_with_stdio(false);
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORL(i,a,b) for(LL i=(a);i<(b);i++)
#define FOR_REV(i,a,b) for(int i=(a);i>=(b);i--)
//for gcc (未test)
// #define FOREACH_IT(it,c) for(typeof(c)::iterator it=(c).begin(); it!=(c).end(); ++it)
//for Visual Studio
#define foreach_it(type,it,c) for(type::iterator it=c.begin(),c_end=c.end();it!=c_end;++it)
#define FOR_ITR(d) for(auto itr=d.begin(),d_end=d.end();itr!=d_end;++itr)	// C++11
// for Debug.
#define DUMP_VVI(b) FOR(i,0,b.size()){FOR(j,0,b[i].size())printf("%d ",b[i][j]);puts("");}
#define D_OUT(str,value) if(dbgF){cout<<str<<" : "<<value<<endl;}
// 入力をpush_back(d)やarray[d]に使う時に1行で書ける
// int INPUT_INT() {int d;cin>>d;return d;}
template<class T>T IN() { T d; cin >> d; return d; }
// 最大公約数（Greatest Common Divisor）
LL gcd(LL a, LL b) { return (b > 0) ? gcd(b, a%b) : a; }
// 最小公倍数（Least Common Multiple）
LL lcm(LL a, LL b) { return a / gcd(a, b) * b; }
// Y年はうるう年か否か
bool uruu(LL Y) { return (((Y % 4 == 0 && Y % 100 != 0) || Y % 400 == 0) ? true : false); }

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

// vector注意
// vec[i][j]の形に入力を入れるとき、vecは初期化してある必要がある.

// ------------------- include, typedef, define END. -------------------

int main() {
	FAST_IO;
	// for D_OUT(str, value)  ... cout<< str <<" : "<< value <<endl;
	bool dbgF = true;

	//コードはここから書く.

	// N(つまりsの長さ及びtの長さ)に依存しないコードを書いてみた。
	int N;
	string s, t;
	cin >> N >> s >> t;
	int ans = s.length() + t.length();

	FOR(i, 0, s.length()) {
		// iはsのindex
		if (s.substr(i) == t.substr(0, s.substr(i).length())) {
			ans -= s.substr(i).length();
			break;
			/* breakしないと以下のようなテストケースでWAする
			 * 8
			 * abcdefef
			 * efefghij
			 */
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		int year;
		long money;
		double X;
		Scanner sc = new Scanner(System.in);
		
		X = Double.parseDouble(sc.next());
		sc.close();
		
		money = 100;
		for(year = 0;money < X;year++,money *= 1.01);
		
		System.out.println(year);
	}
}


Measured memory_bytes: 35840
s = input()
l = len(s)
dig = [1]
for x in range(l-1):
  dig.append(2**x)

ans = 0
for x in range(l):
  n = int(s[x])
  for y in range(l):
    ans += n * dig[y] * (10**(l-y-1))
  dig[x] = 0
  if x < l-1:
    dig[x+1] *= 2
print(ans)

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

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

int main(){
    string S;
    cin >> S;
    int size = (int)S.size();
    int length = 0;
    int max_length = 0;
    rep(i, size){
        if(S.at(i) == 'A' || S.at(i) == 'C' || S.at(i) == 'G' || S.at(i) == 'T'){
            length++;
            if(length > max_length){
                max_length = length;
            }
        }else{
            length = 0;
        }
    }

    cout << max_length << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;
int N_MAX = 100001;
long long INF=123456789123456789;
typedef pair<int,long long> P;
typedef pair<P,int> PP;
int main()
{
  int n,m,l,r,i;
  long long c;
  long long res[N_MAX];
  PP pp;
  priority_queue<PP,vector<PP>,greater<PP>> q;
  cin >> n >> m;
  res[1]=0;
  fill(res+2,res+n+1,INF);
  for(i=0;i<m;i++){
    cin >> l >> r >> c;
    q.push(PP(P(l,c),r));
  }
  pp=q.top();
  if(pp.first.first>1){
    cout << "-1" << endl;
    return 0;
  }
  while(!q.empty()){
    pp=q.top(); q.pop();
    l=pp.first.first;
    c=pp.first.second;
    r=pp.second;
    for(i=r;i>l;i--)
      if(res[l]+c<res[i]){
        res[i]=res[l]+c;
      }else{
        break;
      }
  }
  if(res[n]==INF)
    cout << "-1" << endl;
  else
    cout << res[n] << endl;
  return 0;
}

Measured memory_bytes: 5492
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N = int(readline())
    S = readline().strip()

    ans = 0
    for i in range(1, N):
        tmp = len(set(S[:i]) & set(S[i:]))
        if ans < tmp:
            ans = tmp

    print(ans)
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 9164
n = int(input().strip())
S = [input().split() for i in range(n)]

mx=0

S.sort()
ni=0
ans=[]
for i in range(n):
    if ni>mx:
        ans=S[i]
        mx=ni
    elif ni==mx:
        ans+=S[i]
    if i<n-1:
        if S[i+1]==S[i]:
            ni+=1
        else:
            ni=0

    
[print(i) for i in ans]

Measured memory_bytes: 56340
n, k = [int(i) for i in input().split()]
d = [int(i) for i in input().split()]
ans = n
f = False
while True:
    for dd in d:
        if str(dd) in str(ans):
            f = True
            break
    if not f:
        break
    f = False
    ans += 1

print(ans)

Measured memory_bytes: 73696
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define in(x) cin >> x
#define out(str) cout << str << endl

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int mod=1000000007;
int N,M;

long long kaijo(int X){
    long long ans=1;
    for(int i=1;i<=X;i++){
        ans=(ans*i)%mod;
    }
    return ans;
}

int main(){
    cin>>N>>M;
    if(abs(N-M)<=1){
        if(N==M){
            out((2*kaijo(N)*kaijo(M))%mod);
        }
        else{
            out((kaijo(N)*kaijo(M))%mod);
        }
    }
    else{
        out(0);
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<vector>
using namespace std;
 
int main() {
  long int a;
   long int b;
  long int c;
  cin>>a>>b;
  if(a==1||b==1){
    cout<<1;
    return 0;
  }
  c=a*b/2;
  if(a%2==1&&b%2==1)cout<<c+1;
  else cout<<c;
}


Measured memory_bytes: 256
let split_string ?(pattern="") = Str.split @@ Str.regexp pattern
let (h, w, k) = Scanf.sscanf (read_line ()) "%d %d %d" @@ fun h w k -> (h, w, k)
let ss = Array.init h @@ fun _ -> read_line ()

let rows = Array.init h @@ fun i -> String.length (Str.global_replace (Str.regexp "[^#]") "" ss.(i)) > 0
let ans = Array.make_matrix h w 0

let () =
  let num = ref 1 in
  Array.iteri (fun i s -> if rows.(i) then begin
    for j = 0 to w - 1 do
      if s.[j] = '#' then begin
        ans.(i).(j) <- !num;
        num := !num + 1
      end else if j > 0 && ans.(i).(j - 1)  > 0 then
        ans.(i).(j) <- ans.(i).(j - 1)
    done;
    for j = w - 2 downto 0 do
      if ans.(i).(j) = 0 then ans.(i).(j) <- ans.(i).(j + 1)
    done
  end) ss;
  for i = 0 to w - 1 do
    for j = 1 to h - 1 do
      if ans.(j).(i) = 0 && ans.(j - 1).(i) > 0 then ans.(j).(i) <- ans.(j - 1).(i)
    done;
    for j = h - 2 downto 0 do
      if ans.(j).(i) = 0 && ans.(j + 1).(i) > 0 then ans.(j).(i) <- ans.(j + 1).(i)
    done
  done;
  Array.iter (fun arr ->
    Array.map string_of_int arr |> Array.to_list |> String.concat " " |> print_endline
  ) ans

Measured memory_bytes: 7440
#include <stdio.h>
#include <stdlib.h>
#define ll long long
#define rep(i,l,r)for(ll i=l;i<r;i++)
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}

ll a[210];
int main(){
	ll n,l,r;
	while(scanf("%lld%lld%lld",&n,&l,&r),n){
		rep(i,0,n)scanf("%lld",a+i);
		sortdown(a,n);
		ll M=0;
		ll cnt;
		rep(i,l-1,r){
			if(M<=a[i]-a[i+1]){
				M=a[i]-a[i+1];
				cnt=i+1;
			}
		}
		printf("%lld\n",cnt);
	}
}


Measured memory_bytes: 2032
/*
  AUTHOR:SOURABH
  CREATED:23:06:20
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define ordered_set tree<pii , null_type, less< pii >, rb_tree_tag, tree_order_statistics_node_update>
#define ll long long int
#define ld long double
#define fi first
#define se second
#define pb push_back
#define pob pop_back
#define W while
#define fn(i,x) for(i=0;i<x;i++)
#define fs(i,s,x) for(i=s;i<x;i++)
#define fr(i,x) for(i=x;i>=0;i--)
#define fit(it,s) for(it=s.begin();it!=s.end();it++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define mii map<int,int>
#define mll map<ll,ll>
#define mod 1000000007
#define MAX 100005
#define M 32

using namespace std;
using namespace __gnu_pbds;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);

    ll t,n,i,ans;
    string s,tt;
    t=1;
    //cin>>t;
    W(t--)
    {
        cin>>s>>tt;
        n=s.length();
        ans=0;
        fn(i,n)
        {
            if(s[i]!=tt[i])ans++;
        }
        cout<<ans;
    }
    return 0;
}



























Measured memory_bytes: 3796
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORS(i, m, n) for (int i = m; i <= n; i++)
#define BIT(n) (1LL << (n))
#define INF 2e9
#define MOD (1000000007)
#define EPS 1e-9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long long int lli;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int H, W;
  cin >> H >> W;
  vector< vector< int > > a(H + 1, vector< int >(W + 1));
  vector< vector< int > > save(H * W, vector< int >(4));

  REPS(i, H) {
    REPS(j, W) { cin >> a[i][j]; }
  }

  int count = 0;
  REPS(i, H) {
    REPS(j, W - 1) {
      int flg[2] = {a[i][j] % 2, a[i][j + 1] % 2};
      // 1 0 1 1
      if (flg[0]) {
        save[count][0] = i;
        save[count][1] = j;
        save[count][2] = i;
        save[count][3] = j + 1;
        count++;
        a[i][j + 1] += a[i][j];
        a[i][j] = 0;
        if (flg[1])
          j++;
      }
    }
  }
  REPS(i, H - 1) {
    int flg[2] = {a[i][W] % 2, a[i + 1][W] % 2};
    if (flg[0]) {
      save[count][0] = i;
      save[count][1] = W;
      save[count][2] = i + 1;
      save[count][3] = W;
      count++;
      a[i + 1][W] += a[i][W];
      a[i][W] = 0;
      if (flg[1])
        i++;
    }
  }
  /*
    REPS(i, H) {
      REPS(j, W) { cout << a[i][j] << " "; }
      cout << endl;
    }*/
  cout << count << "\n";
  REP(i, count) {
    cout << save[i][0] << " " << save[i][1] << " " << save[i][2] << " "
         << save[i][3] << "\n";
  }
}


Measured memory_bytes: 16768
#include <iostream>
#include <cmath>

#define PI 3.14159265

using namespace std;

void func_A() {

    double r;
    cin >> r;

    cout << 2 * PI * r;
}

void func_B() {

}

void func_C() {

}

int main() {

    func_A();
    //func_B();
    //func_C();

    return 0;
}


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

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

Measured memory_bytes: 640
N,M=map(int,input().split())
p_y=[]
for i in range(M):
    p,y=map(int,input().split())
    p_y.append([i+1,p,y])

p_c=[0]*N
p_y.sort(key=lambda x:x[2])
for k,a in enumerate(p_y):
    p_c[a[1]-1]+=1
    p_y[k].append(p_c[a[1]-1])
p_y.sort(key=lambda x:x[0])
for b in p_y:
    print(str(b[1]).zfill(6)+str(b[3]).zfill(6))

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

int main() {

    int a;
    cin >> a;
    cout << a + a * a + a * a * a << endl;

    return 0;
}

Measured memory_bytes: 3596
# coding: utf-8
#a,bの最大公約数
def calcGCD(a, b):
    while b:
        a, b = b, a % b
    return a

#a,bの最小公倍数
def calcLCM(a, b):
    return a * b // calcGCD (a, b)

def countNum(ab, c, d, lcm):
    return ab // c + ab // d - ab // lcm

a, b, c, d = list(map(int, input().split()))
a -= 1
lcm = calcLCM(c, d)
print(b - a - (countNum(b, c, d, lcm) - countNum(a, c, d, lcm)))


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

#define ll long long
#define ld long double
#define pb push_back
#define eb emplace_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()

#define int long long
using namespace std;
const int INF = 2e16;
const int MOD = 1e9 + 7;
const int MB = 20;

int mod_pow(int a, int b) {
	if (!b) return 1;
	if (b % 2) return a * mod_pow(a, b - 1) % MOD;
	int q = mod_pow(a, b / 2);
	return q * q % MOD;
}

void solve() {
	int x, y;
	cin >> x >> y;
	vector<int> fact(max(x, y) + 1);
	fact[0] = 1;
	for (int i = 1; i < fact.size(); i++) {
		fact[i] = fact[i - 1] * i % MOD;
	}
	for (int i = 0; i <= x; i++) {
		if (y - i * 2 >= 0 && (x - i) % 2 == 0 && (x - i) / 2 == y - 2 * i) {
			int n = i + (x - i) / 2;
			int k = i;
			int one = fact[n] * mod_pow(fact[k], MOD - 2) % MOD;
			int two = one * mod_pow(fact[n - k], MOD - 2) % MOD;
			cout << two << '\n';
			return;
		}
	}
	cout << 0;
}
	

signed main() {
	/*
	freopen("search.in", "r", stdin);
	freopen("search.out", "w", stdout);
	*/
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	cout << fixed;
	cout.precision(12);
	solve();
}

Measured memory_bytes: 8064
import java.util.Scanner;

class Main{
	static Scanner s=new Scanner(System.in);
	static int gInt() {return Integer.parseInt(s.next());}
	static long gLong() {return Long.parseLong(s.next());}

	public static void main(String[]$){
		int r=0,i=gInt(),a=gInt(),b=gInt(),d;
		for(;i>0;--i) {
			d=(""+i).chars().map(v->v-'0').sum();
			if(a<=d&&d<=b)
				r+=i;
		}
		System.out.println(r);
	}
}

Measured memory_bytes: 31440
import math
while True:
    n = int(raw_input())
    if n == 0:
        break
    stdnt = map(int, raw_input().split())
    ave = 0
    for score in stdnt:
        ave += float(score)/n
    alpha = 0
    for score in stdnt:
        alpha += (score-ave) ** 2/n
    print math.sqrt(alpha)
    

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

#define int         long long
#define uint        unsigned int
#define ld          long double
#define showoff     ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb          push_back
#define pii         pair<int,int>
#define FOR(i,a,b)  for(int i=a;i<b;++i)
#define RFOR(i,a,b) for(int i=a;i>b;--i)
#define f           first
#define se          second
#define maxn        200005
#define all(v)      v.begin(),v.end()
#define sz(x)       (int)x.size()
#define mod         1000000007
#define pqueue      priority_queue<int>
#define pdqueue     priority_queue< pii,vector<pii> ,greater< pii >>

using namespace std;


//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

/*int power(int a,int n)
{
    if(n == 1)return a%mod;
    if(n == 0)return 1;
    if(n&1)return ((a%mod)*(power((a*a)%mod,n/2))%mod)%mod;
    return power((a*a)%mod,n/2)%mod;
}*/
//const int md = 998244353;

/*int inverse(int x){

    return power(x,mod-2)%mod;//little fermat....
}*/
const int inf = (int) 1e18;
const int md = (int) 1e9+21;


signed main()
{
    showoff;
    int n;
    cin >> n;
    int ans = 0,ma = 0,h[n+5];
    FOR(i,1,n+1){
        cin >> h[i];
        if(h[i] >= ma)++ans;
        ma = max(ma,h[i]);
    }
    cout << ans;
    return 0;
}
//*->for large size of matrix take int not long long if possible......
//*->always take maximum as inf for safer side ...


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF=100100100;
const int MOD=(int)1e9+7;
#define ALL(a) a.begin(),a.end()
#define REP(i,n) for(int i=0; i<n; i++)
#define FOR(i,a,b) for(int i=a; i<b; i++)

int main(){
    int n;
    string s;
    cin>>n>>s;
    REP(i,s.size()){
        REP(j,n){
        s.at(i)++;
        if(s.at(i)=='[') s.at(i)='A';
        }
    }
    cout<<s<<endl;
}

Measured memory_bytes: 256
#include<cstdio>
long N,h,n,t1,t2;
int main(){
	scanf("%d",&N);
	for(h=1;h<=3500;h++){
		for(n=1;n<=3500;n++){
			t1=N*h*n;
			t2=4*h*n-N*(h+n);
			if(t1>0&&t2>0&&t1%t2==0){
				printf("%ld %ld %ld",h,n,t1/t2);
				return 0;
			}
		}
	}
	return 0;
}


Measured memory_bytes: 128
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		Main mainObj = new Main();
		mainObj.solve();
	}

	public void solve() throws IOException {
		FastScanner fs = new FastScanner();
		
		double a = (double)fs.nextInt();
		double b = (double)fs.nextInt();
		double x = (double)fs.nextInt();
		
		double v = a *  a *  b;
		
		if(x == v/2) {
			System.out.println(45.0000000000);
			return;
		}
		if(x==v) {
			System.out.println(0.000000);
			return;
		}
		
		if(x < v/2) {
			System.out.println(90-Math.toDegrees(Math.atan(2*x/(a*b*b))));
		}else {
			System.out.println(90-Math.toDegrees(Math.atan((a*a*a) / (2*(v-x)))));
		}
	}

	

	public class FastScanner {

		BufferedReader reader;
		private StringTokenizer st;

		public FastScanner() {
			st = null;
			reader = new BufferedReader(new InputStreamReader(System.in));
		}

		public String next() throws IOException {
			if (st == null || !st.hasMoreElements()) {
				st = new StringTokenizer(reader.readLine());
			}
			return st.nextToken();
		}

		public String nextLine() throws IOException {
			st = null;
			String readLine = null;
			readLine = reader.readLine();
			return readLine;
		}

		public int nextInt() throws NumberFormatException, IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws NumberFormatException, IOException {
			return Long.parseLong(next());
		}

		public int[] nextIntArr(int n) throws NumberFormatException, IOException {
			int[] retArr = new int[n];
			for (int i = 0; i < n; i++) {
				retArr[i] = nextInt();
			}
			return retArr;
		}

		public long[] nextLongArr(int n) throws NumberFormatException, IOException {
			long[] retArr = new long[n];
			for (int i = 0; i < n; i++) {
				retArr[i] = nextLong();
			}
			return retArr;
		}

		public void close() throws IOException {
			reader.close();
		}
	}

}


Measured memory_bytes: 22484
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>
#include <functional>
#include <map>
using namespace std;

int N, A[100009], sum = 0, minx = (1 << 30);

int main() {
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> A[i]; sum += A[i];
		if (A[i] % 2 == 1) minx = min(minx, A[i]);
	}
	if (sum % 2 == 0) cout << sum / 2 << endl;
	else {
		cout << (sum - minx) / 2 << endl;
	}
	return 0;
}


Measured memory_bytes: 3092
#include<bits/stdc++.h>
#include<array>
using namespace std;
using UL = unsigned;
using LL = long long;
using ULL = unsigned long long;
#define rep(i, n) for(UL i = 0; i < (n); i++)
void Solve() {
	UL x; cin >> x;
	if (x % 100 <= x / 100 * 5) cout << 1 << endl;
	else cout << 0 << endl;
}
int main() { Solve(); return 0; }


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

int main(){
	int n,l;
	cin>>n>>l;
	int a = l;
	int h = l+n-1;
	int flag;
	if(h<=0)flag=h;
	else if(l>=0)flag=l;
	else flag = 0;
	
	int ans = (a+h)*(h-a+1)/2-flag;
	cout<<ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <random>
#include <chrono>
 
using namespace std;
using namespace __gnu_pbds;
 
#define endl '\n'
 
typedef long long ll;
typedef pair<int, int> pii;
typedef tree<int, null_type,less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
template<typename T>
static T randint(T lo, T hi){
	return uniform_int_distribution<T>(lo, hi)(rng);
}



int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
 
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);

	const int D = 365;

	for(int i = 0; i < D; i++){
		int t = randint(1, 26);
		cout << t << endl;
	}


	return 0;
}

Measured memory_bytes: 3684
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
//const int64 INF = 1LL << 58;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);	
  	
  	string s;
  	cin >> s;
  	
  	int n = s.size();
    string rs = s;
  	reverse(all(rs));
  	int x =0;
  	rep(i,n/2){
      	if(s[i]!=rs[i]) x++;
    }
  	cout << x << endl;
  	return 0;
}

Measured memory_bytes: 256
'use strict';
(function(stdin) {
  var inputs = stdin.toString().trim().split('\n');

  (function(x) {
    // ????????????????????????
    console.log(Math.pow(x, 3));


  })(parseInt(inputs[0], 10)); // ??°?????????

}(require('fs').readFileSync('/dev/stdin', 'utf8')));

Measured memory_bytes: 15848
#ifndef ONLINE_JUDGE
#endif
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <bitset>
#include <string>
using namespace std;
const int maxn = 1e4;
bitset<maxn>b[maxn];

int main(int argc, char const *argv[])
{
	#ifndef ONLINE_JUDGE
	//freopen("in.txt", "r", stdin);
	#endif
	int r, c;
	while(scanf("%d%d", &r, &c) && r){
		for(int i = 0; i < r; i++){
			for(int j = 0; j < c; j++){
				int t;
				scanf("%d", &t);
				b[i][j] = t;
			}
		}
		int ans = 0;
		for(int i = 0; i < (1<<r); i++){
			for(int j = 0; j < r; j++){
				if(i & (1 << j)){
					b[j].flip();
				}
			}
			int sum = 0;
			for(int j = 0; j < c; j++){
				int t = 0;
				for(int k = 0; k < r; k++){
					if(b[k][j]) t++;
				}
				sum += min(t, r-t);
			}
			ans = max(ans, r*c-sum);
			for(int j = 0; j < r; j++){
				if(i & (1 << j)){
					b[j].flip();
				}
			}
		}
		cout << ans << endl;
	}
	return 0;
}



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

const int N=1e6+5;
int n,p,cur,cnt[N],val[N];
string s;

main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    //freopen("SSMOD.inp","r",stdin);
    //freopen("SSMOD.out","w",stdout);
	cin>>n>>p>>s;
	int ans=0;
	int q=p;
	int t=1;
	while(q%2==0) q/=2,t*=2;
	while(q%5==0) q/=5,t*=5;
    for(int i=0;i<n;i++)
    {
        int now=0;
        for(int j=i;j<min(n,i+20);j++)
        {
            now=(now*10+s[j]-'0')%p;
            if(now==0) ans++;
        }
    }
    cur=0;
    int now=1;
    for(int i=n-1;i>=0;i--)
    {
        (cur+=(s[i]-'0')*now)%=q;
        val[i]=cur;
        now=now*10%q;
    }
    cnt[val[0]]++;
    for(int i=20;i<n;i++)
    {
        int l=i-19;
        int now=0;
        for(int j=l;j<=i;j++) now=(now*10+s[j]-'0')%t;
        if(now==0) ans+=cnt[val[i+1]];
        cnt[val[l]]++;
    }
	cout<<ans;
}


Measured memory_bytes: 4244
import bisect

N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

A.sort()
B.sort()
C.sort()

S = 0
for b in B:
    a = bisect.bisect_left(A, b)
    c = bisect.bisect_right(C, b)
    S += a * (N - c)
print(S)

Measured memory_bytes: 105444
#define _USE_MATH_DEFINES
#define INF 100000000
#include <iostream>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>

using namespace std;

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

static const double EPS = 1e-8;

int main(){
	int n,m;
	while(~scanf("%d %d",&n,&m)){
		if(n==m && m==0) break;

		vector<int> elapsedTime;
		elapsedTime.push_back(0);

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

		sort(elapsedTime.begin(),elapsedTime.end());

		int diff=0;
		for(int i=0;i+1<elapsedTime.size();i++){
			diff = max(diff,abs(elapsedTime[i+1]-elapsedTime[i]));
		}

		printf("%d\n",diff);
	}
}

Measured memory_bytes: 0
N, K = gets.split(" ").map(&:to_i)
x = gets.split(" ").map(&:to_i)
ans = 10**9
tmp = 0
(N - K + 1).times do |i|
    x[i] 
    if x[i + K - 1] < 0
        tmp = x[i].abs
        ans = tmp if ans > tmp
    elsif x[i] < 0 && x[i + K - 1] >= 0
        tmp = x[i + K - 1] - x[i]
        tmp += x[i].abs < x[i + K - 1] ? x[i].abs : x[i + K - 1]
        ans = tmp if ans > tmp
    else
        tmp = x[i + K - 1]
        ans = tmp if ans > tmp
    end
end

puts ans

Measured memory_bytes: 8460
group1 = [1, 3, 5, 7, 8, 10, 12]
group2 = [4, 6, 9, 11]
group3 = [2]

input = list(input().split())
input_x = int(input[0])
input_y = int(input[1])

exist_group1 = group1.count(input_x) + group1.count(input_y)
exist_group2 = group2.count(input_x) + group2.count(input_y)
exist_group3 = group3.count(input_x) + group3.count(input_y)

if exist_group1 == 2 or exist_group2 == 2 or exist_group3 == 2:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <vector>
#include <cstring>
#include <queue>
#include <map>
#include <set>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef vector<vector<int>> Graph;
const int dx[4] = {0,1,0,-1};
const int dy[4] = {1,0,-1,0};
template<class T> inline bool chmax(T &a,T& b){if(a < b){a = b; return true;} else return false;}
template<class T> inline bool chmin(T &a,T& b){if(a > b){a = b; return true;} else return false;}
//struct area

//function area

//main area
int main(){
    int x;
    cin >> x;
    int ax = x/100;
    int maru = x%100;
    cout << (ax*5 < maru ? 0 : 1) << endl;
}
/*

18027
ax = 180, maru = 27
180回で27を作れるか？
ax*5 <> maru

*/

Measured memory_bytes: 3540
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
int h,w,k;
char s[305][305];
int t;
bool T;
ll a;
ll ans[305][305];
int main(void){
	cin>>h>>w>>k;
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			cin>>s[i][j];
		}
	}
	a=1;
	for(int i=0;i<h;i++){
		t=0; T=false;
		for(int j=0;j<w;j++){
			if(s[i][j]=='#'){
				for(int l=t;l<=j;l++){
					ans[i][l]=a;
				}
				a++;
				t=j+1;
				T=true;
			}
		}
		if(T){
			for(int j=t;j<w;j++){
				ans[i][j]=a-1;
			}
		}
	}
	for(int i=1;i<h;i++){
		if(ans[i][0]==0){
			for(int j=0;j<w;j++){
				ans[i][j]=ans[i-1][j];
			}
		}
	}
	for(int i=h-2;i>=0;i--){
		if(ans[i][0]==0){
			for(int j=0;j<w;j++){
				ans[i][j]=ans[i+1][j];
			}
		}
	}
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			cout<<ans[i][j];
			if(j==w-1){
				cout<<endl;
			}else{
				cout<<" ";
			}
		}
	}
	
}


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

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

int main() {
	int N, M, C;
 	cin >> N >> M >> C;
  	vector<int> B(M);
	REP(i, 0, M) cin >> B[i];
  	vector< vector<int> > A (N, vector<int>(M));
	REP(i, 0, N) REP(j, 0, M) cin >> A[i][j];
  int Y = 0;
  	REP(i, 0, N){
      int X = 0;
      REP(j, 0, M)X = X+A[i][j]*B[j];
    if(X+C>0)Y++;
    }
    cout << Y << endl;
}

Measured memory_bytes: 256
# include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)

struct INIT{
    INIT(){
        std::ios::sync_with_stdio(false);
        std::cin.tie(0);
        cout << fixed << setprecision(13);
    }
}INIT;

LL h, w, n;
map<pair<int, int>, int> cnt;

int main(){
    cin >> h >> w >> n;
    REP(k, n){
        int a, b;
        cin >> a >> b;
        for(int i = -2;i <= 0;i++){
            for(int j = -2;j <= 0;j++){
                int ny = a + i;
                int nx = b + j;
                if(!(ny >= 1 && nx >= 1))continue;
                if(!(ny + 2 <= h && nx + 2 <= w))continue;
                cnt[make_pair(ny, nx)]++;
            }
        }
    }
    vector<LL> cnt2(10, 0);
    cnt2[0] = (h - 2)*(w - 2);
    for(auto it = cnt.begin();it != cnt.end();it++){
        cnt2[it->second]++;
        cnt2[0]--;
    }
    REP(i, 10){
        cout << cnt2[i] << endl;
    }
}

Measured memory_bytes: 56576
#include<iostream>
using namespace std;
int main(){
    int n,k,r,s,p;
    cin >> n >> k >> r >> s >> p;
    char t[100001];
    long long sum = 0;
    for(int i=0;i<n;i++){
        cin >> t[i];
        int tmp;
        switch(t[i]){
            case 'r' : sum+=p; tmp = p; break;
            case 's' : sum+=r; tmp = r; break;
            case 'p' : sum+=s; tmp = s; break;
        }
        if(i>=k && t[i] == t[i-k]){
            sum-=tmp;
            t[i] = 'a';
        }
    }
    cout << sum << endl;
}

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

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

	int arr[N];

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

	int dp[100005]={-1};

	dp[0]= 0;
	dp[1]= abs(arr[1]-arr[0]);

	for(int i=2;i<N;i++)
	{
		dp[i]= min(dp[i-1]+abs(arr[i]-arr[i-1]), dp[i-2]+ abs(arr[i]-arr[i-2]));
	}

	cout << dp[N-1] << endl;

	return 0;
}

Measured memory_bytes: 1024
#include <cstdio>
using namespace std;

int main(){
	int s;
	while(scanf("%d", &s), s){
		int x, y;
		int ans = -1;
		for(int i = 1; i <= 12; ++i){
			scanf("%d%d", &x, &y);
			s -= x - y;
			if(s <= 0 && ans == -1){
				ans = i;
			}
		}
		printf(ans == -1 ? "NA\n" : "%d\n", ans);
	}
}

Measured memory_bytes: 1028
#include "bits/stdc++.h"
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/pb_ds/tree_policy.hpp"

using namespace std;
using namespace __gnu_pbds;


#define ll long long int
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(a) a.begin(),a.end()

typedef tree <ll, null_type, less <ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// order_of_key(val): returns the number of values less than val
// find_by_order(k): returns an iterator to the kth largest element (0-based)

int main(void)
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n, i;
    cin >> n;
    ll a[n], x = 0;
    for(i = 0; i < n; i++) {
    	cin >> a[i];
    	x ^= a[i];
    }
    for(i = 0; i < n; i++) {
    	cout << (a[i] ^ x) << " ";
    }
    cout <<"\n";
}

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

int main(){
    ll n;
    cin >> n;
    vector <vector <ll>> gs(n,vector <ll> (2));
    ll x,l;

    rep(i,n){
        cin >> x >> l;
        gs[i][0]=x+l;
        gs[i][1]=x-l;
    }

    sort(gs.begin(),gs.end());
    ll g;
    g=gs[n-1][0];
    ll s=gs[0][0];
    ll k=1;
    rep(i,n){
        if(gs[i][1]>=s){
            s=gs[i][0];
            ++k;
        }
    }
    cout << k << endl;
    

    return 0;
}

Measured memory_bytes: 5760
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep1(i, n) for(int i = 1; i < n+1; i++)
#define sort(A) sort(A.begin(),A.end())
#define reverse(A) reverse(A.begin(),A.end());

int main(){
  int n,m,x;
  cin >> n >> m >> x;
  vector<int> v(n+1,0);
  rep(i,m){
    int tmp;
    cin >> tmp;
    v[tmp] = 1;
  }
  int ansL = 0;
  for(int i=1;i<x;i++){
    ansL += v[i];
  }
  int ansR = 0;
  for(int i=x+1;i<n;i++){
    ansR += v[i];
  }
  cout << min(ansL,ansR) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <cstring>
#include <functional>
#include <cmath>
#include <complex>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define rep1(i,n) for(int i=1;i<=(n);++i)
#define all(c) (c).begin(),(c).end()
#define fs first
#define sc second
#define pb push_back
#define show(x) cout << #x << " " << x << endl
#define chmin(x,y) x=min(x,y)
typedef pair<int,int> P;
int H,W,dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};//d,r,u,l
bool can[30][30][4];
int d[30][30][4][30][30];//(a,b)<-x->(a+,b+)
int dp[901][30][30],inf=1e9;
void bfs(int xx,int yy,int dd){
	queue<P> que;
	d[xx][yy][dd][H-1][W-1]=0;
	que.push(P(H-1,W-1));
	while(!que.empty()){
		P p=que.front();
		int x=p.fs,y=p.sc;
		que.pop();
		rep(di,4){
			if(!can[x][y][di]) continue;
			int nx=x+dx[di],ny=y+dy[di];
			if(d[xx][yy][dd][nx][ny]!=inf) continue;
			d[xx][yy][dd][nx][ny]=d[xx][yy][dd][x][y]+1;
			que.push(P(nx,ny));
		}
	}
}
int main(){
	while(true){
		cin>>H>>W;
		if(H==0) break;
		rep(i,H) rep(j,W) rep(di,4) can[i][j][di]=0;
		rep(i,H) rep(j,W) rep(k,H*W+1) dp[k][i][j]=inf;
		rep(i,H) rep(j,W) rep(di,4) rep(x,H) rep(y,W) d[i][j][di][x][y]=inf;
		rep(i,H){
			rep(j,W-1){
				int x;
				cin>>x;
				if(x==0){
					can[i][j][1]=1;
					can[i][j+1][3]=1;
				} 
			}
			if(i==H-1) break;
			rep(j,W){
				int x;
				cin>>x;
				if(x==0){
					can[i][j][0]=1;
					can[i+1][j][2]=1;
				}
			}
		}
		rep(xx,H) rep(yy,W) rep(dd,4){
			if(!can[xx][yy][dd]) continue;
			can[xx][yy][dd]=0;
			can[xx+dx[dd]][yy+dy[dd]][(dd+2)%4]=0;
			bfs(xx,yy,dd);
			can[xx][yy][dd]=1;
			can[xx+dx[dd]][yy+dy[dd]][(dd+2)%4]=1;
		}
		dp[0][0][0]=0;
		int ans=inf;
		rep(i,H*W){
//			show(i);
			rep(x,H) rep(y,W){
				if(dp[i][x][y]==inf) continue;
				rep(di,4){
					if(!can[x][y][di]) continue;
					int nx=x+dx[di],ny=y+dy[di];
					chmin(dp[i+1][nx][ny],max(dp[i][x][y],i+d[x][y][di][x][y]));
				}
			}
		}
		rep(i,H*W+1){
//			show(dp[i][H-1][W-1]);
			chmin(ans,dp[i][H-1][W-1]);
		}
		if(ans==inf) ans=-1;
		cout<<ans<<endl;
	}
}

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

int main(){
  string w; cin >> w;
  int k=w.size();
  if(k==1){
    cout << "No" << endl;
    return 0;
  }
  vector<char> MY(k);
  for(int i=0;i<k;i++){
    MY.at(i)=w.at(i);
  }
  sort(MY.begin(),MY.end());
  int count=1;
  for(int i=1;i<k;i++){
    if(MY.at(i)==MY.at(i-1)){
      count++;
    }
    if(MY.at(i)!=MY.at(i-1)){
      if(count%2!=0){
        cout << "No" << endl;
        return 0;
      }
      count=1;
    }
  }
  if(MY.at(k-2)!=MY.at(k-1)){
    cout << "No" << endl;
  }
  else cout << "Yes" << endl;
}
  
 

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;//J O I

void count(piii& dp, char s){
  if(s == 'J'){
    dp.first++;        
  }else if(s == 'O'){
    dp.second.first++;
  }else{
    dp.second.second++;
  }
}

piii add(piii a, piii b){
  piii res;
  res = a;
  res.first += b.first;
  res.second.first += b.second.first;
  res.second.second += b.second.second;
  return res;
}

piii sub(piii a, piii b){
  piii res;
  res = a;
  res.first -= b.first;
  res.second.first -= b.second.first;
  res.second.second -= b.second.second;
  return res;
}

int main(int argc, char *argv[]){
  int w, h, k;
  cin >> h >> w >> k;
  vector<string> s(h);
  for (int i = 0; i < h; i++) {
    cin >> s[i];
  }
  
  vector<vector<piii> >dp(h, vector<piii>(w, piii(0,pii(0,0))));
  count(dp[0][0], s[0][0]);
  for (int i = 1; i < w; i++) {
    dp[0][i] = dp[0][i - 1];
    count(dp[0][i], s[0][i]);
  }
  for (int i = 1; i < h; i++) {
    dp[i][0] = dp[i - 1][0];
    count(dp[i][0], s[i][0]);
  }
  for (int i = 1; i < h; i++) {
    for (int j = 1; j < w; j++) {
      dp[i][j] = dp[i - 1][j];
      dp[i][j] = add(dp[i][j], dp[i][j - 1]);
      dp[i][j] = sub(dp[i][j], dp[i - 1][j - 1]);
      count(dp[i][j], s[i][j]);
    }
  }
  for (int i = 0; i < k; i++) {
    int sx, sy, gx, gy;
    cin >> sy >> sx >> gy >> gx;
    sx--,sy--,gx--,gy--;
    piii ans = dp[gy][gx];
    if(1 <= sx)
      ans = sub(ans, dp[gy][sx - 1]);
    if(1 <= sy)
      ans = sub(ans, dp[sy - 1][gx]);
    if(1 <= sy && 1 <= sx)
      ans = add(ans, dp[sy - 1][sx - 1]);
    std::cout << ans.first << " " << ans.second.first << " " << ans.second.second << std::endl;
  }
  // for (int i = 0; i < h; i++) {
  //   for (int j = 0; j < w; j++) {
  //     std::cout << dp[i][j].second.first << " ";
  //   }
  //   std::cout << std::endl;
  // }
  return 0;
}

Measured memory_bytes: 13676