akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
using namespace std;
int main(){
  int n,o,p,k,i,x=0,y;
  cin>>n>>k; 
  o=n;
  p=n;
   int h[100000];
  for(i=0;i<o;i++){
  cin>>h[i];
  }
  for(y=0;y<p;y++){
  if(h[y]>=k){
  x++;
  }
  }
  cout<<x<<endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <algorithm>
#define N 100005
using namespace std;

typedef long long ll;
struct st{
	ll F, S;
} a[N];
ll n, mn = 1e9, ans[N];

bool cmp1(st p, st q) {
	if (p.F != q.F) return p.F > q.F;
	return p.S < q.S;
}

int main()
{
	ll i;
	cin >> n;
	for (i = 1; i <= n; i++) scanf("%lld", &a[i].F), a[i].S = i;
	sort(a + 1, a + n + 1, cmp1);
	for (i = 1; i <= n; i++) {
		mn = min(mn, a[i].S);
		ans[mn] += (a[i].F - a[i + 1].F) * i;
	}
	for (i = 1; i <= n; i++) printf("%lld\n", ans[i]);
    return 0;
}

Measured memory_bytes: 3456
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<cmath>
#include<math.h>
#include<algorithm>
#include<string.h>
#include <iomanip>
#include <sstream>
using namespace std;

int main() {
  int N, M;
  int ans = 0;
  string S;
  int zcnt =0;
  int ocnt =0;

   cin >> S;

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


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
//const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;
//const ll MOD = ;
ll mod(ll A, ll M) {return (A % M + M) % M;}
const ll INF = 1LL << 60;
template<class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
ll divceil(ll A, ll B) {return (A + (B - 1)) / B;}
ll myctoi(char C) {return C - '0';}
char myitoc(ll N) {return '0' + N;}
#define FINALANS(A) {cout << (A) << '\n'; exit(0);}

int main()
{
  ll N;
  cin >> N;
  string S;
  cin >> S;
  S += '?';

  ll ans = 0;
  for (ll i = 0; i < N; i++)
  {
    if (S.at(i) != S.at(i + 1))
      ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 512
#include<stdio.h>
int main(){
  int n;
  scanf("%d",&n);
  int r = n;
  for(int i = 0;i <= n;i++){
    int c = 0,t = i;
    while(t > 0){
      c += t % 6;
      t /= 6;
    }
    t = n - i;
    while(t > 0){
      c += t % 9;
      t /= 9;
    }
    if(r > c){
      r = c;
    }
  }
  printf("%d\n",r);
  return 0;
}

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

using namespace std;

int main() {
    string S;
    long long K;
    cin >> S >> K;

    int ans = 1;
    for (int i = 0; i < S.length() and i < K; ++i) {
        if (S[i] != '1') {
            ans = S[i] - '0';
            break;
        }
    }

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    
    //*
    int a, b;
    cin >> a >> b ;
    //*/

    /*
    vector<int> vec(4);
    cin >> vec.at(0) >> vec.at(1) >> vec.at(2) ;
    
    sort(vec.begin(), vec.end());
    */
    
    //*
    if( a <= b){
        cout << a << endl;
    } else {
        cout << a - 1 << endl;
    }
    //*/
    
    //cout << min(a, b) << endl;

    return 0; 
}


Measured memory_bytes: 3556
#include<bits/stdc++.h>
typedef int G;std::vector<G>A['   '];G N,M,S['   '],B,L,R,I;G U(G z,G u){while(z<=N)S[z]+=u,z+=z&-z;}main(){for(scanf("%d%d",&M,&N);~scanf("%d%d",&L,&R);)A[R-L+1].push_back(L);for(L=1;L<=N;L++){B=M;for(I=L;I<=N;I+=L){R=I;while(R)B+=S[R],R-=R&-R;}for(G u:A[L])U(u,1),U(u+L,-1),M--;printf("%d\n",B);}}

Measured memory_bytes: 53760
#include<iostream>
#include<bits/stdc++.h>
#include<iomanip>
#include<math.h>
#include<vector>
#include<cctype>
#include<string>
#include<set>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
std::string line;
typedef long long ll;

int main(){
   int d;
   cin >> d;
   switch(d){
      case 25: cout << "Christmas" << endl;break;
      case 24: cout << "Christmas Eve" << endl;break;
      case 23: cout << "Christmas Eve Eve" << endl;break;
      case 22: cout << "Christmas Eve Eve Eve" << endl;break;
   }




   return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args)throws IOException{
		int rank = 0;
		String[] look;
		boolean [] S = new boolean [13];
		boolean [] H = new boolean [13];
		boolean [] C = new boolean [13];
		boolean [] D = new boolean [13];

		BufferedReader  br = new BufferedReader(new InputStreamReader(System.in));
		int card = Integer.parseInt(br.readLine());

		for(int i = 0; i < card; i++){
			look = br.readLine().split(" ");
			rank = Integer.parseInt(look[1]);

			if(look[0].equals("S")){
				S[rank - 1] = true;
			}else if(look[0].equals("H")){
				H[rank - 1] = true;
			}else if(look[0].equals("C")){
				C[rank - 1] = true;
			}else if(look[0].equals("D")){
				D[rank - 1] = true;
			}
		}
		for(int s = 0; s < 13; s++){
			if(!S[s]){
				System.out.println("S" + " " + (s + 1));
			}
		}
		for(int s = 0; s < 13; s++){
			if(!H[s]){
				System.out.println("H" + " " + (s + 1));
			}
		}
		for(int s = 0; s < 13; s++){
			if(!C[s]){
				System.out.println("C" + " " + (s + 1));
			}
		}
		for(int s = 0; s < 13; s++){
			if(!D[s]){
				System.out.println("D" + " " + (s + 1));
			}
		}
	}
}

Measured memory_bytes: 24236
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main(){
  ll a,b;
  cin>>a>>b;
  ll total=0;
  if(a<b){
    if(b-1>a)total=2*b-1;
    else total=a+b;
  }
  else{
    if(a-1>b)total=2*a-1;
    else total=a+b;
  }
  cout<<total<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n-1);i>=0;i--)
#define FOR(i,n,m) for(int i=n;i<=(int)(m);i++)
#define RFOR(i,n,m) for(int i=(int)(n);i>=m;i--)
#define all(x) (x).begin(),(x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(std::unique(all(x)), x.end());
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
const double PI=acos(-1);
using namespace std;
vector<int> dx={1,0,-1,0};
vector<int> dy={0,1,0,-1};
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

ll modinv(ll a, ll m) {
    ll b=m,u=1,v=0;
    while(b){
        ll t = a/b;
        a -= t*b; swap(a,b);
        u -= t*v; swap(u,v);
    }
    u %= m;
    if (u<0) u += m;
    return u;
}

void kaijou(vector<ll> &vec) {
    vec.resize(1001001);
    vec[0]=1;
    rep(i,1001000) vec[i+1]=(vec[i]*(i+1))%MOD;
    return;
}

vector<ll> kai;
ll comb(int x,int y){
    if(x<y || y<0)  return 0;
    return kai[x]*modinv(kai[x-y]*kai[y],MOD)%MOD;
}

int main() {
    kaijou(kai);
    ll n,m,k;
    cin>>n>>m>>k;
    
    ll ans=0;
    for(ll i=0; i<n; i++) {
        ans+=i*(n-i)*m*m%MOD;
        ans%=MOD;
    }
    for(ll i=0; i<m; i++) {
        ans+=i*(m-i)*n*n%MOD;
        ans%=MOD;
    }
    ans*=comb(n*m-2,k-2);
    ans%=MOD;
    
    cout<<ans<<endl;
}


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

int main(){
  	string str;
  	int count = 0;
	cin >> str;
  	for(int i = 0; i < str.length()/2; i++){
    	if(str.substr(i,1) != str.substr(str.length()-1-i,1)){
        	++count;
        }
    }
  	cout << count << endl;
	return 0;
}

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

#define ll long long

inline ll read() {
    ll x = 0, f = 1; char ch = getchar();
    for(; ch < '0' || ch>'9'; ch = getchar())
        if(ch == '-') f = -f;
    for(; ch >= '0' && ch <= '9'; ch = getchar())
        x = x * 10 + ch - '0';
    return x * f;
}

inline void chkmin( int &a, int b ) { if(a > b) a = b; }

inline void chkmax( int &a, int b ) { if(a < b) a = b; }

#define _ read()

#define ln endl

const int N = 2e5 + 5;
ll ans;
map<int, int> mp;
int n, k, sum[N];

int main()
{
	n = _; k = _;
	mp[0] = 1;
	for( int i = 1, x; i <= n; i++ ) 
		x = _, sum[i] = (sum[i - 1] + x) % k;
	for( int i = 1; i <= n; i++ )
		sum[i] = (sum[i] - i % k + k )% k;;
	for( int i = 1; i <= n; i++ ) 
	{
		if(i >= k)
			mp[sum[i - k]]--;
		ans = ans + mp[sum[i]],
		mp[sum[i]]++; 
	}
	cout << ans << ln;
}
/*
	sum[r] - r = sum[l - 1] - (l - 1)
*/

Measured memory_bytes: 10368
// Ala be zekrellah tatmaenolgholoob ...
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define F first
#define S second
#define MP make_pair
const int maxn = 100+9;
const ll mod = 1e9+7;

set <int> st;
map <int,int> mp;
ll dp[maxn][maxn];
int h[maxn], val[maxn], len[maxn];

ll cal (ll x, ll p) {
	if (p == 0)
		return 1;
	ll res = cal(x, p / 2);
	res = (res * res) % mod;
	if (p % 2)
		res = res * x % mod;
	return res;
}

int main () {
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	int n, num = 1;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> h[i];
		st.insert(h[i]);
	}
	int last = 0;
	for (auto x : st) {
		val[num] = x;
		len[num] = x - last;
		mp[x] = num;
		num++;
		last = x;
	}
	// base
	dp[0][0] = 2;
	for (int i = 1; i <= mp[h[0]]; i++) {
		if (val[i] == 1)
			continue;
		ll cur = cal(2, h[0] - val[i] + 1) * (cal(2, len[i]) - 1) % mod;
		if (i == 1)
			cur = cal(2, h[0] - val[i]) * (cal(2, len[i]) - 2) % mod;
		cur = (cur + mod) % mod;
		dp[0][i] = cur;
	}
	for (int i = 1; i < n; i++) {
		// dp[i][0]
		dp[i][0] = dp[i - 1][0] * 2 % mod;
		for (int t = mp[h[i]] + 1; t < maxn; t++)
			dp[i][0] = (dp[i][0] + dp[i - 1][t] * 2 % mod) % mod;
		// dp[i][a]
		for (int t = 1; t <= mp[h[i]]; t++)
			dp[i][t] = dp[i - 1][t] * cal(2, max(h[i] - h[i - 1], 0)) % mod;
		if (h[i] <= h[i - 1])
			continue;
		ll f = dp[i - 1][0];
		for (int t = mp[h[i - 1]] + 1; t <= mp[h[i]]; t++)
			dp[i][t] = f * cal(2, h[i] - val[t] + 1) % mod * (cal(2, len[t]) - 1) % mod;
	}
	// ans
	ll res = 0;
	for (int i = 0; i < maxn; i++)
		res = (res + dp[n - 1][i]) % mod;
	cout << res << "\n";
}



Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;

typedef pair<int,int> P;

int main(){
	int n, m, a;
	while( cin >> n >> m >> a, n || m || a ){
		vector<P> s[1001];
		int max_h=0;
		
		for(int i=0 ; i < m ; i++ ){
			int h, p, q;
			cin >> h >> p >> q;
			s[h].push_back( P(p,q) );
			max_h = max( max_h , h );
		}

		for(int y = max_h ; y >= 0 ; y-- ){
			for(int i=0 ; i < s[y].size() ; i++ ){
				int p = s[y][i].first;
				int q = s[y][i].second;
				if( a == p ){
					a = q;
					break;
				}else if( a == q ){
					a = p;
					break;
				}
			}
		}
		cout << a << endl;
	}
}

Measured memory_bytes: 932
/*
ID: allengu01
TASK: 
LANG: C++
*/

#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <set>
#include <unordered_map>
using namespace std;
unordered_map<int, int> q;

int n, h[100007], dp[100007];
int main()
{
	cin >> n;
  	for (int i = 1; i <= n; i++) {
      cin >> h[i];
    }
  for (int i = 1; i <= n; i++) {
    dp[i] = 1000000000;
  }
  	dp[1] = 0;
  	for (int i = 1; i < n; i++) {
      	dp[i+1] = min(dp[i+1], dp[i]+abs(h[i+1]-h[i]));
      	dp[i+2] = min(dp[i+2], dp[i]+abs(h[i+2]-h[i]));
    }
  	cout << dp[n];
}



Measured memory_bytes: 1024
package main

import (
	"fmt"
)

func main() {
	nums := make([]int, 5)
	for i := 0; i < 5; i++ {
		fmt.Scan(&nums[i])
	}

	var max int
	var maxP int
	for i := 0; i < 5; i++ {
		n := nums[i]
		if 10 >= n {
			if 10 - n > max {
				max = 10 - n
				maxP = i
			}
		} else  {
			if n % 10 != 0 && 10 - n%10 > max {
				max = 10 - n%10
				maxP = i
			}
		}
	}
	var sum int
	for i := 0; i < 5; i++ {
		if i != maxP {
			n := nums[i]
			sum += n
			if sum % 10 != 0 {
				sum += 10 - (sum%10)
			}
		}
	}
	fmt.Println(sum + nums[maxP])
}

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

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

    ll n;
    cin >> n;

    ll prev = 0, ans = 1;

    for (ll i = 0; i < n; i++) {
        ll t;
        cin >> t;
        if (t <= prev) {
            ans++;
        }
        prev = t;
    }
    cout << ans << endl << n << endl;
}


Measured memory_bytes: 3212
n=int(input())
s=[list(map(int,list(input().split()))) for i in range(n)]
dp=[[0]*3 for i in range(n+1)]
for i in range(n):
    for j in range(3):#today
        for k in range(3):#yesterday
            if j==k:
                continue
            dp[i+1][j]=max(dp[i+1][j],dp[i][k]+s[i][j])
print(max(dp[n][:]))

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

#define For(i, j, k) for (int i = j; i <= k; ++ i)

using namespace std;

const int N = 2e3 + 10;
int a[N], t[N], n, k, q, b[N];

int main() {

	scanf("%d%d%d", &n, &k, &q);
	For(i, 1, n) scanf("%d", a + i); a[++ n] = -1;

	int ans = INT_MAX;
	For(tt, 1, n) {
		int nw = a[tt], c = 0, lstps = 1;

		For(i, 1, n) if (a[i] < nw) {
			if (i - lstps < k) { lstps = i + 1; continue; }
			int cnt = 0;
			For(j, lstps, i - 1) b[++ cnt] = a[j];
			nth_element(b + 1, b + cnt - k + 1, b + cnt + 1);
			For(j, 1, cnt - k + 1) t[++ c] = b[j];
			lstps = i + 1;
		}
	
		if (c < q) continue;
		nth_element(t + 1, t + q, t + c + 1);
		ans = min(ans, t[q] - nw);
	}

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


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<vector>
#include<algorithm>
#include<functional>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<deque>
#include<tuple>
#include<iostream>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<cassert>
using namespace std;
#define REP(i,x) for (int i=0;i<x;i++)
#define REPP(i,x,y) for (int i=x;i<=y;i++)
#define SI(x) scanf("%d",&x)
#define SL(x) scanf("%lld",&x)
#define MX3(x,y,z) max({x,y,z})
#define MX4(x,y,z,p) max({x,y,z,p})
#define MX5(x,y,z,p,q) max({x,y,z,p,q})
#define MN3(x,y,z) min({x,y,z})
#define MN4(x,y,z,p) min({x,y,z,p})
#define MN5(x,y,z,p,q) min({x,y,z,p,q})
#define amax(x,y) x=max(x,y)
#define amin(x,y) x=min(x,y)
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef vector<vb> vvb;
typedef long double ld;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef tuple<int,int,int> ti;
typedef tuple<ll,ll,ll> tl;
// #####################################################################

const int MAX = 500 + 10;
char arr[MAX][MAX];
bool mark[MAX];

void solve() {

    int n;
    SI(n);
    REP(i, n) {
        scanf("%s", arr[i]);
    }

    bool all_dot = true;
    REP(i, n) {
        REP(j, n) {
            if(arr[i][j] != '.') all_dot = false;
        }
    }
    if(all_dot) {
        puts("-1");
        return;
    }

    int ans = 0, pick = -1;
    REP(i, n) {
        bool lost = false;
        REP(j, n) {
            if(arr[j][i] == '.') {
                lost = true;
            } else {
                mark[i] = true;
            }
        }
        if(lost) ans++;
    }

    REP(i, n) {
        int tmp = 0;
        if(!mark[i]) tmp = 1;
        REP(j, n) {
            if(arr[i][j] == '.') {
                tmp++;
            }
        }
        if(pick == -1) pick = tmp;
        else amin(pick, tmp);
    }

    if(pick == -1) puts("-1");
    else {
        printf("%d\n", pick + ans);
    }
}

void init() {
    


}

int main () {
    init();
    solve();
    return 0;
}


Measured memory_bytes: 512
#include        "algorithm"
#include        "iostream"
#include        "numeric"
#include        "iomanip"
#include        "cstring"
#include        "math.h"
#include        "bitset"
#include        "string"
#include        "vector"
#include        "ctime"
#include        "queue"
#include        "stack"
#include        "map"
#include        "set"

#include        "ext/pb_ds/assoc_container.hpp" // Common file
#include        "ext/pb_ds/tree_policy.hpp" // Including tree_order_statistics_node_update
#include        "ext/pb_ds/detail/standard_policies.hpp"

using namespace std;
using namespace __gnu_pbds;


#define          f first
#define          lgn 25
#define          endl '\n'
#define          sc second
#define          pb push_back
#define          N (int)2e5+5
#define          PI acos(-1.0)
#define          int long long 
#define          vi vector<int>
#define          mod 1000000007
#define          ld long double
#define          eb emplace_back
#define          mii map<int,int>
#define          vpii vector<pii>
#define          pii pair<int,int>
#define          pq priority_queue
#define          BLOCK (int)sqrt(N)
#define          test(x) while(x--)
#define          all(x) begin(x),end(x)
#define          allr(x) x.rbegin(),x.rend()
#define          fo(i,a,n) for(int i=a;i<n;i++)
#define          rfo(i,n,a) for(int i=n;i>=a;i--)
#define          FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define          time() cerr << "Time : " << (double)clock() / (double)CLOCKS_PER_SEC << "s\n"
#define            bug(...)       __f (#__VA_ARGS__, __VA_ARGS__)

typedef tree< int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update > 
OS ;

template <typename Arg1>
void __f (const char* name, Arg1&& arg1) { cout << name << " : " << arg1 << endl; }
template <typename Arg1, typename... Args>
void __f (const char* names, Arg1&& arg1, Args&&... args)
{
     const char* comma = strchr (names + 1, ',');
     cout.write (names, comma - names) << " : " << arg1 << " | "; __f (comma + 1, args...);
}

const int inf = 0x3f3f3f3f;
const int INF = 0x3f3f3f3f3f3f3f3f;

int A , B , n;


void go()
{
    cin >> A >> B >> n;


    int x = max( 1LL , min( B-1 , n) );
    int xx = (A * x)/B;
    int yy = A * ( x / B );

    cout << ( xx - yy ) << endl;
}

int32_t main()
{
     FAST;     
     int t=1; 
     // cin>>t;
     test(t) go();
}



Measured memory_bytes: 3608
import itertools
import copy
from collections import deque
import heapq
def binary_search(List, item):
    low = 0
    high = len(List) - 1
    while low <= high:
        mid = (low + high) //2
        guess = List[mid]
        if guess == item:
            return mid
        if guess > item:
            high = mid -1
        else:
            low = mid + 1
    return high
n,m,k = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
p = [0]
q = []
c = 0
d = 0
for i in a:
    if i + c > k:
        break
    c += i
    p.append(c)
for i in b:
    if i + d > k:
        break
    d += i
    q.append(d)
ans = len(p)-1
for i in range(1,len(p)+1):
    check = p[-1*i]
    s = k - check
    c_ans = len(p)-i
    c_ans += binary_search(q,s)+1
    #print(binary_search(q,s)+1,q,s,c,check)
    ans = max(ans,c_ans)
    #print(ans,c_ans)
print(ans)

Measured memory_bytes: 42164
//----------------------------おまじない
#pragma GCC optimize ("O3")
#pragma GCC target ("tune=native")
#pragma GCC target ("avx")
//----------------------------
#define FOR(i,j,n) for (int i=(j);i<(n);i++)
#define REP(i,n) for (int i=0;i<(n);i++)
#define REPN(i,n) for (int i=(n);i>=0;i--)
#define I(n) scanf("%d", &(n))
#define LL(n) scanf("%lld", &(n))
#define pb(n) push_back((n))
#define mp(i,j) make_pair((i),(j))
#include <bits/stdc++.h>
using namespace std;

//------------------------------typedef集
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
typedef vector<vi> vvi;
typedef vector<vpi> vvpi;
typedef vector<vvi> vvvi;
typedef long long ll;

int a,b;
char table[100][100];

int main(){
    cin >> a >> b;
    REP(i,50) REP(j,100) table[i][j] = '.';
    FOR(i,50,100) REP(j,100) table[i][j] = '#';

    int ai = 1, bi = 1;
    REP(i,b-1){
        table[bi][ai] = '#';
        ai += 2;
        if (ai >= 100) { ai = 1; bi += 2;}
    }
    ai = 1;
    bi = 51;
    REP(i,a-1){
        table[bi][ai] = '.';
        ai += 2;
        if (ai >= 100) { ai = 1; bi += 2;}
    }
    cout << "100 100" << endl;
    REP(i,100) { REP(j,100) cout << table[i][j]; cout << endl;}
}


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

int main(){
    int n;
    cin >> n;
    map<string, ll> mp;
    rep(i, n){
        string s0;
        cin >> s0;
        sort(s0.begin(), s0.end());
        mp[s0]++;
    }
    ll ans = 0;
    for(auto s0: mp){
        ans += (ll)(s0.second - 1) * s0.second / 2;
    }
    cout << ans << endl;
}

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

#define ll long long
#define pb push_back
#define INF 1e9+7
#define cases int t;cin>>t;while(t--)
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define per(i,a,b) for(ll i=a;i>=b;i--)
#define ff first
#define ss second

#define test4(x,y,z,a) cout<<"x is "<<x<<"		y is "<<y<<"		z is "<<z<<"		a is "<<a<<endl;
#define test3(x,y,z) cout<<"x is "<<x<<"		y is "<<y<<"		z is "<<z<<endl;
#define test2(x,y) cout<<"x is "<<x<<"		y is "<<y<<endl;
#define test1(x) cout<<"x is "<<x<<endl;

int main(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	
	ll x,n;
	cin>>x>>n;
	ll a[n];
	map<ll,ll>m;
	rep(i,0,n){
		cin>>a[i];
		m[a[i]]++;
	}
	ll min=INF,b;
	rep(i,0,102){
		if(m[i])
			continue;
		if(min>abs(x-i)){
			min=abs(x-i);
			b=i;
		}
	}
	cout<<b;
	
	
	return 0;
}

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

using namespace std;

int 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;
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const int mod = 1000000007;
struct mint{
	ll x;
	mint(ll x = 0):x((x%mod+mod)%mod){}
	mint operator-() const{return mint(-x);}
	mint& operator+=(const mint a){
		if((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a){
		if((x += mod-a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a){
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint a) const{
		mint res(*this);
		return res+=a;
	}
	mint operator-(const mint a) const{
		mint res(*this);
		return res-=a;
	}
	mint operator*(const mint a) const{
		mint res(*this);
		return res*=a;
	}
	mint pow(ll t) const{
		if(!t) return 1;
		mint a = pow(t>>1);
		a *= a;
		if(t&1) a *= *this;
		return a;
	}
	mint inv() const{
		return pow(mod-2);
	}
	mint& operator/=(const mint a){
		return (*this) *= a.inv();
	}
	mint operator/(const mint a) const{
		mint res(*this);
		return res/=a;
	}
	bool operator==(const mint a){
		return x == a.x;
	}
};

struct Sieve{
	int n;
	vector<int> f, primes;
	Sieve(int n):n(n), f(n+1){
		f[0] = f[1] = -1;
		for(long long i = 2; i <= n; i++){
			if(f[i]) continue;
			primes.push_back(i);
			f[i] = i;
			for(long long j = i*i; j <= n; j += i){
				if(!f[j]) f[j] = i;
			}
		}
	}
	bool isPrime(int x){return f[x] == x;}
	vector<int> factorList(int x){
		vector<int> res;
		while(x != 1){
			res.push_back(f[x]);
			x /= f[x];
		}
		return res;
	}
	vector<pair<int, int>> factor(int x){
		vector<int> fl = factorList(x);
		if(fl.size() == 0) return {};
		vector<pair<int, int>> res(1, pair<int, int>(fl[0], 0));
		for(int p : fl){
			if(res.back().first == p){
				res.back().second++;
			}
			else{
				res.emplace_back(p, 1);
			}
		}
		return res;
	}
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, k;
    cin >> n >> k;
    Sieve sieve(k);
    mint ans = 0;
    vector<mint> d(k+1);
    for(int i = 1; i <= k; ++i){
        d[i] = mint(k/i).pow(n);
    }
    for(int p : sieve.primes){
        for(int i = p; i <= k; i += p){
            d[i/p] -= d[i];
        }
    }
    for(int i = 1; i <= k; ++i) ans += d[i] * i;
    cout << ans.x << endl;
    return 0;
}


Measured memory_bytes: 4524
import java.util.*;

public class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		StringBuilder str = new StringBuilder();
		while(sc.hasNext()){
			str.append(sc.nextLine());
		}
		char[] moji = str.toString().toLowerCase().toCharArray();
		Map<Character, Integer> map = new LinkedHashMap<>();
		for(int i = (int)'a'; i <= (int)'z'; i++){
			map.put((char)i,0);
		}
		for(char data: moji){
			if((int)'a' <= (int)data && (int)data <= (int)'z'){
				int temp = map.get(data);
				temp++;
				map.put(data,temp);
			}
		}
		for(char data: map.keySet()){
			System.out.printf("%c : %d\n",data, map.get(data));
		}
	}
}




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

int main(){
	int n,m,a;
	while(cin>>n>>m>>a and n){
		int b[1010][n+2];
		rep(i,1010)rep(j,n+2) b[i][j]=0;
		rep(i,m){
			int h,p,q; cin>>h>>p>>q;
			b[h][p]=q; b[h][q]=p;
		}
		rep(h,1001){
			if(b[1000-h][a]>0) a=b[1000-h][a];
		}
		cout<<a<<endl;
	}
	return 0;
}



Measured memory_bytes: 3360
#include <iostream>
#include <stdio.h>
#include <math.h>
using namespace std;
typedef long long int ll;
int prime(ll n)
{
    for (int i = 2; (ll)i * i <= n; i++)
    {
        if (n % i == 0)
            return 0;
    }
    return 1;
}
int main()
{
    ll n;
    cin >> n;
    if (prime(n))
    {
        cout << n - 1 << endl;
    }
    else
    {
        ll a, b;
        int temp = sqrt(n);
        for (int i = temp; i >= 1; i--)
        {
            if (n % i == 0)
            {
                a = i;
                b = n / i;
                break;
            }
        }
        cout << a + b - 2 << endl;
    }
    return 0;
}


Measured memory_bytes: 256
/* 
	Author: ankrypt
*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define MOD 1000000007
#define ll long long int
#define u64 unsigned long long int
#define ff first
#define ss second
#define all(x) x.begin(), x.end() 
#define ub upper_bound
#define lb lower_bound
#define MAX_INT 100005
#define PI 3.141592653589793
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define go ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define fi(a, b, c, d) for(int a = b; a < c; a += d)
#define fl(a, b, c, d) for(ll a = b; a < c; a += d)
#define fei(a, b, c, d) for(int a = b; a <= c; a += d)
#define fel(a, b, c, d) for(ll a = b; a <= c; a += d)
#define quit exit(0)
#define mem(x, a) memset(x, a, sizeof x)
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pcl pair<char, ll>
#define psl pair<string, ll>


ll N, M, A, B, C;
ll arr[MAX_INT], arr1[MAX_INT], data[MAX_INT];
vector<ll> V;
unordered_map<ll, ll> mp;
set<ll> s;
string S = "";
ll cases;

int main() {
	go;
    cin >> N;
    fi(i, 0, N, 1) {
    	cin >> arr[i];
    	mp[arr[i]]++;
    }
    fi(i, 0, N, 1) {
    	if(mp[arr[i]] == 1) {
    		continue;
    	}
    	else if(mp[arr[i]] & 1) {
    		mp[arr[i]] = 1;
    	}
    	else if(mp[arr[i]] % 2 == 0) {
    		mp[arr[i]] = 2;
    	}
    }
    ll cnt = 0;
   	for(auto x: mp) {
   		if(x.ss == 2) {
   			cnt++;
   		}
   	}
   	// trace1(cnt);
   	if(cnt % 2) {
   		cout << mp.size() - 1 << "\n";
   	}
   	else {
   		cout << mp.size() << "\n";
   	}
}
/*
	Powered by Buggy Plugin
*/




Measured memory_bytes: 7976
#include "bits/stdc++.h"
using namespace std;

int main (){
	int a[10000];
	int i = 0;
	while(1){
		cin >> a[i];
		if(a[i] == 0) break;
		i++;
	}
	for(int b = 0;b < i;b++){
		cout << "Case "<<(b+1) <<": " <<a[b]<<endl;
	}

return 0;
}

Measured memory_bytes: 3048
#include <bits/stdc++.h>
using namespace std;
  
int main(){
  long long N,b;
  cin >> N;
  long long a=sqrt(N);
  for(int i=a;i>=1;i--){
    if(N%i==0){
      string ans=to_string(N/i);
      cout << ans.size() << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
namespace mp = boost::multiprecision;
#define ll long long
#define cpp mp::cpp_int
#define dequeue deque
#define rep(i, n) for(int i = 0; i < n; i++)
#define rrep(i, n) for(int i = 1; i <= n; i++)
#define drep(i, n) for(int i = n-1; i >= 0; i--)
#define srep(i, s, t) for (int i = s; i < t; i++)
#define vi vector<int>
#define P pair<ll, ll>
int mod = 1'000'000'000 + 7;
struct edge {
	int to;
	ll cost;
};

void COME_LET_THE_GAMES_BEGIN() {
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << setprecision(20);
}
void reverse(string* s) {
	reverse((*s).begin(), (*s).end());
}
ll gcd(ll a, ll b) {
	if (b == 0)return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}
int main() {
	COME_LET_THE_GAMES_BEGIN();
	ll A, B, C, D;
	cin >> A >> B >> C >> D;
	ll ans = 0;
	ans += B / C - (A - 1) / C;
	ans += B / D - (A - 1) / D;
	ans -= B / lcm(C, D) - (A - 1) / lcm(C, D);
	ans = (B - A + 1) - ans;
	cout << ans << endl;
}

Measured memory_bytes: 256
s = list(input())
first_zero = []
first_one = []
s_size = len(s)
for i in range(s_size):
    if i % 2 == 0:
        first_zero.append("0")
        first_one.append("1")
    else:
        first_zero.append("1")
        first_one.append("0")

count_zero = 0
count_one = 0

for index,number in enumerate(s):
    if number == first_zero[index]:
        pass
    else:
        count_zero += 1

    if number == first_one[index]:
        pass
    else:
        count_one += 1

if count_one > count_zero:
    print(count_zero)
else:
    print(count_one)

Measured memory_bytes: 5512
#include <bits/stdc++.h>
#define l_ength size
const int inf = (1<<30);
const int mod = 1000000007;
using ll = long long;
using namespace std;

int main(){
	int n, a, b; cin >> n >> a >> b;
	cout << min(n*a, b) << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
using namespace std;
int a[100005];
int main()
{
	ios::sync_with_stdio(0);cin.tie(0);
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
	}
	sort(a+1,a+n+1);
	int sum=a[n/2+1]-a[n/2];
	cout<<sum<<'\n';
	
}
	

Measured memory_bytes: 640
#include <iostream>

using namespace std;

int main() {
	int n;
	cin >> n;
	long long s = 0;
	for (int i = 1; i <= n; i++) {
		if (i%3 != 0 && i%5 != 0) {
			s += i;
		}
	}
	cout << s << '\n';
	return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <numeric>
#include <tuple>
#include <stack>

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(),x.end()
#define print(s) cout << s << endl
typedef long long ll;
using namespace std;

int main() {
    int a,b; cin >> a >> b;
    cout << (a*b%2 == 0 ? "No" : "Yes") << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define all(x) (x).begin(), (x).end()
using ll = long long;
using namespace std;
template <typename T> using vec = std::vector<T>;

int main() {
    ll A;
    long double D;
    cin >> A >> D;
    cout << (ll)floor(A*D) <<endl;
}


Measured memory_bytes: 3724
n,k=map(int,input().split())
*a,=map(int,input().split())
l,r=0,10**9
while r-l>1:
    m=(l+r)//2
    t=0
    for x in a:
        if x<=m:
            continue
        t+=(x+m-1)//m-1
    if t<=k:
        r=m
    else:
        l=m
print(r)

Measured memory_bytes: 30984
#include<iostream>
#include<iomanip>
#include<cstdlib>
#include<algorithm>
#include<vector>
#include<map>
#include<cmath>
#include<string>

#define rep(i,p) for(int i=1;i<=p;i++)
#define ll long long

using namespace std;

int main(){

ll int K,X;

cin >> K >> X;

if ( 500*K >= X){
	cout << "Yes";
}
else{
	cout << "No";
}











	return 0;

}



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

int main(){
  vector<string> vec(3);

  for (int i = 0; i < vec.size(); i++){
    cin >> vec.at(i);
  }

  for (int i = 0; i < vec.size(); i++){
    cout << vec.at(i).at(i);
  }

  cout << "" << endl;
}

Measured memory_bytes: 3584
#include <cstdio>
#include <algorithm>
const long long MOD = 924844033;
int N, K, M, L = 0;
long long fc[2001], O, p[2001], q[2002], f[1002][1002], g[2001];
void F(long long *o, int n)
{
	if (n & 1)
	{
		static long long tmp[1001];
		int m = n + 1 >> 1;
		for (int ij = 1; ij <= m; ij++)
				for (int k = 0; k <= m - ij; k++)
					(tmp[m - 1 - k] += ij * f[k][m - ij]) %= MOD;
		for (int i = 0; i < m; i++)
			for (int j = 0; j <= n >> 1; j++)
				o[i + j] = (o[i + j] + tmp[i] * f[(n >> 1) + 1 - j][(n >> 1) + 1]) % MOD;
	}
	else
	{
		static long long tmp[1001];
		int m = n >> 1;
		for (int i = 1; i <= m + 1; i++)
			for (int j = 0; j <= m + 1 - i; j++)
				(tmp[m - j] += f[j][m + 1 - i]) %= MOD;
		for (int i = 0; i <= m; i++)
			for (int j = 0; j <= m; j++)
				o[i + j] = (o[i + j] + tmp[i] * tmp[j]) % MOD;
	}
	for (int i = 1; i <= n; i += 2)
		o[i] = (MOD - o[i]) % MOD;
}
void P(long long *o, int n)
{
	for (int i = L; ~i; i--)
		for (int j = n; j; j--)
			g[i + j] = (g[i + j] + g[i] * o[j]) % MOD;
	L += n;
}
int main()
{
	scanf("%d%d", &N, &K);
	M = N / K >> 1;
	f[0][0] = 1;
	for (int i = 1; i <= M + 1; i++)
	{
		long long S = 0, R = 0;
		for (int j = 0; j <= M + 1; j++)
		{
			f[i][j] = S;
			R = (R + f[i - 1][j]) % MOD;
			S = (S + R) % MOD;
		}
	}
	F(p, N / K);
	F(q, N / K + 1);
	g[0] = 1;
	for (int T = K - N % K; T--; )
		P(p, N / K);
	for (int T = N % K; T--; )
		P(q, N / K + 1);
	fc[0] = 1;
	for (int i = 1; i <= N; i++)
		fc[i] = fc[i - 1] * i % MOD;
	for (int i = 0; i <= N; i++)
		O = (O + fc[i] * g[N - i]) % MOD;
	printf("%lld\n", O);
	return 0;
}


Measured memory_bytes: 8064
import math

ans = 1000000000000
n = int(input())
for i in range(1, int(math.sqrt(n)) + 1):
    if n % i == 0:
        if i == 1:
            ans = min(ans, (n / i) - 1)
        else:
            ans = min(ans, (i + (n / i) - 2))
print(int(ans))

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

using ll = long long;
#define REP(i,n) for(int i=0; i < (n); ++i)
#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
#define INF 1e9
// constexpr ll INF = 1LL << 60;
int main(){
  int H, W, A, B;
  cin >> H >> W >> A >> B;
  REP(i, H){
    REP(j, W){
      if(i < B && j < A || B<=i && A<=j){
        cout << 0;
      }
      else{
        cout << 1;
      }
    }
    cout << endl;
  }
  return 0;
}



Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
set<string>s;
int main()
{
	ios::sync_with_stdio(false);
	string st;
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>st;
		s.insert(st);
	}
	cout<<s.size()<<endl;
	return 0;
}

Measured memory_bytes: 19168
#include <stdio.h>

int main(){
  int a,b;
  scanf("%d %d",&a,&b);

  if(a < b){
    printf("a < b\n");
  }

  if(a > b){
    printf("a > b\n");
  }

  if(a == b){
    printf("a == b\n");
  }

  return 0;
}

Measured memory_bytes: 1816
#include<stdio.h>
int main()
{
    int a,b,num,c;
    while(scanf("%d%d",&a,&b)!=EOF)
    {
        c=a+b;
        num=0;
        if(c==0)num=1;
        while(c!=0)
        {
            num++;
            c=c/10;
        }
        printf("%d\n",num);
    }
    return 0;
}

Measured memory_bytes: 600
#!/usr/bin/env python3

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

    from collections import Counter

    C = Counter(A)

    sum = 0
    for val in list(C.values()):
        sum += val * (val - 1) // 2

    ans = [None] * N
    for i in range(N):
        p = C[A[i]]
        ans[i] = sum - p * (p - 1) // 2 + (p - 1) * (p - 2) // 2

    print('\n'.join(map(str, ans)))


if __name__ == "__main__":
    main()


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


int main(){
    int N;
    cin >> N;
    vector<int> C(N), S(N), F(N);
    for(int i=0; i<N-1; i++) cin >> C[i] >> S[i] >> F[i];
    
    for(int i=0; i<N-1; i++){
        int t = S[i];
        t += C[i];
        for(int j=i+1; j<N-1; j++){
            if(t<S[j]){
                t = S[j];
            }
            int f=S[j];
            if(f!=t){
                while(1){
                    f += F[j];
                    if(t<=f){
                        t = f;
                        break;
                    }
                }
            }
            t += C[j];
        }
        cout << t << endl;
    }
    cout << 0 << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <queue>
#include <list>
#include <cmath>
#include <stack>
#include <deque>
#include <iomanip>

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

const ll INF = 1LL<<60;
const ll MOD = 1000000007;

//cout << fixed << setprecision(10);

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

    cout << (N*(N-1))/2 << endl;

    return 0;
}

Measured memory_bytes: 256
using System;
using System.IO;

class Program
{
    static void Main(string[] args) {
        var writer = new StreamWriter(Console.OpenStandardOutput()) {AutoFlush = false};
        Console.SetOut(writer);
        Console.WriteLine(Solve());
        Console.Out.Flush();
    }
    static string Solve() {
        var N = Console.ReadLine();
        var len = N.Length;
        var sum = 0;
        for (int i = 0; i < len; i++) {
            sum += N[i] - '0';
        }
        return sum % 9 == 0 ? "Yes" : "No";
    }
}

Measured memory_bytes: 26472
#define debug_interval ','
#define dump_interval ' '
#define debug_toggle 1
//{
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define INT_MAX LLONG_MAX
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define fi first
#define se second
#define mp make_pair
#define rev reverse
#define dans dump(ans)
#define MOD 1000000007
#define amp(v,n) (v).count(n)?v[n]++:v[n]=1;
#define cni cin

//{
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class...A> inline void dump(){cout<<endl;}
template<class...A> inline void dump_rest() {cout<<endl;}
template<class T, class...A> inline void dump_rest(const T& first, const A&... rest){cout<<dump_interval<<first;dump_rest(rest...);}
template<class T,class...A> inline void dump(const T&first,const A&...rest){cout<<first;dump_rest(rest...);}
template<class...A> inline void debug(){cerr<<endl;}
template<class...A> inline void debug_rest() {cerr<<endl;}
template<class T, class...A> inline void debug_rest(const T& first, const A&... rest){cerr<<debug_interval<<first;debug_rest(rest...);}
template<class T,class...A> inline void debug(const T&first,const A&...rest){if(debug_toggle)cerr<<first,debug_rest(rest...);}
//}

typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}
template<int m>class mint{private:int i;public:mint() : i(0){}mint(int i): i((i%m+m)%m){}mint operator+(const mint& o){return o.i+i;}mint operator*(const mint& o){return o.i*i;}mint operator-(){return -i;}operator int() {return i;}};

//}

int h,w,D,q;
int py[111111],px[111111],d[111111];

main(){
    cin>>h>>w>>D;
    rep(i,h){
        rep(j,w){
            int t;
            cin>>t;
            py[t]=i;
            px[t]=j;
        }
    }
    for(int i=1+D;i<=h*w;i++){
        d[i]=d[i-D]+abs(px[i]-px[i-D])+abs(py[i]-py[i-D]);
    }
    cin>>q;
    rep(i,q){
        int l,r;
        cin>>l>>r;
        cout<<d[r]-d[l]<<endl;
    }
}




Measured memory_bytes: 3200
N = int(input())
s = input()

BK = '#'

c_bk = [0]
t_bk = 0

c_wt = [0]
t_wt = 0

for ss in s:
    if ss == BK:
        t_bk += 1
    else:
        t_wt += 1

    c_bk.append(t_bk)
    c_wt.append(t_wt)

ans = N
for i in range(0, N + 1):
    to_white = c_bk[i] - c_bk[0]
    to_black = c_wt[N] - c_wt[i]
    ans = min(ans, to_black + to_white)

print(ans)


Measured memory_bytes: 12776
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9+7;
#define rep(i,n) for(int i=0;i<n;i++)
int main(){
    long long ans = 1;
    long n;
    cin >> n;
    long long a[n];
    rep(i,n) cin >> a[i];
    long arr[3] = {0,0,0};
    rep(i,n){
        long now = a[i];
        long long cnt = 0;
        rep(j,3){
            if(now==arr[j]) cnt++;
        }
        ans*=cnt;
        ans%=MOD;
        rep(j,3){
            if(now==arr[j]){
                arr[j]++;
                break;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define rep(i, n) repd(i, 0, n)

using namespace std;

namespace mp = boost::multiprecision;

using ll = long long;
using Bint = mp::cpp_int;
ll mod = 1000000007;

int main() {
input:
    ll n, k;
    cin >> n >> k;

    ll temp[n];
    rep(i, n) { cin >> temp[i]; }

calculate:

    double p[n];
    rep(i, n) { p[i] = double(temp[i] + 1) / 2.0; }

    double sum[n];
    sum[0] = p[0];
    repd(i, 1, n) { sum[i] = sum[i - 1] + p[i]; }

    double sum_section[n - k + 1];

    rep(i, n - k + 1) {
        if (i == 0) {
            sum_section[i] = sum[k - 1];
        } else {
            sum_section[i] = sum[i + k - 1] - sum[i - 1];
        }
    }

    /* rep(i, n - k + 1) { cout << sum_section[i] << " "; } */
    /* cout << endl; */

    double temp_max = 0;
    rep(i, n - k + 1) { temp_max = max(temp_max, sum_section[i]); }

    // double ans = double(temp_max + k) / 2.0;

    printf("%.1f\n", temp_max);

    return 0;
}



Measured memory_bytes: 6528
#include <cstdio>
 
int n, a[200010];
 
int main(){
	scanf("%d", &n);
	for(int i=1; i<=n; i++)
		scanf("%d", &a[i]);
	int st = 1;
	long long cnt = 0;
	if(a[1] != 0) goto bad;
	for(int i=2; i<=n; i++){
		if(a[i] == 0) st = i;
		else if(a[i] > i-st) goto bad;
		else if(a[i] == i-st) cnt ++;
		else{
			cnt += a[i];
			st = i-a[i];
		}
	}
	printf("%lld\n", cnt);
	return 0;
	bad:
	puts("-1");
	return 0;
}

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

int main(){
  int n,m;
  long long SUM=0;
  cin >> n>>m;
  vector<int> line(n);
  for(int i=0;i<n;i++){
    cin >> line[i];
    SUM+=line[i];
  }
  sort(line.begin(), line.end());
  reverse(line.begin(), line.end());
  for(int i = 0;i < m;i++){
    if(line[i] < (double)SUM / (4*m)){
      cout<<"No"<<'\n';
      return 0;
    }
  }
    cout<<"Yes"<<'\n';
}


Measured memory_bytes: 3576
#include <iostream>
#include <cstring>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
#include <map>
#include <cstdlib>
using namespace std;

typedef long long ll;

int main()
{
    int N;
    cin >> N;
    vector<int> A(N), sorted(N);
    for(int i=0; i<N; i++){
        cin >> A[i];
        sorted[i]=A[i];
    }
    sort(sorted.begin(), sorted.end(), greater<int>());
    int M1=sorted[0], M2=sorted[1];
    for(int i=0; i<N; i++){
        if(A[i]==M1) cout << M2 << endl;
        else{
            cout << M1 << endl;
        }
    }



    return 0;
}

Measured memory_bytes: 3200
public class Main {
  private static void solve() {
    int n = ni();
    int[] a = na(n);

    int cnt = 0;
    for (int v : a) {
      while (v % 2 == 0) {
        cnt ++;
        v /= 2;
      }
    }
    System.out.println(cnt);
  }

  public static void main(String[] args) {
    new Thread(null, new Runnable() {
      @Override
      public void run() {
        long start = System.currentTimeMillis();
        String debug = args.length > 0 ? args[0] : null;
        if (debug != null) {
          try {
            is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
          } catch (Exception e) {
            throw new RuntimeException(e);
          }
        }
        reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
        solve();
        out.flush();
        tr((System.currentTimeMillis() - start) + "ms");
      }
    }, "", 64000000).start();
  }

  private static java.io.InputStream is = System.in;
  private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
  private static java.util.StringTokenizer tokenizer = null;
  private static java.io.BufferedReader reader;

  public static String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }

  private static double nd() {
    return Double.parseDouble(next());
  }

  private static long nl() {
    return Long.parseLong(next());
  }

  private static int[] na(int n) {
    int[] a = new int[n];
    for (int i = 0; i < n; i++)
      a[i] = ni();
    return a;
  }

  private static char[] ns() {
    return next().toCharArray();
  }

  private static long[] nal(int n) {
    long[] a = new long[n];
    for (int i = 0; i < n; i++)
      a[i] = nl();
    return a;
  }

  private static int[][] ntable(int n, int m) {
    int[][] table = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[i][j] = ni();
      }
    }
    return table;
  }

  private static int[][] nlist(int n, int m) {
    int[][] table = new int[m][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[j][i] = ni();
      }
    }
    return table;
  }

  private static int ni() {
    return Integer.parseInt(next());
  }

  private static void tr(Object... o) {
    if (is != System.in)
      System.out.println(java.util.Arrays.deepToString(o));
  }
}




Measured memory_bytes: 27280
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, x, n) for (int i = x; i < (n); i++)
#define all(n) begin(n), end(n)
struct cww
{
    cww()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
} star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template <typename T, typename... Ts>
auto make_v(size_t a, Ts... ts)
{
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }

template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v)
{
    for (auto &e : t)
        fill_v(e, v);
}
int main()
{
    int K;
    cin >> K;
    ll sum = 0;
    for (int a = 1; a <= K; a++)
    {
        for (int b = 1; b <= K; b++)
        {
            for (int c = 1; c <= K; c++)
            {
                sum += gcd(gcd(a, b), c);
            }
        }
    }
    cout << sum;
    return 0;
}

Measured memory_bytes: 3652