akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
/*------------------junk----------------------*/

typedef long long int lli;
typedef unsigned long long int ulli;
const int MOD = 1e9 + 7;
#define F first
#define S second
#define gc getchar_unlocked
#define fri(i, j , n) for (auto (i) = (j); (i) < (n); ++(i))
#define frie(i, j , n) for (auto (i) = (j); (i) <= (n); ++(i))
#define frb(i,j, n) for (auto (i) = (j); (i) >= (n); (i)--)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define rall(x) (x).rbegin(),(x).rend()
#define f2a(x , n , v)  fill(&(x)[0][0], &(x)[0][0] + (0 + n) *(0 + n) , (v))
#define fa(x , n , v) fill( (x), (x)+(n), (v)) 
#define ra(a) for(int &x : (a)) cin >> (x)
#define pa(a) for(int &x : (a)) cout << (x) << " ";cout << "\n"
#define pb emplace_back
#define mp make_pair
#define vi vector<int>
#define vlli vector<lli>

/*----------check constraints again-------------*/

int32_t main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n;
  double ans = 0.0 , a;
  cin >>n;
  fri(i,0,n){
    cin >> a;
    ans+=1.0 / a;
  }
  ans = 1.0 / ans;
  cout << setprecision(16) << ans << endl;
 
}

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

int main(){
  int l, n, m;
  cin >> l >> n >> m;
  int p = INF, q = INF;
  int a[l], b[n];
  rep(i,l) {
    cin >> a[i];
    p = min(a[i],p);
  }
  rep(i,n) {
    cin >> b[i];
    q = min(b[i],q);
  }
  int ans = p + q;
  rep(i,m) {
    int x, y, c;
    cin >> x >> y >> c;
    x--; y--;
    ans = min(ans,a[x]+b[y]-c);
  }
  cout << ans << endl;
  return 0;
}


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

using namespace std;
using namespace std::chrono;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi; 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)    
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define print(x) cout << x << "\n";
#define REP(i,a,b) for(i=a;i<=b;i++)
#define RAP(i,a,b) for(i=a;i>=b;i--)
#define spa <<" "<<
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)x.size()
ll mod=1000000007;
const int MX=0x3f3f3f3f;

int main(){
    IOS;
	ll a;
	long double b;
	cin>>a>>b;
	ll c=a*b;
	cout<<c;
    return 0;
}


Measured memory_bytes: 3744
N, X, M = map(int, input().split())

if X == 0:
    print(0)
elif X == 1:
    print(N)
else:
    ans = 0
    check, dset = {}, set()

    roop = [0, 0]
    for i in range(2, M):
        j, temp, t = i**2, i, 1
        while j < M:
            temp += j
            t += 1
            j **= 2
        jump = j % M
        roop.append([temp, t, jump])

    while roop[X][1] <= N:
        check[X] = [ans, N]
        dset.add(X)
        ans += roop[X][0]
        N -= roop[X][1]
        X = roop[X][2]
        if X <= 1:
            print(ans + N*X)
            exit()
        if X in dset:
            cyc_ans = ans - check[X][0]
            cyc_N = check[X][1] - N
            ans += cyc_ans * (N//cyc_N)
            N %= cyc_N
    for i in range(N):
        ans += X
        X **= 2
    print(ans)

Measured memory_bytes: 38632
#include<iostream>
#include<string>
#include<unordered_set>
#include<set>
#include<vector>
using namespace std;
typedef unsigned long long int ull;


int main(){
  int n, m;
  std::cin >> n >> m;
  string s;
  std::cin >> s;
  ull r = 1, l = 0;
  vector<ull> vb(n + 10, 1), vh(n + 10, 0);
  ull base = 1e9 + 7;
  vh[0] = s[0];
  for (int i = 0; i < n - 1; i++) {
    vb[i + 1] = vb[i]*base;
    vh[i + 1] = vh[i]*base + s[i + 1];
  }
  ull val = s[0];
  set<ull> bucket;
  for (int i = 0; i < m; i++) {
    string ss;
    std::cin >> ss;
    if(ss == "R++"){
      val = val*base + s[r];
      r++;
    }else if(ss == "R--"){
      if(l != 0)val = vh[r - 2] - vb[r - l - 1]*vh[l - 1];
      else val = vh[r - 2];
      r--;
    }else if(ss == "L++"){
      val = val - s[l]*vb[r - l - 1];
      l++;
    }else{
      val = val + s[l - 1]*vb[r - l];
      l--;
    }
    bucket.insert(val);
  }
  std::cout << bucket.size() << std::endl;
  return 0; 
}

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

int main() {
  int s;
  cin>>s;
  
  vector<int> a(1);
  a={s};
  int N=1;
  bool X=0;
  
  for(int j=0;j<53;j--){
    if(s%2==0)
      s/=2;
    else
      s=3*s+1;
    
    a.push_back(s);
      
    for(int i=0;i<N;i++){
      if(a.at(i)==s){
        X=1;
        break;
      }
    }
    
    N++;
    
    if(X==1){
      break;
    }
  }
  cout<<N<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <valarray>
#include <map>
#include <set>
#include <list>
#include <queue>
#include <stack>
#include <bitset>
#include <utility>
#include <numeric>
#include <algorithm>
#include <functional>
#include <complex>
#include <string>
#include <sstream>

#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cmath>

using namespace std;

#define all(c) c.begin(),c.end()
#define repeat(i,n) for(int i=0;i<static_cast<int>(n);i++)
#define debug(x) #x << "=" << (x)
#define dump(x) cerr << debug(x) << " (L:" << __LINE__ << ")"<< endl

typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<string> vs;

template<typename T>
ostream& operator<<(ostream& os, const vector<T>& vec){
    os << "[";
    for(int i = 0; i < vec.size(); i++){
        os << vec[i] << ",";
    }
    os << "]";
    return os;
}

template<typename T>
T input(){
    T t;
    cin >> t;
    return t;
}

template<typename T>
vector<T> input(const int N){
    vector<T> v(N);
    repeat(i,N) cin >> v[i];
    return v;
}

long long gcd(long long a, long long b){
    if(b == 0){
        return a;
    }
    return gcd(b, a % b);
}

long long lcm(long long a, long long b){
    return (a / gcd(a, b)) * b;
}

long long mul(const long long& a, const long long& b, const long long& mod) {
    return ((a % mod) * (b % mod)) % mod;
}

long long power(const long long& x, const long long& y, const long long& mod) {
    if (y == 0) {
        return 1;
    } else if (y == 1) {
        return x % mod;
    } else {
        long long value = power(x, y / 2, mod);
        if (y % 2 == 0) {
            return mul(value, value, mod);
        } else {
            return mul(value, value, mod) * x % mod;
        }
    }
}

long long div(const long long& a, const long long& b, const long long& mod) {
    return mul(a, power(b, mod - 2, mod), mod);
}

map<long long, long long> factorials;
long long factorial(const long long& n, const long long& mod) {
    if (n == 0 || n == 1) {
        return 1;
    }
    if (factorials[n] != 0) {
        return factorials[n];
    }
    factorials[n] = n * factorial(n - 1, mod) % mod;
    return factorials[n] % mod;
}

long long combination(const long long& n, const long long& x, const long long& mod) {
    long long numerator = 1;
    long long denominator = 1;
    repeat(i, x) {
        numerator *= (n - i) % mod;
        numerator %= mod;
        denominator *= (i + 1) % mod;
        denominator %= mod;
    }
    return div(numerator, denominator, mod);
}

int main(){
    int N;
    cin >> N;
    cout << N * 800 - (N / 15) * 200 << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <vector>
#define llint long long

using namespace std;

llint n;
string s, res;
bool ans[205];

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n;
	
	cout << "? ";
	for(int i = 1; i <= n; i++) cout << i << " ";
	cout << endl;
	cin >> s;
	
	llint ub = n+1, lb = 1, mid;
	while(ub-lb > 1){
		mid = (ub+lb)/2;
		cout << "? ";
		for(int j = 0; j < n; j++) cout << mid+j << " ";
		cout << endl;
		cin >> res;
		if(s == res) lb = mid;
		else ub = mid;
	}
	
	int pos = ub;
	ans[pos-1] = true;
	ans[pos-1+n] = false;
	
	for(int i = 1; i <= 2*n; i++){
		if(i < pos-1 || i > pos-1+n){
			cout << "? ";
			for(int j = pos; j <= pos-2+n; j++) cout << j << " ";
			cout << i << endl;
		}
		else{
			cout << "? ";
			for(int j = 1; j < pos-1; j++) cout << j << " ";
			for(int j = pos+n; j <= 2*n; j++) cout << j << " ";
			cout << i << endl;
		}
		cin >> res;
		ans[i] = (s == res);
	}
	
	cout << "! ";
	for(int i = 1; i <= 2*n; i++){
		if(ans[i]) cout << s[0];
		else{
			if(s[0] == 'R') cout << "B";
			else cout << "R";
		}
	}
	cout << endl;
	
	return 0;
}

Measured memory_bytes: 724
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 1000000007
#define EPS 1e-10

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;

int prime[10000];
bool is_p[100000];

int n;

int main(){
	for (int i = 0; i <= 10000; i++) is_p[i] = 1;
	is_p[0] = is_p[1] = 0;
	/*int p = 0;*/
	for (int i = 2; i <= 10000; i++){
		if (is_p[i]){
			//prime[p++] = i;
			for (int j = i * 2; j <= 10000; j += i)is_p[j] = 0;
		}
	}
	while (cin >> n&&n){
		int p = -1, q = -1;
		for (int i = n; i > 0; i--){
			if (is_p[i] == 1){
				if (p == -1){
					p = i;
					continue;
				}
				if (q == -1){
					q = i;
					if (p - q == 2){
						cout << q << " " << p << endl;
						break;
					}
					else{
						p = q;
						q = -1;
					}
				}
			}
		}
	}
}

Measured memory_bytes: 1168
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
using namespace std;
int main(){
    int n,t;
    double a;
    long data[n];
    cin >> n;
    cin >> t >> a;
    for(int i = 0; i < n; i++){
        cin>>data[i];
    }

    double temp = t-0.006*data[0];
    double gap = abs(a - temp);
    int point = 0;
    for(int i = 0; i < n; i++){
        temp = t - 0.006*data[i];
        if(gap > abs(a - temp)){
            point = i;
            gap = abs(a - temp);
        }
    }
    cout<<point+1<<endl;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
  public static void main( String[] args ) {
	  Scanner scan = new Scanner(System.in);
	  String S_A = scan.next();
	  String S_B = scan.next();
	  String S_C = scan.next();
	  //次が誰の手番か管理する変数（A,B,Cの3つの文字を扱う）
	  String turn = "A";
	  while( true ){
		  if( turn.equals("A") ) {	//Aさんの番の場合
			  if( S_A.length() == 0 ) {
				  System.out.println("A");
				  break;
			  }else {
				  if( S_A.substring(0, 1).equals("a") ) {
					  turn = "A";
				  }else if( S_A.substring(0, 1).equals("b") ) {
					  turn = "B";
				  }else if( S_A.substring(0, 1).equals("c") ) {
					  turn = "C";
				  }
				  S_A = S_A.substring(1, S_A.length());
			  }
		  }else if( turn.equals("B") ) {	//Bさんの番の場合
			  if( S_B.length() == 0 ) {
				  System.out.println("B");
				  break;
			  }else {
				  if( S_B.substring(0, 1).equals("a") ) {
					  turn = "A";
				  }else if( S_B.substring(0, 1).equals("b") ) {
					  turn = "B";
				  }else if( S_B.substring(0, 1).equals("c") ) {
					  turn = "C";
				  }
				  S_B = S_B.substring(1, S_B.length());
			  }
		  }else if( turn.equals("C") ) {	//Cさんの番の場合
			  if( S_C.length() == 0 ) {
				  System.out.println("C");
				  break;
			  }else {
				  if( S_C.substring(0, 1).equals("a") ) {
					  turn = "A";
				  }else if( S_C.substring(0, 1).equals("b") ) {
					  turn = "B";
				  }else if( S_C.substring(0, 1).equals("c") ) {
					  turn = "C";
				  }
				  S_C = S_C.substring(1, S_C.length());
			  }
		  }
	  }
  }
}

Measured memory_bytes: 21716
#include<bits/stdc++.h>
using namespace std;
#define int long long

signed main() {
  int K,A,B;
  cin >> K;
  cin >> A >> B;

  for(int i=A; i<=B; i++) {
    if(i%K==0) {
      puts("OK");
      return 0;
    }
  }
  puts("NG");
  
}



Measured memory_bytes: 3632
import sys


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    s = str(readline().rstrip().decode('utf-8'))
    dp = [[0] * 13 for _ in range(len(s))]
    for i in range(len(s)):
        if i == 0:
            if s[-i-1] == "?":
                for j in range(10):
                    dp[i][j % 13] += 1
            else:
                t = int(s[-i-1])
                dp[i][t % 13] += 1
        else:
            md = pow(10, i, 13)
            if s[-i-1] == "?":
                for j in range(10):
                    for k in range(13):
                        dp[i][(j * md + k) % 13] += dp[i-1][k]
            else:
                t = int(s[-i-1])
                for k in range(13):
                    dp[i][(t * md + k) % 13] += dp[i - 1][k]
        for l in range(13):
            dp[i][l] %= mod
    print(dp[-1][5])


if __name__ == '__main__':
    solve()


Measured memory_bytes: 61788
(defun bit-collection (n function)
  (loop :for k :from 1 :upto (1- (expt 2 n))
          :collect(funcall function (loop :for j :from 0 :upto (1- n) :collect (logbitp j k)))))
(let* ((n (read))
       (m (read))
       (s (read))
       (lst (loop :repeat n :collect (loop :repeat (1+ m) :collect (read)))))
  (defun f (ll)
    (reduce (lambda (a b) (mapcar #'+ a b))
            (loop :for k :in ll
                  :for a :in lst
                  :if k :collect a)))
  (let* ((p (loop :for k :in (bit-collection n #'f)
                  :if (every (lambda (a) (<= s a))
                             (cdr k))
                    :collect k)))
    (if p
        (princ (loop :for q :in p
                     :minimize (car q)))
        (princ -1))))


Measured memory_bytes: 30140
import bisect, collections, copy, heapq, itertools, math, string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int, sys.stdin.readline().rstrip().split())
def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())


K = I()

B = []

#(i, j): iから始まるj桁のルンルン数の個数
lun = {(0, 1): 1, (1, 1): 1, (2, 1): 1, (3, 1): 1, (4, 1): 1, (5, 1): 1, (6, 1): 1, (7, 1): 1, (8, 1): 1, (9, 1): 1}
for j in range(2, 11):
    for i in range(10):
        if i == 0:
            lun[(i, j)] = lun[(i, j - 1)] + lun[(i + 1, j - 1)]
        elif i == 9 :
            lun[(i, j)] = lun[(i - 1, j - 1)] + lun[(i, j - 1)]
        else:
            lun[(i, j)] = lun[(i - 1, j - 1)] + lun[(i, j - 1)] + lun[(i + 1, j - 1)]

cnt = 0
for j in range(1, 10):
    for i in range(1, 10):
        cnt += lun[(i, j)]
    B.append(cnt)

b = bisect.bisect_right(B, K)

ans = []
if b == 0:
    print(K)
    exit()
if K == B[b - 1]:
    print(pow(10, b) - 1)
    exit()
else:
    K -= B[b - 1]
    i = 1
    while K > 0:
        K -= lun[(i, b + 1)]
        i += 1
    if K == 0:
        for j in range(b + 1):
            c = i - 1 + j
            if c <= 9:
                ans.append(c)
            else:
                ans.append(9)
    else:
        K += lun[(i - 1, b + 1)]
        ans.append(i - 1)
        for l in range(b):
            if ans[-1] == 0:
                k = 0
            else:
                k = ans[-1] - 1
            while K > 0:
                K -= lun[(k, b - l)]
                k += 1
            if K == 0:
                for j in range(b - l):
                    c = k - 1 + j
                    if c <= 9:
                        ans.append(c)
                    else:
                        ans.append(9)
                break
            else:
                K += lun[(k - 1, b - l)]
                ans.append(k - 1)
print(''.join(map(str, ans)))




Measured memory_bytes: 68468
#include<bits/stdc++.h>
using namespace std;
int main(){
    int ans=0,j,a,b,c;cin>>a>>b>>c;
    if(ans<a*10+b+c)ans=a*10+b+c;
    if(ans<b*10+a+c)ans=b*10+a+c;
    if(ans<c*10+a+b)ans=c*10+a+b;
    cout<<ans<<endl;
}

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

using namespace std;

#define rep(i,n) for(int i=0 ; i<(n) ; i++)
#define repr(i,n) for(int i=(n) ; i>=0 ; i--)
#define FOR(i,m,n) for(int i=(m) ; i<(n) ; i++)
#define FORR(i,m,n) for(int i=(m) ; i>=(n) ; i--)

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

typedef long long ll;
typedef unsigned long long ull;

const int INF = 1e9;

int main(){
   string s;
   cin >> s;
   string t = "CODEFESTIVAL2016";
   int ans = 0;
   for(int i=0;i<16;i++){
      if(s[i] != t[i])ans++;
   }
   cout << ans << endl;
   return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>
#include <iomanip>

#define REP(i,n) for(auto i=0;i<n;++i)
#define REPR(i,n) for(auto i=n;i>=0;--i)
#define REPI(itr,v) for(auto itr=v.begin();itr!=v.end();++itr)
#define REPIR(itr,v) for(auto itr=v.rbegin();itr!=v.rend();++itr)
#define FOR(i,a,b) for(auto i=a;i<b;++i)
#define SORT(v,n) sort(v, v+n)
#define SORTV(v) sort(v.begin(), v.end())
#define ALL(v) v.begin(),v.end()
#define llong long long
#define ll long long
#define INF 999999999
#define MOD 1000000007
#define pb push_back
#define pf push_front
#define MP make_pair
#define SV(n,v) {int tmp;for(int i=0;i<n;++i){scanf("%d",&tmp);v.push_back(tmp);}}

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

using namespace std;

typedef pair<int,int> pii;

int main(){

  double a, b;
  double h, m;
  cin >> a >> b >> h >> m;

  double angle_a, angle_b, angle;
  
  angle_a = 30 * h + m / 2;
  angle_b = 6 * m;

  angle = fabs(angle_a - angle_b);
  if(angle > 180){
    angle = 360 - angle;
  }
  double ans = a * a + b * b - 2 * a * b * cos(angle * (M_PI / 180));

  cout << setprecision(20) << sqrt(ans) << endl;
  return 0;
}



Measured memory_bytes: 4168
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] A = new int[N];
        for(int i=0;i<N;i++) A[i] = sc.nextInt();
        int[] rec= new int[N];
        for(int i=0;i<N;i++) rec[A[i]]++;
        boolean flag;
        if(N%2==1){
            flag = (rec[0]==1);
            for(int i=1;i<=N-1;i++){
                if(i%2==1) flag = flag&(rec[i]==0);
                else flag=flag&(rec[i]==2);
            }
        }else{
            flag = (rec[0]==0);
            for(int i=1;i<=N-1;i++){
                if(i%2==1) flag = flag&(rec[i]==2);
                else flag=flag&(rec[i]==0);
            }
        }
        if(!flag){
            System.out.println(0);
        }
        else{
            long ans = 1;
            long Mod = 1000000000+7;
            for(long i=1;i<=N/2;i++) ans = (ans*2)%Mod;
            System.out.println(ans);
        }
    }
}


Measured memory_bytes: 48924
#include <bits/stdc++.h>
 
using namespace std;
 
#define ALL(x) x.begin(), x.end()
 
typedef long long int lld;
typedef pair<int, int> pii;
 
const lld mod = 1e9 + 7;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.precision(15);
	cout << fixed;
 
	string s;
	cin >> s;

	vector<lld> dp(13, 0);
	reverse(ALL(s));
	lld now = 1;

	dp[0] = 1;

	for (auto &c : s) {
		vector<lld> dp_n(13, 0);

		if (isdigit(c)) {
			int n = c - '0';
			for (int i = 0; i < 13; i++) {
				dp_n[(n * now + i) % 13] = (dp_n[(n * now + i) % 13] + dp[i]) % mod;
			}
		} else {
			for (int n = 0; n < 10; n++) {
				for (int i = 0; i < 13; i++) {
					dp_n[(n * now + i) % 13] = (dp_n[(n * now + i) % 13] + dp[i]) % mod;
				}
			}
		}
		dp = dp_n;

		now *= 10;
		now %= 13;
	}

	cout << dp[5] << '\n';
	
	return 0;
}

Measured memory_bytes: 512
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<int, int> P;
typedef pair<int, P> E;
#define MOD (1000000007ll)
#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a += b;
	if(a>=MOD){
		a -= MOD;
	}
}

int main(void){
	int a,b;
	cin >> a >> b;
	cout << max(a+b,max(2*a-1,2*b-1)) << endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.LinkedList;
import java.util.Scanner;
import java.util.Vector;

public class Main 
{
	static class Tile
	{
		int x;
		int y;
		public Tile(int x0, int y0)
		{
			x=x0;
			y=y0;
		}
	}
	static boolean[][] vis;
	static long[][] scr;
	static int h,w;
	static boolean bound(int x, int y)
	{
		if(x<0 || x>=w)return false;
		if(y<0 || y>=h)return false;
		return true;
	}
	
	public static void main(String[] args) 
	{
		Scanner sc = new Scanner(System.in);
		h = sc.nextInt();
		w = sc.nextInt();
		
		vis = new boolean[w][h];
		scr = new long[w][h];
		
		LinkedList<Tile> q = new LinkedList<>();
		Vector<Tile> qq = new Vector<Tile>();
		long bl = 0;
		
		for(int y = 0; y < h; y++)
		{
			String s = sc.next();
			for(int x = 0; x < w; x++)
			{
				if(s.charAt(x) == '#')
				{
					vis[x][y] = true;
					q.add(new Tile(x,y));
					bl++;
					scr[x][y] = 0;
				}
				else scr[x][y] = 99999999;
			}
		}
		long max = 0;
		while(!q.isEmpty())
		{
			Tile t = q.pop();
			int x = t.x;
			int y = t.y;
			if(bound(x-1,y) && !vis[x-1][y])
			{
				vis[x-1][y]=true;
				scr[x-1][y]=scr[x][y]+1;
				q.add(new Tile(x-1,y));
			}
			if(bound(x+1,y) && !vis[x+1][y])
			{
				vis[x+1][y]=true;
				scr[x+1][y]=scr[x][y]+1;
				q.add(new Tile(x+1,y));
			}
			if(bound(x,y+1) && !vis[x][y+1])
			{
				vis[x][y+1]=true;
				scr[x][y+1]=scr[x][y]+1;
				q.add(new Tile(x,y+1));
			}
			if(bound(x,y-1) && !vis[x][y-1])
			{
				vis[x][y-1]=true;
				scr[x][y-1]=scr[x][y]+1;
				q.add(new Tile(x,y-1));
			}
			max = Math.max(max, scr[x][y]);
		}
		System.out.println(max);
	}

}


Measured memory_bytes: 85080
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
using namespace std;

int main(){
    int n, o;
    vector<int> a;

    cin >> n;

    for(int i = 0; i < n; i++){
        cin >> o;
        a.push_back(o);
    }
    
    reverse(a.begin(), a.end());
    for(int i = 0; i < a.size(); i++){
        if(i == a.size()-1){
            cout << a[i];
        }else{
            cout << a[i] << " ";
        }
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 3168
#include <cstdio>
#include <algorithm>
#include <iostream>

using namespace std;

int main(){
    int a[6];
    cin>>a[1]>>a[2]>>a[3];
    sort(a+1,a+1+3);
    cout<<a[1]+a[2]<<endl;
    return 0;    
}

Measured memory_bytes: 256
/*
** MergeSort
*/

# include <cstdio>
# define MAX 2000000000

const int maxn = 500000 + 10;
int s[maxn], cnt, L[maxn / 2 + 2], R[maxn / 2 + 2];

void merge(int a[], int left, int mid, int right) {
    int n1 = mid - left;
    int n2 = right - mid;
    for (int i = 0; i < n1; i++) {
        L[i] = a[left + i];
    }
    for (int i = 0; i < n2; i++) {
        R[i] = a[mid + i];
    }
    L[n1] = MAX, R[n2] = MAX;
    int i = 0, j = 0;
    for (int k = left; k < right; k++) {
        cnt++;
        if (L[i] <= R[j]) {
            a[k] = L[i++];
        }
        else
        {
            a[k] = R[j++];
        }
    }
}

void mergeSort(int a[], int left, int right) {
    if (left+1 < right) {
        int mid = (left + right) / 2;
        mergeSort(a, left, mid);
        mergeSort(a, mid, right);
        merge(a, left, mid, right);
    }
}

int main() {
    // freopen("infile", "r", stdin);
    // freopen("outfile", "w", stdout);
    int n;
    scanf("%d", &n);
    for (int i = 0; i < n; i++)
        scanf("%d", &s[i]);
    cnt = 0;
    mergeSort(s, 0, n);

    for (int i = 0; i < n-1; i++)
        printf("%d ", s[i]);
    printf("%d\n%d\n", s[n - 1], cnt);

    return 0;
}


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

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define per(i, b, a) for(int i = b - 1; i >= a; i--)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
#define hash dhsjakhd
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef long double ld;

unsigned seed = std::chrono::system_clock::now().time_since_epoch().count();
std::mt19937 eng(seed);

uniform_int_distribution<> DD(0, (1ll << 31));

ll random2(){
    return (ll(DD(eng))*(1ll << 31) + ll(DD(eng))) & ((1ll << 62ll)-1);
}

ll n,m,T,k,q;

const ll big = 1000000007;
const ll big2 = 1000000009;
const ll mod =  998244353;

const int MAXN = 200001;



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

    //freopen("input.txt","r",stdin);
   // freopen("autput.txt","w",stdout);
    ll a,b,c,d;

    cin >> n;

    rep(c1,0,n){
        rep(c2,c1+1,n){
            ll x = (c1^c2);
            ll level = 1;
            while(x%2 == 0){
                x /= 2;
                level++;
            }
            cout << level << " ";
        }cout << "\n";
    }

    return 0;
}


Measured memory_bytes: 512
//url:
//problem name: 

#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); ++i)
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long long,long long>;
using veci = vector<int>;
using vecl = vector<long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;

int main() {
    int N,T; cin >> N >> T;
    vector<P> A(N);
    REP(i,N) cin >> A[i].first >> A[i].second;
    int ans = 1e9;;
    REP(i,N) if(A[i].second <= T) {
        chmin(ans,A[i].first);
    }
    if(ans == 1e9) cout <<"TLE" << endl;
    else cout << ans << endl;
}


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

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

    int ans=0;
    for(int i=0;i<16;i++){
        if(s[i]!=t[i]) ans++;
    }

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


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

ll gcd(ll x,ll y) {return y ? gcd(y,x%y) : x;} 
ll lcm(ll x,ll y) {return x/gcd(x,y)*y;}

int main(){
    int h,w;
    cin >> h >> w;
    char c[101][101];
    int dp[101][101];
    rep(i,h+1)rep(j,w+1){
        c[i][j]='#';
        dp[i][j]=3333;
    }
    for(int i=1;i<=h;i++){
        for(int j=1;j<=w;j++){
            cin >> c[i][j];
        }
    }
    
    if(c[1][1]=='#') dp[1][1]=1;
    else dp[1][1]=0;
    
    for(int i=1;i<=h;i++){
        for(int j=1;j<=w;j++){
            if(i==1&&j==1) continue;
            int x=0,y=0;
            if(c[i][j-1]=='.'&&c[i][j]=='#') x=1;
            if(c[i-1][j]=='.'&&c[i][j]=='#') y=1;
            dp[i][j]=min(dp[i][j-1]+x,dp[i-1][j]+y);
        }
    }
    
    cout << dp[h][w] << endl;

    return 0;
}







Measured memory_bytes: 256
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int a[] = new int[N];
    for(int i=0;i<N;i++){
      a[i]=sc.nextInt();
    }
    int c[] = new int[201];
    for(int i=0;i<=200;i++){
      c[i]=calc(i-100,a);
    }
    Arrays.sort(c);
    System.out.println(c[0]);
    
  }
  public static int calc(int n,int[] a){
    int res =0;
    for(int i=0;i<a.length;i++){
      res=res+(a[i]-n)*(a[i]-n);
    }
    return res;
    
    
    
  }
  

  
}

Measured memory_bytes: 22736
#float型を許すな
#numpyはpythonで
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi,factorial
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

class WeightedUnionfind():
    def __init__(self,n):
        self.par =[i for i in range(n+1)]
        self.rank =[0]*(n+1)
        self.weight =[0]*(n+1)

    def find(self,x):
        if self.par[x]==x:
            return x

        else:
            y =self.find(self.par[x])
            self.weight[x]+=self.weight[self.par[x]]
            self.par[x]=y
            return y

    def union(self,x,y,w):
        rx=self.find(x)
        ry=self.find(y)
        if self.rank[rx]<self.rank[ry]:
            self.par[rx]=ry
            self.weight[rx]=w-self.weight[x]+self.weight[y]
        else:
            self.par[ry]=rx
            self.weight[ry]=-w-self.weight[y]+self.weight[x]
            if self.rank[rx]==self.rank[ry]:
                self.rank[rx]+=1
    def same(self,x,y):
        return self.find(x)==self.find(y)

    def diff(self,x,y):
        return self.weight[x]-self.weight[y]

n,m=MI()
wuf=WeightedUnionfind(n)
for i in range(m):
    l,r,d=MI()
    #print(l,r,d,end=" ")
    #print(wuf.same(l,r))
    if wuf.same(l,r):
        #print(wuf.diff(l,r))
        if wuf.diff(l,r)!=d:
            print("No")
            sys.exit()
    else:
        wuf.union(l,r,d)
print("Yes")



    
    



    


        


    
    


    

    
            
        
        
    
    
    
    

    
    


    
    

        
        
    


    

Measured memory_bytes: 84104
#include <stdio.h>

int main(){
	char buf[10];
	int num1;
	int num2;
	int num3;
	
		fgets(buf,10,stdin);
		sscanf(buf,"%d %d",&num1,&num2);
	
		num3 = num1 + num2;
		if(num3 >= 24)
			num3 -= 24;
		
		printf("%d\n",num3);
		
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <limits.h>
using namespace std;
typedef long long ll;

ll lcm(ll a, ll b) {
    ll aa = a, bb = b;
    if (a < b) {
    	ll tmp = a;
    	a = b;
    	b = tmp;
    }
    ll r = a % b;
    while (r != 0) {
    	a = b;
    	b = r;
    	r = a % b;
    }
    
    return aa / b * bb;
}

int main(void){
    ll n, t[105];
    cin >> n;
    for (int i = 0; i < n; i++) cin >> t[i];
    
    ll lm = t[0];
    for (int i = 1; i < n; i++) {
        lm = lcm(lm, t[i]);
    }
    
    cout << lm << endl;
    
    
}


Measured memory_bytes: 256
#include<stdio.h>
typedef struct{int Parent,Rank;}UnionFind;
static inline int Root(int x,UnionFind *uf)
{
  if(uf[x].Parent==x)return x;
  else return uf[x].Parent=Root(uf[x].Parent,uf);
}
static inline int Unite(int x,int y,UnionFind *uf)
{
  x=Root(x,uf),y=Root(y,uf);
  if(x==y)return 0;
  uf[x].Parent=y;uf[y].Rank+=uf[x].Rank;return 1;
}
static inline int Size(int x,UnionFind *uf){return uf[Root(x,uf)].Rank;}
static inline int Belong(int x,int y,UnionFind *uf){return Root(x,uf)==Root(y,uf);}
int main(void)
{
  int A,B,C,D,N,M,K,j;
  j=scanf("%d %d %d",&N,&M,&K);
  int known[N];
  UnionFind uft[N];
  for(int i=0;i<N;i++){known[i]=0;uft[i].Parent=i;uft[i].Rank=1;}
  while(M--)
  {
    j=scanf("%d %d",&A,&B);
    A--,B--;known[A]++,known[B]++;Unite(A,B,uft);
  }
  while(K--)
  {
    j=scanf("%d %d",&C,&D);
    C--,D--;if(Belong(C,D,uft))known[C]++,known[D]++;
  }
  for(int i=0;i<N;i++){printf("%d ",Size(i,uft)-known[i]-1);}
  return printf("\n"),0;
}

Measured memory_bytes: 2304
import java.math.*;
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
    static final int modnum = 1000000007;

    public static void main(String[] args) {
        ArrayList<Node> node = new ArrayList<Node>();
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();

        for (int i = 1; i <= N; i++) {
            node.add(new Node(node,i));
        }

        for (int i = 1; i < N; i++) {
            int p1 = sc.nextInt();
            int p2 = sc.nextInt();
            int length = sc.nextInt();
            node.get(p1 - 1).addEdge(p2, length);
            node.get(p2 - 1).addEdge(p1, length);
        }

        node.get(0).setParent(0, 0);

        for (int i = 0; i < N; i++) {
            System.out.println(node.get(i).isBlack ? 1:0);
        }
    }
}

class Node {
    final int number;
    boolean isLeaf = true;
    boolean isBlack = false;
    int parent = 0;

    ArrayList<Node> node;

    ArrayList<Integer> edge = new ArrayList<Integer>();
    ArrayList<Boolean> even = new ArrayList<Boolean>();

    Node(ArrayList<Node> node,int number) {
        this.node = node;
        this.number = number;
    }

    void addEdge(int n, int length) {
        edge.add(n);
        even.add(length % 2 == 0);
    }

    void setParent(int p, int odds) {
        parent = p;
        if (odds % 2 != 0)
            isBlack = true;
        for (int i = 0; i < edge.size(); i++) {
            if (edge.get(i) == p)
                continue;
            int nextodds = even.get(i) ? odds : odds + 1;
            node.get(edge.get(i) - 1).setParent(number, nextodds);
        }
    }

}

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

using namespace std;

int main(int argc, const char *argv[]) {
  int n, l;
  cin >> n >> l;
  vector<string> vs(n);
  for (int i = 0; i < n; ++i) {
    cin >> vs[i];
  }

  sort(vs.begin(), vs.end());
  string ans;
  for (int i = 0; i < vs.size(); ++i) {
    ans += vs[i];
  }

  cout << ans << '\n';

  return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#include <map>
#include <vector>
#include <string>
#include <cstdio>
#include <cmath>

using namespace std;

int main(void)
{
    int wsd[10], ko[10];
    for(int i=0; i<10; i++) cin>>wsd[i];
    for(int i=0; i<10; i++) cin>>ko[i];
    sort(wsd, wsd+10);
    sort(ko, ko+10);
    printf("%d %d\n",wsd[9]+wsd[8]+wsd[7], ko[9]+ko[8]+ko[7]);

    return 0;
}

Measured memory_bytes: 1164
#include<bits/stdc++.h>
#define ll long long int
#define pb push_back
#define ii pair<int,int>
#define setin set.insert
using namespace std;

void solve()
{
   ll n,m,k;
   cin >> n >> m >> k;
   ll a[n+10]={0},b[m+10]={0};
   ll x;
   for(int i=1;i<=n;i++)
   {
       cin >> x;
       a[i]=a[i-1]+x;
   }
   for(int i=1;i<=m;i++)
   {
       cin >> x;
       b[i]=b[i-1]+x;
   }
   int ans=0,p=0;
   for(int i=0;i<=n;i++)
   {
       for(int j=m-p;j>=0;j--)
       {
           if(a[i]+b[j]<=k)
           {
               ans=max(ans,(i+j));
               break;
           }
           p++;
       }
   }
    cout << ans << endl;

}

int main()
{

    solve();

    return 0;
}


Measured memory_bytes: 6768
#include <bits/stdc++.h>
using namespace std;
#define fol(i,n) for(int i=0;i<n;i++)
#define pb push_back
typedef long long ll;
typedef pair<int,int> P;
typedef vector<P> vip;
ll g(ll a,ll c){
    if(a==-1) return 0;
    else return a/c+1;
}
int main(){
    ll a,b,c;
    cin >>a>>b>>c;
    cout << g(b,c)-g(a-1,c)<<endl;
    return 0;
}


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

using namespace std;

int main()
{
  int a,b,c;
  cin>>a>>b>>c;
  int ans=0;
  ans = 10*a+b+c;
  if(10*b+a+c>ans)
    ans=10*b+a+c;
  if(10*c+a+b>ans)
    ans=10*c+a+b;
  cout<<ans<<endl;
}

Measured memory_bytes: 3596
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <limits.h>

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

int iin() {
    int i;
    scanf("%d", &i);
    return i;
}

long long llin() {
    long long i;
    scanf("%lld", &i);
    return i;
}

double din() {
    double i;
    scanf("%lf", &i);
    return i;
}

char cin() {
    char c;
    scanf("%c", &c);
    return c;
}

void stin(char *s) {
    scanf("%s", s);
}

void iout(int i) {
    printf("%d\n", i);
}

void llout(long long i) {
    printf("%lld\n", i);
}

void dout(double i) {
    printf("%lf\n", i);
}

void cout(char c) {
    printf("%c\n", c);
}

void stout(char *s) {
    printf("%s\n", s);
}

int dfs(int v, int n, int *visited, int table[n][n]) {
    int all_visited = 1, i;

    REP(i,n) {
        if (!visited[i]) {
            all_visited = 0;
            break;
        }
    }

    if (all_visited) {
        return 1;
    }

    int count = 0;

    REP(i,n) {
        if (!table[v][i]) continue;
        if (visited[i]) continue;

        visited[i] = 1;
        count += dfs(i, n, visited, table);
        visited[i] = 0;
    }

    return count;
}

int main() {
    int n = iin();
    char s[n];
    stin(s);
    int k = iin(), i;
    REP(i,n) {
        if (s[k - 1] != s[i]) s[i] = '*';
    }
    stout(s);
    return 0;
}


Measured memory_bytes: 128
def is_palindrome(str):
  return True if str == str[::-1] else False

S1 = input()
N = len(S1)
S2 = S1[:(N - 1) // 2]
S3 = S1[(N + 3) // 2 - 1:]
is_stroing_palindrome = all([is_palindrome(S1), is_palindrome(S2), is_palindrome(S2)])

print('Yes') if is_stroing_palindrome else print('No')


Measured memory_bytes: 3060
//I read the news today, oh boy
//About a lucky man who made the grade
 
#include <vector>
#include <iostream>
#include <set>
#include <map>
#include <algorithm>
#include <queue>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz(x) int((x).size())
#define all(v) (v).begin(),(v).end()
#define trace(x) cerr << #x << " = " << x << endl
#define fastio ios_base::sync_with_stdio(0);cin.tie(0)
#define For(i,a,b) for(int i = int(a); i < int(b); ++i)
#define roF(i,a,b) for(int i = int(a); i >= int(b); i--)
using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

const int N=1e6;


int main(){
	fastio;
	int a, b; cin>>a>>b;
	int ans = a*b;
	if(a<10 && b<10){
		cout<<ans<<endl;
		return 0;
	}
	cout<<-1<<endl;
	return 0;
}

Measured memory_bytes: 256
N = int(input())


def conv3570(p):
  D = [0, 3, 5, 7]
  ans = 0
  i = 0
  while p > 0:
    ans += D[p % 4] * 10**i
    p //= 4
    i += 1
  return ans

p = 0
q = 0
ans = 0
while q <= N:
  q_str = str(q)
  if q_str.count("0") == 0 and q_str.count("3") > 0 and q_str.count("5") > 0 and q_str.count("7") > 0:
    ans += 1
  p += 1
  q = conv3570(p)
  
print(ans)
  

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

using namespace std;

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

    int N;
    cin >> N;
    int ans = 0;
    for (int i = 0; i < N; ++i) {
        int tmp;
        cin >> tmp;
        ans += tmp - 1;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
/**akshaykumar99**/
 
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;
 
template<typename T> using id_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update> ;
template<typename T> using id_setp = tree<pair<T,T>,null_type,less<pair<T,T>>,rb_tree_tag,tree_order_statistics_node_update> ;

#define f(i,x,n) for(i=x;i<n;i++)
#define fr(i,x,n) for(i=x;i>=n;i--)
#define pu push_back           
#define pp pop_back
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define SP(x) fixed<<setprecision(x)
#define IOS() ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 
const long long MOD=1e9+7;
const long double PI = acos(-1);
const long long INF=INT_MAX;
const long long LINF=LLONG_MAX;
const long long N=1e5+1;
 
typedef long long ll;
typedef long double ld;
 
ld dist(ld a, ld b) 
{
    return a*a + b*b;
}
int main()
{
    IOS();
   ll n;
   ld x[1005], y[1005], X, Y, d, e;
   cin>>n;
    for (int i = 0; i < n; i++) 
    {
        cin>>x[i]>>y[i];
        X += x[i]; Y += y[i];
    }
    X /= n; Y /= n;
    double P = 0.1;
    for (int i = 0; i < 30000; i++) 
    {
        int f = 0;
        d = dist(X - x[0], Y - y[0]);
        for (int j = 1; j < n; j++) 
        {
            e = dist(X - x[j], Y - y[j]);
            if (d < e) { d = e; f = j; }
        }
        X += (x[f] - X)*P;
        Y += (y[f] - Y)*P;
        P *= 0.999;
    }
    cout<<SP(12)<<sqrt(d)<<" ";
}

Measured memory_bytes: 256
//
//$$$$$$$$$$$$$$$$$$$$$$
//$$                  $$
//$$   gyoubu_oniwa   $$
//$$                  $$
//$$$$$$$$$$$$$$$$$$$$$$
//
#include<bits/stdc++.h>
using namespace std;
#define DBG(a) if(DBGDO) cout<<#a<<':'<<a<<endl;
#define PB push_back
#define EB emplace_back
#define btoe(v) (v).begin(),(v).end()
#define etob(v) (v).rbegin(),(v).rend()
#define F first
#define S second
#define SZ size()
#define pow(a,b) (pow(a,b)+0.5)

typedef unsigned long long int ulli;
typedef long long int lli;
typedef long double ldbl;
#define f(i,a,b) for(int i=(a); i<(b); ++i)
#define fr(i,a,b) for(int i=(a); i>(b); --i)
#define fl(i,a,b) for(lli i=(a); i<(b); ++i)
#define flr(i,a,b) for(lli i=(a); i>(b); --i)
#define w(x) lli x; cin>>x; while(x--) 
#define inpn(n,v,T) T n; cin>>n; vector<T> v(n); fl(i,0,n) cin>>v[i];
#define inp(n,v,T) vector<T> v(n); fl(i,0,n) cin>>v[i];

typedef pair<int,int> pii;typedef vector<int> vi;typedef vector<vi> vvi;typedef vector<pii> vpii;typedef vector<vector<pii>> vvpii;typedef pair<lli,lli> plli;typedef vector<lli> vlli;typedef vector<vlli> vvlli;typedef vector<plli> vplli;typedef vector<vector<plli>> vvplli;typedef vector<bool> vb;typedef vector<string> vs;typedef vector<vector<string>> vvs;

#define unmp unordered_map

#define PRIME ((lli)(1e9+7ll))
#define PRIME2 (998244353ll)
const lli TEN_18 = 1e18;
const lli TEN_9 = 1e9;
const lli TEN_5 = 1e5;

inline void debugORfast(int a=1,int b=1){
    if(a){
        #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
        #endif
    }
    if(b){ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
}}

template<typename T>
void print(const T &v, int begin=-1, int end=-1, int w=2)
{
	if(begin<=end){
		if(begin==-1) fl(i,0,v.SZ) cout<<setw(w)<<v[i]<<' ';
		else if(end==-1) fl(i,begin,v.SZ) cout<<setw(w)<<v[i]<<' ';
		else fl(i,begin,end) cout<<setw(w)<<v[i]<<' ';
		cout<<endl;}
	else{
		if(begin==-1) flr(i,v.SZ-1,-1) cout<<setw(w)<<v[i]<<' ';
		else if(end==-1) flr(i,begin,-1) cout<<setw(w)<<v[i]<<' ';
		else flr(i,begin,end) cout<<setw(w)<<v[i]<<' ';
		cout<<endl;
	}
}

void pans(char v){
	switch(v){
		case 'y' : cout<<"yes"<<endl; break;
		case 'n' : cout<<"no"<<endl; break;
		case 'Y' : cout<<"Yes"<<endl; break;
		case 'N' : cout<<"No"<<endl; break;
		case 'B' : cout<<"YES"<<endl; break;
		case 'S' : cout<<"NO"<<endl; break;
	}
}

int DBGDO=0;

lli brute(){
	return 0;
}

lli solve(){
    return 0;
}

int main()
{
	debugORfast(0,1);
	//w(ttt)
	{
		string s,t; cin>>s>>t;
		int c=0;
		f(i,0,s.SZ){
			if(s[i]!=t[i])c++;
		}
		cout<<c<<endl;
	}
	return 0;
}


Measured memory_bytes: 3888
#include <bits/stdc++.h>
using namespace std;
#define REP(i,x,n) for(int i=x;i<(int)n;i++)
#define rep(i,n) REP(i,0,n)
#define sp(p) cout<<setprecision(16)<<fixed<<p<<endl;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define SORT(a) sort(all(a))
#define RSORT(a) sort(rall(a))
#define UNIQ(a) unique(all(a))
#define UNIQNUM(a) UNIQ(a)-a.begin()
#define UNIQIT(a) a.erase(UNIQ(a), a.end());
#define VOUT(v,i) cout<<#v<<": ";for(int i=0;i<(int)v.size();i++){cout<<v[i]<<" ";}cout<<"\n";
#define vout(v) VOUT(v,z);
#define vmin(v) *min_element(all(v))
#define vmax(v) *max_element(all(v))
#define vsum(v) accumulate(all(v), 0LL);
#define MOUT(m,r,c) rep(i,r){rep(j,c){cout<<m[i][j]<<" ";}cout<<endl;}
#define mout(m) MOUT(m,m.size(),m[0].size())
#define debg(a) cout<<#a<<": "<<a<<endl;
#define show(a) for(cont &y:a){for(cont &x:y){cout<<x<<" ";}cout<<endl;}
#define digit(a) to_string(a).length();
template<class T>inline int out(const T &t){ print(t); putchar('\n'); return 0; }
template<class T>inline T gcd(T a,T b){if(b==0)return a; return(gcd(b,a%b));}
template<class T>inline T lcm(T a,T b){return a/gcd(a,b)*b;}
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef vector<ll> V;
// const long long MOD=1000000007;
const long long INF = 1e18;
#define EPS (1e-7)
#define PI (acos(-1))
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) { a = b; return true; }
    return false;
}
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) { a = b; return true; }
    return false;
}

const string YES = "Yes";
const string NO = "No";
#define judge(f) cout<<(f?YES:NO)<<"\n";

void solve(long long K, long long X){
    bool f = 500*K>=X;
    judge(f);
}

int main(){
    long long K;
    scanf("%lld",&K);
    long long X;
    scanf("%lld",&X);
    solve(K, X);
    return 0;
}


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

struct BIT{
  int size;
  ll t[100000];
  void init(int n){
    size=n+5;
    for(int i=0;i<=size;i++)t[i]=0;
  }
  
  ll sum(int i){
    ll res=0;
    while(0<i){
      res+=t[i];
      i-=(i&-i);
    }
    return res;
  }
  ll sum(int a,int b){
    if(a>b)return 0;
    if(a<=1)return sum(b);
    else return sum(b)-sum(a-1);
  }
  void add(int i,ll x){
    while(i<size){
      t[i]+=x;
      i+=(i&-i);
    }
  }
};

ll W,N;
BIT X,DP;

int judge(int l,int r,ll M){
  if(l==r)return -1;
  ll d=X.sum(l,r);
  if(d+(r-l)>W)return 1;
  if(d+(ll)(r-l)*M<W)return -1;
  return 0;
}

int getlower(int i,ll M){
  int left=i+1,right=N,mid;
  while(left<right){
    mid=(left+right)/2;
    if(judge(i,mid,M)==-1)left=mid+1;
    else right=mid;
  }
  return left;
}

int getupper(int i,ll M){
  int left=i+1,right=N+1,mid;
  while(right-left>1){
    mid=(left+right)/2;
    if(judge(i,mid,M)<=0)left=mid;
    else right=mid;
  }
  return left;
}

bool check(int M){
  DP.init(N+1);
  DP.add(N+1,1);
  int fi=N;
  int se=N;
  
  for(int i=N;i>=1;i--){
    if(X.sum(i,N)+N-i<=W){
      DP.add(i,1);
      continue;
    }
    while(judge(i,fi-1,M)>=0)fi--;
    while(judge(i,se,M)==1)se--;
    
    if(DP.sum(fi+1,se+1)>0)DP.add(i,1);
  }
  return (DP.sum(1)==1);
}

int main(){
  while(1){
    scanf("%lld %lld",&W,&N);
    if(W==0&&N==0)break;
    X.init(N+5);
    for(int i=1;i<=N;i++){
      ll x;
      scanf("%lld",&x);
      X.add(i,x);
    }
    
    int L=1,R=W-2,M;
    while(L<R){
      M=(L+R)/2;
      if(check(M))R=M;
      else L=M+1;
    }
    printf("%d\n",L);
    
  }
  return 0;
}

Measured memory_bytes: 4020
// https://atcoder.jp/contests/abl/tasks/abl_e
#include <atcoder/all>
#include <bits/stdc++.h>
using namespace std;
using mint = atcoder::modint998244353;
struct S {
    mint val, unit;
};
using F = int;
const F ID = -1;

// 区間に対する演算方法
S op(S a, S b) { return {a.val + b.val, a.unit + b.unit}; }
// 単位元 a⋅e = e⋅a = a
S e() { return {0, 0}; }
// f(x) を返す関数
S mapping(F f, S x) {
    if (f != ID)
        x.val = f * x.unit;
    return x;
}
// f∘g を返す関数
F composition(F f, F g) { return (f == ID ? g : f); }
// id を返す関数
F id() { return ID; }

int main() {
    int N, Q;
    cin >> N >> Q;
    vector<S> init(N);
    mint pow10 = 1;
    for (int i = N - 1; i >= 0; i--) {
        init[i] = {pow10, pow10};
        pow10 *= 10;
    }
    atcoder::lazy_segtree<S, op, e, F, mapping, composition, id> seg(init);
    while (Q--) {
        int l, r, d;
        cin >> l >> r >> d;
        seg.apply(l - 1, r, d);
        cout << seg.all_prod().val.val() << "\n";
    }
}


Measured memory_bytes: 9872
import java.util.Scanner;

public class Main {

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

		int n = sc.nextInt();
		int a = sc.nextInt();

		System.out.println((n % 500 <= a) ? "Yes" : "No");

		sc.close();
	}

}




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

using namespace std;

int main(){
    vector<int> p;

    int x, n; cin >> x >> n;
    for(int i=0;i<n;i++){
        int pp; cin >> pp; p.push_back(pp);
    }

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

    int i=0;
    for(int i=0;i<=101;i++){
        bool isFind = false;
        for(int j=0;j<p.size();j++){
            if(x-i==p[j])isFind=true;
        }
        if(!isFind){
            cout << x-i << endl;
            return 0;
        }
        isFind=false;
         for(int j=0;j<p.size();j++){
            if(x+i==p[j])isFind=true;
        }
        if(!isFind){
            cout << x+i << endl;
            return 0;
        }       
    }
    return 0;
}

Measured memory_bytes: 3632