akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;

namespace kyoupuro {

    class MainClass {

        public static void Main() {
            var N = Input.NextInt();
            var result = Input.NextLong();

            for (int i = 1; i < N; i++) {
                var t = Input.NextLong();

                result = (result / Gcd(result, t)) * t;
            }

            Console.WriteLine(result);
        }

        static long Gcd(long a, long b) {
            return b == 0 ? a : Gcd(b, a % b);
        }
    }

    class Input {
        static IEnumerator<string> enumerator = new string[] { }.AsEnumerable().GetEnumerator();

        public static string Line() {
            return Console.ReadLine();
        }

        public static int NextInt() {
            while (!enumerator.MoveNext()) {
                enumerator = StrArr().AsEnumerable().GetEnumerator();
            }
            return int.Parse(enumerator.Current);
        }

        public static long NextLong() {
            while (!enumerator.MoveNext()) {
                enumerator = StrArr().AsEnumerable().GetEnumerator();
            }
            return long.Parse(enumerator.Current);
        }

        public static string[] StrArr() {
            return Line().Split(' ');
        }

        public static List<int> IntList() {
            return StrArr().Select(int.Parse).ToList();
        }

        public static List<long> LongList() {
            return StrArr().Select(long.Parse).ToList();
        }

        public static void Skip(int line = 1) {
            enumerator.Reset();
            for (int i = 0; i < line; i++) Console.ReadLine();
        }

        public static void Reset() {
            enumerator.Reset();
        }
    }
}

Measured memory_bytes: 13268
#include <iostream>
#include <stack>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <functional>
#include <string>
#include <cstdlib>
#include <numeric>
#include <cstdbool>
#include <map> 
#include<set>
#include<queue>

typedef long long ll;


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

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

const long long INF = 1000000000000000;
const ll inf = -1e18;
typedef pair<int, int> P;
ll ma = 1000000000 + 7;
ll h, w, n,k,m; string s,t;
char maze[60][60];
int dis[101][101]; int graph[52][52]; bool vis[52];
int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, 1, 0, -1 };
ll gcd(ll x, ll y) {
	if (x % y == 0) return y;
	return gcd(y, x % y);

}
ll lcm(ll a,ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}

int main() {
	cin >> s;
	int s0 = s[0] - '0';
	int s1 = s[1] - '0';
	int s2 = s[2] - '0';
	int s3 = s[3] - '0';
	int ss1, ss2;
	ss1 = s0 * 10 + s1;
	ss2 = s2 * 10 + s3;
	if (ss1 <= 12 && ss2 <= 12&&ss1 != 0 && ss2 != 0) {
		cout << "AMBIGUOUS" << endl;
	}
	else if (ss1 <= 12 && ss2 > 12&&ss1!=0|| ss1 <= 12 && ss2 ==0 && ss1 != 0) {
		cout << "MMYY" << endl;
	}
	else if (ss1 > 12 && ss2 <= 12&&ss2!=0||(ss1==0&& ss2 <= 12 && ss2 != 0)) {
		cout << "YYMM" << endl;
	}
	else cout << "NA" << endl;
}

Measured memory_bytes: 256
(let ((n (read))
    (ans 0)
    (yakusu 0))

    (loop for i from 1 to n by 2 do
        (progn
        (setq yakusu 0)
        (loop for j from 1 while (<= (* j j) i) do
            (if (zerop (rem i j))
            (progn
                (incf yakusu)
                (if (not (= (* j j) i))
                    (incf yakusu)
                )
            )
            )
        )
        (if (= yakusu 8)
            (incf ans)
        )
        )
    )
    (princ ans )
)

Measured memory_bytes: 24368
#include <iostream>
using namespace std;
int data[] = {1, 5, 10, 50, 100, 500};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int sum = 0;
    for(int i = 0; i < 6; ++i){
        int cnt;
        cin >> cnt;
        sum += cnt * data[i];
    }
    
    cout << (sum >= 1000 ? 1 : 0) << endl;
}

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

#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, m, n) for(int i = (int)(m); i < (int)(n); ++i)

const int MOD = 998244353;

template <typename T>
T pow_mod(T n, T p, T m)  // (n^p) % m
{
    if(p == 0) return 1;
    if(p%2 == 1) return pow_mod<T>(n, p-1, m) * n % m;
    else{
        T tmp = pow_mod<T>(n, p/2, m) % m;
        return tmp * tmp % m;
    }
}

int main()
{
    int N, M, K;
    cin >> N >> M >> K;

    // M == 1 の場合、下の factor = 0 となって答えが 0 になるが、N == 1 or K == N-1 のときのみ違う
    if(M == 1 and(N == 1 or K == N-1)){
        cout << 1 << endl;
        return 0;
    }

    vector<long long> comb(K+1, 0);
    comb[0] = 1;
    FOR(i, 1, K+1){
        comb[i] = ((N-i)*comb[i-1])%MOD * pow_mod<long long>(i, MOD-2, MOD);
        comb[i] %= MOD;
    }

    long long ans = 0, factor = pow_mod<long long>(M-1, N-1, MOD);
    REP(k, K+1){
        ans += ((M*factor)%MOD*comb[k]) % MOD;
        ans %= MOD;
        factor *= pow_mod<long long>(M-1, MOD-2, MOD);
        factor %= MOD;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 4624
N = int(input())
s = []
for i in range(N):
    s.append(sorted(input()))
s.sort()

ans = 0
tmp = 1
for i in range(N-1):
    if s[i] == s[i + 1]:
        tmp += 1
    else:
        ans += tmp * (tmp-1) // 2
        tmp = 1
ans += tmp * (tmp-1) // 2
print(ans)

Measured memory_bytes: 24652
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;

namespace AtCoder.A
{
    public class Program
    {
        public static void Main() { var r = GetResult(); Debug.WriteLine(r); Console.Write(r); }

        private static object GetResult()
        {
            var N = ReadLong();
            if (N == 1)
            {
                return "Hello World";
            }
            var A = ReadLong();
            var B = ReadLong();
            return A + B;
        }

        #region Console.Read

        public static string ReadText() { return Console.ReadLine(); }
        public static List<string> ReadTexts() { return Console.ReadLine().Split(' ').ToList(); }
        public static long ReadLong() { return long.Parse(Console.ReadLine()); }
        public static (long, long) Read2Longs() { var ls = ReadLongs(); return (ls[0], ls[1]); }
        public static (long, long, long) Read3Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2]); }
        public static (long, long, long, long) Read4Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3]); }
        public static (long, long, long, long, long) Read5Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3], ls[4]); }
        public static List<long> ReadLongs() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList(); }

        #endregion
    }
}


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

int main()
{
	int n;
	cin >> n;
	int a[105];
	for(int i = 1; i <= n; i++){
		scanf("%d",&a[i]);
	}
	int num = 0;
	for(int i = 1; i <= n; i += 2){
		if(a[i] % 2 != 0)
			num++;
	}
	cout << num << endl;
	return 0;
}

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

using ll = int64_t;
#define int ll

#define FOR(i, a, b) for (int i = int(a); i < int(b); i++)
#define REP(i, b) FOR(i, 0, b)
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(x) x.begin(), x.end()

using pi = pair<int, int>;
using vi = vector<int>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  REP(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

ll read() {
  ll i;
  scanf("%" SCNd64, &i);
  return i;
}

void printSpace() { printf(" "); }

void printEoln() { printf("\n"); }

void print(ll x, int suc = 1) {
  printf("%" PRId64, x);
  if (suc == 1)
    printEoln();
  if (suc == 2)
    printSpace();
}

string readString() {
  static char buf[3341000];
  scanf("%s", buf);
  return string(buf);
}

char *readCharArray() {
  static char buf[3341000];
  static int bufUsed = 0;
  char *ret = buf + bufUsed;
  scanf("%s", ret);
  bufUsed += strlen(ret) + 1;
  return ret;
}

template <class T, class U> void chmax(T &a, U b) {
  if (a < b)
    a = b;
}

template <class T, class U> void chmin(T &a, U b) {
  if (b < a)
    a = b;
}

template <class T> T Sq(const T &t) { return t * t; }

const int mod = 1e9 + 7;

signed main() {
  int a, b, c, x;
  std::cin >> a >> b >> c >> x;
  int ans = 0;
  for (int i = 0; i <= a; i++) {
    for (int j = 0; j <= b; j++) {
      for (int k = 0; k <= c; k++) {
        int tmp = i * 500 + j * 100 + k * 50;
        if (tmp == x)
          ans++;
      }
    }
  }
  print(ans);
}


Measured memory_bytes: 256
from sys import stdin
input = stdin.readline
import math

def main():
    N = int(input())
    p = [list(map(int, input().split())) for _ in range(N)]
    s = 0.0
    for i in range(N - 1):
        for j in range(i + 1, N):
            s += math.sqrt((p[i][0] - p[j][0])**2 + (p[i][1] - p[j][1])**2)
    print(s*2/N)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include <iostream>

int main() {
	long long N, D, a, b, c = 0;
  	std::cin >> N >> D;
  	for ( int i = 0; i < N; i++ ) {
		std::cin >> a >> b;
      	if ( a*a + b*b <= D*D )
          	c++;
    }
  	std::cout << c << std::endl;
	return 0;
}


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

using namespace std;

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

    int arr[3], seven = 1, five = 2, i = 3;
    cin >> arr[0] >> arr[1] >> arr[2];
    while (i--) {
        if (arr[i] == 5)
            five--;
        else if (arr[i] == 7)
            seven--;
    }

    if (!five && !seven)
        cout << "YES\n";
    else
        cout << "NO\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=100010;
const ll mod=1e9+7;


int main(){
  int a,b; cin >> a;
  b = a/1.08;
  if(floor(b*1.08)==a){ cout << b <<endl; return 0;  }
  b++;
  if(floor(b*1.08)==a){ cout << b <<endl; } else {cout << ":(" <<endl;}
  return 0;   
}

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

int main() {
    int n;
    std::cin >>n;
    
    double a[n];
    for(int i=0;i<n;i++)cin>>a[i];
    
    double dp[n+1][n+1];
   
    for(int i=0;i<=n;i++)
    {
        for(int j=0;j<=n;j++)
        {
          // cout<<dp[i][j]<<" ";
          dp[i][j]=0;
        }
        //cout<<endl;
    }
    
    //  for(int i=0;i<=n;i++)
    // {
    //     for(int j=0;j<=n;j++)
    //     {
    //       cout<<dp[i][j]<<" ";
    //       //dp[i][j]=0;
    //     }
    //     cout<<endl;
    // }
    
    dp[0][0]=1;
    
    for(int i=1;i<=n;i++)
    {
        dp[i][0]=(1-a[i-1])*dp[i-1][0];
        for(int j=1;j<=i;j++)
        {
            dp[i][j]=a[i-1]*dp[i-1][j-1] + (1.0-a[i-1])*dp[i-1][j];
        }
    }
    
    //  for(int i=0;i<=n;i++)
    // {
    //     for(int j=0;j<=n;j++)
    //     {
    //       cout<<dp[i][j]<<" ";
    //       //dp[i][j]=0;
    //     }
    //     cout<<endl;
    // }
    double ans=0;
    for(int i=n/2+1;i<=n;i++)
    {
        ans+=dp[n][i];
    }
    
    cout<<setprecision(10)<<ans<<endl;
    
	return 0;
}

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

#define int long long int
#define MOD 1000000007

int dp[100005][5] ;

int32_t main()
{
    int t = 1 ;
    //cin >> t ;
    while(t--)
    {
       int n ;
       cin >> n ;
       int a[n][3] ;
       
       for(int i = 0 ; i < n ; i++)
       {
           for(int j = 0 ; j < 3 ; j++)
           {
               cin >> a[i][j] ;
               dp[i+1][j] = a[i][j] ;
           }
       }
       for(int i = 1 ; i <= n ; i++)
       {
           for(int j = 0 ; j < 3 ; j++)
           {
               if(j == 0)
               {
                   dp[i][j] = dp[i][j] + max(dp[i-1][1], dp[i-1][2]) ;
               }
               else if(j == 2)
               {
                   dp[i][j] = dp[i][j] + max(dp[i-1][0], dp[i-1][1]) ;
               }
               else
                   dp[i][j] = dp[i][j] + max(dp[i-1][0], dp[i-1][2]) ;
           }
       }
       int ans = 0 ;
       for(int i = 0 ; i < 3 ; i++)
           ans = max(ans, dp[n][i]) ;
       cout << ans << endl ;       
    }
    return 0 ;
}

Measured memory_bytes: 6528
#include <cstdio>
#include <cstring>
#include <cctype>
#include <algorithm>
#include <vector>
#include <numeric>
#include <stack>
#include <queue>
#include <functional>
#include <cmath>

using LL = long long;

const int maxN = (int)1e5 + 10;

int N;
LL C;
LL V[maxN]; LL VPref[maxN];
LL VC[maxN];LL VCPref[maxN];
LL X[maxN]; LL XC[maxN];

LL maxPref[maxN];
LL maxPrefC[maxN];

void input()
{
    scanf("%d%lld", &N, &C);
    for (int i = 1; i <= N; i++)
        scanf("%lld%lld", X + i, V + i);

    for (int i = 1; i <= N; i++)
    {
        XC[i] = C - X[N + 1 - i];
        VC[i] = V[N + 1 - i];
    }
    std::partial_sum(V, V + N + 1, VPref);
    std::partial_sum(VC, VC + N + 1, VCPref);
}

LL solve()
{
    LL ans = 0;
    for (int i = 1; i <= N; i++)
        maxPref[i] = std::max(maxPref[i - 1], VPref[i] - X[i]);

    for (int i = 1; i <= N; i++)
        maxPrefC[i] = std::max(maxPrefC[i - 1], VCPref[i] - XC[i]);

    ans = std::max(maxPref[N], maxPrefC[N]);

    for (int i = 1; i < N; i++)
    {
        ans = std::max(ans, VPref[i] - 2 * X[i] + maxPrefC[N - i]);
        ans = std::max(ans, VCPref[i] - 2 * XC[i] + maxPref[N - i]);
    }

    return ans;
}

int main()
{
    input();
    printf("%lld", solve());
    return 0;
}


Measured memory_bytes: 6400
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define RFOR(i,a,b) for(int i=(a);i>=(b);--i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define RREP(i,n) for(int i=(n);i>0;--i)
#define CI cin>>
#define CO cout<<
#define EN <<endl
#define all(x) (x).begin(),(x).end()
using namespace std;
template <typename T>
istream& operator>>(istream& is, vector<T>& vec) {
	for (T& x : vec) is >> x;
	return is;
}
typedef long long ll;


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

int main() {
	int n; CI n;
	int ali = 0, bob = 0;
	vector<int> a(n); CI a;

	sort(all(a), greater<int>());

	REP(i, n) {
		i % 2 == 0 ? ali +=a[i] : bob += a[i];
	}

	CO ali - bob EN;

	return 0;
}

Measured memory_bytes: 256
#pragma optimize("unroll-loops,no-stack-protector")
#include <bits/stdc++.h>
using namespace std;
// using namespace __gnu_pbds;
// #include <ext/pb_ds/assoc_container.hpp>
// typedef tree<int,null_type,less<int>,rb_tree_tag,
// tree_order_statistics_node_update> indexed_set;
#define f(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(ll i=a;i>=b;i--)
#define Max(a,b,c) max(a,max(b,c))
#define Min(a,b,c) min(a,min(b,c))
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define pc(x)  __builtin_popcount (x)
#define vl vector< ll >
#define sorts(v) sort(v.begin(),v.end())
#define sortg(v) sort(v.begin(),v.end(),greater<ll>())
#define ss second
#define ff first
#define ll long long
#define ld long double
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1e18)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod 1000000007
#define mem(x,y) memset(x,y,sizeof(x))
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >
#define flush fflush(stdout) 
#define gcd __gcd
#define primeDEN 727999983
#define nx_pe next_permutation(s.begin(),s.end())
#define cl cout<<"\n"
#define sp(x) setprecision(x)
const ll N=2e5+5;
map<pll,ll>mm;
ll n,m;
vector<ll>v[N];
ll ans=0;
ll sz=0;
bool vis[N];

void dfs(ll u)
{
    vis[u]=1;
    sz++;
    for(ll x:v[u])
    {
        if(!vis[x])
        {
            dfs(x);
        }
    }
}

void solve()
{
   cin>>n>>m;
   rep(i,m)
   {
       ll x,y;
       cin>>x>>y;
       if(mm.find({x,y})==mm.end())
       {
           v[x].pb(y);
           v[y].pb(x);
           mm[{x,y}]++;
           mm[{y,x}]++;
       }
   }
   f(i,1,n+1)
   {
       if(!vis[i])
       {
           sz=0;
           dfs(i);
           ans=max(ans,sz);
       }
   }
   cout<<ans<<"\n";
}


    
int main()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin) ;
    freopen("ouput.txt", "w", stdout) ;
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL) ; cout.tie(NULL) ;
    std::ios::sync_with_stdio(false);
    ll te=1;
    // cin>>te;
    while(te--){
        solve();
    }
    
}


Measured memory_bytes: 46032
#include <iostream>
#include <vector>

using namespace std;

int main(){
	int N;
	while(cin >> N){
		vector<int> a(N), b(N);
		for(int i=0;i<N;i++){
			a[i] = i+1;
			b[i] = N-i;
		}
		for(int i=0;i<N;i++){
			int p; cin >> p; --p;
			for(int j=0;j<p;j++) b[j] += N-i;
			for(int j=p+1;j<N;j++) a[j] += N-i;
		}
		for(int i=0;i<N-1;i++) cout << a[i] << " "; cout << a.back() << endl;
		for(int i=0;i<N-1;i++) cout << b[i] << " "; cout << b.back() << endl;
	}
}


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

int main()
{
    int n, b, f, r, v, i, j, k, a[4][3][10] = {};
    scanf("%d", &n);
    for (i = 0; i < n; i++)
    {
        scanf("%d %d %d %d", &b, &f, &r, &v);
        a[b - 1][f - 1][r - 1] += v;
    }

    for (i = 0; i < 4; i++)
    {
        if (i != 0)
            printf("####################\n");
        for (j = 0; j < 3; j++)
        {
            for (k = 0; k < 10; k++)
                printf(" %d", a[i][j][k]);
            printf("\n");
        }
    }
}


Measured memory_bytes: 3196
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define repit(it, li) for(auto it=li.begin(); it!=li.end(); it++)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main(){
   int n, m;
   cin>>n>>m;

   vector<int> wa(n);
   vector<bool> ac(n);
   int swa=0, sac=0;
   rep(i, m){
      int p;
      string s;
      cin>>p>>s;

      if(ac[p]) continue;
      if(s=="WA") wa[p]++;
      else{
         ac[p]=true;
         sac++;
         swa+=wa[p];
      }
   }

   cout<<sac<<" "<<swa<<endl;
   return 0;
}


Measured memory_bytes: 3764
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true) {
			double t1 = sc.nextDouble();
	        double s1 = sc.nextDouble();
	        double t2 = sc.nextDouble();
	        double s2 = sc.nextDouble();
	        if (t1 == -1 && s1 == -1 && t2 == -1 && s2 == -1) return;
			double r = 6378.1;
			double[] p = pr(t1,s1);
			double[] q = pr(t2,s2);
			double a = p[0] * q[0] + p[1] * q[1] + p[2] * q[2];
			double c = Math.acos(a);
	        double ans = r * c;
	        System.out.printf("%d\n", (int)(ans + 0.5));
		}
	}
	
	static double[] pr(double a, double b) {
		double x = Math.cos(b / 180.0 * Math.PI) * Math.cos(a / 180.0 * Math.PI);
        double y = Math.sin(b / 180.0 * Math.PI) * Math.cos(a / 180.0 * Math.PI);
        double z = Math.sin(a / 180.0 * Math.PI);
        return new double[]{x, y, z};
	}
	

}

Measured memory_bytes: 20548
n = int(input())
s = []
t = []
for i in range(n):
    si,ti = map(str,input().split())
    s.append(si)
    t.append(int(ti))
x = input()

ans = 0
for i in range(s.index(x)+1,n):
    ans += t[i]

print(ans)


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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
using P = pair<ll,ll>;
using ld=long double;

int main(){
    ll n;cin >>n;
    vector<ll>ans;
    for (int i = 1; i <=n; i+=2) {
        ll cnt=0;
        for (int j = 1; j <=n; ++j) {
            if(i%j==0)cnt++;
        }
        if(cnt==8)ans.push_back(i);
    }
    cout <<ans.size()<<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++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
int main()
{
    int N, A;
    cin >> N >> A;
    cout << N * N - A << endl;
    return 0;
}

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

int main() {
  int H, W;
  cin >> H >> W;
  vector<string> result(H + 2);
  string a(W + 2, '#');
  result[0] = a;
  for (int i = 0; i < H; ++i) {
    cin >> a;
    result[i + 1] = "#" + a + "#";
  }
  result[H + 1] = result[0];
  for (int i = 0; i < H + 2; ++i) {
    cout << result[i] << endl;
  }
  return 0;
}


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

// template {{{  0 
// using {{{ 1
using ll = long long int;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vii = vector<pii>;
using vll = vector<pll>;
// }}} 1
// definition {{{ 1
// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)
#define Scll(x) scanf("%lld", &x)
#define Scll2(x,y) scanf("%lld%lld", &x, &y)
#define Scll3(x,y,z) scanf("%lld%lld%lld", &x, &y, &z)
#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2
// constants {{{ 2
#define EPS (1e-7)
#define INF (2e9)
#define PI (acos(-1))
// }}} 2
// systems {{{ 2
#define Repe(x,y,z) for(ll x = z; x < y; x++)
#define Rep(x,y) Repe(x,y,0)
#define RRepe(x,y,z) for(ll x = y-z-1; x >= 0; x--)
#define RRep(x,y) RRepe(x,y,0)
// }}} 2
// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n")
#define YESNO(a) (a)?printf("YES\n"):printf("NO\n")
// }}} 2
// }}} 1
// input {{{ 1
// }}} 1
// }}} 0

struct E{
    int to,co;
};

int main() {

    int N,M;
    Scd2(N,M);

    int a,b,c;
    vector<vector<E>> e(N);
    Repe(i,N,1){
        e[i].push_back({i-1,0});
    }
    Rep(i,M){
        Scd3(a,b,c);
        a--,b--;
        e[a].push_back({b,c});
    }

    vl dist(N,1e17);
    dist[0] = 0;
    priority_queue<pll,vll,greater<pll>> q;
    q.push({0,0});
    while( q.size() ){
        int from = q.top().second; ll di = q.top().first; q.pop();
        for( E toe : e[from] ){
            int to = toe.to;
            ll co = toe.co;
            if( dist[to] > dist[from] + co ){
                // printf ("%d->%d\n", from, to );
                dist[to] =  dist[from] + co;
                q.push({dist[to],to});
            }
        }
    }

    printf ("%lld\n", dist[N-1]==1e17 ? -1 : dist[N-1] );

    return 0;
}







Measured memory_bytes: 8440
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();

		int answer = N * (N - 1) / 2 + M * (M - 1) / 2;

		System.out.println(answer);
	}
}

Measured memory_bytes: 23124
#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;
    int p = count(s.begin(), s.end(), '+');
    int m = count(s.begin(), s.end(), '-');
    cout << p - m << endl;;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		char[] s = sc.next().toCharArray();
		sc.close();

		int[] a = new int[4];
		for (int i = 0; i < 4; i++) {
			a[i] = s[i] - '0';
		}

		int end = 1 << 3;
		for (int i = 0; i < end; i++) {
			int val = a[0];
			StringBuilder sb = new StringBuilder();
			sb.append(s[0]);
			for (int j = 0; j < 3; j++) {
				if ((i >> j & 1) == 1) {
					val += a[j + 1];
					sb.append('+').append(s[j + 1]);
				} else {
					val -= a[j + 1];
					sb.append('-').append(s[j + 1]);
				}
			}
			if (val == 7) {
				sb.append("=7");
				System.out.println(sb.toString());
				return;
			}
		}
	}
}


Measured memory_bytes: 23764
#include<stdio.h>

int main(){
	int d;
	int ans = 0;
	int ss;
	int i;
	while(scanf("%d", &d) != EOF){
		for(i = 1; i <= (600 - d) / d; i++){
			ss = i * i * d * d * d;
			ans += ss;
		}
		printf("%d\n", ans);
		ans = 0;
	}
	return 0;
}

Measured memory_bytes: 596
import java.util.Arrays;
import java.util.Scanner;

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

		int n = sc.nextInt();
		long[][] task = new long[n][2];

		for (int i = 0; i < n; i++) {
			task[i][0] = sc.nextInt();
			task[i][1] = sc.nextInt();
		}

		Arrays.sort(task, (a, b) -> (Long.compare(a[1], b[1])));

		long sum = 0;
		for (int i = 0; i < n; i++) {
			sum += task[i][0];
			if (sum > task[i][1]) {
				System.out.println("No");
				sc.close();
				return;
			}
		}

		System.out.println("Yes");

		sc.close();
	}

}


Measured memory_bytes: 113380
#include<iostream>
#include<cstdio>
#include<map>
#include<vector>
#define fi first
#define se second
#define N 100100
using namespace std;

int n,a[N],b[N],cnt,ans,ta,tb,now,fa[N];
map<int,int>mm,ca,cb;
map<int,int>::iterator ia,ib;

int ff(int u){return u==fa[u]?u:fa[u]=ff(fa[u]);}
inline void in(int u){if(!mm[u]) mm[u]=++cnt;}

int main()
{
	int i,j,p,q;
	cin>>n;
	for(i=1;i<=n;i++) scanf("%d",&a[i]),ta^=a[i],fa[i]=i;ca[ta]++;
	for(i=1;i<=n;i++)
	{
		scanf("%d",&b[i]);
		if(b[i]!=a[i])
		{
			in(a[i]),in(b[i]);
			ca[a[i]]++;
			cb[b[i]]++;
			ans++;
		}
		tb^=b[i];
	}
	cb[tb]++;
	in(ta),in(tb);
	for(ia=ca.begin(),ib=cb.begin();ia!=ca.end();ia++,ib++)
	{
		if((*ia).fi!=(*ib).fi||(*ia).se!=(*ib).se)
		{
			puts("-1");
			return 0;
		}
	}
	for(i=1;i<=n;i++)
	{
		if(a[i]!=b[i])
		{
			fa[ff(mm[a[i]])]=ff(mm[b[i]]);
		}
	}
	if(ta!=tb) fa[ff(mm[ta])]=ff(mm[tb]);
	for(i=1;i<=cnt;i++) if(i==ff(i)) ans++;
	cout<<ans-1;
}

Measured memory_bytes: 17024
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define FAST ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);srand(time(NULL));
#define MOD 1000000007 
#define INF LONG_LONG_MAX
#define MINF LONG_LONG_MIN


ll po(ll x,ll n){
    if(n==0) return 1;
    else if(n%2 == 0) return po((x*x)%MOD,n/2);
    else return (x*po((x*x)%MOD,(n-1)/2))%MOD;
}

void solve(){
    double l;
    cin>>l;
    l = l/3.0;
    double ans = l*l*l;
    printf( "%.6lf", ans );
    return;
}

int main(){
    FAST;
    //init();
    ll t = 1;
    //cin>>t;
    while( t-- ) solve();
    return 0;
} 

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

int main() {
    long long N;
    cin >> N;
    string S;
    cin >> S;
    char pre=S.at(0);
    string res=""s+pre;
    for (long long i=1; i<N; i++) {
        if (S.at(i)!=pre) {
            res+=S.at(i);
            pre = S.at(i);
        }
    }
    cout << res.size() << endl;
}

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

int main() {
	long a, b, c;
	cin >> a >> b >> c;
	long k = (c - a - b) * (c - a - b);
	if (c - a - b < 0) cout << "No" << endl;
	else if (k > 4 * a * b) cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0; i<(n); ++i)
#define REPR(i,n,m) for (int i=(n); i>=(m); --i)
using namespace std;
using LL = long long;
using LD = long double;
using PLL = pair<long long, long long>;     // 
using PLD = pair<long double, long double>;
using VLL = vector<long long>;
using VLD = vector<long double>;
using VPLD = vector<PLD>;

const int INF = numeric_limits<int>::max();

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

    int n, m; cin >> n >> m;
    vector<PLL> p(m); REP(i,m) cin >> p[i].first >> p[i].second;

    sort(p.begin(), p.end());
    for (int i=0; i<m-1; i++) {
        if (p[i].first==p[i+1].first&&p[i].second!=p[i+1].second) {
            cout << "-1" << endl;
            return 0;
        }
    }

    for (int i=0; i<1000; i++) {
        string str = to_string(i);
        if (str.size()==n) {
            bool f = true;
            for (int j=0; j<m; j++) {
                if ((str[p[j].first-1]-'0')==p[j].second) ;
                else f = false;
            }
            if (f == true) {
                cout << str << endl;
                return 0;
            }
        }
    }

    cout << "-1" << endl;
    
    return 0;
}


Measured memory_bytes: 3740
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
#include <functional>
using namespace std;

int main()
{
    int n, k, x0;
    cin >> n >> k >> x0;
    if(x0 == 0){
        cout << 0 << endl;
        return 0;
    }

    unsigned long long x = x0;
    vector<int> cnt(128, 0);
    for(int i=0; i<n; ++i){
        unsigned long long y = x + LLONG_MAX + 1;
        ++ cnt[y / (ULLONG_MAX / 128)];
        x ^= x << 13;
        x ^= x >> 7;
        x ^= x << 17;
    }

    int index = 0;
    while(cnt[index] < k){
        k -= cnt[index];
        ++ index;
    }

    x = x0;
    vector<unsigned long long> v;
    for(int i=0; i<n; ++i){
        unsigned long long y = x + LLONG_MAX + 1;
        if(y / (ULLONG_MAX / 128) == index)
            v.push_back(y);
        x ^= x << 13;
        x ^= x >> 7;
        x ^= x << 17;
    }

    sort(v.begin(), v.end());
    long long ret = v[k-1] - LLONG_MAX - 1;
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 11292
/*
これを入れて実行
g++ code.cpp
./a.out
 */

#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <tuple>
#include <iomanip>

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

int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};

const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;

bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}

int gcd(int a, int b){
	if (b == 0)return a;
	return gcd(b, a % b);
}

//-----------------------ここから-----------


int main(void){
	int a, b, x;
	cin >> a >> b >> x;

	if(a > x || a + b < x){
		cout << "NO" << endl;
	} else {
		cout << "YES" << endl;
	}
}



Measured memory_bytes: 256
char S[12];
char out[2<<20];
int outsz,Slen;
main()
{
	int N,K;
	scanf("%d%d ",&N,&K);
	gets(S);
	Slen=strlen(S);
	S[Slen++]='\n';
	for(int i=0;i<K;i++)
	{
		memcpy(out+outsz,S,Slen);
		outsz+=Slen;
	}
	for(int i=K;i<N;i++)
	{
		out[outsz++]='7';
		out[outsz++]='\n';
	}
	write(1,out,outsz);
}

Measured memory_bytes: 2304
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int jud = n/2+1;
        if(n%2 == 0){
            jud--;
        }
        String ans = "NO";
        
        if(k <= jud){
            ans = "YES";
        }
        System.out.println(ans);
    }
}


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

#define rep(i, n) for(int i=0; i < n; i++)
#define reps(i, n) for(int i=1; i <= n; i++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()

using namespace std;
using ll=long long;

long mod=1e9+7;


int main() {
  string s;cin>>s;
  int n=s.size();
  ll ans=0;
  ll cw=0;
  rep(i,n){
    if(s[i]=='W'){
      ans+=i-cw;
      cw++;
    }
  }
  cout<<ans;
}



Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,a[1000],mx=0,ans=0;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		mx=max(mx,a[i]);
	}
	bool ok=true;
	for(int i=0;i<n;i++)
	{
		if(a[i]!=mx || !ok)
		ans+=a[i];
		else
		{
			ok=false;
			ans=ans+a[i]/2;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
n, x, y = map(int,input().split())
ans = [0]*(n-1)

for i in range(1,n):
    for j in range(i+1,n+1):
        if j <= x or y <= i:
            dist = j - i
        else:
            dist = j - i
            short = abs(x - i) + 1 + abs(y - j)
            dist = min(dist, short)
        ans[dist-1] += 1

for k in ans:
    print(k)

Measured memory_bytes: 3444
#include<bits/stdc++.h>
using namespace std;
int main(){
int a,b;
cin>>a>>b;
if(a==1&&b==2){
    cout<<3<<endl;
}
else if(a==1&&b==3){
    cout<<2<<endl;
}
else if(a==2&&b==1){
    cout<<3<<endl;
}
else if(a==2&&b==3){
    cout<<1<<endl;
}
else if(a==3&&b==1){
    cout<<2<<endl;
}
else if(a==3&&b==2){
    cout<<1<<endl;
}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
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(){
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    string c;
    cin >> c;
    int ans = 0;
    int l= 0;
    int r = c.size()-1;
    while(true) {
        while(c[l] == 'R' && l < r) l++;
        while(c[r] == 'W' && l < r) r--;
        if(l < r) ans++; else break;
        r--;
        l++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3784
open System
let readInt () = stdin.ReadLine() |> int
let readIntArray () = stdin.ReadLine().Split(' ') |> Array.map int

let N = readInt ()
let TXY : (int * int * int) [] = Array.zeroCreate (N + 1)
TXY.[0] <- (0, 0, 0)
for i in [1..N] do
    let [| x; y; z |] = readIntArray ()
    TXY.[i] <- (x , y , z)

let check (((t0, x0, y0) , (t1, x1, y1)) : (int * int * int) * (int * int * int)) =
    ((x0 + y0) % 2 = t0 % 2) && ((x1 + y1) % 2 = t1 % 2) && (Math.Abs(x0 - x1) + Math.Abs(y0 - y1) <= t1 - t0)

TXY
|> Array.pairwise
|> Array.map check
|> Array.reduce (&&)
|> (fun b -> if b then "Yes" else "No")
|> printfn "%s"

Measured memory_bytes: 31100
using System;
using System.Collections.Generic;
using System.Linq;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            ABC096_B();
        }

        static void ABC096_B()
        {
            var abc = Console.ReadLine().Split(' ').Select(int.Parse).ToList();
            var K = int.Parse(Console.ReadLine());

            var max = abc.Max();
            abc.Remove(max);
            for (var k = 1; k <= K; k++)
                max *= 2;
            Console.WriteLine(max + abc.Sum());
        }
    }
}

Measured memory_bytes: 13280
#include <stdio.h>

int main(void){
    int n;
    int tmp;
    int sum = 0;

    scanf("%d", &n);
    tmp = n;

    for(int i = 0; i < 9; i++){
        sum += tmp%10;
        tmp = tmp/10;
    }

    if(n % sum == 0){
        printf("Yes\n");
    }else{
        printf("No\n");
    }
    return 0;
}

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

int main(){
  int N,ans;
  cin>>N;
  ans=0;
  
  for(int i=1;i<N+1;i+=2){
    int count=0;
    for(int j=1;j<i+1;j++){
      if(i%j==0){
        count++;
      }
    }
    if(count==8){
      ans++;
    }
  }
  cout<<ans<<endl; 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const ll INF = LLONG_MAX;
int main()
{
    int n, m;
    cin >> n >> m;
    vector<int> k(m), p(m);
    vector<int> s(10);
    for (int i = 0; i < m; i++)
    {
        cin >> k[i];
        int hoge = 0;
        for (int j = 0; j < k[i]; j++)
        {
            int tmp;
            cin >> tmp;
            hoge += (1 << (tmp - 1));
        }
        s[i] = hoge;
    }
    for (int i = 0; i < m; i++)
    {
        cin >> p[i];
    }
    int ans = 0;
    for (int i = 0; i < (1 << n); i++)
    {
        int hoge = 0;
        for (int j = 0; j < m; j++)
        {
            int tmp = 0;
            int ka = s[j] & i;
            tmp = __builtin_popcount(ka);
            if (tmp % 2 == p[j])
            {
                hoge++;
            }
        }
        if (hoge == m)
        {
            ans++;
        }
    }
    cout << ans << endl;
}

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

int bola[105], robotA[105], robotB[105];

int main(){
	int banyak, koordinat, jarak = 0;
	scanf("%d", &banyak);
	scanf("%d", &koordinat);
	for(int i = 1; i <= banyak; i++){
		scanf("%d", &bola[i]);
		robotA[i] = 0;
		robotB[i] = koordinat;
		if(2 * abs(bola[i] - robotA[i]) < 2 * abs(bola[i] - robotB[i]))
			jarak += 2 * abs(bola[i] - robotA[i]);
		else
			jarak += 2 * abs(bola[i] - robotB[i]);
	}
	printf("%d\n",  jarak);
	return 0;
}

Measured memory_bytes: 256
# coding: utf-8 
#Author:Code
s = raw_input()
arr = []
for i in range(4):
    if s[i] not in arr:
        arr.append(s[i])

if len(arr) != 2:
    print "No"
else:
    a = 0
    b = 0
    for i in range(4):
        if s[i] == arr[0]:
            a = a + 1
        elif s[i] == arr[1]:
            b = b + 1
    if a == 2 and b == 2:
        print "Yes"
    else:
        print "No"

Measured memory_bytes: 2568
#include<stdio.h>
#include<algorithm>
using namespace std;
int main(){
  int n;
  scanf("%d",&n);
  int a[101],ans=0;
  for(int i=0;i<n;i++){
    scanf("%d",&a[i]);
  }
  sort(a,a+n);
  reverse(a,a+n);
  for(int i=0;i<n&&ans==i;i++){
    if(i<a[i]) ans++;
  }
  printf("%d\n",ans);
  return (0);
}

Measured memory_bytes: 2724
import java.util.Scanner

var max=2020L
val mod=2019L
fun main(args:Array<String>){
    val sc=Scanner(System.`in`)
    var L=sc.nextLong()
    var R=sc.nextLong()

    for( i in (L+1)..Math.min(L+2019,R)){
        for(j in L..(i-1)){
            max=Math.min(max,i*j%mod)
        }
    }
    println(max)
}

Measured memory_bytes: 31516
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    s = input()
    l = len(s)

    from collections import Counter
    counter = Counter()
    prev = 0
    counter[0] += 1

    for i in range(l):
        num = int(s[l - i - 1])
        m = (num * pow(10, i, 2019) + prev) % 2019
        counter[m] += 1
        prev = m

    ans = 0
    for i in range(2019):
        cnt = counter[i]
        ans += cnt * (cnt - 1) // 2

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 68944
#include <iostream>
#define rep(i,to) for(int i=0;i<to;i++)
using namespace std;

int w,h;
int f[51][51];

int di[] = { 0, 0, 1, 1, 1,-1,-1,-1};
int dj[] = { 1,-1, 0, 1,-1, 0, 1,-1};

void dfs(int i,int j){
	f[i][j] = 0;
	rep(k,8){
		int ni = i + di[k];
		int nj = j + dj[k];
		if(ni>=0 && ni<h && nj>=0 && nj<w && f[ni][nj]==1)
			dfs(ni,nj);
	}
}

int main(void){
	while(cin>>w>>h && (w||h)){
		rep(i,h) rep(j,w) cin>>f[i][j];

		int ans = 0;
		rep(i,h) rep(j,w) if(f[i][j]==1) { dfs(i,j); ans++;}
		cout<<ans<<endl;
	}

	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <set>
#include <map>
#include <cassert>
#include <queue>
#include <ctime>
#include <string>
#include <cstring>
#define mp make_pair
#define pb push_back
#define NAME ""
#define y1 y1_423
#define list lista

using namespace std;

typedef long long ll;
typedef long double ld;

template<typename T>
ostream& operator << (ostream& cout, const vector<T> &a) {
	if ((int)a.size() == 0) {
		return (cout << "()");
	}
	cout << "(" << a[0];
	for (int i = 1; i < (int)a.size(); i++) {
		cout << "; " << a[i];
	}
	return (cout << ")");
}

template<typename T>
ostream& operator << (ostream& cout, const set<T> &a) {
	if ((int)a.size() == 0) {
		return (cout << "{}");
	}
	auto it = a.begin();
	cout << "{" << *it;
	++it;
	for (; it != a.end(); ++it) {
		cout << "; " << *it;
	}
	return (cout << "}");
}

template<typename T>
ostream& operator << (ostream& cout, const multiset<T> &a) {
	if ((int)a.size() == 0) {
		return (cout << "{}");
	}
	auto it = a.begin();
	cout << "{" << *it;
	++it;
	for (; it != a.end(); ++it) {
		cout << "; " << *it;
	}
	return (cout << "}");
}

template<typename T1, typename T2>
ostream& operator << (ostream& cout, const pair<T1, T2> &a) {
	return cout << "(" << a.first << "; " << a.second << ")";
}

const int nmax = 2000 * 1000;
const int inf = 2000 * 1000 * 1000;
const ll infl = 1000ll * 1000ll * 1000ll * 1000ll * 1000ll * 1000ll;
const int mod = 1000 * 1000 * 1000 + 7;
const ld pi = acos(-1.0);

int used[nmax], c1[nmax], cnt[nmax], ans[nmax];
vector<int> a[nmax], go[nmax];
int n, k, l, x, y;

void dfs(int v, int color) {
	used[v] = true;
	go[color].pb(v);
	for (int u : a[v]) {
		if (!used[u]) {
			dfs(u, color);
		}
	}
}

void dfsa(int v, int color) {
	used[v] = true;
	c1[v] = color;
	for (int u : a[v]) {
		if (!used[u]) {
			dfsa(u, color);
		}
	}
}

int main() {
	//freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
	//freopen(NAME".in", "r", stdin);freopen(NAME".out", "w", stdout);
	cin >> n >> k >> l;
	for (int i = 0; i < k; i++) {
		scanf("%d%d", &x, &y);
		x--, y--;
		a[x].pb(y);
		a[y].pb(x);
	}
	int top = 0;
	for (int i = 0; i < n; i++) {
		if (!used[i]) {
			dfs(i, top);
			top++;
		}
	}
	for (int i = 0; i < n; i++) {
		a[i].clear();
		used[i] = false;
	}
	for (int i = 0; i < l; i++) {
		scanf("%d%d", &x, &y);
		x--, y--;
		a[x].pb(y);
		a[y].pb(x);
	}
	int topa = 0;
	for (int i = 0; i < n; i++) {
		if (!used[i]) {
			dfsa(i, topa);
			topa++;
		}
	}
	for (int i = 0; i < top; i++) {
		for (int u : go[i]) {
			cnt[c1[u]]++;
		}
		for (int u : go[i]) {
			ans[u] += cnt[c1[u]];
		}
		for (int u : go[i]) {
			cnt[c1[u]]--;
		}
	}
	for (int i = 0; i < n; i++) {
		printf("%d ", ans[i]);
	}
	return 0;
}


Measured memory_bytes: 106232
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const ll inf =1LL << 62;
const ll mod=1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b,const ll &mod) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b,const ll &mod) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b,const ll &mod) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b,const ll &mod) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
random_device rd;
mt19937 mt(rd());
uniform_int_distribution<int> dice(1,6);
uniform_real_distribution<double> score(0.0,10.0);

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

    int n; cin >> n;
    vll a(n); for(auto& e : a) cin >> e;

    ll res = 0;
    while(true){
        ll num = 0;
        rep(i, n){
            num += a[i] / n;
        }
        res += num;
        bool ok = true;
        rep(i, n){
            a[i] -= (a[i] / n) * (n + 1);
            a[i] += num;
            if(a[i] >= n) ok = false;
        }
        if(ok) break;
    }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 512
def main ():
	N = int(input())
	A = list(map(int,input(). split ()))
	if 0 in A:
		print(0)
		return
	prod = 1
	for a in A:
		prod *= a
		if prod > 1000000000000000000:
			print(-1)
			return
	print(prod)
main ()

Measured memory_bytes: 21588
#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
#define pi pair<int ,int >
#define pl pair<ll ,ll >
#define pb push_back
#define vl vector <long long int >
#define vi vector <int >
#define vp vector <pi>
#define mod 1000000007
#define eps 1e-9
#define fi first
#define se second
#define all(x) x.begin(), x.end()
#define _ <<" "<<
#define forn(x,	n) for(int x = 0; x < n ;++ x) 
#define forn1n(x,n) for(int x = 1; x <= n ;++ x)
#define forn1(x,n) for(int x = 1; x < n ;++ x)
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#pragma GCC optimize ("Ofast")
void scan(){}
template<typename F, typename... R> void scan(F &f,R&... r){cin>>f;scan(r...);}
int di_; string dnms_, co_ = ",";
void debug_(){cout<<endl;}
template<typename F, typename... R> void debug_(F &f, R&... r){while(dnms_[di_] != ',')cout<<dnms_[di_++];di_++;cout<<": "<<f<<",";debug_(r...);}
#define debug(...) dnms_=#__VA_ARGS__+co_,di_=0,debug_(__VA_ARGS__)

template<class A, class B> ostream& operator<<(ostream& out, const pair<A, B> &a){
    return out<<"("<<a.first<<","<<a.second<<")";}
template<class A> ostream& operator<<(ostream& out, const vector<A> &a){
	out<<"";for(auto it=a.begin();it!=a.end();it++){if(it!=a.begin())out<<" ";out<<*it;}out<<"";
	return out;}
template<class A, class B> istream& operator>>(istream& in, pair<A,B> &a){in>>a.first>>a.second;return in;}
template<class A> istream& operator>>(istream& in, vector<A> &a){for(A &i:a)in>>i;return in;}

int main(){
	IOS

	int n;
	cin>>n;
	vi a(n);
	vi b(n);
	vi c(n-1);
	cin>>a>>b>>c;

	int sum=b[a[0]-1];

	forn1(i,n)
	{
		sum += b[a[i]-1];
		if(a[i]==a[i-1]+1)
			sum+=c[a[i-1]-1];
	}
	cout<<sum;
 
	return 0;	
}

Measured memory_bytes: 384
import java.util.*;
class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int s = sc.nextInt();
        int h = s/3600;
        int m = (s-h*3600)/60;
        int s1 = s-h*3600-m*60;
        System.out.println(h+":"+m+":"+s1);
    }
}



Measured memory_bytes: 26304
import sys
from math import gcd
from copy import deepcopy

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


def lcm(a, b):
    return a * b // gcd(a, b)


def resolve():
    n, m = map(int, input().split())
    A = list(map(int, input().split()))

    A_ = deepcopy(A)
    cnt = [0] * n
    for i in range(n):
        while A_[i] % 2 == 0:
            A_[i] //= 2
            cnt[i] += 1
        if i != 0 and cnt[i] != cnt[i - 1]:
            print(0)
            exit()

    L = 1
    for a in A:
        L = lcm(L, a // 2)

    res = m // L - (m // (L * 2))
    print(res)


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 21024