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

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<=(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define Eback(s) s.erase(s.end()-1,s.end())
#define rev(v) reverse(all(v))
#define minvec(v) *min_element(all(v))
#define maxvec(v) *max_element(all(v))
#define sumvec(v) accumulate(all(v),0LL)
#define mapmin(v) v.rbegin()->first
#define mapmax(v) v.begin()->first
#define pb push_back
#define pf push_front
#define m_p make_pair
#define DOUBLE fixed << setprecision(15)
#define OK cerr<<"OK\n"
#define OK1 cerr<<"OK1\n"
#define OK2 cerr<<"OK2\n"
#define SIZE(s) (int)s.size()
//#define INF ((1LL<<62)-(1LL<<31))
#define INF 1e18
#define zero(x,n) setw(x) << setfill('0') << n
#define endl '\n'

typedef long long ll;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long> vll;
typedef vector<vll> vvll;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<string> vs;

typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;
typedef vector<pair<ll,ll>> vpll;

const double pi = acos(-1.0);
const ll mod=1000000007;
const ll mod2=998244353;

template<class A, class B>
ostream& operator<<(ostream& ost, const pair<A, B>&p) {
	ost << "{" << p.first << ", " << p.second << "} ";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost, const vector<T>&v) {
	ost << "{";
	for (int i = 0; i<(int)v.size(); i++) {
		if (i)ost << " ";
		ost << v[i];
	}
	ost << "} \n";
	return ost;
}

template<class A, class B>
ostream& operator<<(ostream& ost, const map<A, B>&v) {
	ost << "{";
	for (auto p:v) {
		ost << "{" << p.first << ", " << p.second << "} ";
	}
	ost << "} ";
	return ost;
}

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;}

void YES(bool b) {cout << ((b)?"YES\n":"NO\n");}
void Yes(bool b) {cout << ((b)?"Yes\n":"No\n");}
void yes(bool b) {cout << ((b)?"yes\n":"no\n");}
void Yay(bool b) {cout << ((b)?"Yay!\n":":(\n");}

void out(){cout << "\n";}
template<class T,class... Args>
void out(const T &x,const Args &... args){
	cout << x << " ";
	out(args...);
}

ll powmod(ll a,ll b){ll c=1; while(b>0){ if(b&1){ c=a*c%mod; } a=a*a%mod; b>>=1; } return c;}
ll gcd(ll x, ll y) {return __gcd(x,y);}
ll lcm(ll x, ll y) {return x/__gcd(x,y)*y;}

int main()
{
	ll n;
	cin >> n;
	vll a(n+1);
	rep(i,n) cin >> a[i+1];
	vll b(n+1);
	for(ll i=n;i>=1;i--){
		ll cnt=0;
		for(ll j=i*2;j<=n;j+=i){
			cnt+=b[j];
		}
		if(cnt%2!=a[i]) b[i]++;
	}
	vll ans;
	REP(i,1,n){
		if(b[i]) ans.pb(i);
	}
	cout << ans.size() << endl;
	rep(i,SIZE(ans)) cout << ans[i] << (i==SIZE(ans)-1?"\n":" ");
	return 0;
}

Measured memory_bytes: 4980
#include <bits/stdc++.h>
#define INF 1e9
using namespace std;

#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(a)  (a).begin(),(a).end()

template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}
typedef long long ll;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}


int main() {
    int N;
    cin >> N;
    vector<double> a(N);
    REP(i,N) cin >> a[i];

    double av = accumulate(ALL(a),double(0))/N;
    int ans  = 0;
    double shortest = INF;
    REP(i,N) {
        if (chmin(shortest,abs(av-a[i]))) {
            ans = i;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
main(){
    int N;
    cin >> N;
    double sum = 0;
    rep(i,0,N){
        double a;
        string s;
        cin >> a >> s;
        if(s == "JPY")sum += a;
        else sum += a * 380000;
    }
    printf("%.9lf\n",sum);
}

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


public class Main {
	private	static	final	int				CHAR_DIFF = 'A' - 'a';
	private	static			BufferedReader	br        = null;

	static {
		br   = new BufferedReader(new InputStreamReader(System.in));
	}

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		String	strStdin = null;

		while((strStdin = parseStdin()) != null) {
			char[]	aStdin = strStdin.toCharArray();
			for (int n = 0; n < aStdin.length; n++) {
				if ('a' <= aStdin[n] && aStdin[n] <= 'z') {
					aStdin[n] += CHAR_DIFF;
				}
			}
			System.out.println(aStdin);
		}
	}

	private static String parseStdin() {
		String	strNum = null;

		try {
			String line = br.readLine();
			if (line != null) {
				if (!line.isEmpty()) {
					strNum = line;
				}
			}
		}
		catch (IOException e) {}

		return strNum;
	}
}

Measured memory_bytes: 17008
#　%%まず500円を持ちうる個数を確認する
X = int(input())
count1 = int(X/500) #500円の枚数
#print(count1)

# %%　500円玉の合計額を引いた値から、5円玉を確認する
deducation = X - count1 * 500

count2 = int(deducation / 5)
#print(count2)

# %%　スコアを計算する
uresisa = count1 * 1000 + count2 * 5
print(uresisa)

# %%


Measured memory_bytes: 2940
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
using namespace std;

int N;
string T;

int z_algorithm(int start) {
    string S = T.substr(start);
    vector<int> A(S.size());
    A[0] = (int) S.size();
    int j = 0;
    for (int i = 1; i < S.size();) {
        while (i + j < S.size() && S[j] == S[i + j]) j++;
        A[i] = j;
        if (j == 0) {
            i++;
            continue;
        }
        int k = 1;
        while ( i + k < S.size() && k + A[k] < j) {
            A[i + k] = A[k];
            k++;
        }
        i += k; j -= k;
    }
    int ret = 0;
    for (int i = 0; i < S.size(); i++) {
        ret = max(ret, min(A[i], i));
    }
    return ret;
}

int main() {
    cin >> N >> T;
    int ans = 0;
    for (int s = 0; s < N; s++) {
        ans = max(ans, z_algorithm(s));
    }
    cout << ans << endl;
}



Measured memory_bytes: 256
#include<stdio.h>
 int main(void)
{

 int i,n;
  int number;
  long long int sum=0;
  int min=0; 
  int max=0;
    scanf("%d",&n);
    for(i=0;i<n;i++)
  { 
     scanf("%d",&number); 
    if(i==0)
  { 
  min = number; 
  max = number;
  } 
  if(number<min) min = number;
   if(number>max) max = number; 
     sum += number;
     } 
   printf("%d %d %lld\n",min,max,sum);
     return 0;
 }
 

Measured memory_bytes: 600
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main {
    
    public static void main(String[] args) {
        // input data
        List<String> input = inputLines();
        
        // get input
        int length = Integer.valueOf(input.get(0));
        String[] numbersString = input.get(1).split(" ");
        int[] numbers = new int[length];
        for (int i = 0; i < length; i++) {
            numbers[i] = Integer.valueOf(numbersString[i]);
        }
        int[] A = numbers;

        // main logic
        for (int i = 1; i <= A.length-1; i++) {
            output(A);
            int key = A[i];
            /* insert A[i] into the sorted sequence A[0,...,j-1] */
            int j = i - 1;
            while (j >= 0 && A[j] > key) {
                A[j+1] = A[j];
                j--;
            }
            A[j+1] = key;
        }
        output(A);

    }

    private static List<String> mocups() {
        List<String> input = Arrays.asList(
                "6",
                "5 2 4 6 1 3"
                );
        return input;
    }

    /** output data */
    private static void output(int[] o) {
        System.out.println(Arrays.toString(o).replaceAll("[\\[,\\]]", ""));
    }

    /** input data */
    private static List<String> inputLines() {
        Scanner in = new Scanner(System.in);
        List<String> input = new ArrayList<String>();
        while(in.hasNext()) {
            String buf = in.nextLine();
            input.add(buf);
        }
        in.close();
        return input;
    }

}

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

int main() {
  ll A, B;
  cin >> A >> B;
  cout << (A % 2 == 1 && B % 2 == 1 ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(100001)

N, M = map(int, input().split())

dp = [0] * N
g = [[] for _ in range(N)]

for _ in range(M):
    x, y = map(int, input().split())
    x -= 1
    y -= 1
    g[x].append(y)

def dfs(node):
    if dp[node] > 0:
        return dp[node]
    mx = 0
    for i in g[node]:
        a = dfs(i) + 1
        if mx < a:
            mx = a
    dp[node] = mx
    return mx

ans = 0
for i in range(N):
    if dp[i] == 0:
        ans = max(ans, dfs(i))

print(ans)

Measured memory_bytes: 59008
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define repi(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define repdi(i,a,b) for(ll i=(a)-1;i>=(b);--i)
#define repd(i,a) repdi(i,a,0)
#define itr(it,a) for( auto it = (a).begin(); it != (a).end(); ++it )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

using ll = long long;
using P = std::pair<ll, ll>;

constexpr ll INF = 1ll<<60;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

template<class S, class T>
std::ostream& operator<< ( std::ostream& out, const std::pair<S,T>& a )
{ std::cout << '(' << a.first << ", " << a.second << ')'; return out; }

template<class T>
std::ostream &operator<< ( std::ostream& out, const std::vector<T>& a )
{ std::cout << '['; rep( i, a.size() ){ std::cout << a[i]; if( i != a.size()-1 ) std::cout << ", "; } std::cout << ']'; return out; }

ll N, K;
ll A[200010], F[200010];
ll S[200010];

int main()
{
  std::cin >> N >> K;

  rep( i, N )
    std::cin >> A[i];

  rep( i, N )
    std::cin >> F[i];

  std::sort( A, A+N, std::greater<ll>() );
  std::sort( F, F+N );

  ll ub = 0;

  rep( i, N )
    chmax( ub, A[i]*F[i] );

  ll ng = -1, ok = ub+1;

  while( ok-ng > 1 ) {
    ll mid = (ng+ok)/2;

    auto C = [&]( ll x ) {
      ll sum = 0;

      rep( i, N )
        sum += std::max( A[i]-x/F[i], 0ll );

      return sum <= K;
    };

    (C(mid) ? ok : ng) = mid;
  }

  std::cout << ok << std::endl;

  return 0;
}

Measured memory_bytes: 3328
#include <algorithm>
#include <cstdio>
#include <cstring>

const int MaxN = 200000;

int K, N;
int A[MaxN + 5];

int main() {
  scanf("%d %d", &K, &N);
  for (int i = 1; i <= N; ++i) scanf("%d", &A[i]);
  int mx = 0;
  for (int i = 2; i <= N; ++i) mx = std::max(mx, A[i] - A[i - 1]);
  mx = std::max(mx, A[1] + K - A[N]);
  printf("%d\n", K - mx);
  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define GET_MACRO(_1,_2,_3,_4,_5,_6,NAME,...) NAME
#define pr(...) GET_MACRO(__VA_ARGS__,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__)
#define Pr(a) (#a)<<"="<<(a)<<" "
#define pr1(a) cerr<<Pr(a)<<endl;
#define pr2(a,b) cerr<<Pr(a)<<Pr(b)<<endl;
#define pr3(a,b,c) cerr<<Pr(a)<<Pr(b)<<Pr(c)<<endl;
#define pr4(a,b,c,d) cerr<<Pr(a)<<Pr(b)<<Pr(c)<<Pr(d)<<endl;
#define pr5(a,b,c,d,e) cerr<<Pr(a)<<Pr(b)<<Pr(c)<<Pr(d)<<Pr(e)<<endl;
#define pr6(a,b,c,d,e,f) cerr<<Pr(a)<<Pr(b)<<Pr(c)<<Pr(d)<<Pr(e)<<Pr(f)<<endl;
#define int long long
#define double long double
using namespace std;
const int N = 100010;
const int INF = 1LL<<55;
const int mod = (1e9)+7;
const double EPS = 1e-8;
const double PI = 6.0 * asin(0.5);
typedef pair<int,int> P;
typedef long long ll;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
ostream& operator<<(ostream& o,P p){return o<<"("<<p.first<<","<<p.second<<")";}
istream& operator>>(istream& i,P &p){return i>>p.first>>p.second;}
ostream& operator<<(ostream& o,vector<auto> &a){int i=0;for(auto t:a)o<<(i++?" ":"")<<t;return o;}
istream& operator>>(istream& i,vector<auto> &a){for(auto &t:a)i>>t;return i;}
void prArr(auto a,string s=" "){int i=0;for(auto t:a)cout<<(i++?s:"")<<t;cout<<endl;}


signed main(){
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int A,B,C;
  cin>>A>>B>>C;

  int X,Y;
  cin>>X>>Y;

  int ans = INF;
  for(int i=0;i<1000000;i++){
    int ab = i;
    int a = max(0LL, X - ab/2);
    int b = max(0LL, Y - ab/2);
    int cost = ab * C + a * A + b * B;
    Min(ans,cost);    
  }

  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 256
let dbg = Printf.printf "[debug]%s"

let id = fun x -> x
let tuple2 x y = (x,y)

let (++) n m =
  let rec aux i =
    if i = m then [m]
    else i :: aux (i+1) in
  if n > m then [] else aux n

let (++^) n m = n ++ (m-1)

let scanf fmt f = Scanf.sscanf (read_line ()) fmt f

let scanfs n fmt f =
  List.map (fun _ -> scanf fmt f) (0++^n)

let scan_matrix n m e conv =
  let arr = Array.make_matrix n m e in
  Array.iteri (fun i line ->
      let s = Scanf.Scanning.from_string @@ read_line () in
      Array.iteri (fun j _ ->
          arr.(i).(j) <- Scanf.bscanf s " %s" conv;
        ) line) arr; arr

let between n x m = n <= x && x < m

let (n, w) = scanf "%d %d" tuple2
let items = Array.of_list @@ scanfs n "%d %d" tuple2
let memo = Array.make_matrix (n+1) (w+1) (-1)

let () =
  memo.(0).(0) <- 0;
  Array.iteri (fun i (v0, w0) ->
      List.iter (fun j ->
          if j - w0 >= 0 && memo.(i).(j-w0) >= 0 then
            memo.(i+1).(j) <- max memo.(i).(j) (memo.(i).(j-w0) + v0)
          else
            memo.(i+1).(j) <- memo.(i).(j)
        ) (0++w)) items;
  Array.fold_left max 0 memo.(n)
  |> Printf.printf "%d\n"



Measured memory_bytes: 13932
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll a[404],f[404][404],n,sum[404]; 
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++)
			f[i][j]=1e17;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		f[i][i]=0;
		sum[i]=sum[i-1]+a[i];
	}
	for(int i=1;i<n;i++)
		for(int j=1;j<=n-i;j++)
			for(int k=j;k<j+i;k++)
				f[j][j+i]=min(f[j][j+i],f[j][k]+f[k+1][j+i]+sum[j+i]-sum[j-1]);
	cout<<f[1][n]<<endl;
	return 0;
}


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


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

    if (s.find("A") != string::npos && s.find("B") != string::npos) {
        cout << "Yes" << endl;
    }
    else cout << "No" << endl;


    return 0;
}



Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int n;
  scanf("%d",&n);
  int s=0;
  int m=n;
  while(m>0){
    s+=m%10;
    m=(m-m%10)/10;
  }
  if(n%s==0){
    printf("Yes\n");
  }else{
    printf("No\n");
  }
  return 0;
}

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

using namespace std;

void hawawa(){
	int n, k;
	cin >> n >> k;
	vector<long long> x(n);
	for (auto&& i : x) {
		cin >> i;
	}
	long long ans = numeric_limits<long long>::max();
	for (int i = 0; i <= n - k; i++) {
		ans = min(min(abs(min(0LL, x[i])), max(0LL, x[i + k - 1])) * 2 + max(abs(min(0LL, x[i])), max(0LL, x[i + k - 1])), ans);
	}
	cout << ans << "\n";
}

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


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

#define fi first
#define se second

const int N = 200200;
const long long mod = 1e9 + 7;

using namespace std;

int n;
int d[N];

void add(int &x, int y)
{
        x += y;
        if(x >= mod){
                x -= mod;
        }
}

int main()
{
        //freopen("input.txt", "r", stdin);
        //freopen("output.txt", "w", stdout);
        ios_base::sync_with_stdio(0);

        cin >> n;
        int res = 1, f = 0;
        for(int i = 1, y = 0; i <= n; i++){
                int x;
                cin >> x;
                if(x == y){
                        continue;
                }
                add(d[x], f);
                f = d[x];
                add(d[x], 1);
                y = x;
        }
        add(res, f);
        cout << res << "\n";
}


Measured memory_bytes: 1024
s = input().split(" ");
a = int(s[0]);
b = int(s[1]);
c = int(s[2]);
d = int(s[3]);
e = int(s[4]);
f = int(s[5]);
ans = 0;
ans_w = 100*a;
ans_s = 0;
for i in range(0,f,100*a) :
	for j in range(0,f,100*b) :
		#if 100 * a * i + 100 * b * j <= f :
			for k in range(0, f - i - j,c) :
				for l in range(0, f - i - j,d) :
					if i != 0 or j != 0 or k != 0 or l != 0 :
						#print(i,j,k,l,100*( k + l )//( i + j + k + l ));
						if i+j+k+l <= f and  k + l <= e * ( i + j )//100 :
							if 100*( k + l )/( i + j + k + l ) > ans :
								ans = 100 *( k + l )/( i + j + k + l );
								ans_w = i + j;
								ans_s = k + l;
print(ans_w+ans_s,ans_s);

Measured memory_bytes: 3064
/**
DufauX-XuafuD
**/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define reset(x) memset(x,-1,sizeof(x))
#define CheckBit(a,b) (a&(1ll<<b))
#define SetBit(a,b) a=(a|(1ll<<b))
#define UnSetBit(a,b) a=(a&(~(1ll<<b)))
#define maxx 10000006
#define PI 2*acos(0.0)
const long long INF = 2000000000000000000LL;	// 2e18
const int inf = 0x3f3f3f3f;	// 1061109567
const long double EPS = 1e-9;
//bitset<maxx/2>vis;
//bitset<maxx>pr;
//int mobi[maxx+10];
//vector<ll>prime;
//void sieve(){
//    ll x=maxx/2, y=sqrt(maxx)/2;
//    for(ll i=1;i<=y;i++){
//        if(vis[i]==0){
//            for(ll j=(i*(i+1)*2);j<x;j+=(2*i)+1)
//                vis[j]=1;
//        }
//    }
//    prime.push_back(2);
//    for(ll i=3;i<maxx;i+=2)
//        if(vis[i/2]==0)
//        prime.push_back(i);
//}
//void generate_mobius()
//{
//    for(int i=0;i<maxx;i++)mobi[i]=1;
//    for(int i=2;i<maxx;i++){
//        if(!pr[i]){
//            mobi[i]*=-1;
//            for(int j=i+i;j<maxx;j+=i){
//                pr[j]=1;
//                mobi[j]*=(j%(i*i)?-1:0);
//            }
//        }
//    }
//}
//bool isprime(ll a)
//{
//    if(a==1)return false;
//    if(a==2)return true;
//    if(a%2==0)return false;
//    for(ll i=0;i<prime.size() && prime[i]*prime[i]<=a;i++)
//        if(a%prime[i]==0)return false;
//    return true;
//}
/* Calculate ( a*b ) %c */
inline ll mulmod(ll a, ll b, ll c) {
    ll ret = 0 , cur = a % c ;
    while(b) { if(b%2) ret=(ret+cur)%c; cur=(cur<<1)%c; b=b>>1; }
    return ret%c;
}
//Calculate (b^p)%m || modular inverse: b^-1 = bigmod(b, m-2, m)
inline ll bigmod(ll b, ll p, ll m){
    ll ret = 1, cur = b % m;
    while(p) { if(p&1) ret=(ret*cur)%m; cur=(cur*cur)%m; p=p>>1; }
    return ret;
}
inline ll modulo(ll a,ll b,ll c) { //Same as big mod, use for numbers over 1e10
    ll ret = 1 , cur = a%c ;
    while(b) { if(b%2) ret=mulmod(ret,cur,c); cur=mulmod(cur,cur,c); b=b>>1; }
    return ret%c ;
}
inline ll power(ll b, ll p){
    ll ret = 1, cur = b;
    while(p) { if(p&1) ret=(ret*cur); cur=(cur*cur); p=p>>1; }
    return ret;
}
ll lcm(ll a,ll b)
{
    return (a/__gcd(a,b))*b;
}
ll gcd(ll a,ll b)
{
    return __gcd(a,b);
}
map<ll,ll>maps;
ll arr[100005];
void Dufaux()
{
    ll n;
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>arr[i];
    }
    ll p=1;
    ll cnt=0;
    while(true){
        if(maps[p]){
            cout<<"-1"<<endl;
            return;
        }
        cnt++;
        maps[p]=1;
        p=arr[p];
        if(p==2){
            cout<<cnt<<endl;
            return;
        }
    }
}
int main()
{
    FastIO;
	///sieve();
	///generate_mobius();
	int test=1;
	while(test--){
        Dufaux();
	}
	return 0;
}






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

int getCoin(int b,int r,int g,int c){
  int sum=100;
  sum+=b*5*13;
  sum+=r*3*13;
  sum+=g*7;
  sum+=c*2;
  sum+=b*15;
  sum+=r*15;
  return sum;
}

int getLostcoin(int b,int r,int s, int t){
  int sum=0;
  sum=(t-b*5-r*3-s)*3;
  return sum;
}
int main(){
  int b,r,g,c,s,t,gc,lc;
  while(1){
    cin>>b>>r>>g>>c>>s>>t;
    if(b==0 && r==0 && g==0 && c==0 && s==0 && t==0) break;
    gc=getCoin(b,r,g,c);
    lc=getLostcoin(b,r,s,t);
    cout<<gc-lc<<endl;
  }
  return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<tuple>
#include<algorithm>
#include<cmath>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); ++i) 

int main() {
	int r;
	cin >> r;
	int rs = r * r;
	cout << rs << endl;

	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;
const ll INF = 1001001001;

int main(){
  int n; cin >> n;
  vector<ll> a(n);
  ll w = 1e18;
  ll tisa=1;
  ll ans;
  bool fl = true;
  double keta = 0;
  double kk = 0;
  rep(i,n){
    cin >> a[i];
    if(a[i]==0){
      fl = false;
      ans = 0;
      break;
    }
    keta = log10(a[i]);
    kk += keta;
    if(kk > 18){
      fl = false;
      ans = -1;
    }
  }
  
  if(fl){
    rep(i,n){
      tisa *= a[i];
      
      if(tisa > w){
        fl = false;
        ans = -1;
        break;
      }
      
    }
  }
  if(fl){ans = tisa;}
  cout << ans << endl;
}

Measured memory_bytes: 4036
#include<iostream>
using namespace std;
int main(){
    int n;
    cin >> n;
    int ans = 0; 
    for(int i=1; i<=n;i++){
        int x;
        cin >> x;
        if(x%2==1 && i%2==1)
            ans++;
    }
    cout<<ans;
    return 0; 
}

Measured memory_bytes: 3616
#include <stdio.h>

int main(void){
	int t,j,sa,shi,h;
	int ans;
	
	scanf("%d %d %d %d %d",&t,&j,&sa,&shi,&h);
	if(t<40){
		t=40;
	}
	if(j<40){
		j=40;
	}
	if(sa<40){
		sa=40;
	}
	if(shi<40){
		shi=40;
	}
	if(h<40){
		h=40;
	}
	
	ans=(t+j+sa+shi+h)/5;
	
	printf("%d\n",ans);
	
	
	
	
	
	
	return 0;
}

Measured memory_bytes: 1028
#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++)
#define _GLIBCXX_DEBUG

template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}

template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}

const int max_n = 200010;
int n, a[max_n];
typedef long long ll;

int main(){
    cin >> n;
    rep(i, n) cin >> a[i];
    ll ans = 0, mymax = a[0];

    rep2(i, 1, n){
        if(a[i] < mymax) {
            ans += mymax - a[i];
        }else{
            mymax = a[i];
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
#include <stdio.h>
#include <ios>     
#include <iomanip> 

using namespace std;
#define inputInt(a) int a; cin >> a; 
#define inputInt2(a,b) int a; int b; cin >> a >> b; 
#define inputInt3(a,b,c) int a; int b; int c; cin >> a >> b >> c;
#define inputLong(a) long a;cin >> a; 
#define inputIntArray(a,N) int a[N];for(int i=0;i<N;i++){cin >> a[i];}
#define inputLongArray(a,N) long a[N];for(int i=0;i<N;i++){cin >> a[i];}
#define inputIntArray2(a,b,N) int a[N]; int b[N]; for(int i=0;i<N;i++){cin >> a[i] >> b[i];}
#define output(answer) cout << answer << endl;
#define fN(i,N)    for(int i=0; i<N; i++)
#define fSE(i,s,e) for(int i=s; i<=e; i++)
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()
{
  //input
  int A, B;
  cin >> A >> B;
  
  //main  

  // output
  if( (B-A)%2 == 0){
    cout << (A+B)/2 << endl;
  }else{
    cout <<  "IMPOSSIBLE" << endl;
  }
  
  return 0;
}

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

signed main() {
	string s;
	cin >> s;
	rep(i, s.size()) {
		switch(s[i]) {
			case 'A':
			s[i] = 'T';
			break;
			case 'T':
			s[i] = 'A';
			break;
			case 'G':
			s[i] = 'C';
			break;
			case 'C':
			s[i] = 'G';
			break;
		}
	}
	cout << s << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int N,K;
    cin >> N >> K;
    int num = 1;
    for (int i = 0;i<N;i++){
        if (num + K <= num * 2){
            num = num + K;
        }
        else{
            num = num * 2;
        }
    }

    cout << num << endl;
}

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

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

	int n, t, l, b;
	while (cin >> n >> t >> l >> b , n) {
		bool lose[110] = {false}, back[110] = {false};
		int x;
		for (int i = 0; i < l; i++) {
			cin >> x;
			lose[x] = true;
		}
		for (int i = 0; i < b; i++) {
			cin >> x;
			back[x] = true;
		}

		double dp[110][110] = {0};
		dp[0][0] = 1.0;


		for (int turn = 0; turn < t; turn++) {
			for (int pos = 0; pos < n; pos++) {
				if (dp[turn][pos] == 0) continue;

				for (int dice = 1; dice <= 6; dice++) {
					int npos = pos + dice;
					if (n < npos) npos = n - (npos - n);

					if (lose[npos]) {
						dp[turn + 2][npos] += dp[turn][pos] / 6.0;
					}
					else if (back[npos]) {
						dp[turn + 1][0] += dp[turn][pos] / 6.0;
					}
					else {
						dp[turn + 1][npos] += dp[turn][pos] / 6.0;
					}
				}
			}
		}

		double ans = 0;
		for (int turn = 1; turn <= t; turn++) {
			ans += dp[turn][n];
		}
		cout << fixed << setprecision(6) << ans << endl;
	}
}

Measured memory_bytes: 1364
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define PI 3.14159265359
#define INF 1000100100
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define P pair<ll, ll>
#define PP pair<P,P>
using namespace std;
 
vector<ll> divisor(ll a){
    vector<ll> res;
    for(ll i=2; i<=sqrt(a); i++){
        if(a%i==0){
            res.push_back(i);
            if(i!=a/i) res.push_back(a/i);
        }
    }
    res.push_back(a);
    sort(all(res));
    return res;
}


int main(){
    int n,k; cin >> n >> k;
    vector<int> a(n);
    int sum=0;
    rep(i,n){
        cin >> a[i];
        sum+=a[i];
    }

    vector<ll> p=divisor(sum);
    reverse(all(p));

    rep(i,p.size()){
        vector<ll> moda;
        rep(j,n){
            if(a[j]%p[i]) moda.push_back(a[j]%p[i]);
        }
        int ms=moda.size();
        /*if(!ms){
            cout << p[i] << endl;
            return 0;
        }*/
        sort(all(moda));
        vector<ll> rmoda(ms+1);
        rmoda[0]=0;
        rep(j,ms) rmoda[j+1]=p[i]-moda[j]+rmoda[j];
        ll now=0;
        rep(j,ms){
            now+=moda[j];
            if(now==rmoda[ms]-rmoda[j+1]){
                if(now<=k){
                    cout << p[i] << endl;
                    return 0;
                }
                break;
            }
            else if(now>rmoda[ms]-rmoda[j+1]) break;
        }
    }
    cout << 1 << endl;
return 0;
}


Measured memory_bytes: 256
R,G,B,N = gets.chomp.split(" ").map(&:to_i)
cnt = 0
0.upto(N/R) do |i|
  0.upto(N/G) do |j|
    cnt += 1 if (N - i*R - j*G) % B == 0 && (N - i*R - j*G) >= 0
  end
end
puts cnt

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

#define REP(i,a,n) for(int i=a;i<n;++i)
#define REPL(i,a,n) for(ll i=a;i<n;++i)
#define RUP(a,b) ((a+b-1)/(b))
#define ENT "\n"
#define SORTVG(v) sort(v.begin(),v.end(),greater<>())
#define SORTV(v) sort(v.begin(),v.end())
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define INF INT_MAX/2
#define int long long

typedef long long ll;
typedef pair<int,int> Pii;
typedef vector<int> Vi;
typedef vector<Vi> VVi;

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;}}
template<class T> void YesNo(T& a) {if(a){cout << "Yes" << ENT;}else{cout << "No" << ENT;}}
template<class T> void YESNO(T& a) {if(a){cout << "YES" << ENT;}else{cout << "NO" << ENT;}}
template<class T> void AorB(T& a, string A,string B) {if(a){cout << A << ENT;}else{cout << B << ENT;}}

int atcoder(){
    int a,b,c;
    cin>>a>>b>>c;
    
    if(a==b && b==c){
        if(a%2==0) cout<<-1<<ENT;
        else cout<<0<<ENT;
        return 0;
    }
    
    int ans=0;
    while(1){
        if(a%2==1 || b%2==1 || c%2==1) break;
        int newa=(b+c)/2;
        int newb=(a+c)/2;
        int newc=(a+b)/2;
        a=newa;
        b=newb;
        c=newc;
        ans++;
    }
    cout<<ans<<ENT;
    return 0;
}

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


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

const int MaxN = 1e5 + 10;
int n, x, y, t, xp, yp, tp;

int main() {
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> t >> x >> y;
        int d = abs(x - xp) + abs(y - yp);
        if (d > t - tp || d % 2 != (t - tp) % 2) {
            cout << "No";
            return 0;
        }
        xp = x;
        yp = y;
        tp = t;
    }
    cout << "Yes";
	return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

const int max_num = (1e5 + 5), work = 3;
int happy[max_num][work], dp[max_num][work];

int get_num() {
    int input;
    cin >> input;

    return input;
}

int main() {
    int num = get_num();
    for (int i = 0; i < num; i++) {
        for (int j = 0; j < work; j++) {
            happy[i][j] = get_num();
        }
    }

    for (int i = 0; i < work; i++) {
        dp[0][i] = happy[0][i];
    }
    for (int i = 1; i < num; i++) {
        for (int j = 0; j < 3; j++) {
            for (int k = 0; k < 3; k++) {
                if (k != j and (dp[i][j] < (dp[i - 1][k] + happy[i][j]))) {
                    dp[i][j] = (dp[i - 1][k] + happy[i][j]);
                }
            }
        }
    }

    cout << max(max(dp[num - 1][0], dp[num - 1][1]), dp[num - 1][2]);
}

Measured memory_bytes: 5500
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using ll = long long;
using P = pair<int, int>;
const int mod = 1000000007;

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



int main(){
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    rep(i, n) {
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    vector<mint> data(n);
    mint temp(1);
    rep(i, n) {
        if (i<=k-2) {
            data[i] = mint(0);
        }
        else if (i==k-1) data[i] = 1;
        else {
            temp *= i;
            temp /= (i+1-k);
            data[i] = temp;
        }
    }
    /*
    rep(i, k-1) {
        temp *= n-1-i;
        temp /= (i+1);
    }
    data.push_back(temp);
    rep(i, n-k) {
        temp /= n-1-i;
        temp *= n-i-k;
        data.push_back(temp);
    }
    data.push_back(mint(0));
     */
    mint ans(0);
    rep(i, n) {
        ans += data[i]*a[i];
        ans -= data[n-1-i]*a[i];
    }
    
    
    
    cout << ans.x << endl;
    return 0;
}


Measured memory_bytes: 1408
#include<stdio.h>
int main()
{
	int n,a,cnt[200001]={0};
	int i,j;

	scanf("%d",&n);
	i=1;
	while(scanf("%d",&a)){
      	cnt[a]++;
		i++;
		if(i>=n){break;}
	}
	for(i=1;i<=n;i++){
		printf("%d\n",cnt[i]);
	}
	return 0;
}


Measured memory_bytes: 2516
#include <algorithm>
#include <cstdio>
#include <cstdlib>
using namespace std;

int main() {
	for(long long a, b; scanf("%lld %lld", &a, &b) == 2;) {
		long long g = __gcd(a, b);
		printf("%lld %lld\n", g, a / g * b);
	}

	return EXIT_SUCCESS;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int a, b;
    cin >> a >> b;
    if (a < 0 && b < 0)
    {
        cout << ((b - a) % 2 == 0 ? "Negative" : "Positive") << endl;
        return 0;
    }
    if (a < 0 && b >= 0 || a == 0)
    {
        cout << "Zero" << endl;
        return 0;
    }
    if (a > 0 && b > 0)
    {
        cout << "Positive" << endl;
        return 0;
    }
}

Measured memory_bytes: 256
// ABC068B - Break Number

#include <bits/stdc++.h>
using namespace std;

int main() {
	int N;
	cin >> N;

	int ans = 2;
	while (1) {
		if (ans > N) {
			break;
		}
		ans *= 2;
	}

	cout << ans / 2 << endl;

	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;
// Welcome to my source code!

const int MOD = 998244353;

int main() {
    int n;
    cin >> n;
    int d[n];
    REP(i,n) cin >> d[i];
    if (d[0] != 0) {
        cout << 0 << endl;
        return 0;
    }
    sort(d, d+n);
    int cnt[n] = {};
    REP(i,n) cnt[d[i]]++;
    if (cnt[0] != 1) {
        cout << 0 << endl;
        return 0;
    }
    ll ans = 1;
    REP(i,n) {
        if (d[i] < 2) continue;
        int x = d[i];
        ans *= cnt[x-1];
        ans %= MOD;
    }
    cout << ans << endl;
}

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

int main(){
    vector<int> vec(100);
    vector<vector<int>> data(3,vector<int>(4));
    string s,t;
    int n,ans;
    ans = 0;

    cin >> s ;
    
    if(s == "RRR"){
        ans = 3;
    }else if(s == "RRS" || s == "SRR"){
        ans = 2;
    }else if(s == "RSS" || s == "SRS" || s == "SSR" || s == "RSR"){
        ans = 1;
    }
    cout << ans << endl;
    
}

Measured memory_bytes: 3628
#define _LIBCPP_DEBUG 0
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll MOD = 1e9+7;

int main(void) {

    int N; cin>>N;
    vector<int> L(N);
    for (int i = 0; i < N; ++i) {
        cin >> L[i];
    }
    sort(L.begin(), L.end());
    int ans = 0;
    for (int i = 0; i < N-2; ++i) {
        for (int j = i+1; j < N-1; ++j) {
            int syu = L[i]+L[j];
            auto it = upper_bound(L.begin()+j+1, L.end(), syu-1);
            int kyori =  distance(L.begin()+j+1, it);
            ans += kyori;
        }
    }

    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
from collections import defaultdict
import random

S = input()
n = len(S)

mp = defaultdict(int)
mp[0] += 1
x = 0
y = 1
for i, s in enumerate(reversed(S)):
    x = (x + int(s) * y) % 2019
    y = (y * 10) % 2019
    mp[x] += 1

ans = 0
for m in mp.values():
    ans += m * (m - 1) // 2

print(ans)


Measured memory_bytes: 78464
# O(n^2) fastest to AC though.. not sure if correct
N, X, Y = map(int, input().split())
values_hm = N * [0]
for i in range(1, N):
    for j in range(i+1, N+1):
        if not ((i < X and j < X) or (i > Y and j > Y)):
            shorter_route = abs(i - X) + abs(j - Y) + 1
            difference = min(j - i, shorter_route)
        else:
            difference = j - i
        values_hm[difference] += 1
print("\n".join([str(ans) for ans in values_hm[1:]]))

Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  int n;
  cin >> n;
  int k[n];
  rep(i,n){
    int a;
    cin >> a;
    k[a-1]=i+1;
  }
  rep(i,n-1)cout << k[i] << " ";
  cout << k[n-1] << endl;
}


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

#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))

typedef long long LL;

int main(){
  int d,w;
  while(1){
    cin >> d >> w;
    if(d==0) return 0;
    vector<vector<int>> e(d,vector<int>(w));
    for(int i=0;i<d;i++){
      for(int j=0;j<w;j++){
        cin >> e[i][j];
      }
    }
    vector<vector<vector<int>>> yokomin(d,vector<vector<int>>(w,vector<int>(w,10)));
    vector<vector<vector<int>>> tatemin(w,vector<vector<int>>(d,vector<int>(d,10)));
    for(int i=0;i<d;i++){
      for(int j=0;j<w;j++){
        for(int k=j+2;k<w;k++){
          for(int l=j;l<=k;l++){
            yokomin[i][j][k]=min(yokomin[i][j][k],e[i][l]);
          }
        }
      }
    }
    for(int i=0;i<w;i++){
      for(int j=0;j<d;j++){
        for(int k=j+2;k<d;k++){
          for(int l=j;l<=k;l++){
            tatemin[i][j][k]=min(tatemin[i][j][k],e[l][i]);
          }
        }
      }
    }
    vector<vector<vector<int>>> yokomax(d,vector<vector<int>>(w,vector<int>(w,0)));
    for(int i=0;i<d;i++){
      for(int j=0;j<w;j++){
        for(int k=j;k<w;k++){
          for(int l=j;l<=k;l++){
            yokomax[i][j][k]=max(yokomax[i][j][k],e[i][l]);
          }
        }
      }
    }
    //  添え磁気圏
    vector<vector<int>> ruiseki(d+1,vector<int>(w+1,0));
    for(int i=1;i<=d;i++){
      for(int j=1;j<=w;j++){
        ruiseki[i][j]=ruiseki[i-1][j]+ruiseki[i][j-1]-ruiseki[i-1][j-1]+e[i-1][j-1];
      }
    }
    int ans=0;
    int mi=10,ma;
    for(int i=0;i<d;i++){
      for(int j=0;j<w;j++){
        for(int k=i+2;k<d;k++){
          for(int l=j+2;l<w;l++){
            mi=yokomin[i][j][l];
            mi=min(mi,yokomin[k][j][l]);
            mi=min(mi,tatemin[j][i][k]);
            mi=min(mi,tatemin[l][i][k]);
            ma=0;
            for(int x=i+1;x<=k-1;x++){
              ma=max(ma,yokomax[x][j+1][l-1]);
            }
            if(mi>ma){
              ans=max(ans,mi*(k-i-1)*(l-j-1)-(ruiseki[k][l]-ruiseki[i+1][l]-ruiseki[k][j+1]+ruiseki[i+1][j+1]));
            }
          }
        }
      }
    }
    cout << ans << endl;
  }
  return 0;
}



Measured memory_bytes: 3168
#include <iostream>

int main()
{
  int N;
  
  std::cin >> N;
  
  int a[N];
  int i;
  int sum_a = 0;
  int sum_aa = 0;
  
  for (i = 0; i < N; i++) {
    std::cin >> a[i];
    sum_a += a[i];
    sum_aa += a[i] * a[i];
  }
  
  int min = sum_aa + (2 * 100 * sum_a) + (N * 100 * 100);
  
  for (i = -99; i <= 100; i++) {
    int tmp = sum_aa - (2 * i * sum_a) + (N * i * i);
    if (min > tmp) {
      min = tmp;
    }
    if (min == 0) break;
  }
  
  std::cout << min;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <iterator>
#pragma warning(disable:4996)
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223372036854775807
#define INF 2147483647
#define MOD 1000000007
using namespace std;



int main(int argc, char* argv[])
{
    long n;
    scanf("%ld", &n);

    printf("%ld\n", 800*n-200*(n/15));

    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
	multiset<ll> a;
	multiset<ll>::iterator it;
	int n,k; cin>>n>>k;
	for(int i = 0 ; i < n ; i++)
	{
		ll v; cin>>v;
		a.insert(v);
	}
	ll c = 0, ans =0;
	while(c<k)
	{
		
		it = a.end();
		it--;
		ll new_val  = *it; 
		new_val/=2;
		a.erase(it);
		a.insert(new_val);
		c++; 
	
    }
    for(auto& itq : a)
    	ans += itq;
	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 4992
n=int(input())

l=[]
for i in range(n):
    l+=[input()[0]]

march=[0]*5
for j in range(n):
    if l[j]=='M':
        march[0]+=1
    elif l[j]=='A':
        march[1]+=1
    elif l[j]=='R':
        march[2]+=1
    elif l[j]=='C':
        march[3]+=1
    elif l[j]=='H':
        march[4]+=1

from itertools import combinations
ans=0
for x,y,z in combinations(march, 3):
    ans+=x*y*z

print(ans)

Measured memory_bytes: 3992
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using bint = boost::multiprecision::cpp_int;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repSE(i,s,n) for (int i = (s); i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main()
{
    string S;
    cin >> S;
    bool ans = false;
    rep(i,3) {
        if (S[i] - '0' == 7) {
            ans = true;
            break;
        }
    };
    cout << (ans ? "Yes": "No") << endl;
    return 0;
}


Measured memory_bytes: 3596
n = int(input())

for i in range(1000):
    if n > 26**(i+1):
        n -= 26**(i+1)
    else:
        break
x = i+1

t = 26**i
ans = ""
for i in range(x-1,-1,-1):
    t = 26**i
    for j in range(26):
        if n > t:
            n -= t
        else:
            ans += chr(ord("a")+j)
            break
print(ans)



Measured memory_bytes: 61804
n = int(input())
a = []
for i in range(n):
    a.append(list(map(int, input().split())))
dp = [[0 for i in range(3)] for i in range(n+10)]
#print(a)
#print(dp)
for i in range(1,n+1):
    dp[i][0] = max(dp[i-1][1] + a[i-1][0],dp[i-1][2] + a[i-1][0])
    dp[i][1] = max(dp[i-1][0] + a[i-1][1],dp[i-1][2] + a[i-1][1])
    dp[i][2] = max(dp[i-1][0] + a[i-1][2],dp[i-1][1] + a[i-1][2])
print(max(dp[n][0],dp[n][1],dp[n][2]))

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

#define rep(i, a, b) for (int i = a; i < (int)(b); ++i)
#define rrep(i, a, b) for (int i = b - 1; i >= (int)(a); --i)

using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;

constexpr int MOD = 1000000007;

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

    ll n;
    cin >> n;

    // O(n)
    vll a(n);
    ll maxv = 0;
    rep(i, 0, n) {
        cin >> a[i];
        maxv = max(maxv, a[i]);
    }

    // O(n)
    vll dp(maxv + 1, 0);
    rep(i, 0, n) { ++dp[a[i]]; }

    // O(n)
    ll ans = 0;
    rep(i, 1, maxv + 1) {
        if (dp[i] >1) { ans += dp[i] * (dp[i] - 1) / 2; }
    }

    rep(i, 0, n) {
        if (dp[a[i]] <= 1) {
            cout << ans << endl;
            continue;
        }
        ll fake = dp[a[i]] * (dp[a[i]] - 1) / 2;
        ll truth = (dp[a[i]] - 1) * (dp[a[i]] - 2) / 2;
        cout << ans - fake + truth << endl;
    }

    return 0;
}

Measured memory_bytes: 5632
#include<bits/stdc++.h>
#define int long long
using namespace std;
int rt[30];
signed main()
{
	int d;
	scanf("%lld",&d);
	rt[0]=1;
	for(int i=1;i<30;i++)
		rt[i]=rt[i-1]*10ll;
	int ret=0;
	for(int i=2;i<=20;i++)
	{
		int k=i/2;
		for(int s=0;s<(1<<k);s++)
		{
			int way=i%2==1?10:1,zan=d;
			for(int j=0;j<k;j++)
			{
				int dd=abs(zan)%10ll;
				if(zan<0)
				{
					dd=10-dd;
					dd%=10;
				}
				if(s>>j&1)
				{
					int nm=10ll-dd;
					if(j==0)
						nm--;
					way*=nm;
					zan+=dd*rt[i-2*j-1];
					zan-=dd;
				}
				else
				{
					int nm=dd;
					if(j==0)
						nm--;
					if(nm<0)
					{
						way=0;
						break;
					}
					way*=nm;
					zan-=(10ll-dd)*rt[i-2*j-1];
					zan+=(10ll-dd);
				}
				zan/=10ll;
			}
			if(zan==0)
				ret+=way;
		}
	}
	cout<<ret;
	return 0;
} 

Measured memory_bytes: 3760
N, M, K = map(int, input().split())
MOD = 10 ** 9 + 7

def comb(n, k):
    ret = 1
    for i in range(1, k + 1):
        ret = ret * (n - i + 1) % MOD        
        ret = ret * pow(i, MOD - 2, MOD) % MOD
        
    return ret

ans = 0
for d in range(N):
    ans += d * (N - d) * M ** 2
    ans %= MOD
    
for d in range(M):
    ans += d * (M - d) * N ** 2
    ans %= MOD
    
print(ans * comb(N * M - 2, K - 2) % MOD)



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

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

    int len = s.length();
    int ans = 0;
    for(int i=0, n=len-1; i<len/2; ++i, --n){
        if(s[i]!=s[n]) ans++;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
    
    public static void main(String[] args) {
	    Scanner in=new Scanner(System.in);
	    int n=in.nextInt();
	    List<List<Node>> ls=new ArrayList<>();
	    
	    for(int i=0;i<n;i++)ls.add(new ArrayList<Node>());
	    for(int i=0;i<n;i++) {
		int u=Integer.parseInt(in.next()),k=Integer.parseInt(in.next());
		for(int j=0;j<k;j++) {
		    int v=Integer.parseInt(in.next()),
			c=Integer.parseInt(in.next());
		    ls.get(u).add(new Node(v,c));
		}
	    }
	    
	    int visit[]=new int[n],parent[]=new int[n],d[]=new int[n];
	    for(int i=0;i<n;i++) {
		parent[i]=-1; d[i]=Integer.MAX_VALUE;
	    }
	    d[0]=0;
		
	    while(true) {
		int u=-1,min=Integer.MAX_VALUE;
		
		for(int i=0;i<n;i++) {
		    if(visit[i]<2 && d[i]<min) {
			min=d[i];
			u=i;
		    }
		}
		
		if(u==-1)break;
		visit[u]=2;
		
		for(int i=0;i<ls.get(u).size();i++) {
		    Node v=ls.get(u).get(i);
		    if(visit[v.v]<2 && d[u]+v.c<d[v.v]) {
			d[v.v]=d[u]+v.c;
			parent[v.v]=u;
			visit[v.v]=1;
		    }
		}
	    }
	    
	    for(int i=0;i<n;i++)System.out.println(i+" "+d[i]);
    }
    
}

class Node{
    int v,c;
    Node(int a,int b){
	v=a;
	c=b;
    }
}


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

vector<int> prime(100,0);
int P[25]={2,3,5,7,11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97};

void Factoring(int n){
    for(int i = 0; i < 25; i++)
    {
        while(n%P[i]==0){
            prime[P[i]]++;
            n /= P[i];
        }
    }
}

int main(){
    int N;
    cin >> N;
    for(int i = 0; i < N; i++)
    {
        Factoring(i+1);
    }
    
    sort(prime.rbegin(),prime.rend());

    vector<int> over(5,0);
    for(int i = 0; i < 25; i++)
    {
        if(prime[i]>=74) over[4]++;
        if(prime[i]>=24) over[3]++;
        if(prime[i]>=14) over[2]++;
        if(prime[i]>=4) over[1]++;
        if(prime[i]>=2) over[0]++;
    }
    
    int ans = 0;

    ans += over[1]*(over[1]-1)*(over[0]-2)/2;
    ans += over[2]*(over[1]-1);
    ans += over[3]*(over[0]-1);
    ans += over[4];
    
    cout << ans << endl;
}


Measured memory_bytes: 256