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

#define isz(x) (int)(x).size()

template<class X, class Y> X& remin(X& x, Y y) { return x = (y < x ? y : x); }

const int INF = (int)1e9+7;

using vi = std::vector<int>;
using vvi = std::vector<vi>;

int fast(std::string s) {
    assert(isz(s) >= 1);
    if (s[0] != '0') {
        return fast("0" + s);
    }
    vvi dp(2, vi(isz(s), INF));
    dp[0][0] = 0;
    dp[1][0] = 1;
    for (int i = 1; i < isz(s); i++) {
        // dp[0][i] - либо платим ровно столько, либо платим на 1 больше
        for (int d = 0; d <= 1 - (i == isz(s)-1); d++) {
            dp[d][i] = std::min(dp[0][i-1] + (s[i] - '0' + d), dp[1][i-1] + 10 - (s[i] - '0' + d));
        }
    }
    return std::min(dp[0][isz(s)-1], dp[1][isz(s)-1]);
}

int fast(int n) {
    return fast(std::to_string(n));
}
int cost(int n) {
    int r(0);
    do {
        r += n % 10;
        n /= 10;
    } while (n > 0);
    return r;
}
int naive(int n, bool flag = false) {
    int answ = cost(n);
    int best = n;
    for (int s = n; s <= 20 * n; s++) {
        int curr = cost(s) + cost(s - n);
        if (curr < answ) {
            best = s;
            answ = curr;
        }
    }
    if (flag) {
        std::cout << "naive for n = " << n << ", best = " << best << std::endl;
    }
    return answ;
}
void test() {
    for (int n = 1; n <= 10000; n++) {
        if (naive(n) != fast(n)) {
            std::cout << "---------------------------------" << std::endl;
            int nv = naive(n,1);
            int ft = fast(n);
            std::cout << "    n = " << n << std::endl;
            std::cout << "naive = " << nv << std::endl;
            std::cout << " fast = " << ft << std::endl;
            //std::exit(0);
        }
    }
    std::exit(0);
}
int main() {
    //test();
    std::string s; std::cin >> s;
    const int n = isz(s);
    assert(isz(s) >= 1);
    if (s[0] != '0') s = "0" + s;
    vvi dp(2, vi(n+1, INF));
    dp[0][0] = 0;
    dp[1][0] = 1;
    for (int i = 1; i <= n; i++) {
        for (int d = 0; d <= 1; d++) {
            dp[d][i] = std::min(dp[0][i-1] + (s[i] - '0' + d), dp[1][i-1] + 10 - (s[i] - '0' + d));
        }
    }
    std::cout << dp[0][n] << std::endl;
    return 0;
}

Measured memory_bytes: 13104
#include <bits/stdc++.h>
using namespace std;
#define x first
#define y second
#define ll long long
#define pi pair<int,int>
#define pl pair<ll,ll>
#define pd pair<double,double>
#define ld long double
#define pld pair<ld,ld>
#define lg length()
#define sz size()
#define pb push_back
#define INF 1000000005
#define LINF 1000000000000000005

double dp[305][305][305];

int n,a,b,c,x;

int32_t main(){
    ios_base :: sync_with_stdio(0); cin.tie(); cout.tie();
    cin >> n; cout << fixed << setprecision(10);
    for(int i=1;i<=n;i++){
        cin >> x;
        if(x==1) a++;
        else if(x==2) b++;
        else c++;
    }
    for(int k=0;k<=c;k++){
        for(int j=0;j<=b+c;j++){
            for(int i=0;i<=a+b+c;i++){
                if(!i && !j && !k) continue;
                dp[i][j][k]=(double)n/(i+j+k);
                if(i) dp[i][j][k]+=(double)i/(i+j+k)*dp[i-1][j][k];
                if(j) dp[i][j][k]+=(double)j/(i+j+k)*dp[i+1][j-1][k];
                if(k) dp[i][j][k]+=(double)k/(i+j+k)*dp[i][j+1][k-1];
            }
        }
    }
    cout << dp[a][b][c];
}


Measured memory_bytes: 219392
n, tl = [int(x) for x in input().split()]

c_init = 10 ** 4
ans = c_init
for _ in range(n):
    c, t = [int(x) for x in input().split()]
    if (t <= tl) and (c < ans):
        ans = c
if ans == c_init:
    ans = "TLE"
print(ans)

Measured memory_bytes: 3060
# import sys
# input = sys.stdin.readline

def mp(): return map(int, input().split())
def lmp(): return list(map(int, input().split()))

n,k = mp()
a = lmp()
for i in range(n-k):
    l = a[i]
    r = a[i+k]
    if r > l:
        print("Yes")
    else:
        print("No")




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

int main(){
  vector<int> n(4);
  for (int i=0; i<4; i++) cin>>n[i];
  sort(n.begin(),n.end());
  if (n[0]==1 and n[1]==4 and n[2]==7 and n[3]==9) cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
}

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

#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define test cout<<"test"<<endl;
#define fi first
#define se second
#define rep(i,n,m) for(ll i = n; i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = n - 1; i >= (ll)(m); i--)
typedef long long ll;
typedef long double ld;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T>
void chmin(T &a,T b){if(a>b)a=b;}
template<typename T>
void chmax(T &a,T b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void pmod(ll &a,ll b,ll c){a=(b+c)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void qmod(ll &a,ll b,ll c){a=(b*c)%MOD;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>
void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
void debug(vector<vector<ll>>v,ll h,ll w){for(ll i=0;i<h;i++)
{cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
void debug(vector<ll>v,ll n){cout<<v[0];
for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
vector<vector<ll>>vec(ll x, ll y, ll w){
  vector<vector<ll>>v(x,vector<ll>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while((r=x%y)!=0){x=y;y=r;}return y;}
//m.emplace(x,0).fi->se++;

int main(){
  cin.tie(NULL);
  ios_base::sync_with_stdio(false);
  ll res=0,res1=INF,res2=-INF,buf=0;
  bool judge = true;
  ll n;cin>>n;
  vector<string>s(n);
  rep(i,0,n)cin>>s[i];
  map<string,ll>m;
  rep(i,0,n){
    sort(ALL(s[i]));
    m.emplace(s[i],0).fi->se++;
  }
  for(auto z:m){
    res+=(z.se*(z.se-1))/2;
  }
  cout<<res<<endl;
  return 0;
}

Measured memory_bytes: 16640
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define FOR(i,a,b) for(int i=(a); i<=(b); i++) 
#define rep(i,n); for(int i = 0; i < (n); i++)
#define chmin(a,b) if((a)>(b)) (a)=(b); 
#define chmax(a,b) if((a)<(b)) (a)=(b);
#define vi vector<int>
int gcd(int a,int b){/*a>=0,b>=0,￢(a=b=0)*/
  while(min(a,b)>0){if(a<b)swap(a,b);a%=b;}return max(a,b);
}
int dx[]={0,1,0,-1,1,-1,-1,1};
int dy[]={1,0,-1,0,1,1,-1,-1};
const int MOD = 1e9+7;
const int INF = 1e10+10;

/*----------------------------------------------*/

signed main(){
  int n;
  cin>>n;
  vi a(n);
  rep(i,n) cin>>a[i];
  rep(i,n){
    int v=a[i];
    int j=i-1;
    while(j>=0&&a[j]>v){
      a[j+1]=a[j];
      j--;
    }
    a[j+1]=v;
    rep(k,n-1) cout<<a[k]<<" ";
    cout<<a[n-1]<<endl;
  }
  return 0;
}


Measured memory_bytes: 3092
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#define watch(x) cout << (#x) << " is " << (x) << endl

typedef long long ll;
typedef long double ld;
using namespace std;

int mana = INT_MAX;
int a, b, c;

void brute_force(vector<int> &l, int A, int B, int C, int used, int i)
{
  if(i == l.size())
  {
    if(A == 0 || B == 0 || C == 0)
    {
      return;
    }
    mana = min(mana, used + abs(a - A) + abs(b - B) + abs(c - C));
    return;
  }
  else
  {
    brute_force(l, A, B, C, used, i + 1);
    brute_force(l, A + l[i], B, C, used + ((A == 0) ? 0 : 10), i + 1);
    brute_force(l, A, B + l[i], C, used + ((B == 0) ? 0 : 10), i + 1);
    brute_force(l, A, B, C + l[i], used + ((C == 0) ? 0 : 10), i + 1);
  }
}

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n >> a >> b >> c;
  vector<int> l(n);
  for(int i = 0; i < n; i++)
  {
    cin >> l[i];
  }
  brute_force(l, 0, 0, 0, 0, 0);
  cout << mana;

  return 0;
}



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

#define mp make_pair
#define eb emplace_back
#define ff first
#define ss second

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#ifdef ONPC
mt19937 rnd(228);
#else
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#endif


const int MAXN = 100;
//#define int long long
const int INF = 1e9;

int dp[(int)1e5 + 54][30];

void solve(){
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  int l, Q;
  cin >> l >> Q;
  int x, y;

  for (int i = 0; i < 30; i++) dp[0][i] = -1;
  deque<int> q;
  q.eb(0);
  for (int i = 1; i < n; i++){
    while (a[q.front()] + l < a[i]) q.pop_front();
    //cerr << "DP " << i << " : ";
    dp[i][0] = q.front();
    //cerr << dp[i][0] << ' ';
    for (int j = 1; j < 30; j++){
      if (dp[i][j - 1] == -1) {
        dp[i][j] = -1;
        continue;
      }
      dp[i][j] = dp[dp[i][j-1]][j-1];
      //cerr << dp[i][j] << ' ';
    }
    //cerr << '\n';
    q.eb(i);
  }

  for (int i = 0; i < Q; i++){
    cin >> x >> y;
    x--, y--;

    if (x > y) swap(x, y);

    int ans = 0;
    int cur = y;
    while (cur > x){
    //cerr << cur << '\n';
      int f = 0;
      for (int j = 29; j > 0; j--){
        if (dp[cur][j] >= x){
          cur = dp[cur][j];
          ans += (1 << j);
          f = 1;
          break;
        }
      }
      if (f) continue;
      cur = dp[cur][0];
      ans++;
    }

    cout << ans << '\n';
  }
}

signed main()
{
    #ifdef FILEIO
      freopen("input.txt", "r", stdin);
      freopen("output.txt", "w", stdout);
    #endif

    ios_base::sync_with_stdio(0);
    cin.tie(0);

    solve();

    return 0;
}


Measured memory_bytes: 15872
# coding: utf-8
# Your code here!

i_list = list(input())
o_list = []

for i in range(len(i_list)):
    if i_list[i] == "0":
        o_list.append("0")
    elif i_list[i] == "1":
        o_list.append("1")
    elif len(o_list) >= 1:
        del o_list[-1]

for j in range(len(o_list)):
    print(o_list[j], end = "")


Measured memory_bytes: 3060
import java.util.*;
import java.lang.*;

/**
 * BinarySearch
 */
public class Main {

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

        int[] s = new int[n];

        for (int i = 0; i < n; i++) {
            s[i] = Integer.parseInt(sc.next());
        }

        int q = Integer.parseInt(sc.next());
        int ans = 0;

        for (int i = 0; i < q; i++) {
            int t = Integer.parseInt(sc.next());
            // ここで二分探索
            if (Arrays.binarySearch(s, t) >= 0) {
                ans++;
            }
        }

        System.out.println(ans);

        sc.close();
    }
}


Measured memory_bytes: 71100
x,y,z,k = gets.split(" ").map(&:to_i)

a = gets.split(" ").map(&:to_i).sort.reverse
b = gets.split(" ").map(&:to_i).sort.reverse
c = gets.split(" ").map(&:to_i).sort.reverse

ary = []
x.times do |i|
  y.times do |j|
    break if (i + 1) * (j + 1) > k
    z.times do |t|
      break if (i + 1) * (j + 1) * (t + 1) > k
      ary << a[i] + b[j] + c[t]
    end
  end
end

ary.sort!.reverse!
k.times{|i| puts ary[i] }


Measured memory_bytes: 3832
import java.util.*;
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();

        int odd = (a==b)? c :((a==c)? b: a);

        System.out.println(odd);
    }
}

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

using namespace std;
using ll = long long;
using ld = long double;

ll MOD = 1000000007;
const int SINF = 1000000009;
const ll INF =  1000000000000000018;

#define nl          "\n"
#define inv(a)      powr((a), (MOD - 2))
#define all(c)      (c).begin(),(c).end()
#define rep(i,a,b)  for(ll i = (a); i < (b); i ++)
#define prec(n)     cout << fixed << setprecision(n)
#define PI          3.14159265358979323846264338327951
#define ifalse      ios_base::sync_with_stdio(false), cin.tie(NULL)

template<typename T> void toInt(string s, T &a) { istringstream(s) >> a; }
ll gcd(ll a, ll b) { ll t; while(a) { t = a; a = b%a; b = t; } return b; }
ll sub(ll a, ll b) { a -= b; a = (a + MOD) % MOD; return a; }
ll mul(ll a, ll b) { return ((a % MOD) * (b % MOD)) % MOD; }
ll add(ll a, ll b) { a += b; a %= MOD; return a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a, b); }

ll powr(ll a, ll b) {
		ll x = 1LL;
		while(b) {
				if(b & 1) x = mul(x, a);
				a = mul(a, a), b >>= 1;
		}
		return x%MOD;
}

bool check(ll n)
{
		if(n == 1) return 0;
		if(n == 2 or n == 3) return 1;
		if(n%2 == 0 or n%3 == 0) return 0;
		for(ll i = 5; i*i <= n; i += 6) if(n%i == 0 or n % (i+2) == 0) return 0;
		return 1;
}

int main(){
	ifalse;
	int n, m;
	cin >> n >> m;
	vector<vector<ll>> ans(n, vector<ll>(m));
	char t;
	for(auto&row: ans){
		for(auto&x: row){
			cin >> t;
			if(t == '.')
				x = 1;
			else x = -1;
		}
	}
	auto valid = [&](const int&i, const int&j){
		return i >= 0 && i < n && j >=0 && j < m;
	};
	for(int i = 0;i < n; ++i){
		for(int j = 0;j < m; ++j){
			if(ans[i][j] == -1 || (i == 0 && j == 0)) continue;
			ll temp = 0;
			if(valid(i - 1, j) && ans[i - 1][j] != -1){
				temp += ans[i - 1][j];
			}
			if(valid(i, j - 1) && ans[i][j - 1] != -1){
				temp = add(temp, ans[i][j - 1]);
			}
			ans[i][j] = temp;
		}
	}
	cout << ans[n - 1][m - 1] << endl;
	return 0;
}


Measured memory_bytes: 8064
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        // B - Palindrome-philia

        Scanner sc = new Scanner(System.in);

        String s = sc.next();
        
        char[] cs = s.toCharArray();
        
        int count = 0;
        for (int i = 0; i < cs.length / 2; i++) {
            if (cs[i] != cs[cs.length - i -1]) {
                ++count;
            }
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 23764
#include <iostream>
#include <map>

using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)

template<int MOD> struct MInt {
  long long val;
  MInt(long long val = 0) : val(val % MOD) { if (val < 0) val += MOD; }
  MInt operator+(const MInt& n) const { return MInt(val) += n; }
  MInt operator*(const MInt& n) const { return MInt(val) *= n; }
  MInt& operator+=(const MInt& n) { val = (val + n.val) % MOD; return *this; }
  MInt& operator*=(const MInt& n) { val = (val * n.val) % MOD; return *this; }
  bool operator==(const MInt& n) { return val == n.val; }
  bool operator!=(const MInt& n) { return val != n.val; }
  friend ostream& operator<<(ostream& os, const MInt& n) { os<<n.val; return os; }
};
const int MOD = 1e9+7;
using mint = MInt<MOD>;

int main() {
  string S; cin >> S;
  int N = S.size();

  map<string, mint> count;
  mint pow = 1;
  rep(i, N) {
    if (S[i] == 'C') { count["ABC"] += count["AB"]; }
    if (S[i] == 'B') { count["AB"] += count["A"]; }
    if (S[i] == 'A') { count["A"] += pow; }
    if (S[i] == '?') {
      count["ABC"] = count["ABC"] * 3 + count["AB"];
      count["AB"] = count["AB"] * 3 + count["A"];
      count["A"] = count["A"] * 3 + pow;
      pow *= 3;
    }
  }
  cout << count["ABC"] << endl;

  return 0;
}


Measured memory_bytes: 512
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		// TODO Auto-generated method stub

		Scanner scn = new Scanner(System.in);
		int N = scn.nextInt();
		int sum = 0;
		for (int i = 1; i <= N; i++) {
			for (int j = 1; j <= N; j++) {
				for (int k = 1; k <= N; k++) {
					int c = HCF(i, j);
					int d = HCF(c, k);
					sum = sum + d;
				}
			}
		}
		System.out.println(sum);

	}

	public static int HCF(int a, int b) {
		int temp = -1;
		int x = Math.max(a, b);
		int y = Math.min(a, b);
		while (x > 0) {
			temp = x;
			x = y % x;
			y = temp;
		}
		return y;
	}

}


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

int main() {
  bool flag=true;
  string s;
  cin >> s;
  int n=s.length();
  char c[(n+2)/4];
  r(i,(n+2)/4)c[i]=s[i];
  
  r(i,(n+2)/4){
    if(s[i]!=c[i]||s[(n-3)/2-i]!=c[i]||s[(n+1)/2+i]!=c[i]||s[n-1-i]!=c[i])flag=false;
  }
 if(flag)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int N=110000,mod=1000000007;
int n,ans;
int jc[N],njc[N],bir[N],nbir[N];
int a[N],fa[N],du[N],num[N],vis[N],tail[N],rem[N];
int f[N][2][2];
vector<int>vec[N],v1;
int qpow(int x,int y)
{
	int ret=1;
	while(y)
	{
		if(y&1)ret=(ll)ret*x%mod;
		x=(ll)x*x%mod;y>>=1;
	}
	return ret;
}
void init()
{
	for(int i=1;i<=n;i++)fa[i]=i;
	jc[0]=njc[0]=bir[0]=nbir[0]=1;
	for(int i=1;i<=n;i++)
	{
		jc[i]=(ll)jc[i-1]*i%mod;
		bir[i]=bir[i-1]*2%mod;
	}
	njc[n]=qpow(jc[n],mod-2);
	nbir[n]=qpow(bir[n],mod-2);
	
	for(int i=n-1;i>=1;i--)
	{
		njc[i]=(ll)njc[i+1]*(i+1)%mod;
		nbir[i]=nbir[i+1]*2%mod;
	}
}
int find(int x){return fa[x]==x ? x : fa[x]=find(fa[x]);}
void quit(){puts("0");exit(0);}
void ins(int x)
{
	if(!tail[x])return;
	if(rem[x]<tail[x])quit();
	else if(rem[x]>tail[x])ans=ans*2%mod;
}
int main()
{
	//freopen("tt.in","r",stdin);
	scanf("%d",&n);
	init();
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		if(find(i)!=find(a[i]))
			fa[find(i)]=find(a[i]);
		du[a[i]]++;
	}
	for(int i=1;i<=n;i++)
	{
		if(du[i]>2)quit();
		vec[find(i)].push_back(i);
	}
	ans=1;
	for(int i=1,sz;i<=n;i++)if(sz=vec[i].size())
	{
		int p=-1;
		for(int j=0;j<sz;j++)
			if(du[vec[i][j]]==2)p=vec[i][j];
		if(p==-1)num[sz]++;
		else
		{
			int t=0,p1=a[p];
			vis[p]=++t;
			while(p1!=p)
			{
				if(vis[p1])quit();
				vis[p1]=++t;
				p1=a[p1];
			}
			for(int j=0,cnt;j<sz;j++)
				if(du[p1=vec[i][j]]==0)
				{
					cnt=0;
					while(!vis[p1])
					{
						cnt++;
						if(du[p1]==2)quit();
						p1=a[p1];
					}
					tail[p1]=cnt;
				}
			int now=0;p1=p;
			for(int j=1;j<=t*2;j++,p1=a[p1])
			{
				if(tail[p1])
					rem[p1]=max(rem[p1],now+1),now=0;
				else now++;
			}
			v1.clear();
			ins(p);p1=a[p];
			while(p1!=p)
			{
				ins(p1);
				p1=a[p1];
			}
		}
	}
	for(int i=1;i<=n;i++)if(num[i])
	{
		int t=0,now=1;
		for(int j=0;j<=num[i];j+=2)
		{
			int t1=(ll)jc[num[i]]*njc[num[i]-j]%mod*njc[j>>1]%mod*nbir[j>>1]%mod*now%mod;
			if((i&1)&&i!=1)t1=(ll)t1*bir[num[i]-j]%mod;
			t=(t+t1)%mod;
			now=(ll)now*i%mod;
		}
		ans=(ll)ans*t%mod;
	}
	printf("%d\n",ans);
	return 0;
}


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

using namespace std;

#define int long long
#define ll long long
typedef pair<int, int> P;
#define mod 1000000007
#define INF (1LL<<60)

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define YES cout << "YES" << endl;
#define Yes cout << "Yes" << endl;
#define NO cout << "NO" << endl;
#define No cout << "No" << endl;



signed main(){

	int a[5];
	cin >> a[0] >> a[1] >> a[2] >> a[3] >> a[4];
	sort(a, a + 5, [](int a, int b){ return (((a-1) % 10) > ((b-1) % 10)); });

	int ans = 0;
	rep(i, 5){
		ans = ceil(ans/10.0)*10 +  a[i];
		cerr << ans << endl;
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef pair<double,int> pdi;
struct cir {
    ll x, y, r;
    cir(){x=y=r=0;}
    cir(ll x, ll y, ll r):x(x),y(y),r(r){}
};

cir arr[1100];
double dist[1100][1100];
double dd[1100];
bool visit[1100];
const double eps = 1e-10;
int n;

double mabs(double a) {return a<0?-a:a;}
double dis(cir a, cir b) {
    return max(sqrt(max(0.0,1.0*(a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y)))-a.r-b.r,0.0);
}

int main() {
    int i, j;

    scanf("%lld%lld%lld%lld",&arr[0].x,&arr[0].y,&arr[1].x,&arr[1].y);
    scanf("%d",&n);
    for (i=2;i<n+2;i++) scanf("%lld%lld%lld",&arr[i].x,&arr[i].y,&arr[i].r);
    n+=2;
    for (i=0;i<n;i++) {
        dist[i][i] = 0.0;
        for (j=i+1;j<n;j++) {
            dist[i][j] = dist[j][i] = dis(arr[i],arr[j]);
        }
    }
    priority_queue<pdi, vector<pdi>, greater<pdi>> pq;
    for (i=0;i<n;i++) dd[i] = 1e18;
    dd[0] = 0; pq.push(pdi(0,0));
    while(!pq.empty()) {
        pdi tmp = pq.top();
        pq.pop();
        int here = tmp.second;
        visit[here] = true;
        double d = tmp.first;
        if (mabs(dd[here]-d)>eps) continue;
        for (i=0;i<n;i++) {
            if (visit[i]) continue;
            if (dd[i]>eps+dd[here]+dist[here][i]) {
                dd[i]=dd[here]+dist[here][i];
                pq.push(pdi(dd[i],i));
            }
        }
    }
    printf("%.15lf\n",dd[1]);

    return 0;
}


Measured memory_bytes: 13680
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<math.h>
#include<stdio.h>

using namespace std;

using ll = long long;

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

const ll INF = 1LL << 60;

typedef pair<ll, double> P;

bool pairCompare(const P & firstElof, const P & secondElof)
{
	return firstElof.second < secondElof.second;
}

bool IsPrime(ll num)
{
	if (num < 2) return false;
	else if (num == 2) return true;
	else if (num % 2 == 0) return false; // 偶数はあらかじめ除く
	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			// 素数ではない
			return false;
		}
	}

	// 素数である
	return true;
}

signed main() {
	ll ans = 0;

	ll n, m;
	cin >> n >> m;

	priority_queue<ll>a;
	rep(i, n) {
		ll tmp;
		cin >> tmp;
		a.push(tmp);
	}
	rep(i, m) {
		ll tmp = a.top();
		a.pop();
		a.push((ll)tmp / 2);
	}
	 while(!a.empty()){
		 ll tmp = a.top();
		 a.pop();
		 ans += tmp;
	}
	
	cout << ans;
}


Measured memory_bytes: 1400
#include<bits/stdc++.h>
#include<iostream>
using namespace std;
#define INF                          1e9+5
#define int                          long long
#define mod                          1000000007  // 1e9 + 7 >>>  ans%mod
#define greator_sort(arr,n)          sort(arr, arr+n, greater<int>())  //descending order sorting of array
#define mk(arr,n,type)               type*arr = new type[n];    //to make array dynamically // n = size_of_array  |  type = int or long long etc;                      
#define w(x)                         int x;cin>>x; while(x--)   //x = test cases
#define pb                           push_back

/*void c_p_c()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}*/
//WINES PROBLEMS TUTORIAL EXPLANATION-----------------------------------------------------------------------
/*int profit(int wines[], int i, int j, int y, int dp[][100]) {
	//base case
	if (i > j) {
		return 0;
	}

	//return if dp[i][j]
	if (dp[i][j] != 0) {
		return dp[i][j];
	}

	//recursive case
	int op1 = wines[i] * y + profit(wines, i + 1, j, y + 1, dp);
	int op2 = wines[i] * y + profit(wines, i, j - 1, y + 1, dp);

	return dp[i][j] =  max(op1, op2);

}



int32_t main()
{
	c_p_c();
	int wines[] = {2, 3, 5, 1, 4};
	int dp[100][100] = {0};
	int y = 1;
	int n = sizeof(wines) / sizeof(int);
	cout << profit(wines, 0, n - 1, y, dp);

	return 0;

}
*/
//-------------------------------------------------------------------------------------------------------------------------//
//
//
//SOLUTION OF   FROG 1---------------------------------------------------->

/*int ans(int a[], int n, int dp[]) {
	//base case
	dp[1] = 0;

	//recursive case
	for (int i = 2; i <= n ; ++i)
	{
		int op2;
		int op1 = abs(a[i] - a[i - 1]) + dp[i - 1];
		if (i != 2)
			op2 = abs(a[i] - a[i - 2]) + dp[i - 2];
		if (i == 2)
			dp[i] = op1;
		else
			dp[i] = min(op1, op2);
	}
	return dp[n];
}



int32_t main()
{
	c_p_c();
	int n; cin >> n; //size of the array
	int a[n];//height array
	for (int i = 1; i <= n; ++i)
	{
		cin >> a[i];
	}
	int dp[n + 1] = {0};
	cout << ans(a, n, dp) << endl;
}
*/


int32_t main()
{
	//c_p_c();
	int n , k;
	cin >> n >> k;

	int a[n + 1];
	for (int i = 0; i < n; ++i)
	{
		cin >> a[i];
	}
	vector<int> dp(n, INF);
	//base case
	dp[0] = 0;
	//recursive case
	for (int i = 0; i < n; ++i)
	{
		for (int j = i + 1; j <= i + k; ++j)
		{
			if (j < n)
				dp[j] = min(dp[j], abs(a[i] - a[j]) + dp[i]);
		}
	}
	cout << dp[n - 1] << endl;
}


Measured memory_bytes: 1792
-- {-# LANGUAGE BangPatterns #-}
-- {-# LANGUAGE ScopedTypeVariables #-}
-- {-# LANGUAGE FlexibleContexts #-}
-- {-# LANGUAGE ViewPatterns #-}
-- {-# LANGUAGE OverloadedStrings #-}

import qualified Data.Vector as V
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VUM
-- import qualified Data.Vector.Algorithms.Merge as VAM
-- import qualified Data.Heap as HP
import qualified Data.ByteString.Char8 as BC
import qualified Data.Map as MP
import qualified Data.Set as ST
import qualified Data.Sequence as SQ
import Data.Array
import Data.Array.Unboxed
import Data.Array.ST
import Data.Array.IO
import Data.Maybe
import Data.Ratio
import Data.Char
import Data.Bits
import Data.List
import Data.Tuple
import Data.Functor
import Data.IORef
import Data.STRef
import Control.Applicative
import Control.Monad
import Control.Monad.ST
import Debug.Trace

--------------------------------------------------------------------------
solve [] _ = 0
solve [y] x
    | y == x = 1
    | otherwise = 0
solve (y:ys) x
    | x < y = 0
    | otherwise = 1 + solve ys (x-y) 

main = do
    [n,x] <- sLineToIntL
    ys <- sort <$> sLineToIntL
    print $ solve ys x
--------------------------------------------------------------------------

-- Input Util
int :: IO Int
int = readLn 

double :: IO Double
double = readLn 

str :: IO String
str = getLine

strBC :: IO BC.ByteString
strBC = BC.getLine

sLineToIntL :: IO [Int]
sLineToIntL = getLine >>= return . map read . words

sLineToDoubleL :: IO [Double]
sLineToDoubleL = getLine >>= return . map read . words

sLineToIntV :: Int -> IO (VU.Vector Int)
sLineToIntV n = BC.getLine >>= return . VU.unfoldrN n (BC.readInt . BC.dropWhile isSpace)

sLineToDoubleV :: Int -> IO (VU.Vector Double)
sLineToDoubleV n = BC.getLine >>= return . VU.fromList . map (read . BC.unpack) . BC.words

mLinesToIntL :: Int -> IO [Int]
mLinesToIntL n = replicateM n readLn

mLinesToDoubleL :: Int -> IO [Double]
mLinesToDoubleL n = replicateM n readLn

mLinesToIntV :: Int -> IO (VU.Vector Int)
mLinesToIntV n = VU.replicateM n readLn

mLinesToDoubleV :: Int -> IO (VU.Vector Double)
mLinesToDoubleV n = VU.replicateM n (BC.getLine >>= return . read . BC.unpack)

mLinesToTupleL :: Int -> IO [(Int, Int)]
mLinesToTupleL n = replicateM n (getLine >>= return . (\[a,b] -> (a,b)) . map read . words)

mLinesToTupleV :: Int -> IO (VU.Vector (Int, Int))
mLinesToTupleV n = VU.replicateM n $ do
    bs <- strBC
    let
        Just (a, bs') = BC.readInt $ BC.dropWhile isSpace bs
        Just (b, _) = BC.readInt $ BC.dropWhile isSpace bs'
    return (a,b)
    
mLinesToTripleV :: Int -> IO (VU.Vector (Int, Int, Int))
mLinesToTripleV n = VU.replicateM n $ do
    bs <- strBC
    let
        Just (a, bs') = BC.readInt $ BC.dropWhile isSpace bs
        Just (b, bs'') = BC.readInt $ BC.dropWhile isSpace bs'
        Just (c, _) = BC.readInt $ BC.dropWhile isSpace bs''
    return (a,b,c)

-- others
strToChr :: String -> Char
strToChr [x] = x

chrToStr :: Char -> String
chrToStr x = [x]

m1 :: Int -> Int
m1 x = subtract 1 x

toDouble :: Int -> Double
toDouble x = fromIntegral x

toInt :: Double -> Int
toInt x = floor x

Measured memory_bytes: 1020
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int A, B, total;
		String ans;

		A = Integer.parseInt(sc.next());
		B = Integer.parseInt(sc.next());
		total = A + B;

		if(A % 3 == 0 || B % 3 == 0 || (A + B) % 3 == 0){
			ans = "Possible";
		}else{
			ans = "Impossible";
		}

		System.out.println(ans);

	}

}

Measured memory_bytes: 23252
import std.stdio,std.string,std.array,std.algorithm,std.range,std.conv;
import std.algorithm:rev=reverse;

void main(){
    auto input=readln.chomp.split.to!(int[]);
    auto n=input[0];
    auto m=input[1];

    auto result=n*(n-1)/2;
    result+=m*(m-1)/2;
    result.writeln;
}

Measured memory_bytes: 256
(defun get-loop-origin (n arr)
  (let ((visited (make-array n
                             :initial-contents
                             (loop repeat n collect 0))))
       (loop with pos = 0
             while t
             when (= 1 (aref visited pos))
               return (1- (aref arr pos))
             do (setf (aref visited pos) 1)
                (setf pos (1- (aref arr pos))))))

(defun get-loop-length (n arr idx)
  (let ((visited (make-array n
                             :initial-contents
                             (loop repeat n collect 0))))
       (loop with c = 0
             with pos = idx
             when (= 1 (aref visited pos))
               return c
             do (setf (aref visited pos) 1)
                (setf pos (1- (aref arr pos)))
                (incf c))))

(defun cost-until-origin (arr idx)
  (loop with c = 0
        with pos = 0
        when (= pos idx)
          return c
        do (setf pos (1- (aref arr pos)))
           (incf c)))

(defun solve (n arr k)
  (let* ((origin (get-loop-origin n arr))
         (length (get-loop-length n arr origin))
         (cost (cost-until-origin arr origin))
         (shortened-k (mod (- k cost) length)))
        (if (<= k cost)
            (loop with pos = 0
                  with rest-time = k
                  when (= rest-time 0)
                    return (1+ pos)
                  do (setf pos (1- (aref arr pos)))
                     (decf rest-time))
            (loop with pos = 0
                  with rest-time = (+ cost shortened-k)
                  when (= rest-time 0)
                    return (1+ pos)
                  do (setf pos (1- (aref arr pos)))
                     (decf rest-time)))))
              
  
(let* ((n (read))
       (k (read))
       (arr (make-array n
                        :initial-contents
                        (loop repeat n collect (read)))))
      (format t "~A" (solve n arr k)))


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

using namespace std;

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

  int64_t n;
  cin >> n;
  if (n == 0) {
    cout << "0\n";
    return 0;
  }
  stringstream ans;
  while (0 != n) {
    if (n % 2 != 0) {
      n -= 1;
      ans << "1";
    } else {
      ans << "0";
    }
    n /= -2;
  }
  string d = ans.str();
  reverse(d.begin(), d.end());
  cout << d << "\n";
}


Measured memory_bytes: 256
def bit_op(i,j):
    a = i&j
    return i ^ a


N = [int(i) for i in input().split()]

a = [0]*N[1]
b = [0]*N[1]
c = []

for k in range(N[1]):
    inp = [int(i) for i in input().split()]
    a[k] = inp[0]
    b[k] = inp[1]

    key = [int(i) for i in input().split()]

    c.append(key)
    
#print(a)
#print(b)
#print(c)

c_two = []

for k in range(N[1]):
    key=0
    for i in range(len(c[k])):
        key = key | 2**(c[k][i]-1)
    
    #print(key)
    c_two.append(key)

#print(c_two)

max_j = 2**N[0]

val = [1000000] * max_j

for i in range(N[1]):

    for j in range(max_j):
        j2 = bit_op(j, c_two[i])
        if j2 == 0 :
            if a[i] < val[j] :
                val[j] = a[i]
        else :
            if (val[j2] + a[i]) < val[j]:
                val[j] = val[j2] + a[i]

if val[max_j-1] == 1000000:
    print(-1)
else:
    print(val[max_j-1])

Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb(x) push_back(x)
#define f(i,st,n) for(i=st;i<n;i++)
#define vec vector
#define mst(a,b) memset(a,b,sizeof(a))
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;  
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define mod 1000000007
#define sfl(x) scanf("%lld",&x)
#define pfl(x) printf("%lld\n",x)
#define pf(x) printf("%lld",x)
#define all(v) v.begin(),v.end()
#define mpr make_pair
#define fs first
#define se second
#define inf LLONG_MAX
#define nnf LLONG_MIN
 
 
 
ll gcd(ll a,ll b){
    if(a==0){
        return b;
    }                     
    return gcd(b%a,a);
}
ll power(ll x,ll y){            
    ll res=1;
    while(y>0){
        if(y%2==1){
            res=((res%mod)*(x%mod))%mod;
        }
        x=((x%mod)*(x%mod))%mod;
        y=y/2;
    }
    return res;
}
 
 struct custom_hash {
  static uint64_t splitmix64(uint64_t x) {
    // http://xorshift.di.unimi.it/splitmix64.c
    x += 0x9e3779b97f4a7c15;
    x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
    x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
    return x ^ (x >> 31);
  }

  size_t operator()(pair<uint64_t,uint64_t> x) const {
    static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
    return splitmix64(x.first + FIXED_RANDOM)^(splitmix64(x.second + FIXED_RANDOM) >> 1);
  }
};

void get_time(auto start,auto end){
    double time_taken =  
      chrono::duration_cast<chrono::nanoseconds>(end - start).count(); 
  
    time_taken *= 1e-9;
    cout<<"\n";
    cout<<"Time taken : "<<fixed<<time_taken<<setprecision(6);
}




int main(){

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

  auto start = chrono::high_resolution_clock::now();

  
 

 /*#ifndef ONLINE_JUDGE
    
   freopen("input.txt", "r", stdin);
   
   freopen("output.txt", "w", stdout);
   #endif*/

   ll n,i;
   string s;
   cin>>n>>s;
   vec<ll>a,b;
   for(i=0;i<n;i++){
    if(s[i]=='W')a.pb(i);
    else b.pb(i);
   }

   ll ans=0;
   reverse(all(b));

   ll m=min(a.size(),b.size());

   for(i=0;i<m;i++){

    if(b[i]>a[i])ans++;
   }
   cout<<ans;



  auto end = chrono::high_resolution_clock::now();

  /*#ifndef ONLINE_JUDGE

   get_time(start,end); 

  #endif*/

    return 0;
 }

Measured memory_bytes: 5868
#include<cstdio>

int h,w;
int ans;
char map[102][102];
int dx[] = {0,0,1,-1};
int dy[] = {1,-1,0,0};

void dfs(int x,int y,char c){
  map[x][y] = 'A';
  for(int i=0;i<4;i++){
    if(map[x+dx[i]][y+dy[i]]==c){
      dfs(x+dx[i],y+dy[i],c);
    }
  }
}

int solve(){
  for(int i=0;i<=h+1;i++){
    for(int j=0;j<=w+1;j++){
      if(i==0||j==0||i==h+1||j==w+1) map[i][j] = 'A';
      else scanf(" %c ",&map[i][j]);
    }
  }
  for(int i=1;i<=h;i++){
    for(int j=1;j<=w;j++){
      if(map[i][j]!='A'){
        ans++;
        dfs(i,j,map[i][j]);
      }
    }
  }
  printf("%d\n",ans);
}
int main(){
  while(1){
    ans = 0;
    scanf("%d %d",&h,&w);
    if(h==0&&w==0) return 0;
    solve();
  }
}

Measured memory_bytes: 1508
#![allow(non_snake_case)]
use proconio::input;
// use std::collections::HashMap;

fn main() {
    input! {
        N: usize,
        Ls: [i64; N],
    }

    // 制約的に、O(N^3)の全探索でいける
    let mut ans = 0;
    for i in 0..N {
        for j in i + 1..N {
            for k in j + 1..N {
                if Ls[i] != Ls[j] && Ls[j] != Ls[k] && Ls[k] != Ls[i] {
                    if Ls[i] + Ls[j] > Ls[k] && Ls[j] + Ls[k] > Ls[i] && Ls[k] + Ls[i] > Ls[j] {
                        ans += 1;
                    }
                }
            }
        }
    }

    println!("{}", ans);
}


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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(int i=0;i<n;++i)
#define ALL(name) name.begin(),name.end()
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_N 100010

double RadianToDegree(double r) { return (r * 180.0 / acos(-1)); }

double a, b, x;

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

    cin >> a >> b >> x;

    double x2 = x / (a * a);

    double m = 2 * x2 - b;

    double ans;
    //DBG("x2: %f z: %f a: %f\n", x2, z, a);
    if(m >= 0) {
        ans = atan(2 * b / a - 2 * x / (a * a * a));
        printf("%.7f\n", RadianToDegree(ans));
    }
    else {
        double z = 2 * a * x2 / b;
        ans = atan(b / z);
        printf("%.7f\n", RadianToDegree(ans));
    }

    return 0;
}


Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n = int(input())
    S1 = input()
    S2 = input()

    Domino = []
    i = 0
    while i < n:
        if S1[i] == S2[i]:
            Domino.append("X")
            i += 1
        else:
            Domino.append("Y")
            i += 2

    res = 3 if Domino[0] == "X" else 6
    for i in range(1, len(Domino)):
        if Domino[i] == "X" and Domino[i - 1] == "X":
            res = res * 2 % mod
        elif Domino[i] == "X" and Domino[i - 1] == "Y":
            pass
        elif Domino[i] == "Y" and Domino[i - 1] == "X":
            res = res * 2 % mod
        else:
            res = res * 3 % mod

    print(res)


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 3064
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N = int(readline())
S = read().rstrip()

bl = False
if N % 2 == 0:
    M = N // 2
    bl = S[:M] == S[M:]

answer = 'Yes' if bl else 'No'
print(answer)

Measured memory_bytes: 3060
#include <iostream>
using ll = long long;
using namespace std;
 
int main() {
    string s;
    ll k;
    cin >> s >> k;
    ll p = min(k , (ll)s.length());
    for (int i = 0; i < p; ++i) {
        char e = s[i];
        if(e != '1') {
            cout << e << "\n";
            return 0;
        }
    }
    cout << s[p-1] << "\n";
    return 0;
}

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

using namespace std;
using ll = long long;


int main()
{
    string o, e;
    cin >> o >> e;
    vector<char> s(o.size() + e.size());

    int cur = 0;
    for(auto i : o){
        s[cur] = i;
        cur += 2;
    }
    cur = 1;
    for(auto i : e){
        s[cur] = i;
        cur += 2;
    }
    for(auto i : s)cout << i;
    cout << endl;
}

Measured memory_bytes: 256
N, D = map(int, input().split())
X = list()
Y = list()
for i in range(N):
    x, y = map(int, input().split())
    X.append(x)
    Y.append(y)

count = 0
for i in range(N):
    if X[i] * X[i] + Y[i] * Y[i] <= D * D:
        count += 1

print(count)


Measured memory_bytes: 24784
/// Containers Start
#include <algorithm>
#include <bitset>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
/// C Header Files
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <math.h>
#include <stdio.h>
/// Containers End

using namespace std;

/// Math Start
#define PI acos(-1.0)
#define Pi 3.141592653589793
#define EPS (1e-7)
#define INF (0x3f3f3f3f)
/// Math End

/// Extra Start
#define nn '\n'
#define pb push_back
#define ull unsigned long long
#define ll long long
#define MOD 1000000007
#define sz(a) int((a).size())
#define space " "
#define All(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
/// Extra End

#define rep(i, n) for (int i = 0; i < n; i++)
#define Cini(a)                                                                \
    int a;                                                                     \
    cin >> a;
#define Cinii(a, b)                                                            \
    int a, b;                                                                  \
    cin >> a >> b;
#define Ciniii(a, b, c)                                                        \
    int a, b, c;                                                               \
    cin >> a >> b >> c;
#define Cins(s)                                                                \
    string s;                                                                  \
    cin >> s;
#define Cinss(s1, s2)                                                          \
    string s1, s2;                                                             \
    cin >> s1 >> s2;
#define Cinc(c)                                                                \
    char c;                                                                    \
    cin >> c;
/// Functions End

/// Debug Start
#define deb(x) cout << #x << ": " << x << endl
#define deb2(x, y) cout << #x << ": " << x << '\t' << #y << ": " << y << endl;
#define deb3(x, y, z)                                                          \
    cout << #x << ": " << x << '\t' << #y << ": " << y << '\t' << #z << ": "   \
         << z << endl;
/// Debug End

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

/**>>>>>>>>>>>>>>>>>>> END <<<<<<<<<<<<<<<<<<**/

/// template

signed main(void) {
    cin.sync_with_stdio(false);
    cin.tie(0);
    Cini(N);
    vector<int> W(N);
    rep(i,N) cin >> W[i];
    int ans = INF;
    for(int t=1;t<N;t++){
        int sumLeft = 0,sumRight = 0;
        rep(i,t) sumLeft+= W[i];
        for(int i=t+1;i<=N;i++) sumRight += W[i-1];
        ans = min(ans,abs(sumRight-sumLeft));
    }
    cout << ans << nn;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h> 


using namespace std;



int main()
{
	int N;
	cin >> N;
	int verdict[4];
	for(int i = 0; i < 4; i++)
		verdict[i] = 0;
	string res;
	for(int i = 0; i < N; i++) {
		cin >> res;
		if(res == "AC") 
			verdict[0]++;
		else if (res == "WA")
			verdict[1]++;
		else if (res == "TLE")
			verdict[2]++;
		else
			verdict[3]++;
	}
	cout << "AC x " << verdict[0] << endl;
	cout << "WA x " << verdict[1] << endl;
	cout << "TLE x " << verdict[2] << endl;
	cout << "RE x " << verdict[3] << endl;
	return 0;
}

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

int N, a;

int main()
{
  scanf("%d", &N);

  int x = 1;
  for(int i = 0; i < N; i++) {
    scanf("%d", &a);
    if(a == x) x++;
  }
  x--;

  printf("%d\n", x==0? -1 : N - x);

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    int n;
    scanf("%d",&n);
    printf("%d\n",n/100*100+n/100*10+n/100>=n?n/100*100+n/100*10+n/100:(n/100+1)*100+(n/100+1)*10+n/100+1);
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <string>

using namespace std;

int A, B;
string S, T, U;




int main()
{


	cin >> S;
	cin >> T;
	cin >> A;
	cin >> B;
	cin >> U;


	
	if (U.compare(S) == 0) {
		A--;
	}
	else if (U.compare(T) == 0) {
		B--;
	}

	cout << A << " " << B << endl;

	return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<tuple>
#define TT std::tuple<double,double,double>
double t[210];
double v[210];
std::vector<TT> D;
double ans;
int SE;
int main() {
	int N;
	std::cin >> N;
	D.push_back(TT{ 0,0,0 });
	for (int i = 1; i <= N; i++) {
		std::cin >> t[i];
		t[i] += t[i - 1];
	}
	for (int i = 1; i <= N; i++) {
		std::cin >> v[i];
		D.push_back(TT{ t[i - 1],t[i],v[i] });
	}
	D.push_back(TT{ t[N],t[N],0 });
	double bef = 0;
	for (double i = 0.5; i <= t[N]; i+=0.5) {
		double ms = bef + 0.5;
		for (auto u : D) {
			double a, b, c;
			std::tie(a, b, c) = u;
			if (b <= i) {
				ms = std::min(ms, c + i - b);
			}
			if (a <= i&&i <= b) {
				ms = std::min(ms, c);
			}
			if (i <= a) {
				ms = std::min(ms, c + a - i);
			}
		}
		ans += (bef + ms)*0.25;

		bef = ms;
	}
	std::cout << std::fixed << ans << std::endl;
	return 0;
}

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

typedef long long int llint;

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

  int sum;

  for(int i = 0; i < 2; i++) {
    for(int j = 0; j < 2; j++) {
      for(int k = 0; k < 2; k++) {
	
	sum = s[0] - '0';

	sum += (s[1] - '0') * (i ? 1 : -1);
	sum += (s[2] - '0') * (j ? 1 : -1);
	sum += (s[3] - '0') * (k ? 1 : -1);

	if(sum == 7) {
	  string ans;
	  ans += s[0];
	  ans += (i ? '+' : '-');
	  ans += s[1];
	  ans += (j ? '+' : '-');
	  ans += s[2];
	  ans += (k ? '+' : '-');
	  ans += s[3];

	  cout<< ans + "=7" <<endl;

	  return 0;
	}

      }
    }
  }

  return 0;
}


Measured memory_bytes: 256
a = int(input())
b = int(input())
c = int(input())
x = int(input())

count = 0
for ai in range(a+1):
    a_val = 500 * ai
    for bi in range(b+1):
        b_val = 100 * bi
        for ci in range(c+1):
            c_val = 50 * ci
            sum_val = a_val + b_val + c_val
            if sum_val == x:
                count += 1

print(count)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define LL long long
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPA(i,n) for(int i=1;i<(n);++i)
#define foreach(i, n) for(auto &i:(n))
#define PII pair<int,int>
#define PLI pair<long long, int>
#define PLL pair<long long, long long>
#define PDD pair<double, double>
#define MOD ((int)1e9 + 7)
#define INF ((int)1e9)
#define INFLL ((LL)1e18)
#define ALL(x) (x).begin(),(x).end()
#define ctoi(x) (x - 'a') 
#define CTOI(x) (x - 'A')
#define BIT(x) (1 << (x))
using namespace std;

LL modinv(LL a){
    LL b = MOD, u = 1, v = 0;
    while(b){
        LL t = a / b;
        a -= t * b;swap(a, b);
        u -= t * v;swap(u, v);
    }
    u%=MOD;
    if(u < 0) u += MOD;
    return u;

}

LL exp(LL a, LL b){
    LL sum = a;
    LL res = 1;
    while(b){
        if(b&1){
            res = (res * sum)%MOD;
        }
        sum = (sum * sum) % MOD;
        b>>=1;
    }
    return res;
}

int main(){
    string str;
    map<char, int> m;
    string left="qwertasdfgzxcvb";
    string right="yuiophjklnm";
    foreach(i, left)m[i]=1;
    foreach(i, right)m[i]=2;
    while(cin>>str&&str!="#"){
        int count = 0;
        REPA(i, str.size())count += m[str[i]] != m[str[i-1]];
        cout << count << endl;
    }
    return 0;
}



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

int main() {
  int a,b,c;
  cin >>a>>b>>c;
  int count =0;
  while(a%2==0 && b%2==0 && c%2==0){
    count++;
    int tmpa=a;
    int tmpb=b;
    int tmpc=c;
    a=tmpb/2+tmpc/2;
    b=tmpa/2+tmpc/2;
    c=tmpa/2+tmpb/2;
    if(a==tmpa&&b==tmpb&&c==tmpc){
      cout<<-1<<endl;
      return 0;
    }
  }
  cout<<count<<endl;
  return 0;
}

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

int main()
{
    int a = 0, b = 0;
    std::cin >> a >> b;
    std::cout << a / b << " " << a % b << " ";
    printf("%.5f", (double)a / b);
    return 0;
}


Measured memory_bytes: 3220
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
#define Priq priority_queue<int,vi,greater<int>>
#define pb push_back
#define mp make_pair
#define INF (1ll<<60)
signed main(){
  vi A={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  int N; cin>>N;
  cout<<A[N-1]<<endl;
}


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


def key_search(dicti, item):
    for k, v in dicti.items():
        if v == item:
            return k


# print(As)
sb = {str(i): As[i-1] for i in range(1, n+1)}
jb = {}
for i in range(1, n+1):
    # print(sb[str(i)])
    jb[sb[str(i)]] = i
srted = sorted(jb.items())

ans = [srted[i][1] for i in range(n)]
print(*ans)




Measured memory_bytes: 85096