akhauriyash/Code-Regression huggingface dataset:
n = int(input())
s_1 = list(input())
s_2 = list(input())
array_kind = []
i = 0
while i < n:
    if s_1[i] == s_2[i]:
        array_kind.append('X')
        i += 1
    else:
        array_kind.append('Y')
        i += 2
ans = 1
mod = 10**9+7
if array_kind[0] == 'X':
    ans = 3
else:
    ans = 6
for i in range(1,len(array_kind)):
    if array_kind[i] == 'X':
        if array_kind[i-1] == 'X':
            ans *= 2
        else:
            ans *= 1
    else:
        if array_kind[i-1] == 'X':
            ans *= 2
        else:
            ans *= 3
    ans %= mod
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using lli=long long int;




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

	int dp[m+1][n+1][2];//last [2] here 0 stores value and 1 will store from the valve came
	//1 if it came from diagonal 
	//2 if it came from row
	//3 if it came from column
	//when row and column are same and add 2
	//we may store the the cordinates from where it came by using pair in vector
	int i,j;
	
	for(i=0;i<=m;i++)
		dp[i][0][0]=0;

	for(i=0;i<=n;i++)
		dp[0][i][0]=0;	
	
	for(i=1;i<=m;i++)
	{
		for(j=1;j<=n;j++)
		{
			if(s[i-1]==t[j-1])
			{
				dp[i][j][0]=dp[i-1][j-1][0]+1;
				dp[i][j][1]=1;
			}
			else
			{
				dp[i][j][0]=max(dp[i-1][j][0] , dp[i][j-1][0]);
				if(dp[i-1][j][0] > dp[i][j-1][0])
					dp[i][j][1]=3;
				else
					dp[i][j][1]=2;
			}
		}
	}
	int len=dp[m][n][0];
	char ans[len+1];



	j=n;
    for(i=m;i>0;)
    {
    	for(;j>0;)
    	{
    		if(dp[i][j][1]==1)
    		{
    			ans[len--]=t[j-1];
    			i--;
    			j--;
    		}
    		else if(dp[i][j][1]==2)
    		{
    			j--;
    		}
    		else
    		{
    			i--;
    		}
    		if(i<=0)
    			break;//important note it
    	}
    	if(j<=0)
    		break;//important note it
    }
    
    len=dp[m][n][0];//we are assigning again as len as changed previously
    //so take care of these mistakes
    for(i=1;i<=len;i++)
    	cout<<ans[i];


	return 0;
}

Measured memory_bytes: 70656
h, n = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(n)]
max_a = max(a for a, _ in ab)
dp = [10 ** 18 for _ in range(h + max_a)]
dp[0] = 0
for i in range(1, h + max_a):
    dp[i] = min(dp[i-a]+b for a, b in ab)
print(min(dp[h:]))


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

int main()
{
  string s;
  cin >> s;
  vector<char> check(128);
  int i;
  int ch = 0;
  for(i = 0; i < s.size(); i++)
  {
    check.at(s.at(i))++;
  }
  for(i = 0; i < 128; i++)
  {
    if(check.at(i) >= 2)
    {
      ch = 1;
      break;
    }
  }
  if(ch == 1)
  {
    cout << "no" << endl;
  }
  else
  {
    cout << "yes" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0;i<(n);i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
 
 
int main() {
    int n;
    cin >> n;
    vector<int> ans(n);
    for(int i=1;i<=100;i++){
        for(int j=1;j<=100;j++){
            for(int k=1;k<=100;k++){
                ll num=i*i+k*k+j*j+i*j+j*k+k*i;
                if(num<=n) ans.at(num-1)++;
            }
        }
    } 
    rep(i,n) cout << ans.at(i) << endl;
}
   


Measured memory_bytes: 3632
#include <iostream>
using namespace std;
int main(){
	int N;
	while( cin >> N, N ){
		int i, j, sum;
		int ans = 0;
		for( i = (N+1)/2; i > 0; i-- ){
			sum = i;
			for( j = i - 1; j > 0; j-- ){
				sum += j;
				if( sum == N ){
					ans++;
					break;
				}
				if( sum > N ) break;
			}
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int MOD = 1e9+7;

int main(){
	int n;
	string s;
	cin >> n >> s;
	ll ans = 1;
	vector<ll> al(26,0);
	for(int i=0;i<n;i++) {
		al[s[i]-'a']++;
	}
	for(int i=0;i<26;i++) {
		ans *= (al[i]+1);
		ans %= MOD;
	}
	cout << ans-1 << endl;
}

Measured memory_bytes: 512
# include <bits/stdc++.h>
using namespace std; 
int main(){
  int x, j, temp, p,i,k,n; 
  cin>>x>>n; 
  temp=1000;
  p=1000;
  vector <int> vec; 
  for(i=0;i<n;i++){
    cin>>k;
    vec.push_back(k);
  }
  sort(vec.begin(),vec.end());
  if((find(vec.begin(),vec.end(),x))==vec.end()){
    cout<<x; 
  }
  else{
    j=x-1;
   while(j>=0){
     if((find(vec.begin(),vec.end(),j))==vec.end()){
       temp=j; 
       break; 
    }
    else{
      j--;
    }
   }
   j=x+1;
   while(true){
     if((find(vec.begin(),vec.end(),j))==vec.end()){
       p=j;
       break; 
    }
    else{
      j++;
    }
   }
   if((x-temp)>(p-x)){
     cout<<p; 
   }
   else{
     cout<<temp; 
   }
  }
  return 0;
}

Measured memory_bytes: 3600
import math, string, fractions, heapq, re, array, bisect, sys, random, time, copy
import itertools as it
import operator as op
import collections as cl
import functools as ft

def LI(): return list(map(int, input().split()))
def LI_(): return list(map(lambda x: int(x) - 1, input().split()))
def LF(): return list(map(float, input().split()))
def LS(): return input().split()
def I(): return int(input())
def F(): return float(input())
def S(): return input()


def factorize(n):
    fct = []  # prime factor
    b, e = 2, 0  # base, exponent
    while b * b <= n:
        while n % b == 0:
            n = n // b
            e = e + 1
        if e > 0:
            fct.append((b, e))
        b, e = b + 1, 0
    if n > 1:
        fct.append((n, 1))
    return fct


def divisorize(fct):
    b, e = fct.pop()  # base, exponent
    pre_div = divisorize(fct) if fct else [[]]
    suf_div = [[(b, k)] for k in range(e + 1)]
    return [pre + suf for pre in pre_div for suf in suf_div]


def count_divisor(fct):
    counts_plus1 = [count+1 for _, count in fct]
    total = ft.reduce(op.mul, counts_plus1)

    return total


if __name__ == '__main__':
    n = I()
    count_8 = 0
    for i in range(3, n+1, 2):
        fct = factorize(i)
        if count_divisor(fct) == 8:
            count_8 += 1

    print(count_8)


Measured memory_bytes: 6868
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//namespace mp = boost::multiprecision;

using namespace std;

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

double equal(double a, double b) {
    return fabs(a - b) < DBL_EPSILON;
}

std::istream &operator>>(std::istream &in, set<int> &o) {
    int 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(); }

//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
//const ll mod = 1e10;

typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;

int main() {
    ll d, t, s;
    cin >> d >> t >> s;

    if (t * s >= d) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

}


Measured memory_bytes: 3632
#include<stdio.h>
int main()
{
    int n,w,h,ans;
    int t;
    while(scanf("%d%d%d",&h,&w,&n)!=EOF)
    {
        if(h<w)
            t = w;
        else
            t = h;
        if(n%t==0)
        {
            ans = n/t;
        }
        else
        {
            ans = n/t+1;
        }
        printf("%d\n",ans);
    }
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define LL long long
using namespace std;
int D; LL ans,ten[19],a[19];
void dfs(int t,int up,LL s,LL D)
{
	int i;
	if(abs(D)>a[t]) return ;
	if(t>(up-1)/2){ ans+=s*(~up&1 ? 10 : 1); return ;}
	for(i=-9;i<=9;i++)
		dfs(t+1,up,s*(10-abs(i)-(t==0&&i>=0)),D-i*(ten[up-t]-ten[t]));
}
int main()
{
	int i,j;
	scanf("%d",&D),ten[0]=1;
	for(i=1;i<=18;i++)
		ten[i]=ten[i-1]*10;
	for(i=1;i<=18;i++){
		memset(a,0,sizeof(a));
		for(j=0;j<=(i-1)/2;j++)
			a[j]=9*(ten[i-j]-ten[j]);
		for(j=(i-1)/2;j>=0;j--)
			a[j]+=a[j+1];
		dfs(0,i,1,D);
	  }
	cout<<ans;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr long long INFL = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;


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

    int N;
    cin >> N;
    int s[N];
    int sum=0;
    rep(i,N) {
        cin >>s[i];
        sum+=s[i];
    }
    sort(s,s+N);
    int ans=0;
    if(sum%10!=0) cout << sum << endl;
    else{
        rep(i,N){
            if(s[i]%10!=0){
                ans=sum-s[i];
                break;
            }
        }
        cout << ans << endl;
    } 


}


Measured memory_bytes: 256
k, x = map(int,input().split(' '))
if x-k+1 <= -100000:
    for i in range(0,k):
        print(-100000+i,sep=' ',end=' ')
elif x+k-1 >= 100000:
    for i in range(0,k):
        print(100000-i,sep=' ',end=' ')
else:
    for i in range(k,1,-1):
        print(x-i+1,sep=' ',end=' ')
    for i in range(0,k):
        print(x+i,sep=' ',end=' ')


Measured memory_bytes: 3064
from scipy.ndimage import distance_transform_cdt
H,W = map(int,input().split())
S = list(list(input()) for h in range(H))
for h in range(H):
    for w in range(W):
        if S[h][w] == '#':
            S[h][w] = 0
        else:
            S[h][w] = 1
print(distance_transform_cdt(S, metric='taxicab').max())

Measured memory_bytes: 46788
#include<iostream>
#include<vector>
using namespace std;
int main(){
    long long N,W;
    cin >> N >> W;
    long long w[N];
    long long v[N];
    for(long long i=0;i<N;i++){
        cin >> w[i] >> v[i];
    }


    long long dp[N+1][W+1];
    for(long long i=0;i<N+1;i++){
        for(long long j=0;j<W+1;j++){
            dp[i][j] = 0;
        }
    }

    for(long long i= 0;i<N;i++){
        for(long long j=0;j<W+1;j++){
            if(j < w[i]){
                dp[i+1][j] = dp[i][j];
                //cout << dp[i+1][j] << endl;
            }else{
                dp[i+1][j] = max(dp[i][j], (dp[i][j - w[i]] + v[i]));
                //cout << dp[i+1][j] << endl;
            }
        }
    }

    cout << dp[N][W] << endl;
    

    return 0;
}

Measured memory_bytes: 79104
#include <iostream>
#include <string>
#include <vector>

using namespace std;

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

		string str;
		cin >> str;

		vector<int> ix;
		for (int i = 0; i < str.size(); ++i)
			if (str[i] == 'I')
				ix.push_back(i);

		vector<bool> ioi;
		for (int i = 1; i < ix.size(); ++i)
			if (ix[i] - ix[i-1] == 2)
				ioi.push_back(true);
			else
				ioi.push_back(false);

		int ans = 0, count = 0;

		for (int i = 0; i < ioi.size(); ++i)
			if (ioi[i]) {
				if (++count == n)
					--count, ++ans;
			}
			else count = 0;

		cout << ans << endl;
	}
}

Measured memory_bytes: 4120
import java.util.*;
public class Main{
    public static void main(String[] args){
	new Main().run();
    }
    Scanner sc = new Scanner(System.in);

    int n, s;
    int ans;

    void run(){
	while(sc.hasNext()){
	    n = sc.nextInt();
	    s = sc.nextInt();
	    if(n!=0){
		ans = 0;
		solve(0, 0, 0);
		System.out.println(ans);
	    }
	}
    }

    void solve(int level, int sum, int use){
	if(use==n){
	    if(sum==s) ans++;
	    return;
	}
	if(level>=10 || use>n || sum>s) return;

	solve(level+1, sum+level, use+1);
	solve(level+1, sum, use);
    }
}

Measured memory_bytes: 18056
def main():
    from builtins import int, map, list, print
    import sys
    sys.setrecursionlimit(10 ** 6)

    input = sys.stdin.readline
    input_list = (lambda: input().rstrip().split())
    input_number = (lambda: int(input()))
    input_number_list = (lambda: list(map(int, input_list())))

    S,W = input_number_list()
    print(['unsafe','safe'][S>W])

if __name__ == '__main__':
    main()


Measured memory_bytes: 9188
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define LLMAX (1ll << 60) - 1
#define INTMAX (1 << 30) - 1
#define MOD 1000000007 
#define NMAX 1000*100+1

#define numberOfSetBits(S) __builtin_popcount(S) // __builtin_popcountl(S) __builtin_popcountll(S)
#define MSET(x,y) memset(x,y,sizeof(x))
#define gcd(a,b) __gcd(a,b)
#define all(x)  x.begin(),x.end()
#define isOn(S, j) (S & (1 << j))
#define endl '\n'
#define setBit(S, j) (S |= (1 << j))
#define clearBit(S, j) (S &= ~(1 << j))
#define toggleBit(S, j) (S ^= (1 << j))
#define print(x)    for(auto it:x) cout<<it<<' '; cout<<endl;
#define printii(x)  for(auto it:x) cout<<it.F<<' '<<it.S<<'\t';  cout<<endl;
#define in(x,n)   for(int e=0;e<n;e++){ll y;cin>>y;x.pb(y);}

#define vi vector<ll>
#define vvi vector<vi>
#define ii pair<ll,ll>
#define pll pair<ll,ll>
#define vii vector<ii>
#define vvii vector<vii>
#define viii vector<pair<ii,ll>>
#define pb push_back
#define F first
#define S second
#define mp make_pair
#define mc(a,b,c) mp(mp(a,b),c)
const int nmax = 2e5+3;
vvi adj(nmax);
vector<bool> visited(nmax);
ll lef,rig;

void dfs(int v){
    visited[v] = true;
    v<=1e5?lef++:rig++;
    for(auto it: adj[v]){
        if(!visited[it]){
            dfs(it);
        }
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,x,t,m,y,z;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>x>>y;
        y+=1e5;
        adj[x].pb(y);
        adj[y].pb(x);
    }
    z = 0;
    for(int i=1;i<1e5;i++){
        lef = 0;rig=0;
        if(!visited[i]){
            dfs(i);
        }
        z+=lef*rig;
    }
    cout<<z-n;
    



    return 0;
}

Measured memory_bytes: 9984
#include <iostream>
using namespace std;
int data[105];
int main()
{
	int n;
	cin >> n;
	for(int i = 1; i <= n; ++i)
		cin >> data[i];
	cout << data[1];
	for(int j = 2; j <= n; ++j)
		cout << ' ' << data[j];
	cout << endl;
	for(int i = 2; i <= n; ++i)
	{
		int v = data[i];
		int j = i-1;
		while((j > 0) && (data[j] > v))
		{
			data[j+1] = data[j];
			--j;
		}
		data[j+1] = v;
		cout << data[1];
		for(int j = 2; j <= n; ++j)
			cout << ' ' << data[j];
		cout << endl;
	}
	return 0;
}


Measured memory_bytes: 3084
numbers =input().rstrip().split(" ")
nop =int(numbers[0])
point =int(numbers[1])
nos =int(numbers[2])
seikais=[]
points=[]
for i in range(nos):
  seikais.append(int(input()))
#print(seikais)
base =point-nos
for i in range(nop):
  points.append(base)
#print(points)
for i in range(nos):
  points[seikais[i]-1]=points[seikais[i]-1]+1
#print(points)
for i in range(nop):
  if points[i]<=0:
    print("No")
  else:
    print("Yes")



Measured memory_bytes: 10452
#include<bits/stdc++.h>
using namespace std;
const int ZDN=1e2+8;
long long sz[ZDN]={};
int main(){
	long long n;
	cin>>n;
	
	long long i,j,k;
	long long ans=0;
	for (i=1; i<=n; i++){
		cin>>sz[i];
	}
	for (i=1; i<=n; i++){
		for (j=i+1; j<=n; j++){
			for (k=j+1; k<=n; k++){
				if (i!=j && j!=k && i!=k 
				&& sz[i]!=sz[j] && sz[j]!=sz[k] && sz[i]!=sz[k]
				&& sz[i]+sz[j]>sz[k] && sz[j]+sz[k]>sz[i] 
				&& sz[i]+sz[k]>sz[j]){
					ans++;
				}
			}
		}
	}
	cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 3636
# AtCoder DP Task F - LCS
def backtrack(C, A, B, i, j):
    out = ""
    while i != 0 and j != 0:
        if A[i - 1] == B[j - 1]:
            out = A[i - 1] + out
            i -= 1
            j -= 1
        elif C[i][j - 1] > C[i - 1][j]:
            j -= 1
        else:
            i -= 1
    return out

def lcs(A, B):
    a, b = len(A), len(B)
    C = [ [0] * (b + 1) for _ in range(a + 1) ]
    for i in range(1, a + 1):
        for j in range(1, b + 1):
            if A[i - 1] == B[j - 1]:
                C[i][j] = C[i-1][j-1] + 1
            else:
                C[i][j] = max(C[i][j - 1], C[i - 1][j])
#    return C[a][b]
    ret = backtrack(C, A, B, a, b)
    return ret

assert lcs("XMJYAUZ", "MZJAWXU") == "MJAU"
assert lcs("MZJAWXU", "XMJYAUZ") == "MJAU"
assert lcs("AGCAT", "GAC") == "AC"
assert lcs("AAAA", "AAAA") == "AAAA"
assert lcs("a", "z") == ""

if False:
    import random
    for _ in range(1000):
        q = [chr(random.randint(ord('a'), ord('z'))) for _ in range(random.randint(1, 1000))]
        p = [chr(random.randint(ord('a'), ord('z'))) for _ in range(random.randint(1, 1000))]
        lcs("".join(q), "".join(p))

x = input().strip()
y = input().strip()
ans = lcs(x, y)
print(ans)


Measured memory_bytes: 111452
#include "bits/stdc++.h"
using namespace std;
int main() {
	long long N, K; cin >> N >> K;
	vector<long long>A(N);
	for (long long i = 0; i < N; i++) {
		cin >> A.at(i);
	}
	sort(A.begin(), A.end());
	long long ans = 0;
	for (long long i = 0; i < K; i++) {
		ans += A.at(i);
	}
	cout << ans << endl;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define INF         9223372036854775807
#define    endl        '\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)    for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define lower(u)    transform(u.begin(), u.end(), u.begin(), ::tolower);//convert string u to lowercase;
#define upper(u)    transform(u.begin(), u.end(), u.begin(), ::toupper);
using namespace std;

#define N  100005

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int TESTS=1;
//    cin>>TESTS;
    while(TESTS--)
    {
        string s;
        cin>>s;
        ll n=s.size();
        if(n%2==1)
        {
            cout<<"No";
            exit(0);
        }
        bool f=1;
        rep(i,0,n)
        {
            if(i%2==0)
            {if(s[i]!='h')f=0;}

            if(i%2==1)
            {
                if(s[i]!='i')
                    f=0;
            }
        }
        if(f)
        {
            cout<<"Yes";
        }
        else
        {
            cout<<"No";
        }
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int idx = 0;
		int number = 11;
		StringBuilder sb = new StringBuilder();
		while (idx < n) {
		    if (isPrime(number)) {
		        if (idx != 0) {
		            sb.append(" ");
		        }
		        sb.append(number);
		        idx++;
		    }
		    number += 10;
		}
	    System.out.println(sb);
   }
   
   static boolean isPrime(int x) {
       for (int i = 2; i <= Math.sqrt(x); i++) {
           if (x % i == 0) {
               return false;
           }
       }
       return true;
   }
}




Measured memory_bytes: 21844
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <utility>
#include <vector>

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

typedef long long ll;
using namespace std;

int main() {
  ll N;
  cin >> N;
  map<int, int> mp;

  if (N % 2 == 0) {
    for (int i = 1; i < N; i += 2) {
      mp[i] = 0;
    }
  } else {
    for (int i = 0; i < N; i += 2) {
      mp[i] = 0;
    }
  }

  bool invalid = false;
  REP(i, N) {
    ll t;
    cin >> t;
    auto itr = mp.find(t);
    if (itr == mp.end()) {
      invalid = true;
    } else {
      mp[t] += 1;
    }
  }

  if (invalid) {
    cout << 0 << endl;
    // cout << "debug x" << endl;
    return 0;
  }

  for (auto itr = mp.begin(); itr != mp.end(); ++itr) {
    int key = itr->first;
    int cnt = itr->second;
    if (N % 2 == 1 && key == 0) {
      if (cnt == 1) {
        continue;
      } else {
        invalid = true;
      }
    } else {
      if (cnt != 2) {
        invalid = true;
      }
    }
  }

  if (invalid) {
    cout << 0 << endl;
    // cout << "debug y" << endl;
    return 0;
  }

  ll ans = 1;
  for (ll i = 0; i < N / 2; i++) {
    ans *= 2;
    ans %= 1000000007;
  }
  cout << ans << endl;

  return 0;
}


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


long long int jump(int n,int h[],int start,int end,long long int y[],int k)
{

    if(y[n]!=-1)
    {
    	return y[n];
    }
	if(end==start)
	{
		return 0;
	}
	int d = end - start;
	int e = abs(h[start+1]-h[start]);
	y[n] = e + jump(n-1,h,start+1,end,y,k);
	for(int r=2;r<=min(d,k);r++)
	{
		int q =abs(h[start+r]-h[start]);
		y[n] = min(y[n],q + jump(n-r,h,start+r,end,y,k));
	}
	
	return y[n];
}

int main()
{
      // #ifndef ONLINE_JUDGE
      // freopen("input.txt","r",stdin);
      // freopen("output.txt","w",stdout);
      // #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;int k;
    cin>>n>>k;int g=n;
    int h[n];
    long long int y[1000001];
    memset(y, -1, sizeof(y));
    for(int i=0;i<n;i++)
    {
    	cin>>h[i];
    }   
    int f = jump(n,h,0,g-1,y,k);
    cout<<f;

    // #ifndef ONLINE_JUDGE
    //     cout<<"\nTime Elapsed : "<< 1.0*clock() / CLOCKS_PER_SEC << " s\n";
    // #endif
    
    return 0;
}

Measured memory_bytes: 17792
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using ld = long double;
long double const pi = std::acos(-1.0L);
typedef pair<int,int> P;

int main() {
  string s,t; cin >> s >> t;
  int minv = t.size();
  rep(i,s.size()-t.size()+1){
    int cnt = 0;
    rep(j,t.size()){
      if(s[i+j]!=t[j]) cnt++;
    }
    minv = min(minv,cnt);
  }
  cout << minv << endl;

  return 0;
}

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

if h == 1 or w == 1:
    print(1)
    exit()

if h % 2 == 0:
    print(h // 2 * w)
else:
    if w % 2 == 0:
        ans = (h // 2 + 1) * (w//2) + (h//2) * (w//2)
    else:
        ans = (h // 2 + 1) * (w // 2 + 1) + (h // 2) * (w // 2)
    print(ans)



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

int main() {
  int N;
  cin >> N;
  string s;
  int p;
  vector<tuple<int, string, int>> sp(N);
  for (int i = 0; i < N; ++i) {
    cin >> s >> p;
    sp[i] = make_tuple(i + 1, s, p);
  }
  sort(sp.begin(), sp.end(), [](auto l, auto r) {
    return (get<1>(l) < get<1>(r)) ||
           ((get<1>(l) == get<1>(r)) && (get<2>(l) > get<2>(r)));
  });
  for (int i = 0; i < N; ++i) {
    cout << get<0>(sp[i]) << endl;
  }
  return 0;
}


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

int main(){
    string S;
    int ans=0;
    cin >> S;
    int length = S.length();
    rep(i,length/2){
        if(S[i]!=S[length-i-1]){
            ans += 1;
        }
    }
    cout << ans << endl ;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int A[5]; string s;
	cin >> s;
	for(int i = 0; i < 4; i ++) {
		A[i + 1] = s[i] - '0';
	} int a = A[1], b = A[2], c = A[3], d = A[4];
	if(a + b + c + d == 7) {printf("%d+%d+%d+%d=7\n",a,b,c,d);return 0;}
	if(a + b - c + d == 7) {printf("%d+%d-%d+%d=7\n",a,b,c,d);return 0;}
	if(a + b + c - d == 7) {printf("%d+%d+%d-%d=7\n",a,b,c,d);return 0;}
	if(a + b - c - d == 7) {printf("%d+%d-%d-%d=7\n",a,b,c,d);return 0;}
	if(a - b - c + d == 7) {printf("%d-%d-%d+%d=7\n",a,b,c,d);return 0;}
	if(a - b + c - d == 7) {printf("%d-%d+%d-%d=7\n",a,b,c,d);return 0;}
	if(a - b - c - d == 7) {printf("%d-%d-%d-%d=7\n",a,b,c,d);return 0;}
	if(a - b + c + d == 7) {printf("%d-%d+%d+%d=7\n",a,b,c,d);return 0;}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int M = 1e2 + 5;
int n, k, cnt[M];
 
int32_t main() 
{
	ios_base::sync_with_stdio(0);	cin.tie(0);	cout.tie(0);
	cin >> n >> k;
	for(int i = 0; i < k; i++)
	{
		int d;		cin >> d;
		while(d--)
		{
			int sn;		cin >> sn;
			cnt[sn]++;
		}
	}
	int ans = 0;
	for(int i = 1; i <= n; i++)
		ans += (cnt[i] == 0);
	cout << ans;
    	return 0;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
        using namespace std;
         
        int main(){
           int n;
          cin>>n;
          vector<int> v(n);
          for(int i=0;i<n;i++) cin>>v[i];
          int ans=0,count=0;
          for(int i=0;i<n-1;i++){
            if(v[i+1]<=v[i]) count++;
            else ans=max(ans,count),count=0;
          }
          ans=max(ans,count);
          cout<<ans;
        }

Measured memory_bytes: 640
#include<cstdio>
#include<cstring>
#include<algorithm>
#define rep(i,l,r) for (int i=l; i<=r; i++)
typedef long long ll;
using namespace std;

const int N=200010;
ll n,ans,a[N];
ll Abs(ll x){ return (x<0) ? -x : x; }

int main(){
	scanf("%lld",&n);
	rep(i,1,n) scanf("%lld",&a[i]),a[i]=a[i]-i;
	sort(a+1,a+n+1); ll b=a[(n+1)>>1];
	rep(i,1,n) ans+=Abs(a[i]-b);
	printf("%lld\n",ans);
	return 0;
}

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

using namespace std;

struct work{
	int64_t a;
	int64_t b;
};

struct work works[200000];

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

	for(int i = 0; i < n; ++i){
		cin >> works[i].a >> works[i].b;
	}

	sort(works, works+n, [](const work& x, const work& y){	return x.b < y.b;	});

	int64_t current_t = 0;
	bool flag = false;

	for(int i = 0; i < n; ++i){
		current_t += works[i].a;
		if(current_t > works[i].b){
			flag = true;
			break;
		}
	}

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

	return 0;
}

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

using namespace std;

#define all(x) (x).begin(), (x).end()

typedef long long ll;

const int N = 300100;

void solve() {
  int n, m; cin >> n >> m;
  vector<int> nvt(m);
  int sum = 0;
  for (int i = 0; i < m; i++) {
    cin >> nvt[i];
    sum += nvt[i] / 2;
  }
  if (sum + n / 2 < n - 1) {
    cout << "Impossible"; return;
  }
  vector<int> odd, even;
  for (int i = 0; i < m; i++) {
    if (nvt[i] % 2 == 0) even.push_back(nvt[i]);
    else odd.push_back(nvt[i]);
  }
  if (n % 2 == 0) {
    // two odd or zero odd
    vector<int> vt;
    if (odd.size() == 2) {
      vt.push_back(odd[0]);
      for (auto x : even) vt.push_back(x);
      vt.push_back(odd[1]);
    }
    else {
      for (auto x : even) vt.push_back(x);
    }
    for (auto x : vt) cout << x << " "; cout << "\n";
    vt[0]--;
    if (m > 1) vt[m - 1]++;
    else vt.push_back(1);
    if (vt[0] == 0) vt.erase(vt.begin());
    cout << vt.size() << "\n";
    for (auto x : vt) cout << x << " "; cout << "\n";
  }
  else {
    // one odd only
    vector<int> vt;
    vt.push_back(odd[0]);
    for (auto x : even) vt.push_back(x);
    for (auto x : vt) cout << x << " "; cout << "\n";
    vt[0]--;
    if (vt[0] == 0) vt.erase(vt.begin());
    vt.push_back(1);
    cout << vt.size() << "\n";
    for (auto x : vt) cout << x << " "; cout << "\n";
  }
}

// CHECK LIMITS (n <= 10^5)
// CHECK CORNER CASES (n == 1)

int main() {
  ios::sync_with_stdio(NULL), cin.tie(0), cout.tie(0);
  cout.setf(ios::fixed), cout.precision(20);
  //cout << 1.0 * clock() / CLOCKS_PER_SEC << endl;
  solve();
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
 
const int MOD = 1000000007;
const int N = 100005;
const int M = 1000005;
 
#define ll                      long long int
#define loop(i,a,b)             for(int i=(int)a;i<(int)b;++i)
#define rloop(i,a,b)            for(int i=(int)a;i<=(int)b;++i)
#define loopl(i,a,b)            for(ll i=(ll)a;i<(ll)b;++i)
#define loopr(i,a,b)            for(int i=(int)a;i>=(int)b;--i)
#define pb                      push_back
#define F                       first
#define S                       second
#define mp                      make_pair
#define RALL(x)                 x.rbegin(),x.rend()
#define ALL(x)                     x.begin(),x.end()
#define MAX                     1e9
#define MIN                     -1e9
// #define max(x,y)                (x>y)?x:y
// #define min(x,y)                (x<y)?x:y
#define mid(l,r)                (l+(r-l)>>1)
#define mina(a)                    *min_element(a.begin(), a.end())
#define maxa(a)                    *max_element(a.begin(), a.end())
#define PI                      acos(-1.0)

typedef  map<string,int>         msi;
typedef  map<int,int>             mii;
typedef  map<ll, ll>             mll;
typedef  map<char,int>           mci;
typedef  map<int,string>         mis;
typedef  pair<int,int>              pii;
typedef  pair<string, int>       psi;
typedef  pair<string, string>    pss;
typedef  vector<int>              vi;
typedef  vector<string>          vs;
typedef  vector<char>             vc;
typedef  vector<bool>            vb;
typedef  vector< pii >           vii;

int main() {
    std::ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);

    string s,t;
    cin>>s>>t;

    int m = s.size(), n = t.size();

    int dp[m+1][n+1];
    rloop(i,0,m)
    {
       rloop(j,0,n)
       {
            if(i==0||j==0)
                dp[i][j]=0;
            else if(s[i-1]==t[j-1])
                dp[i][j]=1+dp[i-1][j-1];
            else dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
       } 
    }

    int id = dp[m][n];
    // cout<<"len is "<<id<<endl;
    char res[id+1];
    res[id]='\0';
    int i = m, j=n;
    while(i>0&&j>0)
    {
        if(s[i-1]==t[j-1])
        {
            res[id-1]=s[i-1];
            id--;i--;j--;
        }
        else if(dp[i-1][j]>dp[i][j-1]) i--;
        else j--;
    }

    loop(x,0,dp[m][n])
        cout<<res[x];
    cout<<endl;


    return 0;
}

Measured memory_bytes: 35456
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <numeric>
#include <regex>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
#define modulo 1000000007 // 10^9 + 7
#define INF 1000000000 // 10^9
#define LLINF 1LL<<60

// ナップサック

ll N, W;
ll w[101], v[101];
ll dp[101][100001]; // dp[i][j] : i番目までの商品で価値j持って帰る際の最小の重さ

void input() {
	cin >> N >> W;
	for (int i = 1; i <= N; i++) cin >> w[i] >> v[i];
	for (int j = 0; j <= 100000; j++) dp[0][j] = LLINF;
}

void solve() {
	dp[0][0] = 0;
	for (int i = 1; i <= N; i++) {
		for (int j = 0; j <= 100000; j++) {
			if (j >= v[i]) dp[i][j] = min(dp[i - 1][j], dp[i - 1][j - v[i]] + w[i]);
			else dp[i][j] = dp[i - 1][j];
		}
	}

	int ans = 0;
	for (int j = 0; j <= 100000; j++) {
		if (dp[N][j] <= W) {
			// 持って帰れる
			ans = j;
		}
	}
	cout << ans << endl;
}

int main() {
	input();
	solve();

	return 0;
}

Measured memory_bytes: 79104
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using boost::multiprecision::cpp_int;
using namespace std;

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MOD 1000000007

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; }

typedef long long ll;
typedef pair<ll, ll> p;


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;
  cin >> s;
  ll res = 0;
  bool flag = false;
  for (int i = int(s.size())-1; i >= 0; i--) {
    int num = s[i] - '0';
    if(flag) num++;
    flag = false;
    if(num >= 6 || (num == 5 && i >= 1 && s[i-1] - '0' >= 5)) {
      res += 10-num;
      flag = true;
    }else{
      res += num;
    }
    // cout << res << endl;
  }

  if(flag) res++;
  cout << res << endl;
}


Measured memory_bytes: 1948
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll read(){
	ll a=0,b=getchar(),c=1;
	while(!isdigit(b))c=b=='-'?-1:1,b=getchar();
	while(isdigit(b))a=a*10+b-'0',b=getchar();
	return a*c;
}
int a,b,c,d;
int main(){
	a=read(),b=read(),c=read(),d=read();
	int e=(a+d-1)/d,f=(c+b-1)/b;
	if(e<f)puts("No");
	else puts("Yes");
	return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define mp make_pair
#define v vector
#define inp_push(no, v) \
    ll no;              \
    cin >> no;          \
    v.push_back(no);
#define pb push_back
#define fi first
#define se second
#define ALL(v) v.begin(), v.end()
#define UN(v) sort((v).begin(), (v).end()), v.erase(unique(v.begin(), v.end()), v.end())
#define N 200005
#define mod 1000000009
#define INF INT64_MAX

//////////////////////////IMPORTANT FUNCTIONS/////////////////////////////////////////////

/* Guidlines berfore submitting solution
1. Check N value before submitting
2. Check all constant kind of values you are using. Might give WA. Think
3. Check mod value
*/

v<ll> fact(N);
v<ll> prime_check(1e7 + 2);
v<ll> primes;

long long powmod(long long x, long long y, long long m)
{
    long long res = 1LL;
    while (y)
    {
        if (y & 1)
            res = (res * x) % m;
        x = (x * x) % m;
        y /= 2;
    }
    return res;
}

void init_fact()
{
    fact[0] = 1;
    for (ll i = 1; i < N; i++)
    {
        fact[i] = (fact[i - 1] * i) % mod;
    }
}

ll C(ll n, ll r)
{
    if (n < r)
        return 0;
    ll temp = fact[n] * powmod(fact[r], mod - 2, mod) % mod;
    temp *= powmod(fact[n - r], mod - 2, mod);
    temp %= mod;
    return temp;
}

void Sieve()
{
    for (ll i = 2; i <= 1e7 + 1; i++)
    {
        if (prime_check[i])
            continue;
        primes.pb(i);
        for (ll j = 2 * i; j <= 1e7 + 1; j += i)
            prime_check[j] = i;
    }
}
ll phi(ll n)
{
    ll i, res = n;
    for (i = 2; i * i <= n; i++)
        if (n % i == 0)
        {
            while (n % i == 0)
                n /= i;
            res -= res / i;
        }
    if (n > 1)
        res -= res / n;
    return res;
}

/////////////////////////////////////START CODE HERE/////////////////////////////////////////////

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    // init_fact();
    // Sieve();
    char a;
    cin >> a;
    if (a >= 'A' && a <= 'Z')
        cout << "A\n";
    else
        cout << "a\n";
}

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

#define check cnt=0;for(j=0;j<6;j++)if(d1[j]==d2[j])cnt++;
#define r tmp=d2[1];d2[1]=d2[3];d2[3]=d2[4];d2[4]=d2[2];d2[2]=tmp;
#define y tmp=d2[0];d2[0]=d2[3];d2[3]=d2[5];d2[5]=d2[2];d2[2]=tmp;

int main(){
 int d1[6],d2[6],tmp,cnt,j,a=1,i,k;

 for(int i=0;i<6;i++){
  cin >> d1[i] ;
 }
 for(int i=0;i<6;i++){
  cin >> d2[i] ;
 }

 check
   if(cnt==6)a=0;

 while(a){
  for(i=0;i<5;i++){
   for(k=0;k<4;k++){
    check
    if(cnt==6)break;
    r
   }
   check
   if(cnt==6)break;
   tmp=d2[0];
   d2[0]=d2[1];
   d2[1]=d2[5];
   d2[5]=d2[4];
   d2[4]=tmp;
  }
  if(cnt==6)break;
  y
  for(k=0;k<4;k++){
   check
   if(cnt==6)break;
   r
  }
  if(cnt==6)break;
  y
  y
  for(k=0;k<4;k++){
   check
   if(cnt==6)break;
   r
  }
  if(cnt==6)break;
  a=0;
 }

 if(cnt==6)cout << "Yes" << endl ;
 else cout << "No" << endl ;

 return 0;
}

Measured memory_bytes: 3084
n,m = map(int,input().split())
l = [0] * (m+1)
c = 0
for i in range(1,n+1):
  a = list(map(int,input().split()))
  for k in range(a[0]):
    l[a[k+1]] += 1
for i in range(m+1):
  if l[i] == n:
    c += 1
print(c)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
#define pb push_back
#define mp make_pair
#define PI 3.14159265358979323846
#define fi first
#define se second

ll mod = 1e9+7;
		
ll max(ll a, ll b ) {
	if(a>b)
		return a;
	else return b;
}
ll min(ll a, ll b ) {
	if(a<b)
		return a;
	else return b;
}

int main() {
	ll tttt; 
	//cin>>tttt;
	tttt = 1;
    while(tttt--) { 
		int x; cin>>x;
		if(x==0) cout<<1;
		else cout<<0;	
    } 
    return 0; 
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define rb(x) ((x)&(-(x)))
#define upmin(a,b) (a)=min((a),(b))
#define upmax(a,b) (a)=max((a),(b))
#define INF (0x3f3f3f3f)
#define INFLL (0x3f3f3f3f3f3f3f3fll)
using namespace std;
typedef long long ll;
const int MAXN = 100005;
const int MX = 131072;
struct SEG {
   	SEG() { init(); }
   	ll d[MX*2];
   	void init() { fill(d, d+MX*2, INFLL); }
   	void upd(int x, ll r) {
   		x += MX; d[x] = r;
   		for(x /= 2; x; x /= 2)
   			d[x] = min(d[x*2], d[x*2+1]);
   	}
   	ll get(int s, int e) {
   		ll r = INFLL; for(s += MX, e += MX; s <= e; s /= 2, e /= 2) {
   			if(s&1) upmin(r, d[s++]); if(~e&1) upmin(r, d[e--]);
   		} return r;
   	}
}seg1, seg2;
ll dp[MAXN];
int A[MAXN];
int N, T, E;
int main() {
  	scanf("%d%d%d", &N, &E, &T);
   	for(int i = 1; i <= N; i++) scanf("%d", &A[i]);
   	seg1.upd(0, 0);
   	seg2.upd(0, -2 * ll(A[1]));
   	for(int i = 1; i <= N; i++) {
   		ll &ret = dp[i];
   		ret = INFLL;
   		int li = max(0, (int)(lower_bound(A, A+i, A[i] - T/2) - A) - 1);
   		if(li < i)
   			upmin(ret, seg1.get(li, i-1) + A[i] + T);
   		if(0 < li)
  			upmin(ret, seg2.get(0, li-1) + ll(A[i])*3);
   		seg1.upd(i, ret - A[i]);
   		seg2.upd(i, ret - A[i] - ll(A[i+1])*2);
   	}
   	printf("%lld\n", dp[N] + E - A[N]);
  	return 0;
}

Measured memory_bytes: 5504
/* ex 9_1
   cy_an  */

#include <stdio.h>
#include <stdlib.h>
//スタックに格納するデータの最大数
#define SIZE 10

//スタックの定義
typedef struct stack{
    int size;
    int count;
    char data[SIZE];
    char *top;
} stack;

//スタックの初期化
void initialize_stack(stack *stk){
    stk->count = 0;
    stk->size = SIZE;
    stk->top = &(stk->data[SIZE]);
}

//データの追加
void push(stack *stk, char elem){
    if(stk->count >= stk->size){
        fprintf(stderr, "Error: stack overflow. (x=%c)\n", elem);
        exit(1);
    }
    else{
        stk->top--;
        *(stk->top) = elem;
        stk->count++;
    }
}

//データの取り出し
char pop(stack *stk){
    char latest;
    if(stk->count <= 0){
        fprintf(stdout, "Error: stack underflow.\n");
        exit(1);
    }
    else{
        latest = *(stk->top);
        stk->top++;
        stk->count--;
        return latest;
    }
}

int main(void){
    stack input, output;
    char arr[SIZE+1];
    int i=0;
    
    //スタックを初期化
    initialize_stack(&input);
    initialize_stack(&output);

    //スタックにデータを追加
    scanf("%s", arr);
    while(arr[i] != '\0'){
        if(arr[i] == 'B'){
            if(input.count > 0){
                pop(&input);
            }
        }else{
            push(&input, arr[i]);
        }
        i++;
    }
    // スタックから別のスタックへ移して並べ替え
    while(input.count > 0){
        push(&output, pop(&input));
    }
    // スタックから要素を取り出して出力
    while(output.count > 0){
        printf("%c", pop(&output));
    }
    return 0;
}

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

using namespace std;

#define INF 1000000007
#define LINF (1LL << 60)
#define PI 3.14159265358979

typedef long long i64;
typedef pair<i64,i64> P;

inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }

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



int n, a[20202];
int x[20202], y[20202];
void solve(){
	cin >> n;
	for(int i = 1; i <= n; i++){
		cin >> a[i];
	}
	
	for(int i = 1; i <= n; i++){
		x[i] = i*20202;
		y[i] = (n-i)*20202;
	}
	
	for(int i = 1; i <= n; i++){
		y[a[i]] += i;
	}
	
	for(int i = 1; i <= n; i++){
		cout << x[i];
		if(i != n) cout << " ";
	}
	cout << endl;
	for(int i = 1; i <= n; i++){
		cout << y[i];
		if(i != n) cout << " ";
	}
	cout << endl;
}

int main(){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();
	}
	
	return 0;
}


Measured memory_bytes: 896
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;
static const int MAX = 200000;

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

	a = a * b;
	c = c * d;

	a > c ? cout << a << endl : cout << c << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<map>
#include<numeric>
#include<set>
#include<sstream>
#include<string>
#include<utility>
#include<vector>

#define rep(i, a, n)  for(int i=a; i<n; i++)
#define per(i, a, n)  for(int i=n-1; i>=a; i--)
#define fill0(n)  setfill('0') << right << setw(n)
#define all(x)  (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define MAX 1000000000+7
using namespace std;
typedef long long ll;

struct UnionFind{
  vector<int> par;

  UnionFind(int N) : par(N){
    for(int i=0; i<N; i++)  par[i] = i;
  }

  int root(int x){
    if(par[x] == x) return x;
    return par[x] = root(par[x]);
  }

  void unite(int x, int y){
    int rx = root(x);
    int ry = root(y);
    if(rx == ry)  return;
    par[rx] = ry;
  }

  bool same(int x, int y){
    int rx = root(x);
    int ry = root(y);
    return rx == ry;
  }
};

int main(){
  int N, M; cin >> N >> M;
  vector<int> p(N);
  UnionFind tree(N);
  rep(i, 0, N)  {
    cin >> p[i];
    p[i]--;
  }
  for(int i=0; i<M; i++){
    int x, y;  cin >> x >> y;
    x--;  y--;
    tree.unite(x, y);
  }
  int ans = 0;
  for(int i=0; i<N; i++){
    if(tree.same(p[i], tree.root(i))){
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
int main() {
    int n;
    string s;
    cin >> n >> s;
    int ans = 0;
    for(int i = 0; i <= n - 3; i++) {
            if(s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C') ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int n;
  while(cin>>n){
    if(n==0) break;
    int nae[n+1];
    for(int i=0;i<n+1;i++) cin >> nae[i];
    int ks;
    if(nae[0]+(nae[1]-nae[0])*(n-1)==nae[n]){
      ks = nae[1] - nae[0];
      for(int i=1;i<n;i++){
	if(nae[i+1]-nae[i]!=ks){
	  cout << nae[i+1] << endl;
	  break;
	}
      }
    }
    else{
      ks = nae[3] - nae[2];
      if(nae[n]-nae[n-1]!=ks) cout << nae[n] << endl;
      else if(nae[2]-nae[1]!=ks) cout << nae[1] << endl;
      else cout << nae[0] << endl;
    }
    //cout << nae[0]+(nae[1]-nae[0])*n-1 << endl;
    //cout << nae[n] << endl;
  }
  return 0;
} 

Measured memory_bytes: 1164
#include<map>
#include<cstdio>
using namespace std;
map <int,bool> vis;
int main(){
	int st,ed,k;
	scanf("%d %d %d",&st,&ed,&k);
	for(int i=st;i<=min(st+k-1,ed);i++){
		printf("%d\n",i);
		vis[i]=1;
	}
	for(int i=max(st,ed-k+1);i<=ed;i++)
		if(!vis[i])
			printf("%d\n",i);
	return 0;
}

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

using namespace std;

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

//===


const int INF = int(1e9 + 7);


int main() {

	cin.tie(0);
	ios::sync_with_stdio(false);

	int N, M;
	cin >> N >> M;
	vector<Vi> to(N);
	for (int i = 0; i < M; ++i) {
		int u, v;
		cin >> u >> v;
		--u, --v;
		to[u].push_back(v);
	}
	int S, T;
	cin >> S >> T;
	--S; --T;

	auto pdist = make_shared<array<array<int, 3>, 100005>>();
	auto& dist = *pdist;
	for (int i = 0; i < N; ++i) {
		for (int j = 0; j < 3; ++j) {
			dist[i][j] = INF;
		}
	}

	queue<Pii> q;
	q.emplace(S, 0);
	dist[S][0] = 0;
	while (!q.empty()) {
		int v = q.front().first;
		int l = q.front().second;
		q.pop();
		for (const auto& u : to[v]) {
			int nl = (l + 1) % 3;
			if (dist[u][nl] != INF) continue;
			dist[u][nl] = dist[v][l] + 1;
			q.emplace(u, nl);
		}
	}

	int ans = dist[T][0];
	if (ans == INF) ans = -1;
	else ans /= 3;
	cout << ans << endl;
}


Measured memory_bytes: 6912
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
typedef long long ll;
using namespace std;
int main(void){
 int h,w;
 cin>>h>>w;
 vector<vector<char>>a(h,vector<char>(w));
 for(int i=0;i<h;i++){
     for(int j=0;j<w;j++){
         cin>>a[i][j];
     }
 }
 bool col[101]={false};
 bool row[101]={false};
 for(int i=0;i<h;i++){
     for(int j=0;j<w;j++){
         if(a[i][j]=='#'){
             row[i]=true;
             break;
         }
     }
 }
 for(int j=0;j<w;j++){
     for(int i=0;i<h;i++){
         if(a[i][j]=='#'){
             col[j]=true;
             break;
         }
     }
 }

 bool exe=false;
 for(int i=0;i<h;i++){
     exe=false;
     for(int j=0;j<w;j++){
         if(row[i]==true&col[j]==true){
             cout<<a[i][j];
             exe=true;
         }
     }
     if(exe){
             cout<<endl;
         }
 }
 }

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

int main(){
    long A, B, Q;
    cin>>A>>B>>Q;
    long s[A], t[B], x[Q];
    for(long i=0;i<A;++i){
        cin>>s[i];
    }
    for(long i=0;i<B;++i){
        cin>>t[i];
    }
    for(long i=0;i<Q;++i){
        cin>>x[i];
    }
    vector<long>xarr;
    for(long i=0;i<Q;++i){
        xarr.push_back(x[i]);
    }
    sort(xarr.begin(), xarr.end());
    map<long, long> ans;
    long sh=0, te=0;
    long tmpans1, tmpans2, tmpans3, tmpans4;
    for(long now=0;now<Q;++now){
        while(s[sh]<xarr[now] & sh<A-1){
            sh++;
        }
        while(t[te]<xarr[now] & te<B-1){
            te++;
        }
        if(sh>0 & te>0){
            tmpans1 = abs(xarr[now] - s[sh-1]);
            if(abs(s[sh-1] - t[te]) < abs(s[sh-1] - t[te-1])) tmpans1 += abs(s[sh-1] - t[te]);
            else tmpans1 += abs(s[sh-1] - t[te-1]);

            tmpans2 = abs(xarr[now] - s[sh]);
            if(abs(s[sh] - t[te]) < abs(s[sh] - t[te-1])) tmpans2 += abs(s[sh] - t[te]);
            else tmpans2 += abs(s[sh] - t[te-1]);

            tmpans3 = abs(xarr[now] - t[te-1]);
            if(abs(t[te-1] - s[sh]) < abs(t[te-1] - s[sh-1])) tmpans3 += abs(t[te-1] - s[sh]);
            else tmpans3 += abs(t[te-1] - s[sh-1]);

            tmpans4 = abs(xarr[now] - t[te]);
            if(abs(t[te] - s[sh]) < abs(t[te] - s[sh-1])) tmpans4 += abs(t[te] - s[sh]);
            else tmpans4 += abs(t[te] - s[sh-1]);
            ans[xarr[now]] = min(tmpans1, min(tmpans2, min(tmpans3, tmpans4)));
            //cout<<xarr[now]<<" "<<tmpans1<<" "<<tmpans2<<" "<<tmpans3<<" "<<tmpans4<<" "<<sh<<" "<<te<<endl;
        }
        else if(sh==0 & te>0){
            tmpans1 = abs(xarr[now] - s[sh]);
            if(abs(s[sh] - t[te]) < abs(s[sh] - t[te-1])) tmpans1 += abs(s[sh] - t[te]);
            else tmpans1 += abs(s[sh] - t[te-1]);

            tmpans2 = abs(xarr[now] - t[te]);
            tmpans2 += abs(t[te] - s[sh]);
            tmpans3 = abs(xarr[now] - t[te-1]);
            tmpans3 += abs(t[te-1] - s[sh]);
            ans[xarr[now]] = min(tmpans1, min(tmpans2, tmpans3));
        }
        else if(sh>0 & te==0){
            tmpans1 = abs(xarr[now] - t[te]);
            if(abs(t[te] - s[sh]) < abs(t[te] - s[sh-1])) tmpans1 += abs(t[te] - s[sh]);
            else tmpans1 += abs(t[te] - s[sh-1]);

            tmpans2 = abs(xarr[now] - s[sh]);
            tmpans2 += abs(s[sh] - t[te]);
            tmpans3 = abs(xarr[now] - s[sh-1]);
            tmpans3 += abs(s[sh-1] - t[te]);
            ans[xarr[now]] = min(tmpans1, min(tmpans2, tmpans3));
        }
        else {
            tmpans1 = abs(xarr[now] - s[sh]) + abs(s[sh] - t[te]);
            tmpans2 = abs(xarr[now] - t[te]) + abs(t[te] - s[sh]);
            ans[xarr[now]] = min(tmpans1, tmpans2);
        }
    }
    for(long i=0;i<Q;++i){
        cout<<ans[x[i]]<<endl;
    }
}


Measured memory_bytes: 10740
#include<cmath>
#include<algorithm>
#include<iostream>
#include<vector>
#include<climits>
#include<cstdio>
#include<cfloat>

using namespace std;

double EPS = 1e-10;

double add(double a, double b){
  if(abs(a+b) < EPS * (abs(a)+abs(b)))return 0;
  return a+b;
}

struct point{
  double x, y;
  point(){}
  point(double x,double y) : x(x) , y(y){}

  point operator + (point p){
    return point(add(x,p.x), add(y,p.y));
  }
};

double dot(point a, point b) {
  return (a.x * b.x + a.y * b.y);
}

double norm(point a){
  return sqrt(a.x*a.x+a.y*a.y);
}

int main(void){
  double D;
  point p,v;
 
  while(cin >> D,D){
  
    cin >> p.x >> p.y >> v.x >> v.y;
     
    double d=D+1;
    double a=dot(p,v)/norm(p)/norm(v);

    if(abs(1.0 + a) < EPS )d=norm(p);
    else if(abs(1.0 - a) < EPS)d=2.0-norm(p);

    if(d<D || abs(d-D)<EPS)printf("%.8f\n",d);
    else cout << "impossible" << endl;
  }
 
  return 0;
}

Measured memory_bytes: 1272