akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<cmath>
#include<cstring>
#include <map>   

using namespace std;

int main() {
	int n;
	vector<string> s;
	vector<int> p;
	cin >> n;
	char temp[11];
	int temp1;
	for (int i = 0; i < n; i++) {
		cin >> temp >> temp1;
		s.push_back(temp);
		p.push_back(temp1);
	}
	
	string st_temp;
	int int_temp;
	int ans_num;
	for (int k = 0; k < n; k++) {
		for (int i = 0; i < n; i++) {
			if (i == 0) {
				st_temp = s[0];
				int_temp = p[0];
				ans_num = 1;
			}
			else
			{
				if (st_temp > s[i]) {
					st_temp = s[i];
					int_temp = p[i];
					ans_num = i + 1;
				}
				else if (st_temp == s[i]) {
					if (int_temp < p[i]) {
						st_temp = s[i];
						int_temp = p[i];
						ans_num = i + 1;
					}
				}
			}
			if (i == n - 1) {
				cout << ans_num << endl;
				s.erase(s.begin() + ans_num - 1);
				if (ans_num == n) {
					s.push_back("zzzzzzzzzz");
				}
				else s.insert(s.begin() + ans_num - 1, "zzzzzzzzzz");
			}
		}
	}
	
	

	return 0;
}

Measured memory_bytes: 384
package main

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

func main() {
  a := nextLine()
  fmt.Println(a[0:3])
}
/*----------標準入力用の関数----------*/
var reader = bufio.NewReaderSize(os.Stdin, 1000000)

func nextLine() string {
	buffer := make([]byte, 0)
	for true {
		line, isPrefix, _ := reader.ReadLine()
		buffer = append(buffer, line...)
		if !isPrefix {
			break
		}
	}
	return string(buffer)
}

Measured memory_bytes: 1792
#include<iostream>
using namespace std;
int main() {
	long long int i, N, A,j,k,ans,B;
	cin >> N >> A >> B;
	k = 0;
	k=N/(A+B);
    j=N%(A+B);
	i=k*(A+B);
    if(N-i>A){
        ans=k*A+A;
    }
    else{
        ans=k*A+j;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<cstdlib>
#include<cstdio>
using namespace std;
const int maxn=500010,inf=1e9;
int n;
int pos[maxn][26],f[maxn];
char s[maxn];
void read(int &k)
{
	int f=1;k=0;char c=getchar();
	while(c<'0'||c>'9')c=='-'&&(f=-1),c=getchar();
	while(c<='9'&&c>='0')k=k*10+c-'0',c=getchar();
	k*=f;
}
int main()
{
	scanf("%s",s+1);n=strlen(s+1);
	memset(f,32,(n+1)<<2);f[n+1]=1;f[n+2]=0;
	for(int i=0;i<26;i++)pos[n+1][i]=n+1;
	for(int i=n;i;i--)
	{
		for(int j=0;j<26;j++)
		pos[i][j]=pos[i+1][j];
		pos[i][s[i]-'a']=i;
	}
	for(int i=n;i;i--)
	for(int j=0;j<26;j++)
	f[i]=min(f[i],f[pos[i][j]+1]+1);
	int now=1;
	for(int j=f[1];j;j--)
	for(int i=0;i<26;i++)
	if(f[now]==f[pos[now][i]+1]+1)
	{
		putchar(i+'a');
		now=pos[now][i]+1;
		break;
	}
}

Measured memory_bytes: 23808
@1=map$-=$_-2,@0=1..<>+2;--$0[-1];map$\+=$'*($$_[$$_[$P=${1-$_}[$`]]=$N=$$_[$`]]-$N)*($`-$P),/	/,0for`tr ' ' '
'|nl|sort -nk2`;print

Measured memory_bytes: 42236
#include<stdio.h>
int gcd(long int m,long int n);
int main(void){
long int m,n;
int anc;
scanf("%ld %ld",&m,&n);
anc=gcd(m,n);
printf("%d\n",anc);
return 0;
}
int gcd(long int m,long int n){
int anc,i;
while(m%n!=0){
i=m%n;
m=n;
n=i;
}
anc=n;
return anc;
}

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

int n,s;

//  dp[#number of items in the set][# sum of the set] => number of ways to do it

int arr[55];
ll dp[55][2555];

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
  cin>>n>>s;
  for(int i=1; i<=n; ++i){
    cin>>arr[i];
  }
  dp[0][0] = 1;
  for(int i=1; i<=n; ++i){
    // Choosing i'th element update all the previous ones
    for(int j=i-1; j>=0; --j){
      for(int k=0; k<2555-arr[i]; ++k){
        dp[j+1][k+arr[i]] += dp[j][k];
      }
    }
  }
  ll ans = 0;
  for(int i=1; i<=n; ++i){
    ans += dp[i][i*s];
  }
  cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 1280
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector< vector<int> > VVI;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()

int main(){
  string S;
  cin>>S;
  int Q;
  cin>>Q;
  int N=1;
  string B,D;
  rep(i,Q){
    int T;
    cin>>T;
    if(T==1){
      N=(N+1)%2;
    }else{
      int F;
      cin>>F;
      string C;
      cin>>C;
      if((N&&F==1)||(N==0&&F==2)) D+=C;
      if((N&&F==2)||(N==0&&F==1)) B+=C;
    }
  }
  if(N==1){
    reverse(all(D));
    cout<<D<<S<<B<<endl;
  }else{
    reverse(all(S));
    reverse(all(B));
    cout<<B<<S<<D<<endl;
  }
}



Measured memory_bytes: 1088
N = int(input())
A = []
for i in range(N):
    A.append(int(input()))
num = A[0] // 2
for i in range(1, N):
    if A[i] >= 1:
        A[i] += A[i - 1] % 2
    num += A[i] // 2

print(num)

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

using namespace std;

int main() {
    int n, runner, out, score;
    string s;

    cin >> n;

    for (int i=0; i<n; i++) {
        runner = 0;
        out = 0;
        score = 0;

        while (out < 3) {
            cin >> s;

            if(s == "HIT") {
                runner++;
                if(runner > 3) {
                    score++;
                    runner = 3;
                }
            } else if(s == "HOMERUN") {
                score += runner+1;
                runner = 0;
            } else {
                out++;
            }
        }
        cout << score << endl;
    }

    return 0;
}

Measured memory_bytes: 3112
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <string>
#define REP(i, START, n, STEP) for(int i = START; i < (n); i += (STEP))
#define rep(i, n) REP(i, 0, n, 1)
using namespace std;

typedef long long int ll;

vector<int> nodes[200004];
int val[200004];

void set_counter(int num, int start)
{
	for (auto& node : nodes[num])
	{
		if (node != start)
		{
			val[node] += val[num];
			set_counter(node, num);
		}
	}
}

int main()
{
	int n, q;
	cin >> n >> q;
	int a, b;
	rep(i, n - 1)
	{
		cin >> a >> b;
		a--; b--;
		nodes[a].push_back(b);
		nodes[b].push_back(a);
	}
	int p, x;
	rep(i, q)
	{
		cin >> p >> x;
		val[p - 1] += x;
	}
	set_counter(0, -1);
	rep(i, n)
	{
		cout << val[i] << " ";
	}
	return 0;
}

Measured memory_bytes: 23424
#include<iostream>
#include<vector>
#include<functional>
#include<utility>
#include<string>
#include<array>
using u32 = unsigned int;
using u64 = unsigned long long;

int main() {
	::std::string s, ans;
	::std::cin >> s;
	u32 k;
	::std::cin >> k;
	::std::array<u32, 26> cnt = {}, it = {};
	::std::array<::std::vector<u32>, 26> cs = {};
	for (const auto c : s) {
		++cnt[c - 'a'];
		u32 cur = 0;
		for (u32 i = static_cast<u32>(c - 'a') + 1;i < 26;++i)
			cur += cnt[i];
		cs[c - 'a'].emplace_back(cur);
	}
	for (auto &e : cnt)
		e = 0;

	for (u32 i = 0;i < s.size();++i) {
		for (u32 j = 0;j < 26;++j) {
			if (it[j] == cs[j].size())
				continue;
			if (k >= cs[j][it[j]] - cnt[j]) {
				ans.push_back('a' + j);
				k -= cs[j][it[j]] - cnt[j];
				++it[j];
				for (u32 l = 0;l < j;++l)
					++cnt[l];
				break;
			}
		}
	}
	::std::cout << ans << ::std::endl;
	return 0;
}




Measured memory_bytes: 4392
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
int main() {
  uint64_t a, b, k;
  cin >> a >> b >> k;

  if (a <= k) {
    k -= a;
    a = 0;
  } else {
    a -= k;
    k = 0;
  }

  if (b <= k) {
    k -= b;
    b = 0;
  } else {
    b -= k;
    k = 0;
  }

  cout << a << " " << b << endl;
  return 0;
}


Measured memory_bytes: 256
# coding: utf-8
# Your code here!

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

A=list(map(int,input().split()))

cand=[2**i for i in range(40)][::-1]
bit=[0]*40

for a in A:
    for i in range(40):
        if a>=cand[i]:
            a-=cand[i]
            bit[i]+=1

digits=1
while K>=2**(digits):
    digits+=1
#print(digits)
ans=0

if K==0:
    for i in range(40):
        ans+=cand[i]*bit[i]
    print(ans)
    exit()

for i in range(40-digits):
    ans+=cand[i]*bit[i]
#print(ans)


dp=[[[0 for k in range(2)] for j in range(digits)] for i in range(2)]
cand=cand[40-digits:40]
bit=bit[40-digits:40]
dp[0][0][0]=bit[0]*cand[0]
dp[1][0][1]=(N-bit[0])*cand[0]
K-=cand[0]

for i in range(digits-1):
    cor=bit[i+1]*cand[i+1]
    rev=(N-bit[i+1])*cand[i+1]
    if K>=cand[i+1]:
        K-=cand[i+1]
        dp[0][i+1][0]=max(dp[0][i][0],dp[0][i][1],dp[1][i][1],dp[1][i][0])+cor
        dp[0][i+1][1]=max(dp[0][i][0],dp[0][i][1])+rev
        dp[1][i+1][1]=max(dp[1][i][1],dp[1][i][0])+rev
        
    else:#Kに余裕がなくて足せない
        dp[0][i+1][0]=max(dp[0][i][0],dp[0][i][1])+cor
        dp[0][i+1][1]=max(dp[0][i][0],dp[0][i][1])+rev
        dp[1][i+1][0]=max(dp[1][i][0],dp[1][i][1])+cor

#print(dp)

temp=max(max(dp[0][-1]),max(dp[1][-1]))
print(ans+temp)




Measured memory_bytes: 14660
#include <bits/stdc++.h>
#define ll long long
#define M 1000000007 
#define MM 998244353
#define PI 3.14159265 
using namespace std;
 
int main()
{
	int sum = 0;
	string s;
	cin >> s;

	for (int i = 0; i < 3; i++)
	{	
		int j = i;
		while (s[j] == 'R')
		{
			sum++;
			j++;
		}
		if (sum != 0)
		{
			break;
		}
	}

	cout << sum;

  	return 0;
}

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

int main() {
  int x1, y1, x2, y2;
  cin >> x1 >> y1 >> x2 >> y2;
  int x3, y3, x4, y4;

  x3 = x2 - (y2 - y1);
  y3 = y2 + (x2 - x1);
  x4 = x1 - (y2 - y1);
  y4 = y1 + (x2 - x1);
  cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;
}

Measured memory_bytes: 380
import java.util.*;
import java.io.*;

public class Main {


    public static void main(String[] args) throws IOException {
        Scanner sc = new Scanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);
        char[]s = sc.next().toCharArray();
        int mx=0;
        int cur=0;
        for (int i =0;i<s.length;i++){
            if (s[i]=='S'){
                mx=Math.max(mx,cur);
                cur=0;
            }else cur++;
        }
        mx=Math.max(mx,cur);
        pw.println(mx);
        pw.close();

    }



    static class Scanner {
        BufferedReader br;
        StringTokenizer st;

        public Scanner(InputStream s) {
            br = new BufferedReader(new InputStreamReader(s));
        }

        public String next() throws IOException {
            while (st == null || !st.hasMoreTokens())
                st = new StringTokenizer(br.readLine());
            return st.nextToken();
        }

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

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

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

        public int[] nextIntArr(int n) throws IOException {
            int[] arr = new int[n];
            for (int i = 0; i < n; i++) {
                arr[i] = Integer.parseInt(next());
            }
            return arr;
        }

    }

}

Measured memory_bytes: 32740
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
struct unionfind{
    vector<int> par, sz;
    unionfind() {}
    unionfind(int n):par(n), sz(n, 1){
        for(int i=0; i<n; i++) par[i]=i;
    }
    int find(int x){
        if(par[x]==x) return x;
        return par[x]=find(par[x]);
    }
    void unite(int x, int y){
        x=find(x); y=find(y);
        if(x==y) return;
        if(sz[x]>sz[y]) swap(x, y);
        par[x]=y;
        sz[y]+=sz[x];
    }
    bool same(int x, int y){
        return find(x)==find(y);
    }
    int size(int x){
        return sz[find(x)];
    }
};
int n;
vector<int> g[200020];
int c[200020];
int d[200020];
vector<int> vq[200020];
int par[200020];
void dfs(int x, int p, int mx){
    par[x]=p;
    for(auto y:g[x]){
        if(y==p) continue;
        if(x==0) d[y]=1;
        else if(max({mx, x, y})==x){
            if(y<mx) vq[x].push_back(2*y), vq[mx].push_back(2*y+1);
            else vq[x].push_back(2*y);
        }else if(max({mx, x, y})==y){
            vq[max(x, mx)].push_back(2*y);
        }
        dfs(y, x, max(mx, x));
    }
}
void dfs2(int x, int p){
    for(auto y:g[x]){
        if(y==p) continue;
        c[y]=c[x]+d[y];
        dfs2(y, x);
    }
}
int main()
{
    cin>>n;
    for(int i=0; i<n-1; i++){
        int a, b; cin>>a>>b; a--; b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    dfs(0, -1, -1);
    unionfind uf(n);
    for(int i=0; i<n; i++){
        for(auto j:vq[i]){
            int y=j/2;
            int cnt=1;
            if(y<i){
                cnt=uf.size(y);
            }else{
                for(auto z:g[y]){
                    if(z==par[y]) continue;
                    if(z<i) cnt+=uf.size(z);
                }
            }
            if(j&1) d[y]-=cnt;
            else d[y]+=cnt;
        }
        for(auto y:g[i]){
            if(y<i) uf.unite(i, y);
        }
    }
    dfs2(0, -1);
    for(int i=1; i<n; i++) cout<<c[i]<<" ";
    cout<<endl;
	return 0;
}


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

namespace ABC146a
{
    class Program
    {
        static void Main(string[] args)
        {
            string a;
            int n;
            a = Console.ReadLine();
            n = 0;
            if (a == "SUN")
                n = 7;
            if (a == "MON")
                n = 6;
            if (a == "TUE")
                n = 5;
            if (a == "WED")
                n = 4;
            if (a == "THU")
                n = 3;
            if (a == "FRI")
                n = 2;
            if (a == "SAT")
                n = 1;

            Console.WriteLine(n);

        }
    }
}

Measured memory_bytes: 11092
#include<bits/stdc++.h>
#define forn(i,n) for(int i = 0; i < n; i++)
#define forr(i,a,n) for(int i = a; i<= n; i++)
#define __ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define fi first
#define se second
#define pb push_back
#define all(u) u.begin(),u.end()
#define lli long long int
#define ld long double

using namespace std;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<vi> vvi;
const int maxn = 5e5 + 100;
int rep[maxn], num[maxn], cont = 0, n, m, bit[maxn], lstvst[maxn];
struct Query{
	int l, r, indx;
	bool operator<(Query q) const{
		return r < q.r;
	}
}Q[maxn];
void update(int p, int v){
	for(; p <= maxn; p+= (p&-p))
		bit[p]+=v;
}
int query(int p){
	if(p < 0) return 0;
	int ans = 0;
	for(; p;p-=(p&-p))
		ans += bit[p];
	return ans;
}
vi go(){
	vi answer(m);
	sort(Q, Q+m);
	memset(lstvst, -1, sizeof(lstvst));
	int qrAct = 0;
	forn(i,n){
		if(lstvst[num[i]] != -1)
			update(lstvst[num[i]] + 1, -1);
		lstvst[num[i]] = i;
		update(lstvst[num[i]] + 1, 1);
		while(qrAct < m && Q[qrAct].r == i){
			answer[Q[qrAct].indx] = query(Q[qrAct].r+1) - query(Q[qrAct].l);
			qrAct++;
		}
	}
	return answer;
}
int main(){__
	cin >> n >> m;
	forn(i,n) cin >> num[i];
	forn(i,m){
		cin >> Q[i].l  >> Q[i].r;
		Q[i].l--; Q[i].r--;
		Q[i].indx = i;
	}
	auto ans = go();
	for(int x : ans) cout << x << '\n';
	return 0;
}



Measured memory_bytes: 17452
#include<bits/stdc++.h>
using namespace std;
typedef  long long ll;
using vll=vector<ll>;
using vi=vector<int>;

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}

//pow(llpow,modpow)
template<class T> ll llpow(T x,T n){ll ans=1;if(x==0)ans=0;while(n){if(n&1)ans*=x;x*=x;n>>=1;}return ans;}
long long modpow(long long a, long long n, long long mod) {long long res = 1;while (n > 0) {if (n & 1) res = res * a % mod;a = a * a % mod;n >>= 1;}return res;}
//最大公約数
template<class T> inline T gcd(T x,T y){if(y==0)return x; else {return gcd(y,x%y);}}
//最小公倍数
template<class T> inline T lcm(T x,T y){return x/gcd(x,y)*y;}
//逆元
long long modinv(long long a, long long m) {long long b = m, u = 1, v = 0;while (b) {long long t = a / b;a -= t * b; swap(a, b);u -= t * v; swap(u, v);}u %= m;if (u < 0) u += m;return u;}

#define rep(i,n) for(ll i=0;i<(ll)n;i++)
#define rep2(i, begin_i, end_i) for (ll i = (ll)begin_i; i < (ll)end_i; i++)

long long INF = 1LL<<60;
int main( ){
    int n;
    cin>>n;
    vi a(n);
    rep(i,n)cin>>a[i];
    ll res=0;
    rep(i,n){
        res+=a[i]-1;
    }
    cout<<res<<endl;
    return 0;
}




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

using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;
#define DEBUG freopen("in.txt", "r", stdin);

struct fastio {
    fastio() {
        ios::sync_with_stdio(false);
        cout << setprecision(10) << fixed;
        cin.tie(0);
    }
};

fastio _fast_io;

const int N = 2e5 + 5;
int a[N], b[N];
int n;
int ans;
int T[31][N];
int CNT[31];

int main() {
    cin >> n;
    for (int i = 0; i < n; ++i)
        cin >> a[i];
    for (int i = 0; i < n; ++i)
        cin >> b[i];
    int base = 2; // 2T
    for (int k = 0; k <= 28; ++k) {
        for (int i = 0; i < n; ++i) {
            T[k][i] = a[i] % base;
        }
        sort(T[k], T[k] + n);
        base <<= 1;
    }
    base = 2;
    for (int k = 0; k <= 28; ++k) {
        for (int i = 0; i < n; ++i) {
            int B = b[i] % base;
            int t1 = base / 2;
            int t2 = t1 * 2;
            int t3 = t1 * 3;
            int t4 = t2 * 2;
            CNT[k] += lower_bound(T[k], T[k] + n, t2 - B) -
                      lower_bound(T[k], T[k] + n, t1 - B);
            CNT[k] += lower_bound(T[k], T[k] + n, t4 - B) -
                      lower_bound(T[k], T[k] + n, t3 - B);
        }
        base <<= 1;
    }
    for (int i = 0; i <= 30; ++i) {
        if (CNT[i] & 1)
            ans |= (1 << i);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 27788
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Convert;
using static System.Console;
using static System.Math;

namespace AtCorder
{
    class Program
    {
        static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }


        public void Solve(ConsoleInput cin)
        {
            var S = cin.Read;
            var ans = S.Count(v => v == '1');
            WriteLine(ans);
        }


        public class ConsoleInput
        {
            private readonly System.IO.TextReader _stream;
            private char _separator = ' ';
            private Queue<string> inputStream;
            public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
            {
                this._separator = separator;
                this._stream = stream;
                inputStream = new Queue<string>();
            }
            public string Read
            {
                get
                {
                    if (inputStream.Count != 0) return inputStream.Dequeue();
                    string[] tmp = _stream.ReadLine().Split(_separator);
                    for (int i = 0; i < tmp.Length; ++i)
                        inputStream.Enqueue(tmp[i]);
                    return inputStream.Dequeue();
                }
            }
            public string ReadLine { get { return _stream.ReadLine(); } }
            public int ReadInt { get { return int.Parse(Read); } }
            public long ReadLong { get { return long.Parse(Read); } }
            public double ReadDouble { get { return double.Parse(Read); } }
            public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
            public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
            public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
        }
    }
}


Measured memory_bytes: 11348
package main

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

func main() {
	W, H, N := ReadInt(), ReadInt(), ReadInt()

	sx, sy := 0, 0
	tx, ty := W, H

	for i := 0; i < N; i++ {
		x, y, a := ReadInt(), ReadInt(), ReadInt()
		switch a {
		case 1:
			sx = Max(sx, x)
		case 2:
			tx = Min(tx, x)
		case 3:
			sy = Max(sy, y)
		case 4:
			ty = Min(ty, y)
		}

		if tx <= sx || ty <= sy {
			fmt.Println(0)
			return
		}
	}
	fmt.Println((tx - sx) * (ty - sy))
}

func Min(xs ...int) int {
	min := xs[0]
	for _, x := range xs[1:] {
		if min > x {
			min = x
		}
	}
	return min
}
func Max(xs ...int) int {
	max := xs[0]
	for _, x := range xs[1:] {
		if max < x {
			max = x
		}
	}
	return max
}

var sc = bufio.NewScanner(os.Stdin)

func init()        { sc.Buffer(make([]byte, 256), 1e9); sc.Split(bufio.ScanWords) }
func Read() string { sc.Scan(); return sc.Text() }

func ReadInt() int {
	v, e := strconv.Atoi(Read())
	if e != nil {
		panic(e.Error())
	}
	return v
}


Measured memory_bytes: 1772
#include<bits/stdc++.h>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;
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; }

using namespace std;

void yesno(bool b) {
    if (b) {
        cout << "Yes" << endl;
    }     else {
        cout << "No" << endl;
    }

}

int main(){
    ll X, Y, A, B, C;
    cin >> X >> Y >> A >> B >> C;
    ll p[A], q[B], r[C];
    pair<ll, ll> z[A+B+C];
    rep(i, A) {
        cin >> p[i];
        z[i] = make_pair(p[i], 0);
    }
    rep(i, B) {
        cin >> q[i];
        z[A+i] = make_pair(q[i], 1);
    }
    rep(i, C) {
        cin >> r[i];
        z[A+B+i] = make_pair(r[i], 2);
    }

    int count[3];
    rep(i, 3) {
        count[i] = 0;
    }
    sort(z, z+A+B+C);
    reverse(z, z+A+B+C);

    ll ans = 0;
    rep(i, A+B+C) {
        pair<ll, ll> now = z[i];
        if (X - count[0] + Y - count[1] <= count[2]) {
            break;
        }
//        cout << count[0] << " " << count[1] << " " << count[2] << endl;
        if (now.second == 0) {
            if (count[0] < X) {
                count[0]++;
                ans += now.first;
            }
        } else if (now.second == 1) {
            if (count[1] < Y) {
                count[1]++;
                ans += now.first;
            }
        } else {
            count[2]++;
            ans += now.first;
        }
    }
    cout << ans << endl;
}



Measured memory_bytes: 7296
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep1(i,n) for(int i=1; i<=(n); ++i)
#define repi(i,a,b) for(int i=a; i<=(b); ++i)
#define rrep(i,n) for(int i=(n-1); i>=0; --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define pb push_back
#define mp make_pair
#define to_s to_string
#define sz(v) (int)v.size()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define pr(x) cout<<(x)<<'\n'
#define debug(x) cout << #x << ": " << (x) << '\n'
#define yes "Yes"
#define no "No"
using ll = long long;
using namespace std;
typedef pair<int,int> P;
struct aaa{aaa(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);};}aaaaaaa;
int MOD = 1e9 + 7;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return (a*b)/gcd(a,b);}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int A,B,C,D;
int main(){
    cin>>A>>B>>C>>D;
    if(A+B==C+D) pr("Balanced");
    else if(A+B > C+D) pr("Left");
    else pr("Right");
}

Measured memory_bytes: 256
from collections import deque

N, M, X = map(int, input().split())
A = list(map(int, input().split()))

Q = deque([(X, 1, 0), (X, -1, 0)])
R = []
while Q:
    P = Q.popleft()
    N1 = P[0] + P[1]
    if N1 == 0 or N1 == N:
        R.append(P[2])
        continue
    C = P[2] + (1 if N1 in A else 0)
    Q.append((N1, P[1], C))

print(min(R))

Measured memory_bytes: 3316
#include "bits/stdc++.h"
using namespace std;
#define rep(i,a,n) for(ll i=a;i<n;i++)
#define ALL(s) s.begin(),s.end()
const int M=100010;
const int MOD=1000000007;
const int INF=1000000007;
using ll=long long;

int main() {	
	bool f[100001]={};
	int c[100002]={};
	int N,L,R;
	rep(i,2,100001)if(!f[i])for(int j=i+i;j<=100000;j+=i)
		f[j]=true;
	for(int i=3;i<=100000;i+=2)if(!f[i]&&!f[(i+1)/2])c[i]++;
	rep(i,3,100001)c[i]+=c[i-1];
	cin>>N;
	while(N--){
		cin>>L>>R;
		cout<<c[R]-c[L-1]<<endl;
	}
}


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

int main(){
    ll n, a, b; cin >> n >> a >> b;
    ll k = a + b;
    ll c = n / k;
    n = n - c * k;
    if(n >= a){
        cout << c * a + a << endl;
    }else{
        cout << c * a + n << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
const double PI=acos(-1);

template<typename T>
istream& operator>> (istream& is, vector<T> &vec){
    for(T& x: vec) is >> x;
    return is;
}

int main(){
    ll n; cin >> n;
    vector<ll> a(n);
    rep(i, n){
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    ll cnt = 0, m = a[a.size()-1];
    vector<ll> aaa(m+1, 0);
    for(ll i = 0; i < a.size(); ++i){
        aaa[a[i]]++;
        if(aaa[a[i]] == 1){
            for(ll j = 2; j*a[i] <= m; j++){
                aaa[j*a[i]]++;
            }
        }
    }
    //for(auto i : a) printf("%lld ", i); cout << "\n";
    //for(auto i : a) printf("%s ", aaa[i] ? "TRUE" : "FALSE"); cout << "\n";
    rep(i, a.size()){
        if(aaa[a[i]] == 1) cnt++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 12760
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>

using namespace std;


int main()
{
	for (int i = 1; i <= 9; i++) {
		for (int j = 1; j <= 9; j++) {
			cout << i << "x" << j << "=" << i*j << endl;
		}
}

	return (0);
}

Measured memory_bytes: 3080
#include<stdio.h>
#include<algorithm>
using namespace std;
int table[97];
int main(){
	for(int i=0;i<96;i++){
		table[i+1]=(i+1)*(i+2)*(i+3)/6;
	}
	int a;
	while(scanf("%d",&a),a){
		int ret=0;
		for(int i=0;i*i*i<=a;i++){
			ret=max(ret,i*i*i+table[upper_bound(table,table+97,a-i*i*i)-1-table]);
		}
		printf("%d\n",ret);
	}
}

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

#ifdef LOCAL
#define DEBUG(...) debug(#__VA_ARGS__, __VA_ARGS__);
#else
#define DEBUG(...) 6;
#endif

template<typename T, typename S> ostream& operator << (ostream &os, const pair<T, S> &p) {return os << "(" << p.first << ", " << p.second << ")";}
template<typename C, typename T = decay<decltype(*begin(declval<C>()))>, typename enable_if<!is_same<C, string>::value>::type* = nullptr>
ostream& operator << (ostream &os, const C &c) {bool f = true; os << "["; for (const auto &x : c) {if (!f) os << ", "; f = false; os << x;} return os << "]";}
template<typename T> void debug(string s, T x) {cerr << s << " = " << x << "\n";}
template<typename T, typename... Args> void debug(string s, T x, Args... args) {cerr << s.substr(0, s.find(',')) << " = " << x << " | "; debug(s.substr(s.find(',') + 2), args...);}

int pref[300005];

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

    int n;
    string s;
    cin >> n >> s;

    for (int i=0; i<n; i++)
        pref[i] = (i > 0 ? pref[i-1] : 0) + (s[i] == 'W');

    int ret = INT_MAX;
    for (int i=0; i<n; i++)
        ret = min(ret, (i > 0 ? pref[i-1] : 0) + (n - i - 1 - (pref[n-1] - pref[i])));
    cout << ret << "\n";

    return 0;
}


Measured memory_bytes: 4888
function Main(input) {
  const splited = input.split('\n');
  const ans = splited[1].split('').map(x => {
    const next = x.charCodeAt() + parseInt(splited[0], 10);
    if(next === 90) {
      return 'Z' 
    }
    if(next > 90) {
      return String.fromCharCode(next - 90 + 64)
    } else {
      return String.fromCharCode(next)
    }
  }).join('')
  console.log(ans)
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7500
IDENTIFICATION                   DIVISION.
PROGRAM-ID.                      ABC_075_B.
ENVIRONMENT                      DIVISION.
DATA                             DIVISION.
WORKING-STORAGE                  SECTION.
    01 INP    PIC X(5).
    01 H      PIC 9(2).
    01 W      PIC 9(2).

    01 field1.
        03 field11 OCCURS 50.
            05 field    PIC X(50).

    01 ln     PIC X(50).

    01 MARK1  PIC X(1) VALUE '#'.
    01 MARK2  PIC X(1) VALUE SPACE.

    01 x      PIC 9(2).
    01 y      PIC 9(2).

    01 nx     PIC 9(2).
    01 ny     PIC 9(2).

    01 i      PIC 9(18).
    01 j      PIC 9(18).

    01 k      PIC 9(1).

    01 dx1.
        03 dx11 OCCURS 8.
            05 dx    PIC S9(1).

    01 dy1.
        03 dy11 OCCURS 8.
            05 dy    PIC S9(1).

    01 cnt    PIC 9(1).

PROCEDURE                        DIVISION.
MAIN.
*> X座標
*> 下、右、上、左、右下、右上、左下、左上
MOVE  0 TO dx(1).
MOVE  1 TO dx(2).
MOVE  0 TO dx(3).
MOVE -1 TO dx(4).
MOVE  1 TO dx(5).
MOVE  1 TO dx(6).
MOVE -1 TO dx(7).
MOVE -1 TO dx(8).

*> Y座標
*> 下、右、上、左、右下、右上、左下、左上
MOVE  1 TO dy(1).
MOVE  0 TO dy(2).
MOVE -1 TO dy(3).
MOVE  0 TO dy(4).
MOVE  1 TO dy(5).
MOVE -1 TO dy(6).
MOVE  1 TO dy(7).
MOVE -1 TO dy(8).

    ACCEPT INP.

    UNSTRING INP
    DELIMITED BY SPACE
    INTO H W.

    PERFORM VARYING i FROM 1 BY 1 UNTIL H < i
        ACCEPT field(i)
    END-PERFORM.

    PERFORM VARYING i FROM 1 BY 1 UNTIL H < i
        PERFORM VARYING j FROM 1 BY 1 UNTIL W < j
            MOVE i TO x
            MOVE j TO y
            MOVE 0 TO cnt

            IF field(x)(y:1) = MARK1 THEN
                STRING
                    ln(1:FUNCTION STORED-CHAR-LENGTH(ln))
                    MARK1 DELIMITED BY SIZE
                    INTO ln
                END-STRING
            ELSE
                PERFORM VARYING k FROM 1 BY 1 UNTIL 8 < k
                    COMPUTE nx = x + dx(k)
                    COMPUTE ny = y + dy(k)

                    IF nx < 1 OR H < nx
                        OR ny < 1 OR W < ny THEN
                            CONTINUE
                    ELSE

                    IF field(nx)(ny:1) = MARK1 THEN
                            ADD 1 TO cnt
                        END-IF
                    END-IF

                END-PERFORM

                STRING
                    ln(1:FUNCTION STORED-CHAR-LENGTH(ln))
                    cnt DELIMITED BY SIZE
                    INTO ln
                END-STRING
            END-IF
        END-PERFORM
        DISPLAY ln
        MOVE SPACE TO ln
    END-PERFORM.

    STOP RUN.


Measured memory_bytes: 892
#include <stdio.h>          // printf(), scanf()

int
main(int argc, char **argv)
{
	int n;
	scanf("%d", &n);
	for (int i = 1; i <= n; ++i)
	{
		int x;
		scanf("%d", &x);

		printf("Case %d:\n", i);
		for (int j = 0; j < 10; ++j)
		{
			x = ((x * x) / 100) % 10000;
			printf("%d\n", x);
		}
	}

	return 0;
}

Measured memory_bytes: 1828
#include <bits/stdc++.h>
#define ll long long
#define MAX_L 3001000
using namespace std;

// L(1~n)
// c< a+b
// reight = (a+b)　以上の数
// left = b以下の数

// ex) n= 4, L =1,2,3,4
// a = 1, b= 2
// lb(3) = 3
// lb(2) = 2

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    ll n;
    cin>>n;
    vector<ll> L(n+1, 0);
    for(int i =1; i<=n; i++){
        ll t;
        cin>>t;
        L[i] = t;
    }
    sort(L.begin(), L.end());
    ll ans = 0;
    vector<ll> C(MAX_L,0);
    for(int i=1; i<= n; i++){
        ll t = L[i];
        C[t]++;
    }
    for(ll i=0; i<MAX_L; i++){
        C[i+1] += C[i];
    }
    for(int a = 1;a<n-1; a++){
        for(int b = a+1; b<n; b++){
            ll bv = L[b];
            ll cv = L[a] +L[b];
            ll lc = b;
            ll rc = C[cv-1];
            ll dif = rc - lc;
            if(dif > 0) ans += dif;
        }
    }
    cout<< ans << endl;
    return 0;
}


Measured memory_bytes: 23680
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i <(n); ++i)
#define REP2(i,x,n) for (int i = x; i <(n); ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int,int>;
static const double PI = acos(-1);
static const int INF = 1e9+7;



int main(){
  char a, b;
  cin >> a >> b;
  if(a == b) cout << 'H' << endl;
  else cout << 'D' << endl;
  return 0;
}


Measured memory_bytes: 3640
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int r[6][6] = {
	{ -1, 2, 4, 1, 3, -1 }, { 3, -1, 0, 5, -1, 2 }, { 1, 5, -1, -1, 0, 4 },
	{ 4, 0, -1, -1, 5, 1 }, { 2, -1, 5, 0, -1, 3 }, { -1, 3, 1, 4, 2, -1 }
};

int main()
{
	vector<int> d(6);

	for (int i = 0; i < d.size(); ++i)
		cin >> skipws >> d[i];

	int q;
	cin >> q;

	string ans;
	while (q--)
	{
		int f, t;
		cin >> t >> f;

		vector<int>::iterator itt, itf;
		itt = find(d.begin(), d.end(), t);
		itf = find(d.begin(), d.end(), f);
		ans += to_string(d[r[itt - d.begin()][itf - d.begin()]]) + "\n";
	}

	cout << ans;

	return 0;
}

Measured memory_bytes: 3260
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#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 rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define inf (1ll<<60)
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())
#define VI(a,n) vi a(n); rep(i,n)cin>>a[i];
#define sq(n) (n)*(n)

using namespace std;

const int mod=1e9+7;

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

void run(){
    int h,w;
    cin>>h>>w;
    vector<string> a(h);
    rep(i,h)cin>>a[i];
    vvi dp(h,vi(w));
    rep(i,h){
        if(a[i][0]=='#')break;
        dp[i][0]=1;
    }
    rep(i,w){
        if(a[0][i]=='#')break;
        dp[0][i]=1;
    }
    Rep(i,1,h){
        Rep(j,1,w){
            if(a[i][j]=='#')continue;
            int u=0,l=0;
            if(a[i-1][j]!='#')u=dp[i-1][j];
            if(a[i][j-1]!='#')l=dp[i][j-1];
            dp[i][j]=(u+l)%mod;
        }
    }
    cout<<dp[h-1][w-1]<<endl;
}

Measured memory_bytes: 9216
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("Failed to read bytes") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let a: u128 = read();
    let mut b: String = read();
    let b:u128 = b.replace(".", "").parse().unwrap();
    println!("{}", a * b / 100);
}


Measured memory_bytes: 2136
#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define irep(i,a,b) for(ll i=ll(a);i>=ll(b);i--)
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; }
#define pb push_back
#define mp make_pair
#define F .first
#define S .second 
using ll=long long;
using ld=long double;
const ll INF = 1LL<<60;
const ll mod=1e9+7;
using namespace std;
ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }
ll a[220000];
ll b[220000];
map<ll,vector<ll>>x;
int main(){
    ll n,k,ans=1e11;
    cin>>n>>k;
    rep(i,1,n+1)cin>>a[i];
    ll cnt=1;
    ll mm=0;
    ll pos=1;
    b[0]=1;
    while(cnt<=n){
        pos=a[pos];
        b[cnt]=pos;
        cnt++;
    }
    ll aa,bb=-1;
    rep(i,0,n+1){
        x[b[i]].pb(i);
        if(x[b[i]].size()>1){aa=x[b[i]][0];bb=x[b[i]][1]-x[b[i]][0];break;}
    }
    ll cc=0;
    if(k>n&&bb!=-1){
        if(k>=aa)cc=(k-aa)%bb+aa;
        else cc=aa;
    }
    else if(k>n&&bb==-1)cc=k;
    else if(k<=n)cc=k;
    
    cout<<b[cc]<<endl;

}


Measured memory_bytes: 28376
#include<stdio.h>
#include<iostream>
#include<math.h>
#include<algorithm>
#include<string>
#define pi 3.14159
using namespace std;

int main() {
	string str;
	int i;
	while(getline(cin, str)) {
		for(i = 0; i < 26; i++) {
			for(int j = 0; j < str.size(); j++) {
				if(str[j] != ' ' && str[j] != '.') {
					if(str[j] != 'a') {
						str[j] -= 1;
					} else str[j] = 'z';
				}
			}
			for(int j = 0; j < str.size() - 4; j++) {
				if(str[j] == 't' && str[j + 1] == 'h') {
					if(str[j + 2] == 'e' ) {
						cout << str <<endl;
						i = 26;
						break;
					} else if(str[j + 2] == 'i' && str[j + 3] == 's'){
						cout << str <<endl;
						i = 26;
						break;
					} else if(str[j + 2] == 'a' && str[j + 3] == 't') {
						cout << str <<endl;
						i = 26;
						break;
					}
				}
			}
			
		}
	}

	return 0;
}

Measured memory_bytes: 1172
#include <bits/stdc++.h>
using namespace std;
const int N = 19, INF = 1000000009;

int n;
int a[N], b[N];

int s[1 << N][N];

int dp[1 << N][N][2];

int main()
{
    scanf("%d", &n);
    for (int i = 0; i < n; ++i)
        scanf("%d", &a[i]);
    for (int i = 0; i < n; ++i)
        scanf("%d", &b[i]);
    for (int x = 0; x < (1 << n); ++x)
    {
        for (int i = n - 1; i >= 0; --i)
        {
            s[x][i] = s[x][i + 1];
            if ((x & (1 << i)))
                ++s[x][i];
        }
    }
    for (int x = 0; x < (1 << n); ++x)
    {
        for (int i = 0; i < n; ++i)
        {
            for (int z = 0; z < 2; ++z)
                dp[x][i][z] = INF;
        }
    }
    for (int x = 0; x < (1 << n); ++x)
    {
        for (int i = 0; i < n; ++i)
        {
            if (!(x & (1 << i)))
            {
                int y = (x | (1 << i));
                int qq = i + s[x][i] - s[x][0];
                int q = s[x][i] + qq;
                q %= 2;
                int u;
                if (q == 0)
                    u = a[i];
                else
                    u = b[i];
                for (int j = 0; j < n; ++j)
                {
                    if ((x & (1 << j)))
                    {
                        if (a[j] <= u)
                            dp[y][i][q] = min(dp[y][i][q], dp[x][j][0] + qq);
                        if (b[j] <= u)
                            dp[y][i][q] = min(dp[y][i][q], dp[x][j][1] + qq);
                    }
                }
                if (x == 0)
                    dp[y][i][q] = min(dp[y][i][q], qq);
            }
        }
    }
    int ans = INF;
    for (int i = 0; i < n; ++i)
    {
        for (int z = 0; z < 2; ++z)
            ans = min(ans, dp[(1 << n) - 1][i][z]);
    }
    if (ans == INF)
        printf("-1\n");
    else
        printf("%d\n", ans);
    return 0;
}


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

using namespace std;

template <typename T>
T cin2var()
{
    T val;
    cin >> val;
    return val;
}

void sub()
{
    const auto A(cin2var<size_t>());
    const auto S(cin2var<string>());
    if (A < 3200) {
        cout << "red" << endl;
    }
    else {
        cout << S << endl;
    }
}

int main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    sub();
    return 0;
}


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

const int N = 200005;

int main()
{
	int i, n, t;
	ll ans = 0;
	scanf("%d", &n);
	map<int, int> x;
	for (i = 0; i < n; i++)
	{
		scanf("%d", &t);
		x[t]++;
	}
	bool have = false;
	for(auto it = x.rbegin(); it != x.rend(); it++)
	{
		if (!have && it->second >= 4)
		{
			ans = static_cast<long long>(it->first);
			ans = ans*static_cast<long long>(it->first);
			break;
		}
		else if (!have && it->second >=2)
		{
			ans = static_cast<long long>(it->first);
			have = true;
		}
		else if (have && it->second>=2)
		{
			ans = ans*static_cast<long long>(it->first);
			break;
		}
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 4992
#include <iostream>
#include <vector>
#include <cmath>
#include <string> 
#include <cstdint>
#include <cstring>
//https://qiita.com/ofutonfuton/items/92b1a6f4a7775f00b6ae
 
using namespace std;
typedef long long ll;
bool** connection;
ll N, M;
int result = 0;

bool saiki(bool* searched, int current){
    searched[current] = true;
    for(ll i = 0; i < N; i ++){
        if(connection[current][i] == true && searched[i] == false){
            saiki(searched, i);
        }
    }
}

int main()
{
    cin >> N >> M;
    ll* a = new ll[M];
    ll* b = new ll[M];
    connection = new bool*[N];
    for(ll i = 0; i < N; i ++){
        connection[i] = new bool[N];
        for(ll n = 0; n < N; n ++){
            connection[i][n] = false;
        }
    }
    for(ll i = 0; i < M; i ++){
        cin >> a[i] >> b[i];
        a[i] --;
        b[i] --;
        connection[a[i]][b[i]] = true;
        connection[b[i]][a[i]] = true;
    }

    for(ll i = 0; i < M; i ++){
        bool* newSearched = new bool[N];
        for(ll n = 0; n < N; n ++){
            newSearched[n] = false;
        }
        connection[a[i]][b[i]] = false;
        connection[b[i]][a[i]] = false;
        saiki(newSearched, 0);
        for(ll i = 0; i < N; i ++){
            if(newSearched[i] == false){
                result ++;
                break;
            }
        }   
        connection[a[i]][b[i]] = true;
        connection[b[i]][a[i]] = true;
    }


    cout << result;
    
    return 0;
}

Measured memory_bytes: 256
import std.algorithm, std.conv, std.range, std.stdio, std.string;

void main()
{
  auto rd1 = readln.split.to!(size_t[]), n = rd1[0], m = rd1[1];
  auto r = new int[](n);
  foreach (_; 0..m) {
    auto rd2 = readln.split.to!(size_t[]), a = rd2[0]-1, b = rd2[1]-1;
    ++r[a];
    ++r[b];
  }

  foreach (ri; r) writeln(ri);
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main()
{
    int a,b;
    char s1[101],s2[101],s3[101];
	
	    // 文字列の入力
	scanf("%s %s",&s1, &s2);//S,Tの入力
	scanf("%d %d",&a, &b);//AB
	scanf("%s",&s3);
	
	if(strcmp(s3,s1)==0){
		printf("%d %d\n", a-1, b);
		return 0;
	}
	printf("%d %d\n", a, b-1);
	    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i=0; i < n; i++)
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define all(vec) vec.begin(), vec.end()
#define tmax(x, y, z) max((x), max((y), (z)))
#define tmin(x, y, z) min((x), min((y), (z)))
ll MM = 1000000000; ll mod = MM + 7; ll MMM=9223372036854775807;//2^63 -1
ll GCD(ll x, ll y){ if(y == 0) return x; else return GCD(y, x % y);}
ll LCM(ll x, ll y){ return x / GCD(x, y) * y;}
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 INF = 1LL << 60;
//cout << fixed << setprecision(10);

int main(){
    ll n, ans=-1, a, x, y; cin>>n;
    vector<set<pair<ll,ll>>> v(n);
    rep(i,n){
        cin>>a;
        rep(j,a){
            cin>>x>>y;
            v[i].insert(make_pair(x-1,y));
        }
    }
    for(ll bit=0;bit<(1<<n);bit++){
        bool ok=1;
        ll cnt=0;
        rep(i,n){
            if(bit&(1<<i)){
                cnt++;
                for(auto p: v[i]){
                    if(p.second && !(bit&(1<<p.first))){
                        ok=0; break;
                    }
                    else if(!p.second && (bit&(1<<p.first))){
                        ok=0; break;
                    }
                }
            }
            if(!ok) break;
        }
        if(ok) ans=max(ans, (ll)__builtin_popcount(bit));
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
#include <ctype.h>
#include <stdint.h>
#include <string.h>
#include <wchar.h>
#include <math.h>

#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define ABSS(a, b) ((a) > (b) ? (a) - (b) : (b) - (a))

int compare_f(const void *a, const void *b) {
	return *((size_t *)a) > *((size_t *)b) ? -1 : 1;
}

static size_t comb(const size_t n, const size_t r) {
	size_t result = 1;

	for (size_t i = 0; i < r; i++) {
		result *= n - i;
		result /= i + 1;
	}

	return result;
}

static size_t countDivisors(const size_t n)
{
	size_t count = 1;

	for (size_t i = 2; i <= n; i++) {
		if (n%i == 0) {
			count++;
		}
	}

	return count;
}

int main(void) {
	size_t N, K;

	scanf("%zu %zu", &N, &K);

	puts((N % K == 0 ? "0" : "1"));

	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
using namespace std;
const ll mod=1e9+7;
const ll inf = (ll)1e17;
const ld eps = 1e-12;
const ld PI = 3.14159265358979323846;
ll mul(ll a, ll b, ll m = mod) { return (ll)(a * b) % m;}
ll add(ll a, ll b, ll m = mod) { a += b; if(a >= m) a -= m; if(a < 0) a += m; return a;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    string a,b,c;
    int x,y;
    cin>>a>>b>>x>>y>>c;
    if(a==c){
        cout<<x-1<<" "<<y<<endl;
    }
    else cout<<x<<" "<<y-1<<endl;
    return 0;
    }


Measured memory_bytes: 256
//atcoder clange
#include <stdio.h>

int main(void){
    int N,D;
      scanf("%d", &N);//数値の取得
        scanf("%d", &D);//数値の取得
	int count = 0;
  int ans = 0;
  while(ans < N){
   ans = ans + (D*2)+1;
    count++;
  }
  
  
  printf("%d",count);
  	
    return 0;
}

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

#define ARRAY_MAX 110

int main() {
	
	int pro = 0;
	cin >> pro;
	
	vector<int>array(ARRAY_MAX,0);
	vector<int>total(ARRAY_MAX,0);
	
	for(int i = 0;i < pro;i++){
		cin >> array[i];
	}
	
	int count = 0;
	int score = 0;
	int maxi = 0;

	for(int i = 1;i <= 100 ;i++){
		score = i;
		for(int j = 0;j < pro;j++){
			if(array[j] >= score){
				total[i]++;
			}
		
		}		
		if(score <= total[i]){
			maxi = i; 
		}
	}
		
	cout << maxi << endl;
	return 0;
}

Measured memory_bytes: 3116
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define PI 3.141592653589793
#define rep(i, n) for (int i = 0; i < (n); i++)
#define REP(i, a, n) for (int i = a; i < (n); i++)
#define rrep(i, n, k) for (int i = (n); i >= (k); i--);
#define all(x) (x).begin(), (x).end()
#define vi vector<int>
#define pi pair<int, int>
#define pl pair<ll, ll>
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T>vector<T> make_vector(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto make_vector(size_t a, Ts... ts){return vector<decltype(make_vector<T>(ts...))>(a, make_vector<T>(ts...));}
const int MOD = 1e9+ 7;
const int INF = numeric_limits<int>::max() - 1e8;
const ll INFLL = numeric_limits<ll>::max() - 1e17;

signed main() {
    string S;
    cin >> S;
    bool ok = false;
    for (int i = 0; i < 3; i++) if (S[i] == '7') ok = true;
    cout << (ok ? "Yes" : "No") << endl;
}


Measured memory_bytes: 3592