akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
typedef long long ll;
#define ALL(l)  (l).begin(),(l).end()
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
using namespace std;

//const ll mod =  1000000007;
//const ll maxn = 1000000000;

//---------------------------------------------------------------------------------------------------
using vi = vector<int>; // intの1次元の型に vi という別名をつける
using vll = vector<ll>; // intの1次元の型に vi という別名をつける
using vvll = vector<vll>; // intの2次元の型に vvi という別名をつける
using vs = vector<string>; // stringの1次元の型に vs という別名をつける
using pll = pair<ll, ll>; // これ以降 pii という型名はpair<ll, ll> と同じ意味で使える
//---------------------------------------------------------------------------------------------------
struct UnionFind {
    vector<ll> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(ll N) : par(N) { //最初は全てが根であるとして初期化
        for(ll i = 0; i < N; i++) par[i] = i;
    }

    ll root(ll x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(ll x, ll y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(ll x, ll y) { // 2つのデータx, yが属する木が同じならtrueを返す
        ll rx = root(x);
        ll ry = root(y);
        return rx == ry;
    }
};

int main() {
 ll N, Q,ans=0;
    cin >> N >> Q;
    vll a(N,0);
    UnionFind tree(N);

    for(ll i = 0; i < Q; i++) {
        ll x, y;
        cin  >> x >> y;
        
          
                tree.unite(x-1, y-1);
            
        
    }
    
    rep(i,N){
        a.at(tree.root(i))++;
    }
    rep(i,N){
        ans=max(ans,a.at(i));
    }

cout<<ans<<endl;
 
}



Measured memory_bytes: 12500
//Leonidas
#pragma GCC optimize("Ofast")
//#pragma GCC target ("avx2")
//#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container'.',hpp>
//#include <ext/pb_ds/tree_policy'.',hpp>
//typedef tree < int , null_type, less <int>, rb_tree_tag, tree_order_statistics_node_update> TREE;
#define ll long long
#define ull unsigned long long int
#define pb push_back
#define mp make_pair
#define vi vector<int>
#define pii pair<int,int>
#define pss pair<short,short>
#define pld pair<long double,long double >
#define ld long double
#define piii  pair<pii,int>
#define vii vector<pair<int,int> >
#define st first
#define nd second
#define pll pair<ll,ll>
#define speed ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define M_PI 3.14159265358979323846
#define int long long
const int mod=1000000007;
//const int mod=1009;
//const int mod=998244353;
const int inf=1000000009;
const long long INF=1000000000000000009;
const long long big=1000000000000000;
const long double eps=0.000000000000000000001;
using namespace std;
int32_t main()
{
    speed
    int a;
    cin>>a;
    cout<<a+a*a+a*a*a;
    return 0;
}


Measured memory_bytes: 3652
#include "bits/stdc++.h"

#define REP(i, n, N) for(ll i=(n); i<(N); i++)
#define RREP(i, n, N) for(ll i=(N-1); i>=(n); i--)
#define LREP(lst,itr) for(auto itr = lst.begin(); itr != lst.end(); ++itr)
#define CK(n, a, b) ((a)<=(n)&&(n)<(b))
#define ALL(v) (v).begin(),(v).end()
#define MCP(a, b) memcpy(b,a,sizeof(b))
#define P(s) cout<<(s)<<endl
#define P2(a, b) cout<<(a)<<" "<<(b)<<endl
#define V2(T) vector<vector<T>>
typedef long long ll;
using namespace std;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;

int main(){
    ll N,K,Q;
    cin >> N >> K >> Q;
    vector<ll> score(N,K-Q);
    REP(i,0,Q){
        ll cur;
        cin >> cur;
        score[cur-1]++;
    }   
    REP(i,0,N){
        if(score[i]>0){
            P("Yes");
        }else{
            P("No");
        }
    }
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef pair<int,int> P;
constexpr ll INF = (1LL << 60);

int main() {
  int a, b;
  cin >> a >> b;
  if (a % 3 == 0) {
    cout << "Possible" << endl;
    return 0;
  }
   if (b % 3 == 0) {
    cout << "Possible" << endl;
    return 0;
  }
   if ((a + b) % 3 == 0) {
    cout << "Possible" << endl;
    return 0;
  }
  cout << "Impossible" << endl;
  return 0; 
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    int A,B,sum;
    cin >> A >> B;
  
    sum = 0;
 
    for (int i=A;i<=B;i++) {
        if ((i/10000 == i%10) && ((i/1000) % 10 == (i%100) / 10)) {
  	
  	
            sum ++;
        
        }
    }
  cout << sum << endl;
}

Measured memory_bytes: 256
char s[50][99],*p;d[5]={0,1,0,-1},t[50][50]={1},i,u,v,x,y,f,c,P[1<<17][2];
main(l,h,w){
	for(scanf("%d%d\n",&h,&w);i<h;)for(gets(p=s+i++);*p;)c+=*p++==46;
	for(;f<l;)for(x=P[f][i=0],y=P[f++][1];i<4;u>=0&v>=0&u<h&v<w&&(!t[u][v]||t[u][v]>t[x][y]+1)&&s[u][v]-35&&(t[P[l][0]=u][P[l++][1]=v]=t[x][y]+1))u=x+d[i],v=y+d[++i];
	printf("%d",(f=t[h-1][w-1])?c-f:-1);
}

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

int main() {
  int N,L;
  cin >> N >> L;
  
  int Taste = 0;
    for (int i = 0; i < N; i++){
      Taste += L+i;
    }
   if ( L > 0 )
    Taste -= L;
  else if ( N+L <= 0 )
    Taste -= N+L-1;
  
  cout << Taste << endl;
}

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

using namespace std;

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

    cin >> N >> K >> S;

    if (S[K - 1] == 'A') S[K - 1] = 'a';
    if (S[K - 1] == 'B') S[K - 1] = 'b';
    if (S[K - 1] == 'C') S[K - 1] = 'c';

    cout << S << std::endl;

    return 0;
}

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

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

using ll = long long;
using ld = long double;
ll INF = LLONG_MAX;

using vi = vector<int>;
using vll = vector<ll>;
using pii = pair<int, int>;

namespace output {
	void pr(int x) { cout << x; }
	void pr(long x) { cout << x; }
	void pr(ll x) { cout << x; }
	void pr(unsigned x) { cout << x; }
	void pr(unsigned long x) { cout << x; }
	void pr(unsigned long long x) { cout << x; }
	void pr(float x) { cout << x; }
	void pr(double x) { cout << x; }
	void pr(ld x) { cout << x; }
	void pr(char x) { cout << x; }
	void pr(const char* x) { cout << x; }
	void pr(const string& x) { cout << x; }
	void pr(bool x) { pr(x ? "true" : "false"); }
	template<class T> void pr(const complex<T>& x) { cout << x; }
	
	template<class T1, class T2> void pr(const pair<T1,T2>& x);
	template<class T> void pr(const T& x);
	
	template<class T, class... Ts> void pr(const T& t, const Ts&... ts) { 
		pr(t); pr(ts...); 
	}
	template<class T1, class T2> void pr(const pair<T1,T2>& x) { 
		pr("{",x.f,", ",x.s,"}"); 
	}
	template<class T> void pr(const T& x) { 
		pr("{"); // const iterator needed for vector<bool>
		bool fst = 1; for (const auto& a: x) pr(!fst?", ":"",a), fst = 0; 
		pr("}");
	}
	
	void print() { pr("\n"); } // print w/ spaces
	template<class T, class... Ts> void print(const T& t, const Ts&... ts) { 
		pr(t); if (sizeof...(ts)) pr(" "); print(ts...); 
	}
}

using namespace output;

int main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int N; cin >> N;
	vi arr (N);
	F0R(i, N) cin >> arr[i];
	int X = 0;
	for (int x : arr) X ^= x;
	F0R(i, N) cout << (X ^ arr[i]) << " ";
	cout << endl;
}

Measured memory_bytes: 3960
#include <iostream>
using namespace std;
  
int main() {
    int N;
    long double x[4],y[4];
    cin>>N;
    while(N--){
        for(int i=0;i<4;i++) cin>>x[i]>>y[i];
        long double y1=y[1]-y[0]; long double x1=x[1]-x[0];
        long double y2=y[3]-y[2]; long double x2=x[3]-x[2];
        if(y1*x2==y2*x1) cout<<"YES"<<endl;
        else cout<<"NO"<<endl;
    }
    return 0;
}

Measured memory_bytes: 1224
#include <bits/stdc++.h>
using namespace std;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define int long long
#define ld long double
#define fi first
#define se second
#define all(uiet) uiet.begin(),uiet.end()
#define read(UIET) for(int i = 0; i < n; ++i) cin >> UIET[i]
#define out(UIET) for(int i = 0; i < n; ++i) cout << UIET[i]
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define vpp vector<pair< int, int > >
#define pll pair<int , int >
#define ppll pair < pll , pll >
#define debug(n1) cout << n1 << endl
#define len(a) ((int) (a).size())
#define endl "\n"
#define mod 1000000007
const int INF=(1LL<<60)-1;
bool isPerfectSquare(long double x) {   
    long double sr = sqrt(x); 
    return ((sr - floor(sr)) == 0); 
} 
int32_t main(){
    SPEED;
    int n, k;
    cin >> n >> k;
    int rem = n % k;
    int ans = k - rem;
    cout << min(rem, ans);
}


Measured memory_bytes: 3668
#include<iostream>
#include<list>
#include<vector>
#include<algorithm>
#include<string>
#include<stdio.h>
#include<math.h>
#include<unordered_map>

using namespace std;
using vec = vector<int>;
using mat = vector<vec>;
using lst = list<int>;


bool solve()
{
	int N, M, T;
	cin >> N >> M >> T;

	vec V(T+1, 0);

	for (int i = 0; i < N; ++i)
	{
		int a; cin >> a;

		V[a - M + 1] = 1;
		if (a + M + 1 <= T)
			V[a + M + 1] = -1;
	}

	int ans = 0;

	for (int i = 1; i <= T; ++i)
	{
		V[i] += V[i - 1];
		ans += V[i] == 0;
	}

	cout << ans << endl;

	return true;
}


int main()
{
	solve();

	return 0;
}


Measured memory_bytes: 3140
#include <bits/stdc++.h>
#define sz(c)      int(c.size())
#define rep(i,a,b) for (int i=a; i<(b); ++i)
#define per(i,a,b) for (int i=(b)-1; i>=(a); --i)
using namespace std;
using ll = long long;

int const MAXN=220000;
int N;
int a[MAXN];
int len;
pair<int,int> cur[MAXN];
int psum[MAXN];

bool enough(int size) {
	len=0;
	cur[len++]=make_pair(0,a[0]);
	psum[len-1]=a[0];
	rep(i,1,N) {
		if (a[i]>a[i-1]) {
			if (cur[len-1].first==0) {
				cur[len-1].second+=a[i]-a[i-1];
				psum[len-1]+=a[i]-a[i-1];
			} else {
				cur[len++]=make_pair(0,a[i]-a[i-1]);
				psum[len-1]=psum[len-2]+a[i]-a[i-1];
			}
			continue;
		}

		int pos=int(lower_bound(psum,psum+len,a[i]) - psum);
		assert(pos<len);
		len=pos+1;

		if (psum[pos]>a[i]) {
			cur[pos].second-=psum[pos]-a[i];
			psum[pos]-=psum[pos]-a[i];
		
			assert(cur[pos].second>0);
			assert(psum[pos]==a[i]);
		}

		if (cur[pos].first+1 < size) {
			if (cur[pos].second==1) {
				cur[pos].first++;
				if (pos-1>=0 && cur[pos-1].first==cur[pos].first) {
					cur[pos-1].second++;
					psum[pos-1]++;
					len--;
				}
				continue;
			}

			cur[pos].second--;
			psum[pos]--;
			cur[len++]=make_pair(cur[pos].first+1,1);
			psum[len-1]=psum[pos]+1;
			continue;
		}

		if (pos==0) return false;

		cur[pos].first=0;

		if (cur[pos-1].second==1) {
			cur[pos-1].first++;
			if (pos-2>=0 && cur[pos-2].first==cur[pos-1].first) {
				cur[pos-2].second++;
				psum[pos-2]++;
				cur[pos-1]=make_pair(0,cur[pos].second);
				psum[pos-1]=psum[pos-2]+cur[pos-1].second;
				len--;
			}
			continue;
		}

		int tmp=cur[pos].second;

		cur[pos-1].second--;
		psum[pos-1]--;
		cur[pos]=make_pair(cur[pos-1].first+1,1);
		psum[pos]=psum[pos-1]+1;
		cur[pos+1]=make_pair(0,tmp);
		psum[pos+1]=psum[pos]+tmp;
		len++;
	}

	return true;
}

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

	cin>>N;
	rep(i,0,N) cin>>a[i];

// cerr<<enough(2)<<endl;

	int l=1,r=N;
	while (l<r) {
		int m=(l+r)/2;
		if (!enough(m)) l=m+1; else r=m;
	}
	cout<<l<<"\n";
}


Measured memory_bytes: 1024
#include<stdio.h>
int main(void){
  int h,w,i,j,k;
 
  for(i = 0;;i++){
    scanf("%d%d",&h,&w);
     
    if(h==0 && w==0)break;
     
    for(j = 0;j < h;j++){
      for(k = 0;k < w;k++){
    if(j == 0 || j == h-1)
      printf("#");
    else if(k == 0 || k == w-1)
      printf("#");
    else
      printf(".");
      }
      printf("\n");
    }
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 1808
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
#include <math.h>
#include <string>
#include <math.h>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<ll, P> Q;

const ll mod = 1000000007;
const ll INF = 1000000000000;

ll N, M, p, A[5010], B[5010], C[5010], d[2510];

bool rp[2510];

vector<P> G[2510];

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

	for (int i = 0; i < M; i++)
	{
		cin >> A[i] >> B[i] >> C[i];

		G[A[i]].push_back(P(B[i], C[i] - p));
		C[i] -= p;
	}

	for (int i = 1; i <= N; i++)
	{
		d[i] = -INF;
	}

	d[1] = 0;

	for (int j = 0; j < M * 2; j++)
	{
		for (int i = 0; i < M; i++)
		{
			ll from = A[i], to = B[i], cost = C[i];
			if (d[from] != -INF && d[to] < d[from] + cost)
			{
				d[to] = d[from] + cost;
			}
		}
	}

	ll num = d[N];

	for (int j = 0; j < M * 2; j++)
	{
		for (int i = 0; i < M; i++)
		{
			ll from = A[i], to = B[i], cost = C[i];
			if (d[from] != -INF && d[to] < d[from] + cost)
			{
				d[to] = d[from] + cost;
			}
		}
	}

	if (d[N] == num)
	{
		if (d[N] < 0)
		{
			cout << 0 << endl;
		}
		else
		{
			cout << d[N] << endl;
		}
	}
	else
	{
		cout << -1 << endl;
	}
	int www;
	cin >> www;
}

Measured memory_bytes: 640
import java.util.Scanner;
public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        double r = sc.nextDouble();
        double p = Math.PI; 
        double area = r*r*p;
        double length = 2*p*r;
        System.out.printf("%f %f",area,length);
        sc.close();
    }
}


Measured memory_bytes: 28200
# coding: utf-8

"""
import codecs
import sys

sys.stdout = codecs.getwriter("shift_jis")(sys.stdout) # ??????
sys.stdin = codecs.getreader("shift_jis")(sys.stdin) # ??\???

# ??\??¬?????????print??????????????´?????? print(u'?????????') ??¨??????
# ??\??¬?????????input??? input(u'?????????') ??§OK
# ??°?¢???????????????????????????´??????6,7???????????????????????¢??????
"""

num = int(raw_input())
print num**3

Measured memory_bytes: 6364
s = ''.join(input().split('ST'))
while 1:
    i = s.find('ST')
    if i > -1:
        cnt = 0
        for j in range(min(i, len(s)-2-i)):
            if s[i-j-1] == 'S' and s[i+j+2] == 'T':
                cnt += 1
            else:
                break
        s = s[:i-cnt] + s[i+cnt+2:]
    else:
        break
print(len(s))

Measured memory_bytes: 5352
N,K = map(int, input().split())
V = list(map(int, input().split()))
import sys
max_value=-1000000000

for i in range(K+1):
        for left in range(i+1):
                right= i - left

                leftlist = V[:left]

                if right == 0:
                        rightlist = []
                else:
                        rightlist = V[-right:]

        #       print(left)
        #       print(right)


                leftlist.extend(rightlist)

                leftlist.sort()


#               for push in range(K-i):

                num = 0
                for value in range(len(leftlist)):
                        num+=1
                        if num > K-i:
                                break

                        if leftlist[value] > 0:
                                break
                        leftlist[value]=0
        #       print(leftlist)



                s = sum(leftlist)
                if max_value < s:
                        max_value = s

                if left+right > N:
                        print(max_value)
                        sys.exit()

print(max_value)

Measured memory_bytes: 3064
#include <iostream>
using namespace std;
#define ll long long

ll fnc(ll a, ll x);

int main(){
  ll a,b,x;
  cin >> a >> b >> x;
  cout << fnc(b,x)-fnc(a-1,x) << endl;

  return 0;
}

ll fnc(ll a, ll x){
  if(a<0) return 0;
  return a/x+1;
}

Measured memory_bytes: 256
using System;
namespace aoj {
	public class Program {
		public static void Main() {
			string str;
			int r = 0;
			while ((str = Console.ReadLine()) != null)
				for (int i = 0; i < str.Length; i++)
					if ('0' <= str[i] && str[i] <= '9') {
						int s = i, l = 1;
						while (++i < str.Length && '0' <= str[i] && str[i] <= '9') l++;
						r += int.Parse(str.Substring(s, l));
					}
			Console.WriteLine(r);
		}
	}
}

Measured memory_bytes: 9132
#include <iostream>
#include <string>
#include <algorithm>
#define	MOD  1000000007;
using namespace std;

int main()
{
	int N, K;
	cin >> N >> K;
	int a[100];

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

	int sum = 0;
	for (int i = 0; i < N; i++)
	{
		sum += (K - a[i] <= a[i]) ? (K - a[i]) : a[i];
	}
	cout << 2 * sum << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<map>
#include<numeric>

using namespace std;

int main(){
    int n;
    cin >> n;
    vector<string> vec;
    for(int i = 0; i < n; i++){
        string s;
        cin >> s;
        vec.push_back(s);
    }

    int ac = 0, tle = 0, wa = 0, re = 0;

    for(const auto& e: vec){
        if(e == "AC") ac++;
        else if(e == "WA") wa++;
        else if (e == "TLE") tle++;
        else if (e == "RE") re++;
    }

    cout << "AC" << " x " << ac << endl; 
    cout << "WA" << " x " << wa << endl; 
    cout << "TLE" << " x " << tle << endl; 
    cout << "RE" << " x " << re << endl; 

}

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

int main()
{
    int n,m,i,j;
    cin>>n>>m;
    char a[n][m];
    for(i=0;i<n;i++)
    {
        for(j=0;j<m;j++)
        {
            cin>>a[i][j];
        }
    }
    long long int b[n][m];
    memset(b,0,sizeof(b));
    for(i=0;i<n;i++)
    {
        if(a[i][0]=='#')
        {
            break;
        }
        b[i][0]=1;
    }
    for(j=0;j<m;j++)
    {
        if(a[0][j]=='#')
        break;
        b[0][j]=1;
    }
    for(i=1;i<n;i++)
    {
        for(j=1;j<m;j++)
        {
            if(a[i][j]=='#')
            continue;
            b[i][j]=(b[i-1][j]+b[i][j-1])%1000000007;
        }
    }
    cout<<(b[n-1][m-1])<<endl;
}

Measured memory_bytes: 12396
#include<iostream>
#include<cstdio>
#include <stdio.h>
#include<algorithm>
#include<cstring>
#include <string>
#include<cmath>
#include<cstdlib>
#include<queue>
#include<map>
#include<vector>
#include<bits/stdc++.h>
#include <set>
#define ll   long long
#define IO ios::sync_with_stdio(false);cin.tie();cout.tie(0)
#define inf 0x3f3f3f3f3f3f3f3f
#define pi 3.1415926535898
#define N 200010
using namespace std;
int n;
int a[15];
void dfs(int x,int p)
{
    int j,i,now;
    if(x==n)
    {
        for(j=0; j<n; j++)
            printf("%c",a[j]+'a');
        printf("\n");
        return ;
    }
    now=min(x,p+1);
    for( i=0; i<=now; i++)
    {
        a[x]=i;
        p=max(p,i);
        dfs(x+1,p);
    }
}
int main()
{
    scanf("%d",&n);
    dfs(0,-1);
    return 0;
}


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

int main() {
	int a,b,c,d,e;
	cin >> a >> b >> c >> d >> e;
	if(a<40){
		a=40;
	}
	if(b<40){
		b=40;
	}
	if(c<40){
		c=40;
	}
    if(d<40){
		d=40;
	}
    if(e<40){
		e=40;
	}
	cout << (a+b+c+d+e)/5 << endl;

	// your code goes here
	return 0;
}

Measured memory_bytes: 1160
unittest
{
	assert( [ "a" ].parse.expand.solve == 'b' );
	assert( [ "y" ].parse.expand.solve == 'z' );
}



import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto c = input.front.to!( dchar );
	return tuple( c );
}

auto solve( dchar c )
{
	return cast( dchar )( c + 1 );
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i,N) for(int i = 0; i < (N); i++)
#define erep(i,N) for(int i = N - 1; i >= 0; i--)
const ll INF = 1000000000;
//const ll MOD = 1000000007;
const ld PI = (acos(-1));
using Graph = vector<vector<int>>;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true;} return false;}
typedef pair<int, int> pair;
double rad(double a) {return a * 180 / PI;}

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号 (例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

//dpTable
int dp[100050];

int main(){
    int N;
    cin >> N;
    vector<ll> A(N);
    rep(i,N) cin >> A.at(i);
    ll a1 = __gcd(A.at(0),A.at(1));
    ll ans = a1;
    for (int i = 1; i < N; i++) {
        ll a = __gcd(A.at(i - 1),A.at(i));
        ans = __gcd(ans,a);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4040
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
const int INF = 1000000001;

int main(){
  int a;
  cin >> a;
  if(a%10 == a/100) cout << "Yes"<<endl;
  else cout << "No" <<endl;
}

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

#define MOD 1000000007
#define rep(i, n) for(ll i=0; i < (n); i++)
#define ALL(v) v.begin(),v.end()
#define FOR(i, j, k) for(ll i=j;i<k;i++)
#define DUMP(i, v)for(ll i=0;i<v.size();i++)cout<<v[i]<<" "

using namespace std;
typedef long long int ll;
typedef vector<ll> llvec;
typedef vector<double> dvec;
typedef pair<ll, ll> P;
typedef long double ld;
struct Edge{ll from, to, cost;};
struct node{ll cost, to;
  bool friend operator>(node a, node b){
    return a.cost>b.cost;
  }
};

ll mod(ll a, ll mod){
  ll res = a%mod;
  if(res<0)res=res + mod;
  return res;
}

ll modpow(ll a, ll n, ll mod){
  ll res=1;
  while(n>0){
    if(n&1) res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll modinv(ll a, ll mod){
  return modpow(a, mod-2, mod);
}

ll gcd(ll a, ll b){
  ll r = a%b;
  if(r==0) return b;
  else return gcd(b, a%b);
}

bool is_prime(ll n){
  ll i = 2;
  if(n==1)return false;
  if(n==2)return true;
  bool res = true;
  while(i*i <n){
    if(n%i==0){
      res = false;
    }
    i = i+1;
  }

  //if(i==1)res = false;
  if(n%i==0)res=false;
  return res;
}


/**************************************
** A main function starts from here  **
***************************************/
int main(){
  string S;
  cin >>S;
  ll N = S.size();
  ll l, r;
  rep(i, N){
    if(S[i]=='A'){
      l=i;
      break;
    }
  }
  rep(i, N){
    if(S[N-i-1]=='Z'){
      r=N-i-1;
      break;
    }
  }

  cout << r-l+1<<endl;
  return 0;
}


Measured memory_bytes: 640
import sys
input = sys.stdin.readline

def readlines(n):
    for _ in range(n):
        a, b = map(int, input().split())
        yield a, b

n, m = map(int, input().split())
bridges = list(readlines(m))
tree = list(range(n+1))
rank = [1] * (n+1)

def root(v):
    while tree[v] != v:
        tree[v] = tree[tree[v]]
        v = tree[v]
    return v

def merge(x, y):
    if rank[x] < rank[y]:
        tree[x] = y
        rank[y] += rank[x]
    else:
        tree[y] = x
        rank[x] += rank[y]

def main():
    fuben = n*(n-1)//2

    for a, b in bridges[::-1]:
        x = root(a)
        y = root(b)

        if x == y:
            yield str(fuben)
            continue
        
        yield str(fuben)
        fuben -= rank[x]*rank[y]
        merge(x, y)


print("\n".join(reversed(list(main()))))

Measured memory_bytes: 29448
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl "\n"
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define pb push_back
#define F first
#define S second
#define um map <ll,ll>
#define rep(i,z,n)  for(int i=z;i<n;i++)
#define repi(i,z,n) for(int i=z;i<=n;i++)
#define repn(i,z,n) for(int i=n-1;i>=z;i--)
#define vec vector<ll>
#define vecp vector<pair<ll,ll>>
#define pi (double)3.14159265358979323846
#define ld long double
#define all(z) z.begin(),z.end()

ll power(ll a, ll b, ll m) { ll ans = 1; a = a % m; if (a == 0) return 0; while (b) { if (b & 1) ans = (ans * a) % m; b /= 2; a = (a * a) % m; } return ans; }
ll modInverse(ll a, ll m) {return power(a, m - 2, m);}
ll binpow(ll a, ll b) {ll res = 1; while (b > 0) {if (b & 1)res = res * a; a = a * a; b >>= 1;} return res;}
ll binlog2(ll n) {ll logValue = -1; while (n) {logValue++; n >>= 1;} return logValue;}
void print(vec a) {rep(i, 0, a.size())cout << a[i] << " "; cout << endl;}
const ll mod = 1e9 + 7;
const ll N = 1e5 + 5;
const ll inf = 2e18;




void solve() {
    ll n;
    cin >> n;
    vec a(n);
    rep(i, 0, n)
    cin >> a[i];
    vec dp(n, 0);
    if (n >= 2)
        dp[1] = abs(a[1] - a[0]);
    rep(i, 2, n) {
        dp[i] = min(dp[i - 1] + abs(a[i] - a[i - 1]), dp[i - 2] + abs(a[i] - a[i - 2]));
    }

    cout << dp[n - 1] << endl;


}





int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    speed;
    int test = 1;
    // cin >> test;
    while (test--) {
        // cout << "Case #" << t1 << ": ";
        solve();
    }
    return 0;
}

Measured memory_bytes: 4688
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.stream.IntStream;
import java.util.Arrays;
import java.util.Scanner;

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

    static class ABC095_B {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int k = in.nextInt();
            int[] m = new int[n];
            for (int i = 0; i < n; i++) {
                m[i] = in.nextInt();
            }

            int sum = Arrays.stream(m).sum();
            Arrays.sort(m);
            int min = m[0];

            out.print(n + (k - sum) / min);
        }

    }
}



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

using namespace std;

long long a,b,c,d,n,k;
long long m[100100],l[100100],o[100100];

void update(long long i, long long x)
{
	for(;i<=d;i += i &-i)
		m[i] += x;

}

long long query(long long i)
{
	long long x = 0;
	for(;i>0;i -= i &-i)
		x += m[i];
		
	return x;

}

int main()
{
	
	cin >> n >> k;
	
	m[0]=0;d = 0;
	for(a=1;a<=n;a++)
	{
		m[a] = 0;
		scanf("%lld %lld", l+a, o+a);
		if(l[a] > d) d = l[a];
	}
	d++;
	
	for(a=1;a<=n;a++)
	{
		
		update(l[a],o[a]);
	
	}
	
	a = 0;
	while(k > query(a) ) a++;
	cout << a;
	

}

Measured memory_bytes: 2560
#include"bits/stdc++.h"

void Main() {
  int n;
  std::cin >> n;

  int height[n];
  int ans = 0;
  int move = 0;
  std::cin >> height[0];
  for (int i = 1; i < n; i++) {
    std::cin >> height[i];
    if (height[i - 1] >= height[i]) {
      move++;
    } else {
      if (move > ans) {
        ans = move;
      }
      move = 0;
    }
  }
  if (move > ans) {
    ans = move;
  }

  std::cout << ans << std::endl;
}

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <functional>
#define fs first
#define se second

using namespace std;
typedef long long llong;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<llong, llong> pll;
typedef pair<ld, ld> pdd;

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    int a, b;
    cin >> a >> b;
    printf("%d\n", (b - 1 + a - 2) / (a - 1));
    return 0;
}

Measured memory_bytes: 256
n=int(input())
xy=[]
for i in range(n):
  a=int(input())
  xy.append([list(map(int,input().split())) for j in range(a)])
 
ans=0
for i in range(2**n):
  honest=[]
  for j in range(n):
    if (i>>j)&1:
      honest.append(1)
    else:
      honest.append(0)
  p=0
  for j,k in enumerate(honest):
    if k==1:
      r=0
      for l in xy[j]:
        if honest[l[0]-1]!=l[1]:
          r=1
          break    
      if r==0:
        p=p+1
  if p==sum(honest) and p>ans:
    ans=p
print(ans)

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

int main() {
  int x;
  scanf("%d", &x);
  for (int i = 1; i <= 9; i++) {
    for (int j = 1; j <= 9; j++) {
      if (i * j == x) {
        printf("Yes");
        return 0;
      }
    }
  }
  printf("No");
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define DEKAI 1000000007
#define INF (1<<28)
#define lp(i,n) lps(i,0,n)
#define lps(i,j,n) for(int i=j;i<n;i++)
#define FDST int hogehogehoge;cin>>hogehogehoge
#define MAX_V 110
#define   int long long

int H, W, L;
string str[MAX_V];
char foo(char temp){
   if(temp == 'S'){
     temp = 'W';
   } else if(temp == 'N'){
     temp = 'E';
   } else if(temp == 'E'){
     temp = 'S';
   } else if(temp == 'W'){
     temp = 'N';
   }
   return temp;
}

signed  main(){
  while(true){
    int xy[2];
    int dp[MAX_V][MAX_V][30] = {}, used[MAX_V][MAX_V] = {};
    char temp;
    cin>>H>>W>>L;

    if(!H&&!W&&!L) break;
    
    for(int i = 0; i < H; i++){
      cin>>str[i];
      for(int j = 0; j < W; j++){
	if(str[i][j] != '.' && str[i][j] != '#'){
	  xy[0] = i; xy[1] = j;
	  temp = str[i][j];
	}
      }
    }

    for(int i = 1; i <= L;){
      int x = xy[1], y = xy[0];
      // char tt  = temp;
      //int xx= x, yy = y;
      //cout<<i<<" "<<x<<" "<<y<<" "<<temp<<endl;
      if(temp == 'S'){
	y++;
      } else if(temp == 'N'){
	y--;
      } else if(temp == 'E'){
	x++;
      } else if(temp == 'W'){
	x--;
      }
      if(0 <= y && y < H && 0 <= x && x < W){
	if(str[y][x] == '#'){
	  temp = foo(temp);
	  dp[y][x][temp-'A'] = i;
	} else {
	  if(dp[y][x][temp-'A']){
	    if((L-i)/(i-dp[y][x][temp-'A'])){
	      i = L-(L-i)%(i-dp[y][x][temp-'A']);
	    } else {
	      xy[0] = y, xy[1] = x;
	      i++;
	    }
	  } else {
	    xy[0] = y, xy[1] = x;
	    dp[y][x][temp-'A'] = i;
	    i++;
	  }
	}
	
      } else {
	temp = foo(temp);
	dp[y][x][temp-'A'] = i;
      }
    }
    cout<<xy[0]+1<<" "<<xy[1]+1<<" "<<temp<<endl;
  }

  return 0;
}



Measured memory_bytes: 5924
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Grand032A
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var nums = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToList();
            var ans = new int[N];
            var numsMax = nums.Max();
            var isSolvable = true;
            for (int i=0;i<N;i++)
            {
                var exist = false;
                var max = numsMax < nums.Count ? numsMax : nums.Count;
                for(int j=max;j>0;j--)
                {
                    if(nums[j -1] == j)
                    {
                        nums.RemoveAt(j - 1);
                        ans[N - i - 1] = j;
                        exist = true;
                        break;
                    }
                }
                if (!exist)
                {
                    isSolvable = false;
                    break;
                }
            }

            if (isSolvable)
            {
                foreach (var a in ans)
                    Console.WriteLine(a);
            }
            else
                Console.WriteLine("-1");
        }
    }
}


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

#define MAX 100000

int count[MAX+1];

void quickSort(int *,char *,int,int);
int partition(int *,char *,int,int);
int Stable(int *,int);

int main(){

  int i,n,k;
  char B[MAX+1],c,d,e;
  int A[MAX+1];
  

  scanf("%d%c",&n,&e);
  /*
  for(i=1;i<=(2*n);i++){
    if(i%2==1)scanf("%c",&B[(i+1)/2]);
    else scanf("%d",&A[i/2]);
    printf("%d",n);  
    }
  */
  for(i=1;i<n+1;i++){
   scanf("%c%c%d%c",&B[i],&c,&A[i],&d);
   count[i]=i;
  }

  quickSort(A,B,1,n);

  if(Stable(A,n)==0) printf("Stable\n");
  else printf("Not stable\n");

  for(k=1;k<=n;k++){
    printf("%c %d\n",B[k],A[k]);
  }

  return 0;
}

void quickSort(int *A,char *B,int p,int r){
  int q;
  
  if(p<r){
    q=partition(A,B,p,r);
    quickSort(A,B,p,q-1);
    quickSort(A,B,q+1,r);
  }
}

int partition(int *A,char *B,int p,int r){
  int x,i,j,s,swap;
  char exc;

   x=A[r];
   i=p-1;

  for(j=p;j<r;j++){
    if(A[j]<=x){
      i++;
      swap=A[i];
      A[i]=A[j];
      A[j]=swap;
      exc=B[i];
      B[i]=B[j];
      B[j]=exc;
      s=count[i];
      count[i]=count[j];    
      count[j]=s;
    }
}
      swap=A[i+1];
      A[i+1]=A[r];
      A[r]=swap;
      exc=B[i+1];
      B[i+1]=B[r];
      B[r]=exc;
      s=count[i+1];
      count[i+1]=count[r];    
      count[r]=s;

      return i+1;
}

int Stable(int *A,int n){
  int i;

  for(i=1;i<=n;i++){
    if(A[i]==A[i+1]){
      if(count[i]>count[i+1]) return 1;
    }
  }
  return 0;

}

Measured memory_bytes: 1484
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
#include <map>
using namespace std;

typedef long long ll;

#define INF 10e10
#define rep(i,n) for(int i=0; i<n; i++)
#define rep_r(i,n,m) for(int i=m; i<n; i++)
#define END cout << endl
#define MOD 1000000007
#define pb push_back
// 昇順sort
#define sorti(x) sort(x.begin(), x.end())
// 降順sort
#define sortd(x) sort(x.begin(), x.end(), std::greater<int>())

ll res = 0;

int main() {
  int n; scanf("%d", &n);
  vector<ll> a(n+1,0);
  for (int i = 1; i <= n; ++i) {
    ll t;
    scanf("%lld", &t);
    a[i] = a[i-1] + t;
  }

  /*
  swap(a[0], a.back());
  a.pop_back();
  */

  map<ll,ll> mp;
  for (int i = 0; i <= n; ++i) {
    mp[a[i]]++;
  }

  for (auto itr : mp) {
    //cout << itr.second << endl;
    res += ((itr.second - 1) * itr.second) / 2;
  }
  printf("%lld\n", res);
}


Measured memory_bytes: 14336
//Relive your past life.
//Face your demons.
//The past is never dead,it is not even past.
//The memories are not only the key to the past but...also to the future.
//coded in Rusty Lake
#include<cmath>
#include<math.h>
#include<ctype.h>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cwchar>
#include<cwctype>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<typeinfo>
#include<utility>
#include<valarray>
#include<vector>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
#define ll   long long
#define pb   push_back
#define mp   make_pair
#define orz  1000000007
using namespace std;
int n,a[105],ans;
int main(){
    scanf("%d",&n);
    for(int i=1;i<=n;++i)scanf("%d",a+i);
    for(int i=2;i<=n;++i)if(a[i]==a[i-1])++ans,++i;
    printf("%d\n",ans);
	//system("pause");
	return 0;
}


Measured memory_bytes: 256
/*
 *  Created on: 6-August-2019
 *      Author: ankur314
 */
#include<bits/stdc++.h>
#define lli long long int
#define li long int
#define db double
#define ldb long double
#define vr vector
#define it iterator
#define fi(i,a,n) for(int i=a;i<n;i++)
#define fli(i,a,n) for(long int i=a;i<n;i++)
#define flli(i,a,n) for(long long int i=a;i<n;i++)
#define pb(n) push_back(n)
#define ppf() pop_front()
#define pii pair<int,int>
#define MOD 1000000007

#define debug1(x) cout<<x<<"\n"
#define debug2(x,y) cout<<x<<" "<<y<<"\n"
#define debug3(x,y,z) cout<<x<<" "<<y<<" "<<z<<"\n"
#define debug4(x,y,z,w) cout<<x<<" "<<y<<" "<<z<<" "<<w<<"\n"

using namespace std;

lli dp[105][100005];
lli w[100005];
lli v[100005];

int main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    /*freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);*/
    int n,W;cin>>n>>W;
    fi(i,0,n) cin>>w[i]>>v[i];
    fi(i,1,n+1)
    {
        fi(j,0,W+1)
        {
            if(i==0 || j==0) dp[i][j] = 0;
            if(j-w[i-1] >= 0)
            {
                dp[i][j] = max(dp[i-1][j], v[i-1]+dp[i-1][j-w[i-1]]);
            }
            else
            {
                dp[i][j] = dp[i-1][j];
            }
        }
    }
    cout<<dp[n][W];
    return 0;
}


Measured memory_bytes: 80128
#include<bits/stdc++.h>
using namespace std;
#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif
//#define int long long
//const int INF = 1LL << 60;

signed main(){

  int H, W, K; cin >> H >> W >> K;
  vector<string> S(H);
  for(int i = 0; i < H; i++){
    cin >> S[i];
  }

  int ans = 1<<30;
  for(int i = 0; i < 1 << (H-1); i++){
    int res = __builtin_popcount(i);
    int h = res + 1;
    bool flag2 = false;
    for(int j = 0; j < W; j++){
      int cnt2 = 0;
      for(int k = 0; k < H; k++){
        cnt2 += (S[k][j] == '1');
        if(cnt2 > K){
          flag2 = true;
          break;
        }
        if(i >> k & 1){
          cnt2 = 0;
        }
      }
      //cout << i << " " << cnt2 << endl;
      if(flag2) break;
    }
    if(flag2) continue;
    vector<int> v(h, 0);
    for(int j = 0; j < W; j++){
      int cnt = 0;
      h = 0;
      bool flag = false;
      for(int k = 0; k < H; k++){
        cnt += (S[k][j] == '1');
        if(i >> k & 1 || k == H-1){
          if(v[h] + cnt > K){
            res++;
            for(int l = 0; l < v.size(); l++){
              v[l] = 0;
            }
            j--;
            flag = true;
            cnt = 0;
            break;
          }
          v[h] += cnt;
          cnt = 0;
          h++;
        }
        if(flag) break;
      }
    }
    ans = min(ans, res);
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.lang.*;

public class Main {
    
    public static void main (String args[]) {
        
        int ans = 0;

        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] p = new int[n];
        for (int i = 0; i < n; i++) {
            p[i] = sc.nextInt();
        }
        
        int max = 0;
        int maxnum = 0;
        
        for (int i = 0; i < n; i ++) {
            if (p[i] > max) {
                max = p[i];
                maxnum = i;
            }
        }
        
        for (int i = 0; i < n; i++) {
            if (i != maxnum) {
                ans += p[i];
            }
        }
        
        ans += max/2;
	    
        System.out.println(ans);
    }
}

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

struct Benri { Benri() { std::cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(12);}} benri;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using vll = vector<long long>;
using vvll = vector<vll>;
using pll = pair<ll, ll>;
using ull = unsigned long long;

template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define F first
#define S second

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; }

constexpr long long MOD = 1000000007;
//constexpr long long MOD = 998244353;
//constexpr int INF = 1001001001;
constexpr ll INF = 1001001001001001001LL;
constexpr double EPS = 1e-10;
using number = long long;

int main() {
    int N; cin >> N;
    vll d(N);
    rep(i, N) cin >> d[i];
    ll ans = 0;
    rep(i, N - 1) {
        for (int j = i + 1; j < N; j++) ans += d[i] * d[j];
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>

int n,m,k;

int got()
{
	for(int i=1,x;i<=n;i++)
	{
		scanf("%d",&x);
		if(x==1)return i;
	}
	return -1;
}

int calc(int len)
{
	return len/(k-1)+(len%(k-1)!=0);
}

int main()
{
	scanf("%d%d",&n,&k);
	m=got();

	int ans=n;
	for(int l=std::max(1,m-k+1);l<=m;l++)
	{
		int r=std::min(n,l+k-1);
		ans=std::min(ans,1+calc(l-1)+calc(n-r));
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define int long long
#define inf 1000000007
#define LINF 100000000000007LL
#define ll long long
using namespace std;
signed main(){
	int n,x;
	cin>>n>>x;
	vector< pair<int, int> > ids;
	vector< int > b,l,r;
	for(int i=0;i<n;i++){
		int t1,t2,t3;
		cin>>t1>>t2>>t3;
		b.pb(t1);
		l.pb(t2);
		r.pb(t3);
		int mx = b[i] * l[i] + r[i] * ( x - b[i] );
		ids.pb(mp(mx,i));
	}
	sort( ids.begin(), ids.end(), greater< pair<int,int> >() );
	int ng = -1, ok = x*n;
	int aok = 0;
	for(int i=0;i<n;i++){
		aok += b[i]*l[i];
	}
	while( ok - ng > 1 ){
		int mid = ( ok + ng ) / 2;
		int ful = mid/x;
		int amari = mid % x;
		int donyok = 0;
		for(int i=0;i<ful;i++){
			donyok += ids[i].first;
		}
		bool fl = false;
		for(int k=0;k<n;k++){ // amari == k
			int tak = donyok;
			int c = ids[k].second;
			if( k < ful ){
				tak -= b[c] * l[c] + r[c] * ( x - b[c] );
				tak += min( b[c], amari ) * l[c] + max( 0LL, amari-b[c] ) * r[c];
				tak += ids[ful].first;
			}
			else{
				tak += min( b[c], amari ) * l[c] + max( 0LL, amari-b[c] ) * r[c];
			}
			if( tak >= aok ){
				fl = true;
			}
		}
		if(fl){
			ok = mid;
		}
		else{
			ng = mid;
		}
	}
	cout<<ok<<endl;
	return 0;
}

Measured memory_bytes: 4304
(a, b) = gets.chomp.split(' ')
a = a.to_i
b = b.to_i

a = a == 1 ? 14 : a
b = b == 1 ? 14 : b

if (a > b)
  puts 'Alice'
elsif(a < b)
  puts 'Bob'
else
  puts 'Draw'
end

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

int n, a, b, c;
int l[8];
const int INF = 3000;

int cal(int i, int a1, int b1, int c1) {
	if (i == n) {
		if(a1 > 0 && b1 > 0 && c1 > 0)
			return abs(a - a1) + abs(b - b1) + abs(c - c1) - 30;
		else
			return INF;
	}

	int j1 = cal(i + 1, a1, b1, c1);
	int j2 = cal(i + 1, a1 + l[i], b1, c1) + 10;
	int j3 = cal(i + 1, a1, b1 + l[i], c1) + 10;
	int j4 = cal(i + 1, a1, b1, c1 + l[i]) + 10;

	return min({ j1, j2, j3, j4 });
}

int main()
{	
	cin >> n >> a >> b >> c;

	for (int i = 0; i < n; i++)
		cin >> l[i];

	cout << cal(0, 0, 0, 0) << endl;

	return 0;
}


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

ll gcd(ll a, ll b) {
  if (a < b) swap(a, b);
  if (b == 0) return a;
  return gcd(b, a % b);
}

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

  ll tmp = gcd(a, b);
  ll ans = 1;
  ans = (ll) a * b;

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

Measured memory_bytes: 256
// 基本テンプレート
 
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
using namespace std;
 
#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
constexpr ll INF = 1001001001001001LL;
constexpr ll MOD = 1000000007LL;

signed main() {
    int A, B; cin >> A >> B;
    string s; cin >> s;

    bool ok = true;
    rep(i,0,A) if(!isdigit(s[i])) ok = false;
    if(isdigit(s[A])) ok = false;
    rep(i,A+1,A+1+B) if(!isdigit(s[i])) ok = false;

    cout << (ok ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>
#include <stdio.h>
#include <string.h>
using ll = long long;

//LLONG_MAX
#define int long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define LOWER_BOUND(v,a) (lower_bound((v).begin(), (v).end(), (a)))
#define UPPER_BOUND(v,a) (upper_bound((v).begin(), (v).end(), (a)))
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define CONTAINS_MAP(m, a) (m).find((a)) != m.end()
using namespace std;

int A, B;

signed main()
{
	cin >> A >> B;

	if (B % A == 0)
	{
		cout << A + B << endl;
	}
	else
	{
		cout << B - A << endl;
	}
}








Measured memory_bytes: 256
"use strict";
function main(input) {
    let S = input.replace("\n", "");
    let ans = countBy([...S]);
    console.log(Object.values(ans).length == 2 && Object.values(ans)[0] == 2 ? "Yes" : "No");
    return;
}
function countBy(data, keyGetter) {
    var keyResolver = {
        'function': function (d) { return keyGetter(d); },
        'string': function (d) { return d[keyGetter]; },
        'undefined': function (d) { return d; }
    };

    var result = {};

    data.forEach(function (d) {
        var keyGetterType = typeof keyGetter;
        var key = keyResolver[keyGetterType](d);

        if (result.hasOwnProperty(key)) {
            result[key] += 1;
        } else {
            result[key] = 1;
        }
    });

    return result;
}
// list1 = ['a', 'b', 'c', 'b', 'a', 'b', 'c', 'a', 'a', 'a'];
// console.log(countBy(list1));  // {'a':5, 'b':3, 'c':2}
// list2 = ['abc', 'aa', 'b3', 'abcd', 'cd'];
// console.log(countBy(list2, 'length'));  // {2: 3, 3: 1, 4: 1}
// list3 = [1.2, 7.8, 1.9];
// console.log(countBy(list3, Math.floor));  // {1: 2, 7: 1}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

int main()
{
    string x;
    cin >> x;
    int n = x.size();
    int s = 0, st = 0;
    for(int i = 0; i < n; i++){
        if(x[i] == 'S') s++;
        if(x[i] == 'T' && s > 0){
            st++;
            s--;
        }
    }
    cout << n - st * 2 << endl;
}

Measured memory_bytes: 640
#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;
  set<int> f;
  for(int i=1; i<1000; ++i){
    f.insert(i*i);
  }
  
  for(int i=0; i<n-1; ++i){
    for(int j=i+1; j<n; ++j){
      int d2=0;
      for(int k=0; k<d; ++k)d2+=(x[i][k]-x[j][k])*(x[i][k]-x[j][k]);
      if(f.find(d2)!=f.end())++ans;
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256