akhauriyash/Code-Regression huggingface dataset:
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;
import java.util.Random;

public class Main {
    private static FastScanner sc = new FastScanner();
    private static boolean DEBUG_FLG = false;

    public static void main(String[] args) {
    	int N = sc.nextInt();
    	int X = sc.nextInt();
    	int[] L = new int[N];
    	for(int i=0; i<N; i++) {
    		L[i] = sc.nextInt();
    	}
    	int ans = 1;
    	int now = 0;
    	for(int i=0; i<N; i++) {
    		now += L[i];
    		if(now <= X) {
    			ans++;
    		} else {
    			break;
    		}
    	}
    	System.out.println(ans);
    }

    static void debug(long... args) {
    	if(!DEBUG_FLG) return;
    	boolean flg = false;
    	for(long s : args) {
    		if(flg) System.out.print(" ");
    		flg = true;
    		System.out.print(s);
    	}
    	System.out.println();
    }

    static class FastScanner {
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;
        private boolean hasNextByte() {
            if(ptr < buflen) {
                return true;
            } else {
                ptr = 0;
                try {
                    buflen = in.read(buffer);
                } catch(IOException e) {
                    e.printStackTrace();
                }
                if(buflen <= 0) {
                    return false;
                }
            }
            return true;
        }
        private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
        private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
        private void skipUnprintable() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
        public boolean hasNext() { skipUnprintable(); return hasNextByte();}
        public String next() {
            if (!hasNext()) throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while(isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }
        public long nextLong() {
            return Long.parseLong(next());
        }
        public int nextInt(){
            return Integer.parseInt(next());
        }
        public double nextDouble(){
            return Double.parseDouble(next());
        }
    }

    static void shuffleArray(long[] arr){
        int n = arr.length;
        Random rnd = new Random();
        for(int i=0; i<n; ++i){
            long tmp = arr[i];
            int randomPos = i + rnd.nextInt(n-i);
            arr[i] = arr[randomPos];
            arr[randomPos] = tmp;
        }
    }
}


Measured memory_bytes: 21204
#include <iostream>
#include <algorithm>
#include <math.h>
using namespace std;


int main(){
	int n, a[100000],point[100002],sum,ans;
	cin >> n;

	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}

	point[0] = 0;
	point[n + 1] = 0;
	sum = 0;

	for (int i = 0; i < n; i++) {
		sum += abs(a[i] - point[i]);
		point[i+1] = a[i];
	}
	sum += abs(point[n] - 0);

	for (int i = 1; i <= n; i++) {
		ans = sum - abs(point[i - 1] - point[i]) - abs(point[i] - point[i + 1]);
		ans += abs(point[i + 1] - point[i - 1]);
		cout << ans << endl;
	}
	return 0;
}


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

int main(){
    int n;
    cin >> n;
    int t = n/111;
    if( n%111 != 0 ) t++;
    cout << t*111 << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

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

    int[][][] house = new int[4][3][10];
    for (int i = 0; i < 4; i++) {
      for (int j = 0; j < 3; j++) {
        for (int k = 0; k < 10; k++) {
          house[i][j][k] = 0;
        }
      }
    }
    int n = in.nextInt();
    for (int i = 0; i < n; i++) {
      int b = in.nextInt();
      int f = in.nextInt();
      int r = in.nextInt();
      int v = in.nextInt();
      house[b - 1][f - 1][r - 1] += v;
    }
    for (int i = 0; i < 4; i++) {
      for (int j = 0; j < 3; j++) {
        for (int k = 0; k < 10; k++) {
          System.out.print(" " + house[i][j][k]);
        }
        System.out.println();
      }
      if (i != 3) {
        System.out.println("####################");
      }
    }
  }
}

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

    int x = Math.min(p+q,q+r);
    int y = Math.min(x,r+p);
    System.out.println(y);

  }
}


Measured memory_bytes: 23124
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,m;
    cin>>n>>m;
    if(n==m)
    cout<<"Yes\n";
    else 
    cout<<"No\n";
	// your code goes here
	return 0;
}


Measured memory_bytes: 3652
#include<iostream>
#include<bits/stdc++.h>
#include<math.h>
#include<stdlib.h>
#include<stdio.h>
#include<string.h>

#include<sstream>
using namespace std;

bool IsPrime(long long int number)
{
	long long int i;
	for (i=2; i*i<=number; i++)
	{
		if (number % i == 0)
		{
			return false;
		}
	}

	return true;
}

int main()
{
    long long int n,num,i;cin>>n;num=n;
    printf("%lld:",n);
    if(IsPrime(n))
    { printf(" %lld\n",n); return 0; }

    for(i=2;num!=1,i<=n;i++)
    {
      if(num%i==0)
      {
          while(n%i==0)
        { printf(" %d",i);n/=i; }
      }
    }
    cout<<endl;

return 0;
}

Measured memory_bytes: 3204
import java.util.Scanner;


public class Main{
	
	public static void main(String[] args){

		Scanner sc = new Scanner(System.in);
		System.out.println(reverse(sc.next()));
		sc.close();
	}
	
	static String reverse(String str) {
		char[] temp = str.toCharArray();
		char[] result = new char[temp.length];
		for(int i = 0; i < temp.length; i++) result[i] = temp[temp.length - 1 - i];
		return new String(result);
	}
}

Measured memory_bytes: 17124
#include <bits/stdc++.h>
using namespace std;
#define ld double
#define ll long long
#define pb emplace_back
#define mk make_pair
#define mod 1000000007
#define ff first
#define ss second
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define all(x) x.begin(),x.end()
ll power(ll a, ll b) {ll res = 1; a = a % mod; while (b) {if (b & 1)res = (res * a) % mod; a = (a * a) % mod; b /= 2;} return res;}
ll invmod(ll a) {return power(a, mod - 2);}
int main(void)
{
	FIO
	int n, y;
	cin >> n;
	int arr[n], x = 0;
	for (int i = 0; i < n; i++) {
		cin >> arr[i];
		x ^= arr[i];
	}
	for (int i = 0; i < n; i++) {
		y = arr[i] ^ x;
		cout << y << " ";
	}
	cout << "\n";
	return 0;
}

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

#define int long long
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define pb push_back
#define fi first
#define se second
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;}

typedef tuple<int,int,int,int>latte;

int N,M,X;
int T[10000];

const int INF=1001001001001001001ll;
int dist[10000][201][2];

vpint G[10000];

signed main(){
    scanf("%lld%lld%lld",&N,&M,&X);
    rep(i,N){
        scanf("%lld",&T[i]);
        if(T[i]==1)T[i]=2;
        else if(T[i]==2)T[i]=1;
    }
    rep(i,M){
        int a,b,c;
        scanf("%lld%lld%lld",&a,&b,&c);
        a--;b--;
        G[a].pb({b,c});
        G[b].pb({a,c});
    }

    fill_n(**dist,10000*201*2,INF);
    priority_queue<latte,vector<latte>,greater<latte>>que;
    que.push(make_tuple(0,0,0,0));
    dist[0][0][0]=0;
    while(que.size()){
        int d,v,x,t;
        tie(d,v,x,t)=que.top();
        que.pop();
        if(dist[v][x][t]<d)continue;

        if(v==N-1){
            cout<<d<<endl;
            return 0;
        }

        for(auto &e:G[v]){
            if(T[e.fi]==2){
                int nx=min(X,x+e.se);
                if(dist[e.fi][nx][t]<=d+e.se)continue;
                dist[e.fi][nx][t]=d+e.se;
                que.push(make_tuple(dist[e.fi][nx][t],e.fi,nx,t));
            }
            else{
                if(T[e.fi]!=t&&x+e.se<X)continue;
                if(dist[e.fi][0][T[e.fi]]<=d+e.se)continue;
                dist[e.fi][0][T[e.fi]]=d+e.se;
                que.push(make_tuple(dist[e.fi][0][T[e.fi]],e.fi,0,T[e.fi]));
            }
        }
    }

    return 0;
}

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

#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, n, m) for (int i = n; i < m; i++)
#define ll long long int

using namespace std;

int main()
{
  int x,y;
  cin >> x >> y;
  cout << x + y/2 << endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    long long A,B;
    cin >> A >> B;
    
    long long sub=B-A;
    long long ans;
    
    if(A%2==0){
    
        if(sub==0)ans=B;
        else if(sub%4==1)ans=1;
        else if(sub%4==2)ans=B^1;
        else if(sub%4==3)ans=0;
        else ans=B^0;
    
    }else{
        
        if(sub==0)ans=B^A;
        else if((sub-1)%4==1)ans=1^A;
        else if((sub-1)%4==2)ans=B^1^A;
        else if((sub-1)%4==3)ans=0^A;
        else ans=B^0^A;
    
        
        
    }
    
    
   cout << ans << endl; 
   
   return 0;
}

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

int main() {
  std::string S,T;
  std::cin >> S >> T;
  
  int i;
  bool f = true;
  
  for (i=0; i<S.length(); i++) {
    if (S[i] != T[i]) {
      f = false;
    }
  }
  
  if (f) {
    std::cout << "Yes" << std::endl;
  } else {
    std::cout << "No" << std::endl;
  }
  
  return 0;
}

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

int main() {
  int64_t n,m;
  cin>>n>>m;
  int64_t time=(1900*m+100*(n-m));
  int64_t ans=0;
  ans+=(time*pow((int64_t)(2),m));
  cout<<ans;
}

Measured memory_bytes: 256
n, m = gets.split.map(&:to_i)
a = gets.split.map(&:to_i)

x = []
a.each do |i|
  i.to_s(2).chars.reverse.each_with_index do |j, k|
    if j == '1'
      x[k] ||= 0
      x[k] += 1
    else
      x[k] ||= 0
    end
  end
end

sum = 0
(0...(m.to_s(2).length)).reverse_each do |i|
  sum += 2**i if (x[i] == nil || x[i] <= n/2.0) && sum + 2**i <= m
end

puts a.map{|i| i ^ sum}.inject(:+)

Measured memory_bytes: 12816
#include<stdio.h>
int main()
{
int A1, A2, A3, chan;
scanf("%d %d %d", &A1, &A2, &A3);

if (A1 > A2 && A1 > A3)
  {
    chan = A1;
    A1 = A2;
    A2 = chan;

    if(A2 > A3)
    {
      chan = A2;
      A2 = A3;
      A3 = chan;
    }
    if(A1 > A2)
    {
      chan = A1;
      A1 = A2;
      A2 = chan;
    }
  }
  
else if (A2 == A3)
{
  if (A1 > A2)
  {
    chan = A1;
    A1 = A3;
    A3 = chan;
  }
}


  
  else
  {
    if(A2 > A3)
    {
      chan = A2;
      A2 = A3;
      A3 = chan;
    }
    if(A1 > A2)
    {
      chan = A1;
      A1 = A2;
      A2 = chan;
    }
  }
  
  
printf("%d", A3-A1);

return 0;
}


Measured memory_bytes: 128
INPUT = list(input().split())
stack = []

for x in INPUT:
    if x.isdigit():
        stack.append(x)
    else:
        second_item = stack.pop()
        first_item = stack.pop()
        tmp = eval(first_item + x + second_item)
        stack.append(str(tmp))

print(int(stack.pop()))


Measured memory_bytes: 5596
// Copyright (C) 2017 __debug.

// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as
// published by the Free Software Foundation; version 3

// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with this program; If not, see <http://www.gnu.org/licenses/>.


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

#define x first
#define y second
#define MP std::make_pair
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(), (x).end()
#define DEBUG(...) fprintf(stderr, __VA_ARGS__)
#ifdef __linux__
#define getchar getchar_unlocked
#define putchar putchar_unlocked
#endif

using std::pair;
using std::vector;
using std::string;

typedef long long LL;
typedef pair<int, int> Pii;

const int oo = 0x3f3f3f3f;

template<typename T> inline bool chkmax(T &a, T b) { return a < b ? a = b, true : false; }
template<typename T> inline bool chkmin(T &a, T b) { return b < a ? a = b, true : false; }
string procStatus()
{
    std::ifstream t("/proc/self/status");
    return string(std::istreambuf_iterator<char>(t), std::istreambuf_iterator<char>());
}
template<typename T> T read(T &x)
{
    int f = 1;
    char ch = getchar();
    for (; !isdigit(ch); ch = getchar())
        f = (ch == '-' ? -1 : 1);
    for (x = 0; isdigit(ch); ch = getchar())
        x = 10 * x + ch - '0';
    return x *= f;
}
template<typename T> void write(T x)
{
    if (x == 0) {
        putchar('0');
        return;
    }
    if (x < 0) {
        putchar('-');
        x = -x;
    }
    static char s[20];
    int top = 0;
    for (; x; x /= 10)
        s[++top] = x % 10 + '0';
    while (top)
        putchar(s[top--]);
}
// EOT

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

LL N;

void input()
{
    read(N);
}

#define GE(x, g) (((x) > t) || (((x) == t) && (g)))

void solve()
{
    static int dp[MAXN][2][2][2];

    int n = log2(N) + 1;

    dp[0][0][0][0] = 1;
    for (int i = 0; i < n; ++i) {
        int t = N >> i & 1;
        for (int j = 0; j < 2; ++j) {
            for (int ug = 0; ug < 2; ++ug) {
                for (int vg = 0; vg < 2; ++vg) {
                    if (!dp[i][j][ug][vg])
                        continue;
                    // u = 0, v = j
                    (dp[i + 1][0][GE(0, ug)][GE(j, vg)] += dp[i][j][ug][vg]) %= MOD;
                    (dp[i + 1][1][GE(0, ug)][GE(j, vg)] += dp[i][j][ug][vg]) %= MOD;
                    // u = 1, v = j^1
                    (dp[i + 1][j][GE(1, ug)][GE(j^1, vg)] += dp[i][j][ug][vg]) %= MOD;
                }
            }
        }
    }

    int ans = dp[n][0][0][0];
    printf("%d\n", ans);
}

int main()
{
#ifdef __DEBUG
    freopen("D.in", "r", stdin);
    freopen("D.out", "w", stdout);
#endif

    input();
    solve();

    return 0;
}

// 唯有门前镜湖水，春风不改旧时波。
//     -- 贺知章《回乡偶书二首》


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def resolve():
    n,m=map(int,input().split())
    E=[[] for _ in range(n)]
    for _ in range(m):
        a,b=map(lambda x:int(x)-1,input().split())
        E[a].append(b)
        E[b].append(a)
    def dfs(v,vis):
        vis[v]=1
        if all(vis): return 1
        res=0
        for u in E[v]:
            if vis[u]==0:
                nvis=vis[:]
                res+=dfs(u,nvis)
        return res
    print(dfs(0,[0]*n))
resolve()

Measured memory_bytes: 43612
#include <stdio.h>

char symbols[][5] = {"==", "<", ">"};

int cmp(const int a, const int b)
{
    if(a == b)
        return 0;
    else if(a < b)
        return 1;
    else
        return 2;
}

int main(void)
{
    int bef, aft;
    int idx;

    scanf("%d %d", &bef, &aft);
    idx = cmp(bef, aft);

    printf("a %s b\n", symbols[idx]);

    return 0;
}

Measured memory_bytes: 592
fun main(args: Array<String>) {
    val (a,b) = readLine()!!.split(" ").mapIndexed{ s ,i-> s.toLong()+i.toLong()-1 }.map{num->Array(62){2.toLong() shl it}.map{i-> ((num-num%i)/2 + Math.max(num%i+1-i/2,0))%2 } }
    println((0 until 62).map { if(a[it] != b[it]){ 1.toLong() shl it}else 0 }.sum())
}

Measured memory_bytes: 38184
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define Rep(i,s,n) for(int i=s;i<n;i++)
typedef long long int ll;
typedef pair<int, int> P;
typedef long double ld;
void ans(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}

const ll INF=1001001001;

int main(){
  int N;cin>>N;
  ll n=0;
  int a,b,c;
  
  vector<vector<int>> v(9,vector<int>(9,0));
  Rep(i,1,N+1){
    a=i%10;
    b=i;
    c=b;
    while(b){
      c=b;
      b=b/10;
    }
    if(a!=0 && c !=0){
    v.at(a-1).at(c-1)++;
    }
  }
  
  
  Rep(i,1,N+1){
    a=i%10;
    b=i;
    c=b;
    while(b){
      c=b;
      b=b/10;
    }
    if(a!=0 && c !=0){
    n+=v.at(c-1).at(a-1);
    }
  }
  
  cout<<n<<endl;
  
}

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

int a[200010];


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

    for (int i = 1; i <= n; i++) {
        cin >> a[i];
        a[i] -= i;
    }

    int val, until = n + 1;

    long long nrop = 0;

    for (int i = n; i >= 1; i--) {
        if ((until <= i && val == a[i]) || (until > i && a[i] == -i))
            continue;
        if (a[i] >= 0 || -a[i] >= until)
            return cout << -1, 0;
        nrop += i + a[i];
        val = a[i];
        until = -a[i];
    }

    cout << nrop << '\n';

    return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>
int main(void){
	int a,b,c,sum=0;
	scanf("%d%d",&a,&b);
	for(c=0;c<2;c++){
		if(a>b){
			sum+=a;
			a--;
		}else{
			sum+=b;
			b--;
		}
	}
	printf("%d",sum);
return 0;
}

Measured memory_bytes: 128
//
// Created by admin on 2020/7/11.
//
#include <bits/stdc++.h>
using namespace std;
int l,r,d,ans,a1,a2,i;
int main()
{
    cin>>l>>r>>d;
    for(i=1;i<=1000;i++)
        if(i*d>=l)
            break;
    a1=i;
    for(;i<=1000;i++)
        if(i*d>=r)
            break;
    a2=i-1;
    if(i*d==r)
        a2++;
    ans=a2-a1+1;
    cout<<ans<<endl;
    return 0;
}


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

std::string str,a,b,aa,bb;

int n;

bool step[100100];
bool memo[100100];

bool pd(int on)
{
	bool &ans=memo[on];
	if(on>=n)
		return true;
	if(step[on])
		return ans;
	step[on]=true;
	ans=false;
	std::string s;
	for(int i=0;i+on<n && i<5;i++)
		s+=str[i+on];
	//std::cout << "on " << on << ',';
	//std::cout << s << '\n';
	if(s==aa)
	{
		ans=ans||pd(on+5);
		if(on+6<n)
		{
			s+=str[on+5];
			s+=str[on+6];
			if(s==a)
				ans=ans||pd(on+7);
		}
	}
	else if(s==b)
	{
		ans=ans||pd(on+5);
		if(on+5<n)
		{
			s+=str[on+5];
			if(s==bb)
				ans=ans||pd(on+6);
		}
	}
	return ans;

}

int main()
{
	std::cin >> str;
	a="dreamer";
	aa="dream";
	b="erase";
	bb="eraser";
	n=str.size();
	if(pd(0))
		std::cout << "YES\n";
	else
		std::cout << "NO\n";
}

Measured memory_bytes: 3200
/*
"Won't stop untill I'm Phenomenal"
- Phenomenal, EMINEM
*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define ff first
#define Shazam ios_base::sync_with_stdio(false);   cin.tie(NULL); cout.tie(NULL);
#define ss second
#define all(c) c.begin(),c.end()
#define endl "\n"
#define test() int t; cin>>t; while(t--)
#define fl(i,a,b) for(int i = a ; i <b ;i++)
#define get(a) fl(i,0,a.size())  cin>>a[i];
#define pr(a) fl(i,0,a.size()) cout<<a[i]<<" ";	cout<<endl;
#define pra(a,n) fl(i,0,n) cout<<a[i]<<" ";	cout<<endl;
const ll INF = 2e18;
const int inf = 2e9;
const int mod1 = (int)1e9 + 7;
vector<ll> fac, ifac;
ll binmodulo(ll x, ll y){
    ll res = 1;
    x%=mod1;
    if(!x) return 1;
    while(y){
        if(y&1){
            res = res*x%mod1;
        }
        x = x*x%mod1;
        y>>=1;
    }
    return  res;
}

void precompute(int n){
    fac.resize(n+1,1);
    ifac.resize(n+1);
    for(ll i = 2; i <=n; i++){
        fac[i] = fac[i-1]*i%mod1;
    }
    ifac[n] = binmodulo(fac[n],mod1-2);
    for(ll i = n-1; i>=0; i--){
        ifac[i] = ifac[i+1]*(i+1)%mod1;
    }
}
ll npr(ll n, ll r){
    return fac[n]*ifac[n-r]%mod1;
}
ll ncr(ll n, ll r){
    return fac[n]*ifac[n-r]%mod1*ifac[r]%mod1;
}
int main(){
    Shazam;
    int n,m; cin>>n>>m;
    precompute(m);
    ll ans = 0;
    for(int i = 0; i<= n; i++){
        if(i&1){
            ans = (ans + mod1 - ncr(n,i)*npr(m,i)%mod1*npr(m-i, n-i)%mod1*npr(m-i,n-i)%mod1)%mod1;
        }
        else{
            ans = (ans + ncr(n,i)*npr(m,i)%mod1*npr(m-i, n-i)%mod1*npr(m-i,n-i)%mod1)%mod1;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 11060
#include<stdio.h>
#include<algorithm>
#include<string.h>
#include<set>
#include<queue>
#include<string>
#include<sstream>
#include<iostream>
#include<sstream>
#include<stack>
#include<map>
#include<vector>
#include<math.h>
using namespace std;
int a[110000];
struct Node
{
	int z;
	int y;
}b[110000];
bool cmp(Node a, Node b)
{
	return a.y < b.y;
}
int main()
{
	memset(a, 0, sizeof(a));
	int n,m,i,j;
	scanf("%d %d", &n, &m);
	for (i = 0; i < m; i++)
	{
		scanf("%d %d", &b[i].z, &b[i].y);
	}
	sort(b, b + m, cmp);
	int now = 0,ans=0;
	for (i = 0; i < m; i++)
	{
		if (b[i].z < now&&b[i].y >= now);
		else
		{
			ans++;
			now = b[i].y;
		}
	}
	printf("%d", ans);
}

Measured memory_bytes: 1408
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int a = in.nextInt();
		int b = in.nextInt();
		if(a>=1 && a<=9 && b>=1 && b<=9) {
			System.out.print(a*b);
		}
		else {
			System.out.print(-1);
		}
	}
}


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

int main()
{
	auto& in = cin;

	long long N;
	in >> N;
	map<long long, long long> nums;
	long long total = 0;
	for (long long i = 0; i < N; ++i) {
		long long a;
		in >> a;
		++nums[a];
		total += a;
	}
	long long Q;
	in >> Q;
	for (long long i = 0; i < Q; ++i) {
		long long b, c;
		in >> b >> c;
		long long numB = nums[b];
		long long numC = nums[c];
		long long diff = numB * (c - b);
		total += diff;
		cout << total << "\n";
		nums[b] = 0;
		nums[c] = numB + numC;
	}

	return 0;
}


Measured memory_bytes: 9292
n = int(input())
a = list(map(int, input().split()))
a.sort()

cs_a = [0] * n
cs_a[0] = a[0]
for i in range(n-1):
    cs_a[i+1] = cs_a[i] + a[i+1]

ans = 0
for i in range(n-1):
    if a[i+1] <= cs_a[i] * 2:
        ans += 1
    else:
        ans = 0

print(ans+1)


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

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

  if(abs(a-b) % 2 == 0) cout << abs(a - b) / 2 << endl;
  else {
    cout << min(a - 1, n - b) + 1 + (b - a - 1) / 2 << endl;
  }
}

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

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

  int front = s / 100;
  int back = s % 100;


  if(front == 0 || front > 12) {
    if(back == 0 || back > 12) {
      cout << "NA" << endl;
    }else {
      cout << "YYMM" << endl;
    }
  }else{
    if(back == 0 || back > 12) {
      cout << "MMYY" << endl;
    }else {
      cout << "AMBIGUOUS" << endl;
    }
  }







}

Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); ++i)

const int INF = 1 << 29;

using namespace std;

int main() {
    int n, x, y;
    cin >> n >> x >> y;
    x--; y--;

    vector<int> ans(n);
    rep(sv, n) {
        vector<int> dist(n, INF);
        queue<int> q;

        auto push = [&](int v, int d) {
            if (dist[v] != INF) return;
            dist[v] = d;
            q.push(v);
        };

        push(sv, 0);

        while (!q.empty()) {
            int v = q.front();
            q.pop();
            int d = dist[v];

            if (v - 1 >= 0) push(v - 1, d + 1);
            if (v + 1 < n) push(v + 1, d + 1);
            if (v == x) push(y, d + 1);
            if (v == y) push(x, d + 1);
        }
        rep(i, n) ans[dist[i]]++;
    }
    rep(i, n) ans[i] /= 2;
    for (int i = 1; i < n; ++i) cout << ans[i] << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(long long int i = 0; i < n; i++)
#define _rep(i,m,n) for(long long int i = m; i < n; i++)
#define print(n) std::cout << n << std::endl
#define _print(n) std::cout << n
using namespace std;
typedef long long ll;
const int N = 1000000;
const ll mod = 1000000007;

int main() {
    string s; cin >> s;
    vector<int> a(4);
    rep(i,4) a[i] = int(s[i] - '0');

    for(int bit = 0; bit < (1 << 3); bit++){
        int sum = 0;

        for (int i = 0; i < 3; ++i) {
            if (bit & (1 << i)) {
                sum += a[i + 1];
            } else {
                sum -= a[i + 1];
            }
        }
        if(sum + a[0] == 7){
            _print(a[0]);
            for (int i = 0; i < 3; ++i){
                if(bit & (1 << i)){
                    _print('+');
                }else{
                    _print('-');
                }
                _print(a[i + 1]);
            }
            print("=7");
            break;
        }
    }
}

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

int main(void){
	int Prime[1000000];
	int i,j;
	int Flag = 0;
	
	Prime[0] = 0;
	Prime[1] = 0;
	for(i = 2;i < 1000000;i++){
		for(j = 2;j <= sqrt(i);j++){
			if(i % j == 0){
				Flag = 1;
				break;
			}
		}
		
		if(Flag == 1){
			Prime[i] = Prime[i-1];
		}else{
			Prime[i] = Prime[i-1] + 1;
		}
		Flag = 0;
	}
	
	while(scanf("%d",&i) != EOF){
		printf("%d\n",Prime[i]);
	}
return 0;
}

Measured memory_bytes: 4500
from numpy import *
f=bitwise_xor.reduce
N=int(input())
A=array(input().split(),int64)
X=f(A)
A=hstack((A,array([1<<i for i in range(60)if X&(1<<i)],int64)))
for k in range(60)[::-1]:
  b=1<<k
  j=A&b!=0
  i=where(j&(A<2*b))[0]
  if len(i):i=i[0];x=A[i];A[j]^=x;A[i]=x
r=f(A)
print(r+(r^X))

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

#include<cstdio>
#define r(i,n) for(int i=0;i<n;i++)

int main(void){
  int n;
  cin>>n;
  vector<int> a(n);
  r(i,n)cin>>a.at(i);

  sort(a.begin(),a.end());
  cout<<a.at(n-1)-a.at(0)<<endl;



return 0;}


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

using namespace std;

int main() {
	int takenum;
	
	//vector <pair<int, pair<string, int>>> v0;
	cin >> takenum;
	
    vector<pair<pair<string, int>,int>> v;
	v.resize(takenum);
	for (int i = 0; i < takenum; i++) {
		v[i].second = i+1;
		cin >> v[i].first.first >> v[i].first.second;
		v[i].first.second *= -1;
	}
	sort(v.begin(), v.end());

	for (int j = 0; j < takenum; j++) {
		v[j].first.second *= -1;
		//cout << v[j].first.first << " " << v[j].first.second <<" "<< 
		cout<<v[j].second<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define F first
#define S second
#define mp make_pair
#define pb push_back
//#define ll __int128
#define ll long long
//#define int long long
//#define int __int128
#define LEFT(a) ((a)<<1)
#define RIGHT(a) (LEFT(a) + 1)
#define MID(a,b) ((a+b)>>1)
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define y1 y122

/*
#pragma GCC optimize ("O3")
#pragma GCC optimize("Ofast")

#pragma GCC target("avx2,fma")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC target ("avx2")
#pragma GCC optimization ("unroll-loops")

#pragma comment(linker, "/STACK: 20000000005")
*/

using namespace std;

const int N = 200005;


void solve () {
}

main()
{
    //freopen ("in.in", "r", stdin);freopen ("out.out", "w", stdout);
    ios_base::sync_with_stdio(0);
    int n;
    cin >> n;
    int m = __gcd (n, 360);
    cout << 360 / m << endl;
}


Measured memory_bytes: 3648
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
                                                                                                
  
int main(){
                                                                                                
   
    long long n, i;

         
    cin >> n;

    vector<long long> l( n + 1 );

    l.at(0) = 2;

    l.at(1) = 1;


    for( i = 2 ; i <= n ; i = i + 1 ){

         l.at(i) = l.at( i - 1 ) + l.at( i - 2 );

         }


    cout << l.at( n ) << endl;


    return 0;
                                                          
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define N 100010
#define ll long long
int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    int ans = 0;
    if(a % b){
        ans = ((a / b) + 1) * c;
    }
    else{
        ans = (a / b) * c;
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 3620
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    if len(x) == 0:
        return []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False

def pow_k(x, n):
    ans = 1
    while n:
        if n % 2:
            ans *= x
        x *= x
        n >>= 1
    return ans

"""
def nibu(x,n,r):
    ll = 0
    rr = r
    while True:
        mid = (ll+rr)//2

    if rr == mid:
        return ll
    if (ここに評価入れる):
        rr = mid
    else:
        ll = mid+1
"""

h,w = m()

data = [input()[:-1] for i in range(h)]

print("#" * (w+2))

for i in range(h):
    print("#" + data[i] + "#")

print("#" * (w+2))



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


int main(){
    int ABC[3];
    int ACdiff,BCdiff;
    int ans = 0;
    cin >> ABC[0] >> ABC[1] >> ABC[2];
    sort(ABC,ABC+3);

    ACdiff = ABC[2] - ABC[0];
    BCdiff = ABC[2] - ABC[1];

    if(ACdiff%2){
        if(BCdiff%2){
            //両方奇数
            ans++;
            ACdiff--;
            BCdiff--;
            ans += ACdiff/2;
            ans += BCdiff/2;
        }
        else{
            //ACの差が奇数、BCの差は偶数
            ans++;
            ans += (ACdiff+1)/2;
            ans += BCdiff/2;
        }
    }
    else{
        if(BCdiff%2){
            //ACの差は偶数、BCの差が奇数
            ans++;
            ans += ACdiff/2;
            ans += (BCdiff+1)/2;
        }
        else{
            //両方偶数
            ans += ACdiff/2;
            ans += BCdiff/2;
        }
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
# region header
import sys
import math
from bisect import bisect_left, bisect_right, insort_left, insort_right
from collections import defaultdict, deque, Counter
from copy import deepcopy
from fractions import gcd
from functools import lru_cache, reduce
from heapq import heappop, heappush
from itertools import accumulate, groupby, product, permutations, combinations, combinations_with_replacement
from math import ceil, floor, factorial, log, sqrt, sin, cos
from operator import itemgetter
from string import ascii_lowercase, ascii_uppercase, digits
sys.setrecursionlimit(10**7)
rs = lambda: sys.stdin.readline().rstrip()
ri = lambda: int(rs())
rf = lambda: float(rs())
rs_ = lambda: [_ for _ in rs().split()]
ri_ = lambda: [int(_) for _ in rs().split()]
rf_ = lambda: [float(_) for _ in rs().split()]
INF = float('inf')
MOD = 10 ** 9 + 7
PI = math.pi
# endregion
D, N = ri_()
print(N * (100 ** D) if N != 100 else 101 * (100 ** D))

Measured memory_bytes: 64108
#include <bits/stdc++.h>
using namespace std;
constexpr long long MOD = 1000000007;
using ll = long long;
int main() {
string s;
ll k;
cin >> s >> k;
for (ll i = 0; i < k;i++){
    if(s[i]!='1'){
        cout << s[i] << endl;
        return 0;
    }
}
cout << "1" << endl;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda:sys.stdin.readline().rstrip()
from collections import defaultdict
def resolve():
    n,a=map(int,input().split())
    X=list(map(lambda x:int(x)-a,input().split()))
    dp=defaultdict(int)
    dp[0]=1
    for x in X:
        ndp=defaultdict(int)
        for key,val in dp.items():
            ndp[key]+=val
            ndp[key+x]+=val
        dp=ndp

    print(dp[0]-1)
resolve()

Measured memory_bytes: 41584
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
const int INF = 1000000; // 十分大きな値
int n,m,a[60],b[60],c[60],d[60];
int func(int id){
	int best = INT_MAX;
	int ans = -1;
	REP(j,m){
		int dist = abs(a[id] -c[j]) + abs(b[id] -d[j]);
		if(dist < best){
			best = dist;
			ans = j;
		}
	}
	return ans + 1;
}
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> n >> m;
	REP(i,n)cin >> a[i] >> b[i];
	REP(j,m)cin >> c[j] >> d[j];
	REP(i,n)cout << func(i) << endl;
	return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>

using namespace std;

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

signed  main(){
  // abc091
  int a,b,c;
  cin >>a>>b>>c;
  if(a+b>=c){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <array>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include <cstdint>
#include <unordered_set>
#include <ctime>
#include <numeric>
#include <cstdint>

using llint = long long int;

template<typename T>
void dump(const T& arr){
  std::cout << "[";
  for(const auto& elem: arr){
    std::cout << elem << ", ";
  }
  std::cout << "]" << std::endl;
}

void solve(void){
  int cnt = 0;
  int n;
  std::cin >> n;

  int max_cnt = 0;
  for(int i=0; i<n; i++){
    int d1, d2;
    std::cin >> d1 >> d2;
    if(d1 == d2) cnt++;
    else         cnt = 0;
    max_cnt = std::max(max_cnt, cnt);
  }
  if(max_cnt >=3) std::cout << "Yes" << std::endl;
  else            std::cout << "No"  << std::endl;
  return;

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





Measured memory_bytes: 3620
import std.stdio;
import std.string;
import std.conv;
import std.typecons;
import std.algorithm;
import std.functional;
import std.bigint;
import std.numeric;
import std.array;
import std.math;
import std.range;
import std.container;
import std.ascii;
void times(alias fun)(int n) {
    foreach(i; 0..n) fun();
}
auto rep(alias fun, T = typeof(fun()))(int n) {
    T[] res = new T[n];
    foreach(ref e; res) e = fun();
    return res;
}
// fold was added in D 2.071.0.
template fold(fun...) if (fun.length >= 1) {
    auto fold(R, S...)(R r, S seed) {
        static if (S.length < 2) {
            return reduce!fun(seed, r);
        } else {
            return reduce!fun(tuple(seed), r);
        }
    }
}

long INF = long.max/3;
void main() {
    int N, Q;
    readf("%d %d\n", &N, &Q);

    auto tree = redBlackTree!((a, b) => a.w < b.w, true, Edge)([]);
    Edge[] es = N.iota.map!(i => Edge(i, (i+1)%N, INF)).array;
    Q.times!({
        int a, b, c;
        readf("%d %d %d\n", &a, &b, &c);
        tree.insert(Edge(a, b, c));
        es[a].w = min(es[a].w, c+1);
        es[b].w = min(es[b].w, c+2);
    });
    foreach(i; 0..N*2) {
        es[(i+1)%N].w = min(es[(i+1)%N].w, es[i%N].w + 2);
    }
    tree.insert(es);

    long ans = 0;
    auto set = DisjointSet(N);
    tree[].each!((e){
        if (!set.same(e.s, e.g)) {
            set.unite(e.s, e.g);
            ans += e.w;
        }
    });
    ans.writeln;
}

struct Edge {
    int s, g;
    long w;
}

// 互いに素な集合
// UnionFindTreeによる実装
struct DisjointSet {

private:
    Vertex[] _vertices;

public:
    this(size_t size) {
        _vertices = new Vertex[size];
        foreach(i, ref v; _vertices) {
            v.index = i;
            v.parent = i;
        }
    }

    void makeSet(size_t[] indices...) {
        foreach(index; indices) {
            _vertices[index] = Vertex(index, index);
        }
    }

    void unite(size_t x, size_t y) {
        link(findSet(x), findSet(y));
    }

    void link(size_t x, size_t y) {
        if (x==y) return;
        if (_vertices[x].rank > _vertices[y].rank) {
            _vertices[y].parent = x;
        } else {
            _vertices[x].parent = y;
            if (_vertices[x].rank == _vertices[y].rank) {
                _vertices[y].rank++;
            }
        }
    }

    bool same(size_t x, size_t y) {
        return findSet(x) == findSet(y);
    }

    size_t findSet(size_t index) {
        if (_vertices[index].parent == index) {
            return index;
        } else {
            return _vertices[index].parent = findSet(_vertices[index].parent);
        }
    }

private:
    struct Vertex {
        size_t index;
        size_t parent;
        size_t rank = 1;
    }
}


Measured memory_bytes: 34044
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll mod=1000000007;
const int MAX_N = 1000;         // n の最大値
 
// nCk を取得
double nCk(int n, int k) {
double res=1.0;
for(int i=0; i<n; i++){
res*=0.5;}
for(int i=0; i<k; i++){
res*=(double)(n-i);
res/=(double)(k-i);
}
return res;}
 
int main() {
ll n;
cin>>n;
for(ll i=1; i<=3500; i++){
for(ll k=1; k<=3500; k++){
if((4*i*k-n*k-n*i)>0&&(n*k*i)%(4*i*k-n*k-n*i)==0){
if(n*k*i<=3500*(4*i*k-n*k-n*i)){
cout << i << " " << k << " " << (n*k*i)/(4*i*k-n*k-n*i);
goto asd;
}
}}}
asd: 
cout << endl;
return 0;}



Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, cnt=0;
  cin >> N;
  int a[N];
  for(int i=0; i<N; i++) {
    cin >> a[i];
  }
  for(int h=0; h<30; h++) {
    for(int i=0; i<N; i++) {
      if(a[i]%2==0) {
        a[i]/=2;
        cnt++;
      }
      else {
      }
    }
  }
  cout << cnt << endl;
}
  

Measured memory_bytes: 256
import math
import sys
input=sys.stdin.readline
from collections import deque
from heapq import heappush,heappop
import re

def int_raw():
    return int(input())
 
def ss_raw():
    return input().split()
 
def ints_raw():
    return tuple(map(int, ss_raw()))


def mod_inv(a, b):
    r = a
    w = b
    u = 1
    v = 0
    while w != 0:
        t = r//w
        r -= t*w
        r, w = w, r
        u -= t*v
        u, v = v, u
    return (u % b+b) % b


DIV = 10**9+7

def ncr(n, r, mod=DIV):
	r = min(r, n-r)
	ret = 1
	for i in range(1, r+1):
		ret = ret * (n-i+1) % mod
		ret = ret * mod_inv(i, mod) % mod
	return ret
    
def mod_modify(a,mod):
    return (a+mod)%mod

def cal_ABC(A,B,C):
    AC = A//C + (1 if A%C>0 else 0)
    BC = (B//C)
    return max(BC-AC+1,0)


def gcd(a, b):
    if(b == 0):
        return a
    return gcd(b, a % b)

def main():
    ans =0
    A,B,C,D = ints_raw()
    total = B-A+1
    dC = cal_ABC(A,B,C)
    dD = cal_ABC(A,B,D)
    dCD = cal_ABC(A,B,C*D//gcd(max(C,D),min(C,D)))
    return total-dC-dD+dCD

print(main())


Measured memory_bytes: 38452
import sys
from collections import Counter, deque, defaultdict
from math import factorial
import heapq, bisect
import math
import itertools
sys.setrecursionlimit(10 ** 5 + 10)
INF = 10**15 +5
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))

n = INT()
s = input()
res = 1
for i in range(n-1):
    if s[i] != s[i+1]:
        res += 1

print(res)

Measured memory_bytes: 39536
N = int(input())
L = []
for _ in range(N):
    l = list(map(int,input().split()))
    L.append(l)
dp = [[0 for _ in range(3)] for _ in range(N+1)]
#dp[その日数][最後が'a' or 'b' or 'c'] := 右を満たす最大値
for day in range(N):
    for i in range(3):
        for new in range(3):
            if i != new:
                dp[day+1][new] = max(dp[day][i]+L[day][new] ,dp[day+1][new])
ans = 0
for i in range(3):
    ans = max(ans,dp[N][i])
print(ans)


Measured memory_bytes: 75480
#include <iostream>

using namespace std;

#define MAX_N 1000

// 入力
int N;
int T[MAX_N], A[MAX_N];

int main(void) {
    cin >> N;
    for (int i = 0; i < N; ++i) {
        cin >> T[i] >> A[i];
    }

    long long vote_t = 1, vote_a = 1;
    for (int i = 0; i < N; ++i) {
        long long n_t, n_a;
        if (vote_t % T[i] == 0) {
            n_t = vote_t / T[i];
        } else {
            n_t = vote_t / T[i] + 1;
        }
        if (vote_a % A[i] == 0) {
            n_a = vote_a / A[i];
        } else {
            n_a = vote_a / A[i] + 1;
        }
        long long n = max(n_t, n_a);
//        cout << "n_t" << n_t << " n_a" << n_a << endl;
//        cout << "n: " << n << endl;
        vote_t = T[i] * n;
        vote_a = A[i] * n;
//        cout << vote_t << " " << vote_a << endl;
    }

    cout << vote_t + vote_a << endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;

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

    int n;
    string s;
    cin >> n >> s;

    vector <int> white(n+1, 0);
    vector <int> black(n+1, 0);
    for (int i = 0; i < n; i++) {
        if (s[i] == '#') black[i+1]++;
        black[i+1] += black[i];
    }

    for (int i = n-1; i >= 0; i--) {
        if (s[i] == '.') white[i]++;
        white[i] += white[i+1];
    }

    int ans = n;
    for (int k = 0; k <= n; k++) {
        ans = min(ans, black[k] + white[k]);
    }

    cout << ans << "\n";
    return 0;
}

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

using namespace std;

int main()
{
	vector<int>a;
	int t;
	for(int i=1;i<=3;i++)
	{
		cin>>t;
		a.push_back(t);
	}
	
	sort(a.begin(),a.end());
	
	cout<<a.at(0)<<" "<<a.at(2)<<endl;



	return 0;
}


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

const int N = 310;

int mat[N][N], dis[N][N];

int main(){
	int n;
	scanf("%d", &n);
	for (int i = 0; i < n; ++ i){
		for (int j = 0; j < n; ++ j){
			scanf("%d", &mat[i][j]);
			dis[i][j] = mat[i][j];
		}
	}
	for (int k = 0; k < n; ++ k){
		for (int i = 0; i < n; ++ i){
			for (int j = 0; j < n; ++ j){
				if (i == j || i == k || j == k) continue;
				dis[i][j] = std::min(dis[i][j], dis[i][k] + dis[k][j]);
			}
		}
	}
	long long ans = 0;
	for (int i = 0; i < n; ++ i){
		for (int j = 0; j < n; ++ j){
			if (dis[i][j] != mat[i][j]){
				return printf("-1\n"), 0;
			}
			bool flag = true;
			for (int k = 0; k < n; ++ k){
				if (i == k || i == j || k == j) continue;
				if (dis[i][k] + dis[k][j] == dis[i][j]){
					flag = false;
					break;
				}
			}
			if (flag) ans += mat[i][j];
		}
	}
	return printf("%lld\n", ans >> 1), 0;
}

Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    string S; cin >> S;
    if (N % 2 == 1) {
        cout << "No" << endl;
        return 0;
    }
    rep(i, N / 2) {
        if (S[i] != S[i + N / 2]) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;

    return 0;
}


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

#define int long long
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)

using namespace std;

const unsigned int M = 1e9 + 7;

int32_t main() {
	fastio;

	int n;
	cin >> n;
	int a[n];
	for(int i = 0; i < n; ++i) cin >> a[i];
	int freq[100001], sum = 0;
	memset(freq, 0, sizeof(freq));
	for(int i = 0; i < n; ++i) ++freq[a[i]], sum += a[i];
	int q;
	cin >> q;
	while(q--) {
		int b, c;
		cin >> b >> c;
		sum -= b * freq[b], sum += c * freq[b];
		freq[c] += freq[b], freq[b] = 0;
		cout << sum << '\n';
	}

	return 0;
}

/*
Pre-computing sum gives 1+2+3+4
* Now, to remove 1 and add 2 -> (1+2+3+4) - (1) + (2)
* Similarly to remove 3 and add 2 now, current sum - 3 + 2
* And so on
But for this problem, there are multiple instances of same number
* So, it makes sense to pre-compute frequencies
* For each query, we subtract b times the frequency of b, and add c times the frequency of b
* Now, the frequency of c increases by the frequency of b and frequency of b is zero
*/


Measured memory_bytes: 5100
#include<iostream>
#include<stdio.h>
using namespace std;

int main() {
	double d;
	while (cin >> d) {
		double n=d;
		for (int i = 2; i <= 10; i++) {
			if (i % 2 == 0) {
				n = n * 2;
			}
			else if (i % 2 == 1) {
				n = n / 3;
			}
			d += n;
		}
		printf("%.8lf\n", d);
	}
}


Measured memory_bytes: 3088
s = int(input())
a=[s]
for i in range(1000000):
    if a[-1]%2 == 0:
        a2 = int(a[-1] /2)
        if a2 in a:
            print(i +2)
            break
        a.append(a2)
            
    else:
        a2 = a[-1]*3 + 1
        if a2 in a:
            print(i + 2)
            break
        a.append(a2)

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

#include <math.h>
#include <stdlib.h>


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

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_MAX	2,147,483,647 = 2*1.0e9

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    string S;    cin >> S;
    int ans = 0;
    for(int i = 0; i <4; i++){
        if(S[i] == '+') ans++;
        else ans--;
    }

    cout << ans << endl;

    return 0;
}


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

using namespace std;

#define be begin
#define en end
 
double calc_path(const vector<int> x,const vector<int> y,const vector<int> ind)
{
  double path=0;
  for(int i=0; i<ind.size()-1; i++){
    int t1 = ind[i];
    int t2 = ind[i+1];
    path += sqrt((x[t1]-x[t2])*(x[t1]-x[t2]) + (y[t1]-y[t2])*(y[t1]-y[t2]));
  }
  return path;
}
int main(){
	int n;
	cin>>n;
	vector<int> x(n),y(n);
	vector<int> index(n);
	for(int i=0; i<n; i++){
		cin>>x[i]>>y[i];
		index[i] = i;
	}

  int cnt = 0;
  double total = 0.;
	do{
    total+=calc_path(x,y,index);
    cnt++;
	}while(next_permutation(index.be(), index.en()));
  cout<<fixed;
  cout<<setprecision(10)<<total/double(cnt)<<endl;
	return 0;
}

Measured memory_bytes: 256