akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_poizcy.hpp>
typedef long long  ll;
#define pb                push_back
#define mp                make_pair
#define all(a)            (a).begin(), (a).end()
#define clr(a,h)          memset(a, (h), sizeof(a))
#define mem(a,h)          memset(a, (h), sizeof(a))
#define fi first
#define se second
#define por(a,b) (((a%MOD) * (b%MOD))%MOD)
#define forg(i, b, e, c)    for (ll i = (ll)b; i < (ll)e; i+=c)
#define forr(i, b, e)    for (ll i = b; i < e; i++)
 
 
using namespace std;
//using namespace __gnu_pbds;
typedef double lldb;
typedef pair<ll, ll>  ii;
typedef pair<double, double>  iidb;
typedef pair<ll, ii>  iii;
typedef vector<ll>     vi;
typedef vector<vi>     vvi;
typedef vector<ii>      vii;
typedef vector<ll>      vll;
//typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
const ll INF = 1e9+7;
const double PI = acos(-1);
const ll MOD= 1e9+7;
#define initseg ll new_nodo=(nodo*2),mid=(iz+der)/2;
 
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define tam 210000
#define offset 200
#define ptr nodo*
const ll inf=2e18;

const double EPS=1e-9;
ll dp[tam],v[tam];
int main()
{
	dp[0]=1000;
	int n;
	cin>>n;
	forr(i,1,n+1)
		cin>>v[i];
	forr(j,1,n+1)
	{

		forr(k,0,j)
		dp[j]=max(dp[j],dp[k]);
		forr(k,1,j)
		{
				dp[j]=max(ll(dp[k]/v[k])*v[j]+dp[k]%v[k],dp[j]);
		}
		//cout<<dp[j]<<" ";
	}
	cout<<dp[n]<<endl;
}				

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

int main() {
  int N;
  cin >> N;
  int sum=0;
  int A = N;
  
  while( A > 0 ){
  	sum += A%10;
    A = A/10;
  }
  if ( N%sum == 0 ){
  	cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
import qualified Data.ByteString.Char8 as B
import Data.Char
import Data.List

readInts :: IO [Int]
readInts = unfoldr (B.readInt . B.dropWhile isSpace) <$> B.getLine

main :: IO ()
main = do
  n <- readLn
  print $ solve n

solve :: Int -> Int
solve n = n * n * n


Measured memory_bytes: 508
#include <bits/stdc++.h>
using namespace std;
#define fix(f,n) std::fixed<<std::setprecision(n)<<f
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long int ll;
typedef unsigned long long int ull;
#define vi vector<int>
#define pii pair<int,int>
#define vii vector<pii>
#define max(a,b) ((a>b)?a:b)
#define min(a,b) ((a>b)?b:a)
#define max3(a,b,c) ((a>b)?(a>c)?a:c:(b>c)?b:c)
#define min3(a,b,c) ((a<b)?(a<c)?a:c:(b<c)?b:c)
#define REP(i,a,n) for(ll i=a;i<n;i++)
#define pb push_back
#define mp make_pair

int main(){
	fast;
	int test=1;
	//cin >> test;
	while(test--){
	    int n,W;
	    cin >> n >> W;
	    int v[n+1],w[n+1];
	    ll sum=0;
	    for(int i=1 ; i<=n ; i++){
	        cin >> w[i] >> v[i];
	        sum+=v[i];
	    }
	    ll dp[sum+1][n+1];
	    memset(dp,-1,sizeof dp);
	    dp[0][0]=0;
	    for(int k = 1; k <= n; k++){
	        for (int x = 0; x<=sum; x++){
	            if(x>=v[k] && dp[x-v[k]][k-1]!=-1){
	                dp[x][k]=min(w[k]+dp[x-v[k]][k-1],(dp[x][k-1]==-1?1000000000000000000:dp[x][k-1]));
	            }else{
	                dp[x][k]=dp[x][k-1];
	            }
	        }
	    }
	    for(int i=sum ; i>=0 ; i--){
	        if(dp[i][n]<=W && dp[i][n]!=-1){
	            cout << i << endl;
	            break;
	        }
	    }
	}
	return 0;
}

Measured memory_bytes: 82520
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int MAX=1e5+10;
int main (){
    ll q,h,s,d,N;
    cin >> q >> h >> s >> d;
    cin >> N;
    ll odd = 0 , even = 0;
    if(N&1)odd=1,even=N-1;
    else odd=0,even=N;
    ll res = min(odd*s,min(2*odd*h,4*odd*q));
    res = res + min(min(even*s,min(2*h*even,4*q*even)),even/2 * d);
    cout<<res<<endl;
    return 0;
}


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

using namespace std;

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

typedef long long ll;

int N;

int main(){
  ll cnt = 0;
  cin >> N;
  vector<int>A(N+2);
  rep(i,N)cin>>A[i+1];

  vector<ll>D1(N+2);
  vector<ll>D2(N+2);
  vector<int>C1(N+2);
  vector<int>C2(N+2);

  for(int i = 1; i <= N; ++i){
    ll bigger = max(D1[i-1],D2[i-1]);
    D1[i] = bigger+(A[i]/2);
    C1[i] = (A[i]%2);

    if(A[i]>0){
      if(C1[i-1]!=0 && C2[i-1]!=0){
        D2[i] = bigger + (A[i]-1)/2 + 1;
        C2[i] = A[i] - (((A[i]-1)/2)*2 + 1);
      }
      else if(C1[i-1]!=0){
        D2[i] = D1[i-1] + (A[i]-1)/2 + 1;
        C2[i] = A[i] - (((A[i]-1)/2)*2 + 1);
      }
      else if(C2[i-1]!=0){
        D2[i] = D2[i-1] + (A[i]-1)/2 + 1;
        C2[i] = A[i] - (((A[i]-1)/2)*2 + 1);
      }
      else{
        D2[i]=D1[i];
        C2[i]=C1[i];
      }
    }
  }

  cout << max(D1[N],D2[N]) << endl;

  return 0;
}


Measured memory_bytes: 2944
#include <cstdlib>
#include <iostream>
#include <string>
#include <vector>
typedef long long LL;

int main() {
  int N; std::cin >> N;

  int ng_cnt = 0;
  for (int i = 1; i <= N; ++i) {
    int a; std::cin >> a;
    if (a != i) ++ng_cnt;
  }

  if (ng_cnt <= 2) std::cout << "YES" << std::endl;
  else              std::cout << "NO" << std::endl;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

func solve(d, t, s int) string {
	if float64(d)/float64(s) <= float64(t) {
		return "Yes"
	} else {
		return "No"
	}
}

func scanNums(len int) (nums []int) {
	var num int
	for i := 0; i < len; i++ {
		fmt.Scan(&num)
		nums = append(nums, num)
	}
	return
}

func main() {
	nums := scanNums(3)
	d := nums[0]
	t := nums[1]
	s := nums[2]

	result := solve(d, t, s)
	fmt.Println(result)
}


Measured memory_bytes: 1772
#include<stdio.h>
#include<iostream>
#include<cmath>
using namespace std;

int main() {
	int x, y, s;
	while(1) {
		cin >> x >> y >> s;
		int max = 0;
		if(x == y) break;
		for(int i = 1; i < s/2 + 1; i++) {
			int temp1, temp2;
			temp1 = int(ceil(double((s - i)) * 100 / (100 + x)));
			temp2 = int(ceil(double(i) * 100 / (100 + x)));
			if(temp1 * (100+x) / 100 == s - i) {
				if(temp2 * (100+x) / 100 == i) {
					temp1 = temp1 * (100 + y) / 100;
					temp2 = temp2 * (100 + y) / 100;
					if(max < temp1 + temp2) max = temp1 + temp2;
				}
			}
		}
		cout << max <<endl;
	}

	return 0;
}

Measured memory_bytes: 1164
#[allow(unused_macros)]
macro_rules ! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( std :: io :: BufReader :: new ( stdin . lock ( ) ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! input_inner { ( $ next : expr ) => { } ; ( $ next : expr , ) => { } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! read_value { ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) } ; ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) } ; }

fn main() {
    input! {
        d: u64, n: u64
    }

    let mut ret = 0;
    let mut cnt = 0;
    for i in 1.. {
        if div_cnt(i) == d {
            cnt += 1;
        }
        if cnt == n {
            ret = i;
            break;
        }
    }
    println!("{}", ret);
}

fn div_cnt(mut k: u64) -> u64 {
    let mut cnt = 0;
    while k % 100 == 0 {
        cnt += 1;
        k /= 100;
    }
    cnt
}

Measured memory_bytes: 4352
#include<algorithm>
#include<chrono>
#include<climits>
#include<numeric>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<random>
#include<set>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<vector>
#include<cassert>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<string>
using namespace std;
 
struct Debug{
    int cnt = 0;
    bool on = false;
    char debug[10] = "debug";
    template<class T>
    Debug & operator<<(const T & v) {
        if(on && cnt++ == 0) cerr << "debug: ";
        if(on) cerr << v << ' ';
        return *this;
    }
    Debug & operator<<(ostream&(*pManip)(ostream&)) {
        if(on) cerr << (*pManip);
        cnt = 0;
        return *this;
    }
} debug;
#define rep(i, a, b) for(auto i = (a); i < (b); i++)
#define rrep(i, a, b) for(auto i = (a); i > (b); i--)
#define all(v) (v).begin(), (v).end()
#define print(v) {if(debug.on){for(auto x : v) debug << x; debug << endl;}}
#define printn(v, n) {if(debug.on){for(int _i = 0; _i < n; _i++) debug << *(v + _i); debug << endl;}}
 

typedef unsigned long long ull;
typedef long long ll;
 
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<pii> vpii;


const int MAXN = 2e3 + 20;



int main(int argc, char * argv[]) {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    if(argc > 1 && !strcmp(argv[1], debug.debug)) debug.on = true;

    string s;
    cin >> s;
    int n = s.size();
    bool good = true;
    for(int i = 0; i < n; i++) {
    	if(i % 2 == 0 && s[i] == 'L')
    		good = false;
    	if(i % 2 == 1 && s[i] == 'R')
    		good = false;
    }
    if(good)cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}






















Measured memory_bytes: 384
# できるだけ等しく分割して、その結果の少ないほうの最大値

w,h, x, y = map(int, input().split())

maxsize = w*h

size = float(maxsize) / 2 

if (x == w/2) and (y == h/2):
    answer = str(float(size)) + " 1"
else:
    answer = str(float(size)) + " 0"

print(answer)



Measured memory_bytes: 2940
N=int(input())
pos=[0,0]
now=0
flag=True
for i in range(N):
  t,x,y=map(int,input().split())
  d = abs(x-pos[0])+abs(y-pos[1])
  if d>t-now:
    flag=False
    break
  else:
    if d%2==(t-now)%2:
      now=t
      pos[0],pos[1]=x,y
    else:
      flag=False
      break
if flag:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define REP(i,n) for(ll i=0;i<(n);++i)
#define itn int
#define ocut cout
#define ouct cout
int main(){
    char s[1000];
    cin >> s;
    for(int i=0;i<strlen(s);i++){
        cout << "x";
    }
}

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

int main() {
  int N,count;
  count = 0;
  cin >> N;
  vector<int> vec(N);
  for(int i =0;i<N;i++){
    cin >> vec.at(i);
  }
  for(int i=0;i<N-1;i++){
    if(vec.at(i)!=0){
      for(int j=i+1;j<N;j++){
      if(vec.at(i)==vec.at(j)){
        vec.at(j) = 0;
        count++;
        }
      }
    }
  }
  cout << (N-count) << endl;
}

Measured memory_bytes: 256
N = int(input())
m = list(map(lambda t:max(len(str(t[0])), len(str(t[1]))),[(r,int(N / r)) for r in range(2, int(N ** 0.5) + 2) if N % r == 0]))
print(min(m) if len(m) != 0 else len(str(N)))

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

int main(){
    int K, S, i, j, k;
    int ans=0;

    cin >> K >> S;
    

    for (i = 0; i < K+1; i++){
        for (j = 0; j < K+1; j++){
                if (S-i-j <= K && 0 <= S-i-j)
                    ans++;
            }
        }

        cout << ans << endl;
    }



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < n; ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
#define FORV(i, v) for (auto i = v.begin(); i != v.end(); i++)
using namespace std;

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

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; }
const int INF = 1001001001;
const long long INFLL = LLONG_MAX / 3;
const double eps = (1e-9);

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

  ll n, m;
  cin >> n >> m;

  if (n >= m / 2) {
    cout << m / 2 << endl;
    return 0;
  }

  ll ans = n;
  m -= n * 2;
  ans += m / 4;
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3592
array = gets.chomp.split(" ")
array.map!{|i|i.to_i}
if !array.inject(1){|sum,i| sum *= i}.odd?
  puts 0
else
  sum = 1
  array.sort.reverse.each_with_index do |i,index|
    sum *= i if index != 0
  end
  puts sum
end

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

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

int main(){
	int N;
	cin >> N;
	vector<LL> A(N);
	rep(i,N) cin >> A[i];
	int Q;
	cin >> Q;
	map<LL,LL> m;
	LL ans=0;
	rep(i,N) ans+=A[i];
	rep(i,N) m[A[i]]++;
	rep(i,Q){
		int B, C;
		cin >> B >> C;
		ans+=(C-B)*m[B];
		m[C]+=m[B];
		m[B]=0;
		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 9900
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

int32_t main(){
	IOS;
	string s;
	cin >> s;

	map<char, int> count;

	for(int i = 0;i < 4; i++){
		count[s[i]]++;
	}	

	if(count.size() == 2){
		for(auto x: count){
			if(x.second != 2){
				cout << "No" << endl;
				return 0;
			}
		}
	}
	else{
		cout << "No" << endl;
		return 0;
	}

	cout << "Yes" << endl;






	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <string>
using namespace std;
long long r[4000],g[4000],b[4000];
int main(){
	int n;
	string s;
	cin>>n>>s;
	for(int i=0;i<n;i++){
		if(s[i]=='R'){
			r[i]=1;
		}else if(s[i]=='G'){
			g[i]=1;
		}else{
			b[i]=1;
		}
	}
	for(int i=1;i<n;i++){
		r[i]+=r[i-1];
		g[i]+=g[i-1];
		b[i]+=b[i-1];
	}
	long long ans=0;
	for(int i=0;i<n;i++){
		for(int j=i+1;j<n;j++){
			int k=j+j-i;
			if(s[i]=='R'&&s[j]=='G'){
				ans+=b[n-1]-b[j];
				if(k<n&&s[k]=='B'){
					ans--;
				}
			}else if(s[i]=='G'&&s[j]=='R'){
				ans+=b[n-1]-b[j];
				if(k<n&&s[k]=='B'){
					ans--;
				}
			}else if(s[i]=='R'&&s[j]=='B'){
				ans+=g[n-1]-g[j];
				if(k<n&&s[k]=='G'){
					ans--;
				}
			}else if(s[i]=='B'&&s[j]=='R'){
				ans+=g[n-1]-g[j];
				if(k<n&&s[k]=='G'){
					ans--;
				}
			}else if(s[i]=='G'&&s[j]=='B'){
				ans+=r[n-1]-r[j];
				if(k<n&&s[k]=='R'){
					ans--;
				}
			}else if(s[i]=='B'&&s[j]=='G'){
				ans+=r[n-1]-r[j];
				if(k<n&&s[k]=='R'){
					ans--;
				}
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3656
#include <iostream>
#include <string>
using namespace std;
const string apple = "apple";
const string peach = "peach";
int main (int argc, char *argv[]) {
	string line;
	getline(cin,line);
	for(int i = 0; i < line.size(); ++i) {
		bool flag = true;
		if (line[i] == 'a') {
			if (line.size() < i + apple.size()) continue;
			for(int j = 0; j < apple.size(); ++j) {
				if (apple[j] != line[i+j]) {
					flag = false; break;
				}
			}
			
			if (flag) {
				for (int j=0;j<peach.size();j++) line[i+j] = peach[j];
			}
			
		} else if (line[i] == 'p') {
			if (line.size() < i + peach.size()) continue;
			for(int j = 0; j < peach.size(); ++j) {
				if (peach[j] != line[i+j]) {
					flag = false; break;
				}
			}
			
			if (flag) {
				for (int j=0;j<apple.size();j++) line[i+j] = apple[j];
			}
		}
	}
	cout << line << endl;
	return 0;
}

Measured memory_bytes: 0
#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 FOR(i,n,m) for(int i=n;i<=(int)(m);i++)
#define RFOR(i,n,m) for(int i=(int)(n);i>=m;i--)
#define all(x) (x).begin(),(x).end()
#define sz(x) int(x.size())
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;
vector<int> dy={1,0,-1,0};
vector<int> dx={0,1,0,-1};
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

int n,q;
string s;
vector<char> t,d;

bool f(int x,bool left){ //初期位置s[x]のゴーレムが生き残るならtrue
    int now=x;
    rep(i,q){
        if(t[i]!=s[now]) continue;
        now+=(d[i]=='L' ? -1 : 1);
        if(now<0){
            if(left) return false;
            else return true;
        }
        if(now>=n){
            if(left) return true;
            else return false;
        }
    }
    return true;
}

int main(){
    cin>>n>>q>>s;
    t.resize(q);
    d.resize(q);
    rep(i,q) cin>>t[i]>>d[i];
    
    int ng_left = -1, ok_left = n;
    while (ok_left - ng_left > 1) {
        int mid = (ng_left + ok_left) / 2;
        (f(mid,true) ? ok_left : ng_left) = mid;
    }
    if(ok_left==n) {
        cout<<0<<endl;
        return 0;
    }
    
    int ng_right = n, ok_right = -1;
    while (ng_right - ok_right > 1) {
        int mid = (ng_right + ok_right) / 2;
        (f(mid,false) ? ok_right : ng_right) = mid;
    }
    if(ok_right==-1) {
        cout<<0<<endl;
        return 0;
    }
    
    cout<<max(0,ok_right-ok_left+1)<<endl;
    
}


Measured memory_bytes: 900
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
#define all(q) (q).begin(),(q).end()
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int arr[MAX];
int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);
    int n,mx=-INT_MAX,x=0,mn=INT_MAX,y=0;
    cin>>n;
    for(int i=1; i<=n; i++)
    {
        cin>>arr[i];
        if(mx<arr[i])
        {
            mx=arr[i];
            x=i;
        }
        if(mn>arr[i])
        {
            mn=arr[i];
            y=i;
        }
    }
    vector<pair<int,int> >v;
    if(mx>=0 && mn<=0)
    {
        if(abs(mx)>=abs(mn))
        {
            for(int i=1; i<=n; i++)
            {
                arr[i]+=mx;
                v.push_back({x,i});
            }
        }
        else
        {
            for(int i=1; i<=n; i++)
            {
                arr[i]+=mn;
                v.push_back({y,i});
            }
        }
    }
    int f=0;
    if(arr[1]>=0)
    {
        for(int i=2; i<=n; i++)
        {
            arr[i]+=arr[i-1];
            v.push_back({i-1,i});
        }
    }
    else
    {
        for(int i=n-1; i>=1; i--)
        {
            arr[i]+=arr[i+1];
            v.push_back({i+1,i});
        }
    }

    cout<<v.size()<<endl;
    for(auto i:v)
        cout<<i.first<<" "<<i.second<<endl;

    return 0;
}


Measured memory_bytes: 3596
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>

using namespace std;

#define REP(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define pb(a) push_back(a)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

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

int main(){
 int A,B,n=0;
 cin >>A>>B;
 if(A>B){
 	n+=A;
 	A--;
 }else{
 	n+=B;
 	B--;
 }
 if(A>B){
 	n+=A;
 	A--;
 }else{
 	n+=B;
 	B--;
 }
 cout<<n<<endl;
}


Measured memory_bytes: 256
import sys
def p(*a):
  s=" ".join(map(str,a))
  #print(s)
  sys.stderr.write(s+"\n")



N=int(input())
A = [int(i) for i in input().split()]	# 1 2 3 4 5 ...
ABS=[]

iCount=0
iABSMin=10**9+1

for i in range(N):
	a = A[i]
	if a<0: iCount+=1
	
	b = abs(a)
	ABS.append(b)
	
	iABSMin=min(iABSMin,b)
	
	

if iCount%2==0:
	print(sum(ABS))
	exit()


ans=sum(ABS)-(iABSMin*2)
print(ans)



Measured memory_bytes: 14412
#include<stdio.h>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
ll mod = 1000000007;
#define SIZE 210000
ll inv[SIZE + 1];
ll kai[SIZE + 1];
ll invkai[SIZE + 1];
void invinit()
{
	inv[1] = 1;
	for (int i = 2; i <= SIZE; i++)
	{
		inv[i] = mod - (mod / i)*inv[mod%i] % mod;
	}
	kai[0] = invkai[0] = 1;
	for (int i = 1; i <= SIZE; i++)
	{
		kai[i] = kai[i - 1] * i%mod;
		invkai[i] = invkai[i - 1] * inv[i] % mod;
	}
}
ll com(ll a, ll b)
{
	if (b < 0 || a < b)return 0;
	return (invkai[b] * invkai[a - b]) % mod*kai[a] % mod;
}
ll d[200000];
int main()
{
	invinit();
	ll mx, my, ax, ay;
	scanf("%lld%lld%lld%lld", &mx, &my, &ax, &ay);
	for (int i = 0; i < mx - ax; i++)
	{
		d[i] = com(ay + i - 1, i);
	}
	ll ans = 0;
	for (int i = 0; i < mx; i++)
	{
		ans += d[i] * com(my - ay - 1 + mx - 1 - i, mx - 1 - i);
		ans %= mod;
	}
	printf("%lld\n", ans);
}

Measured memory_bytes: 5760
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef set<int> si;
typedef pair<int,int> pii;
#define rep(i,a,b) for(int i=(a); i<(b); ++i)
#define per(i,a,b) for(int i=(b)-1; i>=(a); --i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define F first
#define S second
const int INF = 987654321;
const ll MOD = 1000000007;

int n;
string s;

int main(void) {
  ios_base::sync_with_stdio(false); 
  cin.tie(NULL); 
  cout.tie(NULL);
  //freopen("in.txt", "r", stdin);
  cin >> s;
  n = sz(s);
  rep(i,0,n-1) {
    if(s[i] == 'B' && s[i+1] == 'C') {
      s[i] = 'D';
      s[i+1] = 'D';
    }
  }

  ll ret = 0;
  int a = 0;
  int d = 0;
  rep(i,0,n) {
    if(d == 0 && s[i] == 'A') {
      a++;
      continue;
    }
    if(a > 0 && s[i] == 'D') {
      d++;
      continue;
    }
    ret += (ll) a * (d/2);
    if(s[i] == 'A') {
      a++;
    } else {
      a = 0;
    }
    d = 0;
  }
  ret += (ll) a * (d/2);
  cout << ret << endl;
  return 0;
}

Measured memory_bytes: 720
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <utility>
#include <set>
#include <stack>
#include <climits>
#include <cmath>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define rep1(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define reps(i,s,n) for(int i=s, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define MEMSET(v, h) memset((v), h, sizeof(v))
typedef long long ll;
const char sp = ' ';


using namespace std;

int main(void){
    ll a, b;
    cin>>a>>b;
    cout<<(a*b%2==0 ? "Even" : "Odd")<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.lang.*;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);

        int N = Integer.parseInt(in.nextLine());
        long[] arr = new long[N];

        StringTokenizer s = new StringTokenizer(in.nextLine());
        for (int i = 0; i < N; ++i) {
            arr[i] = Integer.parseInt(s.nextToken());
        }

        // Stores score relative to Taro
        long[][] dp = new long[N][N];

        for (int i = 0; i < N; ++i) for (int j = 0; j < N; ++j) dp[i][j] = -1;

        for (int i = 0; i < N; ++i) {
            dp[N-1][i] = arr[i];
        }

        for (int turn = N-2; turn >= 0; --turn) {
            int length = N - turn; // # remaining pieces
            for (int leftMost = 0; leftMost + length <= N; ++leftMost) {

                int l = leftMost;
                int r = leftMost + length - 1;

                dp[turn][leftMost] = Math.max(
                        arr[r] - dp[turn+1][leftMost],
                        arr[l] - dp[turn+1][leftMost+1]);
            }
        }

        System.out.println(dp[0][0]);

    }
}


Measured memory_bytes: 132664
def dfs():
    sta = []
    ans = [-1]*(N+1)

    sta.append(K)
    ans[K] = 0

    while sta:
        nod = sta.pop()
        for t, d in tree[nod]:
            if ans[t] < 0:
                ans[t] = ans[nod] + d
                sta.append(t)

    return ans


N = int(input())
tree = [[] for i in range(N+1)]
for i in range(N-1):
    a, b, c = map(int, input().split())
    tree[a].append((b, c))
    tree[b].append((a, c))
Q, K = map(int, input().split())
dis = dfs()

for i in range(Q):
    x, y = map(int, input().split())
    print(dis[x]+dis[y])


Measured memory_bytes: 43312
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s1,s2,s3;
  cin >> s1 >> s2 >> s3;
  char dif;
  dif = 'A'-'a';
  printf("%c%c%c\n", s1[0] + dif, s2[0] + dif, s3[0] + dif);
}

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

int main() {
    long long N;
    cin >> N;
    string res = "";
    while (N) {
        --N;
        res += (char)('a' + (N % 26));
        N /= 26;
    }
    reverse(res.begin(), res.end());
    cout << res << endl;
}

Measured memory_bytes: 3612
from collections import defaultdict
import sys

stdin = sys.stdin
read_int = lambda : list(map(int,stdin.readline().split()))
read_str = lambda : stdin.readline().rstrip()

N = read_int()[0]
d = defaultdict(lambda: int())
to_str = "".join

for _ in range(N):
    row = to_str(sorted(input()))
    d[row] += 1

def solve():
    ans = 0
    for _, v in d.items():
        ans += v * (v - 1) // 2
    return ans

if __name__ == "__main__":
    print(solve())

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

using namespace std;

#define lli long long int
#define REP(i,n) for(int i=0;i<n;i++)
#define REP2(i,n) for(lli i=1;i<=n;i++)

	lli d[600][600] = {0};
	lli x[600][600] = {0};

int main(){
	lli n,m,q;
	cin>>n>>m>>q;
	lli p1,p2;

	REP(i,m){
		lli tmpI,tmpJ;
		cin>>tmpI>>tmpJ;
		d[tmpI][tmpJ]++;
	}

	REP2(i,n)REP2(j,n)x[i][j] = x[i][j-1] + d[i][j];

	REP(i,q){
		cin>>p1>>p2;
		lli sum=0;
		for(lli j=p1;j<=p2;j++)sum += x[j][p2] - x[j][p1-1];
		cout<<sum<<endl;
	}

	return 0;
}



Measured memory_bytes: 6016
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}
#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}
#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        a: u32,
        b: u32, 
        c: u32, 
        d: u32, 
    }
    if a * b > c * d {
        println!("{}", a * b);
    } else {
        println!("{}", c * d);
    }
} 


Measured memory_bytes: 4352
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
using namespace std;
#define MOD 1000000007
#define INF 1<<30
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define RREP(i,a,b) for(ll i=(a); i>=(b); i--)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> p;
typedef vector<pair<ll, ll>> vpl;

int main(){
    ll n; cin >> n;
    vl a(n);
    ll sum = 0;
    rep(i,n) {
        cin >> a[i];
        sum += a[i];
    }
    ll s = 0;
    for(int i=0; i<n-2; i+=2){
        s += 2 * a[i];
    }
    //cout << s << "\n";    
    vl ans(n);
    ans[n-1] = sum - s;
    for(int i=n-2; i>=0; i--){
        ans[i] = 2 * a[i] - ans[i+1];
    }
    rep(i,n){
        if(i == n-1) cout << ans[i] << "\n";
        else cout << ans[i] << " ";
    }
}

Measured memory_bytes: 2944
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
# define ll int64_t
# define str string
# define rep(i,n) for(ll i=0;i<n;i++)
# define rrep(i,n) for(ll i=1;i<=n;i++)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define mod 1000000007
# define PI 3.141592653589793
# define vec vector
#define dump(x) cerr<<#x<<"="<<x<<endl
using namespace std;

#define INF 2000000000
#define MAX_V 10



bool compare_by_b(pair<string,ll> a,pair<string,ll> b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}

bool my_compare(pair<string,ll> a,pair<string,ll> b){
    if(a.first != b.first) return a.first<b.first;
    if(a.second != b.second) return a.second>b.second;
    else return true;
}

ll modpow(ll a,ll n,ll mod1) {
    ll res=1;
    while(n>0){
        if(n&1) res=res*a%mod1;
        a = a*a%mod1;
        n >>= 1;
    }
    return res;
}

ll factorial(ll n){
    ll x=1;
    rrep(i,n) (x*=i)%=mod;
    return x;
}

ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b,a%b));
}

ll lcm(ll a,ll b){
   return a/gcd(a,b)*b;
}


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    
    ll n,sum=0;
    cin>>n;
    vec<ll> a(n+2);
    rrep(i,n) cin>>a[i];
    a[n+1]=0;
    rrep(i,n+1){
        sum+=abs(a[i]-a[i-1]);
    }
    for(ll i=1;i<=n;i++){
        ll num=sum;
        if(a[i-1]<a[i] && a[i]>a[i+1]){
            num-=(abs(a[i]-a[i-1])+abs(a[i]-a[i+1]));
            num+=abs(a[i-1]-a[i+1]);
        }else if(a[i-1]>a[i] && a[i]<a[i+1]){
            num-=(abs(a[i]-a[i-1])+abs(a[i]-a[i+1]));
            num+=abs(a[i-1]-a[i+1]);
        }
        cout<<num<<endl;
    }
    return 0;
}


Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
#define Rep(i,N) for(int i = 0; i < N; i++)
#define INF 1 << 28
typedef pair<int,int> Pi;
#define F first
#define S second
#define pb push_back

inline void chmax(int &a, int b) { a = max(a,b); }
inline void chmin(int &a, int b) { a = min(a,b); }

const int mod = 1e5;

int main()
{
  int N, M;
  cin >> N >> M;
  int sum[100005] = {0}, val;
  for(int i = 1; i < N; i++) {
    cin >> val;
    sum[i] = (sum[i - 1] + val) % mod;
  }
  int now = 0;
  int data, ans = 0;
  while(M--) {
    cin >> data;
    int a = now, b = now + data;
    if(a > b)swap(a,b);
    (ans += sum[b] - sum[a]) %= mod;
    now += data;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3472
#define _USE_MATH_DEFINES
#include <math.h>
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <stdio.h>
#include <vector>
#include <map>

using namespace std;
typedef long long ll;

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

int main() {

    ll K;
    string S;
    cin >> K >> S;
    ll N = S.length();
    string out = S;
    if(N>K){
        out.erase(K);
        out += "...";
    }
    cout << out << endl;
    return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <queue>

using namespace std;

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	int N;
	cin >> N;
	priority_queue<pair<int,int>, vector<pair<int,int> >, greater<pair<int,int> > > job;
	for(int i=0;i<N;i++)
	{
		int a, b;
		cin >> a >> b;
		job.push(make_pair(b,a));
	}
	int time = 0;
	for(int i=0;i<N;i++)
	{
		pair<int,int> now = job.top();
		job.pop();
		time = time + now.second;
		if(now.first < time)
		{
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	
	return 0;
}

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

int main() {
    int N, K; cin >> N >> K;
    int p[N];
    for (int i = 0; i < N; i++) cin >> p[i];
    double ans = 0.0, exp = 0.0;
    for (int i = 0; i < N; i++) {
        exp += (p[i] + 1) / 2.0;
        if (i < K-1) continue;
        ans = max(ans, exp);
        exp -= (p[i-K+1] + 1) / 2.0; 
    }
    cout << fixed << setprecision(10) << ans << endl;
}

Measured memory_bytes: 1024
#include <iostream>

using namespace std;

int main() {
    long long x, y;
    cin >> x;
    y = x / 11;
    if (y * 11 >= x)
        cout << y * 2 << endl;
    else if (y * 11 + 6 >= x)
        cout << y * 2 + 1 << endl;
    else
        cout << y * 2 + 2 << endl;

    return 0;
}

Measured memory_bytes: 256
/*<---------------------------CONCEPTS LEARNT------------------------------>

<-------------------------------------------------------------------------->
            _           __                _      _____ _____ _____ 
  ___ _   _| |__   ___ / _|_ __ ___  __ _| | __ |___  |___  |___  |
 / __| | | | '_ \ / _ \ |_| '__/ _ \/ _` | |/ /    / /   / /   / / 
| (__| |_| | |_) |  __/  _| | |  __/ (_| |   <    / /   / /   / /  
 \___|\__,_|_.__/ \___|_| |_|  \___|\__,_|_|\_\  /_/   /_/   /_/   

*/
#include<bits/stdc++.h>
using namespace std;
typedef long long ll ;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<ll> vi;
typedef vector<pll> vpll;
typedef unordered_map <ll,ll> umap ; 
//#pragma GCC optimize "trapv"
#define loop(i,a,b) for(ll i=a ;i<b;i++)
#define For(i,n) for(int i=0;i<(ll)n;i++)
#define Rev(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,n) for(int i=1;i<=n;++i)
#define F first
#define S second
#define pb push_back
#define em emplace_back
#define all(v) (v).begin(),(v).end()
#define mems(x, y) memset(x, y, sizeof(x))
#define sz(v) (v).size()
#define mp(a,b) make_pair(a,b)
#define pf(n) cout<<n<<"\n"
#define pff(n) cout << n << " " ; 
long const M=1e9+7;
const long mxN =1e5+2 ;
const long mxNN =1e6+2 ;

void solve(){
     long double l ; cin >> l ;
     cout << (l/3)*(l/3)*(l/3) << endl ;
}
int main() {
     ios_base::sync_with_stdio(false);
     cin.tie(NULL);
     cout << fixed << setprecision(20) ;
     solve() ;
     //ll t ; cin >> t ; while(t--)solve();
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<string> 
using namespace std;
int a,b,c,i,j,k;
char ch,lch;
int ans;
int main(){
	ans=0;
	string str;
	cin>>str;
	lch=str[0];
	for(i=1;i<str.length();i++){
		ch=str[i];
		if(ch!=lch){
			lch=ch;
			ans++;
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 512
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long a, b;
		a = sc.nextLong();
		b = sc.nextLong();

		int height = 0;
		for (int i = 1; i <= (b - a); i++) {
			height += i;
		}

		System.out.println(height - b);
	}
}

Measured memory_bytes: 23764
#include<stdio.h>

int main(){
  int i=0,j,tmp;
  int m[10];

  for(i=0; i<10;i++){
    scanf("%d",&m[i]);
  }

  //bubble sort
  for(j=9; j>0; j--){
    for(i=0; i<j; i++){
      if(m[i] < m[i+1]){
	tmp = m[i];
	m[i] = m[i+1];
	m[i+1] = tmp;
      }
    }
  }

  //output
  printf("%d\n",m[0]);
  printf("%d\n",m[1]);
  printf("%d\n",m[2]);
  
  return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
using Int = int_fast64_t;

Int n, m, mod = 1e9+7;
vector<Int> s, t;
vector<vector<Int>> dp;

Int func(size_t p, size_t q){
	if(dp[p][q] != -1) return dp[p][q];
	Int res = 0;
	if(p == 0 || q == 0) return dp[p][q] = 0;
	res = ((func(p-1, q) + func(p, q-1)) % mod - func(p-1, q-1)) % mod;
	if(s[p-1] == t[q-1]){
		res += func(p-1, q-1) + 1;
		res %= mod;
	}
	if(res < 0) res += mod;
	return dp[p][q] = res;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> n >> m;
	s.resize(n); t.resize(m);
	for(auto &i:s) cin >> i;
	for(auto &i:t) cin >> i;
	dp.resize(s.size()+1, vector<Int>(t.size()+1, -1));
	cout << (func(s.size(), t.size()) + 1) % mod<< "\n";
//	for(size_t i=0; i<=s.size(); ++i)
//		for(size_t j=0; j<=t.size(); ++j)
//			cout << dp[i][j] << " \n"[j==t.size()];
}

Measured memory_bytes: 32000
use std::collections::HashSet;
use std::collections::VecDeque;
use std::io::*;
use std::str::FromStr;

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")
}

const N: usize = 3;
const N2: usize = 9;

const DX: [i32; 4] = [-1, 0, 1, 0];
const DY: [i32; 4] = [0, -1, 0, 1];
const DIR: [&str; 4] = [&"u", &"l", &"d", &"r"];

#[derive(PartialEq, Eq, Hash, Clone)]
struct Puzzle {
    f: Vec<usize>,
    space: usize,
    path: String,
}

fn is_target(puzzle: Puzzle) -> bool {
    for index in 0..N2 {
        if puzzle.f[index] != (index + 1) {
            return false;
        }
    }
    return true;
}

fn puzzle_key(puzzle: Puzzle) -> String {
    return puzzle.f.iter().map(|&s| s.to_string()).collect::<String>();
}

fn bfs(puzzle: Puzzle) -> String {
    let mut q: VecDeque<Puzzle> = VecDeque::new();
    let mut v = HashSet::new();
    let new_puzzle = puzzle;
    let v_key: String = puzzle_key(new_puzzle.clone());
    q.push_back(new_puzzle);
    v.insert(v_key);
    while q.len() > 0 {
        let u_puzzle: Puzzle = q.pop_front().unwrap();
        if is_target(u_puzzle.clone()) {
            return u_puzzle.path;
        }
        let sx = u_puzzle.space / N;
        let sy = u_puzzle.space % N;
        for r in 0..4 {
            let tx: i32 = sx as i32 + DX[r];
            let ty: i32 = sy as i32 + DY[r];
            if tx < 0 || ty < 0 || tx >= N as i32 || ty >= N as i32 {
                continue;
            }
            let mut v_puzzle = u_puzzle.clone();
            v_puzzle
                .f
                .swap(u_puzzle.space, tx as usize * N + ty as usize);
            v_puzzle.space = tx as usize * N + ty as usize;
            let v_puzzle_key: String = puzzle_key(v_puzzle.clone());

            if !v.contains(&v_puzzle_key) {
                v.insert(v_puzzle_key);
                v_puzzle.path = v_puzzle.path + DIR[r];
                q.push_back(v_puzzle);
            }
        }
    }
    return "".to_string();
}

fn main() {
    let mut init_numbers: Vec<usize> = vec![0; N2];
    let mut init_space: usize = 0;
    for i in 0..N2 {
        let number: usize = read();
        init_numbers[i] = number;

        if init_numbers[i] == 0 {
            init_numbers[i] = N2;
            init_space = i;
        }
    }

    let puzzle = Puzzle {
        f: init_numbers,
        space: init_space,
        path: "".to_string(),
    };

    let ans: String = bfs(puzzle);
    println!("{}", ans.len());
}



Measured memory_bytes: 23472
/*
　　　∫ ∫ ∫
　　　ノヽ
　　（＿　 ）
　（＿　　　 ）
（＿＿＿＿＿＿ ）
　ヽ(´･ω･)ﾉ　
　　 |　 /
　　 UU
*/
#pragma region macro
#include <bits/stdc++.h>
typedef long long int64;
using namespace std;
typedef vector<int> vi;
const int MOD = (int)1e9 + 7;
const int64 INF = 1LL << 62;
const int inf = 1<<30;
const char bn = '\n';
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define REP(i, n) for (int i = 0; i < (n); i++)
#define FOR(i,s,n) for (int i = s; i < (n); i++)
#define ALL(obj) (obj).begin(), (obj).end() //コンテナじゃないと使えない!!
#define debug(x) cerr << #x << ": " << x << "\n";
#define mp make_pair
template <typename T>
ostream& operator<<(ostream& os, const vector<T> &V){
    int N = V.size();
    REP(i,N){
        os << V[i];
        if (i!=N-1) os << " ";
    }
    os << "\n";
    return os;
}
template <typename T,typename S>
ostream& operator<<(ostream& os, pair<T,S> const&P){
    os << "(";
    os << P.first;
    os << " , ";
    os << P.second;
    os << ")";
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, set<T> &S){
    auto it=S.begin();
    while(it!=S.end()){
        os << *it;
        os << " ";
        it++;
    }
    os << "\n";
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, deque<T> &q){
    for(auto it=q.begin();it<q.end();it++){
        os<<*it;
        os<<" ";
    }
    os<<endl;
    return os;
}
template <typename T,typename S>
ostream& operator<<(ostream& os, map<T,S> const&M){
    for(auto e:M){
        os<<e;
    }
    os<<endl;
    return os;
}
vector<pair<int,int>> dxdy = {mp(0,1),mp(1,0),mp(-1,0),mp(0,-1)};
#pragma endregion
//fixed<<setprecision(10)<<ans<<endl;



int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int N,P; cin >> N >> P;
    vector<int> A(N);
    REP(i,N) cin >> A[i], A[i]&=1;
    vector<int64> DP(2);
    DP[0] = 1;
    for(auto a:A){
        auto tmp = DP;
        REP(x,2){
            DP[x^a] += tmp[x];
        }        
    }

    cout << DP[P] << endl;
}

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

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

    int len = s.length();

    int left = 0;
    int right = len - 1;
    int ans = 0;
    int flag = 0;
    while(1){
        if(left >= right){
            break;
        }

        if(s[left] == s[right]){
            left++;
            right--;
        }else if(s[left] == 'x'){
            left++;
            ans++;
        }else if(s[right] == 'x'){
            right--;
            ans++;
        }else{
            flag = 1;
            break;
        }
    }

    if(flag == 1){
        ans = -1;
    }

    cout << ans << endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <map>
#include <sstream>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <iterator>
#include <stack>
#include <list>
using namespace std;
#define INF 1000000000
typedef long long int lli;
typedef pair<int,int> P;

int dp[100000];
P data[100000];

int main(){
	int N,L,ans=0;
	cin >> N >> L;
	for(int i=0; i<N; ++i){
		dp[i]=0;
	}
	for(int i=0; i<N; ++i){
		int tmp;
		cin >> tmp;
		data[i].first=L-tmp;
		data[i].second=i;
	}
	sort(data,data+N);
	for(int i=0; i<N; ++i){
		if(data[i].second==0){
			dp[data[i].second]=data[i].first+dp[data[i].second+1];
		} else if(data[i].second==N-1){
			dp[data[i].second]=data[i].first+dp[data[i].second-1];
		} else {
			dp[data[i].second]=data[i].first+max(dp[data[i].second-1],dp[data[i].second+1]);
		}
		ans=max(ans,dp[data[i].second]);
	}
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 2340
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();
// freopen("input.txt", "r", stdin);

int main() {
    int n;
    cin >> n;
    vector<ll> dp(3, 0);
    vector<ll> arr(3, 0);
    for(int i = 0; i < n; i++) {
        for(ll& val: arr)
            cin >> val;
        vector<ll> new_dp(3, 0);
        for(int j = 0; j < 3; j++) {
            ll cur = 0;
            for(int k = 0; k < 3; k++) {
                if (k == j) continue;
                cur = max(cur, dp[k]);
            }
            new_dp[j] = arr[j] + cur;
        }
        swap(dp, new_dp);
    }
    cout << max({dp[0], dp[1], dp[2]}) << endl;

    return 0;
}



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

using namespace std;

#define MOD 1000000007

template<typename T>
istream& operator >> (istream& is, vector<T>& vec) {
	for (T& x : vec) is >> x;
	return is;
}

int d[100000 * 3];

int main() {
	int n;
	cin >> n;
	int m = 0;
	for (int i = 0; i < n; i++)
	{
		int buf;
		cin >> buf;
		if (buf < 3200)
			d[buf / 400]++;
		else
			m++;
	}
	int a = 0;
	for (int i = 0; i < 8; i++)
	{
		if (d[i] > 0)
			a++;
	}
	if (a > 0)
		cout << a << " " << a + m << endl;
	else
		cout << 1 << " " << m << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define ff first
#define ss second
// #define mp make_pair
#define pb push_back
#define ios                           \
    std::ios::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define fill(x, v) memset(x, v, sizeof(x))
const ll mod = 1000000007;
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char *name, Arg1 &&arg1)
{
    cerr << name << " : " << arg1 << 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) << " : " << arg1 << " | ";
    __f(comma + 1, args...);
}
/*
std::cout << std::setprecision(9) << f << '\n';//3.141590000;
map<char,int>::reverse_iterator rit;
*/
// --------dsu-- --------

//-----------------------------

int main()
{
    string s;
    cin >> s;
    ll n = s.size();
    map<ll, ll> mp;
    ll ans = 0, val = 0, p10 = 1;mp[0]=1;
    for (int i = n - 1; i >= 0; i--)
    {
        ll x = s[i] - '0';
        val = (val + x * p10) % 2019;
        ans += mp[val];
        mp[val]++;
        // trace(val);
        p10 = (p10 * 10) % 2019;
    }

    cout << ans << endl;
}


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

int main() {

int n;cin>>n;bool isfail=true;
while(n>0)
{
	if(n%10==7)
	{

		cout<<"Yes"<<endl;
		isfail=false;
		break;

	}n/=10;


}if(isfail==true)
	cout<<"No"<<endl;















    return 0;
}


Measured memory_bytes: 3048
import java.util.*;
import java.io.*;
public class Main {
   public static void main(String[] args) {
      
      BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
      try {
         String line = reader.readLine();
         
         line = line.replace('C', 'A');
         line = line.replace('G', 'A');
         line = line.replace('T', 'A');

         int count = 0;
         String sample = "A";

         int n = line.indexOf(sample);
         if (n != -1) {
            count = 1;
         }

         for(int i = 1; i < 11; i++){
            sample = sample + "A";

            n = line.indexOf(sample);
            if(n != -1){
               count = i + 1;
            }
         }
         System.out.println(count);
      }

      catch (IOException e) {
         System.out.println(e);
      }
   }
}

Measured memory_bytes: 23252