akhauriyash/Code-Regression huggingface dataset:
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"sort"
	"strconv"
)

//Util
func nextStr() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func maxInt(a, b int) int {
	if a > b {
		return a
	} else {
		return b
	}
}

func minInt(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}

func absInt(a int) int {
	if a >= 0 {
		return a
	} else {
		return -a
	}
}

func absFloat64(a float64) float64 {
	if a >= 0 {
		return a
	} else {
		return -a
	}
}

func maxFloat64(a, b float64) float64 {
	if a > b {
		return a
	} else {
		return b
	}
}

func minFloat64(a, b float64) float64 {
	if a > b {
		return b
	} else {
		return a
	}
}

func str2Int(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}

func reverse(s string) string {
	runes := []rune(s)
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return string(runes)
}

func powInt(p, q int) int {
	return int(math.Pow(float64(p), float64(q)))
}

func isPrime(x int) bool {
	if x == 1 {
		return false
	}
	if x == 2 {
		return true
	}
	if x%2 == 0 {
		return false
	}

	b := true
	rootx := int(math.Sqrt(float64(x)))
	i := 3
	for i <= rootx {
		if x%i == 0 {
			b = false
			break
		}
		i += 2
	}
	return b
}

func PrimeFactors(n int) (pfs []int) {
	// Get the number of 2s that divide n
	for n%2 == 0 {
		pfs = append(pfs, 2)
		n = n / 2
	}

	// n must be odd at this point. so we can skip one element
	// (note i = i + 2)
	for i := 3; i*i <= n; i = i + 2 {
		// while i divides n, append i and divide n
		for n%i == 0 {
			pfs = append(pfs, i)
			n = n / i
		}
	}

	// This condition is to handle the case when n is a prime number
	// greater than 2
	if n > 2 {
		pfs = append(pfs, n)
	}

	return
}

func sumInts(x []int) int {

	total := 0
	for _, v := range x {
		total += v
	}

	return total
}

//Main
const (
	initialBufSize = 10000
	maxBufSize     = 1000000
	mod            = 1e9 + 7
)

var (
	sc *bufio.Scanner = func() *bufio.Scanner {
		sc := bufio.NewScanner(os.Stdin)
		buf := make([]byte, initialBufSize)
		sc.Buffer(buf, maxBufSize)
		return sc
	}()
)

var N int

func main() {
	sc.Split(bufio.ScanWords)

	N = nextInt()
	a := make([]int, 3*N)
	for i := 0; i < 3*N; i++ {
		a[i] = nextInt()
	}
	sort.Ints(a)

	ans := 0
	for i := 0; i < N; i++ {
		ans += a[3*N-2-2*i]
	}

	fmt.Println(ans)
}


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

using namespace std;
#define inf             0x3f3f3f3f
#define INF             2e18
#define eps             1e-9

#define FastRead        ios_base::sync_with_stdio(0);cin.tie(0)
#define fRead           freopen("input.txt","r",stdin)
#define fWrite          freopen("output.txt","w",stdout)

#define LL              long long
#define ull            unsigned long long
#define PI              acos(-1.0)
#define pb              push_back
#define mk              make_pair
#define pii             pair<int,int>
#define pLL             pair<LL,LL>
#define ff              first
#define ss              second
#define all(a)          a.begin(),a.end()
#define SQR(a)          ((a)*(a))
#define min3(a,b,c)     min(a,min(b,c))
#define max3(a,b,c)     max(a,max(b,c))
#define min4(a,b,c,d)   min(min(a,b),min(c,d))
#define max4(a,b,c,d)   max(max(a,b),max(c,d))
#define max5(a,b,c,d,e) max(max3(a,b,c),max(d,e))
#define min5(a,b,c,d,e) min(min3(a,b,c),min(d,e))
#define vi              vector <int>
#define vL              vector <LL>
#define LB(a,x)         (lower_bound(all(a),x)-a.begin()) //  first element in the range [first,last) which does not compare less than val.
#define UB(a,x)         (upper_bound(all(a),x)-a.begin()) //  first element in the range [first,last) which compares greater than val.
#define prec(n)         fixed << setprecision(n)

#define MEM(a,x)        memset(a,x,sizeof(a))
#define SORT(v)         sort(v.begin(),v.end())
#define REV(v)          reverse(v.begin(),v.end())
#define Unique(a)       sort(all(a)),a.erase(unique(all(a)),a.end())

#define FOR(i,a,b)      for(int i=a;i<=b;i++)
#define ROF(i,a,b)      for(int i=a;i>=b;i--)
#define REP(i,b)        for(int i=0;i<b;i++)
#define IT(it,x)	    for(it=x.begin();it!=x.end();it++)
int main()
{
    string s;
    cin>>s;
    int cnt=0;
    string st1=s;
    reverse(all(st1));
    if(st1==s)
        cnt++;
    string st2="";
    int n=s.size();
    for(int i=0; i<(n-1)/2; i++)
        st2+=s[i];

//    cout<<st2;
//    cout<<endl;
    string st21=st2;
    reverse(all(st21));
    if(st2==st21)
        cnt++;
    string st3="";
    for(int i=(n+3)/2-1; i<n; i++)
        st3+=s[i];
//    cout<<st3<<endl;
    string st32=st3;
    reverse(all(st32));
    if(st3==st32)
        cnt++;
    if(cnt==3)
        cout<<"Yes";
    else
        cout<<"No";

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define downque(que) priority_queue<ll> que;
#define upque(que) priority_queue<ll, vector<int>, greater<int>> que;
typedef long long ll;
typedef vector<vector<int>> Matrix;
const int MOD = 1e9 + 7;
const int MAX = 1e7;
const int INF = numeric_limits<int>::max();

int main(){
  int x; cin>>x;
  vector<bool> b(100004,1);
  REP(i,100004)b[i]=1;
  for(int i=2; i<332; i++){
    for(int j=2*i; j<=100003; j+=i){
      b[j]=0;
      }
  }
  int res=0;
  FOR(i,1,100004){
    if(b[i]&&i>=x){
      res=i; break;
    }
  }
  cout<<res<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
//素数判定

int Prime(int x){
  int i;

  if(x < 2)
    return 0;
  else if(x == 2)
    return 1;
  if(x%2 == 0)
    return 0;

  for(i=3; i*i<=x; i+=2){
    if(x%i==0)
      return 0;
  }
  return 1;
}

int main(){
  int n, x, i;
  int cnt=0;

  scanf("%d", &n);

  for(i=0; i<n; i++)
  {
    scanf("%d", &x);
    if(Prime(x))
    cnt++;
  }

  printf("%d\n", cnt);

  return 0;
}



Measured memory_bytes: 2064
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <climits>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <vector>
#include <list>
#include <ext/rope>
#define rep(i,m,n) for(i=m;i<=n;i++)
#define rsp(it,s) for(set<int>::iterator it=s.begin();it!=s.end();it++)
#define vi vector<int>
#define pii pair<int,int>
#define mod 1000000007
#define inf 0x3f3f3f3f
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define ll long long
#define pi acos(-1.0)
const int maxn=2e3+10;
const int dis[4][2]={{0,1},{-1,0},{0,-1},{1,0}};
using namespace std;
using namespace __gnu_cxx;
ll gcd(ll p,ll q){return q==0?p:gcd(q,p%q);}
ll qpow(ll p,ll q){ll f=1;while(q){if(q&1)f=f*p;p=p*p;q>>=1;}return f;}
int n,m,a[maxn][maxn],mi,cnt;
vi p[maxn];
pii q[maxn];
void dfs(int root,int pre,int now,int s)
{
    a[root][now]=s;
    for(int x:p[now])
    {
        if(x!=pre)dfs(root,now,x,s+1);
    }
}
int main()
{
    int i,j,k,t;
    mi=inf;
    scanf("%d%d",&n,&k);
    rep(i,1,n-1){
        scanf("%d%d",&j,&t);
        p[j].pb(t),p[t].pb(j);
        q[i].fi=j,q[i].se=t;
    }
    rep(i,1,n)dfs(i,-1,i,0);
    rep(i,1,n)
    {
        cnt=0;
        rep(j,1,n)
            if(2*a[i][j]>k)cnt++;
        mi=min(mi,cnt);
    }
    rep(i,1,n-1)
    {
        cnt=0;
        rep(j,1,n)
            if(2*min(a[j][q[i].fi],a[j][q[i].se])+1>k)
                cnt++;
        mi=min(mi,cnt);
    }
    printf("%d\n",mi);
    //system ("pause");
    return 0;
}


Measured memory_bytes: 16256
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

typedef long long lint;

using namespace std;

int main(){
  lint N;
  cin>>N;
  vector<lint> K(N+1,0);
  FOR(i,1,N+1){
    for(lint j=0;j<=N;j+=i){
      K[j]++;
    }
  }
  lint ans=0;
  REP(i,N+1)ans+=i*K[i];
  // REP(i,N)cerr<<i<<" "<<K[i]<<endl;
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 81364
x1,y1,x2,y2=map(int,input().split())
x3,y3,x4,y4=100,100,100,100
if y2-y1==0 or x2-x1==0:
  if x2>x1:
    x3=x2
    y3=y2+(x2-x1)
    x4=x1
    y4=y3
  elif y2>y1:
    x3=x1-(y2-y1)
    y3=y2
    x4=x3
    y4=y1
  elif x1>x2:
    x3=x2
    y3=y2+(x2-x1)
    x4=x1
    y4=y3
  elif y1>y2:
    x3=x1-(y2-y1)
    y3=y2
    x4=x3
    y4=y1

else:
  if x2>x1 and y2>y1:
    x3=x2-(y2-y1)
    y3=y2+(x2-x1)
    x4=x3-(x2-x1)
    y4=y3-(y2-y1)
  elif x2<x1 and y2>y1:
    x3=x2-(y2-y1)
    y3=y2-(x1-x2)
    x4=x3+(x1-x2)
    y4=y3-(y2-y1)
  elif x2<x1 and y2<y1:
    x3=x2+(y1-y2)
    y3=y2-(x1-x2)
    x4=x3+(x1-x2)
    y4=y3+(y1-y2)
  elif x2>x1 and y1>y2:
    x3=x2+(y1-y2)
    y3=y2+(x2-x1)
    x4=x3-(x2-x1)
    y4=y3+(y1-y2)

print(x3,y3,x4,y4)

Measured memory_bytes: 9256
#include <stdio.h>

char change(int x){
  if(x==0){
    return 'S';
  }else if(x==1){
    return 'H';
  }else if(x==2){
    return 'C';
  }else{
    return 'D';
  }
}

int main(){

  int n,i,j,c[4][14];
  char str[100];

  for(i=0;i<4;i++){
    for(j=0;j<14;j++){
      c[i][j]=0;
    }
  }
  


  scanf("%d",&n); 
  int s;
  for(i=0;i<n;i++){
    scanf("%s %d",str,&s);
    if(str[0]=='S'){
      c[0][s]=1;
    }else if(str[0]=='H'){
      c[1][s]=1;
    }else if(str[0]=='C'){
      c[2][s]=1;
    }else if(str[0]=='D'){
      c[3][s]=1;
    }
  }

  for(j=0;j<4;j++){
    for(i=1;i<14;i++){
      
      if(c[j][i]==0){
	
	printf("%c %d\n",change(j),i);
      }
      } 
  }
  return 0;
}
  

Measured memory_bytes: 596
# include <iostream>
# include <vector>
# include <limits>
# include <algorithm>
# include <map>
# include <string>
using namespace std;

int main() {
	string s;
	cin >> s;
	for (int i = 0; i < s.size(); i++) {
		s[i] -= 3;
		if (s[i] < 65) {
			s[i] += 26;
		}
	}
	cout << s << endl;
}

Measured memory_bytes: 3080
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<set>
#include<map>
#include<queue>
#include<complex>
#include<cmath>

using namespace std;

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

int n;
vector<int> A;

void init(){}

bool input(){
	cin>>n;
	A=vector<int>(n);
	rep(i,n)cin>>A[i];
}

void vecsort(vector<int>& a){sort(a.begin(),a.end());}

void printvec(vector<int> a){
	rep(i,a.size())printf("%d\n",a[i]);
}
void solve(){
	
	vector<int> zero;
	vector<int> one;
	vector<int> other;
	
	rep(i,A.size())if(A[i]==0)zero.push_back(A[i]);
	rep(i,A.size())if(A[i]==1)one.push_back(A[i]);
	rep(i,A.size())if(A[i]!=0 && A[i]!=1)other.push_back(A[i]);
	
	vecsort(zero);
	vecsort(one);
	vecsort(other);
	
	if(zero.size()%2==1){
		if(one.size()==0){
			if(other.size()!=0){
				zero.push_back(other[0]);
				other.erase(other.begin());
				
				swap(zero[zero.size()-1], zero[zero.size()-2]);
			}
		}else{
			zero.push_back(one[0]);
			one.erase(one.begin());
			
			swap(zero[zero.size()-1], zero[zero.size()-2]);
		}
	}
	
	if(other.size()>=2){
		if(other[other.size()-1]==3 && other[other.size()-2]==2){
			swap(other[other.size()-1], other[other.size()-2]);
		}
	}
	printvec(other);
	printvec(zero);
	printvec(one);
}

int main(){
	init();
	input();
	solve();
}

Measured memory_bytes: 1204
#include<cstdio>
#include<algorithm>

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

using namespace std;

struct Disk{ int x,y,r,c; };

int n;
Disk D[24];

char dp[1<<24];
int overlap[24];

int dfs(int used){
	if(~dp[used]) return dp[used];

	int nc[4]={},top[4][6];
	rep(i,n) if((used&(1<<i))==0 && (overlap[i]&used)==overlap[i]) {
		top[D[i].c][nc[D[i].c]++]=i;
	}

	int ans=0;
	rep(c,4) rep(j,nc[c]) rep(i,j) {
		ans=max(ans,dfs(used|(1<<top[c][i])|(1<<top[c][j]))+2);
	}
	return dp[used]=ans;
}

#define sq(x) ((x)*(x))
#define sqsum(x,y) (sq(x)+sq(y))

int main(){
	for(;scanf("%d",&n),n;){
		rep(S,1<<n) dp[S]=-1;
		rep(i,n) scanf("%d%d%d%d",&D[i].x,&D[i].y,&D[i].r,&D[i].c), D[i].c--;

		rep(i,n){
			overlap[i]=0;
			rep(j,i) if(sqsum(D[i].x-D[j].x,D[i].y-D[j].y)<sq(D[i].r+D[j].r)) {
				overlap[i]|=1<<j;
			}
		}

		printf("%d\n",dfs(0));
	}

	return 0;
}

Measured memory_bytes: 16000
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b;cin>>a>>b;
  string s;cin>>s;
  for(int i=0;i<s.size();i++){
    if(i==a){
      if(s[i]!='-'){
        cout<<"No"<<endl;
        return 0;
      }
    }
    else{
      if(s[i]=='-'){
        cout<<"No"<<endl;
        return 0;
      }
    }
  }
  cout<<"Yes"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, x, N) for (int i = x; i < (N); i++)
using namespace std;
int main()
{
    int N;
    string S;
    cin >> N >> S;
    if (N % 2 != 0)
    {
        cout << "No" << endl;
        return 0;
    }
    else
    {
        int m = N / 2;
        vector<char> S1(m), S2(m);
        for (int i = 0; i < m; i++)
        {
            S1[i] = S[i];
        }
        int j = 0;
        for (int i = m; i < N; i++)
        {
            S2[j] = S[i];
            j++;
        }
        for (int i = 0; i < m; i++)
        {
            if (S1[i] != S2[i])
            {
                cout << "No" << endl;
                return 0;
            }
        }
        cout << "Yes" << endl;
    }
}


Measured memory_bytes: 256
//From Naruto to Hokage
//#include <RJ>
#include<bits/stdc++.h>
using namespace std;

#define ll          long long
#define pb          push_back
#define eb          emplace_back
#define endl        '\n'
#define mii         map<ll,ll>
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll)x.size()
#define hell        1000000007
#define INF         (1ll<<60)
#define rep(i,a,b)  for(ll i=a;i<=b;i++)
#define rrep(i,a,b)  for(ll i=a;i>=b;i--)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define time        cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll lcm(ll a, ll b) { return a * (b / gcd(a, b)); }
const int N=100005;
void solve(){
    ll n,m;
    cin>>n>>m;
    char c[n+1][m+1];
    rep(i,1,n) rep(j,1,m) cin>>c[i][j];
    ll dp[n+1][m+1];
    rep(i,0,n) dp[i][0]=0;
    // dp[1][0]=1;
    dp[1][1]=1;
    rep(i,0,m) dp[0][i]=0;
    rep(i,1,n){
        rep(j,1,m){
            if(i==1 && j==1) continue;
            if(c[i][j]=='.') dp[i][j]=(dp[i-1][j]+dp[i][j-1])%hell;
            else dp[i][j]=0;
            // ans=(ans+)
        }
    }
    cout<<dp[n][m];
}
signed main()
{
    ios
    int TESTS=1;
    //cin>>TESTS;
    while(TESTS--){
        solve();
    }
    time
    return 0;
}

Measured memory_bytes: 9088
import java.io.*;
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
        
        final int N = Integer.parseInt(sc.next());
        int[] C = new int[N];
        String p = "";
        String q = "";
        int a = 0;
        int b = 0;
        int lap = 0;
        for (int i = 0; i < N; i++) {
            C[i] = i + 1;
        }
        for (int i = 0; i < N; i++) {
            p += sc.next();
        }
        for (int i = 0; i < N; i++) {
            q += sc.next();
        }
        sc.close();
        
        do {
            lap++;
            String s = "";
            for (int i = 0; i < N; i++) {
                s += C[i];
            }
            if (s.equals(p)) a = lap;
            if (s.equals(q)) b = lap;
        } while (nextPermutation(C));
        
        out.println(Math.abs(a - b));
        
        out.flush();
    }
    
    public static boolean nextPermutation(int[] a) {
        for (int i = a.length - 1; 0 < i; i--) {
            if (a[i - 1] < a[i]) {
                int index = find(a[i - 1], a, i, a.length - 1);
                int temp = a[index];
                a[index] = a[i - 1];
                a[i - 1] = temp;
                Arrays.sort(a, i, a.length);
                return true;
            }
        }
        return false;
    }

    // destより大きい要素の中で最小のもののインデックスを二分探索で探す
    private static int find(int dest, int[] a, int s, int e) {
        if (s == e) {
            return s;
        }
        int m = (s + e + 1) / 2;
        return a[m] <= dest ? find(dest, a, s, m - 1) : find(dest, a, m, e);
    }

}

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

// macros
#define ll long long int
#define pb emplace_back
#define mk make_pair
#define pq priority_queue
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for(int i=((int)(n)-1);i>=0;i--)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define FI first
#define SE second
using namespace std;

//  types
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
typedef pair<double, double> Pd;
 
// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;
const int mod = 1e9 + 7;

// solve
template <class T>bool chmax(T &a, const T &b){if(a < b){a = b; return 1;} return 0;}
template <class T>bool chmin(T &a, const T &b){if(a > b){a = b; return 1;} return 0;}
template <typename T> istream &operator>>(istream &is, vector<T> &vec){for(auto &v: vec)is >> v; return is;}

template<typename T>
struct BIT_{
  int n;
  vector<T> bit;
  BIT_(int n_){
    n = n_;
    bit = vector<T>(n+1, 0);
  }
  void add(int a, T w){
    for(int x = a; x < n; x |= (x + 1)){
      bit[x] += w;
    }
  }
  T sum(int a){
    T res = 0;
    for(int x = a; x >= 0; x = (x & (x + 1)) - 1){
      res += bit[x];
    }
    return res;
  }
};

typedef struct BIT_<int> BITI;
typedef struct BIT_<long long> BITL;

int main(int argc, char const* argv[])
{
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n, q;
  cin >> n >> q;
  BITL bt(n);
  rep(i, q){
    int c;
    cin >> c;
    int x, y;
    cin >> x >> y, x--, y;
    if(c == 0){
      bt.add(x, y);
    }else{
      cout << bt.sum(y-1) - (x > 0 ? bt.sum(x-1): 0) << endl;
    }
  }
	return 0;
}



Measured memory_bytes: 3616
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <queue>
#include <string>

using namespace std;
string s;
int main()
{
	int l, r;
	cin >> s;
	for(int i = 0;i < s.length(); i++)
		if(s[i] =='A')
		{
			l = i;
			break;
		}
	for(int i = s.length() - 1; i >= 0; i--)
		if(s[i] == 'Z')
		{
			r = i;
			break;
		}
	cout << r - l + 1 << endl;
	return 0; 
} 

Measured memory_bytes: 644
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define mp make_pair
#define pb push_back
#define pll pair<ll,ll>
ll INF = 1000000007;


/***************/
 #define amin main
/***************/

ll exp(ll x, ll n)
{if(n==0) return 1;if(n==1) return x%INF;if(n%2==0) return exp((x*x)%INF,n/2); else return(x*exp((x*x)%INF,n/2))%INF;}


int amin()
{
	
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll t,i;
	string k;
	cin>>k;
	for(i=0;i<3;i++)
	{
		cout<<k[i];
	}
	


	
	

	
	


	
	return 0;
}

Measured memory_bytes: 3600
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>

typedef long long unsigned int ll;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

using namespace std;

int main()
{
	int n,ans=0;
	cin >> n;
	vector<int> d(n);

	for (int i = 0; i < n; i++) {
		cin >> d.at(i);
	}

	for (int i = 0; i < n; i++) {
		for (int j = i; j < n-1; j++) {
			ans += d.at(i)*d.at(j + 1);
		}
	}
	cout << ans << endl;

	return 0;
}



Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<ll, int> P;
#define MOD (1000000007ll)
#define l_ength size

int main(void){
	int x,a,b;
	cin >> x >> a >> b;
	cout << ((abs(a-x)<abs(b-x))?"A":"B") << endl;
	return 0;
}

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

int main(){
  int n,l;
  cin>>n;
  vector<int> v;
  for(int i=0; i<2*n; ++i){
    cin>>l;
    v.push_back(l);
  }
  sort(v.begin(),v.end());
  int s;
  s=0;
  for(int i=0; i<2*n; i+=2){
    s+=v[i];
  }
  cout<<s<<endl;
  return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) throws IOException {
        FastScanner in = new FastScanner();
        int a = in.nextInt();
        int b = in.nextInt();
        String S = in.nextLine();
        boolean hyphen = false;




        int count =0;
        for (int j =0 ; j < S.length()-1; j++ )
        {
            if(S.charAt(j)=='-')
            {
                count++;
            }
        }

        if (count == 1 && S.charAt(a)=='-')
        {
            hyphen = true;
        }

        else
            {
                System.out.println("No");
                System.exit(0);

            }

        if (hyphen == true)
        {
            if (S.length()-2 == a+b-1)
            {
                System.out.println("Yes");
            }
        }
        else
            {
                System.out.println("No");
            }


        }







    public static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner(String s) {
            try {
                br = new BufferedReader(new FileReader(s));
            } catch (FileNotFoundException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }

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

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

        String nextLine() {
            st = null;
            try {
                return br.readLine();
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            return null;
        }

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

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

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


Measured memory_bytes: 23124
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
      String[] nyu=sc.nextLine().split(" ");

  //   String nyu=sc.nextLine();
int A=Integer.parseInt(nyu[0]);
int B=Integer.parseInt(nyu[1]);
//int C=Integer.parseInt(nyu);


//double A=Double.parseDouble(nyu[0]);
//double B=Double.parseDouble(nyu[1]);
/*
switch(C){
case 7:
case 5:
case 3:
System.out.println("YES") ;
break;
default:
System.out.println("NO") ;

break;
}
*/

int num[]=new int[3];

num[0]=A+B;
num[1]=A-B;
num[2]=A*B;
Arrays.sort(num);

System.out.println(num[2]);



	}
}

Measured memory_bytes: 21844
A = [list(map(int, input().split())) for _ in range(3)]
N = int(input())
b = [int(input()) for _ in range(N)]

for i in b:
    for j in A:
        if i in j:
            A[A.index(j)][j.index(i)] = -1
for i in range(3):
    if A[i][0] == A[i][1] == A[i][2] == -1 or A[0][i] == A[1][i] == A[2][i] == -1:
        print('Yes')
        exit()
if A[0][0] == A[1][1] == A[2][2] == -1 or A[0][2] == A[1][1] == A[2][0] == -1:
    print('Yes')
    exit()
print('No')


Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <bitset>
#include<vector>
#include<utility>
#include<fstream>
#include<queue>
#include <iomanip>
using namespace std;
typedef long long ll;
#define rep(i,k) for(i=0;i<k;i++)
#define P pair<ll,ll>
int s[2005];
int t[2005];
ll i, a, b, c,n,m, z;
int day[1005], pos[1005];
vector<int> ss[100000];
vector<int> tt[100000];
int main() {
	cin >> n;




	cout << n*n*n;
}

Measured memory_bytes: 4992
declare function require(x: string): any;

const loop = (arr: number[]): number => {
  if (arr.every((x) => x % 2 == 0)) {
    return 1 + loop(arr.map((x) => x / 2));
  } else {
    return 0;
  }
};

const main = (input: string[][]) => {
  const a: number[] = input[1].map(Number);
  console.log(loop(a));
};

const whole_input: string = require('fs').readFileSync('/dev/stdin', 'utf8');

main(whole_input.split('\n').map((s: string) => s.split(' ')));


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

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

  vector<tuple<string, int, int>> review(N);
  for (int i = 0; i < N; i++) {
    string S;
    int P;
    cin >> S >> P;
    review.at(i) = make_tuple(S, -P, i+1);
  }

  sort(review.begin(), review.end());

  for (int i = 0; i < N; i++) {
    cout << get<2>(review.at(i)) << endl;
  }
}

Measured memory_bytes: 256
#pragma comment(linker, "/STACK:102400000,102400000")
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cmath>
#include <string>
#include <vector>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <sstream>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#define lson root<<1,l,mid
#define rson root<<1|1,mid+1,r
#define Key_Value ch[ch[root][1]][0]
#define DBN1(a)           cerr<<#a<<"="<<(a)<<"\n"
#define DBN2(a,b)         cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<"\n"
#define DBN3(a,b,c)       cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<"\n"
#define DBN4(a,b,c,d)     cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<"\n"
#define DBN5(a,b,c,d,e)   cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<", "<<#e<<"="<<(e)<<"\n"
#define DBN6(a,b,c,d,e,f) cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<", "<<#e<<"="<<(e)<<", "<<#f<<"="<<(f)<<"\n"
#define clr(a,x) memset(a,x,sizeof(a))
using namespace std;
typedef long long ll;
const int maxn=1e5+5;
const int INF=0x3f3f3f3f;
const int P=1000000007;
const double PI=acos(-1.0);
template<typename T>
inline T read(T&x){
    x=0;int _f=0;char ch=getchar();
    while(ch<'0'||ch>'9')_f|=(ch=='-'),ch=getchar();
    while(ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar();
    return x=_f?-x:x;
}
/*int n;
int a[maxn],b[maxn],c[maxn];
vector<int>vec;
ll ma[maxn*3],mc[maxn*3];
int main(){
    read(n);
    for (int i=1;i<=n;i++) read(a[i]),vec.push_back(a[i]);
    for (int i=1;i<=n;i++) read(b[i]),vec.push_back(b[i]);
    for (int i=1;i<=n;i++) read(c[i]),vec.push_back(c[i]);
    sort(vec.begin(),vec.end());
    vec.erase(unique(vec.begin(),vec.end()),vec.end());
    for (int i=1;i<=n;i++){
        int pos=lower_bound(vec.begin(),vec.end(),a[i])-vec.begin();
        pos++;
        ma[pos]++;
    }
    for (int i=1;i<=n;i++){
        int pos=lower_bound(vec.begin(),vec.end(),c[i])-vec.begin();
        pos++;
        mc[pos]++;
    }
    for (int i=1;i<=3e5;i++) ma[i]+=ma[i-1],mc[i]+=mc[i-1];
    ll ans=0;
    for (int i=1;i<=n;i++){
        int pos=lower_bound(vec.begin(),vec.end(),b[i])-vec.begin();
        pos++;
        ans+=ma[pos-1]*(mc[300000]-mc[pos]);
    }
    cout<<ans<<endl;
    return 0;
}*/
ll n,x;
int main(){
    read(n);
    for (x=1;;x++){
        if (x*x>n) return printf("%lld\n",(x-1)*(x-1))*0;
    }
    return 0;
}


Measured memory_bytes: 256
n=int(input())
arr=list(map(int,input().split()))
if n==0:
  if arr[0]==1:
    print(1)
  else:
    print(-1)
  exit()
acum=[arr[0]]
for i in range(1,n+1):
  acum.append(acum[-1]+arr[i])
b=[0]*n
b[0]=1-arr[0]
b[0]=min(b[0],acum[n]-acum[0])
for i in range(1,n):
  b[i]=2*b[i-1]-arr[i]
  b[i]=min(b[i],acum[n]-acum[i])
for i in range(n):
  if b[i]<=0:
    print(-1)
    exit()
  if b[i]<=30 and arr[i+1]>2**b[i]:
    print(-1)
    exit()
ans=sum(arr)+sum(b)
print(ans)

Measured memory_bytes: 650836
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }

// ================================================= //

/*
 update(s,t,x): [s,t) をxに変更する。
 find(s,t): [s,t) の最小値を出力する。
 */

const ll INIT = INT_MAX;
struct SegTree {
    int N;
    ll init_v;
    vector<ll> node, lazy;
    
    SegTree(int _N):init_v(INIT) {
        N = 1;
        while (N < _N) N *= 2;
        node.resize(2 * N - 1, init_v);
        lazy.resize(2 * N - 1, -1);
    }
    
    void lazy_evaluate(int k) {
        if (lazy[k] == -1) return;
        node[k] = lazy[k];
        if (k < N - 1) {
            lazy[2 * k + 1] = lazy[k];
            lazy[2 * k + 2] = lazy[k];
        }
        lazy[k] = -1;
    }
    
    /* [a,b) 引数の範囲に注意!! s~tまでを更新→update(s,t+1,~) */
    ll update(int a, int b, int x) { return update(a, b, 0, 0, N, x); }
    ll update(int a, int b, int k, int l, int r, int x) {
        if (r <= a || b <= l) {
            lazy_evaluate(k); // nodeの値を見るときは必ず遅延評価を更新する
            return node[k]; // updateでは全体の中の最小を見つける必要があるため, [l,r)外になっても値を参照
        }
        if (a <= l && r <= b) {
            lazy[k] = x;
            lazy_evaluate(k);
            return node[k];
        }
        else {
            lazy_evaluate(k);
            ll vl = update(a, b, 2 * k + 1, l, (l + r) / 2, x);
            ll vr = update(a, b, 2 * k + 2, (l + r) / 2, r, x);
            return node[k] = min(vl, vr);
        }
    }
    
    /* [a,b) 引数の範囲に注意!! */
    ll query(int a, int b) { return query(a, b, 0, 0, N); }
    ll query(int a, int b, int k, int l, int r) {
        if (r <= a || b <= l) return init_v;
        if (a <= l && r <= b) {
            lazy_evaluate(k);
            return node[k];
        }
        else {
            lazy_evaluate(k);
            ll vl = query(a, b, 2 * k + 1, l, (l + r) / 2);
            ll vr = query(a, b, 2 * k + 2, (l + r) / 2, r);
            return min(vl, vr);
        }
    }
};



int main(void) {
    cin.tie(0); ios::sync_with_stdio(false);
    int n,q; cin >> n >> q;
    SegTree ST(n);
    while(q--){
        int com,x,y; cin >> com >> x >> y;
        if(com == 0){
            ST.update(x,x+1,y);
        }else{
            cout << ST.query(x,y+1) << endl;
        }
    }
    return 0;
}



Measured memory_bytes: 7036
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
using ll = long long;
typedef pair<int, int> P;
ll Mod = 1000000007;
int main() {
  int N;
  cin >> N;
  ll A[N];
  vector<ll> plus;
  vector<ll> minus;
  ll min_abs = 999999;
  ll sum = 0;
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    sum += abs(A[i]);
    min_abs = min(min_abs,abs(A[i]));
    if (A[i] >= 0) {
      plus.push_back(A[i]);
    } else {
      minus.push_back(A[i]);
    }
  }

  if ((int)plus.size() == N || (int)minus.size() == N) {
    cout << sum - (min_abs * 2) << endl;
    if ((int)plus.size() == N) {
      sort(plus.begin(),plus.end());
      for (int i = 1; i < (int)plus.size() - 1; i++) {
        cout << plus[i-1] << " " << plus[i] << endl;
        plus[i] = plus[i-1] - plus[i];
      }
      cout << plus[plus.size() - 1] << " " << plus[plus.size() - 2] << endl;
    } else {
      sort(minus.begin(),minus.end());
      reverse(minus.begin(),minus.end());
      for (int i = 1; i < (int)minus.size() - 1; i++) {
        cout << minus[i-1] << " " << minus[i] << endl;
        minus[i] = minus[i-1] - minus[i];
      }
      cout << minus[minus.size() - 2] << " " << minus[minus.size() - 1] << endl;
    }
  } else {
    cout << sum << endl;
    swap(plus[0],minus[0]);
    for (int i = 1; i < (int)plus.size(); i++) {
      cout << plus[i-1] << " " << plus[i] << endl;
      plus[i] = plus[i-1] - plus[i]; 
    }
    for (int i = 1; i < (int)minus.size(); i++) {
      cout << minus[i-1] << " " << minus[i] << endl;
      minus[i] = minus[i-1] - minus[i];
    }
    cout << minus[(int)minus.size() - 1] << " " << plus[(int)plus.size() - 1] << endl;
  }
  return 0;
}

Measured memory_bytes: 5012
import collections
import math
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
N = int(input())
A = list(map(int,input().split()))
B = collections.Counter(A)
num = 0
for i in set(A):
    if B[i] > 1:
        num += combinations_count(B[i], 2)
for i in A:
    print(num-B[i]+1)

Measured memory_bytes: 34144
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    var list = MyLinkedList<Int>()


        for (i in 1..n) {
            val input: List<String> = readLine()!!.split(" ")

        when (input[0]) {
            "insert" -> {
                list.insert(Integer.parseInt(input[1]))
            }
            "delete" -> {
                list.delete(Integer.parseInt(input[1]))
            }
            "deleteFirst" -> {
                list.deleteFirst()
            }
            "deleteLast" -> {
                list.deleteLast()
            }
        }

        }
    println(list)
    }

class MyLinkedList<T> {
    private val nil: Element = Element(null)
    init {
        nil.next = nil
        nil.prev = nil
    }

    fun insert(value: T) {
        val element = Element(value)
        element.next = nil.next
        nil.next?.prev = element
        nil.next = element
        element.prev = nil
    }

    fun delete(value: T) {
        var element = nil.next
        while (element != nil) {
            if (element?.value == value) {
                element?.prev?.next = element?.next
                element?.next?.prev = element?.prev
                return
            }
            element = element?.next
        }
    }

    fun deleteFirst() {
        val element = nil.next
        nil.next = element?.next
        element?.next?.prev = nil
    }

    fun deleteLast() {
        val element = nil.prev
        nil.prev = element?.prev
        element?.prev?.next = nil
    }

    override fun toString(): String {
        var element = nil.next
        val strBuilder = StringBuilder()
        while (element != nil) {
            strBuilder.append(element?.value)
            strBuilder.append(" ")
            element = element?.next
        }
        strBuilder.deleteCharAt(strBuilder.lastIndex)
        return strBuilder.toString()
    }

    inner class Element(val value: T?) {
        var prev: Element? = null
        var next: Element? = null
    }
}



Measured memory_bytes: 336772
#include <random>
#include "bits/stdc++.h"

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;
constexpr ld eps = 1e-12;
constexpr int inf = numeric_limits<int>::max() / 2;
constexpr ll mod = 1e9 + 7;
mt19937_64 rnd{random_device()()};

template <typename T>
void printv(const vector<T> &v) {
  int sz = v.size();
  for (int i = 0; i < sz; i++) {
    cout << v[i] << " \n"[i == sz - 1];
  }
}

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

  ll n, k;
  cin >> n >> k;
  vector<int> a(n);
  const int MAX_N = 200010;
  vector<vector<int>> pos(MAX_N);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    pos[a[i]].push_back(i);
  }
  if (n == 1) {
    if (k % 2) {
      cout << a[0] << endl;
    }
    return 0;
  }
  // npos[i] := i 番目から始めるとどこで終わるか
  vector<int> npos(n);
  for (int i = 0; i < n; i++) {
    // cout << "!" << a[i] << ":";
    // printv(pos[a[i]]);
    auto itr = upper_bound(pos[a[i]].begin(), pos[a[i]].end(), i);
    if (itr != pos[a[i]].end()) {
      npos[i] = *itr;
      // cout << i << " " << npos[i] << endl;
      continue;
    }
    npos[i] = pos[a[i]][0];
    // cout << i << " " << npos[i] << endl;
  }
  // printv(npos);
  ll cycle = 1, cur = 0;
  while (true) {
    if (cur == n) {
      break;
    }
    if (npos[cur] <= cur) {
      cycle++;
      cur = npos[cur] + 1;
      continue;
    }
    cur = npos[cur] + 1;
  }
  // cout << "cycle:" << cycle << endl;
  k %= cycle;
  if (k == 0) {
    return 0;
  }
  assert(k <= n);
  cycle = 1;
  cur = 0;
  while (true) {
    if (cur == n) {
      break;
    }
    if (cycle == k) break;
    if (npos[cur] <= cur) {
      cycle++;
      cur = npos[cur] + 1;
      continue;
    }
    cur = npos[cur] + 1;
  }
  // cout << cur << endl;
  set<int> st;
  vector<int> ans;
  for (int i = cur; i < n; i++) {
    if (st.count(a[i]) == 0) {
      st.insert(a[i]);
      ans.push_back(a[i]);
      continue;
    }
    while (ans.back() != a[i]) {
      st.erase(ans.back());
      ans.pop_back();
    }
    st.erase(a[i]);
    ans.pop_back();
  }
  printv(ans);
}


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

int main() {
  int h, w, k;
  cin >> h >> w >> k;
  vector<string> v(h);
  for (auto& e : v) cin >> e;

  int r = 0;
  for (int a = 0; a < (1 << h); a++) {
    for (int b = 0; b < (1 << w); b++) {
      int x = 0;
      for (int i = 0; i < h; i++) {
        if (a >> i & 1) continue;
        for (int j = 0; j < w; j++) {
          if (b >> j & 1) continue;
          if (v[i][j] == '#') x++;
        }
      }
      if (x == k) r++;
    }
  }
  cout << r << endl;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define mod 1000000007
#define pb push_back
#define pii pair<ll,ll>
#define pi pair<int ,int> 
#define REP(i,a,n) for(int i=a;i<n;i++)
#define rep(i,a,n) for(int i=a;i>=n;i-- )
//ll dp[26][26];ll dp2[26];
ll power(ll x,ll y)
{   if(y==0){return 1;}
    ll ans=power(x,y/2)%mod;
    ans=((ans%mod)*(ans%mod))%mod;
    return (y%2==0)?(ans%mod):(ans*x)%mod;
}

ll ncr(ll x,ll y)
{
    if(y>x-y){y=x-y;}
    ll ans=1;
    for(ll i=0;i<y;i++)
    {
        ans=(ans*(x-i))%mod;
        ll temp=power(i+1,mod-2);
        temp=(temp+mod)%mod;
        ans=((ans%mod)*(temp%mod))%mod;
    }
    return ans%mod;
}
int main() {
      ll n,a,b;
      cin>>n>>a>>b;
      ll ans1=0;
      ans1=(ans1%mod+(power(2,n))%mod)%mod;
      ll ans2=0,ans3=0;
      //ans1=(ans1-1)%mod;
      ans2=ncr(n,a)%mod;
      
      if(b+a==n){ans3=ans2;}
      else{ans3=ncr(n,b)%mod;}
      ll ans4=(ans1%mod-ans2%mod-ans3%mod-1%mod+mod+mod+mod+mod)%mod;
      if(ans4==0){cout<<"0";}
      else{cout<<ans4%mod;}
      
       
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int main()
{
  for(;;){
    vector<int> v(5);
    cin >> v[0];
    if(v[0] == 0) break;
    bool b1,b2,b3;
    b1 = b2 = b3 = false;
    switch(v[0]){
    case 1: b1 = true; break;
    case 2: b2 = true; break;
    case 3: b3 = true; break;
    }
    for(int i=1; i<5; i++){
      cin >> v[i];
      switch(v[i]){
      case 1: b1 = true; break;
      case 2: b2 = true; break;
      case 3: b3 = true; break;
      }
    }
    if(b1 && b2 && b3 || !b1 && !b2 || !b1 && !b3 || !b2 && !b3){
      for(int i=0; i<5; i++) cout << 3 << endl;
      continue;
    }
    if(b1 && b2){
      for(int i=0; i<5; i++){
        if(v[i] == 1) cout << 1 << endl;
        else cout << 2 << endl;
      }
      continue;
    }
    if(b1 && b3){
      for(int i=0; i<5; i++){
        if(v[i] == 3) cout << 1 << endl;
        else cout << 2 << endl;
      }
      continue;
    }
    if(b2 && b3){
      for(int i=0; i<5; i++){
        if(v[i] == 2) cout << 1 << endl;
        else cout << 2 << endl;
      }
      continue;
    }
  }
  return 0;
}

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

int main() {
  int n; cin>>n;
  vector<int>veca(n);
  vector<int>vecb(n);
  int suma=0;
  int sumb=0;
  for(int i=0;i<n;i++){
    cin>>veca[i];
    suma+=veca[i];
  }
  for(int i=0;i<n;i++){
    cin>>vecb[i];
  }
  
  if(n==1) cout<<veca[0]+vecb[0]<<endl;
  else if(n==2){
    cout<<max(veca[0]+veca[1]+vecb[1],veca[0]+vecb[0]+vecb[1])<<endl;
  }
  else{
    sumb=vecb[n-1];
    vector<int>vecans(n);
    for(int i=0;i<n;i++){
      vecans[i]=suma+sumb;
      suma-=veca[n-1-i];
      sumb+=vecb[n-2-i];
    }
    sort(vecans.begin(),vecans.end());
    reverse(vecans.begin(),vecans.end());
    cout<<vecans[0]<<endl;
  }
}

    
  


Measured memory_bytes: 256
/* ***********************************************
Author        :taciturnity
Created Time  :2020/2/21 8:23:51
File Name     :TEST.cpp
************************************************ */

#include <iostream>
#include <vector>
#include <queue>
#include <cstdio>
#include <map>
#include <set>
#include <stack>
#include <string>
#include <cmath>
#include <bitset>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#define ll long long
#define INF 0x3f3f3f3f
#define rep(i,x,y) for(int i = x;i <= y;++i)
#define fori(i,x,y) for(int i = x;i >= y; -- i)
#define bug puts("--------------")
#define out(x) cout<<x<<'\n';
inline char gc(){char op[2];scanf("%s",op);return op[0];}
const int N = 2e5+10;
const double eps = 0.00000001;
const ll mod = 1e9 + 7 ;
using namespace std;
ll read()
{
    ll x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
map<int,int> hap;
int a[N];
int main(){
    int n = read();
    rep(i,1,n) a[i] = read(),hap[a[i]] ++;
    ll ans = 0;
    for(auto p = hap.begin();p!=hap.end();++p){
        ll d = p ->second;
        ans += (d-1)*d/2;
    }
    rep(i,1,n){
        ll d = hap[a[i]];
        ll tmp = ans;
        tmp -= d*(d-1)/2;
        d --;
        tmp += (d-1)*d/2;
        cout<<tmp<<endl;
    }
}

Measured memory_bytes: 8320
#include <iostream>
#include <cstring>

using namespace std;
#define S 100000

int main(){
  int l,count1=0,count2=0;
  //cin >> n;
  
  char a[S];
  
    cin >> a;
	l = strlen(a);
  	//cout << l << endl;
  char b[l],c[l];
  char i[]="0",j[]="1";
    
  	for(int k =0; k<l;k++){
      b[k] = i[0];
      c[k] = j[0];
      if(i[0] == '1'){
        i[0] = '0';
      }else{
        i[0]= '1';
      }
      if(j[0] == '1'){
        j[0] = '0';
      }else{
        j[0] = '1';
      }
    }
  
  	for(int k = 0; k<l;k++){
      if(a[k] !=b[k]){
        count1++;
        //cout << b[k] << endl;
      }
      if(a[k] !=c[k]){
        count2++;
      }
    }
  
  	int result;
  	result = min(count1,count2);
  	cout << result << endl;
  return 0;
}
    

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

#define SORT(c) sort((c).begin(), (c).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
#define ANS(ans) cout << (ans) << endl;
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
typedef vector<int> VI;
typedef pair<int, int> P;

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

// 座標 corrdinate と深さを保持するための構造体
struct Corr {
  int y;
  int x;
  int depth;
};

int H, W;
int s_y, s_x, g_y, g_x;     // スタート，ゴールの座標
int y, x, depth;            // キューから取り出した座標
vector<string> vec;         // 座標を受け取る配列
vector<string> vec_origin;  // 座標を受け取る配列

queue<Corr> q;
int max_depth;

VI y_vec = {0, 0, -1, +1};
VI x_vec = {-1, +1, 0, 0};

int bfs() {
  while (!q.empty()) {
    Corr now = q.front();
    q.pop();  // キューの先頭を取り出す
    y = now.y, x = now.x,
    depth = now.depth;  // 行，列が y, x になっているので注意

    max_depth = max(max_depth, depth);
    // 上下左右 4 方向を探索．進むことができればキューに格納する．
    for (int i = 0; i < 4; ++i) {
      Corr next = {y + y_vec[i], x + x_vec[i], depth + 1};
      if (0 <= next.y && next.y <= H - 1 && 0 <= next.x && next.x <= W - 1 &&
          vec[next.y][next.x] == '.') {
        vec[next.y][next.x] = 'x';  // 同じ場所を探索しないようにする
        q.push(next);
      }
    }
  }
  return 0;
}

int main() {
  cin >> H >> W;
  vec_origin.resize(H);
  vec.resize(H);
  REP(i, H) {
    cin >> vec_origin[i];
  }
  

  int ans = 0;
  REP(i, H) {
    REP(j, W) {
      if (vec_origin[i][j] == '.') {
        max_depth = 0;
        vec = vec_origin;
        vec[i][j] = 'x';
        Corr start = {i, j, 0};
        q.emplace(start);
        bfs();
        ans = max(ans, max_depth);
      }
    }
  }

  ANS(ans);

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <vector>
#include <cassert>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <utility>
#include <tuple>
#include <regex>
#include <map>

using namespace std;
using ull = unsigned long long;

int main() {
	int N, K;
	string S;
	cin >> N >> K >> S;

	if (S.length() == 1) {
		cout << 1 << endl;
		return 0;
	}

	// 色分けする(連続数で配列にする)	
	vector<int> vec;
	int now = 1;
	int cnt = 0;

	for (size_t i = 0; i < S.length(); i++) {
		if (S[i] == (char)(now + '0')) { // int型の1をcharの'1'に変える手順
			// 同じ文字が続けばカウントアップ
			cnt++;
		} else {
			// 違う文字がでたらカウントを格納して、違う文字をカウント1から数えなおす
			vec.push_back(cnt);
			now = now xor 1; // 1と排他的論理和すると0と1が反転する。
			cnt = 1;
		}
	}
	// 最後のcntが格納できないので後始末する
	if (cnt != 0) {
		vec.push_back(cnt);
	}
	// 1の連続数, 0の連続数, 1の連続数, 0の連続数となっている。最後を常に1の連続数にする
	// 最後に1が0個連続していることにするため0を入れる。
	if (vec.size() % 2 == 0) {
		vec.push_back(0);
	}

	// 累積和を作る
	vector<int> sums(vec.size()+ 1);
	for (size_t i = 0; i < vec.size(); i++) {
		sums[i + 1] = sums[i] + vec[i];
	}

	int ans = 0;
	// 累積和を使って範囲の値を取り出しながら範囲のleft, rightを動かす
	for (size_t i = 0; i < vec.size(); i += 2) { // leftは2ずつ動かせばいい
		// leftはiでよい
		int left = i;
		// rightは目いっぱい動かす
		int right = min((int)vec.size(), left + (K * 2 + 1));
		
		// 累積和の右から左を引けば範囲の和が取れる
		int tempSum = sums[right] - sums[left];

		// 大きければ更新する
		ans = max(ans, tempSum);
	}

	cout << ans << endl;

	return 0;
}

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

bag =[]
for i in range(1000):
    ans = str(i)    
    if len(ans) == N:
        for j in range(M):
            if ans[S[j][0]-1] != str(S[j][1]):
                break
        else:# インナーループがbreakで終了しなかった
            print(i)
            break
else:#for文の二重ループがbreakで終わらなかった
    print(-1)

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

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;
using std::bitset;

#define rep(i,n)    for(int i=0; i<(int)n; i++)
#define reps(i,s,e) for(int i=s; i<(int)e; i++)
#define coutd(i) cout << std::fixed << std::setprecision(i)
typedef long double ld;
typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef std::pair<int, int> pii;
typedef std::pair<ll, ll> pll;

template<class T>
using Set = std::set<T>;
template<class T, class U>
using Map = std::map<T, U>;

template<class T>
using Graph = vector<vector<T>>;

const int INT_BIG = 1<<28;

int main() {
    ll a;
    ld b;
    cin >> a >> b;
    cout << (ll)std::floor(a * b) << endl;
}

Measured memory_bytes: 3716
def main():
    import bisect

    a, b, q = map(int, input().split())
    INF = float('inf')
    s = [-INF] + [int(input()) for _ in range(a)] + [INF]
    t = [-INF] + [int(input()) for _ in range(b)] + [INF]
    x = [int(input()) for _ in range(q)]

    for i in x:
        si = bisect.bisect_left(s, i)
        ti = bisect.bisect_left(t, i)
        sl, sr = i-s[si-1], s[si]-i
        tl, tr = i-t[ti-1], t[ti]-i
        print(min(max(sl,tl), sl+tr+min(sl,tr), sr+tl+min(sr,tl), max(sr,tr)))

main()

Measured memory_bytes: 20876