akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
constexpr double EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max()/2;
constexpr int MOD = 1e9+7;

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

    string a,b;cin>>a>>b;
    set<int> st;
    for(int i=1;i<10000;i++) st.insert(i*i);
    int n=stoi(a+b);
    if(st.find(n)!=st.end()) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


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

using namespace std;

#define ll long long int
#define ld long double
#define MAX 500007
#define MOD 1000000007
#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)

int main(){

    fast;

    string s1,s2;
    cin >> s1 >> s2;

    ll n1,n2,i,j;
    n1 = s1.size();
    n2 = s2.size();

    ll dp[n1+1][n2+1];

    for(i=0;i<=n1;i++){
        for(j=0;j<=n2;j++){
            if((i==0)||(j==0)){
                dp[i][j]=0;
            }
            else{
                if(s1[i-1]==s2[j-1]){
                    dp[i][j] = dp[i-1][j-1]+1;
                }
                else{
                    dp[i][j] = max(dp[i-1][j],dp[i][j-1]);
                }
            }
        }
    }

    i = n1;
    j = n2;

    vector<char> a;

    while(dp[i][j]){

        if(dp[i][j]==dp[i-1][j-1]){
            i--;
            j--;
        }
        else if(dp[i][j]==dp[i][j-1]){
            j--;
        }
        else if(dp[i][j]==dp[i-1][j]){
            i--;
        }
        else{
            a.push_back(s1[i-1]);
            i--;
            j--;
        }
    }

    if(a.size()){
        for(i=a.size()-1;i>=0;i--){
            cout << a[i];
        }
    }
    else{
        return 0;
    }

}

//    cout << fixed << setprecision(2);


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

int main(){
  string s;
  cin >> s;
  int n1 = stoi(s); //霜2桁
  int n2 = n1/100; //神2桁
  n1 = n1 - n2*100;
  if(n2>0 && n2<13){ //神に桁が1～12
    if(n1>=13 || n1 == 0){
      cout << "MMYY" << endl;
      return 0;
    }else if(n1>0 && n1<13){
      cout << "AMBIGUOUS" << endl;
      return 0;
    }
  }
  if(n2==0){//神に桁が0
    if(n1>0 && n1<13){
      cout << "YYMM" << endl;
      return 0;
    }else{
      cout << "NA" << endl;
      return 0;   
    }
  }
  if(n2>12 && n2<100){ //神に桁が13~99
    if(n1>=13 || n1 == 0){ //
      cout << "NA" << endl;
      return 0;
    }else if(n1>0 && n1<13){
      cout << "YYMM" << endl;
      return 0;
    }
  }  
}

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

using namespace std ;

int main()
{
	int w ,h ;
	int x ,y ,r ;
	cin >> w >> h >> x >> y >> r ;
	if( x - r < 0 || x + r > w || y - r < 0 || y + r > h )
		cout << "No" << endl ;
	else
		cout << "Yes" << endl ;
	return 0 ;
}

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

#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,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

const int dx[8] = { 1,1,0,-1,-1,-1,0,1 };
const int dy[8] = { 0,1,1,1,0,-1,-1,-1 };


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	cin >> s;
	ll ans = 0;
	
	int n = s.size();
	vi v(n);
	REP(i, n)v[i] = s[i] - '0';
	REP(i, 1 << (n - 1)) {
		ll tmp = 0;
		ll t = v[0];
		REP(j, n - 1) {
			if (i&(1 << j)) {
				t *= 10;
				t += v[j + 1];
			}
			else {
				tmp += t;
				t = v[j + 1];
			}
		}
		tmp += t;
		ans += tmp;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<iostream>
#include<string>
#include<complex>
#include<algorithm>
#include<vector>
#include<math.h>
#include<set>
#include<map>

int main()
{
    int n, k, x[100000], minus{};
    long long min = 100000000000000;
    scanf("%d%d", &n, &k);
    for (int i = 0; i < n; i++)
    {
        scanf("%d", x + i);
        if (x[i] < 0)
            minus = i;
    }

    for (int i = std::max(minus - k + 1, 0); i + k <= n; i++)
    {
        long long sum = std::abs(x[i] - x[i + k - 1]) + std::min(std::abs(x[i]), std::abs(x[i + k - 1]));
        if (sum < min) min = sum;
    }
    printf("%lld\n", min);

	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1, T2> P)
{
	return s << '<' << P.first << ", " << P.second << '>';
}
template<class T> ostream& operator << (ostream &s, vector<T> P)
{
	for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s;
}
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{
	for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl;
}
template<class T1, class T2> ostream& operator << (ostream &s, map<T1, T2> P)
{
	EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl;
}
template<class T> ostream& operator << (ostream &s, set<T> P)
{
	EACH(it, P) { s << "<" << *it << "> "; } return s << endl;
}




long long N, A, B;

vector<long long> solve() {
    vector<long long> res;
    for (long long i = B-1; i >= 0; --i) res.push_back(i);
    
    if (A == 1) return res;
    
    long long rem = N - B;
    long long p = rem / (A-1);
    long long r = rem % (A-1);
    
    long long b = r;
    long long c = A-1-r;
    
    for (int i = 0; i < b; ++i) {
        int size = res.size();
        for (int j = 0; j < p+1; ++j) {
            res.push_back(size + p - j);
        }
    }
    for (int i = 0; i < c; ++i) {
        int size = res.size();
        for (int j = 0; j < p; ++j) {
            res.push_back(size + p-1 - j);
        }
    }
    
    return res;
}

int main() {
    while (cin >> N >> A >> B) {
        if (N <= A + B - 2) {
            cout << -1 << endl;
            continue;
        }
        if (N > A*B) {
            cout << -1 << endl;
            continue;
        }
        
        vector<long long> res = solve();
        
        for (int i = 0; i < res.size(); ++i) {
            cout << res[i] + 1;
            if (i != (int)res.size() - 1) cout << " ";
        }
        cout << endl;
        
    }
}



Measured memory_bytes: 6384
// g++ -std=c++14

/*

Today might be the chance to grasp the chance to let your talent bloom.
May be tomorrow, the day after, or next year...
May be even when you are 30. I'm not sure if physique has anything to do with it
but if you think that it will never come, it probably never will.

- Tooru Oikawa.

*/


#include<bits/stdc++.h>

typedef long long ll;
typedef long double lld;
using namespace std;

#define sd(x) scanf("%d",&x)
#define sd2(x,y) scanf("%d%d",&x,&y)
#define sd3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define endl "\n"
#define fi first
#define se second
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define LET(x, a)  __typeof(a) x(a)
#define foreach(it, v) for(LET(it, v.begin()); it != v.end(); it++)
#define MEMS(a,b) memset(a,b,sizeof(a))
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define __ freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define all(c) c.begin(),c.end()
#define inf 1000000000000000001

#define tr(...) cout<<__FUNCTION__<<' '<<__LINE__<<" = ";trace(#__VA_ARGS__, __VA_ARGS__)

template<typename S, typename T>
ostream& operator<<(ostream& out,pair<S,T> const& p){out<<'('<<p.fi<<", "<<p.se<<')';return out;}

template<typename T>
ostream& operator<<(ostream& out,vector<T> const& v){
ll l=v.size();for(ll i=0;i<l-1;i++)out<<v[i]<<' ';if(l>0)out<<v[l-1];return out;}

template<typename T>
void trace(const char* name, T&& arg1){cout<<name<<" : "<<arg1<<endl;}

template<typename T, typename... Args>
void trace(const char* names, T&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');cout.write(names, comma-names)<<" : "<<arg1<<" | ";trace(comma+1,args...);}

#define int ll

int n, m;

int32_t main(){ _
    cin >> n >> m;
    int ans = 1;
    for(int i = 1; i*i <= m; i++){
        if(m % i == 0){
            int sum = m/i;
            if(sum >= n){
                ans = max(ans, i);
            }
            int curr = m/i;
            sum = m/curr;
            if(sum >= n){
                ans = max(ans, curr);
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
using ll = long long;
using pll = pair<ll, ll>;
#define all(x) (x).begin(), (x).end()
#define call(x) (x).cbegin(), (x).cend()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define sz(x) ((x).size())
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define rep(i, a, b) for(ll i = ll(a); i < ll(b); i++)
const double PI = acos(-1);
const int mod = 1e9+7;
const long long INF = (1LL << 60);
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a / gcd(a,b) * b;}
ll stringcount(string s, char c){return count(s.cbegin(), s.cend(), c);}
bool isInteger(double x){return floor(x) == x;}
ll ceil(ll a, ll b){return ((a)+(b)-1)/b;}
template<class T> inline bool chmax(T &a, const T &b){ if(a < b){ a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b){ if(a > b){ a=b; return 1; } return 0; }

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

  ll n;
  cin >> n;
  vector<ll> h(n);
  rep(i, 0, n) cin >> h[i];

  rep(i, 0, n-1){
    if(h[i] < h[i+1]){
      h[i+1]--;
      continue;
    }else{
      if(h[i] == h[i+1]) continue;
      else{
        cout << "No" << endl;
        return 0;
      }
    }
  }
  cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 1024
def a(s):
  n = len(s)
  for i in range(n // 2):
    if s[i] != s[-(i + 1)]:
      return False

  return True


def test(s):
  if not a(s):
    return "No"

  n = len(s)
  if not a(s[:(n - 1) // 2]):
    return "No"

  if not a(s[(n + 3) // 2 - 1:]):
    return "No"

  return "Yes"


print(test(input().strip()))


Measured memory_bytes: 3060
from collections import deque

n = int(input())
A = list(map(int,input().split()))
que = deque()

for i in range(n):
    if i % 2 == 0:
        que.appendleft(A[i])
    else:
        que.append(A[i])
else:
    if n % 2 == 0:
        que.reverse()
    lis = list(map(lambda x:str(x),que))
    print(" ".join(lis))

Measured memory_bytes: 32968
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
using namespace std;
typedef long long ll;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	map<pair<int, int>, bool> r;
	rep(i, 3) {
		int a, b; cin >> a >> b;
		a--; b--;
		r[make_pair(a, b)] = true;
		r[make_pair(b, a)] = true;
	}
	//0-indexed

	for (int i = 0; i < 4; ++i) {
		for (int j = 0; j < 4; ++j) {
			if (r[make_pair(i, j)] || r[make_pair(j, i)]) {
				for (int k = 0; k < 4; ++k) {
					if (k == i) continue;
					if (r[make_pair(j, k)] || r[make_pair(k, j)]) {
						for (int l = 0; l < 4; ++l) {
							if (l == i || l == j) continue;
							if (r[make_pair(k, l)] || r[make_pair(l, k)]) {
								puts("YES");
								return 0;

							}
						}
					}
				}
			}
		}
	}

	puts("NO");

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>

using namespace std;

int main(){
	typedef vector<int> vint;
	typedef vector<int>::iterator vintit;

	const int SUM_OF_DATA = 10;
	const int TOP = 3;
	vint hList(SUM_OF_DATA);
	vint result(TOP);
	
	for (vintit it = hList.begin(), end = hList.end(); it != end; ++it) cin >> *it;

	partial_sort_copy(hList.begin(), hList.end(), result.begin(), result.end(), greater<int>());
	for (vintit it = result.begin(), end = result.end(); it != end; ++it) cout << *it << endl;
	
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
using namespace std;
int main(){
	int a,b;
	string c;
	for(;;){
		a=0;
		cin>>c;
		b=c.size();
		if(c=="0"){
			return 0;
		}
		for(int i=0;i<b;i++){
			a=a+c[i]-'0';
		}
			cout<<a<<endl;
		}
	}



Measured memory_bytes: 3164
#include <bits/stdc++.h>
//#include <chrono>
//#pragma GCC optimize("Ofast")
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second

using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;

ll N,M,H,W,Q,K,A,B;
string S;
typedef pair<ll, ll> P;
const ll INF = (1LL<<58);

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

void add_c(ll v, ll c, unordered_map<ll, vector<ll> > &G){
    if(G[N * c + v].empty()) {
        G[v].push_back(N * c + v);
        G[N * c + v].push_back(v);
    }
}

int main() {
    cin>>N>>M;
    unordered_map<ll, vector<ll> > G;
    rep(i, M){
        ll p, q, c;
        cin>>p>>q>>c;
        --p; --q;
        add_c(p, c, G); add_c(q, c, G);
        G[N * c + p].push_back(N * c + q);
        G[N * c + q].push_back(N * c + p);
    }
    const ll base = - (1LL<<60);
    unordered_map<ll, ll> dist;
    dist[0] = base;
    priority_queue<P, vector<P>, greater<> > pque;
    pque.emplace(base, 0);
    while(!pque.empty()){
        P p = pque.top(); pque.pop();
        ll v = p.se, d = p.fi;
        if(dist[v] < d) continue;
        for(ll to : G[v]){
            bool plus = min(v, to) < N;
            if(chmin(dist[to], d + plus)){
                pque.emplace(d + plus, to);
            }
        }
    }
    cout<<(dist[N - 1] == 0 ? -1 : (dist[N - 1] - base) / 2)<<endl;
}


Measured memory_bytes: 69864
#include<stdio.h>
int main(){
  int i;
  int n;
  int q;
  int count = 0;
  int S[10000];
  int T[500];
  int j;
  
  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%d",&S[i]);
  }

  scanf("%d",&q);

  for(i=0;i<q;i++){
    scanf("%d",&T[i]);
  }

  for(i=0;i<q;i++){
    for(j=0;j<n;j++){
      if(S[j] == T[i]){
	count++;
	break;
      }
    }
  }
  printf("%d\n",count);
  return 0;
}



Measured memory_bytes: 2144
#include <iostream>

using namespace std;

int main()
{
  int r, c;
  cin >> r >> c;
  int rc[r + 1][c];
  for (int i = 0; i < r; i++)
  {
    for (int j = 0; j < c; j++)
    {
      rc[i][j] = 0;
      if (i == 0)
        rc[r][j] = 0;

      cin >> rc[i][j];
      rc[r][j] += rc[i][j];
    }
  }

  int row_sum = 0;
  for (int i = 0; i <= r; i++)
  {
    int col_sum = 0;
    for (int j = 0; j < c; j++)
    {
      cout << rc[i][j] << " ";
      col_sum += rc[i][j];
    }
    cout << col_sum << endl;
  }
  return 0;
}

Measured memory_bytes: 3116
#include <numeric>
#include<iostream>
#include<set>
#include<queue>
#include<vector>
#include<map>
#include<stack>
#include <cstdio>
#include<algorithm>
#include <sstream>
#include<string>
#include<string.h>
#include <cmath>
#include <iomanip>
#include <string>
#include<list>
using namespace std;
#define int long long
#define inf 1000000007
#define rep(i,j,n) for(int i=j;i<n;i++)
typedef pair<int,int>  P;
double pi = 3.141592653589793;
//使うやつはここから下に置こうな
signed main(){
    int n,m;cin>>n>>m;
    int num[114514];rep(i,1,n+1)num[i]=1;
    bool bo[114514]={};
    bo[1]=true;
    rep(i,0,m){
        int a,b;cin>>a>>b;
        if(bo[a])bo[b]=true;
        num[a]--;
        num[b]++;
        if(num[a]==0)bo[a]=false;
    }
    int ans=0;
    rep(i,1,n+1){
        if(bo[i])ans++;
    }
    cout<<ans<<endl;
    return 0;
}

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

int main(){
  int h , w, i, j;
  cin >> h >> w;
  char m[h + 2][w + 2];
  for(i = 1; i < h + 1; i++){
    for(j = 1; j < w + 1; j++){
      cin >> m[i][j];
    }
  }
  for(i = 0; i < h + 2; i++){
    m[i][0] = '#';
    m[i][w + 1] = '#';
  }
  for(i = 0; i < w + 2; i++){
    m[0][i] = '#';
    m[h + 1][i] = '#';
  }
  for(i = 0; i < h + 2; i++){
    for(j = 0; j < w + 2; j++){
      cout << m[i][j];
    }
    cout << endl;
  }
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
    public class Main {
     
    	public static void main(String[] args) {
    		Scanner scan = new Scanner(System.in);
    		int a=Integer.parseInt(scan.next());
    		int b=Integer.parseInt(scan.next());
    		
    		for (int i=1;i<1010;++i) {
    			if ((int)(i*0.08)==a && (int)(i*0.1)==b) {
    				System.out.print(i);
    				System.exit(0);
    				break;
    			}
    		}
    		System.out.print(-1);
    		
    		
    }	
    }
// end 

Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
typedef long long lo;
typedef vector<lo> vl;
typedef vector<vl>vll;
#define all(v) (v).begin(), (v).end()
#define debug(x) cerr<<#x<<" = "<<x<<endl;
#define REPV(a, b, c) for (lo(a) = b; (a) < (c); (a)++) 
#define REP(a,b) for(lo i =(a) ;i<(b);i++)

template <typename T>

istream &operator>>(istream &in, vector<T> &v)
{
	for (unsigned i = 0; i < v.size(); i++)
		in >> v[i];
	return in;
}



void solve(){
	int ans = 0;
	lo N,M,K;
	cin>>N>>M>>K;
	vector<string>v(N);
	REP(0,N)cin>>v[i];
	for(int bit1=0;bit1<1<<N;bit1++){
		for(int bit2=0;bit2<1<<M;bit2++){

		vector<string>temp = v;
		for(int i=0;i<N;i++){
			if(bit1&(1<<i)){
				temp[i] = string(v[i].size(),'r');
			}
		}
		for(int i=0;i<M;i++){
			if(bit2&(1<<i)){
			for(int j=0;j<N;j++){
				temp[j][i] = 'r';
			}
			}
		}
	int count=0;
		for(int i=0;i<N;i++){
			for(int j=0;j<M;j++){
				if(temp[i][j]=='#')count++;
			}
		}
		ans+=(count==K);		

		}
	}

	cout<<ans<<endl;

}


int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cout.precision(20);
	solve();
	return 0;
}

Measured memory_bytes: 3616
//{{{
#include <bits/stdc++.h>
using namespace std;
#define rep(...) repN((__VA_ARGS__,rep3,rep2,loop,~))(__VA_ARGS__)
#define loop(n) rep2(_loop_,n)
#define rep2(i,n) rep3(i,0,n)
#define rep3(i,begin,end) for(int i=(int)(begin),i##_end=(int)(end);i<i##_end;++i)
#define repN(a) repX a
#define repX(a0,a1,a2,x,...) x
#define foreach(x,a) for(auto &x:a)
typedef long long ll;
const int MOD = 1e9+7;
//}}}

int main(){
  int x, y;
  cin >> x >> y;
  int ans = 0;
  if(x >= 0){
    if(y > x){
      ans = y - x;
    }else{
      if(y <= -x){
        ans = ((-y) - x) + 1;
      }else{
        ans = min(1 + x - y + 1, 1 + (y - (-x)));
      }
    }
  }else{
    if(y < x){
      ans = 1 + (x - y) + 1;
    }else{
      if(y > -x){
        ans = 1 + (y - (-x));
      }else{
        ans = min(y - x, ((-y) - x) + 1);
      }
    }
  }
  cout << ans << endl;
  return 0;
}


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

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(), (v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x,n) bitset<n>(x)

typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,P> PP;

struct edge {
	int to,cost;
	edge(int t,ll c):to(t),cost(c) {}
};

int dx[]={1,-1,0,0},dy[]={0,0,1,-1};
int ddx[]={1,1,1,0,-1,-1,-1,0},ddy[]={1,0,-1,-1,-1,0,1,1};

ll mypow(ll x,ll n,ll m) {
	if(n==0) return 1;
	if(n%2==0) return mypow(x*x%m,n/2,m);
	else return x*mypow(x,n-1,m)%m;
}

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

int n;
ll t=1,a=1;

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

	cin>>n;
	REP(i,n) {
		ll tt,aa; cin>>tt>>aa;
		ll ttt=t,aaa=a;
		(ttt/=tt)+=(t%tt?1:0);
		(aaa/=aa)+=(a%aa?1:0);
		ll m=max(aaa,ttt);
		t=m*tt,a=m*aa;
	}
	cout<<t+a<<endl;

	return 0;
}


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

using namespace std;

#define NMAX 105
#define WMAX 10005
#define DIAGONAL 1
#define TOP 0

struct Item {
  int value, weight;
};

int N, W;
Item items[NMAX + 1];
int C[NMAX + 1][WMAX + 1], G[NMAX + 1][WMAX + 1];

void compute(int& maxValue, vector<int>& selection) {
  for (int w = 0; w <= W; w++) {
    C[0][w] = 0;
    G[0][w] = DIAGONAL;
  }

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

  for (int i = 1; i <= N; i++) {
    for (int w = 1; w <= W; w++) {
      C[i][w] = C[i - 1][w];
      G[i][w] = TOP;
      if (items[i].weight > w) {
        continue;
      }
      if (items[i].value + C[i - 1][w - items[i].weight] > C[i - 1][w]) {
        C[i][w] = items[i].value + C[i - 1][w - items[i].weight];
        G[i][w] = DIAGONAL;
      }
    }
  }

  maxValue = C[N][W];
  selection.clear();
  for (int i = N, w = W; i >= 1; i--) {
    if (G[i][w] == DIAGONAL) {
      selection.push_back(i);
      w -= items[i].weight;
    }
  }

  reverse(selection.begin(), selection.end());
}

void input() {
  cin >> N >> W;
  for (int i = 1; i <= N; i++) {
    cin >> items[i].value >> items[i].weight;
  }
}

int main() {
  int maxValue;
  vector<int> selection;

  input();
  compute(maxValue, selection);

  cout << maxValue << endl;

  return 0;
}


Measured memory_bytes: 11024
N,M = map(int,input().split())
c = [1 for _ in range(N)]
H = list(map(int,input().split()))

for i in range(M):
  a, b = map(int,input().split())
  if(H[a-1] > H[b-1]):
    c[b-1] = 0
  elif(H[a-1] < H[b-1]):
    c[a-1] = 0
  else:
    c[a-1] = c[b-1] = 0
print(c.count(1))

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

int main() {
    int64_t n, wa;
    cin >> n >> wa;
    int64_t dp[wa+1];
    for (int64_t i = 0; i <= wa; i++) {
        dp[i] = -1;
    }
    dp[0] = 0;
    int64_t w[n];
    int64_t v[n];
    for (int64_t i = 0; i < n; i++) {
        cin >> w[i] >> v[i];
    }
    //cout << "done reading" << endl;
    for (int64_t i = 0; i < n; i++) {
        for (int64_t j = wa; j >= 0; j--) {
            //cout << j << endl;
            if (w[i] + j > wa || dp[j] == -1) {
                continue;
            }
            dp[j+w[i]] = max(dp[j+w[i]], dp[j]+v[i]);
        }
    }
    int64_t out = 0;
    for (int i = 0; i <= wa; i++) {
        out = max(out, dp[i]);
    }
    cout << out << endl;
}

Measured memory_bytes: 1024
#include <iostream>

using namespace std;

int main() {
	int W, H, x, y, r;
	cin >> W >> H >> x >> y >> r;
	W -= x;
	H -= y;
	if (r > x || r > y || r > W || r > H) {
		cout << "No" << endl;
	}
	else {
		cout << "Yes" << endl;
	}
}


Measured memory_bytes: 3120
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
map <int,int> mp;
#define INF (1<<30)
#define INFLL (1ll<<60)
#define EPS (1e-10)
static const int MAX=100000;
static const int NMAX=50;
static const int MMAX=50;
int N,K;
int main(){
    cin>>N>>K;
    ll ans=K;
    for(int i=0;i<N-1;i++) ans*=K-1;

    cout<<ans<<"\n";

    return 0;
}




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

using namespace std;
using ll = long long;
using P = pair<ll, ll>;

const ll INF64 = 1LL << 60;
const int INF32 = 1 << 29;
const int MOD = 1000000007;

const int CASES = 3;

int H, W;
vector<string> field;
const int dx[] = {-1, 1, 0, 0};
const int dy[] = {0, 0, -1, 1};

bool dfs(int y, int x, int count){
    for(int i = 0; i < 4; ++i){
        int nx = x + dx[i];
        int ny = y + dy[i];
        if(nx < 0 || W <= nx || ny < 0 || H <= ny){
            continue;
        }
        if(field[ny][nx] == '#'){
            return true;
        }
    }
    return false;
}

void solve(){
    cin >> H >> W;
    field.resize(H);
    for(int i = 0; i < H; ++i){
        cin >> field[i];
    }
    for(int i = 0; i < H; ++i){
        for(int j = 0; j < W; ++j){
            if(field[i][j] == '#'){
                if(!dfs(i, j, 0)){
                    cout << "No" << endl;
                    return;
                }
            }
        }
    }

    cout << "Yes" << endl;
    return;
}

int main() {
    #ifdef MYLOCAL
    vector<string> filenames {"input1.txt", "input2.txt", "input3.txt", "input4.txt"};
    cout << "------------\n";
    for(int i = 0; i < CASES; ++i){
        ifstream in(filenames[i]);
        cin.rdbuf(in.rdbuf());
        solve();
        cout << "------------\n";
    }
    #else

    solve();

    #endif
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define  ll      long long 
#define  int     ll 
#define  mod     1000000007
#define  pb      push_back
#define  pob     pop_back
#define  f1      first
#define  s2      second
#define  N       100005
#define  K       100005
#define  bol     (int)ceil((say-1)/2.0)
#define  PII     pair<int,int>
#define  PIII    pair<int,PII>
#define  PIIII   pair<PII,PII>
#define  PIIIII  pair<PIII,PII>
#define  PIIIIII pair<PIII,PIII>

using namespace std; 

string s;
int d,n;
int dp[N][102][3];

int dpf(int indis,int sum,int flag){
    sum+=d;
    sum%=d;
    if(indis==n){
        return (sum==0)?1:0;
    }
    if(dp[indis][sum][flag]!=-1)
        return dp[indis][sum][flag];
    int top=0;
    if(!flag){
        for(int i=0;i<(s[indis]-'0');i++){
            top+=dpf(indis+1,(sum+i)%d,1);
            top%=mod;
        }
        top+=dpf(indis+1,(sum+s[indis]-'0')%d,0);
        top%=mod;
    }
    else{
        for(int i=0;i<=9;i++){
            top+=dpf(indis+1,(sum+i)%d,1);
            top%=mod;
        }
    }
    dp[indis][sum][flag]=top;
    return dp[indis][sum][flag];

}



int32_t main(){
    // freopen("a.gir","r",stdin);      
    // freopen("a.cik","w",stdout);
    cin>>s;
    scanf("%lld",&d);
    n=s.size();
    memset(dp,-1,sizeof(dp));

    printf("%lld\n", (dpf(0,0,0)-1+mod)%mod);

}


Measured memory_bytes: 240128
h,w=map(int,input().split())
if h%3==0 or w%3==0:
    print(0)
else:
    x=[]
    for i in range(1,w):
        sub=[]
        sub.append([h*i,h*((w-i)//2),h*(w-i)-h*((w-i)//2)])
        #sub.append([h*i,h*((w-i)//2+1),h*(w-i)-h*((w-i)//2+1)])
        sub.append([h*i,(w-i)*(h//2),h*(w-i)-(w-i)*(h//2)])
        #sub.append([h*i,(w-i)*(h//2+1),h*(w-i)-(w-i)*(h//2+1)])
        for j in sub:
            x.append(max(j)-min(j))
    for i in range(1,h):
        sub=[]
        sub.append([w*i,w*((h-i)//2),w*(h-i)-w*((h-i)//2)])
        #sub.append([w*i,w*((h-i)//2+1),w*(h-i)-w*((h-i)//2+1)])
        sub.append([w*i,(h-i)*(w//2),w*(h-i)-(h-i)*(w//2)])
        #sub.append([w*i,(h-i)*(w//2+1),w*(h-i)-(h-i)*(w//2+1)])
        for j in sub:
            x.append(max(j)-min(j))
    print(min(x))


Measured memory_bytes: 18924
#include <stdio.h>
#include<string.h>
char a[1000000][900],b[900];
int main()
{int i,j,n,l,s,p,z;
  while(~scanf("%d%d",&n,&l))
   {p=0,z=0;
   for(i=0;i<n;i++)
   scanf("%s",a[i]);
   for(s=0;s<n-1;s++)
    for(p=0;p<n-1-s;p++)
      for(j=0;j<l;j++)
        if(a[p][j]<a[p+1][j])
         break;
         else
      if(a[p][j]>a[p+1][j])
	  {
	  strcpy(b,a[p]);
      strcpy(a[p],a[p+1]);
      strcpy(a[p+1],b);
     
      break;
      }
      
      for(i=0;i<n;i++)
        printf("%s",a[i]);
        printf("\n");
}
}

Measured memory_bytes: 384
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<stack>
#include<queue>
#include<algorithm>
#include<vector>
#include<math.h>
#include<bitset>
#include<iomanip>
using namespace std;

typedef stack<int> IntStack;
typedef queue<int> IntQueue;

const double pi = 3.141592653589793;


//文字0~9をint型0~9に変換
int char_to_int(char c)
{
	if (c == '0') return 0;
	if (c == '1') return 1;
	if (c == '2') return 2;
	if (c == '3') return 3;
	if (c == '4') return 4;
	if (c == '5') return 5;
	if (c == '6') return 6;
	if (c == '7') return 7;
	if (c == '8') return 8;
	if (c == '9') return 9;
	else return -1;
}
//a^b mod MODを計算
long long int ModPower(long long int a, long long int b, long long int MOD)
{
	if (b == 0) return 1;
	else if (b % 2 == 0)
	{
		long long int d = ModPower(a, b / 2, MOD);
		return (d*d) % MOD;
	}
	else
	{
		return (a*ModPower(a, b - 1, MOD)) % MOD;
	}
}
//nCr mod MODを計算
long long int ModCombi(long long int n, long long int r, long long int MOD)
{
	if (n == 0 || r == 0) return 1;

	long long int Kn=1, Kr=1, Knr=1;

	long long int temp = 1;
	for (long long int i = 1; i <= n; i++)
	{
		temp *= i;
		temp %= MOD;
		if (i == n) Kn = temp;
		if (i == r) Kr = temp;
		if (i == n - r) Knr = temp;
	}

	long long int x = ModPower(Kr, MOD - 2, MOD);
	long long int y = ModPower(Knr, MOD - 2, MOD);

	long long int ans;
	ans = Kn * x;
	ans %= MOD;
	ans *= y;
	ans %= MOD;

	return ans;
}


/*ここまでテンプレ*//*ここまでテンプレ*//*ここまでテンプレ*//*ここまでテンプレ*/



int main()
{
	int N, M;
	int k[10], s[10][10];
	int p[10];

	cin >> N >> M;
	for (int i = 0; i < M; i++)
	{
		cin >> k[i];

		for (int j = 0; j < k[i]; j++)
		{
			cin >> s[i][j];
		}
	}
	for (int i = 0; i < M; i++)
	{
		cin >> p[i];
	}

	int all = (int)pow(2, N);
	/*cout << "all=" << all << endl;*/

	int sw[10];
	int ans = 0;

	for (int i = 0; i < all; i++)
	{
		for (int j = 0; j < N; j++)
		{
			sw[j] = (i / (int)pow(2, j)) % 2;
		}
		/*cout << "Now:";
		for (int y = 0; y < N; y++)
		{
			cout << sw[y] << " ";
		}
		cout << endl;*/

		bool ch = true;

		for (int j = 0; j < M; j++)
		{
			int x = 0;
			for (int l = 0; l < k[j]; l++)
			{
				x += sw[s[j][l]-1];
			}
			x = x%2;
			/*cout << "x=" << x << endl;*/

			if (x != p[j])
			{
				ch = false;
				break;
			}
		}

		if(ch) ans++;
	}

	cout << ans;

	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
       public static void main(String[] args) {
    	   Scanner sc = new Scanner(System.in);
           int n = sc.nextInt();
           int[] a = new int[n];
           for (int i = 0; i < n; i++)
               a[i] = sc.nextInt();
           for (int i = a.length - 1; i >= 0; i--) {
               if (i == a.length - 1)
                   System.out.print(a[i]);
               else
                   System.out.print(" " + a[i]);
           }
           System.out.println();
       }
   }


Measured memory_bytes: 26260
N = int(input())
a_list = list(map(int,input().split()))

# def exec_cnt_and_s(s,i,one_is_pos):
#     if 

def count_operation(one_is_pos):
    cnt = 0
    s = 0
    for i, a in enumerate(a_list):
        s += a
        if one_is_pos:
            if i % 2 == 0:
                if s <= 0:
                    cnt += -s + 1
                    s = 1
            else:
                if s >= 0:
                    cnt += s + 1
                    s = -1
        else:
            if i % 2 == 1:
                if s <= 0:
                    cnt += -s + 1
                    s = 1
            else:
                if s >= 0:
                    cnt += s + 1
                    s = -1
    return cnt

print(min(count_operation(True),count_operation(False)))

Measured memory_bytes: 63216
#include <bits/stdc++.h>
#include <stdio.h>
#include <algorithm>
#include <map>
#include <string>
using namespace std;
#define r(i,n) for(int i=0;i<n;i++)
#define ll long long
#define rn(i,n) for(int i=1;i<=n;i++)
#define N 1000;
#define INF 1000000007

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

vector<pair<int,int> > p(n+1);
p[1]=make_pair(1,0);
//vector<int> a(1001,0);
ll cnt;

//cout<<"hello"<<endl;
for(int i=2;i<=n;i++){
  cnt=0;
  for(int j=2;j<=i;j++){
    if(i%j==0)cnt++;
  }
  if(cnt==1)p[i]=make_pair(i,0);
}

//cnt=0;
ll sum=1;

for(int i = 2;i <= n;i++){
  cnt=0;
  for(int j = 2;j <= i;j++){
  //  cout<<p[j].first<<endl;
  //cout<<i<<" "<<j<<endl;
    if(p[j].first!=0 and i % p[j].first == 0){
        ll tmp=i;
          while(tmp%p[j].first==0){
            tmp/=p[j].first;
            p[j].second++;
            //cout<<i<<" "<<j<<" "<<p[j].second<<endl;
          }
//          cnt++;
  //        cout<<i<<" "<<p[j].first<<" "<<cnt<<endl;
    }
  }
}


for(int i=2;i<=p.size();i++){
      sum*=(p[i].second+1);
      sum=sum % INF;
      //cout<<p[i].second<<endl;;
      //cout<<sum<<endl;
}




cout<<sum<<endl;

//r(i,p.size()+1)cout<<p[i].first<<endl;


return 0;
}


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

struct P
{
    int x,y;
    bool operator<(const P &a)const{
        if(y!=a.y) return y>a.y;
        return x>a.x;
    }
};

vector<P> v;
//bitset<4001000> b;
int i,n,d,m,k,a,b,c;
int e;
int o[1];
int l[1];
int j[1];

int dx[10]={0,1,0,-1,1,1,-1,-1},dy[10]={1,0,-1,0,1,-1,1,-1},dz[10]={0,0,0,0,1,-1};
int px[10]={-1,1,1,-1,1,1,-1,-1},py[10]={1,1,-1,-1,1,-1,1,-1};
long long mod=1000000007,mod2=1000000009,mod3=2017;
long long x,z,y;
double pi=3.14159265;
P u[1];
stack<int> s;
//set<int> se[33],s1;

//priority_queue<P> q;
queue<int> q;
string r;

char r1[1],r2[1];
//2147483647
//'1'==49;
//'A'==65;
//'a'==97;
//unordered_
//map<int,int> p;
//v.resize(unique(v.begin(),v.end())-v.begin());

bool as(P a,P b)
{
    if(a.x!=b.x)
    //return a.y>b.y;
    return a.x<b.x;
    return a.y<b.y;
}

//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
//rng();



int main()
{
    scanf("%lld",&x);
    for(long long t=1;t*t<=x;t++)
    if(x%t==0)
    {
        if((x/t-1)>t) y+=x/t-1;
    }
    printf("%lld",y);
}


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

int main()
{
    int a, b, k;
    cin >> a >> b >> k;
    vector<int> ans;
    
    for (int i = 1; i <= min(a, b); ++i)
    {
        if (a % i == 0 && b % i == 0) ans.push_back(i);
    }
    cout << ans[ans.size() - k] << endl;
}

Measured memory_bytes: 256
#nの約数とn-1の約数全部愚直
n = int(input())
fct1 = []
fct2 = []
for i in range(1,int(n**(1/2))+10):
    if n%i==0:
        fct1.append(i)
        fct2.append(n//i)
    if (n-1)%i==0:
        fct1.append(i)
        fct2.append((n-1)//i)

fct = set(fct1+fct2)
if 1 in fct:
    fct.remove(1)
ans = 0
for k in fct:
    n2 = n
    while n2 and n2%k==0:
        n2//=k
    n2%=k
    if n2==1:
        ans += 1
print(ans)

Measured memory_bytes: 40924
#include<iostream>
#include<set>
#include<cstring>
using namespace std;
int main()
{
	int n;
	cin>>n;
	string str;
	char c;
	cin>>str;
	set<string> s;
	c=str[str.length()-1];
	s.insert(str);
	int flag=1;
	for(int i=1;i<n;i++){
		cin>>str;
		if(c!=str[0]||s.count(str))
			flag=0;
		s.insert(str);
		c=str[str.length()-1];
	}
    if(flag==0){
    	cout<<"No";
	}else{
		cout<<"Yes";
	}
} 



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

int main(){
  int N;
  cin >> N;
  vector<int> data(N);
  int sum = 0;
  for(int i = 0; i < N; i++){
    cin >> data.at(i);
    sum = sum + data.at(i);
  }
  int mean_1 = sum / N, mean_2 = sum / N + 1;
  int point_1, point_2;
  for(int i = 0; i < N; i++){
    point_1 = point_1 + (data.at(i) - mean_1) * (data.at(i) - mean_1);
    point_2 = point_2 + (data.at(i) - mean_2) * (data.at(i) - mean_2);
  }
  int point = min(point_1, point_2);
  cout << point <<endl;
}

Measured memory_bytes: 256
#include<cmath>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
const int maxn=4000;
const int mod=1e9+7;
int n,k;

int read()
{
    int x=0,f=1;char ch=getchar();
    for (;ch<'0'||ch>'9';ch=getchar()) if (ch=='-') f=-1;
    for (;ch>='0'&&ch<='9';ch=getchar()) x=x*10+ch-'0';
    return x*f;
}

int power(int a,int k)
{
    if(k<0) return 1;
    int sum=1;
    for (;k;k>>=1,a=1ll*a*a%mod)
	if (k&1)
	    sum=1ll*sum*a%mod;
    return sum;
}

int fac[maxn+10],ifac[maxn+10],inv[maxn+10];

int C(int a,int b){return (a<0)||(b<0)||(a<b)?0:1ll*fac[a]*ifac[b]%mod*ifac[a-b]%mod;}

int F(int i,int j){return 1ll*C(i+j,i)*(i-j+1)%mod*inv[i+1]%mod;}

int main()
{
    fac[0]=inv[0]=inv[1]=ifac[0]=1;
    for(int i=1; i<=maxn; ++i)
	{
	    fac[i]=1ll*fac[i-1]*i%mod;
	}
    for(int i=2; i<=maxn; ++i) inv[i]=1ll*(mod-mod/i)*inv[mod%i]%mod;
    for(int i=1; i<=maxn; ++i) ifac[i]=1ll*ifac[i-1]*inv[i]%mod;
    n=read(),k=read();
    printf("%lld\n",1ll*F(n-1,k-1)*power(2,n-k-1)%mod);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
#include <vector>
#include <numeric>
#include <map>
#include <cmath>
#include <iomanip>
#include <queue>
using ll =long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vs = vector<string>;

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

    if(W>=S){
        cout << "unsafe" << endl;
    }
    else{
        cout << "safe" << endl;
    }

}


Measured memory_bytes: 3104
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
#include <bitset>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define show(x) cout << #x << " = " << (x) << endl;
using namespace std;
using ll = long long;
using pii = pair<int,int>;
ll mod = 998244353;
ll combi(ll N_, ll C_) {
    const int NUM_=8005;
    static ll fact[NUM_+1],factr[NUM_+1],inv[NUM_+1];
    if (fact[0]==0) {
        inv[1]=fact[0]=factr[0]=1;
        for (int i=2;i<=NUM_;++i) inv[i] = inv[mod % i] * (mod - mod / i) % mod;
        for (int i=1;i<=NUM_;++i) fact[i]=fact[i-1]*i%mod, factr[i]=factr[i-1]*inv[i]%mod;
    }
    if(C_<0 || C_>N_) return 0;
    return factr[C_]*fact[N_]%mod*factr[N_-C_]%mod;
}
ll hcomb(ll P_,ll Q_) { return (P_==0&&Q_==0)?1:combi(P_+Q_-1,Q_);}
ll mod_pow(ll a,ll b){//a^b
    ll ans = 1;
    while(b!=0){
        if(b%2==0){
            b = b/2;
            a = (a*a)%mod;
        }
        else{
            ans = (ans *a)%mod;
            b--;
        }
    }
    return ans;
}
int main(){
    ll k, n;
    cin >> k >> n;
    vector<ll>res;
    for(ll i = 2; i <= 2 * k; i++){
        ll ans = 0;
        if(i%2){
            ll jiyu = max(0LL,k-i+1);
            ll pea = i/2;
            for(ll q = 0; q <= pea; q++){
                ans = (ans + mod_pow(2,q)*combi(pea,q)%mod*combi(q-1+jiyu+n-q-1+1,q-1+jiyu-1+1))%mod;
            }
        }else{
            //i/2が0個
            {
                ll jiyu = max(0LL,k-i+1);
                ll pea = i/2-1;
                for(ll q = 0; q <= pea; q++){
                    ans = (ans + mod_pow(2,q)*combi(pea,q)%mod*combi(q-1+jiyu+n-q-1+1,q-1+jiyu-1+1))%mod;
                }
            }
            //1個
            {
                ll jiyu = max(0LL,k-i+1);
                ll pea = i/2-1;
                for(ll q = 0; q <= pea; q++){
                    ans = (ans + mod_pow(2,q)*combi(pea,q)%mod*combi(q-1+jiyu+(n-1)-q-1+1,q-1+jiyu-1+1))%mod;
                }
            }
        }
//        cout << ans << endl;
        res.push_back(ans);
    }
    rep(i,res.size()){
        if(i < k){
            cout << res[i] << "\n";
        }else{
            cout << res[res.size()-i-1] << "\n";
        }
    }
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <iomanip>
#include <map>
using namespace std;

#define INF 1e9
#define LLINF 1e18
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;

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


int main() {
    int a, b, c, d, e;
    cin >> a >> b >> c >> d >> e;
    cout << 15 - (a + b + c + d + e) << endl;
}

Measured memory_bytes: 3548
#include<stdio.h>
int main(){
  double w,h,x,y;
  int cnt=0;
  scanf("%lf %lf %lf %lf",&w,&h,&x,&y);
  double ans=w*h/2;
  if(x==w/2 && y==h/2)
    cnt++;
  printf("%f %d\n",ans,cnt);
  return 0;
}

Measured memory_bytes: 128
/******************************************
 *  Author : Atul Anand   
 *  Created On : Sat Feb 08 2020
 *******************************************/

import java.io.*;
import java.util.*;

public class Main{
    
    public static void main(String[] args) throws IOException {
        int N=in.nextInt();
        int W=in.nextInt();
        int w[]=new int[N];         // weights
        int v[]=new int[N];         // values
        
        for(int i=0;i<N;i++){
            w[i]=in.nextInt();
            v[i]=in.nextInt();
        }

        long dp[][]=new long[W+1][N+1];
        
        // No infinite supply of items
        for(int i=1;i<=W;i++){
            for(int j=1;j<=N;j++){
                if(w[j-1]>i){
                    dp[i][j]=dp[i][j-1];
                }
                else{
                    dp[i][j]=Math.max(dp[i-w[j-1]][j-1]+v[j-1], dp[i][j-1]);
                }
            }
        }
        println(dp[W][N]);
        in.close();
        out.close();
    }

    static int MIN = Integer.MIN_VALUE;
    static int MAX = Integer.MAX_VALUE;
    static Reader in = new Reader();
    static PrintWriter out = new PrintWriter(System.out);
    static void read(int arr[], int N) throws IOException{ for(int i=0;i<N;i++){ arr[i]=in.nextInt(); } }
    static void read(long arr[], int N) throws IOException{ for(int i=0;i<N;i++){ arr[i]=in.nextLong(); } }
    static void read(String arr[], int N) throws IOException{ for(int i=0;i<N;i++){ arr[i]=in.next(); } }
    static void print(Object O){ out.print(O); }
    static void println(Object O){ out.println(O); }
    static void print(int arr[]){ for(int i=0;i<arr.length;i++){ print(arr[i]+" "); } println(""); }
    static void print(int arr[][]){ for(int i=0;i<arr.length;i++){ print(arr[i]); } }
    static void debug(Object O){ System.out.println(O); }
}

class Reader {
    BufferedReader reader;
    StringTokenizer tokenizer;

    Reader() {
        reader = new BufferedReader(new InputStreamReader(System.in));
        tokenizer = new StringTokenizer("");
    }

    String next() throws IOException {
        while (!tokenizer.hasMoreTokens() ) { tokenizer=new StringTokenizer(reader.readLine()); }
        return tokenizer.nextToken();
    }

    int nextInt() throws IOException { return Integer.parseInt(next()); }
    double nextDouble() throws IOException { return Double.parseDouble(next()); }
    long nextLong() throws IOException { return Long.parseLong(next()); }
    String nextLine() throws IOException { return reader.readLine(); }
    void close() throws IOException { reader.close(); }
}

Measured memory_bytes: 127572
#include <algorithm>
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<string>

#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<limits.h>

using namespace std;
int main(){
  string str;
  int n,ii;
  int arr[] = {111,222,333,444,555,666,777,888,999};
  cin >> n;

  for(ii=0;ii<=8;ii++){
	if(n<=arr[ii]){
	  break;
	}
  }

  cout << arr[ii] << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define int_Max 2147483647
#define ll_Max 9223372036854775807
#define REP(i,f,n) for(int i=f; i<(n); i++)
bool key1[26], key2[26];

void kazu(string s, int a){
  int ans = 0, n = s.length();
  if(a==0)REP(i,0,26)key1[i] = false;
  else REP(i,0,26)key2[i] = false;
  REP(i,0,n){
    int c = s[i] - 'a';
    if(a==0){if(key1[c])continue;}
    else {if(key2[c])continue;}
    if(a==0)key1[c] = true;
    else key2[c] = true;
    ans++;
  }
}

int main()
{
  int ans = 0, n;
  string s;
  cin >> n;
  cin >> s;
  REP(i,1,n){
    int cnt = 0;
    string h1 = s.substr(0,i);
    string h2 = s.substr(i,n);
    kazu(h1, 0);
    kazu(h2, 1);
    REP(j,0,26){
      if(!(key1[j] && key2[j]))continue;
      cnt++;
    }
    ans = max(ans, cnt);
  }
  cout << ans << endl;

  //--debug : end_stoper
  //string end_stoper; cin >> end_stoper;

  return 0;
}

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

using ll = long long;
// #define int long long
using P = pair<int, int>;
#define LOG(variable) cout << #variable":\t" << (variable) << endl
#define LOGCON(i, container) for(int (i) = 0; (i) < (container).size(); ++(i)) cout << (i) << ":\t" << (container)[(i)] << endl
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(i, r, n) for (int i = (r); i < (n); ++i)
#define REPR(i, n) for(int i = (n); i >= 0; --i) // from n to 0
#define REPRS(i, r, n) for(int i = (n); i >= (r); --i) // from n to r
#define REPOBJ(itr, obj) for(auto itr = (obj).begin(); itr != (obj).end() ; ++itr)
#define REPROBJ(itr, obj) for(auto itr = (obj).rbegin(), e = (obj).rend(); itr != e; ++itr)
#define COUTB(x) cout << (x) << "\n"
#define COUTS(x) cout << (x) << " "
#define PB push_back
#define SORT(obj) sort((obj).begin(), (obj).end())
#define SORTR(obj) sort((obj).begin(), (obj).end(), greater<>())
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define PI (acos(-1))
/***** MAIN *****/
signed main() {
  int H, W;
  cin >> H >> W;
  int coins[H][W];
  REP(i,H) {
    REP(j,W) {
      cin >> coins[i][j];
    }
  }
  int count = 0;
  vector<P> command;
  bool moving_coin = false;
  int prev_y;
  int prev_x;
  REP(y,H) {
    REP(x,W) {
      int cur_y = y;
      int cur_x = x;
      if(cur_y%2) cur_x = W - 1 - x;
      if(moving_coin) {
        ++coins[cur_y][cur_x];
        ++count;
        command.PB(P(prev_y+1, prev_x+1));
        command.PB(P(cur_y+1, cur_x+1));
      }
      if(coins[cur_y][cur_x]%2) {
        moving_coin = true;
        prev_y = cur_y;
        prev_x = cur_x;
      } else {
        moving_coin = false;
      }
    }
  }
  cout << count << endl;
  REP(i,count) {
    COUTS(command[i*2].first);
    COUTS(command[i*2].second);
    COUTS(command[i*2+1].first);
    COUTB(command[i*2+1].second);
  }
  return 0;
}
/***** MAIN *****/


Measured memory_bytes: 5104
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define mp make_pair
#define pb(x) push_back(x)
#define vi vector<int>
#define vs vector<string>
#define vll vector<long long>
#define vc vector<char>
#define vs vector<string>
#define pii pair<int, int>
#define pll pair<long long, long long>
#define pil pair<int, long long>
#define pli pair<long long, int>
#define pcc pair<char, char>
#define pdd pair<double, double>
#define mll map<long long, long long>
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(), (v).end()
#define flsh fflush(stdout)
#define gcd __gcd
#define clr(x) memset(x, 0, sizeof(x))
#define mod 1000000007LL
#define mod2 998244353LL
#define INF 1000000000007

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> o_tree;

ld dist(ll x,ll y)
{
    ld res = x*x+y*y;
    res=sqrt(res);
    return res;
}

void solve()
{
    ll k;
    cin>>k;
    ll p10=1;
    ll i;
    ll rem=0;
    for(i=1;i<=k;i++)
    {
      rem+=(7*(p10))%k;
      rem%=k;
      p10*=10ll;
      p10%=k;
      if(rem==0)
      {
          cout<<i<<"\n";
          return;
      }
    }
    cout<<"-1\n";
    return;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    if (fopen("input.txt", "r"))
    {
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    }
    cout << setprecision(20);

    ll t = 1;

    // cin>>t;

    while (t--)
    {
        solve();
    }

    return 0;
}

Measured memory_bytes: 3700
n, k = map(int, input().split())
h = [int(i) for i in input().split()]

dp = [0] * n
dp[1] = abs(h[1] - h[0])

for i in range(2,n):
    min_cost = 999999999
    for j in range(1,min(i,k)+1):
        tmp = dp[i-j] + abs(h[i] - h[i-j])
        min_cost = min(min_cost, tmp)
    dp[i] = min_cost

print(dp[n-1])

Measured memory_bytes: 52576
s = str(input())

if s == 'SUN':
  print(7)
elif s == 'MON':
  print(6)
elif s == 'TUE':
  print(5)
elif s == 'WED':
  print(4)
elif s == 'THU':
  print(3)
elif s == 'FRI':
  print(2)
else:
  print(1)

Measured memory_bytes: 38256