akhauriyash/Code-Regression huggingface dataset:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N,Q = map(int,readline().split())
ABPX = list(map(int,read().split()))
AB = iter(ABPX[:N+N-2])
PX = iter(ABPX[N+N-2:])

graph = [[] for _ in range(N+1)]
for a,b in zip(AB,AB):
    graph[a].append(b)
    graph[b].append(a)

C = [0] * (N+1)
for p,x in zip(PX,PX):
    C[p] += x

se = set([1])
stack = [1]
while stack:
    # print(C)
    x = stack.pop()
    for y in graph[x]:
        if y in se:
            continue
        stack.append(y)
        se.add(y)
        # 親x, 子y
        C[y] += C[x]

print(' '.join(str(i) for i in C[1:]))


Measured memory_bytes: 96500
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<sstream>
#include<iomanip>
#include<limits>
#include<deque>
#include<map>
#include<list>
#include<set>
#include <unordered_set>
#include<vector>
#include<cmath>
#include<cstdio>
#include<memory>
#include<bitset>
#include<stack>
#include<functional>
#include<queue>
#include<regex>
#include<time.h>

using namespace std;


#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl

#define Tof(x) (x) ? Yes : No
#define TOF(x) (x) ? YES : NO
#define tof(x) (x) ? yes : no

using ll = long long;

//constexpr ll MOD = 1000000007;
constexpr ll INF = 1050000000;


/*vectorの要素を全部確認するやつだよ。普通に拡張for文したほうがいいよ。

for (vector<int>::iterator itr = ans.begin(); itr != ans.end(); ++itr) {
	cout << *itr << " ";
}

*/


/*for文でx,yを上下左右確認するやつだよ。正直使いづらいよ。

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


for (int i = 0; i < 4; i++) {
	int ny = y + dy[i];
	int nx = x + dx[i];
}

*/


/*繰り返し二乗法だよ。modもとってくれるよ。n^kをmodで割った余りでやってくれるよ。

ll POW_MOD(ll n, ll k, ll mod) {
	ll r = 1;

	for (; k > 0; k >>= 1) {
		if (k & 1) {
			r = (r * n) % mod;
		}
		n = (n * n) % mod;
	}
	return r;
}

*/


/*実行開始からの経過時間を表すよ。

while (clock() < 1900000) {  }

*/


/*まだ使えないテクニックのメモだよ。

for (int bit = 0; bit < (1<<n); ++bit)//bit全探索用のfor文だよ

*/


/*2重for文書くのめんどくなった時用だよ。

for (int i = 0; i < h; ++i) {
	for (int j = 0; j < w; ++j) {

	}
}

*/


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

	for (int i = 0; i < s.size() && i < k; i++) {
		if (s[i] != '1') { cout << s[i] << endl; return 0; }
	}

	cout << 1 << endl;

	return 0;
}



Measured memory_bytes: 256
a,b,k=map(int, input().split())
c=0
for j in range(max(a,b)):
    i=max(a,b)-j
    #print(i,a % i==0 , b % i==0)
    if a % i==0 and b % i==0:
        c+=1
        if c==k:
            print(i)
            break

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

using namespace std;

int main(){
    int n,q;
    string s;
    cin>>n>>q;
    cin>>s;
    int counter[n];
    counter[0]=0;
    for(int i=0;i<s.length()-1;i++){
        counter[i+1]=counter[i]+(s.substr(i,2)=="AC");
    }
    for(int i=0;i<q;i++){
        int a,b;
        cin>>a>>b;
        cout<<counter[b-1]-counter[a-1]<<endl;
    }
    

    return 0;
}

Measured memory_bytes: 1408
n,m = $stdin.gets.chomp.split(' ').map(&:to_i)
h = $stdin.gets.chomp.split(' ').map(&:to_i)
arr = []
m.times do
  arr.push $stdin.gets.chomp.split(' ').map(&:to_i)
end
flagarr =Array.new(n,1)
arr.each do |part|
if h[(part[0]-1)] > h[(part[1]-1)]
    flagarr[(part[1]-1)] = 0
elsif h[(part[0]-1)] < h[(part[1]-1)]
    flagarr[(part[0]-1)] = 0
elsif h[(part[0]-1)] == h[(part[1]-1)]
    flagarr[(part[0]-1)] = 0
    flagarr[(part[1]-1)] = 0
end

end

puts flagarr.count(1)

Measured memory_bytes: 29368
#include<iostream>
#include<cstdlib>
#include<cstdio>
#define MN 200000
using namespace std;
inline int read()
{
	int x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
int head[MN+5],n,cnt=1,rt1,rt2,c[MN+5],vis[MN*2+5],Ans[MN+5];
struct edge{int to,next;}e[MN*3+5];
inline void ins(int f,int t)
{
	e[++cnt]=(edge){t,head[f]};head[f]=cnt;
	e[++cnt]=(edge){f,head[t]};head[t]=cnt;	
}
void dfs(int x,int f)
{
	for(int i=head[x];i;i=e[i].next)
		if(e[i].to!=f) dfs(e[i].to,x),c[x]^=1;
	if(x>n&&c[x]!=c[x-n]) {puts("IMPOSSIBLE");exit(0);}
	if(x>n&&!c[x]) ins(x,x-n);  
}
void Dfs(int x)
{
	for(int&i=head[x];i;)
		if(!vis[i>>1])
		{
			int t=i;i=e[i].next;
			vis[t>>1]=1;Dfs(e[t].to);
			if(x<=n&&e[t].to>n) --Ans[x];
			if(x>n&&e[t].to<=n) ++Ans[x-n]; 
		}
		else i=e[i].next;
}
int main()
{
	n=read();
	for(int i=1,j;i<=n;++i) if((j=read())!=-1) ins(j,i); else rt1=i;
	for(int i=1,j;i<=n;++i) if((j=read())!=-1) ins(j+n,i+n); else rt2=i;
	dfs(rt1,0);dfs(rt2+n,0);puts("POSSIBLE");Dfs(rt1);
	for(int i=1;i<=n;++i) printf("%d ",Ans[i]);
	return 0;
}



Measured memory_bytes: 18432
class SegmentTreeLazy():
    def __init__(self, arr, ti, ei, func, op, merge):
        self.h = len(arr).bit_length()
        self.n = 2**self.h
        self.func = func
        self.op = op
        self.merge = merge
        self.ti = ti
        self.ei = ei
        self.data = [ti for _ in range(2 * self.n)]
        for i in range(len(arr)):
            self.data[i + self.n] = arr[i]
        for i in range(1, self.n)[::-1]:
            self.data[i] = self.func(self.data[2 * i], self.data[2 * i + 1])
        self.lazy = [ei for _ in range(2 * self.n)]

    def reflect(self, k):
        if self.lazy[k] == self.ei:
            return self.data[k]
        return self.op(self.data[k], self.lazy[k])

    def propagate(self, k):
        if self.lazy[k] == self.ei:
            return
        self.lazy[2 * k] = self.merge(self.lazy[2 * k], self.lazy[k])
        self.lazy[2 * k + 1] = self.merge(self.lazy[2 * k + 1], self.lazy[k])
        self.data[k] = self.reflect(k)
        self.lazy[k] = self.ei

    def thrust(self, k):
        for i in range(1, self.h + 1)[::-1]:
            self.propagate(k >> i)

    def recalc(self, k):
        while k:
            k //= 2
            self.data[k] = self.func(
                self.reflect(2 * k), self.reflect(2 * k + 1))

    def update(self, left, right, x):
        l, r = left, right
        left += self.n
        right += self.n
        self.thrust(left)
        self.thrust(right - 1)
        while right - left > 0:
            if left & 1:
                self.lazy[left] = self.merge(self.lazy[left], x)
                left += 1
            if right & 1:
                right -= 1
                self.lazy[right] = self.merge(self.lazy[right], x)
            left //= 2
            right //= 2
        self.recalc(l + self.n)
        self.recalc(r + self.n - 1)

    def query(self, left, right):
        left += self.n
        right += self.n
        self.thrust(left)
        self.thrust(right - 1)
        tmp_l = tmp_r = self.ti
        while right - left > 0:
            if left & 1:
                tmp_l = self.func(tmp_l, self.reflect(left))
                left += 1
            if right & 1:
                right -= 1
                tmp_r = self.func(self.reflect(right), tmp_r)
            left //= 2
            right //= 2
        return self.func(tmp_l, tmp_r)


import sys
input = sys.stdin.readline
from operator import add

N, C = map(int, input().split())
A = [0 for _ in range(101010)]

st = SegmentTreeLazy(A, 0, 0, max, add, add)

P = [list(map(int, input().split())) for _ in range(N)]
P.sort()
P.sort(key=lambda x:x[2])

Q = []
prev = P[0]
for i in range(1, N):
    if prev[2] != P[i][2] or prev[1] != P[i][0]:
        Q.append((prev[0], prev[1]))
        prev = P[i]
    else:
        prev = (prev[0], P[i][1], prev[2])
Q.append((prev[0], prev[1]))

for i in range(len(Q)):
    s, t = Q[i]
    st.update(s, t+1, 1)

print(st.query(0, 100010))

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

typedef long long int ll;

ll mod = 1e9 + 7;

ll mul(ll a, ll b){
	return (mod+(a*b)%mod)%mod;
}

ll diff(ll a, ll b){
	return (mod+(a-b)%mod)%mod;
}

ll add(ll a, ll b){
	return (mod+(a+b)%mod)%mod;
}

int main(){
	
	ll n;
	cin>>n;
	
	ll ten = 1;
	ll nine = 1;
	ll eight = 1;
	for(ll i=1;i<=n;i++){
		ten = mul(ten, 10);
		nine = mul(nine, 9);
		eight = mul(eight, 8);
	}
	
	cout<<add(diff(ten, mul(nine, 2)), eight);
	
}


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

using namespace std;

long long n, a, b;

int main (int argc, char const *argv[]) {
  cin >> n >> a >> b;
  if (n == 1) {
    if (a == b) puts("1");
    else puts("0");
    return 0;
  }
  if (a > b) {
    puts("0");
    return 0;
  }
  long long ans = (n - 2LL) * (b - a) + 1LL;
  printf("%lld\n", ans);  
  return 0;
}



Measured memory_bytes: 256
function Main(input) {
  input = input.trim()
  input = input.split("\n");
  var N = input[0].split(" ").map(Number);
  input.shift();
  var arr = Array(N[0]);
  arr.fill(0);
  for(var i=0;i<N[1];i++){
    var aandb = input[i].split(" ").map(Number);
    arr[aandb[0]-1]++;
    arr[aandb[1]-1]++;
  }
  for (var i=0; i<arr.length;i++){
    console.log(arr[i]);
  }
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
//
//  main.cpp
//  CoderTest
//
//  Created by yuya on 2019/07/25.
//  Copyright © 2019 yuya. All rights reserved.
//

#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair <int,int> P;


int main()
{
    
    int N;
    cin >> N;
    vector<ll> A(N+1), B(N);
    for(int i=0;i<N+1;i++) cin >> A[i];
    for(int i=0;i<N;i++) cin >> B[i];
    
    ll beat = 0;
    ll x;
    for(int i = N-1; i >= 0; i--)
    {
        x = min(A[i+1], B[i]);
        A[i+1] -= x;
        B[i] -= x;
        beat += x;
        
        x = min(A[i], B[i]);
        A[i] -= x;
        B[i] -= x;
        beat += x;
    }
    
    cout << beat << endl;
    
    return 0;
}


Measured memory_bytes: 1792
#define _CRT_SECURE_NO_WARNINGS
#define _SCL_SECURE_NO_WARNINGS

#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>
#include <set>
#include <iomanip>
#include <map>
#include <stack>
#include <bitset>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <random>
#include <cassert>
#include <iterator>
#include <utility>

using namespace std;

//#define FAST_ALLOCATOR_MEMORY 2e8
#undef LOCAL
//#include "optimization.h"

int main() {
	iostream::sync_with_stdio(0);
	cin.tie(0), cout.tie(0);

#ifdef LOCAL
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	int n;
	cin >> n;
	vector<int> p(n);
	for (int i = 0; i < n; i++)
		cin >> p[i];
	vector<int> pos(n);
	for (int i = 0; i < n; i++) {
		p[i]--;
		pos[p[i]] = i;
	}
	int mx = 0;
	for (int i = 0; i < n; i++) {
		int r = i;
		while (r + 1 < n && pos[r + 1] > pos[r]) r++;
		mx = max(mx, r - i + 1);
		i = r;
	}
	cout << n - mx;
	return 0;
}

Measured memory_bytes: 1792
import java.io.{BufferedOutputStream, BufferedReader, InputStreamReader, PrintWriter}

object Main {
  def main(args: Array[String]): Unit = {
    val in = new BufferedReader(new InputStreamReader(System.in))
    val out = new PrintWriter(new BufferedOutputStream(System.out))
    val Array(k, n) = in.readLine().split("\\s+").map(_.toInt)
    val as = in.readLine().split("\\s+").map(_.toInt)

    val distances = Array.ofDim[Int](as.length)
    for(i <- 0 until as.length - 1) {
      distances(i) = as(i + 1) - as(i)
    }
    distances(distances.length - 1) = k + as(0) - as.last

    out.println(k - distances.max)
    out.flush()
  }
}


Measured memory_bytes: 52860
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using pi = pair<lint, int>;
const int MAXN = 100005;
const int mod = 1e9 + 7;

int g(int x, int k){
	while(x % k){
		int st = 0, ed = x;
		while(st != ed){
			int m = (st+ed)/2;
			if((m + k - 1) / k == (x + k - 1) / k) ed = m;
			else st = m + 1;
		}
		int cur = (x + k - 1) / k;
		x -= cur * ((x - st) / cur + 1);
	}
	return x / k;
}

int main(){
	int q; cin >> q;
	int ans = 0;
	while(q--){
		int x, y; cin >> x >> y;
		ans ^= g(x, y);
	}
	puts(ans ? "Takahashi" : "Aoki");
}



Measured memory_bytes: 384
#include <iostream>

using namespace std;

class Dice {
private:
	int number[6];
	int state[6];
public:
	Dice();
	~Dice();
	void initialize();
	void setNumber(int index, int num);
	void roll(char d);
	void move(string d);
	int getNumber(int idx);
	int getTop();
	int getSide(int t, int f);
	bool cmp(Dice dice1);
};

Dice::Dice() {
	initialize();
}

Dice::~Dice() {
}

void Dice::initialize() {
	for (int i = 0; i < 6; i++)
		state[i] = i+1;
}

void Dice::setNumber(int index, int num) {
	number[index] = num;
}

void Dice::roll(char d) {
	int nextIndex[4][6] = {
		{1, 5, 2, 3, 0, 4},
		{3, 1, 0, 5, 4, 2},
		{2, 1, 5, 0, 4, 3},
		{4, 0, 2, 3, 5, 1},
	};
	int *idx, nextState[6];
	switch (d) {
		case 'N': idx = nextIndex[0]; break;
		case 'E': idx = nextIndex[1]; break;
		case 'W': idx = nextIndex[2]; break;
		case 'S': idx = nextIndex[3]; break;
		default: return;
	}
	for (int i = 0; i < 6; i++)
		nextState[i] = state[idx[i]];
	for (int i = 0; i < 6; i++)
		state[i] = nextState[i];
}

void Dice::move(string d) {
	int oldIndex[4][6] = {
		{1, 5, 2, 3, 0, 4},
		{3, 1, 0, 5, 4, 2},
		{2, 1, 5, 0, 4, 3},
		{4, 0, 2, 3, 5, 1},
	};
	for (int i = 0; i < d.size(); i++) {
		int newNumber[6] = {0};
		int *idx;
		char c = d[i];
		switch (c) {
			case 'N': idx = oldIndex[0]; break;
			case 'E': idx = oldIndex[1]; break;
			case 'W': idx = oldIndex[2]; break;
			case 'S': idx = oldIndex[3]; break;
			default: return;
		}
		for (int i = 0; i < 6; i++)
			newNumber[i] = number[idx[i]];
		for (int i = 0; i < 6; i++)
			number[i] = newNumber[i];
	}
}

int Dice::getNumber(int idx) {
	return number[state[idx]-1];
}

int Dice::getTop() {
	return getNumber(0);
}

int Dice::getSide(int t, int f) {
	string s = "NNNNENNNN";
	for (int i = 0; i < s.size(); i++) {
		if (number[state[1]-1] == f) {
			break;
		}
		char c = s[i];
		roll(c);
	}
	s = "EEEEE";
	for (int i = 0; i < s.size(); i++) {
		if (number[state[0]-1] == t)
			break;
		char c = s[i];
		roll(c);
	}
	return getNumber(2);
}

bool Dice::cmp(Dice op) {
	string s = "SWWWWNEEEEENEEEENNEEEESEEEEESEEEE";
	for (int i = 0; i < s.size(); i++) {
		char c = s[i];
		op.roll(c);
		int flag = 0;
		for (int i = 0; i < 6; i++)
			if (op.getNumber(i) != number[i]) {
				flag = 1;
				break;
			}
		if (flag == 0)
			return true;
	}
	return false;
}

int main() {
	Dice dice1, dice2;
	int n;
	for (int i = 0; i < 6; i++) {
		cin >> n;
		dice1.setNumber(i, n);
	}
	for (int i = 0; i < 6; i++) {
		cin >> n;
		dice2.setNumber(i, n);
	}
	if (dice1.cmp(dice2) == true)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
}

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

set<int> p;
int n;
int a[100005];
int f[100005];
int r[100005];
int ans;

#define INF 1000000000

int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        f[i]=__gcd(f[i-1],a[i]);
    }
    for(int i=n;i>=1;i--){
        r[i]=__gcd(r[i+1],a[i]);
    }
    for(int i=1;i<=n;i++){
        ans=max(ans,__gcd(f[i-1],r[i+1]));
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 1408
#include "bits/stdc++.h"

using namespace std;
typedef long long ll;
#define rep(i,j,n) for (ll i = j; i < (n); i++)
#define CLR(mat,f) memset(mat, f, sizeof(mat))
#define IN(a, b, x) (a<=x&&x<b)
#define out(ans) cout << ans << endl
typedef pair<ll,ll>P;
const ll mod=1e9+7;
const int INF = 1000000;
const double PI=3.14159265359;

int main(){

  ll k,t;cin>>k>>t;
  multiset<ll,greater<ll>>ms;
  rep(i,0,t){
    ll a;cin>>a;
    ms.insert(a);
  }
  ms.insert(0);
  ll ans=0;
  rep(i,0,(k+1)/2){

    ll x=*ms.begin();
    ms.erase(ms.begin(),++ms.begin());
    x--;

    ll y=*ms.begin();
    ms.erase(ms.begin(),++ms.begin());
    // out(x+1<<":"<<y);
    if((x+1)!=1&&y==0){
      out(x);
      return 0;
    }
    else y--;

    ms.insert(x);
    ms.insert(y);
    // for(auto itr=ms.begin();itr!=ms.end();itr++){
    //   // out(*itr);
    //   cout<<*itr<<",";
    // }
    // cout<<endl;

  }
  out(ans);


  return 0;
}


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

#define ll long long
#define mod 1000000007
#define mod2 998244353
#define pii pair<ll,ll>
#define pb push_back

#define debug(a) { cout << #a << " = " << a << endl;}

void sep() {
    cout << "-------------BLOCK-----------------\n";
}

template<typename T>
void debugv(vector<T> arr) {
    for (auto t: arr)
        cout << t << " ";
    cout << "\n";
}

template<typename T>
void debugarr(T arr, int n) {
    for (int i=0;i<n;i++) cout << arr[i] << " ";
    cout << "\n";
}

ll __min(ll a, ll b) {
    return a < b ? a : b;
}

ll __max(ll a, ll b) {
    return a > b ? a : b;
}

const int maxn = 1e5+1;
ll arr[maxn], n, m, t, k, q;
unordered_map<ll,ll> u;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    cin>>n;
    set<ll> s;
    u.clear();
    for (int i=0;i<n;i++) {
        cin>>m;
        u[m]++;
        s.insert(m);
    }
    ll f=-1;
    ll se=-1;
    for (set<ll>::reverse_iterator itr=s.rbegin();itr!=s.rend();itr++) {
        if (u[*itr] >= 4 && f == -1) {
            cout << (*itr)*(*itr) << endl;
            exit(0);
        }
        if (u[*itr]>=2) {
            if (f == -1) f = *itr;
            else if (se == -1) {
                se = *itr;
                break;
            }
        }
    }
    if (se==-1) cout << "0\n";
    else cout << f*se << endl;
 }


Measured memory_bytes: 12056
#include <bits/stdc++.h>
using namespace std;
const int N = 200005;
const int LOGN = 18;
int n, K, a[N], pa1[LOGN][N], pa2[LOGN][N];
long long sum1[LOGN][N], sum2[LOGN][N];
int main() {
	scanf("%d%d", &n, &K);
	for (int i = 1; i <= n; i++) {
		scanf("%d", &a[i]);
	}
	for (int i = 1, j = 1; i <= n; i++) {
		while (j <= n && a[j] - a[i] < K) j++;
		pa1[0][i] = j;
		sum1[0][i] = j;
	}
	for (int i = 0; i < LOGN; i++) pa1[i][n + 1] = n + 1;
	for (int i = 1; i < LOGN; i++)
		for (int j = 1; j <= n; j++) {
			pa1[i][j] = pa1[i - 1][pa1[i - 1][j]];
			sum1[i][j] = sum1[i - 1][j] + sum1[i - 1][pa1[i - 1][j]];
		}
	for (int i = n, j = n; i >= 1; i--) {
		while (j > 0 && a[i] - a[j] < K) j--;
		pa2[0][i] = j;
		sum2[0][i] = j;
	}
	for (int i = 0; i < LOGN; i++) pa2[i][0] = 0;
	for (int i = 1; i < LOGN; i++)
		for (int j = 1; j <= n; j++) {
			pa2[i][j] = pa2[i - 1][pa2[i - 1][j]];
			sum2[i][j] = sum2[i - 1][j] + sum2[i - 1][pa2[i - 1][j]];
		}
	int q;
	scanf("%d", &q);
	while (q--) {
		int l, r;
		scanf("%d%d", &l, &r);
		int u = l;
		long long s1 = l;
		int cnt = 1;
		for (int i = LOGN - 1; i >= 0; i--) if (pa1[i][u] <= r) {
			cnt += (1 << i);
			s1 += sum1[i][u];
			u = pa1[i][u];
		}
		u = r;
		long long s2 = r;
		for (int i = LOGN - 1; i >= 0; i--) if (pa2[i][u] >= l) {
			s2 += sum2[i][u];
			u = pa2[i][u];
		}
		printf("%lld\n", s2 - s1 + cnt);
	}
	return 0;
}

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



int gcd(int x,int y){
	if(x < y){

		swap(x,y);
	}

	if(y == 0){
		return x;
	}else{
		return gcd(y,x%y);
	}
}


int extend_Euclid(int a,int b,int& ans_x,int& ans_y){
	if(b == 0){ //再帰の一番最後にたどり着いた場合
		ans_x = 1;
		ans_y = 0;
		return a; //最小公倍数
	}else{
		int ret = extend_Euclid(b,(a%b),ans_y,ans_x);
		ans_y -= (a/b)*ans_x;
		return ret;
	}
}

//https://icpc.iisf.or.jp/past-icpc/comments/2016-slides.pdf

void func(){

	int x_bb,y_bb;

	scanf("%d %d",&x_bb,&y_bb);

	int x,y,num;

	num = extend_Euclid(x_bb,y_bb,x,y);

	if(num <= 50000){

		printf("3\n");
		printf("0 0\n");

		printf("%d %d\n",x_bb,y_bb);

		printf("%d %d\n",abs(y),abs(x));

	}else{

		printf("4\n");
		printf("0 0\n");

		printf("%d %d\n",x_bb-1,y_bb);
		printf("%d %d\n",x_bb/num,y_bb/num);
		printf("%d %d\n",x_bb,y_bb-1);
	}
}

int main(){

	int num_case;

	scanf("%d",&num_case);

	for(int loop = 0; loop < num_case; loop++){

		func();
	}

	return 0;
}



Measured memory_bytes: 3220
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan=new Scanner(System.in);
		int H=scan.nextInt();
		int W=scan.nextInt();
		int h=scan.nextInt();
		int w=scan.nextInt();
		System.out.println((H-h)*(W-w));

	}

}

Measured memory_bytes: 35632
#include <bits/stdc++.h>
//#include <cmath>
//using namespace std; 
//bool is_integer( double x ){
//  return std::floor(x)==x;
//}
#include <iostream>

using namespace std;

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

int lcm(int a, int b)
{
   return a * b / gcd(a, b);
}
int main(){
	int k, ans, x;
  	cin >> x;
  	if(1<=x&&x<=179){
      	ans = (lcm(360, x))/x;
      	cout << ans << endl;
    }
}



Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}
const ll INF = 1e16;
const ll MOD = 1000000007;
typedef pair<ll,ll> P;
const ll MAX = 2510;
constexpr ll nx[8] = {1,0,-1,0,-1,-1,1,1};
constexpr ll ny[8] = {0,1,0,-1,-1,1,-1,1};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h,w,n;
    cin >> h >> w >> n;
    vector<vector<ll>> grid(h,vector<ll>(w));
    vector<ll> a(n);
    cins(all(a));
    int c = 0,color = 1,x = 0,y = 0;
    rep(_,h*w){
        c++;
        grid[x][y] = color;
        if (c+1 > a[color-1]){
            c = 0;
            color++;
        }
        if (x%2 == 0 && y == w-1) x++;
        else if (x%2 && y == 0) x++;
        else if (x%2 == 0) y++;
        else y--;
    }
    rep(i,h) array_output(all(grid[i]));
}


Measured memory_bytes: 512
h,*s=open(0)
h,w=map(int,h.split())
r=range
a,b,c,d=eval('eval("w*[0],"*h),'*4)
for i in r(h*w):i,j=i//w,i%w;f=s[i][j]>'#';a[i][j]=-~a[i][j-1]*f;b[i][~j]=-~b[i][-j]*(s[i][-j-2]>'#');c[i][j]=-~c[i-1][j]*f;d[~i][j]=-~d[-i][j]*(s[~i][j]>'#')
print(max(a[i][j]+b[i][j]+c[i][j]+d[i][j]-3for i in r(h)for j in r(w)))

Measured memory_bytes: 188808
N = int(input())
A = [0] * N
B = [0] * N
Sum = [[0] * 2 for i in range(N)]

for i in range(N):
    A[i], B[i] = map(int, input().split())
    Sum[i][0] = i
    Sum[i][1] = A[i] + B[i]
    
a = 0
b = 0
turn = 0

Sum.sort(key=lambda x:x[1], reverse=True)
    
for i in range(N):
    if turn == 0:
        a += A[Sum[i][0]]
        turn = 1
    else:
        b += B[Sum[i][0]]
        turn = 0

print(a - b)


Measured memory_bytes: 29152
import sys

# 解説カンニング済み

N = int(input())
xs = []
ys = []
hs = []
reference = None
for i in range(N):
    x, y, h = map(int, input().split())
    xs.append(x)
    ys.append(y)
    hs.append(h)
    # 地面でないことが分かっている(ピラミッド内のサンプル)を1つ選ぶ
    if h > 0:
        reference = (x, y, h)

for cx in range(0, 100+1):
    for cy in range(0, 100+1):
        # サンプルの高さを求める
        rx, ry, rh = reference
        ref_H = rh + abs(rx-cx) + abs(ry-cy)
        # 他のデータも全てサンプルと合致するか検証する
        ok = True
        for i in range(N):
            calc_H = max(ref_H - abs(xs[i]-cx) - abs(ys[i]-cy), 0)
            if calc_H != hs[i]:
                ok = False
                break
        if ok:
            print(cx, cy, ref_H)
            sys.exit(0)


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

int main () {
  int n, a, b;
  cin >> n >> a >> b;
  int p[n];
  for (int i = 0; i < n; i++) {
    cin >> p[i];  
  }  
  sort(p, p + n);
  int aa, bb, cc;
  aa = 0;
  bb = 0;
  cc = 0;
  for (int i = 0; i < n; i++) {
    if (p[i] <= a) {
      aa++;  
    }  
    else {
      if (p[i] <= b) {
        bb++;  
      }
      else {
        cc++;  
      }

    }
  }
  int ans[3];
  ans[0] = aa;
  ans[1] = bb;
  ans[2] = cc;
  sort(ans, ans + 3);
  cout << ans[0] << endl;
}

Measured memory_bytes: 256
program main
      implicit none
      integer :: a,b,ans,i

      read *, a, b

      ans = 0
      if ( a > b ) then
        do i = 1, a
          ans = ans + 10**(i-1)*b
        end do
      else
        do i = 1, b
          ans = ans + 10**(i-1)*a
        end do
      end if
      print *, ans

end program main


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

using namespace std;
#define ll long long
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
const ll mod = 1e9 + 7;
typedef pair<int,int> P;




int main (){
    
    int n;
    int r = 0;
    int b = 0;
    string s;
    cin >> n >> s;
    for(int i = 0; i < s.size(); i++){
        if(s[i] == 'R') r++;
        else b++;

    }
    
    if(r > b){
        cout << "Yes" << endl;
    }else cout << "No" << endl;





    return 0;
}

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

int main()
{
  int x,ans;
  ans=0;
  cin>>x;
  if(x>=105)
    ans++;
  if(x>=135)
    ans++;
  if(x>=165)
    ans++;
  if(x>=189)
    ans++;
  if(x>=195)
    ans++;
  cout<<ans<<endl;
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>s
using namespace std;
char s[11];
int main()
{
    int a,b;
    cin>>a>>b;
    for(int i=1;i<=a+b+1;i++) cin>>s[i];
    for(int i=1;i<=a+b+1;i++)
    {
        if((s[i]<'0'||s[i]>'9')&&i!=a+1)
        {
            cout<<"No"<<endl;
            return 0;
        }
        if(i==a+1&&s[i]!='-')
        {
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
}

Measured memory_bytes: 256
import java.lang.Math

fun main(args: Array<String>)
{
    val s = readString().toCharArray()
    val t = readString().toCharArray()

    var cnt = 0
    for (i in 0..2) {
        if (s[i] == t[i]) cnt += 1
    }

    println(cnt)
}

fun readInts(): List<Int> = readLine()!!.split(" ").map(String::toInt)
fun readLongs(): List<Long> = readLine()!!.split(" ").map(String::toLong)

fun readIntArr(): IntArray = readLine()!!.split(" ").map(String::toInt).toIntArray()
fun readLongArr(): LongArray = readLine()!!.split(" ").map(String::toLong).toLongArray()

fun readIntArrS(): IntArray = readLine()!!.split(" ").map(String::toInt).toIntArray().sortedArray()
fun readLongArrS(): LongArray = readLine()!!.split(" ").map(String::toLong).toLongArray().sortedArray()

fun readIntArrSD(): IntArray = readLine()!!.split(" ").map(String::toInt).toIntArray().sortedArrayDescending()
fun readLongArrSD(): LongArray = readLine()!!.split(" ").map(String::toLong).toLongArray().sortedArrayDescending()

fun readString() = readLine()!!


Measured memory_bytes: 31664
#include <algorithm>
#include <iostream>
#include <stdio.h>
#include <string>
using namespace std;

int main() {
    int N, K;
    cin >> N >> K;
    int P[200005];
    for (int i = 0; i < N; i++) {
        cin >> P[i];
    }

    int sum_p = 0;
    for (int k = 0; k < K; k++) {
        sum_p += P[k];
    }

    int mx_sum_p = sum_p;
    for (int j = 0; j < N - K; j++) {
        sum_p -= P[j];
        sum_p += P[j + K];
        mx_sum_p = max(mx_sum_p, sum_p);
    }

    double ans = (double)(K + mx_sum_p) / 2;
    printf("%.12f", ans);
    return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
#include<string.h>
#define LEN 100005

typedef struct pp{
  char name[100];
  int t;
}P;

P Q[LEN];
int head,tail,n;

void enqueue(P x){
  Q[tail]=x;
  tail=(tail+1)%LEN;

}

P dequeue(){
  P x=Q[head];
  head=(head+1)%LEN;
  return x;
}

int min(int a,int b){
  return a < b ? a : b;
}

int main(){
  int elaps=0,c;
  int i,q;
  P u;
  
  scanf("%d %d",&n,&q);
  
  for(i=1;i<=n;i++){
    scanf("%s",Q[i].name);
    scanf("%d",&Q[i].t);
  }
  head=1;
  tail=n+1;

  while(head != tail){
    u=dequeue();
    c=min(q,u.t);
    u.t -= c;
    elaps +=c;
    if(u.t>0) enqueue(u);
    else{
      printf("%s %d\n",u.name,elaps);
    }

  }

  return 0;
}



Measured memory_bytes: 11848
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cstring> 
#include<cassert>
#include<cmath>
#include<sstream>
#include<fstream>
#include<map>
#include<set>
#include<vector>
#include<queue>
#include<stack>
#include<bitset>
using namespace std;
int dp[105][4][4][4][4];
bool can(int i,int j,int k,int l){
	if(i==0&&j==1&&k==2) return 0;
	if(j==0&&k==1&&l==2) return 0;
	return 1;
}
bool check(int i,int j,int k,int l){
	return (can(i,j,k,l)&can(j,i,k,l)&can(i,k,j,l)&can(i,j,l,k));
}
int main(){
	int n;
	cin>>n;
	if(n==3){
		cout<<61;	
		return 0;
	} 
	if(n==4){
		cout<<230;
		return 0;
	} 
	int cnt=0;
	for(int i=0;i<4;i++)for(int j=0;j<4;j++)for(int k=0;k<4;k++)for(int l=0;l<4;l++){
		dp[4][i][j][k][l]=check(i,j,k,l);
		cnt+=check(i,j,k,l);
	}
//	cout<<cnt<<endl;
	long long res=0;
	for(int ii=5;ii<=n;ii++){
		for(int i=0;i<4;i++)for(int j=0;j<4;j++)for(int k=0;k<4;k++)for(int l=0;l<4;l++){
			if(!check(i,j,k,l)) dp[ii][i][j][k][l]=0;
			else{
				for(int la=0;la<4;la++){
					dp[ii][i][j][k][l]+=dp[ii-1][la][i][j][k];
					if(dp[ii][i][j][k][l]>=1e9+7)dp[ii][i][j][k][l]-=1e9+7;
				}
				if(ii==n){
					res+=dp[ii][i][j][k][l];
					if(res>=1e9+7) res-=1e9+7;
				}
			}
		}
	}
	cout<<res;
}

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cmath>
#include <set>
#include <cstring>
using namespace std;

#define REP(i,n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> pint;

bool f(string &s) {
  set<char> sc;
  REP(i,s.length()) sc.insert(s[i]);
  return sc.size() == 3;
}

int main() {
  int N; cin>>N;
  vector<string> cand[20];
  cand[1].push_back("3");
  cand[1].push_back("5");
  cand[1].push_back("7");
  for(int i = 1; i < 9; i++) {
    for(int j = 0; j < cand[i].size(); j++) {
      cand[i+1].push_back(cand[i][j] + "3");
      cand[i+1].push_back(cand[i][j] + "5");
      cand[i+1].push_back(cand[i][j] + "7");
    }
  }
  vector<int> work;
  for(int i = 1; i <= 9; i++) {
    for(int j = 0; j < cand[i].size(); j++) {
      static int n;
      bool ok = f(cand[i][j]);
      if(!ok) continue;
      sscanf(cand[i][j].c_str(), "%d", &n);
      work.push_back(n);
    }
  }
  sort(work.begin(), work.end());
#ifdef DEBUG
  REP(i,10) cout << work[i] << endl;
  REP(i,10) cout << work[work.size() - 1 - i] << endl;
#endif
  int ans = 0;
  for(int i = 0; i < work.size(); i++) {
    if(work[i] > N) break;
    ans++;
  }
  cout << ans << endl;
  return 0;
}


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

#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define int long long
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;

signed main(){
    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,d,e,k;
	cin >> a >> b >> c >> d >> e >> k;
	if(b-a > k){cout << ":(";return 0;}
	if(c-a > k){cout << ":(";return 0;}
	if(d-a > k){cout << ":(";return 0;}
	if(e-a > k){cout << ":(";return 0;}
	if(c-b > k){cout << ":(";return 0;}
	if(d-b > k){cout << ":(";return 0;}
	if(e-b > k){cout << ":(";return 0;}
	if(d-c > k){cout << ":(";return 0;}
	if(e-c > k){cout << ":(";return 0;}
	if(e-d > k){cout << ":(";return 0;}
	cout << "Yay!";
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
  int n,x;
  while(1)
  {
    cin>>n>>x;
    if(n==0&&x==0)break;
    int s=0;
    for(int i=1;i<=n;i++)
      for(int j=i+1;j<=n;j++)
        for(int k=j+1;k<=n;k++)
          if(i+j+k==x) s++;
    cout<<s<<endl;
  }
}

Measured memory_bytes: 3076
using System.Collections.Generic;
using System;

public class Hello
{
    public const int INF = 1000000001;
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        var a = new int[n];
        for (int i = 0; i < n; i++) a[i] = int.Parse(Console.ReadLine().Trim());
        Console.WriteLine(goDP(a));
    }
    public static int goDP(int[] a)
    {
        var n = a.Length;
        var dp = new int[n];
        for (int i = 0; i < n; i++) dp[i] = INF;
        for (int i = 0; i < n; i++)
        {
            var w = LowerBound(dp, a[i]);
            dp[w] = a[i];
        }
        return LowerBound(dp, INF);
    }
    public static int LowerBound<T>(T[] arr, int start, int end, T value, IComparer<T> comparer)
    {
        var low = start;
        var high = end;
        int mid;
        while (low < high)
        {
            mid = ((high - low) >> 1) + low;
            if (comparer.Compare(arr[mid], value) < 0) low = mid + 1;
            else high = mid;
        }
        return low;
    }
    public static int LowerBound<T>(T[] arr, T value) where T : IComparable
    {
        return LowerBound(arr, 0, arr.Length, value, Comparer<T>.Default);
    }
}



Measured memory_bytes: 10688
# -*- coding: utf-8 -*-
from sys import stdin
from operator import itemgetter
from collections import deque, Counter
import math
import pprint
from functools import reduce
# stdin = open("sample.txt")

MOD = 1000000007
INF = float('inf')
alpha = ["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"]

def keta(kazu): # 入力されたintを桁ごとに分解，リストで出力
    kazu_str = str(kazu)
    kazu_list = [int(kazu_str[i]) for i in range(0, len(kazu_str))]
    return kazu_list

def gcd(*numbers): # 最小公倍数
    return reduce(math.gcd, numbers)

def combination(m,n): # mCn
    
    if n > m:
        return 'すまん'
    return math.factorial(m) // (math.factorial(m-n) * math.factorial(n))

def pow_k(x,n):  # (x**n)の計算の高速化
    if n == 0:
        return 1
    K = 1
    while n > 1:
        if n % 2 != 0:
            K *= x
        x *= x
        n //= 2
    return K * x

def main():
    s = stdin.readline().rstrip()
    t = stdin.readline().rstrip()
    ans = 0
    for i in range(len(s)):
        if s[i] != t[i]:
            ans += 1
    print(ans)
main()

Measured memory_bytes: 10300
#include <stdio.h>

int main(void)
{
  int dame[2][3] = {{1, 1, 0}, {0, 0, 1}};
  int a, b, c;
  int flag = 0;
  int i = 0;

  scanf("%d %d %d", &a, &b, &c);

  for (i = 0; i < 2; i++) {
    if (a == dame[i][0] && b == dame[i][1] && c == dame[i][2]) {
      flag = 1;
    }
  }

  if (flag == 1) {
    printf("Open\n");
  } else {
    printf("Close\n");
  }


  return (0);
}

Measured memory_bytes: 584
fun main(args:Array<String>) {
    val s = readLine()!!.toMutableList()

    if(s.size == s.distinct().size) {
        if(s.size < 26) {
            for(i in ('a'..'z')) {
                if(s.contains(i)) {
                    continue
                }
                s.add(i)
                println(s.joinToString(""))
                return
            }
        }
    }
    println(getAns(s))
}

fun getAns(target:MutableList<Char>): String {
    for(i in (0 .. target.lastIndex).reversed()) {
        if(target[i] == 'z') {
            continue
        }
        if(i == 0) {
            val tmp = ('a'..'z').toList()
            var idx = tmp.indexOf(target[0])
            return tmp[idx+1].toString()
        }
        val sub = target.subList(0, i)
        if(sub.size != sub.distinct().size) {
            continue
        }
        for(j in (target[i]..'z')) {
            if(j == target[i]) {
                continue
            }
            if(sub.contains(j)) {
                continue
            }
            sub.add(j)
            return sub.joinToString("")
        }
    }
    return "-1"
}


Measured memory_bytes: 33848
n = int(input())
a = [0]+list(map(int,input().split()))+[0]
s = 0
for i in range(n+1):
    s += abs(a[i+1]-a[i])
for i in range(n):
    ans = s+ abs(a[i+2]-a[i])-(abs(a[i]-a[i+1])+abs(a[i+1] - a[i+2]))
    print(ans)

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

int main(){
    string s;
    cin >> s;
    if(s == "RRR"){
        cout << 3 << endl;
        return 0;
    } else if (s[0] == 'R' && s[1] == 'R'){
        cout << 2 << endl;
    } else if (s[2] == 'R' && s[1] == 'R'){
        cout << 2 << endl;
    } else if (s == "SSS"){
        cout << 0 << endl;
    } else {
        cout << 1 << endl;
    }
    return 0;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstring>
#include <chrono>
#include <complex>
#define endl "\n"
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define mod 1000000007
#define inf 1000000000000000001;
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define f first
#define s second

using namespace std;
int main()
{
	std::ios::sync_with_stdio(false);
	int n;
	cin>>n;
	if(n>=30)	cout<<"Yes"<<endl;
	else	cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 3608
#include<math.h>
#include<cmath>
#include<bitset>
#include<stdio.h>
#include<string>
#include<map>
#include<algorithm>
#include<vector>
#include<iostream>
#include<utility>
using namespace std;
int main(){
  char s;
  int a[55][55],i,j,h,w;
  scanf("%d %d\n",&h,&w);
  for(i=0;i<=h+1;i++){
    for(j=0;j<=w+1;j++){
      a[i][j]=0;
    }
  }
  for(i=1;i<=h;i++){
    for(j=1;j<=w;j++){
      scanf("%c",&s);
      if(s=='#'){
        a[i][j]=1;
      }
    }
    scanf("\n");
  }
  for(i=1;i<=h;i++){
    for(j=1;j<=w;j++){
      if(a[i][j]==1){
        if(a[i-1][j]==1 || a[i+1][j]==1 || a[i][j-1]==1 || a[i][j+1]==1){
          continue;
        }
        else{
          printf("No\n");
          return 0;
        }
      }
    }
  }
  printf("Yes\n");
  return 0;
}

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

ll gcd(ll a, ll b)
{
    return b==0?a:gcd(b,a%b);
}
//prime factorization
vector<int> factorize(ll n)
{
    vector<int> res;
    for (ll i = 2; i*i <= n; i++)
    {
        if (n%i)
            continue;
        res.emplace_back(i);
        while (n%i == 0)
        {
            n /= i;
        }
    }
    if (n != 1)
        res.emplace_back(n);
    return res;
}
int main()
{
    ll a, b;
    cin >> a >> b;
    ll n = gcd(a, b);
    auto f = factorize(n);
    int ans = f.size() + 1;
    cout << ans << endl;
    return 0;
}


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

#define int long long
#define endl "\n"
#define REP(i,a,n) for(int i=a;i<n;++i)
#define RUP(a,b) ((a+b-1)/(b))
#define SORTG(v) sort(v.begin(),v.end(),greater<>())
#define SORT(v) sort(v.begin(),v.end())
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007
#define INF LLONG_MAX/3

typedef long long ll;
typedef pair<int,int> Pii;
typedef tuple<int,int,int> Tiii;
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef vector<string> Vs;

template<class T> void chmax(T& a, T b) {if(a<b){a=b;}}
template<class T> void chmin(T& a, T b) {if(a>b){a=b;}}
void YesNo(int a) {if(a){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}}
void YESNO(int a) {if(a){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}}
void AorB(int a,string b,string c) {if(a){cout<<b<<endl;}else{cout<<c<<endl;}}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
void start(){cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);}

signed main(){start();
    string s;
    cin>>s;
    YesNo(s.substr(0,4)=="YAKI");
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;

  int n4 = N/1000;
  int n3 = (N- n4*1000)/100;
  int n2 = (N- n4*1000 - n3 * 100)/10;
  int n1 = (N- n4*1000 - n3*100 -n2*10);
  if(( n4==n3 && n3 ==n2) || (n3==n2 && n2==n1)){
	  cout << "Yes" << endl;
  }else{
    cout << "No" <<endl;
  }
 
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
	
	int a,b,ans=0;
	cin>>a>>b;
	if(a<b){
		ans+=b;
		b--;
	}else{
		ans+=a;
		a--;
	}

	if(a<b){
		ans+=b;
		b--;
	}else{
		ans+=a;
		a--;
	}
	cout<<ans<<endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int range(int x[10][10], int d, int n, int m);

int main(void)
{
    int d;
    int n;
    int x[10][10];
    int i;
    int j;
    int count = 0;

    scanf("%d %d", &n, &d);

    for(i = 0; n > i; i++){
        for(j = 0; d > j; j++){
            scanf("%d", &x[i][j]);
        }
    }

    for(i = 0; n > i; i++){
        for(j = 1; n > i + j; j++){
            if(range(x, d, i, i + j) == 1){
                count++;
            }
        }
    }

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

    return 0;
}

int range(int x[10][10], int d, int n, int m)
{
    int a[10];
    int b = 0;
    int i;

    for(i = 0; i< 10; i++){
        a[i] = 0;
    }

    for(i = 0; i < d; i++){
        a[i] = x[n][i] - x[m][i];
    }

    for(i = 0; i < d; i++){
        b += a[i] * a[i];
    }

    for(i = 0; i < 200; i++){
        if(b == i * i){
            return 1;
        }
    }

    return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        
        Scanner scanner = new Scanner(System.in);
        
        // r...row count,  c...column count
        int r = scanner.nextInt();
        int c = scanner.nextInt();
        
        // r(y) x c(x) matrix
        int[][] rcmatrix = new int[r+1][c+1];
        
        for(int i=0; i<r; i++){
            for(int j=0; j<c; j++){
                rcmatrix[i][j] = scanner.nextInt();
            }
            
            int c1 = 0;
            for(int k=0; k<c; k++){
                c1 += rcmatrix[i][k];
            }
            rcmatrix[i][c] = c1;
        }
        
        
        for(int i=0; i<c+1; i++){
            int r1 = 0;
            for(int j=0; j<r; j++){
                r1 += rcmatrix[j][i];
            }
            rcmatrix[r][i] = r1;
        }
        
        // display
        for(int i=0; i<r+1; i++) {
            for(int j=0; j<c+1; j++){
                System.out.print(rcmatrix[i][j]);
                if (j != c) { System.out.print(" "); }
            }
            // if (i != r) { System.out.println(); }
            System.out.println();
        }
        
        
    }
}


Measured memory_bytes: 41356
//By Ralif Rakhmatullin
#include<iostream>
#include<fstream>
#include<string>
#include<cstring>
#include<math.h>
#include<cassert>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<map>
#include<ctime>
#include<queue>
#include<stack>
#include<set>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<bitset>
#include<valarray>
#include<iterator>
#include<list>
#define ll long long
#define ull unsigned long long
#define mp make_pair
#define S second
#define ld long double
#define F first
#define y1 LOL
#define ld long double
#define pb push_back
#define len length
#define sz size
#define beg begin
const ll INF = (ll)1e18 + 123;
const int inf=(int)2e9 + 123; 
const int mod=1e9+7;
using namespace std;
int n;
int main(){
	unsigned int FOR;
 	asm("rdtsc" : "=A"(FOR));
  	srand(FOR);
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	//cout.tie(0);
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	cin >> n;
	ll ans = 0, mn = inf;
	for(int i = 1; i <= n; i ++){
		ll a, b;
		cin >> a >> b;
		if(b < a){
			mn = min(mn, b);
		}
		ans += a;
	}
	if(mn == inf)
		cout << 0;
	else
		cout << ans - mn;  
	return 0;
}

Measured memory_bytes: 256
//CODING ME ACCHHA KARNEKA HAI TERKO TO BAS PRACTICE KARTE REH
#include <bits/stdc++.h>
#define pragma
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define pf push_front
#define aisort sort(a,a+n)
#define adsort sort(a,a+n,greater<ll>())
#define PI 2 * acos(0)

typedef pair<ll, ll> pii;
typedef pair<ll, pii> piii;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef vector<pii> vii;
typedef vector<piii> viii;
typedef set<ll> Set;

const ll maxs = 1e5+3;
const ll maxs1 = 1e3+4;
const ll mod = 1e9 + 7;

//MODULO OPEARTIONS
    inline ll add(ll a, ll b) { return (mod + a + b) % mod; }
    inline ll sub(ll a, ll b) { return (a - b + mod) % mod; }
    inline ll mul(ll a, ll b) { return (1ll * a * b) % mod; }

//POWER
    ll fastpow(ll x,ll y)
    {ll res = 1;x = x % mod;while (y > 0){ if (y & 1)res = (res * x) % mod; y = y >> 1 ; x = (x * x) % mod; } return res;}

//MODULAR INVERSE
    ll inv(ll x){ return fastpow(x , mod - 2);}
    
//PRIME
    bool isPrime(ll n) { if (n <= 1)  return false; if (n <= 3)  return true;if (n%2 == 0 || n%3 == 0) return false; for (int i=5; i*i<=n; i=i+6) if (n%i == 0 || n%(i+2) == 0) return false; return true; } 




int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
   ll i,k,a,b,cnt=0,res=1;
   cin>>k>>a>>b;
   ll flg=0;
   while(res<=b)
   {
       cnt++;
       res=k*cnt;
       if(res>=a&&res<=b)
       flg=1;
   }
   if(flg==1)
   cout<<"OK";
   else
   cout<<"NG";
}




Measured memory_bytes: 3616
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<iterator>
#include<math.h>
#include<cstring>
using namespace std;
void lets_play()
 
{
   int n,m,l,c=0;
   cin>>n>>m>>l;
 
  if(m==7)
    c++;
    if(n==7)
        c++;
    if(l==7)
        c++;
    if(c==1)
        cout<<"YES"<<endl;
    else
        cout<<"NO"<<endl;
    }
 
int main()
{
        lets_play();
 
}

Measured memory_bytes: 3552
#include<stdio.h>

int main(void){
  int da[10];
  int b,i,j;
  int hit,blow;
  while(scanf("%d",&da[0]) != EOF){
    for(i=1;i<4;i++){
      scanf("%d",&da[i]);
    }
    hit = 0;
    blow = 0;
    for(i=0;i<4;i++){
      scanf("%d",&b);
      for(j=0;j<4;j++){
        if (b==da[j]){
          if(i==j) hit++;
          else blow++;
        }
      }
    }
    printf("%d %d\n",hit,blow);
  }
  return 0;
}

Measured memory_bytes: 596
#include"bits/stdc++.h"
using namespace std;
using ll=long long;
using ull=unsigned long long;
constexpr auto inf=static_cast<ll>(1e18);
template<typename T=ll>inline T in(){T ret;cin>>ret;return ret;}
template<typename T=ll>inline auto vec2(size_t h,size_t w,T v=T()){return vector<vector<T>>(h,vector<T>(w,v));}
inline void setp(int n){cout<<fixed<<setprecision(n);}
inline void delnl(){cin.ignore(numeric_limits<streamsize>::max(),'\n');}

int main()
{
    cout<<[](ll n){return (n-1)*n/2;}(in())<<endl;
}

Measured memory_bytes: 256