akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <string>
#include <unordered_map>
#include <queue>
#include <set>
using namespace std;


int main(){
    int n;
    cin >> n;
    vector<long long> a(n), b(n + 1);
    for (int i = 0; i < n; i++) cin >> a[i];

    long long l=0, r=a[0];
    while(l <= r){
        b[0] = (l + r) / 2;
        for (int i = 1; i <= n; i++){
            b[i] = a[i - 1] - b[i - 1];
        }
        if (b[n] == b[0]) break;
        else if (b[n] < b[0]) r = (l + r) / 2 - 1;
        else l = (l + r) / 2 + 1;
    }
    for (int i = 0; i < n; i++)
        cout << b[i] * 2 << " ";
    cout << endl;
    return 0;
}

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

typedef long long ll;

const int MOD = 1000000007;
const int INF = 1001001001;



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

int H, W;

int d[30][30];
char maze[30][30];
int dh[4] = {1, 0, -1, 0};
int dw[4] = {0, 1, 0, -1};

int bfs(int sh, int sw) {
    queue<int> ph;
    queue<int> pw;

    rep(i, H) rep(j, W) d[i][j] = INF;
    d[sh][sw] = 0;
    ph.push(sh);
    pw.push(sw);

    while(ph.size()) {
        int h = ph.front();
        int w = pw.front();
        ph.pop();
        pw.pop();
        for(int i = 0; i < 4; i++) {
            int nh = h + dh[i];
            int nw = w + dw[i];
            if(0 <= nh and nh < H and 0 <= nw and nw < W && maze[nh][nw] != '#' && d[nh][nw] == INF) {
                ph.push(nh);
                pw.push(nw);
                d[nh][nw] = d[h][w] + 1;
            }
        }
    }
    int ret = 0;
    rep(i, H) rep(j, W) {
        if(d[i][j] != INF) {
            ret = max(ret, d[i][j]);
        }
    }

    return ret;
}

int main() {
    cin >> H >> W;
    rep(i, H) cin >> maze[i];
    int ans = 0;
    rep(i, H) rep(j, W) {
        if(maze[i][j] != '#') {
            ans = max(ans, bfs(i, j));
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <fstream>
#include <algorithm>
#include <string>
#include <string.h>
#include <queue>
#include <vector>
#include <set>
#include <map>
using namespace std;

int main() {
	long long int A, B, C;
	cin >> A >> B >> C;
	cout << min(abs(A*B*(C / 2) - A*B*(C - C / 2)), min(abs(A*C*(B / 2) - A*C*(B - B / 2)), abs(B*C*(A / 2) - B*C*(A - A / 2))));
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  string s;
  cin>>s;
  int l=s.length();
  if(l>n){
    string t=s.substr(0,n);
    t=t+"...";
    cout<<t;
  }
  else cout<<s;
  return 0;
}

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

int main()
{
    int n=0;
    cin >> n;
    int ar[n];
    bool ans = true;
    for(int i=0; i<n; i++){
        cin >> ar[i];
        if(ar[i]==0 || ar[i]==2 || ar[i]==4){
            ans = false;
            continue;
        }
        if(ar[i]%2==0){
            if(ar[i]%3!=0 && ar[i]%5!=0){
                ans = false;
                continue;
            }
        }
    }
    if(ans==true) cout << "APPROVED" << endl;
    else cout << "DENIED" << endl;
    return 0;
}

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

int sum(int n){
  int x = 0;
  while(n >= 1){
    x += n % 10;
    n /= 10;
  }
  return x;
}

int main() {
  int n;
  cin >> n;
  
  if(n % sum(n) == 0) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

int main(){
  string s;
  int a,b,n,m = 0;
  cin >> s;
  for(int i = 0;i < s.size()-1;i++){
    if(s[i] == 'A' && s[i+1] == 'C')
      m = 1;
  }
  if(m == 1)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}


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

int main(void){
  char o[51];
  char e[51];
  scanf("%s %s", o, e);
  
  for(int i = 0; i < strlen(e); i++){
    printf("%c%c", o[i], e[i]);
  }
  if(strlen(o) > strlen(e)) printf("%c", o[strlen(o) - 1]);
  printf("\n");
  return 0;
}

Measured memory_bytes: 128
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt(); //命令の数
        Set<String> set = new HashSet<String>();
        for(int i=0; i<n; i++) {
            String s1 = sc.next();
            String s2 = sc.next();
            if (s1.equals("insert")) {
                set.add(s2);
            } else if (set.contains(s2)) {
                System.out.println("yes");
            } else {
                System.out.println("no");
            }
        }
    }
}



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

int main() {
    double input, min = -1, max = -1;
    while (cin >> input) {
        if (min == -1 || max == -1) {
            min = input;
            max = input;
        }
        if (max < input) {
            max = input;
        } else if (input < min) {
            min = input;
        }
    }
    cout << max - min << endl;
}

Measured memory_bytes: 0
#include<cstdio>
#include<algorithm>

#define MAX_M 20
#define MAX_N 50000
#define MAX_NUM 20000

using namespace std;

int C[MAX_M + 5], T[MAX_N + 5];

int main()
{
    int m, n, i, j;
    scanf("%d %d", &n, &m);
    for (i = 0; i < m; i++) {
        scanf("%d", &C[i]);
    }
    T[0] = 0;
    for (i = 1; i <= n; i++) {
        T[i] = MAX_NUM;
    }
    for (i = 0; i < m; i++) {
        for (j = 0; j + C[i] <= MAX_N; j++) {
            if (T[j] + 1 < T[j + C[i]]) {
                T[j + C[i]] = T[j] + 1;
            }
        }
    }
    printf("%d\n", T[n]);

    return 0;
}

Measured memory_bytes: 2880
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import java.math.*;
import java.text.*;
import java.util.*;

public class Main {	
	
	public static void main(String[] args) throws NumberFormatException, IOException 
	{
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		Task solver = new Task();
		solver.solve(1, in, out);
		out.close();
	}
	
	static class Task {
		
        public void solve(int testNumber, InputReader in, PrintWriter out) {

        	int a = in.nextInt();
        	int b = in.nextInt();
        	int c = in.nextInt();
        	int d = in.nextInt();
        	
        	if(b < c){
        		out.println(0);
        	}
        	else{
        		out.println(Math.max(0 , Math.min(b, d) - Math.max(a, c) ) );
        	}

        }
        
	}
	
	static class InputReader {
		
		BufferedReader in;
		StringTokenizer tok;
		
		public InputReader(InputStream stream){
			in = new BufferedReader(new InputStreamReader(stream), 32768);
			tok = null;
		}
		
		String nextToken() 
		{
			String line = "";
			while(tok == null || !tok.hasMoreTokens()) {
				try {
					if((line = in.readLine()) != null)
						tok = new StringTokenizer(line);
					else 
						return null;
				} catch (IOException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
					return null;
				}
			}
			return tok.nextToken();
		}
		int nextInt(){
			return Integer.parseInt(nextToken());
		}
		long nextLong()	{
			return Long.parseLong(nextToken());
		}
		double nextDouble()	{
			return Double.parseDouble(nextToken());
		}	
		
	}	
	
}








Measured memory_bytes: 21332
n=int(input()) 
dp1,dp2,dp3=[0]*n,[0]*n,[0]*n
f=[]
for i in range(n):
	f.append([int(x) for x in input().split()])  
dp1[0]=f[0][0] 
dp2[0]=f[0][1] 
dp3[0]=f[0][2] 
for i in range(1,n):
	dp1[i]=f[i][0]+max(dp2[i-1],dp3[i-1]) 
	dp2[i]=f[i][1]+max(dp1[i-1],dp3[i-1])
	dp3[i]=f[i][2]+max(dp2[i-1],dp1[i-1])
print(max(dp1[-1],dp2[-1],dp3[-1])) 

Measured memory_bytes: 92780
N = int(input())
C = input()
White = C.count("W")
Red = C.count("R")
left_white = 0
left_red = 0
right_white = White
right_red = Red
ans = Red
for n,c in enumerate(C):
    if c == "W":
        left_white += 1
        right_white -= 1
    else:
        left_red += 1
        right_red -= 1
    ans = min(ans,max(left_white,right_red))
print(ans)

Measured memory_bytes: 68328
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N=0;
  cin>>N;
  vector <int> vec(N);
  for (int i=0; i<N; i++){
    cin>>vec.at(i);
  }
  int ans=0;
  int dans=100000000;
  int d=10000000;
  for(int i=0; i<100; i++){
    d=0;
    for(int j=0; j<N; j++){
      d+=(vec.at(j)-i)*(vec.at(j)-i);
    }
    if(d<dans){
      dans=d;
      ans=i;
    }
  }
  cout<<dans<<endl;
 
  
}

Measured memory_bytes: 3624
//	????????????????????????????????°???????????????????????\?????????????????????

import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		/*	?¨??????\???????????????????????????????????????	*/
		Scanner sc = new Scanner(System.in);
		
		/*	 ????£???¨?¨??£??????¬??°?????\??????*/
		int w = sc.nextInt();
		int n = sc.nextInt();
		
		/*	????£??????°????????????	*/
		int[] values = new int[w];
		for(int i = 0; i< values.length; i++){
			values[i] = i + 1;
		}
		
		/*	?¨??£??????????	*/
		for(int i=0; i<n; i++){
			String str = sc.next();
			String[] ab = str.split(",");
			/*????£????????????????????????????????????????(?????????)???*/
			int a = Integer.parseInt(ab[0]) - 1;
			int b = Integer.parseInt(ab[1]) -1;
			int c = values[a];
			values[a] = values[b];
			values[b] = c;
			
		}
		for(int i=0; i<values.length; i++){
			System.out.println(values[i]);
		}
	}

}

Measured memory_bytes: 26008
def solve(n, u, v):
    res = (n*(n+1)*(2*n+1)//6 + n*(n+1)//2) // 2
    for l, r in zip(u, v):
        if l > r:
            l, r = r, l
        res -= l * (n - r + 1)
    return res

n = int(input())
u = [0] * n
v = [0] * n
for i in range(n-1):
    u[i], v[i] = map(int, input().split())
print(solve(n, u, v))

Measured memory_bytes: 24712
#include<stdio.h>

int main(void)
{
   int i,j;
   char c[4][4];
   for(i=0;i<3;i++){
      for(j=0;j<4;j++){
      scanf("%c",&c[i][j]);
         if(j==4)
         c[i][j]='\0';
      }
   }

   printf("%c",c[0][0]);
   printf("%c",c[1][1]);
   printf("%c",c[2][2]);
   printf("\n");
   return 0;
   }


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vel;
typedef vector<int> vei;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> ve_vel;
typedef vector<vector<int>> ve_vei;
typedef vector<vector<char>> ve_vec;
typedef vector<vector<bool>> ve_veb;
typedef vector<vector<string>> ve_ves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pub push_back
#define pob pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
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 N;
vei g[100000];
int dist[2][100000], id;
 
void dfs(int idx, int p = -1)
{
  if(~p) dist[id][idx] = dist[id][p] + 1;
  for(auto &to : g[idx]) if(to != p) dfs(to, idx);
}
 
int main()
{
  cin >> N;
  for(int i = 0; i < N - 1; i++) {
    int a, b;
    cin >> a >> b;
    --a, --b;
    g[a].emplace_back(b);
    g[b].emplace_back(a);
  }
 
  id = 0;
  dfs(0);
  id = 1;
  dfs(N - 1);
 
  int ret = 0;
  for(int i = 0; i < N; i++) {
    if(dist[0][i] <= dist[1][i]) ++ret;
  }
  if(ret >= (N + 2) / 2) cout << "Fennec" << endl;
  else cout << "Snuke" << endl;
}

Measured memory_bytes: 11136
while True:
    b = int(input())
    if b == 0:
        break
    n = 1
    ans = []
    while True:
        # print(n)
        if n % 2 == 0:
            if b % n != 0:
                if b // n >= n // 2:
                    if (b / n * 10) % 5 == 0:
                        ans = [b // n - n // 2 + 1, n]
                else:
                    break
        else:
            if b % n == 0:
                if b // n - 1 >= (n - 1) // 2:
                    ans = [b // n - 1 - (n - 1) // 2 + 1, n]
                else:
                    break
        n += 1
        # print(ans)
    print(ans[0], ans[1])


Measured memory_bytes: 5612
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Globalization;
using System.Diagnostics;
using static System.Console;
using Pair = System.Collections.Generic.KeyValuePair<int, int>;
//using System.Numerics;

class Program
{
    static void Main()
    {
        //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
        new Program().solve();
        Out.Flush();
    }
    Scanner cin = new Scanner();
    Random rnd = new Random();
    Stopwatch sw = new Stopwatch();
    readonly int[] dd = { 0, 1, 0, -1, 0 };
    readonly int mod = 1000000007;
    readonly string alfa = "abcdefghijklmnopqrstuvwxyz";
    readonly string ALFA = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

    int N;
    void solve()
    {
        N = cin.nextint;
        long x = cin.nextint;
        var B = cin.scanlong;
        var A = new long[N];
        B.CopyTo(A, 0);
        long ans = 0;
        for (int i = 1; i < N; i++)
        {
            if (B[i] + B[i - 1] > x)
            {
                long d = (B[i] + B[i - 1]) - x;
                ans += d;
                if (B[i] < d)
                {
                    B[i - 1] -= d - B[i];
                    B[i] = 0;
                }
                else B[i] -= d;
            }
        }

        WriteLine(ans);
    }


}

class Scanner
{
    string[] s; int i;
    char[] cs = new char[] { ' ' };
    public Scanner() { s = new string[0]; i = 0; }
    public string[] scan { get { return ReadLine().Split(); } }
    public int[] scanint { get { return Array.ConvertAll(scan, int.Parse); } }
    public long[] scanlong { get { return Array.ConvertAll(scan, long.Parse); } }
    public double[] scandouble { get { return Array.ConvertAll(scan, double.Parse); } }
    public string next
    {
        get
        {
            if (i < s.Length) return s[i++];
            string st = ReadLine();
            while (st == "") st = ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
            return next;
        }
    }
    public int nextint { get { return int.Parse(next); } }
    public long nextlong { get { return long.Parse(next); } }
    public double nextdouble { get { return double.Parse(next); } }
}

Measured memory_bytes: 30424
#ifdef LOCAL
#include <cstdio>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cstring>
#else
#include <bits/stdc++.h>
#endif
using namespace std ;

typedef long long ll ;
#define rep(i , n ) for ( int i =0; i < n ; i++)
#define _sort(arg) sort(begin(arg), end(arg))
#define MOD 1000000007
#define pb push_back
#define DEBUG(x) cout << #x << ": " << x << endl;

/*
__attribute__((constructor))
void initial()
{
	cin.tie(NULL);
	ios::sync_with_stdio(false);
}
*/

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

	ll X;
	
	cin >> X;

	ll sum = 0;
	int i = 0;
	while(sum < X)
	{
		sum += ++i;
	}

	cout << i << endl;

	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define INF 999999999
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<n;++i)

using namespace std;

typedef pair<int,int>P;

const int MAX_N = 505;

vector<int> G[MAX_N];
vector<int> GG;
int n,m;
bool visited[MAX_N];

int main()
{
	while(1){	
		scanf("%d",&n);
		scanf("%d",&m);
		if(n==0&&m==0){
			break;
		}
		rep(i,MAX_N){
			G[i].clear();
		}
		fill(visited,visited+MAX_N,false);
		GG.clear();
		rep(i,m){
			int a,b;
			scanf("%d%d",&a,&b);
			G[a-1].push_back(b-1);
			G[b-1].push_back(a-1);
		}
		rep(i,G[0].size()){
			visited[G[0][i]] = true;
			GG.push_back(G[0][i]);
		}
		rep(i,GG.size()){
			rep(j,G[GG[i]].size()){
				visited[G[GG[i]][j]] = true;
			}
		}
		int ans=0;
		for(int i=1;i<n;i++){
			if(visited[i]){
				ans++;
			}
		}
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 3212
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep_1(i,n) for(int (i)=0;(i)<=(n);(i)++)
#define rep_2(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int main(){
    ll n,m;cin>>n>>m;
    vector<bool> a(n+1,true);
    rep(i,m){
        ll tmp;cin>>tmp;
        a[tmp] = false;
    }
    vector<ll> dp(n+1);

    dp[0] = 1;
    if(a[1]) dp[1] = 1;
    for(ll i =  2;i<=n;i++){
        if(a[i])dp[i] = dp[i-1] + dp[i-2];
      	dp[i] %= MOD;
    }

    cout << dp[n] <<endl;
}



Measured memory_bytes: 1024
#include<stdio.h>
#include <stdlib.h>

int main(void){
    int K, X, i;
    
    scanf("%d %d", &K, &X);
    
    for(i=X-K+1;i<=X+K-1;i++) printf(" %d", i);
    printf("\n");
    
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <queue>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
using ll = long long;

using namespace std;



int main() {
    int n, m;
    cin >> n >> m;
    priority_queue<int> q;
    rep(i,n) {
        int a;
        cin >> a;
        q.push(a);
    }
    ll ans = 0;
    rep(i,m) {
        int a = q.top();  q.pop();
        q.push(a/2);
    }
    rep(i,n) {
        ans += q.top(); q.pop();
    }
    
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3868
#include <iostream>
#include <cstdlib>
#include <list>
using namespace std;

int main() {
	list<int>L; int n, x; char s[15];
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> s;
		if (s[0] == 'i')cin >> x,  L.push_front(x);
		else if (s[6] == 'F')L.pop_front();
		else if (s[6] == 'L')L.pop_back();
		else {
			cin >> x;
			for (list<int>::iterator it = L.begin(); it != L.end(); it++)
				if (*it == x) {
					L.erase(it); break;
				}
		}
		
	}
	n = 0;
	for (list<int>::iterator it = L.begin(); it != L.end(); it++) {
		if (n++)cout << " ";
		cout << *it;
	}
	cout << endl;
}

Measured memory_bytes: 34224
#include <stdio.h>
int main(void){
   int a,b,c,x;
    scanf("%d%d%d%d",&a,&b,&c,&x);
    int r = solve(a,b,c,x);
    printf("%d\n",r);
    return 0;
}

int solve(a,b,c,x){
    int ans = 0;
    for(int i=0; i<=a; ++i){
        for(int j=0; j<=b; ++j){
            for(int k=0; k<=c; ++k){
                int tmp = (i*500)+(j*100)+(k*50);
                    if(tmp==x) {ans++;}
            }
        }
    }
    return ans;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <string>
#include <functional>
#include <algorithm>
using namespace std;

typedef long long ll;

bool is_prime(int n)
{
    bool prime = true;
    if(n == 1) return false;
    for(int i = 2; i * i <= n; i++) {
        if(n % i == 0) {
            prime = false;
            break;
        }
    }
    return prime;
}

int main()
{
    int a, d, n;
    while(cin >> a >> d >> n && a && d && n) {
        int cnt = 0, num;
        for(int i = 0; ; i++) {
            num = a + d * i;
            if(is_prime(num)) 
                cnt++;
            
            if(cnt == n) {
                cout << num << endl;
                break;
            }
        }
    }
}

Measured memory_bytes: 864
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#define N 10
using namespace std;

int n, c, x[N], y[N], t[N];
double s;

int wprhq(int p) {return p * p;}

int main()
{
	int i;
	cin >> n;
	for (i = 0; i < n; i++) {
		scanf("%d %d", &x[i], &y[i]);
		t[i] = i;
	}
	do {
		for (i = 1; i < n; i++) {
			s += sqrt(1.0 * wprhq(x[t[i]] - x[t[i - 1]]) + wprhq(y[t[i]] - y[t[i - 1]]));
		}
		c++;
	} while (next_permutation(t, t + n));
    printf("%.9f", s / c);
    return 0;
}

Measured memory_bytes: 256
/********************/
/* K B G D E L T A */
/*     DA-IICT      */
/********************/
 
#include<bits/stdc++.h>
using namespace std;
using   ll=long long;
using   ld=long double;
#define fast           ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define endl           "\n"
#define F(i,n)         for(ll i=0;i<n;i++)
#define rep(i,a,b)     for(ll i=a;i<b;i++)
#define repp(i,a,b)    for(ll i=a;i>=b;i--)
#define pb             push_back
#define mp             make_pair
#define vll            vector<ll>
#define f              first
#define s              second
#define pll            pair<ll,ll>
#define ALL(v)         v.begin(),v.end()
#define ALLR(v)        v.rbegin(),v.rend()
#define pii            3.14159265358979323
#define mod            1000000007
 
void solve()
{
    ll n,ans=0;

    cin>>n;

    vll a(n);

    F(i,n)
    {
        cin>>a[i];
    }

    vll dp(n+1,0);

    for(int i=n-2;i>=0;i--)
    {
        if(a[i]>=a[i+1])
        {
            dp[i]=dp[i+1]+1;

            ans=max(ans,dp[i]);
        }
    }

    cout<<ans;
}
 
signed main(){
 
    fast;
 
    ll t=1;
 
    //cin>>t;
 
    while(t--)
    {
        solve();
    }
 
    return 0;
}


Measured memory_bytes: 1920
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define dup(x,y) (((x)+(y)-1)/(y))
#define v(T) vector<T>
#define vv(T) v(v(T))
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;
inline int getInt() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MX = 200005;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
//---------------------------------------------------------------
#define fastio std::ios::sync_with_stdio(false);
#define myio ifstream iofi; if(argc>1){iofi.open(argv[1]); std::cin.rdbuf(iofi.rdbuf());}
//--------------------------------------------------------------

void Main(){
  string s,t;
  cin>>s>>t;
  map<char,vi> tm;
  set<char> list;
  rep(i,t.length()) tm[t[i]].pb(i);
  for(auto i:tm){
    char eq = s[i.se[0]];
    if(list.find(eq)==list.end()){list.insert(eq);}
    else{cout<<"No"; return;}
    for(auto j:i.se){
      if(s[j]!=eq){cout<<"No"; return;}
    } 
  }
  cout<<"Yes";
}

int main(int argc,char** argv)
{fastio; myio; Main();}


Measured memory_bytes: 2192
#include <iostream>
#include <string>

using namespace std;

int main()
{
	long long A;
	string B;
	cin >> A >> B;
	
	long long ans = 0;
	ans += A * 100 * (B[0] - '0');
	ans += A * 10 * (B[2] - '0');
	ans += A * 1 * (B[3] - '0');
	ans /= 100;
	cout << ans << endl;
}


Measured memory_bytes: 3628
def gcd(x1, x2):
    if x2 == 0:
        return x1
    return gcd(x2, x1 % x2)

N, X = map(int, input().split())
x = list(map(int, input().split()))
if N == 1:
    print(abs(X - x[0]))
    exit()
x.sort()
D = gcd(abs(X-x[0]), abs(X-x[1]))
for i in range(2, N):
    D = gcd(D, abs(X - x[i]))
print(D)

Measured memory_bytes: 14224
#include<iostream>
#include<algorithm>
#include<vector>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;

int main()
{
    int a,b,c;
    cin >> a >> b >> c;
    int five=0,seven=0;
    if(a == 5)
    {   
        five++;
    }
    if(a == 7)
    {
        seven++;
    }

    if(b == 5)
    {   
        five++;
    }
    if(b == 7)
    {
        seven++;
    }

    if(c == 5)
    {   
        five++;
    }
    if(c == 7)
    {
        seven++;
    }

    if(five == 2 && seven == 1)
    {
        cout << "YES" << endl;
    }
    else
    {
        cout << "NO" << endl;
    }
}


Measured memory_bytes: 256
import math

n,d = map(int,input().split())

xy = [0]*n

for i in range(n):
  xy[i] = input().split()
  
c = 0

for i in range(n):
  tmp = math.sqrt(int(xy[i][0])**2 + int(xy[i][1])**2)
  if d >= tmp:
    c += 1
print(c)

Measured memory_bytes: 106180
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	static BufferedReader reader;
	//static field here
	
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		reader = new BufferedReader(new InputStreamReader(System.in));
		//code here
		String[] strings = readLine();
		long L = Long.parseLong(strings[0]);
		long R = Long.parseLong(strings[1]);
		print(lcm(L,R));
		
		
		
		//String[] s = readLine();
		//print(num);
	}
	
	//functions here
	//note that all methods should be STATIC
	private static long gcd(long m, long n) {
	    if(m < n) return gcd(n, m);
	    if(n == 0) return m;
	    return gcd(n, m % n);
	}
	private static long lcm(long m, long n) {
	    return m * n / gcd(m, n);
	}
	private static String[] readLine(){
		try{
			return reader.readLine().split(" ");
		}catch(Exception e){
			e.printStackTrace();
			return new String[]{e.getMessage()};
		}
	}
	private static void print(Object o){
		System.out.println(o);
	}
	private static void print(){
		System.out.println();
	}
}


Measured memory_bytes: 22740
import std.stdio;
import std.c.stdio;
import std.range;
import std.array;
import std.functional;
import std.algorithm;
import std.conv;
import std.container;
import std.math;
import std.numeric;
import std.string;
import std.c.string;
import std.regex;
import std.typecons;
 
void main() {
    int S, D, M;
    int[] P, W;
    int[][] P1, W1;
    bool input() {
        int r = scanf("%d %d %d\n", &S, &D, &M);
        if (r == EOF) return false;
        P.clear;
        W.clear;
        P1 = new int[][S];
        W1 = new int[][S];
        foreach (i; 0 .. S) {
            int k; scanf("%d\n", &k);
            P1[i] = new int[k];
            W1[i] = new int[k];
            foreach (j; 0 .. k) {
                int w, p;
                scanf("%d %d", &w, &p);
                P1[i][j] = p;
                W1[i][j] = w;
            }
        }
        foreach (i; 0 .. D) {
            int f; scanf("%d", &f);
            P ~= P1[f];
            W ~= W1[f];
        }
        return true;
    }

    void solve() {
        auto dp = new int[][](2, M + 1);
        foreach (i; 0 .. 2) dp[i][] = int.min;
        auto N = P.length;
        dp[0][0] = 0;
        for (long n = 1; n <= N; n++) {
            for (long c = 0; c <= M; c++) {
                dp[n & 1][c] = dp[(n - 1) & 1][c];
                if (c - P[n - 1] >= 0) {
                    dp[n & 1][c] = max(dp[n & 1][c], dp[(n - 1) & 1][c - P[n - 1]] + W[n - 1]);
                }
            }
        }
        int x = dp[N & 1].reduce!max;
        writeln(x, " ", dp[N & 1].countUntil(x));
    }
    while (input) solve;
}

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

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

  vector<bool> ac(n);
  vector<int> pena(n);
  rep(i, m){
    int p;
    string s;
    cin >> p >> s;
    --p;
    if(ac[p] == false){
      if(s == "AC")
        ac[p] = true;
      else
        pena[p]++;
    }
  }
  
  int AC = 0, PENA = 0;
  rep(i, n){
    if(ac[i]){
      AC++;
      PENA += pena[i];
    }
  }

  cout << AC << " " << PENA << endl;

  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
using namespace std;
typedef long long ll; 
typedef long double ld;
typedef pair<ll, ll> pll;

const ll N = 2e5 + 30, Mod = 1e9 + 7;
const ll SQ = 330;

int main () {
	ios::sync_with_stdio(0), cin.tie(0);
    	ll a, b;
    	cin >> a>> b;
    	cout << a * b;
}

Measured memory_bytes: 3668
#include <iostream>
#include <string>
#define _USE_MATH_DEFINES
#include <math.h>
using namespace std;

int main()
{
	unsigned long long x,a,b;
	cin >> x;
	a = 100;
	b = 0;

	while (x > a) {
		a = a + a * 0.01;
		b++;
	}
	cout << b << endl;
	

}

Measured memory_bytes: 3636
n,c,k=map(int, input().split())
t=[int(input()) for _ in range(n)]
t.sort()
tmp_lim=t[0]+k
num_bus=0
num_person=1
for i in range(1, n):
    if tmp_lim<t[i] or c<=num_person:
        num_bus+=1
        tmp_lim=t[i]+k
        num_person=1
    else:
        num_person+=1
    # print(num_bus, num_person, tmp_lim)
print(num_bus+1)

Measured memory_bytes: 13328
N, M = tuple(map(int, input().split()))
Hs = tuple(map(int, input().split()))

good = [True] * N

for _ in range(M):
    A, B = tuple(map(int, input().split()))
    H_A, H_B = Hs[A-1], Hs[B-1]
    if H_A < H_B:
        good[A-1] = False
    elif H_B < H_A:
        good[B-1] = False
    else:
        good[A-1] = good[B-1] = False

print(sum([v == True for v in good]))

# path = [[0] * N for _ in range(N)]
# for _ in range(M):
#     A, B = tuple(map(int, input().split()))
#     H_A, H_B = Hs[A-1], Hs[B-1]
#     path[A-1][B-1] = H_B
#     path[B-1][A-1] = H_A

# print(sum(all(Hs[i] > h for h in p) for i, p in enumerate(path)))


Measured memory_bytes: 20256
package main

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

var scanner = bufio.NewScanner(os.Stdin)

func nextString() string {
	scanner.Scan()
	return scanner.Text()
}

func nextInt() int {
	n, err := strconv.Atoi(nextString())
	if err != nil {
		fmt.Printf("strconv.Atoi failed: %v\n", err)
	}
	return n
}

func binarySearchLoop(a []int, b, e, k int) (bool, int) {
	// fmt.Println(a, a[b:e], b, e, k)

	n := len(a)

	// fmt.Println(k <= a[b], a[e-1] < k)
	if k <= a[b] {
		return true, b
	} else if a[e-1] < k {
		return true, n
	}

	// fmt.Println(b, e, e-b)
	if e-b <= 2 {
		// fmt.Println(a[b] < k && k <= a[b+1], a[b+1] < k && k <= a[e])
		if a[b] < k && k <= a[b+1] {
			return true, b + 1
		} else if a[b+1] < k && k <= a[b+2] {
			return true, b + 2
		}
	}

	mid := (b + e) / 2
	// fmt.Println(a, b, mid, e, a[b:(mid+1)], a[mid:e], k, e-b+1)
	if a[mid] < k && k <= a[mid+1] {
		return true, mid + 1
	}

	// fmt.Println("a[mid] > k :", a[mid] > k)
	if a[mid] >= k {
		okLeft, iLeft := binarySearchLoop(a, b, mid+1, k)
		if okLeft {
			return true, iLeft
		}
	}
	// fmt.Println("before right", a, mid, e, k)
	okRight, iRight := binarySearchLoop(a, mid, e, k)
	// fmt.Println(okRight, iRight)
	if okRight {
		return true, iRight
	}

	return false, -1
}

func binarySearch(a []int, k int) int {
	n := len(a)

	if k <= a[0] {
		return 0
	} else if a[n-1] < k {
		return n
	}

	_, i := binarySearchLoop(a, 0, n, k)
	return i
}

func main() {
	scanner.Split(bufio.ScanWords)
	sizeA := nextInt()
	a := make([]int, sizeA)
	for i := 0; i < sizeA; i++ {
		a[i] = nextInt()
	}
	nQueries := nextInt()
	for i := 0; i < nQueries; i++ {
		qi := nextInt()
		fmt.Println(binarySearch(a, qi))
	}
}


Measured memory_bytes: 5908
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;
 
static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const ll INF = 1023456789;
 
#define REP(i,n)	for(int i=0;i<n;++i)
#define REPR(i,n)	for(int i=n-1;i>=0;--i)
#define FOR(i,s,n)	for(int i=s;i<n;++i)
#define FORR(i,s,n)	for(int i=n-1;i>=s;--i)
#define ALL(c)		(c).begin(),(c).end()
#define CLEAR(v)	memset(v,0,sizeof(v))
#define MP(a,b)		make_pair((a),(b))
#define ABS(a)		((a)>0?(a):-(a))
#define F			first
#define S			second
 
int main(int argc, char **argv) {
	int a, b;
	cin >> a >> b;
	cout << (a - (a <= b ? 0 : 1)) << endl;
	return 0;
}
 

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

int main(){
  int n, k;
  cin >> n >> k;
  double res = 0;

  for (int i = 1; i <= n; i++) {
    int now = i;
    double p = 1.0 / n;
    while (now < k) p *= 0.5, now *= 2;
    res += p;
  }
  printf("%.12f\n", res);
  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<string>
#include<algorithm>
#include<stdio.h>
#include<locale.h>
#include<math.h>
#include<set>
#include<stack>
#include<queue>
using namespace std;

int main()
{
 int n;
 long long int money=1000;
 long long int kabu;
 int a[200];
 scanf("%d",&n);
 for(int i=0;i<n;i++)
 {
	 scanf("%d",&a[i]);
 }
 for(int i=1;i<n;i++)
 {
  kabu=money/a[i-1];
  money-=kabu*a[i-1];
  money+=kabu*max(a[i],a[i-1]);
 }
 printf("%lld",money);
}

Measured memory_bytes: 3792
import java.util.*;
import java.io.*;
public class Main  {
    public static void main(String args[]) {
      FastScanner fs=new FastScanner();    
      PrintWriter out=new PrintWriter(System.out);
      String s=fs.next();
      String t=fs.next();
      int l1=s.length();
      int l2=t.length();
      
      int i,j;
      char ch;
      int min=0;
      String sub;
      if(l1==l2)
      {
          for(i=0;i<l1;i++)
          {
              if(s.charAt(i)!=t.charAt(i))
              min++;
          }
      }
      else
      {min=l2;
      for(i=0;i<l1-l2;i++)
      {
        sub=s.substring(i,i+l2);
        int c=0;
        for(j=0;j<l2;j++)
        {
            if(sub.charAt(j)!=t.charAt(j))
            c++;
        }
        if(c<min)
        min=c;
      }
      }
      out.println(min);
        
        out.flush();
        out.close();
    }
	static void ruffleSort(int[] a) {
 		Random random=new Random();
		int n=a.length;
		for (int i=0; i<n; i++) {
			int oi=random.nextInt(n), temp=a[oi];
			a[oi]=a[i]; a[i]=temp;
		}
		Arrays.sort(a);
	}
}
        class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		
		String next() {
			while (!st.hasMoreTokens())
				try {
				st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}
		String nextLine(){
		    String str="";
		    try{
		        str=br.readLine();
		    }catch(IOException e){
		        e.printStackTrace(); }
		    return str;
		}
		int nextInt() {
			return Integer.parseInt(next());
		}
		int[] readArray(int n) {
			int[] a=new int[n];
			for (int i=0; i<n; i++) a[i]=nextInt();
			return a;
		}
		long nextLong() {
			return Long.parseLong(next());
		}
	}

Measured memory_bytes: 33800
#include <iostream>
#include <array>
#include <algorithm>
#include <map>
#include <vector>
#include <list>
#include <cmath>
#include <stack>
#include <queue>
#include <climits>
#include <string.h>
#include <cctype>
#include <set>

#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using namespace std;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }

// a と b の最大公約数を返す関数
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
	ll x; // typedef long long ll;
	mint(ll x = 0) :x((x% mod + mod) % mod) {}
	mint operator-() const { return mint(-x); }
	mint& operator+=(const mint a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this; }
	mint operator+(const mint a) const { return mint(*this) += a; }
	mint operator-(const mint a) const { return mint(*this) -= a; }
	mint operator*(const mint a) const { return mint(*this) *= a; }
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

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

struct combination {
	vector<mint> fact, ifact;
	combination(int n) :fact(n + 1), ifact(n + 1) {
		fact[0] = 1;
		for (int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i;
		ifact[n] = fact[n].inv();
		for (int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i;
	}
	mint operator()(int n, int k) {
		if (k < 0 || k > n) return 0;
		return fact[n] * ifact[k] * ifact[n - k];
	}
} comb(2000005);

mint g(int r, int c) {
	return comb(r + c + 2, r + 1) - 1;
}

bool comp(int i, int j) {
	return i > j;
}

int main()
{
	int n, l;
	cin >> n >> l;
	int d[200];
	int sum = 0;
	for (int i = 0; i < n; i++)
	{
		d[i] = l + i;
		sum += d[i];
	}

	int check = sum;
	check -= d[0];
	int near = check;
	for (int i = 1; i < n; i++)
	{
		check += d[i - 1];
		check -= d[i];
		if (abs(check - sum) < abs(near - sum))
		{
			near = check;
		}
	}
	cout << near;
}



Measured memory_bytes: 31488
def main():  
  x = int(input())
  a = 1
  while True:
    c = a**5
    for b in range(-a,a+1):
      d = c - b**5
      if d == x:
        print(a,b)
        return
      if d == -x:
        print(b,a)
        return
    a+=1
  
if __name__ == "__main__":
  main()

Measured memory_bytes: 9112
#include <iostream>
#include <utility>
#include <vector>
using namespace std;
int n,m;
vector<int> member;//<num>

void solve() {
  int temp;
  member.clear();
  for(int i=1;i<=n;i++) { //initializing member
    member.push_back(i);
  }

  int pass = 0;
  int kill = 0;
  vector<int>::iterator it = member.end()-1;

  while(kill < n-1) {
    if(it != member.end()-1) {
      it++;
    }
    else {
      it = member.begin();
    }
    pass++;
    if(pass == m) {
      pass = 0;
      member.erase(it);
      it--;
      kill++;
    }
  }
  cout << member[0] << endl;
}

int main() {
  while(cin >> n >> m) {
    if(n==0 && m==0) break;
    solve();
  }
}

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

int main(){
    int n, max = 0;
    string s;
    vector<string> ans;
    map<string, int> dict;
    cin>>n;
    for(int i=0; i<n; i++){
        cin>>s;
        dict[s]++;
        if(dict[s]>max){
            max = dict[s];
            ans.clear();
            ans.push_back(s);
        } else if (dict[s] == max){
            ans.push_back(s);
        }
    }

    sort(ans.begin(), ans.end());
    
    for (string str : ans){
        cout<<str<<endl;
    }
    return 0;
}



Measured memory_bytes: 26736
#include<bits/stdc++.h>
using namespace std;
#define arep(i,x,n) for(int i=int(x);i<(int)(n);i++)
#define rep(i,n) for(long long i = 0;i < n;++i)
#define pi 3.141592653589793
#define eps 0.00000001
#define INF 1e9+7  
using ll = long long; 
using P=pair<int,int>;
using lP=pair<ll,ll>;
using fP=pair<double,double>;
ll const mod=998244353;
const ll MAX=300000;
using vi=vector<int>;
using vc=vector<char>;
using vs=vector<string>;
using vvi =vector<vector<int>>;
using vvc=vector<vector<char>>;
using vvp =vector<vector<P>>;
int main(){
    int n,m;
    cin>>n>>m;
    vi c(m);
    rep(i,m)cin>>c[i];
    vvi dp(m+1,vi(n+1,INF));
    dp[0][0]=0;
    rep(i,m){
        rep(j,n+1){
            if(j>=c[i]){
                dp[i+1][j]=min(dp[i+1][j-c[i]]+1,dp[i][j]);
            }
            else{
                dp[i+1][j]=dp[i][j];
            }
        }
    }
    cout<<dp[m][n]<<endl;
    return 0;
}


Measured memory_bytes: 7148
sx,sy,tx,ty = map(int,input().split())

Ans1 = []
Ans2 = []
dx = tx - sx
dy = ty - sy
cnt = abs(dx) + abs(dy)
if dy > 0:
    for i in range(dy):
        Ans1.append("U")
        Ans2.append("D")
else:
    for i in range(-dy):
        Ans1.append("D")
        Ans2.append("U")
if dx > 0:
    for i in range(dx):
        Ans1.append("R")
        Ans2.append("L")
else:
    for i in range(-dx):
        Ans1.append("L")
        ANs2.append("R")

add1 = ["L","U"]
add2 = ["R","D"]

print("".join(Ans1) ,end="")
print("".join(Ans2) ,end="")

if Ans1[0] == "U":
    print("".join(add1),end="")
    print("".join(Ans1) ,end="")
    print("".join(add2),end = "")
    print("".join(add2),end="")
    print("".join(Ans2) ,end="")
    print("".join(add1))
else:
    print("".join(add2),end="")
    print("".join(Ans1) ,end="")
    print("".join(add1),end="")
    print("".join(add1),end="")
    print("".join(Ans2) ,end="")
    print("".join(add2))

Measured memory_bytes: 9312
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
int main(void){
    int n;
    cin>>n;
    int p[100001];
    for(int i=1;i<=n;i++) cin>>p[i];
    int ans=0;
    for(int i=1;i<=n-1;i++){
        if(p[i]==i){
            ans++;
            int temp=p[i];
            p[i]=p[i+1];
            p[i+1]=temp;
        }
    }
    if(p[n]==n) ans++;
    cout<<ans<<endl;
}

Measured memory_bytes: 640
n = int(input())
a = list(map(int, input().split()))
cnt = 0
m = float('inf')
for i in range(n):
    if a[i] < 0:
        cnt += 1
    if abs(a[i]) < m:
        m = abs(a[i])
ans = 0
for i in range(n):
    ans += abs(a[i])
if cnt % 2 == 1:
    ans -= m * 2
print(ans)

Measured memory_bytes: 14412
#include<iostream>
#include<unordered_map>
#include<cstdio>
using namespace std;
#define N 16
#define U 65537
#define mod 1000000007
inline int M(int x){return (x>=mod)?(x-mod):x;}
inline int M1(int x){return (x<0)?(x+mod):x;}
inline int ksm(int p,int k){int res=1;while(k){if(k&1)res=1ll*res*p%mod;k>>=1;p=1ll*p*p%mod;}return res;}
int n,m,all,ans,f[U],w[N][N],deg[N][U],P[N];unordered_map<int,int>g[U];
int main(){
	P[0]=0;for(int i=1;i<N;i++)P[i]=M(P[i-1]<<1|1);
	scanf("%d%d",&n,&m);all=(1<<n)-1;int i,x,y,res,S,T,p,v;
	for(i=1;i<=m;i++){scanf("%d%d",&x,&y);++w[x-1][y-1];}
	for(x=0;x<n;x++)
	for(S=0;S<=all;S++)
	for(y=0;y<n;y++)
	if((S&(1<<y))&&w[x][y])deg[x][S]+=w[x][y];
	ans=ksm(2,m);f[0]=1;
	for(T=3;T<=all;T++)
	if(((T&3)==3)||((T&3)==0))
	for(S=T;S;S=T&(S-1))
	{
		p=T^S;v=1;
		if(((p&3)==3)||((p&3)==0))
		{
			for(x=0;x<n;x++)
			if(T&(1<<x))
			{
				if(p&(1<<x))v=1ll*v*P[deg[x][S]]%mod;
				else v=1ll*v*M(P[deg[x][p]]+1)%mod;
			}
		}f[T]=(f[T]+1ll*f[p]*v)%mod;
	}printf("%d",M1(ans-f[all]));return 0;
}

Measured memory_bytes: 6912
N,Ma,Mb = map(int,input().split())

INF = 10000

dp = [[[INF for b in range(401)] for a in range(401)] for i in range(N+1)]

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


for i in range(1,N+1):
    ai,bi,ci = map(int,input().split())
    for a in range(401):
        for b in range(401):
            if a-ai >= 0 and b-bi >= 0:
                dp[i][a][b] = min(dp[i-1][a][b],dp[i-1][a-ai][b-bi]+ci)
            else:
                dp[i][a][b] = dp[i-1][a][b]

ans = INF
for j in range(1,401):
    if Ma*j >= 400 or Mb*j >= 400:
        break
    ans = min(ans,dp[N][Ma*j][Mb*j])
print(ans if ans != INF else -1)


Measured memory_bytes: 98908
#include<iostream>
#include<string>
using namespace std;
int main (void)
{
	string S;
	cin >> S;
	int i;
	char coffee [7];
	for (i = 0; i < 6; i++)
		coffee [i] = S [i];
	if (coffee [2] == coffee [3] && coffee [4] == coffee [5])
	{
		cout << "Yes" << endl;
		return 0;
	}
	cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
double a[100005];
int main(){
    set<pair<pair<int,int>,int>> s;
    int n,m,p,x;
    while(scanf("%d%d",&n,&m)!=EOF){
        double dat;
        memset(a,0,sizeof(a));
        for(int i=1;i<=m;i++){
            scanf("%d%d",&p,&x);
            s.insert(make_pair(make_pair(p,x),i));
        }
        int flag=0,num=0;
        for(int i=1;i<=m;i++){
            if(flag!=s.begin()->first.first){
                flag=s.begin()->first.first;
                num=1;
            }
            else  num++;
            a[s.begin()->second]=1e6*s.begin()->first.first+num;
            s.erase(s.begin());
        }
        for(int i=1;i<=m;i++){
            printf("%012.0lf\n",round(a[i]));
        }
    }

}

Measured memory_bytes: 8576
// /usr/local/bin/g++ Main.cpp -std=c++14
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1000000007;

int N, K;
ll p[101], l[256][101];

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

	cin >> N >> K;
	p[0] = 1;
	for (int i = 1; i < 101; i++) {
		p[i] = p[i-1]*i%INF;
	}

	int a;
	for (int i = 0; i < N; i++) {
		cin >> a;
		ll ll[256][101];
		for (int j = 0; j < 256; j++) {
			for (int k = 0; k < 101; k++) {
				ll[j][k] = 0;
			}
		}
		for (int j = 0; j < 256; j++) {
			for (int k = 0; k < 101; k++) {
				if (l[j][k] > 0) {
					ll[j][k] = (ll[j][k]+l[j][k])%INF;
					ll[j^a][k+1] = (ll[j^a][k+1]+l[j][k])%INF;
				}
			}
		}
		ll[a][1]++;
		for (int j = 0; j < 256; j++) {
			for (int k = 0; k < 101; k++) {
				l[j][k] = ll[j][k];
			}
		}
	}
	ll res = 0;
	for (int i = 1; i < 101; i++) {
		if (l[K][i] > 0) {
			res = (res+p[i]*l[K][i])%INF;
		}
	}
	cout << res << endl;
}

Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
signed main(){
  string s;
  cin>>s;
  Int n=s.size();

  vector<Int> ls(n,-1);
  for(Int i=0;i<n;i++){
    if(s[i]=='L'){
      if(s[i-1]=='R') ls[i]=0;
      else ls[i]=ls[i-1]+1;
    }
  }

  vector<Int> rs(n,n);
  for(Int i=n-1;i>=0;i--){
    if(s[i]=='R'){
      if(s[i+1]=='L') rs[i]=0;
      else rs[i]=rs[i+1]+1;
    }
  }

  vector<Int> ans(n,0);
  for(Int i=0;i<n;i++){
    if(s[i]=='L'){
      ans[i-ls[i]-(ls[i]&1)]++;
    }
    if(s[i]=='R'){
      ans[i+rs[i]+(rs[i]&1)]++;
    }
  }

  for(Int i=0;i<n;i++){
    if(i) cout<<" ";
    cout<<ans[i];
  }
  cout<<endl;
  return 0;
}


Measured memory_bytes: 3072
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        n: usize,
        d1_2_vec: [(i64, i64); n],
    };
    let mut count = 0;
    for d1_2 in d1_2_vec {
        if d1_2.0 == d1_2.1 {
            count += 1;
            if count == 3 {
                println!("Yes");
                return;
            }
        } else {
            count = 0;
        }
    }
    println!("No");
}


Measured memory_bytes: 2148
#include<iostream>
#include<vector>
#include<functional>
#include<algorithm>
#include<string>
#include<map>
#include<queue>

using namespace std;

int main(void){

    int h, n;
    cin >> h >> n;
    vector<int> a(n);

    int total = 0;

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

    cout << (total >= h ? "Yes" : "No") << endl;



    return 0;
}

Measured memory_bytes: 640
#include <stdio.h>
int main(void){
    int a, b, c;
    scanf("%d%d%d", &a, &b, &c);
    if(a%2 == 0){
        printf("%d", a / 2);
    }else{
        printf("%d", a / 2 + 1);
    }     
    
    return 0;
}


Measured memory_bytes: 128