akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int po[]=new int[n];
        int gcd1[]=new int[n];
        int gcd2[]=new int[n];
        for(int i=0;i<n;i++){
            po[i]=sc.nextInt();
        }
        for(int i=0;i<n;i++){
            if(i==0)gcd1[0]=po[0];
            else{
                gcd1[i]=gcd(gcd1[i-1],po[i]);
            }
        }
        for(int i=n-1;i>=0;i--){
            if(i==n-1)gcd2[n-1]=po[n-1];
            else{
                gcd2[i]=gcd(gcd2[i+1],po[i]);
            }
        }
        int max=0;
        for(int i=0;i<n;i++){
            if(i==0)max=Math.max(max,gcd2[1]);
            else if(i==n-1)max=Math.max(max,gcd1[n-2]);
            else{
                max=Math.max(max,gcd(gcd1[i-1],gcd2[i+1]));
            }
        }
        
        System.out.println(max);
    }
    public static int gcd(int m, int n) {
        if(m < n) return gcd(n, m);
        if(n == 0) return m;
        return gcd(n, m % n);
    }
}

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

int main(){
	char str[100];
	int count = 0;
	
	while (scanf("%s", str) != EOF){
		int o = 0;
		for (int i = 0; i < strlen(str) / 2; i++){
			if (str[i] == str[strlen(str) - 1 - i]) o++;
		}
		if (o == strlen(str)/2) count++;
	}

	printf("%d\n", count);
	return 0;
}

Measured memory_bytes: 968
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define int long long

signed main(){
    int N;
    cin >>N;
    cout<<3*N*N<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
const int MOD = 1000000007;
const int INF = 1010000000;
const double EPS = 1e-10;
using namespace std;
//cout << fixed << setprecision(0)
int main() { 
  ll a,b;cin >> a >> b;
  int cnt;
  while(a<=b){
    a *= 2;
    cnt++;
  }
  cout << cnt;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int a,b,c,d,e;
string s;
int main(){
    ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
    cin>>s;
    if(s[0]==s[1]||s[1]==s[2]||s[3]==s[2]){
        cout<<"Bad";
        return 0;
    }else{
        cout<<"Good";
    }
    return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
using P   = pair<ll, ll>;
using mat = vector<vector<ll>>;
typedef string::const_iterator State;
class ParseError {};

void IOS() { ios::sync_with_stdio(false), cin.tie(0); }

const ll INF = 1e16;
const ll INM = 114514;
const ll MOD = 1e9 + 7;
const ld EPS = 1e-12;

template <typename T>
void dump(T x) { cout << x << endl; }
void dumpf(ld x, int t) { cout << setprecision(t) << fixed << x << endl; }
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
	fill((T *)array, (T *)(array + N), val);
}
inline ll mod(ll a, ll b) {
	if (a > 0) return a % b;
	if (a % b == 0) return 0;
	ll x = -a / b + 1;
	a += x * b;
	return a % b;
}
ll powm(ll a, ll b, ll c) {
	if (b == 0)
		return 1;
	else if (b % 2 == 0) {
		ll d = powm(a, b / 2, c);
		return (d * d) % c;
	} else
		return (a * powm(a, b - 1, c)) % c;
}
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 dx[4] = {1, 0, -1, 0};
ll dy[4] = {0, 1, 0, -1};

int main() {
	IOS();
	ll a, b;
	cin >> a >> b;
	if (abs(a - b) % 2 == 0) {
		dump((a + b) / 2);
	} else {
		dump("IMPOSSIBLE");
	}
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
  int a,b;
  scanf("%d%d",&a,&b);
  int all = 1,count = 0;
  while(all<=b-1){
    all -= 1;
    all += a;
    count++;
  }
  printf("%d\n",count);
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1001001001;
int s[300000] = {};

int main() {
  int N, M;
  cin >> N >> M;
  if(N%2 == 1) {
    for(int i = 0; i < (M+1)/2; i++) {
      cout << i+1 << " " << (M+1)/2 * 2 + 1 - i  << endl;
    }
    for(int i = 0; i < M / 2; i++) {
      cout << (M+1)/2 * 2 + 2 + i << " " << (M+1)/2 * 2 + 1 + 2 * (M / 2) - i << endl;
    }
  } else {
    for(int i = 0; i < (M+1)/2; i++) {
      cout << i+1 << " " << (M+1)/2 * 2 - i  << endl;
    }
    for(int i = 0; i < M / 2; i++) {
      cout << (M+1)/2 * 2 + 1 + i << " " << (M+1)/2 * 2 + 1 + 2 * (M / 2) - i << endl;
    }
  }
  return 0;
}

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

const double PI = acos(-1);
const double EPS = 1e-15;
using ll = long long;
using ull = unsigned long long;
const int inf = 2e9;
const ll INF = 2e18;
const ll MOD = 1e9+7;
const ll MOD1 = 998244353;
typedef pair<ll,ll> P;

#define rep(i,a,b) for (int i = (a); i < (b); i++)
#define rrep(i,a,b) for (int i = (a); i >= (b); i--)
#define REP(i,n) rep(i,0,n)
#define RREP(i,n) rrep(i,n,0)
#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second
//#define mp make_pair

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

  int y,m,d;
  scanf("%d/%d/%d",&y,&m,&d);
  cout << (m >= 5? "TBD":"Heisei") << endl;

  return 0;
}


Measured memory_bytes: 256
#![allow(dead_code)]
#![allow(unused_imports)]
#![allow(non_camel_case_types)]
#![allow(non_snake_case)]
use ascii::{AsciiChar, AsciiStr, AsciiString};
use indexmap::IndexMap;
use itertools::*;
use libm::*;
use num::*;
use ordered_float::OrderedFloat;
use permutohedron::LexicalPermutation;
use proconio::marker::{Bytes, Chars};
use proconio::{fastout, input};
use std::cmp::{max, min, Ordering};
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
use std::mem::swap;

type query = (usize, usize, usize, usize);

fn calc(q: &Vec<query>, A: &Vec<usize>) -> usize {
    let mut res = 0;
    for (a, b, c, d) in q.iter() {
        if A[*b] - A[*a] == *c {
            res += *d
        }
    }
    res
}

fn dfs((q, n, m): (&Vec<query>, usize, usize), A: &mut Vec<usize>, res: &mut usize) {
    if A.len() > n {
        let p = calc(q, A);
        *res = max(*res, p);
        return
    }
    let e = A.last().unwrap();
    for i in *e..=m {
        A.push(i);
        dfs((q, n, m), A, res);
        A.pop();
    }

}

fn main() {
    input!(n:usize, m:usize, q:usize, v:[(usize, usize, usize, usize); q]);
    let mut A = vec![1];
    let mut ans = 0;
    dfs((&v, n, m), &mut A, &mut ans);
    println!("{}", ans);
}


Measured memory_bytes: 2140
#include <iostream>
#include <algorithm>
#include <set>
#include <string>
#include <sstream>
#include <cstdlib>

using namespace std;

typedef long long ll;
const ll INF=(1LL<<50);

ll DecToBaseNum(ll num,int base){
  string s;
  ll res=0;
  while(num){
    stringstream ss;
    ss<<(num%base);
    if(num%base>9)return -1;
    s=ss.str()+s;
    num/=base;
  }
  for(int i=0;i<s.size();i++)res=res*10+(s[i]-'0');
  return res;
}

ll A,B,C;
int main(){
  while(cin>>A>>B>>C&&!(A==-1&&B==-1&&C==-1)){
    bool ok=false;
    for(int i=2;i<=16;i++){
      ll a=DecToBaseNum(A,i);
      if(a==B){
	ok=true;
	break;
      }
    }
    if(!ok)cout<<-1<<endl;
    else{
      ll cur=B;
      ok=true;
      for(int i=A+1;i<=C;i++){
	ll nxt=INF;
	for(int j=2;j<=16;j++){
	  ll a=DecToBaseNum(i,j);
	  if(a>=cur&&nxt>a)nxt=a;
	}
	if(nxt==INF){
	  ok=false;
	  break;
	}
	cur=nxt;
      }
      if(!ok)cout<<-1<<endl;
      else cout<<cur<<endl;
    }
  }
  return 0;
}

Measured memory_bytes: 944
#include <bits/stdc++.h>
using namespace std;
/*
	__________   _____     _________   __            __    __________    ________     _________
	----------  | ----\    ---------   \ \   		/ /    |  _______|	| _____  \    ---------
		||      ||    ||  	  ||		\ \		   / /	   | |			| |		\ \	     ||
		||      ||____//      ||		 \ \      / /	   | |_____ 	| |		 | |	 ||
		||      |__ __/       ||		  \ \    / /	   | _____|		| |		 | |	 ||
		||      || \\         ||		   \ \  / /	   	   | |			| |		 | |	 ||
		||      ||  \\     ___||____        \ \/ /         | |_______ 	| |_____/ /   ___||____
		||		|| 	 \\    _________         \__/		   |_________|	|________/	  _________
*/
/********************************************************************/
/*
Codeforces : @a.trivedi
Codechef   : @adityat25
HackerRank : @adityatrivedi

/********************************************************************/
#define M1 1000000007
#define M3 1000000009
#define M2 998244353
#define ll long long
#define pll pair<ll,ll>
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define REPR(i,a,b) for(ll i=b-1;i>=a;i--)
#define forr(i,n) for(ll i=0;i<n;i++)
#define F first
#define S second
#define pb push_back
#define DB pop_back
#define mp make_pair
#define MT make_tuple
#define V(a) vector<a>
#define vi vector<ll>
#define endl '\n'
#define ce(ele) cout<<ele<<' '
#define cs(ele) cout<<ele<<'\n'
#define CASE(t) ll t; cin>>t; while(t--)
/********************************************************************/
const double pi = 3.1415926535;
/********************************************************************/
//FAST IO//
void FAST() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}
/********************************************************************/

int main() {
	FAST();
	const int mxn = 1e5 + 5;
	ll frogs[mxn];
	ll n, k;
	cin >> n >> k;

	for (int i = 0; i < n; i++) {
		cin >> frogs[i];
	}

	ll dp[n + 5] = {};
	dp[n - 1] = 0;
	//dp[n - 2] = dp[n - 1] + abs(frogs[n - 2] - frogs[n - 1]);
	for (int i = n - 2; i >= 0; i--) {
		ll ans = INT_MAX;
		for (int j = 1; j <= k; j++) {
			if (i + j < n) {
				ll val = abs(frogs[i] - frogs[i + j ]) + dp[i + j];
				ans = min(ans, val);
			}
		}
		dp[i] = ans;
	}
	cout << dp[0];


	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int main() {
	string s;
	cin >> s;
	set<char> ss;
	for (int i = 0; i < s.length(); i++) {
		char a = s.at(i);
		if (ss.count(a)) {
			cout << "no" << endl;
			return 0;
		}
		else {
			ss.insert(a);
		}
	}
	cout << "yes" << endl;
}

Measured memory_bytes: 256
import math

n = int(input())

tax_excluded_round_up = math.ceil(n / 1.08)
tax_excluded_round_down = math.floor(n / 1.08)

if math.floor(tax_excluded_round_up * 1.08) == n:
	print(tax_excluded_round_up)
	exit()
if math.floor(tax_excluded_round_down * 1.08) == n:
	print(tax_excluded_round_down)
	exit()

print(":(")

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

using namespace std ;

int main() {
    int n , m , d ; 
    cin >> n >> m >> d ;
    double res = (m - 1) ;
    res /= n ;
    if(d) {
        res *= 2 ;
        res *= (n - d) ; 
        res /= n ;
    }
    cout << fixed << setprecision(10) << res << endl ;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){
	int n;
	cin >> n;
	bool ok = 1;
	for(int i = 0; i < n; i++){
		char a;
		cin >> a;
		if(a == 'Y') ok = 0;
	}
	(ok) ? cout << "Three" : cout << "Four";
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("tune=native")
#pragma GCC target ("avx")

#include <bits/stdc++.h>

// 汎用マクロ
#define ALL_OF(x) (x).begin(), (x).end()
#define REP(i,n) for (long long i=0, i##_len=(n); i<i##_len; i++)
#define RANGE(i,is,ie) for (long long i=(is), i##_end=(ie); i<=i##_end; i++)
#define DSRNG(i,is,ie) for (long long i=(is), i##_end=(ie); i>=i##_end; i--)
#define UNIQUE(v) { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); }
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; }
#define INF 0x7FFFFFFF
#define LINF 0x7FFFFFFFFFFFFFFFLL
#define Yes(q) (q ? "Yes" : "No")
#define YES(q) (q ? "YES" : "NO")
#define DUMP(q) cerr << "[DEBUG] " #q ": " << (q) << " at " __FILE__ ":" << __LINE__ << endl
#define DUMPALL(q) { cerr << "[DEBUG] " #q ": ["; REP(dumpall_i, (q).size()) { cerr << q[dumpall_i] << (dumpall_i == (q).size() - 1 ? "" : ", "); } cerr << "] at " __FILE__ ":" << __LINE__ << endl; }
template<class T> T gcd(const T &a, const T &b) { return a < b ? gcd(b, a) : b ? gcd(b, a % b) : a; }
template<class T> T lcm(const T &a, const T &b) { return a / gcd(a, b) * b; }

// gcc拡張マクロ
#define popcount __builtin_popcount
#define popcountll __builtin_popcountll

// エイリアス
using  ll = long long;
using ull = unsigned long long;
using  ld = long double;
using namespace std;

// モジュール
constexpr ll p = 1000000007LL;

// 処理内容
int main() {
    
    string s; cin >> s;
    ll n = s.size();
    reverse(ALL_OF(s));

    // dp[i][j] := i文字目まで見て，mod13がjの数が何通りか
    vector<vector<ll>> dp(n+1, vector<ll>(13, 0));
    dp[0][0] = 1; // 0の1通り

    ll base = 1;
    REP(i, n) {

        if (s[i] == '?') {
            REP(j, 13) REP(d, 10) {
                ll j2 = (j + base * d) % 13;
                (dp[i+1][j2] += dp[i][j]) %= p;
            }
        } else {
            REP(j, 13) {
                ll j2 = (j + base * (s[i] - '0')) % 13;
                (dp[i+1][j2] += dp[i][j]) %= p;
            }
        }
        
        (base *= 10) %= 13;
    }

    cout << dp[n][5] << endl;
    
}

Measured memory_bytes: 13696
def divisible_length(n):
    min_length = len(str(n))
    for i in range(1, int(n ** 0.5) + 1):
        if n % i == 0:
            min_length = min(min_length, max(len(str(i)), len(str(n // i))))
    return min_length

n = int(input())
print(divisible_length(n))

Measured memory_bytes: 3188
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;

namespace ConsoleApplication1
{
    class Dice : IEquatable<Dice>
    {
        protected string[] val = new string[6];

        public Dice(string[] str)
        {
            Array.Copy(str, val, 6);
        }

        public string this[int index]
        {
            get
            {
                if (index < 6)
                    return val[index];
                return null;
            }
            set
            {
                if (index < 6)
                    val[index] = value;
            }
        }

        public bool Equals(Dice dice2)
        {
            if ((this[0] == dice2[2] && this[5] == dice2[3]) || (this[0] == dice2[3] && this[5] == dice2[2]))
            {
                string tmp = dice2[1];
                dice2[1] = dice2[2];
                dice2[2] = dice2[4];
                dice2[4] = dice2[3];
                dice2[3] = tmp;
            }

            for (int i = 0; i < 3; i++)
            {
                if (this[0] == dice2[0] && this[5] == dice2[5])
                    break;
                string tmp = dice2[0];
                dice2[0] = dice2[1];
                dice2[1] = dice2[5];
                dice2[5] = dice2[4];
                dice2[4] = tmp;
            }

            for (int i = 0; i < 3; i++)
            {
                if (this[1] == dice2[1] && this[4] == dice2[4])
                    break;
                string tmp = dice2[1];
                dice2[1] = dice2[2];
                dice2[2] = dice2[4];
                dice2[4] = dice2[3];
                dice2[3] = tmp;
            }

            if (this[0] == dice2[0] && this[1] == dice2[1] && this[2] == dice2[2] && this[3] == dice2[3] && this[4] == dice2[4] && this[5] == dice2[5])
                return true;
            else return false;
        }
    }
    class Program
    {
        static void Main(string[] args)
        {
            int num = int.Parse(Console.ReadLine());
            Dice[] dices = new Dice[num];

            for(int i=0;i<num;i++)
            {
                dices[i] = new Dice(Console.ReadLine().Split(' '));
            }

            bool res = true;
            for(int i=0;i<num;i++)
            {
                for(int j=i+1;j<num;j++)
                {
                    if (dices[i].Equals(dices[j])) { res = false;  break; }
                }
            }

            Console.WriteLine(res?"Yes":"No");
        }
    }
}

Measured memory_bytes: 8984
main()
{
 int W, H, x, y, r;

 scanf("%d%d%d%d%d", &W, &H, &x, &y, &r);

 if(r <= x && x <= W - r)
  if(r <= y && y <= H - r) 
   printf("Yes\n");
  else printf("No\n");
 else printf("No\n");
  
 return 0;
}

Measured memory_bytes: 584
// kyopro.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

//#include <iostream>
//#include"cpp_kyopro.h"
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
using namespace std;
int main()
{
	int p, q, r,max; cin >> p >> q >> r;
	if (p < q) {
		if (q < r) {
			max = r;
		}
		else max = q;
	}
	else {
		if (p < r) max = r;
		else max = p;
	}
	cout << p + r + q - max << endl;
}

// プログラムの実行: Ctrl + F5 または [デバッグ] > [デバッグなしで開始] メニュー
// プログラムのデバッグ: F5 または [デバッグ] > [デバッグの開始] メニュー

// 作業を開始するためのヒント: 
//    1. ソリューション エクスプローラー ウィンドウを使用してファイルを追加/管理します 
//   2. チーム エクスプローラー ウィンドウを使用してソース管理に接続します
//   3. 出力ウィンドウを使用して、ビルド出力とその他のメッセージを表示します
//   4. エラー一覧ウィンドウを使用してエラーを表示します
//   5. [プロジェクト] > [新しい項目の追加] と移動して新しいコード ファイルを作成するか、[プロジェクト] > [既存の項目の追加] と移動して既存のコード ファイルをプロジェクトに追加します
//   6. 後ほどこのプロジェクトを再び開く場合、[ファイル] > [開く] > [プロジェクト] と移動して .sln ファイルを選択します


Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


#define NUM 1000

int N,num_query;
stack<int> S[NUM];

int main(){

	scanf("%d %d",&N,&num_query);

	int command,A,B;

	for(int loop = 0; loop < num_query; loop++){

		scanf("%d",&command);

		switch(command){
		case 0:

			scanf("%d %d",&A,&B);
			S[A].push(B);
			break;

		case 1:

			scanf("%d",&A);
			if(!S[A].empty()){
				printf("%d\n",S[A].top());
			}

			break;

		case 2:

			scanf("%d",&A);
			if(!S[A].empty()){
				S[A].pop();
			}
			break;
		}
	}

	return 0;
}




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

int main(){
    int N, X;
    cin >> N >> X;
    int state = 0;
    int times = 1;
    for(int i = 0;i < N;++i){
        int tmp;
        cin >> tmp;
        state += tmp;
        if(state <= X){
            times += 1;
        }
    }
    cout << times << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
using namespace std;

int main() {
  vector<int> result;
  string n, a;
  getline(cin, n);
  getline(cin, a);
  istringstream iss(a);
  string num;

  while (getline(iss, num, ' ')) {
    result.push_back(stoi(num));
  }

  int n_num = stoi(n);
  for (int i = n_num; i > 0; i--) {
    cout << result[i - 1];
    if (i != 1) {
      cout << " ";
    }
  }
  cout << endl;
}


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

const int INF = 1001001001;

int main() {
    int h, n;
    cin >> h >> n;
    vector<int> dp(h+1, INF);
    dp[0] = 0;
    rep(i,n) {
        int a, b;
        cin >> a >> b;
        rep(j,h) {
            int nj = min(j+a,h);
            dp[nj] = min(dp[nj], dp[j] + b);
        }
    }
    cout << dp[h] << endl;
    return 0;
}

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

//#define int long long
#define DBG 1
#define dump(o) if(DBG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#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 each(it,c) for(auto it=(c).begin();it!=(c).end();it++)
#define all(c) c.begin(),c.end()
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);
vector<vector<int>>d = vector<vector<int>>(10, vector<int>(10, INF));;
int n;
signed main() {
	while (cin >> n, n) {
		d = vector<vector<int>>(10, vector<int>(10, INF));;
		rep(i, 0, 10)d[i][i] = 0;
		int x(0), y(0);
		rep(i, 0, n) {
			int a, b, c; cin >> a >> b >> c;
			x = max(x, a); y = max(y, b);
			d[a][b] = c; d[b][a] = c;
		}
		rep(k, 0, 10) {
			rep(i, 0, 10) {
				rep(j, 0, 10) {
					d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
				}
			}
		}
		int z = max(x, y);
		int sum(INF), ind(0);
		rep(i, 0, z + 1) {
			int v = accumulate(d[i].begin(), d[i].begin() + z + 1, 0);
			if (sum > v) {
				sum = v;
				ind = i;
			}
		}
		cout << ind << " " << sum << endl;
	}
	return 0;
}

Measured memory_bytes: 3132
#include <iostream>

void coin(int n, int result[4]) {
    result[0] = (n % 50) / 10;
    result[1] = (n % 100) / 50;
    result[2] = (n % 500) / 100;
    result[3] = n / 500;
}

int main(void) {
    std::string str;
    while(true) {
        int n = 0;
        std::cin >> n;
        if(n == 0){
            break;
        }

        int c10, c50, c100, c500;
        std::cin >> c10 >> c50 >> c100 >> c500;

        int result[4];
        coin(c10 * 10 + c50 * 50 + c100 * 100 + c500 * 500 - n, result);
        if(c10 - result[0] > 0)
            str += "10 " + std::to_string(c10 - result[0]) + "\n";
        if(c50 - result[1] > 0)
            str += "50 " + std::to_string(c50 - result[1]) + "\n";
        if(c100 - result[2] > 0)
            str += "100 " + std::to_string(c100 - result[2]) + "\n";
        if(c500 - result[3] > 0)
            str += "500 " + std::to_string(c500 - result[3]) + "\n";
        str += "\n";
    }
    std::cout << str.substr(0, str.length() - 1);
    return 0;
}

Measured memory_bytes: 1328
#include <iostream>
#include <algorithm>
#include <vector>
#include <functional>
#include <math.h>
#include <string>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
const int MOD = 1000000007;

using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

int main(){
    int n,d;
    cin>>n>>d;
    double x[10][10];
    rep(i,n){
        rep(j,d){
            cin>>x[i][j];
        }
    }
    int ans=0;
    /*rep(i,n){
        rep(j,d){
            printf("%lf ",pow(x[i][j],2));
        }
        cout<<endl;
    }*/
    rep(i,n-1){
        for(int j=i+1;j<n;++j){
            double diff=0;
            rep(k,d){   
                diff += pow((x[i][k] - x[j][k]),2);
            }
            diff = pow(diff,0.5);
            //cout<<diff<<endl;
            if(ceil(diff) == floor(diff)){
                ++ans;
            }
        }
    }
    cout<<ans<<endl;
}

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

int main(){
  int n;
  cin >> n; 
  vector<long long >a(n);
  for(int i=0;i<n;i++){
      cin >> a.at(i);
  }
  bool ans = true;
  reverse(a.begin(),a.end());
  for(int i=1;i<n;i++){
    if(a.at(i-1)<a.at(i)){
        a.at(i)-=1;
        if(a.at(i-1)<a.at(i)){
            ans = false;
            break;
        }
    }
  }
  if(ans){
      cout << "Yes"<<endl;
  }
  if(!ans){
      cout <<"No"<<endl;
  }
}

Measured memory_bytes: 1024
import sys
sys.setrecursionlimit(10**9)
n,m = map(int,input().split())
a = [int(input()) for _ in range(m)]
mod = 10**9+7
memo = [-1]*(n+1)
def rec(x):
    if memo[x] != -1: pass
    elif x == 0: memo[x] = 1
    elif a and x == a[-1]:
        memo[x] = 0
        a.pop()
    elif x == 1: memo[x] = 1
    else: memo[x] = rec(x-1)+rec(x-2)
    return memo[x]%mod
print(rec(n))

Measured memory_bytes: 84084
#include <iostream>
#include <set>

using namespace std;

int main() {
    int x, n, p, ans = -1e9;
    cin >> x >> n;
    set<int> s;
    for (int i = 0; i < n; i++) {
        cin >> p;
        s.insert(p);
    }

    int i = 0;
    while (1) {
        if (s.find(x - i) == s.end()) {
            cout << x - i << endl;
            return 0;
        }
        if (s.find(x + i) == s.end()) {
            cout << x + i << endl;
            return 0;
        }
        i++;
    }

    return 0;
}


Measured memory_bytes: 3632
// template
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<long long, long long> LP;
#define INF 999999999
#define MOD 1000000007
#define REP(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define REP_AB(i, a, b) for (ll i = ll(a); i <= ll(b); ++i)
#define ALL(v) v.begin(), v.end()
#define SORT(v) sort(ALL(v))
#define UNIQUE(v) sort(ALL(v));v.erase(unique(ALL(v)), v.end());
#define SIZE(x) ((ll)(x).size())
#define REVERSE(v) reverse(ALL(v))
// true / false
#define BIN_SEARCH(v, a) binary_search(ALL(v), a)
// index
#define BIN_LEFT(v, a) (lower_bound(ALL(v), a) - v.begin())
#define BIN_RIGHT(v, a) (upper_bound(ALL(v), a) - v.begin())
#define BIN_INSERT(v, a) (v.insert(v.begin() + BIN_LEFT(v, a), a))
#define DEL(v, i) v.erase(v.begin() + i)
#define INSERT(v, i, a) v.insert(v.begin() + i, a)
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return (a / gcd(a, b)) * b;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
#define out cout
#define in cin
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 end

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n, ans = 1;
    in >> n;
    REP(i, n){
        ans = ans * (i + 1) % MOD;
    }

    out << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
 
using namespace std;
 
 
const int INF = (int) 1e9;

struct point {
	int x;
    int y;
	point() : x(0), y(0) {}
};
 
struct fenwick_tree {
	int n;
	unordered_map<int, int> F;
 
	fenwick_tree() : n(INF) {}
	void upd(int i, int x) {
		for (; i < n; i |= i + 1)
			F[i] = max(F[i], x);
	} 
	int get(int i) {
		int res = 0;
		for (; i >= 0; i &= i + 1, --i)
			res = max(res, F[i]);
		return res;
	}
};
 
 
bool cmp(point a, point b) {
    return make_pair(a.x, a.y) < make_pair(b.x, b.y); 
}
 
 
int main() {
#ifdef NICK
	freopen("input.txt", "r", stdin);
#else

#endif
    point start, finish;
    int n;
    cin >> start.x >> start.y;
    cin >> finish.x >> finish.y;
    cin >> n;
    vector<point> p(n);
    for (int i = 0; i < n; i++) {
        cin >> p[i].x >> p[i].y;
    }
    if (start.x > finish.x)
        swap(start, finish);
    if (start.y > finish.y) {
        finish.y = 2 * start.y - finish.y;
        for (int i = 0; i < n; i++) {
            p[i].y = 2 * start.y - p[i].y;
        }
    }
    vector<point> a;
    for (int i = 0; i < n; i++) {
        if (start.x <= p[i].x && p[i].x <= finish.x && start.y <= p[i].y && p[i].y <= finish.y)
            a.emplace_back(p[i]);
    }
    fenwick_tree dp;
    sort(a.begin(), a.end(), cmp);
    for (int i = 0; i < (int)a.size(); ++i)
        dp.upd(a[i].y, dp.get(a[i].y) + 1);
    int cur = dp.get(INF);
    long double ans = 0;
    if (cur != min(finish.y - start.y, finish.x - start.x) + 1)
        ans = 100.0 * (finish.y + finish.x - start.y - start.x) - 20.0 * cur + 5 * M_PI * cur;
    else
        ans = 100.0 * (finish.y + finish.x - start.x - start.y) - 20.0 * cur + 5 * M_PI * (cur - 1) + 10 * M_PI;
    cout << fixed << setprecision(13) << ans << "\n";
	return 0;
}

Measured memory_bytes: 70776
#include<iostream>
#include <functional>
#include<algorithm>

using namespace std;

typedef  long long ll;

int main(){
  	int A,B,T;
	cin >> A>>B>>T;
  	
  	int ans=0;

  	for(int i = 0 ;i < T/A ; i++){
    	ans += B; 
    }
  	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<ll>;
using vii = vector<vi>;
using Pll = pair<ll, ll>;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
const int MOD = 1000000007;
template<class T> void print(const T& t){ cout << t << endl; }
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; }

int main(){
  ll h, w;
  cin >> h >> w;
  vector<vector<char>> c(h*2, vector<char>(w));
  rep(i,h){
    rep(j,w){
      cin >> c[2*i][j];
      c[2 * i + 1][j] = c[2 * i][j];
    }
  }
  rep(i,h*2){
    rep(j,w){
      cout << c[i][j];
    }
    cout << "\n";
  }
}

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

using namespace std;

const int INF = 2e+8;

double r_min = INF;
double r_max = -INF;
double l_min = INF;
double l_max = -INF;
double u_min = INF;
double u_max = -INF;
double d_min = INF;
double d_max = -INF;
double x_min = INF;
double x_max = -INF;
double y_min = INF;
double y_max = -INF;

double calc(double t){
    double max_x = max(x_max, max(l_max-t, r_max+t));
    double min_x = min(x_min, min(r_min+t, l_min-t));
    double max_y = max(y_max, max(d_max-t, u_max+t));
    double min_y = min(y_min, min(u_min+t, d_min-t));
    double ans = max_x-min_x;
    double tmp = max_y-min_y;
    ans = ans*tmp;
    return ans;
}

int main(){
    int N;
    cin >> N;
    double x[100000], y[100000];
    double ans = 1e+20;

    for(int i = 0; i < N; i++){
        char d;
        cin >> x[i] >> y[i] >> d;
        if(d == 'R'){
            r_max = max(r_max, x[i]);
            r_min = min(r_min, x[i]);
            y_max = max(y_max, y[i]);
            y_min = min(y_min, y[i]);
        }
        if(d == 'L'){
            l_max = max(l_max, x[i]);
            l_min = min(l_min, x[i]);
            y_max = max(y_max, y[i]);
            y_min = min(y_min, y[i]);
        }
        if(d == 'U'){
            u_max = max(u_max, y[i]);
            u_min = min(u_min, y[i]);
            x_max = max(x_max, x[i]);
            x_min = min(x_min, x[i]);
        }
        if(d == 'D'){
            d_max = max(d_max, y[i]);
            d_min = min(d_min, y[i]);
            x_max = max(x_max, x[i]);
            x_min = min(x_min, x[i]);
        }
    }
    ans = calc(0);
    double t = (double)(d_max-u_max)/2;
    if(t >= 0){
        ans = min(ans, calc(t));
    }
    t = (d_max - y_max);
    if(t >= 0){
        ans = min(ans, calc(t));
    }
    t = (y_max - u_max);
    if(t >= 0){
        ans = min(ans, calc(t));
    }
    
    t = (double)(l_max-r_max)/2;
    if(t >= 0){
        ans = min(ans, calc(t));
    }
    t = (l_max - x_max);
    if(t >= 0){
        ans = min(ans, calc(t));
    }
    t = (x_max - r_max);
    if(t >= 0){
        ans = min(ans, calc(t));
    }

    t = (double)(d_min-u_min)/2;
    if(t >= 0){
        ans = min(ans, calc(t));
    }
    t = (d_min - y_min);
    if(t >= 0){
        ans = min(ans, calc(t));
    }
    t = (y_min - u_min);
    if(t >= 0){
        ans = min(ans, calc(t));
    }

    t = (double)(l_min-r_min)/2;
    if(t >= 0){
        ans = min(ans, calc(t));
    }
    t = (l_min - x_min);
    if(t >= 0){
        ans = min(ans, calc(t));
    }
    t = (x_min - r_min);
    if(t >= 0){
        ans = min(ans, calc(t));
    }
    cout << fixed;
    cout << setprecision(10) <<  ans << endl;
}

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

#define int long long
#define pb push_back
#define fi first
#define se second
#define FOR(a, b, c) for(int a = b; a <= c; ++a)
#define mp make_pair
const int N=1e5+5;
typedef pair<int,int> ii;
typedef pair<int,ii> iii;
int n, pr[N];
vector<ii> xx, yy;
priority_queue<iii, vector<iii>, greater<iii> > pq;
int find(int i) {
	return (pr[i] == i) ? i : (pr[i] = find(pr[i]));
}
signed main(){
    ios_base::sync_with_stdio(false);
    cin >> n;
    FOR(i, 1, n) {
    	int x, y; cin >> x >> y;
    	xx.pb(mp(x, i)); yy.pb(mp(y, i));
	}
	sort(xx.begin(), xx.end()); sort(yy.begin(), yy.end());
	FOR(i, 1, xx.size() - 1)	{
		pq.push(mp(xx[i].fi - xx[i - 1].fi, mp(xx[i].se, xx[i - 1].se)) );
	}
	FOR(i, 1, yy.size() - 1)
		pq.push(mp(yy[i].fi - yy[i - 1].fi, mp(yy[i].se, yy[i - 1].se)));
	int ans = 0;
	FOR(i, 1, n) 	pr[i] = i;
	while(!pq.empty())	{
		int u = pq.top().se.fi, v = pq.top().se.se, uv = pq.top().fi; pq.pop();
		if(find(u) != find(v))	{
			pr[find(u)] = find(v);
			ans += uv;
		}
	}
	cout << ans;
} 


Measured memory_bytes: 13152
#include<cstdio>
#include<algorithm>
using namespace std;
const int MAXN=105;
int n,a[MAXN];
void PI(){printf("Impossible\n");}
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	sort(a+1,a+n+1);
	if(a[1]==a[2]&&a[2]==a[3]){PI();return 0;}
	if(a[n]!=a[n-1]){PI();return 0;}
	if(a[1]!=a[2]&&a[1]*2!=a[n]){PI();return 0;}
	if(a[1]==a[2]&&a[1]*2-1!=a[n]){PI();return 0;}
	for(int i=n-1;i>=1;i--)
		if(a[i]!=a[i+1]&&a[i]+1!=a[i+1]){
			PI();return 0;
		}
	printf("Possible\n");
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <map>
#include <math.h>
#include <vector>
using namespace std;
struct cww { cww() { ios::sync_with_stdio(false); cin.tie(0); } }star;
map<int, int> ct;
map<int, int> ct2;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<pair<int, int> > vpii;
typedef pair<int, int> pii;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef vector<ll> vll;
#define INF 0x3f3f3f3f
#define MOD 998244353LL
#define EPS 0.00001
#define f first
#define s second
#define pb push_back
#define mp make_pair

#define FOR(i, a, b) for (int i=(a); i<=(signed)(b); i++)
#define AFOR(i, a) for (int i=0; i<(signed)(a); i++)
#define RFOR(i, a, b) for (int i=(a); i >= b; i--)

#define MN 100005
int n, m, l;
int a, b, c;
string s[MN];
string str;
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };

/*
int N;
cin >> N;
vi vect(N);
FOR(i,N) cin >> vec.at(i);*/
//sort(vec.begin(),vec.end());
//vvi data(N,vi(4));

std::vector<int> Eratosthenes(const int N)
{
	std::vector<bool> is_prime(N + 1);
	for (int i = 0; i <= N; i++)
	{
		is_prime[i] = true;
	}
	std::vector<int> P;
	for (int i = 2; i <= N; i++)
	{
		if (is_prime[i])
		{
			for (int j = 2 * i; j <= N; j += i)
			{
				is_prime[j] = false;
			}
			P.emplace_back(i);
		}
	}
	return P;
}
/*	int bfs(int x, int y,vvi &A,vvi flag) {
		queue<pii> que;
		que.push(pii(x, y));
		while (que.size()) {
			pii p = que.front(); que.pop();
			AFOR(i, 4) {
				int nx = p.first + dx[i]; int ny = p.second + dy[i];
				if (0 <= nx && nx < N && 0 <= ny && ny < N) {
					if (A.at(p.first).at(p.second) + flag.at(p.first).at(p.second) < A.at(nx).at(ny)) {
						A.at(nx).at(ny) = A.at(p.first).at(p.second) + flag.at(p.first).at(p.second);
						que.push(pii(nx, ny));
					}
				}
			}
		}
		return 0;
	}
	*/
	/*int gcd(int p, int q){
		while(q != 0){
		int r = p % q;
		p = q;
		q = r;
		}
	return p;
	}*/
ll N;
ll K;
ll A[200100];
int  L[200100];

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int N, X;
	cin >> X >> N;
	int p[100];
	if (N == 0) {
		cout << X << endl;
		return 0;
	}
	else if (N == 100) {
		if (X > 50) { cout << 101 << endl; }
		else cout << 0 << endl;
		return 0;
	}
	AFOR(i, N) {
		cin >> p[i];
	}
	int t = 0;
	int q[101];
	AFOR(i, 101) {
		q[i] = 0;
	}
	AFOR(i, N) { q[p[i]]++; }
	if (q[X] == 0) { cout << X << endl; }
	else {
		FOR(i,1,100) {
			if (q[i] == 0) {
				if (abs(t - X) > abs(X - i)) { t = i; }
			}
		}
		if (abs(X - t) > abs(101 - X)) {
			t = 101;
		}
		if (abs(X) <= abs(t - X)) { t = 0; }
		cout << t << endl;
	}

	return 0;

}

Measured memory_bytes: 6772
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep1(i, n) for(int i = 1; i < n; i++)
#define all(v) (v).begin(), (v).end()
#define decimal fixed << setprecision(20)
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
using namespace std;
using LL = long long;
const int INF = 1e9;
const LL LLINF = 1e16;

int main(){
  string s;
  cin>>s;
  int ans=0;
  string agct="AGCT";
  rep(i,s.size())rep1(j,s.size()-i+1){
    int tmp = j;
    for(auto k:s.substr(i,j)){
      if(agct.find(k) == string::npos) tmp = 0;
      }
    ans=max(ans,tmp);
  }
  cout<<ans<<endl;
}

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

#define fast ios::sync_with_stdio(false);cin.tie(0); cout.tie(0);
#define pb push_back
#define sz(s) (int)s.size()
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i,n) for(int i=0;i<(int)n;i++)
#define for1(i,n) for(int i=1;i<=(int)n;i++)
#define ford(i, b, a) for (int i = (int)(b); i >= a; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<ll> vl;
const int N = (int)1e5+77;
const ll inf = (ll) 1e15+77;
const ll mod = (ll) 998244353;
const ld pi = acos(-1);

int n, m, x, y, dp[N];
vector<vector<int>> g;

int main() {
    fast;
    cin >> n >> m;
    g = vector<vector<int>>(n + 1);
    vector<int> deg(n + 1, 0);
    while (m--) {
        cin >> x >> y;
        g[x].push_back(y);
        ++deg[y];
    }
    queue<int> q;
    for1(i, n) if (deg[i] == 0) q.push(i), dp[i] = 0;
    while (q.size()) {
        int cur = q.front();
        q.pop();
        for (auto next : g[cur]) {
            dp[next] = max(dp[next], dp[cur] + 1);
            --deg[next];
            if (deg[next] == 0) q.push(next);
        }
    }
    int ans = 0;
    for1(i, n) ans = max(ans, dp[i]);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6528
import math

N = int(input())

# A/=Bの場合
# A>Bの数を数える

# 与えられたAについて，(A,B)が問題の条件を満たすB<Aの数を返す
def calc(A):
    A_str = str(A)
    # 桁数
    m = len(A_str)    
    # 先頭
    a = int(A_str[0])
    # 末尾
    b = int(A_str[-1])

    # # a<bなら存在しない
    # if a < b:
    #     return 0
    if b == 0:
        # 末尾が0なら存在しない
        return 0
    elif m==1:
        # 1桁ならなし
        return 0
    elif m==2:
        # 2桁なら
        if a < b:
            return 0
        else:
            return 1
    else:        
        # 3桁以上なら，
        if a < b:
            # i=0..m-3桁について，10**i個を足す
            X = 0
            for i in range(0,m-2):
                X += 10**i

            return X
            
        elif a==b:
            # 全体がm桁になるBの数は，間のm-2桁を00..0~(Bの間の数-1)で埋めた数
            X = int(A_str[1:-1])
            # i=0..m-3桁について，10**i個を足す
            for i in range(0,m-2):
                X += 10**i

            # 1桁の数字aも
            X = X + 1
            return X
        else:
            # 全体がm桁になるBの数は，間のm-2桁を00..0~99..9で埋めた数 = sum_i=0^{m-2} 10**i
            X = 0
            for i in range(0,m-1):
                X += 10**i
                
            return X

# 与えられたAについて，(A,B)が問題の条件を満たすB=Aの数を返す
def calc2(A):
    A_str = str(A)
    # 桁数
    m = len(A_str)    
    # 先頭
    a = int(A_str[0])
    # 末尾
    b = int(A_str[-1])

    if m==1:
        return 1
    else:
        if a==b:
            return 1
        else:
            return 0

num1 = 0
num2 = 0
for A in range(1,N+1):
    num1 += calc(A)
    num2 += calc2(A)


print(num1*2 + num2)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define ff first
#define ss second
#define quick                    \
    ios::sync_with_stdio(false); \
    cin.tie(0);
#define time cerr << (0.1 * clock()) / CLOCKS_PER_SEC << endl;
#define mod 1000000007
typedef long long ll;
typedef pair<ll, ll> pl;
#define forn(n) for (ll i = 0; i < ll(n); i++)

void solve() {
    ll n;
    cin >> n;
    vector<ll> v(n);
    forn(n) {
        cin >> v[i];
    }
    vector<ll> dp(n);
    dp[1] = abs(v[0] - v[1]);
    for (int i = 2; i < n; ++i) {
        dp[i] = min(dp[i - 1] + abs(v[i] - v[i - 1]), dp[i - 2] + abs(v[i] - v[i - 2]));
    }
    cout << dp[n - 1] << '\n';
}

int main() {
    quick;
    solve();
    // ll t;
    // cin >> t;
    // while (t--) {
    //     solve();
    // }
}

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

typedef long long ll;

#define int ll
#define all(v) v.begin(), v.end()
#define reps(__i, a, b) for (int __i = a; i < b; i++)
#define rep(__i, n) reps(__i, 0, n)

const ll INF = (1ll << 60);
const ll MOD = (ll)1e9 + 7;

signed main()
{
    int a, p;
    cin >> a >> p;

    cout << (a * 3 + p) / 2 << endl;
}

Measured memory_bytes: 256
/*
　　　　 ∧＿∧　にっぽんちゃちゃちゃ
　／＼（　・∀・）／ヽ
（ ●　と　　　つ　● ）　にっぽんちゃちゃちゃ
　＼/⊂、 ノ　　＼ノ
　　　　　し'
*/
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define repone(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define Rep(j,n) for(int j=0;j<(int)(n);++j)
#define Repo(j,o,n) for(int j=o;j<(int)(n);++j)
#define Repone(j,n) for(int j=1;j<(int)(n);++j)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define int long long
#define MOD 1000000007
#define INF 9223372036854775807

signed main(){
int x=0,y=0,z=0,w=0;
std::cin >> x>>y>>z;
std::cout << x+y+z << '\n';
}



Measured memory_bytes: 3116
import java.util.*;

class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] member = new int[n];
        for(int i = 0;i < n-1;i++){
            int num = sc.nextInt();
            member[num-1]++;
        }
        for(int ans:member)
            System.out.println(ans);
    }
}

Measured memory_bytes: 70624
from collections import Counter
N = int(input())
S = [input() for i in range(N)]
M = int(input())
T = [input() for i in range(M)]
c1 = Counter(S)
c2 = Counter(T)

ans = 0
for k,v in c1.items():
    tmp = v - c2[k]
    ans = max(ans, tmp)
print(ans)

Measured memory_bytes: 3316
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet};
#[allow(unused_imports)]
use std::io::*;
#[allow(unused_imports)]
use std::str::*;

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

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

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

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

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let cin = stdin();
    let cin = cin.lock();
    let s: String = cin
        .bytes() // Bytes
        .map(|c| c.expect("failed reading char") as char)
        .skip_while(|c| c.is_whitespace()) // c が whitespace である限り skip
        .take_while(|c| !c.is_whitespace()) // c が whitespace でない限り要素を返す
        .collect();
    s.parse().ok().expect("failed parsing")
}

fn main() {
    input! {s:String}
    println! {"{}", s.chars().filter(|c| *c == '1').count()};
}


Measured memory_bytes: 4352
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-8;
const int inf=1e8;
int main(){
	int n,m;
	cin>>n>>m;
	vp in(n);
	vi x,y;
	rep(i,n){
		int a,b;
		cin>>a>>b;
		x.pb(a);
		y.pb(b);
		in[i]=pii(a,b);
	}
	sort(all(x));
	sort(all(y));
	x.erase(unique(all(x)),x.end());
	y.erase(unique(all(y)),y.end());
	rep(i,n)in[i]=pii(lower_bound(all(x),in[i].first)-x.begin(),lower_bound(all(y),in[i].second)-y.begin());
	vvi fi(x.size()+1,vi(y.size()+1));
	rep(i,n)fi[in[i].first+1][in[i].second+1]++;
	rep(i,x.size())rep(j,y.size())fi[i+1][j+1]+=fi[i][j+1]+fi[i+1][j]-fi[i][j];
	while(m--){
		int a,b,c,d;
		cin>>a>>b>>c>>d;
		a=lower_bound(all(x),a)-x.begin();
		b=lower_bound(all(y),b)-y.begin();
		c=upper_bound(all(x),c)-x.begin();
		d=upper_bound(all(y),d)-y.begin();
		cout<<fi[c][d]-fi[a][d]-fi[c][b]+fi[a][b]<<endl;
	}
}

Measured memory_bytes: 100752
#include <iostream>

using namespace std;

int main() {
    int N;
    cin >> N;
    bool ans = false;
    for (int y = 0; y < 100; ++y) {
        int tmp = N - 7 * y;
        if (tmp < 0) break;
        if (tmp % 4 == 0) {
            ans = true;
            break;
        }
    }
    if (ans) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 384
#define _LIBCPP_DEBUG 0
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll MOD = 1e9+7;

int main(void) {

    long double  a,b,x;cin>>a>>b>>x;
    long double y=0;
    long double ans=0;
    if(x>(a*a*b)/2.0000000){
        y=(2.0000000/(a*a))*(a*a*b-x);
        ans=atan2((long double)(y),(long double)(a));
    }
    else{
        ans=atan2((long double)(a*b*b),(long double)(2.0000000*x));
    }
    ans=ans*(360.0000000/(2.0000000*M_PI));
    //cout<<ans<<setprecision(10);
    printf("%.7Lf",ans);
    return 0;

    return 0;
}

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

void fastio() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
}

#define MAX 100010
int dp[MAX];

int dfs(vector<vector<int> > &G, int node) {
	if (dp[node] != -1) return dp[node];
	int temp = 0;
	for (const auto &child : G[node]) {
		temp = max(temp, dfs(G, child));
	}
	dp[node] = 1 + temp;
	return 1 + temp;
}

int main(int argc, char const *argv[])
{
	int n, m;
	cin >> n >> m;
	vector<vector<int> > G(n + 1);
	for (int i = 0; i < m; ++i) {
		int x, y;
		cin >> x >> y;
		G[x].push_back(y);
	}
	for (int i = 0; i < MAX; ++i)
		dp[i] = -1;
	for (int i = 1; i <= n; ++i) {
		dfs(G, i);
	}
	int ans = 0;
	for (int i = 0; i < MAX; ++i)
		ans = max(ans, dp[i]);
	cout << ans-1 << endl;
	return 0;
}

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

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

    string str;
    cin >> str;

    if (str.length() > n)
    {
        string rep = "...";
        str.replace(n, str.length(), rep);
        cout << str << endl;
    }
    else
    {
        cout << str << endl;
    }
}

Measured memory_bytes: 3604
h,w=map(int,input().split())
a=[list(input()) for i in range(h)]

#上下左右のマスを黒くしていく
#BFS
from collections import deque
def bfs():
    dx=[0,1,0,-1]
    dy=[1,0,-1,0]
    log=[[0]*w for i in range(h)]

    que=deque()
    for i in range(h):
        for j in range(w):
            if a[i][j]=='#':
                que.append((i,j))

    while que:
        #queの先頭を取り出す
        p=que.popleft()
        for i in range(4):
            nx=p[0]+dx[i]
            ny=p[1]+dy[i]

            if not(0<=nx<h and 0<=ny<w):continue
            if a[nx][ny]=='#':continue
            que.append((nx,ny))
            log[nx][ny]=log[p[0]][p[1]]+1
            a[nx][ny]='#'

    return log

G=bfs()
ans=0
for i in range(h):
    for j in range(w):
        if ans<G[i][j]:
            ans=G[i][j]
print(ans)

Measured memory_bytes: 121308