akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin>>s;
    if(s[0]=='Y' and s[1]=='A' and s[2]=='K' and s[3]=='I')
        cout<<"Yes\n";
    else
        cout<<"No\n";
   return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define M 100005
using namespace std;
struct ll{
	int a,b;
	bool operator <(const ll x)const{
		if(b!=x.b)return b>x.b;
		return a>x.a;
	}
}A[M];
int f[M];
int getfa(int x){
	if(f[x]==x)return x;
	return f[x]=getfa(f[x]);
}
int main(){
	int n,m;
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)scanf("%d%d",&A[i].a,&A[i].b);
	for(int i=1;i<=m;i++)f[i]=i;
	sort(A+1,A+n+1);
	int ans=0;
	for(int i=1;i<=n;i++){
		if(A[i].a>m)continue;
		int k=getfa(m-A[i].a+1);
		if(k==0)continue;
		f[k]=getfa(k-1);
		ans+=A[i].b;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 1408
public class A
{
    public static void Main()
    {
        string str = System.Console.ReadLine();
        string[] istr = str.Split(' ');
        int a = int.Parse(istr[0]);
        int b = int.Parse(istr[1]);
        System.Console.WriteLine((a * b) + " " + (a + a + b + b));
    }
}


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

double dp[2][1 << 16][16];
double memo[1 << 16];

int main() {
    int m, n;
    cin >> m >> n;
    vector<vector<double>> p(m, vector<double>(n));
    for(int i = 0; i < m; ++i) {
        for(int j = 0; j < n; ++j) {
            cin >> p[i][j];
        }
    }
    for(int S = 1; S < (1 << m); ++S) {
        for(int i = 0; i < m; ++i) {
            dp[n & 1][S][i] = 1;
        }
    }
    for(int i = n - 1; i >= 0; --i) {
        for(int S = 0; S < (1 << m); ++S) {
            for(int j = 0; j < m; ++j) {
                dp[i & 1][S][j] = 0;
            }
            for(int j = 0; j < m; ++j) {
                if(!((S >> j) & 1)) {
                    continue;
                }
                dp[i & 1][S][j] = dp[(i + 1) & 1][S][j] * p[j][i] + memo[S & ~(1 << j)] * (1 - p[j][i]);
            }
            double ma = 0;
            for(int j = 0; j < m; ++j) {
                if((S >> j) & 1) {
                    ma = max(ma, dp[i & 1][S][j]);
                }
            }
            memo[S] = ma;
        }
    }
    double res = *max_element(begin(dp[0][(1 << m) - 1]), end(dp[0][(1 << m) - 1]));
    cout << fixed << setprecision(10) << res << endl;
}


Measured memory_bytes: 20144
#include <iostream>
#include <algorithm>
using namespace std;
int N, K, A[100'000];
int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);

    cin>>N>>K;
    for(int n = 0; n < N; n++) cin>>A[n];
    cout<<(N+K-3)/(K-1)<<'\n';

    return 0;
}

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

int main() {
  long Q, H, S, D, N;
  cin >> Q >> H >> S >> D >> N;
  long ans, minprice = min({Q*4, H*2, S});
  if (min(minprice*2, D) == D) {
    ans += N / 2 * D;
    if (N % 2) ans += minprice;
    cout << ans << endl;
    return 0;
  }
  cout << N * minprice << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, o, n) for (auto i = (o); (i) < (n); ++(i))
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (auto i = (n)-1; (i) >= 0; --i)
#define REPI(itr, v) for (auto itr = v.begin(); itr != v.end(); ++itr)
#define REPIR(itr, v) for (auto itr = v.rbegin(); itr != v.rend(); ++itr)
#define fi first
#define se second
#define ll long long
#define V2(name, h, w) vector<vector<int> > name((h), vector<int>(w));
int main(){
	int N, Q; cin >> N >> Q;
	string S; cin >> S;

	vector<int> v(S.size());
	int sum = 0;
	REP(i, S.size()-1){
		if(S[i] == 'A' and S[i+1] == 'C') ++sum; 
		v[i+1] = sum;
	}

	REPI(i, v) cerr << *i << ' '; cerr << endl;
	REP(i, Q){
		int l, r; cin >> l >> r;
		cout << v[r-1] - v[l-1] << endl;
	}

}


Measured memory_bytes: 1408
#include<stdio.h>

int main(void){
    int H,A[100000],N,i,n=0;
    scanf("%d%d",&H,&N);
    for(i=0;i<N;i++){
        scanf("%d",&A[i]);
        n=n+A[i];
    }
    if(H-n<=0)
    printf("Yes");
    else
    printf("No");
    return 0;
}


Measured memory_bytes: 512
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using uint = unsigned int;
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printe) FUNC(printw) FUNC(printew) FUNC(printb) FUNC(printd) FUNC(printde);
#endif

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s; cin >> s;
    if(s.find("AC") != string::npos){
        cout << "Yes" << '\n';
    }else{
        cout << "No" << '\n';
    }
}


Measured memory_bytes: 888
#define _USE_MATH_DEFINES
#include <array>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>
#include <tuple>
#include <utility>

using namespace std;

template <typename A, typename B>
string to_string(pair<A, B> p);
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);
 
string to_string(const string& s) {
  return '"' + s + '"';
}
 
string to_string(const char* s) {
  return to_string((string) s);
}
 
string to_string(bool b) {
  return (b ? "true" : "false");
}
 
string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}
 
template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}
 
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
 
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}
 
void debug_out() { cerr << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
 
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

typedef long long int64;
typedef pair<int, int> pii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  for (int i = 1; i < 10; ++i) {
    if (n % i == 0 && n / i < 10) {
      puts("Yes");
      return 0;
    }
  }
  puts("No");
  return 0;
}



Measured memory_bytes: 256
#define _GLIBCXX_DEBUG//TLEの原因になるので注意！！！！！！！！！！！
#include<cmath>
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
vector<int> arr;
stack<int> st;
queue<int> qu;
queue<pair<int,int> > qu2;
priority_queue<int> pq;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rep2(i,n) for(int i=1; i<=(int)(n); i++)
#define mins(x,y) x=min(x,y)
#define maxs(x,y) x=max(x,y)
typedef set<int> set_t;
typedef set<string> set_g;
typedef complex<double> xy_t;
static const int NIL = -1;
static const int INF = 1000000007;
#define mp make_pair
#define sz(x) int(x.xise())
#define mod 1000000007
#define reps(i,s,n) for(int i = s; i < n; i++)
deque<int> deq;
//#define int long long

//cerrはコメントアウトしなくても通る//ただしTLEを引き起こすことがある

ll dp[100005];
ll l[100005];

int main(){
    int n,m;
    cin >> n>> m;
    string s;
    cin >> s;
    //cerr<<s<<endl;
    int now=n;
    while(now!=0){
        int temp=now-m;
        if(temp<0){
            temp=0;
        }
        //cerr<<s[temp]<<endl;
        while(s[temp]!='0'){
            temp++;
            if(temp==now){
                cout<<-1<<endl;
                return 0;
            }
        }
        st.push(now-temp);
        now=temp;
    }
    cerr<<st.size()<<endl;
    while(!st.empty()){
        int ans=st.top();
        st.pop();
        cout<<ans<<endl;
    }
    return 0;
}

Measured memory_bytes: 876
# 無駄なところも数えて良いっていう考え方もある。
# 常に最適化しないといけないわけではない

N, K = map(int, input().split())
x = [int(i) for i in input().split()]

time = 10 ** 20

for i in range(N - K + 1):
    x_min = x[i]
    x_max = x[i + K - 1]
    if x_min >= 0:
        this_time = x_max
    elif x_max <= 0:
        this_time = abs(x_min)
    else:
        this_time = x_max - x_min + min(x_max, abs(x_min))

    if time > this_time:
        time = this_time

print(time)

Measured memory_bytes: 14252
//#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <climits>
#include <iomanip>

using namespace std;

#define FAST       			ios_base :: sync_with_stdio(false); cin.tie(NULL); 
#define endl "\n"

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

ll gcd(ll a, ll b){ 
    if (a == 0) 
        return b;  
    return gcd(b % a, a);  
 } 
     
 ll lcm(ll a, ll b)  
 {  
    return (a*b)/gcd(a, b);  
 }  


int main()
{
	FAST;
	ll a,b;
	cin >> a >> b;

	cout << lcm(a , b);
	return 0;
}

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

int main(){
  ll n;cin>>n;
  vector<ll> v(5,0);
  
  rep(i,n){
    string s;cin>>s;
    if (s.at(0) == 'M'){
      v.at(0)++;
    }
    else if (s.at(0) == 'A'){
      v.at(1)++;
    }
    else if (s.at(0) == 'R'){
      v.at(2)++;
    }
    else if (s.at(0) == 'C'){
      v.at(3)++;
    }
    else if (s.at(0) == 'H'){
      v.at(4)++;
    }
  }
  ll ans = 0;
  for (int bit = 0;bit<(1<<5); bit++){
    ll sum = 1;
    int a = 0;
    rep(i,5){
      if (bit & (1<<i)){
        a++;
        sum*=v.at(i);
      }
    }
    if (a==3){
      ans+=sum;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int N=300009;
int n,a[N],maxi[N<<3],val,locate,l,r,len=0,k,ans=0;
void update(int o,int left,int right)
{
    int lc=o*2,rc=o*2+1,mid=(left+right)/2;
    if(left==right)
    {
        maxi[o]=val;
    }
    else
    {
        if(locate<=mid)
            update(lc,left,mid);
        else
            update(rc,mid+1,right);
        maxi[o]=max(maxi[lc],maxi[rc]);
    }
}
int query(int o,int left,int right)
{
    int lc=o*2,rc=o*2+1,mid=(left+right)/2;
    if(l<=left&&r>=right)
    {
        return maxi[o];
    }
    else
    {
        int res=0,res1=0;
        if(l<=mid)
            res=query(lc,left,mid);
        if(r>mid)
            res1=query(rc,mid+1,right);
        return max(res,res1);
    }
}
int main()
{
    scanf("%d%d",&n,&k);
    for(int i=1; i<=n; i++)
        scanf("%d",&a[i]),a[i]++,len=max(a[i],len);
    for(int i=1; i<=(n<<3); i++)
        maxi[i]=0;
    for(int i=1; i<=n; i++)
    {
        l=max(a[i]-k,1),r=min(a[i]+k,len);
        int res;
        res=query(1,1,len);
        res++;
        //cout<<res<<endl;
        ans=max(ans,res);
        locate=a[i];
        val=res;
        update(1,1,len);
    }
    printf("%d",ans);
    return 0;
}


Measured memory_bytes: 14372
import java.util.*;
 
public class Main {
	public static void main(String args[] ) throws Exception {

		Scanner sc = new Scanner(System.in);
		int n = Integer.valueOf ( sc.nextLine().trim() ) ;

		int mod = 1000000007 ;

		long arr[] = new long[n+1] ; 
		for ( int j=3 ;j<=n ; j++ )
			arr[j] = 1 ;

		for ( int j=3 ;j<=n ; j++ ) {
			for ( int r=3; r<=n ; r++ ) {
				if ( j + r > n ) break ;
				arr[j+r] += arr[j] ;
				arr[j+r] %= mod ;
			}
		}
		System.out.println( arr[n] ) ;

	}
}

Measured memory_bytes: 27192
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
	long long int a,b,x,val,val2;
	cin>>a>>b>>x;
	if(x<b)
		{
			val=(a*x)/b;
			cout<<val;
			return 0;
		}
	else {
		val=(a*(b-1))/b;
		cout<<val;
	}
    return 0;
}

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

using namespace std;
#define ll long long

int main()
{
    int n, mi=1000000007, a[100];
    scanf("%d",&n);
    for(int i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
    }
    for(int i=1;i<=100;i++)
    {
        int k=0;
        for(int j=0;j<n;j++)
        {
            k+=(a[j]-i)*(a[j]-i);
        }
        if(k<mi)
            mi=k;
    }
    printf("%d\n",mi);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = 1; i <= n; i++)
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a,b); }
using P = pair <int, int>;
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; }

ll MOD = 1000000007;
ll INF =1<<30;

int main(){
    int a,b,c;
    cin >> a>>b>>c;
    int d = max(a,max(b,c));
    int e = min(a,min(b,c));
    int s = a+b+c;
    if(c==s-d-e) cout << "Yes" << endl;
    else cout << "No" <<endl; 
}


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

int N, K;
long long A[100000];
long long res;
long long around, center;

int main() {
  cin >> N >> K;
  for(int i = 0; i < N; ++i) cin >> A[i];
  for(int i = K; i < N; ++i) around += max(0LL, A[i]);
  for(int i = 0; i < K; ++i) center += A[i];
  res = around + max(0LL, center);
  for(int i = 0; i < N - K; ++i) {
    center -= A[i]; center += A[i + K];
    around += max(0LL, A[i]); around -= max(0LL, A[i + K]);
    res = max(res, around + max(0LL, center));
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/dynamic_bitset.hpp>
using namespace std;
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define RFOR(i,n1,n2) for(ll i=((ll)(n1)-1);i>=(ll)(n2);i--)
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
#define IOS cin.tie(0),ios::sync_with_stdio(false)
typedef long long ll;
typedef unsigned long long ull;
typedef std::pair<ll, ll> P;
template<typename T1, typename T2> inline bool chmin(T1& a, T2 b) { if (a > b) { a = b; return 1; }return 0; }
template<typename T1, typename T2> inline bool chmax(T1& a, T2 b) { if (a < b) { a = b; return 1; }return 0; }
template<class Type>struct is_vector : std::false_type {};
template<class ValueType, class Alloc>struct is_vector<std::vector<ValueType, Alloc>> : std::true_type {};
template <typename T> inline std::ostream& operator << (std::ostream& out, const std::vector<T>& v) {
	if (v.empty())return out;
	constexpr bool is_vector_v = is_vector<T>::value;
	if (is_vector_v)for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? "\n" : "");
	else for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? " " : "");
	return out;
}
inline void put() {}
template<class T> inline void put(const T& first) { std::cout << first << "\n"; }
template<class T, class... N> inline void put(const T& first, const N& ... rest) { std::cout << first << " "; put(rest...); }
inline void putn() {}
template<class T, class... N> inline void putn(const T& first, const N& ... rest) { std::cout << first << "\n"; putn(rest...); }

namespace {
	using namespace std;
	using namespace boost;
	using bt = dynamic_bitset<>;
	constexpr int t = 80 * 160 * 2;
	void solve() {
		int h, w;
		cin >> h >> w;
		vector<vector<bt>> d(h, vector<bt>(w, bt(t)));
		vector<vector<ll>> a(h, vector<ll>(w));
		vector<vector<ll>> b(h, vector<ll>(w));
		vector<vector<ll>> c(h, vector<ll>(w));
		REP(i, h) {
			REP(j, w) {
				cin >> a[i][j];
			}
		}
		REP(i, h) {
			REP(j, w) {
				cin >> b[i][j];
				c[i][j] = a[i][j] - b[i][j];
				c[i][j] = abs(c[i][j]);
			}
		}
		int dx[2] = { 0,1 };
		int dy[2] = { 1,0 };
		d[0][0][c[0][0] + t/2] = 1;
		REP(i, h) {
			REP(j, w) {
				REP(k, 2) {
					ll ny = i + dy[k];
					ll nx = j + dx[k];
					if (ny < h && nx < w) {
						d[ny][nx] |= (d[i][j] << c[ny][nx]) | (d[i][j] >> c[ny][nx]);
					}
				}
			}
		}
		int res = INT_MAX;
		REP(i, t) {
			if (d[h - 1][w - 1][i + t / 2]) {
				res = i;
				break;
			}
		}
		put(res);
	}
}

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


Measured memory_bytes: 20864
def resolve():
    '''
    code here
    '''
    N = int(input())
    res = 0

    def div2(num):
        if num == 1:
            return 1
        else:
            cnt = 0
            while True:
                if num % 2 == 0:
                    num //= 2
                    cnt += 1
                else:
                    return cnt


    res_max_cnt = 0
    for i in range(N):
        tepm_cnt = div2(i+1)
        if res_max_cnt <= tepm_cnt:
            res_max_cnt = tepm_cnt
            res = i+1
    print(res)

if __name__ == "__main__":
    resolve()


Measured memory_bytes: 9168
import java.io.*;
import java.util.*;

class Main{
    public static void main(String[] args){
	BufferedReader sc=new BufferedReader(new InputStreamReader(System.in));
	try {
	    int N = Integer.valueOf(sc.readLine());
	    int K = Integer.valueOf(sc.readLine());
	    for(int i=0; i<K; i++){
		String[] st = sc.readLine().split(" ");
		int x = Integer.valueOf(st[0]);
		int y = Integer.valueOf(st[1]);
		if(x>(N+1)/2)		
		    x = N-x+1;
		if(y>(N+1)/2)
		    y = N-y+1;
		int min = Math.min(x,y);
		min%=3;
		if(min==0)
		    min=3;
		System.out.println(min);
	    }
	}catch(Exception e){
	    System.out.println("Error");
	}
    }
}

Measured memory_bytes: 22736
#include "bits/stdc++.h"
// Begin Header {{{
#define all(x) (x).begin(), (x).end()
#define rep(i, s, n) for (i64 i = (s), i##_limit = (n); i < i##_limit; ++i)
#define repr(i, s, t) for (i64 i = (s), i##_limit = (t); i >= i##_limit; --i)
#define var(type, ...) \
    type __VA_ARGS__;  \
    read(__VA_ARGS__);
#ifndef DBG
#define dump(...)
#endif
using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T, class U>
inline bool chmax(T &a, const U &b) {
    return b > a && (a = b, true);
}
template <class T, class U>
inline bool chmin(T &a, const U &b) {
    return b < a && (a = b, true);
}
constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

template <class T>
inline vector<T> makeV(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}

template <class T, class... Args>
inline auto makeV(const T &initValue, size_t sz, Args... args) {
    return vector<decltype(makeV<T>(initValue, args...))>(
        sz, makeV<T>(initValue, args...));
}

template <class T>
inline istream &operator>>(istream &is, vector<T> &vec) {
    for (auto &e : vec) is >> e;
    return is;
}

inline void read() {}

template <class Head, class... Tail>
inline void read(Head &head, Tail &... tail) {
    cin >> head;
    read(tail...);
}

inline void print() { cout << "\n"; }

template <class Head, class... Tail>
inline void print(Head &&head, Tail &&... tail) {
    cout << head;
    if (sizeof...(tail)) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
inline ostream &operator<<(ostream &os, const vector<T> &vec) {
    static constexpr const char *delim[] = {" ", ""};
    for (const auto &e : vec) os << e << delim[&e == &vec.back()];
    return os;
}

template <class Container>
struct Rev {
    Container &x_;
    inline Rev(Container &x) : x_(x) {}
    inline auto begin() { return rbegin(x_); }
    inline auto end() { return rend(x_); }
};
// }}} End Header

int N;
vector<vector<int>> G;
vector<int> C;
vector<i64> ans;
bool visited[100010];

void dfs(int u, vector<int>::const_iterator &itr) {
    if (visited[u]) return;
    visited[u] = true;
    for (const int nxt : G[u]) dfs(nxt, itr);
    ans[u] = *itr++;
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    read(N);
    G.resize(N);
    rep(i, 0, N - 1) {
        var(int, a, b);
        --a, --b;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    C.resize(N);
    read(C);
    sort(all(C));

    ans.resize(N);
    auto itr = C.cbegin();
    dfs(0, itr);

    i64 sum = 0;
    rep(u, 0, N) {
        for (const int v : G[u]) {
            sum += min(ans[u], ans[v]);
        }
    }

    print(sum / 2);
    print(ans);

    return 0;
}


Measured memory_bytes: 1408
#include"bits/stdc++.h"
using namespace std;

void Main() {
  int k, x;
  cin >> k >> x;
  if (k * 500 >= x) cout << "Yes" << endl;
  else cout <<"No" << endl;
}

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target ("avx")
#define io_init cin.tie(0);ios::sync_with_stdio(0);cout<<setprecision(10)
#include <bits/stdc++.h>
constexpr int INF = 2147483647;
constexpr long long int INF_LL = 9223372036854775807;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;


int main() {
	io_init;
	int N;
	cin >> N;
	vector<int> A(N), B;
	set<int> o, e;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}
	B = A;
	sort(B.begin(), B.end());
	for (int i = 0; i < N; i++) {
		if (i % 2 == 0)e.insert(B[i]);
		else o.insert(B[i]);
	}
	int cnt = 0;
	for (int i = 0; i < N; i++) {
		if (i % 2 == 0) {
			if (e.count(A[i]) == 0)cnt++;
		}
		else {
			if (o.count(A[i]) == 0)cnt++;
		}
	}
	cout << cnt / 2 << endl;
}

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

int main() {
  int N,l,r;
  int sum = 0;
  int prer,prel;
  cin >> N;
  if((N<0)||(N>1000))
    cout << "error" << endl;
  else{
    for(int i=0;i<N;i++){
      cin >> l;
      cin >> r;
      if((r>=l)&&(r>=1)&&(l>=1)&&(r<=100000)&&(l<=100000)){
        sum += r-l+1;
      }
      else 
        cout << "error" << endl; 
    }
  cout << sum << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>

using namespace std;

int main(void) {

	int a,b;
	string op;

	while(true) {
		cin >> a >> op >> b;

		if(op == "?")	break;

		if(op == "+") {
			cout << a + b << endl;
		} else if(op == "-") {
			cout << a - b << endl;
		} else if(op == "*") {
			cout << a * b << endl;
		} else if (op == "/") {
			cout << a / b << endl;
		}
	}



	return 0;
}

Measured memory_bytes: 1204
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
#include <random>
#include <cassert>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 1e3 + 10;
int a[N];
int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int ans = 0;
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) cin >> a[i];
	for (int i = 0; i < n; i++)
	{
		int x;
		cin >> x;
		ans += max(0, a[i] - x);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
int n[1006]={0},m[1006]={0},k=0,i,N,M;
for(;;k=0){
scanf("%d%d",&N,&M);
if(M==0)break;
for(i=0;i<N;i++)scanf("%d",&n[i]);
for(i=0;i<M;i++)scanf("%d",&m[i]);
for(i=0;;i++){
k+=m[i];
k+=n[k];
if(k>=N-1)break;
}
printf("%d\n",i+1);
}
exit(0);
}

Measured memory_bytes: 0
#include<iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <string>
#include<limits>
#include<cstdlib>
#include<functional>
#include<cassert>
#include <cstdio>
#include <stack>
#include <queue>
#define fi(p) for(int i=0;i<(p);i++)
using namespace std;
int N;
int L;
int P;
const int MAX_N = 100000;
const int MAX_W = 100000;


int A[MAX_N+1];
int B[MAX_N+1];

void solve() {
	int N;
	cin >> N;
	vector<int> d(N);

	fi(N) {
		cin >> d[i];
	}
	sort(d.begin(), d.end());

	int ans = d[N/2]-d[N/2-1];



	cout << ans << endl;


}


int main()
{
	solve();

	int a;//止める用
	cin >> a;
	return 0;
}

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

using namespace std;

int n,K;
int h[100010],f[100010];

int main(){
	scanf("%d%d",&n,&K);
	for(int i=1;i<=n;i++){
		scanf("%d",h+i);
		f[i]=i==1?0:1e9;
		
		for(int j=1;j<=K&&i-j>0;j++)
			f[i]=min(f[i],f[i-j]+abs(h[i]-h[i-j]));
	}

	printf("%d\n",f[n]);

	return 0;
}

Measured memory_bytes: 1024
using System;

namespace ABC154_F___Many_Many_Paths
{
    class Program
    {
        static void Main(string[] args)
        {
            var read = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            var r1 = read[0]; var c1 = read[1]; var r2 = read[2]; var c2 = read[3];
            var MOD = 1000000007;
            Combination.combInit(3000000, MOD);
            long temp1 = (Combination.combination(r2 + c2 + 2, c2 + 1) + Combination.combination(r1 + c1, c1)) % MOD;
            long temp2 = (Combination.combination(r2 + c1 + 1, c1) + Combination.combination(r1 + c2 + 1, c2 + 1)) % MOD;
            long result = (temp1 - temp2) % MOD;
            result = result < 0 ? result += MOD:result;
            Console.WriteLine(result);
        }
    }

    static class Combination
    {
        static long combMax;
        static long combMOD;

        static long[] factorial;
        static long[] inverse;
        static long[] factInv;

        public static void combInit(long _max, long _mod)
        {
            combMax = _max;
            combMOD = _mod;
            factorial = new long[combMax];
            inverse = new long[combMax];
            factInv = new long[combMax];

            factorial[0] = factorial[1] = 1;
            factInv[0] = factInv[1] = 1;
            inverse[1] = 1;

            for (int i = 2; i < combMax; i++)
            {
                factorial[i] = factorial[i - 1] * i % combMOD;
                inverse[i] = combMOD - inverse[combMOD % i] * (combMOD / i) % combMOD;
                factInv[i] = factInv[i - 1] * inverse[i] % combMOD;
            }
        }

        public static long combination(int n, int k)
        {
            if (n < k) return 0;
            if (n < 0 || k < 0) return 0;
            return factorial[n] * (factInv[k] * factInv[n - k] % combMOD) % combMOD;
        }
    }
}


Measured memory_bytes: 81484
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define len(v) ll(v.size())

template <class T>
void cout_vec(const vector<T> &vec1){
  rep(i,len(vec1)){
    cout<<vec1[i]<<' ';
  }
  cout<<'\n';
}

typedef pair<int,int> P;
const ll mod=1e9+7;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    set<int> a;
    rep(i,n){
      int x;
      cin>>x;
      a.insert(x);
    }
    int k=len(a);
    if(k%2==1) cout<<k<<endl;
    else cout<<k-1<<endl;
}

Measured memory_bytes: 4992
//遷移：使う, 使わない (2通り)
//状態：dp(i)[val] = (先頭i個まで見て)最後に値valを使ったときの最大個数
//区間max, 1点更新を高速にできれば良い -> セグメントツリー
#include <iostream>
#include <algorithm>
#include <vector>
#include <atcoder/segtree>
using namespace std;
using namespace atcoder;

int op(int a, int b) { return max(a, b); }
int e() { return 0; }

int N, K;
vector<int> a;

int main() {
	int i;
	
	cin >> N >> K;
	vector<int> a(N);
	for (i = 0; i < N; i++) cin >> a[i];
	
	vector<int> zero(300002, 0);
	segtree<int, op, e> seg(zero);
	
	for (i = 0; i < N; i++) {
		int l = max(0, a[i] - K);
		int r = min(300001, a[i] + K + 1);
		int maxLen = seg.prod(l, r);
		seg.set(a[i], maxLen + 1);
	}
	
	cout << seg.all_prod() << endl;
	return 0;
}

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

int main() {
	int d;
	cin >> d;
	if (d == 25) cout << "Christmas";
	else if (d == 24) cout << "Christmas Eve";
	else if (d == 23) cout << "Christmas Eve Eve";
	else cout << "Christmas Eve Eve Eve";
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<list>
#include<set>
#include<string>
using namespace std;
int gcd(int a, int b) {
	int c = a % b;
	while (c != 0) {
		a = b;
		b = c;
		c = a % b;
	}
	return b;
}
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;
	}
};
typedef long long ll;

ll M = 1000000007;

vector<ll> fac(300001); //n!(mod M)
vector<ll> ifac(300001); //k!^{M-2} (mod M)

ll mpow(ll x, ll n) {
	ll ans = 1;
	while (n != 0) {
		if (n & 1) ans = ans * x % M;
		x = x * x % M;
		n = n >> 1;
	}
	return ans;
}
ll comb(ll a, ll b) {
	if (a == 0 && b == 0)return 1;
	if (a < b || a < 0)return 0;
	ll tmp = ifac[a - b] * ifac[b] % M;
	return tmp * fac[a] % M;
}
// mod. m での a の逆元 a^{-1} を計算する
long long modinv(long long a) {
	long long b = M, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= M;
	if (u < 0) u += M;
	return u;
}
vector<vector<ll>> mul(vector<vector<ll>> a, vector<vector<ll>> b, int n) {
	int i, j, k, t;
	vector<vector<ll>> c(n);
	for (i = 0; i < n; i++) {
		for (j = 0; j < n; j++) {
			t = 0;
			for (k = 0; k < n; k++)
				t = (t + a[i][k] * b[k][j] % M) % M;
			c[i].push_back(t);
		}
	}
	return c;
}

template< typename Monoid >
struct SegmentTree {

	int sz;
	vector< Monoid > seg;

	const Monoid M1;

	SegmentTree(int n,  const Monoid &M1) :  M1(M1) {
		sz = 1;
		while (sz < n) sz <<= 1;
		seg.assign(2 * sz, M1);
	}

	void set(int k, const Monoid &x) {
		seg[k + sz] = x;
	}

	void build() {
		for (int k = sz - 1; k > 0; k--) {
			seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
		}
	}

	void update(int k, const Monoid &x) {
		k += sz;
		seg[k] = x;
		while (k >>= 1) {
			seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
		}
	}

	Monoid query(int a, int b) {
		Monoid L = M1, R = M1;
		for (a += sz, b += sz; a < b; a >>= 1, b >>= 1) {
			if (a & 1) L = f(L, seg[a++]);
			if (b & 1) R = f(seg[--b], R);
		}
		return f(L, R);
	}

	Monoid value(const int &k) const {
		return seg[k + sz];
	}

	Monoid f(Monoid a, Monoid b) {
		return a + b;
	}
};

int main() {
	int n, l, i, sum=0, min = 10000;
	cin >> n >> l;
	for (i = 0; i < n; i++) {
		sum += l + i;
		if (abs(l + i) < abs(min))
			min = l + i;
	}
	sum -= min;
	cout << sum << endl;
}

Measured memory_bytes: 4992
#include <algorithm>
#include <iostream>

using namespace std;

int aa[] = { 0, 1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8 };

long long n;
int ans;

void add(long long p) {
	int k = 0;
	while (n % p == 0)
		k++, n /= p;
	ans += aa[k];
}

int main() {
	cin >> n;
	for (long long p = 2; p <= n / p; p++)
		add(p);
	if (n > 1)
		add(n);
	cout << ans << '\n';
	return 0;
}


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

#define ALL(v) (v).begin(), (v).end()
#define rep(i, n) for (ll i = 0, __##i##_length = (n); i < __##i##_length; i++)
#define rep_reverse(i, n) for (ll i = (n)-1; 0 <= i; i--)
#define FOR(i, from, to) for (ll i = (from), __##i##_end = (to); i < __##i##_end; i++)
#define FOR_REVERSE(i, from, to) for (ll i = (to)-1, __##i##_end = (from); __##i##_end <= i; i--)
#define foreach(e, v) for (const auto e : (v))
#define vfree(v) std::vector<int>().swap(v)
#define DEBUG(x) cout << #x << " = " << (x) << endl

using namespace std;
typedef int64_t ll;
typedef vector<ll> llv;
typedef vector<llv> llvv;

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

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

int main()
{
    ll N, K;
    cin >> N >> K;
    ll m = (N * (N - 1) / 2) - (N - 1);

    if (m < K)
    {
        cout << -1 << endl;
        return 0;
    }

    cout << N - 1 + m - K << endl;
    rep(i, N - 1)
    {
        cout << 1 << " " << i + 2 << endl;
    }
    ll i = 0;
    rep(j, N - 1)
    {
        FOR(k, j + 1, N - 1)
        {
            if (m - K <= i)
                return 0;
            i++;
            cout << j + 2 << " " << k + 2 << endl;
        }
    }

    return 0;
}


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

int main() {
    int X, N;
    cin >> X >> N;
    vector<int> p(N);
    for (int i = 0; i < N; i++) cin >> p.at(i);

    int diff = X + 1;
    int res = -1;
    vector<int> found(102, 0);

    for (int i = 0; i < N; i++) found.at(p.at(i))++;
    for (int i = 0; i <= 101; i++) {
        if (found.at(i) == 0 && abs(i - X) < diff) {
            diff = abs(i - X);
            res = i;
        }
    }
    cout << res << endl;
}


Measured memory_bytes: 3632
"use strict";

function* getDatasets(cin) {
    const lines = cin.split("\n");
    let sp = 0;
    while (lines[sp] !== "0") {
        const n = parseInt(lines[sp++]);
        const table = lines.slice(sp, sp + n).map(elt => elt.split(" ").map(e => parseInt(e)));
        sp += n;
        const constraint = lines[sp++].split(" ").map(elt => parseInt(elt));
        yield [table, constraint];
    }
}

new Promise(function(resolve, reject) {
    let content = "";
    process.stdin.on("data", chunk => { content += chunk; })
    process.stdin.on("end", () => { resolve([content, process.stdout]); });
}).then(function([cin, cout]) {
    for (const [d, [P, Q, R, C]] of getDatasets(cin)) {
        const result = d
            .filter(elt => elt[1] <= P)
            .filter(elt => elt[2] <= Q)
            .filter(elt => elt[3] <= R)
            .filter(elt => 4 * elt[1] + 9 * elt[2] + 4 * elt[3] <= C)
            .map(elt => elt[0]);
        if (result.length > 0) {
            cout.write(`${result.join("\n")}\n`);
        } else {
            cout.write("NA\n");
        }
    }
});



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

using LL = long long;
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

void solve(long long H, long long A) {
  // solver code

  int ans = (int)H / A;

  if (H % A != 0) ans++;

  cout << ans << endl;
}

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


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<unordered_set>
#include<set>
#include<map>
#include<unordered_map>
#include<stack>
#include<queue>
#include<string>
#include<cmath>
#include<climits>
using namespace std;

int main() {
    string s,t;
    cin>>s>>t;
    int m=s.length();
    int n=t.length();

    vector<vector<int>> dp(m+1, vector<int> (n+1,0));
    for(int i=1;i<=m;i++) {
        for(int j=1;j<=n;j++) {
            if(s[i-1]==t[j-1])
                dp[i][j] = 1+ dp[i-1][j-1];
            else 
                dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
        }
    }
    string res="";
    while(m>0 && n>0) {
        if(s[m-1]==t[n-1]) {
            res = s[m-1] + res;
            m--; n--;
        }
        else {
            if(dp[m-1][n]>dp[m][n-1]) 
                m--;
            else 
                n--;
        }
    }
    cout<<res;
}


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



int main() {
	vector<int>v(7),y(4);
	int g=2;
	v[0]=1;
	v[1]=3;
	v[2]=5;
	v[3]=7;
	v[4]=8;
	v[5]=10;
	v[6]=12;
	y[0]=4;
	y[1]=6;
	y[2]=9;
	y[3]=11;
int a,b,t=0,p=0;
cin>>a>>b;
if(a==g||b==g){
	cout<<"No"<<endl;
	return 0;
}
for(int i=0;i<v.size();i++){
if(t==0&&a==v[i])
t=1;
if(p==0&&b==v[i])
p=1;
if(p==1&&t==1){
	
cout<<"Yes"<<endl;
return 0;
}
}
p=0;
	t=0;
for(int i=0;i<y.size();i++){
if(t==0&&a==y[i])
t=1;
if(p==0&&b==y[i])
p=1;
if(p==1&&t==1){
cout<<"Yes"<<endl;
return 0;
}
}
cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
         Scanner scanner =new Scanner(System.in);
         int a=scanner.nextInt();
         int b=scanner.nextInt();
         if (a*b % 2==0){
             System.out.println("Even");
         }else {
             System.out.println("Odd");
         }
    }
}

Measured memory_bytes: 21972
import numpy as np
n = int(input())
As = np.array(list(map(int, input().split())))
As_diff = np.diff(As)
status = "no"
money = 1000
stock = 0
for i in range(n):
    if status == "no":
        if i == n-1:
            continue
        elif As_diff[i] > 0:
            stock += int(money / As[i])
            money -= As[i]*stock
            status = "yes"
      
    else:
        if i == n-1:
            
            money += As[i] * stock
            stock = 0
    
        elif As_diff[i] < 0:
            
            money += As[i] * stock
            stock = 0
            status = "no"
print(money)

            

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

#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
typedef long long ll;

typedef P<int, int> pint;
typedef P<pint, pint> ppint;

int main() {
    int H, W; cin >> H >> W;

    int odd = 0;
    V<V<int> > b(H, V<int>(W));
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            cin >> b[i][j];
            if(b[i][j] & 1) odd++;
        }
    }

    V<ppint> ans;
    int num = 0, h = 0, w = 0;
    for(int i = 0; i < H * W; i++){
        if(b[h][w] & 1) num++;

        // ジグザグ移動
        int nh = h, nw = w;
        if(h % 2 == 0){
            if(nw == W - 1) nh++;
            else nw++;
        }else{
            if(nw == 0) nh++;
            else nw--;
        }

        if(num & 1 && num < odd){
            ans.push_back(ppint(pint(h, w), pint(nh, nw)));
        }
        h = nh, w = nw;
    }

    cout << ans.size() << endl;
    for(auto p : ans){
        cout << p.first.first + 1 << " " << p.first.second +1 << " ";
        cout << p.second.first + 1 << " " << p.second.second +1 << endl;
    }



}


Measured memory_bytes: 5232
#include<bits/stdc++.h>
#define ll long long int
const ll mod=1e9+7;
const int maxn=2e5+50;
using namespace std;
int main()
//int found; found=chaine.find(cara); if (found!=std::string::npos) how to verify if a caracter exists in a chaine
// toupper(caractere) ==> return the majuscule of a caractere
//floor(x) Returns the largest integer smaller than x
//ceil(x) returns  Returns the smallest integer greater
{
	
	int h,w;
	cin>>h>>w;
	char map[h][w];
	for(int i=0;i<h;i++)
	{
		for(int j=0;j<w;j++)
		{
			cin>>map[i][j];
		}
	}
	ll dp[h][w];
	bool b=true;
	for(int i=0;i<h;i++)
	{
		if((map[i][0]=='.')and(b))
		{
			dp[i][0]=1;
		}
		else
		{
			dp[i][0]=0;
			b=false;
		}
	}
	b=true;
	for(int i=0;i<w;i++)
	{
		if((map[0][i]=='.')and(b))
		{
			dp[0][i]=1;
		}
		else
		{
			dp[0][i]=0;
			b=false;
		}
	}
	for(int i=1;i<h;i++)
	{
		for(int j=1;j<w;j++)
		{
			if(map[i][j]=='.')dp[i][j]=(dp[i-1][j]+dp[i][j-1])%mod;
			else dp[i][j]=0;
		}
	}
	cout<<dp[h-1][w-1];
}



Measured memory_bytes: 9088
import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush
from math import *
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from time import perf_counter
from fractions import Fraction
# import numpy as np
sys.setrecursionlimit(int(pow(10,6)))
# sys.stdin = open("input.txt", "r")
# sys.stdout = open("output.txt", "w")
mod = int(pow(10, 9) + 7)
mod2 = 998244353
def data(): return sys.stdin.readline().strip()
def out(*var, end="\n"): sys.stdout.write(' '.join(map(str, var))+end)
def l(): return list(sp())
def sl(): return list(ssp())
def sp(): return map(int, data().split())
def ssp(): return map(str, data().split())
def l1d(n, val=0): return [val for i in range(n)]
def l2d(n, m, val=0): return [l1d(n, val) for j in range(m)]



x=l()
print(x.index(0)+1)

Measured memory_bytes: 10524
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <numeric>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

#define rep(i, N) for(int i = 0; i < N; ++i)

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

#define IN(l, r, x) ((l) <= (x) && (x) < (r))

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

    s64 n;
    cin >> n;

    s64 ans = 0;
    vs64 f(n + 1, 0);
    for (int i = 1; i <= n; ++i)
    {
        for (int j = i; j <= n; j += i)
        {
            ++f[j];
        }
    }

    for (int k = 1; k <= n; ++k)
    {
        ans += k * f[k];
    }

    cout << ans << "\n";
    return 0;
}



Measured memory_bytes: 81300
#参考(傾きの捉え方)
N = int(input())
A = list(map(int, input().split()))
f = 0
c = 1
i = 0
while i < N-1:
    if f == 0:
        if A[i] < A[i+1]:
            f = 1
        elif A[i] > A[i+1]:
            f = -1
    elif f == 1:
        if A[i] > A[i+1]:
            c += 1
            f = 0
    elif f == -1:
        if A[i] < A[i+1]:
            c += 1
            f = 0
    i += 1
print(c)

Measured memory_bytes: 14252
private fun readStrings() = readLine()!!.split(" ")
private fun readInts() = readStrings().map { it.toInt() }

private inline fun <T> T.also(block: (T) -> Unit): T { block(this); return this }

fun main(args: Array<String>) {
    val nums = readInts()
    val diff = nums.map { it - nums.min()!! }.sorted()
    val (_dm, a, b) = diff
    println(a / 2 + a % 2 + (b - a / 2 * 2))
}

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

int main(){
    using namespace std;

    long N; cin >> N;
    vector<long> cusum(N+1, 0);

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

    map<long, long> m;
    for (int i = 0; i < N+1; i++) m[cusum[i]]++;
    long cnt = 0;
    for(auto i : m){
        long num = i.second;
        cnt += num * (num - 1) / 2;
    }
    cout << cnt << endl;
}


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

class Eratosthenes{ //NMAX変更しておｋ
    private:
        const static int NMAX = 2000010;
        vector<bool> prime;
    
    public:
        Eratosthenes(){
            prime.resize(NMAX,true);//一旦全部trueとする(true=素数)
            prime[0] = false;
            prime[1] = false;
            for(int i=2;i*i<=NMAX;i++){
                if(prime[i]){
                    for(int j=2;i*j<=NMAX;j++) prime[i*j] = false;
                }
            }
        }
        inline vector<bool> isPrime(){ return prime; }

};
#define debug(x) cerr << x << " = "(x) << endl;
#define ll long long
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll n; cin >> n;
    ll cnt=0;
    ll ni= n;
    Eratosthenes sosu;
    for(ll i=2;i*i<=n+10;i++){
        ll t = i;
        while(ni%t==0 && sosu.isPrime()[i] && ni != 0){
            //cout << i << endl;
            cnt++;
            ni /= t;
            t *= i;
        }
        while(ni%i==0){
            ni /= i;
        }
    }
    if(ni > sqrt(n)){
        bool ok = false;
        for(ll i=2;i*i<=ni+10;i++){
            if(ni%i==0) ok = true;
        }
        if(!ok) cnt++;
    }
    cout << cnt << endl;
}

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

int main(){
  int n,p;
  cin >>n>>p;
  int e=0,o=0;
  int x;
  for(int i=0;i<n;i++){
    cin >>x;
    if(x%2 == 0) e++;
    else if(x%2 == 1) o++;
  }
  long long int ans;
  if(o == 0){
    if(p==0) ans = pow(2,n);
    else ans =0;
  }
  else ans = pow(2,n-1);
  cout << ans <<endl;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll n, sum, v[200100];

int main() {
    cin.tie(0); ios::sync_with_stdio(0);
    cin >> n;
    for (int i = 1; i <= n; i++)
        cin >> v[i];
    sort(v + 1, v + n + 1, greater<int>());
    if (n != 1) {
        int cnt = 1;
        sum = v[1];
        for (int i = 2; cnt < n - 1; i++) {
            sum += v[i];
            cnt++;
            if (cnt < n - 1) {
                sum += v[i];
                cnt++;
            }
        }
    }
    cout << sum;
    return 0;
}


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

using namespace std;

typedef long long LL;
typedef long double LD;





int main()
{
  LL X,Y,Z,K;
  cin >> X >> Y >> Z >> K;
  vector<LL> A(X);
  vector<LL> B(Y);
  vector<LL> C(Z);

  for (LL i = 0; i < X; ++i) {
    cin >> A[i];
  }
  for (LL i = 0; i < Y; ++i) {
    cin >> B[i];
  }
  for (LL i = 0; i < Z; ++i) {
    cin >> C[i];
  }

  priority_queue<LL> V;
  for (LL x = 0; x < X; ++x) {
    for (LL y = 0; y < Y; ++y) {
      V.push(A[x] + B[y]);
    }
  }

  vector<LL> AB;
  LL k = 0;
  while (!V.empty() && k < K) {
    AB.push_back(V.top());
    V.pop();
    k++;
  }

  priority_queue<LL> U;
  for (auto ab : AB) {
    for (LL z = 0; z < Z; ++z) {
      U.push(ab + C[z]);
    }
  }


  k = 0;
  while (!U.empty() && k<K) {
    cout << U.top() << endl;
    U.pop();
    k++;

  }

  return 0;
}

Measured memory_bytes: 43272
program shik_and_game
  implicit none
  integer :: n, i, j = 0
  integer(8) :: e, t, x(100001) = 0_8, dp(0:100000) = 0_8, tmp = 0_8
  read(*,*) n, e, t
  read(*,*) x(1:n)
  x(n+1) = e
  do i = 1, n
    do while (2_8*(x(i)-x(j+1)) > t)
      tmp = min(tmp,dp(j)-2_8*x(j+1))
      j = j+1
    end do
    dp(i) = dp(j)+t
    if (j > 0) dp(i) = min(dp(i),2_8*x(i)+tmp)
  end do
  write(*,'(i0)') dp(n)+e
end program shik_and_game

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

int n,k;
const long long mod=1e9+7;
long long dp[3010][3010],jie[4000010],ni[4000010];
inline long long ksm(long long x,long long y)
{
	long long res=1;
	while(y)
	{
		if(y&1)
		res=res*x%mod;
		x=x*x%mod;
		y>>=1;
	}
	return res;
}
int main()
{
	scanf("%d%d",&n,&k);
	if(k==1)
	{
		printf("1\n");
		return 0;
	}
	jie[0]=1;
	for(int i=1;i<=n*k;++i)
	jie[i]=jie[i-1]*i%mod;
	ni[n*k]=ksm(jie[n*k],mod-2);
	for(int i=n*k-1;i>=0;--i)
	ni[i]=ni[i+1]*(i+1)%mod;
	for(int i=1;i<=n;++i)
	dp[i][0]=1;
	for(int i=1;i<=n;++i)
	{
		for(int j=1;j<=i;++j)
		{
			int x=n*k-i-(j-1)*(k-1)-1;
			dp[i][j]=(dp[i-1][j]+dp[i][j-1]*(n-j+1)%mod*jie[x]%mod*ni[k-2]%mod*ni[x-k+2]%mod)%mod;
		}
	}
	printf("%lld\n",dp[n][n]);
	return 0;
}

Measured memory_bytes: 110848