akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define REPr(i,n) for(int i=(n)-1;i>=0; --i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define SCD(n) scanf("%d",&n)
#define SCD2(m,n) scanf("%d%d",&m,&n)
#define SCD3(m,n,k) scanf("%d%d%d",&m,&n,&k)
#define SCLLD(n) scanf("%lld",&n)
#define SCLLD2(m,n) scanf("%lld%lld",&m,&n)
#define SCLLD3(m,n,k) scanf("%lld%lld%lld",&m,&n,&k)
#define PB push_back
#define MP make_pair
#define ARSCD(A,N) REP(i,N){SCD(A[i]);}
#define ARSCD1(A,N) FORq(i,1,N){SCD(A[i]);}
#define VSCD(v,N) REP(i,N){int x; SCD(x); v.PB(x);}
#define VSCLLD(v,N) REP(i,N){long long x; SCLLD(x); v.PB(x);}
#define PRINTD(n) printf("%d\n",n)
#define PRINTLLD(n) printf("%lld\n",n)
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define SIN(x,S) (S.count(x) != 0)
using namespace std;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector < VI > VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
////////////////////////////////////////////////////////////////////
struct Vertex {
	// edge information
	vector<int> edges_to; //to vertex number
	vector<ll> edges_cost; // edge cost
	
	//for dijkstra
	bool done; //conform or not
	ll cost; // now cost
	int from;
	
	bool operator<(const Vertex& another) const { // priority --> min
        return another.cost < cost; // order(cost)
    }
	
	bool operator==(const Vertex& another) const {
        return another.cost == cost; // order(cost)
    }
};

int main(){
	const int V_MAX = 11002;
	const int E_MAX = 100002;
	int V,E; SCD2(V,E);
	Vertex v[V_MAX];

	REP(i,E){
		int s,t; SCD2(s,t);
		v[s].edges_to.PB(t);
		v[t].cost++;
	}

	stack<int> S;
	vector<int> ans;

	REP(i,V){
		if (v[i].cost == 0){
			S.push(i);
		}
	}

	while(!S.empty()){
		int now = S.top(); S.pop();
		Vertex nowV = v[now];
		ans.PB(now);
		REP(i,nowV.edges_to.size()){
			int nto = nowV.edges_to[i];
			v[nto].cost--;
			if (v[nto].cost == 0) S.push(nto);
		}
	}

	REP(i,ans.size()){
		PRINTD(ans[i]);
	}

	return 0;
}


Measured memory_bytes: 4516
#include<iostream>
#include<algorithm>
#include<vector>
#include<string.h>
#include<math.h>
#include<map>

using namespace std;

int main(){
	int n;
	cin >> n;
	
	vector<int> t(n,0);
	for(int i=0;i<n;i++){
		cin >> t[i];
	}
	
	int m;
	cin >> m;
	
	vector<pair<int,int>> p(m);
	for(int i=0;i<m;i++){
		cin >> p[i].first >> p[i].second;
	}
	
	int sum;
	for(int i=0;i<m;i++){
		sum=0;
		for(int j=0;j<n;j++){
			if(j==p[i].first-1){
				sum+=p[i].second;
			}else{
				sum+=t[j];
			}
		}
		cout << sum << endl;
	}
	
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------

void _main() {
	int A,B,K;
	cin >> A >> B >> K;

	int M;
	M = min(A,B);
	int ans = 0;
	for (int i = M; i > 0; i--) {
		if (A % i == 0 && B % i == 0) {
			ans = i;
			K--;
		}
		if (K == 0) {
			cout << ans << endl;
			break;
		} 
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for(ll i=0; i<n; i++)
#define repr(i, s, e) for(ll i=s; i>=e; i--)
#define reps(i, s, e) for(ll i=s; i<=e; i++)
#define inf 1e18
#define all(v) v.begin(),v.end()
#define ok cout << "ok" << endl;
#define sp << " " <<
template<typename T> inline bool chmax(T &a, T b){ if(a<b) a=b; return a<b; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a) a=b; return b<a; }
template<typename T> void vdeb(T v){
    cout << "#vector set debug" << endl;
    for(auto vv : v) cout << vv << " ";
    cout << endl;
}
template<typename T1, typename T2> void adeb(T1 arr[], T2 n){
    cout << "#adebug" << endl;
    for(int i=0; i<=n; i++) cout << arr[i] << " ";
    cout << endl;
}
template<typename T1> void mdeb(T1 mp){
    cout << "#map pair debug" << endl;
    for(auto const& m : mp) cout << m.first sp m.second << endl;
}
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){ fill((T*)array, (T*)(array+N), val); }
void ans(bool b){ cout << (b ? "Yes" : "No") << endl; }
void ans2(bool b){ cout << (b ? "YES" : "NO") << endl; }
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};


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

    int n;
    vector<pair<int, int>> ta;
    int t, a;
    cin >> n;
    rep(i, n){
        cin >> t >> a;
        ta.push_back(make_pair(t, a));
    }

    ll taka = 0, aoki = 0;
    for(auto const& e : ta){
        int t = e.first;
        int a = e.second;
        if(t == a){
            if(taka < aoki){
                taka = aoki;
            }else if(taka > aoki){
                aoki = taka;
            }
            if(taka==0 && aoki==0){
                taka = aoki = 1;
            }
        }else{
            if(taka != 0 && aoki != 0){
                ll taka1 = taka;
                ll aoki1;
                while(taka1 % t != 0){
                    taka1++;
                }
                aoki1 = taka1 / t * a;

                ll taka2;
                ll aoki2 = aoki;
                while(aoki2 % a != 0){
                    aoki2++;
                }
                taka2 = aoki2 / a * t;

                if(taka1 >= taka && aoki1 >= aoki && taka2 >= taka && aoki2 >= aoki){
                    if(taka1+aoki1 < taka2+aoki2){
                        taka = taka1;
                        aoki = aoki1;
                    }else{
                        taka = taka2;
                        aoki = aoki2;
                    }
                }else{
                    if(taka1 >= taka && aoki1 >= aoki){
                        taka = taka1;
                        aoki = aoki1;
                    }else if(taka2 >= taka && aoki2 >= aoki){
                        taka = taka2;
                        aoki = aoki2;
                    }
                }
            }else{
                taka = t;
                aoki = a;
            }
        }
        //cout << taka sp aoki << endl;
    }

    cout << taka+aoki << endl;

    return 0;
}


Measured memory_bytes: 256
import scala.io.StdIn._
import scala.collection._

object Main {

  class Sieve(val n: Int){
    private[this] val top = (n - 3) / 2 + 1
    private[this] val cmpsts = new Array[Int]((top >>> 5) + 1)
    private[this] val sqrtLmtNdx = (Math.sqrt(n).toInt - 3) / 2

    def isCmpst(ci: Int): Boolean = (cmpsts(ci >>> 5) & (1 << (ci & 31))) != 0
    def setCmpst(ci: Int): Unit = cmpsts(ci >>> 5) |= 1 << (ci & 31)

    private[this] def cull(cmpstId: Int, p: Int): Unit = {
      if(cmpstId <= top){
        setCmpst(cmpstId)
        cull(cmpstId + p, p)
      }
    }

    private[this] def rec(cndId: Int): Unit = {
      if(cndId <= sqrtLmtNdx){
        if(!isCmpst(cndId)){
          val p = 2 * cndId + 3
          cull((p * p - 3) >>> 1, p)
        }
        rec(cndId + 1)
      }
    }

    private[this] def next(cndId: Int): Int =
      if ((cndId > top) || !isCmpst(cndId)) 2 * cndId + 3 else next(cndId + 1)

    def exec: Iterator[Int] = {
      rec(0)
      Iterator.single(2) ++ Iterator.iterate(3)(p => next((p - 1) >>> 1)).takeWhile(_ <= n)
    }
  }

  def loop(s: String){
    if(s != null){
       val Array(n,_*) = s.split(" ").map(_.toInt)
       if(n<2) println(0)
       else println(new Sieve(n).exec.size)
       loop(readLine)
    }
  }

  def main(args: Array[String]): Unit = loop(readLine)
}

Measured memory_bytes: 65400
s = gets.scan(/<*>*/)

count = 0
while str = s.shift
  break if str == ""
  l, r = str.count("<"), str.count(">")
  if l >= r
    count += l * (l+1) / 2
    count += (r-1) * r / 2
  else
    count += r * (r+1) / 2
    count += (l-1) * l / 2
  end
end

puts count



Measured memory_bytes: 25316
n = int(input())
As = [int(i) for i in input().split()]
Bs = [int(i) for i in input().split()]
ABs = [a - b for a, b in zip(As, Bs)]
if sum(As) < sum(Bs) or min(ABs) > 0:
    print(-1)
    exit()
mABs = [ab for ab in ABs if ab < 0]
pABs = [ab for ab in ABs if ab > 0]
ans, t = len(mABs), sum(mABs)
for pab in sorted(pABs, reverse=True):
    if t >= 0:
        break
    ans += 1
    t += pab
print(ans)

Measured memory_bytes: 18708
#ifndef ONLINE_JUDGE
    #include "debug.cpp"
#endif

#include <bits/stdc++.h>

using namespace std;

#define int long long
#define ar array

bool check(int mid, int i, int n){
    if((mid*i) < n) return false;
    else return true;
}

void solve(){
    int n;
    cin >> n;
    int cnt = 0;
    for(int i = 1;i <= n; i++){
        int l = 1, r = n;
        while(l < r){
            int mid = (l+r)/2;
            if(check(mid,i,n)) r=mid;
            else l=mid+1;
        }
        cnt += (l-1);
    }       
    cout << cnt << "\n";
}

int32_t main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);

    int TC = 1;
    while(TC--)
        solve();

    return 0;
}



Measured memory_bytes: 3648
#include<stdio.h>
int main(void)
{
	int n,m,a[1001],b,z[1001],i,j,w,d;
	scanf("%d %d",&n,&m);
	for(i=1;i<=n;i++){
		scanf("%d",&a[i]);
		z[i]=0;
	}
	for(j=0;j<m;j++){
		scanf("%d",&b);
		for(i=1;i<=n;i++){
			if(a[i]<=b){
				z[i]++;
				break;
			}
		}
	}
	d=0;
	w=0;
	for(i=0;i<n;i++){
		if(d<z[i]){
			d=z[i];
			w=i;
		}
	}
	printf("%d\n",w);
	return 0;
}

Measured memory_bytes: 1032
#include <bits/stdc++.h>
using namespace std;
#define fo(i,a,b) for (int i = (a); i < (b); i++)
#define N 123456

int n, a[N], x, y;
int main() {
	scanf("%d", &n);
	fo(i,0,n) scanf("%d", a+i);
	sort(a, a+n); reverse(a, a+n);
	n++;
	while (x+1 < n && y+1 < a[x+1]) x++, y++;
	int dy = a[x] - y;
	int dx = 1;
	if (x+1 < n && a[x+1] == y+1) {
		dx++; x++;
		while (x+1 < n && a[x+1] == a[x]) x++, dx++;
	}
	if (dx%2 && dy%2) puts("Second");
	else puts("First");

	return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;
int l,r;
#define Maxn 100010
int x[Maxn][200];
int main(){
	long long Ans=2019;
	scanf("%d%d",&l,&r);
	for(register int i=l;i<min(l+2019,r+1);++i)
	    for(register int j=max(max(l,r-2018),i+1);j<=r;++j)
	        Ans=min(Ans,1ll*i*j%2019);
	printf("%lld\n",Ans);
	return 0;
} 

Measured memory_bytes: 256
#include<iostream>
#include<cctype>
using namespace std;
int main(){
	int a,b;
	string s;
	cin>>a>>b>>s;
	if(s.size()!=a+b+1){
		cout<<"No";return 0;
	}
	for(int i=0;i<s.size();i++){
		if(i!=a){
			if(!isdigit(s[i])){
				cout<<"No";
				return 0;
			}
		}
		else{
			if(s[i]!='-'){
				cout<<"No";
				return 0;
			}
		}
	}
	cout<<"Yes";
}

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

using namespace std;

#define int long long

const int mod = 998244353;

void solve() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    vector <vector <int> > dp(3001, vector <int> (3001, 0));
    dp[a][b] = 1;
    for (int i = a; i <= 3000; ++i) {
        for (int j = b; j <= 3000; ++j) {
            if (i == a && j == b) continue;
            dp[i][j] = (((dp[i - 1][j] * j + dp[i][j - 1] * i - dp[i - 1][j - 1] * (i - 1) * (j - 1)) % mod) + mod) % mod;
        }
    }
    cout << dp[c][d];
}

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


Measured memory_bytes: 73680
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>

using namespace std;

vector<int> G[100005];
int nr1 = 1, nrN = 1, n;
bool used[100005];

void BFS() {
    queue< pair<int, char> > Q;
    Q.push(make_pair(1, 'B'));
    Q.push(make_pair(n, 'W'));

    used[1] = used[n] = true;

    while (!Q.empty()) {
        int nod = Q.front().first;
        char color = Q.front().second;

        if (color == 'B') ++nr1;
        else ++nrN;

        for (vector<int>::iterator it = G[nod].begin(); it != G[nod].end(); ++it) {
            if (!used[*it]) {
                used[*it] = true;
                Q.push(make_pair(*it, color));
            }
        }

        Q.pop();
    }
}

int main() {

    ios::sync_with_stdio(false);
    cin.tie(0);

    cin >> n;

    int a, b;
    for (int i = 1; i < n; ++i) {
        cin >> a >> b;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    BFS();

    if (nr1 > nrN) {
        cout << "Fennec";
    }
    else {
        cout << "Snuke";
    }

    return 0;
}




Measured memory_bytes: 6144
#define DEBUG 0
#include <bits/stdc++.h>
#define all(v) (v).begin(), (v).end()
#define pb push_back
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template<class T>using numr=std::numeric_limits<T>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int INF = 1e9;
const ll LLINF = 1e16;
const int mod = 1000000007;
const int mod2 = 998244353;
void debug_impl() { std::cerr << std::endl; }
template <typename Head, typename... Tail>
void debug_impl(Head head, Tail... tail) { std::cerr << " " << head; debug_impl(tail...); }
#if DEBUG
#define debug(...)\
    do {\
        std::cerr << std::boolalpha << "[" << #__VA_ARGS__ << "]:";\
        debug_impl(__VA_ARGS__);\
        std::cerr << std::noboolalpha;\
    } while (false)
#else
#define debug(...) {}
#endif

template < typename Container, typename Value = typename Container::value_type, std::enable_if_t<!std::is_same< Container, std::string >::value, std::nullptr_t> = nullptr>
std::istream& operator>> (std::istream& is, Container& v)
    { for (auto & x : v) { is >> x; } return is; }

template < typename Container, typename Value = typename Container::value_type, std::enable_if_t<!std::is_same< Container, std::string >::value, std::nullptr_t> = nullptr >
std::ostream& operator<< (std::ostream& os, Container const& v) {
os << "{";
    for (auto it = v.begin(); it != v.end(); it++)
        {os << (it != v.begin() ? "," : "") << *it;}
    return os << "}";
}
vector< int64_t > divisor(int64_t n) {
  vector< int64_t > ret;
  for(int64_t i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

int main() {
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    int n;
    cin >> n;
    int ans = 0;
    for(int a = 1;a <=n;a++){
        for(int b = 1;a*b<n;b++){
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3648
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <math.h>
#define MOD 1000000007
typedef long long ll;
using namespace std;

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

  ll ans=n+1;
  for(ll i=1;i*i<=n;i++){
    if(n%i==0){
      ll q=n/i;
      ll tmp1=0,tmp2=0;
      for(int j=1;;j++){
        q/=10;
        if(q==0){
          tmp1=j;
          break;
        }
      }
      ll p=i;
      for(int j=1;;j++){
        p/=10;
        if(p==0){
          tmp2=j;
          break;
        }
      }
      if(max(tmp1,tmp2)<ans) ans=max(tmp1,tmp2);
    }
  }

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


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

static const int MAX_N = 65000;

int main()
{

	long long n, MLength = 0, addLength = 0, cnt = 0, Max = 0;
	int p[MAX_N], j[MAX_N - 1];

	while( cin >> n, n ) {

		memset( p, 0, sizeof( p ) );
		memset( j, 0, sizeof( j ) );

		MLength = 0, addLength = 0, Max = 0, cnt = n - 1;

		for( int i = 0; i < n; i++ ) { cin >> p[i]; Max += p[i]; addLength += p[i]; }
		for( int i = 0; i < n - 1; i++ ) cin >> j[i];

		sort( p, p + n, greater< int >() );
		sort( j, j + n - 1, greater< int >() );

		MLength = p[0] + j[0] + p[1];

		Max = max( MLength * cnt, Max * n );

		addLength -= ( p[0] + p[1] );

		for( int i = 2; i < n; i++ ) {

			addLength += MLength;

			Max = max( addLength * cnt, Max );

			cnt--;

			addLength -= ( MLength + p[i] );
			MLength += ( p[i] + j[i - 1 ] );

		}

		cout << Max << endl;

	}

	return 0;

}

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

#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0, a1, a2, a3, a4, x, ...) x
#define dump_1(x1) cerr << #x1 << ": " << x1 << endl
#define dump_2(x1, x2) \
  cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << endl
#define dump_3(x1, x2, x3)                                                \
  cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " \
       << x3 << endl
#define dump_4(x1, x2, x3, x4)                                            \
  cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " \
       << x3 << ", " #x4 << ": " << x4 << endl
#define dump_5(x1, x2, x3, x4, x5)                                        \
  cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " \
       << x3 << ", " #x4 << ": " << x4 << ", " #x5 << ": " << x5 << endl
#define dump(...) \
  CHOOSE((__VA_ARGS__, dump_5, dump_4, dump_3, dump_2, dump_1, ~))(__VA_ARGS__)
#define check(s) cerr << s << endl

#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define unique(v) v.erase(unique(v.begin(), v.end()), v.end());
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)

using namespace std;

using ll = long long;

vector<int> dx = {0, 1, 0, -1};
vector<int> dy = {1, 0, -1, 0};

const ll LINF = 2e18;
const int INF = 1e9;

void solve(std::string S) {
  ll z = S.size();
  if (S.at(z - 1) == 's') {
    cout << S << "es" << endl;
  } else {
    cout << S << "s" << endl;
  }
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  std::string S;
  std::cin >> S;
  solve(S);
  return 0;
}


Measured memory_bytes: 3660
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
#include<limits.h>
#include<deque>
#include<cstdio>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int N = 1000000;
const int mod = 998244353;
const ll INF = 1LL << 60;
#define rep(i,n) for(ll i=(ll)0;i<(ll)n;++i)
#define ALL(x) x.begin(),x.end()
#define pp pair<ll,ll>
#define fi first
#define se second
#define pb push_back
#define fix(n) fixed<<setprecision(n)
#define itr vector<ll>::iterator
ll n, v[200010],m,ans;
int main() {
	cin >> n;
	rep(i, n)cin >> v[i],v[i]-=i;
	sort(v, v + n);
	if (n % 2 == 1) {
		m = v[n / 2];
		rep(i, n) {
			ans += abs(m- v[i]);
		}
	}
	else {
		m = v[n / 2 - 1];
		rep(i, n) {
			ans += abs(m - v[i]);
		}
		ll ans2 = 0;
		m = v[n / 2];
		rep(i, n) {
			ans2 += abs(m  - v[i]);
		}
		ans = min(ans, ans2);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>
#include <stack>



#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(x) (x).begin(),(x).end()

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

typedef long long ll;

using namespace std;


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;cin>>n;
  vector<int>d(n);
  rep(i,n)cin>>d[i];
  ll sum=0;
  rep(i,n)
  {
    repi(j,i+1,n)
    {
      sum+=d[i]*d[j];
    }
  }
  cout<<sum<<endl;

  return 0;

}


Measured memory_bytes: 256
//#include <tourist>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = 1e9;
const ll LINF = 1e18;
const int MOD = 1000000007;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define debug(v)          \
    cout << #v << ":";    \
    for (auto x : v)      \
    {                     \
        cout << x << ' '; \
    }                     \
    cout << endl;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
//setprecision(15)有効数字15桁
//-std=c++14
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
int a, b, c;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> a >> b >> c;
    if (a == b && b == c)
        return no, 0;
    if (a == b || b == c || c == a)
    {
        return yes, 0;
    }
    no;
}


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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  __MAKE_TIME__  Problem: __PROBLEM__ / Link: __CONTEST_URL__  ----- */
/* ------問題------



-----問題ここまで----- */
/* -----解説等-----



----解説ここまで---- */



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

	LL N; cin >> N;
	string s, t; cin >> s >> t;
	LL ans = 1;
	LL prev = 3;
	FOR(i, 0, N) {
		if (s[i] == t[i]) {// |
			if (i) {
				ans *= 2 - prev;
			}
			else {
				ans *= 3;
			}
			prev = 0;
		}
		else { // ==
			if (i) {
				ans *= 2 + prev;
			}
			else {
				ans *= 6;
			}
			prev = 1;
			i++;
		}
		ans %= MOD;
	}

	cout << ans << endl;

	return 0;
}


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

int n, d[50][100005];
int f(int p, int q) {
	int i, mn = 2e9;
	if (p >= 50) return 2e9;
	if (q == 0 && p > 0) return p;
	if (d[p][q] != 0) return d[p][q];
	d[p][q] = 2e9;
	for (i = 0; i <= 9; i++) {
		mn = min(mn, f(p + i, (q * 10 + i) % n));
	}
	return d[p][q] = mn;
}
int main()
{
	cin >> n;
	cout << f(0, 0);
    return 0;
}

Measured memory_bytes: 243584
function main(input) {
  const formatted_input = input.split('\n').map(x => parseInt(x));

  var tmp_minimum=0;
  var result = 0;
  for(var i = 0;i<5;i++){
    result+=(formatted_input[i] - formatted_input[i]%10)
    if(formatted_input[i]%10!=0){
      if(tmp_minimum==0){
        tmp_minimum=formatted_input[i]%10
      }else{
        result+=10;
        tmp_minimum=Math.min(tmp_minimum,formatted_input[i]%10)
      }
    }
  }
  result+=tmp_minimum;

  console.log(result);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 7372
#include "bits/stdc++.h"
using namespace std;
using ll=long long;
#define print(n) cout<<n<<endl
#define rep(i,a,n) for(int i=a;i<n;i++)
#define ALL(s) s.begin(),s.end()
#define P pair<ll,ll>
#define vl vector<ll>
#define vi vector<int>
#define vvl vector<vector<ll>>
#define vvi vector<vector<int>>
const int M=100111;
const int inf=1000000007;
const long long INF=1e18;
int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};
int ddx[8]={1,-1,0,0,1,-1,-1,1},ddy[8]={0,0,1,-1,1,-1,1,-1};

struct UnionFind {
	vector<int> par;

	UnionFind(int n) : par(n, -1) { }
	void init(int n) { par.assign(n, -1); }

	int root(int x) {
		if (par[x] < 0) return x;
		else return par[x] = root(par[x]);
	}

	bool issame(int x, int y) {
		return root(x) == root(y);
	}

	bool merge(int x, int y) {
		x = root(x); y = root(y);
		if (x == y) return false;
		if (par[x] > par[y]) swap(x, y); // merge technique
		par[x] += par[y];
		par[y] = x;
		return true;
	}

	int size(int x) {
		return -par[root(x)];
	}
};

int main() {
	int n, m; cin >>n>>m;
	int x[M],y[M],z;
	for (int i = 0; i < m; ++i) cin >>x[i]>>y[i]>>z,x[i]--,y[i]--;
	UnionFind uf(n);
	for (int i = 0; i < m; ++i) uf.merge(x[i], y[i]);
	set<int> se;
	for (int i = 0; i < n; ++i) se.insert(uf.root(i));
	print(se.size());
}



	

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

import itertools

N = int(readline())
P = tuple(map(int,readline().split()))
Q = tuple(map(int,readline().split()))

permutations = list(itertools.permutations(range(1,N+1)))
p = permutations.index(P)
q = permutations.index(Q)

answer = abs(p - q)
print(answer)

Measured memory_bytes: 8052
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <climits>
#include <sstream>
using namespace std;
static const double EPS = 1e-5;
typedef long long ll;

set<int> app;

main(){
	int n;
	while(scanf("%d",&n)){
		if(n==0)break;
		
		app.clear();
		
		for(int i=1;i<n;i++){
			app.insert(i*i%n);
		}
		vector<int> vapp((n-1)/2);
		for(set<int>::iterator sp=app.begin();sp!=app.end();sp++){
			for(set<int>::iterator tsp=sp;tsp!=app.end();tsp++){
				if(sp==tsp)continue;
				int diff=*tsp-*sp;
				if(diff<0)diff+=n;
				if(diff>(n-1)/2)diff=n-diff;
				vapp[diff-1]+=2;
			}
		}
		for(int i=0;i<vapp.size();i++){
			cout<<vapp[i]<<endl;
		}
	}
}

Measured memory_bytes: 1064
/*---> praveenojha33 <---> 02 September 2019 <--- > 14:07:31 <---*/
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
// #pragma GCC optimize("unroll-loops")
// #pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define F first
#define S second
#define mod 1000000007
#define inf (int)1e18+5
#define sz(x) (int)x.size()
#define PI 3.141592653589793238510
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define __ ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define vi vector<int>
#define vpii vector<pair<int,int> > 
#define vvi vector<vector<int> >
#define PRINT_TIME cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s." <<endl;
#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__) << "] "
typedef long double ld;
typedef pair<int,int> pii;
///////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////
const int N=3005;
vvi dp;
int n;
vi a;
string s;
void add(int &aa,int b){
	aa+=b;
	if(aa>=mod)
		aa-=mod;
}
int32_t main(){__
	cin>>n;
	cin>>s;
	dp.resize(n+1,vi (n+1));
	dp[1][1]=1;
	for(int i=2;i<=n;i++){
		for(int j=1;j<=n;j++){
			add(dp[i-1][j],dp[i-1][j-1]);
		}
		for(int j=1;j<=i;j++){
			int le,ri;
			if(s[i-2]=='<')
				le=1,ri=j-1;
			else
				le=j,ri=i-1;
			add(dp[i][j],(dp[i-1][ri]-dp[i-1][le-1]+mod)%mod);

			// for(int k=1;k<=i-1;k++){
			// 	int prev=k;
			// 	if(prev>=j)
			// 		prev++;
			// 	if(s[i-2]=='<' && prev>j)
			// 		continue;
			// 	if(s[i-2]=='>' && prev<j)
			// 		continue;
			// 	add(dp[i][j],dp[i-1][k]);
			// }
		}
	}
	int ans=0;
	for(int i=1;i<=n;i++)
		add(ans,dp[n][i]);
	// debug()<< imie(dp);
	cout<<ans<<"\n";
return 0;
}

Measured memory_bytes: 70784
#include <iostream>

int main() {
  int N, M, X;
  std::cin >> N >> M >> X;

  int cz = 0, cn = 0;

  for (int i = 0; i < M; i++) {
    int m;
    std::cin >> m;

    if (m < X) {
      cz += 1;
    }

    if (m > X) {
      cn += 1;
    }
  }

  std::cout << std::min(cz, cn) << std::endl;
}


Measured memory_bytes: 256
n, m = map(int, input().split())
max = float("INF")
min = 0
for i in range(m):
    l, r = map(int, input().split())
    if max > r:
        max = r
    if min < l:
        min = l
if max - min + 1 >= 0:
    print(max - min + 1)
else:
    print(0)

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

#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define int long long
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())
#define pqasc priority_queue<long long, vector<long long>, greater<long long>>

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using ul = unsigned long;

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

class UnionFind{
private:
  vector<int> Parent; 
 public:
  UnionFind(int N){
    Parent = vector<int>(N, -1);
  }
  
  int root(int A){
    if(Parent[A] < 0) return A;
    return Parent[A] = root(Parent[A]);
  }
  
  int size(int A){
    return -Parent[root(A)]; 
  }
  
  bool connect(int A, int B){
    A = root(A);
    B = root(B);
    if(A == B){
      return false;
    }
    if(size(A) < size(B)) swap(A, B);
    Parent[A] += Parent[B];
    Parent[B] = A;
    return true;
  }
  
  bool isSame(int A, int B){
    return root(A) == root(B);
  }
};

int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { return a * b / GCD(a, b); }

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

inline bool inside(int y, int x, int H, int W) {
    return (y >= 0 && x >= 0 && y < H && x < W);
}

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  string s; cin>>s;
  int n=s.size();
  
  vi num(n+1,-1);
  int now=0;
  int ans=0;
  rep(i,n){
    ans+=now;
    num[i]=now;
    if(s[i]=='>'){
      now=0;
      continue;
    }
    now++;
  }
  if(s[n-1]=='<') ans+=now;
  // rep(i,n) cout<<num[i]<<" ";
  // cout<<endl;
  now=0;
  rrep(i,n){
    if(num[i+1]==-1){
      ans+=now;
      num[i+1]=now;
    }else{
      if(num[i+1]>=now){}
      else{
        ans+=now-num[i+1];
        num[i+1]=now;
      }
    }
    if(s[i]=='<'){
      now=0;
      continue;
    }
    now++;
  }
  if(s[0]=='>') ans+=now;
  // rep(i,n) cout<<num[i]<<" ";
  cout<<ans<<endl;
}


Measured memory_bytes: 4764
n = int(input())
a = [0]*60010

for i in range(1,101):
    for j in range(1,101):
        for k in range(1,101):
            s = i**2 + j**2 + k**2 + i*j + j*k + k*i
            a[s] = a[s] + 1

for m in range(1,n+1):
    print(a[m])


Measured memory_bytes: 9464
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.util.InputMismatchException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            String[] s = in.nextStringArray(n);

            int count = 0;
            out:
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < n; j++) {
                    for (int k = 0; k < n; k++) {
                        if (j == k) continue;

                        if (s[j].charAt((k + i) % n) != s[k].charAt((j + i) % n)) continue out;
                    }
                }
                count++;
            }

            count *= n;

            out.println(count);
        }

    }

    static class InputReader {
        BufferedReader in;
        StringTokenizer tok;

        public String nextString() {
            while (!tok.hasMoreTokens()) {
                try {
                    tok = new StringTokenizer(in.readLine(), " ");
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
            }
            return tok.nextToken();
        }

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

        public String[] nextStringArray(int n) {
            String[] res = new String[n];
            for (int i = 0; i < n; i++) {
                res[i] = nextString();
            }
            return res;
        }

        public InputReader(InputStream inputStream) {
            in = new BufferedReader(new InputStreamReader(inputStream));
            tok = new StringTokenizer("");
        }

    }
}



Measured memory_bytes: 26376
def has_path(start, goal):
    for step in range(start, goal):
        if (not isRoad[step]) and (not isRoad[step-1]):
            return False
    return True


N, A, B, C, D = map(int, input().split())
S = input()
isRoad = [True if c == "." else False for c in S]

if C <= B:      # すぬけ・ふぬけの二人が独立になっているとき
    if has_path(A, C) and has_path(B, D):
        print("Yes")
    else:
        print("No")
    exit()
elif C < D:    # ふぬけを動かしてからすぬけを動かせば良いとき
    if has_path(A, C) and has_path(B, D):
        print("Yes")
    else:
        print("No")
    exit()
else:       # どこかでふぬけがすぬけを追い越さなければいけない場合
    for i in range(B - 1, D):   # 追い抜く場所があるかどうかを探索
        if isRoad[i - 1] and isRoad[i] and isRoad[i + 1]:
            print("Yes")
            exit()
    print("No")

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

class Program
{
    static void Main(string[] args)
    {
        var N = int.Parse(ReadLine());
        var S = new List<string>();

        for (int i = 0; i < N; i++)
        {
            S.Add(ReadLine());
        }

        var q = S.GroupBy(x => x).ToDictionary(k => k.Key, v => v.Count());

        if (!q.ContainsKey("AC"))
            q.Add("AC", 0);
        if (!q.ContainsKey("WA"))
            q.Add("WA", 0);
        if (!q.ContainsKey("TLE"))
            q.Add("TLE", 0);
        if (!q.ContainsKey("RE"))
            q.Add("RE", 0);

        WriteLine($"AC x {q["AC"]}");
        WriteLine($"WA x {q["WA"]}");
        WriteLine($"TLE x {q["TLE"]}");
        WriteLine($"RE x {q["RE"]}");
    }
}


Measured memory_bytes: 35216
#include <stdio.h>

int main (void)
{
    int N, K;
    scanf("%d%d", &N, &K);
    int A[100000];
    int i;
    for (i = 0; i < N; i++) {
        scanf("%d", &A[i]);
    }
    int m = 0;
    if (N == 1) {
        printf ("%d", m);
        return 0;
    }
    N--;
    K--;
    do {
        m++;
    } while ((N -= K) > 0);

    printf ("%d", m);
    return 0;
}

Measured memory_bytes: 512
n, k = gets.strip.split.map(&:to_i)
hs = n.times.map { gets.strip.to_i }.sort { |a, b| b <=> a }

def ckmin(a, b) a < b ? a : b end

res = 10**9 + 1
n.times do |max_pos|
  min_pos = max_pos + k - 1
  break if min_pos >= n
  res = ckmin(res, hs[max_pos] - hs[min_pos])
end
puts res


Measured memory_bytes: 4596
"""

問題:
N 頂点 M 辺の重み付き有向グラフがあります。
i(1≦i≦M) 番目の辺は 頂点 ai から 頂点 bi を重み ciで結びます。
このグラフと駒を利用して、次の1人ゲームを行います。
最初、駒を頂点 1に置いて、プレイヤーのスコアを 0とします。
プレイヤーは、次の条件で駒を繰り返し移動させることができます。
- 頂点 aiに駒があるとき、i 番目の辺を利用して頂点 bi に移動する。移動後にプレイヤーのスコアが ci加算される。
頂点 Nに駒があるときのみ、ゲームを終了できます。
なお、与えられる有向グラフの上で頂点 1 から頂点 Nに移動できることは保障されています。
プレイヤーがゲーム終了時のスコアを出来るだけ大きくするような行動を取ったとき、ゲーム終了時のスコアはいくつになるでしょうか?
ゲーム終了時のスコアをいくらでも大きくできる場合は inf と出力してください。

制約:
- 2≦N≦1000
- 1≦M≦min(N(N−1),2000)
- 1≦ai,bi≦N(1≦i≦M)
- ai≠bi(1≦i≦M)
- ai≠ajまたは bi≠bj(1≦i<j≦M)
- −10 ** 9≦ci≦10 ** 9(1≦i≦M)
- ciは整数である。
- 与えられるグラフには、頂点 1から頂点 N への経路が存在する。

検討:
- 閉路が存在する場合、スコアをいくらでも大きくできる可能性がある
- 閉路を1周することで得られるスコア合計の符合によってinfにできるかどうかが判定可能
  - 符合が正: inf
  - 符合が0以下: 最短でNに到達したときのスコアが解
- 閉路が複数ある場合はどうするか
  - 1周したときに得られるスコア合計の符合が正かどうかで判断

必要な処理:
- 最短経路探索: ダイクストラ法? -> ベルマンフォード法（コストに正負があるため）
- 閉路を見つけ出す
- 閉路を1周したときのスコア合計

計算時間:
- ベルマンフォード法の時間計算量はO(NM)
- 解説通りにpythonで実装したらTLE判定...(約2100ms)
- 制約通りでいけば、NM = 1000 * 2000 = 2 * 10 ** 6
- 20msの化け物がいる...
"""

n, m = map(int, input().split())
edges = []
for _ in range(m):
    a, b, c = map(int, input().split())
    edges.append([a-1, b-1, -c])

inf = 10 ** 18
dist = [inf for _ in range(n)]
dist[0] = 0

for i in range(n-1):
    for a, b, c in edges:
        dist[b] = min(dist[b], dist[a] + c)

for i in range(n):
    for a, b, c in edges:
        if dist[a] + c < dist[b]:
            dist[b] = -inf

if -inf == dist[-1]:
    print("inf")
else:
    print(-dist[-1])


Measured memory_bytes: 3444
<?php

$sc = new Scanner();
$out = new Out();

$N = $sc->nextInt();
$D = $sc->nextInt();
$X = $sc->nextInt();

$cnt = $X;
for($i = 0; $i < $N; $i++) {
    $A[$i] = $sc->nextInt();
    $cnt += (int)(($D - 1) / $A[$i]) + 1;
}
$out->println($cnt);

class Scanner {
    private $arr = [];
    private $count = 0;
    private $pointer = 0;
    public function next() {
        if($this->pointer >= $this->count) {
            $str = trim(fgets(STDIN));
            $this->arr = explode(' ', $str);
            $this->count = count($this->arr);
            $this->pointer = 0;
        }
        $result = $this->arr[$this->pointer];
        $this->pointer++;
        return $result;
    }
    public function hasNext() {
        return $this->pointer < $this->count;
    }
    public function nextInt() {
        return (int)$this->next();
    }
    public function nextDouble() {
        return (double)$this->next();
    }
}
class Out {
    public static function println($str = "") {
        echo $str . PHP_EOL;
    }
}

Measured memory_bytes: 4604
#include<iostream>

using namespace std;

int main(){
  	char S[3],T[3];
  
  	for (int i = 0; i < 3; i++){
  		cin >> S[i];
    }
  	for (int i = 0; i < 3; i++){
  		cin >> T[i];
    }
  	int count = 0;
    for (int i = 0; i < 3; i++){
      if(S[i] == T[i]){
        count++;
      } 
    }
	cout << count;
	return 0;
}

Measured memory_bytes: 256
// ABC169-C
#include <bits/stdc++.h>
#define endl "\n"
#define rep(i,n) for(int i=0;i<int(n);i++)
#define SZ(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
//typedef pair<int, int> pair;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
namespace you {
    std::string to_string(char val) {
        return std::string(1, val);
        // return std::string{val};
        // you::to_string(char)
    }
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(12);

    ll a;
    string b;
    cin>>a>>b;
    ll c=(b[0]-'0')*100+(b[2]-'0')*10+(b[3]-'0');
    //cout<<c<<endl;
    ll ans=a*c/100;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3636
A=int(input())
B=int(input())
C=int(input())
X=int(input())
count=0
for amai in range(A+1):
  for bmai in range(B+1):
    for cmai in range(C+1):
      if (amai*500+bmai*100+cmai*50==X):
        count=count+1
print(count)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#define INF 1.0e9
using namespace std;
typedef long long ll;

int N;
char nagomi[3] = {'3', '5', '7'};

bool check(int n) {
    if (n < 357) return false;
    else {
        int memo[3] = {0, 0, 0};
        while (n > 0){
            if (n % 10 == 3) {
                memo[0]++;
                n /= 10;
            }
            else if (n % 10 == 5) {
                memo[1]++;
                n /= 10;
            }
            else if (n % 10 == 7) {
                memo[2]++;
                n /= 10;
            }
            else return false;
        }
        for (int i = 0; i < 3; i++){
            if (memo[i] == 0) return false;
        }
        return true;
    }
}

ll dfs(string n) {
    if (n != "") {    
        if (stoll(n) > N) return 0;
    }
    int ret = 0;
    if (n != "") {
        if (check(stoll(n))) ret++;
    }
    for (int i = 0; i < 3; i++){
        string newn = n;
        newn.push_back(nagomi[i]);
        ret += dfs(newn);
    }
    return ret;
}

int main() {
    cin >> N;
    ll ans = dfs("");
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<int> X(N);
  for(int i = 0; i < N; i++){
    cin >> X[i];
  }
  int L = X[0];
  int R = X[0];
  for(int i = 0; i < N; i++){
    L = min(L, X[i]);
    R = max(R, X[i]);
  }
  int ans = 1000000000;
  for(int i = L; i < R+1; i++){
    int cost = 0;
    for(int j = 0; j < N; j++){
      cost = cost + (X[j]-i)*(X[j]-i);
    }
    ans = min(ans, cost);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;

public static class P
{
    public static void Main()
    {
        var nmk = Console.ReadLine().Split().Select(int.Parse).ToArray();
        var n = nmk[0];
        var m = nmk[1];
        var k = nmk[2];
        var c = Enumerable.Repeat(0, n).Select(_ => Console.ReadLine().Split().Select(int.Parse).ToArray()).ToArray();
        int res = int.MaxValue;
        for (int i = 0; i < (1 << n); i++)
        {
            int price = 0;
            int[] a = new int[m];
            for (int j = 0; j < n; j++)
            {
                if ((i >> j & 1) == 1)
                {
                    price += c[j][0];
                    a = a.Zip(c[j].Skip(1), (x, y) => x + y).ToArray();
                }
            }
            if (a.All(x => x >= k)) res = Math.Min(res, price);
        }
        if (res == int.MaxValue) res = -1;
        Console.WriteLine(res);
    }
}


Measured memory_bytes: 38556
#include <stdio.h>
#include <algorithm>
using namespace std;

int N,X,A[111]; long long S;

int main()
{
	scanf ("%d %d",&N,&X);
	for (int i=0;i<N;i++) scanf ("%d",&A[i]), S += A[i];
	sort(A,A+N);

	if (S == X) printf ("%d\n",N);
	else{
		long long s = 0; int ans = 0;
		for (int i=0;i<N;i++){
			s += A[i];
			if (s <= X){
				if (i != N-1) ans = i + 1;
			}
		}
		printf ("%d\n",ans);
	}
	return 0;
}

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

using namespace std;

typedef long long ll;

long long test_cases;
int main()
{
    
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);

    /* cin >> test_cases; */
    test_cases = 1;
    ll n;
    vector <char> ans;
    char letras[27];
    while (test_cases > 0)
    {
        char ini = 'a';
        for (int i = 1; i < 27; i++)
        {
            letras[i] = ini;
            ini++;
        }

        letras[0] = 'z';
        letras[26] = 'z';

        cin >> n;
        ll number_letter;
        if (n > 26)
        {
            while (n > 26)
            {
                number_letter = n%26;
                ans.push_back(letras[number_letter]);
                if (n % 26 == 0)
                {
                    n/=26;
                    n-=1;
                }  
                else
                    n/=26; 
            }
    
            ans.push_back(letras[n%26]); 
        }
            
        else
            ans.push_back(letras[n]);

        string ans_str(ans.rbegin(), ans.rend());
        cout << ans_str << endl;
        
        test_cases--;
    }

    
    return 0;
}

Measured memory_bytes: 3656
package main

import "fmt"

var d = make([]bool, 10)

func check(n int) bool {
	for n > 0 {
		if d[n%10] {
			return false
		}
		n /= 10
	}
	return true
}

func main() {
	var n, k int
	fmt.Scan(&n, &k)

	var t int
	for i := 0; i < k; i++ {
		fmt.Scan(&t)
		d[t] = true
	}

	r := n
	for ; !check(r); r++ {
	}
	fmt.Println(r)
}

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

using namespace std;


int pow(int a, int n)
{
    if(n == 0) return 1;
    else return a * pow(a, n - 1);
}

int main()
{
    int D, N;

    scanf("%d %d", &D, &N);

    printf("%d\n", N != 100 ? N * pow(100, D) : (N + 1) * pow(100, D));

    return 0;
}

Measured memory_bytes: 256
N, K = map(int, input().split())
 
list_monster = list(map(int, input().split()))
list_monster.sort(reverse = True) 
 
if N <= K:
  print(0)
  
elif K == 0:
  print(sum(list_monster))
  
else:
  print(sum(list_monster[K:]))

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

namespace IO {
    inline LL read() {
        LL o = 0, f = 1; char c = getchar();
        while (c < '0' || c > '9') { if (c == '-') f = -1; c = getchar(); }
        while (c > '/' && c < ':') { o = o * 10 + c - '0'; c = getchar(); }
        return o * f;
    }
    inline char recd() {
        char o; while ((o = getchar()) != '1' && o != '0'); return o;
    }
}
using namespace IO;

char Map[233];

int main() {
	Map['b'] = 'd';
	Map['d'] = 'b';
	Map['p'] = 'q';
	Map['q'] = 'p';

	string str; cin >> str;
	for (int pos = 0; pos <= str.size() / 2; pos++)
		if (Map[str[pos]] != str[str.size() - 1 - pos]) {
			puts("No"); return 0;
		}
	puts("Yes");
}


Measured memory_bytes: 512
n = int(input())
l = sorted([input() for _ in range(n)])
x = l[0]
count = 0
score = 0
for s in l[1:]:
    if x==s:
        count+=1
    else:
        score+=count%2==0
        count=0
    x = s
score+=count%2==0
print(score)

Measured memory_bytes: 11488