akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(), (x).end())
#define ALL(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define reps(i, m, n) for (ll i = m; i < n; i++)
#define repr(i, m, n) for (ll i = m; i >= n; i--)
template <class T> bool maxi(T &a, const T &b) {
    if (a < b) { a = b; return 1;} return 0;}
template <class T> bool mini(T &a, const T &b) {
    if (b < a) { a = b; return 1;} return 0;}
#define dame {cout<< "No" <<"\n"; return;}
#define INF2 1000000000000000037
#define INF  1000000007
#define MOD  1000000007
#define PI (acos(-1))
using namespace std;
using ll = long long;
using ld = long double;
using P  = pair<ll,ll>;
//--GLOBAL---------------------------------
const int MAXX=1010;
const int MAXY=1010;
bool map2d[MAXX][MAXY];
ll depth[MAXX][MAXY];
int dx[4]={1,0,0,-1};
int dy[4]={0,1,-1,0};

vector<ll> X;
vector<ll> Y;

ll bfs(ll sx, ll sy) {
    if(map2d[sx][sy]==0 or depth[sx][sy]!=0) return 0;
    deque<P> dq;
    rep(i,X.size()) dq.emplace_back(X[i],Y[i]);
    rep(i,X.size()) depth[X[i]][Y[i]]=1; // departure: depth=1
    ll ct=0;
    while(!dq.empty()) {
        ll vx = dq.front().first;
        ll vy = dq.front().second;
        ++ct;
        dq.pop_front();
        rep(i,4){
            ll x=vx+dx[i]; ll y=vy+dy[i];
            if(x<0 or x>=MAXX or y<0 or y>=MAXY) continue;
            if(map2d[x][y]==0) continue;
            if(depth[x][y]!=0) continue;
            depth[x][y]=depth[vx][vy]+1;
            dq.emplace_back(x,y);
        }
    }
    return ct;
}

//--MAIN-----------------------------------
void Main() {
    ll H,W; cin>>H>>W;
    rep(i,H){
        rep(j,W){
            map2d[i][j]=1;
            char c; cin>>c;
            if(c=='#') X.emplace_back(i),Y.emplace_back(j);
        }
    }
    bfs(X[0],Y[0]);

    ll ans=0;
    rep(i,H){
        rep(j,W){
            maxi(ans,depth[i][j]);
        }
    }
    cout<< ans-1 <<"\n";
}
//--START----------------------------------
int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
}
//-----------------------------------------


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

typedef long long ll;
#define MOD ((ll)(1e9+7))

ll sum(int i, int j, ll* sum) {
    if (i <= 0)
        return sum[j] %MOD;
    return ((sum[j] - sum[i-1]) +MOD) %MOD;
} 

ll dp[101][100001];
ll dp_sum[101][100001];

int main() {
    int N; cin >> N;
    int K; cin >> K;
    int arr[N+1];
    for (int i=1; i<=N; i++) scanf("%d", arr+i);


    dp[0][0] = 1;
    dp_sum[0][0] = 1;
    for (int i=1; i<=K; i++) {
        dp[0][i] = 0;
        dp_sum[0][i] = 1;
    }
    

    for (int i=1; i<=N; i++) {
        for (int k=0; k<=K; k++) {
            dp[i][k] = sum(k-arr[i], k, dp_sum[i-1]);
        }

        dp_sum[i][0] = 1;
        for (int j=1; j<=K; j++)
            dp_sum[i][j] = (dp_sum[i][j-1] + dp[i][j]) %MOD;
    }

    cout << dp[N][K] << endl;

    return 0;
}

Measured memory_bytes: 158080
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
// #include <regex> //正規表現
using namespace std;
#define rep(i,a,b) for(int i=(a); i<(b); ++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define RANGE(a,b,c) (a).begin()+b,(a).begin()+c // コンテナ a の 要素 b から c へのイテレータ
#define MOD 1000000007ll
#define INF 1000000000
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;
// グリッドグラフの移動ベクトル
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

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

int N; cin >> N;
VI a(N), b(N), c(N);
rep(i, 0, N) cin >> a[i] >> b[i] >> c[i];

// 全探索は1日目が3通り，2日目以降が2通り． O(3*2^(N-1))
// dp[i][j] = i日目にjを選ぶときに得る幸福度の最大値．サイズO(3N)．
// j = 0 が a, j = 1 が b , j = 2 が c．
VVI dp(N+1, VI(3, 0));

rep(i, 1, N + 1){
    rep(j, 0, 3){
        if (j == 0){
            dp[i][0] = max(dp[i - 1][1], dp[i - 1][2]) + a[i - 1];
        }
        else if (j == 1){
            dp[i][1] = max(dp[i - 1][0], dp[i - 1][2]) + b[i - 1];
        }
        else if (j == 2){
            dp[i][2] = max(dp[i - 1][1], dp[i - 1][0]) + c[i - 1];
        }
    }
}

cout << max({dp[N][0], dp[N][1], dp[N][2]}) << "\n";
}

// 境界，出力文字列 チェック



Measured memory_bytes: 6912
package main

import "fmt"

func main() {
	var k, x int
	fmt.Scan(&k)
	fmt.Scan(&x)

	min := x - (k - 1)
	max := x + (k - 1)
	for i := min; i < max; i++ {
		fmt.Printf("%d ", i)
	}
	fmt.Println(max)
}


Measured memory_bytes: 512
//----------------------------------------------------------------------
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
//----------------------------------------------------------------------

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

int main(void) {
    int n, k;
    cin >> n >> k;

    ll ans1 = 0;
    ll ans2 = 0;
    for(int i = 1; i <= n; ++i) {
        if(i%k == 0) ans1++;
        else if(i%k == k/2) ans2++;
    }

    if(k%2==0) {
        cout << ans1 * ans1 * ans1 + ans2 * ans2 * ans2 << endl;
    }else {
        cout << ans1 * ans1 * ans1 << endl;
    }
    return 0;
}


Measured memory_bytes: 256
function main(input) {
    const parsedInput = parser(input);
    console.log(amountYearCalc(parsedInput.x));
}

function parser(inputStr) {
    const splitInput = inputStr;
    return {
        x: Number(splitInput),
    };
}

function amountYearCalc(x) {
    var i = 100;
    var count = 0;
    while (x > i) {
        i = Math.floor(i * 1.01);
        count ++;
    }
    return count;
}
// test
// const Q1 = `103`;
// const Q2 = `1000000000000000000`;
// const Q3 = `1333333333`;
// 
// main(Q1);
// main(Q2);
// main(Q3);
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 29684
# ANSHUL GAUTAM
# IIIT-D

from math import *
from copy import *					# ll = deepcopy(l)
from heapq import *					# heappush(hp,x)
from string import *				# alpha = ascii_lowercase
from random import *				# l.sort(key=lambda l1:l1[0]-l1[1]) => ex: sort on the basis difference
from bisect import *				# bisect_left(arr,x,start,end)  => start and end parameters are temporary
from sys import stdin				# bisect_left return leftmost position where x should be inserted to keep sorted
from sys import maxsize				# minn = -maxsize
from operator import *				# d = sorted(d.items(), key=itemgetter(1))
from itertools import *				# pre = [0] + list(accumulate(l))
from decimal import Decimal 		# a = Decimal(a)	# use this for math questions
from collections import Counter		# d = dict(Counter(l))
from collections import defaultdict # d = defaultdict(list)

'''
5
24 11 8 3 16
'''

def solve(l):
	n = len(l)
	l.sort()
	maxx,ans = max(l),0
	cancel,p = [0]*(maxx+1),[0]*(maxx+1)
	for i in l:
		p[i] += 1
	for i in l:
		for j in range(2*i,maxx+1,i):
			cancel[j] = 1
	for i in l:
		if(p[i] == 1 and not cancel[i]):
			ans += 1
	return ans

N = int(stdin.readline())
l = list(map(int, stdin.readline().rstrip().split()))
ans = solve(l)
print(ans)



Measured memory_bytes: 37124
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
template<class T> void chmin(T& a,const T& b){if(a>b)a=b;}
template<class T> void chmax(T& a,const T& b){if(a<b)a=b;}
#define MOD 998244353ll// prime
// How to devide :
// ModInt a(6ll);
// ModInt b(2ll);
// a *= b.exp(MOD-2ll);  -> a/=b;  result: a = 3
struct ModInt{
	ll val;
	ModInt():val(0ll){}
	ModInt(ll v):val(((v%MOD)+MOD)%MOD){}
	ModInt exp(ll y)const{
		if(!y)return ModInt(1ll);
		ModInt a = exp(y/2ll);
		a *= a;
		if(y&1)a*=(*this);
		return a;
	}
	bool operator==(const ModInt& x)const{return val==x.val;}
	inline bool operator!=(const ModInt& x)const{return !(*this==x);}
	bool operator<(const ModInt& x)const{return val<x.val;}
	bool operator>(const ModInt& x)const{return val>x.val;}
	inline bool operator>=(const ModInt& x)const{return !(*this<x);}
	inline bool operator<=(const ModInt& x)const{return !(*this>x);}
	ModInt& operator+=(const ModInt& x){if((val+=x.val)>=MOD)val-=MOD;return *this;}
	ModInt& operator-=(const ModInt& x){if((val+=MOD-x.val)>=MOD)val-=MOD;return *this;}
	ModInt& operator*=(const ModInt& x){(val*=x.val)%=MOD;return *this;}
	ModInt operator+(const ModInt& x)const{return ModInt(*this)+=x;}
	ModInt operator-(const ModInt& x)const{return ModInt(*this)-=x;}
	ModInt operator*(const ModInt& x)const{return ModInt(*this)*=x;}
};
istream& operator>>(istream&i,ModInt&x){i>>x.val;return i;}
ostream& operator<<(ostream&o,const ModInt&x){o<<x.val;return o;}
ModInt pow(ModInt a,ll x){
	ModInt res = ModInt(1ll);
	while(x){
		if(x&1)res *= a;
		x >>= 1;
		a = a*a;
	}
	return res;
}
const int SIZE = 1001000;
ModInt inv[SIZE+10],fac[SIZE+10],facinv[SIZE+10];
// notice: 0C0 = 1 
ModInt nCr(int n,int r){
	assert(!(n<r));
	assert(!(n<0||r<0));
	return fac[n]*facinv[r]*facinv[n-r];
}
void init(){
	fac[0]=ModInt(1ll);
	for(int i=1;i<=SIZE;i++)fac[i]=fac[i-1]*ModInt(i);
	inv[1]=ModInt(1ll);
	for(int i=2;i<=SIZE;i++)inv[i]=ModInt(0ll)-ModInt(MOD/i)*inv[MOD%i];
	facinv[0]=ModInt(1ll);
	for(int i=1;i<=SIZE;i++)facinv[i]=facinv[i-1]*inv[i];
	return;
}
int N;
ll A,B,K;
int main(){
	init();
	cin >> N >> A >> B >> K;
	ModInt ans;
	for(int i=0;i<=N;i++){
		ll rem = K-A*(ll)i;
		if(rem<0ll)break;
		if(rem%B!=0ll)continue;
		ll p = (ll)i,q = rem/B;
		if(q>N)continue;
		ans += nCr(N,p)*nCr(N,q);
	}
	cout << ans << endl;
  return 0;
}



Measured memory_bytes: 23808
def CountingSort(A, B, k):
	C = []
	for i in xrange(k+1):
		C.append(0)
	for j in xrange(n):
		C[A[j]] += 1
	#print C
	#for i in xrange(1,k+1):
	#	C[i] = C[i] + C[i-1]
	#print C
	for j in xrange(len(C)):
		for k in xrange(C[j]):
			B.append(j)
	return B

n = int(raw_input())
A = map(int, raw_input().split())
k = max(A)

B = []
#for i in range(len(A)):
#	B.append(0)

B = CountingSort(A, B, k)
#print B

for i in range(len(B)):
	if i != len(B)-1:
		print(B[i]),
print B[-1]

Measured memory_bytes: 177076
#include<cstdio>
#include<string>
#include<algorithm>
#include<string.h>
#include<functional>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<limits.h>
#include<iostream>
#include<functional>
#include<queue>
#define int long long
using namespace std;

int a[100000];
signed main() {
	int b; cin >> b;
	for (int c = 0; c < b; c++) {
		scanf("%lld", &a[c]);
	}
	int ans = 1 << 29;
	int sum = 0;
	int K = 0;
	for (int i = 0; i < b; i++) {
		sum += a[i];
		if (i & 1) {
			if (sum <= 0) {
				K += 1 - sum;
				sum = 1;
			}
		}
		else {
			if (sum >= 0) {
				K += sum - (-1);
				sum = -1;
			}
		}
	}
	ans = K;
	sum = 0; K = 0;
	for (int i = 0; i < b; i++) {
		sum += a[i];
		if (i %2==0) {
			if (sum <= 0) {
				K += 1 - sum;
				sum = 1;
			}
		}
		else {
			if (sum >= 0) {
				K += sum - (-1);
				sum = -1;
			}
		}
	}
	ans = min(ans, K);
	cout << ans << endl;
}

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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int main()
{
    const int a[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int K;
    cin >> K;
    cout << a[K-1] << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
 
  int n;
  cin >> n;
  int a1[100005] = {};
  int m1 = 0;
  int p1 = 0;
  int a2[100005] = {};
  int m2 = 0;
  int p2 = 0;
  for (int i = 0; i < n; i++) {
    int tmp;
    cin >> tmp;
    if (i % 2 == 0) {
      a1[tmp]++;
      if (a1[tmp] > m1) {
        m1 = a1[tmp];
        p1 = tmp;
      }
    }
    if (i % 2 == 1) {
      a2[tmp]++;
      if (a2[tmp] > m2) {
        m2 = a2[tmp];
        p2 = tmp;
      }
    }
  }
  if (p1 == p2) {
    int M1 = 0;
    int M2 = 0;
    for (int i = 0; i <= 100000; i++) {
      if (i == p1) continue;
      M1 = max(M1, a1[i]);
      M2 = max(M2, a2[i]);
    }
    cout << n - max(m1 + M2, m2 + M1) << endl;
  }
  else {
    cout << n - m1 - m2 << endl;
  }
  return 0;
}

Measured memory_bytes: 1024
N = int(input())
hs = [int(val) for val in input().split(' ')]
num = len(hs)
start_idx = None
end_idx = None
op_num = 0
last_op_idx = None
while sum(hs) > 0:
    for i in range(num):
        if hs[i] > 0:
            hs[i] -= 1
            last_op_idx = i
            if i == num - 1:
                op_num += 1
        else:
            if i >= 1 and last_op_idx == i-1:
                op_num += 1
print(op_num)


Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;

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

    long long sum = 0;
    for (int i = 1; i <= N; ++i) {
        if (i % 3 == 0 || i % 5 == 0) continue;
        sum += i;
    }

    cout << sum << endl;

    return 0;
}



Measured memory_bytes: 3624
#include<bits/stdc++.h>
#define ll long long int

using namespace std;

const ll mod=1000000007;
const ll inf=1e18;

int main(){

  ll n,q;
  cin >> n;
  ll a[n];
  ll s[100010]={};
  ll m=0;
  for(int i=0;i<n;i++){
    cin >> a[i];
    s[a[i]]++;
    m+=a[i];
  }
  cin >> q;
  ll b,c;

  for(int i=0;i<q;i++){
    cin >> b >> c;
    m=m-b*s[b]+c*s[b];
    s[c]+=s[b];
    s[b]=0;
    cout << m << endl;
  }

  


}

Measured memory_bytes: 5144
n,k= map(int,input().split())
grid=[]
gridx=set()
gridy=set()
for i in range(n):
    x,y= map(int,input().split())
    grid.append((x,y))
    gridx.add(x)
    gridy.add(y)
gridxl = sorted(gridx)
xlen = len(gridxl)
gridyl = sorted(gridy)
ylen = len(gridyl)
atable = [[0 for _ in range(ylen+1)] for _ in range(xlen+1)]
for i in range(n):
    (px,py) = grid[i]
    xid = gridxl.index(px)
    yid = gridyl.index(py)
    atable[yid+1][xid+1]=1
for i in range(1,ylen+1):
    for j in range(1,xlen+1):atable[i][j]+=atable[i][j-1]
for j in range(1,xlen+1):
    for i in range(1,ylen+1):atable[i][j]+=atable[i-1][j]
gmin = 99999999999999999999
for x1 in range(1,xlen):
    for x2 in range(x1,xlen+1):
        for y1 in range(1,ylen):
            for y2 in range(y1,ylen+1):
                a = atable[y2][x2]
                b = atable[y1-1][x2]
                c = atable[y2][x1-1]
                d = atable[y1-1][x1-1]
                rui = a - b - c + d
                if rui>=k:
                    r = (gridxl[x2-1]-gridxl[x1-1])*(gridyl[y2-1]-gridyl[y1-1])
                    if gmin>r:
                        gmin = min(gmin,r)                  
print(gmin)

Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  long int k;
  cin>>k;
  int q;
  cin>>q;
  int a[q],s[n+1]={0};
  for(int i=0;i<q;i++)
  {
    cin>>a[i];
    s[a[i]]++;
  }
  for(int j=1;j<=n;j++)
  {
    if((k-(q-s[j]))<=0)
      cout<<"No\n";
    else
      cout<<"Yes\n";
  }
  return 0;
}


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

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

    string S, T, U;
    int A, B;

    cin >> S >> T;
    cin >> A >> B;
    cin >> U;

    (U == S) ? cout << A-1 <<" "<< B : cout << A << " " << B-1;

    return 0;
}

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



int sc1() {int x; scanf("%d", &x); return x;}

long long sc2() {long long x; scanf("%lld", &x); return x;}



#define  gcd(a,b)         __gcd(a,b)
#define  lcm(a,b)         (a*b)/gcd(a,b)
#define  Int              sc1()
#define  LL               sc2()
#define  For(n)           for(int i=0;i<n;i++)
#define  Forj(n)          for(int j=0;j<n;j++)
#define  Fork(n)          for(int k=0;k<n;k++)
#define  For1(n)          for(int i=1;i<=n;i++)
#define  ll               long long
#define  vi               std::vector<int>
#define  vll              std::vector<ll>
#define  qui              qu
#define  pb               push_back
#define  mpsi             std::map<string, int>
#define  MAX              100007

int mo = 1000000007;

int dp[100006];


int F( int a,int b,int c,int d,int n ) {
	if ( n == a) return b;
	if ( n == c ) return d;
	if ( dp[n] != -1 ) return dp[n];
	else
	{
		if(dp[n-1]==-1) dp[n-1]=F(a,b,c,d,n-1);
		if(dp[n-2]==-1) dp[n-2]=F(a,b,c,d,n-2);
		dp[n]=((dp[n-1] % mo)+ (dp[n-2] % mo)) % mo;
		return dp[n];
	}
}




int main()
{

	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);

	memset(dp, -1, sizeof(dp));
	//cout << F(0, 1, 1, 1, 40) << endl;
	//cout << fib1(10) << endl;
	int n=Int,m=Int;

	int arr[m+1];

	For(m) arr[i]=Int;

	sort(arr ,arr+m);
	for(int i=0;i<m-1;i++) if(arr[i]+1==arr[i+1]) {puts("0");return 0;}
	int a=0,b=1,c=1,d=1;
	for(int i=0;i<m;i++)
	{
		int x=arr[i];
		int y = F(a,b,c,d,x-1);
		//cout<<y<<endl;
		a=x+1;b=y;
		c=x+2;d=y;

	}
	cout<<F(a,b,c,d,n)<<endl;



	return 0;
}




Measured memory_bytes: 8448
sx,sy,tx,ty=map(int,input().split())
dy=ty-sy
dx=tx-sx
print("U"*dy+"R"*dx+"D"*dy+"L"*(dx+1)+"U"*(dy+1)+"R"*(dx+1)+"DR"+"D"*(dy+1)+"L"*(dx+1)+"U")


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
int INF = 1e9+7;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
signed main() {
    string S;
    string T;
    cin >> S >> T;
    int ans = 0;
    for(int i = 0; i < S.size(); i++)  {
        if(S[i] != T[i]) {
            ans++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3916
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(x),end(x)
#define show(obj) {for(auto x:obj)cout<<x<<' ';cout<<endl;}
#define line "----------"
typedef long long ll;
typedef pair<int,int> ip;
typedef pair<ll,ll> lp;
const int inf = 1001001000;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

int d2x[2] = {0,1};
int d2y[2] = {1,0};

int main(){
	int H,W; cin>>H>>W;
	vector<vector<char>> nap(H+2,vector<char> (W+2,'.'));
	REP(i,H)REP(j,W)cin>>nap[i][j];
	queue<ip> Q;
	Q.push(make_pair(1, 1));
	nap[1][1] = '.';
	while(!Q.empty()){
		int x = Q.front().second, y = Q.front().first;
		Q.pop();
		rep(i,2){
			int dy = y + d2y[i], dx = x + d2x[i];
			if(nap[dy][dx] == '#'){
				Q.push(make_pair(dy, dx));
				nap[dy][dx] = '.';
				break;
			}
		}
	}
	REP(i,H)REP(j,W)if(nap[i][j] == '#'){cout<<"Impossible"<<endl; return 0;}
	cout<<"Possible"<<endl;
	return 0;
}

Measured memory_bytes: 256
len = int(input())
b = list(map(int,input().split()))
a = [0 for i in range(len)]

a[0] = b[0]
a[1] = b[0]
a[-1] = b[-1]
for i in range(1,len-1):
  a[i] = min(b[i-1],b[i])

print(sum(a))

Measured memory_bytes: 3064
#include <cmath>
#include <vector>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include<functional>
using  namespace std;
typedef long long ll;
#define sc(x) scanf("%d",&x)
#define pd(x) printf("%d\n",x)
const int INF=1e9+10;
const int MOD=1e9+7;
const double eps=1e-5;
const double pi=acos(-1.0);
const int N=2e5+5;
ll p,a[N],sum[N],s[N];
int n;
int lowbit(int i)
{
    return i&(-i);
}
void update(int i)
{
    while(i<=n)
    {
        sum[i]+=1;
        i+=lowbit(i);
    }
}
ll get_sum(ll i)
{
    ll ans=0;
    while(i)
    {
        ans+=sum[i];
        i-=lowbit(i);
    }
    return ans;
}
int main()
{
    while(~scanf("%d%lld",&n,&p))
    {
        memset(sum,0,sizeof(sum));
        memset(s,0,sizeof(s));
        ll ans=0,Ans=0;
        a[0]=0;
//        s[0]=0;
        for(int i=1; i<=n; i++)
        {
            scanf("%lld",&a[i]);
            a[i]-=p;
            a[i]+=a[i-1];
            s[i-1]=a[i];
            if(a[i]>=0) ans++;
        }
//        n++;
        sort(s,s+n);
        int k=unique(s,s+n)-s;
//        for(int i=n; i>=1; i--) a[i]=a[i-1];
        for(int i=1; i<=n; i++) a[i]=(lower_bound(s,s+k,a[i])-s)+1;
        for(int i=1; i<=n; i++)
        {
//            if(a[i]>=0) ans++;
            ll tmp=get_sum(a[i]);
            update(a[i]);
            ans+=tmp;//i前面小于等于a[i]的数个数
            Ans=i-1-tmp;
//        printf("i==%d a[i]==%lld tmp==%lld  ans==%lld\n",i,a[i],tmp,i-tmp);
        }
        printf("%lld\n",ans);
//        printf("%lld\n",Ans);//求逆序数
    }
    return 0;
}


Measured memory_bytes: 4992
/////////////////////////////////////////////////
//                                             //
//                 _ooOoo_                     //
//                o8888888o                    //
//                88" . "88                    //
//                (| -_- |)                    //
//             ____/`---'\\____                //
//           .'  \|     |//  `.                //
//           /  \|||  :  |||// \               //
//          /  _||||| -:- |||||- \             //
//          |   | \\  -  /// |   |             //
//          | \_|  ''\---/''  |  |             //
//          \  .-\__  `-`  ___/-. /            //
//         ___`. .'  /--.--\  `. . __          //
//      ."" '<  `.___\_<|>_/___.'  >'"".       //
//     | | :  `- \`.;`\ _ /`;.`/ - ` : | |     //
//     \  \ `-.   \_ __\ /__ _/   .-` /  /     //
//=====`-.____`-.___\_____/___.-`____.-'=======//
//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^//
//.............................................//
/////////////////////////////////////////////////

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll modn=998244353;
const ll INF = 0x3f3f3f3f;
ll a[1000],b[1000];

double dis(int i,int j){
    return sqrt((a[i]-a[j])*(a[i]-a[j])+(b[i]-b[j])*(b[i]-b[j]));
}
int main(){
    double ans = 0;
    int n;
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%lld%lld",&a[i],&b[i]);
    }
    for(int i=0;i<n;i++)for(int j=i+1;j<n;j++){
        ans += dis(i,j)/n*2;
    }
    printf("%.7lf\n",ans);

    return 0;
}
/*
5
1 2 3 4 5
5 3 2 1 4
*/


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
#include <regex>
#include <string>
#include <cstdlib>
#include <math.h>
using namespace std;
int main() {
  int N;
  string S;
  cin >> N >> S;

  int count = 0;
  char c = '\0';
  for (int i = 0; i < N; i++) {
    if (S[i] != c) {
      count++;
      c = S[i];
    }
  }
  cout << count << endl;
  return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <iomanip>
#include <bitset>
#include <set>
#include <map>
#include <stdio.h>
#include <numeric>
#include <cstring>

#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep1(i,n) for (int i = 1; i < (n); i++)
#define FOR(i,a,b) for (int i=(a); i < (b); i++)
#define MOD 1000000007 //10^9+7
using namespace std;
using ll = long long;
using PII = pair<int, int>;
using PLL = pair<ll, ll>;
const int INF = numeric_limits<int>::max();
const ll INFL = numeric_limits<ll>::max();


// 負の数にも対応した % 演算
long long mod(long long val, long long m) {
    long long res = val % m;
    if (res < 0) res += m;
    return res;
}

//greatest common divisor
long long gcd(ll a, ll b) 
{
    if (a % b == 0) {
        return b;
    } else {
        return gcd(b, a % b);
    }
}

//least common multiple
long long lcm(ll a, ll b)
{
    return a / gcd(a, b) * b ;
}

ll factorial(ll n) {
    ll res = 1;
    for (ll i = 1; i <= n; i++) {
        res *= i;
    }
    return res;
}

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

bool isOK(int index, int key, vector<ll>& a) {
    if (a[index] >= key) return true;
    else return false;
}

int binary_search(int key, vector<ll>& a) {
    int ng = -1;
    int ok = a.size();

    while (abs(ok - ng) > 1) {
        int mid = (ok + ng) / 2;

        if (isOK(mid, key, a)) ok = mid;
        else ng = mid;
    }
    return ok;
}

int main()
{
    string s; cin >> s;
    cout << s[0] << s.length()-2 << s[s.length()-1] << endl;
}


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

//  2進数ならば baseNumber を  2 とする
// 10進数ならば baseNumber を 10 とする
int GetDigitsCount(int targetNumber, int baseNumber=10) {
	int digitsCount = 0;
	while (targetNumber != 0) {
		digitsCount++;
		targetNumber /= baseNumber;
	}
	return digitsCount;
}


int main() {
	
	int n, k; cin >> n >> k;
	//int digit_n = GetDigitsCount(n);
	const int p = 10;
	vector<bool> canUse(p, true);
	for (int i = 0; i < k; i++) {
		int d; cin >> d;
		canUse[d] = false;
	}
	//int canUseMinValue = 1;
	//while (true) {
	//	if (!canUse[canUseMinValue]) {
	//		canUseMinValue--;
	//		break;
	//	}
	//}
	int ans;
	//int start = 10 * (digit_n - 1);
	//int end = 10 * (digit_n - 1) * canUseMinValue;
	//for (int i = start; i <= end; i++) {
	//	if (i < n) continue;
	//	string i_string = to_string(i);
	//	for (int j = 0; j < i_string.size(); j++) {
	//		if (!canUse[(i_string[j] - '0')]) {
	//			continue;
	//		}
	//	}
	//	ans = i;
	//	break;
	//}
	int now = n;
	while (true) {
		string now_s = to_string(now);
		bool ok = true;
		for (int i = 0; i < now_s.size(); i++) {
			for (int j = 0; j < p; j++) {
				if (!canUse[(int)(now_s[i] - '0')]) {
					ok = false;
					break;
				}
			}
		}
		if (ok) {
			ans = now;
			break;
		}
		now++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3640
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#define rep(i, n) for(i = 0; i < n; i++)
using namespace std;
typedef pair<int, int> P;

int n;
int v[100000];
int cnt[2][100000];
P p[2][100000];

signed main() {
	int i, j;
	
	cin >> n;
	rep(i, n) { cin >> v[i]; v[i]--; }
	rep(i, n) { cnt[i % 2][v[i]]++; }
	rep(i, 100000) {
		cnt[0][i] = n / 2 - cnt[0][i];
		cnt[1][i] = n / 2 - cnt[1][i];
		p[0][i] = P(cnt[0][i], i);
		p[1][i] = P(cnt[1][i], i);
	}
	sort(p[0], p[0] + 100000);
	sort(p[1], p[1] + 100000);
	
	int ans = n;
	rep(i, 2) {
		rep(j, 2) {
			if (p[0][i].second == p[1][j].second) continue;
			int cst = p[0][i].first + p[1][j].first;
			ans = min(ans, cst);
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 2944
#include<iostream>
typedef long long ll;
using namespace std;
int main () {
  int N;
  cin >> N;
  ll m = 1e9 + 7;
  ll wanoni = 0;
  ll ninowa = 0;
  for (int i = 0; i < N; i ++) {
    ll a;
    cin >> a;
    wanoni += a;
    a = a * a;
    a %= m;
    ninowa += a;
    wanoni %= m;
    ninowa %= m;
  }
  wanoni = wanoni * wanoni;
  wanoni %= m;
  ll ans = wanoni - ninowa;
  if (ans < 0) ans += m;
  ans *= 500000004;
  ans %= m;
  cout << ans << endl;
}

Measured memory_bytes: 3628
#include <iostream>
using namespace std;
int main() {
    int n, t;
    cin >> n >> t;
    int cost = -1;
    for(int i=0; i<n; i++) {
        int a, b;
        cin >> a >> b;
        if(b<=t && (cost>a||cost==-1)) cost = a;
    }
    if(cost==-1) cout << "TLE" << endl;
    else cout << cost << endl;
    return 0;
}


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

using namespace std;

typedef long long ll;

string s, t;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> s >> t;
    if((int)s.size() != (int)t.size() - 1)
    {
        cout << "No\n";
        return 0;
    }
    for(int i = 0; i < s.size(); i++)
        if(s[i] != t[i])
        {
            cout << "No\n";
            return 0;
        }
    cout << "Yes\n";
    return 0;
}


Measured memory_bytes: 3608
#include<stdio.h>
main(){
  int ta,yo,ka,n,ri[11111];
  int i;
  while(1){
    scanf("%d %d %d",&ta,&yo,&ka);
    if(ta == 0 && yo == 0 && ka == 0) break;
    scanf("%d",&n);
    for(i=0;i<n;i++){
      scanf("%d",&ri[i]);
    }
    for(i=0;i<n;i++){
      if((yo*yo) + (ka*ka) < (ri[i]*2) * (ri[i]*2)){ 
	printf("OK\n");
      }
      else{
	printf("NA\n");
      }
    }
  }
  return 0;
}

      

Measured memory_bytes: 588
#include <iostream>
#include <vector>
#include <unordered_map>
#include <map>
#include <algorithm>
#include <set>
#include <unordered_set>
#include <deque>
#include <cmath>
#include <stack>
#include <queue>
#include <string>
#include <locale>
#include <iomanip>

#define nl '\n';

using namespace std;

string n;
int a, b;

int main(){

    cin >> n;

    for(int i = 0; i < n.length(); i++){
        a = a + (n[i] - '0');
    }

    b = stoi(n);

    if(b%a == 0){
        cout << "Yes";
        return 0;
    }

    cout << "No";



    



}

//g++ -std=c++14 comp.cpp -o b; ./b.exe
//g++ -std=c++14 comp.cpp && ./a.out

// char** arr = new char*[r];
// for(long long i = 0; i < r; i++) arr[i] = new char[c];

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

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

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

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

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

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

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

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

fn main() {
    input! {
    s: String,
    t: String,
    a: usize,
    b: usize,
    u: String,
    }
    if s == u { println!("{} {}", a - 1, b) } else { println!("{} {}", a, b - 1) }
}


Measured memory_bytes: 4352
# -*- coding: utf-8 -*-
S=input()
N=len(S)
count1=0
count2=0
for i in range(N):
    if i%2==0:
        if S[i]=="1":
            count1=count1+1
    else:
        if S[i]=="0":
            count1=count1+1

for i in range(N):
    if i%2==0:
        if S[i]=="0":
            count2=count2+1
    else:
        if S[i]=="1":
            count2=count2+1
            
print(min(count1,count2))

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

int main() {
  int H, W;
  cin >> H >> W;
  vector<vector<char>> a(H, vector<char>(W));
  vector<int> row_blank_count(H,0);
  vector<int> col_blank_count(W,0);
  rep(i,H) {
    rep(j,W) {
      char c;
      cin >> c;
      a.at(i).at(j) = c;
      if ( c == '.' ) {
        row_blank_count.at(i)++;
        col_blank_count.at(j)++;
      }
    }
  }
  rep(i,H) {
    if ( row_blank_count.at(i) == W ) {
      continue;
    }
    rep(j,W) {
      if ( col_blank_count.at(j) == H ) {
        continue;
      }
      cout << a.at(i).at(j);
    }
    cout << endl;
  }
}


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

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

	int ans = 0;
	if(6 <= a && a <= 12) ans = b/2;
	else if(12 <= a) ans = b;

	cout << ans << endl;

}

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

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef int64_t ll; typedef vector<int> VI;typedef pair<int,int> pii;
const int mod = (int)1e9 + 7;


int main()
{

	//cin.tie(0); ios_base::sync_with_stdio(false);
	ll x;
	cin >>x;
	int ans =0;
	vector<ll> v(50010);
	for(ll k=1; k<50008;k++) v[k] = k*(k+1)/2;
	//cout << v[50000] <<"\n";
	while(x>0){
		int z = lower_bound(all(v),x) - v.begin();
		
		ans +=z;
		x -= z*(z+1)/2;
	}
	cout << ans <<endl;
	return 0;

}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#define rep(i,n) for(int i=0;i<(n);i++)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define psortfirst(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.first<b.first;});
#define All(x) (x).begin(),(x).end()
using namespace std;
using pii  = pair<int,int>;
long long gcd(long long a, long long b){return (b == 0 ? a : gcd(b, a%b));}
long long lcm(long long a, long long b){return a*b/gcd(a,b);}
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
int BinarySearch(int key,int n,int S[]){
  int l=0,r=n;
  while(r-l>1){
    int mid=(l+r)/2;
    if(S[mid]>key)r=mid;
    else l=mid;
  }
  return S[l]==(key?1:0);
}
typedef long long ll;
#define MOD 1000000007
#define EPS 10e-8

int main() {
    ll N;cin >> N;
    char A[5];
    rep(i,N){
        cin >>A;
        if(A[0]=='Y'){
            cout << "Four" << endl;
            return 0;
        }
    }
    cout << "Three" << endl;
}

Measured memory_bytes: 256
<?php

    $k = in_int();

    $s = explode(',', '1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51');

    out($s[$k - 1]);
    
    /**
    * お手伝い関数さんたち
    */
    function in() {
        return trim(fgets(STDIN));
    }
    function in_int() {
        return (int)in();
    }
    function in_vals() {
        return explode(' ', in());
    }
    function in_ints() {
        return array_map('intval', in_vals());
    }
    function out($s) {
        echo $s . PHP_EOL;
    }
    function yes() {
        out('Yes');
    }
    function no() {
        out('No');
    }



Measured memory_bytes: 4856
from collections import Counter
N, M = map(int, input().split())
c = []
for i in range(M):
    a, b = map(int, input().split())
    c.append(a)
    c.append(b)
c = Counter(c)
if all(cnt%2==0 for cnt in c.values()):
    print('YES')
else:
    print('NO')

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

#define ll long long
#define PB push_back
#define PII pair<int, int>
#define MP make_pair
#define all(x) x.begin(), x.end()
#define REP(x, y, z) for(int x = y; x <= z; x++)
#define REPP(x, y, z) for(int x = y; x >= z; x--)
#define F first
#define S second
#define MSET(x, y) memset(x, y, sizeof(x)) 
#define EB emplace_back
#define maxn

//structure

//declaration

//functions

int main(void)
{
	#ifdef DBG
	freopen("in.in", "r", stdin);
	freopen("out.out", "w", stdout);
	#endif
    int a, b;
    bool arr[5];MSET(arr, false);

    scanf("%d %d", &a, &b);

    arr[a] = arr[b] = true;

    REP(i, 1, 3)
    {
        if(!arr[i])
        {
             printf("%d\n", i);
             break;
        }
           
    }

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(v) (v).begin(), (v).end()
#define lp(i, n) for (int i = 0; i < (n) ; ++i)
#define sz(v) (ll)(v).size()
#define int long long
#define mod 1000000007

int ar[101];

void solve() {
        int n, m; cin >> n>> m;
        lp(i, n+ 1) ar[i]= -1;
        lp(i, m) {
                int x, y; cin >> x>> y;
                if (ar[x]!= -1&& y!= ar[x]) { cout << "-1\n"; return; }
                ar[x]= y;
        }
        if (n== 1&& (ar[1]== 0|| ar[1]== -1)) { cout << "0"; return; }
        if (ar[1]== 0) cout << -1;
        else {
                if (ar[1]== -1) cout << 1;
                else cout << ar[1];
                for (int i= 2; i<= n; i++) if (ar[i]== -1) cout << 0; else cout << ar[i];
        }
}

int32_t main(){
ios::sync_with_stdio(0), cin.tie(NULL), cout.tie(NULL);
        int t = 1;
        //cin >> t;
        while ( t-- ) {
                solve();
        }
return 0;
}


Measured memory_bytes: 256
n = int(input())
ls = list(map(str,input()))
book =["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"]
ans = []
for a in ls:
    ans.append(book[(book.index(a)+n)%26])
print("".join(ans))


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

using namespace std;
using ll =long long;
using db = double;

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; }

#define che(a,string) cout<<"//"<<string <<"=="<<(a)<<"//" <<endl;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define leftunique(v) SORT(v);(v).erase(unique((v).begin(),(v).end()),(v).end())
//leftuniqueは配列から同じ要素のものを取り除く 例 4 6 2 1 3 4 1 2 なら 1 2 3 4 6 になる
bool IsInt(double a){int b = a/1;if(a==b){return true;}else {return false;}}
bool coY() {cout <<"Yes"<<endl;}
bool coN(){cout <<"No"<<endl;}
const int mod = 1e9 + 7;

ll ans;
//ここから書き始める
int main()
{
	cout << setprecision(10);
	int suginoki,reloading,jogi;
	cin >> suginoki >> reloading>> jogi;
	//スギノキちゃん秒ごとにリロチュー枚のビスケット、jogi秒までに何枚作れるか
	//ジョギをスギノキちゃんで割った回数リロチュー枚作られる
	cout << jogi/suginoki * reloading<< endl;

}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

public class Program
{

	static void Main(string[] args)
	{
		// スペース区切りの整数の入力
		var input = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();

		var result = input.All(x => x == input.First()) ? "Yes" : "No";
		Console.WriteLine(result);
	}

}


Measured memory_bytes: 13396
N, M, X = map(int, input().split())
C, A = [], []
for _ in range(N):
    tmp = [int(a) for a in input().split()]
    C.append(tmp[0])
    A.append(tmp[1:])

mi = 1 << 100
for binary in range(1 << N):
    B = [0] * M
    c = 0
    for i in range(N):
        if binary >> i & 1:
            c += C[i]
            for j in range(M):
                B[j] += A[i][j]
    if min(B) >= X:
        mi = min(c, mi)
print(mi if mi < 1 << 99 else -1)


Measured memory_bytes: 9216
N = int(input())
c = list(input())
rr = []
ww = []
for i in range(N):
  if (c[i] == "R"):
    rr.append(i)
  if (c[i] == "W"):
    ww.append(i)

wl = len(ww)
rl = len(rr)
l = min([wl,rl])
ans = 0
for i in range(l):
  if (ww[i] < rr[-i-1]):
    ans += 1

print(ans)

Measured memory_bytes: 86648
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int H = sc.nextInt();
        int A = sc.nextInt();
        
        int count;
        
        count = H/A;
        if(H%A != 0){
            count++;
        }
        System.out.println(count);
    }
}


Measured memory_bytes: 35832
#include <stdio.h>


int main(){
  int a,b,sum;
  int i;

  while( scanf("%d",&a) != EOF){
    scanf("%d",&b);
    sum = a + b;
    i = 1;
    while( (sum/10)>=1 ){
      sum = sum/10;
      i++;
    }
    printf("%d\n",i);
  }

  return 0;
}

Measured memory_bytes: 600
#include<stdio.h>
#include<string>
#include<stdlib.h>
#include<math.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<numeric>
#include<string.h>
#include<map>
#include<queue>

using namespace std;

typedef pair<int,int> pii;

#define rep(i,j) for(int i=0;i<(j);i++)
#define reps(i,j,k) for(int i=j;i<=k;i++)
#define in(i,j,k) ((i)>=(j)&&(i)<=(k))


int main(){
	int a,b,l,r=0,h=0;
	while(~scanf("%d,%d,%d",&a,&b,&l)){
		if(a==b)h++;
		if(l*l==a*a+b*b)r++;
	}
	printf("%d\n%d\n",r,h);
	return 0;
}

Measured memory_bytes: 1188
#include <bits/stdc++.h>
using namespace std;
//#define int long long
typedef pair<int,int> ii;
typedef tuple<int,int,int> iii;
#define ll long long
#define iiMPQ priority_queue<ii,vector<ii>,greater<ii> >
#define MPQ priority_queue<int,vector<int>,greater<int> >
#define PQ priority_queue<int>
#define iiPQ priority_queue<ii>
#define US unordered_set<int>
#define UMS unordered_multiset<int>
#define UM unordered_map<int>
#define iiUS unordered_set<ii>
#define ST stack<int>
#define MS multiset<int>
#define scan1(n) cin>>n
#define scan2(a,b) cin>>a>>b
#define scan3(a,b,c) cin>>a>>b>>c
#define print(n) cout<<n
#define println(n) cout<<n<<"\n"
#define vi vector<int>
#define vii vector<ii>
#define viii vector<iii>
#define first fi
#define second se
#define REP(i,n) for(int i=0;i<n;++i)
#define SET(arr,k) memset(arr,k,sizeof arr)
#define speed ios::sync_with_stdio(0); cin.tie(0);
#define mp make_pair
#define pb push_back
#define Q queue
#define V vector

void m1(){
  ll n; scan1(n);
  ll res = 0;
  for(ll i=1;i<=n;++i){
    for(ll j=i;j<=n;j+=i) res += j;
  }
  print(res);
}
/* 
void m2(){
  int t; scan1(t);
  while(t--) m1();
}
*/
 
int main(){
  speed;
  //freopen("in.txt","r",stdin);
  m1();
  //m2();
}


Measured memory_bytes: 3556
//g++ -std=c++14 test.cpp -o test.out

#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <map> 
#include <utility>
#include <limits.h>
#include <bitset>
#include <set>
using namespace std;
 
#define LL long long int
const LL INF = (1LL<<60);
const int INF_INT = 2147483647-1e6-1;
const LL mod = 1000000007ll;
const int mod_int = 1000000007;

LL N,K;

LL ans = 0;

void solve(){
	//a = pb + r (0<=r<=b-1)とおく
	//bを固定して考える
	for(int b=K+1;b<=N;b++){
		//cout << "b=" << b << endl;
		//cout << ((b-K)*(N/b) + max(0LL,N%b-K+1)) << endl;
		ans += (b-K)*(N/b) + max(0LL,N%b-K+1);
	}
	if(K==0) ans -= N;
}
 
int main(){
    cin >> N >> K;
 
    solve();

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

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <climits>
#include <tuple>
#include <unordered_map>

using namespace std;

typedef long long ll;

int main(void) {
  string S; cin >> S;
  int orgS = S.size();

  int c0 = 0, c1 = 0;
  for (int i = 0; i < S.size(); i++) {
    if (S[i] == '0') c0++;
    else c1++;
  }
  cout << 2 * min(c0, c1) << endl;
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cmath>
#include <algorithm>
#include <utility>
#include <functional>
#include <fstream>
#define debug(x) cout << #x << " = " << x << endl
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define repr(i,n) for(int i = (n); i > -1; i--)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const double EPS = 1e-9;


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

  int n;
  cin>>n;
  int a[n];
  rep(i,n) cin>>a[i];
  int ans = 0;
  rep(i,n) {
    if(a[a[i] - 1] == i + 1) ans++;
  }
  cout << ans / 2 << endl;

  return 0;
}


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

#include <iostream>
#include <cmath>
#include <algorithm>
#include <unordered_map>
#include <map>
#include <vector>
#include <unordered_set>
#include <cstdio>
#include <cstdlib>
#include <set>
#include <cstring>
#include <stack>
#include <queue>
#include <numeric>
 
 
//#include <bits/stdc++.h>
typedef long long ll;
#define nl "\n"
#define fast ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);

using namespace std;

/*
 
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }
 
    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};


*/

int main(){
    ll n ,d ;  cin>>n>>d;
    int ans = 0 ;
    for( int i = 0 ;i<n; ++i ){
        ll x , y ;  cin>>x >> y ;
        if( sqrt(pow(x,2) + pow(y,2) ) <= d ) ans ++ ;
    }
    cout<<ans ;
}


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

int main(){
	int ary[10],i,j;

	for(i=0; i<10; i++){
		cin >> ary[i];
	}

	for(i=0; i<9; i++){
		for(j=i+1; j<10; j++){
			if(ary[i]<ary[j]){
				int temp = ary[i];
				ary[i] = ary[j];
				ary[j] = temp;
			}
		}
		
	}




	for(i=0; i<3; i++){
		cout << ary[i] << endl;
	}

	return 0;
}

Measured memory_bytes: 1160
#include <stdio.h>
#include <math.h>

int main (void)
{
	int n, s[1010], sum, j=0, i;
	double ave, dev[1010], bun;


	while(1){
		scanf("%d", &n);
		if(n==0)break;
		
		sum=0;
		for(i=0; i<n; i++){
			scanf("%d", &s[i]);
			sum += s[i];
		}

		ave = (double)sum / (double)n;
		bun=0.0;

		for(i=0; i<n; i++)
			bun+=pow(s[i]-ave,2);

			dev[j++] = sqrt(bun/(double)n);
	}

	for(i=0; i<j; i++){
		printf("%f\n", dev[i]);
	}
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n; i >= 0; i--)
#define reprr(i, m, n) for (ll i = m; i < n; i++)
#define inf 2e9
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;


int main()
{
    ll N; cin >> N;
    vll A(N); rep(i, N) cin >> A[i];

    vll cnt(61);
    rep(i, 61) {
        rep(j, N) cnt[i] += (A[j] & (1LL << i) ? 1 : 0);
    }

    ll ans = 0;
    ll mod = 1e9+7;
    rep(i, 61) {
        ll a = cnt[i], b = N - cnt[i];
        (ans += (((a * b) % mod) * ((1LL << i) % mod)) % mod) %= mod;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2560