akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<vector<ll>> VV;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define rep(i, n) REP(i, 0, n)
const int INF=1e9;
const int MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define ALL(v) v.begin(), v.end()
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbgmap(mp) for (auto i = mp.begin(); i != mp.end(); ++i) { cout << i->first <<":"<<i->second << endl;}
#define sum(v) accumulate(ALL(v),0)
#define fi first
#define se second

template<typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s<<"("<<p.first<<", "<<p.second<<")"; }

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<" ";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    char c;
    cin>>c;
    char ans=c+1;
    cout<<ans<<endl;
    return  0;
}


Measured memory_bytes: 256
#include<vector>
#include<algorithm>
#include<iostream>
#include<cstdio>
using namespace std;
struct UnionFind{
  vector<int> root;
  UnionFind(int size) : root(size, -1) {}
  bool unite(int x, int y){
    x = find(x);
    y = find(y);
    if(x == y){
      return 0;
    }
    if(root[y] < root[x]){
      swap(x, y);
    }
    root[x] += root[y];
    root[y] = x;
    return 1;
  }
  bool same(int x, int y){
    return find(x) == find(y);
  }
  int find(int x){
    return root[x] < 0 ? x : root[x] = find(root[x]);
  }
  int size(int x){
    return -root[find(x)];
  }
};

int main(){
  int n, q, com, x, y;
  cin >> n >> q;
  UnionFind uf(n);
  for(int i = 0; i < q; ++i){
    scanf("%d %d %d", &com, &x, &y);
    if(com == 0){
      uf.unite(x, y);
    }
    else{
      cout << (uf.same(x, y) ? 1 : 0) << endl;
    }
  } 
  return 0;
}

Measured memory_bytes: 1284
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define ld long double
#define mod ((ll)1e9+7)
#define inf ((ll)1e18+5)
#define maxx ((ll)1e6+5)
#define pb push_back
#define endl "\n"
#define time(i) cout<<"\nTime Elapsed "<<i<<" : " << 1.0*clock() / CLOCKS_PER_SEC << " sec\n";
#define usefile freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define test ll t; cin>>t; while(t--)
ll exp(ll x,ll y,ll p){ ll res=1; while(y) {if(y%2) res=(res*x%p)%p; x=(x*x)%p; y/=2; } return res;}
ll expm(ll x,ll y){ ll res=1; while(y) {if(y%2) res=(res*x%mod)%mod; x=(x*x)%mod; y/=2; } return res;}
/*
bool sv[maxx]={0};    // returns 0 if a num is prime
int sp[maxx]={0};     // gives smallest prime factor of the number
void Sieve() {for(int i= 2; i< maxx; i+= 2) sv[i]=1,sp[i] = 2;sv[2]=0;for(ll i = 3; i < maxx; i += 2){if (!sv[i]){sp[i] = i;for (ll j = i; (j*i) < maxx; j += 2){if (!sv[j*i])sv[j*i] = true, sp[j*i] = i;}}}}
ll fact[maxx]={0}; // returns factorial of that number
void facto() {fact[0]=1;fact[1]=1;for(int i=2;i<maxx;i++)fact[i]=(fact[i-1]*i)%mod;}
ll ncrm(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(expm(fact[r],mod-2)))%mod; res=(res*(expm(fact[n-r],mod-2)))%mod; return res;}
ll inv[maxx];   // returns the modular inverse of number
void inversify( ll m){inv[1]=1;for(int i=2;i<maxx;i++){inv[i]= m- m/i*inv[m%i]%m;}}
ll ncr(ll n,ll r,ll m){int ans=1;for (int i = 0; i < r; i++){ans=ans*(n-i)%m*inv[i+1]%m;}return ans;}
*/

int adj[20][20];
int vis[20][20];
int dis[20][20];
int dx[]={-1,0,1,0};
int dy[]={0,-1,0,1};
int h,w;
bool check(int x,int y){
  if(x<0 ||x>=h ||y<0||y>=w || adj[x][y]==0) return 0;
  return 1;
}

int bfs(int sx,int sy){
  queue<pair<int,int>> q;
  q.push({sx,sy});
  memset(vis,0,sizeof(vis));
  memset(dis,0,sizeof(dis));
  dis[sx][sy]=0;
  int maxDis=-2;
  while(q.size())
  {
    pair<int,int> u=q.front();
    q.pop();
    vis[u.first][u.second]=1;
    for(int i=0;i<4;i++)
    {
      int nx=u.first+dx[i];
      int ny=u.second+dy[i];
      if( check(nx,ny) && vis[nx][ny]!=1 )
      {
        dis[nx][ny]=dis[u.first][u.second]+1;
        maxDis=max(maxDis,dis[nx][ny]);
        q.push({nx,ny});
        vis[nx][ny]=1;
      }
    }   
  }
  return maxDis;
}



signed main(){
  fast;
  //usefile;
  //test
  {
    cin>>h>>w;
    
    char ch;
    for(int i=0;i<h;i++)
    {
      for(int j=0;j<w;j++)
      {
        cin>>ch;
        if(ch=='.')
          adj[i][j]=1;
      }
    }
    int mx=-1;
    for(int i=0;i<h;i++)
      for(int j=0;j<w;j++)
        if(adj[i][j]==1)
          mx=max(mx,bfs(i,j));
    cout<<mx;

  }
  //time("");
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <queue>
#include <cstring>
#include <string>
#include <stack>
#include <map>
#include <set>
#include <cmath>
#include <iomanip>
#include <ctime> 
using namespace std;

#define pb push_back
#define All(a) a.begin(), a.end()
#define met(a, b) memset(a, b, sizeof(a))
#define rep1(i, l, r) for(int i = l; i <= r; ++i)
#define rep2(i, l, r) for(int i = l; i < r; ++i) 
#define per(i, r, l) for(int i = r; i >= l; --i)
typedef long long ll;
typedef double db;
typedef long double ldb;
const int NIL = -1;
const int oo = 0x3f3f3f3f;
const ll INF = 2e18;
const db eps = 1e-8;
const db PI = acos(-1.0);
const int maxn = 1e5 + 7;

int T[maxn], dis[maxn];

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

inline void write(int x)
{
	if(x < 0) { putchar('-'); x = -x; }
    if(x >= 10) write(x/10); 
	putchar(x%10+'0'); 
}

int main(void)
{
	int flag1 = 0, flag2 = 0;
	int n = read(), k = read();
	rep1(i, 1, n)
	{
		T[i] = read();
		if(T[i] < 0) flag1 = 1;
		if(T[i] > 0) flag2 = 1;
	}
	if(flag1 && !flag2)
	{
		printf("%d", abs(T[n-k+1]));
	}
	else if(!flag1 && flag2)
	{
		printf("%d", abs(T[k]));
	}
	else if(!flag1 && !flag2)
	{
		printf("0");
	}
	else
	{
		int ans = oo;
		int l = 1, r = k;
		while(r <= n)
		{
			int t = T[r] - T[l];
			ans = min(ans, t+abs(T[l]));
			ans = min(ans, t+abs(T[r]));
			++l;
			++r;
		}
		printf("%d", ans);
	} 
		
	return 0;
} 

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

int main() {
  int n,a,b;
  cin>>n>>a>>b;
  int ans=0;
  for(int i=1;i<=n;i++){
    int c=i;
    int cur=0;
    while(c>0){
      cur+=c%10;
      c/=10;
    }
    if(cur>=a && cur<=b) ans+=i;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
import           Data.Char
import qualified Data.ByteString.Char8 as B
import qualified Data.Vector.Unboxed   as U

main :: IO ()
main = do
  [n, x] <- map read . words <$> getLine
  ls <- U.unfoldrN n (B.readInt . B.dropWhile isSpace) <$> B.getLine
  print $ solve x ls

solve :: Int -> U.Vector Int -> Int
solve x = U.length . U.filter (<= x) . U.scanl' (+) 0

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

struct Node {
  int parent;
  int r_sibling;
  int l_child;
  int depth;
};

Node T[100000];
const int NIL = -1;

void setDepth(int id, int depth) {
  T[id].depth = depth;
  if (T[id].l_child != NIL) setDepth(T[id].l_child, depth + 1);
  if (T[id].r_sibling != NIL) setDepth(T[id].r_sibling, depth);
}

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

  int n;
  cin >> n;

  for (int i = 0; i < n; i++) {
    T[i].parent = T[i].r_sibling = T[i].l_child = NIL;
  }

  for (int i = 0; i < n; i++) {
    int id, degree;
    cin >> id >> degree;
    for (int j = 0; j < degree; j++) {
      if (j == 0) {
        cin >> T[id].l_child;
        T[T[id].l_child].parent = id;
        id = T[id].l_child;
      } else {
        cin >> T[id].r_sibling;
        T[T[id].r_sibling].parent = T[id].parent;
        id = T[id].r_sibling;
      }
    }
  }

  for (int i = 0; i < n; i++) {
    if (T[i].parent == NIL) {
      setDepth(i, 0);
      break;
    }
  }

  for (int i = 0; i < n; i++) {
    cout << "node " << i << ": ";
    cout << "parent = " << T[i].parent << ", ";
    cout << "depth = " << T[i].depth << ", ";
    //cout << "l = " << T[i].l_child << ", ";
    //cout << "r = " << T[i].r_sibling << ", ";

    if (T[i].parent == NIL) {
      cout << "root";
    } else if (T[i].l_child == NIL) {
      cout << "leaf";
    } else {
      cout << "internal node";
    }
    cout << ", ";

    cout << "[";
    int cn = T[i].l_child;
    while(1) {
      if (cn == NIL) break;
      if (cn != T[i].l_child) cout << ", ";
      cout << cn;
      cn = T[cn].r_sibling;
    }
    cout << "]";
    cout << endl;
  }

  return 0;
}

Measured memory_bytes: 4664
import java.util.*;
import java.io.*;

public class Main {
    
    public static void main(String[] args) throws IOException {

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        
        String S = br.readLine();
        br.close();

        int N = S.length();

        boolean[] direction = new boolean[4];
        Map<Character, Integer> chr_code = new HashMap<>();

        chr_code.put('N', 0);
        chr_code.put('S', 1);
        chr_code.put('E', 2);
        chr_code.put('W', 3);

        for(int i = 0; i < N; i++){
            char now_chr = S.charAt(i);
            direction[chr_code.get(now_chr)] = true;
        }

        if(
            !(direction[0] ^ direction[1]) &&
            !(direction[2] ^ direction[3])
        ){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 21332
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using p = pair<ll, ll>;
using V = vector<int>;
using VV = vector<vector<int>>;
using VVV = vector<vector<vector<int>>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VVVL = vector<vector<vector<ll>>>;
using Graph = VV;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
int Inf = (1 << 30);
ll inf = (1LL << 60);
const int MOD = 1e9 + 7;
const int T = 1000000001;
string trans(int n) {
	string s = to_string(n);
	reverse(s.begin(), s.end());
	for (int i = s.size(); i < 6; i++) s += "0";
	reverse(s.begin(), s.end());
	return s;
}
int main() {
	int n, m;
	cin >> n >> m;
	// cout << trans(n) << endl << trans(m);
	int i;
	map<ll, int> mp;
	for (i = 1; i <= m; i++) {
		ll a, b;
		cin >> a >> b;
		ll tmp = a * T + b;
		mp[tmp] += i;
	}
	vector<string> pre(m, "000000");
	vector<string> num(m, "000000");
	V count(n + 1, 0);
	for (auto c : mp) {
		ll tmp = c.first;
		int I = c.second - 1;
		ll P = tmp / T;
		pre[I] = trans(P);
		count[P]++;
		num[I] = trans(count[P]);
	}
	for (i = 0; i < m; i++) cout << pre[i] << num[i] << endl;
	return 0;
}

Measured memory_bytes: 19072
#include <stdio.h>

int main ()
{
	int A, B, C;
	
	scanf("%d %d %d", &A, &B, &C);
	
	if (A==B && A!=C && B!=C){
		printf("Yes");
	} else if (A==C && A!=B && B!=C){
		printf("Yes");
	}else if (B==C && A!=B && A!=C){
		printf("Yes");
	}else if (A==B && A==C && B==C){
		printf("No");
	}else if (A!=B && A!=C && B!=C){
		printf("No");
	}
		
	return 0;
}

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

long my_gcd(long a, long b) {
    while (b > 0) {
        long x = b;
        b = a % b;
        a = x;
    }
    return a;
}

vector<long> primes(long x) {
    vector<long> res;
    unordered_map<long, vector<long> > mp;
    for (long p = 2; p <= x; p++) {
        if (mp.find(p) == mp.end()) {
            res.push_back(p);
            mp[p * p].push_back(p);
        } else {
            for (long q: mp[p]) {
                mp[p + q].push_back(q);
            }
        }
    }
    return res;
}

int main() {
    long a, b;
    cin >> a >> b;
    long sqrt_gcd = 1;
    long gcd_v = my_gcd(a, b);
    for (; sqrt_gcd * sqrt_gcd <= gcd_v; sqrt_gcd++) {}
    sqrt_gcd--;

    vector<long> prime_vec = primes(sqrt_gcd);
    int ans = 1;
    for (long x: prime_vec) {
        int c = 0;
        while (gcd_v % x == 0) {
            c++;
            gcd_v /= x;
        }
        if (c) ans++;
    } 
    if (gcd_v > 1) ans++;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 93968
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define printVec(v) printf("{"); for (const auto& i : v) { std::cout << i << ", "; } printf("}\n");
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//Get the highest value and key from a map.
template<typename KeyType, typename ValueType>
std::pair<KeyType,ValueType> get_max( const std::map<KeyType,ValueType>& x ) {
  using pairtype=std::pair<KeyType,ValueType>;
  return *std::max_element(x.begin(), x.end(), [] (const pairtype & p1, const pairtype & p2) {
        return p1.second < p2.second;
  });
}
using namespace std;
using P = pair<int,int>;
using ll = long long;
const ll INF = 1LL<<60;

int main() {
  string s;
  cin >> s;

  int ans = 0;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] != s[s.size() - (i + 1)]) {
      s[i] = s[s.size() - (i + 1)];
      ++ans;
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>      // cout, endl, cin
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <cctype>        // isupper, islower, isdigit, toupper, tolower
#include <cmath>

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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()

int main()
{
        int N, A, B, ans = 0;
        cin >> N;

        int w = 0, j = N;
        while (j > 0)
        {
                w += j % 10;
                j /= 10;
        }

        if (N % w == 0)
        {
                cout << "Yes" << endl;
                return 0;
        }

        cout << "No" << endl;

        return 0;
}


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

class Program
{
	static void Main(string[] args)
	{
		Console.ReadLine();
		var positions = new List<int>(new[] { 0 });
		positions.AddRange(Array.ConvertAll(Console.ReadLine().Split(new[] { ' ' }), number => int.Parse(number)));
		positions.Add(0);

		var totalCost = 0;
		for (var i = 0; i < positions.Count - 1; ++i) {
			totalCost += Math.Abs(positions[i + 1] - positions[i]);
		}

		for (var i = 1; i < positions.Count - 1; ++i) {
			var lostCost = Math.Abs(positions[i] - positions[i - 1]) + Math.Abs(positions[i + 1] - positions[i]);
			var addCost = Math.Abs(positions[i + 1] - positions[i - 1]);
			Console.WriteLine(totalCost - lostCost + addCost);
		}
	}
}

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

//↑見なくていいよ！ここまで--------------------------------------------------
function Main(){
	var s = nextCharArray();
	var mae = myconv(s[0] + s[1],1);
	var ato = myconv(s[2] + s[3]);
	if(mae >= 1 && mae <= 12 && ato >= 1 && ato <= 12){
		myout("AMBIGUOUS")
	}else if(!(mae >= 1 && mae <= 12) && ato >= 1 && ato <= 12){
		myout("YYMM");
	}else if(mae >= 1 && mae <= 12 && !(ato >= 1 && ato <= 12)){
		myout("MMYY");
	}else{
		myout("NA");
	}
}


Measured memory_bytes: 30076
#include<bits/stdc++.h>
using namespace std ;
#define rep( i, s, t ) for( register int i = s; i <= t; ++ i )
#define re register
#define int long long
int gi() {
	char cc = getchar() ; int cn = 0, flus = 1 ;
	while( cc < '0' || cc > '9' ) {  if( cc == '-' ) flus = - flus ; cc = getchar() ; }
	while( cc >= '0' && cc <= '9' )  cn = cn * 10 + cc - '0', cc = getchar() ;
	return cn * flus ;
}
const int N = 2e5 + 5 ;
const int M = 1e6 + 5 ;
const int P = 998244353 ; 
int n, m, a[N], w[M], mu[M], p[M / 10], top, Ans, F[M] ; 
bool isp[M] ; 
int fpow( int x, int k ) {
	int ans = 1, base = x ;
	while( k ) {
		if( k & 1 ) ans = ans * base % P ;
		base = base * base % P, k >>= 1 ; 
	} return ans ; 
}
void Init( int x ) {
	mu[1] = 1 ; 
	for( re int i = 2; i <= x; ++ i ) {
		if( !isp[i] ) p[++ top] = i, mu[i] = -1 ;
		for( re int j = 1; j <= top && p[j] * i <= x; ++ j ) {
			isp[i * p[j]] = 1 ; if( i % p[j] == 0 ) break ;
			mu[i * p[j]] = - mu[i] ;
		}
	} 
}
void inc( int &x, int y ) {
	( ( x += y ) >= P ) && ( x -= P ) ;
}
signed main()
{
	n = gi() ; int Max = 0 ;
	rep( i, 1, n ) a[i] = gi(), ++ w[a[i]], Max = max( Max, a[i] ) ;
	Init( Max ) ; int I2 = fpow( 2, P - 2 ) ;
	for( re int i = 1; i <= Max; ++ i ) {
		int ans = 0, dec = 0 ; 
		for( re int j = i; j <= Max; j += i ) {
			int k = w[j] * j % P ; 
			inc( ans, k ), inc( dec, k * j % P ) ;
		}
		F[i] = ( ans * ans % P - dec + P ) % P * I2 % P ;
	}
	for( re int i = 1; i <= Max; ++ i ) {
		int ans = 0, d = fpow( i, P - 2 ) ; 
		for( re int j = i; j <= Max; j += i ) {
			int k = ( F[j] * mu[j / i] + P ) % P ;
			inc( ans, k ) ;
		}
		inc( Ans, d * ans % P ) ;
	}
	cout << Ans << endl ;
	return 0 ;
}

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

int N, H[100000];
int main() {
	cin >> N;
	for (int i = 0; i < N; i++) cin >> H[i];
	int ans = 1;
	int tmp = 1;
	for (int i = 0; i < N-1; i++) {
		if (H[i] >= H[i + 1]) tmp++;
		else tmp = 1;
		ans = max(ans, tmp);
	}
	cout << ans - 1 << endl;
	
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  int P;
  for (int i = 0; i < N; i++){
    int l, r;
    cin >> l >> r;
    P += r + 1 - l;
  }
  cout << P << endl;
}

Measured memory_bytes: 256
N = int(input())
prev = False
cnt = 0
plist = list(map(int,input().split()))
for i in range(len(plist)):
  p = plist[i]
  if i+1 == p:
    if prev == False:
      cnt += 1
      prev = True
    else:
      prev = False
  else:
    prev = False
print(cnt)

Measured memory_bytes: 14008
import sys
sys.setrecursionlimit(10**9)

def main():
    L = list(input())
    N = len(L)
    MOD = 10**9+7


    dp = [[[0]*2  for _ in range(3)] for _ in  range(N)]

    dp[0][0][1] = 1
    dp[0][1][1] = 1
    dp[0][2][0] = 1

    for i in range(1,N):
        v = sum([dp[i-1][j][0] for j in range(3)]) % MOD
        dp[i][0][0] += v
        dp[i][1][0] += v
        dp[i][2][0] += v
        for j in range(3):
            u = dp[i-1][j][1] % MOD
            if L[i] == "1":
                dp[i][0][1] += u
                dp[i][1][1] += u
                dp[i][2][0] += u
            else:
                dp[i][2][1] += u

    # print(dp)
    print((sum([dp[N-1][i][0]% MOD for i in range(3)]) + sum([dp[N-1][i][1]% MOD for i in range(3)]))% MOD)



if __name__ == "__main__":
  main()


Measured memory_bytes: 84104
N = gets.to_i

通路 = Array.new(N+1){ [] }
$<.each{|ln|
	a,b = ln.split.map(&:to_i)
	通路[a] << b
	通路[b] << a
}

道しるべ = [nil]*(N+1)
道しるべ[1] = 0
q = [1]
until q.empty?
	p = []
	q.each{|r|
		通路[r].each{|s|
			if 道しるべ[s].nil?
				道しるべ[s] = r
				p << s
			end
		}
	}
	q = p
end

puts 'Yes'
p(*道しるべ.drop(2))


Measured memory_bytes: 34420
#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 PB push_back
#define EB emplace_back
#define MP make_pair
#define F first
#define S second
#define FBO find_by_order
#define OOK order_of_key
#define mset(m,v) memset((m),(v),sizeof(m))
#define inrep int TC;cin>>TC;while(TC--)
#define cppio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define PI 3.1415926535897932384626433832795028841971693993751
#define trace1(x) cerr<<#x<<": "<<x<<endl
#define trace2(x, y) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<"\n"
#define trace3(x, y, z) cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<"\n"

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

// SOLUTION


int main() {
	cppio;
	vi flag(1000006, 0);
	for(int i = 1; i < 1000; ++i) flag[i * i] = 1;
	ll a, b;
	cin >> a >> b;
	a *= pow(10, (int)log10(b) + 1);
	a += b;
	// cout << a;
	if(flag[a]) cout << "Yes";
	else cout << "No";
	return 0;
}


Measured memory_bytes: 4480
#include<bits/stdc++.h>
using namespace std;
long n,a[2][3];
main(){
  cin>>n;
  for(auto& b:a)for(auto& c:b)cin>>c;
  vector<long> dp(n+1);
  for(long i=1;i<=n;++i)for(int j=0;j<3;++j)if(i-a[0][j]>=0&&a[0][j]<a[1][j])dp[i]=max(dp[i],a[1][j]-a[0][j]+dp[i-a[0][j]]);
  n+=dp[n];dp=vector<long>(n+1,0);
  for(long i=1;i<=n;++i)for(int j=0;j<3;++j)if(i-a[1][j]>=0&&a[1][j]<a[0][j])dp[i]=max(dp[i],a[0][j]-a[1][j]+dp[i-a[1][j]]);
  cout<<dp[n]+n;
}

Measured memory_bytes: 195584
#include <bits/stdc++.h>
#define reg register
#define ll long long
#define ull unsigned long long
using namespace std;
ll x, k, d;
void work() {
  scanf("%lld%lld%lld", &x, &k, &d), x = abs(x);
  ll tmp = min(x / d, k);
  k -= tmp, x -= tmp * d;
  if(k % 2 == 0) printf("%lld\n", x);
  else printf("%lld\n", d - x);
}
signed main() {
  int _ = 1;
  // scanf("%d", &_);
  while(_--) {
    work();
  }
  return 0;
}



Measured memory_bytes: 3800
#include<iostream>
#include<string>
#include<vector>
using namespace std;
int main(){
  string s;
  int N=0,Q=0;
  int i;
  int l,r,ans=0;
  cin >> N >> Q;
  cin >> s;
  vector <int> count(N,0);
  for(i=0;i<N-1;i++){
    if(s[i]=='A'&&s[i+1]=='C'){
      count[i+1]=count[i]+1;
    }else{
      count[i+1]=count[i];
    }
  }

  for(i=0;i<Q;i++){
    ans=0;
    cin>>l>>r;
    if(l==r){
      break;
    }else{    
      ans = count[r-1] - count[l-1];
      cout<<ans<<endl;
    }
  }
  return 0;
}


Measured memory_bytes: 1408
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;

namespace MyProject
{
    class Program
    {
        static void Main(string[] args)
        {
#if Local
            var sw = new Stopwatch();
            sw.Start();
            Console.SetIn(new StreamReader("input.in"));
#endif

            var solver = new Solver();
            solver.Solve();
#if Local
            Console.WriteLine($"{sw.ElapsedMilliseconds}ms");
#endif
        }
    }

    class Solver
    {
        public void Solve()
        {
            var items = Console.ReadLine().Split().Select(elem => double.Parse(elem)).ToArray();
            var A = items[0];
            var B = items[1];
            var H = items[2];
            var M = items[3];

            // H時M分のときの角度
            var a = 360 * ((H + (M / 60)) / 12);
            var b = 360 * (M / 60);
            var angle = Math.Abs(a - b);
            var answer = Math.Sqrt(Math.Pow(A, 2) + Math.Pow(B, 2) - (2 * A * B * Math.Cos(angle * Math.PI / 180)));

            Console.WriteLine(answer);
        }
    }
}


Measured memory_bytes: 28636
#include<bits/stdc++.h>
#define ll long long int
#define N 2010
using namespace std;
 
int main()
{
    int n,A[N],i,bit=0,ans=1e9+7;
    scanf("%d",&n);
    for(i=0;i<n;i++) scanf("%d",&A[i]),bit+=A[i];
    bitset<N*N> dp;
    dp[0]=1;
    for(i=0;i<n;i++) dp|=(dp<<A[i]);
    for(i=(bit+1)/2;i<=bit;i++)
    {
        if(dp[i])
        {
            printf("%d\n",i);
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
using namespace std;
int n, a, p, q, r;
int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a;
		if (a % 4 == 0) p++;
		else if (a % 2 == 0) q++;
		else r++;
	}
	if (q == 0) cout << (p + 1 >= r ? "Yes" : "No") << endl;
	else cout << (p >= r ? "Yes" : "No") << endl;
	return 0;
}

Measured memory_bytes: 256
local n=io.read("n")
local x={}
local y={}
local h={}
local a
for i=1,n do
    x[i]=io.read("n")
    y[i]=io.read("n")
    h[i]=io.read("n")
    if h[i]>=1 then
        a=i
    end
end

for i=0,100 do
    for j=0,100 do
        local H=h[a]+math.abs(i-x[a])+math.abs(j-y[a])
        local checker=true
        for k=1,n do
           if h[k]>0 and H-h[k]~=math.abs(i-x[k])+math.abs(j-y[k]) then
            checker=false
           end
           if h[k]==0 and H>math.abs(i-x[k])+math.abs(j-y[k]) then
            checker=false
           end
        end
        if checker then
            print(i,j,H)
            return
        end
    end
end

Measured memory_bytes: 2788
#include<bits/stdc++.h>
#include<algorithm>
#include<math.h>
#include<string>
#include<iostream>
#include<vector>
#include<cstdlib>
using namespace std;
 
template <class T> using V = vector<T>;
 
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;
}
 
const long long INF = 1LL << 60;
 
using ll = long long;
using db = double;
using st = string;
using ch = char;
using bl = bool;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;
using vbl = V<bl>;
 
 
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define rFOR(i,a,b) for(ll i=(a);i>(b);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define co(a) cout<<a<<endl;
#define ci(a) cin>>a;
 
 
ll sum(ll n) {
  ll m=0;
  FOR(i,0,20){
    m+=n%10;
    n/=10;
    if(n==0){
      break;
    }
  }
  return m;
}
 
 
const int MAX = 510000;
const int MOD = 1000000007;
 
long long fac[MAX], finv[MAX], inv[MAX];
 
void Comuse() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
 
#define comuse Comuse()
 
ll combi(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 
 
 
 
ll lcm(ll a,ll b){
  ll n;
  n=a/gcd(a,b)*b;
  return n;
}
 
 
/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/
 
 
signed main() {
  ll a,d;
  	ci(a>>d);
  ll n=2*d+1;
  if(a%n==0){
    co(a/n)
  }
  else{
    co(a/n+1)
  }
}

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

const int INF  = 1e9;
const long long INFLL = 1e18;
const int NMAX = 105;
const int MMAX = 100005;
const int KMAX = 1005;
const int MOD  = 1e9 + 7;
using namespace std;

// comment to disable debug functions
#define DEBUG

// frequently used macros

#if __cplusplus >= 201103L
#define ALL(v) begin(v),end(v)
#define SORT(v) sort(begin(v), end(v))
#define FIND(v,x) find(begin(v), end(v), (x))
#else
#define ALL(v) (v).begin(),(v).end()
#define SORT(v) sort(v.begin(), v.end())
#define FIND(v,x) find(v.begin(), v.end(), (x))
#endif

#define MEMNEXT(from, to) do{ memmove((to), (from), sizeof(from)); \
memset((from), 0, sizeof(from)); } while(0)
#ifdef DEBUG
#define DUMP(x) do{ std::cerr << (#x) << ": " << x << std::endl; }while(0)
#else
#define DUMP(x) do{}while(0)
#endif

// frequent used aliases
typedef long long ll;
typedef pair<int, int> p;
typedef pair<ll, int> lp;
typedef pair<ll, ll> llp;
typedef vector<int> vec;
typedef vector<ll> vecll;
typedef vector<vec> mat;
typedef vector<vecll> matll;

// frequently used constants
static const int di[] = {-1, 0, 1, -1, 1, -1, 0, 1};
static const int dj[] = {-1, -1, -1, 0, 0, 1, 1, 1};

// frequently used structs
struct edge{
  int to,cost;
};

// printf for debug
#ifndef DEBUG
void debug(const char* format, ...){}
#else
void debug(const char* format, ...){
  va_list arg;
  va_start(arg, format);
  vprintf(format, arg);
  va_end(arg);
}
#endif

// dump vector
#ifdef DEBUG
#define DUMPV(v, c) do{       \
  printf("%s: ", #v);         \
  for (int i = 0; i < (c); ++i) \
  {                           \
  cout << (v)[i] << " ";      \
  }                           \
  cout << endl;               \
} while(0)
#else
#define DUMPV(v,c)
#endif

// std::fill of multi dimensions
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
  std::fill( (T*)array, (T*)(array+N), val );
}

// binary search
ll BSearch(ll _begin, ll _end, bool (*f)(int)){
  ll mid;
  while(_end - _begin > 1LL) {
  mid = (_begin + _end) / 2LL;
  if(f(mid)) {
    debug("BSearch: f(%d) == true\n", mid);
    _end = mid;
  }
  else
  {
    debug("BSearch: f(%d) == false\n", mid);
    _begin = mid;
  }
  }
  return _end;
}


ll N,M,K,A[NMAX],B,C,D,E;
int dp[NMAX][10] = {};

string S;
vec v;

int ans = 0;

void solve(){
  // main algorithm
  Fill(dp, -1);
  dp[0][0] = 0;
  for (int i = 0; i < N; ++i)
  {
    int mod = A[i] % 10;
    for (int j = 0; j < 10; ++j)
    {
      if (dp[i][j] != -1)
      {
        dp[i+1][(j + mod) % 10] = max(dp[i+1][(j + mod) % 10], dp[i][j] + (int)A[i]);
        dp[i+1][j] = max(dp[i+1][j], dp[i][j]);
      }
    }
  }
  for (int i = 1; i < 10; ++i)
  {
    ans = max(dp[N][i], ans);
  }
}
void debug(){
  // output debug information

}
void answer(){
  // output answer
  cout << ans << endl;
}
int main(int argc, char const *argv[])
{
  // operate inputs

  // Fill(dp, -1);
  cin >> N;
  for (int i = 0; i <N ; ++i)
  {
    scanf("%lld", &A[i]);
  }
  solve();
  #ifdef DEBUG
  debug();
  #endif
  answer();

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <cassert>
#include <functional>
#include <string>
#include <sstream>
#include <cctype>
using namespace std;


int main(){
  int A, B, C;
  cin >> A >> B >> C;
  cout << (A + B) * C / 2 << endl;
}


Measured memory_bytes: 256
N = input().rstrip()
num = [int(i) for i in input().rstrip().split(' ')]

ret = 'APPROVED'
for i in num:
    if i % 2 == 0:
        if not i % 3 == 0 and not i % 5 == 0:
            ret = 'DENIED'
            break

print(ret)

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

const int N = 200005;

int n;
map <long long, int> mp;

int main() {
	scanf("%d", &n);
	long long sum = 0;
	mp[0]++;
	long long res = 0;
	for (int i = 1; i <= n; ++i) {
		int x; scanf("%d", &x);
		sum += x;
		res += mp[sum];
		mp[sum]++;
	}

	cout << res << '\n';
}

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

int main() {
  int N;
  cin >> N;
  vector<int> p(N);
  int flag = 0;
  for (int i = 0; i < N; i ++){
    cin >> p.at(i);
    if ( (i + 1) != p.at(i)){
      flag ++;
    }
  }
  if ( flag < 3){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }  
}



Measured memory_bytes: 256
#include <stdio.h>
int max(int a, int b){
  if(a<b){
    return b;
  }else{
    return a;
  }
}
int main(){
  int a, b, c, x, y;
  scanf("%d%d%d%d%d", &a, &b, &c, &x, &y);
  int ans;
  ans = a * x + b * y;
  int tmp;
  tmp = c * (2 * y) + a * max(0, x-y);
  if (tmp < ans){
    ans = tmp;
  }
  tmp = c * (2 * x) + b * max(0, y-x);
  if (tmp < ans){
    ans = tmp;
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i = a; i < b; ++i)
#define RFOR(i, a, b) for(int i = a; i >= b; --i)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, n, 0)
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
const int INF = 1e9;
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
ll a[100100][3];
ll dp[100100][3];
int main() {
    ll n;
    cin >> n;
    REP(i, n) {
        REP(j, 3) {
            cin >> a[i][j];
        }
    }
    FOR(i, 0, n) {
        REP(j, 3) {
            REP(k ,3) {
                if(j == k) continue;
                chmax(dp[i+1][k], dp[i][j] + a[i][k]);
            }
        }
    }
    cout << max(dp[n][0], max(dp[n][1], dp[n][2])) << endl;
}

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

int main()
{
    int n;
    cin>>n;
    vector<ll >v(n);
    for(int i=0;i<n;i++)
        cin>>v[i];
    sort(v.rbegin(),v.rend());
    
    
    ll answer=v[0];
    int nextPlayer=2;
    for(int i=1;i<n && nextPlayer<n;i++)
    {
    	//cout<<answer<<" "<<nextPlayer<<endl;
        answer+=v[i];
        nextPlayer++;
        if(nextPlayer<n)
            answer+=v[i];
        nextPlayer++;
        
    }
    cout<<answer<<endl;
    return 0;
}


Measured memory_bytes: 4844
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main(){
  ll N,D,A,X,H; cin>>N>>D>>A;
  vector<vector<ll>> Z(N, vector<ll>(2));
  for(int i=0; i<N; i++){cin>>X>>H, Z[i][0]=X, H=(H+A-1)/A; Z[i][1]=H;}
  sort(Z.begin(), Z.end(), [](auto& x, auto& y){return x[0] < y[0];});
  D*=2;
  ll count=0, ans=0;
  for(int i=0, j=0; i<N; i++){
    while(Z[i][0]-Z[j][0]>D){
      count-=Z[j][1];
      j++;
    }
    ll a=Z[i][1]-count;
    ans+=max(0LL,a);
    Z[i][1]=max(0LL,a);
    count+=Z[i][1];
  }
  cout<<ans<<endl;
}


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

#define MAX 10000
#define NIL -1

struct node {
  int p,l,r;
};

struct node T[MAX];
int n;

void pre(int a){
  if(a == NIL) return;
  cout << " " << a;
  pre(T[a].l);
  pre(T[a].r);
}

void in(int a){
  if(a == NIL) return;
  in(T[a].l);
  cout << " " << a;
  in(T[a].r);
}

void post(int a){
  if(a == NIL) return;
  post(T[a].l);
  post(T[a].r);
  cout << " " << a;
}

int main(){
  int i,v,l,r,root;

  cin >> n;
  for(i = 0; i < n; i++){
    T[i].p = NIL;
  }

  for(i = 0; i < n; i++){
    cin >> v >> l >> r;
    T[v].l = l;
    T[v].r = r;
    if(l != NIL) T[l].p = v;
    if(r != NIL) T[r].p = v;
  }

  for(i = 0; i < n; i++){
    if(T[i].p == NIL) root = i;
  }

  cout << "Preorder" <<endl;
  
  pre(root);
  cout << endl;
  
  cout << "Inorder" << endl;
  in(root);
  cout << endl;

  cout << "Postorder" << endl;
  post(root);
  cout << endl;
  
  return 0;
}



Measured memory_bytes: 3080
#include<iostream>
using namespace std;
int main () {
    int a [] = {0 , 1 , 3 , 1 , 2 , 1 , 2 , 1 , 1 , 2 , 1 , 2 , 1};
    int x , y ; cin >> x >> y ;
    cout<<(a[x]==a[y]?"Yes":"No")<<endl;
    return 0;
}


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

#define SENTINEL 1000000000000000000

void merge(long long A[], long long B[], long long left, long long mid, long long right){
  long long n1, n2, i, j, k;
  long long *L,*R, *Lb, *Rb;
  
  n1 = mid-left;
  n2 = right-mid;
  
  L = (long long*)malloc(sizeof(long long) *(n1 + 1));
  R = (long long*)malloc(sizeof(long long) *(n2 + 1));
  Lb = (long long*)malloc(sizeof(long long) *(n1 + 1));
  Rb = (long long*)malloc(sizeof(long long) *(n2 + 1));
  
  for(i = 0; i <= n1 - 1; i++){
    L[i] = A[left + i];
    Lb[i] = B[left + i];
  }
  for(j = 0; j <= n2 - 1; j++){
    R[j] = A[mid + j];
    Rb[j] = B[mid + j];
  }
  
  L[n1] = SENTINEL;
  R[n2] = SENTINEL;
  Lb[n1] = SENTINEL;
  Rb[n2] = SENTINEL;
  
  i = 0;
  j = 0;
  
  for(k = left; k <= right - 1; k++){
   if(L[i] <= R[j]){
      A[k] = L[i];
      B[k] = Lb[i];
      i++;
    }
    else{
      A[k] = R[j];
      B[k] = Rb[j];
      j++;
    }
  }
  free(L);
  free(R);
  free(Lb);
  free(Rb);
}

void mergeSort(long long A[], long long B[], long long left, long long right){
  long long mid;
  
  if(left + 1 < right){
    mid=(left + right)/2;
    mergeSort(A,B, left, mid);
    mergeSort(A,B, mid, right);
    merge(A,B, left, mid, right);
  }
}

int main(void){

    long long N, K;

    scanf("%lld%lld", &N, &K);

    long long a[N], b[N];

    for(long long i = 0; i < N; i++){
        scanf("%lld%lld", &a[i], &b[i]);
    }

    mergeSort(a, b, 0, N);

    long long c = 0;

    for(int i = 0; i < N; i++){
        c += b[i];

        if(c >= K){
            printf("%lld\n", a[i]);
            break;
        }
    }

    return 0;
}

Measured memory_bytes: 4500
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: 38256
#include <bits/stdc++.h>
using namespace std;

#define fs first
#define sc second
#define pb emplace_back
#define mp make_pair
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

using pii = pair<int, int>;
using vi = vector<int>;
using lint = long long;

const int inf = 1001001001;
const lint linf = 1001001001001001001ll;
const int mod = 1e9 + 7;
const int dx[]{0, 1, 0, -1, -1, -1, 1, 1}, dy[]{1, 0, -1, 0, -1, 1, -1, 1};

template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; } return a > b; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; } return a < b; }
template<typename T> inline void print(const T &x, string s = "\n") { cout << x << s; }
template<typename T> inline void print(const vector<T> &v, string s = " ")
{ if (!v.size()) puts(""); rep(i, v.size()) cout << v[i] << (i + 1 == v.size() ? "\n" : s); }
inline bool inside(int y, int x, int H, int W) { return 0 <= y && y < H && 0 <= x && x < W; }
inline lint in() { lint x; std::cin>>x; return x; }

int n;
bool s[101010], a[101010];
signed main() {
  cin >> n;
  rep(i, n) {
    char c;
    cin >> c;
    s[i] = (c == 'o');
  }

  rep(i, 2) rep(j, 2) {
    a[0] = i;
    a[1] = j;

    for (int k = 1; k <= n; ++k) {
      if (a[k] xor s[k % n]) a[k + 1] = !a[k - 1];
      else a[k + 1] = a[k - 1];
    }

    if (a[n] == a[0] && a[n + 1] == a[1]) {
      rep(k, n) cout << (a[k] ? 'S' : 'W');
      cout << endl;
      return 0;
    }
  }

  cout << -1 << endl;
}


Measured memory_bytes: 512
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define MIN(x,y) ((x)<(y)?(x):(y))
#define MAX(x,y) ((x)<(y)?(y):(x))
#define MOD 1000000007

int main(){
  char S[4];
  scanf("%s",S);
  int d[4],i;
  for(i=0;i<4;i++)
  d[i]=S[i]-'0';
  int t=d[0]*10+d[1],b=d[2]*10+d[3];
  if((t>12||t==0)&&(b>12||b==0))printf("NA\n");
  else if(t>12||t==0)printf("YYMM\n");
  else if(b>12||b==0)printf("MMYY\n");
  else printf("AMBIGUOUS\n");

  return 0;
}


Measured memory_bytes: 128
import math
import copy
from collections import defaultdict
from collections import Counter
from collections import deque
# 直積 A={a, b, c}, B={d, e}:のとき，A×B={(a,d),(a,e),(b,d),(b,e),(c,d),(c,e)}: product(A, B)
from itertools import product
# 階乗 P!: permutations(seq), 順列 {}_len(seq) P_n: permutations(seq, n)
from itertools import permutations
# 組み合わせ {}_len(seq) C_n: combinations(seq, n)
from itertools import combinations
from bisect import bisect_left, bisect_right
# import numpy as np
 
def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W
 
# 四方向: 右, 下, 左, 上
dy = [0, -1, 0, 1]
dx = [1, 0, -1, 0]
 
def i_inpl(): return int(input())
def s_inpl(): return map(int,input().split())
def l_inpl(): return list(map(int, input().split()))
INF = float("inf")

N = i_inpl()
p = l_inpl()

ans = 0
for i in range(N-1):
    if p[i] == i+1:
        p[i], p[i+1] = p[i+1], p[i]
        ans += 1

if p[-1] == N:
    ans += 1

print(ans)

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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)

#define ALL(v) v.begin(), v.end()

int A, B, C;
int K;
int main() {
  std::cout << std::fixed << std::setprecision(20);
  
  cin >> A >> B >> C;
  
  cin >> K;

  for(int i = 0; i <= K; i++){
    for(int j = 0; j <= K; j++){
      
      int l = K -(i+j);
      if(i + j + l > K) continue;
      int aa = A * pow(2,i);
      int bb = B * pow(2,j);
      int cc = C * pow(2,l);

      if(bb > aa && cc > bb){
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
  return 0;

}




Measured memory_bytes: 4100
use List::Util qw( sum );

my $input1 = <>;
my $input2 = <>;
chomp $input1;
chomp $input2;
my ( $N, $M ) = split(' ', $input1);
my ( @X ) = split(' ', $input2);

my @X_sorted = sort{$b <=> $a } @X;

my @diffs;
my $prev = shift @X_sorted;
for my $current ( @X_sorted ) {
    push @diffs, $prev - $current;
    $prev = $current;
}

my @diff_sorted = sort{$b <=> $a } @diffs;

$N = $N - 1;
for ( 1..$N ) {
    shift @diff_sorted;
}

my $sum = sum ( @diff_sorted ) // 0;
print $sum;

Measured memory_bytes: 31216
import sys
input = sys.stdin.readline
N,Q=map(int,input().split())
S=input()
query=[[int(i) for i in input().split()]for i in range(Q)]
K=[0]*(N)
t=0
for i in range(N):
    a=0
    if t==1 and S[i]=='C':
        a=1
        t=0
    elif S[i]=='A':
        t=1
    else:
        t=0
    K[i]=a
L=[0]*(N+1)
for i in range(N):
    L[i+1]=L[i]+K[i]
#print(L,K)
for a,b,in query:
    a,b=a-1,b-1
    t=L[b+1]-L[a]
    if a>=1 and S[a]=='C' and S[a-1]=='A':
        t-=1
    print(t)

Measured memory_bytes: 68060
var N;
function c753(S) {
    var s = S - 0;
    if (s > N) return 0;

    var f7 = false, f5 = false, f3 = false;
    S.split('').forEach(function(value) { 
        switch (value - 0) {
        case 7: 
            f7 = true;
            break;
        case 5:
            f5 = true;
            break;
        case 3:
            f3 = true;
            break;
        default:
        }
    });
    var count = (f7 && f5 && f3) ? 1 : 0;
    for (var c of ['7', '5', '3']) { count += c753(S + c); }
    return count;
}

function Main(input) {
    N = input.split("\n")[0] - 0;
    var count = c753("");
    console.log(count);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


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

int main() {
  int n, d, x;
  cin >> n >> d >> x;
  
  int a;
  int ans = x;
  for(int i=0; i<n; i++) {
    cin >> a;
    ans += (d-1)/a+1;
  }
  cout << ans << endl;
  return 0;
}

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

void doc(){
    freopen("ALDS1_5_A.inp","r",stdin);
    freopen("ALDS1_5_A.out","w",stdout);
}

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

void solve(){
    cin >> n;
    int sum = 0;
    for(int i = 0; i < n; i++){
        cin >> a[i];
        sum += a[i];
    }
    bool d[n + 2][MaxN];
    for(int i = 0; i < sum; i++)
        for(int j = 0; j < n; j++) d[j][i] = false;
    d[0][0] = true;
    d[0][a[0]] = true;
    for(int i = 1; i < n; i++){
        for(int j = 0; j < sum; j++)
            d[i][j] = d[i-1][j];
        for(int j = 0; j < sum; j++)
            if (j - a[i] >= 0 && d[i-1][j - a[i]])
                d[i][j] = true;
    }
    int m;
    cin >> m;
    for(int i = 0; i < m; i++){
        int x;
        cin >> x;
        cout << ((d[n-1][x]) ? "yes" : "no");
//        if (d[n - 1][x]) cout << "yes";
//        else cout << "no";
        cout << '\n';
    }
}

int main(){
    //doc();
    solve();
}



Measured memory_bytes: 3120
#include <iostream>
#include <cstring>
#include <string>
#include <algorithm>
#include <cstdio>
#include <algorithm>
#include <vector>

using namespace std;
int A[10003];
int B[103][103];

int main()
{     int n,m;
         int colornum;
       cin>>n>>m;
        cin>>colornum;
          int e;
           int i=0;
            memset(A,0,sizeof(A));
             memset(B,0,sizeof(B));
           int c=0;
        for(int ii=1;ii<=colornum;ii++)
        {
            cin>>A[ii];
        }
        int d=0;
       // cout<<A[2]<<"WWWWWWWWWWWWWW";
        int iv=0;  int ji=1;
            int o=0;
        for(int i=1;i<=colornum;i++)
        {    int h=A[i];
            while(h)
                {if(ji)
                for(;iv<m;)
                {
                    B[d][iv]=i;
                     h--;
                    if(iv==m-1)
                    {
                         d++;
                         ji=0;
                         o=1;
                    }
                    else
                        iv++;
                    if(o)
                        break;
                        if(h==0)
                        break;
                }
                if(h==0)
                        break;
                if(o)
                {    // cout<<d<<' '<<iv<<"WWWWWWWWWWWWW"<<endl;
                    for(;iv>=0;)
                    {
                        B[d][iv]=i;
                        h--;
                        if(iv==0)
                        {
                            d++;
                            ji=1;
                            o=0;
                        }
                        else
                            iv--;
                        if(ji)
                            break;
                            if(h==0)
                            break;
                    }
                }
                if(h==0)
                    break;
                }
        }
       // cout<<B[1][0]<<"AAAAAAAAA";
        for(int i=0;i<n;i++)
            for(int s=0;s<m;s++)
        {
            cout<<B[i][s];
            if(s==m-1)
                cout<<endl;
            else
                cout<<' ';
        }
    return 0;
}


Measured memory_bytes: 384