akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <array>
#include <climits> // INT_MAX, LONG_MAX, LLONG_MAX, UINT_MAX, ULONG_MAX, ULLONG_MAX
#include <cmath>
#include <cstdint>
#include <iostream>
#include <map>
#include <string>
#include <vector>

#define INF (INT_MAX >> 1)

using namespace std;

vector<vector<int>> edge;
vector<vector<int>> dist;

int minDist(int n, int start, int end) {
    vector<bool> check(n, false);
    vector<int> d(n, INF);
    d[start] = 0;
    
    for (int i = 0; i < n; i++) {
        int min = INF;
        int now = 0;
        for (int j = 0; j < n; j++) {
            if (!check[j] && min > d[j]) {
                min = d[j];
                now = j;
            }
        }

        if (min == INF)
            break;

        check[now] = true;

        for (size_t j = 0; j < edge[now].size(); j++) {
            int next = edge[now][j];
            int nextd = d[now] + dist[now][j];
            if (nextd < d[next])
                d[next] = nextd;
        }
    }

    return d[end];
}

int minDist(int total, int from, vector<int> rList, map<int, map<int, int>>& rDist) {
    int d = INF;

    if (rList.size() == 0)
        return total;
    
    for (size_t i = 0; i < rList.size(); i++) {
        int dx = 0;
        if (from != -1)
            dx = rDist[from][rList[i]];

        vector<int> rList2 = rList;
        rList2.erase(rList2.begin() + i);

        d = min(d, minDist(total + dx, rList[i], rList2, rDist));
    }

    return d;
}

int main() {
    int N, M, R;
    cin >> N >> M >> R;

    vector<int> rList;

    for (int i = 0; i < N; i++) {
        dist.push_back({});
        edge.push_back({});
    }
 
    for (int i = 0; i < R; i++) {
        int r;
        cin >> r;
        rList.push_back(r - 1);
    }

    for (int i = 0; i < M; i++) {
        int a, b, c;
        cin >> a >> b >> c;
        
        edge[a - 1].push_back(b - 1);
        dist[a - 1].push_back(c);
        edge[b - 1].push_back(a - 1);
        dist[b - 1].push_back(c);
    }

    map<int, map<int, int>> rDist;
    for (size_t i = 0; i < rList.size(); i++)
        for (size_t j = 0; j < rList.size(); j++)
            if (i < j)
                rDist[rList[i]][rList[j]] = rDist[rList[j]][rList[i]] = minDist(N, rList[i], rList[j]);

    cout << minDist(0, -1, rList, rDist) << endl;
    
    return 0;
}


Measured memory_bytes: 640
import numpy
import math


def main():
    S = input()
    Mod = [0 for i in range(2019)]
    Mod[0] = 1
    d = 1
    tmp = 0
    ans = 0
    for c in reversed(S):
        tmp = (d * int(c) + tmp) % 2019
        ans += Mod[tmp]
        #print(tmp, ans)
        Mod[tmp] += 1
        d = (d * 10) % 2019

    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 27444
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;
const int mod = 1e9 + 7;
const int N = 2e5 + 10;
long long f[N][5];
int n, a[N];
int main()
{
    scanf("%d", &n);
    for (int i = 1; i <= n ; i ++)
        scanf("%d", &a[i]);
    for (int i = 0; i < n ; i ++)
    {
        for (int j = 0; j < 5; j ++)
            f[i + 1][j] = 1e18;
        for (int j = 0; j < 5; j ++)
            for (int k = j; k < 5; k ++)
                if (k == 0 || k == 4)
                    f[i + 1][k] = min(f[i + 1][k], f[i][j] + a[i + 1]);
                else
                    if (k == 1 || k == 3)
                    {
                        if (a[i + 1] == 0)
                            f[i + 1][k] = min(f[i + 1][k], f[i][j] + 2);
                        else
                            f[i + 1][k] = min(f[i + 1][k], f[i][j] + (a[i + 1] & 1));
                    } else
                        f[i + 1][k] = min(f[i + 1][k], f[i][j] + ((a[i + 1] & 1) == 0));
    }
    long long ans = 1e18;
    for (int i = 0; i < 5; i++)
        ans = min(ans, f[n][i]);
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 8832
import math

def main():
    a,b,c = map(int,input().split())
    left = 4*a*b
    right = (c-a-b)**2
    if (c-a-b)<0:
        return 'No'

    if left < right:
        return 'Yes'
    else:
        return 'No'

print(main())


Measured memory_bytes: 9032
#include <bits/stdc++.h>
#define REP(i, a, n) for (long long i = (a); i < (long long)(n); ++i)
#define REPC(i, a, n) for (long long i = (a); i <= (long long)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define MATINIT(type, row, col, init)                                          \
  vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T> using VEC = std::vector<T>;
template <class T> using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail> void DUMP(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
template <typename T> ostream &operator<<(ostream &os, vector<T> &vec) {
  os << "{";
  for (auto v : vec)
    os << v << ",";
  os << "}";
  return os;
}
template <typename T> ostream &operator<<(ostream &os, set<T> &s) {
  os << "{";
  for (auto p : s)
    os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, map<T1, T2> &m) {
  os << "{";
  for (auto p : m)
    os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> p) {
  os << "[" << p.first << " " << p.second << "]";
  return os;
}

int main() {
  LL R,D,X;
  cin>>R>>D>>X;
  REP(i,0,10){
    X=R*X-D;
    cout<<X<<endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

int main() {
    int N, L;
    cin >> N >> L;
    string S[110];
    for(int i = 0; i < N; i++) {
        cin >> S[i];
    }
    sort(S, S + N);
    for(int i = 0; i < N; i++) {
        cout << S[i];
    }
    return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

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

	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	ans := 0
	cnt := 0
	bh := 0
	for i := 0; i < n; i++ {
		sc.Scan()
		h, _ := strconv.Atoi(sc.Text())
		if h <= bh {
			cnt++
		} else {
			cnt = 0
		}
		if cnt > ans {
			ans = cnt
		}
		bh = h
	}
	fmt.Println(ans)
}


Measured memory_bytes: 2176
#include<bits/stdc++.h>
using namespace std;
void solve()
{
	int n,k;
	cin>>n>>k;
	vector<int> ht(n,0);
	for (int i = 0; i < n; ++i)
	{
		cin>>ht[i];
	}
    std::vector<int> cost(n,INT_MAX);
    cost[0] = 0;
    cost[1] = abs(ht[0]-ht[1]);
     for (int i = 2; i < n; ++i)
     {  
     	 for (int j = 1; j <= k; j++)
     	 {  
     	 	if(i-j<0)
     	 		break;
     	 	cost[i] = min(cost[i],abs(ht[i]-ht[i-j])+cost[i-j]);
     	 }
     	
     }
     
     
     	cout<<cost[n-1];
     
}
int main()
{  

   
    solve();
    return 0;

 }

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <unordered_set>
#include <unordered_map>
#include <math.h>

using namespace std;

int main()
{
    long long int A, B; cin >> A >> B;
    char C;
    cin >> C;
    int D;
    cin >> D;
    B *= 100;
    B += D;
    long long int X = A*B;
    X /= 100;
    cout << X << endl;

    return 0;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
#include <vector>
using namespace std;
 
int main()
{
  int a,m,q,l,r;
  cin >> a >> m >> q;
  
  int n[502][502] ={};
  
  for(int i = 0; i < m; i++){
    cin >> l >> r;
    n[l][r]++;
  }
  
  for(int i = 1; i <= 500; i++){
    for(int j = i; j <= 500; j++){
      n[i][j] += n[i][j-1];
    }
  }
  
  for(int i = 499; i > 0; i--){
    for(int j = 500; j >= i; j--){
      n[i][j] += n[i+1][j];
    }
  }
  
  for(int i = 0; i < q; i++){
    cin >> l >> r;
    cout << n[l][r] << endl;
  }
  
}

Measured memory_bytes: 1920
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;

#define LEN(x) (int)x.size()
#define ALL(x) x.begin(), x.end()

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int,int>;
using vpii = vector<pii>;

template<typename T, typename M = __gnu_pbds::null_type>
using ordered_set = __gnu_pbds::tree<T, M, less<T>, __gnu_pbds::rb_tree_tag, __gnu_pbds::tree_order_statistics_node_update>;

template<typename T>
const T INF = (is_same<T, int>::value ? 1e9 : 1e18);
const int MOD = 1e9 + 7;
const double EPS = 1e-9;

inline int fcmp(double x, double y)
{ return (x < y + EPS ? (x < y - EPS ? -1 : 0) : 1);}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.precision(10);
    
    string s;
    int n;
    cin >> n >> s;
    
    for(char c : s) cout << char(((c - 'A' + n) % 26) + 'A');
    cout << endl;

    return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
 
 
#define rp(i, k, n) for (int i = k; i < n; i++)
typedef long long ll;
typedef double ld;
 
ll mod = 1e9 + 7ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll inf = 1ll << 60;

int n, m, p;
vector<vector<pair<int, int>>> rpass(3000);
vector<vector<int>> pass(3000);
vector<int> cango(3000);
vector<int> cancome(3000);
vector<int> s;
vector<vector<int>> opt(3000, vector<int>(3000, -1000000000));
int main(){
    cin >> n >> m >> p;
    rp(i, 0, m){
        int a, b, c;
        scanf("%d%d%d", &a, &b, &c);
        rpass.at(b).emplace_back(a, c);
        pass.at(a).emplace_back(b);
    }
    opt.at(0).at(1) = 0;
    
    //1から行ける点の集合
    queue<int> q;
    q.push(1);
    while(!q.empty()){
        int pointer = q.front(); q.pop();
        if(cango.at(pointer) == 0){
            cango.at(pointer) = 1;
            for(auto x: pass.at(pointer)){
                if(cango.at(x) == 0)q.push(x);
            }
        }
    }
    
    //nに行ける点の集合
    queue<int> q2;
    q2.push(n);
    while(!q2.empty()){
        int pointer = q2.front(); q2.pop();
        if(cancome.at(pointer) == 0){
            cancome.at(pointer) = 1;
            for(auto x: rpass.at(pointer)){
                if(cancome.at(x.first) == 0) q2.push(x.first);
            }
        }
    }
    
    rp(i, 1, n+1){
        if(cancome.at(i) and cango.at(i)) s.emplace_back(i);
    }
    
    
   rp(i, 1, n+1){
       for(auto v: s){
           int c = -1000000000;
           for(auto x: rpass.at(v)){
               chmax(c, opt.at(i-1).at(x.first) + x.second - p);
           }
           opt.at(i).at(v) = max(opt.at(i-1).at(v), c);
       }
   }
   for(auto v: s){
       if(opt.at(n).at(v) != opt.at(n-1).at(v)){
           cout << -1 << endl;
           return 0;
       }
   }
   
   if(opt.at(n).at(n) <= 0) cout << 0 << endl;
   else cout << opt.at(n).at(n) << endl;

   return 0;
}




Measured memory_bytes: 37888
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner amir=new Scanner(System.in);
    //System.out.println("Hello World");
    int a=amir.nextInt();
    //System.out.println("Hello World");
    int b=amir.nextInt();
    int area=a*b;
    int perimeter=2*(a+b);
    System.out.println(area+" "+perimeter);
   
    
  
  }
}


Measured memory_bytes: 26040
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>

using namespace std;
typedef long long llint;
#define inf 1e18

llint a,b;
void solve(){
	cin >> a >> b;
	cout << a*b-a-b+1 << endl;
}

int main(int argc, char *argv[]) {
  solve();
  return 0;
}


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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

int H, W;

int main()
{
    ios::sync_with_stdio(false);

    cin >> H >> W;
    vector<string> grid(H);
    rep(i, H) cin >> grid[i];

    vector<vi> res(H, vi(W));
    rep(i, H)
    {
        vector<bool> done(W);
        rep(j, W)
        {
            if (done[j])
                continue;

            if (grid[i][j] == '#')
            {
                res[i][j] = 0;
                continue;
            }

            int k = 0;
            while (j + k < W)
            {
                if (grid[i][j + k] == '#')
                    break;
                k++;
            }

            rep(l, k)
            {
                res[i][j + l] += k;
                done[j + l] = true;
            }
        }
    }

    rep(i, W)
    {
        vector<bool> done(H);
        rep(j, H)
        {
            if (done[j])
                continue;

            if (grid[j][i] == '#')
            {
                res[j][i] = 0;
                continue;
            }

            int k = 0;
            while (j + k < H)
            {
                if (grid[j + k][i] == '#')
                    break;
                k++;
            }

            rep(l, k)
            {
                res[j + l][i] += k;
                done[j + l] = true;
            }
        }
    }

    int ans = 0;
    rep(i, H) rep(j, W) ans = max(res[i][j] - 1, ans);

    cout << ans << endl;
}


Measured memory_bytes: 21120
import sys
from collections import deque
import copy
import math
def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline



def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [N, L] = [int(input_raw[0]), int(input_raw[1])]
    A = [L + i - 1 for i in range(1, N + 1)]

    abs_min_A = sys.maxint
    abs_min_i = 0
    for i in range(N):
        if abs(A[i]) < abs_min_A:
            abs_min_A = abs(A[i])
            abs_min_i = i
    sum1 = 0
    sum2 = 0
    for i in range(N):
        if i != abs_min_i:
            sum2 += A[i]
    print (sum2)



if __name__ == '__main__':
    main()


Measured memory_bytes: 2932
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define fi first
#define se second
#define pb push_back
#define pr pair<int,int>
#define mod 1000000007
#define endl "\n"

int power(int a,int b,int m=mod)
{
	if(b==0)	return 1;
	if(b==1)	return a;
	int res=power(a,b/2,m);
	res=(res*res)%m;
	if(b&1)	res=(res*a)%m;
	return res;
}
int modinv(int a,int m=mod){ return power(a,m-2,m);}
int add(int a,int b,int m=mod){	int c=(a+b);	if(c>=m)	c-=m;	return c;}
int sub(int a,int b,int m=mod){	int c=(a-b);	if(c<0)		c+=m;	return c;}
int mul(int a,int b,int m=mod){	return (a*b)%m;}
//	x<<1 => x*2		x>>1 => x/2;	cout<<flush;
//	cout<<fixed<<setprecision(10)<<ans<<endl;


void solve()
{
	int n;
	cin>>n;
	int a[n],i,maxi=0,ans=0;
	for(i=0;i<n;i++)
	{
		cin>>a[i];
		ans+=max(0ll,maxi-a[i]);
		maxi=max(maxi,a[i]);
	}
	cout<<ans<<endl;
	
}

int32_t main()
{
	ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
	int t=1;//cin>>t;
	for(int i=1;i<=t;i++){	solve();}
	return 0;
}

Measured memory_bytes: 5188
#include<bits/stdc++.h>
using namespace std;
#define int long double
#define mod 1000000007

int32_t main(){
   string s,t; cin>>s>>t;
   int n = s.length(), m = t.length();
   int ans = m;
   for(int i=0 ; i<=n-m ; i++){
      int count=0;
      for(int j=0,k=i ; j<m ; j++,k++)
       if(s[k]==t[j]) count++;
       ans = min(ans,m-count);
   }
     cout<<ans<<"\n";
}

Measured memory_bytes: 3776
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        final Scanner scanner = new Scanner(System.in);
        final int p = scanner.nextInt();
        final int q = scanner.nextInt();
        final int r = scanner.nextInt();

        final int max = Math.max(p, Math.max(q, r));

        System.out.println(p + q + r - max);
    }
}


Measured memory_bytes: 21972
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
//const ll mod=998244353;
const ll mod=1000000007;
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int main(){
  ll d,n;
  cin>>d>>n;
  V<ll> a(n);
  for(int i=0;i<n;i++){
      cin>>a[i];
  }
  ll ans=inf;
  for(int i=0;i<n-1;i++){
      chmin(ans,d-(a[i+1]-a[i]));
  }
  chmin(ans,d-(a[0]+d-a[n-1]));
  cout<<ans<<"\n";
}


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


int main() {
    ll a,b,c;
    cin >> a >> b >> c;
    if(a%2 == 0 || b%2 == 0 || c%2 ==0){
        cout << 0 << endl;
    }else{
        cout << min({a*b,b*c,c*a}) << endl;
    }
    return 0;
}

/*
やっほい！
　　　　　　　やほほい！
　　　　+　　 　*
　　　 ∧∧　　. ∧∞∧　*
*　ヽ(=´ω｀)人(´ω｀*)ﾉ
　.～（ O x.） （ 　 O)～　+
。*　 　∪　　　　∪
*/

Measured memory_bytes: 256
x,k,d=map(int,input().split())
if abs(x) >= k*d:
    print(abs(x)-k*d)
else:
    just=abs(x)//d
    if (k-just)%2==0:
        print(min(abs(abs(x)-just*d),abs(abs(x)-(just+2)*d)))
    else:
        print(min(abs(abs(x)-(just+1)*d),abs(abs(x)-(just-1)*d)))
        

Measured memory_bytes: 9036
#include<stdio.h>

int main(void)
{
	int a, b, c;
	int i;
	int count = 0;

	scanf("%d %d %d", &a, &b, &c);
	for (i = a; i <= b; i++)
	{
		if (c%i == 0)
		{
			count++;
		}
	}
	printf("%d\n", count);
	return 0;
}


Measured memory_bytes: 2108
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <queue>
#include <tuple>
#include <set>
#include <map>

using namespace std;

int main(void) {
    int H, W, K;
    cin >> H >> W >> K;

    vector< vector<char> > c(H, vector<char>(W));
    for(int i=0; i<H; i++) {
        for(int j=0; j<W; j++) {
            cin >> c[i][j];
        }
    }

    int ans = 0;
    for(int bit=0; bit<(1<<(H+W)); bit++) {
        int tmp = 0;
        for(int i=0; i<H; i++) {
            for(int j=0; j<W; j++) {
                if(c[i][j] == '#' && (bit>>i & 1) && (bit>>(H+j) & 1)) ++tmp;
            }
        }
        if(tmp == K) ++ans;
        // for(int i=0; i<H; i++) {
        //     if(bit>>i & 1) {
        //         for(int j=0; j<W; j++) {
        //             if(c[i][j] == "#") tmp++;
        //         }
        //     }
        // }
        // for(int j=H; j<H+W; j++) {
        //     if(bit>>j & 1) 
        // }
    }

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


Measured memory_bytes: 3628
#include <iostream>

using namespace std;

int main()
{
	int N, K, d[9], R[10]={0}, P=0, X, min=0;
	cin>>N>>K;
	X=N;
	for(int i=0; i<K; ++i)
	{
		cin>>d[i];
		if(d[i]==min)
		{
			min++;
		}
	}
	while(X>0)
	{
		R[P]=X%10;
		X-=R[P];
		X/=10;
		P++;
	}
	for(int i=0; i<=P ; ++i)
	{
		if((R[i]==0)&&(i==P))
		{
			break;
		}
		else
		{
			if(R[i]>=10)
	        {
	         	R[i+1]++;
              	for(int t=0; t<=i; ++t)
	          	{
	       	    	R[t]=min;
		   	    }
	       	}
		    for(int j=0; j<K; ++j)
	    	{
		    	if(R[i]==d[j])
		    	{
		    		R[i]++;
		    		if(R[i]>=10)
	                {
	                 	R[i+1]++;
	                	for(int t=0; t<=i; ++t)
	                	{
	                		R[t]=min;
		            	}
	             	}
	             	else
	             	{
		         	   	if(i>0)
		          		{
		              		for(int t=0; t<i; ++t)
	     	     	    	{
	     	     	     		R[t]=min;
			     	    	}
			         	}
			        }
     			}
    		}
    	}
	}
	if(R[P]>0)
	{
		for(int i=P; i>=0; --i)
		{
			cout<<R[i];
		}
	}
	else
	{
     	for(int i=P-1; i>=0; --i)
		{
			cout<<R[i];
		}
	}
	return 0;
}

Measured memory_bytes: 256
#51c
sx,sy,tx,ty = map(int, input().split())

#最初は二点を頂点とする四角の上を通り、二周目はその1つ外を通るルートにする
diff_x = abs(tx - sx) #四角の横
diff_y = abs(ty - sy) #四角の縦

ans = ["R" for _ in range(diff_x)]
ans += ["U" for _ in range(diff_y)]
ans += ["L" for _ in range(diff_x)]
ans += ["D" for _ in range(diff_y)]
ans += ["D"] #ここから2周目。1つ外側へ
ans += ["R" for _ in range(diff_x)]
ans += ["R"] #1つ外側へ
ans += ["U"] #1周目と同じ高さに
ans += ["U" for _ in range(diff_y)]
ans += ["L"] #これでtに到達
ans += ["U"] #1つ外側へ
ans += ["L" for _ in range(diff_x)]
ans += ["L"] #1つ外側へ
ans += ["D"] #1周目と同じ高さに
ans += ["D" for _ in range(diff_y)]
ans += ["R"] #これでゴール

print(str(''.join(ans)))  

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    int N;
    cin >> N;
    vector<ll> a(N);
    for (int i = 0; i < N; i++) {
        int b; cin >> b;
        a[i] = b - (i + 1);
    }

    sort(a.begin(), a.end());
    ll mid;
    if (N % 2) mid = a[N / 2];
    else {
        mid = (a[N / 2] + a[N / 2 - 1]) / 2;
    }
    ll ans = 0;
    for (int i = 0; i < N; i++) {
        ans += abs(a[i] - mid);
    }
    cout << ans << '\n';
}


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

#define int int_fast64_t

signed main() {
  ios_base::sync_with_stdio(false), cin.tie(nullptr);

  string s; cin >> s;
  cout << s.substr(0, 4) << ' ' << s.substr(4, 12) << '\n';
}

/*
 * Local variables:
 * compile-command:"g++ -D_GLIBCXX_DEBUG -g3 -ggdb3 -O0 -Wall -Wextra -std=c++14 a.cc -o a && for f in *.in; do echo \"--- $f -------------\"; ./a <$f; done"
 * end:
 */



Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
#define ll long long
ll ans;
int main()
{  ll n,a[200005];
    cin>>n;
   map<ll,ll>m;
   for(ll i=1;i<=n;i++)
   { cin>>a[i];
     m[i-a[i]]++;
   }
   for(ll i=1;i<=n;i++)
   {  ll x=a[i]+i;
      ans=ans+m[x];
   }
   cout<<ans;
    return 0;
}


Measured memory_bytes: 27784
#include<stdio.h>
#include<math.h>

int main(void)
{
  int a,b;
  scanf("%d%d",&a,&b);

  int i,j,n,m,tmp,cnt=0;
  for(i=a;i<=b;i++){
    tmp = i;
    n = tmp;
    m = 0;
    for(j=1;j<6;j++){
      m += (tmp%10)*(int)pow(10,5-j);
      tmp /= 10;
    }


    if(n==m)
      cnt++;
  }

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


Measured memory_bytes: 2520
import static java.lang.Integer.parseInt;
import static java.lang.Long.parseLong;
import static java.lang.Math.max;
import static java.lang.System.exit;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {

	static class IntMaxTree {

		final int n;
		final int t[];

		IntMaxTree(int n) {
			this.n = n;
			t = new int[2 * n - 1];
		}

		void init(int v[]) {
			for (int i = 0; i < n; i++) {
				t[n - 1 + i] = v[i];
			}
			for (int i = n - 1; i != 0; i--) {
				t[i - 1] = max(t[(i << 1) - 1], t[i << 1]);
			}
		}

		int get(int i) {
			return t[i + n - 1];
		}

		int getMax(int l, int r) {
			int v = Integer.MIN_VALUE;
			for (l += n, r += n; l != r; l >>>= 1, r >>>= 1) {
				if ((l & 1) != 0) {
					v = max(v, t[l++ - 1]);
				}
				if ((r & 1) != 0) {
					v = max(v, t[--r - 1]);
				}
			}
			return v;
		}

		void set(int i, int v) {
			t[(i += n) - 1] = v;
			for (i >>= 1; i != 0; i >>= 1) {
				t[i - 1] = max(t[(i << 1) - 1], t[i << 1]);
			}
		}
	}

	static void solve() throws Exception {
		int n = scanInt(), k = scanInt();
		int p[] = new int[n];
		IntMaxTree minTree = new IntMaxTree(n), maxTree = new IntMaxTree(n);
		for (int i = 0; i < n; i++) {
			p[i] = scanInt();
			minTree.set(i, -p[i]);
			maxTree.set(i, p[i]);
		}
		int ans = 0;
		boolean haveSorted = false;
		int cntSorted = 0;
		for (int i = 0; i < n; i++) {
			if (i == 0 || p[i] > p[i - 1]) {
				++cntSorted;
			} else {
				cntSorted = 1;
			}
			if (i < k - 1) {
				continue;
			}
			if (cntSorted >= k) {
				if (!haveSorted) {
					haveSorted = true;
					++ans;
				}
			} else {
				if (i >= k) {
					int min = -minTree.getMax(i - k + 1, i),
						max = maxTree.getMax(i - k + 1, i);
					if (p[i] > max && p[i - k] < min) {
						continue;
					}
				}
				++ans;
			}
		}
		out.print(ans);
	}

	static int scanInt() throws IOException {
		return parseInt(scanString());
	}

	static long scanLong() throws IOException {
		return parseLong(scanString());
	}

	static String scanString() throws IOException {
		while (tok == null || !tok.hasMoreTokens()) {
			tok = new StringTokenizer(in.readLine());
		}
		return tok.nextToken();
	}

	static BufferedReader in;
	static PrintWriter out;
	static StringTokenizer tok;

	public static void main(String[] args) {
		try {
			in = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintWriter(System.out);
			solve();
			in.close();
			out.close();
		} catch (Throwable e) {
			e.printStackTrace();
			exit(1);
		}
	}
}

Measured memory_bytes: 50164
import static java.lang.Math.*;
import static java.util.Arrays.*;

import java.util.*;
import java.io.*;


public class Main {
	
	ArrayList<Integer> primes;
	int N = 10000000;
	
	void prime() {
		boolean[] p = new boolean[N+1];
		for(int i=2;i<=N;i++) if( !p[i] ) {
			primes.add(i);
			for(int j=2*i;j<=N;j+=i) p[j] = true;
		}
	}
	
	void run() {
		Scanner sc = new Scanner(System.in);
		primes = new ArrayList<Integer>();
		prime();
		
		for(;;) {
			int n = sc.nextInt();
			if( n == 0 ) break;
			int sum = 0;
			for(int i=0;i<n;i++) sum += primes.get(i);
			System.out.println(sum);
		}
	}

	void debug(Object... os) {
		System.err.println(Arrays.deepToString(os));
	}

	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 49400
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin>>s;
    int n=0,m=0;

    for(int i=0;i<=s.size();i++)
    {

        if(s[i]=='+')
        {
           n++;
        }
        if(s[i]=='-')
        {
           m++;
        }

    }
    cout<<n-m<<endl;




}


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

int main(){
int n; int i=0;
cin >> n;
vector<int> d(n);
while(i<n){
    cin >> d.at(i++);
}

sort(d.begin(),d.end());
cout << (d.at(n/2) - d.at((n/2)-1)) << endl;
return 0;
}

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

int memo[1000001][3];

int dp(int a, int b) {
  if(memo[a][b]) {
    return memo[a][b];
  }

  int ret = 1000111000;

  switch(b) {
    case 0:
      for(int i=0; i*i*i<=a; i++) {
        ret = min(ret, dp(a-i*i*i, 1)+i);
      }
      memo[a][b] = ret;
      break;

    case 1:
      for(int i=0; i*i<=a; i++) {
        ret = min(ret, dp(a-i*i, 2)+i);
      }
      memo[a][b] = ret;
      break;

    case 2:
      ret = a;
      memo[a][b] = ret;
      break;
  }

  return ret;
}

int main() {

  int m;
  while(cin >> m, m) {
    cout << dp(m, 0) << endl;
  }

  return 0;
}

Measured memory_bytes: 14824
#define _LIBCPP_DEBUG 0
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll MOD = 1e9+7;

int main(void) {

    ll N,M; cin>>N>>M;
    ll ans = 0;
    if(N*2<=M){
        ans = N + (M-N*2)/4;
    } else{
        ans = M/2;
    }

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

Measured memory_bytes: 256
#include <iostream>
#include <set>
#include <algorithm>
using namespace std;
int main(){
  int n,q;
  set <int> a;

  cin>>n;
  for(int i=0,t;i<n&&cin>>t;i++) a.insert(t);
  cin>>q;
  for(int i=0,k;i<q;i++){
    cin>>k;
    cout<<(a.find(k)!=a.end())<<endl;
  }

  return 0;

}



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

int main(){
	int n;
	cin >> n;
	vector<int> b(n-1);
	rep(i, n-1) cin >> b.at(i);

	vector<int> a(n);
	a.at(0) = b.at(0);
	rep(i, n-1){
		if(b.at(i) < a.at(i)) a.at(i) = b.at(i);
		a.at(i+1) = b.at(i);
	}

	int ans = 0;
	rep(i, n) ans += a.at(i);

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


Measured memory_bytes: 256
$n=<>;
@a=glob<>;
sub check{
	for(0..$n-2){
		if($a[$_]>$a[$_+1]){
			return 0;
		}
	}
	return 1;
}
if(check){
	print "YES";
	exit
}
for$i(0..$n-1){
	for$j($i+1..$n-1){
		($a[$i],$a[$j])=($a[$j],$a[$i]);
		if(check){
			print "YES";
			exit
		}
		($a[$i],$a[$j])=($a[$j],$a[$i]);
	}
}
print "NO";

Measured memory_bytes: 5240
import itertools

N, M, Q = map(int, input().split())
As = list(itertools.combinations_with_replacement(range(1, M + 1), N))

ans = [0]*len(As)
for _ in range(Q):
    a, b, c, d = map(int, input().split())
    for i, A in enumerate(As):
        if A[b-1]-A[a-1] == c:
            ans[i] += d

print(max(ans))


Measured memory_bytes: 25080
#include<bits/stdc++.h>
#define lc id<<1
#define rc id<<1|1
#define int long long
using namespace std;
const int maxn=400005,mod=998244353;
struct tree {
	int l,r,sum,tag;
} t[maxn*4];
int f[maxn],n,m,ans;
void fac() {
	f[n]=1;
	for(register int i=n-1; i>=1; i--) {
		f[i]=f[i+1]*10ll%mod;
	}
	for(register int i=1; i<=n; i++) {
		f[i]=(f[i]+f[i-1])%mod;
	}
}
void build(int id,int l,int r) {
	t[id].l=l,t[id].r=r;
	if(l==r) {
		return;
	}
	int mid=(l+r)/2;
	build(lc,l,mid);
	build(rc,mid+1,r);
}
void pushdown(int id) {
	if(t[id].tag) {
		t[lc].tag=t[rc].tag=t[id].tag;
		t[lc].sum=(f[t[lc].r]-f[t[lc].l-1]+mod)%mod*t[id].tag%mod;
		t[rc].sum=(f[t[rc].r]-f[t[rc].l-1]+mod)%mod*t[id].tag%mod;
		t[id].tag=0;
	}
}
void pushup(int id) {
	t[id].sum=(t[lc].sum+t[rc].sum)%mod;
}
void add(int id,int l,int r,int v) {
	if(t[id].l>r||t[id].r<l) {
		return;
	}
	if(t[id].l>=l&&t[id].r<=r) {
		//cout<<'*'<<l<<' '<<r<<' '<<t[id].sum<<endl;
		t[id].sum=(f[t[id].r]-f[t[id].l-1]+mod)%mod*v%mod;
		t[id].tag=v;
		return;
	}
	pushdown(id);
	add(lc,l,r,v);
	add(rc,l,r,v);
	pushup(id);
}
signed main() {
	int x,y,z;
	scanf("%lld%lld",&n,&m);
	fac();
	build(1,1,n);
	add(1,1,n,1);
	//cout<<ans<<endl;
	for(register int i=1; i<=m; i++) {
		scanf("%lld%lld%lld",&x,&y,&z);
		add(1,x,y,z);
		printf("%lld\n",t[1].sum%mod);
	}
	return 0;
}

Measured memory_bytes: 21776
def pri(s,n): 
    tab=[i for i in range(n+1) if s[i] and i>=2]
    return(tab)
 
s=[True for _ in range(999999+1)]
i=2
while i**2<=999999:
    if s[i]:
        j=i*2
        while j<=999999:
            s[j]=False
            j+=i
    i+=1

while True:
    try:
        print(len(pri(s,int(input()))))
    except:
        break

Measured memory_bytes: 19004
// Problem : 
// 			E - Picking Goods
// 			
// 		
// Contest : AtCoder - AtCoder Beginner Contest 175
// URL : https://atcoder.jp/contests/abc175/tasks/abc175_e
// Memory Limit : 1024 MB
// Time Limit : 3000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define int long long
#define db double
#define mod 1000000007
#define pb push_back
#define pp pair<int,int>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repe(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=b;i>=a;i--)
#define maxn 200005
#define ss second
#define ff first
#define all(a) a.begin(),a.end()
#define lb lower_bound
#define ub upper_bound
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
int inv(int a, int b){
 return 1<a ? b - inv(b%a,a)*b/a : 1;
}
	int dp[3005][3005][4];
	int a[3005][3005];
void solve()
{
	int n,m,k;
	cin >> n >> m >> k;
	memset(dp,0,sizeof(dp));
	memset(a,0,sizeof(a));
	rep(i,0,k)
	{
		int x,y,v;
		cin >> x >> y >> v;
		a[x][y] = v;
	}
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		{
			int maxi = dp[i-1][j][0];
			maxi = max(dp[i-1][j][1],maxi);
			maxi = max(dp[i-1][j][2],maxi);
			maxi = max(dp[i-1][j][3],maxi);
			if(a[i][j] == 0)
			{
				dp[i][j][0]=max(maxi,dp[i][j-1][0]);
				dp[i][j][1]=dp[i][j-1][1];
				dp[i][j][2]=dp[i][j-1][2];
				dp[i][j][3]=dp[i][j-1][3];
			}
			else{
				dp[i][j][0]=max(maxi,dp[i][j-1][0]);
				dp[i][j][1]=max(maxi+a[i][j],dp[i][j-1][0]+a[i][j]);
				dp[i][j][1]=max(dp[i][j][1],dp[i][j-1][1]);
				dp[i][j][2]=max(dp[i][j-1][2],a[i][j]+dp[i][j-1][1]);
				dp[i][j][3]=max(dp[i][j-1][3],a[i][j]+dp[i][j-1][2]);
			}
		}
	}
	int ans = dp[n][m][0];
	ans = max(ans,dp[n][m][1]);
	ans = max(ans,dp[n][m][2]);
	ans = max(ans,dp[n][m][3]);
	cout << ans ;
}
signed main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t=1;
    //cin >> t;
    while(t--)
    solve();
    return 0;
}


Measured memory_bytes: 356384
#define _CRT_SECURE_NO_WARNINGS
#include"bits/stdc++.h"
#define INF          1e9
#define INFLL        1e18
#define EPS          1e-9
#define MOD          998244353
#define REP(i,n)     for(ll i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)    for(ll i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)    for(ll i=(n)-1;i>=0;--i)
#define REPR1(i,n)   for(ll i=(n);i>0;--i)
#define REPC(i,obj)  for(auto i:obj)
#define ALL(obj)     (obj).begin(),(obj).end()
#define SETP(n)      cout<<fixed<<setprecision(n)
#define VV(T,h,w)    move(vector<vector<T>>(h,move(vector<T>(w))))
#define VVI(T,h,w,i) move(vector<vector<T>>(h,move(vector<T>(w,i))))
using namespace std;
using ll = long long;
template<class T = ll>inline T in() { T ret; cin >> ret; return ret; }

int main()
{
    ll n = in(), m = in();
    set<pair<ll, ll>>pass;
    REP(i, m) {
        ll a = in(), b = in();
        pass.insert(make_pair(a, b));
        pass.insert(make_pair(b, a));
    }
    vector<ll>perm; for (ll i = 2; i <= n; ++i)perm.push_back(i);
    ll cnt = 0;
    do {
        perm.push_back(1);
        bool is_ok = true;
        REP(i, n - 1) is_ok &= pass.count(make_pair(perm[i], perm[i + 1])) == 1;
        if (is_ok)++cnt;
        perm.pop_back();
    } while (next_permutation(ALL(perm)));
    cout << cnt << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
    int x, y;
    while(1){
        scanf("%d %d", &x, &y);
        if(x==0 && y==0)break;
        if(x<y){
            printf("%d %d\n", x, y);
        }else{
            printf("%d %d\n", y, x);
        }
    }
    return 0;
}
	




Measured memory_bytes: 2028
""" A
"""
import sys
import math
from functools import reduce
from bisect import bisect_left

def readString():
    return sys.stdin.readline()

def readInteger():
    return int(readString())

def readStringSet(n):
    return sys.stdin.readline().split(" ")[:n]

def readIntegerSet(n):
    return list(map(int, readStringSet(n)))

def readIntegerMatrix(n, m):
    return [lambda _: readIntegerSet(m) for _ in range(0, n)]

def main(S):
    return S + "es" if S.endswith("s") else S + "s"

if __name__ == "__main__":
    _S = readString().rstrip()

    print(main(_S))

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

int f (vector<int> &a, vector<int> &b, int i, int N){
  if (i > N/2)
    return a.at(i);
  
  else {
    int sum = 0;
    for (int j=i*2; j<=N; j+=i){
        sum += b.at(j);
    } 
    
    if ( ( ( sum + a.at(i) ) % 2 ) == 0 )
      return 0;
    else
      return 1;
    
  }
}

int main()
{
  int N;
  cin >> N;
  vector<int> a(N+1);
  
  a.at(0) = 0;
  for (int i=1; i<=N; i++)
    cin >> a.at(i);
  
  vector<int> b(N+1,0);
  
  int cnt = 0;
  for (int i=N; i>=1; i--){
    b.at(i) = f(a, b, i, N);
    if (b.at(i) == 1)
      cnt++;
    
  }
  
  cout << cnt << endl;
  for (int i=1; i<=N; i++)
    if (b.at(i) == 1)
      cout << i << ' ';
  
  return 0; 
}

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

int main() {
    string S;
    int Q, F;
    char C;
    bool front = true; //trueでfrontが前、falseでbackが前
    deque<char> ans;
    cin >> S >> Q;
    rep(i, S.size()) {
        ans.push_back(S[i]);
    }
    rep(i, Q) {
        int t;
        cin >> t;
        if (t == 1) {
            front = !front;
        }
        else if (t == 2) {
            cin >> F >> C;
            if (F == 1) {
                if (front) {
                    ans.push_front(C);
                }
                else if (!front) {
                    ans.push_back(C);
                }
            }
            else {
                if (front) {
                    ans.push_back(C);
                }
                else {
                    ans.push_front(C);
                }
            }
        }
    }
    if (front) {
        while(!ans.empty()) {
            cout << ans.front();
            ans.pop_front();
        } 
        cout << endl;
        return 0;
    }
    else if (!front) {
        while(!ans.empty()) {
            cout << ans.back();
            ans.pop_back();
        }
        cout << endl;
        return 0;
    }
}

Measured memory_bytes: 896
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
    int a, b, c, k, x, y, z;
    cin >> a >> b >> c >> k;
    if(a >= b && a >= c)
    {x = a; y = b; z = c;}
    if(b > a && b >= c)
    {x = b; y = c; z = a;}
    else if(c > a && c > b)
    {x = c; y = a; z = b;}
    while(k > 0)
    {
        k--;
        x = x * 2;
    }
    cout << y + z + x;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
using namespace std;

int main(){
    int n;
    string s;
    cin>>n>>s;
    for(int i=0;i<s.size();i++){
        int x=s[i]-'A';
        x=(x+n)%26;
        char c=x+'A';
        cout<<c;
    }
    cout<<endl;
    return 0;
}

Measured memory_bytes: 3652
#include <iostream>
using namespace std;
void swap(int &a, int &b){
	int buf = a;
	a = b;
	b = buf;
}
int main(){
	int n, a[200000] = {0};
	char str[200010] = {0};
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}
	int count = 0;
	for(int i = 0; i < n; i++){
		if(a[i] != i + 1){
			count++;
		}
	}
	if(count == 0 || count == 1 || count == 2){
		cout << "YES" << endl;
	}else{
		cout << "NO" << endl;
	}
	return 0;
}

Measured memory_bytes: 1024
S = input()

N = len(S)
r = 1
l = 0
pre = 'R'
ans  = [0]*N
rl_ind = 0
for i in range(1,len(S)):
    if S[i] == 'R':
        if pre == 'L':
            if (r+l)%2==0:
                ans[rl_ind] = (r+l)//2
                ans[rl_ind-1] = (r+l)//2
            else:
                if r>l:
                    if r%2==0:
                        ans[rl_ind] = (r+l+1)//2
                        ans[rl_ind-1] = (r+l-1)//2
                    else:
                        ans[rl_ind] = (r+l-1)//2
                        ans[rl_ind-1] = (r+l+1)//2
                else:
                    if l%2!=0:
                        ans[rl_ind] = (r+l+1)//2
                        ans[rl_ind-1] = (r+l-1)//2
                    else:
                        ans[rl_ind] = (r+l-1)//2
                        ans[rl_ind-1] = (r+l+1)//2

            l = 0
            r = 0


        r += 1
    elif l == 0:
        rl_ind = i
        l += 1
    else:
        l += 1
    pre = S[i]

if (r+l)%2==0:
    ans[rl_ind] = (r+l)//2
    ans[rl_ind-1] = (r+l)//2
if (r+l)%2!=0:
    if r>l:
        if r%2==0:
            ans[rl_ind] = (r+l+1)//2
            ans[rl_ind-1] = (r+l-1)//2
        else:
            ans[rl_ind] = (r+l-1)//2
            ans[rl_ind-1] = (r+l+1)//2
    else:
        if l%2!=0:
            ans[rl_ind] = (r+l+1)//2
            ans[rl_ind-1] = (r+l-1)//2
        else:
            ans[rl_ind] = (r+l-1)//2
            ans[rl_ind-1] = (r+l+1)//2


for i in range(N):
    print(ans[i],"",end = "")


print()



        


    


Measured memory_bytes: 5744
import math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10**7)
inf = 10 ** 20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def _I(): return int(sys.stdin.readline())
def _F(): return float(sys.stdin.readline())
def _pf(s): return print(s, flush=True)

N, M = LI()
A, B = [], []
for i in range(M):
    a, b = LI()
    A.append(a)
    B.append(b)

"""
頂点ごとにみる。
その頂点につながっている辺を洗い出す
洗い出した辺の頂点同士がつながっているか確認する
最終的に自分のもとに戻ってこれるか。
dfsで全経路を洗い出す
1とそれ以外が全部つながるか。
2とそれ以外が全部つながるかを調査すればよい
"""

#  def dfs(reached_nodes, lines):
#      print('df', reached_nodes, lines, file=sys.stderr)
#      # 最初に与えられた線からたどっていって、すべての線を洗い出す。すべての頂点が入っていればおK
#      # このノードにつながっている辺をみつける
#      for line in lines:
#          if line[0] in reached_nodes or line[1] in reached_nodes:
#              # 既に到達しているnodeに入っている場合
#              new_lines = [l for l in lines if l != line]
#              if not dfs(reached_nodes + line, new_lines):
#                  # 全部つながることが確認された場合
#                  return False
#      else:
#          # 一回もひかからなかったので終了
#          print('r', reached_nodes, file=sys.stderr)
#          if len(set(reached_nodes)) < N:
#              print('True', file=sys.stderr)
#              # 無理でした。
#              return True
#          else:
#              return False
def dfs(visited_nodes, lines):
    print(visited_nodes, file=sys.stderr)
    if len(set(visited_nodes)) == N:
        print('False',file=sys.stderr)
        return False
    # 現在のノード
    for l in lines:
        if l[0] in visited_nodes or l[1] in visited_nodes:
            if not (l[0] in visited_nodes and l[1] in visited_nodes):
                return dfs(visited_nodes + l, lines)
    else:
        # 全部見たけどなかった。橋なのでTrue
        print('True', file=sys.stderr)
        return True


ans = 0
for idx in range(M):
    # idx番目の線をなくす
    lines = []
    for m in range(M):
        if m == idx:
            continue
        else:
            lines.append([A[m], B[m]])
    print('idx, lines', idx, lines, file=sys.stderr)
    # 各頂点が全頂点とつながっているか確認
    # ただたんに全頂点が入っているだけでは断絶の可能性があるので不十分
    #  if dfs(lines[0][:1], lines):
    if len(lines) == 0:
        print(1)
        exit()
    if dfs(lines[0], lines):
        ans += 1
print(ans)


Measured memory_bytes: 5452
import sys

def permutation(n, x, mod=10**9+7):
    # nPx
    # 順列
    # ex) permutaion(5, 2) = 20
    tmp = 1
    for i in range(n, n-x, -1):
        tmp = (tmp * i) % mod
    return tmp

N, M = map(int, sys.stdin.readline().strip().split())

if abs(N - M) > 1:
    print(0)
elif abs(N - M) == 1:
    print(permutation(N, N) * permutation(M, M) % (10**9+7))
else:
    print(2 * permutation(N, N) * permutation(M, M)  % (10**9+7))

Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=2e5+100;
const int inf=1e9;
int s2[maxn],s1[maxn];
vector <int> g[maxn];
int vis[maxn],ans[maxn],dep[maxn];
void dfs(int u,int fa,int d)
{
    dep[u]=d;
    for (int i=0;i<g[u].size();i++) {
        int v=g[u][i];
        if (v==fa) continue ;
        dfs(v,u,d+1);
    }
}
int main()
{
    int n,i,top1,top2,x,y,num1,num2;
  // freopen("text.in","r",stdin);
    scanf("%d",&n);
    for (i=1;i<=n-1;i++) {
        scanf("%d%d",&x,&y);
        g[x].push_back(y);
        g[y].push_back(x);
    }
    memset(vis,0,sizeof(vis));
    memset(dep,0,sizeof(dep));
    dfs(1,-1,1);
    top1=0; top2=0;
    for (i=1;i<=n;i++) {
        if (dep[i]%2) {
            s1[++top1]=i;
        }else {
            s2[++top2]=i;
        }
    }
    if (top1<top2) {
        swap(s1,s2);
        swap(top1,top2);
    }
    num1=n/3+(n%3>=1);
    num2=n/3+(n%3>=2);
    int num3=n/3;
    if (top2<=n/3) {
        int now3=3;
        for (i=1;i<=top2;i++) {
            vis[s2[i]]=1;
            ans[s2[i]]=now3;
            now3+=3;
        }
        int now1=1; int now2=2;
        for (i=1;i<=n;i++) {
            if (!vis[i]) {
                if (num1) {
                    num1--;
                    ans[i]=now1;
                    now1+=3;
                }else {
                    if (num2) {
                        ans[i]=now2;
                        now2+=3;
                        num2--;
                    }else {
                        ans[i]=now3;
                        now3+=3;
                    }
                }
            }
        }
        for (i=1;i<=n;i++) {
            printf("%d ",ans[i]);
        }
        cout<<endl;
    }else {
        for (i=1;i<=num1;i++) {
            vis[s1[i]]=1;
            ans[s1[i]]=(i-1)*3+1;
        }
        for (i=1;i<=num2;i++) {
            vis[s2[i]]=1;
            ans[s2[i]]=(i-1)*3+2;
        }
        int now3=3;
        for (i=1;i<=n;i++) {
            if (vis[i]) {
                printf("%d ",ans[i]);
            }else {
                printf("%d ",now3);
                now3+=3;
            }
        }
        cout<<endl;
    }
    /*for (i=1;i<=num2;i++) {
        vis[s1[i]]=1;
        ans[s1[i]]=2;
    }
    for (i=1;i<=n;i++) {
        if (!vis[i]) {
            if (num1) {
                ans[i]=1;

                num1--;
            }else {
                ans[i]=3;
            }
        }
    }
    for (i=1;i<=n;i++) {
        printf("%d ",ans[i]);
    }
    cout<<endl;*/
    /*if (num1>top1||num2>top2) {
        cout<<-1<<endl;
        return 0;
    }
    for (i=1;i<=num1;i++) {
        vis[s1[i]]=1;
        ans[s1[i]]=(i-1)*3+1;
    }
    for (i=1;i<=num2;i++) {
        vis[s2[i]]=1;
        ans[s2[i]]=(i-1)*3+2;
    }
    for (i=1;i<=n;i++) {
        if (vis[i]) {
            printf("%d ",ans[i]);
        }else {
            printf("%d ",3);
        }
    }
    cout<<endl;*/
    return 0;
}


Measured memory_bytes: 23296
#pragma GCC optimize ("O3")
#pragma GCC target ("avx2")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>

using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int mod = 998244353;
const int IMAX = 100000;
constexpr ll modpow(ll A, ll B) {
	ll kotae = 1;
	while (B > 0) {
		if (B & 1) kotae = kotae * A % mod;
		A = A * A % mod;
		B >>= 1;
	}
	return kotae;
}

int dp[3001];
int main() {
	//cin.tie(0);
	//ios::sync_with_stdio(false);


	int N, S;
	scanf("%d %d", &N, &S);

	int A[3000];
	rep(i, N) scanf("%d", A + i);
	sort(A, A + N);

	ll k2 = modpow(2, mod - 2);
	dp[0] = modpow(2, N);
	int s = 0;
	ll kotae = 0;
	rep(i, N) {
		s = min(S - A[i], s + A[i]);

		if (S >= A[i]) kotae += dp[S - A[i]];
		for (int j = s; j >= A[i]; j--) {
			dp[j] = (dp[j] + dp[j - A[i]] * k2) % mod;
		}
	}

	printf("%lld\n", kotae % mod * k2 % mod);

	Would you please return 0;
}

Measured memory_bytes: 1708