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

int main() {
    // Write Your Code Below
    int r, g, b, n;cin >> r >> g >> b >> n;
    int ans = 0;
    for(int i=0;i<n/r+1;i++){
        for(int j=0;j<n/g+1;j++){
            int rest = n-r*i-g*j;
            if(rest>=0&&rest%b==0){
                ans++;
            }
        }
    }
    cout << ans << endl;
}

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

using namespace std;

typedef long long i64;
typedef i64 int_t;
typedef vector<int_t> vi;
typedef vector<vi> vvi;

typedef pair<int_t, int_t> pi;

#define tr(c, i) for(auto i = (c).begin(); i != (c).end(); i++)
#define pb push_back
#define sz(a) i64((a).size())
#define all(c) (c).begin(), (c).end()
#define REP(s, e, i) for(i=(s); i < (e); ++i)

int main(int argc, char *argv[]) {
  i64 X;
  cin >> X;
  unordered_set<i64> s, c;
  i64 ans = 0;
  double x = 0, y = 0;
  double eps = 1e-5;
  while(true) {
    i64 theta = (ans * X) % 360;
    double dx = cos(M_PI * theta / 180);
    double dy = sin(M_PI * theta / 180);
    x += dx;
    y += dy;

    ans++;
    if(x * x + y * y < eps) {
      cout << ans << endl;
      break;
    }
  }
  
  return 0;
}


Measured memory_bytes: 4036
#include<bits/stdc++.h>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
 
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define mod 1000000007
 
using namespace std;

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

    vector<int> a(n);

    for ( int i = 0 ; i < a.size() ; i++ )
    {
        cin>>a[i];
    }

    sort(a.begin(),a.end());
    int ans = mod;
    for ( int i = a[0] ; i <= a[a.size()-1] ; i++ )
    {
        int sum = 0;
        for ( int j = 0 ; j < a.size() ; j++ )
        {
            sum += (i-a[j])*(i-a[j]);
        }
        // cout<<sum<<endl;
        ans = min(sum,ans);
        // cout<<i<<endl;
    }

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

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

#define fi first
#define se second
#define db double
#define U unsigned
#define P std::pair<int,int>
#define LL long long
#define pb push_back
#define MP std::make_pair
#define all(x) x.begin(),x.end()
#define CLR(i,a) memset(i,a,sizeof(i))
#define FOR(i,a,b) for(int i = a;i <= b;++i)
#define ROF(i,a,b) for(int i = a;i >= b;--i)
#define DEBUG(x) std::cerr << #x << '=' << x << std::endl

const int MAXN = 1e5 + 5;
int n;
int a[MAXN];

int main(){
	scanf("%d",&n);n <<= 1;
	FOR(i,1,n) scanf("%d",a+i);
	std::sort(a+1,a+n+1);
	int ans = 0;
	for(int i = 1;i <= n;i += 2) ans += a[i];
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 3784
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.bigint, std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static File _f;
void file_io(string fn) { _f = File(fn, "r"); }
static string[] s_rd;
T _RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T _RD(T = long)(File f) { while(!s_rd.length) s_rd = f.readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T[] _RDA(T = long)(T fix = 0) { auto r = readln.chomp.split.to!(T[]); r[] += fix; return r; }
T[] _RDA(T = long)(File f, T fix = 0) { auto r = f.readln.chomp.split.to!(T[]); r[] += fix; return r; }
T RD(T = long)() { if (_f.isOpen) return _RD!T(_f); else return _RD!T; }
T[] RDA(T = long)(T fix = 0) { if (_f.isOpen)  return _RDA!T(_f, fix); else return _RDA!T(fix); }

size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

void chmin(T)(ref T x, T y) { x = min(x, y); } void chmax(T)(ref T x, T y) { x = max(x, y); }
bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
T lcm(T)(T x, T y) { return x * (y / gcd(x, y)); }

long mod = 10^^9 + 7;
//long mod = 998244353;
//long mod = 1_000_003;
void moda(T)(ref T x, T y) { x = (x + y) % mod; }
void mods(T)(ref T x, T y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(T)(ref T x, T y) { x = (x * y) % mod; }
void modpow(T)(ref T x, T y) { if (!y) { x = 1; return; } auto t = x; x.modpow(y>>1); x.modm(x); if (y&1) x.modm(t); }
void modd(T)(ref T x, T y) { x.modm(y.modpow(mod - 2)); }

void main()
{
	auto N = RD;
	auto A = RDA;

	long[long] cnt;
	foreach (i; 0..N)
	{
		++cnt[A[i]];
	}

	long ans;
	foreach (key; cnt.keys)
	{
		auto v = cnt[key];
		ans += v * (v-1) / 2;
	}

	foreach (i; 0..N)
	{
		auto v = cnt[A[i]];
		writeln(ans - (v - 1));
	}

	stdout.flush;
	debug readln;
}

Measured memory_bytes: 27280
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
int main(){ 
    int n;
    cin>>n;
    double a;
    string s;
    double b=0;
    REP(i,n){
        cin>>a>>s;
    if(s=="JPY"){
        b+=a;
    }else{
        b+=a*380000.0;
    }
    }
    cout<<b;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  string S;
  int N,K;
  cin>>N>>S>>K;
  for(char c:S){
    if(c==S[K-1])
      cout<<c;
    else
      cout<<'*';
  }
  cout<<endl;
}

Measured memory_bytes: 3504
#include <stdio.h>
#include<iostream>
#include<string>
#include <string.h>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <climits>
#include <map>
using namespace std;
int a[200005];
long long ans,sum,mod=1000000007;
long long qpow(long long a,long long b)
{
    long long p=1;
    while(b)
    {
        if(b&1) p=p*a%mod;
        b/=2;
        a=a*a%mod;
    }
    return p;
}
int main() {
    int n;
    cin>>n;
    for(int i=1;i<=n;i++) scanf("%d",&a[i]);
    for(int i=1;i<=n;i++) sum=(sum+a[i])%mod;
    ans=sum*sum%mod;
    for(int i=1;i<=n;i++) ans=(ans-(1LL*a[i]*a[i])%mod)%mod;
    if(ans<0) ans+=mod;
    ans=ans*(qpow(2,mod-2)%mod)%mod;
    cout<<ans<<endl;
    return 0;
}

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

void out(vector<int> a){
		bool isFirst = true;
		for(auto &&ai: a){
			if(!isFirst) cout<<" ";
			cout<<ai;
			isFirst &= false;
		}
		cout<<endl;;	
}


int main() {
	int n;cin>>n;
	vector<int> par(n);
	iota(par.begin(),par.end(),1);
	
	do {
		out(par);
	} while(next_permutation(par.begin(),par.end()));
  return 0;
}



Measured memory_bytes: 3116
#include<stdio.h>
int Digit(int num);

int main(void){
  int count=0,i;
  int n,digit;
  scanf("%d",&n);
  for(i=1;i<=n;i++){
    digit=Digit(i);
    if(digit%2 == 1){
      count++;
    }
  }
  printf("%d\n",count);
  return 0;
}

int Digit(int num){
  int digit=0;
  while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
}

Measured memory_bytes: 128
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <bitset>
using namespace std;

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define fi first
#define se second

#define INF 2147483600

int main(){
  int n;
  cin>>n;
  vector<pair<int, int> > vec(n);
  rep(i,n){
    scanf("%d", &(vec[i].fi));
    vec[i].se = i;
  }

  sort(all(vec));

  int res=0;
  rep(i,n){
    if((i-vec[i].se)%2!=0) res++;
  }

  assert(res%2==0);

  cout<<res/2<<endl;

  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <vector>
#include <bits/stdc++.h>

#define ll unsigned long long
#define p(a, b) pair<a,b>

using namespace std;

//ifstream cin("Input.txt");
//ofstream cout("Output.txt");`

int main() {
    int n;
    cin >> n;
    ll res = 0;
    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;
        res += x - 1;
    }
    cout << res;
    return 0;
}


Measured memory_bytes: 256
const input = require('fs').readFileSync('/dev/stdin', 'utf8');
const lines = input.trim().split('\n');

let array;
let index = 0;
let n;
let m;
let answers = [];
while (line = lines.shift()) {
    if(index === 0){
        const test = line.split(' ').map(Number);
        n = test[0];
        m = test[1];
        index ++;
    } else {
        array = line.split(' ').map(Number);


        let answer = 0;
        for(let i = 0; i<n ;i++){
            for(let j = 0;j<n;j++){
                if(i === j){
                    continue;
                }
                const test = array [i] + array [j];
                if(test > answer && test <= m){
                    answer = test;
                }
            }
        }
        index = 0;
        answers.push(answer);

    }
}
/*
let answer = 0;

for(let i = 0; i<n ;i++){
    for(let j = 0;j<n;j++){
        if(i === j){
            continue;
        }
        const test = array [i] + array [j];
        if(test > answer && test <= m){
            answer = test;
        }
    }
}
*/
answers.forEach(data => console.log(data ? data : 'NONE'))
// console.log(answers);


Measured memory_bytes: 18220
class UnionFind:
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}


n, m = map(int, input().split())
union_find = UnionFind(n)
for _ in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    union_find.union(a, b)
ans = 0
for root in union_find.roots():
    ans = max(union_find.size(root), ans)
print(ans)




Measured memory_bytes: 87740
//↓見なくていいよ！ここから--------------------------------------------------
var read = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});
var obj;
var inLine = [];
read.on('line', function(input){inLine.push(input);});
read.on('close', function(){
  obj = init(inLine);
  console.error("\n");
  var start = Date.now();
  Main();
  var end = Date.now() - start;
  myerr("time : " + (end) + "ms");
  myerr("memory : " + Math.round(process.memoryUsage().heapTotal / 1024) + "KB");
});
function makeClone(obj){return JSON.parse(JSON.stringify(obj));}
function nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}
function nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();}
function init(input){  
  var returnObj = {
    list : input, index : 0, max : input.length,
    hasNext : function(){return (this.index < this.max);},
    next : function(){if(!this.hasNext()){throw "ArrayIndexOutOfBoundsException これ以上ないよ";}else{var returnInput = this.list[this.index];this.index++;return returnInput;}}
  };
  return returnObj;
}
function myout(s){console.log(s);}
function myerr(s){console.error("debug:" + require("util").inspect(s,false,null));}
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す 1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map(Number);case 6:return i.split("");case 7:return i.split("").map(Number);case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}

//↑見なくていいよ！ここまで--------------------------------------------------
function Main(){
	var N = nextInt();
	var list = new Array(N);
	for(var i = 0; i < N; i++){
		var tmp = nextStrArray();
		list[i] = {
			no : i + 1,
			name : tmp[0],
			pi : myconv(tmp[1], 1)
		};
	}
	list.sort(function(a,b){
		if(a.name == b.name){
			return b.pi - a.pi;
		}else{
			if(a.name < b.name){
				return -1;
			}else{
				return 1;
			}
		}
	});
	var output = new Array(N);
	for(var i = 0; i < N; i++){
		output[i] = list[i].no;
	}
	myout(myconv(output,9));
}


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

int main() {
  int n;
  cin >> n;
  int p[n+1];
  for(int i=1;i<=n;i++)
    cin >> p[i];
  int num = 0;
  
  for(int i=2;i<n;i++) {
    if((p[i]>p[i-1]) && (p[i]<=p[i+1]) || (p[i]>p[i+1]) && (p[i]<=p[i-1]))
      num++;

  }
  
  cout << num << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int n, x, A, B, C, count = 0;
	while (1)
	{
		scanf("%d %d", &n, &x);
		if (n == 0 && x == 0)
			break;
			for (A = 1; A <= n; A++)
			{
				for (B = 1; B <= n; B++)
				{
					for (C = 1; C <= n; C++)
					{
						if (A + B + C == x)
						{
							if (A != B && B != C && C != A)
							{
							count++;
							}
						}
					}
				}
			}
	printf("%d\n", count/6);
	count = 0;
	}
	return 0;
}

Measured memory_bytes: 600
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
#import numpy as np
from collections import Counter
def main():
    n, *a = map(int, read().split())
    if 1 in a:
        count1 = a.count(1)
        if count1 == 1:
            print(1)
            sys.exit()
        else:
            print(0)
            sys.exit()
    maxa = max(a)
    seq = [0] * (maxa + 1)
    ac = Counter(a)
    for ae in ac.items():
        if ae[1] == 1:
            seq[ae[0]] = 1
    for ae in a:
        t = ae * 2
        while t <= maxa:
            seq[t] = 0
            t += ae
    r = sum(seq)
    print(r)

if __name__ == '__main__':
    main()


Measured memory_bytes: 135360
package main

import "fmt"

func maxAndSum(a []int) (x, y int) {
	x = a[0]
	for _, i := range a {
		y += i
		if i > x {
			x = i
		}
	}
	return
}

func main() {
	var a, b, c, k int
	fmt.Scan(&a, &b, &c, &k)

	max, sum := maxAndSum([]int{a, b, c})

	x := max
	for i := 0; i < k; i++ {
		x *= 2
	}

	fmt.Println(x + sum - max)
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
const long double PI = (acos(-1));
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
int ctoi(char c)
{
    switch (c)
    {
    case '0':
        return 0;
    case '1':
        return 1;
    case '2':
        return 2;
    case '3':
        return 3;
    case '4':
        return 4;
    case '5':
        return 5;
    case '6':
        return 6;
    case '7':
        return 7;
    case '8':
        return 8;
    case '9':
        return 9;
    default:
        return 0;
    }
}
int main()
{
    int x, y, z;
    cin >> x >> y >> z;
    x -= z;
    int space = y + z;
    int ans = 0;
    while (x >= space)
    {
        x -= space;
        ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import scala.io.StdIn._
import scala.math.pow
import java.util.Scanner

object Main extends App {

  val scanner = new Scanner(System.in)

  val a = scanner.next
  val b = scanner.next
  val c = (a+b).toInt
  val sqrt_c = Math.sqrt(c).toInt
  println(if(sqrt_c*sqrt_c==c.toInt)"Yes" else "No")


}


Measured memory_bytes: 25800
from collections import defaultdict

INF = 10 ** 10
def main():
    N, M = map(int, input().split())

    dp = [[INF] * N for _ in range(N)]
    edges = []
    for i in range(M):
        a, b, c = map(int, input().split())
        a -= 1
        b -= 1
        dp[a][b] = c
        dp[b][a] = c
        edges.append((a, b, c))

    for i in range(N):
        dp[i][i] = 0

    for m in range(N):
        for s in range(N):
            for e in range(N):
                if dp[s][m] != INF and dp[m][e] != INF:
                    dp[s][e] = min(dp[s][e], dp[s][m] + dp[m][e])

    ans = 0
    for a, b, c in edges:
        ans += dp[a][b] != c
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3732
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <deque>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;

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

	auto ans = INT_MAX;
	for (auto i = 0; i <= max(X, Y); ++i)
	{
		auto temp = i * 2 * C;
		temp += A * max(0, X - i);
		temp += B * max(0, Y - i);
		ans = min(ans, temp);
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<map>
#include<algorithm>
#include<stack>
#include<queue>
#include<string.h>
#include<math.h>
#include<iostream>
using namespace std;
long long a[105],ans,n,m,i,sum=0;
double x,y;
bool cmp(long long x,long long y)
{
    return x>y;
}
int main()
{
    int w=0;
    scanf("%lld%lld",&n,&m);
    x=1.0/(4*m);
    for(i=1;i<=n;i++)
    {
        scanf("%lld",&a[i]);
        sum+=a[i];
    }
   // printf("%lld\n",sum);
    x=sum/(4.0*m);
    sort(a+1,a+n+1,cmp);
    for(i=1;i<=m;i++)
    {
   //     printf("%lld %lf\n",a[i],x);
        if(a[i]<x){w=1;break;}
    }
    if(w)printf("No\n");
    else printf("Yes\n");
}

Measured memory_bytes: 256
#import sys
MOD = 10 ** 9 + 7
#input = sys.stdin.readline
import math
import itertools

#import bisect

def sosuhante(n):
    for k in range(2, int(math.sqrt(n))+1):
        if n% k ==0:
            return False
    return True
def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

def kingaku(a,b,n):
    keta=len(str(n))
    return a*n+b*keta

def my_index(l, x, default=False):
    if x in l:
        return l.index(x)
    else:
        return default


def main():
#    h,w,a,b = map(int, input().split())
#    c = [[0 for j in range(n)] for i in range(n)]
    n=int(input())
    s,t=map(str,input().split())
    s=list(s)
    t=list(t)
    c=[]
    for i in range(n):
        c.append(s[i])
        c.append(t[i])
    print("".join(c))

if __name__ == "__main__":
    main()

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#include <string>
#include <algorithm>
#include <string.h>
#include <ctype.h>
#include <math.h>
#include <float.h>
#include <iomanip>
#include <iostream>
using namespace std;
 
int gcd(int x,int y){
    if(y==0)return x;

    return gcd(y,x%y);
}
int lcm(int x,int y){
    return x*y/gcd(x,y);
}

int main(){

    int R,G,B,N,ans=0;
    cin>>R>>G>>B>>N;
    
    for(int r=0;r<=N/R;r++){
        for(int g=0;g<=N/G;g++){
            int x=N-r*R-g*G;
            int b=x/B;
            if(x%B==0&&b>=0)ans++;
        }
    }

    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int N,sum=0;
  scanf("%d",&N );
  while(N>0){
    sum+=N%10;
    N=N/10;
  }
  if(sum==1)
    printf("10\n");
  else
    printf("%d\n",sum );
  return 0;
}


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

int main(){
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  int x=c-a,y=d-b;
  for (int i=0;i<x;i++){
    cout << 'R';
  }
  for (int i=0;i<y;i++){
    cout << 'U';
  }
  for (int i=0;i<x;i++){
    cout << 'L';
  }
  for (int i=0;i<y;i++){
    cout << 'D';
  }
  cout << 'D';
  for (int i=0;i<x+1;i++){
    cout << 'R';
  }
  for (int i=0;i<y+1;i++){
    cout << 'U';
  }
  cout << 'L';
  cout << 'U';
  for (int i=0;i<x+1;i++){
    cout << 'L';
  }
  for (int i=0;i<y+1;i++){
    cout << 'D';
  }
  cout << 'R' << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<queue>
using namespace std;
long long n1,n2,n3;
long long a[300000];
long long gleft[300000];
long long gright[300000];

void Init()
{
    cin>>n1;
    n2=n1*2;
    n3=n1*3;
    for(int i=0;i<n3;i++)
        cin>>a[i];
}
struct cmp
{
    bool operator()  (long long a, long long b) {return a>b;}
};
priority_queue<long long,vector<long long>,cmp> pqleft;
void solve1()
{
    long long p=0;
    for(int i=0;i<n1;i++)
        {
            p+=a[i];
            pqleft.push(a[i]);
        }
    gleft[n1-1]=p;
    for(int i=n1;i<n2;i++)
    {
        gleft[i]=gleft[i-1]+a[i];
        pqleft.push(a[i]);
        gleft[i]-=pqleft.top();
        pqleft.pop();
    }

}
priority_queue<long long> pqright;

void solve2()
{
    long long p=0;
    for(int i=n3-1;i>=n2;i--)
        {
            p+=a[i];
            pqright.push(a[i]);
        }
    gright[n2]=p;
    for(int i=n2-1;i>=n1;i--)
    {
        gright[i]=gright[i+1]+a[i];
        pqright.push(a[i]);
        gright[i]-=pqright.top();
        pqright.pop();
    }

}
void res()
{
    long long r=-1e18;
    for(int i=n1;i<=n2;i++)
        r=max(r,gleft[i-1]-gright[i]);
    cout<<r;
}
int main()
{
    Init();
    solve1();
    solve2();
    res();
}


Measured memory_bytes: 7668
while True:
    a = list(input())
    if a[0] == "-":
        break
    b = int(input())
    d=0
    for i in range (b):
        c = int(input())
        d += c
    e = d % len(a)
    f = a[e:len(a)]+a[0:e]
    g = ''.join(f)
    print(g)



Measured memory_bytes: 5592
n=int(input())
print(0, flush=True)
sl=input()
if sl=="Vacant":
  exit(0)

l=0
r=n-1

for i in range(30):

  if r-l<=2:
    for j in range(3):
      print(l+j+1, flush=True)
      s=input()
      if s=="Vacant":
        exit(0)

      
  elif ((l+r)//2)%2==0:
    print((l+r)//2, flush=True)
    s=input()
    if s=="Vacant":
      exit(0)
    elif s==sl:
      l=(l+r)//2
      sl=s
    else:
      r=(l+r)//2
      sr=s

  else:
    print((l+r)//2+1, flush=True)
    s=input()
    if s=="Vacant":
      exit(0)
    elif s==sl:
      l=(l+r)//2
      sl=s
    else:
      r=(l+r)//2
      sr=s

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

int main () {
int N; cin>>N;
  if(N % 2==0 &&N /2 <=10){cout<<"Yes"<<endl;}
   else if(N % 4==0 &&N /4 <10){cout<<"Yes"<<endl;}
   else if(N % 5==0 &N /5 <10){cout<<"Yes"<<endl;}
   else if(N % 3==0 &N /3 <10){cout<<"Yes"<<endl;}
   else if(N % 6==0 &&N /6 <10){cout<<"Yes"<<endl;}
   else if(N % 7==0 &&N /7 <10){cout<<"Yes"<<endl;}
   else if(N % 8==0 &&N /8 <10){cout<<"Yes"<<endl;}
   else if(N % 9==0 &&N /9 <10){cout<<"Yes"<<endl;}
  else if(N==1){cout <<"Yes"<<endl;}
  else{cout <<"No"<<endl;}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<n;i++)
#define rep2(i,a,n) for(int i=a;i<n;i++)
#define been(ix) (ix).begin(),(ix).end()
using namespace std;
typedef long long ll; 
typedef vector<int> vi;
typedef vector<long long> vl;
const ll INFL = 1e18;
const int INF = 1001001001; 
typedef pair<int,int> P;
#define foreach(ix,i) for(auto& (ix) : (i))
typedef long double ld;
const int mod =1000000007;
const double PI = acos(-1);

int main(){
	int h,w;cin>>h>>w;
	char ma[h][w];
	rep(i,h)rep(j,w)cin>>ma[i][j];
	int dp[h][w];
	rep(i,h)rep(j,w)dp[i][j]=INF;
	if(ma[0][0]=='#')dp[0][0]=1;
	else dp[0][0]=0;
	rep(i,h)rep(j,w){
		if(i!=h-1){
			dp[i+1][j]=min(dp[i+1][j],dp[i][j]+(ma[i+1][j]=='#'&&ma[i][j]=='.'? 1:0));
		}
		if(j!=w-1){
			dp[i][j+1]=min(dp[i][j+1],dp[i][j]+(ma[i][j+1]=='#'&&ma[i][j]=='.'? 1:0));
		}
	}
	cout<<dp[h-1][w-1]<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
using namespace std;

struct Point {
  int x, y;
  Point() {}
  Point(int x, int y) : x(x), y(y) {}
  
  Point operator + (const Point &a) {
	return Point(x - a.x, y - a.y);
  }
  Point operator - (const Point &a) {
	return Point(x - a.x, y - a.y);
  }
  
  Point operator - () {
	return Point(-x, -y);
  }
  
  /*
	テ、ツサツ・テ、ツクツ凝」ツ?ョ2テ」ツ?、テ」ツ?ョ operator テ」ツ?ッ map テァツ板ィ
	mapテ」ツ?ッテ、ツコツ古・ツ按?ヲツ篠「テァツエツ「テ」ツ?凖」ツつ凝」ツ?淌」ツつ?」ツ??ヲツュツ」テ」ツ?療」ツ??< テ」ツつ津・ツョツ堙ァツセツゥテ」ツ?療」ツ?ェテ」ツ??」ツ?ィテ」ツ??」ツ?妥」ツ?ェテ」ツ??
  */
  bool operator < (const Point &a) const {
	if( x == a.x ) {
	  if( y < a.y ) return true;
	}
	else {
	  if( x < a.x ) return true;
	}
	return false;
  }
  
  bool operator == (const Point &a) const {
	return x==a.x && y==a.y;
  }
  
  double norm() {
	return x*x+y*y;
  }
};

typedef Point Vector;

Vector rotate90R(Vector V) {
  return Vector(V.y, -V.x);
}

bool isIn(int x, int y) {
  return 0<=x && x<=5000 && 0<=y && y<=5000;
}

int main() {
  int n;
  int x, y;
  while(cin >> n && n) {

  	vector<Point> vec;
	map<Point, int> exist;

	for(int i=0; i<n; i++) {
	  cin >> x >> y;
	  Point p(x, y);
	  vec.push_back(p);
	  exist[p] ++;
 	}
	
	int ans = 0;
	
	for(int i=0; i<n-1; i++) {
	  for(int j=i+1; j<n; j++) {
		Vector V1 = vec[i] - vec[j];
		Vector V3 = rotate90R(V1);
		Vector V4 = -rotate90R(V1);
		int area = V1.norm();
		
		Vector VV1 = vec[j]+V3;
		Vector VV2 = vec[i]+V3;
		if(isIn(VV1.x, VV1.y) && isIn(VV2.x, VV2.y))
		  if(exist.count(VV1) && exist.count(VV2))
			ans = max(ans, area);
		
		VV1 = vec[j]+V4;
		VV2 = vec[i]+V4;
		if(isIn(VV1.x, VV1.y) && isIn(VV2.x, VV2.y))
		  if(exist.count(VV1) && exist.count(VV2))
			ans = max(ans, area);
	  }
	}
	cout << ans << endl;
  }
  
  return 0;
}

Measured memory_bytes: 1436
using System;
using System.Linq;
using System.Collections;
//using System.Collections.Generic;

class Test
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        int[] A = Console.ReadLine().Split().Select(int.Parse).ToArray();
        int q = int.Parse(Console.ReadLine());
        for (int i = 0; i < q; i++)
        {
            int[] query = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int[] B = new int[query[2] - query[1]];
            Array.Copy(A, query[1], B, 0, query[2] - query[1]);
            Console.WriteLine(query[0] == 0 ? B.Min() : B.Max());
        }
    }
}




Measured memory_bytes: 16344
#include <stdio.h>
int main()
{
	int n,k,person=0,i;
	scanf("%d %d",&n,&k);
	int a[n];
	for(i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
		if(a[i]>=k) person++;
	}
	printf("%d",person);
}


Measured memory_bytes: 512
N = int(input())
S = input()
S = [i for i in S]
list1 = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z']


newlist = []
for i in range(len(S)):
    ind1 = list1.index(S[i])
    newlist.append(list1[ind1+N])

ans = ''.join(newlist)
print(ans)



Measured memory_bytes: 3188
import java.util.*;
public class Main {
        static Scanner sc = new Scanner(System.in);
        static void myout(Object t){System.out.println(t);}//standard output
        static void myerr(Object t){System.err.println(t);}//standard error
        static String getStr(){return sc.next();}
        static int getInt(){return Integer.parseInt(getStr());}
        static long getLong(){return Long.parseLong(getStr());}
        static boolean hasNext(){return sc.hasNext();}
        static char[] mySplit(String str){return str.toCharArray();}
        public static void main(String[] args){
          long N = getLong();
          if(N == 0 || N % 2 == 1){
            myout(0);
            return;
          }
          long output = 0;
          int count = 1;
          long tei = 10;
          while(N >= tei){
            myerr(tei);
            output += N / tei;
            tei *= 5;
          }
          myout(output);
        }
        //Method addition frame start

        //Method addition frame end
}


Measured memory_bytes: 22996
#include<bits/stdc++.h>
#define rep(i,a) for(int (i)=0; (i)<(a); (i)++)
#define rep2(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
#define MOD 1000000007
#define all(v) v.begin(), v.end()
#define m0(x) memset(x,0,sizeof(x))
typedef long long ll;

using namespace std;

const int mod = 1000000007;
// const int mod = 998244353;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const { //値をt乗する
    if (!t) return 1; // t == 0
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this; //*thisは元の値(t乗する対象)
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

mint fac[100500] = {};

mint nCr(ll n, ll r){
      return fac[n]/(fac[r] * fac[n-r]);
}

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

      fac[0] = mint(1); fac[1] = mint(1);
      rep2(i,2,100500){
            fac[i] = fac[i-1] * mint(i);
      }

      ll n,k; cin >> n >> k;
      vector<ll> a(n);
      rep(i,n) cin >> a[i];
      sort(all(a));
      mint max = 0, min = 0;
      rep2(i,k-1,n){
            max += mint(a[i]) * nCr(i, k-1);
      }
      reverse(all(a));
      rep2(i,k-1,n) min += mint(a[i]) * nCr(i,k-1);

      cout << (max - min).x << endl;

  return 0;
}


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

    int n;cin>>n;int k;cin>>k;
    int a[n];
    int dp[n];
    for(int i=0;i<n;i++) cin>>a[i];
    dp[0]=0;
    dp[1]=abs(a[0]-a[1]);
    for(int i=2;i<n;i++){
        dp[i]=INT_MAX;
    for(int j=1;j<=k;j++){
        if(i-j>=0){
            dp[i]=min(dp[i], abs(a[i]-a[i-j])+dp[i-j]);
        }
    }
    }
    cout<<dp[n-1]<<endl;

    return 0;
}


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

using namespace std;

int main(){

    string s , t ;
    cin>>s>>t;
    
    int ans = 0 ;

    for (int i = 0; i <= s.size() ; i++)
        if(s[i]!=t[i])
            ans++;
    cout<<ans<<endl;
    return 0 ; 
}

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

int main(){
	double a,b,c,d,e,f;
	cin>>a>>b>>c>>d>>e>>f;
	
	vector<double> x;
	vector<double> y;
	
	for(int i=0;i<31;i++){
		for(int j=0;j<31;j++){
			x.push_back((i*a+j*b)*100);
		}
	}
	
	for(int i=0;i*c<=1500;i++){
		for(int j=0;i*c+j*d<=1500;j++){
			y.push_back(i*c+j*d);
		}
	}
	
	double ans=0;
	double ans1=a*100;
	double ans2=0;
	
	for(int i=0;i<x.size();i++){
		for(int j=0;j<y.size();j++){
			//cout<<x[i]<<" "<<y[j]<<endl;
			if(x[i]+y[j]<=f&&100*y[j]/(x[i]+y[j])<=100*e/(100+e)){
				if(100*y[j]/(x[i]+y[j])>ans){
					ans=100*y[j]/(x[i]+y[j]);
					ans1=x[i];
					ans2=y[j];
				}
			}
		}
	}
	
	cout<<ans1+ans2<<" "<<ans2<<endl;
}

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

using namespace std;

typedef long long llong;
typedef unsigned long long ullong;
typedef pair<int, int> P;
#define inf 1ll<<60
#define pqueue priority_queue
#define mp make_pair
#define pb push_back
#define fn fill_n
#define int llong


signed main(){
	int a;
	set<int> use;
	cin >> a;
	use.insert(a);
	for(int i = 2;; i++){
		if(a%2 == 0)
			a /= 2;
		else
			a = a*3 + 1;

		if(use.find(a) != use.end()){
			cout << i << endl;
			break;
		}
		use.insert(a);
	}
	return 0;
}

Measured memory_bytes: 256
//#pragma GCC optimize("O3", "unroll-loops")
//#pragma GCC target("avx2")
#include<bits/stdc++.h>

#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define FIXED cout << fixed << setprecision(12)
#define RANDOM srand(94385)
#define all(a) a.begin(), a.end()
#define shuffle(a) \
    for (int i = 0; i < sz(a); ++i) \
        swap(a[i], a[rand() % sz(a)]);
#define enter putchar('\n')
#define space putchar(' ')
#define Mem(a, x) memset(a, x, sizeof(a))
using namespace std;

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

void debug_out() { cerr << '\n'; }

template<typename T, typename ...R>
void debug_out(const T &f, const R &...r) {
    cerr << f << " ";
    debug_out(r...);
}

#define debug(...) cerr << "[" << #__VA_ARGS__ << "]: ", debug_out(__VA_ARGS__);

inline ll read() {
    ll x = 0;
    int f = 0;
    char ch = getchar();
    while (ch < '0' || ch > '9') f |= (ch == '-'), ch = getchar();
    while (ch >= '0' && ch <= '9') x = (x << 3) + (x << 1) + ch - '0', ch = getchar();
    return x = f ? -x : x;
}

inline void write(ll x) {
    if (x == 0) {
        putchar('0');
        return;
    }
    if (x < 0) {
        putchar('-');
        x = -x;
    }
    static char s[23];
    int l = 0;
    while (x != 0)s[l++] = x % 10 + 48, x /= 10;
    while (l)putchar(s[--l]);
}

int lowbit(int x) { return x & (-x); }

template<class T>
T big(const T &a1, const T &a2) { return a1 > a2 ? a1 : a2; }

template<typename T, typename ...R>
T big(const T &f, const R &...r) { return big(f, big(r...)); }

template<class T>
T sml(const T &a1, const T &a2) { return a1 < a2 ? a1 : a2; }

template<typename T, typename ...R>
T sml(const T &f, const R &...r) { return sml(f, sml(r...)); }

template<class T, class U>
inline void checkMin(T &x, U y) { if (y < x) x = y; }

template<class T, class U>
inline void checkMax(T &x, U y) { if (y > x) x = y; }

template<class T, class U>
inline bool ifMax(T &x, U y) {
    if (y > x) return x = y, true;
    return false;
}

template<class T, class U>
inline bool ifMin(T &x, U y) {
    if (y < x) return x = y, true;
    return false;
}

const int M = 212345;// 2e5+5
const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const int mod = 1000000007;// 1e9+7

// HAVE FREE OPEN IN MAIN FUNCTION

int n;
int a[M];
int ans[M];

void init() {
    n = read();
    for (int i = 1; i <= n; ++i) {
        a[i] = read();
    }
    a[0] = -inf;
    for (int i = 1; i <= n; ++i) {
        if (a[i - 1] >= a[i])ans[i] = ans[i - 1] + 1;
        else ans[i] = 0;
    }
    int answer=0;
    for (int i = 1; i <= n; ++i) {
        checkMax(answer,ans[i]);
    }
    write(answer);
    enter;
}

void solve() {

}

int main() {
    init();

    solve();

    return 0;
}

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


void solve(long long N, long long K){
  cout << N - K + 1 << endl;
}

// Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    long long K;
    scanf("%lld",&K);
    solve(N, K);
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int n,amount[100000],total_amount,i;
    scanf("%d %d",&n,&total_amount);
    for(i = 0;i<n;i++)
    {
        scanf("%d",&amount[i]);
    }
    int sum = 0;
    for(i = 0;i<n;i++)
    {
        sum = sum+amount[i];
    }
    int left;
    left = total_amount - sum;
    int total_donut;
    int max_donut = 0;;
    int donut;
    for(i = 0;i<n;i++)
    {
        donut = left/amount[i];
        if(max_donut<donut)
            max_donut = donut;
    }
    total_donut = n+ max_donut;
    printf("%d\n",total_donut);
}


Measured memory_bytes: 1736
#include <iostream>
#include <string>
//typedef long long LL;
using namespace std;

int main(){
    int n;
    int l;
    int eat;
    int sum;
    cin >> n >> l;
    if(l>0){
        eat = l;
    }else if(l+n-1>=0){
        eat = 0;
    }else{
        eat = l+n-1;
    }
    sum = n*(2*l+n-1)/2 - eat;
    cout << sum << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define sp(n) cout << fixed << setprecision(n)
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; }
typedef long long ll;
using namespace std;
int main(void){
   int n;cin>>n;
   vector<ll> a(n);
   rep(i,n) cin>>a[i];
   sort(a.begin(),a.end());
   ll res=1;
   rep(i,n){
       //cout<<res<<" "<<((1e+18)/a[i])<<endl;
       if(a[i]==0){
           cout<<0<<endl;
           return 0;
       }
       if(res>1000000000000000000/a[i]){
           cout<<-1<<endl;
           return 0;
       }
       res*=a[i];
   }
   cout<<res<<endl;
}


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

int main() {
   
    int n;
    string s;
    cin>>n>>s;
    
    int maxxx = 0;
    int x = 0;
    
    
    for(int i=0;i<n;++i)
    {
        if(s[i]=='I')
            x++;
        else
            x--;
        maxxx = max(x,maxxx);
    }
    
    cout<<maxxx;
	return 0;
}


Measured memory_bytes: 256
s = input()

def is_kaibun(kaibun):
    for i in range(len(kaibun)//2):
        if kaibun[i] != kaibun[-i-1]:
            return False
    return True

n =len(s)
s1 = s[0:(n-1)//2]
s2 = s[(n+1)//2:n]

if is_kaibun(s) and is_kaibun(s1) and is_kaibun(s2):
	print("Yes")
else:
	print("No")

Measured memory_bytes: 3060
#include <iostream>
#include <climits>
#include <bitset>
#include <stack>
#include <queue>
#include <iomanip>
#include <limits>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string.h>
 
using namespace std;
typedef long long ll;
 
 
typedef pair<ll,ll> P;
long long int INF = 1e18;
double Pi = 3.141592653589;
const int mod = 1000000007;
// memset(a,0,sizeof(a)); →全部０にする
 
vector<int> G[100005];
std::vector<P> tree[100010];
 
int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
 
#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<x<<" ";
#define re(i,a,b) for(i=a;i<=b;i++)
 
ll i,j,k,ii,jj;
ll n,m,sum,num=INF;
ll ans;
ll a,b,c,d,e;
ll x[100005],y[100005],z[100005];
ll xa[100005],ya[100005],za[100005];
char s[100005];

int main(){
	cin>>s;
	n=strlen(s);
	for(i=0;i<n;i++){
		if(s[i]=='C'){
			a++;
		}
		if(s[i]=='F' && a>=1){
			p("Yes");
			return 0;
		}
	}
	p("No");
	return 0;

    

}

Measured memory_bytes: 5632
#include<bits/stdc++.h>
using namespace std;
int main(){
string S;
  cin>>S;
  int N=S.size();
  int ans=0;
  for(int i=0;i<N-1;i++){
  if((S.at(i)=='B' && S.at(i+1)=='W') ||(S.at(i)=='W' && S.at(i+1)=='B'))
    ans++;
  
  }cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 512
#include "bits/stdc++.h"
using namespace std;
int w[300];
int memo[300][300]; //[l,r]
int solve(int l, int r) {
	if (l >= r) return 0;
	if (memo[l][r] != -1) return memo[l][r];
	int ans1 = 0, ans2 = 0;
	for (int i = l; i <= r - 1; i++) {
		int sum = 0;
		sum += solve(l, i);
		sum += solve(i + 1, r);
		ans1 = max(ans1, sum);
	}
	for (int i = l+1; i <= r-1; i++) { //[l+1,i] [i+1,r-1]
		int sum = 0;
		sum += solve(l + 1, i);
		sum += solve(i + 1, r - 1);
		ans2 = max(ans2, sum);
	}
	if (ans2 == (r - l - 1) && abs(w[l] - w[r]) <= 1) {
		ans2 += 2;
	}
	return memo[l][r] = max(ans1,ans2);
}

int main() {
	int n;
	while (scanf("%d", &n), n) {
		for (int i = 0; i < n; i++) {
			scanf("%d", &w[i]);
		}
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) memo[i][j] = -1;
		}
		printf("%d\n", solve(0, n - 1));
	}
}

Measured memory_bytes: 3504
import java.util.Scanner;
import java.util.Arrays;
import java.util.stream.*;

public class Main {
    public static void main(String[] args) {
        //コード
        Scanner scanner = new Scanner(System.in);
        Integer s = Integer.parseInt(scanner.next());
        Integer w = Integer.parseInt(scanner.next());

        if(w >= s) {
            System.out.println("unsafe");
        } else {
            System.out.println("safe");
        }
    }
}


Measured memory_bytes: 35720
a=int(input())
b=0
c=1
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)

def gcd_list(numbers):
    return reduce(math.gcd, numbers)

for i in range(1,a+1):
    for j in range(1,a+1):
        
        for z in range(1,a+1):
            

            b+=gcd(i,j,z)


print(b)


Measured memory_bytes: 74908
#include <iostream>
#include <algorithm>
#include <vector>
#include <limits>

using namespace std;

int abs(int x) {
    if (x < 0)
        return -x;
    return x;
}

int main() {
    int N, Z, W; cin >> N >> Z >> W;
    vector<int> A(N + 2);
    A[0] = W;
    A[1] = Z;
    for (int i = 2; i < N + 2; ++i)
        cin >> A[i];

    vector< vector<int> > dp[2];
    dp[0] = vector< vector<int> >(N + 2, vector<int>(N + 2, 0));
    dp[1] = vector< vector<int> >(N + 2, vector<int>(N + 2, numeric_limits<int>::max()));

    for (int i = 0; i < N + 1; ++i)
        dp[0][N + 1][i] = dp[1][N + 1][i] = abs(A[i] - A[N + 1]);

    for (int i = N; i >= 0; --i)
        for (int j = i - 1; j >= 0; --j) {
            dp[0][i][j] = max(dp[0][i + 1][j], dp[1][i + 1][i]);
            dp[1][i][j] = min(dp[1][i + 1][j], dp[0][i + 1][i]);
        }

    cout << dp[0][2][0] << "\n";
}


Measured memory_bytes: 31744
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<tuple>
#include<cassert>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define Per(i,sta,n) for(int i=n-1;i>=sta;i--)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};

int n;
ll k;
int p[5010];
ll c[5010];

vector<int> v(int s){
  vector<int> res={s};
  int pos=p[s];
  while(pos!=s){
    res.push_back(pos);
    pos=p[pos];
  }
  return res;
}

void solve(){
  cin >> n >> k;
  rep(i,n) {
    cin >> p[i];p[i]-=1;
  }
  rep(i,n) cin >> c[i];
  ll ans=-INF;
  rep(i,n){
    vector<int> f=v(i);
    int m=f.size();
    int r=k%m,q=k/m;
    ll S=0;
    //cout << i << endl;
    vector<ll> T(m);
    T[0]=c[i];
    rep(i,m){
      //cout << f[i] << " ";
      S+=c[f[i]];
      if(i>=1) T[i]=T[i-1]+c[f[i]];
      //cout << i << " " << f[i] << " " << T[i] << endl;
    }
    ll res1=0,res2=0;
    if(S>0) res1=S*q;
    if(S>0) res2=S*(q-1); 
    ll t1=-INF,t2=-INF;
    rep(i,r+1){
      if(S<0 || q==0) if(i==0) continue; 
      t1=max(t1,T[i]);
    }
    rep(i,m){
      if(S<0 || q-1<0) if(i==0) continue; 
      t2=max(t2,T[i]);
    }
    // cout << "" << endl;
    // cout << res1+t1-c[i] << " " << res2+t2-c[i] << endl;
    ans=max(ans,max(res1+t1,res2+t2)-c[i]);
  }
  cout << ans << endl;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(50);
    solve();
}

Measured memory_bytes: 3772
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
//#define int long long
template<typename T> inline bool chmax(T& a,T b) { if (a < b) { a = b; return true; } return false; }
template<typename T> inline bool chmin(T& a,T b) { if (a > b) { a = b; return true; } return false; }

signed main() {
    int N;
    string S;
    cin >> N >> S;
    int ans = 0;
    for (int i = 0; i < N; i++) {
        if (S[i] == 'A' && S[i+1] == 'B' && S[i+2] == 'C') {
            ans++;
            i += 2;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.InputStreamReader;
import java.io.BufferedReader;
import java.io.PrintWriter;
import java.io.IOException;

public class Main {

    public static void main(String[] args) throws IOException{
        BufferedReader reader = null;
        PrintWriter writer = null;
        
        try {
            reader =new BufferedReader(new InputStreamReader(System.in));
            writer = new PrintWriter(System.out);
            
            int patern = 0;
            
            int amount500 = Integer.parseInt(reader.readLine()),
                amount100 = Integer.parseInt(reader.readLine()),
                amount50 = Integer.parseInt(reader.readLine()),
                amountX = Integer.parseInt(reader.readLine());
            
            for(int a = 0; a <= amount500; a ++){
                for(int b = 0; b <= amount100; b++){
                    for(int c = 0; c<= amount50; c++){
                        if(a * 500 + b * 100 + c * 50 == amountX) patern++;
                    }
                }
            }
            
            writer.println(patern);
            
        }finally{
            if(reader != null){
                reader.close();
            }
            if(writer != null){
                writer.close();
            }
        }

    }
}

Measured memory_bytes: 22996