akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <deque>
#include <map>
#include <set>
#include <complex>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <chrono>
 
#define ft first
#define sc second
#define pb push_back
#define len(v) (int)v.size()
// #define int ll
 
using namespace std;
typedef long long ll;
typedef long double ld;


int get(vector<pair<int, int>> have) {
	if(len(have) == 0) 
		return 0;
	if(len(have) == 1 && have[0].ft == have[0].sc) 
		return 0;
	int ans = 1;
	vector<pair<int, int>> t(len(have));
	
	for (int i = len(have) - 1; i >= 0; i--) {
		int l = 0, r = len(have) - i;
		while(r - l > 1) {
			int m = (l + r) / 2;
			if(have[i + m].ft - m >= have[i].sc) 
				r = m;
			else 
				l = m;
		}
		ans = max(ans, r);
	}
	return max(1, ans);
}

signed main() {
	#ifdef PC
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    #endif  
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int n;
    cin >> n;
    string s, t;
    cin >> s >> t;

    map<char, int> was;
    vector<int> r(n + 1, -1);
    vector<pair<int, int>> have;
    for (char c = 'a'; c <= 'z'; c++)
    	was[c] = -1;
    int uk = n;
    for (int i = n - 1; i >= 0; i--) {
    	if(uk > i) 
    		uk--;
    	while(uk >= 0 && s[uk] != t[i]) 
    		uk--;
    	if(uk == -1) {
    		cout << -1;
    		return 0;
    	}
    	r[uk] = max(r[uk], i);
    }
    // for (int i = 0; i < n; i++) {
    // 	while(uk <= i && s[uk] != t[i]) 
    // 		uk++;
    // 	if(uk > i) {
    // 		cout << -1;
    // 		return -1;
    // 	}
    // 	r[uk] = i;
    // }
    // for (int i = 0; i < n; i++) {
    // 	was[s[i]] = i;
    // 	if(was[t[i]] == -1) {
    // 		cout << -1;
    // 		return 0;
    // 	}
    // 	r[was[t[i]]] = i;
    // }
    for (int i = 0; i < n; i++) {
    	if(r[i] == -1) 
    		continue;
    	have.pb({i, r[i]});
    }
    int lr = -1, rr = -1;
   	vector<pair<int, int>> now;
    int ans = 0;
    for (int i = 0; i < len(have); i++) { 
    	if(rr < have[i].ft) {
    		ans = max(ans, get(now));
    		now.clear();
    		now.pb(have[i]);
    		lr = have[i].ft, rr = have[i].sc;
    		continue;
    	}
    	now.pb(have[i]);
    	lr = have[i].ft, rr = have[i].sc;
    }
    ans = max(ans, get(now));
    cout << ans << endl;
}	

Measured memory_bytes: 37520
#include <bits/stdc++.h>
using namespace std;
#define int long long
int inf = 10e17;
int findLowerBound(
    vector<pair<int, int>> &arr,
    pair<int, int> &p)
{

    auto low = lower_bound(arr.begin(),
                           arr.end(), p);

    return low - arr.begin();
}
int findUpperBound(
    vector<pair<int, int>> &arr,
    pair<int, int> &p)
{
    auto up = upper_bound(arr.begin(),
                          arr.end(), p);

    return up - arr.begin();
}
bool vis[200005];
vector<int> vec[100005];
int child[100005];
void dfs(int node)
{
    vis[node] = 1;
    for (int i = 0; i < vec[node].size(); i++)
    {
        if (!vis[vec[node][i]])
        {
            dfs(vec[node][i]);
            child[node] += child[vec[node][i]];
        }
    }
}
void belman(int n, int m, vector<pair<int, pair<int, int>>> vec, int dis[])
{
    for (int i = 0; i <= n + m - 1; i++)
    {
        for (int j = 0; j < vec.size(); j++)
        {
            int u = vec[j].second.first;
            int v = vec[j].second.second;
            int w = vec[j].first;

            if (dis[u] + w < dis[v])
            {
                dis[v] = dis[u] + w;
            }
        }
    }
}
int fun(int a, int b)
{
    if (a > b)
        return 0;
    if (a == b)
        return 1;
    else
    {
        return fun(a + 1, b) + fun(a, b - a);
    }
}
int32_t main()
{
    // ios_base::sync_with_stdio(false);
    // cin.tie(NULL);
    // cout.tie(NULL);
    int n;
    cin >> n;
    string str;
    cin >> str;
    int ans = 0;
    int count = 0;
    for (int i = 0; i < n; i++)
    {
        if (str[i] == 'I')
        {
            count++;
        }
        else
        {
            count--;
        }
        ans = max(ans, count);
    }
    cout << ans << "\n";
    return 0;
}


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

#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define repi(i,a,b) for(int i = (a); i < (b); i++)

using namespace std;

typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;

const int INF=1<<29;
const double EPS=1e-9;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};
char board[300][300]={{0}};

int n;
int main(){
	while(cin>>n,n){
		pair<pii,pii> dp[300][300];
		memset(dp, 0, sizeof(dp));
		int ans = 0;
		for(int i =1;i <=n;i++){
			for(int j =1;j <=n;j++){
				cin>>board[i][j];
				if(board[i][j]=='1'){
					dp[i][j].first.first =1;
					dp[i][j].first.second=1;
					dp[i][j].second.first =1;
					dp[i][j].second.second=1;
				}
			}
		}
		for(int i =1;i <=n;i++){
			for(int j =1;j <=n;j++){
				if(board[i][j]=='1'){
					int x = dp[i][j].first.first =dp[i][j-1].first.first+1;
					int y = dp[i][j].first.second=dp[i-1][j].first.second+1;
					int z = dp[i][j].second.first =dp[i-1][j-1].second.first+1;
					int r = dp[i][j].second.second=dp[i-1][j+1].second.second+1;
					//cout <<x<<" "<<y<<" "<<" "<<z<<" "<<r<<endl;
					int t1 =max(x,y);
					int t2 =max(z,r);
					ans =max(ans,max(t1,t2));
				}
			}
		}
		cout <<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 2648
a = int(input())

if a == 105:
    cnt = 1
elif a <= 104:
    cnt = 0
else:
    cnt = 0
    divs = 0
    for i in range(1,a+1, 2):
        divs = 0
        for j in range(1,i+1):
            if i%j == 0:
                divs += 1
        if divs == 8:
            cnt += 1

print(cnt)




Measured memory_bytes: 3060
#include<cstdio>
#include<cstring>
#include<algorithm>
typedef long long ll;
int m,a[200010];
ll sum = 0;

template<typename T>
inline void read(T &x){
    x = 0; char ch = getchar(); int f = 1;
    for(;ch < '0' || ch > '9'; ch = getchar()) if(ch == '-') f = -1;
    for(;ch >= '0' && ch <= '9'; ch = getchar()) x = x * 10 + ch - '0';
    x *= f;
}
int main(){
    read(m);
    for(int i = 1;i <= m; i++) read(a[i]);
    for(int i = 2;i <= m; i++)
        if(a[i] < a[i - 1]) sum += a[i - 1] - a[i], a[i] = a[i - 1];
    printf("%lld\n",sum);
    return 0;
}
/*

*/

Measured memory_bytes: 2372
# Problem D - Partition

# 公約数を列挙する関数
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    divisors.sort()
    return divisors

# input process
N, M = map(int, input().split())
common_divisors = make_divisors(M)

# initialization
max_cd = 1

for c in common_divisors:
    if c*N<=M:
        max_cd = max(max_cd, c)

print(max_cd)


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

main(){
	
	char str[100];

	scanf("%s",&str);

	if(str[0]=='Y'&&str[1]=='A'&&str[2]=='K'&&str[3]=='I'){
		printf("Yes\n");
	}else{
		printf("No\n");
	}
	
	return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <map>
#include <iomanip>
#include <math.h> 
#include <stack>
#include <queue>
#include <bitset>
#include <cstdlib>
#include <tuple>
#include <cctype>
#include <ctype.h>
#include <set>
#include <sstream>
#include <time.h>
#include <numeric>
using namespace std;
//#define int long long
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define fi first
#define se second
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))
#define l1 list[index]
#define l2 list[index - 1]
#define l3 list[index + 1]
#define iif(i,j) ((i<0 && j<0) || (i>0 && j>0)) ? true : false 
typedef long long ll;
typedef pair<int, int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
typedef pair<pint, int> P1;
typedef pair<int, pint> P2;
typedef pair<pint, pint> PP;
static const ll maxLL = (ll)1 << 62;
const ll MOD = 1000000007;
const ll INF = 1e18;
const double PI = 3.14159265359;
int ca[12] = { 31,28,31,30,31,30,31,31,30,31,30,31 };

#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))

signed main() {
	int N;
	//vector<int>list;
	int list[2005];
	int cnt = 0;

	//memset(list, 99999999, sizeof(list));
	for (int i = 0; i < 2005; i++) {
		list[i] = 99999999;
	}

	cin >> N;

	for (int i = 0; i < N; i++) {
		int num;
		cin >> num;
		//list.push_back(num);
		list[i] = num;
	}

	//sort(list.begin(), list.end());
	sort(list , list + SIZE_OF_ARRAY(list));
	//int indexk = 0;

	for (int i = 0; i < N - 2; i++) {
		//cout << "i->" << i << endl;
		for (int j = i + 1; j < N - 1; j++) {
			//cout << "i->" << i << endl;
			for (int k = j + 1; k < N; k++) {
			//for (int k = indexk; k > j;) {
			//for (int k = indexk; k < N; k++) {
				//if (k <= j)continue;
				//if (list[i] + list[j] <= list[k]) {
				//	//cnt += (k - j);
				//	cnt += (k + 1);
				//	//cnt += (indexk + 2);
				//	cout << "cnt->" << cnt << " k->" << k << endl;
				//	indexk = k - 1;
				//	break;
				//}
				//else {
				//	//indexk = k;
				//}

				//int num = list[i] + list[j] + list[k];
				//int num = min( { list[i] + list[j], list[j] + list[k], list[i] + list[k]});

				//if (list[i] + list[j] < num && list[i] + list[k] < num &&list[j] + list[k] < num) {
				if (list[i] + list[j] > list[k] && list[i] + list[k] > list[j] &&list[j] + list[k] > list[i]) {
					cnt++;
				}
				/*else {
					break;
				}*/
			}
			//indexk = j + 2;
			//indexk = 0;
		}
		//indexk = 0;
	}



	cout << cnt << endl;


	
	return 0;
}

Measured memory_bytes: 256
my $n = <STDIN>;
my $counter1 = 0;my@a;my$number;
while ($n>$counter1){$number=<STDIN>;chomp($number);push(@a,$number);$counter1++;}
my @sorted =sort{$b<=>$a}@a;
my $a1=$sorted[0];my$a2=$sorted[1];
my $numbers;my @answer;
if($a1==$a2){print "$a1\n" x $n;} else {$numbers=join('!',@a);$numbers=~s/$a1/a/;$numbers=~s/\d+/$a1/g;$numbers=~s/a/$a2/;@answer=split(/!/,$numbers);foreach(@answer){print"$_\n"}}

Measured memory_bytes: 69092
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>

using namespace std;

int v[200010];
int n, m, a, b;

int main()
{
 cin >> n >> m;
 for(int i = 1; i <= m; i++)
 {
   cin >> a >> b;
   if(a == b) continue;
   if(a == 1) v[b]++;
   if(b == n) v[a]++;
 }
 for(int i = 2; i < n; i++)
 {
   if(v[i] > 1)
   {
     cout << "POSSIBLE";
     return 0;
   }
 }

     cout << "IMPOSSIBLE";
     return 0;
}


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

// Shrotening
#define fst first
#define snd second
#define pb push_back

// Loop
#define FOR(i,a,b) for(auto i=(a);i<(b);++i)
#define RFOR(i,a,b) for(auto i=(a);i>=(b);--i)

#define REP(i,a) for(long i=0;i<(a);++i)
#define RREP(i,a) for(long i=(a);i>=0;--i)

#define EACH(i,a) for(auto (i)=(a).begin(),_END=(a).end();i!=_END;++i)
#define REACH(i,a) for(auto (i)=(a).rbegin(),_END=(a).rend();i!=_END;++i)

//Algorithm
#define ALL(a) (a).begin(), a.end()
#define RALL(a) (a).rbegin(), a.rend()
#define EXIST(a,x) ((a).find(x)!=(a).end())
#define SORT(a) std::sort((a).begin(), (a).end())
#define UNIQUE(a) std::sort((a).begin(), a.end()), a.erase(std::unique((a).begin(), a.end()), a.end());
#define SUM(a) std::accumulate((a).begin(), (a).end(), 0);

//Setting
#define OPT std::cin.tie(0);std::ios::sync_with_stdio(false);

//debug message
bool debug = true;
#define MSG(s)   if(debug){std::cout << s << std::endl;}
#define DEBUG(x) if(debug){std::cout << "debug(" << #x << "): " << x << std::endl;}

//alias
typedef long long LL;
typedef std::vector<char> VC;
typedef std::vector<int>  VI;
typedef std::vector<long> VL;
typedef std::vector<long long> VLL;

typedef std::vector< VC > VC2;
typedef std::vector< VI > VI2;
typedef std::vector< VL > VL2;
typedef std::vector< VLL > VLL2;

typedef std::pair<int,int> PII;

int N, M;

std::vector<bool> toStart, toGoal;
int main() {
    std::cin >> N >> M;
    toStart.resize(N, false);
    toGoal.resize(N, false);
    toStart[0]  = true;
    toGoal[N-1] = true;

    REP(i, M) {
        int a, b;
        std::cin >> a >> b;
        --a, --b;
        if(a == 0) {
            toStart[b] = true;
        } else if(b == N-1) {
            toGoal[a] = true;
        }
    }

    for(int i=1; i<N-1; ++i) {
        if(toStart[i] && toGoal[i]) {
            std::cout << "POSSIBLE" << std::endl;
            return 0;
        }
    }

    std::cout << "IMPOSSIBLE" << std::endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
 int H,W;
 int h,w;

 while(1){
  scanf("%d %d",&H,&W);
  if(H==0 && W==0)break;

  for(h=0;h<H;h++){
   for(w=0;w<W;w++){
    if(h==0 || h==H-1 || w==0 || w==W-1)printf("#");
    else printf(".");
   }
   printf("\n");
  }
 printf("\n");
 }
 return 0;
}

Measured memory_bytes: 572
// header {{{
#include <iostream>
#include <algorithm>
#include <vector>
#include <complex>
#include <utility>
#include <string>
#include <sstream>
#include <queue>
#include <map>
#include <list>
#include <stack>
#include <tuple>
#include <cstdio>
#include <cmath>
using namespace std;

#define ALPHABET    26
#define EPS         (1e-10)
#define EQ(a, b)    (abs((a)-(b)) < EPS)

typedef long long ll;
typedef unsigned long long ull;
// }}}

int main() {
    ll x;cin >> x;
    ll ans = 0;
    ans = x/11*2;
    if(x%11 != 0){
        ans++;
        if(x%11 > 6){
            ans++;
        }
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 256
K, X = map(int, input().split())

li = []

if X-K < -1000000:

  for i in range(-1000000, -1000000 + K):
    li.append(i)
elif X+K >1000000:
  for i in range(1000000 - K, 1000000):
    li.append(i)
else:
  for i in range(X-K+1, X+K):
    li.append(i)

print (' '.join(map(lambda x: str(x), li)))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<ll>; using VVI = vector<VI>; using VVVI = vector<VVI>;
const int inf=1e9+7;
const ll INF=1LL<<61;
const ll mod=1e9+7;

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

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int i,j;
    int h,w,k;
    cin>>h>>w>>k;
    VVI v(h+1,VI(w+1,0));
    for(i=1;i<=h;i++){
        for(j=1;j<=w;j++){
            char c;
            cin>>c;
            v[i][j]=v[i-1][j]+v[i][j-1]-v[i-1][j-1];
            if(c=='1') v[i][j]++;
        }
    }
    int ans=inf;
    for(i=0;i<(1<<(h-1));i++){
        VI ks;
        int cnt=0;
        ks.pb(0);
        for(j=0;j<h-1;j++){
            if((i>>j)&1) {
                ks.pb(j+1);
                cnt++;
            }
        }
        ks.pb(h);
        int l=1;
        int r=1;
        while(1){
            while(1){
                bool ng=0;
                for(j=1;j<ks.size();j++){
                    if(v[ks[j]][r]-v[ks[j-1]][r]-v[ks[j]][l-1]+v[ks[j-1]][l-1]>k){
                        ng=1;
                        break;
                    }
                }
                if(!ng) r++;
                else break;
                if(r==w+1) break;
            }
            if(r==w+1){
                ans=min(ans,cnt);
                break;
            }
            if(l!=r) {
                l=r;
                cnt++;
            }
            else break;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 384
X,N = map(int,input().split())
listP=[]
while True:
    try:
        listP=list(map(int,input().split()))
    except:
        break;
        
candidate_list=list(range(-101,201))
for num in listP:
  candidate_list.remove(num)

for num in range(120):
  minus=candidate_list.count(X-num)
  plus=candidate_list.count(X+num)
  if minus==1:
    print(X-num)
    break
  if plus==1:
    print(X+num)
    break

Measured memory_bytes: 9204
//By Don4ick 
//#define _GLIBCXX_DEBUG

#include <bits/stdc++.h>

typedef long long ll;
typedef long double ld;
typedef unsigned int ui;

#define forn(i, n) for (int i = 1; i <= n; i++)
#define pb push_back
#define all(x) x.begin(), x.end()
#define y1 qewr1234

const double PI = acos(-1.0);
const int DIR = 4;
const int X[] = {1, 0, -1, 0};
const int Y[] = {0, 1, 0, -1};

const int N = (int)2e5 + 228;

using namespace std;

int L, n, x[N];
ll ans, pref[N], suf[N];

void solve()
{
	for (int i = 0; i < n; i++)
	{
	 	pref[i] = x[i];
	 	if (i > 0)
	 		pref[i] += pref[i - 1];
	}                            
	for (int i = n - 1; i >= 0; i--)
		suf[i] = L - x[i] + suf[i + 1];
	for (int i = 0; i < n - 1; i++)
	{
		ll cur = x[i];
		if (!((n - i - 1) & 1))
		{
			int k = (n - i - 1) / 2;
			int a = n - k, b = i + k;
			cur += suf[a] + pref[b - 1] - pref[i - 1];
			cur += suf[a + 1] + pref[b - 1] - pref[i];
			cur += max(x[a] - x[b], L - x[a] + x[b]);	
		}
		else
		{
			int k = (n - i - 1) / 2;
			if (k > 0)
			{
				int a = n - k, b = i + k;
				cur += suf[a] + pref[b] - pref[i - 1];
				cur += suf[a] + pref[b - 1] - pref[i];
				cur += max(x[a - 1] - x[b], L - x[a - 1] + x[b]);
			}
			else
			{
				cur += max(x[i + 1] - x[i], L - x[i + 1] + x[i]);
			}
		}
		ans = max(ans, cur);
	}
}
             
int main()
{
	//ios_base::sync_with_stdio(false);
	//cin.tie();
	//cout.tie();		

	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);

	//~read
	scanf("%d%d", &L, &n);
	for (int i = 0; i < n; i++)		
		scanf("%d", &x[i]);
	//~solve
	ans = max(L - x[0], x[n - 1]);
	solve();
	reverse(x, x + n);
	for (int i = 0; i < n; i++)
		x[i] = L - x[i];
	solve();
	cout << ans << endl;	

	return 0;
}



Measured memory_bytes: 4096
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define nl '\n'
#define f(i, n) for (int i = 0; i < n; ++i)

using namespace std;
void solve() {
    int n;
    cin >> n;
    vector<int> a(n);
    f(i, n) cin >> a[i];
    ll ans = 0;
    int req = a[0];
    f(i, n) {
        if (a[i] < req) {
            ans += (req - a[i]);
        } else {
            req = a[i];
        }
    }
    cout << ans << nl;
}

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

Measured memory_bytes: 4004
import java.io.*;

public class Main {

	private static final int subNum = 3;
	private static final int adge1 = 0;
	private static final int adge2 = 1;
	private static final int adge3 = 2;

	public static void main(String[] a) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int num = Integer.parseInt(br.readLine());
		int[][] tryangle = new int[num][subNum];

		for (int i = 0; i < num; i++) {

			String str = br.readLine();
			String[] strBuf = str.split(" ");

			for (int j = 0; j < subNum; j++) {
				tryangle[i][j] = Integer.parseInt(strBuf[j]);
			}
		}
		
		int x, y, z;
		for (int i = 0; i < num; i++) {
			x = tryangle[i][adge1] * tryangle[i][adge1];
			y = tryangle[i][adge2] * tryangle[i][adge2];
			z = tryangle[i][adge3] * tryangle[i][adge3];
			if (((x + y) == z) || ((y + z) == x) || ((x + z) == y))
				System.out.println("YES");
			else
				System.out.println("NO");
		}
	}
}

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

int main()
{
  long long K, A, B;
  cin >> K >> A >> B;
  
  long long n = K;
  long long ans = 1;
  if (B - A < 2) ans = K + 1;
  else if (K < A - 1) ans = K + 1;
  else
  {
    ans = A;
    n -= (A - 1);
    
    ans += (n / 2) * (B - A);
    n = n % 2;
    
    if (n == 1) ans++;
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main() {
  int x,y;
  while(1) {
    scanf("%d",&x);
    scanf("%d",&y);
    if(x == 0 && y == 0) break;
    if(x >= y) {
      printf("%d %d\n", y, x);
    }else {
      printf("%d %d\n", x, y);
    }
  }
  return 0;
}

Measured memory_bytes: 600
let s = read_line ()
let f s x = let n = ref 0 in String.iter (fun c -> if c = x then incr n) s; !n
let _ = print_endline @@ if f s 'a' = 1 && f s 'b' = 1 && f s 'c' = 1 then "Yes" else "No"

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

int main()
{
  string s, t = "";
  cin >> s;
  int ans = 999;
  rep(i, s.size() - 2){
    t += s[i];
    t += s[i + 1];
    t += s[i + 2];
    ans = min(ans, abs(753 - stoi(t)));
    t = "";
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3632
/*
...........__________    							 |										    ___  __
.............|       |     						     |											 |   /
.............|       |     						     |									  		 |  /
.............|       |                               |                         __                | /      _______
.............|_______|  _______            _______   |______   ________   /|  /  |               |/       |      |
.............| \               | |      | |          |      |          | / | /   |               |\       |
.............|  \       _______| |      | |_______   |      |   _______|   |/    |               | \      |
.............|   \      |      | |      |         |  |      |  |       |   |     |               |  \     |
.........  __|    \__|  |______| |______| ________|  |      |_ |_______|   |     |__|           _|   \__ _|        .

*/
#include<bits/stdc++.h>
using namespace std ;
#define int 				long long
#define ull 				unsigned long long int
#define ld 					long double
#define vi 					vector<int>
#define vii 				vector<pair<int,int>>
#define vvi 				vector<vector<int>>
#define pf 					push_front
#define popb 				pop_back
#define pb 					push_back
#define eb 					emplace_back
#define pii 				pair<int,int>
#define prec(x) 			fixed<<setprecision(15)<<x
#define all(x) 				x.begin(),x.end()
#define rall(x) 			x.rbegin(),x.rend()
#define mset(a,b) 			memset(a,b,sizeof(a))
#define mcpy(a,b) 			memcpy(a,b,sizeof(a))
#define fo0(i,n) 			for(int i=0,i##end=n;i<i##end;i++)
#define fo1(i,n) 			for(int i=1,i##end=n;i<=i##end;i++)
#define fo(i,a,b) 			for(int i=a,i##end=b;i<=i##end;i++)
#define foe(i,x)			for(__typeof((x).end())i=(x).begin();i!=(x).end();++i)
#define fre(i,x)			for(__typeof((x).rend())i=(x).rbegin();i!=(x).rend();++i)
#define fast ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0)
#define inf 1e18
const int mod=1e9+7;
const int N=4e5+10;


int power(int x, unsigned int y, int p) 
{ 
	int res = 1;	 
	x = x % p; 
	while (y > 0) 
	{ 
		if (y & 1) 
			res = (res*x) % p; 

		y = y>>1; 
		x = (x*x) % p; 
	} 
	return res; 
}

void raushan_kumar(){
	int n;cin>>n;
	int a[n];
	map<int,int> m;
	set<int> s;
	int cnt=0;
	fo0(i,n){
		cin>>a[i];
		s.insert(a[i]);
		if(a[i]==0){
			cnt++;
		}
	}
	if(cnt==2){
		cout<<0;
		return;
	}
	if(n%2){
		if(s.size()==(n/2+1)){
			cout<<power(2,n/2,mod);
		}
		else{
			cout<<0;
		}
	}
	else{
		if(s.size()==(n/2)){
			cout<<power(2,n/2,mod);
		}
		else{
			cout<<0;
		}
	}
}

int32_t main()
{
	fast;int t=1;
	//cin>>t;
	while(t--){
		raushan_kumar();
	}

}

Measured memory_bytes: 3968
#include<cstdio>
#include<cstring>
#include<algorithm>
#define ll long long
using namespace std;
const int N=300010,P=1e9+7;
inline int read(){
	int x=0,f=0,c=getchar();
	for(;c>'9'||c<'0';f=c=='-',c=getchar());
	for(;c>='0'&&c<='9';c=getchar())
	x=(x<<1)+(x<<3)+c-'0';return f?-x:x;
}
int n,i,a[N],f[N][2];
int main(){
	//freopen("1.out","w",stdout);
	n=read();f[0][1]=1;
	for(i=1;i<=n;i++){
		a[i]=read();
		f[i][1]=f[i][0]=min(f[i-1][0],f[i-1][1])+1;
		if(a[i]>=a[i-1])
			f[i][1]=min(f[i][1],f[i-1][1]);
		if(a[i]<=a[i-1])
			f[i][0]=min(f[i][0],f[i-1][0]);
	}printf("%d\n",min(f[n][0],f[n][1]));
	return 0;
}

Measured memory_bytes: 1280
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;

const static int N = 10;

int partition(vector<int>& A,int p,int r) {
  int x = A[r]; // ?????????????????????
  int i = p - 1;
  for(int j=p;j<r;j++) {
    if(A[j] > x) {
      i++;
      swap(A[i],A[j]);
    }
  }
  swap(A[i+1],A[r]);
  return i+1;
}
void quick_sort(vector<int>& A,int p,int r) {
  if(p < r) {
    int q = partition(A,p,r);
    quick_sort(A,p,q-1);
    quick_sort(A,q+1,r);
  }
}

void sort(vector<int>& vec) {
  quick_sort(vec,0,vec.size()-1);
}

int main() {
  vector<int> hills(N);
  for(int i=0;i<N;i++) {
    scanf("%d",&hills[i]);
  }

  sort(hills);

  for(int i=0;i<3;i++) {
    printf("%d\n",hills[i]);
  }
}

Measured memory_bytes: 1032
dice_faces_count, border_line = gets.split.map(&:to_i)

def calc_score(current_score)
  current_score * 2
end

probability = (1..dice_faces_count).inject(0) do |result, i|
  score = i
  coin_tossed_count = 0
  while score < border_line do
    score = calc_score(score)
    coin_tossed_count += 1
  end
  result += 1 / dice_faces_count.to_f * (1 / 2.to_f ** coin_tossed_count)
end

p probability

Measured memory_bytes: 1788
from itertools import groupby, accumulate, product, permutations, combinations
def solve():
  N = int(input())
  A = [list(map(int, input().split())) for _ in range(N)]
  dp = [0]*(1<<N)
  dp[0] = 0
  for i in range(2,N+1):
    for com in combinations(range(N),i):
      S = sum([1<<c for c in com])
      last = com[-1]
      dp[S] = dp[S-(1<<last)]
      for c in com:
        dp[S] += A[last][c]
  for i in range(2,N+1):
    for com in combinations(range(N),i):
      S = sum([1<<c for c in com])
      T = (S-1)&S
      while T>0:
        dp[S] = max(dp[S],dp[T]+dp[S-T])
        T = (T-1)&S
  ans = dp[-1]
  return ans
print(solve())

Measured memory_bytes: 74556
#include <queue>
#include <cstdio>
#include <iostream>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <stack>
#include <time.h>
#include <functional>

//#include "All.h"

using namespace std;
typedef long long int ll;

#define EPS (1e-9)
#define INF (1e9)
#define PI (acos(-1))
#define REP(i,n) for(int i=0;i<n;i++)

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

ll beki(ll a, ll b) {
    ll tmp = 1;
    REP(i, b) tmp *= a;
    return tmp;
}

int main() {
    float R;
    cin >> R;
    cout << R * 2 * PI << endl;
}

Measured memory_bytes: 3720
import fractions as fr

A, B, C, D = map(int, input().split())
lcm = C * D // fr.gcd(C, D)
ans = B - A + 1
ans -= B // C - (A-1) // C
ans -= B // D - (A-1) // D
ans += B // lcm - (A-1) // lcm
print(ans)

Measured memory_bytes: 5600
#include<iostream>

using namespace std;

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



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

typedef long long ll;
typedef int64_t i6;

#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rep2(i, n) for (ll i = 1; i <= n; ++i)
#define ALL(v) (v).begin(), (v).end()
#define Sort(x) sort(ALL(x))
#define Sort_rev(x) Sort(x);reverse(ALL(x))

template<typename V,typename T>
T find_num(V v, T num) {
    if ( find(ALL(v), num) == v.end() ) {
        return false;
    } else {
        return true;
    }
}

// π M_PI
// deg = rad*180/M_PI

int main() {
    ll n, m;
    cin >> n >> m;
    ll a[m], b[m];
    std::vector<std::vector<ll> > G(n);
    ll flag = 0;
    rep(i, m) {
        cin >> a[i] >> b[i];
        if ( (a[i] == 1 || b[i] == 1) && !flag ) {
            flag = 1;
        }
        G[a[i]-1].push_back(b[i]-1);
        G[b[i]-1].push_back(a[i]-1);
    }

    if ( !flag ) {
        cout << "No" << endl;
        return 0;
    }

    std::vector<ll> v(n);
    std::vector<ll> seen(n, 0);
    queue<ll> q;
    q.push(0);
    while ( !q.empty() ) {
        ll num = q.front();
        seen[num] = 1;
        q.pop();
        rep(i, G[num].size()) {
            ll see = G[num].at(i);
            if ( seen[see] == 0 ) {
                q.push(see);
                seen[see] = 1;
                v[see] = num+1;
            }
        }
    }

    cout << "Yes" << endl;
    rep2(i, n-1) {
        cout << v[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 16708
#include <cstdio>

int a[3];
int ans = 1000000;


int main(){
	scanf("%d %d %d", &a[0], &a[1], &a[2]);
	for(int i=0; i<3; ++i){
		int tmp = 0;
		for(int j=0; j<3; ++j){
			if(i == j) continue;
			if(a[i] < a[j]) tmp += a[j] - a[i];
			else if((a[i] - a[j]) % 2 == 0) tmp += (a[i] - a[j]) / 2;
			else tmp += (a[i] - a[j] + 1) / 2 + 1;
		}
		if(ans > tmp) ans = tmp;
	}
	printf("%d\n", ans);
}

Measured memory_bytes: 128
//url:
//problem name:

#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); ++i)
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long long,long long>;
using veci = vector<int>;
using vecl = vector<long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;

int main() {
    ll L,R; cin >> L >> R;
    ll MOD = 2019;
    ll ans = 2019;
    for(ll i = L; i <= R-1; i++) {
        for(ll j = i+1; j <= R; j++) {
            //cout << i << " " << j << endl;
            if(i*j%MOD == 0) {
                cout << 0 << endl;
                return 0;
            } else {
                chmin(ans,i*j%MOD);
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<string.h>
 
typedef long long int ll;
#define all(x) (x).begin(), (x).end()
 
using namespace std;

int nxt() {
    int x;
    cin >> x;
    return x;
}

ll nxtl(){
    ll x;
    cin>>x;
    return x;
}
 
void SieveOfEratosthenes(int n,vector <int> &primes) 
{ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true. 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // Print all prime numbers 
    for (int p=2; p<=n; p++) 
       if (prime[p]) 
          primes.push_back(p);
} 
 
ll max(ll a,ll b)
{
    if(a>b)
        return a;
    return b;
}
 
ll power(ll x, ll y,ll mod) 
{ 
    ll temp; 
    if( y == 0) 
        return 1; 
    temp = power(x, y/2,mod); 
    if (y%2 == 0) 
        return (temp*temp)%mod; 
    else
        return (((x*temp)%mod)*temp)%mod; 
} 

ll modPow(ll a, ll x, ll p) {
    //calculates a^x mod p in logarithmic time.
    ll res = 1;
    while(x > 0) {
        if( x % 2 != 0) {
            res = (res * a) % p;
        }
        a = (a * a) % p;
        x /= 2;
    }
    return res;
}

ll modInverse(ll a, ll p) {
    //calculates the modular multiplicative of a mod m.
    //(assuming p is prime).
    return modPow(a, p-2, p);
}
ll modBinomial(ll n, ll k, ll p) {
// calculates C(n,k) mod p (assuming p is prime).

    ll numerator = 1; // n * (n-1) * ... * (n-k+1)
    for (int i=0; i<k; i++) {
        numerator = (numerator * (n-i) ) % p;
    }

    ll denominator = 1; // k!
    for (int i=1; i<=k; i++) {
        denominator = (denominator * i) % p;
    }

    // numerator / denominator mod p.
    return ( numerator* modInverse(denominator,p) ) % p;
}

ll f[200001];
 
ll pow(ll a, ll b, ll MOD)
{
 ll x=1,y=a; 
 while(b > 0)
    {
        if(b%2 == 1)
    {
        x=(x*y);
        if(x>MOD) x%=MOD;
    }
    y = (y*y);
    if(y>MOD) y%=MOD; 
    b /= 2;
    }
 return x;
}
 
/* Modular Multiplicative Inverse
 Using Euler's Theorem
 a^(phi(m)) = 1 (mod m)
 a^(-1) = a^(m-2) (mod m) */
ll InverseEuler(ll n, ll MOD)
{
 return pow(n,MOD-2,MOD);
}
 
ll C(ll n, ll r, ll MOD)
{
 
 return (f[n]*((InverseEuler(f[r], MOD) * InverseEuler(f[n-r], MOD)) % MOD)) % MOD;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n=nxt(),k=nxt();
    vector <int> v(n);
    generate(all(v),nxt);
    for(int i=k;i<n;i++)
    {
        if(v[i]>v[i-k])
            cout<<"Yes\n";
        else
            cout<<"No\n";
    }
    
    
    return 0;   
}


 
 


Measured memory_bytes: 3988
using System;
using System.Linq;
using System.Collections.Generic;


namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            MainStream();
        }
        static void MainStream()
        {
            Scan sc = new Scan();
            write wr = new write();

            int a = sc.intarr[0];
            int b = sc.intarr[0];
            int c = sc.intarr[0];
            int d = sc.intarr[0];

            int sum = 0;

            if(a >= b)
            {
                sum += b;
            }
            else
            {
                sum += a;
            }

            if (c >= d)
            {
                sum += d;
            }
            else
            {
                sum += c;
            }

            wr.wri(sum);

        }


    }

    class Scan
    {
        public string str => Console.ReadLine();

        public string[] strarr => str.Split(' ');

        public long[] longarr => strarr.Select(long.Parse).ToArray();
        public int[] intarr => strarr.Select(int.Parse).ToArray();
        public char[] chararr => str.ToArray();


    }



    class write
    {
        public void wri<Type>(Type x)
        {
            Console.WriteLine(x);
        }
    }

    class Method
    {
        static public int max(params int[] nums)
        {

            int maxx = nums[0];
            for (int i = 1; i < nums.Length; i++)
            {
                maxx = Math.Max(maxx, nums[i]);
            }
            return maxx;
        }
    }
}


Measured memory_bytes: 13268
#include <iostream>

using namespace std;

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

	long long int A = 0;

	for (int i = 1; i <= b; i++) {
		A *= 10;
		A += a;
	}

	long long int B = 0;
	for (int i = 1; i <= a; i++) {
		B *= 10;
		B += b;
	}

	if (A >= B) { cout << A << endl; }
	else { cout << B << endl; }

	return 0;
}

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

int main() {
    std::string s;
    std::cin >> s;
    std::map<char, int> m;
    for (auto c : s) m[c]++;
    if (m['N'] + m['S'] == 0) {
        std::cout << (m['E'] * m['W'] > 0 ? "Yes" : "No") << std::endl;
    } else if (m['E'] + m['W'] == 0) {
        std::cout << (m['N'] * m['S'] > 0 ? "Yes" : "No") << std::endl;
    } else {
        std::cout << (m['E'] * m['W'] > 0 && m['N'] * m['S'] > 0 ? "Yes" : "No") << std::endl;
    }

    return 0;
}

Measured memory_bytes: 256
//https://beta.atcoder.jp/contests/abc109/tasks/abc109_a
#include <bits/stdc++.h>
using namespace std;
#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(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main()
{
    int A, B;
    cin >> A >> B;
    cout << ( ( A * B ) % 2 == 1 ? "Yes" : "No" ) << endl;
    return 0;
}

Measured memory_bytes: 256
h,w,d=map(int,input().split())
xy=[(0,0)]*(h*w+1)
for i in range(h):
  a=list(map(int,input().split()))
  for j in range(w):
    xy[a[j]]=(i+1,j+1)
s=[0]*(h*w+1)
for i in range(d+1,h*w+1):
  s[i]=abs(xy[i][0]-xy[i-d][0])+abs(xy[i][1]-xy[i-d][1])+s[i-d]
q=int(input())
for _ in range(q):
  l,r=map(int,input().split())
  print(s[r]-s[l])

Measured memory_bytes: 19712
package main

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

var INF int32 = math.MaxInt32
var INF64 int64 = math.MaxInt64

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

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

func min64(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

func max64(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func readLineNums(bf *bufio.Reader) []int {
	line, _ := bf.ReadString('\n')
	line = strings.Trim(line, "\n")
	fields := strings.Split(line, " ")
	nums := []int{}
	for _, field := range fields {
		num, _ := strconv.Atoi(field)
		nums = append(nums, num)
	}
	return nums
}

func readLineNum64s(bf *bufio.Reader) []int64 {
	line, _ := bf.ReadString('\n')
	line = strings.Trim(line, "\n")
	fields := strings.Split(line, " ")
	nums := []int64{}
	for _, field := range fields {
		num, _ := strconv.ParseInt(field, 10, 64)
		nums = append(nums, num)
	}
	return nums
}

func readLineFloats(bf *bufio.Reader) []float64 {
	line, _ := bf.ReadString('\n')
	line = strings.Trim(line, "\n")
	fields := strings.Split(line, " ")
	nums := []float64{}
	for _, field := range fields {
		num, _ := strconv.ParseFloat(field, 64)
		nums = append(nums, num)
	}
	return nums
}

func readLineStrs(bf *bufio.Reader) []string {
	line, _ := bf.ReadString('\n')
	line = strings.Trim(line, "\n")
	return strings.Split(line, " ")
}

func main() {
	bf := bufio.NewReader(os.Stdin)
	N := readLineNums(bf)[0]
	A := make([][]int, N)
	for i := range A {
		A[i] = readLineNums(bf)
	}

	dp := make([][]int, N+1) // dp[i][mask]: 表示第i个人, 选择mask所表示的人的方案数量
	for i := range dp {
		dp[i] = make([]int, 1<<uint(N))
	}

	dp[0][0] = 1
	for i:=0; i<N; i++ { // 最后一个人的数量由前面N-1个人计算得出
		for mask:=0; mask<len(dp[i]); mask++ {
			if dp[i][mask] == 0 {
				continue
			}
			for j:=0; j<N; j++ {
				if A[i][j] == 0 {
					continue
				}
				if mask & (1<<uint(j)) != 0 {
					continue
				}
				nmask := mask | (1<<uint(j))
				dp[i+1][nmask] += dp[i][mask]
				if dp[i+1][nmask] > 1e9+7 {
					dp[i+1][nmask] -= 1e9+7
				}
			}
		}
	}

	fmt.Println(dp[N][(1<<uint(N))-1])

	// 这种写法代码看着简单, 可读性不高
	//bitCnt := func(mask int) int {
	//	cnt := 0
	//	for i:=0; i<N; i++ {
	//		if mask & (1<<uint(i)) != 0 {
	//			cnt++
	//		}
	//	}
	//	return cnt
	//}
	//dp := make([]int, 1<<uint(N)) // 2^n
	//dp[0] = 1 // 无人匹配
	//for mask:=0; mask<len(dp)-1; mask++ {
	//	a := bitCnt(mask)
	//	for b:=0; b<N; b++ {
	//		if A[a][b] == 0 {
	//			continue
	//		}
	//		if mask & (1<<uint(b)) != 0 {
	//			continue
	//		}
	//		nmask := mask | (1<<uint(b))
	//		dp[nmask] += dp[mask]
	//		if dp[nmask] > 1e9+7 {
	//			dp[nmask] -= 1e9+7
	//		}
	//	}
	//}
	//fmt.Println(dp[(1<<uint(N))-1])
}

Measured memory_bytes: 319488
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define erep(i, n) for (ll i = 0; i <= (ll)(n); ++i)
#define FOR(i,a,b) for (ll i = (a); i < (ll)(b); ++i)
#define EFOR(i,a,b) for (ll i = (a); i <= (ll)(b); ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } }

using Graph = vector<vector<int>>;
using P = pair<int, int>;
using Tuple = tuple<int, int, int>;


int main() {
    int n; cin >> n;
    set<char> st;
    rep(i, n) {
        char a; cin >> a;
        st.insert(a);
    }

    if(st.size() == 4) {
        cout << "Four" << endl;
    } else {
        cout << "Three" << endl;
    }
    return 0;

}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.LinkedHashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        ArrayList<Integer> al = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            al.add(sc.nextInt());
        }
        Set<Integer> set = new LinkedHashSet<>(al);
        System.out.println(set.toArray().length);
    }
}

Measured memory_bytes: 23764
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;

public class Main {

	public static void main(String[] args) {

		//?????£?????????
		int numH = 0;
		int numW = 0;

		String cell = "#";
		String con = ".";

		String[] NumWork;

		try {
			//??\????????????
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

			while (true) {
				String line = br.readLine();

				if (line != null) {

					//??°??£?????´??°?????????
					NumWork = line.split(" ", 0);

					//??´??°?????°??????
					ArrayList<Integer> NumList = new ArrayList<Integer>();

					for (int i = 0; i < NumWork.length; i++) {
						NumList.add(Integer.parseInt(NumWork[i]));
					}
					numH = NumList.get(0);
					numW = NumList.get(1);

					// ????????¨(?????????????????????)
					String outputStr = "";

					//??????????????????
					if (numH != 0 || numW != 0) {

						//????????¢?????????
						//????????????
						for (int i = 1; i <= numH; i++) {
							for (int j = 1; j <= numW; j++) {
								// ????????¨????????????(#)
								if (i == 1 || i == numH){
									outputStr += cell;

								//??????????????????
								} else if (j == 1 || j == numW){
									outputStr += cell;
								} else {
									outputStr += con;
								}
							}
							//?????£???????????????
							System.out.println(outputStr);
							outputStr = "";
						}
						System.out.println("");

					}else{
						break;
					}
				}else{
					break;
				}

			}
		} catch (IOException e) {
			System.out.println(e);
		}

	}

}

Measured memory_bytes: 48060
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define MAX 1e18
#define MIN -1e18
#define MOD 1000000007
//#define mod2 20071027
//#define MOD 998244353
#define rep(i,a) for(int i=0;i<a;i++)
#define rep1(i,a) for(int i=1;i<=a;i++)
#define base 139
//#define mod 1000074259
#define base2 31
#define memz(a) memset(a, 0, sizeof(a))
#define memn(a) memset(a, -1, sizeof(a))
#define in1(a) scanf("%lld", &a)
#define in2(a, b) scanf("%lld%lld", &a, &b)
#define TC(c) printf("Case #%lld: ", ++c)
#define FAST ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;
const ll N=300010,M=1000010;
string s;
ll r[4][N],res;
map<char, ll>mp;
int main()
{
    mp['R']=1, mp['G']=2, mp['B']=3;
    ll sz;
    cin>>sz>>s;
    for(int i=0;i<sz;i++)
    {
        if(i)
        {
            for(int j=1;j<=3;j++)
                r[j][i]=r[j][i-1];
        }
        r[mp[s[i]]][i]++;
    }
    for(int i=0;i<sz;i++)
    {
        for(int j=i+1;j<sz;j++)
        {
            if(s[i]!=s[j])
            {
//                cout<<i<<" "<<j<<endl;
            ll len = j-i, val=0;
            bool vis[5]={0};
            vis[mp[s[i]]]=1, vis[mp[s[j]]]=1;
            for(int k=1;k<=3;k++)
            {
                if(vis[k]==0)
                {
//                    cout<<j+len<<endl;
                    val = r[k][sz-1]-r[k][j];
                    if(j+len<sz && s[j+len]!=s[i] && s[j+len]!=s[j]) val--;
//                    cout<<"val "<<val<<endl;
                    res+=val;
                    break;
                }
            }

            }
        }
    }
    printf("%lld\n",res);
    return 0;
}

/*

*/


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

//構造体
typedef struct {
  char name[10];
  int t;
}Process;


//プロトタイプ宣言
void enqueue(Process);
Process dequeue(void);

//グローバル変数
Process Q[100000];
int n,q;
int ttime;
int i,j;

int main(void){

  int count=0;
  Process stack[1000];

  scanf("%d %d", &n, &q);

  //スケジュールの入力
  for ( i = 0; i < n; i++){
    scanf("%s", Q[i].name);
    scanf("%d", &Q[i].t);
  }

  for(i=0;i<n+j;i++){
  stack[count] = dequeue();
  if(stack[count].t != -1)
  enqueue(stack[count++]);
  }

  return 0;
}


//終了したプロセスを表示する
void enqueue(Process x){

  printf("%s %d\n",x.name,x.t);
}

Process dequeue(void){

  int flag=0;

    if(Q[i].t <= q){
      ttime += Q[i].t;
      Q[i].t = ttime;
      flag=1;
    } 
    else{
      ttime += q;
      Q[n+j].t = Q[i].t - q;
      strcpy(Q[n+j].name,Q[i].name);
      j++;
    }

    if(flag==0)
      Q[i].t = -1;

      return Q[i];
      
}

Measured memory_bytes: 1344
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <functional>

using namespace std;
using lli = long long int;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (lli i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (lli i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

lli h, w, a, b;
int main() {
  cin >> h >> w >> a >> b;
  cout << (h-a)*(w-b) << endl;
  return 0;
}



Measured memory_bytes: 256
object Main {
  import io.StdIn._

  def getStrings = readLine().split(" ")
  def getInts = getStrings.map(_.toInt)

  def main(args: Array[String]): Unit = {
    val N = getInts(0)
    println((1 to N by 2).count(n => (1 to n).count(m => n % m == 0) == 8))
  }
}


Measured memory_bytes: 25300
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int m = scan.nextInt();
		int l = scan.nextInt();

		int[][] a = new int[n][m];
		int[][] b = new int[m][l];
		
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				a[i][j] = scan.nextInt();
			}
		}

		for (int i = 0; i < m; i++) {
			for (int j = 0; j < l; j++) {
				b[i][j] = scan.nextInt();
			}
		}
		
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < l; j++) {
				long sum = 0;
				for (int k = 0; k < m; k++) {
					sum += a[i][k] * b[k][j];
				}
				System.out.print(sum);
				if (j != l - 1) {
					System.out.print(" ");
				}
			}
			System.out.println();
		}
		
		scan.close();
	}

}

Measured memory_bytes: 44936
#include <bits/stdc++.h>
using namespace std;
using lint  = long long;
const lint INF = -1e16;
vector<vector<char> > field;
vector<vector<lint> > dist;
lint H, W;
typedef pair<lint, lint> P;
const vector<lint> dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};

lint bfs(lint sx, lint sy){
  for(lint i = 0; i < H; i++){
    for(lint j = 0; j < W; j++) dist[i][j] = INF;
  }
  queue<P> que;
  que.push(P(sx, sy));
  dist[sx][sy] = 0;
  while(que.size()){
    P p = que.front(); que.pop();
    for(lint i = 0; i < 4; i++){
      lint nx = p.first +  dx[i], ny = p.second + dy[i];
      if(0 <= nx && nx < H && 0 <= ny && ny < W && dist[nx][ny] == INF && field[nx][ny] == '.'){
        dist[nx][ny] = dist[p.first][p.second] + 1;
        que.push(P(nx, ny));
      }
    }
  }
  lint ans = 0;
  for(lint i = 0; i < H; i++){
    for(lint j = 0; j < W; j++) ans = max(ans, dist[i][j]);
  }
  return ans;
}


signed main(){
  cin >> H >> W;
  field.resize(H, vector<char> (W));
  dist.resize(H, vector<lint> (W, 0));
  for(lint i = 0; i < H; i++){
    for(lint j = 0; j < W; j++) cin >> field[i][j];
  }
  lint ans = 0;
  for(lint i = 0; i < H; i++){
    for(lint j = 0; j < W; j++){
      if(field[i][j] == '.'){
        ans = max(ans, bfs(i, j));
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256