akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>
 
int main(void) {
  int n, i, j, k;
  long long int *l;
  int count=0;
  scanf("%d", &n);
  if ((l =(long long int *)calloc(n, sizeof(long long int))) == NULL) {
    exit(1);
  }
  for (i=0; i<n; i++) {
    scanf("%lld", &l[i]);
  }
  
  for (i=0; i<n-2; i++) {
    for (j=i+1; j<n-1; j++) {
      for (k=j+1; k<n; k++) {
		if ((l[i]==l[j]) || (l[j]==l[k]) || (l[k]==l[i])) {
          continue;
        }
        if (l[i]+l[j]>l[k] && l[j]+l[k]>l[i] && l[k]+l[i]>l[j]) {
          count++;
        }
      }
    }
  }
  printf("%d", count);
  return 0;
}

Measured memory_bytes: 1736
n,m = map(int, input().split())
ls = [input().split() for i in range(m)]

ls.sort(key=lambda x:int(x[0]))

idx = 1
w=0
a=0
wp=0
for i in range(m):
    if idx<int(ls[i][0]):
        wp = 0
        idx = int(ls[i][0])
    if idx==int(ls[i][0]):
        if ls[i][1]=='WA':
            wp += 1
        else:
            w += wp
            wp = 0
            a += 1
            idx += 1

print(a,w)

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

int n;
long double a, sum = 0;

int main() {
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> a;
		sum += (1 / a);
	}
	cout << 1 / sum << endl;
	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
#define mp make_pair

template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

Int dp[2][300];
int c[20];
int x[20010];

int main() {
	int n,m;
	while(cin>>n>>m,n){
		int i,j,k;
		for(i=0;i<m;i++){
			cin>>c[i];
		}
		for(i=0;i<n;i++){
			cin>>x[i];
		}
		memset(dp,-1,sizeof(dp));
		dp[0][128]=0;
		int next;
		for(i=0;i<n;i++){
			for(j=0;j<256;j++){
				if(dp[0][j]==-1)continue;
				for(k=0;k<m;k++){
					next=j+c[k];
					if(next<0)next=0;
					if(next>=256)next=255;
					if(dp[1][next]==-1||dp[1][next]>dp[0][j]+(next-x[i])*(next-x[i]))dp[1][next]=dp[0][j]+(next-x[i])*(next-x[i]);
				}
			}
			for(j=0;j<256;j++){
				dp[0][j]=dp[1][j];
				dp[1][j]=-1;
			}
		}
		Int mn=-1;
		for(j=0;j<256;j++){
			if(dp[0][j]!=-1){
				if(mn==-1||mn>dp[0][j])mn=dp[0][j];
			}
		}
		cout<<mn<<endl;
	}
	return 0;
}

Measured memory_bytes: 960
#include <bits/stdc++.h>
#include <stdio.h>
#include <math.h>
using namespace std;
 
int main() {
    long int N;
    cin >> N;
	bool first = false;
  	bool second = false;
    long int idou;
    idou = N-1;
 	double NN = sqrt(N);

    for (int i = 2;i<NN+1;i++){
        long int waru = i;
      	waru = i;
        long int waruk = N / i;
        if (N%waru == 0){
          if (i == waru && N / 1 == waruk){
          	second = true;
          }
            if (idou >= waru + N / waru - 2){
                idou = (waru + N / waru )- 2;
              	first = true;
  
              	//cout << idou << endl;
              	//cout << i << endl;
            }
        }
      	if (second == true){
        	break;
        }
    }
  	
  	if (first == false){
    	cout << idou << endl;
    }else{
    	cout << idou << endl;
    }
  
    

}

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

int main() {
	int S;
	cin >> S;
	int h, m, s;
	h = S/(60*60);
	m = S%(60*60)/60;
	s = S%(60*60*60)%60;
	cout << h << ":" << m << ":" << s << endl;
	return 0;
}


Measured memory_bytes: 3112
// Problem : B - Product Max
// Contest : AtCoder - AtCoder Beginner Contest 178
// URL : https://atcoder.jp/contests/abc178/tasks/abc178_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update

using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
ordered_set;	

#define FOR(i,a,b) for(int i = (a); i <= (b); ++i)
#define FORD(i,a,b) for(int i = (a); i >= (b); --i)
#define RI(i,n) FOR(i,1,(n))
#define REP(i,n) FOR(i,0,(n)-1)
#define mini(a,b) a=min(a,b)
#define maxi(a,b) a=max(a,b)
#define pb push_back
#define st first
#define nd second
#define sz(w) (int) w.size()
typedef vector<int> vi;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<pii, int> para;
const ll inf = 1e18 + 7;
const ll maxN = 1e6 + 5;
const ll MOD = 1e9 + 7;

// sprawdz MODULO!
int main() {
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	ll a, b, c, d;
	cin >> a >> b >> c >> d;
	ll ans = -inf;
	if (a <= 0 && b >= 0) ans = 0;
	if (c <= 0 && d >= 0) ans = 0;
	ans = max(ans, a * c);
	ans = max(ans, a * d);
	ans = max(ans, b * c);
	ans = max(ans, b * d);
	cout << ans;
	return 0;
}
 


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

using namespace std;
typedef long long ll;

int main() {
    int N;  ll K, S = 0;   cin >> N >> K;
    vector<ll> A(N), G;
    for (int i = 0; i < N; i++) {
        cin >> A[i];
        S += A[i];
    }

    for (int x = 1; x * x <= S; x++) {
        if (S % x == 0) {
            G.push_back(x);
            if (S/x != x) 
                G.push_back(S/x);
        }
    }
    sort(G.begin(), G.end(), greater<ll>());

    for (auto x: G) {
        ll s_r = 0, cnt = 0; vector<ll> r(N);
        for (int i = 0; i < N; i++) {
            r[i] = A[i] % x;
            s_r += r[i];
        }

        sort(r.begin(), r.end());
        ll l = s_r / x;
        for (int i = N-l; i < N; i++)
            cnt += x - r[i];
        
        if (cnt <= K) {
            cout << x << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 3580
#include<stdio.h>
int main(void)
{
	int gohyaku,hyaku,gozyu,zyu,go,ichi;
	int dai,otsuri,mai;
	scanf("%d",&dai);
	while(dai!=0){
		otsuri=1000-dai;
		gohyaku=0;
		hyaku=0;
		gozyu=0;
		zyu=0;
		go=0;
		ichi=0;
		while(otsuri!=0){
			while(otsuri>=500){
				otsuri=otsuri-500;
					gohyaku++;
			}
			while(otsuri>=100){
				otsuri=otsuri-100;
					hyaku++;
			}
			while(otsuri>=50){
				otsuri=otsuri-50;
					gozyu++;
			}
			while(otsuri>=10){
				otsuri=otsuri-10;
					zyu++;
			}
			while(otsuri>=5){
				otsuri=otsuri-5;
					go++;
			}
			while(otsuri>=1){
				otsuri=otsuri-1;
					ichi++;
			}
			mai=gohyaku+hyaku+gozyu+zyu+go+ichi;
			printf("%d\n",mai);
			scanf("%d",&dai);
		}
	}
	return 0;
}

Measured memory_bytes: 1028
from collections import Counter
from collections import defaultdict
n = int(input())
a = list(map(int, input().split()))
sa = []
st = []
for i in range(n):
  sa.append(a[i] + i)
  st.append(i - a[i])
c = defaultdict(int)
c = Counter(st)
sum = 0
for i in range(n-1):
  sum = sum + c[sa[i]]
print(sum)

Measured memory_bytes: 50652
#include <stdio.h>

int main(void){

    int x, y;
    int max;

    scanf("%d %d", &x, &y);
    max = x + y;

    if (max < x - y){
        max = x - y;
    }
    
    if (max < x * y){
        max = x * y;
    }

    printf("%d", max);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int n,t[500005],x[500005],y[500005],X,Y,T;
int main(){
	scanf("%d",&n);
	for (int i=1;i<=n;++i) scanf("%d%d%d",&t[i],&x[i],&y[i]);
	for (int i=1;i<=n;++i){
		T=t[i]-t[i-1];
		X=abs(x[i]-x[i-1]);
		Y=abs(y[i]-y[i-1]);
		if (X+Y>T||T-X-Y&1){puts("No"); return 0;}
	}
	puts("Yes");
	return 0;
}

Measured memory_bytes: 2944
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader( new InputStreamReader(System.in));
		String n,sub;

		while(true){
			n= br.readLine();
			if(n.equals("-")){
				break;
			}
			int num = Integer.parseInt(br.readLine());
			int h[] = new int[num];
			for(int i = 0 ; i < num ; i++){
				h[i]= Integer.parseInt(br.readLine());
				sub = n.substring(0, h[i]);
				n +=sub;
				n = n.substring(h[i]);
			}
			System.out.println(n);
		}


	}

}

Measured memory_bytes: 24648
#include <iostream>
#include <vector>
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
using namespace std;
int main() {
	int n,k,x,y,a=0,b=0,c=0;
	cin>>n>>k>>x>>y;
	if(n<=k)
	{
		c=n*x;
	}
	if(n>k)
	{
	  a=x*k;
	  b=(n-k)*y;
	  c=a+b;
    }
	cout<<c;
	return 0;
}

Measured memory_bytes: 3176
#include <iostream>
#include <vector>
#include <math.h>
#include <string>
#include <algorithm>
using namespace std;
using ll = long long;

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

	n = min(b - 1, n);

	ll max = floor(a * n / b) - a * floor(n / b);

	cout << max << endl;
	return 0;
}

Measured memory_bytes: 3636
n,y = map(int, input().split())

yy = y//1000

amax = yy //10

for i in range(amax+1):
    resty = yy- i*10
    restn = n-i
    bmax = resty //5
    for j in range(bmax+1):
        restyz = resty - j*5
        restyn = restn - j
        if restyn == restyz:
            print(str(i)+" "+str(j)+" "+str(restyn))
            exit()

print("-1 -1 -1")

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main(){
    int x[9],i;
    for(i=0;0<=i && i<10;++i){
        cin>>x[i];
           }
    sort(x,x+10);
    cout<<x[9]<<endl;
    cout<<x[8]<<endl;
    cout<<x[7]<<endl;
    return 0;
}

Measured memory_bytes: 3152
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;

long long factor(long long a, long long b) {
	long long m = a % b;
	if (m == 0)return b;
	return factor(b, m);
}

long long calc(long long a, long long b) {
	if (a < b)swap(a, b);
	long long f = factor(a, b);
	return f * (a / f) * (b / f);
}

const int MAX = 100;

int main() {
	int N;
	long long T[MAX];
	long long ans;

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

	ans = T[0];
	for (int i = 1; i < N; i++) {
		ans = calc(T[i], ans);
	}

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

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <cstring>
#include <climits>
#define mk make_pair
#define pb push_back
#define scanf scanf_s
#define printf printf_s
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<ll, ll> pos;
const ll N = 200010, MOD = 1000000007;

ll mn(ll a, ll b) {
	if (a == -1)return b;
	if (b == -1)return a;
	return min(a, b);
}

int bb(int v1) {
	if (v1 % 2 == 0)return v1 / 2 - 1;
	else return v1 / 2;
}

ll pw(ll a, ll b) {
	ll v = 1;
	for (; b > 0; b = (b >> 1), a = (a * a) % MOD) {
		if ((b & 1) > 0)v = (v * a) % MOD;
	}
	return v;
}

ll n, k, a[N],ans=0;
map<int, int> mp;
int main() {
	cin >> n >> k;
	mp[0] = 1;
	for (int i = 1; i <= n; i++) {
		if (i - k  >= 0) {
			ll v2 = (a[i - k ] - (i - k) % k + k) % k;
			mp[v2]--;
		}

		cin >> a[i];
		a[i] = (a[i] + a[i - 1]) % k;
		ll v1 = (a[i] - i%k + k) % k;
		ans += mp[v1];
		mp[v1]++;
	}
	cout << ans << endl;
	return 0;
}


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

#define INF (1<<25)
#define MOD (1000000007)

#define FOR(i,a,n) for (int i = a; i < n; ++i)
#define REP(i,n) FOR(i,0,n)
#define whole(f,x,...) ([&](decltype((x)) whole) { \
    return (f)(begin(whole), end(whole), ## __VA_ARGS__); \
    })(x)
template<typename T> bool chmin(T &a, const T &b) {if (a > b) { a = b; return true; }return false;}
template<typename T> bool chmax(T &a, const T &b) {if (a < b) { a = b; return true; }return false;}

using ll = long long;

int main() {
  int n; cin >> n;
  vector<int> a(n); REP(i,n) cin >> a[i];
  whole(sort, a, greater<int>());
  REP(i,n) {
    if (a[i] != n-i-1+i%2) {
      cout << 0 << endl;
      return 0;
    }
  }
  ll ans = 1;
  REP(i,n/2) ans = ans * 2 % MOD;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 640
#include<stdio.h>

int main(){
  int i=0,j=0,A[100],b,v,k=0;
  scanf("%d",&b);
  for(i=0;i<b;i++){
    scanf("%d",&A[i]);
  }

  for(i=1;i<=b;i++){
    v=A[i];
    j=i-1;
    for(k=0;k<=b-1;k++){
      if(k<b-1){
        printf("%d ",A[k]);
      }
      else{
        printf("%d",A[k]);
      }
    }
    printf("\n");
    while(j>=0 && A[j]>v){
      A[j+1]=A[j];
      j--;
      A[j+1] = v;
    }
  }
  return 0;
}



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

using namespace std;

typedef long long LL;

LL N, Q;
vector<vector<LL>> edges;
vector<LL> PX;
vector<LL> sum_val;
vector<bool> visited;
vector<LL> vals;

void dfs(LL v, LL p, LL add_val) {
    visited[v] = true;
    vals[v] = add_val + sum_val[v];
    for (int i = 0; i < edges[v].size(); i++) {
        LL n = edges[v][i];
        if (visited[n]) {continue;}
        dfs(n, v, add_val + sum_val[v]);
    }
    return;
}

int main()
{
    cin >> N >> Q;
    edges.resize(N);
    for (int i = 0; i < N - 1; i++) {
        LL a, b;
        cin >> a >> b;
        a -= 1;
        b -= 1;
        edges[a].push_back(b);
        edges[b].push_back(a);
    }
    sum_val.resize(N);
    for (int i = 0; i < Q; i++) {
        LL p, x;
        cin >> p >> x;
        p -= 1;
        sum_val[p] += x;
    }
    visited.resize(N);
    vals.resize(N);

    dfs(0, -1, 0);
    for (int i = 0; i < N; i++) {
        cout << vals[i] << endl;
    }

    return 0;
}


Measured memory_bytes: 28928
import sys
input = sys.stdin.readline

N, K = map(int, input().split())
a = list(map(int, input().split()))
acc1 = [0]
acc2 = [0]

for ai in a:
    acc1.append(acc1[-1]+ai)
    acc2.append(acc2[-1]+max(0, ai))

ans = 0

for i in range(N-K+1):
    ans = max(ans, max(0, acc1[i+K]-acc1[i])+acc2[i]+acc2[N]-acc2[i+K])

print(ans)

Measured memory_bytes: 72096
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>

using namespace std;

int main()
{
	int v[26]={};
	string w;
	
	cin >> w;
	
	for(int i=0;i<w.size();i++){
		v[w[i]-'a']++;
	}
	
	for(int i=0;i<26;i++){
		if(v[i]%2!=0){
			cout << "No" << endl;
			return 0;
		}
		
	}
	
	cout << "Yes" << endl;
	return 0;
}

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

int main() {
    int H, W, A, B;
    cin >> H >> W >> A >> B;
    int ans[H][W] = {};
    for (int i = 0; i < H - B; ++i) {
        for (int j = 0; j < A; ++j) {
            ans[i][j] = 1;
        }
    }
    for (int i = H - B; i < H; ++i) {
        for (int j = A; j < W; ++j) {
            ans[i][j] = 1;
        }
    }

    for (int i = 0; i < H; ++i) {
        for (int j = 0; j < W - 1; ++j) {
            cout << ans[i][j];
        }
        cout << ans[i][W-1] << "\n";
    }
    return 0;
}

Measured memory_bytes: 5120
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
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;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef pair<ll,ll> l_l;
typedef pair<int,int> i_i;
const ll mod=1e9+7;
const int inf=1<<30;

int main(){
  int n,m;
  cin >> n >> m;
  string s; cin >> s;
  vector<int> ans(0);
  int i=n,j=n;
  while(i!=0){
    j=i-m;
    while(j<0||s[j]=='1'){
      j++;
    }
    if(i==j){
      cout << -1 << endl;
      return 0;
    }
    ans.push_back(i-j);
    i=j;
  }
  int l=ans.size();
  for(int i=l-1;i>=0;i--){
    cout << ans[i] << " ";
  }cout << endl;
}

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

namespace ABC153
{
    class Program
    {
        static void Main(string[] args)
        {
            b();
        }

        public static void b()
        {
            long[] hn = Console.ReadLine().Split(' ').Select(s => long.Parse(s)).ToArray();
            long h = hn[0];
            long n = hn[1];
            long[] a = Console.ReadLine().Split(' ').Select(s => long.Parse(s)).ToArray();
            long sum = 0;
            foreach(var x in a)
            {
                sum += x;
            }
            if (h <= sum)
            { Console.WriteLine("Yes"); }
            else
            { Console.WriteLine("No"); }
        }
    }
}


Measured memory_bytes: 20832
#include <bits/stdc++.h>
 
using namespace std;
typedef long long int lli;
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
typedef pair <lli,lli> pii;
#define ff first
#define ss second
#define MOD 1000000007
#define pb push_back
#define EPS 1e-6
#define SZ(v) int((v).size())
#define ALL(vec) begin(vec), end(vec)
typedef long long i64; 
long long const INF = 1e18 + 42;
 
 
int main(){
	fast;
	string s;
  	cin>>s;
  	for(int i=0; i<s.size(); i++) cout<<"x";
	
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		int i = Integer.parseInt(S.substring(0,4));
		int root = (int)Math.sqrt(i);
		System.out.println((i + 1) + S.substring(4)); 
	}
}


Measured memory_bytes: 22612
#include<cstdio>
#include<cstring>
#define retrun return
#define cpnst const
int n,m;
typedef long long ll;
cpnst ll mod=119<<23|1;
ll fac[1111111],inv[1111111],pwn[1111111],pwm[1111111];
ll qpow(ll x,ll k){ll r=1;for(;k;k>>=1,(x*=x)%=mod)if(k&1)(r*=x)%=mod;return r;}
void precalc()
{
	register int i;
	cpnst int lim=1e6;
	for(i=fac[0]=1;i<=lim;i++)fac[i]=fac[i-1]*i%mod;
	for(i=lim,inv[i]=qpow(fac[i],mod-2);i;i--)inv[i-1]=inv[i]*i%mod;
}
ll C(ll n,ll r){return fac[n]*inv[r]%mod*inv[n-r]%mod;}

int main()
{
	int n,m;
	scanf("%d%d",&n,&m),precalc();
	register int i;
	for(i=pwn[0]=pwm[0]=1;i<=1e6;i++)pwn[i]=pwn[i-1]*(n+1)%mod,pwm[i]=pwm[i-1]*(m+1)%mod;
	ll ans=0;
	for(i=0;i<=n&&i<=m;i++)
	{
		ll d=C(n,i)*C(m,i)%mod*fac[i]%mod*pwn[m-i]%mod*pwm[n-i]%mod;
		ans+=(i&1)?mod-d:d;
	}printf("%lld\n",ans%mod);
}
/*
Just go for it.
*/

Measured memory_bytes: 32984
#include<iostream>
#include<string>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<functional>
using namespace std;
int main(void) {
    
   int a,b;
   cin>>a>>b;
   int temp;
   int sum=0;

   for(int i=a;i<=b;i++){
       temp = i;
       if(i%10 == i/10000){
            i = (i - i%10 - (i/10000)*10000)/10;
            if(i%10 == i/100){
                sum++;
            }         
        }
      i = temp;
   }
   cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N=2e5+5;
char s[N];
int main()
{
    int n,ans=0;
    cin>>n;
    scanf("%s",s);
    for(int i=0;i<n;i++)
    {
        if(s[i]=='R') ans++;
    }
    int cnt=ans;
    for(int i=0;i<cnt;i++)
    {
        if(s[i]=='R') ans--;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3872
n = gets.chomp.to_i
a = gets.chomp.split(" ").map(&:to_i)

asum = a[0].abs + a[n-1].abs
(n-1).times do |i|
  asum += (a[i + 1] - a[i]).abs
end

n.times do |i|
  if i == 0 then
    puts asum  - (a[1] - a[0]).abs - a[0].abs + a[1].abs
  elsif i == n -1
    puts asum - (a[n-1] - a[n-2]).abs - a[n - 1].abs + a[n - 2].abs
  else
    puts asum - (a[i + 1]- a[i]).abs - (a[i] - a[i - 1]).abs + (a[i + 1] - a[i - 1]).abs
  end
end


Measured memory_bytes: 12164
m = int(input())
m = str(m + 1)
n = list(m)

if len(n) >= 2:
    if int(n[0]) >= 2:
        print((len(n) - 1) * 9 + int(n[0]) - 1)
    else:
        print((len(n) - 1) * 9)
else:
    print(int(n[0]) - 1)

Measured memory_bytes: 3060
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cfloat>
#include <complex>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

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

int main() {
  ll N;
  string str;

  cin >> N >> str;

  vector<vector<ll> > dp(N + 2, vector<ll>(N + 2, 0));

  for (int i = N; i >= 1; i--) {
    for (int j = N; j >= 1; j--) {
      if (str[i-1] == str[j-1])
        dp[i][j] = 1 + dp[i + 1][j + 1];
      else
        dp[i][j] = 0;
    }
  }

  ll ans = 0;
  for (ll i = N; i >= 1; i--) {
    for (ll j = i; j >= 1; j--) {
      ll tmp = min(dp[i][j], i-j);
      ans = max(ans, tmp);
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 195968
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;

#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=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int main() {
	string s;
	cin >> s;
	REP(i,s.length()){
		if (i % 2 == 0) cout << s[i];
	}
	cout << endl;

    return 0;
}

Measured memory_bytes: 512
n = int(input())
A = list(map(int, input().split()))

if n % 2 == 0:
    back = [A[2 * i] for i in range(n // 2)]
    front = [A[2 * i + 1] for i in range(n // 2)][::-1]
    ans = front + back

else:
    back = [A[2 * i + 1] for i in range(n // 2)]
    center = [A[0]]
    front = [A[2 * i + 2] for i in range(n // 2)][::-1]
    ans = front + center + back

ans = [str(i) for i in ans]
print(" ".join(ans))


Measured memory_bytes: 35872
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main() {
	string a, b;
	cin >> a >> b;
	int tmp = max(a.length(), b.length());
	for (int i = 0; i < tmp; i++) {
		if (a.length() > i) {
			cout << a[i];
		}
		if (b.length() > i) {
			cout << b[i];
		}
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
# coding: utf-8
# Your code here!
import collections

h,w = [int(i) for i in input().split()]
board = [input() for j in range(h)] # 縦「n」行

d4 = [[1,0],[0,1],[-1,0],[0,-1]]
memo = [[-1]*w for j in range(h)]
dist = [[100000]*w for j in range(h)]


q = collections.deque()
for i in range(h):
    for j in range(w):
        if board[i][j] == "#":
            memo[i][j] = 1
            q.append((i,j,0))

while len(q) != 0:
#    print(memo)
    i,j,c = q.popleft()
    dist[i][j] = c
    for k in d4:
#        print(k)
        ii,jj = k
        if  i+ii < 0 or i+ii>=h or j+jj <0 or j+jj>=w:
#            print("out",i+ii,j+jj)
            continue
        if memo[i+ii][j+jj] < 0:
#            print("put")
            q.append((i+ii,j+jj,c+1))
            memo[i+ii][j+jj] = 1

ans = 0      
for i in range(h):
    for j in range(w):
        ans = max(ans,dist[i][j])

print(ans)
#print(dist)




                
            
        

Measured memory_bytes: 141148
open Queue
let ans, q, h, w, ss = Scanf.(scanf "%d %d" @@ fun h w -> ref 0, create (), h, w, Array.init h @@ fun _ -> scanf " %s" @@ fun s -> s)
let f sy sx = let ds = Array.make_matrix h w ~-1 in push (sy, sx) q; ds.(sy).(sx) <- 0;
  while not @@ is_empty q do let y0, x0 = pop q in List.iter (fun (dy, dx) -> let y, x = y0 + dy, x0 + dx in if 0 <= y && y < h && 0 <= x && x < w && ds.(y).(x) = -1 && ss.(y).[x] = '.' then (push (y, x) q; ds.(y).(x) <- ds.(y0).(x0) + 1; ans := max !ans ds.(y).(x))) [-1, 0; 0, -1; 1, 0; 0, 1] done
let _ = for sy = 0 to h - 1 do for sx = 0 to w - 1 do if ss.(sy).[sx] = '.' then (f sy sx) done done; Printf.printf "%d\n" !ans

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

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

typedef long long ll;
using namespace std;

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

  int N, M;
  cin >> N >> M;
  vector<vector<int>> G(N);
  int a, b;
  REP(i, M) {
    cin >> a >> b;
    --a;
    --b;
    G.at(a).push_back(b);
    G.at(b).push_back(a);
  }

  REP(i, N) { cout << G.at(i).size() << endl; }

  return 0;
}


Measured memory_bytes: 256
S = input()

ans = 'Yes'
even = ['L', 'U', 'D']
odd = ['R', 'U', 'D']
for i in range(len(S)):
    if i%2 ==1 and S[i] not in even:#even
        ans = 'No'
        break
    if i%2 ==0 and S[i] not in odd: #odd
        ans = 'No'
        break

print (ans)



Measured memory_bytes: 2940
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <random>
#include <chrono>

using namespace std;
using namespace __gnu_pbds;

#define endl '\n'

typedef long long ll;
typedef pair<int, int> pii;
//typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;

//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

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

	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	
	ll a, b;
	cin >> a >> b;
	
	ll ans = a / b + (a % b != 0);
	
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline

n,k = map(int, input().split())

dp = [0] * n

for i in range(k):
    a = int(input())
    people = list(map(int, input().split()))

    for j in people:
        dp[j-1] += 1


ans = 0
for i in dp:
    if i == 0:
        ans += 1

print(ans)

Measured memory_bytes: 9192
#include <iostream>
#include <string>
#include <set>

int N, K;
std::set<char> D;

bool can(){
    std::string str = std::to_string(N);
    for(auto c : str){
        if(D.count(c) >= 1){
            return false;
        }
    }
    return true;
}

int main(void){
    std::cin >> N >> K;
    char d;
    for(int i=0; i<K; ++i){
        std::cin >> d;
        D.insert(d);
    }
    while(!can()) ++N;
    std::cout << N << std::endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;
int main()
{
  int n,h,w;
  cin >> n >> h >> w;

  cout << (n-h+1)*(n-w+1) << endl;
  return 0;
}


Measured memory_bytes: 256
n = int(input())
a_list = [int(input()) for i in range(n)]
a_sorted_list = sorted((a_list), reverse=True)
a_max = a_sorted_list[0]
a_second = a_sorted_list[1]
for a in a_list:
    if a == a_max:
        print(a_second)
    else:
        print(a_max)

Measured memory_bytes: 14152
#include<stdio.h>

int main() {
  int a=700;
  char s[101];

  scanf("%s", s);

  if (s[0]=='o') {
    a += 100;
  }
  if (s[1]=='o') {
    a += 100;
  }
  if (s[2]=='o') {
    a += 100;
  }

  printf("%d", a);

  return 0;
}


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

using namespace std;

typedef unsigned uint;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ldbl;
typedef pair<int, int> pii;
typedef pair<uint, uint> puu;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pull;
typedef pair<double, double> pdd;
typedef vector<int> vi;
typedef vector<uint> vu;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<pii> vpii;
typedef vector<puu> vpuu;
typedef vector<pll> vpll;
typedef vector<pull> vpull;
typedef vector<string> vstr;
typedef vector<double> vdbl;
typedef vector<ldbl> vldbl;
#define pb push_back
#define ppb pop_back
#define pfr push_front
#define ppfr pop_front
#define emp emplace
#define empb emplace_back
#define be begin
#define rbe rbegin
#define all(x) (x).be(), (x).end()
#define rall(x) (x).rbe(), (x).rend()
#define fir first
#define sec second
#define mkp make_pair
#define brif(cond) if (cond) break
#define ctif(cond) if (cond) continue
#define retif(cond) if (cond) return
void canhazfast() {ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);}
template<typename T> T gcd(T a, T b) {return b ? gcd(b, a%b) : a;}
template<typename T> T extgcd(T a, T b, T &x, T &y)
{
    T x0 = 1, y0 = 0, x1 = 0, y1 = 1;
    while (b) {
        T q = a/b; a %= b; swap(a, b);
        x0 -= q*x1; swap(x0, x1);
        y0 -= q*y1; swap(y0, y1);
    }
    x = x0; y = y0; return a;
}
int ctz(uint x) {return __builtin_ctz(x);}
int ctzll(ull x) {return __builtin_ctzll(x);}
int clz(uint x) {return __builtin_clz(x);}
int clzll(ull x) {return __builtin_clzll(x);}
int popcnt(uint x) {return __builtin_popcount(x);}
int popcntll(ull x) {return __builtin_popcountll(x);}
int bsr(uint x) {return 31^clz(x);}
int bsrll(ull x) {return 63^clzll(x);}

int main()
{
    canhazfast();

    int n;

    cin >> n;
    for (int i = 1; i < 10; ++i) {
        retif(n%i == 0 && n/i < 10) cout << "Yes\n", 0;
    }
    cout << "No\n";

    return 0;
}


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

namespace AtCoderMake.ABC162
{
    class ABC162A
    {
        static void Main(string[] args)
        {
            var n = Console.ReadLine();
            if (n.Count((x) => x=='7')>0)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}


Measured memory_bytes: 26252
#include <iostream>
#include <math.h>
#include <algorithm>
#include <queue>
#include <map>
#include <list>
//#include <bits/stdc++.h>


using namespace std;

#define FOR(i,a,b) for(int i=(a),i##formax=(b);i<i##formax;i++)
typedef long long ll;

int main(){
    int X, Y, Z;
    cin >> X >> Y >> Z;
    cout << Z << endl;
    cout << X << endl;
    cout << Y << endl;
    return 0;
}

Measured memory_bytes: 256
//https://atcoder.jp/contests/abc141/submissions/7559296

var ans = "Yes"
for(i, c)in readLine()!.characters.enumerate() {
  if i % 2 == 0 && c == "L" || i % 2 > 0 && c == "R" {
    ans = "No"
  }
}
print(ans)


Measured memory_bytes: 3952
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	int n , k ;
	cin >> n >> k ;
	vector<int> v(n+5);
	for(int i = 0 ; i < n ; i++)
	{
		int x ;
		cin >> x ;
		v[x]++;
	}
	sort(v.begin(),v.end());
	int ans = 0 ;
	for(int i = 0 ; i < v.size() ; i++)
	{
		ans+= v[i];
		if(v.size()-i-1 <= k) break;
	}
	cout << ans << endl;
}


Measured memory_bytes: 1152
k,n = map(int,input().split())
a = list(map(int,input().split()))
max_lenth = 0

for i in range(1,n):
    lenth = a[i] - a[i-1]
    max_lenth = max(max_lenth, lenth)
else:
    lenth = k - a[-1] + a[0]
    max_lenth = max(max_lenth, lenth)
ans = k - max_lenth
print(ans)

Measured memory_bytes: 100080
N = int(input())
W = [int(i) for i in input().split()]

S1 = W[0]
S2 = sum(W) - W[0]
diff = abs(S1-S2)

for i in range(1,N) :
    S1 += W[i]
    S2 -= W[i]
    d = abs(S1-S2)
    if (d < diff) :
        diff = d

print(diff)


Measured memory_bytes: 3060
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.ListIterator;
import java.util.Map.Entry;
import java.util.PriorityQueue;
import java.util.Scanner;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;

import javax.swing.text.Segment;

public class Main {
	
	public static void main(String[] args) throws IOException {
		try(Scanner sc = new Scanner(System.in)){
			final int N = sc.nextInt();
			
			int count = 0;
			HashSet<Integer> set = new HashSet<Integer>();
			for(int i = 0; i < N; i++){
				final int a = sc.nextInt();
				
				if(set.contains(a)){
					set.remove(a);
				}else{
					set.add(a);
				}
			}
			
			System.out.println(set.size());
		}
	}
	
	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;
 
		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}
 
		private void getLine() throws IOException {
			while (!hasNext()) {
				tok = new StringTokenizer(br.readLine());
			}
		}
 
		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}
 
		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}
 
		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}
 
		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}
 
		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}
		
		public int[] nextIntArray(int n) throws IOException {
			final int[] ret = new int[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextInt();
			}
			return ret;
		}
		
		public long[] nextLongArray(int n) throws IOException {
			final long[] ret = new long[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextLong();
			}
			return ret;
		}
 
		public void close() throws IOException {
			br.close();
		}
	}
}

Measured memory_bytes: 45160
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;

int main() {
	int a, b, c;
	scanf("%d%d%d", &a, &b, &c);
	int xmin = 0, ymin = 0, xmax = a, ymax = b;
	for (int d = 0; d < c; d++) {
		int e, f, g;
		cin >> e >> f >> g;
		switch (g) {
		case 1:xmin = max(xmin, e); break;
		case 2:xmax = min(xmax, e); break;
		case 3:ymin = max(ymin, f); break;
		case 4:ymax = min(ymax, f); break;
		}
	}
	printf("%d\n", max(0,xmax - xmin)*max(0,ymax - ymin));
}

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

#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif

const int inf=1e9;
const int64_t inf64=1e18;
const double eps=1e-9;

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
    	os << v << ",";
    }
    os << "]";
    return os;
}

using i64=int64_t;

i64 eval_number(const string& expr,int& i){
    i64 res=0;
    while(i<expr.size() and isdigit(expr[i])){
        res*=10;
        res+=expr[i]-'0';
        ++i;
    }
    return res;
}

void consume(const string& s,int& i,char c){
    assert(s[i]==c);
    ++i;
}

i64 eval_term(const string&,int&);
i64 eval_expr(const string&,int&);

i64 eval_term(const string& term,int& i){
    if(isdigit(term[i])) return eval_number(term,i);
    consume(term,i,'S');
    while(term[i]==' ') consume(term,i,' ');
    consume(term,i,'<');
    while(term[i]==' ') consume(term,i,' ');
    i64 x=eval_expr(term,i);
    while(term[i]==' ') consume(term,i,' ');
    consume(term,i,'>');
    return x*x%1000000007;
}

i64 eval_expr(const string& expr,int& i){
    i64 x=eval_term(expr,i);
    for(;;){
        if(i==expr.size()) break;
        int j=i;

        while(j<expr.size() and expr[j]==' ') consume(expr,j,' ');
        if(j==expr.size() or expr[j]!='>') return x;
        consume(expr,j,'>');
        if(j==expr.size() or expr[j]!='>') return x;
        consume(expr,j,'>');
        while(j<expr.size() and expr[j]==' ') consume(expr,j,' ');
        if(j==expr.size() or (expr[j]!='S' and !isdigit(expr[j]))) return x;
        i=j;
        i64 y=eval_term(expr,i);
        rep(i,0,y){
            if(x==0) break;
            x>>=1;
        }
    }
    return x;
}

void solve(string expr){
    int i=0;
    cout << eval_expr(expr,i) << endl;
}

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    for(;;){
        string expr;
        getline(cin,expr);
        if(expr=="#") break;
        solve(expr);
    }
    return 0;
}

Measured memory_bytes: 5548
#include<iostream>

using namespace std;

int main(){

   while(1){

      int n, r;
      cin>> n>> r;
      if(n==0&&r==0) break;
      int a[n];
      for(int i=0; i<n; i++) a[i]=n-i;
      for(int i=0; i<r; i++){
         int p, c;
         cin>> p>> c;
         int b[c];
         for(int j=p-1; j<p+c-1; j++){
            b[j-(p-1)]=a[j];
         }
         for(int j=p+c-2; j>c-1; j--){
            a[j]=a[j-c];
         }
         for(int j=0; j<c; j++){
            a[j]=b[j];
         }
      }

      cout<< a[0]<< endl;
   }
   return 0;
}

Measured memory_bytes: 3084
#include <iostream>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <vector>
#include <float.h>
using namespace std;
typedef long long ll;
#define loop(i, N) for(int i=0; i<N; ++i)


int main(void) {
	int a;
	string s;
	cin >> a >> s;
	if (a >= 3200) cout << s << endl;
	else cout << "red" << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<cstdio>
using namespace std;

int main(){
    double x1,y1,x2,y2;
    int q;
    cin >> x1 >> y1 >> x2 >> y2 >> q;
    for(int i=1; i<=q; i++){
        double xp,yp,x,y;
        cin >> xp >> yp;
        double a,b,f;
        if(x1==x2){
            printf("%.12lf %.12lf\n",2*x1-xp,yp);
        }
        else if(y1==y2){
            printf("%.12lf %.12lf\n",xp,2*y1-yp);
        }
        else{
            a=(y2-y1)/(x2-x1);
            b=y1-a*x1;
            f=yp+1.0/a*xp;
            x=(f-b)/(a+1.0/a);
            y=a*x+b;
            x=2*x-xp;
            y=2*y-yp;
            printf("%.12lf %.12lf\n",x,y);
        }
    }
    return 0;
}


Measured memory_bytes: 3296
for roop in range(int(raw_input())):
    h,m = map(int,raw_input().split(":"))
    s = 60*h + m
    l = 12*m
    d = abs(l-s)
    arg = d if d < 180*2 else 360*2-d
    if   arg < 30*2: print "alert"
    elif arg < 90*2: print "warning"
    else    : print "safe"

Measured memory_bytes: 4216
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<cctype>
#include <fstream>
#include <time.h>
#include <iterator>





#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define m0(x) memset(x,0,sizeof(x))
#define fil(x,y) memset(x,y,sizeof(x))
#define print(x) cout<<x<<endl;
#define pe(x) cout<<x<<" ";
#define lb(v,n) lower_bound(v.begin(), v.end(), n);
#define ub(v,n) upper_bound(v.begin(), v.end(), n);
#define int long long
#define all(x) (x).begin(), (x).end()
using namespace std;
int MOD = (ll)1000000000 + 7;
const ll INF = 1e17;
const double pi = acos(-1);
const double EPS = 1e-10;
typedef pair<int, int>P;
const int MAX = 500050;



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

	int A, B, N; cin >> N >> A >> B;
	print(min(N*A,B));
}

Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <unordered_map>
#include <climits>
#include <set>
#include <unordered_set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <complex>
#include <regex>

using namespace std;

#define SHOW_VECTOR(v) {std::cerr << #v << "\t:";for(const auto& xxx : v){std::cerr << xxx << " ";}std::cerr << "\n";}
#define SHOW_MAP(v){std::cerr << #v << endl; for(const auto& xxx: v){std::cerr << xxx.first << ” ” << xxx.second << “\n”;}}

using LL = long long;

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

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

constexpr long long INF = 1e12;

vector<LL> h, dp;

//i以降からゴールまでかかるコストを返す
LL f(int i, int N) {
    if (dp[i] < INF) return dp[i];
    long long cost = INF;
    for (int j = 1; j <= 2; j++) {
        int to = min(i + j, N - 1);
        chmin(cost, f(to, N) + abs(h[i] - h[to]));
    }
    return dp[i] = cost;
}

int main() {

    int N;
    cin >> N;

    h = vector<LL>(N);
    for (int i = 0; i < N; i++) cin >> h[i];

    dp = vector<LL>(N, INF);
    dp[N - 1] = 0;

    cout << f(0, N) << endl;

    return 0;
}































Measured memory_bytes: 9600
#include <assert.h>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
 
using ll = long long;
using P = std::pair<long double, ll>;
 
#define rep(i, a, b) for (ll(i) = (a); i < (b); i++)
#define all(i) i.begin(), i.end()
#define debug(i) std::cerr << "debug " << #i <<" "<<i<<std::endl;
 
template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2> pa) {
  return os << pa.first << " " << pa.second;
}
 
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (int i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}
 
template<typename T1,typename T2>
inline bool chmax(T1& a,T2 b){return a<b && (a=b,true);}
 
template<typename T1,typename T2>
inline bool chmin(T1& a,T2 b){return a>b && (a=b,true);}
 
// const ll MOD = 998244353;
const ll MOD = 1e9 + 7;


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

  ll n;
  std::cin>>n;

  std::vector<ll> dp(n+3,-1);
  dp[0]=MOD;

  rep(i,0,n){
    ll a;
    std::cin>>a;

    ll left=-1,right=n+3;

    while(right-left>1){
      ll mid=left+(right-left)/2;

      if(dp[mid]<a)right=mid;
      else left=mid;
    }

    dp[right]=a;

    //debug(dp);

  }

  rep(i,0,n+3){
    if(dp[i]==-1){
      std::cout<<i-1;
      return 0;
    }
  }

  return 0;
}





Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int main(){
    string s;
    cin>>s;
    if(s[2]==s[3]){
        if(s[4]==s[5]){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define max 1000000
#define pb push_back
#define pairs pair<int, int>
#define vi vector<int>
#define vb vector<bool>
#define vii vector<pairs>
#define lb lower_bound
#define ub upper_bound
#define lli long long int
#define endl '\n'
#define FastInput ios_base::sync_with_stdio(false), cin.tie(NULL);
#define Cases  cout << "Case " << ++Case << ": ";
#define __test int tt; int Case=0; cin >> tt; while(tt--)
#define read(x) freopen(x, "r", stdin)
#define write(x) freopen(x, "w", stdout)
#define InputArray(a,n) for(int i=0;i<n;i++) cin >> a[i];
#define CopyArray(a,temp,n) for(int i=0;i<n;i++) temp[i]=a[i];
#define PrintArray(a,n) for(int i=0;i<n;i++) cout << a[i] << " "; cout << endl;
using namespace std;


int main() {
#ifdef Niloy
	read("input.txt");
	write("output.txt");
#endif
	FastInput;
	int n;
	map<string, int> mp;
	cin >> n;
	while(n--) {
		string a;
		cin >> a;
		mp[a]++;
	}

	cout << mp.size() << endl;

	cerr << "time = " << (clock() / CLOCKS_PER_SEC) << " sec" << '\n';
	return 0;
}

Measured memory_bytes: 19312
require 'prime'
loop do
  m, a, b = gets.split.map(&:to_i)
  break if m == 0
  ans = []
  Prime.each.lazy.take_while{ |p| p <= Math.sqrt(100000).to_i && p * p <= m }.each do |p|
    q = Prime.each.lazy.drop_while{ |q| q < p  }
                       .take_while{ |q| a * q <= b * p && p * q <= m }.to_a.last
    ans << [p * q, p, q] if q
  end
  puts ans.sort[-1][1..2] * ' '
end

Measured memory_bytes: 9872
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int N;
    string S;
    cin >> N;
    cin >> S;
    int count = 0;
    for(int i = 0; i <= N-3; i++){
        if(S[i] == 'A' && S[i+1] == 'B' && S[i+2] == 'C' ) count+=1;
    }
    cout << count;
}


Measured memory_bytes: 256
import math

n = int(input())
x = n
print(f'{x}:', end='')
cnt = 0
for i in range(2, n+1):
    if x==1:
        break
    
    if i>math.sqrt(n) and cnt==0:
        print(f' {n}', end='')
        break
    

    while x%i==0:
        cnt += 1
        x=x//i
        print(f' {i}', end='')
        
print()
    
    


Measured memory_bytes: 5672
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace mondai0034
{
	class Program
	{
		static void Main(string[] args)
		{
			while( true ) {
				var	s	= Console.ReadLine();
				if( s == null ) {
					break;
				}
				var	ss	= s.Split( ',' );
				var	kukan	= new int[ 10 ];
				for( int i = 0; i < 10; i++ ) {
					kukan[ i ]	= int.Parse( ss[ i ] );
				}
				var	v1	= int.Parse( ss[ 10 ] );
				var	v2	= int.Parse( ss[ 11 ] );
				
				var	all_kukan	= kukan.Sum();
				var	t	= all_kukan / (double)(v1 + v2);
				var	k	= v1 * t;

				int	chk_k	= 0;
				for( int i = 0; i < 10; i++ ) {
					chk_k	+= kukan[ i ];
					if( chk_k >= k ) {
						Console.WriteLine( i + 1 );
						break;
					}
				}
			}
		}
	}
}

Measured memory_bytes: 5756
#include<stdio.h>
    #include<string.h>
    int main(void){
    int A,B,C,D,E,N,M,x,y,i,j,cou=0,cou2,v[1000000],w[1000000],min_i,en=0;
        char S[100][100],W[100],s[10],X,Y;
       for(i=0;i<3;i++){
            scanf("%s",&S[i]);
    }
    printf("%c%c%c",S[0][0],S[1][1],S[2][2]);
    return 0;
    }

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

signed main(){
	ll H, W, K;
	cin >> H >> W >> K;
	vector<string> S(H);
	for(ll i=0;i<H;i++) {
		cin >> S[i];
	}

	ll ans = LLONG_MAX;
	for(ll bit=0;bit<(1<<(H-1));bit++) {
		// sliceする場所
		vector<ll> sl;
		for(ll i=0;i<H-1;i++)
			if(bit & (1<<i))
				sl.push_back(i);

		sl.push_back(LLONG_MAX);
		vector<ll> white((ll)sl.size(), 0);
		bool flag = true;

		// 線の本数
		ll line = (ll)sl.size() - 1;
		for(ll w=0;w<W;w++) {
			// 横線何本目より前か
			ll cnt = 0;
			vector<ll> nx_white((ll)white.size(), 0);
			for(ll h=0;h<H;h++) {
				if(h > sl[cnt]) {
					cnt++;
				}
				if(S[h][w] == '1') nx_white[cnt]++;
				if(nx_white[cnt] > K) {
					flag = false;
					break;
				}
			}
			if(flag == false) break;

			bool linef = false;
			for(ll i=0;i<white.size();i++) {
				if(white[i] + nx_white[i] > K) {
					line++;
					linef = true;
					break;
				}
			}
			if(linef) {
				for(ll i=0;i<white.size();i++)
					white[i] = nx_white[i];
			} else {
				for(ll i=0;i<white.size();i++)
					white[i] += nx_white[i];
			}
		}
		if(flag)ans = min(ans, line);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256