akhauriyash/Code-Regression huggingface dataset:
program main
    implicit none
    integer(8), allocatable:: h(:)
    integer(8):: n, k, one
    one =1
    read*, n, k
    
    if (k >= n)then
        print*, 0
        stop
    end if
    
    allocate(h(n))
    read*, h(:)
    call marge_sort(h(:), one, n)
    print*, sum(h(k+1:))
contains

recursive subroutine marge_sort(arr,first,last)
    integer(8):: arr(:), tmp
    integer(8):: first, last, mean

    if (last-first <= 1) then
        if (arr(first) <= arr(last))then
            tmp = arr(first)
            arr(first) = arr(last)
            arr(last) = tmp
        end if
        return
    end if
    
    mean = (first + last) / 2
    call marge_sort(arr, first, mean)
    call marge_sort(arr, mean+1, last)
    call marge(arr, first, mean, last)

end subroutine


subroutine marge(arr, first, mean, last)
    integer(8):: arr(:)
    integer(8), allocatable:: tmp(:)
    integer(8):: first, mean, last
    integer(8):: i, i_left, i_right
    
    allocate(tmp(last-first+1))
    i_left = first
    i_right = mean + 1
    i = 1
    do while((i_left <= mean) .and. (i_right <= last))
        if (arr(i_left) >= arr(i_right))then
            tmp(i) = arr(i_left)
            i_left = i_left + 1
        else
            tmp(i) = arr(i_right)
            i_right = i_right + 1
        end if
        i = i + 1
    end do

    if (i_left > mean)then
        tmp(i:) = arr(i_right:last)
    else
        tmp(i:) = arr(i_left:mean)
    end if
    arr(first:last) = tmp(:)

end subroutine
end program main

Measured memory_bytes: 4644
x,n=map(int,input().split())
if n!=0:
  a=list(map(int,input().split()))	
else:
  print(x)
  exit()
  
b=[]

for i in a:
  b.append(abs(i-x))

m=min(b)
  
if m==0:
  for i in range(max(b)+2):
    if a.count(x-i)==0:
      print(x-i)
      exit()
    if a.count(x+i)==0:
      print(x+i)
      exit()
else:
  print(x)
    

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

using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> p(n);
  for (int i = 0; i < n; ++i) cin >> p[i];
  int res = 0;
  for (int i = 1; i < n - 1; ++i) {
    if ((p[i - 1] < p[i] && p[i] < p[i + 1]) || (p[i - 1] > p[i] && p[i] > p[i + 1])) res++;
  }
  cout << res << endl;
}

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

using namespace std;

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

template <typename T>
void printv(const vector<T> &v)
{
    int sz = v.size();
    for (int i = 0; i < sz; i++)
    {
        cout << v[i] << " \n"[i == sz - 1];
    }
}

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

    int n, m;
    cin >> n >> m;
    vector<vector<int>> s(m, vector<int>(n, 0));
    for (int i = 0; i < m; i++)
    {
        int k;
        cin >> k;
        for (int j = 0; j < k; j++)
        {
            int a;
            cin >> a;
            a--;
            s[i][a] = 1;
        }
    }
    vector<int> p(m);
    for (int i = 0; i < m; i++)
        cin >> p[i];
    int ret = 0;
    for (int i = 0; i < (1 << n); i++)
    {
        bool f = true;
        for (int j = 0; j < m; j++)
        {
            int cnt = 0;
            for (int k = 0; k < n; k++)
            {
                if (s[j][k] && ((i >> k) & 1))
                    cnt++;
            }
            if (cnt % 2 == p[j])
                continue;
            f = false;
        }
        if (f)
            ret++;
    }
    cout << ret << endl;
}


Measured memory_bytes: 256
n=gets.to_i
c,s,f=$<.map{|e|e.split.map &:to_i}.transpose
n.times{|i|
	t=0
	(i..n-2).each{|j|
		if t<s[j]
			t=s[j]
		elsif t%f[j]!=0
			t+=f[j]-t%f[j]
		end
		t+=c[j]
	}
	p t
}

Measured memory_bytes: 1916
def main():
    lines = list(get_input())
    for i, line in enumerate(lines):
        if int(line) == 0:
            break
        print("Case {}: {}".format(i+1, int(line)))

def get_input():
    while True:
        try:
            line = input()
            if line == '':
                break
            else: 
                yield line
        except EOFError:
            break


if __name__ == "__main__":
    main()


Measured memory_bytes: 6296
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define abdelrahman010 ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long long ll;
using namespace std;
const int N = 1e5 + 5;
int main()
{
    abdelrahman010
    ll n , a , b;
    cin >> n >> a >> b;
    cout << (n / (a + b)) * a + min(a , n % (a + b));
    return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		sc.nextLine();
		int[][] arr = new int[m][4];
		for (int i = 0; i < m; i++) {
			arr[i][0] = sc.nextInt();
			arr[i][1] = sc.nextInt();
			arr[i][2] = i;
			
			sc.nextLine();
		}
		sort(arr,1);
		
		int[] count = new int[n+1];
		for(int i=0; i<m; i++){
			arr[i][3] = count[arr[i][0]]+1;
			count[arr[i][0]]++;
		}
		sort(arr,2);
		
		for(int i=0; i<m; i++){
			System.out.println(addZeroForNum(arr[i][0]) + addZeroForNum(arr[i][3]));
		}
	}

	public static void sort(int[][] ob, final int order) {
		Arrays.sort(ob, new Comparator<Object>() {
			public int compare(Object o1, Object o2) {
				int[] one = (int[]) o1;
				int[] two = (int[]) o2;
				if (one[order] > two[order]) {
					return 1;
				} else if (one[order] < two[order]) {
					return -1;
				} else {
					return 0;
				}
			}
		});
	}

	public static String addZeroForNum(int no) {
		if(no<10){
			return "00000" + no;
		}else if(no < 100){
			return "0000" + no;
		}else if(no < 1000){
			return "000" + no;
		}else if(no < 10000){
			return "00" + no;
		}else if(no < 100000){
			return "0" + no;
		}else{
			return String.valueOf(no);
		}
	}
}

Measured memory_bytes: 175948
#include <iostream>
#include <cstdio>
#define MAX_N 1000
#define MAX_W 1000
using namespace std;
int dp[MAX_N+1][MAX_W+1];
int N,W;
int v[MAX_N+1],w[MAX_N+1];

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

int main() {
  int vt,wt,p=0,minW;
  while(cin >> W) {
    if(W==0)break;
    cin >> N;
    for(int i=1;i<=N;i++) {
      scanf("%d,%d",&vt,&wt);
      v[i] = vt; w[i] = wt;
    }
    solve();
    p++;
    printf("Case %d:\n",p);
    int top = dp[N][W];
    for(int i=0;i<W;i++) {
      if(top == dp[N][W-i]) {
        minW = W-i;
        continue;
      }
      break;
    }
    printf("%d\n%d\n",dp[N][W],minW);
  }
}

Measured memory_bytes: 0
N = int(input())
A = list(map(int,input().split()))

num = [i+1 for i in range(len(A))]

order = []
for i in range(len(A)):
    order.append([A[i],num[i]])
    
order.sort()

ans = []
for i in range(len(A)):
    ans.append(str(order[i][1]))
    
print(" ".join(ans))


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

using namespace std;

int N;
set<int> st;
map<int, int> mp;

int main(){
    cin.sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> N;
    bool allzero = 1;
    for(int i =1 ; i<=N; i++){
        int n;
        cin >> n;
        allzero &= (n == 0);
        st.insert(n);
        mp[n]++;
    }
    if(allzero){
        cout << "Yes" << endl;
        return 0;
    }
    if(st.size() > 3 || N%3){
        cout << "No" << endl;
        return 0;
    }
    if(st.size() == 2){
        int n = *st.begin(), m = *(--st.end());
        if(n == 0 && mp[m] == 2*N/3){
            cout << "Yes" << endl;
            return 0;
        }
    }
    if(st.size() == 3){
        int n = *st.begin(), m = *(--st.end());
        if(st.count(n^m) && mp[n] == N/3 && mp[m] == N/3){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}


Measured memory_bytes: 7552
#include<iostream>
#include<algorithm>
#include<cmath>
#include<map>
#include<string>
#include<set>
#include<utility>
#include<vector>

#include<time.h>
using namespace std;

int solve(){
  int n;  cin >> n;
  int ans = 0;
  bool con = false;
  for(int i=0; i<n; i++){
    int p;  cin >> p;
    if(p==i+1){
      if(con){
        con = false;
        continue;
      }
      ans++;
      con=true;
    }
    else{
      con = false;
    }
  }
  cout << ans << endl;
}

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


Measured memory_bytes: 256
#include<stdio.h>
     
    int main()
    {
     	int a,b;
      
     	scanf("%d %d",&a,&b);
      
     	if(a%2==1&&b%2==1){
        	printf("Yes\n");
        }else{
        	printf("No\n");
        }
      
    	return 0;
    }

Measured memory_bytes: 128
#include <stdio.h>
#define max(X, Y) ((X) > (Y) ? (X) : (Y))
typedef long long ll;

ll dp[2005][2005];
ll s[2005];
ll t[2005];
ll n, m;

int main()
{
    scanf("%lld %lld", &n, &m);
    for (int i = 1; i <= n; i++) {
        scanf("%lld", s + i);
    }
    for (int i = 1; i <= m; i++) {
        scanf("%lld", t + i);
    }

    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) {

            dp[i][j] = dp[i - 1][j] + dp[i][j - 1];
            dp[i][j] -= dp[i - 1][j - 1];

            if (dp[i][j] < 0) {
                dp[i][j] += (ll)(1e9) + 7;
            }

            if (s[i] == t[j]) {
                dp[i][j] += dp[i - 1][j - 1] + 1;
            }

            dp[i][j] %= (ll)(1e9) + 7;
        }
    }

    dp[n][m]++;
    dp[n][m] %= (ll)(1e9) + 7;

    printf("%lld\n", dp[n][m]);

    return 0;
}


Measured memory_bytes: 31488
/*
 Abu Jafor Mohammad Saleh
 ios_base :: sync_with_stdio(false);
 cin.tie(NULL);
 
 */

#include<cstdio>
#include<iomanip>
#include<sstream>
#include<cstdlib>
#include<cctype>
#include<cmath>
#include<algorithm>
#include<set>
#include<queue>
#include<deque>
#include<stack>
#include<list>
#include<iostream>
#include<fstream>
#include<numeric>
#include<string>
#include<vector>
#include<cstring>
#include<map>
#include<iterator>
#include<limits>
#include <algorithm>
#include <unordered_map>
#include<fstream>
#define f first
#define s second
#define MOD 1000003

#define INF (int)1e9
#define PI 3.1415926535897932384626433832795
#define BOUNDARY(i, j) ((i >= 0 && i < rows) && (j >= 0 && j < coloums))

//#include<bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long
const int maxn = 100001;
using namespace std;
int X[] = {0, 1, 0, -1};
int Y[] = {-1, 0, 1, 0};
int rows,coloums;
long long  gcd(long long  a, long long b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}

bool check1(string s,int p)
{
    p = p-1;
    int j=p;
    for(int i=0;i<=j;i++,j--)
    {
        if(s[i] != s[j])
            return false;
    }
    return true;
}

bool check2(string s,int p,int n)
{

    int j=n-1;
    for(int i=p-1;i<=j;i++,j--)
    {
        if(s[i] != s[j])
            return false;
    }
    return true;
}

int main()
{
    fast;
    string s;
    cin>>s;
    int n = s.length();
    
    int x = (n-1)/2;
    int y  = (n+3)/2;
    
    if(check1(s, x) && check2(s, y, n) && check1(s, n))
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
    
}


Measured memory_bytes: 256
/* *Your Love Makes me STRONG,
   You'r Hate Makes Me UNSTOPABBLE.*
 
  *HOPE is a good thing,Maybe The BEST of Things.
   And No Good Things Ever Dies.*
  
  *Keep calm,Be patient And Chase Your DREAM*

*/


#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define MN7 ios::sync_with_stdio(0);cin.tie(nullptr);
using namespace std;
ll t,n,i,j,k,a,b,c,d,p,q,r,x,y,z,m,cnt,flag,ans;
string s;
void nahid()
{
 cin>>x;
 if(x==0)cout<<1<<endl;
 else cout<<0<<endl;



}
int main()
{ MN7// cin>>t;while(t--)
  nahid();
}


Measured memory_bytes: 3624
#include<stdio.h>
#include<iostream>
#include<string.h>
#include<algorithm>
#include<queue>
#include<stack>
#include<math.h>
#include<map>
typedef long long int ll;
using namespace std;
#define maxn 0x3f3f3f3f

int main()
{
    ll x;
    scanf("%lld",&x);
    ll cnt1=x/500;
    x%=500;
    ll cnt2=x/5;
    ll sum=cnt1*1000+cnt2*5;
    printf("%lld\n",sum);
}



Measured memory_bytes: 256
#include<stdio.h>

int main(){
		int h1,w1,i,j,flag=0,h[100]={0},w[100]={0},counth=0,countw=0;
		char a[100][101];
		scanf("%d%d",&h1,&w1);
		for(i=0;i<h1;i++)scanf("%s",a[i]);
		for(i=0;i<h1;i++){
				flag=0;
				for(j=0;j<w1;j++){
						if(a[i][j]!='.'){
								flag=1;
								break;
						}
				}
				if(flag==0)h[i]=1;
		}
		for(i=0;i<w1;i++){
				flag=0;
				for(j=0;j<h1;j++){
						if(a[j][i]!='.'){
								flag=1;
								break;
						}
				}
				if(flag==0)w[i]=1;
		}
		for(i=0;i<h1;i++){
				for(j=0;j<w1;j++){
						if(h[i]==0&&w[j]==0)printf("%c",a[i][j]);
				}
				if(h[i]==0)puts("");
		}
		return 0;
}


Measured memory_bytes: 128
A,B = [int(i) for i in input().rstrip().split()]
Aa = A/0.08
Ba = B/0.1
round=lambda x:int((x*2+1)//2)
N = round(max(Aa,Ba))

def ch(n):
    global A,B
    #print(int(n * 0.08), A, int(n * 0.1), B)
    if int(n * 0.08) == A and int(n * 0.1) == B:
        return True
    else:
        return False

if ch(N-1):
    print(N-1)
elif ch(N):
    print(N)
else:
    print(-1)

Measured memory_bytes: 3064
#include "bits/stdc++.h"
using namespace std;
using ll = long long;

template <typename TYPE>
void print_vec(const vector<TYPE>& v, int num=0){
  if(num == 0) num = (int)v.size();
	for(int i=0; i<num; i++){
		cout << v[i]; if(i!=num-1) cout << " ";
	}
	cout << endl;
}

template <typename TYPE>
void print_vec2(const vector<vector<TYPE>>& v){
  cout << endl; cout << "       ";
  for(int i=0; i<v[0].size(); i++) cout << i << "   "; 
  cout << endl;
	for(int i=0; i<v.size(); i++){
		cout << "i=" << i << ":   ";
		for(int j=0; j<v[i].size(); j++){
			if(v[i][j] == 0) cout << "\x1B[0m" << v[i][j] << "   ";
      else cout << "\x1B[31m" << v[i][j] << "   ";//https://stackoverrun.com/ja/q/12618775
		}
		cout << "\x1B[0m" << endl;
	}
}

bool is_prime(ll a){
  if(a <= 1) return false;

  for(ll p=2; p*p<=a; p++){
    if(a % p == 0) return false;
  }
  return true;
}
int main(){
  int n;
  cin >> n;
  int ans = 0;
  for(int i=0; i<n; i++){
    ll a;
    cin >> a;
    if(is_prime(a)) ans++;
  }

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




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

using namespace std;

typedef long long ll;

int a[200010];

int main()
{
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++) scanf("%d",&a[i]);
    ll ans=0;
    for(int i=1;i<=n;i++)
    {
        if(a[i]<a[i-1])
        {
            ans+=a[i-1]-a[i];
            a[i]=a[i-1];
        }
    }
    printf("%lld",ans);
    return 0;
}

Measured memory_bytes: 4508
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<iostream>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<map>
#include<set>
#include<algorithm>

#define rep(n) for(int i=0;i<n;i++)
#define repp(j, n) for(int j=0;j<n;j++)
#define reppp(i, m, n) for(int i=m;i<=n;i++)
#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define pb(x) push_back(x)
#define eb(x,y) emplace_back(x,y)
#define MOD 1000000007
#define MAX 1000000001
#define INF 1410065408
#define EPS 1e-9
 
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
struct edge{int from, to; ll cost;};

ll func(ll a, ll b){
	ll ret = 0;
	if(a > b) swap(a,b);
	while(a > 0){
		ret += 2 * a * (b/a);
		ll c = b % a;
		b = a;
		a = c;
	}
	return ret-b;
}

signed main(){
	ll N, X;
	cin >> N >> X;

	cout << N + func(X, N-X);
}



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

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

using namespace std;

#define int long long
#define deb(x) cout << #x << " " << x << endl;
#define pb push_back
#define pp pop_back
#define F first
#define S second
#define all(x) x.begin(),x.end()

#define MOD 1000000007
#define MAX 50000

typedef long double ld;
const int N = 1e5 + 10;
const long double Pie = acos(-1);

map<int, bool> perfectSquares;


signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
		
	int n;
	cin >> n;
	
	int rem = n % 10;
	
	if (rem == 3)
		cout << "bon";
	else if (rem == 0 or rem == 1 or rem == 6 or rem == 8)
		cout << "pon";
	else
		cout << "hon";
		
	return 0;
}


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

int main(){
    int N,K;
    cin >> N >> K;
    
    int h[100001];
    rep(i,N) cin >> h[i];
    
    int ans = 0;
    rep(i,N){
        if(h[i] >= K) ans++;
    }
    
    cout << ans << endl;
}


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

namespace CS_AtCoder {
	class Program {
		static void Main(string[] args) {
			new Calc().Solve();
		}
	}
	public class Calc {
		Scan cin = new Scan();
		public void Solve() {
			var ABC = cin.ReadLong(' ');
			long target = ABC.Sum();
			if (ABC[0] % 2 == 1 || ABC[1] % 2 == 1 || ABC[2] % 2 == 1) { "0".WL();return; }
			if (ABC.All(_ => _ == target / 3)) { "-1".WL(); return; }
			var item = search(ABC[0], ABC[1], ABC[2]) - 1;
			item.WL();
			return;
		}
		private long search(long a,long b,long c) {
			if (a % 2 == 1 || b % 2 == 1 || c % 2 == 1) return 1;
			return search(b / 2 + c / 2, a / 2 + c / 2, b / 2 + a / 2) + 1;
		}
	}

	public class Scan {
		public Scan() { }
		public int ReadInt() => int.Parse(Console.ReadLine());
		public int[] ReadInt(char separator) => Console.ReadLine().Split(separator).Select(int.Parse).ToArray();
		public double ReadDouble() => double.Parse(Console.ReadLine());
		public double[] ReadDouble(char separator) => Console.ReadLine().Split(separator).Select(double.Parse).ToArray();
		public long ReadLong() => long.Parse(Console.ReadLine());
		public long[] ReadLong(char separator) => Console.ReadLine().Split(separator).Select(long.Parse).ToArray();
		public string ReadLine() => Console.ReadLine();
		public string[] ReadLine(char separator) => Console.ReadLine().Split(separator).ToArray();
	}
	public static class Utils {
		public static string Docking<T>(this IEnumerable<T> collection,Func<T,string> filter = null) {
			StringBuilder sb = new StringBuilder();
			foreach (var item in collection) {
				sb.Append(filter != null ? filter(item) : item.ToString());
			}
			return sb.ToString();
		}
		public static void WL(this object obj) => Console.WriteLine(obj);
		public static int IntParse(this string s) => int.Parse(s);
		public static int IntParse(this char c) => (c + "").IntParse();
	}
}


Measured memory_bytes: 13396
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <queue>
#include <stack>
#include <cmath>

using namespace std;
using ll = long long;
using ull = unsigned long long;

void EducationalDP_C()
{
	int N;
	cin >> N;
	vector<vector<int> >abc(N, vector<int>(3));
	for (int i = 0; i < N; ++i)
		cin >> abc[i][0] >> abc[i][1] >> abc[i][2];

	vector<vector<int> > dp(N, vector<int>(3));
	for (int j = 0; j < 3; ++j)
		dp[0][j] = abc[0][j];
	for (int i = 1; i < N; ++i)
	{
		dp[i][0] = max(dp[i - 1][1], dp[i - 1][2]) + abc[i][0];
		dp[i][1] = max(dp[i - 1][2], dp[i - 1][0]) + abc[i][1];
		dp[i][2] = max(dp[i - 1][0], dp[i - 1][1]) + abc[i][2];
	}
	cout << max(dp[N - 1][0], max(dp[N - 1][1], dp[N - 1][2]));
}
int main()
{
	EducationalDP_C();
	return 0;
}

Measured memory_bytes: 11136
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <ctype.h>

int main(void) {
  long n, sn = 0, nc;

  if(scanf("%ld", &n) == 1);

  nc = n;

  while(n) {
    sn += n % 10;
    n /= 10;
  }

  if(nc % sn == 0) {
    printf("Yes");
  } else {
    printf("No");
  }
  return 0;
}


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

int main(){
  int A, B, C, X;
  int count=0;
  cin >> A >> B >> C >> X;
  for(int i=0; i<=A; i++){
    if(500*i>X) break;
    for(int j=0; j<=B; j++){
      if(500*i+100*j>X) break;
      for(int k=0; k<=C; k++){
        if(500*i+100*j+50*k==X){
          count++;
          break;
        }
      }
    }
  }
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 256
//include
//------------------------------------------
#include <bits/stdc++.h>
using namespace std;
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const long long INF = 1000000007;
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
// chmax chmin
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main(void){
    int N; cin >> N;
    vector<int> a(N); REP(i,N) cin >> a[i];
    SORT(a);
    cout << a.back()-a[0] << endl;
    return 0;
}

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

int main()
{
  int n;
  cin>>n;
  int a[n],b[n],c[n];
  ll dp[n][3];
  
  for(int i=0;i<n;i++)cin>>a[i]>>b[i]>>c[i];
  
  dp[0][0]=a[0];
  dp[0][1]=b[0];
  dp[0][2]=c[0];
  
  for(int i=1;i<n;i++){
    dp[i][0]=max(dp[i-1][1],dp[i-1][2])+a[i];
    dp[i][1]=max(dp[i-1][0],dp[i-1][2])+b[i];
    dp[i][2]=max(dp[i-1][1],dp[i-1][0])+c[i];
  }
  
  cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]))<<endl;
  
  return 0;
}

Measured memory_bytes: 3712
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int[] A = new int[N + 2];
    A[0] = 0;
    A[N + 1] = 0;
    for (int i = 1; i <= N; i++) {
      A[i] = sc.nextInt();
    }
    int sum = 0;
    for (int i = 0; i <= N; i++) {
      sum += Math.abs(A[i] - A[i + 1]);
    }
    for (int i = 1; i <= N; i++) {
      int ans = sum + Math.abs(A[i - 1] - A[i + 1]) - (Math.abs(A[i - 1] - A[i]) + Math.abs(A[i] - A[i + 1]));
      System.out.println(ans);
    }
  }
}

Measured memory_bytes: 65208
#include<bits/stdc++.h>
using namespace std;
#define nl cout<<'\n';
int main()
{
    int s=15,a,sum=0,n=5;
    while(n--)
    {
       cin>>a;
       sum+=a;
    }
    cout<<s-sum;
    nl;
    return 0;
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
#define collect(arr, size) rep(i,size) cin >> arr[i];
using intpair = pair<int, int>;

int main(){
    int A,B,C;
    cin >> A >> B >> C;
    cout << (min(A,B)<C && C<max(A,B) ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
def primes(n):
    is_prime = [True] * (n+1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
    # 確かめるのはnの平方根までで大丈夫
        if not is_prime[i]:  # すでにfalseなら次のiへ
            continue
            """
            bool(not False)はTrueになる
            """
        for j in range(i * 2, n + 1, i):
        # iずつ大きくなる(つまりiの倍数をみる)
            is_prime[j] = False
            # i自身を除くiの倍数を全てFalseにする
    return [i for i in range(n + 1) if is_prime[i]]
     # Trueのものだけ列挙して返す


def gcd(m, n):
    while n:
        m, n = n, m % n
    return m


A, B = map(int, input().split())

# Aの約数を列挙する
A_divs = []
ans = 0

for i in range(1, int(A**(1/2))+2):
    if A % i == 0:
        A_divs.append(i)
        A_divs.append(A//i)

common_divisor = []

for a in A_divs:
    if B % a == 0:
        common_divisor.append(a)

common_divisor = list(set(common_divisor))
common_divisor.sort()
# print(common_divisor)

ans = [1]

for num in common_divisor:
    flag = True
    for i in range(len(ans)):
        if gcd(num, ans[i]) != 1:
            flag = False
    if flag:
        ans.append(num)
ans.remove(1)

print(len(ans))


Measured memory_bytes: 4012
#include<bits/stdc++.h>
#define ll long long
#define int long long
#define sz(c) c.size()
#define fr first
#define sc second
#define pb push_back
#define sz(c) c.size()
#define ppb  pop_back
#define all(a)      (a).begin(),(a).end()
#define rep(i,a,n)   for( int i=a ; i<n ; i++)
#define U 1000000007
#define N 200005
#define ins insert
using namespace std;
int n,a[N],t[400009],dp[N];
pair<int,int>p[N];
void build(int v, int tl, int tr){
    if(tl==tr){
        t[v]=a[tl];
        return;
    }
    int tm=(tl+tr)/2;
    build(2*v,tl,tm);
    build(2*v+1,tm+1,tr);
    t[v]=max(t[2*v],t[2*v+1]);
}
void upd(int v, int tl, int tr, int pos, int val){
    if(tl==tr){
        t[v]=val;
        return;
    }
    int tm=(tl+tr)/2;
    if(pos<=tm) upd(2*v,tl,tm,pos,val);
    else upd(2*v+1,tm+1,tr,pos,val);
    t[v]=max(t[2*v],t[2*v+1]);
}
int get(int v, int tl, int tr, int l, int r){
    if(l>r) return 0;
    if(l==tl && r==tr) return t[v];
    int tm=(tl+tr)/2;
    return max(get(2*v,tl,tm,l,min(r,tm)),
            get(2*v+1,tm+1,tr,max(l,tm+1),r));
}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin>>n;
    build(1,1,n);
    rep(i,0,n) cin>>p[i].fr;
    rep(i,0,n) cin>>p[i].sc;
    rep(i,0,n){
        int z=get(1,1,n,1,p[i].fr-1);
        dp[i]=p[i].sc+z;
        upd(1,1,n,p[i].fr,dp[i]);
    }
    int ma=0;
    rep(i,0,n) ma=max(ma,dp[i]);
    cout<<ma;



}

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

int main(){
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    int mn = 1e+5;
    int mn_idx;
    for(int i = 0; i < n; i++){
        cin >> a[i];
        if(mn > a[i]){
            mn = a[i];
            mn_idx = i;
        }
    }
    int ans = 1e+5;
    for(int i = 0; i < k; i++){
        int l = max(mn_idx - i, 0);
        int r = min(l + k - 1, n-1);
        ans = min(ans, (l + k-2) / (k-1) + (n - 1 - r + k-2) / (k-1));
    }
    cout << ans+1 << endl;
    return 0;
}

Measured memory_bytes: 640
#include <cstdio>
#include <algorithm>

using namespace std;

const int Maxn = 110;
int x[Maxn], y[Maxn], h[Maxn];

int main(){
    int n;
    scanf("%d", &n);
    int maxh = 0;
    for (int i = 0; i < n; ++i) {
        scanf("%d%d%d", &x[i], &y[i], &h[i]);
        maxh = max(maxh, h[i]);
    }

    for(int cx = 0; cx <= 100; ++cx){
        for(int cy = 0; cy <= 100; ++cy){
            for(int H = maxh; H <= maxh + 200; ++H){
                bool flag = true;
                for (int i = 0; i < n; ++i) {
                    if (h[i] != max(H - abs(x[i] - cx) - abs(y[i] - cy), 0)){
                        flag = false;
                        break;
                    }
                }
                if (flag){
                    printf("%d %d %d\n", cx, cy, H);
                    return 0;
                }
            }
        }
    }

}

Measured memory_bytes: 128
a=[]
while True:
    try:
        x=int(input())
        a.append(x)
    except:
        break
b=[]
for i in range(1,101):
    y=a.count(i)
    b.append(y)
c=[j for j, v in enumerate(b) if v == max(b)]
e=len(c)
for h in range(e):
    print(c[h]+1)


Measured memory_bytes: 5604
object Main {

  def main(args: Array[String]): Unit = {
    val sc = new java.util.Scanner(System.in)

    val N = sc.nextInt()
    val P = new Array[(Int, Int)](N)
    (0 until N) foreach { i =>
      val x, y = sc.nextInt()
      P(i) = (x, y)
    }

    val routes = P.permutations.map { routes =>
      routes.sliding(2).map { route =>
        Math.sqrt(Math.pow(route(0)._1 - route(1)._1, 2) +
          Math.pow(route(0)._2 - route(1)._2, 2))
      }. sum
    }. toList
    println(routes.sum / routes.length)
  }

}


Measured memory_bytes: 79904
import java.util.Scanner;

class Main{
	static int change = 0;//お釣り
	public static void main(String[] args){
		Scanner stdIn = new Scanner(System.in);
		int paymentAmont = 1000;//支払い金額
		
		while(true){
			int amountShopping = stdIn.nextInt();//買い物金額
			if(amountShopping == 0)break;
			change = paymentAmont - amountShopping;
	
			int coin500 = getCoinNumberOfSheets(500);//釣りの500円玉の枚数
			int coin100 = getCoinNumberOfSheets(100);//釣りの100円玉の枚数
			int coin50 = getCoinNumberOfSheets(50);//釣りの50円玉の枚数
			int coin10 = getCoinNumberOfSheets(10);//釣りの10円玉の枚数
			int coin5 = getCoinNumberOfSheets(5);//釣りの5円玉の枚数
			int coin1 = getCoinNumberOfSheets(1);//釣りの1円玉の枚数
			
			System.out.println(coin500+coin100+coin50+coin10+coin5+coin1);
		}
	}
	public static int getCoinNumberOfSheets(int kindOfCoin){
		int countCoin = 0;
		while(change >= kindOfCoin){
			change -= kindOfCoin;
			countCoin++;
		}
		return countCoin;
	}
}

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

using namespace std;

int main()
{
	string qn,str,p,answer;
	int q,a,b,y,f;
	cin >> str >> q;
	for (int i = 0 ; i < q ; i++ ){
		cin >> qn;
		if (qn == "replace"){
			cin >> a >> b >> p;
			for (int j = 0 ; j < b - a + 1 ; j++ ){
				str[a + j] = p[j]; 
			}
		} 

		if (qn == "reverse"){
			cin >> a >> b;
				for (int x = a ; x < b ; x++ ){
					y = b;
					answer[x] = str[x];
					
				    str[x] = str[y];
				    str[y] = answer[x];
					b--;
                   
				}
		}
		
		if (qn == "print"){
			cin >> a >> b;
			cout << str.substr(a,b - a + 1) << endl;
		}
	}

 return 0;
}

Measured memory_bytes: 3196
<?php
  fscanf(STDIN,"%d%d",$n,$m);
 $x_li = explode(" ",trim(fgets(STDIN)));
 sort($x_li);
$sum_dis = 0;
 $dis_li = array();
 for($i=0;$i<count($x_li)-1;$i++){
   $dis = $x_li[$i+1]-$x_li[$i];
   $dis_li[] = $dis;
   $sum_dis += $dis;
 }


rsort($dis_li);

 for($i=0;$i<$n-1;$i++){
   $sum_dis -= $dis_li[$i];
 }

echo $sum_dis;
 
  

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

int main()
{
  int h, w;

  scanf("%d %d\n", &h, &w);

  char **s;
  s = (char **)malloc(sizeof(char *) * h);

  for (int i = 0; i < h; ++i) {
    s[i] = (char *)malloc(sizeof(char) * w);

    for (int j = 0; j < w; ++j) {
      s[i][j] = getchar();
    }
    getchar();
  }

  for (int i = 0; i < h; ++i) {
    for (int j = 0; j < w; ++j) {
      if (s[i][j] == '.') {
	int num = 0;
	if (i-1 >= 0 && j-1 >= 0 && s[i-1][j-1] == '#') {
	  ++num;
	}
	if (i-1 >= 0 && s[i-1][j] == '#') {
	  ++num;
	}
	if (i-1 >= 0 && j+1 < w && s[i-1][j+1] == '#') {
	  ++num;
	}
	if (j-1 >= 0 && s[i][j-1] == '#') {
	  ++num;
	}
	if (j+1 < w && s[i][j+1] == '#') {
	  ++num;
	}
	if (i+1 < h && j-1 >= 0 && s[i+1][j-1] == '#') {
	  ++num;
	}
	if (i+1 < h && s[i+1][j] == '#') {
	  ++num;
	}
	if (i+1 < h && j+1 < w && s[i+1][j+1] == '#') {
	  ++num;
	}
	s[i][j] = '0' + num;
      }
      putchar(s[i][j]);
    }
    putchar('\n');
  }

  
  for (int i = 0; i < h; ++i) {
    free(s[i]);
  }

  free(s);
  
  return 0;
}



Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
long long a,b,c,d,e,i,j,ii,jj,zx,xc,mod[2],pp=31,xar[1000009][2],hsh[1000009][2],fx[39],kl[2],pas;
string ss[200009],s;
char cha[1000009];
unordered_map <long long, vector <long long> > m;
vector <long long> v,vv;
long long mk(long long q, long long w){
    return q*1000000021LL+w;
}
int main(){
    ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
    mod[0]=1000000007LL;
    mod[1]=1000000009LL;
    xar[0][0]=xar[0][1]=1;
    for(i=1; i<=1000003; i++){
        for(j=0; j<=1; j++){
            xar[i][j]=xar[i-1][j]*pp;
            xar[i][j]%=mod[j];
        }
    }
    //cin>>a;
    scanf("%I64d\n",&a);
    for(i=1; i<=a; i++){
        scanf("%s\n",&cha);
        for(j=0; ; j++){
            if(cha[j]<'a'||cha[j]>'z') break;
            ss[i].push_back(cha[j]);
        }
        //cout<<ss[i]<<endl;
        //cin>>ss[i];
    }
    for(i=1; i<=a; i++){
        s=ss[i];
        b=s.size();
        //cout<<s<<endl;
        s.insert(0,"0");
        hsh[b+1][0]=hsh[b+1][1]=0;
        for(j=b; j>=1; j--){
            for(jj=0; jj<=1; jj++){
                hsh[j][jj]=hsh[j+1][jj]+xar[b-j][jj]*(s[j]-'a'+1);
                hsh[j][jj]%=mod[jj];
            }
        }
        v=m[mk(hsh[2][0],hsh[2][1])];
        if(v.size()==0){
            v.resize(28);
            v[s[1]-'a']++;
        }else{
            v[s[1]-'a']++;
        }
        m[mk(hsh[2][0],hsh[2][1])]=v;
/*        for(ii=0; ii<=5; ii++) cout<<v[ii]<<" ";
        cout<<endl;*/
        //cout<<mk(hsh[1][0],hsh[1][1])<<endl;
    }
    //cout<<endl<<endl;
    for(i=1; i<=a/2; i++) swap(ss[i],ss[a-i+1]);
    for(i=1; i<=a; i++){
        s=ss[i];
        b=s.size();
        //cout<<s<<endl;
        s.insert(0,"0");
        hsh[b+1][0]=hsh[b+1][1]=0;
        for(ii=0; ii<=27; ii++) fx[ii]=0;
        for(j=b; j>=1; j--){
            for(jj=0; jj<=1; jj++){
                hsh[j][jj]=hsh[j+1][jj]+xar[b-j][jj]*(s[j]-'a'+1);
                hsh[j][jj]%=mod[jj];
            }
        }
        for(j=2; j<=b+1; j++){
            fx[s[j-1]-'a']=1;
            v=m[mk(hsh[j][0],hsh[j][1])];
            if(v.size()==0) continue;
            /*cout<<i<<" "<<j<<endl;
            for(ii=0; ii<=5; ii++) cout<<v[ii]<<" ";
            cout<<endl;*/
            for(ii=0; ii<26; ii++){
                if(v[ii]!=0&&fx[ii]!=0) pas+=v[ii];
            }
        }
        //cout<<mk(hsh[1][0],hsh[1][1])<<endl;
    }
    //printf("%I64d",pas);
    cout<<pas-a<<endl;
    return 0;
}

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

int main()
{
    int a, b;
    cin >> a >> b;
    
    cout << fixed;
    cout << setprecision(5);
    cout << a/b << ' ' << a%b << ' ' << (double)a/b << endl;
    return 0;
}


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

using namespace std;

using int64 = long long;
const int64 INF = 1LL << 60;

template< class T >
struct BinaryIndexedTree {
  vector< T > data;

  BinaryIndexedTree(int sz) {
    data.assign(++sz, 0);
  }

  T sum(int k) {
    T ret = 0;
    for(++k; k > 0; k -= k & -k) ret += data[k];
    return (ret);
  }

  void add(int k, T x) {
    for(++k; k < data.size(); k += k & -k) data[k] += x;
  }
};

int N;
int luz[2000], hiled[2000];
int64 dp[2001][2001];
BinaryIndexedTree< int > bit(4001);

int64 rec(int x, int y) {
  int z = x + y;
  if(z == 2 * N) return 0;
  if(~dp[x][y]) return dp[x][y];
  int64 ret = INF;
  if(x < N) {
    bit.add(luz[x], 1);
    ret = min(ret, rec(x + 1, y) + z - bit.sum(luz[x] - 1));
    bit.add(luz[x], -1);
  }
  if(y < N) {
    bit.add(hiled[y], 1);
    ret = min(ret, rec(x, y + 1) + z - bit.sum(hiled[y] - 1));
    bit.add(hiled[y], -1);
  }
  return dp[x][y] = ret;
}

int main() {
  cin >> N;
  for(int i = 0; i < 2 * N; i++) {
    char c;
    int a;
    cin >> c >> a;
    if(c == 'W') luz[--a] = i;
    else hiled[--a] = i;
  }
  memset(dp, -1, sizeof(dp));
  cout << rec(0, 0) << endl;
}

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

using namespace std;

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

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

class XorShift {
	unsigned int x, y, z, w, t;
public:
	XorShift() {
		x = 1335533;
		y = 314167339;
		z = 664338413;
		w = 992399937;
		t = 0;
	}
	unsigned int rand() {
		t = x ^ (x << 11);
		x = y;
		y = z;
		z = w;
		w = (w ^ (w >> 19)) ^ (t ^ (t >> 8));
		return w & 0x7fffffff;
	}
};

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

	XorShift xs;
	for (int loop = 0; loop < 1; loop++) {
		cin >> K;
		cin >> W >> H;
		//K = xs.rand() % 100000 + 1;
		//W = xs.rand() % 100000 + 1;
		//H = xs.rand() % 100000 ;
		//W *= -1;
		//H *= -1;
		if (!W && !H)continue;
		if (K % 2 == 0 && (abs(W) + abs(H)) % 2 == 1) {
			cout << -1 << endl;
			return 0;
			//continue;
		}
		long long int turn = (abs(H) + abs(W)) / K + !!((abs(H) + abs(W)) % K);
		if (turn == 1 && K != abs(H) + abs(W))turn++;
		if ((turn*K) % 2 != (abs(H) + abs(W)) % 2)turn++;
		long long int amari = (turn * K - abs(H) - abs(W)) / 2;
		int ny = 0, nx = 0;
		vector<pair<int, int>>ans;
		int y = abs(H);
		int x = abs(W);
		while (ny != y || nx != x) {
			//cout << nx << " " << ny << endl;
			if (amari >= K) {
				ny -= K;
				amari -= K;
			}
			else if (amari) {
				if (K - amari <= x - nx) {
					ny -= amari;
					nx += K - amari;
				}
				else if (K - amari <= y - ny) {
					ny += K - amari;
					nx -= amari;
				}
				amari = 0;
			}
			else {
				if (K <= x - nx) {
					nx += K;
				}
				else {
					ny += K - (x - nx);
					nx = x;
				}
			}
			if (y < ny) {
				//cout << K << " " << W << " " << H << endl;
				return 0;
			}
			ans.push_back({ nx,ny });
		}
		W /= max(1, x);
		if (!W)W = 1;
		H /= max(1, y);
		if (!H)H = 1;
		cout << ans.size() << endl;
		for (auto i : ans)cout << i.first*W << " " << i.second*H << endl;
	}	
}


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

using namespace std;

/*

        Bismillahir Rahmanir Rahim
        Problem :
        Problem Link :
        Topics :
        Solver : Masud Parves
        I Love Code More than Sharks Love Blood <3
*/


#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define SZ(a)           (int)a.size()
#define all(a)  a.begin(), a.end()
#define allr(a)  a.rbegin(), a.rend()


#define sf(a)           scanf("%d",&a)
#define sff(a,b)        scanf("%d %d",&a,&b)
#define sfff(a,b,c)     scanf("%d %d %d",&a,&b,&c)

#define f0(i,b) for(int i=0;i<(b);i++)
#define f1(i,b) for(int i=1;i<=(b);i++)
#define f2(i,a,b) for(int i=(a);i<=(b);i++)
#define fr(i,b,a) for(int i=(b);i>=(a);i--)

#define CIN ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
#define TEST_CASE(t) for(int zz=1 ; zz<=t ; zz++)
#define PRINT_CASE printf("Case %d: ",zz)
#define Debug(x)            cout<<#x " = "<<(x)<<endl
#define NOT_VISITED 0
#define IS_VISITED 1
#define WHITE 0
#define GRAY 1
#define BLACK 2



int fx[4]= {1,-1,0,0};
int fy[4]= {0,0,1,-1};

/*-----------------------Bitmask------------------*/
//int Set(int N,int pos){return N=N  (1<<pos);}
//int Reset(int N,int pos){return N= N & ~(1<<pos);}
//bool Check(int N,int pos){return (bool)(N & (1<<pos));}
/*------------------------------------------------*/


const double PI = acos(-1.0);
const double EPS = 1e-6;
const int MOD = (int)1e9+7;
const int maxn = (int)2e5+5;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef pair<ll, int> plli;
typedef pair<int, ll> pill;

char A[55][55],B[55][55];
int main() {
    CIN
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    int m,n;
    cin >> n >> m;

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

    for(int i=0 ; i<m ; i++){
        for(int k=0 ; k<m ; k++){
            cin >> B[i][k];
        }
    }

    if(m>n){
        cout << "No" << endl;
        return 0;
    }


    bool ok=false;
    for(int i=0 ; i<n ; i++){
        for(int k=0 ; k<n ; k++){
                if(i+m-1>n || k+m-1>n){
                    continue;
                }
                bool match=true;
                for(int x=0 ; x<m ; x++){
                    for(int y=0 ; y<m ; y++){
                        if(A[i+x][k+y]!=B[x][y]){
                            match=false;
                        }
                    }
                }

                if(match){
                    cout << "Yes" << endl;
                    return 0;
                }

        }
    }

    cout << "No" << endl;


    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define crap ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
typedef long long int ll;
typedef unsigned long long ull;
typedef std::vector<int> vi;
typedef std::vector<ll> vll;
typedef std::vector<vi > vvi;
typedef std::vector<vll > vvll;
typedef std::pair<int,int> ii;
typedef std::pair< ll, ll > lp;
typedef std::vector<ii> vii;
typedef std::vector<vii > vvii;

#define pb emplace_back 
#define PB pop_back
#define pf push_front
#define PF pop_front
#define mp make_pair
#define ub(a,b) upper_bound(all(a),b)
#define lb(a,b) lower_bound(all(a),b)
#define bs(a,b) binary_search(all(a),b)
#define mem(a,b) memset(a,b,sizeof(a))
#define in(a,n) F(i,0,n-1)cin>>a[i]
#define in1(a,n) F(i,1,n)cin>>a[i]
#define out(a,n) F(i,0,n-1)cout<<a[i]<<"\n";cout<<endl
#define ff first
#define ss second
#define F(i,a,b) for (ll i=a;i<=b;i++)
#define RF(i,a,b) for(ll i=a;i>=b;i--)
#define rep(i,n) F(i,0,n-1)
#define clr(a) (a).clear()
#define rz resize
#define sqr(a) ((a) * (a))
#define sz(a) int((a).size())
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin() ,(a).rend()
#define endl '\n'

#define mod 1000000007

ll add(ll a, ll b){return (a%mod + b%mod)%mod;}
ll sub(ll a , ll b){return (a%mod - b%mod + mod)%mod;}
ll mul(ll a, ll b){return (a%mod * b%mod)%mod;}
ull poww(ull a,ull b){ull res=1;while(b){if(b&1){res*=a;}a=a*a;b>>=1;}return res;}
ll poww(ll a,ll b,ll MOD){ll res=1;while(b){if(b&1){res*=a;res%=MOD;}a=a*a;a%=MOD;b>>=1;}return res;}

#define dbg(x) cout<<#x<<" :: "<<x<<endl;
#define dbg2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<endl;
#define dbg3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<endl;
#define dbg4(x,y,z,w) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\t"<<#w<<" :: "<<w<<endl;

//end of template

int main(int argc, char const *argv[])
{
	crap;
	ll r, d, x;
	cin >> r >> d >> x;
	ll a[10];
	a[0] = r*x - d;
	F(i, 1, 9)
		a[i] = r*a[i-1] - d;
	out(a, 10);
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

//#define LOCAL 0
//#ifdef LOCAL
//#define DEBUG(s) cout << (s) << endl
//#define dump(x)  cerr << #x << " = " << (x) << endl
//#define BR cout << endl;
//#else
//#define DEBUG(s) do{}while(0)
//#define dump(x) do{}while(0)
//#define BR
//#endif


//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 20)
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl

//ここから編集する


int main() {
    int a, b, c;
    cin >> a >> b >> c;
    cout << (b - a == c - b ? "YES" : "NO") << endl;
    return 0;
}


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

int main() {
    int n;cin>>n;
    int a[n+1],s[n+1];
    int m,x;cin>>m>>x;
    for(int i=0;i<=n;++i){
        a[i]=0;
    }
    int tmp;
    for(int i=0;i<m;++i){
        cin>>tmp;
        a[tmp]=1;
    }
    s[0]=a[0];
    for(int i=1;i<=n;++i){
        s[i]=s[i-1]+a[i];
    }
    int ans=min(s[n]-s[x],s[x]-s[0]);
    cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
	#ifndef ONLINE_JUDGE
	freopen("i.in","r",stdin);
	freopen("o.out","w",stdout);
	freopen("error.txt","w",stderr);
	#endif
	double n;
	cin >> n;
	if (n)
	{
		cout << 0;
	}else{
		cout <<1;
	}

	
}

Measured memory_bytes: 3724
s = input()
q = int(input())
insts = [input().split() for _ in range(q)]
 
for inst in insts:
    a, b = int(inst[1]), int(inst[2]) + 1
    if inst[0] == "replace":
        p = inst[3]
        s = s[:a] + p + s[b:]
    elif inst[0] == "reverse":
        s = s[:a] + s[a:b][::-1] + s[b:]
    elif inst[0] == "print":
        print(s[a:b])


Measured memory_bytes: 5620
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
	int n; cin>>n;
	int ind[100010];
	for(int i=0; i<n; i++){
		int p; cin>>p;
		ind[p]=i;
	}
	set<int> st;
	st.insert(-1);
	st.insert(n);
	ll ans=0;
	for(int i=n; i>=1; i--){
		auto itr=st.lower_bound(ind[i]);
		auto itr1=itr;
		itr1--;
		int x=*itr, y=*itr1;
		if(x<n){
			auto itr2=itr;
			itr2++;
			int z=*itr2;
			ans+=(ll)(z-x)*(ll)(ind[i]-y)*(ll)i;
		}
		if(y>-1){
			auto itr3=itr1;
			itr3--;
			int w=*itr3;
			ans+=(ll)(x-ind[i])*(ll)(y-w)*(ll)i;
		}
		st.insert(ind[i]);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 7040