akhauriyash/Code-Regression huggingface dataset:
def main():

    input_string = input()
    [str_a, str_b] = input_string.split()
    num_a = int(str_a)
    num_b = int(str_b)

    if num_a < num_b:
        print('a < b')
    elif num_a > num_b:
        print('a > b')
    elif num_a == num_b:
        print('a == b')


main()

Measured memory_bytes: 7704
from collections import deque

n = int(input())
a, b = deque(), deque()
for _ in range(n):
    x, y = map(int, input().split())
    a.appendleft(x)
    b.appendleft(y)
ans = 0
for i in range(n):
    ans += (b[i] - ((a[i] + ans) % b[i])) % b[i]
print(ans)

Measured memory_bytes: 11380
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < (int)(n); i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
using ll = long long;

int main() {
    cin.tie(0); cout.tie(0); ios::sync_with_stdio(false);
    int N, K; cin >> N >> K;
    vector<ll> P(N), C(N);
    REP(i, 0, N) { cin >> P[i]; P[i]--; }
    REP(i, 0, N) cin >> C[i]; 

    ll ans = -(1LL << 60);
    unordered_map<int, int> seen;
    REP(i, 0, N) {
        // cout << "# i : " << i << endl;
        seen.clear();
        ll score = 0; 
        int next = P[i], cnt = 0;
        while (!seen.count(next) && cnt < K) {
            seen[next] = cnt++;
            score += C[next];
            ans = max(ans, score);
            next = P[next];
        }
        // cout << "--> cnt : " << cnt << ", score : " << score << endl;

        if (cnt == K) continue;

        int loop_size = cnt - seen[next];
        vector<ll> additional(loop_size + 1, 0);
        // cout << "--> additional size : " << loop_size << endl;
        ll total = 0;
        REP(i, 0, loop_size) {
            // cout << "--> i : " << next << endl;
            additional[i + 1] = additional[i] + C[next];
            total += C[next];
            next = P[next];
            // cout << "--> total : " << total << endl;
        }

        if (total > 0) {
            ll rem = (K - cnt - 1) / ((int)additional.size() - 1);
            score += rem * total;
            ans = max(ans, score);
            cnt += rem * ((int)additional.size() - 1);
        }
        // cout << "--> cnt : " << cnt << ", score : " << score << endl;

        REP(i, 0, min((int)additional.size() - 1, K - cnt)) {
            ans = max(ans, score + additional[i + 1]);
            // cout << "--> additional score : " << score + additional[i + 1] << endl;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3992
import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;

import static java.lang.Math.*;
import static java.util.Arrays.*;

public class Main{

	Scanner sc=new Scanner(System.in);

	int INF=1<<28;
	double EPS=1e-9;

	void run(){
		for(; sc.hasNext();){
			println(sc.nextInt()+sc.nextInt()+"");
		}
	}

	void debug(Object... os){
		System.err.println(Arrays.deepToString(os));
	}

	void print(String s){
		System.out.print(s);
	}

	void println(String s){
		System.out.println(s);
	}

	public static void main(String[] args){
		// System.setOut(new PrintStream(new BufferedOutputStream(System.out)));
		new Main().run();
	}
}

Measured memory_bytes: 11000
#include <bits/stdc++.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define rep(I, N) for (int I = 1; I <= (N); ++I)
#define repp(I, N) for (int I = 0; I < (N); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORR(I, A, B) for (int I = (A); I >= (B); I--)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
const int N = 2000 + 5;
const double eps = 1e-7;
const int mod = 1e9 + 7;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
LL gcd(LL a,LL b){return b>0?gcd(b,a%b):a;}
LL ksm(LL a,LL b){LL ans = 1;while(b){if(b&1) ans = ans * a % mod;a = a * a % mod;b >>= 1;}return ans % mod;}
LL comb[N][N];//comb[i][j]内存放的是C(i,j)%mod
void init() {
    for(int i=0; i<N; i++) {
        comb[i][i]=1;
        comb[i][0]=1;
        for(int j=1; j<i; j++) {
            comb[i][j]=comb[i-1][j]+comb[i-1][j-1];
            if(comb[i][j]>=mod)
                comb[i][j]-=mod;
        }
    }
}
int main() {
    init();
    LL n,k;
    cin >> n >> k;
    //cout << n << k << endl;
    rep(i,k)
    {
        LL ans = comb[(n - k + 1)][i] % mod * comb[k - 1][i - 1] % mod;
        cout << ans % mod << endl;
    }
    return 0;
}


Measured memory_bytes: 30208
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
using namespace std;

void search(int a,int b,int &x,int &y){
    int c=a%b;
    if(c==0){x=0; y=1;}
    else{
        search(b,c,y,x);
        y-=a/b*x;
    }
}

int main(){
    int a,b,x,y;
    cin>>a>>b;
    search(a,b,x,y);
    cout<<x<<' '<<y<<endl;
    
    return 0;
}


Measured memory_bytes: 3092
from collections import deque
def bfs(graph, N, start):
    visited = [0] * N
    visited[start] = 1
    que = deque([start])
    while que:
        node = que.popleft()
        for n in graph[node]:
            if not visited[n]:
                visited[n] = node + 1
                que.append(n)
    return visited

N, M = map(int, input().split())
graph = [[] for _ in range(N)]
for _ in range(M):
    a, b = map(lambda n: int(n) - 1, input().split())
    graph[a].append(b)
    graph[b].append(a)
visited = bfs(graph, N, 0)[1:]
if all(visited):
    print("Yes")
    print(*visited, sep="\n")
else:
    print("No")


Measured memory_bytes: 38592
n = int(input())
S = input().strip()
r, g, b = map(S.count, 'RGB')
t = 0
for i in range(n-2):
    for w in range(1, (n-i+1) // 2):
        t += len({S[i], S[i+w], S[i+2*w]}) == 3
print(r*g*b - t)

Measured memory_bytes: 9200
#include <cstdio>
#include <utility>
#include <map>
#include <string>
using namespace std;

#define gcu getchar_unlocked
#define pcu putchar_unlocked
#define _T template <typename T>
#define _HT template <typename H, typename... T>
#define _il inline
#define _in _il int in
#define _sc _il bool scan
_T T in(int c){T n=0;bool m=false;if(c=='-')m=true,c=gcu();
	do{n=10*n+(c-'0'),c=gcu();}while(c>='0');return m?-n:n;} //&&c<='9'
_in() {return in<int>(gcu());}
_T T scan(T &n){int c=gcu();return c==EOF?false:(n=in<T>(c),true);}
_sc(char &c){c=gcu();gcu();return c!=EOF;}
_sc(string &s){int c;s="";
	for(;;){c=gcu();if(c=='\n'||c==' ')return true;else if(c==EOF)return false;s+=c;}}
_HT _sc(H &h, T&&... t){return scan(h)&&scan(t...);}
#define _vo _il void out
#define _vl _il void outl
_vo(const char *s){while(*s)pcu(*s++);}
_vo(char c){pcu(c);}
//_vo(string &s){for(char c:s)pcu(c);}
_vo(string s){for(char c:s)pcu(c);}
_T _vo(T n){static char buf[20];char *p=buf;
	if(n<0)pcu('-'),n*=-1;if(!n)*p++='0';else while(n)*p++=n%10+'0',n/=10;
	while (p!=buf)pcu(*--p);}
_vl(){out('\n');}
//_T _vo(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);outl();}
_HT _vo(H&& h, T&&... t){out(h);out(move(t)...);}
template <typename... T> _vl(T&&... t){out(move(t)...);outl();}

int main() {
	multimap<string, int> m;
	string k;
	for (int i = in(); i; i--) {
		int o = in();
		scan(k);
		switch(o) {
		case 0:
			m.insert({k, in()});
			break;
		case 1:
			for (auto i = m.equal_range(k); i.first != i.second; i.first++)
				outl(i.first->second);
			break;
		case 2:
			m.erase(k);
			break;
		case 3:
			{
				string s;
				scan(s);
				for (auto i = m.lower_bound(k), e = m.upper_bound(s); i != e; i++)
					outl(i->first, ' ', i->second);
			}
		}
	}
}


Measured memory_bytes: 24312
#include <cmath>
#include <iostream>
#include <string>

using namespace std;

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

	string S;
	cin >> S;

	char luck[3];
	int result = 0;
	for(int s = 0; s <= 999; s++) {
		for(int i = 0; i < 3; i++) {
			luck[i] = to_string(s / (int)pow(10, 2 - i) % 10)[0];
		}

		int index = 0;
		bool existed = false;
		for(const auto &c : S) {
			if(luck[index] == c) {
				index++;
				if(index == 3) {
					existed = true;
					break;
				}
			}
		}

		if(existed) {
			result++;
		}
	}

	cout << result << endl;

	return 0;
}


Measured memory_bytes: 256
int main(){
    int N,M;
    scanf("%d%d",&N,&M);
    int *num=malloc(sizeof(int)*N);
    int j,k;
    for(int i=0;i<N;i++)num[i]=0;
    for(int i=0;i<M;i++){
        scanf("%d%d",&j,&k);
        num[j-1]++;
        num[k-1]++;
    }
    for(int i=0;i<N;i++)
        printf("%d\n",num[i]);
    return 0;
}


Measured memory_bytes: 128
#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;
    cin >> n;
    vector<int> z(100010,0);
    for(int i = 0; i < n; i++){
        int a; cin >> a;
        z[a]++,z[a+3]--;
    }

    for(int i = 1; i < z.size(); i++) z[i] += z[i-1];

    int ans = 0;
    for(int i = 0; i < z.size(); i++) ans = max(ans,z[i]);

    cout << ans << endl;

    return 0;
}

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

int main() {
    string S, T;
    cin >> S >> T;

    int sum = 0;
    for (int i = 0; i < S.size(); i++) {
        if (S[i] != T[i]) sum++;
    }
    cout << sum << endl;
    return 0;
}


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

#define  int        long long int
 #define    sp(x)                 setprecision(x)
#define    bp(x)           __builtin_popcount(x)
 #define  ld         long double
 #define  f(i,j,n)            for(int i = j; i <= n; i++)
#define  r(i,n,j)       for(int i = n; i >= j; i--)
 #define  all(container)       container.begin() , container.end()
#define  sz(container)   (int)container.size()
 #define  ff             first
#define  ss             second
 #define  pii      pair <int , int>
#define  sp(x)       setprecision(x)
 #define  endl    "\n"
#define  mod  1000000007
 #define  pb    push_back
#define  mp    make_pair
 #define  T     int ttt; cin >> ttt; while(ttt--)
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);

int power(int x, int y, int p)  
{  
    int res = 1;    
    x = x % p; 
    if (x == 0) return 0; 
    while (y > 0)  
    {     
        if (y & 1)  
            res = (res*x) % p;  
        y = y>>1; 
        x = (x*x) % p;  
    }  
    return res; 
}

int32_t main()
{
    fast
    string s,t;
    int ans=0;
    cin>>s>>t;
    f(i,0,sz(s)-1)
        if(s[i]!=t[i])
            ans++;
    cout<<ans;
}

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

int main(){
   int n,m;
   scanf("%d%d",&n,&m);
   priority_queue<int> pq;
   int a; 
  for(int i=0;i<n;i++){
     scanf("%d",&a);
     pq.push(a);
   }
  while(m>0){
    int gg=pq.top();
    pq.pop();
    if(!gg)
       break;
    gg=gg/2;
    pq.push(gg);
    m=m-1;
  }
  long long sum=0;
  while(!pq.empty()){
    sum=sum+pq.top();
    pq.pop();
  }
  printf("%lld",sum);
}
    


Measured memory_bytes: 892
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  ll W, N; cin >> N >> W;
  vector<vector<ll>> dp(N + 1, vector<ll> (100001,10000000000));
  dp[0][0] = 0;
  for(ll i = 1; i <= N; i++) {
    ll w, v; cin >> w >> v;
    for(ll j = 0; j <= 100000; j++) {
      dp[i][j] = dp[i - 1][j];
      if(j - v < 0) continue;
      dp[i][j] = min(dp[i - 1][j - v] + w, dp[i][j]);
    }
  }
  for(ll i = 100000; i >= 0; i--) {
    if(dp[N][i] <= W) {
        cout << i << endl;
        return 0;
    }
  }
}


Measured memory_bytes: 80256
#pragma once
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <deque>
#include <numeric>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 10e9;

int t[100010];
void WriteandErase() {
	int n;
	cin >> n;
	int sum = 0;
	map<int, bool> m;
	
	
	for (size_t i = 0; i < n; i++)
	{
		int a;
		cin >> a;
		m[a] = !m[a];
		sum += (m[a] ? 1 : -1);
	}
	cout << sum << endl;
}

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



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

int main(){
string x;
  string a;
  a = "No";
  cin >> x;
  if(x.at(2) == x.at(3)){
  if(x.at(4)==x.at(5)){
  a = "Yes";
  }

  }

cout << a;

}

Measured memory_bytes: 256
a,b,k=map(int,input().split())
line=[]
for i in range(a,a+k):
    if i>b:break
    else:
        if i not in line:
            line.append(i)

for i in range(b,b-k,-1):
    if i<a:break
    else:
        if i not in line:
            line.append(i)

for i in sorted(line):
    print(i)

Measured memory_bytes: 38384
# coding: utf-8
case=int(input())
results=[input() for i in range(case)]

numAC=results.count('AC')
numWA=results.count('WA')
numTLE=results.count('TLE')
numRE=results.count('RE')

print('AC x ' + str(numAC))
print('WA x ' + str(numWA))
print('TLE x ' + str(numTLE))
print('RE x ' + str(numRE))

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

#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define lfs <<fixed<<setprecision(10)<<
#define test cout<<"test"<<endl;
#define fi first
#define se second
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define rep(i,n,m) for(ll i = n; i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = n - 1; i >= (ll)(m); i--)
typedef long long ll;
typedef long double ld;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T>
void chmin(T &a,T b){if(a>b)a=b;}
template<typename T>
void chmax(T &a,T b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void pmod(ll &a,ll b,ll c){a=(b+c)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void qmod(ll &a,ll b,ll c){a=(b*c)%MOD;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>
void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
template<typename T>
void debug(vector<vector<T>>v,ll h,ll w){for(ll i=0;i<h;i++)
{cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>
void debug(vector<T>v,ll n){cout<<v[0];
for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>
vector<vector<T>>vec(ll x, ll y, T w){
  vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
template<typename T>
void emp(map<T,ll>&m, T x){m.emplace(x,0).first->second++;}
vector<ll>dx={1,0,-1,0,1,1,-1,-1};
vector<ll>dy={0,1,0,-1,1,-1,1,-1};

int main(){
  cin.tie(NULL);
  ios_base::sync_with_stdio(false);
  ll res=0,res1=INF,res2=-INF,buf=0;
  bool judge = true;
  string s;cin>>s;
  rep(i,0,s.size()){
    if(i%2==0&&s[i]=='L')judge=false;
    if(i%2==1&&s[i]=='R')judge=false;
  }
  ans1(judge);
  return 0;
}

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

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    vector<ll>v(n+1);
    for(int i = 1; i <= n; i++)
    {
        for(int k = i; k <= n; k += i)
        {
            v[k]++;
        }
    }
    ll sum = 0;
    for(int i = 0; i <= n; i++)
    {
        sum += (1LL*i*v[i]);
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 81344
#include<iostream>
#include<cstdlib>
#include<string>
#include<map>
#include<algorithm>
#include<vector>
#include<cmath>
#include<iomanip>
#define rep(i,n) for(int i(0);i<n;i++)
const int INF = 1001001001;

using namespace std;
int main(){
	int r;
	cin >> r;
	cout << r*r << endl;
    return 0;
}


Measured memory_bytes: 256
package main

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

var N int

func main() {
	fmt.Scan(&N)
	A := make(SortBy, N)

	reader := bufio.NewScanner(os.Stdin)
	reader.Split(bufio.ScanWords)

	for i := 0; i < N; i++ {
		A[i] = make([]int, 2)

		reader.Scan()
		A[i][0], _ = strconv.Atoi(reader.Text())
		reader.Scan()
		A[i][1], _ = strconv.Atoi(reader.Text())

	}
	sort.Sort(A)
	var time int
	for i := 0; i < N; i++ {
		x, y := A[i][0], A[i][1]

		time += x
		if y < time {
			fmt.Println("No")
			return
		}
	}
	fmt.Println("Yes")
}

/*  ----------------------------------------  */

func gcd(x, y uint64) uint64 {
	if x%y == 0 {
		return y
	} else {
		r := x % y
		return gcd(y, r)
	}
}

func combination(x, y int) int {
	return permutation(x, y) / permutation(y, y)
}

func permutation(x, y int) int {
	var ans int = 1
	for i := x - y; 0 < i; i-- {
		ans *= i
	}
	return ans
}

func max(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Max(float64(x[i]), float64(res)))
	}
	return res
}

func min(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Min(float64(x[i]), float64(res)))
	}
	return res
}
func pow(x, y int) int { return int(math.Pow(float64(x), float64(y))) }
func abs(x int) int    { return int(math.Abs(float64(x))) }
func floor(x int) int  { return int(math.Floor(float64(x))) }

type XY struct {
	x int
	y int
}

type SortBy [][]int

func (a SortBy) Len() int      { return len(a) }
func (a SortBy) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
func (a SortBy) Less(i, j int) bool {
	return a[i][1] < a[j][1]
}


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

template<typename T> struct Mod {
  vector<T> fact, factInv;
  Mod() {}
  Mod(T n, T p = 1e9 + 7) : fact(n + 1), factInv(n + 1) {
    fact[0] = 1;
    for (T i = 1; i < n + 1; ++i) fact[i] = fact[i - 1] * i % p;
    for (T i = 0; i < n + 1; ++i) factInv[i] = modPow(fact[i], p - 2, p);
  }
  T modPow(T x, T n, T m) {
    if (n == 0) return 1;
    T res = modPow(x * x % m, n / 2, m);
    if (n & 1) res = res * x % m;
    return res;
  }
  T modComb(T n, T k, T p = 1e9 + 7) {
    return ((fact[n] * factInv[k]) % p * factInv[n - k]) % p;
  }
};

const ll MOD = 1e9 + 7;

int main() {
  int m, n; cin >> m >> n;
  Mod<ll> md;
  cout << md.modPow(m, n, MOD) << endl;
  return 0;
}



Measured memory_bytes: 3104
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

using ll = long long;
using ull = uint64_t;
using P = pair<int, int>;
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

template<class T>
inline bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}
template<class T>
inline bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

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

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

    for(;;){
        int w, h;
        cin >> w >> h;
        if(w == 0 && h == 0)    return 0;

        // 壁を扱いやすくするために大きさ 0 のマスを導入する。
        // 盤面の大きさは、おおよそ 2 倍になる。
        int W = 2 * w - 1, H = 2 * h - 1;
        vector<vector<int>> a(H, vector<int>(W, 0));
        for(int i = 0; i < H; ++i){
            for(int j = 0; j < w - (i % 2 == 0); ++j){
                cin >> a[i][j * 2 + (i % 2 == 0)];
            }
        }

        vector<vector<int>> dist(H, vector<int>(W, INF));
        queue<P> que;
        dist[0][0] = 1;
        que.emplace(0, 0);
        while(!que.empty()){
            int x = que.front().first, y = que.front().second;
            que.pop();
            // 長さ 0 を示す (x % 2) と (y % 2) は排反になるように操作する
            int lb, ub, cost = 0;
            if(x % 2)   lb = 0, ub = 2;
            else if(y % 2)  lb = 2, ub = 4;
            else    lb = 0, ub = 4, cost = 1;
            for(int i = lb; i < ub; ++i){
                int nx = x + dx[i], ny = y + dy[i];
                if(nx < 0 || nx >= H || ny < 0 || ny >= W)  continue;
                if(a[nx][ny])   continue;
                if(chmin(dist[nx][ny], dist[x][y] + cost)){
                    que.emplace(nx, ny);
                }
            }
        }

        if(dist[H - 1][W - 1] == INF)   dist[H - 1][W - 1] = 0;
        cout << dist[H - 1][W - 1] << '\n';
    }
}


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

typedef long long ll;

int main() {
	int H, W;
	cin >> H >> W;
	vector<vector<string> > S(H, vector<string>(W));
	string ans;
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			cin >> S[i][j];
			if (S[i][j] == "snuke") {
				char ch = 'A'+j;
				ans = ch+to_string(i+1);
			}
		}
	}

	cout << ans << endl;

}

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

int main(){
    
    long long int q,h,s,d;
    cin >> q >> h >> s >> d;
    int n;
    cin >> n;

    long long int price;
    price=min(min(4*q,2*h),s);

    if(n%2){
        price=(n-1)*min(2*price,d)/2+price;
    }
    else{
        price=n*min(2*price,d)/2;
    }

    cout << price << endl;
}

Measured memory_bytes: 3624
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <deque>

#define AS(a) (sizeof(a)/sizeof(a[0]))
using namespace std;
long long int MOD = 1000000007;

int main() {
  int sx,sy,tx,ty;
  cin >> sx >> sy >> tx >> ty;
  int dx = tx - sx;
  int dy = ty - sy;
  for(int i = 0; i < dy; i++) {
    cout << "U";
  }
  for(int i = 0; i < dx; i++) {
    cout << "R";
  }
  for(int i = 0; i < dy; i++) {
    cout << "D";
  }
  for(int i = 0; i < dx; i++) {
    cout << "L";
  }
  cout << "L";
  for(int i = 0; i < dy+1; i++) {
    cout << "U";
  }
  for(int i = 0; i < dx+1; i++) {
    cout << "R";
  }
  cout << "D";
  cout << "R";
  for(int i = 0; i < dy+1; i++) {
    cout << "D";
  }
  for(int i = 0; i < dx+1; i++) {
    cout << "L";
  }
  cout << "U";
  cout << endl;




}


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

public class Main {
	static FastReader f = new FastReader();
	static PrintWriter out = new PrintWriter(System.out);

	public static void main(String[] args) {
		solve();
		out.close();
	}

	static void solve() {
		int n = f.nextInt();
		int[] arr = new int[n];
		for(int i=0;i<n;i++) {
			arr[i] = f.nextInt();
		}

		ArrayList<Integer> primes = new ArrayList<>();
 		boolean[] bol = new boolean[1000];
 		for(int i=2;i<1000;i++) {
 			if(!bol[i]) {
 				for(int j=i+i;j<1000;j+=i) {
 					bol[j] = true;
 				}
 			}
 		}

 		for(int i=2;i<1000;i++) {
 			if(!bol[i]) {
 				primes.add(i);
 			}
 		}

 		boolean[] vis = new boolean[1000001];
 		long gcd = arr[0];
 		boolean pair = true;

 		for(int i=0;i<n;i++) {
 			gcd = calc_gcd(gcd, arr[i]);
 			if(pair) {
 				for(int j : primes) {
	 				if(arr[i] % j == 0) {
	 					if(vis[j]) {
	 						pair = false;
	 					}
	 					vis[j] = true;
	 					while(arr[i] % j == 0) {
	 						arr[i] /= j;
	 					}	
	 				}
	 				if(arr[i] == 1) {
	 					break;
	 				}
 				}
 				if(arr[i] != 1) {
 					if(vis[arr[i]]) {
 						pair = false;
 					}
 					vis[arr[i]] = true;
 				}
 			}
 		}

 		//out.println(gcd);
 		if(gcd == 1) {
 			if(pair) {
 				out.println("pairwise coprime");
 			} else {
 				out.println("setwise coprime");
 			}
 		} else {
 			out.println("not coprime");
 		}

 	}

 	static long calc_gcd(long a, long b) {
 		if(b == 0) {
 			return a;
 		}
 		return calc_gcd(b, a % b);
 	}
 

	static class FastReader {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st;

		String next() {
			while(st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch(IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		String nextLine() {
			String str = "";

			try {
				str = br.readLine();
			} catch(IOException e) {
				e.printStackTrace();
			}
			return str;
		}

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

		double nextDouble() {
			return Double.parseDouble(next());
		}

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

Measured memory_bytes: 76616
#include<iostream>

#include<algorithm>

#include<vector>

#include<queue>

#include<cstring>

#include<cmath>

#define LL  long long

#define MAXK    100010

#define P   1000000007

using namespace std;

int N, K;

LL cnt[MAXK];

LL ans = 0;

LL fastpw(LL base, LL power) {

	LL result = 1;	while(power>0) {

		if(power%2 == 1) {

			result = (result*base) %P;

		}

		power /= 2;

		base =(base*base) %P;

	}

	return result;

}

LL fastpw2(int base, int power) {

	LL result = 1;

	while(power>0) {

		if(power%2 == 0) {

			base = base * base % P;

			power /= 2;

		}else {

			power -= 1;

			result = result*base %P;

			power /= 2;

			base =base*base %P;

		}

	}

	return result;

}

int main()

{

    

    cin>>N>>K;

	cnt[K] = 1;

	ans = K;

    for(int i=K-1; i>=1; i--) {

        int t = K/i;

        cnt[i] = fastpw(t, N);

        //cnt[i] = pow(t, N);

        for(int j=i+i; j<=K; j+=i) {

            cnt[i] = cnt[i] + P - cnt[j];

            if(cnt[i]>=P) cnt[i]-=P;

        }

//        printf("%d %d\n", i, cnt[i]);

        ans += cnt[i]*i;

        ans %= P;

    }

    

  //  cout << fastpw(2, 1000)<<endl;

    cout << ans << endl;

    return 0;

}

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

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

    int n;
    cin>>n;

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

    long long sum=0;
    for(int i=2;i<=n;i++){
        if(a[i]<a[i-1]){
            sum+=a[i-1]-a[i];
            a[i]=a[i-1];
        }
    }

    cout<<sum<<"\n";

    return 0;
}

Measured memory_bytes: 3992
#include<iostream>
#include<vector>

using namespace std;
int main(){
    int n,i,k;
    int num=0;
    vector<int> a;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>k;
        a.push_back(k);
    }
    for(int i=0;i<n;i++){
        for(int j=n-1;j>=i+1;j--){
            if(a[j]<a[j-1]){
                num+=1;
                k=a[j];
                a[j]=a[j-1];
                a[j-1]=k;
            }
        }
    }
    for(int i=0;i<a.size();i++){
        if(i) cout<<' ';
        cout<<a[i];
    }
    cout<<endl<<num<<endl;
    return 0;
}



Measured memory_bytes: 3160
macro_rules! get {
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
            get!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
            get!($($t),*)
        ).collect::<Vec<_>>()
    };
}

fn main() {
    let mut ns = vec![false; 26];
    for c in get!(String).chars() {
        ns[(c as usize) - ('a' as usize)] = true;
    }
    for (i, f) in ns.into_iter().enumerate() {
        if !f {
            println!("{}", (('a' as u8) + (i as u8)) as char);
            return;
        }
    }
    println!("None");
}

Measured memory_bytes: 2208
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define INF 1e9
#define LLINF 1e12
#define PI 3.14159265359
int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
int ny, nx;
typedef long long ll;
using namespace std;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

ll lcm(ll m, ll n)
{
    if ((0 == m) || (0 == n))
        return 0;
    return ((m / gcd(m, n)) * n);
}

ll llpow(ll x, ll y)
{
    ll ans = 1;
    REP(i, y)
    ans *= x;
    return ans;
}

ll llmin(ll x, ll y) { return x < y ? x : y; }
ll llmax(ll x, ll y) { return x > y ? x : y; }

template <typename Container>
bool exist_in(const Container &c, const typename Container::value_type &v)
{
    return (c.end() != std::find(c.begin(), c.end(), v));
}

//std::cout << std::defaultfloat << std::setprecision(10);
////////////////////////////////////////
int main()
{
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);

    int h,n; cin >> h >> n;
    vector<int> a(n);
    REP(i,n) cin >> a[i];

    sort(a.begin(), a.end(), greater<int>());
    int ans=0;

    REP(i,n){
        ans+=a[i];
    }

    if(ans>=h) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 640
/*
    飲んだ魔剤で家が建つ。
    created at: 2020-04-12 12:35:15
*/

#include <bits/stdc++.h>
using namespace std;

#define all(x) (x).begin(),(x).end()
#define rev(x) greater<x>()
#define MOD 1000000007
#define INF 1000000000

typedef long long LL;
typedef long double LD;

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

LL modpower(LL n, LL m, LL mod)
{
    if (m == 0) {
        return 1;
    } else if (m % 2 == 0) {
        LL p = modpower(n, m/2, mod);
        return p*p % mod;
    } else {
        return n*modpower(n, m-1, mod) % mod;
    }
}

LL modinv(LL n, LL mod)
{
    return modpower(n, mod-2, mod);
}

LL modcombination(LL n, LL r, LL mod)
{
    LL ret = 1;

    for (int i = 0; i < r; i++) {
        ret *= (n-i);
        ret %= mod;
        ret *= modinv(i+1, mod);
        ret % mod;
    }

    return ret % mod;
}

int gcd(int k, int l)
{
    if (l > 0) return gcd(l, k%l);
    else return k;
}

struct UnionFind
{
    vector<int> par;

    UnionFind(int n) : par(n) {
        for (int i = 0; i < n; i++) par[i] = i;
    }

    int root(int x) {
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if (rx == ry) return;
        par[rx] = ry;
    }

    bool same(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main()
{
    int x, y, z;
    cin >> x >> y >> z;

    int ans = x / (y+z);
    if (x % (y+z) < z) ans--;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    char a,b;
    scanf("%c %c",&a,&b);
    if(a=='H' && b=='H')
    {
        printf("H");
    }
    else if(a=='D' && b=='D')
    {
        printf("H");
    }
    else if(a=='H' && b=='D')
    {
        printf("D");
    }
    else if(a=='D' && b=='H')
    {
        printf("D");
    }
    else if(a=='H' && b=='D')
    {
        printf("D");
    }
    return 0;
}

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

int main(){
	
	char a[21];
	int i = 0;

	scanf("%s", a);
	i = strlen(a);
	i--;
	while(i >= 0){
		printf("%c",a[i]);
		i--;
		
	}
	
	printf("\n");
	
    return 0;
}

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

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

typedef long long ll;
typedef long double ld;

const int INF = 1e9;
const ld EPS = 1e-8;

int main(){
  int N;
  cin >> N;
  vector<int> a(N);
  REP(i,N) cin >> a[i];

  int ret = 0;
  REP(i,N) {
    while(a[i] % 2 == 0) {
      ++ret;
      a[i] /= 2;
    }
  }

  cout << ret << endl;
  return 0;
}



Measured memory_bytes: 256
#include <iostream>

 

using namespace std;

 

int main() 
{
    int a, b, c, i, ans;
    cin >> a >> b >> c;
    ans = 0;
    for(i=a; i<=b; i++)
    {
        if(c % i == 0)
            ans ++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3096
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll dp[10005];
ll M[10]={2,5,5,4,5,6,3,7,6};
ll a[10];


int main(){
	ll n,m;
	cin>>n>>m;
	vector<ll> a(m);
	for(ll i=0;i<m;i++)cin>>a[i];
	fill(dp,dp+10005,-1);
	dp[0]=0;
	for(ll i=0;i<n;i++){
		if(dp[i]==-1)continue;
		for(ll j=0;j<m;j++){
			dp[M[a[j]-1]+i] = max(dp[M[a[j]-1]+i],dp[i]+1);
		}
	}
	//cout<<dp[n]<<endl;

	/*for(ll i=0;i<n;i++){
		cout<<dp[i]<<endl;
	}*/

	ll tmp=n;
	sort(a.begin(),a.end(),greater<ll>());
	  for(int i = 0; i < dp[n]; i++) {
	    for(int j = 0; j < m; j++) {
	      if(tmp - M[a[j]-1] < 0) continue;
	      if(dp[tmp - M[a[j]-1]] == dp[tmp] - 1) {
		//	cout << tmp << endl;
	    	  tmp -= M[a[j]-1];
	    	  cout << a[j];
	    	  break;
	      }
	    }
	  }
	  cout << endl;
}


Measured memory_bytes: 384
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;

//
#define int long long
#define pb(x) push_back(x)
#define m0(x) memset((x), 0, sizeof(x))
#define mm(x) memset((x), -1, sizeof(x))

//container
#define ALL(x) (x).begin(), (x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
#define PERM(c) \
  sort(ALL(c)); \
  for (bool c##p = 1; c##p; c##p = next_permutation(ALL(c)))

// debug
#define GET_VAR_NAME(variable) #variable
#define test(x) cout << GET_VAR_NAME(x) << " = " << x << endl;

// bit_macro
#define bit(n) (1LL << (n))
#define bitset(a, b) (a) |= (1 << (b))
#define bitunset(a, b) (a) &= ~(1 << (b))
#define bitcheck(a, b) ((((a) >> (b)) & 1) == 1)
#define bitcount(a) __builtin_popcountll((a))

//typedef
typedef long long lint;
typedef unsigned long long ull;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

//constant
const int INF = (int)1e18;
const int MOD = (int)1e9 + 7;
const double PI = (double)acos(-1);
const double EPS = (double)1e-10;
const int dx[] = {-1, 0, 0, 1, 0, -1, -1, 1, 1};
const int dy[] = {0, -1, 1, 0, 0, 1, -1, 1, -1};

//
template <typename T>
void chmax(T &a, T b) { a = max(a, b); }
template <typename T>
void chmin(T &a, T b) { a = min(a, b); }
//
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

//
struct Accelerate_Cin {
  Accelerate_Cin() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);
  };
};

int N, Q;
string s;
char d[202020], t[202020];

int C(int m) {
  int now = m;

  for (int i = 0; i < Q; i++) {
    if (now == 0 || now == N + 1) break;
    if (t[i] != s[now]) continue;

    if (d[i] == 'L') {
      now--;
    } else {
      now++;
    }
  }

  if (now == 0) return -1;
  if (now == N + 1) return 1;
  return 0;
}

signed main() {
  cin >> N >> Q >> s;
  s = " " + s;

  for (int i = 0; i < Q; i++) {
    cin >> t[i] >> d[i];
  }

  int sub = 0;

  int ok = 0, ng = N + 1;
  for (int i = 0; i < 30; i++) {
    int mid = (ok + ng) / 2;
    if (C(mid) == -1) {
      ok = mid;
    } else {
      ng = mid;
    }
  }

  sub += ok;

  ok = N + 1, ng = 0;
  for (int i = 0; i < 30; i++) {
    int mid = (ok + ng) / 2;
    if (C(mid) == 1) {
      ok = mid;
    } else {
      ng = mid;
    }
  }

  sub += N + 1 - ok;

  cout << N - sub << endl;
  return 0;
}


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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<int,int>;

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

  int A[3];
  for(int i=0;i<3;++i){
      std::cin >> A[i];
  }

  std::sort(A, A + 3);

  if(A[0] == A[1] && A[0] != A[2] ||
     A[1] == A[2] && A[0] != A[1]){
      std::cout << "Yes" << std::endl;
  }else{
      std::cout << "No" << std::endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<stdlib.h>
#include<string.h>
#define ll long long
#define T int test; scanf("%d",&test); while(test--)
#define pb push_back
#define in insert
#define sc(n) scanf("%d",&n)
#define sc2(a,b) scanf("%d%d",&a,&b)
#define sc3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define lsc(n) scanf("%lld",&n)
#define lsc2(a,b) scanf("%lld%lld",&a,&b)
#define rep(i,n) for(i=0;i<n;i++)
#define fr(i,a,b) for(i=a;i<=b;i++)
#define gcd(a,b) __gcd(a,b)
#define gcd3(a,b,c) __gcd(__gcd(a,b),c)
#define lcm(a,b) (a*b)/__gcd(a,b)
using namespace std;


int main()
{
	int n,i;
	sc(n);
	set<string>s;
	rep(i,n)
	{
		string ss;
		cin >> ss;
		s.in(ss);
	}
	cout << s.size() << endl;
    return 0;
}


Measured memory_bytes: 19284
package main

import (
        "fmt"
)

func solution(a, b, c, x, y int) int {
        out := 1 << 31

        for i := 0; i <= 1e5; i++ {
                out = min(out, i*2*c+max(0, x-i)*a+max(0, y-i)*b)
        }
        return out
}

func min(x, y int) int {
        if x < y {
                return x
        }
        return y
}
func max(x, y int) int {
        if x > y {
                return x
        }
        return y
}

func main() {
        var a, b, c, x, y int
        fmt.Scan(&a, &b, &c, &x, &y)
        fmt.Println(solution(a, b, c, x, y))
}

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

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

    vector<char> v;
    int happy = 0;
    int preb = 'N';

    for(int i = 0; i < n; ++i)
    {
        char t;
        cin >> t;
        if(preb == t)
        {
            ++happy;
        }
        else
        {
            v.push_back(t);
            preb = t;
        }
    }

    happy += min(k*2, (int)v.size()-1);

    cout << happy << endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll LOG2(ll x){
  ll count=0LL;
  while(x%2==0){
    count++;
    x/=2;
  }
  return count;;
}
int main(){
  vector<ll> vec(0);
  ll n,tmp;
  cin >> n;
  for(ll i=0LL;i<n;i++){
    cin >> tmp;
    vec.push_back(LOG2(tmp));
  }
  sort(vec.begin(),vec.end());
  cout << vec.at(0) << endl;
}

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

int main(){
    int n;
    cin >> n;
    vector<int> t(n+1);
    vector<int> x(n+1);
    vector<int> y(n+1);
    t[0] = 0;
    x[0] = 0;
    y[0] = 0;
    for ( int i = 1; i < n + 1; ++i ) {
        cin >> t[i] >> x[i] >> y[i];
    }
    rep(i, n) {
        if ( t[i+1] - t[i] < x[i+1] - x[i] + y[i+1] - y[i] ) {
            cout << "No" << endl;
            return 0;
        }
        else if ( ( t[i+1] - t[i] - ( x[i+1] - x[i] + y[i+1] - y[i] ) ) % 2 != 0 ) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 1408
N=int(input())
A=list(map(int,input().split()))
A.insert(0,0)
A.append(0)
x=0
for i in range(0,N+1):
    x+=abs(A[i+1]-A[i])
for i in range(1,N+1):
    print(x-abs(A[i]-A[i-1])-abs(A[i]-A[i+1])+abs(A[i+1]-A[i-1]))


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

long long A[51], P[51];

long long solve(int n, long long x) {
    if (x == 0) return 0;
    if (n == 0) return 1;
    if (1 + A[n-1] >= x) return solve(n-1, x-1);
    long long ans = P[n-1];
    x -= 1 + A[n-1];
    if (x == 0) return ans;
    ans++; x--;
    ans += solve(n-1, x);
    return ans;
}

int main(int argc, char** argv) {
    long long n, x; cin >> n >> x;
    A[0] = 1; P[0] = 1;
    for (int i = 1; i <= n; i++) {
        A[i] = 3 + 2 * A[i-1];
        P[i] = 1 + 2 * P[i-1];
    }
    cout << solve(n, x) << endl;
}


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

int main()
{
    int n,ans;

    cin >> n;
    vector<int> p(n);
    rep(i, n) cin >> p[i];

    int m = p[0];
    ans = 1;
    for (int i = 1;i < n;++i) {
        if (p[i] <= m) {
            m = p[i];
            ++ans;
        }
    }

    //結果
    std::cout << ans << endl;
}


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

using namespace std;


int a[1000*1001];

int main(){
	int n,m;
	int i,j,k;
	int *p;
	int r,rr;

	while(true){

		//memset(a,0,sizeof(a));
		scanf("%d%d",&n,&m);
		if(n==0&&m==0) break;

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

		k=n;
		for(i=0;i<n;i++){
			for(j=i;j<n;j++){
				a[k++]=a[i]+a[j];
				}
		}
		sort(a,a+n*(n+1)/2+n);

	/*
		for(i=0;i<n*(n+1)/2+n;i++){
			printf("%d\n",a[i]);
		}
		*/
		rr=0;
		for(i=0;i<n*(n+1)/2+n;i++){
			p=lower_bound(a+i,a+n*(n+1)/2+n,m-a[i]);
			r=*(p-1)+a[i];
			if((*(p-1)<=m-a[i])&&(r>rr)) rr=r;
			}

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

		}

	return 0;
	}

Measured memory_bytes: 3000
/*
	Author: Kuldeep
	Date Time:
	Description:
*/
#include <stdio.h>
#include <stdlib.h>
#include<string.h>
#include<math.h>
#include<limits.h>
#include<ctype.h>

typedef long long ll;
#define Min(a,b) (((a)<(b))?(a):(b))
#define Max(a,b) (((a)>(b))?(a):(b))

int main()
{
	float a,b;
	int n, result;
	scanf("%f%f%d",&a,&b,&n);
	result = (floor(b/n)-ceil(a/n));
	printf("%d\n",result + 1);	
	return 0;
}


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

typedef vector<int> vi;

#define LP(_i,len) for(int _i=0;_i<len;++_i)
#define LP2(_i,_l,len) for(int _i=0,_l=len;_i<_l;++_i)
#define VLP(v,_itr,_end) for(auto _itr=v.begin(),_end=v.end();_itr!=_end;++_itr)
#define VCLP(v,_itr,_end) for(auto _itr=v.cbegin(),_end=v.cend();_itr!=_end;++_itr)

int abs(int x, int y) {
	return x >= 0 ? x : -x;
}

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

	vi h(N);
	VLP(h,itr,end)
		cin >> *itr;
	vi dps(N);
	LP(i,N)
	{
		if (i == 0) {
			dps[0] = 0;
			continue;
		}
		if (i == 1) {
			dps[1] = abs(h[0] - h[1]);
			continue;
		}
		int dp_1 = dps[i - 1] + abs(h[i - 1] - h[i]), dp_2 = dps[i - 2]
				+ abs(h[i - 2] - h[i]);
		dps[i] = dp_1 > dp_2 ? dp_2 : dp_1;
	}
	cout << dps[N - 1] << endl;
	return 0;
}

Measured memory_bytes: 3676
#include <iostream>

using namespace std;

int main(int argc, char *argv[])
{
	string L;
	int mod = 1000000007;
	int dp[100005][2] = {{0}};

	cin >> L;
	int s = L.size();
	dp[0][0] = 1;
	for (int i = 0; i < s; i++) {
		if (L[i] == '0') {
			dp[i + 1][0] = dp[i][0];
			dp[i + 1][1] = dp[i][1];
		} else {
			dp[i + 1][1] = (dp[i][0] + dp[i][1]) % mod;
		}

		if (L[i] == '0') {
			dp[i + 1][1] += (2 * dp[i][1]) % mod;
			dp[i + 1][1] %= mod;
		} else {
			dp[i + 1][0] += (2 * dp[i][0]) % mod;
			dp[i + 1][0] %= mod;
			dp[i + 1][1] += (2 * dp[i][1]) % mod;
			dp[i + 1][1] %= mod;
		}
	}
	cout << (dp[s][0] + dp[s][1]) % mod << "\n";
	return 0;
}

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

int main()
{
    string s, t;
    cin >> s >> t;
    int ans = 1e9;
    rep(i, s.size() - t.size() + 1)
    {
        int cnt = 0;
        rep(j, t.size())
        {
            if (s[i + j] != t[j])
                cnt++;
        }
        ans = min(ans, cnt);
    }
    cout << ans << endl;
}


Measured memory_bytes: 3636
//https://atcoder.jp/contests/agc005/tasks/agc005_b
#include <bits/stdc++.h>
using namespace std;
using ll=int64_t;
#define FOR(i,a,b) for(int64_t i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
int main() {
#if LOCAL&01
    std::ifstream in("./test/sample-1.in"); //input.txt
    std::cin.rdbuf(in.rdbuf());
#endif
//    cin.tie(0);
//    ios::sync_with_stdio(false);
    ll N; cin>>N;
    vector<ll> an(N+1);
    vector<ll> pos(N+1); //aの場所
    FOR(i,1,N+1){
        ll a; cin>>a;
        an.at(i) = a;
        pos.at(a) = i;
    }

    set<ll> tbl{0,N+1}; //小さい順
    // for(auto it=tbl.begin(); it != tbl.end();++it){
    //     cout<<*it<<endl;
    // }
    ll ans=0;
    FOR(v,1,N+1){ //小さい値から
        auto p = pos.at(v);
        auto it = tbl.lower_bound(p);
        auto r = *it;
        auto l = *(--it);
        ans += v * (r-p) * (p-l);

        tbl.insert(p);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 12800
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <map>
#include <iomanip>
#include <math.h> 
#include <stack>
#include <queue>
#include <bitset>

using namespace std;

int main() {
	int i, j, k;
	int a, b;

	cin >> a >> b;

	int maxn = max(a + b, a - b);
	maxn = max(maxn, a*b);

	cout << maxn << endl;













	getchar();
	getchar();
	return 0;
}

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

const int INF = 1000000007;
vector<string> G;
vector<vector<int>> dp;

int main() {
  int H, W; cin >> H >> W;
  G.resize(H);
  dp = vector<vector<int>>(H, vector<int>(W, INF));
  for (int i = 0; i < H; i++) cin >> G.at(i);
  if (G.at(0).at(0) == '#') dp.at(0).at(0) = 1;
  else dp.at(0).at(0) = 0;
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      if (G.at(i).at(j) == '.') {
        if (i-1 >= 0) {
          dp.at(i).at(j) = min(dp.at(i).at(j), dp.at(i-1).at(j));
        }
        if (j-1 >= 0) {
          dp.at(i).at(j) = min(dp.at(i).at(j), dp.at(i).at(j-1));
        }
      }
      else {
        if (i-1 >= 0) {
          if (G.at(i-1).at(j) == '#') dp.at(i).at(j) = min(dp.at(i).at(j), dp.at(i-1).at(j));
          else dp.at(i).at(j) = min(dp.at(i).at(j), dp.at(i-1).at(j) + 1);
        }
        if (j-1 >= 0) {
          if (G.at(i).at(j-1) == '#') dp.at(i).at(j) = min(dp.at(i).at(j), dp.at(i).at(j-1));
          else dp.at(i).at(j) = min(dp.at(i).at(j), dp.at(i).at(j-1) + 1);
        }
      }
    }
  }
  cout << dp.at(H-1).at(W-1) << endl;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var n, m, x int
	fmt.Scan(&n, &m, &x)
	c1, c2 := 0, 0
	var a int
	for i := 0; i < m; i++ {
		fmt.Scan(&a)
		if a < x {
			c1++
		} else {
			c2++
		}
	}
	ans := min(c1, c2)
	fmt.Println(ans)
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}


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

int dp[100008];
vector<int>graph[100005];
int n;

int dfs(int u)
{
    if(dp[u]!=-1) return dp[u];

    int ret = 0;
    for(int i=0;i<graph[u].size();i++)
    {
        ret = max(ret, 1+dfs(graph[u][i]));
    }

    return dp[u] = ret;
}

int main()
{
    int m;
    cin>>n>>m;
    for(int i=0;i<m;i++)
    {
        int x, y;
        cin>>x>>y;
        x--, y--;
        graph[x].push_back(y);
    }

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

    int ans = 0;
    for(int i=0;i<n;i++)
    {
        ans = max(ans, dfs(i));
    }

    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 11404
#include <bits/stdc++.h>
using namespace std;
int a[510][510],c[250250][4];
int h,w;
int main()
{
cin>>h>>w;
for(int i=1;i<=h;i++)
{
for(int j=1;j<=w;j++)
{
cin>>a[i][j];
}
}
int ans=0;
for(int i=1;i<=h;i++)
{
for(int j=1;j<w;j++)
{
if(a[i][j]%2==1)
{ ans++;
c[ans][0]=i; c[ans][1]=j;
c[ans][2]=i; c[ans][3]=j+1;
a[i][j+1]++;a[i][j]--;
}
}
}
for(int i=1;i<=h-1;i++)
{
if(a[i][w]%2==1)
{ ans++;
c[ans][0]=i; c[ans][1]=w;
c[ans][2]=i+1;c[ans][3]=w;
a[i+1][w]++; a[i][w]--;
}
}
cout<<ans<<endl;
for(int i=1;i<=ans;i++)
cout<<c[i][0]<<" "<<c[i][1]<<" "<<c[i][2]<<" "<<c[i][3]<<endl;
return 0;
}

Measured memory_bytes: 6912