akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define REP(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=(b)-1; i>=(a); --i)

#define DEBUG(x) cout<<#x<<": "<<(x)<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

template<typename T> inline void CHMAX(T& a, const T b) {if(a<b) a=b;}
template<typename T> inline void CHMIN(T& a, const T b) {if(a>b) a=b;}

constexpr ll MOD=1000000007ll;
// constexpr ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

char ans[1252][1252];
string three[3]={"aa.", "..a", "..a"};
string four[4]={"aabc", "ddbc", "bcaa", "bcdd"};
string five[5]{"aabba", "bcc.a", "b..cb", "a..cb", "abbaa"};
string six[6]={"aabc..", "ddbc..", "..aabc", "..ddbc", "bc..aa", "bc..dd"};
string seven[7]={"aabbcc.", "dd.dd.a", "..d..da", "..d..db", "dd.dd.b", "..d..dc", "..d..dc"};

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  // cout<<setprecision(10)<<fixed;
  int n;
  cin>>n;
  REP(i, n){
    REP(j, n){
      ans[i][j]='.';
    }
  }
  if(n==2){
    cout<<-1<<'\n';
    return 0;
  }
  int cur=n;
  while(cur>7){
    REP(i, 4){
      REP(j, 4){
        ans[i+n-cur][j+n-cur]=four[i][j];
      }
    }
    cur-=4;
  }
  if(cur==3){
    REP(i, 3){
      REP(j, 3){
        ans[i+n-cur][j+n-cur]=three[i][j];
      }
    }
  }
  else if(cur==4){
    REP(i, 4){
      REP(j, 4){
        ans[i+n-cur][j+n-cur]=four[i][j];
      }
    }
  }
  else if(cur==5){
    REP(i, 5){
      REP(j, 5){
        ans[i+n-cur][j+n-cur]=five[i][j];
      }
    }
  }
  else if(cur==6){
    REP(i, 6){
      REP(j, 6){
        ans[i+n-cur][j+n-cur]=six[i][j];
      }
    }
  }
  else{
    REP(i, 7){
      REP(j, 7){
        ans[i+n-cur][j+n-cur]=seven[i][j];
      }
    }
  }
  REP(i, n){
    REP(j, n){
      cout<<ans[i][j];
    }
    cout<<'\n';
  }
  return 0;
}


Measured memory_bytes: 2432
import sys
def input(): return sys.stdin.readline().rstrip()
def ii(): return int(input())
def mi(): return map(int, input().split())
def li(): return list(mi())


def main():
    s = input()
    cnt = 0
    if 'RRR' in s:
        print(3)
    elif 'RR' in s:
        print(2)
    elif 'R' in s:
        print(1)
    else:
        print(0)


if __name__ == '__main__':
    main()

Measured memory_bytes: 9136
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int D=sc.nextInt();
		int N=sc.nextInt();
		if(N==100)N++;
		switch(D) {
		case 0:break;
		case 1:N*=100;break;
		case 2:N*=10000;break;

		}
		System.out.println(N);
	}

}


Measured memory_bytes: 23124
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>

const int INF = 1000000009;
const long LINF = 1123456789012345678;

std::string s;
int m;
int alp[26];
std::set<std::string> st;
int n;

int main(){
	std::cin >> s;
	scanf("%d", &m);
	n = s.length();
	for(int i = 0; i < n; i++){
		for(int j = 0; j < m; j++){
			if(i + j >= n){
				break;
			}
			st.insert(s.substr(i, j+1));
		}
	}
	/*for(auto i = st.begin(); i != st.end(); i++){
		std::cout << *i << std::endl;
	}
	//*/
	auto it = st.begin();
	for(int i = 1; i < m; i++){
		it++;
	}
	std::cout << *it << std::endl;
}


Measured memory_bytes: 1664
n = int(input())
lis = [list(map(int,input().split())) for _ in range(n)]
s = 0

for i in range(n-1):
    
    for j in range(i+1,n):
        x = (lis[i][0] - lis[j][0])**2
        y = (lis[i][1] - lis[j][1])**2
        s += (x+y)**0.5
print(s*2/n)

Measured memory_bytes: 3064
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define _USE_MATH_DEFINES
#include <math.h>
#define rep(i,n) for(int i = 0;i < n;i++)
#define NIL = -1;
#define all(x) x.begin(),x.end()
const ll INF = 1e9;
const ll mod = 1e9 + 7;

int digit(ll x) {
    if (x / 10 == 0) return 1;
    return digit(x / 10) + 1;
}

ll gcd(long long a,long long b) {
    if (a < b) swap(a,b);
    if (b == 0) return a;
    
    return gcd(b,a%b);
}

ll lcm(ll a,ll b){
    return ((a * b == 0)) ? 0 : (a / gcd(a,b) * b);
}

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


/////////////////////////////////////////////////////////////////////////////////////

int main(){
    ll a;
    double b;
    cin >> a >> b;

    ll bi = ll((b * 100) + 0.0001);
    cout << a * bi / 100 << endl;
}

Measured memory_bytes: 3688
s = raw_input()

while len(s) > 0:
  if s.startswith('eraser'):
    s = s[6:]
  elif s.startswith('erase'):
    s = s[5:]
  elif s.startswith('dreamere') or s.startswith('dreamerd') or s == 'dreamer':
    s = s[7:]
  elif s.startswith('dream'):
    s = s[5:]
  else:
    print 'NO'
    break
else:
  print 'YES'

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

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


int main() {

    int height, width;
    cin >> height >> width;

    vector<string> field(height);
    for (int h = 0; h < height; ++h) cin >> field[h];

    int sx=0, sy=0, gx=height-1, gy=width-1;

    vector<vector<int> > dist(height, vector<int>(width, -1)); 
    dist[sx][sy] = 0; 

    queue<pair<int, int> > que; 
    que.push(make_pair(sx, sy)); 


    while (!que.empty()) {
        pair<int, int> current_pos = que.front(); 
        int x = current_pos.first;
        int y = current_pos.second;
        que.pop(); 

        for (int direction = 0; direction < 4; ++direction) {
            int next_x = x + dx[direction];
            int next_y = y + dy[direction];
            if (next_x < 0 || next_x >= height || next_y < 0 || next_y >= width) continue; 
            if (field[next_x][next_y] == '#') continue; 

            if (dist[next_x][next_y] == -1) {
                que.push(make_pair(next_x, next_y));
                dist[next_x][next_y] = dist[x][y] + 1; 
            }
        }
    }

    if(dist[height-1][width-1] == -1){
      cout << -1;
    } else {
    int score = 0;
    
     for (int h = 0; h < height; ++h) {
        for (int w = 0; w < width; ++w) {
            if(field[h][w]=='.'){
                score += 1;
            }
        }
     }
    
    score -= (dist[height-1][width-1] + 1);
    cout << score;
    }
    
}


Measured memory_bytes: 256
#include<cstdio>

int main(void){
	int n, m, a[100], b, p[100]={0}, i, j;
	scanf("%d%d", &n, &m);
	for(i=0; i<m; ++i){ scanf("%d", a+i); --a[i]; }
	for(i=0; i<m; ++i){
		for(j=0; j<n; ++j){
			scanf("%d", &b); --b;
			if(b==a[i]){ b=j; goto pp; }
			else{ b=a[i]; pp: ++p[b]; }
		}
	}
	for(i=0; i<n; ++i){ printf("%d\n", p[i]); }
	return(0);
}


Measured memory_bytes: 2692
def main():
    h,w,n=map(int,input().split(' '))
    if n==0:
        print((h-2)*(w-2))
        for i in range(9):
            print(0)
        exit()
    draw_list=[]
    for i in range(n):
        draw=tuple(map(int,input().split(' ')))
        for j in range(3):
            for k in range(3):
                if 0<draw[0]-j<=h-2 and 0<draw[1]-k<=w-2:
                    draw_list.append((draw[0]-j,draw[1]-k))
    ans = [0]*9
    sorted_draw = sorted(draw_list)
    for n,i in enumerate(sorted_draw):
        if not n:
            ans_num=0
            tmp = i
            continue
        if tmp == i:
            ans_num+=1
        else:
            ans[ans_num] += 1
            tmp = i
            ans_num = 0
    ans[ans_num] += 1
    print((h-2)*(w-2)-sum(ans))
    for i in ans:
        print(i)



if __name__ == '__main__':
    main()


Measured memory_bytes: 135832
###==================================================
### import
#import bisect
#from collections import Counter, deque, defaultdict
#from copy import deepcopy
#from functools import reduce, lru_cache
#from heapq import heappush, heappop
#import itertools
#import math
#import string
import sys
### stdin
def input(): return sys.stdin.readline()
def iIn(): return int(input())
def iInM(): return map(int, input().split())
def iInM1(): return map(int1, input().split())
def iInLH(): return list(map(int, input().split()))
def iInLH1(): return list(map(int1, input().split()))
def iInLV(n): return [iIn() for _ in range(n)]
def iInLV1(n): return [iIn()-1 for _ in range(n)]
def iInLD(n): return [iInLH() for _ in range(n)]
def iInLD1(n): return [iInLH1() for _ in range(n)]
def sInLH(): return list(input().split())
def sInLV(n): return [input().rstrip('\n') for _ in range(n)]
def sInLD(n): return [sInLH() for _ in range(n)]
### stdout
def OutH(lst, deli=' '): print(deli.join(map(str, lst)))
def OutV(lst): print('\n'.join(map(str, lst)))
### setting
sys.setrecursionlimit(10 ** 6)
### utils
int1 = lambda x: int(x) - 1
### constants
INF = int(1e9)
MOD = 1000000007
dx = (-1, 0, 1, 0)
dy = (0, -1, 0, 1)
###---------------------------------------------------

A = iIn()
B = iIn()
C = iIn()
X = iIn()

# めんどくさいから全探索
ans = 0
for i in range(A + 1):
    for j in range(B + 1):
        for k in range(C + 1):
            if 500 * i + 100 * j + 50 * k == X:
                ans += 1

print(ans)

Measured memory_bytes: 68008
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int array[] = new int[n];

		for(int i = 0; i < n; i++) {
			array[i] = sc.nextInt();
		}

		int q = sc.nextInt();

		for(int i = 0; i < q; i++) {
			int key = sc.nextInt();

			BinarySearch bi = new BinarySearch();
			System.out.println(bi.binarySearch(array, key));
		}
	}
}

class BinarySearch {
	public int binarySearch(int[] array, int key) {
		int pLeft = 0;
		int pRight = array.length - 1;

		do {
			int center = (pLeft + pRight) / 2;

			if (array[center] == key) {
				return 1;
			} else if (array[center] < key){
				pLeft = center + 1; //真ん中の一つ右側を左端とする
			} else {
				pRight = center - 1;
			}
		} while (pLeft <= pRight);

		return 0;
	}
}


Measured memory_bytes: 105956
import java.util.Scanner;

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

    private void run() {
        Scanner scanner = new Scanner(System.in);
        String S = scanner.next();
        String ans = "";
        if(S.equals("Sunny")) {
            ans = "Cloudy";
        } else if(S.equals("Cloudy")) {
            ans = "Rainy";
        } else {
            ans = "Sunny";
        }


        System.out.println(ans);
    }
}


Measured memory_bytes: 20564
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const ll maxn=1999999;
const ll mod=998244353;
const ll INF=500000000000000000ll;
int buf[40];
#define int ll
template<class M> inline void putd(M x)
{
    int p=0;
    if(x<0){
        putchar('-');
        x=-x;
    }
    do{
        buf[p++]=x%10;
        x/=10;
    }while(x);
    for(int i=p-1;i>=0;i--) 
	putchar(buf[i]+'0');
    putchar('\n');
}
template<class T> inline bool read(T& x)
{
    int ch=getchar();
    bool neg=false;
    if(ch!=EOF && ch!='-' && !isdigit(ch)) ch=getchar();
    if(ch==EOF) return false;
    if(ch=='-'){
        neg=true;
        ch=getchar();
    }
    x=ch-'0';
    while(isdigit(ch=getchar())) x=x*10+ch-'0';
    if(neg) x=-x;
    return true;
}
string s;
signed main()
{
	cin>>s;
	int len=s.length();
	int ans=0;
	
	for(int i=0;i<=len-3;i++)
	{
		if((s[i]=='A')&&(s[i+1]=='B')&&(s[i+2]=='C'))
		{
			int p=1;
			if(i>=1)
			{
				int cnt=i-1;
				while(s[cnt]=='A') {
				p++;
				cnt--;}
				int cntT=cnt;
				while((s[cnt]=='C'&&s[cnt-1]=='B')||(s[cntT]=='A')){
					if(s[cnt]=='C'&&s[cnt-1]=='B') {
				cnt=cnt-2;
				cntT=cnt;}
				if(s[cntT]=='A')
				{
					cnt--;
					cntT--;
					p++; 
		}
				}
			}
			int q=1;
			if(i<=len-5)
			{
				int cnt=i+3;
				while((s[cnt]=='B')&&(s[cnt+1]=='C')) q++,cnt=cnt+2;
			}
			ans=ans+p*q;
		}
	}
	cout<<ans;
	return 0;
} 

Measured memory_bytes: 640
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <math.h>
#include <queue>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
ll ans;
ll N;
pair<ll,ll> A[2005];
ll dp[2005][2005];




int main(){
    cin >> N;
    for(ll i = 0;i<N;i++){
        ll a;
        cin >> a;
        A[i] = pair<ll,ll> (a,i);
    }
    sort(A,A+N);
    for (int j=1;j<=N;j++){
        dp[0][j] = dp[0][j-1]+A[N-j].first*(N-j-A[N-j].second);
    }
    for (int i=1;i<=N;i++){
        dp[i][0] = dp[i-1][0]+A[N-i].first*(A[N-i].second-i+1);
        for (int j=1;j<=N;j++){
            dp[i][j] = max(dp[i-1][j]+A[N-i-j].first*(A[N-i-j].second-i+1),dp[i][j-1]+A[N-i-j].first*(N-j-A[N-i-j].second));
        }
    }
    
    for (int i=0;i<N;i++){
        if(ans<dp[i][N-i]){
            ans = dp[i][N-i];
        }
    }

    
    cout << ans << endl;

}



Measured memory_bytes: 35028
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int ans=0;
  int x,y;
  cin>>x>>y;
  if(x==1)
    ans+=300000;
  else if(x==2)
    ans+=200000;
  else if(x==3)
    ans+=100000;
  if(y==1)
    ans+=300000;
  else if(y==2)
    ans+=200000;
  else if(y==3)
    ans+=100000;
  if(x==1 and y==1)
    ans+=400000;
  cout<<ans<<"\n";
  return 0;
}

Measured memory_bytes: 256
using System.Text;
using System;

public class Hello
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        string[] line = Console.ReadLine().Trim().Split(' ');
        getAns(n, line[0], line[1]);
    }
    static void getAns(int n, string s, string t)
    {
        var sb = new StringBuilder();
        for (int i = 0; i < n; i++)
            sb.Append(s[i].ToString() + t[i].ToString());
        Console.WriteLine(sb);
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
int main() {
    int n,a,b,sum=0;
    string s;
    bool flag=true;
    cin >> n >> a >> b;
    for(int i=0;i<n;i++){
        s = to_string(i+1);
        int s_sum=0;
        for(int j=0;j<s.size();j++){
            s_sum += s[j]-'0';
        }
        if (s_sum >=a &&s_sum<=b){
            sum += i+1;
        }
    }
    cout << sum <<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define vl vector<ll int>
#define vs vector<string>
#define v vector<int>
#define mi map<int,int>
#define mc map<char,int>

//ios_base::sync_with_stdio(false);cin.tie(NULL);

using namespace std;

int main(){
     ios_base::sync_with_stdio(false);cin.tie(NULL);
     int n,r,i;
     cin>>n>>r;
     if(n>=10){i=r;}
     else{i=r+100*(10-n);}
     cout<<i <<"\n";

}

Measured memory_bytes: 3616
#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() {
  ll n, q, b, c;
  cin >> n;
  // vector<int> a(n);
  map<ll, ll> mp;
  rep(i, n) {
    // cin >> a[i];
    int a;
    cin >> a;
    mp[a]++;
  }

  ll ans = 0;
  for (auto x : mp) ans += x.first * x.second;

  cin >> q;
  rep(i, q) {
    cin >> b >> c;
    mp[c] += mp[b];
    ans -= b * mp[b];
    ans += c * mp[b];
    mp[b] = 0;
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 9404
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

typedef struct{
  int hana;
  int taro;
}Result;

const int MAX = 201;
int data[MAX];
vector<int>VT;
vector<int>VH;

void out(){
  for(int i = 0; i < VH.size(); i++) cout << VH[i] << " " ;
  cout << endl;
  for(int i = 0; i < VT.size(); i++) cout << VT[i] << " " ;
  cout << endl;
}

int VTsearch(int now){
  int out = 0;
  for(int i = VT.size()-1; i >= 0; i--){
    if(VT[i] > now){
      out = VT[i];
      VT[i] = 0;
      break;
    }
  }
  return out;
}

int VHsearch(int now){
  int out = 0;
  for(int i = VH.size()-1; i >= 0; i--){
    if(VH[i] > now){
      out = VH[i];
      VH[i] = 0;
      break;
    }
  }
  return out;
}

void Vsort(){
  sort(VT.begin(),VT.end());
  reverse(VT.begin(),VT.end());
  while(1){
    if(VT[VT.size()-1] == 0) VT.pop_back();
    else break;
  }

  sort(VH.begin(),VH.end());
  reverse(VH.begin(),VH.end());
  while(1){
    if(VH[VH.size()-1] == 0) VH.pop_back();
    else break;
  }
}

Result solve(){
  int min;
  int now = VT[VT.size()-1];
  VT.pop_back();
  while(1){
    // out();
    Vsort();
    min = VHsearch(now);
    if(min)now = min;
    else now = 0;
    if(VH.size() == 0) break;
    min = VTsearch(now);
    if(min)now = min;
    else now = 0;
    if(VT.size() == 0) break;
  }
  Result out;
  out.hana = VH.size();
  out.taro = VT.size();
  return out;
}

int main(){
  int in;
  while(cin >> in && in){
    fill(data, data+MAX,1);
    fill(data+in*2+1, data+MAX,0);
    VT.clear();
    VH.clear();
    for(int i = 0; i < in; i++){
      int taro;
      cin >> taro;
      VT.push_back(taro);
      data[taro] = 0;
    }
    for(int i = 1; i <= 2*in; i++){
      if(data[i]) VH.push_back(i);
    }
    Vsort();
    Result re = solve();
    cout << re.hana << endl;
    cout << re.taro << endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

//map <vector<int>, int> m;

int main() {
	// your code goes here
	int a,b,t,l,i,j,minAns=100000000;
	cin >> a >> b;

	int ans;

	if(a>=13)
		ans = b;
	else if(a>=6)
		ans = b/2;
	else 
		ans=0;


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


Measured memory_bytes: 256
N,M = map(int,input().split())
L_max = 0
R_min = N
for i in range(0,M):
  L_tmp, R_tmp = map(int,input().split())
  if L_max < L_tmp:
    L_max = L_tmp
  if R_min > R_tmp:
    R_min = R_tmp
  
print(R_min - L_max + 1) if R_min >= L_max else print(0)

Measured memory_bytes: 3060
#include <math.h> 
#include<stdio.h>
int IsPrime(int num);

int main(){
    int x;
    scanf("%d",&x);
    while(IsPrime(x)!=1){
        if(x%2==0)x++;
        else x=x+2;
    }
    printf("%d",x);
    return 0;
}

int IsPrime(int num)
{
    if (num < 2) return 0;
    else if (num == 2) return 1;
    else if (num % 2 == 0) return 0; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return 0;
        }
    }

    // 素数である
    return 1;
}

Measured memory_bytes: 128
#include <iostream>
#include <cmath>

using namespace std;

int main () {
	int n,m;
	cin>>n>>m;
	int a[m];
	int sum=0;
    
    for(int i=0;i<m;i++){
    	cin >> a[i];
    	sum = sum + a[i];
   	}
   	
   	int days = n - sum;
   	
   	if(days<0){
   		cout << -1;
	   }
	   else{
	   	cout << days;
	   }
   	
   	
   	
}

Measured memory_bytes: 3676
#include <bits/stdc++.h>
using namespace std;
long long int a[100010],b[100010];
long long int s[100010];
long long int ans[100010];
long long int f[100010];
long long findd(long long x) { return f[x] == x ? x : f[x] = findd(f[x]); }
int main()
{
    long long int m;
    long long int n;
    scanf("%lld%lld",&n,&m);
    for(int i=1;i<=n;i++)
    {
        f[i]=i;
        s[i]=1;
    }
    for(int i=0;i<m;i++)
    {
        scanf("%lld%lld",&a[i],&b[i]);
    }
    long long int sum=(n-1)*n/2;
    for(int i=m-1;i>=0;i--)
    {
        ans[i]=sum;
        int aa=findd(a[i]);
        int bb=findd(b[i]);
        if(aa!=bb)
        {
            f[bb]=aa;
            sum-=s[aa]*s[bb];
            s[aa]+=s[bb];
        }
    }
    for(int i=0;i<m;i++)
        printf("%lld\n",ans[i]);
}


Measured memory_bytes: 5248
n = int(input())
lst = list(map(int,input().split()))
cnt = 10000000000000000000
for i in range(n):
  temp = 0
  while (lst[i]%2==0):
    lst[i] = lst[i]//2
    temp += 1
  if temp < cnt:
    cnt = temp
print(cnt)

Measured memory_bytes: 3060
#pragma region
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define repc(i, m, n) for (int i = m; i < n; i++)
#define reprc(i, m, n) for (int i = m; i > n; i--)
#define all(v) v.begin(), v.end()
#define INF 1e9
#define EPS 1e-10
using namespace std;
typedef long long ll;
#pragma endregion

int main()
{
    int a,b;
    cin >> a >> b;
    string s,t;

    rep(i, b){
        s += to_string(a);
    }

    rep(i, a){
        t += to_string(b);
    }

    cout << min(s,t) << endl;
}

Measured memory_bytes: 256
#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>;

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

// 無限大の値
const ll INF = 1LL << 60;

// 入力
int N;
long long h[110000];

// DP テーブル
long long dp[110000];

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

    rep(i,N){
        cin >> h[i];
    }

    rep(i,110000){
        dp[i] = INF;
    }

    dp[0] = 0;

    for(int i=1;i<N;i++){
        for(int k=1;k<=K;k++){
            if((i-k)>=0){
            chmin(dp[i],dp[i-k]+abs(h[i]-h[i-k]));
            //printf("%d %d %d %lld\n",i,k,i-k,dp[i]);
            }
        }
    }

    // 解を得て出力
    cout << dp[N-1] << endl;
}

Measured memory_bytes: 1920
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <queue>
#include <vector>
#include <string>
#include <sstream>
#include <utility>
#include <deque>
#include <numeric>
#include <map>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
 
using namespace std;
 
typedef pair<int,int> P;
typedef long long ll;

const int  SIZE = 200005;
const int INF = 1e9 + 10;

int N, M, L, Q;

int main() {
    cin >> N >> M >> L;
    vector< vector<int> > dist(N, vector<int>(N,INF));
    rep(i,N) dist[i][i] = 0;
    rep(i,M) {
      int a, b, c;
      cin >> a >> b >> c;
      --a, --b;
      dist[a][b] = dist[b][a] = c;
    }
    rep(k,N) rep(i,N) rep(j,N) chmin(dist[i][j], dist[i][k] + dist[k][j]);
    vector< vector<int> > dist2(N, vector<int>(N,INF));
    rep(i,N) rep(j,N) {
      if (dist[i][j] <= L) dist2[i][j] = 1;
    }
    rep(k,N) rep(i,N) rep(j,N) chmin(dist2[i][j], dist2[i][k] + dist2[k][j]);
    cin >> Q;
    rep(i,Q) {
      int s, t;
      cin >> s >> t;
      --s, --t;
      int ans = dist2[s][t]-1;
      if (dist2[s][t] == INF) ans = -1;
      cout << ans << endl;
    }
}

Measured memory_bytes: 3880
#include <bits/stdc++.h>
#define xx first
#define yy second
#define mp make_pair
#define pb push_back
#define mset(x, y) memset(x, y, sizeof x)
#define mcpy(x, y) memcpy(x, y, sizeof x)
using namespace std;

typedef long long LL;
typedef pair <int, int> pii;

inline int Read()
{
	int x = 0, f = 1, c = getchar();
	for (; !isdigit(c); c = getchar())
		if (c == '-')
			f = -1;
	for (;  isdigit(c); c = getchar())
		x = x * 10 + c - '0';
	return x * f;
}

const int MAXN = 3005;

int n, a[MAXN], par[MAXN];
vector <int> adj[MAXN];
bool f[MAXN], g[MAXN];

inline void Dfs(int x, int p)
{
	if (p)
		adj[x].erase(find(adj[x].begin(), adj[x].end(), p));
	par[x] = p;
	for (auto y : adj[x])
		Dfs(y, x), f[x] |= !f[y] && a[x] > a[y];
}

inline void Dfs(int x)
{
	int pre = 0, suf = 0;
	for (auto y : adj[x])
		suf += !f[y] && a[x] > a[y];
	for (int i = 0; i < adj[x].size(); i ++)
	{
		if (i)
			pre += !f[adj[x][i - 1]] && a[x] > a[adj[x][i - 1]];
		suf -= !f[adj[x][i]] && a[x] > a[adj[x][i]];
		if ((!g[x] && a[x] > a[par[x]]) || pre || suf)
			g[adj[x][i]] = 1;
		Dfs(adj[x][i]);
	}
}

int main()
{
#ifdef wxh010910
	freopen("data.in", "r", stdin);
#endif
	n = Read();
	for (int i = 1; i <= n; i ++)
		a[i] = Read();
	for (int i = 1, x, y; i < n; i ++)
		x = Read(), y = Read(), adj[x].pb(y), adj[y].pb(x);
	a[0] = INT_MAX;
	Dfs(1, 0);
	Dfs(1);
	for (int i = 1; i <= n; i ++)
		if (f[i] || (!g[i] && a[i] > a[par[i]]))
			printf("%d ", i);
	putchar(10);
	return 0;
}


Measured memory_bytes: 512
import math
n = int(input())
_n = int(n)
ans = []
i = 2
while i <= math.sqrt(n):
    if n%i == 0:
        n = n/i
        ans.append(str(i))
    else:
        i += 1
if n != 1:
    ans.append(str(int(n)))
print(str(_n) + ': ' + " ".join(ans))


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

int main(){
    int cnt_five = 0;
    int cnt_seven = 0;
    vector<int> bun(3);
    cin >> bun.at(0) >> bun.at(1) >> bun.at(2);

    for (int i=0; i<3; i++){
        if (bun.at(i) == 5) cnt_five++;
        else if (bun.at(i) == 7) cnt_seven++;
    }

    if ((cnt_five == 2) && (cnt_seven == 1)) cout << "YES" << endl;
    else cout << "NO" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <math.h>
using namespace std;

const int MAXN = 2000 + 10;
int N, Z, W;
int A[MAXN];
int f[MAXN][MAXN];

int main() {
	register int i;
	scanf("%d%d%d", &N, &Z, &W);
	for(i = 1; i <= N; ++i)
		scanf("%d", A + i);
	printf("%d\n", N == 1 ? abs(A[N] - W) : max(abs(A[N] - A[N - 1]), abs(A[N] - W)));
	return 0;
}

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

#define rep(i,n) for(ll i=0;i<(n);++i)
using ll = long long;
using pll = pair<ll,ll>;
constexpr ll INF = (1LL<<60);
constexpr ll MOD = (1e9+7);
//constexpr ll MOD = (998244353);
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;}
#if loc||debg||local||debug
void dump(){cerr<<endl;}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){cerr<<h<<", ";dump(forward<Ts>(t)...);}
#else
template<class T,class... Ts> void dump(T&& h, Ts&&... t){}
#endif
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T> ostream &operator<<(ostream& os,vector<T>const& v){for(auto const& vi:v)os<<vi<<" ";return os;}
template<class T>vector<T> vec(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto vec(size_t a, Ts... ts){return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...));}
template<class T>vector<T> _vec(size_t a,T v){return vector<T>(a,v);}
template<class T, class... Ts>auto _vec(size_t a, Ts... ts){return vector<decltype(_vec<T>(ts...))>(a, _vec<T>(ts...));}

int main(){

  double n,k;
  cin>>n>>k;
  vector<double> a(n);
  cin>>a;

  vector<double> p(n);
  rep(i,n){
    p[i] = a[i]*(a[i]+1.0)/a[i]/2.0;
  }

  vector<double> sum(n+1);
  rep(i,n)sum[i+1]=sum[i]+p[i];

  double ans = 0.0;
  rep(i,n-k+1)chmax(ans,sum[i+k]-sum[i]);
  cout<<fixed<<setprecision(10);
  cout<<(ans)<<endl;

}

Measured memory_bytes: 4992
#include<bits/stdc++.h>
#define U [1<<18]={}
#define G )+((c=A[a]+A[P[a]]+C[a])%k?c:0)-M(
typedef long long L;using namespace std;map<L,L>T U;
L P U,E U,Z U,H U,C U,A U,O U,X U,B U,k,n,a,b,c;char s U;
L D(L a){L d;Z[a]=1;for(map<L,L>::iterator I=T[a].begin();I!=T[a].end();I++)
  d=I->first,!Z[d]?P[d]=a,E[d]=E[a]+1,C[d]=I->second,D(d),Z[a]+=Z[d],!H[a]|Z[H[a]]<Z[d]?H[a]=d:0:0;}
L M(L i){return i?B[i]+M(i^i&-i):0;}
L S(L a,L i){for(a=M(i++G i);i<2e5;i+=i&-i)B[i]+=a;}
L K(L f){a=X[f];n=X[b];return a-n?M(O[E[a]<E[n]?a=n,n=b,b=f,n:f]G O[a])+K(P[a]):abs(M(O[f])-M(O[b]));}
main(){for(cin>>n>>k;--n;T[a][b]=T[b][a]=c)cin>>a>>b>>c;
       for(D(a=b=0);n<*Z;a=H[P[++n]]-n?n:0)for(;!b|a;S(a=H[a],O[a]=++b))X[a]=n;
       for(cin>>a;cin>>s>>a>>b;*s&2?cout<<K(a)<<endl,0:A[a]+=b,S(H[a],O[a]),S(a,O[a]-1));}

Measured memory_bytes: 39592
#include <bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const string ln = "\n";
constexpr int INF = 1001001001;
constexpr int MOD = 1000000007;

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

  ll x;
  cin >> x;

  ll c = 100;
  ll i = 0;
  while(c < x) {
    c += (c / 100);
    i++;
  }

  cout << i << ln;

  return 0;
}

Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
int x,y,a,b,c;
long long p[100009],q[100009],r[100009],ans;
bool cmp(long long A,long long B) {
	return A>B;
}
long long f(int A,int tot) {
	return p[A]+q[tot-A];
}
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin>>x>>y>>a>>b>>c;
	for(int i=1;i<=a;i++) cin>>p[i];
	for(int i=1;i<=b;i++) cin>>q[i];
	for(int i=1;i<=c;i++) cin>>r[i];
	sort(p+1,p+a+1,cmp);
	sort(q+1,q+b+1,cmp);
	sort(r+1,r+c+1,cmp);
	for(int i=1;i<=a;i++) p[i]+=p[i-1];
	for(int i=1;i<=b;i++) q[i]+=q[i-1];
	for(int i=1;i<=c;i++) r[i]+=r[i-1];
	for(int i=0;i<=min(c,x+y);i++) {
		int tot=x+y-i;
		long long L=max(tot-y,0),R=min(x,tot),nw=0;
		while(L<=R-5) {
			long long mid=L+(R-L)/3,mmid=mid+R>>1;
			if(f(mid,tot)>f(mmid,tot)) R=mmid-1;
			else L=mid+1;
		}
		for(int j=L;j<=R;j++) nw=max(nw,f(j,tot));
		ans=max(ans,r[i]+nw);
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T> using vt = vector<T>;
template<class T> using vvt = vector<vt<T>>;
template<class T> using ttt = tuple<T,T>;
using tii = tuple<int,int>;
using vi = vector<int>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define mt make_tuple
#define ALL(a) (a).begin(),(a).end()
#define FST first
#define SEC second
#define DEB cerr<<"!"<<endl
#define SHOW(a,b) cerr<<(a)<<" "<<(b)<<endl
#define DIV int(1e9+7)
const int INF = (INT_MAX/2);
const ll LLINF = (LLONG_MAX/2);
const double eps = 1e-8;
//const double PI = M_PI;  
inline ll pow(ll x,ll n,ll m){ll r=1;while(n>0){if((n&1)==1)r=r*x%m;x=x*x%m;n>>=1;}return r%m;}
inline ll lcm(ll d1, ll d2){return d1 / __gcd(d1, d2) * d2;}
 
/* Coding space */
int main(){
  int a,b,c; cin >> a >> b >> c;
  int ma = 0;
  ma=max(a,max(b,c));
  int t = 0;
  t += ma-a  + ma-b + ma-c;
  cerr << t << endl;
  int ans = t/2;
  if(t % 2 == 1) ans += 2;
  cout << ans << endl;
}

Measured memory_bytes: 256
x, y = map(int, input().split())
xgroup = ''
ygroup = ''
a = [1, 3, 5, 7, 8, 10, 12]
b = [4, 6, 9, 11]
c = [2]
for i in a:
    if x == i:
        xgroup = 'a'
for i in a:
    if y == i:
        ygroup = 'a'
for i in b:
    if x == i:
        xgroup = 'b'
for i in b:
    if y == i:
        ygroup = 'b'
for i in c:
    if x == i:
        xgroup = 'c'
for i in c:
    if y == i:
        ygroup = 'c'
if xgroup == ygroup:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 38384
/*
 KUNAL RAUT (ZUKONIT14)  :- "DO WHAT YOU LIKE!"
 -PICT,PUNE! :)
 */
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define int long long
#define ld long double
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define mod 1000000007
#define mod9 1000000009
#define pi 3.1415926535
#define MAXN 1000001
#define N 1000001
#define MAX2N 1*1000 + 10
#define all(v) v.begin(), v.end()
#define ms(s, n) memset(s, n, sizeof(s))
#define prec(n) fixed<<setprecision(n)
#define forci(p,n) for(ll i=p;i<(ll)n;i++)
#define forcj(p,n) for(ll j=p;j<(ll)n;j++)
#define bolt ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define bits(a) __builtin_popcount(a)
#define test ll t;cin>>t;for(ll testi=0;testi<t;testi++)
ll zero=0;
ll one=1;
ll gcd(ll a,ll b){    if(b==0) return a;    return gcd(b,a%b);}
ll lcm(ll a,ll b) {    return (a/gcd(a,b)*b);}
ll expo(ll x, ll y) {ll res=1;x=x%mod;while(y>0){if(y&1)res=(1ll*res*x)%mod;
    y=y>>1;x=(1ll*x*x)%mod;} return res;}
ll ncr(ll n,ll r){ ll res=1; if(r>n-r)r=n-r; for(ll i=0;i<r;i++) {  res*=n-i;  res/=i+1; } return res;}
ll max(ll a,ll b){return (a>b)?a:b;}
bool prime(ll n){ll i;for(i=2;i<=sqrt(n);i++){if(n%i==0)return false;}return true;}
bool sortbysec(const pair<ll,ll> &a,const pair<ll,ll> &b)
{   if(a.second == b.second)
    return a.first < b.first;
    return (a.second < b.second);}
//https://www.youtube.com/watch?v=WTJSt4wP2ME

ll rr[]={0,1,1,1,0,-1,-1,-1,};
ll cc[]={1,1,0,-1,-1,-1,0,1};

signed main()
{
    bolt;
    ll n;cin>>n;ll x,flg=1;
    forci(0,n)
    {
        cin>>x;
        if(x%2==0)
        {
            if(x%5!=0 && x%3!=0)
                flg=0;
        }
    }
    if(flg)
        cout<<"APPROVED";
    else
        cout<<"DENIED";
}


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

using namespace std;
#define taskname "A"
#define pb	push_back
#define mp  make_pair

typedef long double ld;
typedef long long ll;
typedef pair<int,int> ii;
const int maxn = 5000 + 5;
const int mod = 1e9 + 7;
int k , q , d[maxn];
int a[maxn];
int n , m , x;

void solve(){
    cin >> n >> x >> m;
    ll sum = 0;
    for(int i = 0 ; i < k ;  ++i){
        sum += (d[i] % m == 0 ? m : d[i] % m);
    }
    sum *= ((n - 1) / k);
    for(int i = 0 ; i < (n - 1) % k ; ++i){
        sum += (d[i] % m == 0 ? m : d[i] % m);
    }
    sum += x % m;
    cout << n - 1 - sum / m << endl;
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	if(fopen(taskname".INP","r")){
        freopen(taskname".INP", "r",stdin) ,
        freopen(taskname".OUT", "w",stdout);
	}
    cin >> k >> q;
    for(int i = 0 ; i < k ; ++i){
        cin >> d[i];
    }
    while(q--)solve();
}


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

using namespace std;

vector<int> get_divisors (int n) {
  vector<int> v;
  for (int i = 1; i <= sqrt(n); i++) {
    if (n % i == 0) {
      int I = n / i;

      v.push_back(i);
      if (i != I) v.push_back(I);
    }
  }
  return v;
}

int gcd (int a, int b) {
  return (b == 0) ? a : gcd(b, a % b);
}

int main () {
  int A, B, K;
  cin >> A >> B >> K;

  vector<int> divisors = get_divisors(gcd(A, B));
  vector<int> common_divisors;

  copy_if(divisors.begin(), divisors.end(), back_inserter(common_divisors), [&](int x) {
    return B % x == 0;
  });
  sort(common_divisors.begin(), common_divisors.end(), greater<int>());

  cout << common_divisors.at(K - 1) << "\n";
}


Measured memory_bytes: 256
import java.io.BufferedReader; 
import java.io.*;
import java.io.InputStreamReader; 
import java.util.Scanner; 
import java.util.StringTokenizer; 
import java.util.*;
import java.math.*;
public class Main 
{ 
    static class FastReader 
    { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader()
        { 
            br = new BufferedReader(new
                     InputStreamReader(System.in)); 
        } 
  
        String next()
        { 
            while (st == null || !st.hasMoreElements()) 
            { 
                try
                { 
                    st = new StringTokenizer(br.readLine()); 
                } 
                catch (IOException  e) 
                { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } 
  
        int nextInt() 
        { 
            return Integer.parseInt(next()); 
        } 
  
        long nextLong() 
        { 
            return Long.parseLong(next()); 
        } 
  
        double nextDouble() 
        { 
            return Double.parseDouble(next()); 
        } 
  
        String nextLine() 
        { 
            String str = ""; 
            try
            { 
                str = br.readLine();
            } 
            catch (IOException e) 
            { 
                e.printStackTrace(); 
            } 
            return str; 
        } 
    } 
   public static void main(String args[])
    {
        FastReader sc=new FastReader();
        PrintWriter pw=new PrintWriter(System.out);
        int t=1;//sc.nextInt();
        while(t-->0)
        {
           int n=sc.nextInt(),f=0,a[]=new int[n];
           for(int i=0;i<n;i++)
           {
             a[i]=sc.nextInt();
           }int ans[]=new int[n],p=0,q=n-1;
           for(int i=n-1;i>=0;i-=2)
           {
             ans[p++]=a[i];
             if(i-1>=0)
             ans[q--]=a[i-1];
           }
           for(int w:ans)
           pw.print(w+" ");
           pw.println();
        }
           pw.close();
    }
}
  

Measured memory_bytes: 59688
// AOJ ITP2_11_D Enumeration of Combinations
// 2019.3.10 bal4u

#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>

#if 1
#define gc() getchar_unlocked()
#define pc(c) putchar_unlocked(c)
#else
#define gc() getchar()
#define pc(c) putchar(c)
#endif
int in()
{
	int n = 0, c = gc();
	do n = 10 * n + (c & 0xf), c = gc(); while (isdigit(c));
	return n;
}

void out(int n)
{
	int i;
	char ob[30];

	if (!n) pc('0');
	else {
		i = 0; while (n) ob[i++] = n % 10 + '0', n /= 10;
		while (i--) pc(ob[i]);
	}
}

void outs(char *s) { while (*s) pc(*s++); }

void pr(int k)
{
	int j;
	out(k), pc(':');
	for (j = 0; k; j++) {
		if (k & 1) pc(' '), out(j);
		k >>= 1;
	}
	pc('\n');
}

void combi(int lim, int from, int n)
{
	int i, m;

	for (i = from+1; i <= lim; i++) {
		m = n;
		m &= ~(1 << from);
		m |= 1 << i;
		pr(m);
		if (from > 0) combi(i - 1, from - 1, m);
	}
}

int main()
{
	int n, k, b;

	n = in(), k = in(), b = (1 << k)-1;
	pr(b);
	combi(n-1, k-1, b);
	return 0;
}


Measured memory_bytes: 2112
#include <bits/stdc++.h>
using namespace std;
using ll=long long int;
using ld=long double;
using VI=vector<ll>;
using VD=vector<ld>;
using VVI=vector<VI>;
using VC=vector<char>;
using VVC=vector<VC>;
using VS=vector<string>;
using PLL =pair<ll,ll>;
using PLD=pair<ld,ld>;
using VPLL=vector<PLL>;
#define print(x) std::cout<<x<<"\n"
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define repd(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define SZ(x) ((ll)(x).size())
#define MAX(x) *max_element((x).begin(),(x).end())
#define MIN(x) *min_element((x).begin(),(x).end())
#define SORTR(x) sort((x).rbegin(),(x).rend())
#define SORT(x) sort((x).begin(),(x).end())
#define SUM(x) accumulate((x).begin(),(x).end(), 0)
#define FILL(x,a) fill(x.begin(),x.end(),a)
#define EACH(i,x) for(typeof((x).begin()) i=(x).begin(); i!=(x).end(); ++i)
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())

const ll INF = 1e18;
const ld EPS   = 1e-10;
const int MOD  = int(1e9)+7;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template <class BidirectionalIterator>
bool next_partial_permutation(BidirectionalIterator first, BidirectionalIterator middle,BidirectionalIterator last){reverse(middle, last); return next_permutation(first , last);}
ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
ll GCD(VI v){ll a = v[0]; for (ll i = 1; i<SZ(v); i++) {a = gcd(a, v[i]);} return a;}
ll LCM(VI v){ll a = v[0]; for (ll i = 1; i<SZ(v); i++) {a = lcm(a, v[i]);} return a;}
VI Bit2Vector(const ll bit, ll n) {	VI s;	rep(i,n) if (bit & (1 << i)) s.push_back(i); return s;}

//https://atcoder.jp/contests/dp/tasks/dp_a
void Main()
{
	ll n,m,l; ll res=0;
	string s,t,u; string sres="No or NO";

	cin>>n;
	VI h(n+1,0),dp(n+1,0);
	rep(i, n) cin >> h[i];

	for (ll i = 1; i < n; ++i) {
		dp[i]=dp[i-1]+abs(h[i]-h[i-1]);
		if(i>1)dp[i]=min(dp[i],dp[i-2]+abs(h[i]-h[i-2]));
	}

	res=dp[n-1];
	cout << res << "\n";
	return;
}

int main()
{
	std::cin.tie(0);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Main();
}


Measured memory_bytes: 1792
import sys
from collections import deque


def input():
    return sys.stdin.readline().rstrip()


def main():
    S =input()
    T =input()
    count =0
    for i in range(3):
        if S[i] ==T[i]:
            count +=1
    print(count)


if __name__ == "__main__":
    main()


Measured memory_bytes: 64668
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE BangPatterns #-}

import Control.Applicative
import Control.Monad
import Control.Arrow
import Data.List
import Data.Maybe
import Data.Char
import qualified Data.ByteString.Char8 as B
import Text.Printf

readInt = ( readLn :: IO Int )
readInts = map ( read :: String -> Int ) . words <$> getLine

getList = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

main = do
	[ a, b, c, x ] <- map read . lines <$> getContents
	print $ length $ filter ( == x ) $ [ i * 500 + j * 100 + k * 50 | i <- [ 0 .. a ], j <- [ 0 .. b ], k <- [ 0 .. c ] ]


Measured memory_bytes: 892
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = Integer.parseInt(sc.next());
		
		int m = n % 500;
		
		long ans =(long)1000* (n / 500) + (m/5) * 5 ;
		
		System.out.println(ans);
	}

}


Measured memory_bytes: 21972
#include <iostream>
#include <iomanip>
using namespace std;
int main(){
  double res=0.0;
  long long N,K; cin>>N>>K;
  for (long long i=1;i<=N;++i){
    long long cnt=i;
    double tmp=1.0;
    while (cnt<K){
      cnt*=2;
      tmp/=2;
    }
    res+=tmp;
  }
  res/=N;
  cout<<fixed<<setprecision(10)<<res<<endl;
}
      
    

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

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


int main() {

    ////////////////////////////////////////
    /* 入力受け取り */
    ////////////////////////////////////////

    /* 縦と横の長さ */
    int height, width;
    cin >> height >> width;

    /* 盤面 */
    vector<string> field(height);
    for (int h = 0; h < height; ++h) cin >> field[h];

    /* スタート地点とゴール地点 */
    int sx = 0, sy = 0, gx = height-1, gy = width - 1;

    ////////////////////////////////////////
    /* 幅優先探索の初期設定 */
    ////////////////////////////////////////

    // 各セルの最短距離 (訪れていないところは -1 としておく)
    vector<vector<int> > dist(height, vector<int>(width, -1)); 
    dist[sx][sy] = 0; // スタートを 0 に

    // 「一度見た頂点」のうち「まだ訪れていない頂点」を表すキュー
    queue<pair<int, int> > que; 
    que.push(make_pair(sx, sy)); // スタートを push

    int cnt = 0;
    rep(h,height) rep(w,width){
      if(field[h][w] == '#') cnt++;
    }


    ////////////////////////////////////////
    /* 幅優先探索を実施 */
    ////////////////////////////////////////    

    /* キューが空になるまで */
    while (!que.empty()) {
      pair<int, int> current_pos = que.front(); // キューの先頭を見る (C++ ではこれをしても pop しない)
      int x = current_pos.first;
      int y = current_pos.second;
      que.pop(); // キューから pop を忘れずに

      // 隣接頂点を探索
      for (int direction = 0; direction < 4; ++direction) {
        int next_x = x + dx[direction];
        int next_y = y + dy[direction];
        if (next_x < 0 || next_x >= height || next_y < 0 || next_y >= width) continue; // 場外アウトならダメ
        if (field[next_x][next_y] == '#') continue; // 壁はダメ

        // まだ見ていない頂点なら push
        if (dist[next_x][next_y] == -1) {
            que.push(make_pair(next_x, next_y));
            dist[next_x][next_y] = dist[x][y] + 1;
        }
      }
    }


    ////////////////////////////////////////
    /* 結果出力 */
    ////////////////////////////////////////    

    /* 各マスへのスタートからの最短距離を見てみる */
    int bfs = dist[height-1][width-1];
    if(bfs == -1){
      cout << -1 << endl;
      return 0;
    }
    int ans = height * width - (cnt + bfs + 1);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()

#define PI acos(-1.0)
#define INF 10000000

typedef long long ll;

vector< pair<int, pair<int, int> > > vpi;
bool f[1000];
int W, Q, id, w;
char s;

int main(){
	while (cin >> W >> Q){
		if (W + Q == 0)break;
		REP(i, Q){
			cin >> s;
			if (s == 's'){
				cin >> id >> w;
				int c = 0;
				REP(j, W){
					f[j] ? c = 0 : c++;
					if (c == w){
						cout << j - w + 1 << endl;
						FOR(k, j - w + 1, j + 1){
							f[k] = 1;
						}
						pair<int, pair<int, int> > pi;
						pi.first = id;
						pi.second.first = j - w + 1;
						pi.second.second = j + 1;
						vpi.push_back(pi);
						break;
					}
					if (j == W - 1){
						cout << "impossible\n";
					}
				}
			}
			else{
				cin >> id;
				REP(j, vpi.size()){
					if (vpi[j].first == id){
						FOR(k, vpi[j].second.first, vpi[j].second.second){
							f[k] = 0;
						}
					}
				}
			}
		}
		cout << "END\n";
		vpi.clear();
		REP(i, W){
			f[i] = 0;
		}
	}
}

Measured memory_bytes: 1196
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(void)
{
    int i = 0;
    
    long long int k;
    
    char a;
    
    char s[100];
    
    scanf("%s\n", s);
    scanf("%lld", &k);
    
    while(1) {
        if(s[i] == '1') {
            i++;
        } else {
            a = s[i];
            break;
        }
    }
    
    //printf("%c", a);
    //printf("%d", i);
    
    if(k <= i) {
        printf("1\n");
    } else {
        printf("%c\n", a);
    }
    
    
    return 0;
}


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

int main()
{
    string s[3];
    cin >> s[0] >> s[1] >> s[2];
    int turn = 0;

    while(1)
    {
        if (s[turn].empty()) {
            cout << char(turn + 'A') << endl;
            return 0;
        }
        int tmp = s[turn][0] -'a';
        s[turn].erase(0, 1);
        turn = tmp;
    }
}


Measured memory_bytes: 256
n = int(input())
cnt = [[0] * 10 for _ in range(10)]
for i in range(1, n+1):
    x, y = int(str(i)[0]), int(str(i)[-1])
    cnt[x][y] += 1
res = 0
for i in range(1, 10):
    for j in range(1, 10):
        res += cnt[i][j] * cnt[j][i]
print(res)


Measured memory_bytes: 40428
//競技プログラミング用のテンプレート
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <string>
#include <math.h>

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

using namespace std;
using ll = long long int;
using p = pair<int, int>;
using pl = pair<ll, ll>;
using v = vector<int>;
using vd = vector<double>;
using vs = vector<string>;
using vl = vector<ll>;

int main()
{
    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;
    int count = 0;
    if(n == 1)
    {
        cout << 0 << endl;
        return 0;
    }
    rep(i, n - 1)
    {
        if(s[i] == 'R' && s[i + 1] == 'R') count++;
    }
    rep(i, n)
    {
        if(i == 0) continue;
        if(s[i - 1] == 'L' && s[i] == 'L') count++;
    }
    for(int i = 0; i < n - 1; i++)
    {
        if(s[i] == s[i + 1]) continue;
        for(int j = i + 1; j < n; j++)
        {
            if(s[i] == s[j])
            {
                k--;
                count += 2;
                i = j - 1;
                break;
            }
            if(j == n - 1){
                k--;
                count++;
                i = j - 1;
            }
        }
        if(k <= 0) break;
    }
    cout << count << endl;
}

Measured memory_bytes: 512
def training():
	N = int(input())

	A = [0]

	for i in range(N):
		A.append(int(input()))

	counter = 1
	index = 1
	#judge = [1]
	if A[index] == 2:
		print(counter)
		return
	counter += 1
	index = A[index]
	for i in range(N):
		#if A[index] in judge:
			#print("-1")
			#return
		if A[index] == 2:
			print(counter)
			return
		counter += 1
		#judge.append(A[index])
		index = A[index]
	print("-1")
	

training()
	

Measured memory_bytes: 7188
#include <cstdio>

char s[10];

int main(){
  scanf("%s", s);

  bool ans = false;

  for(int i = 0; ; i++){
    if(s[i + 1] == 0) break;
    if(s[i] == 'A' && s[i + 1] == 'C') ans = true;
  }

  puts(ans ? "Yes" : "No");
  return 0;
}

Measured memory_bytes: 128
def main():
    N = int(input())
    A = list(map(int, input().split()))

    s = True
    for a in A:
        if a % 2 == 0:
            if a % 3 == 0 or a % 5 == 0:
                continue
            s = False
            break

    print('APPROVED' if s else 'DENIED')


if __name__ == "__main__":
    main()


Measured memory_bytes: 9032
n = int(input())
v = list(map(int, input().split()))
t = [0]
s = 2000000000
for i in range(0, n):
  t.append(t[i]+v[i])
for i in range(0, n-1):
  s = min(s, abs(t[n]-2*t[i+1]))
print(s)

Measured memory_bytes: 23796