akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cmath>
#include <map>
#include <utility>
#include <list>
#include <string>
#include <vector>
#include <algorithm>
#include <set>

using namespace std;

#define LL long long


int main() {
    int n, m;
    cin >> n >> m;
    int food[31];
    for (int i=0; i < 31; i++){
        food[i] = 0;
    }

    for (int i=0; i < n; i++){
        int k;
        cin >> k;
        for (int jj = 0; jj < k; jj++){
            int a;
            cin >> a;
            food[a]++;
        }
    }

    int num = 0;
    for (int i=0; i < 31; i++){
        if (food[i] == n) {
            num++;
        }
    }

    cout << num << endl;

    return 0;
}


Measured memory_bytes: 256
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

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

func getString() string {
	sc.Scan()
	return sc.Text()
}

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

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer([]byte{}, 1000000)

	N, K := getInt(), getInt()
	x := make([]int, N)
	for i := 0; i < N; i++ {
		x[i] = getInt()
	}

	ans := 10010010010
	for i := 0; i < N-K+1; i++ {
		a, b := x[i], x[i+K-1]
		l := 0
		if a >= 0 {
			l = b
		} else if b < 0 {
			l = -a
		} else {
			l = min(-a*2+b, -a+b*2)
		}
		ans = min(ans, l)
		//out(a, b, l)
	}

	out(ans)
}


Measured memory_bytes: 2944
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;
 
int main() {
    ll n;
    cin >> n;

    map<P, ll> mp;
    rep(i, n) {
        ll a;
        cin >> a;
        a--;
        ll j = i;
        if(j > a) {
            swap(j, a);
        }
        mp[make_pair(j, a)]++;
    }

    ll ans = 0;
    for(auto p : mp) {
        ans += p.second - 1;
    }
    
    out(ans);
    re0;
}

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

int primecheck(int n){
    int i;
    
    if(n==0||n==1)return 0;
    if(n==2||n==3)return 1;
    
    for(i=2;i<=sqrt(n);i++){
        if(n%i==0)return 0;
    }
    return 1;
}
//1???????´???°???0??????????´???°???

int main(void){
    int i,n,cnt,sum;
    
    while(1){
        scanf("%d",&n);
        if(n==0)break;
        
        for(i=2,sum=cnt=0;cnt<n;i++){
            if(primecheck(i)==1){
                cnt++;
                sum+=i;
            }
        }
        printf("%d\n",sum);
    }
    
    return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a),i##formax=(b);i<i##formax;i++)
#define FORR(i,a,b) for(int i=(a),i##formax=(b);i>=i##formax;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)
#define show(x) cout<<#x<<" = "<<x<<endl;
#define all(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))
#define bitComb(a,n,k) for(int a##x,a##y,a=(1<<k)-1;a<(1<<n);a##x=a&-a,a##y=a+a##x,a=(((a&~a##y)/a##x)>>1)|a##y)
#define uniq(v) sort(all(v));v.erase(unique(all(v)), v.end())
#define bit(n) (1LL<<(n))
#define randInt(l,r) (uniform_int_distribution<ll>(l,r)(rnd))
#define randDouble(l,r) (uniform_real_distribution<double>(l,r)(rnd))
#define dout(d) printf("%.12f\n",d)

typedef long long ll;
typedef __int128_t lll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T>using V=vector<T>;
template<class T>using VV=V<V<T>>;
template<class T,class Y>ostream& operator<<(ostream& o,const pair<T,Y>& p){return o<<"("<<p.fi<<", "<<p.se<<")";}
template<typename A,size_t N,typename T>void Fill(A (&array)[N],const T&v){fill((T*)array,(T*)(array+N),v);}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll gcd(ll a,ll b){lll x=0,y=0;return gcd(a,b,x,y);}
ll modInv(ll a,ll m){lll x,y;gcd(a,m,x,y);return (x%m+m)%m;}
ll modPow(lll a,lll n,ll m){if(!a)return a;lll p=1;for(;n>0;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
bool isPrime(ll n){if(n<2||n%2==0)return n==2;lll t=n-1,d=t/(t&-t);for(lll a:{2,325,9375,28178,450775,9780504,1795265022})if(a%n){for(t=d,a=modPow(a,t,n);t!=n-1&&a!=1&&a!=n-1;a=a*a%n,t=t*2%n);if(a!=n-1&&t%2==0)return 0;}return 1;}
const int IINF = 1e9+6;
const ll LINF = 1e18;
const int MOD = 1e9+7;
const double PI = acos(-1);
const double EPS = 1e-10;
static random_device rd;
static mt19937 rnd(rd());

const int N = 1e5;
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s1, s2;
  cin >> s1 >> s2;
  reverse(all(s2));
  cout << (s1==s2 ? "YES" : "NO") << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
//INSERT ABOVE HERE
const Int MAX = 2020;
Int dp[MAX][MAX];
const Int MOD = 1e9+7;
Int ri[MAX][27],le[MAX][27];;
Int n;
string s;
Int dfs(Int l,Int r){
  if(~dp[l][r]) return dp[l][r];
  Int &res=dp[l][r];
  res=1;
  for(Int i=0;i<26;i++){
    if(ri[l][i]<r&&le[r][i]>l){
      res++;
      if(ri[l][i]<le[r][i]) res+=dfs(ri[l][i],le[r][i]);
      res%=MOD;
    }
  }
  return res;
}

signed main(){
  cin>>s;
  s=char('a'+26)+s+char('a'+26);
  n=s.size();
  for(Int i=0;i<n;i++) s[i]-='a';
  memset(dp,-1,sizeof(dp));
  for(Int i=0;i<27;i++) ri[n-1][i]=n,le[0][i]=-1;
  for(Int i=n-2;i>=0;i--){
    for(Int j=0;j<27;j++){
      if(s[i+1]==j) ri[i][j]=i+1;
      else ri[i][j]=ri[i+1][j];
    }
  }
  for(Int i=1;i<n;i++){
    for(Int j=0;j<27;j++){
      if(s[i-1]==j) le[i][j]=i-1;
      else le[i][j]=le[i-1][j];
    }
  }
  cout<<(dfs(0,n-1)+MOD-1)%MOD<<endl;
  return 0;
}



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

vector<int> x(4);
string op = "";

bool dfs(int n, string op, int sum) {
  if (n == 4) {
    return sum == 7;
  }
  if (dfs(n+1, op, sum+x[n])) {
    op[n-1] = '+';
    return true;
  }
  if (dfs(n+1, op, sum-x[n])) {
    op[n-1] = '-';
    return true;
  }
  return false;
}

int main() {
  string n; cin >> n;
  rep(i, 4) {
    x[i] = n[i] - '0';
  }
  if (dfs(1, op, x[0])) {
    rep(i, 3) {
      cout << x[i] << op[i];
    }
    cout << x[3];
  }
  cout << "=7" << endl;
}

Measured memory_bytes: 256
#include<cstdint>
#include<limits>
#include<cstdbool>
#include<cmath>
#include<iostream>
#include<vector>
#include<array>
#include<list>
#include<string>
#include<sstream>
#include<algorithm>

int main(){
	int n,k;
	std::cin>>n>>k;
	int a=1;
	for(int i = 0; i< n ;++i){
		if(a<k)
			a*=2;
		else
			a+=k;
	}
	std::cout<<a;

}


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

using namespace std;

int main() {
  ios::sync_with_stdio(false); cin.tie(NULL);
  int n;
  string s;
  cin >> n >> s;
  int ans = 0;
  for (int i = 0; i + 2 < n; i++) {
    if (s.substr(i, 3) == "ABC") ++ans;
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 256
# -*- coding: utf-8 -*-
n = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)

alice = []
bob = []
for i in range(n):
  if (i % 2) == 0:
    alice.append(a[i])
  else:
    bob.append(a[i])

print(sum(alice) - sum(bob))

Measured memory_bytes: 3060
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long answer = 0;
        for (int i = 1; i <= n; i++) {
            answer += i - 1;
        }
        System.out.println(answer);
    }
}


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

int main(){
  int N, A, B;
  cin >> N >> A >> B;
  int P=0, Q=0, R=0;
  int C;
  for(int i=0; i<N; i++){
    cin >> C;
    if(C<=A){
      P++;
    }
    else if(C<=B){
      Q++;
    }
    else{
      R++;
    }
  }
  cout << min(P, min(Q, R)) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vb = vector<bool>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using vlai = valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1E9
#define LINF 1E18*5
#define EPS 1E-9
#define MOD 1000000007
#define PI 3.1415926535897932384

template<class S, class T>ostream& operator<<(ostream&os, pair<S, T>p) { os << "[" << p.first << ", " << p.second << "]"; return os; };
template<class S>auto&operator<<(ostream&os, vector<S>t) { bool a = 1; for (auto s : t) { os << (a ? "" : " ") << s; a = 0; } return os; }

//int dx[]={1,1,1,0,-1,-1,-1,0},dy[8]={1,0,-1,-1,-1,0,1,1,1};
//
constexpr ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }

int main() {
	int n, C, in1, in2, in3, ans = 0;
	vi s, t, c;
	cin >> n >> C;
	vvi vs(C),vt(C);
	vi v(200002);
	rep(i, n) {
		cin >> in1 >> in2 >> in3;
		vs[in3 - 1].push_back(in1);
		vt[in3 - 1].push_back(in2);
	}
	rep(i, C) {
		vi vtmp(200002);
		rep(j, vs[i].size()) {
			vtmp[vs[i][j] * 2 - 1]++;
			vtmp[vt[i][j] * 2]--;
		}
		range(j, 1, vtmp.size()) {
			vtmp[j] += vtmp[j - 1];
		}
		rep(j, vtmp.size()) {
			if (vtmp[j])v[j]++;
		}
	}
	cout << *max_element(all(v)) << endl;

}


Measured memory_bytes: 3184
#include<stdio.h>

int main(){
	
	int input;
	scanf("%d", &input);
	
	int arr[3005];
	int sum = 0;
	for(int i = 0; i < input; i++){
		scanf("%d", &arr[i]);
		sum += arr[i];
	}
		
	printf("%d\n", sum - input);
	
	return 0;
}

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

int main(){
  int n,m;
  cin >> n >> m;
  vector<int> h(n);
  rep(i,n) cin >> h[i];
  vector<int> a(m);
  vector<int> b(m);
  rep(i,m) cin >> a[i] >> b[i];

  vector<int> h_(n,0);//展望台とつながる展望台の高さの最大値
  rep(i,m){
    h_[a[i]-1] = max(h_[a[i]-1],h[b[i]-1]);
    h_[b[i]-1] = max(h_[b[i]-1],h[a[i]-1]);
  }

  int ans = 0;
  rep(i,n){
    if(h[i]>h_[i]) ans++;
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 4808
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <climits>

static int const N = 100;

int main()
{
  for(;;) {
    int n, m;
    std::cin >> n;
    if ( n == 0 )
      break;

    std::cin >> m;
    int G[N][N] = {};
    for( int i=0; i<N; ++i )
      std::fill( G[i], G[i] + N, INT_MAX );

    for( int i=0; i<m; ++i ) {
      int a, b, l;
      std::scanf( "%d,%d,%d", &a, &b, &l );
      l = l / 100 - 1;
    
      G[a][b] = G[b][a] = l;
    }

    int d[N], p[N] = {};
    bool visited[N] = {};
    std::fill( d, d + N, INT_MAX );
    std::fill( visited, visited + N, false );

    // initialize
    int u = 0;
    d[u] = 0;
    p[u] = -1;
    
    int sum = 0;

    for( int i=0; i<n; ++i ) {
      int tmp = INT_MAX;
      for( int j=0; j<n ; ++j ) {
	if ( !visited[j] && d[j] < tmp ) {
	  u = j;
	  tmp = d[j];
	}
      }
      visited[u] = true;
      sum += d[u];
            
      for( int j=0; j<n; ++j ) {
	if ( !visited[j] && G[u][j] < d[j] ) {
	  d[j] = G[u][j];
	  p[j] = u;
       	}
      }
    }
    std::cout << sum << std::endl;
  }
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
typedef long long int llint;

int main(){
	int n, y, a, b, c;
	cin>>n>>y;
	for(a=0; a<=n; a++){
		for(b=0; b<=n-a; b++){
			c=n-a-b;
			if(10000*a+5000*b+1000*c==y){
				cout<<a<<" "<<b<<" "<<c<<endl;
				return 0;
			}
		}
	}
	cout<<-1<<" "<<-1<<" "<<-1<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream> 
#include<vector>
#include<algorithm>
#include<map>
#include<iomanip>
#include<set>
#include<queue>
#include<deque>
#include<iomanip>
#include<sstream>
#include<cmath>
#include<tuple>
#include<bitset>
using namespace std;
#define rep(i, n) for (ll i = 0; i < (int)(n); i++)
#define req(i,n) for(ll i = 1;i <=  n; i++)
#define rrep(i,n) for(ll i = n -1;i >= 0;i--)
#define ALL(obj) begin(obj), end(obj)
typedef long long int ll;
typedef long double ld;
const int INF =  1e9;
int k, m, t;int  sum = 0, ans = INF; int n; string s;
const ld PI = acos(-1);
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T & val) {
    std::fill((T*)array, (T*)(array + N), val);
}
struct LCA {
    int n, bit; 
    vector<int> depth;
    vector<vector<int>> par, v;
    LCA(int n) : n(n) {
        depth.resize(n, -1);
        bit = 0;
        while (1 << bit <= n)  bit++;
        par.resize(bit);
        for (int i = 0; i < bit; i++)    par[i].resize(n);
        v.resize(n);
    }
    void add_edge(int a, int b) {
        v[a].push_back(b);
        v[b].push_back(a);
    }
    void dfs(int now, int p, int d) {
        par[0][now] = p;
        depth[now] = d;
        for (int child : v[now]) {
            if (child == p)  continue;
            dfs(child, now, d + 1);
        }
    }
    void build() {
        for (int i = 0; i < n; i++) {
            if (depth[i] == -1)    dfs(i, -1, 0);
        }
        for (int k = 0; k + 1 < bit; k++) {
            for (int i = 0; i < n; i++) {
                if (par[k][i] < 0)   par[k + 1][i] = -1;
                else                par[k + 1][i] = par[k][par[k][i]];
            }
        }
    }
    int lca(int a, int b) {
        if (depth[a] > depth[b]) swap(a, b);
        for (int k = 0; k < 30; k++) {
            if (((depth[b] - depth[a]) >> k) & 1) {
                b = par[k][b];
            }
        }
        if (a == b)  return a;
        for (int k = bit - 1; k >= 0; k--) {
            if (par[k][a] != par[k][b]) {
                a = par[k][a];
                b = par[k][b];
            }
        }
        return par[0][a];
    }
    int get_dist(int u, int v) {
        return depth[u] + depth[v] - 2 * depth[lca(u, v)];
    }
    bool is_on_path(int u, int v, int a) {
        return get_dist(u, a) + get_dist(a, v) == get_dist(u, v);
    }
};

int main() {
    int n; cin >> n;
    LCA l(n);
    rep(i,n) {
        int k; cin >> k;
        while (k--) {
            int x; cin >> x;
            l.add_edge(i, x);
        }
    }
    l.build();
    int q; cin >> q;
    while (q--) {
        int u, v; cin >> u >> v;
        cout << l.lca(u, v) <<endl;
    }
}


Measured memory_bytes: 18384
n=int(input())
P=[int(i) for i in input().split()]

cnt=0
for i in range(1,n-1):
  a=P[i-1]
  b=P[i]
  c=P[i+1]
  if max([a,b,c])!=b and min([a,b,c])!=b:
    cnt+=1
print(cnt)

Measured memory_bytes: 3060
//Don't have to see. start------------------------------------------
var read = require('readline').createInterface({
  input: process.stdin, output: process.stdout
});
var obj; var inLine = [];
read.on('line', function(input){inLine.push(input);});
read.on('close', function(){
  obj = init(inLine);
  console.error("\n");
  var start = Date.now();
  Main();
  var end = Date.now() - start;
  myerr("time : " + end + "ms");
  myerr("memory : " + Math.round(process.memoryUsage().heapTotal / 1024) + "KB");
});
function makeClone(obj){return JSON.parse(JSON.stringify(obj));}
function nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}
function nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();}
function init(input){  
  return {
    list : input, index : 0, max : input.length,
    hasNext : function(){return (this.index < this.max);},
    next : function(){if(this.hasNext()){return this.list[this.index++];}else{throw "ArrayIndexOutOfBoundsException ‚There is no more input";}}
  };
}
function myout(s){console.log(s);}
function myerr(s){console.error("debug:" + require("util").inspect(s,false,null));}
//param "no" is
//unknown or outlier : return i. 1: parseInt.
//2: split space. 4: split space and parseInt.
//6: split 1 character. 7: split 1 character and parseInt.
//8: join space. 9: join nextline. 0: join no character.
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map(Number);case 6:return i.split("");case 7:return i.split("").map(Number);case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}

//Don't have to see. end------------------------------------------
function Main(){
  var one = nextIntArray();
    var A = one[0];
    var B = one[1];
    myout(Math.max(0, A - (B * 2)));
}


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

int n;

void dfs(string s, int a) {
  if (s.length() == n) {
    cout << s << endl;
    return;
  }
  int b = s[s.length()-1] - 'a';
  a = max(a, b);
  for (int i = 0; i <= a + 1; i++) {
    dfs(s + char('a' + i), a);
  }
}

int main() {
  cin >> n;
  dfs("a", 0);
  return 0;
}

Measured memory_bytes: 1536
#include <iostream>
#include <cstdio>
#include <string>
#include <cmath>
#include <algorithm>
#include <cctype>
using namespace std;

int main() {
    int a, b;
    cin >> a >> b;
    if (b % a == 0) cout << b + a<<endl;
    else cout << b - a << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define Rep(i,a,b) for(int i=a;i<=b;++i)
#define _Rep(i,a,b) for(int i=a;i>=b;--i)
#define mem(a) memset(a,0,sizeof a)
using namespace std;
typedef long long ll;
typedef string str;

int main()
{
    int a, b;
    cin >> a >> b;
    if(a == b) printf("Yes\n");
    else printf("No\n");
    return 0;
}

Measured memory_bytes: 256
import numpy as np
a=np.array(list(map(int,input().split())))

def f(m,n):
    ret=abs(m-n)/2
    if ret==int(ret):
        return ret
    return int(ret+1)

def solve(a):
    count=0
    a=np.sort(a)
    
    diff=a[2]-a[1]
    a[1]=a[2]
    a[0]+=diff
    count+=diff
    
    diff2=f(a[0],a[1])
    a[0]+=2*diff2
    count+=diff2
    
    if a[0]!=a[1]:
        count+=1
    
    return count

print(int(solve(a)))

Measured memory_bytes: 12496
import java.util.Scanner;
public class Main{
public static void main(String[]args){
Scanner scan=new Scanner(System.in);
double x=scan.nextInt();
double y=scan.nextInt();
double a=x/y;
double b=x%y;
double c=x/y;
int n=(int) a;
int m=(int) b;
System.out.print(n+" "+m+" ");
System.out.printf("%.5f",c);
}
}



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

typedef long long int ll;
#define endl "\n"
#define pll pair<ll, ll>
#define pii pair<int, int>
#define pb push_back
#define vi vector<int>
#define vl vector<ll>
#define vpii vector<pair<int, int>>
#define mems(x, y) memset(x, y, sizeof(x))
#define all(x) (x).begin(), (x).end()
#define forn(i, s, e) for(int i = s; i < (e); ++i)
#define FASTIO                                                                                     \
	ios_base::sync_with_stdio(false);                                                              \
	cin.tie(NULL);
#define FILEIO                                                                                     \
	freopen("./input.txt", "r", stdin);                                                            \
	freopen("./output.txt", "w", stdout);
#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#define time__(d)                                                                                  \
	for(auto blockTime = make_pair(chrono::high_resolution_clock::now(), true); blockTime.second;  \
		debug("%s : %lld ms\n ",                                                                   \
			  d,                                                                                   \
			  chrono::duration_cast<chrono::milliseconds>(chrono::high_resolution_clock::now() -   \
														  blockTime.first)                         \
				  .count()),                                                                       \
			 blockTime.second = false)
const int M = 1e9 + 7;

template <class T>
T ABS(const T& x) {
	return x > 0 ? x : -x;
}
ll gcd(ll n1, ll n2) { return n2 == 0 ? ABS(n1) : gcd(n2, n1 % n2); }
ll lcm(ll n1, ll n2) { return n1 == 0 && n2 == 0 ? 0 : ABS(n1 * n2) / gcd(n1, n2); }
ll ceil2(ll a, ll b) { return (a + b - 1) / b; }

int main() {
	FASTIO
#ifdef LOCAL
	FILEIO
#endif
	int n, m, k;
	cin >> n >> m >> k;
	char grid[n][m];
	forn(i, 0, n) {
		forn(j, 0, m) { cin >> grid[i][j]; }
	}
	int ans = 0;
	for(int r = 0; r < (1 << (n)); ++r) {
		for(int c = 0; c < (1 << m); ++c) {
			int leftb = 0;

			for(int i = 0; i < n; ++i) {
				for(int j = 0; j < m; ++j) {
					if((r & (1 << i)) && (c & (1 << j)) && grid[i][j] == '#') ++leftb;
				}
			}
			if(leftb == k) { ++ans; }
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3568
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
const ll p=1000000007;
int main(){
  int n;
  cin >> n;
  int k[100000];
  rep(i,100000)k[i]=0;
  rep(i,n){
    int u;
    cin >> u;
    u--;
    k[u]++;
  }
  int cnt=0;
  rep(i,100000){
    while(k[i]>2){
      k[i]-=2;
      n-=2;
    }
    if(k[i]==2)cnt++;
  }
  if(cnt%2==1)cnt++;
  cout << n-cnt << endl;
}


Measured memory_bytes: 640
#include<iostream>
using namespace std;
int main(){
	int a, b, c, t = 0, h = 0;
	char d, e;
	while (cin >> a >> d >> b >> e >> c){
		if (a*a + b*b == c*c)t++;
		else if (a == b)h++;
	}
	cout << t << endl;
	cout << h << endl;
	return 0;
}


Measured memory_bytes: 3084
#include <bits/stdc++.h>
#include <atcoder/all>

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

using namespace std;
using namespace atcoder;
using ll = long long;

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

    int n, m;
    cin >> n >> m;
    scc_graph graph(n);
    int a, b;
    rep(i, m) {
        cin >> a >> b;
        graph.add_edge(a, b);
    }

    vector<vector<int>> sccs = graph.scc();
    printf("%d\n", sccs.size());
    for(vector<int> scc: sccs) {
        printf("%d", scc.size());
        for(int i: scc) printf(" %d", i);
        printf("\n");
    }

    return 0;
}

Measured memory_bytes: 40104
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl "\n"

int main() {
	#ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s,t;
    cin>>s>>t;
    ll v=0;
    for(ll i=0;i<s.size();i++)
    {
        if(s[i]!=t[i])
            ++v;
    }
    cout<<v<<endl;
	return 0;
}

Measured memory_bytes: 3832
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <tuple>
using namespace std;

int main(){

    int N, T; cin >> N >> T;

    pair<int, int> ct[N];
    for(int i=0; i<N; i++){
        cin >> ct[i].first >> ct[i].second;
    }

    int cmin = 1e9;
    for(int i=0; i<N; i++){
        if(ct[i].second <= T){
            if(ct[i].first < cmin){
                cmin = ct[i].first;
            }
        }
    }

    if(cmin == 1e9){
        cout << "TLE" << endl;
    }
    else{
        cout << cmin << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
	int n,a,b,aa=0,bb=0,i;
	char s[131072];
	scanf("%d%d%d",&n,&a,&b);
	scanf("%s",s);
	for(i=0;i<n;i++){
		if(s[i]=='a'){
			if(aa+bb<a+b){
				aa++;printf("Yes\n");
			}
			else{printf("No\n");}
		}
		if(s[i]=='b'){
			if((aa+bb<a+b) && (bb<b)){
				bb++;printf("Yes\n");
			}
			else{printf("No\n");}
		}
		if(s[i]=='c'){
			printf("No\n");
		}
	}
	return 0;
}

Measured memory_bytes: 640
#include <stdio.h>
#include <ctype.h>
#define debug
int main(int argv, char *argc[]){
    int x;
    char input[1200];
    
    gets(input);
    
    for(x=0; !('\0' == input[x]); x++){
        if(islower(input[x])) input[x] = toupper(input[x]);
        else if(isupper(input[x])) input[x] = tolower(input[x]);
    }
    
    puts(input);
    return 0;
}

Measured memory_bytes: 524
#include <iostream>
#include <fstream>
#include <iomanip>
#include <climits>
#include <limits>
#include <algorithm>
#include <array>
#include <vector>
#include <deque>
#include <queue>
#include <list>
#include <stack>
#include <string>
#include <functional>
#include <numeric>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <unordered_map>
#include <random>
#include <cmath>
#include <complex>

using namespace std;

typedef long long int ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;

const int INFL = (int)1e9;
const ll INFLL = (ll)1e18;
const double INFD = numeric_limits<double>::infinity();
const double PI = 3.14159265358979323846;
#define Loop(i, n) for(int i = 0; i < (int)n; i++)
#define Loopll(i, n) for(ll i = 0; i < (ll)n; i++)
#define Loop1(i, n) for(int i = 1; i <= (int)n; i++)
#define Loopll1(i, n) for(ll i = 1; i <= (ll)n; i++)
#define Loopr(i, n) for(int i = (int)n - 1; i >= 0; i--)
#define Looprll(i, n) for(ll i = (ll)n - 1; i >= 0; i--)
#define Loopr1(i, n) for(int i = (int)n; i >= 1; i--)
#define Looprll1(i, n) for(ll i = (ll)n; i >= 1; i--)
#define Loopitr(itr, container) for(auto itr = container.begin(); itr != container.end(); itr++)
#define printv(vector) Loop(i, vector.size()) { cout << vector[i] << " "; } cout << endl;
#define printmx(matrix) Loop(i, matrix.size()) { Loop(j, matrix[i].size()) { cout << matrix[i][j] << " "; } cout << endl; }
#define rndf(d) (ll)((double)(d) + (d >= 0 ? 0.5 : -0.5))
#define floorsqrt(x) ((ll)sqrt((double)x) + ((ll)sqrt((double)x) * (ll)sqrt((double)x) <= (ll)(x) ? 0 : -1))
#define ceilsqrt(x) ((ll)sqrt((double)x) + ((ll)x <= (ll)sqrt((double)x) * (ll)sqrt((double)x) ? 0 : 1))
#define rnddiv(a, b) ((ll)(a) / (ll)(b) + ((ll)(a) % (ll)(b) * 2 >= (ll)(b) ? 1 : 0))
#define ceildiv(a, b) ((ll)(a) / (ll)(b) + ((ll)(a) % (ll)(b) == 0 ? 0 : 1))
#define bitmanip(m,val) static_cast<bitset<(int)m>>(val)

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

int main() {
	ll a, b, c, k; cin >> a >> b >> c >> k;
	if (k % 2 == 1) cout << b - a << endl;
	else cout << a - b << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.math.*;

public class Main{
    Main(){
	Scanner sc = new Scanner(System.in);
	BigInteger bi;

	while(sc.hasNext()){
	    int cnt = 0;
	    for(int i = sc.nextInt(); i >= 1; --i){
		bi = new BigInteger(sc.next());
		if(bi.isProbablePrime(1000)) ++cnt;
	    }
	    System.out.printf("%d\n", cnt);
	}
    }

    public static void main(String[] args){
	new Main();
    }
}

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

int main() {
  int N;
  cin>>N;
  vector<string> W(N);
  for(int i=0;i<N;i++){
    cin>>W[i];
  }
  bool flg=true;
  for(int i=0;i<N-1;i++){
    for(int j=i+1;j<N;j++){
      if(W[i]==W[j]){
        flg=false;
        break;
      }
    }
    if(!(W[i].at(W[i].size()-1)==W[i+1].at(0))){
      flg=false;
    }
  }
  if(flg){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define all(a) (a).begin(),(a).end()

using namespace std;

int main(int argc, char const *argv[]) {
  int N;
  scanf("%d",&N);
  int maxID,maxPoint,tempID,tempPoint;
  scanf("%d%d",&maxID,&maxPoint);
  for (size_t i = 1; i < N; i++) {
    scanf("%d%d",&tempID,&tempPoint);
    if(maxID<tempID){
      maxID=tempID;
      maxPoint=tempPoint;
    }
  }
  printf("%d\n",maxID+maxPoint);
  return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.1,sse4.2,popcnt,abm,mmx,avx")
// #pragma comment(linker, "/stack:200000000"]
 
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <unordered_set>
#include <unordered_map>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <bitset>
#include <stack>
#include <random>
#include <fstream>
#include <sstream>
#include <chrono>

#define fi first
#define se second
#define pb push_back
#define ll long long
#define ld long double
#define hm unordered_map 
#define pii pair<int, int>
#define sz(a) (int)a.size()
#define all(a) a.begin(), a.end()
#define cinv(v) for (auto& x: v) cin >> x
#define fr(i, n) for (int i = 0; i < n; ++i)
#define fl(i, l, n) for (int i = l; i < n; ++i)

#define int ll

using namespace std;

#ifdef __LOCAL
	#define dbg(x) cerr << #x << " : " << x << '\n'
	const int maxn = 20;
#else 
	#define dbg(x)
	const int maxn = 2e5 + 20;
#endif

//tg: @galebickosikasa
 
const ll inf = (ll) 2e9;
const ld pi = asin (1) * 2;
const ld eps = 1e-8;
const ll mod = (ll)1e9 + 7;
const ll ns = 97;

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



signed main () {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	int n;
	cin >> n;
	vector<int> goo (n);
	cinv (goo);
	hm <int, int> a, b, c, d;
	fr (i, n) {
		++a[goo[i] - i];
		++b[-goo[i] - i];
		++c[goo[i] + i];
		++d[-goo[i] + i];
		dbg (goo[i] - i);
		dbg (-goo[i] - i);
		dbg (goo[i] + i);
		dbg (-goo[i] + i);
	}
	int ans = 0;
	for (auto& x: a) {
		ans += x.se * b[x.fi];
	}
	for (auto& x: c) {
		ans += x.se * d[x.fi];
	}
	cout << ans / 2;







}

Measured memory_bytes: 51204
#include <iostream>
#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>
#include <numeric>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF 1e18
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define PI (acos(-1))

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


int main() {

    int a, b;
    cin >> a >> b;
    int c = min(a, b);
    int d = max(a, b);
    REP(i, d) cout << c;
    cout << endl;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
 
int isok(char*);
void siza(char*);
 
int main(void) {
    char data[100];
    while(!feof(stdin)) {
        if(fgets(data,sizeof(data),stdin)==NULL)break;
        while(!isok(data))siza(data);
        printf("%s",data);
    }
    return 0;
}
 
int isok(char* data) {
    if(strstr(data,"the"))return 1;
    if(strstr(data,"this"))return 1;
    if(strstr(data,"that"))return 1;
    return 0;
}
 
void siza(char* data) {
    int i;
    for(i=0;data[i]!=0;i++) {
        if(data[i]>='a' && data[i]<='z') {
            if(data[i]=='z')data[i]='a';
            else data[i]++;
        }
    }
}

Measured memory_bytes: 528
#include <stdio.h>

int main(void){
	int a,b,c,d,e,f;
	float x,y;
	while(scanf("%d %d %d %d %d %d",&a,&b,&c,&d,&e,&f)!=EOF){
		x=1.0*(c*e-b*f)/(a*e-d*b)+0.0;
		y=1.0*(d*c-a*f)/(d*b-a*e)+0.0;
		printf("%.3lf %.3lf\n",x,y);
	}
}

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


int main() {
	string s; cin >> s;
	int d; cin >> d;
	vector<vector<vector<ll> > > dp(s.size()+1, vector<vector<ll> >(d, vector<ll>(2)));
	dp[0][0][0] = 1;

	for (int i = 0; i < s.size(); ++i)
	{
		for (int j = 0; j < d; ++j)
		{
			for (int k = 0; k < 10; ++k)
			{
				dp[i+1][(j+k)%d][1] += dp[i][j][1];
				dp[i+1][(j+k)%d][1] %= MOD;
				if (s[i]-'0' == k)
				{
					dp[i+1][(j+k)%d][0] += dp[i][j][0];
					dp[i+1][(j+k)%d][0] %= MOD;
				} else if (s[i]-'0' > k) {
					dp[i+1][(j+k)%d][1] += dp[i][j][0];
					dp[i+1][(j+k)%d][1] %= MOD;
				}
			}
		}
	}
	ll ans = dp[s.size()][0][0] + dp[s.size()][0][1] - 1;
	cout << (ans+MOD)%MOD << endl;
	return 0;
}

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

int main() {
    double a, b, c, d;
    cin >> a >> b >> c >> d;
    while(1) {
        c -= b;
        if(c <= 0) {
            cout << "Yes" << endl;
            return 0;
        }
        a -= d;
        if(a <= 0) {
            cout << "No" << endl;
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 3716
//Atcoder
import java.io.*;
import java.util.*;

public class Main {

	static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner() {
            try {
                br = new BufferedReader(new InputStreamReader(System.in));
                st = new StringTokenizer(br.readLine());
            } catch (Exception e){e.printStackTrace();}
        }

        public String next() {
            if (st.hasMoreTokens()) return st.nextToken();
            try {st = new StringTokenizer(br.readLine());}
            catch (Exception e) {e.printStackTrace();}
            return st.nextToken();
        }

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

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

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

        public String nextLine() {
            String line = "";
            if(st.hasMoreTokens()) line = st.nextToken();
            else try {return br.readLine();}catch(IOException e){e.printStackTrace();}
            while(st.hasMoreTokens()) line += " "+st.nextToken();
            return line;
        }
    }

	public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        PrintWriter pw = new PrintWriter(System.out);

        String str = sc.nextLine();
        boolean one = false, two = false; 

        int first = Integer.parseInt(str.substring(0, 2));
        int second = Integer.parseInt(str.substring(2));

        if(first <= 12 && first > 0) {
            one = true;
        }
        if(second <= 12 && second > 0) {
            two = true;
        }

        if(one && two) pw.println("AMBIGUOUS");
        else if(one) pw.println("MMYY");
        else if(two) pw.println("YYMM");
        else pw.println("NA"); 

        pw.close();
    }
}


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

int main(){
  int k;
  cin >> k;
  int dp[10][10];
  for(int i=0; i<10; ++i){
    dp[0][i] = 1;
  }
  for(int i=1; i<10; ++i){
    for(int j=0; j<10; ++j){
      dp[i][j] =0;
      if(j!=0) dp[i][j] += dp[i-1][j-1];
      dp[i][j] += dp[i-1][j];
      if(j!=9) dp[i][j] += dp[i-1][j+1];
    }
  }
  int keta, top, sowa=0;
  for(int i=0; i<10; ++i){
    for(int j=1; j<10; ++j){
      sowa += dp[i][j];
      if(sowa >= k){
        keta = i+1;
        top = j;
        break;
      }
    }
    if(sowa>=k) break;
  }
  ll ans=top;
  while(keta>1){
    ans *= 10;
    sowa -= dp[keta-1][top];
    if(top != 0){
      sowa += dp[keta-2][top-1];
      if(sowa >= k){
        ans += top-1;
        --keta; --top;
        continue;
      }
    }
    sowa += dp[keta-2][top];
    if(sowa >= k){
      ans += top;
      --keta;
      continue;
    }
    sowa += dp[keta-2][top+1];
    if(sowa >= k){
      ans += top +1;
      --keta; ++top;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
ll mod = 1e9+7;
ll p = 41;
 
ll pref[5005], power[5005], inv[5005];
 
ll modpow(ll b, ll e){
    ll res = 1;
    while(e >= 1){
        if(e & 1) res = (res * b) % mod;
        e /= 2;
        b = (b * b) % mod;
    }
    return res;
}
 
ll gethash(int i, int j){
    ll aux = (pref[j] - pref[i-1] + mod)%mod;
    aux = (aux*inv[i-1])%mod;
    return aux;
}
 
int main(){
    int n; cin >> n;
    string s; cin >> s;
    
    s = "$" + s;
    // inv[0] = 1;
    // power[0] = 1;
    // for(int i = 1; i <= n; i++)
    //     power[i] = (power[i-1]*p)%mod;
    // for(int i = 1; i <= n; i++)
    //     inv[i] = modpow(power[i], mod-2);
    // for(int i = 1; i <= n; i++){
    //     pref[i] = pref[i-1] + (power[i]*(s[i]-'a' + 1))%mod;
    //     pref[i] %= mod;
    // }
    
    // for(int i = 1; i <= n; i++)
    //     cout << "pref[" << i << "] = " << pref[i] << endl;
    
    int l = 1, r = n/2;
    int res = 0;
    
    // cout << gethash(1, 1) << endl;
    // cout << gethash(2, 2) << endl;
    
    while(l <= r){
        int mid = (l+r)/2;
        int ok = 0;
        map<string, vector<int> > mapa;
        for(int i = 1; i+mid-1 <= n; i++)
            mapa[s.substr(i, mid)].push_back(i);
        for(auto par : mapa){
            vector<int>& v = par.second;
            if(v.size() >= 2 and v.back() - v.front() >= mid) ok = 1;
            if(ok) break;
        }
        if(ok) res = max(res, mid), l = mid+1;
        else r = mid-1;    
    }
    cout << res << endl;
    return 0;
}

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

void func140c() {
  int n, ans = 0;
  cin >> n;
  vector<int> b(n-1);
  for (int i = 0; i < n-1; i++) cin >> b[i];
  ans += b[0];
  for (int i = 1; i <= n-2; i++) {
    ans += min(b[i], b[i-1]);
  }
  ans += b[n-2];
  cout << ans << "\n";
}

int main() {
  func140c();
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
int main(void)
{
	//変数の宣言
	int n,m;
	long long int x[100010];
	long long int y[100010];

	//よく使う変数
	int i,j,k,l;
	int flag=0;
	long int ans=0;
	int count=0;
	long long int temp,temp1,temp2;
	int max,min;
	int len;
	//データの読み込み
	
	scanf("%d %d",&n,&m);
	
	for(i=0;i<n;i++){
		scanf("%lld",&x[i]);
	}

	for(i=0;i<m;i++){
		scanf("%lld",&y[i]);
	}

//	printf("nは%dです\n", n);
//	printf("データの読み込み終了\n");
	//実際の処理
	
	temp1=0;
	temp2=0;
	for(i=0;i<n-1;i++){
		temp=(long long int)(n-i-1)*(i+1)%1000000007;
//		printf("n-i-1=%d,i+1=%d\n",n-i-1,i+1);
		temp=temp*(x[i+1]-x[i])%1000000007;
		temp1=(temp1+temp)%1000000007;
//		printf("i=%d,dx=%d,temp=%d\n",i,x[i+1]-x[i],temp);
//		printf("temp1=%lld\n",temp1);
	}
	
	for(i=0;i<m-1;i++){
		temp=(long long int)(m-i-1)*(i+1)%1000000007;
//		printf("m-i-1=%d,i+1=%d\n",m-i-1,i+1);
		temp=temp*(y[i+1]-y[i])%1000000007;
		temp2=(temp2+temp)%1000000007;
//		printf("i=%d,dy=%d,temp=%d\n",i,y[i+1]-y[i],temp);
//		printf("temp2=%lld\n",temp2);
	}

	
	
//	printf("計算部分終了\n");
	//出力
	
	printf("%lld",temp1*temp2%1000000007);
	
//	printf("結果の出力終了\n");
	
	return 0;
	
}



Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<(n);++i)
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; }
int gcd(int a,int b) { return b ? gcd(b,a%b) : a;}
int lcm(int a,int b) { return a/gcd(a,b)*b;}
void printb(unsigned int v) {
  unsigned int mask = (int)1 << (sizeof(v) * CHAR_BIT - 1);
  do putchar(mask & v ? '1' : '0');
  while (mask >>= 1);
}
void putb(unsigned int v) {putchar('0'), putchar('b'), printb(v), putchar('\n');}
#define ALL(W) (W).begin(),(W).end()

signed main(){
  int N;
  cin >> N;
  int A[N]={};
  rep(i,N) cin >> A[i];
  sort(A,A+N);
  reverse(A,A+N);
  int c=0,a,b;
  rep(i,N-1){
    if(A[i]==A[i+1] && c==0){
      a=A[i];
      c++;
      i++;
    }
    else if(A[i]==A[i+1] && c==1){
      b=A[i];
      c++;
      break;
    }
  }
  if(c==2) cout << a*b << endl;
  else cout << 0 << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cmath>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main() {
  string S;
  cin >> S;
  int b = 0;
  ll ans = 0;
  rep(i, S.size()) {
    if (S[i] == 'W')
      ans += b;
    else
      b++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 640
N, K = map(int, input().split())

ans = 0

if K == 0:
    ans = N ** 2
else:
    for b in range(K, N+1):
        if b == 0 or b == 1:
            continue

        x = N // b
        y = N % b

        ans += x * (b-K)
        if y >= K:
            ans += y-(K-1)


print(ans)

Measured memory_bytes: 3064
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Arrays;
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    resolve(System.in, System.out);
  }

  static void resolve(InputStream is, PrintStream pw) {
    Scanner sc = new Scanner(is);
    int h = Integer.parseInt(sc.next());
    int w = Integer.parseInt(sc.next());
    int k = Integer.parseInt(sc.next());
    int[][] board = new int[h][w];
    for (int i = 0; i < h; i++) {
      String l = sc.next();
      for (int j = 0; j < w; j++) {
        if (l.charAt(j) == '#') {
          board[i][j] = 1;
        }
      }
    }
    pw.println(recursive(board, 0, 0, h, w, k));
  }

  static int recursive(int[][] board, int currentH, int currentW, int h, int w, int expected) {
    if (currentH == h && currentW == w) {
      if (cont(board) == expected) {
        return 1;
      } else {
        return 0;
      }
    }
    if (currentH < h) {
      int ans = 0;
      ans += recursive(
        paintRow(copy(board, h, w), currentH, w), currentH + 1, currentW, h, w, expected);
      ans += recursive(board, currentH + 1, currentW, h, w, expected);
      return ans;
    }
    if (currentW < w) {
      int ans = 0;
      ans += recursive(
        paintCol(copy(board, h, w), currentW, h), currentH, currentW + 1, h, w,
        expected);
      ans += recursive(board, currentH, currentW + 1, h, w, expected);
      return ans;
    }
    throw new RuntimeException();
  }

  static int[][] copy(int[][] board, int h, int w) {
    int[][] clone = new int[h][w];
    for (int i = 0; i < h; i++) {
      clone[i] = Arrays.copyOf(board[i], w);
    }
    return clone;
  }

  static int[][] paintRow(int[][] board, int targetRow, int w) {
    for (int i = 0; i < w; i++) {
      board[targetRow][i] = 2;
    }
    return board;
  }

  static int[][] paintCol(int[][] board, int targetCol, int h) {
    for (int i = 0; i < h; i++) {
      board[i][targetCol] = 2;
    }
    return board;
  }

  static int cont(int[][] board) {
    int ans = 0;
    for (int i = 0; i < board.length; i++) {
      for (int j = 0; j < board[i].length; j++) {
        ans += board[i][j] == 1 ? 1 : 0;
      }
    }
    return ans;
  }

  static void debug(int[][] board) {
    for (int i = 0; i < board.length; i++) {
      for (int j = 0; j < board[i].length; j++) {
        System.out.print(board[i][j]);
      }
      System.out.println();
    }
    System.out.println();
  }
}


Measured memory_bytes: 40388
#include<iostream>
#include<set>
using namespace std;main(){int n,m,i,t,x;while(cin>>n>>m,n|m){
set<int> s;for(i=0;i++<n+m;s.insert(t))cin>>t;x=t=0;for(set<int>::iterator r=s.begin();r!=s.end();t=*r++)if(x<*r-t)x=*r-t;cout<<x<<endl;}}

Measured memory_bytes: 1336
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); i++)
#define RREP(i, s, n) for (int i = s; i < (n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;
using ll = long long;
typedef pair<int, int> pint;
typedef pair<ll, ll> pll;
const ll MOD = 1000000007;
const ll INF = MOD * MOD;
const int inf = (1<<29);

int main() {

    ll n, d;
    cin >> n >> d;
    
    vector<ll> a(n), b(n);
    REP(i, n) cin >> a[i] >> b[i];

    ll res = 0;

    for(ll i = 0; i < n; i++) {
        if (a[i]*a[i] + b[i]*b[i] <= d*d) res++;
    }
    
    cout << res << endl;
    
    return 0;
}

Measured memory_bytes: 6424
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define int ll
#define double long double
#define YES cout<<"YES"<<'\n'
#define NO cout<<"NO"<<'\n'
#define Yes cout<<"Yes"<<'\n'
#define No cout<<"No"<<'\n'
#define yes cout<<"yes"<<'\n'
#define no cout<<"no"<<'\n'
void YN(bool flg) {cout<<(flg?"YES":"NO")<<'\n';}
void Yn(bool flg) {cout<<(flg?"Yes":"No")<<'\n';}
void yn(bool flg) {cout<<(flg?"yes":"no")<<'\n';}
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())
#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 out(n) cout << n << '\n'
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<VI> VVI;
const int MOD = 1000000007;
const long long INF = 10e10;
const double PI = acos(-1.0);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
int ABS(int a) {if(a<0) a = -a; return a;}
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }
int POW(int a, int n) { int r = 1; while (n > 0) { if (n & 1)r *= a; a *= a; n >>= 1; }return r; }
int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*素因数分解*/map< int, int >prime_factor(int n){map< int, int > ret;for(int i = 2; i * i <= n; i++) {while(n % i == 0) {ret[i]++;n /= i;}}if(n != 1) ret[n] = 1;return ret;}
/*約数の個数*/int divisor_number(int n){auto p = prime_factor(n); int res = 1; for(auto x:p)res*=(x.second+1); return res;}
/*約数列挙*/vector<int> divisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}
//----------------ライブラリとか----------------

int digit_sum(int n){int sum=0 , tmp=n; while(tmp>0){sum+=tmp%10; tmp/=10;} return sum;}

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

    int n,a,b; cin >> n >> a >> b;
    int ans = 0;
    FOR(i,1,n+1) if(a<=digit_sum(i)&&digit_sum(i)<=b) ans+=i;
    out(ans);

    return 0;
}

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

int main(){
    
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    ll n;
    cin >> n;
    
    ll x = sqrt(n);
    
    ll a = 1e12;
    ll b = 1e12;
    
    for(ll i = 1; i <= x; i++){
        if(n % i == 0){
            if(n / i + i <= a + b){
                a = n/ i;
                b = i;
            }
        }
    }
    cout << a + b - 2 << endl;
}

Measured memory_bytes: 384