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

#define Fast            ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
#define fWrite          freopen ("out.txt","w",stdout);
#define TC              int t;cin >> t;FOR(tc,1,t)
#define LL              long long
#define ULL             unsigned long long
#define ff              first
#define ss              second
#define pb              push_back
#define pii             pair<int,int>
#define all(a)          a.begin(),a.end()
#define MEM(a,x)        memset(a,x,sizeof(a))
#define FOR(i,a,b)      for(int i=a;i<=b;i++)
#define ROF(i,a,b)      for(int i=a;i>=b;i--)
#define REP(i,b)        for(int i=0;i<b;i++)

#define Make(x,p)       (x | (1<<p))
#define DeMake(x,p)     (x & ~(1<<p))
#define Check(x,p)      (x & (1<<p))
#define popcount(x)     __builtin_popcount(x)

int main()
{
    Fast
    string str;
    cin >> str;
    if(str[0]=='7' or str[1]=='7' or str[2]=='7') cout << "Yes";
    else cout << "No";
}


Measured memory_bytes: 3648
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

#define ll long long
#define INF 1<<31-1
#define LNF 9223372036854775807
#define PI 3.14159265358979
#define MIN(x,y) ((x)<(y)?(x):(y))
#define MAX(x,y) ((x)<(y)?(y):(x))
#define FOR(i,a,n) for(i=a;i<n;i++)
#define MOD 1000000007
//#define MOD 998244353
#define NUM 200010
 
void swap(int* a,int* b){int tmp=*a;*a=*b;*b=tmp;}
int abs(int a){if(a<0)return -a;return a;}
int dup(int a,int d){if(a%d==0)return a/d;else return a/d+1;}
int mod(int a,int m){if(a<0)return a%m+m;else return a%m;}

void swapl(ll* a,ll* b){ll tmp=*a;*a=*b;*b=tmp;}
ll absl(ll a){if(a<0)return -a;return a;}
ll dupl(ll a,ll d){if(a%d==0)return a/d;else return a/d+1;}
ll modl(ll a,ll m){if(a<0)return a%m+m;else return a%m;}

ll GCD(ll a,ll b){ll c=1,tmp=MAX(a,b);b=MIN(a,b);a=tmp;while(c!=0){c=a%b;a=b;b=c;}return a;}
ll LCM(ll a,ll b){return a*b/GCD(a,b);}

ll factorial(ll n, ll m) {return n < m ? 1 : n*factorial(n-1, m);}

int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}

// ll dp[]
ll k;
ll n;
ll A[200000];

int p(ll m){
    ll cnt = 0;
    for(int i=0; i<n; i++){
        cnt += A[i] / m;
        if (A[i]%m == 0) cnt--;
    }
  return cnt <= k;
}

int main(){
  ll i, lb, ub;
  scanf("%lld%lld", &n, &k);
  for(i = 0; i < n; i++){
    scanf("%lld", &A[i]);
  }

  lb = 0;
  ub = 1000000000;

  while (ub - lb > 1)
  {
    ll mid = (lb+ub)/2;
    if(p(mid)){
      ub = mid;
    }
    else{
      lb = mid;
    }
  }
  
  printf("%lld\n", ub);
  return 0;
}

Measured memory_bytes: 3232
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <cstring>
#include <utility>
#include <numeric>

using namespace std;

int main(){

    int N;
    cin >> N;
    vector<vector<int>> cnt(N, vector<int>(26, 0));
    string s;
    for(int i = 0; i < N; i++){
        cin >> s;
        for(int j = 0; j < (int)s.size(); j++){
            cnt[i][s[j] - 'a']++;
        }
    }

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

    long long ans = 0;
    int tempCnt = 1;
    for(int i = 1; i < N; i++){
        bool isOk = true;
        for(int j = 0; j < 26; j++){
            if(cnt[i - 1][j] != cnt[i][j]){
                isOk = false;
                break;
            }
        }

        if(isOk){
            tempCnt++;
        }
        else{
            ans += (long long)tempCnt * (tempCnt - 1) / 2;
            tempCnt = 1;
        }
    }

    ans += (long long)tempCnt * (tempCnt - 1) / 2;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 13568
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int A, B;

int main(void) {

	cin >> A >> B;

	if (1 <= A && A <= 9 && 1 <= B && B <= 9) { cout << A*B << endl; }
	else { cout << -1 << endl; }

	return 0;
}

Measured memory_bytes: 256
def selectionSort(A,N):
    count = 0
    for i in range(N):
        minj = i
        for j in range(i, N):
            if A[j] < A[minj]:
                minj = j
        
        if i != minj:
            A[i], A[minj] = A[minj], A[i]
            count += 1

    print(*A)
    print(count)

N = int(input())
A = list(map(int, input().split()))

selectionSort(A, N)


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

int main() {
	long n;
	cin>>n;
	long a[n];
	for(int i=0;i<n;i++)cin>>a[i];
	if(n%2==0){
		for(int i=0;i<n/2;i++){
			cout<<a[n-2*i-1]<<" ";
		}
		for(int i=0;i<n/2;i++){
			cout<<a[2*i]<<" ";
		}
	}
	else{
		for(int i=0;i<(n+1)/2;i++){
			cout<<a[n-1-2*i]<<" ";
		}
		for(int i=0;i<(n-1)/2;i++){
			cout<<a[2*i+1]<<" ";
		}
	}
	return 0;
}

Measured memory_bytes: 3712
import sys
def main():
    input = sys.stdin.readline
    N, M = map(int, input().split())
    A = [int(input()) for _ in range(M)] + [-1]
    dp = [Mint() for _ in range(N+1)]
    dp[0] = Mint(1)
    j = 0
    for i in range(1,N+1):
        if i == A[j]:
            j += 1
            continue
        dp[i] += dp[i-1]
        if i >= 2: dp[i] += dp[i-2]

    print(dp[N])

class Mint:
    def __init__(self, value=0, mod=10**9+7):
        self.value = ((value % mod) + mod) % mod
        self.mod = mod

    @staticmethod
    def get_value(x): return x.value if isinstance(x, Mint) else x

    def inverse(self):
        a, b = self.value, self.mod
        u, v = 1, 0
        while b:
            t = a // b
            b, a = a - t * b, b
            v, u = u - t * v, v
        return (u + self.mod) % self.mod

    def __repr__(self): return str(self.value)
    def __eq__(self, other): return self.value == other.value
    def __neg__(self): return Mint(-self.value, self.mod)
    def __hash__(self): return hash(self.value)
    def __bool__(self): return self.value != 0

    def __iadd__(self, other):
        self.value = (self.value + Mint.get_value(other)) % self.mod
        return self
    def __add__(self, other):
        new_obj = Mint(self.value, self.mod)
        new_obj += other
        return new_obj
    __radd__ = __add__

    def __isub__(self, other):
        self.value = (self.value - Mint.get_value(other) + self.mod) % self.mod
        return self
    def __sub__(self, other):
        new_obj = Mint(self.value, self.mod)
        new_obj -= other
        return new_obj
    def __rsub__(self, other):
        new_obj = Mint(Mint.get_value(other), self.mod)
        new_obj -= self
        return new_obj

    def __imul__(self, other):
        self.value = self.value * Mint.get_value(other) % self.mod
        return self
    def __mul__(self, other):
        new_obj = Mint(self.value, self.mod)
        new_obj *= other
        return new_obj
    __rmul__ = __mul__

    def __ifloordiv__(self, other):
        other = other if isinstance(other, Mint) else Mint(other, self.mod)
        self *= other.inverse
        return self
    def __floordiv__(self, other):
        new_obj = Mint(self.value, self.mod)
        new_obj //= other
        return new_obj
    def __rfloordiv__(self, other):
        new_obj = Mint(Mint.get_value(other), self.mod)
        new_obj //= self
        return new_obj

if __name__ == '__main__':
    main()

Measured memory_bytes: 57180
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <list>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <iomanip>
#define INF 1050000000
 
using namespace std;

int n;
int w[101];
int v[101];
int dp[101][10001];

int rec(int i, int j) 
{
	int res;
	if (dp[i][j] >= 0) return dp[i][j];

	if (i == n) res = 0;
	else if (w[i] > j)
		res = rec(i + 1, j);
	else
		res = max(rec(i + 1, j), rec(i + 1, j - w[i]) + v[i]);
	dp[i][j] = res;
	return (res);
}

int main(void)
{
	int W;

	cin >> n >> W;
	memset(dp, -1, sizeof(dp));

	for (int i = 0; i < n; i++) {
		cin >> v[i] >> w[i];
	}
	cout << rec(0, W) << endl;

	return (0);
}

Measured memory_bytes: 5116
import java.util.Scanner;
import java.util.Arrays;
class Main{
    public static void main(String[] args) {
        Scanner scn = new Scanner(System.in);
        int n = scn.nextInt();
        String[] blue = new String[n];
        for(int i=0;i<n;i++){
            blue[i]=scn.next();
        }
        Arrays.sort(blue);
        int m = scn.nextInt();
        String[] red = new String[m];
        for(int j=0;j<m;j++){
            red[j]=scn.next();
        }
        Arrays.sort(red);
        int money = 0;
        for(int i=0;i<n;i++){
            int cnt = 1;
            for(int j=i+1;j<n;j++){
                if(j<n&&blue[i].equals(blue[j])){
                    cnt++;
                }
            }
            int r_cnt=0;
            for(int j=0;j<m;j++){
                if(blue[i].equals(red[j])) r_cnt++;
            }
           money= Math.max(money,cnt-r_cnt);
        }
        System.out.println(money);
    }
}


Measured memory_bytes: 21844
use std::io::*;

fn read<T: std::str::FromStr>() -> T {
    let stdin = stdin();
    let mut buf = String::new();
	stdin.lock().read_line(&mut buf);
	buf.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
	read::<String>().trim().split_whitespace()
        .map(|w| w.parse().ok().unwrap()).collect()
}

fn read_mat<T: std::str::FromStr>(n: usize) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

fn main() {
    let v = read_vec::<usize>();
    let (n,m) = (v[0],v[1]);
    let w = read_mat::<i64>(n);
    let mut score = vec![Vec::with_capacity(n);8];
    for x in w {
        let s = x[0] + x[1] + x[2];
        score[0].push(s);
        score[1].push(s - 2*x[0]);
        score[2].push(s - 2*x[1]);
        score[3].push(s - 2*x[2]);
        score[4].push(-s + 2*x[0]);
        score[5].push(-s + 2*x[1]);
        score[6].push(-s + 2*x[2]);
        score[7].push(-s);
    }
    let mut ans = 0;
    for mut ss in score {
        ss.sort_by(|a,b| b.cmp(a));
        let t = ss.iter().take(m).sum();
        if t > ans {
            ans = t;
        }
    }
    println!("{}",ans);
}


Measured memory_bytes: 4352
#include<iostream>
#include <algorithm>
#include <stdlib.h>
#include <string>
#include <vector>
using namespace std;

int main(void) {
	long long int n, a, b, m, l;
	string s,t;
	char u;
	int i,j,k;
	bool flag = true;
	cin >> s;
	cin >> n;
	a = 0;
	for (i = 0; i < n; i++) {
		cin >> m;
		switch (m) {
		case 1:
			a++;
			break;
		case 2:
			cin >> l;
			cin >> u;
			switch ((l + a) % 2) {
			case 1:
				s.insert(s.begin(), u);
				break;
			default:
				s.push_back(u);
			}
		}
					
	}
	if(a % 2 == 1)reverse(s.begin(), s.end());
	cout << s << endl;
	return 0;
}

Measured memory_bytes: 900
#include <bits/stdc++.h>
#define all(a) (a).begin(), (a).end()
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1; (i)>=0; (i)--)
#define ios() cin.tie(0), ios::sync_with_stdio(false)
typedef long long ll;
typedef unsigned long long ull;
ll const MOD = 1e9+7;
ll const INF = 1e18;
using namespace std;

int main(){
    int n;
    cin >> n;
    string s;
    cin >> s;
    int red = 0, blue = 0;
    REP(i, n){
        if(s[i] == 'R') red++;
        else blue++;
    }
    cout << (red > blue ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 256
def main():
    K = int(input())
    A, B = map(int, input().split())
    div = A // K
    rem = A % K
    if rem == 0:
        flag = True
        print('OK')
    else:
        val = div * K + K
        if val <= B:
            print('OK')
        else:
            print('NG')

if __name__ == '__main__':
    main()

Measured memory_bytes: 9048
import java.util.*;
     
public class Main {
    public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
    	int W = sc.nextInt();
    	int H = sc.nextInt();
    	int N = sc.nextInt();
    	int now_x = sc.nextInt();
    	int now_y = sc.nextInt();
    	
    	int min = 0;
    	
    	for(int i = 0;i < N - 1;i++){
    		int por_x = sc.nextInt();
    		int por_y = sc.nextInt();
    		
    		int x = por_x - now_x;
    		int y = por_y - now_y;
    		    		
    		if(x > 0 && y > 0){
    			min += Math.min(x, y);
    			min += Math.abs(x - y);
    		}else if(x < 0 && y > 0){
    			x = -x;
    			min += x + y;
    		}else if(x < 0 && y < 0){
    			x = -x;
    			y = -y;
    			min += Math.min(x, y);
    			min += Math.abs(x - y);
    		}else if(x > 0 && y < 0){
    			y = -y;
    			min += x + y;
    		}else if(x == 0 && y != 0){
    			min += Math.abs(y);
    		}else if(x != 0 && y == 0){
    			min += Math.abs(x);
    		}
    		
    		now_x = por_x;
    		now_y = por_y;
    	}
    	
    	System.out.println(min);
    }
}

Measured memory_bytes: 25032
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <string>
#include <cmath>
#include <complex>
#include <numeric>
#include <cassert>

#include <vector>
#include <array>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <utility>

#define int64 long long
#define uint64 unsigned long long
using namespace std;

int main()
{
	int64 nn;
	cin >> nn;
	set<string> ans;
	queue<pair<string, char>> qq;
	qq.push(make_pair("a", 'b'));
	while(!qq.empty())
	{
		string tmps = qq.front().first;
		char tmpc = qq.front().second;
		qq.pop();
		if(tmps.length() == nn)
		{
			ans.insert(tmps);
			continue;
		}
		for(char cc = 'a';cc <= tmpc;cc++)
		{
			if(cc == tmpc)
			{
				qq.push(make_pair(tmps + cc, tmpc + 1));
			}
			else
			{
				qq.push(make_pair(tmps + cc, tmpc));
			}
		}
	}
	for(set<string>::iterator ite = ans.begin();ite != ans.end();ite++)
	{
		cout << *ite << endl;
	}
	return 0;
}

Measured memory_bytes: 12712
def selection_sort(A, N):
    cnt = 0
    for i in range(N):
        min_index = i
        for j in range(i, N):
            if A[j] < A[min_index]:
                min_index = j
        if i != min_index:
            A[i], A[min_index] = A[min_index], A[i]
            cnt += 1
    print(' '.join(list(map(str, A))))
    print(cnt)


N = int(input())
A = list(map(int, input().split()))
selection_sort(A, N)



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

int main(){
  char c;
  cin>>c;
  if(c=='a'||c=='e'||c=='i'||c=='o'||c=='u'){
    cout<<"vowel"<<endl;
  }
  else{
    cout<<"consonant"<<endl;
  }
}

Measured memory_bytes: 3616
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);

    char[] s = sc.next().toCharArray();
    if(s[0] == '9' || s[1] == '9'){
      System.out.println("Yes");
    }
    else{
      System.out.println("No");
    }
  }
}


Measured memory_bytes: 21588
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define ll long long
#define si(n) scanf("%d",&n);
#define PI acos(-1.0)
#define sl(n) scanf("%lld",&n);
#define sf(n) scanf("%lf",&n);
#define ss(n) scanf("%s",n);
#define for0(i,n) for(ll i=0;i<n;i++)
#define for1(i,n) for(ll i=1;i<=n;i++)
#define forc(i,j,n) for(ll i=j;i<n;i++)
#define pb push_back
#define sor(n) sort(n.begin(),n.end())
#define sorcmp(n) sort(n.begin(),n.end(),cmp)
#define rev(n) reverse(n.begin(),n.end())
#define pi(x)  printf("%d",x);
#define pl(x)  printf("%lld",x);
#define pf(x)  printf("%.10lf",x);
#define ps(x)  printf("%s",x);
#define en() printf("\n");
#define random_shuffle(r...)random_shuffle(r,[](int _){return rand()%_;})
#define SQR(a) (a)*(a)
#define sp(x) fixed<<setprecision(x)
#define mod 1000000007
#define endl '\n'
#define pii pair<int,int>
#define pll pair<ll,ll>
#define bug cout<<"Here"<<endl
void fastio(){ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);}
template <typename T> T POW(T B,T P){ if(P==0) return 1; if(P&1) return B*POW(B,P-1);  else return SQR(POW(B,P/2));}
ll powmod(ll a, ll b){ll ans = 1;while(b){if(b&1) ans = ans*a%mod;a = a*a%mod;b >>= 1;}return ans;}








bool check(ll n)
{
    for(ll i=2;i*i<=n;i++)
    {
        if(n%i==0)
        {
            return false;
        }
    }

    return true;
}



int main(){
  fastio();


   ll n;
   cin>>n;
   vector<pll>v;
   ll temp=n;
   if(n==1)
   {
       return cout<<0<<endl,0;
   }
   for(ll i=2;i*i<=n;i++)
   {
       if(n%i==0)
       {   ll cnt=0;
           while(n%i==0)
           {
               cnt++;
               n/=i;
           }
           v.pb({i,cnt});
       }


   }

   if(n>1)
   {
       v.pb({n,1});
   }

   ll ans=0;

   for(auto u:v)
   {
       ll k=1;
       while(temp>1)
       {
           if(u.second<k) break;

           temp/=POW(u.first,k);

           u.second-=k;
           k++;

       }
       ans+=k-1;
   }

   cout<<ans<<endl;




return 0;
}



Measured memory_bytes: 3548
N = int(input())
S = input()

r = S.count('R')
g = S.count('G')
b = S.count('B')

ans = r*g*b

for i in range(0,N):
  for j in range(i,N):
    k = 2*j - i
    if j < k <= N-1:
      if S[i] != S[j] and S[i] != S[k] and S[j] != S[k]:
        ans -= 1

print(ans)

Measured memory_bytes: 73668
#include<bits/stdc++.h>
using namespace std;
const int Maxn=100+7;
long long n,a[Maxn],t,m;
int main(){
	cin>>n>>m;
	for(int i=0;i<n;i++)
		cin>>a[i];
	sort(a,a+n);
        for(int i=0;i<n;i++){
       		if(m<a[i]){
			cout<<t;
			return 0;
		}
		m-=a[i];
		t++;
	//	cout<<m<<" "<<t<<endl;		
        }
	if(m!=0)
		t--;
	cout<<t;

}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>

int main(void){
    int N;
    scanf("%d", &N);

    int A1[100] = {0};
    int A2[100] = {0};
    for(int i = 0; i<N; i++){
        scanf("%d", &(A1[i]));
    }
    for(int i = 0; i<N; i++){
        scanf("%d", &(A2[i]));
    }

    unsigned long int max = 0;
    unsigned long int A1_sum = 0;
    unsigned long int A2_sum = 0;
    for(int i=0; i<N; i++){
        A1_sum += A1[i];
        A2_sum = 0;
        for(int j=i; j<N; j++){
            A2_sum += A2[j];
        }
        if(A1_sum + A2_sum > max){
            max = A1_sum + A2_sum;
        }
    }
    printf("%d", max);

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
    public static void main(String[] args){

        Scanner sc =new Scanner(System.in);

        int T[][][]=new int[4][3][10];

        int n = sc.nextInt();

        for(int i=0;i<n;i++){

            int b=sc.nextInt();
            int f=sc.nextInt();
            int r=sc.nextInt();
            int v=sc.nextInt();

            T[b-1][f-1][r-1] += v;
        }

        for(int i=0;i<4;i++){
            for(int j=0;j<3;j++){
                for(int k=0;k<10;k++){
                    System.out.print(" "+T[i][j][k]);
                  }
                  System.out.println();
            }
            if(i != 3)
                System.out.println("####################");
        }
    }
}



Measured memory_bytes: 29640
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int main()
{
    map<string, int> num;
    num["01234567"] = 0;
    queue<string> q;
    q.push("01234567");
    int k = 0;
    while(!q.empty()){
        ++ k;
        int n = q.size();
        for(int i=0; i<n; ++i){
            string s1 = q.front();
            q.pop();

            int j = s1.find('0');
            if(j < 4){
                string s2 = s1;
                swap(s2[j], s2[j+4]);
                if(num.find(s2) == num.end()){
                    q.push(s2);
                    num[s2] = k;
                }
            }else{
                string s2 = s1;
                swap(s2[j], s2[j-4]);
                if(num.find(s2) == num.end()){
                    q.push(s2);
                    num[s2] = k;
                }
            }
            if(j % 4 != 0){
                string s2 = s1;
                swap(s2[j], s2[j-1]);
                if(num.find(s2) == num.end()){
                    q.push(s2);
                    num[s2] = k;
                }
            }
            if(j % 4 != 3){
                string s2 = s1;
                swap(s2[j], s2[j+1]);
                if(num.find(s2) == num.end()){
                    q.push(s2);
                    num[s2] = k;
                }
            }
        }
    }

    for(;;){
        string s(8, ' ');
        for(int i=0; i<8; ++i){
            if(!(cin >> s[i]))
                return 0;
        }
        cout << num[s] << endl;
    }
}

Measured memory_bytes: 0
#include <iostream>
using namespace std;
int main()
{
	char b;
	cin >> b;
	if(b=='A'){
		cout << 'T' << endl;
	}
	else if(b=='T'){
		cout << 'A' << endl;
	}
	else if(b=='C'){
		cout << 'G' << endl;
	}
	else if(b=='G'){
		cout << 'C' << endl;
	}
	return 0;
}

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

int main(){
    int N,K;
    cin>>N>>K;
    vector<int> A(N);
    for(int i=0; i<N; i++){
        cin>>A[i];
    }
    int ans =0;
   for(int i=0; i<N; i++){
        if(A[i]>=K){
            ans ++;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 640
import java.util.Scanner;


public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int k = sc.nextInt();
		int ans = 0;
		
		if(k < a) {
			ans = k;
		}else {
			ans = a;
		}

		if(0 < k - a - b) {
			ans -= k - a -b;
		}

		System.out.println(ans);
		sc.close();
	}

}

Measured memory_bytes: 35800
use std::io::prelude::*;
use std::io::stdin;
use std::str::FromStr;

fn main() {
    let s: Vec<_> = read::<String>().as_bytes().to_vec();
    let t: Vec<_> = read::<String>().as_bytes().to_vec();
    println!(
        "{}",
        if s[0] == t[2] && s[1] == t[1] && s[2] == t[0] {
            "YES"
        } else {
            "NO"
        }
    );
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|b| b.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


Measured memory_bytes: 4352
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Numerics;

namespace AtCoderWorkspace
{
    public class Solver
    {
        public void Solve()
        {
            var cin = new Scanner();
            var n = cin.nextInt();
            var m = cin.nextInt();
            var a = cin.ArrayLong(m);
            var ans = n - a.Sum();
            Console.WriteLine(ans <0? -1:ans);
        }
    }

    class Scanner
    {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }

        public string next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return next();
            i = 0;
            return s[i++];
        }

        public int nextInt()
        {
            return int.Parse(next());
        }
        public int[] ArrayInt(int N, int add = 0)
        {
            int[] Array = new int[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt() + add;
            }
            return Array;
        }

        public int[] DPArrayInt(int N, int ex)
        {
            int[] Array = new int[N + ex];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt();
            }
            return Array;
        }

        public long nextLong()
        {
            return long.Parse(next());
        }

        public long[] ArrayLong(int N, long add = 0)
        {
            long[] Array = new long[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong() + add;
            }
            return Array;
        }

        public long[] DPArrayLong(int N, int ex)
        {
            long[] Array = new long[N + ex];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong();
            }
            return Array;
        }

        public double nextDouble()
        {
            return double.Parse(next());
        }


        public double[] ArrayDouble(int N, double add = 0)
        {
            double[] Array = new double[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextDouble() + add;
            }
            return Array;
        }
    }

    class Program
    {
        static void Main(string[] s) => new Solver().Solve();
    }
}


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

namespace test
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
            var N = input[0];
            var M = input[1];
            var max = M / N;
            for (int i = max; i > 0; i--)
            {
                var rem = M - N * i;
                if (rem == 0 || rem % i == 0)
                {
                    Console.WriteLine(i);
                    return;
                }
            }
        }
    }
}

Measured memory_bytes: 13396
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<ll> vl;
typedef queue<int> qi;
typedef queue<ll> ql;
typedef pair<ll,ll> pll;
typedef pair<int,ll> pil;
typedef pair<ll,int> pli;
#define pq priority_queue
#define rep(i,n) for (int i=0;i<n;++i)
#define mp make_pair
#define pb push_back
#define pf push_front
#define F first
#define S second
#define INF 200000009
#define init(x) memset(x,0,sizeof(x))
int a[100005],n,ans=0,cnt,lst;
int main ()
{
	ios::sync_with_stdio(false);
	cin>>n;
	rep(i,n) cin>>a[i];
	sort(a,a+n);
	cnt=1;
	lst=a[0];
	for (int i=1;i<n;++i){
		if (lst!=a[i]){
			if (cnt<lst) ans+=cnt;
			else if (cnt>lst) ans+=cnt-lst;
			lst=a[i];
			cnt=1;
		}
		else ++cnt;
	}
	if (cnt<lst) ans+=cnt;
	else if (cnt>lst) ans+=cnt-lst;
	cout<<ans;
	return 0; 
}

Measured memory_bytes: 640
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <iostream>
#include <stdlib.h>

using namespace std;

int main()
{
  int n;
  long long int a,b;
  cin >> n >> a >> b;

  if(n==1){
    if(a==b){
      cout << 1 << endl;
      return 0;
    }
    else{
      cout << 0 << endl;
      return 0;
    }
  }

  if(a>b){
    cout << 0 << endl;
    return 0;
  }

  cout << a + b*(n-1) - ( a*(n-1) + b ) + 1 << endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#include <unordered_map>
#include <iomanip>
//#pragma GCC optimize("Ofast")  //デバッグ時にoptimized-outされて邪魔だった
//#define _GLIBCXX_DEBUG
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
#define int ll
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define floatprec(dig) fixed << setprecision(dig)
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
#define invar(typ, var) typ var; cin >> var;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX / 2;
const ll LLINF = 1LL<<60;
constexpr ll MOD = 1000000007;
const double EPS = 1e-9;

signed main(void) {
  cin.tie(0); ios::sync_with_stdio(false);
  
  int H, W;
  cin >> H >> W;
  
  vvi edges(H*W, vi(H*W));
  
  vector<string> ss(H);
  rep(i, H) {
    cin >> ss[i];
  }
  
  rep(i, H) {
    rep(j, W) {
      if(ss[i][j] != '.') continue;
      
      if(i<H-1 && ss[i+1][j] == '.') {
        edges[i*W+j][(i+1)*W+j] = 1;
        edges[(i+1)*W+j][i*W+j] = 1;
      }
      if(j<W-1 && ss[i][j+1] == '.') {
        edges[i*W+j][i*W+j+1] = 1;
        edges[i*W+j+1][i*W+j] = 1;
      }
    }
  }
  
  //頂点ごと距離
  vvi dist(H*W, vi(H*W));
  rep(i, H*W) {
    rep(j, H*W) {
      dist[i][j] = edges[i][j] ? 1 : INF;
    }
  }
  rep(i, H*W) {
    dist[i][i] = 0;
  }
  
  //ワーシャルフロイド
  //O(N^3)
  rep(i, H*W) {
    rep(j, H*W) {
      rep(k, H*W) {
        if(dist[j][k] > dist[j][i] + dist[i][k]) {
          dist[j][k] = dist[j][i] + dist[i][k];
        }
      }
    }
  }
  
  //最大
  int maxv = 0;
  rep(i, H*W) {
    rep(j, H*W) {
      if(dist[i][j] != INF) {
        chmax(maxv, dist[i][j]);
      }
    }
  }
  
  fin(maxv);
}

Measured memory_bytes: 2816
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
    	n:usize
    }
   
    
    println!("{}", n*n*n);
}

Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <limits>
#include <string>
#include <algorithm>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include "math.h"
#include "assert.h"

using namespace std;

#define ll long long

#define BUFF ios::sync_with_stdio(false)
#define epsilon 1e-07
#define pi 2 * acos(0.0);
#define mod 1000000007   // 1e9+7
#define cerr if(false)cerr
#define watch(x) cerr << #x << " = " << x << endl;

#define inf std::numeric_limits<int>().max();

int main() {
	string s, t;
	cin >> s;
	s += "@";

	string last = s.substr(0, 1); 
	int ans = 1;
	for(int i=1; i<s.size(); i++) {
		ans++;
		t = s.substr(i, 1);
		while (t == last) {
			i++;
			t += s[i];
		}
		last = t;
	}
	ans--;
	cout << ans << endl;
}


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

using namespace std;

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

    if(S.size() >= T.size()){
        for(int i=0; i<=S.size() - T.size(); i++){
            if(T == S.substr(i, T.size())){
                printf("%d\n", i);
            }
        }
    }
    return 0;
}

Measured memory_bytes: 3996
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  int h,w,d;
  cin>>h>>w>>d;
  int ma[1000000][2];
  for(int i=1;i<=h;i++)
    for(int j=1;j<=w;j++){
      int a;
      cin>>a;
      ma[a][0]=i;
      ma[a][1]=j;
    }
  int ans[1000000]={};
  for(int i=1;i<=d;i++){
    for(int j=i+d;j<=h*w;j+=d){
      ans[j]=abs(ma[j-d][0]-ma[j][0])+abs(ma[j-d][1]-ma[j][1])+ans[j-d];
    }
  }
  int q;
  cin>>q;
  for(int i=0;i<q;i++){
    int l,r;
    cin>>l>>r;
    cout<<ans[r]-ans[l]<<endl;
  }
  return 0;  
}


Measured memory_bytes: 11776
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <cstdio>
#include <algorithm>
#include <map>
#include <queue>
using namespace std;

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

vector<ll> v;

int main() {
    int n, k; cin >> n >> k;
    rep(i, n){
        ll a; cin >> a;
        v.push_back(a);
    }

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

    ll ans = 10000000010;

    for(int i = 0; i < n - k + 1; ++i){
        ll tmp = v[i + k - 1] - v[i];
        ans = std::min(ans, tmp);
    }

    cout << ans << endl;
}

Measured memory_bytes: 1400
group1 = (1, 3, 5, 7, 8, 10, 12)
group2 = (4, 6, 9, 11)
group3 = (2,)
x, y = map(int, input().split())
if   x in group1 and y in group1:
    print('Yes')
elif x in group2 and y in group2:
    print('Yes')
elif x in group3 and y in group3:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
    ios_base::sync_with_stdio(false); cin.tie(0);
    ll k,r,z,n;cin>>n;
    
    
    
      
    
    k=n/500;
    r=n%500;
   //cout<<k<<" "<<r<<endl;
      z=r/5;
      
   // cout<<z<<endl;
    cout<<k*1000+z*5;
      }

Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <complex>
using namespace std;

#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define EPS 1e-8
#define DEB 0

int n,m,z,h;
int edge[64][64];
int edge2[200][200];
vector<pair<int,int> > v;


vector<int> calc(vector<int> a, vector<int> b){
	vector<int> ret;
	rep(i,h){
		rep(j,h){
			int sum = 0;
			rep(k,h){
				sum |= a[i*h+k]*b[k*h+j];
			}
			ret.pb(sum);
		}
	}
	return ret;
}

vector<int> multi(vector<int>& matrix, int k){
	if( k==1 ) return matrix;

	vector<int> tmp = multi(matrix,k/2);
	if( k%2 ){
		return calc(matrix,calc(tmp,tmp));
	}else{
		return calc(tmp,tmp);
	}
}

int main(){

	while(scanf(" %d%d%d ",&n,&m,&z),n|m|z){
		rep(i,64)rep(j,64)edge[i][j]=0;
		rep(i,200)rep(j,200)edge2[i][j]=0;
		
		v.clear();
		rep(i,m){
			int s,d; scanf("%d%d",&s,&d);
			edge[s][d] = edge[d][s] = 1;
		}
		REP(i,1,n+1)edge[i][i]=1;
		
		REP(i,1,n+1){
			REP(j,1,n+1)if( edge[j][i]==1 ){
				v.pb(mp(i-1,j-1));
			}
		}

		rep(i,v.size()){
			rep(j,v.size()){
				if( v[i].first!=v[j].first && v[i].first==v[j].second && v[i].second!=v[j].first ){
					edge2[i][j] = 1;
				}
			}
		}
		h = v.size();
		vector<int> mat;
		rep(i,v.size()){
			rep(j,v.size()){
				mat.pb(edge2[i][j]);
			}
		}

#if DEB
		rep(i,v.size()){
			printf("(%d,%d)\n",v[i].first, v[i].second);
		}
		rep(i,v.size()){
			rep(j,v.size()){
				printf("%d ",mat[i*h+j]);
			}
			puts("");
		}
#endif

		
		vector<int> hoge = multi(mat,z);

#if DEB
		printf("z:%d\n",z);
		rep(i,v.size()){
			rep(j,v.size()){
				printf("%d ",hoge[h*i+j]);
			}
			puts("");
		}
#endif
		bool f = false;
		rep(i,v.size())if( v[i].first==n-1 ){
			if( hoge[i]>0 ){
				f = true;
				break;
			}
		}
		puts(f?"yes":"no");
	}
	return 0;
}

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

int main(){
	double a, b, c;
	scanf("%lf%lf%lf", &a, &b, &c);
	c = c / 180 * acos(-1.0);
	printf("%.12lf\n", a*b*sin(c)/2);
	printf("%.12lf\n", a+b+sqrt(a*a+b*b-2*a*b*cos(c)));
	printf("%.12lf\n", b*sin(c));
}



Measured memory_bytes: 3428
s = gets.chomp
K =  gets.to_i
stack = []
token = false
("a".."z").each do |alf|
  # binding.pry
  s.size.times do |i|
    if s[i] == alf
      (s.size - i).times do |j|
        ub = stack.bsearch_index{|x|x > s[i,j+1]}
        lb = stack.bsearch_index{|x|x >= s[i,j+1]}
# 前提として辞書順で探索している為、空でないstackのubが配列の先頭側でnilにはなり得ない
# stackが空 or K個未満の暫定個数より上の順番 or 暫定要素と重複していない
        if stack.empty? || (stack.size < K && !ub && !lb)
          stack << s[i,j+1]
# stackがK個以上 or K個以上の暫定個数より上の順番(!ub || ub >= K)
        elsif stack.size >= K && (!ub || ub >= K)
# 現在の英小文字より辞書順で上の文字ではK番目になり得ない
          token = true
          # binding.pry
          break
# stackがK個以上且つ現在の文字列がK番目以内且つ重複していない
          elsif stack.size >= K && ub < K && ub == lb
          # binding.pry
          stack.insert(ub, s[i,j+1])
        end
      end
    end
  end
  if token
    # binding.pry
    puts stack[K - 1]
    exit
  end
end
puts stack[K - 1]

Measured memory_bytes: 3836
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::*;
#[allow(dead_code)]
fn getline() -> String {
    let mut ret = String::new();
    std::io::stdin().read_line(&mut ret).ok();
    return ret;
}
fn get_word() -> String {
    let mut stdin = std::io::stdin();
    let mut u8b: [u8; 1] = [0];
    loop {
        let mut buf: Vec<u8> = Vec::with_capacity(16);
        loop {
            let res = stdin.read(&mut u8b);
            if res.is_err() || res.ok().unwrap() == 0 || u8b[0] <= ' ' as u8 {
                break;
            } else {
                buf.push(u8b[0]);
            }
        }
        if buf.len() >= 1 {
            let ret = std::string::String::from_utf8(buf).unwrap();
            return ret;
        }
    }
}
fn parse<T: std::str::FromStr>(s: &str) -> T { s.parse::<T>().ok().unwrap() }

#[allow(dead_code)]
fn get<T: std::str::FromStr>() -> T { parse(&get_word()) }

const MOD: i64 = 1_000_000_007;
const BIAS: usize = 2010;
const W: usize = 8001;

fn inv(t: i64) -> i64 {
    let mut sum = 1;
    let mut cur = t;
    let mut e = MOD - 2;
    while e > 0 {
        if e % 2 == 1 {
            sum = sum * cur % MOD;
        }
        cur = cur * cur % MOD;
        e /= 2;
    }
    sum
}

fn main() {
    let n: usize = get();
    let mut tbl: Vec<Vec<i32>> = vec![Vec::new(); W];
    let mut inv_tbl = vec![0_i64; W + 1];
    for i in 0 .. (W + 1) {
        inv_tbl[i] = inv(i as i64);
    }
    for i in 0 .. W {
        tbl[i] = vec![0; i + 1];
        let mut t = 1;
        for j in 0 .. (i + 1) {
            tbl[i][j] = t as i32;
            t = t * (i - j) as i64 % MOD;
            t = t * inv_tbl[j + 1] % MOD;
        }
    }
    let mut f = vec![0_i64; 2 * BIAS];
    let mut dbl = 0_i64;
    let mut e: Vec<(usize, usize)> = Vec::new();
    for _ in 0 .. n {
        let a: usize = get();
        let b: usize = get();
        e.push((a + b, BIAS - a));
        dbl += tbl[2 * a + 2 * b][2 * a] as i64;
        dbl %= MOD;
    }
    e.push((0, 0));
    e.sort();
    e.reverse();
    let mut cur = 2 * BIAS;
    for (a, b) in e {
        while cur > a {
            // f *= (1 + x)
            for i in (0 .. 2 * BIAS - 1).rev() {
                f[i + 1] += f[i];
                f[i + 1] %= MOD;
            }
            cur -= 1;
        }
        if a != 0 {
            f[b] += 1;
            f[b] %= MOD;
        }
    }
    // squaring
    let mut f2 = 0;
    for i in 1 .. 2 * BIAS {
        f2 += f[2 * BIAS - i] * f[i];
        f2 %= MOD;
    }
    let mut r = (f2 - dbl + MOD) % MOD;
    r *= (MOD + 1) / 2;
    r %= MOD;
    println!("{}", r);
}


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

using namespace std;

int a[20][20];
bool check[20][20];

int w, h;
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};

int dfs(int x, int y, int cost){
    if(cost == 10){
        return 100;
    }

    int ret = 100;
    for(int i = 0; i < 4; i++){
        int tempX = x;
        int tempY = y;
        int tempDx = dx[i];
        int tempDy = dy[i];

        int firstX = tempX + tempDx;
        int firstY = tempY + tempDy;
        if(firstX == -1 || firstX == h || firstY == -1 || firstY == w){
            continue;
        }

        if(a[firstX][firstY] == 1){
            continue;
        }

        while(1){
            tempX += tempDx;
            tempY += tempDy;

            if(tempX == -1 || tempX == h || tempY == -1 || tempY == w){
                break;
            }
            else if(a[tempX][tempY] == 3){
                return cost + 1;
            }
            else if(a[tempX][tempY] == 1){
                a[tempX][tempY] = 0;
                int temp = dfs(tempX - tempDx, tempY - tempDy, cost + 1);
                if(temp < ret){
                    ret = temp;
                }
                a[tempX][tempY] = 1;
                break;
            }
        }
    }

    return ret;
}

int main(){



    while(1){
        cin >> w >> h;
        if(w == 0 && h == 0){
            break;
        }

        int sx, sy;
        int temp;
        for(int i = 0; i < h; i++){
            for(int j = 0; j < w; j++){
                cin >> temp;
                a[i][j] = temp;
                if(temp == 2){
                    sx = i;
                    sy = j;
                }
            }
        }

        int ans = dfs(sx, sy, 0);

        if(ans == 100){
            cout << -1 << endl;
        }
        else{
            cout << ans << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 3088
#include<bits/stdc++.h>
using namespace std ;
int main () {
int a,b,c ;
cin>>a>>b>>c ;
if(a==b&&b==c){
    cout<<'1';
}
else if(a!=b&&a!=c&&b!=c){
    cout<<'3';
}
else{
    cout<<'2';
}


}



Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtTest.AGC_035
{
    class A
    {
        static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(OpenStandardOutput()) { AutoFlush = false };
            SetOut(sw);

            Method(args);

            Out.Flush();
        }

        static void Method(string[] args)
        {
            int n = ReadInt();
            int[] array = ReadInts();
            Dictionary<int, int> dict = new Dictionary<int, int>();
            for (int i = 0; i < n; i++)
            {
                if (dict.ContainsKey(array[i])) dict[array[i]]++;
                else dict.Add(array[i], 1);
            }

            List<int> keys = new List<int>();
            foreach (int key in dict.Keys) keys.Add(key);

            if (keys.Count == 1)
            {
                int val = dict.First().Key;
                if (val == 0)
                {
                    WriteLine("Yes");
                    return;
                }
            }

            if (n % 3 > 0)
            {
                WriteLine("No");
                return;
            }

            if (keys.Count == 2)
            {
                if(dict.ContainsKey(0)
                    && dict[0] == n / 3)
                {
                    WriteLine("Yes");
                    return;
                }
            }

            if (keys.Count == 3)
            {
                if(keys[0]==(keys[1]^keys[2])
                    && dict[keys[0]] == n / 3 && dict[keys[1]] == n / 3)
                {
                    WriteLine("Yes");
                    return;
                }
            }

            WriteLine("No");
        }

        private static string Read() { return ReadLine(); }
        private static char[] ReadChars() { return Array.ConvertAll(Read().Split(), a => a[0]); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 21216
#include<iostream>
#include<iomanip>
#include<cassert>
#include<stdexcept>
#include<utility>
#include<functional>
#include<numeric>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<array>
#include<stack>
#include<queue>
#include<deque>
#include<vector>
#include<complex>
#include<set>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include<string>
#include<bitset>
#include<memory>
using namespace std;
using ll=long long;

const int SIZE=17;

const ll MOD=1e9+7;

inline void add(int &lhs,int rhs){
    lhs=(lhs+rhs);
    if(lhs>=MOD) lhs-=MOD;
}
int dp[41][1<<SIZE];
int isAccept[1<<SIZE];
int mypow10[40];

int main(){
    int n;
    cin>>n;
    int xyz[3];
    for(int i=0;i<3;i++) cin>>xyz[i];

    
    dp[0][(1<<SIZE)-1]=1;

    

    for(int bit=0;bit<(1<<SIZE);bit++){
        int st=0;
        int buf=0;
        for(int i=0;i<SIZE;i++){
            buf++;
            if(!((bit>>i)&1) && xyz[st]==buf){
                st++;
                buf=0;
                if(st==3){
                    isAccept[bit]=true;
                    break;
                }
            }
        }
    }

    
    mypow10[0]=1;
    for(int i=0;i+1<n;i++) mypow10[i+1]=ll(mypow10[i])*10%MOD;

    ll res=0;
    int mask=(1<<SIZE)-1;
    for(int i=0;i<n;i++){
        for(int bit=0;bit<(1<<SIZE);bit++){
            if(dp[i][bit]==0) continue;
            for(int v=1;v<=7;v++){
                int nex=(bit<<v)+(1<<(v-1))-1;
                nex&=mask;
                add(dp[i+1][nex],dp[i][bit]);
            }
            add(dp[i+1][mask],(3LL*dp[i][bit])%MOD);
        }
        for(int bit=0;bit<(1<<SIZE);bit++){
            if(isAccept[bit]){
                ll r=mypow10[n-1-i];
                res+=r*dp[i+1][bit];
                res%=MOD;   
                dp[i+1][bit]=0;
            }
        }
    }

    cout<<res<<endl;
    
    
    return 0;
}


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

int main() {
  ll N;
  cin >> N;

  ll ans = 0;
  for (int i = 1; i <= N; i++) {
    ll y = N / i;
    ll gx = (y * (y + 1) * i) / 2;
    ans += gx;
  }

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

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

int main()
{
  int a, b, c;
  cin >> a >> b >> c;
  int ans = 1e9 + 1;
  ans = min(ans, a + b);
  ans = min(ans, a + c);
  ans = min(ans, b + c);
  
  cout << ans << endl;
}

Measured memory_bytes: 256