akhauriyash/Code-Regression huggingface dataset:
def submit():
    n = int(input())
    hlist = list(map(int, input().split()))

    movability = [0]
    for i in reversed(range(0, n - 1)):
        if hlist[i] >= hlist[i + 1]:
            movability.append(movability[-1] + 1)
        else:
            movability.append(0)

    print(max(movability))
             

if __name__ == "__main__":
    submit()

Measured memory_bytes: 14252
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define rep2(i,n) for(int i=0;i<=n;i++)
#define repr(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define P pair<long long,long long>
#define uni(e) e.erase(unique(e.begin(),e.end()),e.end())
#define double long double
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 INF=1e10;
int MOD=1e9+7;
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void yesno(T b){if(b)out("yes");else out("no");}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
template<class T> void YESNO(T b){if(b)out("YES");else out("NO");}
template<class T> void noyes(T b){if(b)out("no");else out("yes");}
template<class T> void NoYes(T b){if(b)out("No");else out("Yes");}
template<class T> void NOYES(T b){if(b)out("NO");else out("YES");}
int keta(int a){
  double b=a;
  b=log10(b);
  int c=b;
  return c+1;
}
int gcd(int a,int b){
  if(a%b==0)
    return b;
  return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
bool sosuu(int a){
  bool b=1;
  if(a<=1)
    return 0;
  else{
  rep1(i,sqrt(a)-1){
  if(a%(i+1)==0)
  b=0;
  }
  return b;
  }
}
signed main(){
  int a,b,c;
  cin>>a>>b>>c;
  YesNo(a==b&&b==c);
    
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
  int i, j, n, ans;
  scanf("%d", &n);
  int x[n], y[n];
  scanf("%d%d", &x[0], &y[0]);
  scanf("%d%d", &x[1], &y[1]);
  x[1] -= x[0], y[1] -= y[0];
  for(i = 2; i < n; ++i) {
    scanf("%d%d", &x[i], &y[i]);
    x[i] -= x[0], y[i] -= y[0];
    ans += y[i] * x[i - 1] - x[i] * y[i - 1];
  }
  printf("%.1f\n", (double)ans / 2);
  return 0; 
} 


Measured memory_bytes: 2756
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#ifdef tabr
#include "library/debug.cpp"
#else
#define debug(...)
#endif

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> a(1000001);
    for (int i = 0; i < n; i++) {
        int t;
        cin >> t;
        a[t]++;
    }
    for (int i = 0; i < 1000001; i++) {
        if (a[i] >= 1) {
            if (a[i] > 1) {
                a[i] = 0;
            }
            for (int j = i * 2; j < 1000001; j += i) {
                a[j] = 0;
            }
        }
    }
    cout << accumulate(a.begin(), a.end(), 0) << '\n';
    return 0;
}

Measured memory_bytes: 7104
#include <iostream>
#include <string>
#include <vector>
#include <tuple>
#include <algorithm>

using namespace std;

int main(int argc, char const *argv[]) {
  int N;
  std::vector<tuple<string,int,int>> v;

  std::cin >> N;
  for (int i = 1; i <= N; i ++ ) {
    string s;
    int p;
    std::cin >> s >> p;
    p = -p;
    v.push_back(tie(s,p,i));
  }
  sort(v.begin(),v.end());
  for (int i = 0 ; i < N; i++) {
    std::cout << get<2>(v[i]) << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
template<typename T>inline T read(){
	T f=0,x=0;char c=getchar();
	while(!isdigit(c)) f=c=='-',c=getchar();
	while(isdigit(c)) x=x*10+c-48,c=getchar();
	return f?-x:x;
}
#define int long long
namespace run{
	const int N=2e5+9,inf=1e18;
	int fa[N],a[N],n,par[N],siz[N],val[N];
	inline int get(int x){return x==fa[x]?x:fa[x]=get(fa[x]);}
	struct node{
		int rt,s,v;explicit node(){}
		node(int _rt,int _s,int _v):rt(_rt),s(_s),v(_v){}
		bool operator <(const node &A)const{
			return s*A.v<A.s*v;
		}
	};
	priority_queue<node> pq;
	int main(){
		n=read<int>();
		for(int i=2;i<=n;i++) par[i]=read<int>();
		for(int i=1;i<=n;i++) a[i]=read<int>(),fa[i]=i,siz[i]=(a[i]==0),val[i]=(a[i]==1);
		for(int i=2;i<=n;i++)
			if(!a[i]){
				int u=get(par[i]),v=get(i);
				fa[v]=u,siz[u]+=siz[v],val[u]+=val[v];
			}

		int ans=0;
		for(int i=1;i<=n;i++)
			if(i!=1 && a[i]){
				pq.push(node(i,siz[i],val[i]));
				ans+=siz[i];
			}
		if(a[1]==1) ans+=siz[1];
		while(!pq.empty()){
			node o=pq.top();pq.pop();
			int u=o.rt,v=get(par[u]);
			if(val[u]!=o.v || siz[u]!=o.s) continue;
			ans+=val[v]*siz[u],fa[u]=v;
			siz[v]+=siz[u],val[v]+=val[u];
			if(v!=1) pq.push(node(v,siz[v],val[v]));
		}
		printf("%lld\n",ans);
		return 0;
	}
}
#undef int
int main(){
#ifdef my
	freopen(".in","r",stdin);
	freopen(".out","w",stdout);
#endif
	return run::main();
}

Measured memory_bytes: 18600
#include <iostream>
#include <cstdlib>
#include <string>
#include <algorithm>
using namespace std;

int comp(const void* a, const void* b){
	return *(int*)a - *(int*)b;
}

int main() {
	int a, b, h;
	cin >> a >> b >> h;
	cout << (a+b)*h/2 << endl;
}

Measured memory_bytes: 256
import io
import math

I=lambda:map(int,input().split())

h,w,d=I()

H={}

W={}

for i in range(1,h+1):
  for j,k in enumerate(I(),1):
    H[k],W[k]=i,j
    
x=1+h*w
s=[0 for _ in [0]*x]

for i in range(d+1,x):
  s[i]=s[i-d]+abs(H[i]-H[i-d])+abs(W[i]-W[i-d])

for _ in [0]*int(input()):
  a,b=I()
  print(s[b]-s[a])

Measured memory_bytes: 24452
//ABC173_B
#include <stdio.h>
#include <string.h>

int main(){
	int n;
	char s[10];
	int ac=0,wa=0,tle=0,re=0;
	
	scanf("%d",&n);
	
	for(int i=0;i<n;i++){
		scanf("%s",s);
		
		//入力された文字のテスト出力
		//printf("%s\n",s);
		
		if(strcmp(s,"AC") == 0)	ac = ac + 1;
		else if(strcmp(s,"WA")==0)	wa = wa + 1;
		else if(strcmp(s,"TLE")==0)	tle = tle + 1;
		else if(strcmp(s,"RE")==0)	re = re + 1;
	}
	
	printf("AC x %d\n",ac);
	printf("WA x %d\n",wa);
	printf("TLE x %d\n",tle);
	printf("RE x %d\n",re);
	
	return 0;
}


Measured memory_bytes: 1732
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iomanip>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(obj) (obj).begin(), (obj).end()
#define DOUT(obj,n) cout << fixed << setprecision(n) << obj << endl

#define PI 3.14159265359

using namespace std;
typedef long long unsigned int ll;

int main() {
	int n, k;
	cin >> n >> k;
	vector<double> x;
	x.emplace_back(0);
	REP(i, n) {
		double tmp;
		cin >> tmp;
		x.emplace_back(x[i] + ((tmp + 1) / 2));
	}
	double m = 0;
	REP(i, n - k + 1) {
		m = max(m, x[n - i] - x[n - i - k]);
	}
	DOUT(m, 10);
}

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

#define REP(i, n) for(ll (i) = 0; (i) < (n); (i)++)
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))

typedef long long ll;

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

	vector<int> g(2), s(2), b(2);
	REP(i, 2){
		cin >> g[i] >> s[i] >> b[i];
	}

	int dif_g = g[1]-g[0], dif_s = s[1]-s[0], dif_b = b[1]-b[0];

	vector<ll> dp(n+1, n);
	REP(i, n){
		if(dp[i] > n || !i){
			if(i+g[0] <= n && dif_g > 0) dp[i+g[0]] = MAX(dp[i+g[0]], dp[i]+dif_g);
			if(i+s[0] <= n && dif_s > 0) dp[i+s[0]] = MAX(dp[i+s[0]], dp[i]+dif_s);
			if(i+b[0] <= n && dif_b > 0) dp[i+b[0]] = MAX(dp[i+b[0]], dp[i]+dif_b);
		}
	}

	ll max = n;
	REP(i, n+1){
		if(dp[i] > max){
			max = dp[i];
		}
	}

	dp.resize(max+1);
	dp.assign(max+1, max);
	//REP(i, max+1) cout << dp[i] << ' '; cout << endl;
	REP(i, max){
		if(dp[i] > max || !i){
			if(i+g[1] <= max && dif_g < 0) dp[i+g[1]] = MAX(dp[i+g[1]], dp[i]-dif_g);
			if(i+s[1] <= max && dif_s < 0) dp[i+s[1]] = MAX(dp[i+s[1]], dp[i]-dif_s);
			if(i+b[1] <= max && dif_b < 0) dp[i+b[1]] = MAX(dp[i+b[1]], dp[i]-dif_b);
		}
	}

	ll ans = max;
	REP(i, max+1){
		if(dp[i] > ans){
			ans = dp[i];
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 195584
#include<stdio.h>
int dp[201][201];
int main(void)
{
	int D,N,T[201],A[201],B[201],C[201],i,j,k,max=0,x=0;
	scanf("%d%d",&D,&N);
	for(i=1;i<=D;i++){
		scanf("%d",&T[i]);
	}
	for(i=1;i<=N;i++){
		scanf("%d%d%d",&A[i],&B[i],&C[i]);
	}
	for(i=1;i<=D;i++){
		for(j=1;j<=N;j++){
			dp[i][j]=-1;
		}
	}
	for(i=1;i<=N;i++){
		dp[1][i]=0;
	}
	for(i=1;i<D;i++){
		for(j=1;j<=N;j++){
			if(dp[i][j]!=-1){
				if(A[j]<=T[i]&&T[i]<=B[j]){
					for(k=1;k<=N;k++){
						if(A[k]<=T[i+1]&&T[i+1]<=B[k]){
							if(C[j]-C[k]<0){
								x=-1*(C[j]-C[k]);
							}
							else{
								x=C[j]-C[k];
							}
						}
						if(dp[i+1][k]<dp[i][j]+x){
							dp[i+1][k]=dp[i][j]+x;
						}
					}
				}
			}
		}
	}
	/*for(i=1;i<=D;i++){
		for(j=1;j<=N;j++){
			printf("%d ",dp[i][j]);
		}
		printf("\n");
	}*/
	for(i=1;i<=N;i++){
		if(max<dp[D][i]){
			max=dp[D][i];
		}
	}
	printf("%d\n",max);
	return 0;
}

Measured memory_bytes: 2884
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <sstream>
#include <utility>
#include <cstdlib>
#include <cctype>
#include <climits>
#include <fstream>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<double> vd;
typedef vector<pair<int, int> > vpii;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define foreach(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); itr++)
#define dbg(x) cout << #x"="<< (x) << endl
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back(a) 
#define in(x) cin >> x;
#define all(x) (x).begin(), (x).end()
#define INF 2147483600
#define fi first
#define se second
using namespace std;
int sum[5001];
int main(){
	int N,ans;
	while(cin>>N&&N){
		ans = INT_MIN;
		rep(i,N){
			cin>>sum[i];
			sum[i] += sum[i-1];
		}
		rep(i,N){
			FOR(j,i,N){
				ans = max(ans,sum[j]-sum[i-1]);
			}
		}
		cout<< ans <<endl;
	}
}

Measured memory_bytes: 3100
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;

namespace Codeforces
{
	internal class Template
	{
		private void Solve()
		{
			var x = cin.NextLong();
			var sum = 0;
			for (var i = 1;; i++)
			{
				sum += i;
				if (sum >= x)
				{
					Console.WriteLine(i);
					return;
				}
			}
		}

		private static readonly Scanner cin = new Scanner();

		private static void Main()
		{
#if DEBUG
			var inputText = File.ReadAllText(@"..\..\input.txt");
			var testCases = inputText.Split(new[] { "input" }, StringSplitOptions.RemoveEmptyEntries);
			var consoleOut = Console.Out;
			for (var i = 0; i < testCases.Length; i++)
			{
				var parts = testCases[i].Split(new[] { "output" }, StringSplitOptions.RemoveEmptyEntries);
				Console.SetIn(new StringReader(parts[0].Trim()));
				var stringWriter = new StringWriter();
				Console.SetOut(stringWriter);
				var sw = Stopwatch.StartNew();
				new Template().Solve();
				sw.Stop();
				var output = stringWriter.ToString();

				Console.SetOut(consoleOut);
				var color = ConsoleColor.Green;
				var status = "Passed";
				if (parts[1].Trim() != output.Trim())
				{
					color = ConsoleColor.Red;
					status = "Failed";
				}
				Console.ForegroundColor = color;
				Console.WriteLine("Test {0} {1} in {2}ms", i + 1, status, sw.ElapsedMilliseconds);
			}
			Console.ReadLine();
			Console.ReadKey();
#else
			new Template().Solve();
			Console.ReadLine();
#endif
		}
	}

	internal class Scanner
	{
		private string[] s = new string[0];
		private int i;
		private readonly char[] cs = { ' ' };

		public string NextString()
		{
			if (i < s.Length) return s[i++];
			var line = Console.ReadLine() ?? string.Empty;
			s = line.Split(cs, StringSplitOptions.RemoveEmptyEntries);
			i = 1;
			return s.First();
		}

		public double NextDouble()
		{
			return double.Parse(NextString());
		}

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

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

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF INT_MAX
#define mod 1000000007

int n,m;
vector<P> g[100];
int sum[1<<15];
int dp[1<<15][15];
int tot=0;

int main(){
  cin>>n>>m;
  rep(i,m){
    int a,b,c;
    cin>>a>>b>>c;
    a--;b--;
    g[a].push_back(P(b,c));
    g[b].push_back(P(a,c));
    tot+=c;
  }
  rep(S,1<<n){
    rep(i,n){
      if(!((S>>i)&1))continue;
      for(P p : g[i]){
        if((S>>p.fi)&1)sum[S]+=p.se;
      }
    }
    sum[S]/=2;
  }

  rep(i,1<<n)rep(j,n)dp[i][j]=-INF;
  dp[0][0]=0;
  rep(S,1<<n)rep(i,n){
    if(dp[S][i]==-INF)continue;
    ll S_=((1<<n)-1)^S;
    for(ll T=S_;T>=0;T--){
      T&=S_;
      if((T>>i)&1)maxch(dp[S|(T^(1<<i))][i],dp[S][i]+sum[T]);
    }
    for(P p : g[i]){
      if((S>>p.fi)&1)continue;
      maxch(dp[S|(1<<i)][p.fi],dp[S][i]+p.se);
    }
  }

  int res=-INF;
  rep(S,1<<n)maxch(res,dp[S][n-1]);
  cout<<tot-res<<endl;
  return 0;
}


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

  using namespace std;

  int main() {
    string S; cin >> S;
    if ((S[0] == S[1] && S[1] == S[2]) || (S[1] == S[2] && S[2] == S[3])) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  }


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(long long i=0; i<n; i++)
#define REPR(i, n) for(long long i=n-1; i>=0; i--)
#define FOR(i, m, n) for(long long i=m; i<=n; i++)
#define FORR(i, m, n) for(long long i=m; i>=n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
#define FIN ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;
const ll mod = 1e9+7;
const ll inf = 1e15;


struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};


int main(){FIN

    ll n,m;cin>>n>>m;
    vll a(n);REP(i,n) cin>>a[i];

    UnionFind tree(n);
    REP(i,m){
        ll a,b;cin>>a>>b;
        tree.unite(a-1,b-1);
    }
    ll ans=0;
    REP(i,n){
        if(tree.same(a[i]-1, i)) ans++;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n,k,x;
    cin>>n>>k;
    for(int i=0;i<k;i++){
        cin>>x;
        n-=x;
        if(n<=0){cout<<"Yes";return 0;}
    }
    cout<<"No";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	
	int n;
	
	cin >> n;
	
	vector<int> v(n);
	
	for (int i=0; i<n; i++) {
		
		cin >> v[i];
		
	}
	
	int res;
	
	sort(v.begin(), v.end());
	
	
	
	if (v[n/2-1] == v[n/2]) {
		
		res = 0;
	
	}
		
	else{
		
		res = v[n/2] -v[n/2-1];
		
	}
	
	cout << res <<endl;
	
	
    return 0;

}


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

#define INF INT_MAX
#define UINF UINT_MAX
#define MOD 1000000007
#define REP(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()

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

using namespace std;

// 座標 corrdinate と深さを保持するための構造体
struct Corr {
    ll y;
    ll x;
    ll depth;
};

ll N, M;  // 迷路の縦，横
ll s_y, s_x, g_y, g_x;  // スタート，ゴールの座標
ll y, x, depth;  // キューから取り出した座標
vector<string> vec;  // 座標を受け取る配列


vector<ll> y_vec = {0, 0, -1, +1};  // 進む方向の簡便化，テクニックとして覚えておく．
vector<ll> x_vec = {-1, +1, 0, 0};  // ループで回すことで上下左右に移動できるようになっている

ll bfs(queue<Corr> q) {
    while (!q.empty()) {
        Corr now = q.front(); q.pop();  // キューの先頭を取り出す
        y = now.y, x = now.x, depth = now.depth;  // 行，列が y, x になっているので注意

        // 停止条件：現在の座標がゴールなら深さを返す
        if (y == g_y && x == g_x) return depth;

        // 上下左右 4 方向を探索．進むことができればキューに格納する．
        for (ll i = 0; i < 4; ++i) {
            Corr next = {y + y_vec[i], x + x_vec[i], depth + 1};
            if (0 <= next.y && next.y <= N-1 && 0 <= next.x && next.x <= M-1 && vec[next.y][next.x] == '.') {
                vec[next.y][next.x] = 'x';  // 同じ場所を探索しないようにする
                q.push(next);
            }
        }
    }
    return 0;
}
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    cin >> N >> M;

    vector<string> meiro;

    REP(j,N){
        string s;
        cin >> s;
        meiro.push_back(s);
    }

    ll ans = 0;

    REP(j,N){
        REP(i,M){
            REP(k,N){
                REP(l,M){
                    queue<Corr> q;
                    vec = meiro;
                    s_y = j,s_x = i;
                    g_y = k,g_x = l;
                    if(vec[j][i] == '#' || vec[k][l] == '#')continue;
                    Corr start = {s_y, s_x, 0};  // 初期位置の深さ(depth)は 0
                    q.emplace(start);  // 初期位置をキューに格納
                    ll ret = bfs(q);
                    if(ret > ans)ans = ret;
                }
            }
        }
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
//for文のマクロ
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define big 1000000007
#define all(a) sort((a).begin(),(a).end()) //ソートのマクロ
#define Re(a) reverse((a).begin(),(a).end())
int main(){
    int n,l;
    cin>>n>>l;
    vector<string> s(n);
    rep(i,n){
        cin>>s[i];
    }   
    all(s);
    rep(i,n){
        cout<<s[i];
    }
    cout<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#define N 1200

int main(void) {

    int i;
    char str[N];
    char ch;

    for (i = 0; i < N; i++) {
        str[i] = 0;
    }

    i = 0;
    while (1) {
        scanf("%c", &ch);
        if ((ch >= 16*4 + 1) && (ch <= 16*5 + 10)) {
            ch += 16*2;
        } else if ((ch >= 16*6 + 1) && (ch <= 16*7 + 10)) {
            ch -= 16*2;
        }
        str[i] = ch;
        i++;
        if (ch == '\n') {
            break;
        }
    }

    printf("%s", str);

    return 0;

}

Measured memory_bytes: 536
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
using namespace std;

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

    int A[N+2];

    for(int i = 1; i <= N; i++){
        cin >> A[i];
    }
    A[0]=0;
    A[N+1]=0;

    int sums = 0;
    for(int i = 1; i <= N+1; i++){
        sums += abs(A[i] - A[i-1]);
    }
//    cout << sums << endl;

    int res;
    for(int i = 1; i <= N; i++){
        res = abs(A[i] - A[i-1]) + abs(A[i] - A[i+1]) - abs(A[i+1] - A[i-1]);
        cout << sums - res << endl;
    }
}

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

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

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


struct Xcsr {
    int depth;
    string::iterator c;
};

int main() {
    char op;
    string ex1, ex2;
    int i;

    while (cin >> op >> ex1 >> ex2) {

        Xcsr x[2], *xa, *xb;
        x[0].depth = x[1].depth = 0;
        x[0].c = ex1.begin();
        x[1].c = ex2.begin();
        string result;
        while (x[0].c != ex1.end() || x[1].c != ex2.end()) {

            for (i = 0; i < 2; i++) {
                if (*(x[i].c) == '(') {
                    x[i].depth++;
                }
                else if (*(x[i].c) == ')') {
                    x[i].depth--;
                }
            }
            if (*(x[0].c) == *(x[1].c) && x[0].depth == x[1].depth) {
                result += *(x[0].c);
            }
            else {
                if (x[0].depth > x[1].depth) {
                    xa = &x[0];
                    xb = &x[1];
                }
                else {
                    xa = &x[1];
                    xb = &x[0];
                }
                while (*(xa->c) != *(xb->c) || xa->depth != xb->depth) {
                    if (op == 'u') result += *(xa->c);
                    xa->c++;
                    if (*(xa->c) == '(') {
                        xa->depth++;
                    }
                    else if (*(xa->c) == ')') {
                        xa->depth--;
                    }
                }
                result += *(x[0].c);
            }
            x[0].c++;
            x[1].c++;
        }
        cout << result << endl;
    }
    return 0;
}

Measured memory_bytes: 1192
package main

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

var sc = bufio.NewScanner(os.Stdin)
var buf = make([]byte, 10000)

func nextLine() string {
	ret := sc.Scan()
	if !ret {
		panic("err")
	}
	return sc.Text()
}

func main() {
	sc.Buffer(buf, 1000000)
	NAB := strings.Split(nextLine(), " ")
	N, _ := strconv.Atoi(NAB[0])
	A, _ := strconv.ParseUint(NAB[1], 10, 64)
	B, _ := strconv.ParseUint(NAB[2], 10, 64)
	X := strings.Split(nextLine(), " ")
	L := make([]uint64, N)
	for i, v := range X {
		L[i], _ = strconv.ParseUint(v, 10, 64)
	}
	var ans uint64
	for i := 0; i < N-1; i++ {
		a := A * (L[i+1] - L[i])
		if a < B {
			ans += a
		} else {
			ans += B
		}
	}
	fmt.Println(ans)
}


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

#define MOD (1000000000+7)

int main() {
	int N;

	cin >> N;

	long long ans = 1;
	for( int i = 1; i <= N; i++ ) {
		ans = ans * i % MOD;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
# author:  Taichicchi
# created: 09.09.2020 23:22:31

import sys

S = input()
N = len(S)
ans = 0
for i in range(N):
    for j in range(i, N):
        if all('ACGT'.count(c) == 1 for c in S[i : j + 1]):
            ans = max(ans, j - i + 1)
print(ans)


Measured memory_bytes: 9036
#include <iostream>
#include <numeric>
#include <cmath>
#include <limits>
#include <stdio.h>
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
using ll = long long;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
ll Max(ll(a), ll(b), ll(c)) {
	return max(max(a, b), c);
}
ll Min(ll(a), ll(b), ll(c)) {
	return min(min(a, b), c);
}
ll gcd(ll(a), ll(b)) {
	ll c = a;
	while (a % b != 0) {
		c = a % b;
		a = b;
		b = c;
	}
	return b;
}



int main() {

	ll A, B, C, X,an=0;
	cin >> A >> B >> C >> X;
	rep(a, A+1) {
		rep(b, B + 1) {
			rep(c, C + 1) {
				if (a * 500 + b * 100 + c * 50 == X) {
					an++;
				}
			}
		}
	}
	cout << an << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <iostream>
#include <string>
using namespace std;

int main(int argc, char* argv[]){
	int N, M;
	cin >> N >> M;
	for(int i=1, j=0; j < M; i++){
		cout << i << " " << (M + 2 - i) << endl ;
		if(++j < M){
			cout << (M + i + 1) << " " <<  ((2 * M) + 2 - i) << endl;
			j++;
		}
	}
	return 0;
}

Measured memory_bytes: 3620
#include<iostream>
#include<list>
#include<queue>
using namespace std;
#define LL long long
struct Edge
{
	LL v;
	LL u;
	LL s;
	bool vis;//false 没被访问过
}edge[100005];

struct Node
{
	LL num;
	bool x;//true为正，false为负；
	list<LL> L;
}node[200005];

bool vis[200005];

LL tol;

LL low = 0;
LL up = 0xfffffffffffffff;

queue<LL> q;

LL jie;

bool f()
{
	while (!q.empty())
	{
		LL top = q.front();
		q.pop();
		list<LL>::iterator it;
		for (it = node[top].L.begin(); it != node[top].L.end(); it++)
		{
			if (!(edge[*it].vis))
			{
				LL u = edge[*it].u;
				LL v = edge[*it].v;
				if (vis[u] && vis[v])
				{
					if (node[u].x^node[v].x)
					{
						if (node[u].num + node[v].num != edge[*it].s)
						{
							return false;
						}
					}
					else if(node[u].x)
					{
						LL temp = -(node[u].num + node[v].num - edge[*it].s);
						if (temp <= 0)
						{
							return false;
						}

						if (temp & 1)
						{
							return false;
						}
						else
						{
							temp /= 2;
							if (!jie)
							{
								jie = temp;
							}
							else if(temp!=jie)
							{
								return false;
							}
						}
					}
					else
					{
						LL temp = (node[u].num + node[v].num - edge[*it].s);
						if (temp <= 0)
						{
							return false;
						}
						if (temp & 1)
						{
							return false;
						}
						else
						{
							temp /= 2;
							if (!jie)
							{
								jie = temp;
							}
							else if (temp != jie)
							{
								return false;
							}
						}
					}
				}
				else if(vis[u])
				{
					node[v].x = !node[u].x;
					node[v].num = edge[*it].s - node[u].num;
					if (node[v].x)
					{
						if (low < -node[v].num)
						{
							low = -node[v].num;
						}
					}
					else
					{
						if (up > node[v].num)
						{
							up = node[v].num;
						}
					}
					vis[v] = true;
					q.push(v);
				}
				else
				{
					node[u].x = !node[v].x;
					node[u].num = edge[*it].s - node[v].num;
					if (node[u].x)
					{
						if (low < -node[u].num)
						{
							low = -node[u].num;
						}
					}
					else
					{
						if (up > node[u].num)
						{
							up = node[u].num;
						}
					}
					vis[u] = true;
					q.push(u);
				}

				edge[*it].vis = true;
			}
		}


	}
	if (low + 1 >= up)return false;
	return true;
}
LL ans = 1;
int main()
{
	LL N, M;
	cin >> N >> M;
	for (LL i = 1; i <= M; i++)
	{
		LL t1, t2, t3;
		cin >> t1 >> t2 >> t3;
		edge[tol].s = t3;
		edge[tol].u = t1;
		edge[tol].v = t2;
		node[t1].L.push_back(tol);
		node[t2].L.push_back(tol);
		tol++;
	}

	for (LL i = 1; i <= N; i++)
	{
		if (!vis[i])
		{
			q.push(i);
			node[i].num = 0;
			node[i].x = true;
			vis[i] = true;
			jie = 0;
			low = 0;
			up = 0xfffffffffffffff;
			if (!f())
			{
				cout << "0" << endl;
				return 0;
			}
			else
			{
				if(!jie)
					ans *= (up - low - 1);
			}
			
		}
	}
	cout << ans << endl;
	
	return 0;
}

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

int A;
int B;
int C;
int D;
int E;
int F;
set<int> s;
bool less_comp(long long int a, long long int b, long long int c, long long int d){  // (a/b)<(c/d)
	if (a / b != c / d) return a / b < c / d;
	a %= b, c %= d;
	if (c == 0) return 0;
	if (a == 0) return 1;
	return less_comp(d, c, b, a);
}
bool greater_cmp(long long int a, long long int b, long long int c, long long int d){
	return a*d < c*b;
}

int main(){
	cin >> A >> B >> C >> D>>E>>F;
	for (int k = 0; k <= F; k += C){
		for (int kk = 0; kk+k <= F; kk += D){
			s.insert(k + kk);
		}
	}
	int A2 = 0;
	int B2 = 100*A;
	for (int i = 0; i < F; i += 100 * A){
		for (int j = 0; j + i < F; j += 100 * B){
			for (auto it = s.begin(); it != s.end(); it++){
				int ALL = i + j + (*it);
				if (ALL == 0)continue;
				if (ALL > F)break;
				int sugar = (*it);
				if (!greater_cmp((i+j)*(long long int)(E), 100, sugar,1)){
					if (!greater_cmp(sugar, ALL,A2,B2)){
						A2 = sugar;
						B2 = ALL;
					}
				}
			}
		}
	}
	cout << B2 << " " << A2 << endl;
	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define gcd(a,b) __gcd(a,b)
#define pb push_back
#define sevensins ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ll long long int
#define mod  1000000007
#define vect vector<long long int>
#define bins binary_search
#define vecti vector<int>::iterator
#define bitout __builtin_popcount
#define binsrch binary_search
int main() 
{sevensins
ll t,i,j,k,l,n;
	string s;
    cin>>s;
    if(s[2]==s[3]&&s[4]==s[5])
    cout<<"Yes"<<"\n";
    else
    cout<<"No"<<"\n";

return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
pair<ll,pair<ll,ll>>p[114514];
string ans[114514];
int main() {
  ll n,m;
  cin>>n>>m;
  for(int i=0;i<m;i++){
    cin>>p[i].first>>p[i].second.first;
    p[i].second.second=i;
  }
  sort(p,p+m);
  ll cnt=1;
  for(int i=0;i<m;i++){
    string a=to_string(p[i].first);
    for(ll j=1;j<=6-a.size();j++)ans[p[i].second.second]+='0';
    ans[p[i].second.second]+=a;
    if(i){
      if(p[i].first==p[i-1].first)cnt++;
      else cnt=1;
    }
    a=to_string(cnt);
    for(ll j=1;j<=6-a.size();j++)ans[p[i].second.second]+='0';
    ans[p[i].second.second]+=a;
  }
  for(int i=0;i<m;i++)cout<<ans[i]<<endl;
  return 0;
}


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

using namespace std;

int main()
{
#ifdef CraZYali
	freopen("a.in", "r", stdin);
	freopen("a.out", "w", stdout);
#endif
	long long ans = 700;
	register char c;
	while ((c = getchar()) != EOF && c ^ '\n')
		if (c == 'o') ans += 100;
	cout << ans;
	return 0;
}


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

long long solve(int level, const vector<long long>& Nums, const vector<long long>& Pates, long long& X) {
	if (Nums[level] <= X) {
		X -= Nums[level];
		return Pates[level];
	}
	else {
		long long ans = 0;
		X--;
		if (X <= 0) return ans;
		ans += solve(level - 1, Nums, Pates, X);
		if (X <= 0)return ans;
		X--;
		ans++;
		if (X <= 0)return ans;
		ans += solve(level - 1, Nums, Pates, X);
		return ans;
	}
}

int main() {
	int N;
	long long X;
	cin >> N >> X;
	vector<long long> Nums(N + 1), Pates(N + 1);
	Nums[0] = 1ll, Pates[0] = 1ll;
	for (int i = 1; i <= N; i++) {
		Nums[i] = Nums[i - 1] * 2 + 3;
		Pates[i] = Pates[i - 1] * 2 + 1;
	}
	cout << solve(N, Nums, Pates, X);

}

Measured memory_bytes: 256
using System;
using System.Numerics;
using System.Linq;
using System.Collections.Generic;
class ProgramD
    {
        static void Main(string[] args)
        {
            
            //入力
            string[] input = Console.ReadLine().Split(' ');
            long n = long.Parse(input[0]);
            long a = long.Parse(input[1]);
            long b = long.Parse(input[2]);

            long MOD = 1000000000 + 7;

            
            
            //まずは総和を計算
            BigInteger temp10 = System.Numerics.BigInteger.ModPow(2, n, MOD);
            long ans = (long)temp10;

            if(n/2 < a)
                 a = n - a;
            
            if(n/2 < b)
                 b = n - b;

            long a_sum = 1;
            long b_sum = 1;
            //分子の方をかける
            for(long i = 0;i < a;i++)
            {
                    a_sum *= n - i;
                    a_sum %= MOD;
            }

            //分母の方を割る
            for(long i = 0;i < a;i++)
            {
                a_sum = a_sum * modinv(i + 1,MOD) % MOD;
            }

            //分子の方をかける
            for(long i = 0;i < b;i++)
            {
                    b_sum *= n - i;
                    b_sum %= MOD;
            }

            //分母の方を割る
            for(long i = 0;i < b;i++)
            {
                b_sum = b_sum * modinv(i + 1,MOD) % MOD;
            }

            ans -= a_sum;
            ans -= b_sum;
            ans -= 1;
            ans %= MOD;

            if(ans < 0)
                ans = MOD - Math.Abs(ans);

            Console.WriteLine(ans);

        }
         
  // mod. m での a の逆元 a^{-1} を計算する
        static long modinv(long a, long m)
         {
            long b = m, u = 1, v = 0;
            while (b > 0)
            {
                //こちらは普通のユークリッドの互除法
                long t = a / b;
                a -= t * b; 
                var temp = a;
                a = b;
                b = temp;
                //こっちは逆算すると解が出る
                u -= t * v; 
                var temp2 = u;
                u = v;
                v = temp2;
            }
            u %= m;
            if (u < 0) 
                u += m;
            return u;
        }
}

Measured memory_bytes: 13396
#include <bits/stdc++.h>
using namespace std;
#define ALL(obj) obj.begin(),obj.end()
#define pb(obj) push_back(obj)
#define REP(i,N) for(int i=0;i<N;i++)
typedef long long ll;
const ll MOD=1000000007;
int main(){
	cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin>>N;
    vector<double> v(N);
    REP(i,N)cin>>v[i];
    sort(ALL(v));
    double sub=(v[0]+v[1])/2;
    for(int i=2;i<=N-1;i++){
        sub=(sub+v[i])/2;
    }
    printf("%.10f\n",sub);
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    void run() {
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int[] dArr = new int[n];

        for (int i = 0; i < n; i++) {
            dArr[i] = sc.nextInt();
        }

        Arrays.sort(dArr);

        int lower = dArr[n / 2 - 1];
        int upper = dArr[n / 2];

        System.out.println(upper - lower);


        // write your code
//        System.out.println("Hello World");
    }

    void debug(Object... os) {
        System.err.println(Arrays.deepToString(os));
    }

    public static void main(String[] args) {
        new Main().run();
    }
}


Measured memory_bytes: 50428
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
const lint mod = 998244353;
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl((lint)(n))
#define fcout cout << fixed << setprecision(15)
#define highest(x) (63 - __builtin_clzl(x))
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T = string, class U = char>int character_count(T text, U character){ int ans = 0; for(U i: text){ ans += (i == character); } return ans; }
lint power(lint base, lint exponent, lint module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ lint root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position mv[4] = {{0, -1}, {1, 0}, {0, 1}, {-1, 0}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); } string to_string(string x){ return x; }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++) ans += to_string(*i) + " "; if(!ans.empty()) ans.pop_back(); cout << ans << endl; }
template<class itr> void cins(itr first, itr last){ for(auto i = first; i != last; i++){ cin >> (*i); } }
template<class T> T gcd_calc(T a, T b){ if(b){ return gcd_calc(b, a % b); }else{ return a; }}
template<class T> T gcd(T a, T b){ if(a < b) swap(a, b); return gcd_calc(a, b); }
template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
struct combination{ vector<lint> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2, mod); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } lint C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };
template<class itr> bool next_sequence(itr first, itr last, int max_bound){ itr now = last; while(now != first){ now--; (*now)++; if((*now) == max_bound){ (*now) = 0; }else{ return true; } } return false; }
inline int at(int x, int k){ return (x >> k) & 1; }
random_device rnd;

int main(){
    lint a, b, c;
    cin >> a >> b >> c;
    Yes(a + b < c && 4 * a * b < (c - a - b) * (c - a - b));
}


Measured memory_bytes: 256
#define X(V,N)0<=V+D[d][N]*(m-1)&&V+D[d][N]*(m-1)<n
D[13][3]={{1,0,0},{0,1,0},{0,0,1},{1,1,0},{1,0,1},{0,1,1},{1,-1,0},{1,0,-1},{0,1,-1},{1,1,1},{-1,1,1},{1,-1,1},{1,1,-1}};
M[7][7][7];main(n,m,p,I,x,y,i,j,k,c,d,z){for(;scanf("%d%d%d",&n,&m,&p),n;){
	for(memset(M,0,sizeof(M)),c=1,I=0;I<p;c*=-1){
		scanf("%d%d",&x,&y),x--,y--,I++;
		for(i=0;;i++)if(!M[x][y][i]){M[x][y][i]=c;break;}
		for(i=0;i<n;i++)for(j=0;j<n;j++)for(k=0;k<n;k++)for(d=0;d<13;d++)if(X(i,0)&&X(j,1)&&X(k,2)){
			for(z=0;z<m;z++)if(M[i+D[d][0]*z][j+D[d][1]*z][k+D[d][2]*z]!=c)break;
			if(z==m){printf("%s %d\n",c==1?"Black":"White",I);goto next;}
		}
	}
	puts("Draw");
next:
	for(;I<p;I++)scanf("%d%d",&x,&y);
}exit(0);}

Measured memory_bytes: 612
import java.io.PrintStream;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = null;
		PrintStream out = null;
		try {
			sc = new Scanner(System.in);
			out = System.out;
			exec(sc, out);
		} catch (Exception e) {
			e.printStackTrace();
			System.exit(1);
		} finally {
			if(out != null) {
				out.close();
			}
			if(sc != null) {
				sc.close();
			}
		}
		System.exit(0);
	}
	public static void exec(final Scanner sc, final PrintStream out) throws Exception{
		final int N = sc.nextInt();
		final int B[] = new int[N-1];

		for(int i=0;i<N-1;i++) {
			B[i] = sc.nextInt();
		}

		int score = B[0];
		for(int i=1;i<N-1;i++) {
			score += Math.min(B[i-1], B[i]);
		}
		score += B[N-2];

		out.println(score);
	}
}


Measured memory_bytes: 21972
#include <iostream>
#include <bitset>
#include <iomanip>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <algorithm>

using namespace std;

#define ll long long
#define vec vector
#define vecll vector<long long>
#define vec2ll vector<vector<long long>>
#define forll(s,a,b) for(long long s = a;s < b;s++)
#define forllde(s,a) for(long long s = a;s > 0;s--)

int main()
{
	ll n, m;
	double  total = 0;
	string s = "Yes";

	cin >> n >> m;

	vecll a(n);

	forll(i, 0, n)
		cin >> a[i];

	forll(i, 0, n)
		total += (double)a[i];

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

	forll(i, 0, m)
	{
		if ((double)a[i] < total / (double)(4 * m))
			s = "No";
	}

	cout << s << endl;

}

Measured memory_bytes: 256
def resolve():
    n = int(input())
    a = list(map(int, input().split()))
    ans = 1000
    pm = 1
    for i in range(n-1):
        if a[i] < a[i+1]:
            t = ans // a[i]
            ans += t * (a[i+1] - a[i])

    print(ans)


if __name__ == "__main__":
    resolve()


Measured memory_bytes: 9076
#include <cstdio>
#include <cstring>
#include <vector>
#include <cassert>
#define MAXN 200010
#define LL long long
using namespace std;

const LL P=1000000007;

LL getPow(LL x,LL y){
	LL res=1;
	while(y){
		if(y&1) res=res*x%P;
		x=x*x%P;
		y>>=1;
	}
	return res;
}

struct edge{
	int to,next;
	edge(int _to=0,int _next=0):to(_to),next(_next){}
}e[MAXN<<1];

int n;
int e2[MAXN][2];
int g[MAXN],nume;
int de[MAXN],dp[MAXN],fa[MAXN],tag[MAXN],size[MAXN],pre[MAXN];
int root;
vector<int> rt[MAXN],tr;
LL fac[MAXN],invfac[MAXN];

void addEdge(int u,int v){
	e[nume]=edge(v,g[u]);
	g[u]=nume++;
}

int getf(int x){
	if(fa[x]==x) return x;
	return fa[x]=getf(fa[x]);
}

void dfs(int x,int p){
	pre[x]=p;
	for(int i=g[x];~i;i=e[i].next)
		if(e[i].to!=p && e[i].to!=root)
			dfs(e[i].to,x);
	if(x>pre[pre[x]]) tr.push_back(x);
}

void init(){
	fac[0]=1;
	for(int i=1;i<MAXN;i++) fac[i]=fac[i-1]*i%P;
	invfac[MAXN-1]=getPow(fac[MAXN-1],P-2);
	for(int i=MAXN-2;i>=0;i--) invfac[i]=invfac[i+1]*(i+1)%P;
}

LL getC(int x,int y){
	return fac[x]*invfac[y]%P*invfac[x-y]%P;
}

LL dfs2(int x){
	size[x]=0;
	LL res=1;
	for(int i=g[x];~i;i=e[i].next)
		if(e[i].to<pre[x]){
			LL temp=dfs2(e[i].to);
			size[x]+=size[e[i].to];
			res=res*temp%P*getC(size[x],size[e[i].to])%P;
		}
	size[x]++;
	return res;
}

int main(){
#ifdef DEBUG
	freopen("F.in","r",stdin);
#endif
	memset(g,-1,sizeof g);
	scanf("%d",&n);
	init();
	n<<=1;
	for(int i=1;i<=n;i++) scanf("%d%d",&e2[i][0],&e2[i][1]);
	for(int i=1;i<=n;i++) fa[i]=i;
	for(int i=1;i<=n;i++){
		int x=e2[i][0],y=e2[i][1]+(n/2);
		addEdge(x,y);
		addEdge(y,x);
		de[x]++; de[y]++;
		if(getf(x)!=getf(y)) fa[fa[x]]=fa[y];
		else tag[x]=tag[y]=1;
	}
	for(int i=1;i<=n;i++){
		if(getf(i)!=i) de[fa[i]]+=de[i];
		dp[fa[i]]++;
		if(tag[i]) rt[fa[i]].push_back(i);
	}
	LL ans=1;
	int ts2=0;
	for(int i=1;i<=n;i++)
		if(getf(i)==i){
			if(de[i]!=dp[i]*2){
				puts("0");
				return 0;
			}
			assert(rt[i].size()==2);
			LL res=0,res1=1;
			tr.clear();
			root=rt[i][0];
			dfs(rt[i][0],rt[i][1]);
			int ts=0;
			for(int j=0;j<tr.size();j++){
				LL temp=dfs2(tr[j]);
				ts+=size[tr[j]];
				res1=res1*temp%P*getC(ts,size[tr[j]])%P;
			}
			res=(res+res1)%P;
			tr.clear();
			root=rt[i][1];
			dfs(rt[i][1],rt[i][0]);
			ts=0;
			res1=1;
			for(int j=0;j<tr.size();j++){
				LL temp=dfs2(tr[j]);
				ts+=size[tr[j]];
				res1=res1*temp%P*getC(ts,size[tr[j]])%P;
			}
			res=(res+res1)%P;
			ts2+=ts;
			ans=ans*res%P*getC(ts2,ts)%P;
		}
	printf("%lld\n",ans);
}


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

int main()
{
	int n, k;
	std::cin >> n >> k;
	std::vector<int> v(n);
	for (int i = 0; i < n; ++i)
	{
		std::cin >> v[i];
	}
	std::sort(v.begin(), v.end());
	int min = std::numeric_limits<int>::max();
	for (int i = 0; i < n && i + k - 1 < n; ++i)
	{
		min = std::min(min, v[i + k - 1] - v[i]);
	}
	std::cout << min << '\n';
	return 0;
}

Measured memory_bytes: 3796
n, k, q = map(int, input().split())
A = []
for _ in range(q):
    A += [int(input())]

from collections import Counter
poi = Counter(A).most_common()

ans = [k-q]*(n+1)

for (i, cnt) in poi:
    ans[i] += cnt

for x in ans[1:]:
    if x > 0:
        print('Yes')
    else:
        print('No')



Measured memory_bytes: 66264
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
#include <math.h>
#include <string>
#include <sstream>
#include <stack>

using namespace std;

#define ll long long

int main() {
    ll l,r;
    cin >> l >> r;
    if(r-l>5000){
        cout << 0 << endl;
    }
    else{
        ll ans=1e9;
        for(ll i=l;i<r;i++){
            for(ll j=i+1;j<=r;j++){
                ll ans1=i*j%2019;
                ans=min(ans,ans1);
            }
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int maxn=-99,sum=0,n;
int mapp[200][200];
int dp[200][200];
int main(){
cin >> n;
memset(dp,0,sizeof(dp));
for(int i=1;i<=2;i++)
{
    for(int j=1;j<=n;j++)
    {
        cin >> mapp[i][j];
    }
}
dp[1][1]=mapp[1][1];
for(int i=1;i<=2;i++)
{
    for(int j=1;j<=n;j++)
    {
        dp[i][j]=max(dp[i-1][j],dp[i][j-1])+mapp[i][j];
    }
}
cout << dp[2][n];
return 0;
}


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

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

	sort(a, a + n);

	int ans = 0;
	rep (i, n) {
		if (a[i] <= x) {
			if (i != n - 1) ans++;
			else if (a[i] == x) ans++;
			x -= a[i];				
			continue;
		}
		break;
	}

	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
n = int(input())

all_combi = pow(10,n,10**9+7)

loss_1 = pow(9,n,10**9+7)
loss_2 = pow(8,n,10**9+7)
ans = (all_combi-2*loss_1+loss_2)%(10**9+7)

if ans < 0:
    ans += 10**9+7
print(ans)

Measured memory_bytes: 61604
import java.util.Scanner;

public class Main {

	public static void main(String args[]) {

        Scanner sc = new Scanner(System.in);
        int input = sc.nextInt();

		if (input > 32 || input < 1) {
			throw new IllegalArgumentException();
		}

		int[] answers = { 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1,
				4, 1, 51 };
		System.out.println(answers[input - 1]);

	}

}

Measured memory_bytes: 21584
#include <bits/stdc++.h>
using namespace std;
 
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef pair<LL, LL> PLL;
 
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(),(c).end())
 
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
 
#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
 
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;
 
int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);
 
  int T; cin >> T;
  REP(_,T){
	int N, D; cin >> N >> D;
	--N;
	LL ans = 0;
	for(int b=1;b<128;b<<=1){
	  if(D&b){
		ans += b * (N/2*2+1);
	  }
	  else{
		ans += b * ((N+1)/2*2);
	  }
	}
	cout << ans << endl;
  }
  
  return 0;
}

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

void fnInput(llong& rnMaxNum, vector<llong>& rvnCapcty)
{
  cin >> rnMaxNum;
  
  for (llong& rnCapcty : rvnCapcty)
    cin >> rnCapcty;
}

llong fnTransptCnt(llong nMaxNum, vector<llong>& rvnCapcty)
{
  for (int i = 0; i < rvnCapcty.size() - 1; i++)   // 交通機関の容量を直前の大きさに合わせる
    if (rvnCapcty[i] < rvnCapcty[i + 1])
      rvnCapcty[i + 1] = rvnCapcty[i];
  
  vector<llong> vnTime(6);                         // 各都市への移動時間

  for (int i = 0; i < vnTime.size() - 1; i++)      // 移動時間を計算
  {
    vnTime[i + 1] = (nMaxNum + (rvnCapcty[i] - 1)) / rvnCapcty[i]; 
    vnTime[i + 1] += i;
  }
  llong nTotalTime = 0;

  for (int i = 0; i < vnTime.size() - 1; i++)      // トータル時間を計算
    nTotalTime += vnTime[i + 1] - vnTime[i];       // 各都市間へ同時に移動しているため
                                                   // 移動時間の差分を加算
  return nTotalTime;
}
 
int main()
{
  llong nMaxNum;
  vector<llong> vnCapcty(5);

  fnInput(nMaxNum, vnCapcty);
  cout << fnTransptCnt(nMaxNum, vnCapcty) << endl;

  return 0;
}

Measured memory_bytes: 3608