akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define ArraySizeOf(array)     (sizeof(array) / sizeof(array[0]))
#define res(i,n) for(int i=n;;i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define REV(i,n) for(int i=n-1;i>0;i--)
#define req(i,n,m) for(int i=n;i<m;i++)
#define REQ(i,n,m,l) for(int i=n;i<m;i+=l) 
#define _GLIBCXX_DEBUG
int INF = 1e9 + 7;
unsigned NthDayOfWeekToDay(unsigned n, unsigned dow, unsigned dow1)
{
    unsigned day;
    if (dow < dow1) dow += 7;
    day = dow - dow1;
    day += 7 * n - 6;
    return day;
}
signed gcd(long long x, long long y) {
    if (y == 0)return x;
    return gcd(y, x % y);
}
signed lcm(long long x, long long y) {
    return x / gcd(x, y) * y;
}
unsigned DayToWeekNumber(unsigned day)
{
    return (day - 1) / 7 + 1;
}
unsigned AnotherDayOfWeek(unsigned day, unsigned day0, unsigned dow0)
{
    return (dow0 + 35 + day - day0) % 7;
}
using namespace std;
signed main() {
    int N; cin >> N;
    string s, t; cin >> s >> t;
    rev(i, N+1) {
        rep(j, i) {
            if (s.at(N - i + j) != t.at(j))break;
            if (j == i-1) {
                cout << N *2-i << endl;
                return 0;
            }
        }
    }
    cout << N * 2 << endl;
}

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

int main() {
	int n;
	cin >> n;
	int a[n];
	for(int i=0; i<n; i++) cin >> a[i];
	int pm = 0;
	int nm = 0;
	int t;

	for (int i=0; i<n; i++) {
		if (i == 0) continue;
		t = a[i] - a[0];
		if (t > 0 && pm < t) {
			pm = t;
		} else if (t < 0 && nm > t) {
			nm = t;
		}
	}

	cout << pm - nm << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner scan = new Scanner(System.in);
        int explosion = scan.nextInt();
        System.out.print("Christmas");
        while(explosion<25){
            System.out.print(" Eve");
            explosion++;
        }
        System.out.println("");
    }
}


Measured memory_bytes: 22612
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        
        long a = sc.nextLong();
        long b = sc.nextLong();
        long x = sc.nextLong();
        
        long count = 0;
        count += b / x + 1;
        if (a != 0) {
            count -= (a - 1) / x + 1;
//        } else {
  //          count--;
        }
        
        
        System.out.println(count);
    }
}


Measured memory_bytes: 22612
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    S = SS()

    ans = 'Good'
    for i in range(len(S) - 1):
        if S[i] == S[i+1]:
            ans = 'Bad'
            break

    print(ans)

if __name__ == '__main__':
    resolve()


Measured memory_bytes: 10000
import java.util.Scanner;

class Main {
    static final long mod = 1000000007;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String s = sc.next();
        sc.close();
        int array[] = new int[n * 2]; // 0は左1は右
        char tmp = s.charAt(0);
        if (s.charAt(0) == 'W') {
            System.out.println(0);
            return;
        }
        for (int i = 1; i < 2 * n; i++) {
            char c = s.charAt(i);
            if (tmp == c) {
                array[i] = 1 - array[i - 1];
            } else {
                array[i] = array[i - 1];
            }
            tmp = c;
        }
        long ans = 1;
        long left = 0;
        for (int i = 0; i < 2 * n; i++) {
            if (array[i] == 0) {
                left++;
            } else {
                ans *= left;
                ans %= mod;
                left--;
                if (left < 0) {
                    System.out.println(0);
                    return;
                }
            }
        }
        long fact[] = new long[n + 100];
        fact[0] = 1;
        fact[1] = 1;
        fact[2] = 2;
        for (int i = 3; i < n + 3; i++) {
            fact[i] = i * fact[i - 1];
            fact[i] %= mod;
        }
        ans *= fact[n];
        ans %= mod;
        if (left == 0) {
            System.out.println(ans);
        } else {
            System.out.println(0);
        }

    }
}


Measured memory_bytes: 30404
n, k = map(int, input().split())
r, s, p = map(int, input().split())
t = str(input())

ans = 0
temp = [0]*n
for i in range(n):
    if i <= k-1:
        if t[i] == 'r':
            ans += p
        elif t[i] == 's':
            ans += r
        else:
            ans += s
    else:
        if t[i-k] == t[i]:
            if temp[i-k] == 0:
                temp[i] = -1
            else:
                if t[i] == 'r':
                    ans += p
                elif t[i] == 's':
                    ans += r
                else:
                    ans += s
                temp[i] = 0
        else:
            if t[i] == 'r':
                ans += p
            elif t[i] == 's':
                ans += r
            else:
                ans += s
            temp[i] = 0

    #print(i, ans)
print(ans)


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

using usize = ::std::size_t;
using u64 = ::std::int_least64_t;
//using u64 = int;
static constexpr u64 Inf = ::std::numeric_limits<u64>::max() / 2;


int main(int argc, char *argv[])
{
    
 
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N;
    cin >> N;
    vector<u64> L(N);
    for (int i = 0; i < N; i++) {
        cin >> L[i];
    }
    int cnt = 0;
    for (int i = 0; i < N; i++) {
        for (int j = i + 1; j < N; j++) {
            for (int k = j + 1; k < N; k++) {
                if (L[i] != L[j] && L[i] != L[k] && L[j] != L[k]) {
                    if (L[i] + L[j] > L[k] && L[i] + L[k] > L[j] && L[j] + L[k] > L[i]) {
                        cnt++;
                        //cout << (i + 1) << " " << (j + 1) << " " << (k + 1) << endl;
                        //cout << L[i] << " " << L[j] << " " << L[k] << endl;
                    }
                }
            }
        }
    }
    
    cout << cnt << endl;
    
    return 0;
}


Measured memory_bytes: 3660
# Problem https://atcoder.jp/contests/abc088/tasks/abc088_a
# Python 1st Try
if __name__ == "__main__":
    yes = "Yes"
    no = "No"
    answer = ""
    N = int(input().strip())
    A = int(input().strip())
    chargeCoin = N % 500
    if chargeCoin <= A:
        answer = yes
    else:
        answer = no
    print(answer)
exit


Measured memory_bytes: 2940
#include <bits/stdc++.h>
// #include "atcoder/all"
// #define popcount __builtin_popcount
using namespace std;
// using namespace atcoder;
#define FOR(i,o,n) for(long long i = o;i<n;i++)
#define oneforall ios::sync_with_stdio(false);cin.tie(0);
#define all(v) (v).begin(),(v).end()
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) long long __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
#define int long long 
const long long inf=1e18;
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
typedef vector<int> vi;
typedef vector<long long> vl;
typedef long long ll;
typedef vector<pair<long, long > > vpll;
typedef vector<pair<int, int > > vpii;
#define FORR(x,arr) for(auto& x:arr)
#define ZERO(a) memset(a,0,sizeof(a))




//3111111111111111111111111111111

	void solve(){
		

		ini(x);
		if(x==0){
			out(1);
		}
		else{
			out(0);
		}
		
		
			
			
			


				
		


		
		
		
		

		


		
		
	}



	



















int32_t main() {
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall 
	oneforall

	solve();
	


	return 0;
}


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

#define int long long
#define pb push_back
#define mp make_pair
#define f(i,a,n) for(int i=a ; i<n ; i++)
#define all(c) (c).begin(),(c).end()
#define F first
#define S second
#define fast ios:: sync_with_stdio(false),cin.tie(nullptr);
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef vector<pii> vpi;

const int inf = 1e9;
const int inf64 = 1e18;
const int MOD = inf + 7;
const ld PI = acos(-1.0);

int32_t main(){
	fast;
	string s1,s2;
	cin >> s1 >> s2;
	
	map<string , int> m;
	
	int n,n1;
	cin >> n >> n1;
	
	m[s1] += n;
	m[s2] += n1;
	
	string s3;
	cin >> s3;
	m[s3] -- ;
	
	cout << m[s1] << " " << m[s2];
}



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

#define sai(j,n) for(sei j=0;j<sei(n);++j)
#define hsai(j,n) for(sei j=sei(n)-1;j>=0;--j)
#define kan(j,m,n) for(sei j=m;j<sei(n);++j)
#define hkan(j,m,n) for(sei j=sei(n)-1;j>=sei(m);--j)
#define zen(v) (v).begin(),(v).end()
#define yu(v) v.erase(unique(zen(v)), v.end());
#define syutu(v) si(a, (v).size()) {cout << v[a];if(a != v.size()-1)cout << " ";else cout << endl;}
#define mug 10000000111;
#define yo 10000000711;
#define kyo 1e-9;

const int dx[8] = {1,1,0,-1,-1,-1,0,1};
const int dy[8] = {0,1,1,1,0,-1,-1,-1};

using namespace std;
typedef long long sei;
typedef long double syo;
typedef vector<sei> vs;
typedef vector<syo> vy;
typedef vector<vs> vvs;
typedef vector<vy> vvy;
typedef pair<sei, sei> ks;
sei max(sei a, int b) {return max(a, sei(b));}
sei max(int a, sei b) {return max(sei(a), b);}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    sei su=mug;
    sei iti;
    sei sa=0;
    sei yu=0;
    sei N,K;
    cin >> N >> K;
    vs A(N);
    sai(j,N){
        cin >> A[j];
        if(A[j]==1){
            iti = j;
        }
    }
    sai(k,K){
        sei gen = 1;
        sa = iti-k;
        yu = N-1-iti-(K-1-k);
//        cout << su << endl;
//        cout << k << ' ' << K << endl;
//        cout << k << ' ' << sa << ' ' << yu << ' ' << gen << endl;
        while(sa > 0 || yu > 0){
            if(sa < K-1&&sa > 0){
                sa = 0;
                gen++;
            }
            else if(sa > 0){
                sa -= K-1;
                gen++;
            }

            if(yu < K-1&&yu > 0){
                yu = 0;
                gen++;
            }
            else if(yu > 0){
                yu -= K-1;
                gen++;
            }
//            cout << k << ' ' << sa << ' ' << yu << ' ' << gen << endl;
        }
        su = min(su,gen);
    }

    cout << su << endl;
    return 0;
}


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

int main(){
    string S;
    cin >> S;
    int t = 0;
    if(S[0] == 'o')
        t++;
    if(S[1] == 'o')
        t++;
    if(S[2] == 'o')
        t++;
    cout << 700 + 100*t;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <queue>
#include <cmath>
using namespace std;

int N,M,cnt;
int head[100050];
long long dis[100050];
bool vis[100050],inq[100050];
struct edge{
    int u,v,w,next;
}t[400050];
inline void read(int& x){
    char c=getchar();
    x=0;
    while(c<'0'||c>'9')c=getchar();
    while(c>='0'&&c<='9')
    {
        x=x*10+c-'0';
        c=getchar();
    }
}
inline void add(int u,int v,int w){
    t[++cnt].u=u;
	t[cnt].v=v;
    t[cnt].w=w;
    t[cnt].next=head[u];
    head[u]=cnt;
}

queue<int>q;
inline bool spfa(int start){
    
    q.push(start);
    inq[start]=true;
    dis[start]=0;
    
    while(!q.empty()){
        int u=q.front();
        	q.pop();
        inq[u]=false;
    	
		for(int i=head[u];i;i=t[i].next){
            int v=t[i].v;
            	if(dis[v]==12345678987654321){
                	dis[v]=dis[u]+t[i].w;
                		vis[v]=true;
                	if(!inq[v])
                   		q.push(v);
            	}
            	else 
				if(dis[v]!=dis[u]+t[i].w)
                	return false;
        }
    }
    return true;
}

int main(){
	read(N),read(M);
    for(int i=1;i<=M;i++){
    	int u,v,w;
        read(u),read(v),read(w);
        add(u,v,w),add(v,u,-w);
    }
    for(int i=1;i<=N;i++)
		dis[i]=12345678987654321;
    for(int i=1;i<=N;i++){
        if(!vis[i]){
            vis[i]=true;
            	bool flag=spfa(i);
            	if(!flag){
                	printf("No\n");
                		return 0;
            	}
        }
    }
    printf("Yes\n");
    return 0;
}

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

using ll = long long;
using ull = unsigned long long;

const double PI = acos(-1);
const int inf = 2e9;
const ll INF = 2e18;
const ll MOD = 1e9+7;

#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second
#define REP(i,n) for (int i = 0; i<n; i++)
#define ALL(a) begin(a), end(a)

int main (void) {
    int N,M;
    cin>>N>>M;
    ll bigger = max(N,M);
    ll lower = min(N,M);
    ll ans = 0;
    if (lower == 1) {
        if (bigger == 1) {
            ans = 1;
        }
        else {
            ans = bigger - 2;
        }
    }
    else {
        ans = (lower - 2) * (bigger - 2);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
using namespace std;
int main()
{
    // 整数の入力
    int r, D, x;
    scanf("%d %d %d", &r, &D, &x);
    // 文字列の入力
    // 出力
    for(int i=0; i < 10; i++){
        x = r * x - D;
        cout << x << endl;
    }
    return 0;
}


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

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

  int a;
  cin >> a;
  int answer = a + a * a + a * a * a;
  cout << answer << '\n';
}


Measured memory_bytes: 3616
#include<bits/stdc++.h>
#define fastio ios_base :: sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define endl '\n'
#define all(a) (a).begin() , (a).end()
typedef long long  int ll;
#define rep(i , a , b) for(int i=a;i<b;i++)
using namespace std;




void solve(){
    int n;
    cin >> n;
    int ans = 1000*(n/500);
    n%=500;
    ans += 5*(n/5);
    cout << ans << endl;
}





int  main(){
    fastio
    int test;
    test = 1;
    while(test--){
        solve();
    }
    return 0;
}


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

#define MAX_S_LEN 400000

int main(void) {

    char s[MAX_S_LEN];
    int slen;
    int ans;
    int i, j;

    i = j = 0;

    scanf("%s", s);

    slen = strlen(s);

    while(1) if(s[i++] == 'A') break;
    i--;
    while(1) {
        if(s[slen - 1 - j] == 'Z') break;
        j++;
    }

    printf("%d\n", slen - j - i);

    return 0;

}

Measured memory_bytes: 384
#include<iostream>
using namespace std;
int main(void){
  int N,count=0;
  cin >> N;
  if(N>50){
    N-=100;
    count++;
  }
  if(N>5){
    N-=10;
    count++;
  }
  if(N>0.5){
    count++;
  }
  cout << count << endl;
}

Measured memory_bytes: 256
import sys
K = int(input())
if K < 10:
    print(K)
    sys.exit()
lst = [[str(i)] for i in range(10)]
i = 9
while True:
    new_lst = [[] for j in range(10)]
    for j in range(10):     #0-9までについて
        for k in range(-1, 2):  #-1, 0, +1の3つについて
            if j == 0 and k == -1:
                continue
            if j == 9 and k == 1:
                break
            for l in lst[j+k]:
                tmp = str(j) + str(l)
                new_lst[j].append(tmp)
                # print(i, K , i == K)
                if j != 0:
                    i += 1
                    if i == K:
                        print(int(tmp))
                        sys.exit()
    # print(i, new_lst)
    lst = new_lst.copy()

Measured memory_bytes: 9076
// インクルード
#include <bits/stdc++.h>

// 名前空間省略
using namespace std;

// メイン関数
int main()
{
    // 標準入出力　高速化
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int n,k,x,y;
    cin >> n >> k >> x >> y;

    int ans=0;
    for(int i=1;i<=n;i++){
        if(i<=k) ans+=x;
        else ans+=y;
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
import math
N=int(input())
List=[list(map(int,input().split())) for i in range(N)]

total=0
for i in range(N-1):
    for j in range(i+1,N):
        total+=2*math.factorial(N-1)*math.sqrt((List[j][0]-List[i][0])**2+(List[j][1]-List[i][1])**2)

average=(total/(math.factorial(N)))
print(average)

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

int main(){
	int h,w;
	cin>>h>>w;
	int n;
	cin>>n;
	int a[n];
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	vector<int>vc[h];
	int ans=1;
	int i=0;
	while(i<h){
		if(a[ans-1]==0){
			ans++;
		}
		else{
			vc[i].push_back(ans);
			a[ans-1]--;
		}
		if(vc[i].size()==w){
			i++;
		}
	}
	int jvb=0;
	for(int j=0;j<h;j++){
		if(jvb%2==0){
			for(int k=0;k<vc[j].size();k++){
				cout<<vc[j][k]<<" ";
			}
		}
		else{
			for(int k=vc[j].size()-1;k>=0;k--){
				cout<<vc[j][k]<<" ";
			}
		}
		jvb++;
		cout<<endl;
	}
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <tuple>
#include <sstream>
#include <typeinfo>
#include <fstream>
#include <random>
#include <queue>
#include <deque>
#include <iterator>
#include <map>
#include <functional>
#include <numeric>
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 FORR(i, m, n) for(int i = m;i >= n;i--)
#define pb(a) push_back(a)
#define llong long long
#define INF 1145141919
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
int dy[] = { 1, 0, -1, 0 };
int dx[] = { 0, 1, 0, -1 };
template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }

int n;
int solve() {
	for (int i = 111; i < 1000; i = i + 111) {
		if (n == i) {
			return n;
		} else if (n < i) {
			return i;
		}
	}
}
int main() {
	cin >> n;
	cout << solve() << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MAXN 10000000
int spf[10000009];
void sieve()
{
    spf[1] = 1;
    for (int i=2; i<=MAXN; i++)
        spf[i] = i;
    for (int i=4; i<=MAXN; i+=2)
        spf[i] = 2;
    for (int i=3; i*i<=MAXN; i++)
    {
        if (spf[i] == i)
        {
            for (int j=i*i; j<=MAXN; j+=i)
                if (spf[j]==j)
                    spf[j] = i;
        }
    }
}
int getFactorization(int x)
{
    vector<int> ret;
    int y=1,i;
    while (x != 1)
    {
        i=1;
        ret.push_back(spf[x]);
        while(ret.back()==spf[x])
        {
            x = x / spf[x];
            i++;
        }
        y*=i;

    }
    return y;
}
int main()
{
    long long int i,j,k,z,t,x,y=0,n,m;
    cin>>n;
    x=0;
    sieve();
    for(i=1;i<=n;i++)
    {
        x=x+i*getFactorization(i);
    }
    cout<<x<<endl;

}


Measured memory_bytes: 42664
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())

int main() {
  int T; cin >>T;
  while(T--){
    string N; cin >>N;
    int cnt = 0;
    while(N.length() > 1){
      int m = (N[0] - '0') + (N[1] - '0');
      stringstream ss;
      ss << m;
      N = ss.str() + N.substr(2);
      ++cnt;
    }
    cout <<(cnt % 2 ? "Fabre wins." : "Audrey wins.") <<endl;
  }
  return 0;
}

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

int a, b, c;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	
	cin >> a >> b >> c;
	if(c < a)
		swap(a, c);
	if(c < b)
		swap(b, c);
	if(b < a)
		swap(a, b);
	
	int t = (c - b);
	a += t;
	if((c - a) % 2 == 0)
		cout << t + (c - a) / 2;
	else
		cout << 1 + t + (c + 1 - a) / 2;	
	
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <vector>

using namespace std;

using ll = long long;
using ld = long double;

const ld pi = 3.141592653589793;

#ifdef EBUG
#define debug(x) cout << "\033[31m" << #x << ": " << x << "\033[0m\n";
#else
#define debug(x)
#endif

#define rep(i, n) for (int i = 0; i < (int)(n); i++)

string t;

int main() {
  cin >> t;
  // for (int i = 0; i < t.length() - 1; i++) {
  //   if (t[i] == 'P' && t[i + 1] == '?') {
  //     t[i + 1] = 'D';
  //   }
  // }
  // for (int i = 1; i < t.length(); i++) {
  //   if (t[i - 1] == '?' && t[i] == 'D') {
  //     t[i - 1] = 'P';
  //   }
  // }
  // for (int i = 0; i < t.length() - 1; i++) {
  //   if (t[i] == '?' && t[i + 1] == '?') {
  //     t[i] = 'D';
  //     t[i + 1] = 'D';
  //   }
  // }
  rep(i, t.length()) {
    if (t[i] == '?') {
      t[i] = 'D';
    }
  }
  cout << t << endl;
}

Measured memory_bytes: 3748
#include <iostream>
#include <climits>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#define INF_INT (INT_MAX / 2)
#define INF_LONG (LONG_MAX / 2)
//#define DEBUG true
#define DEBUG false
using namespace std;

typedef long long ll;

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

  int n;
  ll c;
  cin >> n >> c;
  ll x[n], v[n];
  for(int i = 0; i < n; i++) cin >> x[i] >> v[i];

  ll sum0[n + 1], sum1[n + 1];
  sum0[0] = sum1[0] = 0;
  for(int i = 1; i <= n; i++){
    sum0[i] = sum0[i - 1] + v[i - 1];
    sum1[i] = sum1[i - 1] + v[n - i];
  }

  ll ma0[n + 1], ma1[n + 1];
  ma0[0] = ma1[0] = 0;
  for(int i = 1; i <= n; i++){
    ma0[i] = max(ma0[i - 1], sum0[i] - x[i - 1]);
    ma1[i] = max(ma1[i - 1], sum1[i] - (c - x[n - i]));
  }

  ll ans = 0;
  for(int i = 1; i <= n; i++){
    ans = max(ans, sum0[i] - x[i - 1]);
    ans = max(ans, sum1[i] - (c - x[n - i]));
    ans = max(ans, sum0[i] - 2l * x[i - 1] + ma1[n - i]);
    ans = max(ans, sum1[i] - 2l * (c - x[n - i]) + ma0[n - i]);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 4992
using namespace std;
#include<bits/stdc++.h>
#define BEGIN ios_base::sync_with_stdio(0);cin.tie(0)
#define END return EXIT_SUCCESS
#define FOR(I,A,B) for((I)=(A);(I)<(B);(I)++)
#define REP(I,N) FOR(I,0,N)
#define UP(I,A,B) for((I)=(A);(I)<=(B);(I)++)
#define DW(I,A,B) for((I)=(A);(I)>=(B);(I)--)
#define IN(P) cin>>(P)
#define IN2(P1,P2) cin>>(P1)>>(P2)
#define IN3(P1,P2,P3) cin>>(P1)>>(P2)>>(P3)
#define INS(I,N,V) REP(I,N) cin>>V[I]
#define INS2(I,N,V1,V2) REP(I,N) cin>>V1[I]>>V2[I];
#define INS3(I,N,V1,V2,V3) REP(I,N) cin>>V1[I]>>V2[I]>>V3[I];
#define OUT(P) cout<<P<<endl
#define OUT2(P1,P2) cout<<P1<<" "<<P2<<endl
#define OUT3(P1,P2,P3) cout<<P1<<" "<<P2<<" "<<P3<<endl
#define OUTS(I,N,V) REP(I,N) cout<<V[i]<<endl
#define ALL(C) (C).begin(),(C).end()
#define RALL(C) (C).rbegin(),(C).rend()
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; }
typedef unsigned long ul;
ul N,K,A,i,kind,ans;
map<int,int> cnt;
vector<int> cnt2;
inline void solve(){
  IN2(N,K);
  REP(i,N){
    IN(A);
    cnt[A]++;
  }
  kind=cnt.size();
  if(kind<=K){
    OUT(0);
    return;
  }
  for(map<int,int>::iterator it=cnt.begin();it!=cnt.end();it++)cnt2.push_back(it->second);
  sort(ALL(cnt2));
  REP(i,kind-K)ans+=cnt2[i];
  OUT(ans);
}

int main(int argc,char**argv){
  BEGIN;
  solve();
  END;
}


Measured memory_bytes: 10744
#include <iostream>
#include<cmath>
#include <iomanip>
#include<cstdio>
#include <queue>
using namespace std;
int main(){
    int N = 0,i=0;
    long long int o=0;
    cin >> N;
    for(i=1;i<=N;i++){
        if ((i%3)!=0){
            if((i%5)!=0){
                o+=i;
            }
        }
    }
    cout << o;
	return 0;
}


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

int main(){
	int n;
	cin >> n;
	if(n<1200){
		cout << "ABC" << endl;
	}else if(n<2800){
		cout << "ARC" << endl;
	}else{
		cout << "AGC" << endl;
	}
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String... args) {
        Scanner sc = new Scanner(System.in);
        int H = sc.nextInt();
        int W = sc.nextInt();

        char[][] grid = new char[H][W];
        String line = "";
        for (int i = 0; i < H; i++) {
            line = sc.next();
            for (int j = 0; j < W; j++) {
                grid[i][j] = line.charAt(j);
            }
        }
        sc.close();

        int tmp = -1;
        for (int i = 0; i < H; i++) {
            for (int j = 0; j < W; j++) {
                if (grid[i][j] == '.') {
                    grid[i][j] = '0';
                } else if (grid[i][j] == '#') {
                    for (int k = i - 1; k <= i + 1; k++) {
                        for (int l = j - 1; l <= j + 1; l++) {
                            if (k < 0 || k >= H || l < 0 || l >= W) {
                                continue;
                            }

                            switch (grid[k][l]) {
                            case '#':
                                break;
                            case '.':
                                grid[k][l] = '1';
                                break;
                            default:
                                grid[k][l] = (char) (Character.getNumericValue(grid[k][l]) + 1 + '0');
                            }
                        }
                    }
                }
            }
        }

        for (int i = 0; i < H; i++) {
            for (int j = 0; j < W; j++) {
                System.out.print(grid[i][j]);
            }
            System.out.println();
        }

    }
}

Measured memory_bytes: 23252
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-9;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

ll gcd(ll a,ll b){
	if(!b) return a;
	return gcd(b,a%b);
}

ll q,a,b,c,d;

int main(){
	cin>>q;
	for(int i=0;i<q;i++){
		cin>>a>>b>>c>>d;
		if(a<b||d<b) cout<<"No"<<endl;
		else if(b<=c) cout<<"Yes"<<endl;
		else{
			ll g=gcd(b,d);a%=g;
			if(c<a&&a<b||(b-1-a)/g-(c-a)/g>0) cout<<"No"<<endl;
			else cout<<"Yes"<<endl;
		}
	}
}

Measured memory_bytes: 256
//#pragma GCC optimize ("O3")
//#pragma GCC target ("sse4")

#include <bits/stdc++.h>

using namespace std;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n;
    string s;
    cin >> n >> s;
    if(n%2 == 1)
    {
        cout << "No";
    }
    
    else if(s.substr(0,n/2) == s.substr(n/2,n/2))
    {
        cout << "Yes";
    }
    else
    {
        cout << "No";
    }
    


    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <queue>
#include <math.h>
#include <assert.h>
#include <set>
#include <map>
#include <bitset>
#include <ctime>
#include <time.h>
#include <algorithm>
#include <cstdio>
#include <fstream>
#include <stack>
#include <ctype.h>
#include <numeric>
#include <sstream>
#include <unistd.h>
#include <unordered_map>
#include <unordered_set>
#include <limits>
#include <random>
#include <chrono>
#include <iomanip>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
using ll = long long;
#define endl '\n'
#define debug(name) DEBUG(#name, (name))
template<typename T>
void DEBUG(string label, T value) {
    cerr << "[" << label << " = " << value << "]\n";
}

void solve(){
    int n;
    cin >> n;
    cout << (n >= 30 ? "Yes" : "No") << endl;
}
int main(){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    solve();
}


Measured memory_bytes: 3628
N = int(input())
L = list(map(int, input().split()))

MinL = min(L)
MaxL = max(L)

chobani = 10000000
set = 0

for i in range (MinL, MaxL+1):
	set = 0
	for j in range (0, N):
		set+=(L[j]-i)**2
	if set < chobani:
		chobani = set

print(chobani)

Measured memory_bytes: 3064
#include <algorithm>
#include <bitset>
#include <cmath>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;
const int IINF = 1e9;
const ll INF = 1e18;
const int MOD = 1e9 + 7;

#define dump(x) cout << #x << " = " << (x) << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl

void chmin(ll &a, ll b) {
  if (a > b) {
    a = b;
  }
}
void chmax(ll &a, ll b) {
  if (a < b) {
    a = b;
  }
}

int main() {
  string str;
  cin >> str;
  cout << ((str[2] == str[3] && str[4] == str[5]) ? "Yes" : "No") << endl;
}

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

int main() {
  int N, a, b, c, d;
  cin >> N;
  a = N / 1000;
  b = N / 100 - a * 10;
  c = N / 10 - a * 100 - b * 10;
  d = N - a * 1000 - b * 100 - c * 10;
  
  if(b == c){
    if(a == b || d == b){
    cout << "Yes" << endl;
    }else{
    cout << "No" << endl;
    } 
  }
  else{
  cout << "No" << endl;
  } 
}

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

typedef long long ll;
typedef pair<ll, ll> P;

#define pb push_back
#define rep(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, a, n) for(int i = a; i < (n); i++)
#define mod (ll)(1e9+7)
#define int ll
#define INF 100000000

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}
ll h, w, d;
signed main() {
	cin >> h >> w >> d;
  P place[h * w + 1];
  rep(i, h) rep(j, w) {
    ll a;
    cin >> a;
    place[a] = {i, j};
  }
  ll mp[h * w + 1];
  for(int i = 1; i <= h * w; i++) {
    if (i <= d) {
      mp[i] = 0;
    } else {
      ll x1 = place[i - d].first;
      ll y1 = place[i - d].second;
      ll x2 = place[i].first;
      ll y2 = place[i].second;
      mp[i] = mp[i - d] + abs(x1 - x2) + abs(y1 - y2);
    }
  }
  ll q;
  cin >> q;
  rep(i, q) {
    ll l, r;
    cin >> l >> r;
    cout << mp[r] - mp[l] << endl;
  }
	return 0;
}

Measured memory_bytes: 3200
#include <algorithm>
#include <array>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
#define int long long
constexpr int M = 3;
constexpr long long INF = 1000000000000000000LL + 8;

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

    int n;
    cin >> n;
    vector<int> a;
    a.reserve(M * n);
    for (int i = 0; i < M * n; i++) {
        int tmp;
        cin >> tmp;
        a.push_back(tmp);
    }

    // scores[k]: aの前半N+k要素がa'の前半N要素になるときの最大スコア
    vector<int> scores(n + 1);

    // 前半の総和の最大値を求める処理
    int f_sum = 0;
    priority_queue<int, vector<int>, greater<int>> f;
    for (int i = 0; i < n; i++) {
        f.push(a[i]);
        f_sum += a[i];
    }
    scores[0] += f_sum;

    // aの前半N+k-1要素の総和の最大値を知っている
    // 優先度付きキューにaの前半N+k-1要素のうち大きい順にN要素がある
    // 優先度付きキューにaのN+k番目の要素を入れて1個取り出した
    // aの前半N+k-1要素の総和の最大値にaのN+k番目の要素を足して取り出した要素を引いたのがaのN+k番目の要素の総和の最大値
    for (int i = 0; i < n; i++) {
        f.push(a[i + n]);
        f_sum += a[i + n];

        f_sum -= f.top();
        f.pop();
        scores[i + 1] += f_sum;
    }

    // 後半の総和の最大値を求める処理
    int b_sum = 0;
    priority_queue<int> b;
    for (int i = n - 1; i >= 0; i--) {
        b.push(a[2 * n + i]);
        b_sum += a[2 * n + i];
    }
    scores[n] -= b_sum;

    for (int i = n - 1; i >= 0; i--) {
        b.push(a[i + n]);
        b_sum += a[i + n];

        b_sum -= b.top();
        b.pop();
        scores[i] -= b_sum;
    }

    const int ans = *max_element(scores.begin(), scores.end());
    cout << ans << endl;
}


Measured memory_bytes: 5748
import java.util.*;
import java.lang.*;
import java.math.*;

public class Main {
	Scanner sc = new Scanner(System.in);

	void run() {
		int n = sc.nextInt();
		for (;; n--) {
			if (n == 0) {
				break;
			}
			int r = sc.nextInt();
			int a = sc.nextInt();
			int p1 = 0;
			int p2 = 0;
			for (int i = 1; i < r; i++) {
				int b = sc.nextInt();
				p1 = Math.max(p1, a - b);
				p2 = Math.max(p2, b - a);
				a = b;
			}
			System.out.println(p2 + " " + p1);

		}
	}

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

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

int main(){
    string s,t;
    cin >> s >> t;
    int c=0;
    for(int i=0;i<3;i++){
        if(s.at(i)==t.at(i)){
            c++;
        }
    }
    cout << c << endl;
}


Measured memory_bytes: 256
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        int a = Integer.parseInt(sc.next());
		int b = Integer.parseInt(sc.next());
		int k = Integer.parseInt(sc.next());
 
		if(b - a < k*2) {
			for(int i = a; i <= b; i++) {
				System.out.println(i);
			}
		} else {
			for(int i = a; i < a+k; i++) {
				System.out.println(i);
			}
			for(int i = b-k+1; i <= b; i++) {
				System.out.println(i);
			}
		}
    }
}

Measured memory_bytes: 21844
module UF = struct
  type node = {
    mutable par: int;
    mutable rank: int;
  };;


  let make n = Array.init n (fun i -> { par = i; rank = 0 })
  ;;

  (* 根を求める *)
  let rec find uf x =
    if uf.(x).par == x
    then x
    else
      let par = uf.(x).par in
      let v = find uf par in
      uf.(x).par <- v;
      v
  ;;

  (* xとyの集合を併合 *)
  let unite uf x y =
    let x = find uf x in
    let y = find uf y in
    if x != y then
      if uf.(x).rank < uf.(y).rank
      then (
        uf.(x).par <- y;
        ()
      )
      else (
        uf.(y).par <- x;
        if uf.(x).rank == uf.(y).rank then (
          uf.(x).rank <- uf.(x).rank + 1;
          ()
        )
      )
  ;;

  let some uf x y = find uf x == find uf y
  ;;
end

let dec x = x -1
;;

let tuple2map fa fb (a, b) = (fa a, fb b)
;;

let tuple2 a b = (a, b)
;;

let curry2 f a b = f (a, b)
;;

let uncurry2 f (a, b) = f a b
;;

let (>>) f g x = g (f x)
;;

let (>>>) f g x y = g (f x y)
;;

let list_init n f = Array.init n f |> Array.to_list
;;

let () =
  let n, m = Scanf.scanf "%d %d\n" tuple2 in
  let p_list = list_init n (fun _ -> Scanf.scanf "%d " dec) in
  let xy_list = list_init m (fun _ -> Scanf.scanf "%d %d\n" (tuple2 >>> tuple2map dec dec)) in
  let uf = UF.make n in
  List.iter (uncurry2 @@ UF.unite uf) xy_list;
  let res = p_list |> List.mapi tuple2 |> List.filter (uncurry2 @@ UF.some uf) |> List.length in
  Printf.printf "%d\n" res
;;


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

int main(){
  cout << fixed << setprecision(10);
  int N, T, A;
  cin>>N>>T>>A;
  int answer=1;
  double temp=0;
  double diff=abs(A-temp);
  for(int i=1; i<=N; i++){
    if(i==1){
    int H;
    cin>>H;
    temp=T-H*0.006;
    diff=abs(A-temp);
    }
    else{
    int H;
    cin>>H;
    temp=T-H*0.006;
    if(abs(A-temp)<diff){
      answer=i;
      diff=abs(A-temp);
    }
    } //else
  }
  cout<<answer<<endl;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
def main():
    N = int( input())
    S = [input().strip() for _ in range(N)]
    Up = []
    Down = []
    for s in S:
        now = 0
        m = 0
        for t in s:
            if t == "(":
                now += 1
            else:
                now -= 1
            if now < m:
                m = now
            # print(t, now)
        if now >= 0:
            Up.append((m,now))
        else:
            Down.append((m-now,-now))
    up = 0
    Up.sort(reverse=True)
    for m, inc in Up:
        if up+m < 0:
            print("No")
            return
        up += inc
    
    down = 0
    Down.sort(reverse=True)
    # print(Up, Down)
    for m, dec in Down:
        if down+m < 0:
            print("No")
            return
        down += dec
    if up != down:
        print("No")
        return
    print("Yes")
    
if __name__ == '__main__':
    main()


Measured memory_bytes: 88028
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
 

 class Main{
             static int[][] map=new int[12][12];
             static boolean[][] counted=new boolean[12][12];
     public static void main(String args[]){
         BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
         
         try{
             String line;
             while((line=br.readLine())!= null){if(line.isEmpty())continue;
                for(int i=0;i<12;i++)map[0][i]=Integer.parseInt(line.charAt(i)+"");
                for(int i=1;i<=11;i++){
                    line=br.readLine();
                    //System.out.println(line);
                    for(int j=0;j<12;j++)map[i][j]=Integer.parseInt(line.charAt(j)+"");
                }for(int i=0;i<12;i++)for(int j=0;j<12;j++)counted[i][j]=false;
                //for(int[] aa:map){System.out.println(Arrays.toString(aa));}
                int islanC=0;
                for(int i=0;i<12;i++){
                    for(int j=0;j<12;j++){
                        if(map[i][j]!=0&&!counted[i][j]){
                           // System.out.println("deli");
                            islanC++;countIsl(i,j);}
                    }
                }
                 System.out.println(islanC);
                 
                 
             }
             
         }catch(Exception e){}         
     }
     static void countIsl(int y,int x){
         if(counted[y][x])return; 
         else{//System.out.println("MK x-y:"+x+"-"+y);
            counted[y][x]=true;
         }
         if(y!=0)if(map[y-1][x]!=0)countIsl(y-1,x);
         if(y!=11)if(map[y+1][x]!=0)countIsl(y+1,x);
         if(x!=11)if(map[y][x+1]!=0)countIsl(y,x+1);
         if(x!=0)if(map[y][x-1]!=0)countIsl(y,x-1);
     }
     
    
 }

Measured memory_bytes: 16996
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < (int)b; i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 1e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    int x, y, a, b, c;
    cin >> x >> y >> a >> b >> c;
    ll p[a], q[b], r[c];
    rep(i, 0, a) cin >> p[i];
    rep(i, 0, b) cin >> q[i];
    rep(i, 0, c) cin >> r[i];

    sort(p, p + a, greater<ll>());
    sort(q, q + b, greater<ll>());
    sort(r, r + c, greater<ll>());
    priority_queue<ll> pq;
    rep(i, 0, x) pq.push(p[i]);
    rep(i, 0, y) pq.push(q[i]);
    rep(i, 0, c) pq.push(r[i]);

    int cnt = 0;
    ll ans = 0;
    while (cnt < x + y) {
        ans += pq.top();
        pq.pop();
        cnt++;
    }
    cout << ans << endl;
    return 0;
}


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

#define CEIL(a,b) ((a) / (b) + ((a) % (b) == 0 ? 0 : 1))

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

constexpr int MOD = 1'000'000'007;
constexpr int INF = 1'000'000'001;
constexpr ll LLINF = 4'000'000'000'000'000'001;
// constexpr int INF = 2147483647; // 2 * 1e9
// constexpr ll LLINF = 9223372036854775807; // 9 * 1e18

const int dx[] = {1, 0, -1, 0, 1, -1, -1, 1, 0};
const int dy[] = {0, 1, 0, -1, 1, 1, -1, -1, 0};

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; ++i){
        cin >> a[i];
    }
    vector<int> b(n);
    int fugo = 1;
    ll tmp = 0;
    for(int i = n - 1; i >= 0; --i){
        tmp += fugo * a[i];
        fugo *= -1;
    }
    b[0] = tmp;
    for(int i = 1; i < n; ++i){
        b[i] = 2 * a[i-1] - b[i-1];
    }
    cout << b[0];
    for(int i = 1; i < n; ++i){
        cout << " " << b[i];
    }
    cout << "\n";
    return 0;
}

Measured memory_bytes: 2176
#include <iostream>
using namespace std;
int main(){
  string s;
  cin >> s;
  int i;
  for(i=0;i<s.size();i++){
    if((i+1)%2==1&&s[i]!='R'&&s[i]!='U'&&s[i]!='D'){
      cout << "No" << "\n";
      return 0;
    }
  }
  for(i=0;i<s.size();i++){
    if((i+1)%2==0&&s[i]!='L'&&s[i]!='U'&&s[i]!='D'){
      cout << "No" << "\n";
      return 0;
    }
  }
  cout << "Yes" << "\n";
  return 0;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define IFOR(i,a,b) for(int i=(b-1);i>=(a);--i)
#define RPT(i,a,b) for(int i=(a);i<((a)+(b));++i)
#define IRPT(i,a,b) for(int i=((a)+(b)-1);i>=(a);--i)
#define ALL(x) x.begin(),x.end()
#define fs first
#define sd second
#define couts(x) cout << x << " "
#define coutn(x) cout << x << "\n"
#define endl "\n"

template<typename T> std::istream &operator>>(std::istream &is, std::vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T1, typename T2> std::istream &operator>>(std::istream &is, std::pair<T1,T2> &p){is >> p.first >> p.second; return is; }
template<typename T> std::ostream &operator<<(std::ostream &os, const std::vector<T> &vec){ os << "["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> std::ostream &operator<<(std::ostream &os, const std::deque<T> &vec){ os << "deque["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> std::ostream &operator<<(std::ostream &os, const std::set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> std::ostream &operator<<(std::ostream &os, const std::unordered_set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> std::ostream &operator<<(std::ostream &os, const std::multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> std::ostream &operator<<(std::ostream &os, const std::unordered_multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T1, typename T2> std::ostream &operator<<(std::ostream &os, const std::pair<T1, T2> &pa){ os << "(" << pa.first << "," << pa.second << ")"; return os; }
template<typename TK, typename TV> std::ostream &operator<<(std::ostream &os, const std::map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename TK, typename TV> std::ostream &operator<<(std::ostream &os, const std::unordered_map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }

template<class T> using V = vector<T>;
template<class T> using V2 = V<V<T>>;
template<class T> using V3 = V<V2<T>>;

void solve(){
  int n; cin >> n;
  V<int> p(n);
  cin >> p;
  int cnt = 0;
  FOR(i,0,n) if(p[i]!=(i+1) ) cnt++;
  if(cnt<=2) couts("YES");
  else couts("NO");
}


int main(void){
  solve();
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
 public static void main(String[] args) {
  Scanner kbd = new Scanner(System.in);
   long a=kbd.nextLong();
   long b=kbd.nextLong();
   long c=kbd.nextLong();

   if((c-a-b)>0&&4*a*b<(c-a-b)*(c-a-b)){
     System.out.println("Yes");
   }else{
     System.out.println("No");
   }
}
}

Measured memory_bytes: 23252
S = input()
T = input()

lenS = len(S)
lenT = len(T)
chgCnt = 0

for j in range(lenS - lenT + 1):
  sameCnt = 0
  for i in range(lenT):
    if S[j + i] == T[i]:
      sameCnt += 1
  if chgCnt < sameCnt:
    chgCnt = sameCnt
    
print(lenT - chgCnt)

Measured memory_bytes: 9064
//#include "bits/stdc++.h"

#define _USE_MATH_DEFINES

#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <functional>
#include <utility>
#include <tuple>
#include <vector>
#include <string>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <stack>
#include <iterator>
#include <bitset>
#include <complex>
#include <limits>
#include <random>


using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;

const double EPS = 1e-9;

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

	int N;
	cin >> N;
	if (N >= 30)
	{
		cout << "Yes" << endl;

	}
	else
	{
		cout << "No" << endl;
	}
	
	return 0;
}

Measured memory_bytes: 3648
#include <iostream>

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

    bool answer = false;
    if (A == B && B == C && C == A) {answer = true;}
    
    if (answer) {std::cout << "Yes" << std::endl;}
    else {std::cout << "No" << std::endl;}

    return 0;
}

Measured memory_bytes: 256
import sys
from collections import deque
input = sys.stdin.readline

H,W = map(int,input().split())
D = [list(input()) for i in range(H)]
ans = 0
dist = [[-1]*W for i in range(H)]
Q = deque()
dx = [1,0,-1,0]
dy = [0,-1,0,1]

for sy in range(H):
    for sx in range(W):
        if D[sy][sx] == "#":
            Q.append((sx,sy))
            dist[sy][sx] = 0
while Q:
    x,y = Q.popleft()
    for i in range(4):
        nx = x+dx[i]
        ny = y+dy[i]
        if 0<=nx<=W-1 and 0<=ny<=H-1 and dist[ny][nx] == -1 and D[ny][nx] == ".":
            Q.append((nx,ny))
            dist[ny][nx] = dist[y][x]+1

for y in range(H):
    for x in range(W):
        if D[y][x] == ".":
            ans = max(ans,dist[y][x])
print(ans)

Measured memory_bytes: 154196
import math
N, M = map(int, input().split())
from collections import*
c = Counter(map(int, input().split()))
for _ in range(M):
    B, C = map(int, input().split())
    c[C] = c[C] + B if C in c else B
c = sorted(c.items(), reverse=True)
s = 0
for i in c:
    s += i[0] * min(i[1],N)
    N -= min(i[1],N)
print(s)


Measured memory_bytes: 112136