akhauriyash/Code-Regression huggingface dataset:
/*B - Golden Coins*/

#include <bits/stdc++.h>

using namespace std;

int main(){
	
	
	int coins;

	cin >> coins;

	int aux;
	int ans = 0;

	aux = coins / 500;
	ans = 1000 * aux;

	aux = coins - (aux * 500);
	aux = aux / 5;
	ans += (aux * 5);

	cout << ans;

	return 0;
}

Measured memory_bytes: 256
#include <cstdio>

int main(void)
{
    while (1) {
        int h, w;
        scanf("%d %d", &h, &w);
        if (!h && !w)
            break;

        for (int y=1; y<=h; y++) {
            for (int x=1; x<=w; x++) {
                if (((x>1)&&(x<w)) && ((y>1)&&(y<h)))
                    printf(".");
                else
                    printf("#");
            }
            printf("\n");
        }
        printf("\n");
    }

    return 0;
}

Measured memory_bytes: 2588
#include <cstdio>
#include <vector>
#include <queue>
using namespace std;
const int inf = 1 << 30;

struct edge {
	int to, cost;
	edge(int a, int b){
		to = a;
		cost = b;
	}
};

struct state {
	int now, sum, z;
	bool operator < (const state &t) const {
		return sum > t.sum;
	}
	state(int a, int b, int c){
		now = a;
		sum = b;
		z = c;
	}
};

vector<edge> g[100];
int d[100][3];


int main()
{
	int n, m;
	while (scanf("%d %d", &n, &m), n){
		for (int i = 0; i < 100; i++) g[i].clear();
		for (int i = 0; i < 100; i++){
			for (int j = 0; j < 3; j++){
				d[i][j] = inf;
			}
		}
		
		for (int i = 0; i < m; i++){
			int a, b, c;
			scanf("%d %d %d", &a, &b, &c);
			--a; --b;
			g[a].push_back(edge(b, c));
			g[b].push_back(edge(a, c));
		}
		
		int res = 0;
		priority_queue<state> que;
		for (que.push(state(0, 0, 0)); que.size(); que.pop()){
			state st = que.top();
			if (st.now == n - 1 && st.z != 1){
				res = st.sum;
				break;
			}
			if (d[st.now][st.z] <= st.sum) continue;
			d[st.now][st.z] = st.sum;
			
			for (int i = 0; i < g[st.now].size(); i++){
				edge &e = g[st.now][i];
				if (st.z == 0 || st.z == 1){
					if (d[e.to][st.z + 1] > st.sum){
						que.push(state(e.to, st.sum, st.z + 1));
					}
				}
				if (st.z == 0 || st.z == 2){
					if (d[e.to][st.z] > st.sum + e.cost){
						que.push(state(e.to, st.sum + e.cost, st.z));
					}
				}
			}
		}
		printf("%d\n", res);
	}
	
	return 0;
}

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

using namespace std;
int main()
{
    int n;
    cin>>n;
    vector <int> b(n);
    int a;
    for(int i=0;i<n-1;i++){
        cin>>a;
        b[a-1]++;
    }
    for(int  i=0;i<n;i++)
        cout<<b[i]<<"\n";
    return 0;
}


Measured memory_bytes: 3972
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin>>s;

    if(s.at(2)==s.at(3) && s.at(4)==s.at(5) )
    {
        {
            cout<<"Yes";

        }
    }
    else
    {
        cout<<"No";
    }

    return 0;
}


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

typedef long long LL;

const int N = 1e5, MOD1 = 1000010029, MOD2 = 1001000027;

int n, m, dis1[N + 5], dis2[N + 5];
bool vis[N + 5];
std::vector<std::tuple<int, bool, int>> E[N + 5];

inline int pow(int x, int k, const int &mod) {
	int ans = 1;
	for (; k > 0; k >>= 1, x = (LL)x * x % mod) {
		if (k & 1) {
			ans = (LL)ans * x % mod;
		}
	}
	return ans;
}
inline int inv(int x, const int &mod) {
	return pow(x, mod - 2, mod);
}
inline void addEdge(int u, int v, bool opt, int w) {
	E[u].emplace_back(v, opt, w);
}
inline bool dfs(int u) {
	vis[u] = true;
	for (const auto &t : E[u]) {
		int v = std::get<0>(t), w = std::get<2>(t);
		bool opt = std::get<1>(t);
		if (!vis[v]) {
			dis1[v] = (LL)dis1[u] * (opt ? inv(w, MOD1) : w) % MOD1;
			dis2[v] = (LL)dis2[u] * (opt ? inv(w, MOD2) : w) % MOD2;
			if (dfs(v)) {
				return true;
			}
		} else {
			// printf("Loop Edge %d -> %d (%d) ", u, v, w);
			if (!opt) {
				// printf("nor\n");
				// dis[u] / dis[v] * w != 1
				if ((LL)dis1[v] * inv(dis1[u], MOD1) % MOD1 != w || (LL)dis2[v] * inv(dis2[u], MOD2) % MOD2 != w) {
					return true;
				}
			} else {
				// printf("rev\n");
				if ((LL)dis1[u] * inv(dis1[v], MOD1) % MOD1 != w || (LL)dis2[u] * inv(dis2[v], MOD2) % MOD2 != w) {
					return true;
				}
			}
		}
	}
	return false;
}
int main() {
	scanf("%d%d", &n, &m);
	for (int u, v, w, i = 1; i <= m; i++) {
		scanf("%d%d%d", &u, &v, &w);
		addEdge(u, v, false, w);
		addEdge(v, u, true, w);
	}
	for (int i = 1; i <= n; i++) {
		if (!vis[i]) {
			dis1[i] = 1;
			dis2[i] = 1;
			if (dfs(i)) {
				// printf("%d %d\n", dis1[1], dis2[1]);
				// printf("%d %d\n", dis1[2], dis2[2]);
				// printf("%d %d\n", dis1[3], dis2[3]);
				printf("No\n");
				return 0;
			}
		}
	}
	printf("Yes\n");
	return 0;
}


Measured memory_bytes: 13664
import java.util.*;
 
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);		
		int H = sc.nextInt();		
		int W = sc.nextInt();
		long count = 0;

		if(W == 1 || H == 1){
            System.out.println(1);
			return;
	}
		
		for(long i=1; i<=H; i++){
			if(W%2==0||i%2==0)
			count += W/2; 
			else
			count += (W+1)/2;
		}
		System.out.println(+count);
	    
	}	
}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
int m[10] = {0,2,5,5,4,5,6,3,7,6};
int main(){
  int n, mm;
  cin >> n >> mm;
  vector<int> dp(n + 1, -100000);
  dp[0] = 0;
  vector<int> p(mm);
  for(int & i : p) cin >> i;
  sort(p.rbegin(), p.rend());
  for(int i = 1; i <= n; i++){
  	for(int j : p){
    	if(i - m[j] >= 0) dp[i] = max(dp[i], dp[i - m[j]] + 1);
    }
  }
  string s;
  while(n){
    for(int j : p){
      if(n - m[j] >= 0 && dp[n] == dp[n - m[j]] + 1){
        cout << j;
        n -= m[j];
        break;
      }
    }
  }
  cout << endl;
  return 0;
}


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

using namespace std;
#define sz(a) int(a.size())
#define ll  long long
#define ull unsigned long long
#define mod (ll)(1000000007)
#define endl '\n'
#define ENGZ ios::sync_with_stdio(0);ios_base::sync_with_stdio(0);cin.tie(0) , cout.tie(0) ;
#define pi double(acos(-1))
#define S second
#define F first
#define mem(arr,a) memset(arr,a,sizeof arr)
//  freopen("input.txt","r",stdin);
// freopen("output.txt","w",stdout);
ll fp(ll n , ll p )
{
    if(p==0)
        return 1 ;
    if(p==1)
        return n%mod ;
    ll res ;
    res = fp(n,p/2)%mod;
    res = (res*res)%mod ;
    if(p%2)
        res = (res*n)%mod ;
    return res;
}


int main()
{
    ENGZ;
    string arr[] ={ "Sunny" , "Cloudy" , "Rainy"};
    int ind = 0 ;
    string s ;
    cin>>s ;
    for(int i=0 ;i<3 ; i++)
    {
        if(arr[i] == s)
            ind = i ;
    }
    ind ++ ;
    ind %= 3;
    cout<<arr[ind] <<endl ;
}


Measured memory_bytes: 256
/*
confirm 0LL and 1LL
confirm cornercases such as 0
confirm times of cin < 10^6
*/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
using VecVec = vector<Vec>;
using Tree = vector<VecP>;
template <typename T>
using Vec1 = vector<T>;
template <typename T>
using Vec2 = vector<Vec1<T> >;
#define REP(i, m, n) for(ll (i) = (m); (i) < (n); ++(i))
#define REPN(i, m, n) for(ll (i) = (m); (i) <= (n); ++(i))
#define REPR(i, m, n) for(ll (i) = (m)-1; (i) >= (n); --(i))
#define REPNR(i, m, n) for(ll (i) = (m); (i) >= (n); --(i))
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPNR(i, n, 1)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
template <typename T>
bool chmax(T &a, const T& b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T& b){if(a > b){a = b; return true;} return false;}
template <typename T>
void co(const T n){cout << n << endl;}
template <typename T>
void cosp(const T n){cout << n << ' ';}
void coVec(const Vec &v){for(ll i : v) cosp(i); cout << endl;}
void sonic(){ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);}
void setp(const ll n){cout << fixed << setprecision(n);}
const ll INF = 1e9+1;
const ll LINF = 1e18+1;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ld PI = acos(-1);
const ld EPS = 1e-11;

int main(void){
	ll a, b;
	cin >> a >> b;
	string s, t;

	rep(i, b){
		s += (a+'0');
	}
	rep(i, a){
		t += (b+'0');
	}

	if(s < t) co(s);
	else co(t);

	return 0;
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
A = sorted([(a, i) for i, a in enumerate(A)], reverse=True)

dp = [0] * (N + 1)
for i in range(N):
    dp2 = dp[:]
    for l in range(i + 1):
        a, pos = A[i]
        # add left side
        dp2[l + 1] = max(dp2[l + 1], dp[l] + (pos - l) * a)
        # add right side
        r = i - l + 1
        dp2[l] = max(dp2[l], dp[l] + (N - r - pos) * a)
    dp = dp2
print(max(dp))

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

int main() {
  vector<int> group = {0, 1, 3, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1};
  int a, b;
  cin >> a >> b;
  if (group[a] == group [b]) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
long long n,k,tmp,sum=0;
std::vector<long long> prc;
void solve(){
    sort(prc.begin(),prc.end());
    rep(i,k){
        sum+=prc.at(i);
    }
    cout<<sum<<endl;
}

int main(){
    cin>>n>>k;
    rep(i,n){
        cin>>tmp;
        prc.emplace_back(tmp);
    }

    solve();
    return 0;
}


Measured memory_bytes: 3648
#include <vector>
#include <cmath>
#include <iostream>
#include <algorithm>

typedef char                SINT8;
typedef unsigned char       UINT8;
typedef short               SINT16;
typedef unsigned short      UINT16;
typedef int                 SINT32;
typedef unsigned int        UINT32;
typedef long long           SINT64;
typedef unsigned long long  UINT64;
typedef double              DOUBLE;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)

using namespace std;

int main() {

	SINT32 N = 0;
	SINT32 M = 0;
	SINT32 ANS = 0;

	cin >> N;

	vector<SINT32> DATA(N);
	
	for (SINT32 i = 0; i < N; i++) {
		cin >> DATA[i];
		if (DATA[i] >= M) {
			ANS++;
		}
		M = MAX(M,DATA[i]);
	}

	cout << ANS << endl;
	return 0;
}

//	sort(DATA.begin(),DATA.end());
//	sort(DATA.begin(),DATA.end(),std::greater<SINT32>());
//	__gcd(ANS,DATA[i]);

/*
	SINT32 M = 3;
	vector<pair<SINT32,SINT32>> DATA2(M);
	for (SINT32 i = 0; i < M; i++) {
		cin >> DATA2[i].first;
		cin >> DATA2[i].second;
	}
	sort(DATA2.begin(),DATA2.end());
	cout << DATA2[0].first << endl;
	cout << DATA2[0].second << endl;
*/

//		APOSI = lower_bound(ADATA.begin(),ADATA.end(),QDATA[i]) - ADATA.begin();
//		BPOSI = lower_bound(BDATA.begin(),BDATA.end(),QDATA[i]) - BDATA.begin();

Measured memory_bytes: 256
#include <stdio.h>
#define FOUND 1
#define NOT_FOUND 0
#define MAX 100000
#define max 50000

int n;
int binarySearch(int *,int);

int main(){

    int S[MAX],T[max],q,count,i;

    scanf("%d",&n);
    for( i = 0; i < n; i++) scanf("%d",&S[i]);
    scanf("%d",&q);
    for( i = 0; i < q; i++){
        scanf("%d",&T[i]);
        if(binarySearch(S,T[i]) == FOUND) count++;
    }

        printf("%d\n",count);
        return 0;
}

int binarySearch(int *A,int key){

    int Left = 0,Right = n,mid;

    while( Left < Right ){
        mid = ( Left + Right ) / 2;
        if(A[mid] == key) return FOUND;
        else if(key < A[mid]) Right = mid;
        else Left = mid + 1;
    }

    return NOT_FOUND;
}


Measured memory_bytes: 2328
H, W = map(int, input().split())
sh, sw = map(int, input().split())
gh, gw = map(int, input().split())

sh += 1
sw += 1
gh += 1
gw += 1
S = [0]*(H+4)
S[0] = '*'*(W+4)
S[1] = '*'*(W+4)
S[-2] = '*'*(W+4)
S[-1] = '*'*(W+4)
for h in range(2,H+2):
  S[h] = '**' + input() + '**'

visited = [[float('inf')]*(W+4) for _ in range(H+4)]
dh1 = [0,1,0,-1]
dw1 = [1,0,-1,0]
dh2 = [2,2,2,2,2,1,1,1,1,0,0,-1,-1,-1,-1,-2,-2,-2,-2,-2]
dw2 = [-2,-1,0,1,2,-2,-1,1,2,-2,2,-2,-1,1,2,-2,-1,0,1,2]

from collections import deque

d = deque()
visited[sh][sw] = 0
d.append((sh,sw))
ans = float('inf')
while len(d)>0:
  h,w = d.popleft()
  cnt = visited[h][w]
  if ans<cnt:
    continue
  for i in range(4):
    h1 = h+dh1[i]
    w1 = w+dw1[i]
    if (h1,w1)==(gh,gw):
      ans = min(ans,cnt)
    if S[h1][w1]=='.':
      if visited[h1][w1]>cnt:
        visited[h1][w1]=cnt
        d.appendleft((h1,w1))
  for i in range(20):
    h2 = h+dh2[i]
    w2 = w+dw2[i]
    if (h2,w2)==(gh,gw):
      ans = min(ans,cnt+1)
    if S[h2][w2]=='.':
      if visited[h2][w2]>cnt+1:
        visited[h2][w2]=cnt+1
        d.append((h2,w2))
if ans==float('inf'):
  ans = -1
print(ans)

Measured memory_bytes: 97832
def main():
    a,b = map(int,input().split())
    if a > 0:
        if b > 0:
            print("Positive")
        else:
            print("Zero")
    else:
        if b >= 0:
            print("Zero")
        else:
            if (a-b)%2 == 0:
                print("Negative")
            else:
                print("Positive")

if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n, k;
    cin >> n >> k;
    int a[n];
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    for (int i = 0; i < k; i++)
    {
        int min = i;
        for (int j = i; j < n; j++)
        {
            if (a[min] > a[j])
            {
                min = j;
            }
        }
        if (min != i)
        {
            swap(a[min], a[i]);
        }
    }

    int sum = 0;
    for (int i = 0; i < k; i++)
    {
        sum += a[i];
    }

    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 3576
package main

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

var (
	graph [][]bool
	seen  []bool
)

func dfs(now int) {
	if seen[now] {
		return
	}
	seen[now] = true

	for next, b := range graph[now] {
		if !b {
			continue
		}

		dfs(next)
	}
}

func solve() {
	n, m := getInt(), getInt()
	as, bs := make([]int, m), make([]int, m)
	for i := 0; i < m; i++ {
		as[i], bs[i] = getInt()-1, getInt()-1
	}
	graph = make([][]bool, n)
	for i := range graph {
		graph[i] = make([]bool, n)
	}
	for i := 0; i < m; i++ {
		graph[as[i]][bs[i]] = true
		graph[bs[i]][as[i]] = true
	}
	seen = make([]bool, n)

	ans := 0
	for i := 0; i < m; i++ {
		graph[as[i]][bs[i]] = false
		graph[bs[i]][as[i]] = false
		for i := range seen {
			seen[i] = false
		}

		dfs(0)
		for _, b := range seen {
			if !b {
				ans++
				break
			}
		}

		graph[as[i]][bs[i]] = true
		graph[bs[i]][as[i]] = true
	}

	fmt.Fprintln(wr, ans)
}

// -----------------------------------------

var (
	sc = bufio.NewScanner(os.Stdin)
	wr = bufio.NewWriter(os.Stdout)
)

func main() {
	// buf := 200001
	// sc.Buffer(make([]byte, buf), buf)
	sc.Split(bufio.ScanWords)
	solve()
	wr.Flush()
}

func getInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func getIntSlice(n int) []int {
	is := make([]int, n)
	for i := range is {
		is[i] = getInt()
	}
	return is
}

func getString() string {
	sc.Scan()
	s := sc.Text()
	return s
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define mme(i,j) memset(i,j,sizeof(i))
#define maxs 2020202
#define ll long long
using namespace std;
char s[maxs];
vector<int>vec[44];

int main()
{
    while(~scanf("%s",s))
    {
        int a=-1,b=-1;
        int len=strlen(s);
        for(int i=0;i<len-1;i++){
            if(s[i]==s[i+1]){
                a=i+1;
                b=i+2;
                break;
            }
            if(i<len-2)
            {
                if(s[i] == s[i+2]){
                    a=i+1;
                    b=i+3;
                    break;
                }
            }
        }
        printf("%d %d\n",a,b);
    }
    return 0;
}


Measured memory_bytes: 384
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <iomanip>
#include <cassert>
#include <atcoder/dsu>

using namespace std;
using namespace atcoder;
typedef long long ll;

int main()
{
   int N, Q;
   cin >> N >> Q;
   dsu d(N);
   for (int i = 0; i < Q; i++)
   {
      int t, u, v;
      cin >> t >> u >> v;
      if (t == 0)
         d.merge(u, v);
      else
         cout << (d.same(u, v) ? 1 : 0) << endl;
   }

   return 0;
}


Measured memory_bytes: 3980
#include <algorithm>
#include <cstdint>
#include <iostream>
#include <numeric>
#include <string>
#include <vector>

using namespace std;
using myui = uint64_t;
using myint = int64_t;

template<typename T>
T diff(const T& a, const T& b) {
    return a > b ? a - b : b - a;
}

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

    {
        myui k, n;
        cin >> n >> k;

        vector<myui> as;
        as.reserve(n);

        for(myui i = 0; i < n; i++) {
            myui a;
            cin >> a;
            as.push_back(a);
        }

        myui tail = 1;
        myui cnt = 0;
        while(tail < n) {
            tail += k-1;
            cnt++;
        }
        cout << cnt << endl;
    }

    return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>
int Lsearch(int[],int,int);
int main(){
  int x,y,i,j,k,key,res=0,same[500],A[10000+1];

  scanf("%d",&x);
  for(i=0;i<x;i++){
    scanf("%d",&A[i]);
  }
  scanf("%d",&y);
  for(i=0;i<y;i++){
    scanf("%d",&key);
    if(Lsearch(A,x,key)==1)res++;
  }


  printf("%d\n",res);
  return 0;
}

int Lsearch(int B[],int n,int kkey){
  int i=0;
  B[n]=kkey;
  for(i=0;B[i]!=kkey;i++);
  if(i==n)return 0;
  else return 1;
}

Measured memory_bytes: 640
N = int(input())
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())
X = min(A, B, C, D, E)
if X >= N:
  print(5)
else:
  if N%X == 0:
    print(4+N//X)
  else:
    print(5+N//X)

Measured memory_bytes: 9120
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		while(true) {
			String start = sc.nextLine();
			if(start.equals("-")) break;

			int m = sc.nextInt();
			int[] shuffle = new int[m];
			for (int i = 0; i < m; i++) {
				shuffle[i] = sc.nextInt();
			}
			sc.nextLine();

			String ans = doShuffle(start, shuffle);

			System.out.println(ans);
		}
	}

	private static String doShuffle(String text, int[] shuffle) {

		for(int num : shuffle) {
			text = text.substring(num) + text.substring(0, num);
		}
		return text;
	}
}

Measured memory_bytes: 26484
#include<stdio.h>
#include<stdlib.h>
int main()
{
	int a, b, c;
	scanf("%d%d%d", &a, &b, &c);
	if (c > a&&c<b || c>b&&c < a)
		printf("Yes");
	else
		printf("No");
	//system("pause");
	return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#define f(n)for(int i=0;i<n;i++)
#define s(w)scanf("%d",&w)
int a,n,m,d[99][99];
int u[16]={-1,-1,-1,0,0,1,1,1,-1,0,1,-1,1,-1,0,1};
void k(int x,int y){
	if(d[x][y]){d[x][y]=0;f(8)k(x+u[i],y+u[i+8]);}
}
int main(){
	a=0;
	s(n);s(m);
	if(n==0)return 0;
	f(9801)d[0][i]=0;
	f(n*m)s(d[i/n+1][i%n+1]);
	f(n*m)if(d[i/n+1][i%n+1])a++,k(i/n+1,i%n+1);
	printf("%d\n",a);
	main();
}

Measured memory_bytes: 1136
//https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 より
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

//

fn run() {
    input! {
        a: [u64; 7],
    }
    let o = a[1];
    let i = a[0];
    let j = a[3];
    let l = a[4];
    let mut ans = o + (i / 2) * 2 + (j / 2) * 2 + (l / 2) * 2;
    if i > 0 && j > 0 && l > 0 {
        let v = o + 3 + ((i - 1) / 2) * 2 + ((j - 1) / 2) * 2 + ((l - 1) / 2) * 2;
        ans = std::cmp::max(v, ans);
    }
    println!("{}", ans);
}

fn main() {
    run();
}


Measured memory_bytes: 4352
a = str(input())
b=list(set(a))

if len(b) == 2:
  count = 0
  for i in range(1,4):
    if a[i] == a[0]:
      count +=1
  if count ==1:
    print("Yes")
  else:
    print("No")
else:
  print("No")


Measured memory_bytes: 2940
import java.util.*

const val mod = 1000000007L
fun main(args: Array<String>) {
    val (x, y) = readLine()!!.split(" ").map { it.toInt() }

    if ((x + y) % 3 != 0) {
        println(0)
        return
    }

    val n = ((x + y) / 3).toLong()
    val k = Math.min(x, y) - n

    if (k < 0) {
        println(0)
        return
    }


    var r = factorial(n)
    var a = factorial(k)
    var b = factorial(n - k)
    var c = (a * b) % mod
    var d = inverse(c)
    var e = (r * d) % mod

    //println("$a $b $c $d $e")
    println(e)
}

fun factorial(n: Long): Long {
    var r = 1L
    (1..n).forEach { r = (r * it) % mod }
    return r
}

fun inverse(n: Long): Long {
    return pow(n, mod - 2)
}

fun pow(n: Long, k: Long): Long { // n ^ k
    if (k == 0L) return 1
    if (k == 1L) return n

    val res = pow(n, k / 2)
    var r = (res * res) % mod
    if (k % 2 == 1L) r = (r * n) % mod
    return r
}


Measured memory_bytes: 40296
#include <string>
#include <map>
#include <iostream>
using namespace std;
int main(){
	map<string,int>m;
	string s;
	int N,M,f=0;
	for(cin>>N;N--;m[s]=1)cin>>s;
	for(cin>>M;M--;cout<<s<<endl)if(cin>>s,m[s])cout<<(f?"Closed by ":"Opened by "),f^=1;else cout<<"Unknown ";
}

Measured memory_bytes: 1240
#include <iostream>
#include <vector>
#include <set>
#include <string>
#include <algorithm>
typedef long long ll;
using namespace std;

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
// --------------------------------------------------------
#define FOR(i,l,r) for (int i = (l); i < (r); ++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(c) (c).begin(), (c).end()
#define RALL(c) (c).rbegin(), (c).rend()
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define MIN(c) *min_element(ALL(c))
#define MAX(c) *max_element(ALL(c))
#define SUM(c) accumulate(ALL(c), 0)
#define SUMLL(c) accumulate(ALL(c), 0LL)
#define SZ(c) ((int)(c).size())
#define debug(x) cerr << #x << " = " << (x) << '\n';
using P = pair<int,int>;
using VP = vector<P>;
using VVP = vector<VP>;
using VS = vector<string>;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<ll>;
using VVLL = vector<VLL>;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const ll MOD = 1000000007;
// const ll MOD = 998244353;
const int INF = 1 << 30;
// const ll INF = 1LL << 62;
// --------------------------------------------------------


int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);

    int A, B, C, X, Y; cin >> A >> B >> C >> X >> Y;

    int ans;
    if (A + B <= 2 * C) {
        ans = A * X + B * Y;
    } else {
        int AB = min(X, Y);
        ans = 2 * C * AB + min(A, 2 * C) * (X - AB) + min(B, 2 * C) * (Y - AB);
    }
    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll dp[100003];int n;int a[100003];
ll solve(int idx)
{
  if(idx>=n)
    return 1e9+7;
  if(idx==n-1)
    return 0;
  if(dp[idx]!=-1)
    return dp[idx];
  ll p=(idx+2>=n)?1e9+7:abs(a[idx]-a[idx+2]);
  return dp[idx]=min((ll)abs(a[idx]-a[idx+1])+solve(idx+1),p+solve(idx+2));
}
int main()
{
  
  cin>>n;
  
  for(int i=0;i<n;i++)
    cin>>a[i];
  memset(dp,-1,sizeof(dp));
  ll ans=solve(0);
  cout<<ans<<"\n";
  return 0;
}

Measured memory_bytes: 2944
//abc168_d.cpp
//Sun May 17 20:36:55 2020

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
#define MOD 1000000007

using namespace std;
using ll=long long;
typedef pair<int,int> P;

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

	vector<int> e[n];
	for (int i=0;i<m;i++){
		int a,b;
		cin >> a >> b;
		a--;b--;
		e[a].push_back(b);
		e[b].push_back(a);
	}

	queue<int> q;
	q.push(0);
	int visited[n];
	fill(visited,visited+n,-1);
	visited[0] = 0;
	while (q.size()){
		int room = q.front();q.pop();
		for (int i=0;i<e[room].size();i++){
			int nroom = e[room][i];
			if (visited[nroom]==-1){
				visited[nroom] = room;
				q.push(nroom);
			}
		}
	}

	int flag = 1;
	for (int i=0;i<n;i++){
		if (visited[i]==-1){
			flag = 0;
			break;
		}
	}

	if (flag){
		cout << "Yes" << endl;
		for (int i=1;i<n;i++){
			cout << visited[i]+1 << endl;
		}
	}else {
		cout << "No" << endl;
	}

}

Measured memory_bytes: 10408
#include<bits/stdc++.h>
using namespace std;
inline void rd(int &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(const char c[]){
  int i=0;
  for(i=0;c[i]!='\0';i++){
    putchar_unlocked(c[i]);
  }
}
int N;
int A[100000];
int main(){
  rd(N);
  {
    int Lj4PdHRW;
    for(Lj4PdHRW=0;Lj4PdHRW<N;Lj4PdHRW++){
      rd(A[Lj4PdHRW]);
    }
  }
  sort(A, A+N);
  if(A[0]==A[N-1] && A[N-1]==0){
    wt_L("Yes");
    wt_L('\n');
    return 0;
  }
  if(N%3){
    wt_L("No");
    wt_L('\n');
    return 0;
  }
  if(A[0]==A[N/3-1] && A[N/3]==A[2*N/3-1] && A[2*N/3]==A[N-1] && (A[0]^A[N/3]^A[2*N/3])==0){
    wt_L("Yes");
    wt_L('\n');
    return 0;
  }
  wt_L("No");
  wt_L('\n');
  return 0;
}
// cLay varsion 20190714-1

// --- original code ---
// int N, A[1d5];
// {
//   rd(N,A(N));
//   sort(A, A+N);
// 
//   if(A[0]==A[N-1]==0){
//     wt("Yes");
//     return 0;
//   }
// 
//   if(N%3){
//     wt("No");
//     return 0;
//   }
// 
//   if(A[0]==A[N/3-1] && A[N/3]==A[2N/3-1] && A[2N/3]==A[N-1] && (A[0]^A[N/3]^A[2N/3])==0){
//     wt("Yes");
//     return 0;
//   }
// 
//   wt("No");
// }


Measured memory_bytes: 640
import math
import sys
def isprime(x):
    m = int(math.sqrt(x))
    if m%2 == 1: m += 2
    for i in range(3, m, 2):
        if x%i == 0: return False
    return True

x = int(input())
if x == 1 or x == 2:
    print(x)
    sys.exit()
if x%2 == 0: x += 1
while True:
    if isprime(x):
        print(x)
        break
    x += 2

Measured memory_bytes: 3064
import Control.Applicative ((<$>), (<*>))
import Control.Monad
import Data.List

main :: IO ()
main = do
  xs <- inputData []
  (putStr . intercalate "\n") $ map leapyear xs

solve :: Int -> Int
solve x = x + 100

inputData :: [(Int,Int)] -> IO [(Int,Int)]
inputData acc = do
  [s,t] <- getl $ split toInt
  if s == 0 && t == 0
    then return (reverse acc)
    else inputData ((s,t):acc)

leapyear :: (Int,Int) -> String
leapyear (s,t)
  | null cs = "NA\n"
  | otherwise = (unlines . map show) cs
  where
    ys = [s..t]
    f y = if y `mod` 400 == 0 then True else if y `mod` 100 == 0 then False else if y `mod` 4 == 0 then True else False
    cs = filter f ys
    
toInt :: String -> Int
toInt s = read s

split :: (String -> a) -> String -> [a]
split f = map f . words

getl :: (String -> a) -> IO a
getl f = f <$> getLine

Measured memory_bytes: 4244
// ICPC Ranking
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while (true) {
			int minutes = sc.nextInt();
			int teams = sc.nextInt();
			int problems = sc.nextInt();
			int records = sc.nextInt();
			if ((minutes | teams | problems | records) == 0)
				break;
			Team[] team = new Team[teams];
			for (int i = 0; i < teams; i++)
				team[i] = new Team(i + 1, problems);
			for (int i = 0; i < records; i++) {
				int m = sc.nextInt();
				int t = sc.nextInt() - 1;
				int p = sc.nextInt() - 1;
				int j = sc.nextInt();
				if (j == 0) {
					team[t].solved++;
					team[t].time += m + team[t].wrong[p] * 20;
				} else
					team[t].wrong[p]++;
			}
			Arrays.sort(team);
			StringBuilder result = new StringBuilder();
			result.append(team[0].id);
			for (int i = 1; i < teams; i++) {
				if (team[i].solved == team[i - 1].solved
						&& team[i].time == team[i - 1].time)
					result.append('=');
				else
					result.append(',');
				result.append(team[i].id);
			}
			System.out.println(result);
		}
		sc.close();
	}

	public static class Team implements Comparable<Team> {
		int id;
		int solved;
		int time;
		int[] wrong;

		Team(int id, int problems) {
			this.id = id;
			solved = 0;
			time = 0;
			wrong = new int[problems];
		}

		@Override
		public int compareTo(Team anotherTeam) {
			if (solved != anotherTeam.solved)
				return anotherTeam.solved - solved;
			else if (time != anotherTeam.time)
				return time - anotherTeam.time;
			return anotherTeam.id - id;
		}
	}
}

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

int main()
{
    int n, t;
    std::cin >> n >> t;

    std::vector<std::pair<int, int>> cost_time(n);
    for (int i = 0; i < n; i++) {
        std::cin >> cost_time[i].first >> cost_time[i].second;
    }

    std::sort(cost_time.begin(), cost_time.end());

    for (auto pair : cost_time) {
        if (pair.second <= t) {
            std::cout << pair.first << std::endl;
            return 0;
        }
    }
    std::cout << "TLE" << std::endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
using namespace std;

#define ABS(a) (((a) >= 0) ? (a) : -(a))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) > (b) ? (b) : (a))
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define RFOR(i, a, b) for (int i = a; i > b; --i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define int long long

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

const int kMaxN = 18;
const int kMaxK = 262144;

int N;
int A[kMaxK];
int ans = 0;

Pair B[kMaxK];

signed main() {
  cin >> N;
  int K = 1;
  REP(i, N) { K *= 2; }
  REP(i, K) { cin >> A[i]; }
  REP(i, K) {
    B[i].first = A[i];
    B[i].second = 0;
  }

  REP(i, N) {
    REP(j, K) {
      if (j&(1<<i)) {
        int k = j^(1<<i);
        int C[4] = {B[j].first, B[j].second,
          B[k].first, B[k].second};
        sort(C, C+4);
        B[j].first = C[3]; B[j].second = C[2];
      }
    }
  }

  REP(i, K-1) {
    ans = MAX(ans, B[i+1].first + B[i+1].second);
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 9216
#include <bits/stdc++.h>
#define sz(c)      int(c.size())
#define rep(i,a,b) for (int i=a; i<(b); ++i)
#define per(i,a,b) for (int i=(b)-1; i>=(a); --i)
using namespace std;
using ll = long long;

int const MD=int(1e9)+7;
ll f[4];

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout<<fixed<<setprecision(10);

  string s;
  cin>>s;
  f[0]=1;
  for (char c:s) {
    int lo=0,hi=3;
    if (c!='?') lo=hi=c-'A'+1;
    per(i,lo,hi+1) {
      if (c=='?') f[i]=f[i]*3;
      if (i>0) f[i]+=f[i-1];
      f[i]%=MD;
    }
  }
  cout<<f[3]<<endl;
}


Measured memory_bytes: 512
#include<stdio.h>
#include<math.h>
int main()
{
    int i,j,x,n,r=0;
    scanf("%d", &x);
    for(i=x;i>=x;i++)
    {
        r=0;
        if(i==2)
        {
           break;
        }
        else
        {
            for(j=2;j*j<=i;j++)
        {
            if(i%j==0)
            {
                r=0;
                break;
            }
            else
                r=1;

        }
        }
        if(r==1)
            break;
    }
    printf("%d\n", i);
    return 0;
}


Measured memory_bytes: 1736
#include<cstdio>
using namespace std;
int n, k, a[200010], now, temp;
char s[200010];
inline void print(){for(int i=1; i<=n; i++)printf("%c", (a[(now+i-2)%n+1]^temp)+'A');}
int main(){
	scanf("%d%d%s", &n, &k, s+1); now=1; temp=0;
	for(int i=1; i<=n; i++)a[i]=s[i]-'A';
	while(k&&(now<n||!(a[now]^temp))){
		k--;
		if(!(a[now]^temp)){a[now]^=1; continue;}
		now++; temp^=1;
	}
	if(!(n&1)){print(); return 0;}
	if(k&1)a[now]^=1; print();
	return 0;
}

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


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

int main()
{
    fast
   // FI(); /// skip this line for compile
    ll n,x=100,cnt=0;
    cin >> n;
    while(x<n){
        x+=(x/100);
        cnt++;
    }
    cout << cnt << endl;
    return 0;
}



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

using namespace std;

int main() {
	long long n;
	cin >> n;
	vector<long long> a(n);
	for (int i = 0; i < n; i++) cin >> a[i];

	long long cnt = 0;
	for (int i = 0; i < n; i++) {
		if (a[i] < 0) {
			cnt++;
			a[i] = a[i] * -1;
		}
	}
	
	sort(a.begin(), a.end());
	long long res = 0;
	
	if (cnt % 2 != 0) {
		a[0] = a[0] * -1;
	}
	for (int i = 0; i < n; i++) {
		res += a[i];
	}
	cout << res << endl;
}

Measured memory_bytes: 1024
X, N = list(map(int, input().split()))
if N!=0:
    p = list(map(int, input().split()))
else:
    print(X)
    exit()

abs_diff = 1000
p = set(p)
for i in range(102):
    if not i in p:
        if abs(X-i)<abs_diff:
            ans = i
            abs_diff = abs(X-i)

print(ans)

Measured memory_bytes: 9132
#include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;
const int mod = 1000000007;
const int N = 100005;
#define ll long long 
#define fr(b) for (int i = 0; i <= b; ++i)
int a[1005];
int is_prime[1006];
ll sum[1005];
int tm;
int sieve(int pp){
	int p = 0;
	fr(pp) is_prime[i] = 1;
	is_prime[0] = is_prime[1] = 0;
	for (int i = 2; i <= pp; ++i){
		if (is_prime[i]){
			a[p++] = i;
			for (int j = 2*i; j <= pp; j+=i) is_prime[j] = 0;
		}
	}
	return p;
}
void solve(int o,int k){
	for (int i = 0; i < k; ++i){
		if (o%a[i] == 0){
			sum[a[i]]++;
			o/=a[i];
			while (o%a[i] == 0){
				sum[a[i]]++;
				o/=a[i];
			}
		}
	}
}
int main(){
	int n;cin>>n;
	tm = sieve(1000);
	for (int i = 1; i <= n; ++i){
		solve(i,tm);
	}
	ll ans = 1;
	for (int i = 0;i < tm; ++i){
		//printf("%d\n",sum[a[i]]);
		ans  = ((ans%mod)*((sum[a[i]]+1)%mod))%mod;
	}
	printf("%d\n",ans);
	return 0;
}

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


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int col[8]; rep(i,8) col[i] = (i+1)*400;
    vector<bool> memo(8,true);
    int ansmax = 0, ansmin = 0;
    int n; cin >> n;
    int a;
    bool flag = true;
    rep(i,n){
        cin >> a;
        rep(j,8){
            if(a < col[j]){
                if(memo[j]){
                    ansmax++; ansmin++;
                    memo[j] = false;
                    flag = false;
                    break;
                }else break;
            }
        }
        if(a >= 3200) ansmax++;
    }
    if(flag) ansmin++;
    cout << ansmin << " " << ansmax << endl;
}


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

int main()
{
	size_t n;
	std::cin >> n;

	double sum_jpy = 0;
	double sum_btc = 0;

	for (size_t i = 0; i < n; i++) {
		double value;
		std::string str = {};
		std::cin >> value >> str;

		if (str == "JPY") {
			sum_jpy += value;
		}
		else {
			sum_btc += value;
		}
	}

	sum_jpy += sum_btc * 380000;
	std::cout << sum_jpy;

	return 0;
}

Measured memory_bytes: 256
while 1:
    n=list(map(int,input().split()))
    if n[0]==0:break
    a=0
    for i in range(n[0],n[1]+1):
        b=i
        while b%2==0: b/=2
        while b%3==0: b/=3
        while b%5==0: b/=5
        if b==1:a+=1
    print(a)

Measured memory_bytes: 7516
const main = args =>{
  const s0 = args[0];
  const s1 = args[1];
  let result = 0;
  for(let i=0;i<s0.length;i++){
  	if(s0[i]!==s1[i]){
    	result++;
    }
  }
  console.log(result);
}

 
main( require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n") );

Measured memory_bytes: 34272
#include <bits/stdc++.h>
#define lg2 std::__lg

const int N = 10054;

int n, K, L;
char s[N], ans[N];

int main() {
	int i, best = 0;
	scanf("%d%d%s", &n, &K, s);
	if (n == 1 || K > lg2(n - 1) + 1) return memset(ans, *std::min_element(s, s + n), n), puts(ans), 0;
	std::reverse_copy(s, s + n, s + n);
	for (i = 1; i <= n; ++i) if (memcmp(s + i, s + best, n) < 0) best = i;
	for (i = 1; i < n && s[best + i] == s[best]; ++i);
	L = std::min(n, i << (K - 1));
	memset(ans, s[best], L), memcpy(ans + L, s + (best + i), n - L);
	return puts(ans), 0;
}

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

#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>
#include <stdint.h>
#include <queue>
#include <bitset>

using namespace std;

#define MAX_N 200000

int dp[MAX_N+1];

int main() {

	int N;
	cin >> N;
	vector<long long> inputs;
	for (int i = 0; i < N; i++) {
		long long x;
		cin >> x;
		inputs.push_back(x);
	}


	fill(dp, dp + N + 1, 0);
	for (int i = 0; i < N; ++i) {
		// dp[j]:最後がjで終わる連続増加行列の長さ
		int j = inputs[i];
		dp[j] = dp[j - 1] + 1;
	}
	int maxnum = 0;
	for (int i = 0; i < N+1; ++i) {
		maxnum = max(maxnum, dp[i]);
	}

	cout << N - maxnum << endl;


	return 0;
}



Measured memory_bytes: 2672
#include <cmath>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <functional>
#include <queue>
#include <iostream>
#include <string.h>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <cstdint>
#include <climits>
#include <unordered_set>
#include <sstream>
#include <stack>

using namespace std;

typedef long long int ll;
typedef pair<ll,ll> pii;
typedef tuple<ll,ll,ll> t3;

using namespace std;


int main() {
    int w, h;
    cin >> h >> w;
    vector<string> ss(h);
    for(int i = 0;i < h;i++)
    {
        cin >> ss[i];
    }
    vector<vector<char>> cs(h);
    for(int y = 0;y < h;y++)
    {
        for(int x = 0;x < w;x++)
        {
            if(ss[y][x] == '#')
            {
                cs[y].push_back(ss[y][x]);
            }
            else
            {
                int t = 0;
                for(int dy = max(0,y-1);dy < min(h,y+2);dy++)
                {
                    for(int dx = max(0,x-1);dx < min(w,x+2);dx++)
                    {
                        if(ss[dy][dx] == '#')
                        {
                            t++;
                        }
                    }
                }
                cs[y].push_back('0' + t);
            }
        }
    }
    for(auto e : cs)
    {
        for(auto ee : e)
        {
            cout << ee;
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 256
IDENTIFICATION DIVISION.
PROGRAM-ID. PROGRAM_ID.

DATA DIVISION.
WORKING-STORAGE SECTION.
01 ln         PIC X(400).
01 maxlen     PIC 9(10) VALUE 100 COMP.
01 cur        PIC 9(10) VALUE 1 COMP.
01 i          PIC 9(10) VALUE 1 COMP.
01 j          PIC 9(10) COMP.
01 len        PIC 9(10) COMP.
01 ans        PIC X(200).
01 N          PIC 9(10).
01 S          PIC X(100).
01 T          PIC X(100).

PROCEDURE DIVISION.
  ACCEPT N.
  ACCEPT ln.
  UNSTRING ln DELIMITED BY SPACE INTO S T.
  PERFORM VARYING i FROM 1 BY 1 UNTIL N < i
    STRING ans S(i : 1) T(i : 1) DELIMITED BY SPACE INTO ans
  END-PERFORM.
  DISPLAY FUNCTION TRIM(ans).
  STOP RUN.


Measured memory_bytes: 3748
#include <bits/stdc++.h>
 
using namespace std;
 
int main() {
	int sz = 8010;
	string s;
	int x, y;
	cin >> s >> x >> y;
 
	vector<vector<int>> d(2, vector<int>(2*sz, 0));//diff array for x and y co-ord let say intial pos is sz and need to go to sz+x similar for y.
	d[0][sz] = 0;
	d[1][sz] = 1;
	int cnt = 0;
	int f = -1;
	s += "T";
	for (int i = 0; i < s.size(); ++i) {
		if (s[i] == 'F') {
			++cnt;
			continue;
		}
		if (f < 0) {
			d[0][sz + cnt] = 1; //first dir always +ve x.
			cnt = 0;
			f = 1;
			continue;
		}
		// cnt moves in direction f so can be along any +ve or negative axis. update dp array.
		vector<int> t(2*sz, 0);
		for (int i = 0; i < 2*sz; ++i) {
			if (i - cnt >= 0) { t[i - cnt] |= d[f][i]; }
			if (i + cnt < 2*sz) { t[i + cnt] |= d[f][i]; }
		}
		d[f] = t;
		cnt = 0;
		f = 1 - f;
	}
	cout << (d[0][x + sz] & d[1][y + sz] ? "Yes" : "No") << "\n";
 
	return 0;
}

Measured memory_bytes: 3748
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> IP;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)
const lint MOD = pow(10, 9) + 7;

int main() {
	lint H;
	cin >> H;
	lint cnt = 0;
	while (1) {
		H /= 2;
		cnt++;
		if (H == 0) {
			break;
		}
	}
	lint ans = 1;
	rep(i, cnt) {
		ans *= 2;
	}
	cout << ans-1 << endl;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) throws IOException{
        BufferedReader f = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
        String str = f.readLine();
        if(str.contains("7")){
            out.println("Yes");
        }else{
            out.println("No");
        }
        out.close();
    }
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

const ll A = pow(10, 5);

const ll N = A + 200;

vector<bool> primes(N + 50000, true);

void prime_solve()
{
    primes[0] = false;
    primes[1] = false;
    for(ll i = 2; pow(i,2) <= N; i++){
        if(primes[i])for(ll j = 2; i*j<=N; j++){
            primes[i*j] = false;
        }
    }
}

ll found(ll x)
{
    for(ll i = x; i <= N; i++){
        if(primes[i])return i;
    }
    return 0;
}

int main() {
    ll X;
    cin >> X;
    prime_solve();
    cout << found(X) << endl;

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int H,W,i,j;
	while(1)
	{
		scanf("%d %d",&H,&W);

		if(H==0 && W==0)
		{
			break;
		}
		for(i=0;i<H;i++)
		{
			for(j=0;j<W;j++)
			{
				if(i==0 || i==H-1 || j==0 || j==W-1)
				{
					printf("#");
				}
				else
				{
					printf(".");
				}
			}
			printf("\n");
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 572
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)

typedef int long long ll;
using namespace std;
typedef pair<int,int> P;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const ll MOD=998244353;
static const int MAX = 100;
static const int INF = (1<<23);
template<class T> T gcd(T a, T b){return b? gcd(b,a%b) : a;}
template<class T> T lcm(T a,T b){return a / gcd(a,b)*b;}

int main(){
    int n,k;
    cin>>n>>k;
    vector<pair<int,int>> rl;
    rep(i,k){
        int l,r;
        cin>>l>>r;
        rl.push_back({l,r});
    }

    sort(rl.begin(),rl.end());
    vector<ll> dp(n+1,0);
    vector<ll> rui(n+2,0);
    dp[1]=1;
    rui[1]=1;

    for(int i=2;i<n+1;i++){
        for(int j=0;j<k;j++){
            int l=rl[j].first;
            int r = rl[j].second;
            if(l>=i)break;
            else{
                if(i<=r){
                    r=i-1;
                }

                dp[i]+=rui[i-l];
                dp[i]%=MOD;
                dp[i]-=rui[i-r-1];
                if(dp[i]<0)dp[i]+=MOD;
                dp[i]%=MOD;
            }
        }

        rui[i]+=rui[i-1];
        rui[i]%=MOD;
        rui[i]+=dp[i];
        rui[i]%=MOD;

    }



    cout<<dp[n]<<endl;
//    rep(i,n+1){
//        cout<<dp[i]<<" ";
//    }
//    cout<<endl;
//    rep(i,n+1){
//        cout<<rui[i]<<" ";
//    }









    return 0;
}


Measured memory_bytes: 6420