akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#define SIZE 18
#define BT (1<<18)
#define MX 100005
#define MOD 1000000007

using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

ll fac[MX],finv[MX],inv[MX];
int A[SIZE];
ll dp[2][BT];

void make()
{
	fac[0]=fac[1]=1;
	finv[0]=finv[1]=1;
	inv[1]=1;
	for(int i=2;i<MX;i++)
	{
		inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
		fac[i]=fac[i-1]*(ll) i%MOD;
		finv[i]=finv[i-1]*inv[i]%MOD;
	}
}
ll C(int a,int b)
{
	if(a<b) return 0;
	return fac[a]*(finv[b]*finv[a-b]%MOD)%MOD;
}
int main()
{
	make();
	int n,m;
	scanf("%d %d",&n,&m);
	for(int i=0;i<m;i++) scanf("%d",&A[i]);
	int pos=0;
	memset(dp[pos],0,sizeof(dp[pos]));
	dp[pos][0]=1;
	for(int i=m-1;i>=0;i--)
	{
		pos^=1;
		memset(dp[pos],0,sizeof(dp[pos]));
		for(int S=0;S<1<<n;S++)
		{
			if(dp[pos^1][S]==0) continue;
			dp[pos][S]+=dp[pos^1][S];
			if(dp[pos][S]>=MOD) dp[pos][S]-=MOD;
			int zan=(1<<n)-A[i]+1;
			for(int j=0;j<n;j++) if(S>>j&1) zan-=(1<<j);
			for(int j=0;j<n;j++)
			{
				if(!(S>>j&1)&&zan>=(1<<j))
				{
					dp[pos][S|(1<<j)]+=dp[pos^1][S]*C(zan-1,(1<<j)-1)%MOD*fac[1<<j]%MOD;
					if(dp[pos][S|(1<<j)]>=MOD) dp[pos][S|(1<<j)]-=MOD;
				}
			}
		}
	}
	ll all=0;
	for(int S=0;S<1<<n;S++)
	{
		ll way=dp[pos][S];
		int zan=(1<<n)-1;
		int sgn=1;
		for(int i=0;i<n;i++)
		{
			if(S>>i&1)
			{
				zan-=(1<<i);
				sgn*=-1;
			}
		}
		way=way*fac[zan]%MOD;
		//if(way!=0) printf("%d %lld\n",S,way);
		all+=(ll) sgn*way;
		all+=MOD;
		all%=MOD;
	}
	printf("%lld\n",all*(1<<n)%MOD);
	return 0;
}


Measured memory_bytes: 6656
#include <bits/stdc++.h> 
#include <time.h>
#define F(i,a,b) for(long long i=a;i<=(b);++i)
#define dF(i,a,b) for(long long i=a;i>=(b);--i)
#define inf 0x3f3f3f3f
#define infll 0x3f3f3f3f3f3f3f3f
#define pb push_back
#define maxnkp make_pair
#define fi first
#define se second
#define eps 1e-10
using namespace std;
typedef long long ll;
const int mods = 1e9+7;
const int maxn = 2e5+10;
const int N = 1e5+10;
const int E = 1e5+10;  
ll n,m,k;

ll qpow(ll n,ll b){
	ll res = 1;
	while(b){
		if(b&1) res = n*res;
		n = n*n;
		b>>=1;
	} 
	return res;
} 

int main(){
	cin>>k;
	F(i,0,1000){
		F(j,-1000,1000){
			if(qpow(i,5)-qpow(j,5)==k){
				cout<<i<<" "<<j<<endl;
				return 0;
			}
		}
	}	
}


Measured memory_bytes: 3588
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.StringReader;
import java.util.StringTokenizer;

public class Main  implements Runnable {
	int[][] ta = new int[16][4096];
	int ptr = 0;
    public static void main(String[] args) {
        new Thread(null, new Main(), "", 64 * 1024 * 1024).start();
    }

    public void run() {
    	FastScanner sc = new FastScanner(System.in);
    	//int[] ar = new int[3];
    	//ar[0]=Integer.parseInt(sc.next());
    	//Arrays.parallelSort(ar);
		int n = Integer.parseInt(sc.next());
		//long a = Long.parseLong(sc.next());
		//String s = sc.next();
		//String str = sc.next();
		//char c[] = str.toCharArray();
		//char a[][] = new char[n];
		//ArrayList<Str_4> lists = new ArrayList<Str_4>();
		//lists = new ArrayList;
		PrintWriter out = new PrintWriter(System.out);
		//int[] ra = new int[r];
		//ArrayList<ArrayList<Integer>> lists = new ArrayList<>();
		int [] a = new int [n+1];
		int [] b = new int [n];
		for(int i = 0; i < n+1; i++)
		{
			a[i] = Integer.parseInt(sc.next());
		}
		long ans = 0;
		for(int i = 0; i < n; i++)
		{
			b[i] = Integer.parseInt(sc.next());
			if(b[i] < a[i])
			{
				ans += b[i];
			}
			else
			{
				ans += a[i];
				b[i] -= a[i];
				if(b[i] < a[i+1])
				{
					ans += b[i];
					a[i+1] -= b[i];
				}
				else
				{
					ans += a[i+1];
					a[i+1] = 0;
				}
			}
		}
		
		out.println(ans);
		out.flush();
    }

    static class FastScanner {
        private BufferedReader reader = null;
        private StringTokenizer tokenizer = null;
        public FastScanner(String in) {
        	StringReader sr = new StringReader(in);
            reader = new BufferedReader(new BufferedReader(sr));
            tokenizer = null;
        }
        public FastScanner(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
            tokenizer = null;
        }

        public String next() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public String nextLine() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    return reader.readLine();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }

            return tokenizer.nextToken("\n");
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public long nextInt() {
            return Integer.parseInt(next());
        }

    }
}

Measured memory_bytes: 48376
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long n,i;
    cin>>n;
    long long a[n+1];
    for(i=1;i<=n;i++) cin>>a[i];
    sort(a+1,a+n+1);
    for(i=2;i<=n;i++)
    {
        if(a[i]==a[i-1])
        {
            cout<<"NO";
            return 0;
        }
    } cout<<"YES";
}


Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <vector>

using namespace std;
int main() {
  int N;
  cin >> N;
  //int D[N][2] = {{ 0 }};
  //int C[N] = {0};
  vector<vector<int>> D(N, vector<int>(2));
  vector<int> C(N);
  for(int i=0; i<N; i++){
    cin >> D[i][0] >> D[i][1];
    if(D[i][0] == D[i][1]){
      C[i] = 1;
    }
  }
  
  //check if there is doubles in 3 sequences
  int count_match = 0;
  for(int i=0; i<N; i++){
    if(C[i] == 1){
      count_match++;
      if(count_match == 3) break;
    }else{
      count_match = 0;
    }
  }
  
  if(count_match == 3) cout << "Yes";
  else cout << "No";
  cout << endl;
}

Measured memory_bytes: 3124
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define pi pair<ll, ll>
#define mp make_pair
#define pb push_back
#define vi vector<ll>
#define pd pair<double, double>
#define vp vector<pi>
#define f(i, n) for(int i = 0; i < n; i++)
#define fo(i, a, n) for(int i = a; i < n; i++)
#define mod (1000*1000*1000+7)
#define sz(x) int((x).size())
#define all(x) x.begin(),x.end()
#define DBG(v) cerr << #v << " = " << (v) << endl;
ll INF = (1ll<<62);

using namespace std;

int main(int argc, char* argv[])
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int n; cin >> n;
	cout << fixed << setprecision(20) << 1 - ((n/2)/ (1.0*n)) << endl;

    return 0;
}


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

int main() {
	int n;
	cin >> n;
	int h[n], dp[n];
	for (int i=0; i<n; i++) { cin >> h[i]; }

	dp[0] = 0;
	dp[1] = abs(h[1] - h[0]);
	for (int i=2; i<n; i++) {
			dp[i] = min(
					dp[i-2] + abs(h[i-2] - h[i]),
					dp[i-1] + abs(h[i-1] - h[i])
			);
	}
	cout << dp[n-1] << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <stdio.h>
#include <vector>
#include <cstring>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <utility>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>

#include <chrono>

#define INF 1e9
#define nmax 200010
#define fst first
#define snd second
#define pb push_back
#define SZ(x) ((int)(x.size()))

#define MOD 1000000007

#define MOD1 998244353
#define MOD2 666013
#define P1 255
#define P2 2059

using namespace std;
using namespace std::chrono;

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

int n, s;
int a[3010], dp[3010][3010][3];

int f(int x)
{
    if (x >= MOD1) return x - MOD1; else
        return x;
}

int main()
{
    scanf("%d %d", &n, &s);

    for (int i = 1; i <= n; i++) scanf("%d", &a[i]);

    dp[0][0][0] = 1;

    for (int i = 0; i <= n; i++)
        for (int j = 0; j <= s; j++) {

            dp[i + 1][j][0] = f(dp[i + 1][j][0] + dp[i][j][0]);
            dp[i + 1][j][1] = f(dp[i + 1][j][1] + f(dp[i][j][0] + dp[i][j][1]));
            dp[i + 1][j][2] = f(dp[i + 1][j][2] + f(f(dp[i][j][0] + dp[i][j][1]) + dp[i][j][2]));

            if (j + a[i + 1] <= s) {

                dp[i + 1][j + a[i + 1]][1] = f(dp[i + 1][j + a[i + 1]][1] + f(dp[i][j][0] + dp[i][j][1]));
                dp[i + 1][j + a[i + 1]][2] = f(dp[i + 1][j + a[i + 1]][2] + f(dp[i][j][0] + dp[i][j][1]));
            }
        }

    printf("%d", dp[n][s][2]);

    // IMPORTANT!!!!!
    // Are you missing something????
    // check limits, int or ll

    return 0;
}

Measured memory_bytes: 106112
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
#define SortAsc(c) std::sort(c.begin(), c.end())
#define SortDesc(c) std::sort(c.rbegin(), c.rend())
int dx[8] = {0, 1, 0, -1, 1, 1, -1, -1};
int dy[8] = {1, 0, -1, 0, 1, -1, 1, -1};

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

  vector<bool> okashi(N, false);
  for (int i = 0; i < K; i++) {
    int d;
    cin >> d;
    for (int j = 0; j < d; j++) {
      int a;
      cin >> a;
      okashi[a - 1] = true;
    }
  }
  int res = 0;
  for (int i = 0; i < N; i++) {
    if (!okashi[i]) res++;
  }

  cout << res << endl;
}

Measured memory_bytes: 3628
#include <stdio.h>

int main() {
    int n;
    scanf("%d", &n);
    
    int vec[n];
    for (int i = 0; i < n; ++i)
        scanf("%d", &vec[i]);
    long long res = 0;
        
    for (int i = 0; i < n-1; ++i){
        if (vec[i+1] < vec[i]){
            res += vec[i] - vec[i+1];
            vec[i+1] = vec[i];
        }
    }
    
    printf("%lld\n", res);
    
    
    return 0;
}


Measured memory_bytes: 2444
function Main(input) {
    input = input.trim();
    const n = parseInt(input, 10);
    const alpha = ['z','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'];

    let ans = '';
    let m = n;
    while(m>26){
        ans = alpha[m%26] + ans;
        if(m%26 === 0) {
            m = parseInt(m/26 -1, 10);
        } else{
            m = parseInt(m/26, 10);
        }
    }
    ans = alpha[m] + ans;
    console.log(ans);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 29656
def gcd(x: int, y: int):
    if x < y:
        x, y = y, x
    if y == 0:
        return x
    return gcd(x % y, y)

N = int(input())
A = list(map(int, input().split()))
L = [A[0]]
R = [A[N - 1]]

for i in range(N - 1):
    L.append(gcd(L[i], A[i + 1]))
    R.append(gcd(R[i], A[N - i - 2]))

R.reverse()

ans = 0
for i in range(0, N):
    if i == 0:
        ans = max(ans, R[i + 1])
    elif i == N -1:
        ans = max(ans, L[i - 1])
    else:
        ans = max(ans, gcd(L[i - 1], R[i + 1]))

print(ans)


Measured memory_bytes: 14432
#include<iostream>
using namespace std;
int main()
{
    int n;
    cin >> n;
    
    int l, m, r;
    cin >> l >> m;
    int count = 0;
    for (int i = 0; i < n-2; i++) {
      cin >> r;
      if ((l < m && m < r) || (l > m && m > r)) {
        count++;
      }
      l = m;
      m = r;
    }
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 256
#-swank
(unless (member :child-sbcl *features*)
  (quit
   :unix-status
   (process-exit-code
    (run-program *runtime-pathname*
                 `("--control-stack-size" "128MB"
                   "--noinform" "--disable-ldb" "--lose-on-corruption" "--end-runtime-options"
                   "--eval" "(push :child-sbcl *features*)"
                   "--script" ,(namestring *load-pathname*))
                 :output t :error t :input t))))
(defmacro dp (name args memo-size &body body)
  (let ((memo (gensym)))
    `(let ((,memo (make-array ,memo-size :initial-element nil)))
       (defun ,name ,args
         (or (aref ,memo ,@args)
             (setf (aref ,memo ,@args)
                   ,@body))))))

(defun split (x str)
  (let ((pos (search x str))
        (size (length x)))
    (if pos
      (cons (subseq str 0 pos)
            (split x (subseq str (+ pos size))))
      (list str))))

(defmacro collect-times (time body)
  `(loop repeat ,time collect ,body))

(defun read-times (time)
  (collect-times time (read)))

(defun main (str)
  (count #\1 str))

(defun main (a b c x)
  (loop for i from 0 to a
        sum
        (loop for j from 0 to b
              sum
              (let ((rem (- x (* i 500) (* j 100))))
                (if (zerop (mod rem 50))
                    (if (>= c (/ rem 50) 0) 1 0)
                    0)))))

(princ (main (read) (read) (read) (read)))


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

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

    vector<ll> ans(n,k);

    for(int i=0; i<q; i++){
        int a; cin>>a;
        ans[a-1]++;
    }

    for(int i=0; i<n; i++){
        if(ans[i] - q > 0) cout<<"Yes"<<endl;

        else cout<<"No"<<endl;
    }

    return 0;
    
}

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

using namespace std;

int mod = 1e9 + 7;

int find(int a, vector<int>& group) {
    if (a == group[a]) return a;
    return find(group[a], group);
}

void unite(int group_a, int group_b, vector<int>& group, vector<int>& rank) {
    if (rank[group_a] < rank[group_b]) swap(group_a, group_b);
    group[group_b] = group_a;
    rank[group_a] += rank[group_b];
    return;
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    // N-1 -(built edges)
    int N, M, a, b;
    cin >> N >> M;
    vector<int> group(N + 1);
    for (int i = 0; i <= N; i++) {
        group[i] = i;
    }
    vector<int> rank(N + 1, 0);
    int cnt = 0;
    for (int j = 0; j < M; j++) {
        cin >> a >> b;
        int group_a = find(a, group), group_b = find(b, group);
        if (group_a != group_b) {
            cnt++;
            unite(group_a, group_b, group, rank);
        }
    }
    cout << N - 1 - cnt;

    return 0;
}

Measured memory_bytes: 3992
using System;

class Problem_B
{
  public static void Main(string[] args)
  {
    var input = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
    int a = input[0], b = input[1];
    var s = Console.ReadLine();
	for (var i = 0; i < a; i++)
    {
      if (s[i] < '0' || s[i] > '9')
      {
        Console.WriteLine("No");
        return;
      }
    }
    if (s[a] != '-')
    {
      Console.WriteLine("No");
      return;
    }
    for (var i = a + 1; i < s.Length; i++)
    {
      if (s[i] < '0' || s[i] > '9')
      {
        Console.WriteLine("No");
        return;
      }
    }
    Console.WriteLine("Yes");
  }
}


Measured memory_bytes: 13140
#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cassert>
#include <iterator>
#include <unordered_map>

#define ios ios_base::sync_with_stdio(0), cout.tie(0), cin.tie(0);
#define S second
#define F first
#define pb push_back
#define nl '\n'
#define all(s) s.begin(), s.end()
#define fo(i, start, finish) for(int i = start; i <= finish; i ++)
#define y1 kdfjsalsdkf

const long long MXN = 1e5 + 10;
const long long MNN = 5e3 + 1;
const long long MOD = 1e9 + 7;
const long long INF = 1e18;
const long long OO = 1e9 + 500;

typedef long long llong;
typedef unsigned long long ullong;

using namespace std;

llong n, L, b[MXN], l, r;
llong sum;

int main(){
    ios;
    cin >> n >> L;
    for(int i = 1; i <= n; i++){
        cin >> b[i];
        if(i != 1 && b[i] + b[i - 1] >= L && l == 0) l = i - 1, r = i;
    }
    if(l == 0) return cout << "Impossible", 0;
    else cout << "Possible" << nl;
    for(int i = 1; i < l; i++){
        cout << i << nl;
    }
    for(int i = n - 1; i >= r; i--){
        cout << i << nl;
    }
    cout << l;
    return 0;
}



Measured memory_bytes: 1664
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }

/*
 <url:http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=2170>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

int N,Q;
ll rec(ll v,vector<int>& G,vector<int>& marked){
    if(marked[v]) return v+1;
    return rec(G[v],G,marked);
}
ll solve(){
    ll res = 0;
    vector<int> G(N);
    vector<int> marked(N,0); marked[0] = 1;
    for(int i = 1; i < N;i++){
        int par; cin >> par;
        G[i] = par - 1;
    }
    while(Q--){
        char c; int v;
        cin >> c >> v; v--;
        if(c == 'Q'){
            res += rec(v,G,marked);
        }else{
            marked[v] = 1;
        }
    }
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    while(cin >> N >> Q,N){
        cout << solve() << endl;
    }
    return 0;
}



Measured memory_bytes: 3704
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


x = list(map(int, input().split()))
for i,t in enumerate(x):
    if t==0:
        print(i+1)
        break

Measured memory_bytes: 9116
#include<bits/stdc++.h>
using namespace std;
int main() {
  int N; cin >> N;
  vector<string> S(N);
  for (int i = 0; i < N; i++) cin >> S[i];
  int res = 0;
  for (int i = 0; i < N; i++) {
    bool f = true;
    
    for (int r = 0; r < N; r++) {
      for (int c = 0; c < N; c++) {
        int R = (i + r) % N;
        int C = c;
        int R2 = (c + i) % N;
        int C2 = r;
        f = f && S[R][C] == S[R2][C2];
      }
    }
    res += f;
  }
  cout << res * N << endl;
}

Measured memory_bytes: 3764
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int main(){
    char num[1001];
    while(1){
        scanf("%s", num);
        if(num[0] == '0') break;
        int sum = 0;
        for (int i = 0; strlen(num) > i; i++){
            sum += num[i] - '0';
        }
        printf("%d\n",sum);
    }
    return 0;
}


Measured memory_bytes: 3184
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<deque>
#include<queue>
using namespace std;
#define int long  long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef pair<int, int>P;
const int MOD = 1e9 + 7;
//const int MOD = 998244353;
const int INF = 1e18;
const long double PI = (acos(-1));


signed main() {
	int N;
	cin >> N;
	map<int, int>S, T;
	rep(i, N) {
		int A;
		cin >> A;
		S[A + i + 1]++;
		T[i + 1 - A]++;
	}
	int ans = 0;
	for (auto i : S) {
		ans += i.second * T[i.first];
	}
	cout << ans;
}

Measured memory_bytes: 37788
package main


import (
	"fmt"
	"strconv"
	"strings"
)

func main() {
	var a,b,c int
	fmt.Scan(&a, &b, &c)

	total := 0
	for i := 1; i <= a; i++ {
		str := strings.Split(strconv.Itoa(i),"")
		charSum := 0
		for _,char := range str {
			charInt,_ := strconv.Atoi(char)
			charSum += charInt
		}
		if b <= charSum && charSum <= c {
			total += i
		}
	}
	fmt.Println(total)
}

Measured memory_bytes: 1280
#include<stdio.h>
#include<stdlib.h>

int main(void)
{
  int a,b,c,talk_range,com_ab=0,com_bc=0,com_ca=0;
  char str[16];
  
  fgets(str,sizeof(str),stdin);
  sscanf(str,"%d %d %d %d",&a,&b,&c,&talk_range);
  
  if(abs(a-b) <= talk_range)
    com_ab++;
  if(abs(b-c) <= talk_range)
    com_bc++;
  if(abs(c-a) <= talk_range)
    com_ca++;
  
  if((com_ca > 0)||(com_ab * com_bc > 0))
  {
    puts("Yes");
  }else
  {
    puts("No");
  }
  
  return 0;
}

Measured memory_bytes: 128
import java.util.*;
 
public class Main {
	public static void main(String[] args) {
 
	Scanner sc  = new Scanner(System.in);
        int cnt = 0;
    long ans = 0;
 
    int N = Integer.parseInt(sc.next());
    int x = Integer.parseInt(sc.next());
    int[] a  = new int[N+1];
    while(true){
        a[cnt] = Integer.parseInt(sc.next());
        cnt++;
        if(cnt==N)break;
    }
    

    if (a[0] > x) {
      ans += a[0] - x;
      a[0] = x;
    }
    
    for(int i=0;i<N;i++){
        if(a[i]+a[i+1]>x){
            
                int t = a[i] + a[i+1]-x;
                ans+=t;
                a[i+1] -= t;
    
        }
    }
 
        System.out.print(ans);
        System.out.println();
	}
        
}

Measured memory_bytes: 31836
#!python3

iim = lambda: map(int, input().rstrip().split())

def resolve():
    N, M = iim()
    dp = dict()
    for i in range(M):
        si, ci = iim()
        if si in dp:
            if dp[si] != ci:
                print(-1)
                return
            continue
        dp[si] = ci

    if 1 in dp and dp[1] == 0:
        print(0 if N == 1 else -1)
        return
    if N == 1 and M == 0:
        print(0)
        return

    #print(dp)
    ans = []
    for i in range(1, N+1):
        if i in dp:
            ans.append(dp[i])
        else:
            ans.append(1 if i == 1 else 0)
    print(*ans, sep="")


if __name__ == "__main__":
    resolve()


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

using namespace std;


void solve() {
    int n; cin >> n;
    map<int, int> mp;
    for (int _ = 0; _ < n; _++) {
        int x; cin >> x;
        mp[x]++;
    }
    int res = 0;
    for (auto& p: mp) {
        int x,y;
        tie(x,y) = p;
        if (x <= y) res += y-x;
        else res += y;
    }
    cout << res;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    cout << endl;
}


Measured memory_bytes: 4736
#include "stdio.h"

int main(void){
  int x,y,z,i,j;
  scanf("%d %d", &x, &y);
  int a[x][y];
  int b[y];
  int c[x];
  for(i = 0; i < x; i++){
    c[i] = 0;
  }
  for(i = 0; i < x; i++){
    for(j = 0; j < y; j++){
      scanf("%d ", &a[i][j]);
    }
  }
  for(i = 0; i < y; i++){
    scanf("%d\n", &b[i]);
  }
  for(i = 0; i < x; i++){
    int sum;
    for(j = 0; j < y; j++){
      sum = a[i][j] * b[j];
      c[i] += sum;
    }
  }
  for(i = 0; i < x; i++){
    printf("%d\n", c[i]);
  }
}



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

struct Node{
    int key;
    Node *right, *parent, *left;
};

Node *root;
Node *NIL;

void insert(int k){
    Node *y = NIL;
    Node *x = root; // 走査用
    Node *z;

    z = (Node *)malloc(sizeof(Node));
    z->key = k;
    z->left = NIL;
    z->right = NIL;

    while(x != NIL){
        y = x;
        if(x->key > z->key){
            x = x->left;
        }else{
            x = x->right;
        }
    }

    z->parent = y;
    if(y == NIL){
        root = z;
    }else if(y->key > z->key){
        y->left = z;
    }else{
        y->right = z;
    }
}

void inorder(Node *u){
    if(u == NIL)    return;
    inorder(u->left);
    printf(" %d", u->key);
    inorder(u->right);
}

void preorder(Node *u){
    if(u == NIL)    return;
    printf(" %d", u->key);
    preorder(u->left);
    preorder(u->right);
}

int main(){
    int n, i, x;
    string com;
    scanf("%d", &n);
    
    for(i = 0; i < n; i++){
        cin >> com;
        if(com == "insert"){
            scanf("%d", &x);
            insert(x);
        }else if(com == "print"){
            inorder(root);
            printf("\n");
            preorder(root);
            printf("\n");
        }
    }

    return 0;
}


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

int main() {
  int n, k, s = 0;
  scanf("%d %d", &n, &k);
  vector<int> l(n);
  for(int i = 0; i < n; i++) scanf("%d", &l[i]);
  sort(l.begin(), l.end());
  for(int i = n - k; i < n; i++) s += l[i];
  printf("%d\n", s);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	long long n,d,x,y,s=0;
	cin>>n>>d;
	for(int i=0;i<n;i++){
	  cin>>x>>y;
	  if(x*x+y*y<=d*d) s++;}
	cout<<s;
	return 0;
}

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

typedef pair<ll, pair<int, int> > p;

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

    string N;
    cin >> N;

    if(N[0] == N[2]) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using Int = int64_t;
using UInt = uint64_t;
using C = std::complex<double>;
#define rep(i, n) for(Int i = 0; i < (Int)(n); ++i)
#define guard(x) if( not (x) ) continue;
#ifndef LOCAL_
#define fprintf if( false ) fprintf
#endif

int main() {
   Int v, e;
   std::cin >> v >> e;
   std::vector<Int> ss(e), ts(e);
   rep(i, e) std::cin >> ss[i] >> ts[i];
   std::vector<std::vector<Int>> nexts(v);
   rep(i, e) {
      Int s = ss[i], t = ts[i];
      nexts[t].emplace_back(s);
      nexts[s].emplace_back(t);
   }
   std::vector<Int> xs(v, -1);
   xs[0] = 0;
   std::vector<Int> ys(v, 0);
   Int id = 1;
   std::vector<bool> zs(v);
   std::function<Int(Int,Int)> dfs = [&](Int i, Int prev) {
      xs[i] = id;
      id += 1;
      Int res = 0;
      for(Int k : nexts[i]) {
         guard( k != prev );
         if( xs[k] == -1 ) {
            ys[i] = 0;
            Int t = dfs(k, i);
            if( t + ys[i] == 0 ) {
               zs[i] = zs[i] or nexts[i].size() >= 2;
            }
            res += t + ys[i];
         }
         else if( xs[k] < xs[i] ) {
            res += 1;
            ys[k] -= 1;
         }
      }
      return res;
   };
   Int c = 0;
   for(Int i : nexts[0]) {
      guard( xs[i] == -1 );
      c += 1;
      dfs(i, 0);
   }
   zs[0] = c >= 2;
   rep(i, v) {
      if( zs[i] ) printf("%ld\n", i);
   }
}



Measured memory_bytes: 6444
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <utility>
#include <numeric>

using namespace std;

const uint64_t MOD = 1000000000 + 7;

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

	uint64_t x = 1;
	for (int i = 1; i <= n; i++)
	{
		x = (x * i) % MOD;
	}

	cout << x << endl;
}

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

long long teisuu=1000000000000000000;
int main() {
  long long n;
  cin >>n;
  vector<long long>a(n);
  for(long long i=0;i<n;i++){
    cin>>a[i];
    if(a[i]==0){
      cout<<0<<endl;
      return 0;
    }
  }
  long long kotae=1;
  for(long long i=0;i<n;i++){
    if(teisuu/kotae<a[i]){
      cout<<-1<<endl;
      return 0;
    }
    kotae*=a[i];
  }
  cout<<kotae<<endl;
  return 0;
}
    


Measured memory_bytes: 3976
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define fi first
#define se second
#define pb push_back
ll mod = 1000000007;
ll INF = 1000000099;



signed main(){
    ll n,ans=0;
    cin>>n;
    vector<pair<ll,ll>> cnt(n);//隣接頂点数、頂点番号,昇順
    vector<ll> w(n+1,0);//頂点→書き込んだ数
    vector<vector<ll>> v(n+1,vector<ll>(0));//隣接頂点リスト
    vector<ll> c(n);//書き込む数、降順

    for(ll i=0;i < n;i++)
    {
        cnt.at(i)={0,i+1};
    }//初期化

    
    for(ll i=0;i < n-1;i++)
    {
        ll a,b;
        cin>>a>>b;
        v.at(a).pb(b);
        v.at(b).pb(a);
        cnt.at(a-1).fi++;//隣接する頂点をカウント
        cnt.at(b-1).fi++;
    }

    
    for(ll i=0;i < n;i++)
    {
        cin>>c.at(i);
    }
    sort(c.begin(),c.end());
    for(ll i=0;i < n-1;i++)
    {
        ans+=c.at(i);
    }
    reverse(c.begin(),c.end());
    sort(cnt.begin(),cnt.end());

    queue<ll> q;
    q.push(cnt.at(n-1).se);//一番隣接数が多い点
    
    ll count=0;
    while(!q.empty()){
        ll x=q.front();
        q.pop();

        w.at(x)=c.at(count);
        count++;

        for(ll i=0;i < (ll)(v.at(x).size());i++)
        {
            if(w.at(v.at(x).at(i))==0 ){
                q.push(v.at(x).at(i));
            }
        }
    }
    
    cout << ans <<endl;

    for(ll i=1;i <= n;i++)
    {
        cout<<w.at(i)<<" ";
    }
    cout << endl;
}


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

public class Main {
    public static void main(String[] args) {
        try (Scanner in = new Scanner(System.in)) {
            int N = in.nextInt();
            int X = in.nextInt();
            int[] m = new int[N];
            for (int i = 0; i < N; i++) {
                m[i] = in.nextInt();
            }

            Arrays.sort(m);

            int sum = 0;
            for (int i = 0; i < N; i++) {
                sum += m[i];
            }

            X -= sum;

            System.out.println(N + X / m[0]);
        }
    }
}


Measured memory_bytes: 27240
#include <stdio.h>
#include <math.h>
#define EPS 0.0000000002
#define MAX 1010001000

typedef struct point{
    double x, y;
}point;

typedef struct line{
    point st, en;
}line;

double norm(point a);
double norm2(point a);
double distans(point a, point b);
point sum_vector(point a, point b);
point diff_vector(point a, point b);
point minus_vector(point a);
double dot(point a, point b);
double prod(point a, point b);

point pv(line a, point p) {
    //直線ab上に点pから垂線を下ろしたときの点h//
    point h;
    double k = dot(diff_vector(a.st, p), diff_vector(a.st, a.en))
                / dot(diff_vector(a.en, a.st), diff_vector(a.en, a.st));
    h.x = k * (a.en.x - a.st.x) + a.st.x;
    h.y = k * (a.en.y - a.st.y) + a.st.y;
    return h;
}

double norm(point a)
{
    //原点からの距離
    return sqrt((a.x * a.x) + (a.y * a.y));
}

double norm2(point a)
{
    //原点からの距離の二乗
    return (a.x * a.x) + (a.y * a.y);
}

double distans(point a, point b)
{
    //二点間の距離
    point tmp = sum_vector(b, minus_vector(a));
    return norm(tmp);
}

point sum_vector(point a, point b)
{
    //ベクトルの和
    a.x += b.x;
    a.y += b.y;
    return a;
}

point diff_vector(point a, point b)
{
    //ベクトルの差
    a.x -= b.x;
    a.y -= b.y;
    return a;
}

point minus_vector(point a)
{
    //逆ベクトル
    a.x *= -1;
    a.y *= -1;
    return a;
}

double dot(point a, point b)
{
    //内積
    return (a.x * b.x) + (a.y * b.y);
}

double prod(point a, point b)
{
    //外積
    return (a.x * b.y) - (b.x * a.y);
}

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

int main(void)
{
    point tmp;
    line ab;
    int n, i;

    scanf("%lf%lf%lf%lf%d", &ab.st.x, &ab.st.y, &ab.en.x, &ab.en.y, &n);
    for (i = 0; i < n; i++) {
        scanf("%lf%lf", &tmp.x, &tmp.y);
        tmp = pv(ab, tmp);
        printf("%.10lf %.10lf\n", tmp.x, tmp.y);
    }

    return 0;

}

Measured memory_bytes: 664
def main():
  import sys
  input = sys.stdin.buffer.readline
  n,m=map(int,input().split())
  ac,wa,l,k=0,0,[0]*n,[0]*m
  for _ in k:
    p,s=input().split()
    p=int(p)
    if type(l[p-1])==int:
      if s==b'AC':
        ac+=1
        wa+=l[p-1]
        l[p-1]=''
      else:
        l[p-1]+=1
  print(ac,wa)
  
if __name__ == '__main__':
    main()

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

const int maxn = 200000+3;
vector<int> son[maxn];
#define mp make_pair
#define fi first
#define se second
queue<pair<int,int> > q;
bool vis[maxn];
pair<int,int> bfs(int x)
{
    while(!q.empty())   q.pop();
    memset(vis,0,sizeof vis);
    q.push(mp(x,0));
    int d=0;
    vis[x]=true;
    while(!q.empty())
    {
        x=q.front().fi; d=q.front().se;
        q.pop();
        for(auto g:son[x])
            if(!vis[g])
            {
                q.push(mp(g,d+1));
                vis[g]=true;
            }
    }
    return mp(x,d);
}
int main()
{
    ios::sync_with_stdio(false);
    int N;
    cin>>N;
    int a,b;
    #define pb push_back
    while(--N)
    {
        cin>>a>>b;
        son[a].pb(b);
        son[b].pb(a);
    }
    pair<int,int> x;
    x=bfs(1);
    x=bfs(x.fi);
    #ifdef fuckoj
    cout<<x.se<<endl;
    #endif
    if(x.se%3==1)   cout<<"Second"<<endl;
    else cout<<"First"<<endl;
    return 0;
}

Measured memory_bytes: 13812
#include <bits/stdc++.h>
using namespace std;;
#define ll long long
#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 FORR(i, m, n) for(int i = m;i >= n;i--)
#define INF 1<<30
#define LINF 1LL<<62
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
int main(){
    int n; cin >> n;
    long double t,a; cin >> t >> a;
    long double h[n];
    REP(i,n){
        cin >> h[i]; h[i] = t - 0.006 * h[i];
    }
    long double tmp = INF;
    int ans ;
    REP(i,n){
        if(abs(a-h[i]) < abs(a-tmp)){
            ans = i+1;
            tmp = h[i];
        }
    }
    cout << ans << endl;

    

}

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

int main() {
    int N;
    cin >> N;
    vector<int> x(N), y(N);
    for (int i = 0; i < N; i++) cin >> x[i] >> y[i];

    vector<int> v;
    int f = 1;
    for (int i = 0; i < N; i++) {
        v.push_back(i);
        f *= i + 1;
    }

    double sum = 0.0;
    do {
        for (int i = 0; i + 1 < N; i++) {
            double dist = (x[v[i]] - x[v[i + 1]]) * (x[v[i]] - x[v[i + 1]]);
            dist += (y[v[i]] - y[v[i + 1]]) * (y[v[i]] - y[v[i + 1]]);
            sum += sqrt(dist);
        }
    } while (next_permutation(v.begin(), v.end()));
    double ans = sum / f;

    cout << fixed << setprecision(12) << ans << endl;
}

Measured memory_bytes: 256
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
/*
//#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
*/

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
/*
//#if __cplusplus >= 201103L
#include <array>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
*/
using namespace std;
#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl

#define uni(x) x.erase(unique(all(x)),x.end())
template<class T,class U>inline void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>inline void chmax(T &t,U f){if(t<f)t=f;}
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) > (b) ? (b) : (a))

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;

#define INF INT_MAX/3
#define MAX_N 1000
#define M_INF 1000000000
int n,m,v,i;
void solve(){
   cin.tie(0);
  ios::sync_with_stdio(false);
  cin>>n;
  vector<int> v(n);
  rep(i,n) {
    cin>>v[i];
  }
  int ans = 0;
  map<int,int> rate;
  rep(i,n){
    if(v[i]>=3200){
      ans++;
      continue;
    }
    rate.insert(mp(v[i]/400,v[i]/400));
  }
  if(rate.size() == 0) cout<<1<<" "<<rate.size()+ans<<endl;
  else cout<<rate.size()<<" "<<rate.size()+ans<<endl;
  // if(rate.size()+ans > 8) cout<<8<<endl;
  // else cout<<rate.size()+ans<<endl;
}

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


Measured memory_bytes: 256
object Main extends App {
	val n = scala.io.StdIn.readInt
	val a = new Array[Long](n)
	var bs = Long.MaxValue

	for(i<-0 until n){
		val tp = scala.io.StdIn.readLine.split(" ").map(_.toLong)
		a(i) = tp(0)
		
		if(tp(0) > tp(1)){
			bs = math.min(bs, tp(1))
		}
	}

	if(bs == Long.MaxValue){
		println(0)
	}else{
		println(a.sum - bs)
	}
}

Measured memory_bytes: 39972
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <numeric>
#include <cmath>

using namespace std;

typedef long long int ll;

#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;
const ll MAXN = 1e9;

int main()
{
	ll n,m;
	cin >> n >> m;
	ll ans = 0;
	m /= 2;
	if(n>= m){
		ans = m;
	}else{
		ans = n;
		m -= n;
		m /= 2;
		ans += m;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
s = str(input())


result = 0

if s[0] == "R" and s[1] == "R" and s[2] == "R":
    print(3)
elif s[0] == "R" and s[1] == "R":
    print(2)
elif s[1] == "R" and s[2] == "R":
    print(2)
elif s[0] == "R" or s[1] == "R" or s[2] == "R":
    print(1)
else:
    print(0)

Measured memory_bytes: 9056
#include<iostream>
using namespace std;
int main(){
  int m,f,r;
  cin >> m >> f >> r;
  while(m!=-1||f!=-1||r!=-1){
    if(m==-1||f==-1) cout << "F" << endl;
    else if(m+f>=80) cout << "A" << endl;
    else if(m+f>=65) cout << "B" << endl;
    else if(m+f>=50) cout << "C" << endl;
    else if(m+f>=30)
      if(r>=50) cout << "C" << endl;
      else cout << "D" << endl;
    else cout << "F" << endl;
 
    cin >> m >> f >> r;
  }
  return 0;
}


Measured memory_bytes: 3104
def input_func():
    N, K= map(int,input().split())
    return N, K

def evaluate(N,K):
    if K == 1:
        answer = 0
    else:
        answer = N - K
    return answer

if __name__ == '__main__':
    N, K = input_func()
    answer = evaluate(N,K)
    print(answer)

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef pair<int,int> pii;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(int i=0; i<(n); i++)
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 2020000;
ll dy[8] = {1,-1,0,0,1,-1,1,-1};
ll dx[8] = {0,0,1,-1,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T> inline void print(T &a){
    rep(i,a.size()) cout << a[i] << " ";
    cout << "\n";
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << "\n";}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << "\n";
}
ll pcount(ll x) {return __builtin_popcount(x);};
const int mod = 1e9 + 7;
//const int mod = 998244353;

int main(){
    int n; cin >> n;
    vvl g(n,vl(n));
    rep(i,n) rep(j,n) cin >> g[i][j];
    ll ans = 0;
    rep(i,n){
        REP(j,i+1,n){
            ans += min(g[i][j], g[j][i]);
        }
    }
    cout << ans << "\n";
}


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

int main() {
  int count=0;
  int N;
  cin>>N;
  vector<int>x(N);
  rep(i,N){
  cin>>x[i];
  }
  rep(i,N){
    if(count<x[i]){
      count=x[i];
    }
  }
  count=-1*(count/2);
  rep(i,N){
    count+=x[i];
  }
  cout<<count;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main() 
{
    int n;
    cin>>n;
    ll a[8];
    memset(a,0,sizeof(a));
    a[1]=9;
    a[3]=900;
    a[5]=90000;
    a[7]=9000000;
    int digits=log10(n);
    int num=0;
    for(int i=0;i<digits;i++)
    {
        num=(num*10)+9;
    }
    if(digits+1==1)
    {
        cout<<n-0;
    }
    else
    {
        ll ans=0;
        if(digits%2==0)
        {
            ans=n-num;
        }
        for(int i=0;i<=digits;i++)
        {
            ans+=a[i];
        }
        cout<<ans;
    }
    return 0;
}











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

#define LL long long

using namespace std;

const LL MAX = (1e6+47);

int main(){
	ios_base::sync_with_stdio(false);
	vector<bool> prime(MAX,true);
	vector<LL> primes;
	for (LL i = 2; i < MAX; i++){
		if (!prime[i])
			continue;
		primes.push_back(i);
		for (LL j = i+i; j < MAX; j += i)
			prime[j] = false;
	}
	LL a,b;
	cin >> a >> b;
	LL g = __gcd(a,b);
	LL res = 1;
	for (LL p : primes){
		if (g%p == 0){
			res++;
			while (g%p == 0)
				g /= p;
		}
	}
	if (g > 1)
		res++;
	cout << res << "\n";
}


Measured memory_bytes: 1528
//Robs Code
/***********HEADER***************/
#include<bits/stdc++.h>
/***********MACROS***************/
#define ll long long int
#define fri(l,k) for (i=l;i<=k;i++)
#define frj(l,k) for (j=l;j>=k;j--)
#define fij(a,b,l,k) for(i=a;i<=b;i++) for(j=l;j<=k;j++)
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()
#define endl "\n"
#define pb push_back
#define _1 first
#define _2 second
#define mxsz 10000007
#define mxval 1e9
#define grt [](auto x,auto y){return x>y;}
#define pii pair<ll,ll>
/*********VARIABLE****************/
using namespace std;
ll i,j,n,m,k,l,q,t,a,b,sum[3],tot[3],cnt[3];
/***********MAIN******************/
int main()
{
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	char s;
    cin>>s;
    if(s=='A') cout<<'T';
    else if(s=='T') cout<<'A';
    else 
    if(s=='C') cout<<'G';
    else 
    if(s=='G') cout<<'C';
    return 0;
}
//.........

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define maxs(a, b) a = max(a, b)
#define mins(a, b) a = min(a, b)
using namespace std;
template<class T> inline istream& operator >> (istream & c, vector<T> & A) {rep(i, A.size()) c >> A[i];return c;}
typedef long long ll;
typedef pair<int, int> P;
const ll linf = (1ll << 61);
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int a, b;
	cin >> a >> b;
	if (a <= 8 && b <= 8) cout << "Yay!" << endl;
	else cout << ":(" << endl;
	return 0;
}

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

using namespace std;

using ll = long long;
using pii = pair<int, int>;
using ld = long double;

template <typename T>
int sz(T &x) {
  return (int)(x.size());
}

int power(int x, int y, int mod) {
  if (y == 0) {
    return 1;
  }
  int z = power(x, y >> 1, mod);
  z = z * 1ll * z % mod;
  if (y & 1) {
    z = z * 1ll * x % mod;
  }
  return z;
}

const int mod = 998244353;
const int inf = 1'000'000'007;

void solve() {

  int n;
  cin >> n;

  vector<int> x(n * n + 1, 0);
  vector<pii> e;

  for (int i = 1; i <= n; ++i) {
    int pos;
    cin >> pos;
    x[pos] = i;
    e.push_back(make_pair(pos, i - 1));
  }

  sort(e.begin(), e.end());

  int ptr = 1;
  for (auto &i : e) {
    while (i.second--) {
      while (ptr <= n * n && x[ptr]) {
        ++ptr;
      }
      if (ptr >= i.first) {
        cout << "No\n";
        return;
      }
      x[ptr] = x[i.first];
    }
  }

  for (auto &i : e) {
    i.second = n - x[i.first];
  }
  reverse(e.begin(), e.end());

  ptr = n * n;
  for (auto i : e) {
    while (i.second < 0) {

    }
    while (i.second--) {
      while (ptr >= 1 && x[ptr]) {
        --ptr;
      }
      if (ptr <= i.first) {
        cout << "No\n";
        return;
      }
      x[ptr] = x[i.first];
    }
  }

  cout << "Yes\n";
  for (int i = 1; i <= n * n; ++i) {
    cout << x[i] << " ";
  }
  cout << "\n";

}

int main() {
  #ifndef LOCAL58
    // don't forget to remove if interactive
    ios_base :: sync_with_stdio(false);
    cin.tie(nullptr);
  #endif

  int t;
  t = 1;
  while (t--) {
    solve();
  }

  return 0;
}


Measured memory_bytes: 4284
#include <bits/stdc++.h>
using namespace std;
 
int main(void){
    char s[3],t[3];
    cin >> s >> t;
    int count = 0;
    for(int i = 0;i < 3;i++){
        if(s[i] == t[i]){
            count++;
        }
    }

    cout << count << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <string>
#include <tuple>
#include <vector>

using namespace std;
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef long double ld;

#define INF (1e9)

int N;

int main() {
    cin >> N;

    vvd E(N, vd(2));
    double x, y;
    for (int i = 0; i < N; i++) {
        cin >> x >> y;
        E[i] = vd{x, y};
    }

    sort(E.begin(), E.end(), [](vd l, vd r) {
        return atan2(l[0], l[1]) < atan2(r[0], r[1]);
    });

    ld ans = 0;
    for (int l = 0; l < N; l++) {
        int r = l;
        ld sx = 0, sy = 0;
        do {
            sx += E[r][0];
            sy += E[r][1];
            ans = max(ans, sqrt(sx * sx + sy * sy));
            r++;
            r %= N;
        } while (l != r);
    }

    cout << setprecision(20) << ans << endl;
    return 0;
}


Measured memory_bytes: 256
if __name__ == '__main__':
    k = int(input())

    if k % 2 == 0 or k % 5 == 0:
        print('-1')
    else:
        mod_list = [7 % k]
        if mod_list[-1] == 0:
            print(1)
        else:
            for i in range(1000000):
                mod_list.append((mod_list[0] + mod_list[-1] * 10) % k)
                if mod_list[-1] == 0:
                    break
            print(len(mod_list))



Measured memory_bytes: 140820