akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
int main(){
  string s;
  int k;
  ll cnt1=0,cnt2=0;
  cin >> s >> k;
  if(s == string(s.size(),s[0])) {
    cout << s.size() * k / 2 << endl;
    return 0;
  }
  string t = s+s;
  rep(i,s.size()-1) if(s[i] == s[i+1]) s[i+1] = '#',cnt1++;
  rep(i,t.size()-1) if(t[i] == t[i+1]) t[i+1] = '#',cnt2++;
  cout << cnt1 + (cnt2-cnt1)*(k-1) << endl;
  return 0;
}

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

typedef unsigned long long ULL;
typedef long long LL;

using namespace std;

int main(){
    int N;
    int *D;
    int i;
    int count;
    cin >> N;
    D = new int[N];
    for(i=0;i<N;i++){
        cin >> D[i];
    }
    sort(D,D+N);
    count = 1;
    for(i=1;i<N;i++){
        if( D[i-1] != D[i]){
            count++;
        }
    }
    
    cout << count << endl;
    
    return 0;
}


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

using namespace std;

#define READ() 	    freopen("in.txt","r",stdin)
#define WRITE()     freopen("out.txt","w",stdout)
#define sf(n) 	    scanf("%d",&n)
#define sl(x)       scanf("%I64d",&x)
#define lsf(n) 	    scanf("%lld", &n)
#define pb(n) 	    push_back(n)
#define mem(x,y)    memset(x,y,sizeof(x))
#define DBG(x)      cout << #x << " = " << x << endl
#define YOLO        cout << "YOLO" << endl
#define EPS 	    1e-10
#define INF         INT_MAX
#define MAX         200010
#define MOD         1000000007
#define LL          long long
#define endl        "\n"
#define pi          2.0*acos(0.0)
#define cnd         tree[idx]
#define lnd         tree[left]
#define rnd         tree[right]
#define callLeft    left,st,mid
#define callRight   right,mid+1,ed

int used[MAX];

int main()
{
//	ios_base::sync_with_stdio(false);
//    cin.tie(0); /// use "\n" instead of endl
//    READ();
//    WRITE();

    string s;
    cin >> s;

    int len = s.size();
    int ans = len;

    stack <char> st;
    int cntS = 0;
    for(int i=0;i<len;i++)
    {
        if(s[i] == 'S')
        {
            cntS++;
        }
        else
        {
            if(cntS > 0)
            {
                ans -= 2;
                cntS--;
            }
        }
    }
    cout << ans << endl;

//    main();
    return 0;
}



Measured memory_bytes: 640
#pragma region _head

#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<map>
#include<set>
#include<iomanip>
#include<queue>
#include<stack>
#include<numeric>
#include<utility>
#include<regex>

#pragma region _define

#define f(i,a,b) for(int i=a;i<b;i++)
#define f_vI(v,n) f(i,0,n)cin>>v[i]
#define f_v2I(v1,v2,n) f(i,0,n)cin>>v1[i]>>v2[i]
#define f_v3I(v1,v2,v3,n) f(i,0,n)cin>>v1[i]>>v2[i]>>v3[i]
#define f_vO(v,n) f(i,0,n)cout<<v[i]<<endl
#define all(a) a.begin(),a.end()
#define size(s) s.size()
#define check() cout<<"! ! !"
#define endl "\n"
#define _y() cout<<"Yes"<<endl
#define _Y() cout<<"YES"<<endl
#define _n() cout<<"No"<<endl
#define _N() cout<<"NO"<<endl

#pragma endregion

#pragma region _using

using namespace std;

using LL = long long;
using st = string;
using vi = vector<LL>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vc = vector<char>;
using vs = vector<st>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvvb = vector<vvb>;
using si = stack<LL>;
using ss = stack<st>;
using pi = pair<LL, LL>;
using v_pi = vector<pi>;

#pragma endregion

#pragma region _graph

#define node 50  //グラフの最大位数　適宜変更
//bool graph[node][node]; bool visited[node] = { false };
#define link(a,b,m) f(i,0,m){cin>>a[i]>>b[i]; a[i]--; b[i]--; graph[a[i]][b[i]]=graph[b[i]][a[i]]=true;}

#pragma endregion

LL gcd(LL a, LL b) {
	LL r;
	while ((r = a % b) != 0) {
		a = b;
		b = r;
	}
	return b;
}
LL lcm(LL a, LL b) {
	return (a / gcd(a, b) * b);
}

//階乗計算
LL factorial(LL n) {
	LL a = 1, ret = 1;
	while (a < n) {
		a++;
		ret *= a;
		//ret %= 1000000007;
	}
	return ret;
}

#pragma endregion 

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

	LL x, y;
	cin >> x >> y;
	LL i = 0;
	for (x; x <= y; x *= 2) {
		i++;
	}
	cout << i;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cstdlib>
#include<queue>

using namespace std;

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

int main(){
    int n, i;
    cin >> n >> i;
    cout << n - i + 1 << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef vector<long long> vlong;
typedef vector<string> vstring;
#define _GLIBCXX_DEBUG
#define vpush(a,x) a.push_back(x);
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
const int INF = 1 << 30;
const int dx[] = {1,0,-1,0,1,1,-1,-1};
const int dy[] = {0,-1,0,1,1,-1,-1,1};
#define stp(x)  setprecision(x)
int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  ll k,a,b;
  cin>>k>>a>>b;
  if(a+1>=b){
    cout<<k+1<<'\n';
  }
  else{
    if(k<=a){
      cout<<k+1<<'\n';
    }
    else{
      k-=(a-1);
      if(k%2==0){
        cout<<(k/2*b)-(k/2*a)+a<<'\n';
      }
      else{
        cout<<(k/2*b)-(k/2*a)+a+1<<'\n';
      }
    }
  }
  return(0);
}


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

int dp[100002];
int main(){
	int n,m;
	cin >> n >> m;
	dp[0] = dp[1] = 0 ;
	
	for(int i = 2 ; i <= n ; i++){
		cin >> dp[i];
		dp[i] += dp[i-1];
	}
	long long ans = 0;
	int pos = 1;
	for(int i = 0 ; i < m ; i++){
		int a; cin >> a;
		int x = pos + a , y = pos;
		if(x>y) swap(x,y);
		ans += abs(dp[y] - dp[x]);
		ans %=100000;
		pos += a;
	}
	cout << ans << endl;
}

Measured memory_bytes: 0
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <valarray>
#include <vector>
using namespace std;

using ll = long long;
using ld = long double;
const int INF = 1e9;
const double EPS = 1e-9;
const ll MOD = 1e9 + 7;

int main()
{
  std::string s;
  std::cin >> s;
  long long K;
  scanf("%lld", &K);
  for (int i = 0; i < s.size(); ++i)
  {
    if (s[i] == 'a')
      continue;
    int t = (int)('z' - s[i]) + 1;
    if (t <= K)
    {
      K -= t;
      s[i] = 'a';
    }
  }
  K %= 26;
  int t = (K + (int)(s[s.size() - 1] - 'a')) % 26;
  s[s.size() - 1] = (char)('a' + t);
  cout << s << endl;

  return 0;
}


Measured memory_bytes: 760
import sys

sys.path.append("/home/contestant/.local/lib/python3.8/site-packages")

import networkx as nx

import io
import os


input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
N, D = [int(x) for x in input().split()]
XY = [[int(x) for x in input().split()] for i in range(N)]

graph = nx.DiGraph()
for i in range(2 * N):
    graph.add_node(i)

# f_i = 0 means choose x for flag i, f_i = 1 means choose y
# Node i is (f_i==0), node (i+N) is (f_i==1)
for i, (x1, y1) in enumerate(XY):
    for j in range(N):
        if i != j:
            x2, y2 = XY[j]
            if abs(x1 - x2) < D:
                # f_i==0 => f_j==1
                graph.add_edge(i, j + N)
            if abs(x1 - y2) < D:
                # f_i==0 => f_j==0
                graph.add_edge(i, j)
            if abs(y1 - x2) < D:
                # f_i==1 => f_j==1
                graph.add_edge(i + N, j + N)
            if abs(y1 - y2) < D:
                # f_i==1 => f_j==0
                graph.add_edge(i + N, j)


SCC = nx.algorithms.components.strongly_connected_components(graph)
assignment = {}
for comp in SCC:
    for x in comp:
        if (x < N and x + N in comp) or (x >= N and x - N in comp):
            print("No")
            exit()
        if x not in assignment:
            assignment[x] = True
            assignment[(x + N) % (2 * N)] = False

print("Yes")
for i in range(N):
    print(XY[i][0] if assignment[i] else XY[i][1])



Measured memory_bytes: 121100
import java.util.Scanner;
 
public class Main{
  public static void main(String[] args){
    Scanner scanner = new Scanner(System.in);
    int A = Integer.parseInt(scanner.next());
    int B = Integer.parseInt(scanner.next());
    int output = 0;
    if((B % A) == 0){
    	output = A + B;
    }
    else{
      output = B - A;
    }
    System.out.println(output);
  }
}

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

using namespace std;

int main() {
	int N;
	int tijolos[212345];

	scanf("%d", &N);

	for (int i = 0;i < N;i++) {
		scanf("%d", &tijolos[i]);
	}

	int indc = 1;
	int quebra = 0;

	for (int i = 0;i < N;i++) {
		if (indc == tijolos[i]){
			indc++;
		}else{
			quebra++;
		}
	}

	if (quebra == N){
		puts("-1");
	}else{
		printf("%d\n", quebra);
	}
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    if (s == "Sunny") cout << "Cloudy";
    else if (s == "Cloudy") cout << "Rainy";
    else cout << "Sunny";
}


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

	public static void main(String[] args) {
		Scanner cin = new Scanner(System.in);
		while(cin.hasNext()){
			int n,ans=0;
			n=cin.nextInt();
			for(int a=0;a<10;a++){
				for(int b=0;b<10;b++){
					for(int c=0;c<10;c++){
						for(int d=0;d<10;d++){
							if(a+b+c+d==n){
								ans=ans+1;
							}
						}
					}
				}
			}
			System.out.println(ans);
		}
	}
}

Measured memory_bytes: 19012
'use strict'

function main(input) {
  // AC - WA

  input = input.split('\n')[0].split('')

  let ans = 'WA'
  if (input[0] == 'A') {
    // ans = 'WA'
    let tar = input.slice(2, input.length - 1)
    let C = tar.indexOf('C')

    if (C >= 0) {
      let tar2 = []
      tar2.push(input[1]) //.slice(1, 2))
      tar2 = tar2.concat(tar.filter((x, i, self) => i !== C))
      tar2.push(input[input.length - 1])
      tar2 = tar2.join('')

      if (tar2.match(/^[a-z]+$/)) {
        ans = 'AC'
      }
    }
  }

  console.log(ans)
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'))

Measured memory_bytes: 7372
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <climits>
//#include "h.h"
using namespace std;

#define MOD1097 1000000007

#define ll long long
#define pint pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define mp make_pair
#define pm(first, second) pb(mp(first, second))
#define SPACE " "
#define fpf first.first
#define fps first.second
#define spf second.first
#define sps second.second

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

int main(){

	int N;
	cin >> N;
	vector<int> W(N + 1, 0);
	for(int i = 1; i <= N; i ++){
		cin >> W[i];
		W[i] += W[i - 1];
	}
	int ans = 1000000;
	for(int i = 1; i < N; i ++){
		ans = min(ans, abs(W[i] - (W[N] - W[i])));
	}
	cout << ans << endl;

//"Hiroakimm0415"

	return 0;
}

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

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

  int rain = 0, result = 0;
  for (int i = 0; i < s.length(); ++i) {
    if (s[i] == 'R')
      rain += 1;
    else {
      result = max(result, rain);
      rain = 0;
    }
  }
  result = max(result, rain);
  cout << result << endl;
  return 0;
}


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

const int MOD = 1000000007;

//long long
using ll = long long;

//出力系
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
 
// begin() end()
#define all(x) (x).begin(),(x).end()

//for
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

//最大公約数 
unsigned gcd(unsigned a, unsigned b) {
  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

  
int main() {

string S;
cin >> S;

if(S[0] == S[1] && S[1] == S[2]) yes;
else if(S[1] == S[2] && S[2] == S[3]) yes;
else no;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
using P=pair<int,int>;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
//const ll mod=998244353;
const ll mod=1000000007;
ll GCD(ll a,ll b) {return b ? GCD(b,a%b):a;}
ll LCM(ll c,ll d){return c/GCD(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int main(){
  int n,m;
  cin>>n>>m;
  V<int> same(m,0),d(m,0);
  map<int,int> mp;
  for(int i=0;i<n;i++){
    int a;cin>>a;
    mp[a]++;
    d[a%m]++;
  }
  for(auto p:mp){
     same[p.fi%m]+=p.se/2;
  }
  int ans=0;
  for(int i=0;i<=m/2;i++){
    if(i==(m-i)%m)ans+=d[i]/2;
    else{
    ans+=min(d[i],d[(m-i)%m]);
    if(d[i]>d[(m-i)%m]){
      d[i]-=d[(m-i)%m];
      ans+=min(d[i]/2,same[i]);
    }else{
      d[(m-i)%m]-=d[i];
      ans+=min(d[(m-i)%m]/2,same[(m-i)%m]);
    }
   }
  }
  cout<<ans<<"\n";
}


Measured memory_bytes: 5760
#include <iostream>

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

    int min = a + b;
    if (min > b + c) {
        min = b + c;
    }

    if (min > c + a) {
        min = c + a;
    }

    std::cout << min << std::endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long;
#define FOR(i, k, n) for(ll i = (k); i < (n); i++)
#define FORe(i, k, n) for(ll i = (k); i <= (n); i++)
#define FORr(i, k, n) for(ll i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for(ll i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;

const int INF = 1001001001;

using P = pair<ll, ll>;

int main(void){
  ll h, w;
  cin >> h >> w;
  ll c[2], d[2];
  cin >> c[0] >> c[1];
  cin >> d[0] >> d[1];
  c[0]--; c[1]--;
  d[0]--; d[1]--;
  vector<string> s(h);
  REP(i, h) cin >> s[i];

  vector<vector<ll>> cost(h, vector<ll>(w, INF));
  deque<P> q;
  cost[c[0]][c[1]] = 0;
  q.emplace_front(c[0], c[1]);
  ll dx[] = {-1, 0, 1, 0};
  ll dy[] = {0, -1, 0, 1};
  ll dh[] = {-2, -1, 0, 1, 2};
  ll dw[] = {-2, -1, 0, 1, 2};
  while(!q.empty()){
    ll y = q.front().first;
    ll x = q.front().second;
    q.pop_front();
    REP(i, 4){
      ll nx = x+dx[i];
      ll ny = y+dy[i];
      if(nx < 0 || nx >= w || ny < 0 || ny >= h) continue;
      if(s[ny][nx] == '#') continue;
      if(cost[y][x] < cost[ny][nx]){
        cost[ny][nx] = cost[y][x];
        q.emplace_front(ny, nx);
      }
    }
    REP(i, 5) REP(j, 5){
      if(dh[i] == 0 && dw[j] == 0) continue;
      ll ny = y + dh[i];
      ll nx = x + dw[j];
      if(nx < 0 || nx >= w || ny < 0 || ny >= h) continue;
      if(s[ny][nx] == '#') continue;
      if(cost[y][x]+1 < cost[ny][nx]){
        cost[ny][nx] = cost[y][x] + 1;
        q.emplace_back(ny, nx);
      }
    }
  }
  if(cost[d[0]][d[1]] == INF) cout << -1 << endl;
  else cout << cost[d[0]][d[1]] << endl;
  return 0;
}

Measured memory_bytes: 13544
import bisect
import operator
import os
from collections import Counter, deque
from fractions import gcd
from functools import lru_cache
from functools import reduce
import functools
import heapq
import itertools
import math
import numpy as np
import re
import sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")

# P, Q, R = list(map(int, sys.stdin.readline().split()))
#
# print(P + Q + R - max(P, Q, R))


N = int(sys.stdin.readline())
W = list(map(int, sys.stdin.readline().split()))

ans = INF
for i in range(1, N):
    ans = min(ans, abs(sum(W[:i]) - sum(W[i:])))
print(ans)


Measured memory_bytes: 23176
#include <stdio.h>

int main(void)
{
    int N;
    scanf("%d",&N);
    int res=0;
    for(int i=0;4*i<=N;i++){
        for(int j=0;4*i+7*j<=N;j++){
            if(4*i+7*j==N) res=1;
        }
    }
    puts(res==1?"Yes":"No");
    
    return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
#include <string.h>
#pragma warning(disable : 4996)

int main()
{
    long N;
    int i,p;
    long a[100001] = {0};
    long count = 0;
    long pp[100001] = {1};

    scanf("%ld", &N);

    for (i = 1; i <= N; i++) {
        scanf("%ld", &a[i]);
    }

    i = 1;
    pp[i++] = p = a[1];
    count++;

    if (p == 2) {
        printf("%ld", count);
        return 0;
    }

    while (1) {
        
       pp[i++] = p = a[p];
       count++;

       if (p == 2)
           break;

       for (int j = 0; j < i - 1; j++) {
           if (p == pp[j]) {
               printf("-1");
               return 0;
           }
       }
       


    }

    printf("%ld", count);

    return 0;

}

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

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

    if (abs(a-c) <= d){
        cout << "Yes" << endl;
    }
    else if (abs(a-b) <= d && abs(b-c) <= d){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    return 0;
}

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

using namespace std;

#define maxn 100008
#define ll long long int
#define db(x) cout<<#x<<" -> "<<x<<" "<<endl
#define db2(x,y) cout<<#x<<"-> "<<x<<", "<<#y<<" -> "<<y<<endl
#define db3(x,y,z) cout<<#x<<" -> "<<x<<" , "<<#y<<" -> "<<y<<" , "<<#z<<" -> "<<z<<endl
#define prt(x) for(auto it = x.begin(); it!=x.end(); it++) { cout<<*it<<" "; } cout<<endl
#define IN freopen("input.txt","r",stdin)
ll dp[ maxn ][ 14 ];
string str;
int sz;
const ll mod = (ll)1e9+7;

ll solve(int pos, int rem){
    if(pos >= sz){ return rem==5 ; }
    if(dp[ pos ][ rem ]!=-1){
        return dp[ pos ][ rem ];
    }
    ll ret = 0LL ;
    if(str[pos]!='?'){
        ret+=solve(pos+1, ( ( rem *10 )  + str[ pos ]-'0') % 13 ) % mod ;
        ret%=mod;
    }
    else{
        for(int i=0; i < 10; i++){
            ret+=solve(pos+1, ( ( rem * 10 ) + i ) % 13 ) % mod; ret%=mod;
        }
    }
    return dp[ pos ][ rem ] = ret % mod;
}


int main(){
    ios_base::sync_with_stdio(false)  ; cin.tie(0);
//    IN;
    cin>>str;
    sz = str.size();
//    db2(str,sz);
    memset(dp,-1,sizeof(dp));
    cout<<solve(0,0)<<endl;
    return 0;
}


Measured memory_bytes: 19280
#include <iostream>
#include <vector>

using namespace std;

int main() {
	int N;
	cin >> N;
	
	vector<int> A(N);
	for(int i = 0; i < N; i++) {
		cin >> A[i];
	}
	

	vector<int> hist(N, 0);
	/* 配列が条件を満たすか */
	bool flag = true;
	for(int i = 0; i < N; i++) {
		hist[A[i]] += 1;
	}
	if(N % 2 == 1) {
		for(int i = 2; i <= N - 1; i += 2) {
			if(hist[i] != 2) {
				flag = false;
				break;
			}
		}
		if(hist[0] != 1) {
			flag = false;
		}
	}

	if(N % 2 == 0) {
		for(int i = 1; i <= N - 1; i += 2) {
			if(hist[i] != 2) {
				flag = false;
				break;
			}
		}
	}
	
	/* 2^(N/2)の計算 */
	long long ans = 1;
	if(flag) {
		for(int i = 0; i < N / 2; i++) {
			ans *= 2;
			ans %= 1000000007;
		}
		cout << ans << endl;
	} else {
		cout << 0 << endl;
	}

	return 0;
}



Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<cmath>
typedef long long ll;
#define inf 0x3f3f3f3f
using namespace std;
int a[1000005];
int main()
{
    char s[4];
    int w=0; 
    cin>>s;
    if(s[1]!=s[0])w=1;
    if(s[2]!=s[1])w=1;
    if(w==1)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
	return 0;
 } 

Measured memory_bytes: 256
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE BinaryLiterals #-}
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE NumDecimals #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}

import Control.Applicative
import Control.Arrow
import Control.Monad
import Control.Monad.ST

import Data.Char
import Data.List
import Data.Maybe

import qualified Data.ByteString.Char8 as B

import Data.Array.ST.Safe
import Data.STRef

import Debug.Trace
import Text.Printf

readInt = readLn :: IO Int
readInteger = readLn :: IO Integer
readInts = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine
readIntegers = map ( fst . fromJust . B.readInteger ) . B.words <$> B.getLine

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

modifyArray a i f = writeArray a i =<< f <$> readArray a i

main = do
	n <- readInt
	[ s, t ] <- words <$> getLine
	putStrLn $ solve s t

solve [] [] = []
solve (s:ss) (t:tt) = s : t : solve ss tt

Measured memory_bytes: 508
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <string>
#include <map>
#include <set>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep2(i, s, n) for(int i=s; i<(n); ++i)
#define sz(x) int(x.size())

typedef long long ll;

using namespace std;

static const int MAX = 100001;

/******* c++14 don't include *******/

template<typename T>
T gcd(T a, T b){if( b == 0)return a; return gcd(b, a%b); }
template<typename T>
T lcm(T a, T b){return a*b/gcd(a,b); }

/*******                      *******/

int main(int argc, const char * argv[]) {
    // input from txt
    
    /////////
    //write//
    /////////
    
    int n, m;
    cin >> n >> m;
    priority_queue<int> q;
    
    ll res = 0;
    
    rep(i, n){
        int a;
        cin >> a;
        q.push(a);
        res+= a;
    }
    
    while(m>0){
        int num = q.top();
        q.pop();
        m--;
        res -= num - num/2;
        q.push(num/2);
    }
    
    cout << res << endl;
    
    return 0;
}


Measured memory_bytes: 892
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define MP make_pair
#define F first
#define S second

const int INF = 2e9;

int main() {
  int n, d, a;
  cin >> n >> d >> a;
  vector<P> mon(n);
  rep(i, n) {
    int x, h;
    cin >> x >> h;
    mon[i] = MP(x, h);
  }
  sort(mon.begin(), mon.end());
  vector<int> imos(n+1, 0);
  ll ans = 0;
  rep(ib, n) {
    if (ib) imos[ib] += imos[ib-1];
    if (mon[ib].S <= (ll)imos[ib] * a) continue;
    int hp = mon[ib].S - imos[ib] * a;

    int l = mon[ib].F;
    int r = min((ll)l+2*d, (ll)INF);
    int ie = upper_bound(mon.begin(), mon.end(), MP(r, INF)) - mon.begin();

    int nb = (hp + a - 1) / a;
    imos[ib] += nb;
    imos[ie] -= nb;
    ans += nb;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 5616
n=int(input())
sslis=[]
snumlis=[]
for i in range(n):
    s=input()
    if s in sslis:
        snumlis[sslis.index(s)]+=1
    else:
        sslis.append(s)
        snumlis.append(1)
m=int(input())
tslis=[]
tnumlis=[]
for i in range(m):
    s=input()
    if s in tslis:
        tnumlis[tslis.index(s)]+=1
    else:
        tslis.append(s)
        tnumlis.append(1)
b=0
for i in range(len(sslis)):
    a=0
    if sslis[i] in tslis:
        a=snumlis[i]-tnumlis[tslis.index(sslis[i])]
    else:
        a=snumlis[i]
    b=max(a,b)
print(b)


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

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

	if (a >= k) {
		cout << a - k << " " << b << endl;
	}
	else if (k <= a + b) {

		cout << 0 << " " << b - (k - a) << endl;
	}
	else
	{
		cout << 0 << ' ' << 0 << endl;
	}

	return 0;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
Cost = []
for i in range(M):
    a, b = map(int, input().split())
    c = 0
    K = list(map(int, input().split()))
    for j in range(b):
        c += 2**(K[j]-1)
    Cost.append([c, a])

dp = [[float("inf")]*(2**N+1) for _ in range(M+1)]
for i in range(M+1):
    dp[i][0] = 0

for i in range(1, M+1):
    for j in range(2**N):
        k = Cost[i-1][0] | j
        dp[i][j] = min(dp[i-1][j], dp[i][j])
        dp[i][k] = min([dp[i-1][j] + Cost[i-1][1], dp[i-1][k], dp[i][k]])

if dp[M][2**N-1] == float("inf"):
    print(-1)
else:
    print(dp[M][2**N-1])


Measured memory_bytes: 174680
#include<stdio.h>
int main(){
  int n;
  int a[10000];
  int min;
  int max;
  long long sum=0;
  int i;
  int count=0;
  
  scanf("%d",&n);

  
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
    sum += a[i];
  }
  count = i;
  min = a[0];
  max = a[0];

  for(i=0;i<count;i++){
    if(a[i] < min) min = a[i];
    if(a[i] > max) max = a[i];
  }

  printf("%d %d %lld\n",min,max,sum);
  return 0;
}



Measured memory_bytes: 2144
class Integers
  def initialize
    @count = 0
    @sum = 0
    @digit = 0
    @results = []
    while val = $stdin.gets do
      n, sum = val.chomp.split(' ').map(&:to_i)
      if n == 0 && sum == 0 
        break
      end
      calc(n,sum)
    end

    @results.each do |s|
      puts s
    end
  end

  def calc(n, sum)
    @sum = sum
    @digit = n
    @count = 0
    0.upto(9) do |num|
      array = []
      array[array.size] = num
      value = sum_array(array)
      if value == @sum && 1 == @digit
        @count += 1
        break
      end
      tree(array.dup)
    end
    @results.push(@count)
  end

  def tree(array)
    size = array.size
    if size < @digit
      (array[-1]+1).upto(9) do |num|
        array[size] = num
        value = sum_array(array)
        break if value > @sum
        if value == @sum && array.size == @digit
          @count += 1
          break
        else
          tree(array.dup)
        end
      end
    end
  end

  def sum_array(array)
    array.inject(:+)
  end
end

i = Integers.new

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

int main(void){
  int answer=0,n,state=0;
  int i;
  char str[200];
  while(scanf("%s",&*str)!=EOF){
    state=0;
    n=strlen(str);
    for(i=0;i<n/2;i++){
      if(str[i]!=str[n-1-i]){
	state++;
	break;
      }
    }
    if(state==0){
      answer++;
    }
  }
  printf("%d\n",answer);
  return 0;
}

Measured memory_bytes: 540
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
//for文のマクロ
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define big 1000000007
int main(){
    int n;
    cin>>n;
    int a[n];
    int b[n];
    rep(i,n){
        cin>>a[i];
    }
    rep(i,n){
        cin>>b[i];
    }
    vector<int> sum(n,0);
    rep(i,n){
        rep(j,n){
            if(j<i){
                sum[i] += a[j];
            }
            else if(j==i){
                sum[i] += a[j]+b[j];
            }
            else{
                sum[i] += b[j];
            }
        }
    }
    sort(sum.begin(),sum.end());
    reverse(sum.begin(),sum.end());
    cout<<sum[0]<<endl;
}

Measured memory_bytes: 256
n,y = gets.split.map(&:to_i)
y /= 1000

(n+1).times do |i|
    break if 10 * i > y

    x = y - n - 9 * i
    if x % 4 == 0 && x / 4 <= n - i && x >= 0
        puts "#{i} #{x/4} #{n - i - x/4}"
        exit
    end
end

puts "-1 -1 -1"

Measured memory_bytes: 1788
#include <iostream>
using namespace std;
int main()
{
    int n,q;
    cin>>n>>q;
    string a;
    cin>>a;
    int s[n]={0};
//    if(a[0]=='A'&&a[1]=='C')
//        s[0]=1;
    for (int i = 0; i < n-1; ++i) {
        if(a[i]=='A'&&a[i+1]=='C')
        {
            s[i+1]++;
        }
    }
    for (int i = 1; i < n; ++i) {
        s[i]+=s[i-1];
    }
    while (q--)
    {
        int l,r;
        cin>>l>>r;
        l--;
        r--;
        if(l!=0)
        {
            if(a[l-1]=='A'&&a[l]=='C')
                cout<<s[r]-s[l]<<endl;
            else
                cout<<s[r]-s[l-1]<<endl;
        }
        else
            cout<<s[r]<<endl;
    }
}

Measured memory_bytes: 1408
#include <iostream>
#include <queue>
#include <algorithm>
#include <cstdlib>
#include <cstring>

#define MAX_W 50
#define MAX_H 50

using namespace std;

struct State {
  int lx, ly, rx, ry;
  State (int lx, int ly, int rx, int ry): lx(lx), ly(ly), rx(rx), ry(ry) {;}
};

int W, H;
int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
char rooml[MAX_H + 2][MAX_W + 2], roomr[MAX_H + 2][MAX_W + 2];

void Solve(int sx[2], int sy[2])
{
  queue<State> que;

  que.push(State(sx[0], sy[0], sx[1], sy[1]));

  bool visit[MAX_H + 2][MAX_W + 2][MAX_H + 2][MAX_W + 2];

  memset(visit, false, sizeof(visit));

  string res = "No";
  while (!que.empty()) {
    State s = que.front(); que.pop();
    if (visit[s.ly][s.lx][s.ry][s.rx])
      continue;

    visit[s.ly][s.lx][s.ry][s.rx] = true;
    if (rooml[s.ly][s.lx] == '%' && roomr[s.ry][s.rx] == '%') {
      res = "Yes";
      break;
    }

    for (int k = 0; k < 4; k++) {
      int nlx = s.lx + dx[k], nly = s.ly + dy[k],
          nrx = s.rx - dx[k], nry = s.ry + dy[k];
      char cl = rooml[nly][nlx], cr = roomr[nry][nrx];
      if ((cl != '%' && cr == '%') || (cl == '%' && cr != '%')) {
        continue;
      }

      if (cl == '#') {
        nlx = s.lx; nly = s.ly;  
      }

      if (cr == '#') {
        nrx = s.rx; nry = s.ry;
      }

      que.push(State(nlx, nly, nrx, nry));
    }
  }

  cout << res << endl;
}

int main()
{
  while (cin >> W >> H && W && H) {
    int sx[2], sy[2];
    memset(rooml, '#', sizeof(rooml));
    memset(roomr, '#', sizeof(roomr));

    for (int i = 1; i <= H; i++) {
      for (int j = 1; j <= W; j++) {
        cin >> rooml[i][j];
        if (rooml[i][j] == 'L') {
          sy[0] = i; sx[0] = j;
          rooml[i][j] == '.';
        }
      }


      for (int j = 1; j <= W; j++) {
        cin >> roomr[i][j];
        if (roomr[i][j] == 'R') {
          sy[1] = i; sx[1] = j;
          roomr[i][j] == '.';
        }
      }
    }

    Solve(sx, sy);
  }
}

Measured memory_bytes: 11000
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();

ll func(ll N, vector<ll> in, vector<ll> out) {
    if (in.size() == 1) {
        N += (N / in[0]) * (out[0]-in[0]);
        return N;
    } else if (in.size() == 2) {
        ll ans = 0;
        for(int i = 0; i <= N/in[0]; i++) {
            int j = (N - (in[0]*i)) / in[1];
            ans = max(ans, N + (out[0]-in[0])*i + (out[1]-in[1])*j);
        }
        return ans;
    } else if (in.size() == 3) {
        ll ans = 0;
        for(int i = 0; i <= N/in[0]; i++) {
            for(int j = 0; j <= (N - in[0]*i) / in[1]; j++) {
                int k = (N - in[0]*i - in[1]*j) / in[2];
                ans = max(ans, N + (out[0]-in[0])*i + (out[1]-in[1])*j + (out[2]-in[2])*k);
            }
        }
        return ans;
    }
    return N;
}

int main() {
    ll N;
    vector<vector<int>> ex(3, vector<int>(2, 0));
    cin >> N;
    cin >> ex[0][0] >> ex[1][0] >> ex[2][0];
    cin >> ex[0][1] >> ex[1][1] >> ex[2][1];
    vector<ll> A2B_in;
    vector<ll> A2B_out;
    vector<ll> B2A_in;
    vector<ll> B2A_out;
    for(int i = 0; i < 3; i++) {
        if (ex[i][0] < ex[i][1]) {
            A2B_in.push_back(ex[i][0]);
            A2B_out.push_back(ex[i][1]);
        } else if (ex[i][0] > ex[i][1]) {
            B2A_in.push_back(ex[i][1]);
            B2A_out.push_back(ex[i][0]);
        }
    }
    // A to B
    N = func(N, A2B_in, A2B_out);
    // B to A
    N = func(N, B2A_in, B2A_out);
    cout << N << endl;
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a) for(int i = 0; i < (a); i++)
int main() {
	int n;
	while(cin >> n,n) {
		vector<pair<double,int>> data;
		rep(i,n){
			int index, h, w;
			scanf("%d %d %d", &index, &h, &w);
			data.push_back(make_pair(abs(22.0 - 10000.0 * w / (h * h)),index));
		}
		sort(data.begin(), data.end());
		cout << data[0].second << endl;
	}
	return 0;
}

Measured memory_bytes: 1276
#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
    // Your code here!
    int n;
    std::cin >> n;
    int x[200000];
    int y[200000];
    for (int i = 0; i < n; i++) {
        std::cin >> x[i];
        y[i]=x[i];
    }
    sort(y,y+n);
    
    int f=y[n/2-1],s=y[n/2];
    
    for (int i = 0; i < n; i++) {
        if(x[i]<=f){
            std::cout << s << std::endl;
        }else{
            std::cout << f << std::endl;
        }
    }
}


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

int main(){
	int N;
	cin >> N;
	string s;
	cin >> s;
	int r=0,b=0;
	for(int i=0;i<N;i++){
		if(s[i]=='R')r++;
		else b++;
	}
	if(r>b)cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

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

using namespace std;

template<typename T>
class SegTree {
public:
    explicit SegTree(int n, T def) : N(calcN_(n)), def(def), mVal(2*calcN_(n)-1, def) {}
    void update(int idx, T value){
        int i = N + idx - 1;
        update_(mVal[i], value);
        while(i > 0){
            i = (i-1)/2;
            mVal[i] = operate(mVal[2*i+1], mVal[2*i+2]);
        }
    }
    T get(int l, int r){
        l = max(0, l);
        r = min(N, r);
        int offset = N;
        T res = def;
        while(offset > 0){
            if(l >= r) break;
            if(l&1){ res = operate(res, mVal[offset+l-1]); l++; }
            if(r&1){ res = operate(res, mVal[offset+r-2]); }
            l /= 2;
            r /= 2;
            offset /= 2;
        }
        return res;
    }
private:
    int calcN_(int n){
        int res = 1;
        while(res < n) res *= 2;
        return res;
    }
    void update_(T& data, T val) { data = val; }
    T operate(T a, T b) { return min(a, b); }
    const int N;
    const T def;
    vector<T> mVal;
};

class Node {
public:
    explicit Node(int src, int dst, pair<int,int> minA, pair<int,int> minB) : src(src), dst(dst), minA(minA), minB(minB) {}
    bool operator < (const Node& nd) const { return minA > nd.minA; }
    int src, dst;
    pair<int, int> minA, minB;
};

int main(){
    int N; cin >> N;
    vector<SegTree<pair<int, int>>> seg(2, SegTree<pair<int,int>>(N, make_pair(2*N, 2*N)));
    for(int i=0;i<N;i++){
        int a;
        cin >> a;
        seg[i%2].update(i, make_pair(a, i));
        seg[1-i%2].update(i, make_pair(2*N, i));
    }
    priority_queue<Node> qu;
    auto addNode = [&](int src, int dst){
        if(src >= dst) return;
        auto minA = seg[src%2].get(src, dst);
        auto minB = seg[1-src%2].get(minA.second+1, dst);
        qu.emplace(src, dst, minA, minB);
    };
    addNode(0, N);
    vector<int> res;
    while(!qu.empty()){
        auto nd = qu.top(); qu.pop();
        res.push_back(nd.minA.first);
        res.push_back(nd.minB.first);
        addNode(nd.src, nd.minA.second);
        addNode(nd.minA.second+1, nd.minB.second);
        addNode(nd.minB.second+1, nd.dst);
    }
    cout << res[0];
    for(int i=1;i<N;i++) cout << " " << res[i];
    cout << endl;
}

Measured memory_bytes: 12924
#include<bits/stdc++.h>
#define ull unsigned long long
#define ll int64_t 
#define f(i,s,e) for(i=s;i<e;++i)
#define endl << "\n"
#define sp << " "
#define INF INFINITY
#define mset(a,b) memset(a,b,sizeof(a))
#define mod 1000000007
#define mp(a,b) make_pair(a,b)
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define crap ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define PI 3.14159265358979323846264338327950288419716939937510
#define pb(a) push_back(a)
#define pf(a) push_front(a)

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
using namespace std;

int main()
{
	crap;
	ull a;
	cin >> a;
	cout << a + (a*a) + (a*a*a) endl ;
	return 0;
}

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


int main(){
int N;
cin >> N;
bool flag = false;
for(int i = 1;i<10;i++){
    for(int j = 1;j<10;j++){
        if(i*j==N) flag = true;
    }
}
if(flag)cout<<"Yes"<<endl;
else cout<<"No"<<endl;
}

Measured memory_bytes: 256
from collections import deque
n,q = map(int,input().split())
ans = 0
NT = [list(input().split()) for i in range(n)]

queue = deque(NT)

while len(queue) > 0:
    a = queue.popleft()
    if int(a[1]) <= q:
        ans += int(a[1])
        print(a[0],ans)
    else:
        ans += q
        a[1] = str(int(a[1])-q)
        queue.append(a)


Measured memory_bytes: 15752
#include <math.h>
#include <string.h>
#include <time.h>
#include <stdlib.h>
#include <stdio.h>
#define REP(a) for(i = 1; i <= a; i++)

int main(void)
{
    int i;
    long long int a,power = 1;
    scanf("%lld",&a);
    REP(a) {
        power = i * power % ((int)(pow(10.0,9.0)) + 7);
    }
    printf("%lld\n",power);
    return 0;
 }

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using Map = map<ll,ll>;
using T = tuple<ll,ll,ll>;
using vvl = vector<vector<ll>>;
#define all(v) v.begin(), v.end()
#define print(v) cout<<v<<endl;
#define fi(v) get<0>(v)
#define se(v) get<1>(v)
#define th(v) get<2>(v)
template <typename T> bool chmax(T &a, const T &b){if (a<b){a=b;return 1;}return 0;}
template <typename T> bool chmin(T &a, const T &b){if (a>b){a=b;return 1;}return 0;}
const ll INF=1LL<<60;
const ll MOD=1000000007;

int main(){
    ll N;
    cin >> N;
    ll K;
    cin >> K;
    vector<ll> A(N,0);
    for(ll i=0;i<N;i++)cin>>A[i];
    vector<ll> count(41,0);
    for(ll i=0;i<41;i++)
        for(ll j=0;j<N;j++){
            if(A[j]&(1LL<<i))count[i]++;
        }
    //dp[i][j]のiは未満フラグ、j桁目までみたときの最大値
    vector<vector<ll>> dp(2, vector<ll>(42, 0));

    ll ok=0;

    for(ll i=40;i>=0;i--){
        if(ok==1)ok=2;
        if(!ok&&(K&(1LL<<i)))ok=1;
        if(ok==2&&(K&(1LL<<i))){
            //未満なら０，１
            chmax(dp[1][i],dp[1][i+1]+max(N-count[i],count[i])*(1LL<<i));
            //一致から０
            chmax(dp[1][i],dp[0][i+1]+count[i]*(1LL<<i));
            //一致から1
            chmax(dp[0][i],dp[0][i+1]+(N-count[i])*(1LL<<i));
        }
        else if(ok==1&&(K&(1LL<<i))){
            //一致から０
            chmax(dp[1][i],dp[0][i+1]+count[i]*(1LL<<i));
            //一致から1
            chmax(dp[0][i],dp[0][i+1]+(N-count[i])*(1LL<<i));
        }
        else{
            //Kが始まっていれば未満から０，１
            if(ok)chmax(dp[1][i],dp[1][i+1]+max(N-count[i],count[i])*(1LL<<i));
            //一致から0
            chmax(dp[0][i],dp[0][i+1]+(count[i])*(1LL<<i));
        }
    }

    print(max(dp[0][0],dp[1][0]))

    return 0;
}


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

int main() {
    int a, b;
    char op;
    while (true) {
        cin >> a >> op >> b;
        if (op == '?') break;
        else if (op == '+') cout << a+b << endl;
        else if (op == '-') cout << a-b << endl;
        else if (op == '*') cout << a*b << endl;
        else cout << a/b << endl;
    }
}


Measured memory_bytes: 3100
/*
 *  author: kiran bhanushali
 *  handle: kinibha
 *  time:
 *  email:kiranbhanushali143.kb143@gmail.com
 */


#include<bits/stdc++.h>
using namespace std;

#define int  long long 
  

int32_t main(){
    
   int n ;
   cin>>n;
   vector<int> x(n);
   for(int i = 0 ;i<n;i++){
       cin>>x[i];
}
    int mini = 1000000000;
    for(int p = 1 ; p<=100; p++){
        int tmpmin =0;
        for(int i = 0 ;i<n;i++){
            tmpmin += ( (x[i]-p)*(x[i]-p) );
        }
        mini = min (mini,tmpmin);
    }
    
    cout<<mini<<endl;
 
    return 0;
}


Measured memory_bytes: 256
#ABC117C-Streamline.py

import numpy as np

INPUT = [int(n) for n in input().split()]
N, M = INPUT[0], INPUT[1]
X = [int(x) for x in input().split()]
X.sort()
Diff = []

for i in range(len(X)-1):
    Diff.append(X[i+1]-X[i])

Diff.sort()

for i in range(N-1):
    if Diff == []:
        break
    Diff.pop(-1)

print(int(np.sum(Diff)))


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

using namespace std;

typedef long long LL;
typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define PB(a) push_back(a)
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)))
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)

int N;
vector<int> a;

bool eval(int z){
	LL p = 0, q = 0; int r = 0;
	vector<LL> s(2*N+1);
	repp(i,0,N){
		if(a[i] < z){
			++r;
			q += s[N+r-1];
		} else {
			q -= s[N+r-1];
			--r;
		}
		++s[N+r];
		if(r > 0) ++p;
		p += q;
	}
	return p <= (LL)N*(N+1)/4;
}

int BS(int x, int y){
	if(y-x<2) return x;
	int z = (x+y)/2;
	return eval(z) ? BS(z,y) : BS(x,z);
}

int main(){
	cin >> N;
	a.resize(N);
	repp(i,0,N) cin >> a[i];
	cout << BS(0,1e9+7) << endl;
	return 0;
}


Measured memory_bytes: 2176
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vll vector<ll>
#define rep(c, a, b) for(ll c=a;c<b;c++)
#define re(c, b) for(ll c=0;c<b;c++)
typedef long long int ll;
typedef long double ld;
using namespace std;

int main(int argc, char const *argv[]) {
  ll ans = 0, n, k;std::cin >> n >> k;
  rep(b, 1, n+1){
    if(b<=k) continue;
    if(n%b==0) ans += (n/b)*(b-k);
    else ans += (n/b)*(b-k) + max((ll)0, min(n%b, n%b - k + 1));
    //std::cout << b << " " << ans << '\n';
  }
  std::cout << ans << '\n';
  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;
typedef pair<int,int> P;

int main()
{
	int N;
	cin >> N;
	string c;
	cin >> c;
	int cntR = 0, cntW = 0;
	rep(i,N)
	{
		if (c[i] == 'R') cntR++;
		else cntW++;
	}
	int ans = 0;
	rep(i,cntR)
	{
		if (c[i] == 'W') ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3684
#include <cstdio>
#include <cmath>
#include <utility>
using namespace std;
int H, W, D, Q, sum[301][301]; pair<int, int> A[90001];
int main() {
  scanf("%d %d %d", &H, &W, &D);
  for(int i = 1; i <= H; ++i) {
    for(int j = 1, t; j <= W; ++j) {
      scanf("%d", &t);
      A[t] = {i, j};
    }
  }
  for(int i = 1; i <= H*W; ++i) {
    int x = A[i].first, y = A[i].second;
    if(i <= D) continue;
    int x0 = A[i-D].first, y0 = A[i-D].second;
    sum[x][y] = sum[x0][y0]+abs(x-x0)+abs(y-y0);
  }
  scanf("%d", &Q);
  for(int i = 1, L, R; i <= Q; ++i) {
    scanf("%d %d", &L, &R);
    int lx = A[L].first, ly = A[L].second;
    int rx = A[R].first, ry = A[R].second;
    printf("%d\n", sum[rx][ry]-sum[lx][ly]);
  }
}

Measured memory_bytes: 2048
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
#define rep(i,n)for(ll i=0;i<n;i++)
#define ll long long
#define ggr getchar();getchar();return 0;
#define prique priority_queue
#define inf 1000000007
#define double long double
using namespace std;
typedef pair<ll, ll>P;
bool prime(int n) {
	int cnt = 0;
	for (int i = 1; i <= sqrt(n); i++) {
		if (n % i == 0)cnt++;
	}
	if (cnt != 1)return false;
	else return n != 1;
}
ll gcd(ll x, ll y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
ll lcm(ll x, ll y) {
	return x * y / gcd(x, y);
}
ll mod_pow(ll x, ll n, ll mod) {
	ll bit = 1;
	while (n) {
		if (n & 1)bit = bit * x % mod;
		x = x * x % mod;
		n /= 2;
	}
	return bit;
}
ll C(ll a, ll b) {
	ll x = 1, y = 1;
	rep(i, b) {
		x = x * (a - i) % inf;
		y = y * (b - i) % inf;
	}
	rep(i, inf) {
		if (x == y * i % inf) {
			return i;
		}
	}
}
signed main() {
	ll x, y;
	cin >> x >> y;
	if (x > y)swap(x, y);
	if ((x + y) % 3 != 0 || y / 2 > x)puts("0");
	else {
		ll memo = (x + y) / 3;
		ll p = 2 * memo - x;
		cout << C(memo, p) % inf << endl;
	}
	ggr
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a;
  cin >> a;
  vector<int> vec(a);
  for (int i = 0; i < a; i++) cin >> vec.at(i);
  sort(vec.begin(), vec.end());
  cout << vec.at(a - 1) - vec.at(0) << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

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

		Scanner sc = new Scanner(System.in);

		int K = sc.nextInt();
		int A = sc.nextInt();
		int B = sc.nextInt();

		String ans = "NG";

		for (int i = 1; i <= 1000; i++) {

			int n = K * i;

			if (A <= n && n <= B) {
				ans = "OK";
				break;
			}
		}

		// 出力
		System.out.println(ans);
	}
}

Measured memory_bytes: 27028
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll MOD = 1000000007;
const ll INF = 10000000000000000;
vector<int> x4 = {0, 1, 0, -1}, x8 = {0, 1, 1, 1, 0, -1, -1, -1};
vector<int> y4 = {1, 0, -1, 0}, y8 = {1, 1, 0, -1, -1, -1, 0, 1};
template<class T> struct edge { int from, to; T cost;};
template<class T> inline bool chmin(T& a, T b){if (a>b){a = b; return true;}return false;}
template<class T> inline bool chmax(T& a, T b){if (a<b){a = b; return true;}return false;}
template<class T> inline T powerM(T a,T b){if (b==0) return 1;
  T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }
template<class T> T gcd(T a, T b){if (b==0) return a; return gcd(b, a%b);}
template<class T> T lcm(T a, T b){return a / gcd(a,b) * b;}
// ax+by=gcd(a,b)を解く
template<class T> T extgcd(T a,T b,T &x,T &y){if (b==0){x=1; y=0; return a;} T d=extgcd(b,a%b,y,x); y -= a/b*x; return d;}


int main() {
  int a,b; cin >>a >>b;
  int x,y;
  extgcd(a,b,x,y);
  cout <<x <<" " <<y <<endl;
}



Measured memory_bytes: 3172
#include<stdio.h>

int n,k;
int w[100000];

int check(long long int P){
  int i=0,j;

  for(j=1;j<=k;j++){
    int s=0;
    while(s+w[i]<=P){
      s+=w[i];
      i++;
      if(i==n){
        return n;
      }
    }
  }
  return i;
}

int main(void){
  int i;
  long long int left = 0, right = 100000*10000;

  scanf("%d %d",&n, &k);
  for(i=0; i<n; i++){
    scanf("%d",&w[i]);
  }

  while(right-left>1){
    long long int mid = (left+right)/2;
    int v = check(mid);
    if(v<n){
      left = mid;
    }else{
      right = mid;
    }
  }
  printf("%lld\n",right);

  return 0;
}



Measured memory_bytes: 2244
from collections import deque
K = int(input())

Q = deque()
for i in range(1, 10):
    Q.append(i)

while K > 0:
    q = Q.popleft()
    a = q % 10
    if a == 0:
        Q.append(q * 10)
        Q.append(q * 10 + 1)
    elif a == 9:
        Q.append(q * 10 + 8)
        Q.append(q * 10 + 9)
    else:
        Q.append(q * 10 + a - 1)
        Q.append(q * 10 + a)
        Q.append(q * 10 + a + 1)
    K -= 1

print(q)


Measured memory_bytes: 18704
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B,ans,tap;
  cin >> A >> B;
  ans = 0;
  tap = 1;
  A -= 1;
  while (true){
    if(tap >= B){
      cout << ans << endl;
      exit(0);
    }
    else {
      tap += A;
      ans += 1;
    }
  }

}

Measured memory_bytes: 256