akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<cstring>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<fstream>

#define MOD (1000000007)

using namespace std;

typedef long long int Int;

constexpr Int TEN(int n) { return n == 0 ? 1 : 10 * TEN(n-1); }

int main(void) {
    int A,B;

    cin>>A>>B;

    int K = (A+B)/2;
    if(abs(A-K) == abs(B-K)) {
        cout<<K<<endl;
    } else {
        cout<<"IMPOSSIBLE"<<endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <set>
using namespace std;
const int N = 1005;
set<int> used;
int a[N];

int main() {
	int n;
	while(scanf("%d", &n) != EOF) {
		used.clear();
		for(int i = 0; i < n; ++i) {
			scanf("%d", &a[i]);
		}
		for(int i = 0; i < n; ++i) {
			int tmp = 0;
			for(int j = i; j < i + 3 && j < n; ++j) {
				tmp = tmp * 10 + a[j];
				used.insert(tmp);
			}
		}
		int ans = 0;
		for(int i = 0; i <= 1005; ++i) {
			if(used.find(i) == used.end()) {
				ans = i;
				break;
			}
		}
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 1248
import java.util.Scanner;
public class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    String b = sc.next();
    char c[] = b.toCharArray();
    int counter = 0;
    for(int j = 1;j < c.length;j++){
      if(c[j-1]==c[j]){
        counter++;
      }
    }
        System.out.println(a-counter);
  }
}

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

int main(){
	while (1){

		int H, W;
		cin >> H >> W;

		if (H == 0 && W == 0) break;
		else{
			for (int i = 1; i <= H; i++){
				for (int j = 1; j <= W; j++)
				{
					cout << '#';
				}
				cout << endl;
			}
			cout << endl;
		}
	}
		return 0;
	}



Measured memory_bytes: 3096
#pragma once
#include <stdio.h>
#include <sstream>
#include <string>
#include <string.h>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <deque>
#include <limits>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define bit(x,v) ((ll)x << v)

const ll INF = 1000000007;
const int MAX = 210000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
int pr[100010];
void uini(int n) {
	for (size_t i = 0; i <= n; i++)
	{
		pr[i] = i;
	}
}

int parent(int x) {
	if (x == pr[x]) return x;
	return pr[x] = parent(pr[x]);
}

bool unit(int x, int y) {
	int px = parent(x);
	int py = parent(y);

	if (px == py) return false;
	if (px < py) {
		pr[py] = px;
	}
	else {
		pr[px] = py;
	}
	return true;
}

ll bit[200010];
int max_n = 200000;
int pm = 0;
void add(int x) {

	while (max_n >= x)
	{
		bit[x]++;
		x += x & -x;
	}
}
void sub(int x) {
	while (max_n >= x)
	{
		bit[x]--;
		x += x & -x;
	}
}
int search(int x) {

	int k = 0;
	int p = 1;
	while (p * 2 <= max_n)
	{
		p *= 2;
	}
	for (int i = p; i > 0; i /= 2)
	{
		if (i + k < max_n && bit[i + k] < x) {
			x -= bit[i + k];
			k += i;
		}
	}
	return k + 1;
}
void solv() {

	string s;
	getline(cin,s);
	map<char, char> mp;
	vector<char> v;

	int c = 0;
	for (char i = 'a'; i <= 'z'; i++)v.push_back(i);
	c = v.size();
	for (char i = 'A'; i <= 'Z'; i++)v.push_back(i);
	int j = 0;
	for (char i = 'a'; i <= 'z'; i++)
	{
		mp[i] = v[c + j++];
	}
	j = 0;
	for (char i = 'A'; i <= 'Z'; i++)
	{
		mp[i] = v[j++];
	}
	for (size_t i = 0; i < s.size(); i++)
	{
		if(mp.count(s[i]))
			s[i] = mp[s[i]];
	}
	cout << s << endl;
}
int main() {
	//	COMinit();
	solv();
	return 0;
}



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

using namespace std;
#define int long long
#define inf 9999999999
#define N 6666
int arr[N];int f[N];
int e[N][N];
int a[N];
struct str{
	int x,y,z;
}st[666666];

signed main(){
	int n,m,k;
	cin>>n>>m>>k;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			if(i==j)
				e[i][j]=0;
			else 
				e[i][j]=inf;
		}
	}
	for(int i=1;i<=k;i++)	
		scanf("%lld",&arr[i]);
	for(int i=1;i<=m;i++){
		int a,b,c;
		scanf("%lld%lld%lld",&a,&b,&c);
		e[a][b]=e[b][a]=c;
	}
	for(int k=1;k<=n;k++){
		for(int i=1;i<=n;i++){
			for(int j=1;j<=n;j++){
				e[i][j]=min(e[i][j],e[i][k]+e[k][j]);
			}
		}
	}
	int ans=inf;
	for(int i=1;i<=k;i++) a[i]=i;
	do{
		int sum=0; 
		for(int i=2;i<=k;i++){
			sum+=e[arr[a[i]]][arr[a[i-1]]];
		}
		ans=min(ans,sum);
	}while(next_permutation(a+1,a+1+k));
	cout<<ans;
    return 0;
}
/*

*/

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

#define rep(i,n) for(int i=0;i<(n); ++i)
#define INF 100000 // 2^31-1
#define MAX_V 100000


using namespace std;

using ll =long long;
using P = pair<int,int>;

string replaceAll(string &replacedStr, string from, string to) {
    unsigned int pos = replacedStr.find(from);
    int toLen = to.length();
 
    if (from.empty()) {
        return replacedStr;
    }
 
    while ((pos = replacedStr.find(from, pos)) != string::npos) {
        replacedStr.replace(pos, from.length(), to);
        pos += toLen;
    }
    return replacedStr;
}
 
int ctoi(const 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 -1;
  }
}

//5
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int gettt(long long int num){
    int digit=0;
if(num<10){
digit=0;
}else{
    while(num>1){
        num /= 10;
        digit++;
    }
}
    return digit;
}

int main() {

ios::sync_with_stdio(false);
cin.tie(0);
int a,b;
cin>>a>>b;
bool l=false;
for(int i=0;i<=a;i++){
if(b==2*i+4*(a-i))l=true;
}
if(l)
cout<<"Yes"<<endl;
else
cout<<"No"<<endl;

}
//double res=10.11;
//printf("%.10f",ans);
//cout << fixed << setprecision(5) <<(n*2)*M_PI << endl;


Measured memory_bytes: 3616
#include<bits/stdc++.h>
#define mt make_tuple
#define mp make_pair
#define pu push_back
#define INF 1000000001
#define MOD 1000000007
#define EPS 1e-6
#define ll long long int
#define ld long double
#define fi first
#define se second
#define all(v) v.begin(),v.end()
#define pr(v) { for(int i=0;i<v.size();i++) { v[i]==INF? cout<<"INF " : cout<<v[i]<<" "; } cout<<endl;}
#define t1(x)                cerr<<#x<<" : "<<x<<endl
#define t2(x, y)             cerr<<#x<<" : "<<x<<" "<<#y<<" : "<<y<<endl
#define t3(x, y, z)          cerr<<#x<<" : " <<x<<" "<<#y<<" : "<<y<<" "<<#z<<" : "<<z<<endl
#define t4(a,b,c,d)          cerr<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<" "<<#c<<" : "<<c<<" "<<#d<<" : "<<d<<endl
#define t5(a,b,c,d,e)          cerr<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<" "<<#c<<" : "<<c<<" "<<#d<<" : "<<d<<" "<<#e<<" : "<<e<<endl
#define t6(a,b,c,d,e,f)          cerr<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<" "<<#c<<" : "<<c<<" "<<#d<<" : "<<d<<" "<<#e<<" : "<<e<<" "<<#f<<" : "<<f<<endl
#define GET_MACRO(_1,_2,_3,_4,_5,_6,NAME,...) NAME
#define t(...) GET_MACRO(__VA_ARGS__,t6,t5, t4, t3, t2, t1)(__VA_ARGS__)
#define _ cerr<<"here"<<endl;
#define __ {ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);}

using namespace std;
template<class A, class B> ostream& operator<<(ostream& out, const pair<A, B> &a){ return out<<"("<<a.first<<", "<<a.second<<")";}
template <int> ostream& operator<<(ostream& os, const vector<int>& v) { os << "["; for (int i = 0; i < v.size(); ++i) { if(v[i]!=INF) os << v[i]; else os << "INF";if (i != v.size() - 1) os << ", "; } os << "]\n"; return os; } 
template <typename T> ostream& operator<<(ostream& os, const vector<T>& v) { os << "["; for (int i = 0; i < v.size(); ++i) { os << v[i]; ;if (i != v.size() - 1) os << ", "; } os << "]\n"; return os; } 


int main()
{
  __;
  int n,m;
  cin >> n >> m;
  cout << (n*(n-1))/2 + (m*(m-1))/2 << endl;
  return 0;
}


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++)

using namespace std;

int k, x;

int main() {
  cin >> k >> x;

  if(k*500 >= x) cout << "Yes";
  else cout << "No";
   
}


Measured memory_bytes: 256
k, n = map(int, input().split())
A_1 = list(map(int, input().split()))

def calc_add(N):
    return N + k

A_2 = list(map(calc_add, A_1))

A_total = A_1 + A_2

min_d = k

i = 0
while i < n:
    if A_total[i + n -1] - A_total[i] <= min_d:
        min_d = A_total[i + n -1] - A_total[i]
    
    i += 1

print(min_d)

Measured memory_bytes: 26080
#include <cstdio>
#include <cstring>
#include <queue>
#include <utility>
using namespace std;
typedef pair<int,int> _P;
typedef pair<_P,int> P;
char M[1000][1001];
bool vst[1000][1000];
int dx[]={1,0,-1,0},dy[]={0,1,0,-1};
int W,H,N,X,Y;
int bfs(char C) {
	queue<P> Q;
	Q.push(P(_P(X,Y),0));
	vst[X][Y]=true;
	while(!Q.empty()) {
		P p=Q.front();Q.pop();
		if(M[p.first.second][p.first.first]==C) {
			X=p.first.first,Y=p.first.second;
			return p.second;
		}
		for(int i=0;i<4;i++) {
			int nx=p.first.first+dx[i],ny=p.first.second+dy[i];
			if(0>nx||nx>=W||0>ny||ny>=H)continue;
			if(M[ny][nx]=='X')continue;
			if(vst[nx][ny])continue;
			Q.push(P(_P(nx,ny),p.second+1));
			vst[nx][ny]=true;
		}
	}
	return -1;
}
int main() {
	scanf("%d %d %d",&H,&W,&N);
	for(int i=0;i<H;i++) {
		scanf("%s",M[i]);
	}
	for(int i=0;i<H;i++) {
		for(int j=0;j<W;j++) {
			if(M[i][j]=='S')X=j,Y=i;
		}
	}
	int sum=0;
	for(int i=1;i<=N;i++) {
		memset(vst,0,sizeof(vst));
		sum+=bfs(i+'0');
	}
	printf("%d\n",sum);
}

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


int main()
{
    ios_base::sync_with_stdio(0);
    int n, a, b, sum=0;
    vector<int>v;

    cin >> n >> a >> b;

    for(int j=1; j<=n; j++)
    {
        int c=0;
        int num = j;
        while(num!=0)
        {
            c=c+num%10;
            num= num/10;
        }
        if(c>=a && c<=b)
            {
                v.push_back(j);
            }
    }

    for(vector<int>::iterator it=v.begin(); it <=v.end(); it++)
    {
        sum=sum+*it;
    }

    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 384
#include <iostream>
int main(){
    int A,B;
    std::cin >> A >> B;
    int cnt = 0;
    int current = 0;
    while(B-1 > current){
        current += (A-1);
        cnt++;
    }
    current++;
    if(current-A >= B){
        current -= A;
        cnt--;
    }
    std::cout << cnt << std::endl;
    return 0;
}

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

using namespace std;

#define inf 1<<30
#define llong long long
#define usd unsigned
#define pqueue priority_queue
#define mp make_pair
#define pb push_back
#define fn fill_n
#define P pair<int, int>
struct data{
	int place;
	int cost;

	bool operator<(const data &ri) const{
		return cost < ri.cost;
	}
	bool operator>(const data &ri) const{
		return cost > ri.cost;
	}
};
int nw[9] = {0, 1, 0, -1, -1, 1, 1, -1, 0};
int nh[9] = {1, 0, -1, 0, 1, 1, -1, -1, 0};

// map<int, int> soinsuBunkai(int n){
// 	map<int, int> ret;
// 	ret[1] = 1;

// 	for(int i = 1; i <= n; i++){
// 		int num = i;
// 		while(num % 2 == 0){
// 			ret[2]++;
// 			num /= 2;
// 		}
// 		while(num > 1){
// 			int now = num;
// 			auto sIt = ret.begin();
// 			sIt++;
// 			int start = sIt->first;
// 			for(int i = start; i*i <= num; i += 2){
// 				if(num%i == 0){
// 					ret[i]++;
// 					num /= i;
// 					break;
// 				}
// 			}
// 			if(now != num) continue;
// 			ret[num]++;
// 			num = 1;
// 		}
// 	}


// 	return ret;
// }
map<int, int> soinsuBunkai(int n){
	map<int, int> ret;
	ret[1] = 1;
	for(int i = 1; i <= n; i++){
		int num = i;
		while(num % 2 == 0){
			ret[2]++;
			num /= 2;
		}
		while(num > 1){
			int now = num;
			for(int i = 3; i*i <= num; i += 2){
				if(num%i == 0){
					ret[i]++;
					num /= i;
					break;
				}
			}
			if(now != num) continue;
			ret[num]++;
			num = 1;
		}
	}

	return ret;
}

int main(){
	int N;
	cin >> N;
	auto cnt = soinsuBunkai(N);

	int ans = 0;
	for(auto it = cnt.begin(); it != cnt.end(); it++){
		// cerr << it->first << " " << it->second << endl;
		if(it->second >= 74)
			ans++;
	}
	// cerr << ans << endl;

	auto bend = cnt.end(); bend--;
	auto bbend = bend; bbend--;

	if(cnt.size() >= 2){
		for(auto it1 = cnt.begin(); it1 != bend; it1++){
			auto nbegin = it1; nbegin++;
			for(auto it2 = nbegin; it2 != cnt.end(); it2++){
				// cerr << it1->first << " " << it2->first  << ":" << it1->second << " " << it2->second << endl;
				if(it1->second >= 24 && it2->second >= 2)
					ans++;
				if(it1->second >= 2 && it2->second >= 24)
					ans++;
				if(it1->second >= 14 && it2->second >= 4)
					ans++;
				if(it1->second >= 4 && it2->second >= 14)
					ans++;
			}
		}
	}
	// cerr << ans << endl;

	if(cnt.size() >= 3){
		for(auto it1 = cnt.begin(); it1 != bbend; it1++){
			auto nbegin = it1; nbegin++;
			for(auto it2 = nbegin; it2 != bend; it2++){
				auto tbegin = it2; tbegin++;
				for(auto it3 = tbegin; it3 != cnt.end(); it3++){
					// cerr << it1->first << " " << it2->first  << " " << it3->first <<  ":" << it1->second << " " << it2->second << " " << it3->second << endl;
					if(it1->second >= 2 && it2->second >= 4 && it3->second >= 4)
						ans++;
					if(it1->second >= 4 && it2->second >= 2 && it3->second >= 4)
						ans++;
					if(it1->second >= 4 && it2->second >= 4 && it3->second >= 2)
						ans++;
				}
			}
		}
	}

	cout << ans << endl;

	return 0;
}

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

int mod = 1000000007;
int64_t large = 9223372036854775807;

int main()
{
    int N;
    cin >> N;
    vector<int> P(N);
    vector<int> Q(N);
    for (int i = 0; i < N; i++)
        cin >> P[i], P[i]--;
    for (int i = 0; i < N; i++)
        cin >> Q[i],Q[i]--;

    vector<int> hairetsu(N);
    for (int i = 0; i < N; i++)
        hairetsu[i] = i;

    map<vector<int>, int> list;
    int count = 0;

    do
    {
        list[hairetsu] = count;
        count++;
    } while (next_permutation(hairetsu.begin(), hairetsu.end()));

    cout << abs(list[P] - list[Q]);
}

Measured memory_bytes: 5248
#[allow(dead_code)]
fn is_whitespace(c: &char) -> bool {
    c.is_whitespace()
}

#[allow(dead_code)]
fn is_eol(c: &char) -> bool {
    ['\r', '\n'].contains(c)
}

#[allow(unused_macros)]
macro_rules! input {
    ($var:ident, $($r:tt)*) => {
        input_inner!{$var, $($r)*}
    };

    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        #[allow(unused_mut, unused_variables, bare_trait_objects)]
        let mut next = move |f: &Fn(&char)->bool| -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|f(&c))
                .take_while(|c|!f(&c))
                .collect()
        };
        input_inner!{next, $($r)*};
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; eol ]) => {
        $next(&is_eol).split(' ').map(|x| x.parse::<$t>().unwrap()).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, parser) => {
        $next
    };

    ($next:expr, $t:ty) => {
        $next(&is_whitespace).parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{BinaryHeap, HashMap};

#[allow(dead_code)]
type Graph = Vec<Vec<usize>>;
#[allow(dead_code)]
const M: usize = 1e9 as usize + 9;

fn gcd(a: usize, b: usize) -> usize {
    if b != 0 {
        gcd(b, a % b)
    } else {
        a
    }
}

fn lcm(a: usize, b: usize) -> usize {
    a / gcd(a, b) * b
}

fn main() {
    input! {
        n: usize,
        m: usize,
        a: [usize; n],
    }

    let mut g = a[0] / 2;
    for &x in &a {
        g = lcm(g, x / 2);
        if g > m {
            println!("{}", 0);
            return;
        }
    }

    for &x in &a {
        if (g / (x / 2)) & 1 == 0 {
            println!("0");
            return;
        }
    }

    println!("{}", (m / g) / 2 + (m / g & 1));
}


Measured memory_bytes: 4352
s=input()
a=0
if s=="hi":
    a=1
elif s=="hihi":
    a=1
elif s=="hihihi":
    a=1
elif s=="hihihihi":
    a=1
elif s=="hihihihihi":
    a=1
if a==1:
    print("Yes")
else:
    print("No")
    

Measured memory_bytes: 2940
object Main extends App {
  val in = new java.util.Scanner(System.in)
  val n  = in.nextInt
  val p  = Seq.fill(n)(in.nextInt)

  val answer = (p, p.drop(1), p.drop(2)).zipped.toList.count {
    case (a, b, c) => (a < b && b <= c) || (c < b && b <= a)
  }

  println(answer)
}


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

int main() {
  int a,b;
  int score = 0;
  cin >> a >> b;
  //でかいほうを押す
  if(a >= b){
    score += a;
    a = a-1;
  }else{
    score += b;
    b = b -1;
  }
  if(a >= b){
    score += a;
    a = a-1;
  }else{
    score += b;
    b = b -1;
  }
  cout << score << endl;

  // ここにプログラムを追記
}

Measured memory_bytes: 256
//thank you for plain
#include<stdio.h>
#define N 100
                 
int main(){
int n,x,l[N],d[N+1];
int i,cnt=0;

scanf("%d%d",&n,&x);
d[0]=0;
for(i=0;i<n;i++){
scanf("%d",&l[i]);
d[i+1]=d[i]+l[i];
}
                    
for(i=0;i<=n;i++){
if(d[i]<=x) cnt++;
}
                  
printf("%d",cnt);
                 
                 
return 0;
}

Measured memory_bytes: 128
input()
A = list(map(int,input().split()))
input()
M = list(map(int,input().split()))

d = {}
def solve(i,s):
    if i == len(A):
        d[s] = 0
        return s
        
    solve(i+1,s)
    solve(i+1,s+A[i])
    return 1

solve(0,0)
for a in M:
    if a in d:
        print("yes")
    else:
        print("no")
        

Measured memory_bytes: 7756
from collections import deque
def mbfs(S,H,W):
    dxy=[[1,0],[0,1],[-1,0],[0,-1]]
    while(len(d)!=0):
        h,w,x=d.popleft()
        for t,y in dxy:
            if(0<=h+t<=H-1 and 0<=w+y<=W-1 and S[h+t][w+y]!='#'):
                S[h+t][w+y]='#'
                d.append([h+t,w+y,x+1])
    return x
H,W=map(int,input().split())
A=[list(input()) for i in range(H)]
d=deque()
for i in range(H):
    for j in range(W):
        if(A[i][j]=='#'):
            d.append([i,j,0])
print(mbfs(A,H,W))

Measured memory_bytes: 175964
#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define ll long long
#define maxn 1000005
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
#define inf 1e9
#define eps 1e-10
using namespace std;

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

int main()
{
	//freopen("t1.in","r",stdin);
	ll x,ans=0; cin>>x;
	ans+=(x/500)*1000; x%=500;
	ans+=(x/5)*5; cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define rep2(i,a,n) for(int i = (a);i < (n);i++)
#define rep(i,n) rep2(i,0,n)
#define INF (1LL << 60)
#define vec vector

int main(void){
    int n;
    cin >> n;
    if(n < 600)cout << 8;
    else if(n < 800)cout << 7;
    else if(n < 1000)cout << 6;
    else if(n < 1200)cout << 5;
    else if(n < 1400)cout << 4;
    else if(n < 1600)cout << 3;
    else if(n < 1800)cout << 2;
    else cout << 1;
    cout << endl;
    
    
    
}

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

int main() {
  int x,a,b;
  cin >> x >> a >> b;
  if(a-b >= 0) {
    cout << "delicious" << endl;
  }else if(b-a <= x) {
    cout << "safe" << endl;
  }else{
    cout << "dangerous" << endl;
  }
  return 0;
}

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

#define ll long long
#define debug(x) cerr << fixed << #x << " is " << x << endl;

const int MAX = 100005;

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

	int n, A[MAX];
	memset(A, 0, sizeof A);
	ll tot = 0;
	cin >> n;
	for(int i = 1; i <= n; i++)
	{
		cin >> A[i];
		tot += abs(A[i-1]-A[i]);
	}
	tot += abs(A[n]);
	for(int i = 1; i <= n; i++)
	{
		cout << tot + abs(A[i-1]-A[i+1])-abs(A[i-1]-A[i])-abs(A[i]-A[i+1]) << endl;
	}

	return 0;
}


Measured memory_bytes: 1664
#ifdef DEBUG

#else

#    pragma GCC optimize("O3,no-stack-protector")
#    pragma GCC optimize("unroll-loops")

#    if __cplusplus < 201703L
#        pragma GCC target("avx")
#    else
#        pragma GCC target("avx2")
#    endif

#endif

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;
typedef long double Ld;

using namespace std;
using Graph = vector<vector<Int>>;

const Ld pi = M_PI;
const Int MOD = 1000000007;

Int Floor(Int a, Int b) {
    return (a - (a % b)) / b;
}

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

    const int INF = 1 << 29;

    int n;
    cin >> n;
    vector<int> h(n), dp(n, INF);
    for (int i = 0; i < n; i++) {
        cin >> h[i];
    }

    dp[0] = 0;
    dp[1] = dp[0] + abs(h[1] - h[0]);
    for (int i = 2; i < n; i++) {
        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;

    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define REP(i,N) for(i=0;i<N;i++)
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

int main(void){
  ll N,C; cin >> N >> C;
  vector<PLL> v(N+2);
  v[0] = PLL(0,0);
  v[N+1] = PLL(C,0);
  int i;REP(i,N) cin >> v[i+1].first >> v[i+1].second;
  ll pre[N+1],suf[N+1],max_pre[N+1],max_suf[N+1];
  pre[0] = 0;suf[0] = 0;
  max_pre[0] = 0; max_suf[0] = 0;
  REP(i,N){
    pre[i+1] = pre[i] + v[i+1].second;
    suf[i+1] = suf[i] + v[N-i].second;
    max_pre[i+1] = max(max_pre[i],pre[i+1]-v[i+1].first);
    max_suf[i+1] = max(max_suf[i],suf[i+1]-C+v[N-i].first);
  }
  ll maximum = 0;
  REP(i,N+1){
    maximum = max(maximum, pre[i] - 2ll*v[i].first + max_suf[N-i]);
    maximum = max(maximum, suf[i] - 2ll*(C - v[N-i+1].first) + max_pre[N-i]);
  }
  cout << maximum << endl;
  return 0;
}


Measured memory_bytes: 4992
using System;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;
using Debug = System.Diagnostics.Debug;
using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions;
using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute;


static class P
{
    static void Main()
    {
        var n = int.Parse(Console.ReadLine());
        var a = Console.ReadLine().Split().Select(int.Parse).ToArray();
        Console.WriteLine(Min(Solve(a, 1), Solve(a, -1)));
    }
    static long Solve(int[] a, int target)
    {
        long res = 0;
        var accum = 0;
        for (int i = 0; i < a.Length; i++)
        {
            accum += a[i];
            if (accum * target <= 0)
            {
                res += Abs(target - accum);
                accum = target;
            }
            target *= -1;
        }
        return res;
    }
}


Measured memory_bytes: 30044
#include<bits/stdc++.h>
using namespace std;
const long long MOD = 1e9+7;
#define rep(i,n) for(int i=0;i<n;++i)
typedef long long int ll;
typedef unsigned long long ull;
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
typedef pair<ll,ll> P;

int main()
{
    int n;
    cin>>n;
    
    vector<int> L(n);
    rep(i,n) cin>>L[i];

    if(n<3){
        cout<<0<<endl;
        return 0;
    }
    int cnt=0;
    rep(i,n-2)for(int k=i+1;k<n-1;k++)for(int t=k+1;t<n;t++)
    {
        if(L[i]+L[k]>L[t] && L[t]+L[k]>L[i] && L[i]+L[t]>L[k])
        {
            if(L[i]!=L[k]&&L[i]!=L[t]&&L[k]!=L[t])cnt++;
            //cout<<i+1<<" "<<k+1 <<" "<<t+1<<endl;
        }

    }
    cout<<cnt<<endl;
    return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n, m , c;
    cin >> n >> m >> c;
    vector<int> b(m);
    for(int i = 0; i < m; i++) cin >> b[i];
    vector<vector<int>> a(n, vector<int>(m));
    for(int i = 0; i < n; i++) {
        for(int j = 0; j < m; j++){
            cin >> a[i][j];
        }
    }
    int ans = 0;
    for(int i = 0; i < n; i++){
        int res = 0;
        for(int j = 0; j < m; j++){
            res += a[i][j] * b[j];
        }
        if(res + c > 0) ans += 1;
    }
    cout << ans ;
}


Measured memory_bytes: 256
def main():
    numbers = list(map(int, input().split()))
    answer = 0
    if numbers[0] == numbers[1]:
        answer = numbers[2]
    elif numbers[1] == numbers[2]:
        answer = numbers[0]
    else:
        answer = numbers[1]
    print(answer)


if __name__ == '__main__':
    main()



Measured memory_bytes: 3060
#include <stdio.h>
int main(){
    int n,top,a[110][110],temp;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)for(int j=1;j<=n;j++)scanf("%d",&a[i][j]);
    for(int i=0;i<=n;i++)a[i][0]=a[0][i]=0;
    for(int i=1;i<=n;i++)for(int j=1;j<=n;j++)a[i][j]+=a[i][j-1]+a[i-1][j]-a[i-1][j-1];
    top=a[1][1];
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            for(int k=0;k<i;k++){
                for(int m=0;m<j;m++){
                    temp=a[i][j]-a[k][j]-a[i][m]+a[k][m];
                    if(temp>top)top=temp;
                }
            }
        }
    }
    printf("%d\n",top);
}

Measured memory_bytes: 2796
import java.util.*;

public class Main {
    
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int [] s = new int[n];
        long d = 0;
        for(int i = 0;i < n;i ++) {
            s[i] = in.nextInt();
            s[i] -= i + 1;
        }
        Arrays.sort(s);
        for(int i = 0;i < n;i ++) {
            d += Math.abs(s[i] - s[n / 2]);
        }
        System.out.println(d);
    }
}

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

namespace abc165_b
{
  class Program
  {
    static void Main(string[] args)
    {
      var X = CIn.ReadLong();

      var a = 100L;

      for (int i = 1; i < int.MaxValue; i++)
      {
        a = (long)(a * 1.01);
        if (a >= X)
        {
          Console.WriteLine(i);
          return;
        }
      }
    }
  }

  static class CIn
  {
    private static readonly Queue<string> fieldBuffer = new Queue<string>();

    public static string Read()
    {
      if (fieldBuffer.Count == 0)
      {
        foreach (var field in Console.ReadLine().Split())
        {
          fieldBuffer.Enqueue(field);
        }
      }
      return fieldBuffer.Dequeue();
    }

    public static int ReadInt() => int.Parse(Read());
    public static long ReadLong() => long.Parse(Read());
    public static double ReadDouble() => double.Parse(Read());

    public static string[] ReadStringArray(int n)
    {
      var array = new string[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = Read();
      }
      return array;
    }

    public static int[] ReadIntArray(int n)
    {
      var array = new int[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = ReadInt();
      }
      return array;
    }

    public static long[] ReadLongArray(int n)
    {
      var array = new long[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = ReadLong();
      }
      return array;
    }

    public static double[] ReadDoubleArray(int n)
    {
      var array = new double[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = ReadDouble();
      }
      return array;
    }

    public static char[,] ReadCharMatrix(int h, int w)
    {
      var array = new char[h, w];
      for (var i = 0; i < h; i++)
      {
        var l = Console.ReadLine().ToCharArray();
        for (var j = 0; j < w; j++)
        {
          array[i, j] = l[j];
        }
      }
      return array;
    }
  }
}


Measured memory_bytes: 27840
#include <bits/stdc++.h>
using namespace std;
int main(){
    int a,b,c;
    cin >> a >> b >> c;
    bool flag = false;
    for (int i = 1; i <= b; i++)
    {
        if (a * i % b == c)
        {
            flag = true;
        }
    }
    cout << (flag ? "YES" : "NO") << endl;
}


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

int x[100000];
int r[18][100000];
int main() {
	int n; scanf("%d", &n);
	rep(i, n)scanf("%d", &x[i]);
	int l, q; scanf("%d%d", &l, &q);
	rep(i, n)r[0][i] = upper_bound(x, x + n, x[i] + l) - x - 1;
	for (int i = 1; i < 18; i++) {
		rep(j, n)r[i][j] = r[i - 1][r[i - 1][j]];
	}
	rep(i, q) {
		int a, b; scanf("%d%d", &a, &b); a--; b--;
		if (a > b)swap(a, b);
		int cnt = 0;
		for (int i = 17; i >= 0; i--) {
			if (r[i][a] < b) {
				a = r[i][a]; cnt += 1 << i;
			}
		}
		printf("%d\n", cnt + 1);
	}
}

Measured memory_bytes: 8192
n = int(input())
a = list(map(int,input().split()))
tmp = [0]*61
MOD = 1_000_000_007
for i in range(n):
    for j in range(61):
        mask = 1<<j
        if a[i]&mask>0:
            tmp[j]+=1
ans = 0
for i in range(61):
    mask = 1<<i
    ans = (ans + mask*tmp[i]*(n-tmp[i])) % MOD
print(ans)

Measured memory_bytes: 124592
package main

import (
	"fmt"
)

const MOD = 1000000007

func ModAdd(a, b int64) int64 {
	return (a + b) % MOD
}

func ModMul(a, b int64) int64 {
	return a * b % MOD
}

func ModSub(a, b int64) int64 {
	r := (a%MOD - b%MOD) % MOD
	if r < 0 {
		r += MOD
	}
	return r
}

func ModDiv(a, b int64) int64 {
	return a % MOD * ModInv(b) % MOD
}

func ModPow(a, n int64) int64 {
	var r int64 = 1
	for n > 0 {
		if n&1 == 1 {
			r = r * a % MOD
		}
		a = a * a % MOD
		n >>= 1
	}
	return r
}

func ModInv(a int64) int64 {
	var b, u, v int64 = MOD, 1, 0
	for b > 0 {
		t := a / b
		a -= t * b
		a, b = b, a
		u -= t * v
		u, v = v, u
	}
	u %= MOD
	if u < 0 {
		u += MOD
	}
	return u
}

type Q struct {
	idx, value int
	index      int
}

type QS []*Q

func (p QS) Len() int           { return len(p) }
func (p QS) Less(i, j int) bool { return p[i].value > p[j].value }
func (pq QS) Swap(i, j int) {
	pq[i], pq[j] = pq[j], pq[i]
	pq[i].index = i
	pq[j].index = j
}

func (pq *QS) Push(x interface{}) {
	n := len(*pq)
	item := x.(*Q)
	item.index = n
	*pq = append(*pq, item)
}

func (pq *QS) Pop() interface{} {
	old := *pq
	n := len(old)
	item := old[n-1]
	old[n-1] = nil  // avoid memory leak
	item.index = -1 // for safety
	*pq = old[0 : n-1]
	return item
}
func main() {
	var N int
	fmt.Scanf("%d\n", &N)
	fmt.Println(N * N * N)

}


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

const int INF = 1e9;

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

    int n, k, q;
    cin >> n >> k >> q;
    vector<int> a(n + 1);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    a[n] = -INF;

    int ans = INF;
    for (int i = 0; i < n; i++) {
        // a[i] から取る
        vector<int> b(n + 1), cand;
        for (int j = 0; j <= n; j++) {
            b[j] = a[j];
        }
        int left = -1, right = -1;
        for (int j = 0; j <= n; j++) {
            if (b[j] >= a[i]) {// a[i] 以上だけの区間を探す
                if (left == -1) {
                    left = j;
                    right = j + 1;
                } else {
                    right = j + 1;
                }
            } else {
                if (right - left >= k) {// [left, right) の中で小さい方から right - left - k + 1 個を取り除く候補に追加
                    sort(b.begin() + left, b.begin() + right);
                    for (int l = 0; l < right - left - k + 1; l++) {
                        cand.push_back(b[left + l]);
                    }
                }
                left = -1;
                right = -1;
            }
        }
        sort(cand.begin(), cand.end());
        if (cand.size() >= q) {
            ans = min(ans, cand[q - 1] - cand[0]);
        }
    }

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

Measured memory_bytes: 256
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#define MAXN 705
using namespace std;

typedef pair<int,int> pii;

int N, M, col[MAXN], a, b, vs[2], dp[2][MAXN], ans;
vector <int> G[MAXN];
bool B[MAXN][MAXN], FAIL = false, cur = 0, pre = 1;
vector<pii> P;

void dfs(int x, int c) {
    col[x] = c;
    vs[c]++;
    for (auto y : G[x]) {
        if (col[y] == -1) dfs(y, !c);
        if (col[y] == col[x]) FAIL = true;
    }
}

int cal(int x) {
    return x * (x-1) / 2;
}

int main() {
    scanf("%d%d",&N,&M);
    for (int i=0;i<M;++i) {
        scanf("%d%d",&a,&b);
        B[a][b] = B[b][a] = 1;
    }
    for (int i=1;i<=N;++i)
        for (int j=i+1;j<=N;++j)
            if (!B[i][j]) {
                G[i].push_back(j);
                G[j].push_back(i);
            }
    memset(col,-1,sizeof(col));
    for (int i=1;i<=N;++i)
        if (col[i] == -1) {
            vs[0] = vs[1] = 0;
            dfs(i, 0);
            P.push_back(pii(vs[0],vs[1]));
        }
    if (FAIL) {
        printf("-1\n");
    }
    else {
        dp[pre][0] = 1;
        for (auto p : P) {
            //printf("(%d, %d)\n", p.first, p.second);
            memset(dp[cur],0,sizeof(dp[cur]));
            for (int i=p.first;i<=N;++i) dp[cur][i] |= dp[pre][i-p.first];
            for (int i=p.second;i<=N;++i) dp[cur][i] |= dp[pre][i-p.second];
            cur = !cur;
            pre = !pre;
        }
        ans = cal(N);
        for (int i=1;i<=N;++i)
            if (dp[pre][i]) ans = min(ans, cal(i) + cal(N-i));
        printf("%d\n",ans);
    }
}












Measured memory_bytes: 3200
N,M,C = gets.split.map(&:to_i)
B = gets.split.map(&:to_i)
A = []
N.times{ A << gets.split.map(&:to_i)}
x = 0

N.times{|i|
  	count = 0
	M.times{|j|
  		count += B[j]*A[i][j]
    }
  	x += 1 if count + C > 0
}

puts x


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

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

  for (int i = 0; i < S.size(); i++){
    if (i > K - 1){
      cout << "..." << endl;
      return 0;
    }
    else
    {
      cout << S.at(i);
    }
    
  }
  if (S.size() <= K) cout << "" << endl;
}


Measured memory_bytes: 3560
#include <bits/stdc++.h>
#define io() ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); srand(time(NULL));
 
using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

signed main(){
    io();    
    int n; cin >> n;
    vector<int> v(n);
    for(int i = 0; i < n; ++i){
        cin >> v[i];
    }
    sort(v.begin(), v.end());
    int ans = 0;
    int middle = n / 2;
    return cout << v[middle] - v[middle - 1] << '\n', 0;  
}

Measured memory_bytes: 3704
import itertools

in1 = int(input())
in2 = [input().strip().rsplit(" ") for i in range(2)]
count = 0 
for i in itertools.permutations(range(1, in1+1)):
    if in2[0] == list(map(str, i)):
      ans1 = count
    if in2[1] == list(map(str, i)):
      ans2 = count

    count += 1

print(abs(ans2 - ans1))

Measured memory_bytes: 3064
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <stdio.h>
using namespace std;

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

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

	int N;
	cin >> N;
	int cMax = 100 / 4;
	int dMax = 100 / 7;
	for (int i = 0; i <= cMax; i++) {
		for (int j = 0; j <= dMax; j++) {
			if (N == i * 4 + j * 7) {
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;
	return 0;
}


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

#define REP(i,n) for (int i = 0; i < (n); i++)
#define ALL(obj) (obj).begin(), (obj).end()
typedef long long ll;

using namespace std;

int n;

int main(){
    cin>>n;
    int stem=0;
    for(int i=3;i<n+1;i++){
        if(i==3){
            stem=4;
        }else if(i%2==1){
            stem=stem+2*(i-1);
        }else{
            stem=stem+2*(i-2);
        }
    }
    cout<<stem/2<<endl;
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            if(n%2==0){
                if(i+j!=n-1){
                    cout<<i+1<<" "<<j+1<<endl;
                }
            }else{
                if(i+j!=n-2){
                    cout<<i+1<<" "<<j+1<<endl;
                }
            }
        }
    }
}


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

int sx, sy, tx, ty;
int main(){
  cin >> sx >> sy >> tx >> ty;
  int x = tx - sx + 1;
  int y = ty - sy + 1;
  string str;
  //1回目
  str += 'L';
  for(int i=0; i<y; i++){
    str += 'U';
  }
  for(int i=0; i<x; i++){
    str += 'R';
  }
  str += 'D';

  //2回目
  for(int i=0; i<x-1; i++){
    str += 'L';
  }
  for(int i=0; i<y-1; i++){
    str += 'D';
  }

  //3回目
  str += 'D';
  for(int i=0; i<x; i++){
    str += 'R';
  }
  for(int i=0; i<y; i++){
    str += 'U';
  }
  str += 'L';

  //4回目
  for(int i=0; i<y-1; i++){
    str += 'D';
  }
  for(int i=0; i<x-1; i++){
    str += 'L';
  }

  printf("%s\n", str.c_str());
  // LUUULLDLDDDRRUUULDDL
  // UURDDLLUUURRDRDDDLLU
  // LUUUULLLLDLLLDDDDRRRRUUUULDDDLLL
  // UURRURRDDDLLDLLULUUURRURRDDDLLDL

  return 0;
}


Measured memory_bytes: 256
using System;

class A
{
	static void Main()
	{
		var h = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
		Console.WriteLine((h[0] + h[1]).CompareTo(h[2] + h[3]) switch { 1 => "Left", 0 => "Balanced", _ => "Right" });
	}
}


Measured memory_bytes: 27524
import sys

sys.setrecursionlimit(10**7)
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり
def LI2(): return list(map(int,sys.stdin.readline().rstrip()))  #空白なし
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())  #空白あり
def LS2(): return list(sys.stdin.readline().rstrip())  #空白なし

S = LS2()
T = LS2()

ans = 0
for i in range(len(S)):
    if S[i] != T[i]:
        ans += 1

print(ans)

Measured memory_bytes: 76636
def f(x,y,z):
    ans=0
    for p in x:
        for q in y:
            if p<q and 2*q-p in z: ans+=1
            elif q<p and 2*p-q in z: ans+=1
    return ans

n,s=int(input()),input()
r,g,b=set(),set(),set()
for i in range(n):
    if s[i]=="R": r.add(i)
    elif s[i]=="G": g.add(i)
    else: b.add(i)
print(len(r)*len(g)*len(b)-(f(r,g,b)+f(r,b,g)+f(g,b,r)) )

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

int main()
{
	int n;
	long long sum=0;
	cin>>n;
	
	for(int i=1;i<=n;i++)
	   if(i%3!=0&&i%5!=0)
	     sum+=i;
	     
	cout<<sum;
	
} 

Measured memory_bytes: 3620
#include <iostream>
#include <fstream>
#include <string>

using namespace std;

int main(){
#ifdef CIN
	ifstream cin("input.txt");
	ofstream cout("output.txt");
#endif

	int i, j;

	j = 1;

	while (true)
	{
		cin >> i;
		if (i == 0)
			break;
		cout << "Case " << j << ": " << i << endl;
		j++;
	}


	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#define rep(i, n) for(i = 0; i < n; i++)
#define rrep(i, n) for(i = n - 1; i >= 0; i--)
#define int long long
using namespace std;

string s;
int k;

signed main() {
	int i, j;
	
	cin >> s >> k;
	
	int n = s.length();
	
	if (s[0] != s[n - 1]) {
		int len = 1;
		int cst = 0;
		for (i = 1; i < n; i++) {
			if (s[i - 1] != s[i]) {
				cst += len / 2;
				len = 1;
			}
			else {
				len++;
			}
		}
		cst += len / 2;
		cout << cst * k << endl;
		return 0;
	}
	
	//s[0] == s[n - 1]
	rep(i, n) if (s[i] != s[0]) break;
	rrep(j, n) if (s[j] != s[n - 1]) break;
	
	int l = i;
	int r = j;
	if (l >= r) {
		cout << n * k / 2 << endl;
		return 0;
	}
	
	int len = 1;
	int cst = 0;
	for (i = l + 1; i <= r; i++) {
		if (s[i - 1] != s[i]) {
			cst += len / 2;
			len = 1;
		}
		else {
			len++;
		}
	}
	cst += len / 2;
	
	int aida = (l + n) - r - 1;
	int cst2 = aida / 2;
	
	int cst3 = (n - (r + 1)) / 2;
	int cst4 = l / 2;
	
	cout << cst2 * (k - 1) + cst * k + cst3 + cst4 << endl;
	return 0;
}

Measured memory_bytes: 256
import math

X = int(input())

for k in range(X,0,-1):
    for i in range(2,int(math.sqrt(k))+2,1):
        tmp = i
        tmp = tmp*i
        while tmp <= k:
            if tmp ==k:
                print(k)
                exit()
            tmp = tmp*i
print(1)

Measured memory_bytes: 65932
s = input()
n = len(s)
r = 'Yes'
for i in range(len(s)//2):
    if not s[i]==s[len(s)-1-i]:
        r = 'No'
        break
s_ = s[:(n-1)//2]
for i in range(len(s_)//2):
    if not s_[i]==s_[len(s_)-1-i]:
        r = 'No'
        break
s_ = s[(n+3)//2-1:]
for i in range(len(s_)//2):
    if not s_[i]==s_[len(s_)-1-i]:
        r = 'No'
        break
print(r)

Measured memory_bytes: 3064
#include <stdio.h>

int main(){
  int x,y,r;
  scanf("%d%d",&x,&y);
  
  if( x < y){
    r = y;
    y = x;
    x = r;

  }
       
    while( y > 0){
      r = x % y;
      x = y;
      y = r;
	  }
    printf("%d\n",x);
    
    




  return 0;
}


Measured memory_bytes: 2052
N, K = [int(i) for i in input().split()]

ab = [[int(i) for i in input().split()] for _ in range(N)]

length = 0
sorted_ab = sorted(ab, key=lambda x:x[0])

for x in sorted_ab:
    length += x[1]
    if length >= K:
        output = x[0]
        break
    
print(output)

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

bool f(string S) {
  int N = S.size();
  return S.substr(0, N / 2) == S.substr(N / 2);
}

int main() {
  string S;
  cin >> S;
  S.pop_back();
  while (!f(S)) S.pop_back();
  cout << S.size() << "\n";
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
long long dp[51][51][3000] = {};

void add(long long &a, long long b) {
    a = (a + b) % MOD;
}

int main() {
    int N, K; cin >> N >> K;
    dp[0][0][0] = 1;
    for(int n=0; n<N; ++n) {
        for(int x=0; x<N; ++x) {
            for(int k=0; k<=K; ++k) {
                int nk = k + 2 * x;
                add(dp[n + 1][x + 1][nk], dp[n][x][k]);
                add(dp[n + 1][x][nk], dp[n][x][k] * (2 * x + 1));
                if(x > 0) add(dp[n + 1][x - 1][nk], dp[n][x][k] * x * x);
            }
        }
    }
    cout << dp[N][0][K] << endl;
}

Measured memory_bytes: 60032
#include<stdio.h>

int search(int A[],int n,int key){
  int i=0;
  A[n]=key;
  while(A[i]!=key)i++;
  return i!=n;
}

int main(){
  int i,n,A[10000+1],q,key,sum=0;

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

  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&key);
    if(search(A,n,key))sum++;
  }
  printf("%d\n",sum);
  return 0;
}



Measured memory_bytes: 2048
n=int(input())
a = [int(i) for i in input().split()]
s=0
for i in range(n):
  if i%2==0:
    s+=a[i]
  else:
    s-=a[i]
print(s,end=" ")
s=s//2
for i in range(0,n-1):
  s=(a[i]-s)*2
  print(s,end=" ")
  s=s//2

Measured memory_bytes: 14616
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
const ll mod = 1e9 + 7;

int main(){
    int n, m;
    cin >> n >> m;
    vector<int> s(n), t(m);
    for(int i = 0; i < n; i++)  cin >> s[i];
    for(int i = 0; i < m; i++)  cin >> t[i];
    vector<vector<ll>> dp(n+1, vector<ll>(m+1, 0));
    for(int i = 0; i <= n; i++) dp[i][0] = 1;
    for(int j = 0; j <= m; j++) dp[0][j] = 1;
    ll ans = 0;
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= m; j++){
            dp[i][j] = (dp[i-1][j]+dp[i][j-1]-dp[i-1][j-1]+mod)%mod;
            if(s[i-1] == t[j-1]){
                dp[i][j] += dp[i-1][j-1];
                dp[i][j] %= mod;
            }else{
                // do nothing
            }
        }
    }

    cout << dp[n][m] << endl;
    return 0;
}

Measured memory_bytes: 31616
A, B, K = map(int, input().split())
ans = set()

i = 0
tmp = A
while i < K and tmp <= B:
    ans.add(tmp)
    tmp += 1
    i += 1

i = 0
tmp = B
while i < K and A <= tmp:
    ans.add(tmp)
    tmp -= 1
    i += 1

for i in sorted(ans):
    print(i)


Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#define int long long
using namespace std;

signed main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; ++i) cin >> A[i];
  
  vector<int> B(N + 1);
  for (int i = 0; i < N; ++i) ++B[A[i]];
  int ans = 0;
  for (int i = 1; i < N + 1; ++i) ans += B[i] * (B[i] - 1) / 2;
  
  for (int i = 0; i < N; ++i) {
    int x = ans;
    x -= B[A[i]];
    ++x;
    cout << x << endl;
  }
  return 0;
}

Measured memory_bytes: 5760
ans = 0
while True:
    x = input()
    x = x.split(" ")
    if x[1] == "?": break
    if x[1] == "+":
        ans = int(x[0]) + int(x[2])
    elif x[1] == "-":
        ans = int(x[0]) - int(x[2])
    elif x[1] == "*":
        ans = int(x[0]) * int(x[2])
    elif x[1] == "/":
        ans = int(x[0]) / int(x[2])
    print("%d" % ans)

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

int main()
{
  int ans=1,n,k;
  cin>>n>>k;
  for(int i=1; i<=n; i++)
  {
    if(ans>k)ans+=k;
    else ans*=2;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256