akhauriyash/Code-Regression huggingface dataset:
import sys
input = sys.stdin.readline
import collections

n = int(input())
A = list(map(int, input().split()))
c = collections.Counter(A)
l = c.most_common()
L = [ l[i] for i in range(len(l)) if l[i][1] >= 2 ]
b = sorted(L,reverse = True)
if len(b) == 0:
    ans = 0
elif len(b) == 1 and b[0][1] < 4:
    ans = 0
else:
    if b[0][1] >= 4:
        ans = b[0][0]**2
    else:
        ans = b[0][0]*b[1][0]
print(ans)

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

int main() {
	ios::sync_with_stdio(0);cin.tie(0);
	int n;
	cin >> n;
	map<int, int> mp, mp2;
	for(int i=0; i<n; i++) {
		int t;
		cin >> t;
		mp[t]++;
	}
	for(auto pr: mp) {
		mp2[pr.second]++;
	}
	vector<int> c(n+1);
	for(auto pr: mp2) {
		c[pr.first] = pr.second;
	}
	int mxn = n, cur = n;
	cout << n << '\n';
	for(int k=2; k<=mxn; k++) {
		while(n/k < cur) {
			n -= c[cur];
			c[cur-1] += c[cur];
			c[cur] = 0;
			cur--;
		}
		cout << cur << '\n';
	}
}

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

int main() {
    int n, k, sum = 0;
    cin >> n >> k;
    rep(i,n) {
        int x;
        cin >> x;
        
        sum += min(k-x,x) * 2;
    }
    cout << sum << endl;
    return 0;
}

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

int main() {
  string s; cin >> s;
  int indexS,indexE;
  for ( int i = 0; i < s.length(); i++) {
    if ( s[i] == 'A' ) {
      indexS = i+1;
      break;
    }
  }

  for ( int i = s.length(); i >= indexS-1; i-- ) {
    if ( s[i] == 'Z' ) {
      indexE = i+1;
      break;
    }
  }
  cout << indexE - indexS + 1 << endl;
  return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int a,b,x,i,B;
    cin>>a>>b>>x;

    if(a%x==0)
    {
        B=((b/x)-(a/x))+1;
        cout<<B<<endl;
    }
    else
    {
         B=((b/x)-(a/x));
        cout<<B<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
int64_t MOD=1000000007;


int keta(int64_t x){
  int64_t count=1;
  while(x/10!=0){
    x/=10;
    count++;
  }
  return count;
}


int main() {
  int N,M;
  cin>>N>>M;
  vector<vector<pair<int64_t,int64_t>>> SS(N);
  vector<pair<int64_t,int64_t>> ans;
  //県ごとに年と市の番号のpairを作る
  for(int i=0;i<M;i++){
    int64_t a,b;
    cin>>a>>b;
    SS.at(a-1).push_back(make_pair(b,i));
  }
  //県ごとに並び替え
  for(int64_t i=0;i<N;i++){
    if(SS.at(i).size()==0)continue;
  sort(SS.at(i).begin(),SS.at(i).end());
  }
  //認識番号と市の番号のpairを作る
  for(int64_t i=0;i<N;i++){
    for(int64_t j=0;j<SS.at(i).size();j++){
      int64_t c=SS.at(i).at(j).second;
      ans.push_back(make_pair(c,(i+1)*1000000+(j+1)));
    }
  }
  //市の番号順に並び替え
  sort(ans.begin(),ans.end());
  
  for(int64_t i=0;i<(int64_t)ans.size();i++){
    int64_t d=keta(ans.at(i).second);
    for(int64_t j=0;j<12-d;j++) cout<<0; //0を埋める
    cout<<ans.at(i).second<<endl;
  }
  
}


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

long long gcd(long long a, long long b) {
	if(a == 1 || b == 1){
		return 1;
	}
	if(a < b) gcd(b, a);
	long long r;
	while ((r=a%b)) {
		a = b;
		b = r;
	}
	return b;
}





int main() {
	// your code goes here
	long long n, x, a, b = 99999999, c;
	cin >> n >> x;
	
	long long s[n + 1];
	bool flag = false;
	for(long long i = 0; i < n; i++){
		cin >> s[i];
		
	}
	s[n] = x;
	sort(s, s+n+1);
	
	b = s[1] - s[0];
	for(long long i = 1; i <= n; i++){
		b = abs(gcd(b, s[i] - s[i - 1]));
	}
	cout << b << endl;
	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
using namespace std;
int main(){
	int S,s,h,m;
	cin>>S;
    h=S/3600;
    m=(S-h*3600)/60;
	s=S-h*3600-m*60;
	cout<<h<<":"<<m<<":"<<s<<endl;
	return 0;
}

Measured memory_bytes: 3084
#include <iostream>
#include <map>
using namespace std;
using large = long long;
int main() {
    int n, m;
    cin >> n >> m;
    auto count_of = map<int, int>();
    for (int i = 0; i < n; i++) {
        int a_i;
        cin >> a_i;
        count_of[a_i]++;
    }

    for (; m > 0; --m) {
        auto last = count_of.rbegin();
        auto price = last->first;
        auto count = last->second;
        if (count == 1) {
            count_of.erase(price);
        } else {
            last->second--;
        }
        count_of[price / 2]++;
    }

    auto sum = large(0);
    for (auto kv : count_of)
        sum += large(kv.first) * kv.second;
    cout << sum;
    return 0;
}


Measured memory_bytes: 4992
A,B,C,D = map(int,input().split())

from fractions import gcd

def lcm(x, y):
    return (x * y) // gcd(x, y)

def f(x):
    return x - x // C - x // D + x // lcm(C,D)

print(f(B) - f(A - 1))

Measured memory_bytes: 5048
#include <bits/stdc++.h>
    using namespace std;
    using ll = long long;
     
    int main()
    {
      int n, k; cin >> n >> k;
      vector<int> h(n);
      for (int i = 0; i < n; ++i) cin >> h[i];
      sort(h.begin(), h.end());
      
      ll sum = 0;
      for (int i = 0; i < n-k; ++i) sum += h[i];
      
      cout << sum << endl;
    }

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
    vector<int> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
  }
  sort(A.begin(), A.end()); 
 cout << A[N-1] - A[0] << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct Fast { Fast() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20);} } fast;

long long mod = 1000000007;

long long div(long long a, long long b, long long c){
    return b / c - (a - 1) / c;
}

void print_binary(long long a) {
    for (int i = 31; i >= 0; i--) {
        cout << (a >> i & 1);
    }
    cout << endl;
}


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

    if (n < floor(ceil(n / 1.08) * 1.08)){
        cout << ":(" << endl;
    }else{
        cout << int(ceil(n / 1.08)) << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define ff first
#define ss second
#define mp make_pair
 
using namespace std;

typedef long long ll;

int main(){
	int n,T;

	scanf("%d", &n);

	ll ans = 0;
	for(int i = 1; i <= n; i++)
		for(int j = 1; j <= n; j++)
			for(int k = 1; k <= n; k++)
				ans += __gcd(i, __gcd(j,k));

	printf("%lld\n", ans);

	return 0;
}

Measured memory_bytes: 3836
using System;
using static System.Console;
using System.Collections.Generic;
using System.Linq;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = InputNumList();
            var dx = n[2] - n[0];
            var dy = n[3] - n[1];
            WriteLine($"{n[2] - dy} {n[3] + dx} {n[0] - dy} {n[1] + dx}");
        }

        static int InputNum()
        {
            return int.Parse(ReadLine());
        }
        static List<int> InputNumList()
        {
            return ReadLine().Split(' ').Select(int.Parse).ToList();
        }
    }
}

Measured memory_bytes: 13396
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mod 1000000007
#define mp make_pair
#define pi acos(-1)
#define line cout<<"------------------"<<endl
#define fast ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0);
#define filein freopen("input.txt","r",stdin)
#define fileout freopen("output.txt","w",stdout)
#define mod 1000000007
#define inf (int)1e9+7
using namespace std;
double  ara[3009];
double  dp[3009][3009];
int n;
double  call(int ind, int cnt)
{
    if(ind==n) return cnt>=((n/2)+1);
    double &ret=dp[ind][cnt];
    if(ret!=-1.0) return ret;
    double a=1,b=1;
    a=ara[ind]*call(ind+1,cnt+1);
    b=(1-ara[ind])*call(ind+1,cnt);
    return ret=a+b;
}
int   main()
{

    cin>>n;
    for(int i=0;i<=n;i++)
    {
        for(int j=0;j<=n;j++) dp[i][j]=-1.0;
    }
    for(int i=0;i<n;i++) cin>>ara[i];
    printf("%.10f\n",call(0,0));

}


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

using namespace std;

int main(){
    int a, b;
    cin>>a>>b;
    for(int k=0;k<=1e9+10;k++){
        if(abs(a-k)==abs(b-k)){
            cout<<k<<endl;
            return 0;
        }
    }
    cout<<"IMPOSSIBLE"<<endl;
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define ll long long
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define deb(x) cout<<#x<<"="<<x<<endl;
#define endl '\n'
#define M 1000000007
#define int long long
#define INF 1e18
#define N 1000005

using namespace std;

void solve()
{
	ll a, b, c, d;
	cin >> a >> b >> c >> d;
	cout << max({a * c, b * d, a * d, b * c}) << endl;
}

int32_t main()
{
	IOS
	ll T = 1;
	// cin >> T;
	for (ll i = 1; i <= T; ++i)
	{
		// cout<<"Case #"<<i<<": ";
		solve();
	}
	return 0;
}

Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define RFOR(i,l,r) for(long long i=(l);i>=(r);--i)
#define RREP(i,n) RFOR(i,N-1,0)
#define RREPS(i,n) RFOR(i,N,1)
#define int long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
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;
}
const int INF=1e18;
const int MOD=1e9+7;

signed main(){
    string S,T;cin>>S>>T;
    bool ok=false;
    REP(i,S.size()){
        char c=S[0];
        S=S.substr(1,S.size()-1);
        S+=c;
        if(S==T){
            ok=true;
            break;
        }
    }
    cout<<(ok?"Yes":"No")<<endl;
}

Measured memory_bytes: 256
def main():
    n, w_max = map(int, input().split())
    dp = [[0] * (w_max + 1) for _ in range(n + 1)]
    items = [tuple(map(int, input().split())) for _ in range(n)]
    for i1 in range(1, n + 1):
        w, v = items[i1 - 1][0], items[i1 - 1][1]
        for col in range(1, w_max + 1):
            if w <= col:
                dp[i1][col] = max(dp[i1 - 1][col], dp[i1 - 1][col - w] + v)
            else:
                dp[i1][col] = dp[i1 - 1][col]

    print(dp[-1][-1])


if __name__ == '__main__':
    main()


Measured memory_bytes: 118512
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iostream>
#include <map>
#include <stack>
#include <queue>
#include <vector>

static const int IINF = 1 << 30;
static const long long LINF = 1LL << 60;
static const long long MOD = 1.0e+9 + 7;

template <typename T> std::vector<T> vectors(std::size_t n, T val) {
  return std::vector<T>(n, val);
}

template <typename T, typename... Args>
auto vectors(std::size_t n, Args... args) {
  return std::vector<decltype(vectors<T>(args...))>(n, vectors<T>(args...));
}

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

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

template <class T> inline void chadd(T &a, const T &b) {
  a += b, a %= MOD;
  // TODO minus case
}

template <class T>
std::ostream &operator<<(std::ostream &s, const std::vector<T> &v) {
  if (v.empty())
    return s;
  s << *v.begin();
  for (auto iter = v.begin() + 1; iter != v.end(); ++iter)
    if (std::is_fundamental<T>::value)
      s << " " << *iter;
    else
      s << std::endl << *iter;
  return s;
}

int main() {
  int K, N;
  std::cin >> K >> N;
  std::vector<int> A(N);
  for (int i = 0; i < N; ++i)
    std::cin >> A[i];


  int m = -1;
  for (int i = 0; i < N - 1; ++i) {
    int tmp = A[i + 1] - A[i];
    m = std::max(m, tmp);
  }

  m = std::max(m, A[0] + K - A[N - 1]);

  std::cout << K - m << std::endl;


  return 0;
}


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

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cerr << name << " : " << arg1 << "\n";
}
template <typename Arg1, typename... Args>
void __f(const char* na, Arg1&& arg1, Args&&... args) {
  const char* c = strchr(na + 1, ',');
  cerr.write(na, c - na) << " : " << arg1 << " , ";
  __f(c + 1, args...);
}
#define endl "\n"
#define all(v) v.begin(), v.end()
#define UNIQUE(v) sort(all(v)),v.erase(unique(all(v)),v.end())
typedef long long LL;
typedef pair <int,int> pii;
const double pi = acos(-1.0);
const double eps = 1e-8;
const int mod = 1e9 + 7;
const int inf = 1e9;
const LL INF = 1e18;
const int N = 1e5 + 5;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0); cout.tie(0);
  #ifdef LOCAL
    freopen("input.txt", "r", stdin);
  #endif // LOCAL
  int n;
  cin >> n;
  vector <LL> h (n + 1);
  for (int i = 1; i <= n; i++) cin >> h[i];
  vector <LL> dp (n + 1, INF);
  dp[1] = 0;
  for (int i = 2; i <= n; i++) {
    if (i == 2) dp[i] = dp[i - 1] + abs(h[i] - h[i - 1]);
    else dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i] - h[i - 2]));
  }
  cout << dp[n] << endl;
  return 0;
}


Measured memory_bytes: 1792
/*
ID: anonymo14
TASK: wormhole
LANG: C++                 
*/
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<pair<int,int>> vpii;

#define F first
#define S second
#define PU push
#define PUF push_front
#define PUB push_back
#define PO pop
#define POF pop_front
#define POB pop_back

#define REP(i,a,b) for(int i=a; i<=b; i++)

#define MOD 1000000007

void solve(int test_case) {
	int n;
	cin>>n;
	vi arr(n+2,0);
	ll sum = 0;
	for(int i=1;i<=n;i++){
		cin>>arr[i];
		sum+=abs(arr[i-1]-arr[i]);
	}
	sum+=abs(arr[n]);
	vi sol(n+2,0);
	for(int i=1;i<=n;i++) {
		sol[i] = sum-abs(arr[i-1]-arr[i])-abs(arr[i]-arr[i+1])+abs(arr[i-1]-arr[i+1]);
	}
	for(int i=1;i<=n;i++)cout<<sol[i]<<"\n";
}

int main() {
	
	////// FILE BASED IO////
	//freopen("wormhole.in", "r", stdin);
	//freopen("wormhole.out", "w", stdout);
	///////////////
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
	//cin>>t;
	REP(i,1,t) {
		solve(i);
	}
	return 0;
}	


Measured memory_bytes: 3976
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

//AtCoder Beginner Contest 135
//B	0 or 1 Swap
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt((sc.next()));
		List<Integer> pList = new ArrayList<>();
		List<Integer> sList = new ArrayList<>();
		for (int i = 0; i < N; i++) {
			int p = sc.nextInt();
			pList.add(p);
			sList.add(p);
		}
		sc.close();

		Collections.sort(sList);

		int differ = 0;
		for (int i = 0; i < N; i++) {
			if (pList.get(i) != sList.get(i)) {
				differ++;
			}
		}

		if (differ == 0 || differ == 2) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}
	}
}


Measured memory_bytes: 22996
K=int(input())
array=[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]
print(array[K-1])

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

bool isResolvable(int N, int Y) {
  if (10000 * N < Y) return false;
  if (1000 * N > Y) return false;
  return true;
}

int main(){
  int N, Y;
  cin >> N >> Y;
  
  int x, y, z;
  x = y = z = -1;
  bool found = false;
  
  if (isResolvable(N , Y)) {
    for (int i = 0; i <= N; ++i) {
      for (int j = 0; j <= N - i; ++j) {
        int k = N - i - j;
        if (k < 0) continue;

        int amount = 10000 * i + 5000 * j + 1000 * k;
        if (amount == Y) {
          found = true;
          x = i; y = j; z = k;
          break;
        }
      }
      if (found) break;
    }
  }    
  cout << x << " " << y << " " << z << endl;
}

Measured memory_bytes: 3624
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#define rep(i, j) for (long long i = 0; i < j; i++)

using namespace std;

signed main()
{
    string str;
    cin >> str;
    const char* str2;
    rep(i, str.size())
    {
        if (i % 2 == 1) {
            str2 = "R";
        } else {
            str2 = "L";
        }
        if (*str2 == str[i]) {
            cout << "No" << endl;
            return 0;
        }
    };
    cout << "Yes" << endl;
}


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

using namespace std;

typedef long long ll;

ll n;
ll a[100005];
ll x, y;

int main()
{
    scanf("%lld", &n);
    for(ll i = 0; i < n; i++)
    {
        scanf("%lld", &a[i]);
    }
    sort(a, a + n);
    if(a[n - 1] - a[0] > 1)
    {
        printf("No\n");
        return 0;
    }
    if(a[n - 1] == a[0])
    {
        if(a[0] == n - 1) printf("Yes\n");
        else if(a[0] <= n / 2) printf("Yes\n");
        else printf("No\n");
        return 0;
    }
    x = upper_bound(a, a + n, a[0]) - lower_bound(a, a + n, a[0]);
    y = n - x;
    if(x + y / 2 < a[n - 1]) printf("No\n");
    else if(a[n - 1] <= x) printf("No\n");
    else printf("Yes\n");
    return 0;
}


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

typedef long long ll;
#define REP(i,n) for(ll i=0; i<(ll)(n); i++)
#define REPM(i,n) for(ll i=(n); 0<=i; i--)
#define VI vector<int>
#define VL vector<ll>
#define VD vector<double>
#define VS vector<string>
#define V_SORT_U(x) sort(x.begin(), x.end());                   //昇順
#define V_SORT_D(x) sort(x.begin(), x.end(),greater<int>());    //降順
#define V_SUM(x) accumulate(x.begin(), x.end(), 0)
#define STR_TRANS_UP(x) transform(x.begin(), x.end(), x.begin(), ::toupper); 
#define STR_TRANS_LOW(x) transform(x.begin(), x.end(), x.begin(), ::tolower);
#define SetPre(x) setprecision(x)

int main() {
	int N;
	cin >> N;
	VL A(N);
	VI B(1000001, 0); //全領域でフラグリスト作る
	REP(i,N)
    {
        cin >> A[i];
        B[A[i]] ++; //個数をカウントする
    }
    ll answer = 0;
    REP(i,N)
    {
        bool check = true;
        B[A[i]] --; //該当する数は1->0, それ以外は0->-1になる、自分自身を除外するために-1する、2個以上含まれる場合は除外しないようにする
        for(ll j=1; j*j <= A[i]; j++)
        {
            //A[i]の√の部分まで考えればOK
            if( A[i] % j == 0 )
            {
                //jで割り切れる場合
                if( B[j] != 0 ) check = false; //割り切れる数が与えられた数列に含まれるのでNG
                if( B[A[i] / j ] != 0 ) check = false; //商の値が与えられた数列に含まれるとNG
            }
        }
        //ここまで来て、check=trueだったらOKな変数になる。
        B[A[i]] ++; //自分自身の除外を戻す！
        if(check) answer ++;
    }

	cout << answer << endl;
}

Measured memory_bytes: 8804
import sys
sys.setrecursionlimit(10 ** 8)

def Z(): return int(input())
def ZZ(): return [int(_) for _ in input().split()]

def main():

    n = Z()
    alf = 'zabcdefghijklmnopqrstuvwxy'
    ans = []
    while n > 0:
        n, b = divmod(n, 26)
        ans.append(alf[b])
        if b == 0: n -= 1
    print(''.join(ans)[::-1])

    return

if __name__ == '__main__':
    main()


Measured memory_bytes: 9192
import math

a,b,h,m=map(int,input().split())

h_just=30*h


hm=h_just-(5.5*m)

if hm<0:
  hm=hm*(-1)

elif hm>180:
  hm=360-hm

#print(hm)


print(math.sqrt((a*a)+(b*b)-2*a*b*math.cos(math.radians(hm))))

Measured memory_bytes: 62344
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 998244353


def main():
    N, K, *LR = map(int, read().split())
    interval = [(l, r) for l, r in zip(*[iter(LR)] * 2)]

    dp = [0] * (N + 2)
    dp[1] = 1
    dp[2] = -1

    for i in range(1, N + 1):
        dp[i] = (dp[i] + dp[i - 1]) % MOD
        cur = dp[i]
        for l, r in interval:
            if i + l <= N:
                dp[i + l] += cur
                dp[min(i + r + 1, N + 1)] -= cur

    print(dp[N])
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 75204
#include <bits/stdc++.h>
#if ONLINE_JUDGE
    #define DEBUG false
#else
    #define DEBUG true
#endif
#define fastcin() std::cin.tie(0);std::ios::sync_with_stdio(false)
#define REP(i, k, n) for (int i = (int)(k); i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define rep1(i, n) REP(i, 1, n)
#define rREP(i, k, n) for (int i = (int)(n)-1; i >= k; i--)
#define rrep(i, n) rREP(i, 0, n)
#define all(x) (x).begin(),(x).end()
#define SORT(x) std::sort(all(x))
#define REV(x) std::reverse(all(x))
#define UNIQUE(x) x.erase(std::unique(all(x)), x.end());
#define MAX(x) *std::max_element(all(x))
#define MIN(x) *std::min_element(all(x))
#define LOWitr(x, n) std::lower_bound(all(x), n)
#define UPRitr(x, n) std::upper_bound(all(x), n)
#define cii(x) int x; std::cin >> x
#define cill(x) signed long long int x; std::cin >> x
#define cis(x) std::string x; std::cin >> x
#define co(x) std::cout << x << "\n"
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define truecheck assert
#define dump(x) if(DEBUG) std::cout<<#x<<" : "<<(x)<<"\n"
using LL = signed long long int;
template<class T>using V = std::vector<T>;
template<class T>using VV = std::vector<std::vector<T>>;
template<class T>using Q = std::queue<T>;
template<class T>using PQ = std::priority_queue<T>;
template<class T,class U>using P = std::pair<T, U>;
template<class T,class U>using M = std::map<T, U>;
template<class T,class U>using UM = std::unordered_map<T, U>;
template<class T,class U>inline bool chmax(T &a, const U &b){if (a<b){a=b;return true;}return false;}
template<class T,class U>inline bool chmin(T &a, const U &b){if (b<a){a=b;return true;}return false;}
template<class T,class U>inline void vcinpb(T &v, U n){rep(i, n){typename T::value_type a;std::cin >> a;v.pb(a);}}
template<class T>inline void dumpv(const T& v, std::ostream& os = std::cout){
    if(DEBUG){
        os<<"{";
        auto f=[&os](typename T::value_type p){os<<p<<',';};
        std::for_each(all(v),f);
        os<<"}\n";
    }
}
const int INF = INT_MAX, MOD = 1e9 + 7;
const LL LLINF = LLONG_MAX;
// M_PI 3.1415...

int main() {
    //using namespace std;
    using std::cout;
    using std::cin;
    fastcin();
    cout << std::fixed << std::setprecision(10);
    cill(n);
    V<LL> v(n+10), ph(201000), mh(201000), idxes;
    LL ans = 0;
    rep(i, n){
        cin >> v[i];
    }
    rep(i, n){
        if(i+1 + v[i] < 200900){
            ph[ i+1 + v[i] ]++;
            if (ph[ i+1 + v[i] ] == 1){
                idxes.pb(i+1 + v[i]);
            }
        }
        if(i+1 - v[i] > 0){
            mh[ i+1 - v[i] ]++;
            if (mh[ i+1 - v[i] ] == 1){
                idxes.pb(i+1 - v[i]);
            }
        }

    }
    SORT(idxes);
    UNIQUE(idxes);
    dumpv(idxes);
    for(auto&& i : idxes){
        ans += ph[i] * mh[i];
        dump(ans);
    }
    co(ans);
    return 0;
}

Measured memory_bytes: 10024
//#include <bits/stdc++.h>
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
//#include "boost/multiprecision/cpp_int.hpp"
//typedef boost::multiprecision::cpp_int LL;
typedef long double dd;
//#define i_7 (ll)(1E9+7)
#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
typedef pair<dd,dd> d_d;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fi first
#define se second
#define endl "\n"
#define SORT(v) sort(v.begin(),v.end())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
#define POSL(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define POSU(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

//////////////////////////



int main(){fastio
    ll k;string s;
    cin>>k>>s;
    if(s.size()<=k){
        cout<<s<<endl;
    }else{
        rep(i,0,k-1)cout<<s[i];
        cout<<"..."<<endl;
    }
    return 0;
}


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

import fractions
import sys
from collections import defaultdict

N, M = map(int, input().rstrip().split(' '))
S = [x for x in input()]
T = [x for x in input()]

def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)

L = lcm(N, M)

dp = defaultdict(lambda: -1)

for i, s in enumerate(S):
    dp[i*L//N] = s

for i, t in enumerate(T):
    if dp[i*L//M] != -1:
        if dp[i*L//M] != t:
            print(-1)
            sys.exit()
print(L)


Measured memory_bytes: 18412
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n[3], req = 0;
    for(int i = 0; i < 3; i++){
        cin >> n[i];
    }
    sort(n, n+3);
    req = n[2] - n[0];
    cout << req << endl;
return 0;
}


Measured memory_bytes: 256
def main():
    N = int(input())
    P = list(map(int, input().split()))

    ans = 1
    tmp = P[0]
    for i in range(1, N):
        if P[i] == 1:
            print(ans + 1)
            return

        tmp = min(tmp, P[i])
        if P[i] <= tmp:
            ans += 1

    print(ans)


if __name__ == "__main__":
    main()


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

int main() {
	int k, s; cin >> k >> s;
	int ans = 0;

	if (k + k + k < s)
	{
		cout << ans << endl;
	} else {
		for (int i = 0; i <= k; i++)
		{
			for (int j = 0; j <= k; j++)
			{
				int z = s - i - j;
				if (z >= 0 && z <= k)
				{
					ans++;
				}
				
			}
			
		}
		
	}
	
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
int n,m,cnt[100001],loc[100001];
vector<P> s[200000];
int main(void){
    cin>>n>>m;
    for(int i=0;i<m;i++){
        int a,b,c;
        cin>>a>>b>>c;
        s[a].push_back(P(b,c));
        s[b].push_back(P(a,c*-1));
    }
    for(int i=0;i<n;i++){
        if(!cnt[i]){
            loc[i]=0;
            cnt[i]=1;
            queue<int> que;
            que.push(i);
            while(!que.empty()){
                int q=que.front();
                que.pop();
                for(auto p:s[q]){
                    if(cnt[p.first]){
                        if(loc[q]+p.second!=loc[p.first]){cout<<"No"<<endl;return 0;}
                    }
                    else{
                        loc[p.first]=loc[q]+p.second;
                        cnt[p.first]=1;
                        que.push(p.first);
                    }
                }
            }
        }
    }
    cout<<"Yes"<<endl;
}


Measured memory_bytes: 12160
#include<iostream>
#include<cstdio>
using namespace std;
int main(){
	for(;;){
		int n,field[15][15] = {0};
		cin >>n;
		if(!n){break;}
		int x = n/2,y = n/2+1;
		field[x][y] = 1;
		for(int i=2; i<=n*n; i++){
			x++;
			y++;
			for(;;){
				if(x>=n){x = 0;}
				if(x<0){x = n-1;}
				if(y>=n){y = 0;}
				if(!field[x][y]){field[x][y] = i;break;}
				else if(field[x][y]){x--;y++;}
			}
		}
		for(int i=0; i<n; i++){
			for(int j=0; j<n; j++){
				printf("%4d",field[j][i]);
			}
			cout<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
using namespace std;
int main(){
  int N;cin>>N;
  vector<int>L(N,0);
  int Max=0;
  int tmp=0;
  for (int i=0;i<N;++i){
    cin>>L[i];
    Max+=L[i];
    tmp=max(tmp,L[i]);
  }
  if (tmp<Max-tmp) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}
  
    
    

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

int main(){
  	int N, K, ans=0;
  	cin >> N >> K;
  	vector<int> h(N);
  	for(int i=0; i<N; i++){
    	cin >> h[i];
      	if(h[i]>=K){
        	ans++;
        }
    }
  
  	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640
#ifndef LOCAL
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#else
#include <iostream>
#include <iomanip> 
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <memory>
#include <cctype>
#include <cstring>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; }; sim > rge<c> range(c i, c j) { return rge<c>{i, j}; } sim > auto dud(c* x) -> decltype(cerr << *x, 0); sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; } eni(!=) cerr << boolalpha << i; ris; } eni(==) ris << range(begin(i), end(i)); } sim, class b dor(pair < b, c > d) { ris << "(" << d.first << ", " << d.second << ")"; } sim dor(rge<c> d) { *this << "["; for (auto it = d.b; it != d.e; ++it) *this << ", " + 2 * (it == d.b) << *it; ris << "]"; }
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

// #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> 

template<typename T> void setmax(T& x, T y) {x = max(x, y);}
template<typename T> void setmin(T& x, T y) {x = min(x, y);}
#define fix(a) fixed << setprecision(a)
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define rep(i, a, b) for (int i = int(a); i < int(b); i++)
#define all(V) V.begin(), V.end()
#define rall(V) V.rbegin(), V.rend()
#define len(V) (int)V.size()
#define ll long long
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define endl '\n'

void solve(){
  int n;
  cin >> n;
  int ans = 0;
  forn(i,n){
    int a;
    cin >> a;
    ans += (a - 1);
  }
  cout << ans;
}

int main() {
  ios::sync_with_stdio(false); 
  cin.tie(0); cout.tie(0);
  int t = 1;
  // cin >> t;
  forn(i, t){
    solve();
  }
}

/* 

1
1000000000000000000


*/

Measured memory_bytes: 3648
#include <iostream>
#include <cmath>
#include <iomanip>
#include <assert.h>
using namespace std;
int main(){
	long double a, b, c;
	cin >> a >> b >> c;
    long double eps = 1.0E-14;
    cout << ((sqrt(a) + sqrt(b) + eps < sqrt(c)) ? "Yes" : "No") <<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int n;
    cin>>n;
    int i,j;
    for(i=1;i<=9;i++){
        for(j=1;j<=9;j++){
            if(i*j==n){
                cout<<"Yes";
                return 0;
            }
        }
    }
    cout<<"No";
    return 0;
    }


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

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

typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//定数
#define INF 1000000000 //10^9:極めて大きい値,∞
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

vector<int> c(26);
vector<vector<int>> s(365 ,vector<int>(26));
vector<vector<int>> last(365 ,vector<int>(26));

int calc(int d){
    int k=10;
    int ret=1;
    ll maxv=-INF;
    rep(j,26){
        ll v=s[d][j]+c[j]*(d+1-last[d][j]);
        rep(i,k) v-=c[j]*k;
        if(v>maxv){
            maxv=v;
            ret=j+1;
        }
    }
    return ret;
}

int main(){
    int D;
    cin>>D;
    rep(i,26){ 
        cin>>c[i];
    }
    rep(d,D) rep(j,26) cin>>s[d][j];
    int t;
    int v=0;
    vector<int> kaisai_bi(26);
    int ans=18398+s[1][16];
    rep(j,26){
        if(j==16)continue;
        else if(j==0)ans-=c[j]*(2-1);
        else ans-=c[j]*(2-0);
    }
    rep(d,D) {
//        cin>>t;
        t=calc(d);
        cout<<t<<endl;
        t--;
        v+=s[d][t];
        kaisai_bi[t]=d+1;
        rep(j,26) last[d][j]=kaisai_bi[j];
        rep(j,26){ 
            v-=c[j]*(d+1-last[d][j]);
            }
    }
//    cout<<v<<endl;

    int m;
//    cin>>m;
m=0;
    rep(i,m){
        int dd,q;
        cin>>dd>>q;
        q--;
        int j=0;
        while(last[dd-1][j]!=dd || j>=26) j++;
        if(j==26){ 
            cout<<"error"<<endl;
            return 0;
        }
        v-=s[dd-1][j];
        for(int d=dd-1;d<D;d++){ 
            if(last[d][j]==dd){
                v+=c[j]*(d+1-last[d][j]);
                last[d][j]=(d==0? 0 : last[d-1][j]);
                v-=c[j]*(d+1-last[d][j]);
            }
            else{ 
                break;
            }
        }
        
        v+=s[dd-1][q];
        int before=last[dd-1][q];
        for(int d=dd-1;d<D;d++){ 
            if(last[d][q]==before){ 
                v+=c[q]*(d+1-last[d][q]);
                last[d][q]=dd;
                v-=c[q]*(d+1-last[d][q]);
            }
            else{ 
                break;
            }
        }
        cout<<v<<endl;
    }
    return 0;
}


Measured memory_bytes: 3732
ls=[]
for i in range(3):
    ls1=list(map(int,input().split()))
    ls.append(list(ls1))
    ls1.clear()
#print(ls)
N=int(input())
for i in range(N):
    b = int(input())
    for j in range(3):
        for l in range(3):
            if ls[l][j] == b:
                ls[l][j] = -1
flg = False
for i in range(3):
    if ls[i][0] == ls[i][1] == ls[i][2] == -1:
        print("Yes")
        flg = True
        break
    elif ls[0][i] == ls[1][i] == ls[2][i] == -1:
        print("Yes")
        flg = True
        break
    elif ls[0][0] == ls[1][1] == ls[2][2] == -1:
        print("Yes")
        flg = True
        break
    elif ls[0][2] == ls[1][1] == ls[2][0] == -1:
        print("Yes")
        flg = True
        break
if flg == False:
    print("No")


Measured memory_bytes: 62252
n = int(input())
lis = list(map(int, input().split(' ')))

ret = 0

for i in range(n):
  
  pair1 = max(lis)
  lis.remove(pair1)
  pair2 = max(lis)
  lis.remove(pair2)
  
  ret += pair2
  
print(ret)

Measured memory_bytes: 3060
#include <functional>
#include <algorithm>
#include <stdexcept>
#include <iostream>
#include <sstream>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <utility>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <cctype>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cmath>
#include <queue>
#include <stack>
#include <tuple>
#include <ctime>
#include <list>
#include <map>
#include <set>

#define REP(i,n) for(int i=0;i<(n);i++)
#define TR(i,x) for(__typeof(x.begin()) i=x.begin();i!=x.end();i++)
#define ALL(x) x.begin(),x.end()
#define SORT(x) sort(ALL(x))
#define CLEAR(x) memset(x,0,sizeof(x))
#define FILL(x,c) memset(x,c,sizeof(x))
#define SIZE(x) (int)(x).size()

#define MP make_pair
#define MT make_tuple
#define PB push_back
#define EB emplace_back

using namespace std;

typedef long long LL;
typedef pair<int,int> PII;

int main() {
    int K, T;
    cin >> K >> T;
    int a[110];
    REP(i, T) {
        scanf("%d", a + i);
    }
    int maxa = *max_element(a, a + T);
    cout << max(0, maxa * 2 - K - 1) << endl;
    return 0;
}



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

vector<ll> all(51), pate(51);

//{B, Lv.X-1, P, Lv.X-1, B}
ll dfs(int level, ll remain){
	if(level == 0){
		return 1;
	}
	
	ll ans = 0;
	
	//B
	if(remain >= 1){
		remain--;
	}
	//Lv.X-1
	if(remain >= 1){
		if(remain >= all[level - 1]){
			remain -= all[level - 1];
			ans += pate[level - 1];
		}else{
			ans += dfs(level - 1, remain);
			remain = 0;
		}
	}
	
	//P
	if(remain >= 1){
		remain--;
		ans++;
	}
	
	//Lv.X-1
	if(remain >= 1){
		if(remain >= all[level - 1]){
			remain -= all[level - 1];
			ans += pate[level - 1];
		}else{
			ans += dfs(level - 1, remain);
			remain = 0;
		}
	}
	
	//B
	if(remain >= 1){
		remain--;
	}
	
	return ans;
}

int main() {
	
	int n;
	ll x;
	cin >> n >> x;
	
	//dp
	all[0] = 1;
	pate[0] = 1;
	for(int i = 1; i < n; i++){
		all[i] = all[i - 1] * 2 + 3;
		pate[i] = pate[i - 1] * 2 + 1;
	}
	
	ll ans = dfs(n, x);
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 256
fn main() {
  use std::io::Read;
  let mut input = String::new();
  std::io::stdin().read_to_string(&mut input).unwrap();
  let mut tok = input.split_whitespace();
  let n : u32 = tok.next().unwrap().parse().unwrap();
  let k : u32 = tok.next().unwrap().parse().unwrap();
  println!("{}", k * (k-1).pow(n-1));
}


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

    vector<int> a(N);
	for(int i=0;i<N;++i)cin>>a[i];
    
    int cumsuml[110] = {};
    for(int i=0;i<N;++i) {
        cumsuml[i+1] = cumsuml[i] + a[i]; 
    }

    int cumsumr[110] = {};
    reverse(a.begin(), a.end());
    for(int i=0;i<N;++i) {
        cumsumr[i+1] = cumsumr[i] + a[i]; 
    }

    int res = abs(abs(cumsuml[1]) - abs(cumsumr[N-1]));

    for(int i=0;i<N;++i) {
        res = min(res, abs(abs(cumsuml[i]) - abs(cumsumr[N-i])));
    }
    cout << res << "\n";
}

Measured memory_bytes: 256
import java.util.Scanner;

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

		long N = scan.nextLong();
		long p = scan.nextLong();
		long ans = 0;
		for (long i = 0; i < N - 1; i++) {
			long q = scan.nextLong();
			ans += (p * q) % 1000000007;
			p = (p + q) % 1000000007;
		}
		System.out.println(ans % 1000000007);
	}
}

Measured memory_bytes: 48528
#include <iostream>
#include <algorithm>
#include <string>
#include  <queue>
#include <vector>
#include  <cstdio>
#include <cstring>
#include<map>
#include<set>
//#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define I(a) scanf("%d",&a)
#define I2(a,b) scanf("%d%d",&a,&b)
#define I3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define L(a) scanf("%lld",&a)
#define L2(a,b) scanf("%lld%lld",&a,&b)
#define L3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define PI(a) printf("%d",a)
#define PL(a) printf("%lld",a)
#define PT(t) printf("Case %d: ",t)
#define PB push_back
#define x first
#define y second
#define xx first.first
#define xy first.second
#define yx second.first
#define yy second.second
#define SC scanf
#define PC printf
#define NL printf("\n")
#define SET(a) memset(a,0,sizeof a)
#define SETR(a) memset(a,-1,sizeof a)
#define SZ(a) ((int)a.size())-1
#define f(i,a,b) for(int i=a;i<=b; i++)
#define fr(i,a,b) for(int i=a;i<=b; i++)
#define frr(i,a,b) for(int i=a;i>=b; i--)
#define frv(i,a)  for(int i=0;i<a.size();i++)
#define pi 2.0*acos(0.0)
#define R(a) freopen(a, "r", stdin);
#define W(a) freopen(a, "w", stdout);
#define CB(x) __builtin_popcount(x)
#define STN(a) stringtonumber<ll>(a)
#define lol printf("BUG\n")
#define Endl "\n"
#define mk make_pair
using namespace std;
template <class T> inline T BM(T p, T e, T M)
{
    ll ret = 1;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret * p) % M;
        p = (p * p) % M;
    }
    return (T)ret;
}
template <class T> inline T mul(T p, T e, T M)
{
    ll ret = 0;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret + p) ;
        p = (p + p) ;
        if(ret>=M)ret-=M;
        if(p>=M)p-=M;
    }
    return (T)ret;
}
template <class T> inline T gcd(T a, T b)
{
    if(b == 0)return a;
    return gcd(b, a % b);
}
template <class T> inline T mdINV(T a, T M)
{
    return BM(a, M - 2, M);
}
template <class T> inline T PW(T p, T e)
{
    ll ret = 1;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret * p);
        p = (p * p);
    }
    return (T)ret;
}
 
 
template <class T>bool ISLEFT(T a, T b, T c)
{
    if(((a.xx - b.xx) * (b.yy - c.yy) - (b.xx - c.xx) * (a.yy - b.yy)) < 0.0)return 1;  //Uporer dike //A,b,c, x okkher ordera sorted
    else return 0;
}
 

#define  mx 200004
#define base 193ll
 
typedef pair<int,int >P;
//////////////////////////
////////////////////////
#define F(i,a,b) for(int i=a;i<b; i++)
#define LL long long
#define MX  200007
#define md 998244353ll
///////////////////////////
///////////////////////////
///

int main(){
    string s;
    cin>>s;
    if(s=="ABC")cout<<"ARC"<<endl;
    else cout<<"ABC"<<endl;
    return 0;
}

Measured memory_bytes: 3560
import std.stdio;
import std.array;
import std.conv;

struct Data {
	int id, score;
	int opCmp(ref const Data s) const{
		return (score == s.score ? id - s.id : s.score - score);
	}
}

void main(){
	int m, sum;
	string[] str;
	while (readf("%d\n", &m), m) {
		Data data[];
		foreach (i; 0..m) {
			int[] n;
			str = split(readln());
			foreach (s; str) n ~= to!int(s);
			sum = 0;
			for (int j = 1, r = 0; r < 10; r++) {
				if (n[j] == 10) {
					sum += 10 + n[j+1] + n[j+2];
					j++;
				} else if (n[j] + n[j+1] == 10) {
					sum += 10 + n[j+2];
					j+=2;
				} else {
					sum += n[j] + n[j+1];
					j+=2;
				}
			}
			data ~= Data(n[0], sum);
		}
		foreach (i; data.sort) writeln(i.id, " ", i.score);
	}
}

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

int main(){
    int a, b;
    cin >> a >> b;
    string aa, bb;
    aa = std::to_string(a);
    bb = std::to_string(b);
  	string aaa, bbb;
    for (int i=0;i<b;i++){
        aaa+=aa;
    }
    for (int i=0;i<a;i++){
        bbb+=bb;
    }
    vector<string> vc(2);
  	vc.at(0) = aaa;
  	vc.at(1) = bbb;
    sort(vc.begin(), vc.end());
    cout << vc.at(0) << endl;
}

Measured memory_bytes: 256
#include<map>
#include<set>
#include<list>
#include<cmath>
#include<queue>
#include<stack>
#include<cstdio>
#include<string>
#include<vector>
#include<complex>
#include<cstdlib>
#include<cstring>
#include<numeric>
#include<sstream>
#include<iostream>
#include<algorithm>
#include<functional>

#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,b,n) for(int i=b;i<n;i++)

using namespace std;

typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;

const int INF=1<<29;
const double EPS=1e-9;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};
int k=10000;
int n;

void countingsort(int* A,int *B){
	int C[k+1];
	for(int i = 0;i <=k;i++){
		C[i]=0;
	}
	for(int i = 0;i <n;i++){
		C[A[i]]++;
	}
	C[0]--;
	//C[i]??????i??\????????°???????????°????¨???????????????????
	for(int i =1;i <=k;i++){
		C[i]=C[i]+C[i-1];
	}
	for(int j = n-1;j >=0;j--){
		B[C[A[j]]] =A[j];
		C[A[j]]--;
	}
}


int main(){
	cin>>n;
	int *A;
	int *B;
	A =new int[n];
	B =new int[n];
	memset(A,0,sizeof(A));
	memset(B,0,sizeof(B));
	rep(i,n)cin>>A[i];
	countingsort(A,B);
	for(int i = 0;i <n;i++){
		if(i)cout<<" ";
		cout<<B[i];
	}
	cout<<endl;
	delete[] A;
	delete[] B;
	return 0;
}

Measured memory_bytes: 16768
#include <stdio.h>

int main()
{
	int N;
	static int A[200000];
	scanf("%d", &N);
	for (int i = 0; i < N; i++) {
		scanf("%d", &A[i]);
	}

	int max1 = -1;
	int ind1 = -1;
	int max2 = -1;
	for (int i = 0; i < N; i++) {
		if (A[i] > max1) {
			max2 = max1;
			max1 = A[i];
			ind1 = i;
		}
		else if (A[i] > max2) {
			max2 = A[i];
		}
	}

	for (int i = 0; i < N; i++) {
		if (i == ind1) {
			printf("%d\n", max2);
		}
		else {
			printf("%d\n", max1);
		}
	}

	return 0;
}


Measured memory_bytes: 2304
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
template <class T> vector<T> make_vec(size_t a, T val) {
    return vector<T>(a, val);
}
template <class... Ts> auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec(ts...))>(a, make_vec(ts...));
}
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using Graph = vector<vector<int>>;
template <typename T> struct edge {
    int to;
    T cost;
    edge(int t, T c) : to(t), cost(c) {}
};
template <typename T> using WGraph = vector<vector<edge<T>>>;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

int main() {
    int x;
    cin >> x;
    cout << 1 - x << endl;
}

Measured memory_bytes: 3572
#include <iostream>
#include <algorithm>
#include <bitset>
#include <string>
#include <fstream>
#include <cmath>
#include <climits>
#include <vector>
#include <unordered_map>
using namespace std;

#define ll long long

int main()
{
	ll k, n;
	cin >> k >> n;
	
	vector<ll> a(n);
	vector<ll> b(n);
	ll sum = 0;
	
	for(ll i = 0; i < n; i++)
	{
		cin >> a[i];
		
		if(i >= 1)
		{
			sum += a[i] - a[i - 1];
			b.push_back(a[i] - a[i - 1]);
		}
	}
	
	sum += (a[0] - a[n - 1]) % k + k;
	b.push_back((a[0] - a[n - 1]) % k + k);
	
	ll minCost = LLONG_MAX;
	
	for(ll i = 0; i < b.size(); i++)
	{
		minCost = min(minCost, sum - b[i]);
	}
	
	cout << minCost;
	
	return 0;
}

Measured memory_bytes: 6400
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define re(i,n) for(ll i=0;i<n;++i)
#define ocut cout
#define ouct cout
#define itn int
int main(void){
  int n;
  cin >> n;
  int a[n];
  for(int i=0;i<n;i++){
    cin >> a[i];
  }
  int ans,b=99999999;
  for(int i=0;i<=100;i++){
    ans=0;
    for(int j=0;j<n;j++){
      ans=ans+(a[j]-i)*(a[j]-i);
    }
    b=min(ans,b);
  }
  cout << b;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int n;
	cin >> n;
	int a[n];
	int count=0;
	for(int i=0 ; i<n ; i++){
		cin >> a[i];
		if (a[i]<0) count++;
	}
	long long all=0;
	if (count%2==0){
		for (int i=0;i<n;i++){
			if (a[i]<0) a[i]=a[i]*-1;
			all+=a[i];
		}
		cout << all << endl;
	} else {
		int min=1000000000;
		for(int i=0;i<n;i++){
			if (a[i]<0) a[i]=a[i]*-1;
			if (a[i]<min) min=a[i];
			all+=a[i];
		}
		all=all-min*2;
		cout << all << endl;
	}
	return 0;
}


Measured memory_bytes: 640
N,M = [int(x) for x in input().split()]
List = [list(map(int,input().split())) for i in range(M)]
left = List[0][0]
right = List[0][1]
for j in range(M-1):

    l = List[j+1][0]
    r = List[j+1][1]

    if l > left:
        left = l
    if r < right:
        right = r
    if right < left:
        print(0)
        break
else:
    print(right-left+1)

Measured memory_bytes: 27332
/**
 * Sergey Kopeliovich (burunduk30@gmail.com)
 */

#include <bits/stdc++.h>

using namespace std;

#define forn(i, n) for (int i = 0; i < (int)(n); i++)

typedef long long ll;

const int MOD = 998244353;
void add( int &a, int b ) { if ((a += b) >= MOD) a -= MOD; }
int mul( int a, int b ) { return (ll)a * b % MOD; }

const int N = 2e6 + 3;
int inv[N];

struct C {
	int n, k, r;
	C() {}
	C( int n, int k, int r = 1 ) : n(n), k(k), r(r) { }
	void dn() {
		r = mul(r, ++n);
		r = mul(r, inv[n - k]);
	}
	void dk() {
		r = mul(r, n - k++);
		r = mul(r, inv[k]);
	}
};

int main() {
	inv[1] = 1;
	for (int i = 2; i < N; i++) 
		inv[i] = ((ll)(MOD - inv[MOD % i]) * (MOD / i)) % MOD;

	ios_base::sync_with_stdio(false), cin.tie(0);
	int tmp1, tmp2;
	string sa, sb, sc, sd;
	cin >> tmp1 >> tmp2 >> sa >> sb >> sc >> sd;
	auto ok = [&]( char c ) {
		return c == '1';
	};
	auto get = [&]( string &s ) {
		return count_if(s.begin(), s.end(), ok);
	};

	int res = 0;
	forn(_, 2) {
		int n = sa.size(), m = sc.size();
		int na = get(sa), nb = get(sb);
		vector<int> F1(n), F2(n);
		forn(__, 2) {
			int cnt_a = 0, cnt_b = 0, nc = get(sc);
			C c2(cnt_a + cnt_b + nc - 1, nc - 1);
			forn(i, n) {
				if (ok(sa[i]) || ok(sb[i])) {
					F1[i] = c2.r;
					if (ok(sa[i])) c2.dn(), cnt_a++;
					if (ok(sb[i])) c2.dn(), cnt_b++;
				}
			}
			swap(sc, sd), swap(F1, F2);
			reverse(sa.begin(), sa.end());
			reverse(sb.begin(), sb.end());
		}
		reverse(F2.begin(), F2.end());
		int last = -1;
		for (int i = n - 2; i >= 0; i--) {
			add(F2[i], F2[i + 1]);
			if (ok(sa[i + 1]) + ok(sb[i + 1]) == 2)
				add(F2[i], F2[i + 1]);
		}
		forn(i, n)
			if (ok(sa[i]) || ok(sb[i]))
				add(res, mul(mul(F1[i], F2[i]), ok(sa[i]) + ok(sb[i])));
		swap(sa, sc), swap(sb, sd);
	}
	printf("%d\n", max(res, 1));
}


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

typedef long long ll;
typedef pair<int,int> pii;

long long MOD = 1000000000 + 7;

int main(){
  cout << setprecision(10);
  ll N,K;
  cin >> N >> K;

  if(N%K == 0){
    cout << 0 << endl;
    return 0;
  }

  ll x1 = N % K;
  ll x2 = K - x1;
  cout << min(x1,x2) << endl;

}


Measured memory_bytes: 3600