akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pb push_back
#define fi first
#define se second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mii map<int,int>
#define mll map<ll,ll>
#define all(x) (x).begin(),(x).end()
#define S(x) (int)(x).size()
#define L(x) (int)(x).length()
#define debug(x) cerr << #x << " " << x << endl;
#define debug_p(x) cerr << #x << " [" << x.fi << " " << x.se << "]"<<endl;
#define debug_v(x) {cerr << #x << " "; for (auto ioi : x) cerr << ioi << " "; cerr << endl;}
#define debug_vp(x) {cerr << #x << " "; for (auto ioi : x) cerr << '[' << ioi.fi << " " << ioi.se << ']'; cerr << endl;}
#define debug_v_v(x) {cerr << #x << "/*\n"; for (auto ioi : x) { for (auto ioi2 : ioi) cerr << ioi2 << " "; cerr << '\n';} cerr << "*/" << #x << endl;}
#define gen_clock(x) ll x = clock(); cerr << "Clock " << #x << " created" << endl;
#define check_clock(x) cerr << "Time spent in " << #x << ": " << (double)(clock() - x)/CLOCKS_PER_SEC << endl; x = clock();
#define reset_clock(x) x = clock()
 
const int mod = 1e9+7;
const ll infl = 0x3f3f3f3f3f3f3f3fLL;
const int infi = 0x3f3f3f3f;
 
void solve()
{
	ll n,x,y;
	ll ct=0,m=0;
	cin>>n;
	for(ll i=0;i<n;i++)
	{
		cin>>x>>y;
		if(x==y)
		ct++;
		else
		ct=0;
		m=max(m,ct);
		
	}
	if(m>=3)
	cout<<"Yes"<<endl;
	else
	cout<<"No"<<endl;
    
}
 
int main()
{
	IOS
	int t=1;
	//cin>>t;
	while(t--)
	{
		solve();
	}
}


Measured memory_bytes: 3648
import math

def read():
    a, b, x = list(map(float, input().strip().split()))
    return a, b, x

def solve(a, b, x):
    s = x / a
    h = x / a / a
    if h * 2 <= b:
        rad = math.atan2(b * b, 2 * s)
        deg = math.degrees(rad)
    else:
        rad = math.atan2(2 * (b - h), a)
        deg = math.degrees(rad)
    return deg

if __name__ == '__main__':
    inputs = read()
    print("%.8f" % solve(*inputs))


Measured memory_bytes: 38256
#include<bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
//long long int countt[200003];
#include<ext/pb_ds/assoc_container.hpp> // include the associative containers or group of templates such as set, multimap, map etc.
#include<ext/pb_ds/tree_policy.hpp> // include the tree_order_statistics_node update
using namespace __gnu_pbds; //necessary for the GNU based Policy based data structures.
typedef tree<pair<int,int> ,null_type,less<pair<int,int>>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
 
#define int long long
#define ld long double
#define endl "\n"


signed main()
{
    FAST;
    int t;
    t=1;
    
    while(t--)
    {
        int i=0,j=0,k=0,n=0,m=0,count=0,temp=0;
        int temp1=0,temp2=0,temp3=0,x=0,l=0,y=0,sum=0;
        int left=0,up=0,down=0,start=0,end=0,r=0,q=0,total=0;
        int maxx=0,minn=0,curr=0,ans=0,places=0,zeroes=0,low=0,high=0;
        int prev=0,mid=0,z=0,d=0,val=0,pos=0,shift=0,h=0,right=0,var=0;
        
        cin>>n;
        int a[n+1];
        for(i=1;i<=n;i++)
        {
            cin>>a[i];
            
            if(i%2 && a[i]%2) 
            {
                temp++;
            }
        }
        
        cout<<temp<<endl;
        
       
    }
        
    
    
    
    
}

Measured memory_bytes: 3640
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <map>
#include <string>
#include <vector>
#include <cmath>
#include <random>
#include <climits>
#include <set>
#include <deque>
#include <queue>
#include <bitset>
#include <stack>
#include <regex>

#define mod 1000000007
#define INF2 9999999999
#define INF (1 << 30)
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define P pair<int, int>

using namespace std;
using ll = int64_t;

int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};
int DX[] = {1, 1, 0, -1, -1, -1, 0, 1};
int DY[] = {0, -1, -1, -1, 0, 1, 1, 1};

void solve(){
    int t, x;
    cin >> t >> x;
    cout << t/(double)x << endl;
}

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
struct edge{ll from;ll to;ll cost;};
const ll inf = 100100100100100100;
const ll MAX_V = 1000;
const ll MAX_E = 2000;
ll V,E,D[MAX_V];edge G[MAX_E];
bool BellmanFord(ll s){
    ll i,j;fill(D,D+V,inf);bool update;D[s] = 0;
    for(i=0;i<V;i++){
        update = false;
        for(j=0;j<E;j++){
            if(D[G[j].from] != inf && D[G[j].to] > D[G[j].from]+G[j].cost){
                D[G[j].to] = D[G[j].from]+G[j].cost;
                update = true;
            }
        }
        if(!update) return false;
    }
    return true;
}
int main(){
  ll r,i;scanf("%lld%lld%lld",&V,&E,&r);
  for(i=0;i<E;i++) scanf("%lld%lld%lld",&G[i].from,&G[i].to,&G[i].cost);
  if(BellmanFord(r)){
    printf("NEGATIVE CYCLE\n");return 0;
  }
  for(i=0;i<V;i++){
    if(D[i]==inf) printf("INF\n");
    else printf("%lld\n",D[i]);
  }
  return 0;
}


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

using ll = long long;
#define countof(a) (sizeof(a)/sizeof((a)[0]))
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i < (n); i++)
#define all(a) begin(a),end(a)
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}
template<class T> void cout_v(const vector<T>& c)
{ for (int i = 0; i < c.size(); i++) cout << c[i] << endl; }
template<class T> void cout_h(const vector<T>& c)
{ for (int i = 0; i < c.size(); i++) cout << c[i] << (i==c.size()-1?"\n":" "); }
template<class T> inline bool chmin(T& a, T b) {return a>b?a=b,true:false;}
template<class T> inline bool chmax(T& a, T b) {return a<b?a=b,true:false;}
template<class T> void sort3a(T& a,T& b,T& c) {if (a>b) swap(a,b); if (b>c) swap(b,c); if (a>b) swap(a,b);}
#define SP << " " <<
#define FMT(a) #a<<":"<<a 
#define FMT2(a,b) #a<<":"<<a<<", "<<#b<<":"<<b 
#define FMT3(a,b,c) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c 
#define FMT4(a,b,c,d) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c<<", "<<#d<<":"<<d 

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

    ll Q,H,S,D,N; cin >>Q>>H>>S>>D>>N;

    ll Qx8 = Q*8;
    ll Hx4 = H*4;
    ll Sx2 = S*2;
    // cout << FMT4(Qx8, Hx4, Sx2, D) << endl;
    ll ans = 0;
    if (D<Qx8 && D<Hx4 && D<Sx2) {
        ans = D * (N/2);
        if (N%2) {
            if (Qx8<Hx4 && Qx8<Sx2) {
                ans += Q*4;
            } else if (Hx4<Qx8 && Hx4<Sx2) {
                ans += H*2;
            } else {
                ans += S;
            }
        }
    } else {
        if (Qx8<Hx4 && Qx8<Sx2) {
            ans = Q*4 * N;
        } else if (Hx4<Qx8 && Hx4<Sx2) {
            ans = H*2 * N;
        } else {
            ans = S * N;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <unordered_map>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
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; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}
const ll INF = 1e15;
const ll MOD = 1000000007;
const ll MOD2 = 998244353;
typedef pair<ll,ll> P;
typedef pair<double,double> point;
const ll MAX = 500005;
constexpr ll nx[8] = {1,0,-1,0,1,-1,1,-1};
constexpr ll ny[8] = {0,1,0,-1,1,1,-1,-1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll D,C = 26;
    cin >> D;
    vector<ll> c(C);
    vector<vector<ll>> s(D,vector<ll>(C));
    cins(all(c));
    rep(i,D){
        rep(j,C){
            cin >> s[i][j];
        }
    }
    vector<ll> t(D,-1);
    rep(i,D){
        ll k = -1,ind = -1;
        rep(j,C){
            if (chmax(k,s[i][j])) ind = j;
        }
        t[i] = ind+1;
    }
    rep(i,D){
        PRINT(t[i]);
    }
}


Measured memory_bytes: 3752
/*
    Author : Nishant Gupta 2.0
*/
#include<bits/stdc++.h>
using namespace std;

#define LL long long int
#define getcx getchar_unlocked
#define X first
#define Y second
#define PB push_back
#define MP make_pair
#define MAX 100005
#define LOG_MAX 20
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL (LL(1e18))
#define chk(a) cerr << endl << #a << " : " << a << endl
#define chk2(a,b) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << endl
#define chk3(a,b,c) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << "\t" << #c << " : " << c << endl
#define chk4(a,b,c,d) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << "\t" << #c << " : " << c << "\t" << #d << " : " << d << endl
#define rep(i, a, n) for(i=a;i<n;i++)
#define rev(i, a, n) for(i=a;i>=n;i--)
#define in(x) scanf("%d", &x)
#define inl(x) scanf("%lld", &x)
#define in2(x, y) scanf("%d %d", &x, &y)
#define inl2(x, y) scanf("%lld %lld", &x, &y)
#define MSV(A,a) memset(A, a, sizeof(A))
#define rep_itr(itr, c) for(itr = (c).begin(); itr != (c).end(); itr++)
#define finish(x) {cout<<x<<'\n'; return;}
typedef pair<int, int> pi;
typedef pair<LL, LL> pl;
const char en = '\n';

void solve() {
	int x, n;
  cin>>x>>n;
  int sum = 0, s;
  for(int i=0;i<n;i++) {cin>>s;sum+=s;}
  if(sum >= x) cout<<"Yes"<<en;
  else cout<<"No"<<en;
}

int main() {
	int t = 1;
	
	//cin>>t;
	while(t--) {
		solve();
	}
    return 0;
}


Measured memory_bytes: 3640
#include "bits/stdc++.h"
using namespace std;
int main()
{
	int n, ind = 0;
	double ave = 0, diff = 1000000000;
	scanf("%d", &n);
	vector<double> a(n);
	for(int i = 0; i < n; ++i)
	{
		scanf("%lf", &a[i]);
		ave += a[i];
	}
	ave /= n;
	for(int i = 0; i < n; ++i)
	{
		if(diff > abs(ave - a[i]))
		{
			ind = i;
			diff = abs(ave - a[i]);
		}
	}
	printf("%d\n", ind);
}

Measured memory_bytes: 256
# import numpy as np
import fractions

A, B, C, D = map(int, input().split())

def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)

def undivided_under(N, C, D):
    dived_C = N // C
    dived_D = N // D
    dived_lcm = N // lcm(C, D)

    # print(dived_C, dived_D, dived_lcm)

    return(N - dived_C - dived_D + dived_lcm)

# print(A,B,C,D)
# print(undivided_under( B, C, D ))
# print(undivided_under( A-1, C, D ))

print( int( undivided_under(B, C, D) - undivided_under(A-1, C, D)) )


Measured memory_bytes: 5048
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cassert>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
using namespace std;


typedef long long i64;
const int inf = (int)1.05e9;

const i64 mod = 998244353;

i64 mof(i64 x)
{
	if(x < mod * 2) {
		return (x >= mod) ? x - mod : x;
	}
	return x % mod;
}

int main()
{
	int n, x;

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

	vector<vector<i64>> waf(n + 1);
	for(auto& w : waf) {
		w.resize(2 * n + 1, 0);
	}

	waf[0][0] = 1;

	for(int i = 1; i <= n; i++) {

		waf[i][1] = waf[i - 1][0];

		for(int j = 2; j <= 2 * n; j++) {
			waf[i][j] = mof(waf[i - 1][j - 1] + waf[i - 1][j - 2]);
		}
	}

	vector<vector<i64>> choose(n + 1);
	for(auto& c : choose) {
		c.resize(n + 1, 0);
	}

	for(int i = 0; i <= n; i++) {
		choose[i][0] = 1;
	}

	for(int i = 1; i <= n; i++) {
		for(int j = 1; j <= n; j++) {
			if(i < j) {
				choose[i][j] = 0;
			} else {
				choose[i][j] = mof(choose[i - 1][j] + choose[i - 1][j - 1]);
			}
			// printf("%d C %d = %lld\n", i, j, choose[i][j]);
		}
	}

	i64 ans = 1;

	for(int i = 0; i < x; i++) {
		i64 s = 0;
		for(int m = 1; m <= n; m++) {
			s = mof(s + waf[m][i] * choose[n][m]);
		}
		ans = mof(ans + s);
		// printf("waf %d -> %lld\n", i, s);
	}

	for(int len = x + 1; len <= 2 * n; len++) {

		if((len - x) % 2 == 0) {
			continue;
		}

		int k = len - x;

		if(x - 1 <= k + 1) {

			if(len % 2 == 1) {
				continue;
			}
			ans = mof(ans + choose[n][len / 2]);
			continue;
		}

		int rem = (x - 1) - (k + 1);
		int right = (k + 1) / 2;

		i64 s = 0;
		for(int m = 1; m + 2 * right <= n; m++) {
			s = mof(s + waf[m][rem] * choose[n][n - m - (right * 2)]);
		}
		ans = mof(ans + s);

		//printf("%d -> %lld\n", len, s);
	}

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

	return 0;
}

/* waffle */


Measured memory_bytes: 211456
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <string>
using namespace std;

int main() {
	int n;
	cin >> n;
	string str;
	cin >> str;
	
	string ans = str;
	int l = 0, r = 0;
	for(int i = 0; i < n; i++){
		if(str[i] == '('){
			l++;
		}
		else{
			if(l == 0){
				ans = "(" + ans;
			}
			else{
				l--;
			}
		}
	}
	if(l > 0){
		string rs("");
		for(int i = 0; i < l; i++)
			rs += ")";
		ans += rs;
	}
	cout << ans << endl;
	return 0;
}

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


int main() {
  int K, A, B;
  cin >> K;
  cin >> A >> B;
  bool ans = false;
  for (int i = A; i <= B; i++){
    if (i % K == 0) {
      ans = true;
      break;
    }
  }
  if (ans) {
    cout << "OK" << endl;
  } else {
    cout << "NG" << endl;
  }
  return 0;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define vi vector<ll>
#define vvi vector<vi>
#define BITLE(n) (1LL<<((ll)n))
#define SUBS(s,f,t) ((s).substr((f),(t)-(f)))
#define ALL(a) (a).begin(),(a).end()
#define Max(a) (*max_element(ALL(a)))
#define Min(a) (*min_element(ALL(a)))
using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll x,n;cin>>x>>n;
  vi A(111);
  for(int i=0;i<n;i++){
    ll a;cin>>a;
    A[a]++;
  }
  ll ans = -1;
  ll sa = llINF;
  for(ll i=0;i<=111;i++){
    if(A[i])continue;
    if(sa > abs(i-x)){
      sa = abs(i-x);
      ans = i;
    }else if(sa == abs(i-x)){
      ans = min(ans,i);
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3652
import java.util.Scanner;



public class Main {


	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		String s = sc.next();
		
		boolean[] one = new boolean[10];
		boolean[] two = new boolean[100];
		boolean[] three = new boolean[1000];
		for (int i=0;i<n;i++) {
			int digit = s.charAt(i)-'0';
			for (int j=0;j<100;j++) {
				if (two[j]) {
					three[j*10+digit]=true;
				}
			}
			for (int j=0;j<10;j++) {
				if (one[j]) {
					two[j*10+digit]=true;
				}
			}
			one[digit]=true;
		}
		
		int ans = 0;
		for (int i=0;i<1000;i++) {
			
			if (three[i]) {
				ans++;
			}
		}
		System.out.println(ans);
	
	}
}





Measured memory_bytes: 23892
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define MAXX 100005
#define PI 3.14159265358979323846264338327950
#define ll signed long long int
using namespace std;
ll t , n, k,   y = 2, m, ans = 0,h,s ;
double a[MAXX], b[MAXX], c[MAXX];
double f = 0, x;
vector<ll> adj[MAXX];
bool used[MAXX];
ll d[MAXX];
ll p[MAXX];
queue<ll> q;

signed main()
{
	FAST;
	cin >> n;
	for(ll i = 0; i < n; i++){
		cin >> x;
		x = 1/x;
		f += x;
	}
	f= 1/f;
	cout << fixed << setprecision(14) <<  f;
}

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

template <typename T>
ostream& operator<<(ostream& os, vector<T>& vec) {
    os << "{";
    for (int i = 0; i < (int)vec.size(); ++i) {
        os << vec[i] << (i + 1 == (int)vec.size() ? "" : ", ");
    }
    os << "}";
    return os;
}
template <typename T, typename U>
ostream& operator<<(ostream& os, pair<T, U>& pair_var) {
    os << "(" << pair_var.first << ", " << pair_var.second << ")";
    return os;
}
template <typename T, typename U>
ostream& operator<<(ostream& os, map<T, U>& map_var) {
    os << "{";
    for (auto itr = map_var.begin(); itr != map_var.end(); itr++) {
        os << "(" << itr->first << ", " << itr->second << ")";
        itr++;
        if (itr != map_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, set<T>& set_var) {
    os << "{";
    for (auto itr = set_var.begin(); itr != set_var.end(); itr++) {
        os << *itr;
        ++itr;
        if (itr != set_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
void dump_func() {
    cerr << "\n";
}
template <class Head, class... Tail>
void dump_func(Head&& head, Tail&&... tail) {
    cerr << head;
    if (sizeof...(Tail) == 0) {
        cerr << " ";
    } else {
        cerr << ", ";
    }
    dump_func(std::move(tail)...);
}
#define dump(...) cerr << "[" << to_string(__LINE__) << "]"        \
                       << "    " << string(#__VA_ARGS__) << " = ", \
                  dump_func(__VA_ARGS__)

using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<double>;
using VVI = vector<VI>;
using VVL = vector<VL>;
using PI = pair<int, int>;
using PL = pair<ll, ll>;
using VPI = vector<PI>;
using VPL = vector<PL>;
using VS = vector<string>;

#define ln '\n'
#define REP(t, n) for (int t = 0; t < (n); ++t)
#define FOR(t, a, b) for (int t = (a); t <= (b); ++t)
#define FORR(t, a, b) for (int t = (a); t >= (b); --t)
#define ALL(c) (c).begin(), (c).end()
#define CAUTO const auto&

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

    int l, r;
    cin >> l >> r;
    VI moded;
    if (r - l <= 2018) {
        FOR(i, l % 2019, l % 2019 + r - l) {
            moded.emplace_back(i);
        }
    } else {
        cout << 0 << ln;
        return 0;
    }
    dump(moded);
    int ans = 3000;
    FOR(i, 0, (int)moded.size() - 2) {
        FOR(j, i + 1, (int)moded.size() - 1) {
            int temp = (moded[i] * moded[j]) % 2019;
            if (ans > temp) ans = temp;
        }
    }
    cout << ans << ln;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
const ll LINF=0x1fffffffffffffff;
const int INF=0x3fffffff;
const int MOD=1000000007;
#define VAR(type,...) type __VA_ARGS__;in(__VA_ARGS__)
#define VEC(type,name,size) vector<type> name(size);each(x, name)in(x)
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define rrep(i,a,b) for(ll i=(a-1);i>=(b);--i)
#define each(x,v) for(auto &x:(v))
#define all(x) (x).begin(),(x).end()
#define print(x) cout<<(x)<<endl
void in(){} template<class T,class... U> void in(T &t,U &...u){cin>>t;in(u...);}
void solve();
int main(){cin.tie(0);ios::sync_with_stdio(0);solve();}

void solve() {
  VAR(int, N);
  VEC(int, a, N);
  int mn = *min_element(all(a));
  int mx = *max_element(all(a));
  int ans = INF;
  rep(i, mn, mx + 1) {
    int cc = 0;
    each(x, a) {
      cc += (x - i) * (x - i);
    }
    ans = min(ans, cc);
  }
  print(ans);
}


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

#define loop(n) for(int i = 0;i < (int)(n);++i)
#define rep(i,n) for(int i = 0;i < (int)(n);++i)
#define all(vec) (vec).begin(),(vec).end()
#define Sort(vec) sort(all(vec))
#define Rev(vec) reverse(all(vec))

namespace Input
{
                
    void input(){return;}
    template<typename First,typename... Rest> void input(First &first,Rest&... rest){
    std::cin >> first;
    input(rest...);
}
    
    void inputVec(){return;}
    template<typename First,typename... Rest> void inputVec(vector<First> &first,Rest&... rest){
        int N = first.size();
        for(int i = 0;i < N;i++){
            cin >> first[i];
        }
        inputVec(rest...);
    }
    
    template<typename First,typename Second> void inputTwoVec(vector<First> &first,vector<Second>& second){
        int N = first.size();
        for(int i = 0;i < N;i++){
            cin >> first[i] >> second[i];
        }
    }

}

void calculate(){
    string s;
    Input::input(s);
    int al[26] = {0};
    rep(i,s.size()){
        al[s[i] - 'a']++;
    }
    rep(i,26){
        if(al[i] == 0){
            char a = i + 'a';
            cout << a << '\n';
            return;
        }
    }
    cout << "None\n";
}

int main(int,char**){
    calculate();    
}




Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int MOD = 1e9 + 7;
const int INF = 2e9;
#define pb push_back
#define mp make_pair
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 (a>b) { a=b; return 1; } return 0; }

int main(){
    string s, t;
    cin >> s >> t;
    if(s.length() < t.length()){
        bool g = true;
        for (int i = 0; i < s.length(); i++){
            if(s[i]=='?'){
                g = false;
            }
        }
        if(!g){
            cout << "UNRESTORABLE" << endl;
        }
        else{
            cout << s << endl;
        }
        return 0;
    }
    vector<string> ans;
    int cnt = 0;
    for (int i = 0; i <= s.length() - t.length(); i++){
        bool f = true;
        for (int j = 0; j<t.length(); j++){
            if(s[i+j]!='?' && s[i+j]!=t[j]){
                f = false;
            }
        }
        if(f){
            string tmp = s;
            for (int j = 0; j < t.length(); j++){
                tmp[i + j] = t[j];
            }
            for(int j=0; j<tmp.length(); j++){
                if(tmp[j]=='?'){
                    tmp[j] = 'a';
                }
            }
            ans.pb(tmp);
            cnt++;
        }
    }
    if(cnt==0){
        cout << "UNRESTORABLE" << endl;
    }
    else{
        string mi = ans[0];
        for(auto v : ans){
            if(v.compare(mi)<0){
                mi = v;
            }
        }
        cout << mi << endl;
    }
}

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

bool solve() {
    ll A, V, B, W, T;
    cin >> A >> V >> B >> W >> T;
    if ( W >= V )
    if ( abs(A-B) <= (V-W)*T ) return true;
    else return false;
}

int main() {
    string ans = solve() ? "YES" : "NO";
    cout << ans << "\n";
    return 0;
}

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

int n,v[1000000],freq[2000000],val,pre[1000000];

long long dp[1000000],mod=1e9+7ll,sum,ans;
vector<pair<long long,int> > num[2000000];
vector<int> us;

long long fastp(long long base,int exp){
    
    if(exp==0)return 1ll;
    
    long long tmp2=fastp(base,exp/2);
    
    tmp2=(tmp2*tmp2)%mod;
    
    if(exp%2==1)tmp2*=base;
    
    return tmp2%mod;
}

int main(){

	cin>>n;
	
	for(int i=0;i<n;i++){
	    
	    cin>>v[i];
	    val^=v[i];
	    
	    if(val==0){
	        pre[i]=1;
        }
        if(i!=0)pre[i]+=pre[i-1];
        
        
        if(val!=0){
            freq[val]++;
            if(freq[val]==1)us.push_back(val);
        }
        
        if(val==0){
            
            for(int j=0;j<us.size();j++){
                num[us[j]].push_back({freq[us[j]],i-1});
                freq[us[j]]=0;
            }
            us.clear();
            
        }
	    //cout<<val<<" ";
    }
    //cout<<endl;
    
    if(val==0){
        
        ans=fastp(2,pre[n-1]-1);
        //cout<<ans<<endl;
        
        for(int h=1;h<2000000;h++){
            
            val=h;
            
            if(num[h].size()>0){
                
                for(int i=0;i<num[h].size();i++)dp[i]=0;
                sum=1;
                
                if(num[val].size()==1){
                    ans+=num[val][0].first;
                    continue;
                }
                
                
                dp[num[val].size()-1]=num[val][num[val].size()-1].first;
                sum+=num[val][num[val].size()-1].first*(pre[num[val][num[val].size()-1].second]-pre[num[val][num[val].size()-2].second]);
                sum%=mod;
                
                for(int i=num[val].size()-2;i>=0;i--){
                    dp[i]=(dp[i+1]+(num[val][i].first*sum)%mod)%mod;
                    
                    if(i>0){
                        sum+=((pre[num[val][i].second]-pre[num[val][i-1].second])%mod*dp[i])%mod;
                        sum%=mod;
                    }
                }
                
                ans+=dp[0];
                ans%=mod;
                //cout<<ans<<" "<<h<<endl;
            }
            
            
        }
        
        cout<<ans<<endl;
        
    }
    else{
        
        
        for(int j=0;j<us.size();j++){
            num[us[j]].push_back({freq[us[j]],n-1});
            freq[us[j]]=0;
        }
        us.clear();
        
        if(num[val].size()==1){
            cout<<"1"<<endl;
            return 0;
        }
        
        
        dp[num[val].size()-1]=1;
        sum=pre[num[val][num[val].size()-1].second]-pre[num[val][num[val].size()-2].second];
        sum%=mod;
        
        for(int i=num[val].size()-2;i>=0;i--){
            dp[i]=(dp[i+1]+(num[val][i].first*sum)%mod)%mod;
            
            if(i>0){
                sum+=((pre[num[val][i].second]-pre[num[val][i-1].second])%mod*dp[i])%mod;
                sum%=mod;
            }
        }
        
        cout<<dp[0]<<endl;
    }

return 0;
}


Measured memory_bytes: 71424
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> l_l;
const int INF=1001001000;
const int mINF=-1001001000;
const int mod = 1000000007;
struct mint {
ll x;
mint(ll x=0):x((x%mod+mod)%mod){}
mint operator-() const { return mint(-x);}
mint& operator+=(const mint a) {
if ((x += a.x) >= mod) x -= mod;
return *this;
}
mint& operator-=(const mint a) {
if ((x += mod-a.x) >= mod) x -= mod;
return *this;
}
mint& operator*=(const mint a) {
(x *= a.x) %= mod;
return *this;
}
mint operator+(const mint a) const {
mint res(*this);
return res+=a;
}
mint operator-(const mint a) const {
mint res(*this);
return res-=a;
}
mint operator*(const mint a) const {
mint res(*this);
return res*=a;
}
mint pow(ll t) const {
if (!t) return 1;
mint a = pow(t>>1);
a *= a;
if (t&1) a *= *this;
return a;
}
mint inv() const {
return pow(mod-2);
}
mint& operator/=(const mint a) {
return (*this) *= a.inv();
}
mint operator/(const mint a) const {
mint res(*this);
return res/=a;
}
};
struct combination {
vector<mint> fact, ifact;
combination(int n):fact(n+1),ifact(n+1) {
assert(n < mod);
fact[0] = 1;
for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
ifact[n] = fact[n].inv();
for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
}
mint operator()(int n, int k) {
if (k < 0 || k > n) return 0;
return fact[n]*ifact[k]*ifact[n-k];
}
} comb(200005);
int main(){
    int n,k;cin >> n >> k;
    vector<int> a(n);
    for(int i=0; i<n; i++) cin >> a[i];
    mint ans=0;
    sort(a.begin(),a.end());
    for(int ri=0; ri<2; ri++){
        for(int i=0; i<n; i++){
            mint now=comb(i,k-1);
            if(ri==1) now=-now;
            ans+=now*a[i];
        }
        reverse(a.begin(),a.end());
    }
    cout << ans.x << endl;
    return 0;
}

Measured memory_bytes: 3712
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll mod=1e9+7;
char grid[1002][1002];
int main(int argc, char const *argv[])
{
    ll h,w;
    cin>>h>>w;
    memset(grid,'#',sizeof(grid));
    for(ll i=1;i<=h;i++)
    {
        for(ll j=1;j<=w;j++)
            cin>>grid[i][j];
    }
    ll dp[h+1][w+1]={0};
    dp[1][1]=1;
    for(ll i=1;i<=h;i++)
    {
        for(ll j=1;j<=w;j++)
        {
            if((i!=1 || j!=1) && grid[i][j]=='.'){
                if(grid[i-1][j]=='.' && grid[i][j-1]=='.')
                {
                    dp[i][j]=(dp[i-1][j]+dp[i][j])%mod;
                    dp[i][j]=(dp[i][j-1]+dp[i][j])%mod;
                }
                else if( grid[i-1][j]=='.')
                {
                    dp[i][j]=dp[i-1][j];
                }
                else if( grid[i][j-1]=='.')
                {
                    dp[i][j]=dp[i][j-1];
                }
            }
        }
    }
    cout<<dp[h][w];
    return 0;
}

Measured memory_bytes: 9088
#include <iostream>
#include <iomanip>
#include <vector>
#include <valarray>
#include <map>
#include <set>
#include <list>
#include <queue>
#include <stack>
#include <bitset>
#include <utility>
#include <numeric>
#include <algorithm>
#include <functional>
#include <complex>
#include <string>
#include <sstream>

#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cmath>

using namespace std;

#define all(c) c.begin(),c.end()
#define repeat(i,n) for(int i=0;i<static_cast<int>(n);i++)
#define debug(x) #x << "=" << (x)
#define dump(x) cerr << debug(x) << " (L:" << __LINE__ << ")"<< endl

typedef long long ll;
typedef vector<int> vi;

template<typename T>
ostream& operator<<(ostream& os, const vector<T>& vec){
    os << "[";
    for(int i = 0; i < vec.size(); i++){
        os << vec[i] << ",";
    }
    os << "]";
    return os;
}

template<typename T>
T input(){
    T t;
    cin >> t;
    return t;
}

template<typename T>
vector<T> input(const int N){
    vector<T> v(N);
    repeat(i,N) cin >> v[i];
    return v;
}

long long gcd(long long a, long long b){
    if(b == 0){
        return a;
    }
    return gcd(b, a % b);
}

long long lcm(long long a, long long b){
    return (a / gcd(a, b)) * b;
}

void printField(vector<string>& field) {
    repeat(i,field.size()) {
        cout << field[i] << endl;
    }
}

int main(){
    int H, W;
    cin >> H >> W;
    vector<string> field(H);
    vector<string> answer(H);
    repeat(i,H) {
        cin >> field[i];
    }
    answer = field;
    repeat(i,H) {
        repeat(j,W) {
            char position = field[i][j];
            if (position == '#') {
                continue;
            }
            int count = 0;
            for (int k = i - 1; k <= i + 1; ++k) {
                for (int l = j - 1; l <= j + 1; ++l) {
                    if (k < 0 || H <= k) {
                        continue;
                    }
                    if (l < 0 || W <= l) {
                        continue;
                    }
                    if (field[k][l] == '#') {
                        count++;
                    }
                }
            }
            answer[i][j] = '0' + count;
        }
    }
    printField(answer);
    return 0;
}

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

#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(a)  (a).begin(),(a).end()

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

typedef long long ll;



int main() {
    int N;
    cin >> N;
    string S;
    cin >> S;
    if (N%2!=0) {
        cout << "No" << endl;
        exit(0);
    }
    string mae = S.substr(0,N/2);
    string ushiro = S.substr(N/2,N/2);
    //cout << mae << endl;
    //cout << ushiro << endl;
    if (mae!=ushiro) {
        cout << "No" << endl;
        exit(0);
    }
    cout << "Yes" << endl;

    return 0;
}


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

using namespace std;

#define int long long

const int mod = 1e9 + 7, N = 2e6 + 1;
int x, y, f[N], inv[N];

int binpow(int a, int b){
	int res = 1;
	while(b){
		if(b & 1) (res *= a) %= mod, --b;
		else (a *= a) %= mod, b >>= 1;
	}
	return res;
}

int inverse(int x){
	return binpow(x, mod - 2);
}

void preset(){
	f[0] = 1, inv[0] = 1;
	for(int i = 1; i < N; ++i) f[i] = (f[i - 1] * i) % mod, inv[i] = inverse(f[i]);
}

signed main(){
	int res = 0;
	cin >> x >> y;
	preset();
	if(x > y) swap(x, y);
	int tx = x, ty = y, cnt = 0;
	while(tx > 0 && ty > 0 && tx != ty) --tx, ty -= 2, ++cnt;
	
	if(tx % 3 == 0 && ty % 3 == 0 && tx == ty){
		int n = 2 * tx / 3 + cnt;
		res = ((f[n] * inv[tx / 3]) % mod) * inv[tx / 3 + cnt] % mod;
	}
	
	cout << res;
}

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

#define MAX 10001

void countingSort(int a[], int n)
{
    int c[MAX];
    for (int i = 0; i < MAX; i++)
        c[i] = 0;

    for (int i = 0; i < n; i++)
        c[a[i]]++;

    for (int i = 1; i < MAX; i++)
        c[i] = c[i] + c[i - 1];

    int b[n];
    for (int i = n - 1; i >= 0; i--)
    {
        b[c[a[i]] - 1] = a[i];
        c[a[i]]--;
    }

    for (int i = 0; i < n; i++)
        a[i] = b[i];
}

int main()
{
    int n;
    cin >> n;
    int a[n];
    for (int i = 0; i < n; i++)
        cin >> a[i];
    countingSort(a, n);
    for (int i = 0; i < n; i++)
    {
        cout << a[i];
        if (i != n - 1)
            cout << ' ';
    }
    cout << endl;
}


Measured memory_bytes: 18732
package main

import (
  "fmt"
)
 
func main() {
  var n int
  var s, p string
  fmt.Scan(&n, &s)
  p = s[0:(n/2)]
  if s == p + p {
    fmt.Println("Yes")
  } else {
    fmt.Println("No")
  }
}

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

int main() {
  string S;
  cin >> S;
  string ans="No";
  for (int i=0; i<3; i++) {
    if (S.at(i) == '7') {
      ans = "Yes";
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3632
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.IO;

namespace Contest
{
    class Scanner
    {
        private string[] line = new string[0];
        private int index = 0;

        public string Next()
        {
            if (line.Length <= index)
            {
                line = Console.ReadLine().Split(' ');
                index = 0;
            }

            var res = line[index];
            index++;
            return res;
        }

        public int NextInt()
        {
            return int.Parse(Next());
        }

        public long NextLong()
        {
            return long.Parse(Next());
        }

        public string[] Array()
        {
            line = Console.ReadLine().Split(' ');
            index = line.Length;
            return line;
        }

        public int[] IntArray(int n)
        {
            var array = Array();
            var result = new int[n];
            for (int i = 0; i < n; i++)
            {
                result[i] = int.Parse(array[i]);
            }

            return result;
        }

        public int[] IntArray()
        {
            var array = Array();
            var result = new int[array.Length];
            for (int i = 0; i < array.Length; i++)
            {
                result[i] = int.Parse(array[i]);
            }

            return result;
        }


        public long[] LongArray()
        {
            var array = Array();
            var result = new long[array.Length];
            for (int i = 0; i < array.Length; i++)
            {
                result[i] = long.Parse(array[i]);
            }

            return result;
        }

        public uint NextUint()
        {
            return uint.Parse(Next());
        }
    }

    class Program
    {
        private int[] A;
        private void Scan()
        {
            var sc = new Scanner();
            A = sc.IntArray();
        }
        public void Solve()
        {
            Scan();
            int ans = int.MaxValue;
            for (int i = 0; i < 3; i++)
            {
                for (int j = 0; j < 3; j++)
                {
                    if (i == j) continue;
                    for (int k = 0; k < 3; k++)
                    {
                        if (i == k || j == k) continue;
                        int result = Math.Abs(A[j] - A[i]) + Math.Abs(A[k] - A[j]);
                        ans = Math.Min(ans, result);
                    }
                }
            }
            Console.WriteLine(ans);
        }

        static void Main() => new Program().Solve();
    }
}

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

namespace AtCoder_1
{
    class Program
    {
        static void Main(string[] args)
        {
            var a = CinTAr();
            int d = a[0] * a[1];
            Cout((d < a[2]) ? d : a[2]);
            Cin();
        }


        static string Cin() { return Console.ReadLine(); }
        static string[] CinAr() { return Console.ReadLine().Split(' '); }
        static int CinT() { return S2i(Cin()); }
        static int[] CinTAr() { return CinAr().Select((x, i) => { return S2i(x); }).ToArray(); }
        static long CinL() { return S2L(Cin()); }
        static long[] CinLAr() { return CinAr().Select((x, i) => { return S2L(x); }).ToArray(); }
        static double CinD() { return S2D(Cin()); }
        static double[] CinDAr() { return CinAr().Select((x, i) => { return S2D(x); }).ToArray(); }
        static int S2i(string s) { return int.Parse(s); }
        static long S2L(string s) { return long.Parse(s); }
        static double S2D(string s) { return double.Parse(s); }
        static void Cout(object s) { Console.WriteLine(s); }
        static void DbShowE<Type>(IEnumerable<Type> types)
        {
            foreach(var i in types)
            {
                Console.Write(i + " ");
            }
            Console.WriteLine();
        }
    }
}


Measured memory_bytes: 13268
Q = int(input())

N=10**5
def primes(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    return [i for i in range(n + 1) if is_prime[i]]

F = primes(N)
F_2007=[]

a = [0]*(N+1)

for f in F:
    a[f] = 1

for f in F:
    if a[(f+1)//2] == 1:
        F_2007.append(f)
        
a = [0]*(N+1)
for f in F_2007:
    a[f] = 1
    
a_sum = [0]
for a_ in a:
    a_sum.append(a_sum[-1]+a_)
a_sum=a_sum[1:]

for q in range(Q):
    l,r = list(map(int,input().split()))
    print(a_sum[r] - a_sum[l-1])

Measured memory_bytes: 83448
#include<iostream>
using namespace std;
int main()
{
	long long int n,a,b,c;
	cin>>a>>b>>c;
	if(a==5&&b==5&&c==7)
	{
		cout<<"YES"<<endl;
		return 0;
	}
	if(a==5&&b==7&&c==5)
	{
		cout<<"YES"<<endl;
		return 0;
	}
	if(a==7&&b==5&&c==5)
	{
		cout<<"YES"<<endl;
		return 0;
	}
	cout<<"NO"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--) // [a, b)
#define reprev(i,n) reprrev(i,0,n)

                    
using ll = long long;
using ull = unsigned long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const ll mod = 1e9+7;
void chmod(ll &M){
  if(M >= mod) M %= mod;
  else if(M < 0){
     M += (abs(M)/mod + 1)*mod;
    M %= mod;
}
}
ll modpow(ll x, ll n){
   if(n==0) return 1;
  ll res=modpow(x, n/2);
 if(n%2==0) return res*res%mod;
else return res*res%mod*x%mod;
}
int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };
long long GCD(long long a, long long b) {
  if (b == 0) return a;
  else return GCD(b, a % b);
}

using namespace std;
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
int main()
{
    string S;
    cin >> S;
    bool check = false;
    for (int i = 0; i < 3; i++) {
        if (S[i] == '7') {
            check = true;
            break;
        }
    }
    if (check) cout << "Yes" << endl;
    else cout << "No" << endl;
}



Measured memory_bytes: 3596
import sys
from functools import lru_cache

sys.setrecursionlimit(10 ** 7)

n = int(input())
h = list(map(int, input().split()))

@lru_cache(maxsize=None)
def f(n):
    if n == 0:
        return 0
    elif n == 1:
        return abs(h[1] - h[0])
    return min(f(n-2) + abs(h[n] - h[n-2]), f(n-1) + abs(h[n] - h[n-1]))

print(f(n-1))

Measured memory_bytes: 136452
n, m = gets.chomp.split.map(&:to_i)
sc = []

m.times do |i|
  sc << gets.chomp.split.map(&:to_i)
end

1000.times do |i|
  # 桁数チェックのための型変換と桁数チェック
  ans = i.to_s
  next if ans.length != n

  check = true
  #指定された桁の値の確認
  #“最小のもの”という条件は、0から1000に向かうループで、一番初めに条件を満たした数を出力することで満たせる
  sc.each do |num|
    check = false if ans[num[0]-1] != num[1].to_s
  end
  if check
    puts ans
    exit
  end
end

puts "-1"

Measured memory_bytes: 1788
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>; 
using pll = pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1001001001LL;
constexpr long long LINF = 1001001001001001001;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define rept(i, j, n) for(int i=(j); i<(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


int main(){
   int n; cin >> n;
   vector<ll> A(n); rep(i, n) cin >> A[i];

   vector<string> memo(n, "none");
   bool isup = false;
   rep(i, n-1){
       if(A[i] < A[i+1] && isup == false){//底
         memo[i] = "buy";
         isup = true;
       }
       if(A[i] > A[i+1] && isup == true){//頂点
        memo[i] = "sell";
        isup = false;
       }
   }
   if(isup)memo[n-1] = "sell";
   
   //rep(i, n)cout << memo[i] << " ";
   //cout << ln;

   ll money  = 1000, kabu = 0;
   rep(i, n){
       if(memo[i]=="buy"){
           ll num = money / A[i];
           kabu += num;
           money -= num * A[i];
       }
       if(memo[i] == "sell"){
           ll num = kabu * A[i];
           money += num;
           kabu = 0;
       }
       //cout << "money:" << money << " ";
   }
   //cout << ln;
   cout << money << ln;
}
    


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

int main()
{
	int n, a[50];
	cin >> n;
	a[0] = a[1] = 1;
	for(int i = 2; i <= n; i++)
		a[i] = a[i-1] + a[i-2];
	cout << a[n] << endl;
}



Measured memory_bytes: 3096
import java.util.Scanner;

class Card{
    public String suit;
    public int value;
    public int index;
}

public class Main{
    public static void main(String[] args){
	int i, q;
	
	Scanner s = new Scanner(System.in);
	int n = s.nextInt();
    	Card[] A = new Card[n];

	for(i=0; i<n; i++){
	    A[i] = new Card();
	}

	for(i=0; i<n; i++){
	    A[i].suit = s.next();
	    A[i].value = s.nextInt();
	    A[i].index = i; 
	}

	quickSort(A, 0, n-1);

	if(isStable(A) == true){
	    System.out.print("Stable\n");
	}else{
	    System.out.print("Not stable\n");
	}
	for(i=0; i<n; i++){
	    System.out.printf("%s %d\n", A[i].suit, A[i].value);
	    
	}
    }

    public static void quickSort(Card[] A, int p, int r){
	int q;
	if(p < r){
	    q = partition(A, p, r);
	    quickSort(A, p, q - 1);
	    quickSort(A, q + 1, r); 
	}
    }
    
    public static int partition(Card[] A, int p, int r){
	int x, i, j;
	Card tmp;
	x = A[r].value;
	i = p-1;
	for(j=p; j<r; j++){
	    if(A[j].value<=x){
		i++;
		tmp = A[i]; A[i] = A[j]; A[j] = tmp;
	    }
	}
	tmp = A[i+1]; A[i+1] = A[r]; A[r] = tmp;
	return i+1;
    }
    
    static boolean isStable(Card[] A){
	for(int i = 0; i < A.length; i++){
	    for(int j = i + 1; j < A.length; j++){
		if(A[i].value == A[j].value && A[i].index > A[j].index)
		    return false;
	    }
	}
    return true;
    }	    
}

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

typedef long long ll;
typedef unsigned long long ull;

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

  for (ll i = 1; i <= 9; ++i) {
    for (ll j = 1; j <= 9; ++j) {
      if (i*j == n) {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }

  cout << "No" << endl;
  
  return 0;
}

Measured memory_bytes: 256
n,m = map(int,input().split())
x = list(map(int,input().split()))

x.sort()
dx = [x[i]-x[i-1]-1 for i in range(1,m) if x[i]-x[i-1]-1>0]
dx.sort(reverse=True)

a = 0
if n-1 <= len(dx):
    for i in range(n-1):
        a += dx[i]
else:
    a = sum(dx)

if m <= n:
    ans = 0
else:
    ans = x[m-1] - (x[0] - 1) - n - a
print(ans)

Measured memory_bytes: 13968
package main

import (
	"fmt"
	"sort"
)

func main() {
	var x, n int
	fmt.Scan(&x, &n)

	if n == 0 {
		fmt.Println(x)
		return
	}

	var p []int
	for i := 0; i < n; i++ {
		var a int
		fmt.Scan(&a)
		p = append(p, a)
	}
	sort.Ints(p)

	point := sliceIndex(p, x)
	if point == -1 {
		fmt.Println(x)
		return
	}

	for i := 1; ; i++ {
		flag := sliceIndex(p, p[point]-i)
		if flag == -1 {
			fmt.Println(x - i)
			return
		}
		flag = sliceIndex(p, p[point]+i)
		if flag == -1 {
			fmt.Println(x + i)
			return
		}
	}
}

func sliceIndex(a []int, b int) int {
	for i, e := range a {
		if e == b {
			return i
		}
	}
	return -1
}


Measured memory_bytes: 1844
/*#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

#include <boost/rational.hpp>
*/
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
using ll = long long;
using ld = long double;
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define rep3(i, n) for (ll i = 1; i < (ll)(n+1); i++)
#define rep4(i, s, n) for (ll i = (s); i < (ll)(n+1); i++)
#define repr(i,n) for (ll i = (n-1); i>=0;i--)
#define repr3(i,n) for(ll i = (n);i>0;i--)
#define repr4(i,s,n) for(ll i = (n);i>=(s);i--)
#define stlen(s) ll s.size()-1
#define all(v) v.begin(), v.end()
#define cout(n) cout<<std::fixed<<std::setprecision(n)
using Graph = vector<vector<int>>;
using Graphw = vector<vector<pair<ll,ll>>>;
#define INF1  INT_MAX;
#define INF2  LLONG_MAX;
#define PI  3.14159265358979323846;
#define MOD 1000000007;
/*
namespace mp = boost::multiprecision;
// 任意長整数型
using Bint = mp::cpp_int;
// 仮数部長が32の浮動小数点数型
using Real32 = mp::number<mp::cpp_dec_float<32>>;
// 仮数部長が1024の浮動小数点数型
using Real1024 = mp::number<mp::cpp_dec_float<1024>>;
// 有理数型
using Rat = boost::rational<Bint>;
*/



int main() {
int N;
cin>>N;
string S;
cin>>S;
ll left[N+1],right[N+2];
left[0]=0;
right[N+1]=0;
rep3(i,N){
    if(S[i-1]=='W'){
        left[i]=left[i-1]+1;
    }
    else{
        left[i]=left[i-1];
    }

}
repr3(i,N){
    if(S[i-1]=='E'){
        right[i]=right[i+1]+1;
    }
    else{
        right[i]=right[i+1];
    }
}
ll min_=INF1;
rep3(i,N){
    min_=min(min_,left[i-1]+right[i+1]);
}
cout<<min_<<endl;


return 0;
}


Measured memory_bytes: 5380
package main

import (
	"bufio"
	"bytes"
	"encoding/binary"
	"fmt"
	"os"
)

var rdr = bufio.NewReaderSize(os.Stdin, 10000000)

func readInt() int {
	buf := make([]byte, 0, 10000000)
	for {
		l, p, err := rdr.ReadLine()
		if err != nil {
			panic(err)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	B := bytes.NewReader(buf)
	var i int
	err := binary.Read(B, binary.LittleEndian, &i)
	if err != nil {
		panic(err)
	}
	return i
}

func main() {
	var A, B, K int
	fmt.Scan(&A, &B, &K)

	func() {
		if A > K {
			fmt.Printf("%d %d\n", A-K, B)
			return
		}

		K = K - A
		if B > K {
			fmt.Printf("%d %d\n", 0, B-K)
			return
		}
		fmt.Println("0 0")
		return
	}()

}


Measured memory_bytes: 2944