akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <functional>
#include <algorithm>
using namespace std;

int main(){
  	#define int long long int
	#define HUGE 10000000000
    int N;
    cin >> N;
    int a[N];
    for(int i=0;i<N;i++){
        cin >> a[i];
    }
    int result = 0;
    sort(a, a+N, greater<int>());
    if(a[0] == a[1] && a[0] == a[2] && a[0] == a[3]){
        cout << a[0] * a[0] << endl;
        return 0;
    }
    int x = HUGE;

    for(int i=0;i<N-1;i++){
        if(a[i] == a[i+1] && a[i] < x){
            if(x == HUGE){
                x = a[i];
            }else{
                cout << x * a[i] << endl;
                return 0;
            }
        }
    }
  	cout << 0 << endl;
  	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> llP;



int main() {
  ll x;
  cin>>x;
  bool temp=false;
  for(ll i=-600;i<=600;i++){
    if(temp) break;
    for(ll j=-600;j<=600;j++){
      if(i*i*i*i*i-j*j*j*j*j==x){
        cout<<i<<' '<<j<<endl;
        temp=true;
        break;
      }
    }
  }
  return 0;
}


Measured memory_bytes: 3652
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in); 
		
		String a = stdIn.next();
		
		if(a.equals("Sunny")) {
			System.out.println("Cloudy");
		}
		if(a.equals("Cloudy")) {
			System.out.println("Rainy");
		}
		if(a.equals("Rainy")) {
			System.out.println("Sunny");
        }		
	}

}


Measured memory_bytes: 21716
/* --- author: dxm --- */
#include<bits/stdc++.h>
#pragma GCC optimize(2)
using namespace std;

#define INF 1e9
#define Inf 1e18
#define rep(i,n) for(int (i)=0;(i)<n;i++)
#define REP(i,n) for(int (i)=1;(i)<=n;i++)
#define mp make_pair
#define pb push_back
#define fst first
#define snd second
typedef long long ll;
typedef double db;
typedef long double ldb;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;

void qread(int &x){
	int neg=1;x=0;
	char c=getchar();
	while(c<'0'||c>'9'){if(c=='-')neg=-1;c=getchar();}
	while(c>='0'&&c<='9')x=10*x+c-'0',c=getchar();
	x*=neg;
}

const int mod=1e9+7;
int Add(int a,int b){
	return a+b>=mod?a+b-mod:a+b; 
}
int Sub(int a,int b){
	return a-b<0?a-b+mod:a-b;
}

const int maxn=100005;
int n;
ll A,B,s[maxn];
int to[maxn][2],dp[maxn][2];

class Fenwick{
public:
	int t[maxn];
	void add(int v,int val){
		for(v++;v<=n+1;v+=(v&-v))t[v]=Add(t[v],val);
	}
	int sum(int v){
		int res=0;
		for(v++;v;v-=(v&-v))res=Add(res,t[v]);
		return res;
	}
}tree[2];

int main(){
#ifdef FILE
	freopen("FILE.in","r",stdin);
	freopen("FILE.out","w",stdout);
#endif
	scanf("%d%lld%lld",&n,&A,&B);
	REP(i,n)scanf("%lld",&s[i]);
	to[1][0]=to[1][1]=1;
	for(int i=2;i<=n;i++){
		if(s[i]-s[i-1]>=A)to[i][0]=to[i-1][0];
		else to[i][0]=i;
		if(s[i]-s[i-1]>=B)to[i][1]=to[i-1][1];
		else to[i][1]=i;
	}
	tree[0].add(0,1);
	tree[1].add(0,1);
	REP(i,n)rep(j,2){
		int l=to[i][j]-1,r=upper_bound(s+1,s+1+n,s[i+1]-(!j?B:A))-s-1;
		if(i==n)r=n;
		r=min(r,i-1);
//		cout<<l<<" "<<r<<endl;
		if(l>r)dp[i][j]=0;
		else dp[i][j]=Sub(tree[j^1].sum(r),tree[j^1].sum(l-1));
		tree[j].add(i,dp[i][j]);
//		cout<<i<<" "<<j<<" "<<dp[i][j]<<endl;
	}
	printf("%d\n",Add(dp[n][0],dp[n][1]));
#ifdef TIME
	printf("Running Time = %d ms\n",int(clock()*1000.0/CLOCKS_PER_SEC));
#endif
	return 0;
}

/*
Input:
-----------------
Output:
*/


Measured memory_bytes: 3328
N,M,X,Y=map(int,input().split())
x=[int(x) for x in input().split()]
y=[int(x) for x in input().split()]
ans=False
for z in range(X+1,Y+1):
    if max(x)<z<=min(y):
        ans=True

if ans==True:
    print("No War")
else:
    print("War")


Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <complex>
#include <valarray>
#include <fstream>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <random>

#define _overload(a, b, c, d, ...) d
#define _rep1(X, A, Y) for (int (X) = (A);(X) <= (Y);++(X))
#define _rep2(X, Y) for (int (X) = 0;(X) < (Y);++(X))
#define rep(...) _overload(__VA_ARGS__, _rep1, _rep2)(__VA_ARGS__)
#define rrep(X, Y) for (int (X) = Y-1;(X) >= 0;--(X))
#define all(X) (X).begin(),(X).end()
#define len(X) ((int)(X).size())
#define mod(n, m) (((n)%(m)+(m))%(m))
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;
const int INFINT = 1 << 30;                          // 1.07x10^ 9
const ll INFLL = 1LL << 60;                          // 1.15x10^18
const double EPS = 1e-10;
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

const int MAX_N = 200000;
int N;
string S[MAX_N];

int main() {
    cin >> N;
    rep(i, N) cin >> S[i];

    set<string> st;
    rep(i, N) st.insert(S[i]);

    cout << st.size() << endl;

    return 0;
}


Measured memory_bytes: 25472
#include <stdio.h>
int main (void)
{
	int a,b;
	scanf("%d",&a);
	scanf("%d",&b);
	if (a < b)
	{
		printf("a < b\n");
	}
	else
	{
		if (a > b)
		{
			printf("a > b\n");
		}
		else 
		{
		printf("a == b\n");
		}
		}
	return 0;
}

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



int main() {
	int A, B;
	cin >> A >> B;
	int tmp = max(A + B, A * B);
	cout << max(tmp,A-B) << endl;

}

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

using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	REP(i, v.size()) { if (i)os << " "; os << v[i]; }return os;
}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
	REP(i, v.size()) { if (i)os << endl; os << v[i]; }return os;
}

int main() {
	ll n;

	cin >> n;

	vector<pair<ll, ll>> v(n);

	REP(i, n) {
		ll a, b;
		cin >> a >> b;
		v[i] = make_pair(a, b);
	}

	sort(v.begin(), v.end(), greater<pair<ll, ll>>());

	ll ans = v[0].first;

	if (v[0].second > 0) {
		ans += v[0].second;
	}

	cout << ans << endl;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
using ll =long long;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define all(i) i.begin(),i.end()
template<typename T>
using v =vector<T>;
template<typename T>
using vv = vector<v<T>>;
using p = pair<ll,ll>;
const ll INF = (ll)1e9;
template<typename T> T chmin(T &a,T b){a=min(a,b);}
template<typename T> T chmax(T &a,T b){a=max(a,b);}

ll gcd (ll a,ll b){
    return a==0?a:gcd(b,a%b);
}

void d(){
    ll n,m;
    cin >> n >> m;
    auto data = v<ll>();
    data.push_back(m);
  	data.push_back(1);
    for(ll i=2;i*i<=m;i++){
        if(m%i!=0) continue;
        data.push_back(i);
        data.push_back(m/i);
    }
  	sort(all(data),greater<ll>());
  	for(auto i:data){
    	if(m/i<n) continue;
      	cout << i << endl;
      	return;
    }
}

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

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

int main(){
  int N, D, X;
  cin >> N >> D >> X;

  vector<int> A(N);

  for (int i = 0; i < N; i++)
  {
    cin >> A.at(i);
  }
  
  int eaten = 0;

  for (int i = 0; i < D; i++)
  {
    for (int j = 0; j < N; j++)
    {
      if (A.at(j) * i + 1 <= D){
        eaten += 1;
      }
    }
    
  }
  cout << X + eaten << endl;
}

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

using namespace std;

int main(){
  long long a,b,c;
  cin>>a>>b>>c;
  if(4*a*b<(c-a-b)*(c-a-b)&&c-a-b>0) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 256
//defines e includes
#include <bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define rep1(i, n) for(int i=0;i<(int)n;i++)
#define rep2(i, a, b) for(int i=(int)a;i<(int)b;i++)
#define st first
#define nd second
#define pb push_back
#define pf push_front
#define p_b pop_back
#define p_f pop_front
#define mp make_pair
#define MAX 100010
#define oo INT_MAX
using namespace std;
//tipagem de pares
typedef pair<int, int> ii;
typedef pair<char, char> cc;
typedef pair<int, char> ic;
typedef pair<char, int> ci;
//tipagem de vetores
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<pair<int, int>> vii;
typedef vector<bool> vb;
//tipagem de outras estruturas
typedef queue<int> qi;
typedef deque<int> dqi;
//tipagem de tipos primitivos
typedef long long int ll;
typedef unsigned long long int ull;

int main()
{
	
	fastio;
	int h, a;
	cin >> h >> a;
	int att = 0;
	while(h > 0 ){
		h-=a;
		att++;
	}

	cout << att << endl;

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int linesearch(int S[], int n, int key) {
    int i = 0;
    S[n] = key;
    while ( S[i] != key ) i++;
   
    return i != n;
}


int main() {
    int n, q, S[10001];
    int key;
    scanf("%d", &n);
    for ( int i = 0; i <  n; i++ ) scanf("%d", &S[i]);
    scanf("%d", &q);
    
    int cnt = 0;
    for ( int i = 0; i < q; i++ ) {
        scanf("%d", &key);
        if ( linesearch(S, n, key)) cnt++;
    }
    printf("%d\n", cnt);
    
    return 0;
}



Measured memory_bytes: 2728
#include<iostream>

using namespace std;

int main() {
	int n;
	cin >> n;
	int* a = new int[n + 1];
	int* b = new int[n + 1];
	for (int i = 0;i < n;i++) {
		cin >> a[i + 1];
	}
	for (int i = n;i >= 1;i--) {
		int ans = 0;
		for (int j = i * 2;j <= n;j += i) {
			ans += b[j];
			ans %= 2;
		}
		b[i] = (2 + a[i] - ans) % 2;
	}
	int kosuu = 0;
	for (int i = 1;i <= n;i++) {
		if (b[i] == 1)kosuu++;
	}
	cout << kosuu << endl;
	int cnt = 0;
	for (int i = 1;i <= n;i++) {
		if (b[i] == 1) {
			if (cnt < kosuu - 1) {
				cout << i << " ";
				cnt++;
			}
			else {
				cout << i;
				break;
			}
			
		}
	}
}

Measured memory_bytes: 4664
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
string s,s1,s2;
int ans=0;
int main(){
	cin>>s;
	for(int i=0;i<s.length();i++){
		if(s1+s[i]!=s2){
			ans++;
			s2=s1+s[i];
			s1="";
		}
		else s1+=s[i];
	}
	cout<<ans;
	cout<<"\n";
    return 0;
}

Measured memory_bytes: 640
#include <stdio.h>
#define N 50000
int p[N+1];
void era(void){
	int i,j;
	for(i=2;i<N;i++)
		p[i]=1;
	for(i=2;i*i<N;i++){
		if(p[i]){
			for(j=2*i;j<=N;j=j+i){
				p[j]=0;
			}
		}
	}
}
int main(void){
	int n,i,ans;
	era();
	while(1){
		scanf("%d",&n);
		if(!n)
			break;
		ans=0;
		for(i=2;i<=n/2;i++){
			if(p[i]&&p[n-i])
				ans++;
		}
		printf("%d\n",ans);
	}
	return 0;
}

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

using namespace std;

int solve(int a, int b, int c) {
  if (a + b >= c) {
    return b + c;
  }
  return a + b + b + 1;
}

int main() {
  std::cin.tie(nullptr);
  std::ios::sync_with_stdio(false);
  int a, b, c;
  std::cin >> a >> b >> c;
  std::cout << solve(a, b, c) << std::endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>

int main() {
    int k,a,b;
    std::cin>>k;
    std::cin>>a>>b;
    int f=0;
    for(int i=a;i<=b;i++){
        if(i%k==0){
            f=1;
        }else{
            continue;
        }
    }
    if(f==1) {
        std::cout << "OK"<<'\n';
    }else{
        std::cout << "NG"<<'\n';
    }
    return 0;
}


Measured memory_bytes: 3592
package main

import (
	"fmt"
	"sort"
)

type Student  struct {
	number int
	p int
}

type Students struct {
	s []Student
}

func (r Students)Len() int { return len(r.s) }
func (r Students)Less(i, j int) bool { return r.s[i].p < r.s[j].p }
func (r Students)Swap(i, j int) { r.s[i], r.s[j] = r.s[j], r.s[i] }

func main () {
	var N int
	fmt.Scanf("%d", &N)
	students := make([]Student, N)
	var p int
	for i := 0; i < N; i++ {
		fmt.Scanf("%d", &p)
		students[i] = Student{i, p}
	}

	sort.Sort(Students{students})
	for _, s := range students {
		fmt.Println(s.number + 1)
	}
}

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

#define ll long long
#define ull unsigned long long
#define rep(i,n) for(int i=0;i<n;i++)
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
using namespace std;
ll MOD = 1e9+7;

ll f(ll n){
    if(n==1 || n==1){
        return 1;
    }
    return (n * f(n-1)) % MOD;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n, m;
    cin >> n >> m;
    if(abs(n-m) > 1) cout << 0;
    else if(abs(n-m) == 1){
        ll ans = (f(n) * f(m)) % MOD;
        cout << ans;
    }
    else{
        ll ans =  ((f(n) * f(m) % MOD) * 2) % MOD;
        cout << ans;
    }
    return 0;
}


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

int main(){
  int N,s,sum = 0;
  cin >> N;
  s = N;
  while(s != 0){
    int a;
    a = s % 10;
    sum += a;
    s /= 10;
  }
  if(N%sum == 0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
/**
 * 2018-04-08
 * https://beta.atcoder.jp/contests/abc082/tasks/abc082_a
 */
public class Main {
    public static void main (String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();

        int x = (a+b+2-1)/2;
        System.out.println(x);
    }
}


Measured memory_bytes: 23764
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<iomanip>
using namespace std;

int main(){
    int n;
    cin>>n;
    int a[n+1];
    int cnt=0;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        if(a[i]!=i)cnt++;
    }
    if(cnt<=2)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    return 0;
}

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

const long long MOD = 1000000007;

void solve(long long N, long long M){
    ll cnt = 2;
    if(abs(N - M) > 1) cnt = 0;
    else{
        if(abs(N - M) == 1) cnt = 1;
        //cout << cnt << endl;
        for(ll i = 1; i <= N; ++i){
            cnt *= i;
            //cout << cnt << endl;
            if(cnt >= MOD) cnt = cnt % MOD;
        }
        for(ll i = 1; i <= M; ++i){
            cnt *= i;
            //cout << cnt << endl;
            if(cnt >= MOD) cnt = cnt % MOD;
        }
    }
    cout << cnt << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    solve(N, M);
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
using namespace std;
typedef long long ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define in(x) cin >> x
#define out(str) cout << str << endl

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int N;

int main(){
    cin>>N;
    vector<int> X(N),tmp(N);
    rep(i,N)cin>>X[i];
    tmp=X;
    sort(tmp.begin(),tmp.end());
    rep(i,N){
        if(X[i]<=tmp[N/2-1]){
            out(tmp[N/2]);
        }
        else{
            out(tmp[N/2-1]);            
        }
    }
}


Measured memory_bytes: 3712
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#include <queue>
typedef long long ll;
using namespace std;

int main(void){
  int n,i;
  double v[50];
  cin>>n;
  for(i=0;i<n;i++){
    cin>>v[i];
  }

  sort(v,v+n);

  double ans=v[0];
  for(i=1;i<n;i++){
    ans=(ans+v[i])/2;
  }

  printf("%lf\n",ans);

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
	int n,c=0,temp=0;
	cin>>n;
	string s;
	cin>>s;
	string s1,s2;
	for(int i=1;i<n;i++)
	{
		s1=s.substr(0,i);
		s2=s.substr(i,n-1);
		int a[26],b[26];
		memset(a,0,sizeof(a));
	    memset(b,0,sizeof(b));
		for(int i=0;i<s1.size();i++)
	{
		int x=s1[i]-'a';
		a[x]++;
	}
	for(int i=0;i<s2.size();i++)
	{
		int y=s2[i]-'a';
		b[y]++;
	}
	for(int i=0;i<26;i++)
	{
		if(a[i]>0 && b[i]>0)
		{
			c++;
		}
	}
	temp=max(temp,c);
	c=0;
	}
	cout<<temp<<endl;
	return 0;
}

Measured memory_bytes: 3604
// Problem : A - Sharing Cookies
// Contest : AtCoder - AtCoder Beginner Contest 067
// URL : https://atcoder.jp/contests/abc067/tasks/abc067_a
// Memory Limit : 256 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define eb emplace_back
#define pb push_back
#define size(s) (int)s.size()
#define int long long
#define vi vector<int>
#define vs vector<string>
#define vv vector<vector<int>>
#define pii pair<int,int>
#define m_p(x,y) make_pair(x,y)
#define vp vector<pair<int,int>>
#define setbits(x) __builtin_popcountll(x)
#define f first
#define se second
#define inc(v,n,x) v.assign(n,x)
#define incd(v,n) v.resize(n)
#define iniz(n) memset(n,0,sizeof(n))
#define inin(n) memset(n,-1,sizeof(n))
#define inimi(n) memset(n,0xc0,sizeof(n))
#define inima(n) memset(n,0x3f,sizeof(n))
#define all(v) (v).begin(),(v).end()

using namespace std;

template<typename T1,typename T2>istream &operator>>(istream &is, vector<pair<T1,T2>> &v) { for (pair<T1,T2> &t : v) is >> t.f>>t.se; return is; }
template<typename T>istream &operator>>(istream &is, vector<T> &v) { for (T &t : v) is >> t; return is; }
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v) { for (const T &t : v) {os << t <<" ";} os << '\n'; return os; }

const int N=200001;
double pi=acos(-1.0);
int md=1e9+7;
const int INF=1e15;
int dx1[]={0,0,-1,1};
int dy1[]={1,-1,0,0};

template<class T>
T abst(T a)
{return a<0?-a:a;}

template<class T>
T max2(T a,T b){return a>b?a:b;}
template<class T>
T min2(T a,T b){return a<b?a:b;}

void solve()
{
int a,b;cin>>a>>b;
if(a%3==0 or b%3==0 or(a+b)%3==0)
cout<<"Possible";
else
cout<<"Impossible";
}

int32_t main(){
ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
int t=1;
//cin>>t;
for(int i=1;i<=t;i++)
{
    solve();
}
return 0;
}


Measured memory_bytes: 3616
#include"bits/stdc++.h"
using namespace std;
int n,a,b,c;
double t1,t2,t3;
double f[301][301][301];
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		int tmp;
		scanf("%d",&tmp);
		switch(tmp)
		{
			case 1:a++;break;
			case 2:b++;break;
			case 3:c++;break;
		}
	}
	for(int k=0;k<=n;k++)
	{
		for(int j=0;j+k<=n;j++)
		{
			for(int i=0;i+j+k<=n;i++)
			{
				if(i+j+k==0)
					continue;
				t1=t2=t3=0;
				f[i][j][k]=(double)n/(i+j+k);
				if(i>0)
					t1=f[i-1][j][k]*i/(i+j+k);
				if(j>0)
					t2=f[i+1][j-1][k]*j/(i+j+k);
				if(k>0)
					t3=f[i][j+1][k-1]*k/(i+j+k);
				f[i][j][k]+=t1+t2+t3;
			}
		}
	}
	printf("%.10lf",f[a][b][c]);
}

Measured memory_bytes: 213248
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>

using namespace std;

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

using ll = long long;
#define int ll
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

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

    int n;
    cin >> n;

    vector<int> a(n+2, 0);
    rep(i, n) {
        cin >> a[i];
    }
    vector<int> cumsum(n+2, 0);

    REP(i, 0, n) {
        cumsum[i+1] = (cumsum[i] + a[i])%mod;
    }
    int res =0;
    rep(i, n-1) {
        res = (res + a[i]%mod *(cumsum[n] - cumsum[i+1]+mod)%mod)%mod;
    }

    cout << res << "\n";
}


Measured memory_bytes: 6352
N = int(input())
count = 0
for i in range(N):
    D1, D2 = map(int, input().split())
    if D1 == D2:
        count += 1
    else:
        count = 0
    if count == 3:
        print('Yes')
        break
    if i == N-1:
        print('No')

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

class Legs{
	private:
		int rightLeg;
		int leftLeg;
		int changeNum;
		int last;
	public:
		void changeStatus(string str){
			if(!str.compare("lu")){
				leftLeg = 1;
			}else if(!str.compare("ru")){
				rightLeg = 1;
			}else if(!str.compare("ld")){
				leftLeg = 0;
			}else if(!str.compare("rd")){
				rightLeg = 0;
			}
			checkChenged();
		};
		Legs(){
			rightLeg = -1;
			leftLeg = -2;
			changeNum = 0;
			last = 0;
		};
		void checkChenged(){
			if(rightLeg == leftLeg && last != leftLeg){
				last = !last;
				changeNum++;
			}
		}
		int getNum(){
			return changeNum;
		}
};


int main(){
	while(1){
		int n;
		Legs leg;
		string str;
		cin >> n;
		if(n==0) break;
		while(n--){
			cin >> str;
			leg.changeStatus(str);
		}
		cout << leg.getNum() << endl;
	}
}

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

int main(void){

    long long N ,i;
    long long m = 0;
    
    cin >> N;
    long long a[N+1];
    long long b[N];
    for(i = 0;i < N+1;i ++)
      cin >>a[i];
    for(i = 0;i < N;i ++)
      cin >>b[i];
    for(i = 0; i <N;i++){

      if(b[i] <= a[i] )
        m +=  b[i];
      
      else if(b[i] >= a[i] +a[i+1] ){
        
        m += a[i] + a[i+1];
        a[i+1] = 0;
      }
      else{
        
        a[i+1] = a[i+1]-b[i]+a[i];
        m += b[i]; 
        
      }
        
      
    }

    cout << m << endl;
    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
using namespace std;
int main(){
    int n, m;
    cin >> n >> m;
    int p, ans1 = 0, ans2 = 0;
    vector<int> wa_num(n+1);
    string s;
    for(int i = 0; i < m; i++){
        cin >> p >> s;
        if(wa_num[p] != -1){
            if(s == "AC"){
                ans1++;
                ans2 += wa_num[p];
                wa_num[p] = -1;
            }
            else wa_num[p]++;
        }
    }
    cout << ans1 << " " << ans2;
    return 0;
}

Measured memory_bytes: 640
//============================================================================
//dice1
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

typedef struct{
    int N;
    int E;
    int W;
    int S;
    int T;
    int B;
}TCycoro;
enum {pos1, pos2, pos3, pos4, pos5, pos6, posEND};
char Cmd[101];
void CyRot(TCycoro *cyc, char dir)
{
    int S;

    switch(dir){
        case 'N': // do not move EW
             S=cyc->N, cyc->N = cyc->T, cyc->T=cyc->S, cyc->S=cyc->B, cyc->B=S; break;
        case 'E': // do not move NS
             S=cyc->E, cyc->E = cyc->T, cyc->T=cyc->W, cyc->W=cyc->B, cyc->B=S; break;
        case 'W': // do not move NS
             S=cyc->W, cyc->W = cyc->T, cyc->T=cyc->E, cyc->E=cyc->B, cyc->B=S; break;
        case 'S': // do not move EW
             S=cyc->S, cyc->S = cyc->T, cyc->T=cyc->N, cyc->N=cyc->B, cyc->B=S; break;
    }
}
void prndice(TCycoro *cyc, char dir)
{
    printf("dir:%c, N=%d, E=%d, W=%d, S=%d, T=%d, B=%d\n", dir,
            cyc->N+1, cyc->E+1, cyc->W+1, cyc->S+1, cyc->T+1, cyc->B+1);
}
int main()
{
    int i,cyval[posEND]; TCycoro Cyc; 

    Cyc.N=pos5;
    Cyc.E=pos3;
    Cyc.W=pos4;
    Cyc.S=pos2;
    Cyc.T=pos1;
    Cyc.B=pos6;
    for (i=0; i<posEND; i++)
        scanf("%d", &cyval[i]);
    scanf("%s",Cmd);
    for (i=0; Cmd[i]; i++){
        CyRot(&Cyc, Cmd[i]);
        //printf("dir: %c, top: %d(%d)\n", Cmd[i], cyval[Cyc.T], Cyc.T+1);
        //prndice(&Cyc, Cmd[i]);
    }
    printf("%d\n", cyval[Cyc.T]);
    return 0;
}

Measured memory_bytes: 596
// 4

#include <bits/stdc++.h>

using namespace std;

#define FOR(i,a,b) for (int i =(a); i <(b); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(), (v).end()
#define fi first
#define se second

template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }

typedef long long ll;
typedef pair<int, int> pii;

const bool debug = 0;

int main() {
	int n,ans;
	
	while(cin >> n,n){
		bool f = false;
		ans = 0;
	for(int i=0; i<n; i++){
		int k;
		cin >> k;
		if(k >= 1)ans++;
		if(k >= 2)f= true;
	}
	 if(!f)cout << "NA" << endl;
	 else cout << ans+1 << endl; 
	}
	return 0;
}

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

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
// #pragma GCC optimize("Ofast")

using namespace std;
using ll = long long;

// MACRO
// for loop
#define REP(i, n) for (ll i = 0; i < ll(n); i++)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= ll(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= ll(b); i--)

// for vector
#define ALL(x) x.begin(), x.end()
#define SIZE(x) ll(x.size())
#define SORT(x) sort(ALL(x))
#define RSORT(x) sort(ALL(x), greater<int>())
#define RSORTS(x) sort(ALL(x), greater<string>())
#define FIND(x, n) find(ALL(x), n)
#define VFOR(e, x) for (auto &e : x)

// Constant
const ll INF = 1000000000000; // 10^12:  ∞
const int MOD = 1000000007;   // 10^9+7: Congruence ceremony MOD
const int MAXR = 100000;      // 10^5:   Array Max Range
const char EL = '\n';         // newline

// alias
#define EB emplace_back // push as last element
#define PP pop_back     // pop last element
#define MP make_pair    // pair constractor
#define F first         // first element of pair
#define S second        // second element of pair

// change max/min
template <class T>
bool chmax(T &a, const T &b)
{
  if (a < b)
  {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
  if (b < a)
  {
    a = b;
    return 1;
  }
  return 0;
}

// optimize in/out
#define OPTIMIZE_CIN_COUT() \
  cin.tie(0);               \
  ios::sync_with_stdio(false);

template <typename... Args>
void input(Args... args)
{
  for (int &e : {args...})
  {
    cin >> e;
  }
}
#define INPUT1(a) \
  int a = 0;      \
  cin >> a;
#define INPUT2(a, b) \
  int a = 0;         \
  int b = 0;         \
  cin >> a >> b;
#define INPUT3(a, b, c) \
  int a = 0;            \
  int b = 0;            \
  int c = 0;            \
  cin >> a >> b >> c;
#define INPUTS(s) \
  string s = "";  \
  cin >> s;

#define INPUTA(n, a) \
  int n = 0;         \
  cin >> n;          \
  vector<int> a(n);  \
  REP(i, n)          \
  {                  \
    cin >> a[i];     \
  }
#define INPUTB(x, y, b)                     \
  int x = 0, y = 0;                         \
  cin >> x >> y;                            \
  vector<vector<int>> b(y, vector<int>(x)); \
  REP(i, y)                                 \
  {                                         \
    REP(j, x)                               \
    {                                       \
      cin >> b[i][j];                       \
    }                                       \
  }

int main()
{
  OPTIMIZE_CIN_COUT();

  // INPUT1(N);
  INPUT2(N, D);
  ll CD = pow(D, 2);
  vector<int> X(N);
  vector<int> Y(N);
  int c = 0;

  REP(i, N)
  {
    INPUT2(x, y);
    if (pow(abs(x), 2) + pow(abs(y), 2) <= CD)
    {
      c++;
    }
  }
  cout << c;

  // INPUT3(A, B, C);
  // INPUTS(S);
  // INPUTA(N, A);
  // INPUTB(X, Y, B);
}


Measured memory_bytes: 4780
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int main(void){
int n,d[105];
int i,total,j,tmp;
int yes=1;
scanf("%d",&n);
for(int count=0;count<n;count++){
    scanf("%d",&d[count]);
}

 for (i=0; i<n; ++i) {
    for (j=i+1; j<n; ++j) {
      if (d[i] > d[j]) {
        tmp =  d[i];
        d[i] = d[j];
        d[j] = tmp;
      }
    }
  }

for(i=1;i<n;i++){
    if(d[i]!=d[i-1]){yes++;}
}
printf("%d",yes);
}



Measured memory_bytes: 128
import java.io.IOException;

import java.io.BufferedReader;
import java.io.InputStreamReader;

import java.io.PrintWriter;

@SuppressWarnings("unchecked")
public class Main {
    static final int INF = 1000000007;

    public static void main(String[] args) throws IOException {
        final String s;

        try (
            BufferedReader reader = new BufferedReader(
                new InputStreamReader(System.in))) {
            s = reader.readLine();
        }

        PrintWriter out = new PrintWriter(System.out);

        final String[] sl = s.split(" ");
        int H = Integer.parseInt(sl[0]);
        int W = Integer.parseInt(sl[1]);
        int K = Integer.parseInt(sl[2]);

        int[][] dp = new int[H + 1][W];
        dp[0][0] = 1;

        for (int y = 0; y < H; y++) {
            for (int x = 0; x < W; x++) {
                for (int k = 0; k < 1 << (W - 1); k++) {
                    boolean ok = true;

                    for (int l = 0; l < W - 2; l++)
                        if ((k >> l & 1) == 1 && (k >> l + 1 & 1) == 1)
                            ok = false;

                    if (ok) {
                        if (x >= 1 && (k >> x - 1 & 1) == 1) {
                            dp[y + 1][x - 1] += dp[y][x];
                            dp[y + 1][x - 1] %= INF;
                        } else if (x <= W - 2 && (k >> x & 1) == 1) {
                            dp[y + 1][x + 1] += dp[y][x];
                            dp[y + 1][x + 1] %= INF;
                        } else {
                            dp[y + 1][x] += dp[y][x];
                            dp[y + 1][x] %= INF;
                        }
                    }
                }
            }
        }

        out.println(dp[H][K - 1]);

        out.flush();
    }
}


Measured memory_bytes: 24148
import java.util.Scanner;

public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Scanner cin = new Scanner(System.in);
		while(true){
			int N = cin.nextInt();
			if(N==0){
				break;
			}
			int[] a = new int[N+1];
			int[] sum = new int[N+1];
			int max = -999999;
			for(int i = 1; i <= N;i++){
				a[i]=cin.nextInt();
				sum[i]=sum[i-1]+a[i];
			}
			for(int i = 0; i <= N;i++){
				for(int j = i+1; j <= N;j++){
					max = Math.max(max,sum[j]-sum[i]); 
				}
			}
			System.out.println(max);
		}
	}

}

Measured memory_bytes: 12000
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <cassert>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
const ll mod=1000000007;
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;}
// head

int n,m,k;
int main() {
	scanf("%d%d%d",&n,&m,&k);
	rep(i,0,n+1) rep(j,0,m+1) if (i*m+j*n-2*i*j==k) {
		puts("Yes");
		return 0;
	}
	puts("No");
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <queue>

#define rep(i,n) for(int i=0;i<n;i++)
#define dup(x,y) (((x)+(y)-1)/(y)) // dup * y >= x なる最小のdup.
using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;

ll ans(ll n) {
	if(n==1) return 1;
	else {
		return 1 + 2 * ans(n/2);
	}
}

int main() {
  ll H;
	cin >> H;

	cout << ans(H) << endl;
  
  return 0;
}

Measured memory_bytes: 256
use std::io::*;
use std::str::*;

fn read<T: FromStr>() -> Option<T> {
    let stdin = stdin();
    let s = stdin.bytes().map(|c| c.unwrap() as char)
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    s.parse::<T>().ok()
}

fn main() {
    let x: i32 = read().unwrap();
    let t: i32 = read().unwrap(); 
    println!("{}", if x-t > 0 { x-t } else { 0 });
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vel;
typedef vector<int> vei;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<int>> ve_vei;
typedef vector<vector<char>> ve_vec;
typedef vector<vector<bool>> ve_veb;
typedef vector<vector<string>> ve_ves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pub push_back
#define pob pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) max_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)

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

    int N,M; cin >> N >> M;
    vei a(M); 
    rep(i,M) cin >> a[i];

    vel ans(N+1,-1);
    
    rep(i,M) ans[a[i]] = 0;
    ans[0] = 1;
    

    rep1(i,N+1){
        if(ans[i] == 0) continue;
        if(i == 1) ans[i] = 1;//1段目が壊れてないなら1通り
        if(i >= 2) ans[i] = (ans[i-1] + ans[i-2]) % 1000000007;
    }
    cout << ans[N] << endl;
    return 0;
}

Measured memory_bytes: 1408
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
int gcd(int a, int b) {
	if (b == 0) {
		return a;
	}
	int r = a % b;
	return gcd(b, r);
}
int main(){
	int h, w;
	cin >> h >> w;
	vector<string> mo(h);
	vector<vector<int>> a(h, vector<int>(w,1));
	vector<vector<int>> b(w, vector<int>(h,1));
	vector<int> eh(h,0);
	vector<int> ew(w,0);
	for (int i = 0; i < h; i++) {
		string s;
		cin >> s;
		mo[i]=s;
		for (int j = 0; j < w; j++) {
			if (s[j] == '.') {
				a[i][j] = 0;
				b[j][i] = 0;
			}
		}
	}
	vector<int> zh(w, 0);
	vector<int> zw(h, 0);
	for (int i = 0; i < h; i++) {
		if (a[i] == zh) {
			eh[i] = 1;
		}
	}
	for (int i = 0; i < w; i++) {
		if (b[i] == zw) {
			ew[i] = 1;
		}
	}
	for (int i = 0; i < h; i++) {
		if (eh[i] == 0) {
			for (int j = 0; j < w; j++) {
				if (ew[j] == 0) {
					cout << mo[i][j];
				}
			}
			cout << endl;
		}
	}
}

Measured memory_bytes: 384
#include <bits/stdc++.h> 
 
#define INF (1<<31)//INT_MAX/2
#define MOD 1000000007
 
using ll  = long long;
using ull = unsigned long long;
 
int main(int argc, char *argv[])
{
    int n, m;
    std::cin >> n >> m;

    std::cout << (n-1) * (m-1) << std::endl;
    return 0;
}

Measured memory_bytes: 256
//  zukonit14 - Kunal Raut

#include<bits/stdc++.h>
using namespace std;
#define ll                  long long
#define int                 long long
#define ld                  long double
#define pb                  push_back
#define mp                  make_pair
#define fi                  first
#define se                  second
#define mod                 1000000007
#define pi                  3.1415926535
#define MAXN                2*100000+10
#define MAX2N               1*1000+10
const   ll INF              = 1e18;
#define all(v)              v.begin(), v.end()
#define allr(v)             v.rbegin(), v.rend()
#define ms(s, n)            memset(s, n, sizeof(s))
#define prec(n)             fixed<<setprecision(n)
#define forci(p,n)          for(ll i=p;i<(ll)n;i++)
#define forcj(p,n)          for(ll j=p;j<(ll)n;j++)
#define bolt                ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define bits(a)             __builtin_popcountll(a)
#define djokovic            freopen("input00.txt", "r", stdin);freopen("output00.txt", "w", stdout);
clock_t time_p              = clock();
void rtime()                {time_p = clock() - time_p; cout << "\nTime Taken : " << fixed << (float)(time_p) / CLOCKS_PER_SEC << "s\n";}
ll gcd(ll a, ll b)          {if (b == 0) return a;    return gcd(b, a % b);}
ll lcm(ll a, ll b)          {return (a / gcd(a, b) * b);}
ll expo(ll x, ll y)         {ll res = 1; x = x % mod; while (y > 0) {if (y & 1)res = (1ll * res * x) % mod; y = y >> 1; x = (1ll * x * x) % mod;} return res % mod;}
ll inv_mod(ll q, ll m = mod)   {return (expo(q, m - 2) % m);}
ll ncr(ll n, ll r)          {ll res = 1; if (r > n - r)r = n - r; for (ll i = 0; i < r; i++) {  res *= n - i;  res /= i + 1; } return res;}
ll max(ll a, ll b)          {return (a > b) ? a : b;}
bool prime(ll n)            {ll i; for (i = 2; i <= sqrt(n); i++) {if (n % i == 0)return false;} return true;}
//https://www.youtube.com/watch?v=WTJSt4wP2ME

ll rr[] = {0, 1, 1, 1, 0, -1, -1, -1};
ll cc[] = {1, 1, 0, -1, -1, -1, 0, 1};
ll n, m, k, x, c, q, a[MAXN], dp[MAXN], best;
void solve()
{
    cin >> n >> k; // k = 2;
    for (ll i = 1; i <= n; i++)  cin >> a[i];
    dp[1] = 0;
    for (ll i = 2; i <= n; i++)
    {
        ll min1 = 2e18;
        for (ll j = 1; j <= k; j++)
        {
            if (i - j <= 0)  continue;
            min1 = min(min1, dp[i - j] + abs(a[i - j] - a[i]));
        }
        dp[i] += min1;
    }
    cout << dp[n];
}
signed main()
{
    bolt;
#ifndef ONLINE_JUDGE
    djokovic;
#endif
    ll t;
    t = 1;
    //cin >> t;
    while (t--)
    {
        solve();
    }
    //rtime();
}




Measured memory_bytes: 5228
#include <bits/stdc++.h>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
//using namespace __gnu_pbds;
//template<typename key, typename val>
//using ordered_tree =
//  tree<key, val, greater<>, rb_tree_tag, tree_order_statistics_node_update>;
typedef long long int64;
typedef complex<double> comp;
const double pi = 3.14159265358979323846;
const int inf = (int)1e+9 + 2;
const int64 inf64 = (int64)1e+18 + 2;
const double dinf = 1e+20;
const int mod = 1'000'000'007;//998244353;
const int base = 2187;
const double eps = 1e-8;
const int N = 500'001;
const int LOGN = 19;

int n, m, k;

void solve(int test)
{
  cin >> n >> k;
  vector<int> a(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  int64 ans = 0;
  int64 x = k * 1ll * (k - 1);
  x /= 2;
  x %= mod;
  for (int i = 0; i < n; ++i) {
    int64 val = 0;
    for (int j = i; j < n; ++j) {
      if (a[i] > a[j]) {
        ++val;
      }
    }
    ans += val * k;
    ans %= mod;
    val = 0;
    for (int j = 0; j < n; ++j) {
      if (a[i] > a[j]) {
        ++val;
      }
    }
    ans += x * val;
    ans %= mod;
  }
  cout << ans << '\n';
}

void precalc()
{
}

int main()
{
  ios::sync_with_stdio(0);
  cin.tie(0), cout.tie(0);
  precalc();
  int test = 1;
  //cin >> test;
  //auto start = chrono::high_resolution_clock::now();
  for (int i = 1; i <= test; ++i)
    solve(i);
  //cerr << chrono::duration_cast<chrono::milliseconds>(chrono::high_resolution_clock::now() - start).count() << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define L(i, m, n) for(int i(m);i < n;i++)
#define pb push_back
#define D(X) cout<<"  "<<#X": "<<X<<endl;
#define in(x) cin >> x
#define SZ(X) int(X.size())
#define ff first
#define ss second
#define RF(X) freopen(X, "r", stdin)
#define WF(X) freopen(X, "w", stdout)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef pair<int,int> pii;
typedef vector<pii> vpii;
typedef pair<int, string> pis;
typedef vector<string> vs;
typedef pair<pair<int, int>, pair<int, int > > piiii;
bool isEven(string a){
	if(SZ(a)%2) return 0;
	for(int i=0,j=SZ(a)/2;j<SZ(a);i++,j++)
		if(a[i]!=a[j]) return 0;
	return 1;
	
}

int main(){
	string s;in(s);
	s.pop_back();
	bool ok=0;
	while(!ok){
		if(isEven(s)) ok=1;
		if(!ok)
			s.pop_back();
	}
	cout << SZ(s) <<endl;
	
	
	
	
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
#include<vector>
#include<utility>
#include<queue>

using namespace std;


int main(){

	long long int ans=0;
	int n,k;
	cin>>n>>k;
	long long a[n];
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	sort(a,a+n);
	for(int i=0;i<n-k;i++){
		ans+=a[i];
	}

	cout<<ans;


	cout<<endl;

	return 0;
}


Measured memory_bytes: 1792
A,B,C,D=map(int,input().split())

if C%B==0:
    n=C//B
else:
    n=C//B+1

if A%D==0:
    m=A//D
else:
    m=A//D+1

if n<=m:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 9184
#include <stdio.h>
#include <string.h>
 
char str1[4001], str2[4001];
int len1, len2;
short cache[4000][4000];
 
int MAX(int m, int n){
    return m>n ? m : n;
}
 
int calc_max(int a, int b){
    int res;
    if(a<0 || b<0)
        return 0;
    if(cache[a][b] != -1)
        return cache[a][b];
    if(str1[a] == str2[b]){
        res = calc_max(a-1, b-1) + 1;
    }
    else{
        res = 0;
    }
    cache[a][b] = res;
    return res;
}
 
int main(){
 
  while(scanf("%s%s", str1, str2) != EOF){
    int a, b, num, max=0;
    len1 = strlen(str1);
    len2 = strlen(str2);
    for(a=0; a<len1; a++) for(b=0; b<len2; b++)
        cache[a][b] = -1;
    for(a=0; a<len1; a++) for(b=0; b<len2; b++)
        max = MAX(calc_max(a, b), max);
    printf("%d\n", max);
  }
    return 0;
}

Measured memory_bytes: 30000
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

n,x = na()
a = na()

def gcd(x, y):
    while(x > 0):
        x, y = y % x, x
    return y

g = 0
for v in a:
    g = gcd(g, abs(v-x))
print(g)


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

int main() {
  int H, W;
  cin >> H >> W;
  
  string S = "";
  string S0 = "";
  
  //入力受け取り
  for (int row=0;row<H;row++) {
    string S_in;
    cin >> S_in;
    S += S_in;
    for (int col=0;col<W;col++)
      S0 += "0";
  }
  
  //インクリメント
  for (int i=0;i<H*W;i++) {
    if (S.at(i)=='#') {
      
      if (i%W>0)
        S0.at(i-1) = char(int(S0.at(i-1))+1); //左
      if (i%W<W-1)
        S0.at(i+1) = char(int(S0.at(i+1))+1); //右
      
      if (i>W-1) { //2行目以降
        S0.at(i-W) = char(int(S0.at(i-W))+1); //上
        if (i%W>0)
          S0.at(i-W-1) = char(int(S0.at(i-W-1))+1); //左上
        if (i%W<W-1)
          S0.at(i-W+1) = char(int(S0.at(i-W+1))+1); //右上
      }
      if (i<(H-1)*W) {//最終行以前
        S0.at(i+W) = char(int(S0.at(i+W))+1); //下
        if (i%W>0)
          S0.at(i+W-1) = char(int(S0.at(i+W-1))+1); //左下
        if (i%W<W-1)
          S0.at(i+W+1) = char(int(S0.at(i+W+1))+1); //右下
      }
    }
    
  }

  
  //出力
  for (int i=0;i<H*W;i++) {
    if (S.at(i) == '#'){
      cout << '#';
    }
    else {
      cout << S0.at(i);
    }    
    
    if (i%W == W-1)
      cout << endl;
  }
  
}


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

using namespace std;

#define all(v)				((v).begin()), ((v).end())
#define allr(v)				((v).rbegin()), ((v).rend())
#define sz(v)				((int)((v).size()))
#define ll long long
#define pb					push_back
#define fIO ios_base::sync_with_stdio(0);cin.tie(0);

const ll oo = 1e8;
const double pi = 3.1415926535897;


const double EPS = (1e-7);
int dcmp(double x, double y) {	return fabs(x-y) <= EPS ? 0 : x < y ? -1 : 1;	}


typedef vector<int>                vi;
typedef vector<pair<int,int>>      vii;
typedef vector<ll>                 vll;
typedef vector<double>             vd;
typedef vector< vi >               vvi;
typedef vector< vd >               vvd;
typedef vector<string>             vs;
typedef pair<int, int>             pii;

/**
    * PLEASEEE READDD PROBLEEEM CARFULLY ****
    * Always check for OVERFLOW ll vs int
    * Always check for array bounds
    * Check for function return
    * READ OUTPUT SECTION AGAIN!!!
**/

struct edge{
    int from, to, w;

    edge(){}
    edge(int x, int y, int we): from(x), to(y), w(we){}

    bool operator < (const edge &rhs) const{
        return w > rhs.w;
    }

};

int main(){
    fIO
//    freopen("", "r", stdin);
//    freopen("", "w", stdout);


    ll a;
    string b;

    cin >> a >> b;

    ll tot = 0;
    ll fac = 1;
    int f = 0;
    for(int i = sz(b) - 1; i >= 0; i--) {
        char c = b[i];
        if(c == '.') {
            f = 1;
            continue;
        }
        ll dig = (c - '0');
        tot += a * dig * fac;
        fac *= 10LL;
    }

    cout << tot / 100LL;
}








Measured memory_bytes: 3648
#include "bits/stdc++.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/2
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr<<#x<<": "<<x<<endl
#define debug_vec(v) cerr<<#v<<":";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
//----------------------------------------------------------------

int MOD = 998244353;
// int MOD = 1000000007;

//----------------------------------------------------------------
signed main(){
   
    int n;
	cin >> n;
	cout << n*n << endl;

	return 0;
}

//----------------------------------------------------------------

// g++ -std=c++14 code1.cpp
// sudo pip3 install --upgrade online-judge-tools
// rm -r -f test;oj dl https://code-festival-2018-quala.contest.atcoder.jp/tasks/code_festival_2018_quala_c
// rm -r -f test;oj dl https://nikkei2019-2-qual.contest.atcoder.jp/tasks/nikkei2019_2_qual_b
// rm -r -f test;oj dl https://abc145.contest.atcoder.jp/tasks/abc145_b

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

struct tCell{
	int value;
	tCell* prev;
	tCell* next;
};

class List{
public:
	List() : mQ( 0 ), head( NULL ), tail( NULL ){
		tail = new tCell;
		head = new tCell;
		tail->value = head->value = 0;
		head->prev = tail->next = NULL;
		head->next = tail;
		tail->prev = head;
	}
	~List(){
		for ( int i = mQ; i > 0; --i ){
			tCell* cell = tail->prev;
			tail->prev = cell->prev;
			delete cell;
		}
		if ( !head ) delete head;
		if ( !tail ) delete tail;
	};

	void push( int a ){
		++mQ;
		tCell* cell = new tCell;
		cell->value = a;
		cell->next = tail;
		cell->prev = tail->prev;
		tail->prev->next = cell;
		tail->prev = cell;
	}
	
	bool popStack( int& a ){
		if ( mQ == 0 ) return false;
		--mQ;
		a = tail->prev->value;
		tCell* cell = tail->prev;
		cell->prev->next = cell->next;
		cell->next->prev = cell->prev;
		delete cell;
		return true;
	}
	
	bool popQueue( int& a ){
		if ( mQ == 0 ) return false;
		--mQ;
		a = head->next->value;
		tCell* cell = head->next;
		cell->next->prev = cell->prev;
		cell->prev->next = cell->next;
		delete cell;
		return true;
	}

	int mQ;
	tCell *head, *tail;
private:
};

int main(){
	List list1;
	List list2;
	int a;
	
	while ( cin >> a ){
		list1.push( a );
	}

	while ( list1.popQueue( a ) ){
		if ( a ){
			list2.push( a );
		}else{
			list2.popStack( a );
			cout << a << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 0
n,m = map(int,input().split())

student = []
point = []
dis = 0

for _ in range(n):
    a,b = map(int,input().split())
    student.append((a,b))

for _ in range(m):
    c,d = map(int,input().split())
    point.append((c,d))

for i in range(n):
    ans = []
    for j in range(m):
        ans.append(abs(student[i][0]-point[j][0]) + abs(student[i][1]-point[j][1]))
    idx = ans.index(min(ans))
    print(idx + 1)


Measured memory_bytes: 3064