akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define INF (1<<30)
#define MOD 1000000007
#define l_ength size
using ll = long long;
using namespace std;

const int MAX = 101000;
ll fact[MAX], fact_inv[MAX];

ll power(ll a, ll b){
	ll res=1;
	while(b>0){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		b>>=1;
	}
	return res;
}

ll comb(ll n, ll r){
	return (fact[n]*fact_inv[r])%MOD*fact_inv[n-r]%MOD;
}

bool exist[MAX];
	
int main(){
	const int bound = 100500;
	fact[0]=1;
	for( int i = 0; i < bound; ++i ){
		fact[i+1]=fact[i]*(i+1)%MOD;
	}
	fact_inv[bound] = power(fact[bound], MOD-2);
	for( int i = bound-1; i >= 0; --i ){
		fact_inv[i]=fact_inv[i+1]*(i+1)%MOD;
	}
	int n; cin >> n;
	vector<int> a(n+1);
	int dup = 0;
	for( int i = 0; i <= n; ++i ){
		int tmp; cin >> tmp;
		if( exist[tmp] ) dup = tmp;
		exist[tmp] = true;
		a[i] = tmp;
	}
	ll x = -1 , y = -1;
	for( int i = 0; i <= n; ++i ){
		if( a[i] == dup ){
			if( x == -1 ) x = i;
			else y = n-i;
		}
	}
	// cout << x << " " << y << endl;
	for( ll i = 1; i <= n+1; ++i ){
		if( x+y+1 < i ){
			cout << comb(n+1, i) % MOD << endl;
		} else {
			cout << ( comb(n+1, i) + comb( x+y, i ) + MOD - comb( x+y+1, i ) ) % MOD  << endl; 
		}
	}
    return 0;
}

Measured memory_bytes: 3328
h,w=map(int,input().split())
ans=10**11

for i in range(1,h-1):
    nokori=h-i
    two=nokori//2
    three=nokori-two
    if two==0 or three==0:
        continue
    ans=min(ans,max(i*w, two*w, three*w)-min(i*w, two*w, three*w))

for i in range(1,h):
    nokori=h-i
    two=w//2
    three=w-two
    if two==0 or three==0:
        continue
    ans=min(ans,max(i*w, nokori*two, nokori*three)-min(i*w, nokori*two, nokori*three))

tmp=w
w=h
h=tmp
# print(w)
# print(h)

for i in range(1,h-1):
    nokori=h-i
    two=nokori//2
    three=nokori-two
    if two==0 or three==0:
        continue
    ans=min(ans,max(i*w, two*w, three*w)-min(i*w, two*w, three*w))

for i in range(1,h):
    nokori=h-i
    two=w//2
    three=w-two
    if two==0 or three==0:
        continue
    # print(i*w)
    # print(nokori*two)
    # print(nokori*three)
    # print()
    ans=min(ans,max(i*w, nokori*two, nokori*three)-min(i*w, nokori*two, nokori*three))

print(ans)

Measured memory_bytes: 43248
N,K=map(int,input().split())
S=[0 if c=='L' else 1 for c in input()]
x=S[0]
f=0
r=0
p=-1
for i in range(N):
    if f==0 and S[i]!=x:
        f=1
    if S[i]!=x:
        if K>0:
            S[i]=x
    elif f==1:
        K-=1
        f=0
    if S[i]==p:
        r+=1
    p=S[i]
print(r)

Measured memory_bytes: 4084
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
using namespace std;

int main(){
	long M,D,i,j,k,ans=0;
	cin>>M>>D;
	if(M<=3){
		cout<<0;
	}else{
		for(i=2;i<=M;i++){
			for(j=2;j<=9;j++){
				if(i%j==0){
					k=i/j;
					if(k>=2){
						if(10*k+j<=D){
							ans++;
							//cout<<i<<10*k+j<<endl;
						}
					}
				}
			}
		}
		cout<<ans;
	}
	return 0;
}



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


#define  SZ(items) (int)items.size()
#define  CLR(a)  memset(a,0,sizeof(a))
#define  SET(a)  memset(a,-1,sizeof(a))
#define  nl "\n";

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



template <class T> inline T biton(T n, T pos)
{
    return n | ((T)1 << pos);
}
template <class T> inline T bitoff(T n, T pos)
{
    return n & ~((T)1 << pos);
}
template <class T> inline T ison(T n, T pos)
{
    return (bool)(n & ((T)1 << pos));
}
template <class T> inline T gcd(T a, T b)
{
    while (b)
    {
        a = a % b;
        swap(a, b);
    }
    return a;
}
template <class T> inline T bigmod(T p, T e, T m)
{
    T ret = 1;
    for (; e > 0; e >>= 1)
    {
        if (e & 1)
            ret = (ret * p) % m;
        p = (p * p) % m;
    }
    return (T)ret;
};

#ifdef DEBUG
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
template < typename Arg1 >
void __f(const char* name, Arg1&& arg1)
{
    cerr << name << " is " << arg1 << std::endl;
}
template < typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args)
{
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " is " << arg1 << " | ";
    __f(comma + 1, args...);
}
#else
#define debug(...)
#endif



void solve()
{
  string s,t;
  cin>>s>>t;
  cout<<t<<s<<endl;

}

int main()
{
    ios_base::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(10);
    cout.tie(nullptr);
    cin.tie(nullptr);


    int t = 1;

    while (t--)
    {
        solve();
    }

    return 0;
}


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

using namespace std;

int main() {
    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;

    vector<int> v;
    int count = 1;
    for (int i = 1; i < n; i++) {
        if (s[i] != s[i - 1]) {
            v.push_back(count);
            count = 0;
        }
        count++;
    }
    v.push_back(count);

    int ret = 0;
    int now = 0;
    bool first = s[0] == '1';
    int right = 0;
    for (int left = 0; left < v.size(); left++) {
        for (; right < v.size() && k >= 0; right++) {
            if (first != (right % 2 == 0))k--;
            now += v[right];
        }

        if (k < 0) {
            right--;
            now -= v[right];
            k++;
        }
        ret = max(ret, now);

        if (first != (left % 2 == 0))k++;
        now -= v[left];
    }
    cout << ret << endl;
    return 0;
}

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

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

const int INF=1e9;
const int MOD=1e9+7;

int main(){
    int N,P; cin >> N >> P;
    ll a[N];
    for(int i=0;i<N;i++){
        cin >> a[i];
    }
    ll dp[N+1][N*100+1]={};
    dp[0][0]=1;
    for(int i=0;i<N;i++){
        for(int j=0;j<=N*100;j++){
            dp[i+1][j]+=dp[i][j];
            if(j+a[i]<=100*N){
                dp[i+1][j+a[i]]+=dp[i][j];
            }
        }
    }
    ll ans=0;
    for(int i=0;i<=N*100;i++){
        if(dp[N][i]>0&&i%2==P) ans+=dp[N][i];
    }
    cout << ans << endl;
}


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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define POSSIBLE cout << ((n) ? "POSSIBLE\n" : "IMPOSSIBLE\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int32 n;
  cin >> n;
  int32 k;
  cin >> k;
  vector<int32> x(n);
  REP(i,n)cin >> x[i];
  int32 ans = 0;
  REP(i,n){
    ans += min(x[i],abs(k-x[i])) * 2;
  }
  ANS(ans);
  return 0;
}

Measured memory_bytes: 256
#include <assert.h>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <algorithm>
#include <numeric>
#include <functional>
#include <iostream>
#include <string>
#include <array>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <complex>
#include <bitset>
typedef long long ll;
typedef unsigned long long ull;

# define INF 0x3f3f3f3f

#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define DEBUG(vec) for (auto v : vec) { cout << v << " "; } cout << endl;

using namespace std;

int T[30][200010] = {};

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

  int N, C;
  cin >> N >> C;
  REP(i, N) {
    int s, t, c;
    cin >> s >> t >> c;
    c--;
    for (int j = s * 2 - 1; j <= t * 2; j++) {
      T[c][j] = 1;
    }
  }
  int ma = 0;
  REP(i, 200010) {
    int c = 0;
    REP(j, C) {
      c += T[j][i];
    }
    ma = max(ma, c);
  }

  cout << ma << endl;
  return 0;
}


Measured memory_bytes: 23680
#include <bits/stdc++.h>
using namespace std;
 
int rr[8], cc[8];
int r[8], c[8];


int main(){
  int k;
  cin >> k;
  int count=0;
  for(int i=0;i<k;i++) cin >> r[i] >> c[i];

  
  
  for(int co=0;co<pow(8,8-k);co++)
  {
    for(int i=0;i<8;i++)
    {
      rr[i]=-1;
      cc[i]=-1;
    }
    //無理やり配置を用意して
   
    for(int i=0;i<8;i++)
    {
      rr[i]=i;
      if(i<k) cc[r[i]]=c[i];
    }
    int hoge=0;
    for(int i=0;i<8;i++)
    {
      int a=pow(8,hoge);
      if(cc[i]==-1)
      {
        cc[i]=co%(a*8)/a;
        hoge++;
      }
    }
    //襲撃をtrueで埋めて
    bool masu[8][8]{false};
    for(int i=0;i<8;i++)
    {
      for(int j=1;j<8;j++)
      {
        if(cc[i]-j>=0) masu[rr[i]][cc[i]-j]=true;
        if(cc[i]+j<=7) masu[rr[i]][cc[i]+j]=true;
        if(rr[i]-j>=0) masu[rr[i]-j][cc[i]]=true;
        if(rr[i]+j<=7) masu[rr[i]+j][cc[i]]=true;
        
        if(rr[i]-j>=0&&cc[i]-j>=0) masu[rr[i]-j][cc[i]-j]=true;
        if(rr[i]+j<=7&&cc[i]-j>=0) masu[rr[i]+j][cc[i]-j]=true;
        if(rr[i]-j>=0&&cc[i]+j<=7) masu[rr[i]-j][cc[i]+j]=true;
        if(rr[i]+j<=7&&cc[i]+j<=7) masu[rr[i]+j][cc[i]+j]=true;
      }
    }
    
    count=0;
    for(int j=0;j<8;j++)
    {
      if(masu[rr[j]][cc[j]]==false) count++;
    }
    //cout << count << endl; 
    if(count==8)
    {
      count=0;
      
      for(int j=0;j<k;j++)
      {
        if(c[j]==cc[r[j]]) count++;
      }
      
      if(count==k)
      {
        break;
        //return 0;
      }
    }
  }
  for(int i=0;i<8;i++)
        {
          for(int j=0;j<8;j++)
          {
            if(cc[i]==j) cout << 'Q';
            else cout <<'.';
          }
          cout << endl; 
        }
  //cout << "hoge"<< endl; 
  return 0;
}


Measured memory_bytes: 3284
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Text.RegularExpressions;

namespace AtCoder_1
{
    class Program
    {
        static void Main(string[] args)
        {
            var a = CinTAr();
            List<int[]> lists = new List<int[]>();
            for(int i = 0;i < a[0]; i++)
            {
                lists.Add(CinTAr());
            }
            int res = 0;
            for(int i = 0;i < lists.Count; i++)
            {
                for(int g = i + 1; g < lists.Count; g++)
                {
                    double ha = 0;
                    for(int h = 0;h < a[1]; h++)
                    {
                        ha += Math.Pow(lists[i][h] - lists[g][h], 2);
                    }
                    double df = Math.Sqrt(Math.Abs(ha));
                    if ( Math.Ceiling(df) == df)
                    {
                        res++;
                    }
                }
            }
            Cout(res);
            Cin();
 
        }


        static string Cin() { return Console.ReadLine(); }
        static string[] CinAr() { return Console.ReadLine().Split(' '); }
        static int CinT() { return S2i(Cin()); }
        static int[] CinTAr() { return CinAr().Select((x, i) => { return S2i(x); }).ToArray(); }
        static long CinL() { return S2L(Cin()); }
        static long[] CinLAr() { return CinAr().Select((x, i) => { return S2L(x); }).ToArray(); }
        static double CinD() { return S2D(Cin()); }
        static double[] CinDAr() { return CinAr().Select((x, i) => { return S2D(x); }).ToArray(); }
        static int S2i(string s) { return int.Parse(s); }
        static long S2L(string s) { return long.Parse(s); }
        static double S2D(string s) { return double.Parse(s); }
        static void Cout(object s) { Console.WriteLine(s); }
        static void DbShowE<Type>(IEnumerable<Type> types)
        {
            foreach(var i in types)
            {
                Console.Write(i + " ");
            }
            Console.WriteLine();
        }
    }
}


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

using namespace std;

int64_t convert_base4_to_int64(vector<int64_t> const& a) {
	int64_t i, k, sum = 0;
	for (i = a.size() - 1; i >= 0; i--) {
		sum *= 10;

		switch (a[i]) {
		case 0:
			k = 0;
			break;
		case 1:
			k = 3;
			break;
		case 2:
			k = 5;
			break;
		case 3:
			k = 7;
			break;
		}
		sum += k;
	}

	return sum;
}

int main(int argc, char *argv[]) {

	int64_t i, target, value, count = 0;
	cin >> target;

	//
	//  a は 4進数の bit を格納するvector(15桁)
	//  x は 4進数の bit の数を数えるためのvector 
	//  reset は純粋に x を reset するための 0埋め済み vector
	//
	const int size = 15;
	vector<int64_t> a(size, 0), x(4, 0), reset(4, 0);
	a[0] = 1;   //  まずは4進数の1から始める 

	while (true) {
		value = convert_base4_to_int64(a);  // 4進数 を10進数に変換

		if (value <= target) {
			//  4進数のbit(= 3, 5, 7)の数を数える
			x = reset;
			for (i = 0; i < size; i++) {
				x[a[i]]++;
			}

			//  3, 5, 7 がひとつ以上存在した場合
			if (x[1] > 0 && x[2] > 0 && x[3] > 0) {

				//  bit が0でなくなる箇所を調べる
				for (i = size - 1; i >= 0; i--) {
					if (a[i] != 0) {
						break;
					}
				}
				//  0 の bit が存在していてはいけない
				for (; i >= 0; i--) {
					if (a[i] == 0) {
						goto NEXT;   // ハズレ
					}
				}

				count++;
			}

		} else {
			break;  // おしまい
		}

	NEXT:
		// 4進数のvectorをインクリメントし、
		// 必要に応じて桁上げ
		a[0]++;
		for (i = 0; i < size; i++) {
			if (a[i] == 4) {
				a[i] = 0;
				a[i + 1]++;
			}
		}
	}
	
	cout << count << endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define all(a) (a).begin(),(a).end()
#define INIT(a) memset((a),0,sizeof(a))
#define fs first
#define sc second
#define pb push_back
#define sz size() 
using namespace std;
typedef long long ll;
typedef double D;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<string> vs;

const static int INF = 1e8;
const static D EPS = 1e-8;

const ll mod = 1e9+7;

ll extgcd(ll a, ll b, ll& x, ll& y){
  ll d = a;
  if(b != 0){
    d = extgcd(b,a%b,y,x);
    y -= (a/b) * x;
  }else{
    x = 1; y = 0;
  }
  return d;
}

ll inv[10100];

inline ll mod_inverse(ll a, ll m){
  ll x,y;
  extgcd(a,m,x,y);
  return (m+x%m) % m;
}

inline ll cataran(ll n, ll k){
  if(k==0)return 1;
  ll res = n+1-k;
  rep(i,k-1){
    (res *= n+i+2) %= mod;
    (res *= inv[i+2]) %= mod;
  }
  return res;
}

int main(){
  ll n,m,k;
  cin >> n >> m >> k;
  rep(i,k){
    inv[i+1] = mod_inverse(i+1,mod);
  }

  ll res = 0, comb = 1;
  rep(i,n){
    (comb *= n+m+2*k - i) %= mod;
    (comb *= mod_inverse(i+1,mod)) %= mod;
  }

  rep(x,k+1){
    ll y = k-x;
    ll tmp = ( cataran(n+x,x) * cataran(m+y,y) ) % mod;
    (tmp *= comb) %= mod;

    (res += tmp) %= mod;

    (comb *= m+2*k - 2*x) %= mod;
    (comb *= m+2*k - 2*x-1) %= mod;
    (comb *= mod_inverse(n+1+2*x,mod)) %= mod;
    (comb *= mod_inverse(n+2+2*x,mod)) %= mod;
  }
  cout << res << endl;
}

Measured memory_bytes: 1236
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<climits>
#include<iostream>
#include<sstream>
#include<utility>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<stack>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

string S;

int main()
{
	cin>>S;
	bool a=S.length()%2==0;
	bool b=S[0]==S[S.length()-1];
	cout<<(a^b?"Second":"First")<<endl;
}


Measured memory_bytes: 512
import math as m
import itertools as it

N = int(input())
xy = [[int(i) for i in input().split()] for j in range(N)]
sum_dis = 0
num = 0
for i in it.permutations(xy):
    for jth in range(len(i) - 1):
        sum_dis += m.sqrt(
            (i[jth][0] - i[jth + 1][0]) ** 2 + (i[jth][1] - i[jth + 1][1]) ** 2
        )
    num += 1
print(sum_dis / num)


Measured memory_bytes: 3064
main::IO()
main = do
    _ <- getLine
    n <- map read . words <$> getLine
    let list = [x | x <- (filter even n), (mod x 3 ==0) || (mod x 5 ==0) ]
    putStrLn $ if (length list)==(length $filter even n) then "APPROVED" else "DENIED"

Measured memory_bytes: 4360
#include<bits/stdc++.h>
using namespace std;
#define fr first
#define sc second
typedef long long ll;
typedef double ld;
typedef pair<int,int> p2;
typedef pair<p2,int> p3;
typedef vector<ll> vi;
const ll Mod = 7 + 1e9;
const ll INF32 = 5 + 2e9;
const ll INF64 = 1 + 1e18;
const ll MAX = 5+ 3e3;

int N,K,a[MAX];
ll dp[MAX][MAX];


int main()
{
    cin >> N ;
    for(int i=1; i<=N; i++)
        cin >> a[i];
    for(int i=N;i>=1;i--)
        for(int j=i;j<=N;j++)
        {
            bool turn = ( N - (j-i+1) )%2;
            dp[i][j] = turn ? min( dp[i+1][j] - a[i] ,dp[i][j-1] - a[j] ) : max( dp[i+1][j] + a[i] ,dp[i][j-1] + a[j] );
        }
    cout << dp[1][N] << endl;
    return 0;
}


Measured memory_bytes: 70016
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

n, k = map(int, read().split())
mod = 10 ** 9 + 7
memo = [0] * (k + 1)
ans = 0
for x in range(k, 0, -1):
    v = k // x
    tmp = pow(v, n, mod)
    for i in range(2, v + 1):
        tmp -= memo[i * x]
        tmp %= mod
    memo[x] = tmp
for i, vv in enumerate(memo):
    ans += i * vv
    ans %= mod
print(ans)


Measured memory_bytes: 11292
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        String S = sc.next();
        String T = sc.next();
        for(int i = 0; i < N; i++){
            System.out.print((char)S.charAt(i) + "" + (char)T.charAt(i));
        }
        System.out.println();
    }
}


Measured memory_bytes: 22356
import java.io.PrintStream;
import java.util.Scanner;

public class Main {
	static final PrintStream out = System.out;
	static final Scanner sc = new Scanner(System.in);
	static final long Mod = 1000_000_007L;
	String S;

	public static void main(String[] args) {
		Main main = new Main();
		main.solve();
		System.exit(0);
	}

	void solve() {
		S = next();

		int n = S.length() / 2;

		int i = 0,j = S.length()-1,cnt = 0;
		while(i < j) {
			if(!S.substring(i,i+1).equals(S.substring(j,j+1))) {
				cnt++;
			}
			i++;j--;
		}

		out.println(cnt);

	}

	public int[] nextIntArray(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)a[i] = nextInt();
		return a;
	}
	public long[] nextLongArray(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)a[i] = nextLong();
		return a;
	}
	public int nextInt() {
		return Integer.parseInt(next());
	}
	public long nextLong() {
		return Long.parseLong(next());
	}
	public String next() {
		return sc.next();
	}

	long gcd(long m,long n) {
		if (m<n) return gcd(n,m);
		if (n==0)return m;
		return gcd(n,m%n);
	}
}

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

int main()
{
	int n;
	cin >> n;
	int* arr = new int[n];
	for (int i = 0; i<n; i++)
	{
		cin >> arr[i];
	}
	for (int i = n - 1; i>0; i--)
	{
		cout << arr[i] << " " <<flush;
	}
	cout << arr[0] << endl;
}

Measured memory_bytes: 3084
/*#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

#include <boost/rational.hpp>
*/
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
using ll = long long;
using ld = long double;
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define rep3(i, n) for (ll i = 1; i < (ll)(n+1); i++)
#define rep4(i, s, n) for (ll i = (s); i < (ll)(n+1); i++)
#define repr(i,n) for (ll i = (n-1); i>=0;i--)
#define repr3(i,n) for(ll i = (n);i>0;i--)
#define repr4(i,s,n) for(ll i = (n);i>=(s);i--)
#define stlen(s) ll s.size()-1
#define all(v) v.begin(), v.end()
#define cout(n) cout<<std::fixed<<std::setprecision(n)
using Graph = vector<vector<int>>;
using Graphw = vector<vector<pair<ll,ll>>>;
#define INF1  INT_MAX;
#define INF2  LLONG_MAX;
#define PI  3.14159265358979323846;
#define MOD 1000000007;
/*
namespace mp = boost::multiprecision;
// 任意長整数型
using Bint = mp::cpp_int;
// 仮数部長が32の浮動小数点数型
using Real32 = mp::number<mp::cpp_dec_float<32>>;
// 仮数部長が1024の浮動小数点数型
using Real1024 = mp::number<mp::cpp_dec_float<1024>>;
// 有理数型
using Rat = boost::rational<Bint>;
*/
const int mod = 1000000007;

int main() {
int x1,y1,x2,y2,x3,y3,x4,y4;
cin>>x1>>y1>>x2>>y2;
x3=x2-(y2-y1);
y3=y2+(x2-x1);
x4=x3-(y3-y2);
y4=y3+(x3-x2);
cout<<x3<<" "<<y3<<" "<<x4<<" "<<y4<<endl;

return 0;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long int
#define rep(i, n) for(int i = 0; i < n; i++)
#define repp(i, n) for(int i = 1; i <= n; i++)
#define sort(v) sort((v).begin(), (v).end())
#define pb push_back
#define mp make_pair
#define riverse(v) reverse((v).begin(), (v).end())
using vi = vector<int>;
using vs = vector<string>;
using vvi = vector<vi>;
using vll = vector<ll>;
const int MOD = 1e9+7;
vi alphabet = {'a','b','c','d','e','f','g','h','i','j','k','l','m',
               'n','o','p','q','r','s','t','u','v','w','x','y','z'};
 
int main() {
	ll N;
  	cin >> N;
  	ll ans = N*(N-1);
  	cout << ans/2 << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){

  int x,y,z;

  scanf("%d",&x);
  scanf("%d",&y);


  while(1){

    z = x % y;

    if(z == 0){

      break;

    }

    else{

      x = y;

      y = z;

    }

  }

  printf("%d\n",y);

  return 0;

}

Measured memory_bytes: 592
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_int.hpp>
//typedef boost::multiprecision::cpp_int ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
////////////////////////////

int main(){
    ll n;cin>>n;
    ll a[n];
    rep(i,0,n-1){
        cin>>a[i];
    }
    ll ans=0;
    rep(i,1,n-1){
        if(a[i]>a[i-1]){
            ans++;
        }
    }
    cout<<ans<<endl;
    
    
    
    return 0;
}



Measured memory_bytes: 3884
#include<bits/stdc++.h>
using namespace std;
#define pb(x) push_back(x)
#include<queue>
int n,m,i,o,p,ans;
vector<int> a[200010],b;
priority_queue<int,vector<int>,greater<int> > q;
int main()
{
	scanf("%d %d",&n,&m);
	for(i=1;i<=n;i++)
		scanf("%d %d",&o,&p),a[o].pb(p);
	int t=0;
	for (i=0;i<=m;i++)
		for (int j=0;j<a[i].size();j++)
			if (t<i) t++,q.push(a[i][j]);else q.push(a[i][j]),b.pb(q.top()),q.pop();
	sort(b.begin(),b.end(),greater<int>());
	int s=m+1;ans=b.size();
	for (i=0;i<b.size();i++)
		if (s==t+1) break;else if (b[i]<s) s--,ans--;
	printf("%d\n",ans);
}

Measured memory_bytes: 9976
#include<stdio.h>
int main(void){
    int ans[30],n,i,w,tmp,a,b;
    scanf("%d",&w);
    scanf("%d",&n);
    for(i=0;i<w;i++){
        ans[i]=i+1;
    }

    for(i=0;i<n;i++){
        scanf("%d,%d",&a,&b);
        tmp=ans[a-1];
        ans[a-1]=ans[b-1];
        ans[b-1]=tmp;
    }

    for(i=0;i<w;i++){
        printf("%d\n",ans[i]);
    }
    return 0;
}

Measured memory_bytes: 596
import sys
import math
a,b,c=map(int,input().split())
h=float(b)*math.sin(float(c)*math.pi/180.0)
S=float(a)*float(h)/2;
L=float(a)+float(b)+math.sqrt((float(a)*float(a))+(float(b)*float(b))-(2*float(a)*float(b)*math.cos(float(c)*math.pi/180)));
print(str('{:.08f}'.format(S)))
print(str('{:.08f}'.format(L)))
print(str('{:.08f}'.format(h)))


Measured memory_bytes: 5716
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
#define int int64_t

signed main()
{
    std::ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int n,i;
    cin>>n;

    cout<<(n ? 0 : 1);

    return 0;
}




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

using namespace std;

#define int long long
const int N = (int) 2e5 + 7;
int n, k, a[N];

bool ok(int len) {
  int cur = 0;
  for (int i = 1; i <= n; i++) {
    if (a[i] >= len + 1) {
      cur += (a[i] - 1) / len;
      if (cur > k) {
        return 0;
      }
    }
  }
  return 1;
}

signed main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> k;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  int l = 1, r = (int) 1e9, sol = 0;
  while (l <= r) {
    int m = (l + r) / 2;
    if (ok(m)) {
      sol = m;
      r = m - 1;
    } else {
      l = m + 1;
    }
  }
  cout << sol << "\n";
  return 0;
}


Measured memory_bytes: 5140
N=int(input())
for h in range(1,3501):
  if 4*h-N!=0:
    n=(N*h)//(4*h-N)+1
    if 4*h*n-N*(h+n)>0 and (N*h*n)%(4*h*n-N*(h+n))==0:
      w=(N*h*n)//(4*h*n-N*(h+n))
      break
print(h,n,w)

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

int main() {
	int N, Q;
	cin >> N >> Q;
	string S;
	cin >> S;
	vector<int> tmp(N);
	for (int i = 1; i < N; ++i) {
		if (S[i - 1] == 'A' && S[i] == 'C') tmp[i] = tmp[i - 1] + 1;
		else tmp[i] = tmp[i - 1];
	}
	for (int i = 0; i < Q; ++i) {
		int l, r;
		cin >> l >> r;
		--l;
		--r;
		cout << tmp[r] - tmp[l] << endl;
	}
}

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

int main(){
  int N, C;
  cin >> N >> C;
  vector<vector<int64_t>> color(C,vector<int64_t>(C));
  for(int i=0; i<C; i++){
    for(int j=0; j<C; j++){
      cin >> color.at(i).at(j);
    }
  }
  vector<vector<int64_t>> num(N,vector<int64_t>(N));
  for(int i=0; i<N; i++){
    for(int j=0; j<N; j++){
      cin >> num.at(i).at(j);
    }
  }

  vector<vector<int64_t>> sum(C,vector<int64_t>(3));
  for(int k=0; k<C; k++){
    int one = 0;
    int two = 0;
    int three = 0;
    for(int i=0; i<N; i++){
      for(int j=0; j<N; j++){
        if((i+j) %3 == 0){
          one += color.at(num.at(i).at(j)-1).at(k);
        }
        if((i+j) %3 == 1){
          two += color.at(num.at(i).at(j)-1).at(k);
        }
        if((i+j) %3 == 2){
          three += color.at(num.at(i).at(j)-1).at(k);
        }
      }
    }
    sum.at(k).at(0) = one;
    sum.at(k).at(1) = two;
    sum.at(k).at(2) = three;
  }
  
  
  int64_t cost = 100000000000;
  for(int i=0; i<C; i++){
    for(int j=0; j<C; j++){
      if(j == i){
        continue;
      }
      for(int k=0; k<C; k++){
        if(k == i || k == j){
          continue;
        }
        int64_t cost_x = sum.at(i).at(0) + sum.at(j).at(1) + sum.at(k).at(2);
        cost = min(cost,cost_x);
      }
    }
  }

  cout << cost << endl;          
}

Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, N) for (int i = 0; i < (int)N; i++)
#define all(a) (a).begin(), (a).end()

int R, G;
int main () {
  cin >> R >> G;
  cout << (2*G - R) << endl;
  return 0;
}


Measured memory_bytes: 256
//Robs Code

/***********HEADER***************/
#include <iostream>
#include <bitset>
#include <deque>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <string>
#include <algorithm>
#include <list>
#include <vector>
#include <unordered_set>
#include <unordered_map>
#include <stack>
#include <set>
#include <queue>
#include <map>
#include <iomanip>

/***********MACROS***************/
#define int long long int
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()
#define endl "\n"
#define pb push_back
#define _1 first
#define _2 second
#define pii pair<int,int>

using namespace std;

const int N = 1e5 + 1;
int n,m,i,j,k,l,x,y,z,cnt[3],sum[3];

/***********MAIN**************/
signed main(){
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	cin>>n;
	vector<int> v(n);
	vector<int> hsh(n+1);
	for(auto &x : v){
		cin>>x;
		hsh[x]++;
	}
	int ans = 0;
	for(int i=1;i<=n;i++){
		ans += ((hsh[i]*(hsh[i]-1))/2);
	}
	for(int i=0;i<n;i++){
		cout<<(ans - (hsh[v[i]]*(hsh[v[i]]-1)/2) + ((hsh[v[i]]-1)*(hsh[v[i]]-2)/2))<<"\n";
	}
}
//.........

Measured memory_bytes: 5760
#define _GLIBCXX_DEBUG    //空コンテナ操作禁止　Clang環境では#define _LIBCPP_DEBUG 0
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
using namespace std;
using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;

int main(){
  int N;
  cin >> N;
  vector<int> H(N);
  for( int i=0; i<N; i++ ) cin >> H.at(i);
  //cout << "N=" << N <<endl;
  
  if( N == 1 ){
    cout << "Yes" << endl;
    return 0;
  }
  
  int mini = H.at(N-1);
  for( int i=N-1; i>0; i-- ){
    //printf( "H.at(%d)=%d, min( H.at(%d)~H.at(%d) )=%d\n", i-1, H.at(i-1), i, N-1, mini );
    if( H.at(i-1) > mini + 1 ){
      cout << "No" << endl;
      return 0;
    }
    mini = min( mini, H.at(i-1) );
  }
  cout << "Yes" << endl;
  return 0;
}


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

#define mod 1000000007

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

using namespace std;
typedef long long ll;
const long long INF = 1LL << 60;
 
int main(void){
	
	int N, T, c[110], t[110], ans = 10000;
	
	cin >> N >> T;
	
	bool tle = false;
	
	rep(i, N){
		cin >> c[i] >> t[i];
		if(t[i] <= T){
			ans = min(ans, c[i]);
			tle = true;
		}
	}	
	if(tle)
		cout << ans;
	else
		cout << "TLE";
	
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

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



Measured memory_bytes: 2100
N, M = map(int, input().split())
route = [[] for _ in range(N)]
sign = [0]*N

#print(route)
for i in range(M):
    a,b = map(int, input().split())
    route[a-1].append(b-1)
    route[b-1].append(a-1)
#print(route)

marked = {0}
q = [0]
for i in q:
    for j in route[i]:
        if j in marked:
            continue
        q.append(j)
        marked.add(j)
        sign[j] = i+1

print('Yes')
[print(i) for i in sign[1:]]

Measured memory_bytes: 42764
#include <iostream>
using namespace std;
int s,x,z,a;
int main(){
    cin>>x>>a>>z;
    s=a+x;
    if((a<=500)&&(a>=1)&&(x>=1)&&(x<=500)){
        if(s>=z){
            cout<<"Yes";
        } else {
            cout << "No";

        }
    }
    else{
        cout<<"you can't buy";
    }

    return 0;
}


Measured memory_bytes: 256
import sys
row = sys.stdin.readline
def read_string(row):
    return row().rstrip()

S = read_string(row)
dic = {"SUN": 7,
       "SAT":1,
       "FRI":2,
       "THU":3,
       "WED":4,
       "TUE":5,
       "MON":6}
print(dic[S])

Measured memory_bytes: 2940
#include<iostream>
using namespace std;
int main()
{
    int a,b,i,sum=0,res;
    cin >>a>>b;
    for(i=1;i<=b;i++)
    {
        int c;
        cin>>c;
        sum+=c;
    }
    res=a-sum;
    if(res<0)
        cout<<"-1\n";
    else
    cout<<res;




    return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define what_is(x) cerr << #x << " is " << x << endl;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define st first
#define nd second
#define endl '\n'

typedef long long ll;
typedef pair<int,int> pii;
const int N = 5e3+5;
const int INF = 1e9;
const int MOD = 1e9+7;

int n;
string s;
int ans = 0;
void Zfunction(string s){
	int n = s.length();
	vector<int> z(n,0);
	int x = 0, y = 0;
	for(int i=1; i<n; i++){
		z[i] = max(0, min(z[i-x], y-i+1));
		// if (i <= y) z[i] = min(z[i-x], y-i+1);

		while(i+z[i] < n && s[i+z[i]] == s[z[i]]){
			z[i]++;
		}
		if (i+z[i]-1 > y) {
			x = i; y = i+z[i]-1;
		}
		ans = max(ans, min(z[i],i));
	}
}
int main()
{
	IOS
	//freopen("input.txt", "r", stdin);
	cin >> n >> s;
	string tmp = "";
	for(int i=n-1; i>=0; i--){
		tmp = s[i] + tmp;
		Zfunction(tmp);
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
//2020-07-31 
#include <bits/stdc++.h>
using namespace std;
#define loop(v, st, en) for (int v = st; v < en; v++)
#define loopdesc(v, st, en) for (int v = st; v >= en; v--)
#define INF 1E9
#define clr(v, d) memset(v, d, sizeof(v))
#define P(x) cout << #x  <<" = { "<< x<<" }\n"
#define PI acos(-1)

typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
const int M=2e5+5;


int main () {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n , k ;cin>>n>>k;ll arr[n];
    loop(i,0,n)cin>>arr[i];
    int tail =0;
    loop(i , k , n){
        if(arr[i]>arr[tail])cout <<"Yes\n";
        else cout<<"No\n";
        tail++;
    }
    return 0;
}

Measured memory_bytes: 5200
#include <cstdio>
#include <cstring>

const int M = 1046527;
const int L = 14;

char H[M][L];
int getChar(char ch);
long long getKey(char str[]);
int h1(int key) { return key % M; }
int h2(int key) { return 1 + (key % (M - 1)); }
int find(char str[]);
void insert(char str[]);

int main()
{
	int i, n, h;
	char str[L], com[9];
	for (i = 0; i < M; i++)
	{
		H[i][0] = '\0';
	}
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
	{
		scanf("%s %s", com, str);
		if (com[0] == 'i')
		{
			insert(str);
		}
		else
		{
			if (find(str))
			{
				printf("yes\n");
			}
			else
			{
				printf("no\n");
			}
		}
	}
	return 0;
}

//turn the characters into numbers
int getChar(char ch)
{
	switch (ch)
	{
	case 'A':
		return 1;
		break;
	case 'C':
		return 2;
		break;
	case 'G':
		return 3;
		break;
	case 'T':
		return 4;
		break;
	default:
		return 0;
	}
}

//turn the string into numbers and calculate key
//formula for calculating key: getchar(str[i])*(5^(i))
long long getKey(char str[])
{
	long long sum = 0, p = 1, i;
	for (i = 0; i < strlen(str); i++)
	{
		sum += p*getChar(str[i]);
		p *= 5;
	}
	return sum;
}

int find(char str[])
{
	long long key, h, i;
	key = getKey(str);
	for (i = 0;; i++)
	{
		h = (h1(key) + i*h2(key)) % M;
		if (strcmp(H[h], str) == 0)
		{
			return 1;
		}
		else if (strlen(H[h]) == 0)
		{
			return 0;
		}
	}
	return 0;
}

void insert(char str[])
{
	long long key, h, i;
	key = getKey(str);
	for (i = 0;; i++)
	{
		h = (h1(key) + i*h2(key)) % M;
		//if the argument is the same as the element as in h(k), return
		if (strcmp(H[h], str) == 0)
		{
			return;
		}
		else if (strlen(H[h]) == 0)
		{
			strcpy(H[h], str);
			return;
		}
	}
	return;
}


Measured memory_bytes: 16976
def kitaichi(x):
    return x * (x+1) / (2 * x)

def main():
    n, k = map(int, input().split())
    inlis = tuple(map(int, input().split()))
    kitalis = list(map(kitaichi, inlis))
    kitadic = {}
    kitadic[0] = kitalis[0] 
    for i in range(1, n):
        kitadic[i] = kitadic[i-1] + kitalis[i]
       
    tmp = 0
    if n == k:
        print(kitadic[n-1])
    else:
        for i in range(n - k):
            atai = kitadic[i+k] - kitadic[i]
            if tmp < atai:
                tmp = atai
        print(tmp)
        exit()



    
if __name__ == "__main__":
    main()


Measured memory_bytes: 137464
s=input()
if s[0]==s[1]==s[2]==s[3]:
    print("No")
elif (s[0]==s[1] and s[2]==s[3]) or (s[0]==s[2] and s[1]==s[3])or (s[0]==s[3] and s[1]==s[2]):
        print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
def judge(h, hands):
  if h == '1':
    if '2' in hands:
      if '3' not in hands:
        return 1
      else:
        return 3
    elif '2' not in hands:
      if '3' not in hands:
        return 3
      else:
        return 2
  elif h == '2':
    if '3' in hands:
      if '1' not in hands:
        return 1
      else:
        return 3
    elif '3' not in hands:
      if '1' not in hands:
        return 3
      else:
        return 2
  else:
    if '1' in hands:
      if '2' not in hands:
        return 1
      else:
        return 3
    elif '1' not in hands:
      if '2' not in hands:
        return 3
      else:
        return 2

while True:
  hands = []
  for _ in range(5):
    h = input()
    if h == '0':
      exit()
    else:
      hands.append(h)
  for h in hands:
    print(judge(h, hands))



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

int main(){
    int n;
    cin>>n;
    int w[n];
    int sum=0;
    for(int i=0;i<n;i++) {
        cin >> w[i];
        sum+=w[i];
    }
    int sumtmp=0;
    int ans=sum;
    for(int i=0;i<n-1;i++){
        sumtmp+=w[i];
        if(ans>abs((sum-sumtmp)-sumtmp)) ans=abs((sum-sumtmp)-sumtmp);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
N = int(input())

y = 0
def X(num):
  x = 0
  for i in range(1,num+1):
    if num%i == 0:
      x += 1
  return x
for j in range(1,N+1):
  if X(j) == 8 and j%2==1:
    y = y+1
print(y)

Measured memory_bytes: 9160
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

//struct edge {int from, to, cost;};

constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;
constexpr int MOD = 1'000'000'007;

template<class T> inline T sqr(T x) {return x*x;}

double dp[301][301][301] = {};

double solve(int c1, int c2, int c3, int n) {
    if (c1 <= 0 || c2 < 0 || c3 < 0) return 0.0;
    if (c1 < c2 || c2 < c3 || c1 < c3) return 0.0;
    if (dp[c1][c2][c3] != 0) return dp[c1][c2][c3];

    int sum = c1;
    if (sum == 1 && c1 - c2 == 1) return dp[c1][c2][c3] = 1.0 * n;
    return dp[c1][c2][c3] = (solve(c1-1,c2,c3,n) * (double)(c1 - c2)/n + solve(c1,c2-1,c3,n) * (double)(c2 - c3)/n + solve(c1,c2,c3-1,n) * (double)c3/n + 1) * n / sum;
}

void solve() {
    int n;
    cin >> n;
    VI a(n);
    REP(i,0,n) cin >> a[i];
    int cnt[3] = {};
    REP(i,0,n) REP(j,0,a[i]) cnt[j]++;
    //cout<< solve(cnt[0], cnt[1], cnt[2], n) << endl;
    printf("%.12lf\n", solve(cnt[0], cnt[1], cnt[2], n));
}

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

Measured memory_bytes: 211328
#include <iostream>
#include <cmath>
#include <climits>
#include <string>
#include <numeric>
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
#include <functional>
#include <iomanip>

using namespace std;
using ll = long long;

template<typename T> void print(T t) { cout << t << endl; }

int main() {
	int N, a, ans=1;
	queue<int> alist;
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> a;
		alist.push(a);
	}

	while (!alist.empty()) {
		int lastA = alist.front(), newA, flag=0;
		alist.pop();
		while (!alist.empty()) {
			newA = alist.front();
			alist.pop();
			if (newA != lastA && flag == 0) {
				flag = (newA - lastA > 0) ? 1 : -1;
			}
			else if (newA - lastA < 0 && flag == 1) {
				ans++;
				flag = 0;

			}
			else if (newA - lastA > 0 && flag == -1) {
				ans++;
				flag = 0;
			}
			lastA = newA;
		}
	}
	print(ans);
}

Measured memory_bytes: 3760
#include <iostream>
#include <bits/stdc++.h>
#define ll long long

using namespace std;


int main()
{
    ll h,k;  cin >> h;
    for(ll i = 60;i>=0;i--){
        if(h & (1LL << i))  {
            k = i;
            break;
        }
    }
    ll Ans = 0;
    while(k >= 0){
        Ans+=(1LL << k);
        k--;
    }
    cout << Ans;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
static const int64_t mod=1000000007;
int64_t f(int64_t x,int64_t y){
if(y==0)
  return 1;
  else if(y%2==0)
    return (f(x,y/2)*f(x,y/2))%mod;
  else
    return (x*((f(x,y/2)*f(x,y/2))%mod))%mod;
}
int main(){
  string s,t;
  cin>>s>>t;
  int N=s.size();
  int ans=0;
  for(int i=0;i<N;i++)
    if(s.at(i)!=t.at(i))
      ans++;
  cout<<ans<<endl;
  return 0;
}

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

public class Main {
    public static void main(String[] args) {
        MyScanner sc = new MyScanner();

        int n = sc.nextInt();
        
        System.out.println(n * n * n);
    }

    static class MyScanner {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in), 1 << 15);
        StringTokenizer tokenizer;

        String next() {
            try {
                while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                    tokenizer = new StringTokenizer(reader.readLine());
                }
            } catch (IOException ignored) {
            }
            return tokenizer.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }
    }
}

Measured memory_bytes: 21204
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
  let stdin = stdin();
  let stdin = stdin.lock();
  let token: String = stdin
    .bytes()
    .map(|c| c.expect("failed to read char") as char)
    .skip_while(|c| c.is_whitespace())
    .take_while(|c| !c.is_whitespace())
    .collect();
  token.parse().ok().expect("failed to parse token")
}

use std::cmp::{max, min};

fn main() {
  let n = read::<i64>();
  let ten = 10 as u32;
  let MOD = ten.pow(9) + 7;
  let mut ans = 0;

  let mut dp = vec![vec![vec![vec![0; 4]; 4]; 4]; n as usize + 1];

  dp[0][3][3][3] = 1;
  // i文字目
  for i in 0..n {
    // 最後から3文字目
    for j in 0..4 {
      // 最後から2文字目
      for k in 0..4 {
        // 最後から1文字目
        for l in 0..4 {
          // println!("i: {}, j: {}, k {}, l: {}", i, j, k, l);
          if dp[i as usize][j][k][l] == 0 {
            continue;
          }


          for new in 0..4 {
            if k == 0 && l == 2 && new == 1 {
              continue;
            }
            if k == 2 && l == 0 && new == 1 {
              continue;
            }
            if j == 0 && l == 2 && new == 1 {
              continue;
            }
            if j == 0 && k == 2 && new == 1 {
              continue;
            }
            if k == 0 && l == 1 && new == 2 {
              continue;
            }

            dp[i as usize + 1][k][l][new] += dp[i as usize][j][k][l];
            dp[i as usize + 1][k][l][new] %= MOD;
          }
        }
      }
    }
  }

  let mut ans = 0;
  for i in &dp[n as usize] {
    for j in i {
      for k in j {
        ans += *k;
        ans %= MOD;
      }
    }
  }

  println!("{}", ans);
}



Measured memory_bytes: 4352
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.List;
import java.util.ArrayList;
import java.util.Arrays;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		// 1行目数字、2行目文字
		String s = br.readLine();

		int[] i2 = new int[26];
		
		for(int i=0; i<s.length(); i++) {
			i2[s.charAt(i) - 'a'] += 1;
		}
		
		//checkInput(i2);
		
		//種類数を調べる
		int k=0;
		for(int i:i2) if(i>0){ k += 1; }
		//1種なら、即時終了
		if(k==1){ System.out.println(0); return; }
		
		dp("a ---");
		
		//文字数と種類数が同じ
		int ans;
		ans = (int)( (s.length()-1)/2.0 + 0.5);
		if(k==s.length()){ System.out.println( ans ); return; }
		
		dp("b ---");
		//同じ文字がある
		for(int i=0; i<26; i++){
			if(i2[i]>0){
				char c = Character.forDigit(i+10, 36);
				dp("c=["+c+"]");
				int count = 0;
				int max=0;
				for(int j=0; j<s.length(); j++){
					if(s.charAt(j)==c){
						max = (max > count) ? max : count;
						dp("c=[" +c +"], ans=["+ans+"]");
						count = 0;
					}else{
						count += 1;
					}
				}
				max = (max > count) ? max : count;
				ans = (max < ans) ? max : ans;
			}
		}
		
		dp("c ---");
		

//後ろをは削るだけ
//前を削ると、コピーもできる
//前にしか、文字をコピーできない

//全部違うなら、int((N-1)／2 + 0.5)
//同じのがあるなら、Xの前の個数、一番後ろの個数、で一番大きいのが最低回数


	System.out.println(ans);
	return;
	}
	//-----------------------------------------------------------------
	// Debug.Print
	static void dp(String s) {
		//System.out.println(s);
	}
	static void dp(StringBuilder s) { dp(s.toString()); }
	static void dp(int i) { dp(String.valueOf(i)); }
	static void dp(long i) { dp(String.valueOf(i)); }


	//-----------------------------------------------------------------
	// 入力値確認：リスト
	static void checkInput(List l) { System.out.println(l); }
	//-----------------------------------------------------------------
	// 入力値確認：配列、1次元、float型
	//   ＜使い方＞
	//     float[] f = new float[N];
	//     checkInput(f);
	static void checkInput(float[] i1) {
		StringBuilder sb = new StringBuilder();
		for(float i: i1) sb.append("[" + i + "]");
		System.out.println(sb);
	}
	//-----------------------------------------------------------------
	// 入力値確認：配列、1次元、int型
	//   ＜使い方＞
	//     int[] c = new int[N];
	//     checkInput(c);
	static void checkInput(int[] i1) {
		StringBuilder sb = new StringBuilder();
		for(int i: i1) sb.append("[" + i + "]");
		System.out.println(sb);
	}
	//-----------------------------------------------------------------
	// 入力値確認：配列、二次元、int型
	static void checkInput(int[][] i2) {
		StringBuilder sb = new StringBuilder();
		for(int[] i1: i2){
			for(int i: i1) sb.append("[" + i + "]");
			sb.append(System.getProperty("line.separator"));
		}
		System.out.println(sb);
	}
	//-----------------------------------------------------------------
	// 入力値確認：配列、二次元、int型
	static void checkInput(long[][] i2) {
		StringBuilder sb = new StringBuilder();
		for(long[] i1: i2){
			for(long i: i1) sb.append("[" + i + "]");
			sb.append(System.getProperty("line.separator"));
		}
		System.out.println(sb);
	}

}


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

#define F first
#define S second
#define prev azaza
#define MP make_pair
#define PB push_back

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

const int max_n = 100111, inf = 1000111222;

vector<int> v;

int main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int n;
    cin >> n;
    v.PB(0);
    for (int i = 0; i <n ; ++i) {
        int a;
        cin >> a;
        v.PB(a);
    }
    v.PB(0);
    ll sum = 0;
    for (int i = 0; i + 1 < v.size(); ++i) {
        sum += abs(v[i] - v[i + 1]);
    }
    for (int i = 1; i <= n; ++i) {
        ll sum1 = sum;
        sum1 -= abs(v[i] - v[i - 1]);
        sum1 -= abs(v[i] - v[i + 1]);
        sum1 += abs(v[i - 1] - v[i + 1]);
        cout << sum1 << '\n';
    }



    return 0;
}




Measured memory_bytes: 1784