akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;

typedef unsigned long ul;
typedef long long ll;
typedef pair<ul, ul> P;
map<int, int> dp;
#define REP(i, n) for (int i = 0; i < n; i++)

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  int K;
  cin >> N >> K;
  int ans = 0;
  while (N > 0) {
    N /= K;
    ++ans;
  }
  cout << ans << endl;

  return 0;
}


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

void solve(long long N, std::vector<std::string> S, std::vector<long long> P)
{
    vector<pair<pair<string, ll>, ll>> list;
    rep(i, N){
        list.push_back(make_pair(make_pair(S[i], -P[i]), i + 1));
    }
    sort(list.begin(), list.end());
    rep(i, N){
        // cout << list[i].first.first << " "<< list[i].first.second << " " << list[i].second << endl;
        cout << list[i].second << endl;
    }
}

// Generated by 1.1.6 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);
    std::vector<std::string> S(N);
    std::vector<long long> P(N);
    for (int i = 0; i < N; i++) {
        std::cin >> S[i];
        scanf("%lld", &P[i]);
    }
    solve(N, std::move(S), std::move(P));
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<string>
#include<cmath>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
using namespace std;
#define rep(i,ra,re) for((i)=ra;(i)<(re);(i)++)
#define _rep(i,ra,re) for((i)=ra;(i)>(re);(i)--)
#define rep_(i,ra,re) for((i)=ra;(i)<=(re);(i)++)
#define _rep_(i,ra,re) for((i)=ra;(i)>=(re);(i)--)
#define put(n) cout << n << " "; 
#define puts(n) cout << n << endl;
#define pu(n) cout << n;
#define mod 1000000007
#define ll long long 
int i,j,k,l;
static const int MAX_N=10e5;
vector<pair<int,int> > P;
int main(void){
	int N,M;cin >> N >> M;
	rep(i,0,N){
		int a,b;cin >> a >> b;
		P.push_back(make_pair(a,b));
	}sort(P.begin(),P.end());
	
	priority_queue<int> Q;
	long ans=0;
	int j=0;
	rep_(i,1,M){
		while(1){
			if(j>=N)break;
			int day=P[j].first;
			int val=P[j].second;
			if(day>i)break;
			Q.push(val);
			j++;
		}
		if(!Q.empty()){
			ans+=Q.top();
			Q.pop();
		}
	}puts(ans);
	
	return 0;
}


Measured memory_bytes: 1908
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+10;
int n,m,a[N],sm,j;
int cmp(int x,int y)
{
	return x>y;
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",&a[i]);
	sort(a+1,a+n+1);m=a[n];j=1;
	if(a[1]<0&&a[n]>=0)
	{
		for(j=1;a[j]<0&&a[j+1]<0;j++)a[n]-=a[j];
	}
	//if(a[n]>=0)
	{
		//if(a[1]<0)
		//{int sum=0;
		//	for(int i=1;a[i]<0;i++)a[n]-=a[i],j=i+1;
		//}else j=1;
	}
	if(a[n]<0)sort(a+1,a+n+1,cmp);
	//for(int i=1;i<=n;i++)cout<<a[i]<<" ";cout<<endl;
	sm=a[j];
	for(int i=j+1;i<n;i++)
	sm-=a[i];
	printf("%d\n",abs(a[n]-sm));sm=a[j];
	for(int i=1;i<j;i++)
	{
		//if(a[n]>=0)
		printf("%d %d\n",m,a[i]);
		m-=a[i];
	}
	
	for(int i=j;i<n-1;i++)
	printf("%d %d\n",sm,a[i+1]),sm-=a[i+1];
	if(a[n]<sm)swap(a[n],sm);
	printf("%d %d",a[n],sm);
}


Measured memory_bytes: 2304
program AtCoder_Beginner_Contest_999
  implicit none
  character(3) :: n
  integer :: i
  read(*,*) n
  do i = 1, 3
    n(i:i) = achar(106-ichar(n(i:i)))
  end do
  write(*,'(a)') n
end program AtCoder_Beginner_Contest_999

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

int main(){
  ll a; double b;
  cin >> a >> b;
  ll ib = b*100+0.5;
  a *= ib;
  a /= 100;
  printf("%lld\n", a);
  return 0;
}

Measured memory_bytes: 3720
n,k=map(int,input().split())
a=list(map(int,input().split()))
ans=float("inf")
for i in range(2**n):
    bit=[(i>>j)&1 for j in range(n)]
    if sum(bit)==k and bit[0]==1:
        cost=0
        kijun=a[0]
        for j in range(1,n):
            if bit[j]==0:
                kijun=max(kijun,a[j])
            elif a[j]>=kijun+1:
                kijun=a[j]
            else:
                cost+=kijun+1-a[j]
                kijun+=1
        ans=min(ans,cost)
print(ans)

Measured memory_bytes: 43356
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		long[] a = new long[n];
		long sum = 0;
		for (int i = 0; i < n; i++) {
			a[i] = Integer.parseInt(sc.next());
			sum += a[i];
		}
		String[] ans = new String[2 * n];
		int c  = 0;
		if (sum >= 0) {
			for (int i = 1; i < n; i++) {
				int index = 0;
				long max = Integer.MIN_VALUE;
				for (int j = 0; j < n; j++) {
					if (a[j] > max) {
						max = a[j];
						index = j;
					}
				}
				while (a[i] < a[i - 1]) {
					a[i] += max;
					ans[c++] = String.valueOf(index + 1) + " " + String.valueOf(i + 1);
				}
			}
		}
		else {
			for (int i = n - 2; i >= 0; i--) {
				int index = 0;
				long min = Integer.MAX_VALUE;
				for (int j = 0; j < n; j++) {
					if (a[j] < min) {
						min = a[j];
						index = j;
					}
				}
				while (a[i] > a[i + 1]) {
					a[i] += min;
					ans[c++] = String.valueOf(index + 1) + " " + String.valueOf(i + 1);
				}
			}
		}
		System.out.println(c);
		for (int i = 0; i < c; i++)
			System.out.println(ans[i]);
	}
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define ri register
#define int long long
#define E (n+1)
using namespace std; const int N=200010, Mod=1e9+7;
inline int read()
{
    int s=0, w=1; ri char ch=getchar();
    while(ch<'0'||ch>'9') { if(ch=='-') w=-1; ch=getchar(); }
    while(ch>='0'&&ch<='9') s=(s<<3)+(s<<1)+(ch^48), ch=getchar();
    return s*w;
}
int res,n,a[N],A,b;
signed main()
{
    n=read(); A=read(), b=read();
    for(ri int i=1;i<=n;i++) a[i]=read();
    a[0]=a[1];
    for(ri int i=1;i<=n;i++) res+=min(b,(a[i]-a[i-1])*A);
    printf("%lld\n",res);
    return 0;
}

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

int main() {
    string a, b;
    cin >> a >> b;
    string s = a + b;
    int k = stoi(s);
    if (k == int(sqrt(k)) * int(sqrt(k))) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
import java.util.*;
public class Main
{
  public static void main(String aegs[])
  {
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    int k=sc.nextInt();
    double arr[]=new double[n];
    for(int i=0;i<n;i++)
      arr[i]=sc.nextDouble();
    double max,sum=0;
    int cntr=0;
    for(int i=0;i<k;i++)
    sum+=arr[i];
    max=(sum+k)/2;
    for(int i=k;i<n;i++)
    {
      sum+=arr[i]-arr[i-k];
      if((sum+k)/2>max)
      max=(sum+k)/2;
    }
    System.out.println(max);
  }
}


Measured memory_bytes: 160040
#include <cstdio>
#include <algorithm>
using namespace std;
int main(){
  int X,A,B;
  scanf("%d %d %d",&X,&A,&B);
  if(A>=B) printf("delicious\n");
  else if(A+X>=B) printf("safe\n");
  else printf("dangerous\n");
  return 0;
}


Measured memory_bytes: 128
#import sys
#input = sys.stdin.readline
from math import sqrt
def main():
    S = int( input())
    x = 10**9
    y = (S+x-1)//x
    s = 1
    t = x*y-S
    print(0,0,x,s,t, y)
if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <iostream>
#include<queue>
#include<stack>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<cstring>
#include<string>
#include<cassert>
#include<cmath>
#include<climits>
#include<iomanip>
#include<bitset>
#include<unordered_map>

using namespace std;

#define MOD 998244353
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define rep(i,j,n) for(ll (i)=(j);(i)<(n);(i)++)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define ll long long
#define ull unsigned long long
#define all(hoge) (hoge).begin(),(hoge).end()
typedef pair<ll, ll> P;
const long long INF = 1LL << 60;
typedef vector<ll> Array;
typedef vector<Array> Matrix;


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

//グラフ関連
struct Edge {//グラフ
	ll to, cap, rev;
	Edge(ll _to, ll _cap, ll _rev) {
		to = _to; cap = _cap; rev = _rev;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

void add_edge(Graph& G, ll from, ll to, ll cap, bool revFlag, ll revCap) {
	G[from].push_back(Edge(to, cap, (ll)G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}

void Dijkstra(Graph& G, ll s, Array& d) {//O(|E|log|V|)
	d.resize(G.size());
	REP(i, d.size())d[i] = INF;
	d[s] = 0;
	priority_queue<P, vector<P>, greater<P>> q;
	q.push(make_pair(0, s));
	while (!q.empty()) {
		P a = q.top();
		q.pop();
		if (d[a.second] < a.first)continue;
		REP(i, G[a.second].size()) {
			Edge e = G[a.second][i];
			if (d[e.to] > d[a.second] + e.cap) {
				d[e.to] = d[a.second] + e.cap;
				q.push(make_pair(d[e.to], e.to));
			}
		}
	}
}

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

	ll n, m;
	cin >> n >> m;
	Graph g(n);
	REP(i, m) {
		ll l, r, c;
		cin >> l >> r >> c;
		l--; r--;
		add_edge(g, l, r, c, false, 0);
	}

	REP(i, n-1) {
		add_edge(g, i + 1, i, 0, false, 0);
	}

	Array d;
	Dijkstra(g,0,d);

	if (d[n - 1] != INF) {
		cout << d[n - 1] << endl;
	}
	else {
		cout << -1 << endl;
	}

	return 0;
}

Measured memory_bytes: 10620
#include <iostream>
#define ll long long
#define MOD 998244353
#define MAX 300000

#define MODA(a, b) ((a + b) % MOD)
#define MODS(a, b) (((a - b) % MOD + MOD) % MOD)
#define MODM(a, b) (a * b % MOD)

using namespace std;

ll power_mod(ll x, ll n) {
  if (n == 0)
    return 1;
  else if (n % 2)
    return MODM(x, power_mod(x, n - 1));
  else
    return power_mod(MODM(x, x), n / 2);
}

ll facts[MAX + 1];
ll rfacts[MAX + 1];

ll comb_mod(ll n, ll k) {
  if (n < k) return 0;
  if (n == 0 || k == 0 || n == k) return 1;
  return MODM(MODM(facts[n], rfacts[k]), rfacts[n - k]);
}

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

int main() {
  ll n, a, b, k;
  cin >> n >> a >> b >> k;

  ll f = 1;
  facts[0] = 1;
  for (int i = 1; i <= MAX; i++) {
    f = MODM(f, i);
    facts[i] = f;
    rfacts[i] = power_mod(f, MOD - 2);
  }

  ll lcm = a * b / gcd(a, b);
  ll r = k % lcm;

  ll acnt = 0, bcnt;
  ll tmp = k;
  while (true) {
    if (tmp % b == 0) {
      bcnt = tmp / b;
      break;
    }
    acnt++;
    tmp -= a;
  }

  ll lcm_a = lcm / a;
  ll lcm_b = lcm / b;
  ll acnt2 = acnt;
  ll bcnt2 = bcnt;
  ll res = 0;
  for (int i = 0; bcnt2 >= 0; i++) {
    res = MODA(res, MODM(comb_mod(n, acnt2), comb_mod(n, bcnt2)));
    acnt2 += lcm_a;
    bcnt2 -= lcm_b;
  }

  cout << res << endl;
}

Measured memory_bytes: 4992
#include<iostream>
#include<string>
using namespace std;
int main(){
  string S;
  cin>>S;
  int ans=1;
  int leng=S.size();
  int i=0;
  while(i<leng && ans==1){
    if(i%2==0){
      if(S[i]=='L')ans=0;
    }
    else{
      if(S[i]=='R')ans=0;
    }
    i++;
  }
  if(ans==0)cout<<"No"<<endl;
  else cout<<"Yes"<<endl;
}

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

int main()
{
  int H, W;
  cin >> H >> W;
  
  rep(i, W + 2)
  {
    printf("#");
  }
  printf("\n");
  
  rep(i, H)
  {
    printf("#");
    string a;
    cin >> a;
    cout << a;
    printf("#\n");
  }
  
  rep(i, W + 2)
  {
    printf("#");
  }
  printf("\n");
}


Measured memory_bytes: 256
//chiragjn
#include <bits/stdc++.h>
#define ll long long
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define gibe_de_fast_io_b0ss ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;
const ll mod = 1e9 + 7;
const ll INF = 0x7FFFFFFFFFFFFFFF/2;

ll get_sum(ll* cache_row, int l, int r) {
	ll tmp;
	tmp = cache_row[r];
	if(l > 0) {
		tmp = tmp - cache_row[l - 1];
	}
	return (tmp + mod) % mod;
}

int main(){
    gibe_de_fast_io_b0ss;
    int n, k;
    ll tmp;
    cin>>n>>k;
	vector<int> array(n + 1);
	for(int i = 1; i <= n; i++) {
		cin>>array[i];
	}
	
	if(k == 0) {
		cout<<"1";
		return 0;
	}
	
	ll cache[101][100001] = {{0}};
	cache[0][0] = 1LL;
	tmp = cache[0][0];
	
	for(int j = 1; j <= k; j++) {
		tmp = (tmp + cache[0][j]) % mod;
		cache[0][j] = tmp;
	}
	
	int max_candies = 0;
	for(int i = 1; i <= n; i++) {
		max_candies = min(k, max_candies + array[i]);
		for(int j = 0; j <= max_candies; j++) {
			cache[i][j] = get_sum(cache[i - 1], j - array[i], j);
		}
		tmp = cache[i][0];
		for(int j = 1; j <= k; j++) {
			tmp = (tmp + cache[i][j]) % mod;
			cache[i][j] = tmp;
		}
	}
	cout<<get_sum(cache[n], k, k);
	
    return 0;
}


Measured memory_bytes: 79232
use proconio::input;

fn distance((x, y): (isize, isize)) -> isize {
    x.pow(2) + y.pow(2)
}

fn lower_bound(x: &isize, y: &isize) -> std::cmp::Ordering {
    use std::cmp::Ordering::*;
    match x.cmp(y) {
        Equal => Greater,
        Greater => Greater,
        Less => Less,
    }
}

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

    a.sort_by(|&x, &y| lower_bound(&distance(x), &distance(y)));
    let ans = a.binary_search_by(|&x| lower_bound(&distance(x), &(d*d+1)))
        .unwrap_or_else(|x| x);
    println!("{}", ans);
        

}


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

using namespace std;
using ll = long long;
using ld = long double;

//#define int long long
//signed main(){
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin >> n;
    if(n==25) cout << "Christmas" << "\n";
    else if(n==24) cout << "Christmas Eve" << "\n";
    else if(n==23) cout << "Christmas Eve Eve" << "\n";
    else cout << "Christmas Eve Eve Eve" << "\n";
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
// Need start
#include<vector>
// Need end
using namespace std;
typedef long long ll;

// Copy start
template <class T>
class Bellmanford {
    private:
        T identity;
        struct edge {
            int from, to;
            T cost;
        };
        vector<edge> edges;
        vector<T> dist;
        vector<bool> in_negative;
        bool negative_loop;
    public:
        Bellmanford(int node_num, int edge_num, T _identity):identity(_identity), dist(vector<T>(node_num, _identity)), in_negative(vector<bool>(node_num, false)) {}
        void add_edge(int from, int to, T cost) {
            edge e = {from, to, cost};
            edges.push_back(e);
        }
        void _calc_shortest_path(int start_node) {
            dist[start_node] = 0;
            int n = (int)dist.size();
            int m = (int)edges.size();
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < m; j++) {
                    edge now_edge = edges[j];
                    if (dist[now_edge.from] != identity && dist[now_edge.to] > dist[now_edge.from] + now_edge.cost) {
                        dist[now_edge.to] = dist[now_edge.from] + now_edge.cost;
                        if (i == n - 1) {
                            negative_loop = true;
                            in_negative[now_edge.to] = true;
                        }
                    }
                    if (in_negative[now_edge.from]) {
                        in_negative[now_edge.to] = true;
                    }
                }
            }
        }
        void calc_shortest_path(int start_node) {
            // for the function "in_negative_loop", run _calc_shortest_path twice
            _calc_shortest_path(start_node);
            _calc_shortest_path(start_node);
        }
        bool have_negative_loop() {
            return negative_loop;
        }
        bool in_negative_loop(int node) {
            // return if node is in negative loop
            return in_negative[node];
        }
        T get_dist(int node) {
            return dist[node];
        }
};
// Copy end

int main() {
    // This sample is Atcoder Beginners Contest 61 D
    ll N, M;
    cin >> N >> M;
    ll a, b, c;
    Bellmanford<ll> bell(N, M, 1LL << 50);
    for (int i = 0; i < M; i++) {
        cin >> a >> b >> c;
        a--, b--;
        bell.add_edge(a, b, -c);
    }
    bell.calc_shortest_path(0);
    ll ans = -bell.get_dist(N - 1);
    if (bell.have_negative_loop() && bell.in_negative_loop(N - 1)) {
        cout << "inf" << endl;
    }
    else {
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 256
N = int(input())
X_array = list(map(int, input().split()))

ans = 10 ** 10


for p in range(1, 101):
    power = 0
    for x in X_array:
        # print(x,p,power)
        power += ((x-p) ** 2)
    if power < ans:
        ans = power


print(ans)


Measured memory_bytes: 38896
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <deque>
#include <queue>//for queue and priority_queue
#include <fstream>
#include <iomanip>
#include <stack>
#include <algorithm>
#include <set>
#include <map>
#include <list>
#define endl "\n"
typedef long long ll;
using namespace std;
void Lancer() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); }
bool isPrime(ll n){
	if (n == 2 || n == 3 || n == 5)
		return true;
	else if (n % 2 == 0 || n % 3 == 0 || n % 5 == 0 || n == 1)
		return false;
	else {
		for (int i = 5; i <= sqrt(n); i += 2){
			if (n%i == 0)
				return false;
		}
		return true;
	}
}

//char arr[57][57];
int main(){
	Lancer();
	ll a, b, d, sq;
	cin >> a >> b;
	d = log10(b) + 1;
	a *= pow(10, d);
	a += b;
	sq = sqrt(a);
	sq *= sq;
	if (sq == a) cout << "Yes";
	else cout << "No";
	cout << endl;
	return 0;
}


Measured memory_bytes: 3900
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <vector>
using namespace std;

const double PI = acos(-1.0);

int main() {
    cout << fixed << setprecision(12);

    double A, B, X;
    cin >> A >> B >> X;
    X /= A;
    double answer = 0;

    if (X > A * B / 2) {
        X -= A * B / 2;
        answer = atan2(B - 2 * X / A, A);
    } else {
        answer = PI / 2 - atan2(2 * X / B, B);
    }

    answer *= 180 / PI;
    cout << answer << '\n';
}


Measured memory_bytes: 384
N=int(input())
*V,=map(int,input().split())
from collections import Counter

c1=Counter(V[0::2]).most_common()+[(0,0)]
c2=Counter(V[1::2]).most_common()+[(0,0)]
if c1[0][0]!=c2[0][0]:
    print(N-c1[0][1]-c2[0][1])
else:
    print(min(N-c1[0][1]-c2[1][1],N-c1[1][1]-c2[0][1]))

Measured memory_bytes: 25344
#include <stdio.h>

void printOddLine(int w)
{
	for(int i = 0; i < w; i++) {
		if (i % 2) {
			putchar('#');
		} else {
			putchar('.');
		}
	}
	putchar('\n');
}
void printEvenLine(int w)
{
	for(int i = 0; i < w; i++) {
		if (i % 2) {
			putchar('.');
		} else {
			putchar('#');
		}
	}
	putchar('\n');
}
void printBoard(int h, int w)
{
	for(int i = 0; i < h; i++) {
		if (i % 2) {
			printOddLine(w);
		} else {
			printEvenLine(w);
		}
	}
	putchar('\n');
}

int main()
{
	while(1) {
	  int h, w;
	  scanf("%d %d", &h, &w);
	  if (h == 0 && w == 0) break;
	  printBoard(h, w);
	}
	return 0;
}


Measured memory_bytes: 2608
sx, sy, tx, ty = map(int, input().split())
dx, dy = tx - sx, ty - sy

path1 = 'R' * dx + 'U' * dy
path2 = 'L' * dx + 'D' * dy
path3 = 'D' + 'R' * (dx + 1) + 'U' * (dy + 1) + 'L'
path4 = 'U' + 'L' * (dx + 1) + 'D' * (dy + 1) + 'R'

answer = path1 + path2 + path3 + path4
print(answer)

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

int main()
{
    //入力
    int x;
    cin >> x;
    //abcdに分割
    vector<int> a(4);
    for (int i = 3; i >= 0; i--)
    {
        a[i] = x % 10;
        x /= 10;
    }

    //bit全探索
    // 3ビットのビット列をすべて列挙する

    vector<char> op(3);
    for (int tmp = 0; tmp < (1 << 3); tmp++)
    {
        bitset<3> s(tmp);
        //0->+,1->-
        int sum = a[0];
        rep(i, 3)
        {
            if (s.test(i))
            {
                op[i] = '-';
                sum -= a[i + 1];
            }
            else
            {
                op[i] = '+';
                sum += a[i + 1];
            }
        }
        if (sum == 7)
        {
            break;
        }
    }

    rep(i, 3)
    {
        cout << a[i] << op[i];
    }
    cout << a[3] << "=7" << endl;
}

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

int main(){
  string s;
  cin >> s;
  
  bool flag = true;
  for(int i=0;i<s.length()/2;i++){
    if(s[i]!=s[s.length()-1-i]){
      flag=false;
      // cout << "a" << i << endl;
    }
  }
  int tmp=(s.length()-1)/2;
  for(int i=0;i<tmp/2;i++){
    if(s[i]!=s[tmp-1-i]){
      flag=false;
      // cout << "tmp:" << tmp << endl;
      // cout << "b" << i << endl;
    }
  }
  tmp = (s.length()-(s.length()+3)/2);
  for(int i=0;i<tmp/2;i++){
    if(s[i+(s.length()+3)/2-1]!=s[s.length()-1-i]){
      flag=false;
      // cout << "tmp:" << tmp << endl;
      // cout << "c" << i << endl;
    }
  }

  if(flag)cout << "Yes";
  else cout << "No";
  return 0;
}


Measured memory_bytes: 256
n=int(input())
A =list(map(int,input().split()))
k = sum(A)/2
cnt=0
cnt2 = 0
for i in A:
    k -= i
    if k < 0:
        cnt += abs(k) 
        cnt2 += k + i
        break
    
print(int(2*min(cnt,cnt2)))     

Measured memory_bytes: 26060
//              *           ***********    *********         *         **           *
//            *   *         *         *       ***          *   *       *  *         *
//          *       *       *         *       ***         *     *      *    *       *
//         ***********      ***********       ***        *********     *      *     *
//        *           *     *  *              ***       *         *    *        *   *
//       *             *    *     *           ***      *           *   *          * *
//       *             *    *        **    *********   *           *   *           **

//       **********                *                ***********       ***********
//       *        *              *   *              *                 *
//       *      *              *       *            *                 *
//       * * *                ***********           ***********       ***********
//       * * *               *           *                    *                 *
//       *      *           *             *                   *                 *
//       *        *        *               *                  *                 *
//       **********        *               *        ***********       ***********

#include <iostream>
#include <algorithm>
#include <math.h>
#include <iomanip>
#include <cstdio>
#include <numeric>
#include <float.h>
#include <stdio.h>
#include <chrono>
#include <cmath>
#include <vector>
#include <deque>
#include <queue>
#include <stack>

#define ll long long
#define dou double
#define Turbo std::ios::sync_with_stdio(false)

using namespace std ;

// Until 256 ;)

int main () {
    Turbo ;
    int n , a , b ;
    cin >> n >> a >> b ;
    cout << min (a , b) << ' ' ;
    if (a + b > n) {
        cout << (a + b) - n << '\n' ;
    }
    else {
        cout << 0 << '\n' ;
    }
    return 0 ;
}


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

int main()
{
    int x, n;
    cin >> x >> n;
    if (n == 0)
    {
        cout << x << "\n";
        return 0;
    }
    set<int> a;
    for (int i = 0; i < n; i++)
    {
        int temp;
        cin >> temp;
        a.insert(temp);
    }
    int ans = 100;
    int index = 0;
    for (int i = 0; i <= 101; i++)
    {
        if (a.find(i) != a.end())
        {
            continue;
        }
        else
        {
            if (ans > abs(x - i))
            {
                ans = abs(x - i);
                index = i;
            }
        }
    }
    cout << index << "\n";
}


Measured memory_bytes: 3636
#include<stdio.h>

int main( ) {
	int a;
	int b;

	scanf("%d %d",&a ,&b);
	if( a == b ) {
		printf("a == b\n");
	} else if( a < b ) {
		printf("a < b\n");
	} else if( a > b ) {
		printf("a > b\n");
	}

	return 0;
}

Measured memory_bytes: 580
import java.lang.*;
import java.io.*;
import java.util.*;


public class Main {
	
	public static void main(String[] args) throws java.lang.Exception {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskA solver = new TaskA();
		solver.solve(in, out);
		out.close();
	}
}

class TaskA {
	
	public void solve(InputReader in, PrintWriter out) {
		int n = in.nextInt();
		String op = in.next();
		int x = 0, ans = x;
		
		for (int i=0; i<n; ++i) {
			if (op.charAt(i) == 'I')
				++x;
			else
				--x;
			ans = Math.max(ans, x);
		}
		
		out.println(ans);
	}
}

class InputReader {
	public BufferedReader reader;
	public StringTokenizer tokenizer;
	
	public InputReader(InputStream stream) {
		reader = new BufferedReader(new InputStreamReader(stream), 32768);
		tokenizer = null;
	}
	
	public String next() {
		while (tokenizer==null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(reader.readLine());
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}
	
	public int nextInt() {
		return Integer.parseInt(next());
	}
	
	public long nextLong() {
		return Long.parseLong(next());
	}
}


Measured memory_bytes: 21588
#include <stdio.h>

main(){

  int i,j;
  int mini,N,count=0,tmp;
  int A[101];

  scanf("%d",&N);

  for(i=1; i<=N; i++){
    scanf("%d",&A[i]);
  }

  for(i=1; i<=N; i++){
    mini = i;

    for(j=i; j<=N; j++){
      if(A[j] < A[mini]){
	mini = j;
      }
    }
      if(A[i] > A[mini]){
	count++;
	tmp = A[i];
	A[i] = A[mini];
	A[mini] = tmp;
      }

  }
  for(i=1; i<=N; i++){
    printf("%d",A[i]);
    if(i!=N){
      printf(" ");
    }
  }
  printf("\n%d\n",count);

  return 0;

}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
void solveA()
{
  long long a,b,tem;
  cin>>a>>b;
  tem=(a+b);
  if(tem%2==0)
  {
    cout<<tem/2<<endl;
  }
  else
  {
    cout<<"IMPOSSIBLE"<<endl;
  }
}
void solveB()
{
  int n,i,j,count;
  cin>>n;
  int ar[n];
  for(i=0;i<n;i++)
  {
    cin>>ar[i];
  }
  j=1;
  count=0;
  for(i=0;i<n;i++)
  {
    if(ar[i]!=j)
    {
      count++;
    }
    if(count>2)
    {
      cout<<"NO"<<endl;
      return;
    }
    j++;
  }
  cout<<"YES"<<endl;
}
void solveC()
{
  int a,b,x,y;
  cin>>a>>b;
  x=max(a,b);
  y=min(a,b);
  if((x-y)>=2)
  {
    cout<<2*x-1<<endl;
  }
  else
  {
    cout<<x+y<<endl;
  }
}
void solveD()
{
  int n,i,j;
  cin>>n;
  int ar[n];
  for(i=0;i<n;i++)
  {
    cin>>ar[i];
  }
  int count=n;
  for(i=n-1;i>=0;i--)
  {
    for(j=i-1;j>=0;j--)
    {
      if(ar[i]<ar[j])
      {
        count--;
        break;
      }
    }
  }
  cout<<count<<endl;
}
void solveE()
{
  int h,w,x,y,H,W;
  cin>>H>>W;
  cin>>h>>w;
  x=h*W;
  y=(H-h)*w;
  cout<<(H*W)-(x+y)<<endl;
}
void solveF()
{
  int n,m,c,i,j;
  cin>>n>>m>>c;
  int b[m];
  int ar[n][m];
  for(i=0;i<m;i++)
  {
    cin>>b[i];
  }
  for(i=0;i<n;i++)
  {
    for(j=0;j<m;j++)
    {
      cin>>ar[i][j];
    }
  }
  int count=0;
  int sum;
  for(i=0;i<n;i++)
  {
    sum=0;
    for(j=0;j<m;j++)
    {
      sum=sum+ar[i][j]*b[j];
    }
    if((sum+c)>0)
    {
      count++;
    }
  }
  cout<<count<<endl;
}
void solveG()
{
  
}
int main()
{
  solveA();
  //solveB();
 // solveC();
 //solveD();
 //solveE();
// solveF();
  return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define mk make_pair
#define f first
#define s second

using namespace std;

const int N = 1e5 + 5;

vector<int> g[N];
int dp[N];
bool u[N];

int dps(int v)
{
    if(dp[v] != -1)
        return dp[v];
    for(int i = 0;i < g[v].size(); ++i)
    {
        int x = g[v][i];
        dp[v] = max(dps(x) + 1, dp[v]);

    }
    if(dp[v] == -1)
        dp[v] = 0;
    return dp[v];
}

int32_t main()
{
    ios::sync_with_stdio(false);
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
    int n, m;
    cin >> n >> m;
    for(int i = 0;i < m; ++i)
    {
        int x, y;
        cin >> x >> y;
        --x; --y;
        g[x].push_back(y);
    }
    for(int i = 0;i < n; ++i)
        dp[i] = -1;
    int ans = 0;
    for(int i = 0;i < n; ++i)
    {
        ans = max(ans, dps(i));
    }
    cout << ans;
}

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

int main(){
  int N,A,B;
  cin >> N >> A >> B;
  string str;
  cin >> str;
  
  int foreign=0;
  int pass = 0;
  for(int i=0;i<N;i++){
    if(str.at(i)=='c'){
      cout << "No" << endl;
    }else if(str.at(i)=='a'){
      if(pass < A+B){
        cout << "Yes" << endl;
        pass++;
      }else{
        cout << "No" << endl;
      }
    }else{
      if(pass < A+B && foreign < B){
        cout << "Yes" <<endl;
        pass++;
        foreign++;
      }else{
        cout << "No" << endl;
      }

    }
  }
}

Measured memory_bytes: 896
def multival(): return map(int,input().split())
def data(N=1): return [list(map(int,input().split())) for _ in range(N)]
mod = 10**9 + 7
inf = float("inf")

N,M = multival()
nemat = [[0]*N for _ in range(N)]
ans = 0
for _ in range(M):
    a,b = multival()
    a -= 1; b-= 1
    nemat[a][b] = 1
    nemat[b][a] = 1

def dfs(now=0,visited=[False]*N):
    visited[now] = True
    if all(visited) is True:
        global ans
        ans += 1
    for ne in range(N):
        if nemat[now][ne] == 1 and visited[ne] is False:
            dfs(ne,visited[:])
            # visited[:]
            # n方向に分かれて探索する際にそれぞれ別のvisitedを持たせる
            # そうしなければ例えばsample1では 1->2->3 と進んで全てに訪問済みの印が付く
            # 次に1->2と進もうとしても2は既にTrueに更新済みなので探索が終了してしまう

dfs()
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
const ll mod = 1000000007;
const int MAX_N = 10010;

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

    Graph G(n);
    rep(i, n-1) {
        int a, b;
        cin >> a >> b;
        a--;  b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    queue<int> Q;

    vector<int> c(n);
    vector<int> deg(n);
    rep(i, n) {
        cin >> c[i];
        deg[i] = G[i].size();
        if(G[i].size() == 1) {
            Q.push(i);
        }
    }

    sort(c.begin(), c.end());

    vector<int> d(n);
    int sum = 0;    
    rep(i, n) {

        int v = Q.front();
        Q.pop();

        d[v] = c[i];

        if(i < n-1) {
            sum += c[i];
        }

        rep(j, G[v].size()) {
            int to = G[v][j];
            deg[to]--;
            if(deg[to] == 1) {
                Q.push(to);
            }
        }
    }

    cout << sum << "\n";

    rep(i, n) {
        cout << d[i] << " ";
    }

    cout << endl;
    return 0;
}

Measured memory_bytes: 1024
import math
N,M = map(int, input().split())
a = 0
b = 0
if N != 1 and N != 0:
    a = math.factorial(N)/(2*math.factorial(N-2))
if M != 1 and M != 0:
    b = math.factorial(M)/(2*math.factorial(M-2))
print(int(a+b))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, s, n) for(int i = s; i < (int)n; i++)
#define per(i, n) for(int i = n; i >= 0; i--)
#define ROF(i, s, n) for(int i = s; i >= (int)n; i--)
#define FORIT(i, A) for (auto i : A)
#define PRINT(x) cout << (x) << "\n"
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define MP make_pair
#define EACH(i, n) for (__typeof((n).begin()) i = (n).begin(); i != (n).end(); ++i)
#define SZ(a) int((a).size())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define CLR(a) memset((a), 0 ,sizeof(a))
#define dump(x) cout << #x << " = " << (x) << "\n";
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << "\n";
#define sq(n) (n) * (n)
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef priority_queue<int> maxpq;
typedef priority_queue< int, vector<int>, greater<int> > minpq;
static const double EPS = 1e-10;
static const double PI = acos( -1.0 );
static const int mod = 10007;
static const int INF = 1 << 25;
static const LL LL_INF = 1152921504606846976;
static const int dx[] = { -1, 0, 1, 0,  1, -1,  1, -1 };
static const int dy[] = { 0, -1, 0, 1 , 1,  1, -1, -1 };


string a;
stack<string> s;

int main() {
	while ( !!( getline( cin, a ) ) && a != "." ) {
		bool is_yes = true;
		for ( int i = 0; i < a.size(); i++ ) {
			if ( a[ i ] == '(' ) {
				s.push( "(" );
			}
			if ( a[ i ] == '[' ) {
				s.push( "[" );
			}
			if ( a[ i ] == ')' ) {
				if ( !s.size() || s.top() != "(" ) {
					is_yes = false;
					break;
				}
				s.pop();
			}
			if ( a[ i ] == ']' ) {
				if ( !s.size() || s.top() != "[" ) {
					is_yes = false;
					break;
				}
				s.pop();
			}
		}
		if ( is_yes && !s.size() ) {
			printf( "yes\n" );
		}
		else {
			printf( "no\n" );
		}
		while ( s.size() ) {
			s.pop();
		}
	}
	return 0;
}

Measured memory_bytes: 1180
import { readFileSync } from "fs";

const read = () =>
  readFileSync(0, "utf8")
    .split("\n")
    .map((line) => line.split(" "));

const main = (input: string[][]) => {
  const x = input[0][1][0];

  return `A${x}C`;
};

console.log(main(read()));


Measured memory_bytes: 29640
import sys
S = list(sys.stdin.readline().rstrip())
K = int(sys.stdin.readline().rstrip())
res = []
for k in range(K):
    for i in range(len(S)- k):
        res.append("".join(S[i:i+k+1]))
res = list(set(res))
res.sort()
print(res[K - 1])

Measured memory_bytes: 40304
def main():
    N = int(input())
    X = 1
    Y = 1
    Z = 1

    a = [0]*(N+1)

    for x in range(1,101,1):
        if x**2 + Y**2 + Z**2 + x*Y + Y*Z + Z*x > N:
            break
        for y in range(1,101,1):
            if x**2 + y**2 + Z**2 + x*y + y*Z + Z*x > N:
                break
            for z in range(1,101,1):
                if x**2 + y**2 + z**2 + x*y + y*z + z*x <= N:
                    a[x**2 + y**2 + z**2 + x*y + y*z + z*x] += 1
                elif x**2 + y**2 + z**2 + x*y + y*z + z*x > N:
                    break
    for i in range(1,N+1,1):
        print(a[i])

main()


Measured memory_bytes: 9184
#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;
const int N = 105;
int a[N],n;
int main(){
	cin >> n;
	int ans = 0;
	for (int i = 1;i <= n;i++){
		cin >> a[i];	ans += a[i];
	}
	sort(a+1,a+n+1);
	int p = 1;
	while ((a[p] % 10) == 0 && p <= n)	p++;
	if (ans % 10 != 0)	cout << ans;
	else if (p == n+1)	cout << "0";
	else cout << ans-a[p];
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int[] arr = new int[3];
		for (int i = 0; i < arr.length; i++) {
			arr[i] = in.nextInt();
		}
		
		in.close();
		
		int five = 0;
		int seven = 0;

		for (int i = 0; i < arr.length; i++) {
			if (arr[i] == 5) {
				five++;
			} else if (arr[i] == 7) {
				seven++;
			}
		}

		if (five == 2 && seven == 1) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}
	}
}


Measured memory_bytes: 23764
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <stack>
#include <iomanip>
#include <queue>
#include <deque>
#include <sstream>
#include <stdio.h>
#include <string>
#include <cmath>
#include <map>
#include <utility>
using namespace std;

#define s(n) scanf("%d",&n)
#define sc(n) scanf("%c",&n)
#define ss(n) scanf("%s",&n)
#define MOD 1000000007
#define ll long long int
#define vi vector<int>
#define vii vector< vector<int> >
#define PI 3.1415926535897932384626433832795

int main() {
	string s;
	cin >> s;
	vector<bool> was (500,false);
	for(int i = 0; i < s.length(); i++) {
		if(was[s.at(i)]) {
			cout << "no";
			return 0;
		} else {
			was[s.at(i)] = true;
		}
	}
	cout << "yes";
	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,i,k;
    cin>>a;
    int ar[a];
    cin>>k;
    for(i=0; i<a; i++)
    {
        cin>>ar[i];
    }
    sort(ar,ar+a);
 
     int sum=0;
 
     for(i=0; i<k; i++)
    {
        sum+=ar[i];
    }
    cout<<sum<<endl;
 
    return 0;
}

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

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



if(A+B+1>=C){
  printf("%lld\n",B+C);
  return 0;
}
else{
  printf("%lld\n",A+B+B+1);
}
}


Measured memory_bytes: 256
def issubset(x,y):
    #a<<bならtrue
    if len(x)>len(y):
        return False
    for i in range(1,len(x)+1):
        if (x[-i],y[-i])==("1","0"):
            return False
    return True
N,K=map(int,input().split())
A=[0 for i in range(N)]
B=[0 for i in range(N)]
for i in range(N):
    A[i],B[i]=map(int,input().split())
    A[i]=bin(A[i])[2:]
Ks=bin(K)[2:]
Kl=[Ks]
for i,c in enumerate(Ks):
    if c=="1":
        Kl.append(Ks[:i]+"0"+"1"*(len(Ks)-i-1))
ans=0
for k in Kl:
    tmp=0
    for i in range(N):
        if issubset(A[i],k):
            tmp+=B[i]
    ans=max(tmp,ans)
print(ans)


Measured memory_bytes: 74784
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <bitset>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <utility>
#include <set>
#include <map>
#include <tuple> 
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <list>
using namespace  std;
using ll = long long;
using P = pair<ll, ll>;
#define REP(i, n) for(long long (i)=0, i_bound = (long long)(n); (i)<i_bound; ++i)
#define FOR(i, a, b) for(long long (i)=(a); (i)<(b); ++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
const long long MOD = static_cast<long long>(1e9) + 7LL;
const long long INF = 1234567891234567890LL;
signed main(){
    ll N; cin>>N;
    vector<string> G(N);
    REP(i, N) cin>>G[i];
    ll res = 0;
    int a = 0;
    for(int b=0; b<N; b++){
        bool ok = true;
        for(int i=0; i<N; i++){
            for(int j=i+1; j<N; j++){
                if(G[i][(j+b)%N] != G[j][(i+b)%N]){
                    ok = false;
                    break;
                }
            }
            if(!ok) break;
        }
        if(ok) res++;
    }
    cout << res*N << endl;
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <string.h>
#include <vector>
//s#define rep(i, n) for (int i = 0; i < (n); i++)
#define MAX 10000

using namespace std;

#define ll long long
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define rep(i,a,n) for(int i=a; i<n; i++)
#define r0 return 0
#define INF (int)1e15
#define MOD 1000000007

 int gcd(int a,int b){

   if(a%b == 0)
    return b;
   else
    return gcd(b,a%b);

 }

 int main(){

  long long n,x;

  cin>>n>>x;

  long long a[n+1];

  for(int i=0;i<n;i++)
    cin>>a[i];

  a[n] = x;

  sort(a,a+n+1);

  int ans = a[1]-a[0];

  for(int i=0;i<n;i++){
     ans = gcd(ans,a[i+1]-a[i]);
  }

  cout<<ans<<endl;

 return 0;
 }


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

int     main() {
        long N;
        double T, A;
        cin >>N >>T >>A;
        T *=1000;
        A *=1000;
        long H;
        long TD;
        cin >>H;
        TD=abs(T-H*6-A);
        long I=1;
        for (long i=2; i<=N; i++) {
                cin >> H;
                if (TD>abs(T-H*6-A)) {
                        TD=abs(T-H*6-A);
                        I=i;
                }
        }
        cout << I << endl;
        return 0;
}

Measured memory_bytes: 256
def main():
    S=input()
    k=int(input())
    L=[S[0]]
    N=[]
    prev=S[0]
    num=1
    for s in S[1:]:
        if s!=prev:
            L.append(s)
            N.append(num)
            prev=s
            num=1
        else:
            num+=1
    N.append(num)
    #print(L,N)
    l=len(L)
    if l==1:
        return (len(S)*k)//2
    ans=0
    if L[0]!=L[-1]:
        for num in N:
            ans+=num//2
        return ans*k
    ans+=N[0]//2+N[-1]//2
    tmp=0
    for num in N[1:-1]:
        tmp+=num//2
    ans+=tmp*k
    ans+=(N[0]+N[-1])//2*(k-1)
    return ans
    
if __name__=='__main__':
    print(main())

Measured memory_bytes: 38448
//#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const int INF= 1e9+5;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
int main(){
  ll n;cin>>n;
  vl a(n),b(n),c(n),d(n);
  rep(i,n)cin>>a[i]>>b[i];
  rep(i,n)cin>>c[i]>>d[i];
  vector<P>R(n);
  rep(i,n){
    R[i].first=b[i];R[i].second=a[i];
  }
  vector<P>B(n);
  rep(i,n){
    B[i].first=c[i];B[i].second=d[i];
  }
  sort(R.begin(),R.end());
  reverse(R.begin(),R.end());
  sort(B.begin(),B.end());
  vector<bool>unuse(n,true);
  vector<bool>unuse2(n,true);
  
  ll count=0;
  rep(i,n){
    rep(j,n){
      if(R[j].first<B[i].second && R[j].second<B[i].first && unuse[j] &&unuse2[i]){
        unuse[j]=false;
        unuse2[i]=false;
        count++;
        break;
      }
    }
  }
  cout<<count<<endl;
}
        
    

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<queue>
#include<map>
#include<vector>

using namespace std;

inline int read()
{
  int x=0,f=1;char ch=getchar();
  while (!isdigit(ch)) {if (ch=='-') f=-1;ch=getchar();}
  while (isdigit(ch)) {x=(x<<1)+(x<<3)+ch-'0';ch=getchar();}
  return x*f;
}

const int maxn = 1e5+1e2;

int a[maxn];
int n,k;
long long top,bottle=3;
int main()
{
  scanf("%d",&k);
  for (int i=1;i<=k;i++) a[i]=read();
  if (a[k]!=2){
  	cout<<-1;
  	return 0;
  }
  top=3;
  bottle=2;
  for (int i=k-1;i>=1;i--)
  {
  	 if (bottle>top){
  	 	cout<<-1;
  	 	return 0;
  	 }
  	 if (bottle%a[i]!=0)
	 bottle=bottle+(a[i]-bottle%a[i]);
	 top=(top-top%a[i])+a[i]-1;
	 //cout<<bottle<<" "<<top<<endl;
  }
  if (top<bottle){
  	 	cout<<-1;
  	 	return 0;
	}
  cout<<bottle<<" "<<top;
  return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#include<vector>
#include<iostream>
#include<sstream>
#include<fstream>
#include<list>
#include<deque>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cctype>
#include<cmath>
#include<ctime>
#include<iomanip>
#include<string>
using namespace std;
/*freopen{"input.txt","r",stdin};
freopen{"output.txt","w",stdout};*/
#define mp make_pair
#define pb push_back
const int INF=1000*1000*1000;
const int maxn=2e5; 
typedef long long ll;
typedef long double ld;
typedef pair<int,int>PII;
//priority_queue <int,vector<int>,greater<int> > q1;  //从小到大 
//priority_queue <int,vector<int>,less<int> >q2;  //从大到小 

int main(){
	//ios_base::sync_with_stdio(0);
    //cin.tie(0);
    //cout.tie(0);
    int a,b,c,d;
    scanf("%d%d%d%d",&a,&b,&c,&d);
    while(1){
    	c-=b;
    	if(c<=0){
    		cout<<"Yes";
    	    break;		
		}
    	a-=d;
    	if(a<=0){
    		cout<<"No";
    		break;
		}
	}
    
    return 0;
}



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

int main() {
  int count;
  int length;
  int pos;
  int index;
  int distance;
  
  cin >> count;
  cin >> length;
  
  for(index = 0; index < count; index++)
  {
    cin >> pos;
    
    if (pos > length - pos)
    {
      distance += (length - pos) * 2;
    }
    else
    {
      distance += pos * 2;
    }
  }
  
  cout << distance << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define x first
#define y second
using namespace std;

using f80 = long double;
using f64 = double;
using i64 = unsigned long long;
using pii = pair<int, int>;

const int N = 2048, M = N * N;

bitset<M> a, b;
vector<int> v;

int main() {
#ifdef HOME
	freopen("agc.in", "r", stdin);
	freopen("agc.out", "w", stdout);
#endif
	ios::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	int n, t;

	cin >> n;
	v.resize(n);
	for (auto &i: v)
		cin >> i;

	a = 1;
	b = 0;
	for (int i = 0; i < n; ++i) {
		b = a | (a << v[i]);
		swap(a, b); }

	v.clear();
	for (int i = 0; i < M; ++i) if (a[i])
		v.push_back(i);

	cout << v[v.size() / 2] << endl;

	return 0; }


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

string s1="",s2="";

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

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

typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
#define F first
#define S second

inline int in(){int x, y; y = scanf("%d", &x); return x; }

const int N = -1;
const ld EPS = 1e-12;

bool eq(ld a, ld b){
	return abs(a-b) < EPS;
}

struct PT{
	ld x, y;
	PT (ld x = 0, ld y = 0) : x(x), y(y) {}
	PT operator + (PT ro) const{
		return PT(x+ro.x, y+ro.y);
	}
	PT operator - (PT ro) const{
		return PT(x-ro.x, y-ro.y);
	}
	PT operator * (ld co) const{
		return PT(x*co, y*co);
	}
	PT operator / (ld co) const{
		return PT(x/co, y/co);
	}
	ld operator * (PT ro) const{
		return x*ro.x + y*ro.y;
	}
	ld operator ^ (PT ro) const{
		return x*ro.y - y*ro.x;
	}
};

istream& operator>> (istream &is, PT &p){
	ld val;
	is >> val;
	p.x = val;
	is >> val;
	p.y = val;
	return is;
}

PT operator * (ld co, PT p){
	return p*co;
}

ld len(PT a){
	return sqrt(a*a);
}

PT unit(PT a){
	return a/len(a);
}

PT perp(PT a){
	return PT(-a.y, a.x);
}

PT proj(PT a, PT b, PT c){
	b = b-a, c = c-a;
	return a + (b*c)/(b*b)*b;
}

PT reflect(PT a, PT b, PT c){
	PT d = c;
	b = b-a, c = c-a;
	return d + (c^b)/len(b)*perp(unit(b))*2;
}

int sgn(PT a, PT b, PT c){
	ld cr = (b-a)^(c-a);
	return cr > EPS ? 1 : (cr + EPS < 0 ? -1 : 0);
}

int main(){
	for (int i = in(); i; i--){
		PT a, b, c, d;
		cin >> a >> b >> c >> d;
		b = b-a, d = d-c;
		if (eq(b^d, 0))
			cout << 2 << endl;
		else if (eq(b*d, 0))
			cout << 1 << endl;
		else
			cout << 0 << endl;
	}
	return 0;
}


Measured memory_bytes: 3276
#include<bits/stdc++.h>
using namespace std;
 
#define pb push_back
#define ll unsigned long long
#define maxn 500005
#define fr(i,j,k) for(int i=j;i<k;i++)
#define f(n) fr(i,0,n)
#define f1(n) fr(i,1,n+1)
#define ms(i) memset(i,0,sizeof(i));
#define ms1(i) memset(i,-1,sizeof(i));
#define F first
#define S second
#define all(x) x.begin(), x.end()
const int mod = 1e9 + 7;
#define int long long

int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    string s;
    cin >> s;
    if (s[2] == s[3] && s[4] == s[5]) {
        cout << "Yes\n";
    }
    else {
        cout << "No\n";
    }
}


Measured memory_bytes: 256
/* kadai6_2
   Saikyo_Kazune
*/
#include <stdio.h>
#include <string.h>
 
 
 
 
int main(void){
    //宣言
   int SIZE = 103,length_str;
   char str[SIZE],head,tail,ans[103]={'\0'};
   fgets(str,SIZE,stdin);
   //文字列の長さ(null文字直前までの長さを調べる)
   length_str = strlen(str);
   //改行\nの分を削る
   length_str--;
   //先頭、末尾の文字を取る
   head = str[0];
   tail = str[length_str-1];
   
   //先頭、間の文字数、末尾の文字の順で結合する
   snprintf(ans,103,"%c%d%c",head,length_str-2,tail);
   //出力
   printf("%s\n",ans);
   return 0;
}

Measured memory_bytes: 128