akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main(void){
    
    int r,g,b,n;
    cin >> r >> g >> b >> n;
    
    int ans = 0;
    for(int i = 0; i <= 3000; i++){
        for(int j = 0; j <= 3000; j++){
            //binary search
            int  l = 0; int R = 3001;
            while(R-l > 1){
                int mid = (l+R)/2;
                if(r*i+g*j+b*mid <= n) l = mid;
                else R = mid;
            }
            if(r*i+g*j+b*l == n) {ans += 1;
            }
            //
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3596
from collections import Counter
s = list(map(int,list(input())))

t = 0
cusum = []
for i in range(len(s))[::-1]:
  t += s[i]*pow(10,len(s)-i-1,2019)
  t %= 2019
  cusum.append(t)
  
counter = Counter(cusum)

ans = counter[0]
for v in counter.values():
  ans+=v*(v-1)//2

print(ans)

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


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int xd;
    cin>>xd;
    if(xd<1200)
        cout<<"ABC";
    else
    if(xd<2800)
        cout<<"ARC";
    else
        cout<<"AGC";
}


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

void Main()
{
	int A, B; cin >> A >> B;
	if (A < B) swap(A, B);
	cout << (A == B ? A + B : A * 2 - 1) << endl;
}

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


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

int main(void) {
    int n, m, s, c = 0; 
    cin >> n >> m;
    vector<int> a(n);
    for (int i=0; i<n; i++) cin >> a[i];
    s = accumulate(a.begin(), a.end(), 0);
    
    for (int i=0; i<n; i++) {
        if (4 * m  * a[i] >= s) c++;
    }
    if (c >= m) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

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

///---OPTIMIZE---///
#define BOOST ios_base::sync_with_stdio(false);cin.tie(NULL);

///---DATA TYPE---///
typedef long long ll;
typedef long long int lli;
typedef vector<int> vi;
typedef map<int,int> mpii;
typedef pair<int,int> pii;

///---INPUT---///
#define sf                        scanf
#define ss(ch)                    scanf("%s",ch)

#define sfi(a)                    sf("%d",&a)
#define sfii(a,b)                 sf("%d %d",&a,&b)
#define sfiii(a,b,c)              sf("%d %d %d",&a,&b,&c)

#define sfl(a)                    sf("%ll",&a)
#define sfll(a,b)                 sf("%ll %ll",&a,&b)
#define sflll(a,b,c)              sf("%ll %ll %ll",&a,&b,&c)

#define sflli(a)                  sf("%lld",&a)

///---OUTPUT---///
#define pf                        printf
#define pfi(a)                    pf("%d\n",a)
#define pfii(a,b)                 pf("%d %d\n",a,b)
#define pfiii(a,b,c)              pf("%d %d %d\n",a,b,c)
#define pfl(a)                    pf("%ll\n",a)
#define pfll(a,b)                 pf("%ll %ll\n",a,b)
#define pflll(a,b,c)              pf("%ll %ll %ll\n",a,b,c)

#define pflli(a)                  pf("%lld",&a)

///---NEWLINE---///
#define nlc                       pf("\n")
#define nlcpp                     cout<<"\n"

///---LOOP---///
#define rep0(ini,end)             for(ini=0;ini<end;ini++)
#define rep1(ini,end)             for(ini=1;ini<=end;ini++)
#define rep(ini,start,end)        for(ini=start;ini<=end;ini++)
#define repinc(ini,start,end,inc) for(ini=start;ini<=end;ini+=inc)

///---VECTOR---///
#define v                         vector
#define vi(a)                     v<int>a
#define pb                        push_back



int i,j,k;

int main()
{
    BOOST

    int t;
    //cin>>t;
    t=1;
    while(t--)
    {
        int h1,m1,h2,m2,k;
        cin>>h1>>m1>>h2>>m2>>k;
        int h=h2-h1;
        int m=m2-m1;
        int studyTime=h*60+m;
        //cout<<h*60<<" "<<m<<endl;
        if(studyTime<=k) cout<<"0"<<endl;
        else cout<<studyTime-k<<endl;
    }
    return  0;
}



Measured memory_bytes: 3636
#include <stdio.h>
int main(void) {
	int i, n, minj, j, A[1000], temp, count = 0;
	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		scanf("%d", &A[i]);
	}
	for (i = 0; i < n; i++) {
		minj = i;

		for (j = i; j < n; j++) {
			if (A[j] < A[minj]) {
				minj = j;
			}
		}
		if (A[minj] == A[i]) {
			continue;
		} else {
			temp = A[i];
			A[i] = A[minj];
			A[minj] = temp;
			count++;
		}
	}
	for (i = 0; i < n - 1; i++) {
		printf("%d ", A[i]);
	}
	printf("%d\n", A[n - 1]);
	printf("%d\n", count);
	return 0;
}

Measured memory_bytes: 604
// ※※※ 解答不能 ※※※
// vjudge5氏.
// https://atcoder.jp/contests/tenka1-2017-beginner/submissions/1935464
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
#define repex(i, a, b, c) for(int i = a; i < b; i += c)
#define repx(i, a, b) repex(i, a, b, 1)
#define rep(i, n) repx(i, 0, n)
#define repr(i, a, b) for(int i = a; i >= b; i--)

int main(){
    LL n;
    scanf("%lld", &n);
    repx(a, n / 4 + 1, 3501){
        repx(b, a * n / (4 * a - n) + 1, 3501){
            LL x = a * b * n % (4 * a * b - n * (a + b));
            LL c = a * b * n / (4 * a * b - n * (a + b));
            if(x == 0 && c > 0){
                printf("%lld %lld %lld\n", a, b, c);
                return 0;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <list>
#include <utility>

int main()
{
	int n;
	std::string s;
	std::cin >> n >> s;
	
	unsigned int cnt = 0;
	std::list<char> ls(3);
	for (int i = 0; i < n - 3; i++) {
		ls.assign({'R', 'G', 'B'});
		ls.remove(s[i]);
		char a = ls.front();
		char b = ls.back();
		for (int c = 0; c < 2; c++) {
			for (int j = i + 1; j < n - 1; j++) {
				if (s[j] == a) {
					for (int k = j + 1; k < n; k++) {
						if (s[k] == b && j - i != k - j) {
							cnt++;
						}
					}
				}
			}
			if (c == 0) {
				std::swap(a, b);
			}
		}
	}
	
	std::cout << cnt << std::endl;
	
	return 0;
}


Measured memory_bytes: 3200
#include <iostream>
#include <bits/stdc++.h>
#include <string>
#include <math.h>
using namespace std;

int main(){
  int n; cin>>n;
  int p[n];
  for(int i=0;i<n;i++) cin>>p[i];
  int k=0;
  for(int i=0;i<n;i++){
    if(p[i]!=i+1) k++;
  }
  if(k<=2) cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
  return 0;
}

Measured memory_bytes: 256
io = STDIN
a,b,h,m=io.gets.split.map(&:to_i)

def deg(h,m)
  (h.to_f*60+m)/720
end

mm=m.to_f/60
hh=deg(h,m)
d=[(hh-mm).abs*360,360-(hh-mm).abs*360].min
# p deg(10,40)

def rad(d);d*Math::PI/180;end
x=a*Math.sin(rad(d))
y=a*Math.cos(rad(d))
puts Math.sqrt((b-y)**2+x**2)


Measured memory_bytes: 14692
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define all(aaa) aaa.begin(), aaa.end()

const int N = 505;
const int dx[4] = {-1, 1, 0, 0}, dy[4] = {0, 0, 1, -1};
int a[N][N];
bool used[N][N];

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

    int n;
    cin >> n;

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            a[i][j] = min(min(i, j), min(n - i, n - j) - 1);
        }
    }

    queue<pair<int, int>> q;

    int ans = 0;
    for (int i = 0; i < n * n; i++) {
        int x;
        cin >> x;
        x--;

        int y = x % n;
        x /= n;
        ans += a[x][y];

        // cout << x << " " << y << " " << a[x][y] << "\n";

        used[x][y] = true;

        for (int j = 0; j < 4; j++) {
            int g = x + dx[j],
                h = y + dy[j];
            if (g >= 0 && g < n && h >= 0 && h < n) {
                a[x][y] = min(a[x][y], a[g][h] + !used[g][h]);
            }
        }

        q.push({x, y});

        while (!q.empty()) {
            int cx = q.front().first,
                cy = q.front().second;
            q.pop();

            for (int j = 0; j < 4; j++) {
                int g = cx + dx[j],
                    h = cy + dy[j];
                if (g >= 0 && g < n && h >= 0 && h < n && 
                    a[g][h] > a[cx][cy] + !used[cx][cy]) {
                    a[g][h] = a[cx][cy] + !used[cx][cy];
                    q.push({g, h});
                }
            }
        }
    }

    cout << ans << "\n";


    return 0;
}

Measured memory_bytes: 4884
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
const ll mod=1000000007;
const ll INF=1e15;
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)

int main(){
  ll H,W,N; cin>>H>>W>>N;
  if(H>W) swap(H,W);
  cout<<(N+W-1)/W<<endl;
}

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

int main(){
  string str;
  int n, s, w, e;
  n = s = w = e = 0;
  cin >> str;
  for(int i = 0; i < str.length(); i++){
    if(str[i] == 'N') n++;
    else if(str[i] == 'E') e++;
    else if(str[i] == 'S') s++;
    else w++;
  }
  if(n == 0 && s == 0) {
    if(w != 0 && e != 0) cout << "Yes" << endl;
    else cout << "No" << endl;
  } else if(n != 0 && s != 0) {
    if((w != 0 && e != 0)||(w == 0 && e == 0)) cout << "Yes" << endl;
    else cout << "No" << endl;
  } else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <vector>
#include <math.h>
#include <iostream>
#include <iomanip>      // std::setprecision

using namespace std;

double prob_gt[3000][3000];


int main(){

  int N;
  cin >> N;

  double prob[3000];
  
  for(int i = 0; i < N; i++){
    double p;
    cin >> p;
    prob[i+1] = p;
  }

  prob_gt[1][0] = 1 - prob[1];
  prob_gt[1][1] = prob[1];
  
  for(int i = 2; i <= N; i++){
    for(int j = 0; j <= i ; j++){
      if(j != 0)
	prob_gt[i][j] = prob_gt[i-1][j] * ( 1 - prob[i]) + prob_gt[i-1][j-1] * prob[i];
      else
	prob_gt[i][j] = prob_gt[i-1][j] * ( 1 - prob[i]);
    }
  }

  double ans = 0.0;

  int limit = N / 2 + 1;

  for(int i = limit; i <= N; i++){
    ans += prob_gt[N][i];
  }

  cout << setprecision(10) <<  ans << endl;
  
  
  
  return 0;
}


Measured memory_bytes: 68864
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;
 
public class Main {
	public static void main(String[] args) {
		FastReader sc = new FastReader();
		int n = sc.nextInt();
		int max = Integer.MIN_VALUE;
		int min = Integer.MAX_VALUE;
		
		for (int i = 0; i < n; i++) {
			int loc = sc.nextInt();
			max = Math.max(max, loc);
			min = Math.min(min, loc);
		}
		System.out.println(max - min);
	}
  
    static class FastReader {
	    BufferedReader br;
	    StringTokenizer st;
	
	    public FastReader() {
	      br = new BufferedReader(new InputStreamReader(System.in));
	    }
	  
	    String next() { 
	      while (st == null || !st.hasMoreElements()) {
	        try {
	          st = new StringTokenizer(br.readLine());
	        } catch (IOException  e) {
	          e.printStackTrace();
	        }
	      }
	      return st.nextToken();
	    }
	
	    int nextInt() {
	      return Integer.parseInt(next());
	    }
	
	    long nextLong() {
	      return Long.parseLong(next());
	    }
	
	    double nextDouble() { 
	      return Double.parseDouble(next());
	    }
	
	    String nextLine() {
	      String str = "";
	        try{
	            str = br.readLine();
	        } catch (IOException e) {
	            e.printStackTrace();
	        }
	        return str;
	      }
	  }
}

Measured memory_bytes: 23124
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <numeric>
#include <complex>
#include <cassert>
#include <random>


int main() {
    int n, m; long long s; std::cin >> n >> m >> s;
    std::vector<std::vector<long long>>
        cost(n, std::vector<long long>(n, -1)),
        minutes(n, std::vector<long long>(n, -1));
    long long sum = 0;
    for (int i = 0; i < m; i++) {
        long long a, b, c, d; std::cin >> a >> b >> c >> d;
        a--; b--;
        cost[a][b] = cost[b][a] = c;
        minutes[a][b] = minutes[b][a] = d;
        sum += c;
    }
    if (sum <= s) s = sum;

    constexpr long long INIT = 1e18;
    std::vector<std::vector<long long>>
        ans(n, std::vector<long long>(sum + 2, INIT));
    std::vector<long long> exchange(n), minutes_exchange(n);
    for (int i = 0; i < n; i++) {
        std::cin >> exchange[i] >> minutes_exchange[i];
    }
    using Node = std::pair<long long, std::pair<long long, long long>>;
    std::priority_queue<Node, std::vector<Node>, std::greater<Node>> que;
    que.push({ 0,{ 0, s } });
    while (!que.empty()) {
        auto node = move(que.top());
        que.pop();
        long long dist = node.first;
        long long pos = node.second.first;
        long long coin = node.second.second;
        if (ans[pos][coin] != INIT) continue;
        ans[pos][coin] = dist;

        for (int i = 0; i < n; i++) {
            if (cost[pos][i] == -1) continue;
            long long nxtcoin = coin - cost[pos][i];
            if (nxtcoin < 0) continue;
            if (ans[i][nxtcoin] != INIT) continue;
            que.push({ dist + minutes[pos][i], { i, nxtcoin } });
        }

        if (coin < sum) {
            long long nxtcoin = std::min(sum, coin + exchange[pos]);
            if (ans[pos][nxtcoin] != INIT) continue;
            que.push({ dist + minutes_exchange[pos], {pos, nxtcoin} });
        }
     }
    for (int i = 1; i < n; i++) {
        std::cout << *std::min_element(ans[i].begin(), ans[i].end()) << std::endl;
    }
    return 0;
}


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

int main() {
  int N; cin >> N;
  int m = 1, n = 0;
  int long long sum = 0;
  
  vector<int> a(N);
  for( int i = 0; i < N; i++ )
    cin >> a.at(i);
  
  for( int i = 0; i < N; i++ ) {
    if( a.at(i) < 0 ) {
      n++;
      a.at(i) *= -1;
    }
  }
  
  sort(a.begin(), a.end());
  for( int i = 0; i < N; i++ )
    sum += a.at(i);
  sum = sum - 2 * a.at(0) * ( n % 2 );
  cout << sum << endl;
  
}

Measured memory_bytes: 640
#include <stdio.h>

struct trump {
    char s;
    int n;
    
};

int main(void)
{
    struct trump a[500], b[500], c[500], t;
    int m, i, j, min;
    
    scanf ("%d", &m);
    
    for ( i = 0; i < m; i++) {
        scanf ( " %c%d", &a[i] .s, &a[i] .n );
        b[i] .s = a[i] .s;
        c[i] .s = a[i] .s;
        b[i] .n = a[i] .n;
        c[i] .n = a[i] .n;
    }
    
    for ( i = 0; i < m; i++) {
        for ( j = m - 1; j > i; j--) {
            if ( b[j] .n < b[j - 1] .n) {
                t = b[j];
                b[j] = b[j - 1];
                b[j - 1] = t;
            }
            
        }
    }
    
    for ( i = 0; i < m; i++ ) {
        min = i;
        for ( j = i; j < m; j++) {
            if ( c[j] .n < c[min] .n){
                min = j;
            }
        }
        t = c[i];
        c[i] = c[min];
        c[min] = t;
    }
    
    for ( i = 0; i < m; i++) {
        printf ( "%c%d", b[i] .s, b[i] .n);
        if ( i != m - 1) {
            putchar ( ' ' );
        }
        else {
            putchar ( '\n');
        }
    }
    printf ( "Stable\n");
    
    for ( i = 0; i < m; i++) {
        printf ("%c%d", c[i] .s, c[i] .n);
        
        if ( i != m - 1 ) {
            putchar ( ' ' );
        }
        else {
            putchar ( '\n' );
        }
    }
    
    for ( i = 0; i < m; i++ ) {
        if (b[i] .s != c[i] .s ) {
            printf ( "Not stable\n" );
            break;
        }
    }
    
    if ( i == m ) {
        printf ( "Stable\n" );
    }
    return 0;
}


Measured memory_bytes: 1992
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<double,double> pd;

typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pi> vpi;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001;

int N,K;
ll ans = 0;

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> N >> K;
    FOR(i,1,N+1) for (int j = 0; j <= N; j += i) {
        int lo = max(1,j+K), hi = min(j+i-1,N);
        if (lo <= hi) ans += hi-lo+1;
    }
    cout << ans;
}

// read the question correctly (is y a vowel?)
// look out for SPECIAL CASES (n=1?) and overflow (ll vs int?)

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define pi pair<int,int>
#define vp vector<pair<int,int> >
#define all(v) v.begin(),v.end()
using namespace std;

signed main(){
    int n;
    cin>>n;
    vi a(n);
    rep(i,n)cin>>a[i];
    int q;
    cin>>q;
    rep(i,q){
        int k;
        cin>>k;
        cout<<(lower_bound(all(a),k)-a.begin())<<" "<<(upper_bound(all(a),k)-a.begin())<<endl;
    }
    return 0;
}


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

int main(){
int n; cin >> n;
vector<pair<int,int>> xy(210);
vector<int> hgs(n);
int nbc=0;
rep(i,n){
    int a; cin >> a;
    hgs[i]=a;
    while(a>0){
    cin >> xy[nbc].first >> xy[nbc].second;
    a--; nbc++;
    }
}

int num=(int)pow(2,n);
int ans=0;
vector<int> k(n);
rep(i,num){
    int count=0;
    bool ch=true;
    int tmp=i;
    rep(j,n){
        k[j]=tmp%2;
        if(k[j]) count++;
        tmp/=2;
    }
    int nc=0;
    for(int cc=0; cc<nbc; nc++){
        if(!k[nc]){
            cc+=hgs[nc];
            continue;
        }
        int nagasa=hgs[nc];
        while(nagasa--){
            if(k[xy[cc].first-1]!=xy[cc].second){
            ch=false;
            break;
           }
        cc++;
        }
    }
    if(ch) ans=max(ans,count);
}
cout << ans << endl;
return 0;
}


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

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP0(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define RREP0(i, n) for (int i = (n)-1; i >= 0; --i)
#define REP1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define RREP1(i, n) for (int i = (n); i >= 1; --i)
#define pow10(n) int(1e##n + n)

typedef long long LL;
typedef pair<int, int> P;

const int INTINF = int(1e9) + 1;
const LL LLINF = LL(1e18) + 1;
long double eps = 1.0E-14;

void solve()
{
    int N;
    cin >> N;
    map<string, int> mp;
    REP0 (i, N)
    {
        string S;
        cin >> S;
        mp[S]++;
    }
    int ans = 0;
    for (auto p : mp)
    {
        ans++;
    }
    std::cout << ans << endl;
}

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(20);
    solve();
    return 0;
}


Measured memory_bytes: 19200
#include <bits/stdc++.h>
#define ll long long int
#define fastread ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
ll mod=1000000007;

using namespace std;

int main(){


    int n,cnt=0;
    cin>>n;
    char arr[n][n];

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

   for(int k=0;k<n;k++){
   		bool chek=true;

   		for(int i=0;i<n;i++){
   			for(int j=0;j<n;j++){
   				if(arr[(i+k)%n][j]!=arr[(j+k)%n][i]){
   					chek=false;
   				}
   			}
   		}
   		if(chek)
   			cnt+=n;
   } 

   cout<<cnt;
  return 0;
}



Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long int ll;
typedef vector<pair<ll,ll> > Q;
typedef pair<int,int> P;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
const ll inf=1e9+7;
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; }

int main(){
  string s;
  cin>>s;

  int len=s.size();

  bool flag=false;
  rep(i,0,len){
    if(i%2){
      if(s[i]=='R') flag=true;
    }
    else{
      if(s[i]=='L') flag=true;
    }
  }

  if(flag) cout<<"No";
  else cout<<"Yes";
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
	int n,x;
	int i,j,k,c=0;
	

	

	while(1){
		scanf("%d %d",&n,&x);
		c =0;
		if(n ==0 && x ==0)break;
		for(i=1;i<=n-2;i++)for(j=i+1;j<=n-1;j++)for(k=j+1;k<=n;k++)if(i+j+k==x)c++;
		printf("%d\n",c);
	}

	return 0;
}

Measured memory_bytes: 600
// lcmとか__builtin_popcountとかはg++ -std=c++17 default.cppみたいなかんじで

#include <bits/stdc++.h>
#define mod 1000000007
#define INF LLONG_MAX
#define ll long long
#define ln cout<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
using namespace std;

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

    ll a,b,c,d,m,n,maxi=0,f=0,mini=INF,sum=0;
    string str;
    cin>>n;
    m=1000;
    a=0;
    //vector<vector<ll>> v(tate,vector<ll> (yoko));
    vector<ll> v(n);
    rep(i,n)   cin >> v[i];
    rep(i,n){
        //cout<<v[i]<<"m="<<m<<" to be";
        if(v[i]<=mini){
            mini=v[i];
            //continue;
        }else{
            //決済
            if(i==n-1||v[i+1]<=v[i]){
                a=m/mini;
                m=m%mini;
                m+=a*v[i];
                mini=INF;
            }
        }
        //cout<<m<<endl;
    }
    cout<<m<<endl;

    return 0;
}


Measured memory_bytes: 3640
#include<stdio.h>

int main(void) {

	int W, H, x, y, r;

	scanf("%d %d %d %d %d", &W, &H, &x, &y, &r);

	if (x - r < 0 || x + r > W || y - r < 0 || y + r > H) {
		printf("No\n");
	}
	
	else if(x - r >= 0 && x + r <= W && y - r >= 0 && y + r <= H) {
		printf("Yes\n");
	}


	return(0);

}


Measured memory_bytes: 2108
#include "bits/stdc++.h"
#ifndef err
#define err(...)(void)0
#endif
using namespace std;
using ll = long long;
using ull = decltype(1ull);
template<class T>int size(T&&a) { return a.size(); }
#define REP(t,a)for(typename make_signed<decltype(a.second)>::type t=a.first,_l##t=a.second;t<_l##t;t++)
#define RREP(t,a)for(typename make_signed<decltype(a.second)>::type t=a.second-1,_l##t=a.first;t>=_l##t;t--)
template<class B>pair<int, B>make_pair(B b) { return{ 0,b }; }
#define rep(t,...)REP(t,make_pair(__VA_ARGS__))
#define rrep(t,...)RREP(t,make_pair(__VA_ARGS__))
#define all(a)begin(a),end(a)
#define rall(a)a.rbegin(),a.rend()
#define var(t, ...) t __VA_ARGS__;in,__VA_ARGS__;

void Calc();
int main() {
  ios::sync_with_stdio(false); cin.tie(nullptr);
  cin.exceptions(istream::failbit | istream::badbit);
  cout << fixed << setprecision(15); Calc(); cout.flush(); return 0;
}
template<class A>void amax(A&a, A b) { a = max(a, b); }
template<class A>void amin(A&a, A b) { a = min(a, b); }
template<class A>int comp(A a, A b) { return a < b ? 1 : b < a ? -1 : 0; }
struct Scanner {
  template<class A = string>A Next() { A a; cin >> a; return a; }
  template<class A = int>vector<A>Array(int n) { vector<A>a(n); for (A&i : a) cin >> i; return a; }
  string Line() const { string s; getline(cin, s); return s; }
  template<class A>Scanner&operator,(A&a) { a = Next<A>(); return *this; }
  template<class A>operator A() { return Next<A>(); }
}in;

/*---------------------------------------------------------------------*/


void Calc() {

  var(int, n, m);

  int c = 1;
  rep(i, m) c *= 2;

  double x = 1.0 / ((1.0 / c)*(1.0 / c));
  x /= c;
  err(x);
  int ans = x * (n - m) * 100 + m * x * 1900;
  cout << (ans) << endl;


}


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

class Program
{
    static void Main(string[] args)
    {
        int N = GetInputInt();
        int[] input = GetInputsInt();

        int topCount = 0;
        int count = 0;

        for (int i = 0; i < N-1; i++)
        {
            if (input[i] >= input[i+1])
            {
                count++;
            }
            else if(topCount < count)
            {
                topCount = count;
                count = 0;
            }
            else
            {
                count = 0;
            }
        }
        if (topCount < count)
        {
            topCount = count;
        }

        Console.Write(topCount);

        Console.ReadKey();
    }


    public static int GetInputInt()
    {
        return int.Parse(Console.ReadLine());
    }
    public static int[] GetInputsInt()
    {
        return Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
    }
    public static List<int> GetInputsIntList()
    {
        return Console.ReadLine().Split(' ').Select(int.Parse).ToList();
    }
    public static List<float> GetInputsFloatList()
    {
        return Console.ReadLine().Split(' ').Select(float.Parse).ToList();
    }

    public static long GetInputLong()
    {
        return long.Parse(Console.ReadLine());
    }
    public static long[] GetInputsLong()
    {
        return Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
    }

}


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

ll gcd(ll a, ll b) {
	if(a==0||b==0) return 0;
	if(a<b) swap(a,b);
	ll tmp = a%b;
	while(tmp!=0) {
		a = b;
		b = tmp;
		tmp = a%b;
	}
	return b;
}

ll fac(ll x) {
	ll f=1;
	for(ll i=2; i<x; i++) {
		f*=i;
	}
	return f;
}

ll npr(ll n, ll r) {
	ll result=1;
	for(ll i=r+1; i<=n; i++) result*=i;
	return result;
}

bool IsPrime(ll num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (ll i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}



int main() {
	int n; cin>>n;
	int sum=n/100000+n/10000%10+n/1000%10+n/100%10+n/10%10+n%10;

	if(sum==1) {
		cout<<10<<endl;
		return 0;
	}
	cout << sum << endl;
}


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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;

int main()
{
    map<string, vector<int>> mp;

    string s;
    int n;
    while (cin >> s >> n)
    {
        mp[s].push_back(n);
    }

    for (auto a : mp)
    {
        OP(a.first);
        sort(ALL(a.second));
        rep(i, a.second.size())
        {
            i != a.second.size() - 1 ? cout << a.second[i] << " " : OP(a.second[i]);
        }
    }

    return 0;
}


Measured memory_bytes: 3192
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd

def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))

sys.setrecursionlimit(10 ** 9)
inf = float('inf')
mod = 10 ** 9 + 7

n = INT()
ans = [1, 1]
for i in range(n):
    t,a = MAP()
    k = max((ans[0] + t - 1) // t, (ans[1] + a - 1) // a)
    ans[0] = k * t
    ans[1] = k * a
    #print('a', t+a, ans)
print(sum(ans))


Measured memory_bytes: 5584
/**

  @@@@@@@  @@@@  @@@@  @@@@  @@@@  @ 
  @  @  @  @  @  @  @  @  @  @  @  @
  @  @  @  @  @  @  @  @  @  @  @  @
  @  @  @  @  @  @  @  @  @  @  @  @
  @  @  @  @@@@  @@@@  @@@@  @  @  @

**/
#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define ull unsigned long long
#define db double
#define ld long double
#define str string
#define pi pair
#define tup tuple
#define vec vector
#define temp template
#define tn typename

#define ff first
#define ss second
#define SZ(x) (ll) x.size()
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define rsz resize
#define ins insert
#define fr front 
#define bc back
#define pf push_front
#define pb push_back
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define mk make_pair

#define FOR(i, a, b) for (ll i = (a); i <= (b); i++) 
#define ROF(i, a, b) for (ll i = (a); i >= (b); i--)
#define trav(a, x) for (auto &a : x)
#define popcount __builtin_popcount
#define ctz __builtin_ctz
#define clz __builtin_clz
#define gcd __gcd

// DEBUG
#define ts to_string
temp<tn A, tn B> str ts(pi<A, B> p);
temp<tn A, tn B, tn C> str ts(tup<A, B, C> p);
str ts(const str& s) { return '"' + s + '"'; }
str ts(const char* s) { return ts((str) s); }
str ts(bool b) { return (b ? "true" : "false"); }
str ts(vec<bool> v) { bool f = true; str res = "{";
FOR(i, 0, static_cast<ll>(v.size()) - 1) 
{ if (!f) res += ", "; res += ts(v[i]);
f = false; } res += "}"; return res; }
temp<size_t N> str ts(bitset<N> v) { str res = "";
trav(a, v) { res += (char) ('0' + a); } return res; }
temp<tn A> str ts(A v) { bool f = true; str res = "{";
trav(x, v) { if (!f) res += ", "; res += ts(x);
f = false; } res += "}"; return res; }
temp<tn A, tn B> str ts(pi<A, B> p) { 
  return "(" + ts(p.ff) + ", " + ts(p.ss) + ")"; }
temp<tn A, tn B, tn C> str ts(tup<A, B, C> t) {
  return "(" + ts(get<0>(t)) + ", " + ts(get<1>(t)) + ", " + ts(get<2>(t)) + ")"; }
void DBG() { cerr << endl; }
temp<tn H, tn... T> void DBG(H h, T... t) { cerr << " " << ts(h); DBG(t...); }
#define dbg(...) cerr << "[" << #__VA_ARGS__ << "]:", DBG(__VA_ARGS__);

// INPUT AND OUTPUT
temp<tn T> void re(T& x) { cin >> x; };
temp<tn H, tn... T> void re(H& h, T&... t) { re(h); re(t...); }
temp<tn T> void pr(T x) { cout << x; };
temp<tn H, tn... T> void pr(H h, T... t) { pr(h); pr(t...); }

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n;
  re(n);
  ll ans = 0;
  auto Get = [&](ll x) {
    ll p = 1, sum = 0;
    while (sum <= x) {
      sum += p;
      ++p;
    }
    return p - 2;
  };
  auto Prime = [&](ll x) {
    if (x == 1) return false;
    for (ll i = 2; i * i <= x; i++) {
      if (x % i == 0) {
        return false;
      }
    }
    return true;
  };
  auto Add = [&](ll x, ll m) {
    if (!Prime(x)) return;
    ll cnt = 0;
    while (m % x == 0) {
      m /= x;
      ++cnt;
    }
    ans += Get(cnt);
  };
  for (ll i = 1; i * i <= n; i++) {
    ll j = n / i;
    Add(i, n);
    Add(j, n);
  }
  pr(ans, '\n');
  return 0;
}

Measured memory_bytes: 3648
//#include "IntMod.h"
//typedef IntMod<1000000007> MInt;

#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>
#include <functional>
#include <cmath>
#include <stack>
#include <set>
#include <map>
using namespace std;
#define REP(i,a,n) for(int i = a; i < n; ++i)
#define EPS 0.0001
#define INF 0x3FFFFFFF
typedef long long LL;
typedef unsigned long long ULL;

#define LU(a) (a)
#define RU(a) ((a + 1) % 4)
#define RD(a) ((a + 2) % 4)
#define LD(a) ((a + 3) % 4)
#define IDX(a) (a / 4)
#define DIR(a) (a % 4)

struct Face {
	ULL colors;

	Face(int a, int b, int c, int d) {
		int tmp[4];
		tmp[0] = a;
		tmp[1] = b;
		tmp[2] = c;
		tmp[3] = d;
		
		ULL max = 0;
		REP(i,0,4){
			ULL level = tmp[(i + 0) % 4] * (1ULL << 0) + tmp[(i + 1) % 4] * (1ULL << 16) + tmp[(i + 2) % 4] * (1ULL << 32) + tmp[(i + 3) % 4] * (1ULL << 48);
			max = level > max ? level : max;
		}
		colors = max;
	}
	int symmetry() const {
		if ((*this)[0] == (*this)[1] && (*this)[1] == (*this)[2] && (*this)[2] == (*this)[3]) {
			return 4;
		}
		if ((*this)[0] == (*this)[2] && (*this)[1] == (*this)[3]) {
			return 2;
		}
		return 1;
	} 
	int operator[](int i) const {
		return (colors & (0xFFFFULL << (i * 16))) >> (i * 16);
	}
	bool operator<(const Face& right) const {
		return colors < right.colors;
	}
	bool operator==(const Face& right) const {
		return colors == right.colors;
	}
};

map<Face, LL> faces;
int N;
LL sum = 0;
int main() {
	cin >> N;
	REP(i, 0, N) {
		int a, b, c, d;
		cin >> a >> b >> c >> d;
		++faces[Face(a, b, c, d)];
	}
	for (map<Face, LL>::iterator it = faces.begin(); it != faces.end(); ++it) {
		for (map<Face, LL>::iterator jt = faces.begin(); jt != faces.end(); ++jt) {
			REP(l, 0, 4) {
				Face front(it->first[3], it->first[2], jt->first[(1 + l) % 4], jt->first[(0 + l) % 4]);
				Face right(it->first[2], it->first[1], jt->first[(2 + l) % 4], jt->first[(1 + l) % 4]);
				Face back(it->first[1], it->first[0], jt->first[(3 + l) % 4], jt->first[(2 + l) % 4]);
				Face left(it->first[0], it->first[3], jt->first[(0 + l) % 4], jt->first[(3 + l) % 4]);
				LL top_num = it->second;
				LL bottom_num = jt->second - (jt == it);
				LL front_num = faces.count(front) ? (faces[front] - (it->first == front) - (jt->first == front)) : 0;
				LL right_num = faces.count(right) ? (faces[right] - (it->first == right) - (jt->first == right) - (front == right)) : 0;
				LL back_num = faces.count(back) ? (faces[back] - (it->first == back) - (jt->first == back) - (front == back) - (right == back)) : 0;
				LL left_num = faces.count(left) ? (faces[left] - (it->first == left) - (jt->first == left) - (front == left) - (right == left) - (back == left)) : 0;
				sum +=
					front.symmetry() * right.symmetry() * back.symmetry() * left.symmetry()
					* top_num * bottom_num * front_num * right_num * back_num * left_num;
			}
		}
	}
	cout << sum / 6 << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long n,k,ans = 0,i,j,b = 0;cin >> n >> k;
  long long a[n];
  for(i=0;i<n;i++) cin >> a[i];
  for(i=0;i<n-1;i++){
    for(j=i+1;j<n;j++){
      if(a[i]==a[j]) continue;
      if(a[i]>a[j]) ans = (ans+(k+1)*k/2)%1000000007;
      else ans = (ans+(k-1)*k/2)%1000000007;
    }
  }
  cout << ans << "\n";
}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)
func scanInt() int {
	sc.Scan()
	a,_ := strconv.Atoi(sc.Text())
	return a
}

func main() {
	sc.Split(bufio.ScanWords)

	n := scanInt()
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = scanInt()
	}

	b := make([]int, n)
	for i := n-1; i >= 0; i-- {
		num := i+1
		mul := 0
		for j := 1; j*num < n+1; j++ {
			mul += b[j*num-1]
		}

		if mul%2 == a[i] {
			b[i] = 0
		} else {
			b[i] = 1
		}
	}

	m := 0
	ans := make([]int, 0)
	for i := 0; i < n; i++ {
		if b[i] == 1 {
			m++
			ans = append(ans,i+1)
		}
	}

	fmt.Println(m)
	for i, e := range ans {
		fmt.Print(e)
		if i == len(ans)-1 {
			fmt.Println()
		} else {
			fmt.Print(" ")
		}
	}

	// fmt.Println(b)
	
}


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

using namespace std;

int main(void){
    long long N, x;
    cin >> N >> x;
    vector<long long> a(N);
    for(int i = 0; i < N; i++) cin >> a[i];
    sort(a.begin(), a.end());
    long long ans = 0;
    for(int i = 0; i < N - 1; i++){
        if(a[i] <= x){
            x -= a[i];
            ans++;
        }
    }
    if(a[N - 1] == x) ans++;
    cout << ans << endl;
    return 0;
}

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

const int MOD=1000000007;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;

int a[]{100,101,102,103,104,105};
bool dp[200000];

int main(){
	int x;cin>>x;
	dp[0]=1;
	rep(i,6)rep(j,120000){
		dp[j+a[i]]|=dp[j];
	}
	if(dp[x])puts("1");
	else puts("0");
}

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

using namespace std;

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

    long long a, b, c, ans = 1e18;
    for (long long i = 1; i <= H/2; i++) {
        a = i * W;
        b = ((H * W - a) % 2 != 0) ? (H - i) * (W / 2) : (H * W - a) / 2;
        c = H * W - a - b;
        ans = min(ans, max(a, max(b, c)) - min(a, min(b, c)));
    }

    for (long long i = 1; i <= W/2; i++) {
        a = i * H;
        b = ((H * W - a) % 2 != 0) ? (W - i) * (H / 2) : (H * W - a) / 2;        
        c = H * W - a - b;
        ans = min(ans, max(a, max(b, c)) - min(a, min(b, c)));
    }

    cout << ans << endl;

    return 0;
}


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

constexpr int LEN = 105;
int a[LEN][LEN];

int prim(int n){
	bool check[n];
	int p[n], d[n];
	memset(check, 0, n*sizeof(bool));
	memset(p, -1, n*sizeof(int));
	memset(d, 1, n*sizeof(int));
	rep(i, n) p[i] = INT_MAX;
	d[0] = 0;
	p[0] = -1;

	while(true){
		int min_cost = INT_MAX;
		int now_v;
		rep(i, n){
			if(!check[i] && d[i] < min_cost){
				min_cost = d[i];
				now_v = i;
			}
		}
		if(min_cost == INT_MAX) break;

		check[now_v] = true;

		rep(v, n){
			if(!check[v] && (a[now_v][v] > -1) && (a[now_v][v] < d[v])){
				d[v] = a[now_v][v];
				p[v] = now_v;
			}
		}
	}

	int sum = 0;
	rep(i, n) sum += d[i];

	return sum;
}

int main(){
	int n; cin >> n;
	rep(i, n)rep(j, n) {
		int w; cin >> w;
		a[i][j] = w;
		a[j][i] = w;
	}

	cout << prim(n) << endl;

	return 0;
}



Measured memory_bytes: 3116
#include <bits/stdc++.h>
#define ll long long
const long double PI=acos(-1);
using namespace std;
ll gcd(ll a,ll b)
{
    if(b==0)
        return a;
    else
        return gcd(b,a%b);
}
bool prime(ll x)
{
    if(x==2)
    {
        return true;
    }
    else if(x<2||x%2==0)
    {
        return false;
    }
    else
    {
        for(int i=3;i*i<=x;i+=2) {
            if (x % i == 0) {
                return false;
            }
        }
        return true;
    }
}
int main()
{
   int x;
   cin>>x;
   if(x>=30)
       cout<<"Yes"<<endl;
   else
       cout<<"No"<<endl;

}


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


int main() {
  string S, check = "";
  bool is_exist = false;
  vector<string> list = {"dream", "dreamer", "erase", "eraser"};
  cin >> S;

  for(int i = S.length() - 1; i >= 0; i--) {
    check.insert(0, 1, S[i]);
    auto itr = find(list.begin(), list.end(), check);
    int idx = distance(list.begin(), itr);
    is_exist = (idx == list.size()) ? false : true;
    if ( is_exist ) {
      check = "";
    }
  }
  
  cout << ((is_exist) ? "YES" : "NO") << endl;
  return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>

using namespace std;

vector<int> p, r;


void makeSet(int x){
  p[x] = x;
  r[x] = 0;
}

int findSet(int x){
  if(x != p[x])p[x] = findSet(p[x]);
  return p[x];
}

void link(int x, int y){
  if(r[x] > r[y]) p[y] = x;
  else {
    p[x] = y;
    if(r[x] == r[y]) r[y] = r[y] + 1;
  }
}



void unite(int x, int y){
  link(findSet(x), findSet(y));
}


int main(){

  int N, Q, com, x, y, i;

  cin >> N >> Q;

  p.resize(N);
  r.resize(N);

  for(i=0; i<N; i++) makeSet(i);

  for(i=0; i<Q; i++){
    cin >> com >> x >> y;
    if(com == 0) unite(x, y);
    else if(com == 1){
      if(findSet(x) == findSet(y)) cout << 1 << endl;
      else cout << 0 << endl;
    }
  }

  return 0;
}




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

int main(){
  long long int a,b,c,d;
  cin >> a >> b >> c >> d;
  
  int ab = a*b;
  int cd = c*d;
  if(ab>cd){
    cout << ab << endl;
  }else{
    cout << cd << endl;
  }
}

Measured memory_bytes: 256
n, k = map(int, input().split())
MOD = 10 ** 9 + 7
for i in range(1, k+1):
    if i == 1:
        comb1 = n - k + 1
        comb2 = 1
    else:
        comb1 *= (n - k + 2 - i) * pow(i, MOD-2, MOD)
        comb2 *= (k - i + 1) * pow(i - 1, MOD-2, MOD)
    print(comb1 * comb2 % MOD)


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

int main(){
	cin.tie(0);
   	ios::sync_with_stdio(false);
	ll N,K;
    cin>>N>>K;

    ll ans = 0;
    for(ll i=K;i<=N+1;i++){
        ans +=1;
        ans +=i*(N+1-i)%MOD;
        ans%=MOD;
        // cout<<ans<<"\n";
    }

    cout<<ans<<"\n";


	return 0;
}

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

int main() {
  	long long int n;
  	long long int x;
  	cin >> n;
  	cin >> x;
  	long long int arr[n];
  	for (int i = 0; i < n; i++) {
    	cin >> arr[i];
    }    
  	long long int answer = 0;
  	for (int i = 0; i < n - 1; i++) {
    	if (arr[i] + arr[i + 1] > x) {
        	answer = answer + arr[i + 1] + arr[i] - x;
          	arr[i + 1] = ((x - arr[i]) < 0) ? 0 : (x - arr[i]); 
          	arr[i] = (x - arr[i]) < 0 ? x : arr[i]; 
        }
    }
  	cout << answer << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <string.h>
#include <ctype.h>
#include <algorithm>

using namespace std;

int main() {
  int n,a;
  cin >> n >> a;
  
  int num = n % 500;
  if(num <= a) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 3588
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "functional"
#include "ctime"

using namespace std;

//constexpr long long int MOD = 1000000007;
constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-8;

//int N, M, K, H, W, L, R;
long long int N, M, K, H, W, L, R;

long long int power(long long int x, long long int n, long long int M) {
	long long int ret = 1;
	long long int by = x;
	while (n) {
		if (n & 1) {
			ret *= by;
			ret %= M;
		}
		by *= by;
		by %= M;
		n >>= 1;
	}
	return ret;
}

vector<vector<long long int>>matrix_product(vector<vector<long long int>>v, vector<vector<long long int>>w) {
	vector<vector<long long int>>ret(v.size(), vector<long long int>(w.front().size()));
	for (int i = 0; i < ret.size(); i++) {
		for (int j = 0; j < ret[i].size(); j++) {
			for (int k = 0; k < w.size(); k++) {
				ret[i][j] += v[i][k] * w[k][j];
				ret[i][j] %= MOD;
			}
		}
	}
	return ret;
}

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

	cin >> H >> W >> K;
	if (K <= 1) {
		cout << 1 << endl;
		return 0;
	}
	vector<string>s(H);
	for (auto &i : s)cin >> i;
	int yoko = 0;
	int tate = 0;
	int num = 0;
	for (auto i : s)for (auto j : i)num += j == '#';
	for (int i = 0; i < H; i++) {
		if (s[i].back() == '#'&&s[i].front() == '#')yoko++;
	}
	for (int i = 0; i < W; i++) {
		if (s.front()[i] == '#'&&s.back()[i] == '#')tate++;
	}
	long long int tate_connect = 0, yoko_connect = 0;
	for (int i = 0; i < H; i++) {
		for (int j = 1; j < W; j++)yoko_connect += s[i][j] == s[i][j - 1] && s[i][j] == '#';
	}
	for (int i = 1; i < H; i++) {
		for (int j = 0; j < W; j++)tate_connect += s[i][j] == s[i - 1][j] && s[i][j] == '#';
	}
	if (tate&&yoko) {
		cout << 1 << endl;
		return 0;
	}
	if (!tate && !yoko) {
		cout << power(num, K-1, MOD) << endl;
		return 0;
	}
	K--;
	vector<vector<long long int>>ansmat(4, vector<long long int>(1));

	long long int ans = 1;
	vector<vector<long long int>>by(4, vector<long long int>(4));

	if (!tate) {
		long long int minus = yoko_connect;
		by[1][1] = yoko;
		ansmat[0][0] = 1;
		ansmat[1][0] = minus;
		ansmat[2][0] = num;
		ansmat[3][0] = yoko;
	}
	else {
		long long int minus = tate_connect;
		by[1][1] = tate;
		ansmat[0][0] = 1;
		ansmat[1][0] = minus;
		ansmat[2][0] = num;
		ansmat[3][0] = tate;
	}
	by[0][0] = num;
	by[0][1] = MOD - 1;
	by[2][2] = 1;
	by[3][3] = 1;
	auto box = by;
	K--;
	for (int i = 0; i < 60; i++) {
		if ((K >> i) & 1) {
			by = matrix_product(box, by);
		}
		box = matrix_product(box, box);
	}
	ansmat = matrix_product(by,ansmat);
	//cout << ansmat.size() << " " << ansmat.front().size() << endl;
	cout << ansmat.front().front() << endl;
}

Measured memory_bytes: 1280
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <iomanip>
#include <ios>

using namespace std;

//skip
void C111()
{
  int n;
  cin >> n;
  vector<int> v(n);
  for (int i = 0; i < n; ++i) cin >> v[i];
}


void pyramid()
{
  int n;
  cin >> n;
  vector<int> x(n), y(n), h(n);
  int x1, y1, h1;
  for (int i = 0; i < n; ++i)
  {
    cin >> x[i] >> y[i] >> h[i];
    if (h[i] >= 1)
    {
      x1 = x[i];
      y1 = y[i];
      h1 = h[i];
    }
  }

  for (int i = 0; i <= 100; ++i)
  {
    for (int j = 0; j <= 100; ++j)
    {
      int h_max = max(0, h1 + abs(i - x1) + abs(j - y1));
      int exist_ans = 1;
      for (int k = 0; k < n; ++k)
      {
        if (h[k] != max(0, h_max - abs(i - x[k]) - abs(j - y[k])))
        {
          exist_ans = 0;
          break;
        }
      }
      if (exist_ans)
      {
        cout << i << " " << j << " " << h_max << "\n";
        return;
      }
    }
  }
}


void id_113()
{
  int n, m;
  cin >> n >> m;
  
  vector<vector<pair<int, int>>> py(n);
  for (int i = 0; i < m; ++i)
  {
    int p, y;
    cin >> p >> y;

    py[p - 1].push_back(make_pair(y, i));
  }

  for (int i = 0; i < n; ++i) sort(py[i].begin(), py[i].end());

  map<int, pair<int, int>> ans;
  for (int i = 0; i < n; ++i)
  {
    for (int j = 0; j < py[i].size(); ++j)
    {
      ans[py[i][j].second] = make_pair(i + 1, j + 1);
    }
  }
  
  for (int i = 0; i < m; ++i)
  {
    cout << setfill('0') << right << setw(6) << ans[i].first;
    cout << setfill('0') << right << setw(6) << ans[i].second << "\n";
  }
}


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

  for (int i = 1; i <= n; ++i)
  {
    //string s = (string)n;
  }
}


void christmas_eve()
{
  int n, k;
  cin >> n >> k;
  vector<int> h(n);
  for (int i = 0; i < n; ++i) cin >> h[i];

  sort(h.begin(), h.end());

  int h_diff = 1000000000;
  for (int i = 0; i < n - k + 1; ++i)
  {
    h_diff = min(h_diff, h[i + k - 1] - h[i]);
  }

  cout << h_diff << "\n";
}


void grand_garden()
{
  int n;
  cin >> n;
  vector<int> h(n);
  for (int i = 0; i < n; ++i) cin >> h[i];

  int ans = 0, pre_flower = 0;
  for (int i = 0; i < n; ++i)
  {
    if (h[i] > pre_flower) ans += h[i] - pre_flower;
    pre_flower = h[i];
  }
  cout << ans << "\n";
}


void streamline()
{
  int n, m;
  cin >> n >> m;
  vector<int> x(m);
  for (int i = 0; i < m; ++i) cin >> x[i];

  if (m == 1 || !(n < m)) {
    cout << 0 << "\n";
    return;
  }

  sort(x.begin(), x.end());

  vector<int> l(m);
  int s = 0;
  for (int i = 1; i < m; ++i)
  {
    l[i] = x[i] - x[i - 1];
    s += l[i];
  }

  sort(l.begin(), l.end(), greater<>());

  int ans = s;
  for (int i = 0; i < n - 1; ++i)
  {
    ans -= l[i];
  }
  cout << ans << "\n";
}



int main()
{
  //C111();
  //pyramid();
  //id_113();
  //C_755();
  //christmas_eve();
  //grand_garden();
  streamline();
}


Measured memory_bytes: 1024
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        while (true){
            int H = sc.nextInt(); 
            int W = sc.nextInt(); 
            int i,j;
            if (H == 0 && W == 0) { break; } 
            
            for(i=0;i<W;i++){
                System.out.print("#");
            }
            System.out.println("");
            
            for(i=0;i<H-2;i++){
                System.out.print("#");
                for(j=0;j<W-2;j++){
                    System.out.print(".");
                }
                System.out.print("#");
                System.out.println("");
            }
            
            for(i=0;i<W;i++){
                System.out.print("#");
            }
            System.out.println("");
            System.out.println("");
        
        }
    }
}


Measured memory_bytes: 32456