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

int64_t mod = 1000000007;
int64_t large = 9223372036854775807;
double PI = 3.141592653589793;

int main()
{
    int N, K, tmp, ans = mod;
    cin >> N >> K;
    vector<int> list(N);
    for (int i = 0; i < N; i++)
        cin >> list[i];
    sort(list.begin(), list.end());
    for (int i = 0; i < N - K + 1; i++)
    {
        tmp = list[i + K - 1] - list[i];
        ans = min(ans, tmp);
    }
    cout << ans;
}

Measured memory_bytes: 640
#include <stdio.h>
#include <stdlib.h>
int asc(const void *a, const void *b){
    return *(int*)a-*(int*)b;
}
int main(void){
    int n,i;
    scanf("%d",&n);
    int a[n];
    for(i=0;i<n;i++) scanf("%d",&a[i]);
    qsort(a,n,sizeof(int),asc);
    printf("%d",a[n-1]-a[0]);
}


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

int main(){
  int k;
  cin >> k;
  int rep = 7%k;
  for(int i=0; i<k; i++){
    if(rep==0){
      cout << i+1;
      return 0;
    }
    rep = (10*rep+7)%k;
  }
  cout << -1;
  return 0;
}

Measured memory_bytes: 3188
#include<stdio.h>
#include<string.h>
 
int main(void){
 
  int i;
 
  /* 文字列 */
  char str[1200];
 
  /* 英数字を入力 */
  scanf(" %[^\n]", str);
       
  
  /* アルファベットの小文字を大文字に変換 */
  for(i=0;i<1200;i++){
    /* アルファベットの小文字なら変換 */
    if(str[i]>=97&&str[i]<=122)
      str[i]=str[i]-32;
    else if(str[i] >= 65 && str[i] <= 90)
      str[i]=str[i]+32;
  }
  /* 変換した文字列を出力 */
  printf("%s\n", str);
 
  return 0;
}




Measured memory_bytes: 2044
#include <iostream>
#include <math.h>
using namespace std;

bool isPrime (int num)
{
    if (num <=1)
        return false;
    else if (num == 2)         
        return true;
    else if (num % 2 == 0)
        return false;
    else
    {
        bool prime = true;
        int divisor = 3;
        double num_d = static_cast<double>(num);
        int upperLimit = static_cast<int>(sqrt(num_d) +1);
        
        while (divisor <= upperLimit)
        {
            if (num % divisor == 0)
                prime = false;
            divisor +=2;
        }
        return prime;
    }
}
int main()
{
	unsigned int  n,j;
	cin >> n;
	unsigned  int num[n],count = 0;
	for(int i = 0; i < n; i++)
	{
		cin >> num[i];
	}
	for(int i = 0; i < n; i++)
	{
		if(isPrime(num[i])) count++;
  }
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 3092
#include<bits/stdc++.h>
#define enld '\n'
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[6] = {1, 0, -1, 0,1,1};
const int dy[6] = {0, 1, 0, -1,1,-1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// ---------------------------------------------------------------------------

int N;
vector<string> G;

int solve(int row,int col){
    int res = 0;
    for(int k=0; k<6; k++){
        int x = row;
        int y = col;
        int now = 0;
        while(x>=0 and x<N and y<N and y>=0){
            if(G[x][y]-'0' > 0) now++;
            else{
                chmax(res,now);
                now = 0;
            }
            y += dy[k];
            x += dx[k];
        }
        chmax(res,now);
    }
    return res;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> N;
    while(N != 0){
        int ans = 0;
        G.resize(N);
        for(int i=0; i<N; i++){
            cin >> G[i];
        }
        for(int i=0; i<N; i++){
            chmax(ans,solve(i,0));
            chmax(ans,solve(0,i));
            chmax(ans,solve(i,N-1));
            chmax(ans,solve(N-1,i));
        }
        cout << ans << enld;
        cin >> N;
    }
    return 0;
}



Measured memory_bytes: 3300
def main():
    MOD=10**9+7
    N,K=map(int, input().split())
    A=list(map(int, input().split()))
    A2=A*2
    C1=0
    C2=0
    for i in range(N*2):
        for j in range(i+1,N*2):
            if A2[i] > A2[j]:
                if j < N:
                    C1+=1
                elif i < N and N <= j:
                    C2+=1
    ans = (C1*K%MOD + C2*(K * (K-1) // 2)%MOD)%MOD
    print(ans)
if __name__ == '__main__':
    main()

Measured memory_bytes: 41324
#include <cstring>
#include <cstdio>
#define INF 1e9
#define eps 1e-6
typedef long long ll;

char c[210];
int k, n, dp[110][5][2];

int dfs(int now, int cnt, bool have0){
	//printf("%d %d %d %d\n", now, las, cnt, have0);
	if(now == n + 1)
		return cnt == k;
	if(cnt > k)
		return 0;
	if(dp[now][cnt][have0] >= 0 && !have0)
		return dp[now][cnt][have0];
	
	int maxx = have0 ? c[now] - '0' : 9, sum = 0;
	for(int i = 0; i <= maxx; i++)
		sum += dfs(now + 1, cnt + (i != 0), have0 && (i == maxx));
	
	return dp[now][cnt][have0] = sum;
}

int main(){

	memset(dp, -1, sizeof(dp));
	scanf("%s\n%d", c + 1, &k);
	n = strlen(c + 1);
	printf("%d\n", dfs(1, 0, 1));

	return 0;
}

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

#define for_(i,a,b) for(int i=a;i<b;++i)
#define ALL(a) a.begin(),a.end()
#define INIT(a,b) memset(a,b,sizeof(a))
using lint = long long int;

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

    if (S.back() == 's') cout << S << "es" << endl;
    else cout << S << "s" << endl;
}

Measured memory_bytes: 3624
S = input()

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


Measured memory_bytes: 2940
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int W = in.nextInt();
            int[] wt = new int[n];
            long[] val = new long[n];
            for (int i = 0; i < n; i++) {
                wt[i] = in.nextInt();
                val[i] = in.nextInt();
            }
            int i, w;
            long K[][] = new long[n + 1][W + 1];

            for (i = 0; i <= n; i++) {
                for (w = 0; w <= W; w++) {
                    if (i == 0 || w == 0)
                        K[i][w] = 0;
                    else if (wt[i - 1] <= w)
                        K[i][w] = Math.max(val[i - 1] + K[i - 1][w - wt[i - 1]], K[i - 1][w]);
                    else
                        K[i][w] = K[i - 1][w];
                }
            }

            out.println(K[n][W]);


        }

    }
}



Measured memory_bytes: 126548
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <cmath>
#include <climits>
#include <math.h>
#include <bitset>

#define P pair
#define X first
#define Y second
#define VSORT(v) sort(v.begin(), v.end())
#define VREV(v) reverse(v.begin(), v.end())
#define VMAX_P(v) max_element(v.begin(), v.end())
#define VMIN_P(v) min_element(v.begin(), v.end())
#define VMAX_IDX(v) distance(v.begin(), VMAX_P(v))
#define VMIN_IDX(v) distance(v.begin(), VMIN_P(v))
#define VCOPY(src, dst) copy(src.begin(), src.end(), back_inserter(dst))
#define SUPPER(src, dst) transform(src.begin(), src.end(), dst.begin(), toupper);
#define SLOWER(src, dst) transform(src.begin(), src.end(), dst.begin(), tolower);

using namespace std;
using ll = long long;

int main(int argc, const char *argv[])
{
    int n, cnt = 0;
    cin >> n;
    vector<int> v(n);
    for (int i = 0; i < n; i++)
    {
        cin >> v[i];
        if (i < 2)
        {
            continue;
        }
        if (v[i - 1] != min(v[i], min(v[i - 1], v[i - 2])) && v[i - 1] != max(v[i], max(v[i - 1], v[i - 2])))
        {
            cnt++;
        }
    }
    cout << cnt << endl;
}


Measured memory_bytes: 256
// When you are hungry for something and you're determined and you're focused 
// and you're committed to something it's hard to surrender, isn't it?

#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define endl "\n"
#define ll long long 
#define int ll
#define mod 1000000007
#define mod1 1000000006
#define modi 998244353
#define setbit(x) __builtin_popcount(x)
#define fff(i,n) for(int i=0;i<n;i++)
#define ff first
#define ss second
#define pb push_back
vector<ll> vi[300005];
int color[100005];
ll pa[500005];
ll si[500005];
#define pb push_back
bool visi[1000005]={false};
bool is[100005];
ll fac[10000001];
ll prime[400005];
ll bit[100005];
const long double eps = 1.0e-14;      // allowable error
#define fio ios_base::sync_with_stdio(false); cin.tie(NULL);
 
 
void fact(){
    fac[0]=1;
    for(int i=1;i<=10000000;i++){
        fac[i]=(fac[i-1]*i)%mod;
    }
    return ;
}
void sieve(){
    prime[0]=0;
    prime[1]=0;
    for(int i=2;i<400005;i++){
        prime[i]=1;
    }
    for(int i=2;i*i<400005;i++){
        if(prime[i]==1){
            for(int j=i*i;j<400005;j+=i){
                prime[j]=0;
            }
        }
    }
    
}
 
ll power(ll n , ll p ){
    if(p==0)
        return 1;
    
    ll res = power((n*n)%mod,p/2);
    if(p%2==1)
        res = (n*res)%mod;
    
    return res;
}
 
 
void upd(ll i,ll val,ll n) {
    for(;i<=n;i+=i&(-i))
        bit[i]+=val;
}
 
ll qry(ll i) {
    ll sum=0;
    for(;i>0;i-=i&(-i))
        sum+=bit[i];
    return sum;
}
 
 
ll fin(ll u) {
    if(pa[u]==u)
        return u;
    return fin(pa[u]);
}
 
void uni(ll u,ll v) {
    ll p1=fin(u);
    ll p2=fin(v);
    if(p1==p2)
        return;
    if(si[p1]<si[p2])
        swap(p1,p2);
    si[p1]+=si[p2];
    pa[p2]=p1;
    return;
}

int log(int x) {
    int i;
    for(i=0;(1ll<<i)<=x;i++);
    return i;
}
 
int32_t main() {
    fio
    
    cout << fixed << setprecision(15);
    int a,b;
    cin >> a >> b;
    int p=0,z=0,n=0;
    
    if(a<=0 and b>=0 )
    cout << "Zero";
    else if(a>0)
    cout << "Positive";
    else {
        int x=abs(a-b);
        x+=1;
        if(x%2==0)
        cout << "Positive";
        else
        cout << "Negative";
        
    }
    
	return 0;
    
}

Measured memory_bytes: 8832
//C - Make a Rectangle: 
//Assunto: 
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define loop(i, a, b) for(int i = a; i < b; i++)
#define loopBack(i, a, b) for(int i = a; i >= b; i--)
#define INF INT_MAX
#define LINF LLONG_MAX
#define DINF DBL_MAX
#define MAX 100050
#define MOD 1000000007
using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;

int main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    int n, i;
    ll ans, s1 = -1, s2 = -1;
    cin >> n;
    vector<int> sizes(n);
    loop(i, 0, n) cin >> sizes[i];
    sort(rall(sizes));
    i = 0;
    while(i < n-1) {
        if(sizes[i] == sizes[i+1])  {
            if(s1 == -1) s1 = sizes[i];
            else {
                s2 = sizes[i];
                break;
            }
            i += 2;
        } else i++;
    }
    if(s1 == -1 or s2 == -1) ans = 0;
    else ans = s1 * s2;
    cout << ans << "\n";
}

Measured memory_bytes: 640
A=int(input())
B=int(input())
C=int(input())
X=int(input())
count=0
for a in range(A+1):
  for b in range(B+1):
    for c in range(C+1):
      total=500*a+100*b+50*c
      if total==X:
        count+=1
        
print(count)

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

using namespace std;

typedef pair<int,int> pi;
typedef long long ll;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	string s;
	cin >> s;
	for (int i = 0; i < s.size(); ++i){
		if (s[i] == '?'){
			s[i] = 'D';
		}
	}
	cout << s << '\n';
}

Measured memory_bytes: 3780
#include <bits/stdc++.h>
#define pb push_back
#define all(a) a.begin(),a.end()
#define forn(i,n) for(int i=0;i<int(n);i++)
#define forr(i,n) for(int i=int(n-1);i>=0;i--)
#define fora(i,a,b) for(int i=int(a);i<=int(b);i++)
#define forb(i,a,b) for(int i=int(a);i>=int(b);i--)
#define mod 1000000007
using namespace std;
using ll=long long int;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<ll> vii;
typedef pair<ll,ll> pii;
const int N=1e7;
void solve()
{
	int n,m,k;
	cin>>n>>m>>k;
	int ans=0;
	fora(i,n,m)
	{
		if(i%k==0)ans++;
	}
	cout<<ans<<endl;
}
int main()
{
	
    ios::sync_with_stdio(0); 
    cin.tie(0); 
    cout.tie(0);
    int t=1;
  	//cin>>t;
    while(t--)
   	solve();
}


Measured memory_bytes: 3636
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <tuple>
#include <queue>
#include <bitset>
#include <set>
#include <map>
#include <list>

using ll = long long;
using ld = long double;
using namespace std;
const int INF = 1e9+100;
const ll INF64 = 7e18l;
const int mod = 1000000007;
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(a) (a).begin(), (a).end()
#define FIN ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);


int main(){
    FIN;
    string s;
    cin >> s;
    ll ans = 0;
    for(int i=0;i<s.size()-1;i++){
        if(s[i] != s[i+1]) ans++;
    }

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



Measured memory_bytes: 512
from collections import deque
from typing import List


def main():
    h, w = map(int, input().split())
    g = []
    for _ in range(h):
        r = list(input())
        g.append(r)
    print(mm(h, w, g))


def mm(h: int, w: int, g: List[List[str]]) -> int:
    ret = 0
    for i in range(h):
        for j in range(w):
            if (g[i][j] == '#'):
                continue
            v = set()
            q = deque([(i, j, 0)])
            v.add((i, j))
            while q:
                ii, jj, cnt = q.popleft()
                ret = max(ret, cnt)
                # ↓
                if ii < h - 1 and g[ii + 1][jj] == '.' and (ii + 1, jj) not in v:
                    q.append((ii + 1, jj, cnt + 1))
                    v.add((ii + 1, jj))
                # →
                if jj < w - 1 and g[ii][jj + 1] == '.' and (ii, jj + 1) not in v:
                    q.append((ii, jj + 1, cnt + 1))
                    v.add((ii, jj + 1))
                # ↑
                if ii > 0 and g[ii - 1][jj] == '.' and (ii - 1, jj) not in v:
                    q.append((ii - 1, jj, cnt + 1))
                    v.add((ii - 1, jj))
                # ←
                if jj > 0 and g[ii][jj - 1] == '.' and (ii, jj - 1) not in v:
                    q.append((ii, jj - 1, cnt + 1))
                    v.add((ii, jj - 1))
    return ret


if __name__ == '__main__':
    main()


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

#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

int main() {
    int64_t n, m;
    cin >> n >> m;

    vector<int64_t> h(n);
    for (auto&& hh : h) {
        cin >> hh;
    }

    vector<bool> ok(n, true);
    for (auto _ : irange(0L, m)) {
        int64_t a, b;
        cin >> a >> b;
        --a;
        --b;

        if (h[a] <= h[b]) {
            ok[a] = false;
        }
        if (h[a] >= h[b]) {
            ok[b] = false;
        }
    }

    cout << count(ok.begin(), ok.end(), true) << endl;
}

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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_N 100010

ll N, H, W;

signed main()
{
    cin >> N >> H >> W;
    ll ans = (N - H + 1) * (N - W + 1);
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define sanyes ios_base::sync_with_stdio(0), cout.tie(0); cin.tie(0);
#define llong long long int
#define pb push_back
#define bpc __builtin_popcount
#define f first
#define s second

const llong mxn = 2 * 1e5 + 7;
const llong mod = 1e9 + 7;
const llong inf = 1e18 + 9;

using namespace std; 

llong n, a[mxn], dp[mxn], mx = -inf;

int main(){
    cin >> n;
    for (int i = 1; i <= n; i ++){
        cin >> a[i];
    }for (int i = 1; i <= n; i ++){
        dp[a[i]] = dp[a[i] - 1] + 1;
        mx = max(dp[a[i]], mx);
    }cout << n - mx;
    return 0;
}


Measured memory_bytes: 3328
#include <stdio.h>
#include <math.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define max(p,q)((p)>(q)?(p):(q))

int main(){
	ll a,b,c,d;
	while(scanf("%lld%lld%lld%lld",&a,&b,&c,&d),a){
		printf("%lld\n",max(0,(b*c-a+d-1)/d));
	}
}



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

int main(void)
{
    int len;
    int wid;
    
    int length = 0;
    int area = 0;
    
    scanf("%d %d",&len,&wid);
    length = (len + wid) * 2;
    area = len * wid;
    printf("%d %d\n",area,length);
}


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

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

using namespace std;


int main() {

    ll n,t; cin >> n >> t;
    ll cur,prev;
    ll ans = 0;


    rep(i,n){
        cin >> cur;
        if(i == 0) prev = cur;
        else if((cur-prev) > t) ans += t;
        else ans += cur-prev;
        prev = cur;
    }

    cout << (ans + t);

    return 0;
}











Measured memory_bytes: 3640
#include <bits/stdc++.h> 
using namespace std; 
#define int long long
int minimumCost(int price[], int n) 
{ 
	sort(price, price + n); 
	int totalCost = 0; 
	for (int i = n - 1; i > 1; i -= 2) { 
		if (i == 2) { 
			totalCost += price[2] + price[0]; 
		} 
		else { 
			int  price_first = price[i] + price[0] + 2 * price[1]; 
			int  price_second = price[i] + price[i - 1] + 2 * price[0]; 
			totalCost += min(price_first, price_second); 
		} 
	} 
	if (n == 1) { 
		totalCost += price[0]; 
	} 
	else { 
		totalCost += price[1]; 
	} 

	return totalCost; 
} 
int32_t main() 
{ 
	int s; cin>>s;
    int n; cin>>n;
    cout<<(n+s-1)/n;
    return 0;
	int  price[n];
	int tp=0;
	for(int i=0;i<n;++i)
	{cin>>price[i]; tp+=price[i];}	
	if(tp>=s)
		cout<<"Yes";
	else
		cout<<"No";

	return 0; 
} 


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

int main(void) {

    int X, Y, Z, K;
    cin >> X >> Y >> Z >> K;

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

    vector<long long int> AB(X*Y);
    int index = 0;
    for(int i=0;i<X;i++){
        for(int j=0;j<Y;j++){
            AB[index] = A[i] + B[j];
            index++;
        }
    }

    sort(AB.begin(), AB.end(), greater<>());
    
    vector<long long int> ABC(K*Z);
    index = 0;
    int end = min(K, (int)AB.size());
    for(int i=0;i<end;i++){
        for(int j=0;j<Z;j++){
            ABC[index] = AB[i] + C[j];
            index++;
        }
    }

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

    for(int i=0;i<K;i++){
        cout << ABC[i] << endl;
    }

}

Measured memory_bytes: 31616
#include<iostream>
using namespace std;
int main(void){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  if(a<=b && b<=c && c<=d)cout<<0<<endl;
  else if(a<=c && c<=b && b<=d)cout<<b-c<<endl;
  else if(c<=a && a<=b && b<=d)cout<<b-a<<endl;
  else if(a<=c && c<=d && d<=b)cout<<d-c<<endl;
  else if(c<=a && a<=d && d<=b)cout<<d-a<<endl;
  else cout<<0<<endl;
  return 0;
}

Measured memory_bytes: 256
/*==============================================*\
Codeforces ID:    mdshihab
                                                  |
Name:     Md. Shihabul Minhaz                     |
Study:      CSE, JKKNIU                           |
Address:  Trishal, Mymensingh, Bangladesh         |
                                                  |
 mail:   mdshihabul20171@gmail.com                |
 FB  :   fb.com/mdshihabul.minhaz.7               |
 github: Shihabulminhaz                           |
stopstalk :  mdshihab                             |
                                                  |
@uthor   Md. Shihabul Minhaz (shihab)             |
\*===============================================*/


#include<bits/stdc++.h>
using namespace std;
#define fi(a) scanf("%d",&a);
#define fli(a) scanf("%ld",&a);
#define fll(a) scanf("%lld",&a);
#define pi(a) printf("%d\n",a);
#define ppi(i,a) printf("Case %d: %d\n",i,a);
#define ll long long
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
void FI()
{
#ifndef ONLINE_JUDGE
    freopen("C:\\Users\\SHIHAB\\Desktop\\input.in","r",stdin);
#endif // ONLINE_JUDGE
}

int main()
{
    fast
    //FI(); /// skip this line for compile
    int n,a,b;
    cin >> n >> a >> b;
    for(int i=a;i<=b;i++){
        if(i%n==0){cout << "OK\n"; return 0;}
    }
    cout << "NG\n";
    return 0;
}


Measured memory_bytes: 3656
import java.util.Scanner;

//SAT-EN-3
public class Main{

	char[] s;
	int id;
	boolean assign;
	
	char get(){
		return s[id++];
	}
	
	void exp(){
		boolean[][] r = clause();
		check(r);
		while(true){
			char ch = get();
			if(ch!='|')break;
			r = clause();
			check(r);
		}
	}
	
	void check(boolean[][] r){
		for(int i=0;i<26*2;i++){
			if(r[0][i]&&r[1][i])return;
		}
		assign = true;
	}
	
	//r[0][26*2] = assigned true
	//r[1][26*2] = assigned false;
	boolean[][] clause(){
		get();
		boolean[][] r = new boolean[2][26*2];
		for(int k=0;k<3;k++){
			int a = 0;
			int x = 0;
			char ch = get();
			if(ch=='~'){
				a=1;
				ch = get();
			}
			if(Character.isLowerCase(ch)){
				ch = Character.toUpperCase(ch);
				x = 26;
			}
			r[a][x+ch-'A'] = true;
			get();
		}
		return r;
	}
	
	void run(){
		Scanner sc = new Scanner(System.in);
		while(true){
			s = (sc.next()+"$").toCharArray();
			if(s[0]=='#')break;
			id = 0;
			assign = false;
			exp();
			System.out.println(assign?"yes":"no");
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

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

const double PI = 3.14159265358979323846;
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//typedef pair<ll, ll> P;
typedef pair<ll, int> P;
const ll INF = 1e15;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

std::istream &operator>>(std::istream &in, set<int> &o) {
    ll a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
const int mod = 1000000007;
//const ll mod = 1e10;
typedef priority_queue<string, vector<string>, greater<string> > PQ_ASK;

bool is_over(ll target, ll now) {
    assert(target == -1 || target == 1);
    if (target == 1) {
        return now >= 1;
    } else {
        return now <= -1;
    }
}

ll calc_to(ll target, ll now_sum, ll now) {
    if (is_over(target, now_sum + now)) {
        return now;
    } else {
        ll to = target - now_sum;
        assert(now_sum + to == target);
        return to;
    }
}


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

    vector<vector<ll>> numbers(2, vector<ll>(n));
    rep(i, n) cin >> numbers[0][i];
    rep (i, n) numbers[1][i] = numbers[0][i] * -1;

    ll ans = INF;
    for (vector<ll> &numb : numbers) {
        ll sum = 0;
        // +-+-
        vector<ll> tos(n, 0);
        rep(i, n) {
            ll target = i % 2 == 0 ? 1 : -1;
            ll to = calc_to(target, sum, numb[i]);
            tos[i] = to;
            sum += to;
        }

        ll diff = 0;
        rep(i, n) diff += abs(numb[i] - tos[i]);
        cmin(ans, diff);
    }
    cout << ans << endl;
}


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

using namespace std;
typedef unsigned long ul;
typedef pair<ul, ul> P;

int main(){
    string str[50];
    string ans = "Yes";
    bool can = false;
    int H,W;
    int dx[4] = {-1, 0, 1, 0};
    int dy[4] = {0, 1, 0, -1};

    cin >> H >> W;

    rep(i, H){
        cin >> str[i];
    }

    rep(i, H){
        rep(j, W){
            can = false;
            if (str[i][j] == '.') continue;
            rep(k, 4){
                int di = i + dx[k];
                int dj = j + dy[k];

                if (di < 0 || di >= H) continue;
                if (dj < 0 || dj >= W) continue;
                if (str[di][dj] == '#') can = true;
            }
            if (!can){
                ans = "No";
                i += H;
                j += W;
            }
        }
    }
    cout << ans << endl;
} 

Measured memory_bytes: 256
import itertools
N = int(input())
li = list(map(int, input().split()))
c = 0
for a in itertools.combinations(li, 3):
  b = sorted(a, reverse=True)
  if b[0] != b[1] and b[1] != b[2] and b[2] != b[0]:
    if b[0] < b[1] + b[2]:
      c = c + 1
print(c)

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

using namespace std;
typedef long long unsigned int ll;
int main() {
  ll a, b, x;
  cin >> a >> b >> x;
  ll ans = (b / x) - ((a == 0 ? 0: a - 1) / x) ;
  cout << (a == 0? ans + 1: ans) << endl;
  return 0;
}



Measured memory_bytes: 256
h, w = map(int, input().split())

c = []
for _ in range(10):
  nums = map(int, input().split())
  c.append(list(nums))

wall = []
for _ in range(h):
  wa = list(map(int, input().split()))
  wall.append(list(wa))
  
for k in range(10):
  for i in range(10):
    for j in range(10):
      c[i][j] = min(c[i][j], c[i][k]+c[k][j])

total_cost = 0
for i in range(h):
  for j in range(w):
    num = wall[i][j]
    if num != -1:
      total_cost += c[num][1]
print(total_cost)


Measured memory_bytes: 3444
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Numerics;
public class MainClass
{
	public const long Giri = 1000000007;
	public const long DpInf = 99999999999999;
	
	public static void Main(string[] args)
	{
		var s = Console.ReadLine();
		Console.WriteLine(s.Substring(0,3));
	}
	
	
	static long GCD(long a, long b)
	{
		var v = new[] { a, b };
		while (v[1] != 0) { v = new[] { v[1], v[0] % v[1] }; }
		return v[0];
	}
	public static string[] Input() { return Console.ReadLine().Split(); }
}

public static class Smarter
{
	public static int ToInt(this string str) { return int.Parse(str); }
	public static long ToLong(this string str) { return long.Parse(str); }
	public static int[] ToInt(this string[] str, int offset = 0)
	{
		var r = new int[str.Length];
		for(int i = 0; i < str.Length; i++) r[i] = str[i].ToInt() + offset;
		return r;
	}
}

Measured memory_bytes: 25832
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define db double
#define pii pair<int,int>
#define pli pair<ll,int>
#define pil pair<int,ll>
#define pll pair<ll,ll>
#define mat vector<vector<int>>
const int inf = 1 << 30;
const ll linf = 1e18;
const db EPS = 1e-7;
template<class T> void chmin(T& x, T y){if(x > y) x = y;}
template<class T> void chmax(T& x, T y){if(x < y) x = y;}

template<long long mod>
struct modint{
    long long num;

    constexpr modint(long long x = 0) : num((x + mod) % mod) {}

    constexpr modint &operator += (const modint& rhs){
        num = (num + rhs.num) % mod;
        return *this;
    }
    constexpr modint &operator -= (const modint& rhs){
        num  -= rhs.num;
        while(num < 0) num += mod;
        num %= mod;
        return *this;
    }
    constexpr modint &operator *= (const modint& rhs){
        num = num * rhs.num % mod;
        return *this;
    }
    constexpr modint &operator /= (modint rhs){
        int exp = mod - 2;
        while(exp > 0){
            if(exp % 2){
                *this *= rhs;
            }
            rhs *= rhs;
            exp /= 2;
        }
        return *this;
    }

    constexpr modint operator ++ (){
        ++num;
        return *this;
    }
    constexpr modint operator ++ (int n){
        modint tmp = *this;
        ++(*this);
        return tmp;
    }
    constexpr modint operator -- (){
        --num;
        return *this;
    }
    constexpr modint operator -- (int n){
        const modint tmp = *this;
        --(*this);
        return tmp;
    }

    void modpow(ll y){
        modint tmp = (*this);
        (*this) = 1;
        while(y > 0){
            if(y % 2){
                (*this) *= tmp;
            }
            tmp *= tmp;
            y /= 2;
        }
    }

    constexpr modint operator + (const modint& rhs) const {
        return modint(*this) += rhs;
    }
    constexpr modint operator - (const modint& rhs) const {
        return modint(*this) -= rhs;
    }
    constexpr modint operator * (const modint& rhs) const {
        return modint(*this) *= rhs;
    }
    constexpr modint operator / (const modint& rhs) const {
        return modint(*this) /= rhs;
    }

    
    friend ostream &operator << (ostream& lhs, const modint& rhs){
        return lhs << rhs.num;
    }

    friend istream &operator >> (istream& lhs, modint& rhs){
        long long tmp;
        lhs >> rhs.num;
        return lhs;
    }
};

#define mint modint<1000000007>

int N;
mint x[100010];
mint ans;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> N;
    for(int i = 1; i <= N; i++) cin >> x[i];
    
    mint fac(1);
    for(int i = 1; i < N; i++){
        fac *= i;
    }
    mint sum = 0;
    for(int i = 1; i < N; i++){
        sum += fac / i;
        ans += sum * (x[i + 1] - x[i]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
N = int(input())
W = list(map(int, input().split()))

diff = [0 for i in range(N-1)]
for i in range(N-1):
  S1 = sum(W[:i+1])
  S2 = sum(W[i+1:])
  diff[i] = abs(S1 - S2)
print(min(diff))

Measured memory_bytes: 8912
S = []

W = raw_input().split()
    
for word in W:
    if word == "+":
        s1 = S.pop()
        s2 = S.pop()
        S.append(s1 + s2)
    elif word == "-":
        s1 = S.pop()
        s2 = S.pop()
        S.append(s2 - s1)
    elif word == "*":
        s1 = S.pop()
        s2 = S.pop()
        S.append(s2 * s1)
    else:
        S.append(int(word))

print S.pop()

Measured memory_bytes: 4216
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        if (a == b) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
        sc.close();
    }
}

Measured memory_bytes: 25172
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (ll i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define m1(x) memset(x,-1,sizeof(x))
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const double PI = 3.141592653589;

int main(){
  ll n, k;
  cin >> n >> k;
  ll ans = 0;
  for(ll i = k; i <= n+1; i++){
    ll tmp;
    tmp = (n-i+1) * i + 1;
    tmp %= MOD;
    ans = (tmp + ans) % MOD;
  }
  cout << ans <<endl;
}

Measured memory_bytes: 3640
import math

def makelist(n, m):
    return [[0 for _ in range(m)] for _ in range(n)]

# n
# a, b
# s = input()

N = int(input())
A = [0] + list(map(int, input().split()))


left = 0
right = sum(A)
ans = right
for i in range(1, N+1):
    left += A[i]
    right -= A[i]
    ans = min(ans, abs(right-left))
print(ans)


Measured memory_bytes: 91088
#include <iostream>

using namespace std;

string field[8];
int dx[] = {0, 1, 0, -1}, dy[] = {-1, 0, 1, 0};
void rec(int x, int y)
{
    field[y][x] = '0';
    for (int k = 0; k < 4; k++) {
        for (int a = 1; a <= 3; a++) {
            int nx = x + dx[k] * a, ny = y + dy[k] * a;
            if (nx >= 0 && nx < 8 && ny >= 0 && ny < 8 && field[ny][nx] == '1') {
                rec(nx, ny);
            }
        }
    }
}

int main()
{
    int T;
    scanf("%d", &T);
    for (int tc = 1; tc <= T; tc++) {
        for (int y = 0; y < 8; y++)
            cin >> field[y];
        int sx, sy;
        scanf("%d %d", &sx, &sy);
        rec(sx - 1, sy - 1);
        cout << "Data " << tc << ":" << endl;
        for (int y = 0; y < 8; y++)
            cout << field[y] << endl;
    }
}

Measured memory_bytes: 0
#include<iostream>
#include<string>
//ðÇÁ·é
void addplace(unsigned int *a, unsigned int *last, int num){
	if( a == last ) return; //[·¬ÜÛÀ
	
	int carry = (*a * 10 + num) / 100000000;
	addplace(a+1, last, carry);
	*a = (*a * 10 + num) % 100000000;
}
bool trace(unsigned int *a, unsigned int *last){
	if( a == last ) return false; //[·¬ÜÛÀ
	if( !trace(a+1, last) ){
		if( *a > 0 ){
			std::cout << *a;
			return true;
		}
	}else{
		char b[11]={};
		sprintf(b,"%d",*a+100000000);
		std::cout<<b+1;
		return true;
	}
	return false;
}
void add(unsigned int *a, unsigned int *alast, unsigned int *b, int num=0){
	if( a == alast ) return; //[·¬ÜÛÀ
	
	int carry = (*a + *b + num) / 100000000;
	add(a+1, alast, b+1, carry);
	*a = (*a + *b + num) % 100000000;
}
int main(){
	int n;
	std::cin>>n;
	std::string a,b;
	std::getline(std::cin, a);//üsÇÝÌÄ
	for(;n--;){
		std::getline(std::cin, a);
		std::getline(std::cin, b);
		//uint ½è1 0000 0000-1ÜÅJEg·é
		unsigned int _a[11]={},_b[11]={};
		int pcnt = 0;
		for(std::string::iterator it=a.begin();
			it!=a.end(); it++){
			if(++pcnt>80){
				std::cout<<"overflow\n";
				goto cnti;
			}
			addplace(_a, _a+10, *it-'0');
		}
		pcnt=0;
		for(std::string::iterator it=b.begin();
			it!=b.end(); it++){
			if(++pcnt>80){
				std::cout<<"overflow\n";
				goto cnti;
			}
			addplace(_b, _b+10, *it-'0');
		}
		add(_a, _a+11, _b);
		if( _a[10] >= 1 ){
			std::cout<<"overflow\n";
		}else{
			if(!trace(_a, _a+10))
				std::cout<<'0';
			std::cout<<'\n';
		}
cnti:;
	}
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define ll long long
#define re register
#define ull unsigned ll
using namespace std;
inline int read(){
	int s=0,t=1;
	char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')t=-1;ch=getchar();}
	while(ch>='0'&&ch<='9')s=(s<<3)+(s<<1)+(ch^48),ch=getchar();
	return s*t;
}
int n,m,K,Ans,p[20];
char a[10][10];
void Check(){
	int res=0;
	for(int i=1;i<=n;i++)
	for(int j=1;j<=m;j++)if(!p[i]&&!p[n+j])res+=(a[i][j]=='#');
	Ans+=(res==K);
}
void DFS(int x){
	if(x==n+m+1){Check();return;}
	p[x]=1,DFS(x+1),p[x]=0,DFS(x+1);
}
int main(){
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	n=read(),m=read(),K=read();
	for(int i=1;i<=n;i++)scanf("%s",a[i]+1);
	DFS(1),printf("%d",Ans);	
	return 0;
}


Measured memory_bytes: 3752
#include <set>
#include <iostream>

#define int long long

using namespace std;

int32_t main()
{
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);    
    set<pair<int, int>> m;
    for (int i = 0; i <= 6000; ++i)
    {
        m.insert({i * i * i * i * i, i});
        m.insert({-i * i * i * i * i, -i});
    }
    int x;
    cin >> x;
    for (auto i : m)
    {
        auto it = m.lower_bound({x + i.first, -100000000});
        if (it != m.end())
        {
            if (it->first != x + i.first) continue;
            cout << it->second << ' ' << i.second;
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 4368
import java.util.*;
public class Main{
	public static void main(String args[]) {
		Scanner sc=new Scanner(System.in);
		int N=sc.nextInt();
		int M=sc.nextInt();
		int C=sc.nextInt();
		int A[][]=new int[N][M];
		int B[]=new int[M];
		int sum;
		int count=0;
		for(int i=0;i<M;i++) {
			B[i]=sc.nextInt();
		}
		for(int j=0;j<N;j++) {
			for(int k=0;k<M;k++) {
				A[j][k]=sc.nextInt();
			}
		}
		for(int l=0;l<N;l++) {
			sum=0;
			for(int m=0;m<M;m++) {
				sum+=A[l][m]*B[m];
			}
			sum+=C;
			if(sum>0) {
				count++;
			}
		}
		System.out.println(count);
	}
}

Measured memory_bytes: 22224
#include <cstdint>
#include <cstdio>
using namespace std;
inline char tc(){
  static char fl[100],*A=fl,*B=fl;
  return A==B&&(B=(A=fl)+fread(fl,1,100,stdin),A==B)?EOF:*A++;  
}
inline uint_fast32_t read(){
  uint_fast32_t a=0;static char c;
  while((c=tc())<48||c>57);
  while(c>=48&&c<=57)a=a*10+c-48,c=tc();
  return a;
}
int h[100001];
int main(){
  uint_fast32_t n=read(),a=read(),b=read(),i;a-=b;
  double a_=1.0/a;
  for(i=0;i<n;++i)h[i]=read()+a-1;
  uint_fast32_t left=0,right=1000000000;
  int_fast64_t temp,cnt=0,mid;
  while (right>left+1) {
    mid=(right+left)>>1;
    cnt=0;
    for(i=0;i<n;++i){
      temp=h[i]-b*mid;
      if(temp>0)cnt+=temp*a_;
    }
    if(cnt<=mid)right=mid;
    else left=mid;
  }
  printf("%u\n",right);
}

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

#define ll long long
using namespace std;

ll x, y, z, a, b, c, _ap, _bp, _cp, N, ans, ara[ 200000 + 3 ], hi, flag;
vector <ll> adj[ 2003 ];
ll _a[ 100003 ], _b[ 100003 ], _c[ 100003 ], _t[ 200005 ];

int main()
{
  cin >> x >> y >> a >> b >> c;
  z = c;
  
  for (ll i=0; i<a; i++)
    cin >> _a[ i ];
  
  for (ll i=0; i<b; i++)
    cin >> _b[ i ];
  
  for (ll i=0; i<c; i++)
    cin >> _c[ i ];
 
  sort( _a, _a + a, greater< ll >());
  sort( _b, _b + b, greater< ll >());
  sort( _c, _c + c, greater< ll >());
  
  ll i = 0;
  for ( ; i<x; i++) {
    _t[ i ] = _a[ i ];
    ans += _a[ i ];
  }
  
  ll j = i;
  for (i=0; i<y; i++) {
    _t[ j + i ] = _b[ i ];
    ans += _b[ i ];
  }
  
  sort( _t, _t + x + y );
  
  i = 0;
  while ( _t[ i ] < _c[ i ] ){
    ans += _c[ i ] - _t[ i ];
    i++;
  }
  
  cout << ans << "\n";
  
  return 0;
}


Measured memory_bytes: 4224
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;
 
public class Main {
 
	public static void main(String[] args) {
		FastReader scan = new FastReader();
		PrintWriter out = new PrintWriter(System.out);
		int n = scan.nextInt(), q = scan.nextInt();
		int[] p = new int[n+1];
		char prev = 'z';
		char[] a = scan.next().toCharArray();
		for(int i = 1; i <= n; i++) {
			if(a[i-1] == 'C' && prev == 'A') p[i]++;
			p[i] += p[i-1];
			prev = a[i-1];
		}
		for(int i = 0; i < q; i++) {
			int l = scan.nextInt() - 1, r = scan.nextInt();
			int get = p[r] - p[l];
			if(l > 0 && a[l] == 'C' && a[l-1] == 'A') get--;
			out.println(get);
		}
		out.close();
	}
	
	
	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: 40552
// AOJ 2330 "雅先生の地球侵略日誌" (JAG夏合宿 2010 day 2 Problem A)
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        int n = sc.nextInt();
        long a = 1;
        int count = 0;
        while (a < n) {
            a *= 3;
            count++;
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 17352
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(int I = int(A); I < int(B); ++I)
#define FORR(I,A,B) for(int I = int((B)-1); I >= int(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=1e18+7;
const ll MOD=1e9+7;
#define pri(a) cout << (a) << endl


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

	ll N;
	cin >> N;
	ll dp[N+3];
	FOR(i,0,N+3)dp[i]=INF;
	ll h[N+3];
	FOR(i,1,N+1)cin>>h[i];
	dp[1] = 0;
	FOR(i,1,N+1){
		dp[i+1] = min(dp[i+1],dp[i]+abs(h[i+1]-h[i]));
		dp[i+2] = min(dp[i+2],dp[i]+abs(h[i+2]-h[i]));
	}
	cout << dp[N] << endl;
}

Measured memory_bytes: 1792
#include <iostream>

using namespace std;

typedef long long ll;

int main(int argc, char *argv[])
{
	int N, H[100005];

	cin >> N;

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

	ll ans = 0;
	ll s = 0;
	for (int i = 0; i < N - 1; ) {
		int k = 0;
		s = 0;
		for (int j = i; j < N - 1; j++) {
			k++;
			if (H[j] >= H[j + 1]) {
				s++;
			} else {
				break;
			}
		}
		i = i + k;
		ans = max(ans, s);
	}
	
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define INF 2000000000
using namespace std;
typedef long long ll;
int read(){
    int f = 1, x = 0;
    char c = getchar();
    while(c < '0' || c > '9'){if(c == '-') f = -f; c = getchar();}
    while(c >= '0' && c <= '9')x = x * 10 + c - '0', c = getchar();
    return f * x; 
}
int n, mat[205][205] = {0};
int col[205] = {0}, ans = 1;
bool vis[205];
bool dfs(int cur){
    for (int i = 1; i <= n; ++i)    {
        if (!mat[cur][i]) continue;
        if (col[i]){
            if (col[i] + col[cur] != 3) 
                return false;
        }else {
            col[i] = 3 - col[cur];
            if (!dfs(i))
                return false;
        }
    }
    return true;
}
void init(){
    n = read();
    for (int i = 1; i <= n; ++i)    
        for (int j = 1; j <= n; ++j)
            scanf("%1d", &mat[i][j]);
}
void solve(){
    col[1] = 1;
    if (!dfs(1)) {
        printf("-1\n");
        return ;
    }
    queue<pair<int, int> > q;
    for (int i = 1; i <= n; ++i){
        memset(vis, 0, sizeof(vis));
        vis[i] = true, q.push(make_pair(i, 1));
        while (!q.empty()){
            pair<int, int> p = q.front();
            q.pop();
            ans = max(ans, p.second);
            for (int j = 1; j <= n; ++j){
                if (!mat[p.first][j] || vis[j]) continue;
                vis[j] = true, q.push(make_pair(j, p.second + 1));
            }
        }
    }
        
    printf("%d\n", ans);
}
int main(){
    init();
    solve();
    return 0;
}

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

int main(){
   vector<int> a(3);
   cin >> a.at(0) >> a.at(1) >> a.at(2);
   sort(a.begin(), a.end());
   if(a.at(0) == 5 && a.at(1)== 5 && a.at(2) == 7) cout << "YES\n";
   else cout << "NO\n";
   return 0;
}

Measured memory_bytes: 3580
import itertools
s = input()
n = len(s)
keep = []
num = 0
ans = [0] * len(s)
gr = itertools.groupby(s)
for key, group in gr:
    keep.append([key, len(list(group))])
ans_num = 0
for i in range(len(keep)):
    if keep[i][0] == "R":
        if ans_num + keep[i][1] == n:
            ans[n - 1] += keep[i][1]
        else:
            ans[ans_num + keep[i][1] - 1] += (keep[i][1] - 1) // 2 + 1
            ans[ans_num + keep[i][1]] += keep[i][1] // 2

    else:
        if ans_num == 0:
            ans[0] += keep[i][1]
        else:
            ans[ans_num] += (keep[i][1] - 1) // 2 + 1
            ans[ans_num - 1] += keep[i][1] // 2
    ans_num += keep[i][1]

re_ans = str(ans[0])
for i in range(1, n):
    re_ans = re_ans + " " + str(ans[i])


print(re_ans)


Measured memory_bytes: 19144
#include <stdio.h>
           
int main(void){
           
    int a,b,c,i,n;
    n=0;
        scanf("%d %d %d",&a,&b,&c);
   
   
    for(i=a;i<=b;i++){
        if(c%i==0)n=n+1;
    }
    printf("%d\n",n);
    return 0;
    
}

Measured memory_bytes: 1024
n,m=map(int,input().split())
A=list(map(int,input().split()))
L=[0,2,5,5,4,5,6,3,7,6]
dp=[0]+[-1]*n
for i in range(n+1):
  for a in A:
    if i+L[a]<=n:
      dp[i+L[a]]=max(dp[i+L[a]],dp[i]*10+a)
print(dp[n])

Measured memory_bytes: 14692
#include <iostream>
#include <string>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <cctype>
#include <map>
#include <vector>

#define div 1000000000+7

typedef long long ll;

using namespace std;

void solve() {
   int a, b, c;
    cin >> a >> b;
    c = a + b;
    if(c >= 10){
        cout << "error" << endl;
    }else{
        cout << c << endl;
    }

}

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


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

bool is_strong_palindrome(const string& s)
{
  int n = s.size();
  for (int i = 0; i < n; i++) {
    if (s.at(i) != s.at(n-1-i)) {
      //cout << i << ',' << n-1-i << '\n';
      return false;
    }
  }
  for (int i = 0; i < (n-1)/2; i++) {
    if (s.at(i) != s.at((n-1)/2-1-i)) {
      //cout << i << ',' << (n-1)/2-1-i << '\n';
      return false;
    }
  }
  for (int i = (n+3)/2; i < n; i++) {
    if (s.at(i) != s.at(n-1-i)) {
      //cout << i << ',' << n-1-i << '\n';
      return false;
    }
  }
  return true;
}

int main()
{
  string s;
  cin >> s;
  if (is_strong_palindrome(s)) {
    cout << "Yes\n";
  } else {
    cout << "No\n";
  }
  return 0;
}


Measured memory_bytes: 256
import sys
from collections import deque
sys.setrecursionlimit(300000)

def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LMI(): return list(map(int, sys.stdin.readline().split()))
MOD = 10 ** 9 + 7
INF = float('inf')


N, M = MI()
adj = [list() for _ in range(N)]
for _ in range(M):
    a, b = MI()
    a, b, = a - 1, b - 1
    adj[a].append(b)
    adj[b].append(a)

q = deque()
q.append((0, -1))
seen = set()
seen.add(0)
ans = [0] * N
while len(q) > 0:
    v, p = q.popleft()
    ans[v] = p
    for nxt in adj[v]:
        if nxt not in seen:
            q.append((nxt, v))
            seen.add(nxt)
print('Yes')
for a in ans[1:]:
    print(a + 1)

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

#define PI 3.14159265359
#define rep(i,a,n) for(int i=a;i<(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define descsort(a) sort(a.begin(),a.end(),std::greater<int>())
using namespace std;
typedef long long ll;
const ll INF = 1e9 + 7;

int main(void)
{
    int l,r,d;
    cin>>l>>r>>d;
    int ans=0;
    for(int i=l;i<=r;i++){
        if(i%d==0)ans++;
    }
    cout<<ans<<endl;
    return 0;
}

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

int main(){
  
  int N; cin >> N;
  int count_lst[N]={0}; count_lst[0] = 1;
  
  int a_lst[N];
  for(int i=0; i<N; i++) cin >> a_lst[i];
  
  int num=1;
  int count=0;
  for(int i=0; i<N; i++){
    num = a_lst[num-1];
    count++;
    if(count_lst[num-1] == 1){
      count = -1;
      break;
    }else if(num==2) break;
    count_lst[num-1] = 1;
  }
  cout << count << endl;
  return 0;
}



Measured memory_bytes: 1024