akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
// typedef __int128_t Int;
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF =
    sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(12);

  int N;
  cin >> N;
  vector<vector<int>> dp(1 << N, vector<int>(2));
  rep(i, 0, 1 << N) { cin >> dp[i][0]; }

  rep(i, 0, N) rrep(bits, 0, 1 << N) {
    if (bits >> i & 1) {
      vector<int> tmp;
      tmp.insert(tmp.end(), all(dp[bits]));
      tmp.insert(tmp.end(), all(dp[bits ^ (1 << i)]));
      sort(all(tmp));
      dp[bits][0] = tmp[3];
      dp[bits][1] = tmp[2];
    }
  }

  int ans = -INF;
  rep(k, 1, 1 << N) {
    chmax(ans, dp[k][0] + dp[k][1]);
    cout << ans << endl;
  }

  return 0;
}


Measured memory_bytes: 17408
/* package codechef; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		// your code goes here
		Scanner s=new Scanner(System.in);
		int n=s.nextInt();
		int a[]=new int[n];
		for(int i=0;i<n;i++)
		{
		    a[i]=s.nextInt();
		}
		
		int dp[]=new int[n];
		dp[0]=0;
		dp[1]=Math.abs(a[0]-a[1]);
		for(int i=2;i<n;i++)
		{
		    dp[i]=Math.min(Math.abs(a[i]-a[i-1])+dp[i-1],Math.abs(a[i]-a[i-2])+dp[i-2]);
		}
		System.out.println(dp[n-1]);
	}
}


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

int main() {
  char c;	
  cin >> c;
  
  // ここにプログラムを追記
  if (c=='a' ||
      c=='i' ||
      c=='u' ||
      c=='e' ||
      c=='o') {
    cout << "vowel" << endl;
  }
  else {
    cout << "consonant" << endl;
  }
  
  //cout << sum << endl;
}


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

using namespace std;

const int N = 200010;

int n, k;
int a[N];

int main()
{
	ios::sync_with_stdio(false), cin.tie(0);
	
	cin >> n >> k;
	for (int i = 1; i <= n; ++i) cin >> a[i];
	
	for (int i = k + 1, j = 1; i <= n; ++i, ++j)
	{
		if (a[i] > a[j]) cout << "Yes\n";
		else cout << "No\n";
	}
	
	return 0;
}

Measured memory_bytes: 4396
#include<stdio.h>

#define MAX 8
#define FREE -1
#define ATACK 1
#define TRUE 100
#define FALSE -100

int row[MAX],col[MAX],dpos[2*MAX-1],dneg[2*MAX-1];
int CHESS[MAX][MAX];

void init(){
  int i;

  for(i = 0; i < MAX; i++)row[i] = col[i] = FREE;
  for(i = 0; i < 2*MAX-1; i++)dpos[i] = dneg[i] = FREE;
  
}

void printBoard(){
  int i,j;

  for(i = 0; i < MAX; i++){
    for(j = 0; j < MAX; j++){
      if(CHESS[i][j] == TRUE){
        if(row[i] != j)return;
      }
    }
  }
  for(i = 0; i < MAX; i++){
    for(j = 0; j < MAX; j++){
      if(row[i] == j)printf("Q");
      else printf(".");
    }
    printf("\n");
  }
}

void putQueen(int i){
  int j;
  
  if(i == MAX){
    printBoard();
    return;
  }

  for(j = 0; j < MAX; j++){
    if(col[j] == ATACK || dpos[i+j] == ATACK || dneg[i-j+MAX-1] == ATACK)continue;
    //put a queen at (i,j)
    row[i] = j;
    col[j] = dpos[i+j] = dneg[i-j+MAX-1] = ATACK;
    //CHESS[i][j] = TRUE;
    //try the next row
    putQueen(i+1);
    //remove the queen at (i,j)
    col[j] = dpos[i+j] = dneg[i-j+MAX-1] = FREE;
    //CHESS[i][j] = FALSE;
  }
  
}

int main(){
  int i,j,k,r,c;

  init();
  for(i = 0; i < MAX; i++){
    for(j = 0; j < MAX; j++)CHESS[i][j] = FALSE;
  }

  scanf("%d",&k);

  for(i = 0; i < k; i++){
    scanf("%d %d",&r,&c);
    CHESS[r][c] = TRUE;
       
  }

  putQueen(0);
  
  return 0;
}




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

using namespace std;

using ll = long long;
constexpr int mo = 1e9+7;
constexpr int inf = 1<<30;
constexpr ll infl = 1ll<<60;

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    int h,n;
    cin>>h>>n;
    vector<pair<int,int>> ab(n);
    for(auto &a : ab)cin>>a.first >> a.second;
    vector<int> from(10050,inf);
    from[0] = 0;
    for(int i=0;i<n;++i){
        for(int j=0;j<=10050;++j){
            if(j+ab[i].first < 10050)from[j+ab[i].first] = min(from[j+ab[i].first],from[j] + ab[i].second); 
        }
    }
    int ret = inf;
    for(int i=h;i<10050;++i)if(ret > from[i]) ret = from[i];
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 256
sum,yen = gets.chomp.split(" ").map(&:to_i)
ans10000 = -1
ans5000 = -1
ans1000 = -1
0.upto(sum) do |x|
  0.upto(sum-x) do |y|
    z = sum - x - y
    sum_yen = (x*10000)+(y*5000)+(z*1000)
    if sum_yen == yen
      ans10000 = x
      ans5000 = y
      ans1000 = z
      break
    end
  end
end
puts "#{ans10000} #{ans5000} #{ans1000}"





Measured memory_bytes: 1788
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();

        ArrayList<ArrayList<Integer>> cave = new ArrayList<>();
        //i番目の部屋は(i-1])に対応

        for (int i = 0; i < n; i++) {
            //Listを作って代入、だと上手くいかないので先に空のListをN個入れておく
            cave.add(new ArrayList<Integer>());
        }

        for (int i = 0; i < m; i++) {
            int a = sc.nextInt();
            int b = sc.nextInt();

            cave.get(a - 1).add(b - 1);//caveのa-1番目の要素にb-1というintを代入
            cave.get(b - 1).add(a - 1);
        }

        int[] dist = new int[n];
        for (int i = 0; i < n; i++) {
            dist[i] = -1;//全部屋見つかってない状態に初期化
        }

        LinkedList<Integer> queue = new LinkedList<>();
        queue.add(0);//まず1番目の部屋番号をキューに入れる

        int a = 0;
        while (!queue.isEmpty()) {
            int num = queue.pollLast();//キューの一番下の値をget
            for (int k : cave.get(num)) {//そのキューに繋がってる部屋番号でfor文回す
                if (dist[k] == -1) {//部屋にまだ行ってなかった場合の処理
                    queue.addFirst(k);//その番号をキューの一番上に代入
                    dist[k] = num + 1;//看板を立てる
                }
            }
        }



        System.out.println("Yes");
                for(int i = 1 ; i < n ; i++){
        System.out.println(dist[i]);
        }
    }
}


Measured memory_bytes: 77324
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/adaptor/indexed.hpp>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)
#define ALL(x) begin(x),end(x)

using namespace std;
using namespace boost::adaptors;
using namespace std::string_literals;
using ll = int64_t;
using vecint = vector<int>;
using vecll = vector<ll>;
using boost::irange;

constexpr ll MOD = 998244353;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll n;
  cin>>n;
  vecll a(n);
  for(auto&& e:a) cin>>e;
  int m = n*300+1;
  vecll dp1(m);
  vecll dp2(m);
  dp1[0] = 1;
  dp2[0] = 1;
  REP(i,n) {
    vecll tmp1(m);
    vecll tmp2(m);
    REP(j,m) {
      tmp1[j] += dp1[j];
      tmp1[j] %= MOD;
      tmp2[j] += 2*dp2[j];
      tmp2[j] %= MOD;
      if (j+a[i] < m) {
        tmp1[j+a[i]] += dp1[j];
        tmp1[j+a[i]] %= MOD;
        tmp2[j+a[i]] += dp2[j];
        tmp2[j+a[i]] %= MOD;
      }
    }
    swap(dp1, tmp1);
    swap(dp2, tmp2);
  }
  int sum = accumulate(ALL(a),0);
  ll ans = 0;
  FOR(i,(sum+1)/2,sum+1) {
    ans += dp2[i];
    ans %= MOD;
  }
  if (sum % 2 == 0) {
    ans += MOD - dp1[sum/2];
    ans %= MOD;
  }
  ans *= 3;
  ans %= MOD;
  ll p3 = 1;
  REP(i,n) {
    p3 *= 3;
    p3 %= MOD;
  }
  p3 += MOD - ans;
  p3 %= MOD;
  cout<<p3<<endl;
  return 0;
}


Measured memory_bytes: 3128
#include <stdio.h>

int main(void){
	int h1, m1, s1, h2, m2, s2, sum;
	int i,j;
	int time[2] = {3600, 60};
	
	for (i = 0; i < 3; i++){
		scanf("%d %d %d", &h1, &m1, &s1);
		scanf("%d %d %d", &h2, &m2, &s2);
		
		sum = (h2*3600 + m2*60 + s2) - (h1*3600 + m1*60 + s1);
		
		for (j = 0; j < 2; j++){
			if (j) printf(" ");
			printf("%d", sum/time[j]);
			sum = sum%time[j];
		}
		
		printf(" %d\n", sum);
	}
	
	return 0;
}

Measured memory_bytes: 600
import sys

sys.setrecursionlimit(10 ** 6)
input = sys.stdin.readline
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")

def main():
    n = int(input())
    ans = [0] * n
    csf = []
    for _ in range(n - 1):
        c, s, f = map(int, input().split())
        csf.append([c, s, f])
    for i in range(n - 1):
        elapsed = csf[i][0] + csf[i][1]
        for j in range(i + 1, n - 1):
            c, s, f = csf[j]
            if elapsed <= s:
                elapsed = s
            else:
                elapsed += -elapsed % f
            elapsed += c
        ans[i] = elapsed
    print(*ans, sep="\n")

main()


Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mx = 2e5+10;
ll dp[mx],arr[mx];
int main()
{
    ll n ;
    cin>>n;
    ll sum=0;
    for(int i=1; i<=n; i++)
    {
        cin>>arr[i];
        if(i%2!=0)
            sum+=arr[i];
        if(i!=1)
        {
            if(i%2!=0)
                dp[i]=max(dp[i-2]+arr[i],dp[i-1]);
            else
                dp[i]=max(dp[i-2]+arr[i],sum);
        }
    }
    cout<<dp[n]<<endl;
}


Measured memory_bytes: 6716
#include <iostream>

using namespace std;

int main()
{

    int length;     cin >> length;

    int order[1000000], student;
    for (int i = 0; i < length; i++){
        cin >> student;
        order[student-1] = i + 1;
    }

    for (int i = 0; i < length; i++){
        cout << order[i] << " ";
    }

    return 0;
}


Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define mod 1000000007
#define ll long long int
#define pi 3.141592653589793238

int main(){
	ll a,b,c,d;
    cin>>a>>b>>c>>d;
    cout<<max({a*c,a*d,b*c,b*d})<<endl;
    return 0;
}




Measured memory_bytes: 3608
#include <iostream>
#include <algorithm>

using namespace std;

int main() {
  int K, X;
  cin>>K>>X;

  int a = X - (K-1);
  int b = X + (K-1);

  for (int i=a; i<=b; i++){
    cout << i << " ";
  }
  cout << endl;

  return 0;

}


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

void print(const char str[]);
void reverse(char str[]);
void replace(char str[]);
int main(void)
{	
	char str[1001] = "\0";
	cin >> str;
	int q;
	cin >> q;
	
	for (int i = 0; i < q; i++) {
		char order[8] = "\0";
		cin >> order;
		
		if (strcmp(order, "print") == 0) print(str);
		else if (strcmp(order, "reverse") == 0) reverse(str);
		else replace(str);
	}
	
	return 0;
}

void print(const char str[])
{
	int a, b;
	cin >> a >> b;
	
	for (int i = a; i <= b; i++) {
		cout << str[i];
	}
	cout << endl;
}

void reverse(char str[])
{
	int a, b;
	cin >> a >> b;
	
	int n = (b - a + 1) / 2;
	for (int i = 0; i < n; i++) {
		char temp;
		temp = str[a+i];
		str[a+i] = str[b-i];
		str[b-i] = temp;
	}
}

void replace(char str[])
{
	int a, b;
	char p[1001];
	cin >> a >> b >> p;
	
	strncpy(&str[a], p, (b - a + 1));
}

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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (int i=(int)from; i<(int)to; i++)
#define all(vec) vec.begin(), vec.end()
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = 998244353;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

vector<ll> fac;
void c_fac(int x=pow(10,6)+10) { fac.resize(x,true); rep(i,x) fac[i] = i ? (fac[i-1]*i)%MOD : 1; }
ll inv(ll a, ll m=MOD) { ll b = m, x = 1, y = 0; while (b!=0) { int d = a/b; a -= b*d; swap(a,b); x -= y*d; swap(x,y); } return (x+m)%m; }
ll nck(ll n, ll k) { return fac[n]*inv(fac[k]*fac[n-k]%MOD)%MOD; }
ll gcd(ll a, ll b) { if (a<b) swap(a,b); return b==0 ? a : gcd(b, a%b); }
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }


int main() {
  ll N, S; cin >> N >> S;
  ll A[N]; rep(i,N) cin >> A[i];

  ll dp[N+1][S+1] = {}; dp[0][0] = 1;
  rep(i,N) rep(j,S+1) {

    dp[i+1][j] = ( dp[i+1][j] + dp[i][j]*2 ) % MOD;
    if (A[i]<=j) dp[i+1][j] = ( dp[i+1][j] + dp[i][j-A[i]] ) % MOD;
  }
  // rep(i,N+1) debug(dp[i], dp[i]+(S+1));

  ll result = dp[N][S];
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 74020
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    bool kawa=0;
    while(cin>>n,n){
        if(kawa)cout<<endl;
        string str[10];
        int num[10];
        for(int i=0,win,lose,draw;i<n;i++){
            cin>>str[i]>>win>>lose>>draw;
            num[i]=win*3+draw;
            str[i]+=',';
        }
        for(int i=0;i<n;i++){
            int ma=0;
            for(int j=0;j<n;j++)if(num[ma]<num[j])ma=j;
            cout<<str[ma]<<num[ma]<<endl;
            num[ma]=-1;
        }
        kawa=1;
    }
}

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

int main(){
  int A,B,C,X,count=0;
  cin >> A >> B >> C >> X;
  for(int i=0;i<A+1;i++){
    for(int j=0;j<B+1;j++){
      for(int k=0;k<C+1;k++){
        if(500*i+100*j+50*k==X){
          count++;
        }
      }
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
using namespace std;
typedef long long ll;
const int N=200200,D=26;
char s[N];
int p[N];
ll len[1000],num[1000];
int i,j,k,n,m;
ll l,r;
ll work(ll x,int ch) {
	int i,j;
	ll ans=0;
	ch+='a';
	len[1]=n;num[1]=0;
	for (i=1;i<=n;i++) if (s[i]==ch) num[1]++;
	len[2]=n+m;num[2]=num[1];
	for (i=1;i<=m;i++) if (s[i]==ch) num[2]++;
	//printf("%lld %lld\n",len[1],len[2]);
	for (i=2;i;i++) {
		//printf("%lld\n",len[i]);
		if (len[i-1]+len[i]>x) break;
		len[i+1]=len[i-1]+len[i];
		num[i+1]=num[i-1]+num[i];
	}
	for (j=i;j;j--) {
		if (x>=len[j]) {
			x-=len[j];
			ans+=num[j];
		}
	}
	for (i=1;i<=x;i++) if (s[i]==ch) ans++;
	return ans;
}
int main() {
	scanf("%s",s+1);
	n=strlen(s+1);
	n/=2;
	j=0;
	for (i=2;i<=n;i++) {
		while (j && s[j+1]!=s[i]) j=p[j];
		if (s[j+1]==s[i]) p[i]=++j;
	}
	m=n-p[n];
	scanf("%lld%lld",&l,&r);
	for (i=0;i<D;i++) printf("%lld ",work(r,i)-work(l-1,i));
	puts("");
}

Measured memory_bytes: 768
import java.util.Collections;
import java.util.Scanner;
import java.util.Vector;
public class Main {

	public static void main(String[] args) {
		Scanner input=new Scanner(System.in);
		Vector <Integer> precios=new Vector<Integer>();
		short n=input.nextShort();
		int k=input.nextInt();
		for(int i=0;i<n;i++) {
			precios.add(input.nextInt());
		}
		Collections.sort(precios);
		int suma=0;
		for (int j=0;j<k;j++) {
			suma+=precios.get(j);
		}
		System.out.println(suma);
	}

}


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

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

    cin>>x>>y>>z;
    x-=z;
    int i=0,count=0;

    while(1)
    {
        if(x-(y+z)>=0)
        {
            x-=y+z;
            count++;
        }
        else
        {
            break;
        }
    }
    cout<<count<<endl;
}

Measured memory_bytes: 256
#[allow(unused_imports)]
use std::io::{stdin, Read, StdinLock};
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
#[allow(unused_imports)]
use std::str::FromStr;
#[allow(unused_imports)]
use std::collections::{HashSet, HashMap, BinaryHeap, VecDeque};
#[allow(unused_imports)]
use std::vec::Vec;

#[allow(dead_code)]
const INF: i32 = 1000_000_000;
#[allow(dead_code)]
const INFLL: i64 = 1000_000_000_000_000_000;
#[allow(dead_code)]
const EPS: f64 = 1.0e-10;
#[allow(dead_code)]
const MOD: i32 = 1000_000_007;
#[allow(dead_code)]
const MODLL: i64 = 1000_000_007;

struct Scanner<'a> {
    cin: StdinLock<'a>,
}

#[allow(dead_code)]
impl<'a> Scanner<'a> {
    fn new(cin: StdinLock<'a>) -> Scanner<'a> {
        Scanner {cin: cin}
    }
    fn read1<T: FromStr>(&mut self) -> Option<T> {
        let token = self.cin.by_ref().bytes().map(|c| c.unwrap() as char)
                    .skip_while(|c| c.is_whitespace())
                    .take_while(|c| !c.is_whitespace())
                    .collect::<String>();
        token.parse::<T>().ok()
    }
    fn read<T: FromStr>(&mut self) -> T {
        self.read1().unwrap()
    }
}



fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);

    let mut c: Vec<Vec<i32>> = vec![vec![0; 3]; 3];
    for i in 0..3 {
        for j in 0..3 {
            c[i][j] = sc.read();
        }
    }
    let mut ans = false;
    for a1 in -100..100i32 {
        for a2 in -100..100i32 {
            for a3 in -100..100i32 {
                let b: Vec<i32> = vec![c[0][0] - a1, c[0][1] - a1, c[0][2] - a1];
                let a: Vec<i32> = vec![a1, a2, a3];
                let mut t = true;
                for i in 0..3 {
                    for j in 0..3 {
                        if a[i] + b[j] != c[i][j] {
                            t = false;
                        }
                    }
                }
                ans |= t;
            }
        }
    }
    if ans {
        println!("Yes");
    } else {
        println!("No");
    }
}

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

// iterator
#define REP(i,init, n) for(lli i=init;i<n;i++)
#define REPE(i,init, n) for(lli i=init;i<=n;i++)
#define REPIT(it,container) for(auto it = container.begin(); it != container.end(); it++)
#define REPIT_R(it,container) for(auto it = container.rbegin(); it != container.rend(); it++)

// input
#define cin1(x)             cin >> x
#define cin2(x, y)          cin >> x >> y
#define cin3(x, y, z)       cin >> x >> y >> z
#define ncin1(n, x)         REP(i, 0, n) {cin1(x[i]);}
#define ncin2(n, x, y)      REP(i, 0, n) {cin2(x[i], y[i]);}
#define ncin3(n, x, y, z)   REP(i, 0, n) {cin3(x[i], y[i], z[i]);}

// output
#define cout1(x)         cout << #x << ": " << x << endl;
#define cout2(x, y)      cout << #x << ": " << x << ", " << #y << ": " << y << endl;
#define cout3(x, y, z)   cout << #x << ": " << x << ", " << #y << ": " << y << ", " << #z << ": " << z << endl;;
#define ncout1(n, x)     REP(i, 0, n) {cout << #x << "[" << i << "]: "<< x[i] << endl;}

#define coutp(p)         cout << #p << ":" <<  " (" << p.first << ", " << p.second << ")" << endl;

// sort
#define sort_r(x, y)        sort(x, y, greater<lli>()); // 降順(5,4,3,,,)

#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

typedef long long int lli;
typedef pair<lli, lli> P;
typedef tuple<lli, lli, lli> tup;


lli c[1001]; // i列目のそれの個数
bool is_1[1000][1000];
int main() {
    lli h,w,a,b;
    cin1(h);
    cin1(w);
    cin1(a);
    cin1(b);

    REP(i,0,h) {
        REP(j,0,w) {
            if ((i < b) ^ (j < a))
                cout << 1;
            else
                cout << 0;
        }
        cout << endl;
    }

}


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

main :: IO ()
main = breads >>= print . solve

solve :: [Int] -> Int
solve [x, y] = check 2 [1..]
    where
        r = y `div` x
        check acc (z : zs)
            | acc > r = z
            | otherwise = check (acc * 2) zs

breads :: IO [Int]
breads = unfoldr uff <$> B.getLine
    where
        uff b = check <$> B.readInt b
        check (a, b)
            | B.null b = (a, b)
            | otherwise = (a, B.tail b)

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

using namespace std;

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

const double PI = 3.1415926535897932384626433832795;
const ll MOD = 1000000007;

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

int gcd(int x, int y) { return y ? gcd(y, x % y) : abs(x); }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : abs(x); }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

int n, a, b, c, d;
string s;

bool dfs(int now, int goal, vector<bool> &seen) {
	seen[now] = true;
	if (now == goal) {
		return true;
	}

	if (now + 1 < n && s[now + 1] == '.') {
		return dfs(now + 1, goal, seen);
	}
	
	if (now + 2 < n && s[now + 2] == '.') {
		return dfs(now + 2, goal, seen);
	}

	return false;
}

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

	cin >> n >> a >> b >> c >> d >> s;
	a--; b--; c--; d--;

	vector<bool> seenA(n), seenB(n);
	if (!dfs(b, d, seenB) || !dfs(a, c, seenA)) {
		cout << "No" << endl;
		return 0;
	}

	if (c < d) {
		cout << "Yes" << endl;
		return 0;
	}

	// 追い越し
	for (int i = b; i <= d; i++) {
		if (s[i - 1] == '.' && s[i] == '.' && s[i + 1] == '.') {
			cout << "Yes" << endl;
			return 0;
		}
	}

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


Measured memory_bytes: 592
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<ll,ll> ii;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define RST(i,n) memset(i,n,sizeof i)
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(),a.end()
#define X first
#define Y second
#define mkp make_pair
#define pb push_back
#define eb emplace_back
#define pob pop_back
#ifdef cold66
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<" ,";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // cold66
//}
template<class T> inline bool chkmax(T &a, const T &b) { return b > a ? a = b, true : false; }
template<class T> inline bool chkmin(T &a, const T &b) { return b < a ? a = b, true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;

const ll MAXn=1e5+5,MAXlg=__lg(MAXn)+2;
const ll MOD=1000000007;
const ll INF=0x3f3f3f3f;

int t[MAXn], x[MAXn], y[MAXn];
int main(){
  IOS();
  int n;
  cin>>n;
  REP(i,n) cin>>t[i]>>x[i]>>y[i];
  int nowx = 0, nowy = 0, nowt = 0;
  REP(i,n){
    int tx = x[i], ty = y[i], tt = t[i];
    if( abs(nowx-tx) + abs(nowy-ty) > tt-nowt ) return cout<<"No"<<endl,0;
    int tmp = tt-nowt-abs(nowx-tx)-abs(nowy-ty);
    if( tmp&1 ) return cout<<"No"<<endl,0;
    nowx = tx, nowy = ty, nowt = tt;
  }
  cout<<"Yes"<<endl;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=(ll)1e9+7;
const ll MOD2=(ll)998244353;
const ll INF=(ll)1e18+10;
const double PI=acos(-1);

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int dy[]={-1,1,0,0};
int dx[]={0,0,-1,1};

int dp[12][10];

bool able(ll a,ll K){
    while(a>=K){
        if(a%K==0ll) a/=K;
        else {
            if((a-1)%K==0) return true;
            else return false;
        }
    }
    if(a==1) return true;
    else return false;
}

void solve(int ca){
    ll N; cin>>N;

    ll ans=0ll;
    ll cnt=1ll;
    ll M=N-1,kyokai=sqrt(N-1);
    for(int i=2;i<=kyokai;++i){
        int tmp=1;
        while(M%i==0){
            tmp++;
            M/=i;
        }
        //if(tmp>1) cout<<i<<" "<<tmp<<endl;
        cnt*=(ll)tmp;
    }
    if(M>1) cnt*=2;
    //cout<<cnt<<endl;
    ans+=cnt;
    M=N;
    kyokai=sqrt(N);
    set<ll> yaku;
    for (int i = 1; i <=kyokai; ++i) {
        if(M%i==0) {
            yaku.insert(i);
            yaku.insert(M/i);
        }
    }
    for(auto i:yaku){
        if(i==1) continue;
        if(able(N,i)) {
            //cout<<i<<endl;
            ++ans;
        }
    }
    cout<<ans-1<<endl;
}

//#define MULTI
int main() {
#ifdef MULTI
    int N; cin>>N;
    for (int i = 0; i < N; ++i) {
        solve(i+1);
    }
#else
    solve(1);
#endif
    return 0;
}


Measured memory_bytes: 512
def main():
    INF = float("inf")

    N, M, P, *ABC = map(int, open(0).read().split())

    F = [[] for _ in range(N)]
    B = [[] for _ in range(N)]
    E = [(a - 1, b - 1, P - c) for a, b, c in zip(*[iter(ABC)] * 3)]

    for a, b, c in E:
        F[a].append(b)
        B[b].append(a)

    S = {0}
    stack = [0]
    while stack:
        s = stack.pop()
        for v in F[s]:
            if v not in S:
                stack.append(v)
                S.add(v)

    T = {N - 1}
    stack = [N - 1]
    while stack:
        s = stack.pop()
        for v in B[s]:
            if v not in T:
                stack.append(v)
                T.add(v)

    ok = S & T

    E = [(a, b, c) for a, b, c in E if a in ok and b in ok]

    D = [INF] * N
    D[0] = 0

    def bellman_ford(N):
        for _ in range(N):
            update = False
            for a, b, c in E:
                if D[b] > D[a] + c:
                    D[b] = D[a] + c
                    update = True
            if not update:
                return False
        return True

    print(-1 if bellman_ford(N + 1) else max(-D[-1], 0))


if __name__ == '__main__':
    main()


Measured memory_bytes: 5868
/*
        Author: Prokash
                CSE48, JU

*/

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

typedef long long ll;
#define FAST ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
int ara[2005];
int main()
{
    FAST;
    ll coin,sum=0,n=0,d=0;
    cin>>coin;
    ll ans=coin;
    for(ll i=0;i<=coin;i++)
    {
        sum=0;
        d=i;
        while(d)
        {
            sum+=(d%6);
            d/=6;
        }
        d=coin-i;
        while(d)
        {
            sum+=(d%9);
            d/=9;
        }
        ans=min(ans,sum);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <bitset>
using namespace std;

int main(){
	bitset<1121> isprime;
	isprime.set();
	isprime.reset(0);
	isprime.reset(1);
	
	for(int i = 2; i * i <= 1120; ++i){
		if( isprime[i] ){
			for(int j = i * i; j <= 1120; j += i){
				isprime.reset(j);
			}
		}
	}
	
	vector<int> prime;
	prime.reserve(200);
	for(int i = 2; i < 1120; ++i){
		if( isprime[i] ){
			prime.push_back(i);
		}
	}

	prime.push_back(1e9);

	vector<int>::iterator it;

	int n, k;
	while( scanf("%d%d", &n, &k), n != 0 ){
		vector<vector<int> > dp(k + 1, vector<int>(n + 1) );
		dp[0][0] = 1;

		for(it = prime.begin(); *it <= n; ++it){
			for(int j = n - *it; j >= 0; --j){
				for(int i = 0; i < k; ++i){
					dp[i + 1][j + *it] += dp[i][j];
				}
			}
		}
		
		printf("%d\n", dp[k][n]);
	}
}

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

int main(void) {
    int n;
    cin >> n;
    std::vector<int> h(n);
    for (int i = 0; i < n; ++i) {
        cin >> h[i];
    }
    int diff;
    int ans = 1;
    for (int i = 0; i < n-1; ++i) {
        diff = h[i + 1] - h[i];
        if (diff <= -2) {
            ans = 0;
            break;
        }
        else if (diff == -1) {
            ++h[i + 1];
        }
    }

    if (ans == 0) {
        cout << "No";
    }
    else {
        cout << "Yes";
    }

    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep_inv(i, n, m) for(int i = (int)(n); i > (int)(m); i--)
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vc = vector<char>;
using vvl = vector<vl>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;

ll MOD = 1000000007;

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

  ll ans = 1;

  rep2(i, 1, N + 1){
    ans *= i;
    ans %= MOD;
  }

  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;

public class Main {

    static BufferedReader in;
    static PrintWriter out;
    static StringTokenizer tok;

    void solve() throws IOException {
        int a = ni(), b = ni();

        if ((0 <= a || b <= 0) && a < b) {
            out.println(b - a);
            return;
        }

        if (0 < b && a > b) {
            out.println(a - b + 2);
            return;
        }

        if (0 == b && a > b) {
            out.println(a - b + 1);
            return;
        }

        if (a < 0 && a > b) {
            out.println(a - b + 2);
            return;
        }

        if (a == 0 && a > b) {
            out.println(a - b + 1);
            return;
        }

        out.println(Math.abs(a + b) + 1);
    }

    String ns() throws IOException {
        while (!tok.hasMoreTokens()) {
            tok = new StringTokenizer(in.readLine(), " ");
        }
        return tok.nextToken();
    }

    int ni() throws IOException {
        return Integer.parseInt(ns());
    }

    long nl() throws IOException {
        return Long.parseLong(ns());
    }

    double nd() throws IOException {
        return Double.parseDouble(ns());
    }

    String[] nsa(int n) throws IOException {
        String[] res = new String[n];
        for (int i = 0; i < n; i++) {
            res[i] = ns();
        }
        return res;
    }

    int[] nia(int n) throws IOException {
        int[] res = new int[n];
        for (int i = 0; i < n; i++) {
            res[i] = ni();
        }
        return res;
    }

    long[] nla(int n) throws IOException {
        long[] res = new long[n];
        for (int i = 0; i < n; i++) {
            res[i] = nl();
        }
        return res;
    }

    public static void main(String[] args) throws IOException {
        in = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        tok = new StringTokenizer("");
        Main main = new Main();
        main.solve();
        out.close();
    }
}

Measured memory_bytes: 8404
#include <bits/stdc++.h>
#define INF 1e18
#define PI M_PI
#define ll long long
#define vi vector<int>
#define all(v) v.begin(), v.end()
#define REP(i, n) for (int i=0; i<n; i++)
#define REPD(i, n) for (int i=n-1; i>=0; i--)
#define print(x) cout << x << endl;
#define debug(x) cout << #x << " = " << endl;

using namespace std;

void solve()
{
    int N;
    cin >> N;
    vector<ll> H(N);
    REP(i, N) cin >> H.at(i);
    bool flag = true;
    for (int i=N-1; i>0; i--) {
        if (H.at(i) < H.at(i-1)) {
            H.at(i-1) -= 1;
        }
    }
    REP(i, N-1) {
        if (H.at(i) > H.at(i+1)) {
            flag = false;
            break;
        }
    }
    if (flag) {
        print("Yes");
    } else {
        print("No");
    }
}

int main()
{
    solve();

    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <cctype>
#include <cmath>
#include <string>
using namespace std;
int judge(char,char);
int main(){
    string s;
    int K;
    cin >> s >> K;
    vector<string> subs;
    for(int i = 0;i < K;i ++){
        for(int j = 0;j < s.size()-i;j++){
            subs.push_back(s.substr(j,i+1));
        }
    }
    sort(subs.begin(),subs.end());
    subs.erase(unique(subs.begin(),subs.end()),subs.end());
  	cout << subs.at(K-1) << endl;
}

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

int main() {
    int N;  cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; ++i) cin >> A[i];
    long long ans = 0, mx = 0;
    for (int i = 0; i < N; ++i) {
        if (A[i] < mx) ans += mx - A[i];
        else mx = A[i];
    }
    cout << ans << endl;
}


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

int main(void){
    string row,sub;
    int m,h;
    while(1){
        cin>>row;
        if(row=="-")break;
        cin>>m;
        for(int i=1;i<=m;i++){
            cin>>h;
            sub=row.substr(h,row.size()-h);
            row=row.erase(h,row.size()-h);
            row=sub+row;
        }
        cout<<row<<endl;
    }
    return 0;
}

Measured memory_bytes: 3152
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <random>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
typedef map<int, int> mii;
typedef set<int> si;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STLL(s) strtoll(s.c_str(), NULL, 10)
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int
#define endl '\n';
#define fi first
#define se second
#define NONVOID [[nodiscard]]
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
inline string getline(){string s; getline(cin,s); return s;}
inline void yn(const bool b){b?fin("yes"):fin("no");}
inline void Yn(const bool b){b?fin("Yes"):fin("No");}
inline void YN(const bool b){b?fin("YES"):fin("NO");}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;



int main() {
    
    int n,m;
    cin>>n;
    vi v(n);
    rep(i,n)cin>>v[i];
    Sort(v);
    v.erase(unique(all(v)), v.end());
    rep(j,v.size()){
        if(!j)cout<<v[0];
        else cout<<" "<<v[j];
    }cout<<endl;
}




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

#define pb push_back
#define mk make_pair
#define fi first
#define se second
#define eb emplace_back

typedef long long ll;
typedef pair<int,int> ii;
typedef vector< pair<int,int> > vii;
const int INF = 0x3f3f3f3f;

const int T = 1e3 + 5;
int pont[T];
int par[T];
int d[T];
int mat[T][T];
int n;
 
int main() {
    ios_base::sync_with_stdio(false);
    cin >> n;
    queue<int> fila;

    for(int i = 1; i <= n; i++) {
        for(int j = 0; j < n-1; j++) cin >> mat[i][j];
        par[i] = mat[i][0];
        if(i == par[par[i]]) {
            fila.emplace(i), fila.emplace(par[i]);
            pont[i]++, pont[par[i]]++;
            d[i]++, d[par[i]]++;
        }
    }

    int ans = 0;
    
    while(!fila.empty()) {
        int i = fila.front();
        fila.pop();

        if(pont[i] >= n-1) continue;
        int nxt = mat[i][pont[i]];
        if(pont[nxt] >= n-1) continue;

        if(i == mat[nxt][pont[nxt]]) {
            int x = max(d[i]+1,d[nxt]+1);
            d[nxt] = d[i] = x;
            //cout << i << " x " << nxt << " " << x << endl;
            ans = max(ans,x);
            pont[i]++;
            fila.emplace(i);
            pont[nxt]++;
            fila.emplace(nxt);
        }

    } 

    bool ok = 1;
    for(int i = 1; i <= n; i++) ok &= (pont[i] == n-1);
    cout << (ok? ans : -1) << endl;

    return 0;
}



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

main()
{
    int i,j,k,l,m,n;

    while(cin>>n)
    {
        int x[n];
        for(i=0; i<n; i++)
            cin>>x[i];
        sort(x,x+n);
        m=x[0];
      for(i=0;i<n;i++){
        m=__gcd(m,x[i]);
      }
      cout<<m<<endl;
    }
    return 0;
}


Measured memory_bytes: 640
N=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
ans=0
for i in range(N-1):
    if a[i]<b[i]:
        tmp=b[i]-a[i]
        ans+=a[i]
        if tmp<a[i+1]:
            ans+=tmp
            a[i+1]-=tmp
            
        else:
            ans+=a[i+1]
            a[i+1]=0
            
    else:
        ans+=b[i]
#print(ans)
#print(a)
hoge=a[-1]+a[-2]
#print(hoge)
y=b[-1]
#print(y)
if hoge>y:
    ans+=y
else:
    ans+=hoge
print(ans)

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

using namespace std;

int main() {
    int a, b;
    cin >> a >> b;

    int cnt = 10, tmp = b;
    while (tmp /= 10) {
        cnt *= 10;
    }

    int num = a * cnt + b;

    int num1 = sqrt(num);

    if (num1 * num1 == num) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<numeric>
#include<set>
#include<algorithm>
 
#define PI 3.14159265358979323846
 
using namespace std;
 
int main() {
    int R;
    cin >> R;
 
    cout << 2 * R * PI << endl;
    return 0;
}

Measured memory_bytes: 3776
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Program
{
    public static void Main()
    {
        String input = Console.ReadLine();
        if (input[2] == input[3] && input[4] == input[5]) { Console.WriteLine("Yes"); }
        else { Console.WriteLine("No"); }
    }
}

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

int main() {
  int n;
  cin >> n;
  vector<int> dp(n + 1, INT_MAX);
  dp[0] = 0;
  for (int i = 1; i <= n; i++) {
    dp[i] = min(dp[i], dp[i - 1] + 1);
    for (int j = 6; j <= i; j *= 6) {
      dp[i] = min(dp[i], dp[i - j] + 1);
    }
    for (int j = 9; j <= i; j *= 9) {
      dp[i] = min(dp[i], dp[i - j] + 1);
    }
  }
  cout << dp[n] << endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define mod 1000000007
#define pb push_back
#define pob pop_back()
#define ss second
#define ff first
#define tez ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
int main()
{
	ll n;
	cin>>n;
	ll h[n+1];
	for(ll i=1;i<=n;i++)
	{
		cin>>h[i];
	}
	ll dp[n+1]={INT_MAX};
	dp[1]=0;
	dp[2]=abs(h[2]-h[1]);
	
//	dp[2]=h[2]-h[0];
	for(ll i=3;i<=n;i++)
	{
		dp[i]=min(dp[i-2]+abs(h[i]-h[i-2]),dp[i-1]+abs(h[i]-h[i-1]));
	}
	cout<< dp[n];
}

Measured memory_bytes: 1792
s = input()
t = input()

dp = [[0]*(3001) for j in range(3001)]

for i in range(len(s)):
    for j in range(len(t)):
        if s[i] == t[j]:
            dp[i+1][j+1] = max(dp[i][j]+1,dp[i+1][j],dp[i][j+1])
        else:
            dp[i+1][j+1] = max(dp[i+1][j],dp[i][j+1])

#print(dp[len(s)][len(t)])

res = ""
s_len = len(s)
t_len = len(t)
while s_len > 0 and t_len > 0:
    if dp[s_len][t_len] == dp[s_len-1][t_len]:
        s_len -= 1
    elif dp[s_len][t_len] == dp[s_len][t_len-1]:
        t_len -= 1
    else:
        res = s[s_len-1] + res
        s_len -= 1
        t_len -= 1
print(res)

Measured memory_bytes: 113372
#include <stdio.h>

void swap(int *a, int *b) 
{
    int tmp;
    tmp = *a;
    *a = *b;
    *b = tmp;
}

int main(void) 
{
    int dataset_num;
    int a, b, c, i;
    scanf("%d", &dataset_num);
    for (i=0; i<dataset_num; i++){
        scanf("%d%d%d", &a, &b, &c);
        if (a < b) {
            swap(&a, &b);            
        }
        if (a < c) {
            swap(&a, &c);
        }
        if (a*a == (b*b + c*c)) {
            printf("YES\n");
        } else {
            printf("NO\n");
        }
    }
}



Measured memory_bytes: 2048
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;

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


Measured memory_bytes: 256
n = int(input())
X = list(map(int, input().split()))

ans = 10 ** 9

xmin = min(X)
xmax = max(X)

for i in range(xmin, xmax + 1):
    tmp = 0
    for j in range(n):
        tmp += (X[j] - i) ** 2
    ans = min(ans, tmp)
print(ans)

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

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

    int r = 0;

    for (int i = 0; i < 3; i++){
        if (S.at(i) == 'R'){
            r++;
        }
    }

    if (r == 3){
        cout << 3;
    }
    else if(r == 2){
        if(S.at(1) == 'R'){
            cout << 2;
        }
        else{
            cout << 1;
        }
    }
    else if(r == 0){
        cout << 0;
    }
    else{
        cout << 1;
    }

    return 0;
}


Measured memory_bytes: 3592
#coding:utf-8
N,M=map(int,raw_input().split())
A=map(int,raw_input().split())
dp=[-1 for i in range(10**4 + 1)]
Cost={(i+1):v for i,v in enumerate([2,5,5,4,5,6,3,7,6])}

for a in A:
    dp[Cost[a]]=1
for n in range(2,N+1):
    for a in A:
        if n-Cost[a]>=0 and dp[n-Cost[a]] != -1:
            dp[n]=max(dp[n], dp[n-Cost[a]]+1)
k=dp[N]
n=N
buf=[]
for i in range(dp[N]-1):
    b=-1
    for a in A:
        if n-Cost[a]>=0 and dp[n-Cost[a]] == k-1:
            b=max(b,a)
    k-=1
    n-=Cost[b]
    buf.append(b)
b=-1
for a in A:
    if Cost[a] == n:
        b=max(b,a)
buf.append(b)   
print("".join(map(str,buf)))







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

int main()
{
  int n, d, x;
  cin >> n >> d >> x;
  int sum = x;
  vector<int> v(n);
  for(int i = 0; i < n; i++){
    cin >> v[i];
    v[i] = (d - 1) / v[i] + 1;
    sum += v[i];
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
int main(){
    long long n;cin>>n;--n;
    long long a,b,t,s,tmpa,tmpb;cin>>a>>b;
    for(int i=0;i<n;++i){
        cin>>t>>s;tmpa=t,tmpb=s;
        long long m=max((a+t-1)/t,(b+s-1)/s);
        a=m*t;b=m*s;
    }cout<<a+b;
}


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

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

using namespace std;

int a[110];

int main(void){
	int n,r;
	while(cin >> n >> r,n|r){
		rep(i,n) a[i]=n-i;
		//cout << a[0] << a[1] << endl;
		rep(i,r){
			int p,c;
			cin >> p >> c;
			int tmp[110];
			rep(i,p-1) tmp[i]=a[i];
			rep(i,c) a[i]=a[i+p-1];
			rep(i,p-1) a[i+c]=tmp[i];
		}
		cout << a[0] << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
#define SZ(v) int((v).size())
#define ALL(vec) (vec).begin(),(vec).end()
typedef unsigned long long i64;
template<typename T> inline bool uax(T &x, T y) {return (y > x) ? x = y, true : false;}
template<typename T> inline bool uin(T &x, T y) {return (y < x) ? x = y, true : false;}
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); \
  stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string>) {}
template<typename T1,typename T2> ostream& operator<<(ostream& os, pair<T1,T2> buf) {
  return os << "(" << buf.first << ": " << buf.second << ")"; }
#define DefOut(Con) template<typename T>ostream&operator<<(ostream&os,Con<T>&A){ bool f = false; os << "{"; \
  for (const auto e: A) { if (f) os << ", "; os << e; f = true; } return os << "}"; }
#define DefOut2(Con) template<typename K,typename V>ostream&operator<<(ostream&os,Con<K,V>&A) \
{ bool f = false; os << "{"; for (auto &e: A) { if (f) os << ", "; os << e; f = true; } return os << "}"; }
template<typename T>ostream &operator << (ostream &os,vector<vector<T>>& A) {
  for (auto &B: A) os << '\n' << B; return os; }
DefOut(vector) DefOut(set) DefOut(multiset) DefOut2(map) 
template<typename T,typename... Args> void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " =: " << a << endl; err(++it, args...); }
template<typename T> void kek(T ans) {cout << ans << endl; exit(0);}
int const MOD = 1e9 + 7;
long long const INF = 1e18;
/***********************************************************************/
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  
  string s;
  cin >> s;
  int n = SZ(s);
  bool ok = false;
  for (int i = 1; i < n - 1; ++i)
    ok |= s[i - 1] != s[i + 1];
  int finish = 2 + (n > 2 && s[0] == s[n - 1]);
  kek(ok && (n - finish) & 1 ? "First" : "Second");
  
  return 0;
}


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

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

const int MOD = 1000000007;
const int INF_32 = 1LL << 30;
const int64_t INF_64 = 1LL << 60;

const int mod = 1000000007;
struct mint {
    ll x; // typedef long long ll;
    mint(ll x = 0)
        : x((x % mod + mod) % mod)
    {
    }
    mint operator-() const { return mint(-x); }
    mint& operator+=(const mint a)
    {
        if ((x += a.x) >= mod)
            x -= mod;
        return *this;
    }
    mint& operator-=(const mint a)
    {
        if ((x += mod - a.x) >= mod)
            x -= mod;
        return *this;
    }
    mint& operator*=(const mint a)
    {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const { return mint(*this) += a; }
    mint operator-(const mint a) const { return mint(*this) -= a; }
    mint operator*(const mint a) const { return mint(*this) *= a; }
    mint pow(ll t) const
    {
        if (!t)
            return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1)
            a *= *this;
        return a;
    }

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

int main()
{
    int n;
    cin >> n;
    vector<int> mp1(60, 0);
    vector<int> mp0(60, 0);
    for (int i = 0; i < n; i++) {
        ll a;
        cin >> a;
        int keta = 0;
        while (a > 0) {
            if (a & 1) {
                mp1[keta]++;
            }
            keta++;
            a >>= 1;
        }
    }

    for (int i = 0; i < 60; i++) {
        mp0[i] = n - mp1[i];
    }

    mint two(2);
    mint ans = 0;
    for (int i = 0; i < 60; i++) {
        ans += two.pow(i) * mint(mp1[i]) * mint(mp0[i]);
    }

    cout << ans.x << endl;
}


Measured memory_bytes: 256