akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
using LL = long long;
const LL LINF = 1e18;
using namespace std;
#define COUT(v) cout<<(v)<<endl
#define CIN(n)  int(n);cin >> (n)
#define LCIN(n) LL(n);cin >> (n)
#define SCIN(n) string(n);cin >> (n)
#define YES(n) cout<<((n)? "YES" : "NO")<<endl
#define Yes(n) cout<<((n)? "Yes" : "No")<<endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) <<endl

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)

#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(obj) (obj).begin(),(obj).end()

#define P pair<LL,LL>
#define I vector<int>
#define S set<int>
#define pb(v) push_back(v)
#define V vector
#define rt return
#define rmsame(a) sort(ALL(a)),a.erase(unique(ALL(a)), a.end())

typedef string::const_iterator State;
class PalseError {};
class Edge{
public:
    LL from,to,value;
    Edge(LL a,LL b,LL c){
        from = a;
        to = b;
        value = c;
    }
    Edge(LL a,LL b){
        from = a;
        to = b;
    }
};

int main(){
    CIN(X);CIN(A);CIN(B);
    if(B <= A){
        COUT("delicious");
        return 0;
    }
    if(B <= A+X){
        COUT("safe");
    }
    if(B > A + X){
        COUT("dangerous");
    }
    return 0;
}


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

#define N 100
#define W 10000
#define MAX(X,Y) ((X)>(Y)?(X):(Y))

int main(void){
  int dp[N+1][W+1];
  int v[N+1], w[N+1];
  int n, wmax;
  
  cin >> n >> wmax;
  for (int i=1; i<=n; i++){
    cin >> v[i] >> w[i];
  }
  for (int i=0; i<=n; i++) dp[i][0] = 0;
  for (int i=0; i<=wmax; i++) dp[0][i] = 0;
  for (int i=1; i<=n; i++){
    for (int j=1; j<=wmax; j++){
      if (w[i]>j){ // can't select item[i]
        dp[i][j] = dp[i-1][j];
      } else {
        dp[i][j] = MAX(dp[i-1][j], dp[i][j-w[i]]+v[i]);
      }
    }
  }
  
/*  for (int i=0; i<=n; i++){
    for (int j=0; j<=wmax; j++){
      printf("%3d ", dp[i][j]);
    }
    cout << endl;
  }
  */
  cout << dp[n][wmax] << endl;
  return 0;
}


Measured memory_bytes: 7048
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#define FOR(i,a,b) for(int i=(a); i<(b); i++)
#define RFOR(i,a,b) for(int i=(b-1); i>=(a); i--)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define pb push_back
using ll = long long;
using D = double;
using LD = long double;
using P = pair<int, int>;
const int mod = 1e9+7;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main(){
    int n; cin >> n;
    vector<string> s(n);
    rep(i,n) cin >> s[i];
    map<string, int> mp;
    rep(i,n) mp[s[i]]++;
    int cnt = 0;
    vector<string> v;
    for(auto t : mp){
        if(cnt < t.second){
            v.clear();
            cnt = t.second;
            v.pb(t.first);
        }
        else if(cnt == t.second){
            v.pb(t.first);
        }
    }
    sort(ALL(v));
    rep(i, v.size()){
        cout << v[i] << endl;
    }
}


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

const int N = 200010;

int sz;
std::vector<int> e[N];
bool vis[N];

void dfs(int u){
    if (vis[u]){
        return;
    }
    vis[u] = true;
    ++ sz;
    for (auto v : e[u]){
        dfs(v);
    }
}

int main(){
    int n, m;
    scanf("%d%d", &n, &m);
    for (int i = 0, u, v; i < m; ++ i){
        scanf("%d%d", &u, &v);
        e[u].emplace_back(v);
        e[v].emplace_back(u);
    }
    int max = 0;
    for (int i = 1; i <= n; ++ i){
        if (vis[i]){
            continue;
        }
        sz = 0;
        dfs(i);
        max = std::max(max, sz);
    }
    printf("%d\n", max);
    return 0;
}


Measured memory_bytes: 21036
mod io{
    use std::io::*;
    pub fn read<T: ::std::str::FromStr>()->T{
        let stdin=stdin();
        let ret=stdin.lock().bytes().map(|c|c.unwrap()as char)
        .skip_while(|c|c.is_whitespace())
        .take_while(|c|!c.is_whitespace())
        .collect::<String>().parse().ok().unwrap();
        ret
    }
}
use io::read;
fn main(){
    let n=read::<i32>();
    let mut ans=1;
    for i in 2..33{
        let mut j=i*i;
        while j<=n{
            ans=if ans<j{j}else{ans};
            j*=i
        }
    }
    println!("{}",ans)
}


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

int main(int argc, char* argv[]){
	long long A, B, N;
	scanf("%lld %lld %lld", &A, &B, &N);

	double v = 0.0;
	if(N<B){ v = (double) N/B; }
	else{ v = (double) (B-1)/B; }

	long long ans = (long long)floor( (double)A*v );
	printf("%lld\n", ans);

	return 0;

}

Measured memory_bytes: 2204
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <cassert>
#include <exception>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int,int> P;
#define rep(i,a,n) for(ll i = (a);i < (n);i++)
#define per(i,a,n) for(ll i = (a);i > (n);i--)
#define lep(i,a,n) for(ll i = (a);i <= (n);i++)
#define pel(i,a,n) for(ll i = (a);i >= (n);i--)
#define clr(a,b) memset((a),(b),sizeof(a))
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define sz size()
#define print(X) cout << (X) << endl
const ll INF = 1e+9+7;
ll n,m,l;
string s,t;
ull d[100000],dp[100][100];

int main(){
  vll vec;
  cin >> n;
  rep(i,0,n){
    cin >> m;
    vec.pb(m);
  }
  sort(all(vec),greater<int>());
  m = 0;
  l = vec[0];
  ll ans = 0;
  short count = 0;
  rep(i,0,n){
    if(vec[i] == l)m++;
    else{
      if(m >= 4){
        //４つ同じやつ
        if(ans == 0)ans = l * l;
        else ans *= l;
        count += 2;
        break;
      }else if(m >= 2){
        //２つ同じやつがあったら
        if(ans != 0){
          //２つ目の辺
          ans *= l;
          count++;
          break;
        }else{
          //１つ目の辺
          count++;
          ans = l;
        }
      }
      m = 1;
      l = vec[i];
    }
  }
  print(ans);
  return 0;
}

Measured memory_bytes: 1400
import java.util.*;
// import java.util.stream.*;

public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    try {
      int h = scanner.nextInt();
      int w = scanner.nextInt();
      String[] s = new String[h];
      for (int i = 0; i < h; i++) {
        s[i] = scanner.next();
      }

      boolean[] row = new boolean[h];
      boolean[] col = new boolean[w];

      for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
          if (s[i].charAt(j) == '#') {
            row[i] = true;
            col[j] = true;
          }
        }
      }

      for (int i = 0; i < h; i++) {
        if (!row[i]) continue;
        for (int j = 0; j < w; j++) {
          if (!col[j]) continue;
          System.out.print(s[i].charAt(j));
        }
        System.out.println("");
      }
    } finally {
      scanner.close();
    }
  }
}


Measured memory_bytes: 38524
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (int i = j; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
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; }
//name[i][j]-> vvl name(i,vl(j))
//map<int,int>mp
//余りを切り上げる =>  (a + b - 1) / b 

signed main(){
	string s,t; cin>>s>>t;
	int n=stoi(s+t);
	int i=sqrt(n);
	if(i*i==n) cout<<"Yes";
	else cout<<"No";
	
	return 0;
}

Measured memory_bytes: 256
H, W = map(int, input().split())

if(H%2 != 0):
    ha = H//2+1
    hb = H//2
else:
    ha = H//2
    hb = H//2
if(W%2 != 0):
    wa = W//2+1
    wb = W//2
else:
    wa = W//2
    wb = W//2
if(H != 1 and W != 1):
    print(ha*wa+hb*wb)
else:
    print(1)

Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<map>
#include<functional>
#include<set>


#pragma region
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
#define LOWER(a,x) lower_bound(ALL(a), x) - a.begin() - 1;
#define COUNT(a,x)  upper_bound(ALL(a), x) - lower_bound(ALL(a), x);
#define MCOUNT(a,x,y) upper_bound(ALL(a), y) - lower_bound(ALL(a), x);
#define scan(x) scanf("%lld",&x);
#define inf 5555555555555555555
#define mod 1000000007
#define pi 3.14159265358979323846
#define pb push_back
#define F first
#define S second
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
typedef map<ll, ll> MAP;
typedef set<ll> SET;
ll n = 0, m = 0, ans = 0, sum = 0, cnt = 0, tmp = 0, ma = 0, mi = 0;
string s;
bool flag, ok;
ll dx[4] = { 1,-1,0,0 }, dy[4] = { 0,0,1,-1 };
ll ddx[9] = { 1,-1,0,0,1,1,-1,-1,0 }, ddy[9] = { 0,0,1,-1,1,-1,1,-1,0 };
#pragma endregion
#define MAX 111111


int main(void) {
  string ss;
  cin >> s;
  n = s.length();
  ll bit[11];
  FOR(i, 0, 1 << (n-1)) {
	ss = "";
	FOR(j, 0, n - 1) {
	  ss += s[j];
	  if (i >> j & 1) {
		ans += stoll(ss);
		ss = "";
	  }
	}
	ss += s[n - 1];
	ans += stoll(ss);
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	string s;
	cin>> s;
	string ans;
	if((0 < s[0] - '1') || (s[0] - '1' == 0 && 0 < s[1] - '2')){
		if((0 < s[2] - '1') || (s[2] - '1' == 0 && 0 < s[3] - '2')){
			ans = "NA";
		}else{
			if(s[2] == '0'&&s[3]=='0'){
				ans = "NA";
			}else{
				ans = "YYMM";
			}
		}
	}else if((0 < s[2] - '1') || (s[2] - '1' == 0 && 0 < s[3] - '2')){
		if((0 < s[0] - '1') || (s[0] - '1' == 0 && 0 < s[1] - '2')){
			ans = "NA";
		}else{
			if(s[0] == '0'&&s[1]=='0'){
				ans = "NA";
			}else{
				ans = "MMYY";
			}
		}
	}else{
		if(s[0]=='0'&&s[1]=='0'&&s[2]=='0'&&s[3]=='0'){
			ans ="NA";
		}else{
			if(s[0] == '0'&&s[1]=='0'){
				ans ="YYMM";
			}else if(s[2] == '0'&&s[3]=='0'){
				ans = "MMYY";
			}else{
				ans = "AMBIGUOUS";
			}
		}
	}
	cout<< ans <<endl;
}

Measured memory_bytes: 3640
#include<stdio.h>
int main(){
	int N; int x=0;
	int M; int y=0;
		scanf("%d %d",&N,&M);
		int i;
		
			if(N+M!=2){
				for(i=0;i<N;i++)
					x+=i;
				for(i=0;i<M;i++){
					y+=i;	
					}
					printf("%d\n",x+y);
				}
			else{
				puts("0");
			}
			return 0;
			}
	

Measured memory_bytes: 1700
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<limits>
#include<algorithm>
#include<numeric>

int main(){
    std::string S;

    std::cin >> S;

    int p = stoi(S.substr(0, 2));
    int l = stoi(S.substr(2, 2));

    if(p>=1&&p<=12&&l>=1&&l<=12) std::cout << "AMBIGUOUS" << std::endl;
    else if(p>=1&&p<=12&&(l>12||l==0)) std::cout << "MMYY" << std::endl;
    else if((p>12||p==0)&&l>=1&&l<=12) std::cout << "YYMM" << std::endl;
    else std::cout << "NA" << std::endl;

    return 0;
}

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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
typedef long long ll;


int main() {
    int A,B,C,D,E,F; cin >> A >> B >> C >> D >> E >> F;

    int ans_water = 0;
    int ans_sugar = 0;
    double ans = 0.0;
    REP(a,16){
        REP(b,16){
            REP(c,800){
                REP(d,800){
                    int f = 100*A*a + 100*B*b + C*c + D*d;
                    int e = E*(A*a + B*b) - C*c - D*d;
                    if(e>=0 && f<=F){
                        if(f*ans_sugar <= (C*c+D*d)*ans_water){
                            ans_water = f;
                            ans_sugar = C*c + D*d;
                        }
                    }
                }
            }
        }
    }
    cout << ans_water << " " << ans_sugar << endl;
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef pair<ll,ll> pll;

const ll mod=998244353;
const int nmax=100005;

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



ll pow(ll a,ll b){
   ll c=1;
  rep(i,0,b) {
    c*=(a%mod);
    c%=mod;
  }
    return c;
}

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

 ll n;
  cin >> n;
  vll d(n);
  vll cnt(n,0);   
 ll m=0;
  rep(i,0,n) {
    cin >> d[i];
    cnt[d[i]]++;
    m=max(d[i],m);
  }
  
  if(d[0]!=0||cnt[0]!=1) {
    cout << 0 << endl; 
    return 0;
  }
  
  ll res=1;
  for(ll i=1;i<m+1;i++){
   if(cnt[i]==0) {
     res*=0;
     break;
   }   
     res*=(pow(cnt[i-1],cnt[i])%mod);
   res%=mod; 
  }
  
  

  
 cout << res << endl;
  
}


Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main(void) {
	int N;
	cin >> N;
	if (N % 1000 == 0) {
		N = 0;

	}
	else {
		N = 1000- N% 1000;
	}
	cout << N << endl;
	return 0;
}

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

main() {
    int A,B,C; cin >> A >> B >> C;
    if(A*C<=B) cout << C << endl;
    else cout << B/A << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(){
  char s[100002];
  scanf("%s",s);
  int n,i,count=0;
  n=strlen(s);
  for(i=0;i<n;i++){
    if(i%2==0 && s[i]=='p')
      count--;
    else if(i%2!=0 && s[i]=='g')
      count++;
  }
  printf("%d\n",count);
  return 0;
}


Measured memory_bytes: 1828
#include <algorithm>
#include <iostream>
#include <vector>

#include <stdio.h>

using namespace std;

typedef long long ll;

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 int MAX_N = 30000;

int N;
char S[MAX_N + 1];
bool numbers[1000];

void solve() {
    char str[4];
    for (int i = 0; i < 1000; i++) {
        int ind_i = 0;
        snprintf(str, 4, "%03d", i);
        for (int j = 0; j < N; j++) {
            if (str[ind_i] == S[j]) {
                ind_i++;
                if (ind_i == 3) {
                    numbers[i] = true;
                    break;
                }
            }
        }
    }
}

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

    solve();

    int count = 0;
    for (int i = 0; i <= 1000; i++) {
        if (numbers[i]) {
            count++;
        }
    }

    cout << count << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define mod 1000000007
#define pb emplace_back
#define mp make_pair
#define fi first
#define sec second
typedef long long ll;
typedef long double  ld;
#define pii pair<ll,ll> 
#define vi vector< ll > 
#define vvi vector< vi > 
#define vpi vector< pii > 
#define vvpi vector< vpi > 
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define test(t) ll t;cin>>t;while(t--)
#define mem(a,b) memset(a,b,sizeof(a))
#define inn freopen("input.txt", "r", stdin)
#define outt freopen("output.txt", "w", stdout)
#define all(arr) arr.begin(),arr.end()
#define fr(i,n) for(ll i=0;i<(n);++i)
#define rep(i,a,b) for(ll i=a;i<=b;++i)
#define per(i,a,b) for(ll i=a;i>=b;i--)
#define remin(a,b) (a=min((a),(b)))
#define remax(a,b) (a=max((a),(b)))
#ifndef ONLINE_JUDGE
#define debarr(a,n)cerr<<#a<<":";for(int i=0;i<n;i++)cerr<<a[i]<<" ";cerr<<endl;
#define debmat(mat,row,col)cerr<<#mat<<":\n";for(int i=0;i<row;i++){for(int j=0;j<col;j++)cerr<<mat[i][j]<<" ";cerr<<endl;}
#define pr(...)dbs(#__VA_ARGS__,__VA_ARGS__)
template<class S,class T>ostream &operator<<(ostream &os,const pair<S,T> &p){return os<<"("<<p.first<<","<<p.second<<")";}
template<class T>ostream &operator<<(ostream &os,const vector<T> &p){os<<"[";for(auto&it:p)os<<it<<" ";return os<<"]";}
template<class T>ostream &operator<<(ostream &os,const set<T>&p){os<<"[";for(auto&it:p)os<<it<<" ";return os<<"]";}
template<class T>ostream &operator<<(ostream &os,const multiset<T>&p){os<<"[";for(auto&it:p)os<<it<<" ";return os<<"]";}
template<class S,class T>ostream &operator<<(ostream &os,const map<S,T>&p){os<<"[";for(auto&it:p)os<<it<<" ";return os<<"]";}
template<class T>void dbs(string str,T t){cerr<<str<<":"<<t<<"\n";}
template<class T,class...S>void dbs(string str,T t,S... s){int idx=str.find(',');cerr<<str.substr(0,idx)<<":"<<t<<",";dbs(str.substr(idx+1),s...);}
#else
#define pr(...){}
#define debarr(a,n){}
#define debmat(mat,row,col){}
#endif
ll power(ll x,ll y){ll res = 1;while(y){if(y&1) res = (res*x)%mod;y=y/2,x=(x*x)%mod;}return res%mod;}
ll n,k;
ll func(vpi arr,ll bits)
{
	if(bits==-1)
	{
		ll s = 0;
		for(auto v:arr)
			s+=v.sec;
		return s;
	}
	if(k&(1LL<<bits))
	{
		ll s = 0;
		for(auto v:arr)
		{
			if(!(v.fi&(1LL<<bits)))
				s+=v.sec;
		}
		return max(func(arr,bits-1),s);
	}
	else
	{
		vpi temp;
		for(auto v:arr)
		{
			if(!(v.fi&(1LL<<bits)))
				temp.pb(v);
		}
		return func(temp,bits-1);
	}
}
signed main()
{
    fast;
    cin>>n>>k;
    map < ll , ll > lol;
    fr(i,n)
    {
    	ll a,b;
    	cin>>a>>b;
    	lol[a]+=b;
    }
    vpi arr(lol.size());
    for(auto v:lol)
    	arr.pb(v);
    cout<<func(arr,30);
}


Measured memory_bytes: 142340
#include<stdio.h>
#include<math.h>
int main()
{
    while(1)
    {
        int n,i;   double avg, dif,sum=0.00,last,foravg=0;
      scanf("%d",&n); if(n==0) break;

      int s[n];
      for(i=1;i<=n;i++)
      {
        scanf("%d",&s[i]);
        foravg= foravg + s[i];
      }
        avg=foravg/n;

      for(i=1;i<=n;i++)
      {
          dif=avg-s[i];
          sum=sum+dif*dif;
      }
      last=sum/n;

      printf("%lf\n", sqrt(last));



    }
}



Measured memory_bytes: 2684
#include <algorithm>
#include <bits/stdc++.h>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;

#define rep(X, S, E) for (int(X) = (S); (X) < (E); ++(X))
#define rrep(X, S, E) for (int(X) = (E)-1; (X) >= (S); --(X))
#define itrep(X, Y) for (auto(X) = (Y).begin(); (X) != (Y).end(); (X)++)
#define all(X) (X).begin(), (X).end()
#define pb push_back
#define mp make_pair
#define fi first
#define sc second
#define print(x) cout << x << endl

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll INF = 9 * 1e18;
const long long MOD = 1000000007;

ll calcMulti(ll w, ll check, ll W) {
  ll multi = 0;
  for (ll i = 0; i < (1 << W - 1); i++) {
    if (((i >> w) & 1) != check) {
      continue;
    }
    bool flag = true;
    for (ll j = 0; j < W - 1; j++) {
      if (((i >> j) & 1) == 1 && ((i >> (j + 1)) & 1) == 1) {
        flag = false;
        break;
      }
    }
    if (flag) {
      multi++;
    }
  }
  return multi;
}

ll calcMulti2(ll w, ll check, ll w2, ll check2, ll W) {
  ll multi = 0;
  for (ll i = 0; i < (1 << W - 1); i++) {
    if (((i >> w) & 1) != check || (((i >> w2) & 1) != check2)) {
      continue;
    }
    bool flag = true;
    for (ll j = 0; j < W - 1; j++) {
      if (((i >> j) & 1) == 1 && ((i >> (j + 1)) & 1) == 1) {
        flag = false;
        break;
      }
    }
    if (flag) {
      multi++;
    }
  }
  return multi;
}

void solve(long long H, long long W, long long K) {
  if (W == 1) {
    print(1);
    return;
  }

  vector<vl> dp(H + 1, vl(W));
  dp[0][0] = 1;
  rep(h, 1, H + 1) {
    rep(w, 0, W) {
      if (w == 0) {
        dp[h][w] = dp[h - 1][w] * calcMulti(0, 0, W) % MOD;
        dp[h][w] += dp[h - 1][w + 1] * calcMulti(0, 1, W);
        dp[h][w] %= MOD;
      } else if (w == W - 1) {
        dp[h][w] = dp[h - 1][w] * calcMulti(w - 1, 0, W) % MOD;
        dp[h][w] += dp[h - 1][w - 1] * calcMulti(w - 1, 1, W);
        dp[h][w] %= MOD;
      } else {
        dp[h][w] = dp[h - 1][w] * calcMulti2(w - 1, 0, w, 0, W) % MOD;
        dp[h][w] += dp[h - 1][w - 1] * calcMulti(w - 1, 1, W);
        dp[h][w] %= MOD;
        dp[h][w] += dp[h - 1][w + 1] * calcMulti(w, 1, W);
        dp[h][w] %= MOD;
      }
    }
  }
  print(dp[H][K - 1]);
}

int main() {
  long long H;
  scanf("%lld", &H);
  long long W;
  scanf("%lld", &W);
  long long K;
  scanf("%lld", &K);
  solve(H, W, K);
  return 0;
}


Measured memory_bytes: 256
/*
ID: 5ak0
PROG:
LANG: C++11
*/

#include <bits/stdc++.h>
#define fr first
#define sc second
#define pb push_back
#define mpr make_pair

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
const int MOD = 1e9 + 7, MAXN = 1e5 + 15;

int n, a[MAXN], id[MAXN], l, r;
ll fac[MAXN];

ll binpow (ll a, ll n){
	ll res = 1;
	a %= MOD;
	while (n){
		if (n & 1){
			res *= a;
			res %= MOD;
		}
		a *= a;
		a %= MOD;
		n >>= 1;
	}
	return res % MOD;
}

ll cnk(ll n, ll k){
    if (n - k < 0)
        return 0;
    return ((fac[n] * binpow(fac[k], MOD - 2)) % MOD) * binpow(fac[n - k], MOD - 2) % MOD;
}

int main(){
    #ifndef SAKO
    //freopen(".in", "r", stdin);
    //freopen(".out", "w", stdout);
    #endif // SAKO
    ios_base::sync_with_stdio(0);

	fac[0] = 1;
	for (int i = 1; i <= MAXN; ++i)
        fac[i] = fac[i - 1] * i % MOD;

	cin >> n;
	for (int i = 1; i <= n + 1; ++i){
        cin >> a[i];
        if (id[a[i]])
            r = i, l = id[a[i]];
        id[a[i]] = i;
    }
    cout << n << "\n";
    for (int i = 2; i <= n + 1; ++i)
        cout << (cnk(n + 1, i) - cnk(l - r + n, i - 1) + MOD) % MOD << "\n";

    return 0;
}


Measured memory_bytes: 2816
n = int(input())
lst = list(map(int,input().split()))
flag = 1
count = 0
while flag:
    flag = 0
    for i in range(n-1,0,-1):
        if lst[i] < lst[i-1]:
            lst[i],lst[i-1] = lst[i-1],lst[i]
            flag = 1
            count = count + 1
tmp_lst = map(str,lst)
print(' '.join(tmp_lst))
print(count)



Measured memory_bytes: 5600
N,K = map(int,input().split())
A = list(map(int,input().split()))
S = sum(A)
from itertools import accumulate
def check(n):
    L = [None]*N
    for i in range(N):
        L[i] = ((A[i] % n), n - (A[i] % n))
    L.sort(key=lambda x:x[0])
    acc1 = list(accumulate([L[i][0] for i in range(N)]))
    acc2 = list(accumulate([L[i][1] for i in range(N)]))
    for i in range(N):
        if acc1[i] <= K and acc2[N-1]-acc2[i] <= K:
            return True
    return False

mx = -1
import math
for i in range(math.floor(math.sqrt(S)), 0, -1):
    if S % i == 0:
        if check (i):
            mx = max(i, mx)
        if check (S // i):
            mx = max(S // i, mx)
print(mx)

Measured memory_bytes: 44252
#![allow(unused_imports)]
use proconio::{input, fastout};
use proconio::marker::*;
use std::f64::consts::PI;

#[fastout]
fn main() {
    input! {
    a: f64,
    b: f64,
    h: f64,
    m: f64
    }
    let mp = 2.0 * PI * m / 60.0 + PI;
    let hp = 2.0 * PI * (60.0 * h + m) / 720.0 + PI;
    let (hx, hy) = (a * hp.cos(), a * hp.sin());
    let (mx, my) = (b * mp.cos(), b * mp.sin());
    let ans = ((hx - mx).powi(2) + (hy - my).powi(2)).sqrt();
    println!("{}", ans);
}


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

long long D,T,S;

void Input(){
	cin>>D>>T>>S;
}

void Solve(){
	if(T*S>=D){
		cout<<"Yes"<<'\n';
	}else{
		cout<<"No"<<'\n';
	}
}

int main(){
	Input();
	Solve();
}

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

vector<ll> links;
vector<ll> sizes;

ll root(ll z) {
    while (z!=links[z]) z = links[z];
    return z;
}

int main() {
    ll n, m, a, b;
    cin >> n >> m;
    ll res = n*(n-1)/2;
    vector<pair<ll,ll>> edges;
    for (ll i=0; i<m; i++) {
        cin >> a >> b;
        edges.push_back(make_pair(a,b));
    }
    for (ll i=0; i<=n; i++) {
        links.push_back(i);
        sizes.push_back(1);
    }
    vector<ll> result;
    for (ll i=m-1; i>=0; i--) {
        result.push_back(res);
        ll x = root(edges[i].first);
        ll y = root(edges[i].second);
        if (x==y) continue;
        res-=(sizes[x]*sizes[y]);
        if (sizes[x]<sizes[y]) swap(x,y);
        sizes[x]+=sizes[y];
        links[y] = x;
    }
    for (ll i=m-1; i>=0; i--) cout << result[i] << endl;
    return 0;
}

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

int main() {
  int n,m10,other,min;
  cin>>n;
  vector<int> a(n);
  m10=other=0;
  min=10000;
  for(int i=0;i<n;i++){
    cin>>a[i];
    if(a[i]%10==0)m10+=a[i];
    else{
      other+=a[i];
      if(a[i]<min)min=a[i];
    }
  }
  if(other%10==0 && other!=0)other-=min;
  if(other==0)cout<<0<<endl;
  else cout<<m10+other<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

int main(void){
    int val;

    scanf("%d", &val);

    if(val % 2){
        //printf("%d = kisuu \n", val);//
        int answer = val * 2;
        printf("%d \n", answer);
    }else{
        //printf("%d = guusu \n", val);//
        printf("%d \n", val);
    }

}

Measured memory_bytes: 128
// ABC058B - 

#include <bits/stdc++.h>
using namespace std;

typedef unsigned long long int ull;
typedef long long int ll;

int main() {
	string O, E;
	cin >> O >> E;

	for (int i = 0; i < O.size(); i++) {
		cout << O[i];
		if (i >= E.size()) {
			break;
		}
		cout << E[i];
	}
	cout << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, K;
  cin >> N >> K;
  int z = 0;
  for(int i=0; i<N; i++){
    int y;
    cin >> y;
    if(K>=y*2){
      z += y;
    }
    else{
      z += K-y;
    }
  }
  cout << z*2 << endl;
}


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

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

const ll INF=1001001001;

int main(){
   int n;
   cin>>n;
   int k;
   cin>>k;
   vector<int>h(n);
   rep(i,n)cin>>h[i];
   vector<ll>dp(n);
   rep(i,n)dp[i]=INF;
   dp[0]=0;
   for(ll i=0;i<(n);i++){
       for(int j=1;j<=k;j++){
         if(i+j>=n)break;
         else{
             chmin(dp[i+j],dp[i]+abs(h[i]-h[i+j]));
         }
       }
   }
   ll ans=dp[n-1];
   cout<<ans<<endl;
}

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

int main()
{
    int n;
    string s;
    cin >> n >> s;
    rep(i, s.size())
    {
        s[i] = s[i] - 'A';
        s[i] = (s[i] + n) % 26;
        s[i] = s[i] + 'A';
    }
    cout << s << endl;
    return 0;
}


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

using namespace std;
#define DBG(x)                         \
    (void)(cout << "L" << __LINE__     \
                << ": " << #x << " = " \
                << (x) << '\n')
typedef long long ll;
const int INF = 0x3f3f3f3f;
const int maxn = 110000;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setiosflags(ios::fixed) << setprecision(12);
    ll n, a, b;
    cin >> n >> a >> b;
    ll cur1 = n / (a + b);
    ll ans1 = cur1 * a;
    if (n % (a + b) == 0)
    {
        cout << ans1 << "\n";
    }
    else
    {
        ll cur2 = n - cur1 * (a + b);
        if (cur2 <= a)
            ans1 += cur2;
        else
            ans1 += a;
        cout << ans1 << "\n";
    }
    return 0;
}

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

using namespace std;


#define PI 3.14159265
#define int long long



main(){


	int n, m; cin >> n >> m;

	vector <int> a(n);

	for(int i = 0; i < n; i++){
		cin >> a[i];
	}

	int sum = accumulate(a.begin(), a.end(), 0LL);

	int cnt = 0;
	for(int i = 0; i < n; i++){
		if(a[i] * 4 * m >= sum){
			cnt++;
		}
	}

	cout << (cnt >= m ? "Yes" : "No") << endl;
	
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
//#undef int
#define mk make_pair
#define pb push_back
typedef pair<int, int> pii;
const int mod = 1000000007;
const int INF = 1000000009;
const long long INFL = 1000000000000000018ll;

int N, a[100100], b[100100], c[100100];
int dp[100100][3];

signed main()
{
    cin >> N;
    for(int i = 0; i < N; i++){
        cin >> a[i] >> b[i] >> c[i];
    }
    for(int i = 0; i < N; i++){
        int x = dp[i][0];
        int y = dp[i][1];
        int z = dp[i][2];
        dp[i + 1][0] = max(y, z) + a[i];
        dp[i + 1][1] = max(x, z) + b[i];
        dp[i + 1][2] = max(y, x) + c[i];
    }
    cout << max(dp[N][0], max(dp[N][1], dp[N][2])) << endl;

    return 0;
}
/*



*/



Measured memory_bytes: 4992
import math

a,b,c = map(float,input().split())

S= (a*b*math.sin(math.radians(c)))/2
C=math.sqrt(a**2+ b**2 - 2*a*b*math.cos(math.radians(c)))
L=C+a+b
h=S*2/a

print(f'{S:.08f}')
print(f'{L:.08f}')
print(f'{h:.08f}')


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

int main() {
  int n;
  cin >> n;
  int a[101];
  for (int i=0; i < n; i++) cin >> a[i];
  sort(a, a + n, greater<int>()); //a[0:N]を大きい順にソート
  int sum_a = 0;
  int sum_b = 0;
  for (int i=0; i < n; i++) {
      if(i%2==0) sum_a += a[i];
      else sum_b += a[i];
  }
  cout << sum_a-sum_b << endl;
}

Measured memory_bytes: 3624
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>

#define _USE_MATH_DEFINES

using namespace std;

int main(){
	
	while(true){
		
		int m, n;
		
		cin >> m;
		
		if(m == 0){
			break;
		}
		
		vector<int> v1, v2;
		
		int count = 0;
		
		for(int i = 0; i < m - 1; i++){
			int num;
			cin >> num;
			count += num;
			v1.push_back(num);
		}
		
		v1.push_back(360 - count);
		
		cin >> n;
		
		count = 0;
		
		for(int i = 0; i < n - 1; i++){
			int num;
			cin >> num;
			count += num;
			v2.push_back(num);
		}
		
		v2.push_back(360 - count);
		
		double sum1 = 0;
		double sum2 = 0;
		
		sort(v1.begin(), v1.end());
		sort(v2.begin(), v2.end());
		
		for(int i = 0; i < m; i++){
			sum1 += sin(double(v1[i]) * M_PI / 180);
		}
		
		for(int i = 0; i < n; i++){
			sum2 += sin(double(v2[i]) * M_PI / 180);
		}
		
		if(sum1 == sum2){
			cout << "0" << endl;
		}else if(sum1 > sum2){
			cout << "1" << endl;
		}else{
			cout << "2" << endl;
		}
		
	}
	
	return 0;
}

Measured memory_bytes: 3300
MOD = 1000000007

pascal = [[0 for i in range(2001)] for j in range(2001)]
for i in range(2001):
  pascal[i][0] = 1
  for j in range(1,2001):
    pascal[i][j] = (pascal[i-1][j-1]+pascal[i-1][j])%MOD
n,k = map(int,input().split())
for i in range(1,k+1):
  print((pascal[n-k+1][i]*pascal[k-1][i-1])%MOD)

Measured memory_bytes: 99172
#include <bits/stdc++.h>
const char nl = '\n';
using namespace std;
typedef long long ll;
typedef long double ld;
typedef complex<ld> pt;
const int MOD = 1e9 + 7;
const int INF = 0x3f3f3f3f;
const int N = 3010;
inline char get() {
	static char buf[10000], *S = buf, *T = buf;
	if (S == T) {
		T = (S = buf) + fread(buf, 1, 10000, stdin);
		if (S == T) return EOF;
	}
	return *S++;
}
char c;
inline void read(int &x) {
	x = 0; int sgn = 0;
	for (c = get(); c < '0' || c > '9'; c = get()) if (c == '-') sgn = 1;
	for (; c >= '0' && c <= '9'; c = get()) x = x * 10 + c - '0';
	if (sgn) x = -x;
}
inline void read(string& s) {
  for (c = get(); c == ' ' || c == '\n'; c = get());
  for (; c != ' ' && c != '\n'; c = get()) s.push_back(c);
}

string s, t;
short dp[N][N];

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  read(s); read(t);
  int n = s.size(), m = t.size();
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
      if (s[i-1] == t[j-1]) {
        dp[i][j] = max(dp[i][j], short(dp[i-1][j-1] + 1));
      }
    }
  }
  string ans;
  int ci = n, cj = m;
  while (ci && cj) {
    if (dp[ci-1][cj] == dp[ci][cj]) {
      ci--;
    } else if (dp[ci][cj-1] == dp[ci][cj]) {
      cj--;
    } else {
      //assert(s[ci-1] == t[cj-1] && dp[ci-1][cj-1] + 1 == dp[ci][cj]);
      ans.push_back(s[ci-1]);
      ci--;
      cj--;
    }
  }
  reverse(ans.begin(), ans.end());
  cout << ans << nl;
  return 0;
}


Measured memory_bytes: 17920
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		String s = sc.next();
		if(s.charAt(A)!='-') {
			System.out.println("No");
			return ;
		}
		for (int i=0;i<s.length();i++) {
			if (i!=A) {
				if (s.charAt(i)<'0'||s.charAt(i)>'9') {
					System.out.println("No");
					return ;
				}
			}
		}
		System.out.println("Yes");
		return ;
	}
}

Measured memory_bytes: 35856
a,b=list(map(int,input().split()))

min_a=a*12.5
min_b=b*10

if min_b-min_a<12.5 and min_a<=min_b:
    print(str(min_b))

elif min_a-min_b<10 and min_b<=min_a:
    if a%2==1:
        print(str(int(min_a)+1))
    else:
        print(str(int(min_a)))
else:
    print(str(-1))

Measured memory_bytes: 3064
char buf[1<<17],*p=buf,f[9];
s,i;
main()
{
	read(0,buf,1<<17);
	while(*p++!='\n');
	for(;*p>'\n';++p)s+=*p!=p[-1];
	do{
		f[i++]=s%10+'0';
		s/=10;
	}while(s);
	p=buf;
	s=i;
	while(i--)*p++=f[i];
	write(1,buf,s);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ms(a,b)         memset(a, b, sizeof(a))
#define pb(a)           push_back(a)
#define db              double
#define ll              long long
#define loop(i,e,n)      for(int i=e;i<=n;i++)
#define TEST_CASE(t)    for(int z=1;z<=t;z++)
ll PowFun(ll base, ll power){ll ans = 1;for(int i = 1; i <= power; i++){ans *= base;}return ans;}
double phi = acos(-1);
using namespace std;



    int main()
    {
        int n; cin>>n;
        string str;
        if(n <= 1000)
            cout<<1000-n<<endl;
        else
        {
            if(n % 1000 == 0) cout<<0<<endl;
            else
            cout<<1000-(n%1000)<<endl;
        }
    }



Measured memory_bytes: 3620
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

int main()
{
	ll A, B, C, K;
	cin >> A >> B >> C >> K;
	if (K % 2 == 0) cout << A - B;
	else cout << B - A;
}

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

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            var str = Console.ReadLine();
            if (str == "Sunny")
            {
                Console.WriteLine("Cloudy");
            }
            if (str == "Cloudy")
            {
                Console.WriteLine("Rainy");
            }
            if (str == "Rainy")
            {
                Console.WriteLine("Sunny");
            }
        }
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
#include <iostream>
#define IOS ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define INF 1350851717672992089
#define ll long long int
#define ld long double
#define pi pair<int, int>
#define vi vector<ll>
#define vp vector<pair<ll, ll>>
#define pb push_back
#define mp make_pair
#define M 1000000007
#define F first
#define S second
using namespace std;
int main()
{
    ll n,w;
    cin>>n>>w;
    vp v;
    v.pb(mp(0,0));
    ll sum=0;
    for (int i=1; i<=n; i++)
    {
        int x,y;
        cin>>x>>y;
        v.pb(mp(x,y));
        sum=sum+y;
    }
    //cout<<sum<<endl;
    ll dp[n+1][sum+1];
    for (int i=0; i<=n; i++)
        for (int j=0; j<=sum; j++)
            dp[i][j]=M;
    for (int i=0; i<=n; i++)
        dp[i][0]=0;
    for (int i=1; i<=n; i++)
    {
        for (int j=1; j<=sum; j++)
        {
            if(j<v[i].S)
                dp[i][j]=dp[i-1][j];
            else
                dp[i][j]=min(dp[i-1][j],
                dp[i-1][j-v[i].S]+v[i].F);
        }
    }
    for (int i=sum; i>=0; i--)
    {
        if(dp[n][i]<=w)
        {
            cout<<i<<endl;
            return 0;
        }
    }
}

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

namespace ALDS1_3_C
{
    class Program
    {
        static void Main(string[] args)
        {
            var linkedList = new LinkedList<int>();
            var n = int.Parse(Console.ReadLine());
            for(int i=0; i<n; i++)
            {
                var command = Console.ReadLine().Split(' ');
                string commandType = command[0];
                int value = 0;
                if((commandType == "insert") || (commandType == "delete"))
                {
                    value = int.Parse(command[1]);
                }

                switch (commandType)
                {
                    case "insert":
                        linkedList.AddFirst(value);
                        break;
                    case "delete":
                        linkedList.Remove(value);
                        break;
                    case "deleteFirst":
                        linkedList.RemoveFirst();
                        break;
                    case "deleteLast":
                        linkedList.RemoveLast();
                        break;
                    default:
                        Console.WriteLine("正しいコマンドを入力してください");
                        break;
                }
            }
            Console.WriteLine(string.Join(" ", linkedList));
        }
    }
}



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

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    vector<int> b(n);
    vector<int> ans;
    int m = 0;
    for (int i = n-1; i >= 0; --i) {
        if (a[i] == 1) {
            int s = 0;
            rep(j, n/(i+1)) {
                if (b[(i+1) * (j+1) - 1]) s++;
            }
            if (s % 2 == 0) {b[i] = 1; m++; ans.push_back(i+1);}
        }
        else {
            int s = 0;
            rep(j, n/(i+1)) {
                if (b[(i+1) * (j+1) - 1]) s++;
            }
            if (s % 2 == 1) {b[i] = 1; m++; ans.push_back(i+1);}
        }
    }
    cout << m << endl;
    if (m != 0) {
        rep(i, ans.size()-1) cout << ans[i] << " ";
        cout << ans[ans.size()-1] << endl;
    }
}

Measured memory_bytes: 3064
import math
import collections
import fractions
import itertools
import functools
import operator
import bisect

def divis(l):
    seq = []
    beg, end = 0, 0
    le = len(l)
    for i in range(1,le):
        end = i
        if l[i] < l[i-1]:
            seq.append(l[beg:end])
            beg = i
    seq.append(l[beg:end+1])
    return seq

def solve():
    n = int(input())
    a = list(map(int, input().split()))
    divia = divis(a)
    saihu = 1000
    for i in divia:
        saihu += (i[-1]-i[0])*(saihu//i[0])
    print(saihu)
    return 0

if __name__ == "__main__":
    solve()

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reprv(i, n) for (int i = n - 1; i >= 0; i--)
#define ll long long
using namespace std;


int main() {
    int n,m;

    cin >> n >> m;

    rep (i, m) {
        int k;
        cin >> k;
        n = n - k;
        if (n < 0) {
            cout << -1 << endl;
            return 0;
        }
    }

    cout << n << endl;

    return 0;
}


Measured memory_bytes: 3632
import java.util.*;

 // Compiler version JDK 11.0.2

 public class Main
 {
   public static void main(String args[])
   { 
    Scanner sc= new Scanner(System.in);
    int s = sc.nextInt();
    int w = sc.nextInt();
    if(w>=s)
    System.out.println("unsafe");
    else
    System.out.println("safe");
   }
 }


Measured memory_bytes: 35708
#include <bits/stdc++.h>
#define pb push_back
#define S second
#define F first

using namespace std;
typedef long long ll;
#define int ll
typedef pair<int,int> pii;
const int maxn = 2e5 + 20;
const int mod  = 1e9  + 7;
map<int,int> mp;
set<int> st;
int seq[maxn];
int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(false);
    int n,k;
    cin >> n >> k;
    vector<int> v;
    for (int i  = 0;i < n;i++){
        cin >> seq[i];
        mp[seq[i]]++;
    }
    for (int i= 0;i < n;i++){
        if (st.find(seq[i]) != st.end()) continue;
        v.pb(-mp[seq[i]]);
        st.insert(seq[i]);
    }
    sort(v.begin(),v.end());
    int sum = 0;
    for (int i = 0;i < min((int)v.size(),k);i++){
        sum += v[i];
    }
    cout << n + sum << endl;
    return 0;
}


Measured memory_bytes: 25204
#include<bits/stdc++.h> //Ithea Myse Valgulious
namespace chtholly{
typedef long long ll;
#define re0 register int
#define rec register char
#define rel register ll
#define gc getchar
#define pc putchar
#define p32 pc(' ')
#define pl puts("")
/*By Citrus*/
inline int read(){
  int x=0,f=1;char c=gc();
  for (;!isdigit(c);c=gc()) f^=c=='-';
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  return f?x:-x;
  }
template <typename mitsuha>
inline bool read(mitsuha &x){
  x=0;int f=1;char c=gc();
  for (;!isdigit(c)&&~c;c=gc()) f^=c=='-';
  if (!~c) return 0;
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  return x=f?x:-x,1;
  }
template <typename mitsuha>
inline int write(mitsuha x){
  if (!x) return 0&pc(48);
  if (x<0) x=-x,pc('-');
  int bit[20],i,p=0;
  for (;x;x/=10) bit[++p]=x%10;
  for (i=p;i;--i) pc(bit[i]+48);
  return 0;
  }
inline char fuhao(){
  char c=gc();
  for (;isspace(c);c=gc());
  return c;
  }
}using namespace chtholly;
using namespace std;

int main(){
ll n=read(),m=read(),d=read();
printf("%.10lf",1.0*((d!=0)+1)*(n-d)*(m-1)/(n*n));
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <map>
#include <limits>
#include <cmath>
#include <iomanip>
#include <functional>
#include <random>
#include <set>
using namespace std;
using ll = long long;
ll BASE_NUM = 2000000007;

int main()
{
  // 整数の入力
  ll N;
  cin >> N;
  vector<ll> A(N);
  ll all_xor = 0;
  for (int i = 0; i < N; i++)
  {
    cin >> A[i];
    all_xor ^=  A[i];
  }
  for(int i = 0;i < N;i++){
    if (i != 0){
      cout << " ";
    }
    cout << (all_xor ^ A[i]);
  }
  cout << endl;
  return 0;
}


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

int cnt[108];

using namespace std;

int main(){

  int n;

  string s;

  cin>>n>>s;

  for(char c:s){

   cnt[c]++;

  }

  long long ans = 1;

  long long mof=1e9+7;

  for(char c = 'a';c<='z';c++){

    ans*=cnt[c]+1;

    ans%= mof;

  }

  cout<<(ans-1+mof)%mof<<endl;

}



Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define erep(i,a,b) for(int i=a;i<=(int)(b);++i)
#define per(i,a,b) for(int i=(b);i>(a);--i)
#define eper(i,a,b) for(int i=((int)(a));i>=b;--i)
#define pb push_back
#define mp make_pair
#define INF 2000000000
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a, b)*b;}

int V, E, d[110][110];
int main() {
 ios::sync_with_stdio ( false );
 cin.tie ( 0 );
    cin >> V >> E;
    rep(i, 0, V) rep(j, 0, V) {
        d[i][j] = INF;
        d[i][i] = 0;
    }
    rep(i, 0, E) {
        int s, t, u;
        cin >> s >> t >> u;
        d[s][t] = u;
    }
    rep(k, 0, V) rep(i, 0, V) rep(j, 0, V) {
        if (d[i][k] != INF && d[k][j] != INF) {
            d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
        }
    }
    rep(i, 0, V) {
        if (d[i][i] < 0) {
            printf("NEGATIVE CYCLE\n");
            return 0;
        }
    }
    rep(i, 0, V) {
        rep(j, 0, V) {
            if (d[i][j] != INF) printf("%d", d[i][j]);
            else printf("INF");
            if (j != V-1) printf(" ");
            else printf("\n");
        }
    }
    return 0;
}


Measured memory_bytes: 3272
n,k = (int(x) for x in input().split())
lr = []
for _ in range(k):
    l,r = (int(x) for x in input().split())
    lr.append((l,r))
lr.sort()

mod = 998244353

dp= [0]*(n+1)
dp[1] = 1

for i in range(2,n+1):
    cnt = 0
    for l,r in lr:
        if l >= i:
            break
        else:
            cnt += dp[i-l] - dp[max(0,i-r-1)]
    dp[i] = (dp[i-1] + cnt) % mod

print(cnt%mod)

Measured memory_bytes: 16948
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, i;
  
  cin >> N;
  
  vector<int> A(N);
  
  for (i = 0; i < N; i++){
    cin >> A.at(i);
  }
  
  int even_count;
  even_count = 0;
  for (i = 0; i < N; i++){
    if (A.at(i) % 2 == 0) even_count++;
  }
  
  int ap_count;
  ap_count = 0;
  for (i = 0; i < N; i++){
    if ((A.at(i) % 6 == 0) || (A.at(i) % 10 == 0)) ap_count++;
  }
  
  if (even_count == ap_count) cout << "APPROVED" << endl;
  else cout << "DENIED" << endl;
}

Measured memory_bytes: 256
# 500 M	1000 M
# AAA 級	35 秒 50	1 分 11 秒 00
# AA 級	37 秒 50	1 分 17 秒 00
# A 級	40 秒 00	1 分 23 秒 00
# B 級	43 秒 00	1 分 29 秒 00
# C 級	50 秒 00	1 分 45 秒 00
# D 級	55 秒 00	1 分 56 秒 00
# E 級	1分10 秒 00	2 分 28 秒 00

ranks = ["AAA","AA","A","B","C","D","E","NA"]
timesA = [35.50,37.50,40,43,50,55,70]
timesB = [71,77,83,89,105,116,148]

while(1):
    try:
        a,b = (float(x) for x in input().split())
        rankA = rankB = 7
        # checkA
        for i in range(0,7):
            if timesA[i] > a:
                rankA = i
                break
        # checkB
        for i in range(rankA,7):
            if timesB[i] > b:
                rankB = max(rankA,i)
                break
        print(ranks[rankB])
    except:
        break


Measured memory_bytes: 5580
#include <iostream>
#include <math.h>
#include <algorithm>
#include <set>
#include <map>
#include <string>
using namespace std;
typedef long long ll;
#define rep(i,s,n)for(ll i=s;i<n;i++)
#define repe(i,s,n)for(ll i=s;i<=n;i++)
#define rep_r(i,s,n)for(ll i=n-1;i>=s;i--)
#define repe_r(i,s,n)for(ll i=s;i<=n;i++)
static const ll MOD = 1e9 + 7;
static const ll MAX_L = (ll)1 << 62;

ll c[10][10];
void wf() {
	rep(k, 0, 10) {
		rep(i, 0, 10) {
			rep(j, 0, 10) {
				c[i][j] = min(c[i][j], c[i][k] + c[k][j]);
			}
		}
	}
}
int main() {
	ll h, w; cin >> h >> w;
	rep(i, 0, 10)rep(j, 0, 10)cin >> c[i][j];
	wf();
	ll ans = 0;
	rep(i, 0, h)rep(j, 0, w) {
		ll a; cin >> a;
		if (a != -1 && a != 1) {
			ans += c[a][1];
		}
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, k, n) for (int i = (int)(k); i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n)-1; i >= 0; i--)
#define rREP(i, k, n) for (int i = (int)(n)-1; i >= k; i--)

#define fi first
#define se second

#define vi vector<int>
#define pb push_back
#define mp make_pair

#define pcnt __builtin_popcount

typedef long long ll;

const int inf = 100100100;
const int MOD = (int) 1e9 + 7;
const double EPS = 1e-9;

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

template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b;return 1; }return 0; }
int main() {
    int N,x;
    cin >> N >> x;
    int cnt = 0;
    int a[110];
    rep(i,N) cin >> a[i];
    sort(a,a+N);
    rep(i,N){
        if(x<a[i]) break;
        if(i==N-1&&x!=a[i]) break;
        x-=a[i];
        cnt+=1;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256