akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n); i > 0; i++)
const int MOD =1e9+7;

int main(){
    string s;
    cin >> s;
    int cnt = 0;
    int ans = 0;
    int res = 0;
    rep(i,s.size()){
        if(s[i]=='A'||s[i]=='G'||s[i]=='C'||s[i]=='T') cnt++;
        else {
            res = cnt;
            ans = max(res, ans);
            cnt = 0;
        }
    }
    ans = max(cnt, ans);
    cout << ans << endl;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Numerics;
using System.Linq;

namespace c
{
    class Program
    {
        public static readonly long INF = 999999999999;
        public static readonly long MOD = 1000000007;

        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());

            if (n == 1) Console.WriteLine(1.0);
            else if (n % 2 == 0) Console.WriteLine(0.5);
            else Console.WriteLine(((n/2)+1)/(double)n);
        }
    }

    public class Scanner
    {
        public static string[] Scan() => Console.ReadLine().Split(' ');
        public static int[] IntScan() => Array.ConvertAll(Scan(), int.Parse);
        public static long[] LongScan() => Array.ConvertAll(Scan(), long.Parse);
        public static string[][] Scan(int n) => Enumerable.Repeat(0, n).Select(_ => Scan()).ToArray();
        public static int[][] IntScan(int n) => Enumerable.Repeat(0, n).Select(_ => IntScan()).ToArray();
        public static long[][] LongScan(int n) => Enumerable.Repeat(0, n).Select(_ => LongScan()).ToArray();

    }

    public class Ex
    {
        public static bool Chmin(ref int a, int b) { if (a > b) { a = b; return true; } return false; }
        public static bool Chmin(ref long a, long b) { if (a > b) { a = b; return true; } return false; }
        public static bool Chmax(ref int a, int b) { if (a < b) { a = b; return true; } return false; }
        public static bool Chmax(ref long a, long b) { if (a < b) { a = b; return true; } return false; }
        public static int[] SubArr(int[] arr, int begin, int n) { int[] a = new int[arr.Length]; Array.Copy(arr, begin, a, 0, n); return a; }
    }
}


Measured memory_bytes: 13140
import sys
s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in ss]
ss2nnn = lambda ss: [s2nn(s) for s in ss]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [sys.stdin.readline().rstrip() for _ in range(n)]
ii2sss = lambda n: [list(sys.stdin.readline().rstrip()) for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

from bisect import bisect_left, bisect_right  # 二分探索
from heapq import heapify, heappush, heappop, heappushpop  # プライオリティキュー

def main():
    N = i2n()
    A = ii2nn(N)
    B = [1]
    for a in A:
        t = bisect_right(B, -a)
        if t < len(B):
            B[t] = -a
        else:
            B.append(-a)
    print(len(B))

main()


Measured memory_bytes: 56540
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pq              priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;


void c_p_c()
{
	ios_base::sync_with_stdio(0); 
	cin.tie(0);
	cout.tie(0);
/*
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
*/
}

int32_t main()
{
	c_p_c();
/*	w(t)
	{
	}
	 */
	 int r;
	 cin>>r;
	 double ar= 3.1415926535*r*2;
	 cout<<ar<<endl;
	
	return 0;
}


Measured memory_bytes: 3820
#include "bits/stdc++.h"
using namespace std;
#define Would
#define you
const long long INF = 99999999999999999;
const long long MOD = 1e9 + 7;
const double pi = acos(-1);
const int SIZE = 1 << 17;
int dx[] = { 1,0,-1,0 }, dy[] = { 0,1,0,-1 };

int a, b, x, y;
bool mon[105][105];
char k[105][105];

void dfs(int n, int m) {
	if (k[n][m] == '*') { return; }
	mon[n][m] = 0;
	for (int i = 0; i < 4; ++i) {
		int xx = n + dx[i], yy = m + dy[i];
		if (k[xx][yy] == '@') { continue; }
		if (mon[xx][yy]) {
			dfs(xx, yy);
			return;
		}
	}
}

int main() {
	cin >> a >> b;
	for (int i = 1; i <= a; ++i) {
		for (int j = 1; j <= b; ++j) {
			cin >> k[i][j];
			if (k[i][j] == '@') {
				x = i, y = j;
			}
		}
	}
	for (int i = 1; i <= a; ++i) {
		for (int j = 1; j <= b; ++j) {
			bool bre = false;
			switch (i) {
			case 1:
				mon[i][j] = 1;
				bre = 1;
				break;
			case 2:
				if (j == 1 || j == b) { mon[i][j] = 1; }
				bre = 1;
				break;
			case 3:
				if (j % 4 != 2) { mon[i][j] = 1; }
				bre = 1;
				break;
			}
			if (!bre) {
				if (i != a) {
					if (j % 2) { mon[i][j] = 1; }
				}
				else {
					if (j % 4) { mon[i][j] = 1; }
				}
			}
		}
	}
	for (int i = 0; i < 4; ++i) {
		if (mon[x + dx[i]][y + dy[i]]) {
			dfs(x + dx[i], y + dy[i]);
			break;
		}
	}
	for (int i = 1; i <= a; ++i) {
		for (int j = 1; j <= b; ++j) {
			if (k[i][j] != '.') { cout << k[i][j]; }
			else if (mon[i][j]) { cout << "#"; }
			else { cout << "."; }
		}
		cout << endl;
	}
}


Measured memory_bytes: 3124
blue=[]
red=[]
count=countb=countr=x=maxi=0
nblue=int(input())
for c in range(1,nblue+1):
  blue+=[input()]
nred=int(input())
for c in range(1,nred+1):
  red+=[input()]
for c in range(0,len(blue)):
  countb=blue.count(blue[c])
  countr=red.count(blue[c])
  if countr>=1:
    countr=red.count(blue[c])
    countb-=countr
  if countb>maxi:
    maxi=countb
    x=c
print(maxi)

Measured memory_bytes: 3064
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <array>
#include <cassert>
#include <bitset>
using namespace std;
using LL = long long;

int main(void)
{
	int A, B;
	cin >> A >> B;
	if ((A*B) % 2 == 0) {
		cout << "No" << endl;
	}
	else {
		cout << "Yes" << endl;
	}
	return 0;
}


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

using namespace std;

int main(){

    vector <int> like(100001);
    like[3] = 1;

    for (int i = 4; i < 100001; i++){
        like[i] = like[i - 1];

        if (i % 2 != 0){
            int num = (i + 1) / 2;
            bool flag = true;
            for (int j = 2; j * j <= i; j++){
                if (i % j == 0){
                    flag = false;
                }
            }
            for (int j = 2; j * j <= num; j++){
                if (num % j == 0){
                    flag = false;
                }
            }

            if (flag == true){
                like[i] ++;
            }
        }
    }
    

    int Q;
    cin >> Q;

    vector <int> l(Q), r(Q);
    for (int i = 0; i < Q; i++){
        cin >> l[i] >> r[i];
    }
    
    for (int i = 0; i < Q; i++){
        cout << like[r[i]] - like[l[i] - 1] << endl;
    }
    

    return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef std::vector<vector<int> > vvi;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef vector<pi> vpi;
typedef vector<pll> vpll;
typedef vector<vll> vvll;
typedef vector<vi> vvi;
typedef vector<vector<double>> vvd;
typedef vector<double> vd;

#define debugone(x) cerr << #x << " " << x << "\n"; cerr.flush();
#define debugtwo(x) cerr << #x << "-------------" << "\n";for(auto &it: x) cerr << it << " ";cerr << "\n"; cerr.flush();
#define debugthree(x_, i_, j_) cerr << #x_ << "------------" << "\n";cerr << "from " << i_ << " to " << j_ << "\n";for(ll k_=i_; k_<=j_; k_++) cerr << x_[k_] << " ";cerr << "\n"; cerr.flush();
#define trace1(x)                cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;

const ll MOD = 1e9 + 7;
const int INF = 2e9;
const int MAX_LOG = 21;
const int MAX_N = 12800;

#define forn(i, n) for(int i = 0; i < n; i++)
#define forsn(i, s, n) for(int i = s; i < n; i++)
#define all(x) x.begin(), x.end()

ll expmod(ll x, ll n, ll mod){
	if(n == 0) return 1;
	else if(n % 2 == 0){
		ll temp = expmod(x, n / 2, mod);
		return (temp * temp) % mod;
	}
	else{
		return (expmod(x, n - 1, mod) * x) % mod;
	}
}

ll modinv(ll x, ll mod){
	return expmod(x, mod - 2, mod);
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	int n, k;
	cin >> n >> k;
	ll a[n], maxi = 0, mini = 0;
	forn(i, n){
		cin >> a[i];
	}
	sort(a, a + n);
	ll fac[n + 1], inv_fac[n + 1];
	fac[0] = 1; inv_fac[0] = 1;
	for(int i = 1; i <= n; i++){
		fac[i] = fac[i - 1] * i % MOD;
		inv_fac[i] = inv_fac[i - 1] * modinv(i, MOD) % MOD;
	}
	for(ll i = k - 1; i < n; i++){
		const ll mult = fac[i] * inv_fac[k - 1] % MOD * inv_fac[i - k + 1] % MOD;
		maxi += mult * a[i] % MOD;
		maxi %= MOD;
		mini += mult * a[n - i - 1] % MOD;
		mini %= MOD;
		// trace3(mult, maxi, mini);
	}
	ll ans = maxi - mini;
	ans %= MOD;
	if(ans < 0){
		ans += MOD;
	}
	cout << ans << endl;
}		


Measured memory_bytes: 2560
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<iostream>
#include<string>
using namespace std;

int a[1000010];
int i, n;

int main()
{
	scanf("%d", &n);
	int mina = 100000000, maxa = 0;
	for (i = 1; i <= n; i++)
	{
		scanf("%d", &a[i]);
		mina = min(mina, a[i]);
		maxa = max(maxa, a[i]);
	}
	
	if (maxa > mina + 1)
	{
		puts("No");
		return 0;
	}
	if (maxa == mina)
	{
		if (mina == n - 1)
		{
			puts("Yes");
			return 0;
		}
		puts(((mina << 1) > n) ? "No" : "Yes");
		return 0;
	}
	
	int tot = 0;
	for (i = 1; i <= n; i++)
		if (a[i] == mina) tot++;
	
	if (maxa > tot && n - tot >= 2 * (maxa - tot) && n >= tot + 2) puts("Yes");
	else puts("No");
	
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
using namespace std;
using ll = long long int;
const ll MOD = 1000000007;

int main(){
    ll n;
    cin >> n;
    ll ans = 1;
    for(ll i = 2; i <= n; i++){
        ans *= i;
        ans %= MOD;
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

#define all(c)	(c).begin(),(c).end()
#define rall(c)	(c).rbegin(),(c).rend()
#define rep(i,N)	for(int i=0;i<N;++i)

typedef long long ll;

constexpr ll INF = 0x3fffffffffffffff;
constexpr int inf = 0x1fffffff;
constexpr double inf_l = 1e18;
constexpr ll MOD = 1000000007LL;
constexpr int mod = 1000000007;

int main(void) 
{
	cin.tie(nullptr);
	int n, a, b; cin >> n >> a >> b;
	string s; cin >> s;
	int q = 0;
	int g = 1;

	for (int i = 0; i < n; ++i) {
		int rank = i + 1;
		if (s[i] == 'c') {
			cout << "No" << endl;
			continue;
		}
		if (s[i] == 'a'&&a+b>q) {
			++q;
			cout << "Yes" << endl;
			continue;
		}
		if (s[i] == 'b'&&a + b > q&&b >= g) {
			++q;
			++g;
			cout << "Yes" << endl;
			continue;
		}
		cout << "No" << endl;
	}
}

Measured memory_bytes: 896
import java.util.Arrays;
import java.util.Scanner;

/**
 * 【問題概要】 黒板に NN 個の正の整数 A1,…,ANA1,…,AN が書かれています。
 * すぬけ君は，黒板に書かれている整数がすべて偶数であるとき，次の操作を行うことができます。
 *
 * 黒板に書かれている整数すべてを，2 で割ったものに置き換える。 すぬけ君は最大で何回操作を行うことができるかを求めてください。
 *
 * @author tsuch
 *
 */
public class Main {

	private static Scanner sc = new Scanner(System.in);

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

	private void solve() {
		try {
			int n = sc.nextInt();
			int[] a = new int[n];
			for (int i = 0; i < n; i++) {
				int j = 0;
				int temp = sc.nextInt();
				while (true) {
					if (temp / 2 == (temp + 1) / 2) {
						temp = temp / 2;
						j = j + 1;
					} else {
						a[i] = j;
						break;
					}
				}
			}
			int b = Arrays.stream(a).min().getAsInt();
			System.out.println(b);

		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}

Measured memory_bytes: 27092
// C.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <vector>

using namespace std;

int main(int argc, char *argv[]) {
  int n, ans = 0, a = 0, b = 0, c = 0;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    string s;
    cin >> s;
    for (int j = 0; j < (int)s.length() - 1; ++j) {
      if (s[j] == 'A' && s[j + 1] == 'B') {
        ++ans;
      }
    }
    if (s.back() == 'A' && s[0] == 'B') {
      ++c;
    } else {
      if (s.back() == 'A') {
        ++a;
      } 
      if (s[0] == 'B') {
        ++b;
      }
    }
  }
  b += a ? c : max(0, c - 1);
  a += c;
  ans += min(a, b);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<math.h>
using namespace std;

int main(void){
    double a,b,c,d,e,f,x,y;
    while(cin>>a>>b>>c>>d>>e>>f){
        y=(a*f-d*c)/(a*e-b*d);
        x=(c-b*y)/a;
        y=double(round(y*1000))/1000.0;
        x=double(round(x*1000))/1000.0;
        printf("%.3lf %.3lf\n", x, y);
    }
    return 0;
}

Measured memory_bytes: 3360
import java.util.Arrays;
import java.util.Scanner;

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

public class Main {
  Scanner sc = new Scanner(System.in);

  public static void main(String[] args) {
    new Main().run();
  }

  void run() {
    String str = sc.next();
    for(int i = 0; i < 4; ++i) {
      System.out.print(str.charAt(i));
    }
    System.out.print(" ");
    for(int i = 0; i < 8; ++i) {
      System.out.print(str.charAt(i + 4));
    }
    System.out.println();
  }

  int ni() {
    return Integer.parseInt(sc.next());
  }

  void debug(Object... os) {
    System.err.println(Arrays.deepToString(os));
  }

}


Measured memory_bytes: 10064
n,d = map(int,input().split())
lst = []
for i in range(n):
    l = list(map(int,input().split()))
    lst.append(l)

cnt = 0

for i in range(n):
    for j in range(i+1,n):
        dis = 0
        for k in range(d):
            dis += (lst[i][k]-lst[j][k])**2
        dis = dis**0.5
        if dis == int(dis):
            cnt += 1
print(cnt)
        

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

int main() {
  int N;
  cin >> N;
  vector<tuple<string, int, int>> assessment(N);
  rep(i, N) {
    cin >> get<0>(assessment.at(i)) >> get<1>(assessment.at(i));
    get<2>(assessment.at(i)) = i;
    get<1>(assessment.at(i)) = 100 - get<1>(assessment.at(i));
  }
  
  sort(assessment.begin(), assessment.end());
  rep(i, N) {
    cout << get<2>(assessment.at(i)) + 1 << endl;
  }
}

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

struct point {
    double x, y;
    double angle;
};
bool operator<(const point& x0, const point& x1) {
    return x0.angle < x1.angle;  //<で昇順
}

int main() {
    int n;
    double ans = 0;
    cin >> n;
    vector<point> p;
    for (int i = 0; i < n; i++) {
        double x, y, angle;
        cin >> x >> y;
        if (x == 0 && y == 0) continue;
        angle = atan2(y, x);
        p.push_back({x, y, angle});
    }
    sort(p.begin(), p.end());
    n = p.size();
    for (int i = 0; i < n; i++) {
        p.push_back({p[i].x, p[i].y, p[i].angle + M_PI * 2});
    }
    n = p.size();
    for (int i = 0; i < n; i++) {
        double sx = p[i].x, sy = p[i].y;
        ans = max(ans, sqrt(sx * sx + sy * sy));
        for (int j = i + 1; j < n; j++) {
            if (i+n/2 <= j) break;
            sx += p[j].x;
            sy += p[j].y;
            ans = max(ans, sqrt(sx * sx + sy * sy));
        }
    }
    cout << setprecision(20) << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;


public class Main {

	/**
	 * @param args
	 * @throws IOException 
	 */
	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		while(true){
			String str = br.readLine();
			
			if(str == null){
				break;
			}
			
			double input = Double.parseDouble(str);
			
			Sequence sq = new Sequence(input);
			
			System.out.println(sq.sum(10));
		}
	}

}

class Sequence {
	private double[] seq = new double[11];
	
	public Sequence(double a){
		seq[1] = a;
		
		for(int i = 2; i <= 10; i++){
			if(i % 2 == 0){
				seq[i] = seq[i-1]*2;
			}
			else {
				seq[i] = seq[i-1]/3;
			}
		}
	}
	
	public double sum(int n){
		double sum = 0;
		for(int i = 1 ; i <= n && i < seq.length ; i++){
			sum += seq[i];
		}
		
		return sum;
	}
}

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

#define ALL(a)  a.begin(),a.end()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define debug(x) cerr << #x << ": " << x << endl

using LL = long long; template<class T> using V = vector<T>;


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

	int H, W;
	cin >> H >> W;
	V<V<int>>a(H + 1, V<int>(W + 1));
	FOR(i, 0, H) {
		FOR(j, 0, W) {
			cin >> a[i + 1][j + 1];
		}
	}
	LL ans = 0;
	V<V<int>>dp(H + 1, V<int>(W + 1, 0));
	FOR(i, 1, H + 1) {
		FOR(j, 1, W + 1) {
			if (a[i][j] == 1)dp[i][j] = 0;
			else dp[i][j] = min(dp[i - 1][j - 1], min(dp[i - 1][j], dp[i][j - 1])) + 1;
		}
	}

	FOR(i, 1, H + 1) {
		FOR(j, 1, W + 1) {
			ans = max(ans, (LL)dp[i][j]);
		}
	}
	cout << ans * ans << endl;

	return 0;
}


Measured memory_bytes: 18404
//Battlefield control establishing...
#include <iostream>
#include <cstdio>
#include <bits/stdc++.h>
#include <iomanip>
#define MCV main
#define reset(a,b) memset(a,b,sizeof(a))
const int INF=0x3f3f3f3f;
using namespace std;
typedef long long ll;
//Get ready? LET'S ROCK!
int MCV()
{
   int n,k;
   cin>>n>>k;
   int cnt=0;
   for(int i=1;i<=n;i+=2)
   {
       cnt++;
   }
   if(cnt<k)
    cout<<"NO"<<endl;
   else
    cout<<"YES"<<endl;
   return 0;
}


Measured memory_bytes: 256
import java.util.*;

class Main{
	
	public static void main(String args[]){

		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();

		int arr[] = new int[N];

		for(int n=0;n<N;n++){
			arr[n] = sc.nextInt();
		}

		int cnt = 0;
		for(int n=0;n<N;n++){
			while(arr[n]%2 == 0){
				cnt++;
				arr[n] /= 2;
			}
		}

		System.out.println(cnt);


	}
}

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

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

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


	int x, y;
	int ans = 0;

	for(int i = 1; i < n - 1; i++){
		x = max(p[i - 1], max(p[i], p[i + 1]));
		y = min(p[i - 1], min(p[i], p[i + 1]));
		if(p[i] != x && p[i] != y){
			ans += 1;
		}
	}


	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    int r, g, b;
    cin >> r >> g >> b;
    
    int num;
    num = 100*r + 10*g + b;
    
    if (num % 4 == 0) cout << "YES" << endl;

    else cout << "NO" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include<algorithm>
#include<sstream>
#include<iomanip>
#include<deque>
#include<list>


using namespace std;

typedef long long ll;

typedef pair<int, int> pii;

const ll MOD_CONST = 1000000007;
const ll BIG_NUM = 1000000000000000000;
const int BIG_INT = 1000000000;



int main() {
	int n, m;
	cin >> n >> m;
	vector<ll> x(n);
	vector<ll> y(m);
	for (int i = 0;i < n;i++) {
		cin >> x[i];
	}
	for (int i = 0;i < m;i++) {
		cin >> y[i];
	}

	ll sx = 0;
	for (ll i = 0;i < n;i++) {
		
		sx = (sx + (MOD_CONST - ((n - 1 - 2*i)*(MOD_CONST+x[i])) % MOD_CONST))% MOD_CONST;
		//ll tmp = (n - 1 - 2 * i)*x[i];
		//cout << tmp << " " << tmp%MOD_CONST<< endl;
	}

	ll sy = 0;
	for (ll i = 0;i < m;i++) {
		
		sy = (sy +( MOD_CONST - ((m - 1 - 2*i)*(MOD_CONST+y[i])) % MOD_CONST)) % MOD_CONST;
		//ll tmp = ((n - 1 - 2 * i)*y[i]);
		//cout << tmp << " " << tmp %MOD_CONST << endl;
	}
	//cout << sx << " " << sy << endl;
	ll ans = (sx*sy) % MOD_CONST;
	//cout << sx * sy << endl;
	cout << ans << endl;
}





Measured memory_bytes: 1792
#include<cstdio>//AT2665
#include<iostream>
#include<cstring>
#include<string>
#include<cmath>
#include<algorithm>
#include<cstdlib>
using namespace std;
int n,a,b,c,d,delta,whole;
double nxt,half=0.5,maxhalf,lft;
int main(){
    scanf("%d%d%d%d%d",&n,&a,&b,&c,&d);
    nxt+=c+d;
    nxt/=2;
    half=nxt-c;
    maxhalf=half*(n-1);
    delta=abs(a-b);
    if(delta>(n-1)*nxt+maxhalf){
        printf("NO\n");
        return 0;
    }
    whole=(int)(delta/nxt);
    lft=delta-nxt*whole;
    if(n&1){//n%2==1
        if(whole&1){
            lft=nxt-lft;
            if(lft<=maxhalf){
                printf("YES\n");
                return 0;
            }
            else{
                printf("NO\n");
                return 0;
            }
        }
        else{
            if(lft<=maxhalf){
                printf("YES\n");
                return 0;
            }
            else{
                printf("NO\n");
                return 0;
            }
        }
    }
    else{
        if(whole&1){
            if(lft<=maxhalf){
                printf("YES\n");
                return 0;
            }
            else{
                printf("NO\n");
                return 0;
            }
        }
        else{
            lft=nxt-lft;
            if(lft<=maxhalf){
                printf("YES\n");
                return 0;
            }
            else{
                printf("NO\n");
                return 0;
            }
        }
    }
    return 0;
}

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

using namespace std;
int main() {
  int x;
  cin >> x;
  int result = 0;

  while (true) {
    for (int i = 2; i <= x; i++) {
      if (i == x)
        result = x;
      else if (x % i == 0)
        break;
    }
    if (result > 0) {
      cout << result << endl;
      return 0;
    }
    x++;
  }
  return 0;
}

Measured memory_bytes: 256
{-# LANGUAGE OverloadedLists     #-}
{-# LANGUAGE OverloadedStrings   #-}
{-# LANGUAGE ScopedTypeVariables #-}

import           Control.Monad
import qualified Data.IntMap   as I
import           Data.IORef
import qualified Data.Map      as M
import           Data.Maybe
import qualified Data.Set      as S
import qualified Data.Text     as T
import qualified Data.Text.IO  as T
import qualified Data.Vector   as V
import           System.IO

main :: IO ()
main = travelingBudget

travelingBudget :: IO ()
travelingBudget = do
  a :: Int <- readLn
  b :: Int <- readLn
  c :: Int <- readLn
  d :: Int <- readLn
  let bs = min a b
      tr = min c d
  print $ bs + tr

Measured memory_bytes: 508
#include <bits/stdc++.h>
using namespace std;
#define V(i) vector<i>
#define rep(i, n) for (__typeof(n) i = 0; i < n; i++)
#define crep(i,N,n) for (__typeof(n) i = N; i < n; i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
typedef long l;
#define fio                           \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL)
int main()
{
    fio;
    ll n,w;
    cin>>n>>w;
    V(ll) wei(n+1),val(n+1);
    crep(i,1,n+1)
    {
        cin>>wei[i];
        cin>>val[i];
    }
    V(V(ll)) dp(n+1,V(ll)(w+1,0));
    for(ll i=1;i<=n;i++)
    {
        for(ll j=1;j<=w;j++)
        {
            if(wei[i]<=j)
            {
                dp[i][j] = max(dp[i-1][j],val[i]+dp[i-1][j-wei[i]]);

            }
            else
            {
                dp[i][j] = dp[i-1][j];
            }
            
            

        }
    }
    cout<<dp[n][w];

    return 0;
}

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

#define endl '\n'
#define rep(i,n)       for(int i=0; i<n; i++)
#define clr(arr)       memset(arr, 0, sizeof arr)
#define all(x)         x.begin(), x.end()
const int MOD = 1e9 + 7;
template<class F, class S> ostream& operator<<(ostream &out, const pair<F, S> &p)
{
	return out << '(' << p.first << ", " << p.second << ')';
}
template<class T> auto operator<<(ostream &out, T &&x) -> decltype(x.begin(), out)
{
	out << '{';
	for (auto i = x.begin(); i != x.end(); i++)
		out << *i << (i == prev(x.end()) ? "" : ", ");
	return out << '}';
}
void dmp() {}
template<class T, class... Args> void dmp(T &&x, Args... args)
{
	cerr << x << ";  "; dmp(args...);
}
#ifdef SMIT
struct Nl {~Nl() {cerr << '\n';}};
#define debug(x...) cerr << (strcmp(#x, "") ? #x ":  " : ""), dmp(x), Nl(), cerr << ""
#else
#define debug(...) {}
#endif
// Yes you CAN

const int N = 1e5 + 1;

int n, k, h[N], dp[N];

int cost(int n, int h[])
{
	if (n == 0)
		return 0;
	if (dp[n] != -1)
		return dp[n];
	int mini = INT_MAX;
	for (int i = 1; i <= k; i++)
	{
		if (n - i >= 0)
		{
			mini = min(mini, abs(h[n] - h[n - i]) + cost(n - i, h));
		}
	}
	return dp[n] = mini;
}
void solve()
{
// #define TEST
	memset(dp, -1, sizeof dp);
	cin >> n >> k;
	rep(i, n) cin >> h[i];
	cout << cost(n - 1, h) << endl;
}

int32_t main()
{
#ifdef SMIT
	freopen("/home/smit/Desktop/in.txt", "r", stdin);
#endif
	ios_base::sync_with_stdio(false); cin.tie(nullptr);

	int t = 1;
#ifdef TEST
	cin >> t;
#endif
	while (t--)
		solve();
}

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

typedef long long int ll;
ll powk(ll a, ll n){
    ll r = 1;
    for(ll i = 0;i < n;i++){
        r *= a;
    }

    return r;
}

int main()
{
    ll n;
    string s;
    cin >> n >> s;
    vector<ll> a(n + 1), b(n + 1);
    ll t1 = 0;
    bool f = false;
    for(ll i = 0;i < n;i++){
        if(s[i] == '#'){
            a[i + 1] = a[i] + 1;
        }
        else{
            a[i + 1] = a[i];
        }
    }
    for(ll i = n - 1;i >= 0;i--){
        if(s[i] == '.'){
            b[i] = b[i + 1] + 1;
        }
        else{
            b[i] = b[i + 1];
        }
    }

    ll ans = a[0] + b[0];
    for(ll i = 0;i < n + 1;i++){
        ans = min(ans, a[i] + b[i]);
    }

    cout << ans;

    return 0;
}

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

using namespace std;
typedef long long ll;

#define MOD (long long)(1e9+7)
#define REP(i,n) for(ll i = 0; i < n; i++)
#define REP1(i,n) for(ll i = 1; i <= n; i++)

ll gcd(ll a, ll b)
{
  if(b == 0) return a;
  return gcd(b, a % b);
}

int main(void)
{
  ll k, s; cin >> k >> s;
  ll ans = 0;

  REP(x, k + 1) {
    REP(y, k + 1) {
      ll z = s - x - y;
      if(z >= 0 && z <= k) ans ++;
    }
  }
     
  
  cout << ans << endl;
}


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

using namespace std;

const int mod = 1e9 + 7;

int main()
{
  int H, W, K;
  cin >> H >> W >> K;
  vector<vector<int>> dp(H + 1, vector<int>(W, 0));
  dp[0][0] = 1;
  for (int i = 0; i < H; i++)
    for (int j = 0; j < W; j++)
      for (int bit = 0; bit < 1 << (W - 1); bit++)
      {
        cerr << bit << " " << 1 << (W - 1) << endl;
        bool ok = true;
        for (int k = 0; k < W - 2; k++)
          if (bit & (1 << k) && bit & (1 << (k + 1)))
            ok = false;
        if (!ok)
          continue;
        if (0 < j && (bit & (1 << (j - 1))))
        {
          dp[i + 1][j - 1] += dp[i][j];
          dp[i + 1][j - 1] %= mod;
        }
        else if (j < W - 1 && (bit & (1 << j)))
        {
          dp[i + 1][j + 1] += dp[i][j];
          dp[i + 1][j + 1] %= mod;
        }
        else
        {
          dp[i + 1][j] += dp[i][j];
          dp[i + 1][j] %= mod;
        }
      }
  cout << dp[H][K - 1] << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll N, answer;
ll a[205];
int main(){
  cin >> N;
  for (ll i = 0; i < 2*N; i++){
    cin >> a[i];
  }
  stable_sort(a, a+2*N);
  for (ll i = 0; i < 2*N; i++){
    if (i%2 == 0){
      answer += a[i];
    }
  }
  cout << answer;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
	int h,w,i,j;
	
	while(1){
		scanf("%d %d",&h,&w);
		if(h==0&&w==0){
			break;
		}
		for(i=1;i<=h;i++){
			for(j=1;j<=w;j++){
				if((i%2==1)&&(j%2==1)){
					printf("#");
				}
				else if((i%2==0)&&(j%2==1)){
					printf(".");
				}
				else if((i%2==1)&&(j%2==0)){
					printf(".");
				}
				else if((i%2==0)&&(j%2==0)){
					printf("#");
				}
			}
			printf("\n");
		}	
		printf("\n");
	}
	
	return 0;
}


Measured memory_bytes: 2068
import Control.Monad
import Data.Char
import Data.List
import qualified Data.ByteString.Char8 as B
import qualified Data.Vector.Unboxed as V
main=print.solve.map(unfoldr(B.readInt.B.dropWhile isSpace)).B.lines=<<B.getContents
solve([n,m]:xyzs)=if m<1 then 0 else maximum.map(f.(\v->map(sum.zipWith(*)v)xyzs))$replicateM 3[-1,1]where
  f=(V.!(m-1)).foldr g(V.replicate m$minBound`div`2)
  g t dp=V.generate m$ \i->max(dp V.! i)$t+if i>0 then dp V.!(i-1) else 0

Measured memory_bytes: 27484
N,M= [int(i) for i in input().split()]
tmp=[]
scr=[0]*2
rec=[0]*N
eec=[0]*N

ts=0
for i in range(M):
        tmp = ([x for x in input().split()])
        q=int(tmp[0])

        if rec[q-1] == 1:
                continue
        else:
                if tmp[1] == 'AC':
                        rec[q-1]=1
                        scr[0]+=1
                        scr[1]+=eec[q-1]
                elif tmp[1]=='WA':
                        eec[q-1]+=1
        
        
print(scr[0],scr[1])


Measured memory_bytes: 4596
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
using P   = pair<ll, ll>;
using mat = vector<vector<ll>>;
typedef string::const_iterator State;
class ParseError {};

void IOS() { ios::sync_with_stdio(false), cin.tie(0); }

const ll INF = 1e16;
const ll MOD = 1e9 + 7;
const ld EPS = 1e-12;

template <typename T>
void dump(T x) { cout << x << endl; }
void dumpf(ld x, int t) { cout << setprecision(t) << fixed << x << endl; }
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
	fill((T *)array, (T *)(array + N), val);
}
inline ll mod(ll a, ll b) {
	if (a > 0) return a % b;
	if (a % b == 0) return 0;
	ll x = -a / b + 1;
	a += x * b;
	return a % b;
}
ll powm(ll a, ll b, ll c) {
	if (b == 0)
		return 1;
	else if (b % 2 == 0) {
		ll d = powm(a, b / 2, c);
		return (d * d) % c;
	} else
		return (a * powm(a, b - 1, c)) % c;
}
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

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

ll number(State &);
ll expr(State &);
ll x;

ll number(State &begin) {
	ll ret = 0;
	while (isdigit(*begin)) {
		ret *= 10;
		ret += *begin - '0';
		begin++;
	}
	if (*begin == 'x') {
		begin++;
		if (ret == 0) ret = 1;
		ret *= x;
	}
	if (*begin == '^') {
		begin++;
		int i = *begin - '0';
		for (int j = 1; j < i; j++) {
			ret *= x;
		}
		begin++;
	}
	return ret;
}
ll expr(State &begin) {
	ll ret = number(begin);
	while (1) {
		if (*begin == '+') {
			begin++;
			ret += number(begin);
		} else if (*begin == '-') {
			begin++;
			ret -= number(begin);
		} else {
			break;
		}
	}
	return ret;
}

int main() {
	IOS();
	string s, ans = "";
	cin >> s;
	int MAX = 2 * 1000;
	for (int i = MAX; i >= -MAX; i--) {
		x = i;

		State begin = s.begin();
		ll tmp		= expr(begin);
		//dump(tmp);
		if (tmp == 0) {
			ans = ans + "(x" + (i > 0 ? '-' : '+') + to_string(abs(i)) + ')';
		}
	}
	dump(ans);
	return 0;
}


Measured memory_bytes: 3292
#include <algorithm>
#include <fstream>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>

#include <cmath>
#include <climits>

using namespace std;

int main() {
    const long long INF = 1LL << 60;

    int n; cin >> n;
    int m; cin >> m;
    vector< vector<int> > vec(m);
    for(int i =0; i < m; ++i){
        int k; cin >> k;
        for(int j = 0; j < k; ++j){
            int s; cin >> s;
            vec[i].push_back(s);
        }
    }

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

    int count = 0;
    for(int bit =0; bit < (1L << n); ++bit){
        bool flag = true;
        for(int i = 0; i < m; ++i){
            int flagcount = 0;
            for(int j = 0; j < vec[i].size(); ++j){
                if(bit & (1 << (vec[i][j] - 1) ) ){
                    flagcount++;
                }
            }
            if(flagcount % 2 != p[i])
            {
                flag = false;
            }
        }
        if(flag){
            ++count;
        }
    }
    cout << count << endl;


    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define timer_start()                            \
    chrono::system_clock::time_point start, end; \
    start = chrono::system_clock::now();
#define timer_wrap()                                                       \
    end = chrono::system_clock::now();                                     \
    double time = static_cast<double>(                                     \
        chrono::duration_cast<chrono::microseconds>(end - start).count() / \
        1000.0);                                                           \
    printf("%lf[ms]\n", time);                                             \
    start = end;
#define optimize_cin() \
    cin.tie(0);        \
    ios::sync_with_stdio(false)
using namespace std;
using ll = long long;
#define INF 1000000000    // 10^9
#define INFINF LLONG_MAX  // 2^63-1
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;
}
// ########## template end ##########

#ifdef DEBUG_ON
void test_all();
#endif

vector<ll> A;
ll cnt;
int m;
vector<ll> G;

void insertionSort(int n, ll g) {
    for (int i = g; i < n; i++) {
        ll v = A.at(i);
        int j = i - g;
        while (j >= 0 && A.at(j) > v) {
            A.at(j + g) = A.at(j);
            j = j - g;
            cnt++;
        }
        A.at(j + g) = v;
    }
}
void shellSort(int n) {
    cnt = 0;
    ll g = 1;
    m = 0;
    do {
        G.push_back(g);
        g = 3 * g + 1;
        m++;
    } while (g < n);
    reverse(begin(G), end(G));
    for (int i = 0; i < m; i++) {
        insertionSort(n, G.at(i));
    }
}
void resolve() {
    int n;
    cin >> n;
    A = vector<ll>(n, 0);
    for (int i = 0; i < n; i++) {
        cin >> A.at(i);
    }
    //
    shellSort(n);
    //
    cout << m << endl;
    for (int i = 0; i < m; i++) {
        cout << G.at(i);
        if (i < (m - 1)) {
            cout << " ";
        }
    }
    cout << endl;
    cout << cnt << endl;
    for (int i = 0; i < n; i++) {
        cout << A.at(i) << endl;
    }
}

int main() {
#ifdef DEBUG_ON
    test_all();
#else
    resolve();
#endif
    return 0;
}



Measured memory_bytes: 10664
n, m = gets.split.map(&:to_i)
abs = n.times.map { gets.split.map(&:to_i) }
checks = m.times.map { gets.split.map(&:to_i) }

abs.each do |a, b|
  ans = m
  adist = 2 + 10 ** 8

  (m - 1).downto(0) do |i|
    ca, cb = checks[i]
    dist = (ca - a).abs + (cb - b).abs

    if dist <= adist
      ans = i + 1
      adist = dist
    end
  end

  puts ans
end


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

#ifdef LOCAL
#include "dump.hpp"
#else
#define dump(...)
#define dumpv(...)
#endif

#define rep(i, n) for (int i = 0; i < (n); i++)
#define mins(x, y) (x = min(x, y))
#define maxs(x, y) (x = max(x, y))
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using P = pair<int, int>;
const int MOD = 1e9 + 7;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;

struct nvec : public vector<int> {
  int base;
  nvec(int len, int base) : vector<int>(len), base(base) {}
  nvec& operator++() {
    for (int i = 0; i < size(); i++) {
      at(i)++;
      if (at(i) < base) break;
      at(i) = 0;
    }
    return *this;
  };
  nvec& operator++(int dummy) { return operator++(); };
};

void solve() {
  int n;
  cin >> n;
  vi a(n + 1);
  function<void(int)> dfs = [&](int u) {
    dump(u, a);
    if (u == n - 1) {
      // dump(a);
      rep(i, n) cout << (char)('a' + a[i]);
      cout << endl;
      return;
    }
    int mx = 0;
    rep(i, u + 1) {
      maxs(mx, a[i]);
    }
    for (int v = 0; v <= mx + 1; v++) {
      a[u + 1] = v;
      dfs(u + 1);
    }
  };
  dfs(0);
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  // freopen("temp.1", "r", stdin);
  solve();
  return 0;
}

Measured memory_bytes: 1536
import java.io.*;
import java.util.*;

public class Main {
  private static int f(int n) {
    int sum = 0;
    while (n > 0) {
      sum += n % 10;
      n /= 10;
    }
    return sum;
  }
  
  private static boolean solve(int n) {
    return n % f(n) == 0;
  }
  
  private static void execute(ContestReader reader, PrintWriter out) {
    int n = reader.nextInt();
    out.println(solve(n) ? "Yes" : "No");
  }
  
  public static void main(String[] args) {
    ContestReader reader = new ContestReader(System.in);
    PrintWriter out = new PrintWriter(System.out);
    execute(reader, out);
    out.flush();
  }
}

class ContestReader {
  private BufferedReader reader;
  private StringTokenizer tokenizer;
  
  ContestReader(InputStream in) {
    reader = new BufferedReader(new InputStreamReader(in));
  }
  
  public String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }
  
  public int nextInt() {
    return Integer.parseInt(next());
  }
  
  public long nextLong() {
    return Long.parseLong(next());
  }
  
  public double nextDouble() {
    return Double.parseDouble(next());
  }
  
  public String[] next(int n) {
    String[] array = new String[n];
    for (int i = 0; i < n; i++) {
      array[i] = next();
    }
    return array;
  }
  
  public int[] nextInt(int n) {
    int[] array = new int[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextInt();
    }
    return array;
  }
  
  public long[] nextLong(int n) {
    long[] array = new long[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextLong();
    }
    return array;
  }
  
  public double[] nextDouble(int n) {
    double[] array = new double[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextDouble();
    }
    return array;
  }
  
  public char[] nextCharArray() {
    return next().toCharArray();
  }
  
  public int[][] nextInt(int n, int m) {
    int[][] matrix = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextInt();
      }
    }
    return matrix;
  }
  
  public long[][] nextLong(int n, int m) {
    long[][] matrix = new long[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextLong();
      }
    }
    return matrix;
  }
  
  public double[][] nextDouble(int n, int m) {
    double[][] matrix = new double[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextDouble();
      }
    }
    return matrix;
  }
  
  public char[][] nextCharArray(int n) {
    char[][] matrix = new char[n][];
    for (int i = 0; i < n; i++) {
      matrix[i] = next().toCharArray();
    }
    return matrix;
  }
}


Measured memory_bytes: 22612
#include <iostream>
#include <vector>

int main() {
  int n;
  std::cin >> n;
  std::vector<int> a(n);
  std::vector<int> b1;
  std::vector<int> b2;
  for (int i = 0; i < n; ++i) {
    std::cin >> a[i];
  }
  for (int i = 0; i < n; ++i) {
    if (i%2) {
      b1.push_back(a[i]);
    } else {
      b2.push_back(a[i]);
    }
  }
  if (n%2) {
    for (auto p = b2.rbegin(); p < b2.rend(); ++p) {
      std::cout << *p << " ";
    }
    for (auto p = b1.begin(); p < b1.end(); ++p) {
      std::cout << *p << " ";
    }
  } else {
    for (auto p = b1.rbegin(); p < b1.rend(); ++p) {
      std::cout << *p << " ";
    }
    for (auto p = b2.begin(); p < b2.end(); ++p) {
      std::cout << *p << " ";
    }
  }
  return 0;
}

Measured memory_bytes: 4588
h,w,k = map(int,input().split())
s = [str(input()) for i in range(h)]
num = 0
cnt = 0
ans = [[0]*w for i in range(h)]
before = 0
after = 0
key = 0
ch = [0 for i in range(h)]
for i in range(h):
    if "#" not in s[i]:
        ch[i] = 1
    else:
        cnt += 1
        keyy = 0
        after = 0
        for j in range(w):
            if s[i][j] == "#":
                if keyy == 1:
                    cnt += 1
                else:
                    keyy = 1
            ans[i][j] = str(cnt)
up = -1
for i in range(h):
    if ch[i] == 0:
        up = i
        break
for i in range(up-1,-1,-1):
    if ch[i] == 1:
        for j in range(w):
            ans[i][j] = ans[i+1][j]
for i in range(up+1,h):
    if ch[i] == 1:
        for j in range(w):
            ans[i][j] = ans[i-1][j]
for i in range(h):
    print(" ".join(ans[i]))



Measured memory_bytes: 9332
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define all(c) begin(c), end(c)
const int INF =
    sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = 1e9 + 7;
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 (b < a) {
        a = b;
        return true;
    }
    return false;
}

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    vector<string> v(3);
    rep(i, 0, 3) cin >> v[i];
    cout << v[0][0] << v[1][1] << v[2][2] << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>  // include all standard C++ libraries

using namespace std;

// Loops
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define _rrep(i,n) rrepi(i,n,0)
#define rrepi(i,a,b) for(int i=int(a)-1;i>=int(b);--i)

#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(xi, x) for (auto&& xi : x)
// Note: we can use rep(i,N) or rep(i,from,to)


// typedef
using ll = long long;
template <class T> using vec = vector<T>;
using vi   = vector<int>;
using vvi  = vector<vi>;
using vvvi = vector<vvi>;
using pii  = pair<int, int>;


// Constants

// Shorter repr for frequently used terms
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second


// Algorithms
#define all(x) (x).begin(), (x).end()
#define uniq(v) v.erase( unique(all(v)), v.end() )
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))

template<class T> pair<T, size_t> max(vector<T> &x){ auto it = max_element(all(x)); return mp(*it, it-x.begin()); }
template<class T> pair<T, size_t> min(vector<T> &x){ auto it = min_element(all(x)); return mp(*it, it-x.begin()); }

template<class T> inline bool chmax(T &maxval, const T &newval) { if (maxval<newval) { maxval=newval; return 1; } return 0; }
template<class T> inline bool chmin(T &minval, const T &newval) { if (minval<newval) { minval=newval; return 1; } return 0; }

// Utilities
// Grid world utilities
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
#define inside(H,W,y,x) 0<=(x) && (x)<(W) && 0<=(y) && (y)<(H)

inline int in() {int x; cin >> x; return x;} // read int from cin
inline  ll IN() {ll x; cin >> x; return x;}  // read ll from cin



// Debug
#ifdef LOCAL
  #include "dump.hpp"
  #define debug(x) cerr << #x << ": " << x << '\n'
#else
  #define dump(...)
  #define debug(x)
#endif

// Paste snippets here!!
bool stays(string &S, string &T, char back, char fwd, int H, int pos){
  int L=1; int R=H;
  int N=S.size();
  for(int i=N-1;i>=0;--i){
    char a = T[i];
    if(a==back){
      R = min(R+1,H);
    } else if (a==fwd){
      L = max(L-1,1);
    }
    char b = S[i];
    if(b==back){
      L++;
    } else if (b==fwd){
      R--;
    }
    if(R<L) return false;
  }
  return (L<=pos && pos<=R);
}
// 

int main(){
  cin.tie(0); ios::sync_with_stdio(false);    // Magic for faster cin
  int H, W, N; cin >> H >> W >> N;
  int sr, sc; cin >> sr >> sc;
  string S, T; cin >> S >> T;

  if(stays(S,T,'U','D',H,sr) && stays(S,T,'L','R',W,sc)){
    cout << "YES" << endl;
  } else cout << "NO" << endl;

  return 0;
}


Measured memory_bytes: 920
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

int main(){
    int n,t;
    scanf(" %d %d", &n, &t);

    double ans = 0;
    rep(i,n){
        int x,h;
        scanf(" %d %d", &x, &h);
        // x:h = t:ans
        ans = max(ans, (double)h*t/x);
    }
    printf("%.10f\n", ans);
    return 0;
}



Measured memory_bytes: 3212
#include<cstdio>
#include<cstdlib>
#include<string>
#include<iostream>
using namespace std;

struct Node{
  int key;
  Node *right, *left, *parent;
};

Node *root, *NIL;

void insert(int k){
  Node *y = NIL;
  Node *x = root;
  Node *z;

  z = (Node *)malloc(sizeof(Node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x != NIL){
    y = x;
    if(z->key < x->key){
      x = x->left;
    }
    else{
      x = x->right;
    }
  }
  z->parent = y;
  if(y == NIL){
    root = z;
  }
  else{
    if(z->key < y->key){
      y->left = z;
    }
    else{
      y->right = z;
    }
  }
}

void invorder(Node *u){
  if(u == NIL) return;
  invorder(u->left);
  printf(" %d",u->key);
  invorder(u->right);
}

void preorder(Node *u){
  if(u == NIL) return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}

int main(){
  int n,i,x;
  string com;

  scanf("%d",&n);

  for(i=0;i<n;i++){
    cin >> com;
    if(com == "insert"){
      scanf("%d",&x);
      insert(x);
    }
    else if(com == "print"){
      invorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }

  return 0;
}




Measured memory_bytes: 26616
#B
N=int(input())
a=0
b=0
c=0
d=0
for i in range(N):
    s=input()
    if s=="AC":
        a+=1
    elif s=="WA":
        b+=1
    elif s=="TLE":
        c+=1
    elif s=="RE":
        d+=1
print("AC x ",a)
print("WA x ",b)
print("TLE x ",c)
print("RE x ",d)

Measured memory_bytes: 69860