akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
#define max3(a, b, c) max(a, max(b, c))
#define min3(a, b, c) min(a, min(b, c))
#define gcd(x,y) __gcd(x,y)
#define PI 3.14159265
#define endl "\n"
#define count_ones __builtin_popcountl
#define piii pair<int,pair<int,int>>
const int N=1e5+20,MOD=(int)(1e9)+7;
const int oo = 0x3f3f3f3f;
typedef long long ll;
using namespace std;
ll modPower(ll x, ll y,ll p){
    ll res=1;
    x%=p;
    while(y>0){
        if(y&1) res=(res*x)%p;
        y=y>>1; //divide by 2
        x=(x*x)%p;
    }
    return res;
}
void boost(){
	ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
}
ll GCD(ll a, ll b){
	if(a==0)return b;
	return GCD(b%a,a);
}
/* -------------------------------------- */
ll primeFactors(ll n)  
{ 
	ll cnt = 0; 
    for (ll i = 1; i <= sqrt(n); i++) { 
        if (n % i == 0) { 
            if (n / i == i) 
                cnt++; 
  
            else cnt = cnt + 2; 
        } 
    } 
    return cnt; 
}  
/* -------------------------------------- */
int main() {
	boost();
	int n;cin>>n;ll a[n+1],b[n];
	for(int i=0;i<n+1;i++){
		cin>>a[i];
	}
	for(int i=0;i<n;i++)cin>>b[i];int i=0, j=0;ll sum=0;
	while(j<n){
		int temp1=a[i],temp2=b[j];
		a[i] = max(0, temp1-temp2);
		b[j]= max(0,temp2-temp1);
		sum+= min(temp2,temp1);
		i++;
		temp1=a[i],temp2=b[j];
		a[i] = max(0,temp1-temp2);
		b[j] = max(0,temp2-temp1);
		sum+=min(temp1,temp2);
		j++;
	}
	cout<<sum;
}

Measured memory_bytes: 1792
N,L=(int(x) for x in input().split())
def val(i):
    return L+i

S = 0
for i in range(N):
    S+=val(i)

ans=0
err=max(abs(val(0)),abs(val(N-1)),abs(S))*2
for i in range(N):
    tmp = S - val(i)
    tmp_err = abs(tmp-S)
    if tmp_err < err:
        ans = tmp
        err = tmp_err
print(ans)

Measured memory_bytes: 3064
#include <stdio.h>
#include <math.h>

int main(void){
	int n, i, j, cnt;
	while(scanf("%ld", &n) != EOF){
		int sq_num = (int)sqrt((double)n);
		int *prime = (int *)malloc(sizeof(int) * n);
		
		for(i = 0; i < n; i++){
			prime[i] = 1;
		}
		prime[0] = 0;
		
		for(i = 1; i < sq_num; i++){
			if(prime[i] == 1){
				for(j = (i + 1); (i + 1)*j <= n; j++){
					prime[(i + 1) * j -1] = 0;
				}
			}
		}
		
		cnt = 0;
		
		for(i = 0; i < n; i++){
			if(prime[i] == 1){
				cnt++;
			}
		}
		
		printf("%d\n", cnt);
	}
	
	return 0;
}

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

#define y1 aklsdja
#define ii pair < int , int >
#define iii pair < int , ii >
#define iv pair < ii , ii >

#define fi first
#define se second
#define pb push_back
#define t top()
#define fr front()

#define FOR(i , x , n) for(int i = x ; i <= n ; ++i)
#define REP(i , x) for(int i = 0 ; i < x ; ++i)
#define FORD(i , x , n) for(int i = x ; i >= n ; --i)

#define oo 1e17 + 5
#define ll long long
#define int long long
#define pow poww

const int N = 4e2 + 5;
int n;
int a[N] , sum[N];
int dp[N][N];

main()
{
    //freopen("N.inp","r",stdin);
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> n;
    FOR(i , 1 , n)
    {
        cin >> a[i];
        sum[i] = sum[i - 1] + a[i];
    }
    FOR(i , 1 , n)
        FOR(j , 1 , n)
            dp[i][j] = oo;
    FOR(i , 1 , n)
        dp[i][i] = 0;
    FOR(r , 1 , n)
        FORD(l , r - 1 , 1)
        {
            FOR(k , l , r - 1)
                dp[l][r] = min(dp[l][r] , dp[l][k] + dp[k + 1][r] + sum[r] - sum[l - 1]);
        }
    cout << dp[1][n];
}


Measured memory_bytes: 1664
def LI(): return [int(x) for x in input().split(" ")]
def LS(): return [str(x) for x in input().split(" ")]
def ItoS(L): return [int(x) for x in L]
def StoI(L): return [str(x) for x in L]


def solve():
    a, b, c, d = LI()
    l, r = a + b, c + d
    if l > r:
        print("Left")
    elif r > l:
        print("Right")
    else:
        print("Balanced")


solve()

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mod 1000000007
#define MAX 100000
void inarray(int a[], int n){
    for(int i = 0; i < n; i++) cin >> a[i];
}

int main(){
    int x; cin >> x;
    ll ans = (x/500)*1000 + ((x-(x/500)*500)/5)*5;
    cout << ans << endl;
    return 0;
}

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

int main(){
	string s;
	cin >> s;
	int len = s.size();
	bool frag = true;
	for (int i = 0;i<len;i += 2){
		if(s[i] == 'L') frag = false;
	}
	for(int i=1;i<len; i +=2){
		if(s[i] == 'R') frag = false;
	}


	if(frag){
		cout <<"Yes"<<endl;
	}else{
		cout << "No" <<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
     int N,D;
     cin >> N >> D;
     vector<vector<int>> X(N,vector<int>(D));
     for(int i = 0; i < N; i++){
          for(int j = 0; j < D; j++){
               cin >> X[i][j];
          }
     }

     int ans = 0;
     for(int i = 0; i < N; i++){
          for(int j = i + 1; j < N; j++){
               int y = 0;
               for(int l = 0; l < D; l++){
                    int d = abs(X[i][l] - X[j][l]);
                    y += d*d;
               }

               bool judge = false;
               for(int k = 0; k <= y; k++){
                    if(k*k == y){
                         judge = true;
                    }
               }
               if(judge) ans++;
          }
     }
     cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define MOD 1000000007
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 1
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
 
lli convert[26];
 
signed main(){
 
	string s,t;
	cin>>s>>t;
 
	map<char,lli> ss,tt;
	REP(i,0,s.size()){
		ss[s.at(i)]++;
		tt[t.at(i)]++;
	}
 
	multiset<lli> sC,tC;
	for(auto e:ss){
		sC.insert(e.second);
	}
 
	for(auto e:tt){
		tC.insert(e.second);
	}
 
	if(sC.size()!=tC.size()){
		cout<<"No"<<endl;
		return 0;
	}
	auto itr1 = sC.begin();
	auto itr2 = tC.begin();
 
	while(itr1!=sC.end()){
		if((*itr1)!=(*itr2)){
			cout<<"No"<<endl;
			return 0;
		}
		itr1++;
		itr2++;
	}
	cout<<"Yes"<<endl;
 
	return 0;
}

Measured memory_bytes: 776
def main():
    n, m = map(int, input().split())
    a = list(map(int, input().split()))
    sum_a = sum(a)
    cnt =0
    for i in a:
        if i >= sum_a/(4 * m):
            cnt += 1
    if cnt >= m:
        print("Yes")
    else:
        print("No")
 
if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
N, M = map(int, input().split())
AB = [list(map(int, input().split())) for _ in range(M)]

U = [0] * (N + 2)
for A, B in AB:
  U[A + 1] += 1
  U[B + 1] -= 1
#print("U:", U)

for u in U:
  if u % 2:
    print("NO")
    exit()
print("YES")

Measured memory_bytes: 60888
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; ++i)
#define ALL(v) v.begin(), v.end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100000000;

int main()
{
	int w,h,x,y;
	cin >> w >> h >> x >> y;
	cout<<(double)(w)*(double)(h)/2.0<<' ';
	if(w==x*2&&h==y*2)
	{
		cout<<1<<endl;
	}
	else
	{
		cout<<0<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.*;
public class Main{
public static void main(String[] args) {
	Scanner sc=new Scanner(System.in);
	    long N=sc.nextLong();
	      long D=sc.nextLong();
	      int count=0;
	      while(N>0){
	      long X1=sc.nextLong();
	        long Y1=sc.nextLong();
	        double distance=Math.sqrt(X1*X1+Y1*Y1);
	          if(distance<=D){
	            count++;
	          }
	      N--;
	      }
	      System.out.println(count);
	    }
	  
}

Measured memory_bytes: 60368
import java.util.*;

public class Main{
	public static void main(String[] args){
		String input = new Scanner(System.in).nextLine();
		String[] num = input.split("\\s");
		int a = Integer.parseInt(num[0]);
		int b = Integer.parseInt(num[1]);
		System.out.println(a * b + " " + 2 * (a + b));
	}
}

Measured memory_bytes: 26132
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<ll>; using VVI = vector<VI>; using VVVI = vector<VVI>;
const int inf=1e9+7;
const ll INF=1LL<<60;
const ll mod=1e9+7;



struct UnionFind {
    int n, cnt;
    vector<int> par, rank, sz;

    UnionFind(int n) : n(n), cnt(n), par(n), rank(n), sz(n, 1) {
        iota(par.begin(), par.end(), 0);
    }

    int find(int x) {
        if (x == par[x]) return x;
        return par[x] = find(par[x]);
    }

    bool same(int x, int y) {
        return find(x) == find(y);
    }

    int size(int x) {
        return sz[find(x)];
    }

    void unite(int x, int y) {
        x = find(x), y = find(y);
        if (x == y) return;
        if (rank[x] < rank[y]) {
            par[x] = y;
            sz[y] += sz[x];
        } else {
            par[y] = x;
            sz[x] += sz[y];
            if (rank[x] == rank[y]) {
                rank[x]++;
            }
        }
        cnt--;
    }
};



int main(){
  int i,j;
  int n;
  cin>>n;
  ll d[n][n];
  vector<P> v;
  UnionFind  uf(2*n);
  for(i=0;i<n;i++){
      string s;
      cin>>s;
      for(j=0;j<n;j++){
          d[i][j]=s[j]-'0';
          if(d[i][j]==0&&i!=j) d[i][j]=inf;
          if(d[i][j]==1) {
              uf.unite(i,j+n);
              uf.unite(i+n,j);
          }
      } 
  }
  for(int k=0;k<n;k++){
      for(i=0;i<n;i++){
          for(j=0;j<n;j++){
              d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
          }
      }
  }

  for(i=0;i<n;i++){
      if(uf.same(i,i+n)) {
          cout<<-1<<endl;
          return 0;
      }
  }

  int s=-1,t=-1,c=-1;

  for(i=0;i<n;i++){
      for(j=0;j<n;j++){
          if(c<d[i][j]){
              c=d[i][j];
              s=i;
              t=j;
          } 
      }
  }

    cout<<c+1<<endl;
    return 0;
}

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

int main(void)
{
	int N, K;
	cin >> N >> K;
	int D[10] = {0};
	for (int i = 0; i < K; i++) {
		int d;
		cin >> d;
		D[d] = 1;
	}

	int ans = N;
	for(;;) {
		int n = ans;
		bool kirai = false;
		while (n > 0) {
			if (D[n%10]==0) {
				n /= 10;
				continue;
			}
			else {
				kirai = true;
				break;
			}
		}
		if (!kirai) break;
		ans++;
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#define MOD 1000000007
using namespace std;

string s;

int main() {
    cin >> s;
    for (auto c: s) {
        if (c == ',') {
            cout << ' ';
        } else {
            cout << c;
        }
    }
    cout << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
    using namespace std;
    #define tani_nachi_ke  ios_base::sync_with_stdio(false); cin.tie(NULL);
    #define M_PI 3.14159265358979323846
    int main()
    {
    //  clock_t begin = clock();
    //  #ifndef ONLINE_JUDGE
    //  freopen("input.txt", "r", stdin);
    //  freopen("output.txt", "w", stdout);
    //  #endif
   tani_nachi_ke  
    string s,t;
    cin>>s>>t;
    int n=s.size(),m=t.size();
    int dp[n+1][m+1];
    memset(dp,0,sizeof(dp));
    for(int i=1; i<=n; i++)
    {
      for(int j=1; j<=m; j++)
      {
        if(s[i-1]==t[j-1])
        {
          dp[i][j]=dp[i-1][j-1]+1;
        }
        else 
          {
            dp[i][j]=max(dp[i][j-1],dp[i-1][j]);
          }
      }
    }
    // for(int i=1; i<=n; i++)
    // {
    //   for(int j=1; j<=m; j++)cout<<dp[i][j]<<" ";
    //   cout<<endl;
    // }
    int i=n,j=m;
    string ans="";
    while(i>0&&j>0)
    {
      if(s[i-1]==t[j-1])
        {
          ans.push_back(s[i-1]);
          i--;j--;
        }
      else
      {
        if(dp[i-1][j]>dp[i][j-1])
        {
          i--;
        }
        else j--;
      }
    }
    reverse(ans.begin(),ans.end());
    // cout<<dp[n][m]<<endl;
    cout<<ans<<endl;

    
  
    // #ifndef ONLINE_JUDGE 
    // clock_t end = clock();
    // cout<<endl<<double(end - begin) / CLOCKS_PER_SEC*1000<<" ms";
    // #endif 
    // return 0;
}






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

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

const long long mod = 2;

int main(){
    int n;
    cin >> n;
    vi a(n);
    rep(i, n) cin >> a[i];
    vi b(n);
    rep1r(i, n) {
        int cnt = 0;
        for (int j=i; j<=n; j+=i) {
            cnt += b[j-1];
        }
        if (cnt%2 != a[i-1]) {
            b[i-1] = 1;
        }
    }
    vi ans;
    rep(i, n) if (b[i] == 1) ans.pb(i+1);
    int m = sz(ans);
    cout << m << endl;
    rep(i, m) printf("%d%c", ans[i], (i<m-1?' ':'\n'));
    return 0;
}


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

Measured memory_bytes: 4396
k, a, b = map(int, input().split())
ans = 0
if b >= a + 2:
    ans += a
    k = k - (a - 1)
    if k % 2:
        ans += 1
    ans += (k // 2) * (b - a)
else:
    ans += k + 1
print(ans)

Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main() {
	int H, W;
	cin >> H >> W;
	vector<vector<char>> A(H, vector<char>(W));
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			cin >> A[i][j];
		}
	}
	for (int i = 0; i < W + 2; i++) {
		cout << '#';
	}
	cout << endl;
	for (int i = 0; i < H; i++) {
		cout << '#';
		for (int j = 0; j < W; j++) {
			cout << A[i][j];
		}
		cout << '#' << endl;
	}
	for (int i = 0; i < W + 2; i++) {
		cout << '#';
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 3580
#include <stdio.h>
int main()
{
  int i,j,n,A[100],minj,count=0,temp,flag=1;

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

  for(i=0;i<n;i++)
    {
      minj=i;
      for(j=i;j<n;j++)
	{
	  if(A[j] < A[minj])
	    {
	      minj=j;
	      flag=0;
	    }
	}
      temp=A[i];
      A[i]=A[minj];
      A[minj]=temp;
      if(flag == 0)
	{
	  count++;
	  flag=1;
	}
    }

  for(i=0;i<n;i++)
    {
      if(i == n-1)
	{
	  printf("%d\n%d\n",A[i],count);
	}
      else
	{
	  printf("%d ",A[i]);
	}
    }

  return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <set>

using namespace std;
const double PI = (acos(-1));
const long long MOD = pow(10, 9) + 7;
long long kaizyou(int N);
long long POW(int J);

bool judge(int dt, int dx, int dy);

int main()
{
    int A,B;
    cin >> A >> B;
    
    if(A >= 13)
    {
        cout << B;
    }else if(A >= 6 && 12 >= A)
    {
        cout << B/2;
    }else
    {
        cout << 0;
    }
    
    
}


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

int main() {
	string s;cin>>s;
  int n = s.size();
  rep(i,n/2){
    if(s.at(i)!=s.at(n-i-1)){
      cout <<"No";
      return 0;
    }
  }
  rep(i,n/2){
    if(s.at(i)!=s.at(n/2-i-1)){
      cout <<"No";
      return 0;
    }
  }
  rep(i,(n-3)/2){
    if(s.at((n+3)/2+i-1)!=s.at(n-i-1)){
      cout <<"No";
      return 0;
    }
  }
    cout << "Yes";
  
  
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.PriorityQueue;
import java.util.Set;
import java.util.StringTokenizer;

public class Main {
  public static void main(String[] args) {
	  FastReader sc = new FastReader();
	  int a = sc.nextInt();
	  int b = sc.nextInt();
	  int c = sc.nextInt();
	  int d = sc.nextInt();
	  int e = sc.nextInt();
	  int k = sc.nextInt();
	  
	  if (e - a <= k) {
		  System.out.println("Yay!");
	  } else {
		  System.out.println(":(");
	  }
	  
  }
  
  static class FastReader {
    BufferedReader br;
    StringTokenizer st;

    public FastReader() {
      br = new BufferedReader(new InputStreamReader(System.in));
    }
  
    String next() { 
      while (st == null || !st.hasMoreElements()) {
        try {
          st = new StringTokenizer(br.readLine());
        } catch (IOException  e) {
          e.printStackTrace();
        }
      }
      return st.nextToken();
    }

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

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

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

    String nextLine() {
      String str = "";
        try{
            str = br.readLine();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return str;
      }
  }
}


Measured memory_bytes: 20948
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define pb push_back
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef multiset<ll> S;
typedef priority_queue<ll> PQ;
typedef priority_queue<P,vector<P>,greater<P>> SPQ;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
const ll inf=1001001001001001;
const int INF=1001001001;
const int mod=1000000007;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<endl;}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<endl;}
template<class T> void outvp(T v){rep(i,v.size())outp(v[i]);}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<endl;}
template<class T> void outvv(T v){rep(i,v.size()){rep(j,v[i].size()){if(j)cout<<' ';cout<<v[i][j];}cout<<endl;}}
ll gcd(ll a,ll b){
    if(b==0)return a;
    return gcd(b,a%b);
}
ll modpow(ll a,ll b){
    a%=mod;
    if(b==0)return 1;
    if(b&1)return a*modpow(a,b-1)%mod;
    ll k=modpow(a,b/2);
    return k*k%mod;
}
int main(){
    bool d=false;
  int a,b,c;cin>>a>>b>>c;
    if(a==b&&b!=c)d=true;
    if(a==c&&b!=c)d=true;
    if(c==b&&a!=c)d=true;
    if(d)out("Yes");
    else out("No");
}


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

int main() {
  int n;
  cin >> n;
  vector<int> w(n);
  int sum = 0;
  for(int i = 0; i < n; i++) {
    cin >> w.at(i);    
    sum += w.at(i);
  }
  int sum2 = 0;
  int sum3 = 0;
  for(int i = 0; i < n; i++) {
    sum2 += w.at(i);
    if(sum2 >= sum / 2) {
      break;
    }
    sum3 = sum2;
  }
  
  int ans = min(abs(sum-2*sum2), abs(sum-2*sum3));
  //cout << sum2 << ' ' << sum3 << endl;
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
 int a,b;
 int i;
 int flg;
 int first=1;

 while(1){
  flg=0;
  scanf("%d %d",&a,&b);
  if(a==0 && b==0)break;

  if(first)first=0;
  else printf("\n");

  for(i=a;i<=b;i++)
   if((i%4==0 && i%100!=0) || (i%4==0 && i%400==0)){printf("%d\n",i);flg=1;}
   
  if(flg==0)printf("NA\n");

 }


return 0;
}


Measured memory_bytes: 2104
#include<iostream>
using namespace std;
int main(){
	long long a,b=1,count=1,s=1;
	cin>>a;
	count+=(a-1)/11*2;
	s=(a-1)/11;
	b=(a-1)%11;
	if(s%2==0){
		if(b>5){
			count++;
		}
	}
	if(s%2==1){
		if(b>6){
			count++;
		}
	}
	cout<<count<<endl;
	return 0;
}

Measured memory_bytes: 384
fs = require('fs');
input = fs.readFileSync('/dev/stdin', 'utf8');
tmp = input.split(' ');
X = parseInt(tmp[0],10);
Y = parseInt(tmp[1],10);
for(i=0; i<=X; i++) {
  if(i*4 + (X-i)*2 == Y) { console.log('Yes'); return; }
  if(i*4 + (X-i)*2 == Y) { console.log('Yes'); return; }
}
console.log('No');

Measured memory_bytes: 29616
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7 # 998244353
input=lambda:sys.stdin.readline().rstrip()
from collections import defaultdict
def resolve():
    n=int(input())
    A=list(map(int,input().split()))
    D=defaultdict(int)
    for a in A: D[a]+=1

    m=max(A)
    B=list(range(m//2+1,m+1))*2
    if(m&1==0): B.append(m//2)

    for b in B:
        if(D[b]==0):
            print("Impossible")
            return
        D[b]-=1

    s=min(B)
    for key,val in D.items():
        if(val==0): continue
        if(not (s+1<=key<=m)):
            print("Impossible")
            return

    print("Possible")
resolve()

Measured memory_bytes: 38896
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i = (a); i <= (b); i++)
#define rng(a) a.begin(), a.end()
#define ina(n,a) cin >> n; for(int i = 1; i <= n; i++) cin >> a[i]
#define sz(x) (int)(x).size()
#define se second
#define fi first
#define prev            coyhhhhhhyoc    
#define next          sdNNNmNNNNNNNmds  
#define y0           hNNNNy_yNNNNNN_sNh
#define y1          mNNNNNdtdNNNNNNtsNNm
#define yn          mNNNNNNNNy___smNNNms
#define tm            oooooosyysooooot 
#define read               tyhyt        
#define rank              ytmNmo         
#define index              yyy
#define pb push_back
#define pcnt __builtin_popcountll
#define rrep(i,a,b) for(int i = (b); i >= (a); i--)
#define rall(x,a) for(auto x : a)
#define MOD 1000000007
#define endl "\n"
typedef long long ll;
using namespace std;

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    string s;
    int ans;
    cin >> s;
    if(s == "SUN") ans = 7;
    if(s == "MON") ans = 6;
    if(s == "TUE") ans = 5;
    if(s == "WED") ans = 4;
    if(s == "THU") ans = 3;
    if(s == "FRI") ans = 2;
    if(s == "SAT") ans = 1;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;
using namespace std;
 
#define ff                  first
#define ss                  second
#define endl                "\n"
#define loop(i,s,e)         for(int i=s;i<e;i++)
#define int                 long long
#define vi                  vector<int> 
#define S(v)                sort(v.begin(),v.end())
#define RS(v)               sort(v.rbegin(),v.rend())
#define R(v)                reverse(v.begin(),v.end())
#define mxpq(T)             priority_queue <T>
#define mnpq(T)             priority_queue<T,vector<T>,greater<T>>
#define prv(v)              for(auto &x : v)cout << x << " ";
#define piirv(v)            for(auto &x : v)cout << x.ff << " " << x.ss << endl;
#define prvv(v)             for(auto &x : v)for(auto &y : x.ss)cout << y << " ";
#define mp                  make_pair
#define pii                 pair<int,int>
#define mset(a,f)           memset(a , f , sizeof(a))
#define pb                  push_back
#define inf                 INT_MAX
#define INF                 LLONG_MAX
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> oset;
 
const int N = 2e6 + 6;
const int M = 1e9+7;
int A[N];
int vis[N];
int n , m;

vector<vector<int> > vec;

int dfs( int s) 
{
      vis[s] = 1;
      int ans = 1;
      for( auto &it : vec[s] )
      {     
      	if(!vis[it])ans += dfs(it);
      }

      return ans;
}

void solve()
{
	cin >> n >> m;

	vec.resize(n+1);

	loop(i,0,m)
	{
		int x , y;
		cin >> x >> y;

		vec[x].pb(y);
		vec[y].pb(x);
	}

	int ans = 0;

	loop(i,1,n+1)
	{
		if(!vis[i])
		{
			ans = max(ans , dfs(i));
		}
	}

	cout << ans;
}			
 
int32_t main()
{
 
cout<<fixed<<setprecision(16);
 
ios_base:: sync_with_stdio(false);
cin.tie(NULL); cout.tie(NULL);
 	
 
 	int t = 1;
 	// cin >> t;
 	while(t--)solve();
  
}

Measured memory_bytes: 25136
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin>>s;
  if(s=="KIHBR"||s=="AKIHBR"||s=="KIHABR"||s=="KIHBAR"||s=="KIHBRA"||s=="AKIHABR"||s=="AKIHBAR"||s=="AKIHBRA"||s=="KIHABAR"||s=="KIHABRA"||s=="KIHBARA"||s=="AKIHABAR"||s=="AKIHABRA"||s=="AKIHBARA"||s=="KIHABARA"||s=="AKIHABARA") cout<<"YES";
  else cout<<"NO";
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
for i in range(N):
  if A[i]==0:
    print('0')
    exit()
ans = 1
for i in range(N):
  ans = ans*A[i]
  if ans > 10**18:
    print('-1')
    exit()
print(ans)

Measured memory_bytes: 21524
// Package main provides
//
// File:  d.go
// Author: ymiyamoto
//
// Created on Wed Jan  9 00:08:23 2019
//
package main

import "fmt"

type graph [][]int

func warshalFloyd(g graph) {
	for k := range g {
		for i := range g {
			for j := range g {
				if g[i][k]+g[k][j] < g[i][j] {
					g[i][j] = g[i][k] + g[k][j]
				}
			}
		}
	}
}

func permutation(n int) [][]int {
	if n == 0 {
		return [][]int{[]int{0}}
	}

	perm := permutation(n - 1)
	ret := [][]int{}
	for _, p := range perm {
		for i := 0; i <= len(p); i++ {
			q := make([]int, len(p))
			copy(q, p)
			ret = append(ret, append(q[:i], append([]int{n}, q[i:]...)...))
		}
	}
	return ret
}

func main() {
	var N, M, R int
	fmt.Scan(&N, &M, &R)

	rs := make([]int, R)
	for i := range rs {
		fmt.Scan(&rs[i])
	}

	g := make(graph, N)
	for i := range g {
		g[i] = make([]int, N)
		for j := range g[i] {
			if i != j {
				g[i][j] = 1 << 60
			}
		}
	}

	for i := 0; i < M; i++ {
		var a, b, c int
		fmt.Scan(&a, &b, &c)
		g[a-1][b-1] = c
		g[b-1][a-1] = c
	}

	warshalFloyd(g)
	ans := 1 << 60
	for _, p := range permutation(R - 1) {
		dist := 0
		for i := range p {
			if i+1 < len(p) {
				dist += g[rs[p[i]]-1][rs[p[i+1]]-1]
			}
		}
		if dist < ans {
			ans = dist
		}
	}

	fmt.Println(ans)
}


Measured memory_bytes: 9984
#pragma GCC optimize "trapv"
#include<iostream>
#include <bits/stdc++.h>
using namespace std;
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define ll long long
#define ull unsigned long long
#define ui unsigned int
#define vi vector<int>
#define vll vector<ll>
#define pb push_back
#define ld long double
#define mp make_pair
#define pii pair<int,int>
#define mod 1000000007
#define rep(i,n) for(int i=0;i<n;i++)
#define repp(i,a,n) for(int i=a;i<n;i++)
#define all(v) v.begin(),v.end()
#define input(arr,n) for(ll i1=0;i1<n;i1++ )cin>>arr[i1]
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<ll, null_type,less_equal<ll>, rb_tree_tag,tree_order_statistics_node_update>//s.order_of_key(val) *s.find_by_order(ind)
int main()
{
    fio;
    int t=1;;
    //cin>>t;
    while(t--)
    {
        string s;
        ll cnt=0;
        cin>>s;
        ll sum=0;
        if(s=="RSR" || s=="RSS" || s=="SSR" || s=="SRS")
        cout<<1<<endl;
        else if(s=="RRR")
        cout<<3<<endl;
        else if(s=="SSS")
        cout<<0<<endl;
        else
        cout<<2<<endl;
        //cout<<sum<<endl;
    }
}

Measured memory_bytes: 3620
N = int(input())
Hlist = list(map(int, input().split()))
# 左から右へ　右が左以上ならばカウント　そうでなければ０にもどす
ans = 0
cnt = 0
for i in range(1, N):
    prev = Hlist[i-1]
    if Hlist[i] <= prev:
        cnt += 1
    else:
        ans = max(ans, cnt)
        cnt = 0
 
ans = max(ans, cnt)
print(ans)

Measured memory_bytes: 14252
import * as fs from "fs";

function main(lines: Array<string[]>) {
  const takoyakis = lines[1].map((t) => parseInt(t));
  let point = 0;
  takoyakis.forEach((t1, i1) => {
    takoyakis.forEach((t2, i2) => {
      if (i1 !== i2) point += t1 * t2;
    });
  });
  point /= 2;
  console.log(point);
}

const lines = fs
  .readFileSync("/dev/stdin", "utf8")
  .split("\n")
  .map((l) => l.split(" "))
  .filter((input) => !(input.length === 1 && input[0] === ""));
main(lines);


Measured memory_bytes: 9548
#include <bits/stdc++.h>
// #include "lib.h"
using namespace std;
#define LLINF 1234567890987654321
#define INF 1234567890
#define pb push_back
#define ins insert
#define f first
#define s second
#define db 1-1+1-1+1-1
#define MAXN 3000006
#define rep(kk, l1, l2)for(ll kk = l1; kk < l2; kk++)
typedef long long ll;
typedef pair <ll, ll> pi;
typedef pair <ll, pi> spi;
typedef pair <pi, pi> dpi;
ll N, K, ans, co[200006];
int main()
{
	cin >> N >> K;
	for(ll i = 1; i <= N; i++) co[i%K] ++;
	if(K%2 == 1)
	{
		for(ll i = 1; i <= N; i++)
		{
			if(i%K == 0) ans += co[i%K] * co[i%K];
		}
	}
	else
	{
		for(ll i = 1; i <= N; i++)
		{
			if( ( i%K ) == ( K/2 ) || ( i%K ) == 0)
			{
				ans += co[i%K] * co[i%K];
			}
		}
	}
	cout << ans << "\n";
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rep1(i, n) for (ll i = 1; i <= (n); ++i)
#define rrep(i, n) for (ll i = (n - 1); i >= 0; --i)
#define perm(c) sort(ALL(c));for(bool c##p=1;c##p;c##p=next_permutation(ALL(c)))
#define ALL(obj) (obj).begin(), (obj).end()
#define pb push_back
#define to_s to_string
#define len(v) (ll)v.size()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define print(x) cout << (x) << '\n'
#define drop(x) cout << (x) << '\n', exit(0)
#define debug(x) cout << #x << ": " << (x) << '\n'
using namespace std;
using ll = long long;
typedef pair<ll, ll> P;
typedef vector<ll> vec;
typedef vector<vector<ll>> vec2;
typedef vector<vector<vector<ll>>> vec3;
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; }
ll MOD = 1e9 + 7;
ll devc(ll x, ll y) { return 1 + (x - 1) / y; }

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

    ll N, K;
    cin >> N >> K;
    vec L(N);
    rep(i, N) cin >> L[i];
    sort(L.rbegin(),L.rend());
    ll ans = 0;
    rep(i, K) ans += L[i];
    drop(ans);

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int main()
{
    for(;;){
        int w, h;
        cin >> w >> h;
        if(w == 0)
            return 0;

        vector<string> s(h+1);
        for(int i=1; i<=h; ++i){
            cin >> s[i];
            s[i] = ' ' + s[i];
        }

        vector<vector<string> > best(h+1, vector<string>(w+1));
        string ret;
        for(int i=1; i<=h; ++i){
            for(int j=1; j<=w; ++j){
                if('0' <= s[i][j] && s[i][j] <= '9'){
                    if(best[i-1][j].size() > best[i][j-1].size())
                        best[i][j] = best[i-1][j];
                    else if(best[i-1][j].size() < best[i][j-1].size())
                        best[i][j] = best[i][j-1];
                    else
                        best[i][j] = max(best[i-1][j], best[i][j-1]);
                    best[i][j] += s[i][j];
                    if(best[i][j] == "0")
                        best[i][j] = "";

                    if(best[i][j].size() > ret.size())
                        ret = best[i][j];
                    else if(best[i][j].size() == ret.size())
                        ret = max(ret, best[i][j]);
                }
            }
        }
        cout << ret << endl;
    }
}

Measured memory_bytes: 1016
import java.util.Random;
import java.util.Scanner;

public class Main {
	private static final int K = 26;
	private static final int SEARCH = 1000;
	private static final int CHECK = 30000;
	private static Random rand = new Random(System.currentTimeMillis());

	public static void main(String[] args) {
		var sc = new Scanner(System.in);
		var d = sc.nextInt();
		var c = new int[K];
		var s = new int[d][K];
		for (var i = 0; i < K; i++) {
			c[i] = sc.nextInt();
		}
		for (var i = 0; i < d; i++) {
			for (var j = 0; j < K; j++) {
				s[i][j] = sc.nextInt();
			}
		}
		sc.close();

		var time = System.currentTimeMillis();
		var t = new int[d];
		var max = Integer.MIN_VALUE;
		for (var i = 0; i < SEARCH; i++) {
			if (System.currentTimeMillis() - time > 1000) {
				break;
			}
			var t2 = search(c, s, d);
			var score = score(c, s, t2, d);
			if (score > max) {
				t = t2;
				max = score;
			}
		}

		for (var i = 0; i < d; i++) {
			System.out.println(t[i]);
		}
	}

	private static int[] search(int[] c, int[][] s, int d) {
		var count = 0;
		var t = create(c, s, d);
		for (var i = 0; count < CHECK; i++) {
			for (var j = 1; j < K; j++) {
				count++;
				var mdi = i % d;
				var mti = (t[mdi] + j - 1) % K;
				var check = check(c, s, t, d, mdi, mti);
				if (check > 0) {
					t[mdi] = mti + 1;
					break;
				}
			}
		}

		return t;
	}

	private static int check(int[] c, int[][] s, int[] t, int d, int mdi, int mti) {
		var sum = 0;
		var ti = t[mdi] - 1;
		sum += s[mdi][mti] - s[mdi][ti];

		var last1 = 0;
		var last2 = 0;
		for (var i = mdi - 1; i >= 0; i--) {
			if (t[i] == ti + 1) {
				last1 = i + 1;
				break;
			}
		}
		for (var i = mdi - 1; i >= 0; i--) {
			if (t[i] == mti + 1) {
				last2 = i + 1;
				break;
			}
		}

		var count1 = 1;
		var count2 = 1;
		for (var i = mdi + 1; i < d; i++) {
			if (t[i] == ti + 1) {
				break;
			}
			count1++;
		}
		for (var i = mdi + 1; i < d; i++) {
			if (t[i] == mti + 1) {
				break;
			}
			count2++;
		}
		sum += (mdi - last2 + 1) * c[mti] * count2 - (mdi - last1 + 1) * c[ti] * count1;

		return sum;
	}

	private static int score(int[] c, int[][] s, int[] t, int d) {
		var sum = 0;
		var last = new int[K];
		for (var i = 0; i < d; i++) {
			var ti = t[i] - 1;
			sum += s[i][ti];
			last[ti] = i + 1;
			for (var j = 0; j < K; j++) {
				sum -= ((i + 1) - last[j]) * c[j];
			}
		}

		return sum;
	}

	private static int[] create(int[] c, int[][] s, int d) {
		var t = new int[d];
		var last = new int[K];
		for (var i = 0; i < d; i++) {
			var v = new int[K];
			for (var j = 0; j < K; j++) {
				v[j] = s[i][j] + (((i + 1) - last[j]) * c[j]);
			}
			t[i] = rand(v) + 1;
			last[t[i] - 1] = i + 1;
		}
		return t;
	}

	private static int rand(int[] v) {
		var sum = 0;
		for (var i = 0; i < v.length; i++) {
			sum += v[i];
		}
		var value = rand.nextInt(sum);
		var index = 0;
		sum = 0;
		for (var i = 0; i < v.length; i++) {
			sum += v[i];
			if (value < sum) {
				break;
			}
			index++;
		}
		return index;
	}
}

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

int koyak(int n,int m){
	if(n%m==0){
	return m;
    }else{
    return koyak(m,n%m);
    }
}
int main(){
	int K;
  cin >> K;
  int ans=0;
  for(int i=1;i<K+1;i++){
  	for(int j=1;j<K+1;j++){
    	for(int l=1;l<K+1;l++){
          ans+=koyak(koyak(i,j),l);
        }
    }
  }
  cout << ans<<endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef bool boolean;

#define ll long long

void exgcd(int a, int b, int& x, int& y) {
	if (!b) {
		x = 1, y = 0;
	} else {
		exgcd(b, a % b, y, x);
		y -= (a / b) * x;
	}
}

int inv(int a, int n) {
	int x, y;
	exgcd(a, n, x, y);
	return (x < 0) ? (x + n) : (x);
}

const int Mod = 998244353;

template <const int Mod = :: Mod>
class Z {
	public:
		int v;

		Z() : v(0) {	}
		Z(int x) : v(x){	}
		Z(ll x) : v(x % Mod) {	}

		friend Z operator + (const Z& a, const Z& b) {
			int x;
			return Z(((x = a.v + b.v) >= Mod) ? (x - Mod) : (x));
		}
		friend Z operator - (const Z& a, const Z& b) {
			int x;
			return Z(((x = a.v - b.v) < 0) ? (x + Mod) : (x));
		}
		friend Z operator * (const Z& a, const Z& b) {
			return Z(a.v * 1ll * b.v);
		}
		friend Z operator ~(const Z& a) {
			return inv(a.v, Mod);
		}
		friend Z operator - (const Z& a) {
			return Z(0) - a;
		}
		Z& operator += (Z b) {
			return *this = *this + b;
		}
		Z& operator -= (Z b) {
			return *this = *this - b;
		}
		Z& operator *= (Z b) {
			return *this = *this * b;
		}
		friend boolean operator == (const Z& a, const Z& b) {
			return a.v == b.v;
		} 
};

Z<> qpow(Z<> a, int p) {
	Z<> rt = Z<>(1), pa = a;
	for ( ; p; p >>= 1, pa = pa * pa) {
		if (p & 1) {
			rt = rt * pa;
		}
	}
	return rt;
}

typedef Z<> Zi;

const int N = 1e5 + 5;

int n;
char s[N * 3];

int main() {
	scanf("%d", &n);
	scanf("%s", s + 1);
	int r, g, b, rg, rb, gb;
	r = g = b = 0;
	rg = rb = gb = 0;
	Zi ans = 1;
	for (int i = 1; i <= n; i++)
		ans *= i;
	for (int i = 1; i <= 3 * n; i++) {
		if (s[i] == 'R') {
			if (gb) {
				ans *= gb--;
			} else if (g) {
				ans *= g--;
				rg++;
			} else if (b) {
				ans *= b--;
				rb++;
			} else {
				r++;
			}
		} else if (s[i] == 'G') {
			if (rb) {
				ans *= rb--;
			} else if (r) {
				ans *= r--;
				rg++;
			} else if (b) {
				ans *= b--;
				gb++;
			} else {
				g++;
			}
		} else if (s[i] == 'B') {
			if (rg) {
				ans *= rg--;
			} else if (r) {
				ans *= r--;
				rb++;
			} else if (g) {
				ans *= g--;
				gb++;
			} else {
				b++;
			}
		}
	}
	printf("%d\n", ans.v);
	return 0;
}


Measured memory_bytes: 512
#include<stdio.h>

int main(){
    int num;
    scanf("%d", &num);
    int a, b,c;
    a = num/100;
    b = ((num - (num%10))/10)%10;
    c = num%10;

    if(a == 7 ||  b == 7|| c == 7)printf("Yes\n");
    else printf("No\n");

}

Measured memory_bytes: 1660
a = [list(map(int, input().split())) for l in range(3)]

N = int(input()) 
s = [int(input()) for i in range(N)] 

for nu in range(len(s)):
	for i in range(3):
		for j in range(3):
			if a[i][j] == s[nu]:
				a[i][j] = 0
for r in range(3):
	if a[r][0]==a[r][1]==a[r][2]==0:
		print('Yes')
		exit()
	if a[0][r]==a[1][r]==a[2][r]==0:
		print('Yes')
		exit()

if a[0][0]==a[1][1]==a[2][2]==0	or a[0][2]==a[1][1]==a[2][0]==0:	
		print('Yes')
		exit() 
print('No')
	


Measured memory_bytes: 38384
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define double long double
#define low lower_bound
#define upp upper_bound
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define Rep(i,n) for (int i = (int)(n); i >= 0; i--)
#define all(vec) vec.begin(),vec.end()
#define rever(vec) reverse(all(vec));
#define cend cout << endl;
#define prique(T) priority_queue<T,vector<T>,greater<T>>
struct edge { int to, cost; };
using P = pair<int, int>;
using PP=pair<P, int>;
const int mod = 1e9 + 7, inf = 1e16;

int modpow(int x, int n) {
	int ans = 1;
	while (n > 0) {
		if (n & 1) {
			if (mod <= ans * x) ans = ans * x % mod;
			else ans *= x;
		}
		if (mod <= x * x) x = x * x % mod;
		else x *= x;
		n >>= 1;
	}
	return ans;
}

int fact_memo[114514];
int fact(int n) {
	int ans = 1;
	if (fact_memo[n]) return fact_memo[n];
	rep(i, n) {
		ans *= (i + 1);
		if (mod <= ans) ans %= mod;
		fact_memo[i + 1] = ans;
	}
	return (ans + mod) % mod;
}

int comb(int n, int r) {
	if (n < r) return 0;
	if (n - r < r) r = n - r;
	return (fact(n) * modpow(fact(n - r), mod - 2) % mod * modpow(fact(r), mod - 2) + mod) % mod;
}

int perm(int n, int r) {
	if (n < r) return 0;
	if (n - r < r) r = n - r;
	return (fact(n) * modpow(fact(n - r), mod - 2) % mod + mod) % mod;
}

int gcd(int a, int b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

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

bool pri(int p) {
	for (int i = 2; i * i <= p; i++) if (p % i == 0) return false;
	return p > 1;
}

P operator+(const P& a, const P& b) {
	return P(a.first + b.first, a.second + b.second);
}
P operator-(const P& a, const P& b) {
	return P(a.first - b.first, a.second - b.second);
}

int n, ans;
map<int, int>mp;
signed main() {
	cin >> n;
	rep(i, n) {
		int a;
		cin >> a;
		mp[a]++;
	}
	for (P p : mp) {
		if (p.first == 0) {
			if (n % 2 == 0 || p.second != 1) {
				cout << 0 << endl;
				return 0;
			}
		}
		else {
			if (p.second != 2) {
				cout << 0 << endl;
				return 0;
			}
			ans++;
		}
	}
	cout << modpow(2, ans) << endl;
}

Measured memory_bytes: 4224
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define shandom_ruffle random_shuffle

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);	
	
	int R; cin >> R; cout << 3*R*R << endl;
    return 0;
}

// read the question correctly (ll vs int)
// template by bqi343


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

int main(void){
  string s;
  string t;

  cin >> s >> t;

  int count = 0;
  for(int i=-0; i<s.size(); i++){
     if(s[i] != t[i]) count++;
  }//for
  
  cout << count << "\n";
  
}//main


Measured memory_bytes: 3908
from operator import itemgetter
import heapq

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

A = []
for i in range(N):
  X = list(map(int, input().split()))
  A.append([X[0], -X[1]])
  
A = sorted(A, key=itemgetter(0,1), reverse=False)
#print(A)
# days, values(minus, asc)

Q = []
heapq.heapify(Q)
ans = 0
x = 1
i = 0
while x <= M:
  # A0がxである要素をキューに追加
  if i < N and A[i][0] == x:
    heapq.heappush(Q, A[i][1])
    i += 1
    continue
  else:
    # 最小値（マイナスかけて最大）を答えに追加して、1日進める
    if len(Q) > 0:
      ans += heapq.heappop(Q) * (-1)
    x += 1
      
print(ans)
  

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



int main() {
  ll x;
  cin >> x;
  ll ans=0;
  ans+=(x/11)*2;
  x=x%11;
  if(x>=7){ans+=2;}else if(x>=1)ans++;
  cout << ans << endl;
}

Measured memory_bytes: 256
void main() {
  problem();
}

void problem() {
  auto N = scan!int;
  auto K = scan!int;
  auto Prices = scan!long(N).sort.array;

  long solve() {
    return Prices[0..K].sum;
  }

  solve().writeln;
}

// ----------------------------------------------

import std.stdio, std.conv, std.array, std.string, std.algorithm, std.container, std.range, core.stdc.stdlib, std.math, std.typecons, std.numeric;
T[][] combinations(T)(T[] s, in int m) {   if (!m) return [[]];   if (s.empty) return [];   return s[1 .. $].combinations(m - 1).map!(x => s[0] ~ x).array ~ s[1 .. $].combinations(m); }
string scan(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
T scan(T)(){ return scan.to!T; }
T[] scan(T)(int n){ return n.iota.map!(i => scan!T()).array; }
void deb(T ...)(T t){ debug writeln(t); }
alias Point = Tuple!(long, "x", long, "y");

// -----------------------------------------------


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

using namespace std;

const int inf = 1000000000;

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

	int n;
	cin >> n;

	string s;
	cin >> s;

	vector<vector<int> > G(n);
	for(int i = 0; i < n - 1; ++i) {
		int x, y;
		cin >> x >> y;
		--x; --y;
		G[x].emplace_back(y);
		G[y].emplace_back(x);
	}

	vector<int> dep(n);
	vector<int> dp(n);
	vector<int> sz(n);
	vector<int> Sum(n);

	function<void(int, int)> dfs = [&] (int u, int f) {
		sz[u] = (s[u] == '1');
		dp[u] = 0;
		Sum[u] = dep[u] * (s[u] == '1');
		for(int v : G[u]) {
			if(v != f) {
				dep[v] = dep[u] + 1;
				dfs(v, u);
				int y = min(dp[u], dp[v] + sz[v]);
				dp[u] = dp[u] + dp[v] + sz[v] - 2 * y;
				sz[u] += sz[v];
				Sum[u] += Sum[v];
			}
		}
	};

	int ans = inf;
	for(int i = 0; i < n; ++i) {
		dep[i] = 0;	
		dfs(i, -1);

		int tmp = 0;
		bool ok = true;

		for(int j : G[i]) {
			tmp += dp[j];
		}

		for(int j : G[i]) {
			if(dp[j] + sz[j] > Sum[i] - Sum[j]) {
				ok = false;
			}
		}

		if(ok && Sum[i] % 2 == 0) {
			ans = min(ans, Sum[i] / 2);
		}
	}

	if(ans == inf) {
		cout << -1 << '\n';
	} else {
		cout << ans << '\n';
	}

	return 0;
}


Measured memory_bytes: 3952
//------------------------------------------
// C++ templete 
//------------------------------------------
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
using ll = long long;

#define endl "\n"

//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

//REPEAT
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//container util
//------------------------------------------
#define pb push_back
#define paired make_pair
#define ALL(a) (a).begin(),(a).end()
#define PRINT(V) for (auto v : (V)) cout << v << " "
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())

//constant
//------------------------------------------
const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

//math
//------------------------------------------
int QP(int a,int b){int ans=1;do{if(b&1)ans=1ll*ans*a%MOD;a=1ll*a*a%MOD;}while(b>>=1);return ans;}
int QP(int a,int b,int MOD){int ans=1;do{if(b&1)ans=1ll*ans*a%MOD;a=1ll*a*a%MOD;}while(b>>=1);return ans;}
int GCD(int a,int b){return b?GCD(b,a%b):a;}

//debug
//------------------------------------------
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//動的計画法で役に立つ関数
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

//最大公約数と最小公倍数
ll gcd(ll a, ll b) {
    if(b==0)return a;
    return gcd(b, a%b);
}

ll lcm(ll a, ll b) {
  ll g = gcd(a, b);
  return a/g*b;
}

vector<vector<long long> > comb(int n) {
  vector<vector<long long> > v(n + 1,vector<long long>(n + 1, 0));
  for (int i = 0; i < v.size(); i++) {
    v[i][0] = 1;
    v[i][i] = 1;
  }
  for (int j = 1; j < v.size(); j++) {
    for (int k = 1; k < j; k++) {
      v[j][k] = (v[j - 1][k - 1] + v[j - 1][k]);
    }
  }
  return v;
}

int main() 
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    string S; cin >> S;

    if ((S[0]==S[1] && S[1]==S[2])|| (S[1]==S[2] && S[2] == S[3])) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}



Measured memory_bytes: 256