akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>

#define i64 long long
using namespace std;
int main(){
  i64 r,n;
  while(scanf("%lld",&n),n){
    r=0LL;
    for(i64 i=1LL;i*i<n;i++){
      if(!(n%i)){
        r+=i;if(i>1)r+=n/i;
      }
    }
    // printf("%d %d\n",n,r);
    if(r>n){
      puts("abundant number");
    }
    else if(r==n&&n!=1){
      puts("perfect number");
    }
    else{
      puts("deficient number");
    }
  }
}

Measured memory_bytes: 2576
#include<stdio.h>
#include<stdlib.h>
#define MAX 2000001
#define K 10000

int n;

void CountingSort(unsigned short *A, unsigned short *B){
  int i, j, C[K+1];
  for( i = 0 ; i <= K ; i++ ){
    C[i] = 0;
  }
  for( j = 1 ; j <= n ; j++ ){
    
    C[A[j]]++;
  }
  for( i = 1 ; i <= K ; i++ ){
    C[i] = C[i] + C[i-1];
  }
  for( j = n ; j >= 1 ; j-- ){
    B[C[A[j]]] = A[j];
    C[A[j]]--;
  }
}

int main(){
  unsigned short *A, *B;
  int i, j;
  
  scanf("%d", &n);

  A = malloc(sizeof(short) * n + 1 );
  B = malloc(sizeof(short) * n + 1 );

  for( i = 0 ; i < n ; i++ ) scanf("%hu", &A[i+1]);

  CountingSort(A, B);

  for( i = 1 ; i <= n ; i++ ){
    if( i > 1 ) printf(" ");
    printf("%d", B[i]);
  }
  printf("\n");
  return 0;
}



Measured memory_bytes: 9708
#include <iostream>
#include <vector>
#include <iomanip>
#define REP(i, n) for(int i = 0; i < n; i++)
template<class T> inline void chmin(T& a, T b) {if (a>b) a=b; }
template<class T> inline void chmax(T& a, T b) {if (a<b) a=b; }
using namespace std;
typedef long long ll;
const ll LINF = 1e18;
const int INF = 1e9;

int main() {
    int N, M; cin >> N >> M;
    vector<int> X;
    vector<int> df;
    REP(i, M) {
        int x; cin >> x;
        X.push_back(x);
    }

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

    REP(i, X.size()-1) {
        df.push_back(X[i+1]-X[i]);
    }
    sort(df.begin(), df.end());

    ll ct = 0;
    int sumup_ct = (M-1) - (N-1);
    if(sumup_ct > 0) {
        REP(i, sumup_ct) {
            ct += df[i];
        }
    }
    cout << ct << endl;
    
    return 0;
}

Measured memory_bytes: 1400
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
const ll ans=1e18;
int main()
{
    ll x,y;
    scanf("%lld %lld",&x,&y);
    if(x==y)
        {
            printf("-1");
            return 0;
        }
    else
    {
        int i;
        for(i=2;i<=9999999;i++)
        {
            if((x*i)%y!=0)
            {
                printf("%lld",x*i);
                return 0;
            }
        }
        cout<<-1<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>//Carefully Crafted by hetp111
using namespace std;
#define int long long
#define double long double
#define all(v) (v).begin(),(v).end()
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int,int>
#define vii vector<pii>
#define MOD 1000000007
#define MOD2 998244353
#define MOD3 1000000009
#define PI acos(-1)
#define eps (1e-8)
#define INF (1e18)
#define FASTER ios_base::sync_with_stdio(0);cin.tie(0)
template<class A,class B>ostream&operator<<(ostream&out,const pair<A,B>&a){return out<<"("<<a.first<<","<<a.second<<")";}
template<class A>ostream&operator<<(ostream&out,const vector<A>&a){for(const A &it:a)out<<it<<" ";return out;}
template<class A,class B>istream&operator>>(istream&in,pair<A,B>&a){return in>>a.first>>a.second;}
template<class A>istream&operator>>(istream&in,vector<A>&a){for(A &i:a)in>>i;return in;}
ifstream cinn("ride.in");ofstream coutt("ride.out");
int poww(const int &a,int b,const int &m=MOD){if(b==0)return 1;int x=poww(a,b/2,m);x=x*x%m;if(b&1)x=x*a%m;return x;}
int ceil(const int &a,const int &b){return (a+b-1)/b;}
////Read:
//Check corner cases, n==1;
//
////Some function:
//__builtin_popcountll(), 

int n,t;
int timee[3001];
int taste[3001];
int dp[3001][3001];

int f(int i,int t){
    if(t<=0 || i>=n)return 0;
    int &ans=dp[i][t];
    if(ans!=-INF)return ans;
    ans=f(i+1,t);
    ans=max(ans,taste[i]+f(i+1,t-timee[i]));
    return ans;
}

signed main(){
    FASTER;
    for(int i=0;i<=3000;i++){
        for(int j=0;j<=3000;j++){
            dp[i][j]=-INF;
        }
    }
    
    cin>>n>>t;
    vii v;
    for(int i=0;i<n;i++){
        cin>>timee[i]>>taste[i];
        v.push_back({timee[i],taste[i]});
    }
    sort(all(v));
    for(int i=0;i<n;i++){
        timee[i]=v[i].first;
        taste[i]=v[i].second;
    }
    cout<<f(0,t);
}

Measured memory_bytes: 74360
#include<iostream>
#define rep(i,n) for(int i=0;i<n;++i)
using namespace std;

int main() {
    string ans = "Christmas";
    int d; cin >> d;
    rep(i, 25 - d) {
        ans += " Eve";
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
/*
          Life before Death
          Strength before Weakness
          Journey before Destination
    */
    
    #include <bits/stdc++.h>
    using namespace std;
    
    typedef long long ll;
    #define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    #define rep(i,a,n) for(ll i=a;i<n;i++)
    #define per(i,n,a) for (ll i=n;i>a;i--)
    #define te ll t; std::cin >> t; while(t--)
    #define SZ 100011
    //#define M_PI  3.141592653589793238462643383279502884L
    /*------Just DO IT--------------------------------------*/

    ll dp[150][SZ], w[150], v[150];

    ll solve(){
      ll n,we;
      cin >> n >> we;
      rep(i, 0, n ) cin >> w[i] >> v[i];
      rep(i, 1, n + 1)
        rep(j, 1, we + 1) {
          if(w[i - 1] <= j) dp[i][j] = max(dp[i-1][j], v[i-1] + dp[i-1][j-w[i-1]]);
          else dp[i][j] = dp[i-1][j];
          //cout << i <<" "<<j<<" "<< dp[i][j]<<endl;
        }
        cout << dp[n][we] << endl;
    } 
    
   int main() {
       fastio
       solve();
    }

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

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

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

Real cross(P a,P b){
  return imag(conj(a)*b);
}

Real sur(P a,P b,P c){
  b-=a; c-=a;
  return abs(cross(b,c))/2.0;
}

P ppp[252521];

// count triangle s.t. surface < s
ll calc(int n,Real s){
  Real u = 2.0*M_PI/(Real)n;
  ll ans = 0;
  int a = 0;
  P x = ppp[a];
  ll bai = n;
  if(n%3==0)bai/=3;
  FOR(b,1,n-1){
    P y = ppp[b];
    int low = b+1, high = n-1;
    int cnt = (high-low+1);
    // seisannkakkei guard
    if(n%3==0 && b==n/3){
      cnt--;
    }
    if(cnt%2==1){
      int cent = low + cnt/2;
      P z = ppp[cent];
      if(sur(x,y,z) < s){
        ans += cnt;
        continue;
      }
    }
    cnt /= 2;
    high = low + cnt - 1 + 1;
    low--;
    while(low+1<high){
      int mid = (low+high)/2;
      P z = ppp[mid];
      if(sur(x,y,z) < s){
        low = mid;
      }else{
        high = mid;
      }
    }
    ans += 2ll*(low-b);
  }
  // DEBUG(ans);
  ans /= 3;
  ans *= n;
  return ans;
}

int main(){
  int n;
  ll k;
  cin>>n>>k;
  if(n%3==0 && (ll)n*(n-1)*(n-2)/6 == k){
    puts("1.29903810568");
    return 0;
  }
  Real u = 2.0*M_PI/(Real)n;
  P po = exp(P(0,u));
  ppp[0] = P(1,0);
  REP(i,n)ppp[i+1] = ppp[i]*po;
  Real low = 0.0, high = 1.3;
  // DEBUG(calc(n,2.0));
  REP(_,40){
    Real mid = (low+high)/2.0;
    ll cnt = calc(n,mid);
    // DEBUG(mid);
    // DEBUG(cnt);
    if(cnt >= k){
      high = mid;
    }else{
      low = mid;
    }
  }
  printf("%.12lf\n",low);
  return 0;
}


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

int main() {
    long long a,b,c;
    cin >> a >> b >> c;
    if (a+b>=c) {
        cout << "No" << endl;
    } else {
        long long l = 4*a*b;
        long long r = (c-a-b)*(c-a-b);
        if (l<r) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    }
    
    return 0;
}


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

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		String s = sc.next();
		int cntMax = 0;

		for (int i = 1; i < n; i++){
			String left = s.substring(0, i);
			String right = s.substring(i, s.length());
			HashSet<String> commonStr = new HashSet<String>();
			int cnt = 0;
			for (int j = 0; j < left.length(); j++){
				if (right.contains(left.substring(j, j+1))){
					commonStr.add(left.substring(j, j+1));
				}
			}
			cntMax = Math.max(cntMax, commonStr.size());
		}
		System.out.println(cntMax);
	}
}


Measured memory_bytes: 23892
#include<bits/stdc++.h>
using namespace std;
#define int long long

int X;

signed main() {
  cin >> X;
  for(int A=0; A<1000; A++) {
    for(int B=0; B<1000; B++) {
      int A5=pow(A,5);
      int B5=pow(B,5);
      if(A5-B5 == X) {
        cout << A << " " << B << endl;
        return 0;
      }
      if(A5+B5 == X) {
        cout << A << " " << -B << endl;
        return 0;
      }
    }
  }
}


Measured memory_bytes: 4044
def main():
    n = int(input())
    pattern = ["S", "H", "C", "D"]
    cards = [[False for i in range(13)] for j in range(4)]
    for _ in range(n):
        card = input().split()
        char = card[0]
        num = int(card[1])
        cards[pattern.index(char)][num - 1] = True
    for i in range(4):
        for j in range(13):
            if cards[i][j] == False:
                print(f"{pattern[i]} {j+1}")
    return 0


if __name__ == "__main__":
    main()



Measured memory_bytes: 5608
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

def keyence20_b():
    _ = int(readline())
    Robots = []
    for line in readlines():
        # (左端,右端) の形で格納
        x, l = map(int, line.strip().split())
        Robots.append((x-l, x+l))
    # 右端の昇順にソート
    Robots = sorted(Robots, key=lambda x: x[1])

    ans = 0
    x = -10**10  # 使用済み範囲
    for lf, rt in Robots:
        if x <= lf:
            ans += 1  # 他とぶつからないので採用(ゼロタッチは有効)
            x = rt
    print(ans)

keyence20_b()

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




int main(){
  int N,T,c,t;
  int ans = 10000;
  cin >> N >> T;
  for(int i=0;i<N;i++){
    cin >> c >> t;
    if(t>T){
      continue;
    }
    else{
      if(ans > c) ans = c;
    }
  }
  if(ans==10000){
    cout << "TLE" << endl;
  }
  else
  {
    cout << ans << endl;
  }

}

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

typedef long long ll;

int main () {
  int N, M;
  cin >> N >> M;
  vector< vector<int> > A;
  for (int i = 0; i < N; i++) {
    vector<int> temp;
    for (int j = 0; j < M; j++) {
      int a;
      cin >> a;
      temp.push_back(a);
    }
    A.push_back(temp);
  }
  bool flag[300];
  for (int i = 0; i < M; i++) flag[i] = true;

  int min = N;
  int participation[300];
  for (int k = 0; k < M; k++) {
    for (int t = 0; t < M; t++) participation[t] = 0;
    for (int i = 0; i < N; i++) {
      vector<int> tA = A.at(i);
      for (int j = 0; j < M; j++) {
	int c = tA.at(j) - 1;
	if (flag[c]) {
	  participation[c]++;
	  break;
	}
      }
    }
    /*
    for (int t = 0; t < M; t++) {
      if (flag[t]) cout << t+1;
      else cout << " ";
      cout << " ";
    }
    cout << endl;
    for (int t = 0; t < M; t++) {
      cout << participation[t] << " ";
    }
    cout << endl;*/
    int index;
    int max_part = 0;
    for (int t = 0; t < M; t++) {
      if (participation[t] > max_part) {
	index = t;
	max_part = participation[t];
      }
    }
    if (max_part < min) min = max_part;
    flag[index] = false;
  }
  cout << min << endl;
  return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
const int N = 3010;
const int p = 1e9 + 7, inv2 = (p + 1) >> 1;
int n, a[N], m, px[N], py[N];
int f[N][N];
inline void A(int &x, int y) {
    x = (x + y >= p ? x + y - p : x + y);
}
int main() {
    scanf("%d%d", &n, &m);
    for (int i = 1; i <= n; ++i) scanf("%d", a + i);
    for (int i = 1; i <= m; ++i) scanf("%d%d", px + i, py + i);
    for (int i = 1; i <= n; ++i)
        for (int j = 1; j <= n; ++j)
            f[i][j] = i < j;
    for (int i = m; i; --i) {
        int x = px[i], y = py[i];
        for (int j = 1; j <= n; ++j) if (j != y && j != x) {
            f[x][j] = f[y][j] = 1ll * (f[x][j] + f[y][j]) * inv2 % p;
            f[j][y] = f[j][x] = 1ll * (f[j][x] + f[j][y]) * inv2 % p;
        }
        f[x][y] = f[y][x] = 1ll * (f[x][y] + f[y][x]) * inv2 % p;
    }
    int ans = 0;
    for (int i = 1; i <= n; ++i)
        for (int j = 1; j <= n; ++j)
            if (a[i] > a[j]) 
                A(ans, f[i][j]);
    while (m--) A(ans, ans);
    printf("%d\n", ans);
    return 0;
}


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

int cnt=0;
const int MAX=500000;
int L[MAX/2+2], R[MAX/2+2];

inline void merge(int A[], int left, int mid, int right){
	int n1 = mid - left;
	int n2 = right - mid;
	for(int i=0; i<n1; i++){
		L[i] = A[left+i]; 
	}
	for(int i=0; i<n2; i++){
		R[i] = A[mid+i];
	}
	L[n1] = 2000000000;
	R[n2] = 2000000000;
	
	int i=0, j=0;
	for(int k=left; k<right; k++){
		cnt++;
		if(L[i] <= R[j]){
			A[k] = L[i];
			i++;
		} else {
			A[k] = R[j];
			j++;
		}
	}
}

inline void merge_sort(int A[], int left, int right){
	if (left+1 < right){
		int mid = (left+right)/2;
		merge_sort(A, left, mid);
		merge_sort(A, mid, right);
		merge(A, left, mid, right);
	}
}




int main() {
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	int A[n];
	for(int i=0; i<n; i++){
		cin >> A[i];
	}
	
	merge_sort(A, 0, n);
	for(int i=0; i<n; i++){
		if(i==0) cout << A[i];
		else cout << " " << A[i];
	}
	cout << "\n" << cnt << "\n";

	return 0;
}

Measured memory_bytes: 7060
#include<stdio.h>
int main()
{
    long long a,b,i,j,ans,x,y;

    scanf("%lld%lld",&a,&b);
    if(a>b)
    {
        x=a;
    }
    else
    {
        x=b;
    }


    for(;x>=1;x--)
    {
        if(a%x==0&&b%x==0)
             {
                 y=x;
                 break;
             }
    }
    ans=(a*b)/y;
    printf("%lld\n",ans);
    return 0;

}

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

#define rep(i,n) for(ll i=0;i<n;i++)
#define REP(i,a,n) for(ll i=a;i<n;i++)

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> tiii;
typedef pair<ll, ll> pll;

const int INF = 100000000;
const ll LINF = 1e18+5;

const ll M = 1000000007;


ll dp[1001][10001];

int main() {
    ll H, N;
    cin >> H >> N;
    vector<ll> A;
    vector<ll> B;
    rep(i,N){
        ll a,b;
        cin >> a >> b;
        A.push_back(a);
        B.push_back(b);
    }
    rep(j,H+1){
        dp[0][j] = LINF;
    }
    dp[0][0] = 0;
    rep(i,N){
        rep(j,H+1){
            if (j==0) dp[i+1][j] = 0;
            else if (j < A[i]) {
                dp[i+1][j] = min(dp[i][j], B[i]);
            } else dp[i+1][j] = min(dp[i][j], dp[i+1][j-A[i]] + B[i]);
        }
    }
    cout << dp[N][H] << endl;
    return 0;
}

Measured memory_bytes: 78464
#include<bits/stdc++.h>
#define ll long long
#define endl '\n'
using namespace std;
int main()
{
  vector<ll>arr;
  vector<ll>cost;
  ll n,k,i,j;
  cin>>n;
  for(i=0;i<n;i++)
  {
    cost.push_back(-1);
  }
  cost[0]=0;
  for(i=0;i<n;i++)
  {
    cin>>k;
    arr.push_back(k);
  }
  for(i=0;i<n-1;i++)
  {
    for(j=i+1;j<i+3;j++)
    {
        if(cost[j]!=-1)
        {cost[j]=min(cost[j],abs(arr[j]-arr[i])+cost[i]);}
        else if(cost[j]==-1)
        {
          cost[j]=abs(arr[j]-arr[i])+cost[i];
        }
        if(j==n-1)
        {
          break;
        }
    }
  }
  cout<<cost[n-1]<<endl;
}

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

int main(void) {
	// in
	int n, m;
	std::cin >> n >> m;
	std::vector<int> l(m), r(m);
	for(int i = 0; i < m; ++i) std::cin >> l[i] >> r[i];

	std::sort(l.begin(), l.end());
	std::sort(r.begin(), r.end());

	std::cout << (r[0] - l[m-1] + 1 > 0 ? r[0] - l[m-1] + 1 : 0) << std::endl;

	return 0;
}


Measured memory_bytes: 1024
<?php
 
fscanf(STDIN, "%d %d", $x, $n);

if ($n == 0) {
  echo($x);
  exit;
}

$N_array = trim(fgets(STDIN));
$N_array = explode(" ", $N_array);

if (!in_array($x, $N_array)) {
  echo($x);
  exit;
}

for($i=1;$i <= $n + 1;$i++) {
 	if ($i % 2 == 1) {
      $r = $x - ((int)($i / 2) + 1);
    } else {
      $r = $x + (int)($i / 2);
    }
    if (!in_array($r, $N_array)) {
        echo($r);
        exit;
    }
}



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

using namespace std;

int main(){
	string s;
	cin>>s;
	int n=s.length();
	vector<int> s_comp;
	int count=1;
	for(int i=1;i<n;i++){
		if(s[i]==s[i-1]){
			count++;
		}
		else{
			s_comp.push_back(count);
			count=1;
		}
	}
	s_comp.push_back(count);
	n=s_comp.size();
	int ans=0;
	for(int i=0;i<n;i++){
		if(s_comp[i]%3==0){
			ans+=2*(s_comp[i]/3);
		}
		else if(s_comp[i]%3==1){
			ans+=2*(s_comp[i]/3)+1;
		}
		else{
			ans+=2*(s_comp[i]/3)+1;
			if(i+1<n){
				ans++;
				s_comp[i+1]--;
			}
		}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 1532
#include <bits/stdc++.h>
using namespace std;
using ld = long double;

int main()
{
	ld v;
	while (cin >> v) {
		for (int i = 1;; i++) {
			if (v * v <= 98 * i - 98) {
				cout << i << endl;
				break;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 3176
#n = int(input())
#s = input()
#n, k= map(int,input().split())
#da = list(map(int,input().split()))

n,m = map(int,input().split())
da = [list(map(int,input().split())) for i in range(m)]

ans = -1
for i in range(10**(n)):
    now = str(i)
    ju = True
    for j in range(m):
        if len(now) < da[j][0]:
            ju = False
            break
        if now[da[j][0]-1] != str(da[j][1]):
            ju= False
    if ju and len(str(now)) == n:
        ans = i
        break

print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<string>

using namespace std;

int main(){

	int n;
	int cnt;
	string move,bef;

	while(1){

		cin>>n;
		if(n==0) break;

		bef="NO";
		cnt=0;
		while(n--){

			cin>>move;
			if(bef=="lu"&&move=="ru"||bef=="ru"&&move=="lu"||bef=="ld"&&move=="rd"||bef=="rd"&&move=="ld") cnt++;

			bef=move;
		}

		cout<<cnt<<endl;

	}

	return 0;
}

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

int main()
{
  ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,m;
    cin>>n>>m;
    string a[n];
    for(ll i=0;i<n;i++)
      cin>>a[i];
    vector <ll> r;
    vector <ll> c;
    for(ll i=0;i<n;i++)
    {
      for(ll j=0;j<m;j++)
      {
        if(a[i][j] == '#')
        {
          r.push_back(i);
          break;}
      }
    }
    for(ll i=0;i<m;i++)
    {
      for(ll j=0;j<n;j++)
      {
        if(a[j][i] == '#')
        {
          c.push_back(i);
          break;}
      }
    }
    for(ll i=0;i<r.size();i++)
    {
      for(ll j=0;j<c.size();j++)
      {
        cout<<a[r[i]][c[j]];
      }
      cout<<endl;
    }
   
}

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

DP = [0 for _ in range(N)]

DP[1] = abs(H[1]-H[0])


if len(H) > 2:
    for i in range(2,N):
        DP[i] = min(DP[i-2]+abs(H[i]-H[i-2]),DP[i-1]+abs(H[i]-H[i-1]))

print(DP[N-1])

Measured memory_bytes: 13928
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int d = sc.nextInt();
        int e = sc.nextInt();
      	List<Integer> list = new ArrayList<Integer>();
        List<Integer> numList = new ArrayList<Integer>();
        list.add(a);
        list.add(b);
        list.add(c);
        list.add(d);
        list.add(e);
        int num = 0;
        int min = 10;
        int check = 0;
        for(int i=0; i<5; i++){
          num = list.get(i);
          if(num >= 100) num = num % 100;
          if(num >= 10) num = num % 10;
          if(num == 0) num = 10;
          numList.add(num);
          if(num < min) {
            min = num;
            check = i;
          }
        }
        int sum = 0;
        for(int i=0; i<5; i++){
          if(i == check) continue;
          sum += (list.get(i)+(10-numList.get(i)));
        }
        sum += (list.get(check));
     System.out.println(sum);
	}
}

Measured memory_bytes: 23124
#define _CRT_SECURE_NO_WARNINGS
#define forn(i, a, n) for(ll i = a; i < n; i ++)
#define pb push_back
#define mp make_pair

#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<cmath>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<string>


using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
const ll mod = 1e9 + 7;
const ll power = 49999;

ll n;
set<string> s;
int main()
{
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
/*
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
*/

	cin >> n;
	string last;
	forn(i, 0, n)
	{
		string add;
		cin >> add;
		if (last.size() > 0)
		{
			if (last.back() != add[0] || s.count(add) > 0)
			{
				cout << "No";
				return 0;
			}
		}
		last = add;
		s.insert(add);
	}
	cout << "Yes";
	return 0;
}

Measured memory_bytes: 256
// HTTF.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include "bits/stdc++.h"
#define YES "YES"
#define NO "NO"
#define YESNO OUT(three(solve(),YES,NO))
#define ECHO OUT(solve())
#define three(A,B,C) ((A)?(B):(C))
#define FOR(i,a,b)  for(LL i=(a);i< (LL)(b);i++)
#define EFOR(i,a,b) for(LL i=(a);i<=(LL)(b);i++)
#define RFOR(i,a,b) for(LL i=(a);i>=(LL)(b);i--)
#define REP(i,b) FOR(i,zero,b)
#define EREP(i,b) EFOR(i,zero,b)
#define RREP(i,b) RFOR(i,b,zero)
#define ALL(c) c.begin(),c.end()
#define UNIQUE(c) sort(ALL(c));c.erase(unique(ALL(c)),c.end())
#define MAX(c) (*max_element(ALL(c)))
#define MIN(c) (*min_element(ALL(c)))
#define MP make_pair
#define FI first
#define SE second
#define SI(x) (LL(x.size()))
#define PB push_back
#define DEBUG(a) OUT(a)
#define DEBUG2(a,b) OUT2(a,b)
#define cat cout << __LINE__ << endl
#define OUT(a) cout << (a) << endl
#define OUT2(a,b) cout << (a) <<" "<<(b) << endl
#define zero 0LL
#define int LL
#define pb emplace_back
#define eb pb

using namespace std;
template<typename T> inline void maximize(T &a, T b) { a = max(a, b); }
template<typename T> inline void minimize(T &a, T b) { a = min(a, b); }
template<typename T> inline bool middle(T a, T b, T c) { return b <= a && a <= c; }
template<class T> inline bool MX(T &l, const T &r) { return l < r ? l = r, 1 : 0; }
template<class T> inline bool MN(T &l, const T &r) { return l > r ? l = r, 1 : 0; }
typedef long long LL;
typedef double ld;
typedef int ut;
typedef vector<ut> VI;
typedef vector<VI> VII;
typedef pair<ut, ut> pr;
typedef pair<ut, pr> ppr;
typedef vector<pr> Vpr;
typedef vector<ppr> Vppr;
typedef priority_queue<pr, Vpr, greater<pr> > PQ;
inline void outputVI(VI x) { REP(i, SI(x)) { cout << three(i, " ", "") << x[i]; }OUT(""); }
const int SIZE1 = 5e5 + 1000;
const int SIZE2 = 3010;
const int SIZE3 = 330;
const int SIZE = SIZE1;
const int MAPSIZE = 40;
const LL p = 7 + 1e9;
const LL INF = 1LL << 60;
const long double EPS = 1e-7;
typedef pair<ld, ut> pld;
#define endl "\n" //インタラクティブでは消す
ut N, M, K, L, Q, D, H, W;
// ut A,B,C,D,E,F,G,H,I,J,O,P,Q,R,T,U;
VI edges[SIZE];
LL vals[SIZE], maps2[SIZE2][SIZE2], answer = zero;
LL maps[SIZE2][SIZE2];
LL DP[SIZE];
bool finished[SIZE];
LL A[SIZE2][SIZE2];
LL DP2[SIZE];
LL finished2[SIZE];
LL sum(LL bit) {
	if (finished2[bit]) return DP2[bit];
	finished2[bit] = true;
	REP(i, N) REP(j, i) {
		if ((((1 << i)&bit) > 0) and (((1 << j)&bit) > 0))
			DP2[bit] += A[j][i];
	}
	return DP2[bit];
}
LL solve2(LL bit) {
	if (bit == 0) return DP[bit];
	if (finished[bit]) return DP[bit];
	finished[bit]=true;
	DP[bit] = -INF;
	for (int i = bit; i > 0; i = (i - 1)&bit) {
		MX(DP[bit], solve2(bit - i) + sum(i));
	//	cout << i << " " << sum(i) << endl;
	}
	return DP[bit];
}
LL solve() {
	cin >> N;
	REP(i, N) REP(j, N) cin >> A[i][j];
	cout << solve2((1 << N) - 1) << endl;
	return 0;
}




//!!!!!!!!!!!!!!!!!!!実装を詰める!!!!!!!!!!!!!!!!!!!!!!!!!
signed main() {

	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(0);
	solve();
	cin >> N;
	return 0;

}

Measured memory_bytes: 21888
#include<iostream>
#include<stdio.h>
#include<string>
#include<cmath>
#include<math.h>
#include<vector>
#include<queue>
#include<algorithm>
#include<map>
#include<unordered_map>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rep2(i,n) for(int i = -1; i < (n); i++)
#define PI 3.141592653589793

using namespace std;
using ll = long long;

const ll MA = 1000005;
int cnt[2];
int c[2];
int main() {

	string s;
	cin >> s;
	
	sort(s.begin(), s.end());

	if (s[0] == s[1] && s[2] == s[3]&&s[1]!=s[2]) {
		cout << "Yes" << endl;
	}
	else cout << "No" << endl;



	return 0;
}

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

int main() {
	int K;
	cin >> K;
	if (K % 10 == 5 || K % 2 == 0) {
		cout << -1 << endl;
		return 0;
	}
	int ans = 1;
	int now = 7 % K;
	while (now != 0) {
		ans++;
		now = (now * 10 + 7) % K;
	}
	cout << ans << endl;
}


Measured memory_bytes: 3596
#include <iostream>
#include <vector>
#include <queue>
#include<map>
#include<algorithm>
#include<set>
#include<iomanip>
#define rep(i,n) for(int i = 0;i < n;i++)
#define req(i,n) for(int i = 1; i<=n;i++)
#define ALL(a) a.begin(),a.end()
#define PI  acos(-1)
using namespace std;
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T & val) {
    std::fill((T*)array, (T*)(array + N), val);
}
typedef long long int ll;
typedef long double ld;
int main() {
    ll n, sum = 0; cin >> n; vector<int> a(n), b(n), c(n);
    rep(i, n) cin >> a[i];
    rep(i, n) cin >> b[i];
    rep(i, n) cin >> c[i];
    sort(ALL(a)); sort(ALL(b)); sort(ALL(c));
    rep(i, n) {
        sum += (lower_bound(ALL(a), b[i]) - a.begin()) * (c.end() - upper_bound(ALL(c), b[i]));
    }cout << sum << endl;
}

Measured memory_bytes: 4536
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>  

#pragma warning(disable:4996)  
#pragma comment(linker, "/STACK:336777216")  
using namespace std;

#define mp make_pair  
#define Fi first  
#define Se second  
#define pb(x) push_back(x)  
#define szz(x) ((int)(x).size())  
#define rep(i, n) for(int i=0;i<n;i++)  
#define all(x) (x).begin(), (x).end()  
#define ldb ldouble  

typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

int IT_MAX = 1 << 19;
const ll MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10;

char in[100050];
ll dp[100050][4];

int main() {
	scanf("%s", in + 1);
	int N = strlen(in + 1), i, j;

	dp[0][0] = 1;
	for (i = 1; i <= N; i++) {
		if (in[i] == '?') {
			dp[i][0] = dp[i - 1][0] * 3;
			dp[i][1] = dp[i - 1][1] * 3;
			dp[i][2] = dp[i - 1][2] * 3;
			dp[i][3] = dp[i - 1][3] * 3;
		}
		else {
			dp[i][0] = dp[i - 1][0];
			dp[i][1] = dp[i - 1][1];
			dp[i][2] = dp[i - 1][2];
			dp[i][3] = dp[i - 1][3];
		}

		if (in[i] == '?' || in[i] == 'A') dp[i][1] += dp[i - 1][0];
		if (in[i] == '?' || in[i] == 'B') dp[i][2] += dp[i - 1][1];
		if (in[i] == '?' || in[i] == 'C') dp[i][3] += dp[i - 1][2];

		for (j = 0; j < 4; j++) dp[i][j] %= MOD;
	}
	return !printf("%lld\n", dp[N][3]);
}

Measured memory_bytes: 3456
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int k = scanner.nextInt();
        int n = scanner.nextInt();
        ArrayList<Integer> A = new ArrayList<>();
        for (int i=0;i<n;i++){
            A.add(scanner.nextInt());
        }
        Collections.sort(A);
        ArrayList<Integer> B = new ArrayList<>();
        B.add(k-A.get(n-1)+A.get(0));
        for (int i=1;i<A.size();i++){
            B.add(A.get(i)-A.get(i-1));
        }
        System.out.println(k-Collections.max(B));

    }

}

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

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

using namespace std;

using ll = long long;
using P = pair<int, int>;

int main() {
  int a, b, c, d, e, k;
  cin >> a >> b >> c >> d >> e >> k;

  string result = "Yay!";
  if (e - a > k) {
    result = ":(";
  }
  cout << result << endl;

  return 0;
}


Measured memory_bytes: 256
H,W=map(int,input().split())
A=[[None]*(W+2)]
A.extend([[i=="." for i in "#"+input()+"#"] for _ in range(H)])
A.append([None]*(W+2))

#q=[[(i,j) for i in range(1,H+1) for j in range(1,W+1) if not A[i][j]]]
q=[(i,j) for i in range(1,H+1) for j in range(1,W+1) if not A[i][j]]

#for k in range(2000):
k=0
while(q):
    r=[]
    #q.append([])
    #for i,j in q[k]:
    for i,j in q:
        if A[i-1][j]:
            A[i-1][j]=None
            #q[k+1].append((i-1,j))
            r.append((i-1,j))
        if A[i+1][j]:
            A[i+1][j]=None
            #q[k+1].append((i+1,j))
            r.append((i+1,j))
        if A[i][j-1]:
            A[i][j-1]=None
            #q[k+1].append((i,j-1))
            r.append((i,j-1))
        if A[i][j+1]:
            A[i][j+1]=None
            #q[k+1].append((i,j+1))
            r.append((i,j+1))
    if not len(r):
        break
    q=r
    k+=1
print(k)

Measured memory_bytes: 106868
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
 		int as[] = new int[n];
      	int haf = n/2;
      	if(n % 2 != 0) haf++;
      	int fin = 1;
      	if(n % 2 == 0) fin--;
      
      	for(int i = 0;i < n; i++){
          as[i] = sc.nextInt();
        }
      
      	for(int i = 0;i < haf; i++){
          System.out.print(as[n-1 - 2*i] + " ");
        }
      
      	for(int i = 0;i < n/2; i++){
          System.out.print(as[fin+2*i] + " ");
        }
     
      	System.out.println();
        
	}
}


Measured memory_bytes: 61960
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
#define int long long
using namespace std;

template <typename X, typename T>
auto vectors(X x, T a) {
	return vector<T>(x, a);
}

template <typename X, typename Y, typename Z, typename... Zs>
auto vectors(X x, Y y, Z z, Zs... zs) {
	auto cont = vectors(y, z, zs...);
	return vector<decltype(cont)>(x, cont);
}

template<typename T>
ostream& operator << (ostream& os, vector<T>& v){
	rep(i,v.size()){ os << v[i] << (i == v.size() - 1 ? "" : " "); } return os;
}
template<typename T>
istream& operator >> (istream& is, vector<T>& v){
	for(T& x: v){ is >> x; } return is;
}

signed main(){
	int n;
	while(cin >> n,n){
		for(int len = 2 * sqrt(n); len > 0; len--){
			if(len == 1){
				cout << n << ' ' << 1 << endl;
				break;
			}

			int sum = len * (len - 1) / 2;

			int xl = n - sum;
			if(xl <= 0) continue;

			if(xl % len == 0){
				cout << xl / len << ' ' << len << endl;
				break;
			}
		}
	}
}



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

int main(){
    int W,H,x,y,r;
    cin >>W>>H>>x>>y>>r;


        if(x < r){
            cout << "No" <<endl;
            return 0;
        }else if((x+r) > W){
            cout << "No" <<endl;
            return 0;
        }else if(y < r){
            cout << "No" <<endl;
            return 0;
        }else if((y+r) > H){
            cout << "No" <<endl;
            return 0;
        }else{
            cout << "Yes" <<endl;
        }
}


Measured memory_bytes: 3116
#include <stdio.h>
#include <string.h>
#define M 1000003
#define L 13
 
void insert(char* val);
int find(char* val);
int h(int, int);
int getNumber(char);

char hashTable[M][L];
char hashIsUsed[M];
int codes[4][L];
 
int main(){
 
int n, i, j;
char val[L], com[7];
int p[L];
p[0] = 1;
for(i=1; i<L; i++){
p[i] = p[i-1] * 4;
}

	
for(i=0; i<4; i++){
for(j=0; j<L; j++){
	codes[i][j] = i * p[j];	
}
}
 
scanf("%d",&n);
 
while(n--){
scanf("%s %s",com,val);
if(com[0] == 'i'){
insert(val);
}else if(com[0] == 'f'){
if(find(val) == 1){
    printf("yes\n");
}else{
    printf("no\n");
}
}
}
 
return 0;
 
}
 
void insert(char* val){
 
int code = 0, p = 1, key, i, len, j;
     
for(i=0, len=strlen(val); i<len; i++){
code += codes[getNumber(*(val+i))][i];
}
 
for(i=0; ;i++){
key = h(code,i);
if(hashIsUsed[key] != 1){
    memcpy(hashTable[key],val,len);
	/*
	j=0;
	while(len--){
		*(hashTable[key]+j) = *(val+j);
		j++;
		if(*(val+j) == '\0') break;
	}
	*/
    hashIsUsed[key] = 1;
return;
}
}
 
}
 
int find(char* val){
 
int code = 0, p = 1, key, i, len;
     
for(i=0, len=strlen(val); i<len; i++){
code += codes[getNumber(*(val+i))][i];
}
 
for(i=0; ;i++){
key = h(code,i);
if(hashIsUsed[key] != 1){
return 0;
}else if(!strcmp(hashTable[key],val)){
return 1;
}
}
 
return 0;
 
}
 
int h(int code, int i){
return ((code % M) + i * (1 + (code % (M-1)))) % M;
}
 
int getNumber(char val){
 
return (val == 'A') ? 0 :
	   (val == 'C') ? 1 :
	   (val == 'G') ? 2 :
	   (val == 'T') ? 3 : -1;
 
}

Measured memory_bytes: 13000
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
using namespace std;
#define INF 1e9
#define rep(i, n) for(int i = 0; i < n; i++)
#define sortI(a, b, c) c == 0 ? sort(a, a + b) : sort(a, a + b, greater<int>())
#define vi vector<int>
#define vs vector<string>

int digit(int n){
  int res = 0;
  while(n > 0){
    res += n%10;
    n /= 10;
  }
 
  return res;
}

int main(void){

  //入力
  int N, L;
  cin >> N >> L;
  
  //配列
  vs S(N);
  rep(i, N) cin >> S[i];
  
  //配列のソート
  sort(S.begin(), S.end());
  
  //小さいものから出力
  rep(i, N) cout << S[i];
  cout << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
inline void prep ()
{
  cin.tie (0);
  cin.sync_with_stdio (0);
};
const double pi = acos(-1.);
//printf(%.12lf\n,mid);
// __builtin_popcount(int) count 1's in binary
// get decimal part of number
/*
double intpart;
double thiss = modf((double)(n*m)/(double)k, &intpart);
*/
// round = (int)(num+.5)
long long mod = 1000000007;
 
long long mymod(long long num){
  if (num< 0 && !(num%mod == 0)){
    if (mod == 1){
      return 0;
    }
    return mod-abs(num)%mod;
  }else{
    return num%mod;
  }
}
 
/*string sentence = And I feel fine...;
    istringstream iss(sentence);
*/  
 
double eps = .000000001;

int main(){
  prep();
  int n, m;
  cin >> n >> m;
  int arr[n][m];
  for (int i=0; i<n; i++){
      for (int j=0; j<m; j++){
          cin >> arr[i][j];
          arr[i][j]--;
      }
  }
  int pointers[n] = {0};
  int cnts[m] = {0};
  int res = 0;

  for (int i=0; i<n; i++){
      cnts[arr[i][0]]++;
  }
  for (int i=0; i<m; i++){
      res = max(res, cnts[i]);
  }
  bool erased[m] = {false};
  for (int x=0; x<m-1; x++){
      int maxx = 0;
      int maxind = 0;
      for (int i=0; i<m; i++){
          if (cnts[i] > maxx){
              maxx = cnts[i];
              maxind = i;
          }
      }
      erased[maxind] = true;
      for (int i=0; i<n; i++){
          cnts[arr[i][pointers[i]]]--;
          while (erased[arr[i][pointers[i]]]){
              pointers[i]++;
          }
          cnts[arr[i][pointers[i]]]++;
          
      }
      maxx = 0;
      for (int i=0; i<m; i++){
          maxx = max(cnts[i], maxx);
      }
      res = min(res, maxx);
  }
  cout << res;
  return 0; 
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep2(i,m,n) for (int i = (m); i < (n); ++i)
#define rep(i,n) rep2(i,0,n)
typedef long long int ll;
typedef long double ld;
typedef pair<int, int> P;
template<typename T> struct V : vector<T> { using vector<T>::vector; };
V() -> V<int>;
V(size_t) -> V<int>;
template<typename T> V(size_t, T) -> V<T>;
template<typename T> vector<T> make_vec(size_t n, T a) { return vector<T>(n, a); }
template<typename... Ts> auto make_vec(size_t n, Ts... ts) { return vector<decltype(make_vec(ts...))>(n, make_vec(ts...)); }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << ' '; return os; }
struct fast_ios { fast_ios(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
const int INF = 1<<30;
const ll LINF = 1LL<<61;
const ll MOD = 1000000007;

int main()
{
    int N, T;
    cin >> N >> T;
    auto dp = make_vec(T, 2, 0);
    rep(i,N)
    {
        int t, v;
        cin >> t >> v;
        auto dp2 = make_vec(T, 2, 0);
        for(int j = T-1; j >= 0; j--)
        {
            rep(k,2)
            {
                chmax(dp2[j][k], dp[j][k]);
                if(j + t < T)
                {
                    chmax(dp2[j+t][k], dp[j][k] + v);
                }
                if(k == 0)
                {
                    chmax(dp2[j][k+1], dp[j][k] + v);
                }
            }
        }
        swap(dp, dp2);
    }
    int ans = 0;
    rep(i,T) rep(j,2) chmax(ans, dp[i][j]);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3984
#include <iostream>
#include <string>

using namespace std;
int main() {
  int a, b, c;
  cin >> a >> b;
  c = (a*b)%2;
  
  if(c == 0){
    cout << "Even" << endl;
  }else{
    cout << "Odd" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			String s = sc.next();
			String t = sc.next();
			int result = 0;

			for (int i = 0; i < s.length(); i++) {
				if (s.charAt(i) != t.charAt(i)) {
					result++;
				}
			}
			System.out.println(result);
		}
	}
}


Measured memory_bytes: 41112
#include <bits/stdc++.h>
//----***やべーやつら***----
using namespace std;
#define int long long

//----***型定義***----
using ll = long long;
using pll = pair<ll, ll>;
using pdd = pair<double, double>;
typedef long double lb;
typedef vector<int,vector<int>> vvec;
typedef long double ld;
typedef pair<int,int> P;

//----***Like a Pythonista***----
#define REP(i,j,n) for (ll i=j;i<(n);i++)
#define RREP(i,n,j) for (ll i = n; j<i;i--)
#define each(i,...) for (auto&& i:__VA_ARGS__)
#define ALL(vec) (vec).begin(),(vec).end()
#define sum(...) accumulate(ALL(__VA_ARGS__),0LL)
#define dsum(...) accumulate(ALL(__VA_ARGS__),0.0L)
#define vec(type,name,...) vector<type> name(__VA_ARGS__)
template<class T> inline auto max(const T& a){ return *max_element(ALL(a)); }
template<class T> inline auto min(const T& a){ return *min_element(ALL(a)); }
inline ll gcd(ll a, ll b){ while(b){ ll c = b; b = a % b; a = c; } return a; }
inline ll lcm(ll a, ll b){ if(!a || !b) return 0; return a * b / gcd(a, b); }

//----***定数***----
const int MOD=1e9+7;
#define INF 1e9;
#define EPS 1e-9;

//----***入出力***---
#define print(out) cout<< out  << "\n";
#define debug(var)  do{std::cerr << #var << " ↓ "<<"\n";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
#define here  cout<<"Here"<<endl;


//----***初期時読み込み***----
struct initial{initial(){cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);};}initial_;

signed main(){
  int N,K;cin>>N>>K;
  vector<vector<int>> dp(N+1,vector<int>(K+1,0));
  dp[0][0]=0;
  REP(i,0,N+1){dp[i][0]=1;dp[i][1]=i;}
  REP(i,1,N+1)REP(j,2,K+1){
    dp[i][j]=dp[i-1][j-1]+dp[i-1][j];
    dp[i][j]%=MOD;
  }
  //debug(dp);
  //print(dp[N-K+1][1]*(K-2));
  REP(i,1,K+1){
    int ans=dp[N-K+1][i]*dp[K-1][i-1];
    ans%=MOD;
    print(ans)
  }
}


Measured memory_bytes: 31616
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
using namespace std;
const int N=1505;
int S[N],n,u[N][N],l[N][N],r[N][N];
char A[N][N];
int main(){
	scanf("%d",&n);
	for (int i=1;i<=n;i++)scanf("%s",A[i]+1);
	for (int i=0;i<=n;i++)
		for (int j=0;j<=n;j++)u[i][j]=A[i][j]>='0'&&A[i][j]<='9'?min(i,min(u[i-1][j],u[i][j-1])):1<<30;
	long long ans=0;
	for (int x=1;x<=n;x++){
		for (int i=x;i;i--){
			for (int j=1;j<=n;j++)S[j]=S[j-1]+(u[x][j]<=i?A[x][j]-'0':0);
			for (int j=n+1;j;j--){
				l[i][j]=1<<30;r[i][j]=-1;
				if (A[i][j]>='0'&&A[i][j]<='9'){
					if (i<x){
						l[i][j]=min(l[i][j],l[i+1][j]);
						r[i][j]=max(r[i][j],r[i+1][j]);
					}
					else l[i][j]=r[i][j]=j;
					l[i][j]=min(l[i][j],l[i][j+1]);
					r[i][j]=max(r[i][j],r[i][j+1]);
				}
				if (l[i][j]<=r[i][j])ans+=(A[i][j]-'0')*(S[r[i][j]]-S[l[i][j]-1]-(i==x?A[i][j]-'0':0));
			}
		}
	}
	printf("%lld\n",ans);
}


Measured memory_bytes: 15360
#include <bits/stdc++.h>
using namespace std;
int main(void){
    long long N;
    cin >> N;
    int S = 0;
    int i = 10;
    int j = 1;
    while(N / j > 0){
        S += N % i / j;
        i *= 10;
        j *= 10;
       // cout << S << endl;
    }
    if(N % S == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
}


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

int main(){
  int n, m;
  cin >> n >> m;
  vector<pair<int, int>> students;
  vector<pair<int, int>> points;
  rep(i, n){
    int a, b;
    cin >> a >> b;
    students.push_back(make_pair(a, b));
  }
  rep(i, m){
    int a, b;
    cin >> a >> b;
    points.push_back(make_pair(a, b));
  }
  rep(i, n){
    int nearest = 300000000;
    int num;
    rep(j, m){
      int dis = abs(points[j].first-students[i].first) + abs(points[j].second-students[i].second);
      if(dis < nearest){
      	nearest = dis;
        num = j;
      }
    }
    cout << num+1 << endl;
  }
   return 0;   
      
}

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

int main()
{
    int a,b,c;
    cin>>a>>b>>c;

    int x = b-a;
    if(x<=0)
    {
        if(b<=c && c<=a)
            cout<<"Yes";
        else
            cout<<"No";
    }
    if(x>0)
    {
        if(a<=c && c<=b)
            cout<<"Yes";
        else
            cout<<"No";
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,N) for (int i = 0; i < (N); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int inf{int(1e9)};
int main(void){
  int N;
  cin >> N;
  string S;
  cin >> S;
  int ans = 1;
  for (int i = 1; i < N; i++){
    if (S[i] != S[i - 1]) ans ++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3720
import fractions
a, b = map(int, input().split())
c = fractions.gcd(a, b)

def prime_factorize(n):
    s = set()
    while n % 2 == 0:
        s.add(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            s.add(f)
            n //= f
        else:
            f += 2
    if n != 1:
        s.add(n)
    return s
print(1+len(prime_factorize(c)))

Measured memory_bytes: 5048
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, l, r) for (int i = (l); i < (r); i++)
#include <bits/stdc++.h>
//~ #include <atcoder/all>
using namespace std;
using ll = long long;
//~ using P = pair<int, int>;

template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
//~ int A = (1<<2) | (1<<3) | (1<<5) | (1<<7);
//~ for (int bit=A; ; bit=(bit-1)&A){
//~ if (!bit) break;
//~ }
int next_combination(int sub)
{
    int x = sub & -sub, y = sub + x;
    return (((sub & ~y) / x) >> 1) | y;
}
//~ int n=5;
//~ int k=3; // nCkの組み合わせ、ただしk=0には対応してない
//~ int bit=(1<<k)-1; // 1000 -> 0111
//~ for(; bit < (1<<n); bit=nex_combination(bit){
//~ }
bool isPrime(int a)
{
    if (a == 2)
        return true;
    if (a <= 1 || a % 2 == 0)
        return false;

    for (int i = 3; i * i <= a; i += 2)
    {
        if (a % i == 0)
            return false;
    }
    return true;
}
//~ vector<int> a = {1, 14, 32, 51, 51, 51, 243, 419, 750, 910};
vector<int> a;
// index が条件を満たすかどうか
bool isOK(int index, int key)
{
    if (a[index] >= key)
        return true;
    else
        return false;
}
// 汎用的な二分探索のテンプレ
int binary_search(int key)
{
    int ng = -1;            //「index = 0」が条件を満たすこともあるので、初期値は -1
    int ok = (int)a.size(); // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()

    /* ok と ng のどちらが大きいかわからないことを考慮 */
    while (abs(ok - ng) > 1)
    {
        int mid = (ok + ng) / 2;

        if (isOK(mid, key))
            ok = mid;
        else
            ng = mid;
    }
    return ok;
}

long long modpow(long long a, long long n, long long mod)
{
    long long res = 1;
    while (n > 0)
    {
        if (n & 1)
            res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

//~ int v[100100];
//~ int INF = 1 << 30;
//~ vector<vector<int>> dp(310, vector<int>(310));
//~ ll dp[110][100100];
//~ vector<int> dp(100100, 0));

//~ int seen[110];
//~ int ans[110][2];
//~ ll MOD = 1e9 + 7;

int main()
{
    int N, M, C;
    cin >> N >> M >> C;

    int B[110];
    rep(i, M)
    {
        cin >> B[i];
    }

    int A[110][110];
    rep(i, N)
    {
        rep(j, M)
        {
            cin >> A[i][j];
        }
    }

    int ans = 0;
    rep(i, N)
    {
        int sum = 0;
        rep(j, M)
        {
            sum += A[i][j] * B[j];
        }
        sum += C;
        if (sum > 0)
            ans++;
    }

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


Measured memory_bytes: 3640
Sa=list(input())
Sb=list(input())
Sc=list(input())
S = [Sa, Sb, Sc]
Ans = ["A", "B", "C"]
idx = ['a', 'b', 'c']
p = 'a'

def take_turn(i):
  if len(S[i])==0:
    print(Ans[i])
    exit()
  else:
    p = S[i].pop(0)
    return p
    
while True:
  p = take_turn(idx.index(p))


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

int main(){
 int n;
  cin >> n;
  int test[n]={};
  
  for(int i=0;i<n;i++){
    
    cin >> test[i];  
  }
  
  for(int i=n-1;i>=1;i--){
    
    cout << test[i] << ' ' ;
    
  } 
  cout << test[0] << endl;
}


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

using namespace std;

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

int read(){
	int i;
	scanf("%d",&i);
	return i;
}

int s[1000][1000],c[1001][1001];

int main(){
	while(true){
		
	memset(s,0,sizeof(s));
	memset(c,0,sizeof(c));
	int h=read(),w=read();
	c[0][0]=read()-1;
	if(h==0&&w==0)
		break;
	REP(i,h)
		REP(j,w)
			s[i][j]=read();
	REP(l,h+w-2)
		REP(x,w){
			int y=l-x;
			if(y<0||h<=y)
				continue;
			if(c[y][x]%2==0){
				c[y+1][x]+=c[y][x]/2;
				c[y][x+1]+=c[y][x]/2;
			}else{
				c[y+1][x]+=c[y][x]/2+1-s[y][x];
				c[y][x+1]+=c[y][x]/2+s[y][x];
				s[y][x]^=1;
			}
		}
	int x=0,y=0;
	while(x<w&&y<h){
		if(s[y][x]==0)
			y++;
		else
			x++;
	}
	printf("%d %d\n",y+1,x+1);
	
	}
}

Measured memory_bytes: 11024