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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef map<ll,ll>::iterator itll;
typedef long double ld;
typedef map<ll,ll> mapll;

#define con continue
#define pb push_back
#define fi first
#define se second
#define fr front()
#define INF 1000000000000000000
#define all(vl) vl.begin(),vl.end()
#define m_p make_pair 
#define sz(a) sizeof(a)
#define forn(mp,it) for(it = mp.begin();it!=mp.end();it++)
#define FOR(i,a,n) for(ll i=a;i<n;i++) 
#define FORE(i,a,n) FOR(i,a,n+1)
#define Endl endl
#define eNdl endl
#define enDl endl
#define endL endl

const double one = 1.0;
const double PI = 3.141592653589;
const ll m = 998244353;

int main() 
{
	ll n,k,m;
	cin>>n>>k>>m;
	vector<ll> vl;
	map<ll,ll> pos;
	vl.pb(k);
	pos[k] = 1;
	ll fip,lsp;
	ll an = k;
	if(n<=m){
		ll ans = 0;
		FOR(i,0,n)
		{
			ans+=k;
			k*=k;
			k%=m;
		}
		cout<<ans<<Endl;
		return 0;
	}
	FOR(i,1,m+1)
	{
		k*=k;
		k%=m;
		if(pos[k]!=0)
		{
			fip = pos[k]-1;
			lsp = i-1;
			break;
		}
		vl.pb(k);
		pos[k] = i+1;
	}
	ll ans = 0;
	FOR(i,0,fip)
	{
		ans+=vl[i];
	}
	ll ans1 = 0;
	ll zhouqi = 0;
	FOR(i,fip,lsp+1)
	{
		zhouqi+=vl[i];
	}
	ll z = (n-(fip))/(lsp-fip+1);
	ll y = (n-(fip))%(lsp-fip+1);
	ans1= zhouqi*z;
	FOR(i,fip,fip+y)
	{
		ans1+=vl[i];
	}
//	cout<<"ans1="<<ans1<<Endl;
//	cout<<"ans="<<ans<<endl;
//	cout<<"周期="<<zhouqi<<endl;
//	cout<<"周期个数="<<z<<Endl;
//	cout<<"后缀个数="<<y<<Endl; 
//	cout<<"周期长度="<<lsp-fip+1<<endl;
	cout<<(ans1+ans)<<Endl;
	return 0;
}

Measured memory_bytes: 6712
//============================================================================
// Name        : c.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include<vector>
using namespace std;
typedef long long ll;
int main() {
	int n;cin>>n;
	vector<ll> a(n+1),b(n);
	for(int i=0;i<=n;i++){
		cin>>a[i];
	}
	for(int i=0;i<n;i++){
		cin>>b[i];
	}
	ll ans=0;
	ll res=0;
	ll o=0;
	for(int i=0;i<n;i++){
		ans+=min(a[i],b[i]);
		res=max(b[i]-a[i],o);
		ans+=min(a[i+1],res);

		a[i+1]=max(a[i+1]-res,o);
//		cout<<ans<<' '<<res<<endl;
	}
	cout<<ans<<endl;
	return 0;
}


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

#define REPI(x) for(int i=0;i<x;i++)
#define REPJ(x) for(int j=0;j<x;j++)

using namespace std;

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

    if (S.size ()<=K){
        cout << S << endl;
    }else {
        cout << S.substr (0,K) << "..." << endl;
    }
    return 0;
}

Measured memory_bytes: 3636
#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 REPD(i,a,b) for (int i=(a);i<=(b);i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef set<int> si;
typedef vector<si> vsi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<int, int> pi;
typedef queue<int> qi;
typedef queue<pi> qpi;
typedef pair<ll, ll> pll;
typedef queue<pll> qpll;
typedef vector<pi> vpi;
typedef vector<pll> vpll;
const int mod = 1000000007;
const int INF = 1001001001;
// 小数点　<< fixed << setprecision(0) <<
// sort降順　sort(ALL(),greater<int>());
// 円周率　M_PI
// 文字判定　isupper islower
// 文字変換　
// 順列　do {} while(next_permutation(ALL(X)));
// 最大値　LLONG_MAX
// a内でx以上　auto iter = lower_bound(ALL(a), x);
// a内でxより大きい　auto iter = upper_bound(ALL(a), x);
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
struct edge {
    int from; //出発点
    int to;   //到達点
    int cost; //移動コスト
};
typedef struct edge se;
typedef vector<edge> ve;
unsigned Euclidean_gcd(unsigned a, unsigned b) {
  if(a < b) return Euclidean_gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

int digit_sum(int n) {
  int sum=n%10;
  while(n!=0) {
    n/=10;
    sum+=n%10;
  }
  return sum;
}

vpll PrimeFactorization(ll n) {
  vpll res;
  for (ll i=2; i*i<=n; i++) {
    if(n%i!=0) continue;
    ll ex=0;
    while(n%i==0) {
      ex++;
      n/=i;
    }
    res.push_back(pll(i,ex));
  }
  if(n!=1) res.push_back(pll(n,1));
  return res;
}




int main() {
  int n,m;
  cin >> n >> m;
  vvi br(n);
  REP(i,m) {
    int a,b;
    cin >> a >> b;
    a--;
    b--;
    br[a].push_back(b);
    br[b].push_back(a);
  }
  REP(i,n) {
    cout << br[i].size() << endl;
  }
  return 0;
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int k;
  cin >> k;

  if (k % 2 == 1) {
    cout << k / 2 * (k / 2 + 1) << endl;
  } else {
    cout << k / 2 * k / 2 << endl;
  }

  return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Map;
import java.util.StringTokenizer;
import java.util.TreeMap;

//http://codeforces.com/contest/1095/problem/B
public class Main {

	public static void main(String[] args) throws Exception {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		XeniaAndBitOperations solver = new XeniaAndBitOperations();
		// int test = in.nextInt();
		// while (test-- > 0)
		solver.solve(1, in, out);
		out.close();
	}

	static class XeniaAndBitOperations {

		public void solve(int testNumber, InputReader in, PrintWriter out) throws Exception {

			int n = in.nextInt();
			int h[] = new int[n];
			int dp[] = new int[n];

			for (int i = 0; i < n; i++)
				h[i] = in.nextInt();

//			int ans = mincost(n - 1, h);
//			System.out.println(ans);
			
			dp[1] = Math.abs(h[1]-h[0]);
			for(int i=2; i<n; i++)
			{
				int cost1 = dp[i-1] + Math.abs(h[i] - h[i - 1]);
				int cost2 = dp[i-2] + Math.abs(h[i] - h[i - 2]);
				dp[i]= Math.min(cost1, cost2);
			}
			System.out.println(dp[n-1]);
		}

		private int mincost(int i, int[] h) {
			
			if (i > 0) {
				int cost1 = mincost(i - 1, h) + (i-1>=0 ? Math.abs(h[i] - h[i - 1]) : Integer.MAX_VALUE);
				int cost2 = mincost(i - 2, h) + (i-2>=0 ? Math.abs(h[i] - h[i - 2]) : Integer.MAX_VALUE);

				return Math.min(cost1, cost2);
			}
			
			return 0;
		}

	}

	static class InputReader {
		public BufferedReader reader;
		public StringTokenizer tokenizer;

		public InputReader(InputStream stream) {
			reader = new BufferedReader(new InputStreamReader(stream), 32768);
			tokenizer = null;
		}

		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}

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

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

	}
}

Measured memory_bytes: 33420
N,K=map(int,input().split())
A=[list(map(int,input().split())) for _ in range(N)]
A=sorted(A, key=lambda x: x[0])

cnt=0
for i in range(N):
    a,b=A[i]
    A[i][1]+=cnt
    cnt=A[i][1]

for i in range(N):
    a,b=A[i]
    if K<=b:break
print(a)


Measured memory_bytes: 31536
program main
      implicit none
      integer :: n, k, i
      integer, allocatable :: p(:)
      real(16), allocatable :: s(:)
      real(16), allocatable :: sk(:)

      read *, n, k
      allocate( p(n) )
      read *, p
      allocate( s(0:n) )
      allocate( sk(n-k+1) )

      s = 0.0
      do i = 1, n
        s(i) = s(i-1)+(1+p(i))/2.0
      end do

      sk = 0.0
      do i = 1, n-k+1
        sk(i) = s(i+k-1)-s(i-1)
      end do

      print *, maxval(sk)

end program main


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

using namespace std;

#define N 100'010
#define MOD 1'000'000'007

auto edge = new vector<int32_t>[N];
auto parent = new int32_t[N];
auto dp = new int64_t[N][2];

void dfs(int32_t v) {
  dp[v][0] = dp[v][1] = 1;
  for (auto u : edge[v]) {
    if (u != parent[v]) {
      parent[u] = v;
      dfs(u);
      dp[v][0] = (dp[v][0] * (dp[u][0] + dp[u][1])) % MOD;
      dp[v][1] = (dp[v][1] * dp[u][0]) % MOD;
    }
  }
}

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

  parent[0] = 0;
  dfs(0);

  cout << (dp[0][0] + dp[0][1]) % MOD << endl;
}


Measured memory_bytes: 13312
/*--------------------------"SABUJ-JANA"------"JADAVPUR UNIVERSITY"--------*/
/*-------------------------------@greenindia-----------------------------------*/
//
//		  _____       _           _        _
//		 / ____|     | |         (_)      | |
//		| (___   __ _| |__  _   _ _       | | __ _ _ __   __ _
//		 \___ \ / _` | '_ \| | | | |  _   | |/ _` | '_ \ / _` |
//		 ____) | (_| | |_) | |_| | | | |__| | (_| | | | | (_| |
//		|_____/ \__,_|_.__/ \__,_| |  \____/ \__,_|_| |_|\__,_|
//		                        _/ |
//		                       |__/
/*---------------------- Magic. Do not touch.-----------------------------*/
/*------------------------------God is Great/\---------------------------------*/
#include <bits/stdc++.h>
using namespace std;
#define crap ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
//cout<<fixed<<showpoint<<setprecision(12)<<ans<<endl;
#define int long long int
#define double long double
#define PI acos(-1)
typedef vector<int> vi;
typedef vector<vector<int>> vvi;

void print1d(const vector<int>& vec) {for (auto val : vec) {cout << val << " ";} cout << endl;}

void print2d(const vector<vector<int>>& vec) {for (auto row : vec) {for (auto val : row) {cout << val << " ";} cout << endl;}}

signed main() {
	crap;

	double a, b, h, m;
	cin >> a >> b >> h >> m;
	double deg = 30 * h - (double)((11 * m) / 2);
	double theta = (deg * (double)(PI) / 180) ;
	double val = a * a + b * b - (2 * a * b * cos(theta));
	cout << fixed << showpoint << setprecision(12) << sqrt(val) << endl;


	return 0;
}

Measured memory_bytes: 4188
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<vint> vv;
typedef vector<vv> vvv;
typedef vector<vvv> vvvv;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
string ma[114];
int yo[114][114][114],ta[114][114][114];
vvvv dp;
	vector<int> vi;
int main()
{
	int h,w,ex,ey,out=0;
	cin>>h>>w;
	rep(i,h) cin>>ma[i];
	rep(i,h) rep(j,w){
		if(ma[i][j]=='E') ex=i,ey=j;
	}
	//cout<<ex<<' '<<ey<<endl;
	rep(i,h) rep(j,w){
		if(ma[i][j]=='o') yo[i][j][j]=1;else yo[i][j][j]=0;
		REP(k,j+1,w){
			yo[i][j][k]=yo[i][j][k-1];
			if(ma[i][k]=='o') yo[i][j][k]++;
		}
	}
	rep(i,w) rep(j,h){
		if(ma[j][i]=='o') ta[i][j][j]=1;else ta[i][j][j]=0;
		REP(k,j+1,h){
			ta[i][j][k]=ta[i][j][k-1];
			if(ma[k][i]=='o') ta[i][j][k]++;
		}
	}
	//cout<<'a'<<endl;
	//rep(i,w-ey+2) vi.pb(0);
	//vv Vv(ey+2,vi);
	dp=vvvv(ex+2,vvv(h-ex+2,vv(ey+2,vint(w-ey+2,0))));
	//cout<<'a'<<endl;
	//cout<<ta[1][0][2]<<endl;
	rep(i,ex+1) rep(j,h-ex) rep(k,ey+1) rep(l,w-ey){
		//printf("%d%d%d%d %d\n",i,j,k,l,dp[i][j][k][l]);
		out=max(out,dp[i][j][k][l]);
		int lx=max(ex-i,j),hx=min(ex+j,h-i-1),ly=max(ey-k,l),hy=min(ey+l,w-k-1);
		//cout<<lx<<hx<<ly<<hy<<endl;
		if(ly<=hy && j<ex-i){
			dp[i+1][j][k][l]=max(dp[i+1][j][k][l],dp[i][j][k][l]+yo[ex-i-1][ly][hy]);
		}
		if(ly<=hy && h-i-1>ex+j){
			dp[i][j+1][k][l]=max(dp[i][j+1][k][l],dp[i][j][k][l]+yo[ex+j+1][ly][hy]);
		}
		if(lx<=hx && l<ey-k){
			dp[i][j][k+1][l]=max(dp[i][j][k+1][l],dp[i][j][k][l]+ta[ey-k-1][lx][hx]);
		}
		if(lx<=hx && w-k-1>ey+l){
			dp[i][j][k][l+1]=max(dp[i][j][k][l+1],dp[i][j][k][l]+ta[ey+l+1][lx][hx]);
		}
	}
	cout<<out<<endl;
}


Measured memory_bytes: 44800
N,W=map(int,input().split())
A=[]
for _ in range(N):
    B=list(map(int,input().split()))
    A.append(B)
dp=[]
for _ in range(N):
    dp.append([0]*(W+1))
for j in range(W+1):
    if j>=A[0][0]:
        dp[0][j]=A[0][1]
for i in range(0,N-1):
    for w in range(W+1):
        if w>=A[i+1][0]:
            dp[i+1][w]=max(dp[i][w-A[i+1][0]]+A[i+1][1],dp[i][w])
        else:
            dp[i+1][w]=dp[i][w]
print(dp[N-1][W])

Measured memory_bytes: 120172
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
int main() {
  int n, m, a=0;
  cin >> n >> m;
  rep(i, m) {
    int t;
    cin >> t;
    a += t;
  }
  n >= a ? cout << n - a : cout << -1;
}


Measured memory_bytes: 3624
#include<stdio.h>
#include<stdlib.h>

int gcd(x, y) {
  int temp;
  if(x > y) {
    temp = y;
    y = x;
    x = temp;
  }

  y = y%x;
  if(y == 0) return x;
 
  gcd(x, y);
}

int main() {
  int x, y;
  int ans;
  scanf("%d %d", &x, &y);
  ans = gcd(x, y);
  printf("%d\n", ans);

  return 0;
}

Measured memory_bytes: 592
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
#define rep(i,n) for (int i=0; i<n;++i)
using namespace std;
int N;
int A[100003], B[100003], C[100003];
int H[100004][3]; // happiness // n日目にA, B, Cをした

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

  cin >> N;
  rep(i, N) {
    cin >> A[i] >> B[i] >> C[i];
  }
  // 概念としての0日目を設ける。1-N日目が実際の活動とする。
  rep(i, N) {
    rep(j, 3) {
      H[i+1][1] = max(H[i][0]+B[i], H[i+1][1]);
      H[i+1][2] = max(H[i][0]+C[i], H[i+1][2]);
      H[i+1][0] = max(H[i][1]+A[i], H[i+1][0]);
      H[i+1][2] = max(H[i][1]+C[i], H[i+1][2]);
      H[i+1][0] = max(H[i][2]+A[i], H[i+1][0]);
      H[i+1][1] = max(H[i][2]+B[i], H[i+1][1]);
    }
  }
  int ans = max(H[N][0], max(H[N][1], H[N][2]));
  cout << ans << "\n";
  return 0;
}

Measured memory_bytes: 2560
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

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

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

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

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

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

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

fn main(){
    input!{
        q:chars
    }
    print!("{}", (if q[2] == q[3] && q[4] == q[5] {"Yes"} else {"No"}).to_string())
}


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

#define TRACE(x) x
#define WATCH(x) TRACE(cout << #x" = " << x << endl)
#define WATCHR(a, b) TRACE(for (auto it=a; it!=b;) cout << *(it++) << " "; cout << endl)
#define WATCHC(V) TRACE({cout << #V" = "; WATCHR(V.begin(), V.end());})

#define all(x) (x).begin(), (x).end()

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;

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

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

    int N;
    cin >> N;

    vi x(N), y(N);
    for (int i = 0; i < N; i++) {
        cin >> x[i] >> y[i];
    }

    bool par = (x[0] ^ y[0])&1;
    for (int i = 1; i < N; i++) {
        if (((x[i] ^ y[i])&1) != par) {
            cout << -1 << endl;
            return 0;
        }
    }

    vi arms;
    for (int p2 = 30; p2 >= 0; p2--) {
        arms.push_back(1 << p2);
    }
    if (!par) {
        arms.push_back(1);
    }

    cout << arms.size() << "\n";
    for (int v : arms)
        cout << v << " ";
    cout << "\n";

    string dirs = "LRDU";
    vector<array<int, 2>> move = { { -1, 0 }, { 1, 0 }, { 0, -1 }, { 0, 1 } };

    for (int i = 0; i < N; i++) {
        array<ll, 2> loc = { 0, 0 };
        for (int v : arms) {
            char ch;
            ll ndist = LLONG_MAX;
            array<ll, 2> upd = { 0, 0 };

            for (int d = 0; d < 4; d++) {
                array<ll, 2> after = { loc[0] + move[d][0] * v, loc[1] + move[d][1] * v };
                ll adist = abs(after[0] - x[i]) + abs(after[1] - y[i]);
                if (adist < ndist) {
                    ch = dirs[d];
                    ndist = adist;
                    upd = after;
                }
            }

            cout << ch;
            loc = upd;
        }
        cout << "\n";

        array<ll, 2> goal = { x[i], y[i] };
        assert(loc == goal);
    }

    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
    using namespace std;
    typedef long long ll;
    #define FAST ios_base::sync_with_stdio(false);cin.tie(0);
    const double EPS = 1e-9;
    const double PI = acos(-1);
    const int knightDir[8][2] = {{-2,-1},{-2,1},{-1,2},{1,2},{2,-1},{2,1},{-1,-2},{1,-2}};
    //const int dx[]={0,0,0,1,1,1,-1,-1,-1};
    //const int dy[]={-1,0,1,-1,0,1,-1,0,1};
    const int dx[] = {0 , 1 , 0 , -1};
    const int dy[] = {1 , 0 , -1 , 0};
    //#define MOD         1000000007LL
    #define MAX         1005
    const ll MOD = 1000000000 + 7;

    bool vis[MAX][MAX];
    int cost[MAX][MAX];
    string maze[MAX];
    int w , h ,cx , cy , fx , fy;
    bool isSafe(int x , int y)
    {
        if(x < 0 || x >= w || y < 0 || y >= h)return false;
        return true;
    }
    int main()
    {
        FAST
        int t;
        t = 1;

        while(t--)
        {

           cin >> w >> h;
           cin >> cx >> cy;
           cx-- , cy--;
           cin >> fx >> fy;
           fx--,fy--;

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

           memset(cost , -1 , sizeof cost);

           deque<pair <int , int > > q;
           q.push_front({cx , cy});
           cost[cx][cy] = 0;

           while(!q.empty())
           {

               pair <int, int> t = q.front();
               q.pop_front();

               if(vis[t.first][t.second])
               {
                   continue;
               }
               vis[t.first][t.second] = true;

               for(int i = 0 ; i < 4 ; i++)
               {
                   int nx = t.first + dx[i];
                   int ny = t.second + dy[i];

                   if(!isSafe(nx , ny))continue;
                   if(maze[nx][ny] == '#')continue;

                   if(cost[nx][ny] == -1 || cost[t.first][t.second] < cost[nx][ny])
                   {
                       cost[nx][ny] = cost[t.first][t.second];
                       q.push_front({nx , ny});
                   }

               }

               for(int i = -2 ; i < 3 ; i++)
               {
                   for(int j = -2 ; j < 3 ; j++)
                   {
                       int nx = t.first + i;
                       int ny = t.second + j;

                       if(!isSafe(nx , ny))continue;
                       if(maze[nx][ny] == '#')continue;

                       if(cost[nx][ny] == -1 || cost[t.first][t.second] + 1 < cost[nx][ny])
                       {
                           cost[nx][ny] = cost[t.first][t.second] + 1;
                           q.push_back({nx , ny});
                       }

                   }
               }

           }

           cout << cost[fx][fy] << endl;
        }
    }



Measured memory_bytes: 9732
#include <bits/stdc++.h>
using namespace std;
#include <bits/stdc++.h>
#include <stdio.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
typedef long long LL;
typedef pair<int, int> PII;
int f(){
   int n;
   char a; 
   //cin.get(a);
   LL sum=0;
   while(!(cin.eof())){
        cin.get(a);
        n = atoi(&a);
        sum+=n;
   }
   if(sum % 9 == 0)
    cout << "Yes" << endl;
   else
   {
        cout << "No" << endl;
   }
   
   return 0;
}

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

Measured memory_bytes: 3600
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    def calc(x, y):
        ans = INF
        area = x * y
        for i in range(1, x):
            first = y * i
            x_rem = x - i
            rem = area - first
            if x_rem % 2 == 0 or y % 2 == 0:
                second = rem // 2
                third = rem // 2
            else:
                second = min(x_rem, y) * (max(x_rem, y) // 2 + 1)
                third = rem - second
            score = max(first, second, third) - min(first, second, third)
            ans = min(ans, score)
        return ans

    h, w = map(int, readline().split())

    if h % 3 == 0 or w % 3 == 0:
        print(0)
    else:
        ans = min(calc(h, w), calc(w, h))
        print(ans)


if __name__ == '__main__':
    main()


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

#define debug(n) cerr << #n << ':' << n << endl;

using namespace std;

using  ll = long long;

template<class T,class U>
using umap = unordered_map<T,U>;

template<class T>
using uset = unordered_set<T>;

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

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


int main(){
  int n, k; cin >> n >> k;
  string s; cin >> s;
  int score = 0;
  for(int i = 0; i < n - 1; ++i){
    if(s[i] == 'R' && s[i + 1] == 'R')score++;
  }
  for(int i = 1; i < n; ++i){
    if(s[i] == 'L' && s[i - 1] == 'L')score++;    
  }
  int change = 0;
  for(int i = 0; i < n - 1; ++i){
    if(s[i] != s[i + 1])change++;
  }
  score += min(k*2, change);
  cout << score << endl;
  return 0;
}


Measured memory_bytes: 512
L, R = map(int,input().split())

if R-L >= 672:
    print(0)
    
elif R-L == 1:
    print((L*R) % 2019)

elif R-L >= 2:
    for i in range(L//673, R//673 + 1):
        if L <= 673 * i <= R:
            print(0)
            break
    else:
        ans = 2018
        for i in range(L, R):
            for j in range(i+1, R+1):
                k = (i*j) % 2019
                if k < ans:
                    ans = k
        print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
  
int main() {
  ll X,Y;
  cin >> X >> Y;
  int ans = 0;
  while(X <= Y) {
    X = X << 1;
    ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        
        if (x == 7 || x == 5 || x == 3){
            System.out.println("YES");
        }else {
            System.out.println("NO");
        }

    }

}
 

Measured memory_bytes: 22612
package main

import (
	"fmt"
)

func main() {
	var a, b int
	fmt.Scan(&a, &b)
	if a == b {
		fmt.Println("Draw")
		return
	}
	if a == 1 {
		fmt.Println("Alice")
		return
	}
	if b == 1 {
		fmt.Println("Bob")
		return
	}
	if a > b {
		fmt.Println("Alice")
	} else {
		fmt.Println("Bob")
	}
}


Measured memory_bytes: 1832
<?php

function work(&$A, $x, $y) {
    $A[$x][$y] = 0;
    for ($i = -3; $i <= 3; $i++) {
        for ($j = -3; $j <= 3; $j++) {
            if (0 <= $x + $i && $x + $i < 8 && 0 <= $y + $j && $y + $j < 8 && ($i == 0 || $j == 0)) {
                if ($A[$x + $i][$y + $j] == 1) {
                    work($A, $x + $i, $y + $j);
                }
            }
        }
    }
}

fscanf(STDIN, "%d", $data_num);
for ($c = 1; $c <= $data_num; $c++) {
    fscanf(STDIN, "%d", $a);
    $array = array();
    for ($i = 0; $i < 8; $i++) {
        fscanf(STDIN, "%d", $a);
        $a = str_pad($a, 8, "0", STR_PAD_LEFT);
        array_push($array, $a);
    }
    fscanf(STDIN, "%d", $x);
    fscanf(STDIN, "%d", $y);

    //print_r($array);
    work($array, $y - 1, $x - 1);
    print "Data " . $c . ":\n";
    for ($i = 0; $i < 8; $i++) {
        print $array[$i] . "\n";
    }
    //print_r($array);
    unset($array);
}
?>

Measured memory_bytes: 6640
#include<iostream>
using namespace std;
int suretu[100000];
int cont = 0, max_sum = 0;

int ret_maxsum(int n, int k, int wa, bool isBegin)
{
	int temp = 0;
	int i;
	if(isBegin == 1){for(i = 0; i < k; i++){temp += suretu[cont+i];}}
	else{temp += wa + suretu[cont+k-1];}
	wa = temp - suretu[cont];
	cont++;
	if(max_sum < temp){max_sum = temp;}
	if(cont == n-k+1){return max_sum;}
	else{return ret_maxsum(n, k, wa, 0);}
}
main()
{
	for(;;){
		int n,k;
		cin >> n;
		cin >> k;
		if(n == 0 && k == 0){
			break;
		}
		for(int i = 0; i < n; i++){
			cin >> suretu[i];
		}
		printf("%d\n",ret_maxsum(n, k, 0, 1));
	}
}

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

int main(){
	string s;
	cin >> s;
	if(s=="AKIHABARA"||s=="AKIHABAR" || s=="AKIHABRA" || s=="AKIHABR" ||
		s=="AKIHBARA"||s=="AKIHBAR" || s=="AKIHBRA" || s=="AKIHBR" ||
		s=="KIHABARA"||s=="KIHABAR" || s=="KIHABRA" || s=="KIHABR" ||
		s=="KIHBARA"||s=="KIHBAR" || s=="KIHBRA" || s=="KIHBR" ){
		cout << "YES" << endl;
	}else{
		cout << "NO" << endl;
	}
	return 0;
}

Measured memory_bytes: 764
#include<bits/stdc++.h>
using namespace std;
int main(){
  int h,w;
  char mp[1009][1009];
  cin>>h>>w;
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cin>>mp[i][j];
    }
  }
  for(int i=0;i<h*2;i++){
    for(int j=0;j<w;j++){
      cout<<mp[i/2][j];
    }
    cout<<endl;
  }
  return(0);
}


Measured memory_bytes: 384
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF (1<<30)
#define LINF (1LL<<60)
#define endl "\n"
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
typedef unsigned long long int ull;
typedef long long lint;

int digitsum(int N){
  if(N<=0) return 0;
  int digit=1+floor(log10(N)),res=0;
  for(int i=digit-1;i>=0;i--){
    int mono=N/pow(10,i);
    res+=mono;
    N-=mono*pow(10,i);
  }
  return res;
}

int main(void){
    int N;
    cin >> N;
    if(N%digitsum(N)==0) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
N = int(input())
L = []
for _ in range(N):
    l = list(map(int,input().split()))
    L.append(l)
from itertools import permutations
# permutations('ABCD', 2) --> AB AC AD BA BC BD CA CB CD DA DB DC
# permutations(range(3)) --> 012 021 102 120 201 210
permu_list = list(permutations(L,N))
ans = 0
for x in permu_list:
    for i in range(len(L)-1):
        l1 = x[i]
        l2 = x[i+1]
        length = ((l1[0] - l2[0])**2 + (l2[1] - l1[1]) ** 2)**(1/2)
        ans += length
print(ans/len(permu_list))


Measured memory_bytes: 8052
#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 INF 1e9
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << #x << ": " << x << endl;

using namespace std;
typedef long long ll;

signed main() {
  int a, b, h;
  cin >> a >> b >> h;
  cout << (a + b) * h / 2 << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <numeric>
#include <map>
#include <vector>
#include <string>
#include <vector>
#include <cassert>
#include <cmath>
#include <stack>
#include <cctype>
#include <queue>
#include <algorithm>
#include <memory>
#include <memory.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int INF = 1 << 30;
const double EPS = 1e-10;
const double PI = 3.14159;

int h[101];
int t[101];

int main(){
	int n, m;
	while(cin >> n >> m && (n || m)){
		int sumh = 0, sumt = 0;
		for(int i = 0; i < n; i++){
			cin >> h[i];
			sumh += h[i];
		}
		for(int i = 0; i < m; i++){
			cin >> t[i];
			sumt += t[i];
		}
		int res = INF;
		int resh = 0;
		int rest = 0;
		for(int i = 0; i < n; i++){
			for(int j = 0; j < m; j++){
				if(sumh - h[i] + t[j] == sumt - t[j] + h[i]){
					if(h[i] + t[j] < res){
						res = t[j] + h[i];
						resh = h[i];
						rest = t[j];
					}
				}
			}
		}
		if(res == INF) cout << -1 << endl;
		else cout << resh << " " << rest << endl;
	}
	return 0;
}

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

vector<int> sieve(int n) {
	vector<int> res(1, 2);
	vector<bool> prime(n, true);
	for(int i = 3; i < n; i += 2) {
		if(prime[i]) {
			res.push_back(i);
			for(int j = i * 3; j < n; j += i * 2)
				prime[j] = false;
		}
	}

	return res;
}

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

	const int MAX = 1000000;
	vector<int> primes = sieve(MAX);
	for(int a, d, n; cin >> a >> d >> n, a | d | n;) {
		int cnt = 0;
		const int start = lower_bound(primes.begin(), primes.end(), a) - primes.begin();
		for(int i = start; i < (int)primes.size(); ++i) {
			if((primes[i] - a) % d == 0 && ++cnt == n) {
				cout << primes[i] << endl;
				break;
			}
		}
	}

	return EXIT_SUCCESS;
}

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

using namespace std;

int main(){
    int n,m;
    cin>>n>>m;
    vector<int> imo(n+2,0);
    for (int i = 0; i < m; ++i) {
        int l,r;
        cin>>l>>r;
        ++imo[l];--imo[r+1];
    }
    int ans=0;
    for (int i = 1; i <= n; ++i) {
        imo[i]+=imo[i-1];
        if(imo[i]==m)++ans;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 640
N = int(input())
S = [1 if s == 'o' else -1 for s in input()]

for first in [1, -1]:
    for second in [1, -1]:
        ans = [first, second]
        prev = first
        now = second
        for s in S[1:] + [S[0]]:
            if s == 1:
                if now == 1:
                    prev, now = now, prev
                else:
                    prev, now = now, -prev
            else:
                if now == 1:
                    prev, now = now, -prev
                else:
                    prev, now = now, prev
            ans.append(now)
        if first == ans[-2] and second == ans[-1]:
            print(*['S' if a == 1 else 'W' for a in ans[:-2]], sep='')
            exit()

print(-1)

Measured memory_bytes: 8356
import java.util.Scanner;
public class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);


        int n=scan.nextInt();
        int m=scan.nextInt();
        boolean []jdg=new boolean[n];
        int []ball=new int [n];
        int ans=0;
        for(int i=0;i<n;i++){
            jdg[i]=false;
            ball[i]=1;
        }
        jdg[0]=true;

        int x,y;
        for(int i=0;i<m;i++){
            x=scan.nextInt()-1;
            y=scan.nextInt()-1;
            ball[x]--;
            ball[y]++;
            if(jdg[x])
                jdg[y]=true;
            if(ball[x]==0)
                jdg[x]=false;
        }
        for(int i=0;i<n;i++){
            if(jdg[i]) {
                ans++;

            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 23872
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef long  l;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
const double PI=3.141592653589;
const int INF=1000000007;
const ll LMAX=1000000000000001;
const ll mod=1000000007;
ll gcd(ll a,ll b){if(a<b)swap(a,b);while((a%b)!=0){a=b;b=a%b;}return b;}
int dx[]={-1,0,1,0};
int dy[]={0,1,0,-1};

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

  ll ans=0;
  for(int bit=0;bit<(1<<s.size()-1);bit++){
    ll now=s[0]-'0';
    for(int i=1;i<s.size();i++){
      if((bit&(1<<i-1))!=0){
        ans+=now;
        now=s[i]-'0';
      }else{
        now*=10;now+=s[i]-'0';
      }
    }
    ans+=now;
  }
  cout<<ans<<endl;

  return 0;
}


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


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

    if(a != b && b != c && c != a) cout<<3<<endl;
    else if(a == b && b == c) cout<<1<<endl;
    else cout<<2<<endl;

    return 0;
}



Measured memory_bytes: 256
/*
confirm 0LL and 1LL
confirm cornercases such as 0
confirm times of cin < 10^6
*/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
using Graph = vector<VecP>;
template <typename T>
using Vec1 = vector<T>;
template <typename T>
using Vec2 = vector<Vec1<T> >;
#define REP(i, m, n) for(ll (i) = (m); (i) < (n); ++(i))
#define REPN(i, m, n) for(ll (i) = (m); (i) <= (n); ++(i))
#define REPR(i, m, n) for(ll (i) = (m)-1; (i) >= (n); --(i))
#define REPNR(i, m, n) for(ll (i) = (m); (i) >= (n); --(i))
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPNR(i, n, 1)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
template <typename T>
bool chmax(T &a, const T b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T b){if(a > b){a = b; return true;} return false;}
template <typename T>
ll pow2(const T n){return (1LL << n);}
template <typename T>
void cosp(const T n){cout << n << ' ';}
template <typename T>
void co(const T n){cout << n << '\n';}
template <typename T1, typename T2>
void co(pair<T1, T2> p){cout << p.fs << ' ' << p.sc << '\n';}
template <typename T>
void co(const Vec1<T> &v){for(T i : v) cosp(i); cout << '\n';}
template <typename T>
void co(initializer_list<T> v){for(T i : v) cosp(i); cout << '\n';}
template <typename T>
void ce(const T n){cerr << n << endl;}
void sonic(){ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);}
void setp(const ll n){cout << fixed << setprecision(n);}
const ll INF = 1e9+1;
const ll LINF = 1e18+1;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ld PI = acos(-1);
const ld EPS = 1e-11;

int main(void){
	ll n, m;
	cin >> n >> m;
	VecP r(m);
	rep(i, m) cin >> r[i].fs >> r[i].sc;

	sort(all(r));

	ll ans = 0, pos = -1;
	rep(i, m){
		if(r[i].fs >= pos){
			ans++;
			pos = r[i].sc;
		}else chmin(pos, r[i].sc);
	}
	co(ans);

	return 0;
}


Measured memory_bytes: 1792
#include<stdio.h>
#include<stdlib.h>
#include<stdint.h>
#include<inttypes.h>

typedef int32_t i32;

typedef struct RMQandRUQNode {
  i32 val;
  i32 min;
} node;

typedef struct RMQandRUQ {
  node *a;
  i32 size;
  i32 bit;
  i32 empty;
} RMQandRUQ;

RMQandRUQ* new_RMQandRUQ (const i32 n) {
  i32 k = 0;
  while ((1 << k) < n) k++;
  RMQandRUQ *s = (RMQandRUQ *) calloc (1, sizeof (RMQandRUQ));
  s->a = (node *) calloc (2 << k, sizeof (node));
  s->size = 1 << k;
  s->bit = k;
  s->empty = -1;
  s->a[1].val = 2147483647;
  return s;
}

static inline i32 min (const i32 a, const i32 b) {
  return a < b ? a : b;
}

void propagate (RMQandRUQ *s, i32 x) {
  x += s->size;
  for (i32 i = s->bit; i > 0; --i) {
    i32 k = x >> i;
    if (s->a[k].val == s->empty) continue;
    s->a[2 * k].val = s->a[2 * k + 1].val = s->a[k].val;
    s->a[k].min = s->a[k].val;
    s->a[k].val = s->empty;
  }
}

static inline i32 get_min (RMQandRUQ *s, const i32 k) {
  return s->a[k].val != s->empty ? s->a[k].val : s->a[k].min;
}

static inline void calc_min (RMQandRUQ *s, const i32 k) {
  i32 a = get_min (s, 2 * k);
  i32 b = get_min (s, 2 * k + 1);
  s->a[k].min = min (a, b);
}

void update (RMQandRUQ *s, const i32 l, const i32 r, const i32 v) {
  propagate (s, l);
  propagate (s, r - 1);
  for (i32 x = l + s->size, y = r + s->size; x < y; x >>= 1, y >>= 1) {
    if (x & 1) s->a[x++].val = v;
    if (y & 1) s->a[--y].val = v;
  }
  for (i32 x = (l + s->size) >> 1, y = (r - 1 + s->size) >> 1; x >= 1; x >>= 1, y >>= 1) {
    calc_min (s, x);
    calc_min (s, y);
  }
}

i32 find (RMQandRUQ *s, i32 l, i32 r) {
  propagate (s, l);
  propagate (s, r - 1);
  i32 res = 2147483647;
  for (l += s->size, r += s->size; l < r; l >>= 1, r >>= 1) {
    if (l & 1) res = min (res, get_min (s, l++));
    if (r & 1) res = min (res, get_min (s, --r));
  }
  return res;
}

void run (void) {
  i32 n, q;
  scanf ("%" SCNi32 "%" SCNi32, &n, &q);
  RMQandRUQ *s = new_RMQandRUQ (n);
  while (q--) {
    i32 t, l, r;
    scanf ("%" SCNi32 "%" SCNi32 "%" SCNi32, &t, &l, &r);
    r++;
    if (t == 0) {
      i32 v;
      scanf ("%" SCNi32, &v);
      update (s, l, r, v);
    } else {
      printf ("%" PRIi32 "\n", find (s, l, r));
    }
  }
}

int main (void) {
  run ();
  return 0;
}



Measured memory_bytes: 3316
n = gets.to_i
a = gets.split.map(&:to_i)
count = 0
a.select{|x|x.even?}.each do |i|
  j = 1
  while i >= 2**j && (i / 2**j).even?
    count += 1
    j += 1
  end
  count += 1
end
puts count

Measured memory_bytes: 2428
n=int(input())
l=list(map(int,input().split()))
count=0
for i in range(n):
  for j in range(i+1,n):
    if l[i]!=l[j]:
      s=l[i]+l[j]
      for k in range(j+1,n):
        if l[i]!=l[k] and l[j]!=l[k]:
          if l[k]<s and (l[i]+l[k])>l[j] and (l[j]+l[k])>l[i]:
            count+=1
         
print(count)

Measured memory_bytes: 9208
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque, OrderedDict
from copy import deepcopy
from fractions import gcd
from functools import lru_cache, reduce
from math import ceil, floor
from sys import setrecursionlimit

import heapq
import itertools
import operator


inf = float('inf')


# globals
N = 0
A = []


def set_inputs():
    global N, A
    N = get_int()
    A = get_li()
    return


def main():
    setrecursionlimit(100000)
    set_inputs()
    # ----------MAIN----------
    B = [0] + A + [0]
    total = sum(abs(x - y) for x, y in zip(B, B[1:]))
    distances = [abs(x - y) + abs(y - z) for x, y, z in zip(B, B[1:], B[2:])]
    skip_distances = [abs(x - y) for x, y in zip(B, B[2:])]
    for i in range(N):
        print(total - distances[i] + skip_distances[i])
    return


def get_int():
    return int(input())


def get_float():
    return float(input())


def get_str():
    return input().strip()


def get_li():
    return [int(i) for i in input().split()]


def get_lf():
    return [float(f) for f in input().split()]


def get_lc():
    return list(input().strip())


def get_data(n, types):
    if len(types) == 1:
        return [types[0](input()) for _ in range(n)]
    return zip(*(
        [t(x) for t, x in zip(types, input().split())]
        for _ in range(n)
    ))


if __name__ == '__main__':
    main()


Measured memory_bytes: 20072
s = input()
f = 1
if len(s) % 2:
    f = 0
else:
    for h in s[::2]:
        if h != 'h':
            f = 0

    for i in s[1::2]:
        if i != 'i':
            f = 0

if f:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 2940
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<algorithm>
#include<map>
#include<cstdlib>
#include<cmath>
#include<numeric>
#include<iomanip>
#include<functional>
#include<cstdlib>
#include<queue>
#include<deque>
const double PI = acos(-1);
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
using ll =long long;
const int mod = 1000000007;

//map<string>a
class mint {
	long long x;
public:
	mint(long long x = 0) : x((x% mod + mod) % mod) {}
	mint operator-() const {
		return mint(-x);
	}
	mint& operator+=(const mint & a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint & operator-=(const mint & a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint & operator*=(const  mint & a) {
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint & a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint & a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint & a) const {
		mint res(*this);
		return res *= a;
	}
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}
	// for prime mod
	mint inv() const {
		return pow(mod - 2);
	}
	mint& operator/=(const mint & a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint & a) const {
		mint res(*this);
		return res /= a;
	}

	friend ostream& operator<<(ostream & os, const mint & m) {
		os << m.x;
		return os;
	}
};
int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}
//組み合わせ
void recursive_comb(vector<int> indexes, int s, int rest, std::function<void(vector<int>)> f) {
	if (rest == 0) {
		f(indexes);
	}
	else {
		if (s < 0) return;
		recursive_comb(indexes, s - 1, rest, f);
		indexes[rest - 1] = s;
		recursive_comb(indexes, s - 1, rest - 1, f);
	}
}

// nCkの組み合わせに対して処理を実行する
void foreach_comb(int n, int k, std::function<void(vector<int>)> f) {
	vector<int>indexes(k);
	recursive_comb(indexes, n - 1, k, f);
}

ll gcd(ll a, ll b) {
	if (a % b == 0) {
		return b;
	}
	else {
		return gcd(b, a % b);
	}
}
ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
};


int main() {
	int N, K;
	cin >> N >> K;
	vector<int>p(N);
	rep(i, N)cin >> p[i];
	sort(p.begin(), p.end());
		ll ans=0;
		rep(i, K) {
			ans += p[i];
	}
		cout << ans;
}


Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
const int dy[] = {-1, -1, -1, 0, 1, 1, 1, 0};
const int dx[] = {-1, 0, 1, 1, 1, 0, -1, -1};

int W, H;
string S[10];
map< string, int > sss;

void dfs(string T, int y, int x, const int sy, const int sx, const int dir)
{
  if(!T.empty() && y == sy && x == sx) return;
  sss[T + S[y][x]]++;
  dfs(T + S[y][x], (y + dy[dir] + H) % H, (x + dx[dir] + W) % W, sy, sx, dir);
}

bool compare(const string& x, const string& y)
{
  if(x.size() != y.size()) return(x.size() > y.size());
  return(x < y);
}

int main()
{
  while(cin >> H >> W, H) {
    for(int i = 0; i < H; i++) {
      cin >> S[i];
    }
    for(int i = 0; i < H; i++) {
      for(int j = 0; j < W; j++) {
        for(int k = 0; k < 8; k++) dfs("", i, j, i, j, k);
      }
    }
    string S = "";
    for(auto it : sss) {
      if(it.second >= 2) S = min(S, it.first, compare);
    }
    if(S.size() == 1) cout << 0 << endl;
    else cout << S << endl;
    sss.clear();
  }
}

Measured memory_bytes: 39184
using System;
using System.Collections.Generic;
using System.Linq;

public class Hello
{
    private const int MOD_N = 1000000000 + 7;

    public static void Main()
    {
        var s = long.Parse(Console.ReadLine());

        var answer = new long[6];

        const long Max = 1000000000; 
        answer[2] = Max;
        answer[3] = 1;

        answer[5] = Math.DivRem(s, Max, out answer[4]);
        if (answer[4] > 0)
        {
            ++answer[5];
            answer[4] = Max - answer[4];
        }

        Console.WriteLine(string.Join(" ", answer));
    }

    private static int GCD(int a, int b) => a > b ? GCD_impl(a, b) : GCD_impl(b, a);
    private static int GCD_impl(int a, int b) => b == 0 ? a : GCD_impl(b, a % b);
    private static long LCM(int a, int b) => (long)a * b / GCD(a, b);

    private static int Comb(int m, int n)
    {
        var t = m - n;
        if (n > t)
            n = t;

        long numerator = 1;
        for (int i = 0; i < n; ++i)
        {
            numerator *= m - i;
            numerator %= MOD_N;
        }
        long denominator = 1;
        for (; n != 0; --n)
        {
            denominator *= n;
            denominator %= MOD_N;
        }

        var inv_denominator = ModInv((int)denominator, MOD_N);
        var ret = (int)(numerator * inv_denominator % MOD_N);

        return ret >= 0 ? ret : ret + MOD_N;
    }

    private static int ModInv(int a, int m)
    {
        int b = m, x = 1, y = 0;
        while (b != 0)
        {
            var t = a / b;
            a -= t * b;
            Swap(ref a, ref b);
            x -= t * y;
            Swap(ref x, ref y);
        }
        x %= m;
        return x >= 0 ? x : x + m;
    }

    private static void Swap<T>(ref T a, ref T b)
    {
        var t = a;
        a = b;
        b = t;
    }
}


Measured memory_bytes: 13396
#include <cstdio>
#include <queue>
#include <iostream>
#include <algorithm>
#include<cstring>
using namespace std;
int dp[1<<12];
int main()
{
    int n,m;
    cin >>n >>m;
    memset(dp,0x3f3f3f3f,sizeof(dp));
    dp[0] = 0;
    for(int i=1;i<=m;i++)
    {
        int a,b;
        cin >>a >> b;
        int u=0;
        for(int i=1;i<=b;i++)
        {
            int c;
            cin >> c;
            u = u|(1<<(c-1));
        }
        for(int i=0;i<(1<<12);i++)
        {
            if(dp[i]!=0x3f3f3f3f)
            {
                dp[i|u] = min(dp[i|u],dp[i]+a);
            }
        }
    }
    int sum=1;
    for(int i=1;i<n;i++)
    {
        sum = sum|(1<<i);
    }
    if(dp[sum]==0x3f3f3f3f)
    {
        cout << -1;
    }
    else
    {
        cout << dp[sum];
    }
    return 0;
}

Measured memory_bytes: 3660