akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <bits/stdc++.h>
using namespace std;

int main() {
	// your code goes here
	int n;
	cin>>n;
	bool contains = false;
	while(n != 0){
		int check = n%10;
		if(check == 7){
			contains = true;
			break;
		}
		n /= 10;
	}
	if(contains)
		cout<<"Yes";
	else
		cout<<"No";
	return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std;
int main(){
    int N,K;
    cin>>N>>K;
    vector<int> l(N);
    for(int i=0; i<N; i++) cin>>l[i];
    sort(l.begin(),l.end());
    reverse(l.begin(),l.end());
    int ans =0;
    for(int i=0;i<K; i++) ans += l[i];
    cout<<ans<<endl;
}

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

int main(){
    string a,b,c;

    cin >> a >> b >> c;

    if(a.back() == b.front() && b.back() == c.front() ){
        cout << "YES" << endl;
     }else{
         cout << "NO" << endl;
     }
    
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include <numeric>


#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 FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

typedef long long int ll;
#define ARRAY_MAX 100005

vector<int> par(ARRAY_MAX);//親
vector<int> ran(ARRAY_MAX);//木の深さ

typedef struct edge{

    int u;
    int v;
    int cost;

}EDGE;

typedef struct where{

    int num;
    int x;
    int y;

}WHERE;

bool comp(const EDGE& e1,const EDGE& e2){
    return e1.cost < e2.cost;
}


bool compx(const WHERE& e1,const WHERE& e2){
    return e1.x < e2.x;
}


bool compy(const WHERE& e1,const WHERE& e2){
    return e1.y < e2.y;
}


//n要素で初期化
void init(int n){
    for(int i = 0;i < n;i++){
        par[i] = i;/*各ノードに番号を振る,この時par[x]=xとなる時は木の根となる*/
        ran[i] = 0;/*各ノード自体の高さは0*/
    }
}
//木の根を求める
int find(int x){
    if(par[x] == x){
        return x;/*根ならそのノードの番号を返す*/
    }else{
        return par[x] = find(par[x]);/*根でないならさらにノードの根を探す*/
    }
}

//xとyの属する集合を併合する
void unite(int x,int y){
    x = find(x);//xの根の番号を探す
    y = find(y);//yの根の番号を探す
    if(x == y){//一致すればつながっている
        return;
    }
    if(ran[x] < ran[y]){//xの高さが低いなら高いほうにつなぐ、そして高さは大きい方(y)になる
        par[x] = y;
    }else{
        par[y] = x;//yの高さが低いなら高いほうにつなぐ、そして高さは大きいほう(x)になる
        if(ran[x] == ran[y]){//高さが一致しているなら併合の高さは1増える
            ran[x]++;
        }
    }
}

//xとyが同じ集合に属するか判定
bool same(int x,int y){
    return find(x) == find(y);//同じ集合なら1、違うなら0が返る
}

int kruskal(int n,int count,vector<EDGE>& es){

    sort(es.begin(),es.end(),comp);
    init(n);
    int res = 0;
    for(int i = 0;i < count;i++){
        EDGE e = es[i];
        if(!same(e.u,e.v)){
            unite(e.u,e.v);
            res += e.cost;
        }
    }
    return res;
}


/*最小全域木をクラシカル法で実装*/

int main(){

    int n,e;
    cin >> n >> e;
    vector<EDGE> es;
    vector<WHERE> map(n);

    for(int i = 0;i < e;i++){
        EDGE e;
        cin >> e.u >> e.v >> e.cost;
        es.push_back(e);
    }

    int ans = kruskal(n,e,es);
    cout << ans << endl;



    return 0;
}


Measured memory_bytes: 5520
h , w = map(int, input().split())
n = int(input())
a = list(map(int,input().split()))
p = []
p2 = []
j = 1
for i in a:
    p+=[str(j)]*i
    j+=1
for i in range(h):
    p2.append(p[i*w:i*w+w])
for i in range(h):
    if i%2==1:
        p2[i].reverse()
for i in p2:
    print(" ".join(i))


Measured memory_bytes: 3828
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int INF = 1000000000;
#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define rep(i,n) REP(i, 0, n)
vector<int> f[30];
bool memo[50][50];
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, _t, _f;
    while(cin >> N && N){
        rep(i, 30) f[i].clear();
        memset(memo, 0, sizeof(memo));
        rep(i, N) memo[i][i] = true;
        rep(i, N){
            cin >> _t;
            rep(j, _t){
                cin >> _f; --_f;
                f[_f].push_back(i);
            }
        }
        rep(i, 30){
            for(int k : f[i])
              for(int l : f[i])
                rep(j, N)
                  memo[k][j] |= memo[l][j];
            rep(j, N)
              if(count(memo[j], memo[j] + N, 1) == N){
                  cout << i + 1 << endl;
                  goto success;
              }
        }
        cout << -1 << endl;
        continue;
      success: continue;
    }
    return 0;
}

Measured memory_bytes: 3112
import bisect

n = int(input())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
c = [int(i) for i in input().split()]
a.sort()
b.sort()
c.sort()


total = 0
for i in b:
    a_number = bisect.bisect_left(a, i)
    c_number = n - bisect.bisect_right(c, i)
    total = total +  a_number * c_number
print(total)



Measured memory_bytes: 22592
from collections import deque
from enum import Enum
import sys
import math
 
BIG_NUM = 2000000000
MOD = 1000000007
EPS = 0.000000001
 
 
DICTIONARY = {}
num_query = int(input())
 
for loop in range(num_query):
    input_str = input().split()
    if input_str[0] == 'insert':
        DICTIONARY[input_str[1]] = True
    else:
        if DICTIONARY.__contains__(input_str[1]):
            print("yes")
        else:
            print("no")


Measured memory_bytes: 33864
#include <iostream>
#include <vector>
#include <set>
#include <cstdio>
#include <list>

using namespace std;

typedef long long ll;

static const ll MAX = 1e10;

enum Data {Space, File};

struct Range {
  Data d;
  int id;
  ll start;
  ll end;
  ll size() const {
    return end - start;
  }
  bool operator<(const Range& rhs) const {
    return start < rhs.start;
  }
  void print() const {
    printf("%c %d %lld %lld\n", (d == Space) ? 'S' : 'F', id, start, end);
  }
  Range(Data d, int id, ll start, ll end) : d(d), id(id), start(start), end(end) {}
};

int N;
list<Range> sector;
typedef list<Range> L;

void solve() {
  for (int i = 0; i < N; i++) {
    char cmd;
    cin >> cmd;
    switch (cmd) {
    case 'W': {
      ll id, size;
      cin >> id >> size;
      for (L::iterator it = sector.begin(); it != sector.end(); it++) {
        if (it->d == Space) {
          if (it->size() >= size) {
            Range file(File, id, it->start, it->start + size);
            sector.insert(it, file);
            it->start += size;
            break;
          } else {
            it->d = File;
            it->id = id;
            size -= it->size();
          }
        }
      }
      break;
    }
    case 'D': {
      ll id;
      cin >> id;
      for (L::iterator it = sector.begin(); it != sector.end(); it++) {
        if (it->d == File && it->id == id) {
          L::iterator prev_it = it;
          prev_it--;
          
          if (it != sector.begin() &&
              prev_it->end == it->start && prev_it->d == Space) {
            prev_it->end += it->size();
            it = sector.erase(it);
            goto next;
          } else {
            L::iterator next_it = it;
            next_it++;
            if (it != sector.end() && 
                next_it->start == it->end && next_it->d == Space) {
              next_it->start -= it->size();
              it = sector.erase(it);
              goto next;
            }
          }
          it->d = Space;
        next:;
        }
      }
      break;
    }
    case 'R': {
      ll sec;
      cin >> sec;
      for (L::iterator it = sector.begin(); it != sector.end(); it++) {
        if (it->start <= sec && sec < it-> end) {
          if (it->d == Space) {
            cout << -1 << endl;
          } else {
            cout << it->id << endl;
          }
          break;
        }
      }
      break;
    }
    }
    /*
    cout << "debug" << endl;
    for (L::iterator it = sector.begin(); it != sector.end(); it++) {
      it->print();
    }
    cout << endl;
    */
    //cout << "debug" << endl;
    //cout << sector.size() << endl;
  }
}

void init() {
  sector.clear();
  sector.push_back(Range(Space, -1, 0, MAX));
}

int main() {
  while (true) {
    cin >> N;
    if (N == 0) {
      return 0;
    }
    init();
    solve();
    cout << endl;
  }
}

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

#define REP(i,n) for(ll i=0; i<(ll)(n); i++)
#define FOR(i,n,m) for (ll i=n; i<(ll)(m); i++)
#define pb push_back
#define INF 1000000007LL
#define all(a) (a).begin(),(a).end()

typedef long long ll;
typedef pair<ll,ll> p;

ll dy[4]={-1,1,0,0};
ll dx[4]={0,0,1,-1};

#define MAX_N 100010
ll N,M,K;

vector<ll> swpow(vector<ll> &sw, ll k) {
    vector<ll> ret(sw.size());
    if (k==1) {
        REP(i,sw.size()) {
            ret[i]=sw[i];
        }
        return ret;
    }
    if (k==0) {
        REP(i,sw.size()) {
            ret[i]=i;
        }
        return ret;
    }
    vector<ll> sret = swpow(sw, k/2);
    REP(i,sw.size()) ret[i]=sret[sret[i]];
    if(k%2==0) return ret;
    REP(i,sw.size()) sret[i]=ret[sw[i]];
    return sret;
}

int main(){
    ios::sync_with_stdio(false);
    cin >> N;
    vector<ll> x(N);
    REP(i, N) cin >> x[i];
    vector<ll> diff;
    REP(i,N-1) diff.pb(x[i+1]-x[i]);
    vector<ll> sw;
    REP(i,N-1) sw.pb(i);
    cin >> M >> K;
    vector<ll> a(M);
    REP(i,M) {cin >> a[i];a[i]--;}
    REP(i,M) swap(sw[a[i]],sw[a[i]-1]);
    sw= swpow(sw, K);
    ll ans = x[0];
    cout << ans << endl;
    REP(i,N-1) {
        ans+=diff[sw[i]];
        cout << ans << endl;
    }
    return 0;
}


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

using namespace std;
using ll = long long;
using pint = pair<int, int>;

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

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

	vector<ll> ans(N, 0);
	for (int i = 0; i < M; ++i) {
		int A, B;
		cin >> A >> B;
		A--;
		B--;
		ans[A] = max(ans[A], H[B]);
		ans[B] = max(ans[B], H[A]);
	}

	int cnt = 0;
	for (int i = 0; i < N; ++i) {
		if (ans[i] < H[i]) {
			cnt++;
		}
	}
	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 4784
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1001001001;
const int MOD = 1e9 + 7;

int main() {
  int n, k;
  cin >> n >> k;
  vector<ll> plus;
  vector<ll> minus;
  rep(i, n) {
    ll a;
    cin >> a;
    if (a < 0)
      minus.push_back(a);
    else
      plus.push_back(a);
  }

  ll ans = 1;
  if (n == k) {
    for (ll el : minus) ans = (ans * el) % MOD;
    for (ll el : plus) ans = (ans * el) % MOD;
  } else if (plus.empty()) {
    if (k % 2 == 1) {
      sort(minus.rbegin(), minus.rend());
    } else {
      sort(minus.begin(), minus.end());
    }
    rep(i, k) ans = (ans * minus[i]) % MOD;
  } else if (minus.empty()) {
    sort(plus.rbegin(), plus.rend());
    rep(i, k) ans = (ans * plus[i]) % MOD;
  } else {
    sort(plus.rbegin(), plus.rend());
    sort(minus.begin(), minus.end());
    int pItr = 0;
    int mItr = 0;
    vector<ll> s;
    if (k % 2 == 1) {
      s.push_back(plus[pItr]);
      pItr += 1;
      k--;
    }
    while (s.size() < k) {
      bool plusP;
      if (pItr == plus.size()) {
        plusP = false;
      } else if (mItr == minus.size()) {
        plusP = true;
      } else {
        ll p = plus[pItr] * plus[pItr + 1];
        ll m = minus[mItr] * minus[mItr + 1];
        plusP = p > m;
      }
      if (plusP) {
        s.push_back(plus[pItr]);
        s.push_back(plus[pItr + 1]);
        pItr += 2;
      } else {
        s.push_back(minus[mItr]);
        s.push_back(minus[mItr + 1]);
        mItr += 2;
      }
    }
    for (ll el : s) {
      ans = (ans * el) % MOD;
    }
  }
  ans = (ans + MOD) % MOD;
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 8112
#include <iostream>
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
/* run this program using the console pauser or add your own getch, system("pause") or input loop */

using namespace std;
int main(int argc, char** argv) {
	
	int n,a,b;
	scanf("%d%d%d",&n,&a,&b);
	
	if(a>b || (n==1 && a!=b)) 
	printf("0");
	else if(n==1 && a==b)
	printf("1");
	else 
	{
		printf("%lld",(long long)(b-a)*(n-2)+1);
	}
	
	return 0;
}

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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl





using ll = long long;


const int maxn = 1e6 + 5;




int n;
string s;

vector<pair<int,int>> edges;


void addEdge(int u, int v) {
    edges.emplace_back(u,v);
}


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

    cin>>s;
    n = s.length();
    s = "*" + s;

    if (s[n] == '1') {
	out(-1);
    }


    for (int i=1; i<n; i++) {
	if (s[i] != s[n-i]) {
	    out(-1);
	}
    }

    if (s[1]=='0' || s[n-1]=='0') {
	out(-1);
    }

    int root = 1;
    int ptr = 2;
    int bag = 1;

    for (int i=2; i<=n/2; i++) {
	if (s[i]=='1') {
	    int use = i-bag;
	    int nroot = ptr++;use--; bag++;

	    addEdge(root,nroot);
	    while (use>0) {
		addEdge(nroot,ptr++);
		bag++;
		use--;
	    }
	    root = nroot;
	}
    }

    addEdge(root,ptr);
    root = ptr++;
    while (ptr<=n) {
	addEdge(root, ptr++);
    }


    for (auto p: edges) {
	assert(p.first<=n && p.second<=n);
	cout<<p.first<<" "<<p.second<<"\n";
    }
    
    return 0;
}


Measured memory_bytes: 4280
package main

import "fmt"
import "os"
import "bufio"
import "bytes"
import "strconv"

const NEW_LINE byte = 10
const SPACE string = " "

type long int64
type float float32
type double float64

var reader *bufio.Reader
var buffer[][]byte
var pointer int


func InitReader() {
  reader = bufio.NewReaderSize(os.Stdin,4096)
}

func ReadLine() []byte {
  retBytes,_ := reader.ReadBytes(NEW_LINE)
  return retBytes
}

func Next() string {
  if pointer < len(buffer){
    ret := buffer[pointer]
    pointer++
    return string(ret)
  }
  bs := ReadLine()
  bs = bs[0:len(bs)-1]
  buffer = bytes.Split(bs,[]byte(SPACE))
  pointer = 0
  return Next()
}

func NextLine() string {
  b := ReadLine()
  return string(bytes.TrimSpace(b))
}

func NextInt() int {
  s := Next()
  i,_ := strconv.ParseInt(s,10,32)
  return int(i)
}

func NextLong() long {
  s := Next()
  l,_ := strconv.ParseInt(s,10,64)
  return long(l)
}

func NextFloat() float {
  s := Next()
  f,_ := strconv.ParseFloat(s,32)
  return float(f)
}

func NextDouble() double {
  s := Next()
  d,_ := strconv.ParseFloat(s,64)
  return double(d)
}

func Min(x,y long) long {
 if x < y {
  return x
 }
 return y
}

func main() {
  InitReader()
  
  var N,x,ans,i long
  var a [100000]long
  
  N = NextLong()
  x = NextLong()
  for i=0;i<N;i++ {
    a[i] = NextLong()
  }
   
  for i=1;i<N;i++ {
    var diff long = a[i-1]+a[i]-x
    if diff > 0 {
      ans += diff
      min := Min(diff,a[i])
      a[i] -= min
      diff -= min
      if diff > 0 {
        a[i-1]-=diff
      }
    }
    
  }
  fmt.Println(ans)
}




Measured memory_bytes: 6656
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int l,r,d;
	cin>>l>>r>>d;
	int cnt=0;
	for(int i=l;i<=r;i++)
		if(i%d==0)
			cnt++;
	cout<<cnt<<endl;
	return 0;
}

Measured memory_bytes: 3560
N = int(input())
A1 = input().split(' ')
A2 = input().split(' ')
A1 = [int(A1[i]) for i in range(N)]
A2 = [int(A2[i]) for i in range(N)]
Saidai = 0
for i in range(N):
  Atai = 0
  for j in range(i+1):
    Atai += A1[j]
  for h in range(i, N):
    Atai += A2[h]
  if Atai > Saidai:
    Saidai = Atai
print(Saidai)

Measured memory_bytes: 9108
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.nextLine();
		char a = s.charAt(0);
		char b = s.charAt(1);
		char c = s.charAt(2);
		char d = s.charAt(3);
		char[] chars = new char[] { a, b, c, d };

		for (int i = 0; i <= 3; i++) {
			int con = 0;
			for (int n = 0; n <= 3; n++) {
				if (chars[i] == chars[n]) {
					con += 1;
				}
			}
			if (con == 2) {
				if (i == 3) {
					System.out.println("Yes");
					break;
				}
			} else {
				System.out.println("No");
				break;
			}
		}
	}
}

Measured memory_bytes: 21972
#include<bits/stdc++.h>
using namespace std;
 
int max(int a,int b){
	return (a>b)?a:b;
}
 
int calc(int start,int end,int dp[],int arr[]){
	int mn = INT_MAX;
  	for(int i=start;i>=end;i--){
   		mn = min(mn,(dp[i]+abs(arr[i]-arr[start+1])));
    }
     return mn;
}
 
int main(){
	int n,k;
  	cin>>n>>k;
  	int arr[n];
  	for(int i=0;i<n;i++){
    	cin>>arr[i];
    }
  	int dp[n];
  	dp[0] = 0;
  	for(int i=1;i<n;i++){
      	dp[i] = calc(i-1,max(0,i-k),dp,arr);
    }
  	cout<<dp[n-1];
	return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        
        Scanner scan = new Scanner(System.in);
        int len = scan.nextInt();
        String s = scan.next();
        String t = scan.next();
        
        String[] newS = s.split("");
        String[] newT = t.split("");
        
        String text = "";
        for (int i=0; i<len; i++) {
            text += (newS[i] + newT[i]);
        }
        System.out.println(text);
    }
}


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




int main() {
    int n;
    cin >> n;
    ull ans=1;
//    int cnt=0;
    ull ref = pow(10,18);

    ull realans=10;
    rep(i,n){
        ull tmp;
        ull oldans = ans;
        cin>>tmp;
        ans *=tmp;
        if(ans>ref){
            realans = 2;
        }
        if(tmp==0){
            realans=0;
            break;
        }
        if (ans/tmp != oldans) {
            realans=2;
            //ここにbreakを入れてたのがミス！！！！！！！！！！！！
        }
    }

    switch(realans){
        case 2:
            cout<<-1<<endl;
            break;
        case 0:
            cout<<0<<endl;
            break;
        case 10:
            cout<<ans<<endl;
            break;

    }
    return 0;
}





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



int main() {
    ll a;
    double b;
    cin>>a>>b;
//    cout << b<<endl;
    ll a0 =  b;
    ll a1 =  b*10;
    ll a2 =  b*100;
//    cout<<a1<<endl;
//    cout<<a2<<endl;
    ll b0 = a0%10;
    ll b1 = a1%10;
    ll b2 = a2%10;
    ll c0 = a*b0;
    ll c1 = a*b1/10;
    ll c2 = a*b2/100;
    ll ans= c0+c1+c2;
//    cout<<b1<<endl;
//    cout<<b2<<endl;
//    cout<<c1<<endl;
//    cout<<c2<<endl;
    cout<<ans<<endl;





    return 0;
}
*/



Measured memory_bytes: 3632
#include <algorithm>
#include <cmath>
#include <iostream>
#include <vector>

int main() {
  uint32_t H = 0, W = 0, K = 0;
  std::cin >> H >> W >> K;
  std::vector<std::string> mat(H);
  for (size_t i = 0; i < H; i++) std::cin >> mat[i];
  
  uint32_t H_sub = (1 << H) - 1, W_sub = (1 << W) - 1;
  uint32_t result = 0;
  for (size_t i = 0; i < H_sub; i++)
  {
    for (size_t j = 0; j < W_sub; j++)
    {
      uint32_t count = 0;
      for (size_t h = 0; h < H; h++)
      {
        if(i & (1 << h)) continue;
        for (size_t w = 0; w < W; w++)
        {
          if(j & (1 << w)) continue;
          if(mat[h][w] == '#') count++;
        }
      }
      if(count == K) result++;
    }
  }

  std::cout << result << std::endl;

  return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
const int MOD=1e9+7;
inline int add(register int a,register int b) {return a+=b,a>=MOD?a-MOD:a;}
inline int del(register int a,register int b) {return a-=b,a<0?a+MOD:a;}
inline int mul(register int a,register int b) {return 1LL*a*b%MOD;}
inline int power(register int a,register int b) {register int i,s; for(i=a,s=1;b;b>>=1,i=mul(i,i)) if(b&1) s=mul(s,i); return s;}
const int MAXN=610;
vector<int> v;
int a[MAXN],b[MAXN],cnt,sum;
int dp[MAXN][MAXN][MAXN],n;
int main()
{
	ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
	cin>>n;
	for(register int i=1;i<=(n<<1);i++)
	{
		cin>>a[i];
		if(~a[i]) b[a[i]]=1;
	}
	for(register int i=1;i<=n;i++)
		if((!(~a[(i<<1)-1]))&&(!(~a[i<<1]))) cnt++,sum+=2;
		else if(!(~a[(i<<1)-1])) sum+=2,v.push_back(a[i<<1]);
		else if(!(~a[i<<1])) sum+=2,v.push_back(a[(i<<1)-1]);
	for(register int i=1;i<=(n<<1);i++)
		if(!b[i]) v.push_back(i);
	sort(v.begin(),v.end()),v.push_back(0),reverse(v.begin(),v.end());
	dp[0][0][0]=1;
	for(register int i=1;i<=sum;i++)
		for(register int j=0;j<=sum;j++)
			for(register int k=0;k<=sum;k++)
			{
				if(!dp[i-1][j][k]) continue;
				if(!b[v[i]])
				{
					dp[i][j+1][k]=add(dp[i][j+1][k],dp[i-1][j][k]);
					if(j>0) dp[i][j-1][k]=add(dp[i][j-1][k],dp[i-1][j][k]);
					if(k>0) dp[i][j][k-1]=add(dp[i][j][k-1],mul(dp[i-1][j][k],k));
				}
				else
				{
					dp[i][j][k+1]=add(dp[i][j][k+1],dp[i-1][j][k]);
					if(j>0) dp[i][j-1][k]=add(dp[i][j-1][k],dp[i-1][j][k]);
				}
			}
	for(register int i=1;i<=cnt;i++) dp[sum][0][0]=mul(dp[sum][0][0],i);
	cout<<dp[sum][0][0]<<endl;
	return 0;
}

Measured memory_bytes: 872704
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)
INF = float('inf')

N = int(input())

#nの約数を全て求める
def divisor(n): 
    i = 1
    table = []
    while i * i <= n:
        if n%i == 0:
            table.append(i)
            table.append(n//i)
        i += 1
    table = list(set(table))
    return table

# import numpy as np
# def make_prime(U):
#     """素数判定（エラトステネスの篩）"""
#     is_prime = np.zeros(U, np.bool)
#     is_prime[2] = 1
#     is_prime[3::2] = 1  # 3以上の奇数を一旦すべて素数としてマーク
#     M = int(U**.5) + 1
#     for p in range(3, M, 2):  # 倍数のふるい落とし
#         if is_prime[p]:
#             is_prime[p*p::p+p] = 0  # 奇数*奇数+奇数は偶数になり無駄なのでstepをp+pにして回避
#     return is_prime, is_prime.nonzero()[0]

from functools import lru_cache
#nの素数判定
@lru_cache(None)
def is_prime(n):
    if n == 1:
        return False
    for i in range(2,int(n**0.5)+1):
        if n % i == 0:
            return False
    return True

ans = 0
used = []
while True:
    # print("N: {}".format(N))
    yakusu_table = divisor(N)
    sosu = []
    for yakusu in yakusu_table:
        if is_prime(yakusu):
            sosu.append(yakusu)
    
    yakusu_table.sort()
    # print("yakusu_table: {}".format(yakusu_table))
    # print("sosu: {}".format(sosu))

    is_ok = False
    for n in yakusu_table:
        if n in used:
            continue
        # print("n: {}".format(n))
        for p in sosu:
            i = 1
            z = 0
            while z <= n:
                z = p ** i
                # print("z: {}".format(z))
                if z == n:
                    # print("z!!: {}".format(z))

                    is_ok = True
                    break
                i += 1
            if is_ok:
                break
        if is_ok:
            break
    if is_ok:
        # print("z: {}".format(z))
        N = N / z
        used.append(z)
        ans += 1
        continue

    break  # Nが見つからなければ終了

print(ans)

Measured memory_bytes: 10228
N,D = map(int,input().split())
X = list()
Y = list()
for i in range(N):
    x,y = map(int, input().split())
    X.append(x)
    Y.append(y)
cnt = 0
for i in range(N):
    if D**2 >= X[i]**2 + Y[i]**2:
        cnt += 1
print(cnt)


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

int main(){
    string s,t;
    cin >> s >> t;
    int state = 0;
    for(int i=0;i < s.size();i++){
        if(s.at(i) != t.at(i)){
            cout << "No" << endl;
            state = 1;
            break;
        }
    }
    if(state == 0){
        cout << "Yes" << endl;
    }
}

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

// region template
#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define trav(a, x) for (auto &a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;

ll gcd(ll a, ll b) { return __gcd(a, b); }

ll euclid(ll a, ll b, ll &x, ll &y) {
    if (b) { ll d = euclid(b, a % b, y, x);
        return y -= a/b * x, d; }
    return x = 1, y = 0, a;
}

typedef unsigned long long ull;
typedef long double ld;
ull mod_mul(ull a, ull b, ull M) {
    ll ret = a * b - M * ull(ld(a) * ld(b) / ld(M));
    return ret + M * (ret < 0) - M * (ret >= (ll)M);
}
ull mod_pow(ull b, ull e, ull mod) {
    ull ans = 1;
    for (; e; b = mod_mul(b, b, mod), e /= 2)
        if (e & 1) ans = mod_mul(ans, b, mod);
    return ans;
}

const ll mod = 1000000007;
struct Mod {
    ll x;
    Mod(ll xx) : x(xx) {}
    Mod operator+(Mod b) { return Mod((x + b.x) % mod); }
    Mod operator-(Mod b) { return Mod((x - b.x) % mod); }
    Mod operator*(Mod b) { return Mod((x * b.x) % mod); }
    Mod operator/(Mod b) { return *this * invert(b); }
    Mod invert(Mod a) {
        ll x, y, g = euclid(a.x, mod, x, y);
        assert(g == 1); return Mod((x + mod) % mod);
    }
    Mod operator^(ll e) {
        if (!e) return Mod(1);
        Mod r = *this ^ (e / 2); r = r * r;
        return e & 1 ? *this * r : r;
    }
};
// endregion

int main() {
    cin.sync_with_stdio(0); cin.tie(0); cin.exceptions(cin.failbit);

    int n, k; cin >> n >> k;
    if (k == 1) {
        cout << 0 << endl;
    } else {
        cout << n - k << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <numeric>
#include <cmath>
#include <bitset>

#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
using P = pair<ll, ll>;

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

const ll MOD = 1000000007;
const int INF = 1<<30;
//const ll INF = (ll)1e18 + 1;

int main(){
  string T; cin >> T;
  int N = T.length();
  ll ans = 0;
  rep(i, N) if (T[i] == '?') T[i] = 'D';
  cout << T << endl;
}


Measured memory_bytes: 3724
#include <bits/stdc++.h>
using namespace std;
#include "string"
#define endl '\n'
#define pi pair<char,int>
#define ff first
#define ss second
#define int long long 
#define boost ios_base::sync_with_stdio(false);cin.tie(nullptr)

int32_t main() { 
    boost;
 
	int n;
	cin>>n;
	int ans=0;
	for(int i=1;i<=n;i++){
		if(i%3==0 or i%5==0)
			continue;
		ans+=i;
	}   
	cout<<ans<<endl;
}

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

const int N = 205;

int n, k, s, dis[N][N];
char e[N][N];

bool check() {
    for (int u = 0; u < n; u++) {
        for (int v = 0; v < n; v++) {
            if (e[u][v] == '1' && std::abs(dis[s][u] - dis[s][v]) != 1) { return false; }
        }
    } return true;
}

int main() {
    scanf("%d", &n);
    for (int u = 0; u < n; u++) {
        for (int v = 0; v < n; v++) { dis[u][v] = u == v ? 0 : 1e9; }
    }
    for (int u = 0; u < n; u++) {
        scanf("%s", e[u]);
        for (int v = 0; v < n; v++) {
            if (e[u][v] == '1') { dis[u][v] = std::min(dis[u][v], 1); }
        }
    }
    for (int i = 0; i < n; i++) {
        for (int u = 0; u < n; u++) {
            for (int v = 0; v < n; v++) {
                dis[u][v] = std::min(dis[u][v], dis[u][i] + dis[i][v]); 
            }
        }
    }
    for (int u = 0; u < n; u++) {
        for (int v = 0; v < n; v++) {
            if (dis[u][v] <= 1e8) {
                k = std::max(k, dis[u][v] + 1); s = u;
            }
        }
    }
    printf("%d\n", check() ? k : -1);
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
#define coutd(n) cout << fixed << setprecision(n)
#define ll long long int
#define vl vector<ll>
#define vi vector<int>
const int INF = 2147483647;
const ll MOD = 1000000007;

using namespace std;

ll dp[2000][2000] = {};

int main() {
  int n;
  cin >> n;
  ll x;
  cin >> x;
  vl a(n);
  REP(i, n) { cin >> a[i]; }

  REP(i, n) { dp[0][i] = a[i]; }
  FOR(i, 1, n) {
    REP(j, n) {
      int idx = j - i >= 0 ? j - i : n + (j - i);
      dp[i][j] = min(a[idx], dp[i - 1][j]);
    }
  }

  ll ans = 1e18;
  REP(i, n) {
    ll tmp = 0;
    REP(j, n) { tmp += dp[i][j]; }
    ans = min(tmp + i * x, ans);
  }
  cout << ans << endl;
}


Measured memory_bytes: 31488
#include<stdio.h>
int main(){
  char s[1000];
  double S[1000]={0};
  int i,r,n,f;
  while(fgets(s,1000,stdin)){
    i=r=0;
    while(1){
      if(s[i]==0)break;
      if((s[i+1]==' '||s[i+1]=='\n')&&(s[i]<'0'||'9'<s[i])){
	if(s[i]=='+')S[r-2]+=S[r-1];
	if(s[i]=='-')S[r-2]-=S[r-1];
	if(s[i]=='*')S[r-2]*=S[r-1];
	if(s[i]=='/')S[r-2]/=S[r-1];
	r--;
	i++;
      }
      else{
	f=0;
	if(s[i]=='-'){
	  f=1;
	  i++;
	}
	n=0;
	while('0'<=s[i]&&s[i]<='9')n=n*10+s[i++]-'0';
	if(f)n*=-1;
	S[r++]=n;
      }	
      i++;
    }
    if(S[0]==0)S[0]=0;
    printf("%.10lf\n",S[0]);
  }
  return 0;
}
    

Measured memory_bytes: 576
#include <bits/stdc++.h>
using namespace std;
#define ll          long long int
#define ld          long double


void solve()  
{
	string s, t; cin>>s>>t;
	ll c=0;
	for(ll i=0; i<3; i++) c+=(s[i]==t[i]);
	cout<<c<<endl;
}
 
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);  
	ll T = 1;
	//cin>>T; 
	while(T--)
	    solve();
	return 0;
}


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

namespace ConsoleApp12
{
    class Program
    {
        static void Main(string[] args)
        {
            var values = Console.ReadLine().Split().Select(int.Parse).ToArray();

            int H = values[0];

            int A = values[1];

            Console.WriteLine(Math.Ceiling((double)H / A));
        }
    }
}


Measured memory_bytes: 13268
mod = 1000000007
n, m = map(int, input().split())
a = [int(input()) for _ in range(m)]
count = [0 for _ in range(n+1)]
count[1] = 1
count[0] = 1
for num in a:
  count[num] = -1

for i in range(1, n+1):
  if count[i] != -1:
    if i == 1:
      count[1] = 1
      continue
    count[i] = (count[i-1] + count[i-2])
    count[i] %= mod
  else:
    count[i] = 0
print(count[-1]%mod)

Measured memory_bytes: 7836
#復習用
N, A = map(int, input().split())
X = list(map(lambda x: int(x) - A, input().split()))
maxn = max(max(X), A)
 
dp = [[0 for _ in range(2 * N * maxn + 1)] for _ in range(N + 1)]
dp[0][N * maxn] = 1
for i in range(N):
    for k in range(2 * N * maxn + 1):
        dp[i + 1][k] = dp[i][k]
        if 0 <= k - X[i] < 2 * N * maxn:
            dp[i + 1][k] += dp[i][k - X[i]] 
print(dp[N][N * maxn] - 1)

Measured memory_bytes: 5232
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <algorithm>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1010101010;
constexpr lint LINF = 1LL << 60;

template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (const auto &e : vec) os << e << (&e == &vec.back() ? "\n" : " ");
	return os;
}

#ifdef _DEBUG
template <class T>
void dump(const char* str, T &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + (*(str + 1) == ' ' ? 2 : 1), t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	string s, t, u;
	int a, b;
	cin >> s >> t >> a >> b >> u;

	if (s == u) a--;
	else b--;

	cout << a << ' ' << b << "\n";

	return 0;
}

Measured memory_bytes: 256
num = input().split(" ")
#print(num)
#print(num[0],num[1])
cnt=0
for i in range(1,int(num[1])+1):
    for j in range(1,int(num[0])+1):
        if i<=9 or  i%10==1 or i//10==1:
          pass
        elif (i//10)*(i%10)==j:
            cnt = cnt+1
        else:
            pass
print(cnt)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define rrep(i, n) for (int (i) = 1; (i) <= (n); (i++))
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define yn {puts("Yes");}else {puts("No");}
#define printd(x) printf("%.12f\n", x);
template<class T> bool chmin(T& a, const T& b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> bool chmax(T& a, const T& b) {if (a < b) {a = b; return 1;} return 0;}
using namespace std;
using ll = long long;
using P = pair<int, int>;

bool dp[100005];

int main() {
	int n, k;
	cin >> n >> k;
	int a[n];
	rep (i, n) cin >> a[i];

	for (int i = 1; i <= k; i++) {
		bool ok = false;
		rep (j, n) {
			if (i - a[j] >= 0) if (!dp[i - a[j]]) ok = true;
		}
		dp[i] = ok;
	}
	
	cout << (dp[k] ? "First" : "Second") << endl;
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
struct ios_accelerate { ios_accelerate() { ios::sync_with_stdio(false); cin.tie(nullptr); } } CALL;

#define REP(i, n) for(auto (i) = (n)*0; (i) < (n); (i)++)
#define RNG(i, a, b) for(auto (i) = (a); (i) < (b); (i)++)
#define RBF(i, v) for(auto& (i) : (v))
#define ALL(x) (x).begin(), (x).end()

using LL = long long;
using UL = unsigned long;
using ULL = unsigned long long;
template<typename T> using V = vector<T>;
template<typename T> using VV = vector<vector<T>>;
template<typename T> using P = pair<T, T>;

const double PI = 3.141592653589793;
const int MOD = 1000000007;
const LL INF64 = static_cast<LL>(1e18) + 2;
const int INF = static_cast<int>(1e9) + 2;

template<typename T> inline void upsort(vector<T>& x) { sort(x.begin(), x.end()); }
template<typename T> inline void downsort(vector<T>& x) { sort(x.begin(), x.end(), greater<T>()); }
template<typename T> inline void col(T x) { cout << x << '\n'; }
template<> inline void col(double x) { cout << fixed << setprecision(12) << x << '\n'; }

signed main() {
	int r;
	cin >> r;

	col(r * r);
	return 0;
}

Measured memory_bytes: 3644
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn solve(a: u32, b: u32, h: u32) -> u32 {
    (a + b) * h / 2
}

fn main() {
    input! {a: u32, b: u32, h: u32};
    println!("{}", solve(a, b, h));

}


Measured memory_bytes: 4352
from math import gcd


def resolve():
    n = int(input())
    ans = 0
    for i in range(1, n + 1):
        for j in range(1, n + 1):
            a = gcd(i, j)
            for k in range(1, n + 1):
                ans += gcd(a, k)

    print(ans)


resolve()

Measured memory_bytes: 9188
while True:
    N,M = map(int,input().split())
    if N == 0: break
    src = []
    for i in range(N):
        d,p = map(int,input().split())
        src.append((p,d))
    money = M
    ans = 0
    for p,d in sorted(src,reverse=True):
        guard = min(d,money)
        money -= guard
        ans += (d - guard) * p
    print(ans)

Measured memory_bytes: 6712
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr=(input.trim()).split("\n").map(Number);
while(Arr.length!=0){
   var n=(Arr.shift())/4;
   if(n==0)break;
   var sum=0;
   while(n!=0){sum+=Arr.shift();n--}
   console.log(sum);
}

Measured memory_bytes: 7644
S = input()
T = input()
 
ls = len(S)
lt = len(T)
left = -1
 
for i in range(ls-lt+1):
    for j in range(lt):
        if S[i+j] != "?" and S[i+j] != T[j]:
            break
    else:
       left = i
if left == -1:
    ans = "UNRESTORABLE"
else:
    ans = S[:left]+T+S[left+lt:]
    ans = ans.replace("?", "a")
print(ans)

Measured memory_bytes: 9056
#include<bits/stdc++.h>
using ll  = long long;
#define int ll
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define erep(e,v) for(auto && e :v)
#define all(in) in.begin(), in.end()
#define MP make_pair
#define INF (sizeof(int) == 4 ? (int)1e9:(int)1e18)
#define EPS 0.0000000001
using namespace std;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
template<class T> void join(T &a){int t = 0;for(auto itr :a){if(t++)cout << " "; cout << itr;} cout <<endl; }
using ld  = long double;
using pii = pair<int,int>;
using piii = pair<int,pii>;
int W,H;
int dx[]={0,0,1,-1}, dy[]={1,-1,0,0};
bool valid(int x,int y){return (0<=x&&x<W)&&(0<=y&&y<H);}
signed main(){
    //    std::ios_base::sync_with_stdio(false);
    //    cin.tie(NULL);
    char t;  cin >> t;
    if(t ==  'A')cout << 'T';
    else if(t == 'T') cout << 'A';
    else if(t == 'G') cout << 'C';
    else cout << 'G';
        cout << endl;
    
}




Measured memory_bytes: 256
INF = 100
n = int(input())
a = list(map(int, input().split()))
sorted_a = sorted(a)
count = 0
p1 = INF
p2 = INF
for i in range(n):
    if a[i] != sorted_a[i]:count+=1
    if p2==INF and p1!=INF:p2=i
    elif p1==INF:p1=i
if count < 2:
    print("YES")
    exit()
elif count == 2:
    temp = a[p1]
    temp2 = a[p2]
    rea = a
    rea[p1] = temp2
    rea[p2] = temp
    if a == rea:print("YES")
    exit()
print('NO')

Measured memory_bytes: 38384
n,x = list(map(int,input().split()))
a = list(map(int,input().split()))
a.insert(0,0)
a.append(0)
ans = 0
for i in range(n+1):
    if a[i]+a[i+1]>x:
        ans += a[i]+a[i+1]-x
        a[i+1] -= a[i]+a[i+1]-x
print(ans)


Measured memory_bytes: 14592
dic = {"a":1,"b":2,"c":3,"d":4,"e":5,"f":6,"g":7,"h":8,"i":9,"j":10,"k":11,"l":12,"m":13,"n":14,"o":15,"p":16,"q":17,"r":18,"s":19,"t":20,"u":21,"v":22,"w":23,"x":24,"y":25,"z":26}
dicB = {1:"a",2:"b",3:"c",4:"d",5:"e",6:"f",7:"g",8:"h",9:"i",10:"j",11:"k",12:"l",13:"m",14:"n",15:"o",16:"p",17:"q",18:"r",19:"s",20:"t",21:"u",22:"v",23:"w",24:"x",25:"y",26:"z"}
A = input()
A = int(dic[A]) + 1
print(dicB[A])

Measured memory_bytes: 3064
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <utility>

using namespace std;
#define LL long long
#define pb push_back
#define mk make_pair
#define pill pair<LL, LL>
#define mst(a, b)	memset(a, b, sizeof a)
#define REP(i, x, n)	for(int i = x; i <= n; ++i)
const int MOD = 1e9 + 7;
const int qq = 2e5 + 10;
const int INF = 1e9 + 10;
map<int, int> mp;

int main(){
	int n;	scanf("%d", &n);
	for(int i = 0; i < n; ++i) {
		int x;	scanf("%d", &x);
		mp[x]++;
	}
	LL a, b;
	a = b = -1;
	LL maxn = 0;
	for(auto it = mp.rbegin(); it != mp.rend(); ++it) {
		if(it->second >= 4) {
			maxn = max(maxn, (LL)it->first * it->first);
		}
		if(it->second >= 2) {
			if(a == -1)	a = it->first;
			else if(b == -1)	b = it->first;
		}
	}
	if(a != -1 && b != -1) maxn = max(maxn, a * b);
	printf("%lld\n", maxn);
	return 0;
}

Measured memory_bytes: 4992
#include <stdio.h>
#include <stack>
using namespace std;

int main(){
    
    int input;
    stack<int> train;
    while (scanf("%d",&input)!=EOF) {
        if (input!=0)train.push(input);
        else {
            printf("%d\n",train.top());
            train.pop();
        }
    }
}

Measured memory_bytes: 1036
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define     mkp(a,b)    make_pair(a,b)
#define     PI          3.14159265359
#define     ll              long long
#define     ul              unsigned long long
#define     ld              long double
#define     mset(arr,val)   memset(arr,val,sizeof arr)
#define     MAXN            (long long)2e5+5
#define     eb              emplace_back
#define     mod             (long long)(1e9+7)
#define     FILE_READ       freopen("input.txt","r",stdin)
#define     FILE_WRITE      freopen("output.txt","w",stdout)
using namespace std;
using namespace __gnu_pbds;;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
//    FILE_READ;
//    FILE_WRITE;

    int a;
    string s;
    cin>>a>>s;
    if(a<3200) cout<<"red";
    else cout<<s;


    return 0;
}

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

using namespace std; 
int main(){
int n,cnt=0;
string s;
cin >>n >>s;
for(int i=0; i<n; i++){
    if((s[i]=='A') and (s[i+1]=='B') and (s[i+2]=='C'))cnt++;
}
cout <<cnt <<endl;
return 0;
}

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

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

int main(){
  	int a,b;
  	cin >> a >> b;
  	char ca = '0' + a, cb = '0' + b;
  	string sa, sb;
  	for (int i = 0; i < b; i++) sa += ca;
  	for (int i = 0; i < a; i++) sb += cb;
  	cout << (sa < sb ? sa : sb) << endl;
  	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
constexpr int di[] = { 0, 1, 0, -1 }, dj[] = { 1, 0, -1, 0 };
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define SORTR(v) sort((v).rbegin(), (v).rend())
#define all(v) (v).begin(), (v).end()
#define MAX 100000
#define vmax 10000
#define sentinel 2000000000
#define INF (1<<30)
constexpr long long int inf = 100000000000000000;
constexpr long long int rinf = -(INT64_MAX);
static const int NIL=-1;

//cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);

class edge{
public:
    int t,w;
    edge(){}
    edge(int t,int w): t(t), w(w) {}
};

vector<edge> g[MAX];
int n,d[MAX];

bool visited[MAX];
int cnt;                //確認用

void bfs(int s){
    rep(i,n) d[i]=INF;
    queue<int> q;
    q.push(s);
    d[s]=0;
    while(!q.empty()){
        int u=q.front();q.pop();
        for(auto e:g[u]){
            if(d[e.t]==INF){
                d[e.t]=d[u]+e.w;
                q.push(e.t);
            }
        }
    }
}

void solve(){
    //適当な視点sから最も遠い節点tgtを求める
    bfs(0);
    int maxv=0;
    int tgt=0;
    rep(i,n){
        if(d[i]==INF) continue;
        if(d[i]>maxv){
            maxv=d[i];
            tgt=i;
        }
    }

    //tgtから最も遠い節点の距離maxvを求める
    bfs(tgt);
    maxv=0;
    rep(i,n){
        if(d[i]==INF) continue;
        maxv=max(maxv,d[i]);
    }

    cout<<maxv<<endl;

}

int main(){
    int s,t,w;
    cin>>n;

    for(int i=0;i<n-1;i++){
        cin>>s>>t>>w;
        g[s].push_back(edge(t,w));
        g[t].push_back(edge(s,w));
    }

    solve();

    return 0;
}






Measured memory_bytes: 9792
def main():
    n, d = map(int, input().split())
    x = [list(map(int, input().split())) for i in range(n)]
    res = 0
    cnt = 0
    for i in range(n):
        for j in range(n):
            if i < j:
                for k in range(d):
                    res += abs(x[i][k] - x[j][k])**2
                ans = res ** (1/2)
                if ans.is_integer():
                    cnt += 1
                res = 0
    print(cnt)
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 3188
#include <stdio.h>

int main(void){
	int H, W;
	int m, n;

	do{
	scanf("%d%d", &H, &W);
	if(H == 0 && W == 0) break;
	for(m = 0; m < H; m++){
		if(m == 0 || m + 1 == H){
		for(n = 0; n < W; n++){
			printf("#");
		}
		} else{
		printf("#");
		for(n = 1; n < W - 1; n++){
			printf(".");
		}
		printf("#");
		}

		printf("\n");
	}
	printf("\n");
	} while (H != 0 || W != 0);

	return 0;
}

Measured memory_bytes: 1812
#include<bits/stdc++.h>
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define range(i,l,h) for(int i=l;i<h;i++)
#define endl '\n'
#define I INT_MAX
#define pb push_back
#define all(c) (c).begin(), (c).end()
#define ll long long
#define ull unsigned long long
#define ff first
#define ss second
#define vt vector
using namespace std;
using std::ios;
constexpr int MOD=1e9+7;
constexpr int mod=998244353;
template<typename T> T power(T a,T b){T r=1;while(b){if(b&1)r*=a;b/=2;a*=a;}return r;}

int main()
{
  fastio;
 
  
  int n;
  cin>>n;
  cout<<(!n);

}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define node first
#define weight second
#define MOD 1000000007
typedef pair <int, int> ii;

int32_t main()
{

	ios::sync_with_stdio(false);
	cin.tie(NULL);
	#ifdef LOCAL_PROJECT
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif
	int n, w;
	cin >> n >> w;
	int a[100005]={0}, b[100005]={0};
	int *cur = a, *prev = b;
	for(int i = 0; i < n; i++)
	{
		int wi, vi;
		cin >> wi >> vi;
		swap(cur, prev);
		for(int i = 0; i <= 100000; i++)
		{
			if(vi > i)
				cur[i] = prev[i];
			else
			{
				if(prev[i] != 0 && (prev[i-vi] != 0 || (i-vi) == 0))
					cur[i] = min(prev[i], prev[i-vi] + wi);
				else if(prev[i] != 0)
					cur[i] = prev[i];
				else if(prev[i-vi] != 0 || (i-vi) == 0)
					cur[i] = prev[i-vi] + wi;
				else
					cur[i] = 0;
			}
		}
	}
	for(int i = 100000; i >= 0; i--)
		if(cur[i] <= w && cur[i] != 0)
		{
			cout << i;
			break;
		}
}

Measured memory_bytes: 1792
n = int(input())
l = list(map(int,input().split()))

j = 0
new = []
while True:
    for m,i in enumerate(l):
        if i % 2 == 0:
            l[m] = i/2
            
            if m+1 == n:
                j +=1
        else:
            print(j)
            break
    else:
        continue
    break   
        


Measured memory_bytes: 3060
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <iterator>
#include <cmath>
#include <set>
#include <deque> 
#include <string>


using namespace std;

char s[200010];
char t[200010];
int n;

int main()
{
	scanf("%s\n", s);
	scanf("%s\n", t);
	
	n = strlen(s);
	int count = 0;
	for (int i = 0 ; i < n ; i++) {
		if (s[i] != t[i])
			count++;
	}
	
	printf("%d\n", count);
		
	return 0;
}


Measured memory_bytes: 2116
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		sc.close();

		//double check =  Math.pow(Math.E, Math.log(N)/2);
		double check = Math.sqrt(N);
		double num = Math.floor(check);
		double ans = Math.pow(num, 2);
		int answer = (int) ans;
		System.out.println(answer);
	}

}


Measured memory_bytes: 22740