akhauriyash/Code-Regression huggingface dataset:
import heapq

N, M = tuple(map(int, input().split()))
A = list(map(int, input().split()))
BC = []
for _ in range(M):
    BC.append(tuple(map(int, input().split())))

BC.sort(key=lambda x: x[1], reverse=True)
heapq.heapify(A)
for (b, c) in BC:
    for _ in range(b):
        min_val = A[0]
        if min_val < c:
            heapq.heappop(A)
            heapq.heappush(A, c)
        else:
            break
print(sum(A))

Measured memory_bytes: 97204
#include <stdio.h>
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define max(a,b) (a>b?a:b)

int main(){
    int n;scanf("%d",&n);
    int a[101010],cnt[101010]={0};
    rep(i,n) scanf("%d",a+i);
    rep(i,n){
        cnt[a[i]]++;
        cnt[a[i]+1]++;
        if(a[i]>0)cnt[a[i]-1]++;
    }
    int ans=0;
    rep(i,100001){
        ans=max(ans,cnt[i]);
    }
    printf("%d",ans);
}

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

typedef pair<int, int> P;

struct unionfind {

    int par[10005];
    int rank[100005];

    void init (int N) {
        for(int i=0; i<N; i++) {
            par[i]=i;
            rank[i]=0;
        }
    }

    int  root(int x) {
        if(par[x]==x) {
            return x;
        }
        else {
            return par[x]=root(par[x]);
        }
    }

    void unite (int x, int y) {
        x=root(x);
        y=root(y);
        if(x==y) return;
        if(rank[x]<rank[y]) {
            par[x]=y;
        }
        else {
            par[y]=x;
            if(rank[x]==rank[y]) rank[x]++;
        }
    }

    bool same(int x, int y) {
        return root(x)==root(y);
    }
};

int main() {
    int n, m, a, b, ans=0;
    cin >> n >> m;
    unionfind tree;
    vector<P> vec(m);
    for(int i=0; i<m; i++) {
        cin >> a >> b;
        a--; b--;
        vec[i]=P(a,b);
    }
    for(int i=0; i<m; i++) {
        tree.init(n);
        bool flag=false;
        for(int j=0; j<m; j++) {
            if(i==j) continue;
            a=vec[j].first;
            b=vec[j].second;
            tree.unite(a,b);
        }
        for(int j=0; j<n; j++) {
            for(int k=0; k<n; k++) {
                if(!(tree.same(j, k))) {
                    ans++;
                    flag=true;
                    break;
                }
            }
            if(flag) break;
        }
    }
    cout << ans;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        List<List<Integer>> g = new ArrayList<>();
        for (int i= 0; i < N; i++) {
            g.add(new ArrayList<>());
        }
        for (int i = 0; i < M; i++) {
            int A = sc.nextInt()-1;
            int B = sc.nextInt()-1;
            g.get(A).add(B);
            g.get(B).add(A);
        }

        int[] mark = new int[N];
        for (int i = 0; i < N; i++) {
            mark[i] = -1;
        }

        LinkedList<Integer> q = new LinkedList<>();
        q.offer(0);
        while (!q.isEmpty()) {
            int now = q.poll();
            List<Integer> next = g.get(now);
            for (int n : next) {
                if (n == now) continue;
                if (mark[n] == -1) {
                    q.add(n);
                    mark[n] = now;
                }
            }
        }

        System.out.println("Yes");
        StringBuilder ans = new StringBuilder();
        for (int i = 1; i < N; i++) {
            ans.append(mark[i]+1).append('\n');
        }
        System.out.print(ans);
    }
}


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

// グローバル変数
int n;
vector<int> c;

// 関数プロトタイプ
void input();
void solve();

int main(void)
{
    input();
    solve();  
}

// 標準入力
void input() {
    cin >> n;
    c.resize(n);
    for (int i = 0; i < n;i++) {
        cin >> c[i];
    }
}

void solve() {
    int alice = 0;
    int bob = 0;
    sort(c.begin(), c.end(), greater<int>());
    for (int i = 0; i < n;i++) {
        if(i%2 ==0) 
            alice += c[i];
        else
            bob += c[i];
    }
    cout << alice - bob << endl;
}

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

using namespace std;

int main() {
  long long n;
  cin >> n;
  map<long long, long long> mp;

  long long sum = 0;
  for(long long i = 0; i < n; i++){
    long long a;
    cin >> a;
    mp[a]++;

    sum += a;
  }

  int q;
  cin >> q;
  vector<long long> ans(q);

  for(long long i = 0; i < q; i++){
    long long b, c;
    cin >> b >> c;

    sum = sum - b*mp[b] + c*mp[b];

    ans[i] = sum;

    mp[c] += mp[b];
    mp[b] = 0;
  }

  for(long long i = 0; i < q; i++){
    cout << ans[i] << endl;
  }

   return 0;
}

Measured memory_bytes: 9968
#include <iostream>
using namespace std;
bool judge(int);

int main(void){
	int N,count=0;
	cin >> N;

	for(int i=1;i<=N;i+=2){
		if(judge(i))
			count++;
	}
	cout << count << endl;
}

bool judge(int N){
	int count=0;
	for(int i=1;i<=N;i+=2){
		if(N%i==0)
			count++;
	}
	return count==8?true:false;
}

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

using vi = vector<int>;
using vvi = vector<vector<int>>;
using vvvi = vector<vector<vector<int>>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using vvvll = vector<vector<vector<ll>>>;
using vd = vector<double>;
using vvd = vector<vector<double>>;
using vvvd = vector<vector<vector<double>>>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vs = vector<string>;
using pint = pair<int, int>;
using Graph = vvi;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

bool cmp(pint a, pint b) {return a.second < b.second;}
void YN(bool flg) {cout<<(flg?"YES":"NO")<<'\n';}
void Yn(bool flg) {cout<<(flg?"Yes":"No")<<'\n';}
void yn(bool flg) {cout<<(flg?"yes":"no")<<'\n';}

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

    int ans = 0;
    rep(i, sqrt(n) + 1) {
        if(i * i <= n) ans = max(ans, i * i);
        else break;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
import sys
import collections
import itertools
import math
import re
from collections import deque

MOD = 10 ** 9 + 7

N, X = [int(x) for x in input().split()]
ML = 51
P = [0] * ML
A = [0] * ML

P[0] = 1
A[0] = 1

for i in range(1, ML):
    P[i] = 2 * P[i - 1] + 1
    A[i] = 2 * A[i - 1] + 3


def f(n, x):
    if x <= 0:
        return 0
    if n == 0:
        return 1

    r = 0
    if x <= 1 + A[n - 1]:
        r = f(n - 1, x - 1)
    elif x == 2 + A[n - 1]:
        r = 1 + P[n - 1]
    else:
        r = f(n - 1, x - 2 - A[n - 1]) + 1 + P[n - 1]

    return r


r = f(N, X)

print(r)


Measured memory_bytes: 3700
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <functional>

#ifdef LOCAL
	#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
	#define eprintf(...) 42
#endif

#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define repp(i, m, n) for(ll i = m, i##_len = (n); i < i##_len; ++i)
#define reprev(i, n) for(ll i = (n-1LL); i >= 0; --i)
#define all(x) (x).begin(), (x).end()
template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> P;
typedef long double ld;

int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	bool first = false;
	rep (i, n) {
		int a;
		cin >> a;
		first |= (a % 2 != 0);
	}
	cout << (first ? "first" : "second") << "\n";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pii;
typedef pair<ll, ll> pll;
typedef vector<ll> vii;
typedef vector<ll> vll;

#define X first
#define Y second
#define rep(i,n) for(ll i=0; i<(n); i++)
#define repp(i,ed,b) for(ll i=ed; i<=(b); i++)
#define repp2(i,b,ed) for(ll i=b; i>=(ed); i--)
#define fill(ed,val) memset(ed, (val), sizeof(ed))
#define mp make_pair
#define pb push_back
#define sz(x) (ll)x.size()
#define all(c) (c).begin(), (c).end()
#define uni(c) c.resize(distance(c.begin(), unique(all(c))))
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);
#define sc(n) scanf("%lld",&n)

ll mod= 1e9 + 7, mod1=1e9+9;
const ll N=100005,MAX=2e9+5;



int main()
{   
    io;
    
    string s="CODEFESTIVAL2016";
    string s1;
    cin>>s1;
    int cn=0;
    rep(i,sz(s1))if(s1[i]!=s[i])cn++;
    cout<<cn;
    
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <string.h>
#include <ctype.h>
#include <algorithm>

using namespace std;

int main() {
  string s;
  cin >> s;
  
  if(s[0] == s[1] & s[2] == s[3] & s[0] != s[2])
    cout << "Yes" << endl;
  else if(s[0] == s[2] & s[1] == s[3] & s[0] != s[1])
    cout << "Yes" << endl;
  else if(s[0] == s[3] & s[1] == s[2] & s[0] != s[1])
    cout << "Yes" << endl;
  else cout << "No" << endl;
  
}

Measured memory_bytes: 3596
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <functional>
#include <vector>
#include <queue>
#include <map>

using namespace std;

typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)

int A, B, K;

int main() {
  scanf("%d %d %d", &A, &B, &K);

  int c = 1;
  FORR(i, min(A, B) + 1, 1) {
    if (A % i == 0 && B % i == 0) {
      if (c == K) {
        printf("%d\n", i);
        return 0;
      }
      c++;
    }
  }
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {
    static class FastReader{
        BufferedReader br,br1;
        StringTokenizer st;
        public FastReader() {br = new BufferedReader(new InputStreamReader(System.in));}
        public FastReader(String fileName) throws FileNotFoundException{br = new BufferedReader(new FileReader(fileName));}
        String next() {while (st == null || !st.hasMoreElements()){try{st = new StringTokenizer(br.readLine());}catch (IOException  e){e.printStackTrace();}}return st.nextToken();}
        int nextInt() {return Integer.parseInt(next());}
        long nextLong() {return Long.parseLong(next());}
        double nextDouble() {return Double.parseDouble(next());}
        char[][] readCharArray(int n, int m) {
        	String str;
        	char[][] arr = new char[n][m];
        	for(int i = 0; i < n; ++i) {
        		str=nextLine();
        		for(int j = 0;j < n; ++j) {
        			arr[i][j] = str.charAt(j);
        		}
        	}
        	return arr;
        }
        char[][] readCharArray(int n) {
        	return readCharArray(n,n);
        }
        int[] readArray(int n) {int[] a = new int[n]; for (int i = 0; i < n; ++i) a[i] = nextInt(); return a;}
        long[] readLongArray(int n) {long[] a=new long[n];for (int i = 0; i < n; ++i) a[i] = nextLong(); return a;}
        String nextLine() {String str = "";try{str = br.readLine();} catch (IOException e){e.printStackTrace();} return str;}
    }
    public static void main(String[] args) throws NumberFormatException, IOException {
        FastReader fs = new FastReader();
        PrintWriter out = new PrintWriter(System.out);
        int n = fs.nextInt();
        int ans = 0, cnt1 = -1;
        for (int i = 1; i <= n; ++i) {
            int temp = i;
            int cnt = 0;
            while (temp % 2 == 0) {
                temp /= 2;
                ++cnt;
            }
            if (cnt >= cnt1) {
                cnt1 = cnt;
                ans = i;
            }
        }
        out.println(ans);
        out.close();
    }

}

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

using namespace std;

#define REP(i, n) for(int i = 0; i < (n); i++)
#define SREP(i, s) for(int i = 0; i < (s.length()); i++)
#define SORT(v, n) sort(v, v+n);
#define GSORT(v, n) sort(v, v+n, greater<int>())
#define REV(a) reverse(begin(a),end(a));

int main(){
	ios::sync_with_stdio(false);cin.tie(0);
//////////////////////////////////////////////
	int a,b;
	cin >> a >> b;
	if(a==1) a+=999;
	if(b==1) b+=999;
	if(a==b) cout << "Draw" << endl;
	else cout << (a<b ? "Bob" : "Alice") << endl;

	
//////////////////////////////////////////////
}


Measured memory_bytes: 256
import itertools
N = input()
keta = len(N)
s = 0
for i in range(3,keta+1):
    a = itertools.product([3,5,7],repeat=i)
    for j in a:
        if 3 in j and 5 in j and 7 in j:
            if int("".join(map(str,j)))<= int(N):
                s +=1
print(s)

Measured memory_bytes: 9156
#include<bits/stdc++.h>
using namespace std;
int n,k[4],c[]={10,50,100,500},an[4],t[4],mm;
void dfs(int d,int s,int m){
  if(d==4){
    if(s>=n){
      int a=s-n;
      for(int i=3;i>=0;i--){
	  int p=a/c[i];
	  if(p&&t[i])m=1000000;
	  m+=p;
	  a%=c[i];
	}
      if(m<mm){
	mm=m;
	for(int i=0;i<4;i++)an[i]=t[i];
      }
    }
    return;
  }
  for(int i=0;i<=k[d];i++)
    t[d]=i,dfs(d+1,s+i*c[d],m+k[d]-i);
}

int main(){
  int y=0;
  while(cin>>n&&n){
    if(y++)cout<<endl;
    for(int i=0;i<4;i++)cin>>k[i],an[i]=t[i]=0;
    mm=100000;
    dfs(0,0,0);
    for(int i=0;i<4;i++)
      if(an[i]) cout<<c[i]<<" "<<an[i]<<endl;
  }
    return 0;
}

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

signed main() {
  int A, B, C;
  cin >> A >> B >> C;
  
  if ( A % 2 == 0 || B % 2 == 0 || C % 2 == 0 ){
    cout << 0 << endl;
  }else{
    vector<int> zyun(3);
    zyun = { A, B, C };
    sort(zyun.begin(), zyun.end());
    cout << zyun.at(0) * zyun.at(1) << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
  int n, t;
  int ans =10000;
  cin >> n >> t;
  for(int i=0;i<n;i++){
    int ci, ti;
    cin >> ci >> ti;
    if(ti <= t && ci < ans){
      ans = ci;
    }
  }
  if(ans!=10000){
    cout << ans << endl;
  }else{
    cout << "TLE" << endl;
  }
}

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

int sum(int S[], int begin, int end) {
    int ans = 0;
    for (int i = begin; i < end; ++i) {
        ans += S[i];
    }
    return ans;
}

int main() {

    int n, k;
    for (;;) {
        cin >> n >> k;
        if (n == 0 && k == 0) break;

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

        int dummy = sum(S, 0, k);
        int m = n - k + 1;
        int tmp = 0;
        int ans = dummy;
        for (int i = 1; i < m; ++i) {
            int tmp = dummy - S[i - 1] + S[i + k - 1];
            dummy = tmp;
            if (ans < tmp) ans = tmp;
        }

        cout << ans << endl;
    }

    return 0;
}

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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()

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

  ll A,B,K;
  cin>>A>>B>>K;
  if(A>=K){
    cout<<A-K<<" "<<B<<endl;
  }
  else{
    cout<<0<<" "<<max(B-(K-A),0ll)<<endl;
  }
  return 0;
}


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


 int main() {
 int A, B, C;
   cin >> A >> B >> C;
   if(A < C && C < B) {
     cout << "Yes" << endl;
   }
   else if(B < C && C < A) {
     cout << "Yes" << endl;
   }
   else { 
     cout << "No" << endl;
   }
   
   
   
   return 0;
 }
   
  

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

#define endl "\n"
#define f first
#define s second
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll,ll>
#define ll long long
#define faster ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

const ll M = 998244353;
const int N = 2005;
const int K = 3000;
const ll INF = 1e18;

ll n,m,q;
int a[N][N],c[N][N],r[N][N],cnt[N][N],x1,x2,y1,y2;
char w;

int main () {
	faster
	cin>>n>>m>>q;
	for (int i = 1; i<=n; i++) {
		for (int j = 1; j<=m; j++) {
			cin>>w;
			if (w == '1') a[i][j] = 1;
		}
	}
	for (int i = 1; i<=n; i++) {
		for (int j = 1; j<=m; j++) {
			c[i][j] = c[i-1][j] + c[i][j-1] - c[i-1][j-1] + (a[i][j] == a[i][j-1] && a[i][j] == 1);
			r[i][j] = r[i-1][j] + r[i][j-1] - r[i-1][j-1] + (a[i][j] == a[i-1][j] && a[i][j] == 1);
			cnt[i][j] = cnt[i-1][j] + cnt[i][j-1] - cnt[i-1][j-1] + a[i][j];
		}
	}
	for (int i = 1; i<=q; i++) {
		cin>>x1>>y1>>x2>>y2;
		ll ans = 0;
		ans += cnt[x2][y2] - cnt[x2][y1-1] - cnt[x1-1][y2] + cnt[x1-1][y1-1];
		ans -= c[x2][y2] - c[x2][y1] - c[x1-1][y2] + c[x1-1][y1];
		ans -= r[x2][y2] - r[x1][y2] - r[x2][y1-1] + r[x1][y1-1];
		cout<<ans<<endl;
	}

    return 0;
}


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

  stack<int>st;
  char s[3000];
  int a,b;
int main(){
  while(scanf("%s",s) != EOF ){
    if(s[0]=='+'){
      a=st.top();
      st.pop();
      b=st.top();
      st.pop();
      st.push(a+b);
    }
    else if(s[0]=='-'){
      a=st.top();
      st.pop();
      b=st.top();
      st.pop();
      st.push(b-a);
    }
    else if(s[0]=='*'){
      a=st.top();
      st.pop();
      b=st.top();
      st.pop();
      st.push(a*b);
    }
    else st.push(atoi(s));
  }
  cout<<st.top()<<endl;
}

Measured memory_bytes: 1212
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, o, n) for (auto i = (o); (i) < (n); ++(i))
#define FOR1(i, n) FOR(i, 1, n+1)
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (auto i = (n)-1; (i) >= 0; --i)
#define REPI(itr, v) for (auto itr = v.begin(); itr != v.end(); ++itr)
#define REPIR(itr, v) for (auto itr = v.rbegin(); itr != v.rend(); ++itr)
#define fi first
#define se second
#define ll long long
#define int long long
#define V2(name, h, w) vector<vector<int> > name((h), vector<int>(w));
#define myCeil(dividend, divisor) ceil((double)(dividend) / (double)(divisor))
#define myFloor(dividend, divisor) floor((double)(dividend) / (double)(divisor))
#define calcDigits(num) floor(log10(num))+1

#define dl(line) cerr << "RUN: until " << (line) << "th line." << endl;
#define dv(name, value) cerr << (name) << " is " << (value) << endl;
#define da(v)  cerr << "["; REPI(itr, v){cerr << *itr << (itr != --v.end() ? ", " : "");} cerr << "]" << endl;
#define dpa(v) cerr << "[ " << endl;REPI(itr, v) { cerr << "  [" << (*itr).first << ", " << (*itr).second << ']' << (itr != --v.end() ? "," : "") << endl; } cerr << "]" << endl;


void solve(std::string S){
  if (S == "ABC") {
    cout << "ARC" << endl;
  } else {
    cout << "ABC"<<  endl;
  }
}

signed main(){
  std::string S;
  std::cin >> S;
  solve(S);
}


Measured memory_bytes: 3632
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
#define rep(begin, i, end) for (ll i = begin; i < (ll)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

int main()
{
    string s;
    cin >> s;
    if (s.at(s.size() - 1) == 's')
    {
        s += "es";
    }
    else
    {
        s += 's';
    }

    cout << s << endl;
}

Measured memory_bytes: 3632
#include<stdio.h>

int main(void){
    int a,b;
    scanf("%d %d",&a,&b);
    int diff = b-a;
    int i = 1;
    int sum=0;
    while(i<diff){
        sum+=i;
        i++;
    }
    sum -= a;
    printf("%d",sum);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
char a,b;
bool c,d;
string s;
int main()
{
	cin >>s;
	a=s[0];
	if(s[0]==s[1])
	{
		c=true;
		b=s[2];
		if(s[2]==s[3])
		d=true;
		else
		d=false;
	}
	else
	{
		if(s[0]==s[2])
		{
			c=true;
			if(s[1]==s[3])
			d=true;
			else
			d=false;
		}
		else if(s[0]==s[3])
		{
			c=true;
			if(s[1]==s[2])
			d=true;
			else
			d=false;
		}
		else
		{
			c=false;
			d=false;
		}
	}
	puts((c&&d&&(a!=b)?"Yes":"No"));
}

Measured memory_bytes: 256
using System;

namespace test
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            int k=int.Parse(Console.ReadLine());
            string s = Console.ReadLine();
            if (s.Length > k)
            {
                for (int i = 0; i < k; i++)
                {
                    Console.Write(s[i]);
                }
                Console.WriteLine("...");
            }
            else {
                Console.WriteLine(s);
            }

        }
    }
}


Measured memory_bytes: 27544
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld = long double;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REV(c) reverse(ALL(c))
#define sz(v) (int)v.size()
#define endl '\n'
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;}
template<class T> inline void printv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << (i == n - 1 ? endl : ' ');}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
 
void solve();
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

void solve() {
    int n;
    cin >> n;
    multiset<int> s;
    int a;
    REP(i, n) {
        cin >> a;
        if (s.empty()) {
            s.emplace(a);
            continue;
        }
        auto p = s.lower_bound(a);
        if (p == s.begin()) {
            s.emplace(a);
        } else {
            p--;
            s.erase(p);
            s.emplace(a);
        }
    }
    cout << sz(s) << endl;
}


Measured memory_bytes: 4992
import math

N, D = map(int, input().split())
point = []

for _ in range(N):
    point.append(tuple(map(int, input().split())))

ret = 0
for i in range(N):
    for j in range(i + 1, N):
        d = 0
        for a, b in zip(point[i], point[j]):
            d += (a - b) ** 2

        t = math.floor(math.sqrt(d))
        if t * t == d:
            ret += 1

print(ret)

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

int calc(int x){
  int ret = 0;
  while(x%100 == 0){
    x /= 100;
    ret++;
  }
  return ret;
}

int main(){
  int D, N;
  cin >> D >> N;
  int count=0, val=0;

  while(count < N){
    val++;
    if(calc(val) == D) count++;
  }
  cout << val << endl;
  return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize(3)
#include<bits/stdc++.h>
#define int long long
#define F first
#define S second
#define P pair
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define V vector
#define RE return
#define ALL(a) a.begin(),a.end()
#define MP make_pair
#define PB push_back
#define PF push_front
#define FILL(a,b) memset(a,b,sizeof(a))
using namespace std;
P<int,int> p[100005];
set<int> s;deque<int> v;
int n; 
signed main(){
	ios::sync_with_stdio(0);
    cin.tie(0);
    cin>>n;
    FOR(i,1,n)cin>>p[i].F,p[i].S=i;
    int t=0,ans=0;
    sort(p+1,p+n+1,greater<P<int,int> >());
    FOR(i,1,n){
    	s.insert(p[i].S);if(i==1)continue;
    	set<int>::iterator t=s.lower_bound(p[i].S),iter=t;
    	v.clear();
    	v.PB(*iter);
    	int tl=0;
    	for(int j=0;j<2&&iter!=s.begin();j++){
    		iter--;v.PF((*iter));tl++;
    	}
    	iter=t;iter++;
    	for(int j=0;j<2&&iter!=s.end();j++){
    		v.PB((*iter));iter++;
    	}
    	//for(int j=0;j<v.size();j++)cout<<v[j]<<' ';cout<<tl<<'\n';
    	if(tl){
    		int s1,s2;
    		if(tl!=1){
    			s1=v[1]-v[0];
    		}else s1=v[0];
    		if(tl!=v.size()-1){
    			s2=v[tl+1]-v[tl];
    		}else s2=n-v[tl]+1;
    		ans+=s1*s2*p[i].F;
    	}
    	if(tl!=v.size()-1){
    		int s1,s2;
    		if(tl){
                s1=v[tl]-v[tl-1];
            }else s1=v[tl];
            if(tl!=v.size()-2){
                s2=v[tl+2]-v[tl+1];
            }else s2=n-v[tl+1]+1;
            ans+=s1*s2*p[i].F;
    	}
    }
    cout<<ans;
	RE 0;
}

Measured memory_bytes: 6528
import math
n = input()
a = list(map(int, input().split()))
b  = 0
cnt = 0
while "loop":
    for num in a:
        if num % 2 == 1:
            b= 1
    if  b == 0:
            a = [ i	/2 for i in a]
            cnt += 1
    else:
        break
print(cnt)


Measured memory_bytes: 3060
#include <iostream>
#include <map>
#include <set>
using namespace std;

#define TOP 2
#define RIGHT 1

typedef pair<int,int> P;

map<P, P> graph; //テ」ツ?ゥテ」ツ?ョテ」ツつサテ」ツδォテ」ツ?古」ツ?ゥテ」ツ?ョテ」ツつサテ」ツδォテ」ツ?ィテァツケツ凝」ツ?古」ツ?」テ」ツ?ヲテ」ツ??」ツつ凝」ツ??
set<P> isLeg;    //ティツカツウテ」ツ?ョテ、ツスツ催ァツスツョテ」ツつ津ィツィツ佚ヲツ?カ
set<P> isHead;   //テゥツ?ュテ」ツ?ョテ、ツスツ催ァツスツョテ」ツつ津ィツィツ佚ヲツ?カ

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

bool dfs(P leg, P head){
  isLeg.insert(leg);
  isHead.insert(head);

  for(int i = 0; i < 4; i++){
    P nleg(leg.first + dx[i], leg.second + dy[i]);

    if(nleg == head) continue;
    if(isHead.find(nleg) != isHead.end()) return false;
    if(isLeg.find(nleg) != isLeg.end()) continue;
    if(graph.find(nleg) == graph.end()) continue;

    P nhead = graph[nleg];

    if(!dfs(nleg, nhead)) return false;
  }

  for(int i = 0; i < 4; i++){
    P nhead(head.first + dx[i], head.second + dy[i]);

    if(nhead == leg) continue;
    if(isHead.find(nhead) != isHead.end()) continue;
    if(isLeg.find(nhead) != isLeg.end()) return false;
    if(graph.find(nhead) == graph.end()) continue;

    P nleg = graph[nhead];

    if(!dfs(nleg, nhead)) return false;
  }

  return true;
}

bool solve(){
  isHead.clear();
  isLeg.clear();

  map<P, P>::iterator iter = graph.begin();

  for( ; iter != graph.end(); iter++){
    P head = iter->first;
    P leg = iter->second;

    if(isLeg.find(head)  != isLeg.end())  continue;
    if(isHead.find(head) != isHead.end()) continue;

    if(!dfs(leg, head)) return false;
  }

  return true;
}

int main(){
  int n;

  while(cin >> n, n){
    graph.clear();

    for(int i = 0; i < n; i++){
      int x, y;
      char dir;
      cin >> x >> y >> dir;

      if(dir == 'x'){
        int nx = x + dx[RIGHT];
        int ny = y + dy[RIGHT];
        graph[P(x, y)]   = P(nx, ny);
        graph[P(nx, ny)] = P(x, y);
      }
      else{
        int nx = x + dx[TOP];
        int ny = y + dy[TOP];
        graph[P(x, y)]   = P(nx, ny);
        graph[P(nx, ny)] = P(x, y);
      }
    }

    cout << (solve() ? "Yes" : "No") << endl;
  }
}

Measured memory_bytes: 8056
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n;
	scanf(" %d", &n);
	
	int cnt1 = 0, cnt2 = 0, cnt3 = 0;
	for(int i = 0; i < n; i++) {
		int a;
		scanf(" %d", &a);

		if(a % 4 == 0) {
			cnt1++;
		}
		else if(a % 2 != 0) {
			cnt2++;
		}
		else if(a % 2 == 0) {
			cnt3++;
		}
	}

	if(cnt1 >= cnt2) {
		printf("Yes\n");
	}
	else if(cnt2 == cnt1 + 1 && cnt3 == 0) {
		printf("Yes\n");
	}
	else {
		printf("No\n");
	}

	return 0;
}


Measured memory_bytes: 256
if __name__ == "__main__":
    AB, BC, CA = tuple(map(int, input().split(" ")))
    if AB ** 2 + BC ** 2 == CA ** 2:
        print(AB * BC // 2)
    elif AB ** 2 + CA ** 2 == AB ** 2:
        print(AB * CA // 2)
    else:
        print(BC * CA // 2)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#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()
#define PI 3.14159265358979323846264338327950L
using namespace std;
typedef long long ll;
typedef long double ld;
int main() {
    int x;
    cin>>x;
    if(x/100*5<x%100) cout<<0;
    else cout<<1;
}

Measured memory_bytes: 3520
from itertools import combinations_with_replacement

N, M, Q = map(int, input().split())
abcd = [list(map(int, input().split())) for _ in range(Q)]

ans = 0
for v in combinations_with_replacement(range(1, M+1), N):
    A = list(v)
    temp = 0
    for a, b, c, d in abcd:
        if A[b-1] - A[a-1] == c:
            temp += d
    ans = max(ans, temp)

print(ans)


Measured memory_bytes: 9076
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#define vll vector<ll>
#define vvvl vector<vvl>
#define vvl vector<vector<ll>>
#define VV(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define VVV(a, b, c, d) vector<vvl>(a, vvl(b, vll (c, d)));
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
using namespace std;

struct UF{
  std::vector<int> par, dep, sz, dat;
  UF(int n){
    par.resize(n+1), dep.resize(n+1), sz.resize(n+1), dat.resize(n+1);
    init(n);
  }
  void init(int nu) {
    for(int iu=0;iu<=nu;iu++){
      par[iu] = iu;
      dep[iu] = 0;
      sz[iu] = 1;
      dat[iu] = 0;
    }
  }
  int find(int xu){
    if(par[xu] == xu) return xu;
    return par[xu] = find(par[xu]);
  }
  void unite(int xu, int yu){
    xu=find(xu);
    yu=find(yu);
    if(xu == yu) return;
    if(dep[xu] < dep[yu]){
      sz[yu] += sz[xu];
      par[xu] = yu;
      dat[yu] += dat[xu];
    }else{
      par[yu] = xu;
      sz[xu] += sz[yu];
      dat[xu] += dat[yu];
      if(dep[xu] == dep[yu]) dep[xu]++;
    }
  }
  bool same(int xu, int yu){ return find(xu) == find(yu);}
  int get_size(int x){return sz[find(x)];}
};

int main(int argc, char const *argv[]) {
  ll n, h, w;std::cin >> n >> h >> w;
  UF uf(h+w+1);
  vvl d = VV(n, 3, 0, ll);// num x y
  for(int i=0;i<n;i++){
    scanf("%lld %lld %lld", &d[i][1], &d[i][2], &d[i][0]);
    d[i][1]--;
    d[i][2]--;
  }
  sort(all(d));
  reverse(all(d));
  ll ans = 0;

  for(int i=0;i<n;i++){
    ll x = d[i][1], y = d[i][2]+h;

    if(uf.same(x, y)){
      // 元から連結なら、辺が超えていないか確認
      ll p = uf.find(x);
      if(uf.dat[p]<uf.sz[p]){
        ans += d[i][0];
        uf.dat[p]++;
      }
    }else{
      //違う場合、どちらかに余裕があればマージできる
      ll px = uf.find(x);
      ll py = uf.find(y);
      if(uf.dat[px]<uf.sz[px]||uf.dat[py]<uf.sz[py]){
        uf.unite(x, y);
        ll p = uf.find(x);
        ans += d[i][0];
        uf.dat[p]++;
      }
    }
  }
  std::cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 8832
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
using ll = long long;
int main(){
    string str;
    int n,k;
    cin >> n;
    cin >> str;
    cin >> k;
    char ch = str[k-1];
    for(int i=0;i<n;i++){
        if(str[i]!=ch)  cout << "*";
        else   cout << str[i];
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

#define mp make_pair
#define pb push_back
#define ll long long

//#define debug(x) ;
#define debug(x) cerr << #x << " = " << x << "\n";

const int maxN = 100011;
const int inf = 2000000001;
const ll mod = 1000000007;

ostream& operator<<(ostream& cerr, vector<ll> aux) {
    cerr << "[";
    for (auto e : aux) cerr << e << ' ';
    cerr << "]";
    return cerr;
}


ostream& operator<<(ostream& cerr, vector< pair<int, int> > aux) {
    cerr << "[";
    for (auto e : aux) cerr << e.first << ',' << e.second << ' ';
    cerr << "]";
    return cerr;
}

int n, m, i, cnt;
int x[maxN], y[maxN];
vector< pair<int, int> > robots;
vector<int> coords;
ll aib[maxN];

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

int zrs(int x) {
    return (x ^ (x - 1)) & x;
}

void add_aib(int pos, ll v) {
    while (pos <= cnt) {
        add(aib[pos], v);
        pos += zrs(pos);
    }
}

ll sum_aib(int pos) {
    ll ans = 0;
    while (pos > 0) {
        add(ans, aib[pos]);
        pos -= zrs(pos);
    }
    return ans;
}

int get_id(int x) {
    return lower_bound(coords.begin(), coords.end(), x) - coords.begin() + 1;
}

void solve () {
    int i, j, k;

    sort(robots.begin(), robots.end());
    robots.resize(unique(robots.begin(), robots.end()) - robots.begin());

    coords = {0, inf};
    for (auto e : robots) coords.pb(e.second);
    sort(coords.begin(), coords.end());
    coords.resize(unique(coords.begin(), coords.end()) - coords.begin());
    cnt = coords.size();


    add_aib(1, 1);
    for (i = 0; i < robots.size(); i = j) {
        if (robots[i].first >= inf) break;

        for (j = i; j < robots.size(); j++)
            if (robots[i].first != robots[j].first)
                break;

        for (k = j - 1; k >= i; k--) {
            int pos = get_id(robots[k].second);
            add_aib(pos, sum_aib(pos - 1));
        }
    }

    cout << sum_aib(cnt - 1);
}

int main()
{
    //freopen("test.in","r",stdin);

    scanf("%d%d", &n, &m);
    for (i = 1; i <= n; i++) scanf("%d", &x[i]);
    for (i = 1; i <= m; i++) scanf("%d", &y[i]);

    y[0] = -inf;
    y[m + 1] = inf;

    for (i = 1; i <= n; i++) {
        int pos = lower_bound(y + 1, y + m + 1, x[i]) - y - 1;
        if (pos == 0 || pos == m) {
            if (pos == 0)
                robots.pb(mp(inf, y[1] - x[i]));
            else
                robots.pb(mp(x[i] - y[m], inf));
        } else {
            robots.pb(mp(x[i] - y[pos], y[pos + 1] - x[i]));
        }
    }


    solve();

    return 0;
}

Measured memory_bytes: 3060
#include <algorithm>
#include <iostream>
#include <cmath>
#include <set>
#include <string>
#include <vector>

using namespace std;
using LLONG = long long;

int main()
{
    int N;
    cin >> N;
    for (int i = 0; i < N; ++i)
    {
        char ch;
        cin >> ch;
        if (ch == 'Y')
        {
            cout << "Four" << endl;
            return 0;
        }
    }
    cout << "Three" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define io ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define PI atan(1)*4
typedef long long int ll;
using namespace std;
int main(){
	io;
    int n,m;
    cin >> n >> m;
    int summ = 0;
    for(int i = 0;i < m;++i){
    	int a;
    	cin >> a;
    	summ += a;
	}
	if(summ > n){
		cout << "-1";
	}
	else{
		cout << n-summ;
	}
	return 0;
} 

Measured memory_bytes: 3656
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <cassert>
#include <exception>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<P> vp;
#define rep(i,a,n) for(ll i = (a);i < (n);i++)
#define per(i,a,n) for(ll i = (a);i > (n);i--)
#define lep(i,a,n) for(ll i = (a);i <= (n);i++)
#define pel(i,a,n) for(ll i = (a);i >= (n);i--)
#define clr(a,b) memset((a),(b),sizeof(a))
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define sz size()
#define print(X) cout << (X) << endl
const ll INF = 1e+9+7;
ll n,m,l;
string s,t;
ll d[200010],dp[550][550];

int main(){
  cin >> n >> m;
  l = 0;
  rep(i,0,n)cin >> d[i];
  rep(i,0,n){
    if(d[i] > abs(d[i]-m))l += 2 * abs(d[i]-m);
    else l += 2 * d[i];
  }
  print(l);
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,string>;
using Map = map<string,ll>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;


int main(){
  ll N;
  cin >> N;
  ll A;
  cin >> A;
  ll B;
  cin >> B;
  cout<<min(N*A,B)<<endl;
return 0;
}


Measured memory_bytes: 256
def Con(V,E):
  C1,C2=set(),set()
  C1.add(1)
  while len(C1)>len(C2):
    for v in V:
      if v in C1 and v not in C2:
        for e in E:
          if e[0]==v:
            C1.add(e[1])
          elif e[1]==v:
            C1.add(e[0])
        C2.add(v)
  if len(C1)==len(V):
    return True
  else:
    return False
n,m=map(int,input().split())
V=[int(i) for i in range(1,n+1)]
E=[]
for i in range(m):
  s,g=map(int,input().split())
  E.append([s,g])
ans=0
for i in range(m):
  if Con(V,E[:i]+E[i+1:])==False:
    ans+=1
print(ans)

Measured memory_bytes: 3064
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

/**
 * Created by lyc on 2017/10/12.
 */
class Main {
    public static void main(String[] strings) {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        Set<Integer> set = new HashSet<>();

        while (N-- != 0) {
            int su = scanner.nextInt();
            if (!set.contains(su)) {
                set.add(su);
            }else {
                set.remove(su);
            }
        }
        System.out.print(set.size());
    }
}


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

using namespace std;

signed main()
{
  int n, m; cin >> n >> m;
  int e[m]; vector<bool> u(n+1, false);
  for(int i = 0; i < m; i++) cin >> e[i];
  for(int i = m-1; i >= 0; i--) {
    if(!u[e[i]]) cout << e[i] << endl, u[e[i]] = true;
  }
  for(int i = 1; i <= n; i++) {
    if(!u[i]) cout << i << endl;
  }

  return 0;
}

Measured memory_bytes: 3500
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=998244353;
int n;
ll ans=1;
int a[200003],b[200003];
int ord[4];
int cnt[8];
void get(int x,int y){
	ans*=cnt[x];ans%=mod;
	cnt[x]--;cnt[x+y]++;
}
int main(){
	ios::sync_with_stdio(false);
	cin >> n; string s;cin >> s;
	s='?'+s;
	cnt[0]=n;
	for(int i=1; i<=3*n ;i++){
		char c=s[i];
		if(c=='R'){
			if(cnt[6]!=0) get(6,1);
			else if(cnt[4]!=0) get(4,1);
			else if(cnt[2]!=0) get(2,1);
			else get(0,1);
		}
		else if(c=='G'){
			if(cnt[5]!=0) get(5,2);
			else if(cnt[4]!=0) get(4,2);
			else if(cnt[1]!=0) get(1,2);
			else get(0,2);
		}
		else{
			if(cnt[3]!=0) get(3,4);
			else if(cnt[2]!=0) get(2,4);
			else if(cnt[1]!=0) get(1,4);
			else get(0,4);
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 916
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define ll long long
#define ull unsigned long long
#define ld long double
#define vl vector<long long>
#define vvl vector<vector<long long>>
#define rbf(a, x) for (auto& a : x)
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define drep(i, x) for (ll i = ((ll)(x)-1); i >= 0; i--)
#define pll pair<long long,long long>
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define vvc vector<vector<char>>
#define vc vector<char>
#define vvb vector<vector<bool>>
#define vb vector<bool>
#define Maxe(x) *max_element(all(x))
#define Mine(x) *min_element(all(x))
#define Size(x) ((ll)(x).size())
#define umap unordered_map
const long long INF = 1LL << 60;
const long double pi = 3.1415926535897932;
#define Fi first
#define Se second
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

    template<typename Num>
        constexpr Num mypow(Num a, long long b) {
            if(b==0)return 1;
            if (a==0)return 0;
            Num x = 1;
              while (b > 0) {
                if(b & 1)x*=a;
                a*=a;
                b >>= 1;
              }
              return x;
        }

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

//lis,modpow,uf,modncr,soinsubunkai,yakusurekkyo
//mint,dijkstra,gyakugen

    signed main(){
        ios::sync_with_stdio(false);
        cin.tie(nullptr);
        ll n;
        string s;
        cin>>n>>s;
        vl w(n,0);
        vl b(n,0);
        ll x=0;
        rep(i,n){
            if(s[n-1-i]=='.')x++;
            b[n-i-1]=x;
        }
        x=0;
        rep(i,n){
            if(s[i]=='#')x++;
            w[i]=x;
        }
        ll res=INF;
        rep(i,n-1){
            chmin(res,w[i]+b[i+1]);
        }
        chmin(res,b[0]);
        chmin(res,w[n-1]);
        cout<<res<<endl;
    }

Measured memory_bytes: 6780
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func lowerBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

func main() {
	sc.Split(bufio.ScanWords)
	N := getInt()

	for i := 0; i < 3500; i++ {
		for j := 0; j < 3500; j++ {
			Nhn := N * i * j
			NN := 4*i*j - N*i - N*j
			if NN <= 0 {
				continue
			}
			if Nhn%NN == 0 {
				k := Nhn / NN
				out(i, j, k)
				return
			}
		}
	}
}


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

int main(int argc, const char * argv[]) {
    // insert code here...
    int a, b, h;
    cin >> a >> b >> h;
    
    int area = (a + b) * h / 2;
    
    cout << area << endl;
    
    return 0;
}


Measured memory_bytes: 256
k = int(input())
s = input()

# print(len(s))

if k >= len(s):
  print(s)

else:
  for i in range(k):
    print(s[i], end='')

  print('...')

  # print('文字の長さは ' + str(len(s)) )
  # print('表示する文字数は ' + str(k) )

Measured memory_bytes: 9096
#include <iostream>

using namespace std;
int main() {
    int i,j,n,a,b;
    int wa8,wa7,wa6,wa5,wa4,wa3,wa2,wa1,wa0,souwa;
    cin>>n;
    wa8=n/100000000;
    wa7=(n-wa8*100000000)/10000000;
    wa6=(n-wa8*100000000-wa7*10000000)/1000000;
    wa5=(n-wa8*100000000-wa7*10000000-wa6*1000000)/100000;
    wa4=(n-wa8*100000000-wa7*10000000-wa6*1000000-wa5*100000)/10000;
    wa3=(n-wa8*100000000-wa7*10000000-wa6*1000000-wa5*100000-wa4*10000)/1000;
    wa2=(n-wa8*100000000-wa7*10000000-wa6*1000000-wa5*100000-wa4*10000-wa3*1000)/100;
    wa1=(n-wa8*100000000-wa7*10000000-wa6*1000000-wa5*100000-wa4*10000-wa3*1000-wa2*100)/10;
    wa0=(n-wa8*100000000-wa7*10000000-wa6*1000000-wa5*100000-wa4*10000-wa3*1000-wa2*100-wa1*10);
    souwa=wa8+wa7+wa6+wa5+wa4+wa3+wa2+wa1+wa0;
    if((n%souwa)==0){cout<<"Yes";}
    else{cout<<"No";}



    return 0;
}

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

int main()
{
    int k = 0, x = 0,temp=0;
    cin >> k >> x;
    temp = x - (k - 1);
    for (int i = 0; i < 2*k-1; i++)
    {
        cout << temp<<" ";
        temp++;
    }
    return 0;
}

Measured memory_bytes: 256
S = input()
T = input()

counter = 0
for i in range(len(S)):
    second = 0
    group = S[i:i+len(T)]
    if len(group) < len(T):
        break
    for j in range(len(T)):
        if T[j] != group[j]:
            second += 1
    if counter == 0:
        counter = second
    elif second < counter:
        counter = second


print(counter)

Measured memory_bytes: 9036
#コピペ！！！
N = int(input())
e = [0]*(N+1)
for i in range(2, N+1):   #N!の素因数分解
    cur = i
    for j in range(2, i+1):
        while cur % j == 0:
            e[j] += 1
            cur //= j
def num(m):              # e の要素のうち m 以上のものの個数
    return len(list(filter(lambda x: x >= m-1, e)))

print(num(75) + num(25) * (num(3) - 1) + num(15) * (num(5) - 1)
+ num(5) * (num(5) - 1) * (num(3) - 2) // 2)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define  fo(i,a,b) for(ll i=a;i<b;i++)
#define rfo(i,a,b) for(ll i=a;i>=b;i--)
#define fori(it, x) for (__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
 
#define err() cout<<"----------"<<endl;
#define errA(A) for(auto i:A)   cout<<i<<" ";cout<<endl;
#define pb push_back
#define deb(x) cout<< #x << " = "<<x<<endl;
#define F first
#define S second
#define MP make_pair
#define all(x) (x).begin(), (x).end()
#define pi 3.141592653589
const ll MOD=1e9+7;
ll mod(ll x)
{
   return (x%MOD+MOD)%MOD;
   // works for neg and pos values of x.
}
ll dp[10001];
void initialize(ll x, ll y,ll z)
{
    ll n=x*x+y*y+z*z+x*y+y*z+z*x;
    if(n<10001)
    {
        dp[n]+=1;
    }
    //deb(n);
    /*deb(dp[n]);
    deb(n);
    deb(x);
    deb(y);
    deb(z);*/
 
}
void solve()
{
    ll a;
    cin>>a;
    fo(i,1,a+1)
    {
        cout<<dp[i]<<endl;;
    }
 
}
int main()
{
 
    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
//  clock_t time_req;
//  time_req = clock();
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll t=1;
    //cin>>t;
    fo(i,1,105)
    {
        fo(j,1,105)
        {
            fo(k,1,105)
            {
                initialize(i,j,k);
            }
        }
    }
    while(t--)
    {
        solve();
    }
 
// time_req = clock()-time_req;
//  cout<<"Time taken: "<<(float)time_req/CLOCKS_PER_SEC<<"s"<<endl;
 
    return 0;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main(){
  ll a;
  cin>>a;
  if(a<105){
    cout<<0<<endl;
    return 0;
  }
  if(a<135){
    cout<<1<<endl;
    return 0;
  }
  if(a<165){
    cout<<2<<endl;
    return 0;
  }
  if(a<189){
    cout<<3<<endl;
    return 0;
  }
  if(a<195){
    cout<<4<<endl;
    return 0;
  }
  cout<<5<<endl;
  return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(v) v.begin(), v.end()
#define ll long long
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<long long>;
using vvll = vector<vll>;

//snippets:tmp,cl,cvl,cs,co,coy,con,cov,setp

bool is_prime(ll x) {
  for(int64_t i = 2; i * i <= x; i++) {
    if(x % i == 0) return false;
  }
  return true;
}

int main(){
    ll n;
    cin >> n;
    ll i=2;
    ll count=0;
    ll ans=0;
    if(n==1){
        cout << 0 << endl;
        return 0;
    }
    long double nsq=sqrt(n);
    while(true){
        if(n%i==0){
            n/=i;
            count++;
        }else if(count!=0){
            ll j=1;
            while(true){
                if(j*(j+1)/2>count) break;
                else j++;
            }
            ans+=j-1;
            count=0;
            if(n==1) break;
        }else if(i>nsq){
            ans++;
            break;
        }else{
            i++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3680