akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
using namespace std;

//        894510
#define N 100000
#define MAX 1000000000

int main() {

    int cnt = 0;
    long long q = 1;
    while(cnt++ < 10) {
        string ans;
        stringstream ss;
        ss << "? " << q;
        cout << ss.str() << endl;
        cin >> ans;

        if(ans == "Y") {
            q *= 10;
        } else {
            goto next;
        }
    }
    next:;
    if(cnt == 11) {
        string ans = "N";
        q = 1;
        for(; ans == "N"; q *= 10) {
            cout << "? " << 2 * q << endl;
            cin >> ans;
        }

        cout << "! " << q / 10 << endl;
        exit(0);
    }

    string answer = "";
    for(int i = 0; i < to_string(q - 1).size(); i++) {
        int l = 0, r = 9;
        vector< int > used(10, 0);
        while(l < r) {
            string ans;
            stringstream ss;

            int mid = (l + r) / 2.0;
            if(used[mid]++) mid++;
            string temp;
            if(i == to_string(q - 1).size() - 1) {
                temp = answer + to_string(mid);
                temp += "0";
            } else {
                temp = answer + to_string(mid);
            }
            ss << "? " << temp;
            cout << ss.str() << endl;
            cin >> ans;

            if(ans == "Y") {
                if(i == to_string(q - 1).size() - 1) r = mid;
                else l = mid;
            } else {
                if(i == to_string(q - 1).size() - 1) l = mid + 1;
                else r = mid - 1;
            }
        }
        answer += to_string(l);
    }
    cout << "! " + answer << endl;
    exit(0);
}


Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(ll i=0;i<n;i++)
#define FOR(i,n1,n2) for(ll i=n1;i<n2;i++)
#define bFOR(i,n1,n2) for(ll i=n1;i>=n2;i--)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
typedef long long int ll;
typedef unsigned long long int ull; 
typedef pair<ll,ll> Pi;
typedef tuple<ll,ll,ll> Tu;
const int INF=(ll)(1LL<<30)-1;
const double INFd=100000000000.0;
const double PI=3.14151926535;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
const ll tMOD=(ll)998244353;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a, b)*b;}
int dx[4]={0,-1,0,1},dy[4]={-1,0,1,0};
int mdx[8]={0,1,0,-1,1,1,-1,-1},mdy[8]={-1,0,1,0,1,-1,1,-1};


template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}


ll k;

int main(){
  cin>>k;
  if(k%7==0)k/=7;
  ll t=1%k;
  int flag=0;
  for(int i=0;i<5000000;i++){
    if(t==0){
      flag=i+1;
      break;
    }
    t*=10;
    t+=1;
    t%=k;
  }
  if(flag==0)cout<<-1<<endl;
  else cout<<flag<<endl;
  return 0;
}

Measured memory_bytes: 3640
import numpy as np
import sys
input = sys.stdin.buffer.readline
N,C= map(int,input().split())
x, v = np.array([list(map(int,input().split())) for i in [0]*N]).T.astype(np.int64)
INF = 10**15

rx = C - x[::-1]
dx = np.zeros(N+2).astype(np.int64)
dx[N+1] = C
dx[1:-1] = x
dx = np.diff(dx)

cand = []

# not turnaround 
rv = v - dx[:-1]
rc = np.maximum.accumulate(np.cumsum(rv))
best = rc[-1]
cand.append(best)

lv = v[::-1] - dx[::-1][:-1]
lc = np.maximum.accumulate(np.cumsum(lv))
best = lc[-1]
cand.append(best)

# turnaround
first = (rc-x)[:-1] # ->,<-
second = lc[:-1][::-1] # <-
if first.size:
    cand.append(np.max(first+second))

first = (lc-rx)[:-1]
second = rc[:-1][::-1]
if first.size:
    cand.append(np.max(first+second))

cand.append(0)
print(max(cand))



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

int main(){
  ll A,B,N;
  cin>>A>>B>>N;
  if(N>=B){
    cout<<A*(B-1)/B<<endl;
  }else{
    cout<<A*N/B<<endl;
  }
}


Measured memory_bytes: 3636
def InputToInt():
    A = input().split()
    for i in range(len(A)):
        A[i] = int(A[i])
    return A
    
if __name__ == '__main__':
    N, L = InputToInt()
    if L > 0:
        print(sum(range(L+1,N+L)))
    elif N+L-1>0:
        print(sum(range(L,N+L)))
    else:
        print(sum(range(L,N+L-1)))


Measured memory_bytes: 3060
import std.stdio, std.algorithm, std.conv, std.array, std.string;

long P = 10^^9+7;

void main()
{
    auto nm = readln.split.to!(long[]);
    auto n = nm[0] > nm[1] ? nm[0] : nm[1];
    auto m = n == nm[0] ? nm[1] : nm[0];

    if (n == m || n == m+1) {
        long x = 1;
        foreach (i; 2..n+1) x = (x*i)%P;
        foreach (i; 2..m+1) x = (x*i)%P;
        if (n == m) x = (x*2)%P;
        writeln(x);
    } else {
        writeln(0);
    }
}

Measured memory_bytes: 256
n, m = map(int, input().split())
IN = [int(input()) for _ in range(m)]

# i段目が壊れているならa[i] = 1,そうでないならa[i] = 0
a = [0 for _ in range(n+1)]
for i in IN:
    a[i] = 1

# dp[i] := i段目から最上段にたどり着くまでの移動方法の数
# dp[i] = 0 (a[i] が 1)
# dp[i] = dp[i+1] + dp[i+2] (それ以外)
dp = [-1 for _ in range(n+1)]

dp[n] = 0
if a[n-1] == 1:
    dp[n-1] = 0
else:
    dp[n-1] = 1
if a[n-2] == 1:
    dp[n-2] = 0
elif dp[n-1] == 0:
    dp[n-2] = 1
else:
    dp[n-2] = 2

for i in range(n-3, -1, -1):
    if a[i] == 1:
        dp[i] = 0
    else:
        dp[i] = dp[i+1] +dp[i+2]

print(dp[0]%(10 ** 9 + 7))

Measured memory_bytes: 460824
#include <iostream>
#include <vector>

using namespace std;

int main()
{
    long long h, w;

    cin >> h >> w;

    if(h == 1 || w == 1)
    {
        cout << 1 << endl;
    }
    else
    {
        cout << (h * w + 1) / 2 << endl;
    }
}

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

int main()
{
    string S, T;
    cin >> S >> T;
    long long int i, j, count;
    count = T.size();
    for (i = 0; i <= S.size() - T.size(); i++)
    {
        long long int zantei = 0;
        for (j = 0; j < T.size(); j++)
        {
            if (S[i + j] != T[j])
            {
                zantei += 1;
            }
        }
        if (zantei < count)
        {
            count = zantei;
        }
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 3604
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<map>
#include<vector>
#include<queue>
#include<climits>
#include<set>
#include<utility>
using namespace std;
typedef long long int ll;
const ll MOD=1e9+7;

int main(){

	ll n, k, ans;
	cin >> n >> k;
	ans=k;

	for(int i=1; i<n; i++){
		ans*=(k-1);
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for (ll i = 0; i < (ll)n; i++)
#define all(x) (x).begin(), (x).end()
#define unique(x) x.erase(unique(x.begin(), x.end()), x.end());
const long long INF = 1LL << 60;
// map<int,int> mp;

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

ll h[100010];
ll dp[100010];

int main() {
  int N;
  cin >> N;
  REP(i, N) cin >> h[i];
  REP(i, N) dp[i] = INF;

  dp[0] = 0;

  // もらうDP
  //   for (int i = 1; i < N; i++) {
  //      chmin(dp[i], dp[i - 1] + abs(h[i] - h[i - 1]));

  //     if (i > 1)  chmin(dp[i], dp[i - 2] + abs(h[i] - h[i - 2]));
  //     // cout << i << "/" << dp[i] << endl;
  //   }

  // 配るDP
  for (int i = 0; i < N; i++) {
    chmin(dp[i + 1], dp[i] + abs(h[i + 1] - h[i]));
    chmin(dp[i + 2], dp[i] + abs(h[i + 2] - h[i]));
  }

  cout << dp[N - 1] << endl;
}

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

int w, h;
int dy[8]={0,1,1,1,0,-1,-1,-1}, dx[8]={-1,-1,0,1,1,1,0,-1};
char sea[50][50];

void f(int x, int y){
	sea[x][y] = '0';
	for(int i = 0;i < 8;i++){
		int nx = x + dx[i], ny = y + dy[i];
		if(nx>=0 and nx<h and ny>=0 and ny<w and sea[nx][ny]=='1'){
			// cout << nx << " " << ny << endl;
			f(nx, ny);
		}
	}
	return;
}

int main(){
	while(1){
		cin >> w >> h;
		if(w == 0 and h == 0) break;
		for(int i = 0;i < h;++i){
			for(int j = 0;j < w;++j) cin >> sea[i][j];
		}

		int ans = 0;

		for(int i = 0;i < h;++i){
			for(int j = 0;j < w;++j){
				if(sea[i][j] == '1'){
					// cout << i << j << endl;
					ans++;
					f(i, j);
				}
			}
		}

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


Measured memory_bytes: 3092
import collections
n, x, y = map(int, input().split())
d = [[0]*(i+1) for i in range(n)]
x -= 1
y -= 1
for i in range(n):
    for j in range(i+1):
        d[i][j] = min(i-j, abs(x-j)+abs(y-i)+1)
L = []
for i in range(n):
    for dd in d[i]:
        L.append(dd)
C = collections.Counter(L)
for i in range(1, n):
    print(C[i])

Measured memory_bytes: 83700
#include<stdio.h>
#include<algorithm>
using namespace std;
//NO SPECIFIED SPORTS!!!!
int p[100];
int q[100];
int main(){
	int a;
	scanf("%d",&a);
	for(int i=0;i<a*(a-1)/2;i++){
		int b,c,d,e;
		scanf("%d%d%d%d",&b,&c,&d,&e);
		b--;
		c--;
		if(d==e){
			p[b]--;
			p[c]--;
		}
		if(d<e){
			p[c]-=3;
		}
		if(e<d){
			p[b]-=3;
		}
	}
	for(int i=0;i<a;i++)q[i]=p[i];
	std::sort(p,p+a);
	for(int i=0;i<a;i++){
		printf("%d\n",lower_bound(p,p+a,q[i])-p+1);
	}
}

Measured memory_bytes: 0
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;

#define REP(i, n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i, n) for(ll i=(ll)(n-1);i>=0;i--)
#define FOR(i, a, b) for(ll i=(ll)(a); i<=(ll)(b); i++)
#define RFOR(i, a, b) for(ll i=(ll)(a);i>=(ll)(b); i--)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define INF 1000000000000
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

signed main()
{
	ll N; cin >> N;
	ll ten=1;
	ll nine=1;
	ll eight=1;
	REP(i, N){
		ten = (ten*10)%MOD;
		nine = (nine*9)%MOD;
		eight = (eight*8)%MOD;
	}
	ten = (ten-(2*nine)%MOD)%MOD;
	ten = (ten+eight)%MOD;
  	ten = (ten+2*MOD)%MOD;
	cout << ten << endl;
}


Measured memory_bytes: 3620
#include <iostream>
#include <iomanip>
#include <algorithm>

using namespace std;

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

typedef struct city {
	int i;
	int p;
	int y;
	int s;
} city;

int main(){
	int n, m;
	cin >> n >> m;
	city c[m];
	rep(i,m) {
		int p, y;
		cin >> p >> y;
		c[i].i = i;
		c[i].p = p;
		c[i].y = y;
	}
	
	sort(c, c+m, [](const city& x, const city& y) {return x.y < y.y;});
	
	int s[n+1];
	rep(i,n+1) s[i] = 0;
	rep(i,m) c[i].s = s[c[i].p]++;
	
	sort(c, c+m, [](const city& x, const city& y) {return x.i < y.i;});
	
	rep(i,m) {
		std::cout << std::setfill('0') << std::right << std::setw(6) << c[i].p;
		std::cout << std::setfill('0') << std::right << std::setw(6) << c[i].s + 1;
		cout << endl;
	}
	return 0;
}


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

int main(){
    int n, l, sum = 0, near_zero = 10000000;
    cin >> n >> l;
    for(int i = 0; i < n; i++){
        int x = l + (i+1) - 1;
        sum += x;
        if(abs(near_zero) > abs(x)) near_zero = x;
    }
    cout << sum - near_zero << endl;
    return 0;
}

Measured memory_bytes: 3480
from collections import defaultdict
N=int(input())

sq_set=set()
for i in range(1,10**3+1):
  sq_set.add(i*i)
#print(sq_set)

alist=[i for i in range(N)]
dlist=[i for i in range(N+1)]
for i in range(2,int(N**0.5)+1):
  if dlist[i]<i:
    continue
  else:
    for j in range(i**2,N+1,i):
      dlist[j]=i  
#print(dlist)

answer=1
for i in range(1,N-1):
  AB=N-i
  AB_copy=AB
  facts=defaultdict(int)
  while AB>1:
    facts[dlist[AB]]+=1
    AB//=dlist[AB]
    
  num_div=1
  for k,v in facts.items():
    num_div*=v+1
    
  #print(AB_copy,facts,num_div)
  answer+=num_div
  
print(answer)

Measured memory_bytes: 166244
def main():
    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
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

    n = int(input())
    a = list(map(int, input().split()))
    res = 0
    for i in range(n):
        if a[a[i]-1] == i+1:
            res += 1
    print(res//2)

if __name__ == '__main__':
    main()

Measured memory_bytes: 14132
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <algorithm>

using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, s, n) for (int i = (s); i <= (n); i++)
typedef long long ll;

bool binarySearch(vector<int>& array, int key, int ary_size)
{
	bool ret = false;
	int head = 0;
	int tail = ary_size - 1;

	int center = (head + tail) / 2;

	while (head <= tail) {
		if (array[center] == key) {
			ret = true;
			break;
		}
		else if (array[center] > key) {
			tail = center - 1;
		}
		else {
			head = center + 1;
		}

		center = (head + tail) / 2;
	}

	return ret;
}

int main()
{
	int n, q;
	int ans = 0;

	cin >> n;
	vector<int> S(n);
	rep(i, n) cin >> S[i];
	cin >> q;
	vector<int> T(q);
	rep(i, q) cin >> T[i];

	rep(i, q) {
		if (binarySearch(S, T[i], n)) ans++;
	}

	cout << ans << endl;

	return 0;
}



Measured memory_bytes: 3364
#include <algorithm>
#include <bits/stdc++.h>
#include <bitset>
#include <cassert>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <memory>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <vector>
using namespace std;
#define REP(i, n) for (int64_t i = 0; i < (int64_t)n; i++)
#define REP_FOR(i, a, b) for (int64_t i = (int64_t)a; i < (int64_t)b; i++)
#define REP_REV(i, a, b) for (int64_t i = (int64_t)a; i > (int64_t)b; i--)
#define FORALL(v) (v).begin(), (v).end()
#define mp(a, b) make_pair(a, b)
#define eb(x) emplace_back(x)
#define F first
#define S second
typedef long long ll;
typedef long double ld;
typedef pair<int64_t, int64_t> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<int64_t> vii;
typedef vector<vii> vvii;
const ll mod = 1e9 + 7;
const int64_t infi = 1147483600;
const ll infl = 4e18 + 5;
const char EOL = '\n';
//cout << fixed << setprecision(17) << res << endl;
const ll MOD = 998244353;
 
int main() {
    ll n, r;
    cin >> n;
    r = n /2;
    if (n % 2 == 1) r++;
    cout << r << endl;
}


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

using namespace std;

int main(){

	int n, tmp;

	cin>> n;
	for (int i = 0;i < n;i++) {
		cin >> tmp;
		if (tmp % 2 == 0 && tmp % 3 != 0 && tmp % 5 != 0) {
			cout << "DENIED" << endl;
			return 0;
		}
	}

	cout << "APPROVED" << endl;

}


Measured memory_bytes: 256
/* ****revpro**** */

#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define endl	   '\n'
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll)x.size()
#define hell        1000000007
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define repr(i,a,b) for(ll i=b-1;i>=a;i--)    
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define mii	    map<ll,ll>
using namespace std;

#define N  100005

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int TESTS=1;
//	cin>>TESTS;
	while(TESTS--)
	{
		ll n,k;
		cin>>n>>k;
		ll a[n];
		rep(i,0,n)
		cin>>a[i];
		vi dp(n,hell);
		dp[0]=0;
		rep(i,0,n)
		{
			rep(j,1,k+1)
			{
				if(i+j>=n)
					break;
				dp[i+j]=min(dp[i+j],dp[i]+abs(a[i]-a[i+j]));
			}
		}
		cout<<dp[n-1];
	}
	return 0;
}

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

int main() {
	ios::sync_with_stdio(0);cin.tie(0);
	int n;
	cin >> n;
	vector<int> v(n);
	for(int i=0; i<n; i++) {
		cin >> v[i];
	}
	sort(v.begin(), v.end());
	int m = n/2;
	cout << v[m] - v[m-1];
}

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


int main()
{
    string s;
    int ans=0;
    cin>>s;
    for(int i=0;i<3;i++){
        if(s[i]=='R'){
            ans++;
        }

    }
    if(s[1]=='S' && ans==2) cout<<1<<endl;
    else cout<<ans<<endl;

    return 0;

}


Measured memory_bytes: 3616
// youngjinp20
// 2020 03

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

const int MAX = 1e5+1;
int N;
int arr[3][MAX];

int main() {
	cin >> N;
	for (int i=1; i<=N; i++) {
		for (int j=0; j<3; j++) {
			cin >> arr[j][i];
		}
	}

	int dp[3][MAX] = {0};

	for (int i=1; i<=N; i++) {
		for (int j=0; j<3; j++) {
			for (int k=0; k<3; k++) {
				if (j!=k) {
					dp[j][i] = max(dp[k][i-1]+arr[j][i], dp[j][i]);
				}
			}
		}
	}

	cout << max(dp[0][N], max(dp[1][N], dp[2][N]));

	return 0;
}


Measured memory_bytes: 2560
#include <cstdio>
#include <string>
#include <iostream>
#include <vector>
#include <list>
#include <cmath>
#include <iomanip>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <numeric>
#include <math.h>

typedef unsigned long long ULONG;
typedef long long LONG;
using namespace std;

#define PI 3.1415926535897932384626433
#define _DBG_

#define BIG 10000000000 //10

#define LAST 10000000 //10^7

#define MOD (LONG)(10e8 + 7)


bool check(ULONG a, ULONG b, ULONG c) {
	if (a == b || b == c || a == c) {
		return false;
	}

	if (a + b <= c || a + c <= b || b + c <= a) {
		return false;
	}

	return true;
}


int main(void) {
	int N;
	cin >> N;
	vector<ULONG> L(N);
	for (int i = 0; i < N; i++) {
		cin>>L[i];
	}

	ULONG count = 0;
	for (int i = 0; i < N; i++) {
		for (int j = i + 1; j < N; j++) {
			for (int k = j + 1; k < N; k++) {
				bool flg = check(L[i], L[j], L[k]);
				if (flg) {
					count++;
				}
			}
		}
	}
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
int main (){
  int N ;
  cin>>N;
  int sum = 0 ;
  for(int i = 0 ; i<N ;i++){
    int a , b ;
    cin>>a>>b;
    sum += (b-a+1) ;
  }
  cout<<sum<<endl;
}

Measured memory_bytes: 256
import static java.lang.Math.*;
import static  java.util.Arrays.*;
import java.io.*;
import java.util.*;

class Scanner {
    BufferedReader br;
    StringTokenizer st;
    Scanner(InputStream in) {
        br = new BufferedReader(new InputStreamReader(in));
        eat("");
    }
    void eat(String s) {
        st = new StringTokenizer(s);
    }
    String nextLine() {
        try {
            return br.readLine();
        } catch (IOException e) {
            throw new IOError(e);
        }
    }
    boolean hasNext() {
        while (!st.hasMoreTokens()) {
            String s = nextLine();
            if (s == null) return false;
            eat(s);
        }
        return true;
    }
    String next() {
        hasNext();
        return st.nextToken();
    }
    int nextInt() {
        return Integer.parseInt(next());
    }
    long nextLong() {
        return Long.parseLong(next());
    }
    double nextDouble() {
        return Double.parseDouble(next());
    }
}

public class Main {
    void run() {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] nums = new int[n];
        int[] cnt = new int[n];
        int res = 0x3f3f3f3f;
        for (int i = 0; i < n; i++)
            nums[i] = sc.nextInt();
        for (int i = 0; i < n; i++) {
            cnt[i] = Integer.lowestOneBit(nums[i]);
        }
        for (int i = 0; i < n; i++) {
            res = min(res, cnt[i]);
        }
        int ret = 0;
        while (res % 2 == 0) {
            ret++;
            res /= 2;
        }
        System.out.println(ret);
    }

    static public void main(String[] args) {
        new Main().run();
    }
}

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

int main(){
    int n;
    int A[200010];
    int minA;
    int maxV = -1000000000;
    int v;

    cin >> n;
    for (int i=0; i < n; i++) {
        cin >> A[i];
    }
    
    minA = A[0];
    for (int j=1; j < n; j++) {
       v = A[j] - minA;
       if (maxV < v) maxV = v;
       if (minA > A[j]) minA = A[j];
    }
    cout << maxV << endl;
} 


Measured memory_bytes: 3880
#include <iostream>
#include <cstring>

using namespace std;

int main() {
	// your code goes here
	int x;
	char s[101];
	int i,j,k,max, len;
	
	x = 0;
	k = x;
	cin>>len;
	cin>>s;
	for(i=0; i<len; i++){
	    
	    
	    if(s[i]=='I')
	        x++;
	    else if(s[i]=='D')
	        x--;
	   if (k < x)
	        k = x;
	}
	cout<<k;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
int a,b;
cin>>a>>b;
if(a<b){
	cout<<"a < b"<<endl;
}
else if(a>b){
	cout<<"a > b"<<endl;
}
else {
	cout<<"a == b"<<endl;
}

	

	return 0;
}


Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
#define REP(i, t) for(int i = 0; i < t; i++)
#define PR_MAX 1010

int main()
{
    int N, l[PR_MAX], r[PR_MAX];
    cin >> N;
    REP(i, N) cin >> l[i] >> r[i];

    bool is_occupied[100000] = {0};
    REP(i, N) fill(&is_occupied[l[i] -1], &is_occupied[r[i]], 1);
    cout << count(&is_occupied[0], &is_occupied[100000], 1) << endl;

    return 0;
}

Measured memory_bytes: 384
#include <stdio.h>
int n, a, x;
long long d[51][2501], ans;
int main() {
	scanf("%d%d", &n, &a);
	d[0][0] = 1;
	for (int i = 0; i < n; i++) {
		scanf("%d", &x);
		for (int i = n - 1; i >= 0; i--) {
			for (int j = 0; j <= 50 * i; j++) {
				if (d[i][j])d[i + 1][j + x] += d[i][j];
			}
		}
	}
	for (int i = 1; i <= n; i++) {
		ans += d[i][i * a];
	}
	printf("%lld\n", ans);
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define PI 3.14159265359
#define rep(i,n) for(int i=0;i<(n);i++)
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};

int main()
{
    int a, b, c, x, y;
    ll ans = 0, hoge = 0;
    cin >> a >> b >> c >> x >> y;
    ans = a * x + b * y;
    if(x<y){
        hoge = 2 * c * x + b * (y - x);
        hoge = min(hoge, (ll)(2 * c * y));
    }
    else
    {
        hoge = 2 * c * y + a * (x - y);
        hoge = min(hoge, (ll)(2 * c * x));
    }
    ans = min(ans, hoge);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3556
import numpy as np

n = int(input())
sp = [[i for i in input().split()] for i in range(n)]
sp = [i + [len(i[1])] for i in sp]
sp = [i + [j] for i, j  in zip(sp, range(n))]

sortsecond = lambda val: val[1]
sp.sort(key=sortsecond)

sortsecond = lambda val: val[2]
sp.sort(key=sortsecond)

sortsecond = lambda val: val[0]
sp.sort(key=sortsecond, reverse=True)

ans = np.array(sp[::-1])[:, 3].astype(int) + 1
for i in ans:
  print(i)

Measured memory_bytes: 13116
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <queue>
#define pye cout << "yes" << endl;
#define pno cout << "no" << endl;
#define pYe cout << "Yes" << endl;
#define pNo cout << "No" << endl;
#define pYE cout << "YES" << endl;
#define pNO cout << "NO" << endl;
#define prin(num) cout << num << endl;
#define max(a, b) ((a)>(b) ? (a):(b))
#define min(a, b) ((a)<(b) ? (a):(b))
#define INF 100000000000
#define MOD 1000000007LL
#define MAX 100100
#define MAX_N 100100
#define MAX_LOG_N 25
#define NIL -1
#define WHITE 0
#define BLACK 1
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef map<ll, ll> Map;

int main(void) {
    string s;
    cin >> s;
    ll c[26]={};
    for(ll i=0; i<s.size(); i++) {
        c[s[i]-'a']++;
    }
    ll n=s.size();
    ll ans=(n-1)*n/2+1;
    for(ll i=0; i<26; i++) {
        ans-=(c[i]-1)*c[i]/2;
    }
    
    prin(ans);
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int sum=0;
	int ans=999999999;
	int a[100010]={0};
	int n,m,x;
	int y;
	cin>>n>>m>>x;
	while(m--)
	{
		cin>>y;
		a[y]=1;
	}
	for(y=x;y>=0;y--)
	{
		sum+=a[y];
	}
	ans=min(ans,sum);
	sum=0;
	for(y=x;y<=n+1;y++)
	{
		sum+=a[y];
	}
	ans=min(ans,sum);
	cout<<ans<<endl;
}

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

signed main() {
	int n;
	cin >> n;
	double x;
	string u;
	double sum = 0;
	for (int i = 0; i < n; ++i) {
		cin >> x >> u;
		if (u == "JPY") {
			sum += x;
		}
		else {
			sum += x * 380000.0;
		}
	}
	cout << sum << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(), x.end()
#define mp make_pair
 
typedef long long ll;
typedef unsigned long long int ull;
typedef long double ld;
 
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef pair<string, string> ss;
typedef pair<int, ss> iss;
 
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<ld> vld;
typedef vector<double> vd;
typedef vector<char> vc;
typedef vector<pll> vpll;
typedef vector<pii> vpii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<pair<int, pii>> vpiii;
 
typedef map<string, string> mss;
typedef map<string, int> msi;
typedef map<int, int> mii;
typedef map<int, bool> mib;
typedef map<int, ll> mill;
typedef map<int, vpii> mivpii;

const int MAXN = 21;
const int MOD = 1e9 + 7;

int a[MAXN + 1][MAXN + 1];
int dp[(1 << MAXN) + 1];

void fast_io() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
}

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

int main() {
	fast_io();
//	freopen("input/dp_o.txt", "r", stdin);
	
	int n;
	cin >> n;
	for(int i = 0; i < n; i++) {
		for(int j = 0; j < n; j++)
			cin >> a[i][j];
	}
	
	dp[0] = 1;
	for(int i = 1; i <= n; i++)
	for(int mask = 0; mask < (1 << n); mask++) {
		if(i != __builtin_popcount(mask)) continue;
		for(int j = 0; j < n; j++) {
			if(a[i - 1][j] and (mask & (1 << j)))
				add(dp[mask], dp[mask ^ (1 << j)]);
		}
	}
	
	int FULL_MASK = (1 << n) - 1;
	cout << dp[FULL_MASK] << '\n';
	
	return 0;
}

Measured memory_bytes: 8448
#include <stdio.h>

int main(void) {
int i = 0;
int j=0;
	for(i = 1; i < 10; i++){
		for(j = 1; j < 10; j++){
			int temp = i * j;
			printf("%dx%d=%d\n", i, j, temp);
		}
	}
	return 0;
}

Measured memory_bytes: 524
N=gets.chomp.to_i
def calc(str, used)
    if str.length==N
        puts str
        return
    end
    used.each do |a|
        calc(str+a, used)
    end
    s=("a".ord+used.length).chr
    calc(str+s, (0..(used.length)).to_a.map{|i| ("a".ord+i).chr})
end
calc("a",["a"])


Measured memory_bytes: 14296
#include <iostream>
#include <vector>
#include <string.h>
#include <stack>
#include <queue>
#include <algorithm>
#include <climits>
#include <cmath>
#include <map>
#include <set>
#include <assert.h>
#include <stdio.h>
#define REP(i,n) for(ll i=0;i<(n);i++)
#define MOD 1000000007
#define int long long
#ifdef int
const long long INF = LLONG_MAX / 10;
#else
const int INF = 1010101010;
#endif
using namespace std;
typedef long long ll;
typedef vector<vector<ll> > mat;
typedef pair<int, int> P;
//typedef pair<double, double> P;
const int dx[9] = {-1, 0, 0, 1, -1, -1, 1, 1, 0};
const int dy[9] = {0, -1, 1, 0, -1, 1, -1, 1, 0};
 
int N;
int t[110], v[110];
double ul[40404]; //upper limit(0.5ずつ)

signed main()
{
  cin >> N;
  REP(i,N) cin >> t[i];
  REP(i,N) cin >> v[i];

  REP(i,40404) ul[i] = 99999.9;

  ul[0] = 0.0;
  int ulidx = 0;
  REP(i,N) {
    REP(j,2*t[i]+1) {
      ul[ulidx+j] = min(ul[ulidx+j], 1.0 * v[i]);
    }
    ulidx += t[i] * 2;
  }
  ul[ulidx++] = 0.0;

  // cout << ulidx << endl;

  //左から
  double nowspeed = 0.0;
  REP(i,ulidx) {
    ul[i] = min(ul[i], nowspeed);
    nowspeed = ul[i];
    nowspeed += 0.5;
  }

  //右から
  nowspeed = 0.0;
  for (int i=ulidx-1; i>=0; i--) {
    ul[i] = min(ul[i], nowspeed);
    nowspeed = ul[i];
    nowspeed += 0.5;
  }

  // REP(i,30) cout << ul[i] << " ";

  double ans = 0.0;
  REP(i,ulidx-1) {
    ans += 0.5 * min(ul[i], ul[i+1]);
    if (abs(ul[i] - ul[i+1]) > 0.01) {
      ans += 0.5 * 0.5 / 2.0;
    }
  }

  printf("%.10lf\n", ans);
}

Measured memory_bytes: 512
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


a = list(map(int, input().split()))
if sum(a)>21:
    ans = "bust"
else:
    ans = "win"
print(ans)

Measured memory_bytes: 61820
#include<bits/stdc++.h>
using namespace std;
#define ll int64_t
#define ul unsigned long long int
#define vi vector<int>
#define vl vector<int64_t>
#define all(x) x.begin(),x.end()
#define pb push_back
#define fo(x,a,b) for(int x=a; x<b; x++)
#define rfo(x,a,b) for(int x=a; x>=b; x--)
#define fi first
#define sec second
#define mp make_pair
int sgn(int x) { return x>0 ? 1 : ( x<0 ? -1 : 0); }
typedef pair<int,int> pairs;
double pi = 3.14159265358979323846;
ll mod = 1000000007;

void solve()
{
    int temp;
  cin>>temp;
  if(temp>=30) cout<<"Yes";
  else cout<<"No";
    cout<<"\n";
    return;
}
int main()
{
#ifdef _DEBUG
    freopen("input.txt","r",stdin);
  freopen("output.txt","w",stdout);
#endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    {
        solve();
    }
    return 0;
}

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

string rotate(string &val){
    char tmp;
    for(int i=0; i<val.size()-1;i++){
        tmp = val[0];
        val[0] = val[i+1];
        val[i+1] = tmp;
    }
    tmp = val[0];
    val[0] = tmp;
    return val;
}

int main(void){
    string obj;
    cin >> obj;
    string cor;
    cin >> cor;
    for(int i=0;i<obj.size();i++){
        if(obj.compare(cor)==0){
            cout << "Yes";
            return 0;
        }
        rotate(obj);
    }
    cout << "No";
    return 0;
}

Measured memory_bytes: 256
/*
I_Love_Trueno 
Author- darklight13
Smoke_Weed_Everyday
*/
#define _CRT_SECURE_NO_DEPRECATE
#define V__0_0__V
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double   ld;
#define SYNC std::ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define FRE freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define view(x)     cout << (#x) << " is " << (x) << endl
#define view2(x,y)     cout << (#x) <<" "<<(#y)<< " are " << (x) <<" "<<(y)<< endl
#define  pb push_back
#define  F  first
#define  S  second
#define  mp make_pair
    const ll MOD = 1e9+7;
    const ll INF = 1011111111;
    const ll LLINF = 1000111000111000111LL;
    const ld EPS = 1e-10;
    const ld PI = 3.14159265358979323;
#define all(v) (v).begin(),(v).end()
#define sz(a) (ll)((a).size())
#define sq(x) ((x)*(x))
#define pii pair<ll,ll>
#define endl '\n'
#define pow (ll)pow

int32_t main()
{
  // FRE
    SYNC
    int n,k;cin>>n>>k;
    ll h[n+1];
    for(int i=1;i<=n;i++)    cin>>h[i];
    ll dp[n+1];
    if(k>=n)
    {
        cout<<abs(h[n]-h[1]);
        exit(0);
    }
    for(int i=1;i<=k;i++)
    {
        dp[i] = abs(h[i]-h[1]);
    }
    for(int i=k+1;i<=n;i++)
    {
        dp[i]=LLINF;
        for(int j=1;j<=k;j++)
        {
            if(j>=i)
                break;
            dp[i]= min(dp[i],dp[i-j]+abs(h[i]-h[i-j]));
        }
        if(dp[i]==LLINF)
            dp[i]=0;
    }
    cout<<dp[n];
    return 0;
}

Measured memory_bytes: 1792
#include <vector>
#include <math.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <iomanip>
#include <deque>
#include <map>

typedef long long ll;
#define rep(i, a, n) for(int i = a; i<n; i++)
#define ALL(a) begin(a), end(a)
#define mii map<int, int>
#define msi map<string, int>
#define vi vector<int>
#define vl vector<ll>
#define MOD 1000000007
#define INF 1e9
#define showVector(v) rep(i,0,v.size()){p(v[i]);p(" ")} pl("")
#define p(s) std::cout << s ;
#define pl(s)  std::cout << s << endl;
using namespace std;

// 素数判定 O(√n)
bool is_prime(int n){
    for(int i = 2; i * i <= n; i++){
        if(n % i == 0) return false;
    }
    return true;
}

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;
}
int main() {
    ll N;
    cin >> N;
    vector<pair<ll, ll> > a(N);
    rep(i, 0, N) {
        cin >> a[i].first;
        cin >> a[i].second;
    }
    ll res = 0;
    for (ll i = N-1; i >= 0; --i) {
        a[i].first += res;
        res+=(a[i].second-a[i].first%a[i].second)%a[i].second;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <math.h>
#include <algorithm>
#include <vector>
#include <numeric>
using namespace std;
const double PI = acos(-1.0);
const string ALP = "abcdefghijklmnopqrstuvwxyz";
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
int main(){
  int n,m,a;
  cin >> n >> m;
  vector<int> c(n);
  REP(i,m){
    REP(j,2){
      cin >> a;
      c[--a]++;
    }
  }
  REP(i,n)cout << c[i] << endl;
  return 0;
}

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

int main(){ 
        string s,t;
        vector<int> n1(26,-1),n2(26,-1);
        cin >> s >> t;
        for(int i=0;i<s.size();i++){
                int a = s[i]-'a';
                int b = t[i]-'a';
                if(n1[a]!=-1||n2[b]!=-1){
                        if(n1[a]!=b||n2[b]!=a){
                                cout << "No";
                                return 0;
                        }
                }
                n1[a] = b;
                n2[b] = a;
        }
        cout << "Yes";
        return 0;
}

Measured memory_bytes: 776
# -*- coding: utf-8 -*-

"""
参考：https://img.atcoder.jp/abc070/editorial.pdf
・公式解が再帰だったのでやってみる
"""

import sys

# 再帰呼び出しの回数制限(デフォルト1000)
sys.setrecursionlimit(10 ** 9)

N = int(input())
nodes = [[] for _ in range(N+1)]
for i in range(N-1):
    a, b, c = map(int, input().split())
    # nodes[出発ノード](到着ノード, コスト))
    nodes[a].append((b, c))
    # 無向グラフなのでこっちも入れる
    nodes[b].append((a, c))

memo = [0] * (N+1)
def dfs(cur, prev, dist):
    memo[cur] = dist
    for nxt, cost in nodes[cur]:
        if nxt == prev:
            continue
        dfs(nxt, cur, dist+cost)

Q, K = map(int, input().split())
dfs(K, -1, 0)

for i in range(Q):
    x, y = map(int, input().split())
    # 今回は全てKを経由するので、Kからの距離さえ分かれば全部出る
    print(memo[x] + memo[y])


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

#define iota(i,n,b,s) for(int i=int(b);i!=int((b)+(s)*(n));i+=(s))
#define range(i,n,m) iota(i,(((n)>(m))?((n)-(m)):((m)-(n))),(n),((n)>(m)?-1:1))
#define rep(i,n) iota(i,(n),0,1)
#define loop for(;;)

#define INF (1e9)
#define EPS (1e-9)
#define cons(a,b) (make_pair(a,b))
#define car(a) (a.first)
#define cdr(a) (a.second)
#define cadr(a) (car(cdr(a)))
#define cddr(a) (cdr(cdr(a)))
#define all(a) a.begin(), a.end()
#define trace(var) cerr<<">>> "<<#var<<" = "<<var<<endl;

typedef long long Integer;
typedef double Real;
typedef vector<int> vi;
typedef vector<string> vs;
typedef map<string,int> Dictionary;
const Real PI = acos(-1);

template<class S, class T>
ostream& operator<<(ostream& os, pair<S,T> p) {
  os << '(' << car(p) << ", " << cdr(p) << ')';
  return os;
}

template<class T>
ostream& operator<<(ostream& os, vector<T> v) {
  if (v.size() == 0) {
    os << "(empty)";
    return os;
  }
  os << v[0];
  for (int i=1, len=v.size(); i<len; ++i) os << ' ' << v[i];
  return os;
}

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

bool* PrimeSieve(int n) {
  bool*s = new bool[n];
  for (int i = 0; i < n; ++i) s[i] = true;
  s[0] = s[1] = false;
  for (int i = 2; i < n; ++i)
    if (s[i]) for (int j = i << 1; j < n; j += i) s[j] = false;
  return s;
}

int main() {
  auto ps = PrimeSieve(1e6);
  loop {
    int a, d, n; cin >> a >> d >> n;
    if (!d) break;
    for (; n; a += d) if (ps[a]) --n;
    cout << a-d << endl;
  }
  return 0;
}

Measured memory_bytes: 2156
/*********************************************************************************\
*  _________  _      _  ________  _       _       __       ________               *
* |___   ___|| |    | ||  ______|| |     | |     /  \     |  ____  |              *
*     | |    | |    | || |______ | |_____| |    / /\ \    | |____| |              *
*     | |    | |    | ||______  ||  _____  |   / /__\ \   |  __  __|              *
*     | |    | |____| | ______| || |     | |  / ______ \  | |  \ \                *
*     |_|    |________||________||_|     |_| /_/      \_\ |_|   \_\               *
*                                                                                 *
*   Department of Computer Science & Engineering                                  *
*   Student ID : 18CSE035                                                         *
*   Bangabnadhu Sheikh Mujibur Rahman Science & Technology University,Gopalgonj.  *
*                                                                                 *
\*********************************************************************************/

//Now Write to Code ___________________________


#include <bits/stdc++.h>
using namespace std ;
 
 
typedef long long                ll;
typedef long double              ld;
typedef unsigned long long       ull;
typedef pair <int,int>           pii;
typedef pair <ll,ll>             pll;
typedef vector <int>             vi;
typedef vector <ll>              vll;
typedef vector <vector <int> >   vvi;
 
inline int    Int(){int x; cin >> x; return x;}
inline ll     Long(){ll x; cin >> x; return x;}
inline float  Float(){float x; cin >> x; return x;}
inline double Double(){double x; cin >> x; return x;}
inline void   Yes(){cout << "Yes" << endl;}
inline void   No(){cout << "No" << endl;}
inline void   YES(){cout << "YES" << endl;}
inline void   NO(){cout << "NO" << endl;}
 
const int N             =(int)2e5 + 5;
const int maxN          =(int)1e6 + 6;
const ll  Mod           =(ll)1e9 + 7;
const int inf           =(int)2e9;
const ll  Inf           =(ll)1e18;
 
#define     T           int t,q; cin >> t; for(q=1;q<=t;q++)
#define     debug(x)    cerr << #x << " = " << x << '\n' ;
#define     rep(i,b,e)  for(__typeof(e) i=(b); i!=(e+1)-2*(b > e); i =i+1-2*(b > e))
#define     Int         Int()
#define     Long        Long()
#define     Float       Float()
#define     Double      Double()
#define     all(x)      x.begin() , x.end()
#define     sz(x)       (int)x.size()
#define     ff          first
#define     ss          second
#define     pb          push_back
#define     eb          emplace_back
#define     mem(a)      memset(a , 0 ,sizeof a)
#define     memn(a)     memset(a , -1 ,sizeof a)
#define     biday       return 0 
 
 
int main(){
	int N;
	const double PI = 3.141592653589793;
	cin >> N;

	cout << showpoint;
	cout << fixed;
	cout << setprecision(20);
	cout << 2*PI*(double)N << endl;


    biday;
}
 
//...............BYE BYE................

Measured memory_bytes: 3788
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N,M;
  cin >> N >> M;
  vector<vector<char>> A(N, vector<char>(N));
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      cin >> A.at(i).at(j);
    }
  }
  vector<vector<char>> B(M, vector<char>(M));
  for (int i = 0; i < M; i++) {
    for (int j = 0; j < M; j++) {
      cin >> B.at(i).at(j);
    }
  }
  int count = 0;
  int K = 0;
  int L = 0;
  for (int i = 0; i < N+1-M; i++) {
    for (int j = 0; j < N+1-M; j++) {
      for (int k = i; k < i+M; k++) {
        for (int l = j; l < j+M; l++) {
          if (A.at(k).at(l) != B.at(K).at(L)){
            count++;
          }
          if (K == M-1 && L == M-1 && count == 0){
            cout << "Yes" << endl;
            return 0;
          }
          if (L < M-1){
            L++;
          }
          else{
            K++;
            L = 0;
          }
        }
      }
      K = 0;
      L = 0;
      count = 0;
    }
  }
  cout << "No" << endl;
}

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

int main(){
	double a,b,c,d,e,f;
	while(scanf("%lf %lf %lf %lf %lf %lf",&a,&b,&c,&d,&e,&f)!=EOF){
		double x,y;
		x = double(e*c-b*f)/(a*e-b*d);
		y = double(a*f-c*d)/(a*e-b*d);
		if(x<=0.00 && x>=-0.00400)x=0.0001;
		if(y<=0.00 && y>-0.00500)y=0.0001;
		printf("%.3lf %.3lf\n",x,y);
	}
}


Measured memory_bytes: 3248
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define mod 1000000007
#define all(v)  v.begin(),v.end()
#define pb push_back;0
ll power(ll a,ll x){if(x==0) return 1;ll y=power(a,x/2);ll ans=(y*y)%mod; if(x%2) ans=(ans*a)%mod;return ans;}
ll inv(ll a){return power(a,mod-2);}




 int main(){

 ios_base:: sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
 
 ll n,k;
 cin>>n>>k;
 

 double ans=0;
 
 for(ll i=1;i<=n;i++){
     ll power=1;
     ll temp=i;
     while(temp<k){
         temp=temp*2;
         power=power*2;
     }

     ans=ans+(1.00/(double)(power));

 }
 ans=ans/(double)n;
printf("%.15lf\n", ans);

}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<stack>
#include<queue>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
#define N 100009
#define LL long long
int head[N], tot = 0;
long long input[N];
inline long long read() {
	long long sum = 0, f = 1;char c = getchar();
	while (c > '9' || c < '0') { if (c == '-') f = -1;c = getchar(); }
	while (c <= '9' && c >= '0' || c == '.') { 
		if (c == '.') { c = getchar(); continue; }
		sum = sum * 10 + c - '0';c = getchar(); }
	return sum * f;
}
int main() {
	std::ios::sync_with_stdio(0); std::cin.tie(0);
	int n;
	long long a, b;
	a = read(), b = read();
	long long c = a * b / 100;
	cout << c;
	return 0;
}

Measured memory_bytes: 3160
#include <stdio.h>

int main() {
    int n, i, j, res = 0;

    scanf("%d", &n);

    for (i = 9; i > 0; i--) {
        j = n / i;

        if (i*j == n && j < 10) {
            res = 1;
            break;
        }
    }

    res ? printf("Yes\n") : printf("No\n");

    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define ll                  long long
#define dl                 double
#define pb                push_back
#define F                  first
#define S                  second
#define endl              "\n"
#define rep(i,a,b)       for(i=a;i<b;i++)
#define all(v)             v.begin(),v.end()
#define allr(v)            v.rbegin(),v.rend()
#define mod              1000000007
#define CIN(V,s,n)      for(int i=s;i<n;i++){cin >> V[i];}
#define COUT(V,s,n)   {for(ll i2=s;i2<n;i2++){cout <<  V[i2] << " "  ;} cout << endl;}
#define fast               ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define CLEAR(V);      for(ll i=0;i<V.size();i++) V[i] = 0;
#define N                  500005LL
#define tmod            998244353
using namespace std;

bool sBs(const pair<int,int> &a,const pair<int,int> &b)
{   if(a.first!=a.second)return (a.first < b.first);
    else return a.second > b.second;}

ll SUMD(ll n);
ll BS(vector<ll> &PS,ll s,ll e,ll ser);
ll MI(ll a, ll m);
bool P[N+1];
ll LPF[N+1];
void Sieve(int n=N);
ll Powb(ll b,ll n);

int main()
{
//fast;
ll t,q=1;
//cin >> q;
t = q;
while(q--)
{
    ll i,n,m,k,j,l,r,c=0,b,a,g,counter=0,u,v,d,e,p,x,y,flag=1;
    //n=m=i=j=l=r=a=t=b=c=u=v=w=p=x=y=0;
    cin >> m;
    ll ans  = 0;
    ll sum = 0;
    for(i=0;i<m;i++)
    {
        cin >> d >> c;
        ans += c;
        sum += c*d;
    }
    ans += (sum -1 )/9 - 1;
    cout << ans;
}
return 0;
}


ll Powb(ll b,ll n)
{
    if(n==0) return 1LL;
    if(n==1) return b;
    ll temp = Powb(b,n/2);
    if(n%2==0){return (temp*temp)%mod;}
    else{return (b*((temp*temp)%mod))%mod;}
}

ll SUMD(ll n)
{   ll sum=0;
    while(n>0){sum += n%10;n = n/10;}
    return sum;

}
ll BS(vector<ll> &PS,ll s,ll e,ll ser)
{
    if(s>e)
        return s;
    ll mid = (s+e)/2;
    if(PS[mid]==ser)
    {
        return mid;
    }
    else if(PS[mid] > ser)
    {
        return BS(PS,s,mid-1,ser);
    }
    else
        return BS(PS,mid+1,e,ser);
}
ll MI(ll a, ll m)
{
    ll m0 = m;
    ll y = 0, x = 1;
    if (m == 1)
      return 0;
    while (a > 1)
    {
        ll q = a / m;
        ll t = m;
        m = a % m, a = t;
        t = y;
        y = x - q * y;
        x = t;
    }
    if (x < 0)
       x += m0;
    return x;
}

void Sieve(int n)
{
    memset(P,true,sizeof(P));
    P[0] = false;
    P[1]= false;
    for(int i=1;i<=n;i++)
        LPF[i] = i;
    for(ll i=2;i*i<=n;i++)
    {
        if(P[i])
        {
            for(ll j=i+i;j<=n;j+=i)
            {
                P[j]=false;
                LPF[j] = i;
            }
        }
    }

}



Measured memory_bytes: 256
#include<iostream>

#define MAX 100000

typedef long long llong;
int n, k; llong T[MAX];

int check(llong P){
    int i = 0;
    for ( int j = 0; j < k; j++ ){
        llong s = 0;
        while( s + T[i] <= P ) {
            s += T[i];
            i++;
            if ( i == n ) return n;
        }
    }
    return i;
}

int solve(){
    llong left = 0;
    llong right = 100000 * 10000;
    llong mid;
    while ( right - left > 1 ) {
        mid = (left + right) / 2;
        int v = check(mid);
        if ( v >= n ) right = mid;
        else left = mid;
    }
    return right;
}

int main(){
    std::cin >> n >> k;
    for ( int i = 0; i < n; i++ ) std::cin >> T[i];
    llong ans = solve();
    std::cout << ans << std::endl;
    return 0;
}


Measured memory_bytes: 3876
from collections import defaultdict as ddic, deque, Counter
from itertools import permutations, combinations, product
import bisect, heapq

rr = raw_input
rri = lambda: int(raw_input())
rrm = lambda: map(int, raw_input().split())

def solve(N, M, gates):
    OPEN, CLOSE = 1, 0
    events = []
    for L, R in gates:
        events.append((L, OPEN))
        events.append((R+1, CLOSE))
    events.sort()

    active = prev = 0
    ans = 0
    for x, cmd in events:
        if active == M and cmd == CLOSE:
            
            ans += x - prev
        if cmd == OPEN:
            active += 1
        else:
            active -= 1
        
        prev = x
    return ans

N, M = rrm()
gates = [rrm() for _ in xrange(M)]
print solve(N, M, gates)


Measured memory_bytes: 59164
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int n;
ll sum,a[200005];
int main(){
	cin>>n;
	repn(i,n){ cin >>a[i]; sum+=a[i];}
	ll cur = 0;
	ll ans = 1e18;
	repn(i,n){
		cur += a[i];
		ans = min(ans,abs(sum-cur-cur));
	}
	cout << ans << endl;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int n, k;
int main() {
	cin>>n>>k;
	int ans = 0;
	while(n) {
		ans++;
		n /= k;
	}
	cout<<ans<<endl;
	return 0;
}
/*
11 2
Output:4

1010101 10
Output:7

314159265 3
Output:18

1000000000 2
Output:30

1 10
Output:1
*/

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

int main() {
  int N,K;
  cin >> N >> K;
  int x[N];
  for(int i=0;i<N;i++){
    cin >> x[i];
  }
  int mina=1000000000;
  for(int i=0;i<N-K+1;i++){
    int mi=min(abs(x[i])+x[i+K-1]-x[i],abs(x[i+K-1])+x[i+K-1]-x[i]);
    if(mi<mina)mina=mi;
  }
  cout << mina;
}

Measured memory_bytes: 640