akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main(){
    int h, w, i, j, k;
    cin >> h >> w;
    char a[h][w+1];
    for(i=0; i<h; i++){
        for(j=0; j<w; j++){
            cin >> a[i][j];
        }
    }
    for(i=0; i<h; i++){
        a[i][w] = '\n';
    }
    for(i=0; i<h; i++){
        for(j=0; j<w; j++){
            if(a[i][j] == '#'){
                break;
            }
            if(j == w-1){
                for(k=0; k<=w; k++){
                    a[i][k] = ' ';
                }
            }
        }
    }
    for(j=0; j<w; j++){
        for(i=0; i<h; i++){
            if(a[i][j] == '#'){
                break;
            }
            if(i == h-1){
                for(k=0; k<h; k++){
                    a[k][j] = ' ';
                }
            }
        }
    }
    for(i=0; i<h; i++){
        for(j=0; j<=w; j++){
            if(a[i][j] != ' '){
                cout << a[i][j];
            }
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector< vector<char> > F;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define SORT(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define EQ(a,b) (abs((a)-(b))<eps)
struct Fi
{
	int turn;
	char f[10][10];
	Fi(int t,char b[10][10])
	{
		turn=t;
		for(int i=0;i<10;i++)
		{
			for(int j=0;j<10;j++)
			{
				f[i][j]=b[i][j];
			}
		}
	}
};
int n,m;
char rgb[4]="RGB";
bool All(char a[10][10])
{
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<m;j++)
		{
			if(a[i][j]!=a[0][0])return false;
		}
	}
	return true;
}
int dx[4]={0,0,1,-1};
int dy[4]={1,-1,0,0};
char buf[10][10];
char st[10][10];
bool used[10][10];
char sor;
int ty;
void print(char a[10][10])
{
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<m;j++)
		{
			cout << a[i][j] << ' ';
		}
		cout << endl;
	}
	return;
}
void dfs(int x,int y)
{
	//cout << x << ' ' << y << endl;
	used[x][y]=true;
	buf[x][y]=rgb[ty];
	for(int i=0;i<4;i++)
	{
		int nx=x+dx[i],ny=y+dy[i];
		if(nx<0||nx>=n||ny<0||ny>=m)continue;
		if(used[nx][ny])continue;
		if(buf[nx][ny]!=sor)continue;
		dfs(nx,ny);
	}
	return;
}
int bfs()
{
	if(All(st))return 0;
	queue<Fi> q;
	Fi start(0,st);
	q.push(start);
	while(!q.empty())
	{
		Fi a=q.front();
		//print(a.f);
		q.pop();
		for(int i=0;i<3;i++)
		{
			if((a.f)[0][0]==rgb[i])continue;
			memset(used,false,sizeof(used));
			sor=(a.f)[0][0];
			ty=i;
			memcpy(buf,a.f,sizeof(a.f));
			dfs(0,0);
			//print(nb);
			//cout << a.fi+1 << endl << endl;
			if(All(buf))return a.turn+1;
			q.push(Fi(a.turn+1,buf));
		}
	}
	return 0;
}
int main()
{
	while(1)
	{
		cin >> m >> n;
		if(n==0&&m==0)break;
		for(int i=0;i<n;i++)
		{
			for(int j=0;j<m;j++)
			{
				cin >> st[i][j];
			}
		}
		cout << bfs() << endl;
	}
	return 0;
}

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

ll N, S, dp[15][105][1105];  // dp[i][j][k] = i個のj未満の整数を使って総和がkになるような通り

int main() {
    while(cin >> N >> S, N){
        for(int i=0;i<=N;i++){
            for(int j=0;j<=101;j++){
                fill(dp[i][j], dp[i][j]+S+1,0);
            }
        }
        dp[0][0][0] = 1;
        for(int i=0;i<=N;i++){
            for(int j=0;j<=100;j++){
                for(int k=0;k<=S;k++){
                    dp[i+1][j+1][k+j] += dp[i][j][k];
                    dp[i][j+1][k] += dp[i][j][k];
                }
            }
        }
        cout << dp[N][101][S] << endl;
    }
    return 0;
}


Measured memory_bytes: 12780
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int x = sc.nextInt();
    if (x == 0 ) {
      System.out.println(1);
    } else if (x ==1) {
      System.out.println(0);
    }
  }
}


Measured memory_bytes: 27016
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;

public class GcdAndLcm
{
	public static void Main(string[] args)
	{
		BindingList<string> outputList = new BindingList<string>();
		do
		{
			string input = Console.ReadLine();
			if (string.IsNullOrEmpty(input))
			{
				break;
			}
			string[] inputList = input.Split(' ');
			ulong divideBy = ulong.Parse(inputList[0]);
			ulong divide = ulong.Parse(inputList[1]);
			if (ulong.Parse(inputList[1]) > ulong.Parse(inputList[0]))
			{
				divideBy = ulong.Parse(inputList[1]);
				divide = ulong.Parse(inputList[0]);
			}
			ulong gcd = 1;
			do
			{
				ulong quotient = divideBy % divide;
				if (quotient == 0)
				{
					gcd = divide;
					break;
				}
				divideBy = divide;
				divide = quotient;
			} while (true);
			ulong lcm = (ulong.Parse(inputList[0]) * ulong.Parse(inputList[1])/gcd);
			outputList.Add(gcd + " " + lcm);
		} while(true);
		
		foreach (string output in outputList)
		{
			Console.WriteLine(output);
		}
	}
}

Measured memory_bytes: 6460
from fractions import gcd
import copy

class SegmentTree:
    def __init__(self, N, func, I):
        self.sz = 2 ** (N-1).bit_length()
        self.func = func
        self.I = copy.deepcopy(I)
        self.seg = [copy.deepcopy(I) for i in range(self.sz * 2)]

    def assign(self, k, x):
        self.seg[k + self.sz] = copy.deepcopy(x)

    def build(self):
        for i in range(self.sz - 1, 0, -1):
            self.seg[i] = self.func(self.seg[2 * i], self.seg[2 * i + 1])

    def update(self, k, x):
        k += self.sz
        self.seg[k] = copy.deepcopy(x)
        while k > 1:
            k //= 2
            self.seg[k] = self.func(self.seg[2 * k], self.seg[2 * k + 1])

    def query(self, a, b):
        L = copy.deepcopy(self.I)
        R = copy.deepcopy(self.I)
        a += self.sz
        b += self.sz
        while a < b:
            if a % 2 == 1:
                L = self.func(L, self.seg[a])
                a += 1
            if b % 2 == 1:
                b -= 1
                R = self.func(self.seg[b], R)
            a //= 2
            b //= 2
        return self.func(L, R)

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

def f(x,y):
    if x * y == 0:
        return x + y
    else:
        return gcd(x,y)

seg = SegmentTree(N + 1, f, 0)
for i in range(N):
    seg.assign(i , A[i])
seg.build()

ans = 1
for i in range(N):
    ans = max(ans , f(seg.query(0 , i) , seg.query(i + 1 , N)))
print(ans)



Measured memory_bytes: 121620
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        final Scanner sc=new Scanner(System.in);

        final double A = Integer.parseInt(sc.next());
        final double B = Integer.parseInt(sc.next());
        final double H = Integer.parseInt(sc.next());
        final double M = Integer.parseInt(sc.next());

        final double parseH = H * 30d + (30d * (M / 60d));
        final double parseM = M * 6d;

        double ang = Math.abs(parseH - parseM);
//        if (ang > 180d) {
//            ang -= 180d;
//        } else if (ang == 360) {
//            ang = 0d;
//        } else {
//
//        }
        final double ans = Math.sqrt(Math.pow(A, 2) + Math.pow(B, 2) -2d * A * B * Math.cos(Math.toRadians(ang)));
        System.out.print(ans);
    }
}

Measured memory_bytes: 35776
#include <iostream>
#include <algorithm>

int calc(std::string N) {
    int ret = 0;
    for (auto i=N.begin(); i!=N.end(); i++) {
        ret += (*i - '0');
    }
    return ret;
}

int main() {
    int N, A, B;
    std::cin >> N >> A >> B;
    
    int ans = 0;
    for (int i=1; i<=N; ++i) {
        int temp = calc(std::to_string(i));
        if (temp >= A && temp <= B)
            ans += i;
    }
    std::cout << ans << std::endl;
}

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

using namespace std;

int a[1000][1000],H,W,h,w;

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin>>H>>W>>h>>w;
    for (int i=1;i<=H;i++)
        for (int j=1;j<=W;j++)
            if (i%h==0 && j%w==0) a[i][j]=-696*(h*w-1)-1;
            else a[i][j]=696;
    int sum=0;
    for (int i=1;i<=H;i++)
        for (int j=1;j<=W;j++) sum+=a[i][j];
    if (sum<=0) {
        cout<<"No";
        return 0;
    }
    cout<<"Yes"<<endl;
    for (int i=1;i<=H;i++) {
        for (int j=1;j<=W;j++) cout<<a[i][j]<<" ";
        cout<<endl;
    }
}


Measured memory_bytes: 3328
#include <iostream>
#include <algorithm>
#include <cmath>
#include <queue>
#include <set>
#include <vector>
#include <string>
using namespace std;

#pragma GCC optimize("O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//(UNCOMMENT WHEN HAVING LOTS OF RECURSIONS)
#pragma comment(linker, "/stack:200000000")
//(UNCOMMENT WHEN TRYING TO BRUTEFORCE WITH A LOT OF LOOPS)
#pragma GCC optimize("unroll-loops")

#define DEBUG(x) cout << ">> " << #x << ": " << x << endl;
#define _ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const int MOD = 1000000007;
typedef long long ll;
typedef long double ld;

int main() { _
  int n; cin >> n;
  string s; cin >> s;
  int ans = 0;
  for (int i = 0; i < 10; i++) {
    for (int j = 0; j < 10; j++) {
      for (int k = 0; k < 10; k++) {
        char first = i + (int)'0', second = j + (int)'0', third = k + (int)'0';
        vector<bool> check(2, false);
        for (char c : s) {
          if (c == first && !check[0]) check[0] = true;
          else if (c == second && check[0] && !check[1]) check[1] = true;
          else if (c == third && check[1]) {
            ans++;
            break;
          }
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 384
def gcd(a, b)
   if b == 0
      return a
   else
      return gcd(b, a%b);
    end 
end

x = Array.new(201) {Array.new(201)}
k = gets.to_i
sum = 0

1.upto(200) do |a|
    a.upto(200) do |b|
        x[a][b] = gcd(a,b)
        x[b][a] = gcd(a,b)
    end
end

1.upto(k) do |a|
    1.upto(k) do |b|
        1.upto(k) do |c|
            sum += gcd(x[a][b], x[b][c])
        end
    end
end

puts sum

Measured memory_bytes: 14548
let for_range s e step f =
  let rec loop i =
    if i > e then ()
    else
      begin f i;loop (i + step) end
  in loop s;;

let a =
  let num = 1000000 in
  let p = Array.init (num+1) (fun x -> 1) in
  let rec loop i =
    if i*i < num then
      begin
        if p.(i) = 1 then
          for_range (i+i) num i (fun x -> p.(x) <- 0);
        loop (i+2)
      end
  in
  p.(0) <- 0; p.(1)<-(0);
  for_range 4 num 2 (fun x -> p.(x) <- 0);
  loop 3;
  for i = 1 to num-1 do
    p.(i) <- p.(i) + p.(i-1);
  done;
  let rec read () =
    try let n = read_int () in
        Printf.printf "%d\n" p.(n);
        read ()
    with End_of_file -> ()
  in read ();;

Measured memory_bytes: 10196
#include<bits/stdc++.h>
using namespace std;
int a[105],b[105],f[105],ans=99999999;
int main()
{
	//cout<<-1;
	//return 0;
	int n,m;
	cin>>n>>m;
	for(int i=1;i<=m;i++)
	{
		cin>>a[i]>>b[i];
		if(f[a[i]]&&f[a[i]]!=b[i])
		{
			cout<<-1;
			return 0;
		}
		f[a[i]]=b[i];
	}
	if(n==1)
	{
		cout<<b[1];
		return 0;
	}
	for(int i=pow(10,n-1);i<=pow(10,n)-1;i++)
	{
		for(int j=1;j<=m;j++)
		{
			int q=int(i/pow(10,n-a[j]))%10;
			if(q!=b[j])goto loop;
		}
		ans=min(i,ans);
		loop:;
	}
	if(ans!=99999999)cout<<ans;
	else cout<<-1;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstring>
#include<queue>
#include<map>
#include<set>
#include<cassert>

using namespace std;

typedef long long ll;

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

int di[]={0,-1,0,1};
int dj[]={1,0,-1,0};

int gcd(int a,int b)
{
	if(a<b) swap(a,b);
	if(b==0) return a;
	return a%b==0?b:gcd(b,a%b);
}

struct ST
{
	private:
		int n;
		vector<int> node;

	public:
		ST(vector<int> v)
		{
			int size=v.size();
			n=1;
			while(n<size) n*=2;
			node.resize(2*n-1,0);

			for(int i=0;i<size;i++) node[i+n-1]=v[i];
			for(int i=n-2;i>=0;i--) node[i]=gcd(node[2*i+1],node[2*i+2]);
		}

		void update(int x,int v)
		{
			x+=n-1;
			node[x]=v;
			while(x>0)
			{
				x=(x-1)/2;
				node[x]=gcd(node[2*x+1],node[2*x+2]);
			}
		}

		int get(int a,int b,int k=0,int l=0,int r=-1)
		{
			if(r<0) r=n;
			if(r<=a||b<=l) return 0;
			if(a<=l||r<=b) return node[k];

			int vl=get(a,b,2*k+1,l,(l+r)/2);
			int vr=get(a,b,2*k+2,(l+r)/2,r);
			return gcd(vl,vr);
		}
};

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

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

	auto st=ST(a);
	int res=0;
	for(int i=0;i<n;i++)
	{
		st.update(i,0);
		res=max(res,st.get(0,n));
		st.update(i,a[i]);
	}

	cout<<res<<endl;

	return 0;
}


Measured memory_bytes: 2048
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
typedef long long ll;

int main(){
    string s ; cin >> s;
    cout <<((s[0] == s[2])? "Yes":"No") << endl ; return 0;
}


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

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

int main(){
  string s;
  cin >> s;
  int n = s.size()+1;

  vector<int> right(n,0);
  vector<int> left(n,0);

  int count=0;
  rep(i,n-1){
    if(s.at(i)=='<')count++;
    else count=0;
    right.at(i+1)=count;
  }
  rep(i,n-1){
    int j=n-i-2;
    if(s.at(j)=='>')count++;
    else count=0;
    left.at(j)=count;
  }

  //rep(i,n)cout<<left.at(i)<<" ";
  ll ans=0;
  rep(i,n) ans+=max(left.at(i), right.at(i));
  cout << ans;
}

Measured memory_bytes: 7716
def resolve():
    n = int(input())
    csf = list(list(map(int, input().split())) for _ in range(n - 1))
    for i in range(n - 1):
        now = 0
        for c, s, f in csf[i:]:
            if now <= s:
                now = s + c
            elif now % f == 0:
                now += c
            else:
                now += f - ((now - s) % f) + c
        print(now)
    print(0)


if __name__ == "__main__":
    resolve()


Measured memory_bytes: 3188
#define _USE_MATH_DEFINES
#include  <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include<math.h>
#include<iomanip>
#include<stdio.h>
#include <stdlib.h>
#include<stdio.h>
#include <queue>
#include<map>
#include <sstream>
#include<set>
#include<stack>
#include<time.h>
typedef long long int ll;
//#include<bits/stdc++.h>


using namespace std;



int main()
{

    int k, a, b;
    cin >> k >> a >> b;
    for (int i = a; i <= b; i++) {
        if (i % k == 0) {
            cout << "OK" << endl;
            return 0;
        }
    }
    cout << "NG" << endl;
    return 0;

}


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

#define rep(i,n) for(signed i=0;i<n;++i)
#define int long long
#define str string
#define debg(a) cout<<#a<<":"<<a<<endl;
#define print(a) cout<<a<<endl;
#define end cout<<endl;
#define elif else if


int a,b,c,i,j,k,n,m,x,y,z;
str s,t;
vector<signed> v;

signed main(){
  int n;
  cin>>n;
  
  int a[n][3];
  rep(i,n)rep(j,3)cin>>a[i][j];
  
  int dp[n+1][3];
  rep(i,n+1)rep(j,3)dp[i][j]=0;

  rep(i,n){
    rep(j,3){
      rep(k,3){
        if(j==k)continue;
          dp[i+1][k] = max( dp[i+1][k], dp[i][j]+a[i][k] );
      }
    }
  }

  int ans = max(dp[n][0],max(dp[n][1],dp[n][2]));
  cout<<(ans)<<endl;

  return 0;
}


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

int main() {
    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;
	int dx = tx - sx, dy = ty - sy;
    
	string res = "";

    // 1 回目
	for (int i = 0; i < dx; ++i) res += "R";
	for (int i = 0; i < dy; ++i) res += "U";
	for (int i = 0; i < dx; ++i) res += "L";
	for (int i = 0; i < dy; ++i) res += "D";

    // 2 回目
	res += "D";
	for (int i = 0; i <= dx; ++i) res += "R";
	for (int i = 0; i <= dy; ++i) res += "U";
	res += "L";
	res += "U";
	for (int i = 0; i <= dx; ++i) res += "L";
	for (int i = 0; i <= dy; ++i) res += "D";
	res += "R";
	cout << res << endl;
}


Measured memory_bytes: 256
//®¬
//ño
/* ¤ã£Zåï200lÌ3gÌ[XªsíêÜµ½B
 * »ê¼êÌgÉ8¼iv24¼jÌIèªoêµÜ·Beg
 * ãÊ2ÊÜÅÆegÌ3ÊÈºÌSIèÌ©çãÊ2¼Ì
 * v8¼ªÉioµÜ·BIèÔÆ^CðüÍÆµ
 * AioÒ8¼ÌÔÆ»Ì^CðoÍµÄI¹·é
 * vOðì¬µÄº³¢BüÍf[^Ì1Ú©ç8
 * ÚÜÅª1gÚA9Ú©ç16ÚÜÅª2gÚA17Ú©
 * ç24ÚÜÅª3gÚÌf[^ÆµÜ·B^CÍA1/100
 * ÜÅvªµA¯^CÌIèÍ¢È¢àÌÆµAü Í³¢àÌÆµÜ·B
 */
#include<stdio.h>
struct Data{
	int n;
	double v;
};
struct Data d[8];
int main(){
	struct Data t[12];
	int s=0;
	int i,j,k,n=0,c=0;
	double tmp;
	int tm;
	for(i=0;i<8;i++){
		scanf("%d %lf",&d[i].n,&d[i].v);
		if(i==7){
			for(j=0;j<8;j++){
				for(k=j;k<8;k++){
					if(d[j].v>d[k].v){
						tmp=d[j].v;
						d[j].v=d[k].v;
						d[k].v=tmp;
						tm=d[j].n;
						d[j].n=d[k].n;
						d[k].n=tm;					}
				}
			}
			for(j=0;j<2;j++)printf("%d %.2lf\n",d[j].n,d[j].v);
			for(;j<4;j++)t[n++]=d[j];
			i=-1;
			c++;
			if(c==3)break;
		}
	}
	for(j=0;j<6;j++){
		for(k=j;k<6;k++){
			if(t[j].v>t[k].v){
				tmp=t[j].v;
				t[j].v=t[k].v;
				t[k].v=tmp;
				tm=t[j].n;
				t[j].n=t[k].n;
				t[k].n=tm;					}
		}
	}
	for(j=0;j<2;j++)printf("%d %.2lf\n",t[j].n,t[j].v);
	return 0;
}

Measured memory_bytes: 0
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class Main {

    public static void main(String[] args) throws Exception {
        InputStreamReader is = new InputStreamReader(System.in);
        BufferedReader reader = new BufferedReader(is);

        List<String> mylist = new ArrayList<>();

        // 標準入力からの値を変数strinputに代入
        String strinput = reader.readLine();

        while (strinput != null) {

            mylist.add(strinput);
            strinput = reader.readLine();

        }

        List<String> list01 = Arrays.asList(mylist.get(0).split(" "));

        //String arr[] = mylist.get(0).split(" ");
        int a = Integer.valueOf(list01.get(0));
        int b = Integer.valueOf(list01.get(1));
        int c = Integer.valueOf(list01.get(2));

        int nokori = a - b > 0 ? a - b : 0;

        if (nokori == 0) {
            System.out.println(c);
        } else {
            if (c >= nokori) {
                System.out.println(c - nokori);
            } else {
                System.out.println(0);
            }

        }
    }

}

Measured memory_bytes: 21972
#include  <iostream>
#include  <stdio.h>
#include <algorithm>
#include <map>
#include <math.h>

using namespace std;
#include <vector>
#define rep(i,n) for (int i = 0; i < (n) ; i++)
#define INF 1e9
#define llINF 1e18
#define base10_4 10000      //1e4
#define base10_5 100000     //1e5
#define base10_6 1000000    //1e6
#define base10_7 10000000   //1e7
#define base10_8 100000000  //1e8
#define base10_9 1000000000 //1e9

#define MOD 1000000007
#define pb push_back
#define ll long long
#define ull unsigned long long
#define vint vector<int>
#define vll vector<ll>

//#include <stack>
//#include <queue>

string ans_Yes = "Yes"; 
string ans_No = "No"; 
string ans_yes = "yes"; 
string ans_no = "no"; 

ll A[base10_5];
ll B;
ll C;
ll N;
ll M;
ll K;

int main(){

    
    cin >> N;
    cin >> M;
    ll sum=0;
    rep(mi,M){
        cin >> A[mi];
        sum+=A[mi];
    }

    if(sum>N) cout << -1 << endl;
    else cout << N-sum << endl;



}

Measured memory_bytes: 3676
# include <bits/stdc++.h>
  
  int num(char a,char b,char c){
      return (a-'0')*100 + (b-'0')*10 + (c-'0');
  }
using namespace std ;
int main () {

     string s;
     cin>>s;
     
     int n = s.length();
     vector<int>  v;
     for(int j=0;j<n-2;++j){
         
             v.push_back(abs(753-num(s[j],s[j+1],s[j+2])));
         
     }
     
     
     cout<<*min_element(v.begin(),v.end());
   

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long N,M,K,ans,a[1<<18],b[1<<18];
int main(){
	cin>>N>>M>>K;
	for(int i=1;i<=N;i++)cin>>a[i],a[i]=a[i-1]+a[i];
	for(int i=1;i<=M;i++)cin>>b[i],b[i]=b[i-1]+b[i];
	for(int i=0;i<=N;i++)if(K>=a[i])ans=max(ans,upper_bound(b+1,b+M+1,K-a[i])-b-1+i);
	cout<<ans;
}


Measured memory_bytes: 6720
N,K = map(int,input().split())

from math import ceil
cnt = 0
for i in range(1,N+1):
    a = ceil(K/i)
    if bin(a).count("1") == 1:
        b = a.bit_length()-1
    else:
        b = a.bit_length()
    cnt += (1/N)*(0.5**b)
print(cnt)

Measured memory_bytes: 74236
coin_500 = gets.to_i
coin_100 = gets.to_i
coin_50 = gets.to_i
amount = gets.to_i

result = 0
coin_500.downto(0) do |n|
  if amount < n * 500
    next
  end
  coin_100.downto(0) do |m|
    if amount < n * 500 + m * 100
      next
    end
    coin_50.downto(0) do |l|
      if amount < n * 500 + m * 100 + l * 50
        next
      end
      if amount == n * 500 + m * 100 + l * 50
        result += 1
      end
    end
  end
end
puts result


Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
#define len(x) ((ll)(x).size())
#define debug(var) cout << "[" << #var << "]\n" << var << endl
#define int long long
typedef long long ll;
const int INF = 1001001001001001001ll;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;
const double EPS = 1e-9;

template <typename T>
ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i];
    if (i < len - 1)
      s << ' ';
  }
  return s;
}

template <typename T>
ostream& operator<<(ostream& s, const vector<vector<T>>& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) {
    s << vv[i];
    if (i != len - 1)
      s << '\n';
  }
  return s;
}

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

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

__attribute__((constructor)) void initial() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}

signed main() {
  int N, K;
  cin >> N >> K;
  int k = (N + 1) / 2;
  bool ok = k >= K;
  if (ok)
    cout << "YES\n";
  else
    cout << "NO\n";
}

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

# define C continue;
# define R return

# define D double
# define I insert
# define ll long long
# define ld long double
# define ull unsigned long long

# define pb push_back
# define vi vector < int >
# define vc vector < char >
# define vs vector < string >
# define vb vector < bool >
# define vd vector < D >
# define vll vector < ll >
# define vull vector < ull >

# define vvi vector < vector < int > >
# define vvb vector < vector < bool > >
# define vvc vector < vector < char > >
# define vvll vector < vector < ll > >
# define vvd vector < vector < D > >
# define vld vector < ld >

# define all(v) (v).begin() , (v).end()
# define allrev(v) (v).rbegin() , (v).rend()

# define pii pair < int , int >
# define vpii vector < pii >
# define vvpii vector < vector < pii > >
# define F first
# define S second
# define mp make_pair

# define fast ios_base::sync_with_stdio(false) ; cin.tie(0) ; cout.tie(0);
# define dist(a,b,p,q) sqrt((p-a)*(p-a) + (q-b)*(q-b));
# define mod 1000000007

# define pp(n) printf("%.10f",n);
# define line cout<<"\n";

const D pie = acos(-1);
const D hpie = asin(1);
const D qpie = atan2(1,1);
const D tpie = 2*pie;

string vow = "aeiou";

void solve( int test_case )
{
    int n , l;
    cin >> n >> l;

    vs v ( n );
    for ( int i=0 ; i<n ; i++ ) cin >> v[i];

    sort ( all(v) );

    for ( int i=0 ; i<n ; i++ )
    {
        cout << v[i];
    }
}

int main()
{
    int t = 1;
    //cin>>t;

    for ( int i=0 ; i<t ; i++ ) solve(i);
    return 0;
}


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

using ll=long long;
using namespace std;

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

    vector<int> flag(M+1,0);
    int cnt=1;
    int loop;
    int st;

    while(1){
        //cout<<X<<endl;
        if(flag[X]!=0){
            loop=cnt-flag[X];
            st=flag[X];
            break;
        }else{
            flag[X]=cnt;
        }
        X*=X;
        X%=M;
        cnt++;
    }
    st--;
    //cout<<loop<<" "<<st<<endl;

    N-=st;
    if(N<=0){
        ll ans=0;
        X=save;
        for(int i=0;i<N+st;i++){
            ans+=X;
            X*=X;
            X%=M;
        }
        cout<<ans<<endl;
        return 0;
    }

    X=save;
    ll sum=0;
    for(int i=0;i<st;i++){
        sum+=X;
        X*=X;
        X%=M;
    }
    save=X;
    ll loopsum=0;
    for(int i=0;i<loop;i++){
        loopsum+=X;
        X*=X;
        X%=M;
    }

    ll last=N%loop;
    ll ans=sum+(N/loop)*loopsum;
    X=save;
    for(int i=0;i<last;i++){
        ans+=X;
        X*=X;
        X%=M;
    }

    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 3784
N,K = map(int, input().split())
V = [int(i) for i in input().split()] 

ans = []
for k_l in range(K+1):
    rem = K - k_l
    for k_r in range(rem+1):
        if k_l + k_r > N:
            continue
        rem_ = rem-k_r
        v = V[:k_l]+V[N-k_r:]
        #print(k_l,k_r,rem_,v)
        v.sort()
        for i in range(rem_):
            if i < len(v) and v[i] < 0:
                v[i] = 0
        #print(v)
        ans.append(sum(v))


print(max(ans))

Measured memory_bytes: 41836
use std::io::{stdin, Read, StdinLock};
use std::str::FromStr;

// reference: http://ir5.hatenablog.com/entry/20171209/1512821837

struct Scanner<'a> {
    cin: StdinLock<'a>,
}
 
impl<'a> Scanner<'a> {
    fn new(cin: StdinLock<'a>) -> Scanner<'a> {
        Scanner { cin: cin }
    }
 
    fn read1<T: FromStr>(&mut self) -> Option<T> {
        let token = self.cin.by_ref().bytes().map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        token.parse::<T>().ok()
    }
 
    fn read<T: FromStr>(&mut self) -> T {
        self.read1().unwrap()
    }
}

use std::mem;

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);

    let h: u32 = sc.read();
    let n: u32 = sc.read();
    let mut acc: u32 = 0;
    for i in 0..n {
        let a: u32 = sc.read();
        acc += a;
    }

    if acc >= h {
        println!("{}", "Yes");
    } else {
        println!("{}", "No");
    }
}

Measured memory_bytes: 2120
#include<bits/stdc++.h>
using std::cout;
using std::cin;
using std::endl;
#define EOT "END_OF_TEXT"

std::vector<std::string> split(const std::string &str, char sep)
{
    std::vector<std::string> v;
    std::stringstream ss(str);
    std::string buffer;
    while( std::getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}


int main()
{
    int count=0;
    std::string W, T, doubt;
    cin >> W;
    std::vector<std::string> result;
    getline(cin, doubt);

    while (getline(cin, T))
    {
        if (T==EOT)
            break;
        result = split(T, ' ');
        
        std::vector<std::string>::iterator itr;
        itr=result.begin();

        
        while (itr != result.end())
        {
            std::string s = *itr;
            std::transform(s.begin(), s.end(), s.begin(), tolower);
            if (s == W)
                count++;
            itr++;
        }    
    }


    cout << count << endl;

    return 0;
}


Measured memory_bytes: 3184
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define rep(i,N) for(int i=0;i<(int)N;i++)
#pragma GCC optimize("O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
static inline void PUT(char c)
{
  static char buf[1<<15],*ptr=buf;
  if(ptr==buf+strlen(buf)||c==0){fwrite(buf,1,ptr-buf,stdout),ptr=buf;}*ptr++=c;
}
static inline int IN(void)
{
  int x=0,f=0,c=getchar();while(c<48||c>57){f^=c==45,c=getchar();}
  while(c>47&&c<58){x=x*10+c-48,c=getchar();}return f?-x:x;
}
static inline void OUT(int a)
{
  if(a<0)PUT('-'),a=-a;
  int d[40],i=0;do{d[i++]=a%10;}while(a/=10);
  while(i--){PUT(d[i]+48);}PUT('\n');
}
static inline int Max(int x,int y){return x>y?x:y;}
int main(void)
{
  int H=IN(),W=IN(),M=IN(),row[H]={0},col[W]={0},bomb[300000][2],
  destroy=0,idh=0,idw=0,hmax=0,wmax=0,hsz=0,wsz=0,obj=0;
  rep(i,M)
  {
    bomb[i][0]=IN()-1,bomb[i][1]=IN()-1;
    row[bomb[i][0]]++;col[bomb[i][1]]++;
    hmax=Max(hmax,row[bomb[i][0]]);wmax=Max(wmax,col[bomb[i][1]]);
  }
  rep(i,H){if(hmax==row[i]){idh++;}}rep(j,W){if(wmax==col[j]){idw++;}}
  destroy=hmax+wmax;
  rep(i,M){if(row[bomb[i][0]]==hmax&&col[bomb[i][1]]==wmax){obj++;}}
  return OUT(1l*obj==1l*idh*idw?destroy-1:destroy),0;
}

Measured memory_bytes: 6220
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(n); ++i)
#define repr(i, a, b) for (int i=a; i<(b); ++i)
#define reprev(i, n) for (int i=n-1; i>=0; --i)
#define reprrev(i, a, b) for (int i=b-1; i>=(a); --i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
    cout << fixed << setprecision(10);
    
    int n, m; cin >> n >> m;
    vector<P> pe(m);
    vector<vector<int>> e(n);
    rep(i, m) {
        int a, b; cin >> a >> b;
        a--; b--;
        pe[i] = make_pair(a, b);
        e[a].emplace_back(b);
        e[b].emplace_back(a);
    }
    int ans = 0;
    rep(i, m) {
        int ng_a = pe[i].first, ng_b = pe[i].second;
        queue<int> q;
        q.push(0);
        vector<int> ac(n);

        while (!q.empty()) {
            int now_e = q.front(); q.pop();
            for (auto ne : e[now_e]) {
                if ((ne == ng_a && now_e == ng_b) || (ne == ng_b && now_e == ng_a)) continue;
                if (ac[ne]) continue;
                q.push(ne);
                ac[ne] = 1;
            }
        }

        rep(j, n) {
            if (ac[j] == 0) {
                ans += 1;
                break;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> P;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
/*
vector<char>al(26);
al = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
vector<char>AL(26);
AL = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
vector<char>NUM(10);
	NUM = { '0','1','2' ,'3' ,'4' ,'5' ,'6' ,'7' ,'8' ,'9' };
*/



int main() {
	lint X;
	cin >> X;
	lint ans = 0;
	X--;
	ans++;
	ans += X / 11*2;
	X %= 11;
	if (X <= 5) {
		ans++;
	}
	else {
		ans += 2;
	}
	cout << ans-1 << endl;
}




Measured memory_bytes: 256
# -*- coding: utf-8 -*-

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

S = input()

N = len(S)
print('x' * N)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using P   = pair<ll, ll>;
using mat = vector<vector<ll>>;

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

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

ll mod(ll a) {
	if (a > 0) return a % MOD;
	if (a % MOD == 0) return 0;
	ll x = -a / MOD + 1;
	a += x * MOD;
	return a % MOD;
}

template <typename T> void dump(T x) { cout << x << endl; }
void dumpf(double 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);
}
// int dx[4]    = {1, 0, -1, 0};
// int dy[4]    = {0, 1, 0, -1};
// ll pas[5001][5002];

int main() {
	IOS();
	ll n, k;
	cin >> n >> k;
	dump(2 * k - 1 <= n ? "YES" : "NO");
	return 0;
}

Measured memory_bytes: 256
//
//  main.cpp
//  f_lcs
//
//  Created by AdOjis485 on 29.06.19.
//  Copyright © 2019 AdOjis485. All rights reserved.
//

#include <iostream>
#include <vector>
#include <string>
#define int int64_t
using namespace std;

signed main() {
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    string s, t;
    cin >> s >> t;
    int n = s.size();
    int m = t.size();
    vector<vector<int>> dp(n, vector<int> (m, 0));
    for(int i = 0; i < n; i ++){
        for(int j = 0; j < m; j ++){
            if(s[i] == t[j]){
                if(j > 0 && i > 0){
                    dp[i][j] = dp[i - 1][j - 1] + 1;
                }
                else{
                    dp[i][j] = 1;
                }
            }
            if(j > 0){
                dp[i][j] = max(dp[i][j], dp[i][j - 1]);
            }
            if(i > 0){
                dp[i][j] = max(dp[i][j], dp[i - 1][j]);
            }
        }
    }
    string k = "";
    int i = n - 1;
    int j = m - 1;
    int l = dp[i][j];
    while(i >= 0 && j >= 0 && dp[i][j] > 0){
        while(i > 0 && dp[i - 1][j] == l){
            i --;
        }
        while(j > 0 && dp[i][j - 1] == l){
            j --;
        }
        k += s[i];
        l --;
        i --;
        j --;
    }
    string b = "";
    for(int i = 0; i < k.size(); i ++){
        b += k[k.size() - 1 - i];
    }
    cout << b << '\n';
    return 0;
}


Measured memory_bytes: 70784
//in the name of allah
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 2e3+10;
int n , m , q;
char mpc[MAXN][MAXN] , mpo[MAXN][MAXN] , mpa[MAXN][MAXN];
int psc[MAXN][MAXN] , pso[MAXN][MAXN] , psa[MAXN][MAXN];
void eval(char mp[MAXN][MAXN] , int ps[MAXN][MAXN]){
	for(int i=0 ; i<n ; i++)
		for(int j=0 ; j<m ; j++){
			ps[i][j] = (mp[i][j] == '1');
			ps[i][j] += (i ? ps[i-1][j] : 0) + (j ? ps[i][j-1] : 0) - (i && j ? ps[i-1][j-1] : 0);
		}
}
int get(int x1 , int y1 , int x2 , int y2 , int ps[MAXN][MAXN]){
	if(x2 < x1 || y2 < y1)
		return 0;
	int ret = ps[x2][y2];
	if(x1)
		ret -= ps[x1-1][y2];
	if(y1)
		ret -= ps[x2][y1-1];
	if(x1 && y1)
		ret += ps[x1-1][y1-1];
	return ret;
}

int main(){
	scanf("%d%d%d" , &n , &m , &q);
	for(int i=0 ; i<n ; i++){
		scanf("%s" , mpc[i]);
		for(int j=0 ; j<m ; j++){
			mpo[i][j] = ( (j<m-1 && mpc[i][j] == '1' && mpc[i][j+1] == '1') ? '1' : '0');
			mpa[i][j] = ( (i && mpc[i][j] == '1' && mpc[i-1][j] == '1') ? '1' : '0');
		}
	}
	eval(mpc , psc);
	eval(mpo , pso);
	eval(mpa , psa);
	while(q --){
		int x1 , y1 , x2 , y2;
		scanf("%d%d%d%d" , &x1 , &y1 , &x2 , &y2);
		x1 --;
		y1 --;
		x2 --;
		y2 --;
		int num = get(x1 , y1 , x2 , y2 , psc);
		int e = get(x1 , y1 , x2 , y2-1 , pso) + get(x1+1 , y1 , x2 , y2 , psa);
		printf("%d\n" , num - e);
	}
}


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

int check[1000005];

vector<long long int> PRIME;

void E(void) {
	check[1] = 1;
	for (int i = 2; i <= 1000000; i++) {
		if (check[i] == 0) {
			for (int j = i * 2; j <= 1000000; j += i) {
				check[j] = 1;
			}
		}
	}
	for (int i = 1; i <= 1000000; i++) {
		if (check[i] == 0) {
			PRIME.push_back(i);
		}
	}
}

long long int N, P;

long long int alpha[1000000];

int main(void) {

	E();

	/*for (int i = 0; i <= 30; i++) {
		cout << PRIME[i] << endl;

	}

	cout << PRIME.size() << endl;
	*/

	cin >> N >> P;

	long long int NUM=P;

	for (int i = 0; i < (int)PRIME.size(); i++) {

		while ((PRIME[i] <= NUM) && (NUM % PRIME[i] == 0)) { alpha[i]++; NUM /= PRIME[i]; }

	}

	//cout << NUM << endl;

	if (NUM > 1) { PRIME.push_back(NUM); alpha[PRIME.size() - 1]++; }

	/*for (int i = 0; i <= 10; i++) {
		cout << PRIME[i] << " " << alpha[i] << endl;
	}*/

	long long int ans = 1;

	for (int i = 0; i < (int)PRIME.size(); i++) {

		int J = alpha[i] / N;
		for(int j=1;j<=J;j++){
			ans *= PRIME[i]; }
	}

	cout << ans << endl;

	//system("pause");
	return 0;
}

Measured memory_bytes: 7032
#include<bits/stdc++.h>
#define rep0(i,n) for(i=0;i<n;i++)
#define rep(i,n) for(i=1;i<=n;i++)
#define reps(i,a,n) for(i=a;i<=n;i++)
#define mem(ara,n) memset(ara,n,sizeof(ara))
#define memb(ara) memset(ara,false,sizeof(ara))
#define all(x) (x).begin(),(x).end()
#define fast ios_base:: sync_with_stdio( false ); cin.tie(0); cout.tie(0);
#define eb              emplace_back
#define em              emplace
#define pb              push_back
#define Mp              make_pair
#define ff              first
#define ss              second
#define mod 1000000007
const double pi = 3.14159265358979323846;
typedef long long ll;
using namespace std;

const int M = (int)(2e6 + 239);

int getnum(string a)
{
    int i,p=0;
    rep0(i,a.size())
    {
        p*=10;
        p+=a[i]-'0';
    }
    return p;
}

int main()
{
    fast

    ll a,b,c;
    cin>>a>>b>>c;
    cout<<c<<" "<<a<<" "<<b<<endl;
}


Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

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

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

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

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
fn adjacent4(x: usize, y: usize, sx: usize, sy: usize) -> Vec<(usize, usize)> {
    [(-1, 0), (1, 0), (0, -1), (0, 1)]
        .into_iter()
        .filter_map(|&(dx, dy)| {
            let nx = x as isize + dx;
            let ny = y as isize + dy;
            if nx >= 0 && nx < sx as isize && ny >= 0 && ny < sy as isize {
                Some((nx as usize, ny as usize))
            } else {
                None
            }
        })
        .collect()
}

#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
fn main() {
    input! {
        a: [[usize; 3]; 3],
        n: usize,
        b: [usize; n]
    }
    let mut m: Vec<Vec<bool>> = vec![vec![false; 3]; 3];
    for i in 0..n {
        for j in 0..3 {
            for k in 0..3 {
                if b[i] == a[j][k] {
                    m[j][k] = true;
                }
            }
        }
    }
    let mut ans = "No";
    for i in 0..3 {
        if m[0][i] && m[1][i] && m[2][i] {
            ans = "Yes";
        }
    }
    for i in 0..3 {
        if m[i][0] && m[i][1] && m[i][2] {
            ans = "Yes";
        }
    }
    if m[0][0] && m[1][1] && m[2][2] {
        ans = "Yes";
    }
    if m[0][2] && m[1][1] && m[2][0] {
        ans = "Yes";
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()

#define all(x) x.begin(), x.end()
#define shandom_ruffle random_shuffle

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);   cout.tie(NULL);
    string s; cin >> s;
    int count[2];
    count[0]=count[1]=0;
    int lp=-1,i;
    char cur='R';
    int n=s.size();
    int ans[n]={0};
    for(i=0;i<n;i++)
    {
        if(s[i]==cur)
        {
            count[i%2]++;
        }
        else{
            if(s[i]=='L')
            {
                lp=i-1;
                ans[lp]+=count[lp%2];
                ans[lp+1]+=count[(lp+1)%2];
            }
            else {
                ans[lp]+=count[lp%2];
                ans[lp+1]+=count[(lp+1)%2];
            }
            count[0]=count[1]=0;
            count[i%2]++;
            cur=s[i];
        }
    }
    ans[lp]+=count[lp%2];
    ans[lp+1]+=count[(lp+1)%2];
    for(i=0;i<n;i++)
    {
        cout << ans[i] << " ";
    }

    return 0;
}

Measured memory_bytes: 1104
#include <iostream>
#include <climits>

using namespace std;
using ll = long long;


int main(){
    ll n,a;
    cin >> n;
    ll ans = 1;
    bool is_overflow = false;
    for(int i=0; i<n; i++){
        cin >> a;
        if(a==0){
            cout << 0 << endl;
            return 0;
        }
        if(!is_overflow){
            ans *= a;
            if(ans>1000000000000000000 || ans<a){
                is_overflow = true;
            }
        }
    }
    if(is_overflow){
        cout << -1 << endl;
    }else{
        cout << ans << endl;

    }
    
    return 0;
}

Measured memory_bytes: 3636
#include <iostream>

using namespace std;

int main() {
    string s;
    cin >> s;
    string t;
    cin >> t;
    if(t.length() - s.length() != 1){
        cout << "No" << endl;
        return 0;
    }
    bool flag = true;
    for(long long i = 0; i < s.length(); i++){
        if(s[i] != t[i]){
            flag = false;
            break;
        }
    }
    if(!flag){
        cout << "No" << endl;
    }
    else{
        cout << "Yes" << endl;
    }
}

Measured memory_bytes: 3620
#include <iostream>
using namespace std;
int main(){
	int N;
	cin >> N;
	while(N--){
		int pipe[2] = {0};
		int i=0;
		bool f=false;
		for(; i < 10; i++){
			int num;
			cin >> num;
			if(pipe[1] > pipe[0]){
				
				if(num > pipe[1]){
					pipe[1] = num;
				}else if(num > pipe[0]){
					pipe[0] = num;
				}else{
					f=true;
				}
				
			}else{
				if(num > pipe[0]){
					pipe[0] = num;
				}else if(num>pipe[1]){
					pipe[1] = num;
				}else{
					f=true;
				}
			}
			
		}
		if(!f) cout << "YES" << endl;
		else cout << "NO" << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
	vector<int> n(4), m = { 1,4,7,9 };
	for (int i = 0; i < 4; i++)cin >> n[i];
	sort(n.begin(), n.end());
	puts(n == m ? "YES" : "NO");
}

Measured memory_bytes: 256
# include <iostream>
# include <algorithm>
#include <array>
# include <cassert>
#include <cctype>
#include <climits>
#include <numeric>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <tuple>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <chrono>
# include <random>
# include <limits.h>
# include <unordered_map>
# include <unordered_set>
# include <deque>
# include <cstdio>
# include <cstring>
#include <stdio.h>
#include<time.h>
#include <stdlib.h>
#include <cstdint>
#include <cfenv>
#include<fstream>
//#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const long long MOD = 1000000000 + 7;//1000000000 + 7 998244353 924844033 1000000000 + 9;
constexpr long long INF = 1LL << 60;//numeric_limits<LL>::max();
const double PI = acos(-1);
#define fir first
#define sec second
#define thi third
#define debug(x) cerr<<#x<<": "<<x<<'\n'
typedef pair<LL, LL> Pll;
typedef pair<double, double> Dll;
typedef pair<LL, pair<LL, LL>> Ppll;
typedef pair<LL, pair<LL, bitset<100001>>> Pbll;
typedef pair<LL, pair<LL, vector<LL>>> Pvll;
typedef pair<LL, LL> Vec2;
struct Tll { LL first, second, third; };
struct Fll { LL first, second, third, fourth; };
typedef pair<LL, Tll> Ptll;
#define rep(i,rept) for(LL i=0;i<rept;i++)
#define Rrep(i,mf) for(LL i=mf-1;i>=0;i--)
void YN(bool f) {
	if (f)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}
void yn(bool f) {
	if (f)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}
struct Edge { LL to, cost; };
struct edge {
	LL from, to, cost;
};
vector<vector<Edge>>g;
vector<edge>ed;
vector<Pll>pv;
set<LL>st;
map<Pll, LL>ma;
int di[4][2] = { { 0,1 },{ 1,0 },{ 0,-1 },{ -1,0 } };
string str, ss;
bool f;
LL n, m, s, t, h, w, k, q, p, ans, sum, cnt;
char a[210000], b[210000];
int main() {
	cin >> n>>q;
	cin >> str;
	rep(i, q) {
		cin >> a[i] >> b[i];
	}
	LL l = -1, r = n,mid;
	while (r - l > 1) {
		mid = (r + l) / 2;
		LL cur = mid;
		rep(i, q) {
			if (str[cur] == a[i]) {
				if (b[i] == 'L') cur--;
				else cur++;
			}
			if (cur == -1)break;
			if (cur == n)break;
		}
		if (cur == -1)l = mid;
		else r = mid;
	}
	s = l;
	l = -1, r = n;
	while (r - l > 1) {
		mid = (r + l) / 2;
		LL cur = mid;
		rep(i, q) {
			if (str[cur] == a[i]) {
				if (b[i] == 'L') cur--;
				else cur++;
			}
			if (cur == -1)break;
			if (cur == n)break;
		}
		if (cur == n)r = mid;
		else l = mid;
	}
	t = r;
	ans = s + 1 + n - t;
	cout << max(n - ans, 0LL) << endl;
	return 0;
}

Measured memory_bytes: 1028
n=int(input())
a=[]
for i in range(n):
    a.append(int(input()))
m1=0
m2=0
for i in range(n):
    if a[i]>m1:
        m2=m1
        m1=a[i]
    elif m1>=a[i] and m2<a[i]:
        m2=a[i]
for i in range(n):
    if a[i]!=m1:
        print(m1)
    else:
        print(m2)

Measured memory_bytes: 12532
#include <iostream>
#include <cstdio>

using namespace std;

typedef long long ll;

ll n, k;
ll r, s, p;
string T;
bool v[100005];
ll ans;

int main()
{
    cin>>n>>k>>r>>s>>p>>T;
    for(ll i = 0; i < T.size(); i++)
    {
        if(T[i] == 'r' && (i < k || !v[i - k] || T[i - k] != T[i])) ans += p, v[i] = true;
        else if(T[i] == 's' && (i < k || !v[i - k] || T[i - k] != T[i])) ans += r, v[i] = true;
        else if(T[i] == 'p' && (i < k || !v[i - k] || T[i - k] != T[i])) ans += s, v[i] = true;
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 512
#include<iostream>

using namespace std;

int main(void)
{
	int x = 0 ,y = 0;
	cin >> x >> y;
	
	if( x > y ) 		cout << "a > b"  << endl;
	else if( x == y )	cout << "a == b" << endl;
	else 				cout << "a < b"  << endl;
        
	return 0;
} 


Measured memory_bytes: 3136