akhauriyash/Code-Regression huggingface dataset:
import java.util.Collections;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {

	private static int n;

	public static void main(String[] args) {

		Main main = new Main();
		Set<Integer> set = new HashSet<>(5);
		int[][] arr = main.scan();
		int candies = 0;
		int f = 0;
		for (int i = 0; i < n; i++) {
			f += arr[0][i];
			for (int j = i; j < n; j++) {
				candies += arr[1][j];
			}
			set.add(f + candies);
			candies = 0;
		}
		System.out.println(Collections.max(set));
	}

	private int[][] scan() {

		Scanner sc = new Scanner(System.in);
		n = sc.nextInt();
		int[][] arr = new int[2][n];
		for (int i = 0; i < 2; i++) {
			for (int j = 0; j < n; j++) {
				arr[i][j] = sc.nextInt();
			}
		}
		sc.close();
		return arr;
	}
}

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

int main() {
  int n;
  cin >> n;
  vector<int> h(n);
  rep(i, n) cin >> h.at(i);
  int dp[n + 1] = {};
  dp[0] = 0;
  dp[1] = abs(h[1] - h[0]);
  REP(i, 2, n) {
    dp[i] =
        min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i] - h[i - 2]));
  }
  cout << dp[n - 1] << endl;
}

Measured memory_bytes: 1024
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		String s = sc.next();

		if(s.length() == 2) {

			System.out.println(s);

		}else {

			for(int i=2;i>=0;i--) {

				System.out.print(s.charAt(i));
			}
		}



	}

}


Measured memory_bytes: 23380
n = int(input())
a = [list(map(int, input().split())) for _ in range(2)]

ans = max(a[0][0]+sum(a[1]), sum(a[0])+a[1][-1])
for i in range(1,n-1):
    tmp = sum(a[0][:i+1])+sum(a[1][i:])
    ans = max(ans, tmp)
print(ans)


Measured memory_bytes: 3060
#include<iostream>
using namespace std;
#include<vector>
#include<functional>
#include<limits>
template<typename T>
struct segtree{
	function<T(T,T)>calcfn,updatefn;
	int n;
	T defvalue;
	vector<T>dat;
	segtree(int n_=0,T defvalue_=numeric_limits<T>::max(),
		function<T(T,T)>calcfn_=[](T a,T b){return a<b?a:b;},
		function<T(T,T)>updatefn_=[](T a,T b){return b;}
	):defvalue(defvalue_),calcfn(calcfn_),updatefn(updatefn_)
	{
		n=1;
		while(n<n_)n<<=1;
		dat.assign(2*n-1,defvalue);
	}
	void copy(const vector<T>&v)
	{
		for(int i=0;i<v.size();i++)dat[i+n-1]=v[i];
		for(int i=n-2;i>=0;i--)dat[i]=calcfn(dat[i*2+1],dat[i*2+2]);
	}
	void update(int i,T a)
	{
		i+=n-1;
		dat[i]=updatefn(dat[i],a);
		while(i>0)
		{
			i=(i-1)/2;
			dat[i]=calcfn(dat[2*i+1],dat[2*i+2]);
		}
	}
	T query(int a,int b)//[a,b)
	{
		int L=(a<0?0:a>n?n:a)+n-1;
		int R=(b<0?0:b>n?n:b)+n-1;
		T lret=defvalue,rret=defvalue;
		for(;L<R;L>>=1,R>>=1)
		{
			if(!(L&1))lret=calcfn(lret,dat[L]);
			if(!(R&1))rret=calcfn(dat[--R],rret);
		}
		return calcfn(lret,rret);
	}
};
int N,K;
int P[2<<17];
bool flag[2<<17];
main()
{
	cin>>N>>K;
	segtree<int>X(N,0,[](int a,int b){return a<b?b:a;});
	segtree<int>Y(N,1e9,[](int a,int b){return a>b?b:a;});
	for(int i=0;i<N;i++)
	{
		cin>>P[i];
		X.update(i,P[i]);
		Y.update(i,P[i]);
	}
	int ans=0;
	int p=0;
	int ret=0;
	for(int i=0;i<N;i++)
	{
		if(i>0&&P[i-1]>P[i])p=i;
		if(i-p+1>=K)
		{
			flag[i]=true;
			ret=1;
		}
		if(i>=K-1&&!flag[i])
		{
			if(i==K-1||flag[i-1]||!flag[i-1]&&(P[i-K]!=Y.query(i-K,i)||P[i]!=X.query(i-K+1,i+1)))
			{
				ans++;
			}
		}
	}
	//cout<<ans<<endl;
	//cout<<cnt<<endl;
	cout<<ans+ret<<endl;
}



Measured memory_bytes: 5376
#include <bits/stdc++.h>
using namespace std;
typedef tuple<int, int, int> tp;
typedef long long LL;
typedef long double LD;
typedef pair<int, int> pii;
typedef pair<int, LL> pil;
typedef pair<LL, int> pli;
typedef pair<LL, LL> pll;
typedef pair<pii, int> piipi;
typedef pair<int, pii> pipii;
typedef pair<pii, pii> piipii;
typedef pair<LL, pii> plpii;
typedef pair<LD, LD> pdd;
typedef pair<LD, int> pdi;
typedef pair<LD, LL> pdl;
typedef pair<int, LD> pid;
typedef pair<LL, LD> pld;
const int mod = 1e9 + 7;
const int hf = 999983;
const int N = 1e6;
int p[100005];
int root(int a){
    return p[a] == a?a:(p[a]=root(p[a]));
}
void merge(int a, int b){
    a = root(a), b = root(b);
    if(a != b) p[a] = b;
}
int main(){
    int n, m;
    scanf("%d%d", &n, &m);
    for(int i=1;i<=n;i++) p[i] = i;
    for(int i=1;i<=m;i++){
        int a, b, c;
        scanf("%d%d%d", &a, &b, &c);
        merge(a, b);
    }   
    int ans = 0;
    for(int i=1;i<=n;i++) if(i == root(i)) ans++;
    printf("%d\n", ans);
}


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

int main(){
        ll n, m;
        string s;
        cin >> n >> m >> s;
        reverse(s.begin(), s.end());

        vector<ll> ans(0);
        ll here = 0;
        while(here!=n){
                ll nx = here+m;
                if(here+m>n) nx=n;
                while(s[nx]=='1'){
                        nx--;
                        if(nx<=here){
                                puts("-1");
                                return 0;
                        }
                }
                ans.push_back(nx-here);
                here = nx;
        }

        for(ll i=ans.size()-1; i>=0; i--) printf("%lld\n", ans[i]);
        return 0;
}

Measured memory_bytes: 1528
#include<bits/stdc++.h>
using namespace std;
 
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long
#define rep(i,a,b)    for(ll i=a;i<b;i++)
#define repn(i,a,b)   for(ll i=a;i>=b;i--)
#define F first
#define S second
#define qi queue<ll>
#define pii pair<ll,ll>
#define vi vector<ll>
#define si set<ll>
#define vii vector<pii>
#define mi multiset<ll>
#define mii multiset<pii>
#define MI map<ll,ll>
#define pb push_back
#define mp  make_pair
#define all(v) (v).begin(), (v).end()
#define allr(v) (v).rbegin(), (v).rend()
#define mod 998244353
#define mod2 998244353

// size_t f= str.find(string s,0); find s in str from start
// if found then (f != string::npos)
// m.insert({x,y}); m[x]=y;

int fexp(int a, int b){int ans = 1;while(b){if(b&1) ans = ans*a%mod2; b/=2;a=a*a%mod2;}return ans;}
int inverse(int a, int p){return fexp(a, p-2);}

signed main(){
    IOS
	#ifndef ONLINE_JUDGE
    	freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif
	int a;
    cin >>a;
    if(a%10==2 ||a%10==4||a%10==5||a%10==7||a%10==9){
      cout <<"hon";
    }
  else if(a%10==0||a%10==1||a%10==6||a%10==8) cout <<"pon";
  else cout<<"bon";
    return 0;
}

Measured memory_bytes: 3588
macro_rules! get {
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
            get!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
            get!($($t),*)
        ).collect::<Vec<_>>()
    };
}

use std::cmp;

fn solve(mut i: i64, aa: Vec<i64>) -> i64 {
    let mut x = 0;
    let mut s = 0;
    for &a in aa.iter() {
        s += a;
        if (s < 0 && i > 0) || (s > 0 && i < 0) {
            x += -1*s*i + 1;
            s = i;
        } else if s == 0 {
            x += 1;
            s = i;
        }
        i = if i == -1 { 1 } else { -1 };
    }
    return x;
}

fn main() {
    let _n = get!(i64);
    let aa: Vec<i64> = get!(String).split_whitespace().map(|a| a.parse().unwrap()).collect();
    println!("{}", cmp::min(solve(1, aa.clone()), solve(-1, aa)));
}

Measured memory_bytes: 8444
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
typedef long long ll;
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
using namespace std;
const ll MAX_H=1e5,MAX_W=1e5,MAX_V=MAX_H+MAX_W+1,MAX_N=1e5;
ll N,H,W,R[MAX_N],C[MAX_N],A[MAX_N],par[MAX_V];
void init(ll n){
	REP(i,n)par[i]=i;
}
ll fndpar(ll v){
	if(par[v]==v)return v;
	return par[v]=fndpar(par[v]);
}
void unite(ll u,ll v){
	u=fndpar(u);
	v=fndpar(v);
	par[u]=v;
}
bool same(ll u,ll v){
	u=fndpar(u);
	v=fndpar(v);
	return u==v;
}
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>N>>H>>W;
	init(H+W+1);
	REP(i,N){
		cin>>R[i]>>C[i]>>A[i];
	}
	vector<ll> inx;
	REP(i,N)inx.push_back(i);
	sort(inx.begin(),inx.end(),[](ll a,ll b){
		return A[a]<A[b];
	});
	reverse(inx.begin(),inx.end());
	ll ans=0;
	for(auto i:inx){
		ll u=R[i]-1,v=C[i]+H-1;
		u=fndpar(u);
		v=fndpar(v);
		if(u!=v){
			ans+=A[i];
			unite(u,v);
		}else if(u!=fndpar(H+W)){
			ans+=A[i];
			unite(u,H+W);
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 5368
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <math.h>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <functional>
#include <assert.h>
#define int long
#define ll long long
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define SZ(x) x.size()
#define fi first
#define se second
const int INF = 1e9;
using namespace std;

template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;

using pi=pair<int,int>;
using vi=vc<int>;

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

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(20);

    int N,K,X,Y; cin >> N >> K >> X >> Y;
    if(K<N){
        cout << K*X+(N-K)*Y << endl;
    } else {
        cout << N*X << endl;
    }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int a = s.nextInt();
		int b = s.nextInt();
		int c = s.nextInt();
		String ans = "";

		if (a == b && b == c && c == a) {
			ans = "1";
		} else if (a == b && b != c) {
			ans = "2";
		} else if (a == c && c != b) {
			ans = "2";
		} else if (b == c && b != a) {
			ans = "2";
		} else if (a != b && b != c && c != a) {
			ans = "3";
		}
		System.out.println(ans);

	}

}

Measured memory_bytes: 23764
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.Deque;
 
public class Main {
 
    public static void main(String[] args) throws NumberFormatException,
            IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(
                System.in));
        StringBuilder builder = new StringBuilder();
        int n = Integer.parseInt(reader.readLine());
        Deque<Integer> deque = new ArrayDeque<Integer>();
        for (int i = 0; i < n; i++) {
            String line = reader.readLine();
            if(line.charAt(0) == 'i')
                deque.push(Integer.parseInt(line.substring(7)));
            else if(line.charAt(6)=='F')
                deque.removeFirst();
            else if(line.charAt(6)=='L')
                deque.removeLast();
            else
                deque.remove(Integer.parseInt(line.substring(7)));
            /*System.out.println(deque.stream().map(String::valueOf)
                    .collect(Collectors.joining(", ", "[", "]")));*/
        }
        builder.append(deque.poll());
        for(int num2 : deque)
            builder.append(" ").append(num2);
        System.out.println(builder);
    }
}



Measured memory_bytes: 125108
#include <stdio.h>
#include <stdlib.h>

int binarysearch(int);
int *A,*B,N,K;

int main()
{
  int i,j,count=0;

  scanf("%d",&N);
  A=(int *)malloc(sizeof(int)*N);
  for(i=0;i<N;i++) scanf("%d",&A[i]);

  scanf("%d",&K);
  B=(int *)malloc(sizeof(int)*K);
  for(i=0;i<K;i++) scanf("%d",&B[i]);

  for(i=0;i<K;i++) count=count+binarysearch(B[i]);


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


  return 0;
}

int binarysearch(int key)
{
  int left,right,mid;

  left=0;
  right=N;
  while(left<right)
    {
      mid=(left+right)/2;
      if(A[mid]==key) return 1;
      else if(key<A[mid]) right=mid;
      else left=mid+1;
    }
  return 0;
  
}



Measured memory_bytes: 2292
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {

	public static void main(String[] args) throws IOException {
		ContestScanner scan = new ContestScanner();

		(new Solve(scan.nextInt(), scan.nextInt(), scan.nextInt())).solve();
	}
}

class Solve {
	public final int a;
	public final int b;
	public final int c;

	public Solve(final int a, final int b, final int c)
	{
		this.a = a;
		this.b = b;
		this.c = c;
	}

	public void solve()
	{
		int[] counts = new int[11];

		Arrays.fill(counts, 0);

		counts[a]++;
		counts[b]++;
		counts[c]++;

		if(counts[5] == 2 && counts[7] == 1) System.out.println("YES");
		else System.out.println("NO");
	}
}

class ContestScanner {
	BufferedReader reader;
	String[] line;
	int index;
	public ContestScanner() {
		reader = new BufferedReader(new InputStreamReader(System.in));
	}

	public ContestScanner(String filename) throws FileNotFoundException {
		reader = new BufferedReader(new InputStreamReader(new FileInputStream(filename)));
	}

	public String nextToken() throws IOException {
		if(line == null || index >= line.length)
		{
			line = reader.readLine().trim().split(" ");
			index = 0;
		}

		return line[index++];
	}

	public String next() throws IOException {
		return nextToken();
	}

	public String readLine() throws IOException {
		line = null;
		index = 0;

		return reader.readLine();
	}

	public int nextInt() throws IOException, NumberFormatException {
		return Integer.parseInt(nextToken());
	}

	public long nextLong() throws IOException, NumberFormatException {
		return Long.parseLong(nextToken());
	}

	public double nextDouble() throws IOException, NumberFormatException {
		return Double.parseDouble(nextToken());
	}

	public int[] nextIntArray(int N) throws IOException, NumberFormatException {
		int[] result = new int[N];

		for(int i=0; i < N; i++) result[i] = nextInt();

		return result;
	}

	public long[] nextLongArray(int N) throws IOException, NumberFormatException {
		long[] result = new long[N];

		for(int i=0; i < N; i++) result[i] = nextLong();

		return result;
	}

	public double[] nexDoubleArray(int N) throws IOException, NumberFormatException {
		double[] result = new double[N];

		for(int i=0; i < N; i++) result[i] = nextDouble();

		return result;
	}
}


Measured memory_bytes: 8148
import sys
import time
import math
def inpl():
    return list(map(int, input().split()))
st = time.perf_counter()
# ------------------------------

A, B, K = map(int, input().split())
ans = []
for i in range(1, min(A, B)+1):
	if A%i == 0 and B%i == 0:
		ans.append(i)
print(ans[len(ans)-K])

# ------------------------------
ed = time.perf_counter()
print('time:', ed-st, file=sys.stderr)


Measured memory_bytes: 9056
n, k = [int(i) for i in input().split()]
As = [int(i) for i in input().split()]
def func(x):
    return sum(a^x for a in As)

bs = ['{:050b}'.format(a)[::-1] for a in As]
# print(bs)
strk = '{:b}'.format(k)

ans = ['0'] * len(strk)
# print(strk, ans)
for i in range(len(strk)):
    one = len([True for b in bs if b[len(strk) - 1 - i] == '1'])
    zero = len([True for b in bs if b[len(strk) - 1 - i] == '0'])
    # print(zero, one)

    tmp = ans[:]
    # if k < int('1' + ans, 2):

    # if one == zero:
    #     tmp[i] = '1'
    if zero >= one:
        tmp[i] = '1'
    # else:
    #     ans = ['0' + a for a in ans]
    # print(tmp, int(''.join(tmp), 2))
    if k >= int(''.join(tmp), 2):
        ans = tmp
    # print('ans', ans)

print(func(int(''.join(ans), 2)))

Measured memory_bytes: 134376
#include<iostream>
#include<string>
#include<math.h>
#include<algorithm>

using namespace std;

int main(){
    string s;
    cin >> s;
    int n = s.size();
    int d1 = 0;
    int d2 = 0;
    int flip = 0;
    for (int i = 0; i < n; i++)
    {
        int si = s[i] - '0';
        d1 += abs(si - (1 - flip));
        d2 += abs(si - flip);
        flip = (1 - flip);
    }
    cout << min(d1, d2) << endl;
    return 0;
}

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

using ll = long long;
 int cnt_digits(ll N){
    int digits=0; 
     
    while(N>0){
        N /= 10;
        digits++;
    } 
    return digits; 
 }

int main(void){
    ll N;
    cin >> N;
    
    int ans=cnt_digits(N);
    
    for(ll A=1LL;A*A<=N;A++){
        if(N%A !=0) continue;
        const ll B=N/A;
        
        const int cur =max(cnt_digits(A),cnt_digits(B));
        
        if(ans>cur){
            ans=cur;
        }
    }
    cout << ans << endl;
    return 0;
}
    
    
    


Measured memory_bytes: 256
from itertools import permutations
import sys

sys.setrecursionlimit(10 ** 6)
from bisect import *
from collections import *
from heapq import *

def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def SI(): return sys.stdin.readline()[:-1]
def LLI(rows_number): return [LI() for _ in range(rows_number)]
int1 = lambda x: int(x) - 1
def MI1(): return map(int1, sys.stdin.readline().split())
def LI1(): return list(map(int1, sys.stdin.readline().split()))
p2D = lambda x: print(*x, sep="\n")
dij = [(1, 0), (0, 1), (-1, 0), (0, -1)]

# grobalにmdを設定すること
class mint:
    def __init__(self, x):
        self.__x = x % md

    def __str__(self):
        return str(self.__x)

    def __neg__(self):
        return mint(-self.__x)

    def __add__(self, other):
        if isinstance(other, mint): other = other.__x
        return mint(self.__x + other)

    def __sub__(self, other):
        if isinstance(other, mint): other = other.__x
        return mint(self.__x - other)

    def __rsub__(self, other):
        return mint(other - self.__x)

    def __mul__(self, other):
        if isinstance(other, mint): other = other.__x
        return mint(self.__x * other)

    __radd__ = __add__
    __rmul__ = __mul__

    def __truediv__(self, other):
        if isinstance(other, mint): other = other.__x
        return mint(self.__x * pow(other, md - 2, md))

    def __rtruediv__(self, other):
        return mint(other * pow(self.__x, md - 2, md))

    def __pow__(self, power, modulo=None):
        return mint(pow(self.__x, power, md))

md = 10**9+7

def nCr(com_n, com_r):
    if com_n < com_r: return 0
    return fac[com_n] * ifac[com_r] * ifac[com_n - com_r]

n_max = 200005
fac = [mint(1)]
for i in range(1, n_max + 1): fac.append(fac[-1] * i)
ifac = [mint(1)] * (n_max + 1)
ifac[n_max] /= fac[n_max]
for i in range(n_max - 1, 1, -1): ifac[i] = ifac[i + 1] * (i + 1)

def main():
    h,w,a,b=MI()
    cc=[]
    for i in range(h-a):
        cc.append(nCr(b+i,i))
    #print(*cc)
    ans=mint(0)
    pc=0
    for i,c in enumerate(cc):
        ans+=(c-pc)*nCr(h-1-i+w-1-b,w-1-b)
        pc=c
    print(ans)

main()


Measured memory_bytes: 104256
def search(S,t):
    for s in S:
        if t == s:
            return True
    return False

n = int(raw_input())
S = map(int,raw_input().split(' '))
q = int(raw_input())
T = map(int,raw_input().split(' '))


ret = 0
for t in T:
    if search(S,t):
        ret += 1
print ret

Measured memory_bytes: 6936
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <numeric>
#include <tuple>
#include <stack>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define print(s) cout << s << endl
typedef long long ll;
using namespace std;
ll mod = pow(10,9) + 7;
int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}
char upper(char c){
	return c-0x20;
}
char lower(char c){
	return c+0x20;
}
int main() {
	string s; cin >> s;
	cout << s.substr(0,5) << ' ' << s.substr(6,7) << ' ' << s.substr(14,5) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
int main(){
    int a,b,k;
    cin >> a >> b >> k;
    for(int i=a;i<=b;i++){
        if(i<a+k) cout << i << endl;
        else if(i>b-k) cout << i << endl;
    }
}

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

int main()
{
	int n;
	cin >> n;
	vector<ll> a(n),b(n);
	for(int i = 0;i<n;i++)
	cin >> a[i];
	for(int i = 0;i<n;i++)
	cin >> b[i];
	ll c= 0,d =0;

	for(int i = 0;i<n;i++)
	{
		if(b[i]-a[i]<0)
		{
			d += abs(b[i]-a[i]);
		}
		else 
		{
			c += (b[i]-a[i])/2;
		}
	}
	//cout<<c<<' '<<d<<endl;
	if(c<d)cout<<"No"<<endl;
	else cout<<"Yes"<<endl;
}

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


int main(){
  int n,count=0;
  bool flag=false;
  while(true){
    cin >>n;
    if(n==0) break;

    count=2*n-n;
    for(int i=2*n;i>n;i--){ 
      for(int j=2;j<=sqrt(i);j++){
	if(i%j==0){
	  count--;
	  //cout <<"not "<<i<<endl;
	  break;
	}
      }
    }
    cout <<count<<endl;
  }
  return 0;
}

Measured memory_bytes: 868
#include <iostream>

int main(void) {
  int N, Y;
  int noguchi, higuchi, yukichi;
  std::cin >> N >> Y;
  //重複を許す組み合わせは，最大値がX，種類がYの場合
  //Y-1個のセパレーターがあると考えて
  //(X+Y-1)C(Y-1) で計算できる
  //つまり，　N=5の場合，しきりを|として
  // oo|oo|o
  //↑の|の位置を選ぶイメージ

  const int H = N + 2;
  for(int i = 0; i < H - 1; i++) {
    for(int j = i + 1; j < H; j++) {
      noguchi = i;
      higuchi = j - i - 1;
      yukichi = H - j - 1;

      if(noguchi * 1000 + higuchi * 5000 + yukichi * 10000 == Y) {
        goto end;
      }
    }
  }

  noguchi = higuchi = yukichi = -1;
 end:
     std::cout << yukichi << " " << higuchi << " " << noguchi << std::endl;
  return 0;
}


Measured memory_bytes: 256
using System;

public class Test
{
	public static void Main()
	{
		int a, b, c;
		string[] line = Console.ReadLine().Split(' ');
		a = int.Parse(line[0]);
		b = int.Parse(line[1]);
		c = int.Parse(line[2]);
		if(a+b>=c)
		{
			Console.WriteLine("Yes");
		}
		else
		{
			Console.WriteLine("No");
		}
	}
}

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

N = int(input())
ABlist = [tuple(map(int, input().split())) for _ in range(N)]
ans = 0
for a, b in reversed(ABlist):
    if (a + ans) % b == 0:
        continue
    else:
        ans += b - (a + ans) % b
print(ans)


Measured memory_bytes: 16624
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <queue>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
const int INF = 1<<29;

typedef pair<int, int> pii;

int dist(pii a, pii b) {
  int res = abs(a.second-b.second);
  int r = (res + 1) / 2;
  if (!(a.second % 2 ^ b.second % 2)) {
    if (b.first < a.first - r || a.first + r < b.first)
      res += min(abs(b.first - (a.first-r)), abs(b.first - (a.first+r)));
  } else if (a.second % 2) {
    if (b.first < a.first - r || a.first + r - 1 < b.first)
      res += min(abs(b.first - (a.first-r)), abs(b.first - (a.first+r-1)));    
  } else {
    if (b.first < a.first - r+1 || a.first + r < b.first)
      res += min(abs(b.first - (a.first-r+1)), abs(b.first - (a.first+r)));
  }
  return res;
}

int main() {
  int m, n;
  while(cin >> m, m) {
    cin >> n;
    int s;
    cin >> s;
    pii shop[s+1];
    REP(i,s) {
      int x, y;
      cin >> x >> y;
      shop[i] = pii(x,y);
    }
    int t;
    cin >> t;
    int ans = 0;
    REP(j,t) {
      int p, q;
      cin >> p >> q;
      shop[s] = pii(p,q);
      int res = 0;
      for(int y=1;y<=n; ++y) {
        for(int x=1;x<=m; ++x) {
          int mi = INF;
          int hoge = -1;
          REP(i, s+1) {
            if (mi > dist(pii(x,y), shop[i])) {
              mi = dist(pii(x,y), shop[i]);
              hoge = i;
            } else if (mi == dist(pii(x,y), shop[i])) {
              hoge = -1;
            }
          }
          //   cout << hoge << " ";
          if (hoge == s) res++;
        }
//        cout << endl;
      }
      //     cout << res << endl;
      ans = max(ans, res);
    }
    cout << ans << endl;
  }
}

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

int main() {
  int A,B,C,D;
  cin >> A >> B >> C >> D;

  if (A+B>C+D){
    cout <<"Left"<<endl;
  }
    else if(A+B==C+D){
    cout <<"Balanced" <<endl;
  }
    else{
    cout <<"Right" <<endl;
  }  
}

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

int main() {
  int n;
  string s,s1;
  cin >> n;
  cin >> s;
  int cnt = 0;
  for(int i = 0; i < (int)s.size() - 2; i++){
    s1 = s.substr(i, 3);
    if(s1 == "ABC"){
      cnt++;
    }
  }
  cout << cnt << "\n";
  return 0;
}

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

int main() {
  int N;

  std::cin >> N;

  std::vector<int> accW(N+1);

  for (int i=1; i<N+1; i++) {
    int w;
    std::cin >> w;
    accW[i] = accW[i-1]+w;
  }

  int ans = accW[N];

  for (int i=1; i<N+1; i++) {
    int l = accW[i];
    int r = accW[N]-accW[i];
    ans = std::min(ans, std::abs(l-r));
  }

  std::cout << ans << std::endl;

  return 0;
}


Measured memory_bytes: 256
N = int(input())
L = [-1] * (2 * 10 ** 5 + 1)
mod = 10 ** 9 + 7

dp = [0] * (N + 1)

dp[0] = 1

for i in range(N):
    dp[i+1] += dp[i]
    color = int(input())
    if L[color] != -1 and L[color] != i:
        dp[i+1] += dp[L[color]]
    L[color] = i+1
    dp[i+1] %= mod

print(dp[N])

Measured memory_bytes: 22108
N = int(input())
S = input()

cnt_l = 0
min_h = 0

for ch in S:
    if ch == '(':
        cnt_l += 1
    else:
        cnt_l -= 1
    min_h = min(min_h, cnt_l)
    
print('('*(-min_h) + S + ')'*(cnt_l-min_h))

Measured memory_bytes: 3060
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		int[] arr = new int[n];
		String[] tmp = br.readLine().split(" ");
		for(int i = 0;i < n;i++){
			arr[i] = Integer.parseInt(tmp[i]);
		}
		tmp = null;
		StringBuilder sb = new StringBuilder();
		for(int i = 0;i < n - 1;){
			sb.append(arr[n - ++i]);
			sb.append(" ");
		}
		sb.append(arr[0]);
		System.out.println(sb.toString());
		sb = null;
	}

}

Measured memory_bytes: 17064
s = list(input())
k = int(input())
for i in range(len(s)):
  dp = 26-ord(s[i])+97
  if k >= dp and s[i] != "a":
    k-=dp
    s[i] = "a"
    if k == 0:
      break
else:
  s[-1] = chr((ord(s[-1])-97+k)%26+97)
print(*s,sep="")

Measured memory_bytes: 11428
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define pb push_back
#define pi acos(-1.0)

bool composite[10000005];
vector < ll > v;

void sieve(ll N)
{
    composite[1] = 1;
    for(ll i = 2 ;  1LL * i * i <= N; i++)
    {
        if(composite[i] == 0)
        {
            for(int j = i * i ; j <= N; j = j+i)
            {
                composite[j] = 1;
            }
        }
    }
    for(ll i = 2; i <= N; i++){
        if(composite[i] == 0)
            v.pb(i);
    }
}


int main()
{
    sieve(10000000);
    ll i, j, a, b, k, n, m, cnt = 0;
    cin >> n;

    for(i = n; ; i++){
        if(composite[i] == 0)
        {
            cout << i << endl;
            return 0;
        }
    }

    return 0;
}


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

int main() {
	int k;
	cin >> k;
	int a = 0;
	if(k % 2 == 0){
		cout << (k / 2) * (k / 2) << endl;
	}else{
		cout << (k / 2) * (k / 2 + 1) << endl;
	}
	return 0;
}

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

int main(void){
	int p,x,ans;
	while(1){
		scanf("%d",&x);
		if(x==0)break;
		ans=0;
		for(x-=x%5;x>0;x-=5){
			p=x;
			while(p%5==0){ans++;p/=5;}
		}
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 600
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<unordered_map>
using namespace std;
//---------------------------------------------------
//ライブラリゾーン！！！！
#define int long long
#define str string
typedef long long ll;
typedef long double ld;
const ll inf = 999999999999999999;
struct P {
	ll pos, cost;
};
bool operator<(P a, P b) { return a.cost < b.cost; }
bool operator>(P a, P b) { return a.cost > b.cost; }
struct B {
	ll to, cost;
};
ll gcm(ll i, ll j) {//最大公約数
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcm(j%i, i);
}
//---------------------------------------------------
//+++++++++++++++++++++++++++++++++++++++++++++++++++
vector<B>e[100001];
int a[100001];
signed main() {
	int n, q, k;
	cin >> n;
	for (int i = 1; i < n; i++) {
		int u1, u2, u3;
		cin >> u1 >> u2 >> u3;
		e[u1].push_back(B{ u2,u3 });
		e[u2].push_back(B{ u1,u3 });
	}
	fill(a, a + n + 1, inf);
	cin >> q >> k;
	a[k] = 0;
	priority_queue<P, vector<P>, greater<P>>p;
	p.push(P{ k,0 });
	while (!p.empty()) {
		P t = p.top(); p.pop();
		for (int i = 0; i < e[t.pos].size(); i++) {
			if (a[e[t.pos][i].to] > a[t.pos] + e[t.pos][i].cost) {
				a[e[t.pos][i].to] = a[t.pos] + e[t.pos][i].cost;
				p.push(P{ e[t.pos][i].to,a[e[t.pos][i].to] });
			}
		}
	}
	for (int i = 0; i < q; i++) {
		int t, y;
		cin >> t >> y;
		cout << a[t] + a[y] << endl;
	}
	getchar(); getchar();
}

Measured memory_bytes: 11120
#include <bits/stdc++.h>
#define R real()
#define I imag()
using namespace std;
typedef complex <double> point;
struct S{
  double x,y,z,r;
  S(){x=y=z=r=0;}
  S(double x,double y,double z,double r):x(x),y(y),z(z),r(r){};
  S operator - (const S &a)const{return S(x-a.x,y-a.y,z-a.z,r);}
};
S s[2001],b[20],E;
vector <int> B[20];


double get_dis(S a){return sqrt(a.x*a.x+a.y*a.y+a.z*a.z);}

bool check(S s,S p){
  S res;
  point A=point(s.x,s.y),B=point(p.x,p.y);
  if(abs(A))B*=(conj(A)/abs(A));
  res.y=B.I;

  A=point(abs(A),s.z),B=point(B.R,p.z);
  if(abs(A))B*=(conj(A)/abs(A));
  res.x=B.R,res.z=B.I;
  
  double X=get_dis(s-S(0,0,0,0)),r=0;
  if(max(get_dis(res-S(0,0,0,0)),get_dis(res-S(X,0,0,0)))<=p.r) return 0;
  if(res.x<0) r=get_dis(res-S(0,0,0,0));
  else if(X<res.x) r=get_dis(res-S(X,0,0,0));
  else r=sqrt(res.z*res.z+res.y*res.y);
  return p.r>=r;
}

double cal(S a){return a.r/((a.x*a.x)+(a.y*a.y)+(a.z*a.z));}

int main(){
  int n,m,r;
  while(1){
    cin>>n>>m>>r;
    if(!n&&!m&&!r)break;

    for(int i=0;i<n;i++)cin>>s[i].x>>s[i].y>>s[i].z>>s[i].r;
    for(int i=0;i<m;i++)cin>>b[i].x>>b[i].y>>b[i].z>>b[i].r;
    cin>>E.x>>E.y>>E.z;
    for(int i=0;i<n;i++)s[i]=s[i]-E;
    for(int i=0;i<m;i++)b[i]=b[i]-E;

    for(int i=0;i<m;i++){
      B[i].clear();
      for(int j=0;j<n;j++)
	if(check(b[i],s[j]))B[i].push_back(j);
    }

    double ans=0;
    for(int i=0;i<(1<<m);i++){
      int used[2001]={},cnt=0;
      double sum=0;
      for(int j=0;j<m;j++){
	if(!((i>>j)&1))continue;
	for(int k=0;k<B[j].size();k++)cnt+=!used[B[j][k]],used[B[j][k]]=1;
	if(cnt>r)break;
	sum+=cal(b[j]);
      }
      ans=max(ans,sum);
    }
    cout <<ans<<endl;
  }
  return 0;
}

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

int main() {
  
  int N;
  cin >> N;
  
  if (N/10 == 9 || N%10 == 9) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
  
return 0;
}

Measured memory_bytes: 3568
#include <bits/stdc++.h>
using namespace std;
vector<vector<int> > c;
vector<vector<bool> > done;
int w,h;
int dy[] = {-1,-1,-1,0,0,1,1,1};
int dx[] = {1,0,-1,1,-1,1,0,-1};

void dfs(int y, int x)
{
		done[y][x] = true;
		for(int i=0;i<8;i++)
		{
				int ny = y + dy[i];
				int nx = x + dx[i];
				if(0<=ny && ny<h && 0<=nx && nx<w && c[ny][nx]==1 && !done[ny][nx])
				{
						dfs(ny,nx);
				}
		}
}

signed
main()
{
	while(cin >> w >> h and !(w==0 & h==0))
	{
			c = vector<vector<int> >(h,vector<int>(w));
			done = vector<vector<bool> >(h,vector<bool>(w, false));
			for(int y=0;y<h;y++)
					for(int x=0;x<w;x++)
							cin >> c[y][x];

			int cnt = 0;
			for(int y=0;y<h;y++)
			{
					for(int x=0;x<w;x++)
					{
							if(c[y][x] && !done[y][x]){
									cnt++;
									dfs(y,x);
							}
					}
			}
			cout << cnt << endl;
	}
}


Measured memory_bytes: 3184
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<algorithm>
#include<functional>
#include<utility>
#include<bitset>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<cstdio>
#include<bits/stdc++.h>
using namespace std;
long long n,k;
vector<long long>ds[101010],fr;
int main()
{
	cin>>n>>k;
	for(long long i=0;i<n;i++)
	{
		int t,d;
		cin>>t>>d;
		ds[t-1].push_back(d);
	}
	for(long long i=0;i<n;i++)
	{
		if(!ds[i].empty())
		{
			sort(ds[i].begin(),ds[i].end());
			fr.push_back(ds[i].back());
			ds[i].pop_back();
			reverse(ds[i].begin(),ds[i].end());
		}
	}
	sort(fr.begin(),fr.end(),greater<long long>());
	long long tp=min((long long)fr.size(),k),now=accumulate(fr.begin(),fr.begin()+tp,0l),ans=0;
	priority_queue<long long>ss;
	for(long long i=0;i<n;i++)
	{
		for(int j=0;j<ds[i].size();j++)
		{
			ss.push(ds[i][j]);
		}
	}
	for(long long i=0;i<k-tp;i++)
	{
		now+=ss.top();
		ss.pop();
	}
	ans=now+tp*tp;
	for(long long i=tp-1;i>=1;i--)
	{
		ss.push(fr[i]);
		now+=ss.top()-fr[i];
		ss.pop();
		ans=max(ans,now+i*i);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 6904
#include<stdio.h>
 
int main(){
	int A,B,C,N;
	int count = 0;
  	int i,j;
	scanf("%d %d %d %d",&A,&B,&C,&N);
	
  	for(i=0;i<((int)(N/A)+1);i++){
      if((N-i*A)<0) continue;
    	for(j=0;j<((int)(N/B)+1);j++){
          	if((N-i*A-j*B)<0) continue;
    		if(0==((N-i*A-j*B)%C)) count = count+1;
        }
    }
    printf("%d\n",count);
	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
int n;
int main()
{
	int a[10],r;
	while(~scanf("%d",&r)){
	if(!r){
	n--;
	printf("%d\n",a[n]);
	}
	else {
	a[n]=r;
	n++;
	}
	}
	return 0;
}

Measured memory_bytes: 600
/**                                                     **\
 *    created by:   Divianshu Bansal                     *
 *    e-mail id:    god_coder@icloud.com                 *
*                                                        */

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


using namespace std;
using namespace __gnu_pbds;


typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>new_data_set;
#define MOD 1000000007
#define int long long
#define BIG 998244353
#define pf push_front
#define print(x) for(auto el: x) cout<<el<<" ";cout<<endl
#define bits(x) __builtin_popcount(x)
#define ff first
#define se second
#define pb push_back
#define pii pair<int,int>
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define PSET(x,y) fixed<<setprecision(y)<<x
#define mp make_pair
#define pi 3.141592653589


int power(int x,int y){
    int r=1,z=x;
    while(y){
        if(y & 1)r*=z;
        z*=z;y=y>>1;}
    return r;}
int powerm(int x,int y,int p){
    int r=1;
    while(y){
        if(y & 1)r=(r*x)%p;
        y=y>>1;
        x=(x*x)%p;}
    return r%p;}
int modinv(int x,int m){
    return powerm(x,m-2,m);}
int logarithm(int a,int b){
    int x=0;
    while(a>1){
        x++;
        a/=b;}
    return x;}
int max3(int a,int b,int c){
    return max(a,max(b,c));
}
int min3(int a,int b,int c){
    return min(a,min(b,c));
}
int32_t main(){
    fast;
    int n;  cin>>n;
    vector<int> v(n-1);
    for(int i=0;i<n-1;++i){
        cin>>v[i];
    }
    int tot=0;
    tot+=v[0];
    tot+=v[n-2];
    for(int i=0;i<n-2;++i){
        tot+=min(v[i],v[i+1]);
    }
    cout<<tot;
    return 0;
}

Measured memory_bytes: 256
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <cstdio>
#include <string>
#include <vector>
#include <random>
#include <chrono>
#include <utility>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <sstream>
#include <assert.h>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <unordered_map>
using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(bool x) {cerr << (x ? "true" : "false");}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}

template<typename T, typename V> void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i : x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";} void _print() {cerr << "]\n";}
template <typename T, typename... V>void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifdef HOME
#warning CHECK int:ll::INT_MAX:LLONG_MAX
#define maxn 20
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define maxn 2000006
#define gcd __gcd
#define debug(x...)
#endif

#define ff first
#define endl '\n'
#define ss second
#define inf 0x3f3f3f3f
#define MOD 1000000007
#define PI 3.14159265358979323846264338327950L
#define f(i,x,n) for(int i=x;i<=n;i++)
#define fr(i,x,n) for(int i=x;i>=n;i--)
struct _ { ios_base::Init i; _() { ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL); } } _;

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


int main() {

	int n, k; cin >> n >> k;
	string s; cin >> s;
	if (s[k - 1] >= 'A' and s[k - 1] <= 'Z') s[k - 1] = s[k - 1] - 'A' + 'a';
	cout << s;


	return 0;
}

Measured memory_bytes: 3156
#!/usr/bin/env python3
import sys

YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(H: int, N: int, A: "List[int]"):
    if sum(A) >= H:
        print(YES)
    else:
        print(NO)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    H = int(next(tokens))  # type: int
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(H, N, A)

if __name__ == '__main__':
    main()


Measured memory_bytes: 14068
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>
#define ll long long

using namespace std;

long long MOD = 1000000007;

int main(){
    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;
    string ans="";
    for(int i=0; i<ty-sy; i++){
        ans+="U";
    }
    for(int i=0; i<tx-sx; i++){
        ans+="R";
    }
    for(int i=0; i<ty-sy; i++){
        ans+="D";
    }
    for(int i=0; i<tx-sx; i++){
        ans+="L";
    }
    ans+="D";
    for(int i=0; i<tx-sx+1;i++){
        ans+="R";
    }
    for(int i=0; i<ty-sy+1; i++){
        ans+="U";
    }
    ans+="L";
    ans+="U";
    for(int i=0; i<tx-sx+1; i++){
        ans+="L";
    }
    for(int i=0; i<ty-sy+1; i++){
        ans+="D";
    }
    ans+="R";
    cout << ans << endl;
}

Measured memory_bytes: 3620
import Data.List

solution n l x y z ans
  | x >= n = ans
  | y >= n = solution n l (x+1) (x+2) (x+2) ans
  | z >= n = solution n l x (y+1) (y+1) ans
  | (l!!y) + (l!!z) > (l!!x) && (l!!y /= l!!z) && (l!!y /= l!!x) && (l!!z /= l!!x) =
    solution n l x y (z+1) (ans+1)
  | otherwise =
    solution n l x y (z+1) ans

main = do
  li <- getLine
  let n = read li
  li <- getLine
  let l = reverse $ sort $ map read $ words li
  print $ solution n l 0 1 1 0



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

#define ll long long
#define ul 1000000
// #define ul 10
#define fo(i,a,b) for(int i=a;i<b;++i)
#define mod 1000000007

// bool arr[ul+5];
// vector<int> p;
// int phi[ul+5];
// // ll xxx;
// void sieve()
// {
// 	for(int i=0;i<=ul;i++) arr[i] = true;
// 	// xxx =1;
// 	for(int i=2;i*i<=ul;i++)
// 	{
// 		if(arr[i]) for(int j=i*i;j<=ul;j+=i) arr[j] =false;
// 	}
// 	for(int i=2;i<=ul;i++) if(arr[i]) p.push_back(i);
// 	for(int i=1;i<=ul;i++) phi[i]=i;
// 	for(int i=2;i<=ul;i++)
// 	{
// 		if(phi[i]==i) for(int j=i;j<=ul;j+=i) phi[j] = phi[j]-phi[j]/i;
// 		// xxx += phi[i];
// 	}
// }



int main()
{
	ll x,y;
	cin>>x>>y;
	if(x%y==0) cout<<"-1\n";
	else cout<<x<<'\n';
}

Measured memory_bytes: 256
import java.util.*

object MainKt {
    @JvmStatic
    fun main(args: Array<String>) {
        val scanner = Scanner(System.`in`)
        val n = scanner.nextInt()

        when(n){
            1 -> println("Hello World")
            2 -> {
                val a = scanner.nextInt()
                val b = scanner.nextInt()
                println(a+b)
            }
        }

    }
}

Measured memory_bytes: 31256
#include <iostream>
#include <stdio.h>
#include <cstdio>
#include <algorithm>

using namespace std;

int main(){
  int r1,r2;
  while(cin>>r1>>r2){
    double r3 = r1*r2*1.0/(r1+r2);
    printf("%.7f\n",r3);
    //cout<<r3<<endl;
  }
  return 0;
}

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

int ng() {
    cout << "No\n";
    return 0;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n, x; cin >> n >> x;
    if (x == 1 || x == 2*n-1) return ng();
    deque<int> d(2*n-1);
    for (int i = 0; i < 2*n-1; i++) d[i] = i+1;
    x -= n;
    while (x > 0) {
        x--; d.emplace_back(d.front()); d.pop_front();
    }
    while (x < 0) {
        x++; d.emplace_front(d.back()); d.pop_back();
    }
    cout << "Yes\n";
    for (auto &c: d) cout << c << "\n";
    return 0;
}

Measured memory_bytes: 2304
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
long long mo = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }

int main(){
    ll H,W,D;
    cin >> H >> W >> D;
    vector<vector<ll>> A(H,vector<ll>(W));
    map<ll, Pll> mp;
    rep(i,H)rep(j,W){
        cin >> A[i][j];
        mp[A[i][j]] = Pll(i,j);
    }
    ll Q;
    cin >> Q;
    vector<ll> L(Q),R(Q),S(H*W+2);
    for(ll i=D;i<=H*W;i++){
        S[i+1] = S[i+1-D] +  abs(mp[i+1].first - mp[i+1-D].first) + abs(mp[i+1].second - mp[i+1-D].second);
    }
    rep(i,Q) cin >> L[i] >> R[i];
    rep(i,Q){
        cout << S[R[i]] - S[L[i]] << endl;
    }
}


Measured memory_bytes: 9728
#include<iostream>
#include<cstdio>
#include<queue>
#include<vector>
#include<string.h>
#include<algorithm>
#include <cmath>

using namespace std;

int i,j,k,N;

int main()
{
  cin>>N;
  
  if(N%2==0)
  {
    cout <<N/2;
  }
  else
  {
    cout <<N/2+1;
  }
  
}

Measured memory_bytes: 256
using System;

class Problem
{
  public static void Main(string[] args)
  {
    var n = int.Parse(Console.ReadLine());
    var max = 0;
    for (var i = 1; i * i <= n; i++)
    {
      max = i * i;
    }
    Console.WriteLine($"{max}");
  }
}


Measured memory_bytes: 13140
using System;
using System.Collections.Generic;
using System.Linq;
using static Scanner;

class Program
{
    static void Main() => new Program().Solve();

    public void Solve()
    {
        string s = Read();
        var a = new List<int>();
        a.Add(0);
        foreach (var c in s) if (c == 'R') a[^1]++; else a.Add(0);
        Console.WriteLine(a.Max());
    }
}

static class Scanner
{
    static Queue<string> que = new Queue<string>();
    public static string Read() { if (!que.Any()) foreach (var s in Console.ReadLine().Split()) que.Enqueue(s); return que.Dequeue(); }
    public static int ReadInt() => int.Parse(Read());
    public static long ReadLong() => long.Parse(Read());
    public static double ReadDouble() => double.Parse(Read());
    public static decimal ReadDecimal() => decimal.Parse(Read());
    public static IEnumerable<string> Read(long n) { for (long i = 0; i < n; i++) yield return Read(); }
    public static IEnumerable<int> ReadInt(long n) => Read(n).Select(int.Parse);
    public static IEnumerable<long> ReadLong(long n) => Read(n).Select(long.Parse);
    public static IEnumerable<double> ReadDouble(long n) => Read(n).Select(double.Parse);
    public static IEnumerable<decimal> ReadDecimal(long n) => Read(n).Select(decimal.Parse);
}


Measured memory_bytes: 26632
import random as rng
import itertools as it
import collections as col
import heapq as hq
import sys
import copy as cp
sys.setrecursionlimit(10**9)


def dump_impl(*objects):
    print(*objects, file=sys.stderr)


def dump_dummy(*objects):
    pass


dump = dump_impl if "DEBUG" in sys.argv else dump_dummy

N = int(input())

ans = 0
for n in range(3, 10):
    for l in it.product(["7", "5", "3"], repeat=n):
        if "7" not in l or "5" not in l or "3" not in l:
            continue
        M = int("".join(l))
        if M <= N:
            dump(M, ans)
            ans += 1
dump(N)
print(ans)


Measured memory_bytes: 9864
double n,p[333][333][333];
c[4];
double f(i,j,k)
{
	if(i|j|k&&p[i][j][k]==0)
	{
		p[i][j][k]=(
			(i?i/n*(f(i-1,j,k)+n/(i+j+k)):0)+
			(j?j/n*(f(i+1,j-1,k)+n/(i+j+k)):0)+
			(k?k/n*(f(i,j+1,k-1)+n/(i+j+k)):0)
		)*n/(i+j+k);
	}
	return p[i][j][k];
}
main(a)
{
	for(scanf("%lf",&n);~scanf("%d",&a);)c[a]++;
	printf("%.9f",f(c[1],c[2],c[3]));
}

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

using namespace std;
#define REP(i, n) for (ll i = 0; i < n; ++i)
using ll = long long;

struct Edge {
	int to, cap, rev, cost;
};
using Edges = vector<Edge>;
using Graph = vector<Edges>;

struct maxflow {
	Graph g;
	vector<int> level, iter;
	maxflow(int n) {
		level.resize(n);
		iter.resize(n);
		g.resize(n);
	}

	void add_edge(int from, int to, int cap, int cost = 0) {
		g[from].push_back(Edge{to, cap, (int)g[to].size(), cost});
		g[to].push_back(Edge{from, 0, (int)g[from].size() - 1, -cost});
	}

	void bfs(int s) {
		fill(level.begin(), level.end(), -1);
		queue<int> q;
		level[s] = 0;
		q.push(s);
		while (!q.empty()) {
			int v = q.front();
			q.pop();
			for (auto &&e : g[v]) {
				if (e.cap > 0 && level[e.to] < 0) {
					level[e.to] = level[v] + 1;
					q.push(e.to);
				}
			}
		}
	}
	int dfs(int v, int t, int f) {
		if (v == t) return f;
		for (int &i = iter[v]; i < g[v].size(); i++) {
			Edge &e = g[v][i];
			if (e.cap > 0 && level[v] < level[e.to]) {
				int d = dfs(e.to, t, min(f, e.cap));
				if (d > 0) {
					e.cap -= d;
					g[e.to][e.rev].cap += d;
					return d;
				}
			}
		}
		return 0;
	}
	int max_flow(int s, int t) {
		int flow = 0;
		while (true) {
			bfs(s);
			if (level[t] < 0) return flow;
			fill(iter.begin(), iter.end(), 0);
			int f;
			while ((f = dfs(s, t, 1e9)) > 0) {
				flow += f;
			}
		}
	}
};

int main() {

	int n, m;
	cin >> n >> m;
	vector<vector<int>> cnt(n);
	REP(i, m) {
		int k;
		cin >> k;
		REP(j, k) {
			int a;
			cin >> a;
			cnt[a - 1].push_back(i);
		}
	}
	int ans = 0;
	set<int> used;
	REP(i, n) {
		if (cnt[i].size() == 0)
			ans++;
		else if (cnt[i].size() == 1) {
			if (!used.count(cnt[i][0])) {
				ans++;
				used.insert(cnt[i][0]);
			}
		}
	}
	maxflow mf(2 * m + 2);
	REP(i, n) {
		if (cnt[i].size() == 2) {
			int a = cnt[i][0], b = cnt[i][1];
			if (used.count(a) == 0 && used.count(b) == 0) {
				mf.add_edge(a + 1, b + m + 1, 1);
				mf.add_edge(b + 1, a + m + 1, 1);
			}
		}
	}
	REP(i, m) {
		mf.add_edge(0, i + 1, 1);
		mf.add_edge(i + 1 + m, 2 * m + 1, 1);
	}
	cout << ans + mf.max_flow(0, 2 * m + 1) / 2 << endl;
}


Measured memory_bytes: 17140