akhauriyash/Code-Regression huggingface dataset:
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7

n, m = MAP()
red = [False for _ in range(n)]
bal = [1 for _ in range(n)]
red[0] = 1
for i in range(m):
    x, y = MAP()
    if red[x - 1]:
        red[y - 1] = True
        if bal[x - 1] == 1:
            red[x - 1] = False
    bal[x - 1] -= 1
    bal[y - 1] += 1
print(sum(red))

Measured memory_bytes: 7092
namespace VainZero.Procon.FSharp

open System
open System.Collections.Generic

[<AutoOpen>]
module Operators =
  let read f = Console.ReadLine().Split([|' '|]) |> Array.map f

module Program =
  [<EntryPoint>]
  let main _ =
    let n = Console.ReadLine() |> int
    let scores =
      [|
        for _ in 0..(n - 1) ->
          Console.ReadLine() |> int
      |]
    let maxScore = scores |> Array.sum

    // dp.[i].[s]:
    // 最初の (i + 1) 個の配点を望む組み合わせで加算して、
    // 和をちょうど s にできるとき真。
    let dp =
      [|0..(n - 1)|] |> Array.map (fun _ -> Array.zeroCreate (maxScore + 1))
      
    for i in 0..(n - 1) do
      for s in 0..maxScore do
        let t = scores.[i]
        dp.[i].[s] <-
          if i = 0 then
            s = 0 || s = t
          else
            dp.[i - 1].[s] || (s >= t && dp.[i - 1].[s - t])

    let result =
      [|
        for s in 0..maxScore do
          if dp.[n - 1].[s] then
            yield if s % 10 = 0 then 0 else s
      |]
      |> Array.max

    printfn "%d" result

    0


Measured memory_bytes: 14172
#include<stdio.h>
int main()
{
	int N, M, X, Y;
	int x[100] = {}, y[100] = {};
	int xmax = -100;

	scanf("%d %d %d %d", &N, &M, &X, &Y);

	int i;
	for (i = 0; i < N; i++)
	{
		scanf("%d", &x[i]);
		if (x[i] > xmax)
			xmax = x[i];
	}
	if (X > xmax)
		xmax = X;

	if (Y <= xmax)
	{
		printf("War");
		return 0;
	}

	for (i = 0; i < M; i++)
	{
		scanf("%d", &y[i]);
		if (y[i] <= xmax)
		{
			printf("War");
			return 0;
		}
	}
	printf("No War");
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <numeric>
#include <iomanip>
#include <map>
#include <set>
#include <deque>
#include <utility>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repk(i, k, n) for (int i = k; i < n; i++)
#define all(vec) vec.begin(), vec.end()
#define MOD 1e9 + 7
#define INF 1e9
#define SENTINEL 2e9
#define PIE 3.1415a926535

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;}
template <class T>
inline T GCD(T a, T b){if (b == 0) return a; else return GCD(b, a % b);}
template <class T>
inline T LCM(T a, T b) {return (a * b) / GCD(a, b);}

#define itn int

int main() {
    int n, k;
    cin >> n >> k;
    int digit = 0;
    while (n > 0)
 {       digit++;
     n /= k;
 }
    cout << digit << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1000000007;
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

int main(){
    int n,k;
    cin>>n>>k;
    vector<int> a(n);
    rep(i,n) cin>>a[i];

    int ng=0,ok=1000000001;
    while(ok-ng>1){
        int mid=(ok+ng)/2;
        int cnt=0;
        rep(i,n){
            cnt+=a[i]/mid;
            if(a[i]%mid==0) cnt--;
        }

        if(cnt<=k) ok=mid;
        else ng=mid;
    }

    cout<<ok<<endl;
}

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

// macros
#define pb emplace_back
#define mk make_pair
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for(int i=((int)(n)-1);i>=0;i--)
#define irep(itr, st) for(auto itr = (st).begin(); itr != (st).end(); ++itr)
#define irrep(itr, st) for(auto itr = (st).rbegin(); itr != (st).rend(); ++itr)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define bit(n) (1LL<<(n))
// functions
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(a > b){a = b; return 1;} return 0;}
template <typename T> istream &operator>>(istream &is, vector<T> &vec){for(auto &v: vec)is >> v; return is;}
template <typename T> ostream &operator<<(ostream &os, const vector<T>& vec){for(int i = 0; i < vec.size(); i++){ os << vec[i]; if(i + 1 != vec.size())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const set<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const unordered_set<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const multiset<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const unordered_multiset<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p){os << p.first << " " << p.second; return os;}
template <typename T1, typename T2> ostream &operator<<(ostream &os, const map<T1, T2> &mp){for(auto itr = mp.begin(); itr != mp.end(); ++itr){ os << itr->first << ":" << itr->second; auto titr = itr; if(++titr != mp.end())os << " "; } return os;}
template <typename T1, typename T2> ostream &operator<<(ostream &os, const unordered_map<T1, T2> &mp){for(auto itr = mp.begin(); itr != mp.end(); ++itr){ os << itr->first << ":" << itr->second; auto titr = itr; if(++titr != mp.end())os << " "; } return os;}
//  types
using ll = long long int;
using P = pair<int, int>;
// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;
const int mod = 1000000007;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};
// io
struct fast_io{
  fast_io(){ios_base::sync_with_stdio(false); cin.tie(0); cout << fixed << setprecision(20);}
} fast_io_;


int main(int argc, char const* argv[])
{
  int n; cin >> n;
  string s; cin >> s;
  if(sz(s) & 1)cout << "No" << endl;
  else{
    if(s.substr(0, n/2) == s.substr(n/2, n/2))cout << "Yes" << endl;
    else cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iter = input.split_whitespace();

    let n: u8 = iter.next().unwrap().parse().unwrap();
    let m: u8 = iter.next().unwrap().parse().unwrap();

    if n == m {
        return String::from("Yes");
    } else {
        return String::from("No");
    }
}

#[test]
fn test() {
    assert_eq!(solve(r"3 3"), "Yes");
    assert_eq!(solve(r"3 2"), "No");
    assert_eq!(solve(r"1 1"), "Yes");
}


Measured memory_bytes: 4352
N=int(input())

A=list(map(int,input().split()))

minusCnt = 0
absMin = 10**10
# absMinIndex = -1

for i in range(len(A)):
	if abs(A[i]) < absMin:
		absMin = min( abs(A[i]), absMin )
		absMinIndex = i
	if A[i] < 0:
		minusCnt+=1

if minusCnt % 2 == 0:
	# even
	for i in range(len(A)):
		if A[i] < 0:
			A[i] *= -1
else:
	# odd
	for i in range(len(A)):
		if absMinIndex == i:
			if 0 < A[i]:
				A[i] *= -1
		if A[i] < 0 and i != absMinIndex:
			# print(i,A[i],absMinIndex)
			A[i] *= -1

ans = sum(A)

print(ans)




Measured memory_bytes: 14468
import java.util.*;
import java.io.*;

 public class Main{
// taking inputs
static BufferedReader s1;
static BufferedWriter out;
static String read() throws IOException{String line="";while(line.length()==0){line=s1.readLine();continue;}return line;}
static int int_v (String s1){return Integer.parseInt(s1);}
static long long_v(String s1){return Long.parseLong(s1);}
static int[] int_arr() throws IOException{String[] a=read().split(" ");int[] b=new int[a.length];for(int i=0;i<a.length;i++){b[i]=int_v(a[i]);}return b;}
static long[] long_arr() throws IOException{String[] a=read().split(" ");long[] b=new long[a.length];for(int i=0;i<a.length;i++){b[i]=long_v(a[i]);}return b;}
static void assign(){s1=new BufferedReader(new InputStreamReader(System.in));out=new BufferedWriter(new OutputStreamWriter(System.out));}

//......................................@uthor_Alx..............................................

   public static void main(String[] args) throws  IOException{
	        		  assign();
	        		  	int[] x=int_arr();
	        		  	int[] arr=int_arr();
	        		  	Arrays.sort(arr);
	        		  	int res=0;
	        		  	for(int i=1;i<=x[1];i++){
	        		  		res+=arr[i-1];
	        		  	}
	        		  	
	        		  	out.write(res+"");
                      out.flush();
	        		 
	}
}
	       

Measured memory_bytes: 36716
#include <iostream>
#include <complex>
#include <utility>
using namespace std;

typedef complex<double> Point, Vector;
typedef pair<Point, Point> Segment, Line;

#define X real()
#define Y imag()

#define EPS (1e-10)
#define equals(a, b) (fabs((a) - (b)) < EPS)

static const int COUNTER_CLOCKWISE = 1;
static const int CLOCKWISE = -1;
static const int ONLINE_BACK = 2;
static const int ONLINE_FRONT = -2;
static const int ON_SEGMENT = 0;

double dot(Vector a, Vector b){
    return a.X * b.X + a.Y * b.Y;
}

double cross(Vector a, Vector b){
    return a.X * b.Y - a.Y * b.X;
}

int ccw(Point p0, Point p1, Point p2){
    Vector a = p1 - p0;
    Vector b = p2 - p0;
    if(cross(a, b) > EPS) return COUNTER_CLOCKWISE;
    if(cross(a, b) < -EPS) return CLOCKWISE;
    if(dot(a, b) < -EPS) return ONLINE_BACK;
    if(norm(a) < norm(b)) return ONLINE_FRONT;

    return ON_SEGMENT;
}

bool intersect(Point p1, Point p2, Point p3, Point p4){
    return (ccw(p1, p2, p3) * ccw(p1, p2, p4) <= 0 && ccw(p3, p4, p1) * ccw(p3, p4, p2) <= 0);
}

bool intersect(Segment s1, Segment s2){
    return intersect(s1.first, s1.second, s2.first, s2.second);
}

int main(){
    int q; cin>>q;
    while(q--){
        double x0, y0, x1, y1, x2, y2, x3, y3;
        cin>>x0>>y0>>x1>>y1>>x2>>y2>>x3>>y3;
        Segment s1 = {Point(x0, y0), Point(x1, y1)};
        Segment s2 = {Point(x2, y2), Point(x3, y3)};

        cout << intersect(s1, s2) << endl;
    }
}


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

using namespace std;

int main() {
	static long long int n , a[100010], b[100010];
	cin >> n;
	cin >> a[0] >> a[1];
	b[0] = 0;
	b[1] = abs (a[0] - a[1]);
	for (int i = 2; i < n; i++){
		cin >> a[i];
		b[i] = min (b[i - 1] + abs(a[i] - a[i - 1]) , b[i - 2] + abs(a[i] - a[i - 2]));
	}
	cout << b[n - 1];
}


Measured memory_bytes: 1792
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<string>
#include<map>
#include<set>
#define INF 100000001
using namespace std;
typedef long long ll;
int a[4];
int ans = 3000;
void cost(int x, int y, int z) {
	int w = abs(a[y] - a[x]) + abs(a[z] - a[y]);
	if (w < ans) {
		ans = w;
	}
	
}
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	for (int i = 0; i < 3; i++) {
		cin >> a[i];
	}
	cost(0, 1, 2);
	cost(0, 2, 1);
	cost(1, 0, 2);
	cost(1, 2, 0);
	cost(2, 1, 0);
	cost(2, 0, 1);
	cout << ans<<endl;
	return 0;
}

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

main() {
    int N; cin >> N;
    map<int, int>m;
    rep(i,N){
        int a; cin >> a;
        m[a]++;
    }
    cout << m.size() << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;
//const ll MOD = ;
ll mod(ll A, ll M) {return (A % M + M) % M;}
const ll INF = 1LL << 60;
template<class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
ll divceil(ll A, ll B) {return (A + (B - 1)) / B;}
ll myctoi(char C) {return C - '0';}
char myitoc(ll N) {return '0' + N;}
#define FINALANS(A) do {cout << (A) << '\n'; exit(0);} while (false)

int main()
{
  ll N, M;
  cin >> N >> M;
  vector<ll> S(M), C(M);
  for (ll i = 0; i < M; i++)
  {
    cin >> S.at(i) >> C.at(i);
    S.at(i)--;
  }

  for (ll n = 0; n < 1000; n++)
  {
    string x = to_string(n);
    if (x.size() != N)
      continue;

    bool ok = true;
    for (ll i = 0; i < M; i++)
    {
      if (x.at(S.at(i)) - '0' != C.at(i))
      {
        ok = false;
        break;
      }
    }
    if (ok)
      FINALANS(n);
  }
  cout << -1 << endl;
}

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

using namespace std;

int main(int argc, char const* argv[])
{
	double a,b,c,d,e,f,x,y;

	while(cin >> a >> b >> c >> d >> e >> f){
		double det = 1/(a * e - b * d);

		x = ( c * e - b * f ) * det;
		y = ( a * f - c * d ) * det;


		x *= 1000;
		y *= 1000;
		x = int( x+.5-(x<0) );
		y = int( y+.5-(y<0) );
		y /= 1000;
		x /= 1000;
		printf("%.3f %.3f\n",x,y);
	}
	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define pb push_back
#define N 200001
#define ll long long
#define int ll 
#define pi pair<int , int>
#define pip pair<pair ,int>
#define mp make_pair 
#define f first
#define s second
#define mod 998244353
ll Mod(ll x, ll y, int p) 
{ll res = 1; x = x % p;
while (y > 0) 
{if(y & 1) res = (res*x) % p; 
y = y>>1;x = (x*x) % p; 
}return res; 
}
int* getlps(string pattern){
 int len = pattern.length();
 int * lps = new int[len];
 lps[0] = 0;
 int i = 1 , j = 0;
 while(i < len){
  if(pattern[i] == pattern[j]){
	  lps[i] = j+1;
   i++;
   j++;
  }
  else{
		if(j != 0){
		 j = lps[j-1];
		}
		else{
		 lps[i] = 0;
		 i++;
		}
  }
 }
 return lps;
}
class Triplet{
 public:
 int x ;
 int y ;
 int gcd;
};
Triplet extendedEuclid(int a , int b){
 if(b == 0){Triplet ans; ans.gcd = a;ans.x = 1;ans.y = 0;return ans;}
 Triplet smallAns = extendedEuclid(b , a%b);
 Triplet ans;
 ans.gcd = smallAns.gcd;
 ans.x = smallAns.y;
 ans.y = smallAns.x - (a/b)*smallAns.y;
 return ans;
}
int mmInverse(int a , int m){
 Triplet ans = extendedEuclid(a , m);
 return ans.x;
}
int32_t main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n , m;
cin>>n>>m;
int arr[n];
long double sum = 0;
for(int i = 0 ; i < n ;i++){
 cin>>arr[i];
 sum += arr[i];
}
sum = (sum)/((1.0)*(4*m));
for(int i = 0 ; i < n ;i++){
  if(arr[i] >= sum){
     m--;
     if(m == 0){
	  cout<<"Yes"<<endl;
	  return 0;
	 }
  }
}
if(m != 0)
cout<<"No"<<endl;
else
cout<<"Yes"<<endl;
}



Measured memory_bytes: 256
ans = 0
A = int(input()) + 1
B = int(input()) + 1
C = int(input()) + 1
X = int(input())
for a in range(A):
    for b in range(B):
        for c in range(C):
            if (500 * a + 100 * b + 50 * c == X):
                ans += 1
print(ans)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define mod2 998244353 
#define PI 3.14159265
#define ll long long
#define ld long double
#define pi pair<ll,ll>
#define pb push_back
#define vi vector<ll>
#define sz size()
#define fi first
#define se second
#define lz length()
#define all(x) (x).begin(),(x).end()
#define scf(x) scanf("%lld",&x)
#define rep(i,n) for(ll i=0;i<n;i++)
const int INF = (int)1e9;
const ll IINF=1LL<<62;
const int maxn=10000005;
int divr[maxn];
/*ll modexpo(ll a,ll b)
{
     ll res=1LL;
     while(b>0)
     {
          if(b&1)res=(res*a)%mod;
          a=(a*a)%mod;
          b>>=1;
     }
     return res;
}
void divisor()
{for(int i=2;i<sqrt(maxn);i++)
     {
          if(!divr[i])
          {
               for(int j=i*i;j<maxn;j+=i)if(!divr[j])divr[j]=i;     
          }
     }
     for(int i=1;i<maxn;i++)if(!divr[i])divr[i]=i;
}*/
 
















int ct[100005][2];
int main()
{
     int n,k;cin>>n>>k;
     int a[n];
     rep(i,n)cin>>a[i];
     int index=-1;
     for(int i=0;i<n;i++)if(a[i]==1)index=i;
     int ans=(n-1+k-2)/(k-1);
     cout<<ans;
}

















 

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define rep(i,a,n) for(int i=a;i<n;i++)
using namespace std;
typedef long long ll;
const int maxn = 1e9;

struct node
{
    int v=0,n=0;
};
node a[100010],b[100010];

bool cmp(node a,node b)
{
    return a.n>b.n;
}

int main()
{
    int n;cin>>n;
    rep(i,0,100005)
    {
        a[i].v=i;b[i].v=i;
    }
    rep(i,0,n/2)
    {
        int aa,bb;scanf("%d%d",&aa,&bb);
        a[aa].n+=1;b[bb].n+=1;
    }
    sort(a,a+100002,cmp);
    sort(b,b+100002,cmp);
    if(a[0].v==b[0].v)
    {
        cout<<n-max(a[0].n+b[1].n,a[1].n+b[0].n)<<endl;
    }
    else cout<<n-(a[0].n+b[0].n)<<endl;

    return 0;
}


Measured memory_bytes: 1792
s=input()
a=s.index("A")
z=s.index("Z")
if __name__ == "__main__":
    index_num = [n for n, v in enumerate(s) if v == "A"]
    #print (index_num)
if __name__ == "__main__":
    index_n = [n for n, v in enumerate(s) if v == "Z"]
    #print (index_n)
print(max(index_n)-min(index_num)+1)


Measured memory_bytes: 11464
#include<iostream>
#include<cstdio>
#include<cctype>

using namespace std;

int main()
{
	char ch;
	while (1) {
		scanf("%c",&ch);
		if (isalpha(ch)) {
			if (islower(ch))printf("%c",toupper(ch));
			else printf("%c", tolower(ch));
		}
		else printf("%c", ch);
		if (ch == '\n')break;
	}
	return 0;
}


Measured memory_bytes: 3104
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>

using namespace std;

const int MAXN = 100000 + 1000;

int n, m;
vector<int> edg[MAXN];
int col[MAXN], spe[MAXN], val[MAXN];
int L[MAXN], R[MAXN];

void no()
{
	cout << "No" << endl;
	exit(0);
}

void yes()
{
	cout << "Yes" << endl;
	for(int i = 1; i <= n; i++)
		cout << val[i] << endl;
	exit(0);
}

void update(int x, int l, int r)
{
	L[x] = max(L[x], l);
	R[x] = min(R[x], r);
}

bool dfs1(int x, int fa, int c)
{
	if(spe[x] && c != (val[x] & 1))
		return false;
	for(int i = 0; i < edg[x].size(); i++)
		if(edg[x][i] != fa)
			if(!dfs1(edg[x][i], x, c ^ 1))
				return false;
	return true;
}

bool dfs2(int x, int fa)
{
	if(spe[x])
		update(x, val[x], val[x]);
	for(int i = 0; i < edg[x].size(); i++)
		if(edg[x][i] != fa)
		{
			int y = edg[x][i];
			if(!dfs2(y, x))
				return false;
			update(x, L[y] - 1, R[y] + 1);
		}
	// cerr << x << ' ' << L[x] << ' ' << R[x] << endl;
	return L[x] <= R[x];
}

void dfs3(int x, int fa)
{
	for(int i = 0; i < edg[x].size(); i++)
		if(edg[x][i] != fa)
		{
			int y = edg[x][i];
			if(!spe[y])
				val[y] = (val[x] + 1 <= R[y] ? val[x] + 1 : val[x] - 1);
			dfs3(y, x);
		}
}

int main()
{
	ios::sync_with_stdio(false);
	// freopen("1.in", "r", stdin);
	// freopen("1.out", "w", stdout);

	cin >> n;
	for(int i = 1; i <= n - 1; i++)
	{
		int x, y;
		cin >> x >> y;
		edg[x].push_back(y);
		edg[y].push_back(x);
	}
	cin >> m;
	for(int i = 1; i <= m; i++)
	{
		int x;
		cin >> x;
		cin >> val[x];
		spe[x] = true;
	}

	for(int i = 1; i <= n; i++)
		if(spe[i])
		{
			if(!dfs1(i, 0, val[i] & 1))
				no();
			break;
		}
	memset(L, -31, sizeof(L));
	memset(R, 31, sizeof(R));
	if(!dfs2(1, 0))
		no();
	if(!spe[1])
		val[1] = L[1];
	dfs3(1, 0);
	yes();

	return 0;
}


Measured memory_bytes: 15872
//18
#include<iostream>
#include<cctype>

using namespace std;

char s[101];
char *p;

int pp();
int pm();
int pb();

int pp(){
  int a=pm();
  while(*p=='+'||*p=='-'){
    char o=*p++;
    int b=pm();
    if(o=='+'){
      a+=b;
    }else{
      a-=b;
    }
  }
  return a;
}

int pm(){
  int a=pb();
  while(*p=='*'||*p=='/'){
    char o=*p++;
    int b=pb();
    if(o=='*'){
      a*=b;
    }else{
      a/=b;
    }
  }
  return a;
}

int pb(){
  if(*p=='('){
    p++;
    int a=pp();
    p++;
    return a;
  }else{
    int a=0;
    while(isdigit(*p)){
      a=a*10+*p-'0';
      p++;
    }
    return a;
  }
}

int main(){
  int n;
  cin>>n;
  while(n--){
    cin>>s;
    p=s;
    cout<<pp()<<endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
// S - Digit Sum

#define MOD 1000000007

using namespace std;

string K;
int dp[10005][105];
bool vis[10005];
int D,ans;

void solve2(int len) {
    if (vis[len])
        return;

    vis[len] = true;

    if (len == 0) {
        dp[len][0] = 1;
        return;
    }

    int i,j;

    solve2(len - 1);
    for (i = 0;i < D;i++) {
        for (j = 0;j < 10;j++) {
            dp[len][i] += dp[len - 1][(i - j + (D << 5)) % D];
            dp[len][i] %= MOD;
        }
    }
}

void solve1(int len,int rem) {
    if (len == 0) {
        if (rem == 0) {
            ans++;
            ans %= MOD;
        }
        return;
    }

    int i;

    for (i = 0;i + '0' < K[K.size() - len];i++) {
        solve2(len - 1);
        ans += dp[len - 1][((D << 5) - rem - i) % D];
        ans %= MOD;
    }

    solve1(len - 1,(rem + K[K.size() - len] - '0') % D);
}

int main() {
    cin >> K;
    cin >> D;

    ans = 0;
    solve1((int) (K.size()),0);

    printf("%d\n",(ans - 1 + MOD) % MOD);

    return 0;
}


Measured memory_bytes: 4736
#include<iostream>
#include<vector>
#include<cmath>

int main() {
	int n,m,a;
	std::cin >> n >> m >> a;
	if (n + m >= a) {
		std::cout << "Yes" << std::endl;
	}
	else {
		std::cout << "No" << std::endl;
	}
}

Measured memory_bytes: 256
n = input()
N = int(n)

def can_devide(num):
    return num > 26

def get_alpha(alp):
    apls = [chr(i) for i in range(97, 97+26)]
    return apls[alp - 1]


ans = ""

while True:
    alp = N % 26

    ans += get_alpha(alp)
    
    if alp == 0:
        N = N // 26 -1
    else:
        N = N // 26 
        
    if N == 0:
        break



print(ans[::-1])


Measured memory_bytes: 9184
/*
このコード、と～おれ!
Be accepted!
  ∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
　　　　　　　　　　(¸.·´ (¸.·'* ☆
*/


#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printfin(a) printf(a ? "possible\n" : "inposible\n")
#define all(x) (x).begin(), (x).end()
using ll = long long;

const int INF = 2147483647;
//const ll LINF = ll();今度書く

//マクロとかここまで

#include <stdio.h>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>

using namespace std;

int main() {

	int n, a, ans = INF, anstmp = 0;
	scanf("%d", &n);
	rep(i, n) {
		scanf("%d", &a);
		while (!(a & (1 << anstmp)))++anstmp;
		ans = min(anstmp, ans);
		anstmp = 0;
	}
	printf("%d\n", ans);

	return 0;
}


Measured memory_bytes: 128
A,B = map(int,input().split())

def f(n) :
    if n % 4 == 3 :
        return 0
    elif n % 4 == 1 :
        return 1
    elif n % 4 == 0 :
        return n
    else :
        return n+1

ans = f(A-1) ^ f(B)
print(ans)


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

#define ll long long
#define pb push_back
#define INF 1'000'000'007
#define cases int t;cin>>t;while(t--)
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define per(i,a,b) for(ll i=a;i>=b;i--)
#define ff first
#define ss second

#define test4(x,y,z,a) cout<<"x is "<<x<<"		y is "<<y<<"		z is "<<z<<"		a is "<<a<<endl;
#define test3(x,y,z) cout<<"x is "<<x<<"		y is "<<y<<"		z is "<<z<<endl;
#define test2(x,y) cout<<"x is "<<x<<"		y is "<<y<<endl;
#define test1(x) cout<<"x is "<<x<<endl;

int main(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	
	string s;
	cin>>s;
	ll sum=0;
	rep(i,0,s.size()){
		sum+=s[i]-'0';
	}
	if(sum%9==0){
		cout<<"Yes";
	}
	else{
		cout<<"No";
	}
	
	
	
	return 0;
}

Measured memory_bytes: 3748
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using P = pair<int, int>;
using vec = vector<lint>;
using mat = vector<vector<int>>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"

constexpr int MOD = 1000000007;
const int INF = 1 << 30;

vec a, b, c;
lint res = 0;

int main() {
    int n;
    cin >> n;
    a.resize(n); b.resize(n); c.resize(n);
    rep(i, n) cin >> a[i];
    rep(i, n) cin >> b[i];
    rep(i, n) cin >> c[i];

    sort(all(a));
    sort(all(b));
    sort(all(c));

    vec b_cnt(n);
    rep(i, n) b_cnt[i] = (c.end() - upper_bound(all(c), b[i]));

    vec b_cnts(n);
    b_cnts[n-1] = b_cnt[n-1];
    for (int i = n-2; i >= 0; --i) b_cnts[i] = b_cnts[i+1] + b_cnt[i];

    rep(i, n) {
        int j = upper_bound(all(b), a[i]) - b.begin();
        if (j == n) break;

        res += b_cnts[j];
    }

    cout << res << endl;
    return 0;
}

Measured memory_bytes: 7204
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<long long> vll;
typedef vector<pair<int, int>> vpi;
typedef vector<pair<long long, long long>> vpl;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define FOR(i, k, n) for (int i = (k); i < (int)(n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.begin(), a.end(), greater<int>()
#define ROT(a) a.begin(), a.begin() + 1, a.end()
#define RROT(a) a.begin(), a.end() - 1, a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
#define sz(a) a.size()
const ll MOD = 1e9 + 7;
const int MAX = 10000000;
template <typename T1, typename T2>
inline bool chmin(T1& a, T2 b)
{
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T1, typename T2>
inline bool chmax(T1& a, T2 b)
{
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
T gcd(T a, T b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
//cout << 'H' << endl;
/*--------------------------------------------*/

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

    int N;
    cin >> N;

    ll ans = 0;
    ll pre = 0;

    rep(i, N)
    {
        ll now;
        cin >> now;

        if (pre % 2 && now) {
            now--;
            pre++;
        }

        ans += pre / 2;

        pre = now;
    }

    ans += pre / 2;

    cout << ans << endl;
}


Measured memory_bytes: 256
// 0556.cpp : ??????????????? ??¢????????±????????§????????¨????????? ?????????????????????????????????
//

#include <bits/stdc++.h>

using namespace std;

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

	while (k--) {
		int a, b;
		cin >> a >> b;
		int len = min(min(a, b), min(n - a + 1, n - b + 1));
		cout << ((len % 3) == 0 ? 3 : len % 3) << endl;
	}

    return 0;
}

Measured memory_bytes: 3008
N = int(input())
A = list(map(int,input().split()))
sums_dic = {}
a = sum(A)
sums_dic[a] = 1

for n in range(1,N):
    a -= A[n-1]
    sums_dic[a] = sums_dic.setdefault(a, 0) + 1 

count = 0
for key, value in sums_dic.items():
    if key == 0:
        count += value
    
    if value >= 2:
        count += value * (value - 1) // 2
    
print(count)

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

using namespace std;

#define INF 1000007
#define MOD 1000000007
#define maxn 10001
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) FOR(i, 0, n)
#define int long long
const double PI = acos(-1);
typedef pair<int, int> P;

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

int lcm(int a, int b) { return a / gcd(a, b) * b; }

int mpow(int N, int P, int M) //繰り返し自乗法
{
    if (P == 0)
        return 1;
    if (P % 2 == 0)
    {
        int t = mpow(N, P / 2, M);
        return t * t % M;
    }
    return N * mpow(N, P - 1, M) % M;
}

int counter(int x) //bit計算
{
    if (x == 0)
        return 0;
    return counter(x >> 1) + (x & 1);
}

vector<bool> prime(maxn + 1, true); //素数テーブル
void prime_table(void)
{
    prime[0] = false;
    prime[1] = false;
    for (int i = 2; i * i <= maxn; i++)
    {
        if (!prime[i])
        {
            continue;
        }
        for (int j = i + i; j <= maxn; j += j + i)
        {
            prime[j] = false;
        }
    }
}

bool IsPrime(int num) //素数判定
{
    if (num < 2)
        return false;
    else if (num == 2)
        return true;
    else if (num % 2 == 0)
        return false;

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return false;
        }
    }

    return true;
}
vector<int> divisor(int n) //約数列挙
{
    vector<int> ret;
    for (int i = 1; i * i <= n; i++)
    {
        if (n % i == 0)
        {
            ret.push_back(i - 1);
            if (i * i != n)
            {
                ret.push_back((n / i) - 1);
            }
        }
    }
    sort(ret.begin(), ret.end());
    return (ret);
}

signed main()
{
  string s;
  cin >> s;
  rep(i,s.size()){
    if(s[i] == ','){
    	cout << " ";
    }else{
      cout << s[i] ;
    }
  }
  cout << endl;
}
  


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Threading;
using System.IO.Pipes;
using System.ComponentModel;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            int[] Arr = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            int[] col = new int[8];
            int or = 0;
            int min = 0;
            int max = 0;

            for (int i = 0; i < N; i++) 
            {
                if (Arr[i] >= 3200)
                {
                    or++;
                }
                else 
                {
                    col[Arr[i] / 400] = 1;
                }
            }

            min = col.Sum();
 
            max = min + or;
            
            if (min == 0) 
            {
                min = 1;
            }
            Console.WriteLine(min + " " + max);


        }

    }
}


Measured memory_bytes: 28132
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
namespace AtCoder
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }

        static readonly long Mod = 1000000000 + 7;

        static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });

            var A = Sarray()[0];
            var B = Sarray()[0];
            var C = Sarray()[0];
            var X = Sarray()[0];
            if (X % 50 != 0)
            {
                WriteLine(0);
                return;
            }
            var ans = 0;
            for (var i = 0; i <= A; ++i)
                for (var j = 0; j <= B; ++j)
                {
                    var nokori = X - (500 * i + 100 * j);
                    if (nokori < 0) break;
                    if (nokori / 50 <= C)
                        ++ans;
                }

            WriteLine(ans);
            //Out.Flush();
        }
    }
}

Measured memory_bytes: 13268
N = int(input())
S = []
for _ in range(N):
    D = list(map(int, input().split()))
    S.append(D)

dp = [[0 for _ in range(3)] for _ in range(N+1)]

for i in range(1,N+1):
    for j in range(3):
        for k in range(3):
            if j != k:
                happy =  dp[i-1][k] + S[i-1][j]
                if dp[i][j] < happy:
                    dp[i][j] = happy

print(int(max(dp[N])))

Measured memory_bytes: 74612
#include <iostream>
#include <stdlib.h>

using namespace std;

int main(){
  char in[3];
  for(int i=0; i<3;i++){
    cin >> in[i];
  }
  if(in[0]==in[1] && in[1]==in[2]){
    cout << "No";
  }else{
    cout << "Yes";
  }
}

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

int main(){
  int H,W;
  cin >> H >> W;
  
  string board[50];
  for(int i=0;i<H;i++){
    cin >> board[i];
  }
  
  vector<int> dx={1,-1,1,-1,0,0,1,-1};
  vector<int> dy={0,0,1,-1,1,-1,-1,1};
  
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      cin >> board[i][j];
      if(board[i][j]=='.'){
        int cnt=0;
        for(int k=0;k<8;k++){
          int x=i+dx[k],y=j+dy[k];
          if(x<0 || x>=H || y<0 || y>=W){
            continue;
          }
          if(board[x][y]=='#'){
            cnt++;
          }
        }
        board[i][j]=char(cnt+'0');
      }
    }
  }
  
  for(int i=0;i<H;i++){
    cout << board[i] <<endl;
  }
}

  

Measured memory_bytes: 3608
/******************************************
* AUTHOR : RAJAGOPALAN *
* NICK : ARNO *
* INSTITUTION : VIT *
******************************************/
#include <bits/stdc++.h>
#include <ext/pb_ds/detail/standard_policies.hpp>
#define ll long long
#define ull unsigned long long
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define alli(a, n, k) (a+k),(a+n+k)
#define FP(i, a, b, k) for(__typeof(a) i = a;i < b;i += k)
#define FS(i, a, b, k) for(__typeof(a) i = a;i > b;i -= k)
#define IT(it, a) for(__typeof(a.begin()) it = a.begin();it != a.end(); ++it)
#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define eps 1e-6
#define pi 3.141592653589793
using namespace std;
using namespace __gnu_pbds;

template<class T> inline T gcd(T x, T y) { if (!y) return x; return gcd(y, x%y);}
typedef vector<int> VII;
typedef vector<ll> VLL;
typedef pair<int, int> PII;
typedef vector< pair<int, int> > VPII;
typedef vector< pair<int, PII > > VPPI;
const int MOD = 1e9 + 7;
const int INF = 1e9;

inline ll modulo(ll a, ll m)
{
    return (a % m + m) % m;
}

inline ll modInverse(ll a, ll m)
{
    assert(__gcd(a, m) == 1);
    ll m0 = m;
    ll y = 0, x = 1;

    if (m == 1)
        return 0;

    while (a > 1)
    {
        ll q = a / m;
        ll t = m;

        m = a % m, a = t;
        t = y;

        y = x - q * y;
        x = t;
    }

    if (x < 0)
        x += m0;

    return x;
}

inline ll modPow(ll x, ll y, ll m)
{ //x^y % m
    if (y == 0)
        return 1LL;
    else if (y == 1)
        return x;
    else
    {
        ll ans = modPow(x, y / 2, m) % m;
        if (y & 1)
        {
            return (((ans * ans) % m) * x) % m;
        }
        else
        {
            return (ans * ans) % m;
        }
    }
}

int main(int argc, char* argv[])
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    string s;
    cin >> s;
    int n = s.size();
    bool nf = true;
    if (s[0] != 'A')
        nf = false;
    if (s[1] < 'a' || s[n - 1] < 'a' || s[1] > 'z' || s[n - 1] > 'z')
        nf = false;
    int cnt = 0;
    for (int i = 2; i < n - 1; i++)
    {
        if (s[i] < 'a' || s[i] > 'z')
        {
            if (s[i] != 'C')
            {
                nf = false;
            }
            else
            {
                cnt++;
            }
        }
    }
    if (cnt == 1 && nf)
    {
        cout << "AC";
    }
    else
    {
        cout << "WA";
    }
    return 0;
}

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

int main(){

  int x, h;
  double s;

  while(cin >> x >> h){
    if(x == 0) break;
    s = 2.0 * x * sqrt(0.25 * x * x + h * h);
    s += (double)x * x;
    printf("%lf\n", s);
  }

  return 0;

}

Measured memory_bytes: 1188
#include<bits/stdc++.h>
#define ll long long
#define mp make_pair
#define pb push_back
#define x first
#define y second
#define gc getchar_unlocked
#define cases int t;  cin>>t;   while(t--)
ll mod =1e9+7;
//template<typename T> 
inline ll pwr(ll base,ll n){ll ans=1;while(n>0){ if(n%2==1)ans=ans*base;  base=base*base; n/=2;} return ans;}
struct range{int l,h;}; 
using namespace std;
int main()
{
ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int a,b;
    cin>>a>>b;
    int ct=1;
    int c=0;
    while(ct<b)
    {
      ct-=1;
      ct+=a;
      c++;
    }
    cout<<c;
    return 0;
}

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

int n;
int lim;
vector<string> A;

void f(int digitNum, string s){ 
    vector<bool> J(3, false);
    for(int i = 0; i < s.size(); i++){
        if(s[i] == '3') J[0] = true;
        if(s[i] == '5') J[1] = true;
        if(s[i] == '7') J[2] = true;
    }
    int idx = find(J.begin(), J.end(), false) - J.begin();
    if(idx == 3){
        A.push_back(s);
    }
    if(digitNum == lim){
        return;
    }
    f(digitNum + 1, s + '3');
    f(digitNum + 1, s + '5');
    f(digitNum + 1, s + '7');
    return;
}

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

    cin >> n;
    
    lim = to_string(n).length();
    
    if(lim < 3){
        cout << 0 << endl;
        return 0;
    }

    f(0, "");

    vector<int> B(A.size());
    for(int i = 0; i < A.size(); i++){
        B[i] = stoi(A[i]);
    }

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

    int idx = lower_bound(B.begin(), B.end(), n) - B.begin();

    cout << idx + (B[idx] == n) << endl;

    return 0;
}

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

using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;
typedef vector < vector<ll> > Mat;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int N, Prime[105], ans = 0;

int main(){
  cin >> N;
  for (int i = 2; i <= N; i++){
    int num = i;
    for (int j = 2; j <= i; j++){
      while (num % j == 0){
        Prime[j]++; num /= j; 
      }
    }
  }

  for (int i = 2; i <= N; i++){
    for (int j = i + 1; j <= N; j++){
      for (int k = 2; k <= N; k++){
        if (i == j || j == k || k == i) continue;
        int I = min(5, Prime[i] + 1);
        int J = min(5, Prime[j] + 1);
        int K = min(3, Prime[k] + 1);
        if (I * J * K == 75) ans++;
      }
    }
  }

  for (int i = 2; i <= N; i++){
    for (int j = 2; j <= N; j++){
      if (i == j) continue;
      int I = min(25, Prime[i] + 1);
      int J = min(3, Prime[j] + 1);
      if (I * J == 75) ans++;

      I = min(15, Prime[i] + 1);
      J = min(5, Prime[j] + 1);
      if (I * J == 75) ans++;
    }
  }

  for (int i = 2; i <= N; i++){
    if (Prime[i] >= 74) ans++;
  }

  cout << ans << endl;


  return 0;
}


Measured memory_bytes: 3612
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <string>
/*
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>


typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };
*/

using namespace std;

int main()
{
    int n;
    while (cin >> n)
    {
        if (n == 0)
            break;
        double s[1005];
        for (int i = 0; i < n; i++)
            cin >> s[i];

        double m = 0;
        for (int i = 0; i < n; i++)
            m += s[i]/n;

        double alpha2 = 0;
        for (int i = 0; i < n; i++)
            alpha2 += pow(s[i] - m, 2) / n;

        cout << fixed << setprecision(8) << sqrt(alpha2) << endl;
    }
}


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

int main()
{
    char sr[3];
    scanf("%s", sr);

    int rc_cnt = 0;
    int rc_ans = 0;
    int i;

    for (i = 0; i < strlen(sr); i++)
    {
        if (sr[i] == 'S')
        {
            rc_cnt = 0;
        }
        else if (sr[i] == 'R')
        {
            rc_cnt++;
            if (rc_cnt > rc_ans)
            {
                rc_ans = rc_cnt;
            }
        }
    }

    printf("%d\n", rc_ans);

    return (0);
}

Measured memory_bytes: 1720
#include <stdio.h>
#define MAX 200000
#define MIN -2000000000
int main(){

  int i,x,n,R[MAX],minv=0,maxv=MIN;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&R[i]);
}
  minv=R[0];
  for(i=1;i<n;i++){
    x=R[i]-minv;
    if(maxv<x)maxv=x;
    if(minv>R[i])minv=R[i];
  }
  printf("%d\n",maxv);

  return 0;
}



Measured memory_bytes: 2568
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<climits>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<numeric>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i = m; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a)  (a).rbegin(),(a).rend()
#define PI 3.14159265359
typedef long long LL;

template<class T> inline void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> inline void chmin(T& a, T b) { if (a > b) { a = b; } }
template<class T> void print_vector(vector<T> vec) {
	cout << "[ ";
	for (int i = 0; i < vec.size(); i++) {
		cout << vec[i] << " ";
	}
	cout << "]" << endl;
}
template<class T> void print_pair_vector(vector<pair<T, T> > vec) {
	cout << "[ ";
	for (int i = 0; i < vec.size(); i++) {
		cout << "(" << vec[i].first << "," << vec[i].second << ") ";
	}
	cout << "]" << endl;
}

const int INF = 1 << 30;

int main(void) {
	string A;
	cin >> A;
	A[5] = ' ';
	A[13] = ' ';
	cout << A << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace std;

int toNum(const string &s){
	int tbl[501];
	tbl['I']=1;
	tbl['V']=5;
	tbl['X']=10;
	tbl['L']=50;
	tbl['C']=100;
	tbl['D']=500;
	tbl['M']=1000;
	int sum=0;
	for(int i=0;i<(int)s.size();i++){
		if(i==0)sum+=tbl[s[i]];
		else if(tbl[s[i]]<=tbl[s[i-1]])sum+=tbl[s[i]];
		else{
			sum+=-2*tbl[s[i-1]]+tbl[s[i]];
		}
	}
	return sum;
}

int main(){

	string s;
	while(cin>>s){
		cout<<toNum(s)<<endl;
	}

	return 0;
}

Measured memory_bytes: 0
s = input()
cnt = [0,0]
I = ""
ans = [0] * len(s)
for i in range(len(s)):
    if s[i] == "R": 
        if I == "": cnt[0] += 1
        else:
            ans[I] = (cnt[0]+1)//2 + cnt[1]//2
            ans[I+1] = cnt[0]//2 + (cnt[1]+1)//2
            cnt = [1,0]
            I = ""
    else:
        if I == "": I = i-1
        cnt[1] += 1
ans[I] = (cnt[0]+1)//2 + cnt[1]//2
ans[I+1] = cnt[0]//2 + (cnt[1]+1)//2
print(" ".join(map(str, ans)))

Measured memory_bytes: 16996
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <bitset>

#include <queue>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <ctime>
////
//#include <random>//
/////////

typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;

////定数
const int INF = (int)1e9 + 10;
const LL MOD = (LL)1e9 + 7;
const LL LINF = (LL)4e18 + 20;
const LD PI = acos(-1.0);
const double EPS = 1e-9; 
/////////
using namespace::std;
//////////////

void solve() {
	int N, K, Q;
	cin >> N >> K >> Q;
	vector<int> A(N);
	for (int i = 0; i < N; ++i) {
		cin >> A[i];
	}
	int ans = INF;
	vector<int> temp(N);//候補
	vector<int> temp2(N);//候補候補
	for (int i = 0; i < N; ++i) {
		int X = A[i];
		int num = 0;//選択候補確定
		int cnt = 0;
		/*
		数列分解して、除ける最小値候補を選択
		*/
		for (int j = 0; j < N; ++j) {
			if (A[j] >= X) {
				temp2[cnt] = A[j];
				++cnt;
			}
			else if(A[j] < X ){
				int ter = cnt - K +1;
				if(ter>0){
					sort(temp2.begin(),temp2.begin()+cnt);
					for (int k = 0; k < ter; ++k) {
						temp[num] = temp2[k];
						++num;
					}
				}
				cnt = 0;
			}
		}
		if (cnt) {
			int ter = cnt - K + 1;
			if (ter > 0) {
				sort(temp2.begin(), temp2.begin() + cnt);
				for (int k = 0; k < ter; ++k) {
					temp[num] = temp2[k];
					++num;
				}
			}
			cnt = 0;
		}

		if (num >= Q) {//Q個以上取り除ける候補がある。
			sort(temp.begin(), temp.begin() + num);
			ans = min(ans, temp[Q - 1] - temp[0]);
		}
	}
	cout << ans << endl;
}

signed main(void) {
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
  int A, B, C, X, Y;
  cin >> A >> B >> C >> X >> Y;

  int ans {0};
  
  int n {min(X,Y)};
  if(C*2 <= A + B){
    ans += C*2*n;
  }else{
    cout << X*A+Y*B << endl;
    return 0;
  }

  X -= n;
  Y -= n;

  if(X == 0){
    if(C*2 <= B){
      cout << ans+C*2*Y << endl;
    }else{
      cout << ans+Y*B << endl;
    }
  }else{
    if(C*2 <= A){
      cout << ans+C*2*X << endl;
    }else{
      cout << ans+X*A << endl;
    }
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

int n,m,a,b;
vector<int> d,ans;
vector<vector<pair<int,int>>> v;
vector<bool> vs,c;

void rec(int i,bool f=false){
    if(vs[i]) return;
    vs[i]=true;
    c[i]=f;
    for(auto&j:v[i]) if(ans[j.second]!=-1){
        rec(j.first,!f);
    }
}

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    istream& in(cin);
    ostream& out(cout);
    in>>n>>m;
    d.resize(n);v.resize(n);
    for(auto&i:d) in>>i;
    fr(i,m){
        in>>a>>b;
        --a,--b;
        v[a].emplace_back(b,i);
        v[b].emplace_back(a,i);
    }
    fr(i,n){
        sort(v[i].begin(),v[i].end(),[&](pair<int,int> x,pair<int,int> y){
            return d[x.first]<d[y.first];
        });
        if(d[i]<d[v[i][0].first]) return cout<<-1<<endl,0;
    }
    c.resize(n);
    ans.resize(m,-1);
    vector<int> vis(n,-1);
    fr(i,n){
        if(vis[i]==d[i]) continue;
        int j,e;
        tie(j,e)=v[i][0];
        vis[j]=ans[e]=d[i];
    }
    vs.resize(n);
    fr(i,n) rec(i);
    fr(i,n) cout<<(c[i]?"B":"W");
    cout<<endl;
    fr(i,m) cout<<(ans[i]==-1?1000000000:ans[i])<<endl;
}

Measured memory_bytes: 12032