akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <set>
#include <vector>
#include <algorithm>
#include <bitset>
#define ll long long
using namespace std;


int main(){
    ll N;cin>>N;
    vector <int> a(0);
    ll max = 0;
    for(int i=0;i<N;i++){
        int aaa;cin>>aaa;
        a.push_back(aaa);
        max += aaa-1;
    }

    //int dp[100000] = {0}; 

    //ll max = 0;
/*
    for(ll i=0;i<10000000000;i++){

        ll sum=0;

        for(int j=0;j<N;j++){

            dp[j]++;

            if(dp[j]==a[j]) dp[j] = 0;

            sum += dp[j];

        }

        max = max> sum ? max:sum;
    }*/

 
    cout<<max<<endl;
    
 


    return 0;
}

 



Measured memory_bytes: 256
s = list(input())
t = []
ls = len(s)
for i in range(ls):
    if s[i] == "A":
        t.append("A")
    elif s[i] == "B":
        if not i == ls - 1:
            if s[i + 1] == "C":
                t.append("D")
            else:
                t.append("B")
    else:
        if not i == 0:
            if not s[i - 1] == "B":
                t.append("C")
t = "".join(t).split("B")
for u in range(len(t)):
    t[u] = t[u].split("C")
ans = 0
for u in t:
    for v in u:
        dcnt = 0
        v = list(v)
        for i in range(len(v)):
            if v[i] == "D":
                ans += (i - dcnt)
                dcnt += 1
print(ans)

Measured memory_bytes: 40708
#include<iostream>
#include<bits/stdc++.h>
#include<iomanip>
#include<math.h>
#include<vector>
#include<cctype>
#include<string>
#include<set>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
std::string line;
typedef long long ll;

int main(){

   string n;
   cin >> n;

   if(n[0]=='9' || n[1]=='9') cout << "Yes" << endl;
   else cout << "No" << endl;


   return 0;
}

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

using namespace std;

int a[31];

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

    for (int i = 1; i <= w; ++i) a[i] = i;

    while (n--) {
        int b, c; scanf("%d,%d", &b, &c);
        swap(a[b], a[c]);
    }

    for (int i = 1; i <= w; ++i) cout << a[i] << endl;
}

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

using namespace std;


int main(void){

  string S, T;
  cin >> S >> T;
  int S_num, T_num;
  cin >> S_num >> T_num;

  string gabege; cin >> gabege;
  if(gabege == S){
    S_num--;
  }else if(gabege == T){
    T_num--;
  }


  cout << S_num << " " << T_num << endl;

  return 0;
}

Measured memory_bytes: 888
n, m = [int(v) for v in input().split()]
from_one = []
to_n = {}
for i in range(m):
    a, b = [int(v) for v in input().split()]
    if a == 1:
        from_one.append(b)
    elif b == n:
        to_n[a] = True

ans = 'IMPOSSIBLE'
for v in from_one:
    if v in to_n:
        ans = 'POSSIBLE'

print(ans)

Measured memory_bytes: 18416
#include<stdio.h>
int main()
{
int a,b,c;
scanf("%d%d%d",&a,&b,&c);
if(a==5&&b==7&&c==5)
	printf("YES");
	else if(a==5&&b==5&c==7)
		printf("YES");
		else if(a==7&&b==5&&c==5)
			printf("YES");
		else
			printf("NO");
return 0;	
}

Measured memory_bytes: 128
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
import java.util.Arrays;
import java.util.Objects;

public class Main{
    public static void main(String[] args){
        FastScanner sc = new FastScanner();

        int[][][] people_num = new int[4][3][10];

        int n = sc.nextInt();
        for(int i=0;i<n;i++){
            int b = sc.nextInt();
            int f = sc.nextInt();
            int r = sc.nextInt();
            int v = sc.nextInt();

            people_num[b-1][f-1][r-1] += v;
        }

        for(int i=0;i<4;i++){
            for(int j=0;j<3;j++){
                for(int k=0;k<10;k++){
                    System.out.print(" "+people_num[i][j][k]);
                }
                System.out.println();
            }
            if(i!=3){
                for(int j=0;j<20;j++)System.out.print("#");
                System.out.println();
            }
        }
    }

    public static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner(String s) {
            try {
                br = new BufferedReader(new FileReader(s));
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            }
        }

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

        String nextToken() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(nextToken());
        }

        long nextLong() {
            return Long.parseLong(nextToken());
        }

        double nextDouble() {
            return Double.parseDouble(nextToken());
        }
    }
}



Measured memory_bytes: 24668
#include <iostream>
#include <vector>
#include <stdio.h>
#include <numeric>
#include <cmath>
#include <string>
#include <set>

using namespace std;
void printSet(set<string> &s){
    cout << "size = " << s.size() << endl;
    for(set<string>::iterator it = s.begin();
        it != s.end();
        ++it){
        cout << *it << ", ";
    }
    cout << endl << endl;
}

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

    vector<string> vec(n);

    for(i=0;i<n;i++){
        cin >> vec.at(i);
    }
    
    /*
    cout << "\n配列出力："<< endl;
    for (vector<string>::iterator i=vec.begin(); i!=vec.end(); ++i ) {
        cout << *i << endl;
    }
    */

    set<string> s2(vec.begin(), vec.end());
    cout << s2.size() << endl;


    return 0;
}

Measured memory_bytes: 24960
#[allow(unused_imports)]
use std::{cmp::Reverse, collections::*};

#[allow(unused_imports)]
use proconio::{
    fastout, input,
    marker::{Chars, Usize1},
};

#[allow(unused_imports)]
use itertools::Itertools;

#[allow(unused_imports)]
use num::Integer;

#[fastout]
pub fn main() {
    input! {
        mut a: i64, mut b: i64, mut c: i64,
    }

    if a % 2 != 0 || b % 2 != 0 || c % 2 != 0 {
        println!("0");
        return;
    }

    let mut count = 0;
    while !(a == b && b == c) {
        count += 1;
        let na = a / 2;
        let nb = b / 2;
        let nc = c / 2;
        a = nb + nc;
        b = nc + na;
        c = na + nb;
        if a % 2 != 0 || b % 2 != 0 || c % 2 != 0 {
            println!("{}", count);
            return;
        }
    }
    println!("-1");
}


Measured memory_bytes: 2112
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <bitset>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <queue>

#define mp make_pair
#define pb push_back


typedef long long ll;
typedef long double ld;

using namespace std;

ll n, s;

int main() {
	cin >> n >> s;
	if (n == s) {
		cout << n + 1 << "\n";
		return 0;
	}
	if (s > n) {
		cout << -1 << "\n";
		return 0;
	}
	for (int i = 2; i < 1000000; ++i) {
		ll sum = 0;
		ll tmp = n;
		while (tmp)
			sum += tmp % i, tmp /= i;
		if (sum == s) {
			cout << i << "\n";
			return 0;
		}
	}
	ll mn = n + 1;
	for (ll x = 1; x < 1000000; ++x) {
		ll y = s - x;
		if (y < 0)
			break;
		ll tmp = n - y;
		if (tmp % x != 0)
			continue;
		tmp /= x;
		if (x >= tmp || y >= tmp)
			continue;
		mn = min(mn, tmp);
	}
	if (mn == n + 1)
		cout << -1 << "\n";
	else
		cout << mn << "\n";
	return 0;
}




Measured memory_bytes: 256
#include<stdio.h>

int n, A[50];

int solve(int i, int m) {
  if ( m == 0 ) return 1;
  if ( i >= n ) return 0;
  int res = solve(i + 1, m) || solve(i + 1, m - A[i]);
  return res;
}

int main() {
  int q, M, i;

  scanf("%d", &n);
  for ( i = 0; i < n; i++ ) scanf("%d", &A[i]);
  scanf("%d", &q);
  for ( i = 0; i < q; i++ ) {
    scanf("%d", &M);
    if ( solve(0, M) ) printf("yes\n");
    else printf("no\n");
  }

  return 0;
}


Measured memory_bytes: 2056
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define RFOR(i,l,r) for(long long i=(l);i>=(r);--i)
#define RREP(i,n) RFOR(i,n-1,0)
#define RREPS(i,n) RFOR(i,n,1)
#define int long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define SZ(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V<V<T>>;
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; }
inline void Yes(bool b = true) {cout << (b ? "Yes" : "No") << '\n';}
inline void YES(bool b = true) {cout << (b ? "YES" : "NO") << '\n';}
inline void err(){cout << -1 << '\n';}
const int INF = 1e18;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n, a, b; cin >> n >> a >> b;
    int x[n];
    REP(i,n) cin >> x[i];
    int cost = 0;
    REP(i,n-1) cost += min((x[i+1]-x[i])*a,b);
    cout << cost << '\n';
}

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

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


	while (1)
	{
		C -= B;

		if (C <= 0)
		{
			cout << "Yes" << endl;
			break;
		}
	
		A -= D;

		if(A <= 0)
		{
			cout << "No" << endl;
			break;
		}
	}
}

Measured memory_bytes: 3640
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <iomanip>
#include <queue>
#include <map>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
#define INF 1e10
typedef long long ll;
typedef long double ld;
int main(){
    ll n;
    cin>>n;
    map<string, ll> m;
    ll max=1;
    REP(i,n){
        string name;
        cin>>name;
        if(m.find(name)!=m.end()){
            m[name]++;
            if(max<m[name])max=m[name];
        }else{
            m.insert(make_pair(name,1));
        }
    }
    for(auto itr=m.begin(); itr!=m.end(); itr++){
        if(itr->second == max){
            cout<<itr->first<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 19128
#include <stdio.h>

int main(){
	double xa1,ya1,xa2,ya2,xb1,yb1,xb2,yb2;
	while(scanf("%lf %lf %lf %lf %lf %lf %lf %lf",&xa1,&ya1,&xa2,&ya2,&xb1,&yb1,&xb2,&yb2)!=EOF){
		if((((xb1<=xa1)&&(xa1<=xb2))||((xb1<=xa2)&&(xa2<=xb2))||((xa1<=xb1)&&(xb1<=xa2))||((xa1<=xb2)&&(xb2<=xa2)))&&(((yb1<=ya1)&&(ya1<=yb2))||((yb1<=ya2)&&(ya2<=yb2))||((ya1<=yb1)&&(yb1<=ya2))||((ya1<=yb2)&&(yb2<=ya2)))){
			printf("YES\n");
		}else{
			printf("NO\n");
		}
	}
	return 0;
}

Measured memory_bytes: 612
#include<bits/stdc++.h>
using namespace std;
const int N = 5e3 + 5;
int f[N], n;
char str[N];
#define bug(x) cout << #x << '=' << x << " "
#define debug(x) cout << #x << "=" << x << endl
void build(int x){// x - n
	f[x] = x - 1;
	for(int j = x + 1, i = x - 1; j <= n; ++j){
		for(;i != x - 1 && str[i + 1] != str[j];)i = f[i];
		if(str[i + 1] == str[j]) ++i;
		f[j] = i;
	}
}
int main(){
	cin >> n;
	scanf("%s", str + 1);
	int ans = 0;
	for(int i = 2; i <= n; ++i){
		build(i);
		int w = i - 1;
		for(int j = 1; j < i; ++j){// i - w : len = w - i + 1
			for(;w != i - 1 && str[j] != str[w + 1];)w = f[w];
			if(str[w + 1] == str[j]) ++w;
			if(str[w] == str[j])ans = max(ans, w - i + 1);
			if(w == n) break;
		}
	}
	cout << ans << endl;
	return 0;
}

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

int main() {
  string s,t,u;
  int a,b;
  cin >> s >> t >> a >> b >> u;
  if(u==s){
    cout << a-1 << " " << b << endl;
  }
  else{
    cout << a << " " << b-1 << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;

class union_find {
private:
    vector<ll> par;
    vector<ll> ran;
    vector<ll> m_size;
public:
    union_find(ll n);
    ll find(ll x);
    void unite(ll x, ll y);
    bool same(ll x, ll y);
    ll size(ll x);
};

union_find::union_find(ll n){
    par.resize(n);
    ran.resize(n, 0);
    m_size.resize(n, 1);
    REP(i,n) par[i] = i;
};

ll union_find::find(ll x) {
    if (par[x] == x) return x;
    else return par[x] = find(par[x]);
};

void union_find::unite(ll x, ll y) {
    x = find(x);
    y = find(y);
    if (x == y) return;
    ll t = size(x)+size(y);
    m_size[x] = m_size[y] = t;
    if (ran[x] < ran[y]) {
        par[x] = y;
        //size[y] += size[x];
    } else {
        par[y] = x;
        //ize[x] += size[y];
        if (ran[x]==ran[y]) ran[x]++;
    }
};

ll union_find::size(ll x) {
    if (par[x] == x) return m_size[x];
    return size(par[x] = find(par[x]));
}

bool union_find::same(ll x, ll y) {
    return (find(x) == find(y));
};

int main(int argc, char const *argv[]) {
    int n, m;
    cin >> n >> m;
    vector<int> p(n);
    vector<int> q(n);
    union_find uf(n);
    REP(i,n) {
        cin >> p[i];
        --p[i];
        q[p[i]] = i;
    }
    REP(i,m) {
        int x,y;
        cin >> x >> y;
        --x,--y;
        uf.unite(x, y);
    }
    int ans = 0;
    REP(i,n) {
        if (uf.same(q[i], i)) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3328
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
using namespace std;

int main(void)
{
    int n, m; cin >> n >> m;
    vector<int> h(n);
    for (int i = 0; i < n; i++) cin >> h[i];
    vector<vector<int>> g(n, vector<int>(0));
    int a, b;
    for (int i = 0; i < m; i++)
    {
        cin >> a >> b;
        g[a-1].push_back(b-1);
        g[b-1].push_back(a-1);
    }
    vector<bool> tr(n, true);
    int ans = 0;
    for (int i = 0; i < n; i++)
    {
        if (tr[i])
        {
            bool flag = true;
            tr[i] = false;
            for (int t:g[i])
            {
                if (h[i] > h[t]) tr[t] = false;
                else
                {
                    flag = false; break;
                }
            }
            if (flag) ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 8812
// ABC_059_A
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

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

int main()
{
	string a, b, c;
	cin >> a >> b >> c;

	cout << (char)toupper(a[0]) << (char)toupper(b[0]) << (char)toupper(c[0]) << "\n";

	return 0;
}

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

using namespace std;

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

    long long a,b,c,k;
    cin >> a >> b >> c >> k;

    int ma = 0;
    while(k){
        if(a){
            if(k > a){
                ma += a;
                k -= a;
                a = 0;
            }
            else{
                ma += k;
                a = 0;
                k = 0;
            }
            continue;
        }
        else if(b){
            if(k > b){
                k -= b;
                b = 0;
            }
            else{
                b = 0;
                k = 0;
            }
            continue;
        }
        else if(c){
            ma -= k;
            k -= c;
            c = 0;
            // cout << ma << endl;
            break;
        }
    }
    cout << ma << endl;
    
}

Measured memory_bytes: 3652
from itertools import combinations_with_replacement

def readlines(n):
  for _ in range(n):
    a,b,c,d = map(int,input().split())
    yield a,b,c,d
    
def main():
  N,M,Q = map(int, input().split())
  X = list(readlines(Q))
  
  for comb in combinations_with_replacement(range(1,M+1),N):

    x = 0
    for a,b,c,d in X:
      if comb[b-1] - comb[a-1] == c:
        x += d
    yield x

print(max(main()))

Measured memory_bytes: 68308
import sys
e=sys.stdin.readline
for _ in[0]*int(e()):
 X,z=e(),[]
 for y in e():
  s=i=0
  for k in z:
   t=X.find(y,s)+1
   if t<1:break
   if t<k:z[i]=t
   s=k;i+=1
  else:
   t=X.find(y,s)+1
   if t:z+=[t]
 print(len(z)-1)


Measured memory_bytes: 5616
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void _main()
{
    int N;
    ll H;
    cin >> N >> H;
    vector<ll> a(N), b(N);
    rep(i, 0, N) cin >> a[i] >> b[i];
    sort(a.rbegin(), a.rend());
    sort(b.rbegin(), b.rend());
    int ans = 0;
    ll damage = 0;
    rep(i, 0, N)
    {
        if (b[i] < a[0]) break;

        damage += b[i];
        ++ans;

        if (damage >= H) break;
    }

    while (damage < H)
    {
        damage += a[0];
        ++ans;
    }

    cout << ans << endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define ss second
#define ff first
#define all(x) x.begin(), x.end()

using namespace std;
using ll = long long;
using pii = pair<int, int>;

const int oo = 1e9 + 7;
const int mod = 1e9 + 7, maxn = 100100;
const double PI = acos(-1);


int main (){
    int a, b;
    cin >> a >> b;

    cout << 6 - a - b << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {

    void run() {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int d = sc.nextInt();

        Set<Integer> integers = new HashSet<>();
        for (int i = 0; i < 1000; i++) {
            integers.add(i * i);
        }

        int[][] arr = new int[n][d];

        for (int i = 0; i < n; i++) {
            for (int j = 0; j < d; j++) {
                arr[i][j] = sc.nextInt();
            }
        }
        int count = 0;
        for (int i = 0; i < n - 1; i++) {
            for (int j = i + 1; j < n; j++) {
                int[] jPoint = arr[j];
                int[] iPoint = arr[i];
                int sum = 0;
                for (int k = 0; k < d; k++) {
                    sum += Math.pow(jPoint[k] - iPoint[k], 2);
                }
                count += (integers.contains(sum) ? 1 : 0);
            }
        }

        System.out.println(count);
    }

    void debug(Object... os) {
        System.err.println(Arrays.deepToString(os));
    }

    public static void main(String[] args) {
        new Main().run();
    }
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
typedef long double lb;
#define int long long
#define double long double
typedef pair<int,int> P;
const int MOD = 1000000007;
const ll INF = 1e16;
const double EPS = 1e-10;
const double PI = 3.141592653589793;
template<class T> inline bool chmin(T& a, T b){if(a>b){a = b;return 1;}return 0;}
template<class T> inline bool chmax(T& a, T b){if(a<b){a = b;return 1;}return 0;}
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 


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


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

int n;
vector<vector<int>> ans;
signed main(){
  cin>>n;
  int k = -1;
  repd(i,2,n+3){
    if(i*(i-1)/2 == n){
      k = i;break;
    }else if(i*(i-1)/2 > n){
      cout << "No" << endl;return 0;
    }
  }
  ans.resize(k);
  int t = 1;
  rep(i, k){
    repd(j,i+1,k){
      ans[i].push_back(t);
      ans[j].push_back(t);
      t++;
    }
  }
  cout << "Yes" << endl << k << endl;
  rep(i,k){
    cout << ans[i].size() << " ";
    rep(j,ans[i].size())cout << ans[i][j] << (j == ans[i].size()-1 ? "\n" : " ");
  }
}




Measured memory_bytes: 3200
#include <iostream>
 
using namespace std;
 
int main()
{
    int T[31];
    T[0] = 1;
    T[1] = 1;
    T[2] = T[1]+T[0];
    for (int i=3; i<=30; i++)
        T[i] = T[i-1]+T[i-2]+T[i-3];
    for (int i=0; i<=30; i++)
        T[i] = T[i]/3650+1;
 
    while (true)
    {
        int n;
        cin>>n;
        if (n==0)
            break;
        cout<<T[n]<<endl;
    }
}

Measured memory_bytes: 1160
using System;

class Diverta_2019_D
{
    static void Main(string[] args)
    {
        long N = long.Parse(Console.ReadLine());

        long sum = 0;
        long sqrt = (int) Math.Sqrt(N);


        for (long i=1; i<sqrt+1; i++)
        {
            long a = (N-i) / i;
            if ((N-i) % i==0 && i<a) sum += a;
        }

        Console.WriteLine(sum);
    }
}

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

typedef long long ll;
const ll MOD = 1e9 + 7;
const ll inf = 1LL<<60;
const double eps = 1e-9;

int main()
{
    int n;
    cin >> n;
    map<int, int> a;
    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;
        a[x]++;
    }
    int tmp = int(a.size());
    if (tmp%2 == 0) tmp--;

    cout << tmp << endl;

    return 0;
}


Measured memory_bytes: 4992
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		ArrayList<ArrayList<Integer>> list = new ArrayList<>();

		for (int i = 0; i < n; i++) {
			ArrayList<Integer> tmp = new ArrayList<>();
			list.add(tmp);
		}
		int q = sc.nextInt();
		for (int i = 0; i < q; i++) {
			int command = sc.nextInt();
			int t = sc.nextInt();
			switch (command) {
				case 0:
					int x = sc.nextInt();
					list.get(t).add(x);
					break;
				
				case 1:
					int listsize = list.get(t).size();
					if(listsize > 0) {
						for (int j = 0; j < listsize -1; j++) {	
							System.out.print(list.get(t).get(j) + " ");
						}
						System.out.println(list.get(t).get(listsize -1));
					} else {
						System.out.println();
					}
					break;
				
				case 2:
					list.get(t).clear();
					break;					
			}
		}
	}
}



Measured memory_bytes: 310792
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>

using namespace std;

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = n;i >= m;i--)
#define REPO(i, n) for(int i = 1;i <= n;i++)
#define ll long long
#define INF 1999999999
#define MINF -1999999999
#define ALL(n) n.begin(),n.end()

int main() {
	int a;
	cin >> a;
	cout << a * 800 - a / 15 * 200 << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner in  = new Scanner(System.in);
	        long N = in.nextLong();
	     
	        long x = 0;
	        long y = 0;
	        
	        long t = (long) Math.sqrt(N);
	        for(long i=t;i>=1;i--){
	        		if( N % i ==  0) {
	        			x = i;
	        			y=N/i;
	        			break;
	        		}
	        }
//	        System.out.println(x);
//	        System.out.println(y);
	        System.out.println(x+y-2);
	}

}


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

#define rep(i, a, b) for (int i = (a), i##end = (b); i <= i##end; ++i)
#define per(i, a, b) for (int i = (a), i##end = (b); i >= i##end; --i)

mt19937 Rnd(chrono::high_resolution_clock::now().time_since_epoch().count());

template <typename T>
inline void chkmax(T &x, T y) { if (x < y) x = y; }

template <typename T>
inline void chkmin(T &x, T y) { if (x > y) x = y; }

inline int read() {
  #define nc getchar()
  int x = 0;
  char c = nc;
  while (c < 48) c = nc;
  while (c > 47) x = (x << 3) + (x << 1) + (c ^ 48), c = nc;
  return x;
  #undef nc
}

const int maxn = 2e4 + 10;
char str[maxn];
int n, X, Y, tot, data[maxn];

bitset <maxn> bit;

bool check(int pos) {
  if (abs(pos) > n) return 0;
  bit.reset();
  bit[10000] = 1;
  rep(i, 1, tot) {
    bit = (bit << data[i]) | (bit >> data[i]);
  }
  return bit[10000 + pos];
}

int main() {
  scanf("%s %d %d", str + 1, &X, &Y);
  n = strlen(str + 1);
  vector <int> vec;
  int cur = 0, now = 0, tmp = 0;
  while (now < n && str[now + 1] == 'F') now++, tmp++;
  rep(i, now + 1, n) {
    if (str[i] == 'T') {
      vec.push_back(cur), cur = 0;
    } else {
      cur++;
    }
  }
  vec.push_back(cur);
  int sz = vec.size();
  rep(i, 0, sz - 1) if (i % 2 == 0) {
    data[++tot] = vec[i];
  }
  if (!check(X - tmp)) {
    return puts("No"), 0;
  }
  tot = 0;
  rep(i, 0, sz - 1) if (i % 2 == 1) {
    data[++tot] = vec[i];
  }
  if (!check(Y)) {
    return puts("No"), 0;
  }
  puts("Yes");
  return 0;
}

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

inline int read()
{
	int ret=0; char ch=getchar();
	while (!(ch>='0' && ch<='9')) ch=getchar();
	while (ch>='0' && ch<='9') ret=ret*10+(ch-'0'),ch=getchar();
	return ret;
}

const int maxn=100005;

struct edges{
	int next,to;
} ed[maxn<<2];
int head[maxn],ip;
void add(int u,int v)
{
	ed[++ip].next=head[u];
	ed[ip].to=v;
	head[u]=ip;
}

int n,k,ans;
int a[maxn],dis[maxn];

void dfs(int u,int father)
{
	dis[u]=1;
	int v;
	for (int i=head[u]; i; i=ed[i].next)
	{
		v=ed[i].to;
		if (v!=father)
		{
			dfs(v,u);
			dis[u]=max(dis[u],dis[v]+1);
		}
	}
	if (dis[u]>=k && a[u]>1)
	{
		ans++;
		dis[u]=0;
	}
}

int main()
{
	n=read(); k=read();
	for (int i=1; i<=n; i++)
		a[i]=read();
	if (a[1]!=1)
	{
		a[1]=1;
		ans++;
	}
	for (int i=2; i<=n; i++)
		add(a[i],i),add(i,a[i]);
	dfs(1,1);
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 8960
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<vector>
#include<cstdlib>
#include<map>
#include<queue>
#include<stack>
#include<deque>
#include<fstream>
#include<string>
#include<sstream>
#include<iomanip>
#include<numeric>
#include<cctype>
#include<random>

//#include<boost/circular_buffer.hpp>
using namespace std;

//cout << fixed << setprecision(10);
typedef long long ll;
#define PI 3.141592653589793
#define Yes(a) a ? "Yes" : "No";
#define YES(a) a ? "YES" : "NO";
#define rep(i,n) for(int i=0;i<n;i++)

int gcd(int a, int b) {
	if (a < b) {
		int tmp = a;
		a = b;
		b = tmp;
	}
	int r = a % b;
	while (r != 0) {
		a = b;
		b = r;
		r = a % b;
	}
	return b;
}

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

vector<long long  int> Prime;
void Eratosthenes(long long int n) {
	vector<bool> is_prime(n, true);
	for (int i = 2; i * i <= n; i++) {
		;
		if (is_prime.at(i)) {
			for (int j = i * i; j <= n; j += i) {
				is_prime.at(j) = false;
			}
		}
		Prime.emplace_back(i);
	}
}

/*
map<int, int> prime;
void Prime_number(long long int n) {
	for (int i = 2; i <= n; i++) {
		int count = 0;
		while (n % i == 0) {
			count++;
			n /= i;
		}
		if (count != 0) {
			prime.insert(make_pair(i, count));
		}
	}
}
*/
//std::cout.fill('0');

int main() {
	int n;
	string s;
	string str[7] = { "SUN","MON","TUE","WED","THU","FRI","SAT" };
	

	cin >> n >> s;
	int N = s.size();
	for (int i = 0; i < N; i++) {
		s[i] = (s[i] - 'A' + n) % 26 + 'A';
	}
	cout << s << endl;
}


Measured memory_bytes: 256
/**
 * @copyright (c) 2020 Daisuke Hashimoto
 */

#include <bits/stdc++.h>
using namespace std;
using Pair = pair<int64_t, int64_t>;
constexpr int64_t kInf = INT64_MAX / 2L;

// std::cout << std::setprecision(20) << 1.1 << endl;

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

  int64_t N, C, K;
  cin >> N >> C >> K;
  vector<int64_t> T(N);
  for (int64_t i = 0; i < N; ++i) {
    cin >> T[i];
  }
  sort(T.begin(), T.end());
  int64_t result = 1;
  int64_t bus_start = T[0] + K;
  int64_t passengers = 1;
  for (int64_t i = 1; i < N; ++i) {
    if (T[i] <= bus_start && passengers + 1 <= C) {
      ++passengers;
    } else {
      bus_start = T[i] + K;
      ++result;
      passengers = 1;
    }
  }
  cout << result << endl;
  return 0;
}


Measured memory_bytes: 3976
#include<cstdio>
#include<cstring>
#include<cctype>
#include<cstdlib>
using namespace std;
int main(){
    int w;
    scanf("%d",&w);
    getchar();
    for(int i = 0;i < w; i++){

        char str[1000]={0};

        scanf("%[^\n]",str);
        getchar();
        for(int j = 0;str[j] != 0; j++){
            if(str[j] == 'H'&&str[j+1] == 'o'&&str[j+2] == 's'&&str[j+3] == 'h'&&str[j+4] == 'i'&&str[j+5] == 'n'&&str[j+6] == 'o'){
                   str[j+6] = 'a';
               }
        }
        printf("%s\n",str);
    }
    return 0;
}

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

int main()
{
    int n, k, a[100010] = {};
    cin >> n >> k;
    for (int i = 0; i < n; i++) cin >> a[i];

    cout << (n - 1 + k - 2) / (k - 1) << endl;

    return 0;
}


Measured memory_bytes: 640
import java.util.Scanner;

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

    public static void solve(Scanner sc) {
        String a = sc.next();
        String b =sc.next();
        String c = sc.next();
        System.out.println("" + a.charAt(0) + b.charAt(1) + c.charAt(2));
    }
}

Measured memory_bytes: 23124
#include <iostream>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <tuple>
#include <queue>
#include <set>
#include <cmath>
#include <array>
#include <list>
#include <set>
const int MOD=1000000007;
using namespace std;
typedef long long ll;
typedef tuple<ll,int,int> tup;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int,int> p;
typedef vector<p> vp;
const int INF=1e9;
ll n;

int main(int argc,char const* argv[])
{
  string s;
  ll k;
  cin >> s >> k;
  int index=1000;
  bool oneflag=false;
  char check=' ';
  for(int i=0;i<(int)s.size();i++)
    {
      if(s[i]!='1')
	{
	  index=i+1;
	  check=s[i];
	  break;
	}
      else if(s[i]=='1')
	{
	  oneflag=true;
	}
    }
  if(index==1000)
    {
      cout << '1' << endl;
      return 0;
    }
  if(k<index && oneflag)
    {
      cout << '1' << endl;
    }
  else if((k<index && !oneflag) || k>=index)
    {
      cout << check << endl;
    }
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int k = scan.nextInt();
		int s = scan.nextInt();
		int count = 0;
		
		for(int i = 0; i <= k; i++) {
			for(int j = 0; j <= k; j++) {
				if(i + j <= s && (i + j + k) >= s) {
					count++;
				}
			}
		}
		System.out.println(count);
	}

}


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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()
#define all2(a, b) (a).begin(), (a).begin() + (b)
#define debug(vari) cerr << #vari << " = " << (vari) << endl;

int keta(int n)
{
    int cnt = 0;
    while (n)
    {
        n /= 10;
        cnt++;
    }
    return cnt;
}

int main()
{
    int a, b, k;
    cin >> a >> b >> k;
    int ans = 0;

    for (int i = min(a, b); i >= 0; i--)
    {
        if (a % i == 0 && b % i == 0)
        {
            ans++;
        }
        if (ans == k)
        {
            cout << i << endl;
            return 0;
        }
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <unordered_map>
#include <algorithm>
#include <vector>

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

	const size_t size = num / 2;
	std::vector<std::pair<int, int>> odd_v;
	std::vector<std::pair<int, int>> even_v;
	odd_v.reserve(size);
	even_v.reserve(size);

	{
		std::unordered_map<int, int> odd;
		std::unordered_map<int, int> even;

		for (uint32_t i = 0; i < num; ++i)
		{
			int value;
			std::cin >> value;

			if (i % 2)
			{
				++odd[value];
			}
			else
			{
				++even[value];
			}
		}

		for (auto&& v : odd)
		{
			odd_v.emplace_back(v);
		}

		for (auto&& v : even)
		{
			even_v.emplace_back(v);
		}
	}

	std::sort(odd_v.begin(), odd_v.end(), [](auto v1, auto v2)
	{
		return v1.second > v2.second;
	});

	std::sort(even_v.begin(), even_v.end(), [](auto v1, auto v2)
	{
		return v1.second > v2.second;
	});

	bool is_same_max = odd_v[0].first == even_v[0].first;
	bool is_same_num = odd_v[0].second == even_v[0].second;

	do {
		if (is_same_max)
		{
			if (odd_v.size() == 1)
			{
				odd_v[0] = { odd_v[0].first, 0 };
				break;
			}

			if (is_same_num)
			{
				if (odd_v[1].second > even_v[1].second)
				{
					odd_v[0] = odd_v[1];
				}
				else
				{
					even_v[0] = even_v[1];
				}
			}
			else
			{
				if (odd_v[0].second > even_v[0].second)
				{
					even_v[0] = even_v[1];
				}
				else
				{
					odd_v[0] = odd_v[1];
				}
			}
		}
	} while (false);

	int odd_change = size - odd_v[0].second;
	int even_change = size - even_v[0].second;

	std::cout << odd_change + even_change;

	return 0;
}

Measured memory_bytes: 4968
import math


N, D = map(int, input().split())
X = [list(map(int, input().split())) for i in range(N)]
cnt = 0
for i in range(N):
    for j in range(i+1, N):
        dis_2 = 0
        for k in range(D):
            dis_2 += (X[i][k] - X[j][k])**2
        dis = math.sqrt(dis_2)
        if dis%1 == 0:
            cnt += 1
print(cnt)   

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

class Main {
  public static void main(String[] args) {
    Scanner in = new Scanner(System.in);
    int N = in.nextInt();
    while (0 < N) {
      int n = in.nextInt();
      if (n % 2 == 0 && (n % 3 != 0 && n % 5 != 0)) break;
      N--;
    }
    System.out.println(0 < N ? "DENIED" : "APPROVED");
  }
}

Measured memory_bytes: 23764
n,m = map(int, input().split())
a = set([int(input()) for _ in range(m)])
mod = 10**9+7
dp = [0]*(n+1)
dp[0] = 1
dp[1] = 0 if 1 in a else 1
for i in range(2, n+1):
    dp[i] = (dp[i-1]+dp[i-2])%mod if i not in a else 0 #かけたところは0にしとこう、ってことか…
print(dp[n])

Measured memory_bytes: 13192
#include <bits/stdc++.h>
#define ALL(obj) begin(obj), end(obj)
#define debug(x) cerr << #x << ": " << x << '\n'
using namespace std;
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}

using ll = long long;
using ull = unsigned long long;
const int INF = 1e9;
// const int MOD = 1e9 + 7;

int main() {
    int a, b;
    scanf("%2d%2d", &a, &b);
    if (1 <= a && a <= 12) {
        if (1 <= b && b <= 12) {
            cout << "AMBIGUOUS" << endl;
        } else {
            cout << "MMYY" << endl;
        }
    } else {
        if (1 <= b && b <= 12) {
            cout << "YYMM" << endl;
        } else {
            cout << "NA" << endl;
        }
    }
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main{
	public static void main(String[] args) {

		int maxNumberOfHonest = 0;
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] A = new int[N];

        //claim[i][x_ij] = y_ij 人iは人x_ijがy_ij（正直者1 or 不親切な人0　or　主張なし-1）だと主張している
        int[][] claim = new int[N][N];

        //claimを初期化
        for(int i=0;i<N;i++) {
        	for(int j=0;j<N;j++) {
        		claim[i][j] = -1;
        	}
        }

        //全員の主張を入力
        for(int i=0; i< N; i++) {
        	A[i] = sc.nextInt();
        	for(int j=0; j<A[i]; j++) {
        		int x_ij = sc.nextInt();
        		int y_ij = sc.nextInt();
        		claim[i][x_ij-1] = y_ij;
        	}
        }

        //2^N通りをbit全探査
        //例：001001であれば、６人の中で３人目と６人目だけが正直者
        //(1<<N) = 2^N
        for(int i=0;i<(1<<N);i++) {
        	int numberOfHonest = 0;

        	//assumptin[j] = 0 or1
        	//人jが正直者or不親切な人と仮定
        	//初期値は全員不親切な人
        	int[] assumption = new int[N];
        	for(int j=0;j<N;j++) {
        		assumption[j] = 0;
        	}

        	//正直者と仮定した人を探す
        	//人数も数えておく
        	for(int j=0;j<N;j++) {
        		if((1 & (i>>j))==1) { //iのjbit目が1かどうか　つまり　人jが正直者かどうか
        			assumption[j] = 1;
        			numberOfHonest ++;
        			}
        	}

        	//正直者の主張が、仮定と矛盾しないかチェックする
        	//矛盾する場合は、ループを続ける
        	//矛盾がなければ、ループを脱出する
        	boolean check = true;
        	for(int j=0;j<N;j++) {
        		if(assumption[j]==1) {
        			for(int k=0;k<N;k++) {
        				if(claim[j][k] == -1) continue;
        				if(claim[j][k] != assumption[k]) check = false;
        			}
        		}
        	}

        	if(check) maxNumberOfHonest = Math.max(numberOfHonest, maxNumberOfHonest);
        }
        
        System.out.println(maxNumberOfHonest);


	}

}








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

int main() {
	uint32_t N;
	cin >> N;
	
	vector<vector<double>> dp(2, vector<double>(N+1, 1));	
	for(uint32_t i=1; i<=N; i++) {
		double p;
		cin >> p;
		
		bool ic = i & 1;
		bool ip = !ic;
		
		dp[ic][0] = dp[ip][0] * (1 - p);
		//cout << setprecision(3) << dp[ic][0] << " ";
		
		for(uint32_t j=1; j<i; j++) {
			dp[ic][j] = dp[ip][j-1] * p + dp[ip][j] * (1 - p);
			//cout << setprecision(3) << dp[ic][j] << " ";
		}

		dp[ic][i] = dp[ip][i-1] * p;
		//cout << setprecision(3) << dp[ic][i] << endl;
	}

	double ans = accumulate(dp[N&1].begin() + N/2 + 1, dp[N&1].end(), (double)0);
	cout << setprecision(10) << ans << endl;
	
	return 0;

}

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

struct Edge {
    int from, to, cost;
};

int main() {
    int n, m, p;
    cin >> n >> m >> p;
    Edge es[m];
    int d[n];
    fill(d, d + n, INF);
    d[0] = 0;
    for (int i = 0; i < m; i++) {
        int a, b, c;
        cin >> a >> b >> c;
        a--; b--;
        es[i] = Edge {a, b, p - c};
    }
    int i;
    bool flag = true;
    for (i = 0; i < n && flag; i++) {
        flag = false;
        for (Edge e: es) {
            int can_d = d[e.from] + e.cost;
            if (d[e.to] > can_d) {
                d[e.to] = can_d;
                flag = true;
            }
        }
    }
    if (i == n) {
        int now_d = d[n - 1];
        flag = true;
        for (i = 0; i < n && flag; i++) {
            flag = false;
            for (Edge e: es) {
                int can_d = d[e.from] + e.cost;
                if (d[e.to] > can_d) {
                    d[e.to] = can_d;
                    flag = true;
                }
            }
        }
        cout << ((d[n - 1] < now_d) ? -1 : max(0, -now_d)) << endl;
    } else {
        cout << max(0, -d[n - 1]) << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string>
#include <stdlib.h>
#include <queue>
#include <stack>
#include <utility>
#include <fstream>
#include <random>
#include <map>
#include <unordered_map>
#include <cstdlib>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define INF 1000000001
#define mod 1000000007
#define p pair<int,int>
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
using namespace std;
int POW(int x,int y){return int(pow(double(x),double(y)));}

int main(){
	int n,a;
	cin>>n>>a;
	if(n%500<=a){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
}





Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const long double PI = (acos(-1));
#define rep(i, x, n) for (int i = x; i < (int)(n); i++)
#define sc(x) scanf("%d",&x)
#define scll(x) scanf("%lld",&x)
int main(){
    string s, tmp; cin >> s;
    ll ans = atoll(s.c_str()), sum;
    rep(i, 1, 1<<(s.size()-1)){
        tmp = s[0];
        sum = atoi(tmp.c_str());
        rep(j, 0, s.size()-1){
            tmp = s[j+1];
            if (i & (1<<j)){
                ans += sum;
                sum = atoi(tmp.c_str());
            }else sum = 10*sum + atoi(tmp.c_str());
        }
        ans += sum;
    }
    cout << ans << endl;
    return 0;
}

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

ll maxSum(ll arr[], ll n, ll k) 
{ 
    // k must be greater 
    if (n < k) 
    { 
       cout << "Invalid"; 
       return -1; 
    } 
  
    // Compute sum of first window of size k 
    ll res = 0; 
    for (ll i=0; i<k; i++) 
       res += arr[i]; 
  
    // Compute sums of remaining windows by 
    // removing first element of previous 
    // window and adding last element of  
    // current window. 
    ll curr_sum = res; 
    for (int i=k; i<n; i++) 
    { 
       curr_sum += arr[i] - arr[i-k]; 
       res = max(res, curr_sum); 
    } 
  
    return res; 
} 


int main() {
	ll n,k;
	cin>>n>>k;
	ll arr[n];
	for(ll i=0;i<n;i++)
	{
		cin>>arr[i];
	}
	long double ans=maxSum(arr, n, k);
	ans=ans+k;
	ans=ans/2;
	cout<<setprecision(12)<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1792
from collections import Counter,defaultdict,deque
import sys,bisect,math,itertools,string,queue
from heapq import heappop, heappush
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

s = list(input())
n = len(s)
t = list('keyence')
ll = n - 7
for i in range(8):
    ss = s[::]
    for j in range(ll):
        del ss[i]
    if ss == t:
        print('YES')
        break
else:
    print('NO')


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

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

const ll INF64 = 1LL << 60;
const int INF32 = 1 << 29;
const int MOD = 1000000007;

int main() {
#ifdef MYLOCAL
    ifstream in("input.txt");
    cin.rdbuf(in.rdbuf());
#endif
    char c; cin >> c;
    char ans;
    if(c == 'A'){
        ans = 'T';
    }
    else if(c == 'T'){
        ans = 'A';
    }
    else if(c == 'C'){
        ans = 'G';
    }
    else{
        ans = 'C';
    }
    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 256
//  [amitdu6ey]
// g++ -std=c++11 -o2 -Wall filename.cpp -o filename
#include <bits/stdc++.h>
#define hell 1000000009
#define bug1(x) cout<<"$ "<<x<<" $"<<endl
#define bug2(x) cout<<"% "<<x<<" %"<<endl
#define bug3(x) cout<<"# "<<x<<" #"<<endl
#define ll long long
#define pb push_back
#define mp make_pair
#define tr(z) for(auto it=z.begin(); it!=z.end(); it++)
#define rloop(i,a,b) for(long long i=a; i>=b;i--)
#define loop(i,a,b) for(long long i=a; i<b; i++)
#define vbool vector< bool >
#define vvbool  vector< vector<bool> >
#define vchar vector<char>
#define vi vector<int>
#define vvi vector< vector<int> >
#define pll pair<long long, long long>
#define vll vector<long long>
#define vvl vector< vector<long long> >
#define ninf numeric_limits<long long>::min()
#define pinf numeric_limits<long long>::max()
#define comp(a,b) (abs(a-b)<1e-9) // to compare doubles
using namespace std;

void solve(){
    int n,k;
    cin>>n>>k;
    vll a(n);
    loop(i,0,n) cin>>a[i];
    vll dp(n,pinf);
    dp[0]=0;
    for(int i=1;i<n;i++){
        for(int j=max(0,i-k);j<i;j++){
            dp[i]=min(dp[i], dp[j]+abs(a[i]-a[j]) );
        }
    }
    cout<<dp[n-1];
    return;
}

int main(){
    ios_base::sync_with_stdio(0);
    cout.tie(0);
    cin.tie(0);
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int test_cases=1;
    //cin>>test_cases;
    while(test_cases--){
      solve();
    }
    return 0;
}


Measured memory_bytes: 1792
from collections import deque
n, m = map(int, input().split())
p = list(map(int, input().split()))
paths = {}
for _ in range(m):
    x, y = map(int, input().split())
    if not x in paths.keys():
        paths[x] = [y]
    else:
        paths[x].append(y)
    if not y in paths.keys():
        paths[y] = [x]
    else:
        paths[y].append(x)

connected = [None]*(n+1)
path_id = 1
for i in range(1, n+1):
    if connected[i] is None:
        connected[i] = path_id
    else:
        continue

    if i in paths.keys():
        stack = deque(paths[i])
        cluster = set([i]+paths[i])
    else:
        stack = []
    while len(stack) > 0:
        j = stack.pop()
        connected[j] = path_id
        for k in paths[j]:
            if connected[k] is None and not k in cluster:
                stack.append(k)
                cluster.add(k)
    path_id += 1
# print(connected)

ans = 0
for i in range(n):
    if connected[i+1] == connected[p[i]]:
        ans += 1
print(ans)


Measured memory_bytes: 39044
#include <iostream>
#include <iomanip>

using namespace std;

int main()
{
    int n,i;
    float y;
    cin>>n;
    if( n %2 == 0 ){
        i = n/2;
    }
    else{
        i = (n + 1) / 2;
    }
    y = float(i) / float(n);
    cout<< float(y);
    return 0;
}


Measured memory_bytes: 256
import sys

stdin = sys.stdin
inf = 1 << 60
mod = 1000000007

ni      = lambda: int(ns())
nin     = lambda y: [ni() for _ in range(y)]
na      = lambda: list(map(int, stdin.readline().split()))
nan     = lambda y: [na() for _ in range(y)]
nf      = lambda: float(ns())
nfn     = lambda y: [nf() for _ in range(y)]
nfa     = lambda: list(map(float, stdin.readline().split()))
nfan    = lambda y: [nfa() for _ in range(y)]
ns      = lambda: stdin.readline().rstrip()
nsn     = lambda y: [ns() for _ in range(y)]
ncl     = lambda y: [list(ns()) for _ in range(y)]
nas     = lambda: stdin.readline().split()

n, m = na()
h = na()
ab = nan(m)

g = [[] for _ in range(n)]
for i in range(m):
    a, b = ab[i]
    a -= 1
    b -= 1
    g[a].append(b)
    g[b].append(a)

def ok(v):
    hv = h[v]
    for nv in g[v]:
        if hv <= h[nv]:
            return False
    return True

ans = 0
for i in range(n):
    if ok(i):
        ans += 1

print(ans)

Measured memory_bytes: 48368
#include<bits/stdc++.h>
using namespace std;
const int N=1010;
int a[N][2];
int main(){
	int k;
	scanf("%d",&k);
	if(k==1){
		printf("1\n1\n");
		exit(0);
	}
	int n=(k+1)/2;
	if(n%2!=0){
		n++;
	}
	int c=k-n;
	for(int i=0;i<c;i++){
		a[i][0]=2*i+1;
		a[i][1]=2*i+2;
	}
	for(int i=c;i<n;i++){
		a[i][0]=i+c+1;
		a[i][1]=i+c+1;
	}
	printf("%d\n",n);
	assert(n<=500);
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			printf("%d ",a[(i+j)%n][i%2]);
		}
		printf("\n");
	}
	return 0;
}

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

vector<int> pass[2005]; //         // dis[i] : startからiまでの距離

int main()
{
    int n, m, l;
    cin >> n >> m >> l;
    vector<int> ans(n);
    rep(i, n){
        pass[i].push_back(i + 1);
        pass[i+1].push_back( i );
    } 
    pass[m - 1].push_back(l - 1);
    pass[l - 1].push_back(m - 1);
    rep(start, n)
    {
        vector<int> dis(n,1e9) ;
        queue<int> q;
        auto update = [&](int i, int j) {
            if (dis[i] != 1e9)
                return;
            dis[i] = j;
            q.push(i) ;
        };
        update(start, 0);
        while (!q.empty())
        {
            int i = q.front();
            q.pop();
            for (auto p : pass[i])
                update(p, dis[i] + 1);
        }
        rep(i, n) ans[dis[i]]++ ;
    }
    for(int i = 1 ; i < n ; i++ ) cout << ans[i] / 2 << endl ;
}

Measured memory_bytes: 384