akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<stdlib.h>

#define H_MAX 50
#define H_MIN 2
#define W_MAX 50
#define W_MIN 2
#define CICADA_MAX 9
#define CICADA_MIN 0


class CICADA
{
	public:
		// Public member function
		int Search( void );
		int GetValue( void );
	private:
		// Private member variable
		int H = 0, W = 0;					// height, width
		int blk[H_MAX][W_MAX]={ { 0 } };	// Number of cicadas per block
		int cicada[W_MAX]={ 0 };			// Total of cicadas
		int cicadabak[W_MAX]={ 0 };			// Total of cicadas of one block above
};



int CICADA::Search(void)
{
	
	for( int i = 0; i < W; i++ )
	{
		for( int j = 0; j < i + 1; j++ )
		{
			cicada[i] += blk[0][j];
		}
	}
	
	for( int i = 1; i < H; i++ )
	{
		for( int j = 0; j < W; j++ )
		{
			cicadabak[j] = cicada[j];
			if( j == 0 )
			{
				cicada[j] = cicadabak[j] + blk[i][j];
			}
			else if( cicadabak[j] > cicadabak[j-1] )
			{
				cicada[j] = cicadabak[j-1] + blk[i][j];
			}
			else
			{
				cicada[j] = cicadabak[j] + blk[i][j];
			}
			cicadabak[j] = cicada[j];
		}
	}
	
	printf("%d\n", cicada[W-1]);
	
	return 0;
}



int CICADA::GetValue(void)
{
	char c;
	
	scanf( "%d %d%*c", &H, &W );
	
	for( int i = 0; i < H; i++ )
	{
		for( int j = 0; j < W; j++ )
		{
			scanf( "%c", &c );
			blk[i][j] = c - '0';
			
			if( ( blk[i][j] > CICADA_MAX ) || ( blk[i][j] < CICADA_MIN ) || ( blk[0][0] != 0 ) || ( blk[H-1][W-1] != 0 ) )
			{
				return -1;
			}
		}
		scanf("%*c");
	}
	
	return 0;
}



int main(void)
{
	CICADA Cicada;
	
	if( Cicada.GetValue() == -1 )
	{
		return -1;
	}
	
	Cicada.Search();
	
	return 0;
}




Measured memory_bytes: 2768
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define eb emplace_back
#define precision(n) cout << fixed << setprecision(n);
#define fast {ios_base::sync_with_stdio(false);cin.tie(NULL);}
int main()
{
    fast;
    long long int n,k,sum,x;
    cin>>n>>k;
    if(n%k==0)
    {
        cout<<0<<endl;
    }
    else if(n<k)
    {
        if(abs(n-k)>n)
        {
            cout<<n<<endl;
        }
        else{
           cout<<abs(n-k)<<endl;
        }
    }
    else
    {
        x=(n/k)+1;
        cout<<abs(n-k*x)<<endl;

    }

        return 0;
    }


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
ll powmod(ll n, ll k, ll m) {
ll r=1;
 for(; k>0; k >>=1) {
   if(k&1) r=(r*n)%m;
   n=(n*n)%m;
 }
  return r;
}

ll fact(ll n) {
ll a=1;
rep(i,n) {
a=a*(n-i);
}
return a;
}

ll pow(ll a, ll b) {
ll x=1;
rep(i,b) {
x=x*a;
}
return x;
}




int main() {
ll R;
  cin >>R;
  double a=2*R*3.1415926535;
  cout<<a<<endl;
}

Measured memory_bytes: 3732
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <vector>
#include <map>
#include <queue>
#include <set>
using namespace std;
typedef long long int lo;
#define pb push_back
#define mp make_pair
#define st first
#define nd second
#define inf (lo)1e10 + 7
#define FOR for(lo i = 0 ; i < n ; i++)
#define FORV for(lo i = 0 ; i < (lo)v.size() ; i++)
#define ii pair<lo,lo>
#define iii pair<lo, pair<lo,lo> >
#define si pair<string,lo>
lo a,b,c,d,e,n,m,k,t,h,x,y,a1[300005],a2[300005];
char c1,c2,c3,c4;
string s1,s2,s3,s4;
double d1,d2,d3;
vector <lo> v;
map <lo,lo> mp1;
map <lo,lo> mp2;
set <lo> stt;
queue <lo> q;
priority_queue <lo> pq;
lo vis [10000];
int main() {
    // freopen("gir.gir", "r", stdin);
    // freopen("cik.cik", "w", stdout);
    cin >> k >> n;
    for(lo i = 1 ; i <= n ; i++){
        cin >> a1[i];
    }
    for(lo i = 1 ; i < n ; i++){
        a2[i] = a1[i + 1] - a1[i];
    }
    a2[n] = a1[1] + (k - a1[n]);
    lo mx = -1, mxi;
    for(lo i = 1 ; i <= n ; i++){
        if(a2[i] > mx){
            mxi = i;
            mx = a2[i];
        }
        // cout << a2[i] << " ";
    }
    lo i = mxi + 1;
    lo ans = 0;
    while(1){
        if(i == n + 1){
            i = 0;
        }
        if(i == mxi){
            break;
        }
        ans += a2[i];
        i++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3840
import sys

readline = sys.stdin.readline

H, W = map(int, readline().split())
S = [readline().rstrip() for i in range(H)]

vert = [[0]*W for i in range(H)]
hori = [[0]*W for i in range(H)]

for y in range(H):
    for x in range(W):

        if x > 0 and S[y][x - 1] != '#':
            hori[y][x] = hori[y][x - 1]
        elif S[y][x] == '#':
            hori[y][x] = 0
        else:
            # hori
            count = 1
            while x + count < W and S[y][x + count] == '.':
                count += 1
            hori[y][x] = count

        if y > 0 and S[y - 1][x] != '#':
            vert[y][x] = vert[y - 1][x]
        elif S[y][x] == '#':
            vert[y][x] = 0
        else:
            # hori
            count = 1
            while y + count < H and S[y + count][x] == '.':
                count += 1
            vert[y][x] = count

ans = 0
for y in range(H):
    for x in range(W):
        a = hori[y][x] + vert[y][x] - 1
        ans = max(a, ans)

print(ans)

Measured memory_bytes: 120924
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	Scanner sc;

	int nn = 1121;
	int kk = 15;
	int dp[][] = new int[nn][kk];

	Main() {
		sc = new Scanner(System.in);

		dp[0][0] = 1;

		boolean pp[] = new boolean[nn];
		Arrays.fill(pp, true);
		pp[0] = false;
		pp[1] = false;
		pp[2] = true;

		for (int i = 0; i < nn; i++) {
			if (pp[i]) {
				for (int j = i << 1; j < nn; j += i) {
					pp[j] = false;
				}
			}
		}
		// System.out.println(Arrays.toString(pp));
		for (int k = 0; k < nn; k++) {
			if (!pp[k]) {
				continue;
			}
			for (int i = nn - 1; i >= k; i--) {
				for (int j = 14; j > 0; j--) {
					dp[i][j] += dp[i - k][j - 1];
				}
			}
		}
//		 System.out.println(Arrays.deepToString(dp));
	}

	void run() {
		for (;;) {
			int n = sc.nextInt();
			int k = sc.nextInt();
			if (n + k == 0) {
				break;
			}
			System.out.println(dp[n][k]);

		}
	}

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

Measured memory_bytes: 0
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define MOD (1000000007)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()

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

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

const ll INF = 1LL << 60;

int main(){
  int MAX = 100100;
  vi is_prime(MAX,1);
  is_prime[0] = 0; is_prime[1] = 0;
  for (int i = 2; i < MAX; i++) {
    if(is_prime[i]) for(int j = 2*i; j < MAX; j += i) is_prime[j] = 0;
  }

  vi S(MAX+1);
  rep(i, MAX){
    if(is_prime[i] && is_prime[(i+1)/2]) S[i+1] = S[i] + 1;
    else S[i+1] = S[i];
  }

  int Q; cin >> Q;
  vi l(Q), r(Q); rep(q, Q) cin >> l[q] >> r[q];
  rep(q, Q){
    std::cout << S[r[q]+1] - S[l[q]] << '\n';
  }
}


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

int main() {
    int k, a, b;
    cin >> k >> a >> b;
    int l;
    if ( a % k){
        l = k * (a / k) + k;
    }
    else {
        l = k;
    }
    if (l <= b) {
        cout << "OK\n";
    }
    else
    {
        cout << "NG\n";
    }
    
}


Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <bitset>

using namespace std;

bitset<100000> BlackSumple;
bitset<100000> WhiteSumple;

int main()
{
	string S;

	cin >> S;

	int ans;
	int ChangeTileNumBlack = 0;
	int ChangeTileNumWhite = 0;
	int N = S.size();
	bitset<100000> SBit(S);

	for (int i = 0; i < 100000; i += 2)
	{
		BlackSumple[i] = 1;
		WhiteSumple[i + 1] = 1;
	}

	for (int i = 0; i < N; i++)
	{
		if (BlackSumple[i] != SBit[i])
			ChangeTileNumBlack++;

		if (WhiteSumple[i] != SBit[i])
			ChangeTileNumWhite++;
	}

	if (ChangeTileNumBlack > ChangeTileNumWhite)
	{
		ans = ChangeTileNumWhite;
	}
	else
	{
		ans = ChangeTileNumBlack;
	}

	cout << ans;

	return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cstdio>
using namespace std;
int n, k, x, y;
int main() {
	cin >> n >> k >> x >> y;
	if (k >= n)
	{cout << n*x << endl;}
	else{cout << k*x + (n - k)*y << endl;}
	return 0;
}

Measured memory_bytes: 256
N = [int(x) for x in input()]
for i in range(1<<3):
    ans = N[0]
    li=[]
    for j in range(3):
        if((i>>j &1)==1):
            li+=['+']
            ans+=N[j+1]
        else:
            li+=['-']
            ans-=N[j+1]
    if(ans == 7):
        for j in range(3):
            print(str(N[j])+li[j],end='')
        print(str(N[3])+'=7')
        break

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

ll F(ll a, ll b)
{
  return std::max(floor(log10(a)), floor(log10(b))) + 1;
}

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

  ll res = 100;
  for (ll i = 1LL; i * i <= n; i++)
  {
    if (n % i == 0)
    {
      res = std::min(res, F(i, n / i));
    }
  }

  cout << res << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long int
# define pll pair<ll,ll>
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	int l,r,d;
	cin>>l>>r>>d;
	cout<<(r/d)-((l-1)/d);		
	return 0;
}

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

namespace AtCoder
{
    public class Code7
    {
        static void Main(string[] args)
        {
            string s1 = Console.ReadLine();

            Console.WriteLine(funcMain(s1));
        }

        static public string funcMain(string arg1)
        {
            string ret;

            if ((arg1.StartsWith(new string(arg1[0], 3))) || (arg1.EndsWith(new string(arg1[3], 3))))
                ret = "Yes";
            else
                ret = "No";
            return ret;
        }
    }
}


Measured memory_bytes: 13396
import java.util.Scanner;

public class Main {
    public static void main(String[] arg){
        Scanner sc = new Scanner(System.in);
        
        while(true){
            String line = sc.nextLine();
            String[] arr = line.split(" ");

            // String型をint型に変換
            int a = Integer.parseInt(arr[0]);
            int b = Integer.parseInt(arr[2]);

            int result = 0;

            if(arr[1].equals("+")){
                result = a + b;
            }else if(arr[1].equals("-")){
                result = a - b;
            }else if(arr[1].equals("*")){
                result = a * b;
            }else if(arr[1].equals("/")){
                result = a / b;
            }else if(arr[1].equals("?")){
                break;
            }

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


Measured memory_bytes: 26376
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;

ll X, Y;

int main(void){
    
    scanf("%lld %lld", &X, &Y);
    
    int ans = 1, cnt = 2;
    for(ll i = 1; X * i * cnt <= Y; i *= 2) ++ans;
    printf("%d\n", ans);
	
    return 0;
}


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

long long int p[200010],s[200010];

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n,x;
	cin>>n>>x;
	for(int i=1;i<=n;i++)
		cin>>p[i],s[i]=s[i-1]+p[i];
	long long int ans = 1e18;
	for(int k=1;k<=n;k++){
		int c = 3;
		long long int cur = 0;
		for(int j=n;j>0;j-=k){
			if(cur>ans)	break;
			long long int now = s[j]-s[max(j-k,0)];
			cur += now * max(5,c);
			c+=2;
		}
		ans = min(ans,cur+(k+n)*1LL*x);
	}
	cout<<ans<<endl;
}


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

int main(){
  int N,L,j=40000,l=0;
  cin>>N>>L;
  int k=N*(N-1)/2+L*N;
  for(int i=0;i<N;i++){
    if(j>abs(L+i)){
      j=abs(L+i);
      l=k-(L+i);
    }
  }
  cout<<l<<endl;
}

Measured memory_bytes: 256
a,b=map(int,input().split())
ans=-1
List=[list(map(int,input().split())) for i in range(b)]
for i in range(1001):
    j=str(i)
    if len(j)==a and all(j[s-1]==str(t) for s,t in List):
        ans=i
        break
print(ans)
    

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

int main(){
  int n;
  cin >> n;
  int state,c;
  for(int i=0;i<n;++i){
    stack<char> q;
    int a=0,b=0;
    // a
    state=1;
    while((c=getchar())!=' '){
      if('2'<=c&&c<='9') state=c-'0';
      else if(c=='m'){a+=1000*state; state=1;}
      else if(c=='c'){a+=100*state; state=1;}
      else if(c=='x'){a+=10*state; state=1;}
      else if(c=='i')a+=state;
    }
    // b
    state=1;
    while((c=getchar())!='\n'){
      if('2'<=c&&c<='9') state=c-'0';
      else if(c=='m'){b+=1000*state; state=1;}
      else if(c=='c'){b+=100*state; state=1;}
      else if(c=='x'){b+=10*state; state=1;}
      else if(c=='i')b+=state;
    }

    int sum=a+b;
    if(sum%10>=2) {q.push('i'); q.push('0' + sum%10);}
    else if(sum%10==1) q.push('i');
    sum/=10;
    if(sum%10>=2) {q.push('x'); q.push('0' + sum%10);}
    else if(sum%10==1) q.push('x');
    sum/=10;
    if(sum%10>=2) {q.push('c'); q.push('0' + sum%10);}
    else if(sum%10==1) q.push('c');
    sum/=10;
    if(sum%10>=2) {q.push('m'); q.push('0' + sum%10);}
    else if(sum%10==1) q.push('m');

    while(!q.empty()){
      cout << q.top();
      q.pop();
    }
    putchar('\n');
  }

}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;

 
int main() {

    ll n,m,k;
    cin >> n >> m >> k;
    vector<ll> a(n);
    ll sum = 0;
    rep(i,n) {
        ll x;
        cin >> x;
        sum += x;
        a[i] = sum;
    }
    vector<ll> b(m);
    sum = 0;
    rep(i,m) {
        ll x;
        cin >> x;
        sum += x;
        b[i] = sum;
    }
    ll ans = 0;
    rep(i,n) {
        ll res = 0;
        ll ma = k;
        ma -=a[i];
        if(ma>=0) {
            res += i+1;
            res +=(upper_bound(all(b),ma) - b.begin());
        }
        ans = max(res,ans);
    }
    ans = max((ll)(upper_bound(all(b),k) - b.begin()),ans);

    cout << ans << endl;


 return 0;
}

Measured memory_bytes: 6356
#include<iostream>
using namespace std;
int main()
{
long long n,k,s;
cin>>n>>k>>s;
if(s==1e9){

for(int i=1;i<=k;++i)
{
cout<<s<<' ';
}
for(int i=1;i<=n-k;++i)
cout<<1<<' ';
}
else{
for(int i=1;i<=k;++i)
cout<<s<<' ';
for(int i=1;i<=n-k;++i)
cout<<s+1<<' ';
}
return 0;
}

Measured memory_bytes: 1280
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;

#define int long long

const int MOD = 1e9 + 7;

int add(int a, int b) {
	return (a + b) % MOD;
}

int mul(int a, int b) {
	return (a * b) % MOD;
}


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

    int N;

    cin >> N;

    int acc = 1;

    for(int i=0; i<N; i++){
        acc *= (i+1);
        acc %= MOD;
    }

    cout << acc << endl;


    return 0;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){
  int a, b, k;
  cin >> a >> b >> k;
  
  for(int i = min(a, b); i >= 1; --i){
    if(a % i == 0 && b % i == 0){
      k--;
      if(k == 0){
        cout << i << endl;
      }
    }
  }
}


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

int main(){
  int k,a,b;
  std::cin >> k>>a>>b;
  bool flag=false;
  for (int i = a; i < b+1; i++) {
    if(i%k==0)flag=true;
  }
  if(flag)std::cout << "OK" << '\n';
  else std::cout << "NG" << '\n';

}


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

vector<int> adj_list[30];

// Check whether a set dset of size k is a dominating set of a graph
// of n vertices.
bool is_dominating_set(int dset, int n)
{
  bool dominated[30];
  int rem = n;                  // ??????????????????????????????????????°

  for (int i=0;i<30;i++) dominated[i]=false;
  for (int v=0;v<n;v++)
  {
    int vm = 1<<v;              // ??????v?????´??°??¨???
    int im;
    if (vm & dset)              // v???dset?????????
    {
      for (int i=0;i<adj_list[v].size();i++)
      {
        int w = adj_list[v][i];
        if (!dominated[w]) { dominated[w] = true; rem--; }
      }
    }
  }
  if (rem == 0) return true;
  else return false;
}

int main()
{
  int n, m;
  int u, v;
  while (cin >> n >> m)
  {
    bool found = false;

    if (n == 0) return 0;
    for (int i=0;i<n;i++) adj_list[i].clear();
    for (int i=0;i<n;i++) adj_list[i].push_back(i);
    for (int i=0;i<m;i++)
    {
      cin >> u >> v;
      adj_list[u].push_back(v);
      adj_list[v].push_back(u);
    }

    int dset;
    for (int k=1;k<=n;k++)
    {
      // {0,...,n-1}?????¨???????????§????????????k??§???????????????????????????
      // ????????°???????????°????????????????????£??¬???????????????????????§
      dset = (1 << k) - 1;
      while (dset < 1<<n)
      {
        if (is_dominating_set(dset, n))
        {
          cout << k << endl;
          found = true;
        }
        if (found) break;

        int x = dset & -dset;
        int y = dset + x;
        dset = ((dset & ~y) / x >> 1) | y;
      }
      if (found) break;
    }
  }
}

Measured memory_bytes: 1216
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <string>
#include <set>
#include <cstdint>
#include <numeric>
#include <cmath>
#include <iomanip>
#define INF 1000000000
#define LLINF 2000000000000000
#define MOD 1000000007
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define LOOP(i,N) for(int i=0;i<N;i++)
#define LOOP1(i,N) for(int i=1;i<=N;i++)
#define rad(_deg) (((_deg)/360)*2*M_PI)

typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
// #define int long long

signed main(){
  int a,b,h,m;
  cin >> a >> b >> h >> m;

  double j = 6.0*m;
  double f = 0.5*(60*h + m);
  double k = abs(j-f);
  k = (k >= 180 ? 360-k : k);
  cerr << j << " " << f << " " << k << endl;
  k = rad(k);
  cerr << k << endl;
  double c =  a*a + b*b - 2 * a*b * cos(k);
  cout << fixed << setprecision(12) << sqrt(c) << endl;
}


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

int main(void)
{
   int n, i, x=0;
   int a[4];

   scanf("%d",&n);

   for(i=0;i<=3;i++)
   {
       a[i]=n/pow(10,3-i);
       n=n-a[i]*pow(10,3-i);
   
       if(a[i]==2)
       {
           x+=1;
       }
   }

   printf("%d\n",x);

   return 0;
}

Measured memory_bytes: 128
import sys,os,math
from collections import Counter, defaultdict, deque
import bisect
from sys import stdin, stdout
from itertools import repeat
import Queue
import time
 
 
# sys.stdin = open('input')
# n, k = map(int, raw_input().split())
# da = map(int, raw_input().split())
# db = map(int, raw_input().split())
 
BT = int(1e9)
def main():
    start = time.time()
    m, k = map(int, raw_input().split())
    if k >= (1<<m):
        print -1
        return
    if m==1 and k==0:
        print 1,1,0,0
        return
    if m==1 and k==1:
        print -1
        return
    ans = []
    for i in range(1<<m):
        if i!=k:
            ans.append(i)
    ans.append(k)
    for i in range((1<<m)-1, -1, -1):
        if i!=k:
            ans.append(i)    
    ans.append(k)
    print ' '.join(map(str, ans))

 
main()

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

int g[15][15];

int main(){
    int n;
    cin>>n;
    rep(i,n)rep(j,n)g[i][j]=-1;
    rep(i,n){
        int m;
        cin>>m;
        rep(j,m){
            int a,x;
            cin>>a>>x;
            --a;
            g[i][a]=x;
        }
    }
    int ans=0;
    rep(i,1<<n){
        vector<int>d(n);
        rep(j,n){
            if(i>>j&1){
                d[j]=1;
            }
        }
        bool ok=true;
        rep(j,n){
            if(d[j]){
                rep(k,n){
                    if(g[j][k]==-1)continue;
                    if(g[j][k]!=d[k])ok=false;
                }
            }
        }
        if(ok)ans=max(ans,__builtin_popcount(i));
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int gcd(int x, int y){
    while(1){
        if(x == y) return x;
        else if(x > y) x = x-y;
        else           y = y-x;
    }
}
int main(){
    int A,B,C;bool can = true;
    cin >> A >> B >> C;
    if( gcd(A,B) != 1 && C % gcd(A,B) != 0 ) can = false;
    if(can) cout << "YES" << endl;
    else    cout << "NO"  << endl;
    return 0;
}

Measured memory_bytes: 256
N, M, C = map(int, input().split())
B_list = list(map(int, input().split()))
answer = 0
for i in range(N):
    A_list = list(map(int, input().split()))
    C_list = [A * B for(A, B) in zip(A_list, B_list)]
    if sum(C_list) + C > 0:
        answer += 1
print(answer)

Measured memory_bytes: 3064
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

import java.util.*;

/**
 *
 * @author nai
 */
public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        int[] guu = {1,-1,0};
        int[] ki = {-1,1,0};
        Scanner sc = new Scanner(System.in);
        long A = sc.nextLong();
        long B = sc.nextLong();
        long C = sc.nextLong();
        long K = sc.nextLong();
        long ans = 0;
        if(K % 2 == 0){
            ans = A - B;
        }else{
            ans = -A + B;
        }
        if(ans > Math.pow(10, 18)){
            System.out.println("Unfair");
            return;
        }
        System.out.println(ans);
    }
    
}

Measured memory_bytes: 22996
import java.util.Scanner;
//【156A】
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
	int n =sc.nextInt();
	int r =sc.nextInt();
	if (n<10) {
		r += 100*(10-n);
	}
		System.out.println(r);
		
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
	}
	//----------------------------------------
	//置き場
	//----------------------------------------
}

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

#define int long long
#define pb push_back
#define ff first
#define ss second
#define all(a) a.begin(), a.end()

const int mod = 1e9+7;
const int inf = 2e18;

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

	int n;
	cin>>n;
	int d = (n/1000)+1;	
	int val = d*1000;
	//cout<<((val-n)<1000)?(val-n):0<<'\n';
	//cout<<val<<'\n';
	if(val-n==1000)
	{
		cout<<0<<'\n';
	}
	else
	{
		cout<<val-n<<'\n';
	}
	return 0;
}	

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

int main(void) {
    string s;
    cin >> s;
    int n;
    for (int i = 0; i < s.size(); ++i) {
        if (s[i] == 'A') {
            for (int j = s.size() - 1; j > i; --j) {
                if (s[j] == 'Z') {
                    cout << j - i + 1;
                    return 0;
                }
            }
        }
    }
    return 0;
}

Measured memory_bytes: 640
#include <cstdio>
#include <vector>
#include <algorithm>
#include <map>
#define ll long long
#define P 150094669656737489LL

static ll memo[51][51] = {{}};

ll comb(int n, int k) {
	if(k==1) return n;
	if(k==0) return 1;
	if(n==k) return 1;
	if(memo[n][k]!=0) return memo[n][k];
	return memo[n][k] = comb(n-1, k-1)+comb(n-1,k);
}

int main() {
	int n, a, b;
	std::vector<ll> v;
	std::map<ll, int> m;
	scanf("%d %d %d", &n, &a, &b);
	for(int i=1; i<=n; i++) {
		ll tmp;
		scanf("%lld", &tmp);
		v.push_back(tmp);
	}
	std::sort(v.begin(), v.end(), std::greater<ll>());
	if(v[0]==v[a-1]) {
		double ans = (double)(v[0]*a)/a;
		int cnt = 0;
		for(int i=0; i<n; i++) {
			if(v[i]==v[0]) cnt++;
		}
		ll c = 0;
		for(int i=a-1; i<=b-1; i++) {
			if(v[i]!=v[0]) break;
			else c += comb(cnt, i+1);
		}
		printf("%f\n%lld\n", ans, c);
		return 0;
	} else {
		double ans = 0;
		for(int i=0; i<a; i++) {
			ans += v[i];
		}
		ans = ans / a;
		int cnt1 = 0;
		for(int i=0; i<n; i++) {
			if(v[i]==v[a-1]) cnt1++;
		}
		int cnt2=0;
		for(int i=0; i<a; i++) {
			if(v[i]==v[a-1]) cnt2++;
		}
		printf("%f\n%lld\n", ans, comb(cnt1, cnt2));
		return 0;
	}
	return 0;
}



Measured memory_bytes: 504
import java.util.*;
 
public class Main{
    
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);

        int D = sc.nextInt();
        int N = sc.nextInt();
        sc.close();

        if(N!=100)
            System.out.println((int)Math.pow(100, D) * N);
        else{
            if(D == 0){
                System.out.println(101);
            }
            if(D == 1){
                System.out.println(10100);
            }
            if(D == 2){
                System.out.println(1010000);
            }
        }
    }

}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
#include <stdio.h>
#include<iostream>
#include<cstdio>
#include<bitset>
#include<algorithm>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<string.h>
#include<cmath>
#include<utility>
#include<functional>
#include<map>
#include<set>
#include<cctype>
#include<fstream>
#include <numeric>
#include <iomanip>
#include <cstring> 
using namespace std;
using ll=long long;

#define FOR(i, a, b) for( int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for( int i=(a);i>=(b);i--)
#define LFOR(i, a, b) for( long long int i=(a);i<=(b);i++)
#define LRFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define LLONG_MAXs 9223372036854775800

#include <iostream>
#include <cmath>
using namespace std;
 

 
bool isPrimeNum( ll x ){ // 素数である場合 true を返す
  if( x <= 1 ){ // 1以下である場合は素数でないことがすぐにわかる
    return false;
  }
  // sqrt( double型 ) は引数の平方根を double型で返すので、int型でキャスト
  int n = (int)sqrt( (double)x );
  for( int i = 2; i <= n; i++ ){
    if( x % i == 0 ){ // 割り切る整数がある場合、即判定終了
      return false;
    }
  }
  return true; // 割り切る整数がない場合、素数である
}

ll myPow(ll x, ll n, ll m){
  if(n == 0)
    return 1;
  if(n % 2 == 0)
    return myPow(x * x % m, n / 2, m);
  else
    return x * myPow(x, n - 1, m) % m;
}

constexpr ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
constexpr ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll abs(ll a,ll b){
if(a>=b)return a-b;
if(a<b)return b-a;
}
constexpr ll min(ll a,ll b){
if(a>=b)return b;
if(a<b)return a;
}

constexpr ll max(ll a,ll b){
if(a>=b)return a;
if(a<b)return b;
}

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

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main() {

  ll N;
  cin>>N;
  ll F[N][10];
  ll P[N][10];
  FOR(i,0,N-1){
    FOR(j,0,9){
      cin>>F[i][j];
    }
  }
  FOR(i,0,N-1){
    FOR(j,0,10){
      cin>>P[i][j];
    }
  }

  ll ans=-LLONG_MAXs;
    ll n=10;

    // 全探索 --- bit は {0, 1, ..., n-1} の 2^n 通りの部分集合全体を動きます。
    for (int bit = 1; bit < (1<<n); ++bit)
    {
      ll tmp=0;
      FOR(j,0,N-1){
        ll cnt=0;
        for (int i = 0; i < n; ++i) {
            if (bit & (1<<i) && (F[j][i])==1) { // i 判定
                cnt++;
            }
        }
        tmp=tmp+P[j][cnt];
        //cout<<j<<" "<<bit<<" "<<tmp<<endl;
      }

      ans=max(ans,tmp);



    }
    cout<<ans<<endl;


  return 0;
}
 


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <numeric>
#include <cstdint>
#include <iomanip>
#include <set>
using ll = long long;
#define fast_io(); std::ios_base::sync_with_stdio(0); std::cin.tie(0); std::cout.tie(0);

int main(){
    fast_io();

    int n,m; std::cin >> n >> m;
    int max_l=0, min_r=1145141919;
    for(int i=0; i<m; i++){
        int l,r; std::cin >> l >> r;
        max_l = std::max(max_l, l);
        min_r = std::min(min_r, r);
    }

    std::cout << std::max(min_r-max_l+1,0) << "\n";
    return 0;
}


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

#define INF 1000000021
#define MOD 1000000007
#define pb push_back
#define sqr(a) (a)*(a)
#define M(a, b) make_pair(a,b)
#define T(a, b, c) make_pair(a, make_pair(b, c))
#define F first
#define S second
#define all(x) (x.begin(), x.end())
#define deb(x) cerr << #x << " = " << x << '\n'
#define N 222222

using namespace std;
//using namespace __gnu_pbds;

typedef long double ld;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

const ld pi = 2 * acos(0.0);
template<class T> bool umin(T& a, T b){if(a>b){a=b;return 1;}return 0;}
template<class T> bool umax(T& a, T b){if(a<b){a=b;return 1;}return 0;}
template<class T, class TT> bool pal(T a, TT n){int k=0;for(int i=0;i<=n/2;i++){if(a[i]!=a[n-i-1]){k=1;break;}}return k?0:1;}

//int month[] = {0,31,28,31,30,31,30,31,31,30,31,30,31};

int main()
{
	ll n;
	cin >> n;
	ll ans = 0;
	ll s = 0;
	ll t = n;
	ll res = 0;
	while(t --)
	{
		s *= 10;
		s += 7;
		s %= n;
		ans ++;
		if(!s)
		{
			res = 1;
			break;	
		}
	}
	if(!res)
		ans = -1;
	cout << ans << '\n';




	





	getchar();
	getchar();
	return 0;
	//ios::sync_with_stdio(false);
	//cin.tie(0);
}

Measured memory_bytes: 3636
#pragma gcc optimize("Ofast")
#include <bits/stdc++.h>
#define pb push_back
using namespace std;
const int m=1e9+7;
const int N=1005;

int h,w;
int dp[N][N];
char a[N][N];

int main() {
    ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    cin>>h>>w;
    for (int i=1;i<=h;++i) 
    for (int j=1;j<=w;++j) cin>>a[i][j];
    dp[1][0]=1;
    for (int i=1;i<=h;++i)
    for (int j=1;j<=w;++j) {
        if (a[i][j]=='#') continue;
        dp[i][j]=(dp[i-1][j]+dp[i][j-1])%m;
    }
    cout<<dp[h][w]<<'\n';
}

Measured memory_bytes: 5120
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,n) for(int i=(a); i<(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;

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

    int n; cin >> n;
    map<string, int> mp;
    rep(i, n) {
        string x;
        cin >> x;
        mp[x]++;
    }

    int max_freq = 0;
    vector<string> ans;
    for (const auto & m: mp) {
        auto word = m.first;
        auto freq = m.second;
        if (freq > max_freq) {
            max_freq = freq;
            ans.clear();
            ans.push_back(word);
        } else if (freq == max_freq) {
            ans.push_back(word);
        }
    }

    for (const auto a: ans)  cout << a << endl;
}

Measured memory_bytes: 25584
#!/usr/bin/env python3
#ABC81 D

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n = I()
a = LI()
M,m = max(a),min(a)
Mi,mi = a.index(M),a.index(m)
for i in range(n-1):
    if a[i] > a[i+1]:
        break
else:
    print(0)
    quit()
for i in range(n):
    if a[i] < 0:
        break
else:
    print(n-1)
    for i in range(n-1):
        print(i+1,i+2)
    quit()
for i in range(n):
    if a[i] > 0:
        break
else:
    print(n-1)
    for i in range(n-1)[::-1]:
        print(i+2,i+1)
    quit()
if abs(M) >= abs(m):
    print((n-1)*2)
    for i in range(n):
        if i == Mi:
            continue
        print(Mi+1,i+1)
    for i in range(n-1):
        print(i+1,i+2)
else:
    print((n-1)*2)
    for i in range(n):
        if i == mi:
            continue
        print(mi+1,i+1)
    for i in range(n-1)[::-1]:
        print(i+2,i+1)



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

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> ii;
typedef tuple<ll, ll, ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define REP(i,n) for (ll i = 0; i < n; ++i)
#define REPR(i,n) for (ll i = n-1; i >= 0; --i)
#define FOR(i,m,n) for (ll i = m; i < n; ++i)
#define FORR(i,m,n) for (ll i = n-1; i >= m; --i)
#define FORE(x,xs) for (const auto& x : xs)
#define ALL(v) v.begin(), v.end()

ll N;

ll solve() {
    if (N&1) return 0;
    ll n = N/2;
    ll ret = 0;
    while (n) {
        ret += n/5;
        n /= 5;
    }
    return ret;
}

int main() {
    cin >> N;
    cout << solve() << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll qpow(ll y)
{
    ll sum=1,t=2;
    while(y)
    {
        if(y%2==1) sum*=t;
        y/=2;
        t*=t;
    }
    return sum;
}
int main()
{
    ll l,r;
    scanf("%lld %lld",&l,&r);
    ll ans=0,num=0;
    if(l%2==1) ans^=l,l++;
    if(r%2==0) ans^=r,r--;
    if(r>l)
    {
        num=(r-l+1ll)/2;
        if(num%2==1) ans^=1;
    }
    else if(r==l) ans^=l;
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int d;
    cin>>d;
    if(d==22)
    {
        cout<<"Christmas Eve Eve Eve"<<endl;
    }
    else if(d==23)
    {
        cout<<"Christmas Eve Eve"<<endl;
    }
    else if(d==24)
    {
        cout<<"Christmas Eve"<<endl;
    }
    else if(d==25)
    {

        cout<<"Christmas"<<endl;
    }
    return 0;
}


Measured memory_bytes: 3028
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using ll = long long;
using namespace std;
struct rgb
{
    int R=0;
    int G=0;
    int B=0;
};

int main(){
    ll n,ans=0;
    string s;
    cin>>n>>s;
    vector<rgb> tup(n+1);
    for(int i=n;i>=0;i--){
        switch (s[i])
        {
            case 'R':
            tup[i].R=tup[i+1].R+1;
            tup[i].G=tup[i+1].G;
            tup[i].B=tup[i+1].B;
            break;
            case 'G':
            tup[i].R=tup[i+1].R;
            tup[i].G=tup[i+1].G+1;
            tup[i].B=tup[i+1].B;
            break;
            case 'B':
            tup[i].R=tup[i+1].R;
            tup[i].G=tup[i+1].G;
            tup[i].B=tup[i+1].B+1;
            break;
            default:
            break;;

        }
    }
    for(int i=0;i<n-2;i++){
        for(int j=i+1;j<n-1;j++){
            if(s[i]==s[j])continue;
            if(s[i]=='R'){
                if(s[j]=='G') {
                    ans+=tup[j+1].B;
                    if(j+j-i<n)
                    if(s[j+j-i]=='B') ans--;
                }
                if(s[j]=='B') {
                    ans+=tup[j+1].G;
                    if(j+j-i<n)
                    if(s[j+j-i]=='G') ans--;
                }
            }

            else if(s[i]=='G'){
                if(s[j]=='R') {
                    ans+=tup[j+1].B;
                    if(j+j-i<n)
                    if(s[j+j-i]=='B') ans--;
                }
                if(s[j]=='B') {
                    ans+=tup[j+1].R;
                    if(j+j-i<n)
                    if(s[j+j-i]=='R') ans--;
                }
            }

            else if(s[i]=='B'){
                if(s[j]=='R') {
                    ans+=tup[j+1].G;
                    if(j+j-i<n)
                    if(s[j+j-i]=='G') ans--;
                }
                if(s[j]=='G') {
                    ans+=tup[j+1].R;
                    if(j+j-i<n)
                    if(s[j+j-i]=='R') ans--;
                }
            }
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3668
// Ambition without ammunition is dangerous
#include <iostream>
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long int ll;
typedef long double dl;
#define PI  3.14159265358979323846
#define M   1000000007
ll fast(ll n,ll a,ll m)
{
    if(n==0)
        return 1;
    else if(n==1)
        return a;
    else
    {
        ll r=fast(n/2,a,m);
        if(n%2==0)
        {
            return (((r%m)*(r%m))%m);
        }
        else
        {
            return (((((r%m)*a)%m)*r)%m);
        }
    }
}
ll Sum(ll n)
{
    ll d=n*(n+1);
    d/=2;
    return d;
}
int main()
{
    ll N,K;
    cin>>N>>K;
    ll ans=0,i;
    for(i=K;i<=N+1;i++)
    {
      ll A=(i*N)%M;
      ll B=(i*(i-1))%M;
      A-=B;
      A++;
      if(A<0)
      {
          A+=M;
          A%=M;
      }
      ans=(ans%M+A%M)%M;


    }
    cout<<ans;

}


Measured memory_bytes: 3636
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int K= sc.nextInt();
		int X= sc.nextInt();
		int A=X-(K-1);
		int B=X+(K-1);	
		String ans=""+(A);

		for(int i=A+1;i<=B;i++){	
		ans=ans+" "+(i);			
		}	
		System.out.println(ans);	
	}
}

Measured memory_bytes: 21844
/*
    Author - Param Kothari
    Ah shit, here we go again
*/

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

#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back
#define mk make_pair

typedef long long ll;
typedef long double ld;

const ll inf = 1e18;

void solve(){
    int n, k;
    cin >> n >> k;
    vector<ll> a(n + 1);
    for(int i = 1; i <= n; i++){
        cin >> a[i];
    }
    vector<ll> dp(n + 1);
    dp[0] = 0;
    dp[1] = 0;
    for(int i = 2; i <= n; i++){
        ll curr = inf;
        for(int j = 1; j <= min(i - 1, k); j++){
            curr = min(curr, dp[i - j] + abs(a[i - j] - a[i]));
        }
        dp[i] = curr;
    }
    cout << dp[n] << "\n";
    return;
}

int main(){
    IOS;
    int t = 1;
    // cin >> t;
    for(int i = 1; i <= t; i++){
        solve();
    }
    return 0;
}

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

int main() {
	int N;
  cin >> N;
  if (N/100 == 7){
    cout << "Yes" << endl;
  }
  else if ((N/10)%10==7){
    cout << "Yes" << endl;
  }
  else if (N%10==7){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
          
}


Measured memory_bytes: 3596
#include<stdio.h>
int main(){
  int N;
  char S[200001];
  scanf("%d",&N);
  scanf("%s",S);

  int i;
  int x,y,a[200001]={},b[200001]={};
  for(i=0;i<=N-1;i++){
    if(S[i]=='#'){
      a[i+1]=a[i]+1;
      b[i+1]=b[i];
    }
    else if(S[i]=='.'){
      b[i+1]=b[i]+1;
      a[i+1]=a[i];
    }
  }
  int c[200001]={};
  for(i=0;i<=N;i++){
      c[i]=a[i]+b[N]-b[i];
  }
  int e=N;
  for(i=0;i<=N;i++){
    if(c[i]<e){
      e=c[i];
    }
  }

  printf("%d",e);

  return 0;
}


Measured memory_bytes: 2688
# coding=UTF-8
from collections import deque
from operator import itemgetter
from bisect import bisect_left, bisect
import itertools
import sys
import math
import numpy as np
import time
sys.setrecursionlimit(10**6)
input = sys.stdin.readline


def main():
    n, k = map(int, input().split())
    r, s, p = map(int, input().split())
    t = input()

    myhand = [None] * n
    point = 0

    for i in range(n):
        if t[i] == "r":
            if myhand[i] != "np":
                point += p
                if i+k < n:
                    myhand[i+k] = "np"
            else:
                if i+k < n:
                    myhand[i + k] = None
        elif t[i] == "s":
            if myhand[i] != "nr":
                point += r
                if i+k < n:
                    myhand[i+k] = "nr"
            else:
                if i+k < n:
                    myhand[i + k] = None
        elif t[i] == "p":
            if myhand[i] != "ns":
                point += s
                if i+k < n:
                    myhand[i+k] = "ns"
            else:
                if i+k < n:
                    myhand[i + k] = None

    print(point)


if __name__ == '__main__':
    main()


Measured memory_bytes: 27668
import java.util.Scanner;

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

	String S = scan.next();

	int min = Integer.MAX_VALUE;
	
	for(int i = 0; i < S.length()-2; i++){
	    int num = Integer.parseInt(S.substring(i, i+3));

	    //753との差の絶対値を求める
	    int diff = Math.abs(num-753);

	    if(min > diff){
		min = diff;
	    }
	}

	System.out.println(min);
    }
}


Measured memory_bytes: 23124
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
int vector_finder(std::vector<ll> vec, int number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}

ll calc(ll left, ll right) {
  ll res = 0;
  if(left >= right) {
    res = (left + 1) * left * 0.5;
    res += (right - 1) * right * 0.5;
  } else {
    res = (left - 1) * left * 0.5;
    res += (right + 1) * right * 0.5;
  }
  return res;
}

int main() {
  string S; cin >> S;
  ll ans, left, right; ans = 0; left = 0; right = 0;
  bool flag = false;
  REP(i, S.size()) {
    if(flag == true) {
      if(S[i] == '<') {
        ans += calc(left, right);
        left = 0;
        right = 0;
      }
    }
    if(S[i] == '<') flag = false;
    if(S[i] == '>') flag = true;
    if(flag == false) left++;
    else if(flag == true) right++;
  }
  ans += calc(left, right);
  cout << ans << endl;
}

Measured memory_bytes: 4308
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <list>
#include <queue>
using namespace std;

int inf = (1 << 30);
int mod = 1e9 + 7;
int64_t inf64 = (1LL << 60);

template <typename T>
T gcd(T a, T b) {
    if(b == 0) return a;
    else return gcd(b, a % b);
}

template <typename T>
T lcm(T a, T b) {
    T g = gcd(a, b);
    return a / g * b;
}

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

int lower_bound(vector<int> a, int key){
    int left = -1, right = a.size();
    while(right - left > 1){
        int mid = left + (left + right) / 2;
        if(check(a, mid, key)) right = mid;
        else left = mid;
    }
    return right;
}

int main(){

    int W, H, N;
    cin >> W >> H >> N;
    vector<int> x(N), y(N), a(N);
    for(int i = 0; i < N; i++) cin >> x[i] >> y[i] >> a[i];

    vector<vector<int>> map(W, vector<int>(H, 0));
    for(int i = 0; i < N; i++){
        if(a[i] == 1){
            for(int w = 0; w < x[i]; w++){
                for(int h = 0; h < H; h++){
                    map[w][h] = 1;
                }
            }
        }
        if(a[i] == 2){
            for(int w = x[i]; w < W; w++){
                for(int h = 0; h < H; h++){
                    map[w][h] = 1;
                }
            }
        }
        if(a[i] == 3){
            for(int w = 0; w < W; w++){
                for(int h = 0; h < y[i]; h++){
                    map[w][h] = 1;
                }
            }
        }
        if(a[i] == 4){
            for(int w = 0; w < W; w++){
                for(int h = y[i]; h < H; h++){
                    map[w][h] = 1;
                }
            }
        }
    }

    int ans = 0;
    for(int i = 0; i < W; i++) for(int j = 0; j < H; j++) if(map[i][j] == 0) ans++;
    cout << ans << endl;

    return 0;
}

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

typedef long long int in;

double dp[305][305][305],m;
in aa,bb,cc,a,b,c;

int main() 
{
	in n,i;
	cin>>n;
	
	m=n;
	
	for(i=0;i<n;++i)
	{
	    in v;
	    cin>>v;
	    
	    if(v==1)
	    ++aa;
	    if(v==2)
	    ++bb;
	    if(v==3)
	    ++cc;
	}
	
	for(c=0;c<=n;++c)
	for(b=0;b<=n;++b)
	for(a=0;a<=n;++a)
	{
	    if(a+b+c>0)
	    ++dp[a][b][c];
	    
	    if(a>0)
	    dp[a][b][c]+=((a/m)*dp[a-1][b][c]);
	    
	    if(b>0)
	    dp[a][b][c]+=((b/m)*dp[a+1][b-1][c]);
	    
	    if(c>0)
	    dp[a][b][c]+=((c/m)*dp[a][b+1][c-1]);
	    
	    if(a+b+c>0)
	    dp[a][b][c]*=(m/(a+b+c));
	}
	    
	cout<<fixed<<setprecision(10)<<dp[aa][bb][cc];
	
	return 0;
}


Measured memory_bytes: 219392
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		int a[]= {1,2,3,4,5,6,7,8,9,2,4,6,8,10,12,14,16,18,3,6,9,12,15,18,21,24,27,4,8,12,16,20,24,28,32,36,5,10,15,20,25,30,35,40,45,6,12,18,24,30,36,42,48,54,7,14,21,28,35,42,49,56,63,8,16,24,32,40,48,56,64,72,9,18,27,36,45,54,63,72,81};
		boolean b=false;
		Scanner src=new Scanner(System.in);
		int N=src.nextInt();
		for(int i=0;i<a.length;i++) {
			if(N==a[i]) {
				b=true;
			}
		}
		if(b==true) {
			System.out.println("Yes");
			
		}
		else {
			System.out.println("No");
		}
		

	}

}


Measured memory_bytes: 24020