akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>


int main(void){
	
	int suuti[3], i ,j, esc;
	scanf("%d %d %d",&suuti[0],&suuti[1],&suuti[2]);
	
	for(i = 0;i < 2;i++){
		for(j = i + 1;j < 3;j++){
			if(suuti[i] > suuti[j]){
				esc = suuti[j];
				suuti[j] = suuti[i];
				suuti[i] = esc;
			}
		}
	}
	
	
	printf("%d %d %d\n",suuti[0], suuti[1], suuti[2]);
	return 0;
}

Measured memory_bytes: 596
using System;

namespace B_81
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            string ans = "No";
            for (int i = 1; i <= 9; i++)
            {
                for (int j = 1; j <= 9; j++)
                {
                    if (i * j == n)
                    {
                        ans = "Yes";
                        break;
                    }
                }
            }
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 11092
import java.util.Scanner;
//【155】
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
		int n=sc.nextInt();
		int[] numbers =new int[n];
		for (int i=0;i<n;i++) {
			numbers[i] = sc.nextInt();
		}
		boolean isApproved =true;
		for (int i=0;i<n;i++) {
			if (numbers[i]%2==0) {
				if (numbers[i]%3!=0&&numbers[i]%5!=0) {
					isApproved=false;
				}
			}
		}
		if (isApproved) {
			System.out.println("APPROVED");
		} else {
			System.out.println("DENIED");
		}
		
		
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
	}
	//----------------------------------------
	//置き場
	
	//----------------------------------------
}

Measured memory_bytes: 23508
package main

import (
	"fmt"
)

func uniqueValue(arr []string) []string {
	m := make(map[string]bool)
	var uniq []string

	for _, v := range arr {
		if !m[v] {
			m[v] = true
			uniq = append(uniq, v)
		}
	}
	return uniq
}

func main() {
	var n int
	fmt.Scan(&n)
	arr := make([]string, n)

	for i:= 0; i < n; i ++ {
		fmt.Scan(&arr[i])
	}

	result := uniqueValue(arr)
	fmt.Println(len(result))
}

Measured memory_bytes: 32840
#include<bits/stdc++.h>
using namespace std;
int main()
{
  
  string s;
  cin>>s;
  string s1,s2;
  s1+=s[0];
  s1+=s[1];
  s2+=s[2];
  s2+=s[3];
  if(stoi(s1)>0&&stoi(s1)<13&&stoi(s2)>0&&stoi(s2)<13)
  cout<<"AMBIGUOUS"<<endl;
  else if(stoi(s1)>0&&stoi(s1)<13)
  {
      cout<<"MMYY"<<endl;
  }
  else if(stoi(s2)>0&&stoi(s2)<13)
  cout<<"YYMM"<<endl;
  else
  cout<<"NA"<<endl;
  return 0;
}

Measured memory_bytes: 256
public class Main {
  private static void solve() {
    char[] s = ns();
    for (int i = 0; i < 8; i ++) {
      StringBuilder sb = new StringBuilder();
      int x = s[0] - '0';
      sb.append(s[0]);
      for (int j = 0; j < 3; j ++) {
        if (((i >> j) & 1) == 1) {
          x += s[j + 1] - '0';
          sb.append("+");
        } else {
          x -= s[j + 1] - '0';
          sb.append("-");
        }
        sb.append(s[j + 1]);
      }
      if (x == 7) {
        System.out.println(sb + "=7");
        return;
      }
    }
  }

  public static void main(String[] args) {
    new Thread(null, new Runnable() {
      @Override
      public void run() {
        long start = System.currentTimeMillis();
        String debug = args.length > 0 ? args[0] : null;
        if (debug != null) {
          try {
            is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
          } catch (Exception e) {
            throw new RuntimeException(e);
          }
        }
        reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
        solve();
        out.flush();
        tr((System.currentTimeMillis() - start) + "ms");
      }
    }, "", 64000000).start();
  }

  private static java.io.InputStream is = System.in;
  private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
  private static java.util.StringTokenizer tokenizer = null;
  private static java.io.BufferedReader reader;

  public static String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }

  private static double nd() {
    return Double.parseDouble(next());
  }

  private static long nl() {
    return Long.parseLong(next());
  }

  private static int[] na(int n) {
    int[] a = new int[n];
    for (int i = 0; i < n; i++)
      a[i] = ni();
    return a;
  }

  private static char[] ns() {
    return next().toCharArray();
  }

  private static long[] nal(int n) {
    long[] a = new long[n];
    for (int i = 0; i < n; i++)
      a[i] = nl();
    return a;
  }

  private static int[][] ntable(int n, int m) {
    int[][] table = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[i][j] = ni();
      }
    }
    return table;
  }

  private static int[][] nlist(int n, int m) {
    int[][] table = new int[m][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[j][i] = ni();
      }
    }
    return table;
  }

  private static int ni() {
    return Integer.parseInt(next());
  }

  private static void tr(Object... o) {
    if (is != System.in)
      System.out.println(java.util.Arrays.deepToString(o));
  }
}




Measured memory_bytes: 23252
H, W = map(int, input().split())
C = [list(map(int, input().split())) for _ in range(10)]
A = [list(map(int, input().split())) for _ in range(H)]
for k in range(10):
    for i in range(10):
        for j in range(10):
            C[i][j] = min(C[i][j], C[i][k] + C[k][j])
ans = 0
for i in range(H):
    for j in range(W):
        if A[i][j] >= 0:
            ans += C[A[i][j]][1]
print(ans)


Measured memory_bytes: 9496
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <iomanip>

int main(){
  int x, y, z;
  std::cin >> x >> y >> z;
  int a, b, c;
  std::cout << z << " " << x << " " << y << std::endl;
  
  return 0;
}


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

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

#define MOD 1000000007

using namespace std;

int main(){
	int n,k;
	int ans;
	
	cin >> n >> k;
	
	int a[n];
	
	for(int i=0; i<n; i++)	cin >> a[i];
	
	ans = (n-k)/(k-1)+1;
	
	if((n-k)%(k-1))	ans++;
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#define ll long long

using namespace std;

inline int read() {
    int x = 0, f = 1; char ch = getchar();
    for(; ch < '0' || ch > '9'; ch = getchar()) if(ch == '-') f = -1;
    for(; ch >= '0' && ch <= '9'; ch = getchar()) x = (x << 3) + (x << 1) + (ch ^ 48);
    return x * f;
}

void write(int x) {
    if(x < 0) {putchar('-'); write(-x); return ;}
    if(x > 9) write(x / 10);
    putchar(x % 10 + '0');
    return ;
}

int n, sum = 0, a[101], m, p, x;

int main() {
    n = read();
    for(int i = 1; i <= n; ++i) a[i] = read(), sum += a[i];
    m = read();
    while(m--) {
        p = read(); x = read();
        write(sum - a[p] + x);
        putchar('\n');
    }
    return 0;
}

Measured memory_bytes: 256
a, b, c, x, y = map(int, input().split())

ab = 2 * c
money = 0

if a + b >= ab:
    if x >= y:
        if  a >= ab:
            money = x * ab
        else:
            money = (x - y) * a + y * ab
    else:
        if b >= ab:
            money = y * ab 
        else:
            money = (y - x) * b + x * ab

else:

    if a < ab and b < ab:
        money = a*x + b*y

    if a >= ab and b < ab:
        if y - x >= 0:
            money = x * ab + b * (y - x)
        else:
            money = x * ab

    if a < ab and b >= ab:
        if x -y >= 0:
            money = y * ab + a * (x -y)
        else:
            money = y * ab

    if a >= ab and b >= ab:
        money = x * ab + y * ab

print(money)

Measured memory_bytes: 3064
n, k = map(int, input().split())
a_list = list(map(int, input().split()))

one_index = None
for i in range(len(a_list)):
    if a_list[i] == 1:
        one_index = i
left_n = one_index
right_n = n - one_index - 1

delete_num = k - 1
minimum = None
for i in range(k):
    hidarihashi_index = one_index - i
    migihashi_index = one_index - i + k - 1
    if hidarihashi_index < 0:
        hidari_nokori = 0
    else:
        hidari_nokori = hidarihashi_index

    if migihashi_index > (n-1):
        migi_nokori = 0
    else:
        migi_nokori = (n-1) - migihashi_index

    if hidari_nokori % delete_num == 0:
        hidarikasan = hidari_nokori // delete_num
    else:
        hidarikasan = hidari_nokori // delete_num + 1

    if migi_nokori % delete_num == 0:
        migikasan = migi_nokori // delete_num
    else:
        migikasan = migi_nokori //delete_num + 1

    shikoukaisuu = 1 + migikasan + hidarikasan

    if not minimum:
        minimum = shikoukaisuu
    else:
        minimum = min(shikoukaisuu, minimum)
print(minimum)

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

// begin fast read template by CYJian (source: https://www.luogu.com.cn/paste/i11c3ppx)

namespace io {
	const int __SIZE = (1 << 21) + 1;
	char ibuf[__SIZE], *iS, *iT, obuf[__SIZE], *oS = obuf, *oT = oS + __SIZE - 1, __c, qu[55]; int __f, qr, _eof;
	#define Gc() (iS == iT ? (iT = (iS = ibuf) + fread (ibuf, 1, __SIZE, stdin), (iS == iT ? EOF : *iS ++)) : *iS ++)
	inline void flush () { fwrite (obuf, 1, oS - obuf, stdout), oS = obuf; }
	inline void gc (char &x) { x = Gc(); }
	inline void pc (char x) { *oS ++ = x; if (oS == oT) flush (); }
	inline void pstr (const char *s) { int __len = strlen(s); for (__f = 0; __f < __len; ++__f) pc (s[__f]); }
	inline void gstr (char *s) { for(__c = Gc(); __c < 32 || __c > 126 || __c == ' ';)  __c = Gc();
		for(; __c > 31 && __c < 127 && __c != ' '; ++s, __c = Gc()) *s = __c; *s = 0; }
	template <class I> inline bool gi (I &x) { _eof = 0;
		for (__f = 1, __c = Gc(); (__c < '0' || __c > '9') && !_eof; __c = Gc()) { if (__c == '-') __f = -1; _eof |= __c == EOF; }
		for (x = 0; __c <= '9' && __c >= '0' && !_eof; __c = Gc()) x = x * 10 + (__c & 15), _eof |= __c == EOF; x *= __f; return !_eof; }
	template <class I> inline void print (I x) { if (!x) pc ('0'); if (x < 0) pc ('-'), x = -x;
		while (x) qu[++ qr] = x % 10 + '0',  x /= 10; while (qr) pc (qu[qr --]); }
	struct Flusher_ {~Flusher_(){flush();}}io_flusher_;
} using io::pc; using io::gc; using io::pstr; using io::gstr; using io::gi; using io::print;

// end fast read template by CYJian

#define iter(i, a, b) for(int i=(a); i<(b); i++)
#define rep(i, a) iter(i, 0, a)
#define rep1(i, a) iter(i, 1, (a)+1)
#define log(a) cerr<<"\033[32m[DEBUG] "<<#a<<'='<<(a)<<" @ line "<<__LINE__<<"\033[0m"<<endl
#define all(a) a.begin(), a.end()
#define fi first
#define se second
#define pb push_back
#define mp make_pair
 
using ll=long long;
using pii=pair<int, int>;
//#define int ll
const int MOD = 1000000007;

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int a, b, c, d, k; gi(a), gi(b), gi(c), gi(d), gi(k);
	int t1 = a * 60 + b, t2 = c * 60 + d;
	print(t2 - t1 - k);
}


Measured memory_bytes: 3668
#include <bits/stdc++.h>
#define rep(a,n) for (ll a = 0; a < (n); ++a)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<vector<ll> > Graph;
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 ll INF = 1e18;



int main(){
    ll n,t;
    cin >> n >> t;
    vector<ll>a(n);
    rep(i,n)cin>>a[i];
    vector<ll>m(n,0);
    m[n-1] = -1;
    m[n-2]=a[n-1];
    for(int i=n-3;i>=0;i--){
        chmax(m[i],a[i+1]);
        chmax(m[i],m[i+1]);
    }
    vector<ll> c(n);
    ll M = 0;
    rep(i,n-1){
        c[i]=m[i]-a[i];
        chmax(M,c[i]);
    }
    ll ans = 0;
    rep(i,n-1){
        if(M==c[i])ans++;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 2560
P = 10**9 + 7
S = int(input())

ans = [0]*(S + 1)
for i in range(3, S + 1):
    ans[i] = 1
for i in range(6, S + 1):
    for j in range(3, i - 2):
        ans[i] = (ans[i] + ans[j]) % P

print(ans[S])

Measured memory_bytes: 9184
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
#include<iomanip>
#include<string>
#include<queue>
#include<set>
#include<map>
#include<unordered_map>
#include<unordered_set>

#define int long long

using namespace std;

const int INF = 1e17 + 7;

void solve() {
    int n;
    cin >> n;
    int mx = 0, ans = 0;
    while (n--) {
        int x;
        cin >> x;
        if (mx < x) mx = x;
        ans += mx - x;
    }
    cout << ans;
}

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

    int t = 1;
    //cin >> t;
    while (t--) solve();

    return 0;
}

Measured memory_bytes: 3228
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define PI 3.14159265359
#define INF 1000100100
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define P pair<ll, ll>
#define PP pair<P,P>
using namespace std;
 
int main(){
    int s,w; cin >> s >> w;
    if(w>=s) cout << "unsafe" << endl;
    else cout << "safe" << endl;
return 0;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
// #include <numeric>
#include <complex>

#define FAST ios_base::sync_with_stdio(false); cin.tie(0)
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define repr(i, a, b) for(int i=int(a); i>=int(b); i--)
#define reps(i,n) for(int i=1;i<=int(n);++i)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define iceil(x,y) (x+y-1)/y
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define all(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )

int gcd(int a,int b){return b?gcd(b,a%b):a;}

using namespace std;
typedef long long int ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
typedef pair<int, PII> PP;

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

int main() {
	int x1, y1, x2, y2;
	cin >> x1 >> y1 >> x2 >> y2;
	int dx = x2-x1;
	int dy = y2-y1;
	cout << x2-dy <<" "<< y2+dx <<" "<< x1 - dy << " " << y1+dx << "\n";

	return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import java.lang.reflect.Array;

public class Main {
	public static void main(String[] args) {
		FastReader r = new FastReader();		
		int count = r.ri();
		int k = r.ri();
		int sum = 1;
		for(int i = 0; i<count; i++) {
			if(sum < k)
				sum *= 2;
			else
				sum += k;
		}
		
		print(sum);		
	}

	public static void rolling(int[] arr) {
		if (arr.length < 2)
			return;
		for (int i = 1; i < arr.length; i++)
			arr[i] += arr[i - 1];
	}
	
	public static void rolling(long[] arr) {
		if (arr.length < 2)
			return;
		for (int i = 1; i < arr.length; i++)
			arr[i] += arr[i - 1];
	}

	public static void reverse(int[] arr) {
		for (int i = 0; i < arr.length / 2; i++) {
			int temp = arr[i];
			arr[i] = arr[arr.length - 1 - i];
			arr[arr.length - 1 - i] = temp;
		}
	}
	
	public static void swap(int[] arr, int pos1, int pos2) {
		int temp = arr[pos1];
		arr[pos1] = arr[pos2];
		arr[pos2] = temp;
	}
	public static void swap(long[] arr, int pos1, int pos2) {
		long temp = arr[pos1];
		arr[pos1] = arr[pos2];
		arr[pos2] = temp;
	}
	
	public static String al(String s) {
		return s + "\n";
	}

	public static void print(String s) {
		System.out.println(s);
	}

	public static void print(long s) {
		System.out.println(s);
	}

	public static void print(int s) {
		System.out.println(s);
	}

	static class FastReader {
		BufferedReader br;
		StringTokenizer st;

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

		int ri() {
			return Integer.parseInt(str());
		}

		long rl() {
			return Long.parseLong(str());
		}

		double rd() {
			return Double.parseDouble(str());
		}

		String str() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}

		String[] rsa() {
			return str().split(" ");
		}

		int[] ria() {
			String[] s = rsa();
			int[] arr = new int[s.length];
			for (int i = 0; i < arr.length; i++)
				arr[i] = Integer.parseInt(s[i]);
			return arr;
		}

		long[] rla() {
			String[] s = rsa();
			long[] arr = new long[s.length];
			for (int i = 0; i < arr.length; i++)
				arr[i] = Long.parseLong(s[i]);
			return arr;
		}

		char[] rca() {
			String s = str();
			char[] arr = new char[s.length()];
			for (int i = 0; i < arr.length; i++)
				arr[i] = s.charAt(i);
			return arr;
		}
		
		String[] rsaml(int m) {
			String[] arr = new String[m];
			for (int i = 0; i < arr.length; i++)
				arr[i] = str();
			return arr;
		}

		int[] riaml(int m) {
			int[] arr = new int[m];
			for (int i = 0; i < arr.length; i++)
				arr[i] = Integer.parseInt(str());
			return arr;
		}

		long[] rlaml(int m) {
			long[] arr = new long[m];
			for (int i = 0; i < arr.length; i++)
				arr[i] = Long.parseLong(str());
			return arr;
		}
	}
}

class Node {
	public int val;
	public boolean visited;
	public Node(int v) { val=v; }
}


Measured memory_bytes: 21204
#include <stdio.h>
#include <string>
#include <algorithm>
#include <iostream>
#include <cmath>
using namespace std;

static const int MAX = 1e5;
int n, q, L[MAX], R[MAX], AC[MAX+1], ans;
char S[MAX];
string s, s_i;

int main() {
    scanf("%d %d", &n, &q);
    scanf("%s", S);
    s = S;
    AC[0] = 0;

    for ( int j = 0; j < (int)s.length(); j++ ) {
        AC[j+1] = AC[j];

        if ( (s[j] == 'A') and (s[j+1] == 'C') ) {
            AC[j+1]++;
        }
    }

    for ( int i = 0; i < q; i++ ) {
        scanf("%d %d", &L[i], &R[i]);
        ans = AC[R[i]-1] - AC[L[i]-1];
        printf("%d\n", ans);
    }
    
    
    return 0;
}


Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using pint = pair<int, int>;
using vi = vector<int>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()

template<typename T> T gcd(T a, T b) { return b ? gcd(b, a%b) : a; }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template<class T> void corner(bool flg, T hoge) { if (flg) { cout << hoge << endl; exit(0); } }

const int MOD = 1000000007;

int main() {
    int H, N;
    cin >> H >> N;
    vi A(N);
    rep(i, N) cin >> A[i];

    rep(i, N) H -= A[i];
    if (H > 0) cout << "No" << endl;
    else cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 640
process.stdin.resume();
process.stdin.setEncoding('utf-8');
var input_string = '';

process.stdin.on('data', function(chunk) {
    input_string += chunk;
});

process.stdin.on('end', function() {
    var lines = input_string.split('\n');
    main(lines.slice(0, lines.length-1));
});

function main(lines) {
    var arr = lines[0].split(' ');
    console.log(
        arr.reduce(function(acc, x) {
            return acc * x;
        }, 1),
        arr.reduce(function(acc, x) {
            return acc + x * 2;
        }, 0)
    );
}

Measured memory_bytes: 15584
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    n,k=map(int, input().split())
    l=list(map(int,input().split()))
    l.sort(reverse=True)
    if k>=n:
        ans=0
    else:
        ans=sum(l[k:])
    print(ans)

resolve()

Measured memory_bytes: 26764
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define ll long long 
#define FI first 
#define SE second
#define pb push_back 
#define eb emplace_back
#define mod 1000000007
#define all(c) (c).begin(),(c).end()
#define LB  lower_bound
#define UB  upper_bound
#define max3(a,b,c) max(c,max(a,b))
#define min3(a,b,c) min(c,min(a,b))
#define mems(s, n) memset(s, n, sizeof(s))
#define NINF INT_MIN 
#define INF INT_MAX 
#define int ll int
#define OOK order_of_key  //no of elements less than
#define FBO find_by_order //iterator pointing kth element;indexing starts from 0
#define CK3(x,y,z) cout<<(x)<<" "<<(y)<<" "<<(z)<<endl
#define CK4(a,b,c,d) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<endl

typedef pair<int,int> PII;
typedef pair<pair<int,int>,int> PPII;
typedef pair<int,pair<int,int>> PIPI;
typedef map<int,int>MII;
typedef vector<int> VI;
template <typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

/*int power(int a, int b)
{int x=1,y=a;while(b>0){if(b%2){x =(x*y)%mod;}y =(y*y)%mod;b/=2;}return x%mod;}
*/
//int modInverse(int a, int m) {return power(a, m-2);} //gcd(a,m)=1 


signed main()
{
ios::sync_with_stdio(false); cin.tie(0);
int T=1,T1=0;//cin>>T;
while(T1++<T)
{//cout<<"Case #"<<T1<<":"<<' '; 
   int n;
   cin>>n;VI ar(n);MII mr;int ans=0;
   for(int i=0;i<n;i++)
   {
       cin>>ar[i];
       mr[ar[i]]++;
   }
   for(auto it:mr)ans+=(it.SE*(it.SE-1))/2;
   for(int i=0;i<n;i++)
   {
       cout<<ans-(mr[ar[i]]*(mr[ar[i]]-1))/2+max((int)0,(((mr[ar[i]]-1)*(mr[ar[i]]-2))/2))<<endl;
   }
}


return 0;
}





Measured memory_bytes: 11136
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>
#include <cmath>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
//ll mod = 998244353;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main() {
    int n, d, x;
    cin >> n >> d >> x;
    int ans = 0;
    rep(i, n) {
        int a;
        cin >> a;
        int num = 1;
        int cnt = 0;
        while(1) {
            if (num > d) break;
            num += a;
            ++cnt;
        }
        //cout << cnt << endl;
        ans += cnt;
    }
    cout << ans + x << endl;
    return 0;
}


Measured memory_bytes: 3516
using System;

namespace ITP1_6_A
{
    class Program
    {
        static void Main(string[] args)
        {
            string N=Console.ReadLine();
            int n = int.Parse(N); //数列の長さのn
            string str = Console.ReadLine();
            string[] parseStr = str.Split((char[])null);
            int[] numbers = new int[n];
            if (100 < n)
                Environment.Exit(0);

            for(int i=0;i<n;i++)
            {
                numbers[i] = int.Parse(parseStr[i]); //string[]をint[]に変換
            }

            Array.Reverse(numbers);
            for (int i = 0; i < n; i++)
            {
                if (i < n - 1)
                    Console.Write("{0} ", numbers[i]);
                if (i == n - 1)
                    Console.WriteLine("{0}", numbers[i]);
            }
        }
    }
}


Measured memory_bytes: 17968
#include<stdio.h>
int main(void)
{
	int a,b,c,d,x,y,z;
	scanf("%d %d %d %d",&a,&b,&c,&d);
	x=a+b+c+d;
	y=x/60;
	z=x%60;
	printf("%d\n",y);
	printf("%d\n",z);
	return 0;
}


Measured memory_bytes: 2684
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <math.h>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <iomanip>
#include <numeric>
 
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
multiset<ll,greater<ll>> st[200000];
multiset<ll> ss;
ll N,A,B,C;

int main() {
    cin >> A >> B >> C;
    cin >> N;
    for(int i=0;i<N;i++){
        if(B<=A){
            B *= 2;
        }else{
            C *= 2;
        }
    }
    if(A<B && B < C){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    
}


Measured memory_bytes: 13000
import qualified Data.Vector.Unboxed as U
import qualified Data.Vector as V
import qualified Data.ByteString.Char8 as C
import qualified Data.Array.IO as A
import Debug.Trace
import Data.List
import Control.Monad


r' :: IO [Int]
r'  =   unfoldr    (C.readInt . C.dropWhile (==' ')) <$> C.getLine

main :: IO ()
main = do
    [a,b] <- r'
    print $ maximum [a*b, a+b, a-b]


Measured memory_bytes: 380
N = int(input())
T,A = map(int,input().split())
H = list(map(int,input().split()))
_min = 0
for i in range(N):
	#print(abs(A - (T - H[i]*0.006)))
	if abs(A - (T - H[_min]*0.006))   >= abs(A - (T - H[i]*0.006)):

		_min = i
	
print(_min+1)

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

const int MAXN = 10;
int N;
bool used[MAXN];
string A[MAXN];
set<int> vis;

void rec(string num, int k) {
  if(k == 0) {
    vis.insert(atoi(num.c_str()));
    return;
  }
  for(int i = 0; i < N; ++i) {
    if(used[i]) continue;
    used[i] = true;
    rec(num+A[i], k-1);
    used[i] = false;
  }
}

int main() {
  int k;
  while(cin >> N && N) {
    cin >> k;
    for(int i = 0; i < N; ++i) {
      cin >> A[i];
    }
    vis.clear();
    rec("", k);
    cout << vis.size() << endl;
  }
  return 0;
}

Measured memory_bytes: 1340
import java.util.*;

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

        String s = sc.next();

        int iA = 0;
        while(s.charAt(iA) != 'A'){
            ++iA;
        }
        
        int iZ = s.length()-1;
        while(s.charAt(iZ) != 'Z'){
            --iZ;
        }

        int ans = iZ - iA + 1;

        System.out.println(ans);
    }
}



Measured memory_bytes: 26576
def pin(type=int):
    return map(type,input().split())
#どっかで最悪計算量の入力データを用意する関数を作ろう？
"""
バケットで管理したかったけど数字が多いのでソートして同じ数を固めることに
"""
#solution:
#潜 影 蛇 手 ! !
N=int(input())
S=input()
T=input()
ans=""
for i in range(N):
    #print(i)
    flag=1
    for j in range(N):
        if j+i<N :
            #print(S[j],S[j+i])
            if S[i+j]!=T[j]:
                flag=0
                break
    if flag==1:
            #p#Zrint(i)
        ans+=S[0:i]+T
        break
a=len(ans) if len(ans)!=0 else 2*N
print(a)
#print(["NO","YES"][1-cond])
#print([["NA","YYMM"],["MMYY","AMBIGUOUS"]][cMMYY][cYYMM])

Measured memory_bytes: 38256
N=int(input())
A=int(input())
B=int(input())
C=int(input())
D=int(input())
E=int(input())




minimum=min(A,B,C,D,E)
if minimum>=N:
    print(5)
else:
    if N%minimum==0:
        print(N//minimum+4)
    else:
        print(N//minimum +5)


Measured memory_bytes: 3060
#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 <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <stdio.h>
#include <complex>
#include <cstdint>
#include <tuple>

#define M_PI       3.14159265358979323846

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }
inline int readInt() { int x; scanf("%d", &x); return x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util

//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) (a*a)
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)
#define MOD 998244353

int main() {
	string str;
	cin >> str;
	if ((str.length() & 1) ^ (str[0] == str[str.length() - 1]))cout << "First" << endl;
	else cout << "Second" << endl;
	return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<cstdio>
#include<vector>
#include<map>
#include<string>
#include<algorithm>
#include<math.h>
#include<numeric>

using namespace std;

typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef vector<long long> vll;
typedef pair<long long, long long> pll;

const ll INF = 1e9;
const ll MOD = 1e9 + 7;

int main(){
	int W, a, b;
	cin >> W >> a >> b;
	if (a <= b){
		cout << max(0, b - (a + W)) << endl;
	}
	else{
		cout << max(a - (b + W), 0) << endl;
	}
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<time.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-10;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
int main(){
	int q[5]={0,6000,4000,3000,2000};
	rep(i,4){
		int a,b;
		cin>>a>>b;
		cout<<q[a]*b<<endl;
	}
}

Measured memory_bytes: 1160
def calculate(n,q,S):
    indexes = [0 for i in range(n)]

    arr = list(S)

    for i in range(len(arr)):
        if i == 0:
            indexes[i] = 0
            continue
        if arr[i] == 'C' and arr[i-1] == 'A':
                indexes[i] = indexes[i-1] + 1
        else:
            indexes[i] = indexes[i-1]
    return indexes

def conclution(res,Q):
    for qrr in Q:
        s2 = res[qrr[1]-1]
        s1 = res[qrr[0]-1]
        print(s2-s1)


input1 = input().split(" ")

n = int(input1[0])
q = int(input1[1])
S = input()

res = calculate(n,q,S)

qrr = []

for i in range(q):
    qrr.append([int(s) for s in input().split()])

conclution(res, qrr)



Measured memory_bytes: 24496
s=input()
n=len(s)
ans=0
for i in range(2**(n-1)):
    x=[0]*(n-1)
    k=i
    for j in range(n-1):
        x[j]+=k//(2**(n-2-j))
        k-=2**(n-2-j)*(k//(2**(n-2-j)))
    a=s[0]
    for j in range(n-1):
        if x[j]==0:
            a=a+s[j+1]
        else:
            ans+=int(a)
            a=s[j+1]
    ans+=int(a)
print(ans)

Measured memory_bytes: 70660
import sys
input = sys.stdin.readline
  
def solve():
  n = int(input())
  maxi = -10
  maxi2 = -10
  place = -1
  for i in range(n):
    a = int(input())
    if a>maxi:
      maxi2 = maxi
      maxi = a
      place = i
    else:
      maxi2 = max(maxi2,a)
  for j in range(n):
    if place == j:
      print(maxi2)
    else:
      print(maxi)
  
solve()

Measured memory_bytes: 4540
#include<bits/stdc++.h>
using namespace std;
string a,b;
set<char>ss[100];
set<char>sss[100];
vector<int>s[100];
int main(){
	//cout<<'z'-'a'<<endl;
	cin>>a>>b;
	for(int i=0;i<a.size();i++){
		ss[b[i]-'a'].insert(a[i]);
		sss[a[i]-'a'].insert(b[i]);
	}
	for(int i=0;i<=23;i++){
		if(ss[i].size()>1||sss[i].size()>1){
			cout<<"No"<<endl;
			return 0;
		}	
	}
	cout<<"Yes"<<endl;
	return 0;
}

Measured memory_bytes: 776
#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <stack>
#include <functional>
#include <set>
#include <map>
#include <deque>
#include <cmath>
#define WMAX 10000
#define HMAX 10000

//コメントアウトするとdebug()を実行しない
#define DEBUG

using namespace std;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

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

struct edge{
  int to,cost;
};

int A,B,C,N,W,H,ans,dp[HMAX][WMAX];
char a[HMAX][WMAX];
string S;
static const int dx[8] = {0,1,1,1,0,-1,-1,-1},
					dy[8] = {1,1,0,-1,-1,-1,0,1};

void solve(){


}

void debug(){

}

void answer(){
	for (int i = 0; i < W+2; ++i)
	{
		cout << '#';
	}
	cout << "\n";
	for (int i = 0; i < H; ++i)
	{
			cout << '#';
		for (int j = 0; j < W; ++j)
		{
			cout << a[i][j];
		}
		cout << "#\n";
	}
	for (int i = 0; i < W+2; ++i)
	{
		cout << '#';
	}
	cout << "\n";
}

int main(){
	cin >> H >> W;
	for (int i = 0; i < H; ++i)
	{
		for (int j = 0; j < W; ++j)
		{
			cin >> a[i][j];
		}
	}
	solve();
	#ifdef DEBUG
	debug();
	#endif
	answer();

	return 0;
}

Measured memory_bytes: 640
#include<stdio.h>

int main()
{
  int x,i,y,c,d;
  scanf("%d%d",&x,&y);
  while(1){
    d=x%y;
    if(d==0)break;
    x=y;
    y=d;
  }
  printf("%d\n",y);
  return 0;
}


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

constexpr int INF = 2147483647;
constexpr long long int INF_LL = 9223372036854775807;
constexpr int MOD = 1000000007;
using namespace std;
using ll = long long int;
using ull =  unsigned long long int;

int main() {
	double W, H, x, y;
	cin >> W >> H >> x >> y;
	cout << W * H / 2 << " " << (x == W / 2 && y == H / 2) << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cctype>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;

int main() {
    int n;
    while (cin >> n, n) {
        vector<int> ss(n);
        for (auto& s : ss) {
            cin >> s;
        }
        double m = (double) accumulate(begin(ss), end(ss), 0) / n;
        double var = 0;
        for (auto s : ss) {
            var += (s - m) * (s - m);
        }
        var /= n;
        printf("%.8f\n", sqrt(var));
    }
}

Measured memory_bytes: 1212
#include <iostream>
using namespace std;
#define ll long long int
int main(){
    ll a, b;
    cin>>a>>b;
    if (a==1 || b==1) cout<<1<<endl;
    else {
        ll c=a/2+a%2;
        ll d=a/2;
        c=c*(b/2+b%2);
        d=d*(b/2);
        cout<<c+d<<endl;
    }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		//数取得
		String alfa = sc.next();
		sc.close();

		char answer = 'A';

		for(char a = 'a'; a <= 'z'; a++) {
			if(alfa.charAt(0) == a) {
				answer = 'a';
			}
		}

		System.out.println(answer);
	}

}


Measured memory_bytes: 26884
#!/usr/bin/env python3
import sys


def solve(L: int):
    print((L/3)**3)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    L = int(next(tokens))  # type: int
    solve(L)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
  using namespace std;
#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) int ab;cin>>ab;(p).push_back(ab);
#define vecpl2(p) long long ab;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define set0(k,n) for(int nn=0;nn<(n);nn++){ (k).push_back(0); }
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define vecsize(b,size) vector<int> (b)((size));
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsl(s) vector<pair<ll,ll>> (s);
#define pairss(s) vector<pair<string,string>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairspl(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsps(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsREV(s) (s).push_back(make_pair(bb,aa));
#define pairslREV(s) (s).push_back(make_pair(bb,aa));
#define pairssREV(s) (s).push_back(make_pair(bb,aa));
#define MOD 1000000007

int main() {
	
int N,A;
cin>>N>>A;
int k=N%500;
if(k<=A){
	ce("Yes")
}else{
	ce("No")
}
}


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

using namespace std;

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

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

ll A[3005];
ll dp[3005][3005];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    REP(i, N) {
        cin >> A[i];
    }
    memset(dp, 0, sizeof(dp));
    if (N % 2 == 1) {
        REP(i, N) {
            dp[i][i] = A[i];
        }
    }
    FOR(len, N, 1) {
        REP(i, N) {
            if (i + len >= N)
                break;
            if (len % 2 == N % 2) {
                //! second
                dp[i][i + len] = std::min(dp[i][i + len - 1], dp[i + 1][i + len]);
            }
            else {
                //! firts
                dp[i][i + len] = std::max(dp[i][i + len - 1] + A[i + len], dp[i + 1][i + len] + A[i]);
            }
        }
    }

    ll sum = 0;
    REP(i, N) {
        sum += A[i];
    }
    ll mx = dp[0][N - 1];
    cout << mx - (sum - mx) << endl;
    return 0;
}

Measured memory_bytes: 70784
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <time.h>
#include <stdlib.h>
#include <string>
#include <bitset>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <sstream>
#include <stack>
#include <iomanip>
using namespace std;
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<ll,ll> pii;
typedef double ld;
typedef vector<int> vi;
#define fi first
#define se second
#define fe first
#define FO(x) {freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);}
#define Edg int M=0,fst[SZ],vb[SZ],nxt[SZ];void ad_de(int a,int b){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;}void adde(int a,int b){ad_de(a,b);ad_de(b,a);}
#define Edgc int M=0,fst[SZ],vb[SZ],nxt[SZ],vc[SZ];void ad_de(int a,int b,int c){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;vc[M]=c;}void adde(int a,int b,int c){ad_de(a,b,c);ad_de(b,a,c);}
#define es(x,e) (int e=fst[x];e;e=nxt[e])
#define esb(x,e,b) (int e=fst[x],b=vb[e];e;e=nxt[e],b=vb[e])
#define SZ 666666
int n,m,a[SZ];
pii qzh[SZ];
pii operator + (pii a,pii b)
{return pii(a.fi+b.fi,a.se+b.se);}
pii operator - (pii a,pii b)
{return pii(a.fi-b.fi,a.se-b.se);}
void add(int l,int r,pii g)
{
	if(l>r) return;
	qzh[l]=qzh[l]+g; qzh[r+1]=qzh[r+1]-g;
}
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;++i) scanf("%d",a+i);
	for(int i=1;i<n;++i)
	{
		if(a[i]<=a[i+1])
		{
			add(a[i]+1,a[i+1],pii(-1,a[i+1]+1));
			add(1,a[i],pii(0,a[i+1]-a[i]));
			add(a[i+1]+1,m,pii(0,a[i+1]-a[i]));
		}
		else
		{
			add(a[i]+1,m,pii(-1,a[i+1]+m+1));
			add(1,a[i+1],pii(-1,a[i+1]+1));
			add(a[i+1]+1,a[i],pii(0,a[i+1]+m-a[i]));
		}
	}
	for(int i=1;i<=m;++i)
		qzh[i]=qzh[i-1]+qzh[i];
	ll ans=1e18;
	for(int i=1;i<=m;++i)
		ans=min(ans,qzh[i].fi*i+qzh[i].se);
	cout<<ans<<"\n";
}

Measured memory_bytes: 3840
#include<cstdio>
#include<math.h>
#include<algorithm>
#include<vector>

using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1001001001;
#define LLINF 1001001001001001001001;
#define LL long long

int main(){
   vector<int> nums;int A,B,C;
    scanf("%d %d %d",&A,&B,&C);
    nums.push_back(A);nums.push_back(B);nums.push_back(C);
    sort(nums.begin(),nums.end());
    if((nums[1]-nums[0])%2==0){
        printf("%d\n",(nums[1]-nums[0])/2+(nums[2]-nums[1]));
    }else{
        printf("%d\n",(nums[1]-nums[0]+1)/2+(nums[2]-nums[1])+1);
    }
    return 0;
}

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

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { std::cout << #a << " = " << a << "\n"; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }
template<class T, class V> istream& operator>> (istream& ist, pair<T, V>& p) { return ist >> p.first >> p.second; }
template<class T> ostream& operator<< (ostream& ost, pair<T, T>& p) { return ost << p.first << ", " << p.second; }
template<class T> istream& operator>> (istream& ist, vector<T>& vs) { for(auto& e: vs) ist >> e; return ist; }

typedef long long ll;
int const inf = INT_MAX / 2;

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

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

int get_max_distance(vector<string> const& F, int H, int W, int si, int sj) {
  queue<pair<int, int>> q;
  q.emplace(si, sj);
  vector<vector<int>> dist(H, vector<int>(W, inf));
  dist[si][sj] = 0;
  int ans = 0;
  while (!q.empty()) {
    const auto p = q.front(); q.pop();
    const auto y = p.first;
    const auto x = p.second;
    rep(k, 4) {
      const auto ny = y + dy[k];
      const auto nx = x + dx[k];
      if (!in_field(ny, nx, H, W)) { continue; }
      if (F[ny][nx] == '#') { continue; }
      if (dist[ny][nx] < inf) { continue; }
      dist[ny][nx] = dist[y][x] + 1;
      ans = max(ans, dist[ny][nx]);
      q.emplace(ny, nx);
    }
  }
  return ans;
}

int main() {
  int H, W; cin >> H >> W;
  vector<string> F(H);
  rep(i, H) cin >> F[i];
  int ans = 0;
  rep(i, H) rep(j, W) {
    if (F[i][j] == '#') { continue; }
    ans = max(ans, get_max_distance(F, H, W, i, j));
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
n,m=map(int,input().split())
mod=pow(10,9)+7
if m==1:
  print(1)
  exit()
def factorization(n):
  arr = []
  temp = n
  for i in range(2, int(-(-n**0.5//1))+1):
    if temp%i==0:
      cnt=0
      while temp%i==0:
        cnt+=1
        temp //= i
      arr.append([i, cnt])
  if temp!=1:
    arr.append([temp, 1])
  if arr==[]:
    arr.append([n, 1])
  return arr

# コンビネーション、さらに高速。あらかじめO(N)の計算をすることでのちの計算が早くなる
def cmb(n,r,mod):
  if (r<0 or r>n):
    return 0
  r=min(r,n-r)
  return g1[n]*g2[r]*g2[n-r]%mod
g1=[1,1] 
g2=[1,1] 
inverse=[0,1]
for i in range(2,n+30+1):
  g1.append((g1[-1]*i)%mod)
  inverse.append((-inverse[mod%i]*(mod//i))%mod)
  g2.append((g2[-1]*inverse[-1])%mod)

l=factorization(m)
ans=1
for li in l:
  b=li[1]
  ans*=cmb(b+n-1,n-1,mod)
  ans%=mod
print(ans)

Measured memory_bytes: 20896
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <cstring>
#include <cstdlib>
#include <cmath>
using namespace std;
using ll = long long;

ll L;

struct Graph {
    static constexpr ll INF = 1LL << 59;
    struct VertexQ {
        bool operator<(const VertexQ &o) const {
            return c > o.c; // 逆
        }
        int i;
        ll c;
    };
    struct Vertex { int n; ll c; };
    struct Edge { int i, n, c; };
    Graph(int n, int m) : v(n, { -1 }), e(m), n(n), m(0) {}
    void add_edge(int i, int j, int c) {
        if (c > L) return;
        e[m] = { j, v[i].n, c };
        v[i].n = m;
        m++;
    }
    void dijkstra(int i) {
        for (int i = 0; i < n; i++) v[i].c = INF;
        priority_queue<VertexQ> q;
        q.push({ i, v[i].c = 0 });
        while (!q.empty()) {
            auto p = q.top(); q.pop();
            if (p.c > v[p.i].c) continue;
            for (int j = v[p.i].n; j >= 0; j = e[j].n) {
                Edge &o = e[j];
                ll c = p.c + o.c;

                if (c % (1LL << 32) > L) {
                    c = p.c - p.c % (1LL << 32) + (1LL << 32) + o.c;
                }

                if (c < v[o.i].c) q.push({ o.i, v[o.i].c = c });
            }
        }
    }
    vector<Vertex> v;
    vector<Edge> e;
    int n, m;
};

ll p[300][300];

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

    int n, m;
    cin >> n >> m >> L;

    Graph g(n, m * 2);
    for (int i = 0; i < m; i++) {
        int a, b, c;
        cin >> a >> b >> c;
        a--; b--;

        g.add_edge(a, b, c);
        g.add_edge(b, a, c);
    }

    for (int i = 0; i < n; i++) {
        g.dijkstra(i);
        for (int j = 0; j < n; j++) {
            p[i][j] = g.v[j].c;
        }

    }

    int q;
    cin >> q;

    for (int h = 0; h < q; h++) {
        int s, t;
        cin >> s >> t;
        s--; t--;

        ll x = p[s][t];
        cout << (x == g.INF ? -1 : (x >> 32)) << '\n';
    }

    return 0;
}

Measured memory_bytes: 3040
using System;
class Program
{
	static void Main(string[] args)
	{
        string input = Console.ReadLine();
        int N = int.Parse(input);

        int count = 0;
        for (int i = 1; i < N; i++)
        {
            for (int j = 1; j < i; j++)
            {
                if(i*j < N)
                {
                    count += 2;
                }
                else
                {
                    break;
                }
            } 
        }

        int x = 1;
        while(true)
        {
            if(x*x < N)
            {
                x++;
                count++;
            }
            else
            {
                break;
            }
        }
		//出力
		Console.WriteLine(count);
	}
}

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

const int maxn = 234567;
int n;
long double a[maxn], A[maxn];
long double b[maxn], B[maxn];
int l[maxn], r[maxn];
bool isb[maxn];

void input()
{
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> n;
  F1 (i, n) cin >> A[i];
  F1 (i, n) cin >> B[i];
}

void solve()
{
  pair<long double, int> pos = make_pair(0, 0);
  F1 (i, n) pos = max(pos, make_pair(A[i], i));
  F1 (i, n) a[(i - pos.second + n) % n] = A[i];
  F1 (i, n) b[(i - pos.second + n) % n] = B[i];

  a[n] = a[0], b[n] = b[0];
  for (int i = n; i >= 1; --i) a[i] -= a[i - 1];
  a[0] = 0;
  for (int i = n; i >= 1; --i) a[i] -= a[i - 1];
  queue<int> q;
  F1 (i, n) if (a[i] >= b[i - 1] * 2) q.push(i);
  F1 (i, n) l[i] = i - 1; 
  F1 (i, n) r[i] = i + 1;

  while (!q.empty())
  {
    int cur = q.front();
    q.pop();
    if (isb[cur]) continue;
    isb[cur] = true;
    int x = l[cur], y = r[cur];
    if (x >= 1)
    {
      a[x] += (a[cur] - b[cur - 1] * 2) * (y - cur) / (y - x);
      if (a[x] >= b[x - 1] * 2) q.push(x);
    }
    if (y <= n)
    {
      a[y] += (a[cur] - b[cur - 1] * 2) * (cur - x) / (y - x);
      if (a[y] >= b[y - 1] * 2) q.push(y);
    }
    a[cur] = b[cur - 1] * 2;
    r[l[cur]] = r[cur];
    l[r[cur]] = l[cur];
  }
  F1 (i, n) a[i] += a[i - 1];
  F1 (i, n) a[i] += a[i - 1];
  F1 (i, n) a[i] += a[i - 1];
  cout << setprecision(20) << a[n - 1] / n + pos.first << '\n';
}

main()
{
  input();
  solve();
}

Measured memory_bytes: 18540
a,b=map(int,input().split())
if b==0:
  print(a)
  exit()
s=list(map(int,input().split()))

lst=[i for i in range(0,202)]
for j in range(b):
  lst.remove(s[j])


n=100
for k in lst:
  m=abs(a-k)
  n=min(n,m)

if (a-n) in lst:
  print(a-n)
  exit()
else:
  print(a+n)


Measured memory_bytes: 9204
inputs = readlines.map{ |line| line.chomp }

people_number = inputs[0].to_i
inputs.delete_at(0)
days = inputs[0].split(" ")[0].to_i
after_choco_number = inputs[0].split(" ")[1].to_i
inputs.delete_at(0)
a_array = inputs.map { |element| element.to_i }

def eat_days(a, index, max)
    days = [1]
    i = 1
    day = 0
    loop do
        day = a * i + 1
        break if day > max
        days << i * a + 1
        i += 1
    end
    days
end

eating_days = a_array.map.with_index { |a, index| eat_days(a, index, days) }
ate_choco_number = eating_days.flatten.length

before_choco_number = ate_choco_number + after_choco_number

puts before_choco_number

Measured memory_bytes: 1788