akhauriyash/Code-Regression huggingface dataset:
open System
open System.Collections.Generic

[<AutoOpen>]
module Cin =
    let read f = stdin.ReadLine() |> f
    let reada f = stdin.ReadLine().Split() |> Array.map f
    let readChars() = read string |> Seq.toArray
    let readInts() = readChars() |> Array.map (fun x -> Convert.ToInt32(x.ToString()))

[<AutoOpen>]
module Cout =
    let writer = new IO.StreamWriter(new IO.BufferedStream(Console.OpenStandardOutput()))
    let print (s: string) = writer.Write s
    let println (s: string) = writer.WriteLine s
    let inline puts (s: ^a) = string s |> println

let [| H; W |] = reada int
let maze = Array2D.init H W (fun _ _ -> '.')

for y in 0 .. H - 1 do
    let s = read string
    for x in 0 .. W - 1 do
        maze.[y, x] <- s.[x]

let mutable ok = true

for y in 0 .. H - 2 do
    let line = maze.[y, *]
    let mutable r = 0
    for x in 0 .. W - 1 do
        if maze.[y, x] = '#' then r <- x
    for x in r - 1 .. -1 .. 0 do
        if maze.[y + 1, x] = '#' then ok <- false

if ok then "Possible" else "Impossible"
|> puts

writer.Dispose()


Measured memory_bytes: 11348
N = int(input())
*A, = map(int, input().split())
d = {}


for i in range(1,N+1,1):
    d[i] = 0
for i in range(N-1):
    boss = A[i]
    if d[boss]!=0:
        d[boss] += 1
        continue
    d[boss] = 1


for i in range(1,N+1,1):
    print(d[i])

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

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

using namespace std;

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

template<class T> inline void chmin(T &a, const T &b) { if(a > b) a = b; }

typedef double R;
constexpr R EPS = 1e-8;

struct point {
	R x, y, z;
	explicit point(R x_ = 0, R y_ = 0, R z_ = 0):x(x_), y(y_), z(z_) {}

	inline point operator+(const point &p) const {
		return point(x + p.x, y + p.y, z + p.z);
	}

	inline point operator-(const point &p) const {
		return point(x - p.x, y - p.y, z - p.z);
	}

	inline point operator*(R s) const {
		return point(s * x, s * y, s * z);
	}

	inline point operator/(R s) const {
		return point(x / s, y / s, z / s);
	}
};

inline istream &operator>>(istream &is, point &p) {
	return is >> p.x >> p.y >> p.z;
}

inline R dot(const point &a, const point &b) {
	return a.x * b.x + a.y * b.y + a.z * b.z;
}

inline R norm(const point &p) {
	return p.x * p.x + p.y * p.y + p.z * p.z;
}

inline R abs(const point &p) {
	return sqrt(norm(p));
}

struct sphere {
	point c;
	R r;
	sphere(const point &c_, R r_):c(c_), r(r_) {}
};

// ax^2 + bx + c = 0
vector<R> solve_quadratic_equation(R a, R b, R c) {
	if(abs(a) <= EPS) {
		if(abs(b) <= EPS) {
			if(abs(c) <= EPS) return {0};
			return {};
		}
		return {-c / b};
	}

	const R d = b * b - 4 * a * c;
	if(d < -EPS) return {};

	return {(-b - sqrt(d)) / (2 * a), (-b + sqrt(d)) / (2 * a)};
}

R collision_time(const point &p, const point &v, const sphere &s) {
	const point d_p = p - s.c;
	const R a = norm(v);
	const R b = 2 * dot(d_p, v);
	const R c = norm(d_p) - s.r * s.r;

	R res = INT_MAX;
	for(const auto &t : solve_quadratic_equation(a, b, c)) {
		if(t > EPS) chmin(res, t);
	}
	return res;
}

int main() {
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout.setf(ios::fixed);
	cout.precision(10);

	for(int n; cin >> n && n;) {
		point p, v;
		cin >> v;

		vector<sphere> spheres;
		spheres.reserve(n);

		rep(i, n) {
			point c;
			R r;
			cin >> c >> r;
			spheres.emplace_back(c, r);
		}

		while(true) {
			R min_time = INT_MAX;
			int idx = -1;

			rep(i, n) {
				const R t = collision_time(p, v, spheres[i]);
				if(min_time > t + EPS) {
					min_time = t;
					idx = i;
				}
			}

			if(idx == -1) break;

			p = p + v * min_time;
			point normal = p - spheres[idx].c;
			normal = normal / abs(normal);
			v = v - normal * (2 * dot(v, normal));
		}

		cout << p.x << ' ' << p.y << ' ' << p.z << endl;
	}

	return EXIT_SUCCESS;
}

Measured memory_bytes: 1316
K= int(input())
a,b= list(map(int,input().split()))

def calc(K,a,b):
    # print(K,a,b)
    for i in range(a,b+1):
        # print(i)
        if i % K ==0:
            # res="ok"
            return "OK"
    return "NG"


print(calc(K,a,b))

Measured memory_bytes: 9184
#include <iostream>

using namespace std;
static const int MAX=100;
static const int INFTY= (1<<21);
int M[MAX][MAX]; //?????\??????
int d[MAX]; //?????????????????¬
bool visited[MAX]; //???????¢??????????

void dijkstra(int n)
{
    int min;
    //init
    for(int i=0;i<n;i++)
    {
        visited[i]=false;
        d[i]=INFTY;
    }
    //select node 0
    d[0]=0;
    while(true)
    {
        min=INFTY;
        int min_point=-1;
        for(int i=0;i<n;i++)  //?????????????????????????????\??¶???
        {
            if(min>d[i]&&visited[i]==false)
            {
                min_point=i;
                min=d[i];
            }
        }
        if(min_point==-1) break;  //??????????????°????????????????????????

        visited[min_point]=true;
        //update
        for(int i=0;i<n;i++)
        {
            if(visited[i]==false&&M[min_point][i]!=INFTY)
                if(d[min_point]+M[min_point][i]<d[i])
                    d[i]=d[min_point]+M[min_point][i];
        }
    }
    //print
    for(int i=0;i<n;i++)
        cout<<i<<' '<<(d[i]==INFTY?-1:d[i])<<endl;
}
int main()
{
    int n;
    cin>>n;
    //init
    for(int i=0;i<n;i++)
        for(int j=0;j<n;j++)
            M[i][j]=INFTY;
    for(int i=0;i<n;i++)
    {
        int j;
        cin>>j;
        int nodes_num;
        cin>>nodes_num;
        for(int k=0;k<nodes_num;k++)
        {
            int v,d;
            cin>>v>>d;
            M[j][v]=d;
        }
    }
    dijkstra(n);
}

Measured memory_bytes: 3104
import math
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

def myinput():
    return map(int,readline().split())

n = int(readline())
a = list(myinput())
mod = 10**9 + 7
ans = 0

for j in range(60):
    k = 2**j
    one = 0
    zero = 0
    for i in range(n):
        if (a[i]&k):
            one += 1
        else:
            zero += 1
    ans_bit = zero * one
    ans += (ans_bit)*(2**j) 
    ans %= mod   

print(ans%mod)

Measured memory_bytes: 89712
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
#define ll long long
#define rg register
#define inf 0x3f3f3f3f
inline int read()
{
    int x=0,f=1;char c=getchar();
    while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
    while(c>='0'&&c<='9')x=x*10+c-'0',c=getchar();
    return x*f;
}
int n,z,w,a[2050];
int main(){

    n=read();
    z=read(),w=read();
    for(int i=1;i<=n;i++)
        a[i]=read();
    if(n==1)
    {
        cout<<abs(a[1]-w)<<endl;
        return 0;
    }
    cout<<max(abs(a[n]-a[n-1]),abs(a[n]-w))<<endl;
    return 0;
}

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


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

	bool ans=false;

	for(int i=0;i<=n;i++){
		for(int j=0;j<=n-i;j++){
			int k=n-i-j;
			int maney=i*10000+j*5000+k*1000;
			if(y==maney){
				ans=true;
				cout<<i<<' '<<j<<' '<<k<<endl;
				break;
			}
		}
		if(ans) break;
	}

	if(!ans){
		cout<<-1<<' '<<-1<<' '<<-1<<endl;
	}

	return 0;
}

Measured memory_bytes: 3508
#include<bits/stdc++.h>
#include<string>
#include<map>
#define ll          long long
#define pb          push_back
#define mp          make_pair
#define pii         pair<int,int>
#define pll         pair<ll,ll>
#define vii         vector<pair<ll,ll> >
#define vi          vector<int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (int)x.size()
#define hell        1000000007
#define endl        '\n'
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define rep1(i,a,b) for(ll i=a;i<= b;i++)
#define PI          3.14159
#define MAX         100000001
#define fast_io      ios_base::sync_with_stdio(false);  cin.tie(0); cout.tie(0);
#define scan(var)    scanf("%lld",&var)
#define print(var)   printf("%lld\n", var);
#define BLOCK 317
#define double       long double
#define mod          998244353
using namespace std;
ll dp[101][100001];
ll n,k;
pair<ll,ll>arr[101];
ll solvedp(ll index,ll weight)
{
  if(index == -1)
  {
    return 0;
  }
  if(dp[index][weight] != -1)
  {
    return dp[index][weight];
  }
  if(weight >= arr[index].F)
  {
    dp[index][weight] = max(arr[index].S + solvedp(index - 1,weight - arr[index].F),solvedp(index - 1,weight));
  }
  else
  {
    dp[index][weight] = solvedp(index - 1,weight);
  }
  return dp[index][weight];
}
bool comp(pll p1,pll p2)
{
  return p1.first < p2.first;
}
int main()
{
  fast_io
  cin >> n;
  ll w;
  cin >> w;
  memset(dp,-1,sizeof(dp));
  rep(i,0,n)
  {
    cin >> arr[i].F >> arr[i].S;
  }
  sort(arr,arr + n,comp);
  cout << solvedp(n - 1,w);
  return 0;
}



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

int main() {
    ll N, M; cin >> N >> M;
    vector<vector<ll>> v(8, vector<ll>(N));
    for (int i = 0; i < N; i++)
    {
        ll x, y, z; cin >> x >> y >> z;
        v[0][i] = x + y + z;
        v[1][i] = x - y + z; 
        v[2][i] = x + y - z; 
        v[3][i] = -x + y + z; 
        v[4][i] = x - y - z; 
        v[5][i] = -x - y + z; 
        v[6][i] = -x + y - z; 
        v[7][i] = -x - y - z; 
    }
    for (int i = 0; i < 8; i++)
    {
        sort(v[i].begin(),v[i].end(), greater<ll>());
    }
    
    ll ans = 0;
    for (int i = 0; i < 8; i++)
    {
        ans = max(ans, accumulate(v[i].begin(),v[i].begin()+M, 0LL));
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
n = int(input())
dic_A = set()
dic_C = set()
dic_G = set()
dic_T = set()
for i in range(n) :
    p, string = input().split()
    if p == 'insert' :
        if string[0] == 'A' :
            dic_A.add(string)
        elif string[0] == 'C' :
            dic_C.add(string)
        elif string[0] == 'G' :
            dic_G.add(string)
        else :
            dic_T.add(string)
    else :
        if string[0] == 'A' :
            if string in dic_A :
                print('yes')
            else :
                print('no')
        elif string[0] == 'C' :
            if string in dic_C :
                print('yes')
            else :
                print('no')
        elif string[0] == 'G' :
            if string in dic_G :
                print('yes')
            else :
                print('no')
        else :
            if string in dic_T :
                print('yes')
            else :
                print('no')


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

int main() {
	int N, D; cin >> N;
	map<int, int> made;
	for(int i=0; i<N; ++i){
	    cin >> D;
	    ++made[D];
	}
	int M, T; cin >> M;
	bool flag=true;
	for(int i=0; i<M; ++i){
	    cin >> T;
	    --made[T];
	    if(made[T]<0){
	        flag=false;
	        break;
	    }
	}
	if(flag) cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}


Measured memory_bytes: 9600
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n ,x;
	cin >> n >> x;
	int l[n];
	for(int i=0;i<n;++i){
		int a;
		cin >> a;
		l[i] = a;
	}
	int cor = 0;
	int bounce = 0;
	for(int i=0;i<=n;++i){
		if(i==0){
			bounce++;
		}else if(i>0){
			cor = l[i-1]+cor;
			if(cor<=x){
				bounce++;
			}else if(cor>x){
				break;
			}
		}
	}
	cout << bounce << endl;
	return 0;
	 
}

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

unordered_map<int,unordered_map<int,int>>U;
P a[100000],b[100000];
signed main(){
int n,m;cin>>n>>m;
for(int i=0;i<m;i++){
int c,d;cin>>c>>d;
int e=min(c,d),f=max(c,d);
a[i]={e,f},b[i]={f,e};
}
sort(a,a+m);
sort(b,b+m);
int ans=0;
int x=0,y=0;
while(y<m){
if(!U[b[y].second][b[y].first]){ans++;
                while(a[x].first<b[y].first&&x<m){
                  U[a[x].first][a[x].second]=true;
                  x++;
                }
                               }
  y++;
}
cout<<ans<<endl;
}


Measured memory_bytes: 16804
#include<stdio.h>
#define N 25
#define NIL -1

struct Node {
  int parent;
  int left;
  int right;
};
struct Node T[N];
int cnt,x,y;

int depth(int nodeid) {

 if(T[nodeid].parent == NIL) {
    return 0;
  }
 else {
      cnt++;
      depth(T[nodeid].parent);
    }
 return  cnt;  
}

int height(int nodeid) {
  int x=0,y=0;
  if(T[nodeid].left != NIL)
    x = height(T[nodeid].left) + 1;
  
  if(T[nodeid].right != NIL)
    y = height(T[nodeid].right) + 1;
  
  if(x < y) return y;
  
  else return x; 
  
}

int sibling(int nodeid) {
  if(T[nodeid].parent == NIL)
    return NIL;

 else  if(T[T[nodeid].parent].left == nodeid)
    return T[T[nodeid].parent].right;

 else return T[T[nodeid].parent].left;

}		 

int degree(int nodeid) {
  if(T[nodeid].left == NIL && T[nodeid].right == NIL)
    return 0;
  else if(T[nodeid].left != NIL && T[nodeid].right != NIL)
    return 2;
  else return 1;
}

int main(void) {
  
  int i,j,n,m,l,newnode,left,right;
  
  scanf("%d",&n);
  
  for(i=0;i<n;i++)
    T[i].parent = T[i].left = T[i].right = NIL; 
  
  for(i=0;i<n;i++) {
    scanf("%d%d%d",&newnode,&m,&l);

    T[m].parent = newnode;
    T[l].parent = newnode;  
    T[newnode].left = m;    
    T[newnode].right = l;  
 
  }   
    for(i=0;i<n;i++) { 
      cnt = 0;
      printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d,",i,T[i].parent,sibling(i),degree(i),depth(i),height(i));
      
      if(T[i].parent == NIL) {
	printf(" root\n");
      }
      else if (T[i].left == NIL && T[i].right == NIL) {
	printf(" leaf\n");
      }  
      else  {
	printf(" internal node\n");
      }   
    }
    return 0;    

}  

Measured memory_bytes: 612
from sys import exit, setrecursionlimit, stderr
from functools import reduce
from itertools import *
from collections import defaultdict, Counter
from bisect import bisect

setrecursionlimit(10**7)

def read():
  return int(input())

def reads():
  return [int(x) for x in input().split()]

N, K = reads()
A = reads()

def f(X):
  return sum(X ^ a for a in A)

maj = 0
for j in range(41):
  if sum(a & (1 << j) > 0 for a in A) <= N // 2:
    maj |= (1 << j)

ans = (f(K), K)
for i in range(45):
  if K & (1 << i) == 0:
    continue
  X = K & ((~0) << (i+1)) | (maj & ((1 << i) - 1))
  ans = max(ans, (f(X), X))
print(ans[0])


Measured memory_bytes: 69356
def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

factorization(24) 

import sys
N=int(input())
if(N==1):
  print(0)
  sys.exit()
div = make_divisors(N)
div.remove(1)
new_div=[]
for k in div:
  jud=factorization(k) 
  if(len(jud)==1):
    new_div.append(k)
ans=0

for i in new_div:
  if(N%i==0):
    N=N/i
    ans+=1
  if(N==1):
    print(ans)
    sys.exit()
print(ans)

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

#ifdef DEBUG
#include "debug.h"
#endif

using namespace std;

#define mp make_pair
#define mt make_tuple
#define all(a) (a).begin(), (a).end()
#define rep(i, a, b) for (int (i) = (a); (i) < (b); ++(i))
#define sz(a) ((int)(a).size())
#define make_unique(a) (a).resize(unique(all((x))) - (x).begin())

typedef long long ll;

template<typename T> inline bool mmin(T& a, const T &b) { return a < b ? (a = b, true) : false; }
template<typename T> inline bool mmax(T& a, const T &b) { return a > b ? (a = b, true) : false; }

const int shift = 10;
const int maxn = 201000;

int a[maxn];
ll s[maxn];

ll get_sum(int l, int r) {
    ll res = s[r];
    if (l) {
        res -= s[l - 1];
    }
    return res;
}

int main() {
    std::ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        s[i] = a[i];
        if (i) {
            s[i] += s[i - 1];
        }
    }

    ll ans = 1e16;
    for (int cut2 = 1; cut2 <= n - 3; ++cut2) {
        ll need1 = get_sum(0, cut2) / 2;
        ll need2 = get_sum(0, cut2) + get_sum(cut2 + 1, n - 1) / 2;
        int p1 = lower_bound(s, s + n, need1) - s;
        int p3 = lower_bound(s, s + n, need2) - s;
        for (int cut1 = p1 - shift; cut1 <= p1 + shift; ++cut1) {
            for (int cut3 = p3 - shift; cut3 <= p3 + shift; ++cut3) {
                if (cut1 < 0 || cut3 >= n - 1 || cut2 <= cut1 || cut3 <= cut2) {
                    continue;
                }
                ll s1 = get_sum(0, cut1);
                ll s2 = get_sum(cut1 + 1, cut2);
                ll s3 = get_sum(cut2 + 1, cut3);
                ll s4 = get_sum(cut3 + 1, n - 1);
                ll m1 = min(min(s1, s2), min(s3, s4));
                ll m2 = max(max(s1, s2), max(s3, s4));
                ans = min(ans, m2 - m1);               
            }
        }
    }
    cout << ans << '\n';
    
    return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
using namespace std;
typedef long long ll;
typedef pair<int, int> P; 
const int inf = 1<<21;
const ll INF = 1LL << 60;
const ll mod = 1e9+7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h, n;
    cin >> h >> n;
    vector<P> ab(n);
    rep(i, n){
        int a, b;
        cin >> a >> b;
        ab[i] = make_pair(a, b);
    }

    // // dp[i][j] := i番目までの魔法を使って、体力をj以上消費するようにした時の最小魔力
    ll dp[1005][10005];
    rep(i, n+1)rep(j, h+1) dp[i][j] = INF;
    dp[0][0] = 0;
    for(int i=0; i<n; i++){
        for(int j=0; j<=h; j++){
            chmin(dp[i+1][j], dp[i][j]);
            chmin(dp[i+1][min(j+ab[i].first, h)], dp[i+1][j] + ab[i].second);
        }
    }
    cout << dp[n][h] << endl;

    return 0;
}

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

using namespace std;

const int N = int(1e5 + 10);

int color;
int comp[N];
int a[N];
vector<vector<int> >adj;

void dfs(int x){
	comp[x] = color;
	
	for(int i = 0 ; i < adj[x].size() ; i++){
		int u = adj[x][i];
		
		if(comp[u] == 0){
			dfs(u);
		}
	}	
}

int main(){
	int n, m;
	
	cin >> n >> m;
	
	adj.resize(n + 2);
	
	for(int i = 1 ; i <= n ; i++){
		cin >> a[i];
	}	
	
	for(int i = 0 ; i < m ; i++){
		int u, v;
		
		cin >> u >> v;
		
		adj[u].push_back(v);
		adj[v].push_back(u);
	}
	
	for(int i = 1 ; i <= n ; i++){
		if(comp[i] == 0){
			color++;
			dfs(i);
		}
	}
	
	int r = 0;
	
	for(int i = 1 ; i <= n ; i++){
		if(comp[a[i]] == comp[i]){
			r++;
		}	
	}
	
	cout << r << endl;
	
	return 0;
}

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

const ll  INF = 1LL << 60;
ll s[15];
ll d[100];
ll sum[1 << 15];
ll dp[101][1 << 15];

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

	int N, M;
	while(cin >> N >> M, N) {
		for(int i = 0; i < N; i++) {
			cin >> s[i];
		}
		for(int i = 0; i < M; i++) {
			cin >> d[i];
		}
		sort(d, d + M);

		for(int i = 0; i < 1 << N; i++) {
			sum[i] = 0;
			for(int j = 0; j < N; j++) {
				if(i >> j & 1) sum[i] += s[j];
			}
		}

		fill((ll*)begin(dp), (ll*)end(dp), INF);
		dp[0][0] = 0;
		for(int i = 0; i < M; i++) {
			for(int j = 0; j < 1 << N; j++) {
				if(dp[i][j] == INF) continue;
				dp[i + 1][j] = min(dp[i + 1][j], dp[i][j] + abs(sum[j] - d[i]));
				for(int k = 0; k < N; k++) {
					if(j >> k & 1) continue;
					dp[i][j | (1 << k)] = min(dp[i][j | (1 << k)], dp[i][j]);
				}
			}
		}

		ll ans = INF;
		for(int i = 0; i < 1 << N; i++) {
			ans = min(ans, dp[M][i]);
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 29240
#include<stdio.h>
int main(void)
{
	int x, y, z, i=1;
	while(1){
		scanf("%d %d", &x, &y);
		if(x==0 && y==0){
			break;
		}
		if(x>=y){
			z=x; x=y; y=z;
		}
		printf("%d %d\n", x, y);
	}
	
	return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1<<29;
const int MOD = 1e9+7;
const ll LINF = 1e18;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
    REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
    REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}

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; }

const int dx4[4] = {1, 0, -1, 0};
const int dy4[4] = {0, 1, 0, -1};

const int dx8[8] = {1,1,0,-1,-1,-1,0,1};
const int dy8[8] = {0,1,1,1,0,-1,-1,-1};

vector< vector<int> > Graph;
vector< int > value;





int main(int argc, const char * argv[]) {
    
    // remove the bottom 3 lines when you submit this code.
    std::ifstream in("sample.txt");
    std::cin.rdbuf(in.rdbuf());

    cin.tie(0);
    ios::sync_with_stdio(false);
    
    string s; cin >> s;
    map<char,int> cnt{};
    rep(i,s.size())cnt[s[i]]++;
    
    bool isAns = true;
    
    for(auto it = cnt.begin(); it != cnt.end(); it++){
        if(it->second % 2 == 1) isAns = false;
    }
    
    if(isAns) cout << "Yes" << endl;
    else cout << "No" << endl;
    
}



Measured memory_bytes: 256
import math
n = int(input())

ans_bool = False
ans_num = 0

for i in range(1, n+1):
    if math.floor(i * 1.08) == n:
        ans_bool = True
        ans_num = i
    else:
        pass
if ans_bool:
    print(ans_num)
else:
    print(":(")


Measured memory_bytes: 9160
n = int(input())
arr = list(map(int,input().split()))

rgb = [0 for i in range(3)]

count = 1
m = 1000000007

for i in range(n):
    a = arr[i]
    temp = 0
    hoge = -1
    for j in range(3):
        if rgb[j] == a:
            hoge = j
            temp += 1
    rgb[hoge] += 1
    if temp == 0:
        count = 0
        break
    else:
        count *= temp
        count = count%m

# print(rgb)
print(count)


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

using namespace std;
vector<int> G[123456];
int d[123456];
int main()
{
    int n;
    ios::sync_with_stdio(0);
    cin >> n ;
    for (int i=0;i<n-1;i++)
    {
        int x,y;
        cin >> x>> y;
        --x,--y;
        G[x].push_back(y);
        G[y].push_back(x);
    }
    int k;
    cin >> k ;
    priority_queue<pair<int,int>,vector<pair<int,int>>,greater<pair<int,int>>> pq;
    memset(d,-1,sizeof(d));
    while(k--)
    {
        int x,y;
        cin >> x >>y;
        d[x-1]=y;
        pq.push({y,x-1});
    }
    while(!pq.empty())
    {
        pair<int,int> p=pq.top();pq.pop();
        int u=p.second;
        for (int i=0;i<G[u].size();i++)
        {
            int v=G[u][i];
            if (d[v]==-1)
            {
                d[v]=d[u]+1;
                pq.push({d[v],v});
            }
        }
    }
    for (int u=0;u<n;u++)
    {
        for (int i=0;i<G[u].size();i++)
        {
            int v=G[u][i];
            if (abs(d[u]-d[v])!=1)
            {
                cout << "No" << endl;
                exit(0);
            }
        }
    }
    cout << "Yes" << endl;
    for (int i=0;i<n;i++) cout << d[i] << endl;
    return 0;
}


Measured memory_bytes: 8564
#include<bits/stdc++.h>
using namespace std;
 
int main(){
    int n;
    cin>>n;
    vector<string> s;
    string cnt;
    for(int i=0;i<n;i++)
    {
        cin>>cnt;
        s.push_back(cnt);
    }
    sort(s.begin(),s.end());
    int kind=0;
    for(int k=0;k<n-1;k++){
        if(s[k]!=s[k+1]){kind++;}
    }
    cout<<kind+1;
}

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

signed main(){
  int N;
  cin>>N;
  vector<int> A(N);
  rep(i,N)cin>>A[i];
  int ans=100000;
  rep(i,N){
    int J=0;
    while(A[i]%2==0){
      J+=1;
      A[i]/=2;
    }
    if(ans>J)ans=J;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3592
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int k = in.nextInt();
            int n = in.nextInt();
            int[] a = new int[n];
            for (int i = 0; i < n; i++) a[i] = in.nextInt();
            int maxDist = 0;
            for (int i = 0; i < n - 1; i++)
                maxDist = Math.max(a[i + 1] - a[i], maxDist);
            maxDist = Math.max(k - a[n - 1] + a[0], maxDist);
            int ans = k - maxDist;
            out.println(ans);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 48468
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

#define rep(i, l, n) for(int i=(l); i<(int)(n); i++)
#define REP(i, n) for(int i=1; i<=(int)(n); i++)

using namespace std;

int main(){
    int N;
    cin >> N;
    vector<vector<double> > dp(N+1, vector<double>(N+1, 0));
    vector<double> p(N+1);

    rep(i, 1, N+1) {
        cin >> p[i];
    }
    dp[0][0] = 1;
    rep(i, 1, N+1) {
        rep(j, 0, i+1) {
            if (j>0) {
                dp[i][j] = dp[i-1][j] * (1-p[i]) + dp[i-1][j-1] * p[i];
            } else {
                dp[i][j] = dp[i-1][j] * (1-p[i]);
            }
        }
    }

    double ans = 0;
    rep(i, N/2 + 1, N+1) {
        ans += dp[N][i];
    }

    printf("%0.12f\n", ans);

    return 0;
}



Measured memory_bytes: 70656
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define endl "\n"
#define pb push_back
#define f(i,n) for(i=0;i<n;i++)
#define F(i,a,b) for(i=a;a<=b;i++)
#define arr(a,n) for( i=0;i<n;i++)cin>>a[i];
#define fi first
#define se second
#define mp make_pair
#define mod 1000000007
#define YES cout<<"YES"<<endl;
#define Yes cout<<"Yes"<<endl;
#define NO cout<<"NO"<<endl;
#define No cout<<"No"<<endl;
#define yes cout<<"yes"<<endl;
#define no cout<<"no"<<endl;
#define vi vector<ll>
#define ed end()
#define bg begin()
#define sz size()
#define ln length()
#define s() sort(a,a+n);
#define sr() sort(a,a+n,greater<ll>());
#define v()  sort(v.begin(),v.end());
#define vr() sort(v.begin(),v.end(),greater<ll>());
#define mod 1000000007
#define fast() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);}
ll power(ll x,ll y,ll p){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
int main() {
    /*#ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
    #endif*/
        /* 
        Ofcourse it's Hard.
        It's supposed to be Hard.
        If it's easy everyone would do it.
        HARD IS WHAT MAKES IT GREAT

        YESTERDAY U SAID TOMORROW

        SLOWLY BECOMING THE PERSON I 
        SHOULD HAVE BEEN A LONG TIME AGO

        SAME TASK CAN'T BE FOUND DIFFICULT TWICE

        BTBHWSITW

        SPRH TU KAB P

        CP IS ALL ABOUT THINKING 
        YOU HAVE MUCH MORE POTENTIAL THAN U THINK

        AJIT SHIDDAT 10

        UR DAILY ROUTINE 


        */

fast();
//ll t;cin>>t;while(t--)
{
    ll a,b;
    cin>>a>>b;
    if(b%a==0)
        cout<<a+b<<endl;
    else
        cout<<b-a<<endl;
}
return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
typedef long long               ll;
typedef long double             ld;
 
 
#define racecar          ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define time_start		 time_t start, end; time(&start); 
#define time_end		 time(&end);double time_taken=double(end-start);cout <<"\n"<< time_taken*1000<<" ms";
#define si(a)            scanf("%d", &a)
#define si2(a,b)         scanf("%d %d", &a,&b)
#define sll(a)           scanf("%I64d",&a)
#define sll2(a,b)        scanf("%I64d %I64d",&a,&b)
#define pb               push_back
#define pi(a)            printf("%d",int(a))
#define pll(a)           printf("%I64d",ll(a))
#define all(x)           (x).begin(),(x).end()
#define rall(x)          (x).rbegin(),(x).rend()
#define ps               printf(" ")
#define nln              printf("\n")
#define ff               first
#define ss               second
#define vi               vector<int>
#define vll              vector<ll>
#define vstr             vector<string>
#define vc               vector<char>
#define pii              pair<int,int>
#define PLL              pair<ll,ll>
#define PI               acos(-1)
#define sq(x)            x*x
#define forr(i,a,b)      for(ll i=ll(a);i<ll(b);i++)
#define forn(i,a,b)      for(ll i=ll(a);i>ll(b);i--)
#define max3(a,b,c)      max(a,max(b,c))
#define max4(a,b,c,d)    max(max3(a,b,c),d)
#define min3(a,b,c)      min(a,min(b,c))
#define mod              1000000007
#define inf              9223372036854775807

///knight moves:
///int dx[] = {-2, -1, 1, 2, -2, -1, 1, 2}; 
///int dy[] = {-1, -2, -2, -1, 1, 2, 2, 1};

 
ll power(ll b,ll n)
{
    if(n==0) return 1;
    else if(n%2) return b*power(b,n/2)*power(b,n/2);
    else return power(b,n/2)*power(b,n/2);
}
 
ld root(ll n,ll r)
{
    ld dif=0.0001;
    ld guess=n/2.0;
    while(abs(pow(guess,r)-n)>=dif)
    {
        ld temp=pow(guess,r)-n;
        ld tmp=r*pow(guess,r-1);
        guess-=temp/tmp;
    }
    return guess;
}
 
void fileio()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
}

ll fact(ll n)
{
	if(n==0 || n==1) return 1;
	ll temp=1;
	forr(i,1,n+1) temp*=i;
	return temp;
}




int solve()
{  
    ll n;
    sll(n);
    vll v(n);
    forr(i,0,n) sll(v[i]);
    
    vll gcd_forward(n+1);
    vll gcd_backward(n+1);
    
    gcd_forward[0]=0;
    forr(i,0,n) gcd_forward[i+1]=__gcd(gcd_forward[i],v[i]);
    
    gcd_backward[0]=0;
    forr(i,0,n) gcd_backward[i+1]=__gcd(gcd_backward[i],v[n-i-1]);
    
    ll hi=0;
    
    forr(i,0,n) hi=max(hi,__gcd(gcd_forward[i],gcd_backward[n-i-1]));
    
    pll(hi);
    		
   	return 0;
}
	
 
int main()
{

//    racecar;
//    cout<<fixed<<setprecision(6);
//    fileio();
    solve();

}

 
 
///    Before submission=>
///    ***check for integer overflow,array bounds
///    ***check for n


Measured memory_bytes: 2560
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<set>
#include<map>
#include<string>
#include<functional>
#include<queue>
#include<stack>
#include<math.h>
#define INF 1000000001
#define EPS 1.0e-6

using namespace std;

typedef long long ll;

string t;
string p;


int main()
{
	cin >> t;
	cin >> p;

	int tlen = t.length();
	int plen = p.length();

	for (int i = 0; i <= tlen - plen; i++) {
		if (t[i] == p[0]) {
			int ope = 0;
			int j = 1;
			while (j < plen ) {
				if (t[i + j] == p[j])j++;
				else {
					ope = 1; break;
				}
			}
			if (ope == 0)cout << i << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3180
n = int(input())
s = list(str(input()))

n_s = ""

for c in s:
    add = n
    c_num = ord(c) - 64
    if(n % 26 == 0):
        n_s += c
    else:
        if(c_num + n > 26):
            add = (c_num + n) % 26
            n_s += chr(add + 64)
        else:
            n_s += chr(c_num + add + 64)

print(n_s)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define FIO ios_base::sync_with_stdio (false) ;cin.tie(NULL);
#define tc  int t;cin>>t;for(int i=0;i<t;i++)
#define ll long long int
#define forn(i,n) for(int i=0;i<n;i++)
#define forn1(i,a,b) for(int i=a;i<=b;i++)
#define pb push_back
#define um(a,b) unordered_map<a,b>
#define vv(a) vector<a>
#define pp(a,b) pair<a,b>
int main(){
FIO
   ll n;
   cin>>n;
   ll k;
   cin>>k;
   ll arr[n];
   ll ans=0;
   forn(i,n){
   cin>>arr[i];}
  sort(arr,arr+n);
  for(ll i=0;i<k;i++){
    ans+=arr[i];
  }
  cout<<ans<<endl;
}


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

int main() {
  long double N, K;
  cin >> N >> K;
  long double ans = 0;

  if (N >= K) {
    ans += (N - K + 1) / N;
    for (int i = 1; i < K; i++) {
      int win_coin_count = ceil(log2(K / i));
      ans += 1 / N * pow(0.5, win_coin_count);
    }
  }
  else {
    for (int i = 1; i <= N; i++) {
      int win_coin_count = ceil(log2(K / i));
      ans += 1 / N * pow(0.5, win_coin_count);
    }
  }

  cout << std::setprecision(10) << ans << endl;

  return 0;
}

Measured memory_bytes: 384
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <list>

using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(d) string(1,d)
#define print(x) cout<<#x<<" = "<<x<<endl;

#define MOD 1000000007

ll d[55][55];

int main() {
  ll w,h,t;
  cin>>w>>h>>t;
  clr(d,0);
  ll p;
  cin>>p;
  rep(i,0,p){
    ll a,b,c;
    cin>>a>>b>>c;
    if(c<=t){
      d[b][a]++;
    }
  }
  ll ans = 0;
  rep(y,0,h){
    rep(x,0,w){
      ll a;
      cin>>a;
      if(a==1){
        ans += d[y][x];
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1188
#include "bits/stdc++.h"
#define FI first.first
#define SE first.second
#define TH second
#define fi first
#define se second
#define th second

using namespace std;

class DebugStream {}LOG;
template <typename T>DebugStream &operator<<(DebugStream &s, const T&) { return s; }
#ifdef DEBUG
#define LOG clog
#endif

typedef long long ll;
typedef pair<ll, ll> ii;
typedef long double ld;

const int maxN = 3e2 + 9, maxV = 1e6 + 9, MOD = 998244353, SQ = 335, lg = 20, bs = 29; 

int n, arr[maxN];
ll dp[maxN][maxN * maxN], ot[maxN][maxN * maxN * 2];
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	#ifdef DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif
	cin >> n;
	for(int i = 0; i < n; i++) cin >> arr[i];
	ll ans = 1;

	ot[n][maxN * maxN] = 1;
	for(int i = n - 1; i >= 0; i--) {
		for(int j = 0; j < 2 * maxN * maxN; j++) {
			if(j + arr[i] < 2 * maxN * maxN) ot[i][j + arr[i]] = (ot[i][j + arr[i]] + ot[i + 1][j]) % MOD;
			if(j - arr[i] >= 0) ot[i][j - arr[i]] = (ot[i][j - arr[i]] + ot[i + 1][j]) % MOD;
		}
	}

	dp[n][0] = 3;
	for(int i = n - 1; i >= 0; i--) {
		for(int j = 0; j < maxN * maxN; j++) {
			dp[i][j] = (dp[i][j] + dp[i + 1][j] * 2) % MOD;
			if(j + arr[i] < maxN * maxN)	
				dp[i][j + arr[i]] = (dp[i][j + arr[i]] + dp[i + 1][j]) % MOD;
		}
		ans = ans * 3 % MOD;
	}
	int lim = accumulate(arr, arr + n, 0);

	for(int i = 0; i <= lim; i++) LOG << i << ' ' << dp[0][i] << '\n'; LOG << '\n';
	for(int i = 0; i < maxN * maxN; i++)
		if(i * 2 >= lim)
			ans = (ans + ll(MOD - dp[0][i])) % MOD;
	LOG << ot[0][maxN * maxN] << '\n';
	ans = (ans + ll(ot[0][maxN * maxN]) * 3) % MOD;
	cout << ans << '\n'; 
	
}


Measured memory_bytes: 674048
n = int( input() )

ans = n

if n < 10:
    ans = n
elif n < 100:
    ans = 9
elif n < 1000:
    ans = n - 90
elif n < 10000:
    ans = 9 + 900
elif n < 100000:
    ans = n - 9000 - 90
else:
    ans = 9 + 900 + 90000

print(ans)

Measured memory_bytes: 38384
from collections import deque
s=deque(input())
q=int(input())
flag=0
for i in range(q):
  query=input()
  if len(query)==1:
    flag+=1
  else:
    if query[2]=="1" and flag%2==0 or query[2]=="2" and flag%2==1:
      s.appendleft(query[4])
    else:
      s.append(query[4])
if flag%2==1:
  s.reverse()
print("".join(s))

Measured memory_bytes: 102972
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main {
	void run() {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int w = scan.nextInt();
		int d = scan.nextInt();
		
		int[][] ary = new int[n][2];
		for (int i = 0; i < n; i++) {
			int x = scan.nextInt();
			int y = scan.nextInt();
			switch (scan.next()) {
			case "N":
				ary[i][0] = w + (w - x + y);
				ary[i][1] = ary[i][0] + (d - y) * 2;
				break;
			case "E":
				ary[i][0] = x + y;
				ary[i][1] = ary[i][0] + (w - x) * 2;
				break;
			case "S":
				if (x < y)
					ary[i][0] = 2 * w + 2 * d - (y - x);
				else
					ary[i][0] = x - y;
				ary[i][1] = ary[i][0] + y * 2;
				break;
			default:
				ary[i][0] = w + d + (w - x) + (d - y);
				ary[i][1] = ary[i][0] + x * 2;
				break;
			}
		}
//		for (int i = 0; i < n; i++) {
//			System.out.println(ary[i][0] + " " + ary[i][1]);
//		}
		int min = Integer.MAX_VALUE;
		for (int i = 0; i < n; i++) {
			Arrays.sort(ary, new Comparator<int[]>() {
				public int compare(int[] o1, int[] o2) {
					return o1[1] - o2[1];
				}
			});
			int ans = 1;
			int p = ary[0][1];
			for (int j = 1; j < n; j++) {
				if (p < ary[j][0]) {
					ans++;
					p = ary[j][1];
				}
			}
			ary[0][0] += 2 * w + 2 * d;
			ary[0][1] += 2 * w + 2 * d;
			min = Math.min(min, ans);
		}
		System.out.println(min);
	}
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 39296
tmp = list(map(int,input().split()))
n , m = tmp[0],tmp[1]
lis = list(map(int,input().split()))
import math
def gcd(a,b):
  if a % b:
    return(gcd(b,a%b))
  else:
    return(b)
  
from functools import reduce

def mygcd(*numbers):
     return reduce(gcd, numbers)

x = mygcd(*lis)
if m <= max(lis) and not (m % x):
  print("POSSIBLE")
else:
  print("IMPOSSIBLE")

Measured memory_bytes: 14100
import numpy as np

H,W,K = map(int, input().split())

s = [[]for h in range(H)]
for h in range(H):
    temp = input()
    for w,x in enumerate(temp):
        s[h].append(x)

iro = np.zeros([H,W])
tamari = []
temp = 1
for h in range(H):
    temp_line = 0
    for w in range(W):
        if(s[h][w] == "#"):
            temp_line += 1
    if(temp_line == 0):
        tamari.append(h)
    else:
        count_flag = 0
        for w in range(W):
            if(s[h][w] == "#" and count_flag != temp_line-1):
                iro[h,w] = temp
                if(tamari != []):
                    for hh in tamari:
                        iro[hh,w] = temp
                temp += 1
                count_flag += 1
            elif(s[h][w] == "#"):
                iro[h,w] = temp
                if(tamari != []):
                    for hh in tamari:
                        iro[hh,w] = temp
            else:
                iro[h,w] = temp
                if(tamari != []):
                    for hh in tamari:
                        iro[hh,w] = temp
        temp += 1
        tamari = []
if(tamari != []):
    hhh = int(min(tamari)-1)
    for hh in tamari:
        for w in range(W):
            iro[hh,w]=iro[hhh,w]

for h in range(H):
    temp = ""
    for w in range(W):
        temp += str(int(iro[h,w]))
        if(w != W-1):
            temp += " "
    print(temp)
                


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

int main()
{
	string S;
	cin >> S;

	int N = S.size() + 1;
	vector<int> l( N );
	int n = 0;
	for( int i = 0; i < N - 1; i++ ) {
		if( S[i] == '<' ) n++;
		else n = 0;
		l[i + 1] = n;
	}
	vector<int> r( N );
	n = 0;
	for( int i = N - 2; i >= 0; i-- ) {
		if( S[i] == '>' ) n++;
		else n = 0;
		r[i] = n;
	}
	long long ans = 0;
	for( int i = 0; i < N; i++ ) {
		ans += max( l[i], r[i] );
	}

	cout << ans << endl;
}


Measured memory_bytes: 7584
#include<cstdio>
const int N=400002;
char s[N];
int n,m,c[N],a,b,i,j,k,p;
int h[N],t[N],v[N],vis[N];
void add(int a,int b){
	t[++k]=h[a];h[a]=k;v[k]=b;
	t[++k]=h[b];h[b]=k;v[k]=a;
}
void init(){
	scanf("%s",s+1);
	while(s[n+1])n++;
	for(i=1;i<=n+1;i++)
		c[i]=s[i]-s[i-1];
	for(i=1,j=n+1;i<j;i++,j--)
		add(i,j);
	scanf("%d",&m);
	while(m--){
		scanf("%d%d",&a,&b);
		add(a,b+1);
	}
}
void dfs(int i){
	vis[i]=1;
	p+=c[i];
	for(int j=h[i];j;j=t[j])
		if(!vis[v[j]])
			dfs(v[j]);
}
void work(){
	dfs(n+1);
	for(i=1;i<=n;i++)
		if(!vis[i]){
			p=0;
			dfs(i);
			if(p%26!=0){
				printf("NO\n");
				return;
			}
		}
	printf("YES\n");
}
int main(){
	init();
	work();
	return 0;
}

Measured memory_bytes: 7936
#include<stdio.h>
int main()
{
    int N,i,x=0;
    scanf("%d",&N);
    for(i=1; i<=N; i++)
    {


      if(N%i==0)
      {

        if(i<10 && N/i<10)
            {
                printf("Yes");
                x=1;
                break;
            }

       }

    }
    if(x==0)
    {
         printf("No");
    }
    return 0;
}





Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        if((a < b)&&(b < c)){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}



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

const int MAX = 100005;
const int NIL = -1;

struct Node{
  int p;
  int l;
  int r;
};

Node T[MAX];
int n, D[MAX];

void print(int u){
  int i, c;
  cout << "node " << u << ": ";
  cout << "parent = " << T[u].p << ", ";
  cout << "depth = " << D[u] << ", ";

  if(T[u].p == NIL) cout << "root, ";
  else if (T[u].l == NIL) cout << "leaf, ";
  else cout << "internal node, ";

  cout << "[";
  for(i=0, c=T[u].l; c!=NIL; i++, c=T[c].r){
    if(i) cout << ", ";
    cout << c;
  }
  cout << "]" << endl;
}

void rec(int u, int p){
  D[u] = p;
  if(T[u].r != NIL) rec(T[u].r, p);
  if(T[u].l != NIL) rec(T[u].l, p+1);
}

int main() {
    ios::sync_with_stdio(false);

    int i, j, d, v, c, l, r;
    cin >> n;
    for(i=0; i<n; i++){
      T[i].p = T[i].l = T[i].r = NIL;
    }
    for(i=0; i<n; i++){
      cin >> v >> d;
      for(j=0; j<d; j++){
        cin >> c;
        if(j==0) T[v].l = c;
        else T[l].r = c;
        l = c;
        T[c].p = v;
      }
    }
    for(i=0; i<n; i++){
      if(T[i].p == NIL) r=i; //root????????????0??¨?????????????????????????????§??????
    }

    rec(r, 0);
    for(i=0; i<n; i++) print(i);

    return 0;
}

Measured memory_bytes: 5888
import Control.Applicative
import Control.Monad

import Data.List
import Data.Maybe

table :: Int -> [Int]
table i =
  case i of
    0 -> [1, 3]
    1 -> [5, 2]
    2 -> [4, 0]
    3 -> [5, 1]
    4 -> [0, 3]
    5 -> [4, 2]

main :: IO ()
main = do
  dice <- words <$> getLine
  n <- read <$> getLine
  replicateM_ n $ do
    [top, front] <- map (fromJust . (`elemIndex` dice)) . words <$> getLine
    let sideIndex = 3 - min top (5 - top) - min front (5 - front)
    putStrLn $ dice !! if front `elem` table top then sideIndex else 5 - sideIndex

Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define REP(i, n) for(long long i=0; i<n; i++)
#define REPR(i, n) for(long long i=n-1; i>=0; i--)
#define FOR(i, m, n) for(long long i=m; i<=n; i++)
#define FORR(i, m, n) for(long long i=m; i>=n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
#define FIN ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;
const ll mod = 1e9+7;
const ll inf = 1e15;


int main(){FIN
 
    string s,t;cin>>s>>t;
    if (t.substr(0,s.size())==s){
        cout<<"Yes"<<endl;
        
    }
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 3652
#include <iostream>
#include <algorithm>
#include <string>

using namespace std;
int main() {
	string s;
	while (getline(cin, s), s != "END OF INPUT") {
		for (int i = 0, n = 0; i <= s.length(); i++) {
			if (i == s.length() || s[i] == ' ') {
				cout << n;
				n = 0;
			} else {
				n++;
			}
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 3192
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Math;

class MainClass : Scanner
{
    static void Main()
    {
        var (N, X, T) = ReadStream<int,int,int>();
        int ans = 0;
        int count = 0;
        while (count < N)
        {
            ans += T;
            count += X;
        }
        WriteLine(ans);
    }

}



class Scanner
{
    public static int RInt() => int.Parse(Console.ReadLine());
    public static long RLong() => long.Parse(Console.ReadLine());
    public static string RString() => Console.ReadLine();
    public static double RDouble() => double.Parse(Console.ReadLine());

    public static int[] RInts() => Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
    public static int[] RInts(Func<string, int> func) => Console.ReadLine().Split().Select(func).ToArray();
    public static long[] RLongs() => Array.ConvertAll(Console.ReadLine().Split(), long.Parse);
    public static long[] RLongs(Func<string, long> func) => Console.ReadLine().Split().Select(func).ToArray();
    public static double[] RDoubles() => Array.ConvertAll(Console.ReadLine().Split(), double.Parse);
    public static double[] RDoubles(Func<string, double> func) => Console.ReadLine().Split().Select(func).ToArray();
    public static string[] RStrings() => Console.ReadLine().Split();
    //public static string[] RStrings(Func<string, string> func) => Console.ReadLine().Split().Select(func).ToArray();
    public static T1 ReadStream<T1>()
    {
        var r = RStrings();
        var r1 = (T1)Convert.ChangeType(r[0], typeof(T1));
        return r1;
    }
    public static (T1, T2) ReadStream<T1, T2>()
    {
        var r = RStrings();
        var r1 = (T1)Convert.ChangeType(r[0], typeof(T1));
        var r2 = (T2)Convert.ChangeType(r[1], typeof(T2));
        return (r1, r2);
    }
    public static (T1, T2, T3) ReadStream<T1, T2, T3>()
    {
        var r = RStrings();
        var r1 = (T1)Convert.ChangeType(r[0], typeof(T1));
        var r2 = (T2)Convert.ChangeType(r[1], typeof(T2));
        var r3 = (T3)Convert.ChangeType(r[2], typeof(T3));
        return (r1, r2, r3);
    }
    public static (T1, T2, T3, T4) ReadStream<T1, T2, T3, T4>()
    {
        var r = RStrings();
        var r1 = (T1)Convert.ChangeType(r[0], typeof(T1));
        var r2 = (T2)Convert.ChangeType(r[1], typeof(T2));
        var r3 = (T3)Convert.ChangeType(r[0], typeof(T3));
        var r4 = (T4)Convert.ChangeType(r[0], typeof(T4));
        return (r1, r2, r3, r4);
    }
}

Measured memory_bytes: 27556