akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

struct RollingHash {
	static const ll mo0=1000000007,mo1=1000000009;
	static ll mul0,mul1;
	static const ll add0=1000010007, add1=1003333331;
	static vector<ll> pmo[2];
	string s; int l; vector<ll> hash_[2];
	void init(string s) {
		this->s=s; l=s.size(); int i,j;
		hash_[0]=hash_[1]=vector<ll>(1,0);
		if(!mul0) mul0=10009+(((ll)&mul0)>>5)%259,mul1=10007+(((ll)&mul1)>>5)%257;
		if(pmo[0].empty()) pmo[0].push_back(1),pmo[1].push_back(1);
		FOR(i,l) hash_[0].push_back((hash_[0].back()*mul0+add0+s[i])%mo0);
		FOR(i,l) hash_[1].push_back((hash_[1].back()*mul1+add1+s[i])%mo1);
	}
	pair<ll,ll> hash(int l,int r) { // s[l..r]
		if(l>r) return make_pair(0,0);
		while(pmo[0].size()<r+2)
			pmo[0].push_back(pmo[0].back()*mul0%mo0), pmo[1].push_back(pmo[1].back()*mul1%mo1);
		return make_pair((hash_[0][r+1]+(mo0-hash_[0][l]*pmo[0][r+1-l]%mo0))%mo0,
			             (hash_[1][r+1]+(mo1-hash_[1][l]*pmo[1][r+1-l]%mo1))%mo1);
	}
	pair<ll,ll> hash(string s) { init(s); return hash(0,s.size()-1); }
	static pair<ll,ll> concat(pair<ll,ll> L,pair<ll,ll> R,int RL) { // hash(L+R) RL=len-of-R
		while(pmo[0].size()<RL+2) pmo[0].push_back(pmo[0].back()*mul0%mo0), pmo[1].push_back(pmo[1].back()*mul1%mo1);
		return make_pair((R.first + L.first*pmo[0][RL])%mo0,(R.second + L.second*pmo[1][RL])%mo1);
	}
};
vector<ll> RollingHash::pmo[2]; ll RollingHash::mul0,RollingHash::mul1;

string W;
int L;
int NG[4040][4040];
int num[4040];
ll pat[4040];

int prefixNG[505050];
int suffixNG[505050];


ll mo=1000000007;

RollingHash rh;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>W;
	rh.init(W);
	L=W.size();
	
	// allsame;
	FOR(i,26) {
		if(count(W.begin(),W.end(),'a'+i)==L) return _P("%d\n%d\n",L,1);
	}
	
	for(l=1;l<=L;l++) if(prefixNG[l-1]==0) {
		for(x=l;x+l<=L;x+=l) {
			if(rh.hash(0,l-1)!=rh.hash(x,x+l-1)) break;
			prefixNG[x+l-1]=1;
		}
	}
	if(prefixNG[L-1]==0) return _P("1\n1\n");
	for(l=1;l<=L;l++) if(suffixNG[L-l]==0) {
		for(x=L-l-l;x-l>=0;x-=l) {
			if(rh.hash(x,x+l-1)!=rh.hash(x+l,x+l+l-1)) break;
			suffixNG[x]=1;
		}
	}
	int tot=0;
	FOR(i,L-1) if(prefixNG[i]==0 && suffixNG[i+1]==0) tot++;
	_P("%d\n%d\n",2,tot);
	
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n';
	FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	solve(); return 0;
}


Measured memory_bytes: 20940
using System;
using System.Collections.Generic;

namespace diverta2019_c
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var SD = new Dictionary<string, int>();

            // Aで終わる
            SD.Add("01", 0);

            // Bで始まる
            SD.Add("10", 0);

            // Bで始まりAで終わる
            SD.Add("11", 0);

            int r = 0;

            for (int i = 0; i < N; i++) 
            {
                var s = Console.ReadLine();
                int m = 0;

                if (s.Contains("AB"))
                    for (int j = 0; j < s.Length - 1; j++)
                        if (s[j] == 'A' && s[j + 1] == 'B')
                            r++;

                if (s[0] == 'B')
                    m += 10;

                if (s[s.Length - 1] == 'A')
                    m += 1;

                if (m > 0) 
                    SD[m.ToString("00")]++;
            }

            // 01 11 10
            if (SD["01"] > 0 && SD["11"] > 0 && SD["10"] > 0)
            {
                SD["01"]--;
                SD["10"]--;
                r += SD["11"] + 1;
            }
            // 01 11
            else if (SD["01"] > 0 && SD["11"] > 0)
            {
                SD["01"]--;
                r += SD["11"];
            }
            // 11 10
            else if (SD["11"] > 0 && SD["10"] > 0)
            {
                SD["10"]--;
                r += SD["11"];
            }
            // 11
            else if (SD["11"] > 0)
            {
                r += SD["11"] - 1;
            }

            //「Aで終わる」と「Bで始まる」を可能な限りつなげる
            r += Math.Min(SD["01"], SD["10"]);

            Console.WriteLine(r);
        }
    }
}


Measured memory_bytes: 17360
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int number = sc.nextInt();
    int[] array = new int[number];
		for(int i = 0; i < number; i++){
      array[i] = sc.nextInt();
    }

    Arrays.sort(array);
    int total = 0;
    for(int i = 0; i < array.length-2; i++){

        for(int j = 1+i; j < array.length-1; j++){

            for(int k = 1+j; k < array.length; k++){
              if(array[i]+array[j] <= array[k])
                break;
              total++;
            }

        }

    }

    System.out.println(total);
	}
}

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

int main(){
  string s;
  int k;
  cin >> s >> k;
  int n = s.size();
  
  vector<string> vec;
  rep(i,n){
    for(int j=1;j<=k;j++){
      string t=s.substr(i,j);
      vec.push_back(t);
    }
  }
  sort(vec.begin(),vec.end());
  vec.erase(unique(vec.begin(),vec.end()),vec.end());
  cout << vec[k-1] << endl;
  return 0;
  
}

Measured memory_bytes: 1660
#include<bits/stdc++.h>
#define int long long
using namespace std;
int n,ans,f[300][300],m,r,x,y,z;
bool flag[300];
int read(){
	char c=getchar();while (c!='-'&&(c<'0'||c>'9'))c=getchar();
	int k=1,kk=0;if (c=='-')k=-1;else kk=c-'0';c=getchar();
	while (c>='0'&&c<='9')kk=kk*10+c-'0',c=getchar();return kk*k;
}
void dfs(int x,int d,int la){
		if (x==r){ans=min(ans,d);return;}
		for (int i=1;i<=n;i++)
			if (flag[i]){
				flag[i]=false;
				dfs(x+1,d+f[la][i],i);
				flag[i]=true;
			}
	}
signed main(){
	n=read();m=read();r=read();memset(f,10,sizeof(f));
	for (int i=1;i<=r;i++)x=read(),flag[x]=true;
	for (int i=1;i<=n;i++)f[i][i]=0;
	for (int i=1;i<=m;i++)x=read(),y=read(),z=read(),f[x][y]=min(f[x][y],z),f[y][x]=min(f[y][x],z);
	for (int k=1;k<=n;k++)
		for (int i=1;i<=n;i++)
			for (int j=1;j<=n;j++)f[i][j]=min(f[i][j],f[i][k]+f[k][j]);
	for (int i=1;i<=n;i++)f[0][i]=0;
	ans=1e15;dfs(0,0,0);
	cout<<ans<<endl;
}

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

int main() {
	int a;
	while (cin >> a) {
		int b = (a % 39);
		if (b == 0) { b = 39; }
		cout << "3C";
		if (1 <= b&&b <= 9) { cout << "0"; }
		cout << b << endl;
	}
	return 0;
}

Measured memory_bytes: 3048
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		long ans = 0;
		for(int i = k + 1; i < n + 1; i++) {
			int div = n / i;
			int res = n % i;
			ans += div * (i - k);
			if(res >= k && k != 0) {
				ans += (res - (k - 1));
			} else if(res >= k && k == 0) {
				ans += (res - k);
			}
		}
		System.out.println(ans);
	}

}


Measured memory_bytes: 23764
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

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

int main() {
    int fans = 1012345678;
    vector<int> menus(5);
    rep(i, 5) scanf("%d", &menus[i]);
    vector<int> order = {0, 1, 2, 3, 4};

    while (next_permutation(order.begin(), order.end())) {
        int ans = 0;
        rep(i, menus.size()) {
            while (ans % 10 != 0) ans++;
            ans += menus[order[i]];
        }
        fans = min(fans, ans);
    }

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


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

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

using namespace std;

int main(){
  int n;cin>>n;
  vector<int> d(n);
  rep(i,n)cin>>d[i];
  sort(d.begin(), d.end());
  auto last = unique(d.begin(), d.end());
  d.erase(last, d.end());
//rep(i, d.size())cout<<d[i]<<' ';
cout<<endl;
  cout<<d.size();
  return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll     = long long;
using pii    = pair<int, int>;
using pll    = pair<ll, ll>;
using vi     = vector<int>;
using vl     = vector<ll>;
using vvi    = vector<vi>;
using vvl    = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}
template <class C>
void print(const C &c, std::ostream &os = std::cout) {
    std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, " "));
    os << std::endl;
}

int main() {
    int n;
    cin >> n;
    vector<deque<int>> a(1 << n);
    for (int i = 0; i < (1 << n); ++i) {
        int aa;
        cin >> aa;
        a[i].push_back(aa);
    }
    for (int i = 1; i < (1 << n); i <<= 1) {
        for (int j = 0; j < (1 << n); ++j) {
            if ((i & j) == 0) {
                for (auto &b : a[j])
                    a[j | i].push_back(b);
                sort(a[j | i].begin(), a[j | i].end());
                while (a[j | i].size() > 2)
                    a[j | i].pop_front();
            }
        }
    }
    vi ret(1 << n, 0);
    for (int i = 1; i < (1 << n); ++i) {
        ret[i] = a[i][0] + a[i][1];
        if (i)
            chmax(ret[i], ret[i - 1]);
    }
    for (int i = 1; i < (1 << n); ++i) {
        cout << ret[i] << "\n";
    }
    return 0;
}

Measured memory_bytes: 180224
#!/usr/bin/env python

n = int(input())
a = list(map(int, input().split()))

a = sorted(a)
ma = a[-1]
div = [0 for _ in range(ma+1)]

for i in range(n):
    for j in range(a[i], ma+1, a[i]):
        div[j] += 1

ans = 0 
for i in range(n):
    if div[a[i]] == 1:
        ans += 1
print(ans)

Measured memory_bytes: 32036
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"

using namespace std;

using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;
using i8 = int8_t;
using i16 = int16_t;
using i32 = int32_t;
using i64 = int64_t;

constexpr char newl = '\n';
constexpr double eps = 1e-10;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = ((b)-1); i >=(a); i--)
#define RF0(i,b) RFO(i,0,b)
#define fi first
#define se second
#define debug(x) cout << #x << ": " << x << '\n';
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()

template<typename T1, typename T2> inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
template<class T> void Print(vector<T> v) {
  F0R(i, v.size()) {
    cout << v[i] << ' ';
  }
  cout << newl;
}
template<class T> bool lcmp(const pair<T, T>& l, const pair<T, T>& r) {
  return l.first < r.first;
}

#if 1


// INSERT ABOVE HERE
signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int N, hn;
  i64 K;
  cin >> N >> K;
  hn = N >> 1;
  vector<int> bs(64);
  F0R(i, N) {
    i64 a;
    cin >> a;
    for (int n = 0; a; a >>= 1, n++) {
      if (a&1) bs[n]++;
    }
  }

  vector<vector<i64>> as(64, vector<i64>(2));
  F0R(i, 60) {
    as[i][0] = ((i64)1 << i) * bs[i];
    as[i][1] = ((i64)1 << i) * (N - bs[i]);
  }

  i64 result = 0, score = 0;
  RF0(b, 60) {
    bool f = (K >> b) & 1; // K のここのビット
    //debug(b);
    if (bs[b] > hn) {
      //cout << 0 << newl;
      score += as[b][0];
      //debug(score);
      if (f) {
        // Kが1のビットで0を選択するので、これ以降最善を取ることが出来る
        RF0(c, b) {
          score += max(as[c][0], as[c][1]);
          //debug(score);
        }
        break;
      }
    }
    else if (!f) {
      //cout << 0 << newl;
      score += as[b][0];
    }
    else {
      //cout << 1 << newl;
      i64 score2 = score + as[b][0]; // 0をとる世界線
      RF0(c, b) {
        score2 += max(as[c][0], as[c][1]);
      }
      chmax(result, score2);

      score += as[b][1];
    }
    //debug(score);
  }
  chmax(result, score);
  cout << result;
}
#endif


Measured memory_bytes: 3636
n = int(input())
ls = list(map(int,input().split()))
#a,bの最大公約数
def gcd(a,b):
    if b == 0:
        return a
    else:
        return gcd(b,a%b)
#リスト l の最大公約数
def gcdlist(l):
    a = l[0]
    for i in range(len(l)):
        a = gcd(a,l[i])
    return a
print(gcdlist(ls))

Measured memory_bytes: 62832
N, M = map(int, input().split())
a = [int(input()) for _ in range(M)]
MOD = 10**9 + 7
 
dp = [0] * (N+1)
dp[0] = 1
dp[1] = 1 if 1 not in a else 0
 
a = set(list(range(2,N+1))) - set(a)
for i in a:
    dp[i] = (dp[i-1] + dp[i-2]) % MOD
print(dp[N] % MOD)

Measured memory_bytes: 27552
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  char c;
  cin >> c;
  if(c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o')
    cout << "vowel" << endl;
  else
    cout << "consonant" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define pb push_back 
#define fr first
#define sc second
#define Rep(i,n) for(int i=0;i<(n);i++)
#define All(v) v.begin(),v.end()
#define Uniq(v) v.erase(unique(All(v)),v.end())
typedef pair<int, int> Pii; 
typedef pair<int, Pii> Pip;
typedef pair<string, int> Psi;
const int INF = (1<<30);
const int dx[]={1,0,-1,0}, dy[]={0,-1,0,1};
typedef pair<string, vector<int> > Psv;
typedef pair<int, string> Pis;

int main()
{
  int n;
  while( cin >> n, n ) {
    int times[31] = {0};
    Psv p[21];
    Rep(i, n) {
      string name; cin >> name;
      int d;
      vector<int> v;
      cin >> d;
      Rep(j, d) {
	int a; cin >> a;
	times[a]++;
	v.pb( a );
      }
      p[i] = Psv(name, v); 
    }

    vector<Pis> v2;
    Rep(i, n) {
      int sum = 0;
      vector<int> tmp = p[i].sc;
      Rep(j, tmp.size()) {
	sum += n - times[tmp[j]] + 1;
      }
      v2.pb( Pis(sum, p[i].fr) );
    }

    sort( All(v2) );
    cout << v2[0].fr << " " << v2[0].sc << endl;
  }

}

Measured memory_bytes: 3088
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define pi acos(-1.0)
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
 
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) c.begin(), c.end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
 
int main(){
    int n, m;
    cin >> n >> m;
    VI ans(n);
    REP(i,m){
        int u, v;
        cin >> u >> v;
        ans[u-1]++;
        ans[v-1]++;
    }
    REP(i,n) cout << ans[i] << endl;
    return 0;
}

Measured memory_bytes: 256
#include<cmath>
#include<queue>
#include<cstdio>
#include<vector>
#include<cstring>
#include<iostream>
#include<algorithm>
#define RG register
#define LL long long
#define fre(a) freopen(a".in","r",stdin);//freopen(a".out","w",stdout);
using namespace std;
const int MAXN=300000;
int n,m;
int X[MAXN],Y[MAXN],fa[MAXN];
double ans,ALL;
struct ed
{
   int from,to;
   double len;
}edge[MAXN];
bool comp(ed x,ed y){ return x.len>y.len; }
int find(int x)
{
   if(x!=fa[x])
      fa[x]=find(fa[x]);
   return fa[x];
}
void Union(int x,int y)
{
   x=find(x);
   y=find(y);
   fa[x]=y;
}
void work()
{
   int cnt=0;
   for(int i=1;i<=m;i++)
      {
	 int A=edge[i].from,B=edge[i].to;
	 if(find(A)!=find(B))
	    {
	       Union(A,B);
	       ans+=edge[i].len;
	       cnt++;
	    }
	 if(cnt>=n-1)break;
      }
}
int main()
{
   //fre("1");
   scanf("%d%d",&n,&m);
   for(int i=1;i<=n;i++)
      {
	 scanf("%d%d",&X[i],&Y[i]);
	 fa[i]=i;
      }
   for(int i=1,a,b;i<=m;i++)
      {
	 scanf("%d%d",&a,&b);
	 edge[i].from=a;
	 edge[i].to=b;
	 edge[i].len=sqrt((X[a]-X[b])*(X[a]-X[b])+(Y[a]-Y[b])*(Y[a]-Y[b]));
	 ALL+=edge[i].len;
      }
   sort(edge+1,edge+1+m,comp);
   work();
   ans=ALL-ans;
   printf("%.3lf\n",ans);
   return 0;
}

Measured memory_bytes: 3824
n,m = map(int,input().split())

pre = [0 for i in range(n+1)]
post = [0 for i in range(n+1)]
for _ in range(m):
    a,b = map(int,input().split())
    if a == 1:
        pre[b] = 1
    if b == n:
        post[a] = 1

for pr, po in zip(pre, post):
    if pr == 1 and po == 1:
        print("POSSIBLE")
        import sys
        sys.exit()

print("IMPOSSIBLE")

Measured memory_bytes: 6320
import java.util.Scanner;
import java.util.Arrays;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] a = new int[n];
    long sum = 0;
    for(int i = 0; i < n; i++){
      a[i] = sc.nextInt();
      sum += (long)a[i];
    }
    Arrays.sort(a);

    System.out.println(a[0] + " " + a[n-1] + " " + sum);
  }
}

Measured memory_bytes: 42016
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));

            return;
        }

        public void Solve(ConsoleInput cin)
        {
            var N = cin.ReadInt;
            var K = cin.ReadInt;
            var x = cin.ReadIntArray(N);

            var ans = 0;

            for (int i = 0; i < N; i++)
            {
                if (x[i] < K - x[i])
                {
                    ans += 2 * x[i];
                }
                else
                {
                    ans += 2 * (K - x[i]);
                }
            }

            WriteLine(ans);

        }
    }

    public static class Extensions
    {
        public static string Reverse(this string sourse)
        {
            char[] chrAry = sourse.ToCharArray();
            Array.Reverse(chrAry);
            return new string(chrAry);
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }
}

Measured memory_bytes: 11348
N = int(input())
L = list(map(int, input().split()))

L = sorted(L)

mappin = [0] * 2001
for l in L:
    mappin[l] += 1

for i in range(2000):
    mappin[i + 1] += mappin[i]

ans = 0
for i in range(N):
    for j in range(i + 1, N):
        temp = L[i] + L[j]
        addd = mappin[temp - 1] - j - 1
        # print(str(i) + " " + str(j))
        # print(addd)
        ans += max([0, addd])


print(ans)


Measured memory_bytes: 3188
import java.util.Scanner;
public class Main {
	public static void main(String []args) {
		Scanner sc=new Scanner(System.in);
		int k=0;
		while(true) {
		int x = sc.nextInt();
		int y = sc.nextInt();
		if(x==0&&y==0) {
			break;
		}
		if(x>y) {
		System.out.println(y+" "+x);
		}else if(x<y) {
		System.out.println(x+" "+y);
		}else {
			System.out.println(x+" "+y);
		}
		}
	}
}



Measured memory_bytes: 36572
from collections import deque

SA = deque(list(input()))
SB = deque(list(input()))
SC = deque(list(input()))

turn = 'a'

while True:
    if turn == 'a' and len(SA) == 0:
        ans = 'A'
        break
    elif turn == 'b' and len(SB) == 0:
        ans = 'B'
        break
    elif turn == 'c' and len(SC) == 0:
        ans = 'C'
        break

    if turn == 'a':
        turn = SA.popleft()
    elif turn == 'b':
        turn = SB.popleft()
    else:
        turn = SC.popleft()

print(ans)


Measured memory_bytes: 3444
n=int(input())
ab = []
for i in range(1,int(n**(1/2))+1):
    if n%i == 0:
        ab.append((n//i,i))
ans=10**12
for i in range(len(ab)):
    a,b = ab[i]
    ans=min(a+b-2,ans)
print(ans)

Measured memory_bytes: 3464
#include <iostream>
#include <vector>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;

int main() {
    int n,d;
    cin >> n >> d;
    int x[n][d];
    for (int i = 0; i < n; i++)
    {
        for (int k = 0; k < d; k++)
        {
            cin >> x[i][k];
        }
        
    }
    int ans = 0;
    for (int i = 0; i < n-1; i++)
    {
        for (int j = i+1; j < n; j++)
        {
            int dis = 0;
            for (int k = 0; k < d; k++)
            {
                dis += (x[i][k]-x[j][k])*(x[i][k]-x[j][k]);                
            }
            int intD = (int) sqrt(dis);
            if (intD == (double) sqrt(dis))
            {
                ans++;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

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

    int K;      cin >> K;
    int A, B;   cin >> A >> B;

    int temp = B/K - (A - 1)/K;

    temp > 0 ? puts("OK") : puts("NG");

    return 0;
}


Measured memory_bytes: 3624
A, B = map(int, input().split())

def mygcd(a, b):
    if a < b:
        return mygcd(b, a)
    elif b == 0:
        return a
    else:
        return mygcd(b, a % b)

gcd = mygcd(A, B)

import math

pfac = {}
gcd_tmp = gcd
for p in range(2, int(math.sqrt(gcd)) + 1):
    if gcd_tmp < 2: break
    if gcd_tmp % p == 0:
        i_p = 0
        while gcd_tmp % p == 0:
            gcd_tmp //= p
            i_p += 1
        #
        pfac[str(p)] = i_p
else:
    if gcd_tmp > 1: pfac[str(gcd_tmp)] = 1
    
# print("#", pfac)
        
print(1 + len(pfac))


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

using namespace std;

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  const int MAXP = 110000;
  VI primes;
  vector<bool> isprime(MAXP, true);
  for(int i=2;i<MAXP;++i)
	if(isprime[i]){
	  primes.PB(i);
	  for(int j=i+i;j<MAXP;j+=i)
		isprime[j] = false;
	}

  while(true){
	int N, P; cin >> N >> P;
	if(N == -1) break;
	int idx = upper_bound(ALL(primes), N) - primes.begin();
	VI dm;
	REP(i,P) for(int j=i;j<P;++j)
	  dm.PB(primes[idx+i]+primes[idx+j]);
	SORT(dm);
	cout << dm[P-1] << endl;
  }
  
  return 0;
}

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

#define gc getchar()
inline int read(){
	int x=0;int f=0;char c=gc;
	for(;c<48||c>57;c=gc)
		if(c=='-')f=1;
	for(;c>47&&c<58;c=gc)
		x=x*10+c-48;
	return f?-x:x;
}
#define io read()

#define maxn 200005
map<int,int> mp;
int n,a[maxn];

inline void init(){
	n=io;
	for(int i=1;i<=n;++i){
		a[i]=io;
		++mp[a[i]];
	}
}

inline void solve(){
	int ans=0;
	sort(a+1,a+n+1);
	for(int s=1<<30;s;s>>=1){
		for(int i=1;i<=n;++i){
			if(!mp.count(a[i])||!mp.count(s-a[i]))continue;
			if(s-a[i]==a[i]){
				if(mp[a[i]]>=2)mp[a[i]]-=2,++ans;
			}else{
				if(mp[a[i]]&&mp[s-a[i]])
					--mp[a[i]],--mp[s-a[i]],++ans; 
			}
		}
	}
	printf("%d\n",ans);
}

int main(){
	init();
	solve();
	return 0;
} 

Measured memory_bytes: 12416
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T>& V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> >& Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T>& mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
template<typename T>vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type fill_v(T &t,const V &v){t=v;}
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type fill_v(T &t,const V &v){for(auto &e:t) fill_v(e,v);}
/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

template<class Type>
Type solve(Type res = Type()){
    ll S,W; cin >> S >> W;
    if(W >= S) return "unsafe";
    else return "safe";
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    // solve(0);
    cout << fixed << setprecision(15) << solve<string>() << endl;
    return 0;
}


Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
int main(){
        string s;
        int  a =0 , b = 0, c = 0;
        cin >> s;
        for(int i = 0; i < 3; i++){
                if(s[i] == 'a') a++;
                else if(s[i] == 'b') b++;
                else if (s[i] == 'c') c++;
        }
        if(a == 1 && b == 1 && c == 1) cout << "Yes" << endl;
        else cout << "No" << endl;

return 0;
}


Measured memory_bytes: 256
import re

a, b = input().split()
b = b.replace('.','')
a = int(a)
b = int(b)
result = a * b 
float_r = result // 100

if type(float_r) == int:
  print(float_r)
else:
  print(re.sub('\.[0-9]*','',str(float_r)))

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

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++)
        cin >> a[i];
    for (int i = n - 1; i >= 0; i--) {
        cout << a[i];
        if (i > 0)
            cout << " ";
    }
    cout << endl;
}



Measured memory_bytes: 3112
#include<bits/stdc++.h>
#define SZ(v) ((int)v.size())
#define pb push_back
using namespace std;typedef vector<int> VI;const int N=200005;VI li[N],id;char s[N];int n,m,L,ec,sum,mark[N];
void markit(){for(int i=0;i<<2<id.size();i++){for(int j:{0,1})for(int k:{0,1})mark[id[i<<2|j<<1|k]]=ec+k+1;ec+=2;}}
void output(){puts("Yes");for(int i=0;i<L;i++){if(!mark[i])mark[i]=ec<0?-ec:++ec,ec=-ec;printf("%d ",mark[i]);}exit(0);}
int main(){scanf("%d",&n);scanf("%s",s+1);s[0]='1';L=n<<1;for(int i=0,j;i<L;i++)if(s[i]=='0'&&s[(i+1)%L]=='1'){
for(li[m].pb(i),j=(i+1)%L;s[j]=='1';j=(j+1)%L)li[m].pb(j);m++;}if(!m){if(~n&1){for(int i=0;i<L;i++)id.pb(i);markit();output();}
else puts("No"),exit(0);}for(int i=0;i<m;i++)sum+=SZ(li[i])-2;if(sum&1)puts("No"),exit(0);if(sum&2){for(int i=0;i<m;i++)
if(SZ(li[i])>2)li[m-1].swap(li[i]);for(int i=0;i<m-1;i++)if(SZ(li[i])>2){VI&a=li[i],&b=li[m-1];int la=SZ(a)-1,lb=SZ(b)-1,ea=a[la],eb=b[lb];
mark[a[la-1]]=mark[b[lb-1]]=++ec;a.pop_back();b.pop_back();a.pop_back();b.pop_back();a.push_back(eb);b.push_back(ea);sum-=2;break;}
if(sum&2)puts("No"),exit(0);}for(int i=0;i<m;i++){mark[li[i][0]]=ec+1+i;mark[li[i][SZ(li[i])-1]]=ec+1+(i+1)%m;
for(int j=1;j<SZ(li[i])-1;j++)id.pb(li[i][j]);}ec+=m;markit();output();return 0;}

Measured memory_bytes: 9084
n, k = map(int, input().split())
x = list(map(int, input().split()))
ans = []

for i in range(n-k+1):
    if x[i+k-1] < 0:
        ans.append(abs(x[i]))
    elif x[i] > 0:
        ans.append(abs(x[i+k-1]))
    else:
        ans.append(min(abs(x[i])*2+abs(x[i+k-1]), abs(x[i])+abs(x[i+k-1])*2))

print(min(ans))

Measured memory_bytes: 14224
#include <stdio.h>
#include <string.h>

int main(void){

    int a,b,ans=0 ;
    scanf ("%d%d",&a,&b) ;
    
    for (int i=a; i<=b; i++ ){
        
        if ( i%10==i/10000 ){
            
            int j = (i-(i/10000)*10000)/10 ;
            
            if ( j%10==j/100 ){
                
                ans++ ;
                
            }
        }
    }
    
    printf ("%d\n",ans) ;
    
    return 0 ;
}

Measured memory_bytes: 128
n,K=map(int,input().split())
h=list(map(int,input().split()))
dp=[0]*n 

for i in range(1,n):
    dp[i]=10**10
    for k in range(1,min(K,i)+1):
        dp[i]=min(dp[i],dp[i-k]+abs(h[i]-h[i-k]))
print(dp[n-1])

Measured memory_bytes: 52448
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
typedef long long LL;
int main(){
        LL X;
        LL ans=0;
        LL c=0;
        cin>>X;
        while(X>ans){
           c++;
           ans+=c;
        }
        cout<<c<<endl;
	return(0);
}

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

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

    for (int i = 0; i < b; i++) {
        if (a * i % b == c) {
            std::cout << "YES" << std::endl;
            return 0;
        }
    }

    std::cout << "NO" << std::endl;
}


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

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



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

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> l(N);
    for (int i = 0; i < N; i++){
        cin >> l[i];
    }
    sort(l.begin(), l.end());
    reverse(l.begin(), l.end());
    int cnt = 0;
    for (int i = 0; i < K; i++){
        cnt += l[i];
    }
    cout << cnt << endl;
}


Measured memory_bytes: 256
C = [list(map(int,input().split())) for _ in range(3)]
if C[0][1]-C[0][0]==C[1][1]-C[1][0]==C[2][1]-C[2][0] and C[0][2]-C[0][1]==C[1][2]-C[1][1]==C[2][2]-C[2][1]\
    and C[1][0]-C[0][0]==C[1][1]-C[0][1]==C[1][2]-C[0][2] and C[2][0]-C[1][0]==C[2][1]-C[1][1]==C[2][2]-C[1][2]:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 62060
import java.util.Scanner;

class Solver {
	static final Solver INSTANCE = new Solver();

	void solve(Scanner sc) {
		int N = sc.nextInt();
		int M = sc.nextInt();
		char[] chars = new char[N];
		for (int i = 0; i < M; i++) {
			int d = sc.nextInt() - 1;
			int raw = sc.nextInt();
			if (N != 1 && d == 0 && raw == 0) {
				System.out.println(-1);
				return;
			}
			char digit = (char) ('0' + raw);
			if (chars[d] != 0 && chars[d] != digit) {
				System.out.println(-1);
				return;
			}
			chars[d] = digit;
		}
		for (int i = 0; i < chars.length; i++) {
			if (chars[i] == 0) {
				chars[i] = '0';
			}
		}
		int min = Integer.parseInt(String.copyValueOf(chars), 10);
		int n = Integer.toString(min, 10).length();
		if (N > n) {
			if (N == 3) min += 100;
			else if (N == 2) min += 10;
		}
		System.out.println(min);
	}
}

class Main {
	public static void main(String... args) {
		Scanner in = new Scanner(System.in);

		Solver.INSTANCE.solve(in);

		in.close();
	}
}

Measured memory_bytes: 21844
#include <iostream>
#include<string>
using namespace std;
int main(void){
    string s;
    int flag = 0,a_idx,z_idx;
    cin >> s;
    for(int i=0;i<s.size();i++){
        if(flag == 0){
            if(s[i] == 'A') {
                a_idx = i;
                flag=1;
            }
        }
        if(s[i] == 'Z') z_idx = i;
    }
    
    cout<<z_idx-a_idx + 1;
}


Measured memory_bytes: 640
#include <stdio.h>          // printf(), scanf()
#include <stdlib.h>         // qsort()
#include <stdbool.h>

#define MAX_N 40

typedef struct player_tbl
{
	int id;
	int score;
} player_t;

int n;
player_t players[MAX_N];
int score[MAX_N][21];

int
cmp_func(const void *l_, const void *r_)
{
	const player_t *l = (const player_t*) l_;
	const player_t *r = (const player_t*) r_;

	if (l->score < r->score)
		return 1;

	if (l->score > r->score)
		return -1;

	if (l->id < r->id)
		return -1;

	if (l->id > r->id)
		return 1;

	return 0;
}

void
solve()
{
	for (int i = 0; i < n; ++i)
	{
		int total = 0;
		int s = 0;
		for (int f = 1; f <= 10; ++f)
		{
			int t = s;
			total += score[i][t];
			s++;
			if (score[i][t] == 10)
				total += score[i][t + 1] + score[i][t + 2];
			else
			{
				total += score[i][t + 1];
				s++;
				if (score[i][t] + score[i][t + 1] == 10)
					total += score[i][t + 2];
			}
		}

		players[i].score = total;
	}

	qsort(players, n, sizeof(player_t), cmp_func);
	for (int i = 0; i < n; ++i)
		printf("%d %d\n", players[i].id, players[i].score);
}

int
main(int argc, char **argv)
{
	while (true)
	{
		scanf("%d", &n);
		if (n == 0)
			break;

		for (int i = 0; i < n; ++i)
		{
			scanf("%d", &players[i].id);
			int s = 0;
			for (int f = 1; f <= 10; ++f)
			{
				int t = s;
				scanf("%d", &score[i][s++]);
				if (f != 10)
				{
					if (score[i][t] != 10)
						scanf("%d", &score[i][s++]);
				}
				else // frame 10 ?
				{
					scanf("%d", &score[i][s++]);
					if (score[i][t] == 10 || score[i][t] + score[i][t + 1] == 10)
						scanf("%d", &score[i][s++]);
				}
			}
		}

		solve();
	}

	return 0;
}

Measured memory_bytes: 1820
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cassert>
#define InfL 1000000000
#define InfLL 1000000000000000000LL
#define mod 1000000007
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rrep(i,n) for(int (i)=(n-1);(i)>=(0);(i)--)
using namespace std;
typedef long long ll;
typedef double db;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<db> vd;

int main() {
	ll K,  N;
	cin >> K >> N;
	ll ans = K;
	vl A(N);
	rep(i, N) {
		cin >> A[i];
	}
	sort(A.begin(), A.end(), less<ll>());
	vl Adiff(N);
	rep(i, N) {
		Adiff[i] = A[(i + 1) % N] - A[i];
		Adiff[i] += K;
		Adiff[i] %= K;
		ans = min(ans, K - Adiff[i]);
	}

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

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

//#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

vl l;
ll n,A,B,C;
ll dfs(ll i,ll a,ll b,ll c){
    if(i==n){
        if(!a|!b|!c) return L_INF;
        return abs(a-A) + abs(b-B) + abs(c-C);
    }
    ll res = dfs(i+1,a,b,c);
    chmin(res,dfs(i+1,a+l[i],b,c) + (a?10:0));
    chmin(res,dfs(i+1,a,b+l[i],c) + (b?10:0));
    chmin(res,dfs(i+1,a,b,c+l[i]) + (c?10:0));
    return res;
}
signed main()
{   
    gearup;
    cin >> n >> A >> B >> C;
    l.resize(n);
    rep(i,n)cin>>l[i];
    ll res = dfs(0,0,0,0);
    out(res);
}


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

typedef long lint;
typedef long long llint;

// static const int MAX = 1e6;
// static const int NIL = -1;
// static const ll INF = 1<<21;
// static const ll MOD = 1e9 + 7;

bool compPair(const pair<int, int>& arg1, const pair<int, int>& arg2) { return arg1.first > arg2.first; }
template<class T> void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> void chmin(T& a, T b) { if (a > b) { a = b; } }


int main(void) {
    int n, k;
    cin >> n >> k;

    vector<int> x(n);
    for(int in=0;in<n;in++) {
        cin >> x.at(in);
    }

    int ans = 1e9;
    for(int in=0;in<n-k+1;in++) {
        int ltor, rtol;
        ltor = abs(x.at(in)) + abs(x.at(in+k-1)-x.at(in));
        rtol = abs(x.at(in+k-1)) + abs(x.at(in+k-1)-x.at(in));
        ans = min({ans, ltor, rtol});
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <vector>
#include <stdlib.h>
#include <string.h>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <queue>
using namespace std;
typedef long long ll;
const int N = 1e5+5;


int main()
{
     int n;
     ll mina=10000000000000000;
     scanf("%d",&n);
    for(int i=1;i<=n/2;i++){
        int a=i,b=n-i;
        ll sum=0;
        while(a){
            sum=sum+a%10;
            a=a/10;
        }
        while(b){
            sum=sum+b%10;
            b=b/10;
        }
        mina=min(mina,sum);
    }
    cout<<mina<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#define LL long long
LL ans,b;
int n,prime[2000],not_prime[10010],tot;
void linear_shaker(int x){
	int i,j;
	for(i=2;i<=x;i++){
		if(!not_prime[i])prime[++tot]=i;
		for(j=1;prime[j]*i<=x;j++){
			not_prime[prime[j]*i]=1;
			if(i%prime[j]==0)break;
		}
	}
}
int main(){
	int i,n,cnt,x,j;
	linear_shaker(10000);
	ans=0;
	scanf("%d",&n);
	for(i=1;i<=n;i++){
		x=i,b=1;
		for(j=1;prime[j]*prime[j]<=x;j++){
			cnt=0;
			if(x%prime[j]==0){
				while(x%prime[j]==0)x/=prime[j],cnt++;
				b*=(cnt+1);
			}
		}
		if(x>1)b*=2;
		ans+=b*i;
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 1776
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();
    let a: usize = iter.next().unwrap().parse().unwrap();
    let b: usize = iter.next().unwrap().parse().unwrap();
    let mut ans = (b - 1) / (a - 1);
    if (b - 1) % (a - 1) != 0 {
        ans += 1;
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
public class Main {

	private static void solve() {
		int n = ni();
		int m = ni();
		
		double ret = 0;
		double p = 1;
		for (int i = 0; i < m; i ++) {
			p *= 0.5;
		}

		double q = 1;
		double c = (1900.0 * m + 100.0 * (n - m));
		for (int i = 1; i < 3000000; i ++) {
			ret += c * i * q * p;
			q *= (1 - p);
		}
		double eps = 0.0000001;
		System.out.println((int)Math.floor(ret + eps));
		
	}

	public static void main(String[] args) {
		new Thread(null, new Runnable() {
			@Override
			public void run() {
				long start = System.currentTimeMillis();
				String debug = args.length > 0 ? args[0] : null;
				if (debug != null) {
					try {
						is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
					} catch (Exception e) {
						throw new RuntimeException(e);
					}
				}
				reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
				solve();
				out.flush();
				tr((System.currentTimeMillis() - start) + "ms");
			}
		}, "", 64000000).start();
	}

	private static java.io.InputStream is = System.in;
	private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
	private static java.util.StringTokenizer tokenizer = null;
	private static java.io.BufferedReader reader;

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

	private static double nd() {
		return Double.parseDouble(next());
	}

	private static long nl() {
		return Long.parseLong(next());
	}

	private static int[] na(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}

	private static char[] ns() {
		return next().toCharArray();
	}

	private static long[] nal(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nl();
		return a;
	}

	private static int[][] ntable(int n, int m) {
		int[][] table = new int[n][m];
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				table[i][j] = ni();
			}
		}
		return table;
	}

	private static int[][] nlist(int n, int m) {
		int[][] table = new int[m][n];
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				table[j][i] = ni();
			}
		}
		return table;
	}

	private static int ni() {
		return Integer.parseInt(next());
	}

	private static void tr(Object... o) {
		if (is != System.in)
			System.out.println(java.util.Arrays.deepToString(o));
	}
}


Measured memory_bytes: 21588
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

ll DP[105][10];
ll f[10], g[10], h[10];

int main() {
  int H, W, K;
  cin>>H>>W>>K;
  if(W==1) {
    cout<<1<<endl;
    return 0;
  }
  g[0] = 1;
  for(int i=1;i<10;++i) {
    f[i] = g[i-1];
    g[i] = f[i-1]+g[i-1];
  }
  for(int i=0;i<10;++i) h[i] = f[i]+g[i];
  DP[0][0] = 1;
  for(int i=0;i<H;++i) {
    for(int j=0;j<W;++j) {
      if(j==0) {
        DP[i+1][j] += DP[i][j]*h[max(0, W-2)];
        DP[i+1][j+1] += DP[i][j]*h[max(0, W-3)];
        DP[i+1][j] %= mod;
        DP[i+1][j+1] %= mod;
      }
      else if(j==W-1) {
        DP[i+1][j] += DP[i][j]*h[max(0, W-2)];
        DP[i+1][j-1] += DP[i][j]*h[max(0, W-3)];
        DP[i+1][j] %= mod;
        DP[i+1][j-1] %= mod;
      }
      else {
        DP[i+1][j-1] += DP[i][j]*h[max(0, j-2)]%mod*h[max(0, W-2-j)]%mod;
        DP[i+1][j] += DP[i][j]*h[max(0, j-1)]%mod*h[max(0, W-2-j)]%mod;
        DP[i+1][j+1] += DP[i][j]*h[max(0, j-1)]%mod*h[max(0, W-3-j)]%mod;
        DP[i+1][j-1] %= mod;
        DP[i+1][j] %= mod;
        DP[i+1][j+1] %= mod;
      }
    }
  }
  cout<<DP[H][K-1]<<endl;
}



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


int main(){
ll N;
cin >> N;
ll num[1000000];
num[0] = N;
ll i = 1;
while(true){

if(N%2==0){
N/=2;
}
else N=N*3+1;

num[i] = N;

for(ll j = 0; j < i; j++){
    if(num[i] == num[j]){
        cout << i+1 << endl;
        return 0;
    }
}
i++;

}
}

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

int top,S[1000];
void push(int x){
  S[++top] = x;
}

int pop(){
  top--;
  return S[top+1];
}

int main(){
  int a,b;
  top = 0;
  char s[100];

  while( scanf("%s",s) != EOF){
    if(s[0] == '+'){
      a = pop();
      b = pop();
      push(a + b);
    }else if(s[0] == '-'){
      b = pop();
      a = pop();
      push(a - b);
      
    }else if(s[0] == '*'){
      a = pop();
      b = pop();
      push(a * b);
    }else{
      push(atoi(s));
    }
  }
  printf("%d\n",pop());
  return 0;
}



Measured memory_bytes: 2144
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define bit(x) (1L << (x))
using ll = long long;
using namespace std;

template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
 
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
    return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}

int main() {
    int n, m=0; cin >> n;
    REP(i, n) {
        int h; cin >> h;
        if(m - h > 1) {
            cout << "No" << endl;
            return 0;
        }
        
        m = max(m, h);
    }

    cout << "Yes" << endl;

    return 0;
}


Measured memory_bytes: 256