akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef vector<int> VI;
typedef vector<VI> VVII;
const LL INF = (LL)1e9 *(LL)1e9;
using namespace std;

int main(){
	while (1){
		int N, M;
		cin >> N >> M;
		if (N + M == 0)return 0;
		VI x(N+1),C(M+1);
		for (int i = 0; i < M; i++){
			cin >> C[i];
		}
		for (int i = 1; i < N+1; i++){
			cin >> x[i];
		}
		VVLL dp(N + 1, VLL(256, INF));
		dp[0][128] = 0;
		for (int n = 0; n < N; n++){
			for (int i = 0; i < 256; i++){
				for (int j = 0; j < M; j++){
					int r = i + C[j];
					if (r>255)r = 255;
					else if (r < 0)r = 0;
					dp[n + 1][r] = min(dp[n+1][r],dp[n][i] + (x[n + 1] - r)*(x[n + 1] - r));
				}
			}
		}
		LL res = INF;
		for (int i = 0; i < 256; i++){
			res = min(res, dp[N][i]);
		}
		cout << res << endl;

	}

	return 0;
}

Measured memory_bytes: 42060
import sys
input = sys.stdin.readline


def main():
    N = int(input())
    h = [ list(map(int, input().split())) for _ in range(N) ]
    dp = [ [0] * 3 for _ in range(N) ]
    for i in range(3):
        dp[0][i] = h[0][i]

    for i in range(1, N):
        for k in range(3):
            dp[i][k] = max(dp[i-1][(k+1)%3] + h[i][k], dp[i-1][(k+2)%3] + h[i][k])

    print(max(dp[N-1]))


if __name__ == "__main__":
    main()

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

int INF=10000000;
int N,A,B,C;
vector<int> L;

int rec(int i, int a, int b, int c){
    if(i==N){
        if(!a||!b||!c) return INF;
        return abs(a-A)+abs(b-B)+abs(c-C);
    }
    
    int res=rec(i+1,a,b,c);
    res=min(res, rec(i+1, a + L[i], b, c) + (a ? 10 : 0));
    res=min(res, rec(i+1, a, b + L[i], c) + (b ? 10 : 0));
    res=min(res, rec(i+1, a, b, c + L[i]) + (c ? 10 : 0));
    
    return res;
}



int main(void){
    cin>>N>>A>>B>>C;
    L.resize(N);
    for(int i=0;i<N;i++) cin>>L[i];
    
    cout<<rec(0,0,0,0)<<endl;
    
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"sort"
	"strconv"
)

func main() {
	N := nextInt()
	A := nextInt()
	B := nextInt()

	vs := make([]int, N)
	for i := 0; i < N; i++ {
		vs[i] = nextInt()
	}

	sort.Sort(sort.Reverse(sort.IntSlice(vs)))

	var avg float64
	for i := 0; i < A; i++ {
		avg += float64(vs[i])
	}

	avg /= float64(A)

	// Make dp.
	dp := make([][]int, N+1)
	for i := 0; i <= N; i++ {
		dp[i] = make([]int, i+1)
		for j := 0; j <= i; j++ {
			if j == 0 || j == i {
				dp[i][j] = 1
			} else {
				dp[i][j] = dp[i-1][j-1] + dp[i-1][j]
			}
		}
	}

	// Calc n and k.
	n, k := 0, 0
	for i := 0; i < N; i++ {
		if vs[i] == vs[A-1] {
			n++
			if i < A {
				k++
			}
		}
	}

	cnt := 0
	if k == A {
		for ; k <= B; k++ {
			if k >= len(dp[n]) {
				break
			}

			cnt += dp[n][k]
		}
	} else {
		cnt = dp[n][k]
	}

	fmt.Printf("%f\n%d\n", avg, cnt)
}

// Input. ----------

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Buffer([]byte{}, math.MaxInt64)
	sc.Split(bufio.ScanWords)
}

func nextInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}

	return i
}

func nextString() string {
	sc.Scan()
	if err := sc.Err(); err != nil {
		panic(err)
	}

	return sc.Text()
}

// ---------- Input.

// Util. ----------

func min(x, y int) int {
	if x < y {
		return x
	}

	return y
}

func max(x, y int) int {
	if x > y {
		return x
	}

	return y
}

func abs(x int) int {
	return int(math.Abs(float64(x)))
}

// ---------- Util.


Measured memory_bytes: 640
private fun readLn() = readLine()!!
private fun readStrings() = readLn().split(" ")
private fun readInt() = readLn().toInt()
private fun readInts() = readStrings().map { it.toInt() }
private fun readLong() = readLn().toLong()
private fun readLongs() = readStrings().map { it.toLong() }
private fun readDouble() = readLn().toDouble()
private fun readDoubles() = readStrings().map { it.toDouble() }

fun main(args: Array<String>) {
    var n=readInt()
    val mod=n%1000
    if(mod!=0){
        println(1000-mod)
    }
    else{
        println(0)
    }
}

Measured memory_bytes: 34208
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;

int main(){
    int n;
    cin >> n;
    vector<P> v(n);
    for(int i=0;i<n;i++){
        int x;
        cin >> x;
        v[i]=P(x,i+1);
    }
    sort(v.begin(),v.end());
    for(auto i:v){
        cout << i.second << endl;
    }
    return 0;
}


Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
int main(){
  int S;
  cin >> S;
  if(S % 100 > 12 || S % 100 == 0){
    if( S - (S % 100) > 1200 || S - (S % 100) == 0 ) cout << "NA" <<endl;
    else cout << "MMYY" << endl;
  }
  else {
    if(S - (S % 100) > 1200 || S - (S % 100) == 0) cout << "YYMM" <<endl;
    else cout << "AMBIGUOUS" << endl;
  }
}


Measured memory_bytes: 256
#include<cmath>
#include<algorithm>
#include<iostream>
#include<vector>
#include<climits>
#include<cfloat>

using namespace std;

double EPS = 1e-10;
const double PI = acos(-1);

double add(double a, double b){
if(abs(a+b) < EPS * (abs(a)+abs(b)))return 0;
return a+b;
}

struct point{
double x, y;
point(){}
point(double x,double y) : x(x) , y(y){}

point operator + (point p){
return point(add(x,p.x), add(y,p.y));
}

point operator - (point p){
return point(add(x,-p.x), add(y,-p.y));
}

point operator * (double d){
return point(x*d,y*d);
}

point operator / (double d){
return point(x/d,y/d);
}

bool operator == ( const point &p ) const {
return abs(x-p.x) < EPS && abs(y-p.y) < EPS;
}
};

double dot(point a, point b) {
return (a.x * b.x + a.y * b.y);
}

double cross(point a, point b) {
return (a.x * b.y - a.y * b.x);
}

int is_point_on_line(point a, point b, point c) {
return cross(a-c, b-c)==0 && dot(a-c, b-c)<=0;
}

int is_intersected_ls(point a1, point a2, point b1, point b2) {

if(cross(a1-a2,b1-b2)==0){
return is_point_on_line(a1,a2,b1) || is_point_on_line(a1,a2,b2)
|| is_point_on_line(b1,b2,a1) || is_point_on_line(b1,b2,a2);
}
else {
return ( cross(a2-a1, b1-a1) * cross(a2-a1, b2-a1) < EPS ) &&
( cross(b2-b1, a1-b1) * cross(b2-b1, a2-b1) < EPS );
}
}

int inside(point p, vector<point> ps){
point a,b;
a=b=p;
b.x=DBL_MAX;
int n=ps.size();
ps.push_back(ps[0]);
double ymx=-DBL_MAX,ymn=DBL_MAX;
for(int i=0;i<n;i++){
ymx=max(ymx,ps[i].y);
ymn=min(ymn,ps[i].y);
}
if(a.y<=ymn||a.y>=ymx)return 0;

for(int i=0;i<n;i++){
if(is_point_on_line(ps[i],ps[i+1],p))return 1;
}

int cnt1=0;
for(int i=0;i<n;i++)
if(is_point_on_line(a,b,ps[i]))cnt1++;

int cnt=0;
for(int i=0;i<n;i++)
if(is_intersected_ls(ps[i],ps[i+1],a,b))cnt++;

return (cnt-cnt1)%2;
}

int crossPol(vector<point> pol1, vector<point> pol2){
int szpol1=pol1.size();
int szpol2=pol2.size();

for(int i=0;i<szpol1;i++)
if(inside(pol1[i],pol2))return 1;

for(int i=0;i<szpol2;i++)
if(inside(pol2[i],pol1))return 1;

pol1.push_back(pol1[0]);
pol2.push_back(pol2[0]);

for(int i=0;i<szpol1;i++)
for(int j=0;j<szpol2;j++)
if(is_intersected_ls(pol1[i],pol1[i+1],pol2[j],pol2[j+1]))return 1;

return 0;
}

int gr[101][101],fg[101],m;

void dfs(int j){
fg[j]=1;
for(int k=0;k<m;k++)
if(gr[j][k]==1 && !fg[k])dfs(k);
}

int main(void){
int n;
point a;
vector<point>pol[101];

while(cin >> n,n){

for(int i=0;i<n;i++){
cin >> m;

for(int i=0;i<101;i++)pol[i].clear();

for(int i=0;i<101;i++){
for(int j=0;j<101;j++){
gr[i][j]=0;
}
fg[i]=0;
}

for(int j=0;j<m;j++){
for(int k=0;k<4;k++){
cin >> a.x >> a.y;
pol[j].push_back(a);
}
}

for(int j=0;j<m;j++){
for(int k=0;k<m;k++){
if(j!=k && crossPol(pol[j],pol[k]))gr[j][k]=gr[k][j]=1;
}
}

int cnt=0;
for(int j=0;j<m;j++){
if(fg[j]==0){
dfs(j);
cnt++;
}
}

cout << cnt << endl;
}
}
return 0;
}

Measured memory_bytes: 1008
import java.util.*;
public class Main {
	public static void main(String[] args){
        Main main = new Main();
        main.input();
        main.solve();
        main.output();
    }

    String f;
    int result;

    private void input() {
        Scanner sc = new Scanner(System.in);
        f = sc.next();
        result = 0;
    }

    private void solve() {
        if (f.equals("RRR")) {
            result = 3;
        } else if (f.equals("SRR") || f.equals("RRS")) {
            result = 2;
        } else if (f.contains("R")) {
            result = 1;
        } else {
            result = 0;
        }
    }

    private void output() {
        System.out.println(result);
    }
}


Measured memory_bytes: 35564
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstring>
#include <iterator>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <fstream>
#include <iomanip>
#include <cassert>
//#include <utility>
//#include <memory>
//#include <functional>
//#include <deque>
//#include <cctype>
//#include <ctime>
//#include <numeric>
//#include <list>
//#include <iomanip>

//#if __cplusplus >= 201103L
//#include <array>
//#include <tuple>
//#include <initializer_list>
//#include <forward_list>
//
//#define cauto const auto&
//#else

//#endif

using namespace std;


typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define F first
#define S second
#define mkp make_pair
#define RALL(v) (v).rbegin(),(v).rend()
#define DEBUG
#ifdef DEBUG
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#else
#define dump(x) 
#define debug(x) 
#endif

#define MOD 1000000007LL
#define EPS 1e-8
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)

void mainmain(){
	int a,b;
	cin>>a>>b;
	cout<<a*b<<endl;
}


signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(20);
    mainmain();
}

Measured memory_bytes: 3196
#include <stdio.h>

int main(void) {
    int a, b, c;
    scanf("%d %d %d%*c", &a, &b, &c);

    int count = 3;
    if(a == b) count--;
    if(b == c) count--;
    if(a == c) count--;
    if(count == 0) count++;

    printf("%d\n", count);

    return 0;
}


Measured memory_bytes: 128
#include<stdio.h>
#define N 8
#define free -1
#define Notfree 1
#define False 0
#define True 1

int row[N],col[N],dpos[2*N-1],dneg[2*N-1];
int A[N][N];

void initialize(void);
void recursive(int);
void printboard(void);

int main(){
  int i,j,n,a,b;
  initialize();
  for(i=0;i<N;i++){
    for(j=0;j<N;j++){
      A[i][j]=False;
    }

  }
  scanf("%d",&n);
  for(i=0;i<n;i++){

    scanf("%d %d",&a,&b);
    A[a][b]=True;
  }
  recursive(0);
  return 0;
}
void initialize(){
  int i,j;
  for(i=0;i<N;i++){
    row[i]=free;
    col[i]=free;
  }
  for(i=0;i<2*N-1;i++){
    dpos[i]=free;
    dneg[i]=free;
  }
}
void printboard(){
  int i,j;
  for(i=0;i<N;i++){
    for(j=0;j<N;j++){
      if(A[i][j]){
	if(row[i] != j){
	  return;
	}
      }
    }
  }
  for(i=0;i<N;i++){
    for(j=0;j<N;j++){
      if(row[i] == j)printf("Q");
      else printf(".");
    }
    printf("\n");
  }

}
void recursive(int i){
  int j;
  if(i == N){
    printboard();
    return;
  }
  for(j=0;j<N;j++){
    if(Notfree == col[j] || Notfree == dpos[i+j] || Notfree == dneg[i-j+N-1])continue;
    row[i]=j;
    col[j]=dpos[i+j]=dneg[i-j+N-1]=Notfree;
    recursive(i+1);
    row[i]=col[j]=dpos[i+j]=dneg[i-j+N-1]=free;
  }
}



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

typedef unsigned long long ll;

const ll base = 1000000007;

ll dp[100005][13];

int main(){
    string ss;
    cin >> ss;
    int s_size = ss.size();
    dp[0][0] = 1;
    for(int i = 0; i < s_size; i++){
        int c = ss[i] == '?' ? -1 : ss[i] - '0';
        for(int j = 0; j < 10; j++){
            if(c != -1 && c != j) continue;
            for(int k = 0; k < 13;k++){
                dp[i + 1][(k * 10 + j) % 13] += dp[i][k];
            }
        }
        for(int j = 0; j < 13; j++){
            dp[i+1][j] %= base;
        }
    }
    cout << dp[s_size][5] << endl;
}

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

#define rep(i,s,n) for(ll i = (s); i < (n); i++)
#define rep0(i,n) rep(i,0,n)
#define rep1(i,n) rep(i,1,n+1)
#define repR(i,s,n) for(ll i = (n-1); i >= (s); i--)
#define repR0(i,n) repR(i,0,n)
#define repR1(i,n) repR(i,1,n+1)

#define BR "\n"
#define SP " "
#define SHOW(x) for(int i = 0; i < x.size(); i++) { cout << x[i] << SP; } cout << BR;
#define SHOW2(x) for(int j = 0; j < x.size(); j++) { SHOW(x[j]); } cout << BR;
#define fcout cout << fixed << setprecision(18)

int main() {
  int N, M, X;
  cin >> N >> M >> X;

  int cnt = 0;
  rep0(i, M) {
    int a; cin >> a;
    if (a < X) cnt++;
  }
  
  int ans = min(cnt, M - cnt);
  cout << ans << BR;
  return 0;
}


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

void ans(int flag){
  if (flag == 0)
    puts("Yes");
  else
    puts("No");
}

int same_str(char *str1, char *str2){
  int i;
  int flag = 0;
  int len1 = strlen(str1);
  int len2 = strlen(str2);

  if(len2 != len1){
    flag = 1;
    return flag;
  }
  
  for(i=0; i<len1; i++){
    if(str1[i] != str2[i]){
      flag = 1;
      break;
    }
  }
  return flag;
}

int main(void){
  int n;
  char (*w)[11];
  int i, j;
  int len;
  int flag = 0;
  scanf("%d", &n);
  w = (char (*)[11])malloc(n * sizeof(char [11]));
  for(i=0; i<n; i++){
    scanf("%s", w[i]);
    if(i>0){
      if(w[i][0] != w[i-1][len-1])
	flag = 1;
      for(j=0; j<i; j++)
	if(same_str(w[i], w[j]) == 0)
	  flag = 1;
    }
    len = strlen(w[i]);
  }

  ans(flag);
  free(w);
  
  return 0;
}


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

#define ll long long
#define deb(name,val) cout<<name<<"= "<<val<<" "
#define infile    freopen("/home/suryakant/input.txt","r",stdin)
#define outfile   freopen("/home/suryakant/output.txt","w",stdout)

void solve(ll a,ll b)
{
	if(a==b)
	{
		cout<<"1";
		return;
	}
	int n,m=0;
	bitset<63>A(a);
	bitset<63>B(b);
	for(int i=62;i>=0;--i)
	{
		if(A[i]==B[i])
			A[i]=B[i]=0;
		else
		{
			n=i;
			break;
		}
	}
	m=-1;
	for(int i=n-1;i>=0;--i)
	{
		if(B[i]==1)
		{
			m=i;
			break;
		}
	}

	ll T = (1LL<<n);
	// deb("T->",T);
	ll P = (1LL<<(m+1)) + T -1;
	// deb("P->",P);
	ll AA = (long long)A.to_ulong();
	// deb("AA->",AA)<<"\n";
	ll BB = P;
	// deb("BB->",BB)<<"\n";
	ll CC = T + AA;
	// deb("CC->",CC)<<"\n";
	ll DD = T*2-1;
	// deb("DD=>",DD)<<"\n";
	ll ans;

	if(CC>BB)
	{
		ans = (DD-CC+1) + (BB-AA+1);
	}
	else
	{
		ans = (DD-AA+1);
	}
	cout<<ans;
}

int main()
{
	// infile,outfile;
	ll A,B;cin>>A>>B;
	solve(A,B);
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i=0;i < (int)(n);i++)

int table[101][101];



int main(){
    int n;
    cin >> n;
    int ans = 0;
    for (int i= 1;i*i <= n;i++){
        if ( i*i <= n);
        ans = max(ans,i*i);
    }
    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 256
local mmi, mma = math.min, math.max
local n = io.read("*n", "*l")
local up, down = {}, {}
for i = 1, n do
  local s = io.read()
  local cur = 0
  local min = 0
  for j = 1, #s do
    if s:sub(j, j) == "(" then
      cur = cur + 1
    else
      cur = cur - 1
    end
    min = mmi(min, cur)
  end
  local dec = -min
  if 0 <= cur then
    table.insert(up, {dec, cur})
  else
    local flag = s:sub(#s, #s) == "("
    table.insert(down, {dec, cur, flag})
  end
end

local function sort1(a, b)
  return a[1] < b[1]
end
local function sort2(a, b)
  if a[3] and not b[3] then
    return true
  elseif b[3] and not a[3] then
    return flase
  else
    return a[1] > b[1]
  end
end
table.sort(up, sort1)
table.sort(down, sort2)
local cur = 0
local valid = true
for i = 1, n do
  local dec, tot = 0, 0
  if i <= #up then
    dec, tot = up[i][1], up[i][2]
  else
    local p = i - #up
    dec, tot = down[p][1], down[p][2]
  end
  -- print(i, dec, tot)
  if cur - dec < 0 then
    -- print(cur, dec)
    valid = false
    break
  end
  cur = cur + tot
  if cur < 0 then valid = false break end
  -- print(i)
end
if valid then
  valid = cur == 0
end
-- valid = valid and cur == 0
print(valid and "Yes" or "No")


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

double diff(vector<double> x,vector<double> y){
    double d=0.0;
    for(int i=0;i<x.size();i++){
        double dx = x.at(i) - y.at(i);
        d += dx*dx;
    }
    return pow(d,0.5);
}

int main(){
    int n,d;
    cin >> n >> d;
    int ans=0;
    vector<vector<double>> x(n,vector<double>(d));
    for(int i=0;i<n;i++){
        for(int j=0;j<d;j++){
            cin >> x.at(i).at(j);
        }
    }
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            double d = diff(x.at(i),x.at(j));
            if(int32_t(d)==d){
                ans++;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 384
/*  -*- coding: utf-8 -*-
 *
 * b.cc: B - 0 or 1 Swap
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

/* typedef */

/* global variables */

/* subroutines */

/* main */

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

  int cnt = 0;
  for (int i = 0; i < n; i++) {
    int pi;
    scanf("%d", &pi);
    pi--;
    if (pi != i) cnt++;
  }

  if (cnt <= 2) puts("YES");
  else puts("NO");
  return 0;
}


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

#define ll long long
#define pb push_back
#define vi vector<int>
#define FOR(i, a, b) for(int i = a; i < b; i++)
#define sizeOf(A) (sizeof(A))/(sizeof(A[0]))
#define odd(x) ((x) % (2))

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

    int a, b, c;
    cin >> a >> b >> c;
    if (c >= a && c <= b) {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }
    return 0;
}


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

int main(){
	int a, b, c;
	cin >> a >> b >> c;

	if(a > b)
		swap(a, b);
	
	if(b > c)
		swap(b, c);

	if(a > b)
		swap(a, b);

	cout << a << " " << b << " " << c << endl;

	return 0;
}


Measured memory_bytes: 3100
#include <bits/stdc++.h>
typedef long long ll;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
	
using namespace std;

const int MAX_N=2000;
int N,Z,W,a[MAX_N];

int dp[MAX_N][2];

int dfs(int n,int f){
	int op;
	if (dp[n][f]!=-1){
		return dp[n][f];
	}
	if (n==0){
		op=W;
	}else{
		op=a[n-1];
	}
	int ret=abs(a[N-1]-op);
	REP(i,N-n-1){
		if (f==0){
			ret=max(ret,dfs(n+i+1,1));
		}else{
			ret=min(ret,dfs(n+i+1,0));
		}
	}
	return dp[n][f]=ret;
}
int main(){
	cin>>N>>Z>>W;
	REP(i,N){
		cin>>a[i];
	}
	memset(dp,-1,sizeof(dp));
	cout<<dfs(0,0)<<endl;
	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int a,b,k,x1,y_1,x2,y2,d[500005],v[1005][1005];
bool n[1005][1005],vi[500005];
char c;
struct st{
	int w,v;
	st(int V,int W){
		w=W;
		v=V;
	}
};
struct st1{
	int w,dd;
	st1(){}
	st1(int W,int DD){
		w=W;
		dd=DD;
	}
	friend bool operator < (st1 x,st1 y){return x.dd>y.dd;}
};
priority_queue<st1>q;
vector<st> ans[500005];
int Dijkstra(int s,int t){
	memset(d,0x3f,sizeof(d));
	memset(vi,0,sizeof(vi));
	d[s]=0;
	q.push(st1(s,0));
	while(q.size()){
		int x=q.top().w;
		q.pop();
		if(vi[x]){
			continue;
		} 
		vi[x]=1;
		int siz=ans[x].size();
		for(int i=0;i<siz;i++){
			int vr=ans[x][i].v,w=ans[x][i].w;
			if(d[vr]>d[x]+w){
				d[vr]=d[x]+w;
				q.push(st1(vr,d[vr]));
			}
		}
	}
	return d[t];
}
void dfs(int x,int y){
	if(x>1&&v[x-1][y]==0&&n[x-1][y]==0){
		n[x-1][y]=1;
		v[x-1][y]=k;
		dfs(x-1,y);
		n[x-1][y]=0;
	}
	if(x<a&&v[x+1][y]==0&&n[x+1][y]==0){
		n[x+1][y]=1;
		v[x+1][y]=k;
		dfs(x+1,y);
		n[x+1][y]=0;
	}
	if(y>1&&v[x][y-1]==0&&n[x][y-1]==0){
		n[x][y-1]=1;
		v[x][y-1]=k;
		dfs(x,y-1);
		n[x][y-1]=0;
	}
	if(y<b&&v[x][y+1]==0&&n[x][y+1]==0){
		n[x][y+1]=1;
		v[x][y+1]=k;
		dfs(x,y+1);
		n[x][y+1]=0;
	}
}
int main(){
	scanf("%d %d\n",&a,&b);
	scanf("%d %d\n",&x2,&y2);
	scanf("%d %d",&x1,&y_1);
	for(int i=1;i<=a;i++){
		scanf("\n");
		for(int j=1;j<=b;j++){
			scanf("%c",&c);
			if(c=='#')n[i][j]=1;
		}
	}
	for(int i=1;i<=a;i++){
		for(int j=1;j<=b;j++){
			if(v[i][j]==0&&n[i][j]==0){
				k++;
				v[i][j]=k;
				n[i][j]=1;
				dfs(i,j);
				n[i][j]=0;
			}
		}
	}
	for(int i=1;i<=a;i++){
		for(int j=1;j<=b;j++){
			for(int i1=max(1,i-2);i1<=min(a,i+2);i1++){
				for(int j1=max(1,j-2);j1<=min(b,j+2);j1++){
					if(v[i][j]!=0&&v[i1][j1]!=0&&v[i][j]!=v[i1][j1]){
						ans[v[i][j]].push_back(st(v[i1][j1],1));
						ans[v[i1][j1]].push_back(st(v[i][j],1));
					}
				}
			}
		}
	}
	if(Dijkstra(v[x1][y_1],v[x2][y2])==0x3f3f3f3f){
		printf("-1");
	}else printf("%d",Dijkstra(v[x1][y_1],v[x2][y2]));
	
}

Measured memory_bytes: 65868
import java.util.Scanner;

public class Main {
    public static void main(final String[] args) {
        final Scanner scanner = new Scanner(System.in);
        long a = scanner.nextLong();
        long b = scanner.nextLong();

        long tmp;
        while ((tmp = a % b) != 0) {
            a = b;
            b = tmp;
        }

        int count = 0;
        final double sqrt = Math.sqrt(b);
        for (int i = 2; i <= sqrt + 1; i++) {
            if (b % i == 0) {
                count++;
                while (b % i == 0) {
                    b /= i;
                }
            }
        }
        
        if (b != 1) {
            count++;
        }
        System.out.println(count + 1);
    }
}


Measured memory_bytes: 21844
#include <stdio.h>

int main(){
	int ap[4],bp[4],at,bt;
	scanf("%d %d %d %d",&ap[0],&ap[1],&ap[2],&ap[3]);
	scanf("%d %d %d %d",&bp[0],&bp[1],&bp[2],&bp[3]);
	at = ap[0] + ap[1] + ap[2] + ap[3];
	bt = bp[0] + bp[1] + bp[2] + bp[3];
	if(at >= bt) printf("%d\n",at);
	else printf("%d\n",bt);
	return 0;
}

Measured memory_bytes: 592
/*
    Code written by Talant I.D.
*/
   
#include <bits/stdc++.h>
   
using namespace std;
   
typedef long long ll;
typedef pair <int, int> pii;
typedef tuple <int, int, int> tiii;
   
#define precision(n) fixed << setprecision(n)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define mod (int)1e9+7
#define eps (double)1e-9
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define do_not_disturb ios::sync_with_stdio(0);cin.tie(0);
#define curMod 998244353

map <string, ll> used;

int main(){
		do_not_disturb
		ll com = 0, i, n;
		set <string> st;
		string s;
		
		cin >> n;
		
		for(i = 0; i < n; i++){
			cin >> s;
			sort(all(s));
			used[s]++;
			st.insert(s);
		}
		
		for(auto it = st.begin(); it != st.end(); it++){
			com += used[*it]*(used[*it]-1)/2;
		}
		
		cout << com;
		
    return 0;
} // What is to be written here?


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

#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = (n)-1; i >= 0; i--)
#define rep1(i,n) for(int i = 1; i <= (n); i++)
#define rrep1(i,n) for(int i = (n); i > 0; i--)

#define ll long long
#define pi pair<int, int>
#define pll pair<ll, ll>

#define MOD 1000000007
#define INF 1000000000000000LL

using namespace std;

int main(){
  int k;cin>>k;
  string s;cin>>s;

  if((int)s.size()<=k) { cout<<s; return 0; }

  rep(i, k)cout<<s[i];
  cout<<"...";

  return 0;
}

Measured memory_bytes: 3624
# -*- coding: utf-8 -*-
"""
Created on Thu Sep 26 12:13:54 2019

@author: hiros
"""

N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
"""
print(N)
print(A[0],A[1])
print(B[0],B[1])
print(C[0],C[1])


"""
c_dish = A[0]-1 #料理１ならc_dish = 0と定義
ans = B[c_dish] 
f_dish = c_dish #前に食べた料理番号

for i in range(1,N):
    c_dish = A[i]-1
    ans += B[c_dish]
    if (c_dish == f_dish + 1): #ボーナスポイント
        ans += C[f_dish]
    #print(ans, c_dish,f_dish)

    f_dish = c_dish
    #print(ans, c_dish,f_dish)

print(ans)
    

Measured memory_bytes: 38384
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;
#define vec(s) vector

#define vvec(s) vector<vector
>
typedef vector<lli> vi;
typedef vector<vi> vvi;
typedef pair<lli,lli> pii;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define YN(x) cout<<(bool x?"Yes":"No")<<endl;
#define out(s) cout<<s<<endl;
#define pb(s) push_back(s);
#define sp " ";
#define INF 10000000000
#define all(s) s.begin(),s.end()
void vout(vi v){
    for(int i=0;i<v.size();i++)
    cout<<v.at(i)<<endl;
}
int main(){
    lli n;
    cin >> n;
    out((n > 999 ? "ABD" : "ABC"));
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,a,n) for(int i = (a); i < (n); ++i)
#define ALL(a) (a).begin(), (a).end()
#define debug_v(v,N) for(int i=0;i<N;i++) { cout << v[i] << " "; } cout << endl;
#define debug_vv(v,H,W) for(int i=0;i<H;i++) { for(int j=0;j<W;j++) { cout << v[i][j] << " "; } cout << endl; }

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> pii;

int rec(int i, vi &H, vi &memo) {
    if (i == 0) return 0;
    if (memo[i] != -1) return memo[i];
    int res1 = rec(i - 1, H, memo) + abs(H[i] - H[i - 1]);
    int res2 = 2000000000;
    if (i > 1) {
        res2 = rec(i - 2, H, memo) + abs(H[i] - H[i - 2]);
    }
    return memo[i] = min(res1, res2);
}

void Main()
{
    // メモ再帰
    int N; cin >> N;
    vi H(N);
    rep(i, N) cin >> H[i];
    vi memo(N, -1);
    cout << rec(N - 1, H, memo) << endl;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
}


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

#ifdef __linux__
#define getchar getchar_unlocked
#define putchar putchar_unlocked
#endif
template <class Z> Z getint() {
  char c = getchar();
  bool neg = c == '-';
  Z res = neg ? 0 : c - '0';
  while (isdigit(c = getchar())) res = res * 10 + (c - '0');
  return neg ? -res : res;
}
template <class Z> void putint(Z a, char c = '\n') {
  if (a < 0) putchar('-'), a = -a;
  int d[40], i = 0;
  do d[i++] = a % 10; while (a /= 10);
  while (i--) putchar('0' + d[i]);
  putchar(c);
}

template <class T, T Op(T, T), T E()> struct FoldableDeque {
  vector<T> l, r, cuml{E()}, cumr{E()};
  T fold() const { return Op(cuml.back(), cumr.back()); }
  void build(vector<T> v) {
    l = r = {}, cuml = cumr = {E()};
    int n = v.size();
    for (int i = n / 2; i != n; ++i) push_back(v[i]);
    for (int i = n / 2; i--; ) push_front(v[i]);
  }
  void push_front(T a) { l.push_back(a), cuml.push_back(Op(a, cuml.back())); }
  void push_back(T a) { r.push_back(a), cumr.push_back(Op(cumr.back(), a)); }
  void pop_front() {
    if (l.empty()) build({++begin(r), end(r)});
    else l.pop_back(), cuml.pop_back();
  }
  void pop_back() {
    if (r.empty()) build({++rbegin(l), rend(l)});
    else r.pop_back(), cumr.pop_back();
  }
};

int _min(int a, int b) { return b < a ? b : a; }
int inf() { return 0x3f3f3f3f; }

int main() {
  int n = getint<int>();
  int l = getint<int>();
  FoldableDeque<int, _min, inf> fdeq;
  for (int i = 0; i != n; ++i) {
    fdeq.push_back(getint<int>());
    if (i >= l - 1) {
      putint(fdeq.fold(), " \n"[i == n - 1]);
      fdeq.pop_front();
    }
  }
}



Measured memory_bytes: 4620
#include<iostream>
using namespace std;
int main(){
  string s;
  cin >> s;
  if((s[0] == s[1] && s[0] == s[2])||s[1] == s[2] && s[2] == s[3])
    cout << "Yes" << "\n";
  else
    cout << "No" << "\n";
  return 0;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
lst = [list(map(int, input().rstrip().split())) for n in range(N)]
maximum = -float("inf")
for i in [-1, 1]:
    for j in [-1, 1]:
        for k in [-1, 1]:
            sum_lst = []
            for n in range(N):
                num = lst[n][0] * i + lst[n][1] * j + lst[n][2] * k
                sum_lst.append(num)
            maximum = max(abs(sum(sorted(sum_lst)[:M])), maximum)
            
print(maximum)

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

int main()
{
    int a, b;
    cin >> a >> b;
    for (int i = 1; i <= 999; i++) {
        int A = (i * (i + 1)) / 2 - a;
        int B = ((i + 1) * (i + 2)) / 2 - b;
        if (A == B) {
            cout << A << endl;
        }
    }
    return 0;
}

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

using namespace std;

int main(void){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	
	int N, T, tmp;
	vector<int> t;

	cin>>N>>T;
	for(int i = 0; i < N; i++){
		cin>>tmp;
		t.push_back(tmp);
	}

	vector<int>::iterator it = t.begin();
	vector<int>::iterator endIt = t.end();
	int sum = 0;
	int diff = *it-*(it-1);
	it++;
	while(it != endIt){
		if((diff=*it-*(it-1))<=T) 	sum += diff;
		else						sum += T;
		it++;
	}
	sum+=T;
	
	cout << sum << endl;


	
	return 0;
}


Measured memory_bytes: 1400
#include<iostream>
#include<string>

using namespace std;
using ll = long long;

int sx, sy, tx, ty;

void input(){
  cin >> sx >> sy >> tx >> ty;
}


string first_time(){
  string s;
  int y = ty - sy;
  int x = tx - sx;
  for(int i = 0; i < y; ++i){
    s.append("U");
  }
  for(int i = 0; i < x; ++i){
    s.append("R");
  }
  for(int i = 0; i < y; ++i){
    s.append("D");
  }
  for(int i = 0; i < x; ++i){
    s.append("L");
  }
  return s;
}

string second_time(){
  string s;
  int y = ty - sy;
  int x = tx - sx;
  s.append("L");
  for(int i = 0; i <= y; ++i){
    s.append("U");
  }
  for(int i = 0; i <= x; ++i){
    s.append("R");
  }
  s.append("D");
  s.append("R");
  for(int i = 0; i <= y; ++i){
    s.append("D");
  }
  for(int i = 0; i <= x; ++i){
    s.append("L");
  }
  s.append("U");
  return s;
}

int main(){
  input();
  cout << first_time() << second_time() << endl;
}

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

using namespace std;
using ll = long long;

ll gcd(const ll a, const ll b)
{
    if (a == 0 or b == 0) {
        return (a == 0) ? b : a;
    }
    if (a > b) {
        return gcd(b, a);
    } else {
        return gcd(b % a, a);
    }
}

constexpr int SQRT = 100000;
bool isprime[SQRT];

int main()
{
    ll p, q;
    cin >> p >> q;
    const ll g = gcd(p, q);
    q /= g;

    fill(isprime, isprime + SQRT, true);
    for (ll i = 2; i < SQRT; i++) {
        if (isprime[i]) {
            for (ll j = 2; i * j < SQRT; j++) {
                isprime[i * j] = false;
            }
        }
    }
    vector<ll> prime;
    for (ll i = 2; i < SQRT; i++) {
        if (isprime[i]) {
            prime.push_back(i);
        }
    }

    vector<ll> factor;
    for (ll p : prime) {
        if (q % p == 0) {
            factor.push_back(p);
        }
        while (q % p == 0) {
            q /= p;
        }
    }
    if (q > 1) {
        factor.push_back(q);
    }
    ll prod = 1;
    for (const ll f : factor) {
        prod *= f;
    }
    cout << prod << endl;

    return 0;
}

Measured memory_bytes: 3384
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()
using ll = long long;
const ll mod = 1000000007;
const ll INF = 100000000000000000LL;
signed main(){
    vector<int> a(3);
    rep(i,3)cin>>a[i];
    sort(ALL(a));
    if(a[0]==5&&a[1]==5&&a[2]==7)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}

Measured memory_bytes: 256
def main():
    N, M = (int(i) for i in input().split())
    from collections import defaultdict
    waCnt = defaultdict(int)
    ac = set()
    for _ in [0]*M:
        p, s = (i for i in input().split())
        if s == "WA" and p not in ac:
            waCnt[p] += 1
        else:
            ac.add(p)
    sumWA = sum(waCnt[p] for p in ac)
    print(len(ac), sumWA)


if __name__ == '__main__':
    main()


Measured memory_bytes: 68056
#include<bits/stdc++.h>
#include <ext/rope>

#define min3(a,b,c)   min(a,min(b,c))
#define max3(a,b,c)   max(a,max(b,c))
#define min4(a,b,c,d) min(min(a,b),min(c,d))
#define max4(a,b,c,d) max(max(a,b),max(c,d))

#define count_one(a) __builtin_popcount(a)  // Returns the number of set bits(1) in a number(a). In long long use __builtin_popcountll(a)
#define parity(i)    __builtin_parity(i)  //even parity 0 and odd parity 1
#define blz(a)       __builtin_clz(a) //Returns the number of leading zeroes in a number(a)
#define btz(a)       __builtin_ctz(a) //Returns the number of trailing zeroes in a number(a)
#define gcd(a,b)     __gcd(a,b)
#define lcm(a,b)     (a*(b/gcd(a,b)))

#define pb   push_back
#define PI   M_PI
#define endl "\n"
#define sc   scanf
#define pf   printf

#define ll  long long
#define ull unsigned long long

#define W(t)            while(t--)
#define rep1(i,n)       for(int i = 0; i < n; i++)
#define rep2(a,b)       for(int i = a; i <= b; i++)
#define rep3(a,b,c)     for(int i = a; i <= b; i+=c)
#define irep(a,b,c)     for(int i = b; i >=a; i-=c)
#define repit(it,type)  for(it = type.begin(); it != type.end(); it++)
#define IOS ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
using namespace std;
using namespace __gnu_cxx;

int main()
{
     IOS
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ll n,i,j,cnt=0;

    map<ll,ll> mp;

    cin>>n;
    ll a[n];

    rep1(i,n)
    {
        cin>>a[i];
        mp[a[i]]++;
    }
    sort(a,a+n);
    ll mx = a[n-1];
    for(i = 0; i < n; i++)
    {
         for(j = a[i]; j <= mx; j+=a[i])
         {
              if(j==a[i] && mp[j]>1)
              {
                   cnt+=mp[j];
                   mp[j] = 0;
              }
              if(mp[j]>=1 && j!=a[i])
              {
                   cnt+=mp[j];
                   mp[j] = 0;
              }
         }
    }

    cout<<n-cnt<<endl;

     return 0;
}



Measured memory_bytes: 67300
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    long a = scan.nextLong();
    long b = scan.nextLong();
    long k = scan.nextLong();
    if(a >= k){
      long x = a-k;
      System.out.println(x + " " + b);
    }else if(a < k && a+b >= k){
      long x = a+b-k;
      System.out.println(0 + " " + x);
    }else{
      System.out.println(0 + " " + 0);
    }
  }
}


Measured memory_bytes: 21844
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<algorithm>
#include<iostream>
#include<queue>
#include<map>
#include<cmath>
#include<set>
#include<stack>
#define ll long long
#define max(x,y) ((x)>(y)?(x):(y))
#define min(x,y) ((x)>(y)?(y):(x))
#define cls(name,x) memset(name,x,sizeof(name))
using namespace std;
const int inf=1<<28;
const int maxn=10;
const int maxm=20010;
const int mod=1e9+7;
const double pi=acos(-1.0);
int n;
int main()
{
    //freopen("in.txt","r",stdin);
    scanf("%d",&n);
    int vis[maxn];
    cls(vis,0);
    int k=0;
    for(int i=0;i<n;i++)
    {
        int score;
        scanf("%d",&score);
        if(score>=3200) k++;
        else vis[score/400]=1;
    }
    int c=0;
    for(int i=0;i<=7;i++)
        if(vis[i]) c++;
    if(c!=0)
        printf("%d %d\n",c,c+k);
    else printf("%d %d\n",1,c+k);
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<cstring>
using namespace std;
int main(void)
{
	int l,i,x;
	char s[101];
	cin>>s;
	l=strlen(s);
	x=l-2;
	cout<<s[0]<<x<<s[l-1]<<endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    Scanner s = new Scanner(System.in);
    int N = s.nextInt();
    int T[] = new int[N];
    int Sum = 0;
    for (int i = 0;i < N; i++){
      T[i] = s.nextInt();
      Sum += T[i];
    }
    int M = s.nextInt();
    int Sum2;
    for (int i = 0; i < M; i++){
      Sum2 = Sum;
      Sum2 -= T[s.nextInt() - 1];
      Sum2 += s.nextInt();
      System.out.println(Sum2);
    }
  }
}

Measured memory_bytes: 23636
#include <bits/stdc++.h>
using namespace std;
int main(){
	int N;
	cin>>N;
	char Si;
	for(int i=0;i<N;i++){
		cin>>Si;
		if(Si=='Y'){
			cout<<"Four";
			break;
		}
		if(i==N-1) cout<<"Three";
	}
}


Measured memory_bytes: 256
def int_raw():
    return int(raw_input())

def ss_raw():
    return raw_input().split()

def ints_raw():
    return map(int,ss_raw())

INF = 1<<29

def make1d_arr(n,val=INF):
    return [val for i in xrange(n)]

def make2d_arr(w,h,val =INF):
    return [[val for i in xrange(w)]for i in xrange(h)]


N,Q = ints_raw()
S = raw_input()
target = "AC"

table = [0]*N
 
for i in xrange(1,len(S)):
    if S[i-1:i+1] == target:
        table[i]=table[i-1]+1
    else:
        table[i]=table[i-1]

for i in xrange(Q):
    l, r = ints_raw()
    print table[r-1]-table[l-1]



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

int main() {
  int N; cin >> N;
  vector<int> A(N), B(N-1);
  rep(i, N-1) cin >> B[i];
  rep(i, N) {
    if (i == 0) A[0] = B[0];
    else if (i == N-1) A[N-1] = B[N-2];
    else A[i] = min(B[i-1], B[i]);
  }
  ll ans = accumulate(A.begin(), A.end(), 0);
  cout << ans << endl;
}

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

//ABCXYZ 2
//012345
//CDEZAB
int main () {
	int n;
	scanf ("%d", &n);
	char word[10001];
	scanf ("%s", word);
	int pnjg = strlen(word);
	for (int i = 0; i < pnjg; i++) {
		word[i] += n;
		if (word[i] > 'Z') {
			word[i] -= 26;
		}
		printf ("%c", word[i]);	
	}
	
	return 0;
}

Measured memory_bytes: 1608
#include<bits/stdc++.h>
using namespace std;
using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
const lint mod=1e9+7;

bool others(lint a, lint x1, lint y1, lint x2, lint y2, std::vector<std::vector<lint>>& mat){
  if(x1 > x2){
    lint tmp = x1;
    x1 = x2;
    x2 = tmp;
  }
  if(y1 > y2){
    lint tmp = y1;
    y1 = y2;
    y2 = tmp;
  }
  for(lint i=x1;i<=x2;i++){
    for(lint j=y1;j<=y2;j++){
      if(!(mat[i][j] == a || mat[i][j] == -1)) return false;
    }
  }
  return true;
}

int main()
{
  lint h,w,k;
  cin >> h >> w >> k;
  std::vector<string> s(h);
  REP(i,h) cin >> s[i];

  std::vector<std::vector<lint>> strw(k,std::vector<lint>(4,-1));
  lint cnt = 0;
  for(int i = 0;i<h;i++){
    for(int j = 0;j<w;j++){
      if(s[i][j] == '#'){
        strw[cnt][0] = i;
        strw[cnt][1] = j;
        strw[cnt][2] = i;
        strw[cnt][3] = j;
        cnt++;
      }
    }
  }

  std::vector<std::vector<lint>> result(h,std::vector<lint>(w,-1));
  REP(i,k) result[strw[i][0]][strw[i][1]] = i+1;

  REP(i,k){
    while(strw[i][3]+1 < w && others(i+1,strw[i][0],strw[i][1],strw[i][2],strw[i][3]+1,result)){
      strw[i][3]++;
    }
    while(strw[i][1]-1 >= 0 && others(i+1,strw[i][0],strw[i][1]-1,strw[i][2],strw[i][3],result)){
      strw[i][1]--;
    }
    while(strw[i][2]+1 < h && others(i+1,strw[i][0],strw[i][1],strw[i][2]+1,strw[i][3],result)){
      strw[i][2]++;
    }
    while(strw[i][0]-1 >= 0 && others(i+1,strw[i][0]-1,strw[i][1],strw[i][2],strw[i][3],result)){
      strw[i][0]--;
    }

    lint x1=strw[i][0],y1=strw[i][1],x2=strw[i][2],y2=strw[i][3];
    if(x1 > x2){
      lint tmp = x1;
      x1 = x2;
      x2 = tmp;
    }
    if(y1 > y2){
      lint tmp = y1;
      y1 = y2;
      y2 = tmp;
    }
    for(lint j=x1;j<=x2;j++){
      for(lint k=y1;k<=y2;k++){
        result[j][k] = i+1;
      }
    }

  }

  REP(i,h){
    REP(j,w) cout << result[i][j] << " ";
    cout << "\n";
  }
  return 0;
}


Measured memory_bytes: 7936
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
#define ld long double
#define INF 1000000000000000000
typedef pair<ll, ll> pll;
typedef pair<int, int> pint;

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

    int N;
    cin >> N;
    rep(i, N) {
        string s, t;
        cin >> s >> t;
        int N = s.size(), M = t.size();
        vector<vector<int>> dp(N + 1, vector<int>(M + 1));

        rep(i, N) {
            rep(j, M) {
                if (s[i] == t[j])
                    dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i][j] + 1);
                dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i][j + 1]);
                dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i + 1][j]);
            }
        }

        cout << dp[N][M] << endl;
    }
}


Measured memory_bytes: 6852
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define bit(n) (1<<(n))
#define ii(x) int x; cin >> (x)
#define ii2(x, y) int x, y; cin >> (x) >> (y)
#define ii3(x, y, z) int x, y, z; cin >> (x) >> (y) >> (z)
#define yn(x, ok, ng) cout << ((x)?(ok):(ng)) << endl
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}
int const INF = 1001001001;


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

ld a;
ld b;
cin >> a >> b;
cout << (ll)floor(a*b) << endl;
return 0;
}

Measured memory_bytes: 3764
#include <iostream>
#include <algorithm>
#include <string>
#include <map>
#include <math.h>
#include <set>

using namespace std;
typedef long long  ll;
#define rep(i,s,n)for(ll i=s;i<n;i++)
#define repe(i,s,n)for(ll i=s;i<=n;i++)

static const double PI = 3.1415926535897932384626433;

///////////////////////////
////Prime Creator//////////
///////////////////////////
//bool Prime[100001] = {};
//void createPrime() {
//	ll n = 100001;
//	rep(i, 0, n) Prime[i] = true;
//	Prime[0] = false;
//	Prime[1] = false;
//	rep(i, 2, n) {
//		if (Prime[i]) {
//			rep(j, 2, n) {
//				if (j*i >= n)break;
//				Prime[j*i] = false;
//			}
//		}
//	}
//}
///////////////////////////
///////////////////////////

///////////////////////////
////Warshal Floyid/////////
///////////////////////////
////initialize`
////rep(i, 0, N)rep(j, 0, N) wf[i][j] = 1 << 29;
//static const ll WF_MAX = 300;
//ll wf[WF_MAX][WF_MAX];
//void WarshalFloyid(int size) {
//	rep(k, 0, size)rep(i, 0, size)rep(j, 0, size)wf[i][j] = min(wf[i][j], wf[i][k] + wf[k][j]);
//}

ll A[100000] = {};
ll B[100000] = {};
int main() {
	ll N; cin >> N;

	rep(i, 0, N) {
		cin >> A[i];
		B[A[i]]++;
	}
	ll c = 0;
	ll t = 0;
	rep(i, 0, 100000) {
		if (B[i] != 0) {
			if (B[i] % 2 == 0) {
				B[i] = 2;
				c++;
			}
			else {
				B[i] = 1;
			}
			t++;
		}
	}
	if (c % 2 == 0) {
		cout << t << endl;
	}
	else {
		cout << t - 1 << endl;
	}

	return 0;
}

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

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

#define p_ary(ary,a,b) do { cout << "["; for (int count = (a);count < (b);++count) cout << ary[count] << ((b)-1 == count ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

vector<int> zAlgorithm(bitset<1000010>& s) {
    // int n = s.size();
    int n = 1000010;
    vector<int> ret(n,0);
    ret[0] = n;
    int i = 1,j = 0;
    while (i < n) {
        while (i+j < n && s[j] == s[i+j]) ++j;
        ret[i] = j;
        if (j == 0) {
            ++i;
            continue;
        }
        int k = 1;
        while (i+k < n && k+ret[k] < j) {
            ret[i+k] = ret[k];
            ++k;
        }
        i += k;
        j -= k;
    }
    return ret;
}

array<bitset<1000010>,30> s;

int main() {
    int n;
    cin >> n;
    vector<int> a(n),b(n);
    for (int i = 0;i < n;++i) scanf("%d",&a[i]);
    for (int i = 0;i < n;++i) scanf("%d",&b[i]);
    for (int i = 0;i < 30;++i) for (int j = 0;j < n;++j) {
        if ((a[j]>>i)&1) s[i].set(j);
        if ((b[j]>>i)&1) s[i].set(j+n),s[i].set(j+n+n);
        else s[i].set(j+3*n),s[i].set(j+4*n);
    }
    vector<vector<int>> c(30,vector<int>(1000010));
    vector<P> ans;
    for (int i = 0;i < 30;++i) c[i] = zAlgorithm(s[i]);
    for (int i = 0;i < n;++i) {
        bool ok = true;
        for (int j = 0;j < 30;++j) if (c[j][2*n-i] < n && c[j][4*n-i] < n) {ok = false;break;}
        if (ok) cout << i << " " << (a[0]^b[(n-i)%n]) << "\n";
    }
    // for (int j = 0;j < 30;++j) p_ary(c[j],0,5*n);
    // for (int i = 0;i < 30;++i) for (int j = 0;j < n*5;++j) cout << s[i][j] << " \n"[j == n*5-1];
}

Measured memory_bytes: 126524
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>
#include <iomanip>
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
const ll MOD=1000000007;
const ll MAX_N=500010;
const ll INF=999999999999;

int main(){
    ll n;
    cin>>n;
    vector<ll> a(n);
    vector<ll> b(n);
    for(ll i=0;i<n;i++) cin>>a[i]>>b[i];
    sort(a.begin(),a.end());
    sort(b.begin(),b.end());
    ll ans;
    if(n%2==0){
        ld left=(ld)(a[n/2-1]+a[n/2])/2;
        ld right=(ld)(b[n/2-1]+b[n/2])/2;
        ans=2*right-2*left+1;
    }else{
        ans=b[n/2]-a[n/2]+1;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 6372
//%std
#include<bits/stdc++.h>
#define endl '\n'
using namespace std;
typedef long long ll;
inline int read()
{
	int out=0,fh=1;
	char jp=getchar();
	while ((jp>'9'||jp<'0')&&jp!='-')
		jp=getchar();
	if (jp=='-')
		fh=-1,jp=getchar();
	while (jp>='0'&&jp<='9')
		out=out*10+jp-'0',jp=getchar();
	return out*fh;
}
void report(int x,int y)
{
	printf("%d %d\n",x,y);
}
int N;
void solve(int n)
{
	report(1,2);
	report(2,3);
	report(3,1+N);
	report(1+N,2+N);
	report(2+N,3+N);
	for(int i=4;i<=n;i+=2)
	{
		report(1+N,i+N);
		report(i+N,i+1+N);
		report(1+N,i+1);
		report(i+1,i);
	}
}
int main()
{
	int n=read();
	N=n;
	if(__builtin_popcount(n)==1)
		puts("No");
	else
	{
		puts("Yes");
		if(n&1)
			solve(n);
		else
		{
			solve(n-1);
			for(int i=2;i<n;++i)
			{
				int j=(n+1)^i;
				if(1<j && j<n && i!=j)
				{
					report(n,i&1?i:i+N);
					report(n+N,j&1?j:j+N);
					break;
				}
			}
		}
	}
	return 0;
}


Measured memory_bytes: 2816
k = int(input())
if k % 2 == 0 or k % 5 == 0:
    print(-1)
    exit(0)

a = 7
ans = 1
while True:
    if a % k == 0:
        print(ans)
        exit(0)
    a = (a*10+7) % k
    ans += 1

Measured memory_bytes: 9084