akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <vector>
#define MV 51
#define MX 101
#define MX2 202
#define MOD 1000000007

using namespace std;

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

template <typename T> void read(T& x)
{
	x = 0; char c = getchar();
	while(!isdigit(c)) c = getchar();
	while(isdigit(c)) x = x*10+c-'0', c = getchar();
}

int fst[MV], nxt[MX2], u[MX2], v[MX2], lnum;
ll fac[MX2], faci[MX2];

void addeg(int nu, int nv)
{
	nxt[++lnum] = fst[nu];
	fst[nu] = lnum;
	u[lnum] = nu;
	v[lnum] = nv;
}

int low[MV], dfn[MV], stk[MX], col[MV], top, scc, dfc;
vector<pii> con[MV];
int n, m, k;

void tarjan(int x, int f)
{
	dfn[x] = low[x] = ++dfc;
	for(int i=fst[x]; i; i=nxt[i])
	{
		int y = v[i];
		if(!dfn[y])
		{
			stk[++top] = i;
			tarjan(y, x);
			low[x] = min(low[x], low[y]);
			if(low[y] >= dfn[x])
			{
				scc++;
				while(1)
				{
					int now = stk[top--];
					con[scc].push_back(make_pair(u[now], v[now]));
					if(now == i) break;
				}
			}
		}
		else if(dfn[y]<dfn[x] && y!=f)
		{
			low[x] = min(low[x], dfn[y]);
			stk[++top] = i;
		}
	}
}

ll gcd(ll x, ll y)
{
	return (x==0) ? (y) : gcd(y%x, x);
}

ll qpow(ll x, ll t)
{
	ll ans = 1;
	while(t)
	{
		if(t & 1) ans = ans*x%MOD;
		x = x*x%MOD;
		t >>= 1;
	}
	return ans;
}

ll binom(int x)
{
	return fac[x+k-1] * faci[k-1] % MOD * faci[x] % MOD;
}

ll polya(int x)
{
	ll ret = 0;
	for(int i=0; i<x; i++)
		ret = (ret + qpow(k, gcd(i, x))) % MOD;
	return ret * qpow(x, MOD-2) % MOD;
}

void init()
{
	fac[0] = 1;
	for(int i=1; i<MX2; i++) fac[i] = fac[i-1] * i%MOD;
	faci[MX2-1] = qpow(fac[MX2-1], MOD-2);
	for(int i=MX2-1; i>=1; i--) faci[i-1] = faci[i] * i % MOD;
	lnum = 0;
}

void input()
{
	int a, b;
	read(n); read(m); read(k);
	for(int i=1; i<=m; i++)
	{
		read(a); read(b);
		addeg(a, b);
		addeg(b, a);
	}
}

int siz[MV], ecn[MV], vis[MV];

void work()
{
	for(int i=1; i<=n; i++)
		if(!dfn[i])
			tarjan(i, 0);
	for(int i=1; i<=scc; i++)
	{
		ecn[i] = con[i].size();
		for(auto it=con[i].begin(); it!=con[i].end(); it++)
		{
			if(!vis[it->first]) vis[it->first] = 1, siz[i]++;
			if(!vis[it->second]) vis[it->second] = 1, siz[i]++;
		}
		for(auto it=con[i].begin(); it!=con[i].end(); it++)
		{
			vis[it->first] = 0;
			vis[it->second] = 0;
		}
	}
	ll ans = 1;
	for(int i=1; i<=scc; i++)
	{
		if(siz[i] == ecn[i])
			ans = ans * polya(ecn[i]) % MOD;
		else if(siz[i]  < ecn[i])
			ans = ans * binom(ecn[i]) % MOD;
		else if(siz[i]==2 && ecn[i]==1)
			ans = ans * k % MOD;
	}
	printf("%lld\n", ans);
}

int main()
{
	init();
	input();
	work();
	return 0;
}

Measured memory_bytes: 256
"""
author : halo2halo
date : 30, Jan, 2020
"""

import sys
import itertools

# import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

A, B, C = map(int, readline().decode('utf8').split())

bl = False
for i in range(1, 110):
    if (C + B * i) % A == 0:
        bl = True

print('YES' if bl else 'NO')


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
const long long inf = 1e18;
typedef long long ll;
typedef vector<ll> vl;
#define rp(i, f, t) for (long long int i = f; i < t; i++)
#define pr(i, f, t) for (long long int i = t - 1; i >= f; i--)
#define ca(n, a) rp(ca_i, 0, n) cout << a[ca_i] << ((ca_i == n - 1) ? "\n" : " ")
#define za(n, a) rp(za_i, 0, n) a[za_i] = 0
#define be(a) a.begin(), a.end()
#define ce(a) cout << (a) << endl
int main()
{
    ll n;
    cin >> n;
    vl a(n);
    rp(i, 0, n) cin >> a[i];
    sort(be(a));

    cout << a[n - 1] << " ";
    // ca(n, a);
    ll aa = (a[n - 1] + 1) / 2;
    a[n - 1] = inf;
    ll t = lower_bound(be(a), aa) - a.begin();
    if (t > 0)
    {
        if (llabs(aa - a[t]) <= llabs(aa - a[t - 1]))
        {
            ce(a[t]);
        }
        else
        {
            ce(a[t - 1]);
        }
    }
    else
    {
        ce(a[t]);
    }
}

Measured memory_bytes: 1024
#include <algorithm>
#include <queue>
#define REP(i,n) for(int i=0; i<(int)(n); i++)

#include <cstdio>
inline int getInt(){ int s; scanf("%d", &s); return s; }

#include <set>

using namespace std;

int main(){
  const int n = getInt();
  vector<int> a(n); REP(i,n) a[i] = getInt();
  sort(a.begin(), a.end());

  set<int> s;

  int i = 0;
  int j = n - 1;

  int cnt = 0;
  while(i <= j) {
    if(i == j) {
      if(s.count(a[i])) cnt++;
      break;
    }

    const int p = a[i];
    const int q = a[j];

    if(!s.count(p)) {
      s.insert(p);
      i++;
    } else if(!s.count(q)) {
      s.insert(q);
      j--;
    } else {
      i++;
      j--;
      cnt++;
    }
  }

  printf("%d\n", n - 2 * cnt);
  return 0;
}


Measured memory_bytes: 5248
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;


int main() {
    int n;
    cin >> n;
    unordered_map<int, int> um;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        um[a]++;
        um[a - 1]++;
        um[a + 1]++;
    }
    int res = 0;
    for (auto p : um) {
        res = max(res, p.second);
    }
    cout << res << endl;
}




Measured memory_bytes: 6944
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <vector>
#pragma comment(linker,"/STACK:102400000,102400000")
#define INF 0x3f3f3f3f
#define maxm 1500
typedef long long ll;
using namespace std;
int mp[maxm][maxm]{0};
int dp[maxm][maxm]{0};
int minum(int x,int y,int z)
{
    return min(x,min(y,z));
}
int main()
{
    int h,w;
    cin>>h>>w;
    for(int i=1;i<=h;i++)
    {
        for(int j=1;j<=w;j++)
        {
            cin>>mp[i][j];
        }
    }
    int maxwid=0;
    for(int i=1;i<=h;i++)
    {
        if(!mp[i][1])
            dp[i][1]=1;
        maxwid=max(maxwid,dp[i][1]);
    }
    for(int i=1;i<=w;i++)
    {
        if(!mp[1][i])
            dp[1][i]=1;
        maxwid=max(maxwid,dp[1][i]);
    }
    for(int i=2;i<=h;i++)
    {
        for(int j=2;j<=w;j++)
        {
            if(mp[i][j])
                dp[i][j]=0;
            else
            {
                dp[i][j]=minum(dp[i-1][j-1],dp[i-1][j],dp[i][j-1])+1;
                maxwid=max(maxwid,dp[i][j]);
            }
        }
    }
    //cout<<maxwid<<endl;
    cout<<maxwid*maxwid<<endl;
    return 0;
}
//Do not use memset !



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

typedef struct{
	int n, cost;
}Data;

typedef struct{
	Data data;
	int prior;
}node;

typedef struct{
	node* nodes;
	int arr_sz;  //???????????????????????????
	int que_sz;  //?¬????????´?????????´????????????
}priority_queue;

node* my_realloc(node* old_ptr, int old_sz, int new_sz){
	node* new_ptr = (node*)malloc(sizeof(node) * new_sz);
	if(old_sz){
		memcpy(new_ptr, old_ptr, sizeof(node) * old_sz);
		free(old_ptr);
	}
	return new_ptr;
}

void push(priority_queue *q, Data d, int prior){
	if(q->que_sz >= q->arr_sz){
		int new_sz = (q->arr_sz ? q->arr_sz * 2 : 8);
		q->nodes = my_realloc(q->nodes, q->arr_sz, new_sz);
		q->arr_sz = new_sz;
	}
	
	int k = q->que_sz;
	
	while(true){
		if(k == 0)break;
		
		int next = (k - 1) / 2;
		if(q->nodes[next].prior > prior){
			q->nodes[k] = q->nodes[next];
			k = next;
		}
		else break;
	}
	
	q->nodes[k].data = d;
	q->nodes[k].prior = prior;
	
	++q->que_sz;
}

Data pop(priority_queue *q){
	Data ret = q->nodes[0].data;
	
	q->nodes[0] = q->nodes[--q->que_sz];
	
	int k = 0;
	while(true){
		int l = k * 2 + 1, r = k * 2 + 2;
		int next = -1;
		
		if(l < q->que_sz)next = l;
		if(r < q->que_sz)next = (q->nodes[r].prior < q->nodes[l].prior ? r : l);
		
		if(next == -1)break;
		
		if(q->nodes[next].prior < q->nodes[k].prior){
			q->nodes[k] = q->nodes[next];
			k = next;
		}
		else break;
	}
	
	q->nodes[k] = q->nodes[q->que_sz];
	
	return ret;
}

typedef struct{
	int to, cost;
}Edge;

#define maxN  100005
#define maxM  500001
#define inf 2000000000

int cost[maxN];
Edge *g[maxN];
int g_sz[maxN], cnt[maxN];
int n, m, r;
int s[maxM], t[maxM], d[maxM];

void dijkstra(int k){
	priority_queue que = {0};
	for (int i = 0; i < n; ++i)cost[i] = inf;
	cost[k] = 0;
	Data d;
	d.n = k, d.cost = 0;
	push(&que, d, d.cost);
	
	while (que.que_sz){
		d = pop(&que);
		
		int v = d.n;
		if (cost[v] < d.cost)continue;
		for (int i = 0; i < g_sz[v]; ++i){
			Edge e = g[v][i];
			if (cost[e.to] > cost[v] + e.cost){
				cost[e.to] = cost[v] + e.cost;
				
				Data x;
				x.n = e.to, x.cost = cost[e.to];
				push(&que, x, x.cost);
			}
		}
	}
}

int main(void){
	scanf("%d%d%d", &n, &m, &r);
	
	for(int i = 0; i < m; ++i){
		scanf("%d%d%d", &s[i], &t[i], &d[i]);
		
		++cnt[s[i]];
	}
	
	for(int i = 0; i < n; ++i){
		g[i] = (Edge*)malloc(sizeof(Edge) * cnt[i]);
	}
	
	for(int i = 0; i < m; ++i){
		Edge e;
		e.to = t[i], e.cost = d[i];
		g[s[i]][g_sz[s[i]]++] = e;
	}
	
	dijkstra(r);
	
	for(int i = 0; i < n; ++i){
		if(cost[i] == inf)printf("INF\n");
		else printf("%d\n", cost[i]);
	}
	
	return 0;
}

Measured memory_bytes: 15316
#include<bits/stdc++.h>
using namespace std;
#define cool ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
int main()
{ 
    cool;
    int p,q,r;
    cin>>p>>q>>r;
    int a[3];
    a[0]=p+q;
    a[1]=r+q;
    a[2]=p+r;
    sort(a,a+3);
    cout<<a[0];
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{

	public static void main(String args[]){
		Scanner scan = new Scanner(System.in);
		int K = scan.nextInt();
		int A = scan.nextInt();
		int B = scan.nextInt();
		String result = "NG";

		scan.close();
		do{
		if(A%K==0) {
			result="OK";
		}
			A++;
		}while(result.equals("NG")&&A<=B);
		System.out.println(result);
	}

}

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



int main(){
	int n,k;
	cin>>n>>k;
	vector<int> h(n);
	for(int i=0; i<n;i++){
		cin>>h[i];
	}
	vector<int> dp(n);
	dp[0]=0;
	for(int i=1;i<n;i++){
		int mincost=INT_MAX;
		for(int j=max(0,i-k);j<i;j++){
			mincost=min(mincost,dp[j]+abs(h[i]-h[j]));
		}
		dp[i]=mincost;
	}
	cout<<dp[n-1]<<endl;
}

Measured memory_bytes: 1024
N,K = map(int,input().split())
p = list(map(int,input().split()))
result = 0
p_t = [0]
for i in range(N):
    p_t.append(p[i]+p_t[i])
ans = p_t[K] - p_t[0]

for i in range(N-K):
    tmp = p_t[i+1+K] - p_t[i+1]
    if ans < tmp:
        ans = tmp
print((ans+K)/2)





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

using namespace std;

const int N = 100005;

long long d[N];
vector<pair<int, int>> g[N];

void dfs(int u, int f, long long w) {
  d[u] = w;
  for (auto &go : g[u]) {
    if (go.first != f) {
      dfs(go.first, u, w + go.second);
    }
  }
}

int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i < n; ++i) {
    int u, v, w;
    scanf("%d %d %d", &u, &v, &w);
    g[u].push_back({v, w});
    g[v].push_back({u, w});
  }
  int q, k;
  scanf("%d %d", &q, &k);
  dfs(k, k, 0);
  while (q--) {
    int u, v;
    scanf("%d %d", &u, &v);
    cout << d[u] + d[v] << endl;
  }
  return 0;
}


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

int main(){
	int a,b,k;
	cin >> a >> b >> k;
	if(b-k+1 <= a+k-1){
		for(int i=a; i<=b; i++)cout << i <<endl;
	}
	else{
		for(int i=a; i<=a+k-1; i++)cout << i <<endl;
		for(int i=b-k+1; i<=b; i++)cout << i <<endl;
	}
	return 0;
}

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

int64_t add(int64_t a, int64_t b){
  return a+b;
}

struct P {
  int64_t x, y;
  P() {}
  P(int64_t x, int64_t y): x(x), y(y) {}
  P operator + (P p) {
    return P(add(x,p.x), add(y,p.y));
  }
  P operator - (P p){
    return P(add(x,-p.x), add(y,-p.y));
  }
  int64_t det(P p){
    return add(x*p.y, -y*p.x);
  }
};

bool comp_x(const P& p, const P& q){
  if(p.x!=q.x) return p.x<q.x;
  return p.y<q.y;
}

vector<P> convex_hull(P* ps, int n){
  sort(ps,ps+n, comp_x);
  int k=0;
  vector<P> qs(n*2);
  for(int i=0; i<n; i++){
    while(k>1 && (qs[k-1]-qs[k-2]).det(ps[i]-qs[k-1])<=0) k--;
    qs[k++]=ps[i];
  }
  for(int i=n-2, t=k; i>=0; i--){
    while(k>t && (qs[k-1]-qs[k-2]).det(ps[i]-qs[k-1])<=0)k--;
    qs[k++]=ps[i];
  }
  qs.resize(k-1);
  return qs;
}
int64_t dist(P p, P q){
  return abs(p.x-q.x)+abs(p.y-q.y);
}

int N;
P ps[200002];

void solve(){
  vector<P> qs =convex_hull(ps,N);
  int64_t res=0;
  for(int i=0; i<qs.size(); i++){
    for(int j=0; j<i; j++){
      res=max(res,dist(qs[i],qs[j]));
    }
  }
  cout << res;
}

int main(){
  cin >> N;
  for(int i=0; i<N; i++){
    cin >> ps[i].x >> ps[i].y;
  }
  solve();
  return 0;
}

Measured memory_bytes: 6740
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Fri Aug  9 22:36:19 2019

@author: kohei
"""

N = input()

A = int(N.split()[0])
B = int(N.split()[1])

if A==B:
    print('IMPOSSIBLE')

else:
    if (A+B)%2==0:
        print(int((A+B)/2))
    
    else:
        print('IMPOSSIBLE')
    


Measured memory_bytes: 2940
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int m=sc.nextInt();
        int a[]=new int[m];
        long sum=0;
        for(int i=0;i<m;i++)
        {
            a[i]=sc.nextInt();
            sum+=a[i];
        }
        if(sum>n)
            System.out.println("-1");
        else
            System.out.println(n-sum);
    }
}


Measured memory_bytes: 46264
#include<stdio.h>
int main(){
  long long int ans=0,k,x,y,i,j,n,a[15][15];
  scanf("%lld\n",&n);
  for(i=0;i<10;i++){
    for(j=0;j<10;j++){
      a[i][j]=0;
    }
  }
  for(i=1;i<=n;i++){
    k=i;
    x=k%10;
    while(k>=10){
      k=k/10;
    }
    y=k;
    a[x][y]++;
  }
  for(i=0;i<10;i++){
    for(j=0;j<10;j++){
      ans=ans+a[i][j]*a[j][i];
    }
  }
  printf("%lld\n",ans);
  return 0;
}

Measured memory_bytes: 128
def resolve():
    N = int(input())
    A = list(map(int, input().split()))

    ans = 0
    max_height = A[0]
    for i in range(1, N):
        if max_height < A[i]:
            max_height = A[i]
        else:
            ans += max_height - A[i]
    print(ans)

if __name__ == "__main__":
    resolve()

Measured memory_bytes: 32160
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define shosu(n) setprecision(n)
using namespace std;
int main() {
  int a, b;
  double c, d, ans;
  cin >> a >> b;
  c = a;
  d = b;
  ans = c / d;
  cout << a / b << ' ' << a % b << ' ';
  printf("%.5lf\n", ans);
  return 0;
}

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

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

int main() {
  string S;
  cin >> S;
  while (S[0] != '0') {
    int d = 0;
    for (int i = 0; i < S.size(); i++) {
      d += (S[i] - '0');
    }
    cout << d << BR;
    cin >> S;
  }

  return 0;
}


Measured memory_bytes: 3196
#include<iostream>
#include<string>
#include<cstdlib>
int pop(int A[], int *top) {
  return A[--(*top)];
}
void push(int x, int S[], int *top) {
  S[(*top)++] = x;
}

int main() {
  std::string str1;
  std::getline(std::cin, str1);
  int top = 0, cnt = 0, n, tmp, S[100] = { 0 };
  char c;
  for (int i = 0; i < str1.size(); i++) {
    if(cnt!=0&&str1[i] != ' '){
      c = str1[i];
      n = c-'0';
      tmp=pop(S, &top)*10+n;
      push(tmp, S, &top);
      cnt++;
    }else{
      if (str1[i] != ' ') {
	c = str1[i];
	if (c == '+') {
	  tmp = pop(S, &top) + pop(S, &top);
	  push(tmp, S, &top);
	  cnt=0;
	}
	else if (c == '*') {
	  tmp = pop(S, &top) * pop(S, &top);
	  push(tmp, S, &top);
	  cnt=0;
	}
	else if (c == '-') {
	int a=pop(S, &top);
	int b=pop(S, &top);
	  tmp = b-a;
	  push(tmp, S, &top);
	  cnt=0;
	}
	else {
	  n = c-'0';
	  push(n, S, &top);
	  cnt++;
	}
      }else{
	cnt=0;
      }
    }
  }
  std::cout <<pop(S,&top)<< "\n";
  return 0;
}



Measured memory_bytes: 3148
#![allow(unused_imports)]

use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
use std::{cmp, fmt};
use std::io::{self, BufWriter, Read, StdinLock, Write};
use std::ops::{Add, Div, Mul, Sub};
use std::str::{self, FromStr};

fn main() {
    let stdin = io::stdin();
    let mut sc = Scanner::new(stdin.lock().bytes());
    let (n, m) = (sc.next::<u64>(), sc.next::<u64>());
    let r = if n == 1 && m == 1 {
        1
    } else if n == 1 {
        cmp::max(m, 2) - 2
    } else if m == 1 {
        cmp::max(n, 2) - 2
    } else {
        (cmp::max(n, 2) - 2) * (cmp::max(m, 2) - 2)
    };
    println!("{}", r);
}

struct Scanner<R: Read> {
    buf: Vec<u8>,
    bytes: io::Bytes<R>,
}

#[allow(dead_code)]
impl<R: Read> Scanner<R> {
    fn new(bytes: io::Bytes<R>) -> Self {
        Scanner {
            buf: Vec::with_capacity(1024),
            bytes: bytes,
        }
    }

    fn next<T: FromStr>(&mut self) -> T
    where
        <T as FromStr>::Err: fmt::Debug,
    {
        let buf = &mut self.buf;
        buf.clear();
        self.bytes
            .by_ref()
            .map(Result::unwrap)
            .skip_while(|&c| c == ' ' as u8 || c == '\n' as u8)
            .take_while(|&c| !(c == ' ' as u8 || c == '\n' as u8))
            .foreach(|c| buf.push(c));
        str::from_utf8(&buf).unwrap().parse().unwrap()
    }

    fn vec<T: FromStr>(&mut self, n: usize) -> Vec<T>
    where
        <T as FromStr>::Err: fmt::Debug,
    {
        (0..n).map(|_| self.next()).collect()
    }

    fn pairs<T1: FromStr, T2: FromStr>(&mut self, n: usize) -> Vec<(T1, T2)>
    where
        <T1 as FromStr>::Err: fmt::Debug,
        <T2 as FromStr>::Err: fmt::Debug,
    {
        (0..n).map(|_| (self.next(), self.next())).collect()
    }

    fn trios<T1: FromStr, T2: FromStr, T3: FromStr>(&mut self, n: usize) -> Vec<(T1, T2, T3)>
    where
        <T1 as FromStr>::Err: fmt::Debug,
        <T2 as FromStr>::Err: fmt::Debug,
        <T3 as FromStr>::Err: fmt::Debug,
    {
        (0..n)
            .map(|_| (self.next(), self.next(), self.next()))
            .collect()
    }

    fn mat<T: FromStr>(&mut self, m: usize, n: usize) -> Vec<Vec<T>>
    where
        <T as FromStr>::Err: fmt::Debug,
    {
        (0..m).map(|_| self.vec(n)).collect()
    }

    fn strings_as_mat<T, F: FnMut(u8) -> T>(&mut self, h: usize, mut f: F) -> Vec<Vec<T>> {
        (0..h)
            .map(|_| {
                self.bytes
                    .by_ref()
                    .map(Result::unwrap)
                    .skip_while(|&c| c == ' ' as u8 || c == '\n' as u8)
                    .take_while(|&c| !(c == ' ' as u8 || c == '\n' as u8))
                    .map(&mut f)
                    .collect()
            })
            .collect()
    }
}

trait Foreach {
    type Item;
    fn foreach<F: FnMut(Self::Item)>(self, f: F);
}

impl<T, I: Iterator<Item = T>> Foreach for I {
    type Item = T;

    fn foreach<F: FnMut(T)>(self, mut f: F) {
        self.fold((), move |(), x| f(x));
    }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define cout16 cout << setprecision(16) 
#define rep(i,n) for(int i=0;i<n;i++ )
#define rep2(i,f,n) for(int i=f;i<n;i++ )
#define MAX(A) *max_element(A.begin(),A.end())
#define MIN(A) *min_element(A.begin(),A.end())
#define SORT(A) sort(A.begin(),A.end())
#define REV(A) reverse(A.begin(),A.end())
typedef long long int ll;
using vi = std::vector<int>;
using vvi = std::vector<std::vector<int>>;
using vll = std::vector<ll>;
using vvll = std::vector<std::vector<ll>>;
using P = std::pair<int,int>;
using vp = std::vector<P>;
using namespace std;
#define INF 1001001001
#define LL_INF 1001001001001001001
#define fi first
#define se second

int main(void) {
	int n; cin >> n;
	vi a(n); rep(i,n) cin >> a[i];
	bool app=true;
	rep(i,n){
		if(a[i]%2==0){
			if( a[i]%3!=0 && a[i]%5!=0 ){
				app = false;
				break;
			}
		}
	}
	if(app) cout << "APPROVED" << endl;
	else cout << "DENIED" << endl;
}




Measured memory_bytes: 256
n = int(input())
num_list = list(map(int, input().split()))
dic = {}
ans_list = []
for i in num_list:
    dic[i] = 0
for i in num_list:
    dic[i] += 1
    if dic[i] == 2:
        ans_list.append(i)
    elif dic[i] == 4:
        ans_list.append(i)
re_ans_list = sorted(ans_list, reverse = True)
if len(re_ans_list) < 2:
    print(0)
else:
    print(re_ans_list[0]*re_ans_list[1])
    
    

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


Measured memory_bytes: 2044
#include <iostream>
#include <queue>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#include <iomanip>

using namespace std;

#define REP(i,n) for(ll (i) = (0); (i) < (n); ++i)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define ALL(v) v.begin(),v.end()
#define INF 1100000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007
#define Decimal fixed << setpresicion(20)
#define SHOWP(x) cerr<<"("<<(x).FI<<", "<<(x).SE<<")"<<endl;
#define SHOWX(x) cerr<<#x<<": "<<x<<endl;
#define SHOWVEC(v, e) REP(i, e) cerr << (v[i]) << ' '; cerr << endl;
#define SHOW2D(a, h, w) REP(i, h){REP(j, w)cerr<<setw(3)<<(a[i][j])<<' ';cerr<<endl;}

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


int main()
{
  ll N;
  cin >> N;
  vector<ll> h(N);
  REP(i, N) cin >> h[i];

  ll ans = 0;
  while (1) {
    ll mi = INF;
    REP(i, N) {
      if (h[i] > 0) mi = min(mi, h[i]);
    }

    ll cnt = 0;
    REP(i, N) {
      if ((i == 0 && h[i] > 0) || (h[i - 1] == 0 && h[i] > 0)) cnt++;
    }
    bool flag = true;
    REP(i, N) {
      if (h[i] > 0) {
        h[i] -= mi;
        if (h[i] > 0) flag = false;
      }
    }

    ans += mi * cnt;
    if (flag) break;
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
     
#define pll pair <long long,long long>
#define pb push_back
#define ll long long
#define ff first
#define ss second
#define vll vector <ll>
#define NFS ios_base::sync_with_stdio(0); cin.tie(NULL);
#define endl '\n'
#define M 1000000007   
using namespace std;
 
void solve()
{
	int n,f;
	cin>>n;
	f=n%10;
	if(f==2 || f==4 || f==5 || f==7 || f==9)
	{
		cout<<"hon";
	}else if(f==3)
	{
		cout<<"bon";
	}else{
		cout<<"pon";
	}
}
 
int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
    NFS
 	int t=1;
 	//cin>>t;
 	while(t--)
 	{
 		solve();
 	}
    return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> veci;
typedef vector<ll> vecll;
typedef vector<string> vecs;
template<class T,class U> using Hash=unordered_map<T,U>;

#define REP(i, a, n) for(ll i = a; i < (ll)n; i++)
#define RREP(i, a, n) for(ll i = n-1; i >= (ll)a; i--)
#define rep(i, n) REP(i, 0, n)
#define rrep(i, n) RREP(i, 0, n)
#define MD 1000000007

template<class T> T read(){T a;cin >> a;return a;}
template<class T> void read(T& a){cin >> a;}
template<class T, class ...Args> void read(T& a, Args&... args){cin >> a; read(args...);} 
template<class T> void rarr(T a, int n){for(int i = 0; i < n; i++) {cin >> a[i];}}
template<char c = ' ',class T> void write(T a){cout << fixed << setprecision(4) << a << endl;}
template<char c = ' ',class T,class ...Args> void write(T a, Args... args){cout << fixed << setprecision(4) << a << c; write<c>(args...);}
template<class T> void warr(vector<T> a, const char* c = " "){cout << a[0];for(int i = 1; i < (int)a.size(); i++)cout << c << a[i];cout << endl;;}
template<class T> void warr(T a, int n, const char* c = " "){cout << a[0];for(int i = 1; i < n; i++)cout << c << a[i];cout << endl;}
void split(string s, string delim, veci& result){result.clear();string::size_type pos = 0;while(pos != string::npos){string::size_type p = s.find(delim, pos);if(p == string::npos){result.push_back(atoi(s.substr(pos).data()));break;}else {result.push_back(atoi(s.substr(pos, p - pos).data()));}pos = p + delim.size();}}
void split(string s, string delim, vecs& result){result.clear();string::size_type pos = 0;while(pos != string::npos){string::size_type p = s.find(delim, pos);if(p == string::npos){result.push_back(s.substr(pos));break;}else {result.push_back(s.substr(pos, p - pos));}pos = p + delim.size();}}
ull gcd(ull a, ull b){while(true){ull k = a % b;if(k == 0)return b;a = b;b = k;}}
ull comb(ull n, ull m){ull p=1;m=min(m,n-m);for(ull i=1;i<=m;i++){p*=n-i+1;p/=i;}return p;}

int main(void)
{
    int n;
    while(true){
        unordered_map<int,int> m;
        read(n);
        if(n==0)break;
        pair<int,int> res(0,0);
        rep(i,n){
            int a;
            read(a);
            m[a]++;
            res=max(res,pair<int,int>(m[a],a));
        }
        if(res.first>n/2)write(res.second);
        else write("NO COLOR");
    }
    return 0;
}

Measured memory_bytes: 4384
#include <stdio.h>
#define MAX 100000

int A[MAX], n;

int partition(int p, int r) {
  int x, i, j, t;
  x = A[r];
  i = p-1;
  for(j=p; j<r; j++) {
    if(A[j] <= x) {
      i++;
      t=A[i]; A[i]=A[j]; A[j]=t;
    }
  }
  t=A[i+1]; A[i+1]=A[r]; A[r]=t;
  return i+1;
}

int main(void) {
  int i, q;

  scanf("%d", &n);
  for(i=0; i<n; i++) scanf("%d",&A[i]);
  q = partition(0,n-1);

  for(i=0; i<n; i++) {
    if(i) printf(" ");
    if(i==q) printf("[");
    printf("%d",A[i]);
    if(i==q) printf("]");
  }
  printf("\n");

  return 0;
}


Measured memory_bytes: 2060
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)

	s := make([]string, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&s[i])
	}

	ans := 0
	for a := 0; a < n; a++ {
		good := true
	Check:
		for i := 0; i < n; i++ {
			for j := 0; j < i; j++ {
				if s[(i+a)%n][j] != s[(j+a)%n][i] {
					good = false
					break Check
				}
			}
		}
		if good {
			ans++
		}
	}
	ans *= n

	fmt.Println(ans)
}


Measured memory_bytes: 640
#include <iostream>
#include <iomanip>
#include <queue>
#include <deque>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <bitset>

#define REP(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define FILL(x, y) memset(x, y, sizeof(x))
#define pb push_back
#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define eprintf(...) 42
#endif

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 (a > b) {
      a = b;
      return 1;
   }
   return 0;
}

using namespace std;
using ll = long long;

const int kInf = 2e9;
const ll kLInf = 2e18;

int gcd (int a, int b) {
   return b ? gcd(b, a % b) : a;
}
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int N;
string S;

int main()
{
   cout << fixed << setprecision(10);
   cin >> N >> S;
   int ans = 1;
   REP(i, N) {
      if (!i) continue;
      if (S[i] != S[i-1]) {
         ans++;
      }
   }
   cout << ans << endl;
   return 0;
}



Measured memory_bytes: 512
from datetime import date

day = (
       'Monday',
       'Tuesday',
       'Wednesday',
       'Thursday',
       'Friday',
       'Saturday',
       'Sunday',
       'Sunday',)
while 1:
    m, d = list(map(int, input().split()))
    if m == 0:
        break
    print(day[date(2004, m, d).weekday()])

Measured memory_bytes: 8056
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <array>
#include <vector>
#include <functional>
#include <unordered_map> 
#include <map> 
#include <numeric>
#include <limits>
#include <utility>
#include <queue>
#include <random>
#include <bitset>
#include <memory>
using namespace std;
typedef long long LL;

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

    cout << (a + b)*(h / 2) << endl;

    return 0;
}

Measured memory_bytes: 256
#define DREP(i, s, e) for(register int i = s; i >= e ;i--)
#define  REP(i, s, e) for(register int i = s; i <= e ;i++)

#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <bitset>
#include <vector>
#include <cmath>
#include <queue>
#include <map>

using namespace std;
const int maxn = 1000010;

template <typename T> T read() {
	T ans(0), p(1);
	char c = getchar();
	while (!isdigit(c)) {
		if (c == '-') p = -1;
		c = getchar();
	}
	while (isdigit(c)) {
		ans = ans * 10 + c - 48;
		c = getchar();
	}
	return ans * p;
}
int m, n;
inline void Fa() {cout << "-1 -1 -1";}

int main() {
#ifdef CraZYali
	freopen("c.in", "r", stdin);
	freopen("c.out", "w", stdout);
#endif
	n = read<int>();
	m = read<int>() / 1000;
	int x, y, z;
	z = m % 10;
	REP(i, 0, n)
		REP(j, 0, n - i)
			if (i + j <= n) {
				if (i * 10 + j * 5 + n - i - j == m) {
					printf("%d %d %d", i, j, n - i - j);
					return 0;
				}
			}
			else break;
	Fa();
	return 0;
}


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

int main() {
int a,b;
cin >> a >> b;
for(int n= 0;n<10000;n++){
	int za = n*8/100;
	int zb = n*10/100;
	if(a == za && b == zb){
		cout << n << endl;
		return 0;
	}
}
cout << -1 << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,s,e) for (int i=s;i<(e);i++)
#define All(v) (v).begin(),(v).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define int long long
using namespace std;
typedef long long llint;
typedef pair<int, int> P;
const int MOD = (int)1e9 + 7;
const int INF = (int)1e18 * 5;

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

    int x, y;
    cin >> x >> y;
    int ans = 0;
    if(abs(x) == abs(y)){
        ans = (x == y ? 0 : 1);
    }else if(x*y == 0){
        if(x < y) ans = y-x;
        else ans = x-y+1;
    }else if(x*y < 0){
        ans = abs(abs(x)-abs(y))+1;
    }else{ 
       if(x < y) ans = y-x;
       else ans = x-y+2;
    }
    
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
 
int main(void){
  	int n, r;
  	cin >> n;
  	r = n % 10;
	switch(r){
      case 0:
      case 1:
      case 6:
      case 8:
        cout << "pon";
        break;
      case 2:
      case 4:
      case 5:
      case 7:
      case 9:
        cout << "hon";
        break;
      case 3:
        cout << "bon";
        break;
    }
	return 0;
}

Measured memory_bytes: 3592
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<climits>

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

using namespace std;

int rc[1000 * 1000];
int w, h, q;
int mm;
bool sw;

int buff[2 * 1024 * 1024 + 10];

void gen(){
  const int n = w * h;
  int m = 1; while(m < n) m *= 2; mm = m;

  REP(i, m + m) buff[i] = INT_MAX;
  REP(i, n) buff[i + m - 1] = rc[i];

  while(m - 1 >= 0){
    m /= 2;
    /*
    for(int i = 1; i <= mm; i *= 2){
      for(int j = i - 1; j < i - 1 + i; j++){
     	printf("%d ", buff[j]);
      }
      puts("");
    }
    */

    for(int i = m - 1; i < m - 1 + m; i++){
      buff[i] = min(buff[i * 2 + 1], buff[i * 2 + 2]);
    }
  }
}

int iter(int l, int r, int pos, int width){
  //printf("iter: %d %d %d %d\n", l, r, pos, width);
  int w2 = width / 2;
  if(l + width == r) return buff[pos];
  if(w2 <= l) return iter(l - w2, r - w2, pos * 2 + 2, w2);
  if(w2 >= r) return iter(l, r, pos * 2 + 1, w2);
  return min(iter(l, w2, pos * 2 + 1, w2), iter(0, r - w2, pos * 2 + 2, w2));
}

int query(int l, int r){
  return iter(l, r, 0, mm);
}

int main(){
  while(scanf("%d%d%d", &h, &w, &q), w + h + q){
    sw = h > w;
    
    REP(i, h) REP(j, w){
      if(!sw){
	scanf("%d", rc + i * w + j);
      }else{
	scanf("%d", rc + j * h + i);
      }
    }

    if(sw) swap(h, w);

    gen();

    REP(qq, q){
      int h1, h2, w1, w2;
      int ans = INT_MAX;
      scanf("%d%d%d%d", &h1, &w1, &h2, &w2);

      if(sw){ swap(h1, w1); swap(h2, w2); }

      for(int hh = h1; hh < h2 + 1; hh++){
	int p1 = hh * w + w1;
	int p2 = hh * w + w2;

	//REP(i, h*w) printf("%d ", rc[i]); puts("");
	//printf("query(%d, %d) = %d\n", p1, p2 + 1, query(p1, p2 + 1));

	ans = min(ans, query(p1, p2 + 1));
      }

      cout << ans << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(unique(all(x)), x.end());
typedef long long ll;
typedef complex<double> Complex;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for (int i = 0; i < sz(v); i++) {
        os << v[i];
        if (i < sz(v) - 1) os << " ";
    }
    return os;
}
template <typename T>
vector<T> Dijkstra(int s, vector<vector<pair<int, T>>>& g) {
    priority_queue<pair<T, int>, vector<pair<T, int>>, greater<pair<T, int>>>
        que;
    int n = sz(g);
    vector<T> d(n);
    rep(i, n) d[i] = INF;
    d[s] = 0;
    que.push(make_pair(0LL, s));
    while (!que.empty()) {
        pair<T, int> p = que.top();
        que.pop();
        int v = p.second;
        if (d[v] < p.first) continue;
        for (auto e : g[v]) {
            if (chmin(d[e.first], d[v] + e.second)) {
                que.push(make_pair(d[e.first], e.first));
            }
        }
    }
    return d;
}
int main() {
    int h, w;
    cin >> h >> w;
    int n = h * w;
    auto id = [&](int i, int j) { return i * w + j; };
    int sy, sx, gy, gx;
    cin >> sy >> sx >> gy >> gx;
    sy--, sx--, gy--, gx--;
    vector<string> v(h);
    rep(i, h) cin >> v[i];
    using P = pair<int, int>;
    vector<vector<P>> g(n);
    rep(i, h) rep(j, w) {
        if (v[i][j] != '.') continue;
        for (int dy = -2; dy <= 2; dy++) {
            for (int dx = -2; dx <= 2; dx++) {
                int y = i + dy, x = j + dx;
                if (!(0 <= y && y < h && 0 <= x && x < w)) continue;
                if (v[y][x] != '.') continue;

                if (P(dy, dx) == P(1, 0) || P(dy, dx) == P(-1, 0) ||
                    P(dy, dx) == P(0, 1) || P(dy, dx) == P(0, -1))
                    g[id(i, j)].emplace_back(id(y, x), 0);
                else
                    g[id(i, j)].emplace_back(id(y, x), 1);
            }
        }
    }

    auto d = Dijkstra(id(sy, sx), g);
    cout << (d[id(gy, gx)] == INF ? -1 : d[id(gy, gx)]) << endl;
}

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

int main(){
    int H, W;
    cin >> H >> W;
    vector<string> a(H);
    rep(i,H){
        cin >> a[i];
    }

    vector<bool> rows(H);
    vector<bool> cols(W);

    rep(i,H){
        bool is_white = true;
        for(int j=0; j<W; j++){
            if(a[i][j] == '#'){
                is_white = false;
                break;
            }
        }
        rows[i] = is_white;
    }

    rep(i,W){
        bool is_white = true;
        for(int j=0; j<H; j++){
            if(a[j][i] == '#'){
                is_white = false;
                break;
            }
        }
        cols[i] = is_white;
    }

    rep(i,H){
        if(rows[i])continue;
        for(int j=0; j<W; j++){
            if(cols[j]){continue;}
            cout << a[i][j];
        }
        cout << "" << endl;
    }

    return 0;
}

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

Measured memory_bytes: 17352
N = int(input())
ansT = 1
ansA = 1
for i in range(N):
    T, A = map(int,input().split())
    if int(ansT / T) > int(ansA / A):
        ansT = T * int((ansT + T - 1) // T)
        ansA = A * int((ansT + T - 1) // T)
    else:
        ansT = T * int((ansA + A - 1) // A)
        ansA = A * int((ansA + A - 1) // A)

print(int(ansT + ansA))


Measured memory_bytes: 3060
#include <algorithm>
#include <climits>
#include <cmath>
#include <deque>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>

// author:Swastik Banerjee

using namespace std;

typedef long long ll;
#define MOD 1000000007

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



  string x;
  cin >> x;

  for (int i = 0; i < x.size(); i++) {
    x[i] = 'x';
  }

  cout << x << endl;
}

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

long long int dp[100005];

int main()
{


     ios_base::sync_with_stdio(false);
     cin.tie(NULL);
   

    int first,second;
    cin>>first>>second;
    vector<long long int>all(first+1,0);
    //vector<long long int>deg(first+1,0);
    for(int i=1;i<=first;i++)
    {
        long long int temp;
        cin>>temp;
      //  dp[i]=temp;
        all[i]=temp;
    }

    for(int i=0;i<second;i++)
    {
        int first1,second1;
        cin>>first1>>second1;

        //deg[first1]++;
        //deg[second1]++;

        if(all[first1]<=all[second1])
            dp[first1]=1;
        if(all[second1]<=all[first1])
            dp[second1]=1;
    }


    long long int ans=0;
    for(int i=1;i<=first;i++)
    {
      //  cout<<dp[i]<<" "<<deg[i]<<endl;
        if(dp[i]==0)
            ans++;
    }

    cout<<ans<<endl;
  
  return 0;

}

Measured memory_bytes: 4780
from collections import Counter


def read():
    N, K = list(map(int, input().strip().split()))
    return N, K


def n_gcd(k, N, K, cache, MOD=10**9+7):
    if cache[k] != -1:
        return cache[k]
    n = pow(K // k, N, MOD)
    for j in range(2*k, K+1, k):
        n -= n_gcd(j, N, K, cache)
        n %= MOD
    cache[k] = n
    return n


def solve(N, K, MOD=10**9+7):
    cache = [-1 for k in range(K+1)]
    ans = 0
    for k in range(K, 0, -1):
        ans += n_gcd(k, N, K, cache) * k
        ans %= MOD
    return ans

if __name__ == '__main__':
    inputs = read()
    print("{}".format(solve(*inputs)))


Measured memory_bytes: 11728
sx, sy, tx, ty = map(int, input().split())
diff_x = tx-sx
diff_y = ty-sy

ans = ''
ans += 'U'*abs(diff_y) if diff_x>0 else 'D'*abs(diff_y) # 1
ans += 'R'*abs(diff_x+1) if diff_x>0 else 'L'*abs(diff_x+1) # 2
ans += 'U'*(abs(diff_y)+1) if diff_x<0 else 'D'*(abs(diff_y)+1) # 3
ans += 'R'*abs(diff_x+1) if diff_x<0 else 'L'*abs(diff_x+1) # 4
ans += 'U' if diff_x>0 else 'D' # 1
ans += 'R' if diff_x<0 else 'L' # 2

ans += 'U'*abs(diff_y+1) if diff_x>0 else 'D'*abs(diff_y+1) # 1
ans += 'R'*abs(diff_x+1) if diff_x>0 else 'L'*abs(diff_x+1) # 2

ans += 'U'*(abs(diff_y)+1) if diff_x<0 else 'D'*(abs(diff_y)+1) # 3
ans += 'R'*abs(diff_x) if diff_x<0 else 'L'*abs(diff_x) # 2
print(ans)

Measured memory_bytes: 3064
//Template 1
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define pb push_back
#define Test ll T; cin>>T; while(T--)
#define vll vector<ll>
#define all(x) x.begin(),x.end()
#define allr(x) x.end(),x.begin()
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

int main()
 {  
    int n;
    cin>>n;
    char ar[n];
    for(int i=0;i<n;i++)
    {cin>>ar[i];}
    int i=0; 
    int j=n-1,ans=0;
    while(i<j)
    {
        if(ar[i]=='R')
        {i++;}
        if(ar[j]=='W')
        {j--;}
        if(ar[i]=='W' && ar[j]=='R')
        {ans++; i++; j--;}
        
    }
    cout<<ans;
    
}

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

int main(){
  int N;
  cin >> N;
  map<string, int> S;
  int max_num=0;
  for(int ii=0; ii<N; ii++){
    string s;
    cin >> s;
    S[s]++;
    max_num = max(max_num, S[s]);
  }
  for(auto& s : S){
    if(s.second == max_num){
      cout << s.first << endl;
    }
  }
  return 0;
}

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

int main(){
    stack<int> st;
    int n;
    while(cin>>n){
        if(n==0){
            cout << st.top() << endl;
            st.pop();
        }else{
            st.push(n);
        }
    }
    return 0;
}

Measured memory_bytes: 3080
fun main (args:Array<String>) {
    var (allBalls, bBall, rBall) = readLine()!!.split(" ").map(String::toLong)
    val brBall = bBall + rBall

//    if(brBall == allBalls){
//        print(bBall)
//        return
//    }
//    if(allBalls % brBall == 0L){
//        print(allBalls / brBall * bBall)
//    }
//    else{
        if(allBalls % brBall > bBall){
            print((allBalls / brBall * bBall) + bBall)
        }
        else {
            print((allBalls / brBall * bBall) + (allBalls % brBall))
        }
//    }

}

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

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define rep(i, n) repd(i, 0, n)

using namespace std;

using ll = long long;
using ul = unsigned long long;
using ld = long double;
ll mod = 1000000007;

int main() {
    ll h, w;
    cin >> h >> w;
    ll a[h][w], b[h][w], c[h][w];
    rep(i, h) {
        rep(j, w) { cin >> a[i][j]; }
    }
    rep(i, h) {
        rep(j, w) { cin >> b[i][j]; }
    }
    rep(i, h) {
        rep(j, w) { c[i][j] = abs(a[i][j] - b[i][j]); }
    }

    const ll bitset_size = 80 * 2 * 80 * 2;
    ll shift = bitset_size / 2;
    bitset<bitset_size> m[h][w];

    rep(i, w) {
        int num = c[0][i];
        if (i == 0) {
            m[0][i][shift + num] = true;
            m[0][i][shift - num] = true;
            continue;
        }
        m[0][i] |= m[0][i - 1] << num;
        m[0][i] |= m[0][i - 1] >> num;
    }

    repd(i, 1, h) {
        rep(j, w) {
            int num = c[i][j];
            if (j == 0) {
                m[i][j] |= m[i - 1][j] << num;
                m[i][j] |= m[i - 1][j] >> num;
                continue;
            }
            m[i][j] |= m[i][j - 1] << num;
            m[i][j] |= m[i][j - 1] >> num;

            m[i][j] |= m[i - 1][j] << num;
            m[i][j] |= m[i - 1][j] >> num;
        }
    }

    ll ans = bitset_size;

    rep(i, bitset_size) {
        ll num = abs(i - shift);
        if (m[h - 1][w - 1][i]) {
            ans = min(ans, num);
        }
    }

    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 23808
#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 REPR(i,a,n) for(int i=a;i>n;--i)
#define RUP(a,b) ((a+b-1)/(b))
#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/2

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<Pii> VPii;
typedef vector<string> Vs;

template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T> void YesNo(T a) {cout<<(a?"Yes":"No")<<endl;}
template<class T> void YESNO(T a) {cout<<(a?"YES":"NO")<<endl;}
void vin(Vi &v){REP(i,0,(v).size()) cin>>v[i];}
void vin(Vi &v,Vi &v2){REP(i,0,(v).size()) cin>>v[i]>>v2[i];}
void vout(Vi &v){for(int i=0;i<(v).size();i++) cout<<v[i]<<" ";cout<<endl;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a,b)*b;}
void uniq(Vi &v){sort(v.begin(),v.end()); v.erase(unique(v.begin(),v.end()),v.end());}
int ctoi(char c){if(c>='0'&&c<='9'){return c-'0';}return 0;}
void accum(Vi &v){REP(i,1,(v).size()) v[i]+=v[i-1];}
bool comp(Pii a,Pii b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}

signed main(){cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);
    int n,m;
    cin>>n>>m;
    Vi x(m),y(m);
    vin(x,y);
    REP(i,0,m){
        x[i]--;
        y[i]--;
    }
    
    Vi count(n,1),ans(n,0);
    ans[0]=1;
    REP(i,0,m){
        if(ans[x[i]]==1) ans[y[i]]=1;
        count[x[i]]--;
        count[y[i]]++;
        if(count[x[i]]==0) ans[x[i]]=0;
    }
    int ans2=0;
    REP(i,0,n){
        ans2 += ans[i];
    }
    cout<<ans2<<endl;
    return 0;
}


Measured memory_bytes: 3456
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Edge = int;
using Graph = vector<vector<Edge>>;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
const ll MOD = 1000000007;
const ll nmax = 8;
const ll INF = 1e9;
bool graph[nmax][nmax];
vector<vector<ll>> dist = vector<vector<ll>>(nmax, vector<ll>(nmax, INF));
void warshall_floyd(ll n)
{
    for (size_t i = 0; i < n; i++)
    {
        for (size_t j = 0; j < n; j++)
        {
            for (size_t k = 0; k < n; k++)
            {
                dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
            }
        }
    }
}

class UnionFind
{
public:
    vector<ll> Parent;

    UnionFind(ll N)
    {
        Parent = vector<ll>(N, -1);
    }
    ll find(ll A)
    {
        if (Parent[A] < 0)
            return A;
        return Parent[A] = find(Parent[A]);
    }

    ll size(ll A)
    {
        return -Parent[find(A)];
    }

    bool Union(ll A, ll B)
    {
        A = find(A);
        B = find(B);
        if (A == B)
        {
            return false;
        }
        if (size(A) < size(B))
            swap(A, B);

        Parent[A] += Parent[B];
        Parent[B] = A;

        return true;
    }
};

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

ll lcm(ll a, ll b)
{
    ll g = gcd(a, b);
    return a / g * b;
}

ll mulMod(ll a, ll b)
{
    return (((a % MOD) * (b % MOD)) % MOD);
}

ll powMod(ll a, ll p)
{
    if (p == 0)
    {
        return 1;
    }
    else if (p % 2 == 0)
    {
        ll half = powMod(a, p / 2);
        return mulMod(half, half);
    }
    else
    {
        return mulMod(powMod(a, p - 1), a);
    }
}

ll ceil(ll a, ll b)
{
    return (a + b - 1) / b;
}
vector<bool> seen;
vector<int> grp;

void dfs(const Graph &G, int v, int group)
{
    seen[v] = true;
    if (grp[v] == -1)
    {
        grp[v] = group;
    }
    for (auto next_v : G[v])
    {
        if (seen[next_v])
            continue;
        dfs(G, next_v, group);
    }
}

int main()
{
    long long N;
    scanf("%lld", &N);
    long long M;
    scanf("%lld", &M);
    std::vector<long long> p(N);
    for (int i = 0; i < N; i++)
    {
        scanf("%lld", &p[i]);
    }
    UnionFind uni(N);

    for (int i = 0; i < M; i++)
    {
        ll x, y;
        cin >> x >> y;
        x--;
        y--;
        uni.Union(x, y);
    }
    ll ans = 0;

    for (int i = 0; i < N; i++)
    {
        if (uni.find(i) == uni.find(p[i] - 1))
        {
            ans++;
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int main(){
	int a;
	int x=0;
	while(1){
		cin>>a;
		x=x+1;
		if(a>0){
			cout<<"Case "<<x<<": "<<a<<endl;
			}
			if(a==0){
				break;
				}
		}
}



Measured memory_bytes: 3000