akhauriyash/Code-Regression huggingface dataset:
import os
import sys
from io import BytesIO, IOBase


def main():
    n = list(input())
    n = list(map(int, n))
    if sum(n) % 9 == 0:
        print("Yes")
    else:
        print("No")

# region fastio

BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

# endregion

if __name__ == "__main__":
    main()

Measured memory_bytes: 12720
#include<bits/stdc++.h>
using namespace std;
#define int long long
int n,m;
signed main(){
	scanf("%lld%lld",&n,&m);
	if(n==1||m==1)puts("1");
	else printf("%lld\n",n*m/2ll+((n*m)&1ll));
	return 0;
}

Measured memory_bytes: 256
ans [r,t] 
  | mr == 0 && mt == 0 = [dr + 5*dt]
  | mr == 0 && mt /= 0 = [dr + 5*dt, dr + 5*(dt+1)]
  | mr /= 0 && mt == 0 = [dr + 5*dt, (dr+1) + 5*dt]
  | mr /= 0 && mt /= 0 = [dr + 5*dt, (dr+1) + 5*dt, dr + 5*(dt+1), dr+1 + 5*(dt+1)]
  | otherwise          = [0]
  where
    mr = r `mod` 100
    dr = r `div` 100
    mt = t `mod` 30
    dt = t `div` 30
        
main = do
  _ <- getLine
  c <- getContents
  let i = map (map read) $ map words $ lines c :: [[Int]]
      o = map ans i
  mapM_ putStrLn $ map unwords $ map (map show) o

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

int main() {
	ll n;	cin >> n;
	map <ll, ll> m;	vector <ll> v(n);
	for (int i = 0; i < n; i++) {
		cin >> v[i];
		m[v[i]]++;
	}
	ll ans = 0;
	for (auto i: m) {
		ans += (i.second * (i.second - 1)) / 2;
	}
	for (int i = 0; i < n; i++) {
		cout << max(ans - m[v[i]] + 1, 0ll) << endl;
	}

	return 0;
}

Measured memory_bytes: 12288
#include <stdio.h>
#include <string.h>

int main(void) {
    int i;
    int length;
    char input[20];
    char output[20];
    scanf("%s",input);
    length = strlen(input);
    for(i = 0;i < length;i++){
        output[(length-1)-i] = input[i];
    }
    output[length] = '\0';
    printf("%s\n",output);
	return 0;
}

Measured memory_bytes: 1740
N, T=input().split(" ")

N=int(N)
T=int(T)
c1=list()
c2=list()
for i in range(N):
    temp=input().split(" ")
    c1.append(int(temp[0]))
    c2.append(int(temp[1]))

if min(c2)>T:
    print("TLE")
else:
    min_cost=min([c1[i] for i in range(len(c2)) if c2[i]<=T])
    print(c1[c1.index(min_cost)])

Measured memory_bytes: 3064
#include <bits/stdc++.h>
// #include <atcoder/all>
#define ll long long int
#define ld long double
#define yorn(f) cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repi(i, n) for (ll i = 1; i < (ll)(n); i++)
#define all(x) (x).begin(), (x).end()
#define put(x) cout << x << endl;
#define println(x) cout << x << endl;
using namespace std;
// using namespace atcoder;

ll mpow(ll x, ll n, ll mod){
    ll ans = 1;
    while(n != 0){
        if(n&1) ans = ans*x % mod;
        x = x*x % mod;
        n = n >> 1;
    }
    return ans;
}

ll combination(ll n, ll a, ll mod) {
    ll X = 1;
    for (ll i = n - a + 1; i <= n; i++) {
        X = (X * i) % mod;
    }
    ll Y = 1;
    for (ll i = 1; i <= a; i++) {
        Y = (Y * i) % mod;
    }

    ll iY = mpow(Y, mod - 2, mod);
    return X * iY % mod;
}

void Main()
{
    ll n, a, b;
    cin >> n >> a >> b;

    ll mod = 1e9 + 7LL;
    ll res = mpow(2, n, mod);
    res = (res - 1 + mod) % mod;
    res = (res - combination(n, a, mod) + mod) % mod;
    res = (res - combination(n, b, mod) + mod) % mod;

    put(res);
}
signed main(){ Main();return 0;}

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


#define vt vector
#define all(c) (c).begin(), (c).end()
#define sz(x) (int)(x).size()
#define ll long long
#define ld long double
#define ar array
#define inf() ifstream cin("d.txt")
#define onf() ofstream cout("test.txt")
#define mod 1000000007
#define pb push_back
#define endl cout<<"\n";
#define prt1(a) cout<<a<<" "
#define prt2(a,b) cout<<a<<" "<<b<<" "
#define prt3(a,b,c) cout<<a<<" "<<b<<" "<<c<<" "
#define in(a) cin>>a
#define inn(a,b) cin>>a>>b
#define innn(a,b,c) cin>>a>>b>>c 
#define rep(i,st,end) for(int i=st;i<end;i++)
#define repv(i,st,end) for( i=st;i>=end;i--)
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define TEST ll tc;cin>>tc;while(tc--)
#define EACH(x, a) for (auto& x: a)

template<class A> void read(vt<A>& v);
template<class A, size_t S> void read(ar<A, S>& a);
template<class T> void read(T& x) {
    cin >> x;
}
void read(double& d) {
    string t;
    read(t);
    d=stod(t);
}
void read(long double& d) {
    string t;
    read(t);
    d=stold(t);
}
template<class H, class... T> void read(H& h, T&... t) {
    read(h);
    read(t...);
}
template<class A> void read(vt<A>& x) {
    EACH(a, x)
        read(a);
}
template<class A, size_t S> void read(array<A, S>& x) {
    EACH(a, x)
        read(a);
}
#define debug(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a <<"\n";
    err(++it, args...);
}

// to find root  call using root(arr,element)

ll root (ll Arr[ ] ,ll i)
{
    while(Arr[ i ] != i)
    {
        Arr[ i ] = Arr[ Arr[ i ] ] ; 
i = Arr[ i ]; 
    }
return i;
}

  // to do union  initilize size[] by 1 
void weighted_union(ll Arr[ ],ll size[ ],ll A,ll B)
{
    ll root_A = root(Arr,A);
    ll root_B = root(Arr,B);
    if(size[root_A] < size[root_B ])
    {
Arr[ root_A ] = Arr[root_B];
size[root_B] += size[root_A];
}
    else
    {
Arr[ root_B ] = Arr[root_A];
size[root_A] += size[root_B];
}

}


void solve()
{
    ll n,m ;
    read(n,m);
    ll arr[n],size[n];
    rep(i,0,n)
    {
      arr[i] =  i;
      size[i] = 1;
    }
    rep(i,0,m)
    {
      ll x ,y ;
      read(x,y);
      --x;--y;
      if(root(arr,x)!=root(arr,y))
        weighted_union(arr,size,x,y);
    }
    map<ll,ll>mp;
    rep(i,0,n)
    mp[root(arr,i)]++;

    ll mx = 0;
    EACH(it,mp)
    mx=max(it.second ,mx);
    cout<<mx;
}

 int main()
 {
    fio;
    ll k = 1;
    ll tc = 1;
    // cin>>tc;
    while(tc--){
       // cout<<"Case #"<<k<<": ";k++;
        solve();
        endl;
    }
    
 }




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

int main() 
{
    int n;
    cin >> n;
    string s, t;
    cin >> s >> t;
    string q = "";
    for (int i=0; i<n; i++)
        q=q+s[i]+t[i];
    cout << q;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define min(a,b) ((a) < (b) ? a : b)
#define max(a,b) ((a) > (b) ? a : b)
main()
{

    int a,b,c,a1,b1,c1;

    while(scanf("%d %d %d",&a,&b,&c)!=EOF){

    a1=min(min(a,b),c);
    c1=max(max(a,b),c);
    if(a1!=a && c1!=a ) b1=a;
    else if (a1!=b && c1!=b) b1=b;
    else b1=c;
        printf("%d %d %d\n",a1,b1,c1);
    }

    return 0;




}



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

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

	const size_t ss = s.size();
	int c[2] = {0,0};
	for (size_t i = 0; i < ss; i += 2) {
		if (s[i] == '1') {
			++c[0];
		}
		else{
			++c[1];
		}
	}
	for (size_t i = 1; i < ss; i += 2) {
		if (s[i] == '1') {
			++c[1];
		}
		else {
			++c[0];
		}
	}

	cout << min(c[0], c[1]) << endl;

	return 0;
}

Measured memory_bytes: 512
package main

import (
        "fmt"
)

func solution(s string) int {
        max := func(x, y int) int {
                if x > y {
                        return x
                }
                return y
        }

        isACGT := func(s string) bool {
                for _, r := range s {
                        if !(r == 'A' || r == 'C' || r == 'G' || r == 'T') {
                                return false
                        }
                }
                return true
        }

        l := len(s)
        out := 0
        for i := 0; i <= l; i++ {
                for j := i + 1; j <= l; j++ {
                        t := s[i:j]
                        if isACGT(t) {
                                out = max(out, len(t))
                        }
                }
        }
        return out
}

func main() {
        var s string
        fmt.Scan(&s)
        fmt.Println(solution(s))
}

Measured memory_bytes: 1768
#include <algorithm>
#include <cmath>
#include <iostream>
#include <queue>
#include <stdio.h>
#include <string>
#include <vector>

#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const double PI = 3.1415926535897932;

/* a と b の最大公約数を返す関数 */
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

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

	vector<int> Ai(N, 0);
	vector<ll> vote((N + 1), 0);

	int t;
	rep(i, N)
	{
		cin >> t;
		Ai.at(i) = t;
		vote[t] += 1;
	}
	
	ll all = 0;
	for (int i = 1; i <= N; ++i)
	{
		all += vote[i] * (vote[i] - 1) / 2;
	}
	
	ll ans;
	int before, after, val;
	for (int i = 0; i < N; ++i)
	{
		val = vote[Ai[i]];
		before = val * (val - 1) / 2;
		after = (val -1) * (val - 2) / 2;

		ans = all - before + after;
		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 5636
#include <bits/stdc++.h>
#include <string>
#include <cstring>
#include <algorithm>
#include <math.h>
#include <map>
#include <bitset>
#include <cmath>
#include <set>
#include <utility>
#include <sstream>

#define INF 1000000000000
#define MOD 1000000007 //10^9+7:合同式の法

using namespace std;
typedef long long ll;

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

    if(N < 1200)
        cout << "ABC" << endl;
    else if(N < 2800)
        cout << "ARC" << endl;
    else
        cout << "AGC" << endl;

} 

Measured memory_bytes: 3584
#include <iostream>
#include <algorithm>
using namespace std;
int main(){

	int x,y,i;

	for(i=0; i<=3000; i++){
		cin>>x>>y;
		if (x==0 && y==0) break;

		if(x>y)
			swap(x,y);

		cout<<x<<" "<<y<<endl;

	}

	return 0;
}


Measured memory_bytes: 3052
#include <stdio.h>

int main(int argc, char const *argv[]) {
  int aa,j,b,c,d=0,i,n[100],k[30][30];
  char a[3];
  scanf("%s",a);
  if (a[0]==a[1]&&a[0]==a[2]) {
    printf("No");
    return 0;
  }
  printf("Yes");
  return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
using namespace std;
int main(void)
{ 
  int n,l,i,sum,ans;
  cin>>n>>l;
  sum=0;
  for(i=1;i<=n;i++)
  {
    sum+=(l+i-1);
  }

  if(l>0){sum-=l;}
  else if(l+n-1<0){sum-=l+n-1;}
  cout<<sum<<endl;
  
}

Measured memory_bytes: 3568
#define _USE_MATH_DEFINES
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdio.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
using namespace std;
int main() {
	int n, k,cnt=1,A[100000];
	cin >> n >> k;
	rep(i, n)cin >> A[i];
	int s = k;
	while (s < n) {
		s += k - 1;
		cnt++;
	}

	cout << cnt << endl;

	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
//#include <math.h>
//#include <queue>
//#include <stack>
//#include <iomanip>

// sometimes used
//#include <set>
//#include <map>
//#include <numeric>
//#include <list>
//#include <deque>
//#include <unordered_map>

typedef long long LL;
//typedef long double LD;
using namespace std;
 
//#define MOD 1000000007
//#define MAX 10000100
//#define NIL -1

int main() {
    string s;
    cin >> s;
    reverse(s.begin(), s.end());
    vector<string> w={"dream", "dreamer", "erase", "eraser"};
    for(LL i=0; i<4; i++){
        reverse(w[i].begin(), w[i].end());
    }

    LL idx=0;
    bool is_word_ok;
    bool is_char_ok;
    while(idx<s.size()){
        is_word_ok=false;
        for(LL i=0; i<4; i++){
            is_char_ok=true;
            if(w[i].size()+idx<=s.size()){
                for(LL j=0; j<w[i].size(); j++){
                    if(s[idx+j]!=w[i][j]){
                        is_char_ok=false;
                        break;
                    }
                }
                if(is_char_ok==true){
                    is_word_ok=true;
                    idx+=w[i].size();
                    //cout << w[i] << endl;
                    break;
                }
            }
        }
        //cout << idx << " " << is_word_ok << endl;
        if(is_word_ok==false){
            break;
        }
    }

    if(is_word_ok==true){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }

    return 0;
}


Measured memory_bytes: 3768
object Main {
  def main(args: Array[String]): Unit = {
    val scanner = new java.util.Scanner(System.in)

    while(true) {
      val n = scanner.nextInt
      if(n == 0) System.exit(0)
      val ns = Seq.fill(n)(scanner.nextInt)

      val m = ns.sum.toDouble / n
      println(f"${math.sqrt(ns.foldLeft(0.0d){ case (s, si) => s + (si - m) * (si - m) } / n)}%.5f")
    }
  }
}



Measured memory_bytes: 49396
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int mod=7+1e9;
ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
ll lcm(ll x,ll y){return x/gcd(x,y)*y;}
ll qpow(ll a,ll b,ll p){a%=p; ll ret=1;for(;b;b>>=1,a=a*a%p) if(b&1) ret=ret*a%p; return ret;}
ll getInv(ll x,ll p){return qpow(x,p-2,p);}
const int N=5+2e5;
ll n[N];
ll C(ll a,ll b){ return n[a]*getInv(n[b]*n[a-b]%mod,mod)%mod;}
int main(){
    ll h,w,a,b; cin>>h>>w>>a>>b;
    n[0]=1;
    for(int i=1;i<N;i++) n[i]=n[i-1]*i%mod;
    ll ans=0;
    for(int i=b+1;i<=w;i++)
        ans=(ans+C(h-a-1+i-1,h-a-1)*C(a-1+w-i,w-i)%mod)%mod;
    ans=(ans+mod)%mod;
    cout<<ans<<'\n';
}

Measured memory_bytes: 5120
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int main() {
  int i, j;
  int N;
  int temp;

  scanf("%d", &N);
  temp = (int)log2((double)N);
  printf("%d", (int)pow(2, temp));

  return 0;
}

Measured memory_bytes: 384
#include <stdio.h>
#define k 20000001
int A[k],B[k],C[k];
int main()
{
  int i,n;
 
  scanf("%d",&n);
  for(i=0;i<n;i++)
    {
      scanf("%d",&A[i+1]);
      C[i]=0;  
    }

  for(i=1;i<=n;i++)
    {
      C[A[i]]=C[A[i]]+1;
    }
  for(i=1;i<k;i++)
    {
      C[i]=C[i]+C[i-1];
    }
  for(i=n;i>0;i--)
    {
      B[C[A[i]]]=A[i];
      C[A[i]]=C[A[i]]-1;
    }

  for(i=1;i<=n-1;i++)
    {
      printf("%d ",B[i]);
    }
  printf("%d\n",B[i]);
  return 0;
}

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

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner();
		int[] array = new int[2];
		for(int i= 0; i < 2; i++)
			array[i] = sc.nextInt();
		int c = sc.nextInt();

		for(int i = 0; i < c; i++) {
			int num = i % 2;
			if(array[num] % 2 != 0)
				array[num]--;
			array[num] /=2;
			array[(num+1) % 2] += array[num];
		}
		System.out.println(array[0] + " " + array[1]);
	}
}

class Scanner {
	private BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	private static final int SPACE = (int)' ';
	private static final int LINE_END_0 = 13;
	private static final int LINE_END_1 = 10;
	private static final int BEFORE = -1;
	
	public boolean ready() {
		try {
			return br.ready();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return false;
	}
	
	public String next(){
		StringBuilder sb = new StringBuilder();
		
		int length = BEFORE;
		readLoop: while(true) {
			try {
				int value = br.read();
				switch(value) {
				case LINE_END_1:
					if(length == BEFORE)
						break;
					
					if((int)sb.charAt(length) == LINE_END_0)
						sb.deleteCharAt(length);
				case SPACE:
					break readLoop;
				}
				sb.append((char)value);
				length++;

			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
		return sb.toString();
	}
	
	public int nextInt() {
		return Integer.parseInt(next());
	}
	
	public double nextDouble() {
		return Double.parseDouble(next());
	}
	
	public long nextLong() {
		return Long.parseLong(next());
	}
}


Measured memory_bytes: 23124
/*      ░░█ ▄▀█ █   █▀ █░█ █▀█ █▀▀ █▀▀   █▀█ ▄▀█ █▀▄▀█
        █▄█ █▀█ █   ▄█ █▀█ █▀▄ ██▄ ██▄   █▀▄ █▀█ █░▀░█     */

// Author : Udit "luctivud" Gupta @ (https://www.linkedin.com/in/udit-gupta-1b7863135/)


#include <bits/stdc++.h>
#pragma GCC optimize "trapv"

using namespace std;

typedef long long int lld;
typedef unsigned long long int llu;


#define       TESTCASES()  cin >> (T3X0); T353 = T3X0; while(T3X0--)
#define       _input(V3C)  for(auto &V3C_I7 : (V3C)) cin >> (V3C_I7)
#define mems(A77AY, V4LU)  memset((A77AY), (V4LU), sizeof((A77AY)))
#define  CH3K(I7, E4, S7)  (((S7)<0) ? (I7)>(E4) : (I7)<(E4))
#define for4(I7,S4,E4,S7)  for(auto I7=(S4); CH3K(I7,E4,S7); (I7)+=(S7))




void solveEachTest(lld T35TC453N = 1) {

	lld a = 2, b = 1;
	lld n; cin >> n;
	for4 (i, 0ll, n, 1ll)  {
		lld temp = b;
		b = a + b;
		a = temp;
		// cout << a << " ";
	}

	cout << a;
	return;
}


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

	lld T3X0 = 0, T353 = 1;

	// TESTCASES()
	solveEachTest(T353 - T3X0);
	return 0;
}
// Random Thought :  null

Measured memory_bytes: 3648
#include <iostream>
#include <string> 
#include <vector> 
#include <algorithm> 
#include <utility> 
#include <tuple> 
#include <cstdint> 
#include <cstdio> 
#include <map> 
#include <queue> 
#include <set> 
#include <stack> 
#include <deque> 
#include <unordered_map> 
#include <unordered_set> 
#include <bitset> 
#include <cctype> 
#include<math.h>
using namespace std;
//#define int long long
#define m_p make_pair
#define mod 1000000007
#define rep(i,n)  for(int i=0; i<(int) (n); i++)
#define all(v)  v.begin(),v.end()
#define vecin(v) for(int i=0; i<(int)v.size(); i++)cin>>vec[i];
using namespace std;

int jousu(int, int);
int jousu(int x00, int y00) {
	int z00 = 1;
	for (int i = 0; i < y00; i++) {
		z00 *= x00;
	}
	return z00;
}
int kurai(int x00, int y00) {
	int z00 = (x00 % jousu(10, y00)) / jousu(10, y00 - 1);
	return z00;
}
int keta(int x00) {
	int z00 = x00;
	int w00 = 0;
	while (z00 != 0) {
		z00 /= 10;
		w00++;
	}
	return w00;
}




int main() {
	int n;
	cin >> n;
	if (n < 10) {
		cout << n << endl;
		return 0;
	}
	if (n < 100) {
		cout << 9 << endl;
		return 0;
	}
	if (n < 1000) {
		cout << n - 90 << endl;
		return 0;
	}
	if (n < 10000) {
		cout << 909 << endl;
		return 0;
	}
	if (n < 100000) {
		cout << n - 9090 << endl;
		return 0;
	}
	if (n == 100000) {
		cout << 90909 << endl;
	}
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<vector>
#include<list>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<cctype>
#include<climits>
#include<bitset>
#include<bits/stdc++.h>
#define ld long double
#define ll long long int
#define ull unsigned long long intS
#define rep(i,n) for(int i=0;i<n;i++)
#define fin(ans) cout<<(ans)<<endl
#define INF INT_MAX
#define vi vector<int>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pair<int,int> >
#define vvi vector<vector<int> >
#define vvc vector<vector<char> >
#define vvs vector<vector<string> >
#define P 1000000007
using namespace std;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const long long LLINF=1LL<<60;
//set<int>::iterator it;


int main(void){ios::sync_with_stdio(false);cin.tie(0);
//////////////////////////////////////////////////////
    
    int x,y;
    
    cin >> x >> y;
    
    cout << x +y/2 << endl;
    
    
    
    
//////////////////////////////////////////////////////
return 0;}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
	
	int k, s;
	cin >> k;
	cin >> s;
	
	int result = 0;
	
	for(int i = 0; i <= k; i++){
		for(int j = 0; j <= k; j++){
			int tmp = s - i - j;
			if(tmp >= 0 && tmp <= k){
				result++;
			}
		}		
	}
	cout << result << endl;
}

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

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

ll gcd(ll a, ll b) {
  if(b == 0) return a;
  return gcd(b, a % 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; }

ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

ll d[300][300] = {0};
bool useless[300][300] = {false};

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

  int N;
  cin >> N;
  for(int i = 0; i < N; i++){
    for(int j = 0; j < N; j++){
      cin >> d[i][j];
    }
  }

  bool is_ok = true;

  for(int i = 0; i < N-1; i++){
    for(int j = i+1; j < N; j++){
      for(int k = 0; k < N; k++){

        // cout << i << j << k << endl;;
        if(k == i) continue;
        if(k == j) continue;
        
        if(d[i][j] > d[i][k] + d[j][k]){
          is_ok = false;
          break;
        }
      }
    }
  }


  for(int i = 0; i < N-1; i++){
    for(int j = i+1; j < N; j++){
      for(int k = 0; k < N; k++){

        // cout << i << j << k << endl;;
        if(k == i) continue;
        if(k == j) continue;
        
        if(d[i][j] == d[i][k] + d[j][k]){
          useless[i][j] = true;
        }
      }
    }
  }

  
  if(is_ok){
    ll ans = 0;
    for(int i = 0; i < N-1; i++){
      for(int j = i+1; j < N; j++){
        if(!useless[i][j]){
          ans += d[i][j];
        }
      }
    }
    cout << ans << endl;    
  }else{
    cout << - 1 << endl;
  }

  return 0;
}


Measured memory_bytes: 1152
#include<iostream>
using namespace std;
#define mod 1000000007

int n,m;
long long int kazyo(int a){
  long long int ans=1;
  int i=a;
  do{
    ans=((ans)*(i))%mod;i--;
  }while(i>1);
  return ans;
}
int main(void){
  cin>>n>>m;
  if(n-m>1 || m-n>1)cout<<0<<endl;
  else if(n==m)
    cout<<(2*(kazyo(n)%mod)*(kazyo(m)%mod))%mod<<endl;
  else if(n-m==1 || m-n==1)
    cout<<((kazyo(n)%mod)*(kazyo(m)%mod))%mod<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

int main(void) {
	char s[128], p[128], *i;
	char ss[256];
	if (fgets(s, sizeof(s), stdin) == NULL) return 1;
	if (fgets(p, sizeof(p), stdin) == NULL) return 1;
	if ((i = strchr(s, '\n')) != NULL) *i = '\0';
	if ((i = strchr(p, '\n')) != NULL) *i = '\0';
	strcpy(ss, s);
	strcat(ss, s);
	puts(strstr(ss, p) != NULL ? "Yes" : "No");
	return 0;
}




Measured memory_bytes: 2112
import java.math.BigDecimal;
        import java.util.*;
 
public class Main {
 
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int a = sc.nextInt();
        int[] x = new int[50];
        for (int i = 0; i < n; i++) {
            x[i] = sc.nextInt();
        }
        
        long[][][] dp = new long[51][51][3010];
        
        dp[0][0][0] = 1;
 
        for (int i = 0; i < n; i++) {
            for (int k = 0; k < n; k++) {
                for (int j = 0; j <= 2500; j++) {
                    dp[i + 1][k][j] += dp[i][k][j];
                    dp[i + 1][k + 1][j+x[i]] += dp[i][k][j];
                }
            }
 
        }
 
        long ans = 0;
        for (int k = 1; k <= n; k++) {
            ans += dp[n][k][k * a];
        }
        System.out.println(ans);
 
    }
 
}

Measured memory_bytes: 130584
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        
        Scanner sc = new Scanner(System.in);
        int r = sc.nextInt();
        double ans = 0;

        ans = Math.pow(r, 2) * 3;

        System.out.println((int)ans);

        sc.close();
    }    
}


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

typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vector<bool>> vvb;
typedef vector<vector<int>> vvi;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)

int main() {
	int n, a, b;
	cin >> n >> a >> b;
	cout << min(n * a, b) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#pragma GCC optimize("O2")
#pragma GCC optimize("unroll-loops")
 
using namespace std;
#define ll long long
#define ull unsigned long long
#define rep(i,n,N) for(int i=n;i<=N;++i)
#define asd(i,n,N) for(int i=n;i< N;++i)
#define rap(i,n,N) for(int i=n;i>=N;--i)
#define mp make_pair
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define fi first
#define se second
#define ff fi.fi
#define fs fi.se
#define sf se.fi
#define ss se.se
#define lc (id<<1)
#define rc ((id<<1)|1)
#define db(x) cout << ">>>> " << #x << " -> " << x << endl
#define mems(x,y) memset(x,y,sizeof x)
#define all(x) x.begin(),x.end()
#define pii pair<int,int> 
#define pll pair<ll,ll>
#define plll pair<pll,ll>
#define piii pair<int,pii>
#define piiii pair<pii,pii>
#define psi pair<string,int>
#define endl '\n'
const int MAX = 3e3+5;
const ll MAX2 = 11;
const ll MOD = 1000000007;
const ll MOD2 = 1000005329;
const ll INF = 2e18;
const int dr[]={1,0,-1,0,1,1,-1,-1,0};
const int dc[]={0,1,0,-1,1,-1,1,-1,0};
const double pi = acos(-1);
const double EPS = 1e-9;
const int block = 555;

ll n,m,k,x[MAX][MAX],a,b,c,dp[MAX][MAX][4];

ll f(int r,int c,int cnt){
	if(r>n||c>m)return -INF;
	if(r==n&&c==m)return (cnt==3?0:x[r][c]);
	ll &ret = dp[r][c][cnt];
	if(ret!=-1)return ret;
	if(cnt!=3)ret = max(max(f(r+1,c,0),f(r,c+1,cnt)),max(f(r+1,c,0),f(r,c+1,cnt+1))+x[r][c]);
	else ret = max(f(r+1,c,0),f(r,c+1,cnt));
	return ret;
}

int main(){
//	cout<<fixed<<setprecision(2);
//    freopen("input.txt", "r", stdin);
//	freopen("output.txt","w",stdout);
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin>>n>>m>>k;
    rep(i,1,k){
    	cin>>a>>b>>c;
    	x[a][b] = c;
	}
//	rep(i,1,n){
//		rep(j,1,m)cout<<x[i][j]<<' '; cout<<endl;
//	}
	mems(dp,-1);
	cout<<f(1,1,0)<<endl;
    return 0;
}

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

const int _ = 1 << 19 | 1 , MOD = 924844033 , G = 5;
struct Edge{int end , upEd;}Ed[_ << 1];
int arr[_] , tp[_] , N , head[_] , cntEd , jc[_] , inv[_];
void addEd(int a , int b){Ed[++cntEd] = (Edge){b , head[a]}; head[a] = cntEd;}
int upd(int x){return x + (x >> 31 & MOD);}

int poww(long long a , int b){
	int times = 1;
	while(b){
		if(b & 1) times = times * a % MOD;
		a = a * a % MOD; b >>= 1;
	}
	return times;
}

int dfs(int x , int p){
	int sz = 1;
	for(int i = head[x] ; i ; i = Ed[i].upEd)
		if(Ed[i].end != p){int t = dfs(Ed[i].end , x); ++arr[t]; ++arr[N - t]; sz += t;}
	return sz;
}

int dir[_] , need , invnd;
void init(int len){
	need = 1; while(need < len) need <<= 1;
	invnd = poww(need , MOD - 2);
	for(int i = 1 ; i < need ; ++i)
		dir[i] = (dir[i >> 1] >> 1) | (i & 1 ? need >> 1 : 0);
}

void DFT(int *arr){
	for(int i = 1 ; i < need ; ++i)
		if(i < dir[i]) swap(arr[i] , arr[dir[i]]);
	for(int i = 1 ; i < need ; i <<= 1){
		int wn = poww(G , MOD / i / 2);
		for(int j = 0 ; j < need ; j += i << 1){
			long long w = 1;
			for(int k = 0 ; k < i ; ++k , w = w * wn % MOD){
				int x = arr[j + k] , y = arr[i + j + k] * w % MOD;
				arr[j + k] = upd(x + y - MOD); arr[i + j + k] = upd(x - y);
			}
		}
	}
}

void IDFT(int *arr){
	reverse(arr + 1 , arr + need); DFT(arr);
	for(int i = 0 ; i < need ; ++i) arr[i] = 1ll * arr[i] * invnd % MOD;
}

int binom(int a , int b){return 1ll * jc[a] * inv[b] % MOD * inv[a - b] % MOD;}

int main(){
	ios::sync_with_stdio(0); cin >> N;
	for(int i = 1 , x , y ; i < N ; ++i){cin >> x >> y; addEd(x , y); addEd(y , x);}
	dfs(1 , 0); jc[0] = 1;
	for(int i = 1 ; i <= N ; ++i) jc[i] = 1ll * jc[i - 1] * i % MOD;
	for(int i = 1 ; i <= N ; ++i) arr[i] = 1ll * arr[i] * jc[i] % MOD;
	inv[N] = poww(jc[N] , MOD - 2);
	for(int i = N - 1 ; i >= 0 ; --i) inv[i] = inv[i + 1] * (i + 1ll) % MOD;
	memcpy(tp , inv , sizeof(int) * (N + 1)); reverse(tp , tp + N + 1);
	init(2 * N + 1); DFT(arr); DFT(tp);
	for(int i = 0 ; i < need ; ++i) arr[i] = 1ll * arr[i] * tp[i] % MOD;
	IDFT(arr);
	for(int i = 1 ; i <= N ; ++i)
		cout << (1ll * N * binom(N , i) % MOD - 1ll * arr[N + i] * inv[i] % MOD + MOD) % MOD << endl;
	return 0;
}

Measured memory_bytes: 26496
import math
from functools import reduce

ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

k=ni()

ans = 0
for a in range(1,k+1):
  for b in range(1,k+1):
    for c in range(1,k+1):
      arr = [a,b,c]
      r = reduce(math.gcd, arr)
      ans+=r

print(ans)

Measured memory_bytes: 69680
/*input
6
30 10 60 10 60 50

*/
/**
 * A Frog-1
 * @author: Raj
 */
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstring>
#define endl '\n'
#define lli long long int
#define vi vector<int>
#define vlli vector<lli>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define mod 1000000007
#define MOD 1000000007
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define eb(n) emplace_back(n)
#define pb(n) push_back(n)
#define F first
#define S second
#define int long long int
#define double long double
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> new_data_set;
void note_to_myself(){
	//new_data_set s;
	//logn operations
	//cout << *(s.find_by_order(i)) << " ";
	//cout << "The index of number 6::" << p.order_of_key(6) << endl; 
}
int add(int x, int y) {
	x += y;
	if (x >= MOD) return x - MOD;
	return x;
}
int sub(int x, int y) {
	x -= y;
	if (x < 0) return x + MOD;
	return x;
}
int mul(int x, int y) {
	return ((long long)x * y) % MOD;
}
inline int power(int a, int b) {
  int res = 1;
  while (b > 0) {
    if (b & 1) {
      res = mul(res, a);
    }
    a = mul(a, a);
    b >>= 1;
  }
  return res;
}
inline int inv(int a) {
	a %= MOD;
	if (a < 0) a += MOD;
	int b = MOD, u = 0, v = 1;
	while (a) {
		int t = b / a;
		b -= t * a; swap(a, b);
		u -= t * v; swap(u, v);
	}
	assert(b == 1);
	if (u < 0) u += MOD;
	return u;
}
const int INF = 1e9+5;
int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin >> n;
	vi h(n);
	for (int i = 0; i < n; ++i){
		cin >> h[i];
	}
	vi dp(n,INF);
	dp[0] = 0;
	for (int i = 0; i < n; ++i){
		for(int j : {i+1,i+2}){
			if (j < n){
				dp[j] = min(dp[j],dp[i] + abs(h[i] - h[j]));
			}
		}
	}
	cout << dp[n-1] << endl; 
	return 0;
}

Measured memory_bytes: 1792
//khodaya khodet komak kon
#include <bits/stdc++.h>

#define F first
#define S second
#define pb push_back
#define all(x) x.begin(), x.end()
#pragma GCC optimise ("ofast")
#pragma GCC optimise("unroll-loops")

using namespace std;

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

const int N = 200000 + 10;
const ll MOD = 1000000000 + 7;
const ll INF = 1000000000000000000;
const ll LOG = 25;

int n, h[N], res[N], Mx = 0, H = 0;
vi G[N];
vector<int> col[2];

void DFS(int v = 1, int p = 1){
	col[h[v] % 2].pb(v);
	for (auto u:G[v]){
		if (u == p) continue;
		h[u] = h[v] + 1;
		DFS(u, v);
	}
}

void DFS2(int v = 1, int p = 1, int hh = 0){
	if (hh >= H) Mx = v, H = hh;
	for (auto u:G[v]){
		if (u == p) continue;
		DFS2(u, v, hh + 1);
	}
}

int32_t main(){
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n;
	for (int i = 0; i < n - 1; i++){
		int v, u;
		cin >> v >> u;
		G[v].pb(u);
		G[u].pb(v);
	}
	DFS();
	
	if (n <= 3){
		for (int i = 1; i <= n; i++){
			cout << i << ' ';
		}
		return 0;
	}
	int cnt0 = 3;
	if (col[0].size() < col[1].size()) swap(col[0], col[1]);
	int cnt2 = 2, cnt = 1;
	if (col[1].size() <= n / 3){
		for (auto u:col[1]){
			res[u] = cnt0;
			cnt0 += 3;
		}
	}
	else{
		for (auto u:col[1]){
			if (cnt2 <= n){
				res[u] = cnt2;
				cnt2 += 3;
			}else{
				res[u] = cnt0;
				cnt0 += 3;
			}
		}
	}
	for (int i = 1; i <= n; i++){
		if (res[i] == 0){
			if (cnt <= n){
				res[i] = cnt;
				cnt += 3;
			}else if(cnt2 <= n){
				res[i] = cnt2;
				cnt2 += 3;
			}else{
				res[i] = cnt0;
				cnt0 += 3;
			}
		}
	}
	for (int i = 1; i <= n; i++) cout << res[i] << ' ';









	return 0;
}


Measured memory_bytes: 20084
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <cmath>
#include <numeric>

using namespace std;

int main()
{
    int n, m;
    cin >> n >> m;
    int a[n][m], b[m];
    int sum = 0;

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            cin >> a[i][j];
        }
    }
    for (int i = 0; i < m; i++) {
        cin >> b[i];
    }

    for (int i = 0; i < n; i++) {
        sum = 0;
        for (int j = 0; j < m; j++) {
            sum += a[i][j] * b[j];
        }
        cout << sum << endl;
    }

}




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

int main() {
	int a,b,c;
	char s,x;
	cin>>a>>s>>b>>x>>c;
	if(a<=2019&&b<=4&&c<=30)
	cout<<"Heisei";
	else 
	cout<<"TBD";
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<math.h>
#include<queue>
#include<deque>
#include<map>

#define rep(i, n) for(int i = 0;i < (n);i++)
#define rrep(i, n) for(int i = (n);i >= 0;i--)
#define FOR(i, m, n) for(int i = (m);i < (n);i++)

using namespace std;
using ll = long long;

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

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


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

struct Edge {
    int to;
    ll cost;
};

int main() {
    int n; cin >> n;
    vector<vector<Edge>> g(n);
    for (int i = 0; i < n-1; i++)
    {
        int a, b; cin >> a >> b;
        a--; b--;
        ll c; cin >> c;

        g[a].push_back(Edge{b, c});
        g[b].push_back(Edge{a, c});
    }

    // int q, k; cin >> q >> k;
    // k--;
    // vector<pair<int, int>> xy(n);
    // for (int i = 0; i < q; i++)
    // {
    //     int x, y;
    //     cin >> x >> y;
    //     x--; y--;
    //     xy[i] = make_pair(x, y);
    // }


    vector<ll> dp(n);
    vector<bool> visited(n, false);
    
    auto dfs = [&](auto &&dfs, int now, ll len) -> void {
        if (visited[now]) return;
        visited[now] = true;
        dp[now] = len;

        for (int i = 0; i < g[now].size(); i++)
        {
            int next = g[now][i].to;
            ll c = g[now][i].cost;
            dfs(dfs, next, dp[now]+c);
        }
        
    };

    int q, k; cin >> q >> k;
    k--;
    dfs(dfs, k, 0);
    vector<pair<int, int>> xy(n);
    for (int i = 0; i < q; i++)
    {
        int x, y;
        cin >> x >> y;
        x--; y--;
        cout << dp[x] + dp[y] << endl;
    }

    // for (int i = 0; i < q; i++)
    // {
    //     cout << dp[xy[i].first] + dp[xy[i].second] << endl;
    // }
    
    return 0;
}


Measured memory_bytes: 13184
#include <cstdio>
#include <string>
#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;

int dp[80010][13];
int main() {
    string s;
    while(cin >> s) {
        if(s == "0") break;
        memset(dp, 0, sizeof(dp));
        int N = s.length();
        for(size_t i=0; i<N; i++) {
            int num = s[i] - '0';
            if(num) dp[i+1][num]++;
            for(int k=0; k<11; k++) {
                int mo = ((k * 10) + num) % 11;
                dp[i+1][mo] += dp[i][k];
            }
        }
        int ans = 0;
        for(int i=1; i<=N; i++) {
            ans += dp[i][0];
        }
        cout << ans << endl;
    }    
    return 0;
}


Measured memory_bytes: 7408
#include <bits/stdc++.h>
#define INF 5000000000000000000
#define ll long long
#define pll pair<ll, ll>
using namespace std;

int main()
{
  ll a, b, c, d;
  cin >> a >> b >> c >> d;
  while (a > 0 && c > 0) {
    a -= d;
    c -= b;
  }
  // cout << a << c << endl;
  if (c <= 0) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 3636
// Problem : E - Knapsack 2
// Contest : AtCoder - Educational DP Contest
// URL : https://atcoder.jp/contests/dp/tasks/dp_e
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

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

//Macros

#define ll long long
#define db long double
#define pb push_back
#define eb emplace_back
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define mi map<int,int>
#define mii map<pii,int>
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()
#define sz(x) (int)x.size()
#define mod 1000000007
#define EPS 1e-9
#define io ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define inf 1e18
#define PI acos(-1.0)
#define int long long
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define N 102
#define MX 100005

//Solution

int n,W,V;
int w[N],v[N];
int dp[N][MX];

void solve(){
    cin>>n>>W;
    int V = 100000;
    for(int i=1;i<=n;i++) cin>>w[i]>>v[i];
    for(int i=0;i<=n;i++){
        for(int j=0;j<=V;j++) dp[i][j] = inf;
    }
    dp[0][0] = 0;
    for(int i=1;i<=n;i++){
        for(int j=0;j<=V;j++){
            dp[i][j] = dp[i-1][j];
            if(j >= v[i]) dp[i][j] = min(dp[i][j],dp[i-1][j-v[i]]+w[i]);
        }
    }
    for(int i=V;i>=0;i--){
        if(dp[n][i] <= W){
            cout<<i;
            return;
        }
    }
}

signed main(){
    io;
    //freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
    int tests;
    //cin>>tests;
    tests = 1;
    while(tests--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 82536
import math
while True:
  t = []
  a = int(input())
  if a == 0:
    break
  else:
    x = list(map(int,input().split()))
    m = sum(x)/len(x)
    for i in range(len(x)):
      d = 0
      d = m-x[i]
      d = d**2
      t.append(d)
    print(math.sqrt(sum(t)/len(t)))


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

a = [0] * (n+1)
for i in range(1, n+1):
    d = 2
    while d <= i:
        #print(str(d)+"を"+str(i)+"で割る")
        if i%d == 0:
            #print("割れた")
            a[d] += 1
            i /= d
            d = 2
        else:
            #print("割れない")
            d += 1

ans = 1
for i in range(n+1):
    ans *= (a[i]+1)
print(ans%(10**9+7))

Measured memory_bytes: 3060
import math
d=input().split()
N,K=int(d[0]),int(d[1])
a=math.factorial(K-1)
b=math.factorial(N-K+1)
if N-K+2<=K:
  for i in range(1,N-K+2):
    t=b//(math.factorial(i)*math.factorial(N-K-i+1))
    s=(a//(math.factorial(i-1)*math.factorial(K-i)))*t%(10**9+7)
    print(s)
  for i in range(N-K+2,K+1):
    print(0)
else:
    for i in range(1,K+1):
       t=b//(math.factorial(i)*math.factorial(N-K-i+1))
       s=(a//(math.factorial(i-1)*math.factorial(K-i)))*t%(10**9+7)
       print(s)
  

Measured memory_bytes: 66520
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <queue>
# define MOD 1000000000+7
# define INF 1000000000
#define rep(i,rept)	for(ll i = 0; i<rept;i++)
typedef long long ll;
using namespace std;
unsigned long long int a = 0, b = 0, c = 0, d = 0, e = 0, ans = 0, x = 0, y = 0, z = 0, N = 0, m = 0, maxy = 0, mini = 9999, counter = 0, endp = 0, checker = 0;

std::vector <char> vec{}, vecsec{}, vecth{};
long long int iremono[100010], koware[100001];
long long  int iremono2[100001], check[100001], xpo[10000001], ypo[10000001], hei[1000001];
std::vector<std::string>kinds{}, kaku{};
char maze[1000];
int sx, sy;
int gx, gy;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
bool okada = false, okada2 = false;
long long int dp[4][100003] ,ire[4][100003];
std::string input[103],one,two,three;
char re;

int H, W;//はんい
bool qw = false, er = false, ty = false, ui = false;
std::string code;
int main() {
	rep(i, 4) {
		cin >> re;
		vec.push_back(re);
	}
	std::sort(vec.begin(),vec.end());
	if (vec[0] == vec[1] && vec[2] == vec[3] && vec[1] != vec[2]) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}



Measured memory_bytes: 2304
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <limits.h>
using namespace std;

int main(){
  int K, X, check = 0;
  cin >> K >> X ;
  for(int i=(X-K+1);i<(X+K);i++){
    cout << i << " ";
  }  
  cout << endl ;
  return 0 ;
}

Measured memory_bytes: 256
import math
N=int(input())
A = []
B = []
for _ in range(N):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)
cnt = 0
for i in range(N-1):
    for j in range(i+1,N,1):
        cnt +=math.sqrt((A[i]-A[j])**2+(B[i]-B[j])**2)
print(cnt*2/N)

Measured memory_bytes: 3064
/*  Bichrome Cells
    Y_Aizaki    */

#include <stdio.h>

int main(void){
    int row, white_square;

    scanf("%d", &row); //列の数
    scanf("%d", &white_square); //白マスの数
    printf("%d\n", (row * row) - white_square);
    return 0;
}

Measured memory_bytes: 128
#include<bitset>
#include<math.h>
#include<limits.h>
#include<iostream>
#include<string>
#include<vector>
#include<cstdio>
#include<sstream>
#include<list>
#include<queue>
#include<algorithm>
#include<functional>
#include<map>
#include<set>
#include<utility>
#include<initializer_list>
#include<tuple>
#include<regex>
using namespace std;
#define ull unsigned long long
#define ll long long
#define rep(i, a, n) for(int i=(a);i<(int)(n);i++)
#define repc(i, a, n) for(int i=(a);i<=(int)(n);i++)
#define all(t) t.begin(), t.end()
#define rall(t) t.rbegin(), t.rend()
#define mat(type, row, col, init) vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout<<(cond? "Yes":"No")<<endl;
#define YES(cond) cout<<(cond? "YES":"NO")<<endl;
#define DBG(str) cerr<<(str)<<endl;

void showmat(vector<vector<int>>&a) {
	rep(i, 0, a.size()) {
		rep(j, 0, a[i].size()) {
			cerr << a[i][j] << " ";
		}
		cerr << endl;
	}
	cerr << endl;
}

int main() {
	ll n;
	cin >> n;
	vector<ll>p(n, 0);
	rep(i, 0, n)cin >> p[i];
	vector<ll>q(n, 0);
	rep(i,0,n) q[p[i]-1] = i;
	ll ma = 0;
	ll seq = 1;
	rep(i, 0, n-1) {
		if (q[i + 1] > q[i])seq++;
		else {
			ma = max(ma, seq);
			seq = 1;
		}

	}
	ma = max(ma, seq);
	cout << n - ma;
	//auto d = mat(int, 2, n + 1, INT32_MAX);
	//int length = 0;
	//vector<set<int>>a(2);
	//rep(i, 0, n) {
	//	d[1][i + 1] = min(d[1][i], p[i]);
	//}
	//rep(j, 1, n+1) {

	//	a[j % 2].clear();

	//	rep(i, 1, n+1) {
	//		cerr << "j:" << j << ", i:" << i << endl;
	//		showmat(d);
	//		auto pam = [&]()->int {
	//			if (a[(j - 1) % 2].count(p[i] - 1)) {
	//				d[j % 2][i] = p[i-1];
	//			}
	//			return min(d[j % 2][i], d[j % 2][i - 1]);
	//		};
	//		d[j % 2][i] = pam();
	//		int now = d[j % 2][i];
	//		if (d[j % 2][i] != INT32_MAX) {
	//			length = j;
	//			a[j % 2].insert(d[j % 2][i]);
	//		}

	//	}


	//}
	//cout << n - length;

	return 0;
}





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

using namespace std;
typedef long long ll;

int main(void) {
  ll k;
  cin >> k;

  ll n = 50;
  vector<ll> a(n);
  for (int i = 0; i < n; i++) {
    a[i] = 51 * (k / 50) - k + 49;
  }

  int r = k % 50;
  for (int i = 0; i < r; i++) {
    a[i] += 51;
  }

  cout << n << endl;
  for (int i = 0; i < n; i++) {
    if (i) cout << " ";
    cout << a[i];
  }
  cout << endl;

  return 0;
}

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

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
typedef vector<ll> VL; const int MD = (int)1e9 + 7;
void dbg(){ cerr << "\n"; } template <typename T,typename ...T2> void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }

int main()
{
	//cin.tie(0); ios_base::sync_with_stdio(false);
	//int n, ans =0;
	string s;
	cin >>s;
	
	rep(i,sz(s)) if(s[i]=='7'){
		puts("Yes"); return 0;
	}
	puts("No"); 
	return 0;
}


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

int main() {
	int N;
	cin >>N;
	int A[N];
	bool f = 1;
	for(int i=0 ; i<N ;i++){
		cin >>A[i];
	}
	int k=0;
	for(int i=0;f;i++){
		f = 0;
		for(int j = N-1; j>=i+1 ;j--){
			if(A[j]<A[j-1]){
				int t = A[j];
				A[j]=A[j-1];
				A[j-1]=t;
				k++;
				f=1;
			}
		}
	}
	cout <<A[0];

	for(int i=1;i<N;i++){
		cout <<" "<<A[i];
	}
	cout <<endl<<k<<endl;

}


Measured memory_bytes: 3096
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N=4005,M=1e9+7;
int fac[N*2],n,inv[N*2],dp[N][N],a[N*50],b[N*50];
int ksm(int x,int y){
	if (!y)return 1;
	int z=ksm(x,y/2);
	z*=z;z%=M;
	if (y&1)z*=x;
	return z%M;
}
int C(int x,int y){
	return fac[x]*inv[y]%M*inv[x-y]%M;
} 
signed main(){
	scanf("%lld",&n);
	for (int i=1;i<=n;i++)scanf("%lld%lld",&a[i],&b[i]);
	fac[0]=inv[0]=1;
	for (int i=1;i<=8000;i++)fac[i]=fac[i-1]*i%M,inv[i]=ksm(fac[i],M-2);
	for (int i=1;i<=n;i++)dp[-a[i]+2001][-b[i]+2001]++;
	for (int i=1;i<=4001;i++)
		for (int j=1;j<=4001;j++)
			(dp[i][j]+=dp[i-1][j]+dp[i][j-1])%=M;
	int ans=0;
	for (int i=1;i<=n;i++)(ans+=dp[a[i]+2001][b[i]+2001])%=M;
	for (int i=1;i<=n;i++)
		(ans+=M-C(a[i]+b[i]+a[i]+b[i],a[i]+a[i]))%=M;
	printf("%lld\n",ans*ksm(2,M-2)%M);
	return 0;
}

Measured memory_bytes: 128768
import math

def main():
    N = int(input())
    X = list(map(int, input().split()))
    min_tai = 1000000
    min_x = -1
    for x in range(min(X), max(X)+1):
        temp_tai = 0
        for temp_x in X:
            temp_tai += math.pow(x-temp_x, 2)
        if(temp_tai < min_tai):
            min_x = x
            min_tai = temp_tai
    print(int(min_tai))

if __name__ == "__main__":
    main()


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

const int N = 1e5 + 10;

long long n, x, m;
int bo[N];
long long b[N];
long long sum[N];
int top=0;
int main() {
    std::cin >> n >> x >> m;
    x = x % m;
    for (int i = 1; i <= m+1&&i<=n; ++i) {
        if (bo[x]>0) {        
            break;
        }
        b[++top]=x;
        sum[top]=sum[top-1]+x;
        bo[x] = i;
        x = x * x%m;
    }
    if(n>top){
        std::cout<<sum[top]+(n-top)/(top-bo[x]+1)*(sum[top]-sum[bo[x]-1])+sum[(n-top)%(top-bo[x]+1)+bo[x]-1]-sum[bo[x]-1];
    }else{
        std::cout<<sum[top]<<'\n';
    }
    return 0;
}

Measured memory_bytes: 4692