akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll MOD = 998244353;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-11;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
const int MAX_N = (1 << 18);
int t; ll dat[2 * MAX_N - 1][2];
int n;
void init() {
	t = 1;
	while(t < 2*n)t *= 2;
	rep(i, 2 * t - 1) {
		rep(j, 2) {
			dat[i][j] = -INF;
		}
	}
}
void update(int k, int j, ll a) {
	k += t - 1;
	dat[k][j] = a;
	while (k > 0) {
		k = (k - 1) / 2;
		int le = k * 2 + 1; int ri = k * 2 + 2;
		if (dat[ri][0] != -INF || dat[ri][1] != -INF) {
			dat[k][0] = max(dat[le][0] + dat[ri][0], dat[le][1] + dat[ri][1]);
			dat[k][1] = max(dat[le][0] + dat[ri][1], dat[le][1] + dat[ri][0]);
		}
		else {
			dat[k][0] = dat[le][0];
			dat[k][1] = dat[le][1];
		}
	}
}
int main(){
	int q; cin >> n >> q; init();
	rep(i, 2 * n) {
		int a; cin >> a;
		update(i, 0, a);
	}
	rep(i, 2 * n) {
		int b; cin >> b;
		if (i > 0 && i < 2 * n - 1) {
			update(i, 1, b);
		}
	}
	rep(i, q) {
		int p; ll x, y; cin >> p >> x >> y; p--;
		update(p, 0, x);
		if (p > 0 && p < 2 * n - 1) {
			update(p, 1, y);
		}
		cout << dat[0][0] << endl;
	}
	return 0;
}

Measured memory_bytes: 9856
#include<stdio.h>

int main(void){
	
	int a,b;
	
	scanf("%d %d",&a,&b);
	
	if(a<b){
		printf("a < b\n");
	}
	
	else if(a>b){
		printf("a > b\n");
	}
	
	else{
		printf("a == b\n");
	}
	return 0;
}

Measured memory_bytes: 580
/*input
4
*/
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
#include <iomanip>

using namespace std; 

int GCD(int x,int y){return y?GCD(y,x%y):x;}
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define rep(i,n) for(int i=0;i<(n);i++)
#define repl(i,a,b) for(int i=(a);i<(b);i++)
#define repm(i,a,b) for(int i=(a);i>(b);i--)
#define rept(v) for(auto it=v.begin();it<v.end();it++)
#define all(v) v.begin(),v.end()
const int INF = 1<<30;
typedef long long ll;
typedef pair<int,int> pii;





int main() {
	ll n;
	cin>>n;
	ll arr[n+1];
	memset(arr,0,sizeof(arr));
	for(ll i = 1; i<=n;i++){
		for(ll j = 0; j<=n;j=j+i){
			arr[j]++;
		}
	}
	ll ans = 0;
	rep(i,n+1){
		ans = ans + i*arr[i];
	}
	cout<<ans<<endl;
	

}



Measured memory_bytes: 81752
#include<cstring>
#include<string>
#include<vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<list>
#include<set>
#include<map>
#include<sstream>
#include<climits>
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define all(X) (X).begin(),(X).end()
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

const int MAX_N = 100000, MAX_Q = 50000;
int n, q;
int S[MAX_N], T[MAX_Q];

int binary_search(int *s, int n, int i) {
  int lb = -1, ub = n-1, mid;    //(lb,ub]
  while (ub - lb > 1) {
    mid = (lb+ub)/2;
    if (s[mid] >= i) {
      ub = mid;     //(lb,mid]
    } else {                 
      lb = mid;     //(mid,ub]
    }
  }
  return s[ub];
}

int main() {
  cin >> n;
  rep(i,n) cin >> S[i];
  cin >> q;
  rep(i,q) cin >> T[i];

  int ans = 0;
  rep(i,q) {
   if (T[i] == binary_search(S, n, T[i])) ++ans;
  }

  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 3636
N = int(input())
L = [[] for _ in range(1000)]
l = 0
r = 1
for i in range(1, N+1):
  L[l].append(i)
  L[r].append(i)
  if(r-l == 1):
    r += 1
    l = 0
  else:
    l += 1
if(l != 0):
  print('No')
else:
  print('Yes')
  print(r)
  for i in range(r):
    print(len(L[i]), *L[i])

Measured memory_bytes: 47196
#include <stdio.h>
#include <stdlib.h>
#define MAX 2000001
#define VMAX 10000

int main(){
  int *A, *B;

  int C[VMAX+1];
  int n, i, j;
  scanf("%d", &n);

    A = malloc(sizeof(int)*n+1);
  B = malloc(sizeof(int)*n+1);

  for ( i = 0; i <= VMAX; i++ ) C[i] = 0;/*C[i]???10000??¨?????????*/

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

  for ( i = 1; i <= VMAX; i++ ) C[i] = C[i] + C[i - 1];/*?´??¨?*/

  for ( j = n; j >0; j-- ){/*????????????*/
    B[C[A[j]]] = A[j];
    C[A[j]]--;/*?´??¨?????????????*/
  }

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

  return 0;
}

Measured memory_bytes: 16276
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt(); // blue card count
		Map<String, Integer> map = new HashMap<String, Integer>();
		for (int i=0; i<N; i++) {
			String key = sc.next();
			Integer count = map.get(key);
			if ( count == null ) count = 1;
			else count++;
			map.put(key, count);
		}
		int M = sc.nextInt(); // red card count
		for (int i=0; i<M; i++) {
			String key = sc.next();
			Integer count = map.get(key);
			if ( count == null ) count = -1;
			else count--;
			map.put(key, count);
		}
		Iterator<Integer> it = map.values().iterator();
		int res = 0;
		while(it.hasNext()) {
			int t = it.next();
			if (res < t) res = t;
		}
		System.out.println(res);
	}
}


Measured memory_bytes: 23508
#include<iostream>
#include <bits/stdc++.h>
#include<math.h>
#include <vector>
using namespace std;
typedef long long ll;

#define pb push_back
#define mp make_pair
#define M 1000000007
int main()
{
	ll r;
	cin >> r;
	float ans = 2*3.14*r;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3784
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    int b[n];
    int ans = 0;
    for (int i = 0; i < n - 1; ++i)
    {
        cin >> b[i];
    }
    ans+= b[0];
    for (int i = 1; i < n - 1; ++i){
        ans+= min(b[i-1], b[i]);
    }
    ans+= b[n-2];
    cout << ans;
}


Measured memory_bytes: 256
#from collections import deque,defaultdict
printn = lambda x: print(x,end='')
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 10**18+7
R = 10**9 + 7
#R = 998244353

def ddprint(x):
  if DBG:
    print(x)

n,k = inm()
p = inl()
c = inl()
p = [x-1 for x in p]
used = [False]*n
mx = -BIG
for i in range(n):
    if used[i]:
        continue
    j = p[i]
    used[i] = used[j] = True
    pt = c[j]
    ids = [i,j]
    acc = [0,pt]
    while j!=i:
        j = p[j]
        used[j] = True
        pt += c[j]
        ids.append(j)
        acc.append(pt)
    ids.pop()
    cycsum = acc[-1]
    t = len(ids)
    if k>=t:
        mx = max(mx, cycsum*(k//t))
        mx = max(mx, cycsum)
    for j in range(1,t):
        acc.append(acc[j]+cycsum)
    #ddprint(f"{ids=} {acc=} {cycsum=} {t=}")
    for j in range(t):
        for m in range(1,min(k+1,t)):
            mx = max(mx, acc[j+m]-acc[j]+max(0,cycsum*((k-m)//t)))
print(mx)


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

using namespace std;

#define int long long
#define all(v) (v).begin(), (v).end()
#define resz(v, ...) (v).clear(), (v).resize(__VA_ARGS__)
#define reps(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep(i, n) reps(i, 0, n)

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

using Pi = pair<int, int>;
using Tapris = tuple<int, int, int>;
using vint = vector<int>;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  string s;
  cin >> s;
  bool flag = [&]() {
    if(s[0] != 'A') return false;
    int cnt = 0;
    reps(i, 2, s.size()-1) {
      if(s[i] == 'C') ++cnt;
    }
    if(cnt != 1) return false;
    rep(i, s.size()) {
      if(s[i] != 'A' && s[i] != 'C' && isupper(s[i])) return false;
    }
    return true;
  }();
  cout << (flag ? "AC" : "WA") << endl;

  return 0;
}


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

int main(){
    ll N, A, B;
    cin >> N >> A >> B;
    ll C = N / (A + B);
    ll D = N % (A + B);
    if(D <= A){
        cout << A * C + D << endl;
    }
    else{
        cout << A * C + A << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.HashSet;
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
    HashSet<Integer> S = new HashSet<Integer>();
    HashSet<Integer> T = new HashSet<Integer>();
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    for(int i = 0; i < n; i++)
	S.add(sc.nextInt());
    int q = sc.nextInt();
    for(int i = 0; i < q; i++)
	T.add(sc.nextInt());
    int count = 0;
    for(Integer T1 : T)
	if(S.contains(T1)) count++;
    System.out.println(count);
    }
}


Measured memory_bytes: 38664
/** 
 *                                                                   
 *   |    |                        ,   .              ,--.,--.,--.,--.
 *   |    |    ,---..    ,,---.    |   |,---..   .      -||  ||  ||  |
 *   |    |    |   | \  / |---'    `---'|   ||   |       ||  ||  ||  |
 *   `    `---'`---'  `'  `---'      |  `---'`---'    `--'`--'`--'`--'
 *                                   `                                
**/
#include <bits/stdc++.h>
using namespace std;

int n, w, wei[105], val[105];
long long dp[105][100005];

long long solve(int id, int sisa) {
	if (sisa < 0) return -1e18;
	if (id == n) return 0;
	if (dp[id][sisa] != -1) return dp[id][sisa];

	return dp[id][sisa] = max(solve(id + 1, sisa), solve(id + 1, sisa - wei[id]) + val[id]);
}

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

	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);

	cin >> n >> w;
	for (int i = 0; i < n; i++) {
		cin >> wei[i] >> val[i];
	}

	memset(dp, -1, sizeof(dp));
	cout << solve(0, w) << '\n';

	return 0;
}

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

int main(void)
{
	char ans[1000];
	char str[1000];
	int len, x, y, z;
	
	while (scanf("%s", str) != EOF) {
		z = 0;
		len = strlen(str);
		if (len % 2 != 0) {
			ans[0] = 'N';
			ans[1] = 'A';
			ans[2] = '\0';
		}
		else {
			for (x = 0; x < len; x += 2) {
				if ((((str[x] - '0') > 6) || ((str[x] - '0') < 1)) || (((str[x + 1] - '0') < 1) || ((str[x + 1] - '0') > 5))) {
					ans[0] = 'N';
					ans[1] = 'A';
					z = 2;
					break;
				}
				y = ((((str[x] - '0') - 1) * 5) + (str[x + 1] - '0'));
				y += 96;
				if (str[x] == '6') {
					if (str[x + 1] == '1') {
						ans[z] = 'z';
					}
					else if (str[x + 1] == '2') {
						ans[z] = '.';
					}
					else if (str[x + 1] == '3') {
						ans[z] = '?';
					}
					else if (str[x + 1] == '4') {
						ans[z] = '!';
					}
					else if (str[x + 1] == '5') {
						ans[z] = ' ';
					}
				}
				else {
					ans[z] = y;
				}
				z++;
			}
			ans[z] = '\0';
		}
		
		printf("%s\n", ans);
		ans[0] = '\0';
	}
	
	return (0);
}

Measured memory_bytes: 524
#include <cstdio>
#include <cstring>

char c[1010000];
int q[1010000], h = 0, t = 0;
int s[1010000];

int main()
{
	int n, Q; scanf("%d%s%d", &n, c + 1, &Q);
	for(int i = 1; i <= Q; i++)
	{
		int k; scanf("%d", &k);
		memset(s, 0, sizeof(s));
		long long sum = 0, ans = 0;
		h = t = 0;
		for(int j = 1; j <= n; j++)
		{
			if(c[j] == 'D') q[t++] = j;
			if(c[j] == 'M') s[h]++, s[t]--, sum += t - h;
			if(c[j] == 'C')
			{
				while(h < t && j - q[h] >= k)
					{sum -= s[h]; s[h + 1] += s[h]; h++;}
				ans += sum; 
			}
		} printf("%lld\n", ans);
	}
}

Measured memory_bytes: 9088
#include<iostream>
#include<vector>
#include<string>
#define rep(i, start, end) for (int i = (int)start; i < (int)end; ++i)
#define rrep(i, start, end) for (int i = (int)start - 1; i >= (int)end; --i)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return 0;}
template<typename T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return 0;}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<int> P(N);
    for (auto& p : P) {
        cin >> p;
    }
    int ans = 0;
    rep(i, 1, N - 1) {
        if ((P[i - 1] <= P[i] && P[i] <= P[i + 1]) || (P[i + 1] <= P[i] && P[i] <= P[i - 1])) {
            ++ans;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cstring>
using namespace std;
struct node{
  node *pre, *next;
  int key;
};

node *head;

node * find(int x){
  node *ima=head->next;
  while(ima->key!=x&&ima!=head) ima=ima->next;
  return ima;
}

void mk_node(int key,node *next,node *prev){
  node *n=(node *)malloc(sizeof(node));
  n->key=key;
  n->next=next;
  n->pre=prev;
  next->pre=n;
  prev->next=n;
}

void insert(int x){mk_node(x,head->next,head);}

void del(int x){
  node *del=find(x);
  if(del->key!=x) return;
  del->pre->next=del->next;
  del->next->pre=del->pre;
  free(del);
}

void delF(){
  node *del=head->next;
  if(del==head) return;
  del->next->pre=head;
  head->next=del->next;
  free(del);
}

void delL(){
  node *del=head->pre;
  if(del==head)return;
  del->pre->next=head;
  head->pre=del->pre;
  free(del);
}


char str[1000];

int main(){
  head=(node *)malloc(sizeof(node *));
  head->next=head;
  head->pre=head;
  head->key=-1;

  int n;
  cin>>n;
  while(n--){

    int a;
    scanf("%s",str);
    if(str[0]=='i'){
      scanf("%d",&a);
      insert(a);
    }

    if(str[0]=='d'&&strlen(str)==6){
      scanf("%d",&a);
      del(a);
    }else{
      if(str[6]=='F')delF();
      if(str[6]=='L')delL();
    }
  }
  
  node *ima=head->next;
  while(ima->next!=head&&ima->key!=-1)cout <<ima->key<<" ",ima=ima->next;
  cout << ima->key<<endl;
  return 0;
}

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

using namespace std;
int main() {
  string r, g, b;
  cin >> r >> g >> b;
  string rgb = r + g + b;
  if (stoi(rgb) % 4 == 0)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define sz(x) int(x.size())
#define pb push_back
#define eb emplace_back
using ll=long long;
using P = pair<int,int>;
using LP=pair<ll,int>;
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
const ll MOD=1000000007,MOD2=998244353;

//解説みた

int main() {
    int L;
    cin>>L;
    vector<ll> A(L);
    rep(i,L){
        cin>>A.at(i);
    }
    vector<vector<ll>> dp(5,vector<ll>(L));
    rep(i,L){
        ll now,bef;
        rep(j,5){
            if(j==0 || j==4){
                now=A.at(i);
            }
            if(j==1 || j==3){
                now=A.at(i)%2;
                if(A.at(i)==0)now=2;
            }
            if(j==2){
                now=(A.at(i)+1)%2;
            }
            if(i==0)bef=0;
            else{
                bef=dp[0][i-1];
                rep(k,j+1)chmin(bef,dp[k][i-1]);
            }
            dp[j][i]=now+bef;
        }
    }
    
    ll ans=dp[0][L-1];
    rep(i,5)chmin(ans,dp[i][L-1]);
    cout<<ans<<endl;
    /*rep(i,5){
        rep(j,L){
        cout<<dp[i][j]<<" ";}
        cout<<endl;
    }*/
}

Measured memory_bytes: 14356
N = int(input())
L = list(map(int, input().split()))
L.sort(reverse=True)
ans = 0
while len(L) >= 3:
    tmp = L.pop(0)
    left = 0
    right = len(L) - 1
    while left < right:
        if L[left] + L[right] > tmp:
            ans += right - left
            left += 1
        else:
            right -= 1
print(ans)


Measured memory_bytes: 41580
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using std::cerr;
using std::cin;
using std::cout;
using std::endl;

int main(void) {
  cout << std::fixed << std::setprecision(10);
  cin.tie(0);
  std::ios::sync_with_stdio(false);
  int r, g, b, n;
  cin >> r >> g >> b >> n;
  int result = 0;
  for (int br = 0; br <= n; br++) {
    for (int bg = 0; bg <= n; bg++) {
      int rplusg = br * r + bg * g;
      int remain = n - rplusg;
      if (remain >= 0 && remain % b == 0) {
        result++;
      }
    }
  }
  cout << result << endl;
  return 0;
}


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

int main(){
  int N,K;
  cin >> N >> K;
  vector<int> A(N);
  for(int i=0;i<N;i++) cin >> A[i];
  int res=0,index=0;
  while(index<N){
    if(res==0) index += K;
    else index += K-1;
    res++;
  }
  cout << res << endl;
}



Measured memory_bytes: 640
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n,i=1;
        while(true){
        n=sc.nextInt();
        if(n==0) break;
        System.out.printf("Case %d: %d\n",i,n);
        i++;
        }
    }
}


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

using namespace std;

using ll = long long;
constexpr ll MOD = 1e9 + 7;
constexpr ll INF = 1e18;

int main() {
    ll n, m, i, j, k;
    cin >> n >> k;
    vector<double> A(n);
    for(auto&x:A){
        cin >> x;
    }
    
    vector<double> ret(n,0);
    for(i=0;i<n;i++){
        ret[i]=(A[i]+1)/2.0;
    }
    double cnt=0.0,tmp=0;
    for(i=0;i<k;i++){
        tmp+=ret[i];
    }
    cnt = tmp;
    for(i=1;i<n;i++){
        if(i+k-1>=n)break;
        tmp-=ret[i-1];
        tmp+=ret[i+k-1];
        cnt=max(cnt,tmp);
    }
    printf("%.12f\n",cnt);
    return 0;
}

Measured memory_bytes: 3328
#include <iostream>
#include <algorithm>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}
const ll INF = 1e18;
const ll MOD = 1000000007;
typedef pair<ll,ll> P;
const ll MAX = 20000;
constexpr ll nx[8] = {1,0,-1,0,-1,-1,1,1};
constexpr ll ny[8] = {0,1,0,-1,-1,1,-1,1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    double sum = 0;
    cin >> n;
    vector<double> x(n),y(n);
    rep(i,n){
        cin >> x[i] >> y[i];
    }
    rep(i,n){
        rep(j,n){
            sum += sqrt((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]));
        }
    }
    printf("%0.10f",sum/(double)n);
}

Measured memory_bytes: 256
//is there any case of -1 or any special corner cases ?
#include<bits/stdc++.h>
using namespace std;
#define int long long int 
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define vi vector<int>
#define pi pair<int,int>
#define all(v) v.begin(),v.end()
#define zeros(arr) memset(arr,0,sizeof(arr));
#define precise(num)  cout<<fixed; cout << std::setprecision(num)
#define nl cout<<"\n";
#define test int t;cin>>t;wahile(t--) 
const int maxx  = 3*1e5 , limit = 1e17 , MOD=1e9+7;
string binary(int n){bitset<32>b(n) ;string p =b.to_string();return p;}
int decimal(string s){int res = 0; for(int i = 0; i < s.size() ; i++ ){if(s[i] == '1')res = res + pow(2,s.size() - i -1);}    return res;}
bool isPrime(int n){if (n <= 1) return false; if (n <= 3) return true;if (n % 2 == 0 || n % 3 == 0) return false;
for (int i = 5; i * i <= n; i = i + 6) if (n % i == 0 || n % (i + 2) == 0) return false; return true; }
int pow (int x, int n,int mod) {if (n == 0) return 1; int res = pow (x, n / 2,mod);res = (res * res) % mod;if (n % 2) res = (res * x ) % mod;return res;}
#define boost  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int subCount(vector<int>arr, int n, int k) 
{ 
    int mod[k]; 
    memset(mod, 0, sizeof(mod)); 
  
    int cumSum = 0; 
    for (int i = 0; i < n; i++) { 
        cumSum += arr[i]; 
        mod[((cumSum % k) + k) % k]++; 
    } 
  
    int result = 0; // Initialize result 
  for (int i = 0; i < k; i++) 
  
     if (mod[i] > 1) 
            result += (mod[i] * (mod[i] - 1)) / 2; 
   result += mod[0]; 
  
    return result; 
} 

int32_t main(){
    boost;
    string s;
    cin>>s;
    
    vector<int>v;
    reverse(all(s));
    
    for(int i = 0; i  <s.size() ; i++ ){
        int vl = s[i]-'0';
        int num = vl*pow(10 , i , 2019);
        num = num %2019;
        v.pb(num);
        
    }
    
    
    cout<<subCount(v,v.size() , 2019);
    
    // cout<<ans<<endl;
    
    
    
}

Measured memory_bytes: 6708
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define X first
#define Y second
#define REP(i,a) for(int i=0;i<a;++i)
#define REPP(i,a,b) for(int i=a;i<b;++i)
#define FILL(a,x) memset(a,x,sizeof(a))
#define foreach( gg,itit )  for( typeof(gg.begin()) itit=gg.begin();itit!=gg.end();itit++ )
#define mp make_pair
#define pb push_back
#define all(s) s.begin(),s.end()
#define present(c,x) ((c).find(x) != (c).end())
const double EPS = 1e-8;
const int mod = 1e9+7;
const int N = 1e6+10;
const ll INF = 1e18;

//#define DEBUG
ll power(ll x,ll y){
  ll t=1;
  while(y>0){
    if(y%2) y-=1,t=t*x%mod;
    else y/=2,x=x*x%mod;
  }
  return t;
}
#ifdef DEBUG
#define dprintf(fmt,...) fprintf(stderr,fmt,__VA_ARGS__)
#else
#define dprintf(fmt,...)
#endif

ll arr[N];
ll p[N];
int main(){
  int n; 
  scanf("%d",&n);
  if(n==1){
    printf("YES\n"); exit(0);
  }
  REP(i,n) scanf("%lld",&arr[i]);
  ll sum=0;
  REP(i,n) sum+=arr[i];
  ll p = 1ll*n*(n+1)/2;

  if(sum%p!=0){
    printf("NO\n"); exit(0);
  }
  sum/=p;
  int fl=1;
  REP(i,n){
    ll z = sum-(arr[i]-arr[(i-1+n)%n]);
   // printf("%lld %lld\n",sum,z);
    if(z%n!=0||z<0) fl=0;
  }
  if(fl) printf("YES\n"); else printf("NO\n");
  return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>
#include <fstream>
#include <sstream>
#include <string>
#include <cmath>
#include <cstdio>
#include <cctype>
#include <ctime>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <complex>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cwchar>
#include <cwctype>
#include <exception>
#include <locale>
#include <numeric>
#include <new>
#include <stdexcept>
#include <limits>
#include <valarray>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <list>
#include <utility>
#include <bitset>
#include <algorithm>
#include <functional>
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define MP make_pair
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int INF=1e9+7;
struct node{
	node* son[2];
	bool hv;
	node(){
		hv=false;
		son[0]=son[1]=NULL;
	}
};
vector<ll> sol;
string S;
ll T;
void insert(node*& cur,int pos){
	if(cur==NULL)cur=new node;
	if(pos==S.length())cur->hv=true;
	else insert(cur->son[S[pos]-'0'],pos+1);
}
void dfs(node*& cur,int dep){
	if(dep>T)return;
	if(cur==NULL){
		sol.push_back(T-dep);
		return;
	}
	if(cur->hv)return;
	dfs(cur->son[0],dep+1);
	dfs(cur->son[1],dep+1);
}
ll grundy(ll x){
	return (x+1LL)&(-x-1LL);
}
int main(){
	int n;
	node* root=NULL;
	cin>>n>>T;
	rep(k,n){
		cin>>S;
		insert(root,0);
	}
	dfs(root,0);
	ll dat=0LL;
	rep(k,sol.size())dat^=grundy(sol[k]);
	cout<<(dat==0LL?"Bob\n":"Alice\n");
	return 0;
}

Measured memory_bytes: 9336
import java.util.Scanner;
import java.lang.Math;
class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();
        sc.close();

        System.out.print(C+" "+ A +" " + B);
    }
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
using p=pair<int,int>;
#define int long long
#define rep(i,N) for(int i=0;i<N;i++)
 
signed main(){
  string S;
  cin>>S;
  if(S=="ABC")cout<<"ARC"<<endl;
  else cout<<"ABC"<<endl;
}

Measured memory_bytes: 3600
N = int(input())
XL = [[int(i) for i in input().split()] for _ in range(N)]

R = [(X - L, X + L) for X, L in XL]
R.sort(key=lambda x: x[1])

ret = 0
rmax = -float('inf')
for l, r in R :
  if l >= rmax :
    ret += 1
    rmax = r
    
print(ret)

Measured memory_bytes: 71384
l=[0,0,0,0]
n=int(input())
for _ in range(n):
  s=str(input())
  if s=='AC': l[0]+=1
  if s=='WA': l[1]+=1
  if s=='TLE': l[2]+=1
  if s=='RE': l[3]+=1
print('AC '+'x '+str(l[0]))
print('WA '+'x '+str(l[1]))
print('TLE '+'x '+str(l[2]))
print('RE '+'x '+str(l[3]))


Measured memory_bytes: 9204
IDENTIFICATION DIVISION.
        PROGRAM-ID. AtCoder.
      
        ENVIRONMENT DIVISION.
      
        DATA DIVISION.
        WORKING-STORAGE SECTION.
        01 INP PIC X(100).
        01 A PIC 9(11).
        01 B PIC 9(11).
        01 C PIC 9(11).
	    01 temp1 PIC 9(11).
        01 temp2 PIC 9(11).
        01 N PIC 9(11).
      
        PROCEDURE DIVISION.
      	MAIN.
            ACCEPT A.
			ACCEPT INP.
			IF A >= 3200 THEN
				DISPLAY INP
			ELSE 
				DISPLAY "red"
			END-IF.
		STOP RUN.

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

int main(){

  int N,M,X,a,b,ans;
  cin >> N >> M >>X;
  int A[M];
  for(int i=0; i<M; i++) cin >> A[i];

  for(int i=0; i<M; i++){
    if(A[i] > X){
      a = i;
      b = M-i;
      break;
    }else if(i == M-1){
      a = M;
      b = 0;
      break;
    }
  }

  ans = min(a,b) > 0 ? min(a,b) : 0 ;

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include<stdio.h>
#include<math.h>
int main() {
	double x, h;
	while (~fscanf(stdin, "%lf%lf", &x, &h), (x || h))
		fprintf(stdout, "%lf\n", x*x + 2 * x*sqrt((x / 2)*(x / 2) + h*h));
	return 0;
}

Measured memory_bytes: 648
//##Moh_K_Imar .......
//27/08/2020  ...  8.10
//Ya Rab....
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
int main(){
    ll a,b,c,d,e;
    cin>>a>>b>>c>>d>>e;
    if(a==0)cout<<1<<endl;
    else if(b==0)cout<<2<<endl;
    else if(c==0)cout<<3<<endl;
    else if(d==0)cout<<4<<endl;
    else cout<<5<<endl;
    
    return 0;
}



Measured memory_bytes: 3500
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
using namespace std;
int main(void){
    int n;
    cin >> n;
    vector<int> a(n);
    vector<int> b(n);
    vector<int> c(n-1);
    for(int i=0; i<n; i++){
        cin >> a.at(i);
    }
    for(int i=0; i<n; i++){
        cin >> b.at(i);
    }
    for(int i=0; i<n-1; i++){
        cin >> c.at(i);
    }
    
    int hoge = 0;
    for(int i = 0; i < n; i++){
        hoge += b.at(a.at(i)-1);
    }
    for(int i= 0; i < n-1; i++){
        if(a.at(i) == a.at(i+1)-1) hoge += c.at(a.at(i)-1);
    }
    cout << hoge << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void) {
	int r, c, sum, allsum = 0;
	register int i, ii;
	scanf("%d %d", &r, &c);
	int data[r][c];
	for (i = 1; i <= r; i ++) for (ii = 1; ii <= c; ii ++) scanf("%d", &data[i - 1][ii - 1]);
	for (i = 1; i <= r; i ++) {
		sum = 0;
		for (ii = 1; ii <= c; ii ++) {
			printf("%d ", data[i - 1][ii - 1]);
			sum += data[i - 1][ii - 1];
		}
		printf("%d\n", sum);
	}
	for (ii = 1; ii <= c; ii ++) {
		sum = 0;
		for (i = 1; i <= r; i ++) {
			sum += data[i - 1][ii - 1];
		}
		allsum += sum;
		printf("%d ", sum);
	}
	printf("%d\n", allsum);
	return 0;
}

Measured memory_bytes: 636
#import sys
#import numpy as np
import math
#from fractions import Fraction
import itertools
from collections import deque
from collections import Counter
import heapq
from fractions  import gcd
#input=sys.stdin.readline
#import bisect
h,w,k=map(int,input().split())
a=1
res=[]
ans_r=[0]*h
x=0
for i in range(h):
    s=list(input())
    ans=[0]*w
    cnt=0
    if a==k+1:
      ans_r[i]=x-1
      continue
    for j in range(w):
        if s[j]=="#":
            if cnt==0:
                cnt+=1
            else:
                a+=1
            ans[j]=a
        else:
            ans[j]=a
    ans_r[i]=x
    if cnt!=0:
        res.append(ans)
        x+=1  
        a+=1
  
for i in range(h):
    j=ans_r[i]
    if j==-1:
        print(*res[-1])
    else:
        print(*res[j])

Measured memory_bytes: 81060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=100005;
const ll INF=1LL<<60;

int main(){
    
    int N;cin>>N;
    vector<int> A(2*N);
    vector<char> ans(2*N,'C');
    cout<<"?";
    for(int j=0;j<N;j++){
        cout<<" "<<j+1;
    }
    cout<<endl;
    string X;cin>>X;
    if(X[0]=='B'){
        A[0]=1;
        A[N]=0;
    }
    else{
        A[0]=0;
        A[N]=1;
    }
    int left=0,right=N;
    while(right-left>1){
        int mid=(left+right)/2;
        cout<<"?";
        for(int j=0;j<N;j++){
            cout<<" "<<j+mid+1;
        }
        cout<<endl;
        string S;cin>>S;
        if(S[0]=='B') A[mid]=1;
        else A[mid]=0;
        
        if(A[left]==A[mid]) left=mid;
        else right=mid;
    }
    if(A[left]==1){
        ans[left]='B';
        ans[left+N]='R';
    }else{
        ans[left]='R';
        ans[left+N]='B';
    }
    left++;
    right=left+N;
    
    for(int re=left+1;re<=right-1;re++){
        cout<<"?";
        cout<<" "<<left<<" "<<right;
        for(int j=left+1;j<=right-1;j++){
            if(j==re) continue;
            cout<<" "<<j;
        }
        cout<<endl;
        string S;cin>>S;
        if(S[0]=='B'){
            ans[re-1]='R';
        }else{
            ans[re-1]='B';
        }
    }
    
    for(int i=1;i<left;i++){
        cout<<"?";
        cout<<" "<<i;
        for(int j=left+1;j<=right-1;j++){
            cout<<" "<<j;
        }
        cout<<endl;
        string S;cin>>S;
        if(S[0]=='R') ans[i-1]='R';
        else ans[i-1]='B';
    }
    
    for(int i=right;i<=2*N;i++){
        cout<<"?";
        cout<<" "<<i;
        for(int j=left+1;j<=right-1;j++){
            cout<<" "<<j;
        }
        cout<<endl;
        string S;cin>>S;
        if(S[0]=='R') ans[i-1]='R';
        else ans[i-1]='B';
    }
    
    cout<<"! ";
    for(int j=0;j<ans.size();j++) cout<<ans[j];
    cout<<endl;
}



Measured memory_bytes: 724
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        C solver = new C();
        solver.solve(1, in, out);
        out.close();
    }

    static class C {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            int n = Integer.parseInt(in.next());
            int[] a = new int[n];
            long total = 0;
            for (int i = 0; i < n; i++) {
                a[i] = Integer.parseInt(in.next());
                total += a[i];
            }
            long ans = Long.MAX_VALUE;

            long x = 0;
            for (int i = 0; i < n; i++) {
                x += a[i];
                if (i + 1 < n) ans = Math.min(ans, Math.abs(total - 2 * x));
            }
            // 出力
            out.println(ans);

        }

    }
}



Measured memory_bytes: 59908
#include <bits/stdc++.h>
using namespace std;
const int N=400010;
int i,j,k,n,m,x,y,t,la,no,ans;
struct data{int l,r,sum,lazy;}T[2][N*4];
vector<int>c[N];
void build(int id,int i,int l,int r){
	T[id][i]={l,r,0,0};
	if (l==r)return;
	int mid=l+r>>1;
	build(id,i*2,l,mid);build(id,i*2+1,mid+1,r);
}
void pushup(int id,int i){T[id][i].sum=T[id][i*2].sum+T[id][i*2+1].sum;}
void pushdown(int id,int i){
	if (T[id][i].lazy){
		T[id][i*2].lazy=T[id][i*2+1].lazy=T[id][i].lazy;
		T[id][i*2].sum=(T[id][i*2].r-T[id][i*2].l+1)*(T[id][i].lazy-1);
		T[id][i*2+1].sum=(T[id][i*2+1].r-T[id][i*2+1].l+1)*(T[id][i].lazy-1);
		T[id][i].lazy=0;
	}
}
void change(int id,int i,int l,int r,int num){
	pushdown(id,i);
	if (T[id][i].l==l&&T[id][i].r==r){
		T[id][i].sum=num*(r-l+1);
		T[id][i].lazy=num+1;
		return;
	}
	int mid=T[id][i].l+T[id][i].r>>1;
	if (r<=mid)change(id,i*2,l,r,num);
	else if (l>mid)change(id,i*2+1,l,r,num);
	else{change(id,i*2,l,mid,num);change(id,i*2+1,mid+1,r,num);}
	pushup(id,i);
}
int query(int id,int i,int l,int r){
	pushdown(id,i);
	if (T[id][i].sum==0)return -1;
	if (T[id][i].l==T[id][i].r)return T[id][i].l;
	int mid=T[id][i].l+T[id][i].r>>1;
	if (r<=mid)return query(id,i*2,l,r);
	else if (l>mid)return query(id,i*2+1,l,r);
	else {
		int te=query(id,i*2,l,mid);
		if (te!=-1)return te;
		return query(id,i*2+1,mid+1,r);
	}
}
int main(){
	scanf("%d%d%d",&n,&m,&t);
	ans=1013687232;
	for (i=1;i<=t;i++){
		scanf("%d%d",&x,&y);
		if (x>1)c[y].push_back(x);
	}
	for (i=1;i<=m;i++)c[i].push_back(n+1);
	for (i=1;i<=m;i++)sort(c[i].begin(),c[i].end());
	no=0;la=1;
	build(0,1,1,n);build(1,1,1,n);
	change(no,1,1,c[1][0]-1,1);
	ans=c[1][0]-1;
	for (i=2;i<=m;i++){
		swap(no,la);change(no,1,1,n,0);
		int be=1;
		for (j=0;j<c[i].size();j++){
			if (be<=c[i][j]-2){
				int pos=query(la,1,be,c[i][j]-2);
				if (pos!=-1){change(no,1,pos+1,c[i][j]-1,1);/*printf("###%d %d %d\n",i,c[i][j],i-1+c[i][j]-2);*/ans=min(ans,c[i][j]-1);}
			}
			be=c[i][j];
		}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 51712
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif
// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;

#define rep(i,n) for(int i=0; i<((int)n); i++)
#define REP(i,n) for(int i=0; i<=((int)n); i++)
#define srep(i,a,n) for(int i=a; i<((int)n); i++)
#define SREP(i,a,n) for(int i=a; i<=((int)n); i++)
#define rrep(i,n) for(int i=n-1; i>=0; i--)
#define RREP(i,n) for(int i=n; i>=0; i--)
#define INF 1000000000
const int mod = INF+7;

//ポイント
//上の桁から処理していく。
//上に張り付いているものについてと、以下のものについてそれぞれDPする。


int main(){
  string L;
  cin >> L;
  int N=L.length();

  vector<int> dp1(N);
  vector<int> dp2(N);

  dp1[0]=1;
  dp2[0]=2;
  srep(i,1,N){
    if(L[i]=='0'){
      dp1[i]=((long)dp1[i-1]*3+dp2[i-1]*0)%mod;
      dp2[i]=dp2[i-1];
    }
    else if(L[i]=='1'){
      dp1[i]=((long)dp1[i-1]*3+dp2[i-1]*1)%mod;
      dp2[i]=(long)dp2[i-1]*2%mod;
    }
  }

  printf("%ld\n", ((long)dp1[N-1]+dp2[N-1])%mod);


}


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

// macro
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long
#define all(v) v.begin(), v.end()

// code starts
int main()
{
  int n,p;
  string s;
  cin>>n>>p>>s;
  ll ans=0;
  int i;
  if(p==2)
  {
    rep(i,n)if((s[i]-'0')%2==0)ans+=(i+1);
  }
  else if(p==5)
  {
    rep(i,n)if((s[i]-'0')%5==0)ans+=(i+1);  
  }
  else
  {
    vector<int> modp(p,0);
    modp[0]=1;
    int mod10=1;
    int modn=0;
    for(i=n-1;i>=0;i--)
    {
      modn=(modn+mod10*(s[i]-'0'))%p;
      ans+=modp[modn];
      modp[modn]++;
      mod10=(mod10*10)%p;
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 640
s = input()
x, y = map(int, input().split())
a = []
b = []
c = 0
n = 0
for i in range(len(s)):
  if s[i]=='F':
    n += 1
  else:
    if c%2==0:
      a += [n]
    else:
      b += [n]
    c += 1
    n = 0
if s[-1]=='F':
  if c%2==0:
    a += [n]
  else:
    b += [n]
sa = sum(a)
sb = sum(b)
dpa1 = [0]*(2*sa+1)
dpa2 = [0]*(2*sa+1)
dpb1= [0]*(2*sb+1)
dpb2 = [0]*(2*sb+1)
dpa1[sa] = 1
dpb1[sb] = 1
if len(a)>0:
  if sa-a[0]<abs(x-a[0]) or sb<abs(y):
    print('No')
    import sys
    sys.exit()
else:
  if sa<abs(x) or sb<abs(y):
    print('No')
    import sys
    sys.exit()

if len(a)%2==0:
  A = dpa1
else:
  A = dpa2
if len(b)%2==0:
  B = dpb1
else:
  B = dpb2

for i in range(len(a)):
  c = a[i]
  if i%2==0:
    for j in range(2*sa+1):
      if dpa1[j]==1:
        dpa1[j] = 0
        dpa2[j-c] = 1
        dpa2[j+c] = 1
  else:
    for j in range(2*sa+1):
      if dpa2[j]==1:
        dpa2[j] = 0
        dpa1[j-c] = 1
        dpa1[j+c] = 1
for i in range(len(b)):
  c = b[i]
  if i%2==0:
    for j in range(2*sb+1):
      if dpb1[j]==1:
        dpb1[j] = 0
        dpb2[j-c] = 1
        dpb2[j+c] = 1
  else:
    for j in range(2*sb+1):
      if dpb2[j]==1:
        dpb2[j] = 0
        dpb1[j-c] = 1
        dpb1[j+c] = 1

if A[x+sa]==1 and B[y+sb]==1:
  print('Yes')
else:
  print('No')


Measured memory_bytes: 43868
from collections import Counter
N = int(input())
ans = 0
evidence = [[] for n in range(N)]

for n in range(N):
    A = int(input())
    for a in range(A):
        lis = list(map(int, input().split()))
        evidence[n].append(lis)

for n in range(1 << N):
    bits = [(n >> i) & 1 for i in range(N)]
    flag = True
    boolean = True
    for i in range(N):
        if (n >> i) & 1 == 0:
            continue
        for x, y in evidence[i]:
            if bits[x-1] == y:
                continue
            flag = False
    if flag:
        ans = max(ans, sum(bits))
print(ans)

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

bool func( int x, int y, int z )
{
    if ( x + y == z )
    {
        cout << "Yes" << endl;
        return true;
    }
    else
        return false;
}

int main( void )
{
    int a,b,c;
    cin >> a >> b >> c;
    
    if ( a + b == c || a + c == b || b + c ==a )
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}


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

using namespace std;

int main(){
  int n,t,a;
  vector<int> h;
  cin >> n >> t >> a;
  for(int i=0; i<n; i++){
    int temp;
    cin >> temp;
    h.push_back(temp);
  }

  int ans = 0;
  float abs_min = 999999;
  for(int i=0; i<n; i++){
    if( abs( a - (t - h.at(i)*0.006) ) <= abs_min ){
      abs_min = abs( a - (t - h.at(i)*0.006) );
      ans = i;
    }
  }
  cout << ans + 1;

  return 0;
}


Measured memory_bytes: 256
import numpy as np

N, M = map(int, input().split())

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

t_list = np.ones(N)

for j in range(M):
    A, B = map(int, input().split())
    if H_list[A-1] ==  H_list[B-1]:
        t_list[A-1] -= 1
        t_list[B-1] -= 1

    elif H_list[A-1] > H_list[B-1]:
        t_list[B-1] -= 1

    else:
        t_list[A-1] -= 1

ones = t_list[t_list > 0]
print(len(ones))


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

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

    l = a + b;
    r = c + d;

    if (l > r) {
        cout << "Left" << endl;
    }
    else if (l < r) {
        cout << "Right" << endl;
    }
    else if (l == r) {
        cout << "Balanced" << endl;
    }
}

Measured memory_bytes: 3648
def selection_sort(array):
    counter = 0
    for i in range(len(array)):
        # print(f"\n----- i: {i} -----")
        
        # iより後ろで最も小さい数のindexを探す
        j_min = i
        for j in range(i, len(array)):
            # print("j:", j)
            if array[j] < array[j_min]:
                j_min = j
            # print(f'j_min: {j_min} ({array[j_min]})')
        
        # print(f'arrray[i]: {array[i]}, array[j_min]: {array[j_min]}')
        if array[i] > array[j_min]:
            array[i], array[j_min] = array[j_min], array[i]
            # print(f'change to: {array}')
            counter += 1
            
    return array, counter

N = int(input())
A = list(map(int, input().split()))
# print(f'array: {A}')

A_new, num_ans = selection_sort(A)

print(" ".join(map(str, A_new)))
print(num_ans)


Measured memory_bytes: 5600
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 3e5 + 10;
int get_first(int n) {
    while(n >= 10) {
        n /= 10;
    }
    return n;
}
int main() {
    int n, c[10][10] = {0};
    cin >> n;
    for(int i = 1; i <= n; i++) {
        c[get_first(i)][i%10]++;
    }
    ll ans = 0;
    for(int i = 1; i <= 9; i++) {
        for(int j = 1; j <= 9; j++) {
            ans += 1LL * c[i][j] * c[j][i];
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
using namespace std;
const int INF= 1e9+5;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>>vvi;

int main(){
  string s="qwertyuiopasdfghjklzxcvbnm";
  string w;
  cin>>w;
  for(int i=0;i<26;i++){
    int count=0;
    for(int j=0;j<w.size();j++){
      if(w[j]==s[i])count++;
    }
    if(count%2!=0){
      cout<<"No"<<endl;
      return 0;
    }
  }
  cout<<"Yes"<<endl;
}
  

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
vector<char>mp;
int main(){
	string s;
	cin>>s;
	int final=0;
	char lastchar=s[0];
	for (int x=1;x<s.length();x++){
		char a=s[x];
		if (a=='0'){
			if (lastchar=='0'){
				final++;
				lastchar='1';
			}
			else lastchar='0';
		}
		else if (a=='1'){
			if (lastchar=='1'){
				final++;
				lastchar='0';
			}
			else lastchar='1';
		}
	}
	cout<<final<<endl;

}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <iomanip>
#include <bitset>
#include <set>
#include <map>
#include <stdio.h>
#include <numeric>
#include <cstring>

#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep1(i,n) for (int i = 1; i < (n); i++)
#define FOR(i,a,b) for (int i=(a); i < (b); i++)
#define MOD 1000000007 //10^9+7
using namespace std;
using ll = long long;
using PII = pair<int, int>;
using PLL = pair<long long, long long>;
const int INF = numeric_limits<int>::max();

// 負の数にも対応した % 演算
long long mod(long long val, long long m) {
    long long res = val % m;
    if (res < 0) res += m;
    return res;
}

//greatest common divisor
long long gcd(ll a, ll b) 
{
    if (a % b == 0) {
        return b;
    } else {
        return gcd(b, a % b);
    }
}

//least common multiple
long long lcm(ll a, ll b)
{
    return a / gcd(a, b) * b ;
}

int main()
{
    ll n, k; cin >> n >> k;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    //ll base = 1;
    //for (int i = 0; i < k; i++) {
    //    base *= a[i];
    //}
    //for (int i = k; i < n; i++) {
    //    ll score = (base / a[i-k]) * a[i];
    //    if (score > base)
    //        cout << "Yes" << endl;
    //    else
    //        cout << "No" << endl;
    //    base = score;
    //}
    for (int i = 0; i < n -k; i++) {
        if (a[i] < a[i+k])
            cout << "Yes" << endl;
        else
            cout << "No" << endl;
    }
    
    return 0;
}


Measured memory_bytes: 4800
#include <bits/stdc++.h>
using namespace std;
int main(void){
    string ABCD;
    cin >> ABCD;

    int A = int(ABCD[0]-'0');
    int B = int(ABCD[1]-'0');
    int C = int(ABCD[2]-'0');
    int D = int(ABCD[3]-'0');
    //cout << A + B + C + D << endl;
    if(A + B + C + D == 7){cout << A << "+" << B << "+" << C << "+" << D <<"=7"<<endl;return 0;}
    if(A + B + C - D == 7){cout << A << "+" << B << "+" << C << "-" << D <<"=7"<<endl;return 0;}
    if(A + B - C + D == 7){cout << A << "+" << B << "-" << C << "+" << D <<"=7"<<endl;return 0;}
    if(A + B - C - D == 7){cout << A << "+" << B << "-" << C << "-" << D <<"=7"<<endl;return 0;}
    if(A - B + C + D == 7){cout << A << "-" << B << "+" << C << "+" << D <<"=7"<<endl;return 0;}
    if(A - B + C - D == 7){cout << A << "-" << B << "+" << C << "-" << D <<"=7"<<endl;return 0;}
    if(A - B - C + D == 7){cout << A << "-" << B << "-" << C << "+" << D <<"=7"<<endl;return 0;}
    if(A - B - C - D == 7){cout << A << "-" << B << "-" << C << "-" << D <<"=7"<<endl;return 0;}

}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String [] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int [] a  = new int [N];
		for(int i=0; i<N; i++){
			a[i] = sc.nextInt();
		}
		int konkansize = 0;
		//??????????????????
		boolean flag = true;
		while(flag){
			flag = false;
			for(int j=N-1; j>0; j--){
				if(a[j] < a[j-1]){
					int ste = a[j];
					a[j] = a[j-1];
					a[j-1] = ste;  
					konkansize++;
					flag = true;
				}
			}
		}
		for(int i=0; i<N-1; i++){
			System.out.print(a[i] + " ");
		}
		System.out.println(a[N-1]);
		System.out.println(konkansize);
		sc.close();
	}
}

Measured memory_bytes: 26244