akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define for_(i,a,b) for(int i=a;i<b;++i)
#define ALL(a) a.begin(),a.end()
#define INIT(a,b) memset(a,b,sizeof(a))
using lint = long long int;

vector<int> enumerate(int x) {
    int REP = sqrt(x) + 1;
    vector<int> ret;
    for_(i,1,REP+1) {
        if (x % i == 0) {
            int b = x / i;
            ret.push_back(i);
            ret.push_back(b);
        }
    }
    return ret;
}

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

    vector<int> cnt(1000006, 0);
    for_(i,0,N) {
        int A;
        cin >> A;
        cnt[A]++;
    }

    int ans = 0;
    for_(i,0,1000006) {
        if (cnt[i] == 1) {
            vector<int> p = enumerate(i);
            bool ok = true;
            for (int x : p) if (x != i) ok &= (cnt[x] == 0);
            if (ok) ++ans;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 7312
def Atcoder111(n):

    ans = ""

    if int(n[0]) > int(n[1]) or int(n[0]) == int(n[1]) >= int(n[2]):
        ans = n[0]*3
    else:
        ans = int(n[0]*3)
        ans += 111

    return ans

def main():
    n = str(input())
    print(Atcoder111(n))

if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
#include<iostream>
using namespace std;
int main() {
	char N[4];
	cin >> N;
	if (N[0] == '7') {
		cout << "Yes" << endl;
		return 0;
	}
	if (N[1] == '7') {
		cout << "Yes" << endl;
		return 0;
	}
	if (N[2] == '7') {
		cout << "Yes" << endl;
		return 0;
	}
	cout << "No" << endl;
	return 0;
}



Measured memory_bytes: 3624
import java.util.Scanner;

public class Main {

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

		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();

		if (a == b && b == c) {
			System.out.println("Yes");
		}
		else {
			System.out.println("No");
		}
	}

}

Measured memory_bytes: 22868
#include<iostream>
#include<cmath>
#include<algorithm>

using namespace std;
int a[1000];
int main()
{
	int N, K;
	int sum =0, n = 0;
	scanf("%d %d", &N, &K);
	for (int i = 0; i < N; i++)
		scanf("%d", &a[i]);
	sort(a, a + N);
	for (int i = 0; i < K; i++)
		sum += a[i];
	printf("%d", sum);
	

	return 0;
}

Measured memory_bytes: 3788
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int ac = 0; int wa = 0; int tle = 0; int re = 0;

		int n = sc.nextInt();

		for(int i = 0; i < n; i++) {
			String s = sc.next();
			ac += s.equals("AC") ? 1 : 0;
			wa += s.equals("WA") ? 1 : 0;
			tle += s.equals("TLE") ? 1 : 0;
			re += s.equals("RE") ? 1 : 0;
		}

		System.out.println("AC x " + ac);
		System.out.println("WA x " + wa);
		System.out.println("TLE x " + tle);
		System.out.println("RE x " + re);
	}
}

Measured memory_bytes: 58188
import math

n,m = map(int,input().split())
li = list(map(int,input().split()))
wa = 0
for i in li :
    wa+=i

for i in li :
    if i < math.ceil((wa/float(4*m))) :
        n -= 1

if n>=m:
    print("Yes")
else:
    print("No")


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

int main(){
    int h,w;
    for (;;) {
        scanf("%d %d",&h,&w);
        if (h==0) break;
        for (int i=0;i<h;i++) {
            for (int j=0;j<w;j++) {
                printf("#");
            }
            printf("\n");
        }
        printf("\n");
    }
    return 0;
}



Measured memory_bytes: 3104
S= input()

f=int(S[0]+S[1])
r=int(S[2]+S[3])

if f>=1 and f<=12 and r>=1 and r<=12:
  print('AMBIGUOUS')
elif (r>=1 and r<=12):
  print('YYMM')
elif (f>=1 and f<=12):
  print('MMYY')
else:
  print('NA')
    

Measured memory_bytes: 3060
#include <iostream>
 
using namespace std;
 
int s[7];
 
int main()
{
  int a, b, c;
  
  cin >> a >> b >> c;
  
  s[a]++;
  
  s[b]++;
  
  s[c]++;
  
  if(s[5]==2 && s[7]==1) cout << "YES" << endl;
    
  else cout << "NO" << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
#include <string>
#include <vector>
#include <set>
#include <cstdlib>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

struct Sum2D {
	vector<vector<ll>> b;
	Sum2D() {};
	Sum2D(const vector<vector<ll>>& a) {
		int H = a.size(), W = a[0].size();
		b = a;
		for(int i = 0; i < H; i++)
		for(int j = 0; j < W - 1; j++) b[i][j + 1] += b[i][j];
		for(int j = 0; j < W; j++)
		for(int i = 0; i < H - 1; i++) b[i + 1][j] += b[i][j];
	}
	// ?????????
	ll sum(int x1, int y1, int x2, int y2) {
		ll ret = b[y2][x2];
		if(y1 - 1 >= 0) ret -= b[y1 - 1][x2];
		if(x1 - 1 >= 0) ret -= b[y2][x1 - 1];
		if(y1 - 1 >= 0 && x1 - 1 >= 0) ret += b[y1 - 1][x1 - 1];
		return ret;
	}
};
Sum2D S;

//D
int N;

bool in(int x, int y) {
	return 0 <= x && x < N && 0 <= y && y < N;
}

string A[128];
int dp[64][64][64][64];
int dx[4] = { 1, 0, -1, 0 }, dy[4] = { 0, 1, 0, -1 };

vector<int> cross[128];

int conv(int x1, int y1, int x2, int y2) {
	int ret = x1;
	ret = ret * 128 + y1;
	ret = ret * 128 + x2;
	ret = ret * 128 + y2;
	return ret;
}

map<int, int> dpm;

int f(int x1, int y1, int x2, int y2) {
	if(x2 < x1 || y2 < y1) return 0;
	int hash = conv(x1, y1, x2, y2);
	if(dpm.count(hash)) return dpm[hash];
	//if(dp[x1][y1][x2][y2] >= 0) return dp[x1][y1][x2][y2];
	//int& d = dp[x1][y1][x2][y2];
	int H = y2 - y1 + 1, W = x2 - x1 + 1;
	if(S.sum(x1, y1, x2, y2) == 0) return 0;
	int d = 1000;
	for(int y = y1; y <= y2; y++) {
		for(auto x : cross[y]) {
			if(x1 <= x && x <= x2) {
				if(S.sum(x1, y, x2, y) != W) continue;
				if(S.sum(x, y1, x, y2) != H) continue;
				int sum = 1;
				sum += f(x1, y1, x - 1, y - 1);
				sum += f(x + 1, y1, x2, y - 1);
				sum += f(x1, y + 1, x - 1, y2);
				sum += f(x + 1, y + 1, x2, y2);
				d = min(d, sum);
			}
		}
	}
	return dpm[hash] = d;
}

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

	cin >> N;
	vector<vector<ll>> b(N);
	for(int i = 0; i < N; i++) {
		cin >> A[i];
		for(int j = 0; j < N; j++) {
			b[i].push_back(A[i][j] == 'x');
		}
	}
	S = Sum2D(b);
	for(int y = 0; y < N; y++) {
		for(int x = 0; x < N; x++) {
			if(A[y][x] == 'o') continue;
			bool ok = true;
			for(int k = 0; k < 4; k++) {
				int nx = x + dx[k], ny = y + dy[k];
				if(in(nx, ny) && A[ny][nx] == 'o') {
					ok = false;
					break;
				}
			}
			if(ok) cross[y].push_back(x);
		}
	}
	memset(dp, -1, sizeof dp);
	cout << f(0, 0, (N - 1), (N - 1)) << endl;
}

Measured memory_bytes: 68876
#include <iostream>
#include <functional>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <queue>
#include <map>
#include <iomanip>
#include <complex>
#include <random>
#include <bitset>
#include <list>
// #include <prettyprint.hpp>
using namespace std;
#define repi(i,n) for(int i=0;i<n;++i)
#define rep(i,n) for(ll i=0;i<n;++i)
#define repinvi(i,n) for(int i=n-1;i>=0;--i)
#define sll(n) scanf("%lld", &n);
#define sii(n) scanf("%d", &n);
#define slf(n) scanf("%lf", &n);
#define pll pair<ll,ll>
#define pii pair<int,int>
#define psi pair<si,si>
typedef long long ll;
typedef double lf;
typedef short int si;



void Main(){
    ll N, X, M;
    cin >> N >> X >> M;
    set<ll> found;
    vector<ll> found_r = {X};
    found.insert(X);

    ll a = X;
    ll circle_length = 0;
    // ll sum = a;
    rep(i, M){
        a = (a * a) % M;
        if(found.find(a) != found.end()){
            circle_length = i+1;
            break;
        }
        found.insert(a);
        found_r.emplace_back(a);
        // sum += a;
    }

    // ll size_r = found_r.size();
    auto it = find(found_r.begin(), found_r.end(), a);
    ll first_l = it - found_r.begin();
    ll circle_l = found_r.size() - first_l;
    ll sum = 0;
    ll first_s = 0;
    rep(i, circle_l){
        sum += found_r[first_l+i];
    }
    rep(i, first_l){
        first_s += found_r[i];
    }
    // found_r.find()

    // cout << "found r:" << found_r << endl;
    // cout << "size_r:" << size_r << " circle_l="<<circle_length <<endl;
    // cout << "first_l:" << first_l << " circle_l=" << circle_l << endl;
    // cout << "circle sum:" << sum << " first_s:" << first_s <<endl;

    ll res = (N  - first_l)% circle_l;
    ll ans = (N - first_l) / circle_l * sum;
    if(res>0){
        rep(i, res){
            ans += found_r[i+first_l];
        }
    }

    cout << ans + first_s <<endl;

}

int main(){
    Main();
}

Measured memory_bytes: 5516
//============================================================================
// Name        : ATcoder.cpp
// Author      : Akari Fujii
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <cctype>
#include <string>
#include<algorithm>
using namespace std;
typedef long long ll;
int main() {


	string str1,str2,str3;
	int d=0,e=0;
	cin>>str1>>str2>>str3;


	d+=str1.size();
	e+=str2.size();
	if(str1[d-1]==str2[0]&&str2[e-1]==str3[0]){
		cout<<"YES"<<endl;
	}else{
		cout<<"NO"<<endl;
	}





	return 0;




}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const int MOD = (int)1e9 + 7;
const double PI = 3.14159265358979323846;

int main(void) {
  int a;
  cin >> a;
  int ans = a + a * a + a * a * a;
  cout << ans << endl;
  return 0;
}

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

int main() {
	char S[20];
	string T;
	string p;
	string Q;
	int a = 0;
	int A = 0;
	int b = 0;
	int B = 0;
	int c = 0;
	int C = 0;
	int q, w, z;
	int n = 0;
	int x = 0;
	int y = 0;
	int ans = 0;
	cin >> T;
	if (T[0] == '9' || T[1] == '9') {
		cout << "Yes";
	}
	else {
		cout << "No";
	}
}

Measured memory_bytes: 256
a,b,c,d,e,f = map(int,input().split())
w = []
for k in range(f//(100*a)+1):
  x = a*k
  while x <= f//100:
    w += [x]
    x += b    
s = []
for k in range(f//c+1):
  x = c*k
  while x <= f:
    s += [x]
    x += d
  
p,q = a,0    
for x in w:
  if x == 0:
    continue
  for y in s:
    if 100*x+y <= f and y/x <= e and y/x > q/p:
      p,q = x,y
print(100*p+q,q)
    

Measured memory_bytes: 12440
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <cmath>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
#define drep(i,cc,n) for(int i=cc;i>=n;--i)
typedef long long ll;
using namespace std;
int main(){
    int n;
    cin >> n;
    pair<pair<string, int>, int> p[n];
    for (int i = 0; i < n; i++) {
        string city;
        int point;
        cin >> city >> point;
        p[i].first.first = city;
        p[i].first.second = (-1) * point;
        p[i].second = i + 1;
    }
    sort(p, p + n);
    for (int i = 0; i < n; i++) {
        cout << p[i].second << endl;
    }    
}

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

#define ll long long
#define INF 99999999
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()



int main()
{
   int R;

    cin >> R;

   cout << 2 * R * 3.14 << endl; 
    
}

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

using namespace std;

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

    int A, B;
    map<int, vector<int>> adj_map;

    for (int i = 0; i < M; i++){
        cin >> A >> B;
        A--; B--;
        adj_map[A].push_back(B);
        adj_map[B].push_back(A);
    }

    for (int i = 0; i < N; i++){
        vector<int> adj_rooms = adj_map[i];
        for (auto itr = adj_rooms.begin(); itr != adj_rooms.end(); itr++){
        }
    }

    vector<int> direction(N);
    direction[0] = -1;
    for (int i = 1; i < N; i++){
        direction[i] = 0;
    }

    queue<int> que;
    que.push(0);

    while(!que.empty()){
        int curr_room = que.front();
        vector<int> adj_rooms = adj_map[curr_room];
        for (auto itr = adj_rooms.begin(); itr != adj_rooms.end(); itr++){
            int room = *itr;
            if (direction[room] == 0){
                direction[room] = curr_room + 1;
                que.push(room);
            }
        }
        que.pop();
    }

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

    return 0;
}


Measured memory_bytes: 16104
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<math.h>
#include<string>
#include <iomanip>
#include<deque>

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
const ll LINF = 1e18;
const int INF = 1e8;

using namespace std;


//マクロ定義
#define vvint(vec,n,m,l) vector<vector<int>> vec(n, vector<int>(m,l));	// lで初期化
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>
#define pint pair<int,int>
#define rep(i,a) for(int i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()
#define debug system("pause")				//デバッグ用


int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int n, m;
	cin >> n >> m;

	cout << (n - 1) * (m - 1) << endl;
	
}

Measured memory_bytes: 256
n, m = [int(_) for _ in input().split()]
student = [[int(x) for x in input().split()] for i in range(n)]
check = [[int(x) for x in input().split()] for i in range(m)]
for s in student:
  d = 10**12
  i = -1
  for ii, c in enumerate(check, 1):
    dd = abs(s[0] - c[0]) + abs(s[1] - c[1])
    if dd < d:
      d = dd
      i = ii
  print(i)

Measured memory_bytes: 3064
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var xa = ReadInts();
            if (xa[0] < xa[1])
            {
                WriteLine(0);
            }
            else if(xa[0] >= xa[1])
            {
                WriteLine(10);
            }
        }


        private static string Read() { return ReadLine(); }
        private static string[] Reads() { return (Read().Split()); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }

        //最大公約数

        public static int Gcd(int a, int b)
        {
            if (a < b)
            {
                return Gcd(b, a);
            }
            while (b != 0)
            {
                var reminder = a % b;
                a = b;
                b = reminder;
            }
            return a;
        }

        //最小公倍数
        public static int Lcm(int a, int b)
        {
            return a * b / Gcd(a, b);
        }

        //文字数を数える
        public static int CountChar(string s, char c)
        {
            return s.Length - s.Replace(c.ToString(), "").Length;
        }
        static long fibonacci(int n)
        {
            switch (n)
            {
                case 0:
                case 1:
                    return n;
                default:
                    return fibonacci(n - 2) + fibonacci(n - 1);
            }
        }
    }
}


Measured memory_bytes: 11092
/**
 *    author:  math2do
 *    created: 04.05.2020 04:33:38 IST
**/

#include <bits/stdc++.h>

using namespace std;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector <int> arr(n);
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
  } 
  map <int, int> right;
  for (int i = n - 1; i >= 0; i--) {
    int pos = i - arr[i];
    right[pos]++;
  } 
  long long ans = 0;
  for (int i = 0; i < n - 1; i++) {
    int pos = i - arr[i];
    right[pos]--;
    int at = arr[i] + i;
    auto it = right.find(at);
    if (it != right.end()) {
      ans += it->second;
    } 
  } 
  
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 12488
s=input()

def is_kaibun(s):
    for i in range(len(s)//2):
        if s[i] != s[-i-1]:
            return False
    return True

n = len(s)
n%2 == 1
ed=int((n-1)/2)
st=int((n+3)/2)

s2= s[0:ed]
s3= s[st:(-1)]


if is_kaibun(s) == False:
    print("No")
    exit()

elif is_kaibun(s)==True:
    if is_kaibun(s2)==True:
        if is_kaibun(s3)==True:
            print("Yes")
            exit()

print("No")


Measured memory_bytes: 3064
#include "bits/stdc++.h"
#define MOD 1000000007
#define INF 1234567890
#define in std::cin
#define out std::cout
#define rep(i,N) for(LL i=0;i<N;++i)
typedef long long int LL;

std::string S;

int main()
{
     in >> S;
    
     std::sort(S.begin(), S.end());
     rep(i, S.length() - 1)
     {
         if (S[i] == S[i + 1])
         {
             out << "no" << std::endl;
             return 0;
         }
     }
    
    out << "yes" << std::endl;
    return 0;
}

Measured memory_bytes: 256
#include <iomanip>
#include <iostream>
using namespace std;
int main(void) {
  int n;
  cin >> n;
  for(int i = 3; i < n + 1; i++) {
    bool flag = (i % 3 == 0);
    int m = i;
    while(m != 0) {
      if(m % 10 == 3)
        flag = true;
      m /= 10;
    }
    if(flag)
      cout << " " << i;
  }
  cout << endl;

  return 0;
}



Measured memory_bytes: 3100
#include <iostream>

using namespace std;

int main()
{
	string num;
	int sum;
	while(true) {
		sum = 0;
		cin >> num;
		if(num == "0")
			break;
		for(int i = 0; i < num.size(); ++i) {
			sum += num[i] - '0';
		}
		cout << sum << endl;
	}
}

Measured memory_bytes: 1188
x1, x2, x3, x4, x5 = map(int, input().split())

if x1 == 0:
  print('1')
else:
  if x2 == 0:
    print('2')
  else:
    if x3 == 0:
      print('3')
    else:
      if x4 == 0:
        print('4')
      else:
        if x5 == 0:
          print('5')



Measured memory_bytes: 9168
#!/usr/bin/perl
my ($n,$x) = map { $_ - 0 } split(/[\s]+/,<STDIN>);
my $res = &foo($n,$x);
print "$res\n";
exit(0);
sub n_layer {
  my $l = shift;
  return +[1,0] if $l == 0;
  my $l1 = &n_layer($l-1);
  return +[1+2*($l1->[0]),2+2*($l1->[1])];
}
sub foo {
  my $l = shift;
  my $a = shift;
  return 1 if $l==0;
  return 0 if $a == 1;
  my $nl = &n_layer($l);
  return $nl->[0] if $a >= ($nl->[0]+$nl->[1])-1;
  my $b = (($nl->[0]+$nl->[1])-1)/2;
  if( $a >= $b + 1 ){
    my $r = 1 + &foo($l-1,$b-1);
    $r += &foo($l-1,$a-($b+1)) if $a > $b + 1;
    return $r;
  }
  return &foo($l-1,$a-1);
}


Measured memory_bytes: 512
#include <cstdio>
#include <cstdint>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <array>
#include <vector>
#include <unordered_map>

int main()
{
    int K;
    std::cin >> K;

    if (K % 2 == 0) {
       std::cout << std::pow(K/2, 2) << std::endl;
    } else {
        std::cout << K/2 * (K/2 + 1) << std::endl;
    }

    return 0;
}

Measured memory_bytes: 256
# coding: utf-8

s = list(map(int, input().split(" ")))

tnb = s[0]
mc = s[1]

hk = list(map(int, input().split(" ")))
v = []
for i in range(mc) :
    tmp = list(map(int, input().split(" ")))
    x = tmp[0] - 1
    y = tmp[1] - 1
    ap = y
    if hk[x] < hk[y] :
        ap = x
        v.append(ap)
        continue
    elif hk[x] == hk[y] :
        v.append(x)
        v.append(y)
        continue
    v.append(ap)

ans = tnb - len(set(v))
print(ans)

Measured memory_bytes: 19996
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
using namespace std; using ll = long long; using pll = pair<ll, ll>;
using vl = vector<ll>; using vll = vector<vl>; using vpll = vector<pll>;
int ctoi(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2;
	case '3': return 3; case '4': return 4; case '5': return 5;
	case '6': return 6; case '7': return 7; case '8': return 8;
	case '9': return 9;  default: return 0;
	}
}
bool pairCompare(const pll firstElof, pll secondElof)
{
	return firstElof.second < secondElof.second;
}
ll nod(ll F) { return log10(F) + 1; }
//**定義場所**//
//gcd, isPrime, eratos, modinv, bitSearch, dfs, bfs, dijkstra, UnionFind//
ll i, j, k, l, m, n; ll N, M, K, H, W, L; string S;
ll MOD = 1000000007; ll ans = 0; ll INF = 9999999999999;
vl flag, color; vll path;
//***********//
int main() {
	cin >> N >> K;
	vl P(N);
	vector<double> Q(N);
	for (i = 0; i < N; i++) {
		cin >> P[i];
		Q[i] = (1 + P[i]) * P[i] / 2;
		double B = P[i];
		Q[i] = Q[i] / B;
	}
	vector<double> sum(N+1);
	sum[0] = 0;
	for (i = 1; i <= N; i++) {
		sum[i] = sum[i - 1] + Q[i-1];
	}
	double M = 0;
	for (i = 0; i < N-K+1; i++) {
		M = max(M, sum[i + K] - sum[i]);
	}
	double A = M;
	double B = N;
	cout << fixed << setprecision(12) << M;
}


Measured memory_bytes: 4992
X,N=map(int,input().split())
A=[int(x) for x in input().split()]

for i in range(10**9):
    if (X-i) in A:
        pass
    else:
        print(X-i)
        exit()
    if (X+i) in A:
        pass
    else:
        print(X+i)
        exit()


Measured memory_bytes: 9176
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int N = 2e5 + 5;
map<int,int> mp;
vector<int> adj[N];
void dfs(int root){
    mp[root] = adj[root].size();
    for(auto v : adj[root]){
        dfs(v);
    }
}
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    int n;
    cin >> n;
    for(int i = 2; i <= n; i++){
        int num;
        cin >> num;
        adj[num].push_back(i);
    }
    dfs(1);
    for(auto v : mp){
        cout << v.second << endl; 
    }
}

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

const int MAX_S = 3100;
const int MAX_T = 3100;

long long dp[MAX_S][MAX_T] = {0};//N-1番目までで入れた容量の価値を最大にするもの
const long long INF = 1LL << 60;


int main(){
    string S, T;
    cin >> S >> T;

    dp[0][0] = 0;

    for (int i = 0; i < S.size(); ++i)
    {
        for(int j = 0; j < T.size(); ++j){
            if(S[i] == T[j])
                dp[i+1][j+1] = max(dp[i+1][j+1],dp[i][j]+1);
            dp[i+1][j+1] = max(dp[i+1][j+1],dp[i+1][j]);
            dp[i+1][j+1] = max(dp[i+1][j+1],dp[i][j+1]);
        }
    }

    string res = "";
    int i=S.size(), j=T.size();

    while( i>0 && j>0){
        if(dp[i][j] == dp[i-1][j]){
            --i;
        }else if(dp[i][j] == dp[i][j-1]){
            --j;
        }else{
            res = S[i-1]+ res;
            --i,--j;
        }
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 73984
n = gets.to_i
s = gets.chomp.split("")
bw = []
i = cnt = 0
jud = s[0]
s.each do |c|
  if jud == c
    cnt += 1
  else
    bw[i] = cnt
    jud = c
    i += 1
    cnt = 1
  end
end
bw[i] = cnt

min = 999999999999
bsums = Array.new(i+2)
wsums = Array.new(i+2)
bsums[0] = 0
wsums[0] = 0
i = 1
le = 1
le = 0 if s[0] == '.'
bw.each do |k|
  if i % 2 == le
    bsums[i] = bsums[i-1] + k
    wsums[i] = wsums[i-1]
  else
    wsums[i] = wsums[i-1] + k
    bsums[i] = bsums[i-1]
  end
  i += 1
end
for j in 0..(i-1)
  ch = bsums[j] + (wsums[i-1] - wsums[j])
  min = ch if min > ch
end
puts min

Measured memory_bytes: 17604
# union by size
class DisjointSet:
    def __init__(self, size):
        self.size = [0 for i in range(size)]
        self.p = [0 for i in range(size)]
        for i in range(size):
            self.makeSet(i)
    
    def makeSet(self, x):
        self.p[x] = x
        self.size[x] = 1

    def same(self, x, y):
        return self.findSet(x) == self.findSet(y)

    def unite(self, x, y):
        self.link(self.findSet(x), self.findSet(y))

    def link(self, x, y):
        if self.size[x] > self.size[y]:
            self.p[y] = x
            self.size[x] += self.size[y]
        else:
            self.p[x] = y
            self.size[y] += self.size[x]
    
    def findSet(self, x):
        if x != self.p[x]:
            self.p[x] = self.findSet(self.p[x])
        return self.p[x]

    def getSize(self, x):
        return self.size[ds.findSet(x)]

N, M = map(int, input().split())
ds = DisjointSet(N+1)
for i in range(M):
    A, B = map(int, input().split())
    if ds.same(A, B):
        continue
    ds.unite(A, B)
print(max(ds.size))


Measured memory_bytes: 94336
#include <iostream>
#include <queue>
#include <vector>

#define N 9
#define SIZE 3

using namespace std;

class Puzzle{
private:
    vector<int> table;
    vector<int> goal;
    vector<int> checks;
    const int STATE_NUM;
    
    int Factrial(int n){
        if(n <= 1)
            return 1;
        return n * Factrial(n - 1);
    }
    
    int GetSpace(const vector<int> &v){
        for(int i = 0; i < N; i++)
            if(v[i] == 0)
                return i;
        return -1;
    }
    
    int state_number(vector<int> v){
        int n = 0;
        
        for(int i = 0; i < N - 1 ; i++){
            n += v[i] * Factrial(N - i - 1);
            for(int j = i + 1; j < N; j++){
                if(v[i] < v[j])
                    v[j]--;
            }
        }
        
        return n;
    }
    
    queue<int> next_q(vector<int> &v){
        queue<int> q;
        int space = GetSpace(v);
        
        if(space % SIZE != 2)
            q.push(space + 1);
        if(space % SIZE != 0)
            q.push(space - 1);
        if(0 <= space + SIZE && space + SIZE < N)
            q.push(space + SIZE);
        if(0 <= space - SIZE && space - SIZE < N)
            q.push(space - SIZE);
        
        return q;
    }
    
    int search(int step, vector<vector<int> > &state){
        std::queue<int> q;
        int target;
        int state_num;
        int q_num = 0;
        vector<vector<int> > new_state;
        
        if(step == 1 && state[0] == goal)
            return 0;
        
        for(vector<vector<int> >::size_type i = 0; i < state.size(); i++){
            state_num = state_number(state[i]);
            
            if(checks[state_num] == 0){
                checks[state_num] = 1;
                q = next_q(state[i]);
                
                new_state.resize(q.size() + q_num);
                while(!q.empty()){
                    new_state[q_num] = state[i];
                    target = q.front();
                    q.pop();
                    
                    swap(new_state[q_num][target], new_state[q_num][GetSpace(new_state[q_num])]);
                    if(new_state[q_num] == goal)
                        return step;
                    
                    q_num++;
                }
            }
        }
        
        return search(step + 1, new_state);
    }
    
public:
    Puzzle() : STATE_NUM(Factrial(N)), table(N){
        checks.resize(STATE_NUM);
        
        for(int i = 0; i < N; i++){
            cin >> table[i];
            goal.push_back(i == N - 1 ? 0 : i + 1);
        }
    }
    
    int GetMinStep(){
        vector<vector<int> > state(1);
        state[0] = table;
        return search(1, state);
    }
};

int main(){
    Puzzle pz;
    cout << pz.GetMinStep() << endl;
    return 0;
}



Measured memory_bytes: 39244
#a,bの最大公約数
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

#a,bの最小公倍数
def lcm(a, b):
    return a * b // gcd (a, b)
  
a,b = map(int,input().split())
print(lcm(a, b))

Measured memory_bytes: 2940
while True:
    sta = input()
    if len(sta) == 3:
        break

judge = ""
count = 0
result = ""
station = [sta[0], sta[1], sta[2]]
for ss in station:
    if count == 0:
        judge = ss
    else:
        if ss == judge:
            result = "No"
        else:
            result = "Yes"
            break
            
    count = 1
print(result)




Measured memory_bytes: 3060
import math
import copy
from operator import mul
from functools import reduce
from collections import defaultdict
from collections import Counter
from collections import deque
# 直積 A={a, b, c}, B={d, e}:のとき，A×B={(a,d),(a,e),(b,d),(b,e),(c,d),(c,e)}: product(A, B)
from itertools import product
# 階乗 P!: permutations(seq), 順列 {}_len(seq) P_n: permutations(seq, n)
from itertools import permutations
# 組み合わせ {}_len(seq) C_n: combinations(seq, n)
from itertools import combinations
# 一次元累積和
from itertools import accumulate
from bisect import bisect_left, bisect_right

# import numpy as np
# from scipy.misc import perm
# from scipy.misc import comb

def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W

# 四方向: 右, 下, 左, 上
dy = [0, -1, 0, 1]
dx = [1, 0, -1, 0]
 
def i_inpl(): return int(input())
def l_inpl(): return list(map(int, input().split()))
def line_inpl(x): return [i_inpl() for _ in range(x)]

INF = int(1e18)
MOD = int(1e9)+7 # 10^9 + 7

########

# N, A, B = l_inpl()

# print(min(N*A, B))
N, D = l_inpl()
X = []

for _ in range(N):
    Xi = l_inpl()
    X.append(Xi)

ans = 0
for yi, zi in combinations(list(range(N)), 2):
    tmp = 0
    for y, z in zip(X[yi], X[zi]):
        tmp += (abs(y - z)) ** 2
    
    if (tmp**(1/2)).is_integer():
        ans += 1

print(ans)


Measured memory_bytes: 3824
input_lines=raw_input()
length=len(input_lines)
result = True

for i in xrange(length):
    for j in range(i+1,length):
        if input_lines[i]==input_lines[j]:
            result = False
            break
    if result == False:
        break


if result:
    print "yes"
else:
    print "no"

Measured memory_bytes: 2568
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[][][] g = buildWeightedGraph(n, sc);
        ArrayDeque<Integer> ad = new ArrayDeque<>();
        ad.add(0);
        int[] ans = new int[n];
        boolean[] used = new boolean[n];
        used[0] = true;
        while(!ad.isEmpty()){
            int x = ad.poll();
            int[][] next = g[x];
            for(int[] nv : next){
                if(used[nv[0]]) continue;
                used[nv[0]] = true;
                ans[nv[0]] = nv[1] % 2 == 0 ? ans[x] : Math.abs(ans[x] - 1);
                ad.add(nv[0]);
            }
        }
        for (int i = 0; i < n; i++) System.out.println(ans[i]);
        sc.close();

    }

    public static int[][][] buildWeightedGraph(int n, Scanner sc){
        int m = n-1;
        int[][][] graph = new int[n][][];
        int[][] edges = new int[n-1][3];
        int[] deg = new int[n];
        for (int i = 0; i < m; i++) {
            edges[i][0] = sc.nextInt()-1;
            edges[i][1] = sc.nextInt()-1;
            edges[i][2] = sc.nextInt();
            deg[ edges[i][0] ]++;
            deg[ edges[i][1] ]++;
        }
        for (int i = 0; i < n; i++) {
            graph[i] = new int[deg[i]][2];
        }
        for (int i = 0; i < m; i++) {
            int a = edges[i][0];
            int b = edges[i][1];
            int c = edges[i][2];
            graph[a][--deg[a]][0] = b;
            graph[a][deg[a]][1] = c;
            graph[b][--deg[b]][0] = a;
            graph[b][deg[b]][1] = c;
        }

        return graph;
    }

}


Measured memory_bytes: 107596
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define int ll
#define fr(i,a,b) for(int i=a;i<b;i++)
#define frr(i,a,b) for(int i=b-1;i>=a;i--)
#define mod 1000000007
#define pb push_back
#define son ll t; cin>>t;while(t--)
#define fst ios_base::sync_with_stdio(false); cin.tie(NULL);
#define yes cout<<"YES"<<endl
#define no cout<<"NO"<<endl
#define mpr make_pair
#define ff first
#define ss second
#define inf 5e18
#define dex(x,y) fixed<<setprecision(x)<<y
void start()
{
    #ifndef ONLINE_JUDGE 
    freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
    #endif
}

int32_t main()
{
    fst
//    start();
   int n,c=0;
  cin>>n;
  int a[n];
  fr(i,0,n)
  {
     cin>>a[i];if(i%2==0&&a[i]%2==1)c++;}
  cout<<c;
     }

Measured memory_bytes: 3648
#include<stdio.h>
#include<stdlib.h>
#define FOR(n) for(int i=0;i<n;i++)
#define FORJ(n) for(int j=0;j<n;j++)
#define PRN(n) printf("%d\n",n)
#define PRS(s) printf("%s\n",s)
int compare(const void *a, const void *b){
    return *(int*)a - *(int*)b;
}
int main(void){
  int a,b,n;
  scanf("%d %d %d",&a,&b,&n);
  if(a<b){
    PRN(((n-1)/1000+1)*a);
  }else{
    int ans=0;
    if(n%1000<=500&&n%1000>0){
      n-=500;
      ans=b;
      //PRS("a");
    }
    n--;
    if(n>0){
      if(a<2*b){
        ans+=(n/1000+1)*a;
        //PRS("b");
      }else{
        ans+=(n/500+1)*b;
        //PRS("c");
      }
    }
    PRN(ans);
  }
  return 0;
}


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

#define int long long
#define ll long long
#define pb push_back
#define mp make_pair
#define f(i,a,n) for(int i=a ; i<n ; i++)
#define rf(i,n,a) for(int i=n ; i>=a ; i--)
#define F first
#define S second
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)

typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef vector<pii> vpi;

const int inf = 1e9;
const int inf64 = 1e18;
const int MOD = 998244353;
int dp[3005][3005];

int32_t main(){
   fast;
   int n , s;
   cin >> n >> s;
   int a[n+1];
   f(i,1,n+1)  cin >> a[i];

   dp[0][0] = 1;
   for(int i=1 ; i<=n ; i++){
      for(int j=0 ; j<=s ; j++){
         dp[i][j] = (2 * dp[i-1][j]) % MOD;
         if(j - a[i] >= 0){
            dp[i][j] += dp[i-1][j-a[i]];
            dp[i][j] %= MOD;
         }
      }
   }

   cout << dp[n][s];
}

Measured memory_bytes: 74036
#ifndef call_from_test
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
#endif
//BEGIN CUT HERE
template<typename T>
T extgcd(T a,T b,T& x,T& y){
  T d=a;
  if(b!=0){
    d=extgcd(b,a%b,y,x);
    y-=(a/b)*x;
  }else{
    x=1;y=0;
  }
  return d;
}
template<typename T>
T mod_inverse(T a,T mod){
  T x,y;
  extgcd(a,mod,x,y);
  return (x%mod+mod)%mod;
}
//END CUT HERE
#ifndef call_from_test
//INSERT ABOVE HERE

//extgcd
signed AOJ_NTL1E(){
  int a,b;
  cin>>a>>b;
  int x,y;
  extgcd(a,b,x,y);
  cout<<x<<" "<<y<<endl;
  return 0;
}
/*
  verified on 2019/05/26
  http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=NTL_1_E&lang=jp
*/

signed main(){
  AOJ_NTL1E();
  return 0;
}
#endif



Measured memory_bytes: 3084
#include <bits/stdc++.h>
#define mod 1000000007
#define ll long long int
#define pb(x) push_back(x)
#define MP(x,y) make_pair(x,y)
using namespace std;
ll power(ll a,ll b,ll m)
{
    if(b==0)
        return(1);
    ll sol=power(a,b/2,m);
    sol=(sol*sol)%m;
    if(b%2==1)
        sol=(sol*a)%m;
    return(sol);
}
ll gcd(ll a,ll b)
{
	if(a%b==0)
		return b;
	else
		return gcd(b,a%b);
}
vector< pair<int ,int> >v;
int a[200005];
void solve()
{
    int n;
    cin>>n;
    for(int i=0;i<n;i++)
        {
            int x;
            cin>>x;
            v.push_back(MP(x,i));
        }
    sort(v.begin(),v.end());
    for(int i=0;i<n;i++)
    {
        if(i<n/2)
        {
            a[v[i].second]=v[n/2].first;
        }
        else
            a[v[i].second]=v[n/2-1].first;
    }
    for(int i=0;i<n;i++)
        cout<<a[i]<<" ";
}
int main()
{
    int t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
	return 0;
}


Measured memory_bytes: 4720
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <iomanip>
#include <cstdio>
#include <set>
#include <map>
#include <list>
#include <cstdlib>

using namespace std;

#define mod (1e9 + 7)
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(x) x.begin(), x.end()

typedef long long ll;

void solve1()
{
    int n;
    cin >> n;
    int ans = -1;
    for (int i = 1; i <= 50000; i++)
    {
        if (floor(i * 1.08) == n)
        {
            ans = i;
            break;
        }
    }

    if(ans == -1) {
        cout << ":(" << endl;
    } else {
        cout << ans << endl;
    }
}

int main()
{
    solve1();
}


Measured memory_bytes: 3632
#define _CRT_SECURE_NO_WARNINGS
#include<cstdio>
#include<algorithm>
#define rep(i,a) for(int i=0;i<(a);++i)

int n, k;
int a[100001], sum[100001];

int main(){
	while (scanf("%d%d", &n, &k), n|k){
		rep(i, 100001)sum[i] = 0;
		scanf("%d", &a[0]);
		for (int i = 1; i < n; ++i){
			scanf("%d", &a[i]);
			sum[i] = sum[i - 1] + a[i];
		}
		int ans = 0;
		for (int i = 0; i < n - k; ++i){
			ans = std::max(ans, sum[i + k] - sum[i]);
		}
		printf("%d\n", ans);
	}
	return 0;
}

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


int main() {
    long long k;
    int n;
    cin>>k>>n;
    long long int ar[n],b[n];
    long long int maxi=INT_MIN;
    for(int i=0;i<n;i++)
    {
        cin>>ar[i];
    }
    for(int i=0;i<n-1;i++)
    {
        b[i]=ar[i+1]-ar[i];
        maxi=max(maxi,b[i]);
    }
    maxi=max(maxi,k-ar[n-1]+ar[0]);
    
    cout<<k-maxi;

return 0;
        
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = int(A); I < int(B); ++I)
#define FORR(I,A,B) for(ll I = int((B)-1); I >= int(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=1e18+7;
const ll MOD=1e9+7;



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

	string s,m;
	cin >> s;
	m = s;
	REV(m);
	FOR(i,0,m.size()){
		if(m[i]=='p')m[i]='q';
		else if(m[i]=='q')m[i]='p';
		else if(m[i]=='b')m[i]='d';
		else if(m[i]=='d')m[i]='b';
	}
	if(s==m){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
}

Measured memory_bytes: 512
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int n = 0;
        for (int i = 0; i < s.length(); i++) {
            n += s.charAt(i) - '0';
        }
        System.out.println(Integer.parseInt(s) % n == 0 ? "Yes" : "No");
    }
}

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

using namespace std;

#define int long long

int H, W;
int A[33][33];

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

using Tapris = tuple<int, int, int, int>;

int mincost[1001][33][33];

signed main() {
  scanf("%lld %lld", &H, &W);
  for(int i = 0; i < H; ++i) {
    for(int j = 0; j < W; ++j) {
      scanf("%lld", &A[i][j]);
    }
  }

  auto in = [&](int i, int j) {
    return 0<=i&&i<H&&0<=j&&j<W;
  };

  priority_queue<Tapris, vector<Tapris>, greater<Tapris> > que;
  fill((int*)mincost[0], (int*)mincost[1001], 1LL<<55);
  que.emplace(0, 0, 0, 0);
  mincost[0][0][0] = 0;
  while(!que.empty()) {
    int cost, dist, y, x;
    tie(cost, dist, y, x) = que.top(); que.pop();
    if(y == H-1 && x == W-1) {
      printf("%lld\n", cost);
      return 0;
      break;
    }
    if(mincost[dist][y][x] < cost) continue;
    for(int i = 0; i < 4; ++i) {
      int ny = y+dy[i], nx = x+dx[i];
      if(!in(ny, nx)) continue;
      int nd = dist+1;
      int nc = cost+(2*dist+1)*A[ny][nx];
      if(nd <= 1000 && nc < mincost[nd][ny][nx]) {
	que.emplace(nc, nd, ny, nx);
	mincost[nd][ny][nx] = nc;
      }
    }
  }
  assert(false);
  int ans = 1LL<<55;
  for(int i = 0; i < 1001; ++i) ans = min(ans, mincost[i][H-1][W-1]);
  printf("%lld\n", ans);

  return 0;
}



Measured memory_bytes: 19716
h, w = gets.split.map(&:to_i)
s = h.times.map { "." + gets.chomp + "." }
s.unshift("." * (w+2))
s.push("." * (w+2))
ans = "Yes"
for i in 1..h do
  for j in 1..w do
    if s[i][j] == "#"
      if s[i-1][j] != "#" && s[i+1][j] != "#" &&
         s[i][j-1] != "#" && s[i][j+1] != "#"
        ans = "No"
        break
      end
    end
  end
  break if ans == "No"
end
puts ans


Measured memory_bytes: 2044
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define int long long
#define double long double
#define mod 1000000007
#define F first
#define S second
#define P pair<long long,long long>
#define all(a) a.begin(),a.end()
#define INF 1000000000000000000
using namespace std;

signed main(){
    int n,q; string s; cin>>n>>q>>s;
    vector<int> l(q),r(q);
    rep(i,q) cin>>l.at(i)>>r.at(i);
    
    vector<int> AC(1,-INF);
    rep(i,n-1){
        if(s.at(i)=='A' and s.at(i+1)=='C') AC.push_back(i);
    }
    AC.push_back(INF);
    
    rep(i,q){
        int a=l.at(i)-1,b=r.at(i)-2;
        cout<<upper_bound(all(AC),b)-lower_bound(all(AC),a)<<endl;
    }
}

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

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		
		Integer[] l = new Integer[n];
		
		Arrays.setAll(l, i -> sc.nextInt());
		Arrays.sort(l, (a, b) -> b - a);
		
		int ans = 0;
		for (int i = 0; i < k; i++) {
			ans += (int) l[i];
		}
		
		System.out.println(ans);

		sc.close();
	}

}


Measured memory_bytes: 27988
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
	int n;
	while(cin>>n){
		if(n==0)
			break;
		int a[n];
		for(int i=0; i<n; i++)
			cin>>a[i];
		int maximum=-100000;
		for(int i=0; i<n; i++){
			int sum=0;
			for(int j=i; j<n; j++){
				sum+=a[j];
				maximum=max(maximum, sum);
			}
		}
		cout<<maximum<<endl;
	}
	return 0;
}


Measured memory_bytes: 3012
N, M = map(int, input().strip().split(" "))

road = [[0]*N for i in range(N)]

for _ in range(M):
    a, b = map(int, input().strip().split(" "))
    road[a-1][b-1] += 1
    road[b-1][a-1] += 1

for i in range(N):
    print(sum(road[i]))


Measured memory_bytes: 9060
#include <iostream>
#include <vector>
#include<list>
#include <algorithm>
#include <string>
#include <math.h>
#include<map>
#include <utility>
#include <cstring>
#include <iomanip>
#include<queue>
#include<set>
#include<stack>

using namespace std;
#define REP(i,k,n) for(int i=k;i<n;i++)
 
#define INF 1000000000
typedef long long  ll;

#define MOD 1000000007



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

	if(S=="Sunny"){
		cout<<"Cloudy"<<endl;
	}else if(S=="Cloudy"){
		cout<<"Rainy"<<endl;
	}else{
		cout<<"Sunny"<<endl;
	}
	return 0;
	
}

Measured memory_bytes: 256
//
// Created on 2020/02/22.
//

//#include <bits/stdc++.h>
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <ios>
#include <iomanip>
#include <numeric>

#define all(x) (x).begin(),(x).end()
typedef long long ll;
using namespace std;
const long long LINF =1e18;
const int INF = 1e9;
using gragh = vector<vector<int>>;

int main() {
    int ans = INF;
    int n;
    cin>>n;
    vector<int>x(n);
    for (int i = 0; i < n; ++i) {
        cin>>x[i];
    }
    for (int j = 0; j <= 100 ; ++j) {
        int temp = 0;
        for (int i = 0; i < n; ++i) {
            temp += pow(x[i]-j,2);
        }
        ans = min(ans,temp);
    }

    cout<<ans<<endl;
}


Measured memory_bytes: 256
a, b = map(int, input().split())
s = input()
s_a = s[0:a]
s_b = s[(a+1):(a+2)+b]
minus = s[a]
if minus == "-" and s_a.isdecimal() and s_b.isdecimal():
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
n   = gets.to_i
ary = gets.split.map(&:to_i)

n.times do |i|
  ary[i] = [ary[i], i]
end

ary.sort!

n.times do |i|
  ary[i] << ary[n / 2 - i / (n / 2)][0]
end

ary.sort_by{|a| a[1]}.each do |x|
  puts x[2]
end


Measured memory_bytes: 33432
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  cin >> n;
  double sum_j=0, sum_b=0;
  double x;
  string u;
  for(int i=0;i<n;i++){
    cin >>x >>u ;
    if (u=="BTC"){
      sum_b += x;
    }else{
      sum_j += x;
    }
  }
  cout << sum_j+sum_b*380000 <<endl;
}

Measured memory_bytes: 256
// atcoder/abc125/A/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { each (i, v) is >> i; return is; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  int a, b, t;
  while (cin >> a >> b >> t) {
    cout << (t / a) * b << endl;
  }

  return 0;
}


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

using namespace std;

int main (void)
{
	string T,H;
	int n,tt = 0,hh = 0;
	cin >> n;


	for (int a = 0; a < n; a++)
	{
		cin >> T >> H;

		if (T == H)
		{
			tt += 1;
			hh += 1;
		}

		else if (T > H)
		{
			tt += 3;
		}
		else if (T < H)
		{
			hh += 3;
		}
	}

	cout << tt << " " << hh << endl;
}

Measured memory_bytes: 3208
#import<iostream>

using namespace std;

int main(){
	int n, m;
	char a, b;
	while(cin>>n, n){
		int d[256] = {};
		for(int i=0;i<n;i++){
			cin >> a >> b;
			d[a] = b-a;
		}
		for(cin>>n;n--;printf("%c", a+d[a]))
			cin>>a;
		puts("");
	}
}

Measured memory_bytes: 840
#include <bits/stdc++.h>
#define f first
#define s second
using namespace std;
typedef pair<int,int> P;
map <string,int> M;
vector <P> e[301];
int C[301],used[301];

bool check(int ima,int cost){
  int size=e[ima].size();
  if(used[ima])return (cost-C[ima])==0;
  used[ima]=1,C[ima]=cost;
  for(int i=0;i<size;i++)
    if(!check(e[ima][i].f,cost+e[ima][i].s))return 0;
  return 1;
}

int main(){
  int n;
  while(cin>>n,n){;
    for(int i=0;i<300;i++)e[i].clear();
    M.clear();

    int N=0;
    for(int i=0;i<n;i++){
      string a,b,c,d,E;
      cin>>a>>b>>c>>d>>E;
      if(!M.count(b))M[b]=N++;
      if(!M.count(E))M[E]=N++;
      int num=0,j=3,flg=1;
      if(d[3]=='-')flg=-1,j=4;
      while(j<d.size())num=num*10+d[j++]-'0';
      e[M[b]].push_back(P(M[E],num*flg));
      e[M[E]].push_back(P(M[b],-num*flg));
    }

    int ans=1;
    for(int i=0;i<N;i++){
      memset(used,0,sizeof(used));
      memset(C,0,sizeof(C));
      ans*=check(i,0);
    }
    cout <<(ans? "Yes":"No")<<endl;
  }
  return 0;
}

Measured memory_bytes: 1252
n,k=map(int,input().split())
d=set(list(map(str,input().split())))

for i in range(n,10*n):
    flag=0
    sn=str(i)
    for j in sn:
        if j in d:
            flag=1
    if flag==0:
        print(i)
        exit()









Measured memory_bytes: 41068
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
#pragma warning(disable : 4996)
using namespace std;
int N, M, Q, a, b, c[100009], dp[13][100009]; vector<int> g[100009];
int main() {
	scanf("%d %d", &N, &M);
	for (int i = 0; i < M; i++) {
		scanf("%d %d", &a, &b); a--, b--;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	scanf("%d", &Q);
	for (int i = 0; i < Q; i++) {
		scanf("%d %d %d", &a, &b, &c[i]); a--;
		dp[b][a] = i + 1;
	}
	for (int i = 9; i >= 0; i--) {
		for (int j = 0; j < N; j++) {
			dp[i][j] = max(dp[i][j], dp[i + 1][j]);
			for (int k : g[j]) dp[i][j] = max(dp[i][j], dp[i + 1][k]);
		}
	}
	for (int i = 0; i < N; i++) {
		if (dp[0][i] == 0) cout << 0 << endl;
		else cout << c[dp[0][i] - 1] << endl;
	}
	return 0;
}

Measured memory_bytes: 12160